Commit graph

2145 commits

Author SHA1 Message Date
Patrick Ohly
1c099e31a8 QtContacts: experimental code for "Backup" profile format as raw format
The QVersitContactHandlerFactory::ProfileBackup profile enables a
vCard flavor which contains all information stored in a QtContact. It
might make sense to use that format for raw access (--import/export).
Not currently enabled though because the format is pretty verbose.
2011-02-18 12:32:09 +01:00
Patrick Ohly
7a706b90c3 compiler: fix warnings/errors reported by clang 2.8
clang 2.8 compiles SyncEvolution + Synthesis faster than g++ 4.4.5
(3:40min instead of 4:10min on my laptop) and produces more useful
error reports. This patch fixes the code so that it compiles cleanly
with clang when using "-Wall -Werror -Wno-unknown-pragmas". Note that
clang 2.6 (Debian Squeeze) goes into an infinite recursion compiling
code using gdbus-cxx-bridge.h and dies eventually with a stack
overflow - can't be used.

Changes necessary for clang:
- eptr pointer referencing ambiguous, use *x.get() instead
- boost::intrusive_ptr* must be defined before code using it
- two-phase template checking requires explicitly specifying
  members in base classes
- name clashes with plain C structs (DBusServer, DBusWatch) are
  an error and need to be avoided (done with namespaces GDBusCXX and
  SyncEvo)
- floats cannot be inline constants
- unused methods in local classes are warned about (left() in SyncML.cpp)
2011-02-18 09:22:36 +01:00
Patrick Ohly
94cca8cb5b D-Bus C++: simplified code
A lot of the code was roled out explicitly. This patch replaces
that with an approach similar to iostreams: remember context, then
work on one parameter at a time.

Because the decision what to do with a certain method parameter
depends on the type of the parameter, that type must be used to pick
between Get/Set classes which skip resp. work on the parameter.
2011-02-17 13:27:51 +01:00
Patrick Ohly
eb3c1987c9 Curl transport: use Timespec instead of time_t + time(NULL)
Makes timeout handling resilient against system time changes and more
accurate.
2011-02-16 12:33:46 +01:00
Patrick Ohly
0969bd8ae1 local sync: use Timespec instead of time_t + time(NULL)
This makes the timeout handling resilient against system time changes
and increases accuracy.
2011-02-16 12:07:20 +01:00
Patrick Ohly
54e207f72b Timespec: C++ wrapper code for struct timespec
Allows comparison, substraction and addition. Reads monotonic and system
time. This is a better alternative to time(NULL) + time_t, because it
has sub-second resolution and (for timeouts) is resilient against manually
setting system time.
2011-02-16 12:05:17 +01:00
Patrick Ohly
067a370f40 local sync: better abort handling
When the glib event loop is left because the D-Bus client has
requested an abort, the LocalTransportAgent should simply return a
"failed" status and let the caller handle the abort. The return code
of write/readMessage() must be able to convey that - extended from
boolean to an enum.

SyncContext did not do that correctly in server mode: the check for
abort must be done before giving up by throwing an exception.

The D-Bus test now checks that the right status is recorded (wasn't
the case earlier).
2011-02-16 11:55:43 +01:00
Patrick Ohly
6a89155131 sync result: failure not reported
The final sync status is reported by the Synthesis engine as a
progress event. SyncEvolution ignored that overall status. In most
cases, it ended up using either one of its own errors (like transport
problem) or the status of a specific source as the final status of
sync.

When synchronization was aborted by the user before the first message
(as in an artificial test), then the source did not encounter a
problem and thus no error was set for the session, although it
failed. Fixed by remembering the Synthesis status code.
2011-02-16 09:37:56 +01:00
Patrick Ohly
0eb7baa89b local sync: allow running inside syncevo-dbus-server
Local sync inside syncevo-dbus-server must keep the main event
loop running, otherwise the D-Bus server would stop responding
to D-Bus calls while a sync runs.

