Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Perform checks if XML Node(s) have been found or not.
[xestiacalendar/.git] / source / objects / CalDAV / CalDAV-XMLProcessing.cpp
index 38e26c7..8f39d86 100644 (file)
@@ -49,6 +49,12 @@ string CalDAV::ProcessXMLUserPrincipal(){
                
        }
        
+       if (NodeFound == false){
+       
+               return UserPrincipalURI;
+
+       }
+       
        // Look for response.
 
        if (NodeFound == false){ return UserPrincipalURI; } else { NodeFound = false; }
@@ -113,6 +119,12 @@ string CalDAV::ProcessXMLCalendarHome(){
                
        }
        
+       if (NodeFound == false){
+       
+               return CalendarHomeURI;
+
+       }
+       
        // Look for response.
 
        if (NodeFound == false){ return CalendarHomeURI; } else { NodeFound = false; }
@@ -182,6 +194,12 @@ CalDAVCalendarList CalDAV::ProcessXMLCalendarList(){
                
        }
        
+       if (NodeFound == false){
+       
+               return CalendarList;
+
+       }
+       
        for (NodeResponse = NodeSeek->children;
                NodeResponse != nullptr;
                NodeResponse = NodeResponse->next)
@@ -333,6 +351,20 @@ CalDAVCalendarList CalDAV::ProcessXMLCalendarList(){
                                
                        }
                        
+                       // Get the calendar tag URL.
+                       
+                       NodeData = xmlCopyNode(NodeMatch, 1);
+                       
+                       string CalendarTagURL = "";
+                       
+                       if (!MatchXMLNameTransverse(&NodeData, "propstat")){ continue; }
+                       if (!MatchXMLNameTransverse(&NodeData, "prop")){ continue; }
+                       if (MatchXMLNameTransverse(&NodeData, "sync-token")){ 
+                               
+                               CalendarTagURL = FetchXMLData(&NodeData);
+                               
+                       }
+                       
                        // Insert the calendar information into the
                        // list if all the information is there.
                        
@@ -342,6 +374,7 @@ CalDAVCalendarList CalDAV::ProcessXMLCalendarList(){
                        CalendarList.CalColour.insert(make_pair(ResponseCount, CalendarColour));
                        CalendarList.Order.insert(make_pair(ResponseCount, CalendarOrder));
                        CalendarList.Tag.insert(make_pair(ResponseCount, CalendarTag));
+                       CalendarList.TagURL.insert(make_pair(ResponseCount, CalendarTagURL));
                        
                        ResponseCount++;
                        
@@ -355,6 +388,82 @@ CalDAVCalendarList CalDAV::ProcessXMLCalendarList(){
        
 }
 
+string CalDAV::ProcessXMLEntryETag(){
+       
+       string EntryETag;
+       
+       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;
+                       
+               }
+               
+       }
+       
+       if (NodeFound == false){
+       
+               return EntryETag;
+
+       }
+       
+       // Look for response.
+       
+       if (NodeFound == false){ return EntryETag; } else { NodeFound = false; }
+       NodeFound = MatchXMLNameTransverse(&NodeSeek, "response");
+
+       // Look for propstat.
+       
+       if (NodeFound == false){ return EntryETag; } else { NodeFound = false; }
+       NodeFound = MatchXMLNameTransverse(&NodeSeek, "propstat");
+
+       // Look for prop.
+       
+       if (NodeFound == false){ return EntryETag; } else { NodeFound = false; }
+       NodeFound = MatchXMLNameTransverse(&NodeSeek, "prop");
+       
+       // Look for calendar-home-set.
+       
+       if (NodeFound == false){ return EntryETag; } else { NodeFound = false; }
+       NodeFound = MatchXMLNameTransverse(&NodeSeek, "getetag");
+
+       // Get the data from href.
+       
+       EntryETag = FetchXMLData(&NodeSeek);    
+       
+       xmlFreeDoc(xmlCalDAVDoc);       
+       
+       // Check if the entity tag contains quote marks
+       // at the start and end and remove them (if needed).
+       
+       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;
+       
+}
+
 bool CalDAV::MatchXMLNameTransverse(xmlNodePtr *NodePtr, string NodeName){
 
        string NodeNameSmallD = "d:" + NodeName;
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy