diff --git a/lib/EAPBase_UI/include/EAP_UI.h b/lib/EAPBase_UI/include/EAP_UI.h index 0927322..bd1cbd2 100644 --- a/lib/EAPBase_UI/include/EAP_UI.h +++ b/lib/EAPBase_UI/include/EAP_UI.h @@ -356,6 +356,32 @@ public: /// wxEAPProviderIdentityPanel(eap::config_provider &prov, wxWindow* parent); + friend class wxEAPConfigProvider; // Allows direct setting of keyboard focus + +protected: + /// \cond internal + virtual bool TransferDataToWindow(); + virtual bool TransferDataFromWindow(); + /// \endcond + +protected: + eap::config_provider &m_prov; ///< EAP method configuration + winstd::library m_shell32; ///< shell32.dll resource library reference + wxIcon m_icon; ///< Panel icon +}; + + +class wxEAPProviderLockPanel : public wxEAPProviderLockPanelBase +{ +public: + /// + /// Constructs a provider lock pannel + /// + /// \param[inout] prov Provider configuration data + /// \param[in] parent Parent window + /// + wxEAPProviderLockPanel(eap::config_provider &prov, wxWindow* parent); + protected: /// \cond internal virtual bool TransferDataToWindow(); @@ -383,6 +409,7 @@ public: protected: eap::config_provider &m_prov; ///< EAP method configuration wxEAPProviderIdentityPanel *m_identity; ///< Provider identity panel + wxEAPProviderLockPanel *m_lock; ///< Provider lock panel }; diff --git a/lib/EAPBase_UI/res/wxEAP_UI.cpp b/lib/EAPBase_UI/res/wxEAP_UI.cpp index 29e50ef..3c40b73 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.cpp +++ b/lib/EAPBase_UI/res/wxEAP_UI.cpp @@ -464,3 +464,55 @@ wxEAPProviderIdentityPanelBase::~wxEAPProviderIdentityPanelBase() 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 ) +{ + wxStaticBoxSizer* sb_provider_lock; + sb_provider_lock = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Configuration Lock") ), wxVERTICAL ); + + wxBoxSizer* sb_provider_lock_horiz; + sb_provider_lock_horiz = new wxBoxSizer( wxHORIZONTAL ); + + m_provider_lock_icon = new wxStaticBitmap( sb_provider_lock->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + sb_provider_lock_horiz->Add( m_provider_lock_icon, 0, wxALL, 5 ); + + wxBoxSizer* sb_provider_lock_vert; + sb_provider_lock_vert = new wxBoxSizer( wxVERTICAL ); + + m_provider_lock_label = new wxStaticText( sb_provider_lock->GetStaticBox(), wxID_ANY, _("Your configuration can be locked to prevent accidental modification by end-users. Users will only be allowed to enter credentials."), wxDefaultPosition, wxDefaultSize, 0 ); + m_provider_lock_label->Wrap( 446 ); + sb_provider_lock_vert->Add( m_provider_lock_label, 0, wxALL|wxEXPAND, 5 ); + + wxBoxSizer* sb_provider_name; + sb_provider_name = new wxBoxSizer( wxVERTICAL ); + + m_provider_lock = new wxCheckBox( sb_provider_lock->GetStaticBox(), wxID_ANY, _("&Lock this configuration and prevent any further modification via user interface."), wxDefaultPosition, wxDefaultSize, 0 ); + sb_provider_name->Add( m_provider_lock, 0, wxEXPAND|wxBOTTOM, 5 ); + + m_provider_lock_note = new wxStaticText( sb_provider_lock->GetStaticBox(), wxID_ANY, _("(Warning: Once locked, you can not revert using this dialog!)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_provider_lock_note->Wrap( -1 ); + sb_provider_name->Add( m_provider_lock_note, 0, wxALIGN_RIGHT, 5 ); + + + sb_provider_lock_vert->Add( sb_provider_name, 0, wxEXPAND|wxALL, 5 ); + + + sb_provider_lock_horiz->Add( sb_provider_lock_vert, 1, wxEXPAND, 5 ); + + + sb_provider_lock->Add( sb_provider_lock_horiz, 1, wxEXPAND, 5 ); + + + 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 8e66211..95184fa 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.fbp +++ b/lib/EAPBase_UI/res/wxEAP_UI.fbp @@ -3766,5 +3766,435 @@ + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + wxEAPProviderLockPanelBase + + 500,-1 + + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnUpdateUI + + wxID_ANY + Configuration Lock + + sb_provider_lock + wxVERTICAL + none + + + 5 + wxEXPAND + 1 + + + sb_provider_lock_horiz + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + Load From Icon Resource; ; [32; 32] + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_provider_lock_icon + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + sb_provider_lock_vert + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Your configuration can be locked to prevent accidental modification by end-users. Users will only be allowed to enter credentials. + + 0 + + + 0 + + 1 + m_provider_lock_label + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + 446 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + + sb_provider_name + wxVERTICAL + none + + 5 + wxEXPAND|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + &Lock this configuration and prevent any further modification via user interface. + + 0 + + + 0 + + 1 + m_provider_lock + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_RIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + (Warning: Once locked, you can not revert using this dialog!) + + 0 + + + 0 + + 1 + m_provider_lock_note + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/EAPBase_UI/res/wxEAP_UI.h b/lib/EAPBase_UI/res/wxEAP_UI.h index 53e5602..6eef1b6 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.h +++ b/lib/EAPBase_UI/res/wxEAP_UI.h @@ -210,4 +210,28 @@ class wxEAPProviderIdentityPanelBase : public wxPanel }; +/////////////////////////////////////////////////////////////////////////////// +/// Class wxEAPProviderLockPanelBase +/////////////////////////////////////////////////////////////////////////////// +class wxEAPProviderLockPanelBase : public wxPanel +{ + private: + + protected: + wxStaticBitmap* m_provider_lock_icon; + 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: + + wxEAPProviderLockPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,-1 ), long style = wxTAB_TRAVERSAL ); + ~wxEAPProviderLockPanelBase(); + +}; + #endif //__WXEAP_UI_H__ diff --git a/lib/EAPBase_UI/src/EAP_UI.cpp b/lib/EAPBase_UI/src/EAP_UI.cpp index 06a1909..32c4a98 100644 --- a/lib/EAPBase_UI/src/EAP_UI.cpp +++ b/lib/EAPBase_UI/src/EAP_UI.cpp @@ -292,6 +292,38 @@ bool wxEAPProviderIdentityPanel::TransferDataFromWindow() } +////////////////////////////////////////////////////////////////////// +// wxEAPProviderLockPanel +////////////////////////////////////////////////////////////////////// + +wxEAPProviderLockPanel::wxEAPProviderLockPanel(eap::config_provider &prov, wxWindow* parent) : + m_prov(prov), + wxEAPProviderLockPanelBase(parent) +{ + // Load and set icon. + if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE)) + wxSetIconFromResource(m_provider_lock_icon, m_icon, m_shell32, MAKEINTRESOURCE(1003)); +} + + +bool wxEAPProviderLockPanel::TransferDataToWindow() +{ + m_provider_lock->SetValue(m_prov.m_read_only); + + return wxEAPProviderLockPanelBase::TransferDataToWindow(); +} + + +bool wxEAPProviderLockPanel::TransferDataFromWindow() +{ + wxCHECK(wxEAPProviderLockPanelBase::TransferDataFromWindow(), false); + + m_prov.m_read_only = m_provider_lock->GetValue(); + + return true; +} + + ////////////////////////////////////////////////////////////////////// // wxEAPConfigProvider ////////////////////////////////////////////////////////////////////// @@ -305,4 +337,9 @@ wxEAPConfigProvider::wxEAPConfigProvider(eap::config_provider &prov, wxWindow* p m_identity = new wxEAPProviderIdentityPanel(prov, this); AddContent(m_identity); + + m_lock = new wxEAPProviderLockPanel(prov, this); + AddContent(m_lock); + + m_identity->m_provider_name->SetFocusFromKbd(); } diff --git a/lib/TLS_UI/src/TLS_UI.cpp b/lib/TLS_UI/src/TLS_UI.cpp index 29c4689..f9f63c6 100644 --- a/lib/TLS_UI/src/TLS_UI.cpp +++ b/lib/TLS_UI/src/TLS_UI.cpp @@ -423,14 +423,6 @@ wxTLSServerTrustPanel::wxTLSServerTrustPanel(const eap::config_provider &prov, e bool wxTLSServerTrustPanel::TransferDataToWindow() { - if (m_prov.m_read_only) { - // This is provider-locked configuration. Disable controls. - m_root_ca_add_store->Enable(false); - m_root_ca_add_file ->Enable(false); - m_root_ca_remove ->Enable(false); - m_server_names ->Enable(false); - } - // Populate trusted CA list. for (std::list::const_iterator cert = m_cfg.m_trusted_root_ca.cbegin(), cert_end = m_cfg.m_trusted_root_ca.cend(); cert != cert_end; ++cert) m_root_ca->Append(wxString(eap::get_cert_title(*cert)), new wxCertificateClientData(cert->duplicate())); @@ -469,10 +461,19 @@ void wxTLSServerTrustPanel::OnUpdateUI(wxUpdateUIEvent& event) { UNREFERENCED_PARAMETER(event); - if (!m_prov.m_read_only) { + if (m_prov.m_read_only) { + // This is provider-locked configuration. Disable controls. + m_root_ca_add_store->Enable(false); + m_root_ca_add_file ->Enable(false); + m_root_ca_remove ->Enable(false); + m_server_names ->Enable(false); + } else { // 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_server_names ->Enable(true); } } diff --git a/lib/TTLS_UI/include/TTLS_UI.h b/lib/TTLS_UI/include/TTLS_UI.h index 7a97d5f..d3d988f 100644 --- a/lib/TTLS_UI/include/TTLS_UI.h +++ b/lib/TTLS_UI/include/TTLS_UI.h @@ -91,6 +91,7 @@ protected: virtual bool TransferDataToWindow(); virtual bool TransferDataFromWindow(); virtual void OnInitDialog(wxInitDialogEvent& event); + virtual void OnUpdateUI(wxUpdateUIEvent& event); /// \endcond protected: diff --git a/lib/TTLS_UI/src/TTLS_UI.cpp b/lib/TTLS_UI/src/TTLS_UI.cpp index fccd7bf..42c0db5 100644 --- a/lib/TTLS_UI/src/TTLS_UI.cpp +++ b/lib/TTLS_UI/src/TTLS_UI.cpp @@ -38,14 +38,6 @@ wxTTLSConfigPanel::wxTTLSConfigPanel(const eap::config_provider &prov, eap::conf bool wxTTLSConfigPanel::TransferDataToWindow() { - if (m_prov.m_read_only) { - // This is provider-locked configuration. Disable controls. - m_outer_identity_same ->Enable(false); - m_outer_identity_empty ->Enable(false); - m_outer_identity_custom ->Enable(false); - m_outer_identity_custom_val->Enable(false); - } - // Populate identity controls. if (m_cfg.m_anonymous_identity.empty()) { m_outer_identity_same->SetValue(true); @@ -82,8 +74,17 @@ void wxTTLSConfigPanel::OnUpdateUI(wxUpdateUIEvent& event) { UNREFERENCED_PARAMETER(event); - if (!m_prov.m_read_only) { + if (m_prov.m_read_only) { + // This is provider-locked configuration. Disable controls. + m_outer_identity_same ->Enable(false); + m_outer_identity_empty ->Enable(false); + m_outer_identity_custom ->Enable(false); + m_outer_identity_custom_val->Enable(false); + } else { // This is not a provider-locked configuration. Selectively enable/disable controls. + m_outer_identity_same ->Enable(true); + m_outer_identity_empty ->Enable(true); + m_outer_identity_custom ->Enable(true); m_outer_identity_custom_val->Enable(m_outer_identity_custom->GetValue()); } } @@ -144,11 +145,6 @@ wxTTLSConfigWindow::wxTTLSConfigWindow(const eap::config_provider &prov, eap::co bool wxTTLSConfigWindow::TransferDataToWindow() { - if (m_prov.m_read_only) { - // This is provider-locked configuration. Disable controls. - m_inner_type->GetChoiceCtrl()->Enable(false); - } - eap::config_method_pap *cfg_pap = dynamic_cast(m_cfg.m_inner.get()); if (cfg_pap) { m_cfg_pap = *cfg_pap; @@ -194,6 +190,14 @@ void wxTTLSConfigWindow::OnInitDialog(wxInitDialogEvent& event) } +void wxTTLSConfigWindow::OnUpdateUI(wxUpdateUIEvent& event) +{ + wxEAPConfigWindow::OnUpdateUI(event); + + m_inner_type->GetChoiceCtrl()->Enable(!m_prov.m_read_only); +} + + ////////////////////////////////////////////////////////////////////// // wxTTLSCredentialsPanel //////////////////////////////////////////////////////////////////////