Inner EAP method support progress continues...

This commit is contained in:
Simon Rozman 2016-09-30 15:22:12 +02:00
parent 13d84c3c4d
commit a834fbcb7c
7 changed files with 89 additions and 2 deletions

View File

@ -21,6 +21,11 @@
#include "../../EAPBase_UI/include/EAP_UI.h"
#include "../../EAPMsg/include/Config.h"
///
/// Helper class for auto-destroyable EAP_METHOD_TYPE used in wxWidget's item containers
///
class wxEAPMethodTypeClientData;
///
/// Inner EAP method config panel
///
@ -46,6 +51,20 @@ class wxEAPMsgConfigPanel;
#include <Windows.h>
class wxEAPMethodTypeClientData : public wxClientData
{
public:
///
/// Constructs client data object with existing handle
///
wxEAPMethodTypeClientData(const EAP_METHOD_TYPE &type, DWORD properties);
public:
EAP_METHOD_TYPE m_type; ///< EapHost method type
DWORD m_properties; ///< Method properties
};
class wxEAPMsgMethodConfigPanel : public wxEAPMsgMethodConfigPanelBase
{
public:
@ -57,6 +76,12 @@ public:
/// \param[in ] parent Parent window
///
wxEAPMsgMethodConfigPanel(const eap::config_provider &prov, eap::config_method_eapmsg &cfg, wxWindow *parent);
protected:
/// \cond internal
virtual void OnUpdateUI(wxUpdateUIEvent& event);
virtual void OnSettings(wxCommandEvent& event);
/// \endcond
};

View File

@ -54,12 +54,14 @@ wxEAPMsgMethodConfigPanelBase::wxEAPMsgMethodConfigPanelBase( wxWindow* parent,
this->Layout();
// Connect Events
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPMsgMethodConfigPanelBase::OnUpdateUI ) );
m_settings->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPMsgMethodConfigPanelBase::OnSettings ), NULL, this );
}
wxEAPMsgMethodConfigPanelBase::~wxEAPMsgMethodConfigPanelBase()
{
// Disconnect Events
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( wxEAPMsgMethodConfigPanelBase::OnUpdateUI ) );
m_settings->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxEAPMsgMethodConfigPanelBase::OnSettings ), NULL, this );
}

View File

@ -77,7 +77,7 @@
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<event name="OnUpdateUI">OnUpdateUI</event>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Inner EAP Method</property>

View File

@ -43,6 +43,7 @@ class wxEAPMsgMethodConfigPanelBase : public wxPanel
wxButton* m_settings;
// Virtual event handlers, overide them in your derived class
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnSettings( wxCommandEvent& event ) { event.Skip(); }

View File

@ -20,6 +20,19 @@
#include "StdAfx.h"
#pragma comment(lib, "Eappcfg.lib")
//////////////////////////////////////////////////////////////////////
// wxEAPMsgMethodConfigPanel
//////////////////////////////////////////////////////////////////////
wxEAPMethodTypeClientData::wxEAPMethodTypeClientData(const EAP_METHOD_TYPE &type, DWORD properties) :
m_type(type),
m_properties(properties)
{
}
//////////////////////////////////////////////////////////////////////
// wxEAPMsgMethodConfigPanel
@ -34,6 +47,48 @@ wxEAPMsgMethodConfigPanel::wxEAPMsgMethodConfigPanel(const eap::config_provider
winstd::library lib_shell32;
if (lib_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
m_method_icon->SetIcon(wxLoadIconFromResource(lib_shell32, MAKEINTRESOURCE(175)));
winstd::eap_method_info_array methods;
std::unique_ptr<EAP_ERROR, winstd::EapHostPeerFreeErrorMemory_delete> error;
DWORD dwResult = EapHostPeerGetMethods(&methods, &std::addressof(error)->_Myptr);
if (dwResult == ERROR_SUCCESS) {
for (DWORD i = 0; i < methods.dwNumberOfMethods; i++)
m_method->Append(methods.pEapMethods[i].pwszFriendlyName, new wxEAPMethodTypeClientData(methods.pEapMethods[i].eaptype, methods.pEapMethods[i].eapProperties));
} else if (error)
wxLogError(_("Enumerating EAP methods failed (error %u, %s, %s)."), error->dwWinError, error->pRootCauseString, error->pRepairString);
else
wxLogError(_("Enumerating EAP methods failed (error %u)."), dwResult);
}
void wxEAPMsgMethodConfigPanel::OnUpdateUI(wxUpdateUIEvent& event)
{
wxEAPMsgMethodConfigPanelBase::OnUpdateUI(event);
int sel = m_method->GetSelection();
const wxEAPMethodTypeClientData *data =
sel != wxNOT_FOUND && m_method->HasClientObjectData() ?
dynamic_cast<const wxEAPMethodTypeClientData*>(m_method->GetClientObject(sel)) :
NULL;
m_settings->Enable(data && (data->m_properties & eapPropSupportsConfig));
}
void wxEAPMsgMethodConfigPanel::OnSettings(wxCommandEvent& event)
{
wxEAPMsgMethodConfigPanelBase::OnSettings(event);
int sel = m_method->GetSelection();
const wxEAPMethodTypeClientData *data =
sel != wxNOT_FOUND && m_method->HasClientObjectData() ?
dynamic_cast<const wxEAPMethodTypeClientData*>(m_method->GetClientObject(sel)) :
NULL;
if (data && (data->m_properties & eapPropSupportsConfig)) {
DWORD cfg_data_size = 0;
std::unique_ptr<BYTE[], winstd::EapHostPeerFreeMemory_delete> cfg_data;
std::unique_ptr<EAP_ERROR, winstd::EapHostPeerFreeErrorMemory_delete> error;
DWORD dwResult = EapHostPeerInvokeConfigUI(GetHWND(), 0, data->m_type, 0, NULL, &cfg_data_size, &std::addressof(cfg_data)->_Myptr, &std::addressof(error)->_Myptr);
}
}

View File

@ -23,3 +23,7 @@
#define _CRT_SECURE_NO_WARNINGS // Prevent warnings from wxWidgets headers
#include "../include/EAPMsg_UI.h"
#include <WinStd/EAP.h>
#include <eaphostpeerconfigapis.h>

@ -1 +1 @@
Subproject commit d02935808605803b51b6b533b9943bf1e3d370a4
Subproject commit 129b9c9a10c2145235e8f447706875dcafa4a4a3