"Fossies" - the Fresh Open Source Software Archive

Member "src/Main/UserInterface.h" (10 Oct 2018, 6464 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 "UserInterface.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_UserInterface
   14 #define TC_HEADER_Main_UserInterface
   15 
   16 #include "System.h"
   17 #include "Core/Core.h"
   18 #include "Main.h"
   19 #include "CommandLineInterface.h"
   20 #include "FavoriteVolume.h"
   21 #include "LanguageStrings.h"
   22 #include "UserPreferences.h"
   23 #include "UserInterfaceException.h"
   24 #include "UserInterfaceType.h"
   25 
   26 namespace VeraCrypt
   27 {
   28     class UserInterface : public wxApp
   29     {
   30     public:
   31         virtual ~UserInterface ();
   32 
   33         virtual bool AskYesNo (const wxString &message, bool defaultYes = false, bool warning = false) const = 0;
   34         virtual void BackupVolumeHeaders (shared_ptr <VolumePath> volumePath) const = 0;
   35         virtual void BeginBusyState () const = 0;
   36         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 = 0;
   37         virtual void CheckRequirementsForMountingVolume () const;
   38         virtual void CloseExplorerWindows (shared_ptr <VolumeInfo> mountedVolume) const;
   39         virtual void CreateKeyfile (shared_ptr <FilePath> keyfilePath = shared_ptr <FilePath>()) const = 0;
   40         virtual void CreateVolume (shared_ptr <VolumeCreationOptions> options) const = 0;
   41         virtual void DeleteSecurityTokenKeyfiles () const = 0;
   42         virtual void DismountAllVolumes (bool ignoreOpenFiles = false, bool interactive = true) const;
   43         virtual void DismountVolume (shared_ptr <VolumeInfo> volume, bool ignoreOpenFiles = false, bool interactive = true) const;
   44         virtual void DismountVolumes (VolumeInfoList volumes, bool ignoreOpenFiles = false, bool interactive = true) const;
   45         virtual void DisplayVolumeProperties (const VolumeInfoList &volumes) const;
   46         virtual void DoShowError (const wxString &message) const = 0;
   47         virtual void DoShowInfo (const wxString &message) const = 0;
   48         virtual void DoShowString (const wxString &str) const = 0;
   49         virtual void DoShowWarning (const wxString &message) const = 0;
   50         virtual void EndBusyState () const = 0;
   51         static wxString ExceptionToMessage (const exception &ex);
   52         virtual void ExportSecurityTokenKeyfile () const = 0;
   53         virtual shared_ptr <GetStringFunctor> GetAdminPasswordRequestHandler () = 0;
   54         virtual const UserPreferences &GetPreferences () const { return Preferences; }
   55         virtual void ImportSecurityTokenKeyfiles () const = 0;
   56         virtual void Init ();
   57         virtual void InitSecurityTokenLibrary () const = 0;
   58         virtual void ListMountedVolumes (const VolumeInfoList &volumes) const;
   59         virtual void ListSecurityTokenKeyfiles () const = 0;
   60         virtual shared_ptr <VolumeInfo> MountVolume (MountOptions &options) const;
   61         virtual shared_ptr <VolumeInfo> MountVolumeThread (MountOptions &options) const { return Core->MountVolume (options);}
   62         virtual VolumeInfoList MountAllDeviceHostedVolumes (MountOptions &options) const;
   63         virtual VolumeInfoList MountAllFavoriteVolumes (MountOptions &options);
   64         virtual void OpenExplorerWindow (const DirectoryPath &path);
   65         virtual void RestoreVolumeHeaders (shared_ptr <VolumePath> volumePath) const = 0;
   66         virtual void SetPreferences (const UserPreferences &preferences);
   67         virtual void ShowError (const exception &ex) const;
   68         virtual void ShowError (const char *langStringId) const { DoShowError (LangString[langStringId]); }
   69         virtual void ShowError (const wxString &message) const { DoShowError (message); }
   70         virtual void ShowInfo (const exception &ex) const { DoShowInfo (ExceptionToMessage (ex)); }
   71         virtual void ShowInfo (const char *langStringId) const { DoShowInfo (LangString[langStringId]); }
   72         virtual void ShowInfo (const wxString &message) const { DoShowInfo (message); }
   73         virtual void ShowWarning (const exception &ex) const { DoShowWarning (ExceptionToMessage (ex)); }
   74         virtual void ShowWarning (const char *langStringId) const { DoShowWarning (LangString[langStringId]); }
   75         virtual void ShowString (const wxString &str) const { DoShowString (str); }
   76         virtual void ShowWarning (const wxString &message) const { DoShowWarning (message); }
   77         virtual wxString SizeToString (uint64 size) const;
   78         virtual wxString SpeedToString (uint64 speed) const;
   79         virtual void Test () const;
   80         virtual wxString TimeSpanToString (uint64 seconds) const;
   81         virtual bool VolumeHasUnrecommendedExtension (const VolumePath &path) const;
   82         virtual void Yield () const = 0;
   83         virtual WaitThreadUI* GetWaitThreadUI(WaitThreadRoutine *pRoutine) const { return new WaitThreadUI(pRoutine);}
   84         virtual wxDateTime VolumeTimeToDateTime (VolumeTime volumeTime) const { return wxDateTime ((time_t) (volumeTime / 1000ULL / 1000 / 10 - 134774ULL * 24 * 3600)); }
   85         virtual wxString VolumeTimeToString (VolumeTime volumeTime) const;
   86         virtual wxString VolumeTypeToString (VolumeType::Enum type, bool truecryptMode, VolumeProtection::Enum protection) const;
   87 
   88         Event PreferencesUpdatedEvent;
   89 
   90         struct BusyScope
   91         {
   92             BusyScope (const UserInterface *userInterface) : UI (userInterface) { UI->BeginBusyState (); }
   93             ~BusyScope () { UI->EndBusyState (); }
   94             const UserInterface *UI;
   95         };
   96 
   97         static void ThrowException (Exception* ex);
   98 
   99     protected:
  100         UserInterface ();
  101         virtual bool OnExceptionInMainLoop () { throw; }
  102         virtual void OnUnhandledException ();
  103         virtual void OnVolumeMounted (EventArgs &args);
  104         virtual void OnWarning (EventArgs &args);
  105         virtual bool ProcessCommandLine ();
  106 
  107         static wxString ExceptionToString (const Exception &ex);
  108         static wxString ExceptionTypeToString (const std::type_info &ex);
  109 
  110         UserPreferences Preferences;
  111         UserInterfaceType::Enum InterfaceType;
  112 
  113     private:
  114         UserInterface (const UserInterface &);
  115         UserInterface &operator= (const UserInterface &);
  116     };
  117 }
  118 
  119 #endif // TC_HEADER_Main_UserInterface