Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion MajorPrivacy/Core/Volumes/VolumeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void CVolumeManager::Update()
}
}

STATUS CVolumeManager::AddVolume(const QString& Path)
STATUS CVolumeManager::AddVolume(const QString& Path, bool bProtect)
{
if (Path.endsWith("\\"))
{
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion MajorPrivacy/Core/Volumes/VolumeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CVolumeManager : public QObject

QList<CVolumePtr> 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);
Expand Down
21 changes: 19 additions & 2 deletions MajorPrivacy/Wizards/VolumeWizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<STATUS>() << Result, parent ? parent : theGUI);

return Result.IsSuccess();
Expand Down Expand Up @@ -185,6 +188,11 @@ int CVolumeWizard::GetKdf() const
return iKdf;
}

bool CVolumeWizard::GetProtectContainerFile() const
{
return field("protectContainerFile").toBool();
}

//////////////////////////////////////////////////////////////////////////////////////////
// CVolumeIntroPage
//
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions MajorPrivacy/Wizards/VolumeWizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class CVolumeWizard : public QWizard
QString GetCipher() const;
QString GetFileSystem() const;
int GetKdf() const;
bool GetProtectContainerFile() const;

private slots:
void showHelp();
Expand Down Expand Up @@ -234,4 +235,5 @@ class CVolumeSummaryPage : public QWizardPage

private:
QLabel* m_pSummaryLabel;
QCheckBox* m_pProtectFile;
};