From 279c99fdf829884b8a544441d0a2cd09e9c8dd27 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 8 Mar 2015 20:08:16 +0100 Subject: Linux/MacOSX: Load preferences if only volume path is given in command line and GUI mode enabled. --- src/Main/CommandLineInterface.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/Main/CommandLineInterface.cpp') diff --git a/src/Main/CommandLineInterface.cpp b/src/Main/CommandLineInterface.cpp index fd164474..82a99e7f 100644 --- a/src/Main/CommandLineInterface.cpp +++ b/src/Main/CommandLineInterface.cpp @@ -17,7 +17,7 @@ namespace VeraCrypt { - CommandLineInterface::CommandLineInterface (wxCmdLineParser &parser, UserInterfaceType::Enum interfaceType) : + CommandLineInterface::CommandLineInterface (int argc, wchar_t** argv, UserInterfaceType::Enum interfaceType) : ArgCommand (CommandId::None), ArgFilesystem (VolumeCreationOptions::FilesystemType::Unknown), ArgNoHiddenVolumeProtection (false), @@ -26,6 +26,9 @@ namespace VeraCrypt ArgTrueCryptMode (false), StartBackgroundTask (false) { + wxCmdLineParser parser; + parser.SetCmdLine (argc, argv); + parser.SetSwitchChars (L"-"); parser.AddOption (L"", L"auto-mount", _("Auto mount device-hosted/favorite volumes")); @@ -475,6 +478,22 @@ namespace VeraCrypt // Parameters if (parser.GetParamCount() > 0) { + // in case of GUI interface, we load the preference when only + // specifying volume path without any option/switch + if (Application::GetUserInterfaceType() != UserInterfaceType::Text) + { + // check if only parameters were specified in the command line + // (e.g. when associating .hc extension in mimetype with /usr/bin/veracrypt) + bool onlyParametersPresent = (parser.GetParamCount() == (size_t) (argc - 1)); + + if (onlyParametersPresent) + { + // no options/switches, so we load prefences now + Preferences.Load(); + ArgMountOptions = Preferences.DefaultMountOptions; + } + } + if (ArgCommand == CommandId::None) { ArgCommand = CommandId::MountVolume; -- cgit v1.2.3