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

Windows: Add support for PIN in favorites. Several enhancements to GUI handling of Dynamic Mode.

This commit is contained in:
Mounir IDRASSI
2015-06-07 01:37:23 +02:00
parent 550e2bcf3b
commit c3c1bdd29d
13 changed files with 210 additions and 48 deletions

View File

@@ -13,6 +13,7 @@
#include "Dlgcode.h"
#include "Language.h"
#include "Mount.h"
#include "Common/Resource.h"
#include "Resource.h"
#include "Xml.h"
#include "Favorites.h"
@@ -86,6 +87,7 @@ namespace VeraCrypt
favorite.Removable = prop.removable ? true : false;
favorite.SystemEncryption = prop.partitionInInactiveSysEncScope ? true : false;
favorite.OpenExplorerWindow = (bExplore == TRUE);
favorite.Pin = prop.volumePin;
if (favorite.VolumePathId.empty()
&& IsVolumeDeviceHosted (favorite.Path.c_str())
@@ -547,6 +549,11 @@ namespace VeraCrypt
XmlGetAttributeText (xml, "label", label, sizeof (label));
favorite.Label = Utf8StringToWide (label);
XmlGetAttributeText (xml, "pin", label, sizeof (label));
favorite.Pin = strtol (label, NULL, 10);
if (favorite.Pin < 0)
favorite.Pin = 0;
char boolVal[2];
XmlGetAttributeText (xml, "readonly", boolVal, sizeof (boolVal));
if (boolVal[0])
@@ -676,6 +683,9 @@ namespace VeraCrypt
if (!favorite.Label.empty())
s += L" label=\"" + favorite.Label + L"\"";
if (favorite.Pin > 0)
s += L" pin=\"" + IntToWideString(favorite.Pin) + L"\"";
if (favorite.ReadOnly)
s += L" readonly=\"1\"";
@@ -763,6 +773,14 @@ namespace VeraCrypt
static void SetControls (HWND hwndDlg, const FavoriteVolume &favorite, bool systemFavoritesMode, bool enable)
{
if (favorite.Pin > 0)
{
char szTmp[MAX_PIN + 1];
StringCbPrintfA (szTmp, sizeof(szTmp), "%d", favorite.Pin);
SetDlgItemText (hwndDlg, IDC_PIN, szTmp);
}
else
SetDlgItemText (hwndDlg, IDC_PIN, "");
SetDlgItemTextW (hwndDlg, IDC_FAVORITE_LABEL, favorite.Label.c_str());
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_ON_LOGON, favorite.MountOnLogOn);
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_ON_ARRIVAL, favorite.MountOnArrival);
@@ -788,6 +806,9 @@ namespace VeraCrypt
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOVE_UP), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOVE_DOWN), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_REMOVE), enable);
EnableWindow (GetDlgItem (hwndDlg, IDT_PIN), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_PIN), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_PIN_HELP), enable);
EnableWindow (GetDlgItem (hwndDlg, IDT_FAVORITE_LABEL), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_LABEL), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOUNT_ON_LOGON), enable && !systemFavoritesMode);
@@ -815,6 +836,8 @@ namespace VeraCrypt
else
favorite.Label.clear();
favorite.Pin = GetPin (hwndDlg, IDC_PIN);
favorite.ReadOnly = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_READONLY) != 0);
favorite.Removable = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE) != 0);