Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Version 0.10 release
[xestiaab/.git] / source / frmEditAccount.cpp
index 6a718e7..5313dcd 100644 (file)
@@ -1,4 +1,23 @@
+// frmEditAccount.cpp - Edit Account form.
+//
+// (c) 2012-2015 Xestia Software Development.
+//
+// This file is part of Xestia Address Book.
+//
+// Xestia Address Book is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Address Book is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
+
 #include "frmEditAccount.h"
+#include "frmInvalidSSLCertificate.h"
 #include "carddav/carddav.h"
 
 frmEditAccount::frmEditAccount( wxWindow* parent )
@@ -65,6 +84,68 @@ void frmEditAccount::DetectAddressBook( wxCommandEvent& event )
        
        CDavObj.SetupConnection(txtAddress->GetValue(), (int)PortNum, txtUsername->GetValue(), txtPassword->GetValue(), UseSSL);
        
+       // Verify SSL trust first before doing anything.
+
+       if (UseSSL == TRUE){
+
+               CURLcode sslcode = CDavObj.SSLVerifyTest();
+
+               if (sslcode == CURLE_OK){
+                               
+
+
+               } else if (sslcode == CURLE_SSL_CACERT || sslcode == CURLE_SSL_CONNECT_ERROR){
+
+                       // Certificate is more than likely a self-signed or
+                       // expired certificate so display the invalid
+                       // SSL certificate message.
+
+                       // Setup the data to be sent in the wxPostEvent command.
+
+                       int SSLResult;
+                       
+                       frmInvalidSSLCertificate *frmICPtr = new frmInvalidSSLCertificate(this);
+
+                       frmICPtr->LoadDataNew(CDavObj.GetSSLVerifyResults(), txtAddress->GetValue());
+                       frmICPtr->ShowModal();
+                                       
+                       SSLResult = frmICPtr->GetResult();
+                                                       
+                       // Clean up before processing response.
+                               
+                       delete frmICPtr;
+                       frmICPtr = NULL;
+                                               
+                       // Process the response from the user.
+                                                       
+                       if (SSLResult == 1){
+                                                               
+                               // Accept the Certificate.
+
+                               CDavObj.AllowSelfSignTest(TRUE);
+                                                               
+                       } else if (SSLResult == 2){
+                                                               
+                               // Reject the certificate, abort the task and mark as failed.
+
+                               wxMessageBox(_("An error occured whilst connnecting: ") + CDavObj.GetErrorMessage() + wxString::Format(wxT(" (%i)\n%s"), sslcode, CDavObj.GetErrorBuffer().mb_str()), _("Failed"), wxOK+wxICON_ERROR);
+                               return;
+                                                               
+                       }
+                               
+
+               } else {
+
+                       // Something else happened. Stop the process and
+                       // display an error message instead.
+
+                       wxMessageBox(_("An error occured whilst connnecting: ") + CDavObj.GetErrorMessage() + wxString::Format(wxT(" (%i)\n%s"), sslcode, CDavObj.GetErrorBuffer().mb_str()), _("Failed"), wxOK+wxICON_ERROR);
+                       return;
+
+               }
+
+       }
+       
        // Attempt to extract the CardDAV address.
        
        wxString ABURL = CDavObj.GetDefaultAddressBookURL();
@@ -220,12 +301,20 @@ void frmEditAccount::UpdateSettings( wxCommandEvent& event )
                ContinueAcc = cfgfile->GetNextGroup(AccountName, itemindex);
 
        }
-       
+
+       DialogResult = true;    
        this->Close();  
 
 }
 
 void frmEditAccount::CloseWindow( wxCommandEvent& event )
 {
+       DialogResult = false;
        this->Close();
 }
+
+bool frmEditAccount::GetDialogResult(){
+       
+       return DialogResult;
+       
+}
\ No newline at end of file
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy