This submission completes the foreground UI and the data writing part of the“On Terminate” trigger, but it remains to complete the actual trigger part.

This commit is contained in:
Yeyixiao 2024-02-24 23:15:59 +08:00
parent c64fa1c147
commit 80b3308220
3 changed files with 150 additions and 98 deletions

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>715</width> <width>785</width>
<height>526</height> <height>526</height>
</rect> </rect>
</property> </property>
@ -3732,7 +3732,7 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
</font> </font>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>4</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tabMisc"> <widget class="QWidget" name="tabMisc">
<attribute name="title"> <attribute name="title">
@ -3849,8 +3849,8 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
<property name="bottomMargin"> <property name="bottomMargin">
<number>3</number> <number>3</number>
</property> </property>
<item row="15" column="1"> <item row="21" column="1">
<widget class="QToolButton" name="btnAddDeleteCmd"> <widget class="QToolButton" name="btnDelAuto">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -3863,11 +3863,21 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
<height>23</height> <height>23</height>
</size> </size>
</property> </property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLabel" name="label_68">
<property name="toolTip"> <property name="toolTip">
<string>This command will be run before the box content will be deleted</string> <string>These commands are run UNBOXED just before the box content is deleted</string>
</property> </property>
<property name="text"> <property name="text">
<string>Run Command</string> <string>On File Recovery</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
@ -3890,7 +3900,46 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" rowspan="18"> <item row="1" column="1">
<widget class="QLabel" name="label_66">
<property name="toolTip">
<string>These commands are executed only when a box is initialized. To make them run again, the box content must be deleted.</string>
</property>
<property name="text">
<string>On Box Init</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="19" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="16" column="1">
<widget class="QLabel" name="label_67">
<property name="toolTip">
<string>These commands are run UNBOXED just before the box content is deleted</string>
</property>
<property name="text">
<string>On Delete Content</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="21">
<widget class="QTreeWidget" name="treeTriggers"> <widget class="QTreeWidget" name="treeTriggers">
<property name="sortingEnabled"> <property name="sortingEnabled">
<bool>true</bool> <bool>true</bool>
@ -3913,26 +3962,29 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
</widget> </widget>
</item> </item>
<item row="11" column="1"> <item row="11" column="1">
<widget class="QLabel" name="label_68"> <widget class="QLabel" name="label_18">
<property name="toolTip"> <property name="toolTip">
<string>These commands are run UNBOXED just before the box content is deleted</string> <string>This command runs after all processes in the sandbox have finished.</string>
</property> </property>
<property name="text"> <property name="text">
<string>On File Recovery</string> <string>On Box Terminate</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="17" column="1"> <item row="0" column="0">
<widget class="QCheckBox" name="chkShowTriggersTmpl"> <widget class="QLabel" name="label_32">
<property name="text"> <property name="text">
<string>Show Templates</string> <string>Here you can specify actions to be executed automatically on various box events.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="1"> <item row="15" column="1">
<widget class="QToolButton" name="btnAddRecoveryCmd"> <widget class="QToolButton" name="btnAddRecoveryCmd">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -3954,80 +4006,6 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
</property> </property>
</widget> </widget>
</item> </item>
<item row="18" column="1">
<widget class="QToolButton" name="btnDelAuto">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="16" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_66">
<property name="toolTip">
<string>These commands are executed only when a box is initialized. To make them run again, the box content must be deleted.</string>
</property>
<property name="text">
<string>On Box Init</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_32">
<property name="text">
<string>Here you can specify actions to be executed automatically on various box events.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QToolButton" name="btnAddAutoExec">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Run Command</string>
</property>
</widget>
</item>
<item row="8" column="1"> <item row="8" column="1">
<widget class="QLabel" name="label_33"> <widget class="QLabel" name="label_33">
<property name="toolTip"> <property name="toolTip">
@ -4041,6 +4019,35 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
</property> </property>
</widget> </widget>
</item> </item>
<item row="18" column="1">
<widget class="QToolButton" name="btnAddDeleteCmd">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>This command will be run before the box content will be deleted</string>
</property>
<property name="text">
<string>Run Command</string>
</property>
</widget>
</item>
<item row="20" column="1">
<widget class="QCheckBox" name="chkShowTriggersTmpl">
<property name="text">
<string>Show Templates</string>
</property>
</widget>
</item>
<item row="10" column="1"> <item row="10" column="1">
<widget class="QToolButton" name="btnAddAutoSvc"> <widget class="QToolButton" name="btnAddAutoSvc">
<property name="sizePolicy"> <property name="sizePolicy">
@ -4060,16 +4067,41 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
</property> </property>
</widget> </widget>
</item> </item>
<item row="13" column="1"> <item row="2" column="1">
<widget class="QLabel" name="label_67"> <widget class="QToolButton" name="btnAddAutoExec">
<property name="toolTip"> <property name="sizePolicy">
<string>These commands are run UNBOXED just before the box content is deleted</string> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property> </property>
<property name="text"> <property name="text">
<string>On Delete Content</string> <string>Run Command</string>
</property> </property>
<property name="alignment"> </widget>
<set>Qt::AlignCenter</set> </item>
<item row="12" column="1">
<widget class="QToolButton" name="btnAddTerminateCmd">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Run Command</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -4473,8 +4505,8 @@ instead of &quot;*&quot;.</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>98</width> <width>92</width>
<height>28</height> <height>16</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="dbgLayout"> <layout class="QGridLayout" name="dbgLayout">

View File

