|
37 | 37 |
|
38 | 38 | namespace VeraCrypt
|
39 | 39 | {
|
| 40 | + class AdminPasswordGUIRequestHandler : public GetStringFunctor |
| 41 | + { |
| 42 | + public: |
| 43 | + virtual void operator() (string &passwordStr) |
| 44 | + { |
| 45 | + |
| 46 | + wxString sValue; |
| 47 | + if (Gui->GetWaitDialog()) |
| 48 | + { |
| 49 | + Gui->GetWaitDialog()->RequestAdminPassword(sValue); |
| 50 | + if (sValue.IsEmpty()) |
| 51 | + throw UserAbort (SRC_POS); |
| 52 | + } |
| 53 | + else |
| 54 | + { |
| 55 | + wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]); |
| 56 | + if (dialog.ShowModal() != wxID_OK) |
| 57 | + throw UserAbort (SRC_POS); |
| 58 | + sValue = dialog.GetValue(); |
| 59 | + } |
| 60 | + wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased |
| 61 | + finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); }); |
| 62 | + |
| 63 | + StringConverter::ToSingle (wPassword, passwordStr); |
| 64 | + } |
| 65 | + }; |
40 | 66 | #ifdef TC_MACOSX
|
41 | 67 | int GraphicUserInterface::g_customIdCmdV = 0;
|
42 | 68 | int GraphicUserInterface::g_customIdCmdA = 0;
|
@@ -452,33 +478,7 @@ namespace VeraCrypt
|
452 | 478 |
|
453 | 479 | shared_ptr <GetStringFunctor> GraphicUserInterface::GetAdminPasswordRequestHandler ()
|
454 | 480 | {
|
455 |
| - class AdminPasswordRequestHandler : public GetStringFunctor |
456 |
| - { |
457 |
| - public: |
458 |
| - virtual void operator() (string &passwordStr) |
459 |
| - { |
460 |
| - |
461 |
| - wxString sValue; |
462 |
| - if (Gui->GetWaitDialog()) |
463 |
| - { |
464 |
| - Gui->GetWaitDialog()->RequestAdminPassword(sValue); |
465 |
| - if (sValue.IsEmpty()) |
466 |
| - throw UserAbort (SRC_POS); |
467 |
| - } |
468 |
| - else |
469 |
| - { |
470 |
| - wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]); |
471 |
| - if (dialog.ShowModal() != wxID_OK) |
472 |
| - throw UserAbort (SRC_POS); |
473 |
| - sValue = dialog.GetValue(); |
474 |
| - } |
475 |
| - wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased |
476 |
| - finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); }); |
477 |
| - |
478 |
| - StringConverter::ToSingle (wPassword, passwordStr); |
479 |
| - } |
480 |
| - }; |
481 |
| - return shared_ptr <GetStringFunctor> (new AdminPasswordRequestHandler); |
| 481 | + return shared_ptr <GetStringFunctor> (new AdminPasswordGUIRequestHandler); |
482 | 482 | }
|
483 | 483 |
|
484 | 484 | int GraphicUserInterface::GetCharHeight (wxWindow *window) const
|
|
0 commit comments