This is tested as part of new test-dbus.py tests. They set up local
sync between two directories and then test syncing, timeout detection
when using the glib support code, and aborting via the D-Bus API
while a sync runs.

This testing depends on delaying the sync inside the child
process. Setting the SYNCEVOLUTION_LOCAL_CHILD_DELAY env variable
achieves that (might also be useful for interactive debugging). It is
set for those tests which need it via additional function properties,
similar to the older @timeout() mechanism, which now uses the
more general @property function decorator.
2011-02-15 16:50:39 +01:00
Patrick Ohly
53cd5598ff glib: emulate select() call while keeping the event loop running
LocalTransportAgent needs to wait temporarily for message transfers.
Without other activity, that is done with select(). But inside syncevo-dbus-server,
the main glib event loop must be served while waiting. GLibSelect()
does that by setting up a source which returns a) after the timeout
or b) when the file descriptor is ready for the next read or write.

As a special case, other returns from the event loop must also be reported.
2011-02-15 16:50:20 +01:00
Patrick Ohly
675fcde74c client-test: always setting "source type" is too aggressive
Doing setSourceType() unconditionally unintentionally also removed a
configured syncFormat and forceSyncFormat setting for an existing
configuration. Only setBackend() (as with this patch) is necessary
and valid in all cases (never run a test with the wrong backend!).
2011-02-14 16:47:56 +01:00
Patrick Ohly
ed64a3f067 config migration: handle inconsistent old config (type mismatch!)
If the context "type" was wrong and only the peer "type" was right,
the old config was usable for syncing. It seems that the "Memotoo"
template created such broken configs. After migration, the wrong
backend was selected based on the context's broken "type", thus
breaking syncing.

This patch fixes that problem by overriding the context "type" with
the corresponding values from one peer which has the source enabled.
The rationale is that this peer used to work and should be kept
working.

There's still a chance that different peers had different backends
configured, which is neither checked nor detected at the moment.
2011-02-14 14:39:58 +01:00
Patrick Ohly
73083348a4 SyncContext: avoid incorrect logging of timeout period in server mode
When the initial wait() in a server fails, sendStart is not yet
initialized. Set it before the wait() so that the log message give
the right duration.
2011-02-13 20:41:48 +01:00
Patrick Ohly
0df76f7e09 LocalTransport: redo output redirection
Local sync suffered from the race condition that is solved by
LogRedirect::redoRedirection(). Use that...
2011-02-13 20:41:48 +01:00
Patrick Ohly
4be48b56f0 LogRedirect: added redoRedirect()
The new call is meant to be used after forking: in such a situation,
redirected stdout/stderr output can be read by both the parent and the
child, which leads to a race condition and makes it non-deterministic
where that output will be handled. redoRedirect() closes the child's
connection to the parent's redirection and sets up its own instead.
2011-02-13 20:41:48 +01:00
Patrick Ohly
3f118591af SyncSource/Context: throwError() with specific status
So far throwError() always resulted in a STATUS_FATAL. Now
the caller can specify a specific error code.
2011-02-10 14:53:51 +01:00
Patrick Ohly
06f57b4b71 client-test: allow tests to hook into SyncContext::prepare()
The new optional callback is run as part of SyncContext::prepare().
It can be used to override additional settings as part of the sync
run.
2011-02-09 15:37:57 +01:00
Patrick Ohly
834bede321 LocalTransportAgent: implemented timeout handling
Timeouts for the SyncML message are detected on the server side.
No resending is possible, nor needed: this is a reliable local
transport after all, not HTTP.

The implementation uses select() and non-blocking sockets to time out
at the right time. While at it, it also sets CLOEXEC to ensure that
the pipes are not accidentally inherited by other child programs.
2011-02-09 15:33:20 +01:00
Patrick Ohly
40f84d7fc1 TransportAgent: simplified timeout API
Instead of allowing users of the API to register a callback
which can choose between aborting and time out, only accept
the timeout duration and always treat that as a timeout.

