Sandboxie/SandboxiePlus/SandMan/SandMan.h

430 lines
11 KiB
C
Raw Normal View History

2021-10-16 16:19:51 +01:00
#pragma once
#include <QtWidgets/QMainWindow>
#include "../MiscHelpers/Common/Settings.h"
#include "../MiscHelpers/Common/TreeViewEx.h"
#include "../MiscHelpers/Common/PanelView.h"
#include "../MiscHelpers/Common/ProgressDialog.h"
#include "../MiscHelpers/Common/NetworkAccessManager.h"
#include <QTranslator>
#include "Windows/PopUpWindow.h"
#include "../version.h"
//#include "../QSbieAPI/SbieAPI.h"
#include "SbiePlusAPI.h"
class CSbieView;
2022-07-11 18:30:09 +01:00
class CFileView;
2021-10-16 16:19:51 +01:00
class CBoxBorder;
class CSbieTemplates;
class CTraceView;
class CSandMan : public QMainWindow
{
Q_OBJECT
public:
CSandMan(QWidget *parent = Q_NULLPTR);
virtual ~CSandMan();
CSbieTemplates* GetCompat() { return m_SbieTemplates; }
static QString GetVersion();
2022-06-08 16:23:19 +01:00
SB_PROGRESS RecoverFiles(const QString& BoxName, const QList<QPair<QString, QString>>& FileList, int Action = 0);
2021-10-16 16:19:51 +01:00
2022-02-18 19:09:35 +00:00
enum EDelMode {
eDefault,
eAuto,
eForDelete
};
SB_STATUS DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, bool DeleteShapshots = true);
2022-02-13 11:55:52 +00:00
2022-02-18 19:09:35 +00:00
SB_STATUS AddAsyncOp(const CSbieProgressPtr& pProgress, bool bWait = false, const QString& InitialMsg = QString());
2021-10-16 16:19:51 +01:00
static QString FormatError(const SB_STATUS& Error);
static void CheckResults(QList<SB_STATUS> Results);
2022-11-05 13:53:44 +00:00
static QIcon GetIcon(const QString& Name, int iAction = 1);
2021-10-16 16:19:51 +01:00
bool IsFullyPortable();
2022-07-09 10:46:07 +01:00
bool IsShowHidden() { return m_pShowHidden && m_pShowHidden->isChecked(); }
bool KeepTerminated() { return m_pKeepTerminated && m_pKeepTerminated->isChecked(); }
bool ShowAllSessions() { return m_pShowAllSessions && m_pShowAllSessions->isChecked(); }
bool IsDisableRecovery() {return m_pDisableRecovery && m_pDisableRecovery->isChecked();}
bool IsDisableMessages() {return m_pDisableMessages && m_pDisableMessages->isChecked();}
2021-10-16 16:19:51 +01:00
CSbieView* GetBoxView() { return m_pBoxView; }
2022-07-13 16:00:03 +01:00
CFileView* GetFileView() { return m_pFileView; }
2021-10-16 16:19:51 +01:00
2022-02-02 18:31:03 +00:00
bool RunSandboxed(const QStringList& Commands, const QString& BoxName, const QString& WrkDir = QString());
2021-10-16 16:19:51 +01:00
2022-07-09 10:46:07 +01:00
QIcon GetBoxIcon(int boxType, bool inUse = false);// , bool inBusy = false);
2022-07-10 17:28:10 +01:00
QRgb GetBoxColor(int boxType) { return m_BoxColors[boxType]; }
2022-09-29 17:28:48 +01:00
QIcon GetColorIcon(QColor boxColor, bool inUse = false/*, bool bOut = false*/);
2022-07-09 10:46:07 +01:00
QIcon MakeIconBusy(const QIcon& Icon, int Index = 0);
2022-11-07 11:06:15 +00:00
QIcon MakeIconRecycle(const QIcon& Icon);
2021-10-16 16:19:51 +01:00
QString GetBoxDescription(int boxType);
2022-06-06 18:46:03 +01:00
2022-08-09 17:19:46 +01:00
bool CheckCertificate(QWidget* pWidget);
2021-10-16 16:19:51 +01:00
void UpdateTheme();
void UpdateTitleTheme(const HWND& hwnd);
2021-10-16 16:19:51 +01:00
2022-01-13 22:52:58 +00:00
void UpdateCertState();
signals:
void CertUpdated();
2021-10-16 16:19:51 +01:00
protected:
2022-02-02 18:31:03 +00:00
SB_RESULT(void*) ConnectSbie();
2021-10-16 16:19:51 +01:00
SB_STATUS ConnectSbieImpl();
SB_STATUS DisconnectSbie();
2022-02-02 18:31:03 +00:00
SB_RESULT(void*) StopSbie(bool andRemove = false);
2021-10-16 16:19:51 +01:00
2022-06-08 16:23:19 +01:00
static void RecoverFilesAsync(const CSbieProgressPtr& pProgress, const QString& BoxName, const QList<QPair<QString, QString>>& FileList, int Action = 0);
2021-10-16 16:19:51 +01:00
2022-02-18 19:09:35 +00:00
QIcon GetTrayIcon(bool isConnected = true);
QString GetTrayText(bool isConnected = true);
2021-10-16 16:19:51 +01:00
2022-08-09 17:19:46 +01:00
void CheckSupport();
2021-10-16 16:19:51 +01:00
void closeEvent(QCloseEvent* e);
void dragEnterEvent(QDragEnterEvent* e);
void dropEvent(QDropEvent* e);
void timerEvent(QTimerEvent* pEvent);
int m_uTimerID;
bool m_bConnectPending;
bool m_bStopPending;
CBoxBorder* m_pBoxBorder;
CSbieTemplates* m_SbieTemplates;
QMap<CSbieProgress*, CSbieProgressPtr> m_pAsyncProgress;
QStringList m_MissingTemplates;
enum EBoxColors
{
eYellow = 0,
eRed,
eGreen,
eBlue,
eCyan,
eMagenta,
eOrang,
2022-07-10 17:28:10 +01:00
eWhite,
2021-10-16 16:19:51 +01:00
eMaxColor
};
2022-07-10 17:28:10 +01:00
QMap<int, QRgb> m_BoxColors;
2022-09-01 18:29:07 +01:00
//struct SBoxIcon {
// QIcon Empty;
// QIcon InUse;
// //QIcon Busy;
//};
//QMap<int, SBoxIcon> m_BoxIcons;
2021-10-16 16:19:51 +01:00
class UGlobalHotkeys* m_pHotkeyManager;
public slots:
2022-09-01 18:29:07 +01:00
void OnBoxSelected();
2022-01-13 22:52:58 +00:00
void OnMessage(const QString& MsgData);
2021-10-16 16:19:51 +01:00
void OnStatusChanged();
void OnLogMessage(const QString& Message, bool bNotify = false);
void OnLogSbieMessage(quint32 MsgCode, const QStringList& MsgData, quint32 ProcessId);
void OnNotAuthorized(bool bLoginRequired, bool& bRetry);
void OnQueuedRequest(quint32 ClientPid, quint32 ClientTid, quint32 RequestId, const QVariantMap& Data);
void OnFileToRecover(const QString& BoxName, const QString& FilePath, const QString& BoxPath, quint32 ProcessId);
2022-06-08 16:23:19 +01:00
void OnFileRecovered(const QString& BoxName, const QString& FilePath, const QString& BoxPath);
2021-10-16 16:19:51 +01:00
2022-01-30 14:53:37 +00:00
bool OpenRecovery(const CSandBoxPtr& pBox, bool& DeleteShapshots, bool bCloseEmpty = false);
2021-10-16 16:19:51 +01:00
class CRecoveryWindow* ShowRecovery(const CSandBoxPtr& pBox, bool bFind = true);
2022-07-09 10:46:07 +01:00
void UpdateSettings(bool bRebuildUI);
2022-08-28 11:43:08 +01:00
void RebuildUI();
2021-10-16 16:19:51 +01:00
void OnIniReloaded();
void SetupHotKeys();
void OnHotKey(size_t id);
void OnAsyncFinished();
void OnAsyncFinished(CSbieProgress* pProgress);
void OnAsyncMessage(const QString& Text);
void OnAsyncProgress(int Progress);
void OnCancelAsync();
2022-09-29 17:28:48 +01:00
void OnBoxAdded(const CSandBoxPtr& pBox);
2022-06-13 19:12:53 +01:00
void OnBoxClosed(const CSandBoxPtr& pBox);
2021-10-16 16:19:51 +01:00
2022-09-29 17:28:48 +01:00
void OnStartMenuChanged();
2021-10-16 16:19:51 +01:00
void OpenUrl(const QString& url) { OpenUrl(QUrl(url)); }
void OpenUrl(const QUrl& url);
2022-09-29 17:28:48 +01:00
int ShowQuestion(const QString& question, const QString& checkBoxText, bool* checkBoxSetting, int buttons, int defaultButton, int type);
void ShowMessage(const QString& message, int type);
2021-10-16 16:19:51 +01:00
void OnBoxMenu(const QPoint &);
void OnBoxDblClick(QTreeWidgetItem*);
2022-09-29 17:28:48 +01:00
void SyncStartMenu();
void ClearStartMenu();
2022-08-09 17:19:46 +01:00
void UpdateLabel();
2021-10-16 16:19:51 +01:00
private slots:
void OnMenuHover(QAction* action);
2022-07-10 17:28:10 +01:00
void OnBoxMenuHover(QAction* action);
2021-10-16 16:19:51 +01:00
2022-07-09 10:46:07 +01:00
void OnSandBoxAction();
2022-07-11 18:30:09 +01:00
void OnSettingsAction();
2021-10-16 16:19:51 +01:00
void OnEmptyAll();
void OnWndFinder();
void OnDisableForce();
void OnDisableForce2();
2022-08-10 19:14:37 +01:00
void OnDisablePopUp();
2021-10-16 16:19:51 +01:00
void OnMaintenance();
void OnViewMode(QAction* action);
void OnAlwaysTop();
2022-07-11 18:30:09 +01:00
void OnView(QAction* action);
2022-05-16 20:30:40 +01:00
void OnRefresh();
2021-10-16 16:19:51 +01:00
void OnCleanUp();
void OnProcView();
2022-07-11 18:30:09 +01:00
void OnRecoveryLog();
2021-10-16 16:19:51 +01:00
void OnSettings();
void OnResetMsgs();
2022-02-02 20:04:37 +00:00
void OnResetGUI();
2021-10-16 16:19:51 +01:00
void OnEditIni();
void OnReloadIni();
2022-07-09 10:46:07 +01:00
void OnMonitoring();
2021-10-16 16:19:51 +01:00
2022-08-09 17:19:46 +01:00
void CheckForUpdates(bool bManual = true);
2021-10-16 16:19:51 +01:00
void OnExit();
void OnHelp();
void OnAbout();
void OnShowHide();
void OnSysTray(QSystemTrayIcon::ActivationReason Reason);