Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
3828d0776490b869f9daf614e2a1806b3d1eeb63
[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"
25 #include "../common/dirs.h"
27 #include <curl/curl.h>
28 #include <wx/tokenzr.h>
29 #include <wx/file.h>
30 #include <libxml/parser.h>
31 #include <libxml/tree.h>
33 #include <string>
34 #include <vector>
36 class CardDAV2 : public ConnectionObject {
37         
38         public:
39         
40                 using ConnectionObject::ConnectionObject;
41         
42                 // Destructor.
43         
44                 ~CardDAV2();
45         
46                 // Functions from the ConnectionObject interface.
47         
48                 void SetupConnectionObject();
49                 
50                 bool IsTaskCompleted();
51                 
52                 COConnectResult Connect(bool DoAuthentication);
53                 
54                 COServerResponse GetDefaultPrefix(std::string *ServerPrefix);
55                 COServerResponse AddContact(std::string Location, std::string Data);
56                 COServerResponse EditContact(std::string Location, std::string Data);
57                 COServerResponse DeleteContact(std::string Location, std::string EntityTag);
58                 COServerResponse GetServerEntityTagValue(std::string Location);
59                 COServerResponse GetContact(std::string Location);
60                 COContactList GetContactList(std::string SyncToken);
61         
62                 bool CanDoProcessing();
63                 bool CanDoSSL();
64                 COSSLVerified SSLVerify();
65                 bool AbleToLogin();
66                 bool HasValidResponse();
67                 bool IsSelfSigned();
68                 std::string GetErrorMessage();
70                 void BypassSSLVerification(bool EnableBypass);
72 #if defined(__APPLE__)
73 #elif defined(__WIN32__)
74 #else
75                 SSLCertCollectionString BuildSSLCollection();
77 #endif
78         
79         protected:
80         private:
81                 
82                 // Variables to set for the CardDAV2 class.
83                 
84                 CURL *ConnectionSession = nullptr;
85                 CURLcode SessionResult = CURLE_OK;
86                 struct curl_slist *HeaderList = nullptr;
87         
88                 void SetupDefaultParametersNonSSL(bool DoAuthentication);
89                 void SetupDefaultParametersSSL(bool DoAuthentication);
90         
91                 std::string PageData;
92                 std::string PageHeader;
93                 char SessionErrorBuffer[CURL_ERROR_SIZE];
94         
95                 static size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, void *stream);
96                 size_t WritebackFuncImplementation(char *ptr, size_t size, size_t nmemb, void *stream);
97         
98                 std::string BuildURL(std::string URI);
99                 void ResetResults();
100                 std::vector<std::string> GetDAVHeader();
101                 std::string GetETagHeader();
102         
103                 std::string GetUserPrincipalURI();
104                 std::string GetAddressBookHomeURI();
105                 std::string GetDefaultAddressBookURI();
106         
107 #if defined(__APPLE__)
108 #elif defined(__WIN32__)
109 #else
110                 bool EnableSSLBypass = false;
111 #endif
112         
113 };
115 #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