Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
6fed60df42ef4141664a1e97d74e23c882914caf
[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 #include <iostream>
20 #include <map>
21 #include <wx/wx.h>
22 #include <libxml/parser.h>
23 #include <libxml/tree.h>
24 #include <curl/curl.h>
25 #include "../vcard/vcard.h"
26 #include "../frmActivityMgr.h"
27 #include "../common/sslcertstructs.h"
29 #ifndef CALDAV_CALDAV_H
30 #define CALDAV_CALDAV_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         
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);
116         private:
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;
148         protected:
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;
156                                 
157 };
159 #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