2017-09-01 15:13:17 +00:00
|
|
|
#ifndef FORTMANAGER_H
|
|
|
|
#define FORTMANAGER_H
|
2017-09-01 13:13:12 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
2017-09-07 10:44:15 +00:00
|
|
|
|
2019-05-03 14:32:50 +00:00
|
|
|
#include "util/classhelpers.h"
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2021-01-26 15:10:37 +00:00
|
|
|
class AppInfoCache;
|
|
|
|
class AppListModel;
|
|
|
|
class AppStatModel;
|
|
|
|
class ConfManager;
|
2021-02-12 09:10:39 +00:00
|
|
|
class ConnListModel;
|
|
|
|
class ConnectionsWindow;
|
2021-01-26 15:10:37 +00:00
|
|
|
class DriverManager;
|
|
|
|
class EnvManager;
|
|
|
|
class FirewallConf;
|
|
|
|
class FortSettings;
|
|
|
|
class GraphWindow;
|
2021-02-21 18:44:58 +00:00
|
|
|
class HostInfoCache;
|
2021-01-26 15:10:37 +00:00
|
|
|
class HotKeyManager;
|
|
|
|
class LogManager;
|
2021-03-31 10:29:19 +00:00
|
|
|
class MainWindow;
|
2021-01-26 15:10:37 +00:00
|
|
|
class NativeEventFilter;
|
|
|
|
class OptionsWindow;
|
|
|
|
class ProgramsWindow;
|
|
|
|
class QuotaManager;
|
|
|
|
class StatManager;
|
|
|
|
class TaskManager;
|
2021-04-12 07:54:14 +00:00
|
|
|
class TrayIcon;
|
2021-01-26 15:10:37 +00:00
|
|
|
class ZoneListModel;
|
|
|
|
class ZonesWindow;
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-09-01 15:13:17 +00:00
|
|
|
class FortManager : public QObject
|
2017-09-01 13:13:12 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-08-20 09:36:41 +00:00
|
|
|
enum TrayMessageType { MessageOptions, MessageZones };
|
2020-02-17 07:15:27 +00:00
|
|
|
Q_ENUM(TrayMessageType)
|
|
|
|
|
2021-03-26 11:48:11 +00:00
|
|
|
explicit FortManager(FortSettings *settings, EnvManager *envManager, QObject *parent = nullptr);
|
2019-02-08 08:19:20 +00:00
|
|
|
~FortManager() override;
|
2019-05-03 14:32:50 +00:00
|
|
|
CLASS_DELETE_COPY_MOVE(FortManager)
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2021-04-12 07:54:14 +00:00
|
|
|
MainWindow *mainWindow() const { return m_mainWindow; }
|
|
|
|
HotKeyManager *hotKeyManager() const { return m_hotKeyManager; }
|
|
|
|
|
|
|
|
ProgramsWindow *progWindow() const { return m_progWindow; }
|
|
|
|
OptionsWindow *optWindow() const { return m_optWindow; }
|
|
|
|
ZonesWindow *zoneWindow() const { return m_zoneWindow; }
|
|
|
|
GraphWindow *graphWindow() const { return m_graphWindow; }
|
|
|
|
ConnectionsWindow *connWindow() const { return m_connWindow; }
|
|
|
|
|
2020-01-13 04:30:42 +00:00
|
|
|
FirewallConf *conf() const;
|
|
|
|
FirewallConf *confToEdit() const;
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2020-01-13 04:30:42 +00:00
|
|
|
FortSettings *settings() const { return m_settings; }
|
2021-03-26 11:48:11 +00:00
|
|
|
EnvManager *envManager() const { return m_envManager; }
|
2019-10-29 18:58:10 +00:00
|
|
|
ConfManager *confManager() const { return m_confManager; }
|
2017-09-04 11:39:15 +00:00
|
|
|
DriverManager *driverManager() const { return m_driverManager; }
|
2017-11-10 13:36:29 +00:00
|
|
|
LogManager *logManager() const { return m_logManager; }
|
2017-09-19 08:35:43 +00:00
|
|
|
TaskManager *taskManager() const { return m_taskManager; }
|
2020-01-31 10:00:36 +00:00
|
|
|
AppListModel *appListModel() const { return m_appListModel; }
|
|
|
|
AppStatModel *appStatModel() const { return m_appStatModel; }
|
|
|
|
ZoneListModel *zoneListModel() const { return m_zoneListModel; }
|
2021-02-13 05:37:33 +00:00
|
|
|
ConnListModel *connListModel() const { return m_connListModel; }
|
2017-09-04 11:39:15 +00:00
|
|
|
|
2021-04-17 09:03:06 +00:00
|
|
|
bool checkRunningInstance();
|
|
|
|
|
|
|
|
void initialize();
|
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
signals:
|
2021-04-12 07:54:14 +00:00
|
|
|
void optWindowChanged(bool visible);
|
|
|
|
void graphWindowChanged(bool visible);
|
2020-02-01 11:09:45 +00:00
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
public slots:
|
2019-04-04 08:53:59 +00:00
|
|
|
void installDriver();
|
|
|
|
void removeDriver();
|
|
|
|
|
2021-04-03 08:33:45 +00:00
|
|
|
void show();
|
2019-02-08 19:25:01 +00:00
|
|
|
|
2017-09-03 05:57:35 +00:00
|
|
|
void showTrayIcon();
|
2021-04-15 10:09:41 +00:00
|
|
|
void closeTrayIcon();
|
2020-08-20 09:36:41 +00:00
|
|
|
void showTrayMessage(
|
|
|
|
const QString &message, FortManager::TrayMessageType type = MessageOptions);
|
2017-09-03 05:57:35 +00:00
|
|
|
|
2020-01-02 09:40:26 +00:00
|
|
|
void showProgramsWindow();
|
|
|
|
void closeProgramsWindow();
|
|
|
|
|
2021-03-30 10:01:02 +00:00
|
|
|
bool showProgramEditForm(const QString &appPath);
|
2021-03-23 09:46:12 +00:00
|
|
|
|
2019-12-16 10:41:44 +00:00
|
|
|
void showOptionsWindow();
|
|
|
|
void closeOptionsWindow();
|
2021-04-17 07:39:41 +00:00
|
|
|
void reloadOptionsWindow();
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2020-01-31 10:00:36 +00:00
|
|
|
void showZonesWindow();
|
|
|
|
void closeZonesWindow();
|
|
|
|
|
2018-03-15 15:35:49 +00:00
|
|
|
void showGraphWindow();
|
2021-04-17 09:03:06 +00:00
|
|
|
void closeGraphWindow(bool wasVisible = false);
|
2018-03-15 15:35:49 +00:00
|
|
|
void switchGraphWindow();
|
2019-02-10 15:55:23 +00:00
|
|
|
void updateGraphWindow();
|
2018-03-15 15:35:49 +00:00
|
|
|
|
2021-02-12 09:10:39 +00:00
|
|
|
void showConnectionsWindow();
|
|
|
|
void closeConnectionsWindow();
|
|
|
|
|
2021-04-03 09:21:42 +00:00
|
|
|
void processRestartRequired();
|
|
|
|
|
2021-04-06 10:46:07 +00:00
|
|
|
void quitByCheckPassword();
|
2017-09-06 08:39:20 +00:00
|
|
|
|
2018-01-12 08:29:08 +00:00
|
|
|
bool checkPassword();
|
|
|
|
|
2020-08-20 09:36:41 +00:00
|
|
|
void showErrorBox(const QString &text, const QString &title = QString());
|
|
|
|
void showInfoBox(const QString &text, const QString &title = QString());
|
|
|
|
bool showQuestionBox(const QString &text, const QString &title = QString());
|
2021-04-02 17:30:39 +00:00
|
|
|
bool showYesNoBox(const QString &text, const QString &yesText, const QString &noText,
|
|
|
|
const QString &title = QString());
|
2017-09-03 19:41:03 +00:00
|
|
|
|
2021-03-30 10:01:02 +00:00
|
|
|
bool saveOriginConf(const QString &message, bool onlyFlags = false);
|
2017-09-07 05:34:18 +00:00
|
|
|
bool saveConf(bool onlyFlags = false);
|
|
|
|
bool applyConf(bool onlyFlags = false);
|
2017-12-14 10:23:40 +00:00
|
|
|
bool applyConfImmediateFlags();
|
2017-09-04 11:39:15 +00:00
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
private:
|
2020-01-25 05:54:25 +00:00
|
|
|
void setupTranslationManager();
|
|
|
|
|
2019-04-27 13:24:15 +00:00
|
|
|
void setupThreadPool();
|
|
|
|
|
2017-09-04 13:53:45 +00:00
|
|
|
bool setupDriver();
|
2017-11-10 13:36:29 +00:00
|
|
|
void closeDriver();
|
|
|
|
|
2021-04-09 11:31:22 +00:00
|
|
|
void setupAppInfoCache();
|
|
|
|
void setupHostInfoCache();
|
2020-01-31 10:00:36 +00:00
|
|
|
void setupModels();
|
|
|
|
|
2019-04-04 08:53:59 +00:00
|
|
|
void setupLogManager();
|
|
|
|
void closeLogManager();
|
|
|
|
|
2021-04-09 11:31:22 +00:00
|
|
|
void setupEventFilter();
|
2019-11-21 08:36:18 +00:00
|
|
|
void setupEnvManager();
|
2019-10-09 08:56:41 +00:00
|
|
|
void setupStatManager();
|
2019-10-23 12:03:59 +00:00
|
|
|
void setupConfManager();
|
2018-02-19 15:01:35 +00:00
|
|
|
|
2018-01-11 08:54:38 +00:00
|
|
|
void setupLogger();
|
2019-10-29 18:58:10 +00:00
|
|
|
void setupTaskManager();
|
2018-12-25 07:36:11 +00:00
|
|
|
|
2021-04-07 09:37:00 +00:00
|
|
|
void setupMainWindow();
|
2021-04-09 14:20:05 +00:00
|
|
|
void closeMainWindow();
|
|
|
|
|
2021-04-07 09:37:00 +00:00
|
|
|
void setupHotKeyManager();
|
2021-04-09 11:31:22 +00:00
|
|
|
void setupTrayIcon();
|
2019-10-06 06:15:46 +00:00
|
|
|
|
2021-04-07 09:37:00 +00:00
|
|
|
void setupProgramsWindow();
|
|
|
|
void setupOptionsWindow();
|
|
|
|
void setupZonesWindow();
|
|
|
|
void setupGraphWindow();
|
|
|
|
void setupConnectionsWindow();
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2019-10-08 15:32:34 +00:00
|
|
|
void closeUi();
|
|
|
|
|
2020-02-01 11:09:45 +00:00
|
|
|
bool loadConf();
|
|
|
|
bool saveConf(FirewallConf *newConf, bool onlyFlags = false);
|
2017-09-04 13:53:45 +00:00
|
|
|
|
2019-11-21 08:36:18 +00:00
|
|
|
bool updateDriverConf(bool onlyFlags = false);
|
2017-09-02 14:25:47 +00:00
|
|
|
|
2018-02-20 12:21:10 +00:00
|
|
|
void updateLogManager(bool active);
|
2019-10-09 08:56:41 +00:00
|
|
|
void updateStatManager(FirewallConf *conf);
|
2017-12-08 02:38:02 +00:00
|
|
|
|
2021-03-17 13:47:58 +00:00
|
|
|
void onTrayActivated(int reason);
|
|
|
|
void onTrayMessageClicked();
|
|
|
|
|
2021-04-12 07:54:14 +00:00
|
|
|
QWidget *focusWidget() const;
|
2021-04-17 13:50:32 +00:00
|
|
|
static void activateModalWidget();
|
2017-09-03 05:57:35 +00:00
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
private:
|
2021-04-17 06:12:59 +00:00
|
|
|
bool m_initialized : 1;
|
2021-04-08 10:04:05 +00:00
|
|
|
bool m_trayTriggered : 1;
|
2017-09-03 05:57:35 +00:00
|
|
|
|
2020-02-17 07:15:27 +00:00
|
|
|
TrayMessageType m_lastMessageType = MessageOptions;
|
|
|
|
|
2021-04-03 08:33:45 +00:00
|
|
|
void *m_instanceMutex = nullptr;
|
|
|
|
|
2021-03-31 10:29:19 +00:00
|
|
|
MainWindow *m_mainWindow = nullptr; // dummy window for tray icon
|
|
|
|
|
2021-04-12 07:54:14 +00:00
|
|
|
NativeEventFilter *m_nativeEventFilter = nullptr;
|
|
|
|
HotKeyManager *m_hotKeyManager = nullptr;
|
|
|
|
|
|
|
|
TrayIcon *m_trayIcon = nullptr;
|
2020-01-02 09:40:26 +00:00
|
|
|
|
|
|
|
ProgramsWindow *m_progWindow = nullptr;
|
2020-01-01 11:28:59 +00:00
|
|
|
OptionsWindow *m_optWindow = nullptr;
|
2020-01-31 10:00:36 +00:00
|
|
|
ZonesWindow *m_zoneWindow = nullptr;
|
2020-01-01 11:28:59 +00:00
|
|
|
GraphWindow *m_graphWindow = nullptr;
|
2021-02-12 09:10:39 +00:00
|
|
|
ConnectionsWindow *m_connWindow = nullptr;
|
|
|
|
|
2020-01-13 04:30:42 +00:00
|
|
|
FortSettings *m_settings = nullptr;
|
2021-03-26 11:48:11 +00:00
|
|
|
EnvManager *m_envManager = nullptr;
|
2020-01-01 11:28:59 +00:00
|
|
|
QuotaManager *m_quotaManager = nullptr;
|
|
|
|
StatManager *m_statManager = nullptr;
|
|
|
|
DriverManager *m_driverManager = nullptr;
|
2020-01-04 11:19:56 +00:00
|
|
|
ConfManager *m_confManager = nullptr;
|
2020-01-01 11:28:59 +00:00
|
|
|
LogManager *m_logManager = nullptr;
|
|
|
|
TaskManager *m_taskManager = nullptr;
|
2021-04-07 09:37:00 +00:00
|
|
|
|
2020-01-01 11:28:59 +00:00
|
|
|
AppInfoCache *m_appInfoCache = nullptr;
|
2021-02-21 18:44:58 +00:00
|
|
|
HostInfoCache *m_hostInfoCache = nullptr;
|
2020-01-31 10:00:36 +00:00
|
|
|
|
|
|
|
AppListModel *m_appListModel = nullptr;
|
|
|
|
AppStatModel *m_appStatModel = nullptr;
|
|
|
|
ZoneListModel *m_zoneListModel = nullptr;
|
2021-02-13 05:37:33 +00:00
|
|
|
ConnListModel *m_connListModel = nullptr;
|
2017-09-01 13:13:12 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 15:13:17 +00:00
|
|
|
#endif // FORTMANAGER_H
|