+}
+
+void CardDAV2::ProcessContactData(COContactList *ContactList){
+
+ xmlDocPtr xmlCardDAVDoc;
+ xmlCardDAVDoc = xmlReadMemory(PageData.c_str(), (int)PageData.size(), "noname.xml", NULL, 0);
+
+ xmlNodePtr MultiStatusNode;
+ xmlNodePtr ResponseNode;
+ xmlNodePtr ResponseDataNode;
+ xmlNodePtr PropStatNode;
+ xmlNodePtr ValueNode;
+ xmlNodePtr ETagNode;
+ xmlNodePtr StatusNode;
+
+ std::string HREFValue;
+ std::string ETagValue;
+ std::string StatusValue;
+ std::string SyncValue;
+
+ // Go through the document!
+
+ MultiStatusNode = xmlCardDAVDoc->children;
+
+ if (MultiStatusNode == nullptr){
+ return;
+ }
+
+ bool SyncTokenFound = false;
+
+ // Tranverse through the catacombs of the response to get our ETag for the file and
+ // the server syncronisation token.
+
+ for (ResponseNode = MultiStatusNode->children;
+ ResponseNode != nullptr;
+ ResponseNode = ResponseNode->next){
+
+ // Check if tag is response or sync-token.
+
+ if (!xmlStrcmp(ResponseNode->name, (const xmlChar *)"response") ||
+ !xmlStrcmp(ResponseNode->name, (const xmlChar *)"d:response") ||
+ !xmlStrcmp(ResponseNode->name, (const xmlChar *)"D:response")){
+
+ COContactStatus ContactStatus = COCS_UNKNOWN;
+
+ for (ResponseDataNode = ResponseNode->children;
+ ResponseDataNode != nullptr;
+ ResponseDataNode = ResponseDataNode->next){
+
+ if (!xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"href") ||
+ !xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"d:href") ||
+ !xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"D:href")){
+
+ HREFValue = (const char*)ResponseDataNode->children->content;
+
+ // Get the filename after the last forward slash.
+
+ int LastSlash = 0;
+
+ for (int HREFValueSeek = 0; HREFValueSeek < HREFValue.size(); HREFValueSeek++){
+
+ if (HREFValue[HREFValueSeek] == '/'){
+
+ LastSlash = HREFValueSeek;
+
+ }
+
+ }
+
+ HREFValue = HREFValue.substr((LastSlash + 1));
+
+ } else if (!xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"propstat") ||
+ !xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"d:propstat") ||
+ !xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"D:propstat")){
+
+ for (PropStatNode = ResponseDataNode->children;
+ PropStatNode != nullptr;
+ PropStatNode = PropStatNode->next){
+
+ if (!xmlStrcmp(PropStatNode->name, (const xmlChar *)"prop") ||
+ !xmlStrcmp(PropStatNode->name, (const xmlChar *)"d:prop") ||
+ !xmlStrcmp(PropStatNode->name, (const xmlChar *)"D:prop")){
+
+ for (ETagNode = PropStatNode->children;
+ ETagNode != nullptr;
+ ETagNode = ETagNode->next){
+
+ if (!xmlStrcmp(ETagNode->name, (const xmlChar *)"getetag") ||
+ !xmlStrcmp(ETagNode->name, (const xmlChar *)"getetag") ||
+ !xmlStrcmp(ETagNode->name, (const xmlChar *)"getetag")){
+
+ ETagValue = (const char*)ETagNode->children->content;
+
+ if (ETagValue.size() > 2 && ETagValue.substr(0,1) == "\""){
+ ETagValue.erase((ETagValue.size() - 1),1);
+ ETagValue.erase(0,1);
+ }
+
+ }
+
+
+ }
+
+ } else if (!xmlStrcmp(PropStatNode->name, (const xmlChar *)"status") ||
+ !xmlStrcmp(PropStatNode->name, (const xmlChar *)"d:status") ||
+ !xmlStrcmp(PropStatNode->name, (const xmlChar *)"D:status")){
+
+ StatusValue = (const char*)PropStatNode->children->content;
+
+ if (StatusValue == "HTTP/1.1 200 OK"){
+
+ ContactStatus = COCS_UPDATED;
+
+ } else if (StatusValue == "HTTP/1.1 404 Not Found"){
+
+ ContactStatus = COCS_DELETED;
+
+ } else {
+
+ ContactStatus = COCS_UNKNOWN;
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ COContactData ContactInformation;
+
+ ContactInformation.Location = HREFValue;
+ ContactInformation.Data = ETagValue;
+ ContactInformation.Status = ContactStatus;
+
+ HREFValue.clear();
+ ETagValue.clear();
+ StatusValue.clear();
+
+ ContactList->ListData.push_back(ContactInformation);
+
+ } else if (!xmlStrcmp(ResponseNode->name, (const xmlChar *)"sync-token") ||
+ !xmlStrcmp(ResponseNode->name, (const xmlChar *)"d:sync-token") ||
+ !xmlStrcmp(ResponseNode->name, (const xmlChar *)"D:sync-token")){
+
+ SyncValue = (const char*)ResponseNode->children->content;
+
+ }
+
+ }
+
+ ContactList->SyncToken = SyncValue;
+
+ xmlFreeDoc(xmlCardDAVDoc);
+
+ return;
+
+}