From: Steve Brokenshire <sbrokenshire@xestia.co.uk>
Date: Sun, 6 Mar 2016 10:55:16 +0000 (+0000)
Subject: Added ProcessXMLCalenadrHome to the CalDAV Object.
X-Git-Tag: release-0.02~302
X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=2dfb7189efe8e02d37af274b2ec193b5ae058d85;p=xestiacalendar%2F.git

Added ProcessXMLCalenadrHome to the CalDAV Object.
---

diff --git a/source/objects/CalDAV/CalDAV-XMLProcessing.cpp b/source/objects/CalDAV/CalDAV-XMLProcessing.cpp
index 81d4674..1884533 100644
--- a/source/objects/CalDAV/CalDAV-XMLProcessing.cpp
+++ b/source/objects/CalDAV/CalDAV-XMLProcessing.cpp
@@ -84,6 +84,70 @@ string CalDAV::ProcessXMLUserPrincipal(){
 	
 }
 
+string CalDAV::ProcessXMLCalendarHome(){
+
+	string CalendarHomeURI;
+	
+	xmlDocPtr xmlCalDAVDoc;
+	xmlCalDAVDoc = xmlReadMemory(ServerData.c_str(), (int)ServerData.size(), "noname.xml", NULL, 0);
+
+	xmlNodePtr NodeSeek;
+	bool NodeFound = false;
+	
+	// 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")
+		){
+			
+			NodeFound = true;
+			break;
+			
+		}
+		
+	}
+	
+	// Look for response.
+
+	if (NodeFound == false){ return CalendarHomeURI; } else { NodeFound = false; }
+	NodeFound = MatchXMLName(&NodeSeek, "response");
+
+	// Look for propstat.
+	
+	if (NodeFound == false){ return CalendarHomeURI; } else { NodeFound = false; }
+	NodeFound = MatchXMLName(&NodeSeek, "propstat");
+
+	// Look for prop.
+	
+	if (NodeFound == false){ return CalendarHomeURI; } else { NodeFound = false; }
+	NodeFound = MatchXMLName(&NodeSeek, "prop");
+	
+	// Look for calendar-home-set.
+	
+	if (NodeFound == false){ return CalendarHomeURI; } else { NodeFound = false; }
+	NodeFound = MatchXMLName(&NodeSeek, "calendar-home-set");
+	
+	// Look for href.	
+	
+	if (NodeFound == false){ return CalendarHomeURI; } else { NodeFound = false; }
+	NodeFound = MatchXMLName(&NodeSeek, "href");
+
+	// Get the data from href.
+	
+	CalendarHomeURI = FetchXMLData(&NodeSeek);
+	
+	xmlFreeDoc(xmlCalDAVDoc);
+	
+	return CalendarHomeURI;
+	
+}
+
 bool CalDAV::MatchXMLName(xmlNodePtr *NodePtr, string NodeName){
 
 	string NodeNameSmallD = "d:" + NodeName;