diff --git a/MajorPrivacy/Core/Volumes/VolumeManager.cpp b/MajorPrivacy/Core/Volumes/VolumeManager.cpp index 56282a5..0b1a6a9 100644 --- a/MajorPrivacy/Core/Volumes/VolumeManager.cpp +++ b/MajorPrivacy/Core/Volumes/VolumeManager.cpp @@ -53,7 +53,7 @@ void CVolumeManager::Update() } } -STATUS CVolumeManager::AddVolume(const QString& Path) +STATUS CVolumeManager::AddVolume(const QString& Path, bool bProtect) { if (Path.endsWith("\\")) { @@ -66,6 +66,17 @@ STATUS CVolumeManager::AddVolume(const QString& Path) if(!Status) return Status; } + else if (bProtect) + { + CAccessRulePtr pRule = CAccessRulePtr(new CAccessRule(theCore->ProgramManager()->GetAll()->GetID())); + pRule->SetType(EAccessRuleType::eProtect); + pRule->SetEnabled(true); + pRule->SetName(tr("%1 - Protection").arg(Path)); + pRule->SetPath(Path); + STATUS Status = theCore->AccessManager()->SetAccessRule(pRule); + if(!Status) + return Status; + } CVolumePtr pVolume = CVolumePtr(new CVolume()); pVolume->SetImagePath(Path); diff --git a/MajorPrivacy/Core/Volumes/VolumeManager.h b/MajorPrivacy/Core/Volumes/VolumeManager.h index 5e96c2e..1d0768e 100644 --- a/MajorPrivacy/Core/Volumes/VolumeManager.h +++ b/MajorPrivacy/Core/Volumes/VolumeManager.h @@ -13,7 +13,7 @@ class CVolumeManager : public QObject QList List() { return m_List.values(); } - STATUS AddVolume(const QString& Path); + STATUS AddVolume(const QString& Path, bool bProtect = false); STATUS RemoveVolume(const QString& Path); STATUS SetVolume(const CVolumePtr& pVolume); diff --git a/MajorPrivacy/Wizards/VolumeWizard.cpp b/MajorPrivacy/Wizards/VolumeWizard.cpp index a1f7358..171b13d 100644 --- a/MajorPrivacy/Wizards/VolumeWizard.cpp +++ b/MajorPrivacy/Wizards/VolumeWizard.cpp @@ -131,8 +131,11 @@ bool CVolumeWizard::ShowWizard(QWidget* parent) pWatcher->deleteLater(); - if (Result.IsSuccess()) - theCore->VolumeManager()->AddVolume(Path); + if (Result.IsSuccess()) { + STATUS Status = theCore->VolumeManager()->AddVolume(Path, wizard.GetProtectContainerFile()); + if (!Status) + Result = Status; + } theGUI->CheckResults(QList() << Result, parent ? parent : theGUI); return Result.IsSuccess(); @@ -185,6 +188,11 @@ int CVolumeWizard::GetKdf() const return iKdf; } +bool CVolumeWizard::GetProtectContainerFile() const +{ + return field("protectContainerFile").toBool(); +} + ////////////////////////////////////////////////////////////////////////////////////////// // CVolumeIntroPage // @@ -1076,6 +1084,15 @@ CVolumeSummaryPage::CVolumeSummaryPage(QWidget *parent) m_pSummaryLabel->setStyleSheet("QLabel { background-color: palette(alternate-base); padding: 15px; border-radius: 5px; }"); layout->addWidget(m_pSummaryLabel); + layout->addSpacing(16); + + m_pProtectFile = new QCheckBox(tr("Protect the volume container file (.pv) from modification by other programs")); + m_pProtectFile->setWordWrap(true); + m_pProtectFile->setToolTip(tr("Adds a Protect access rule for the container file itself, so that no other program can read, modify or delete it while the protection is active.")); + m_pProtectFile->setChecked(true); + layout->addWidget(m_pProtectFile); + registerField("protectContainerFile", m_pProtectFile); + layout->addSpacing(20); QLabel* noteLabel = new QLabel(tr( diff --git a/MajorPrivacy/Wizards/VolumeWizard.h b/MajorPrivacy/Wizards/VolumeWizard.h index 0acdb39..e9ac0a8 100644 --- a/MajorPrivacy/Wizards/VolumeWizard.h +++ b/MajorPrivacy/Wizards/VolumeWizard.h @@ -32,6 +32,7 @@ class CVolumeWizard : public QWizard QString GetCipher() const; QString GetFileSystem() const; int GetKdf() const; + bool GetProtectContainerFile() const; private slots: void showHelp(); @@ -234,4 +235,5 @@ class CVolumeSummaryPage : public QWizardPage private: QLabel* m_pSummaryLabel; + QCheckBox* m_pProtectFile; };