size_t CalDAVSend(char *sendBuffer, size_t size, size_t newMemoryBytes, void *dataStruct){
- struct CalDAVSendData *uploadPtr = (struct calDAVSendData *)dataStruct;
+ struct CalDAVSendData *uploadPtr = (struct CalDAVSendData *)dataStruct;
if (uploadPtr->sizeleft){
}
-CalDAVServerResult CalDAV::Connect(){
+CalDAVServerResult CalDAV::Connect(bool doAuthentication){
+
+ connectionData.useSSL ? SetupDefaultParametersSSL(doAuthentication) : SetupDefaultParametersNonSSL(doAuthentication);
+ ResetResults();
CalDAVServerResult serverResult;
// Setup the server password.
- ServerUserPass += connectionData.username;
- ServerUserPass += ":";
- ServerUserPass += connectionData.password;
+ serverUserPass += connectionData.username;
+ serverUserPass += ":";
+ serverUserPass += connectionData.password;
curl_easy_setopt(connectionHandle, CURLOPT_URL, serverAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_USERPWD, serverUserPass.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_FAILONERROR, 1L);
curl_easy_setopt(connectionHandle, CURLOPT_TIMEOUT, connectionData.timeout);
- curl_easy_setopt(connectionHandle, CURLOPT_WRITEFUNCTION, calDAVReceive);
+ curl_easy_setopt(connectionHandle, CURLOPT_WRITEFUNCTION, CalDAVReceive);
curl_easy_setopt(connectionHandle, CURLOPT_WRITEDATA, &serverData);
curl_easy_setopt(connectionHandle, CURLOPT_WRITEHEADER, &serverHeader);
serverResult.code = curl_easy_perform(connectionHandle);
// Process the result received from the server.
-
- if (serverResult.code != CURLE_OK){
-
- serverResult.result = CALDAVQUERYRESULT_SERVERERROR;
-
- } else {
-
- serverResult.result = CALDAVQUERYRESULT_OK;
-
- }
-
+
// Get the HTTP code.
curl_easy_getinfo(connectionHandle, CURLINFO_RESPONSE_CODE, &serverResult.httpCode);
+
+ switch(serverResult.code){
+ case CURLE_OK:
+ authPassed = true;
+ case CURLE_HTTP_RETURNED_ERROR:
+ if (connectionData.useSSL)
+ {
+ sslStatus = connectionData.useSSL;
+ sslVerified = COSSL_VERIFIED;
+ }
+ serverResult.result = CALDAVQUERYRESULT_OK;
+ if (serverResult.httpCode == 401)
+ {
+ authPassed = false;
+ }
+ break;
+ case CURLE_SSL_CACERT:
+ case CURLE_SSL_CONNECT_ERROR:
+ if (connectionData.useSSL)
+ {
+ sslStatus = connectionData.useSSL;
+ sslVerified = COSSL_UNABLETOVERIFY;
+ }
+ serverResult.result = CALDAVQUERYRESULT_SSLFAILURE;
+ authPassed = false;
+ break;
+ default:
+ serverResult.result = CALDAVQUERYRESULT_SERVERERROR;
+ authPassed = false;
+ break;
+ };
+
+ if (serverResult.httpCode >= 200 && serverResult.httpCode <= 299)
+ {
+ validResponse = true;
+ }
return serverResult;
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "PROPFIND");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &userPrincipalSendData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Process the data.
// Set the results.
if (serverResult == CURLE_OK){
- connectionServerResult.Result = CALDAVQUERYRESULT_OK;
+ connectionServerResult.result = CALDAVQUERYRESULT_OK;
} else {
- connectionServerResult.Result = CALDAVQUERYRESULT_SERVERERROR;
+ connectionServerResult.result = CALDAVQUERYRESULT_SERVERERROR;
}
- connectionServerResult.Code = serverResult;
- curl_easy_getinfo(connectionHandle, CURLINFO_RESPONSE_CODE, &connectionServerResult.HTTPCode);
+ connectionServerResult.code = serverResult;
+ curl_easy_getinfo(connectionHandle, CURLINFO_RESPONSE_CODE, &connectionServerResult.httpCode);
if (serverResult != CURLE_OK){
// Reset the changed settings.
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_URL, calendarHomeURL.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "PROPFIND");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &calendarHomeSendData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Process the data.
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_URL, calendarListURLAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "PROPFIND");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &calendarListSendData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Process the data.
connectionServerResult.code = serverResult;
curl_easy_getinfo(connectionHandle, CURLINFO_RESPONSE_CODE, &connectionServerResult.httpCode);
- if (cerverResult != CURLE_OK){
+ if (serverResult != CURLE_OK){
return serverList;
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_URL, entryListURLAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "REPORT");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &entryListSendData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Process the data.
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_URL, entryListURLAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "REPORT");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &entryListSendData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Process the data.
curl_easy_setopt(connectionHandle, CURLOPT_URL, entryListURLAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "REPORT");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &updatedEntryListSendData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Get the updated calendar data.
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
if (userPrincipalURI.size() == 0){
- return ServerResult;
+ return serverResult;
}
struct curl_slist *calendarRequestHeader = NULL;
- //curl_easy_setopt(ConnectionHandle, CURLOPT_HTTPHEADER, CalendarRequestHeader);
+ //curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, CalendarRequestHeader);
curl_easy_setopt(connectionHandle, CURLOPT_URL, calendarListURLAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "MKCALENDAR");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &calendarAddSendData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Process the data.
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
struct curl_slist *calendarRequestHeader = NULL;
- //curl_easy_setopt(ConnectionHandle, CURLOPT_HTTPHEADER, CalendarRequestHeader);
+ //curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, CalendarRequestHeader);
curl_easy_setopt(connectionHandle, CURLOPT_URL, calendarEditURLAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "PROPPATCH");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &calendarEditSendData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Process the data.
CURLcode serverConnectionResult = curl_easy_perform(connectionHandle);
- if (serverConnectionRsult == CURLE_OK){
+ if (serverConnectionResult == CURLE_OK){
serverResult.result = CALDAVQUERYRESULT_OK;
} else {
serverResult.result = CALDAVQUERYRESULT_SERVERERROR;
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
- return ServerResult;
+ return serverResult;
}
}
-CalDAVServerResult CalDAV::EditCalendar(string *CalendarHREF,
- Colour *CalendarColour){
-
+CalDAVServerResult CalDAV::EditCalendar(string *calendarHREF,
+ Colour *calendarColour){
CalDAVServerResult serverResult;
CURLcode serverConnectionResult = curl_easy_perform(connectionHandle);
if (serverConnectionResult == CURLE_OK){
- serverResult.Result = CALDAVQUERYRESULT_OK;
+ serverResult.result = CALDAVQUERYRESULT_OK;
} else {
- serverResult.Result = CALDAVQUERYRESULT_SERVERERROR;
+ serverResult.result = CALDAVQUERYRESULT_SERVERERROR;
}
serverResult.code = serverConnectionResult;
curl_easy_getinfo(connectionHandle, CURLINFO_RESPONSE_CODE, &serverResult.httpCode);
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_URL, getETagURLAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "REPORT");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &entryETagGetData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Attempt to get the entity tag.
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_URL, entryAddURLAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &entryAddSendData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Process the data.
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_URL, entryAddURLAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, &entryAddSendData);
- curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, calDAVSend);
+ curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, CalDAVSend);
// Process the data.
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_URL, originalServerAddress.c_str());
curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_UPLOAD, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
curl_easy_setopt(connectionHandle, CURLOPT_READDATA, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, NULL);
}
-bool CalDAVObjectValidSettings(CalDAVConnectionData *connData){
+COSSLVerified CalDAV::SSLVerify()
+{
+ return sslVerified;
+}
+
+void CalDAV::BypassSSLVerification(bool enableBypass){
+ enableSSLBypass = enableBypass;
+ sslSelfSigned = enableBypass;
+}
+
+#if defined(__APPLE__)
+
+SecTrustRef CalDAV::BuildSSLCollection(){
+
+ return certificateData;
+
+}
+
+#elif defined(__WIN32__)
+
+PCCERT_CONTEXT CalDAV::BuildSSLCollection(){
+
+ return certificateData;
+
+}
+
+#else
+
+SSLCertCollectionString CalDAV::BuildSSLCollection(){
+
+ // Build and return the SSL collection.
+
+ SSLCertCollectionString sslCertInfo;
+
+ // Grab the certificate data.
+
+ union {
+ struct curl_slist *certdata;
+ struct curl_certinfo *certinfo;
+ } certptr;
+
+ certptr.certdata = NULL;
+
+ CURLcode result = curl_easy_getinfo(connectionHandle, CURLINFO_CERTINFO, &certptr.certinfo);
+
+ std::string certPropName;
+ std::string certPropValue;
+
+ for (int i = 0; i < certptr.certinfo->num_of_certs; i++){
+
+ struct curl_slist *slist;
+ SSLCertDataString sslCertDataInc;
+
+ for (slist = certptr.certinfo->certinfo[i]; slist; slist = slist->next){
+
+ // Using wxStringTokenizer from wxWidgets.
+
+ wxStringTokenizer certDataInc(wxString::FromUTF8(slist->data), ":");
+
+ // Get first token as the property name.
+
+ certPropName = certDataInc.GetNextToken().ToStdString();
+
+ // Get remaining tokens as the property value.
+
+ while(certDataInc.HasMoreTokens()){
+
+ certPropValue.append(certDataInc.GetNextToken());
+
+ }
+
+ sslCertDataInc.CertData.insert(std::make_pair(certPropName, certPropValue));
+ certPropName.clear();
+ certPropValue.clear();
+
+ }
+
+ sslCertInfo.SSLCollection.insert(std::make_pair(i, sslCertDataInc));
+
+ }
+
+ return sslCertInfo;
+
+}
+
+#endif
+
+bool CalDAV::CanDoSSL(){
+ return sslStatus;
+}
+
+bool CalDAV::HasValidResponse(){
+ return validResponse;
+}
+
+bool CalDAV::AbleToLogin(){
+ return authPassed;
+}
+
+bool CalDAV::IsSelfSigned(){
+ return sslSelfSigned;
+}
+
+string CalDAV::GetErrorMessage(){
+
+ errorMessage = sessionErrorBuffer;
+ return errorMessage;
+
+}
+
+static bool CalDAVObjectValidSettings(CalDAVConnectionData *connData){
// Check if the passed CalDAV Connection Data is has
// an address set. Return false if nullptr is used.
}
-string BuildServerAddress(CalDAVConnectionData *connData, string uriAddress){
+string CalDAV::BuildServerAddress(CalDAVConnectionData *connData, string uriAddress){
string serverAddress;
return serverAddress;
+}
+
+void CalDAV::SetupDefaultParametersNonSSL(bool doAuthentication){
+
+ std::string serverAddress = "";
+
+ string serverAddressURL = "http://" + connectionData.hostname + ":" + to_string(connectionData.port) + "/";
+ string usernamePassword = connectionData.username + ":" + connectionData.password;
+
+ curl_easy_setopt(connectionHandle, CURLOPT_URL, serverAddressURL.c_str());
+ curl_easy_setopt(connectionHandle, CURLOPT_NOPROGRESS, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC);
+ curl_easy_setopt(connectionHandle, CURLOPT_TIMEOUT, 60);
+ curl_easy_setopt(connectionHandle, CURLOPT_FAILONERROR, true);
+ curl_easy_setopt(connectionHandle, CURLOPT_USERAGENT, XSDCAL_USERAGENT);
+ curl_easy_setopt(connectionHandle, CURLOPT_NOSIGNAL, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "GET");
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, nullptr);
+ curl_easy_setopt(connectionHandle, CURLOPT_POSTFIELDS, nullptr);
+ curl_easy_setopt(connectionHandle, CURLOPT_POSTFIELDSIZE, 0L);
+
+ if (doAuthentication == true){
+ curl_easy_setopt(connectionHandle, CURLOPT_USERPWD, usernamePassword.c_str());
+ } else {
+ curl_easy_setopt(connectionHandle, CURLOPT_USERPWD, NULL);
+ }
+
+}
+
+void CalDAV::SetupDefaultParametersSSL(bool doAuthentication){
+
+ // Setup the default parameters.
+
+ string ServerAddressURL = "https://" + connectionData.hostname + ":" + to_string(connectionData.port) + "/";
+ string UsernamePassword = connectionData.username + ":" + connectionData.password;
+
+ curl_easy_setopt(connectionHandle, CURLOPT_URL, ServerAddressURL.c_str());
+ curl_easy_setopt(connectionHandle, CURLOPT_NOPROGRESS, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_CERTINFO, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC);
+ curl_easy_setopt(connectionHandle, CURLOPT_TIMEOUT, 60);
+ curl_easy_setopt(connectionHandle, CURLOPT_FAILONERROR, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_USERAGENT, XSDCAL_USERAGENT);
+ curl_easy_setopt(connectionHandle, CURLOPT_ERRORBUFFER, sessionErrorBuffer);
+ curl_easy_setopt(connectionHandle, CURLOPT_CUSTOMREQUEST, "GET");
+ curl_easy_setopt(connectionHandle, CURLOPT_HTTPHEADER, nullptr);
+ curl_easy_setopt(connectionHandle, CURLOPT_POSTFIELDS, nullptr);
+ curl_easy_setopt(connectionHandle, CURLOPT_POSTFIELDSIZE, 0L);
+
+ if (doAuthentication == true){
+ curl_easy_setopt(connectionHandle, CURLOPT_USERPWD, UsernamePassword.c_str());
+ } else {
+ curl_easy_setopt(connectionHandle, CURLOPT_USERPWD, NULL);
+ }
+
+ if (enableSSLBypass == true){
+ curl_easy_setopt(connectionHandle, CURLOPT_SSL_VERIFYHOST, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_SSL_VERIFYPEER, 0L);
+ curl_easy_setopt(connectionHandle, CURLOPT_SSL_VERIFYSTATUS, 0L);
+ } else {
+ curl_easy_setopt(connectionHandle, CURLOPT_SSL_VERIFYHOST, 2L);
+ curl_easy_setopt(connectionHandle, CURLOPT_SSL_VERIFYPEER, 1L);
+ curl_easy_setopt(connectionHandle, CURLOPT_SSL_VERIFYSTATUS, 1L);
+ }
+
+#if !defined(__APPLE__) || defined(__WIN32__)
+
+ if (connectionData.account.size() > 0){
+
+ // Check if the server certificate file exists.
+
+ string certificateFilename = GetAccountDir(connectionData.account, true);
+
+ if (wxFile::Exists(certificateFilename)){
+
+ curl_easy_setopt(connectionHandle, CURLOPT_CAINFO, certificateFilename.c_str());
+
+ }
+
+ }
+
+#endif
+
+}
+
+void CalDAV::ResetResults(){
+
+ sslStatus = false;
+ COSSLVerified SSLVerified = COSSL_NORESULT;
+ validResponse = false;
+ authPassed = false;
+ sslSelfSigned = false;
+ //taskCompleted = false;
+ errorMessage = "";
+ sessionErrorBuffer[0] = '\0';
+ //sessionResult = CURLE_OK;
+ serverData = "";
+ serverHeader = "";
+ /*if (headerList != nullptr){
+ curl_slist_free_all(headerList);
+ headerList = nullptr;
+ }*/
+
}
\ No newline at end of file