diff options
author | cos <cos> | 2017-01-21 13:19:13 +0100 |
---|---|---|
committer | cos <cos> | 2017-01-21 13:19:13 +0100 |
commit | 43339a01394c360cf3269afadc5634eac82391af (patch) | |
tree | 72b2c7ddf08cb3750bba98684180d2cc005b3806 /contrib | |
parent | 3375fddb4e594badf7a7ab0cc722dc33a3af1131 (diff) | |
download | calcurse-wip/fugly_propfind_sync.zip |
Attempt two at hacking up caldav to kind of semi-work with SOGo.wip/fugly_propfind_sync
This is an ugly work around that makes an initial one time synchronization
happen, it is not an actually working fix.
Implementing a proper fix would require reading up on WebDAV and understanding
the protocol. That means reading at least section 7 of rfc479.
https://tools.ietf.org/html/rfc4791#section-7
All this code does is demonstrating that calcurse-caldav can do something
slightly useful with SOGo calendars if prepending the REPORT command with a
PROPFIND and feeding the output from the first command to the second.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/caldav/calcurse-caldav.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py index 5c028bf..f40c12b 100755 --- a/contrib/caldav/calcurse-caldav.py +++ b/contrib/caldav/calcurse-caldav.py @@ -135,6 +135,27 @@ def remote_query(conn, cmd, path, additional_headers, body): return (headers, body) +def get_hrefs(conn): + body = ('<?xml version="1.0" encoding="utf-8" ?>' + '<D:propfind xmlns:D="DAV:"><D:prop><D:getetag/></D:prop></D:propfind>' ) + headers, body = remote_query(conn, "PROPFIND", path, {}, body) + + if not headers: + return {} + + root = etree.fromstring(body) + + hreflist = [] + for node in root.findall(".//D:response", namespaces=nsmap): + hrefnode = node.find("./D:href", namespaces=nsmap) + if hrefnode is None: + die_atnode('Missing href.', node) + href = hrefnode.text + + hreflist.append(href) + + return hreflist + def get_etags(conn, hrefs=[]): if len(hrefs) > 0: @@ -525,9 +546,10 @@ try: ' --init=keep-local Remove all remote objects\n' + ' --init=two-way Copy local items to the server and vice versa') + hreflist = get_hrefs(conn) # Query the server and compute a lookup table that maps each path to its # current ETag. - etagdict = get_etags(conn) + etagdict = get_etags(conn, hreflist) # Compute object diffs. missing = set() |