VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main/Forms/WizardPage.h
blob: ef34154f245a12a81c7ecdf17c7ef10ba1cdc308 (plain)
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
/*
 Copyright (c) 2008 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_Forms_WizardPage
#define TC_HEADER_Main_Forms_WizardPage

#include "Main/Main.h"

namespace VeraCrypt
{
	class WizardPage : public wxPanel
	{
	public:
		WizardPage (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
			: wxPanel (parent, id, pos, size, style)
		{ }
		virtual ~WizardPage () { }

		wxString GetPageTitle () const { return PageTitle; }
		virtual bool IsValid () = 0;
		virtual void OnPageChanging (bool forward) { }
		wxString GetNextButtonText () const { return NextButtonText; }
		void SetNextButtonText (const wxString &text) { NextButtonText = text; }
		virtual void SetMaxStaticTextWidth (int width) { }
		void SetPageTitle (const wxString &title) { PageTitle = title; }
		virtual void SetPageText (const wxString &text) = 0;

		Event PageUpdatedEvent;

	protected:
		wxString PageTitle;
		wxString NextButtonText;
	};
}

#endif // TC_HEADER_Main_Forms_WizardPage
ons 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. */ #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/mount.h> #include <sys/mntent.h> #include <sys/mnttab.h> #include "CoreSolaris.h" #include "Core/Unix/CoreServiceProxy.h" namespace VeraCrypt { CoreSolaris::CoreSolaris () { } CoreSolaris::~CoreSolaris () { } DevicePath CoreSolaris::AttachFileToLoopDevice (const FilePath &filePath, bool readOnly) const { list <string> args; args.push_back ("-a"); args.push_back (filePath); return StringConverter::Trim (Process::Execute ("lofiadm", args)); } void CoreSolaris::DetachLoopDevice (const DevicePath &devicePath) const { list <string> args; args.push_back ("-d"); args.push_back (devicePath); for (int t = 0; true; t++) { try { Process::Execute ("lofiadm", args); break; } catch (ExecutedProcessFailed&) { if (t > 5) throw; Thread::Sleep (200); } } } HostDeviceList CoreSolaris::GetHostDevices (bool pathListOnly) const { HostDeviceList devices; foreach_ref (const FilePath &devPath, Directory::GetFilePaths ("/dev/rdsk", false)) { string drivePath = devPath; if (drivePath.rfind ("p0") == drivePath.size() - 2) { make_shared_auto (HostDevice, device); device->Path = drivePath; try { device->Size = GetDeviceSize (device->Path); } catch (...) { device->Size = 0; } if (device->Size == 0) continue; device->MountPoint = GetDeviceMountPoint (device->Path); device->SystemNumber = 0; devices.push_back (device); for (int partNumber = 1; partNumber <= 32; partNumber++) { stringstream partPath; partPath << drivePath.substr (0, drivePath.size() - 1) << partNumber; if (FilesystemPath (partPath.str()).IsBlockDevice() || FilesystemPath (partPath.str()).IsCharacterDevice()) { make_shared_auto (HostDevice, partition); partition->Path = partPath.str(); try { partition->Size = GetDeviceSize (partition->Path); } catch (...) { partition->Size = 0; } if (partition->Size == 0) continue; partition->MountPoint = GetDeviceMountPoint (partition->Path); partition->SystemNumber = 0; device->Partitions.push_back (partition); } } } } return devices; } MountedFilesystemList CoreSolaris::GetMountedFilesystems (const DevicePath &devicePath, const DirectoryPath &mountPoint) const { MountedFilesystemList mountedFilesystems; FILE *mtab = fopen ("/etc/mnttab", "r"); throw_sys_sub_if (!mtab, "/etc/mnttab"); finally_do_arg (FILE *, mtab, { fclose (finally_arg); }); int getmntentResult; struct mnttab entry; while ((getmntentResult = getmntent (mtab, &entry)) == 0) { make_shared_auto (MountedFilesystem, mf); if (entry.mnt_special) mf->Device = DevicePath (entry.mnt_special); else continue; if (entry.mnt_mountp) mf->MountPoint = DirectoryPath (entry.mnt_mountp); if (entry.mnt_fstype) mf->Type = entry.mnt_fstype; if ((devicePath.IsEmpty() || devicePath == mf->Device) && (mountPoint.IsEmpty() || mountPoint == mf->MountPoint)) mountedFilesystems.push_back (mf); } throw_sys_if (getmntentResult > 0); return mountedFilesystems; } void CoreSolaris::MountFilesystem (const DevicePath &devicePath, const DirectoryPath &mountPoint, const string &filesystemType, bool readOnly, const string &systemMountOptions) const { try { // Try to mount FAT by default as mount is unable to probe filesystem type on Solaris CoreUnix::MountFilesystem (devicePath, mountPoint, filesystemType.empty() ? "pcfs" : filesystemType, readOnly, systemMountOptions); } catch (ExecutedProcessFailed&) { if (!filesystemType.empty()) throw; CoreUnix::MountFilesystem (devicePath, mountPoint, filesystemType, readOnly, systemMountOptions); } } unique_ptr <CoreBase> Core (new CoreServiceProxy <CoreSolaris>); unique_ptr <CoreBase> CoreDirect (new CoreSolaris); }