From 53d77f5310765e248097da0c2f7056efd7c67488 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 11 Apr 2016 22:22:57 +0100 Subject: [PATCH] Added OS X support for frmMain itself. --- source/frmMain.cpp | 179 ++++++++++++++++++++++++++++++--------------- source/frmMain.h | 23 +++++- 2 files changed, 143 insertions(+), 59 deletions(-) diff --git a/source/frmMain.cpp b/source/frmMain.cpp index 5c3695a..59c3770 100644 --- a/source/frmMain.cpp +++ b/source/frmMain.cpp @@ -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::iterator SSLColIter; +#if defined(__APPLE__) + + std::map::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::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::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(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::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. diff --git a/source/frmMain.h b/source/frmMain.h index 6ae03ea..e3844af 100644 --- a/source/frmMain.h +++ b/source/frmMain.h @@ -37,6 +37,11 @@ Subclass of frmMainADT, which is generated by wxFormBuilder. #include #include +#if defined(__APPLE__) +#import +#import +#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 WindowList; std::map AccountRefreshList; std::map AccountAccDirList; +#if defined(__APPLE__) + std::map AccountTrustData; +#else std::map AccountSSLData; +#endif std::map AccountSSLResult; std::multimap AccountGroupList; std::multimap 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 -- 2.39.5