VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Volume/EncryptionModeXTS.cpp
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2019-02-13 17:13:55 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2019-02-15 00:17:11 +0100
commit29b749bdd96668d1aa9259b70be436e807b46af2 (patch)
treef170fbd253d5206b02f66469457bd5e0a500d230 /src/Volume/EncryptionModeXTS.cpp
parentadf97533d315a939393f12067e1d2a655b076bf0 (diff)
downloadVeraCrypt-29b749bdd96668d1aa9259b70be436e807b46af2.tar.gz
VeraCrypt-29b749bdd96668d1aa9259b70be436e807b46af2.zip
Windows: rename IsCpuRngSupport to IsCpuRngSupported for clarity and use it in Mount.c
Diffstat (limited to 'src/Volume/EncryptionModeXTS.cpp')
0 files changed, 0 insertions, 0 deletions
/a> 117 118 119 120 121 122
/*
 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 "FavoriteVolumesDialog.h"

namespace VeraCrypt
{
	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);
	}
}