From 28fea2e0bc35684621aa5788a8d375739743b0b0 Mon Sep 17 00:00:00 2001 From: DavidXanatos <3890945+DavidXanatos@users.noreply.github.com> Date: Sun, 15 Sep 2024 14:26:58 +0200 Subject: [PATCH] 1.14.9 --- SandboxiePlus/QSbieAPI/Sandboxie/SandBox.cpp | 6 ++ SandboxiePlus/QSbieAPI/Sandboxie/SandBox.h | 1 + SandboxiePlus/SandMan/Forms/CompressDialog.ui | 36 +++++--- SandboxiePlus/SandMan/Forms/ExtractDialog.ui | 86 +++++++++++++++++++ SandboxiePlus/SandMan/SandMan.pri | 3 + SandboxiePlus/SandMan/SandMan.vcxproj | 3 + SandboxiePlus/SandMan/SandMan.vcxproj.filters | 11 ++- SandboxiePlus/SandMan/SbiePlusAPI.cpp | 6 +- SandboxiePlus/SandMan/SbiePlusAPI.h | 2 +- SandboxiePlus/SandMan/Views/SbieView.cpp | 34 ++++---- .../SandMan/Windows/CompressDialog.cpp | 16 ++++ .../SandMan/Windows/CompressDialog.h | 4 + .../SandMan/Windows/ExtractDialog.cpp | 72 ++++++++++++++++ SandboxiePlus/SandMan/Windows/ExtractDialog.h | 23 +++++ 14 files changed, 267 insertions(+), 36 deletions(-) create mode 100644 SandboxiePlus/SandMan/Forms/ExtractDialog.ui create mode 100644 SandboxiePlus/SandMan/Windows/ExtractDialog.cpp create mode 100644 SandboxiePlus/SandMan/Windows/ExtractDialog.h diff --git a/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.cpp b/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.cpp index 09e824a8..26ae0a7c 100644 --- a/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.cpp +++ b/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.cpp @@ -141,6 +141,12 @@ void CSandBox::SetBoxPaths(const QString& FilePath, const QString& RegPath, cons m_IpcPath = IpcPath; } +void CSandBox::SetFileRoot(const QString& FilePath) +{ + SetText("FileRootPath", FilePath); + m_pAPI->UpdateBoxPaths(this); +} + SB_STATUS CSandBox::RunStart(const QString& Command, bool Elevated) { #ifdef _DEBUG diff --git a/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.h b/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.h index 5b7e3ddb..fef08c30 100644 --- a/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.h +++ b/SandboxiePlus/QSbieAPI/Sandboxie/SandBox.h @@ -43,6 +43,7 @@ public: virtual void UpdateDetails(); virtual void SetBoxPaths(const QString& FilePath, const QString& RegPath, const QString& IpcPath); + virtual void SetFileRoot(const QString& FilePath); virtual QString GetFileRoot() const { return m_FilePath; } virtual QString GetRegRoot() const { return m_RegPath; } virtual QString GetIpcRoot() const { return m_IpcPath; } diff --git a/SandboxiePlus/SandMan/Forms/CompressDialog.ui b/SandboxiePlus/SandMan/Forms/CompressDialog.ui index 3002f294..fb11dabe 100644 --- a/SandboxiePlus/SandMan/Forms/CompressDialog.ui +++ b/SandboxiePlus/SandMan/Forms/CompressDialog.ui @@ -16,9 +16,6 @@ - - - @@ -32,14 +29,10 @@ - - - - Compression - - + + - + When selected you will be prompted for a password after clicking OK @@ -49,7 +42,7 @@ - + Solid archiving improves compression ratios by treating multiple files as a single continuous data block. Ideal for a large number of small files, it makes the archive more compact but may increase the time required for extracting individual files. @@ -59,10 +52,27 @@ - + + + + Compression + + + + + + + + 0 + 0 + + + + + - Export Sandbox to a 7z or Zip archive, Choose Your Compression Rate and Customize Additional Compression Settings. + Export Sandbox to a archive, Choose Your Compression Rate and Customize Additional Compression Settings. true diff --git a/SandboxiePlus/SandMan/Forms/ExtractDialog.ui b/SandboxiePlus/SandMan/Forms/ExtractDialog.ui new file mode 100644 index 00000000..62949f84 --- /dev/null +++ b/SandboxiePlus/SandMan/Forms/ExtractDialog.ui @@ -0,0 +1,86 @@ + + + ExtractDialog + + + + 0 + 0 + 424 + 207 + + + + Extract Files + + + + + + + + + + + Export Sandbox from an archive + + + true + + + + + + + Import Sandbox Name + + + + + + + Box Root Folder + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + ... + + + + + + + true + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + diff --git a/SandboxiePlus/SandMan/SandMan.pri b/SandboxiePlus/SandMan/SandMan.pri index ca9809f0..5ff41db1 100644 --- a/SandboxiePlus/SandMan/SandMan.pri +++ b/SandboxiePlus/SandMan/SandMan.pri @@ -38,6 +38,7 @@ HEADERS += ./stdafx.h \ ./Wizards/BoxAssistant.h \ ./Windows/BoxImageWindow.h \ ./Windows/CompressDialog.h \ + ./Windows/ExtractDialog.h \ ./Engine/BoxEngine.h \ ./Engine/ScriptManager.h \ ./Engine/BoxObject.h \ @@ -88,6 +89,7 @@ SOURCES += ./main.cpp \ ./Wizards/BoxAssistant.cpp \ ./Windows/BoxImageWindow.cpp \ ./Windows/CompressDialog.cpp \ + ./Windows/ExtractDialog.cpp \ ./Engine/BoxEngine.cpp \ ./Engine/ScriptManager.cpp \ ./Engine/BoxObject.cpp \ @@ -105,6 +107,7 @@ FORMS += ./Forms/SelectBoxWindow.ui \ ./Forms/SnapshotsWindow.ui \ ./Forms/BoxImageWindow.ui \ ./Forms/CompressDialog.ui \ + ./Forms/ExtractDialog.ui \ ./Forms/TestProxyDialog.ui TRANSLATIONS += sandman_de.ts \ diff --git a/SandboxiePlus/SandMan/SandMan.vcxproj b/SandboxiePlus/SandMan/SandMan.vcxproj index 0909ab7a..bb436e28 100644 --- a/SandboxiePlus/SandMan/SandMan.vcxproj +++ b/SandboxiePlus/SandMan/SandMan.vcxproj @@ -348,6 +348,7 @@ + true true @@ -443,6 +444,7 @@ + @@ -504,6 +506,7 @@ + diff --git a/SandboxiePlus/SandMan/SandMan.vcxproj.filters b/SandboxiePlus/SandMan/SandMan.vcxproj.filters index dc7afdb0..c2a47302 100644 --- a/SandboxiePlus/SandMan/SandMan.vcxproj.filters +++ b/SandboxiePlus/SandMan/SandMan.vcxproj.filters @@ -234,6 +234,9 @@ Windows + + Windows + @@ -385,6 +388,9 @@ Windows + + Windows + @@ -428,7 +434,10 @@ Form Files - Form Files + Form Files + + + Form Files diff --git a/SandboxiePlus/SandMan/SbiePlusAPI.cpp b/SandboxiePlus/SandMan/SbiePlusAPI.cpp index 9a747510..70a5ade9 100644 --- a/SandboxiePlus/SandMan/SbiePlusAPI.cpp +++ b/SandboxiePlus/SandMan/SbiePlusAPI.cpp @@ -332,15 +332,13 @@ void CSandBoxPlus::ImportBoxAsync(const CSbieProgressPtr& pProgress, const QStri pProgress->Finish(Status); } -SB_PROGRESS CSandBoxPlus::ImportBox(const QString& FileName, const QString& RootFolder, const QString& Password) +SB_PROGRESS CSandBoxPlus::ImportBox(const QString& FileName, const QString& Password) { if (!CArchive::IsInit()) return SB_ERR((ESbieMsgCodes)SBX_7zNotReady); CSbieProgressPtr pProgress = CSbieProgressPtr(new CSbieProgress()); - QString filepath = RootFolder.isEmpty()?m_FilePath:RootFolder; - - QtConcurrent::run(CSandBoxPlus::ImportBoxAsync, pProgress, FileName, filepath, m_Name, Password); + QtConcurrent::run(CSandBoxPlus::ImportBoxAsync, pProgress, FileName, m_FilePath, m_Name, Password); return SB_PROGRESS(OP_ASYNC, pProgress); } diff --git a/SandboxiePlus/SandMan/SbiePlusAPI.h b/SandboxiePlus/SandMan/SbiePlusAPI.h index b9970b41..aef287e1 100644 --- a/SandboxiePlus/SandMan/SbiePlusAPI.h +++ b/SandboxiePlus/SandMan/SbiePlusAPI.h @@ -75,7 +75,7 @@ public: virtual QString GetDisplayName() const; SB_PROGRESS ExportBox(const QString& FileName, const QString& Password = "", int Level = 5, bool Solid = false); - SB_PROGRESS ImportBox(const QString& FileName, const QString& RootFolder,const QString& Password); + SB_PROGRESS ImportBox(const QString& FileName, const QString& Password); virtual void UpdateDetails(); diff --git a/SandboxiePlus/SandMan/Views/SbieView.cpp b/SandboxiePlus/SandMan/Views/SbieView.cpp index 5027e950..94fd7440 100644 --- a/SandboxiePlus/SandMan/Views/SbieView.cpp +++ b/SandboxiePlus/SandMan/Views/SbieView.cpp @@ -17,6 +17,7 @@ #include "../MiscHelpers/Archive/Archive.h" #include "../Windows/SettingsWindow.h" #include "../Windows/CompressDialog.h" +#include "../Windows/ExtractDialog.h" #include "qt_windows.h" #include "qwindowdefs_win.h" @@ -1071,27 +1072,24 @@ QString CSbieView::ImportSandbox() StrPair PathName = Split2(Path, "/", true); StrPair NameEx = Split2(PathName.second, ".", true); QString Name = NameEx.first; + + CExtractDialog optWnd(Name, this); + if (!theGUI->SafeExec(&optWnd) == 1) + return ""; + Name = optWnd.GetName(); + QString BoxRoot = optWnd.GetRoot(); CSandBoxPtr pBox; - for (;;) { - pBox = theAPI->GetBoxByName(Name); - if (pBox.isNull()) - break; - Name = QInputDialog::getText(this, "Sandboxie-Plus", tr("This name is already in use, please select an alternative box name"), QLineEdit::Normal, Name); - if (Name.isEmpty()) - return ""; - } - SB_PROGRESS Status = theAPI->CreateBox(Name); if (!Status.IsError()) { pBox = theAPI->GetBoxByName(Name); if (pBox) { - QString rootname = ""; - if (QMessageBox::question(this, tr("Importing Sandbox"), tr("Do you want to select custom root folder?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { - rootname=QFileDialog::getExistingDirectory(this); - } + auto pBoxEx = pBox.objectCast(); + if (!BoxRoot.isEmpty()) + pBox->SetFileRoot(BoxRoot); + if (!Password.isEmpty()) { Status = pBoxEx->ImBoxCreate(ImageSize / 1024, Password); if (!Status.IsError()) @@ -1099,11 +1097,13 @@ QString CSbieView::ImportSandbox() } if (!Status.IsError()) - Status = pBoxEx->ImportBox(Path,rootname,Password); - if(!rootname.isEmpty()) - pBox->SetText("FileRootPath", rootname); + Status = pBoxEx->ImportBox(Path, Password); + + // always overwirte restored FileRootPath + pBox->SetText("FileRootPath", BoxRoot); } } + if (Status.GetStatus() == OP_ASYNC) { Status = theGUI->AddAsyncOp(Status.GetValue(), true, tr("Importing: %1").arg(Path)); if (Status.IsError()) { @@ -1405,7 +1405,7 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList& SandB Password = pwWnd.GetPassword(); } - QString Path = QFileDialog::getSaveFileName(this, tr("Select file name"), SandBoxes.first()->GetName() + ".7z", tr("7-zip Archive (*.7z);;Zip Archive (*.zip)")); + QString Path = QFileDialog::getSaveFileName(this, tr("Select file name"), SandBoxes.first()->GetName() + optWnd.GetFormat(), tr("7-Zip Archive (*.7z);;Zip Archive (*.zip)")); if (Path.isEmpty()) return; diff --git a/SandboxiePlus/SandMan/Windows/CompressDialog.cpp b/SandboxiePlus/SandMan/Windows/CompressDialog.cpp index 0e2e9eb0..02277a60 100644 --- a/SandboxiePlus/SandMan/Windows/CompressDialog.cpp +++ b/SandboxiePlus/SandMan/Windows/CompressDialog.cpp @@ -22,6 +22,11 @@ CCompressDialog::CCompressDialog(QWidget *parent) ui.setupUi(this); this->setWindowTitle(tr("Sandboxie-Plus - Sandbox Export")); + connect(ui.cmbFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(OnFormatChanged(int))); + + ui.cmbFormat->addItem(tr("7-Zip"), ".7z"); + ui.cmbFormat->addItem(tr("Zip"), ".zip"); + ui.cmbCompression->addItem(tr("Store"), 0); ui.cmbCompression->addItem(tr("Fastest"), 1); ui.cmbCompression->addItem(tr("Fast"), 3); @@ -41,6 +46,17 @@ CCompressDialog::~CCompressDialog() //theConf->SetBlob("CompressDialog/Window_Geometry", saveGeometry()); } +void CCompressDialog::OnFormatChanged(int index) +{ + ui.chkSolid->setEnabled(index == 0); + ui.chkEncrypt->setEnabled(index == 0); +} + +QString CCompressDialog::GetFormat() +{ + return ui.cmbFormat->currentData().toString(); +} + int CCompressDialog::GetLevel() { return ui.cmbCompression->currentData().toInt(); diff --git a/SandboxiePlus/SandMan/Windows/CompressDialog.h b/SandboxiePlus/SandMan/Windows/CompressDialog.h index 84a05fe5..a86aa2d2 100644 --- a/SandboxiePlus/SandMan/Windows/CompressDialog.h +++ b/SandboxiePlus/SandMan/Windows/CompressDialog.h @@ -12,12 +12,16 @@ public: CCompressDialog(QWidget *parent = Q_NULLPTR); ~CCompressDialog(); + QString GetFormat(); int GetLevel(); bool MakeSolid(); void SetMustEncrypt(); bool UseEncryption(); +private slots: + void OnFormatChanged(int index); + private: Ui::CompressDialog ui; }; diff --git a/SandboxiePlus/SandMan/Windows/ExtractDialog.cpp b/SandboxiePlus/SandMan/Windows/ExtractDialog.cpp new file mode 100644 index 00000000..c862ce92 --- /dev/null +++ b/SandboxiePlus/SandMan/Windows/ExtractDialog.cpp @@ -0,0 +1,72 @@ +#include "stdafx.h" +#include "ExtractDialog.h" +#include "SandMan.h" +#include "../MiscHelpers/Common/Settings.h" +#include "../MiscHelpers/Common/Common.h" + + +CExtractDialog::CExtractDialog(const QString& Name, QWidget *parent) + : QDialog(parent) +{ + Qt::WindowFlags flags = windowFlags(); + flags |= Qt::CustomizeWindowHint; + //flags &= ~Qt::WindowContextHelpButtonHint; + //flags &= ~Qt::WindowSystemMenuHint; + //flags &= ~Qt::WindowMinMaxButtonsHint; + //flags |= Qt::WindowMinimizeButtonHint; + //flags &= ~Qt::WindowCloseButtonHint; + flags &= ~Qt::WindowContextHelpButtonHint; + //flags &= ~Qt::WindowSystemMenuHint; + setWindowFlags(flags); + + ui.setupUi(this); + this->setWindowTitle(tr("Sandboxie-Plus - Sandbox Import")); + + ui.txtName->setText(Name); + + QString Location = theAPI->GetGlobalSettings()->GetText("FileRootPath", "\\??\\%SystemDrive%\\Sandbox\\%USER%\\%SANDBOX%"); + ui.cmbRoot->addItem(Location/*.replace("%SANDBOX%", field("boxName").toString())*/); + QStringList StdLocations = QStringList() + << "\\??\\%SystemDrive%\\Sandbox\\%USER%\\%SANDBOX%" + << "\\??\\%SystemDrive%\\Sandbox\\%SANDBOX%" + << "\\??\\%SystemDrive%\\Users\\%USER%\\Sandbox\\%SANDBOX%"; + foreach(auto StdLocation, StdLocations) { + if (StdLocation != Location) + ui.cmbRoot->addItem(StdLocation); + } + + connect(ui.btnRoot, &QPushButton::clicked, [&]() { + QString FilePath = QFileDialog::getExistingDirectory(this, tr("Select Directory")); + if (!FilePath.isEmpty()) + ui.cmbRoot->setCurrentText(FilePath.replace("/", "\\")); + }); + + connect(ui.buttonBox, SIGNAL(accepted()), SLOT(OnAccept())); + connect(ui.buttonBox, SIGNAL(rejected()), SLOT(reject())); + + //restoreGeometry(theConf->GetBlob("ExtractDialog/Window_Geometry")); +} + +CExtractDialog::~CExtractDialog() +{ + //theConf->SetBlob("ExtractDialog/Window_Geometry", saveGeometry()); +} + +void CExtractDialog::OnAccept() +{ + CSandBoxPtr pBox = theAPI->GetBoxByName(ui.txtName->text()); + if (!pBox.isNull()) { + QMessageBox::warning(this, "Sandboxie-Plus", tr("This name is already in use, please select an alternative box name")); + return; + } + + accept(); +} + +QString CExtractDialog::GetRoot() const +{ + QString Location = theAPI->GetGlobalSettings()->GetText("FileRootPath", "\\??\\%SystemDrive%\\Sandbox\\%USER%\\%SANDBOX%"); + if (Location == ui.cmbRoot->currentText()) + return ""; + return ui.cmbRoot->currentText(); +} \ No newline at end of file diff --git a/SandboxiePlus/SandMan/Windows/ExtractDialog.h b/SandboxiePlus/SandMan/Windows/ExtractDialog.h new file mode 100644 index 00000000..53f437ac --- /dev/null +++ b/SandboxiePlus/SandMan/Windows/ExtractDialog.h @@ -0,0 +1,23 @@ +#pragma once + +#include +#include "ui_ExtractDialog.h" +#include "SbiePlusAPI.h" + +class CExtractDialog : public QDialog +{ + Q_OBJECT + +public: + CExtractDialog(const QString& Name, QWidget *parent = Q_NULLPTR); + ~CExtractDialog(); + + QString GetName() const { return ui.txtName->text(); } + QString GetRoot() const; + +private slots: + void OnAccept(); + +private: + Ui::ExtractDialog ui; +};