From 43339a01394c360cf3269afadc5634eac82391af Mon Sep 17 00:00:00 2001 From: cos Date: Sat, 21 Jan 2017 13:19:13 +0100 Subject: Attempt two at hacking up caldav to kind of semi-work with SOGo. 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. --- contrib/caldav/calcurse-caldav.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 = ('' + '' ) + 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() -- cgit v1.2.3