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

Add TrueCrypt 7.1a MacOSX/Linux specific source files.

This commit is contained in:
Mounir IDRASSI
2014-05-31 18:44:53 +02:00
parent 97011f179c
commit 7ffce028d0
203 changed files with 52120 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Volume/Version.h"
#include "Main/Application.h"
#include "Main/GraphicUserInterface.h"
#include "Main/Resources.h"
#include "AboutDialog.h"
namespace TrueCrypt
{
AboutDialog::AboutDialog (wxWindow* parent) : AboutDialogBase (parent)
{
LogoBitmap->SetBitmap (Resources::GetTextualLogoBitmap());
wxFont versionStaticTextFont = VersionStaticText->GetFont();
versionStaticTextFont.SetWeight (wxFONTWEIGHT_BOLD);
VersionStaticText->SetFont (versionStaticTextFont);
VersionStaticText->SetLabel (Application::GetName() + L" " + StringConverter::ToWide (Version::String()));
CopyrightStaticText->SetLabel (StringConverter::ToWide (TC_STR_RELEASED_BY));
WebsiteHyperlink->SetLabel (L"www.truecrypt.org");
CreditsTextCtrl->SetMinSize (wxSize (
Gui->GetCharWidth (CreditsTextCtrl) * 70,
Gui->GetCharHeight (CreditsTextCtrl) * 6
#ifdef TC_WINDOWS
- 5
#else
- 11
#endif
));
Layout();
Fit();
Center();
CreditsTextCtrl->ChangeValue (
L"Portions of this software are based in part on the works of the following people: "
L"Paul Le Roux, "
L"Bruce Schneier, John Kelsey, Doug Whiting, David Wagner, Chris Hall, Niels Ferguson, "
L"Lars Knudsen, Ross Anderson, Eli Biham, "
L"Joan Daemen, Vincent Rijmen, "
L"Phillip Rogaway, "
L"Hans Dobbertin, Antoon Bosselaers, Bart Preneel, "
L"Paulo Barreto, Brian Gladman, Wei Dai, Peter Gutmann, and many others.\n\n"
L"Portions of this software:\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"
L"\nThis software as a whole:\n"
L"Copyright \xA9 2012 TrueCrypt Developers Association. 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"
L"A TrueCrypt Foundation Release");
}
}

View File

@@ -0,0 +1,25 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_AboutDialog
#define TC_HEADER_Main_Forms_AboutDialog
#include "Forms.h"
namespace TrueCrypt
{
class AboutDialog : public AboutDialogBase
{
public:
AboutDialog (wxWindow* parent);
void OnWebsiteHyperlinkClick (wxHyperlinkEvent& event) { Gui->OpenHomepageLink (this, L"main"); }
};
}
#endif // TC_HEADER_Main_Forms_AboutDialog

View File

