Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Moved the ConnectionObject subroutines in the CardDAV header to in the #defined(__APP...
[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 #include "../vcard/vcard.h"
29 #include "../actmgr/frmActivityMgr.h"
30 #include "../common/sslcertstructs.h"
32 struct FileSyncData{
33         unsigned int DataFlag:2;
34         wxString ETagData;
35 };
37 struct ContactListData{
38         wxString SyncToken;
39         std::map<wxString,FileSyncData> ListData;
40 };
42 struct UploadDataStruc{
43         wxString *readptr;
44         long sizeleft;
45         int seek = 0;
46 };
48 /*struct CertificateData{
49         std::multimap<wxString,wxString> CertificateData;
50         bool CertValid;
51         int CertError;
52 };
54 struct CertificateCollection{
55         std::map<int,CertificateData> Certificates;
56         std::map<int,int> ParentCerticiate;
57         bool AllCertsValid;
58         std::map<int,int> CertErrors;
59 };*/
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);
67 class CardDAV
68 {
69         public:
70                 CardDAV();
71                 ~CardDAV();
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);
74                 bool CanDoCardDAV();
75                 bool CanDoSSL();
76                 bool SSLVerify();
77                 bool AbleToLogin();
78                 bool HasValidResponse();
79                 bool IsSelfSigned();
80                 wxString GetResponseData();
81                 void AllowSelfSignTest(bool AllowSelfSignIn);           
82                 bool Connect();
83                 bool ConnectThread();
84                 void ProcessData();
85                 void SetupData(wxString Method, wxString FilenameLocation, wxString UploadData);
86                 void ProcessDataThread();
87                 void SetUploadMode(bool IncMode);
88                 void Abort();
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);
100                 int GetResultCode();
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();
114 #endif
115     
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);
122         private:
123 #if defined(__APPLE__)
124                 static SSLContext *SSLContextPointer;
125                 static SecTrustRef SecTrustObject;
126                 static CURL* ConnectionObject;
127 #endif
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;
159         protected:
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;
167                                 
168 };
170 #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