Commit graph

4631 commits

Author SHA1 Message Date
Patrick Ohly aa2bb63cec testing: activesyncd is now hosted on gnome.org 2012-07-12 15:59:03 +00:00
Patrick Ohly 93f2020ef0 D-Bus server: fixed HTTP presence for recent libdbus
Testing with libdbus 1.6.0 on Debian Testing failed because the
lib changed some behavior: instead of looking up the owner of
a certain bus name immediately, it now does that when invoking
a method. Therefore the check for "have connection" in NetworkManager
and ConnMan client code was too simplistic and missed the fact that
both were not usable, causing the server to assume that HTTP was down
while in reality it should have assumed it to be up.
2012-07-12 15:53:48 +00:00
Patrick Ohly 7b48710114 D-Bus server: more debug logging to auto sync
Added/changed some more debug logging to track down why auto syncing
wasn't happening. Turned out that it was related to presence detection.
2012-07-12 15:52:39 +00:00
Patrick Ohly 6045c21f93 testing: generalized libdl suppression
Made the libdl jump segfault more general, to catch another variant
of it.
2012-07-12 15:51:37 +00:00
Patrick Ohly a4bc4e74ca D-Bus testing: fixed race condition in TestCmdline
If the command line tool returned before test-dbus.py recorded
all D-Bus events of that session, then the check of the events
failed. Need to wait until "status: done" is also seen via D-Bus.
Not getting it will result in test timeouts.
2012-07-12 15:49:55 +00:00
Patrick Ohly a0a698b339 syncevolution.org: declare dependency on libical
Let the bundle .deb depend on libical if the lib was enabled during
compilation (for example, for CalDAV). This ensures that it gets
installed on systems which otherwise don't have it.
2012-07-10 15:10:15 +02:00
Patrick Ohly 5947ba419f CalDAV + syncevolution.org: fixed segfault without libical+libecal
When libical and libecal were not installed, trying to use the CalDAV
backend for VEVENTs segfaulted because it depends on libical and did
not check properly for it. Only affected syncevolution.org binaries.

The root cause is that libical functions were only looked up in
combination with libecal, when compiled with
--enable-evolution-compatibility. Now they are first checked via
libecal (for old libecal which embedded libical) and separately in
libical itself as fallback.
2012-07-10 15:10:14 +02:00
Patrick Ohly 13ae47b6ac testing: added and updated several failure tests
Instead of using delays to kill processes at the right time, watch old
and new debug output via D-Bus and then kill the processes. To avoid
race conditions, these processes get delayed at the right point.

Added tests for local sync and command line, covering killing of
all involved processes.
2012-07-10 13:09:04 +00:00
Patrick Ohly 7828dd52ff D-Bus server: updated session output handling
The session output needs to go through the server's
message handling, to get the same kind of treatment.
Sending it to the server's parent logger was missing
previously and thus it did not get sent to the
servers stdout. Found while looking at test-dbus.py
logs, which were incomplete.
2012-07-10 09:37:25 +00:00
Patrick Ohly ae522de4ea D-Bus server: updated helper shutdown handling
When the D-Bus helper quit unexpectedly, the session
was closed immediately. That is necessary as a workaround
for D-Bus libdbus, which does not properly shut down
pending method calls when the connection goes down.

However, it prevents processing further events that might
still be pending. So as a workaround for the workaround
let's run the session shutdown with an internal failure
in an idle callback, which will happen after processing all
pending events.
2012-07-10 09:37:25 +00:00
Patrick Ohly a5a85adaf6 D-Bus server: simplified internal timeout API
The API supported repeating timeouts, but none of the users of
it needed that. To fit the API, they were forced to return a boolean
value, which prevented binding to callbacks without such a
return value.

That'll be useful, so let's simplify the code...
2012-07-10 09:37:25 +00:00
Patrick Ohly 9d9b6d8b57 local sync: fixed helper process shutdown in case of parent failure
The helper process only detected that the parent failed when
it tried to log something while the parent had already shut down
the D-Bus connection. Even that did not work reliably and differed
between D-Bus libdbus and GIO.

Now logging ignores failures to send the message (done the same way
as in the syncevo-dbus-helper -> syncevo-dbus-server communication).
Parent failures are detected via the ForkExecChild::m_onQuit signal.
They set the "abort" state permanently until the helper process
terminates.