@@ -0,0 +1,157 @@
/*
Copyright (c) 2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Volume/EncryptionModeXTS.h"
#include "Main/GraphicUserInterface.h"
#include "BenchmarkDialog.h"
namespace TrueCrypt
{
BenchmarkDialog::BenchmarkDialog (wxWindow *parent)
: BenchmarkDialogBase (parent)
{
BenchmarkNoteStaticText->SetLabel (LangString["IDT_BOX_BENCHMARK_INFO"]);
BenchmarkNoteStaticText->Wrap (RightSizer->GetSize().GetWidth());
list <size_t> bufferSizes;
bufferSizes.push_back (1 * BYTES_PER_MB);
bufferSizes.push_back (5 * BYTES_PER_MB);
bufferSizes.push_back (10 * BYTES_PER_MB);
bufferSizes.push_back (50 * BYTES_PER_MB);
bufferSizes.push_back (100 * BYTES_PER_MB);
bufferSizes.push_back (200 * BYTES_PER_MB);
bufferSizes.push_back (500 * BYTES_PER_MB);
bufferSizes.push_back (1 * BYTES_PER_GB);
foreach (size_t size, bufferSizes)
{
BufferSizeChoice->Append (Gui->SizeToString (size), (void *) size);
}
BufferSizeChoice->Select (1);
list <int> colPermilles;
BenchmarkListCtrl->InsertColumn (ColumnAlgorithm, LangString["ALGORITHM"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (322);
BenchmarkListCtrl->InsertColumn (ColumnEncryption, LangString["ENCRYPTION"], wxLIST_FORMAT_RIGHT, 1);
colPermilles.push_back (226);
BenchmarkListCtrl->InsertColumn (ColumnDecryption, LangString["DECRYPTION"], wxLIST_FORMAT_RIGHT, 1);
colPermilles.push_back (226);
BenchmarkListCtrl->InsertColumn (ColumnMean, LangString["MEAN"], wxLIST_FORMAT_RIGHT, 1);
colPermilles.push_back (226);
Gui->SetListCtrlWidth (BenchmarkListCtrl, 62, false);
Gui->SetListCtrlHeight (BenchmarkListCtrl, 14);
Gui->SetListCtrlColumnWidths (BenchmarkListCtrl, colPermilles);
Layout();
Fit();
Center();
}
void BenchmarkDialog::OnBenchmarkButtonClick (wxCommandEvent& event)
{
try
{
list <BenchmarkResult> results;
wxBusyCursor busy;
Buffer buffer ((size_t) Gui->GetSelectedData <size_t> (BufferSizeChoice));
EncryptionAlgorithmList encryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms();
foreach (shared_ptr <EncryptionAlgorithm> ea, encryptionAlgorithms)
{
if (!ea->IsDeprecated())
{
BenchmarkResult result;
result.AlgorithmName = ea->GetName();
Buffer key (ea->GetKeySize());
ea->SetKey (key);
shared_ptr <EncryptionMode> xts (new EncryptionModeXTS);
xts->SetKey (key);
ea->SetMode (xts);
wxLongLong startTime = wxGetLocalTimeMillis();
// CPU "warm up" (an attempt to prevent skewed results on systems where CPU frequency gradually changes depending on CPU load).
do
{
ea->EncryptSectors (buffer, 0, buffer.Size() / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
}
while (wxGetLocalTimeMillis().GetValue() - startTime.GetValue() < 20);
uint64 size = 0;
uint64 time;
startTime = wxGetLocalTimeMillis();
do
{
ea->EncryptSectors (buffer, 0, buffer.Size() / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
size += buffer.Size();
time = (uint64) (wxGetLocalTimeMillis().GetValue() - startTime.GetValue());
}
while (time < 100);
result.EncryptionSpeed = size * 1000 / time;
startTime = wxGetLocalTimeMillis();
size = 0;
do
{
ea->DecryptSectors (buffer, 0, buffer.Size() / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
size += buffer.Size();
time = (uint64) (wxGetLocalTimeMillis().GetValue() - startTime.GetValue());
}
while (time < 100);
result.DecryptionSpeed = size * 1000 / time;
result.MeanSpeed = (result.EncryptionSpeed + result.DecryptionSpeed) / 2;
bool inserted = false;
for (list <BenchmarkResult>::iterator i = results.begin(); i != results.end(); ++i)
{
if (i->MeanSpeed < result.MeanSpeed)
{
results.insert (i, result);
inserted = true;
break;
}
}
if (!inserted)
results.push_back (result);
}
}
BenchmarkListCtrl->DeleteAllItems();
foreach (const BenchmarkResult &result, results)
{
vector <wstring> fields (BenchmarkListCtrl->GetColumnCount());
fields[ColumnAlgorithm] = result.AlgorithmName;
fields[ColumnEncryption] = Gui->SpeedToString (result.EncryptionSpeed);
fields[ColumnDecryption] = Gui->SpeedToString (result.DecryptionSpeed);
fields[ColumnMean] = Gui->SpeedToString (result.MeanSpeed);
Gui->AppendToListCtrl (BenchmarkListCtrl, fields);
}
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
}

View File

@@ -0,0 +1,43 @@
/*
Copyright (c) 2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_BenchmarkDialog
#define TC_HEADER_Main_Forms_BenchmarkDialog
#include "Forms.h"
#include "Main/Main.h"
namespace TrueCrypt
{
class BenchmarkDialog : public BenchmarkDialogBase
{
public:
BenchmarkDialog (wxWindow *parent);
protected:
enum
{
ColumnAlgorithm = 0,
ColumnEncryption,
ColumnDecryption,
ColumnMean
};
struct BenchmarkResult
{
wstring AlgorithmName;
uint64 EncryptionSpeed;
uint64 DecryptionSpeed;
uint64 MeanSpeed;
};
void OnBenchmarkButtonClick (wxCommandEvent& event);
};
}
#endif // TC_HEADER_Main_Forms_BenchmarkDialog

View File

@@ -0,0 +1,195 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/Main.h"
#include "Main/GraphicUserInterface.h"
#include "ChangePasswordDialog.h"
namespace TrueCrypt
{
ChangePasswordDialog::ChangePasswordDialog (wxWindow* parent, shared_ptr <VolumePath> volumePath, Mode::Enum mode, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles)
: ChangePasswordDialogBase (parent), DialogMode (mode), Path (volumePath)
{
bool enableNewPassword = false;
bool enableNewKeyfiles = false;
bool enablePkcs5Prf = false;
switch (mode)
{
case Mode::ChangePasswordAndKeyfiles:
enableNewPassword = true;
enableNewKeyfiles = true;
enablePkcs5Prf = true;
SetTitle (_("Change Volume Password and Keyfiles"));
break;
case Mode::ChangeKeyfiles:
enableNewKeyfiles = true;
SetTitle (_("Add/Remove Keyfiles to/from Volume"));
break;
case Mode::RemoveAllKeyfiles:
SetTitle (_("Remove All Keyfiles from Volume"));
break;
case Mode::ChangePkcs5Prf:
enablePkcs5Prf = true;
SetTitle (_("Change Header Key Derivation Algorithm"));
break;
default:
throw ParameterIncorrect (SRC_POS);
}
CurrentPasswordPanel = new VolumePasswordPanel (this, password, keyfiles);
CurrentPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate));
CurrentPasswordPanelSizer->Add (CurrentPasswordPanel, 1, wxALL | wxEXPAND);
NewPasswordPanel = new VolumePasswordPanel (this, newPassword, newKeyfiles, false, enableNewPassword, enableNewKeyfiles, enableNewPassword, enablePkcs5Prf);
NewPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate));
NewPasswordPanelSizer->Add (NewPasswordPanel, 1, wxALL | wxEXPAND);
if (mode == Mode::RemoveAllKeyfiles)
NewSizer->Show (false);
Layout();
Fit();
Center();
OnPasswordPanelUpdate();
CurrentPasswordPanel->SetFocusToPasswordTextCtrl();
}
ChangePasswordDialog::~ChangePasswordDialog ()
{
CurrentPasswordPanel->UpdateEvent.Disconnect (this);
NewPasswordPanel->UpdateEvent.Disconnect (this);
}
void ChangePasswordDialog::OnOKButtonClick (wxCommandEvent& event)
{
// Avoid a GTK bug
if (!OKButton->IsEnabled())
return;
try
{
shared_ptr <VolumePassword> newPassword;
if (DialogMode == Mode::ChangePasswordAndKeyfiles)
{
newPassword = NewPasswordPanel->GetPassword();
newPassword->CheckPortability();
if (newPassword->Size() > 0 && newPassword->Size() < VolumePassword::WarningSizeThreshold
&& !Gui->AskYesNo (LangString ["PASSWORD_LENGTH_WARNING"], false, true))
{
NewPasswordPanel->SetFocusToPasswordTextCtrl();
return;
}
}
else
newPassword = CurrentPasswordPanel->GetPassword();
shared_ptr <KeyfileList> newKeyfiles;
if (DialogMode == Mode::ChangePasswordAndKeyfiles || DialogMode == Mode::ChangeKeyfiles)
newKeyfiles = NewPasswordPanel->GetKeyfiles();
else if (DialogMode != Mode::RemoveAllKeyfiles)
newKeyfiles = CurrentPasswordPanel->GetKeyfiles();
Gui->UserEnrichRandomPool (this, NewPasswordPanel->GetPkcs5Kdf() ? NewPasswordPanel->GetPkcs5Kdf()->GetHash() : shared_ptr <Hash>());
{
#ifdef TC_UNIX
// Temporarily take ownership of a device if the user is not an administrator
UserId origDeviceOwner ((uid_t) -1);
if (!Core->HasAdminPrivileges() && Path->IsDevice())
{
origDeviceOwner = FilesystemPath (wstring (*Path)).GetOwner();
Core->SetFileOwner (*Path, UserId (getuid()));
}
finally_do_arg2 (FilesystemPath, *Path, UserId, origDeviceOwner,
{
if (finally_arg2.SystemId != (uid_t) -1)
Core->SetFileOwner (finally_arg, finally_arg2);
});
#endif
wxBusyCursor busy;
Core->ChangePassword (Path, Gui->GetPreferences().DefaultMountOptions.PreserveTimestamps,
CurrentPasswordPanel->GetPassword(), CurrentPasswordPanel->GetKeyfiles(),
newPassword, newKeyfiles, NewPasswordPanel->GetPkcs5Kdf());
}
switch (DialogMode)
{
case Mode::ChangePasswordAndKeyfiles:
Gui->ShowInfo ("PASSWORD_CHANGED");
break;
case Mode::ChangeKeyfiles:
case Mode::RemoveAllKeyfiles:
Gui->ShowInfo ("KEYFILE_CHANGED");
break;
case Mode::ChangePkcs5Prf:
Gui->ShowInfo ("PKCS5_PRF_CHANGED");
break;
default:
throw ParameterIncorrect (SRC_POS);
}
EndModal (wxID_OK);
}
catch (UnportablePassword &e)
{
Gui->ShowError (e);
NewPasswordPanel->SetFocusToPasswordTextCtrl();
}
catch (PasswordException &e)
{
Gui->ShowWarning (e);
CurrentPasswordPanel->SetFocusToPasswordTextCtrl();
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
void ChangePasswordDialog::OnPasswordPanelUpdate ()
{
bool ok = true;
bool passwordEmpty = CurrentPasswordPanel->GetPassword()->IsEmpty();
bool keyfilesEmpty = !CurrentPasswordPanel->GetKeyfiles() || CurrentPasswordPanel->GetKeyfiles()->empty();
if (passwordEmpty && keyfilesEmpty)
ok = false;
if (DialogMode == Mode::RemoveAllKeyfiles && (passwordEmpty || keyfilesEmpty))
ok = false;
if (DialogMode == Mode::ChangePasswordAndKeyfiles || DialogMode == Mode::ChangeKeyfiles)
{
bool newKeyfilesEmpty = !NewPasswordPanel->GetKeyfiles() || NewPasswordPanel->GetKeyfiles()->empty();
if (DialogMode == Mode::ChangeKeyfiles
&& ((passwordEmpty && newKeyfilesEmpty) || (keyfilesEmpty && newKeyfilesEmpty)))
ok = false;
if (DialogMode == Mode::ChangePasswordAndKeyfiles
&& ((NewPasswordPanel->GetPassword()->IsEmpty() && newKeyfilesEmpty) || !NewPasswordPanel->PasswordsMatch()))
ok = false;
}
OKButton->Enable (ok);
}
}

View File

@@ -0,0 +1,48 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_ChangePasswordDialog
#define TC_HEADER_Main_Forms_ChangePasswordDialog
#include "Forms.h"
#include "Main/Main.h"
#include "VolumePasswordPanel.h"
namespace TrueCrypt
{
class ChangePasswordDialog : public ChangePasswordDialogBase
{
public:
struct Mode
{
enum Enum
{
ChangePasswordAndKeyfiles,
ChangeKeyfiles,
RemoveAllKeyfiles,
ChangePkcs5Prf
};
};
ChangePasswordDialog (wxWindow* parent, shared_ptr <VolumePath> volumePath, Mode::Enum mode = Mode::ChangePasswordAndKeyfiles, shared_ptr <VolumePassword> password = shared_ptr <VolumePassword> (), shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList> (), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword> (), shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList> ());
virtual ~ChangePasswordDialog ();
protected:
void OnOKButtonClick (wxCommandEvent& event);
void OnPasswordPanelUpdate ();
void OnPasswordPanelUpdate (EventArgs &args) { OnPasswordPanelUpdate(); }
Mode::Enum DialogMode;
VolumePasswordPanel *CurrentPasswordPanel;
VolumePasswordPanel *NewPasswordPanel;
shared_ptr <VolumePath> Path;
};
}
#endif // TC_HEADER_Main_Forms_ChangePasswordDialog

View File

@@ -0,0 +1,120 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "Main/Resources.h"
#include "DeviceSelectionDialog.h"
namespace TrueCrypt
{
DeviceSelectionDialog::DeviceSelectionDialog (wxWindow* parent)
: DeviceSelectionDialogBase (parent)
{
wxBusyCursor busy;
list <int> colPermilles;
DeviceListCtrl->InsertColumn (ColumnDevice, LangString["DEVICE"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (447);
#ifdef TC_WINDOWS
DeviceListCtrl->InsertColumn (ColumnDrive, LangString["DRIVE"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (91);
#endif
DeviceListCtrl->InsertColumn (ColumnSize, LangString["SIZE"], wxLIST_FORMAT_RIGHT, 1);
colPermilles.push_back (153);
#ifdef TC_WINDOWS
DeviceListCtrl->InsertColumn (ColumnName, LangString["LABEL"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (307);
#else
DeviceListCtrl->InsertColumn (ColumnMountPoint, LangString["MOUNT_POINT"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (396);
#endif
wxImageList *imageList = new wxImageList (16, 12, true);
imageList->Add (Resources::GetDriveIconBitmap(), Resources::GetDriveIconMaskBitmap());
DeviceListCtrl->AssignImageList (imageList, wxIMAGE_LIST_SMALL);
DeviceList = Core->GetHostDevices();
foreach_ref (HostDevice &device, DeviceList)
{
if (device.Size == 0)
continue;
vector <wstring> fields (DeviceListCtrl->GetColumnCount());
if (DeviceListCtrl->GetItemCount() > 0)
Gui->AppendToListCtrl (DeviceListCtrl, fields);
#ifdef TC_WINDOWS
fields[ColumnDevice] = StringFormatter (L"{0} {1}:", _("Harddisk"), device.SystemNumber);
fields[ColumnDrive] = device.MountPoint;
fields[ColumnName] = device.Name;
#else
fields[ColumnDevice] = wstring (device.Path) + L":";
fields[ColumnMountPoint] = device.MountPoint;
#endif
fields[ColumnSize] = Gui->SizeToString (device.Size);
Gui->AppendToListCtrl (DeviceListCtrl, fields, 0, &device);
foreach_ref (HostDevice &partition, device.Partitions)
{
fields[ColumnDevice] =
#ifndef TC_WINDOWS
wstring (L" ") +
#endif
wstring (partition.Path);
#ifdef TC_WINDOWS
fields[ColumnDrive] = partition.MountPoint;
fields[ColumnName] = partition.Name;
#else
fields[ColumnMountPoint] = partition.MountPoint;
#endif
fields[ColumnSize] = Gui->SizeToString (partition.Size);
Gui->AppendToListCtrl (DeviceListCtrl, fields, -1, &partition);
}
}
Gui->SetListCtrlWidth (DeviceListCtrl, 73);
Gui->SetListCtrlHeight (DeviceListCtrl, 16);
Gui->SetListCtrlColumnWidths (DeviceListCtrl, colPermilles);
Fit();
Layout();
Center();
StdButtonsOK->Disable();
StdButtonsOK->SetDefault();
}
void DeviceSelectionDialog::OnListItemActivated (wxListEvent& event)
{
if (StdButtonsOK->IsEnabled())
EndModal (wxID_OK);
}
void DeviceSelectionDialog::OnListItemDeselected (wxListEvent& event)
{
if (DeviceListCtrl->GetSelectedItemCount() == 0)
StdButtonsOK->Disable();
}
void DeviceSelectionDialog::OnListItemSelected (wxListEvent& event)
{
HostDevice *device = (HostDevice *) (event.GetItem().GetData());
if (device)
{
SelectedDevice = *device;
StdButtonsOK->Enable();
}
else
StdButtonsOK->Disable();
}
}

View File

@@ -0,0 +1,46 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_DeviceSelectionDialog
#define TC_HEADER_Main_Forms_DeviceSelectionDialog
#include "Forms.h"
#include "Main/Main.h"
namespace TrueCrypt
{
class DeviceSelectionDialog : public DeviceSelectionDialogBase
{
public:
DeviceSelectionDialog (wxWindow* parent);
HostDeviceList DeviceList;
HostDevice SelectedDevice;
protected:
enum
{
ColumnDevice = 0,
#ifdef TC_WINDOWS
ColumnDrive,
#endif
ColumnSize,
#ifdef TC_WINDOWS
ColumnName
#else
ColumnMountPoint
#endif
};
void OnListItemActivated (wxListEvent& event);
void OnListItemDeselected (wxListEvent& event);
void OnListItemSelected (wxListEvent& event);
};
}
#endif // TC_HEADER_Main_Forms_DeviceSelectionDialog

View File

@@ -0,0 +1,137 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Volume/EncryptionTest.h"
#include "Volume/Hash.h"
#include "Main/GraphicUserInterface.h"
#include "BenchmarkDialog.h"
#include "EncryptionOptionsWizardPage.h"
#include "EncryptionTestDialog.h"
namespace TrueCrypt
{
EncryptionOptionsWizardPage::EncryptionOptionsWizardPage (wxPanel* parent)
: EncryptionOptionsWizardPageBase (parent)
{
EncryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms();
foreach (shared_ptr <EncryptionAlgorithm> ea, EncryptionAlgorithms)
{
if (!ea->IsDeprecated())
EncryptionAlgorithmChoice->Append (ea->GetName(), ea.get());
}
EncryptionAlgorithmChoice->Select (0);
Hashes = Hash::GetAvailableAlgorithms();
foreach (shared_ptr <Hash> hash, Hashes)
{
if (!hash->IsDeprecated())
HashChoice->Append (hash->GetName(), hash.get());
}
HashChoice->Select (0);
OnEncryptionAlgorithmSelected();
}
shared_ptr <EncryptionAlgorithm> EncryptionOptionsWizardPage::GetEncryptionAlgorithm () const
{
return Gui->GetSelectedData <EncryptionAlgorithm> (EncryptionAlgorithmChoice)->GetNew();
}
shared_ptr <Hash> EncryptionOptionsWizardPage::GetHash () const
{
return Gui->GetSelectedData <Hash> (HashChoice)->GetNew();
}
void EncryptionOptionsWizardPage::OnBenchmarkButtonClick (wxCommandEvent& event)
{
BenchmarkDialog dialog (this);
dialog.ShowModal();
}
void EncryptionOptionsWizardPage::OnEncryptionAlgorithmSelected ()
{
FreezeScope freeze (this);
shared_ptr <EncryptionAlgorithm> ea = GetEncryptionAlgorithm();
CipherList ciphers = ea->GetCiphers();
if (ciphers.size() == 1)
{
EncryptionAlgorithmHyperlink->SetLabel (StringFormatter (LangString["MORE_INFO_ABOUT"], ea->GetName()));
if (typeid (*ea) == typeid (AES))
EncryptionAlgorithmStaticText->SetLabel (LangString["AES_HELP"]);
else if (typeid (*ea) == typeid (Serpent))
EncryptionAlgorithmStaticText->SetLabel (LangString["SERPENT_HELP"]);
else if (typeid (*ea) == typeid (Twofish))
EncryptionAlgorithmStaticText->SetLabel (LangString["TWOFISH_HELP"]);
else
EncryptionAlgorithmStaticText->SetLabel (L"");
}
else
{
if (ciphers.size() == 2)
{
EncryptionAlgorithmStaticText->SetLabel (StringFormatter (LangString["TWO_LAYER_CASCADE_HELP"],
ciphers[0]->GetName(), (int) ciphers[0]->GetKeySize() * 8,
ciphers[1]->GetName(), (int) ciphers[1]->GetKeySize() * 8));
}
else if (ciphers.size() == 3)
{
EncryptionAlgorithmStaticText->SetLabel (StringFormatter (LangString["THREE_LAYER_CASCADE_HELP"],
ciphers[0]->GetName(), (int) ciphers[0]->GetKeySize() * 8,
ciphers[1]->GetName(), (int) ciphers[1]->GetKeySize() * 8,
ciphers[2]->GetName(), (int) ciphers[2]->GetKeySize() * 8));
}
else
EncryptionAlgorithmStaticText->SetLabel (L"");
EncryptionAlgorithmHyperlink->SetLabel (_("More information"));
}
Layout();
}
void EncryptionOptionsWizardPage::OnEncryptionAlgorithmHyperlinkClick (wxHyperlinkEvent& event)
{
if (GetEncryptionAlgorithm()->GetCiphers().size() == 1)
Gui->OpenHomepageLink (this, wxString (GetEncryptionAlgorithm()->GetName()).Lower());
else
Gui->OpenHomepageLink (this, L"cascades");
}
void EncryptionOptionsWizardPage::OnHashHyperlinkClick (wxHyperlinkEvent& event)
{
Gui->OpenHomepageLink (this, L"hashalgorithms");
}
void EncryptionOptionsWizardPage::OnTestButtonClick (wxCommandEvent& event)
{
EncryptionTestDialog dialog (this);
dialog.ShowModal();
}
void EncryptionOptionsWizardPage::SetEncryptionAlgorithm (shared_ptr <EncryptionAlgorithm> algorithm)
{
if (algorithm)
{
EncryptionAlgorithmChoice->SetStringSelection (algorithm->GetName());
OnEncryptionAlgorithmSelected ();
}
}
void EncryptionOptionsWizardPage::SetHash (shared_ptr <Hash> hash)
{
if (hash)
HashChoice->SetStringSelection (hash->GetName());
}
}

View File

@@ -0,0 +1,41 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_EncryptionOptionsWizardPage
#define TC_HEADER_Main_Forms_EncryptionOptionsWizardPage
#include "Forms.h"
namespace TrueCrypt
{
class EncryptionOptionsWizardPage : public EncryptionOptionsWizardPageBase
{
public:
EncryptionOptionsWizardPage (wxPanel* parent);
shared_ptr <EncryptionAlgorithm> GetEncryptionAlgorithm () const;
shared_ptr <Hash> GetHash () const;
bool IsValid () { return true; }
void SetPageText (const wxString &text) { }
void SetEncryptionAlgorithm (shared_ptr <EncryptionAlgorithm> algorithm);
void SetHash (shared_ptr <Hash> hash);
protected:
void OnBenchmarkButtonClick (wxCommandEvent& event);
void OnEncryptionAlgorithmHyperlinkClick (wxHyperlinkEvent& event);
void OnEncryptionAlgorithmSelected ();
void OnEncryptionAlgorithmSelected (wxCommandEvent& event) { OnEncryptionAlgorithmSelected(); }
void OnHashHyperlinkClick (wxHyperlinkEvent& event);
void OnTestButtonClick (wxCommandEvent& event);
EncryptionAlgorithmList EncryptionAlgorithms;
HashList Hashes;
};
}
#endif // TC_HEADER_Main_Forms_EncryptionOptionsWizardPage

View File

@@ -0,0 +1,227 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Volume/EncryptionModeXTS.h"
#include "Volume/EncryptionTest.h"
#include "Main/GraphicUserInterface.h"
#include "EncryptionTestDialog.h"
namespace TrueCrypt
{
EncryptionTestDialog::EncryptionTestDialog (wxWindow* parent)
: EncryptionTestDialogBase (parent)
{
EncryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms();
foreach (shared_ptr <EncryptionAlgorithm> ea, EncryptionAlgorithms)
{
if (!ea->IsDeprecated())
EncryptionAlgorithmChoice->Append (ea->GetName(), ea.get());
}
EncryptionAlgorithmChoice->Select (0);
Reset();
Fit();
Layout();
Center();
}
void EncryptionTestDialog::EncryptOrDecrypt (bool encrypt)
{
try
{
bool xts = XtsModeCheckBox->IsChecked();
shared_ptr <EncryptionAlgorithm> ea = GetSelectedEncryptionAlgorithm();
Buffer key;
GetTextCtrlData (KeyTextCtrl, key);
if (key.Size() != ea->GetKeySize())
throw_err (LangString["TEST_KEY_SIZE"]);
ea->SetKey (key);
Buffer data;
GetTextCtrlData (encrypt ? PlainTextTextCtrl : CipherTextTextCtrl, data);
if (data.Size() != ea->GetMaxBlockSize())
throw_err (LangString[encrypt ? "TEST_PLAINTEXT_SIZE" : "TEST_CIPHERTEXT_SIZE"]);
if (xts)
{
Buffer secondaryKey;
GetTextCtrlData (SecondaryKeyTextCtrl, secondaryKey);
if (secondaryKey.Size() != ea->GetKeySize())
throw_err (LangString["TEST_INCORRECT_SECONDARY_KEY_SIZE"]);
uint64 dataUnitNumber;
size_t blockNumber;
try
{
dataUnitNumber = StringConverter::ToUInt64 (wstring (DataUnitNumberTextCtrl->GetValue()));
}
catch (...)
{
DataUnitNumberTextCtrl->SetFocus();
throw StringConversionFailed (SRC_POS);
}
try
{
blockNumber = StringConverter::ToUInt32 (wstring (BlockNumberTextCtrl->GetValue()));
if (blockNumber > 31)
{
blockNumber = 31;
BlockNumberTextCtrl->SetValue (L"31");
}
}
catch (...)
{
BlockNumberTextCtrl->SetFocus();
throw StringConversionFailed (SRC_POS);
}
shared_ptr <EncryptionMode> xts (new EncryptionModeXTS);
xts->SetKey (secondaryKey);
ea->SetMode (xts);
Buffer sector (ENCRYPTION_DATA_UNIT_SIZE);
BufferPtr block = sector.GetRange (blockNumber * ea->GetMaxBlockSize(), ea->GetMaxBlockSize());
block.CopyFrom (data);
if (encrypt)
ea->EncryptSectors (sector, dataUnitNumber, 1, sector.Size());
else
ea->DecryptSectors (sector, dataUnitNumber, 1, sector.Size());
data.CopyFrom (block);
}
else
{
if (encrypt)
ea->GetCiphers().front()->EncryptBlock (data);
else
ea->GetCiphers().front()->DecryptBlock (data);
}
SetTextCtrlData (encrypt ? CipherTextTextCtrl : PlainTextTextCtrl, data);
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
shared_ptr <EncryptionAlgorithm> EncryptionTestDialog::GetSelectedEncryptionAlgorithm () const
{
return Gui->GetSelectedData <EncryptionAlgorithm> (EncryptionAlgorithmChoice)->GetNew();
}
void EncryptionTestDialog::GetTextCtrlData (wxTextCtrl *textCtrl, Buffer &buffer) const
{
vector <byte> data;
string dataStr = StringConverter::ToSingle (wstring (textCtrl->GetValue()));
for (size_t i = 0; i < dataStr.size() / 2; ++i)
{
unsigned int dataByte;
if (sscanf (dataStr.substr (i * 2, 2).c_str(), "%x", &dataByte) != 1)
{
textCtrl->SetFocus();
throw StringConversionFailed (SRC_POS);
}
data.push_back ((byte) dataByte);
}
if (data.empty())
return;
buffer.CopyFrom (ConstBufferPtr (&data.front(), data.size()));
}
void EncryptionTestDialog::OnAutoTestAllButtonClick (wxCommandEvent& event)
{
try
{
{
wxBusyCursor busy;
EncryptionTest::TestAll();
}
Gui->ShowInfo ("TESTS_PASSED");
}
catch (Exception &e)
{
Gui->ShowError (e);
Gui->ShowError ("TESTS_FAILED");
}
}
void EncryptionTestDialog::OnEncryptionAlgorithmSelected ()
{
shared_ptr <EncryptionAlgorithm> ea = GetSelectedEncryptionAlgorithm();
KeySizeStaticText->SetLabel (StringFormatter (L"{0} {1}", (uint32) ea->GetKeySize() * 8, LangString["BITS"]));
Buffer key (ea->GetKeySize());
key.Zero();
SetTextCtrlData (KeyTextCtrl, key);
SetTextCtrlData (SecondaryKeyTextCtrl, key);
Buffer block (ea->GetMaxBlockSize());
block.Zero();
SetTextCtrlData (PlainTextTextCtrl, block);
SetTextCtrlData (CipherTextTextCtrl, block);
if (ea->GetCiphers().size() > 1)
{
XtsModeCheckBox->Disable();
XtsModeCheckBox->SetValue (true);
SecondaryKeyTextCtrl->Enable (true);
DataUnitNumberTextCtrl->Enable (true);
BlockNumberTextCtrl->Enable (true);
}
else
XtsModeCheckBox->Enable();
}
void EncryptionTestDialog::OnXtsModeCheckBoxClick (wxCommandEvent& event)
{
bool enabled = event.IsChecked();
SecondaryKeyTextCtrl->Enable (enabled);
DataUnitNumberTextCtrl->Enable (enabled);
BlockNumberTextCtrl->Enable (enabled);
}
void EncryptionTestDialog::SetTextCtrlData (wxTextCtrl *textCtrl, const BufferPtr &data)
{
wstring str;
for (size_t i = 0; i < data.Size(); i++)
{
char strBuf[3];
sprintf (strBuf, "%02x", (int) data[i]);
str += StringConverter::ToWide (strBuf);
}
textCtrl->SetValue (str);
}
void EncryptionTestDialog::Reset ()
{
OnEncryptionAlgorithmSelected();
DataUnitNumberTextCtrl->SetValue (L"0");
BlockNumberTextCtrl->SetValue (L"0");
}
}

View File

@@ -0,0 +1,40 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_EncryptionTestDialog
#define TC_HEADER_Main_Forms_EncryptionTestDialog
#include "Forms.h"
#include "Main/Main.h"
namespace TrueCrypt
{
class EncryptionTestDialog : public EncryptionTestDialogBase
{
public:
EncryptionTestDialog (wxWindow* parent);
protected:
void EncryptOrDecrypt (bool encrypt);
shared_ptr <EncryptionAlgorithm> GetSelectedEncryptionAlgorithm () const;
void GetTextCtrlData (wxTextCtrl *textCtrl, Buffer &buffer) const;
void OnAutoTestAllButtonClick (wxCommandEvent& event);
void OnDecryptButtonClick (wxCommandEvent& event) { EncryptOrDecrypt (false); }
void OnEncryptButtonClick (wxCommandEvent& event) { EncryptOrDecrypt (true); }
void OnEncryptionAlgorithmSelected ();
void OnEncryptionAlgorithmSelected (wxCommandEvent& event) { OnEncryptionAlgorithmSelected(); }
void OnResetButtonClick (wxCommandEvent& event) { Reset(); }
void OnXtsModeCheckBoxClick (wxCommandEvent& event);
void SetTextCtrlData (wxTextCtrl *textCtrl, const BufferPtr &data);
void Reset ();
EncryptionAlgorithmList EncryptionAlgorithms;
};
}
#endif // TC_HEADER_Main_Forms_EncryptionTestDialog

View File

@@ -0,0 +1,118 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "FavoriteVolumesDialog.h"
namespace TrueCrypt
{
FavoriteVolumesDialog::FavoriteVolumesDialog (wxWindow* parent, const FavoriteVolumeList &favorites, size_t newItemCount)
: FavoriteVolumesDialogBase (parent), Favorites (favorites)
{
list <int> colPermilles;
FavoritesListCtrl->InsertColumn (ColumnVolumePath, LangString["VOLUME"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (500);
FavoritesListCtrl->InsertColumn (ColumnMountPoint, LangString["MOUNT_POINT"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (500);
FavoritesListCtrl->SetMinSize (wxSize (400, -1));
Gui->SetListCtrlHeight (FavoritesListCtrl, 15);
Gui->SetListCtrlColumnWidths (FavoritesListCtrl, colPermilles);
Layout();
Fit();
Center();
#ifdef TC_MACOSX
// wxMac cannot insert items to wxListCtrl due to a bug
MoveUpButton->Show (false);
MoveDownButton->Show (false);
#endif
vector <wstring> fields (FavoritesListCtrl->GetColumnCount());
size_t itemCount = 0;
foreach (shared_ptr <FavoriteVolume> favorite, Favorites)
{
fields[ColumnVolumePath] = favorite->Path;
fields[ColumnMountPoint] = favorite->MountPoint;
Gui->AppendToListCtrl (FavoritesListCtrl, fields, -1, favorite.get());
if (++itemCount > Favorites.size() - newItemCount)
{
FavoritesListCtrl->SetItemState (itemCount - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
FavoritesListCtrl->EnsureVisible (itemCount - 1);
}
}
UpdateButtons();
FavoritesListCtrl->SetFocus();
}
void FavoriteVolumesDialog::OnMoveDownButtonClick (wxCommandEvent& event)
{
FreezeScope freeze (this);
foreach_reverse (long itemIndex, Gui->GetListCtrlSelectedItems (FavoritesListCtrl))
{
if (itemIndex >= FavoritesListCtrl->GetItemCount() - 1)
break;
Gui->MoveListCtrlItem (FavoritesListCtrl, itemIndex, itemIndex + 1);
}
UpdateButtons();
}
void FavoriteVolumesDialog::OnMoveUpButtonClick (wxCommandEvent& event)
{
FreezeScope freeze (this);
foreach (long itemIndex, Gui->GetListCtrlSelectedItems (FavoritesListCtrl))
{
if (itemIndex == 0)
break;
Gui->MoveListCtrlItem (FavoritesListCtrl, itemIndex, itemIndex - 1);
}
UpdateButtons();
}
void FavoriteVolumesDialog::OnOKButtonClick (wxCommandEvent& event)
{
FavoriteVolumeList newFavorites;
for (long i = 0; i < FavoritesListCtrl->GetItemCount(); i++)
{
newFavorites.push_back (make_shared <FavoriteVolume> (
*reinterpret_cast <FavoriteVolume *> (FavoritesListCtrl->GetItemData (i))));
}
Favorites = newFavorites;
EndModal (wxID_OK);
}
void FavoriteVolumesDialog::OnRemoveAllButtonClick (wxCommandEvent& event)
{
FavoritesListCtrl->DeleteAllItems();
UpdateButtons();
}
void FavoriteVolumesDialog::OnRemoveButtonClick (wxCommandEvent& event)
{
long offset = 0;
foreach (long item, Gui->GetListCtrlSelectedItems (FavoritesListCtrl))
FavoritesListCtrl->DeleteItem (item - offset++);
}
void FavoriteVolumesDialog::UpdateButtons ()
{
bool selected = FavoritesListCtrl->GetSelectedItemCount() > 0;
MoveDownButton->Enable (selected);
MoveUpButton->Enable (selected);
RemoveAllButton->Enable (FavoritesListCtrl->GetItemCount() > 0);
RemoveButton->Enable (selected);
}
}

View File

@@ -0,0 +1,45 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_FavoriteVolumesDialog
#define TC_HEADER_Main_Forms_FavoriteVolumesDialog
#include "Forms.h"
#include "Main/Main.h"
#include "Main/FavoriteVolume.h"
namespace TrueCrypt
{
class FavoriteVolumesDialog : public FavoriteVolumesDialogBase
{
public:
FavoriteVolumesDialog (wxWindow* parent, const FavoriteVolumeList &favorites, size_t newItemCount = 0);
FavoriteVolumeList GetFavorites () const { return Favorites; }
protected:
void OnListItemDeselected (wxListEvent& event) { UpdateButtons (); }
void OnListItemSelected (wxListEvent& event) { UpdateButtons (); }
void OnMoveUpButtonClick (wxCommandEvent& event);
void OnMoveDownButtonClick (wxCommandEvent& event);
void OnOKButtonClick (wxCommandEvent& event);
void OnRemoveAllButtonClick (wxCommandEvent& event);
void OnRemoveButtonClick (wxCommandEvent& event);
void UpdateButtons ();
enum
{
ColumnVolumePath = 0,
ColumnMountPoint
};
FavoriteVolumeList Favorites;
};
}
#endif // TC_HEADER_Main_Forms_FavoriteVolumesDialog

3062
src/Main/Forms/Forms.cpp Normal file

File diff suppressed because it is too large Load Diff

1023
src/Main/Forms/Forms.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "InfoWizardPage.h"
namespace TrueCrypt
{
InfoWizardPage::InfoWizardPage (wxPanel *parent, const wxString &actionButtonText, shared_ptr <Functor> actionFunctor)
: InfoWizardPageBase (parent)
{
if (!actionButtonText.empty())
{
wxButton *actionButton = new wxButton (this, wxID_ANY, actionButtonText);
ActionFunctor = actionFunctor;
actionButton->Connect (wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (InfoWizardPage::OnActionButtonClick), nullptr, this);
InfoPageSizer->Add (actionButton, 0, wxALL, 5);
}
InfoStaticText->SetFocus();
}
void InfoWizardPage::SetMaxStaticTextWidth (int width)
{
InfoStaticText->Wrap (width);
}
}

View File

@@ -0,0 +1,32 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_InfoWizardPage
#define TC_HEADER_Main_Forms_InfoWizardPage
#include "Forms.h"
namespace TrueCrypt
{
class InfoWizardPage : public InfoWizardPageBase
{
public:
InfoWizardPage (wxPanel *parent, const wxString &actionButtonText = wxEmptyString, shared_ptr <Functor> actionFunctor = shared_ptr <Functor> ());
bool IsValid () { return true; }
void SetMaxStaticTextWidth (int width);
void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); }
protected:
virtual void OnActionButtonClick (wxCommandEvent& event) { (*ActionFunctor)(); }
shared_ptr <Functor> ActionFunctor;
};
}
#endif // TC_HEADER_Main_Forms_InfoWizardPage

View File

@@ -0,0 +1,118 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "Volume/Hash.h"
#include "KeyfileGeneratorDialog.h"
namespace TrueCrypt
{
KeyfileGeneratorDialog::KeyfileGeneratorDialog (wxWindow* parent) : KeyfileGeneratorDialogBase (parent)
{
RandomNumberGenerator::Start();
Hashes = Hash::GetAvailableAlgorithms();
foreach (shared_ptr <Hash> hash, Hashes)
{
if (!hash->IsDeprecated())
HashChoice->Append (hash->GetName(), hash.get());
}
HashChoice->Select (0);
RandomNumberGenerator::SetHash (Gui->GetSelectedData <Hash> (HashChoice)->GetNew());
ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24));
MouseStaticText->Wrap (Gui->GetCharWidth (MouseStaticText) * 70);
MainSizer->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 24));
Layout();
Fit();
Center();
foreach (wxWindow *c, this->GetChildren())
c->Connect (wxEVT_MOTION, wxMouseEventHandler (KeyfileGeneratorDialog::OnMouseMotion), nullptr, this);
}
KeyfileGeneratorDialog::~KeyfileGeneratorDialog ()
{
}
void KeyfileGeneratorDialog::OnGenerateButtonClick (wxCommandEvent& event)
{
try
{
FilePathList files = Gui->SelectFiles (Gui->GetActiveWindow(), wxEmptyString, true);
if (files.empty())
return;
SecureBuffer keyfileBuffer (VolumePassword::MaxSize);
RandomNumberGenerator::GetData (keyfileBuffer);
{
File keyfile;
keyfile.Open (*files.front(), File::CreateWrite);
keyfile.Write (keyfileBuffer);
}
Gui->ShowInfo ("KEYFILE_CREATED");
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
void KeyfileGeneratorDialog::OnHashSelected (wxCommandEvent& event)
{
RandomNumberGenerator::SetHash (Gui->GetSelectedData <Hash> (HashChoice)->GetNew());
}
void KeyfileGeneratorDialog::OnMouseMotion (wxMouseEvent& event)
{
event.Skip();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&event), sizeof (event)));
long coord = event.GetX();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord)));
coord = event.GetY();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord)));
if (ShowRandomPoolCheckBox->IsChecked())
ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24));
}
void KeyfileGeneratorDialog::OnShowRandomPoolCheckBoxClicked (wxCommandEvent& event)
{
if (!event.IsChecked())
RandomPoolStaticText->SetLabel (L"");
}
void KeyfileGeneratorDialog::ShowBytes (wxStaticText *textCtrl, const ConstBufferPtr &buffer, bool appendDots)
{
wxString str;
for (size_t i = 0; i < buffer.Size(); ++i)
{
str += wxString::Format (L"%02X", buffer[i]);
}
if (appendDots)
str += L"..";
textCtrl->SetLabel (str.c_str());
for (size_t i = 0; i < str.size(); ++i)
{
str[i] = L'X';
}
}
}

View File

@@ -0,0 +1,34 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_KeyfileGeneratorDialog
#define TC_HEADER_Main_Forms_KeyfileGeneratorDialog
#include "Forms.h"
#include "Main/Main.h"
namespace TrueCrypt
{
class KeyfileGeneratorDialog : public KeyfileGeneratorDialogBase
{
public:
KeyfileGeneratorDialog (wxWindow* parent);
~KeyfileGeneratorDialog ();
protected:
void OnGenerateButtonClick (wxCommandEvent& event);
void OnHashSelected (wxCommandEvent& event);
void OnMouseMotion (wxMouseEvent& event);
void OnShowRandomPoolCheckBoxClicked (wxCommandEvent& event);
void ShowBytes (wxStaticText *textCtrl, const ConstBufferPtr &buffer, bool appendDots = true);
HashList Hashes;
};
}
#endif // TC_HEADER_Main_Forms_KeyfileGeneratorDialog

View File

@@ -0,0 +1,44 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "KeyfilesDialog.h"
namespace TrueCrypt
{
KeyfilesDialog::KeyfilesDialog (wxWindow* parent, shared_ptr <KeyfileList> keyfiles)
: KeyfilesDialogBase (parent), Keyfiles (keyfiles)
{
mKeyfilesPanel = new KeyfilesPanel (this, keyfiles);
PanelSizer->Add (mKeyfilesPanel, 1, wxALL | wxEXPAND);
WarningStaticText->SetLabel (LangString["IDT_KEYFILE_WARNING"]);
WarningStaticText->Wrap (Gui->GetCharWidth (this) * 15);
Layout();
Fit();
KeyfilesNoteStaticText->SetLabel (LangString["KEYFILES_NOTE"]);
KeyfilesNoteStaticText->Wrap (UpperSizer->GetSize().GetWidth() - Gui->GetCharWidth (this) * 2);
Layout();
Fit();
Center();
}
void KeyfilesDialog::OnCreateKeyfileButttonClick (wxCommandEvent& event)
{
Gui->CreateKeyfile();
}
void KeyfilesDialog::OnKeyfilesHyperlinkClick (wxHyperlinkEvent& event)
{
Gui->OpenHomepageLink (this, L"keyfiles");
}
}

View File

@@ -0,0 +1,33 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_KeyfilesDialog
#define TC_HEADER_Main_Forms_KeyfilesDialog
#include "Forms.h"
#include "Main/Main.h"
#include "KeyfilesPanel.h"
namespace TrueCrypt
{
class KeyfilesDialog : public KeyfilesDialogBase
{
public:
KeyfilesDialog (wxWindow* parent, shared_ptr <KeyfileList> keyfiles);
shared_ptr <KeyfileList> GetKeyfiles () const { return mKeyfilesPanel->GetKeyfiles(); }
protected:
void OnCreateKeyfileButttonClick (wxCommandEvent& event);
void OnKeyfilesHyperlinkClick (wxHyperlinkEvent& event);
shared_ptr <KeyfileList> Keyfiles;
KeyfilesPanel *mKeyfilesPanel;
};
}
#endif // TC_HEADER_Main_Forms_KeyfilesDialog

View File

@@ -0,0 +1,160 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "KeyfilesPanel.h"
#include "SecurityTokenKeyfilesDialog.h"
namespace TrueCrypt
{
KeyfilesPanel::KeyfilesPanel (wxWindow* parent, shared_ptr <KeyfileList> keyfiles)
: KeyfilesPanelBase (parent)
{
KeyfilesListCtrl->InsertColumn (0, LangString["KEYFILE"], wxLIST_FORMAT_LEFT, 1);
Gui->SetListCtrlHeight (KeyfilesListCtrl, 10);
Layout();
Fit();
if (keyfiles)
{
foreach_ref (const Keyfile &k, *keyfiles)
{
vector <wstring> fields;
fields.push_back (FilesystemPath (k));
Gui->AppendToListCtrl (KeyfilesListCtrl, fields);
}
}
class FileDropTarget : public wxFileDropTarget
{
public:
FileDropTarget (KeyfilesPanel *panel) : Panel (panel) { }
wxDragResult OnDragOver (wxCoord x, wxCoord y, wxDragResult def)
{
return wxDragLink;
}
bool OnDropFiles (wxCoord x, wxCoord y, const wxArrayString &filenames)
{
foreach (const wxString &f, filenames)
Panel->AddKeyfile (make_shared <Keyfile> (wstring (f)));
return true;
}
protected:
KeyfilesPanel *Panel;
};
SetDropTarget (new FileDropTarget (this));
KeyfilesListCtrl->SetDropTarget (new FileDropTarget (this));
#ifdef TC_MACOSX
foreach (wxWindow *c, GetChildren())
c->SetDropTarget (new FileDropTarget (this));
#endif
UpdateButtons();
}
void KeyfilesPanel::AddKeyfile (shared_ptr <Keyfile> keyfile)
{
vector <wstring> fields;
fields.push_back (FilesystemPath (*keyfile));
Gui->AppendToListCtrl (KeyfilesListCtrl, fields);
UpdateButtons();
}
shared_ptr <KeyfileList> KeyfilesPanel::GetKeyfiles () const
{
make_shared_auto (KeyfileList, keyfiles);
for (long i = 0; i < KeyfilesListCtrl->GetItemCount(); i++)
keyfiles->push_back (make_shared <Keyfile> (wstring (KeyfilesListCtrl->GetItemText (i))));
return keyfiles;
}
void KeyfilesPanel::OnAddDirectoryButtonClick (wxCommandEvent& event)
{
DirectoryPath dir = Gui->SelectDirectory (this, LangString["SELECT_KEYFILE_PATH"]);
if (!dir.IsEmpty())
{
vector <wstring> fields;
fields.push_back (dir);
Gui->AppendToListCtrl (KeyfilesListCtrl, fields);
UpdateButtons();
}
}
void KeyfilesPanel::OnAddFilesButtonClick (wxCommandEvent& event)
{
FilePathList files = Gui->SelectFiles (this, LangString["SELECT_KEYFILES"], false, true);
foreach_ref (const FilePath &f, files)
{
vector <wstring> fields;
fields.push_back (f);
Gui->AppendToListCtrl (KeyfilesListCtrl, fields);
}
UpdateButtons();
}
void KeyfilesPanel::OnAddSecurityTokenSignatureButtonClick (wxCommandEvent& event)
{
try
{
SecurityTokenKeyfilesDialog dialog (this);
if (dialog.ShowModal() == wxID_OK)
{
foreach (const SecurityTokenKeyfilePath &path, dialog.GetSelectedSecurityTokenKeyfilePaths())
{
vector <wstring> fields;
fields.push_back (path);
Gui->AppendToListCtrl (KeyfilesListCtrl, fields);
}
UpdateButtons();
}
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
void KeyfilesPanel::OnListSizeChanged (wxSizeEvent& event)
{
list <int> colPermilles;
colPermilles.push_back (1000);
Gui->SetListCtrlColumnWidths (KeyfilesListCtrl, colPermilles);
event.Skip();
}
void KeyfilesPanel::OnRemoveAllButtonClick (wxCommandEvent& event)
{
KeyfilesListCtrl->DeleteAllItems();
UpdateButtons();
}
void KeyfilesPanel::OnRemoveButtonClick (wxCommandEvent& event)
{
long offset = 0;
foreach (long item, Gui->GetListCtrlSelectedItems (KeyfilesListCtrl))
KeyfilesListCtrl->DeleteItem (item - offset++);
UpdateButtons();
}
void KeyfilesPanel::UpdateButtons ()
{
RemoveAllButton->Enable (KeyfilesListCtrl->GetItemCount() > 0);
RemoveButton->Enable (KeyfilesListCtrl->GetSelectedItemCount() > 0);
}
}

View File

@@ -0,0 +1,37 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_KeyfilesPanel
#define TC_HEADER_Main_Forms_KeyfilesPanel
#include "Forms.h"
#include "Main/Main.h"
namespace TrueCrypt
{
class KeyfilesPanel : public KeyfilesPanelBase
{
public:
KeyfilesPanel (wxWindow* parent, shared_ptr <KeyfileList> keyfiles);
void AddKeyfile (shared_ptr <Keyfile> keyfile);
shared_ptr <KeyfileList> GetKeyfiles () const;
protected:
void OnAddFilesButtonClick (wxCommandEvent& event);
void OnAddDirectoryButtonClick (wxCommandEvent& event);
void OnAddSecurityTokenSignatureButtonClick (wxCommandEvent& event);
void OnListItemDeselected (wxListEvent& event) { UpdateButtons(); }
void OnListItemSelected (wxListEvent& event) { UpdateButtons(); }
void OnListSizeChanged (wxSizeEvent& event);
void OnRemoveButtonClick (wxCommandEvent& event);
void OnRemoveAllButtonClick (wxCommandEvent& event);
void UpdateButtons ();
};
}
#endif // TC_HEADER_Main_Forms_KeyfilesPanel

View File

@@ -0,0 +1,28 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "LegalNoticesDialog.h"
#include "Main/GraphicUserInterface.h"
#include "Main/Resources.h"
namespace TrueCrypt
{
LegalNoticesDialog::LegalNoticesDialog (wxWindow* parent) : LegalNoticesDialogBase (parent)
{
LegalNoticesTextCtrl->SetMinSize (wxSize (
Gui->GetCharWidth (LegalNoticesTextCtrl) * 88,
Gui->GetCharHeight (LegalNoticesTextCtrl) * 28));
Layout();
Fit();
Center();
LegalNoticesTextCtrl->ChangeValue (StringConverter::ToWide (Resources::GetLegalNotices()));
}
}

View File

@@ -0,0 +1,23 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_LegalNoticesDialog
#define TC_HEADER_Main_Forms_LegalNoticesDialog
#include "Forms.h"
namespace TrueCrypt
{
class LegalNoticesDialog : public LegalNoticesDialogBase
{
public:
LegalNoticesDialog (wxWindow* parent);
};
}
#endif // TC_HEADER_Main_Forms_LegalNoticesDialog

1585
src/Main/Forms/MainFrame.cpp Normal file

File diff suppressed because it is too large Load Diff

173
src/Main/Forms/MainFrame.h Normal file
View File

@@ -0,0 +1,173 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_MainFrame
#define TC_HEADER_Main_Forms_MainFrame
#include "Forms.h"
#include "ChangePasswordDialog.h"
namespace TrueCrypt
{
struct FavoriteVolume;
class MainFrame : public MainFrameBase
{
public:
MainFrame (wxWindow* parent);
virtual ~MainFrame ();
void OnDeviceChange (const DirectoryPath &mountPoint = DirectoryPath());
#ifdef TC_UNIX
static FilePath GetShowRequestFifoPath () { return Application::GetConfigFilePath (L".show-request-queue", true); }
#endif
protected:
enum
{
ColumnSlot = 0,
ColumnPath,
ColumnSize,
#ifdef TC_WINDOWS
ColumnEA,
#else
ColumnMountPoint,
#endif
ColumnType
};
void AddToFavorites (const VolumeInfoList &volumes);
bool CanExit () const;
void ChangePassword (ChangePasswordDialog::Mode::Enum mode = ChangePasswordDialog::Mode::ChangePasswordAndKeyfiles);
void CheckFilesystem (bool repair = false);
bool CheckVolumePathNotEmpty () const;
void DismountVolume (shared_ptr <VolumeInfo> volume = shared_ptr <VolumeInfo> ());
const UserPreferences &GetPreferences () const { return Gui->GetPreferences(); }
shared_ptr <VolumeInfo> GetSelectedVolume () const;
shared_ptr <VolumePath> GetSelectedVolumePath () const { return make_shared <VolumePath> (wstring (VolumePathComboBox->GetValue())); }
void InitControls ();
void InitEvents ();
void InitMessageFilter ();
void InitPreferences ();
void InitTaskBarIcon ();
bool IsFreeSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); }
bool IsMountedSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && !Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); }
void LoadFavoriteVolumes ();
void LoadPreferences ();
void MountAllDevices ();
void MountAllFavorites ();
void MountVolume ();
void OnAboutMenuItemSelected (wxCommandEvent& event);
void OnActivate (wxActivateEvent& event);
void OnAddAllMountedToFavoritesMenuItemSelected (wxCommandEvent& event);
void OnAddToFavoritesMenuItemSelected (wxCommandEvent& event);
void OnBackupVolumeHeadersMenuItemSelected (wxCommandEvent& event);
void OnBeginnersTutorialMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"tutorial"); }
void OnBenchmarkMenuItemSelected (wxCommandEvent& event);
void OnChangeKeyfilesMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::ChangeKeyfiles); }
void OnChangePasswordMenuItemSelected (wxCommandEvent& event) { ChangePassword (); }
void OnChangePkcs5PrfMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::ChangePkcs5Prf); }
void OnCheckFilesystemMenuItemSelected( wxCommandEvent& event ) { CheckFilesystem (); }
void OnClearSlotSelectionMenuItemSelected (wxCommandEvent& event);
void OnClose (wxCloseEvent& event);
void OnCloseAllSecurityTokenSessionsMenuItemSelected (wxCommandEvent& event);
void OnContactMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"contact"); }
void OnCreateKeyfileMenuItemSelected (wxCommandEvent& event) { Gui->CreateKeyfile(); }
void OnCreateVolumeButtonClick (wxCommandEvent& event);
void OnDefaultKeyfilesMenuItemSelected (wxCommandEvent& event);
void OnDismountAllButtonClick (wxCommandEvent& event);
void OnDismountVolumeMenuItemSelected (wxCommandEvent& event) { DismountVolume(); }
void OnDownloadsMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"downloads"); }
void OnEncryptionTestMenuItemSelected (wxCommandEvent& event);
void OnExitButtonClick (wxCommandEvent& event);
void OnFavoriteVolumeMenuItemSelected (wxCommandEvent& event);
void OnFaqMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"faq"); }
void OnHiddenVolumeProtectionTriggered (shared_ptr <VolumeInfo> protectedVolume);
void OnHotkey (wxKeyEvent& event);
void OnHotkeysMenuItemSelected (wxCommandEvent& event);
void OnLegalNoticesMenuItemSelected (wxCommandEvent& event);
void OnListChanged ();
void OnListItemActivated (wxListEvent& event);
void OnListItemDeleted (long itemIndex);
void OnListItemDeselected (wxListEvent& event);
void OnListItemInserted (long itemIndex);
void OnListItemRightClick (wxListEvent& event);
void OnListItemSelected (wxListEvent& event);
void OnListItemSelectionChanged ();
void OnLogoBitmapClick (wxMouseEvent &event) { wxCommandEvent ev; OnAboutMenuItemSelected (ev); }
void OnManageSecurityTokenKeyfilesMenuItemSelected (wxCommandEvent& event);
void OnMountAllDevicesButtonClick (wxCommandEvent& event);
void OnMountAllFavoritesMenuItemSelected (wxCommandEvent& event);
void OnMountVolumeMenuItemSelected (wxCommandEvent& event) { MountVolume(); }
void OnNewsMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"news"); }
void OnNoHistoryCheckBoxClick (wxCommandEvent& event);
void OnOnlineHelpMenuItemSelected (wxCommandEvent& event) { Gui->OpenOnlineHelp (this); }
void OnOpenVolumeMenuItemSelected (wxCommandEvent& event) { OpenSelectedVolume(); }
void OnOpenVolumeSystemRequestEvent (EventArgs &args) { SetVolumePath (wstring (dynamic_cast <OpenVolumeSystemRequestEventArgs &> (args).mVolumePath)); }
void OnOrganizeFavoritesMenuItemSelected (wxCommandEvent& event);
void OnPreferencesMenuItemSelected (wxCommandEvent& event);
void OnPreferencesUpdated (EventArgs &args);
void OnRemoveKeyfilesMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::RemoveAllKeyfiles); }
void OnRepairFilesystemMenuItemSelected( wxCommandEvent& event ) { CheckFilesystem (true); }
void OnRestoreVolumeHeaderMenuItemSelected (wxCommandEvent& event);
void OnSecurityTokenPreferencesMenuItemSelected (wxCommandEvent& event);
void OnSelectDeviceAndMountMenuItemSelected (wxCommandEvent& event);
void OnSelectDeviceButtonClick (wxCommandEvent& event);
void OnSelectFileAndMountMenuItemSelected (wxCommandEvent& event);
void OnSelectFileButtonClick (wxCommandEvent& event);
void OnTimer ();
void OnVersionHistoryMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"history"); }
void OnVolumePropertiesButtonClick (wxCommandEvent& event);
void OnVolumeToolsButtonClick (wxCommandEvent& event);
void OnVolumeButtonClick (wxCommandEvent& event);
void OnVolumeDismounted (EventArgs &args) { UpdateVolumeList(); }
void OnVolumeMounted (EventArgs &args) { UpdateVolumeList(); }
void OnUserGuideMenuItemSelected (wxCommandEvent& event) { Gui->OpenUserGuide (this); }
void OnWebsiteMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"website"); }
void OnWipeCacheButtonClick (wxCommandEvent& event);
void OrganizeFavorites (const FavoriteVolumeList &favorites, size_t newItemCount = 0);
void OpenSelectedVolume () const;
void SavePreferences () const;
long SlotNumberToItemIndex (uint32 slotNumber) const;
void SetVolumePath (const VolumePath &path) { VolumePathComboBox->SetValue (wstring (path)); }
void ShowTaskBarIcon (bool show = true);
void UpdateControls ();
void UpdateVolumeList ();
void UpdateWipeCacheButton ();
void WipeCache ();
struct VolumeActivityMapEntry
{
VolumeActivityMapEntry () { }
VolumeActivityMapEntry (const VolumeInfo &volume, wxLongLong lastActivityTime)
: LastActivityTime (lastActivityTime),
SerialInstanceNumber (volume.SerialInstanceNumber),
TotalDataRead (volume.TotalDataRead),
TotalDataWritten (volume.TotalDataWritten)
{ }
wxLongLong LastActivityTime;
uint64 SerialInstanceNumber;
uint64 TotalDataRead;
uint64 TotalDataWritten;
};
map <int, FavoriteVolume> FavoriteVolumesMenuMap;
bool ListItemRightClickEventPending;
VolumeInfoList MountedVolumes;
auto_ptr <wxTaskBarIcon> mTaskBarIcon;
auto_ptr <wxTimer> mTimer;
long SelectedItemIndex;
VolumeSlotNumber SelectedSlotNumber;
int ShowRequestFifo;
map <wstring, VolumeActivityMapEntry> VolumeActivityMap;
};
}
#endif // TC_HEADER_Main_Forms_MainFrame

View File

@@ -0,0 +1,174 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/Main.h"
#include "Main/GraphicUserInterface.h"
#include "MountOptionsDialog.h"
namespace TrueCrypt
{
MountOptionsDialog::MountOptionsDialog (wxWindow *parent, MountOptions &options, const wxString &title, bool disableMountOptions)
: MountOptionsDialogBase (parent, wxID_ANY, wxString()
#ifdef __WXGTK__ // GTK apparently needs wxRESIZE_BORDER to support dynamic resizing
, wxDefaultPosition, wxSize (-1,-1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
#endif
), Options (options)
{
if (!title.empty())
this->SetTitle (title);
else if (options.Path && !options.Path->IsEmpty())
this->SetTitle (StringFormatter (LangString["ENTER_PASSWORD_FOR"], wstring (*options.Path)));
else
this->SetTitle (LangString["ENTER_TC_VOL_PASSWORD"]);
if (disableMountOptions)
OptionsButton->Show (false);
PasswordPanel = new VolumePasswordPanel (this, options.Password, options.Keyfiles, !disableMountOptions);
PasswordPanel->SetCacheCheckBoxValidator (wxGenericValidator (&Options.CachePassword));
PasswordSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND);
#ifdef __WXGTK__
FilesystemOptionsSizer->Remove (FilesystemSpacer);
OptionsPanel->Show (false);
Fit();
Layout();
SetMinSize (GetSize());
#endif
NoFilesystemCheckBox->SetValidator (wxGenericValidator (&Options.NoFilesystem));
RemovableCheckBox->SetValidator (wxGenericValidator (&Options.Removable));
PartitionInSystemEncryptionScopeCheckBox->SetValidator (wxGenericValidator (&Options.PartitionInSystemEncryptionScope));
TransferDataToWindow();
if (Options.MountPoint && !Options.MountPoint->IsEmpty())
MountPointTextCtrl->SetValue (wstring (*Options.MountPoint));
FilesystemOptionsTextCtrl->SetValue (Options.FilesystemOptions);
ReadOnlyCheckBox->SetValue (Options.Protection == VolumeProtection::ReadOnly);
ProtectionCheckBox->SetValue (Options.Protection == VolumeProtection::HiddenVolumeReadOnly);
OptionsButtonLabel = OptionsButton->GetLabel();
OptionsButton->SetLabel (OptionsButtonLabel + L" >");
OptionsPanel->Show (false);
ProtectionPasswordPanel = new VolumePasswordPanel (OptionsPanel, options.ProtectionPassword, options.ProtectionKeyfiles, false, true, true, false, false, _("P&assword to hidden volume:"));
ProtectionPasswordSizer->Add (ProtectionPasswordPanel, 1, wxALL | wxEXPAND);
UpdateDialog();
Center();
}
void MountOptionsDialog::OnInitDialog (wxInitDialogEvent& event)
{
PasswordPanel->SetFocusToPasswordTextCtrl();
}
void MountOptionsDialog::OnMountPointButtonClick (wxCommandEvent& event)
{
DirectoryPath dir = Gui->SelectDirectory (this, wxEmptyString, false);
if (!dir.IsEmpty())
MountPointTextCtrl->SetValue (wstring (dir));
}
void MountOptionsDialog::OnOKButtonClick (wxCommandEvent& event)
{
TransferDataFromWindow();
Options.Password = PasswordPanel->GetPassword();
Options.Keyfiles = PasswordPanel->GetKeyfiles();
if (ReadOnlyCheckBox->IsChecked())
{
Options.Protection = VolumeProtection::ReadOnly;
}
else if (ProtectionCheckBox->IsChecked())
{
Options.Protection = VolumeProtection::HiddenVolumeReadOnly;
Options.ProtectionPassword = ProtectionPasswordPanel->GetPassword();
Options.ProtectionKeyfiles = ProtectionPasswordPanel->GetKeyfiles();
}
else
{
Options.Protection = VolumeProtection::None;
}
wstring mountPoint (MountPointTextCtrl->GetValue());
if (!mountPoint.empty())
Options.MountPoint = make_shared <DirectoryPath> (mountPoint);
Options.FilesystemOptions = FilesystemOptionsTextCtrl->GetValue();
try
{
if (Options.Password)
Options.Password->CheckPortability();
}
catch (UnportablePassword &)
{
Gui->ShowWarning (LangString ["UNSUPPORTED_CHARS_IN_PWD_RECOM"]);
}
EndModal (wxID_OK);
}
void MountOptionsDialog::OnOptionsButtonClick (wxCommandEvent& event)
{
FreezeScope freeze (this);
OptionsPanel->Show (!OptionsPanel->IsShown());
UpdateDialog();
OptionsButton->SetLabel (OptionsButtonLabel + (OptionsPanel->IsShown() ? L" <" : L" >"));
}
void MountOptionsDialog::OnProtectionCheckBoxClick (wxCommandEvent& event)
{
FreezeScope freeze (this);
ProtectionPasswordPanel->Show (event.IsChecked());
Fit();
Layout();
ProtectionPasswordPanel->SetFocusToPasswordTextCtrl();
}
void MountOptionsDialog::OnProtectionHyperlinkClick (wxHyperlinkEvent& event)
{
Gui->OpenHomepageLink (this, L"hiddenvolprotection");
}
void MountOptionsDialog::UpdateDialog ()
{
FreezeScope freeze (this);
#ifdef TC_WINDOWS
FilesystemSizer->Show (false);
#else
FilesystemOptionsSizer->Show (!NoFilesystemCheckBox->IsChecked());
# ifdef TC_MACOSX
FilesystemOptionsStaticText->Show (false);
FilesystemOptionsTextCtrl->Show (false);
# endif
if (!Options.Path || Options.Path->IsEmpty())
{
MountPointTextCtrlStaticText->Show (false);
MountPointTextCtrl->Show (false);
MountPointButton->Show (false);
}
RemovableCheckBox->Show (false);
#endif
ProtectionSizer->Show (!ReadOnlyCheckBox->IsChecked());
ProtectionPasswordPanel->Show (!ReadOnlyCheckBox->IsChecked() && ProtectionCheckBox->IsChecked());
Fit();
Layout();
}
}

View File

@@ -0,0 +1,42 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_MountOptionsDialog
#define TC_HEADER_Main_Forms_MountOptionsDialog
#include "Forms.h"
#include "Main/Main.h"
#include "VolumePasswordPanel.h"
namespace TrueCrypt
{
class MountOptionsDialog : public MountOptionsDialogBase
{
public:
MountOptionsDialog (wxWindow* parent, MountOptions &options, const wxString &title = wxEmptyString, bool disableMountOptions = false);
void OnShow ();
protected:
void OnInitDialog (wxInitDialogEvent& event);
void OnMountPointButtonClick (wxCommandEvent& event);
void OnNoFilesystemCheckBoxClick (wxCommandEvent& event) { UpdateDialog(); }
void OnOKButtonClick (wxCommandEvent& event);
void OnOptionsButtonClick (wxCommandEvent& event);
void OnProtectionCheckBoxClick (wxCommandEvent& event);
void OnProtectionHyperlinkClick (wxHyperlinkEvent& event);
void OnReadOnlyCheckBoxClick (wxCommandEvent& event) { UpdateDialog(); }
void UpdateDialog ();
MountOptions &Options;
wxString OptionsButtonLabel;
VolumePasswordPanel *PasswordPanel;
VolumePasswordPanel *ProtectionPasswordPanel;
};
}
#endif // TC_HEADER_Main_Forms_MountOptionsDialog

View File

@@ -0,0 +1,45 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "NewSecurityTokenKeyfileDialog.h"
namespace TrueCrypt
{
NewSecurityTokenKeyfileDialog::NewSecurityTokenKeyfileDialog (wxWindow* parent, const wstring &keyfileName) : NewSecurityTokenKeyfileDialogBase (parent)
{
list <SecurityTokenInfo> tokens = SecurityToken::GetAvailableTokens();
if (tokens.empty())
throw_err (LangString ["NO_TOKENS_FOUND"]);
foreach (const SecurityTokenInfo &token, tokens)
{
wstringstream tokenLabel;
tokenLabel << L"[" << token.SlotId << L"] " << token.Label;
SecurityTokenChoice->Append (tokenLabel.str(), (void *) token.SlotId);
}
SecurityTokenChoice->Select (0);
KeyfileNameTextCtrl->SetValue (keyfileName);
KeyfileNameTextCtrl->SetMinSize (wxSize (Gui->GetCharWidth (KeyfileNameTextCtrl) * 32, -1));
Fit();
Layout();
Center();
}
void NewSecurityTokenKeyfileDialog::OnKeyfileNameChanged (wxCommandEvent& event)
{
StdButtonsOK->Enable (!KeyfileNameTextCtrl->GetValue().empty());
event.Skip();
}
}

View File

@@ -0,0 +1,30 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_NewSecurityTokenKeyfileDialog
#define TC_HEADER_Main_Forms_NewSecurityTokenKeyfileDialog
#include "Forms.h"
#include "Common/SecurityToken.h"
namespace TrueCrypt
{
class NewSecurityTokenKeyfileDialog : public NewSecurityTokenKeyfileDialogBase
{
public:
NewSecurityTokenKeyfileDialog (wxWindow* parent, const wstring &keyfileName);
wstring GetKeyfileName () const { return wstring (KeyfileNameTextCtrl->GetValue()); }
CK_SLOT_ID GetSelectedSlotId () const { return reinterpret_cast <CK_SLOT_ID> (SecurityTokenChoice->GetClientData (SecurityTokenChoice->GetSelection())); }
protected:
void OnKeyfileNameChanged (wxCommandEvent& event);
};
}
#endif // TC_HEADER_Main_Forms_NewSecurityTokenKeyfileDialog

View File

@@ -0,0 +1,488 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include <wx/dynlib.h>
#ifdef TC_WINDOWS
#include <wx/msw/registry.h>
#endif
#include "Common/SecurityToken.h"
#include "Main/Main.h"
#include "Main/Application.h"
#include "Main/GraphicUserInterface.h"
#include "Volume/Cipher.h"
#include "PreferencesDialog.h"
namespace TrueCrypt
{
PreferencesDialog::PreferencesDialog (wxWindow* parent)
: PreferencesDialogBase (parent),
LastVirtualKeyPressed (0),
Preferences (Gui->GetPreferences()),
RestoreValidatorBell (false)
{
#define TC_CHECK_BOX_VALIDATOR(NAME) (TC_JOIN(NAME,CheckBox))->SetValidator (wxGenericValidator (&Preferences.NAME));
#ifdef TC_MACOSX
PreferencesNotebook->SetMinSize (wxSize (Gui->GetCharWidth (PreferencesNotebook) * 108, -1));
#endif
// Security
TC_CHECK_BOX_VALIDATOR (DismountOnLogOff);
TC_CHECK_BOX_VALIDATOR (DismountOnPowerSaving);
TC_CHECK_BOX_VALIDATOR (DismountOnScreenSaver);
TC_CHECK_BOX_VALIDATOR (DismountOnInactivity);
DismountOnInactivitySpinCtrl->SetValidator (wxGenericValidator (&Preferences.MaxVolumeIdleTime));
TC_CHECK_BOX_VALIDATOR (ForceAutoDismount);
PreserveTimestampsCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.PreserveTimestamps));
TC_CHECK_BOX_VALIDATOR (WipeCacheOnAutoDismount);
TC_CHECK_BOX_VALIDATOR (WipeCacheOnClose);
// Mount options
CachePasswordsCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.CachePassword));
MountReadOnlyCheckBox->SetValue (Preferences.DefaultMountOptions.Protection == VolumeProtection::ReadOnly);
MountRemovableCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.Removable));
FilesystemOptionsTextCtrl->SetValue (Preferences.DefaultMountOptions.FilesystemOptions);
// Keyfiles
TC_CHECK_BOX_VALIDATOR (UseKeyfiles);
DefaultKeyfilesPanel = new KeyfilesPanel (DefaultKeyfilesPage, make_shared <KeyfileList> (Preferences.DefaultKeyfiles));
DefaultKeyfilesSizer->Add (DefaultKeyfilesPanel, 1, wxALL | wxEXPAND);
DefaultKeyfilesSizer->Layout();
TC_CHECK_BOX_VALIDATOR (BackgroundTaskEnabled);
TC_CHECK_BOX_VALIDATOR (CloseBackgroundTaskOnNoVolumes);
CloseBackgroundTaskOnNoVolumesCheckBox->Show (!Core->IsInPortableMode());
TC_CHECK_BOX_VALIDATOR (BackgroundTaskMenuDismountItemsEnabled);
TC_CHECK_BOX_VALIDATOR (BackgroundTaskMenuMountItemsEnabled);
TC_CHECK_BOX_VALIDATOR (BackgroundTaskMenuOpenItemsEnabled);
// Encryption
AesHwCpuSupportedStaticText->SetLabel (
#ifdef TC_AES_HW_CPU
(is_aes_hw_cpu_supported() ? LangString["UISTR_YES"] : LangString["UISTR_NO"]));
#else
LangString["NOT_APPLICABLE_OR_NOT_AVAILABLE"]);
#endif
NoHardwareCryptoCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.NoHardwareCrypto));
// Security tokens
Pkcs11ModulePathTextCtrl->SetValue (wstring (Preferences.SecurityTokenModule));
TC_CHECK_BOX_VALIDATOR (CloseSecurityTokenSessionsAfterMount);
// System integration
TC_CHECK_BOX_VALIDATOR (StartOnLogon);
TC_CHECK_BOX_VALIDATOR (MountDevicesOnLogon);
TC_CHECK_BOX_VALIDATOR (MountFavoritesOnLogon);
TC_CHECK_BOX_VALIDATOR (CloseExplorerWindowsOnDismount);
TC_CHECK_BOX_VALIDATOR (OpenExplorerWindowAfterMount);
NoKernelCryptoCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.NoKernelCrypto));
#ifdef TC_WINDOWS
// Hotkeys
TC_CHECK_BOX_VALIDATOR (BeepAfterHotkeyMountDismount);
TC_CHECK_BOX_VALIDATOR (DisplayMessageAfterHotkeyDismount);
#endif
TransferDataToWindow(); // Code below relies on TransferDataToWindow() called at this point
#if defined (TC_WINDOWS) || defined (TC_MACOSX)
FilesystemSizer->Show (false);
#else
// Auto-dismount is not supported on Linux as dismount may require the user to enter admin password
AutoDismountSizer->Show (false);
WipeCacheOnAutoDismountCheckBox->Show (false);
#endif
#ifndef TC_WINDOWS
LogOnSizer->Show (false);
MountRemovableCheckBox->Show (false);
CloseExplorerWindowsOnDismountCheckBox->Show (false);
#endif
#ifndef wxHAS_POWER_EVENTS
DismountOnPowerSavingCheckBox->Show (false);
#endif
#ifdef TC_MACOSX
DismountOnScreenSaverCheckBox->Show (false);
DismountOnLogOffCheckBox->SetLabel (_("TrueCrypt quits"));
OpenExplorerWindowAfterMountCheckBox->SetLabel (_("Open Finder window for successfully mounted volume"));
MountRemovableCheckBox->Show (false);
FilesystemSizer->Show (false);
LogOnSizer->Show (false);
CloseExplorerWindowsOnDismountCheckBox->Show (false);
#endif
#ifndef TC_LINUX
KernelServicesSizer->Show (false);
#endif
#ifdef TC_WINDOWS
// Hotkeys
list <int> colPermilles;
HotkeyListCtrl->InsertColumn (ColumnHotkeyDescription, LangString["ACTION"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (642);
HotkeyListCtrl->InsertColumn (ColumnHotkey, LangString["SHORTCUT"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (358);
vector <wstring> fields (HotkeyListCtrl->GetColumnCount());
UnregisteredHotkeys = Preferences.Hotkeys;
Hotkey::UnregisterList (Gui->GetMainFrame(), UnregisteredHotkeys);
foreach (shared_ptr <Hotkey> hotkey, Preferences.Hotkeys)
{
fields[ColumnHotkeyDescription] = hotkey->Description;
fields[ColumnHotkey] = hotkey->GetShortcutString();
Gui->AppendToListCtrl (HotkeyListCtrl, fields, -1, hotkey.get());
}
Gui->SetListCtrlHeight (HotkeyListCtrl, 5);
Layout();
Fit();
Gui->SetListCtrlColumnWidths (HotkeyListCtrl, colPermilles);
RestoreValidatorBell = !wxTextValidator::IsSilent();
wxTextValidator::SetBellOnError (true);
HotkeyTextCtrl->SetValidator (wxTextValidator (wxFILTER_INCLUDE_CHAR_LIST));
UpdateHotkeyButtons();
#endif
// Page setup
for (size_t page = 0; page < PreferencesNotebook->GetPageCount(); page++)
{
wxNotebookPage *np = PreferencesNotebook->GetPage (page);
if (np == HotkeysPage)
{
#ifndef TC_WINDOWS
PreferencesNotebook->RemovePage (page--);
continue;
#endif
}
np->Layout();
}
Layout();
Fit();
Center();
StdButtonsOK->SetDefault();
#ifdef TC_WINDOWS
// Hotkey timer
class Timer : public wxTimer
{
public:
Timer (PreferencesDialog *dialog) : Dialog (dialog) { }
void Notify()
{
Dialog->OnTimer();
}
PreferencesDialog *Dialog;
};
mTimer.reset (dynamic_cast <wxTimer *> (new Timer (this)));
mTimer->Start (25);
#endif
}
PreferencesDialog::~PreferencesDialog ()
{
if (RestoreValidatorBell)
wxTextValidator::SetBellOnError (false);
}
void PreferencesDialog::SelectPage (wxPanel *page)
{
for (size_t pageIndex = 0; pageIndex < PreferencesNotebook->GetPageCount(); pageIndex++)
{
if (PreferencesNotebook->GetPage (pageIndex) == page)
PreferencesNotebook->ChangeSelection (pageIndex);
}
}
void PreferencesDialog::OnAssignHotkeyButtonClick (wxCommandEvent& event)
{
#ifdef TC_WINDOWS
foreach (long item, Gui->GetListCtrlSelectedItems (HotkeyListCtrl))
{
Hotkey *hotkey = reinterpret_cast <Hotkey *> (HotkeyListCtrl->GetItemData (item));
int mods = 0;
mods |= HotkeyShiftCheckBox->IsChecked() ? wxMOD_SHIFT : 0;
mods |= HotkeyControlCheckBox->IsChecked() ? wxMOD_CONTROL : 0;
mods |= HotkeyAltCheckBox->IsChecked() ? wxMOD_ALT : 0;
mods |= HotkeyWinCheckBox->IsChecked() ? wxMOD_WIN : 0;
// F1 is help and F12 is reserved for use by the debugger at all times
if (mods == 0 && (LastVirtualKeyPressed == VK_F1 || LastVirtualKeyPressed == VK_F12))
{
Gui->ShowError ("CANNOT_USE_RESERVED_KEY");
return;
}
// Test if the hotkey can be registered
if (!this->RegisterHotKey (hotkey->Id, mods, LastVirtualKeyPressed))
{
Gui->ShowError (SystemException (SRC_POS));
return;
}
UnregisterHotKey (hotkey->Id);
foreach_ref (const Hotkey &h, Preferences.Hotkeys)
{
if (h.Id != hotkey->Id && h.VirtualKeyCode == LastVirtualKeyPressed && h.VirtualKeyModifiers == mods)
{
Gui->ShowError ("SHORTCUT_ALREADY_IN_USE");
return;
}
}
hotkey->VirtualKeyCode = LastVirtualKeyPressed;
hotkey->VirtualKeyModifiers = mods;
vector <wstring> fields (HotkeyListCtrl->GetColumnCount());
fields[ColumnHotkeyDescription] = hotkey->Description;
fields[ColumnHotkey] = hotkey->GetShortcutString();
Gui->UpdateListCtrlItem (HotkeyListCtrl, item, fields);
UpdateHotkeyButtons();
}
#endif // TC_WINDOWS
}
void PreferencesDialog::OnBackgroundTaskEnabledCheckBoxClick (wxCommandEvent& event)
{
if (!event.IsChecked())
BackgroundTaskEnabledCheckBox->SetValue (!Gui->AskYesNo (LangString["CONFIRM_BACKGROUND_TASK_DISABLED"], false, true));
}
void PreferencesDialog::OnNoHardwareCryptoCheckBoxClick (wxCommandEvent& event)
{
if (event.IsChecked())
{
if (Gui->AskYesNo (LangString["CONFIRM_SETTING_DEGRADES_PERFORMANCE"], true, true))
{
#ifdef TC_LINUX
Gui->ShowWarning (_("Please note that this setting takes effect only if use of the kernel cryptographic services is disabled."));
#endif
}
else
NoHardwareCryptoCheckBox->SetValue (false);
}
Gui->ShowWarning (_("Please note that any currently mounted volumes need to be remounted before they can use this setting."));
}
void PreferencesDialog::OnNoKernelCryptoCheckBoxClick (wxCommandEvent& event)
{
if (event.IsChecked())
NoKernelCryptoCheckBox->SetValue (Gui->AskYesNo (_("Disabling the use of kernel cryptographic services can degrade performance.\n\nAre you sure?"), false, true));
}
void PreferencesDialog::OnClose (wxCloseEvent& event)
{
#ifdef TC_WINDOWS
Hotkey::RegisterList (Gui->GetMainFrame(), UnregisteredHotkeys);
#endif
event.Skip();
}
void PreferencesDialog::OnDismountOnPowerSavingCheckBoxClick (wxCommandEvent& event)
{
if (event.IsChecked() && !ForceAutoDismountCheckBox->IsChecked())
Gui->ShowWarning ("WARN_PREF_AUTO_DISMOUNT");
}
void PreferencesDialog::OnDismountOnScreenSaverCheckBoxClick (wxCommandEvent& event)
{
if (event.IsChecked() && !ForceAutoDismountCheckBox->IsChecked())
Gui->ShowWarning ("WARN_PREF_AUTO_DISMOUNT");
}
void PreferencesDialog::OnForceAutoDismountCheckBoxClick (wxCommandEvent& event)
{
if (!event.IsChecked())
ForceAutoDismountCheckBox->SetValue (!Gui->AskYesNo (LangString["CONFIRM_NO_FORCED_AUTODISMOUNT"], false, true));
}
void PreferencesDialog::OnHotkeyListItemDeselected (wxListEvent& event)
{
UpdateHotkeyButtons();
}
void PreferencesDialog::OnHotkeyListItemSelected (wxListEvent& event)
{
UpdateHotkeyButtons();
HotkeyTextCtrl->ChangeValue (LangString ["PRESS_A_KEY_TO_ASSIGN"]);
AssignHotkeyButton->Enable (false);
}
void PreferencesDialog::OnOKButtonClick (wxCommandEvent& event)
{
#ifdef TC_WINDOWS
HotkeyTextCtrl->SetValidator (wxTextValidator (wxFILTER_NONE));
#endif
if (!Validate())
return;
TransferDataFromWindow();
Preferences.DefaultMountOptions.Protection = MountReadOnlyCheckBox->IsChecked() ? VolumeProtection::ReadOnly : VolumeProtection::None;
Preferences.DefaultMountOptions.FilesystemOptions = FilesystemOptionsTextCtrl->GetValue();
Preferences.DefaultKeyfiles = *DefaultKeyfilesPanel->GetKeyfiles();
bool securityTokenModuleChanged = (Preferences.SecurityTokenModule != wstring (Pkcs11ModulePathTextCtrl->GetValue()));
Preferences.SecurityTokenModule = wstring (Pkcs11ModulePathTextCtrl->GetValue());
Gui->SetPreferences (Preferences);
try
{
if (securityTokenModuleChanged)
{
if (Preferences.SecurityTokenModule.IsEmpty())
{
if (SecurityToken::IsInitialized())
SecurityToken::CloseLibrary ();
}
else
{
Gui->InitSecurityTokenLibrary();
}
}
}
catch (exception &e)
{
Gui->ShowError (e);
}
#ifdef TC_WINDOWS
// Hotkeys
Hotkey::RegisterList (Gui->GetMainFrame(), Preferences.Hotkeys);
#endif
EndModal (wxID_OK);
}
void PreferencesDialog::OnPreserveTimestampsCheckBoxClick (wxCommandEvent& event)
{
#ifdef TC_LINUX
if (!event.IsChecked())
Gui->ShowInfo (_("Please note that disabling this option may have no effect on volumes mounted using kernel cryptographic services."));
#endif
}
void PreferencesDialog::OnRemoveHotkeyButtonClick (wxCommandEvent& event)
{
#ifdef TC_WINDOWS
foreach (long item, Gui->GetListCtrlSelectedItems (HotkeyListCtrl))
{
Hotkey *hotkey = reinterpret_cast <Hotkey *> (HotkeyListCtrl->GetItemData (item));
hotkey->VirtualKeyCode = 0;
hotkey->VirtualKeyModifiers = 0;
vector <wstring> fields (HotkeyListCtrl->GetColumnCount());
fields[ColumnHotkeyDescription] = hotkey->Description;
fields[ColumnHotkey] = hotkey->GetShortcutString();
Gui->UpdateListCtrlItem (HotkeyListCtrl, item, fields);
UpdateHotkeyButtons();
}
#endif
}
void PreferencesDialog::OnSelectPkcs11ModuleButtonClick (wxCommandEvent& event)
{
list < pair <wstring, wstring> > extensions;
wxString libExtension;
libExtension = wxDynamicLibrary::CanonicalizeName (L"x");
#ifdef TC_MACOSX
extensions.push_back (make_pair (L"dylib", LangString["DLL_FILES"]));
#endif
if (!libExtension.empty())
{
extensions.push_back (make_pair (libExtension.Mid (libExtension.find (L'.') + 1), LangString["DLL_FILES"]));
extensions.push_back (make_pair (L"*", L""));
}
string libDir;
#ifdef TC_WINDOWS
char sysDir[TC_MAX_PATH];
GetSystemDirectoryA (sysDir, sizeof (sysDir));
libDir = sysDir;
#elif defined (TC_MACOSX)
libDir = "/usr/local/lib";
#elif defined (TC_UNIX)
libDir = "/usr/lib";
#endif
Gui->ShowInfo ("SELECT_PKCS11_MODULE_HELP");
FilePathList files = Gui->SelectFiles (this, LangString["SELECT_PKCS11_MODULE"], false, false, extensions, libDir);
if (!files.empty())
Pkcs11ModulePathTextCtrl->SetValue (wstring (*files.front()));
}
void PreferencesDialog::OnTimer ()
{
#ifdef TC_WINDOWS
for (UINT vKey = 0; vKey <= 0xFF; vKey++)
{
if (GetAsyncKeyState (vKey) < 0)
{
bool shift = wxGetKeyState (WXK_SHIFT);
bool control = wxGetKeyState (WXK_CONTROL);
bool alt = wxGetKeyState (WXK_ALT);
bool win = wxGetKeyState (WXK_WINDOWS_LEFT) || wxGetKeyState (WXK_WINDOWS_RIGHT);
if (!Hotkey::GetVirtualKeyCodeString (vKey).empty()) // If the key is allowed and its name has been resolved
{
LastVirtualKeyPressed = vKey;
HotkeyShiftCheckBox->SetValue (shift);
HotkeyControlCheckBox->SetValue (control);
HotkeyAltCheckBox->SetValue (alt);
HotkeyWinCheckBox->SetValue (win);
HotkeyTextCtrl->ChangeValue (Hotkey::GetVirtualKeyCodeString (LastVirtualKeyPressed));
UpdateHotkeyButtons();
return;
}
}
}
#endif
}
void PreferencesDialog::UpdateHotkeyButtons()
{
AssignHotkeyButton->Enable (!HotkeyTextCtrl->IsEmpty() && HotkeyListCtrl->GetSelectedItemCount() > 0);
bool remove = false;
foreach (long item, Gui->GetListCtrlSelectedItems (HotkeyListCtrl))
{
if (reinterpret_cast <Hotkey *> (HotkeyListCtrl->GetItemData (item))->VirtualKeyCode != 0)
remove = true;
}
RemoveHotkeyButton->Enable (remove);
}
}

View File

@@ -0,0 +1,60 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_PreferencesDialog
#define TC_HEADER_Main_Forms_PreferencesDialog
#include "Forms.h"
#include "Main/Main.h"
#include "KeyfilesPanel.h"
namespace TrueCrypt
{
class PreferencesDialog : public PreferencesDialogBase
{
public:
PreferencesDialog (wxWindow* parent);
~PreferencesDialog ();
void SelectPage (wxPanel *page);
protected:
void OnAssignHotkeyButtonClick (wxCommandEvent& event);
void OnBackgroundTaskEnabledCheckBoxClick (wxCommandEvent& event);
void OnCancelButtonClick (wxCommandEvent& event) { Close(); }
void OnClose (wxCloseEvent& event);
void OnDismountOnPowerSavingCheckBoxClick (wxCommandEvent& event);
void OnDismountOnScreenSaverCheckBoxClick (wxCommandEvent& event);
void OnForceAutoDismountCheckBoxClick (wxCommandEvent& event);
void OnHotkeyListItemDeselected (wxListEvent& event);
void OnHotkeyListItemSelected (wxListEvent& event);
void OnNoHardwareCryptoCheckBoxClick (wxCommandEvent& event);
void OnNoKernelCryptoCheckBoxClick (wxCommandEvent& event);
void OnOKButtonClick (wxCommandEvent& event);
void OnPreserveTimestampsCheckBoxClick (wxCommandEvent& event);
void OnRemoveHotkeyButtonClick (wxCommandEvent& event);
void OnSelectPkcs11ModuleButtonClick (wxCommandEvent& event);
void OnTimer ();
void UpdateHotkeyButtons();
enum
{
ColumnHotkeyDescription = 0,
ColumnHotkey
};
KeyfilesPanel *DefaultKeyfilesPanel;
int LastVirtualKeyPressed;
auto_ptr <wxTimer> mTimer;
UserPreferences Preferences;
bool RestoreValidatorBell;
HotkeyList UnregisteredHotkeys;
};
}
#endif // TC_HEADER_Main_Forms_PreferencesDialog

View File

@@ -0,0 +1,80 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "ProgressWizardPage.h"
namespace TrueCrypt
{
ProgressWizardPage::ProgressWizardPage (wxPanel* parent, bool enableAbort)
: ProgressWizardPageBase (parent),
PreviousGaugeValue (0),
ProgressBarRange (1),
RealProgressBarRange (1)
{
#ifdef TC_MACOSX
ProgressGauge->SetMinSize (wxSize (-1, 12)); // OS X apparently supports only up to 12px thick progress bars
#else
ProgressGauge->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 2));
#endif
ProgressValue.Set (0);
ProgressGauge->SetValue (0);
AbortButton->Show (enableAbort);
class Timer : public wxTimer
{
public:
Timer (ProgressWizardPage *page) : Page (page) { }
void Notify()
{
Page->OnTimer();
}
ProgressWizardPage *Page;
};
mTimer.reset (dynamic_cast <wxTimer *> (new Timer (this)));
mTimer->Start (30);
}
void ProgressWizardPage::OnAbortButtonClick (wxCommandEvent& event)
{
AbortEvent.Raise();
}
void ProgressWizardPage::OnTimer ()
{
uint64 value = ProgressValue.Get();
int gaugeValue = static_cast <int> (value * RealProgressBarRange / ProgressBarRange);
if (value == ProgressBarRange)
gaugeValue = RealProgressBarRange; // Prevent round-off error
if (gaugeValue != PreviousGaugeValue)
{
ProgressGauge->SetValue (gaugeValue);
PreviousGaugeValue = gaugeValue;
}
}
void ProgressWizardPage::SetMaxStaticTextWidth (int width)
{
InfoStaticText->Wrap (width);
}
void ProgressWizardPage::SetProgressRange (uint64 progressBarRange)
{
ProgressBarRange = progressBarRange;
RealProgressBarRange = ProgressGauge->GetSize().GetWidth();
ProgressGauge->SetRange (RealProgressBarRange);
}
}

View File

@@ -0,0 +1,42 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_ProgressWizardPage
#define TC_HEADER_Main_Forms_ProgressWizardPage
#include "Forms.h"
namespace TrueCrypt
{
class ProgressWizardPage : public ProgressWizardPageBase
{
public:
ProgressWizardPage (wxPanel* parent, bool enableAbort = false);
~ProgressWizardPage () { }
void EnableAbort (bool enable = true) { AbortButton->Enable (enable); }
bool IsValid () { return true; }
void SetMaxStaticTextWidth (int width);
void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); }
void SetProgressRange (uint64 progressBarRange);
Event AbortEvent;
SharedVal <uint64> ProgressValue;
protected:
void OnAbortButtonClick (wxCommandEvent& event);
void OnTimer ();
auto_ptr <wxTimer> mTimer;
int PreviousGaugeValue;
uint64 ProgressBarRange;
int RealProgressBarRange;
};
}
#endif // TC_HEADER_Main_Forms_ProgressWizardPage

View File

@@ -0,0 +1,93 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "Volume/Hash.h"
#include "RandomPoolEnrichmentDialog.h"
namespace TrueCrypt
{
RandomPoolEnrichmentDialog::RandomPoolEnrichmentDialog (wxWindow* parent) : RandomPoolEnrichmentDialogBase (parent)
{
RandomNumberGenerator::Start();
Hashes = Hash::GetAvailableAlgorithms();
foreach (shared_ptr <Hash> hash, Hashes)
{
if (!hash->IsDeprecated())
{
HashChoice->Append (hash->GetName(), hash.get());
if (typeid (*hash) == typeid (*RandomNumberGenerator::GetHash()))
HashChoice->Select (HashChoice->GetCount() - 1);
}
}
ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24));
MouseStaticText->Wrap (Gui->GetCharWidth (MouseStaticText) * 70);
MainSizer->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 24));
Layout();
Fit();
Center();
foreach (wxWindow *c, this->GetChildren())
c->Connect (wxEVT_MOTION, wxMouseEventHandler (RandomPoolEnrichmentDialog::OnMouseMotion), nullptr, this);
}
RandomPoolEnrichmentDialog::~RandomPoolEnrichmentDialog ()
{
}
void RandomPoolEnrichmentDialog::OnHashSelected (wxCommandEvent& event)
{
RandomNumberGenerator::SetHash (Gui->GetSelectedData <Hash> (HashChoice)->GetNew());
}
void RandomPoolEnrichmentDialog::OnMouseMotion (wxMouseEvent& event)
{
event.Skip();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&event), sizeof (event)));
long coord = event.GetX();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord)));
coord = event.GetY();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord)));
if (ShowRandomPoolCheckBox->IsChecked())
ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24));
}
void RandomPoolEnrichmentDialog::OnShowRandomPoolCheckBoxClicked (wxCommandEvent& event)
{
if (!event.IsChecked())
RandomPoolStaticText->SetLabel (L"");
}
void RandomPoolEnrichmentDialog::ShowBytes (wxStaticText *textCtrl, const ConstBufferPtr &buffer)
{
wxString str;
for (size_t i = 0; i < buffer.Size(); ++i)
{
str += wxString::Format (L"%02X", buffer[i]);
}
str += L"..";
textCtrl->SetLabel (str.c_str());
for (size_t i = 0; i < str.size(); ++i)
{
str[i] = L'X';
}
}
}

View File

@@ -0,0 +1,33 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_RandomPoolEnrichmentDialog
#define TC_HEADER_Main_Forms_RandomPoolEnrichmentDialog
#include "Forms.h"
#include "Main/Main.h"
namespace TrueCrypt
{
class RandomPoolEnrichmentDialog : public RandomPoolEnrichmentDialogBase
{
public:
RandomPoolEnrichmentDialog (wxWindow* parent);
~RandomPoolEnrichmentDialog ();
protected:
void OnHashSelected (wxCommandEvent& event);
void OnMouseMotion (wxMouseEvent& event);
void OnShowRandomPoolCheckBoxClicked (wxCommandEvent& event);
void ShowBytes (wxStaticText *textCtrl, const ConstBufferPtr &buffer);
HashList Hashes;
};
}
#endif // TC_HEADER_Main_Forms_RandomPoolEnrichmentDialog

View File

@@ -0,0 +1,197 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "Common/SecurityToken.h"
#include "NewSecurityTokenKeyfileDialog.h"
#include "SecurityTokenKeyfilesDialog.h"
namespace TrueCrypt
{
SecurityTokenKeyfilesDialog::SecurityTokenKeyfilesDialog (wxWindow* parent, bool selectionMode)
: SecurityTokenKeyfilesDialogBase (parent)
{
if (selectionMode)
SetTitle (LangString["SELECT_TOKEN_KEYFILES"]);
list <int> colPermilles;
SecurityTokenKeyfileListCtrl->InsertColumn (ColumnSecurityTokenSlotId, LangString["TOKEN_SLOT_ID"], wxLIST_FORMAT_CENTER, 1);
colPermilles.push_back (102);
SecurityTokenKeyfileListCtrl->InsertColumn (ColumnSecurityTokenLabel, LangString["TOKEN_NAME"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (368);
SecurityTokenKeyfileListCtrl->InsertColumn (ColumnSecurityTokenKeyfileLabel, LangString["TOKEN_DATA_OBJECT_LABEL"], wxLIST_FORMAT_LEFT, 1);
colPermilles.push_back (529);
FillSecurityTokenKeyfileListCtrl();
Gui->SetListCtrlWidth (SecurityTokenKeyfileListCtrl, 65);
Gui->SetListCtrlHeight (SecurityTokenKeyfileListCtrl, 16);
Gui->SetListCtrlColumnWidths (SecurityTokenKeyfileListCtrl, colPermilles);
Fit();
Layout();
Center();
DeleteButton->Disable();
ExportButton->Disable();
OKButton->Disable();
OKButton->SetDefault();
}
void SecurityTokenKeyfilesDialog::FillSecurityTokenKeyfileListCtrl ()
{
wxBusyCursor busy;
SecurityTokenKeyfileListCtrl->DeleteAllItems();
SecurityTokenKeyfileList = SecurityToken::GetAvailableKeyfiles();
size_t i = 0;
foreach (const SecurityTokenKeyfile &key, SecurityTokenKeyfileList)
{
vector <wstring> fields (SecurityTokenKeyfileListCtrl->GetColumnCount());
fields[ColumnSecurityTokenSlotId] = StringConverter::ToWide ((uint64) key.SlotId);
fields[ColumnSecurityTokenLabel] = key.Token.Label;
fields[ColumnSecurityTokenKeyfileLabel] = key.Id;
Gui->AppendToListCtrl (SecurityTokenKeyfileListCtrl, fields, 0, &SecurityTokenKeyfileList[i++]);
}
}
void SecurityTokenKeyfilesDialog::OnDeleteButtonClick (wxCommandEvent& event)
{
try
{
if (!Gui->AskYesNo (LangString["CONFIRM_SEL_FILES_DELETE"]))
return;
wxBusyCursor busy;
foreach (long item, Gui->GetListCtrlSelectedItems (SecurityTokenKeyfileListCtrl))
{
SecurityToken::DeleteKeyfile (*reinterpret_cast <SecurityTokenKeyfile *> (SecurityTokenKeyfileListCtrl->GetItemData (item)));
}
FillSecurityTokenKeyfileListCtrl();
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
void SecurityTokenKeyfilesDialog::OnExportButtonClick (wxCommandEvent& event)
{
try
{
foreach (long item, Gui->GetListCtrlSelectedItems (SecurityTokenKeyfileListCtrl))
{
SecurityTokenKeyfile *keyfile = reinterpret_cast <SecurityTokenKeyfile *> (SecurityTokenKeyfileListCtrl->GetItemData (item));
FilePathList files = Gui->SelectFiles (this, wxEmptyString, true);
if (!files.empty())
{
wxBusyCursor busy;
vector <byte> keyfileData;
SecurityToken::GetKeyfileData (*keyfile, keyfileData);
BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size());
finally_do_arg (BufferPtr, keyfileDataBuf, { finally_arg.Erase(); });
File keyfile;
keyfile.Open (*files.front(), File::CreateWrite);
keyfile.Write (keyfileDataBuf);
}
else
break;
Gui->ShowInfo ("KEYFILE_EXPORTED");
}
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
void SecurityTokenKeyfilesDialog::OnImportButtonClick (wxCommandEvent& event)
{
try
{
FilePathList keyfilePaths = Gui->SelectFiles (this, LangString["SELECT_KEYFILES"], false);
if (keyfilePaths.empty())
return;
FilePath keyfilePath = *keyfilePaths.front();
File keyfile;
keyfile.Open (keyfilePath, File::OpenRead, File::ShareReadWrite, File::PreserveTimestamps);
if (keyfile.Length() > 0)
{
vector <byte> keyfileData (keyfile.Length());
BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size());
keyfile.ReadCompleteBuffer (keyfileDataBuf);
finally_do_arg (BufferPtr, keyfileDataBuf, { finally_arg.Erase(); });
NewSecurityTokenKeyfileDialog newKeyfileDialog (this, keyfilePath.ToBaseName());
if (newKeyfileDialog.ShowModal() == wxID_OK)
{
wxBusyCursor busy;
SecurityToken::CreateKeyfile (newKeyfileDialog.GetSelectedSlotId(), keyfileData, StringConverter::ToSingle (newKeyfileDialog.GetKeyfileName()));
FillSecurityTokenKeyfileListCtrl();
}
}
else
throw InsufficientData (SRC_POS, keyfilePath);
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
void SecurityTokenKeyfilesDialog::OnListItemDeselected (wxListEvent& event)
{
if (SecurityTokenKeyfileListCtrl->GetSelectedItemCount() == 0)
{
DeleteButton->Disable();
ExportButton->Disable();
OKButton->Disable();
}
}
void SecurityTokenKeyfilesDialog::OnListItemSelected (wxListEvent& event)
{
if (event.GetItem().GetData() != (wxUIntPtr) nullptr)
{
DeleteButton->Enable();
ExportButton->Enable();
OKButton->Enable();
}
}
void SecurityTokenKeyfilesDialog::OnOKButtonClick ()
{
foreach (long item, Gui->GetListCtrlSelectedItems (SecurityTokenKeyfileListCtrl))
{
SecurityTokenKeyfile *key = reinterpret_cast <SecurityTokenKeyfile *> (SecurityTokenKeyfileListCtrl->GetItemData (item));
SelectedSecurityTokenKeyfilePaths.push_back (*key);
}
EndModal (wxID_OK);
}
}

View File

@@ -0,0 +1,47 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_SecurityTokenKeyfilesDialog
#define TC_HEADER_Main_Forms_SecurityTokenKeyfilesDialog
#include "Forms.h"
#include "Common/SecurityToken.h"
#include "Main/Main.h"
namespace TrueCrypt
{
class SecurityTokenKeyfilesDialog : public SecurityTokenKeyfilesDialogBase
{
public:
SecurityTokenKeyfilesDialog (wxWindow* parent, bool selectionMode = true);
list <SecurityTokenKeyfilePath> GetSelectedSecurityTokenKeyfilePaths() const { return SelectedSecurityTokenKeyfilePaths; }
protected:
enum
{
ColumnSecurityTokenSlotId = 0,
ColumnSecurityTokenLabel,
ColumnSecurityTokenKeyfileLabel,
};
void FillSecurityTokenKeyfileListCtrl ();
void OnDeleteButtonClick (wxCommandEvent& event);
void OnExportButtonClick (wxCommandEvent& event);
void OnImportButtonClick (wxCommandEvent& event);
void OnListItemActivated (wxListEvent& event) { OnOKButtonClick(); }
void OnListItemDeselected (wxListEvent& event);
void OnListItemSelected (wxListEvent& event);
void OnOKButtonClick ();
void OnOKButtonClick (wxCommandEvent& event) { OnOKButtonClick(); }
vector <SecurityTokenKeyfile> SecurityTokenKeyfileList;
list <SecurityTokenKeyfilePath> SelectedSecurityTokenKeyfilePaths;
};
}
#endif // TC_HEADER_Main_Forms_SecurityTokenKeyfilesDialog

View File

@@ -0,0 +1,32 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "SelectDirectoryWizardPage.h"
namespace TrueCrypt
{
bool SelectDirectoryWizardPage::IsValid ()
{
if (!DirectoryTextCtrl->IsEmpty())
{
return FilesystemPath (DirectoryTextCtrl->GetValue()).IsDirectory();
}
return false;
}
void SelectDirectoryWizardPage::OnBrowseButtonClick (wxCommandEvent& event)
{
DirectoryPath dir = Gui->SelectDirectory (this);
if (!dir.IsEmpty())
DirectoryTextCtrl->SetValue (wstring (dir));
}
}

View File

@@ -0,0 +1,33 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_SelectDirectoryWizardPage
#define TC_HEADER_Main_Forms_SelectDirectoryWizardPage
#include "Forms.h"
namespace TrueCrypt
{
class SelectDirectoryWizardPage : public SelectDirectoryWizardPageBase
{
public:
SelectDirectoryWizardPage (wxPanel* parent) : SelectDirectoryWizardPageBase (parent) { }
DirectoryPath GetDirectory () const { return DirectoryPath (DirectoryTextCtrl->GetValue()); }
bool IsValid ();
void SetDirectory (const DirectoryPath &path) { DirectoryTextCtrl->SetValue (wstring (path)); }
void SetMaxStaticTextWidth (int width) { InfoStaticText->Wrap (width); }
void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); }
protected:
void OnBrowseButtonClick (wxCommandEvent& event);
void OnDirectoryTextChanged (wxCommandEvent& event) { PageUpdatedEvent.Raise(); }
};
}
#endif // TC_HEADER_Main_Forms_SelectDirectoryWizardPage

View File

@@ -0,0 +1,116 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_SingleChoiceWizardPage
#define TC_HEADER_Main_Forms_SingleChoiceWizardPage
#include "Forms.h"
namespace TrueCrypt
{
template <class ChoiceType>
class SingleChoiceWizardPage : public SingleChoiceWizardPageBase
{
public:
SingleChoiceWizardPage (wxPanel* parent, const wxString &groupBoxText = wxEmptyString, bool choiceTextBold = false)
: SingleChoiceWizardPageBase (parent),
ChoiceTextBold (choiceTextBold)
{
if (!groupBoxText.empty())
{
OuterChoicesSizer->Remove (ChoicesSizer);
ChoicesSizer = new wxStaticBoxSizer (wxVERTICAL, this, groupBoxText);
OuterChoicesSizer->Add (ChoicesSizer, 0, wxEXPAND, 5);
}
}
void AddChoice (ChoiceType choice, const wxString &choiceText, const wxString &infoText = wxEmptyString, const wchar_t *infoLinkId = nullptr, const wxString &infoLinkText = wxEmptyString)
{
assert (RadioButtonMap.find (choice) == RadioButtonMap.end());
wxRadioButton *radioButton = new wxRadioButton (this, wxID_ANY, choiceText);
if (RadioButtonMap.empty())
radioButton->SetValue (true);
RadioButtonMap[choice] = radioButton;
if (ChoiceTextBold)
{
wxFont buttonFont = radioButton->GetFont();
buttonFont.SetWeight (wxFONTWEIGHT_BOLD);
radioButton->SetFont (buttonFont);
}
ChoicesSizer->Add (radioButton, 0, wxALL, 5);
wxBoxSizer *infoSizer = new wxBoxSizer (wxVERTICAL);
wxStaticText *infoStaticText = new wxStaticText (this, wxID_ANY, infoText, wxDefaultPosition, wxDefaultSize, 0);
ChoiceInfoTexts.push_back (infoStaticText);
infoSizer->Add (infoStaticText, 0, wxALL, 5);
ChoicesSizer->Add (infoSizer, 0, wxEXPAND | wxLEFT, Gui->GetCharWidth (this) * 3);
if (infoLinkId)
{
wxHyperlinkCtrl *hyperlink = Gui->CreateHyperlink (this, infoLinkId, infoLinkText);
infoSizer->Add (hyperlink, 0, wxALL, 5);
hyperlink->Connect (wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler (SingleChoiceWizardPage::OnChoiceHyperlinkClick), nullptr, this);
}
ChoicesSizer->Add (1, Gui->GetCharHeight (this) * 1, 0, wxEXPAND, 5);
}
ChoiceType GetSelection () const
{
typedef pair <ChoiceType, wxRadioButton*> MapPair;
foreach (MapPair p, RadioButtonMap)
{
if (p.second->GetValue())
return p.first;
}
throw NoItemSelected (SRC_POS);
}
bool IsValid ()
{
return true;
}
void SetMaxStaticTextWidth (int width)
{
InfoStaticText->Wrap (width);
foreach (wxStaticText *infoText, ChoiceInfoTexts)
infoText->Wrap (width - Gui->GetCharWidth (this) * 3);
}
void SetPageText (const wxString &text)
{
InfoStaticText->SetLabel (text);
}
void SetSelection (ChoiceType choice)
{
RadioButtonMap[choice]->SetValue (true);
}
protected:
void OnChoiceHyperlinkClick (wxHyperlinkEvent &event)
{
Gui->OpenHomepageLink (this, event.GetURL());
}
bool ChoiceTextBold;
list <wxStaticText*> ChoiceInfoTexts;
map <ChoiceType, wxRadioButton*> RadioButtonMap;
};
}
#endif // TC_HEADER_Main_Forms_SingleChoiceWizardPage

17436
src/Main/Forms/TrueCrypt.fbp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,183 @@
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "VolumeCreationProgressWizardPage.h"
namespace TrueCrypt
{
VolumeCreationProgressWizardPage::VolumeCreationProgressWizardPage (wxPanel* parent, bool displayKeyInfo)
: VolumeCreationProgressWizardPageBase (parent),
PreviousGaugeValue (0),
ProgressBarRange (1),
RealProgressBarRange (1),
VolumeCreatorRunning (false)
{
DisplayKeysCheckBox->SetValue (displayKeyInfo);
#ifdef TC_WINDOWS
DisplayKeysCheckBox->SetLabel (L"");
#endif
#ifdef TC_MACOSX
ProgressGauge->SetMinSize (wxSize (-1, 12)); // OS X apparently supports only up to 12px thick progress bars
KeySamplesUpperSizer->Remove (KeySamplesUpperInnerSizer);
#else
ProgressGauge->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 2));
#endif
if (DisplayKeysCheckBox->IsChecked())
ShowBytes (RandomPoolSampleStaticText, RandomNumberGenerator::PeekPool(), true);
else
ShowAsterisks (RandomPoolSampleStaticText);
class Timer : public wxTimer
{
public:
Timer (VolumeCreationProgressWizardPage *page) : Page (page) { }
void Notify()
{
Page->OnRandomPoolTimer();
}
VolumeCreationProgressWizardPage *Page;
};
RandomPoolTimer.reset (dynamic_cast <wxTimer *> (new Timer (this)));
RandomPoolTimer->Start (30);
AbortButton->Disable();
ProgressGauge->SetValue (0);
}
void VolumeCreationProgressWizardPage::OnAbortButtonClick (wxCommandEvent& event)
{
AbortEvent.Raise();
}
void VolumeCreationProgressWizardPage::OnDisplayKeysCheckBoxClick (wxCommandEvent& event)
{
if (!event.IsChecked())
{
ShowAsterisks (RandomPoolSampleStaticText);
ShowAsterisks (HeaderKeySampleStaticText);
ShowAsterisks (MasterKeySampleStaticText);
}
else
{
RandomPoolSampleStaticText->SetLabel (L"");
HeaderKeySampleStaticText->SetLabel (L"");
MasterKeySampleStaticText->SetLabel (L"");
}
}
void VolumeCreationProgressWizardPage::OnRandomPoolTimer ()
{
if (!VolumeCreatorRunning && DisplayKeysCheckBox->IsChecked())
ShowBytes (RandomPoolSampleStaticText, RandomNumberGenerator::PeekPool(), true);
}
void VolumeCreationProgressWizardPage::SetKeyInfo (const VolumeCreator::KeyInfo &keyInfo)
{
if (DisplayKeysCheckBox->IsChecked())
{
ShowBytes (RandomPoolSampleStaticText, RandomNumberGenerator::PeekPool(), true);
ShowBytes (HeaderKeySampleStaticText, keyInfo.HeaderKey);
ShowBytes (MasterKeySampleStaticText, keyInfo.MasterKey);
}
}
void VolumeCreationProgressWizardPage::ShowAsterisks (wxStaticText *textCtrl)
{
wxString str;
for (size_t i = 0; i < MaxDisplayedKeyBytes + 1; ++i)
{
str += L"**";
}
textCtrl->SetLabel (str.c_str());
}
void VolumeCreationProgressWizardPage::ShowBytes (wxStaticText *textCtrl, const ConstBufferPtr &buffer, bool appendDots)
{
wxString str;
for (size_t i = 0; i < MaxDisplayedKeyBytes && i < buffer.Size(); ++i)
{
str += wxString::Format (L"%02X", buffer[i]);
}
if (appendDots)
str += L"..";
textCtrl->SetLabel (str.c_str());
for (size_t i = 0; i < str.size(); ++i)
{
str[i] = L'X';
}
}
void VolumeCreationProgressWizardPage::SetProgressValue (uint64 value)
{
int gaugeValue = static_cast <int> (value * RealProgressBarRange / ProgressBarRange);
if (value == ProgressBarRange)
gaugeValue = RealProgressBarRange; // Prevent round-off error
if (gaugeValue != PreviousGaugeValue)
{
ProgressGauge->SetValue (gaugeValue);
PreviousGaugeValue = gaugeValue;
}
if (value != 0)
{
SizeDoneStaticText->SetLabel (wxString::Format (L"%7.3f%%", 100.0 - double (ProgressBarRange - value) / (double (ProgressBarRange) / 100.0)));
wxLongLong timeDiff = wxGetLocalTimeMillis() - StartTime;
if (timeDiff.GetValue() > 0)
{
uint64 speed = value * 1000 / timeDiff.GetValue();
if (ProgressBarRange != value)
SpeedStaticText->SetLabel (Gui->SpeedToString (speed));
TimeLeftStaticText->SetLabel (speed > 0 ? Gui->TimeSpanToString ((ProgressBarRange - value) / speed) : L"");
}
}
else
{
SizeDoneStaticText->SetLabel (L"");
SpeedStaticText->SetLabel (L"");
TimeLeftStaticText->SetLabel (L"");
}
}
void VolumeCreationProgressWizardPage::SetMaxStaticTextWidth (int width)
{
InfoStaticText->Wrap (width);
}
void VolumeCreationProgressWizardPage::SetProgressState (bool volumeCreatorRunning)
{
if (volumeCreatorRunning)
StartTime = wxGetLocalTimeMillis();
VolumeCreatorRunning = volumeCreatorRunning;
}
void VolumeCreationProgressWizardPage::SetProgressRange (uint64 progressBarRange)
{
ProgressBarRange = progressBarRange;
RealProgressBarRange = ProgressGauge->GetSize().GetWidth();
ProgressGauge->SetRange (RealProgressBarRange);
}
}

View File

@@ -0,0 +1,53 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_VolumeCreationProgressWizardPage
#define TC_HEADER_Main_Forms_VolumeCreationProgressWizardPage
#include "Forms.h"
#include "Core/VolumeCreator.h"
namespace TrueCrypt
{
class VolumeCreationProgressWizardPage : public VolumeCreationProgressWizardPageBase
{
public:
VolumeCreationProgressWizardPage (wxPanel* parent, bool displayKeyInfo);
~VolumeCreationProgressWizardPage () { }
void EnableAbort (bool enable = true) { AbortButton->Enable (enable); }
bool IsKeyInfoDisplayed () const { return DisplayKeysCheckBox->GetValue(); }
bool IsValid () { return true; }
void OnRandomPoolTimer ();
void SetKeyInfo (const VolumeCreator::KeyInfo &keyInfo);
void SetMaxStaticTextWidth (int width);
void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); }
void SetProgressRange (uint64 progressBarRange);
void SetProgressValue (uint64 value);
void SetProgressState (bool volumeCreatorRunning);
Event AbortEvent;
protected:
void OnAbortButtonClick (wxCommandEvent& event);
void OnDisplayKeysCheckBoxClick (wxCommandEvent& event);
void ShowAsterisks (wxStaticText *textCtrl);
void ShowBytes (wxStaticText *textCtrl, const ConstBufferPtr &buffer, bool appendDots = true);
static const size_t MaxDisplayedKeyBytes = 13;
int PreviousGaugeValue;
uint64 ProgressBarRange;
auto_ptr <wxTimer> RandomPoolTimer;
int RealProgressBarRange;
wxLongLong StartTime;
bool VolumeCreatorRunning;
};
}
#endif // TC_HEADER_Main_Forms_VolumeCreationProgressWizardPage

View File

@@ -0,0 +1,984 @@
/*
Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Platform/SystemInfo.h"
#ifdef TC_UNIX
#include <unistd.h>
#include "Platform/Unix/Process.h"
#endif
#include "Core/RandomNumberGenerator.h"
#include "Core/VolumeCreator.h"
#include "Main/Application.h"
#include "Main/GraphicUserInterface.h"
#include "Main/Resources.h"
#include "VolumeCreationWizard.h"
#include "EncryptionOptionsWizardPage.h"
#include "InfoWizardPage.h"
#include "ProgressWizardPage.h"
#include "SingleChoiceWizardPage.h"
#include "VolumeCreationProgressWizardPage.h"
#include "VolumeFormatOptionsWizardPage.h"
#include "VolumeLocationWizardPage.h"
#include "VolumePasswordWizardPage.h"
#include "VolumeSizeWizardPage.h"
namespace TrueCrypt
{
VolumeCreationWizard::VolumeCreationWizard (wxWindow* parent)
: WizardFrame (parent),
CrossPlatformSupport (true),
DisplayKeyInfo (true),
LargeFilesSupport (false),
QuickFormatEnabled (false),
SelectedFilesystemClusterSize (0),
SelectedFilesystemType (VolumeCreationOptions::FilesystemType::FAT),
SelectedVolumeHostType (VolumeHostType::File),
SelectedVolumeType (VolumeType::Normal),
SectorSize (0),
VolumeSize (0)
{
RandomNumberGenerator::Start();
SetTitle (LangString["INTRO_TITLE"]);
SetImage (Resources::GetVolumeCreationWizardBitmap (Gui->GetCharHeight (this) * 21));
SetMaxStaticTextWidth (55);
SetStep (Step::VolumeHostType);
class Timer : public wxTimer
{
public:
Timer (VolumeCreationWizard *wizard) : Wizard (wizard) { }
void Notify()
{
Wizard->OnRandomPoolUpdateTimer();
}
VolumeCreationWizard *Wizard;
};
RandomPoolUpdateTimer.reset (dynamic_cast <wxTimer *> (new Timer (this)));
RandomPoolUpdateTimer->Start (200);
}
VolumeCreationWizard::~VolumeCreationWizard ()
{
}
WizardPage *VolumeCreationWizard::GetPage (WizardStep step)
{
switch (step)
{
case Step::VolumeHostType:
{
ClearHistory();
OuterVolume = false;
LargeFilesSupport = false;
QuickFormatEnabled = false;
SingleChoiceWizardPage <VolumeHostType::Enum> *page = new SingleChoiceWizardPage <VolumeHostType::Enum> (GetPageParent(), wxEmptyString, true);
page->SetMinSize (wxSize (Gui->GetCharWidth (this) * 58, Gui->GetCharHeight (this) * 18 + 5));
page->SetPageTitle (LangString["INTRO_TITLE"]);
page->AddChoice (VolumeHostType::File, LangString["IDC_FILE_CONTAINER"], LangString["IDT_FILE_CONTAINER"], L"introcontainer", LangString["IDC_MORE_INFO_ON_CONTAINERS"]);
page->AddChoice (VolumeHostType::Device, _("Create a volume within a partition/&drive"), _("Formats and encrypts a non-system partition, entire external or secondary drive, entire USB stick, etc."));
page->SetSelection (SelectedVolumeHostType);
return page;
}
case Step::VolumeType:
{
SingleChoiceWizardPage <VolumeType::Enum> *page = new SingleChoiceWizardPage <VolumeType::Enum> (GetPageParent(), wxEmptyString, true);
page->SetPageTitle (LangString["VOLUME_TYPE_TITLE"]);
page->AddChoice (VolumeType::Normal, LangString["IDC_STD_VOL"], LangString["NORMAL_VOLUME_TYPE_HELP"]);
page->AddChoice (VolumeType::Hidden, LangString["IDC_HIDDEN_VOL"], LangString["HIDDEN_VOLUME_TYPE_HELP"], L"hiddenvolume", LangString["IDC_HIDDEN_VOL_HELP"]);
page->SetSelection (SelectedVolumeType);
return page;
}
case Step::VolumeLocation:
{
VolumeLocationWizardPage *page = new VolumeLocationWizardPage (GetPageParent(), SelectedVolumeHostType);
page->SetPageTitle (LangString["VOLUME_LOCATION"]);
if (SelectedVolumeType == VolumeType::Hidden)
page->SetPageText (LangString[SelectedVolumeHostType == VolumeHostType::File ? "FILE_HELP_HIDDEN_HOST_VOL" : "DEVICE_HELP_HIDDEN_HOST_VOL"]);
else
page->SetPageText (LangString[SelectedVolumeHostType == VolumeHostType::File ? "FILE_HELP" : "DEVICE_HELP_NO_INPLACE"]);
page->SetVolumePath (SelectedVolumePath);
return page;
}
case Step::EncryptionOptions:
{
EncryptionOptionsWizardPage *page = new EncryptionOptionsWizardPage (GetPageParent());
if (OuterVolume)
page->SetPageTitle (LangString["CIPHER_HIDVOL_HOST_TITLE"]);
else if (SelectedVolumeType == VolumeType::Hidden)
page->SetPageTitle (LangString["CIPHER_HIDVOL_TITLE"]);
else
page->SetPageTitle (LangString["CIPHER_TITLE"]);
page->SetEncryptionAlgorithm (SelectedEncryptionAlgorithm);
page->SetHash (SelectedHash);
return page;
}
case Step::VolumeSize:
{
wxString freeSpaceText;
wxString pageTitle;
wxString pageText;
if (OuterVolume)
{
pageTitle = LangString["SIZE_HIDVOL_HOST_TITLE"];
pageText = LangString["SIZE_HELP_HIDDEN_HOST_VOL"];
}
else if (SelectedVolumeType == VolumeType::Hidden)
{
pageTitle = LangString["SIZE_HIDVOL_TITLE"];
pageText = LangString["SIZE_HELP_HIDDEN_VOL"] + L"\n\n" + _("Please note that if your operating system does not allocate files from the beginning of the free space, the maximum possible hidden volume size may be much smaller than the size of the free space on the outer volume. This not a bug in TrueCrypt but a limitation of the operating system.");
freeSpaceText = StringFormatter (_("Maximum possible hidden volume size for this volume is {0}."), Gui->SizeToString (MaxHiddenVolumeSize));
}
else
{
pageTitle = LangString["SIZE_TITLE"];
pageText = LangString["VOLUME_SIZE_HELP"];
}
VolumeSizeWizardPage *page = new VolumeSizeWizardPage (GetPageParent(), SelectedVolumePath, SectorSize, freeSpaceText);
page->SetPageTitle (pageTitle);
page->SetPageText (pageText);
if (!OuterVolume && SelectedVolumeType == VolumeType::Hidden)
page->SetMaxVolumeSize (MaxHiddenVolumeSize);
else
page->SetVolumeSize (VolumeSize);
if (OuterVolume)
page->SetMinVolumeSize (TC_MIN_HIDDEN_VOLUME_HOST_SIZE);
else if (SelectedVolumeType == VolumeType::Hidden)
page->SetMinVolumeSize (TC_MIN_HIDDEN_VOLUME_SIZE);
else
page->SetMinVolumeSize (TC_MIN_VOLUME_SIZE);
return page;
}
case Step::VolumePassword:
{
VolumePasswordWizardPage *page = new VolumePasswordWizardPage (GetPageParent(), Password, Keyfiles);
if (OuterVolume)
page->SetPageTitle (LangString["PASSWORD_HIDVOL_HOST_TITLE"]);
else if (SelectedVolumeType == VolumeType::Hidden)
page->SetPageTitle (LangString["PASSWORD_HIDVOL_TITLE"]);
else
page->SetPageTitle (LangString["PASSWORD_TITLE"]);
page->SetPageText (LangString[OuterVolume ? "PASSWORD_HIDDENVOL_HOST_HELP" : "PASSWORD_HELP"]);
return page;
}
case Step::LargeFilesSupport:
{
SingleChoiceWizardPage <bool> *page = new SingleChoiceWizardPage <bool> (GetPageParent(), wxEmptyString, true);
page->SetPageTitle (LangString["FILESYS_PAGE_TITLE"]);
page->AddChoice (false, _("I will not store files larger than 4 GB on the volume"),
_("Choose this option if you do not need to store files larger than 4 GB (4,294,967,296 bytes) on the volume."));
page->AddChoice (true, _("I will store files larger than 4 GB on the volume"),
_("Choose this option if you need to store files larger than 4 GB (4,294,967,296 bytes) on the volume."));
page->SetSelection (LargeFilesSupport);
return page;
}
case Step::FormatOptions:
{
VolumeFormatOptionsWizardPage *page = new VolumeFormatOptionsWizardPage (GetPageParent(), VolumeSize, SectorSize,
SelectedVolumePath.IsDevice() && (OuterVolume || SelectedVolumeType != VolumeType::Hidden), OuterVolume, LargeFilesSupport);
page->SetPageTitle (_("Format Options"));
page->SetFilesystemType (SelectedFilesystemType);
if (!OuterVolume && SelectedVolumeType == VolumeType::Hidden)
QuickFormatEnabled = true;
page->SetQuickFormat (QuickFormatEnabled);
return page;
}
case Step::CrossPlatformSupport:
{
SingleChoiceWizardPage <bool> *page = new SingleChoiceWizardPage <bool> (GetPageParent(), wxEmptyString, true);
page->SetPageTitle (_("Cross-Platform Support"));
page->AddChoice (true, _("I will mount the volume on other platforms"),
_("Choose this option if you need to use the volume on other platforms."));
page->AddChoice (false, StringFormatter (_("I will mount the volume only on {0}"), SystemInfo::GetPlatformName()),
_("Choose this option if you do not need to use the volume on other platforms."));
page->SetSelection (CrossPlatformSupport);
return page;
}
case Step::CreationProgress:
{
VolumeCreationProgressWizardPage *page = new VolumeCreationProgressWizardPage (GetPageParent(), DisplayKeyInfo);
if (OuterVolume)
page->SetPageTitle (LangString["FORMAT_HIDVOL_HOST_TITLE"]);
else if (SelectedVolumeType == VolumeType::Hidden)
page->SetPageTitle (LangString["FORMAT_HIDVOL_TITLE"]);
else
page->SetPageTitle (LangString["FORMAT_TITLE"]);
page->SetPageText (LangString["FORMAT_HELP"]);
page->AbortEvent.Connect (EventConnector <VolumeCreationWizard> (this, &VolumeCreationWizard::OnAbortButtonClick));
page->SetNextButtonText (LangString["FORMAT"]);
return page;
}
case Step::VolumeCreatedInfo:
{
InfoWizardPage *page = new InfoWizardPage (GetPageParent());
page->SetPageTitle (LangString["FORMAT_FINISHED_TITLE"]);
page->SetPageText (LangString["FORMAT_FINISHED_HELP"]);
SetCancelButtonText (_("Exit"));
return page;
}
case Step::OuterVolumeContents:
{
ClearHistory();
MountOptions mountOptions;
mountOptions.Keyfiles = Keyfiles;
mountOptions.Password = Password;
mountOptions.Path = make_shared <VolumePath> (SelectedVolumePath);
try
{
wxBusyCursor busy;
Gui->SetActiveFrame (this);
MountedOuterVolume = Core->MountVolume (mountOptions);
}
catch (exception &e)
{
Gui->SetActiveFrame (this);
Gui->ShowError (e);
Close();
return new InfoWizardPage (GetPageParent());
}
struct OpenOuterVolumeFunctor : public Functor
{
OpenOuterVolumeFunctor (const DirectoryPath &outerVolumeMountPoint) : OuterVolumeMountPoint (outerVolumeMountPoint) { }
virtual void operator() ()
{
Gui->OpenExplorerWindow (OuterVolumeMountPoint);
}
DirectoryPath OuterVolumeMountPoint;
};
InfoWizardPage *page = new InfoWizardPage (GetPageParent(), _("Open Outer Volume"),
shared_ptr <Functor> (new OpenOuterVolumeFunctor (MountedOuterVolume->MountPoint)));
page->SetPageTitle (LangString["HIDVOL_HOST_FILLING_TITLE"]);
page->SetPageText (StringFormatter (
_("Outer volume has been successfully created and mounted as '{0}'. To this volume you should now copy some sensitive-looking files that you actually do NOT want to hide. The files will be there for anyone forcing you to disclose your password. You will reveal only the password for this outer volume, not for the hidden one. The files that you really care about will be stored in the hidden volume, which will be created later on. When you finish copying, click Next. Do not dismount the volume.\n\nNote: After you click Next, the outer volume will be analyzed to determine the size of uninterrupted area of free space whose end is aligned with the end of the volume. This area will accommodate the hidden volume, so it will limit its maximum possible size. The procedure ensures no data on the outer volume are overwritten by the hidden volume."),
wstring (MountedOuterVolume->MountPoint)));
return page;
}
case Step::HiddenVolume:
{
ClearHistory();
OuterVolume = false;
LargeFilesSupport = false;
InfoWizardPage *page = new InfoWizardPage (GetPageParent());
page->SetPageTitle (LangString["HIDVOL_PRE_CIPHER_TITLE"]);
page->SetPageText (LangString["HIDVOL_PRE_CIPHER_HELP"]);
return page;
}
default:
throw ParameterIncorrect (SRC_POS);
}
}
void VolumeCreationWizard::OnAbortButtonClick (EventArgs &args)
{
AbortRequested = true;
}
void VolumeCreationWizard::OnMouseMotion (wxMouseEvent& event)
{
event.Skip();
if (!IsWorkInProgress() && RandomNumberGenerator::IsRunning())
{
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&event), sizeof (event)));
long coord = event.GetX();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord)));
coord = event.GetY();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord)));
}
}
void VolumeCreationWizard::OnProgressTimer ()
{
if (!IsWorkInProgress())
return;
if (AbortRequested && !AbortConfirmationPending)
{
AbortConfirmationPending = true;
if (Gui->AskYesNo (LangString ["FORMAT_ABORT"], true))
{
if (IsWorkInProgress() && Creator.get() != nullptr)
{
CreationAborted = true;
Creator->Abort();
}
}
AbortRequested = false;
AbortConfirmationPending = false;
}
VolumeCreator::ProgressInfo progress = Creator->GetProgressInfo();
VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage());
page->SetProgressValue (progress.SizeDone);
if (!progress.CreationInProgress && !AbortConfirmationPending)
{
SetWorkInProgress (false);
OnVolumeCreatorFinished ();
}
}
void VolumeCreationWizard::OnRandomPoolUpdateTimer ()
{
if (!IsWorkInProgress())
{
wxLongLong time = wxGetLocalTimeMillis();
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&time), sizeof (time)));
}
}
void VolumeCreationWizard::OnVolumeCreatorFinished ()
{
VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage());
ProgressTimer.reset();
page->SetProgressState (false);
Gui->EndInteractiveBusyState (this);
SetWorkInProgress (false);
UpdateControls();
try
{
if (!CreationAborted)
{
Creator->CheckResult();
#ifdef TC_UNIX
// Format non-FAT filesystem
const char *fsFormatter = nullptr;
switch (SelectedFilesystemType)
{
case VolumeCreationOptions::FilesystemType::Ext2: fsFormatter = "mkfs.ext2"; break;
case VolumeCreationOptions::FilesystemType::Ext3: fsFormatter = "mkfs.ext3"; break;
case VolumeCreationOptions::FilesystemType::Ext4: fsFormatter = "mkfs.ext4"; break;
case VolumeCreationOptions::FilesystemType::MacOsExt: fsFormatter = "newfs_hfs"; break;
case VolumeCreationOptions::FilesystemType::UFS: fsFormatter = "newfs" ; break;
default: break;
}
if (fsFormatter)
{
wxBusyCursor busy;
MountOptions mountOptions (Gui->GetPreferences().DefaultMountOptions);
mountOptions.Path = make_shared <VolumePath> (SelectedVolumePath);
mountOptions.NoFilesystem = true;
mountOptions.Protection = VolumeProtection::None;
mountOptions.Password = Password;
mountOptions.Keyfiles = Keyfiles;
shared_ptr <VolumeInfo> volume = Core->MountVolume (mountOptions);
finally_do_arg (shared_ptr <VolumeInfo>, volume, { Core->DismountVolume (finally_arg, true); });
Thread::Sleep (2000); // Try to prevent race conditions caused by OS
// Temporarily take ownership of the device if the user is not an administrator
UserId origDeviceOwner ((uid_t) -1);
DevicePath virtualDevice = volume->VirtualDevice;
#ifdef TC_MACOSX
string virtualDeviceStr = virtualDevice;
if (virtualDeviceStr.find ("/dev/rdisk") != 0)
virtualDevice = "/dev/r" + virtualDeviceStr.substr (5);
#endif
try
{
File file;
file.Open (virtualDevice, File::OpenReadWrite);
}
catch (...)
{
if (!Core->HasAdminPrivileges())
{
origDeviceOwner = virtualDevice.GetOwner();
Core->SetFileOwner (virtualDevice, UserId (getuid()));
}
}
finally_do_arg2 (FilesystemPath, virtualDevice, UserId, origDeviceOwner,
{
if (finally_arg2.SystemId != (uid_t) -1)
Core->SetFileOwner (finally_arg, finally_arg2);
});
// Create filesystem
list <string> args;
if (SelectedFilesystemType == VolumeCreationOptions::FilesystemType::MacOsExt && VolumeSize >= 10 * BYTES_PER_MB)
args.push_back ("-J");
args.push_back (string (virtualDevice));
Process::Execute (fsFormatter, args);
}
#endif // TC_UNIX
if (OuterVolume)
{
SetStep (Step::OuterVolumeContents);
}
else
{
Gui->ShowInfo (SelectedVolumeType == VolumeType::Hidden ? "HIDVOL_FORMAT_FINISHED_HELP" : "FORMAT_FINISHED_INFO");
SetStep (Step::VolumeCreatedInfo);
}
return;
}
}
catch (exception &e)
{
Gui->ShowError (e);
}
page->SetProgressValue (0);
if (SelectedVolumeType == VolumeType::Normal && !SelectedVolumePath.IsDevice())
{
try
{
FilePath (wstring (SelectedVolumePath)).Delete();
}
catch (...) { }
}
}
WizardFrame::WizardStep VolumeCreationWizard::ProcessPageChangeRequest (bool forward)
{
switch (GetCurrentStep())
{
case Step::VolumeHostType:
{
SingleChoiceWizardPage <VolumeHostType::Enum> *page = dynamic_cast <SingleChoiceWizardPage <VolumeHostType::Enum> *> (GetCurrentPage());
try
{
SelectedVolumeHostType = page->GetSelection();
}
catch (NoItemSelected &)
{
return GetCurrentStep();
}
return Step::VolumeType;
}
case Step::VolumeType:
{
SingleChoiceWizardPage <VolumeType::Enum> *page = dynamic_cast <SingleChoiceWizardPage <VolumeType::Enum> *> (GetCurrentPage());
try
{
SelectedVolumeType = page->GetSelection();
}
catch (NoItemSelected &)
{
return GetCurrentStep();
}
if (SelectedVolumeType == VolumeType::Hidden)
OuterVolume = true;
return Step::VolumeLocation;
}
case Step::VolumeLocation:
{
VolumeLocationWizardPage *page = dynamic_cast <VolumeLocationWizardPage *> (GetCurrentPage());
SelectedVolumePath = page->GetVolumePath();
VolumeSize = 0;
if (forward)
{
if (Core->IsVolumeMounted (SelectedVolumePath))
{
Gui->ShowInfo ("DISMOUNT_FIRST");
return GetCurrentStep();
}
if (SelectedVolumePath.IsDevice())
{
if (!DeviceWarningConfirmed && !Gui->AskYesNo (LangString["FORMAT_DEVICE_FOR_ADVANCED_ONLY"]))
return GetCurrentStep();
DeviceWarningConfirmed = true;
foreach_ref (const HostDevice &drive, Core->GetHostDevices())
{
if (drive.Path == SelectedVolumePath && !drive.Partitions.empty())
{
foreach_ref (const HostDevice &partition, drive.Partitions)
{
if (partition.MountPoint == "/")
{
Gui->ShowError (_("Error: You are trying to encrypt a system drive.\n\nTrueCrypt can encrypt a system drive only under Windows."));
return GetCurrentStep();
}
}
Gui->ShowError ("DEVICE_PARTITIONS_ERR");
return GetCurrentStep();
}
}
try
{
SectorSize = Core->GetDeviceSectorSize (SelectedVolumePath);
VolumeSize = Core->GetDeviceSize (SelectedVolumePath);
}
catch (UserAbort&)
{
return Step::VolumeLocation;
}
catch (exception &e)
{
Gui->ShowError (e);
Gui->ShowError ("CANNOT_CALC_SPACE");
return GetCurrentStep();
}
DirectoryPath mountPoint;
try
{
mountPoint = Core->GetDeviceMountPoint (SelectedVolumePath);
if (!mountPoint.IsEmpty())
{
if (mountPoint == "/")
{
Gui->ShowError (_("Error: You are trying to encrypt a system partition.\n\nTrueCrypt can encrypt system partitions only under Windows."));
return GetCurrentStep();
}
if (!Gui->AskYesNo (StringFormatter (_("WARNING: Formatting of the device will destroy all data on filesystem '{0}'.\n\nDo you want to continue?"), wstring (mountPoint)), false, true))
return GetCurrentStep();
try
{
Core->DismountFilesystem (mountPoint, true);
}
catch (exception &e)
{
Gui->ShowError (e);
Gui->ShowError (StringFormatter (_("The filesystem of the selected device is currently mounted. Please dismount '{0}' before proceeding."), wstring (mountPoint)));
return GetCurrentStep();
}
}
}
catch (...) { }
}
else
SectorSize = TC_SECTOR_SIZE_FILE_HOSTED_VOLUME;
}
return Step::EncryptionOptions;
}
case Step::EncryptionOptions:
{
EncryptionOptionsWizardPage *page = dynamic_cast <EncryptionOptionsWizardPage *> (GetCurrentPage());
SelectedEncryptionAlgorithm = page->GetEncryptionAlgorithm ();
SelectedHash = page->GetHash ();
if (forward)
RandomNumberGenerator::SetHash (SelectedHash);
if (SelectedVolumePath.IsDevice() && (OuterVolume || SelectedVolumeType != VolumeType::Hidden))
return Step::VolumePassword;
else
return Step::VolumeSize;
}
case Step::VolumeSize:
{
VolumeSizeWizardPage *page = dynamic_cast <VolumeSizeWizardPage *> (GetCurrentPage());
try
{
VolumeSize = page->GetVolumeSize();
}
catch (Exception &e)
{
if (forward)
{
Gui->ShowError (e);
return GetCurrentStep();
}
}
if (forward
&& !OuterVolume && SelectedVolumeType == VolumeType::Hidden
&& (double) VolumeSize / MaxHiddenVolumeSize > 0.85)
{
if (!Gui->AskYesNo (LangString["FREE_SPACE_FOR_WRITING_TO_OUTER_VOLUME"]))
return GetCurrentStep();
}
if (forward
&& SelectedVolumeHostType == VolumeHostType::File
&& VolumeSize > 4 * BYTES_PER_GB
&& (OuterVolume || SelectedVolumeType != VolumeType::Hidden)
&& !Core->FilesystemSupportsLargeFiles (SelectedVolumePath))
{
Gui->ShowWarning (LangString["VOLUME_TOO_LARGE_FOR_FAT32"]);
}
return Step::VolumePassword;
}
case Step::VolumePassword:
{
VolumePasswordWizardPage *page = dynamic_cast <VolumePasswordWizardPage *> (GetCurrentPage());
Password = page->GetPassword();
Keyfiles = page->GetKeyfiles();
if (forward && Password && !Password->IsEmpty())
{
try
{
Password->CheckPortability();
}
catch (UnportablePassword &e)
{
Gui->ShowError (e);
return GetCurrentStep();
}
if (Password->Size() < VolumePassword::WarningSizeThreshold
&& !Gui->AskYesNo (LangString["PASSWORD_LENGTH_WARNING"], false, true))
{
return GetCurrentStep();
}
}
if (forward && OuterVolume)
{
// Use FAT to prevent problems with free space
QuickFormatEnabled = false;
SelectedFilesystemType = VolumeCreationOptions::FilesystemType::FAT;
return Step::CreationProgress;
}
if (VolumeSize > 4 * BYTES_PER_GB)
{
if (VolumeSize <= TC_MAX_FAT_SECTOR_COUNT * SectorSize)
return Step::LargeFilesSupport;
else
SelectedFilesystemType = VolumeCreationOptions::FilesystemType::GetPlatformNative();
}
return Step::FormatOptions;
}
case Step::LargeFilesSupport:
{
SingleChoiceWizardPage <bool> *page = dynamic_cast <SingleChoiceWizardPage <bool> *> (GetCurrentPage());
try
{
LargeFilesSupport = page->GetSelection();
}
catch (NoItemSelected &)
{
return GetCurrentStep();
}
if (LargeFilesSupport)
SelectedFilesystemType = VolumeCreationOptions::FilesystemType::GetPlatformNative();
else
SelectedFilesystemType = VolumeCreationOptions::FilesystemType::FAT;
return Step::FormatOptions;
}
case Step::FormatOptions:
{
VolumeFormatOptionsWizardPage *page = dynamic_cast <VolumeFormatOptionsWizardPage *> (GetCurrentPage());
SelectedFilesystemType = page->GetFilesystemType();
QuickFormatEnabled = page->IsQuickFormatEnabled();
if (SelectedFilesystemType != VolumeCreationOptions::FilesystemType::None
&& SelectedFilesystemType != VolumeCreationOptions::FilesystemType::FAT)
return Step::CrossPlatformSupport;
return Step::CreationProgress;
}
case Step::CrossPlatformSupport:
{
SingleChoiceWizardPage <bool> *page = dynamic_cast <SingleChoiceWizardPage <bool> *> (GetCurrentPage());
try
{
CrossPlatformSupport = page->GetSelection();
}
catch (NoItemSelected &)
{
return GetCurrentStep();
}
if (forward && CrossPlatformSupport)
Gui->ShowWarning (StringFormatter (_("Please note that the volume will not be formatted with a FAT filesystem and, therefore, you may be required to install additional filesystem drivers on platforms other than {0}, which will enable you to mount the volume."), SystemInfo::GetPlatformName()));
return Step::CreationProgress;
}
case Step::CreationProgress:
{
VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage());
DisplayKeyInfo = page->IsKeyInfoDisplayed();
if (forward)
{
if (SelectedVolumeType != VolumeType::Hidden || OuterVolume)
{
if (OuterVolume && VolumeSize > TC_MAX_FAT_SECTOR_COUNT * SectorSize)
{
uint64 limit = TC_MAX_FAT_SECTOR_COUNT * SectorSize / BYTES_PER_TB;
wstring err = StringFormatter (_("Error: The hidden volume to be created is larger than {0} TB ({1} GB).\n\nPossible solutions:\n- Create a container/partition smaller than {0} TB.\n"), limit, limit * 1024);
if (SectorSize < 4096)
{
err += _("- Use a drive with 4096-byte sectors to be able to create partition/device-hosted hidden volumes up to 16 TB in size");
#if defined (TC_LINUX)
err += _(".\n");
#else
err += _(" (not supported by components available on this platform).\n");
#endif
}
Gui->ShowError (err);
return GetCurrentStep();
}
if (SelectedVolumePath.IsDevice())
{
wxString confirmMsg = LangString["OVERWRITEPROMPT_DEVICE"];
confirmMsg.Replace (L"%hs", L"%s");
if (!Gui->AskYesNo (wxString::Format (confirmMsg, wxString (_("DEVICE")).c_str(), wstring (SelectedVolumePath).c_str(), L""), false, true))
return GetCurrentStep();
}
else if (FilesystemPath (wstring (SelectedVolumePath)).IsFile())
{
wxString confirmMsg = LangString["OVERWRITEPROMPT"];
confirmMsg.Replace (L"%hs", L"%s");
if (!Gui->AskYesNo (wxString::Format (confirmMsg, wstring (SelectedVolumePath).c_str(), false, true)))
return GetCurrentStep();
}
}
AbortRequested = false;
AbortConfirmationPending = false;
CreationAborted = false;
SetWorkInProgress (true);
UpdateControls();
Gui->BeginInteractiveBusyState (this);
try
{
make_shared_auto (VolumeCreationOptions, options);
options->Filesystem = SelectedFilesystemType;
options->FilesystemClusterSize = SelectedFilesystemClusterSize;
options->SectorSize = SectorSize;
options->EA = SelectedEncryptionAlgorithm;
options->Password = Password;
options->Keyfiles = Keyfiles;
options->Path = SelectedVolumePath;
options->Quick = QuickFormatEnabled;
options->Size = VolumeSize;
options->Type = OuterVolume ? VolumeType::Normal : SelectedVolumeType;
options->VolumeHeaderKdf = Pkcs5Kdf::GetAlgorithm (*SelectedHash);
Creator.reset (new VolumeCreator);
Creator->CreateVolume (options);
page->SetKeyInfo (Creator->GetKeyInfo());
class Timer : public wxTimer
{
public:
Timer (VolumeCreationWizard *wizard) : Wizard (wizard) { }
void Notify()
{
Wizard->OnProgressTimer();
}
VolumeCreationWizard *Wizard;
};
page->SetProgressRange (options->Size);
page->SetProgressState (true);
ProgressTimer.reset (dynamic_cast <wxTimer *> (new Timer (this)));
ProgressTimer->Start (50);
}
catch (Exception &e)
{
CreationAborted = true;
OnVolumeCreatorFinished();
Gui->ShowError (e);
}
}
return GetCurrentStep();
}
case Step::VolumeCreatedInfo:
Creator.reset();
SetCancelButtonText (L"");
return Step::VolumeHostType;
case Step::OuterVolumeContents:
try
{
// Determine maximum size of the hidden volume. Scan cluster table offline as a live filesystem test would
// require using FUSE and loop device which cannot be used for devices with sectors larger than 512.
wxBusyCursor busy;
MaxHiddenVolumeSize = 0;
Gui->SetActiveFrame (this);
if (MountedOuterVolume)
{
Core->DismountVolume (MountedOuterVolume);
MountedOuterVolume.reset();
}
#ifdef TC_UNIX
// Temporarily take ownership of a device if the user is not an administrator
UserId origDeviceOwner ((uid_t) -1);
if (!Core->HasAdminPrivileges() && SelectedVolumePath.IsDevice())
{
origDeviceOwner = FilesystemPath (wstring (SelectedVolumePath)).GetOwner();
Core->SetFileOwner (SelectedVolumePath, UserId (getuid()));
}
finally_do_arg2 (FilesystemPath, SelectedVolumePath, UserId, origDeviceOwner,
{
if (finally_arg2.SystemId != (uid_t) -1)
Core->SetFileOwner (finally_arg, finally_arg2);
});
#endif
shared_ptr <Volume> outerVolume = Core->OpenVolume (make_shared <VolumePath> (SelectedVolumePath), true, Password, Keyfiles, VolumeProtection::ReadOnly);
MaxHiddenVolumeSize = Core->GetMaxHiddenVolumeSize (outerVolume);
// Add a reserve (in case the user mounts the outer volume and creates new files
// on it by accident or OS writes some new data behind his or her back, such as
// System Restore etc.)
uint64 reservedSize = outerVolume->GetSize() / 200;
if (reservedSize > 10 * BYTES_PER_MB)
reservedSize = 10 * BYTES_PER_MB;
if (MaxHiddenVolumeSize < reservedSize)
MaxHiddenVolumeSize = 0;
else
MaxHiddenVolumeSize -= reservedSize;
MaxHiddenVolumeSize -= MaxHiddenVolumeSize % outerVolume->GetSectorSize(); // Must be a multiple of the sector size
}
catch (exception &e)
{
Gui->SetActiveFrame (this);
Gui->ShowError (e);
return GetCurrentStep();
}
return Step::HiddenVolume;
case Step::HiddenVolume:
return Step::EncryptionOptions;
default:
throw ParameterIncorrect (SRC_POS);
}
}
void VolumeCreationWizard::UpdateControls ()
{
VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage());
if (page)
{
page->EnableAbort (IsWorkInProgress());
}
}
bool VolumeCreationWizard::DeviceWarningConfirmed;
}

View File

@@ -0,0 +1,85 @@
/*
Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_VolumeCreationWizard
#define TC_HEADER_Main_Forms_VolumeCreationWizard
#include "WizardFrame.h"
#include "Core/VolumeCreator.h"
namespace TrueCrypt
{
class VolumeCreationWizard : public WizardFrame
{
public:
VolumeCreationWizard (wxWindow* parent);
~VolumeCreationWizard ();
protected:
struct Step
{
enum Enum
{
VolumeHostType,
VolumeType,
VolumeLocation,
EncryptionOptions,
VolumeSize,
VolumePassword,
LargeFilesSupport,
FormatOptions,
CrossPlatformSupport,
CreationProgress,
VolumeCreatedInfo,
OuterVolumeContents,
HiddenVolume
};
};
void CreateVolume ();
WizardPage *GetPage (WizardStep step);
void OnAbortButtonClick (EventArgs &args);
void OnMouseMotion (wxMouseEvent& event);
void OnProgressTimer ();
void OnRandomPoolUpdateTimer ();
void OnThreadExiting (wxCommandEvent& event);
void OnVolumeCreatorFinished ();
WizardStep ProcessPageChangeRequest (bool forward);
volatile bool AbortConfirmationPending;
volatile bool AbortRequested;
volatile bool CreationAborted;
auto_ptr <VolumeCreator> Creator;
bool CrossPlatformSupport;
static bool DeviceWarningConfirmed;
bool DisplayKeyInfo;
auto_ptr <wxTimer> ProgressTimer;
auto_ptr <wxTimer> RandomPoolUpdateTimer;
shared_ptr <KeyfileList> Keyfiles;
bool LargeFilesSupport;
uint64 MaxHiddenVolumeSize;
shared_ptr <VolumeInfo> MountedOuterVolume;
bool OuterVolume;
bool QuickFormatEnabled;
shared_ptr <EncryptionAlgorithm> SelectedEncryptionAlgorithm;
uint32 SelectedFilesystemClusterSize;
VolumeCreationOptions::FilesystemType::Enum SelectedFilesystemType;
VolumePath SelectedVolumePath;
VolumeHostType::Enum SelectedVolumeHostType;
VolumeType::Enum SelectedVolumeType;
shared_ptr <VolumePassword> Password;
uint32 SectorSize;
shared_ptr <Hash> SelectedHash;
uint64 VolumeSize;
private:
void UpdateControls ();
};
}
#endif // TC_HEADER_Main_Forms_VolumeCreationWizard

View File

@@ -0,0 +1,81 @@
/*
Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "VolumeFormatOptionsWizardPage.h"
namespace TrueCrypt
{
VolumeFormatOptionsWizardPage::VolumeFormatOptionsWizardPage (wxPanel* parent, uint64 volumeSize, uint32 sectorSize, bool enableQuickFormatButton, bool disableNoneFilesystem, bool disable32bitFilesystems)
: VolumeFormatOptionsWizardPageBase (parent)
{
InfoStaticText->SetLabel (_(
"In order to enable your operating system to mount your new volume, it has to be formatted with a filesystem. Please select a filesystem type.\n\nIf your volume is going to be hosted on a device or partition, you can use 'Quick format' to skip encryption of free space of the volume."));
if (!disableNoneFilesystem)
FilesystemTypeChoice->Append (LangString["NONE"], (void *) VolumeCreationOptions::FilesystemType::None);
if (!disable32bitFilesystems && volumeSize <= TC_MAX_FAT_SECTOR_COUNT * sectorSize)
FilesystemTypeChoice->Append (L"FAT", (void *) VolumeCreationOptions::FilesystemType::FAT);
#ifdef TC_WINDOWS
FilesystemTypeChoice->Append (L"NTFS", (void *) VolumeCreationOptions::FilesystemType::NTFS);
#elif defined (TC_LINUX)
FilesystemTypeChoice->Append (L"Linux Ext2", (void *) VolumeCreationOptions::FilesystemType::Ext2);
FilesystemTypeChoice->Append (L"Linux Ext3", (void *) VolumeCreationOptions::FilesystemType::Ext3);
FilesystemTypeChoice->Append (L"Linux Ext4", (void *) VolumeCreationOptions::FilesystemType::Ext4);
#elif defined (TC_MACOSX)
FilesystemTypeChoice->Append (L"Mac OS Extended", (void *) VolumeCreationOptions::FilesystemType::MacOsExt);
#elif defined (TC_FREEBSD) || defined (TC_SOLARIS)
FilesystemTypeChoice->Append (L"UFS", (void *) VolumeCreationOptions::FilesystemType::UFS);
#endif
if (!disable32bitFilesystems && volumeSize <= TC_MAX_FAT_SECTOR_COUNT * sectorSize)
SetFilesystemType (VolumeCreationOptions::FilesystemType::FAT);
else
SetFilesystemType (VolumeCreationOptions::FilesystemType::GetPlatformNative());
QuickFormatCheckBox->Enable (enableQuickFormatButton);
}
VolumeCreationOptions::FilesystemType::Enum VolumeFormatOptionsWizardPage::GetFilesystemType () const
{
return (VolumeCreationOptions::FilesystemType::Enum) reinterpret_cast <unsigned long long> (Gui->GetSelectedData <void> (FilesystemTypeChoice));
}
void VolumeFormatOptionsWizardPage::OnFilesystemTypeSelected (wxCommandEvent& event)
{
}
void VolumeFormatOptionsWizardPage::OnQuickFormatCheckBoxClick (wxCommandEvent& event)
{
if (event.IsChecked())
{
QuickFormatCheckBox->SetValue (Gui->AskYesNo (LangString["WARN_QUICK_FORMAT"], false, true));
}
}
void VolumeFormatOptionsWizardPage::SetFilesystemType (VolumeCreationOptions::FilesystemType::Enum type)
{
switch (type)
{
case VolumeCreationOptions::FilesystemType::None: FilesystemTypeChoice->SetStringSelection (LangString["NONE"]); break;
case VolumeCreationOptions::FilesystemType::FAT: FilesystemTypeChoice->SetStringSelection (L"FAT"); break;
case VolumeCreationOptions::FilesystemType::NTFS: FilesystemTypeChoice->SetStringSelection (L"NTFS"); break;
case VolumeCreationOptions::FilesystemType::Ext2: FilesystemTypeChoice->SetStringSelection (L"Linux Ext2"); break;
case VolumeCreationOptions::FilesystemType::Ext3: FilesystemTypeChoice->SetStringSelection (L"Linux Ext3"); break;
case VolumeCreationOptions::FilesystemType::Ext4: FilesystemTypeChoice->SetStringSelection (L"Linux Ext4"); break;
case VolumeCreationOptions::FilesystemType::MacOsExt: FilesystemTypeChoice->SetStringSelection (L"Mac OS Extended"); break;
case VolumeCreationOptions::FilesystemType::UFS: FilesystemTypeChoice->SetStringSelection (L"UFS"); break;
default:
throw ParameterIncorrect (SRC_POS);
}
}
}

View File

@@ -0,0 +1,36 @@
/*
Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_VolumeFormatOptionsWizardPage
#define TC_HEADER_Main_Forms_VolumeFormatOptionsWizardPage
#include "Forms.h"
#include "Core/VolumeCreator.h"
namespace TrueCrypt
{
class VolumeFormatOptionsWizardPage : public VolumeFormatOptionsWizardPageBase
{
public:
VolumeFormatOptionsWizardPage (wxPanel* parent, uint64 volumeSize, uint32 sectorSize, bool enableQuickFormatButton = true, bool disableNoneFilesystem = false, bool disable32bitFilesystems = false);
VolumeCreationOptions::FilesystemType::Enum GetFilesystemType () const;
bool IsValid () { return true; }
bool IsQuickFormatEnabled () const { return QuickFormatCheckBox->IsChecked(); }
void SetMaxStaticTextWidth (int width) { InfoStaticText->Wrap (width); }
void SetFilesystemType (VolumeCreationOptions::FilesystemType::Enum type);
void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); }
void SetQuickFormat (bool enabled) { QuickFormatCheckBox->SetValue (enabled); }
protected:
void OnFilesystemTypeSelected (wxCommandEvent& event);
void OnQuickFormatCheckBoxClick (wxCommandEvent& event);
};
}
#endif // TC_HEADER_Main_Forms_VolumeFormatOptionsWizardPage

View File

@@ -0,0 +1,98 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "Main/VolumeHistory.h"
#include "VolumeLocationWizardPage.h"
namespace TrueCrypt
{
VolumeLocationWizardPage::VolumeLocationWizardPage (wxPanel* parent, VolumeHostType::Enum hostType, bool selectExisting)
: VolumeLocationWizardPageBase (parent),
SelectExisting (selectExisting)
{
switch (hostType)
{
case VolumeHostType::Device:
SelectFileButton->Show (false);
break;
case VolumeHostType::File:
SelectDeviceButton->Show (false);
break;
default:
break;
}
Gui->PreferencesUpdatedEvent.Connect (EventConnector <VolumeLocationWizardPage> (this, &VolumeLocationWizardPage::OnPreferencesUpdated));
VolumeHistory::ConnectComboBox (VolumePathComboBox);
NoHistoryCheckBox->SetValue (!Gui->GetPreferences().SaveHistory);
}
VolumeLocationWizardPage::~VolumeLocationWizardPage ()
{
Gui->PreferencesUpdatedEvent.Disconnect (this);
VolumeHistory::DisconnectComboBox (VolumePathComboBox);
}
void VolumeLocationWizardPage::OnNoHistoryCheckBoxClick (wxCommandEvent& event)
{
UserPreferences prefs = Gui->GetPreferences();
prefs.SaveHistory = !event.IsChecked();
Gui->SetPreferences (prefs);
if (event.IsChecked())
{
try
{
VolumeHistory::Clear();
}
catch (exception &e) { Gui->ShowError (e); }
}
}
void VolumeLocationWizardPage::OnPageChanging (bool forward)
{
if (forward)
{
VolumePath path = GetVolumePath();
if (!path.IsEmpty())
VolumeHistory::Add (path);
}
}
void VolumeLocationWizardPage::OnPreferencesUpdated (EventArgs &args)
{
NoHistoryCheckBox->SetValue (!Gui->GetPreferences().SaveHistory);
}
void VolumeLocationWizardPage::OnSelectFileButtonClick (wxCommandEvent& event)
{
FilePath path = Gui->SelectVolumeFile (this, !SelectExisting);
if (!path.IsEmpty())
SetVolumePath (path);
}
void VolumeLocationWizardPage::OnSelectDeviceButtonClick (wxCommandEvent& event)
{
DevicePath path = Gui->SelectDevice (this);
if (!path.IsEmpty())
SetVolumePath (path);
}
void VolumeLocationWizardPage::SetVolumePath (const VolumePath &path)
{
VolumePathComboBox->SetValue (wstring (path));
PageUpdatedEvent.Raise();
}
}

View File

@@ -0,0 +1,40 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_VolumeLocationWizardPage
#define TC_HEADER_Main_Forms_VolumeLocationWizardPage
#include "Forms.h"
namespace TrueCrypt
{
class VolumeLocationWizardPage : public VolumeLocationWizardPageBase
{
public:
VolumeLocationWizardPage (wxPanel* parent, VolumeHostType::Enum hostType = VolumeHostType::Unknown, bool selectExisting = false);
~VolumeLocationWizardPage ();
VolumePath GetVolumePath () const { return VolumePath (wstring (VolumePathComboBox->GetValue())); }
bool IsValid () { return !VolumePathComboBox->GetValue().IsEmpty(); }
void OnPageChanging (bool forward);
void SetVolumePath (const VolumePath &path);
void SetMaxStaticTextWidth (int width) { InfoStaticText->Wrap (width); }
void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); }
protected:
void OnVolumePathTextChanged (wxCommandEvent& event) { PageUpdatedEvent.Raise(); }
void OnNoHistoryCheckBoxClick (wxCommandEvent& event);
void OnSelectDeviceButtonClick (wxCommandEvent& event);
void OnSelectFileButtonClick (wxCommandEvent& event);
void OnPreferencesUpdated (EventArgs &args);
bool SelectExisting;
};
}
#endif // TC_HEADER_Main_Forms_VolumeLocationWizardPage

View File

@@ -0,0 +1,310 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "KeyfilesDialog.h"
#include "VolumePasswordPanel.h"
#include "SecurityTokenKeyfilesDialog.h"
namespace TrueCrypt
{
VolumePasswordPanel::VolumePasswordPanel (wxWindow* parent, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, bool enableCache, bool enablePassword, bool enableKeyfiles, bool enableConfirmation, bool enablePkcs5Prf, const wxString &passwordLabel)
: VolumePasswordPanelBase (parent), Keyfiles (new KeyfileList)
{
if (keyfiles)
{
*Keyfiles = *keyfiles;
UseKeyfilesCheckBox->SetValue (!Keyfiles->empty());
}
else
{
*Keyfiles = Gui->GetPreferences().DefaultKeyfiles;
UseKeyfilesCheckBox->SetValue (Gui->GetPreferences().UseKeyfiles && !Keyfiles->empty());
}
PasswordTextCtrl->SetMaxLength (VolumePassword::MaxSize);
ConfirmPasswordTextCtrl->SetMaxLength (VolumePassword::MaxSize);
if (!passwordLabel.empty())
{
PasswordStaticText->SetLabel (passwordLabel);
GridBagSizer->Detach (PasswordStaticText);
GridBagSizer->Add (PasswordStaticText, wxGBPosition (0, 1), wxGBSpan (1, 1), wxALIGN_CENTER_VERTICAL | wxBOTTOM, Gui->GetDefaultBorderSize());
}
CacheCheckBox->Show (enableCache);
if (!enablePassword && enableKeyfiles)
{
Layout();
Fit();
PasswordPlaceholderSizer->SetMinSize (wxSize (PasswordTextCtrl->GetSize().GetWidth(), -1));
}
else if (!enablePkcs5Prf)
{
GridBagSizer->Remove (PasswordPlaceholderSizer);
}
PasswordStaticText->Show (enablePassword);
PasswordTextCtrl->Show (enablePassword);
DisplayPasswordCheckBox->Show (enablePassword);
ConfirmPasswordStaticText->Show (enableConfirmation);
ConfirmPasswordTextCtrl->Show (enableConfirmation);
UseKeyfilesCheckBox->Show (enableKeyfiles);
KeyfilesButton->Show (enableKeyfiles);
Pkcs5PrfStaticText->Show (enablePkcs5Prf);
Pkcs5PrfChoice->Show (enablePkcs5Prf);
if (enablePkcs5Prf)
{
foreach_ref (const Pkcs5Kdf &kdf, Pkcs5Kdf::GetAvailableAlgorithms())
{
if (!kdf.IsDeprecated())
Pkcs5PrfChoice->Append (kdf.GetName());
}
Pkcs5PrfChoice->Select (0);
}
if (!enablePkcs5Prf || (!enablePassword && !enableKeyfiles))
{
GridBagSizer->Remove (Pkcs5PrfSizer);
}
// Keyfiles drag & drop
class FileDropTarget : public wxFileDropTarget
{
public:
FileDropTarget (VolumePasswordPanel *panel) : Panel (panel) { }
wxDragResult OnDragOver (wxCoord x, wxCoord y, wxDragResult def)
{
return wxDragLink;
}
bool OnDropFiles (wxCoord x, wxCoord y, const wxArrayString &filenames)
{
foreach (const wxString &f, filenames)
Panel->AddKeyfile (make_shared <Keyfile> (wstring (f)));
return true;
}
protected:
VolumePasswordPanel *Panel;
};
if (enableKeyfiles)
{
SetDropTarget (new FileDropTarget (this));
#ifdef TC_MACOSX
foreach (wxWindow *c, GetChildren())
c->SetDropTarget (new FileDropTarget (this));
#endif
}
Layout();
Fit();
}
VolumePasswordPanel::~VolumePasswordPanel ()
{
WipeTextCtrl (PasswordTextCtrl);
WipeTextCtrl (ConfirmPasswordTextCtrl);
}
void VolumePasswordPanel::AddKeyfile (shared_ptr <Keyfile> keyfile)
{
if (!Keyfiles)
Keyfiles.reset (new KeyfileList);
Keyfiles->push_back (keyfile);
UseKeyfilesCheckBox->SetValue (true);
}
void VolumePasswordPanel::DisplayPassword (bool display, wxTextCtrl **textCtrl, int row)
{
FreezeScope freeze (this);
wxTextCtrl *newTextCtrl = new wxTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, display ? 0 : wxTE_PASSWORD);
newTextCtrl->SetMaxLength (VolumePassword::MaxSize);
newTextCtrl->SetValue ((*textCtrl)->GetValue());
newTextCtrl->SetMinSize ((*textCtrl)->GetSize());
GridBagSizer->Detach ((*textCtrl));
GridBagSizer->Add (newTextCtrl, wxGBPosition (row, 1), wxGBSpan (1, 2), wxEXPAND|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5);
(*textCtrl)->Show (false);
WipeTextCtrl (*textCtrl);
Fit();
Layout();
newTextCtrl->SetMinSize ((*textCtrl)->GetMinSize());
newTextCtrl->Connect (wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (VolumePasswordPanel::OnTextChanged), nullptr, this);
*textCtrl = newTextCtrl;
}
shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword () const
{
return GetPassword (PasswordTextCtrl);
}
shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword (wxTextCtrl *textCtrl) const
{
shared_ptr <VolumePassword> password;
wchar_t passwordBuf[VolumePassword::MaxSize + 1];
finally_do_arg (BufferPtr, BufferPtr (reinterpret_cast <byte *> (passwordBuf), sizeof (passwordBuf)), { finally_arg.Erase(); });
#ifdef TC_WINDOWS
int len = GetWindowText (static_cast <HWND> (textCtrl->GetHandle()), passwordBuf, VolumePassword::MaxSize + 1);
password.reset (new VolumePassword (passwordBuf, len));
#else
wxString passwordStr (textCtrl->GetValue()); // A copy of the password is created here by wxWidgets, which cannot be erased
for (size_t i = 0; i < passwordStr.size() && i < VolumePassword::MaxSize; ++i)
{
passwordBuf[i] = (wchar_t) passwordStr[i];
passwordStr[i] = L'X';
}
password.reset (new VolumePassword (passwordBuf, passwordStr.size() <= VolumePassword::MaxSize ? passwordStr.size() : VolumePassword::MaxSize));
#endif
return password;
}
shared_ptr <Pkcs5Kdf> VolumePasswordPanel::GetPkcs5Kdf () const
{
try
{
return Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection()));
}
catch (ParameterIncorrect&)
{
return shared_ptr <Pkcs5Kdf> ();
}
}
void VolumePasswordPanel::OnAddKeyfileDirMenuItemSelected (wxCommandEvent& event)
{
try
{
DirectoryPath dir = Gui->SelectDirectory (this, LangString["SELECT_KEYFILE_PATH"]);
if (!dir.IsEmpty())
{
Keyfiles->push_back (make_shared <Keyfile> (dir));
UseKeyfilesCheckBox->SetValue (!Keyfiles->empty());
OnUpdate();
}
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
void VolumePasswordPanel::OnAddKeyfilesMenuItemSelected (wxCommandEvent& event)
{
try
{
FilePathList files = Gui->SelectFiles (this, LangString["SELECT_KEYFILES"], false, true);
if (!files.empty())
{
foreach_ref (const FilePath &f, files)
Keyfiles->push_back (make_shared <Keyfile> (f));
UseKeyfilesCheckBox->SetValue (!Keyfiles->empty());
OnUpdate();
}
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
void VolumePasswordPanel::OnAddSecurityTokenSignatureMenuItemSelected (wxCommandEvent& event)
{
try
{
SecurityTokenKeyfilesDialog dialog (this);
if (dialog.ShowModal() == wxID_OK)
{
foreach (const SecurityTokenKeyfilePath &path, dialog.GetSelectedSecurityTokenKeyfilePaths())
{
Keyfiles->push_back (make_shared <Keyfile> (wstring (path)));
}
if (!dialog.GetSelectedSecurityTokenKeyfilePaths().empty())
{
UseKeyfilesCheckBox->SetValue (!Keyfiles->empty());
OnUpdate();
}
}
}
catch (exception &e)
{
Gui->ShowError (e);
}
}
void VolumePasswordPanel::OnDisplayPasswordCheckBoxClick (wxCommandEvent& event)
{
DisplayPassword (event.IsChecked(), &PasswordTextCtrl, 1);
if (ConfirmPasswordTextCtrl->IsShown())
DisplayPassword (event.IsChecked(), &ConfirmPasswordTextCtrl, 2);
OnUpdate();
}
void VolumePasswordPanel::OnKeyfilesButtonClick (wxCommandEvent& event)
{
KeyfilesDialog dialog (GetParent(), Keyfiles);
if (dialog.ShowModal() == wxID_OK)
{
Keyfiles = dialog.GetKeyfiles();
UseKeyfilesCheckBox->SetValue (!Keyfiles->empty());
OnUpdate();
}
}
void VolumePasswordPanel::OnKeyfilesButtonRightClick (wxMouseEvent& event)
{
wxMenu popup;
Gui->AppendToMenu (popup, LangString["IDC_KEYADD"], this, wxCommandEventHandler (VolumePasswordPanel::OnAddKeyfilesMenuItemSelected));
Gui->AppendToMenu (popup, LangString["IDC_ADD_KEYFILE_PATH"], this, wxCommandEventHandler (VolumePasswordPanel::OnAddKeyfileDirMenuItemSelected));
Gui->AppendToMenu (popup, LangString["IDC_TOKEN_FILES_ADD"], this, wxCommandEventHandler (VolumePasswordPanel::OnAddSecurityTokenSignatureMenuItemSelected));
PopupMenu (&popup, KeyfilesButton->GetPosition().x + 2, KeyfilesButton->GetPosition().y + 2);
}
void VolumePasswordPanel::OnKeyfilesButtonRightDown (wxMouseEvent& event)
{
#ifndef TC_MACOSX
event.Skip();
#endif
}
bool VolumePasswordPanel::PasswordsMatch () const
{
assert (ConfirmPasswordStaticText->IsShown());
return *GetPassword (PasswordTextCtrl) == *GetPassword (ConfirmPasswordTextCtrl);
}
void VolumePasswordPanel::WipeTextCtrl (wxTextCtrl *textCtrl)
{
textCtrl->SetValue (wxString (L'X', textCtrl->GetLineLength(0)));
GetPassword (textCtrl);
}
}

View File

@@ -0,0 +1,54 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_PasswordPanel
#define TC_HEADER_Main_Forms_PasswordPanel
#include "Forms.h"
#include "Platform/Functor.h"
#include "Main/Main.h"
namespace TrueCrypt
{
class VolumePasswordPanel : public VolumePasswordPanelBase
{
public:
VolumePasswordPanel (wxWindow* parent, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, bool enableCache = false, bool enablePassword = true, bool enableKeyfiles = true, bool enableConfirmation = false, bool enablePkcs5Prf = false, const wxString &passwordLabel = wxString());
virtual ~VolumePasswordPanel ();
void AddKeyfile (shared_ptr <Keyfile> keyfile);
shared_ptr <KeyfileList> GetKeyfiles () const { return UseKeyfilesCheckBox->IsChecked() ? Keyfiles : shared_ptr <KeyfileList> (); }
shared_ptr <VolumePassword> GetPassword () const;
shared_ptr <Pkcs5Kdf> GetPkcs5Kdf () const;
void SetCacheCheckBoxValidator (const wxGenericValidator &validator) { CacheCheckBox->SetValidator (validator); }
void SetFocusToPasswordTextCtrl () { PasswordTextCtrl->SetSelection (-1, -1); PasswordTextCtrl->SetFocus(); }
bool PasswordsMatch () const;
Event UpdateEvent;
protected:
void DisplayPassword (bool display, wxTextCtrl **textCtrl, int row);
shared_ptr <VolumePassword> GetPassword (wxTextCtrl *textCtrl) const;
void OnAddKeyfileDirMenuItemSelected (wxCommandEvent& event);
void OnAddKeyfilesMenuItemSelected (wxCommandEvent& event);
void OnAddSecurityTokenSignatureMenuItemSelected (wxCommandEvent& event);
void OnDisplayPasswordCheckBoxClick (wxCommandEvent& event);
void OnKeyfilesButtonClick (wxCommandEvent& event);
void OnKeyfilesButtonRightClick (wxMouseEvent& event);
void OnKeyfilesButtonRightDown (wxMouseEvent& event);
void OnTextChanged (wxCommandEvent& event) { OnUpdate(); }
void OnUpdate () { UpdateEvent.Raise(); }
void OnUseKeyfilesCheckBoxClick (wxCommandEvent& event) { OnUpdate(); }
void WipeTextCtrl (wxTextCtrl *textCtrl);
shared_ptr <KeyfileList> Keyfiles;
shared_ptr <Functor> UpdateCallback;
};
}
#endif // TC_HEADER_Main_Forms_PasswordPanel

View File

@@ -0,0 +1,39 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "VolumePasswordWizardPage.h"
namespace TrueCrypt
{
VolumePasswordWizardPage::VolumePasswordWizardPage (wxPanel* parent, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, bool enableConfirmation)
: VolumePasswordWizardPageBase (parent), ConfirmationMode (enableConfirmation)
{
PasswordPanel = new VolumePasswordPanel (this, password, keyfiles, false, true, true, enableConfirmation);
PasswordPanel->UpdateEvent.Connect (EventConnector <VolumePasswordWizardPage> (this, &VolumePasswordWizardPage::OnPasswordPanelUpdate));
PasswordPanelSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND);
}
VolumePasswordWizardPage::~VolumePasswordWizardPage ()
{
PasswordPanel->UpdateEvent.Disconnect (this);
}
bool VolumePasswordWizardPage::IsValid ()
{
if (ConfirmationMode && !PasswordPanel->PasswordsMatch())
return false;
shared_ptr <KeyfileList> keyfiles (GetKeyfiles());
shared_ptr <VolumePassword> password (GetPassword());
return (password && !GetPassword()->IsEmpty()) || (keyfiles && !keyfiles->empty());
}
}

View File

@@ -0,0 +1,37 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_VolumePasswordWizardPage
#define TC_HEADER_Main_Forms_VolumePasswordWizardPage
#include "Forms.h"
#include "VolumePasswordPanel.h"
namespace TrueCrypt
{
class VolumePasswordWizardPage : public VolumePasswordWizardPageBase
{
public:
VolumePasswordWizardPage (wxPanel* parent, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, bool enableConfirmation = true);
~VolumePasswordWizardPage ();
shared_ptr <KeyfileList> GetKeyfiles () const { return PasswordPanel->GetKeyfiles(); }
shared_ptr <VolumePassword> GetPassword () const { return PasswordPanel->GetPassword(); }
bool IsValid ();
void SetMaxStaticTextWidth (int width) { InfoStaticText->Wrap (width); }
void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); }
protected:
void OnPasswordPanelUpdate (EventArgs &args) { PageUpdatedEvent.Raise(); }
bool ConfirmationMode;
VolumePasswordPanel *PasswordPanel;
};
}
#endif // TC_HEADER_Main_Forms_VolumePasswordWizardPage

View File

@@ -0,0 +1,97 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/Main.h"
#include "Main/GraphicUserInterface.h"
#include "VolumePropertiesDialog.h"
namespace TrueCrypt
{
VolumePropertiesDialog::VolumePropertiesDialog (wxWindow* parent, const VolumeInfo &volumeInfo)
: VolumePropertiesDialogBase (parent)
{
list <int> colPermilles;
PropertiesListCtrl->InsertColumn (0, LangString["PROPERTY"], wxLIST_FORMAT_LEFT, 208);
colPermilles.push_back (500);
PropertiesListCtrl->InsertColumn (1, LangString["VALUE"], wxLIST_FORMAT_LEFT, 192);
colPermilles.push_back (500);
Gui->SetListCtrlWidth (PropertiesListCtrl, 70, false);
Gui->SetListCtrlHeight (PropertiesListCtrl, 17);
Gui->SetListCtrlColumnWidths (PropertiesListCtrl, colPermilles, false);
AppendToList ("LOCATION", wstring (volumeInfo.Path));
#ifndef TC_WINDOWS
AppendToList ("VIRTUAL_DEVICE", wstring (volumeInfo.VirtualDevice));
#endif
AppendToList ("SIZE", Gui->SizeToString (volumeInfo.Size));
AppendToList ("TYPE", Gui->VolumeTypeToString (volumeInfo.Type, volumeInfo.Protection));
AppendToList ("READ_ONLY", LangString [volumeInfo.Protection == VolumeProtection::ReadOnly ? "UISTR_YES" : "UISTR_NO"]);
wxString protection;
if (volumeInfo.Type == VolumeType::Hidden)
protection = LangString["NOT_APPLICABLE_OR_NOT_AVAILABLE"];
else if (volumeInfo.HiddenVolumeProtectionTriggered)
protection = LangString["HID_VOL_DAMAGE_PREVENTED"];
else
protection = LangString [volumeInfo.Protection == VolumeProtection::HiddenVolumeReadOnly ? "UISTR_YES" : "UISTR_NO"];
AppendToList ("HIDDEN_VOL_PROTECTION", protection);
AppendToList ("ENCRYPTION_ALGORITHM", volumeInfo.EncryptionAlgorithmName);
AppendToList ("KEY_SIZE", StringFormatter (L"{0} {1}", volumeInfo.EncryptionAlgorithmKeySize * 8, LangString ["BITS"]));
if (volumeInfo.EncryptionModeName == L"XTS")
AppendToList ("SECONDARY_KEY_SIZE_XTS", StringFormatter (L"{0} {1}", volumeInfo.EncryptionAlgorithmKeySize * 8, LangString ["BITS"]));
wstringstream blockSize;
blockSize << volumeInfo.EncryptionAlgorithmBlockSize * 8;
if (volumeInfo.EncryptionAlgorithmBlockSize != volumeInfo.EncryptionAlgorithmMinBlockSize)
blockSize << L"/" << volumeInfo.EncryptionAlgorithmMinBlockSize * 8;
AppendToList ("BLOCK_SIZE", blockSize.str() + L" " + LangString ["BITS"]);
AppendToList ("MODE_OF_OPERATION", volumeInfo.EncryptionModeName);
AppendToList ("PKCS5_PRF", volumeInfo.Pkcs5PrfName);
#if 0
AppendToList ("PKCS5_ITERATIONS", StringConverter::FromNumber (volumeInfo.Pkcs5IterationCount));
AppendToList ("VOLUME_CREATE_DATE", Gui->VolumeTimeToString (volumeInfo.VolumeCreationTime));
AppendToList ("VOLUME_HEADER_DATE", Gui->VolumeTimeToString (volumeInfo.HeaderCreationTime));
#endif
AppendToList ("VOLUME_FORMAT_VERSION", StringConverter::ToWide (volumeInfo.MinRequiredProgramVersion < 0x600 ? 1 : 2));
AppendToList ("BACKUP_HEADER", LangString[volumeInfo.MinRequiredProgramVersion >= 0x600 ? "UISTR_YES" : "UISTR_NO"]);
#ifdef TC_LINUX
if (string (volumeInfo.VirtualDevice).find ("/dev/mapper/truecrypt") != 0)
{
#endif
AppendToList ("TOTAL_DATA_READ", Gui->SizeToString (volumeInfo.TotalDataRead));
AppendToList ("TOTAL_DATA_WRITTEN", Gui->SizeToString (volumeInfo.TotalDataWritten));
#ifdef TC_LINUX
}
#endif
Layout();
Fit();
Center();
StdButtonsOK->SetDefault();
}
void VolumePropertiesDialog::AppendToList (const string &name, const wxString &value)
{
vector <wstring> fields (PropertiesListCtrl->GetColumnCount());
fields[0] = LangString[name];
fields[1] = value;
Gui->AppendToListCtrl (PropertiesListCtrl, fields);
}
}

View File

@@ -0,0 +1,26 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_VolumePropertiesDialog
#define TC_HEADER_Main_Forms_VolumePropertiesDialog
#include "Forms.h"
#include "Main/Main.h"
namespace TrueCrypt
{
class VolumePropertiesDialog : public VolumePropertiesDialogBase
{
public:
VolumePropertiesDialog (wxWindow* parent, const VolumeInfo &volumeInfo);
void AppendToList (const string &name, const wxString &value);
};
}
#endif // TC_HEADER_Main_Forms_VolumePropertiesDialog

View File

@@ -0,0 +1,137 @@
/*
Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "VolumeSizeWizardPage.h"
namespace TrueCrypt
{
VolumeSizeWizardPage::VolumeSizeWizardPage (wxPanel* parent, const VolumePath &volumePath, uint32 sectorSize, const wxString &freeSpaceText)
: VolumeSizeWizardPageBase (parent),
MaxVolumeSize (0),
MaxVolumeSizeValid (false),
MinVolumeSize (1),
SectorSize (sectorSize)
{
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->Select (Prefix::MB);
wxLongLong diskSpace = 0;
if (!wxGetDiskSpace (wxFileName (wstring (volumePath)).GetPath(), nullptr, &diskSpace))
{
VolumeSizeTextCtrl->Disable();
VolumeSizeTextCtrl->SetValue (L"");
}
FreeSpaceStaticText->SetFont (Gui->GetDefaultBoldFont (this));
if (!freeSpaceText.empty())
{
FreeSpaceStaticText->SetLabel (freeSpaceText);
}
else
{
#ifdef TC_WINDOWS
wxString drive = wxFileName (wstring (volumePath)).GetVolume();
if (!drive.empty())
{
FreeSpaceStaticText->SetLabel (StringFormatter (_("Free space on drive {0}: is {1}."),
drive, Gui->SizeToString (diskSpace.GetValue())));
}
else
#endif
{
FreeSpaceStaticText->SetLabel (StringFormatter (_("Free space available: {0}"),
Gui->SizeToString (diskSpace.GetValue())));
}
}
VolumeSizeTextCtrl->SetMinSize (wxSize (Gui->GetCharWidth (VolumeSizeTextCtrl) * 20, -1));
wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc.
const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" };
validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr));
VolumeSizeTextCtrl->SetValidator (validator);
}
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 = StringConverter::ToUInt64 (wstring (VolumeSizeTextCtrl->GetValue()));
if (val <= 0x7fffFFFFffffFFFFull / prefixMult)
{
val *= prefixMult;
uint32 sectorSizeRem = val % SectorSize;
if (sectorSizeRem != 0)
val += SectorSize - sectorSizeRem;
return val;
}
else
return 0;
}
bool VolumeSizeWizardPage::IsValid ()
{
if (!VolumeSizeTextCtrl->IsEmpty() && Validate())
{
try
{
if (GetVolumeSize() >= MinVolumeSize && (!MaxVolumeSizeValid || GetVolumeSize() <= MaxVolumeSize))
return true;
}
catch (...) { }
}
return false;
}
void VolumeSizeWizardPage::SetMaxStaticTextWidth (int width)
{
FreeSpaceStaticText->Wrap (width);
InfoStaticText->Wrap (width);
}
void VolumeSizeWizardPage::SetVolumeSize (uint64 size)
{
if (size == 0)
{
VolumeSizePrefixChoice->Select (Prefix::MB);
VolumeSizeTextCtrl->SetValue (L"");
return;
}
if (size % (1024 * 1024 * 1024) == 0)
{
size /= 1024 * 1024 * 1024;
VolumeSizePrefixChoice->Select (Prefix::GB);
}
else if (size % (1024 * 1024) == 0)
{
size /= 1024 * 1024;
VolumeSizePrefixChoice->Select (Prefix::MB);
}
else
{
size /= 1024;
VolumeSizePrefixChoice->Select (Prefix::KB);
}
VolumeSizeTextCtrl->SetValue (StringConverter::FromNumber (size));
}
}

View File

@@ -0,0 +1,51 @@
/*
Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_VolumeSizeWizardPage
#define TC_HEADER_Main_Forms_VolumeSizeWizardPage
#include "Forms.h"
namespace TrueCrypt
{
class VolumeSizeWizardPage : public VolumeSizeWizardPageBase
{
public:
VolumeSizeWizardPage (wxPanel* parent, const VolumePath &volumePath, uint32 sectorSize, const wxString &freeSpaceText = wxEmptyString);
uint64 GetVolumeSize () const;
bool IsValid ();
void SetMaxStaticTextWidth (int width);
void SetMaxVolumeSize (uint64 size) { MaxVolumeSize = size; MaxVolumeSizeValid = true; }
void SetMinVolumeSize (uint64 size) { MinVolumeSize = size; }
void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); }
void SetVolumeSize (uint64 size);
protected:
struct Prefix
{
enum
{
KB = 0,
MB,
GB
};
};
void OnBrowseButtonClick (wxCommandEvent& event);
void OnVolumeSizePrefixSelected (wxCommandEvent& event) { PageUpdatedEvent.Raise(); }
void OnVolumeSizeTextChanged (wxCommandEvent& event) { PageUpdatedEvent.Raise(); }
uint64 MaxVolumeSize;
bool MaxVolumeSizeValid;
uint64 MinVolumeSize;
uint32 SectorSize;
};
}
#endif // TC_HEADER_Main_Forms_VolumeSizeWizardPage

View File

@@ -0,0 +1,189 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "Main/Resources.h"
#include "WizardFrame.h"
namespace TrueCrypt
{
WizardFrame::WizardFrame (wxWindow* parent)
: WizardFrameBase (parent),
CurrentPage (nullptr),
CurrentStep (-1),
MaxStaticTextWidth (-1),
WorkInProgress (false)
{
SetIcon (Resources::GetTrueCryptIcon());
PageTitleStaticText->SetFont (wxFont (
#ifdef TC_WINDOWS
16
#elif defined(TC_MACOSX)
18
#elif defined(__WXGTK__)
14
#endif
* Gui->GetCharHeight (this) / 13, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, L"Times New Roman"));
UpdateControls();
this->SetDefaultItem (NextButton);
NextButton->SetFocus();
foreach (wxWindow *c, MainPanel->GetChildren())
c->Connect (wxEVT_MOTION, wxMouseEventHandler (WizardFrame::OnMouseMotion), nullptr, this);
}
WizardFrame::~WizardFrame ()
{
if (CurrentPage)
CurrentPage->Destroy();
}
void WizardFrame::ClearHistory ()
{
StepHistory.clear();
UpdateControls();
}
void WizardFrame::OnActivate (wxActivateEvent& event)
{
Gui->SetActiveFrame (this);
event.Skip();
}
void WizardFrame::OnClose (wxCloseEvent& event)
{
if (WorkInProgress)
return;
Gui->SetActiveFrame (nullptr);
event.Skip();
}
void WizardFrame::OnHelpButtonClick (wxCommandEvent& event)
{
Gui->OpenUserGuide (this);
}
void WizardFrame::OnNextButtonClick (wxCommandEvent& event)
{
if (CurrentPage->IsValid())
{
WizardStep nextStep = ProcessPageChangeRequest (true);
if (nextStep != CurrentStep)
SetStep (nextStep);
}
}
void WizardFrame::OnPreviousButtonClick (wxCommandEvent& event)
{
ProcessPageChangeRequest (false);
if (!StepHistory.empty())
{
WizardStep prevStep = *StepHistory.rbegin();
StepHistory.pop_back();
SetStep (prevStep, false);
}
}
void WizardFrame::SetCancelButtonText (const wxString &text)
{
CancelButton->SetLabel (text.empty() ? wxString (_("Cancel")) : text);
}
void WizardFrame::SetImage (const wxBitmap &bitmap)
{
WizardBitmap->SetBitmap (bitmap);
}
void WizardFrame::SetMaxStaticTextWidth (size_t charCount)
{
MaxStaticTextWidth = Gui->GetCharWidth (this) * charCount;
}
void WizardFrame::SetStep (WizardStep newStep)
{
SetStep (newStep, true);
}
void WizardFrame::SetStep (WizardStep newStep, bool forward)
{
bool init = false;
FreezeScope freeze (this);
#ifdef TC_WINDOWS
HelpButton->Disable(); // Prevent Help button from getting default focus
NextButton->Enable();
#endif
if (CurrentPage)
{
if (forward)
StepHistory.push_back (CurrentStep);
CurrentPage->OnPageChanging (forward);
CurrentPage->Destroy();
CurrentPage = nullptr;
}
else
init = true;
CurrentStep = newStep;
CurrentPage = GetPage (newStep);
CurrentPage->PageUpdatedEvent.Connect (EventConnector <WizardFrame> (this, &WizardFrame::OnPageUpdated));
CurrentPage->Connect (wxEVT_MOTION, wxMouseEventHandler (WizardFrame::OnMouseMotion), nullptr, this);
foreach (wxWindow *c, CurrentPage->GetChildren())
c->Connect (wxEVT_MOTION, wxMouseEventHandler (WizardFrame::OnMouseMotion), nullptr, this);
if (MaxStaticTextWidth > 0)
CurrentPage->SetMaxStaticTextWidth (MaxStaticTextWidth);
PageTitleStaticText->SetLabel (CurrentPage->GetPageTitle());
PageSizer->Add (CurrentPage, 1, wxALL | wxEXPAND);
if (init)
{
Fit();
Layout();
Center();
}
else
MainPanel->Layout();
CurrentPage->SetFocus();
wxString nextButtonText = CurrentPage->GetNextButtonText();
if (nextButtonText.empty())
NextButton->SetLabel (_("&Next >"));
else
NextButton->SetLabel (nextButtonText);
#ifdef TC_WINDOWS
HelpButton->Enable();
#endif
UpdateControls();
}
void WizardFrame::SetWorkInProgress (bool state)
{
WorkInProgress = state;
UpdateControls();
}
void WizardFrame::UpdateControls ()
{
CancelButton->Enable (!WorkInProgress);
HelpButton->Enable (!WorkInProgress);
NextButton->Enable (!WorkInProgress && CurrentPage != nullptr && CurrentPage->IsValid());
PreviousButton->Enable (!WorkInProgress && !StepHistory.empty());
}
}

View File

@@ -0,0 +1,58 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_WizardFrame
#define TC_HEADER_Main_Forms_WizardFrame
#include "Forms.h"
#include "Main/Main.h"
namespace TrueCrypt
{
class WizardFrame : public WizardFrameBase
{
public:
WizardFrame (wxWindow* parent);
virtual ~WizardFrame ();
protected:
typedef int WizardStep;
void ClearHistory ();
virtual WizardPage *GetPage (WizardStep step) = 0;
WizardPage *GetCurrentPage () const { return CurrentPage; }
WizardStep GetCurrentStep () const { return CurrentStep; }
wxPanel *GetPageParent () const { return MainPanel; }
bool IsWorkInProgress() const { return WorkInProgress; }
virtual void OnCancelButtonClick (wxCommandEvent& event) { Close(); }
virtual void OnClose (wxCloseEvent& event);
virtual void OnHelpButtonClick (wxCommandEvent& event);
virtual WizardStep ProcessPageChangeRequest (bool forward) = 0;
void SetCancelButtonText (const wxString &text);
void SetImage (const wxBitmap &bitmap);
void SetMaxStaticTextWidth (size_t charCount);
void SetStep (WizardStep newStep);
void SetWorkInProgress (bool state);
private:
void OnActivate (wxActivateEvent& event);
void OnNextButtonClick (wxCommandEvent& event);
void OnPageUpdated (EventArgs &args) { UpdateControls(); }
void OnPreviousButtonClick (wxCommandEvent& event);
void SetStep (WizardStep newStep, bool forward);
void UpdateControls ();
WizardPage *CurrentPage;
WizardStep CurrentStep;
int MaxStaticTextWidth;
list <WizardStep> StepHistory;
bool WorkInProgress;
};
}
#endif // TC_HEADER_Main_Forms_WizardFrame

View File

@@ -0,0 +1,41 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_Forms_WizardPage
#define TC_HEADER_Main_Forms_WizardPage
#include "Main/Main.h"
namespace TrueCrypt
{
class WizardPage : public wxPanel
{
public:
WizardPage (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
: wxPanel (parent, id, pos, size, style)
{ }
virtual ~WizardPage () { }
wxString GetPageTitle () const { return PageTitle; }
virtual bool IsValid () = 0;
virtual void OnPageChanging (bool forward) { }
wxString GetNextButtonText () const { return NextButtonText; }
void SetNextButtonText (const wxString &text) { NextButtonText = text; }
virtual void SetMaxStaticTextWidth (int width) { }
void SetPageTitle (const wxString &title) { PageTitle = title; }
virtual void SetPageText (const wxString &text) = 0;
Event PageUpdatedEvent;
protected:
wxString PageTitle;
wxString NextButtonText;
};
}
#endif // TC_HEADER_Main_Forms_WizardPage