Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
TODOs: Remove TODOs no longer needed from code
[xestiaab/.git] / source / carddav2 / carddav2.cpp
1 // CardDAV2.cpp - CardDAV v2 class
2 //
3 // (c) 2012-2016 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/> 
19 #include "carddav2.h"
21 using namespace std;
23 CardDAV2::CardDAV2(string ServerAddress, int ServerPort, string ServerUser, string ServerPass, bool ServerSSL){
25         this->ServerAddress = ServerAddress;
26         this->ServerPort = ServerPort;
27         this->ServerUser = ServerUser;
28         this->ServerPass = ServerPass;
29         this->ServerSSL = ServerSSL;
31         TestMode = true;
32         this->SetupConnectionObject();
34 }
36 CardDAV2::CardDAV2(string ServerAddress, int ServerPort, string ServerUser, string ServerPass, bool ServerSSL, string ServerPrefix, string ServerAccount){
38         this->ServerAddress = ServerAddress;
39         this->ServerPort = ServerPort;
40         this->ServerUser = ServerUser;
41         this->ServerPass = ServerPass;
42         this->ServerSSL = ServerSSL;
43         this->ServerPrefix = ServerPrefix;
44         this->ServerAccount = ServerAccount;
47         TestMode = false;
48         this->SetupConnectionObject();
50 }
52 size_t CardDAV2::WritebackFunc(char *ptr, size_t size, size_t nmemb, void *stream){
54         return static_cast<CardDAV2PassObject*>(stream)->CardDAV2Object->WritebackFuncImplementation(ptr, size, nmemb, stream);
55         
56 }
58 size_t CardDAV2::WritebackFuncImplementation(char *ptr, size_t size, size_t nmemb, void *stream){
59         
60         // Writeback function for the CardDAV object.
61                 
62         CardDAV2PassObject *data = static_cast<CardDAV2PassObject*>(stream);
63         data->DataSetting->append(ptr);
64         
65         // Get the SSL engine pointer and trust if required on certain operating systems.
67         if (data->ServerUsingSSL == true) {
69 #if defined(__APPLE__)
71                 const struct curl_tlssessioninfo *TLSInfo;
72                 CURLcode TLSCode;
73                 TLSCode = curl_easy_getinfo(data->ConnectionSessionObject, CURLINFO_TLS_SSL_PTR, &TLSInfo);
75                 SecTrustRef CertificateData;
76                 
77                 if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK) {
78                         SSLCopyPeerTrust((SSLContext*)TLSInfo->internals, &CertificateData);
79                         data->SSLContext = CertificateData;
80                 }
82 #elif defined(__WIN32__)
84                 const struct curl_tlssessioninfo *TLSInfo;
85                 CURLcode TLSCode;
86                 TLSCode = curl_easy_getinfo(data->ConnectionSessionObject, CURLINFO_TLS_SSL_PTR, &TLSInfo);
88                 if (TLSInfo->internals != nullptr && TLSCode == CURLE_OK) {
90                         // Free the previous certificate data.
92                         //CertFreeCertificateContext(CertificateData);
94                         PCCERT_CONTEXT CertificateData;
96                         PCtxtHandle SSLHandle = (PCtxtHandle)TLSInfo->internals;
97                         SECURITY_STATUS GetData = QueryContextAttributes(SSLHandle, SECPKG_ATTR_REMOTE_CERT_CONTEXT, &CertificateData);
99                         data->SSLContext = CertificateData;
101                 }
103 #endif
105         }
107         return size * nmemb;
111 void CardDAV2::SetCertificateData() {
115 CardDAV2::~CardDAV2(){
116         
117         curl_easy_cleanup(ConnectionSession);
118         ConnectionSession = nullptr;
119         
120         if (HeaderList != nullptr){
121                 curl_slist_free_all(HeaderList);
122                 HeaderList = nullptr;
123         }
125 #if defined(__WIN32__)
127         if (CertificateData != nullptr) {
129                 CertFreeCertificateContext(CertificateData);
131         }
133 #endif
134         
137 #if defined(__APPLE__)
139 SecTrustRef CardDAV2::BuildSSLCollection(){
140         
141         return CertificateData;
142         
145 #elif defined(__WIN32__)
147 PCCERT_CONTEXT CardDAV2::BuildSSLCollection(){
149         return CertificateData;
153 #else
155 SSLCertCollectionString CardDAV2::BuildSSLCollection(){
157         // Build and return the SSL collection.
158         
159         SSLCertCollectionString SSLCertInfo;
161         // Grab the certificate data.
163         union {
164                 struct curl_slist *certdata;
165                 struct curl_certinfo *certinfo;
166         } certptr;
168         certptr.certdata = NULL;
169         
170         CURLcode result = curl_easy_getinfo(ConnectionSession, CURLINFO_CERTINFO, &certptr.certinfo);
171         
172         std::string CertPropName;
173         std::string CertPropValue;
174         
175         for (int i = 0; i < certptr.certinfo->num_of_certs; i++){
176                 
177                 struct curl_slist *slist;
178                 SSLCertDataString SSLCertDataInc;
179                 
180                 for (slist = certptr.certinfo->certinfo[i]; slist; slist = slist->next){
181                         
182                         // Using wxStringTokenizer from wxWidgets.
183                         
184                         wxStringTokenizer CertDataInc(wxString::FromUTF8(slist->data), ":");
185                         
186                         // Get first token as the property name.
187                         
188                         CertPropName = CertDataInc.GetNextToken().ToStdString();
189                         
190                         // Get remaining tokens as the property value.
191                         
192                         while(CertDataInc.HasMoreTokens()){
193                         
194                                 CertPropValue.append(CertDataInc.GetNextToken());
195                         
196                         }
197                         
198                         SSLCertDataInc.CertData.insert(std::make_pair(CertPropName, CertPropValue));
199                         CertPropName.clear();
200                         CertPropValue.clear();
201                         
202                 }
203         
204                 SSLCertInfo.SSLCollection.insert(std::make_pair(i, SSLCertDataInc));
205         
206         }
207         
208         return SSLCertInfo;
212 #endif
214 void CardDAV2::BypassSSLVerification(bool EnableBypass) {
215         EnableSSLBypass = EnableBypass;
216         SSLSelfSigned = EnableBypass;
219 void CardDAV2::SetupConnectionObject(){
220         ConnectionSession = curl_easy_init();
223 bool CardDAV2::IsTaskCompleted(){
224         return false;
227 COConnectResult CardDAV2::Connect(bool DoAuthentication){
228         
229         ServerSSL ? SetupDefaultParametersSSL(DoAuthentication) : SetupDefaultParametersNonSSL(DoAuthentication);
230         ResetResults();
231         
232         COConnectResult ConnectResult = COCONNECT_UNITTESTFAIL;
233         string ServerAddressURL = BuildURL("/principals/");
234         
235         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
236         
237         if (TestMode == true){
238                 SessionResult = curl_easy_perform(ConnectionSession);
239         } else {
240                 SessionResult = curl_easy_perform(ConnectionSession);           
241         }
242         
243         switch(SessionResult){
244                 case CURLE_OK:
245                 case CURLE_HTTP_RETURNED_ERROR:
246                         SSLStatus = true;
247                         SSLVerified = COSSL_VERIFIED;
248                         ConnectResult = COCONNECT_OK;
249                         break;
250                 case CURLE_SSL_CACERT:
251                 case CURLE_SSL_CONNECT_ERROR:
252                         SSLStatus = true;
253                         ConnectResult = COCONNECT_OK;
254                         SSLVerified = COSSL_UNABLETOVERIFY;
255                         break;
256                 default:
257                         ConnectResult = COCONNECT_INVALID;
258                         break;
259         };
260         
261         // Set the certificate data (if required).
263 #if defined(__APPLE__)
264         
265         if (ServerSSL) {
266                 
267                 CertificateData = PageHeaderObject.SSLContext;
268                 
269         }
270         
271 #elif defined(__WIN32__)
273         if (ServerSSL) {
275                 CertificateData = PageHeaderObject.SSLContext;
277         }
279 #endif
281         // Check if an error occured before continuing.
282         
283         // Check if authentication was successful.
284         
285         long SessionResponseCode = 0;
286         
287         curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
288         
289         if (DoAuthentication == true){
290                 
291                 // Get the HTTP status code (Should be 200 and not 403).
292                 // Return error otherwise.
293                 
294                 if (SessionResponseCode == 200){
295                         ConnectResult = COCONNECT_OK;
296                         AuthPassed = true;
297                         ValidResponse = true;
298                 } else if (SessionResponseCode == 401){
299                         ConnectResult = COCONNECT_AUTHFAIL;
300                         AuthPassed = false;
301                         ValidResponse = true;
302                 } else if (SessionResponseCode >= 200) {
303                         ConnectResult = COCONNECT_INVALID;
304                         AuthPassed = false;
305                         ValidResponse = true;
306                 } else {
307                         ConnectResult = COCONNECT_INVALID;
308                         AuthPassed = false;
309                         ValidResponse = false;                  
310                 }
311                 
312         } else {
313                 
314                 ValidResponse = true;
315                 
316         }
317         
318         // Check the header to see if CardDAV is supported.
319         
320         vector<string> DAVHeaderValues = GetDAVHeader();
321         
322         for (vector<string>::iterator DAVHeaderValuesIter = DAVHeaderValues.begin();
323                 DAVHeaderValuesIter != DAVHeaderValues.end(); DAVHeaderValuesIter++){
324                 
325                 if ((*DAVHeaderValuesIter) == "addressbook"){
326                         CanProcess = true;
327                         break;
328                 }
329                         
330         }
331         
332         return ConnectResult;
333         
336 COServerResponse CardDAV2::GetDefaultPrefix(string *ServerPrefix){
338         // Check if authentication was successful, otherwise don't do anything.
340         COServerResponse ServerResponse;
341         
342         if (AuthPassed == false){
343                 ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
344                 ServerResponse.EntityTag = "";
345                 ServerResponse.SessionCode = 0;
346                 ServerResponse.ResultCode = 0;
347                 ServerResponse.ResultMessage = "";
348                 return ServerResponse;
349         }
351         ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
352         ResetResults();
353         
354         // Need to do three requests:
355         
356         // 1. Get the current user principal URI.
357         // 2. Get the address book home URI.
358         // 3. Get the default address book URI.
359         
360         // Setup the first query finding out where the principal URL is.
361         
362         const char* CurrentUserPrincipalXMLQuery = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
363                 "<D:propfind xmlns:D=\"DAV:\">\n"
364                 " <D:prop>"
365                 "  <D:current-user-principal/>\n"
366                 " </D:prop>"
367                 "</D:propfind>";
369         // Setup the second query finding out where the address book home URL is.
370         
371         const char* AddressBookHomeXMLQuery = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
372         "<D:propfind xmlns:D=\"DAV:\""
373         "  xmlns:C=\"urn:ietf:params:xml:ns:carddav\">\n"
374         "  <D:prop>\n"
375         "    <C:addressbook-home-set/>\n"
376         "  </D:prop>\n"
377         "</D:propfind>";
378         
379         // Setup the third query finding out where the default address book URL is.
380         
381         const char* DefaultAddressBookXMLQuery = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
382         "<D:propfind xmlns:D=\"DAV:\""
383         "  xmlns:C=\"urn:ietf:params:xml:ns:carddav\">\n"
384         "  <D:prop>\n"
385         "    <C:default-addressbook-URL/>\n"    
386         "  </D:prop>\n"
387         "</D:propfind>";
388         
389         string ServerAddressURL = BuildURL("/principals/");
390         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
391         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "PROPFIND");
392         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, CurrentUserPrincipalXMLQuery);
393         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(CurrentUserPrincipalXMLQuery));
394         
395         if (TestMode == true){
396                 SessionResult = curl_easy_perform(ConnectionSession);
397         } else {
398                 
399         }
400         
401         switch(SessionResult){
402                 case CURLE_OK:
403                         SSLStatus = true;
404                         SSLVerified = COSSL_VERIFIED;
405                         break;
406                 case CURLE_SSL_CACERT:
407                 case CURLE_SSL_CONNECT_ERROR:
408                         SSLStatus = true;
409                         SSLVerified = COSSL_UNABLETOVERIFY;
410                         break;
411                 default:
412                         break;
413         };
414         
415         long SessionResponseCode = 0;
416         
417         curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
418         
419         if (SessionResponseCode == 200 || SessionResponseCode == 207){
420                 AuthPassed = true;
421                 ValidResponse = true;
422         } else if (SessionResponseCode == 403){
423                 AuthPassed = false;
424                 ValidResponse = true;
425         } else if (SessionResponseCode >= 400) {
426                 AuthPassed = false;
427                 ValidResponse = true;
428         } else {
429                 AuthPassed = false;
430                 ValidResponse = false;                  
431         }
432         
433         if (ValidResponse == false && AuthPassed == false){
434                 ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
435                 ServerResponse.EntityTag = "";
436                 ServerResponse.SessionCode = SessionResult;
437                 ServerResponse.ResultCode = SessionResponseCode;
438                 ServerResponse.ResultMessage = "";
439                 return ServerResponse;
440         }
441         
442         // Process the first response.
443         
444         string UserPrincipalURI = GetUserPrincipalURI();
445         
446         // Cleanup and reset for the second connection.
447         
448         ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
449         ResetResults();
451         ServerAddressURL = BuildURL(UserPrincipalURI);
452         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
453         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "PROPFIND");
454         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, AddressBookHomeXMLQuery);
455         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(AddressBookHomeXMLQuery));
456         
457         if (TestMode == true){
458                 SessionResult = curl_easy_perform(ConnectionSession);
459         } else {
460                 
461         }
462         
463         switch(SessionResult){
464                 case CURLE_OK:
465                         SSLStatus = true;
466                         SSLVerified = COSSL_VERIFIED;
467                         break;
468                 case CURLE_SSL_CACERT:
469                 case CURLE_SSL_CONNECT_ERROR:
470                         SSLStatus = true;
471                         SSLVerified = COSSL_UNABLETOVERIFY;
472                         break;
473                 default:
474                         break;
475         };
476         
477         SessionResponseCode = 0;
478         
479         curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
480         
481         if (SessionResponseCode == 200 || SessionResponseCode == 207){
482                 AuthPassed = true;
483                 ValidResponse = true;
484         } else if (SessionResponseCode == 403){
485                 AuthPassed = false;
486                 ValidResponse = true;
487         } else if (SessionResponseCode >= 400) {
488                 AuthPassed = false;
489                 ValidResponse = true;
490         } else {
491                 AuthPassed = false;
492                 ValidResponse = false;                  
493         }
494         
495         if (ValidResponse == false && AuthPassed == false){
496                 ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
497                 ServerResponse.EntityTag = "";
498                 ServerResponse.SessionCode = SessionResult;
499                 ServerResponse.ResultCode = SessionResponseCode;
500                 ServerResponse.ResultMessage = "";
501                 return ServerResponse;
502         }
503         
504         // Process the second response.
505         
506         string AddressBookHomeURI = GetAddressBookHomeURI();
507         
508         // Cleanup and reset for the second connection.
509         
510         ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
511         ResetResults();
512         
513         ServerAddressURL = BuildURL(AddressBookHomeURI);
514         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
515         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "PROPFIND");
516         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, DefaultAddressBookXMLQuery);
517         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(DefaultAddressBookXMLQuery));
518         
519         if (TestMode == true){
520                 SessionResult = curl_easy_perform(ConnectionSession);
521         } else {
522                 
523         }
524         
525         switch(SessionResult){
526                 case CURLE_OK:
527                         SSLStatus = true;
528                         SSLVerified = COSSL_VERIFIED;
529                         break;
530                 case CURLE_SSL_CACERT:
531                 case CURLE_SSL_CONNECT_ERROR:
532                         SSLStatus = true;
533                         SSLVerified = COSSL_UNABLETOVERIFY;
534                         break;
535                 default:
536                         break;
537         };
538         
539         SessionResponseCode = 0;
540         
541         curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
542         
543         if (SessionResponseCode == 200 || SessionResponseCode == 207){
544                 AuthPassed = true;
545                 ValidResponse = true;
546         } else if (SessionResponseCode == 403){
547                 AuthPassed = false;
548                 ValidResponse = true;
549         } else if (SessionResponseCode >= 200) {
550                 AuthPassed = false;
551                 ValidResponse = true;
552         } else {
553                 AuthPassed = false;
554                 ValidResponse = false;                  
555         }
556         
557         if (ValidResponse == false || AuthPassed == false){
558                 ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
559                 ServerResponse.EntityTag = "";
560                 ServerResponse.SessionCode = SessionResult;
561                 ServerResponse.ResultCode = SessionResponseCode;
562                 ServerResponse.ResultMessage = "";
563                 return ServerResponse;
564         }
565         
566         // Process the second response.
567         
568         (*ServerPrefix) = GetDefaultAddressBookURI();
569         
570         CanProcess = true;
571         
572         ServerResponse.RequestResult = COREQUEST_OK;
573         ServerResponse.EntityTag = "";
574         ServerResponse.SessionCode = SessionResult;
575         ServerResponse.ResultCode = SessionResponseCode;
576         ServerResponse.ResultMessage = SessionErrorBuffer;
577         return ServerResponse;
578         
581 std::string CardDAV2::GetUserPrincipalURI(){
582         
583         xmlDocPtr xmlCardDAVDoc;
584         xmlCardDAVDoc = xmlReadMemory(PageData.c_str(), (int)PageData.size(), "noname.xml", NULL, 0);
585         string UserPrincipalURI = "";
586         
587         xmlNodePtr nodeLevel1;
588         xmlNodePtr nodeLevel2;
589         xmlNodePtr nodeLevel3;
590         xmlNodePtr nodeLevel4;
591         xmlNodePtr nodeLevel5;
592         xmlNodePtr nodeLevel6;
593         xmlNodePtr nodeLevel7;
594                 
595         for (nodeLevel1 = xmlCardDAVDoc->children;
596                 nodeLevel1 != NULL;
597                 nodeLevel1 = nodeLevel1->next)
598         {
600                 for (nodeLevel2 = nodeLevel1->children;
601                         nodeLevel2 != NULL;
602                         nodeLevel2 = nodeLevel2->next)
603                 {
606                         for (nodeLevel3 = nodeLevel2->children;
607                         nodeLevel3 != NULL;
608                         nodeLevel3 = nodeLevel3->next)
609                         {
610                         
611                                 for (nodeLevel4 = nodeLevel3->children;
612                                 nodeLevel4 != NULL;
613                                 nodeLevel4 = nodeLevel4->next)
614                                 {
615                         
616                                         for (nodeLevel5 = nodeLevel4->children;
617                                         nodeLevel5 != NULL;
618                                         nodeLevel5 = nodeLevel5->next)
619                                         {
620                         
621                                                 for (nodeLevel6 = nodeLevel5->children;
622                                                 nodeLevel6 != NULL;
623                                                 nodeLevel6 = nodeLevel6->next)
624                                                 {
625                         
626                                                         if (!xmlStrcmp(nodeLevel6->name, (const xmlChar *)"href") ||
627                                                         !xmlStrcmp(nodeLevel6->name, (const xmlChar *)"d:href") ||
628                                                         !xmlStrcmp(nodeLevel6->name, (const xmlChar *)"D:href")
629                                                         ){
630                         
631                                                                 // Found the <href> part so extract the principal URL address.
632                                                                 
633                                                                 for (nodeLevel7 = nodeLevel6->children;
634                                                                 nodeLevel7 != NULL;
635                                                                 nodeLevel7 = nodeLevel7->next)
636                                                                 {
637                                                                 
638                                                                         UserPrincipalURI = ((const char*)nodeLevel7->content);
640                                                                 }
641                         
642                                                         }
643                         
644                                                 }
645                         
646                                         }
647                         
648                                 }
649                         
650                         }
651                 
652                 }
653                 
654         }
655         
656         xmlFreeDoc(xmlCardDAVDoc);
657         
658         return UserPrincipalURI;
659         
662 std::string CardDAV2::GetAddressBookHomeURI(){
663         
664         xmlDocPtr xmlCardDAVDoc;
665         xmlCardDAVDoc = xmlReadMemory(PageData.c_str(), (int)PageData.size(), "noname.xml", NULL, 0);
666         string AddressBookHomeURI = "";
667         
668         xmlNodePtr nodeLevel1;
669         xmlNodePtr nodeLevel2;
670         xmlNodePtr nodeLevel3;
671         xmlNodePtr nodeLevel4;
672         xmlNodePtr nodeLevel5;
673         xmlNodePtr nodeLevel6;
674         xmlNodePtr nodeLevel7;
675                 
676         for (nodeLevel1 = xmlCardDAVDoc->children;
677                 nodeLevel1 != NULL;
678                 nodeLevel1 = nodeLevel1->next)
679         {
681                 for (nodeLevel2 = nodeLevel1->children;
682                         nodeLevel2 != NULL;
683                         nodeLevel2 = nodeLevel2->next)
684                 {
687                         for (nodeLevel3 = nodeLevel2->children;
688                         nodeLevel3 != NULL;
689                         nodeLevel3 = nodeLevel3->next)
690                         {
691                         
692                                 for (nodeLevel4 = nodeLevel3->children;
693                                 nodeLevel4 != NULL;
694                                 nodeLevel4 = nodeLevel4->next)
695                                 {
696                         
697                                         for (nodeLevel5 = nodeLevel4->children;
698                                         nodeLevel5 != NULL;
699                                         nodeLevel5 = nodeLevel5->next)
700                                         {
701                         
702                                                 for (nodeLevel6 = nodeLevel5->children;
703                                                 nodeLevel6 != NULL;
704                                                 nodeLevel6 = nodeLevel6->next)
705                                                 {
706                         
707                                                         if (!xmlStrcmp(nodeLevel6->name, (const xmlChar *)"href") ||
708                                                         !xmlStrcmp(nodeLevel6->name, (const xmlChar *)"d:href") ||
709                                                         !xmlStrcmp(nodeLevel6->name, (const xmlChar *)"D:href")
710                                                         ){
711                         
712                                                                 // Found the <href> part so extract the principal URL address.
713                                                                 
714                                                                 for (nodeLevel7 = nodeLevel6->children;
715                                                                 nodeLevel7 != NULL;
716                                                                 nodeLevel7 = nodeLevel7->next)
717                                                                 {
718                                                                 
719                                                                         AddressBookHomeURI = ((const char*)nodeLevel7->content);
721                                                                 }
722                         
723                                                         }
724                         
725                                                 }
726                         
727                                         }
728                         
729                                 }
730                         
731                         }
732                 
733                 }
734                 
735         }
736         
737         xmlFreeDoc(xmlCardDAVDoc);
738         
739         return AddressBookHomeURI;
740         
743 std::string CardDAV2::GetDefaultAddressBookURI(){
744         
745         xmlDocPtr xmlCardDAVDoc;
746         xmlCardDAVDoc = xmlReadMemory(PageData.c_str(), (int)PageData.size(), "noname.xml", NULL, 0);
747         string DefaultAddressBookURI = "";
748         
749         xmlNodePtr nodeLevel1;
750         xmlNodePtr nodeLevel2;
751         xmlNodePtr nodeLevel3;
752         xmlNodePtr nodeLevel4;
753         xmlNodePtr nodeLevel5;
754         xmlNodePtr nodeLevel6;
755         xmlNodePtr nodeLevel7;
756                 
757         for (nodeLevel1 = xmlCardDAVDoc->children;
758                 nodeLevel1 != NULL;
759                 nodeLevel1 = nodeLevel1->next)
760         {
762                 for (nodeLevel2 = nodeLevel1->children;
763                         nodeLevel2 != NULL;
764                         nodeLevel2 = nodeLevel2->next)
765                 {
768                         for (nodeLevel3 = nodeLevel2->children;
769                         nodeLevel3 != NULL;
770                         nodeLevel3 = nodeLevel3->next)
771                         {
772                         
773                                 for (nodeLevel4 = nodeLevel3->children;
774                                 nodeLevel4 != NULL;
775                                 nodeLevel4 = nodeLevel4->next)
776                                 {
777                         
778                                         for (nodeLevel5 = nodeLevel4->children;
779                                         nodeLevel5 != NULL;
780                                         nodeLevel5 = nodeLevel5->next)
781                                         {
782                         
783                                                 for (nodeLevel6 = nodeLevel5->children;
784                                                 nodeLevel6 != NULL;
785                                                 nodeLevel6 = nodeLevel6->next)
786                                                 {
787                         
788                                                         if (!xmlStrcmp(nodeLevel6->name, (const xmlChar *)"href") ||
789                                                         !xmlStrcmp(nodeLevel6->name, (const xmlChar *)"d:href") ||
790                                                         !xmlStrcmp(nodeLevel6->name, (const xmlChar *)"D:href")
791                                                         ){
792                         
793                                                                 // Found the <href> part so extract the principal URL address.
794                                                                 
795                                                                 for (nodeLevel7 = nodeLevel6->children;
796                                                                 nodeLevel7 != NULL;
797                                                                 nodeLevel7 = nodeLevel7->next)
798                                                                 {
799                                                                 
800                                                                         DefaultAddressBookURI = ((const char*)nodeLevel7->content);
802                                                                 }
803                         
804                                                         }
805                         
806                                                 }
807                         
808                                         }
809                         
810                                 }
811                         
812                         }
813                 
814                 }
815                 
816         }
817         
818         xmlFreeDoc(xmlCardDAVDoc);
819         
820         return DefaultAddressBookURI;
821         
824 COServerResponse CardDAV2::AddContact(std::string Location, std::string Data){
825         
826         // Check if authentication was successful, otherwise don't do anything.
828         COServerResponse ServerResponse;
829         
830         if (AuthPassed == false){
831                 ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
832                 ServerResponse.EntityTag = "";
833                 ServerResponse.SessionCode = 0;
834                 ServerResponse.ResultCode = 0;
835                 ServerResponse.ResultMessage = "";
836                 return ServerResponse;
837         }
839         ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
840         ResetResults();
841         
842         string ServerAddressURL = BuildURL(ServerPrefix + Location);
843         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
844         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "PUT");
845         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, Data.c_str());
846         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(Data.c_str()));
847         
848         HeaderList = curl_slist_append(HeaderList, "Content-Type: text/vcard; charset=utf-8");
850         curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, HeaderList);
851         
852         if (TestMode == true){
853                 SessionResult = curl_easy_perform(ConnectionSession);
854         } else {
855                 SessionResult = curl_easy_perform(ConnectionSession);
856         }
857         
858         switch(SessionResult){
859                 case CURLE_OK:
860                         SSLStatus = true;
861                         SSLVerified = COSSL_VERIFIED;
862                         break;
863                 case CURLE_SSL_CACERT:
864                 case CURLE_SSL_CONNECT_ERROR:
865                         SSLStatus = true;
866                         SSLVerified = COSSL_UNABLETOVERIFY;
867                         break;
868                 default:
869                         break;
870         };
871         
872         long SessionResponseCode = 0;
873         
874         curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
875         
876         if (SessionResponseCode == 200 || SessionResponseCode == 201 || SessionResponseCode == 204){
877                 AuthPassed = true;
878                 ValidResponse = true;
879         } else if (SessionResponseCode == 403){
880                 AuthPassed = false;
881                 ValidResponse = true;
882         } else if (SessionResponseCode >= 400){
883                 AuthPassed = false;
884                 ValidResponse = true;
885         } else {
886                 AuthPassed = false;
887                 ValidResponse = false;                  
888         }
889         
890         if (ValidResponse == false || AuthPassed == false){
891                 ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
892                 ServerResponse.EntityTag = "";
893                 ServerResponse.SessionCode = SessionResult;
894                 ServerResponse.ResultCode = SessionResponseCode;
895                 ServerResponse.ResultMessage = "";
896                 return ServerResponse;
897         }
898         
899         CanProcess = true;
900         
901         ServerResponse.RequestResult = COREQUEST_OK;
902         ServerResponse.EntityTag = "";
903         ServerResponse.SessionCode = SessionResult;
904         ServerResponse.ResultCode = SessionResponseCode;
905         ServerResponse.ResultMessage = SessionErrorBuffer;
906         return ServerResponse;
907         
910 COServerResponse CardDAV2::EditContact(std::string Location, std::string Data){
912         // Check if authentication was successful, otherwise don't do anything.
914         COServerResponse ServerResponse;
915         
916         if (AuthPassed == false){
917                 ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
918                 ServerResponse.EntityTag = "";
919                 ServerResponse.SessionCode = 0;
920                 ServerResponse.ResultCode = 0;
921                 ServerResponse.ResultMessage = "";
922                 return ServerResponse;
923         }
925         ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
926         ResetResults();
927         
928         string ServerAddressURL = BuildURL(ServerPrefix + Location);
929         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
930         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "PUT");
931         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, Data.c_str());
932         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(Data.c_str()));
933         
934         HeaderList = curl_slist_append(HeaderList, "Content-Type: text/vcard; charset=utf-8");
936         curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, HeaderList);
937         
938         if (TestMode == true){
939                 SessionResult = curl_easy_perform(ConnectionSession);
940         } else {
941                 SessionResult = curl_easy_perform(ConnectionSession);
942         }
943         
944         switch(SessionResult){
945                 case CURLE_OK:
946                         SSLStatus = true;
947                         SSLVerified = COSSL_VERIFIED;
948                         break;
949                 case CURLE_SSL_CACERT:
950                 case CURLE_SSL_CONNECT_ERROR:
951                         SSLStatus = true;
952                         SSLVerified = COSSL_UNABLETOVERIFY;
953                         break;
954                 default:
955                         break;
956         };
957         
958         long SessionResponseCode = 0;
959         
960         curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
961         
962         if (SessionResponseCode == 200 || SessionResponseCode == 201 || SessionResponseCode == 204){
963                 AuthPassed = true;
964                 ValidResponse = true;
965         } else if (SessionResponseCode == 403){
966                 AuthPassed = false;
967                 ValidResponse = true;
968         } else if (SessionResponseCode >= 400){
969                 AuthPassed = false;
970                 ValidResponse = true;
971         } else {
972                 AuthPassed = false;
973                 ValidResponse = false;                  
974         }
975         
976         if (ValidResponse == false || AuthPassed == false){
977                 ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
978                 ServerResponse.EntityTag = "";
979                 ServerResponse.SessionCode = SessionResult;
980                 ServerResponse.ResultCode = SessionResponseCode;
981                 ServerResponse.ResultMessage = "";
982                 return ServerResponse;
983         }
984         
985         CanProcess = true;
986         
987         ServerResponse.RequestResult = COREQUEST_OK;
988         ServerResponse.EntityTag = "";
989         ServerResponse.SessionCode = SessionResult;
990         ServerResponse.ResultCode = SessionResponseCode;
991         ServerResponse.ResultMessage = SessionErrorBuffer;
992         return ServerResponse;
993         
996 COServerResponse CardDAV2::DeleteContact(std::string Location){
997         
998         // Check if authentication was successful, otherwise don't do anything.
1000         COServerResponse ServerResponse;
1001         
1002         if (AuthPassed == false){
1003                 ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
1004                 ServerResponse.EntityTag = "";
1005                 ServerResponse.SessionCode = 0;
1006                 ServerResponse.ResultCode = 0;
1007                 ServerResponse.ResultMessage = "";
1008                 return ServerResponse;
1009         }
1011         ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
1012         ResetResults();
1013         
1014         string ServerAddressURL = BuildURL(ServerPrefix + Location);
1015         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
1016         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "DELETE");
1017         
1018         if (TestMode == true){
1019                 SessionResult = curl_easy_perform(ConnectionSession);
1020         } else {
1021                 SessionResult = curl_easy_perform(ConnectionSession);
1022         }
1023         
1024         switch(SessionResult){
1025                 case CURLE_OK:
1026                         SSLStatus = true;
1027                         SSLVerified = COSSL_VERIFIED;
1028                         break;
1029                 case CURLE_SSL_CACERT:
1030                 case CURLE_SSL_CONNECT_ERROR:
1031                         SSLStatus = true;
1032                         SSLVerified = COSSL_UNABLETOVERIFY;
1033                         break;
1034                 default:
1035                         break;
1036         };
1037         
1038         long SessionResponseCode = 0;
1039         
1040         curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
1041         
1042         if (SessionResponseCode == 200 || SessionResponseCode == 202 || SessionResponseCode == 204){
1043                 AuthPassed = true;
1044                 ValidResponse = true;
1045         } else if (SessionResponseCode == 403){
1046                 AuthPassed = false;
1047                 ValidResponse = true;
1048         } else if (SessionResponseCode >= 400){
1049                 AuthPassed = false;
1050                 ValidResponse = true;
1051         } else {
1052                 AuthPassed = false;
1053                 ValidResponse = false;                  
1054         }
1055         
1056         if (ValidResponse == false || AuthPassed == false){
1057                 ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
1058                 ServerResponse.EntityTag = "";
1059                 ServerResponse.SessionCode = SessionResult;
1060                 ServerResponse.ResultCode = SessionResponseCode;
1061                 ServerResponse.ResultMessage = "";
1062                 return ServerResponse;
1063         }
1064         
1065         CanProcess = true;
1066         
1067         ServerResponse.RequestResult = COREQUEST_OK;
1068         ServerResponse.EntityTag = "";
1069         ServerResponse.SessionCode = SessionResult;
1070         ServerResponse.ResultCode = SessionResponseCode;
1071         ServerResponse.ResultMessage = SessionErrorBuffer;
1072         return ServerResponse;
1073         
1076 COServerResponse CardDAV2::GetServerEntityTagValue(std::string Location){
1077         
1078         // Check if authentication was successful, otherwise don't do anything.
1080         COServerResponse ServerResponse;
1081         
1082         if (AuthPassed == false){
1083                 ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
1084                 ServerResponse.EntityTag = "";
1085                 ServerResponse.SessionCode = 0;
1086                 ServerResponse.ResultCode = 0;
1087                 ServerResponse.ResultMessage = "";
1088                 return ServerResponse;
1089         }
1091         ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
1092         ResetResults();
1093         
1094         static const char* GetETagQuery =
1095         "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
1096         "<C:addressbook-query xmlns:D=\"DAV:\""
1097         "       xmlns:C=\"urn:ietf:params:xml:ns:carddav\">"
1098         "<D:prop><D:getetag/>"
1099         "</D:prop>"
1100         "<C:filter/>"
1101         "</C:addressbook-query>";
1102         
1103         string ServerAddressURL = BuildURL(ServerPrefix + Location);
1104         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
1105         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "REPORT");
1106         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, GetETagQuery);
1107         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(GetETagQuery));
1108         
1109         if (TestMode == true){
1110                 SessionResult = curl_easy_perform(ConnectionSession);
1111         } else {
1112                 SessionResult = curl_easy_perform(ConnectionSession);
1113         }
1114         
1115         switch(SessionResult){
1116                 case CURLE_OK:
1117                         SSLStatus = true;
1118                         SSLVerified = COSSL_VERIFIED;
1119                         break;
1120                 case CURLE_SSL_CACERT:
1121                 case CURLE_SSL_CONNECT_ERROR:
1122                         SSLStatus = true;
1123                         SSLVerified = COSSL_UNABLETOVERIFY;
1124                         break;
1125                 default:
1126                         break;
1127         };
1128         
1129         long SessionResponseCode = 0;
1130         
1131         curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
1132         
1133         if (SessionResponseCode == 207){
1134                 AuthPassed = true;
1135                 ValidResponse = true;
1136         } else if (SessionResponseCode == 403){
1137                 AuthPassed = false;
1138                 ValidResponse = true;
1139         } else if (SessionResponseCode >= 400){
1140                 AuthPassed = false;
1141                 ValidResponse = true;
1142         } else {
1143                 AuthPassed = false;
1144                 ValidResponse = false;                  
1145         }
1146         
1147         if (ValidResponse == false || AuthPassed == false){
1148                 ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
1149                 ServerResponse.EntityTag = "";
1150                 ServerResponse.SessionCode = SessionResult;
1151                 ServerResponse.ResultCode = SessionResponseCode;
1152                 ServerResponse.ResultMessage = "";
1153                 return ServerResponse;
1154         }
1155         
1156         CanProcess = true;
1157         
1158         ServerResponse.RequestResult = COREQUEST_OK;
1159         ServerResponse.EntityTag = GetETagValue();
1160         ServerResponse.SessionCode = SessionResult;
1161         ServerResponse.ResultCode = SessionResponseCode;
1162         ServerResponse.ResultMessage = SessionErrorBuffer;
1163         
1164         return ServerResponse;
1165         
1168 COServerResponse CardDAV2::GetContact(std::string Location, std::string *ContactData){
1169         
1170         // Check if authentication was successful, otherwise don't do anything.
1172         COServerResponse ServerResponse;
1173         
1174         if (AuthPassed == false){
1175                 ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
1176                 ServerResponse.EntityTag = "";
1177                 ServerResponse.SessionCode = 0;
1178                 ServerResponse.ResultCode = 0;
1179                 ServerResponse.ResultMessage = "";
1180                 return ServerResponse;
1181         }
1183         ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
1184         ResetResults();
1185         
1186         string ServerAddressURL = BuildURL(ServerPrefix + Location);
1187         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
1188         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "GET");
1189         
1190         if (TestMode == true){
1191                 SessionResult = curl_easy_perform(ConnectionSession);
1192         } else {
1193                 SessionResult = curl_easy_perform(ConnectionSession);
1194         }
1195         
1196         switch(SessionResult){
1197                 case CURLE_OK:
1198                         SSLStatus = true;
1199                         SSLVerified = COSSL_VERIFIED;
1200                         break;
1201                 case CURLE_SSL_CACERT:
1202                 case CURLE_SSL_CONNECT_ERROR:
1203                         SSLStatus = true;
1204                         SSLVerified = COSSL_UNABLETOVERIFY;
1205                         break;
1206                 default:
1207                         break;
1208         };
1209         
1210         long SessionResponseCode = 0;
1211         
1212         curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
1213         
1214         if (SessionResponseCode == 200){
1215                 AuthPassed = true;
1216                 ValidResponse = true;
1217         } else if (SessionResponseCode == 403){
1218                 AuthPassed = false;
1219                 ValidResponse = true;
1220         } else if (SessionResponseCode >= 400){
1221                 AuthPassed = false;
1222                 ValidResponse = true;
1223         } else {
1224                 AuthPassed = false;
1225                 ValidResponse = false;                  
1226         }
1227         
1228         if (ValidResponse == false && AuthPassed == false){
1229                 ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
1230                 ServerResponse.EntityTag = "";
1231                 ServerResponse.SessionCode = SessionResult;
1232                 ServerResponse.ResultCode = SessionResponseCode;
1233                 ServerResponse.ResultMessage = "";
1234                 return ServerResponse;
1235         }
1236         
1237         CanProcess = true;
1238         
1239         ServerResponse.RequestResult = COREQUEST_OK;
1240         ServerResponse.EntityTag = "";
1241         ServerResponse.SessionCode = SessionResult;
1242         ServerResponse.ResultCode = SessionResponseCode;
1243         ServerResponse.ResultMessage = SessionErrorBuffer;
1244         
1245         (*ContactData) = PageData;
1246         
1247         return ServerResponse;
1248         
1251 COContactList CardDAV2::GetContactList(std::string SyncToken){
1252         
1253         COContactList ServerContactList;
1254         
1255         // Check if authentication was successful, otherwise don't do anything.
1256         
1257         if (AuthPassed == false){
1258                 ServerContactList.ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED;
1259                 ServerContactList.ServerResponse.EntityTag = "";
1260                 ServerContactList.ServerResponse.SessionCode = 0;
1261                 ServerContactList.ServerResponse.ResultCode = 0;
1262                 ServerContactList.ServerResponse.ResultMessage = "";
1263                 return ServerContactList;
1264         }
1266         ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true);
1267         ResetResults();
1268         
1269         std::string SyncData;
1270         
1271         if (SyncToken.size() > 0){
1272                 
1273                 SyncData = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
1274                 "<D:sync-collection xmlns:D=\"DAV:\"\n"
1275                 " xmlns:C=\"urn:ietf:params:xml:ns:carddav\">\n"
1276                 "<D:sync-token>";
1277                 SyncData.append(SyncToken);
1278                 SyncData.append("</D:sync-token>\n"
1279                 "<D:sync-level>1</D:sync-level>\n"
1280                 "<D:prop>\n"
1281                 "       <D:getetag/>\n"
1282                 "</D:prop>\n"
1283                 "</D:sync-collection>");
1284         
1285         } else {
1286                 
1287                 SyncData = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
1288                 "<D:sync-collection xmlns:D=\"DAV:\"\n"
1289                 " xmlns:C=\"urn:ietf:params:xml:ns:carddav\">\n"
1290                 "<D:sync-level>1</D:sync-level>\n"
1291                 "<D:prop>\n"
1292                 "       <D:getetag/>\n"
1293                 "</D:prop>\n"
1294                 "</D:sync-collection>";
1296         }
1297         
1298         string ServerAddressURL = BuildURL(ServerPrefix);
1299         
1300         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
1301         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, SyncData.c_str());
1302         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(SyncData.c_str()));
1303         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "REPORT");
1304         
1305         HeaderList = curl_slist_append(HeaderList, "Content-Type: application/xml; charset=utf-8");
1306         HeaderList = curl_slist_append(HeaderList, "Depth: 1");
1308         curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, HeaderList);
1309         
1310         if (TestMode == true){
1311                 SessionResult = curl_easy_perform(ConnectionSession);
1312         } else {
1313                 SessionResult = curl_easy_perform(ConnectionSession);
1314         }
1315         
1316         switch(SessionResult){
1317                 case CURLE_OK:
1318                         SSLStatus = true;
1319                         SSLVerified = COSSL_VERIFIED;
1320                         break;
1321                 case CURLE_SSL_CACERT:
1322                 case CURLE_SSL_CONNECT_ERROR:
1323                         SSLStatus = true;
1324                         SSLVerified = COSSL_UNABLETOVERIFY;
1325                         break;
1326                 default:
1327                         break;
1328         };
1329         
1330         long SessionResponseCode = 0;
1331         
1332         curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode);
1333         
1334         if (SessionResponseCode == 207){
1335                 AuthPassed = true;
1336                 ValidResponse = true;
1337         } else if (SessionResponseCode == 403){
1338                 AuthPassed = false;
1339                 ValidResponse = true;
1340         } else if (SessionResponseCode >= 400){
1341                 AuthPassed = false;
1342                 ValidResponse = true;
1343         } else {
1344                 AuthPassed = false;
1345                 ValidResponse = false;                  
1346         }
1347         
1348         if (ValidResponse == false || AuthPassed == false){
1349                 ServerContactList.ServerResponse.RequestResult = COREQUEST_ERROR_SERVER;
1350                 ServerContactList.ServerResponse.EntityTag = "";
1351                 ServerContactList.ServerResponse.SessionCode = SessionResult;
1352                 ServerContactList.ServerResponse.ResultCode = SessionResponseCode;
1353                 ServerContactList.ServerResponse.ResultMessage = "";
1354                 return ServerContactList;
1355         }
1356         
1357         CanProcess = true;
1358         
1359         ProcessContactData(&ServerContactList);
1360         
1361         ServerContactList.ServerResponse.RequestResult = COREQUEST_OK;
1362         ServerContactList.ServerResponse.EntityTag = "";
1363         ServerContactList.ServerResponse.SessionCode = SessionResult;
1364         ServerContactList.ServerResponse.ResultCode = SessionResponseCode;
1365         ServerContactList.ServerResponse.ResultMessage = SessionErrorBuffer;
1366         
1367         return ServerContactList;
1368         
1370         
1371 bool CardDAV2::CanDoProcessing(){
1372         return CanProcess;
1375 bool CardDAV2::CanDoSSL(){
1376         return SSLStatus;
1379 COSSLVerified CardDAV2::SSLVerify(){
1380         return SSLVerified;
1383 bool CardDAV2::AbleToLogin(){
1384         return AuthPassed;
1387 bool CardDAV2::HasValidResponse(){
1388         return ValidResponse;
1391 bool CardDAV2::IsSelfSigned(){
1392         return SSLSelfSigned;
1395 void CardDAV2::SetupDefaultParametersNonSSL(bool DoAuthentication){
1396         
1397         std::string ServerAddress = "";
1399         string ServerAddressURL = "http://" + ServerAddress + ":" + to_string(ServerPort) + "/";
1400         string UsernamePassword = ServerUser + ":" + ServerPass;
1402         PageDataObject.CardDAV2Object = this;
1403         PageDataObject.ConnectionSessionObject = ConnectionSession;
1404         PageDataObject.DataSetting = &PageData;
1405         PageDataObject.ServerUsingSSL = false;
1407         PageHeaderObject.CardDAV2Object = this;
1408         PageHeaderObject.ConnectionSessionObject = ConnectionSession;
1409         PageHeaderObject.DataSetting = &PageHeader;
1410         PageHeaderObject.ServerUsingSSL = false;
1411         
1412         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddress.c_str());
1413         curl_easy_setopt(ConnectionSession, CURLOPT_NOPROGRESS, 1L);
1414         curl_easy_setopt(ConnectionSession, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC);
1415         curl_easy_setopt(ConnectionSession, CURLOPT_TIMEOUT, 60);
1416         curl_easy_setopt(ConnectionSession, CURLOPT_FAILONERROR, true);
1417         curl_easy_setopt(ConnectionSession, CURLOPT_USERAGENT, XSDAB_USERAGENT);
1418         curl_easy_setopt(ConnectionSession, CURLOPT_WRITEFUNCTION, CardDAV2::WritebackFunc);
1419         curl_easy_setopt(ConnectionSession, CURLOPT_WRITEDATA, &PageDataObject);
1420         curl_easy_setopt(ConnectionSession, CURLOPT_WRITEHEADER, &PageHeaderObject);
1421         curl_easy_setopt(ConnectionSession, CURLOPT_NOSIGNAL, 1L);
1422         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "GET");
1423         curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, nullptr);
1424         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, nullptr);
1425         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, 0L);
1427         if (DoAuthentication == true){
1428                 curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, UsernamePassword.c_str());
1429         } else {
1430                 curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, NULL);             
1431         }
1432         
1435 void CardDAV2::SetupDefaultParametersSSL(bool DoAuthentication){
1436         
1437         // Setup the default parameters.
1438         
1439         string ServerAddressURL = "https://" + ServerAddress + ":" + to_string(ServerPort) + "/";
1440         string UsernamePassword = ServerUser + ":" + ServerPass;
1442         PageDataObject.CardDAV2Object = this;
1443         PageDataObject.ConnectionSessionObject = ConnectionSession;
1444         PageDataObject.DataSetting = &PageData;
1445         PageDataObject.ServerUsingSSL = true;
1447         PageHeaderObject.CardDAV2Object = this;
1448         PageHeaderObject.ConnectionSessionObject = ConnectionSession;
1449         PageHeaderObject.DataSetting = &PageHeader;
1450         PageHeaderObject.ServerUsingSSL = true;
1451         
1452         curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str());
1453         curl_easy_setopt(ConnectionSession, CURLOPT_NOPROGRESS, 1L);
1454         curl_easy_setopt(ConnectionSession, CURLOPT_CERTINFO, 1L);
1455         curl_easy_setopt(ConnectionSession, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC);
1456         curl_easy_setopt(ConnectionSession, CURLOPT_TIMEOUT, 60);
1457         curl_easy_setopt(ConnectionSession, CURLOPT_FAILONERROR, 0L);
1458         curl_easy_setopt(ConnectionSession, CURLOPT_USERAGENT, XSDAB_USERAGENT);
1459         curl_easy_setopt(ConnectionSession, CURLOPT_WRITEFUNCTION, CardDAV2::WritebackFunc);
1460         curl_easy_setopt(ConnectionSession, CURLOPT_WRITEDATA, &PageDataObject);
1461         curl_easy_setopt(ConnectionSession, CURLOPT_WRITEHEADER, &PageHeaderObject);
1462         curl_easy_setopt(ConnectionSession, CURLOPT_ERRORBUFFER, SessionErrorBuffer);
1463         curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "GET");
1464         curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, nullptr);
1465         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, nullptr);
1466         curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, 0L);
1468         if (DoAuthentication == true){
1469                 curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, UsernamePassword.c_str());
1470         } else {
1471                 curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, NULL);             
1472         }
1473         
1474         if (EnableSSLBypass == true){
1475                 curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYHOST, 0L);
1476                 curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYPEER, 0L);
1477                 curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYSTATUS, 0L);
1478         } else {
1479                 curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYHOST, 2L);
1480                 curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYPEER, 1L);
1481                 curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYSTATUS, 1L);
1482         }
1483         
1484 #if !defined(__APPLE__) || defined(__WIN32__)
1485         
1486         if (TestMode == false && ServerAccount.size() > 0){
1487                 
1488                 // Check if the server certificate file exists.
1489                 
1490                 string CertificateFilename = GetAccountDir(ServerAccount, true);
1491                 
1492                 if (wxFile::Exists(CertificateFilename)){
1493                         
1494                         curl_easy_setopt(ConnectionSession, CURLOPT_CAINFO, CertificateFilename.c_str());
1495                         
1496                 }
1497                 
1498         }
1500 #endif
1501         
1504 string CardDAV2::BuildURL(string URI){
1505         
1506         string ServerAddressURL;
1507         
1508         if (ServerSSL == true){
1509                 ServerAddressURL = "https://" + ServerAddress + ":" + to_string(ServerPort) + URI;      
1510         } else {
1511                 ServerAddressURL = "http://" + ServerAddress + ":" + to_string(ServerPort) + URI;
1512         }
1513         
1514         return ServerAddressURL;
1515         
1518 string CardDAV2::GetErrorMessage(){
1519         
1520         ErrorMessage = SessionErrorBuffer;      
1521         return ErrorMessage;
1522         
1525 void CardDAV2::ResetResults(){
1526         
1527         SSLStatus = false;
1528         COSSLVerified SSLVerified = COSSL_NORESULT;
1529         ValidResponse = false;
1530         AuthPassed = false;
1531         CanProcess = false;
1532         SSLSelfSigned = false;
1533         TaskCompleted = false;
1534         ErrorMessage = "";
1535         SessionErrorBuffer[0] = '\0';
1536         SessionResult = CURLE_OK;
1537         PageData = "";
1538         PageHeader = "";
1539         if (HeaderList != nullptr){
1540                 curl_slist_free_all(HeaderList);
1541                 HeaderList = nullptr;
1542         }
1543         
1546 string CardDAV2::GetETagValue(){
1547         
1548         xmlDocPtr xmlCardDAVDoc;
1550         xmlCardDAVDoc = xmlReadMemory(PageData.c_str(), (int)PageData.size(), "noname.xml", NULL, 0);
1552         xmlNodePtr nodeLevel1;
1553         xmlNodePtr nodeLevel2;
1554         xmlNodePtr nodeLevel3;
1555         xmlNodePtr nodeLevel4;
1556         xmlNodePtr nodeLevel5;
1557         xmlNodePtr nodeLevel6;
1559         //std::map<wxString,wxString> xmlDataMap;
1561         std::string DataFilename;
1562         std::string ETagData;
1564         std::string xmlStringSafe;
1565         std::string ETagValue;
1567         // Tranverse through the catacombs of the response to get our ETag for the file.
1569         for (nodeLevel1 = xmlCardDAVDoc->children;
1570                 nodeLevel1 != NULL;
1571                 nodeLevel1 = nodeLevel1->next)
1572         {
1574                 bool HREFFound = FALSE;
1575                 bool ETagFound = FALSE;
1577                 for (nodeLevel2 = nodeLevel1->children;
1578                         nodeLevel2 != NULL;
1579                         nodeLevel2 = nodeLevel2->next)
1580                 {
1582                         for (nodeLevel3 = nodeLevel2->children;
1583                         nodeLevel3 != NULL;
1584                         nodeLevel3 = nodeLevel3->next)
1585                         {
1587                                 if (!xmlStrcmp(nodeLevel3->name, (const xmlChar *)"href") ||
1588                                 !xmlStrcmp(nodeLevel3->name, (const xmlChar *)"d:href") ||
1589                                 !xmlStrcmp(nodeLevel3->name, (const xmlChar *)"D:href")
1590                                 ){
1592                                         // Get the filename.
1593                                         
1594                                         for (nodeLevel4 = nodeLevel3->children;
1595                                         nodeLevel4 != NULL;
1596                                         nodeLevel4 = nodeLevel4->next)
1597                                         {
1598                                         
1599                                                 if (!xmlStrcmp(nodeLevel4->name, (const xmlChar *)"text") ||
1600                                                 !xmlStrcmp(nodeLevel4->name, (const xmlChar *)"d:text") ||
1601                                                 !xmlStrcmp(nodeLevel4->name, (const xmlChar *)"D:text")
1602                                                 ){
1604                                                         DataFilename = wxString::FromUTF8((const char*)nodeLevel4->content);
1605                                                         wxStringTokenizer wSTDFilename(DataFilename, wxT("/"));
1606                                                 
1607                                                         while (wSTDFilename.HasMoreTokens()){
1608                                                         
1609                                                                 DataFilename = wSTDFilename.GetNextToken().ToStdString();
1610                                                         
1611                                                         }
1612                                                         
1613                                                         HREFFound = TRUE;
1614                                                 
1615                                                 }
1616                                                 
1617         
1618                                         
1619                                         }
1621                                 } else {
1623                                         for (nodeLevel4 = nodeLevel3->children;
1624                                         nodeLevel4 != NULL;
1625                                         nodeLevel4 = nodeLevel4->next)
1626                                         {
1627                                                         
1628                                                         for (nodeLevel5 = nodeLevel4->children;
1629                                                         nodeLevel5 != NULL;
1630                                                         nodeLevel5 = nodeLevel5->next)
1631                                                         {
1633                                                                 if (!xmlStrcmp(nodeLevel5->name, (const xmlChar *)"getetag") ||
1634                                                                 !xmlStrcmp(nodeLevel5->name, (const xmlChar *)"d:getetag") ||
1635                                                                 !xmlStrcmp(nodeLevel5->name, (const xmlChar *)"D:getetag")
1636                                                                 ){
1638                                                                         for (nodeLevel6 = nodeLevel5->children;
1639                                                                         nodeLevel6 != NULL;
1640                                                                         nodeLevel6 = nodeLevel6->next)
1641                                                                         {
1642                                                         
1643                                                                                 // Strip the quotes from the ETag.
1644                                                         
1645                                                                                 ETagData = (const char*)nodeLevel6->content;
1646                                                                                 if (ETagData[0] == '"' && ETagData[(ETagData.size() - 1)] == '"'){
1647                                                         
1648                                                                                         ETagData.erase(0, 1);
1649                                                                                         ETagData.erase((ETagData.size() - 1));
1650                                                         
1651                                                                                 }
1652                                                                         
1653                                                                                 ETagFound = TRUE;
1655                                                                         }
1656                                                                         
1657                                                                 }
1659                                                         }       
1661                                         }
1663                                 }
1665                         }
1667                 }
1668                 
1669                 if (HREFFound == TRUE && ETagFound == TRUE){
1670                                 
1671                         // Add to the map data.
1672                                 
1673                         ETagValue = ETagData;
1674                         
1675                         HREFFound = FALSE;
1676                         ETagFound = FALSE;
1677                         break;
1678                                 
1679                 }
1682         }
1684         xmlFreeDoc(xmlCardDAVDoc);
1685         
1686         return ETagValue;
1687         
1690 string CardDAV2::GetETagHeader(){
1691         
1692         // Go through each of the lines looking for the
1693         // 'DAV:' section.
1694         
1695         string HeaderName;
1696         string HeaderValue;
1697         bool FastForward = false;
1698         
1699         for (int HeaderSeek = 0; HeaderSeek < PageHeader.size(); HeaderSeek++){
1700                 
1701                 if (FastForward == true){
1702                         
1703                         if (PageHeader[HeaderSeek] == '\n'){
1704                                 FastForward = false;
1705                         }
1706                         
1707                         continue;
1708                         
1709                 }
1710                 
1711                 try {
1712                         PageHeader.substr(HeaderSeek, 5) == "ETag:";
1713                 }
1714                 
1715                 catch (const out_of_range &oor){
1716                         break;
1717                 }
1718                 
1719                 if (PageHeader.substr(HeaderSeek, 5) == "ETag:"){
1720                         
1721                         int CharacterSeek = 5;
1722                         
1723                         while ((HeaderSeek + CharacterSeek) < PageHeader.size()){
1724                                 
1725                                 if (PageHeader.substr((HeaderSeek + CharacterSeek), 2) == "\r\n"){
1726                                         break;
1727                                 }
1728                                 
1729                                 HeaderValue += PageHeader.substr((HeaderSeek + CharacterSeek), 1);
1730                                 CharacterSeek++;
1731                         }
1732                         
1733                         break;
1734                         
1735                 } else {
1736                         
1737                         FastForward = true;
1738                         continue;
1739                         
1740                 }
1741                 
1742                 if (PageHeader[HeaderSeek] == '\n'){
1743                         HeaderName = "";
1744                 }
1745                 
1746                 //HeaderName += PageHeader.substr(HeaderSeek, 1);
1747                 
1748         }
1749         
1750         // Check for quotation marks at the start and end and strip
1751         // them out.
1752         
1753         if (HeaderValue.size() >= 2){
1754                 
1755                 if (HeaderValue[0] == '"'){
1756                         HeaderValue.erase((HeaderValue.size() - 1));
1757                         HeaderValue.erase(0);
1758                 }
1759                 
1760         }
1761         
1762         return HeaderValue;
1763         
1766 vector<string> CardDAV2::GetDAVHeader(){
1767         
1768         // Go through each of the lines looking for the
1769         // 'DAV:' section.
1770         
1771         string HeaderName;
1772         string HeaderValue;
1773         bool FastForward = false;
1774         vector<string> DAVHeaderList;
1775         
1776         for (int HeaderSeek = 0; HeaderSeek < PageHeader.size(); HeaderSeek++){
1777                 
1778                 if (FastForward == true){
1779                         
1780                         if (PageHeader[HeaderSeek] == '\n'){
1781                                 FastForward = false;
1782                         }
1783                         
1784                         continue;
1785                         
1786                 }
1787                 
1788                 try {
1789                         PageHeader.substr(HeaderSeek, 4) == "DAV:";
1790                 }
1791                 
1792                 catch (const out_of_range &oor){
1793                         break;
1794                 }
1795                 
1796                 if (PageHeader.substr(HeaderSeek, 4) == "DAV:"){
1797                         
1798                         int CharacterSeek = 5;
1799                         
1800                         while ((HeaderSeek + CharacterSeek) < PageHeader.size()){
1801                                 
1802                                 if (PageHeader.substr((HeaderSeek + CharacterSeek), 2) == "\r\n"){
1803                                         break;
1804                                 }
1805                                 
1806                                 HeaderValue += PageHeader.substr((HeaderSeek + CharacterSeek), 1);
1807                                 CharacterSeek++;
1808                         }
1809                         
1810                         break;
1811                         
1812                 } else {
1813                         
1814                         FastForward = true;
1815                         continue;
1816                         
1817                 }
1818                 
1819                 if (PageHeader[HeaderSeek] == '\n'){
1820                         HeaderName = "";
1821                 }
1822                 
1823                 //HeaderName += PageHeader.substr(HeaderSeek, 1);
1824                 
1825         }
1826         
1827         // Split the header data.
1828         
1829         std::string DAVHeaderValue;
1830         
1831         for (int HeaderSeek = 0; HeaderSeek < HeaderValue.size(); HeaderSeek++){
1832                 
1833                 if (HeaderValue.substr(HeaderSeek, 1) == ","){
1834                         DAVHeaderList.push_back(DAVHeaderValue);
1835                         DAVHeaderValue = "";
1836                         HeaderSeek++;
1837                         continue;
1838                 }
1839                 
1840                 DAVHeaderValue += HeaderValue[HeaderSeek];
1841                 
1842         }
1843         
1844         if (DAVHeaderValue.size() > 0){
1845                 
1846                 DAVHeaderList.push_back(DAVHeaderValue);
1847                 
1848         }
1849         
1850         return DAVHeaderList;
1851         
1854 void CardDAV2::ProcessContactData(COContactList *ContactList){
1855         
1856         xmlDocPtr xmlCardDAVDoc;
1857         xmlCardDAVDoc = xmlReadMemory(PageData.c_str(), (int)PageData.size(), "noname.xml", NULL, 0);
1859         xmlNodePtr MultiStatusNode;
1860         xmlNodePtr ResponseNode;
1861         xmlNodePtr ResponseDataNode;
1862         xmlNodePtr PropStatNode;
1863         xmlNodePtr ValueNode;
1864         xmlNodePtr ETagNode;
1865         xmlNodePtr StatusNode;
1867         std::string HREFValue;
1868         std::string ETagValue;
1869         std::string StatusValue;
1870         std::string SyncValue;
1872         // Go through the document!
1874         MultiStatusNode = xmlCardDAVDoc->children;
1876         if (MultiStatusNode == nullptr){
1877                 return;
1878         }
1880         bool SyncTokenFound = false;
1882         // Tranverse through the catacombs of the response to get our ETag for the file and
1883         // the server syncronisation token.
1884         
1885         for (ResponseNode = MultiStatusNode->children;
1886                 ResponseNode != nullptr;
1887                 ResponseNode = ResponseNode->next){
1889                 // Check if tag is response or sync-token.
1891                 if (!xmlStrcmp(ResponseNode->name, (const xmlChar *)"response") ||
1892                 !xmlStrcmp(ResponseNode->name, (const xmlChar *)"d:response") ||
1893                 !xmlStrcmp(ResponseNode->name, (const xmlChar *)"D:response")){
1895                         COContactStatus ContactStatus = COCS_UNKNOWN;
1896                         
1897                         for (ResponseDataNode = ResponseNode->children;
1898                                 ResponseDataNode != nullptr;
1899                                 ResponseDataNode = ResponseDataNode->next){
1901                                 if (!xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"href") ||
1902                                 !xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"d:href") ||
1903                                 !xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"D:href")){
1904                                 
1905                                         HREFValue = (const char*)ResponseDataNode->children->content;
1907                                         // Get the filename after the last forward slash.
1908                                         
1909                                         int LastSlash = 0;
1910                                         
1911                                         for (int HREFValueSeek = 0; HREFValueSeek < HREFValue.size(); HREFValueSeek++){
1912                                                 
1913                                                 if (HREFValue[HREFValueSeek] == '/'){
1914                                                 
1915                                                         LastSlash = HREFValueSeek;
1916                                                         
1917                                                 }
1918                                                 
1919                                         }
1920                                         
1921                                         HREFValue = HREFValue.substr((LastSlash + 1));
1922                                         
1923                                 } else if (!xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"propstat") ||
1924                                 !xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"d:propstat") ||
1925                                 !xmlStrcmp(ResponseDataNode->name, (const xmlChar *)"D:propstat")){
1927                                         for (PropStatNode = ResponseDataNode->children;
1928                                                 PropStatNode != nullptr;
1929                                                 PropStatNode = PropStatNode->next){
1931                                                 if (!xmlStrcmp(PropStatNode->name, (const xmlChar *)"prop") ||
1932                                                         !xmlStrcmp(PropStatNode->name, (const xmlChar *)"d:prop") ||
1933                                                         !xmlStrcmp(PropStatNode->name, (const xmlChar *)"D:prop")){
1935                                                         for (ETagNode = PropStatNode->children;
1936                                                                 ETagNode != nullptr;
1937                                                                 ETagNode = ETagNode->next){
1939                                                                         if (!xmlStrcmp(ETagNode->name, (const xmlChar *)"getetag") ||
1940                                                                         !xmlStrcmp(ETagNode->name, (const xmlChar *)"getetag") ||
1941                                                                         !xmlStrcmp(ETagNode->name, (const xmlChar *)"getetag")){
1943                                                                                 ETagValue = (const char*)ETagNode->children->content;
1945                                                                                 if (ETagValue.size() > 2 && ETagValue.substr(0,1) == "\""){
1946                                                                                         ETagValue.erase((ETagValue.size() - 1),1);
1947                                                                                         ETagValue.erase(0,1);
1948                                                                                 }
1950                                                                         }
1951                                                         
1953                                                         }
1955                                                 } else if (!xmlStrcmp(PropStatNode->name, (const xmlChar *)"status") ||
1956                                                         !xmlStrcmp(PropStatNode->name, (const xmlChar *)"d:status") ||
1957                                                         !xmlStrcmp(PropStatNode->name, (const xmlChar *)"D:status")){
1959                                                         StatusValue = (const char*)PropStatNode->children->content;
1961                                                         if (StatusValue == "HTTP/1.1 200 OK"){
1963                                                                 ContactStatus = COCS_UPDATED;
1965                                                         } else if (StatusValue == "HTTP/1.1 404 Not Found"){
1967                                                                 ContactStatus = COCS_DELETED;
1969                                                         } else {
1971                                                                 ContactStatus = COCS_UNKNOWN;
1973                                                         }
1975                                                 }
1977                                         }
1979                                 }
1981                         }
1983                         COContactData ContactInformation;
1984                         
1985                         ContactInformation.Location = HREFValue;
1986                         ContactInformation.Data = ETagValue;
1987                         ContactInformation.Status = ContactStatus;
1989                         HREFValue.clear();
1990                         ETagValue.clear();
1991                         StatusValue.clear();
1992                         
1993                         ContactList->ListData.push_back(ContactInformation);
1995                 } else if (!xmlStrcmp(ResponseNode->name, (const xmlChar *)"sync-token") ||
1996                         !xmlStrcmp(ResponseNode->name, (const xmlChar *)"d:sync-token") ||
1997                         !xmlStrcmp(ResponseNode->name, (const xmlChar *)"D:sync-token")){
1999                         SyncValue = (const char*)ResponseNode->children->content;
2001                 }
2003         }
2005         ContactList->SyncToken = SyncValue;
2007         xmlFreeDoc(xmlCardDAVDoc);
2009         return;
2010         
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