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/>
22 #include <libxml/parser.h>
23 #include <libxml/tree.h>
24 #include <curl/curl.h>
25 #include "../vcard/vcard.h"
26 #include "../actmgr/frmActivityMgr.h"
27 #include "../common/sslcertstructs.h"
29 #ifndef CALDAV_CALDAV_H
30 #define CALDAV_CALDAV_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();
110 // SSL Verification tests when connecting.
112 static CURLcode SSLVerifyTest();
113 static SSLCertCollection GetSSLVerifyResults();
115 //size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *userdata);
117 static wxString ServerAddress;
118 static int ServerPort;
119 static wxString ServerUser;
120 static wxString ServerPass;
121 static wxString ServerPrefix;
122 static wxString ServerAccount;
123 static bool ServerSSL;
124 static bool *ServerResult;
125 static bool *ServerMonitor;
126 static bool SSLStatus;
127 static bool SSLVerified;
128 static bool ValidResponse;
129 static bool AuthPassed;
130 static bool HasCalDAVSupport;
131 static bool AbortConnection;
132 static wxString ServerResponse;
133 static wxString ServerMethod;
134 static wxString ServerFilenameLocation;
135 static wxString ServerUploadData;
136 static wxString ETagData;
137 static wxString ETagResult;
138 static bool UploadMode;
139 static bool EditMode;
140 static long ItemIndex;
141 static std::map<int, int> *ActivityListPtr;
142 //frmActivityMgr *ActMgrPtr;
143 static char curlerrbuffer[CURL_ERROR_SIZE];
144 static SSLCertCollection SSLCertCol;
145 static wxString ErrorMessage;
146 static wxString ErrorBufferMessage;
147 static bool AllowSelfSign;
149 static int SSLErrorCode;
150 static int ConnectionErrorCode;
151 static wxString PageHeader;
152 static wxString PageData;
153 static CURLcode claconncode;
154 static int HTTPErrorCode;
155 static SSLCertCollection VerifyCertCollection;