wxInitializerPeer: Move upstream and make reusable
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
c4fc8d184a
commit
6addc49df2
@ -91,7 +91,7 @@
|
|||||||
<PropertyGroup />
|
<PropertyGroup />
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;..\..\wxExtend\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||||
|
@ -46,6 +46,7 @@ template <class _Tcred, class _Tbase> class wxEAPCredentialsPanel;
|
|||||||
template <class _Tcred, class _Tbase> class wxIdentityCredentialsPanel;
|
template <class _Tcred, class _Tbase> class wxIdentityCredentialsPanel;
|
||||||
template <class _Tcred, class _Tbase> class wxPasswordCredentialsPanel;
|
template <class _Tcred, class _Tbase> class wxPasswordCredentialsPanel;
|
||||||
class wxEAPProviderSelectDialog;
|
class wxEAPProviderSelectDialog;
|
||||||
|
class wxInitializerPeer;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// \defgroup EAPBaseGUI GUI
|
/// \defgroup EAPBaseGUI GUI
|
||||||
@ -121,7 +122,9 @@ inline void wxInitializeConfig();
|
|||||||
#include <WinStd/Win.h>
|
#include <WinStd/Win.h>
|
||||||
|
|
||||||
#include <wx/config.h>
|
#include <wx/config.h>
|
||||||
|
#include <wx/intl.h>
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
|
#include <wx/thread.h>
|
||||||
|
|
||||||
#include <CommCtrl.h>
|
#include <CommCtrl.h>
|
||||||
|
|
||||||
@ -409,6 +412,32 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Peer initializer
|
||||||
|
///
|
||||||
|
class wxInitializerPeer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
/// Initialize peer
|
||||||
|
///
|
||||||
|
wxInitializerPeer(_In_ HINSTANCE instance, _In_ const wxString &domain, _In_opt_ HWND hwndParent);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Uninitialize peer
|
||||||
|
///
|
||||||
|
virtual ~wxInitializerPeer();
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxWindow* m_parent; ///< Parent window
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static wxCriticalSection s_lock; ///< Initialization lock
|
||||||
|
static unsigned long s_init_ref_count; ///< Initialization reference counter
|
||||||
|
static wxLocale *s_locale; ///< Locale
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// EAP general note
|
/// EAP general note
|
||||||
///
|
///
|
||||||
@ -1028,8 +1057,6 @@ protected:
|
|||||||
/// \endcond
|
/// \endcond
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @}
|
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Generic password credential entry panel
|
/// Generic password credential entry panel
|
||||||
|
@ -467,3 +467,62 @@ void wxEAPProviderSelectDialog::OnProvSelect(wxCommandEvent& event)
|
|||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
/// \endcond
|
/// \endcond
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// wxInitializerPeer
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
wxInitializerPeer::wxInitializerPeer(_In_ HINSTANCE instance, _In_ const wxString &domain, _In_opt_ HWND hwndParent)
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker locker(s_lock);
|
||||||
|
|
||||||
|
if (s_init_ref_count++ == 0) {
|
||||||
|
// Initialize application.
|
||||||
|
new wxApp();
|
||||||
|
wxEntryStart(instance);
|
||||||
|
|
||||||
|
// Do our wxWidgets configuration and localization initialization.
|
||||||
|
wxInitializeConfig();
|
||||||
|
s_locale = new wxLocale;
|
||||||
|
if (wxInitializeLocale(*s_locale)) {
|
||||||
|
s_locale->AddCatalog(wxT("wxExtend") wxT(wxExtendVersion));
|
||||||
|
if (!domain.IsEmpty())
|
||||||
|
s_locale->AddCatalog(domain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hwndParent) {
|
||||||
|
// Create wxWidget-approved parent window.
|
||||||
|
m_parent = new wxWindow;
|
||||||
|
m_parent->SetHWND((WXHWND)hwndParent);
|
||||||
|
m_parent->AdoptAttributesFromHWND();
|
||||||
|
wxTopLevelWindows.Append(m_parent);
|
||||||
|
} else
|
||||||
|
m_parent = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxInitializerPeer::~wxInitializerPeer()
|
||||||
|
{
|
||||||
|
wxCriticalSectionLocker locker(s_lock);
|
||||||
|
|
||||||
|
if (m_parent) {
|
||||||
|
wxTopLevelWindows.DeleteObject(m_parent);
|
||||||
|
m_parent->SetHWND((WXHWND)NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (--s_init_ref_count == 0) {
|
||||||
|
wxEntryCleanup();
|
||||||
|
|
||||||
|
if (s_locale) {
|
||||||
|
delete s_locale;
|
||||||
|
s_locale = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxCriticalSection wxInitializerPeer::s_lock;
|
||||||
|
unsigned long wxInitializerPeer::s_init_ref_count = 0;
|
||||||
|
wxLocale *wxInitializerPeer::s_locale = NULL;
|
||||||
|
@ -23,4 +23,7 @@
|
|||||||
#include "../include/EAP_UI.h"
|
#include "../include/EAP_UI.h"
|
||||||
#include "../include/Module.h"
|
#include "../include/Module.h"
|
||||||
|
|
||||||
|
#include <wxex/common.h>
|
||||||
|
|
||||||
|
#include <wx/app.h>
|
||||||
#include <wx/commandlinkbutton.h>
|
#include <wx/commandlinkbutton.h>
|
||||||
|
@ -91,7 +91,7 @@
|
|||||||
<PropertyGroup />
|
<PropertyGroup />
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;..\..\wxExtend\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\Events\build\temp\Events.$(Platform).$(Configuration).$(PlatformToolset);..\..\WinStd\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||||
|
@ -24,32 +24,6 @@ using namespace std;
|
|||||||
using namespace winstd;
|
using namespace winstd;
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Peer initializer
|
|
||||||
///
|
|
||||||
class wxInitializerPeer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
///
|
|
||||||
/// Initialize peer
|
|
||||||
///
|
|
||||||
wxInitializerPeer(_In_ HINSTANCE instance, _In_opt_ HWND hwndParent);
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Uninitialize peer
|
|
||||||
///
|
|
||||||
virtual ~wxInitializerPeer();
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxWindow* m_parent; ///< Parent window
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static wxCriticalSection s_lock; ///< Initialization lock
|
|
||||||
static unsigned long s_init_ref_count; ///< Initialization reference counter
|
|
||||||
static wxLocale *s_locale; ///< Locale
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// eap::peer_ttls_ui
|
// eap::peer_ttls_ui
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@ -118,7 +92,7 @@ void eap::peer_ttls_ui::invoke_config_ui(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize application.
|
// Initialize application.
|
||||||
wxInitializerPeer init(m_instance, hwndParent);
|
wxInitializerPeer init(m_instance, wxT("EAP-TTLS_UI"), hwndParent);
|
||||||
|
|
||||||
// Create and launch configuration dialog.
|
// Create and launch configuration dialog.
|
||||||
wxEAPConfigDialog<wxTTLSConfigWindow> dlg(cfg, init.m_parent);
|
wxEAPConfigDialog<wxTTLSConfigWindow> dlg(cfg, init.m_parent);
|
||||||
@ -186,7 +160,7 @@ void eap::peer_ttls_ui::invoke_identity_ui(
|
|||||||
config_method_ttls *cfg_method = NULL;
|
config_method_ttls *cfg_method = NULL;
|
||||||
|
|
||||||
// Initialize application.
|
// Initialize application.
|
||||||
wxInitializerPeer init(m_instance, hwndParent);
|
wxInitializerPeer init(m_instance, wxT("EAP-TTLS_UI"), hwndParent);
|
||||||
|
|
||||||
if (cfg.m_providers.size() > 1) {
|
if (cfg.m_providers.size() > 1) {
|
||||||
// Multiple identity providers: User has to select one first.
|
// Multiple identity providers: User has to select one first.
|
||||||
@ -443,7 +417,7 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Initialize application.
|
// Initialize application.
|
||||||
wxInitializerPeer init(m_instance, hwndParent);
|
wxInitializerPeer init(m_instance, wxT("EAP-TTLS_UI"), hwndParent);
|
||||||
|
|
||||||
sanitizing_wstring
|
sanitizing_wstring
|
||||||
challenge(reinterpret_cast<sanitizing_wstring::const_pointer>(ctx.m_data.data()), ctx.m_data.size()/sizeof(sanitizing_wstring::value_type)),
|
challenge(reinterpret_cast<sanitizing_wstring::const_pointer>(ctx.m_data.data()), ctx.m_data.size()/sizeof(sanitizing_wstring::value_type)),
|
||||||
@ -504,61 +478,3 @@ void eap::peer_ttls_ui::invoke_interactive_ui(
|
|||||||
// Pack output data.
|
// Pack output data.
|
||||||
pack(ctx.m_data, ppDataFromInteractiveUI, pdwDataFromInteractiveUISize);
|
pack(ctx.m_data, ppDataFromInteractiveUI, pdwDataFromInteractiveUISize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// wxInitializerPeer
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
wxInitializerPeer::wxInitializerPeer(_In_ HINSTANCE instance, _In_opt_ HWND hwndParent)
|
|
||||||
{
|
|
||||||
wxCriticalSectionLocker locker(s_lock);
|
|
||||||
|
|
||||||
if (s_init_ref_count++ == 0) {
|
|
||||||
// Initialize application.
|
|
||||||
new wxApp();
|
|
||||||
wxEntryStart(instance);
|
|
||||||
|
|
||||||
// Do our wxWidgets configuration and localization initialization.
|
|
||||||
wxInitializeConfig();
|
|
||||||
s_locale = new wxLocale;
|
|
||||||
if (wxInitializeLocale(*s_locale)) {
|
|
||||||
s_locale->AddCatalog(wxT("wxExtend") wxT(wxExtendVersion));
|
|
||||||
s_locale->AddCatalog(wxT("EAP-TTLS_UI"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hwndParent) {
|
|
||||||
// Create wxWidget-approved parent window.
|
|
||||||
m_parent = new wxWindow;
|
|
||||||
m_parent->SetHWND((WXHWND)hwndParent);
|
|
||||||
m_parent->AdoptAttributesFromHWND();
|
|
||||||
wxTopLevelWindows.Append(m_parent);
|
|
||||||
} else
|
|
||||||
m_parent = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxInitializerPeer::~wxInitializerPeer()
|
|
||||||
{
|
|
||||||
wxCriticalSectionLocker locker(s_lock);
|
|
||||||
|
|
||||||
if (m_parent) {
|
|
||||||
wxTopLevelWindows.DeleteObject(m_parent);
|
|
||||||
m_parent->SetHWND((WXHWND)NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (--s_init_ref_count == 0) {
|
|
||||||
wxEntryCleanup();
|
|
||||||
|
|
||||||
if (s_locale) {
|
|
||||||
delete s_locale;
|
|
||||||
s_locale = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wxCriticalSection wxInitializerPeer::s_lock;
|
|
||||||
unsigned long wxInitializerPeer::s_init_ref_count = 0;
|
|
||||||
wxLocale *wxInitializerPeer::s_locale = NULL;
|
|
||||||
|
@ -34,8 +34,4 @@
|
|||||||
#include "../../EapHost/include/Credentials.h"
|
#include "../../EapHost/include/Credentials.h"
|
||||||
#include "../../TTLS/include/UIContext.h"
|
#include "../../TTLS/include/UIContext.h"
|
||||||
|
|
||||||
#include <wxex/common.h>
|
|
||||||
|
|
||||||
#include <wx/app.h>
|
|
||||||
#include <wx/choicdlg.h>
|
#include <wx/choicdlg.h>
|
||||||
#include <wx/thread.h>
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user