"Fossies" - the Fresh Open Source Software Archive

Member "src/Main/Forms/VolumePropertiesDialog.cpp" (10 Oct 2018, 4270 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "VolumePropertiesDialog.cpp" see the Fossies "Dox" file reference documentation.

    1 /*
    2  Derived from source code of TrueCrypt 7.1a, which is
    3  Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
    4  by the TrueCrypt License 3.0.
    5 
    6  Modifications and additions to the original source code (contained in this file)
    7  and all other portions of this file are Copyright (c) 2013-2017 IDRIX
    8  and are governed by the Apache License 2.0 the full text of which is
    9  contained in the file License.txt included in VeraCrypt binary and source
   10  code distribution packages.
   11 */
   12 
   13 #include "System.h"
   14 #include "Main/Main.h"
   15 #include "Main/GraphicUserInterface.h"
   16 #include "VolumePropertiesDialog.h"
   17 
   18 namespace VeraCrypt
   19 {
   20     VolumePropertiesDialog::VolumePropertiesDialog (wxWindow* parent, const VolumeInfo &volumeInfo)
   21         : VolumePropertiesDialogBase (parent)
   22     {
   23         list <int> colPermilles;
   24 
   25         PropertiesListCtrl->InsertColumn (0, LangString["PROPERTY"], wxLIST_FORMAT_LEFT, 208);
   26         colPermilles.push_back (500);
   27         PropertiesListCtrl->InsertColumn (1, LangString["VALUE"], wxLIST_FORMAT_LEFT, 192);
   28         colPermilles.push_back (500);
   29 
   30         Gui->SetListCtrlWidth (PropertiesListCtrl, 70, false);
   31         Gui->SetListCtrlHeight (PropertiesListCtrl, 17);
   32         Gui->SetListCtrlColumnWidths (PropertiesListCtrl, colPermilles, false);
   33 
   34         AppendToList ("LOCATION", wstring (volumeInfo.Path));
   35 #ifndef TC_WINDOWS
   36         AppendToList ("VIRTUAL_DEVICE", wstring (volumeInfo.VirtualDevice));
   37 #endif
   38         AppendToList ("SIZE", Gui->SizeToString (volumeInfo.Size));
   39         AppendToList ("TYPE", Gui->VolumeTypeToString (volumeInfo.Type, volumeInfo.TrueCryptMode, volumeInfo.Protection));
   40         AppendToList ("READ_ONLY", LangString [volumeInfo.Protection == VolumeProtection::ReadOnly ? "UISTR_YES" : "UISTR_NO"]);
   41 
   42         wxString protection;
   43         if (volumeInfo.Type == VolumeType::Hidden)
   44             protection = LangString["NOT_APPLICABLE_OR_NOT_AVAILABLE"];
   45         else if (volumeInfo.HiddenVolumeProtectionTriggered)
   46             protection = LangString["HID_VOL_DAMAGE_PREVENTED"];
   47         else
   48             protection = LangString [volumeInfo.Protection == VolumeProtection::HiddenVolumeReadOnly ? "UISTR_YES" : "UISTR_NO"];
   49 
   50         AppendToList ("HIDDEN_VOL_PROTECTION", protection);
   51         AppendToList ("ENCRYPTION_ALGORITHM", volumeInfo.EncryptionAlgorithmName);
   52         AppendToList ("KEY_SIZE", StringFormatter (L"{0} {1}", volumeInfo.EncryptionAlgorithmKeySize * 8, LangString ["BITS"]));
   53 
   54         if (volumeInfo.EncryptionModeName == L"XTS")
   55             AppendToList ("SECONDARY_KEY_SIZE_XTS", StringFormatter (L"{0} {1}", volumeInfo.EncryptionAlgorithmKeySize * 8, LangString ["BITS"]));
   56 
   57         wstringstream blockSize;
   58         blockSize << volumeInfo.EncryptionAlgorithmBlockSize * 8;
   59         if (volumeInfo.EncryptionAlgorithmBlockSize != volumeInfo.EncryptionAlgorithmMinBlockSize)
   60             blockSize << L"/" << volumeInfo.EncryptionAlgorithmMinBlockSize * 8;
   61 
   62         AppendToList ("BLOCK_SIZE", blockSize.str() + L" " + LangString ["BITS"]);
   63         AppendToList ("MODE_OF_OPERATION", volumeInfo.EncryptionModeName);
   64         if (volumeInfo.Pim <= 0)
   65             AppendToList ("PKCS5_PRF", volumeInfo.Pkcs5PrfName);
   66         else
   67             AppendToList ("PKCS5_PRF", StringFormatter (L"{0} (Dynamic)", volumeInfo.Pkcs5PrfName));
   68 
   69 #if 0
   70         AppendToList ("PKCS5_ITERATIONS", StringConverter::FromNumber (volumeInfo.Pkcs5IterationCount));
   71         AppendToList ("VOLUME_CREATE_DATE", Gui->VolumeTimeToString (volumeInfo.VolumeCreationTime));
   72         AppendToList ("VOLUME_HEADER_DATE", Gui->VolumeTimeToString (volumeInfo.HeaderCreationTime));
   73 #endif
   74 
   75         AppendToList ("VOLUME_FORMAT_VERSION", StringConverter::ToWide (volumeInfo.MinRequiredProgramVersion < 0x10b ? 1 : 2));
   76         AppendToList ("BACKUP_HEADER", LangString[volumeInfo.MinRequiredProgramVersion >= 0x10b ? "UISTR_YES" : "UISTR_NO"]);
   77 
   78 #ifdef TC_LINUX
   79         if (string (volumeInfo.VirtualDevice).find ("/dev/mapper/veracrypt") != 0)
   80         {
   81 #endif
   82         AppendToList ("TOTAL_DATA_READ", Gui->SizeToString (volumeInfo.TotalDataRead));
   83         AppendToList ("TOTAL_DATA_WRITTEN", Gui->SizeToString (volumeInfo.TotalDataWritten));
   84 #ifdef TC_LINUX
   85         }
   86 #endif
   87 
   88         Layout();
   89         Fit();
   90         Center();
   91 
   92         StdButtonsOK->SetDefault();
   93     }
   94 
   95     void VolumePropertiesDialog::AppendToList (const string &name, const wxString &value)
   96     {
   97         vector <wstring> fields (PropertiesListCtrl->GetColumnCount());
   98 
   99         fields[0] = LangString[name];
  100         fields[1] = value;
  101 
  102         Gui->AppendToListCtrl (PropertiesListCtrl, fields);
  103     }
  104 }