This commit is contained in:
DavidXanatos 2022-02-05 15:09:53 +01:00
parent 09a40ed45f
commit 46904667b0
24 changed files with 631 additions and 324 deletions

View File

@ -147,9 +147,8 @@ SB_PROGRESS CSandBox::CleanBox()
if (GetBool("NeverDelete", false))
return SB_ERR(SB_DeleteProtect);
SB_STATUS Status = TerminateAll();
if (Status.IsError())
return Status;
if (GetActiveProcessCount() > 0)
return SB_ERR(SB_DeleteNotEmpty);
return CleanBoxFolders(QStringList(m_FilePath));
}
@ -181,7 +180,7 @@ SB_STATUS CSandBox__DeleteFolder(const CSbieProgressPtr& pProgress, const QStrin
NTSTATUS status = NtIo_DeleteFolderRecursively(&ntObject.attr, [](const WCHAR* info, void* param) {
CSbieProgress* pProgress = (CSbieProgress*)param;
pProgress->ShowMessage(QString::fromWCharArray(info));
pProgress->ShowMessage(CSandBox::tr("Deleting folder: %1").arg(QString::fromWCharArray(info)));
return !pProgress->IsCanceled();
}, pProgress.data());
@ -243,6 +242,27 @@ SB_STATUS CSandBox::RemoveBox()
return RemoveSection();
}
QString CSandBox::Expand(const QString& Value)
{
QString Value2 = Value;
QRegExp rx("%([a-zA-Z0-9 ]+)%");
for (int pos = 0; (pos = rx.indexIn(Value, pos)) != -1; ) {
QString var = rx.cap(1);
QString val;
if (var.compare("BoxPath", Qt::CaseInsensitive) == 0)
val = this->GetFileRoot();
else if (var.compare("BoxName", Qt::CaseInsensitive) == 0)
val = this->GetName();
else
val = m_pAPI->SbieIniGet(this->GetName(), "%" + var + "%", 0x80000000); // CONF_JUST_EXPAND
Value2.replace("%" + var + "%", val);
pos += rx.matchedLength();
}
return Value2;
}
QList<SBoxSnapshot> CSandBox::GetSnapshots(QString* pCurrent, QString* pDefault) const
{
QSettings ini(m_FilePath + "\\Snapshots.ini", QSettings::IniFormat);
@ -467,7 +487,7 @@ SB_STATUS CSandBox__MergeFolders(const CSbieProgressPtr& pProgress, const QStrin
NTSTATUS status = NtIo_MergeFolder(&ntSource.attr, &ntTarget.attr, [](const WCHAR* info, void* param) {
CSbieProgress* pProgress = (CSbieProgress*)param;
pProgress->ShowMessage(QString::fromWCharArray(info));
pProgress->ShowMessage(CSandBox::tr("Merging folder: %1").arg(QString::fromWCharArray(info)));
return !pProgress->IsCanceled();
}, pProgress.data());

View File

@ -65,6 +65,8 @@ public:
virtual SB_STATUS RenameBox(const QString& NewName);
virtual SB_STATUS RemoveBox();
virtual QString Expand(const QString& Value);
virtual QList<SBoxSnapshot> GetSnapshots(QString* pCurrent = NULL, QString* pDefault = NULL) const;
virtual void SetDefaultSnapshot(QString Default);
virtual QString GetDefaultSnapshot(QString* pCurrent = NULL) const;

View File

@ -27,6 +27,7 @@ enum ESbieMsgCodes
SB_BadNameChar,
SB_FailedKillAll,
SB_DeleteProtect,
SB_DeleteNotEmpty,
SB_DeleteError,
//SB_RemNotEmpty,
SB_DelNotEmpty,

View File

@ -0,0 +1,43 @@
#include "stdafx.h"
#include "BoxJob.h"
#include "SbiePlusAPI.h"
#include "../QSbieAPI/SbieUtils.h"
///////////////////////////////////////////////////////////////////////////////
// CCleanUpJob
//
SB_PROGRESS CCleanUpJob::Start()
{
CSandBoxPlus* pBox = GetBox();
SB_PROGRESS Status;
if (!m_DeleteShapshots && pBox->HasSnapshots()) {
QString Current;
QString Default = pBox->GetDefaultSnapshot(&Current);
if (m_bOnAutoDelete) {
Default = Current; // on auto delete always return to the latest
}
Status = pBox->SelectSnapshot(Default);
}
else // if there are no snapshots jut use the normal cleaning procedure
Status = pBox->CleanBox();
if (Status.GetStatus() == OP_ASYNC)
m_pProgress = Status.GetValue();
return Status;
}
///////////////////////////////////////////////////////////////////////////////
// COnDeleteJob
//
SB_PROGRESS COnDeleteJob::Start()
{
m_pProgress = CSbieUtils::RunCommand(m_Command, true);
if (m_pProgress.isNull())
return SB_ERR();
return SB_PROGRESS(OP_ASYNC, m_pProgress);
}

View File

@ -0,0 +1,64 @@
#pragma once
#include "../QSbieAPI/SbieStatus.h"
#include "../QSbieAPI/SbieAPI.h"
class CSandBoxPlus;
class CBoxJob : public QObject
{
Q_OBJECT
public:
CBoxJob(QObject* parent = NULL) : QObject(parent) { }
virtual SB_PROGRESS Start() = 0;
CSbieProgressPtr GetProgress() { return m_pProgress; }
QString GetDescription(){ return m_Description; }
CSandBoxPlus* GetBox() { return (CSandBoxPlus*)parent(); }
protected:
CSbieProgressPtr m_pProgress;
QString m_Description;
};
///////////////////////////////////////////////////////////////////////////////
// CCleanUpBoxJob
//
class CCleanUpJob : public CBoxJob
{
protected:
friend CSandBoxPlus;
CCleanUpJob(CSandBoxPlus* pBox, bool DeleteShapshots = true, bool bOnAutoDelete = false) : CBoxJob((QObject*)pBox) {
m_Description = tr("Deleting Content");
m_DeleteShapshots = DeleteShapshots;
m_bOnAutoDelete = bOnAutoDelete;
}
virtual SB_PROGRESS Start();
protected:
bool m_DeleteShapshots;
bool m_bOnAutoDelete;
};
///////////////////////////////////////////////////////////////////////////////
// COnDeleteJob
//
class COnDeleteJob : public CBoxJob
{
protected:
friend CSandBoxPlus;
COnDeleteJob(CSandBoxPlus* pBox, const QString& Command) : CBoxJob((QObject*)pBox) {
m_Description = tr("OnDelete: %1").arg(Command);
m_Command = Command;
}
virtual SB_PROGRESS Start();
protected:
QString m_Command;
};

View File

@ -45,7 +45,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>8</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabGeneral">
<attribute name="title">
@ -64,48 +64,7 @@
<layout class="QGridLayout" name="gridLayout_27">
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Appearance</string>
</property>
</widget>
</item>
<item row="1" column="3" colspan="2">
<widget class="QComboBox" name="cmbBoxIndicator"/>
</item>
<item row="2" column="5">
<widget class="QToolButton" name="btnBorderColor">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label_56">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>General Configuration</string>
</property>
</widget>
</item>
<item row="5" column="3" colspan="2">
<widget class="QComboBox" name="cmbBoxType"/>
</item>
<item row="5" column="0" colspan="3">
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="label_57">
<property name="text">
<string>Box Type Preset:</string>
@ -115,26 +74,6 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Sandbox Indicator in title:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="7">
<widget class="QLabel" name="label_14">
<property name="text">
<string>px Width</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="label_21">
<property name="text">
@ -145,23 +84,17 @@
</property>
</widget>
</item>
<item row="7" column="1" colspan="6">
<widget class="QLabel" name="lblBoxInfo">
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label_56">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Box info</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1" colspan="6">
<widget class="QLabel" name="label_58">
<property name="text">
<string/>
<string>General Configuration</string>
</property>
</widget>
</item>
@ -178,28 +111,51 @@
</property>
</widget>
</item>
<item row="3" column="1" colspan="7">
<widget class="QCheckBox" name="chkShowForRun">
<item row="6" column="3" colspan="2">
<widget class="QComboBox" name="cmbBoxType"/>
</item>
<item row="7" column="1" colspan="6">
<widget class="QLabel" name="label_58">
<property name="text">
<string>Show this box in the 'run in box' selection prompt</string>
<string/>
</property>
</widget>
</item>
<item row="9" column="2" colspan="5">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="9" column="1" colspan="6">
<widget class="QLabel" name="lblSupportCert">
<property name="text">
<string>&lt;b&gt;More Box Types&lt;/b&gt; are exclusively available to &lt;u&gt;project supporters&lt;/u&gt;, the Privacy Enhanced boxes &lt;b&gt;&lt;font color='red'&gt;protect user data from illicit access&lt;/font&gt;&lt;/b&gt; by the sandboxed programs.&lt;br /&gt;If you are not yet a supporter, then please consider &lt;a href=&quot;https://sandboxie-plus.com/go.php?to=sbie-get-cert&quot;&gt;supporting the project&lt;/a&gt;, to receive a &lt;a href=&quot;https://sandboxie-plus.com/go.php?to=sbie-cert&quot;&gt;supporter certificate&lt;/a&gt;.&lt;br /&gt;You can test the other box types by creating new sandboxes of those types, however processes in these will be auto terminated after 5 minutes.</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</spacer>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="3" colspan="2">
<widget class="QComboBox" name="cmbBoxBorder"/>
<item row="2" column="7">
<widget class="QLabel" name="label_14">
<property name="text">
<string>px Width</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1" colspan="6">
<widget class="QLabel" name="lblBoxInfo">
<property name="text">
<string>Box info</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_30">
@ -220,20 +176,41 @@
</property>
</widget>
</item>
<item row="8" column="1" colspan="6">
<widget class="QLabel" name="lblSupportCert">
<item row="2" column="3" colspan="2">
<widget class="QComboBox" name="cmbBoxBorder"/>
</item>
<item row="2" column="5">
<widget class="QToolButton" name="btnBorderColor">
<property name="text">
<string>&lt;b&gt;More Box Types&lt;/b&gt; are exclusively available to &lt;u&gt;project supporters&lt;/u&gt;, the Privacy Enhanced boxes &lt;b&gt;&lt;font color='red'&gt;protect user data from illicit access&lt;/font&gt;&lt;/b&gt; by the sandboxed programs.&lt;br /&gt;If you are not yet a supporter, then please consider &lt;a href=&quot;https://sandboxie-plus.com/go.php?to=sbie-get-cert&quot;&gt;supporting the project&lt;/a&gt;, to receive a &lt;a href=&quot;https://sandboxie-plus.com/go.php?to=sbie-cert&quot;&gt;supporter certificate&lt;/a&gt;.&lt;br /&gt;You can test the other box types by creating new sandboxes of those types, however processes in these will be auto terminated after 5 minutes.</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
<string/>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Appearance</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Sandbox Indicator in title:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="10" column="1">
<spacer name="verticalSpacer_17">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -246,6 +223,36 @@
</property>
</spacer>
</item>
<item row="10" column="2" colspan="5">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3" colspan="2">
<widget class="QComboBox" name="cmbBoxIndicator"/>
</item>
<item row="3" column="1" colspan="7">
<widget class="QCheckBox" name="chkShowForRun">
<property name="text">
<string>Show this box in the 'run in box' selection prompt</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="7">
<widget class="QCheckBox" name="chkPinToTray">
<property name="text">
<string>Always show this sandbox in the systray list (Pinned)</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -2783,8 +2790,8 @@ instead of &quot;*&quot;.</string>
<rect>
<x>0</x>
<y>0</y>
<width>63</width>
<height>16</height>
<width>98</width>
<height>28</height>
</rect>
</property>
<layout class="QGridLayout" name="dbgLayout">

View File

@ -45,7 +45,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabGeneral">
<attribute name="title">
@ -211,13 +211,22 @@
<item row="0" column="1">
<widget class="QComboBox" name="uiLang"/>
</item>
<item row="10" column="1" colspan="2">
<widget class="QCheckBox" name="chkTrayActiveOnly">
<item row="10" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Show only sandboxes with running processes in the tray list</string>
<string>Show boxes in tray list:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QComboBox" name="cmbTrayBoxes"/>
</item>
</layout>
</item>
</layout>

View File

@ -195,14 +195,17 @@ QList<QVariant> CSbieModel::Sync(const QMap<QString, CSandBoxPtr>& BoxList, cons
QMap<quint32, CBoxedProcessPtr> ProcessList = pBox->GetProcessList();
bool inUse = Sync(pBox, pNode->Path, ProcessList, New, Old, Added);
bool Busy = pBoxEx->IsBusy();
int boxType = pBoxEx->GetType();
if (pNode->inUse != inUse || pNode->boxType != boxType)
if (pNode->inUse != inUse || (pNode->busyState || Busy) || pNode->boxType != boxType)
{
pNode->inUse = inUse;
pNode->boxType = boxType;
if(Busy) pNode->busyState = (pNode->busyState == 1) ? 2 : 1; // make it flach, the cheep way
else pNode->busyState = 0;
//pNode->Icon = pNode->inUse ? m_BoxInUse : m_BoxEmpty;
pNode->Icon = theGUI->GetBoxIcon(boxType, inUse);
pNode->Icon = theGUI->GetBoxIcon(boxType, inUse, pNode->busyState == 1);
Changed = 1; // set change for first column
}

View File

@ -1,6 +1,7 @@
#pragma once
#include <qwidget.h>
#include "../SbiePlusAPI.h"
#include "../SbieProcess.h"
#include "../../MiscHelpers/Common/TreeItemModel.h"
@ -50,6 +51,7 @@ protected:
CSandBoxPtr pBox;
bool inUse;
int busyState;
int boxType;
int OrderNumber;

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

View File

@ -82,5 +82,6 @@
<file alias="Full0">Boxes/sandbox-y-full.png</file>
<file alias="Empty6">Boxes/sandbox-o-empty.png</file>
<file alias="Full6">Boxes/sandbox-o-full.png</file>
<file alias="Busy">Boxes/BusyOverlay.png</file>
</qresource>
</RCC>

View File

@ -207,8 +207,23 @@ CSandMan::CSandMan(QWidget *parent)
connect(m_pHotkeyManager, SIGNAL(activated(size_t)), SLOT(OnHotKey(size_t)));
SetupHotKeys();
for (int i = 0; i < eMaxColor; i++)
m_BoxIcons[(EBoxColors)i] = qMakePair(QIcon(QString(":/Boxes/Empty%1").arg(i)), QIcon(QString(":/Boxes/Full%1").arg(i)));
for (int i = 0; i < eMaxColor; i++) {
m_BoxIcons[i].Empty = QIcon(QString(":/Boxes/Empty%1").arg(i));
m_BoxIcons[i].InUse= QIcon(QString(":/Boxes/Full%1").arg(i));
//QImage Image(QString(":/Boxes/Empty%1").arg(i));
//Image.invertPixels();
//m_BoxIcons[i].Busy = QIcon(QPixmap::fromImage(Image));
QPixmap base = QPixmap(QString(":/Boxes/Empty%1").arg(i));
QPixmap overlay= QPixmap(":/Boxes/Busy");
QPixmap result(base.width(), base.height());
result.fill(Qt::transparent); // force alpha channel
QPainter painter(&result);
painter.drawPixmap(0, 0, base);
painter.drawPixmap(0, 0, overlay);
m_BoxIcons[i].Busy = QIcon(result);
}
// Tray
m_pTrayIcon = new QSystemTrayIcon(GetTrayIconName(), this);
@ -599,7 +614,7 @@ void CSandMan::closeEvent(QCloseEvent *e)
QApplication::quit();
}
QIcon CSandMan::GetBoxIcon(int boxType, bool inUse)
QIcon CSandMan::GetBoxIcon(int boxType, bool inUse, bool inBusy)
{
EBoxColors color = eYellow;
switch (boxType) {
@ -611,7 +626,11 @@ QIcon CSandMan::GetBoxIcon(int boxType, bool inUse)
case CSandBoxPlus::eAppBox: color = eGreen; break;
case CSandBoxPlus::eInsecure: color = eMagenta; break;
}
return inUse ? m_BoxIcons[color].second : m_BoxIcons[color].first;
if (inBusy)
return m_BoxIcons[color].Busy;
if (inUse)
return m_BoxIcons[color].InUse;
return m_BoxIcons[color].Empty;
}
QString CSandMan::GetBoxDescription(int boxType)
@ -881,36 +900,6 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
}
}
bool CSandMan::DoDeleteCmd(const CSandBoxPtr &pBox)
{
foreach(const QString& Value, pBox->GetTextList("OnBoxDelete", true, false, true)) {
QString Value2 = Value;
QRegExp rx("%([a-zA-Z0-9 ]+)%");
for(int pos = 0; (pos = rx.indexIn(Value, pos)) != -1; ) {
QString var = rx.cap(1);
QString val;
if (var.compare("BoxPath", Qt::CaseInsensitive) == 0)
val = pBox->GetFileRoot();
else if (var.compare("BoxName", Qt::CaseInsensitive) == 0)
val = pBox->GetName();
else
val = theAPI->SbieIniGet(pBox->GetName(), "%" + var + "%", 0x80000000); // CONF_JUST_EXPAND
Value2.replace("%" + var + "%", val);
pos += rx.matchedLength();
}
CSbieProgressPtr pProgress = CSbieUtils::RunCommand(Value2, true);
if (!pProgress.isNull()) {
AddAsyncOp(pProgress, true, tr("Executing OnBoxDelete: %1").arg(Value2));
if (pProgress->IsCanceled())
return false;
}
}
return true;
}
void CSandMan::OnBoxClosed(const QString& BoxName)
{
CSandBoxPtr pBox = theAPI->GetBoxByName(BoxName);
@ -924,20 +913,9 @@ void CSandMan::OnBoxClosed(const QString& BoxName)
if(!theGUI->OpenRecovery(pBox, DeleteShapshots, true)) // unless no files are found than continue silently
return;
if (!DoDeleteCmd(pBox))
return;
SB_PROGRESS Status;
if (!DeleteShapshots && pBox->HasSnapshots()) { // in auto delete mdoe always return to last snapshot
QString Current;
pBox->GetDefaultSnapshot(&Current);
Status = pBox->SelectSnapshot(Current);
}
else // if there are no snapshots jut use the normal cleaning procedure
Status = pBox->CleanBox();
if (Status.GetStatus() == OP_ASYNC)
AddAsyncOp(Status.GetValue(), true, tr("Auto Deleting %1 content").arg(BoxName));
auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
SB_STATUS Status = pBoxEx->DeleteContentAsync(DeleteShapshots);
CheckResults(QList<SB_STATUS>() << Status);
}
}
@ -1973,6 +1951,7 @@ QString CSandMan::FormatError(const SB_STATUS& Error)
case SB_BadNameChar: Message = tr("The sandbox name can contain only letters, digits and underscores which are displayed as spaces."); break;
case SB_FailedKillAll: Message = tr("Failed to terminate all processes"); break;
case SB_DeleteProtect: Message = tr("Delete protection is enabled for the sandbox"); break;
case SB_DeleteNotEmpty: Message = tr("All sandbox processes must be stopped before the box content can be deleted"); break;
case SB_DeleteError: Message = tr("Error deleting sandbox folder: %1"); break;
//case SB_RemNotEmpty: Message = tr("A sandbox must be emptied before it can be renamed."); break;
case SB_DelNotEmpty: Message = tr("A sandbox must be emptied before it can be deleted."); break;
@ -2035,7 +2014,7 @@ void CSandMan::OnSysTray(QSystemTrayIcon::ActivationReason Reason)
{
QMap<QString, CSandBoxPtr> Boxes = theAPI->GetAllBoxes();
bool bActiveOnly = theConf->GetBool("Options/TrayActiveOnly", false);
int iSysTrayFilter = theConf->GetInt("Options/SysTrayFilter", 0);
bool bAdded = false;
if (m_pTrayBoxes->topLevelItemCount() == 0)
@ -2056,8 +2035,14 @@ void CSandMan::OnSysTray(QSystemTrayIcon::ActivationReason Reason)
CSandBoxPlus* pBoxEx = qobject_cast<CSandBoxPlus*>(pBox.data());
if (bActiveOnly && pBoxEx->GetActiveProcessCount() == 0)
continue;
if (iSysTrayFilter == 2) { // pinned only
if (!pBox->GetBool("PinToTray", false))
continue;
}
else if (iSysTrayFilter == 1) { // active + pinned
if (pBoxEx->GetActiveProcessCount() == 0 && !pBox->GetBool("PinToTray", false))
continue;
}
QTreeWidgetItem* pItem = OldBoxes.take(pBox->GetName());
if(!pItem)

View File

@ -38,8 +38,6 @@ public:
SB_PROGRESS RecoverFiles(const QList<QPair<QString, QString>>& FileList, int Action = 0);
bool DoDeleteCmd(const CSandBoxPtr &pBox);
bool AddAsyncOp(const CSbieProgressPtr& pProgress, bool bWait = false, const QString& InitialMsg = QString());
static QString FormatError(const SB_STATUS& Error);
static void CheckResults(QList<SB_STATUS> Results);
@ -54,7 +52,7 @@ public:
bool RunSandboxed(const QStringList& Commands, const QString& BoxName, const QString& WrkDir = QString());
QIcon GetBoxIcon(int boxType, bool inUse = false);
QIcon GetBoxIcon(int boxType, bool inUse = false, bool inBusy = false);
QString GetBoxDescription(int boxType);
bool CheckCertificate();
@ -108,7 +106,12 @@ protected:
eMaxColor
};
QMap<EBoxColors, QPair<QIcon, QIcon> > m_BoxIcons;
struct SBoxIcon {
QIcon Empty;
QIcon InUse;
QIcon Busy;
};
QMap<int, SBoxIcon> m_BoxIcons;
class UGlobalHotkeys* m_pHotkeyManager;

