VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount/Favorites.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mount/Favorites.cpp')
-rw-r--r--src/Mount/Favorites.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp
index a1a469bc..6fe871a0 100644
--- a/src/Mount/Favorites.cpp
+++ b/src/Mount/Favorites.cpp
@@ -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);