|
|
1.1 root 1: /*
2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
3:
4: Governed by the TrueCrypt License 2.4 the full text of which is contained
5: in the file License.txt included in TrueCrypt binary and source code
6: distribution packages.
7: */
8:
9: #ifndef TC_HEADER_Main_Forms_MainFrame
10: #define TC_HEADER_Main_Forms_MainFrame
11:
12: #include "Forms.h"
13: #include "ChangePasswordDialog.h"
14:
15: namespace TrueCrypt
16: {
17: struct FavoriteVolume;
18:
19: class MainFrame : public MainFrameBase
20: {
21: public:
22: MainFrame (wxWindow* parent);
23: virtual ~MainFrame ();
24:
25: void OnDeviceChange (const DirectoryPath &mountPoint = DirectoryPath());
26:
27: protected:
28: enum
29: {
30: ColumnSlot = 0,
31: ColumnPath,
32: ColumnSize,
33: #ifdef TC_WINDOWS
34: ColumnEA,
35: #else
36: ColumnMountPoint,
37: #endif
38: ColumnType
39: };
40:
41: void AddToFavorites (const VolumeInfoList &volumes);
42: bool CanExit () const;
43: void ChangePassword (ChangePasswordDialog::Mode::Enum mode = ChangePasswordDialog::Mode::ChangePasswordAndKeyfiles);
44: void CheckFilesystem (bool repair = false);
45: bool CheckVolumePathNotEmpty () const;
46: void DismountVolume (shared_ptr <VolumeInfo> volume = shared_ptr <VolumeInfo> ());
47: const UserPreferences &GetPreferences () const { return Gui->GetPreferences(); }
48: shared_ptr <VolumeInfo> GetSelectedVolume () const;
49: shared_ptr <VolumePath> GetSelectedVolumePath () const { return make_shared <VolumePath> (wstring (VolumePathComboBox->GetValue())); }
50: void InitControls ();
51: void InitEvents ();
52: void InitMessageFilter ();
53: void InitPreferences ();
54: void InitTaskBarIcon ();
55: bool IsFreeSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); }
56: bool IsMountedSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && !Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); }
57: void LoadFavoriteVolumes ();
58: void LoadPreferences ();
59: void MountAllDevices ();
60: void MountAllFavorites ();
61: void MountVolume ();
62: void OnAboutMenuItemSelected (wxCommandEvent& event);
63: void OnActivate (wxActivateEvent& event);
64: void OnAddAllMountedToFavoritesMenuItemSelected (wxCommandEvent& event);
65: void OnAddToFavoritesMenuItemSelected (wxCommandEvent& event);
66: void OnBackupVolumeHeadersMenuItemSelected (wxCommandEvent& event);
67: void OnBeginnersTutorialMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"tutorial"); }
68: void OnChangeKeyfilesMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::ChangeKeyfiles); }
69: void OnChangePasswordMenuItemSelected (wxCommandEvent& event) { ChangePassword (); }
70: void OnChangePkcs5PrfMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::ChangePkcs5Prf); }
71: void OnCheckFilesystemMenuItemSelected( wxCommandEvent& event ) { CheckFilesystem (); }
72: void OnClearSlotSelectionMenuItemSelected (wxCommandEvent& event);
73: void OnClose (wxCloseEvent& event);
74: void OnContactMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"contact"); }
75: void OnCreateVolumeButtonClick (wxCommandEvent& event);
76: void OnDefaultKeyfilesMenuItemSelected (wxCommandEvent& event);
77: void OnDismountAllButtonClick (wxCommandEvent& event);
78: void OnDismountVolumeMenuItemSelected (wxCommandEvent& event) { DismountVolume(); }
79: void OnDonationsMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"donations"); }
80: void OnDownloadsMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"downloads"); }
81: void OnEncryptionTestMenuItemSelected (wxCommandEvent& event);
82: void OnExitButtonClick (wxCommandEvent& event);
83: void OnFavoriteVolumeMenuItemSelected (wxCommandEvent& event);
84: void OnFaqMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"faq"); }
85: void OnForumsMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"forum"); }
86: void OnHiddenVolumeProtectionTriggered (shared_ptr <VolumeInfo> protectedVolume);
87: void OnHotkey (wxKeyEvent& event);
88: void OnHotkeysMenuItemSelected (wxCommandEvent& event);
89: void OnLegalNoticesMenuItemSelected (wxCommandEvent& event);
90: void OnListChanged ();
91: void OnListItemActivated (wxListEvent& event);
92: void OnListItemDeleted (long itemIndex);
93: void OnListItemDeselected (wxListEvent& event);
94: void OnListItemInserted (long itemIndex);
95: void OnListItemRightClick (wxListEvent& event);
96: void OnListItemSelected (wxListEvent& event);
97: void OnListItemSelectionChanged ();
98: void OnLogoBitmapClick (wxMouseEvent &event) { wxCommandEvent ev; OnAboutMenuItemSelected (ev); }
99: void OnMountAllDevicesButtonClick (wxCommandEvent& event);
100: void OnMountAllFavoritesMenuItemSelected (wxCommandEvent& event);
101: void OnMountVolumeMenuItemSelected (wxCommandEvent& event) { MountVolume(); }
102: void OnNewsMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"news"); }
103: void OnNoHistoryCheckBoxClick (wxCommandEvent& event);
104: void OnOnlineHelpMenuItemSelected (wxCommandEvent& event) { Gui->OpenOnlineHelp (this); }
105: void OnOpenVolumeMenuItemSelected (wxCommandEvent& event) { OpenSelectedVolume(); }
106: void OnOrganizeFavoritesMenuItemSelected (wxCommandEvent& event);
107: void OnPreferencesMenuItemSelected (wxCommandEvent& event);
108: void OnPreferencesUpdated (EventArgs &args);
109: void OnRemoveKeyfilesMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::RemoveAllKeyfiles); }
110: void OnRepairFilesystemMenuItemSelected( wxCommandEvent& event ) { CheckFilesystem (true); }
111: void OnReportBugMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"bugreport"); }
112: void OnRestoreVolumeHeaderMenuItemSelected (wxCommandEvent& event);
113: void OnSelectDeviceButtonClick (wxCommandEvent& event);
114: void OnSelectFileButtonClick (wxCommandEvent& event);
115: void OnTimer ();
116: void OnTravelerDiskWizardMenuItemSelected (wxCommandEvent& event);
117: void OnVersionHistoryMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"history"); }
118: void OnVolumePropertiesButtonClick (wxCommandEvent& event);
119: void OnVolumeToolsButtonClick (wxCommandEvent& event);
120: void OnVolumeButtonClick (wxCommandEvent& event);
121: void OnVolumeDismounted (EventArgs &args) { UpdateVolumeList(); }
122: void OnVolumeMounted (EventArgs &args) { UpdateVolumeList(); }
123: void OnUserGuideMenuItemSelected (wxCommandEvent& event) { Gui->OpenUserGuide (this); }
124: void OnWebsiteMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"website"); }
125: void OnWipeCacheButtonClick (wxCommandEvent& event);
126: void OrganizeFavorites (const FavoriteVolumeList &favorites, size_t newItemCount = 0);
127: void OpenSelectedVolume () const;
128: void SavePreferences () const;
129: long SlotNumberToItemIndex (uint32 slotNumber) const;
130: void SetVolumePath (const VolumePath &path) { VolumePathComboBox->SetValue (wstring (path)); }
131: void ShowTaskBarIcon (bool show = true);
132: void UpdateControls ();
133: void UpdateVolumeList ();
134: void UpdateWipeCacheButton ();
135: void WipeCache ();
136:
137: struct VolumeActivityMapEntry
138: {
139: VolumeActivityMapEntry () { }
140:
141: VolumeActivityMapEntry (const VolumeInfo &volume, wxLongLong lastActivityTime)
142: : LastActivityTime (lastActivityTime),
143: SerialInstanceNumber (volume.SerialInstanceNumber),
144: TotalDataRead (volume.TotalDataRead),
145: TotalDataWritten (volume.TotalDataWritten)
146: { }
147:
148: wxLongLong LastActivityTime;
149: uint64 SerialInstanceNumber;
150: uint64 TotalDataRead;
151: uint64 TotalDataWritten;
152: };
153:
154: map <int, FavoriteVolume> FavoriteVolumesMenuMap;
155: VolumeInfoList MountedVolumes;
156: auto_ptr <wxTaskBarIcon> mTaskBarIcon;
157: auto_ptr <wxTimer> mTimer;
158: long SelectedItemIndex;
159: VolumeSlotNumber SelectedSlotNumber;
160: map <wstring, VolumeActivityMapEntry> VolumeActivityMap;
161: };
162: }
163:
164: #endif // TC_HEADER_Main_Forms_MainFrame
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.