1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
/*
Copyright (c) 2008-2009 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_HEADER_Main_GraphicUserInterface
#define TC_HEADER_Main_GraphicUserInterface
#include "System.h"
#include <utility>
#include "Main.h"
#include "UserInterface.h"
#include "Forms/WaitDialog.h"
namespace VeraCrypt
{
class GraphicUserInterface : public UserInterface
{
public:
GraphicUserInterface ();
virtual ~GraphicUserInterface ();
virtual void AppendToListCtrl (wxListCtrl *listCtrl, const vector <wstring> &itemFields, int imageIndex = -1, void *itemDataPtr = nullptr) const;
virtual wxMenuItem *AppendToMenu (wxMenu &menu, const wxString &label, wxEvtHandler *handler = nullptr, wxObjectEventFunction handlerFunction = nullptr, int itemId = wxID_ANY) const;
virtual bool AskYesNo (const wxString &message, bool defaultYes = false, bool warning = false) const;
virtual void AutoDismountVolumes (VolumeInfoList mountedVolumes, bool alwaysForce = true);
virtual void BackupVolumeHeaders (shared_ptr <VolumePath> volumePath) const;
virtual void BeginBusyState () const { wxBeginBusyCursor(); }
virtual void BeginInteractiveBusyState (wxWindow *window);
virtual void ChangePassword (shared_ptr <VolumePath> volumePath = shared_ptr <VolumePath>(), shared_ptr <VolumePassword> password = shared_ptr <VolumePassword>(), int pim = 0, shared_ptr <Hash> currentHash = shared_ptr <Hash>(), bool truecryptMode = false, shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList>(), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword>(), int newPim = 0, shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList>(), shared_ptr <Hash> newHash = shared_ptr <Hash>()) const { ThrowTextModeRequired(); }
wxHyperlinkCtrl *CreateHyperlink (wxWindow *parent, const wxString &linkUrl, const wxString &linkText) const;
virtual void CreateKeyfile (shared_ptr <FilePath> keyfilePath = shared_ptr <FilePath>()) const;
virtual void CreateVolume (shared_ptr <VolumeCreationOptions> options) const { ThrowTextModeRequired(); }
virtual void ClearListCtrlSelection (wxListCtrl *listCtrl) const;
virtual void DeleteSecurityTokenKeyfiles () const { ThrowTextModeRequired(); }
virtual void DoShowError (const wxString &message) const;
virtual void DoShowInfo (const wxString &message) const;
virtual void DoShowString (const wxString &str) const;
virtual void DoShowWarning (const wxString &message) const;
virtual void EndBusyState () const { wxEndBusyCursor(); }
virtual void EndInteractiveBusyState (wxWindow *window) const;
virtual void ExportSecurityTokenKeyfile () const { ThrowTextModeRequired(); }
virtual wxTopLevelWindow *GetActiveWindow () const;
virtual shared_ptr <GetStringFunctor> GetAdminPasswordRequestHandler ();
virtual int GetCharHeight (wxWindow *window) const;
virtual int GetCharWidth (wxWindow *window) const;
virtual int GetDefaultBorderSize () const { return 5; }
virtual wxFont GetDefaultBoldFont (wxWindow *window) const;
virtual wxString GetHomepageLinkURL (const wxString &linkId, bool secure = false, const wxString &extraVars = wxEmptyString) const;
virtual wxFrame *GetMainFrame () const { return mMainFrame; }
virtual int GetScrollbarWidth (wxWindow *window, bool noScrollBar = false) const;
virtual list <long> GetListCtrlSelectedItems (wxListCtrl *listCtrl) const;
virtual wxString GetListCtrlSubItemText (wxListCtrl *listCtrl, long itemIndex, int columnIndex) const;
virtual void ImportSecurityTokenKeyfiles () const { ThrowTextModeRequired(); }
virtual void InitSecurityTokenLibrary () const;
virtual void InsertToListCtrl (wxListCtrl *listCtrl, long itemIndex, const vector <wstring> &itemFields, int imageIndex = -1, void *itemDataPtr = nullptr) const;
virtual bool IsInBackgroundMode () const { return BackgroundMode; }
virtual bool IsTheOnlyTopLevelWindow (const wxWindow *window) const;
virtual void ListSecurityTokenKeyfiles () const;
virtual VolumeInfoList MountAllDeviceHostedVolumes (MountOptions &options) const;
virtual shared_ptr <VolumeInfo> MountVolume (MountOptions &options) const;
virtual void MoveListCtrlItem (wxListCtrl *listCtrl, long itemIndex, long newItemIndex) const;
virtual void OnAutoDismountAllEvent ();
virtual bool OnInit ();
virtual void OnLogOff ();
virtual void OpenDocument (wxWindow *parent, const wxFileName &document);
virtual void OpenHomepageLink (wxWindow *parent, const wxString &linkId, const wxString &extraVars = wxEmptyString);
virtual void OpenOnlineHelp (wxWindow *parent);
virtual void OpenUserGuide (wxWindow *parent);
virtual void RestoreVolumeHeaders (shared_ptr <VolumePath> volumePath) const;
virtual DevicePath SelectDevice (wxWindow *parent) const;
virtual DirectoryPath SelectDirectory (wxWindow *parent, const wxString &message = wxEmptyString, bool existingOnly = true) const;
virtual FilePathList SelectFiles (wxWindow *parent, const wxString &caption, bool saveMode = false, bool allowMultiple = false, const list < pair <wstring, wstring> > &fileExtensions = (list < pair <wstring, wstring> > ()), const DirectoryPath &directory = DirectoryPath()) const;
virtual FilePath SelectVolumeFile (wxWindow *parent, bool saveMode = false, const DirectoryPath &directory = DirectoryPath()) const;
virtual void SetActiveFrame (wxFrame *frame) { ActiveFrame = frame; }
virtual void SetBackgroundMode (bool state);
virtual void SetListCtrlColumnWidths (wxListCtrl *listCtrl, list <int> columnWidthPermilles, bool hasVerticalScrollbar = true) const;
virtual void SetListCtrlHeight (wxListCtrl *listCtrl, size_t rowCount) const;
virtual void SetListCtrlWidth (wxListCtrl *listCtrl, size_t charCount, bool hasVerticalScrollbar = true) const;
virtual void ShowErrorTopMost (char *langStringId) const { ShowErrorTopMost (LangString[langStringId]); }
virtual void ShowErrorTopMost (const wxString &message) const;
virtual void ShowInfoTopMost (char *langStringId) const { ShowInfoTopMost (LangString[langStringId]); }
virtual void ShowInfoTopMost (const wxString &message) const;
virtual void ShowWarningTopMost (char *langStringId) const { ShowWarningTopMost (LangString[langStringId]); }
virtual void ShowWarningTopMost (const wxString &message) const;
virtual bool UpdateListCtrlItem (wxListCtrl *listCtrl, long itemIndex, const vector <wstring> &itemFields) const;
virtual void UserEnrichRandomPool (wxWindow *parent, shared_ptr <Hash> hash = shared_ptr <Hash>()) const;
virtual void Yield () const;
virtual shared_ptr <VolumeInfo> MountVolumeThread (MountOptions &options) const;
WaitDialog* GetWaitDialog () { return mWaitDialog; }
void ExecuteWaitThreadRoutine (wxWindow *parent, WaitThreadRoutine *pRoutine) const;
#ifdef TC_MACOSX
virtual void MacOpenFiles (const wxArrayString &fileNames);
virtual void MacReopenApp ();
#endif
template <class T>
T *GetSelectedData (wxControlWithItems *control) const
{
int sel = control->GetSelection();
if (sel == wxNOT_FOUND)
return nullptr;
return reinterpret_cast <T *> (control->GetClientData (sel));
}
Event OpenVolumeSystemRequestEvent;
protected:
virtual void OnEndSession (wxCloseEvent& event) { OnLogOff(); }
#ifdef wxHAS_POWER_EVENTS
virtual void OnPowerSuspending (wxPowerEvent& event);
#endif
static void OnSignal (int signal);
virtual void OnVolumesAutoDismounted ();
virtual int ShowMessage (const wxString &message, long style, bool topMost = false) const;
void ThrowTextModeRequired () const;
wxFrame *ActiveFrame;
bool BackgroundMode;
#ifdef TC_WINDOWS
auto_ptr <wxDDEServer> DDEServer;
#endif
wxFrame *mMainFrame;
auto_ptr <wxSingleInstanceChecker> SingleInstanceChecker;
mutable WaitDialog* mWaitDialog;
private:
GraphicUserInterface (const GraphicUserInterface &);
GraphicUserInterface &operator= (const GraphicUserInterface &);
};
struct OpenVolumeSystemRequestEventArgs : public EventArgs
{
OpenVolumeSystemRequestEventArgs (const wxString &volumePath) : mVolumePath (volumePath) { }
wxString mVolumePath;
};
class FreezeScope
{
public:
FreezeScope (wxWindow *window) : Window (window)
{
Window->Freeze();
}
~FreezeScope ()
{
Window->Thaw();
}
wxWindow *Window;
};
DECLARE_EVENT_TYPE (TC_EVENT_THREAD_EXITING, -1);
extern GraphicUserInterface *Gui;
}
#endif // TC_HEADER_Main_GraphicUserInterface
|