Credential UI revised to honor read-only, allow-save, and config/prompt mode correctly

This commit is contained in:
2016-08-03 12:34:49 +02:00
parent 2868fd3848
commit cadf7272df
9 changed files with 162 additions and 126 deletions

View File

@@ -149,70 +149,3 @@ bool wxEAPProviderLockedPanel::AcceptsFocusFromKeyboard() const
{
return !m_prov.m_help_email.empty() || !m_prov.m_help_web.empty() || !m_prov.m_help_phone.empty();
}
//////////////////////////////////////////////////////////////////////
// wxPasswordCredentialsPanel
//////////////////////////////////////////////////////////////////////
wxPasswordCredentialsPanel::wxPasswordCredentialsPanel(const eap::config_provider &prov, const eap::config_method &cfg, eap::credentials &cred, LPCTSTR pszCredTarget, wxWindow* parent, bool is_config) :
m_cred((eap::credentials_pass&)cred),
wxEAPCredentialsPanelBase<wxEAPCredentialsPanelPassBase>(prov, cfg, cred, pszCredTarget, parent, is_config)
{
// Load and set icon.
if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE))
wxSetIconFromResource(m_credentials_icon, m_icon, m_shell32, MAKEINTRESOURCE(269));
bool layout = false;
if (!m_prov.m_lbl_alt_credential.empty()) {
m_credentials_label->SetLabel(m_prov.m_lbl_alt_credential);
m_credentials_label->Wrap( 446 );
layout = true;
}
if (!m_prov.m_lbl_alt_identity.empty()) {
m_identity_label->SetLabel(m_prov.m_lbl_alt_identity);
layout = true;
}
if (!m_prov.m_lbl_alt_password.empty()) {
m_password_label->SetLabel(m_prov.m_lbl_alt_password);
layout = true;
}
if (layout)
this->Layout();
}
bool wxPasswordCredentialsPanel::TransferDataToWindow()
{
// Inherited TransferDataToWindow() calls m_cred.retrieve().
// Therefore, call it now, to set m_cred.
wxCHECK(wxEAPCredentialsPanelBase<wxEAPCredentialsPanelPassBase>::TransferDataToWindow(), false);
m_identity->SetValue(m_cred.m_identity);
m_identity->SetSelection(0, -1);
m_password->SetValue(m_cred.m_password.empty() ? wxEmptyString : s_dummy_password);
return true;
}
bool wxPasswordCredentialsPanel::TransferDataFromWindow()
{
m_cred.m_identity = m_identity->GetValue();
wxString pass = m_password->GetValue();
if (pass.compare(s_dummy_password) != 0) {
m_cred.m_password = pass;
pass.assign(pass.length(), wxT('*'));
}
// Inherited TransferDataFromWindow() calls m_cred.store().
// Therefore, call it only now, that m_cred is set.
return wxEAPCredentialsPanelBase<wxEAPCredentialsPanelPassBase>::TransferDataFromWindow();
}
const wxStringCharType *wxPasswordCredentialsPanel::s_dummy_password = wxT("dummypass");