Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
macOS: Implemented support for adding, editing and deleting a CalDAV account
[xestiacalendar/.git] / source / objects / CalDAV / CalDAV.h
index 7ca237a..eeb84e7 100644 (file)
@@ -22,6 +22,8 @@
 #include <curl/curl.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
+#include <wx/tokenzr.h>
+#include <wx/file.h>
 #include <string>
 #include <iostream>
 #include <vector>
 #include "../../common/colour.h"
 #include "../../common/text.h"
 #include "../../common/uuid.h"
+#include "../../common/dirs.h"
 #include "../../common/sslcertstructs.h"
+#include "../../version.h"
+
+#if defined (__APPLE__)
+#import <Foundation/Foundation.h>
+#import <SecurityInterface/SFCertificateTrustPanel.h>
+#endif
+
+#if defined(__WIN32__)
+#include "../common/win32ssl.h"
+#endif
 
 using namespace std;
 
@@ -41,7 +54,8 @@ enum CalDAVQueryResult {
        CALDAVQUERYRESULT_UNITTESTFAIL = -1,
        CALDAVQUERYRESULT_OK,
        CALDAVQUERYRESULT_NOTRUN,
-       CALDAVQUERYRESULT_SERVERERROR
+       CALDAVQUERYRESULT_SERVERERROR,
+       CALDAVQUERYRESULT_SSLFAILURE,
 };
 
 struct CalDAVCalendarList {
@@ -73,6 +87,7 @@ struct CalDAVConnectionData{
        string prefix = "";
        bool useSSL = true;
        int timeout = 60;
+       string account = "";
        
 };
 
@@ -155,22 +170,40 @@ class CalDAV{
                        Colour *calendarColour,
                        string *calendarDescription,
                        int *calendarOrder);
+               string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress);
+               void SetupDefaultParametersNonSSL(bool doAuthentication);
+               void SetupDefaultParametersSSL(bool doAuthentication);
+               void ResetResults();
+
+               static size_t CalDAVReceive(char *receivedBuffer, size_t size, size_t newMemoryBytes, void *stream);
        
                CalDAVConnectionData connectionData;
                CalDAVServerResult connectionServerResult;
                CURL *connectionHandle = nullptr;
+               char sessionErrorBuffer[CURL_ERROR_SIZE];
                string serverData = "";
                string serverHeader = "";
        
-               COSSLVerified SSLVerified;
-               bool EnableSSLBypass = false;
-               bool SSLSelfSigned = false;
+               COSSLVerified sslVerified;
+               bool enableSSLBypass = false;
+               bool sslSelfSigned = false;
+               bool sslStatus = false;
+               
+               bool validResponse = false;
+               bool authPassed = false;
+               string errorMessage = "";
+
+#if defined(__APPLE__)
+               SecTrustRef certificateData = nullptr;
+#elif defined(__WIN32__)
+               PCCERT_CONTEXT certificateData = nullptr;
+#endif
        public:
                CalDAV();
                ~CalDAV();
                void SetupConnectionData(CalDAVConnectionData *connData);
                CalDAVStatus GetConnectionData();
-               CalDAVServerResult Connect();
+               CalDAVServerResult Connect(bool doAuthentication);
                CalDAVServerResult GetServerResult();
                CalDAVServerSupport GetServerSupport();
                CalDAVCalendarList GetCalendars();
@@ -205,6 +238,12 @@ class CalDAV{
                
                CalDAVServerResult GetEntryETag(string *calendarEntryHREF, string *eTagValue);
 
+               bool CanDoSSL();
+               bool HasValidResponse();
+               bool AbleToLogin();
+               bool IsSelfSigned();
+               std::string GetErrorMessage();
+
                COSSLVerified SSLVerify();
                void BypassSSLVerification(bool EnableBypass);
                
@@ -220,12 +259,27 @@ class CalDAV{
                SSLCertCollectionString BuildSSLCollection();
 
 #endif
+
+               struct CalDAVPassObject {
+                       CalDAV *CalDAVObject = nullptr;
+                       std::string *DataSetting = nullptr;
+                       bool ServerUsingSSL = false;
+                       CURL *ConnectionSessionObject = nullptr;
+#if defined(__APPLE__)
+                       SecTrustRef SSLContext = nullptr;
+#elif defined (__WIN32__)
+                       PCCERT_CONTEXT SSLContext = nullptr;
+#endif
+               };
+
+               private:
+                       CalDAVPassObject PageDataObject;
+                       CalDAVPassObject PageHeaderObject;
 };
 
 // Subroutines that are used with the 
 // CalDAVConnectionData struct.
 
 //bool CalDAVObjectValidSettings(CalDAVConnectionData *connData);
-//string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress);
 
 #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