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

index 5c3695a..59c3770 100644 (file)
@@ -90,6 +90,9 @@ DEFINE_EVENT_TYPE(SYNCACCOUNT);
 DEFINE_EVENT_TYPE(IMPORT_RESULTSSHOW);
 DEFINE_EVENT_TYPE(RELOADCONTACTLIST);
 DEFINE_EVENT_TYPE(REFRESHADDRESSBOOK);
+#if defined(__APPLE__)
+DEFINE_EVENT_TYPE(INVALIDSSLTRUST);
+#endif
 
 // Setup the event table using the event types.
 
@@ -119,6 +122,9 @@ EVT_COMMAND(wxID_ANY, SYNCACCOUNT, frmMain::SyncAccount)
 EVT_COMMAND(wxID_ANY, IMPORT_RESULTSSHOW, frmMain::ShowImportResults)
 EVT_COMMAND(wxID_ANY, RELOADCONTACTLIST, frmMain::ReloadContactList)
 EVT_COMMAND(wxID_ANY, REFRESHADDRESSBOOK, frmMain::RefreshAddressBook)
+#if defined(__APPLE__)
+EVT_COMMAND(wxID_ANY, INVALIDSSLTRUST, frmMain::DisplayTrustPanel)
+#endif
 END_EVENT_TABLE()
 
 frmMain::frmMain( wxWindow* parent )
@@ -477,7 +483,7 @@ void frmMain::OpenNewABDialog( wxCommandEvent& event)
                // the application.
         
                this->LoadPreferences();
-           
+
        }
     
 }
@@ -1395,7 +1401,7 @@ void frmMain::LoadPreferences(){
        }
     
        AccountSyncTimers.clear();
-    
+        
        wxString AccDir;
        wxString AccDirFull;
        wxString AccDirFullSfx;
