#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"
using namespace std;
CALDAVQUERYRESULT_UNITTESTFAIL = -1,
CALDAVQUERYRESULT_OK,
CALDAVQUERYRESULT_NOTRUN,
- CALDAVQUERYRESULT_SERVERERROR
+ CALDAVQUERYRESULT_SERVERERROR,
+ CALDAVQUERYRESULT_SSLFAILURE,
};
struct CalDAVCalendarList {
string prefix = "";
bool useSSL = true;
int timeout = 60;
+ string account = "";
};
int seek = 0;
};
+// Objects to move to a ConnectionObject-like interface in the future.
+
+enum COSSLVerified {
+ COSSL_UNITTESTFAIL = -1,
+ COSSL_VERIFIED,
+ COSSL_VERIFIED_USER,
+ COSSL_UNABLETOVERIFY,
+ COSSL_NOTAPPLICABLE,
+ COSSL_NORESULT
+};
+
class CalDAV{
private:
Colour *calendarColour,
string *calendarDescription,
int *calendarOrder);
+ string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress);
+ void SetupDefaultParametersNonSSL(bool doAuthentication);
+ void SetupDefaultParametersSSL(bool doAuthentication);
+ void ResetResults();
CalDAVConnectionData connectionData;
CalDAVServerResult connectionServerResult;
CURL *connectionHandle = nullptr;
+ char sessionErrorBuffer[CURL_ERROR_SIZE];
string serverData = "";
string serverHeader = "";
+ COSSLVerified sslVerified;
+ bool enableSSLBypass = false;
+ bool sslSelfSigned = false;
+ bool sslStatus = false;
+
+ bool validResponse = false;
+ bool authPassed = false;
+ string errorMessage = "";
public:
CalDAV();
~CalDAV();
void SetupConnectionData(CalDAVConnectionData *connData);
CalDAVStatus GetConnectionData();
- CalDAVServerResult Connect();
+ CalDAVServerResult Connect(bool doAuthentication);
CalDAVServerResult GetServerResult();
CalDAVServerSupport GetServerSupport();
CalDAVCalendarList GetCalendars();
string GetCalendarHome(string userPrincipalURI);
CalDAVServerResult GetEntryETag(string *calendarEntryHREF, string *eTagValue);
-
+
+ bool CanDoSSL();
+ bool HasValidResponse();
+ bool AbleToLogin();
+ bool IsSelfSigned();
+ std::string GetErrorMessage();
+
+ COSSLVerified SSLVerify();
+ void BypassSSLVerification(bool EnableBypass);
+
+#if defined(__APPLE__)
+
+ SecTrustRef BuildSSLCollection();
+
+#elif defined(__WIN32__)
+
+ PCCERT_CONTEXT BuildSSLCollection();
+
+#else
+ SSLCertCollectionString BuildSSLCollection();
+
+#endif
};
// Subroutines that are used with the
// CalDAVConnectionData struct.
-bool CalDAVObjectValidSettings(CalDAVConnectionData *connData);
-string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress);
+//bool CalDAVObjectValidSettings(CalDAVConnectionData *connData);
#endif