From f6522b8fa756a0259987c3decbd839e7eb11ccbb Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 31 Jan 2017 10:36:53 +0100 Subject: [PATCH] wxPasswordCredentialsPanel<> split to wxIdentityCredentialsPanel<> and wxPasswordCredentialsPanel<> to provide support for identity-only credentials (i.e. EAP-GTC). --- lib/EAPBase_UI/include/EAP_UI.h | 83 ++++-- lib/EAPBase_UI/res/wxEAP_UI.cpp | 49 ++++ lib/EAPBase_UI/res/wxEAP_UI.fbp | 440 ++++++++++++++++++++++++++++++++ lib/EAPBase_UI/res/wxEAP_UI.h | 22 ++ 4 files changed, 577 insertions(+), 17 deletions(-) diff --git a/lib/EAPBase_UI/include/EAP_UI.h b/lib/EAPBase_UI/include/EAP_UI.h index 2e46b17..aa12149 100644 --- a/lib/EAPBase_UI/include/EAP_UI.h +++ b/lib/EAPBase_UI/include/EAP_UI.h @@ -43,6 +43,7 @@ class wxEAPProviderIDPanel; class wxEAPConfigProvider; template class wxEAPCredentialsConfigPanel; template class wxEAPCredentialsPanel; +template class wxIdentityCredentialsPanel; template class wxPasswordCredentialsPanel; class wxEAPProviderSelectDialog; @@ -945,14 +946,14 @@ protected: /// -/// Generic password credential entry panel +/// Generic identity credential entry panel /// template -class wxPasswordCredentialsPanel : public wxEAPCredentialsPanel<_Tcred, _Tbase> +class wxIdentityCredentialsPanel : public wxEAPCredentialsPanel<_Tcred, _Tbase> { public: /// - /// Constructs a password credentials panel + /// Constructs a identity credentials panel /// /// \param[in] prov Provider configuration data /// \param[in] cfg Method configuration data @@ -960,8 +961,7 @@ public: /// \param[in] parent Parent window /// \param[in] is_config Is this panel used to config credentials? /// - wxPasswordCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, wxWindow* parent, bool is_config = false) : - m_password_set(false), + wxIdentityCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, wxWindow* parent, bool is_config = false) : wxEAPCredentialsPanel<_Tcred, _Tbase>(prov, cfg, cred, parent, is_config) { // Load and set icon. @@ -981,11 +981,6 @@ public: layout = true; } - if (!m_prov.m_lbl_alt_password.empty()) { - m_password_label->SetLabel(m_prov.m_lbl_alt_password); - layout = true; - } - if (layout) this->Layout(); } @@ -997,26 +992,80 @@ protected: { m_identity->SetValue(m_cred.m_identity); m_identity->SetSelection(0, -1); - m_password->SetValue(m_cred.m_password.empty() ? wxEmptyString : wxT("dummypass")); - m_password_set = false; if (!m_is_config && m_cfg.m_use_cred) { // Credential prompt mode & Using configured credentials m_identity_label->Enable(false); m_identity ->Enable(false); - m_password_label->Enable(false); - m_password ->Enable(false); } - return wxEAPCredentialsPanel<_Tcred, wxPasswordCredentialsPanelBase>::TransferDataToWindow(); + return wxEAPCredentialsPanel<_Tcred, _Tbase>::TransferDataToWindow(); } virtual bool TransferDataFromWindow() { - if (!wxEAPCredentialsPanel<_Tcred, wxPasswordCredentialsPanelBase>::TransferDataFromWindow()) + if (!wxEAPCredentialsPanel<_Tcred, _Tbase>::TransferDataFromWindow()) return false; m_cred.m_identity = m_identity->GetValue(); + + return true; + } + + /// \endcond +}; + +/// @} + + +/// +/// Generic password credential entry panel +/// +template +class wxPasswordCredentialsPanel : public wxIdentityCredentialsPanel<_Tcred, _Tbase> +{ +public: + /// + /// Constructs a password credentials panel + /// + /// \param[in] prov Provider configuration data + /// \param[in] cfg Method configuration data + /// \param[inout] cred Credentials data + /// \param[in] parent Parent window + /// \param[in] is_config Is this panel used to config credentials? + /// + wxPasswordCredentialsPanel(const eap::config_provider &prov, const eap::config_method_with_cred &cfg, _Tcred &cred, wxWindow* parent, bool is_config = false) : + m_password_set(false), + wxIdentityCredentialsPanel<_Tcred, _Tbase>(prov, cfg, cred, parent, is_config) + { + if (!m_prov.m_lbl_alt_password.empty()) { + m_password_label->SetLabel(m_prov.m_lbl_alt_password); + this->Layout(); + } + } + +protected: + /// \cond internal + + virtual bool TransferDataToWindow() + { + m_password->SetValue(m_cred.m_password.empty() ? wxEmptyString : wxT("dummypass")); + m_password_set = false; + + if (!m_is_config && m_cfg.m_use_cred) { + // Credential prompt mode & Using configured credentials + m_password_label->Enable(false); + m_password ->Enable(false); + } + + return wxIdentityCredentialsPanel<_Tcred, _Tbase>::TransferDataToWindow(); + } + + virtual bool TransferDataFromWindow() + { + if (!wxIdentityCredentialsPanel<_Tcred, _Tbase>::TransferDataFromWindow()) + return false; + if (m_password_set) m_cred.m_password = m_password->GetValue(); @@ -1025,7 +1074,7 @@ protected: virtual void OnPasswordText(wxCommandEvent& event) { - wxEAPCredentialsPanel<_Tcred, _Tbase>::OnPasswordText(event); + wxIdentityCredentialsPanel<_Tcred, _Tbase>::OnPasswordText(event); m_password_set = true; } diff --git a/lib/EAPBase_UI/res/wxEAP_UI.cpp b/lib/EAPBase_UI/res/wxEAP_UI.cpp index ea70d69..ea764d1 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.cpp +++ b/lib/EAPBase_UI/res/wxEAP_UI.cpp @@ -418,6 +418,55 @@ wxPasswordCredentialsPanelBase::~wxPasswordCredentialsPanelBase() } +wxIdentityCredentialsPanelBase::wxIdentityCredentialsPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxEAPCredentialsPanelBase( parent, id, pos, size, style ) +{ + m_sb_credentials = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User ID") ), wxVERTICAL ); + + wxBoxSizer* sb_credentials_horiz; + sb_credentials_horiz = new wxBoxSizer( wxHORIZONTAL ); + + m_credentials_icon = new wxStaticBitmap( m_sb_credentials->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); + sb_credentials_horiz->Add( m_credentials_icon, 0, wxALL, 5 ); + + m_sb_credentials_vert = new wxBoxSizer( wxVERTICAL ); + + m_credentials_label = new wxStaticText( m_sb_credentials->GetStaticBox(), wxID_ANY, _("Please provide your user ID."), wxDefaultPosition, wxDefaultSize, 0 ); + m_credentials_label->Wrap( 440 ); + m_sb_credentials_vert->Add( m_credentials_label, 0, wxALL|wxEXPAND, 5 ); + + wxFlexGridSizer* sb_credentials_tbl; + sb_credentials_tbl = new wxFlexGridSizer( 0, 2, 5, 5 ); + sb_credentials_tbl->AddGrowableCol( 1 ); + sb_credentials_tbl->SetFlexibleDirection( wxBOTH ); + sb_credentials_tbl->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_identity_label = new wxStaticText( m_sb_credentials->GetStaticBox(), wxID_ANY, _("User ID:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_identity_label->Wrap( -1 ); + sb_credentials_tbl->Add( m_identity_label, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_identity = new wxTextCtrl( m_sb_credentials->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_identity->SetToolTip( _("Enter your user name here (user@domain.org, DOMAIN\\User, etc.)") ); + + sb_credentials_tbl->Add( m_identity, 2, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + + + m_sb_credentials_vert->Add( sb_credentials_tbl, 0, wxEXPAND|wxALL, 5 ); + + + sb_credentials_horiz->Add( m_sb_credentials_vert, 1, wxEXPAND, 5 ); + + + m_sb_credentials->Add( sb_credentials_horiz, 0, wxEXPAND, 5 ); + + + this->SetSizer( m_sb_credentials ); + this->Layout(); +} + +wxIdentityCredentialsPanelBase::~wxIdentityCredentialsPanelBase() +{ +} + wxEAPProviderContactInfoPanelBase::wxEAPProviderContactInfoPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) { wxStaticBoxSizer* sb_provider_contact; diff --git a/lib/EAPBase_UI/res/wxEAP_UI.fbp b/lib/EAPBase_UI/res/wxEAP_UI.fbp index 9d38348..50959be 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.fbp +++ b/lib/EAPBase_UI/res/wxEAP_UI.fbp @@ -3116,6 +3116,446 @@ + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + wxIdentityCredentialsPanelBase + + 500,-1 + wxEAPCredentialsPanelBase; ../include/wxEAP_UIBase.h + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + wxID_ANY + User ID + + m_sb_credentials + wxVERTICAL + protected + + + 5 + wxEXPAND + 0 + + + sb_credentials_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_credentials_icon + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + m_sb_credentials_vert + wxVERTICAL + protected + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Please provide your user ID. + + 0 + + + 0 + + 1 + m_credentials_label + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + 440 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + 2 + wxBOTH + 1 + + 5 + + sb_credentials_tbl + wxFLEX_GROWMODE_SPECIFIED + none + 0 + 5 + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + User ID: + + 0 + + + 0 + + 1 + m_identity_label + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALIGN_CENTER_VERTICAL + 2 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_identity + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Enter your user name here (user@domain.org, DOMAIN\User, etc.) + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 wxAUI_MGR_DEFAULT diff --git a/lib/EAPBase_UI/res/wxEAP_UI.h b/lib/EAPBase_UI/res/wxEAP_UI.h index 183ebdc..5953cd5 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.h +++ b/lib/EAPBase_UI/res/wxEAP_UI.h @@ -222,6 +222,28 @@ class wxPasswordCredentialsPanelBase : public wxEAPCredentialsPanelBase }; +/////////////////////////////////////////////////////////////////////////////// +/// Class wxIdentityCredentialsPanelBase +/////////////////////////////////////////////////////////////////////////////// +class wxIdentityCredentialsPanelBase : public wxEAPCredentialsPanelBase +{ + private: + + protected: + wxStaticBoxSizer* m_sb_credentials; + wxStaticBitmap* m_credentials_icon; + wxBoxSizer* m_sb_credentials_vert; + wxStaticText* m_credentials_label; + wxStaticText* m_identity_label; + wxTextCtrl* m_identity; + + public: + + wxIdentityCredentialsPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,-1 ), long style = wxTAB_TRAVERSAL ); + ~wxIdentityCredentialsPanelBase(); + +}; + /////////////////////////////////////////////////////////////////////////////// /// Class wxEAPProviderContactInfoPanelBase ///////////////////////////////////////////////////////////////////////////////