"Fossies" - the Fresh Open Source Software Archive

Member "src/Main/Forms/MainFrame.h" (10 Oct 2018, 9447 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 "MainFrame.h" 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 #ifndef TC_HEADER_Main_Forms_MainFrame
   14 #define TC_HEADER_Main_Forms_MainFrame
   15 
   16 #include "Forms.h"
   17 #include "ChangePasswordDialog.h"
   18 
   19 namespace VeraCrypt
   20 {
   21     struct FavoriteVolume;
   22 
   23     DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_UPDATE_VOLUME_LIST, -1);
   24     DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_PREF_UPDATED, -1);
   25     DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_OPEN_VOLUME_REQUEST, -1);
   26 
   27     class MainFrame : public MainFrameBase
   28     {
   29     public:
   30         MainFrame (wxWindow* parent);
   31         virtual ~MainFrame ();
   32 
   33         void OnDeviceChange (const DirectoryPath &mountPoint = DirectoryPath());
   34 #ifdef TC_UNIX
   35         static FilePath GetShowRequestFifoPath () { return Application::GetConfigFilePath (L".show-request-queue", true); }
   36 #endif
   37 
   38     protected:
   39         enum
   40         {
   41             ColumnSlot = 0,
   42             ColumnPath,
   43             ColumnSize,
   44 #ifdef TC_WINDOWS
   45             ColumnEA,
   46 #else
   47             ColumnMountPoint,
   48 #endif
   49             ColumnType
   50         };
   51 
   52         void AddToFavorites (const VolumeInfoList &volumes);
   53         bool CanExit () const;
   54         void ChangePassword (ChangePasswordDialog::Mode::Enum mode = ChangePasswordDialog::Mode::ChangePasswordAndKeyfiles);
   55         void CheckFilesystem (bool repair = false);
   56         bool CheckVolumePathNotEmpty () const;
   57         void DismountVolume (shared_ptr <VolumeInfo> volume = shared_ptr <VolumeInfo> ());
   58         const UserPreferences &GetPreferences () const { return Gui->GetPreferences(); }
   59         shared_ptr <VolumeInfo> GetSelectedVolume () const;
   60         shared_ptr <VolumePath> GetSelectedVolumePath () const { return make_shared <VolumePath> (wstring (VolumePathComboBox->GetValue())); }
   61         void InitControls ();
   62         void InitEvents ();
   63         void InitMessageFilter ();
   64         void InitPreferences ();
   65         void InitTaskBarIcon ();
   66         bool IsFreeSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); }
   67         bool IsMountedSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && !Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); }
   68         void LoadFavoriteVolumes ();
   69         void LoadPreferences ();
   70         void MountAllDevices ();
   71         void MountAllFavorites ();
   72         void MountVolume ();
   73         void OnAboutMenuItemSelected (wxCommandEvent& event);
   74         void OnQuit(wxCommandEvent& event) { Close(true); }
   75         void OnActivate (wxActivateEvent& event);
   76         void OnAddAllMountedToFavoritesMenuItemSelected (wxCommandEvent& event);
   77         void OnAddToFavoritesMenuItemSelected (wxCommandEvent& event);
   78         void OnBackupVolumeHeadersMenuItemSelected (wxCommandEvent& event);
   79         void OnBeginnersTutorialMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"tutorial"); }
   80         void OnBenchmarkMenuItemSelected (wxCommandEvent& event);
   81         void OnChangeKeyfilesMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::ChangeKeyfiles); }
   82         void OnChangePasswordMenuItemSelected (wxCommandEvent& event) { ChangePassword (); }
   83         void OnChangePkcs5PrfMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::ChangePkcs5Prf); }
   84         void OnCheckFilesystemMenuItemSelected( wxCommandEvent& event ) { CheckFilesystem (); }
   85         void OnClearSlotSelectionMenuItemSelected (wxCommandEvent& event);
   86         void OnClose (wxCloseEvent& event);
   87         void OnCloseAllSecurityTokenSessionsMenuItemSelected (wxCommandEvent& event);
   88         void OnDonateMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"donate"); }
   89         void OnContactMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"contact"); }
   90         void OnCreateKeyfileMenuItemSelected (wxCommandEvent& event)
   91         {
   92 #ifdef TC_MACOSX
   93             if (Gui->IsInBackgroundMode())
   94                 Gui->SetBackgroundMode (false);
   95 #endif
   96             Gui->CreateKeyfile();
   97         }
   98         void OnCreateVolumeButtonClick (wxCommandEvent& event);
   99         void OnDefaultKeyfilesMenuItemSelected (wxCommandEvent& event);
  100         void OnDefaultMountParametersMenuItemSelected( wxCommandEvent& event );
  101         void OnDismountAllButtonClick (wxCommandEvent& event);
  102         void OnDismountVolumeMenuItemSelected (wxCommandEvent& event) { DismountVolume(); }
  103         void OnDownloadsMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"downloads"); }
  104         void OnEncryptionTestMenuItemSelected (wxCommandEvent& event);
  105         void OnExitButtonClick (wxCommandEvent& event);
  106         void OnFavoriteVolumeMenuItemSelected (wxCommandEvent& event);
  107         void OnFaqMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"faq"); }
  108         void OnHiddenVolumeProtectionTriggered (shared_ptr <VolumeInfo> protectedVolume);
  109         void OnHotkey (wxKeyEvent& event);
  110         void OnHotkeysMenuItemSelected (wxCommandEvent& event);
  111         void OnLegalNoticesMenuItemSelected (wxCommandEvent& event);
  112         void OnListChanged ();
  113         void OnListItemActivated (wxListEvent& event);
  114         void OnListItemDeleted (long itemIndex);
  115         void OnListItemDeselected (wxListEvent& event);
  116         void OnListItemInserted (long itemIndex);
  117         void OnListItemRightClick (wxListEvent& event);
  118         void OnListItemSelected (wxListEvent& event);
  119         void OnListItemSelectionChanged ();
  120         void OnLogoBitmapClick (wxMouseEvent &event) { wxCommandEvent ev; OnAboutMenuItemSelected (ev); }
  121         void OnManageSecurityTokenKeyfilesMenuItemSelected (wxCommandEvent& event);
  122         void OnMountAllDevicesButtonClick (wxCommandEvent& event);
  123         void OnMountAllFavoritesMenuItemSelected (wxCommandEvent& event);
  124         void OnMountVolumeMenuItemSelected (wxCommandEvent& event) { MountVolume(); }
  125         void OnNewsMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"news"); }
  126         void OnNoHistoryCheckBoxClick (wxCommandEvent& event);
  127         void OnOnlineHelpMenuItemSelected (wxCommandEvent& event) { Gui->OpenOnlineHelp (this); }
  128         void OnOpenVolumeMenuItemSelected (wxCommandEvent& event) { OpenSelectedVolume(); }
  129         void OnOpenVolumeSystemRequest (wxCommandEvent& event);
  130         void OnOpenVolumeSystemRequestEvent (EventArgs &args);
  131         void OnOrganizeFavoritesMenuItemSelected (wxCommandEvent& event);
  132         void OnPreferencesMenuItemSelected (wxCommandEvent& event);
  133         void OnPreferencesUpdated (wxCommandEvent& event);
  134         void OnPreferencesUpdatedEvent (EventArgs &args) { wxQueueEvent (this, new wxCommandEvent( wxEVT_COMMAND_PREF_UPDATED,0)); }
  135         void OnRemoveKeyfilesMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::RemoveAllKeyfiles); }
  136         void OnRepairFilesystemMenuItemSelected( wxCommandEvent& event ) { CheckFilesystem (true); }
  137         void OnRestoreVolumeHeaderMenuItemSelected (wxCommandEvent& event);
  138         void OnSecurityTokenPreferencesMenuItemSelected (wxCommandEvent& event);
  139         void OnSelectDeviceAndMountMenuItemSelected (wxCommandEvent& event);
  140         void OnSelectDeviceButtonClick (wxCommandEvent& event);
  141         void OnSelectFileAndMountMenuItemSelected (wxCommandEvent& event);
  142         void OnSelectFileButtonClick (wxCommandEvent& event);
  143         void OnTimer ();
  144         void OnVersionHistoryMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"history"); }
  145         void OnVolumePropertiesButtonClick (wxCommandEvent& event);
  146         void OnVolumeToolsButtonClick (wxCommandEvent& event);
  147         void OnVolumeButtonClick (wxCommandEvent& event);
  148         void OnUpdateVolumeList (wxCommandEvent& event) { UpdateVolumeList(); }
  149         void OnVolumeDismounted (EventArgs &args) { wxQueueEvent (this, new wxCommandEvent( wxEVT_COMMAND_UPDATE_VOLUME_LIST,0)); }
  150         void OnVolumeMounted (EventArgs &args) { wxQueueEvent (this, new wxCommandEvent( wxEVT_COMMAND_UPDATE_VOLUME_LIST,0)); }
  151         void OnUserGuideMenuItemSelected (wxCommandEvent& event) { Gui->OpenUserGuide (this); }
  152         void OnWebsiteMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"website"); }
  153         void OnWipeCacheButtonClick (wxCommandEvent& event);
  154         void OrganizeFavorites (const FavoriteVolumeList &favorites, size_t newItemCount = 0);
  155         void OpenSelectedVolume () const;
  156         void SavePreferences () const;
  157         long SlotNumberToItemIndex (uint32 slotNumber) const;
  158         void SetVolumePath (const VolumePath &path) { VolumePathComboBox->SetValue (wstring (path)); }
  159         void ShowTaskBarIcon (bool show = true);
  160         void UpdateControls ();
  161         void UpdateVolumeList ();
  162         void UpdateWipeCacheButton ();
  163         void WipeCache ();
  164 
  165         struct VolumeActivityMapEntry
  166         {
  167             VolumeActivityMapEntry () { }
  168 
  169             VolumeActivityMapEntry (const VolumeInfo &volume, wxLongLong lastActivityTime)
  170                 : LastActivityTime (lastActivityTime),
  171                 SerialInstanceNumber (volume.SerialInstanceNumber),
  172                 TotalDataRead (volume.TotalDataRead),
  173                 TotalDataWritten (volume.TotalDataWritten)
  174             { }
  175 
  176             wxLongLong LastActivityTime;
  177             uint64 SerialInstanceNumber;
  178             uint64 TotalDataRead;
  179             uint64 TotalDataWritten;
  180         };
  181 
  182         map <int, FavoriteVolume> FavoriteVolumesMenuMap;
  183         bool ListItemRightClickEventPending;
  184         VolumeInfoList MountedVolumes;
  185         auto_ptr <wxTaskBarIcon> mTaskBarIcon;
  186         auto_ptr <wxTimer> mTimer;
  187         long SelectedItemIndex;
  188         VolumeSlotNumber SelectedSlotNumber;
  189         int ShowRequestFifo;
  190         map <wstring, VolumeActivityMapEntry> VolumeActivityMap;
  191     };
  192 }
  193 
  194 #endif // TC_HEADER_Main_Forms_MainFrame