Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial version of CardDAV2 class
[xestiaab/.git] / source / carddav2 / carddav2.h
1 // CardDAV2.h - CardDAV v2 class header
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 #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>
31 #include <string>
32 #include <vector>
34 class CardDAV2 : public ConnectionObject {
35         
36         public:
37         
38                 using ConnectionObject::ConnectionObject;
39         
40                 // Destructor.
41         
42                 ~CardDAV2();
43         
44                 // Functions from the ConnectionObject interface.
45         
46                 void SetupConnectionObject();
47                 
48                 bool IsTaskCompleted();
49                 
50                 COConnectResult Connect(bool DoAuthentication);
51                 
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);
59         
60                 bool CanDoProcessing();
61                 bool CanDoSSL();
62                 COSSLVerified SSLVerify();
63                 bool AbleToLogin();
64                 bool HasValidResponse();
65                 bool IsSelfSigned();
66                 std::string GetErrorMessage();
68                 void BypassSSLVerification(bool EnableBypass);
70 #if defined(__APPLE__)
71 #elif defined(__WIN32__)
72 #else
73                 SSLCertCollectionString BuildSSLCollection();
75 #endif
76         
77         protected:
78         private:
79                 
80                 // Variables to set for the CardDAV2 class.
81                 
82                 CURL *ConnectionSession = nullptr;
83                 CURLcode SessionResult = CURLE_OK;
84         
85                 void SetupDefaultParametersNonSSL(bool DoAuthentication);
86                 void SetupDefaultParametersSSL(bool DoAuthentication);
87         
88                 std::string PageData;
89                 std::string PageHeader;
90                 char SessionErrorBuffer[CURL_ERROR_SIZE];
91         
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);
94         
95                 std::string BuildURL(std::string URI);
96                 void ResetResults();
97                 std::vector<std::string> GetDAVHeader();
98         
99                 std::string GetUserPrincipalURI();
100                 std::string GetAddressBookHomeURI();
101                 std::string GetDefaultAddressBookURI();
102         
103 #if defined(__APPLE__)
104 #elif defined(__WIN32__)
105 #else
106                 bool EnableSSLBypass = false;
107 #endif
108         
109 };
111 #endif
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