@ -89,6 +89,7 @@ void COptionsWindow::CreateAdvanced()
connect(ui.btnAddAutoExec, SIGNAL(clicked(bool)), this, SLOT(OnAddAutoExec())); connect(ui.btnAddAutoExec, SIGNAL(clicked(bool)), this, SLOT(OnAddAutoExec()));
connect(ui.btnAddRecoveryCmd, SIGNAL(clicked(bool)), this, SLOT(OnAddRecoveryCheck())); connect(ui.btnAddRecoveryCmd, SIGNAL(clicked(bool)), this, SLOT(OnAddRecoveryCheck()));
connect(ui.btnAddDeleteCmd, SIGNAL(clicked(bool)), this, SLOT(OnAddDeleteCmd())); connect(ui.btnAddDeleteCmd, SIGNAL(clicked(bool)), this, SLOT(OnAddDeleteCmd()));
connect(ui.btnAddTerminateCmd, SIGNAL(clicked(bool)), this, SLOT(OnAddTerminateCmd()));
connect(ui.btnDelAuto, SIGNAL(clicked(bool)), this, SLOT(OnDelAuto())); connect(ui.btnDelAuto, SIGNAL(clicked(bool)), this, SLOT(OnDelAuto()));
connect(ui.chkShowTriggersTmpl, SIGNAL(clicked(bool)), this, SLOT(OnShowTriggersTmpl())); connect(ui.chkShowTriggersTmpl, SIGNAL(clicked(bool)), this, SLOT(OnShowTriggersTmpl()));
@ -411,6 +412,7 @@ void COptionsWindow::SaveAdvanced()
QStringList RecoveryCheck; QStringList RecoveryCheck;
QStringList DeleteCommand; QStringList DeleteCommand;
QStringList AutoExec; QStringList AutoExec;
QStringList TerminateCommand;
for (int i = 0; i < ui.treeTriggers->topLevelItemCount(); i++) { for (int i = 0; i < ui.treeTriggers->topLevelItemCount(); i++) {
QTreeWidgetItem* pItem = ui.treeTriggers->topLevelItem(i); QTreeWidgetItem* pItem = ui.treeTriggers->topLevelItem(i);
switch (pItem->data(0, Qt::UserRole).toInt()) switch (pItem->data(0, Qt::UserRole).toInt())
@ -420,6 +422,7 @@ void COptionsWindow::SaveAdvanced()
case eAutoExec: AutoExec.append(pItem->text(2)); break; case eAutoExec: AutoExec.append(pItem->text(2)); break;
case eRecoveryCheck: RecoveryCheck.append(pItem->text(2)); break; case eRecoveryCheck: RecoveryCheck.append(pItem->text(2)); break;
case eDeleteCmd: DeleteCommand.append(pItem->text(2)); break; case eDeleteCmd: DeleteCommand.append(pItem->text(2)); break;
case eTerminateCmd: TerminateCommand.append(pItem->text(2)); break;
} }
} }
WriteTextList("StartProgram", StartProgram); WriteTextList("StartProgram", StartProgram);
@ -427,6 +430,7 @@ void COptionsWindow::SaveAdvanced()
WriteTextList("AutoExec", AutoExec); WriteTextList("AutoExec", AutoExec);
WriteTextList("OnFileRecovery", RecoveryCheck); WriteTextList("OnFileRecovery", RecoveryCheck);
WriteTextList("OnBoxDelete", DeleteCommand); WriteTextList("OnBoxDelete", DeleteCommand);
WriteTextList("OnBoxTerimate", TerminateCommand);
// //
@ -874,6 +878,9 @@ void COptionsWindow::AddTriggerItem(const QString& Value, ETriggerAction Type, c
pItem->setText(0, tr("On Delete Content")); pItem->setText(0, tr("On Delete Content"));
pItem->setText(1, tr("Run Command")); pItem->setText(1, tr("Run Command"));
break; break;
case eTerminateCmd:
pItem->setText(0, tr("On Terminate"));
pItem->setText(1, tr("Run Command"));
} }
pItem->setText(2, Value); pItem->setText(2, Value);
pItem->setFlags(pItem->flags() | Qt::ItemIsEditable); pItem->setFlags(pItem->flags() | Qt::ItemIsEditable);
@ -924,6 +931,17 @@ void COptionsWindow::OnAddDeleteCmd()
OnOptChanged(); OnOptChanged();
} }
void COptionsWindow::OnAddTerminateCmd()
{
QString Value = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please enter the command line to be executed"), QLineEdit::Normal);
if (Value.isEmpty())
return;
AddTriggerItem(Value, eTerminateCmd);
m_AdvancedChanged = true;
OnOptChanged();
}
void COptionsWindow::OnAddRecoveryCheck() void COptionsWindow::OnAddRecoveryCheck()
{ {
QString Value = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please enter the command line to be executed"), QLineEdit::Normal); QString Value = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please enter the command line to be executed"), QLineEdit::Normal);

View File

@ -191,6 +191,7 @@ private slots:
void OnAddAutoExec(); void OnAddAutoExec();
void OnAddRecoveryCheck(); void OnAddRecoveryCheck();
void OnAddDeleteCmd(); void OnAddDeleteCmd();
void OnAddTerminateCmd();
void OnDelAuto(); void OnDelAuto();
void OnAddProcess(); void OnAddProcess();
@ -334,7 +335,8 @@ public:
eOnStartSvc, eOnStartSvc,
eAutoExec, eAutoExec,
eRecoveryCheck, eRecoveryCheck,
eDeleteCmd eDeleteCmd,
eTerminateCmd
}; };
static QString AccessTypeToName(EAccessEntry Type); static QString AccessTypeToName(EAccessEntry Type);