View File

@ -195,6 +195,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="BoxJob.cpp" />
<ClCompile Include="Dialogs\MultiErrorDialog.cpp" />
<ClCompile Include="Helpers\FindTool.cpp" />
<ClCompile Include="Helpers\WinAdmin.cpp" />
@ -204,6 +205,7 @@
<ClCompile Include="Models\SbieModel.cpp" />
<ClCompile Include="SandMan.cpp" />
<ClCompile Include="SbiePlusAPI.cpp" />
<ClCompile Include="SbieProcess.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
@ -246,10 +248,12 @@
<QtMoc Include="Models\SbieModel.h" />
<QtMoc Include="Models\TraceModel.h" />
<QtMoc Include="Dialogs\MultiErrorDialog.h" />
<QtMoc Include="BoxJob.h" />
<ClInclude Include="Helpers\FindTool.h" />
<ClInclude Include="Helpers\WinAdmin.h" />
<ClInclude Include="resource.h" />
<QtMoc Include="SbiePlusAPI.h" />
<QtMoc Include="SbieProcess.h" />
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>

View File

@ -138,6 +138,12 @@
<ClCompile Include="Windows\FileBrowserWindow.cpp">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="BoxJob.cpp">
<Filter>SandMan</Filter>
</ClCompile>
<ClCompile Include="SbieProcess.cpp">
<Filter>SandMan</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@ -199,6 +205,12 @@
<QtMoc Include="Windows\FileBrowserWindow.h">
<Filter>Windows</Filter>
</QtMoc>
<QtMoc Include="BoxJob.h">
<Filter>SandMan</Filter>
</QtMoc>
<QtMoc Include="SbieProcess.h">
<Filter>SandMan</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<QtRcc Include="Resources\SandMan.qrc">