Found while testing some new failure test cases in combination with
D-Bus libdbus.
2012-07-10 09:37:25 +00:00
Patrick Ohly 8654992eca ForkExec: removed unnecessary line break
Showed up while adding more failure tests.
2012-07-10 09:37:25 +00:00
Patrick Ohly 82ec2e06a9 testing: fixed testAddBothSides + VJOURNAL
The test fails if properties are involved which get
concatenated by the Synthesis engine during merging. Need
to remove those also for VJOURNAL.
2012-07-10 09:37:24 +00:00
Patrick Ohly 2673b67981 testing: fixed testInsertTwice
Backends need to declare how they'll react to inserting
the same item (= same UID) item twice.
2012-07-10 09:37:24 +00:00
Patrick Ohly 7feed6634a EDS: updated syncevolution.org packages, incompatible with EDS 3.6
The EDS backend in the syncevolution.org packages are compiled
for the API in EDS <= 3.4. With some tricks (dynamically
loading libs) it works across a range of libecal and libebook
releases.

Now the syncevolution-evolution meta package declares that
it depends on one of these libecal/ebook libraries (was missing
earlier), to ensure that the libs get installed on a system
which did not have them already.

The dynamic loading will no longer attempt to work with
EDS 3.6. For EDS 3.6 it will be necessary to update the EClient
variant of the EDS backend and compile the syncevolution.org
binaries differently.
2012-07-10 09:37:24 +00:00
Patrick Ohly af9ec74339 NEWS: fixed spelling and truncation
Copying long lines from git log output truncated them at the width
of the shell.
2012-07-10 09:37:24 +00:00
Patrick Ohly 7256318870 GDBus libdbus + GIO: simplified Watch
Avoid the abstract base class and implement the GDBusXX::Watch
class directly. This became necessary because moving the GIO
implementation into the .cpp resulted in strange crashes around
the virtual setCallback() method - but only when optimization
was enabled. Compiler bug?!

Simplifying the class hierarchy is the right step either way. It was
done with separate classes initially to avoid dependencies on
gdbus-cxx-bridge.h in code which just needs to interact with the base
functionality, but it turned out that no code needs that.
2012-07-10 09:31:39 +00:00
Patrick Ohly 9e02f1fc93 D-Bus GIO: reimplemented DBusWatch
The previous implementation did not work at all. It relied
on "NameLost" signals with the watched D-Bus name as sender,
but that is not how the signal works. It is sent by the D-Bus
daemon to the old owner of that name if it looses the name.

Instead we need to watch the "NameOwnerChanged" signal and
detect when the peer we are watching is the one who disconnected
from the bus.

Also moved the actual code into the .cpp file because there is
no need to inline all of it.

