diff options
Diffstat (limited to 'src/Main/GraphicUserInterface.cpp')
-rw-r--r--[-rwxr-xr-x] | src/Main/GraphicUserInterface.cpp | 161 |
1 files changed, 130 insertions, 31 deletions
diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp index 2a3b2cdf..16db8f83 100755..100644 --- a/src/Main/GraphicUserInterface.cpp +++ b/src/Main/GraphicUserInterface.cpp @@ -37,6 +37,11 @@ namespace VeraCrypt { +#ifdef TC_MACOSX + int GraphicUserInterface::g_customIdCmdV = 0; + int GraphicUserInterface::g_customIdCmdA = 0; +#endif + GraphicUserInterface::GraphicUserInterface () : ActiveFrame (nullptr), BackgroundMode (false), @@ -51,7 +56,9 @@ namespace VeraCrypt #endif #ifdef TC_MACOSX - wxApp::s_macHelpMenuTitleName = _("&Help"); + g_customIdCmdV = wxNewId(); + g_customIdCmdA = wxNewId(); + wxApp::s_macHelpMenuTitleName = LangString["MENU_HELP"]; #endif } @@ -184,8 +191,8 @@ namespace VeraCrypt options->Password, options->Pim, options->Kdf, - false, options->Keyfiles, + options->EMVSupportEnabled, options->Protection, options->ProtectionPassword, options->ProtectionPim, @@ -201,7 +208,42 @@ namespace VeraCrypt } catch (PasswordException &e) { - ShowWarning (e); + bool bFailed = true; + if (!options->UseBackupHeaders) + { + try + { + OpenVolumeThreadRoutine routine2( + options->Path, + options->PreserveTimestamps, + options->Password, + options->Pim, + options->Kdf, + options->Keyfiles, + options->EMVSupportEnabled, + options->Protection, + options->ProtectionPassword, + options->ProtectionPim, + options->ProtectionKdf, + options->ProtectionKeyfiles, + true, + volumeType, + true + ); + + ExecuteWaitThreadRoutine (parent, &routine2); + volume = routine2.m_pVolume; + bFailed = false; + } + catch (...) + { + } + } + + if (bFailed) + ShowWarning (e); + else + ShowWarning ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK"); } } @@ -273,7 +315,7 @@ namespace VeraCrypt // Re-encrypt volume header SecureBuffer newHeaderBuffer (normalVolume->GetLayout()->GetHeaderSize()); - ReEncryptHeaderThreadRoutine routine(newHeaderBuffer, normalVolume->GetHeader(), normalVolumeMountOptions.Password, normalVolumeMountOptions.Pim, normalVolumeMountOptions.Keyfiles); + ReEncryptHeaderThreadRoutine routine(newHeaderBuffer, normalVolume->GetHeader(), normalVolumeMountOptions.Password, normalVolumeMountOptions.Pim, normalVolumeMountOptions.Keyfiles, normalVolumeMountOptions.EMVSupportEnabled); ExecuteWaitThreadRoutine (parent, &routine); @@ -282,7 +324,7 @@ namespace VeraCrypt if (hiddenVolume) { // Re-encrypt hidden volume header - ReEncryptHeaderThreadRoutine hiddenRoutine(newHeaderBuffer, hiddenVolume->GetHeader(), hiddenVolumeMountOptions.Password, hiddenVolumeMountOptions.Pim, hiddenVolumeMountOptions.Keyfiles); + ReEncryptHeaderThreadRoutine hiddenRoutine(newHeaderBuffer, hiddenVolume->GetHeader(), hiddenVolumeMountOptions.Password, hiddenVolumeMountOptions.Pim, hiddenVolumeMountOptions.Keyfiles, hiddenVolumeMountOptions.EMVSupportEnabled); ExecuteWaitThreadRoutine (parent, &hiddenRoutine); } @@ -302,7 +344,7 @@ namespace VeraCrypt void GraphicUserInterface::BeginInteractiveBusyState (wxWindow *window) { - static auto_ptr <wxCursor> arrowWaitCursor; + static unique_ptr <wxCursor> arrowWaitCursor; if (arrowWaitCursor.get() == nullptr) arrowWaitCursor.reset (new wxCursor (wxCURSOR_ARROWWAIT)); @@ -367,7 +409,7 @@ namespace VeraCrypt void GraphicUserInterface::EndInteractiveBusyState (wxWindow *window) const { - static auto_ptr <wxCursor> arrowCursor; + static unique_ptr <wxCursor> arrowCursor; if (arrowCursor.get() == nullptr) arrowCursor.reset (new wxCursor (wxCURSOR_ARROW)); @@ -424,7 +466,7 @@ namespace VeraCrypt } else { - wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), _("Enter your user password or administrator password:"), _("Administrator privileges required")); + 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(); @@ -590,7 +632,7 @@ namespace VeraCrypt try { - SecurityToken::InitLibrary (Preferences.SecurityTokenModule, auto_ptr <GetPinFunctor> (new PinRequestHandler), auto_ptr <SendExceptionFunctor> (new WarningHandler)); + SecurityToken::InitLibrary (Preferences.SecurityTokenModule, unique_ptr <GetPinFunctor> (new PinRequestHandler), unique_ptr <SendExceptionFunctor> (new WarningHandler)); } catch (Exception &e) { @@ -635,11 +677,21 @@ namespace VeraCrypt return true; } - void GraphicUserInterface::ListSecurityTokenKeyfiles () const + void GraphicUserInterface::ListTokenKeyfiles () const { SecurityTokenKeyfilesDialog dialog (nullptr); dialog.ShowModal(); } + void GraphicUserInterface::ListSecurityTokenKeyfiles () const + { + SecurityTokenKeyfilesDialog dialog (nullptr); + dialog.ShowModal(); + } + void GraphicUserInterface::ListEMVTokenKeyfiles () const + { + SecurityTokenKeyfilesDialog dialog (nullptr); + dialog.ShowModal(); + } #ifdef TC_MACOSX void GraphicUserInterface::MacOpenFiles (const wxArrayString &fileNames) @@ -657,6 +709,41 @@ namespace VeraCrypt { SetBackgroundMode (false); } + + bool GraphicUserInterface::HandlePasswordEntryCustomEvent (wxEvent& event) + { + bool bHandled = false; + if ( (event.GetEventType() == wxEVT_MENU) + && ((event.GetId() == g_customIdCmdV) || (event.GetId() == g_customIdCmdA))) + { + wxWindow* focusedCtrl = wxWindow::FindFocus(); + if (focusedCtrl + && (focusedCtrl->IsKindOf(wxCLASSINFO(wxTextCtrl))) + && (focusedCtrl->GetWindowStyle() & wxTE_PASSWORD)) + { + wxTextCtrl* passwordCtrl = (wxTextCtrl*) focusedCtrl; + if (event.GetId() == g_customIdCmdV) + passwordCtrl->Paste (); + else if (event.GetId() == g_customIdCmdA) + passwordCtrl->SelectAll (); + bHandled = true; + } + } + + return bHandled; + } + + void GraphicUserInterface::InstallPasswordEntryCustomKeyboardShortcuts (wxWindow* window) + { + // we manually handle CMD+V and CMD+A on password fields in order to support + // pasting password values into them. By default, wxWidgets doesn't handle this + // for password entry fields. + wxAcceleratorEntry entries[2]; + entries[0].Set(wxACCEL_CMD, (int) 'V', g_customIdCmdV); + entries[1].Set(wxACCEL_CMD, (int) 'A', g_customIdCmdA); + wxAcceleratorTable accel(sizeof(entries) / sizeof(wxAcceleratorEntry), entries); + window->SetAcceleratorTable(accel); + } #endif void GraphicUserInterface::MoveListCtrlItem (wxListCtrl *listCtrl, long itemIndex, long newItemIndex) const @@ -746,7 +833,7 @@ namespace VeraCrypt options.Keyfiles = make_shared <KeyfileList> (GetPreferences().DefaultKeyfiles); if ((options.Password && !options.Password->IsEmpty()) - || (options.Keyfiles && !options.Keyfiles->empty() && (options.TrueCryptMode || options.Password))) + || (options.Keyfiles && !options.Keyfiles->empty() && options.Password)) { try { @@ -808,7 +895,7 @@ namespace VeraCrypt #ifdef TC_LINUX if (volume && !Preferences.NonInteractive && !Preferences.DisableKernelEncryptionModeWarning && volume->EncryptionModeName != L"XTS" - && !AskYesNo (LangString["ENCRYPTION_MODE_NOT_SUPPORTED_BY_KERNEL"] + _("\n\nDo you want to show this message next time you mount such a volume?"), true, true)) + && !AskYesNo (LangString["ENCRYPTION_MODE_NOT_SUPPORTED_BY_KERNEL"] + LangString["LINUX_MESSAGE_ON_MOUNT_AGAIN"], true, true)) { UserPreferences prefs = GetPreferences(); prefs.DisableKernelEncryptionModeWarning = true; @@ -888,8 +975,8 @@ namespace VeraCrypt wxConnectionBase *OnMakeConnection () { return new Connection; } }; - auto_ptr <wxDDEClient> client (new Client); - auto_ptr <wxConnectionBase> connection (client->MakeConnection (L"localhost", serverName, L"raise")); + unique_ptr <wxDDEClient> client (new Client); + unique_ptr <wxConnectionBase> connection (client->MakeConnection (L"localhost", serverName, L"raise")); if (connection.get() && connection->Execute (nullptr)) { @@ -909,7 +996,7 @@ namespace VeraCrypt if (write (showFifo, buf, 1) == 1) { close (showFifo); - Gui->ShowInfo (_("VeraCrypt is already running.")); + Gui->ShowInfo (LangString["LINUX_VC_RUNNING_ALREADY"]); Application::SetExitCode (0); return false; } @@ -941,7 +1028,7 @@ namespace VeraCrypt wxLog::FlushActive(); Application::SetExitCode (1); - Gui->ShowInfo (_("VeraCrypt is already running.")); + Gui->ShowInfo (LangString["LINUX_VC_RUNNING_ALREADY"]); return false; #endif } @@ -1232,7 +1319,7 @@ namespace VeraCrypt #elif defined (TC_MACOSX) htmlPath += L"/../Resources/doc/HTML/"; #elif defined (TC_UNIX) - htmlPath = L"/usr/share/veracrypt/doc/HTML/"; + htmlPath = L"/usr/share/doc/veracrypt/HTML/"; #else localFile = false; #endif @@ -1240,7 +1327,14 @@ namespace VeraCrypt { /* check if local file exists */ wxFileName htmlFile = htmlPath + url; - htmlFile.Normalize(); + htmlFile.Normalize ( + wxPATH_NORM_ENV_VARS | + wxPATH_NORM_DOTS | + wxPATH_NORM_CASE | + wxPATH_NORM_LONG | + wxPATH_NORM_SHORTCUT | + wxPATH_NORM_TILDE + ); localFile = htmlFile.FileExists(); } @@ -1370,8 +1464,8 @@ namespace VeraCrypt options.Password, options.Pim, options.Kdf, - options.TrueCryptMode, options.Keyfiles, + options.EMVSupportEnabled, options.Protection, options.ProtectionPassword, options.ProtectionPim, @@ -1404,7 +1498,7 @@ namespace VeraCrypt // Re-encrypt volume header wxBusyCursor busy; SecureBuffer newHeaderBuffer (volume->GetLayout()->GetHeaderSize()); - ReEncryptHeaderThreadRoutine routine(newHeaderBuffer, volume->GetHeader(), options.Password, options.Pim, options.Keyfiles); + ReEncryptHeaderThreadRoutine routine(newHeaderBuffer, volume->GetHeader(), options.Password, options.Pim, options.Keyfiles, options.EMVSupportEnabled); ExecuteWaitThreadRoutine (parent, &routine); @@ -1485,12 +1579,12 @@ namespace VeraCrypt backupFile.ReadAt (headerBuffer, layout->GetType() == VolumeType::Hidden ? layout->GetHeaderSize() : 0); // Decrypt header - shared_ptr <VolumePassword> passwordKey = Keyfile::ApplyListToPassword (options.Keyfiles, options.Password); - Pkcs5KdfList keyDerivationFunctions = layout->GetSupportedKeyDerivationFunctions(options.TrueCryptMode); + shared_ptr <VolumePassword> passwordKey = Keyfile::ApplyListToPassword (options.Keyfiles, options.Password, options.EMVSupportEnabled); + Pkcs5KdfList keyDerivationFunctions = layout->GetSupportedKeyDerivationFunctions(); EncryptionAlgorithmList encryptionAlgorithms = layout->GetSupportedEncryptionAlgorithms(); EncryptionModeList encryptionModes = layout->GetSupportedEncryptionModes(); - DecryptThreadRoutine decryptRoutine(layout->GetHeader(), headerBuffer, *passwordKey, options.Pim, options.Kdf, options.TrueCryptMode, keyDerivationFunctions, encryptionAlgorithms, encryptionModes); + DecryptThreadRoutine decryptRoutine(layout->GetHeader(), headerBuffer, *passwordKey, options.Pim, options.Kdf, keyDerivationFunctions, encryptionAlgorithms, encryptionModes); ExecuteWaitThreadRoutine (parent, &decryptRoutine); @@ -1519,7 +1613,7 @@ namespace VeraCrypt // Re-encrypt volume header wxBusyCursor busy; SecureBuffer newHeaderBuffer (decryptedLayout->GetHeaderSize()); - ReEncryptHeaderThreadRoutine routine(newHeaderBuffer, decryptedLayout->GetHeader(), options.Password, options.Pim, options.Keyfiles); + ReEncryptHeaderThreadRoutine routine(newHeaderBuffer, decryptedLayout->GetHeader(), options.Password, options.Pim, options.Keyfiles, options.EMVSupportEnabled); ExecuteWaitThreadRoutine (parent, &routine); @@ -1535,7 +1629,7 @@ namespace VeraCrypt if (decryptedLayout->HasBackupHeader()) { // Re-encrypt backup volume header - ReEncryptHeaderThreadRoutine backupRoutine(newHeaderBuffer, decryptedLayout->GetHeader(), options.Password, options.Pim, options.Keyfiles); + ReEncryptHeaderThreadRoutine backupRoutine(newHeaderBuffer, decryptedLayout->GetHeader(), options.Password, options.Pim, options.Keyfiles, options.EMVSupportEnabled); ExecuteWaitThreadRoutine (parent, &backupRoutine); @@ -1650,7 +1744,7 @@ namespace VeraCrypt FilePath GraphicUserInterface::SelectVolumeFile (wxWindow *parent, bool saveMode, const DirectoryPath &directory) const { list < pair <wstring, wstring> > extensions; - extensions.push_back (make_pair (L"tc", LangString["TC_VOLUMES"].ToStdWstring())); + extensions.push_back (make_pair (L"hc", LangString["TC_VOLUMES"].ToStdWstring())); FilePathList selFiles = Gui->SelectFiles (parent, LangString[saveMode ? "OPEN_NEW_VOLUME" : "OPEN_VOL_TITLE"], saveMode, false, extensions, directory); @@ -1677,6 +1771,10 @@ namespace VeraCrypt } BackgroundMode = state; + +#ifdef HAVE_INDICATORS + gtk_menu_item_set_label ((GtkMenuItem*) ((MainFrame*) mMainFrame)->indicator_item_showhide, LangString[Gui->IsInBackgroundMode() ? "SHOW_TC" : "HIDE_TC"].mb_str()); +#endif } void GraphicUserInterface::SetListCtrlColumnWidths (wxListCtrl *listCtrl, list <int> columnWidthPermilles, bool hasVerticalScrollbar) const @@ -1810,9 +1908,9 @@ namespace VeraCrypt else { if (style & wxICON_EXCLAMATION) - caption = wxString (_("Warning")) + L':'; + caption = wxString (LangString["LINUX_WARNING"]) + L':'; else if (style & wxICON_ERROR || style & wxICON_HAND) - caption = wxString (_("Error")) + L':'; + caption = wxString (LangString["LINUX_ERROR"]) + L':'; else caption.clear(); } @@ -1830,8 +1928,9 @@ namespace VeraCrypt style |= wxSTAY_ON_TOP; } - - return wxMessageBox (subMessage, caption, style, GetActiveWindow()); + wxMessageDialog cur(GetActiveWindow(), subMessage, caption, style); + cur.SetYesNoLabels(LangString["UISTR_YES"], LangString["UISTR_NO"]); + return (cur.ShowModal() == wxID_YES ? wxYES : wxNO) ; } } @@ -1846,7 +1945,7 @@ namespace VeraCrypt void GraphicUserInterface::ThrowTextModeRequired () const { - Gui->ShowError (_("This feature is currently supported only in text mode.")); + Gui->ShowError (LangString["LINUX_ONLY_TEXTMODE"]); throw UserAbort (SRC_POS); } |