+ if (entryETag.substr(0,1) == "\"" &&
+ entryETag.substr(entryETag.size()-1, 1) == "\"" && entryETag.size() > 2){
+
+ entryETag.erase(entryETag.begin());
+ entryETag.erase(entryETag.end()-1);
+
+ }
+
+ return entryETag;
+
+}
+
+CalDAVEntryList CalDAV::ProcessXMLEntryList(){
+
+ 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 calendar data.
+
+ nodeData = xmlCopyNode(nodeMatch, 1);
+
+ string entryDescription = "";
+
+ if (!MatchXMLNameTransverse(&nodeData, "propstat")){ continue; }
+ if (!MatchXMLNameTransverse(&nodeData, "prop")){ continue; }
+ if (MatchXMLNameTransverse(&nodeData, "calendar-data")){
+
+ // Note: libxml2 will strip the CDATA part at the start and
+ // end of each calendar-data section.
+
+ entryDescription = 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, entryDescription));
+ entryList.tag.insert(make_pair(responseCount, entryEntityTag));
+
+ responseCount++;
+
+ }
+
+ }
+
+ xmlFreeDoc(xmlCalDAVDoc);
+
+ 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);