From a8a6f5ce748d281a3101b1dfc489f725ff35ab05 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 15 Jun 2017 13:49:06 +0200 Subject: [PATCH] fix(App): deal correctly with single app, avoid usage of two binaries --- src/app/App.cpp | 13 ++++--------- src/components/core/CoreManager.cpp | 7 ++----- src/main.cpp | 9 +++++++++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/app/App.cpp b/src/app/App.cpp index 80365504f..1ea669109 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -29,8 +29,6 @@ #include #include -#include "gitversion.h" - #include "../components/Components.hpp" #include "../utils/Utils.hpp" @@ -57,10 +55,6 @@ #define SELF_TEST_DELAY 300000 -#ifndef LINPHONE_QT_GIT_VERSION - #define LINPHONE_QT_GIT_VERSION "unknown" -#endif // ifndef LINPHONE_QT_GIT_VERSION - using namespace std; // ============================================================================= @@ -69,8 +63,7 @@ inline bool installLocale (App &app, QTranslator &translator, const QLocale &loc return translator.load(locale, LANGUAGES_PATH) && app.installTranslator(&translator); } -App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true) { - setApplicationVersion(LINPHONE_QT_GIT_VERSION); +App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::User | Mode::ExcludeAppPath | Mode::ExcludeAppVersion) { setWindowIcon(QIcon(WINDOW_ICON_PATH)); createParser(); @@ -264,7 +257,9 @@ void App::smartShowWindow (QQuickWindow *window) { } void App::checkForUpdate () { - CoreManager::getInstance()->getCore()->checkForUpdate(LINPHONE_QT_GIT_VERSION); + CoreManager::getInstance()->getCore()->checkForUpdate( + ::Utils::appStringToCoreString(applicationVersion()) + ); } // ----------------------------------------------------------------------------- diff --git a/src/components/core/CoreManager.cpp b/src/components/core/CoreManager.cpp index 87c299ece..2d291948e 100644 --- a/src/components/core/CoreManager.cpp +++ b/src/components/core/CoreManager.cpp @@ -20,6 +20,7 @@ * Author: Ronan Abhamon */ +#include #include #include #include @@ -29,10 +30,6 @@ #include "CoreManager.hpp" -#ifndef LINPHONE_QT_GIT_VERSION - #define LINPHONE_QT_GIT_VERSION "unknown" -#endif // ifndef LINPHONE_QT_GIT_VERSION - #define CBS_CALL_INTERVAL 20 #define DOWNLOAD_URL "https://www.linphone.org/technical-corner/linphone/downloads" @@ -154,7 +151,7 @@ void CoreManager::createLinphoneCore (const QString &configPath) { mCore->setVideoDisplayFilter("MSOGL"); mCore->usePreviewWindow(true); - mCore->setUserAgent("Linphone Desktop", LINPHONE_QT_GIT_VERSION); + mCore->setUserAgent("Linphone Desktop", ::Utils::appStringToCoreString(QCoreApplication::applicationVersion())); // Force capture/display. // Useful if the app was built without video support. diff --git a/src/main.cpp b/src/main.cpp index 4d3868d7f..a062f6298 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,8 +24,14 @@ #include #include +#include "gitversion.h" + #include "app/App.hpp" +// Must be unique. Used by `SingleApplication`. +#define APPLICATION_NAME "Linphone Desktop" +#define APPLICATION_VERSION LINPHONE_QT_GIT_VERSION + #define DEFAULT_FONT "Noto Sans" using namespace std; @@ -69,6 +75,9 @@ int main (int argc, char *argv[]) { // App creation. // --------------------------------------------------------------------------- + QCoreApplication::setApplicationName(APPLICATION_NAME); + QCoreApplication::setApplicationVersion(APPLICATION_VERSION); + App app(argc, argv); if (app.isSecondary()) {