Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Fixed cleaning of old object files
[xestiaab/.git] / source / carddav / carddav.h
1 // carddav.h - CardDAV Object header file.
2 //
3 // (c) 2012-2015 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 CALDAV_CALDAV_H
20 #define CALDAV_CALDAV_H
22 #include <iostream>
23 #include <map>
24 #include <wx/wx.h>
25 #include <libxml/parser.h>
26 #include <libxml/tree.h>
27 #include <curl/curl.h>
28 #if defined(__WIN32__)
29 #include <Windows.h>
30 #include <basetsd.h>
31 #include <winapifamily.h>
32 #include <security.h>
33 #include <schannel.h>
34 #include <cryptuiapi.h>
35 #include <sspi.h>
36 #endif
37 #include "../vcard/vcard.h"
38 #include "../actmgr/frmActivityMgr.h"
39 #include "../common/sslcertstructs.h"
41 struct FileSyncData{
42         unsigned int DataFlag:2;
43         wxString ETagData;
44 };
46 struct ContactListData{
47         wxString SyncToken;
48         std::map<wxString,FileSyncData> ListData;
49 };
51 struct UploadDataStruc{
52         wxString *readptr;
53         long sizeleft;
54         int seek = 0;
55 };
57 /*struct CertificateData{
58         std::multimap<wxString,wxString> CertificateData;
59         bool CertValid;
60         int CertError;
61 };
63 struct CertificateCollection{
64         std::map<int,CertificateData> Certificates;
65         std::map<int,int> ParentCerticiate;
66         bool AllCertsValid;
67         std::map<int,int> CertErrors;
68 };*/
70 //size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *userdata);
72 size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *userdata);
73 int ProgressFunc(void *clientdata, double TTDown, double NDown, double TTUp, double NUp);
74 size_t UploadReadFunc(void *ptr, size_t size, size_t nmemb, void *userdata);
76 class CardDAV
77 {
78         public:
79                 CardDAV();
80                 ~CardDAV();
81                 bool SetupConnection(wxString SvrAddress, int SvrPort, wxString SvrUser, wxString SvrPass, bool SvrSSL);
82                 bool SetupConnection(wxString SvrAddress, int SvrPort, wxString SvrUser, wxString SvrPass, bool SvrSSL, wxString SvrPrefix, wxString SvrAccount);
83                 bool CanDoCardDAV();
84                 bool CanDoSSL();
85                 bool SSLVerify();
86                 bool AbleToLogin();
87                 bool HasValidResponse();
88                 bool IsSelfSigned();
89                 wxString GetResponseData();
90                 void AllowSelfSignTest(bool AllowSelfSignIn);           
91                 bool Connect();
92                 bool ConnectThread();
93                 void ProcessData();
94                 void SetupData(wxString Method, wxString FilenameLocation, wxString UploadData);
95                 void ProcessDataThread();
96                 void SetUploadMode(bool IncMode);
97                 void Abort();
98                 bool SetupResultBools(bool *SvrResult, bool *SvrMonitor);
99                 int ProgressFuncProc(void *clientdata, double TTUp, double NUp, double TTDown, double NDown);
100                 void SetupVariables(std::map<int, int> *actlist, int actindex);
101                 wxString GetETagData();
102                 void GetServerETagValue();
103                 void GetServerETagValueThread();
104                 void GetServerContactData();
105                 wxString GetPageData();
106                 void SetEditMode(bool EditModeInc);
107                 ContactListData GetContactList(wxString SyncTokenInc);
108                 void SetServerFilename(wxString Filename);
109                 int GetResultCode();
110                 static int GetHTTPCode();
111                 wxString GetErrorBuffer();
112                 wxString GetDefaultAddressBookURL();
113                 void GetSSLResults();
114                 SSLCertCollection GetCertificateData();
115                 static SSLCertCollection BuildSSLCollection(CURL *conn);
116                 wxString ETagValueResult();
117                 wxString GetErrorMessage();
118                 static size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *stream);
119 #if defined(__APPLE__) || defined(__WIN32__)
120                 static CURL* GetConnectionObject();
121                 static void SetConnectionObject(CURL *ConnectionObject);
122 #endif
124 #if defined(__APPLE__)
125                 SecTrustRef GetTrustObject();
126 #elif defined(__WIN32__)
127                 PCCERT_CONTEXT GetCertificateContextPointer();
128                 CERT_CONTEXT GetCertificateContext();
129 #endif
130     
131                 // SSL Verification tests when connecting.
133                 static CURLcode SSLVerifyTest();
134                 static SSLCertCollection GetSSLVerifyResults();
136                 //size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *userdata);
137         private:
138 #if defined(__APPLE__) || defined(__WIN32__)
139                 static CURL* ConnectionObject;
140 #endif
141 #if defined(__APPLE__)
142                 static SSLContext *SSLContextPointer;
143                 static SecTrustRef SecTrustObject;
144 #elif defined(__WIN32__)
145                 static PCCERT_CONTEXT CertificateData;
146 #endif
147                 static wxString ServerAddress;
148                 static int ServerPort;
149                 static wxString ServerUser;
150                 static wxString ServerPass;
151                 static wxString ServerPrefix;
152                 static wxString ServerAccount;
153                 static bool ServerSSL;
154                 static bool *ServerResult;
155                 static bool *ServerMonitor;
156                 static bool SSLStatus;
157                 static bool SSLVerified;
158                 static bool ValidResponse;
159                 static bool AuthPassed;
160                 static bool HasCalDAVSupport;
161                 static bool AbortConnection;
162                 static wxString ServerResponse;
163                 static wxString ServerMethod;
164                 static wxString ServerFilenameLocation;
165                 static wxString ServerUploadData;
166                 static wxString ETagData;
167                 static wxString ETagResult;
168                 static bool UploadMode;
169                 static bool EditMode;
170                 static long ItemIndex;
171                 static std::map<int, int> *ActivityListPtr;
172                 //frmActivityMgr *ActMgrPtr;
173                 static char curlerrbuffer[CURL_ERROR_SIZE];
174                 static SSLCertCollection SSLCertCol;
175                 static wxString ErrorMessage;
176                 static wxString ErrorBufferMessage;
177                 static bool AllowSelfSign;
178         protected:
179                 static int SSLErrorCode;
180                 static int ConnectionErrorCode;
181                 static wxString PageHeader;
182                 static wxString PageData;
183                 static CURLcode claconncode;
184                 static int HTTPErrorCode;
185                 static SSLCertCollection VerifyCertCollection;
186                                 
187 };
189 #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