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
|
|
|
|
|
|
|
#include "mainwindow.h"
|
2019-05-03 14:32:50 +00:00
|
|
|
#include "util/classhelpers.h"
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-12-06 02:51:40 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QSystemTrayIcon)
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2019-04-21 10:21:15 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(AppInfoCache)
|
2020-01-31 10:00:36 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(AppListModel)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(AppStatModel)
|
2019-10-23 12:03:59 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(ConfManager)
|
2017-12-06 02:51:40 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(DriverManager)
|
2019-11-21 08:36:18 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(EnvManager)
|
2017-12-06 02:51:40 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(FirewallConf)
|
2018-02-19 15:01:35 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(FortSettings)
|
2018-03-15 15:35:49 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(GraphWindow)
|
2018-03-07 10:12:58 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(HotKeyManager)
|
2017-12-06 02:51:40 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(LogManager)
|
2018-03-07 10:12:58 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(NativeEventFilter)
|
2019-12-16 10:41:44 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(OptionsWindow)
|
2020-01-02 09:40:26 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(ProgramsWindow)
|
2018-02-19 15:01:35 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QuotaManager)
|
2019-10-09 08:56:41 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(StatManager)
|
2017-12-06 02:51:40 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(TaskManager)
|
2018-03-15 15:35:49 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(WidgetWindowStateWatcher)
|
2020-01-31 10:00:36 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(ZoneListModel)
|
|
|
|
QT_FORWARD_DECLARE_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-02-17 07:15:27 +00:00
|
|
|
enum TrayMessageType {
|
|
|
|
MessageOptions,
|
|
|
|
MessageZones
|
|
|
|
};
|
|
|
|
Q_ENUM(TrayMessageType)
|
|
|
|
|
2019-12-21 15:14:40 +00:00
|
|
|
explicit FortManager(FortSettings *settings,
|
2017-09-11 03:54:19 +00:00
|
|
|
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
|
|
|
|
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; }
|
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; }
|
2020-01-13 04:30:42 +00:00
|
|
|
EnvManager *envManager() const { return m_envManager; }
|
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; }
|
2017-09-04 11:39:15 +00:00
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
signals:
|
2020-02-01 11:09:45 +00:00
|
|
|
void optWindowChanged();
|
|
|
|
|
2020-01-02 09:40:26 +00:00
|
|
|
void afterSaveProgWindowState();
|
|
|
|
void afterRestoreProgWindowState();
|
|
|
|
|
2019-12-24 04:06:30 +00:00
|
|
|
void afterSaveOptWindowState();
|
|
|
|
void afterRestoreOptWindowState();
|
2019-05-01 20:13:25 +00:00
|
|
|
|
2020-01-31 10:00:36 +00:00
|
|
|
void afterSaveZoneWindowState();
|
|
|
|
void afterRestoreZoneWindowState();
|
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
public slots:
|
2019-04-04 08:53:59 +00:00
|
|
|
void installDriver();
|
|
|
|
void removeDriver();
|
|
|
|
|
2019-02-08 19:25:01 +00:00
|
|
|
void launch();
|
|
|
|
|
2017-09-03 05:57:35 +00:00
|
|
|
void showTrayIcon();
|
2020-02-17 07:15:27 +00:00
|
|
|
void showTrayMessage(const QString &message,
|
|
|
|
FortManager::TrayMessageType type = MessageOptions);
|
2019-02-07 15:51:07 +00:00
|
|
|
void showTrayMenu(QMouseEvent *event);
|
2017-09-03 05:57:35 +00:00
|
|
|
|
2020-01-02 09:40:26 +00:00
|
|
|
void showProgramsWindow();
|
|
|
|
void closeProgramsWindow();
|
|
|
|
|
2019-12-16 10:41:44 +00:00
|
|
|
void showOptionsWindow();
|
|
|
|
void closeOptionsWindow();
|
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();
|
2019-02-10 15:55:23 +00:00
|
|
|
void closeGraphWindow(bool storeVisibility = 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
|
|
|
|
2017-09-06 08:39:20 +00:00
|
|
|
void exit(int retcode = 0);
|
|
|
|
|
2018-01-12 08:29:08 +00:00
|
|
|
bool checkPassword();
|
|
|
|
|
2017-12-23 09:51:23 +00:00
|
|
|
void showErrorBox(const QString &text,
|
|
|
|
const QString &title = QString());
|
|
|
|
void showInfoBox(const QString &text,
|
|
|
|
const QString &title = QString());
|
2019-12-20 09:30:16 +00:00
|
|
|
bool showQuestionBox(const QString &text,
|
|
|
|
const QString &title = QString());
|
2017-09-03 19:41:03 +00:00
|
|
|
|
2017-09-21 13:24:45 +00:00
|
|
|
bool saveOriginConf(const QString &message);
|
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-03 08:18:30 +00:00
|
|
|
private slots:
|
|
|
|
void saveTrayFlags();
|
|
|
|
|
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();
|
|
|
|
|
2020-01-31 10:00:36 +00:00
|
|
|
void setupModels();
|
|
|
|
|
2019-04-04 08:53:59 +00:00
|
|
|
void setupLogManager();
|
|
|
|
void closeLogManager();
|
|
|
|
|
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
|
|
|
|
2017-09-03 05:57:35 +00:00
|
|
|
void setupTrayIcon();
|
2018-04-10 12:41:20 +00:00
|
|
|
|
2019-10-06 06:15:46 +00:00
|
|
|
void setupAppInfoCache();
|
|
|
|
|
2020-01-02 09:40:26 +00:00
|
|
|
bool setupProgramsWindow();
|
2019-12-16 10:41:44 +00:00
|
|
|
bool setupOptionsWindow();
|
2020-01-31 10:00:36 +00:00
|
|
|
bool setupZonesWindow();
|
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
|
|
|
|
2020-01-02 09:40:26 +00:00
|
|
|
void saveProgWindowState();
|
|
|
|
void restoreProgWindowState();
|
|
|
|
|
2019-12-16 10:41:44 +00:00
|
|
|
void saveOptWindowState();
|
|
|
|
void restoreOptWindowState();
|
2018-01-09 07:36:20 +00:00
|
|
|
|
2020-01-31 10:00:36 +00:00
|
|
|
void saveZoneWindowState();
|
|
|
|
void restoreZoneWindowState();
|
|
|
|
|
2019-02-10 15:55:23 +00:00
|
|
|
void saveGraphWindowState(bool visible);
|
2018-03-15 15:35:49 +00:00
|
|
|
void restoreGraphWindowState();
|
|
|
|
|
2020-02-17 09:05:30 +00:00
|
|
|
void updateTrayIcon(bool alerted = false);
|
|
|
|
|
2020-02-01 11:09:45 +00:00
|
|
|
void updateTrayMenu(bool onlyFlags = false);
|
|
|
|
void createTrayMenu();
|
|
|
|
void updateTrayMenuFlags();
|
|
|
|
void retranslateTrayMenu();
|
2017-09-03 05:57:35 +00:00
|
|
|
|
2018-03-07 10:12:58 +00:00
|
|
|
void addHotKey(QAction *action, const QString &shortcutText,
|
|
|
|
bool hotKeyEnabled);
|
|
|
|
void removeHotKeys();
|
|
|
|
|
2017-09-03 05:57:35 +00:00
|
|
|
static QAction *addAction(QWidget *widget,
|
|
|
|
const QIcon &icon, const QString &text,
|
2017-11-01 14:06:47 +00:00
|
|
|
const QObject *receiver = nullptr, const char *member = nullptr,
|
2017-09-03 05:57:35 +00:00
|
|
|
bool checkable = false, bool checked = false);
|
|
|
|
static void setActionCheckable(QAction *action, bool checked = false,
|
2017-11-01 14:06:47 +00:00
|
|
|
const QObject *receiver = nullptr, const char *member = nullptr);
|
2017-09-03 05:57:35 +00:00
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
private:
|
2017-09-07 10:44:15 +00:00
|
|
|
MainWindow m_window; // dummy window for tray icon
|
2017-09-03 05:57:35 +00:00
|
|
|
|
2020-02-17 07:15:27 +00:00
|
|
|
TrayMessageType m_lastMessageType = MessageOptions;
|
|
|
|
|
2020-01-02 09:40:26 +00:00
|
|
|
bool m_trayTriggered = false;
|
2020-01-01 11:28:59 +00:00
|
|
|
QSystemTrayIcon *m_trayIcon = nullptr;
|
2020-01-02 09:40:26 +00:00
|
|
|
|
|
|
|
ProgramsWindow *m_progWindow = nullptr;
|
|
|
|
WidgetWindowStateWatcher *m_progWindowState = nullptr;
|
2018-01-10 02:41:42 +00:00
|
|
|
|
2020-01-01 11:28:59 +00:00
|
|
|
OptionsWindow *m_optWindow = nullptr;
|
|
|
|
WidgetWindowStateWatcher *m_optWindowState = nullptr;
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2020-01-31 10:00:36 +00:00
|
|
|
ZonesWindow *m_zoneWindow = nullptr;
|
|
|
|
WidgetWindowStateWatcher *m_zoneWindowState = nullptr;
|
|
|
|
|
2020-01-01 11:28:59 +00:00
|
|
|
GraphWindow *m_graphWindow = nullptr;
|
|
|
|
WidgetWindowStateWatcher *m_graphWindowState = nullptr;
|
2018-03-15 15:35:49 +00:00
|
|
|
|
2020-02-01 11:09:45 +00:00
|
|
|
QAction *m_programsAction = nullptr;
|
|
|
|
QAction *m_optionsAction = nullptr;
|
|
|
|
QAction *m_zonesAction = nullptr;
|
2020-01-01 11:28:59 +00:00
|
|
|
QAction *m_graphWindowAction = nullptr;
|
|
|
|
QAction *m_filterEnabledAction = nullptr;
|
|
|
|
QAction *m_stopTrafficAction = nullptr;
|
|
|
|
QAction *m_stopInetTrafficAction = nullptr;
|
2020-01-18 06:10:22 +00:00
|
|
|
QAction *m_allowAllNewAction = nullptr;
|
2020-02-01 11:09:45 +00:00
|
|
|
QAction *m_quitAction = nullptr;
|
2017-09-06 11:38:57 +00:00
|
|
|
QList<QAction *> m_appGroupActions;
|
2017-09-03 19:41:03 +00:00
|
|
|
|
2020-01-13 04:30:42 +00:00
|
|
|
FortSettings *m_settings = nullptr;
|
2020-01-01 11:28:59 +00:00
|
|
|
QuotaManager *m_quotaManager = nullptr;
|
|
|
|
StatManager *m_statManager = nullptr;
|
|
|
|
DriverManager *m_driverManager = nullptr;
|
|
|
|
EnvManager *m_envManager = 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;
|
|
|
|
NativeEventFilter *m_nativeEventFilter = nullptr;
|
|
|
|
HotKeyManager *m_hotKeyManager = nullptr;
|
|
|
|
TaskManager *m_taskManager = nullptr;
|
|
|
|
AppInfoCache *m_appInfoCache = nullptr;
|
2020-01-31 10:00:36 +00:00
|
|
|
|
|
|
|
AppListModel *m_appListModel = nullptr;
|
|
|
|
AppStatModel *m_appStatModel = nullptr;
|
|
|
|
ZoneListModel *m_zoneListModel = nullptr;
|
2017-09-01 13:13:12 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 15:13:17 +00:00
|
|
|
#endif // FORTMANAGER_H
|