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"
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-12-06 02:51:40 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QQmlApplicationEngine)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QSystemTrayIcon)
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-12-06 02:51:40 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(DatabaseManager)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(DriverManager)
|
|
|
|
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)
|
2018-02-19 15:01:35 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QuotaManager)
|
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)
|
2018-01-10 02:41:42 +00:00
|
|
|
QT_FORWARD_DECLARE_CLASS(WindowStateWatcher)
|
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
|
2017-09-02 10:17:51 +00:00
|
|
|
Q_PROPERTY(FortSettings *fortSettings READ fortSettings CONSTANT)
|
2017-09-11 06:16:51 +00:00
|
|
|
Q_PROPERTY(FirewallConf *firewallConf READ firewallConf NOTIFY firewallConfToEditChanged)
|
2017-09-03 05:57:35 +00:00
|
|
|
Q_PROPERTY(FirewallConf *firewallConfToEdit READ firewallConfToEdit NOTIFY firewallConfToEditChanged)
|
2017-11-10 13:36:29 +00:00
|
|
|
Q_PROPERTY(LogManager *logManager READ logManager CONSTANT)
|
2017-09-19 08:35:43 +00:00
|
|
|
Q_PROPERTY(TaskManager *taskManager READ taskManager CONSTANT)
|
2017-09-01 13:13:12 +00:00
|
|
|
|
|
|
|
public:
|
2017-09-11 03:54:19 +00:00
|
|
|
explicit FortManager(FortSettings *fortSettings,
|
|
|
|
QObject *parent = nullptr);
|
2019-02-08 08:19:20 +00:00
|
|
|
~FortManager() override;
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-09-02 10:17:51 +00:00
|
|
|
FortSettings *fortSettings() const { return m_fortSettings; }
|
2017-09-11 06:16:51 +00:00
|
|
|
FirewallConf *firewallConf() const { return m_firewallConf; }
|
|
|
|
FirewallConf *firewallConfToEdit() const { return m_firewallConfToEdit; }
|
2017-09-01 13:13:12 +00:00
|
|
|
|
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; }
|
2017-09-04 11:39:15 +00:00
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
signals:
|
2017-09-03 05:57:35 +00:00
|
|
|
void firewallConfToEditChanged();
|
2017-09-01 13:13:12 +00:00
|
|
|
|
|
|
|
public slots:
|
2017-09-03 05:57:35 +00:00
|
|
|
void showTrayIcon();
|
2017-09-21 13:24:45 +00:00
|
|
|
void showTrayMessage(const QString &message);
|
2019-02-07 15:51:07 +00:00
|
|
|
void showTrayMenu(QMouseEvent *event);
|
2017-09-03 05:57:35 +00:00
|
|
|
|
2017-09-01 15:13:17 +00:00
|
|
|
void showWindow();
|
2017-09-03 05:57:35 +00:00
|
|
|
void closeWindow();
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2018-03-15 15:35:49 +00:00
|
|
|
void showGraphWindow();
|
|
|
|
void closeGraphWindow();
|
|
|
|
void switchGraphWindow();
|
|
|
|
|
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());
|
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-09 04:24:04 +00:00
|
|
|
void setLanguage(int language);
|
2017-09-07 10:44:15 +00:00
|
|
|
|
2017-09-03 08:18:30 +00:00
|
|
|
private slots:
|
|
|
|
void saveTrayFlags();
|
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
private:
|
2017-09-03 05:57:35 +00:00
|
|
|
FirewallConf *nullConf() const { return nullptr; }
|
|
|
|
|
|
|
|
void setFirewallConfToEdit(FirewallConf *conf);
|
|
|
|
|
2017-09-02 10:17:51 +00:00
|
|
|
static void registerQmlTypes();
|
|
|
|
|
2017-09-04 13:53:45 +00:00
|
|
|
bool setupDriver();
|
2017-11-10 13:36:29 +00:00
|
|
|
void closeDriver();
|
|
|
|
|
2018-02-19 15:01:35 +00:00
|
|
|
void setupDatabaseManager();
|
|
|
|
|
2018-01-11 08:54:38 +00:00
|
|
|
void setupLogger();
|
2017-12-08 02:38:02 +00:00
|
|
|
void setupLogManager();
|
|
|
|
|
2018-12-25 07:36:11 +00:00
|
|
|
void setupTranslationManager();
|
|
|
|
|
2017-09-03 05:57:35 +00:00
|
|
|
void setupTrayIcon();
|
2018-04-10 12:41:20 +00:00
|
|
|
|
2017-09-10 06:52:38 +00:00
|
|
|
bool setupEngine();
|
2018-04-10 12:41:20 +00:00
|
|
|
void closeEngine();
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-09-04 13:53:45 +00:00
|
|
|
bool loadSettings(FirewallConf *conf);
|
2017-11-20 14:39:57 +00:00
|
|
|
bool saveSettings(FirewallConf *newConf, bool onlyFlags = false,
|
2017-12-14 10:23:40 +00:00
|
|
|
bool immediateFlags = false);
|
2017-09-04 13:53:45 +00:00
|
|
|
|
2018-12-25 07:36:11 +00:00
|
|
|
bool updateDriverConf(FirewallConf *conf, bool onlyFlags = false);
|
2017-09-02 14:25:47 +00:00
|
|
|
|
2018-02-20 12:21:10 +00:00
|
|
|
void updateLogManager(bool active);
|
2017-12-11 06:05:49 +00:00
|
|
|
void updateDatabaseManager(FirewallConf *conf);
|
2017-12-08 02:38:02 +00:00
|
|
|
|
2017-09-02 14:25:47 +00:00
|
|
|
FirewallConf *cloneConf(const FirewallConf &conf);
|
2017-09-02 10:17:51 +00:00
|
|
|
|
2018-01-09 07:36:20 +00:00
|
|
|
void saveWindowState();
|
|
|
|
void restoreWindowState();
|
|
|
|
|
2018-03-15 15:35:49 +00:00
|
|
|
void saveGraphWindowState();
|
|
|
|
void restoreGraphWindowState();
|
|
|
|
|
2018-01-11 08:54:38 +00:00
|
|
|
void updateLogger();
|
2017-09-03 05:57:35 +00:00
|
|
|
void updateTrayMenu();
|
|
|
|
|
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
|
|
|
|
|
|
|
QSystemTrayIcon *m_trayIcon;
|
2017-09-01 13:13:12 +00:00
|
|
|
QQmlApplicationEngine *m_engine;
|
2018-01-10 02:41:42 +00:00
|
|
|
|
2017-09-03 05:57:35 +00:00
|
|
|
QWindow *m_appWindow;
|
2018-01-10 02:41:42 +00:00
|
|
|
WindowStateWatcher *m_appWindowState;
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2018-03-15 15:35:49 +00:00
|
|
|
GraphWindow *m_graphWindow;
|
|
|
|
WidgetWindowStateWatcher *m_graphWindowState;
|
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
FortSettings *m_fortSettings;
|
2017-09-01 15:13:17 +00:00
|
|
|
FirewallConf *m_firewallConf;
|
2017-09-02 10:17:51 +00:00
|
|
|
FirewallConf *m_firewallConfToEdit;
|
2017-09-03 08:18:30 +00:00
|
|
|
|
2018-03-19 10:15:54 +00:00
|
|
|
QAction *m_graphWindowAction;
|
2017-09-03 08:18:30 +00:00
|
|
|
QAction *m_filterEnabledAction;
|
2017-12-23 06:15:36 +00:00
|
|
|
QAction *m_stopTrafficAction;
|
2018-01-12 08:52:09 +00:00
|
|
|
QAction *m_stopInetTrafficAction;
|
2017-09-06 11:38:57 +00:00
|
|
|
QList<QAction *> m_appGroupActions;
|
2017-09-03 19:41:03 +00:00
|
|
|
|
2018-02-19 15:01:35 +00:00
|
|
|
QuotaManager *m_quotaManager;
|
2017-12-01 14:13:06 +00:00
|
|
|
DatabaseManager *m_databaseManager;
|
2017-09-03 19:41:03 +00:00
|
|
|
DriverManager *m_driverManager;
|
2017-11-10 13:36:29 +00:00
|
|
|
LogManager *m_logManager;
|
2018-03-07 10:12:58 +00:00
|
|
|
NativeEventFilter *m_nativeEventFilter;
|
|
|
|
HotKeyManager *m_hotKeyManager;
|
2017-09-19 08:35:43 +00:00
|
|
|
TaskManager *m_taskManager;
|
2017-09-01 13:13:12 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 15:13:17 +00:00
|
|
|
#endif // FORTMANAGER_H
|