diff --git a/lib/EAPBase/include/Config.h b/lib/EAPBase/include/Config.h index d0c76d8..a36510f 100644 --- a/lib/EAPBase/include/Config.h +++ b/lib/EAPBase/include/Config.h @@ -453,6 +453,9 @@ namespace eap m_read_only(other.m_read_only), m_id(other.m_id), m_name(other.m_name), + m_help_email(other.m_help_email), + m_help_web(other.m_help_web), + m_help_phone(other.m_help_phone), m_lbl_alt_credential(other.m_lbl_alt_credential), m_lbl_alt_identity(other.m_lbl_alt_identity), m_lbl_alt_password(other.m_lbl_alt_password), @@ -470,6 +473,9 @@ namespace eap m_read_only(std::move(other.m_read_only)), m_id(std::move(other.m_id)), m_name(std::move(other.m_name)), + m_help_email(std::move(other.m_help_email)), + m_help_web(std::move(other.m_help_web)), + m_help_phone(std::move(other.m_help_phone)), m_lbl_alt_credential(std::move(other.m_lbl_alt_credential)), m_lbl_alt_identity(std::move(other.m_lbl_alt_identity)), m_lbl_alt_password(std::move(other.m_lbl_alt_password)), @@ -492,6 +498,9 @@ namespace eap m_read_only = other.m_read_only; m_id = other.m_id; m_name = other.m_name; + m_help_email = other.m_help_email; + m_help_web = other.m_help_web; + m_help_phone = other.m_help_phone; m_lbl_alt_credential = other.m_lbl_alt_credential; m_lbl_alt_identity = other.m_lbl_alt_identity; m_lbl_alt_password = other.m_lbl_alt_password; @@ -515,6 +524,9 @@ namespace eap m_read_only = std::move(m_read_only); m_id = std::move(other.m_id); m_name = std::move(other.m_name); + m_help_email = std::move(other.m_help_email); + m_help_web = std::move(other.m_help_web); + m_help_phone = std::move(other.m_help_phone); m_lbl_alt_credential = std::move(other.m_lbl_alt_credential); m_lbl_alt_identity = std::move(other.m_lbl_alt_identity); m_lbl_alt_password = std::move(other.m_lbl_alt_password); @@ -578,6 +590,34 @@ namespace eap return false; } + // / + winstd::com_obj pXmlElHelpdesk; + if ((dwResult = eapxml::create_element(pDoc, pXmlElProviderInfo, winstd::bstr(L"eap-metadata:Helpdesk"), winstd::bstr(L"Helpdesk"), bstrNamespace, &pXmlElHelpdesk)) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return false; + } + + // // + if (!m_help_email.empty()) + if ((dwResult = eapxml::put_element_value(pDoc, pXmlElHelpdesk, winstd::bstr(L"EmailAddress"), bstrNamespace, winstd::bstr(m_help_email))) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return false; + } + + // // + if (!m_help_web.empty()) + if ((dwResult = eapxml::put_element_value(pDoc, pXmlElHelpdesk, winstd::bstr(L"WebAddress"), bstrNamespace, winstd::bstr(m_help_web))) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return false; + } + + // // + if (!m_help_phone.empty()) + if ((dwResult = eapxml::put_element_value(pDoc, pXmlElHelpdesk, winstd::bstr(L"Phone"), bstrNamespace, winstd::bstr(m_help_phone))) != ERROR_SUCCESS) { + *ppEapError = m_module.make_error(dwResult, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" Error creating element."), NULL); + return false; + } + // / if (!m_lbl_alt_credential.empty()) if ((dwResult = eapxml::put_element_value(pDoc, pXmlElProviderInfo, winstd::bstr(L"CredentialPrompt"), bstrNamespace, winstd::bstr(m_lbl_alt_credential))) != ERROR_SUCCESS) { @@ -656,6 +696,9 @@ namespace eap // m_name.clear(); + m_help_email.clear(); + m_help_web.clear(); + m_help_phone.clear(); m_lbl_alt_credential.clear(); m_lbl_alt_identity.clear(); m_lbl_alt_password.clear(); @@ -664,6 +707,18 @@ namespace eap // eapxml::get_element_localized(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:DisplayName"), lang.c_str(), m_name); + winstd::com_obj pXmlElHelpdesk; + if (eapxml::select_element(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:Helpdesk"), &pXmlElHelpdesk) == ERROR_SUCCESS) { + // / + eapxml::get_element_localized(pXmlElHelpdesk, winstd::bstr(L"eap-metadata:EmailAddress"), lang.c_str(), m_help_email); + + // / + eapxml::get_element_localized(pXmlElHelpdesk, winstd::bstr(L"eap-metadata:WebAddress"), lang.c_str(), m_help_web); + + // / + eapxml::get_element_localized(pXmlElHelpdesk, winstd::bstr(L"eap-metadata:Phone"), lang.c_str(), m_help_phone); + } + // eapxml::get_element_localized(pXmlElProviderInfo, winstd::bstr(L"eap-metadata:CredentialPrompt"), lang.c_str(), m_lbl_alt_credential); @@ -715,6 +770,9 @@ namespace eap bool m_read_only; ///< Is profile read-only std::wstring m_id; ///< Profile ID winstd::tstring m_name; ///< Provider name + winstd::tstring m_help_email; ///< Helpdesk e-mail + winstd::tstring m_help_web; ///< Helpdesk website URL + winstd::tstring m_help_phone; ///< Helpdesk phone winstd::tstring m_lbl_alt_credential; ///< Alternative label for credential prompt winstd::tstring m_lbl_alt_identity; ///< Alternative label for identity prompt winstd::tstring m_lbl_alt_password; ///< Alternative label for password prompt @@ -935,6 +993,9 @@ namespace eapserial pack(cursor, val.m_read_only ); pack(cursor, val.m_id ); pack(cursor, val.m_name ); + pack(cursor, val.m_help_email ); + pack(cursor, val.m_help_web ); + pack(cursor, val.m_help_phone ); pack(cursor, val.m_lbl_alt_credential); pack(cursor, val.m_lbl_alt_identity ); pack(cursor, val.m_lbl_alt_password ); @@ -949,6 +1010,9 @@ namespace eapserial get_pk_size(val.m_read_only ) + get_pk_size(val.m_id ) + get_pk_size(val.m_name ) + + get_pk_size(val.m_help_email ) + + get_pk_size(val.m_help_web ) + + get_pk_size(val.m_help_phone ) + get_pk_size(val.m_lbl_alt_credential) + get_pk_size(val.m_lbl_alt_identity ) + get_pk_size(val.m_lbl_alt_password ) + @@ -962,6 +1026,9 @@ namespace eapserial unpack(cursor, val.m_read_only ); unpack(cursor, val.m_id ); unpack(cursor, val.m_name ); + unpack(cursor, val.m_help_email ); + unpack(cursor, val.m_help_web ); + unpack(cursor, val.m_help_phone ); unpack(cursor, val.m_lbl_alt_credential); unpack(cursor, val.m_lbl_alt_identity ); unpack(cursor, val.m_lbl_alt_password ); diff --git a/lib/EAPBase_UI/include/EAP_UI.h b/lib/EAPBase_UI/include/EAP_UI.h index 4a6ebb3..86c9f76 100644 --- a/lib/EAPBase_UI/include/EAP_UI.h +++ b/lib/EAPBase_UI/include/EAP_UI.h @@ -18,6 +18,7 @@ along with GÉANTLink. If not, see . */ +#include #include #include #include @@ -223,25 +224,106 @@ public: /// /// Constructs a notice pannel and set the title text /// - wxEAPProviderLocked(_Tprov &prov, wxWindow* parent) : wxEAPProviderLockedBase(parent) + wxEAPProviderLocked(_Tprov &prov, wxWindow* parent) : + m_prov(prov), + wxEAPProviderLockedBase(parent) { // Load and set icon. if (m_shell32.load(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE)) wxSetIconFromResource(m_provider_locked_icon, m_icon, m_shell32, MAKEINTRESOURCE(48)); - m_provider_locked_label->SetLabel( - wxString::Format(_("%s has pre-set parts of this configuration. Those parts are locked to prevent accidental modification."), - !prov.m_name.empty() ? prov.m_name.c_str() : - !prov.m_id .empty() ? winstd::string_printf(_("Your %ls provider"), prov.m_id.c_str()).c_str() : _("Your provider"))); + m_provider_locked_label->SetLabel(wxString::Format(_("%s has pre-set parts of this configuration. Those parts are locked to prevent accidental modification."), + !m_prov.m_name.empty() ? m_prov.m_name.c_str() : + !m_prov.m_id .empty() ? winstd::string_printf(_("Your %ls provider"), m_prov.m_id.c_str()).c_str() : _("Your provider"))); m_provider_locked_label->Wrap(452); + + if (!m_prov.m_help_email.empty() || !m_prov.m_help_web.empty() || !m_prov.m_help_phone.empty()) { + wxStaticText *provider_notice = new wxStaticText(this, wxID_ANY, wxString::Format(_("For additional help and instructions, please contact %s at:"), + !m_prov.m_name.empty() ? m_prov.m_name.c_str() : + !m_prov.m_id .empty() ? winstd::string_printf(_("your %ls provider"), m_prov.m_id.c_str()).c_str() : _("your provider")), wxDefaultPosition, wxDefaultSize, 0); + provider_notice->Wrap(452); + m_provider_locked_vert->Add(provider_notice, 0, wxUP|wxLEFT|wxRIGHT|wxEXPAND, 5); + + wxFlexGridSizer* sb_contact_tbl; + sb_contact_tbl = new wxFlexGridSizer(0, 2, 5, 5); + sb_contact_tbl->AddGrowableCol(1); + sb_contact_tbl->SetFlexibleDirection(wxBOTH); + sb_contact_tbl->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); + + wxFont font_wingdings(-1, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Wingdings")); + + if (!m_prov.m_help_web.empty()) { + wxStaticText *label = new wxStaticText(this, wxID_ANY, wxT("\xb6"), wxDefaultPosition, wxDefaultSize, 0); + label->Wrap(-1); + label->SetFont(font_wingdings); + sb_contact_tbl->Add(label, 0, wxEXPAND|wxALIGN_TOP, 5); + + wxHyperlinkCtrl *value = new wxHyperlinkCtrl(this, wxID_ANY, m_prov.m_help_web, m_prov.m_help_web, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + value->SetToolTip(_("Open the default web browser")); + sb_contact_tbl->Add(value, 0, wxEXPAND|wxALIGN_TOP, 5); + } + + if (!m_prov.m_help_email.empty()) { + wxStaticText *label = new wxStaticText(this, wxID_ANY, wxT("\x2a"), wxDefaultPosition, wxDefaultSize, 0); + label->Wrap(-1); + label->SetFont(font_wingdings); + sb_contact_tbl->Add(label, 0, wxEXPAND|wxALIGN_TOP, 5); + + wxHyperlinkCtrl *value = new wxHyperlinkCtrl(this, wxID_ANY, m_prov.m_help_email, wxString(wxT("mailto:")) + m_prov.m_help_email, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + value->SetToolTip(_("Open your e-mail program")); + sb_contact_tbl->Add(value, 0, wxEXPAND|wxALIGN_TOP, 5); + } + + if (!m_prov.m_help_phone.empty()) { + wxStaticText *label = new wxStaticText(this, wxID_ANY, wxT("\x29"), wxDefaultPosition, wxDefaultSize, 0); + label->Wrap(-1); + label->SetFont(font_wingdings); + sb_contact_tbl->Add(label, 0, wxEXPAND|wxALIGN_TOP, 5); + + wxHyperlinkCtrl *value = new wxHyperlinkCtrl(this, wxID_ANY, m_prov.m_help_phone, wxString(wxT("tel:")) + GetPhoneNumber(m_prov.m_help_phone.c_str()), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE); + value->SetToolTip(_("Dial the phone number")); + sb_contact_tbl->Add(value, 0, wxEXPAND|wxALIGN_TOP, 5); + } + + m_provider_locked_vert->Add(sb_contact_tbl, 0, wxLEFT|wxRIGHT|wxDOWN|wxEXPAND, 5); + } + + this->Layout(); } protected: /// \cond internal - virtual bool AcceptsFocusFromKeyboard() const { return false; } + + virtual bool AcceptsFocusFromKeyboard() const + { + return !m_prov.m_help_email.empty() || !m_prov.m_help_web.empty() || !m_prov.m_help_phone.empty(); + } + + template + static std::basic_string<_Elem, _Traits, _Ax> GetPhoneNumber(_In_z_ const _Elem *num) + { + assert(num); + + std::basic_string<_Elem, _Traits, _Ax> str; + for (; *num; num++) { + _Elem c = *num; + if ('0' <= c && c <= '9' || c == '+' || c == '*' || c == '#') + str += c; + } + + return str; + } + + template + static std::basic_string<_Elem, std::char_traits<_Elem>, std::allocator<_Elem> > GetPhoneNumber(_In_z_ const _Elem *num) + { + return GetPhoneNumber<_Elem, std::char_traits<_Elem>, std::allocator<_Elem> >(num); + } + /// \endcond protected: + _Tprov &m_prov; ///< EAP provider winstd::library m_shell32; ///< shell32.dll resource library reference wxIcon m_icon; ///< Panel icon }; diff --git a/lib/EAPBase_UI/res/wxEAP_UI.cpp b/lib/EAPBase_UI/res/wxEAP_UI.cpp index 6082252..44513f0 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.cpp +++ b/lib/EAPBase_UI/res/wxEAP_UI.cpp @@ -129,15 +129,14 @@ wxEAPProviderLockedBase::wxEAPProviderLockedBase( wxWindow* parent, wxWindowID i m_provider_locked_icon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); sb_provider_locked_horiz->Add( m_provider_locked_icon, 0, wxALL, 5 ); - wxBoxSizer* sb_provider_locked_vert; - sb_provider_locked_vert = new wxBoxSizer( wxVERTICAL ); + m_provider_locked_vert = new wxBoxSizer( wxVERTICAL ); m_provider_locked_label = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_provider_locked_label->Wrap( 452 ); - sb_provider_locked_vert->Add( m_provider_locked_label, 0, wxALL|wxEXPAND, 5 ); + m_provider_locked_vert->Add( m_provider_locked_label, 0, wxALL|wxEXPAND, 5 ); - sb_provider_locked_horiz->Add( sb_provider_locked_vert, 1, wxEXPAND, 5 ); + sb_provider_locked_horiz->Add( m_provider_locked_vert, 1, wxEXPAND, 5 ); this->SetSizer( sb_provider_locked_horiz ); diff --git a/lib/EAPBase_UI/res/wxEAP_UI.fbp b/lib/EAPBase_UI/res/wxEAP_UI.fbp index 9498482..8709d28 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.fbp +++ b/lib/EAPBase_UI/res/wxEAP_UI.fbp @@ -767,9 +767,9 @@ 1 - sb_provider_locked_vert + m_provider_locked_vert wxVERTICAL - none + protected 5 wxALL|wxEXPAND diff --git a/lib/EAPBase_UI/res/wxEAP_UI.h b/lib/EAPBase_UI/res/wxEAP_UI.h index 075ccaf..29889c7 100644 --- a/lib/EAPBase_UI/res/wxEAP_UI.h +++ b/lib/EAPBase_UI/res/wxEAP_UI.h @@ -110,6 +110,7 @@ class wxEAPProviderLockedBase : public wxPanel protected: wxStaticBitmap* m_provider_locked_icon; + wxBoxSizer* m_provider_locked_vert; wxStaticText* m_provider_locked_label; public: