Commit graph

13 commits

Author SHA1 Message Date
Patrick Ohly 6ba33b8dcb CalDAV: cache UID and SEQUENCE, fix SEQUENCE before sending
Google requires that all items sent to it have a higher SEQUENCE
number than the copy on the server. Calendar applications are allowed
to make changes to an item even when they are not the organizer, in
which case they are *not* meant to increase the SEQUENCE.

This patch works around the issue by increasing the SEQUENCE number
artifically before sending to the CalDAV server (regardless whether
it is Google or something else).

It does that by keeping track of UID and SEQUENCE number in the
cache. The UID is used to find the resource before sending in case that
the caller didn't know, the SEQUENCE to know what the outgoing item
must have.

The sequence number is shared among all sub items. That is an
intentional simplification of the implementation which may or may not
be necessary to work around the issue.  If we have to touch the
sequence number, we might as well do it for all sub items.
2011-02-24 10:11:33 +01:00
Patrick Ohly b16b37c395 WebDAV error codes: map to SyncMLStatus
This patch enhances error handling so that a more specific
TransportStatusException with the right SyncMLStatus inside is
thrown. This is necessary to report back authentication errors.
2011-02-24 10:11:33 +01:00
Patrick Ohly a2d6bc814b WebDAVSource: fixed compiler error with g++ 4.5
g++ 4.5 correctly points out that UUID::UUID() calls the constructor,
instead of construction a UUID instance, which is UUID().
2011-02-24 10:11:33 +01:00
Patrick Ohly 58fddf857e WebDAV: some testing and fixes for iCalendar 2.0 with Google
The tests must run with a modified ical20.ics.google.tem which
does not contain RECURRENCE-ID, because that is not yet supported.
Also, our complex 1234567890!@#$%^&*()<>@dummy must be avoided
because Google has an issue with it (doesn't find resulting resource):

CLIENT_TEST_SERVER=google CLIENT_TEST_SIMPLE_UID=1 ./client-test Client::Source::caldav_ical20::testImport

This patch fixes some (but not all) issues found in testImport:
- readItem() did not clear the item string before appending
  the new item.
- Detection of "item existed already" cannot use the alternative name
  returned by the server, because Google does that also for items
  which are really new.
- The test registered itself as "ical20", which conflicts with the EDS
  backend. Now use "caldav_ical20".
2011-02-24 10:11:32 +01:00
Patrick Ohly 721ce8cb0f WebDAV settings: take from context
This replaces the WEBDAV_* env variables with access to the
normal per-peer properties, passed into the source via the new
SyncSourceParams context member.

When used on the command line, @foobar context configs are not
enough to use the WebDAV sources. A properly configured peer
context (foo@bar) is needed. There is no explicit check for this,
the resulting error is about not being able to access the empty
URL `' (Neon uses these quotation marks).
2011-02-24 10:11:32 +01:00
Patrick Ohly 6f58a1f5f7 WebDAV: implemented removeItem()
Mapping removeItem() to DELETE is straight-forward. Except that CalDAV
will require additional support for removing individual VEVENTs from
a resource that contains more than one VEVENT...
2011-02-24 10:11:32 +01:00
Patrick Ohly 31eb20f704 WebDAV: implemented insertion of items
This works for updating and adding an item. Storing a new item under a
different resouce URI is also handled, which can happen with CalDAV
when there is already an item with the same UID.

It would be nice if the server returned a ETag in response to a PUT,
but Google Calendar doesn't do that. The header is checked neverthless
(untested!), with an explicit PROPGET as fallback.

This patch also clarifies LUID (relative if possible, absolute if not)
and revision string handling (without W/ and quotation marks). We
don't care about weak ETags at the moment, Google doesn't use
them. Even if a server did, what would we do with the information that
the item wasn't stored verbatim?

The current implementation is not yet good enough for CalDAV:
- only one VEVENT per UID supported: must merge and split
  related VEVENTs into one CalDAV calendar resource
- adding or updating VEVENT without UID probably fails:
  must insert new or old UID
2011-02-24 10:11:32 +01:00
Patrick Ohly 424d640ca7 WebDAV: implemented item listing
Listing items in WebDAV consists of getting the ETag for each URI
directly underneath the collection. Checking for "empty source"
is done by reading all pairs and then checking for non-empty map.

It would be nice to abort the processing once an error is encountered
or once "not empty" has been observed, but Neon does not support that.
Probably for a good reason, because it would render the TCP connection
useless.
2011-02-24 10:11:32 +01:00
Patrick Ohly 42e6307048 properly resolve relative ../events/ path for Google
Added URI::resolve(), which is now used for Google default calendar
if (and only if) starting with the "/user" or "/user/" URL.
2011-02-24 10:11:32 +01:00
Patrick Ohly d7c73d5aeb WebDAVSource: avoid cut-and-paste of boost::bind
The boost::bind() calls is complex enought to only write it once...
2011-02-24 10:11:32 +01:00
Patrick Ohly 7d4ab11ce5 WebDAVSource: debug dump of properties
This verifies that reading properties works. For Google, the real
calendar collection happens to be ../events/.
2011-02-24 10:11:32 +01:00
Patrick Ohly a4dabc3685 WebDAV: first version which can log into Google
The Neon::Session wraps most of the relevant calls. It is
parameterized by Neon::Settings. It is uncertain where all of these
are meant to come from, because there is no peer configuration in many
cases. Perhaps we can enforce that a WebDAV source may only be created
in a context which has one and exactly one peer config?

The current intermediate solution in WebDAVSourceRegister.cpp grabs
all settings from WEBDAV_* env variables.

Disabling SSL verification and Neon debug logging are implemented.
Opening the source runs a few checks on the URL. Disabling SSL
certificate checking turned out to be necessary, probably because of
the known issue of gnutls not trusting the weak Google certificate
chain.
2011-02-24 10:11:32 +01:00
Patrick Ohly 544456364b WebDAV: initial commit of skeleton sources and build scripts 2011-02-24 10:11:32 +01:00