1 // carddav.h - CardDAV Object header file.
3 // (c) 2012-2015 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 CALDAV_CALDAV_H
20 #define CALDAV_CALDAV_H
25 #include <libxml/parser.h>
26 #include <libxml/tree.h>
27 #include <curl/curl.h>
28 #include "../vcard/vcard.h"
29 #include "../actmgr/frmActivityMgr.h"
30 #include "../common/sslcertstructs.h"
33 unsigned int DataFlag:2;
37 struct ContactListData{
39 std::map<wxString,FileSyncData> ListData;
42 struct UploadDataStruc{
48 /*struct CertificateData{
49 std::multimap<wxString,wxString> CertificateData;
54 struct CertificateCollection{
55 std::map<int,CertificateData> Certificates;
56 std::map<int,int> ParentCerticiate;
58 std::map<int,int> CertErrors;
61 //size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *userdata);
63 size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *userdata);
64 int ProgressFunc(void *clientdata, double TTDown, double NDown, double TTUp, double NUp);
65 size_t UploadReadFunc(void *ptr, size_t size, size_t nmemb, void *userdata);
72 bool SetupConnection(wxString SvrAddress, int SvrPort, wxString SvrUser, wxString SvrPass, bool SvrSSL);
73 bool SetupConnection(wxString SvrAddress, int SvrPort, wxString SvrUser, wxString SvrPass, bool SvrSSL, wxString SvrPrefix, wxString SvrAccount);
78 bool HasValidResponse();
80 wxString GetResponseData();
81 void AllowSelfSignTest(bool AllowSelfSignIn);
85 void SetupData(wxString Method, wxString FilenameLocation, wxString UploadData);
86 void ProcessDataThread();
87 void SetUploadMode(bool IncMode);
89 bool SetupResultBools(bool *SvrResult, bool *SvrMonitor);
90 int ProgressFuncProc(void *clientdata, double TTUp, double NUp, double TTDown, double NDown);
91 void SetupVariables(std::map<int, int> *actlist, int actindex);
92 wxString GetETagData();
93 void GetServerETagValue();
94 void GetServerETagValueThread();
95 void GetServerContactData();
96 wxString GetPageData();
97 void SetEditMode(bool EditModeInc);
98 ContactListData GetContactList(wxString SyncTokenInc);
99 void SetServerFilename(wxString Filename);
101 static int GetHTTPCode();
102 wxString GetErrorBuffer();
103 wxString GetDefaultAddressBookURL();
104 void GetSSLResults();
105 SSLCertCollection GetCertificateData();
106 static SSLCertCollection BuildSSLCollection(CURL *conn);
107 wxString ETagValueResult();
108 wxString GetErrorMessage();
109 static size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream);
110 #if defined(__APPLE__)
111 static CURL* GetConnectionObject();
112 static void SetConnectionObject(CURL *ConnectionObject);
113 SecTrustRef GetTrustObject();
116 // SSL Verification tests when connecting.
118 static CURLcode SSLVerifyTest();
119 static SSLCertCollection GetSSLVerifyResults();
121 //size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *userdata);
123 #if defined(__APPLE__)
124 static SSLContext *SSLContextPointer;
125 static SecTrustRef SecTrustObject;
126 static CURL* ConnectionObject;
128 static wxString ServerAddress;
129 static int ServerPort;
130 static wxString ServerUser;
131 static wxString ServerPass;
132 static wxString ServerPrefix;
133 static wxString ServerAccount;
134 static bool ServerSSL;
135 static bool *ServerResult;
136 static bool *ServerMonitor;
137 static bool SSLStatus;
138 static bool SSLVerified;
139 static bool ValidResponse;
140 static bool AuthPassed;
141 static bool HasCalDAVSupport;
142 static bool AbortConnection;
143 static wxString ServerResponse;
144 static wxString ServerMethod;
145 static wxString ServerFilenameLocation;
146 static wxString ServerUploadData;
147 static wxString ETagData;
148 static wxString ETagResult;
149 static bool UploadMode;
150 static bool EditMode;
151 static long ItemIndex;
152 static std::map<int, int> *ActivityListPtr;
153 //frmActivityMgr *ActMgrPtr;
154 static char curlerrbuffer[CURL_ERROR_SIZE];
155 static SSLCertCollection SSLCertCol;
156 static wxString ErrorMessage;
157 static wxString ErrorBufferMessage;
158 static bool AllowSelfSign;
160 static int SSLErrorCode;
161 static int ConnectionErrorCode;
162 static wxString PageHeader;
163 static wxString PageData;
164 static CURLcode claconncode;
165 static int HTTPErrorCode;
166 static SSLCertCollection VerifyCertCollection;