X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2FfrmNewAccount.cpp;h=87681963e58b89ea3b0bc305d68177cd32a5be75;hb=5adbbedaa38b2853d751f2e4dbf43521296447f6;hp=1e23c214cbcfb5792c37171a72b6cfaffc32ad0c;hpb=cbaeace3c348a70ab67429ab995f5702b1b38aa7;p=xestiaab%2F.git diff --git a/source/frmNewAccount.cpp b/source/frmNewAccount.cpp index 1e23c21..8768196 100644 --- a/source/frmNewAccount.cpp +++ b/source/frmNewAccount.cpp @@ -22,8 +22,14 @@ #include #include +#if defined(__WIN32__) +#include +#endif + #include "carddav/carddav.h" #include "common/dirs.h" +#include "common/svrblist.h" +#include "common/win32ssl.h" #include "frmInvalidSSLCertificate.h" frmNewAccount::frmNewAccount( wxWindow* parent ) @@ -127,6 +133,20 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) } + // Check if server address matches against the blacklist. + // Bring up warning message if it does. + + if (CheckBlacklist(txtServerAddress->GetValue())){ + + int MessageBoxResult = wxMessageBox(_("The server with the address given does not support the CardDAV protocol properly and shouldn't be used.\n\nData loss is very likely.\n\nDo you still want to continue using this server?"), _("Server warning"), wxYES_NO, this); + + if (MessageBoxResult == wxNO){ + PageSeek--; + return; + } + + } + btnNext->Disable(); bool ServerResult = FALSE; @@ -165,6 +185,12 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) UseSSL); CardDAVConn.SetupResultBools(&ServerResult, &ServerAction); +#if defined(__WIN32__) + + BOOL ModifiedCertificateData = FALSE; + +#endif + // Verify SSL trust first before doing anything. if (UseSSL == TRUE){ @@ -182,37 +208,74 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) // SSL certificate message. // Setup the data to be sent in the wxPostEvent command. + + int SSLResult; + +#if defined(__APPLE__) + + SSLResult = DisplayTrustPanel(&CardDAVConn); - //SSLInvalidCertNotifObj SSLICNProcData; + if (SSLResult != NSOKButton){ + + lblServerConnResult->SetLabel(_("Failed")); + lblServerResponse->SetLabel(_("Not applicable")); + lblServerSSLResult->SetLabel(_("Used")); + lblServerSSLValid->SetLabel(_("No")); + lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + CardDAVConn.GetErrorMessage() + wxString::Format(wxT(" (%i)\n%s"), sslcode, CardDAVConn.GetErrorBuffer().mb_str())); + return; + + } else { + + // Evalulate the trust object. + + SecTrustResultType EvalResult = ProcessResultType(&CardDAVConn); + + switch(EvalResult){ + case kSecTrustResultProceed: + lblServerSSLValid->SetLabel(_("Verified")); + break; + case kSecTrustResultConfirm: + lblServerSSLValid->SetLabel(_("Verified (user)")); + break; + default: + lblServerSSLValid->SetLabel(_("Unable to verify")); + } + + lblServerResponse->SetLabel(_("Not applicable")); + lblServerSSLResult->SetLabel(_("Used")); + + if (EvalResult != kSecTrustResultProceed){ + return; + } + + } - //bool *PauseMode = new bool; - int SSLResult; - //QRNotif qrn; +#elif defined(__WIN32__) - //*PauseMode = TRUE; - //qrn.QResponse = &SSLResult; - //qrn.PausePtr = PauseMode; - - //SSLICNProcData.CertCollection = CardDAVConn.GetSSLVerifyResults(); - //SSLICNProcData.QRNotifData = &qrn; - //SSLICNProcData.AccountName = _("New account"); + CRYPTUI_VIEWCERTIFICATE_STRUCTW CertificateData = BuildCertificateData(&CardDAVConn, (HWND)this->GetHandle()); + + if (!CryptUIDlgViewCertificate(&CertificateData, &ModifiedCertificateData)){ + wxMessageBox(_("An error occured while trying to open the certificate dialog."), _("Error opening Certificate Information dialog")); + } + + if (ModifiedCertificateData == FALSE){ + + lblServerConnResult->SetLabel(_("Failed")); + lblServerResponse->SetLabel(_("Not applicable")); + lblServerSSLResult->SetLabel(_("Used")); + lblServerSSLValid->SetLabel(_("No")); + lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + CardDAVConn.GetErrorMessage() + wxString::Format(wxT(" (%i)\n%s"), sslcode, CardDAVConn.GetErrorBuffer().mb_str())); + return; + + } + +#else frmInvalidSSLCertificate *frmICPtr = new frmInvalidSSLCertificate(this); frmICPtr->LoadDataNew(CardDAVConn.GetSSLVerifyResults(), txtServerAddress->GetValue()); frmICPtr->ShowModal(); - - //wxCommandEvent event(INVALIDSSLCERT); - //event.SetClientData(&SSLICNProcData); - //wxPostEvent(this->GetParent(), event); - - /*timespec n1, n2; - - // Fall asleep until we get an response. - - n1.tv_sec = 0; - n1.tv_nsec = 250000000L;*/ - + SSLResult = frmICPtr->GetResult(); // Clean up before processing response. @@ -237,18 +300,16 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) return; } - - //frmInvalidSSLCertificate *frmICPtr = new frmInvalidSSLCertificate(this); - - //frmICPtr->LoadDataNew(CardDAVConn.GetSSLVerifyResults(), txtServerAddress->GetValue()); - //frmICPtr->ShowModal(); +#endif } else { // Something else happened. Stop the process and // display an error message instead. + CURLcode sslcode = CardDAVConn.SSLVerifyTest(); + lblServerConnResult->SetLabel(_("Failed")); lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + CardDAVConn.GetErrorMessage() + wxString::Format(wxT(" (%i)\n%s"), sslcode, CardDAVConn.GetErrorBuffer().mb_str())); return; @@ -261,59 +322,93 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) ConnTest.join(); - if (ServerResult == FALSE){ - - lblServerConnResult->SetLabel(_("Failed")); - return; + if (ServerResult == FALSE && ModifiedCertificateData == FALSE){ + lblServerConnResult->SetLabel(_("Failed")); + lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + CardDAVConn.GetErrorMessage()); + return; + } else { - lblServerConnResult->SetLabel(_("Connected")); + lblServerConnResult->SetLabel(_("Connected")); } - + if (CardDAVConn.CanDoSSL() == TRUE){ - - lblServerSSLResult->SetLabel(_("Used")); - + + lblServerSSLResult->SetLabel(_("Used")); + } else { - lblServerSSLResult->SetLabel(_("Not Used")); - lblServerSSLValid->SetLabel(_("Not Applicable")); + lblServerSSLResult->SetLabel(_("Not Used")); + lblServerSSLValid->SetLabel(_("Not Applicable")); } - + +#if defined(__APPLE__) + + // Evalulate the trust object. + + SecTrustResultType EvalResult = ProcessResultType(&CardDAVConn); + + switch(EvalResult){ + case kSecTrustResultProceed: + lblServerSSLValid->SetLabel(_("Verified")); + break; + case kSecTrustResultConfirm: + lblServerSSLValid->SetLabel(_("Verified (user)")); + break; + default: + lblServerSSLValid->SetLabel(_("Unable to verify")); + } + +#elif defined(__WIN32__) + + if (ModifiedCertificateData == TRUE){ + lblServerSSLValid->SetLabel(_("Verified (user)")); + } else { + lblServerSSLValid->SetLabel(_("Verified")); + } + +#else + if (CardDAVConn.SSLVerify() == TRUE && CardDAVConn.CanDoSSL() == TRUE){ - lblServerSSLValid->SetLabel(_("Verified")); + lblServerSSLValid->SetLabel(_("Verified")); } else if (CardDAVConn.SSLVerify() == FALSE && CardDAVConn.CanDoSSL() == TRUE && CardDAVConn.IsSelfSigned() == TRUE){ - lblServerSSLValid->SetLabel(_("Verified (user)")); + lblServerSSLValid->SetLabel(_("Verified (user)")); } else if (CardDAVConn.SSLVerify() == FALSE && CardDAVConn.CanDoSSL() == TRUE) { - lblServerSSLValid->SetLabel(_("Unable to verify")); + lblServerSSLValid->SetLabel(_("Unable to verify")); - } - + } + +#endif + if (CardDAVConn.CanDoCardDAV() == TRUE){ - lblCardDAVSupportResult->SetLabel(_("Supported")); + lblCardDAVSupportResult->SetLabel(_("Supported")); } else { - lblCardDAVSupportResult->SetLabel(_("Unsupported")); + lblCardDAVSupportResult->SetLabel(_("Unsupported")); + SetErrorMessageLabel(); + return; } if (CardDAVConn.AbleToLogin() == TRUE){ - lblAbleToLoginResult->SetLabel(_("Yes")); + lblAbleToLoginResult->SetLabel(_("Yes")); } else { - lblAbleToLoginResult->SetLabel(_("No")); + lblAbleToLoginResult->SetLabel(_("No")); + SetErrorMessageLabel(); + return; } @@ -323,25 +418,27 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) if (CardDAVConn.HasValidResponse() == TRUE){ - lblServerResponse->SetLabel(_("Yes")); + lblServerResponse->SetLabel(_("Yes")); } else { - lblServerResponse->SetLabel(_("No")); + lblServerResponse->SetLabel(_("No")); + SetErrorMessageLabel(); + return; } if (ServerResult == TRUE && CardDAVConn.HasValidResponse() == TRUE && - //CardDAVConn.CanDoSSL() == TRUE && CardDAVConn.SSLVerify() == TRUE && - CardDAVConn.CanDoCardDAV() == TRUE && CardDAVConn.AbleToLogin() == TRUE){ + + CardDAVConn.CanDoCardDAV() == TRUE && CardDAVConn.AbleToLogin() == TRUE){ - btnNext->Enable(); + btnNext->Enable(); - lblConnectionResultText->SetLabel(_("Click on Next to set the account name.")); + lblConnectionResultText->SetLabel(_("Click on Next to set the account name.")); } else { - lblConnectionResultText->SetLabel(_("A problem has occured whilst connecting to the CardDAV server.\nPlease review the above information and change the server details if needed.\nIf there are still problems, please speak to your system administrator(s).")); + SetErrorMessageLabel(); } @@ -359,11 +456,11 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) if (txtAccountName->IsEmpty() && PageSeek == 2){ - btnNext->Disable(); + btnNext->Disable(); } else { - btnNext->Enable(); + btnNext->Enable(); } @@ -602,7 +699,7 @@ void frmNewAccount::CloseWindow( wxCommandEvent& event ) void frmNewAccount::UpdateRequirements( wxCommandEvent& event ) { - // Update the options. + // Update the options. if (cmbServerType->GetCurrentSelection() == 1){ @@ -630,4 +727,10 @@ void frmNewAccount::SetupPointers(bool *ReloadAccountInc){ ReloadAccountConfig = ReloadAccountInc; +} + +void frmNewAccount::SetErrorMessageLabel(){ + + lblConnectionResultText->SetLabel(_("A problem has occured whilst connecting to the CardDAV server.\nPlease review the above information and change the server details if needed.\nIf there are still problems, please speak to your system administrator(s).")); + } \ No newline at end of file