/* 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_UserInterface #define TC_HEADER_Main_UserInterface #include "System.h" #include "Core/Core.h" #include "Main.h" #include "CommandLineInterface.h" #include "FavoriteVolume.h" #include "LanguageStrings.h" #include "UserPreferences.h" #include "UserInterfaceException.h" #include "UserInterfaceType.h" namespace VeraCrypt { class UserInterface : public wxApp { public: virtual ~UserInterface (); virtual bool AskYesNo (const wxString &message, bool defaultYes = false, bool warning = false) const = 0; virtual void BackupVolumeHeaders (shared_ptr volumePath) const = 0; virtual void BeginBusyState () const = 0; 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 = 0; virtual void CheckRequirementsForMountingVolume () const; virtual void CloseExplorerWindows (shared_ptr mountedVolume) const; virtual void CreateKeyfile (shared_ptr keyfilePath = shared_ptr ()) const = 0; virtual void CreateVolume (shared_ptr options) const = 0; virtual void DeleteSecurityTokenKeyfiles () const = 0; virtual void DismountAllVolumes (bool ignoreOpenFiles = false, bool interactive = true) const; virtual void DismountVolume (shared_ptr volume, bool ignoreOpenFiles = false, bool interactive = true) const; virtual void DismountVolumes (VolumeInfoList volumes, bool ignoreOpenFiles = false, bool interactive = true) const; virtual void DisplayVolumeProperties (const VolumeInfoList &volumes) const; virtual void DoShowError (const wxString &message) const = 0; virtual void DoShowInfo (const wxString &message) const = 0; virtual void DoShowString (const wxString &str) const = 0; virtual void DoShowWarning (const wxString &message) const = 0; virtual void EndBusyState () const = 0; static wxString ExceptionToMessage (const exception &ex); virtual void ExportSecurityTokenKeyfile () const = 0; virtual shared_ptr GetAdminPasswordRequestHandler () = 0; virtual const UserPreferences &GetPreferences () const { return Preferences; } virtual void ImportSecurityTokenKeyfiles () const = 0; virtual void Init (); virtual void InitSecurityTokenLibrary () const = 0; virtual void ListMountedVolumes (const VolumeInfoList &volumes) const; virtual void ListSecurityTokenKeyfiles () const = 0; virtual shared_ptr MountVolume (MountOptions &options) const; virtual shared_ptr MountVolumeThread (MountOptions &options) const { return Core->MountVolume (options);} virtual VolumeInfoList MountAllDeviceHostedVolumes (MountOptions &options) const; virtual VolumeInfoList MountAllFavoriteVolumes (MountOptions &options); virtual void OpenExplorerWindow (const DirectoryPath &path); virtual void RestoreVolumeHeaders (shared_ptr volumePath) const = 0; virtual void SetPreferences (const UserPreferences &preferences); virtual void ShowError (const exception &ex) const; virtual void ShowError (const char *langStringId) const { DoShowError (LangString[langStringId]); } virtual void ShowError (const wxString &message) const { DoShowError (message); } virtual void ShowInfo (const exception &ex) const { DoShowInfo (ExceptionToMessage (ex)); } virtual void ShowInfo (const char *langStringId) const { DoShowInfo (LangString[langStringId]); } virtual void ShowInfo (const wxString &message) const { DoShowInfo (message); } virtual void ShowWarning (const exception &ex) const { DoShowWarning (ExceptionToMessage (ex)); } virtual void ShowWarning (const char *langStringId) const { DoShowWarning (LangString[langStringId]); } virtual void ShowString (const wxString &str) const { DoShowString (str); } virtual void ShowWarning (const wxString &message) const { DoShowWarning (message); } virtual wxString SizeToString (uint64 size) const; virtual wxString SpeedToString (uint64 speed) const; virtual void Test () const; virtual wxString TimeSpanToString (uint64 seconds) const; virtual bool VolumeHasUnrecommendedExtension (const VolumePath &path) const; virtual void Yield () const = 0; virtual WaitThreadUI* GetWaitThreadUI(WaitThreadRoutine *pRoutine) const { return new WaitThreadUI(pRoutine);} virtual wxDateTime VolumeTimeToDateTime (VolumeTime volumeTime) const { return wxDateTime ((time_t) (volumeTime / 1000ULL / 1000 / 10 - 134774ULL * 24 * 3600)); } virtual wxString VolumeTimeToString (VolumeTime volumeTime) const; virtual wxString VolumeTypeToString (VolumeType::Enum type, bool truecryptMode, VolumeProtection::Enum protection) const; Event PreferencesUpdatedEvent; struct BusyScope { BusyScope (const UserInterface *userInterface) : UI (userInterface) { UI->BeginBusyState (); } ~BusyScope () { UI->EndBusyState (); } const UserInterface *UI; }; static void ThrowException (Exception* ex); protected: UserInterface (); virtual bool OnExceptionInMainLoop () { throw; } virtual void OnUnhandledException (); virtual void OnVolumeMounted (EventArgs &args); virtual void OnWarning (EventArgs &args); virtual bool ProcessCommandLine (); static wxString ExceptionToString (const Exception &ex); static wxString ExceptionTypeToString (const std::type_info &ex); UserPreferences Preferences; UserInterfaceType::Enum InterfaceType; private: UserInterface (const UserInterface &); UserInterface &operator= (const UserInterface &); }; } #endif // TC_HEADER_Main_UserInterface ' href='#n99'>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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 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 264 265 266 267 268 269 270 271 272 273