// carddav.h - CardDAV Object header file. // // (c) 2012-2015 Xestia Software Development. // // This file is part of Xestia Address Book. // // Xestia Address Book is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by the // Free Software Foundation, version 3 of the license. // // Xestia Address Book is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with Xestia Address Book. If not, see #include #include #include #include #include #include #include "../vcard/vcard.h" #include "../actmgr/frmActivityMgr.h" #include "../common/sslcertstructs.h" #ifndef CALDAV_CALDAV_H #define CALDAV_CALDAV_H struct FileSyncData{ unsigned int DataFlag:2; wxString ETagData; }; struct ContactListData{ wxString SyncToken; std::map ListData; }; struct UploadDataStruc{ wxString *readptr; long sizeleft; int seek = 0; }; /*struct CertificateData{ std::multimap CertificateData; bool CertValid; int CertError; }; struct CertificateCollection{ std::map Certificates; std::map ParentCerticiate; bool AllCertsValid; std::map CertErrors; };*/ //size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *userdata); size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, wxString *userdata); int ProgressFunc(void *clientdata, double TTDown, double NDown, double TTUp, double NUp); size_t UploadReadFunc(void *ptr, size_t size, size_t nmemb, void *userdata); class CardDAV { public: CardDAV(); ~CardDAV(); bool SetupConnection(wxString SvrAddress, int SvrPort, wxString SvrUser, wxString SvrPass, bool SvrSSL); bool SetupConnection(wxString SvrAddress, int SvrPort, wxString SvrUser, wxString SvrPass, bool SvrSSL, wxString SvrPrefix, wxString SvrAccount); bool CanDoCardDAV(); bool CanDoSSL(); bool SSLVerify(); bool AbleToLogin(); bool HasValidResponse(); bool IsSelfSigned(); wxString GetResponseData(); void AllowSelfSignTest(bool AllowSelfSignIn); bool Connect(); bool ConnectThread(); void ProcessData(); void SetupData(wxString Method, wxString FilenameLocation, wxString UploadData); void ProcessDataThread(); void SetUploadMode(bool IncMode); void Abort(); bool SetupResultBools(bool *SvrResult, bool *SvrMonitor); int ProgressFuncProc(void *clientdata, double TTUp, double NUp, double TTDown, double NDown); void SetupVariables(std::map *actlist, int actindex); wxString GetETagData(); void GetServerETagValue(); void GetServerETagValueThread(); void GetServerContactData(); wxString GetPageData(); void SetEditMode(bool EditModeInc); ContactListData GetContactList(wxString SyncTokenInc); void SetServerFilename(wxString Filename); int GetResultCode(); static int GetHTTPCode(); wxString GetErrorBuffer(); wxString GetDefaultAddressBookURL(); void GetSSLResults(); SSLCertCollection GetCertificateData(); static SSLCertCollection BuildSSLCollection(CURL *conn); wxString ETagValueResult(); wxString GetErrorMessage(); // SSL Verification tests when connecting. static CURLcode SSLVerifyTest(); static SSLCertCollection GetSSLVerifyResults(); //size_t WritebackFunc(char *ptr, size_t size, size_t nmemb, FILE *userdata); private: static wxString ServerAddress; static int ServerPort; static wxString ServerUser; static wxString ServerPass; static wxString ServerPrefix; static wxString ServerAccount; static bool ServerSSL; static bool *ServerResult; static bool *ServerMonitor; static bool SSLStatus; static bool SSLVerified; static bool ValidResponse; static bool AuthPassed; static bool HasCalDAVSupport; static bool AbortConnection; static wxString ServerResponse; static wxString ServerMethod; static wxString ServerFilenameLocation; static wxString ServerUploadData; static wxString ETagData; static wxString ETagResult; static bool UploadMode; static bool EditMode; static long ItemIndex; static std::map *ActivityListPtr; //frmActivityMgr *ActMgrPtr; static char curlerrbuffer[CURL_ERROR_SIZE]; static SSLCertCollection SSLCertCol; static wxString ErrorMessage; static wxString ErrorBufferMessage; static bool AllowSelfSign; protected: static int SSLErrorCode; static int ConnectionErrorCode; static wxString PageHeader; static wxString PageData; static CURLcode claconncode; static int HTTPErrorCode; static SSLCertCollection VerifyCertCollection; }; #endif