VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Core
AgeCommit message (Expand)AuthorFilesLines
2016-08-15Linux/MacOSX: Similar fix to Windows one. Write fake hidden volume header tha...Mounir IDRASSI1-6/+57
2016-05-10Remove trailing whitespaceDavid Foerster39-116/+116
2016-05-01Reset bogus executable permissionsDavid Foerster1-0/+0
2016-02-22Linux: fix compilation errorMounir IDRASSI1-1/+0
2016-02-22Linux: fix mount issue on Fedora 23 by forcing the creation of a default loop...Mounir IDRASSI1-0/+11
2016-02-21MacOSX: Correctly detect newer versions of OSXFuseMounir IDRASSI1-10/+12
2016-01-27Windows/Linux: Implement exFAT support.Mounir IDRASSI1-0/+1
2016-01-20Copyright: update dates to include 2016.Mounir IDRASSI39-39/+39
2015-08-06Update license information to reflect the use of a dual license Apache 2.0 an...Mounir IDRASSI39-183/+337
2015-07-04Linux: Support checking/reparing mounted filesystem on KDE when xterm not ava...Mounir IDRASSI1-0/+25
2015-06-24Linux/MacOSX: restore normal file mode to some source filesMounir IDRASSI8-0/+0
2015-06-24Linux/MacOSX: first dynamic mode implementationMounir IDRASSI8-27/+48
2015-03-23Linux: solve mount point permission issues for some users where the non-FAT v...Mounir IDRASSI1-0/+17
2014-12-30Linux/MacOSX: Implement TrueCrypt conversion and loading support. Correct man...Mounir IDRASSI6-40/+63
2014-12-26Linux/MacOSX: Implement waiting dialog for lengthy operations in order to hav...Mounir IDRASSI2-0/+133
2014-12-19Linux/MacOSX: Enhance performance by implementing the possibility to choose t...Mounir IDRASSI5-6/+45
2014-12-11Linux/MacOSX: Implement generating more than one keyfile, specifying the size...Mounir IDRASSI2-24/+42
2014-11-08MacOSX : Support hard drives with a large sector size ( > 512).Mounir IDRASSI1-1/+1
2014-11-08MacOSX : Support detection of OSXFUSE and the presence of MacFUSE compatibili...Mounir IDRASSI1-3/+29
2014-11-08Linux/MacOSX port of manual selection of number of passes for volume header o...Mounir IDRASSI2-8/+7
2014-11-08Remove remaining legacy cryptographic algorithms that are never used by VeraC...Mounir IDRASSI1-6/+1
2014-11-08Change namespace from TrueCrypt to VeraCrypt. Rename method from Resources Re...Mounir IDRASSI33-33/+33
2014-11-08Replace TrueCrypt from Linux/MacOSX mount point namesMounir IDRASSI2-3/+3
2014-11-08Replace TrueCrypt references in added sources and resources by VeraCrypt ones.Mounir IDRASSI4-6/+6
2014-11-08Add TrueCrypt 7.1a MacOSX/Linux specific source files.Mounir IDRASSI39-0/+5300
ex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 Derived from source code of TrueCrypt 7.1a, which is
 Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
 by the TrueCrypt License 3.0.

 Modifications and additions to the original source code (contained in this file)
 and all other portions of this file are Copyright (c) 2013-2017 IDRIX
 and are governed by the Apache License 2.0 the full text of which is
 contained in the file License.txt included in VeraCrypt binary and source
 code distribution packages.
*/

#include "System.h"
#include "Main/GraphicUserInterface.h"
#include "Main/Resources.h"
#include "DeviceSelectionDialog.h"

namespace VeraCrypt
{
	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)
		{
			vector <wstring> fields (DeviceListCtrl->GetColumnCount());
			
			if (DeviceListCtrl->GetItemCount() > 0)
				Gui->AppendToListCtrl (DeviceListCtrl, fields);
			
			//	i.e. /dev/rdisk0 might have size = 0 in case open() fails because, for example on OSX, 
			//	SIP is enabled on the machine ; 
			//	This does not mean that it does not have partitions that have been successfully opened
			//	and have a size != 0 ;
			//	Therefore, we do not show the device ONLY if it does not have partitions with size != 0 ;
			if (device.Size == 0)
			{
				bool bHasNonEmptyPartition = false;
				foreach_ref (HostDevice &partition, device.Partitions)
				{
					if (partition.Size)
					{
						bHasNonEmptyPartition = true;
						break;
					}
				}
				
				if (!bHasNonEmptyPartition)
					continue;
			}

#ifdef TC_WINDOWS
			fields[ColumnDevice] = StringFormatter (L"{0} {1}:", LangString["HARDDISK"], device.SystemNumber);
			fields[ColumnDrive] = device.MountPoint;
			fields[ColumnName] = device.Name;
#else
			fields[ColumnDevice] = wstring (device.Path) + L":";
			fields[ColumnMountPoint] = device.MountPoint;
#endif
			//	If the size of the device is 0, we do not show the size to avoid confusing the user ;
			if (device.Size)
				fields[ColumnSize] = Gui->SizeToString (device.Size);
			else
				fields[ColumnSize] = L"";
			Gui->AppendToListCtrl (DeviceListCtrl, fields, 0, &device);

			foreach_ref (HostDevice &partition, device.Partitions)
			{
				//	If a partition's size is 0, there is no need to show it in the list 
				//	since this means it is not usable (i.e on OSX, because of SIP enabled in the machine) ;
				if (!partition.Size)
					continue;

				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();
		OKButton->Disable();
		OKButton->SetDefault();
	}

	void DeviceSelectionDialog::OnListItemActivated (wxListEvent& event)
	{
		if (OKButton->IsEnabled())
			EndModal (wxID_OK);
	}

	void DeviceSelectionDialog::OnListItemDeselected (wxListEvent& event)
	{
		if (DeviceListCtrl->GetSelectedItemCount() == 0)
			OKButton->Disable();
	}

	void DeviceSelectionDialog::OnListItemSelected (wxListEvent& event)
	{
		HostDevice *device = (HostDevice *) (event.GetItem().GetData());
		//	If a device's size is 0, we do not enable the 'OK' button since it is not usable
		if (device && device->Size)
		{
			SelectedDevice = *device;
			OKButton->Enable();
		}
		else
			OKButton->Disable();
	}
}