mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Fix compatibility with iCloud again
This commit is contained in:
parent
f32b4411ae
commit
f23c79eac9
2 changed files with 43 additions and 32 deletions
|
|
@ -17,6 +17,7 @@ Version 0.5.0
|
||||||
- Raise version of required requests-toolbelt to ``0.4.0``.
|
- Raise version of required requests-toolbelt to ``0.4.0``.
|
||||||
- Command line should be a lot faster when no work is done, e.g. for help
|
- Command line should be a lot faster when no work is done, e.g. for help
|
||||||
output.
|
output.
|
||||||
|
- Fix compatibility with iCloud again.
|
||||||
|
|
||||||
Version 0.4.4
|
Version 0.4.4
|
||||||
=============
|
=============
|
||||||
|
|
|
||||||
|
|
@ -507,6 +507,32 @@ class DavStorage(Storage):
|
||||||
hrefs.add(href)
|
hrefs.add(href)
|
||||||
yield href, etag, props
|
yield href, etag, props
|
||||||
|
|
||||||
|
def list(self):
|
||||||
|
headers = self.session.get_default_headers()
|
||||||
|
headers['Depth'] = 1
|
||||||
|
|
||||||
|
data = '''<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<D:propfind xmlns:D="DAV:">
|
||||||
|
<D:prop>
|
||||||
|
<D:resourcetype/>
|
||||||
|
<D:getcontenttype/>
|
||||||
|
<D:getetag/>
|
||||||
|
</D:prop>
|
||||||
|
</D:propfind>
|
||||||
|
'''
|
||||||
|
|
||||||
|
# We use a PROPFIND request instead of addressbook-query due to issues
|
||||||
|
# with Zimbra. See https://github.com/untitaker/vdirsyncer/issues/83
|
||||||
|
response = self.session.request('PROPFIND', '', data=data,
|
||||||
|
headers=headers)
|
||||||
|
root = _parse_xml(response.content)
|
||||||
|
|
||||||
|
# Decode twice because ownCloud encodes twice.
|
||||||
|
# See https://github.com/owncloud/contacts/issues/581
|
||||||
|
rv = self._parse_prop_responses(root, decoding_rounds=2)
|
||||||
|
for href, etag, prop in rv:
|
||||||
|
yield href, etag
|
||||||
|
|
||||||
|
|
||||||
class CaldavStorage(DavStorage):
|
class CaldavStorage(DavStorage):
|
||||||
|
|
||||||
|
|
@ -584,7 +610,6 @@ class CaldavStorage(DavStorage):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_list_filters(components, start, end):
|
def _get_list_filters(components, start, end):
|
||||||
|
|
||||||
if components:
|
if components:
|
||||||
caldavfilter = '''
|
caldavfilter = '''
|
||||||
<C:comp-filter name="VCALENDAR">
|
<C:comp-filter name="VCALENDAR">
|
||||||
|
|
@ -611,10 +636,24 @@ class CaldavStorage(DavStorage):
|
||||||
for x in CaldavStorage._get_list_filters(('VTODO', 'VEVENT'),
|
for x in CaldavStorage._get_list_filters(('VTODO', 'VEVENT'),
|
||||||
start, end):
|
start, end):
|
||||||
yield x
|
yield x
|
||||||
else:
|
|
||||||
yield '<C:comp-filter name="VCALENDAR"/>'
|
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
|
caldavfilters = list(self._get_list_filters(
|
||||||
|
self.item_types,
|
||||||
|
self.start_date,
|
||||||
|
self.end_date
|
||||||
|
))
|
||||||
|
if not caldavfilters:
|
||||||
|
# If we don't have any filters (which is the default), taking the
|
||||||
|
# risk of sending a calendar-query is not necessary. There doesn't
|
||||||
|
# seem to be a widely-usable way to send calendar-queries with the
|
||||||
|
# same semantics as a PROPFIND request... so why not use PROPFIND
|
||||||
|
# instead?
|
||||||
|
#
|
||||||
|
# See https://github.com/dmfs/tasks/issues/118 for backstory.
|
||||||
|
for x in DavStorage.list(self):
|
||||||
|
yield x
|
||||||
|
|
||||||
data = '''<?xml version="1.0" encoding="utf-8" ?>
|
data = '''<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<C:calendar-query xmlns:D="DAV:"
|
<C:calendar-query xmlns:D="DAV:"
|
||||||
xmlns:C="urn:ietf:params:xml:ns:caldav">
|
xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
|
|
@ -634,9 +673,6 @@ class CaldavStorage(DavStorage):
|
||||||
# the spec which values from WebDAV are actually allowed.
|
# the spec which values from WebDAV are actually allowed.
|
||||||
headers['Depth'] = 1
|
headers['Depth'] = 1
|
||||||
|
|
||||||
caldavfilters = self._get_list_filters(self.item_types,
|
|
||||||
self.start_date, self.end_date)
|
|
||||||
|
|
||||||
for caldavfilter in caldavfilters:
|
for caldavfilter in caldavfilters:
|
||||||
xml = data.format(caldavfilter=caldavfilter)
|
xml = data.format(caldavfilter=caldavfilter)
|
||||||
response = self.session.request('REPORT', '', data=xml,
|
response = self.session.request('REPORT', '', data=xml,
|
||||||
|
|
@ -671,29 +707,3 @@ class CarddavStorage(DavStorage):
|
||||||
_dav_namespace = 'urn:ietf:params:xml:ns:carddav'
|
_dav_namespace = 'urn:ietf:params:xml:ns:carddav'
|
||||||
_dav_resourcetype = 'addressbook'
|
_dav_resourcetype = 'addressbook'
|
||||||
get_multi_data_query = '{urn:ietf:params:xml:ns:carddav}address-data'
|
get_multi_data_query = '{urn:ietf:params:xml:ns:carddav}address-data'
|
||||||
|
|
||||||
def list(self):
|
|
||||||
headers = self.session.get_default_headers()
|
|
||||||
headers['Depth'] = 1
|
|
||||||
|
|
||||||
data = '''<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<D:propfind xmlns:D="DAV:">
|
|
||||||
<D:prop>
|
|
||||||
<D:resourcetype/>
|
|
||||||
<D:getcontenttype/>
|
|
||||||
<D:getetag/>
|
|
||||||
</D:prop>
|
|
||||||
</D:propfind>
|
|
||||||
'''
|
|
||||||
|
|
||||||
# We use a PROPFIND request instead of addressbook-query due to issues
|
|
||||||
# with Zimbra. See https://github.com/untitaker/vdirsyncer/issues/83
|
|
||||||
response = self.session.request('PROPFIND', '', data=data,
|
|
||||||
headers=headers)
|
|
||||||
root = _parse_xml(response.content)
|
|
||||||
|
|
||||||
# Decode twice because ownCloud encodes twice.
|
|
||||||
# See https://github.com/owncloud/contacts/issues/581
|
|
||||||
rv = self._parse_prop_responses(root, decoding_rounds=2)
|
|
||||||
for href, etag, prop in rv:
|
|
||||||
yield href, etag
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue