config_method_ttls: Split to make reusable

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
2020-01-14 15:30:14 +01:00
parent a943a14d0f
commit 248e15641a
10 changed files with 195 additions and 88 deletions

View File

@@ -54,7 +54,7 @@ public:
///
/// Constructs a configuration panel
///
wxTTLSConfigPanel(const eap::config_provider &prov, eap::config_method_ttls &cfg, wxWindow* parent);
wxTTLSConfigPanel(const eap::config_provider &prov, eap::config_method_tls_tunnel &cfg, wxWindow* parent);
protected:
/// \cond internal
@@ -65,7 +65,7 @@ protected:
protected:
const eap::config_provider &m_prov; ///< EAP provider
eap::config_method_ttls &m_cfg; ///< TTLS configuration
eap::config_method_tls_tunnel &m_cfg; ///< TLS tunnel configuration
};

View File

@@ -157,7 +157,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
credentials_connection cred_out(*this, cfg);
config_provider *cfg_prov = NULL;
config_method_ttls *cfg_method = NULL;
config_method_tls_tunnel *cfg_method = NULL;
// Initialize application.
wxInitializerPeer init(m_instance, wxT("EAP-TTLS_UI"), hwndParent);
@@ -188,7 +188,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
// The identity provider is selected.
assert(cfg_prov);
cfg_method = dynamic_cast<config_method_ttls*>(cfg_prov->m_methods.front().get());
cfg_method = dynamic_cast<config_method_tls_tunnel*>(cfg_prov->m_methods.front().get());
assert(cfg_method);
// Configure output credentials.
@@ -393,7 +393,7 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
// Look-up the provider.
config_provider *cfg_prov;
config_method_ttls *cfg_method;
config_method_tls_tunnel *cfg_method;
for (auto _cfg_prov = cfg.m_providers.begin(), cfg_prov_end = cfg.m_providers.end();; ++_cfg_prov) {
if (_cfg_prov != cfg_prov_end) {
if (cred.match(*_cfg_prov)) {
@@ -401,7 +401,7 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
if (_cfg_prov->m_methods.empty())
throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", _cfg_prov->get_id().c_str()));
cfg_prov = &*_cfg_prov;
cfg_method = dynamic_cast<config_method_ttls*>(_cfg_prov->m_methods.front().get());
cfg_method = dynamic_cast<config_method_tls_tunnel*>(_cfg_prov->m_methods.front().get());
break;
}
} else

View File

@@ -25,7 +25,7 @@
// wxTTLSConfigPanel
//////////////////////////////////////////////////////////////////////
wxTTLSConfigPanel::wxTTLSConfigPanel(const eap::config_provider &prov, eap::config_method_ttls &cfg, wxWindow* parent) :
wxTTLSConfigPanel::wxTTLSConfigPanel(const eap::config_provider &prov, eap::config_method_tls_tunnel &cfg, wxWindow* parent) :
m_prov(prov),
m_cfg(cfg),
wxTTLSConfigPanelBase(parent)
@@ -143,7 +143,7 @@ wxTTLSConfigWindow::wxTTLSConfigWindow(eap::config_provider &prov, eap::config_m
m_outer_title->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVECAPTION ) );
sb_content->Add(m_outer_title, 0, wxALL|wxALIGN_RIGHT, FromDIP(5));
m_outer_identity = new wxTTLSConfigPanel(m_prov, dynamic_cast<eap::config_method_ttls&>(m_cfg), this);
m_outer_identity = new wxTTLSConfigPanel(m_prov, dynamic_cast<eap::config_method_tls_tunnel&>(m_cfg), this);
sb_content->Add(m_outer_identity, 0, wxALL|wxEXPAND, FromDIP(5));
m_tls = new wxTLSConfigPanel(m_prov, dynamic_cast<eap::config_method_tls&>(m_cfg), this);
@@ -177,7 +177,7 @@ wxTTLSConfigWindow::~wxTTLSConfigWindow()
bool wxTTLSConfigWindow::TransferDataToWindow()
{
auto &cfg_ttls = dynamic_cast<eap::config_method_ttls&>(m_cfg);
auto &cfg_ttls = dynamic_cast<eap::config_method_tls_tunnel&>(m_cfg);
// Native inner methods
switch (cfg_ttls.m_inner->get_method_id()) {
@@ -220,7 +220,7 @@ bool wxTTLSConfigWindow::TransferDataFromWindow()
{
wxCHECK(wxScrolledWindow::TransferDataFromWindow(), false);
auto &cfg_ttls = dynamic_cast<eap::config_method_ttls&>(m_cfg);
auto &cfg_ttls = dynamic_cast<eap::config_method_tls_tunnel&>(m_cfg);
if (!m_prov.m_read_only) {
// This is not a provider-locked configuration. Save the data.