From ebf3f2ddeb22558184680ce19b122be87cc0b364 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 13 Sep 2017 16:08:27 +0500 Subject: [PATCH] Installer: Add option "Block access to network when Fort Firewall is not running". --- deploy/FortFirewall.iss | 7 ++++++- src/ui/fortsettings.cpp | 16 +++++++++++----- src/ui/fortsettings.h | 6 ++++-- src/ui/main.cpp | 10 ++++++---- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/deploy/FortFirewall.iss b/deploy/FortFirewall.iss index c073c8b3..98de1885 100644 --- a/deploy/FortFirewall.iss +++ b/deploy/FortFirewall.iss @@ -32,20 +32,25 @@ SolidCompression=yes [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" +[Tasks] +Name: "provBoot"; Description: "Block access to network when Fort Firewall is not running"; Flags: unchecked + [Files] Source: ".\build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs [Icons] ; Start menu shortcut Name: "{group}\{#APP_NAME}"; Filename: "{app}\{#APP_EXE_NAME}"; IconFilename: "{app}\fort.ico" -; Unistaller shortcut +; Uninstaller shortcut Name: "{group}\{cm:UninstallProgram,{#APP_NAME}}"; Filename: "{uninstallexe}"; IconFilename: "{app}\fort.ico" [Run] +Filename: "{app}\{#APP_EXE_NAME}"; Parameters: "-b=1"; Description: "Provider boot"; Flags: runascurrentuser; Tasks: provBoot Filename: "{app}\driver\scripts\install.bat"; Description: "Install driver"; Flags: runascurrentuser [UninstallRun] Filename: "{app}\driver\scripts\uninstall.bat"; Flags: runascurrentuser +Filename: "{app}\{#APP_EXE_NAME}"; Parameters: "-b=0"; Flags: runascurrentuser [UninstallDelete] Type: filesandordirs; Name: "{app}" diff --git a/src/ui/fortsettings.cpp b/src/ui/fortsettings.cpp index cfd94250..e25c7763 100644 --- a/src/ui/fortsettings.cpp +++ b/src/ui/fortsettings.cpp @@ -11,7 +11,9 @@ FortSettings::FortSettings(const QStringList &args, QObject *parent) : - QObject(parent) + QObject(parent), + m_hasProvBoot(false), + m_provBoot(false) { processArguments(args); setupIni(); @@ -37,9 +39,10 @@ void FortSettings::processArguments(const QStringList &args) { QCommandLineParser parser; - const QCommandLineOption bootOption( - "boot", "Block access to network when Fort Firewall is not running."); - parser.addOption(bootOption); + const QCommandLineOption provBootOption( + QStringList() << "b" << "boot", + "Block access to network when Fort Firewall is not running.", "boot"); + parser.addOption(provBootOption); const QCommandLineOption profileOption( QStringList() << "p" << "profile", @@ -51,7 +54,10 @@ void FortSettings::processArguments(const QStringList &args) parser.process(args); - m_boot = parser.isSet(bootOption); + m_hasProvBoot = parser.isSet(provBootOption); + if (m_hasProvBoot) { + m_provBoot = QVariant(parser.value(provBootOption)).toBool(); + } m_profilePath = parser.value(profileOption); if (m_profilePath.isEmpty()) { diff --git a/src/ui/fortsettings.h b/src/ui/fortsettings.h index a30aed86..466a89a5 100644 --- a/src/ui/fortsettings.h +++ b/src/ui/fortsettings.h @@ -21,7 +21,8 @@ public: explicit FortSettings(const QStringList &args, QObject *parent = nullptr); - bool boot() const { return m_boot; } + bool hasProvBoot() const { return m_hasProvBoot; } + bool provBoot() const { return m_provBoot; } bool debug() const { return iniBool("base/debug"); } void setDebug(bool on) { setIniValue("base/debug", on); } @@ -75,7 +76,8 @@ private: static QString startupShortcutPath(); private: - uint m_boot : 1; + uint m_hasProvBoot : 1; + uint m_provBoot : 1; QString m_profilePath; diff --git a/src/ui/main.cpp b/src/ui/main.cpp index e7bc815c..f19b38a8 100644 --- a/src/ui/main.cpp +++ b/src/ui/main.cpp @@ -9,8 +9,6 @@ int main(int argc, char *argv[]) { - OsUtil::createGlobalMutex(APP_NAME); - QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); @@ -21,11 +19,15 @@ int main(int argc, char *argv[]) FortSettings fortSettings(qApp->arguments()); // Register booted provider and exit - if (fortSettings.boot()) { + if (fortSettings.hasProvBoot()) { FortCommon::provUnregister(); - return FortCommon::provRegister(true); + return fortSettings.provBoot() + ? FortCommon::provRegister(true) : 0; } + // To check running instance + OsUtil::createGlobalMutex(APP_NAME); + FortManager fortManager(&fortSettings); // Error: Cannot open the driver device