ValidResponse = false;
}
- if (ValidResponse == false && AuthPassed == false){
+ if (ValidResponse == false || AuthPassed == false){
ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
ServerResponse.EntityTag = "";
ServerResponse.SessionCode = SessionResult;
ValidResponse = false;
}
- if (ValidResponse == false && AuthPassed == false){
+ if (ValidResponse == false || AuthPassed == false){
ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
ServerResponse.EntityTag = "";
ServerResponse.SessionCode = SessionResult;
}
COServerResponse CardDAV2::EditContact(std::string Location, std::string Data){
+
+ // Check if authentication was successful, otherwise don't do anything.
+
+ COServerResponse ServerResponse;
+
+ if (AuthPassed == false){
+ ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = 0;
+ ServerResponse.ResultCode = 0;
+ ServerResponse.ResultMessage = "";
+ return ServerResponse;
+ }
+
+ ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
+ ResetResults();
+
+ string ServerAddressURL = BuildURL(ServerPrefix + Location);
+ curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
+ curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "PUT");
+ curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, Data.c_str());
+ curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(Data.c_str()));
+
+ HeaderList = curl_slist_append(HeaderList, "Content-Type: text/vcard; charset=utf-8");
+
+ curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, HeaderList);
+
+ if (TestMode == true){
+ SessionResult = curl_easy_perform(ConnectionSession);
+ } else {
+ SessionResult = curl_easy_perform(ConnectionSession);
+ }
+
+ switch(SessionResult){
+ case CURLE_OK:
+ SSLStatus = true;
+ SSLVerified = COSSL_VERIFIED;
+ break;
+ case CURLE_SSL_CACERT:
+ case CURLE_SSL_CONNECT_ERROR:
+ SSLStatus = true;
+ SSLVerified = COSSL_UNABLETOVERIFY;
+ break;
+ default:
+ break;
+ };
+
+ long SessionResponseCode = 0;
+
+ curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
+
+ if (SessionResponseCode == 200 || SessionResponseCode == 201 || SessionResponseCode == 204){
+ AuthPassed = true;
+ ValidResponse = true;
+ } else if (SessionResponseCode == 403){
+ AuthPassed = false;
+ ValidResponse = true;
+ } else if (SessionResponseCode >= 400){
+ AuthPassed = false;
+ ValidResponse = true;
+ } else {
+ AuthPassed = false;
+ ValidResponse = false;
+ }
+
+ if (ValidResponse == false || AuthPassed == false){
+ ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = SessionResult;
+ ServerResponse.ResultCode = SessionResponseCode;
+ ServerResponse.ResultMessage = "";
+ return ServerResponse;
+ }
+
+ CanProcess = true;
+
+ ServerResponse.RequestResult = COREQUEST_OK;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = SessionResult;
+ ServerResponse.ResultCode = SessionResponseCode;
+ ServerResponse.ResultMessage = SessionErrorBuffer;
+ return ServerResponse;
}
-COServerResponse CardDAV2::DeleteContact(std::string Location, std::string EntityTag){
+COServerResponse CardDAV2::DeleteContact(std::string Location){
+
+ // Check if authentication was successful, otherwise don't do anything.
+
+ COServerResponse ServerResponse;
+
+ if (AuthPassed == false){
+ ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = 0;
+ ServerResponse.ResultCode = 0;
+ ServerResponse.ResultMessage = "";
+ return ServerResponse;
+ }
+
+ ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
+ ResetResults();
+
+ string ServerAddressURL = BuildURL(ServerPrefix + Location);
+ curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
+ curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "DELETE");
+
+ if (TestMode == true){
+ SessionResult = curl_easy_perform(ConnectionSession);
+ } else {
+ SessionResult = curl_easy_perform(ConnectionSession);
+ }
+
+ switch(SessionResult){
+ case CURLE_OK:
+ SSLStatus = true;
+ SSLVerified = COSSL_VERIFIED;
+ break;
+ case CURLE_SSL_CACERT:
+ case CURLE_SSL_CONNECT_ERROR:
+ SSLStatus = true;
+ SSLVerified = COSSL_UNABLETOVERIFY;
+ break;
+ default:
+ break;
+ };
+
+ long SessionResponseCode = 0;
+
+ curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
+
+ if (SessionResponseCode == 200 || SessionResponseCode == 202 || SessionResponseCode == 204){
+ AuthPassed = true;
+ ValidResponse = true;
+ } else if (SessionResponseCode == 403){
+ AuthPassed = false;
+ ValidResponse = true;
+ } else if (SessionResponseCode >= 400){
+ AuthPassed = false;
+ ValidResponse = true;
+ } else {
+ AuthPassed = false;
+ ValidResponse = false;
+ }
+
+ if (ValidResponse == false || AuthPassed == false){
+ ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = SessionResult;
+ ServerResponse.ResultCode = SessionResponseCode;
+ ServerResponse.ResultMessage = "";
+ return ServerResponse;
+ }
+
+ CanProcess = true;
+
+ ServerResponse.RequestResult = COREQUEST_OK;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = SessionResult;
+ ServerResponse.ResultCode = SessionResponseCode;
+ ServerResponse.ResultMessage = SessionErrorBuffer;
+ return ServerResponse;
}
COServerResponse CardDAV2::GetServerEntityTagValue(std::string Location){
+ // Check if authentication was successful, otherwise don't do anything.
+
+ COServerResponse ServerResponse;
+
+ if (AuthPassed == false){
+ ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = 0;
+ ServerResponse.ResultCode = 0;
+ ServerResponse.ResultMessage = "";
+ return ServerResponse;
+ }
+
+ ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
+ ResetResults();
+
+ static const char* GetETagQuery =
+ "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
+ "<C:addressbook-query xmlns:D=\"DAV:\""
+ " xmlns:C=\"urn:ietf:params:xml:ns:carddav\">"
+ "<D:prop><D:getetag/>"
+ "</D:prop>"
+ "<C:filter/>"
+ "</C:addressbook-query>";
+
+ string ServerAddressURL = BuildURL(ServerPrefix + Location);
+ curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
+ curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "REPORT");
+ curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, GetETagQuery);
+ curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(GetETagQuery));
+
+ if (TestMode == true){
+ SessionResult = curl_easy_perform(ConnectionSession);
+ } else {
+ SessionResult = curl_easy_perform(ConnectionSession);
+ }
+
+ switch(SessionResult){
+ case CURLE_OK:
+ SSLStatus = true;
+ SSLVerified = COSSL_VERIFIED;
+ break;
+ case CURLE_SSL_CACERT:
+ case CURLE_SSL_CONNECT_ERROR:
+ SSLStatus = true;
+ SSLVerified = COSSL_UNABLETOVERIFY;
+ break;
+ default:
+ break;
+ };
+
+ long SessionResponseCode = 0;
+
+ curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
+
+ if (SessionResponseCode == 207){
+ AuthPassed = true;
+ ValidResponse = true;
+ } else if (SessionResponseCode == 403){
+ AuthPassed = false;
+ ValidResponse = true;
+ } else if (SessionResponseCode >= 400){
+ AuthPassed = false;
+ ValidResponse = true;
+ } else {
+ AuthPassed = false;
+ ValidResponse = false;
+ }
+
+ if (ValidResponse == false || AuthPassed == false){
+ ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = SessionResult;
+ ServerResponse.ResultCode = SessionResponseCode;
+ ServerResponse.ResultMessage = "";
+ return ServerResponse;
+ }
+
+ CanProcess = true;
+
+ ServerResponse.RequestResult = COREQUEST_OK;
+ ServerResponse.EntityTag = GetETagValue();
+ ServerResponse.SessionCode = SessionResult;
+ ServerResponse.ResultCode = SessionResponseCode;
+ ServerResponse.ResultMessage = SessionErrorBuffer;
+
+ return ServerResponse;
+
}
-COServerResponse CardDAV2::GetContact(std::string Location){
+COServerResponse CardDAV2::GetContact(std::string Location, std::string *ContactData){
+
+ // Check if authentication was successful, otherwise don't do anything.
+
+ COServerResponse ServerResponse;
+
+ if (AuthPassed == false){
+ ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = 0;
+ ServerResponse.ResultCode = 0;
+ ServerResponse.ResultMessage = "";
+ return ServerResponse;
+ }
+
+ ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
+ ResetResults();
+
+ string ServerAddressURL = BuildURL(ServerPrefix + Location);
+ curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
+ curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "GET");
+
+ if (TestMode == true){
+ SessionResult = curl_easy_perform(ConnectionSession);
+ } else {
+ SessionResult = curl_easy_perform(ConnectionSession);
+ }
+
+ switch(SessionResult){
+ case CURLE_OK:
+ SSLStatus = true;
+ SSLVerified = COSSL_VERIFIED;
+ break;
+ case CURLE_SSL_CACERT:
+ case CURLE_SSL_CONNECT_ERROR:
+ SSLStatus = true;
+ SSLVerified = COSSL_UNABLETOVERIFY;
+ break;
+ default:
+ break;
+ };
+
+ long SessionResponseCode = 0;
+
+ curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
+
+ if (SessionResponseCode == 200){
+ AuthPassed = true;
+ ValidResponse = true;
+ } else if (SessionResponseCode == 403){
+ AuthPassed = false;
+ ValidResponse = true;
+ } else if (SessionResponseCode >= 400){
+ AuthPassed = false;
+ ValidResponse = true;
+ } else {
+ AuthPassed = false;
+ ValidResponse = false;
+ }
+
+ if (ValidResponse == false && AuthPassed == false){
+ ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = SessionResult;
+ ServerResponse.ResultCode = SessionResponseCode;
+ ServerResponse.ResultMessage = "";
+ return ServerResponse;
+ }
+
+ CanProcess = true;
+
+ ServerResponse.RequestResult = COREQUEST_OK;
+ ServerResponse.EntityTag = "";
+ ServerResponse.SessionCode = SessionResult;
+ ServerResponse.ResultCode = SessionResponseCode;
+ ServerResponse.ResultMessage = SessionErrorBuffer;
+
+ (*ContactData) = PageData;
+
+ return ServerResponse;
}
COContactList CardDAV2::GetContactList(std::string SyncToken){
+ COContactList ServerContactList;
+
+ // Check if authentication was successful, otherwise don't do anything.
+
+ if (AuthPassed == false){
+ ServerContactList.ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ ServerContactList.ServerResponse.EntityTag = "";
+ ServerContactList.ServerResponse.SessionCode = 0;
+ ServerContactList.ServerResponse.ResultCode = 0;
+ ServerContactList.ServerResponse.ResultMessage = "";
+ return ServerContactList;
+ }
+
+ ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
+ ResetResults();
+
+ std::string SyncData;
+
+ // TODO: Copy old code from CardDAV class as needed.
+
+ if (SyncToken.size() > 0){
+
+ SyncData = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
+ "<D:sync-collection xmlns:D=\"DAV:\"\n"
+ " xmlns:C=\"urn:ietf:params:xml:ns:carddav\">\n"
+ "<D:sync-token>";
+ SyncData.append(SyncToken);
+ SyncData.append("</D:sync-token>\n"
+ "<D:sync-level>1</D:sync-level>\n"
+ "<D:prop>\n"
+ " <D:getetag/>\n"
+ "</D:prop>\n"
+ "</D:sync-collection>");
+
+ } else {
+
+ SyncData = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
+ "<D:sync-collection xmlns:D=\"DAV:\"\n"
+ " xmlns:C=\"urn:ietf:params:xml:ns:carddav\">\n"
+ "<D:sync-level>1</D:sync-level>\n"
+ "<D:prop>\n"
+ " <D:getetag/>\n"
+ "</D:prop>\n"
+ "</D:sync-collection>";
+
+ }
+
+ string ServerAddressURL = BuildURL(ServerPrefix);
+
+ std::cout << SyncData << std::endl;
+
+ curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
+ curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, SyncData.c_str());
+ curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(SyncData.c_str()));
+ curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "REPORT");
+
+ HeaderList = curl_slist_append(HeaderList, "Content-Type: application/xml; charset=utf-8");
+ HeaderList = curl_slist_append(HeaderList, "Depth: 1");
+
+ curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, HeaderList);
+
+ if (TestMode == true){
+ SessionResult = curl_easy_perform(ConnectionSession);
+ } else {
+ SessionResult = curl_easy_perform(ConnectionSession);
+ }
+
+ switch(SessionResult){
+ case CURLE_OK:
+ SSLStatus = true;
+ SSLVerified = COSSL_VERIFIED;
+ break;
+ case CURLE_SSL_CACERT:
+ case CURLE_SSL_CONNECT_ERROR:
+ SSLStatus = true;
+ SSLVerified = COSSL_UNABLETOVERIFY;
+ break;
+ default:
+ break;
+ };
+
+ long SessionResponseCode = 0;
+
+ curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
+
+ if (SessionResponseCode == 207){
+ AuthPassed = true;
+ ValidResponse = true;
+ } else if (SessionResponseCode == 403){
+ AuthPassed = false;
+ ValidResponse = true;
+ } else if (SessionResponseCode >= 400){
+ AuthPassed = false;
+ ValidResponse = true;
+ } else {
+ AuthPassed = false;
+ ValidResponse = false;
+ }
+
+ if (ValidResponse == false || AuthPassed == false){
+ ServerContactList.ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
+ ServerContactList.ServerResponse.EntityTag = "";
+ ServerContactList.ServerResponse.SessionCode = SessionResult;
+ ServerContactList.ServerResponse.ResultCode = SessionResponseCode;
+ ServerContactList.ServerResponse.ResultMessage = "";
+ return ServerContactList;
+ }
+
+ CanProcess = true;
+
+ ProcessContactData(&ServerContactList);
+
+ ServerContactList.ServerResponse.RequestResult = COREQUEST_OK;
+ ServerContactList.ServerResponse.EntityTag = "";
+ ServerContactList.ServerResponse.SessionCode = SessionResult;
+ ServerContactList.ServerResponse.ResultCode = SessionResponseCode;
+ ServerContactList.ServerResponse.ResultMessage = SessionErrorBuffer;
+
+ return ServerContactList;
+
}
bool CardDAV2::CanDoProcessing(){
curl_easy_setopt(ConnectionSession, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, nullptr);
+ curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, nullptr);
+ curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, 0L);
if (DoAuthentication == true){
curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, UsernamePassword.c_str());
curl_easy_setopt(ConnectionSession, CURLOPT_VERBOSE, 1);
curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, nullptr);
+ curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, nullptr);
+ curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, 0L);
if (DoAuthentication == true){
curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, UsernamePassword.c_str());
}
+string CardDAV2::GetETagValue(){
+
+ xmlDocPtr xmlCardDAVDoc;
+
+ xmlCardDAVDoc = xmlReadMemory(PageData.c_str(), (int)PageData.size(), "noname.xml", NULL, 0);
+
+ xmlNodePtr nodeLevel1;
+ xmlNodePtr nodeLevel2;
+ xmlNodePtr nodeLevel3;
+ xmlNodePtr nodeLevel4;
+ xmlNodePtr nodeLevel5;
+ xmlNodePtr nodeLevel6;
+
+ //std::map<wxString,wxString> xmlDataMap;
+
+ std::string DataFilename;
+ std::string ETagData;
+
+ std::string xmlStringSafe;
+ std::string ETagValue;
+
+ // Tranverse through the catacombs of the response to get our ETag for the file.
+
+ for (nodeLevel1 = xmlCardDAVDoc->children;
+ nodeLevel1 != NULL;
+ nodeLevel1 = nodeLevel1->next)
+ {
+
+ bool HREFFound = FALSE;
+ bool ETagFound = FALSE;
+
+ for (nodeLevel2 = nodeLevel1->children;
+ nodeLevel2 != NULL;
+ nodeLevel2 = nodeLevel2->next)
+ {
+
+ for (nodeLevel3 = nodeLevel2->children;
+ nodeLevel3 != NULL;
+ nodeLevel3 = nodeLevel3->next)
+ {
+
+ if (!xmlStrcmp(nodeLevel3->name, (const xmlChar *)"href") ||
+ !xmlStrcmp(nodeLevel3->name, (const xmlChar *)"d:href") ||
+ !xmlStrcmp(nodeLevel3->name, (const xmlChar *)"D:href")
+ ){
+
+ // Get the filename.
+
+ for (nodeLevel4 = nodeLevel3->children;
+ nodeLevel4 != NULL;
+ nodeLevel4 = nodeLevel4->next)
+ {
+
+ if (!xmlStrcmp(nodeLevel4->name, (const xmlChar *)"text") ||
+ !xmlStrcmp(nodeLevel4->name, (const xmlChar *)"d:text") ||
+ !xmlStrcmp(nodeLevel4->name, (const xmlChar *)"D:text")
+ ){
+
+ DataFilename = wxString::FromUTF8((const char*)nodeLevel4->content);
+ wxStringTokenizer wSTDFilename(DataFilename, wxT("/"));
+
+ while (wSTDFilename.HasMoreTokens()){
+
+ DataFilename = wSTDFilename.GetNextToken().ToStdString();
+
+ }
+
+ HREFFound = TRUE;
+
+ }
+
+
+
+ }
+
+ } else {
+
+ for (nodeLevel4 = nodeLevel3->children;
+ nodeLevel4 != NULL;
+ nodeLevel4 = nodeLevel4->next)
+ {
+
+ for (nodeLevel5 = nodeLevel4->children;
+ nodeLevel5 != NULL;
+ nodeLevel5 = nodeLevel5->next)
+ {
+
+ if (!xmlStrcmp(nodeLevel5->name, (const xmlChar *)"getetag") ||
+ !xmlStrcmp(nodeLevel5->name, (const xmlChar *)"d:getetag") ||
+ !xmlStrcmp(nodeLevel5->name, (const xmlChar *)"D:getetag")
+ ){
+
+ for (nodeLevel6 = nodeLevel5->children;
+ nodeLevel6 != NULL;
+ nodeLevel6 = nodeLevel6->next)
+ {
+
+ // Strip the quotes from the ETag.
+
+ ETagData = (const char*)nodeLevel6->content;
+ if (ETagData[0] == '"' && ETagData[(ETagData.size() - 1)] == '"'){
+
+ ETagData.erase(0, 1);
+ ETagData.erase((ETagData.size() - 1));
+
+ }
+
+ ETagFound = TRUE;
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ if (HREFFound == TRUE && ETagFound == TRUE){
+
+ // Add to the map data.
+
+ ETagValue = ETagData;
+
+ HREFFound = FALSE;
+ ETagFound = FALSE;
+ break;
+
+ }
+
+
+ }
+
+ xmlFreeDoc(xmlCardDAVDoc);
+
+ return ETagValue;
+
+}
+
string CardDAV2::GetETagHeader(){
// Go through each of the lines looking for the
return DAVHeaderList;
+}
+
+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;
+
}
\ No newline at end of file