EAP-GTC response panel and dialog finished

This commit is contained in:
Simon Rozman 2017-02-01 14:33:12 +01:00
parent 6f3aa650b6
commit dd3da2f41a
2 changed files with 73 additions and 5 deletions

View File

@ -22,6 +22,7 @@
#include "../../GTC/include/Config.h"
class wxGTCConfigPanel;
class wxGTCResponseDialog;
class wxGTCResponsePanel;
/// \addtogroup EAPBaseGUI
@ -46,6 +47,8 @@ typedef wxEAPCredentialsConfigPanel<eap::credentials_identity, wxGTCCredentialsP
#include <wx/panel.h>
#include <wx/stattext.h>
#include <string>
#include <Windows.h>
@ -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
};
/// @}

View File

@ -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