From 96974169199d347172fc5d4a2924f092d602b3de Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 30 Jun 2024 01:22:05 +0200 Subject: Linux: Make the C++ code compatible with old compilers (g++ 4.4.7 on CentOS 6) --- src/Main/GraphicUserInterface.cpp | 53 ++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'src/Main/GraphicUserInterface.cpp') diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp index af2db217..0fd756a3 100644 --- a/src/Main/GraphicUserInterface.cpp +++ b/src/Main/GraphicUserInterface.cpp @@ -37,6 +37,33 @@ namespace VeraCrypt { + class AdminPasswordRequestHandler : public GetStringFunctor + { + public: + virtual void operator() (string &passwordStr) + { + + wxString sValue; + if (Gui->GetWaitDialog()) + { + Gui->GetWaitDialog()->RequestAdminPassword(sValue); + if (sValue.IsEmpty()) + throw UserAbort (SRC_POS); + } + else + { + wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]); + if (dialog.ShowModal() != wxID_OK) + throw UserAbort (SRC_POS); + sValue = dialog.GetValue(); + } + wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased + finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); }); + + StringConverter::ToSingle (wPassword, passwordStr); + } + }; + #ifdef TC_MACOSX int GraphicUserInterface::g_customIdCmdV = 0; int GraphicUserInterface::g_customIdCmdA = 0; @@ -452,32 +479,6 @@ namespace VeraCrypt shared_ptr GraphicUserInterface::GetAdminPasswordRequestHandler () { - struct AdminPasswordRequestHandler : public GetStringFunctor - { - virtual void operator() (string &passwordStr) - { - - wxString sValue; - if (Gui->GetWaitDialog()) - { - Gui->GetWaitDialog()->RequestAdminPassword(sValue); - if (sValue.IsEmpty()) - throw UserAbort (SRC_POS); - } - else - { - wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]); - if (dialog.ShowModal() != wxID_OK) - throw UserAbort (SRC_POS); - sValue = dialog.GetValue(); - } - wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased - finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); }); - - StringConverter::ToSingle (wPassword, passwordStr); - } - }; - return shared_ptr (new AdminPasswordRequestHandler); } -- cgit v1.2.3