Simplify UI flow
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
b2d939011f
commit
24a02e5adf
@ -117,8 +117,6 @@ void eap::peer_ttls_ui::invoke_config_ui(
|
|||||||
// This is a blank network profile. `cfg` is already set to defaults.
|
// This is a blank network profile. `cfg` is already set to defaults.
|
||||||
}
|
}
|
||||||
|
|
||||||
int result;
|
|
||||||
{
|
|
||||||
// Initialize application.
|
// Initialize application.
|
||||||
wxInitializerPeer init(m_instance, hwndParent);
|
wxInitializerPeer init(m_instance, hwndParent);
|
||||||
|
|
||||||
@ -128,10 +126,7 @@ void eap::peer_ttls_ui::invoke_config_ui(
|
|||||||
FLASHWINFO fwi = { sizeof(FLASHWINFO), dlg.GetHWND(), FLASHW_ALL | FLASHW_TIMERNOFG };
|
FLASHWINFO fwi = { sizeof(FLASHWINFO), dlg.GetHWND(), FLASHW_ALL | FLASHW_TIMERNOFG };
|
||||||
::FlashWindowEx(&fwi);
|
::FlashWindowEx(&fwi);
|
||||||
}
|
}
|
||||||
result = dlg.ShowModal();
|
if (dlg.ShowModal() != wxID_OK)
|
||||||
}
|
|
||||||
|
|
||||||
if (result != wxID_OK)
|
|
||||||
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
||||||
|
|
||||||
// Pack new configuration.
|
// Pack new configuration.
|
||||||
@ -150,9 +145,6 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
_Out_ DWORD *pdwUserDataOutSize,
|
_Out_ DWORD *pdwUserDataOutSize,
|
||||||
_Out_ LPWSTR *ppwszIdentity)
|
_Out_ LPWSTR *ppwszIdentity)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
|
||||||
//::Sleep(10000);
|
|
||||||
#endif
|
|
||||||
assert(ppwszIdentity);
|
assert(ppwszIdentity);
|
||||||
|
|
||||||
// Unpack configuration.
|
// Unpack configuration.
|
||||||
@ -173,8 +165,6 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
config_provider *cfg_prov = NULL;
|
config_provider *cfg_prov = NULL;
|
||||||
config_method_ttls *cfg_method = NULL;
|
config_method_ttls *cfg_method = NULL;
|
||||||
|
|
||||||
int result;
|
|
||||||
{
|
|
||||||
// Initialize application.
|
// Initialize application.
|
||||||
wxInitializerPeer init(m_instance, hwndParent);
|
wxInitializerPeer init(m_instance, hwndParent);
|
||||||
|
|
||||||
@ -188,21 +178,21 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
FLASHWINFO fwi = { sizeof(FLASHWINFO), dlg.GetHWND(), FLASHW_ALL | FLASHW_TIMERNOFG };
|
FLASHWINFO fwi = { sizeof(FLASHWINFO), dlg.GetHWND(), FLASHW_ALL | FLASHW_TIMERNOFG };
|
||||||
::FlashWindowEx(&fwi);
|
::FlashWindowEx(&fwi);
|
||||||
}
|
}
|
||||||
if ((result = dlg.ShowModal()) == wxID_OK) {
|
if (dlg.ShowModal() != wxID_OK)
|
||||||
|
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
||||||
|
|
||||||
cfg_prov = dlg.GetSelection();
|
cfg_prov = dlg.GetSelection();
|
||||||
assert(cfg_prov);
|
assert(cfg_prov);
|
||||||
}
|
|
||||||
} else if (!cfg.m_providers.empty()) {
|
} else if (!cfg.m_providers.empty()) {
|
||||||
// Single identity provider. No need to ask user to select one.
|
// Single identity provider. No need to ask user to select one.
|
||||||
result = wxID_OK;
|
|
||||||
cfg_prov = &cfg.m_providers.front();
|
cfg_prov = &cfg.m_providers.front();
|
||||||
} else {
|
} else {
|
||||||
// No identity provider. Bail out.
|
// No identity provider. Bail out.
|
||||||
result = wxID_CANCEL;
|
throw invalid_argument(__FUNCTION__ " Configuration has no identity providers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg_prov) {
|
|
||||||
// The identity provider is selected.
|
// 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_ttls*>(cfg_prov->m_methods.front().get());
|
||||||
assert(cfg_method);
|
assert(cfg_method);
|
||||||
|
|
||||||
@ -254,7 +244,9 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
FLASHWINFO fwi = { sizeof(FLASHWINFO), dlg.GetHWND(), FLASHW_ALL | FLASHW_TIMERNOFG };
|
FLASHWINFO fwi = { sizeof(FLASHWINFO), dlg.GetHWND(), FLASHW_ALL | FLASHW_TIMERNOFG };
|
||||||
::FlashWindowEx(&fwi);
|
::FlashWindowEx(&fwi);
|
||||||
}
|
}
|
||||||
if ((result = dlg.ShowModal()) == wxID_OK) {
|
if (dlg.ShowModal() != wxID_OK)
|
||||||
|
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
||||||
|
|
||||||
if (panel->GetRemember()) {
|
if (panel->GetRemember()) {
|
||||||
// Write credentials to credential manager.
|
// Write credentials to credential manager.
|
||||||
try {
|
try {
|
||||||
@ -266,10 +258,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
result = wxID_OK;
|
|
||||||
|
|
||||||
if (result == wxID_OK) {
|
|
||||||
// Combine inner credentials.
|
// Combine inner credentials.
|
||||||
eap::credentials::source_t src_inner = cred->m_inner->combine(
|
eap::credentials::source_t src_inner = cred->m_inner->combine(
|
||||||
dwFlags,
|
dwFlags,
|
||||||
@ -326,7 +315,9 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
FLASHWINFO fwi = { sizeof(FLASHWINFO), dlg.GetHWND(), FLASHW_ALL | FLASHW_TIMERNOFG };
|
FLASHWINFO fwi = { sizeof(FLASHWINFO), dlg.GetHWND(), FLASHW_ALL | FLASHW_TIMERNOFG };
|
||||||
::FlashWindowEx(&fwi);
|
::FlashWindowEx(&fwi);
|
||||||
}
|
}
|
||||||
if ((result = dlg.ShowModal()) == wxID_OK) {
|
if (dlg.ShowModal() != wxID_OK)
|
||||||
|
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
||||||
|
|
||||||
// Write credentials to credential manager.
|
// Write credentials to credential manager.
|
||||||
if (panel->GetRemember()) {
|
if (panel->GetRemember()) {
|
||||||
try {
|
try {
|
||||||
@ -338,7 +329,6 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#if EAP_INNER_EAPHOST
|
#if EAP_INNER_EAPHOST
|
||||||
else {
|
else {
|
||||||
// EapHost inner method
|
// EapHost inner method
|
||||||
@ -358,7 +348,6 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
get_ptr(identity),
|
get_ptr(identity),
|
||||||
get_ptr(error),
|
get_ptr(error),
|
||||||
NULL);
|
NULL);
|
||||||
result = dwResult == ERROR_SUCCESS ? wxID_OK : wxID_CANCEL;
|
|
||||||
if (dwResult == ERROR_SUCCESS) {
|
if (dwResult == ERROR_SUCCESS) {
|
||||||
// Inner EAP method provided credentials.
|
// Inner EAP method provided credentials.
|
||||||
cred_inner->m_identity = identity.get();
|
cred_inner->m_identity = identity.get();
|
||||||
@ -369,20 +358,17 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
// TODO: If we ever choose to store EapHost credentials to Windows Credential Manager, add a "Save credentials? Yes/No" prompt here and write them to Credential Manager.
|
// TODO: If we ever choose to store EapHost credentials to Windows Credential Manager, add a "Save credentials? Yes/No" prompt here and write them to Credential Manager.
|
||||||
} else if (dwResult == ERROR_CANCELLED) {
|
} else if (dwResult == ERROR_CANCELLED) {
|
||||||
// Not really an error.
|
// Not really an error.
|
||||||
} else if (error)
|
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
||||||
|
} else if (error) {
|
||||||
wxLogError(_("Invoking EAP identity UI failed (error %u, %s, %s)."), error->dwWinError, error->pRootCauseString, error->pRepairString);
|
wxLogError(_("Invoking EAP identity UI failed (error %u, %s, %s)."), error->dwWinError, error->pRootCauseString, error->pRepairString);
|
||||||
else
|
throw eap_runtime_error(*error , __FUNCTION__ " EapHostPeerInvokeIdentityUI failed.");
|
||||||
|
} else {
|
||||||
wxLogError(_("Invoking EAP identity UI failed (error %u)."), dwResult);
|
wxLogError(_("Invoking EAP identity UI failed (error %u)."), dwResult);
|
||||||
|
throw win_runtime_error(dwResult, __FUNCTION__ " EapHostPeerInvokeIdentityUI failed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else
|
|
||||||
result = wxID_OK;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result != wxID_OK)
|
|
||||||
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
|
||||||
|
|
||||||
// Build our identity. ;)
|
// Build our identity. ;)
|
||||||
wstring identity(std::move(cfg_method->get_public_identity(*dynamic_cast<const credentials_ttls*>(cred_out.m_cred.get()))));
|
wstring identity(std::move(cfg_method->get_public_identity(*dynamic_cast<const credentials_ttls*>(cred_out.m_cred.get()))));
|
||||||
@ -430,8 +416,6 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
|
|||||||
auto cfg_inner_eaphost = dynamic_cast<config_method_eaphost*>(cfg_method->m_inner.get());
|
auto cfg_inner_eaphost = dynamic_cast<config_method_eaphost*>(cfg_method->m_inner.get());
|
||||||
if (!cfg_inner_eaphost)
|
if (!cfg_inner_eaphost)
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
int result;
|
|
||||||
{
|
{
|
||||||
// Initialize application.
|
// Initialize application.
|
||||||
wxInitializerPeer init(m_instance, hwndParent);
|
wxInitializerPeer init(m_instance, hwndParent);
|
||||||
@ -455,17 +439,14 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
|
|||||||
FLASHWINFO fwi = { sizeof(FLASHWINFO), dlg.GetHWND(), FLASHW_ALL | FLASHW_TIMERNOFG };
|
FLASHWINFO fwi = { sizeof(FLASHWINFO), dlg.GetHWND(), FLASHW_ALL | FLASHW_TIMERNOFG };
|
||||||
::FlashWindowEx(&fwi);
|
::FlashWindowEx(&fwi);
|
||||||
}
|
}
|
||||||
if ((result = dlg.ShowModal()) == wxID_OK) {
|
if (dlg.ShowModal() != wxID_OK)
|
||||||
|
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
||||||
|
|
||||||
// Save response.
|
// Save response.
|
||||||
ctx.m_data.assign(
|
ctx.m_data.assign(
|
||||||
reinterpret_cast<sanitizing_blob::const_pointer>(response.data() ),
|
reinterpret_cast<sanitizing_blob::const_pointer>(response.data() ),
|
||||||
reinterpret_cast<sanitizing_blob::const_pointer>(response.data() + response.length()));
|
reinterpret_cast<sanitizing_blob::const_pointer>(response.data() + response.length()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (result != wxID_OK)
|
|
||||||
throw win_runtime_error(ERROR_CANCELLED, __FUNCTION__ " Cancelled.");
|
|
||||||
}
|
|
||||||
#if EAP_INNER_EAPHOST
|
#if EAP_INNER_EAPHOST
|
||||||
else {
|
else {
|
||||||
// EapHost inner method
|
// EapHost inner method
|
||||||
|
Loading…
x
Reference in New Issue
Block a user