// CardDAV2.h - CardDAV v2 class header // // (c) 2012-2016 Xestia Software Development. // // This file is part of Xestia Address Book. // // Xestia Address Book is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by the // Free Software Foundation, version 3 of the license. // // Xestia Address Book is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with Xestia Address Book. If not, see #ifndef __CARDDAV2_CARDDAV2_H__ #define __CARDDAV2_CARDDAV2_H__ #include "../connobject/ConnectionObject.h" #include "../version.h" #include "../common/sslcertstructs.h" #include "../common/dirs.h" #include #include #include #include #include #include #include class CardDAV2 : public ConnectionObject { public: using ConnectionObject::ConnectionObject; // Destructor. ~CardDAV2(); // Functions from the ConnectionObject interface. void SetupConnectionObject(); bool IsTaskCompleted(); COConnectResult Connect(bool DoAuthentication); 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); COServerResponse GetServerEntityTagValue(std::string Location); COServerResponse GetContact(std::string Location, std::string *ContactData); COContactList GetContactList(std::string SyncToken); bool CanDoProcessing(); bool CanDoSSL(); COSSLVerified SSLVerify(); bool AbleToLogin(); bool HasValidResponse(); bool IsSelfSigned(); std::string GetErrorMessage(); void BypassSSLVerification(bool EnableBypass); #if defined(__APPLE__) #elif defined(__WIN32__) PCCERT_CONTEXT BuildSSLCollection(); #else SSLCertCollectionString BuildSSLCollection(); #endif protected: private: // Variables to set for the CardDAV2 class. CURL *ConnectionSession = nullptr; CURLcode SessionResult = CURLE_OK; struct curl_slist *HeaderList = nullptr; void SetupDefaultParametersNonSSL(bool DoAuthentication); void SetupDefaultParametersSSL(bool DoAuthentication); std::string PageData; std::string PageHeader; char SessionErrorBuffer[CURL_ERROR_SIZE]; static size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, void *stream); size_t WritebackFuncImplementation(char *ptr, size_t size, size_t nmemb, void *stream); std::string BuildURL(std::string URI); void ResetResults(); std::vector GetDAVHeader(); std::string GetETagHeader(); std::string GetETagValue(); std::string GetUserPrincipalURI(); std::string GetAddressBookHomeURI(); std::string GetDefaultAddressBookURI(); void ProcessContactData(COContactList *ContactList); #if defined(__APPLE__) #elif defined(__WIN32__) PCCERT_CONTEXT CertificateData; #else bool EnableSSLBypass = false; #endif }; #endif