Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented DeleteContact in the CardDAV2 class
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 28 Aug 2016 08:44:19 +0000 (09:44 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sun, 28 Aug 2016 08:44:19 +0000 (09:44 +0100)
source/carddav2/carddav2.cpp
source/carddav2/carddav2.h

index 9d42c04..1d8f632 100644 (file)
@@ -915,7 +915,83 @@ COServerResponse CardDAV2::EditContact(std::string Location, std::string Data){
        
 }
 
-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;
        
 }
 
index 212c5a2..ceca5c2 100644 (file)
@@ -54,7 +54,7 @@ class CardDAV2 : public ConnectionObject {
                COServerResponse GetDefaultPrefix(std::string *ServerPrefix);
                COServerResponse AddContact(std::string Location, std::string Data);
                COServerResponse EditContact(std::string Location, std::string Data);
-               COServerResponse DeleteContact(std::string Location, std::string EntityTag);
+               COServerResponse DeleteContact(std::string Location);
                COServerResponse GetServerEntityTagValue(std::string Location);
                COServerResponse GetContact(std::string Location, std::string *ContactData);
                COContactList GetContactList(std::string SyncToken);
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