1 // CardDAV2.h - CardDAV v2 class header
3 // (c) 2012-2016 Xestia Software Development.
5 // This file is part of Xestia Address Book.
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.
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.
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 #ifndef __CARDDAV2_CARDDAV2_H__
20 #define __CARDDAV2_CARDDAV2_H__
22 #include "../connobject/ConnectionObject.h"
23 #include "../version.h"
24 #include "../common/sslcertstructs.h"
26 #include <curl/curl.h>
27 #include <wx/tokenzr.h>
28 #include <libxml/parser.h>
29 #include <libxml/tree.h>
34 class CardDAV2 : public ConnectionObject {
38 using ConnectionObject::ConnectionObject;
44 // Functions from the ConnectionObject interface.
46 void SetupConnectionObject();
48 bool IsTaskCompleted();
50 COConnectResult Connect(bool DoAuthentication);
52 COServerResponse GetDefaultPrefix(std::string *ServerPrefix);
53 COServerResponse AddContact(std::string Location, std::string Data);
54 COServerResponse EditContact(std::string Location, std::string Data);
55 COServerResponse DeleteContact(std::string Location, std::string EntityTag);
56 COServerResponse GetServerEntityTagValue(std::string Location);
57 COServerResponse GetContact(std::string Location);
58 COContactList GetContactList(std::string SyncToken);
60 bool CanDoProcessing();
62 COSSLVerified SSLVerify();
64 bool HasValidResponse();
66 std::string GetErrorMessage();
68 void BypassSSLVerification(bool EnableBypass);
70 #if defined(__APPLE__)
71 #elif defined(__WIN32__)
73 SSLCertCollectionString BuildSSLCollection();
80 // Variables to set for the CardDAV2 class.
82 CURL *ConnectionSession = nullptr;
83 CURLcode SessionResult = CURLE_OK;
85 void SetupDefaultParametersNonSSL(bool DoAuthentication);
86 void SetupDefaultParametersSSL(bool DoAuthentication);
89 std::string PageHeader;
90 char SessionErrorBuffer[CURL_ERROR_SIZE];
92 static size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, void *stream);
93 size_t WritebackFuncImplementation(char *ptr, size_t size, size_t nmemb, void *stream);
95 std::string BuildURL(std::string URI);
97 std::vector<std::string> GetDAVHeader();
99 std::string GetUserPrincipalURI();
100 std::string GetAddressBookHomeURI();
101 std::string GetDefaultAddressBookURI();
103 #if defined(__APPLE__)
104 #elif defined(__WIN32__)
106 bool EnableSSLBypass = false;