From b1467ce3cde3c61f79030bf4329f7037904043e1 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Sun, 21 Aug 2016 22:56:17 +0100 Subject: [PATCH] Added AddContact for CardDAV2 and frmActivityMgr --- source/actmgr/frmActivityMgr-tasks.cpp | 4 + source/actmgr/frmActivityMgr.cpp | 179 ++++++++++++++++++++-- source/actmgr/frmActivityMgr.h | 4 + source/carddav2/carddav2.cpp | 200 +++++++++++++++++++++++-- source/carddav2/carddav2.h | 4 + source/connobject/ConnectionObject.h | 10 ++ source/frmInvalidSSLCertificate.cpp | 21 +++ source/frmInvalidSSLCertificate.h | 7 + source/frmMain.cpp | 27 ++++ source/frmMain.h | 2 + source/frmNewAccount-CardDAV2.cpp | 4 +- 11 files changed, 438 insertions(+), 24 deletions(-) diff --git a/source/actmgr/frmActivityMgr-tasks.cpp b/source/actmgr/frmActivityMgr-tasks.cpp index cdcdfc7..f9046ea 100644 --- a/source/actmgr/frmActivityMgr-tasks.cpp +++ b/source/actmgr/frmActivityMgr-tasks.cpp @@ -117,11 +117,15 @@ int frmActivityMgr::AddTask(int TaskType, wxString TaskDetail, wxString TaskAcco ETagDB *ETagDBPtr = ETagTmrPtr->GetPointer(AccountDir); + CardDAV2 *ConnObject = new CardDAV2(AccountAddress.ToStdString(), AccountPort, AccountUsername.ToStdString(), AccountPassword.ToStdString(), AccountSSL, AccountPrefix.ToStdString(), AccountDir.ToStdString()); + ConnObject->SetupConnectionObject(); + ActivityListType.insert(std::make_pair(ActivityTaskID, 0)); ActivityListData.insert(std::make_pair(ActivityTaskID, TaskData)); ActivityListURL.insert(std::make_pair(ActivityTaskID, TaskURL)); ActivityListEditMode.insert(std::make_pair(ActivityTaskID, false)); ActivityListConn.insert(std::make_pair(ActivityTaskID, CardDAVConn)); + ActivityListConnObject.insert(std::make_pair(ActivityTaskID, ConnObject)); ActivityListIndex.insert(std::make_pair(ActivityTaskID, itemindex)); ActivityListTaskDetail.insert(std::make_pair(ActivityTaskID, TaskDetail)); ActivityListAccount.insert(std::make_pair(ActivityTaskID, TaskAccount)); diff --git a/source/actmgr/frmActivityMgr.cpp b/source/actmgr/frmActivityMgr.cpp index 63755f8..1b63314 100644 --- a/source/actmgr/frmActivityMgr.cpp +++ b/source/actmgr/frmActivityMgr.cpp @@ -214,6 +214,7 @@ void frmActivityMgr::ProcessTasksThread() std::map::iterator StringETagIter; std::map::iterator StringETagOrigIter; std::map::iterator CardDAVIter; + std::map::iterator ConnObjectIter; std::map::iterator AccountSettingsIter; std::map::iterator LongIter; bool TasksFoundProc = FALSE; @@ -235,6 +236,7 @@ void frmActivityMgr::ProcessTasksThread() // Start the animation timer if it hasn't started. CardDAVIter = ActivityListConn.find(iter->first); + ConnObjectIter = ActivityListConnObject.find(iter->first); TypeIter = ActivityListType.find(iter->first); StringETagIter = ActivityListETag.find(iter->first); StringETagOrigIter = ActivityListETagOriginal.find(iter->first); @@ -329,13 +331,148 @@ void frmActivityMgr::ProcessTasksThread() FullFilename = StringFullFilenameIter->second; EditMode = ActivityListEditMode.find(iter->first)->second; - bool KeepUpdating = TRUE; + bool KeepUpdating = true; - while(KeepUpdating == TRUE){ + while(KeepUpdating == true){ - bool ExitLoop = FALSE; + COConnectResult ConnectResponse = ConnObjectIter->second->Connect(false); - while (ExitLoop == FALSE){ + bool ExitLoop = false; + + while (ExitLoop == false){ + + if (ConnObjectIter->second->SSLVerify() == COSSL_UNABLETOVERIFY){ + + frmMainPtrGet->PauseAllTimers(); + +#if defined(__APPLE__) +#elif defined(__WIN32__) +#else + + bool UsingSSLBypass = false; + int SSLResult = 0; + + // Connect again and fetch SSL certificate information. + + ConnObjectIter->second->BypassSSLVerification(true); + + COConnectResult ConnectionSSLResult = ConnObjectIter->second->Connect(false); + + ConnObjectIter->second->BypassSSLVerification(false); + + SSLInvalidCertNotifObjString SSLICNProcData; + + SSLCertCollectionString certcol = ConnObjectIter->second->BuildSSLCollection(); + + bool *PauseMode = new bool; + QRNotif qrn; + + *PauseMode = TRUE; + qrn.QResponse = &SSLResult; + qrn.PausePtr = PauseMode; + + SSLICNProcData.CertCollection = certcol; + SSLICNProcData.QRNotifData = &qrn; + SSLICNProcData.AccountName = AccountNameFriendly; + + wxCommandEvent event(INVALIDSSLCERTSTRING); + event.SetClientData(&SSLICNProcData); + wxPostEvent(frmMainPtrGet, event); + + while (*PauseMode == TRUE){ + //nanosleep(&n1, &n2); + SleepFor(250000000); + } + + // Process the response from the user. + + if (SSLResult == 1){ + + // Accept the Certificate. + + UsingSSLBypass = true; + ConnObjectIter->second->BypassSSLVerification(true); + + COConnectResult TestConnectionResult = ConnObjectIter->second->Connect(true); + WriteServerCertificate(AccountDir, certcol); + + ConnObjectIter->second->BypassSSLVerification(false); + + } else if (SSLResult == 2){ + + // Reject the certificate, abort the task and mark as failed. + + iter->second = 2; + break; + + } + +#endif + + frmMainPtrGet->ResumeAllTimers(); + ExitLoop = true; + + } else if (ConnectResponse == COCONNECT_AUTHFAIL){ + + ConnectResponse = ConnObjectIter->second->Connect(true); + + if (ConnectResponse == COCONNECT_OK){ + + ExitLoop = true; + break; + + } else { + + ExitLoop = true; + iter->second = 2; + break; + + } + + } else if (ConnectResponse == COCONNECT_OK){ + + ConnectResponse = ConnObjectIter->second->Connect(true); + + ExitLoop = true; + break; + + } else { + + ExitLoop = true; + iter->second = 2; + break; + + } + + } + + if (iter->second == 2 || iter->second == 3 || iter->second == 4){ + break; + } + +#if defined(__APPLE__) + + frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetTrustObject()); + +#elif defined(__WIN32__) + + frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateContextPointer()); + +#else + + frmMainPtrGet->UpdateSSLAccountStatus(AccountID, 0, ConnHandle.GetCertificateData()); + +#endif + + COServerResponse AddContactResponse = ConnObjectIter->second->AddContact(StringURLIter->second.ToStdString(), + StringDataIter->second.ToStdString()); + + if (AddContactResponse.RequestResult != COREQUEST_OK){ + iter->second = 2; + break; + } + + /*while (ExitLoop == FALSE){ // Verify that we have a trusted SSL connection first. @@ -421,13 +558,6 @@ void frmActivityMgr::ProcessTasksThread() event.SetClientData(&SSLICNProcData); wxPostEvent(frmMainPtrGet, event); - /*timespec n1, n2; - - // Fall asleep until we get an response. - - n1.tv_sec = 0; - n1.tv_nsec = 250000000L;*/ - while (*PauseMode == TRUE){ //nanosleep(&n1, &n2); SleepFor(250000000); @@ -510,7 +640,12 @@ void frmActivityMgr::ProcessTasksThread() // Add contact to the ETag DB. ConnHandle.GetServerETagValueThread(); - ETagServer = ConnHandle.ETagValueResult(); + ETagServer = ConnHandle.ETagValueResult();*/ + + // TODO: Get the entity tag for the new contact. + + + ETagDBPtr->AddETag(ContactFilename, ETagServer, ETagServer); iter->second = 4; @@ -2216,6 +2351,26 @@ void frmActivityMgr::WriteServerCertificate(wxString AccountName, SSLCertCollect } +void frmActivityMgr::WriteServerCertificate(wxString AccountName, SSLCertCollectionString SSLCertInc){ + + wxString ServerCertFinal; + + // Get the Cert section of the certificate and write it to the file. + + ServerCertFinal = GetAccountDir(AccountName, TRUE); + + wxFile CertFile; + + std::map::iterator SSLCDIter = SSLCertInc.SSLCollection.find(0); + std::multimap::iterator SSLDataIter = SSLCDIter->second.CertData.find("Cert"); + + CertFile.Open(ServerCertFinal, wxFile::write); + + CertFile.Write(SSLDataIter->second, wxConvUTF8); + CertFile.Close(); + +} + void frmActivityMgr::StartTimer(wxCommandEvent& event){ ActListProcTimer.Start(1000, FALSE); diff --git a/source/actmgr/frmActivityMgr.h b/source/actmgr/frmActivityMgr.h index d6dc31a..861a726 100644 --- a/source/actmgr/frmActivityMgr.h +++ b/source/actmgr/frmActivityMgr.h @@ -39,6 +39,8 @@ Subclass of frmActivityMgrADT, which is generated by wxFormBuilder. #include "../common/dirs.h" #include "../common/preferences.h" #include "../common/sslcertstructs.h" +#include "../connobject/ConnectionObject.h" +#include "../carddav2/carddav2.h" #if defined(__WIN32__) #include "../common/win32ssl.h" @@ -108,6 +110,7 @@ class frmActivityMgr : public frmActivityMgrADT std::map ActivityListFilename; std::map ActivityListFullFilename; std::map ActivityListConn; + std::map ActivityListConnObject; std::map ActivityListAccSettings; std::map ActivityListETag; std::map ActivityListETagOriginal; @@ -142,6 +145,7 @@ class frmActivityMgr : public frmActivityMgrADT void ToggleConnectionStatus( wxCommandEvent& event ); void SleepMode( wxCommandEvent &event ); void WriteServerCertificate(wxString AccountName, SSLCertCollection SSLCertInc); + void WriteServerCertificate(wxString AccountName, SSLCertCollectionString SSLCertInc); void UpdateStatusLabel( wxCommandEvent& event ); public: /** Constructor */ diff --git a/source/carddav2/carddav2.cpp b/source/carddav2/carddav2.cpp index f5bc2a3..494468c 100644 --- a/source/carddav2/carddav2.cpp +++ b/source/carddav2/carddav2.cpp @@ -77,8 +77,15 @@ size_t CardDAV2::WritebackFuncImplementation(char *ptr, size_t size, size_t nmem } CardDAV2::~CardDAV2(){ + curl_easy_cleanup(ConnectionSession); ConnectionSession = nullptr; + + if (HeaderList != nullptr){ + curl_slist_free_all(HeaderList); + HeaderList = nullptr; + } + } #if defined(__APPLE__) @@ -172,11 +179,12 @@ COConnectResult CardDAV2::Connect(bool DoAuthentication){ if (TestMode == true){ SessionResult = curl_easy_perform(ConnectionSession); } else { - + SessionResult = curl_easy_perform(ConnectionSession); } switch(SessionResult){ case CURLE_OK: + case CURLE_HTTP_RETURNED_ERROR: SSLStatus = true; SSLVerified = COSSL_VERIFIED; ConnectResult = COCONNECT_OK; @@ -209,7 +217,7 @@ COConnectResult CardDAV2::Connect(bool DoAuthentication){ ConnectResult = COCONNECT_OK; AuthPassed = true; ValidResponse = true; - } else if (SessionResponseCode == 403){ + } else if (SessionResponseCode == 401){ ConnectResult = COCONNECT_AUTHFAIL; AuthPassed = false; ValidResponse = true; @@ -336,7 +344,7 @@ COServerResponse CardDAV2::GetDefaultPrefix(string *ServerPrefix){ } else if (SessionResponseCode == 403){ AuthPassed = false; ValidResponse = true; - } else if (SessionResponseCode >= 200) { + } else if (SessionResponseCode >= 400) { AuthPassed = false; ValidResponse = true; } else { @@ -393,19 +401,15 @@ COServerResponse CardDAV2::GetDefaultPrefix(string *ServerPrefix){ curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode); if (SessionResponseCode == 200 || SessionResponseCode == 207){ - //ConnectResult = COCONNECT_OK; AuthPassed = true; ValidResponse = true; } else if (SessionResponseCode == 403){ - //ConnectResult = COCONNECT_AUTHFAIL; AuthPassed = false; ValidResponse = true; - } else if (SessionResponseCode >= 200) { - //ConnectResult = COCONNECT_INVALID; + } else if (SessionResponseCode >= 400) { AuthPassed = false; ValidResponse = true; } else { - //ConnectResult = COCONNECT_INVALID; AuthPassed = false; ValidResponse = false; } @@ -741,6 +745,88 @@ std::string CardDAV2::GetDefaultAddressBookURI(){ COServerResponse CardDAV2::AddContact(std::string Location, std::string Data){ + // Check if authentication was successful, otherwise don't do anything. + + COServerResponse ServerResponse; + + if (AuthPassed == false){ + ServerResponse.RequestResult = COREQUEST_ERROR_NOTCONNECTED; + ServerResponse.EntityTag = ""; + ServerResponse.SessionCode = 0; + ServerResponse.ResultCode = 0; + ServerResponse.ResultMessage = ""; + return ServerResponse; + } + + ServerSSL ? SetupDefaultParametersSSL(true) : SetupDefaultParametersNonSSL(true); + ResetResults(); + + string ServerAddressURL = BuildURL(ServerPrefix + Location); + curl_easy_setopt(ConnectionSession, CURLOPT_URL, ServerAddressURL.c_str()); + curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "PUT"); + curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDS, Data.c_str()); + curl_easy_setopt(ConnectionSession, CURLOPT_POSTFIELDSIZE, strlen(Data.c_str())); + + HeaderList = curl_slist_append(HeaderList, "Content-Type: text/vcard; charset=utf-8"); + + curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, HeaderList); + + if (TestMode == true){ + SessionResult = curl_easy_perform(ConnectionSession); + } else { + SessionResult = curl_easy_perform(ConnectionSession); + } + + switch(SessionResult){ + case CURLE_OK: + SSLStatus = true; + SSLVerified = COSSL_VERIFIED; + break; + case CURLE_SSL_CACERT: + case CURLE_SSL_CONNECT_ERROR: + SSLStatus = true; + SSLVerified = COSSL_UNABLETOVERIFY; + break; + default: + break; + }; + + long SessionResponseCode = 0; + + curl_easy_getinfo(ConnectionSession, CURLINFO_RESPONSE_CODE, &SessionResponseCode); + + if (SessionResponseCode == 200 || SessionResponseCode == 201 || SessionResponseCode == 204){ + AuthPassed = true; + ValidResponse = true; + } else if (SessionResponseCode == 403){ + AuthPassed = false; + ValidResponse = true; + } else if (SessionResponseCode >= 400){ + AuthPassed = false; + ValidResponse = true; + } else { + AuthPassed = false; + ValidResponse = false; + } + + if (ValidResponse == false && AuthPassed == false){ + ServerResponse.RequestResult = COREQUEST_ERROR_SERVER; + ServerResponse.EntityTag = ""; + ServerResponse.SessionCode = SessionResult; + ServerResponse.ResultCode = SessionResponseCode; + ServerResponse.ResultMessage = ""; + return ServerResponse; + } + + CanProcess = true; + + ServerResponse.RequestResult = COREQUEST_OK; + ServerResponse.EntityTag = ""; + ServerResponse.SessionCode = SessionResult; + ServerResponse.ResultCode = SessionResponseCode; + ServerResponse.ResultMessage = SessionErrorBuffer; + return ServerResponse; + } COServerResponse CardDAV2::EditContact(std::string Location, std::string Data){ @@ -805,6 +891,7 @@ void CardDAV2::SetupDefaultParametersNonSSL(bool DoAuthentication){ curl_easy_setopt(ConnectionSession, CURLOPT_WRITEHEADER, &PageHeader); curl_easy_setopt(ConnectionSession, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "GET"); + curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, nullptr); if (DoAuthentication == true){ curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, UsernamePassword.c_str()); @@ -835,6 +922,7 @@ void CardDAV2::SetupDefaultParametersSSL(bool DoAuthentication){ curl_easy_setopt(ConnectionSession, CURLOPT_CERTINFO, 1); curl_easy_setopt(ConnectionSession, CURLOPT_VERBOSE, 1); curl_easy_setopt(ConnectionSession, CURLOPT_CUSTOMREQUEST, "GET"); + curl_easy_setopt(ConnectionSession, CURLOPT_HTTPHEADER, nullptr); if (DoAuthentication == true){ curl_easy_setopt(ConnectionSession, CURLOPT_USERPWD, UsernamePassword.c_str()); @@ -850,6 +938,20 @@ void CardDAV2::SetupDefaultParametersSSL(bool DoAuthentication){ curl_easy_setopt(ConnectionSession, CURLOPT_SSL_VERIFYPEER, 1); } + if (TestMode == false && ServerAccount.size() > 0){ + + // Check if the server certificate file exists. + + string CertificateFilename = GetAccountDir(ServerAccount, true); + + if (wxFile::Exists(CertificateFilename)){ + + curl_easy_setopt(ConnectionSession, CURLOPT_CAINFO, CertificateFilename.c_str()); + + } + + } + } string CardDAV2::BuildURL(string URI){ @@ -886,18 +988,96 @@ void CardDAV2::ResetResults(){ SessionErrorBuffer[0] = '\0'; PageData = ""; PageHeader = ""; + if (HeaderList != nullptr){ + curl_slist_free_all(HeaderList); + HeaderList = nullptr; + } } -vector CardDAV2::GetDAVHeader(){ +string CardDAV2::GetETagHeader(){ // Go through each of the lines looking for the // 'DAV:' section. + string HeaderName; + string HeaderValue; + bool FastForward = false; + + for (int HeaderSeek = 0; HeaderSeek < PageHeader.size(); HeaderSeek++){ + + if (FastForward == true){ + + if (PageHeader[HeaderSeek] == '\n'){ + FastForward = false; + } + + continue; + + } + + try { + PageHeader.substr(HeaderSeek, 5) == "ETag:"; + } + + catch (const out_of_range &oor){ + break; + } + + if (PageHeader.substr(HeaderSeek, 5) == "ETag:"){ + + int CharacterSeek = 5; + + while ((HeaderSeek + CharacterSeek) < PageHeader.size()){ + + if (PageHeader.substr((HeaderSeek + CharacterSeek), 2) == "\r\n"){ + break; + } + + HeaderValue += PageHeader.substr((HeaderSeek + CharacterSeek), 1); + CharacterSeek++; + } + + break; + + } else { + + FastForward = true; + continue; + + } + + if (PageHeader[HeaderSeek] == '\n'){ + HeaderName = ""; + } + + //HeaderName += PageHeader.substr(HeaderSeek, 1); + + } + + // Check for quotation marks at the start and end and strip + // them out. + + if (HeaderValue.size() >= 2){ + + if (HeaderValue[0] == '"'){ + HeaderValue.erase((HeaderValue.size() - 1)); + HeaderValue.erase(0); + } + + } + + return HeaderValue; + +} + +vector CardDAV2::GetDAVHeader(){ + + // Go through each of the lines looking for the + // 'DAV:' section. string HeaderName; string HeaderValue; - bool DAVFound = false; bool FastForward = false; vector DAVHeaderList; diff --git a/source/carddav2/carddav2.h b/source/carddav2/carddav2.h index 0c41fdb..3828d07 100644 --- a/source/carddav2/carddav2.h +++ b/source/carddav2/carddav2.h @@ -22,9 +22,11 @@ #include "../connobject/ConnectionObject.h" #include "../version.h" #include "../common/sslcertstructs.h" +#include "../common/dirs.h" #include #include +#include #include #include @@ -81,6 +83,7 @@ class CardDAV2 : public ConnectionObject { CURL *ConnectionSession = nullptr; CURLcode SessionResult = CURLE_OK; + struct curl_slist *HeaderList = nullptr; void SetupDefaultParametersNonSSL(bool DoAuthentication); void SetupDefaultParametersSSL(bool DoAuthentication); @@ -95,6 +98,7 @@ class CardDAV2 : public ConnectionObject { std::string BuildURL(std::string URI); void ResetResults(); std::vector GetDAVHeader(); + std::string GetETagHeader(); std::string GetUserPrincipalURI(); std::string GetAddressBookHomeURI(); diff --git a/source/connobject/ConnectionObject.h b/source/connobject/ConnectionObject.h index 35e0b78..96aa615 100644 --- a/source/connobject/ConnectionObject.h +++ b/source/connobject/ConnectionObject.h @@ -22,6 +22,7 @@ #include #include #include +#include "../common/sslcertstructs.h" enum COConnectResult { COCONNECT_UNITTESTFAIL = -1, @@ -98,6 +99,15 @@ class ConnectionObject{ virtual bool HasValidResponse() {}; virtual bool IsSelfSigned() {}; virtual std::string GetErrorMessage() {}; + + // OS specific functions. + +#if defined(__APPLE__) +#elif defined(__WIN32__) +#else + SSLCertCollectionString BuildSSLCollection() {}; + +#endif protected: // Test Mode. diff --git a/source/frmInvalidSSLCertificate.cpp b/source/frmInvalidSSLCertificate.cpp index fb3a4e0..f3b4de1 100644 --- a/source/frmInvalidSSLCertificate.cpp +++ b/source/frmInvalidSSLCertificate.cpp @@ -82,6 +82,27 @@ void frmInvalidSSLCertificate::LoadData(SSLCertCollection CertDataInc, } +void frmInvalidSSLCertificate::LoadData(SSLCertCollectionString CertDataInc, + wxString AccountNameInc) +{ + + // Load the invalid SSL certificate dialog. + + AccountName = AccountNameInc; + CertDataString = CertDataInc; + + wxString SSLTextLabel; + + SSLTextLabel.Append(wxString::Format(_("An invalid SSL certificate was received from the server for the '%s' account.\n\n"), AccountName)); + SSLTextLabel.Append(_("Click on one of the following buttons:\n\n")); + SSLTextLabel.Append(_("- Accept to accept the SSL certificate for this session and future sessions until the certificate changes.\n")); + SSLTextLabel.Append(_("- Reject to not use this certificate and disconnect (you will be asked again on subsequent reconnections to the server).\n")); + SSLTextLabel.Append(_("- View Certificates to review the certificates that were received.")); + + lblSSLText->SetLabel(SSLTextLabel); + +} + void frmInvalidSSLCertificate::LoadDataNew(SSLCertCollection CertDataInc, wxString DomainNameInc) { diff --git a/source/frmInvalidSSLCertificate.h b/source/frmInvalidSSLCertificate.h index 6a47166..934cae7 100644 --- a/source/frmInvalidSSLCertificate.h +++ b/source/frmInvalidSSLCertificate.h @@ -36,6 +36,12 @@ struct SSLInvalidCertNotifObj{ wxString AccountName; }; +struct SSLInvalidCertNotifObjString{ + SSLCertCollectionString CertCollection; + QRNotif *QRNotifData; + wxString AccountName; +}; + /** Implementing frmInvalidSSLCertificateADT */ class frmInvalidSSLCertificate : public frmInvalidSSLCertificateADT { @@ -53,6 +59,7 @@ class frmInvalidSSLCertificate : public frmInvalidSSLCertificateADT /** Constructor */ frmInvalidSSLCertificate( wxWindow* parent ); void LoadData(SSLCertCollection CertDataInc, wxString AccountNameInc); + void LoadData(SSLCertCollectionString CertDataInc, wxString AccountNameInc); void LoadDataNew(SSLCertCollection CertDataInc, wxString DomainNameInc); void LoadDataNew(SSLCertCollectionString CertDataInc, std::string DomainNameInc); int GetResult(); diff --git a/source/frmMain.cpp b/source/frmMain.cpp index b8a80cf..3c785f2 100644 --- a/source/frmMain.cpp +++ b/source/frmMain.cpp @@ -85,6 +85,7 @@ DEFINE_EVENT_TYPE(WINDOW_EDIT); DEFINE_EVENT_TYPE(WINDOW_CLOSE); DEFINE_EVENT_TYPE(CONNSTAT_UPDATE); DEFINE_EVENT_TYPE(INVALIDSSLCERT); +DEFINE_EVENT_TYPE(INVALIDSSLCERTSTRING); DEFINE_EVENT_TYPE(GETSELECTEDLIST); DEFINE_EVENT_TYPE(SYNCACCOUNT); DEFINE_EVENT_TYPE(IMPORT_RESULTSSHOW); @@ -117,6 +118,7 @@ EVT_COMMAND(wxID_ANY, WINDOW_EDIT, frmMain::WindowEdit) EVT_COMMAND(wxID_ANY, WINDOW_CLOSE, frmMain::WindowDelete) EVT_COMMAND(wxID_ANY, CONNSTAT_UPDATE, frmMain::UpdateConnectionStatus) EVT_COMMAND(wxID_ANY, INVALIDSSLCERT, frmMain::InvalidSSLCertificate) +EVT_COMMAND(wxID_ANY, INVALIDSSLCERTSTRING, frmMain::InvalidSSLCertificateString) EVT_COMMAND(wxID_ANY, GETSELECTEDLIST, frmMain::GetSelectedList) EVT_COMMAND(wxID_ANY, SYNCACCOUNT, frmMain::SyncAccount) EVT_COMMAND(wxID_ANY, IMPORT_RESULTSSHOW, frmMain::ShowImportResults) @@ -2750,6 +2752,31 @@ void frmMain::InvalidSSLCertificate( wxCommandEvent &event ){ } +void frmMain::InvalidSSLCertificateString( wxCommandEvent &event ){ + + // Display the form for showing an invalid SSL certificate. + + frmInvalidSSLCertificate *frameISC = new frmInvalidSSLCertificate ( this ); + SSLInvalidCertNotifObjString *SSLICNObj = (SSLInvalidCertNotifObjString*)event.GetClientData(); + SSLCertCollectionString SSLCCData = SSLICNObj->CertCollection; + wxString AccountName = SSLICNObj->AccountName; + frameISC->LoadData(SSLCCData, AccountName); + frameISC->ShowModal(); + + int FinalConflictResult = frameISC->GetResult(); + + wxCommandEvent event2(ACTMGR_RESUMEPROC); + event2.SetClientData(SSLICNObj->QRNotifData); + event2.SetInt(FinalConflictResult); + + delete frameISC; + frameISC = NULL; + + frmActivityMgr *frameActMgr = static_cast(ActMgrPtr); + wxPostEvent(frameActMgr, event2); + +} + void frmMain::PauseAllTimers(){ // Pause all the account timers. diff --git a/source/frmMain.h b/source/frmMain.h index 8d3c58d..6d3e578 100644 --- a/source/frmMain.h +++ b/source/frmMain.h @@ -75,6 +75,7 @@ DECLARE_EVENT_TYPE(WINDOW_EDIT, wxID_ANY); DECLARE_EVENT_TYPE(WINDOW_CLOSE, wxID_ANY); DECLARE_EVENT_TYPE(CONNSTAT_UPDATE, wxID_ANY); DECLARE_EVENT_TYPE(INVALIDSSLCERT, wxID_ANY); +DECLARE_EVENT_TYPE(INVALIDSSLCERTSTRING, wxID_ANY); DECLARE_EVENT_TYPE(GETSELECTEDLIST, wxID_ANY); DECLARE_EVENT_TYPE(SYNCACCOUNT, wxID_ANY); DECLARE_EVENT_TYPE(IMPORT_RESULTSSHOW, wxID_ANY); @@ -254,6 +255,7 @@ class frmMain : public frmMainADT void UpdateConnectionStatus( wxCommandEvent& event ); void SetupSSLStatus( int AccountID ); void InvalidSSLCertificate( wxCommandEvent& event ); + void InvalidSSLCertificateString( wxCommandEvent& event ); void CheckUpdates( wxCommandEvent& event ); void OpenImportDialog( wxCommandEvent& event ); void OpenExportDialog( wxCommandEvent& event ); diff --git a/source/frmNewAccount-CardDAV2.cpp b/source/frmNewAccount-CardDAV2.cpp index f593238..d8bd4fb 100644 --- a/source/frmNewAccount-CardDAV2.cpp +++ b/source/frmNewAccount-CardDAV2.cpp @@ -107,9 +107,9 @@ void frmNewAccount::RunCardDAV2Test( wxCommandEvent& event ){ } std::string ReceivedServerPrefix; - COServerResponse PrefixRequestResult = TestConnection.GetDefaultPrefix(&ReceivedServerPrefix); - + ServerPrefix = ReceivedServerPrefix; + if (UsingSSLBypass == true){ TestConnection.BypassSSLVerification(true); } -- 2.39.2