@@ -1408,6 +1414,10 @@ void frmMain::LoadPreferences(){
        wxTreeItemId AccountTreeId;
        wxTreeItemId GroupTreeId;
        int intGroupID = 0;
+        
+        // Relaod the accounts for the ETagProcTimer.
+        
+        ETagProcTimer.ReloadAccounts();
     
        for (int i = 0; i < preferences.accounts.GetCount(); i++){
         
@@ -2480,8 +2490,52 @@ void frmMain::ShowSSLCertificates( wxCommandEvent &event ){
        wxString AccTypeLower;
        wxString AccType;
        bool AccountSSL;
-       std::map<int, SSLCertCollection>::iterator SSLColIter;
     
+#if defined(__APPLE__)
+
+       std::map<int, SecTrustRef>::iterator SSLTrustIter;
+        
+        for (int i = 0; i < prefaccounts.GetCount(); i++){
+                
+                SeekAccount.Append(prefaccounts.GetAccountDirectory(i));
+                AccType.Append(prefaccounts.GetAccountType(i));
+                AccountSSL = prefaccounts.GetAccountSSL(i);
+                AccTypeLower = AccType.MakeLower();
+                SeekAccount.Append(wxT("."));
+                SeekAccount.Append(AccTypeLower);
+                
+                if (SeekAccount == ActiveAccount){
+                        
+                        if (AccTypeLower == wxT("local")){
+                                
+                                return;
+                                
+                        }
+                        
+                        if (AccountSSL == false){
+                                
+                                return;
+                                
+                        }
+                        
+                        SSLTrustIter = AccountTrustData.find(i);
+                        
+                        // Setup and display the form.
+                        
+                        DisplayCertificate(SSLTrustIter->second);
+                        
+                }
+                
+                SeekAccount.Clear();
+                AccTypeLower.Clear();
+                AccType.clear();
+                
+        }
+    
+#else
+    
+       std::map<int, SSLCertCollection>::iterator SSLColIter;
+        
        for (int i = 0; i < prefaccounts.GetCount(); i++){
         
                SeekAccount.Append(prefaccounts.GetAccountDirectory(i));
@@ -2524,6 +2578,8 @@ void frmMain::ShowSSLCertificates( wxCommandEvent &event ){
                AccType.clear();
         
        }
+
+#endif
     
 }
 
@@ -2553,61 +2609,6 @@ void frmMain::UpdateConnectionStatus( wxCommandEvent &event ){
     
 }
 
-void frmMain::SetupSSLStatus( int AccountID ){
-    
-       // Check if account ID given is
-       // the active account and if not, do nothing.
-    
-       wxString AccType;
-       wxString AccTypeLower;
-    
-       AccType = prefaccounts.GetAccountType(AccountID);
-       AccTypeLower = AccType.MakeLower();
-    
-       wxString AccountIDName = prefaccounts.GetAccountDirectory(AccountID) + wxT(".") +
-               AccTypeLower;
-    
-       if (AccountIDName != ActiveAccount){
-        
-               return;
-        
-       }
-    
-       // Check if the account has SSL enabled.
-    
-       bool SSLInUse = prefaccounts.GetAccountSSL(AccountID);
-    
-       if (SSLInUse == FALSE){
-        
-               SSLToolTip->SetTip(wxT("SSL is not enabled for this account"));
-               imgSSLStatus->SetBitmap(*imgNoSSL);
-        
-       } else {
-        
-               // Get the SSL Collection Data.
-        
-               std::map<int,int>::iterator SSLResultIter = AccountSSLResult.find(AccountID);
-        
-               if (SSLResultIter->second == 1){
-            
-                       imgSSLStatus->SetBitmap(*imgSSLWarning);
-                       SSLToolTip->SetTip(wxT("Invalid certificate(s) received for '") + 
-                               prefaccounts.GetAccountName(AccountID) +
-                       wxT("' (Connection denied by user)\n\nDouble click for more information."));
-            
-               } else if (SSLResultIter->second == 0){
-            
-                       imgSSLStatus->SetBitmap(*imgSSL);
-                       SSLToolTip->SetTip(wxT("Account '") + 
-                               prefaccounts.GetAccountName(AccountID) +
-                       wxT("' secured using SSL\n\nDouble click for more information."));
-            
-               }
-        
-       }
-    
-}
-
 void frmMain::InvalidSSLCertificate( wxCommandEvent &event ){
     
        // Display the form for showing an invalid SSL certificate.
@@ -2630,6 +2631,7 @@ void frmMain::InvalidSSLCertificate( wxCommandEvent &event ){
     
        frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);  
        wxPostEvent(frameActMgr, event2);
+        
 }
 
 void frmMain::PauseAllTimers(){
@@ -2658,6 +2660,10 @@ void frmMain::ResumeAllTimers(){
     
 }
 
+#if defined(__APPLE__)
+
+#else
+
 void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollection SSLCertInc){
     
        // Delete existing data.
@@ -2672,6 +2678,63 @@ void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollec
     
 }
 
+#endif
+
+void frmMain::SetupSSLStatus( int AccountID ){
+        
+        // Check if account ID given is
+        // the active account and if not, do nothing.
+        
+        wxString AccType;
+        wxString AccTypeLower;
+        
+        AccType = prefaccounts.GetAccountType(AccountID);
+        AccTypeLower = AccType.MakeLower();
+        
+        wxString AccountIDName = prefaccounts.GetAccountDirectory(AccountID) + wxT(".") +
+        AccTypeLower;
+        
+        if (AccountIDName != ActiveAccount){
+                
+                return;
+                
+        }
+        
+        // Check if the account has SSL enabled.
+        
+        bool SSLInUse = prefaccounts.GetAccountSSL(AccountID);
+        
+        if (SSLInUse == FALSE){
+                
+                SSLToolTip->SetTip(wxT("SSL is not enabled for this account"));
+                imgSSLStatus->SetBitmap(*imgNoSSL);
+                
+        } else {
+                
+                // Get the SSL Collection Data.
+                
+                std::map<int,int>::iterator SSLResultIter = AccountSSLResult.find(AccountID);
+                
+                if (SSLResultIter->second == 1){
+                        
+                        imgSSLStatus->SetBitmap(*imgSSLWarning);
+                        SSLToolTip->SetTip(wxT("Invalid certificate(s) received for '") +
+                                           prefaccounts.GetAccountName(AccountID) +
+                                           wxT("' (Connection denied by user)\n\nDouble click for more information."));
+                        
+                } else if (SSLResultIter->second == 0){
+                        
+                        imgSSLStatus->SetBitmap(*imgSSL);
+                        SSLToolTip->SetTip(wxT("Account '") +
+                                           prefaccounts.GetAccountName(AccountID) +
+                                           wxT("' secured using SSL\n\nDouble click for more information."));
+                        
+                }
+                
+        }
+        
+}
+
 void frmMain::CheckUpdates( wxCommandEvent& event ){
     
        // Check for updates to Xestia Address Book.
index 6ae03ea..e3844af 100644 (file)
@@ -37,6 +37,11 @@ Subclass of frmMainADT, which is generated by wxFormBuilder.
 #include <wx/mstream.h>
 #include <wx/tooltip.h>
 
+#if defined(__APPLE__)
+#import <Foundation/Foundation.h>
+#import <SecurityInterface/SFCertificateTrustPanel.h>
+#endif
+
 #include "common/timers.h"
 #include "common/events.h"
 #include "common/etag.h"
@@ -74,6 +79,10 @@ DECLARE_EVENT_TYPE(IMPORT_RESULTSSHOW, wxID_ANY);
 DECLARE_EVENT_TYPE(RELOADCONTACTLIST, wxID_ANY);
 DECLARE_EVENT_TYPE(REFRESHADDRESSBOOK, wxID_ANY);
 
+#if defined(__APPLE__)
+DECLARE_EVENT_TYPE(INVALIDSSLTRUST, wxID_ANY);
+#endif
+
 struct UCNotif{
        wxString ContactAccount;
        wxString ContactFilename;
@@ -116,7 +125,11 @@ class frmMain : public frmMainADT
                std::map<wxString, bool> WindowList;
                std::map<int, wxTimer> AccountRefreshList;
                std::map<int, wxString> AccountAccDirList;
+#if defined(__APPLE__)
+               std::map<int, SecTrustRef> AccountTrustData;
+#else
                std::map<int, SSLCertCollection> AccountSSLData;
+#endif
                std::map<int, int> AccountSSLResult;
                std::multimap<int, int> AccountGroupList;
                std::multimap<int, wxString> AccountGroupFilename;
@@ -178,6 +191,10 @@ class frmMain : public frmMainADT
                int WindowMenuItemID = 0;
                XABContactMenu *ContactMenu = new XABContactMenu(XABCONTACTMENU_MAIN); 
                void ResetContactInfo();
+#if defined(__APPLE__)
+               void DisplayCertificate(SecTrustRef SecurityTrustObject);
+               void DisplayTrustPanel( wxCommandEvent& event );
+#endif
        protected:
                // Handlers for frmMainADT events.
                void QuitApp( wxCloseEvent& event );
@@ -251,11 +268,15 @@ class frmMain : public frmMainADT
                void ActivityIconStop( wxCommandEvent& event );
                void PauseAllTimers();
                void ResumeAllTimers();
-               void UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollection SSLCertInc);
                void GetListControl(wxListCtrl *lstContactsPtr, wxArrayString *ContactsFileIndexPtr);
                void ShowImportResults( wxCommandEvent& event );
                void ReloadContactList( wxCommandEvent& event );
                XABViewMode GetViewMode();
+#if defined(__APPLE__)
+               void UpdateSSLAccountStatus(int AccountID, int SSLStatus, SecTrustRef SecurityTrustObject);
+#else
+               void UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollection SSLCertInc);
+#endif
                DECLARE_EVENT_TABLE()
 
        //// end generated class members
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