Sandboxie/SandboxiePlus/SandMan/SandMan.h

272 lines
6.5 KiB
C
Raw Normal View History

2020-06-01 17:11:56 +01:00
#pragma once
#include <QtWidgets/QMainWindow>
#include "../MiscHelpers/Common/Settings.h"
#include "../MiscHelpers/Common/TreeViewEx.h"
#include "../MiscHelpers/Common/PanelView.h"
2020-06-18 16:44:29 +01:00
#include "../MiscHelpers/Common/ProgressDialog.h"
2020-12-07 16:34:20 +00:00
#include "../MiscHelpers/Common/NetworkAccessManager.h"
2021-03-04 20:13:45 +00:00
#include "Models/TraceModel.h"
2021-02-14 19:18:29 +00:00
//#include "Models/ApiMonModel.h"
2020-07-19 21:09:02 +01:00
#include <QTranslator>
2020-11-28 16:20:56 +00:00
#include "Windows/PopUpWindow.h"
2020-06-01 17:11:56 +01:00
2021-02-14 19:34:13 +00:00
#include "../version.h"
2020-06-01 17:11:56 +01:00
2020-06-18 16:44:29 +01:00
//#include "../QSbieAPI/SbieAPI.h"
#include "SbiePlusAPI.h"
2020-06-01 17:11:56 +01:00
class CSbieView;
2020-07-04 11:07:36 +01:00
class CBoxBorder;
2020-09-05 16:45:39 +01:00
class CSbieTemplates;
2021-03-04 20:13:45 +00:00
class CTraceView;
2020-06-01 17:11:56 +01:00
2021-07-05 12:37:28 +01:00
2020-06-01 17:11:56 +01:00
class CSandMan : public QMainWindow
{
Q_OBJECT
public:
CSandMan(QWidget *parent = Q_NULLPTR);
virtual ~CSandMan();
2020-09-05 16:45:39 +01:00
CSbieTemplates* GetCompat() { return m_SbieTemplates; }
2020-06-18 16:44:29 +01:00
2020-06-01 17:11:56 +01:00
static QString GetVersion();
2020-12-29 08:54:59 +00:00
SB_PROGRESS RecoverFiles(const QList<QPair<QString, QString>>& FileList, int Action = 0);
2020-11-28 16:20:56 +00:00
2020-09-05 16:45:39 +01:00
void AddAsyncOp(const CSbieProgressPtr& pProgress);
2020-12-23 18:17:24 +00:00
static QString FormatError(const SB_STATUS& Error);
2020-06-01 17:11:56 +01:00
static void CheckResults(QList<SB_STATUS> Results);
2021-07-30 11:47:38 +01:00
static QIcon GetIcon(const QString& Name, bool bAction = true);
2020-12-07 16:34:20 +00:00
2021-01-02 08:03:16 +00:00
bool IsFullyPortable();
2021-01-26 20:58:43 +00:00
bool IsShowHidden() { return m_pShowHidden->isChecked(); }
2021-06-13 17:11:04 +01:00
CSbieView* GetBoxView() { return m_pBoxView; }
2021-07-05 12:37:28 +01:00
void RunSandboxed(const QStringList& Commands);
QIcon GetBoxIcon(bool inUse, int boxType = 0);
2020-06-01 17:11:56 +01:00
protected:
2020-06-08 16:17:37 +01:00
SB_STATUS ConnectSbie();
2020-07-04 11:07:36 +01:00
SB_STATUS ConnectSbieImpl();
2020-06-08 16:17:37 +01:00
SB_STATUS DisconnectSbie();
SB_STATUS StopSbie(bool andRemove = false);
2020-12-29 08:54:59 +00:00
static void RecoverFilesAsync(const CSbieProgressPtr& pProgress, const QList<QPair<QString, QString>>& FileList, int Action = 0);
2020-11-28 16:20:56 +00:00
2021-01-18 12:04:14 +00:00
void closeEvent(QCloseEvent* e);
void dragEnterEvent(QDragEnterEvent* e);
void dropEvent(QDropEvent* e);
2020-06-01 17:11:56 +01:00
void timerEvent(QTimerEvent* pEvent);
int m_uTimerID;
2020-06-08 16:17:37 +01:00
bool m_bConnectPending;
bool m_bStopPending;
2020-07-04 11:07:36 +01:00
CBoxBorder* m_pBoxBorder;
2020-09-05 16:45:39 +01:00
CSbieTemplates* m_SbieTemplates;
2020-07-04 11:07:36 +01:00
2020-09-05 16:45:39 +01:00
QMap<CSbieProgress*, CSbieProgressPtr> m_pAsyncProgress;
2020-06-01 17:11:56 +01:00
2020-12-07 16:34:20 +00:00
CNetworkAccessManager* m_RequestManager;
2020-12-12 11:55:20 +00:00
CSbieProgressPtr m_pUpdateProgress;
2020-12-07 16:34:20 +00:00
2021-01-18 12:04:14 +00:00
QStringList m_MissingTemplates;
2021-07-05 12:37:28 +01:00
enum EBoxColors
{
2021-07-30 11:47:38 +01:00
eYellow = 0,
2021-07-05 12:37:28 +01:00
eRed,
eGreen,
eBlue,
eCyan,
eMagenta,
eOrang,
eMaxColor
};
QMap<EBoxColors, QPair<QIcon, QIcon> > m_BoxIcons;
class UGlobalHotkeys* m_pHotkeyManager;
2020-06-01 17:11:56 +01:00
public slots:
2020-06-08 16:17:37 +01:00
void OnMessage(const QString&);
void OnStatusChanged();
2020-07-04 11:07:36 +01:00
void OnLogMessage(const QString& Message, bool bNotify = false);
2020-11-28 16:20:56 +00:00
void OnLogSbieMessage(quint32 MsgCode, const QStringList& MsgData, quint32 ProcessId);
2020-06-01 17:11:56 +01:00
2020-07-19 21:09:02 +01:00
void OnNotAuthorized(bool bLoginRequired, bool& bRetry);
2020-11-28 16:20:56 +00:00
void OnQueuedRequest(quint32 ClientPid, quint32 ClientTid, quint32 RequestId, const QVariantMap& Data);
2021-06-13 17:11:04 +01:00
void OnFileToRecover(const QString& BoxName, const QString& FilePath, const QString& BoxPath, quint32 ProcessId);
2020-11-28 16:20:56 +00:00
void OpenRecovery(const QString& BoxName);
2020-07-19 21:09:02 +01:00
void UpdateSettings();
2020-11-28 16:20:56 +00:00
void OnIniReloaded();
2020-07-19 21:09:02 +01:00
2021-07-05 12:37:28 +01:00
void SetupHotKeys();
void OnHotKey(size_t id);
2020-09-05 16:45:39 +01:00
void OnAsyncFinished();
void OnAsyncFinished(CSbieProgress* pProgress);
void OnAsyncMessage(const QString& Text);
2020-12-12 11:55:20 +00:00
void OnAsyncProgress(int Progress);
2020-09-05 16:45:39 +01:00
void OnCancelAsync();
2020-09-12 09:09:24 +01:00
void OnBoxClosed(const QString& BoxName);
2020-12-07 16:34:20 +00:00
void CheckForUpdates(bool bManual = true);
2020-12-29 08:54:59 +00:00
void OpenUrl(const QUrl& url);
2021-01-06 12:19:13 +00:00
int ShowQuestion(const QString& question, const QString& checkBoxText, bool* checkBoxSetting, int buttons, int defaultButton);
2021-07-10 11:59:32 +01:00
void OnBoxMenu(const QPoint &);
void OnBoxDblClick(QTreeWidgetItem*);
2020-06-01 17:11:56 +01:00
private slots:
void OnSelectionChanged();
2020-06-08 16:17:37 +01:00
void OnMenuHover(QAction* action);
2020-06-01 17:11:56 +01:00
void OnNewBox();
void OnEmptyAll();
2021-01-26 20:58:43 +00:00
void OnWndFinder();
2020-11-03 15:45:04 +00:00
void OnDisableForce();
2020-12-12 11:55:20 +00:00
void OnDisableForce2();
2020-06-08 16:17:37 +01:00
void OnMaintenance();
2020-06-01 17:11:56 +01:00
2020-12-12 11:55:20 +00:00
void OnViewMode(QAction* action);
2021-01-18 12:04:14 +00:00
void OnAlwaysTop();
2020-06-01 17:11:56 +01:00
void OnCleanUp();
void OnSetKeep();
2020-07-19 21:09:02 +01:00
void OnSettings();
2020-12-29 08:54:59 +00:00
void OnResetMsgs();
2020-06-01 17:11:56 +01:00
void OnEditIni();
void OnReloadIni();
void OnSetMonitoring();
void OnExit();
2020-12-07 16:34:20 +00:00
void OnHelp();
2020-06-01 17:11:56 +01:00
void OnAbout();
2020-12-22 14:50:58 +00:00
void OnShowHide();
2020-06-01 17:11:56 +01:00
void OnSysTray(QSystemTrayIcon::ActivationReason Reason);
2020-12-07 16:34:20 +00:00
void OnUpdateCheck();
void OnUpdateProgress(qint64 bytes, qint64 bytesTotal);
void OnUpdateDownload();
2020-06-01 17:11:56 +01:00
private:
2020-12-07 16:34:20 +00:00
void CreateMenus();
void CreateToolBar();
2020-12-12 11:55:20 +00:00
void SetViewMode(bool bAdvanced);
2020-12-22 14:50:58 +00:00
void LoadState();
void StoreState();
2020-06-01 17:11:56 +01:00
QWidget* m_pMainWidget;
QVBoxLayout* m_pMainLayout;
QToolBar* m_pToolBar;
QSplitter* m_pPanelSplitter;
QSplitter* m_pLogSplitter;
CSbieView* m_pBoxView;
QTabWidget* m_pLogTabs;
CPanelWidgetEx* m_pMessageLog;
2021-03-04 20:13:45 +00:00
CTraceView* m_pTraceView;
2020-06-01 17:11:56 +01:00
QMenu* m_pMenuFile;
2020-06-08 16:17:37 +01:00
QAction* m_pNew;
QAction* m_pEmptyAll;
2021-01-26 20:58:43 +00:00
QAction* m_pWndFinder;
2020-11-03 15:45:04 +00:00
QAction* m_pDisableForce;
2020-12-12 11:55:20 +00:00
QAction* m_pDisableForce2;
2020-06-08 16:17:37 +01:00
QMenu* m_pMaintenance;
QAction* m_pConnect;
QAction* m_pDisconnect;
QMenu* m_pMaintenanceItems;
QAction* m_pInstallDrv;
QAction* m_pStartDrv;
QAction* m_pStopDrv;
QAction* m_pUninstallDrv;
QAction* m_pInstallSvc;
QAction* m_pStartSvc;
QAction* m_pStopSvc;
QAction* m_pUninstallSvc;
QAction* m_pStopAll;
QAction* m_pExit;
2020-06-01 17:11:56 +01:00
QMenu* m_pMenuView;
2020-12-12 11:55:20 +00:00
QActionGroup* m_pViewMode;
2021-01-26 20:58:43 +00:00
QAction* m_pShowHidden;
2021-01-18 12:04:14 +00:00
QAction* m_pWndTopMost;
2020-12-12 11:55:20 +00:00
int m_iMenuViewPos;
2020-06-08 16:17:37 +01:00
QMenu* m_pCleanUpMenu;
QAction* m_pCleanUpProcesses;
QAction* m_pCleanUpMsgLog;
2021-02-14 19:18:29 +00:00
QAction* m_pCleanUpTrace;
2020-06-08 16:17:37 +01:00
QToolButton* m_pCleanUpButton;
2020-06-01 17:11:56 +01:00
QAction* m_pKeepTerminated;
QMenu* m_pMenuOptions;
2020-07-19 21:09:02 +01:00
QAction* m_pMenuSettings;
2020-12-29 08:54:59 +00:00
QAction* m_pMenuResetMsgs;
2020-06-01 17:11:56 +01:00
QAction* m_pEditIni;
QAction* m_pReloadIni;
QAction* m_pEnableMonitoring;
QMenu* m_pMenuHelp;
2020-06-08 16:17:37 +01:00
QAction* m_pSupport;
2020-12-07 16:34:20 +00:00
QAction* m_pForum;
QAction* m_pManual;
QAction* m_pUpdate;
QAction* m_pAbout;
2020-06-08 16:17:37 +01:00
QAction* m_pAboutQt;
2020-06-01 17:11:56 +01:00
QSystemTrayIcon* m_pTrayIcon;
QMenu* m_pTrayMenu;
2021-07-10 11:59:32 +01:00
QTreeWidget* m_pTrayBoxes;
//QMenu* m_pBoxMenu;
2020-06-08 16:17:37 +01:00
bool m_bIconEmpty;
2020-12-22 14:50:58 +00:00
bool m_bIconDisabled;
2020-06-01 17:11:56 +01:00
bool m_bExit;
2020-06-18 16:44:29 +01:00
CProgressDialog* m_pProgressDialog;
2020-11-28 16:20:56 +00:00
CPopUpWindow* m_pPopUpWindow;
2020-07-19 21:09:02 +01:00
2021-02-01 19:13:09 +00:00
void SetUITheme();
2020-07-19 21:09:02 +01:00
QString m_DefaultStyle;
QPalette m_DefaultPalett;
void LoadLanguage();
QTranslator m_Translator;
QByteArray m_Translation;
2021-07-05 12:37:28 +01:00
2020-11-28 16:20:56 +00:00
public:
quint32 m_LanguageId;
2021-02-01 19:13:09 +00:00
bool m_DarkTheme;
2020-06-01 17:11:56 +01:00
};
2020-06-18 16:44:29 +01:00
2021-07-05 12:37:28 +01:00
extern CSandMan* theGUI;