VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main')
-rw-r--r--src/Main/CommandLineInterface.cpp69
-rw-r--r--src/Main/FatalErrorHandler.cpp6
-rw-r--r--src/Main/Forms/AboutDialog.cpp4
-rw-r--r--src/Main/Forms/Forms.cpp8
-rw-r--r--src/Main/Forms/Forms.h2
-rw-r--r--src/Main/Forms/MainFrame.cpp70
-rw-r--r--src/Main/Forms/MainFrame.h19
-rw-r--r--src/Main/Forms/TrueCrypt.fbp98
-rw-r--r--src/Main/Forms/VolumeSizeWizardPage.cpp58
-rw-r--r--src/Main/Forms/VolumeSizeWizardPage.h4
-rw-r--r--src/Main/Forms/international.h2
-rw-r--r--[-rwxr-xr-x]src/Main/GraphicUserInterface.cpp6
-rw-r--r--src/Main/LanguageStrings.cpp6
-rwxr-xr-xsrc/Main/Main.make14
-rw-r--r--src/Main/Resources.cpp27
-rw-r--r--src/Main/TextUserInterface.cpp102
-rw-r--r--src/Main/UserInterface.cpp3
17 files changed, 400 insertions, 98 deletions
diff --git a/src/Main/CommandLineInterface.cpp b/src/Main/CommandLineInterface.cpp
index 0ae246c6..865f69dd 100644
--- a/src/Main/CommandLineInterface.cpp
+++ b/src/Main/CommandLineInterface.cpp
@@ -339,7 +339,7 @@ namespace VeraCrypt
ArgFilesystem = VolumeCreationOptions::FilesystemType::UFS;
#endif
else
- ArgFilesystem = VolumeCreationOptions::FilesystemType::None;
+ throw_err (LangString["UNKNOWN_OPTION"] + L": " + str);
}
}
@@ -574,40 +574,45 @@ namespace VeraCrypt
if (parser.Found (L"size", &str))
{
- uint64 multiplier;
- wxChar lastChar = str [str.Length () - 1];
- if (lastChar >= wxT('0') && lastChar <= wxT('9'))
- multiplier = 1;
- else if (lastChar == wxT('K') || lastChar == wxT('k'))
- multiplier = BYTES_PER_KB;
- else if (lastChar == wxT('M') || lastChar == wxT('m'))
- multiplier = BYTES_PER_MB;
- else if (lastChar == wxT('G') || lastChar == wxT('g'))
- multiplier = BYTES_PER_GB;
- else if (lastChar == wxT('T') || lastChar == wxT('t'))
- multiplier = BYTES_PER_TB;
- else
- throw_err (LangString["PARAMETER_INCORRECT"] + L": " + str);
-
- // remove suffix if present
- if (multiplier != 1)
- str.RemoveLast ();
- // check that we only have digits in the string
- size_t index = str.find_first_not_of (wxT("0123456789"));
- if (index != (size_t) wxNOT_FOUND)
+ if (str.CmpNoCase (wxT("max")) == 0)
{
- // restore last characater for error display
- if (multiplier != 1)
- str += lastChar;
- throw_err (LangString["PARAMETER_INCORRECT"] + L": " + str);
+ ArgSize = (uint64) -1; // indicator of maximum available size
}
- try
- {
- ArgSize = multiplier * StringConverter::ToUInt64 (wstring (str));
- }
- catch (...)
+ else
{
- throw_err (LangString["PARAMETER_INCORRECT"] + L": " + str);
+ uint64 multiplier;
+ wxString originalStr = str;
+ size_t index = str.find_first_not_of (wxT("0123456789"));
+ if (index == 0)
+ {
+ throw_err (LangString["PARAMETER_INCORRECT"] + L": " + str);
+ }
+ else if (index != (size_t) wxNOT_FOUND)
+ {
+ wxString sizeSuffix = str.Mid(index);
+ if (sizeSuffix.CmpNoCase(wxT("K")) == 0 || sizeSuffix.CmpNoCase(wxT("KiB")) == 0)
+ multiplier = BYTES_PER_KB;
+ else if (sizeSuffix.CmpNoCase(wxT("M")) == 0 || sizeSuffix.CmpNoCase(wxT("MiB")) == 0)
+ multiplier = BYTES_PER_MB;
+ else if (sizeSuffix.CmpNoCase(wxT("G")) == 0 || sizeSuffix.CmpNoCase(wxT("GiB")) == 0)
+ multiplier = BYTES_PER_GB;
+ else if (sizeSuffix.CmpNoCase(wxT("T")) == 0 || sizeSuffix.CmpNoCase(wxT("TiB")) == 0)
+ multiplier = BYTES_PER_TB;
+ else
+ throw_err (LangString["PARAMETER_INCORRECT"] + L": " + str);
+
+ str = str.Left (index);
+ }
+ else
+ multiplier = 1;
+ try
+ {
+ ArgSize = multiplier * StringConverter::ToUInt64 (wstring (str));
+ }
+ catch (...)
+ {
+ throw_err (LangString["PARAMETER_INCORRECT"] + L": " + originalStr);
+ }
}
}
diff --git a/src/Main/FatalErrorHandler.cpp b/src/Main/FatalErrorHandler.cpp
index 55c989cf..5e391698 100644
--- a/src/Main/FatalErrorHandler.cpp
+++ b/src/Main/FatalErrorHandler.cpp
@@ -25,7 +25,7 @@
#ifdef TC_MACOSX
# include <sys/ucontext.h>
-#elif defined (TC_BSD)
+#elif defined (TC_BSD) && !defined (TC_OPENBSD)
# include <ucontext.h>
#endif
@@ -56,9 +56,13 @@ namespace VeraCrypt
#elif defined (TC_MACOSX)
# ifdef __x86_64__
faultingInstructionAddress = context->uc_mcontext->__ss.__rip;
+# else
+# ifdef __aarch64__
+ faultingInstructionAddress = context->uc_mcontext->__ss.__pc;
# else
faultingInstructionAddress = context->uc_mcontext->__ss.__eip;
# endif
+# endif
#endif
wstringstream vars;
diff --git a/src/Main/Forms/AboutDialog.cpp b/src/Main/Forms/AboutDialog.cpp
index 300db727..1751d8b4 100644
--- a/src/Main/Forms/AboutDialog.cpp
+++ b/src/Main/Forms/AboutDialog.cpp
@@ -57,7 +57,7 @@ namespace VeraCrypt
L"Paulo Barreto, Brian Gladman, Wei Dai, Peter Gutmann, and many others.\n\n"
L"Portions of this software:\n"
- L"Copyright \xA9 2013-2020 IDRIX. All rights reserved.\n"
+ L"Copyright \xA9 2013-2022 IDRIX. All rights reserved.\n"
L"Copyright \xA9 2003-2012 TrueCrypt Developers Association. All Rights Reserved.\n"
L"Copyright \xA9 1998-2000 Paul Le Roux. All Rights Reserved.\n"
L"Copyright \xA9 1998-2008 Brian Gladman. All Rights Reserved.\n"
@@ -69,7 +69,7 @@ namespace VeraCrypt
L"Copyright \xA9 2013-2019 Stephan Mueller <smueller@chronox.de>\n\n"
L"\nThis software as a whole:\n"
- L"Copyright \xA9 2013-2020 IDRIX. All rights reserved.\n\n"
+ L"Copyright \xA9 2013-2022 IDRIX. All rights reserved.\n\n"
L"This software uses wxWidgets library, which is copyright \xA9 1998-2011 Julian Smart, Robert Roebling et al.\n\n"
diff --git a/src/Main/Forms/Forms.cpp b/src/Main/Forms/Forms.cpp
index 0af3e2a6..d281febc 100644
--- a/src/Main/Forms/Forms.cpp
+++ b/src/Main/Forms/Forms.cpp
@@ -3625,6 +3625,12 @@ VolumeSizeWizardPageBase::VolumeSizeWizardPageBase( wxWindow* parent, wxWindowID
bSizer99->Add( 0, 0, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 );
+ UseAllFreeSpaceCheckBox = new wxCheckBox( this, wxID_ANY, _("IDC_USE_ALL_FREE_SPACE"), wxDefaultPosition, wxDefaultSize, 0 );
+ bSizer99->Add( UseAllFreeSpaceCheckBox, 0, wxALL|wxEXPAND, 5 );
+
+
+ bSizer99->Add( 0, 0, 0, wxBOTTOM|wxEXPAND|wxTOP, 5 );
+
FreeSpaceStaticText = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
FreeSpaceStaticText->Wrap( -1 );
@@ -3649,6 +3655,7 @@ VolumeSizeWizardPageBase::VolumeSizeWizardPageBase( wxWindow* parent, wxWindowID
// Connect Events
VolumeSizeTextCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( VolumeSizeWizardPageBase::OnVolumeSizeTextChanged ), NULL, this );
VolumeSizePrefixChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( VolumeSizeWizardPageBase::OnVolumeSizePrefixSelected ), NULL, this );
+ UseAllFreeSpaceCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( VolumeSizeWizardPageBase::OnUseAllFreeSpaceCheckBoxClick ), NULL, this );
}
VolumeSizeWizardPageBase::~VolumeSizeWizardPageBase()
@@ -3656,6 +3663,7 @@ VolumeSizeWizardPageBase::~VolumeSizeWizardPageBase()
// Disconnect Events
VolumeSizeTextCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( VolumeSizeWizardPageBase::OnVolumeSizeTextChanged ), NULL, this );
VolumeSizePrefixChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( VolumeSizeWizardPageBase::OnVolumeSizePrefixSelected ), NULL, this );
+ UseAllFreeSpaceCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( VolumeSizeWizardPageBase::OnUseAllFreeSpaceCheckBoxClick ), NULL, this );
}
diff --git a/src/Main/Forms/Forms.h b/src/Main/Forms/Forms.h
index 3ea89763..b1756876 100644
--- a/src/Main/Forms/Forms.h
+++ b/src/Main/Forms/Forms.h
@@ -1063,12 +1063,14 @@ namespace VeraCrypt
protected:
wxTextCtrl* VolumeSizeTextCtrl;
wxChoice* VolumeSizePrefixChoice;
+ wxCheckBox* UseAllFreeSpaceCheckBox;
wxStaticText* FreeSpaceStaticText;
wxStaticText* InfoStaticText;
// Virtual event handlers, overide them in your derived class
virtual void OnVolumeSizeTextChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void OnVolumeSizePrefixSelected( wxCommandEvent& event ) { event.Skip(); }
+ virtual void OnUseAllFreeSpaceCheckBoxClick( wxCommandEvent& event ) { event.Skip(); }
public:
diff --git a/src/Main/Forms/MainFrame.cpp b/src/Main/Forms/MainFrame.cpp
index b744ebbd..ab42ac06 100644
--- a/src/Main/Forms/MainFrame.cpp
+++ b/src/Main/Forms/MainFrame.cpp
@@ -46,6 +46,9 @@ namespace VeraCrypt
DEFINE_EVENT_TYPE(wxEVT_COMMAND_SHOW_WARNING)
MainFrame::MainFrame (wxWindow* parent) : MainFrameBase (parent),
+#ifdef HAVE_INDICATORS
+ indicator (NULL),
+#endif
ListItemRightClickEventPending (false),
SelectedItemIndex (-1),
SelectedSlotNumber (0),
@@ -282,7 +285,7 @@ namespace VeraCrypt
VolumeStaticBoxSizer->Detach (VolumeGridBagSizer);
VolumeStaticBoxSizer->Add (VolumeGridBagSizer, 1, wxEXPAND, 0);
- ExitButton->SetLabel (LangString["CLOSE"]);
+ ExitButton->SetLabel (LangString["IDCLOSE"]);
MountAllDevicesButton->SetLabel (LangString["LINUX_MOUNT_ALL_DEV"]);
#endif
@@ -1558,6 +1561,32 @@ namespace VeraCrypt
}
}
+#ifdef HAVE_INDICATORS
+ void MainFrame::SetBusy (bool busy)
+ {
+ gtk_widget_set_sensitive(indicator_item_mountfavorites, !busy);
+ gtk_widget_set_sensitive(indicator_item_dismountall, !busy);
+ gtk_widget_set_sensitive(indicator_item_prefs, !busy);
+ gtk_widget_set_sensitive(indicator_item_exit, !busy /*&& CanExit()*/);
+ }
+
+ static void IndicatorOnShowHideMenuItemSelected (GtkWidget *widget, MainFrame *self) { Gui->SetBackgroundMode (!Gui->IsInBackgroundMode()); }
+ static void IndicatorOnMountAllFavoritesMenuItemSelected (GtkWidget *widget, MainFrame *self) { self->SetBusy(true); self->MountAllFavorites (); self->SetBusy(false); }
+ static void IndicatorOnDismountAllMenuItemSelected (GtkWidget *widget, MainFrame *self) { self->SetBusy(true); Gui->DismountAllVolumes(); self->SetBusy(false); }
+ static void IndicatorOnPreferencesMenuItemSelected (GtkWidget *widget, MainFrame *self) {
+ self->SetBusy(true);
+ PreferencesDialog dialog (self);
+ dialog.ShowModal();
+ self->SetBusy(false);
+ }
+ static void IndicatorOnExitMenuItemSelected (GtkWidget *widget, MainFrame *self) {
+ self->SetBusy(true);
+ if (Core->GetMountedVolumes().empty() || Gui->AskYesNo (LangString ["CONFIRM_EXIT"], false, true))
+ self->Close (true);
+ self->SetBusy(false);
+ }
+
+#endif
void MainFrame::ShowTaskBarIcon (bool show)
{
if (!show && mTaskBarIcon->IsIconInstalled())
@@ -1567,8 +1596,47 @@ namespace VeraCrypt
else if (show && !mTaskBarIcon->IsIconInstalled())
{
#ifndef TC_MACOSX
+#ifndef HAVE_INDICATORS
mTaskBarIcon->SetIcon (Resources::GetVeraCryptIcon(), L"VeraCrypt");
#endif
+#endif
+#ifdef HAVE_INDICATORS
+ if (indicator == NULL) {
+ indicator = app_indicator_new ("veracrypt", "veracrypt", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
+ app_indicator_set_status (indicator, APP_INDICATOR_STATUS_ACTIVE);
+
+ GtkWidget *menu = gtk_menu_new();
+
+ indicator_item_showhide = gtk_menu_item_new_with_label (LangString[Gui->IsInBackgroundMode() ? "SHOW_TC" : "HIDE_TC"].mb_str());
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), indicator_item_showhide);
+ g_signal_connect (indicator_item_showhide, "activate", G_CALLBACK (IndicatorOnShowHideMenuItemSelected), this);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new());
+
+ indicator_item_mountfavorites = gtk_menu_item_new_with_label (LangString["IDM_MOUNT_FAVORITE_VOLUMES"]);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), indicator_item_mountfavorites);
+ g_signal_connect (indicator_item_mountfavorites, "activate", G_CALLBACK (IndicatorOnMountAllFavoritesMenuItemSelected), this);
+
+ indicator_item_dismountall = gtk_menu_item_new_with_label (LangString["HK_DISMOUNT_ALL"]);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), indicator_item_dismountall);
+ g_signal_connect (indicator_item_dismountall, "activate", G_CALLBACK (IndicatorOnDismountAllMenuItemSelected), this);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new());
+
+ indicator_item_prefs = gtk_menu_item_new_with_label (LangString["IDM_PREFERENCES"]);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), indicator_item_prefs);
+ g_signal_connect (indicator_item_prefs, "activate", G_CALLBACK (IndicatorOnPreferencesMenuItemSelected), this);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new());
+
+ indicator_item_exit = gtk_menu_item_new_with_label (LangString["EXIT"]);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), indicator_item_exit);
+ g_signal_connect (indicator_item_exit, "activate", G_CALLBACK (IndicatorOnExitMenuItemSelected), this);
+
+ gtk_widget_show_all (menu);
+ app_indicator_set_menu (indicator, GTK_MENU (menu));
+ }
+#endif
}
}
diff --git a/src/Main/Forms/MainFrame.h b/src/Main/Forms/MainFrame.h
index 9089ce72..5372adbb 100644
--- a/src/Main/Forms/MainFrame.h
+++ b/src/Main/Forms/MainFrame.h
@@ -13,6 +13,12 @@
#ifndef TC_HEADER_Main_Forms_MainFrame
#define TC_HEADER_Main_Forms_MainFrame
+#ifdef HAVE_INDICATORS
+#define GSocket GlibGSocket
+#include <libayatana-appindicator/app-indicator.h>
+#undef GSocket
+#endif
+
#include "Forms.h"
#include "ChangePasswordDialog.h"
#ifdef TC_MACOSX
@@ -38,6 +44,18 @@ namespace VeraCrypt
static FilePath GetShowRequestFifoPath () { return Application::GetConfigFilePath (L".show-request-queue", true); }
#endif
+ void MountAllFavorites ();
+
+#ifdef HAVE_INDICATORS
+ AppIndicator *indicator;
+ GtkWidget *indicator_item_showhide;
+ GtkWidget *indicator_item_mountfavorites;
+ GtkWidget *indicator_item_dismountall;
+ GtkWidget *indicator_item_prefs;
+ GtkWidget *indicator_item_exit;
+ void SetBusy (bool busy);
+
+#endif
protected:
enum
{
@@ -71,7 +89,6 @@ namespace VeraCrypt
void LoadFavoriteVolumes ();
void LoadPreferences ();
void MountAllDevices ();
- void MountAllFavorites ();
void MountVolume ();
void OnAboutMenuItemSelected (wxCommandEvent& event);
void OnQuit(wxCommandEvent& event) { Close(true); }
diff --git a/src/Main/Forms/TrueCrypt.fbp b/src/Main/Forms/TrueCrypt.fbp
index 927a60b9..24689fcf 100644
--- a/src/Main/Forms/TrueCrypt.fbp
+++ b/src/Main/Forms/TrueCrypt.fbp
@@ -29553,6 +29553,104 @@
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
+ <object class="wxCheckBox" expanded="0">
+ <property name="BottomDockable">1</property>
+ <property name="LeftDockable">1</property>
+ <property name="RightDockable">1</property>
+ <property name="TopDockable">1</property>
+ <property name="aui_layer"></property>
+ <property name="aui_name"></property>
+ <property name="aui_position"></property>
+ <property name="aui_row"></property>
+ <property name="best_size"></property>
+ <property name="bg"></property>
+ <property name="caption"></property>
+ <property name="caption_visible">1</property>
+ <property name="center_pane">0</property>
+ <property name="checked">0</property>
+ <property name="close_button">1</property>
+ <property name="context_help"></property>
+ <property name="context_menu">1</property>
+ <property name="default_pane">0</property>
+ <property name="dock">Dock</property>
+ <property name="dock_fixed">0</property>
+ <property name="docking">Left</property>
+ <property name="enabled">1</property>
+ <property name="fg"></property>
+ <property name="floatable">1</property>
+ <property name="font"></property>
+ <property name="gripper">0</property>
+ <property name="hidden">0</property>
+ <property name="id">wxID_ANY</property>
+ <property name="label">IDC_USE_ALL_FREE_SPACE</property>
+ <property name="max_size"></property>
+ <property name="maximize_button">0</property>
+ <property name="maximum_size"></property>
+ <property name="min_size"></property>
+ <property name="minimize_button">0</property>
+ <property name="minimum_size"></property>
+ <property name="moveable">1</property>
+ <property name="name">UseAllFreeSpaceCheckBox</property>
+ <property name="pane_border">1</property>
+ <property name="pane_position"></property>
+ <property name="pane_size"></property>
+ <property name="permission">protected</property>
+ <property name="pin_button">1</property>
+ <property name="pos"></property>
+ <property name="resize">Resizable</property>
+ <property name="show">1</property>
+ <property name="size"></property>
+ <property name="style"></property>
+ <property name="subclass">; forward_declare</property>
+ <property name="toolbar_pane">0</property>
+ <property name="tooltip"></property>
+ <property name="validator_data_type"></property>
+ <property name="validator_style">wxFILTER_NONE</property>
+ <property name="validator_type">wxDefaultValidator</property>
+ <property name="validator_variable"></property>
+ <property name="window_extra_style"></property>
+ <property name="window_name"></property>
+ <property name="window_style"></property>
+ <event name="OnChar"></event>
+ <event name="OnCheckBox">OnUseAllFreeSpaceCheckBoxClick</event>
+ <event name="OnEnterWindow"></event>
+ <event name="OnEraseBackground"></event>
+ <event name="OnKeyDown"></event>
+ <event name="OnKeyUp"></event>
+ <event name="OnKillFocus"></event>
+ <event name="OnLeaveWindow"></event>
+ <event name="OnLeftDClick"></event>
+ <event name="OnLeftDown"></event>
+ <event name="OnLeftUp"></event>
+ <event name="OnMiddleDClick"></event>
+ <event name="OnMiddleDown"></event>
+ <event name="OnMiddleUp"></event>
+ <event name="OnMotion"></event>
+ <event name="OnMouseEvents"></event>
+ <event name="OnMouseWheel"></event>
+ <event name="OnPaint"></event>
+ <event name="OnRightDClick"></event>
+ <event name="OnRightDown"></event>
+ <event name="OnRightUp"></event>
+ <event name="OnSetFocus"></event>
+ <event name="OnSize"></event>
+ <event name="OnUpdateUI"></event>
+ </object>
+ </object>
+ <object class="sizeritem" expanded="0">
+ <property name="border">5</property>
+ <property name="flag">wxBOTTOM|wxEXPAND|wxTOP</property>
+ <property name="proportion">0</property>
+ <object class="spacer" expanded="0">
+ <property name="height">0</property>
+ <property name="permission">protected</property>
+ <property name="width">0</property>
+ </object>
+ </object>
+ <object class="sizeritem" expanded="0">
+ <property name="border">5</property>
+ <property name="flag">wxALL|wxEXPAND</property>
+ <property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
diff --git a/src/Main/Forms/VolumeSizeWizardPage.cpp b/src/Main/Forms/VolumeSizeWizardPage.cpp
index 47d73983..61427ea5 100644
--- a/src/Main/Forms/VolumeSizeWizardPage.cpp
+++ b/src/Main/Forms/VolumeSizeWizardPage.cpp
@@ -24,9 +24,10 @@ namespace VeraCrypt
SectorSize (sectorSize),
AvailableDiskSpace (0)
{
- VolumeSizePrefixChoice->Append (LangString["KB"], reinterpret_cast <void *> (1024));
- VolumeSizePrefixChoice->Append (LangString["MB"], reinterpret_cast <void *> (1024 * 1024));
- VolumeSizePrefixChoice->Append (LangString["GB"], reinterpret_cast <void *> (1024 * 1024 * 1024));
+ VolumeSizePrefixChoice->Append (LangString["KB"], reinterpret_cast <void *> (1));
+ VolumeSizePrefixChoice->Append (LangString["MB"], reinterpret_cast <void *> (2));
+ VolumeSizePrefixChoice->Append (LangString["GB"], reinterpret_cast <void *> (3));
+ VolumeSizePrefixChoice->Append (LangString["TB"], reinterpret_cast <void *> (4));
VolumeSizePrefixChoice->Select (Prefix::MB);
wxLongLong diskSpace = 0;
@@ -34,6 +35,7 @@ namespace VeraCrypt
{
VolumeSizeTextCtrl->Disable();
VolumeSizeTextCtrl->SetValue (L"");
+ UseAllFreeSpaceCheckBox->Disable();
}
else
{
@@ -74,13 +76,25 @@ namespace VeraCrypt
uint64 VolumeSizeWizardPage::GetVolumeSize () const
{
uint64 prefixMult = 1;
- int selection = VolumeSizePrefixChoice->GetSelection();
- if (selection == wxNOT_FOUND)
- return 0;
-
- prefixMult = reinterpret_cast <uint64> (VolumeSizePrefixChoice->GetClientData (selection));
+ uint64 val;
+ if (UseAllFreeSpaceCheckBox->IsChecked ())
+ {
+ val = AvailableDiskSpace;
+ }
+ else
+ {
+ int selection = VolumeSizePrefixChoice->GetSelection();
+ if (selection == wxNOT_FOUND)
+ return 0;
- uint64 val = StringConverter::ToUInt64 (wstring (VolumeSizeTextCtrl->GetValue()));
+ uint64 counter = reinterpret_cast <uint64> (VolumeSizePrefixChoice->GetClientData (selection));
+ while (counter)
+ {
+ prefixMult *= 1024;
+ counter--;
+ }
+ val = StringConverter::ToUInt64 (wstring(VolumeSizeTextCtrl->GetValue()));
+ }
if (val <= 0x7fffFFFFffffFFFFull / prefixMult)
{
val *= prefixMult;
@@ -98,7 +112,7 @@ namespace VeraCrypt
bool VolumeSizeWizardPage::IsValid ()
{
- if (!VolumeSizeTextCtrl->GetValue().empty() && Validate())
+ if ((!VolumeSizeTextCtrl->GetValue().empty() || UseAllFreeSpaceCheckBox->IsChecked ()) && Validate())
{
try
{
@@ -126,7 +140,12 @@ namespace VeraCrypt
return;
}
- if (size % (1024 * 1024 * 1024) == 0)
+ if (size % (1024ULL * 1024ULL * 1024ULL * 1024ULL) == 0)
+ {
+ size /= 1024ULL * 1024ULL * 1024ULL * 1024ULL;
+ VolumeSizePrefixChoice->Select (Prefix::TB);
+ }
+ else if (size % (1024 * 1024 * 1024) == 0)
{
size /= 1024 * 1024 * 1024;
VolumeSizePrefixChoice->Select (Prefix::GB);
@@ -144,4 +163,21 @@ namespace VeraCrypt
VolumeSizeTextCtrl->SetValue (StringConverter::FromNumber (size));
}
+
+ void VolumeSizeWizardPage::OnUseAllFreeSpaceCheckBoxClick( wxCommandEvent& event )
+ {
+ if (UseAllFreeSpaceCheckBox->IsChecked ())
+ {
+ VolumeSizePrefixChoice->Select (Prefix::MB);
+ VolumeSizeTextCtrl->SetValue (L"");
+ VolumeSizePrefixChoice->Disable();
+ VolumeSizeTextCtrl->Disable();
+ }
+ else
+ {
+ VolumeSizePrefixChoice->Enable();
+ VolumeSizeTextCtrl->SetValue (L"");
+ VolumeSizeTextCtrl->Enable();
+ }
+ }
}
diff --git a/src/Main/Forms/VolumeSizeWizardPage.h b/src/Main/Forms/VolumeSizeWizardPage.h
index aac41f99..754bd691 100644
--- a/src/Main/Forms/VolumeSizeWizardPage.h
+++ b/src/Main/Forms/VolumeSizeWizardPage.h
@@ -37,13 +37,15 @@ namespace VeraCrypt
{
KB = 0,
MB,
- GB
+ GB,
+ TB
};
};
void OnBrowseButtonClick (wxCommandEvent& event);
void OnVolumeSizePrefixSelected (wxCommandEvent& event) { PageUpdatedEvent.Raise(); }
void OnVolumeSizeTextChanged (wxCommandEvent& event) { PageUpdatedEvent.Raise(); }
+ void OnUseAllFreeSpaceCheckBoxClick( wxCommandEvent& event );
uint64 MaxVolumeSize;
bool MaxVolumeSizeValid;
diff --git a/src/Main/Forms/international.h b/src/Main/Forms/international.h
index a30adab0..1ca0c436 100644
--- a/src/Main/Forms/international.h
+++ b/src/Main/Forms/international.h
@@ -1,4 +1,4 @@
-#ifdef TC_LINUX
+#ifndef TC_WINDOWS
#include "Main/LanguageStrings.h"
#undef _
#define _(key) LangString[key]
diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp
index 04e98855..7d1cee7c 100755..100644
--- a/src/Main/GraphicUserInterface.cpp
+++ b/src/Main/GraphicUserInterface.cpp
@@ -1018,7 +1018,7 @@ namespace VeraCrypt
wxLog::FlushActive();
Application::SetExitCode (1);
- Gui->ShowInfo (LangStrin["LINUX_VC_RUNNING_ALREADY"]);
+ Gui->ShowInfo (LangString["LINUX_VC_RUNNING_ALREADY"]);
return false;
#endif
}
@@ -1754,6 +1754,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
diff --git a/src/Main/LanguageStrings.cpp b/src/Main/LanguageStrings.cpp
index 33aaf6a9..71914ec7 100644
--- a/src/Main/LanguageStrings.cpp
+++ b/src/Main/LanguageStrings.cpp
@@ -29,6 +29,9 @@ namespace VeraCrypt
{
if (Map.count (key) > 0)
return wxString (Map.find (key)->second);
+ // return "VeraCrypt" as it is
+ if (key == "VeraCrypt")
+ return L"VeraCrypt";
return wxString (L"?") + StringConverter::ToWide (key) + L"?";
}
@@ -40,7 +43,6 @@ namespace VeraCrypt
void LanguageStrings::Init ()
{
-#ifdef TC_LINUX
static byte LanguageXml[] =
{
# include "Common/Language.xml.h"
@@ -53,7 +55,7 @@ namespace VeraCrypt
text.Replace (L"\\n", L"\n");
Map[StringConverter::ToSingle (wstring (node.Attributes[L"key"]))] = text;
}
-#endif
+
foreach (XmlNode node, XmlParser (Resources::GetLanguageXml()).GetNodes (L"entry"))
{
wxString text = node.InnerText;
diff --git a/src/Main/Main.make b/src/Main/Main.make
index 77f7dc91..8def8aaa 100755
--- a/src/Main/Main.make
+++ b/src/Main/Main.make
@@ -178,6 +178,7 @@ endif
ifeq "$(PLATFORM)" "MacOSX"
prepare: $(APPNAME)
mkdir -p $(APPNAME).app/Contents/MacOS $(APPNAME).app/Contents/Resources/doc/HTML
+ mkdir -p $(APPNAME).app/Contents/MacOS $(APPNAME).app/Contents/Resources/languages
-rm -f $(APPNAME).app/Contents/MacOS/$(APPNAME)
-rm -f $(APPNAME).app/Contents/MacOS/$(APPNAME)_console
@@ -200,6 +201,7 @@ endif
cp $(BASE_DIR)/Resources/Icons/VeraCrypt.icns $(APPNAME).app/Contents/Resources
cp $(BASE_DIR)/Resources/Icons/VeraCrypt_Volume.icns $(APPNAME).app/Contents/Resources
cp $(BASE_DIR)/../doc/html/* $(APPNAME).app/Contents/Resources/doc/HTML
+ cp $(BASE_DIR)/../Translations/* $(APPNAME).app/Contents/Resources/languages
echo -n APPLTRUE >$(APPNAME).app/Contents/PkgInfo
ifdef VC_LEGACY_BUILD
@@ -207,6 +209,7 @@ ifdef VC_LEGACY_BUILD
else
sed -e 's/_VERSION_/$(patsubst %a,%.1,$(patsubst %b,%.2,$(TC_VERSION)))/' ../Build/Resources/MacOSX/Info.plist.xml >$(APPNAME).app/Contents/Info.plist
endif
+ chmod -R go-w $(APPNAME).app
codesign -s "Developer ID Application: IDRIX (Z933746L2S)" --timestamp $(APPNAME).app
install: prepare
@@ -253,16 +256,23 @@ prepare: $(APPNAME)
mkdir -p $(BASE_DIR)/Setup/Linux/usr/share/veracrypt/languages
cp -r $(BASE_DIR)/../Translations/* $(BASE_DIR)/Setup/Linux/usr/share/veracrypt/languages/
+ mkdir -p $(BASE_DIR)/Setup/Linux/usr/sbin
+ cp $(BASE_DIR)/Setup/Linux/mount.$(APPNAME) $(BASE_DIR)/Setup/Linux/usr/sbin/mount.$(APPNAME)
+ chmod +x $(BASE_DIR)/Setup/Linux/usr/sbin/mount.$(APPNAME)
ifndef TC_NO_GUI
mkdir -p $(BASE_DIR)/Setup/Linux/usr/share/applications
mkdir -p $(BASE_DIR)/Setup/Linux/usr/share/pixmaps
+ mkdir -p $(BASE_DIR)/Setup/Linux/usr/share/mime/packages
cp $(BASE_DIR)/Resources/Icons/VeraCrypt-256x256.xpm $(BASE_DIR)/Setup/Linux/usr/share/pixmaps/$(APPNAME).xpm
cp $(BASE_DIR)/Setup/Linux/$(APPNAME).desktop $(BASE_DIR)/Setup/Linux/usr/share/applications/$(APPNAME).desktop
+ cp $(BASE_DIR)/Setup/Linux/$(APPNAME).xml $(BASE_DIR)/Setup/Linux/usr/share/mime/packages/$(APPNAME).xml
endif
install: prepare
+ifneq "$(DESTDIR)" ""
mkdir -p $(DESTDIR)
+endif
cp -R $(BASE_DIR)/Setup/Linux/usr $(DESTDIR)/
ifeq "$(TC_BUILD_CONFIG)" "Release"
@@ -304,15 +314,19 @@ prepare: $(APPNAME)
ifndef TC_NO_GUI
mkdir -p $(BASE_DIR)/Setup/FreeBSD/usr/share/applications
mkdir -p $(BASE_DIR)/Setup/FreeBSD/usr/share/pixmaps
+ mkdir -p $(BASE_DIR)/Setup/Linux/usr/share/mime/packages
cp $(BASE_DIR)/Resources/Icons/VeraCrypt-256x256.xpm $(BASE_DIR)/Setup/FreeBSD/usr/share/pixmaps/$(APPNAME).xpm
cp $(BASE_DIR)/Setup/Linux/$(APPNAME).desktop $(BASE_DIR)/Setup/FreeBSD/usr/share/applications/$(APPNAME).desktop
+ cp $(BASE_DIR)/Setup/Linux/$(APPNAME).xml $(BASE_DIR)/Setup/Linux/usr/share/mime/packages/$(APPNAME).xml
endif
chown -R root:wheel $(BASE_DIR)/Setup/FreeBSD/usr
chmod -R go-w $(BASE_DIR)/Setup/FreeBSD/usr
install: prepare
+ifneq "$(DESTDIR)" ""
mkdir -p $(DESTDIR)
+endif
cp -R $(BASE_DIR)/Setup/FreeBSD/usr $(DESTDIR)/.
ifeq "$(TC_BUILD_CONFIG)" "Release"
diff --git a/src/Main/Resources.cpp b/src/Main/Resources.cpp
index 32bcd9d2..d9a787a5 100644
--- a/src/Main/Resources.cpp
+++ b/src/Main/Resources.cpp
@@ -14,16 +14,17 @@
#include "Platform/Platform.h"
#include "Resources.h"
-#ifdef TC_LINUX
+#ifdef TC_WINDOWS
+#include "Main/resource.h"
+#else
+#ifdef TC_MACOSX
+#include "Application.h"
+#endif
#include "Platform/File.h"
#include "Platform/StringConverter.h"
#include <stdio.h>
#endif
-#ifdef TC_WINDOWS
-#include "Main/resource.h"
-#endif
-
namespace VeraCrypt
{
@@ -54,18 +55,24 @@ namespace VeraCrypt
strBuf.Zero();
strBuf.CopyFrom (res);
return string (reinterpret_cast <char *> (strBuf.Ptr()));
-#elif TC_LINUX
+#else
// get language from env LANG
// support: C,POSIX,
// support for e.g. german: de_DE.UTF-8, de.UTF8, de_DE, de
// not support e.g.: de@Euro
string defaultLang("en");
+#if defined (TC_MACOSX)
+ string filenamePrefix = StringConverter::ToSingle (Application::GetExecutableDirectory()) + "/../Resources/languages/Language.";
+#else
string filenamePrefix("/usr/share/veracrypt/languages/Language.");
+#endif
string filenamePost(".xml");
string filename = filenamePrefix + defaultLang + filenamePost;
if(const char* env_p = getenv("LANG")){
string lang(env_p);
+#ifdef DEBUG
std::cout << lang << std::endl;
+#endif
if ( lang.size() > 1 ){
int found = lang.find(".");
if ( found > 1 ){
@@ -127,14 +134,6 @@ namespace VeraCrypt
};
return string ((const char*) LanguageXml);
-#else
- static byte LanguageXml[] =
- {
-# include "Common/Language.xml.h"
- , 0
- };
-
- return string ((const char*) LanguageXml);
#endif
}
diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp
index 2cacbb1b..7233b8b6 100644
--- a/src/Main/TextUserInterface.cpp
+++ b/src/Main/TextUserInterface.cpp
@@ -646,6 +646,29 @@ namespace VeraCrypt
}
else
{
+ uint64 AvailableDiskSpace = 0;
+ wxLongLong diskSpace = 0;
+ if (wxGetDiskSpace (wxFileName (wstring (options->Path)).GetPath(), nullptr, &diskSpace))
+ {
+ AvailableDiskSpace = (uint64) diskSpace.GetValue ();
+ if (maxVolumeSize > AvailableDiskSpace)
+ maxVolumeSize = AvailableDiskSpace;
+ }
+
+ if (options->Size == (uint64) (-1))
+ {
+ if (AvailableDiskSpace)
+ {
+ // caller requesting maximum size
+ // we use maxVolumeSize because it is guaranteed to be less of equal to AvailableDiskSpace
+ options->Size = maxVolumeSize;
+ }
+ else
+ {
+ throw_err (_("Failed to get available disk space on the selected target."));
+ }
+ }
+
options->Quick = false;
uint32 sectorSizeRem = options->Size % options->SectorSize;
@@ -657,43 +680,62 @@ namespace VeraCrypt
if (Preferences.NonInteractive)
throw MissingArgument (SRC_POS);
- wstring sizeStr = AskString (options->Type == VolumeType::Hidden ? _("\nEnter hidden volume size (sizeK/size[M]/sizeG): ") : _("\nEnter volume size (sizeK/size[M]/sizeG): "));
uint64 multiplier = 1024 * 1024;
-
- if (sizeStr.find (L"K") != string::npos)
- {
- multiplier = 1024;
- sizeStr.resize (sizeStr.size() - 1);
- }
- else if (sizeStr.find (L"M") != string::npos)
+ wxString sizeStr = AskString (options->Type == VolumeType::Hidden ? _("\nEnter hidden volume size (sizeK/size[M]/sizeG/sizeT/max): ") : _("\nEnter volume size (sizeK/size[M]/sizeG.sizeT/max): "));
+ if (sizeStr.CmpNoCase(wxT("max")) == 0)
{
- sizeStr.resize (sizeStr.size() - 1);
- }
- else if (sizeStr.find (L"G") != string::npos)
- {
- multiplier = 1024 * 1024 * 1024;
- sizeStr.resize (sizeStr.size() - 1);
+ multiplier = 1;
+ if (AvailableDiskSpace)
+ {
+ // caller requesting maximum size
+ // we use maxVolumeSize because it is guaranteed to be less of equal to AvailableDiskSpace
+ options->Size = maxVolumeSize;
+ }
+ else
+ {
+ throw_err (_("Failed to get available disk space on the selected target."));
+ }
}
- else if (sizeStr.find (L"T") != string::npos)
+ else
{
- multiplier = (uint64) 1024 * 1024 * 1024 * 1024;
- sizeStr.resize (sizeStr.size() - 1);
- }
+ multiplier = 1024 * 1024;
+ size_t index = sizeStr.find_first_not_of (wxT("0123456789"));
+ if (index == 0)
+ {
+ continue;
+ }
+ else if (index != (size_t) wxNOT_FOUND)
+ {
+ wxString sizeSuffix = sizeStr.Mid(index);
+ if (sizeSuffix.CmpNoCase(wxT("K")) == 0 || sizeSuffix.CmpNoCase(wxT("KiB")) == 0)
+ multiplier = BYTES_PER_KB;
+ else if (sizeSuffix.CmpNoCase(wxT("M")) == 0 || sizeSuffix.CmpNoCase(wxT("MiB")) == 0)
+ multiplier = BYTES_PER_MB;
+ else if (sizeSuffix.CmpNoCase(wxT("G")) == 0 || sizeSuffix.CmpNoCase(wxT("GiB")) == 0)
+ multiplier = BYTES_PER_GB;
+ else if (sizeSuffix.CmpNoCase(wxT("T")) == 0 || sizeSuffix.CmpNoCase(wxT("TiB")) == 0)
+ multiplier = BYTES_PER_TB;
+ else
+ continue;
- try
- {
- options->Size = StringConverter::ToUInt64 (sizeStr);
- options->Size *= multiplier;
+ sizeStr = sizeStr.Left (index);
+ }
- sectorSizeRem = options->Size % options->SectorSize;
- if (sectorSizeRem != 0)
- options->Size += options->SectorSize - sectorSizeRem;
- }
- catch (...)
- {
- options->Size = 0;
- continue;
+ try
+ {
+ options->Size = StringConverter::ToUInt64 (wstring(sizeStr));
+ }
+ catch (...)
+ {
+ options->Size = 0;
+ continue;
+ }
}
+ options->Size *= multiplier;
+
+ sectorSizeRem = options->Size % options->SectorSize;
+ if (sectorSizeRem != 0)
+ options->Size += options->SectorSize - sectorSizeRem;
if (options->Size < minVolumeSize)
{
diff --git a/src/Main/UserInterface.cpp b/src/Main/UserInterface.cpp
index b4bfe836..d0e2f9a1 100644
--- a/src/Main/UserInterface.cpp
+++ b/src/Main/UserInterface.cpp
@@ -1270,10 +1270,11 @@ namespace VeraCrypt
"--slot=SLOT\n"
" Use specified slot number when mounting, dismounting, or listing a volume.\n"
"\n"
- "--size=SIZE[K|M|G|T]\n"
+ "--size=SIZE[K|KiB|M|MiB|G|GiB|T|TiB] or --size=max\n"
" Use specified size when creating a new volume. If no suffix is indicated,\n"
" then SIZE is interpreted in bytes. Suffixes K, M, G or T can be used to\n"
" indicate a value in KiB, MiB, GiB or TiB respectively.\n"
+ " If max is specified, the new volume will use all available free disk space.\n"
"\n"
"-t, --text\n"
" Use text user interface. Graphical user interface is used by default if\n"