1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 19:08:26 -06:00

Linux: Make the C++ code compatible with old compilers (g++ 4.4.7 on CentOS 6)

This commit is contained in:
Mounir IDRASSI
2024-06-30 01:22:05 +02:00
parent 1e7d6948c9
commit 9697416919
13 changed files with 138 additions and 130 deletions

View File

@@ -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 <GetStringFunctor> 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 <GetStringFunctor> (new AdminPasswordRequestHandler);
}