The advanced functionality wasn't used and the simplification
makes implementing the API easier.
2011-02-09 15:02:13 +01:00
Patrick Ohly
75c75dcf97 local sync: copy sync source status to parent
In some cases (aborted sync, source status was set to a remote error),
the child process has more detailed and accurate information about a failure
related to a source. Copy that to the parent's reports.

Patch depends on still having the LocalTransportAgent instance (moved
m_agent.reset()) and updating the source should be reflectd in final
report (moved updateSyncReport()). The later probably also was broken
for the "partial success case".
2011-02-08 12:49:14 +01:00
Patrick Ohly
157d9904aa SyncReport: added findSyncSourceReport()
In contrast to getSyncSourceReport(), findSyncSourceReport() can be
called on a const SyncReport and returns a pointer to an existing
SyncSourceReport or NULL if not present. Useful when
getSyncSourceReport() would unintentionally create the result.
2011-02-08 12:47:48 +01:00
Patrick Ohly
720a194e66 command line: fixed printing of sources (BMC #13301)
After the removal of the "type" property, listing of sources broke
because the command kind code kept setting that to select a backend.
Fixed by parsing the type and setting "backend" and "databaseFormat"
instead.
2011-02-08 09:46:58 +01:00
Patrick Ohly
ac875465e4 EDS compatibility: avoid warning about libedataserver-1.2.so.13
Testing showed that libedataserver-1.2.so.13 is compatible with
SyncEvolution binaries. Don't warn about it.
2011-02-08 09:46:06 +01:00
Patrick Ohly
8f0a65a896 Merge branch 'syncevolution-1-1-branch' 2011-02-07 14:11:26 +01:00
Patrick Ohly
63d76f8742 build failure (S360): size_t != unsigned int (BMC #13201)
SyncEvolution 1.1.1 did not build without this patch on S360, because
the source used an integer typedef which turned out to be incompatible
with size_t, although it should have the same size. Apparently the
compiler distinguishes between "unsigned int" and "unsigned long",
even if both have the same size.
2011-02-07 14:08:05 +01:00
Patrick Ohly
51714dfcd9 GTK sync UI: English language fixes
"backup" and "setup" are not verbs. Has to be "back up" and "set up".
Translation files are also patched, so no re-translation necessary.
2011-02-07 13:56:34 +01:00
Patrick Ohly
5be653afae GTK sync ui: made some strings translatable
One of them ("We don't know what this device...") was already
translated elsewhere. It might be that it is already translated in the
UI. The other ("Use these settings") was not and thus really showed up
as untranslated.
2011-02-07 13:40:42 +01:00
Patrick Ohly
870707b48a autotools: disable automatic gen-autotools.sh invocation in released sources
Running gen-autotools.sh as part of "make distcheck" fails because the
source directory is read-only. It shouldn't be needed and wouldn't
replicate the same autotools files (due to the missing "git describe"
output), so disable running it unless the source directory contains a
.git repo.
2011-02-07 13:27:56 +01:00
Patrick Ohly
65a14e7fa6 autotools: rebuild makefiles also when files are added or removed
"gen-autotools.sh" (invoked by "autogen.sh") is needed to create some
of the autotools .am and .in files. This is necessary to avoid
hard-coding certain lists of dirs (backends) and files (templates).
The generated makefiles updated themselves when these files were
modified, but not when files were added or removed.

This patch fixes that. It also avoids some code duplication. Instead
of adding explicit rules to the makefiles for the file dependencies,
now gen-autotools.sh is run on each "make all" or "make Makefile"
invocation. It modifies the generated files only if their content has
changed. The dependency rules for "Makefile.am" and "configure.in" are
constructed so that make re-checks their time stamps after running the
gen-autotools.sh script.
2011-02-07 13:02:58 +01:00
Patrick Ohly
637e80f91f SyncML status codes: explain MIGRATION_NEEDED and RELEASE_TOO_OLD
Added strings which explain the two new status codes.
2011-02-04 21:33:01 +01:00
Patrick Ohly
2077b32f44 LogRedirect: fixed memory handling issue during shutdown
A nightly test run showed that process() was freeing memory
when called indirectly from restore(). The protection against
recursive processing wasn't working because m_processing wasn't
set by restore(). Added it to that and some other high-level
calls which might end up with a recursive call into process().
2011-02-04 16:19:05 +01:00
Patrick Ohly
6ea0886317 LogRedirect: fixed "glib" test
The test failed only because the test's own introduction text on
stdout ended up being redirected. Flushing it before running the
test avoids that.

The flushing was added to both the client runner (because some other
tests also accidentally redirected the output, and it should be
made visible right away) and to the "glib" test (because it shouldn't
depend on flushing in the runner).
2011-02-04 16:14:13 +01:00
Patrick Ohly
0641a5801f KCalExtended: allow extended tests
After fixing BMC #6061, mKCal allows childs without parents. The extended
set of tests passes now, so enable them.
2011-02-03 21:11:03 +01:00
Patrick Ohly
04fd248bf7 client-test: always set source type, also for sync case
An incomplete source config might already exist. Better set the source
type in all cases, to ensure that we really run with the right backend
and data format.
2011-02-03 20:16:51 +01:00
Patrick Ohly
cf23b4e912 command line: --sync/source-property keyword optional
Just saying "foo = bar" is enough now. --sync-property and
--source-property are still accepted, in case that "foo" ever becomes
ambiguous (not the case right now).
2011-02-03 14:05:16 +01:00
Patrick Ohly
664a1e54a5 ConfigProperty: removed the SHARED_AND_UNSHARED hack
After removing the "type" property there is no longer any property
which is both shared and unshared. Removing the dead code.
2011-02-03 13:00:22 +01:00
Patrick Ohly
388f72b369 config: replaced overloaded "type" with "backend/databaseFormat/syncFormat/forceSyncFormat" (BMC #1023)
The meaning of "type" was horribly complex and had effects on the
backend and the peer. It was impossible to specify the sync format to
be used for a specific peer independently of the local backend and its
format, so adding a peer to a context broke the context configuration
(BMC #1023).

This is now fixed by splitting "type" into four independent properties:
- backend = plugin which interfaces with the data
- databaseFormat = data format used inside backend, only relevant for file backend
- syncFormat = data format preferred when talking to peer
- forceSyncFormat = disable format auto-negotiation, use preferred format

With that split, it is now possible to specify the format in which the
file backend stores items independently of the format in which they
are exchanged with the peer.

Old configurations with "type" can still be read. The values specified
inside it are transparently mapped to the new properties. Command line
and D-Bus API users will only see the new properties.

The command line tool still accepts "type" as an alias for the four new
properties. Using that has the same disadvantage as before: it will modify
the context even if only modifying the peer was intended.

The D-Bus API accepts only the new properties. Clients using "type"
must be adapted to the new property names. Clients not using that
continue to run unchanged.

Writing into the configuration requires a migration of the peer config
*and* the context in which it is defined. That is necessary because
the new semantic (independent database format) cannot be stored in the
old format. The migration is handled by rewriting first the context,
then all peers defined inside it.

Other user-visible changes:
- updated help texts
- the canonical "backend" value for the file backend is just "file"
  instead of the long "Files in one directory", which is now an alias
  (used to be the other way around); done because "type = file"
  was expanded to the long name, which was a bit unexpected and showed
  how unintuitive the long name is

Internal changes:
- getMimeVersion() is still present, although it hasn't been used
  for a long time; FileSyncSource::getMimeVersion() now derives
  the version from the supported Mime types, in case that the
  function will be needed again in the future
- setSourceType() with string as argument was replaced with one
  taking a SourceType instance; to emulate the old behavior if
  desired, construct SourceType from an old-style string
- ConfigProperty methods need to be virtual so that derived classes
  like SourceBackendConfigProperty can generate content at runtime
  (a recent commit broke that feature)
- File templates were stripped down to the essential properties,
  with "type" replaced by the per-peer "syncFormat".  "type" would
  still have been accepted (so it is not necessary to adapt
  syncevo-phone-config right away), but has the original
  disadvantage of modifying "backend" and "databaseFormat".
2011-02-03 12:59:02 +01:00
Patrick Ohly
49707f9429 config: reduce dependencies on "type" property string
First step towards removing "type". The parsing of the type string was
moved into SourceType. m_localType and comments were added to
illustrate how SourceType will be used in the future (not enabled
yet). getSourceTypeString() was removed because it was only needed for
error messages and will no longer be correct once "type" property is
gone.
2011-02-02 10:05:42 +01:00
Patrick Ohly
f6c151b26c SyncConfig + command line: enabled migration of config contexts
Because of the shared source property name changes
(evolutionsource/user/password -> database*), mixing old and new
configs inside the same context is not possible. Bumped
CONFIG_CONTEXT_MIN_VERSION and CONFIG_CONTEXT_CUR_VERSION to reflect
that and added the necessary code for migrating a context and all
peers inside it.

This is triggered by a) an automatic config migration in release mode
and b) an explicit --migrate of *any peer inside the context* or of
the context itself.
2011-02-01 22:14:22 +01:00
Patrick Ohly
65bd473dc2 SyncConfig: added getLayout()
The layout used to be class-internal detail. Migrating a config needs
to know about it, too.
2011-02-01 21:35:50 +01:00
Patrick Ohly
7c2a7d48a7 SyncConfig: added getPeers()
The call only makes sense for context configs. In that case it scans the file
system to find peers defined inside the context.
2011-02-01 21:33:31 +01:00
Patrick Ohly
2229146e1a merge: refactoring 2011-02-01 16:32:22 +01:00
Patrick Ohly
2928aed4df SyncContext: added complementary getPeerName(), renamed configurable peer name to UserPeerName
There was a getContextName(), but no getPeerName(). Added. Required
renaming the existing getPeerName() to getUserPeerName(), with
setUserPeerName() renamed accordingly. The former is the internal
part of the config name, the latter the user-visible chosen name.
2011-02-01 16:29:45 +01:00
Patrick Ohly
34437d77cb command line: refactored migrate/configure code
No functional changes. Splitting out some code should make it easier
to migrate contexts.
2011-02-01 16:04:04 +01:00
Patrick Ohly
706b667c6a Cmdline test: test wasn't independent of others
CmdlineTest::testSetupRenamed failed when the config dir wasn't in
the expected state, because it wasn't cleared properly.
2011-02-01 15:25:01 +01:00
Ville Nummela
c9be0e0690 syncevo-dbus-server: Get current NetworkManager state at startup 2011-01-31 12:21:38 +01:00
Ville Nummela
58dc1ed891 syncevo-dbus-server: Tracking NetworkManager state changes 2011-01-31 12:21:18 +01:00
Patrick Ohly
07390794c9 command line: --remove was broken by recent commit
--remove sanity check had the logic for "has properties" inverted,
which prevented running the operation *unless* a property was given.
2011-01-31 11:34:46 +01:00
Patrick Ohly
6643a2c643 syncevo-dbus-server: also accept BT template extensions in SetConfig()
The list of read-only properties which can be ignored in SetConfig()
was incomplete. Also need to take into account the ones added for
Bluetooth templates.
2011-01-31 11:30:08 +01:00
Patrick Ohly
0506bc2bb9 D-Bus API docs: consolidated documentation of artificial properties
GetConfig() contains several read-only properties. Keep all of them
in one place.
2011-01-31 11:28:54 +01:00