Sandboxie/SandboxiePlus/SandMan/SandMan.h

234 lines
5.7 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"
2020-06-01 17:11:56 +01:00
#include "Models/ResMonModel.h"
2020-07-04 11:07:36 +01: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
#define VERSION_MJR 0
2020-11-28 16:20:56 +00:00
#define VERSION_MIN 5
2020-12-29 08:54:59 +00:00
#define VERSION_REV 3
2021-01-02 08:03:16 +00:00
#define VERSION_UPD 2
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;
class CApiLog;
2020-07-04 11:07:36 +01:00
class CBoxBorder;
2020-09-05 16:45:39 +01:00
class CSbieTemplates;
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);
2020-12-22 14:50:58 +00:00
static QIcon GetIcon(const QString& Name);
2020-12-07 16:34:20 +00:00
2021-01-02 08:03:16 +00:00
bool IsFullyPortable();
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
2020-06-01 17:11:56 +01:00
void closeEvent(QCloseEvent *e);
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-06-01 17:11:56 +01:00
CApiLog* m_ApiLog;
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
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);
void OnFileToRecover(const QString& BoxName, const QString& FilePath, quint32 ProcessId);
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
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);
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();
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);
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 OnSetLogging();
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;
2020-07-04 11:07:36 +01:00
CPanelViewEx* m_pResourceLog;
2020-06-01 17:11:56 +01:00
CResMonModel* m_pResMonModel;
2020-07-04 11:07:36 +01:00
CPanelViewEx* m_pApiCallLog;
CApiMonModel* m_pApiMonModel;
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;
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;
int m_iMenuViewPos;
2020-06-08 16:17:37 +01:00
QMenu* m_pCleanUpMenu;
QAction* m_pCleanUpProcesses;
QAction* m_pCleanUpMsgLog;
QAction* m_pCleanUpResLog;
QAction* m_pCleanUpApiLog;
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;
QAction* m_pEnableLogging;
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;
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
void SetDarkTheme(bool bDark);
QString m_DefaultStyle;
QPalette m_DefaultPalett;
void LoadLanguage();
QTranslator m_Translator;
QByteArray m_Translation;
2020-11-28 16:20:56 +00:00
public:
quint32 m_LanguageId;
2020-06-01 17:11:56 +01:00
};
2020-06-18 16:44:29 +01:00
extern CSandMan* theGUI;