diff --git a/lib/EAPBase_UI/include/EAP_UI.h b/lib/EAPBase_UI/include/EAP_UI.h index 8c04faf..9e08889 100644 --- a/lib/EAPBase_UI/include/EAP_UI.h +++ b/lib/EAPBase_UI/include/EAP_UI.h @@ -223,19 +223,22 @@ protected: } } - virtual void OnUpdateUI(wxUpdateUIEvent& event) + virtual void OnUpdateUI(wxUpdateUIEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); + int idx = m_providers->GetSelection(); + eap::config_provider &cfg_provider = ((_wxT*)m_providers->GetPage(idx))->GetProvider(); - m_advanced->Enable(!m_cfg.m_providers.at(m_providers->GetSelection()).m_read_only); + m_advanced->Enable(!cfg_provider.m_read_only); } - virtual void OnAdvanced(wxCommandEvent& event) + virtual void OnAdvanced(wxCommandEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); + int idx = m_providers->GetSelection(); + eap::config_provider &cfg_provider = ((_wxT*)m_providers->GetPage(idx))->GetProvider(); - wxEAPConfigProvider dlg(m_cfg.m_providers.at(m_providers->GetSelection()), this); - dlg.ShowModal(); + wxEAPConfigProvider dlg(cfg_provider, this); + if (dlg.ShowModal() == wxID_OK) + m_providers->SetPageText(idx, wxEAPGetProviderName(cfg_provider.m_id)); } /// \endcond @@ -360,22 +363,25 @@ public: /// \param[inout] cfg Configuration data /// \param[in] parent Parent window /// - wxEAPConfigWindow(const eap::config_provider &prov, eap::config_method &cfg, wxWindow* parent); + wxEAPConfigWindow(eap::config_provider &prov, eap::config_method &cfg, wxWindow* parent); /// /// Destructs the configuration window /// virtual ~wxEAPConfigWindow(); +public: + inline eap::config_provider& GetProvider() const { return m_prov; } + inline eap::config_method & GetConfig () const { return m_cfg ; } + protected: /// \cond internal virtual void OnInitDialog(wxInitDialogEvent& event); - virtual void OnUpdateUI(wxUpdateUIEvent& event); /// \endcond protected: - const eap::config_provider &m_prov; ///< EAP provider - eap::config_method &m_cfg; ///< Method configuration + eap::config_provider &m_prov; ///< EAP provider + eap::config_method &m_cfg; ///< Method configuration }; @@ -459,6 +465,7 @@ public: m_prov(prov), m_cfg(cfg), m_target(pszCredTarget), + m_has_own(false), m_cred_own(cfg.m_module), m_cred_preshared(cfg.m_module), wxEAPCredentialsConfigPanelBase(parent) @@ -480,32 +487,6 @@ public: protected: /// \cond internal - bool RetrieveCredentials() - { - try { - m_cred_own.retrieve(m_target.c_str()); - if (m_cred_own.empty()) - m_own_identity->SetValue(_T("")); - else { - wxString identity(m_cred_own.get_name()); - m_own_identity->SetValue(!identity.empty() ? identity : _("")); - } - return true; - } catch (winstd::win_runtime_error &err) { - if (err.number() == ERROR_NOT_FOUND) { - m_own_identity->Clear(); - return false; - } else { - m_own_identity->SetValue(wxString::Format(_(""), err.number())); - return true; - } - } catch (...) { - m_own_identity->SetValue(_("")); - return true; - } - } - - virtual bool TransferDataToWindow() { if (!m_cfg.m_use_preshared) @@ -513,7 +494,13 @@ protected: else m_preshared->SetValue(true); + if (m_cfg.m_allow_save) { + RetrieveOwnCredentials(); + m_timer_own.Start(3000); + } + m_cred_preshared = *(_Tcred*)m_cfg.m_preshared.get(); + UpdatePresharedIdentity(); return wxEAPCredentialsConfigPanelBase::TransferDataToWindow(); } @@ -533,34 +520,24 @@ protected: } - virtual void OnUpdateUI(wxUpdateUIEvent& event) + virtual void OnUpdateUI(wxUpdateUIEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); - if (m_cfg.m_allow_save) { if (m_own->GetValue()) { m_own_identity->Enable(true); m_own_set ->Enable(true); - m_own_clear ->Enable(RetrieveCredentials()); + m_own_clear ->Enable(m_has_own); } else { m_own_identity->Enable(false); m_own_set ->Enable(false); m_own_clear ->Enable(false); } } else { - m_own_identity->Clear(); m_own_identity->Enable(false); m_own_set ->Enable(false); m_own_clear ->Enable(false); } - if (m_cred_preshared.empty()) - m_preshared_identity->SetValue(_T("")); - else { - wxString identity(m_cred_preshared.get_name()); - m_preshared_identity->SetValue(!identity.empty() ? identity : _("")); - } - if (m_prov.m_read_only) { // This is provider-locked configuration. Disable controls. // To avoid run-away selection of radio buttons, disable the selected one last. @@ -575,8 +552,8 @@ protected: m_preshared_set ->Enable(false); } else { // This is not a provider-locked configuration. Selectively enable/disable controls. - m_own ->Enable(true); - m_preshared ->Enable(true); + m_own ->Enable(true); + m_preshared->Enable(true); if (m_own->GetValue()) { m_preshared_identity->Enable(false); m_preshared_set ->Enable(false); @@ -588,12 +565,10 @@ protected: } - virtual void OnSetOwn(wxCommandEvent& event) + virtual void OnSetOwn(wxCommandEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); - // Read credentials from Credential Manager. - RetrieveCredentials(); + RetrieveOwnCredentials(); // Display credential prompt. wxEAPCredentialsDialog dlg(m_prov, this); @@ -603,37 +578,87 @@ protected: // Write credentials to credential manager. try { m_cred_own.store(m_target.c_str()); - - // Re-read credentials from Credential Manager. To test if they load! - RetrieveCredentials(); + m_has_own = TRUE; + UpdateOwnIdentity(); } catch (winstd::win_runtime_error &err) { wxLogError(winstd::tstring_printf(_("Error writing credentials to Credential Manager: %hs (error %u)"), err.what(), err.number()).c_str()); + RetrieveOwnCredentials(); } catch (...) { wxLogError(_("Writing credentials failed.")); + RetrieveOwnCredentials(); } } } - virtual void OnClearOwn(wxCommandEvent& event) + virtual void OnClearOwn(wxCommandEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); - - if (!CredDelete(m_cred_own.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0)) + if (CredDelete(m_cred_own.target_name(m_target.c_str()).c_str(), CRED_TYPE_GENERIC, 0)) { + m_own_identity->Clear(); + m_has_own = false; + } else wxLogError(_("Deleting credentials failed (error %u)."), GetLastError()); } - virtual void OnSetPreshared(wxCommandEvent& event) + virtual void OnSetPreshared(wxCommandEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); - wxEAPCredentialsDialog dlg(m_prov, this); _wxT *panel = new _wxT(m_prov, m_cfg, m_cred_preshared, _T(""), &dlg, true); dlg.AddContent(panel); - dlg.ShowModal(); + if (dlg.ShowModal() == wxID_OK) + UpdatePresharedIdentity(); + } + + + virtual void OnTimerOwn(wxTimerEvent& /*event*/) + { + RetrieveOwnCredentials(); + } + + + void RetrieveOwnCredentials() + { + try { + m_cred_own.retrieve(m_target.c_str()); + m_has_own = true; + UpdateOwnIdentity(); + } catch (winstd::win_runtime_error &err) { + if (err.number() == ERROR_NOT_FOUND) { + m_own_identity->Clear(); + m_has_own = false; + } else { + m_own_identity->SetValue(wxString::Format(_(""), err.number())); + m_has_own = true; + } + } catch (...) { + m_own_identity->SetValue(_("")); + m_has_own = true; + } + } + + + inline void UpdateOwnIdentity() + { + if (m_cred_own.empty()) + m_own_identity->SetValue(_T("")); + else { + wxString identity(m_cred_own.get_name()); + m_own_identity->SetValue(!identity.empty() ? identity : _("")); + } + } + + + inline void UpdatePresharedIdentity() + { + if (m_cred_preshared.empty()) + m_preshared_identity->SetValue(_T("")); + else { + wxString identity(m_cred_preshared.get_name()); + m_preshared_identity->SetValue(!identity.empty() ? identity : _("")); + } } /// \endcond @@ -644,6 +669,7 @@ protected: winstd::tstring m_target; ///< Credential Manager target private: + bool m_has_own; ///< Does the user has (some sort of) credentials stored in Credential Manager? _Tcred m_cred_own; ///< Temporary own credential data _Tcred m_cred_preshared; ///< Temporary pre-shared credential data }; @@ -676,12 +702,6 @@ public: m_is_config(is_config), _Tbase(parent) { - this->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(_Tthis::OnUpdateUI)); - } - - virtual ~wxEAPCredentialsPanel() - { - this->Disconnect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(_Tthis::OnUpdateUI)); } virtual void SetRemember(bool val) @@ -697,10 +717,8 @@ public: protected: /// \cond internal - virtual void OnUpdateUI(wxUpdateUIEvent& event) + virtual bool TransferDataToWindow() { - UNREFERENCED_PARAMETER(event); - if (m_is_config) { // Configuration mode // Always store credentials (somewhere). @@ -715,6 +733,8 @@ protected: m_remember->SetValue(false); m_remember->Enable(false); } + + return _Tbase::TransferDataToWindow(); } /// \endcond @@ -780,6 +800,14 @@ protected: m_identity->SetSelection(0, -1); m_password->SetValue(m_cred.m_password.empty() ? wxEmptyString : s_dummy_password); + if (!m_is_config && m_cfg.m_use_preshared) { + // Credential prompt mode & Using pre-shared credentials + m_identity_label->Enable(false); + m_identity ->Enable(false); + m_password_label->Enable(false); + m_password ->Enable(false); + } + return wxEAPCredentialsPanel<_Tcred, wxEAPCredentialsPassPanelBase>::TransferDataToWindow(); } @@ -798,19 +826,6 @@ protected: return true; } - virtual void OnUpdateUI(wxUpdateUIEvent& event) - { - if (!m_is_config && m_cfg.m_use_preshared) { - // Credential prompt mode & Using pre-shared credentials - m_identity_label->Enable(false); - m_identity ->Enable(false); - m_password_label->Enable(false); - m_password ->Enable(false); - } - - wxEAPCredentialsPanel<_Tcred, wxEAPCredentialsPassPanelBase>::OnUpdateUI(event); - } - /// \endcond private: diff --git a/lib/EAPBase_UI/res/wxEAP_UI.cpp b/lib/EAPBase_UI/res/wxEAP_UI.cpp index 3c08310..135fc3c 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.cpp +++ b/lib/EAPBase_UI/res/wxEAP_UI.cpp @@ -272,12 +272,14 @@ wxEAPCredentialsConfigPanelBase::wxEAPCredentialsConfigPanelBase( wxWindow* pare this->SetSizer( sb_credentials ); this->Layout(); + m_timer_own.SetOwner( this, wxID_ANY ); // Connect Events this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPCredentialsConfigPanelBase::OnUpdateUI ) ); m_own_clear->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnClearOwn ), NULL, this ); m_own_set->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetOwn ), NULL, this ); m_preshared_set->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetPreshared ), NULL, this ); + this->Connect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( wxEAPCredentialsConfigPanelBase::OnTimerOwn ) ); } wxEAPCredentialsConfigPanelBase::~wxEAPCredentialsConfigPanelBase() @@ -287,6 +289,7 @@ wxEAPCredentialsConfigPanelBase::~wxEAPCredentialsConfigPanelBase() m_own_clear->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnClearOwn ), NULL, this ); m_own_set->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetOwn ), NULL, this ); m_preshared_set->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPCredentialsConfigPanelBase::OnSetPreshared ), NULL, this ); + this->Disconnect( wxID_ANY, wxEVT_TIMER, wxTimerEventHandler( wxEAPCredentialsConfigPanelBase::OnTimerOwn ) ); } @@ -453,16 +456,10 @@ wxEAPProviderIdentityPanelBase::wxEAPProviderIdentityPanelBase( wxWindow* parent this->SetSizer( sb_provider_id ); this->Layout(); - - // Connect Events - this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPProviderIdentityPanelBase::OnUpdateUI ) ); } wxEAPProviderIdentityPanelBase::~wxEAPProviderIdentityPanelBase() { - // Disconnect Events - this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPProviderIdentityPanelBase::OnUpdateUI ) ); - } wxEAPProviderLockPanelBase::wxEAPProviderLockPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) @@ -505,14 +502,8 @@ wxEAPProviderLockPanelBase::wxEAPProviderLockPanelBase( wxWindow* parent, wxWind this->SetSizer( sb_provider_lock ); this->Layout(); - - // Connect Events - this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPProviderLockPanelBase::OnUpdateUI ) ); } wxEAPProviderLockPanelBase::~wxEAPProviderLockPanelBase() { - // Disconnect Events - this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPProviderLockPanelBase::OnUpdateUI ) ); - } diff --git a/lib/EAPBase_UI/res/wxEAP_UI.fbp b/lib/EAPBase_UI/res/wxEAP_UI.fbp index ec9f918..dbd2da9 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.fbp +++ b/lib/EAPBase_UI/res/wxEAP_UI.fbp @@ -1913,6 +1913,15 @@ + + 0 + wxID_ANY + m_timer_own + 0 + 3000 + protected + OnTimerOwn + 0 @@ -2667,7 +2676,7 @@ - OnUpdateUI + wxID_ANY Your Organization @@ -3817,7 +3826,7 @@ - OnUpdateUI + wxID_ANY Configuration Lock diff --git a/lib/EAPBase_UI/res/wxEAP_UI.h b/lib/EAPBase_UI/res/wxEAP_UI.h index 076aad2..4dc89f5 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.h +++ b/lib/EAPBase_UI/res/wxEAP_UI.h @@ -33,6 +33,7 @@ class wxEAPBannerPanel; #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -143,12 +144,14 @@ class wxEAPCredentialsConfigPanelBase : public wxPanel wxRadioButton* m_preshared; wxTextCtrl* m_preshared_identity; wxButton* m_preshared_set; + wxTimer m_timer_own; // Virtual event handlers, overide them in your derived class virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } virtual void OnClearOwn( wxCommandEvent& event ) { event.Skip(); } virtual void OnSetOwn( wxCommandEvent& event ) { event.Skip(); } virtual void OnSetPreshared( wxCommandEvent& event ) { event.Skip(); } + virtual void OnTimerOwn( wxTimerEvent& event ) { event.Skip(); } public: @@ -201,10 +204,6 @@ class wxEAPProviderIdentityPanelBase : public wxPanel wxTextCtrl* m_provider_email; wxStaticText* m_provider_phone_icon; wxTextCtrl* m_provider_phone; - - // Virtual event handlers, overide them in your derived class - virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } - public: @@ -225,10 +224,6 @@ class wxEAPProviderLockPanelBase : public wxPanel wxStaticText* m_provider_lock_label; wxCheckBox* m_provider_lock; wxStaticText* m_provider_lock_note; - - // Virtual event handlers, overide them in your derived class - virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } - public: diff --git a/lib/EAPBase_UI/src/EAP_UI.cpp b/lib/EAPBase_UI/src/EAP_UI.cpp index 815775f..211a3f3 100644 --- a/lib/EAPBase_UI/src/EAP_UI.cpp +++ b/lib/EAPBase_UI/src/EAP_UI.cpp @@ -223,7 +223,7 @@ wxEAPCredentialWarningPanel::wxEAPCredentialWarningPanel(const eap::config_provi // wxEAPConfigWindow ////////////////////////////////////////////////////////////////////// -wxEAPConfigWindow::wxEAPConfigWindow(const eap::config_provider &prov, eap::config_method &cfg, wxWindow* parent) : +wxEAPConfigWindow::wxEAPConfigWindow(eap::config_provider &prov, eap::config_method &cfg, wxWindow* parent) : m_prov(prov), m_cfg(cfg), wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL) @@ -232,42 +232,23 @@ wxEAPConfigWindow::wxEAPConfigWindow(const eap::config_provider &prov, eap::conf // Connect Events this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPConfigWindow::OnInitDialog)); - this->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(wxEAPConfigWindow::OnUpdateUI)); } wxEAPConfigWindow::~wxEAPConfigWindow() { // Disconnect Events - this->Disconnect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(wxEAPConfigWindow::OnUpdateUI)); this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(wxEAPConfigWindow::OnInitDialog)); } -void wxEAPConfigWindow::OnInitDialog(wxInitDialogEvent& event) +void wxEAPConfigWindow::OnInitDialog(wxInitDialogEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); - // Call TransferDataToWindow() manually, as wxScrolledWindow somehow skips that. TransferDataToWindow(); } -void wxEAPConfigWindow::OnUpdateUI(wxUpdateUIEvent& event) -{ - UNREFERENCED_PARAMETER(event); - - if (m_parent && m_parent->IsKindOf(wxCLASSINFO(wxNotebook))) { - // We're a notebook page. Set the ID of our provider as our page label. - wxNotebook *notebook = (wxNotebook*)m_parent; - int idx = notebook->FindPage(this); - if (idx != wxNOT_FOUND) - notebook->SetPageText(idx, wxEAPGetProviderName(m_prov.m_id)); - } else - this->SetLabel(wxEAPGetProviderName(m_prov.m_id)); -} - - ////////////////////////////////////////////////////////////////////// // wxEAPProviderIdentityPanel ////////////////////////////////////////////////////////////////////// diff --git a/lib/TLS_UI/res/wxTLS_UI.cpp b/lib/TLS_UI/res/wxTLS_UI.cpp index 614ab7e..7f4f8c4 100644 --- a/lib/TLS_UI/res/wxTLS_UI.cpp +++ b/lib/TLS_UI/res/wxTLS_UI.cpp @@ -194,8 +194,14 @@ wxTLSCredentialsPanelBase::wxTLSCredentialsPanelBase( wxWindow* parent, wxWindow this->SetSizer( sb_credentials ); this->Layout(); + + // Connect Events + this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxTLSCredentialsPanelBase::OnUpdateUI ) ); } wxTLSCredentialsPanelBase::~wxTLSCredentialsPanelBase() { + // Disconnect Events + this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxTLSCredentialsPanelBase::OnUpdateUI ) ); + } diff --git a/lib/TLS_UI/res/wxTLS_UI.fbp b/lib/TLS_UI/res/wxTLS_UI.fbp index 5135458..5ec5ab8 100644 --- a/lib/TLS_UI/res/wxTLS_UI.fbp +++ b/lib/TLS_UI/res/wxTLS_UI.fbp @@ -1050,7 +1050,7 @@ - + OnUpdateUI wxID_ANY TLS Client Certificate diff --git a/lib/TLS_UI/res/wxTLS_UI.h b/lib/TLS_UI/res/wxTLS_UI.h index df69220..27042b0 100644 --- a/lib/TLS_UI/res/wxTLS_UI.h +++ b/lib/TLS_UI/res/wxTLS_UI.h @@ -84,6 +84,10 @@ class wxTLSCredentialsPanelBase : public wxPanel wxTextCtrl* m_identity; wxStaticText* m_identity_note; wxCheckBox* m_remember; + + // Virtual event handlers, overide them in your derived class + virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } + public: diff --git a/lib/TLS_UI/src/StdAfx.h b/lib/TLS_UI/src/StdAfx.h index 082f7c3..9ed5d92 100644 --- a/lib/TLS_UI/src/StdAfx.h +++ b/lib/TLS_UI/src/StdAfx.h @@ -25,3 +25,5 @@ #include "../../../include/Version.h" #include "../include/TLS_UI.h" + +#include diff --git a/lib/TLS_UI/src/TLS_UI.cpp b/lib/TLS_UI/src/TLS_UI.cpp index 8638548..c1b2c42 100644 --- a/lib/TLS_UI/src/TLS_UI.cpp +++ b/lib/TLS_UI/src/TLS_UI.cpp @@ -385,7 +385,7 @@ bool wxTLSCredentialsPanel::TransferDataFromWindow() } -void wxTLSCredentialsPanel::OnUpdateUI(wxUpdateUIEvent& event) +void wxTLSCredentialsPanel::OnUpdateUI(wxUpdateUIEvent& /*event*/) { if (!m_is_config && m_cfg.m_use_preshared) { // Credential prompt mode & Using pre-shared credentials @@ -404,8 +404,6 @@ void wxTLSCredentialsPanel::OnUpdateUI(wxUpdateUIEvent& event) m_cert_select_val->Enable(m_cert_select->GetValue()); m_identity->Enable(true); } - - wxEAPCredentialsPanel::OnUpdateUI(event); } @@ -465,10 +463,8 @@ bool wxTLSServerTrustPanel::TransferDataFromWindow() } -void wxTLSServerTrustPanel::OnUpdateUI(wxUpdateUIEvent& event) +void wxTLSServerTrustPanel::OnUpdateUI(wxUpdateUIEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); - if (m_prov.m_read_only) { // This is provider-locked configuration. Disable controls. m_root_ca_add_store->Enable(false); @@ -479,9 +475,12 @@ void wxTLSServerTrustPanel::OnUpdateUI(wxUpdateUIEvent& event) // This is not a provider-locked configuration. Selectively enable/disable controls. m_root_ca_add_store->Enable(true); m_root_ca_add_file ->Enable(true); - wxArrayInt selections; - m_root_ca_remove->Enable(m_root_ca->GetSelections(selections) ? true : false); + m_root_ca_remove ->Enable(ListBox_GetSelCount(m_root_ca->GetHWND()) ? true : false); // * m_server_names ->Enable(true); + + // * ListBox_GetSelCount() is not cross-platform, but this is Windows EAP Supplicant, + // and this is the fastest way to find out if there is a selection in the list box, + // observing wxWidgets 3.0.2 has nothing faster to offer. } } @@ -494,10 +493,8 @@ void wxTLSServerTrustPanel::OnRootCADClick(wxCommandEvent& event) } -void wxTLSServerTrustPanel::OnRootCAAddStore(wxCommandEvent& event) +void wxTLSServerTrustPanel::OnRootCAAddStore(wxCommandEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); - winstd::cert_store store; if (store.create(NULL, _T("ROOT"))) { winstd::cert_context cert; @@ -510,8 +507,6 @@ void wxTLSServerTrustPanel::OnRootCAAddStore(wxCommandEvent& event) void wxTLSServerTrustPanel::OnRootCAAddFile(wxCommandEvent& event) { - UNREFERENCED_PARAMETER(event); - const wxString separator(wxT("|")); wxFileDialog open_dialog(this, _("Add Certificate"), wxEmptyString, wxEmptyString, _("Certificate Files (*.cer;*.crt;*.der;*.p7b;*.pem)") + separator + wxT("*.cer;*.crt;*.der;*.p7b;*.pem") + separator + @@ -538,10 +533,8 @@ void wxTLSServerTrustPanel::OnRootCAAddFile(wxCommandEvent& event) } -void wxTLSServerTrustPanel::OnRootCARemove(wxCommandEvent& event) +void wxTLSServerTrustPanel::OnRootCARemove(wxCommandEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); - wxArrayInt selections; for (int i = m_root_ca->GetSelections(selections); i--; ) m_root_ca->Delete(selections[i]); diff --git a/lib/TTLS_UI/include/TTLS_UI.h b/lib/TTLS_UI/include/TTLS_UI.h index 0ffc6bf..b51f66d 100644 --- a/lib/TTLS_UI/include/TTLS_UI.h +++ b/lib/TTLS_UI/include/TTLS_UI.h @@ -76,14 +76,19 @@ class wxTTLSConfigWindow : public wxEAPConfigWindow { public: /// - /// Constructs a configuration panel + /// Constructs a configuration window /// /// \param[in] prov Provider configuration data /// \param[inout] cfg Configuration data /// \param[in] pszCredTarget Target name of credentials in Windows Credential Manager. Can be further decorated to create final target name. /// \param[in] parent Parent window /// - wxTTLSConfigWindow(const eap::config_provider &prov, eap::config_method &cfg, LPCTSTR pszCredTarget, wxWindow* parent); + wxTTLSConfigWindow(eap::config_provider &prov, eap::config_method &cfg, LPCTSTR pszCredTarget, wxWindow* parent); + + /// + /// Destructs the configuration window + /// + virtual ~wxTTLSConfigWindow(); protected: /// \cond internal diff --git a/lib/TTLS_UI/src/TTLS_UI.cpp b/lib/TTLS_UI/src/TTLS_UI.cpp index 0e40ae0..3c7cf58 100644 --- a/lib/TTLS_UI/src/TTLS_UI.cpp +++ b/lib/TTLS_UI/src/TTLS_UI.cpp @@ -71,10 +71,8 @@ bool wxTTLSConfigPanel::TransferDataFromWindow() } -void wxTTLSConfigPanel::OnUpdateUI(wxUpdateUIEvent& event) +void wxTTLSConfigPanel::OnUpdateUI(wxUpdateUIEvent& /*event*/) { - UNREFERENCED_PARAMETER(event); - if (m_prov.m_read_only) { // This is provider-locked configuration. Disable controls. m_outer_identity_same ->Enable(false); @@ -95,7 +93,7 @@ void wxTTLSConfigPanel::OnUpdateUI(wxUpdateUIEvent& event) // wxTTLSConfigWindow ////////////////////////////////////////////////////////////////////// -wxTTLSConfigWindow::wxTTLSConfigWindow(const eap::config_provider &prov, eap::config_method &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : +wxTTLSConfigWindow::wxTTLSConfigWindow(eap::config_provider &prov, eap::config_method &cfg, LPCTSTR pszCredTarget, wxWindow* parent) : m_cfg((eap::config_method_ttls&)cfg), m_cfg_pap(cfg.m_module), wxEAPConfigWindow(prov, cfg, parent) @@ -143,6 +141,14 @@ wxTTLSConfigWindow::wxTTLSConfigWindow(const eap::config_provider &prov, eap::co // m_inner_type->SetFocusFromKbd(); // This control steals mouse-wheel scrolling for itself panel_pap->SetFocusFromKbd(); + + this->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(wxTTLSConfigWindow::OnUpdateUI)); +} + + +wxTTLSConfigWindow::~wxTTLSConfigWindow() +{ + this->Disconnect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(wxTTLSConfigWindow::OnUpdateUI)); } @@ -193,10 +199,8 @@ void wxTTLSConfigWindow::OnInitDialog(wxInitDialogEvent& event) } -void wxTTLSConfigWindow::OnUpdateUI(wxUpdateUIEvent& event) +void wxTTLSConfigWindow::OnUpdateUI(wxUpdateUIEvent& /*event*/) { - wxEAPConfigWindow::OnUpdateUI(event); - m_inner_type->GetChoiceCtrl()->Enable(!m_prov.m_read_only); }