From ee7305a77c32ef3c9a0217b19431efe215795e7d Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Thu, 12 May 2016 22:26:26 +0100 Subject: [PATCH] Win32 Support: Support for adding a new account on Windows. --- source/frmNewAccount.cpp | 50 +++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/source/frmNewAccount.cpp b/source/frmNewAccount.cpp index bff53e1..8768196 100644 --- a/source/frmNewAccount.cpp +++ b/source/frmNewAccount.cpp @@ -22,9 +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 ) @@ -180,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){ @@ -238,7 +249,26 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) } } - + +#elif defined(__WIN32__) + + 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); @@ -292,7 +322,7 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) ConnTest.join(); - if (ServerResult == FALSE){ + if (ServerResult == FALSE && ModifiedCertificateData == FALSE){ lblServerConnResult->SetLabel(_("Failed")); lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + CardDAVConn.GetErrorMessage()); @@ -303,11 +333,11 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) lblServerConnResult->SetLabel(_("Connected")); } - + if (CardDAVConn.CanDoSSL() == TRUE){ - + lblServerSSLResult->SetLabel(_("Used")); - + } else { lblServerSSLResult->SetLabel(_("Not Used")); @@ -331,7 +361,15 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event ) 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){ -- 2.39.5