This problem was found after adding more failure tests to
test-dbus.py. The real-world effect was that syncevo-dbus-server did
not clean up properly when clients disconnected early and that the
command line kept running after syncevo-dbus-server crashed. Did not
affect syncevolution.org binaries, which do not use D-Bus GIO.
2012-07-10 09:08:00 +00:00
Patrick Ohly 35e81d293c D-Bus GIO: revised DBusWatch creation
The static template method doesn't have to be in the header
file (doesn't depend on template parameters). Moving it into
the .cpp file to minimize compile and executable size.

Runtime work can be minimized by holding the instance
temporarily in a simpler auto pointer before moving it
into the final shared pointer.

Another reason was that compiling with optimization enabled
produced binaries which crashed in that code. However, moving
it did not help.
2012-07-10 07:35:34 +00:00
Patrick Ohly 033b685099 local sync: use weak pointers with asynchronous D-Bus calls
An asynchronous D-Bus call will invoke the callback even if
the call instance itself was already deleted. Therefore binding
the this pointer of the call instance owner is not safe. This
caused use-after-free errors in local sync (found during testing).

Add a weak pointer to itself to each LocalTransportAgent
instance and use that weak pointers so that the callback
does not crash when it happens to late.
2012-07-10 07:35:25 +00:00
Patrick Ohly 31051c0b9e D-Bus server: use weak pointers with asynchronous D-Bus calls
An asynchronous D-Bus call will invoke the callback even if
the call instance itself was already deleted. Therefore binding
the this pointer of the call instance owner is not safe. This
caused use-after-free errors in local sync (found during testing).

Use weak pointers as a precaution where it can be done easily.
Some remaining start() calls still need to be converted.
2012-07-10 06:37:10 +00:00
Patrick Ohly 663a7063e4 boost: support boost::bind() + weak pointers
On several occasions, boost::bind() is used with a this
pointer as second parameter. This is only safe as long as
the functor is only called when the instance is still valid.

After including BoostHelper.h it is also possible to use
a weak pointer. The result is a functor which does not
prevent deleting the instance and doesn't do anything
when the instance is gone when called.
2012-07-10 06:30:33 +00:00
Patrick Ohly 99e27d4661 D-Bus API: added update script for docbook XSL
Script which might come handy for updating our copy of the docbook
XSL files.
2012-07-04 17:02:03 +02:00
Patrick Ohly 3ac2b73ffb D-Bus API: generate docs using local copy of docbook XSL
Nightly builds with --enable-doc tended to fail occassionally due to
download errors of the current docbook XSL from SourceForge. Using
a local copy of those files avoids that problem, speeds up compilation
and gives us some control over potentially incompatible changes
in the upstream docbook XSL.
2012-07-04 17:02:03 +02:00
Patrick Ohly fafc158ebd NEWS: updated for 1.2.99.2 2012-07-04 17:00:49 +02:00
Patrick Ohly b641345cc4 autotools: distribute files necessary for autogen.sh
Normal autoreconf worked, but not ./autogen.sh.
2012-07-04 16:59:00 +02:00
Patrick Ohly c24940cc7c NEWS: revised 1.2.99.2 2012-07-02 17:58:20 +02:00
Patrick Ohly 2f9daf13ee testing: blacklist KDE and testReadItem404
Reporting that an item does not exist does not work reliably with Akonadi.
Ignore that error for the time being.
2012-07-02 15:42:52 +02:00
Patrick Ohly 1f1009aaf6 Google Calendar: updated URL redirect handling
Google Calendar sometimes returns redirect requests to human-readable
web sites (an "unavailable" page, a login form). This is of course
bogus when the client is an automated CalDAV client.

The "unavailable.html" case was already handled. Made it a bit more
flexible to also catch possible variations of it (additional
parameters, https instead of http).

Added the https://accounts.google.com/ServiceLogin case. Not sure
whether retrying will help in that case, but there's not much else
that SyncEvolution can do.
2012-07-02 15:08:01 +02:00
Patrick Ohly dfbd3dc45c testing: check result of "item already exists" during insert
The new testInsertTwice checks what the backend does when the same
item already exists in the database. This is only done for test data
which has a UID (i.e. for calendar data, but not for contacts). This
test exercises the code which previously failed with 412 "Precondition
Failed" in the CalDAVMemo backend.
2012-07-02 14:58:10 +02:00
Patrick Ohly 2add74a5ea WebDAV: handle UID conflicts
When asked to insert a VJOURNAL which already existed (= same UID),
CalDAV servers respond with a 412 "Precondition failed" error. This
needs to be detected and translated into an "item needs to be merged"
result so that the engine can load the existing item, merge the data,
and then write back.

A test for this, testInsertTwice, will be committed separately.  The
code was written so that it handles the same error when using CardDAV.
However, this was not tested because CardDAV test data does not have a
UID (wouldn't trigger the problem) and Radicale did not report 412 when
adding the UID.
2012-07-02 14:51:09 +02:00
Patrick Ohly b0173cbff4 testing: fixed insertion of VJOURNAL
WebDAVSource, in contrast to CalDAVSource, does not check for UID
conflicts before the PUT. As a result, testSimpleInsert and
testLocalDeleteAll were failing when the VJOURNAL test item had
already been imported.

Need to strip the UID in cases where it is not guaranteed that the
item is not already in the database. Cases where that can be taken
for granted because of a preceeding delete continue to use the UID
embedded in the test data (but don't rely on it, because update()
without LUID will find the existing item and use its LUID).
2012-07-02 14:32:23 +02:00
Patrick Ohly ff64158435 WebDAV: updated Radicale 412 -> 404 workaround
Instead of relying on catching an exception, better use the new
"expected status codes" feature and check for 412 as part of the
normal switch statement.
2012-07-02 14:07:51 +02:00
Patrick Ohly 68ff18bba4 WebDAV: added possibility to accept certain error codes
Some WebDAV requests might fail with a non-okay status code that the
caller expects. This was reported via an exception. But
SyncEvolution's design uses exceptions only for non-normal
incidencences. Therefore better allow the caller to indicate which
status codes are expected and return normally from run() and
checkError() when those are encountered, without retrying and without
throwing an exception.
2012-07-02 14:06:08 +02:00
Patrick Ohly bfdc3977e2 testing: fixed testConversion
The testConversion test was conceptually broken: it only passed for
peers where synccompare filtered out X-EVOLUTION-UI-SLOT, because that
parameter always gets dropped during import/export. It's disable by
default and needs to be enabled via DevInf, which is never received
during this test.

synccompare also might have hidden other kinds of data loss, depending
on which workarounds were enabled via CLIENT_TEST_SERVER.

The fix is to unset CLIENT_TEST_SERVER and enable removal of
X-EVOLUTION-UI-SLOT via CLIENT_TEST_STRIP_PARAMETERS.
2012-07-02 10:16:13 +02:00
Patrick Ohly 8f613fa1bb testing: fixed testExtensions
The testExtensions test was broken since creating sources reads
CLIENT_TEST_SERVER to find the databases, because CLIENT_TEST_SERVER
was temporarily cleared in testExtensions.
2012-07-02 10:04:40 +02:00
Patrick Ohly a2ebc922ca NEWS, configure: updated for 1.2.99.2 2012-06-30 07:32:22 +02:00
Patrick Ohly 8b86963466 Funambol: ignore UID
Funambol's OneMedia sends UID, but not RECURRENCE-ID. That becomes a
problem when multiple events of the same event series are added to a
backend which follows the iCalendar 2.0 standard (CalDAV, EDS, KDE),
because these events all look like the master event, and there can be
only one of those.

SyncEvolution now strips the UID from all events coming from any
Funambol server (regardless of the version). If a future Funambol
server release adds support for both UID and RECURRENCE-ID, then
SyncEvolution will have to be updated to take advantage of the
improved server. Because the RECURRENCE-ID is also getting
stripped (despite not being set at the moment), SyncEvolution should
continue to work as it does now even if the server changes.

It would have been nice to limit this workaround to affected Funambol
server versions, but an inquiry on the Funambol mailing list didn't
get a reply, therefore SyncEvolution is playing it safe and assumes
that all future Funambol releases will have the same problem.
2012-06-29 16:56:13 +02:00
Patrick Ohly c81a7fceaf WebDAV: fixed data corruption issue when uploading item with long UID
In some cases data with a very long UID wasn't handled correctly,
causing the out-going data to be malformed and probably causing a
rejection by the server.

The root-cause was two-fold:
- extractUID() didn't expect folding. Normally it deals only with
  data encoded by libsynthesis, which does not use folding; the unexpected
  exception was data which gets imported directly (--import).
- setResourceName() used std::string::replace() incorrectly: second
  parameter is length, not end offset, of the data to be replaced.
2012-06-29 11:36:32 +02:00
Patrick Ohly 266656d8bd engine: add DTSTAMP+LAST-MODIFIED before writing calendar items
When writing calendar items into a backend storage as iCalendar 2.0 or
vCalendar 1.0, they should have DTSTAMP and LAST-MODIFIED values. DTSTAMP
is expected by some CalDAV servers (like Apple). LAST-MODIFIED is usually
added by the storage, but not always.

In the text/plain -> syncevolution -> text/calendar -> Radicale -> EDS
-> syncevolution chain the LAST-MODIFIED was not added by Radicale, which caused
problems for change tracking in an EDS-based SyncEvolution.
2012-06-29 11:36:32 +02:00
Patrick Ohly 3d299422f9 WebDAV: --status for WebDAV source aborted
The command line --status operation did not complete when applied to a
CalDAV/CardDAV source. Instead it aborted because the operation took a
code path where the backend was not fully initialized.
2012-06-29 11:36:32 +02:00
Patrick Ohly 7b72e54a3d GDBus GIO: fixed embedding of line number in error messages
__LINE__ instead of the actual number became part of the error
message, because the preprocessor trick wasn't using a double
indirection, as required.
2012-06-29 11:36:32 +02:00
Patrick Ohly 2bcb382588 ForkExec: slight logging improvement
Forking helper processes has better support for debugging. It disables
this output redirection and inherited loggers before executing the
helper. Not a big change because the parent probably already disabled
output redirection.
2012-06-29 11:36:32 +02:00
Patrick Ohly e5c2a86096 local sync: improved target side output
Added a "target side of local sync ready" INFO message to introduce
the output which has the target context in the [INFO] tag. The sync report
from the target side now has the target context embedded in brackets
after the "Changes applied during synchronization" header, to avoid
ambiguities.

Output from the target side of a local sync was passed through stderr
redirection as chunks of text to the frontends. This had several
drawbacks:
- forwarding only happened when the local sync parent was processing
  the output redirection, which (due to limitations of the implementation)
  only happens when it needs to print something itself
- debug messages were not forwarded
- message boundaries might have been lost

In particular INFO messages about delays on the target side are
relevant while the sync runs and need to be shown immediately.

Now the output is passed through D-Bus, which happens immediately,
preserves message boundaries and is done for all output. The frontend
can decide separately whether it shows debug messages (not currently
supported by the command line tool).

Implementing this required extending the D-Bus API. The
Server.LogOutput signal now has an additional "process name"
parameter. Normally it is empty. For messages originating from the
target side, it carries that extra target context string.

This D-Bus API change is backward compatible. Older clients can still
subscribe to and decode the LogOutput messages, they'll simply ignore
the extra parameter. Newer clients expecting that extra parameter
won't work with an older D-Bus daemon: they'll fail to decode the
D-Bus message.

This revealed that the last error messages in a session was
incorrectly attributed to the syncevo-dbus-server. Might also have
happened with several other error messages. Now everything happening
in the server while working on code related to a session is logged as
coming from that sessions. It's not perfect either (some of the output
could be from unrelated events encountered indirectly while running
that code), but it should be better than before.

The patch changes the handling or errors in the local sync parent
slightly: because it logs real ERROR messages now instead of plain
text, it'll record the child's errors in its own sync report. That's
okay, user's typically shouldn't have to care about where the error
occurred. The D-Bus tests need to be adapted for this, because it
removes the "failure in local sync child" from the sync report.

Another, more internal change is that the syncevo-local-sync helper
does its own output redirection instead of relying on the stderr
handling of the parent. That way libneon debug output ends up in the
log file of the child side (where it belongs) and not in the parent's
log.
2012-06-29 11:35:53 +02:00
Patrick Ohly a7b569074a WebDAV: print INFO messages when access gets delayed
Sometimes the backend has to resend requests because of temporary
issues. If the problem turned out to be permanent, there was a long
period of time, retryDuration=5 minutes to be precice, in which no
visible progress happened.

Now SyncEvolution's WebDAV backend will print a message like this
before going to sleep until it is time to retry:

[INFO @client-test-googlecalendar] operation temporarily (?) failed, going to retry in 5.0s before giving up in 18.4s: PROPFIND: Neon error code 1: 401 Unauthorized

The uncertainty comes from several factors. In this example, the 401
might indicate a permanent problem (wrong credentials), or it could be
Google reporting a temporary authorization problem which is (probably)
meant to slow down the client while it asks the user to re-enter the
password. SyncEvolution only asks for passwords once, so it tries
again with the same password if it was successful with it in the
past. Otherwise it gives up immediately.

Another dubious example are name server lookup errors. They can be
ermanent (wrong host name) or temporary (name server
down). SyncEvolution errs on the side of retrying, to avoid
interrupting an operation which still has a chance to continue.

Currently this output is only visible in combination with --daemon=no,
because when using syncevo-dbus-server the output is not passed on
properly.
2012-06-28 14:38:32 +02:00
Patrick Ohly 3819e389ad command line: fixed password + property lookup during --print-databases
--print-databases for an existing configuration did not look up
passwords stored in a keyring, causing the operation to fail for
backends like CalDAV/CardDAV where credentials are required.

Overriding source properties in that case also only worked when using
the unqualified property name ("databasePassword=foo") but not when
using the source name as prefix ("calendar/databasePassword=foo").
2012-06-28 14:29:01 +02:00
Patrick Ohly 6130b46b72 testing: ignored failures could lead to false overall success
The code which marked a failure as "ignored" unintentionally
cleared the overall error flag, causing client-test runs
with ignored and real failures to return 0 = success.
2012-06-26 08:25:21 +00:00
Rohan Garg d7fd5ef98d Use 'templateName' instead of 'template' since 'template' is a keyword 2012-06-25 10:31:43 +02:00
Rohan Garg 2d3153bc48 Use org.qtproject.QtDBus.QtTypeName.In3 instead of org.qtproject.QtDBus.QtTypeName.In2 2012-06-25 10:31:43 +02:00