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-03 05:57:35 +00:00
|
|
|
#include <QMainWindow>
|
2017-09-01 13:13:12 +00:00
|
|
|
|
|
|
|
class QQmlApplicationEngine;
|
2017-09-03 05:57:35 +00:00
|
|
|
class QSystemTrayIcon;
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-09-03 19:41:03 +00:00
|
|
|
class DriverManager;
|
2017-09-01 13:13:12 +00:00
|
|
|
class FortSettings;
|
|
|
|
class FirewallConf;
|
2017-09-04 11:39:15 +00:00
|
|
|
class LogBuffer;
|
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-03 05:57:35 +00:00
|
|
|
Q_PROPERTY(FirewallConf *firewallConfToEdit READ firewallConfToEdit NOTIFY firewallConfToEditChanged)
|
2017-09-04 11:39:15 +00:00
|
|
|
Q_PROPERTY(DriverManager *driverManager READ driverManager CONSTANT)
|
2017-09-01 13:13:12 +00:00
|
|
|
|
|
|
|
public:
|
2017-09-01 15:13:17 +00:00
|
|
|
explicit FortManager(QObject *parent = nullptr);
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-09-02 10:17:51 +00:00
|
|
|
FortSettings *fortSettings() const { return m_fortSettings; }
|
2017-09-03 05:57:35 +00:00
|
|
|
|
|
|
|
FirewallConf *firewallConfToEdit() const {
|
|
|
|
return m_firewallConfToEdit ? m_firewallConfToEdit : m_firewallConf;
|
|
|
|
}
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-09-04 11:39:15 +00:00
|
|
|
DriverManager *driverManager() const { return m_driverManager; }
|
|
|
|
|
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-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
|
|
|
|
2017-09-06 08:39:20 +00:00
|
|
|
void exit(int retcode = 0);
|
|
|
|
|
2017-09-03 19:41:03 +00:00
|
|
|
void showErrorBox(const QString &text);
|
|
|
|
|
2017-09-01 15:13:17 +00:00
|
|
|
bool saveConf();
|
2017-09-02 14:25:47 +00:00
|
|
|
bool applyConf();
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-09-04 11:39:15 +00:00
|
|
|
void setAppLogBlocked(bool enable);
|
|
|
|
|
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-09-03 05:57:35 +00:00
|
|
|
void setupTrayIcon();
|
|
|
|
void setupEngine();
|
2017-09-01 13:13:12 +00:00
|
|
|
|
2017-09-04 13:53:45 +00:00
|
|
|
bool loadSettings(FirewallConf *conf);
|
2017-09-02 14:25:47 +00:00
|
|
|
bool saveSettings(FirewallConf *newConf);
|
2017-09-04 13:53:45 +00:00
|
|
|
|
|
|
|
bool updateDriverConf(FirewallConf *conf);
|
|
|
|
bool updateDriverConfFlags(FirewallConf *conf);
|
2017-09-02 14:25:47 +00:00
|
|
|
|
|
|
|
FirewallConf *cloneConf(const FirewallConf &conf);
|
2017-09-02 10:17:51 +00:00
|
|
|
|
2017-09-03 05:57:35 +00:00
|
|
|
void updateTrayMenu();
|
|
|
|
|
|
|
|
static QAction *addAction(QWidget *widget,
|
|
|
|
const QIcon &icon, const QString &text,
|
|
|
|
const QObject *receiver = 0, const char *member = 0,
|
|
|
|
bool checkable = false, bool checked = false);
|
|
|
|
static void setActionCheckable(QAction *action, bool checked = false,
|
|
|
|
const QObject *receiver = 0, const char *member = 0);
|
|
|
|
|
2017-09-01 13:13:12 +00:00
|
|
|
private:
|
2017-09-03 05:57:35 +00:00
|
|
|
QMainWindow m_window; // dummy window for tray icon
|
|
|
|
|
|
|
|
QSystemTrayIcon *m_trayIcon;
|
2017-09-01 13:13:12 +00:00
|
|
|
QQmlApplicationEngine *m_engine;
|
2017-09-03 05:57:35 +00:00
|
|
|
QWindow *m_appWindow;
|
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
|
|
|
|
|
|
|
QAction *m_filterEnabledAction;
|
|
|
|
QAction *m_ipIncludeAllAction;
|
|
|
|
QAction *m_ipExcludeAllAction;
|
|
|
|
QAction *m_appBlockAllAction;
|
|
|
|
QAction *m_appAllowAllAction;
|
|
|
|
QMenu *m_appGroupsMenu;
|
2017-09-03 19:41:03 +00:00
|
|
|
|
|
|
|
DriverManager *m_driverManager;
|
2017-09-01 13:13:12 +00:00
|
|
|
};
|
|
|
|
|
2017-09-01 15:13:17 +00:00
|
|
|
#endif // FORTMANAGER_H
|