Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added OS X support for frmNewAccount itself.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 11 Apr 2016 21:23:19 +0000 (22:23 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Mon, 11 Apr 2016 21:23:19 +0000 (22:23 +0100)
source/frmNewAccount.cpp
source/frmNewAccount.h

index 49d278e..9c0beff 100644 (file)
@@ -198,7 +198,50 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
 
                                // Setup the data to be sent in the wxPostEvent command.
 
+                               // TODO: Port to OS X.
+                               
                                int SSLResult;
+                               
+#if defined(__APPLE__)
+       
+                               SSLResult = DisplayTrustPanel(&CardDAVConn);
+
+                               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;
+                                       }
+                                       
+                               }
+                               
+#else
                        
                                frmInvalidSSLCertificate *frmICPtr = new frmInvalidSSLCertificate(this);
 
@@ -229,12 +272,16 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
                                        return;
                                                                
                                }
+                               
+#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;
@@ -250,8 +297,9 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
                if (ServerResult == FALSE){
             
                        lblServerConnResult->SetLabel(_("Failed"));
+                       lblConnectionResultText->SetLabel(_("An error occured whilst connnecting: ") + CardDAVConn.GetErrorMessage());
                        return;
-            
+                       
                } else {
             
                        lblServerConnResult->SetLabel(_("Connected"));
@@ -268,7 +316,26 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
                        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"));
+               }
+               
+#else
+               
                if (CardDAVConn.SSLVerify() == TRUE && CardDAVConn.CanDoSSL() == TRUE){
             
                        lblServerSSLValid->SetLabel(_("Verified"));
@@ -281,8 +348,10 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
             
                        lblServerSSLValid->SetLabel(_("Unable to verify"));
             
-               }       
-        
+               }
+               
+#endif
+               
                if (CardDAVConn.CanDoCardDAV() == TRUE){
             
                        lblCardDAVSupportResult->SetLabel(_("Supported"));
@@ -290,6 +359,8 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
                } else {
             
                        lblCardDAVSupportResult->SetLabel(_("Unsupported"));
+                       SetErrorMessageLabel();
+                       return;
             
                }
         
@@ -300,6 +371,8 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
                } else {
             
                        lblAbleToLoginResult->SetLabel(_("No"));
+                       SetErrorMessageLabel();
+                       return;
             
                }
         
@@ -314,6 +387,8 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
                } else {
             
                        lblServerResponse->SetLabel(_("No"));
+                       SetErrorMessageLabel();
+                       return;
             
                }
         
@@ -327,7 +402,7 @@ void frmNewAccount::ProcessNext( wxCommandEvent& event )
             
                } 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();
             
                }
         
@@ -616,4 +691,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
index c335dfa..d6f0853 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include "AppXestiaAddrBk.h"
+#include "carddav/carddav.h"
 #include <wx/fileconf.h>
 
 //// end generated include
@@ -40,6 +41,10 @@ protected:
        void CloseWindow( wxCommandEvent& event );
        void UpdateRequirements( wxCommandEvent& event );
        void WriteAccountDetails( wxFileConfig *cfgfilein, wxString AccountType, wxString DirectoryName );
+#if defined(__APPLE__)
+       int DisplayTrustPanel(CardDAV *Connection);
+       SecTrustResultType ProcessResultType(CardDAV *Connection);
+#endif
 public:
        /** Constructor */
        frmNewAccount( wxWindow* parent );
@@ -49,6 +54,7 @@ private:
        int PageSeek = 0;
        wxString ServerPrefix;
        bool *ReloadAccountConfig = NULL;
+       void SetErrorMessageLabel();
 };
 
 #endif // __frmNewAccount__
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