From 7beb143270fe58f9dc650ddbd9c6a9dbc62169fb Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 31 Mar 2021 15:42:36 +0300 Subject: [PATCH] Installer: Add global setup mutex. --- deploy/FortFirewall.iss | 11 ++++++----- src/ui/FortFirewall.rc | 6 +++--- src/ui/fortsettings.cpp | 8 ++++---- src/ui/main.cpp | 2 +- src/ui/util/startuputil.cpp | 2 +- src/version/fort_version.h | 1 + 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/deploy/FortFirewall.iss b/deploy/FortFirewall.iss index 20a3d6f5..4e25942a 100644 --- a/deploy/FortFirewall.iss +++ b/deploy/FortFirewall.iss @@ -3,8 +3,8 @@ #include SRC_PATH + "\version\fort_version.h" -#define APP_EXE_NAME "FortFirewall.exe" -#define APP_ICO_NAME "FortFirewall.ico" +#define APP_EXE_NAME APP_BASE + ".exe" +#define APP_ICO_NAME APP_BASE + ".ico" #define APP_EXE StringChange("{app}\%exe%", "%exe%", APP_EXE_NAME) @@ -12,7 +12,8 @@ ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppMutex={#APP_NAME} +SetupMutex=Global\Setup{#APP_BASE} +AppMutex={#APP_NAME},{#APP_BASE},Global\{#APP_BASE} AppName={#APP_NAME} AppVersion={#APP_VERSION_STR} VersionInfoVersion={#APP_VERSION_STR} @@ -27,7 +28,7 @@ DefaultDirName={pf32}\{#APP_NAME} AlwaysShowDirOnReadyPage=yes AlwaysShowGroupOnReadyPage=yes AllowNoIcons=yes -OutputBaseFilename=FortFirewall-{#APP_VERSION_STR} +OutputBaseFilename={#APP_BASE}-{#APP_VERSION_STR} Uninstallable=not IsTaskSelected('portable') UninstallFilesDir={app}\uninst UninstallDisplayIcon={uninstallexe} @@ -47,7 +48,7 @@ Name: "portable"; Description: "Portable"; Flags: unchecked [Files] Source: "build\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs -Source: "FortFirewall.exe.example.ini"; DestDir: "{app}" +Source: "{#APP_EXE_NAME}.example.ini"; DestDir: "{app}" Source: "README.portable"; DestDir: "{app}"; Tasks: portable [Registry] diff --git a/src/ui/FortFirewall.rc b/src/ui/FortFirewall.rc index 5cffce3b..a7f211c1 100644 --- a/src/ui/FortFirewall.rc +++ b/src/ui/FortFirewall.rc @@ -9,13 +9,13 @@ #define VER_PRODUCTVERSION_STR APP_VERSION_STR #define VER_COMPANYNAME_STR APP_PUBLISHER -#define VER_FILEDESCRIPTION_STR "Fort Firewall" -#define VER_INTERNALNAME_STR "FortFirewall" +#define VER_FILEDESCRIPTION_STR APP_NAME +#define VER_INTERNALNAME_STR APP_BASE #define VER_LEGALCOPYRIGHT_STR APP_LEGALCOPYRIGHT #define VER_LEGALTRADEMARKS1_STR "" #define VER_LEGALTRADEMARKS2_STR "" #define VER_ORIGINALFILENAME_STR "FortFirewall.exe" -#define VER_PRODUCTNAME_STR "Fort Firewall" +#define VER_PRODUCTNAME_STR APP_NAME #ifdef _DEBUG #define VER_DEBUG (VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE|VS_FF_DEBUG) diff --git a/src/ui/fortsettings.cpp b/src/ui/fortsettings.cpp index 59c4519f..e9ca7a3a 100644 --- a/src/ui/fortsettings.cpp +++ b/src/ui/fortsettings.cpp @@ -51,7 +51,7 @@ int FortSettings::appVersion() const void FortSettings::setupGlobal() { // Use global settings from program's working directory. - const QSettings settings("FortFirewall.exe.ini", QSettings::IniFormat); + const QSettings settings(APP_BASE ".exe.ini", QSettings::IniFormat); // High-DPI scale factor rounding policy const auto dpiPolicy = settings.value("global/dpiPolicy").toString(); @@ -186,7 +186,7 @@ void FortSettings::processArguments(const QStringList &args, EnvManager *envMana void FortSettings::setupIni() { - const QString iniPath(profilePath() + "FortFirewall.ini"); + const QString iniPath(profilePath() + (APP_BASE ".ini")); FileUtil::makePath(profilePath()); FileUtil::makePath(statPath()); @@ -211,12 +211,12 @@ void FortSettings::setErrorMessage(const QString &errorMessage) QString FortSettings::statFilePath() const { - return statPath() + QLatin1String("FortFirewall.stat"); + return statPath() + (APP_BASE ".stat"); } QString FortSettings::confFilePath() const { - return profilePath() + QLatin1String("FortFirewall.config"); + return profilePath() + (APP_BASE ".config"); } void FortSettings::readConfIni(FirewallConf &conf) const diff --git a/src/ui/main.cpp b/src/ui/main.cpp index 3a6b26b6..482ca9dd 100644 --- a/src/ui/main.cpp +++ b/src/ui/main.cpp @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) #ifdef APP_SINGLE_INSTANCE // Check running instance - if (!OsUtil::createGlobalMutex(APP_NAME)) { + if (!OsUtil::createGlobalMutex(APP_BASE)) { QMessageBox::critical(nullptr, QString(), "Application is already running!"); return FORT_ERROR_INSTANCE; } diff --git a/src/ui/util/startuputil.cpp b/src/ui/util/startuputil.cpp index 97876a0a..1cf97aad 100644 --- a/src/ui/util/startuputil.cpp +++ b/src/ui/util/startuputil.cpp @@ -13,7 +13,7 @@ namespace { -const char *const serviceName = "FortFirewallSvc"; +const char *const serviceName = APP_BASE "Svc"; const char *const regCurUserRun = R"(HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run)"; diff --git a/src/version/fort_version.h b/src/version/fort_version.h index 8b8b7bfe..0ace3447 100644 --- a/src/version/fort_version.h +++ b/src/version/fort_version.h @@ -8,6 +8,7 @@ #define APP_VERSION 0x030400 #define APP_NAME "Fort Firewall" +#define APP_BASE "FortFirewall" #define APP_PUBLISHER "Nodir Temirkhodjaev" #define APP_LEGALCOPYRIGHT "Copyright (C) 2015-2021 Nodir Temirkhodjaev. All Rights Reserved." #define APP_URL "https://github.com/tnodir/fort"