/* Derived from source code of TrueCrypt 7.1a, which is Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2017 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source code distribution packages. */ #ifndef TC_HEADER_Main_GraphicUserInterface #define TC_HEADER_Main_GraphicUserInterface #include "System.h" #include #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 &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) const; virtual void BeginBusyState () const { wxBeginBusyCursor(); } virtual void BeginInteractiveBusyState (wxWindow *window); virtual void ChangePassword (shared_ptr volumePath = shared_ptr (), shared_ptr password = shared_ptr (), int pim = 0, shared_ptr currentHash = shared_ptr (), bool truecryptMode = false, shared_ptr keyfiles = shared_ptr (), shared_ptr newPassword = shared_ptr (), int newPim = 0, shared_ptr newKeyfiles = shared_ptr (), shared_ptr newHash = shared_ptr ()) const { ThrowTextModeRequired(); } wxHyperlinkCtrl *CreateHyperlink (wxWindow *parent, const wxString &linkUrl, const wxString &linkText) const; virtual void CreateKeyfile (shared_ptr keyfilePath = shared_ptr ()) const; virtual void CreateVolume (shared_ptr 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 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, const wxString &extraVars = wxEmptyString) const; virtual wxFrame *GetMainFrame () const { return mMainFrame; } virtual int GetScrollbarWidth (wxWindow *window, bool noScrollBar = false) const; virtual list 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 &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 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) 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 > &fileExtensions = (list < pair > ()), 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 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 &itemFields) const; virtual void UserEnrichRandomPool (wxWindow *parent, shared_ptr hash = shared_ptr ()) const; virtual void Yield () const; virtual shared_ptr 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 (); static bool HandlePasswordEntryCustomEvent (wxEvent& event); static void InstallPasswordEntryCustomKeyboardShortcuts (wxWindow* window); #endif template T *GetSelectedData (wxControlWithItems *control) const { int sel = control->GetSelection(); if (sel == wxNOT_FOUND) return nullptr; return reinterpret_cast (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 DDEServer; #endif wxFrame *mMainFrame; auto_ptr SingleInstanceChecker; mutable WaitDialog* mWaitDialog; public: #ifdef TC_MACOSX static int g_customIdCmdV; static int g_customIdCmdA; #endif 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 #n183'>183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263