From feee46cd739cb77e2adac508832f13b7b6d1b75f Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 29 May 2016 20:35:01 +0100 Subject: [PATCH] Added the ProcessXMLSyncTokenList function for the CalDAV class --- .../objects/CalDAV/CalDAV-XMLProcessing.cpp | 95 +++++++++++++++++++ source/objects/CalDAV/CalDAV.h | 1 + 2 files changed, 96 insertions(+) diff --git a/source/objects/CalDAV/CalDAV-XMLProcessing.cpp b/source/objects/CalDAV/CalDAV-XMLProcessing.cpp index 9589868..d216a33 100644 --- a/source/objects/CalDAV/CalDAV-XMLProcessing.cpp +++ b/source/objects/CalDAV/CalDAV-XMLProcessing.cpp @@ -574,6 +574,101 @@ CalDAVEntryList CalDAV::ProcessXMLEntryList(){ return EntryList; } + +CalDAVEntryList CalDAV::ProcessXMLSyncTokenList(){ + + CalDAVEntryList EntryList; + + xmlDocPtr xmlCalDAVDoc; + xmlCalDAVDoc = xmlReadMemory(ServerData.c_str(), (int)ServerData.size(), "noname.xml", NULL, 0); + + xmlNodePtr NodeSeek = NULL; + xmlNodePtr NodeResponse = NULL; + xmlNodePtr NodeMatch = NULL; + xmlNodePtr NodeData = NULL; + bool NodeFound = false; + int ResponseCount = 0; + + // Start with the first node, look for multistatus. + + for (NodeSeek = xmlCalDAVDoc->children; + NodeSeek != NULL; + NodeSeek = NodeSeek->next) + { + + if (!xmlStrcmp(NodeSeek->name, (const xmlChar *)"multistatus") || + !xmlStrcmp(NodeSeek->name, (const xmlChar *)"d:multistatus") || + !xmlStrcmp(NodeSeek->name, (const xmlChar *)"D:multistatus") + ){ + + NodeResponse = NodeSeek->children; + NodeFound = true; + break; + + } + + } + + if (NodeFound == false){ + + return EntryList; + + } + + for (NodeResponse = NodeSeek->children; + NodeResponse != nullptr; + NodeResponse = NodeResponse->next) + { + + // Go through each of the responses and find the calendars. + + NodeMatch = xmlCopyNode(NodeResponse, 1); + + if (MatchXMLName(&NodeMatch, "response")){ + + NodeData = xmlCopyNode(NodeMatch, 1); + + // Get the HREF. + + NodeData = xmlCopyNode(NodeMatch, 1); + + if (!MatchXMLNameTransverse(&NodeData, "href")){ continue; } + + string HREFAddress = FetchXMLData(&NodeData); + + // Get the entry entity tag. + + NodeData = xmlCopyNode(NodeMatch, 1); + + string EntryEntityTag = ""; + + if (!MatchXMLNameTransverse(&NodeData, "propstat")){ continue; } + if (!MatchXMLNameTransverse(&NodeData, "prop")){ continue; } + if (MatchXMLNameTransverse(&NodeData, "getetag")){ + + EntryEntityTag = FetchXMLData(&NodeData); + + } + + // Insert the calendar information into the + // list if all the information is there. + + EntryList.HREF.insert(make_pair(ResponseCount, HREFAddress)); + EntryList.Data.insert(make_pair(ResponseCount, "")); + EntryList.Tag.insert(make_pair(ResponseCount, EntryEntityTag)); + + ResponseCount++; + + } + + } + + xmlFreeDoc(xmlCalDAVDoc); + + return EntryList; + +} + bool CalDAV::MatchXMLNameTransverse(xmlNodePtr *NodePtr, string NodeName){ string NodeNameSmallD = "d:" + NodeName; diff --git a/source/objects/CalDAV/CalDAV.h b/source/objects/CalDAV/CalDAV.h index 9a7b473..e95c03b 100644 --- a/source/objects/CalDAV/CalDAV.h +++ b/source/objects/CalDAV/CalDAV.h @@ -133,6 +133,7 @@ class CalDAV{ string ProcessXMLCalendarHome(); CalDAVCalendarList ProcessXMLCalendarList(); CalDAVEntryList ProcessXMLEntryList(); + CalDAVEntryList ProcessXMLSyncTokenList(); string ProcessXMLEntryETag(); bool MatchXMLNameTransverse(xmlNodePtr *NodePtr, string NodeName); bool MatchXMLName(xmlNodePtr *NodePtrOriginal, string NodeName); -- 2.39.2