From dd3da2f41aafb72ed45f963c420236db3801459b Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 1 Feb 2017 14:33:12 +0100 Subject: [PATCH] EAP-GTC response panel and dialog finished --- lib/GTC_UI/include/GTC_UI.h | 31 +++++++++++++++++++++++- lib/GTC_UI/src/GTC_UI.cpp | 47 +++++++++++++++++++++++++++++++++---- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/lib/GTC_UI/include/GTC_UI.h b/lib/GTC_UI/include/GTC_UI.h index 6f231bd..5505aae 100644 --- a/lib/GTC_UI/include/GTC_UI.h +++ b/lib/GTC_UI/include/GTC_UI.h @@ -22,6 +22,7 @@ #include "../../GTC/include/Config.h" class wxGTCConfigPanel; +class wxGTCResponseDialog; class wxGTCResponsePanel; /// \addtogroup EAPBaseGUI @@ -46,6 +47,8 @@ typedef wxEAPCredentialsConfigPanel #include +#include + #include @@ -78,6 +81,19 @@ protected: }; +/// +/// GTC challenge/response dialog +/// +class wxGTCResponseDialog : public wxEAPGeneralDialog +{ +public: + /// + /// Constructs a credential dialog + /// + wxGTCResponseDialog(const eap::config_provider &prov, wxWindow *parent, wxWindowID id = wxID_ANY, const wxString &title = _("GTC Challenge"), const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE); +}; + + /// /// GTC challenge/response panel /// @@ -87,7 +103,20 @@ public: /// /// Constructs a panel /// - wxGTCResponsePanel(const eap::config_provider &prov, eap::config_method_eapgtc &cfg, wxWindow* parent); + /// \param[inout] response GTC response + /// \param[in ] challenge GTC challenge + /// \param[in ] parent Parent window + /// + wxGTCResponsePanel(winstd::sanitizing_wstring &response, const wchar_t *challenge, wxWindow* parent); + +protected: + /// \cond internal + virtual bool TransferDataToWindow(); + virtual bool TransferDataFromWindow(); + /// \endcond + +protected: + winstd::sanitizing_wstring &m_response_value; ///< GTC response }; /// @} diff --git a/lib/GTC_UI/src/GTC_UI.cpp b/lib/GTC_UI/src/GTC_UI.cpp index 5405b25..cf80f93 100644 --- a/lib/GTC_UI/src/GTC_UI.cpp +++ b/lib/GTC_UI/src/GTC_UI.cpp @@ -58,17 +58,56 @@ void wxGTCConfigPanel::OnInitDialog(wxInitDialogEvent& event) /// \endcond +////////////////////////////////////////////////////////////////////// +// wxGTCResponseDialog +////////////////////////////////////////////////////////////////////// + +wxGTCResponseDialog::wxGTCResponseDialog(const eap::config_provider &prov, wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style) : + wxEAPGeneralDialog(parent, id, title, pos, size, style) +{ + // Set banner title. + m_banner->m_title->SetLabel(wxString::Format(_("%s Challenge"), wxEAPGetProviderName(prov.m_name))); +} + + ////////////////////////////////////////////////////////////////////// // wxGTCResponsePanel ////////////////////////////////////////////////////////////////////// -wxGTCResponsePanel::wxGTCResponsePanel(const eap::config_provider &prov, eap::config_method_eapgtc &cfg, wxWindow* parent) : wxGTCResponsePanelBase(parent) +wxGTCResponsePanel::wxGTCResponsePanel(winstd::sanitizing_wstring &response, const wchar_t *challenge, wxWindow* parent) : + wxGTCResponsePanelBase(parent), + m_response_value(response) { - UNREFERENCED_PARAMETER(prov); - UNREFERENCED_PARAMETER(cfg); - // Load and set icon. winstd::library lib_shell32; if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE)) m_response_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(24))); + + // Set challenge label. + m_challenge->SetLabelText(challenge); + m_challenge->Wrap(200); + + this->Layout(); } + + +/// \cond internal + +bool wxGTCResponsePanel::TransferDataToWindow() +{ + m_response->SetValue(m_response_value.c_str()); + + return wxGTCResponsePanelBase::TransferDataToWindow(); +} + + +bool wxGTCResponsePanel::TransferDataFromWindow() +{ + wxCHECK(wxGTCResponsePanelBase::TransferDataFromWindow(), false); + + m_response_value = m_response->GetValue(); + + return true; +} + +/// \endcond