View File

@ -1,5 +1,7 @@
#include "stdafx.h"
#include "SbiePlusAPI.h"
#include "SbieProcess.h"
#include "SandMan.h"
#include "..\MiscHelpers\Common\Common.h"
#include <windows.h>
@ -182,6 +184,9 @@ QString CSandBoxPlus::GetStatusStr() const
if (!m_IsEnabled)
return tr("Disabled");
if (!m_StatusStr.isEmpty())
return m_StatusStr;
QStringList Status;
if (IsEmpty())
@ -423,110 +428,105 @@ int CSandBoxPlus::IsLeaderProgram(const QString& ProgName)
return FindInStrList(Programs, ProgName) != Programs.end() ? 1 : 0;
}
///////////////////////////////////////////////////////////////////////////////
// CSbieProcess
//
QString CSbieProcess::ImageTypeToStr(quint32 type)
SB_STATUS CSandBoxPlus::DeleteContentAsync(bool DeleteShapshots, bool bOnAutoDelete)
{
enum {
UNSPECIFIED = 0,
SANDBOXIE_RPCSS,
SANDBOXIE_DCOMLAUNCH,
SANDBOXIE_CRYPTO,
SANDBOXIE_WUAU,
SANDBOXIE_BITS,
SANDBOXIE_SBIESVC,
MSI_INSTALLER,
TRUSTED_INSTALLER,
WUAUCLT,
SHELL_EXPLORER,
INTERNET_EXPLORER,
MOZILLA_FIREFOX,
WINDOWS_MEDIA_PLAYER,
NULLSOFT_WINAMP,
PANDORA_KMPLAYER,
WINDOWS_LIVE_MAIL,
SERVICE_MODEL_REG,
RUNDLL32,
DLLHOST,
DLLHOST_WININET_CACHE,
WISPTIS,
GOOGLE_CHROME,
GOOGLE_UPDATE,
ACROBAT_READER,
OFFICE_OUTLOOK,
OFFICE_EXCEL,
FLASH_PLAYER_SANDBOX,
PLUGIN_CONTAINER,
OTHER_WEB_BROWSER,
OTHER_MAIL_CLIENT,
DLL_IMAGE_MOZILLA_THUNDERBIRD
};
if (GetBool("NeverDelete", false))
return SB_ERR(SB_DeleteProtect);
switch (type)
SB_STATUS Status = TerminateAll();
if (Status.IsError())
return Status;
m_ActiveProcessCount = 0; // to ensure CleanBox will be happy
foreach(const QString& Command, GetTextList("OnBoxDelete", true, false, true)) {
CBoxJob* pJob = new COnDeleteJob(this, Expand(Command));
AddJobToQueue(pJob);
}
CBoxJob* pJob = new CCleanUpJob(this, DeleteShapshots, bOnAutoDelete);
AddJobToQueue(pJob);
return SB_OK;
}
void CSandBoxPlus::AddJobToQueue(CBoxJob* pJob)
{
m_JobQueue.append(QSharedPointer<CBoxJob>(pJob));
if (m_JobQueue.count() == 1)
StartNextJob();
}
void CSandBoxPlus::StartNextJob()
{
next:
Q_ASSERT(m_JobQueue.count() > 0);
Q_ASSERT(m_JobQueue.first()->GetProgress().isNull());
QSharedPointer<CBoxJob> pJob = m_JobQueue.first();
SB_PROGRESS Status = pJob->Start();
if (Status.GetStatus() == OP_ASYNC)
{
case UNSPECIFIED: return tr("");
case SANDBOXIE_RPCSS: return tr("Sbie RpcSs");
case SANDBOXIE_DCOMLAUNCH: return tr("Sbie DcomLaunch");
case SANDBOXIE_CRYPTO: return tr("Sbie Crypto");
case SANDBOXIE_WUAU: return tr("Sbie WuauServ");
case SANDBOXIE_BITS: return tr("Sbie BITS");
case SANDBOXIE_SBIESVC: return tr("Sbie Svc");
case MSI_INSTALLER: return tr("MSI Installer");
case TRUSTED_INSTALLER: return tr("Trusted Installer");
case WUAUCLT: return tr("Windows Update");
case SHELL_EXPLORER: return tr("Windows Explorer");
case INTERNET_EXPLORER: return tr("Internet Explorer");
case MOZILLA_FIREFOX: return tr("Firefox");
case WINDOWS_MEDIA_PLAYER: return tr("Windows Media Player");
case NULLSOFT_WINAMP: return tr("Winamp");
case PANDORA_KMPLAYER: return tr("KMPlayer");
case WINDOWS_LIVE_MAIL: return tr("Windows Live Mail");
case SERVICE_MODEL_REG: return tr("Service Model Reg");
case RUNDLL32: return tr("RunDll32");
case DLLHOST: return tr("DllHost");
case DLLHOST_WININET_CACHE: return tr("DllHost");
case WISPTIS: return tr("Windows Ink Services");
case GOOGLE_CHROME: return tr("Chromium Based");
case GOOGLE_UPDATE: return tr("Google Updater");
case ACROBAT_READER: return tr("Acrobat Reader");
case OFFICE_OUTLOOK: return tr("MS Outlook");
case OFFICE_EXCEL: return tr("MS Excel");
case FLASH_PLAYER_SANDBOX: return tr("Flash Player");
case PLUGIN_CONTAINER: return tr("Firefox Plugin Container");
case OTHER_WEB_BROWSER: return tr("Generic Web Browser");
case OTHER_MAIL_CLIENT: return tr("Generic Mail Client");
case DLL_IMAGE_MOZILLA_THUNDERBIRD: return tr("Thunderbird");
default: return tr("");
m_StatusStr = pJob->GetDescription();
CSbieProgressPtr pProgress = Status.GetValue();
connect(pProgress.data(), SIGNAL(Message(const QString&)), this, SLOT(OnAsyncMessage(const QString&)));
connect(pProgress.data(), SIGNAL(Progress(int)), this, SLOT(OnAsyncProgress(int)));
connect(pProgress.data(), SIGNAL(Finished()), this, SLOT(OnAsyncFinished()));
}
else
{
m_JobQueue.removeFirst();
if (Status.IsError()) {
m_JobQueue.clear();
theGUI->CheckResults(QList<SB_STATUS>() << Status);
return;
}
if (!m_JobQueue.isEmpty())
goto next;
}
}
QString CSbieProcess::GetStatusStr() const
void CSandBoxPlus::OnAsyncFinished()
{
QString Status;
if (m_uTerminated != 0)
Status = tr("Terminated");
//else if (m_bSuspended)
// Status = tr("Suspended");
else {
Status = tr("Running");
if ((m_ProcessFlags & 0x00000002) != 0) // SBIE_FLAG_FORCED_PROCESS
Status.prepend(tr("Forced "));
Q_ASSERT(m_JobQueue.count() > 0);
Q_ASSERT(!m_JobQueue.first()->GetProgress().isNull());
m_StatusStr.clear();
QSharedPointer<CBoxJob> pJob = m_JobQueue.takeFirst();
CSbieProgressPtr pProgress = pJob->GetProgress();
if (pProgress->IsCanceled()) {
m_JobQueue.clear();
return;
}
if(m_SessionId != theAPI->GetSessionID())
Status += tr(" in session %1").arg(m_SessionId);
if (m_bIsWoW64)
Status += " *32";
quint32 ImageType = GetImageType();
if (ImageType != -1) {
QString Type = ImageTypeToStr(ImageType);
if(!Type.isEmpty())
Status += tr(" (%1)").arg(Type);
SB_STATUS Status = pProgress->GetStatus();
if (Status.IsError()) {
m_JobQueue.clear();
theGUI->CheckResults(QList<SB_STATUS>() << Status);
return;
}
return Status;
if (!m_JobQueue.isEmpty())
StartNextJob();
}
void CSandBoxPlus::OnAsyncMessage(const QString& Text)
{
m_StatusStr = Text;
}
void CSandBoxPlus::OnAsyncProgress(int Progress)
{
}
void CSandBoxPlus::OnCancelAsync()
{
if (m_JobQueue.isEmpty())
return;
Q_ASSERT(!m_JobQueue.first()->GetProgress().isNull());
QSharedPointer<CBoxJob> pJob = m_JobQueue.first();
CSbieProgressPtr pProgress = pJob->GetProgress();
pProgress->Cancel();
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "../QSbieAPI/SbieAPI.h"
#include "BoxJob.h"
class CSbiePlusAPI : public CSbieAPI
@ -89,6 +90,15 @@ public:
class COptionsWindow* m_pOptionsWnd;
class CRecoveryWindow* m_pRecoveryWnd;
bool IsBusy() const { return !m_JobQueue.isEmpty(); }
SB_STATUS DeleteContentAsync(bool DeleteShapshots = true, bool bOnAutoDelete = false);
public slots:
void OnAsyncFinished();
void OnAsyncMessage(const QString& Text);
void OnAsyncProgress(int Progress);
void OnCancelAsync();
protected:
friend class CSbiePlusAPI;
virtual bool CheckUnsecureConfig() const;
@ -96,6 +106,11 @@ protected:
virtual bool TestProgramGroup(const QString& Group, const QString& ProgName);
virtual void EditProgramGroup(const QString& Group, const QString& ProgName, bool bSet);
void AddJobToQueue(CBoxJob* pJob);
void StartNextJob();
QList<QSharedPointer<CBoxJob>> m_JobQueue;
bool m_bLogApiFound;
bool m_bINetBlocked;
bool m_bSharesAllowed;
@ -107,40 +122,8 @@ protected:
int m_iUnsecureDebugging;
bool m_SuspendRecovery;
QString m_StatusStr;
QSet<QString> m_RecentPrograms;
};
///////////////////////////////////////////////////////////////////////////////
// CSbieProcess
//
class CSbieProcess : public CBoxedProcess
{
Q_OBJECT
public:
CSbieProcess(quint32 ProcessId, class CSandBox* pBox) : CBoxedProcess(ProcessId, pBox) {}
virtual QString GetStatusStr() const;
virtual void BlockProgram() { GetBox()->BlockProgram(m_ImageName); }
virtual void SetInternetAccess(bool bSet) { GetBox()->SetInternetAccess(m_ImageName, bSet); }
virtual bool HasInternetAccess() { return GetBox()->HasInternetAccess(m_ImageName); }
virtual void SetForcedProgram(bool bSet) { GetBox()->SetForcedProgram(m_ImageName, bSet); }
virtual bool IsForcedProgram() { return GetBox()->IsForcedProgram(m_ImageName); }
virtual void SetLingeringProgram(bool bSet) { GetBox()->SetLingeringProgram(m_ImageName, bSet); }
virtual int IsLingeringProgram() { return GetBox()->IsLingeringProgram(m_ImageName); }
virtual void SetLeaderProgram(bool bSet) { GetBox()->SetLeaderProgram(m_ImageName, bSet); }
virtual int IsLeaderProgram() { return GetBox()->IsLeaderProgram(m_ImageName); }
virtual CSandBoxPlus* GetBox() { return qobject_cast<CSandBoxPlus*>(m_pBox); }
virtual int GetRememberedAction(int Action) { return m_RememberedActions.value(Action, -1); }
virtual void SetRememberedAction(int Action, int retval) { m_RememberedActions.insert(Action, retval); }
static QString ImageTypeToStr(quint32 type);
protected:
QMap<int, int> m_RememberedActions;
};

View File

@ -0,0 +1,107 @@
#include "stdafx.h"
#include "SbieProcess.h"
QString CSbieProcess::ImageTypeToStr(quint32 type)
{
enum {
UNSPECIFIED = 0,
SANDBOXIE_RPCSS,
SANDBOXIE_DCOMLAUNCH,
SANDBOXIE_CRYPTO,
SANDBOXIE_WUAU,
SANDBOXIE_BITS,
SANDBOXIE_SBIESVC,
MSI_INSTALLER,
TRUSTED_INSTALLER,
WUAUCLT,
SHELL_EXPLORER,
INTERNET_EXPLORER,
MOZILLA_FIREFOX,
WINDOWS_MEDIA_PLAYER,
NULLSOFT_WINAMP,
PANDORA_KMPLAYER,
WINDOWS_LIVE_MAIL,
SERVICE_MODEL_REG,
RUNDLL32,
DLLHOST,
DLLHOST_WININET_CACHE,
WISPTIS,
GOOGLE_CHROME,
GOOGLE_UPDATE,
ACROBAT_READER,
OFFICE_OUTLOOK,
OFFICE_EXCEL,
FLASH_PLAYER_SANDBOX,
PLUGIN_CONTAINER,
OTHER_WEB_BROWSER,
OTHER_MAIL_CLIENT,
DLL_IMAGE_MOZILLA_THUNDERBIRD
};
switch (type)
{
case UNSPECIFIED: return tr("");
case SANDBOXIE_RPCSS: return tr("Sbie RpcSs");
case SANDBOXIE_DCOMLAUNCH: return tr("Sbie DcomLaunch");
case SANDBOXIE_CRYPTO: return tr("Sbie Crypto");
case SANDBOXIE_WUAU: return tr("Sbie WuauServ");
case SANDBOXIE_BITS: return tr("Sbie BITS");
case SANDBOXIE_SBIESVC: return tr("Sbie Svc");
case MSI_INSTALLER: return tr("MSI Installer");
case TRUSTED_INSTALLER: return tr("Trusted Installer");
case WUAUCLT: return tr("Windows Update");
case SHELL_EXPLORER: return tr("Windows Explorer");
case INTERNET_EXPLORER: return tr("Internet Explorer");
case MOZILLA_FIREFOX: return tr("Firefox");
case WINDOWS_MEDIA_PLAYER: return tr("Windows Media Player");
case NULLSOFT_WINAMP: return tr("Winamp");
case PANDORA_KMPLAYER: return tr("KMPlayer");
case WINDOWS_LIVE_MAIL: return tr("Windows Live Mail");
case SERVICE_MODEL_REG: return tr("Service Model Reg");
case RUNDLL32: return tr("RunDll32");
case DLLHOST: return tr("DllHost");
case DLLHOST_WININET_CACHE: return tr("DllHost");
case WISPTIS: return tr("Windows Ink Services");
case GOOGLE_CHROME: return tr("Chromium Based");
case GOOGLE_UPDATE: return tr("Google Updater");
case ACROBAT_READER: return tr("Acrobat Reader");
case OFFICE_OUTLOOK: return tr("MS Outlook");
case OFFICE_EXCEL: return tr("MS Excel");
case FLASH_PLAYER_SANDBOX: return tr("Flash Player");
case PLUGIN_CONTAINER: return tr("Firefox Plugin Container");
case OTHER_WEB_BROWSER: return tr("Generic Web Browser");
case OTHER_MAIL_CLIENT: return tr("Generic Mail Client");
case DLL_IMAGE_MOZILLA_THUNDERBIRD: return tr("Thunderbird");
default: return tr("");
}
}
QString CSbieProcess::GetStatusStr() const
{
QString Status;
if (m_uTerminated != 0)
Status = tr("Terminated");
//else if (m_bSuspended)
// Status = tr("Suspended");
else {
Status = tr("Running");
if ((m_ProcessFlags & 0x00000002) != 0) // SBIE_FLAG_FORCED_PROCESS
Status.prepend(tr("Forced "));
}
if(m_SessionId != theAPI->GetSessionID())
Status += tr(" in session %1").arg(m_SessionId);
if (m_bIsWoW64)
Status += " *32";
quint32 ImageType = GetImageType();
if (ImageType != -1) {
QString Type = ImageTypeToStr(ImageType);
if(!Type.isEmpty())
Status += tr(" (%1)").arg(Type);
}
return Status;
}

View File

@ -0,0 +1,32 @@
#pragma once
#include "SbiePlusAPI.h"
class CSbieProcess : public CBoxedProcess
{
Q_OBJECT
public:
CSbieProcess(quint32 ProcessId, class CSandBox* pBox) : CBoxedProcess(ProcessId, pBox) {}
virtual QString GetStatusStr() const;
virtual void BlockProgram() { GetBox()->BlockProgram(m_ImageName); }
virtual void SetInternetAccess(bool bSet) { GetBox()->SetInternetAccess(m_ImageName, bSet); }
virtual bool HasInternetAccess() { return GetBox()->HasInternetAccess(m_ImageName); }
virtual void SetForcedProgram(bool bSet) { GetBox()->SetForcedProgram(m_ImageName, bSet); }
virtual bool IsForcedProgram() { return GetBox()->IsForcedProgram(m_ImageName); }
virtual void SetLingeringProgram(bool bSet) { GetBox()->SetLingeringProgram(m_ImageName, bSet); }
virtual int IsLingeringProgram() { return GetBox()->IsLingeringProgram(m_ImageName); }
virtual void SetLeaderProgram(bool bSet) { GetBox()->SetLeaderProgram(m_ImageName, bSet); }
virtual int IsLeaderProgram() { return GetBox()->IsLeaderProgram(m_ImageName); }
virtual CSandBoxPlus* GetBox() { return qobject_cast<CSandBoxPlus*>(m_pBox); }
virtual int GetRememberedAction(int Action) { return m_RememberedActions.value(Action, -1); }
virtual void SetRememberedAction(int Action, int retval) { m_RememberedActions.insert(Action, retval); }
static QString ImageTypeToStr(quint32 type);
protected:
QMap<int, int> m_RememberedActions;
};

View File

@ -78,6 +78,7 @@ CSbieView::CSbieView(QWidget* parent) : CPanelView(parent)
m_pAddGroupe = m_pMenu->addAction(CSandMan::GetIcon("Group"), tr("Create Box Group"), this, SLOT(OnGroupAction()));
m_pRenGroupe = m_pMenu->addAction(CSandMan::GetIcon("Rename"), tr("Rename Group"), this, SLOT(OnGroupAction()));
m_pDelGroupe = m_pMenu->addAction(CSandMan::GetIcon("Remove"), tr("Remove Group"), this, SLOT(OnGroupAction()));
m_pStopAsync = m_pMenu->addAction(CSandMan::GetIcon("Stop"), tr("Stop Operations"), this, SLOT(OnSandBoxAction()));
m_iMenuTop = m_pMenu->actions().count();
//m_pMenu->addSeparator();
@ -301,7 +302,7 @@ void CSbieView::OnCustomSortByColumn(int column)
}
}
void CSbieView::UpdateMenu()
bool CSbieView::UpdateMenu()
{
QList<QAction*> MenuActions = m_pMenu->actions();
@ -312,6 +313,7 @@ void CSbieView::UpdateMenu()
//}
CSandBoxPtr pBox;
bool bBoxBusy = false;
CBoxedProcessPtr pProcess;
int iProcessCount = 0;
int iSandBoxeCount = 0;
@ -338,23 +340,32 @@ void CSbieView::UpdateMenu()
iSandBoxeCount = -1;
else if (iSandBoxeCount != -1)
iSandBoxeCount++;
auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
if(pBoxEx->IsBusy())
bBoxBusy = true;
}
else
iGroupe++;
}
}
if (bBoxBusy) {
iSandBoxeCount = 0;
iGroupe = 0;
}
for (int i = 0; i < m_iMenuTop; i++)
MenuActions[i]->setVisible(iSandBoxeCount == 0 && iProcessCount == 0);
MenuActions[i]->setVisible(!bBoxBusy && iSandBoxeCount == 0 && iProcessCount == 0);
m_pStopAsync->setVisible(bBoxBusy);
m_pRenGroupe->setVisible(iGroupe == 1 && iSandBoxeCount == 0 && iProcessCount == 0);
m_pDelGroupe->setVisible(!Rows.isEmpty() && iSandBoxeCount == 0 && iProcessCount == 0);
m_pDelGroupe->setVisible(iGroupe > 0 && iSandBoxeCount == 0 && iProcessCount == 0);
for (int i = m_iMenuTop; i < m_iMenuBox; i++)
MenuActions[i]->setVisible(iSandBoxeCount != 0 && iProcessCount == 0);
m_pMenuRun->setEnabled(iSandBoxeCount == 1);
MenuActions[m_iMoveTo]->setVisible(!Rows.isEmpty() && iProcessCount == 0);
MenuActions[m_iMoveTo]->setVisible((iGroupe > 0 || iSandBoxeCount > 0) && iProcessCount == 0);
if(iSandBoxeCount == 1)
UpdateRunMenu(pBox);
@ -428,6 +439,8 @@ void CSbieView::UpdateMenu()
// foreach(QAction * pAction, MenuActions)
// pAction->setEnabled(false);
//}
return bBoxBusy == false;
}
void CSbieView::OnMenu(const QPoint& Point)
@ -435,6 +448,7 @@ void CSbieView::OnMenu(const QPoint& Point)
if (!theAPI->IsConnected())
return;
UpdateMenu();
CPanelView::OnMenu(Point);
}
@ -733,7 +747,15 @@ void CSbieView::OnSandBoxAction(QAction* Action)
QList<CSandBoxPtr> SandBoxes = CSbieView::GetSelectedBoxes();
if (SandBoxes.isEmpty())
return;
if (Action == m_pMenuRunAny)
if (Action == m_pStopAsync)
{
foreach(const CSandBoxPtr & pBox, SandBoxes)
{
auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
pBoxEx->OnCancelAsync();
}
}
else if (Action == m_pMenuRunAny)
{
/*QString Command = ShowRunDialog(SandBoxes.first()->GetName());
if(!Command.isEmpty())
@ -956,6 +978,12 @@ void CSbieView::OnSandBoxAction(QAction* Action)
foreach(const CSandBoxPtr& pBox, SandBoxes)
{
SB_STATUS Status1 = pBox->TerminateAll();
if (Status1.IsError()) {
Results.append(Status1);
continue;
}
SB_PROGRESS Status = pBox->CleanBox();
if (Status.GetStatus() == OP_ASYNC)
theGUI->AddAsyncOp(Status.GetValue(), true, tr("Deleting %1 content").arg(pBox->GetName()));
@ -993,20 +1021,9 @@ void CSbieView::OnSandBoxAction(QAction* Action)
foreach(const CSandBoxPtr &pBox, SandBoxes)
{
if (!theGUI->DoDeleteCmd(pBox))
break;
SB_PROGRESS Status;
if (!DeleteShapshots && pBox->HasSnapshots()) {
QString Default = pBox->GetDefaultSnapshot();
Status = pBox->SelectSnapshot(Default);
}
else // if there are no snapshots jut use the normal cleaning procedure
Status = pBox->CleanBox();
if (Status.GetStatus() == OP_ASYNC)
theGUI->AddAsyncOp(Status.GetValue());
else if (Status.IsError())
auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
SB_STATUS Status = pBoxEx->DeleteContentAsync(DeleteShapshots);
if (Status.IsError())
Results.append(Status);
}
}
@ -1204,7 +1221,7 @@ void CSbieView::OnDoubleClicked(const QModelIndex& index)
void CSbieView::ProcessSelection(const QItemSelection& selected, const QItemSelection& deselected)
{
if (selected.empty()) {
UpdateMenu();
//UpdateMenu();
return;
}
@ -1237,7 +1254,7 @@ void CSbieView::ProcessSelection(const QItemSelection& selected, const QItemSele
selectionModel->select(invalid, QItemSelectionModel::Deselect);
UpdateMenu();
//UpdateMenu();
}
QList<CSandBoxPtr> CSbieView::GetSelectedBoxes()
@ -1322,6 +1339,8 @@ void CSbieView::SelectBox(const QString& Name)
void CSbieView::PopUpMenu(const QString& Name)
{
SelectBox(Name);
if (!UpdateMenu())
return;
m_pMenu2->exec(QCursor::pos());
//m_pMenu2->popup(QCursor::pos());
//OnMenu(QCursor::pos());

View File

@ -63,7 +63,7 @@ protected:
private:
void UpdateMenu();
bool UpdateMenu();
void UpdateGroupMenu();
void RenameGroup(const QString OldName, const QString NewName);
@ -84,6 +84,7 @@ private:
QAction* m_pAddGroupe;
QAction* m_pRenGroupe;
QAction* m_pDelGroupe;
QAction* m_pStopAsync;
int m_iMenuTop;
QMenu* m_pMenuRun;
QAction* m_pMenuRunAny;

View File

@ -56,6 +56,7 @@ void COptionsWindow::CreateGeneral()
connect(ui.btnBorderColor, SIGNAL(clicked(bool)), this, SLOT(OnPickColor()));
connect(ui.spinBorderWidth, SIGNAL(valueChanged(int)), this, SLOT(OnGeneralChanged()));
connect(ui.chkShowForRun, SIGNAL(clicked(bool)), this, SLOT(OnGeneralChanged()));
connect(ui.chkPinToTray, SIGNAL(clicked(bool)), this, SLOT(OnGeneralChanged()));
connect(ui.chkBlockNetShare, SIGNAL(clicked(bool)), this, SLOT(OnGeneralChanged()));
connect(ui.chkBlockNetParam, SIGNAL(clicked(bool)), this, SLOT(OnGeneralChanged()));
@ -106,6 +107,7 @@ void COptionsWindow::LoadGeneral()
ui.spinBorderWidth->setValue(BorderWidth);
ui.chkShowForRun->setChecked(m_pBox->GetBool("ShowForRunIn", true));
ui.chkPinToTray->setChecked(m_pBox->GetBool("PinToTray", false));
ui.chkBlockNetShare->setChecked(m_pBox->GetBool("BlockNetworkFiles", false));
ui.chkBlockNetParam->setChecked(m_pBox->GetBool("BlockNetParam", true));
@ -160,6 +162,7 @@ void COptionsWindow::SaveGeneral()
WriteText("BorderColor", BorderCfg.join(","));
WriteAdvancedCheck(ui.chkShowForRun, "ShowForRunIn", "", "n");
WriteAdvancedCheck(ui.chkPinToTray, "PinToTray", "y", "");
WriteAdvancedCheck(ui.chkBlockNetShare, "BlockNetworkFiles", "y", "");
WriteAdvancedCheck(ui.chkBlockNetParam, "BlockNetParam", "", "n");

View File

@ -3,6 +3,7 @@
#include <QtWidgets/QMainWindow>
#include "ui_PopUpWindow.h"
#include "../SbiePlusAPI.h"
#include "../SbieProcess.h"
class CPopUpEntry: public QWidget
{

View File

@ -110,6 +110,10 @@ CSettingsWindow::CSettingsWindow(QWidget *parent)
ui.cmbSysTray->addItem(tr("Show Plus icon"));
ui.cmbSysTray->addItem(tr("Show Classic icon"));
ui.cmbTrayBoxes->addItem(tr("All Boxes"));
ui.cmbTrayBoxes->addItem(tr("Active + Pinned"));
ui.cmbTrayBoxes->addItem(tr("Pinned Only"));
ui.cmbOnClose->addItem(tr("Close to Tray"), "ToTray");
ui.cmbOnClose->addItem(tr("Prompt before Close"), "Prompt");
ui.cmbOnClose->addItem(tr("Close"), "Close");
@ -120,6 +124,7 @@ CSettingsWindow::CSettingsWindow(QWidget *parent)
LoadSettings();
connect(ui.cmbSysTray, SIGNAL(currentIndexChanged(int)), this, SLOT(OnChange()));
connect(ui.cmbTrayBoxes, SIGNAL(currentIndexChanged(int)), this, SLOT(OnChange()));
connect(ui.cmbOnClose, SIGNAL(currentIndexChanged(int)), this, SLOT(OnChange()));
m_FeaturesChanged = false;
@ -256,7 +261,7 @@ void CSettingsWindow::LoadSettings()
ui.cmbSysTray->setCurrentIndex(theConf->GetInt("Options/SysTrayIcon", 1));
ui.chkTrayActiveOnly->setChecked(theConf->GetBool("Options/TrayActiveOnly", false));
ui.cmbTrayBoxes->setCurrentIndex(theConf->GetInt("Options/SysTrayFilter", 0));
ui.cmbOnClose->setCurrentIndex(ui.cmbOnClose->findData(theConf->GetString("Options/OnClose", "ToTray")));
@ -408,7 +413,7 @@ void CSettingsWindow::SaveSettings()
theConf->SetValue("Options/WatchIni", ui.chkWatchConfig->isChecked());
theConf->SetValue("Options/SysTrayIcon", ui.cmbSysTray->currentIndex());
theConf->SetValue("Options/TrayActiveOnly", ui.chkTrayActiveOnly->isChecked());
theConf->SetValue("Options/SysTrayFilter", ui.cmbTrayBoxes->currentIndex());
theConf->SetValue("Options/OnClose", ui.cmbOnClose->currentData());