From 213ba75585ddf98de9656077190bdbe2ebbeab64 Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Wed, 20 Nov 2024 17:50:58 +0000 Subject: [PATCH] App version & core user-agent --- Linphone/CMakeLists.txt | 18 ++++ Linphone/config.h.cmake | 4 +- Linphone/core/App.cpp | 28 ++++++ Linphone/core/App.hpp | 8 ++ Linphone/data/image/app-window.svg | 1 + Linphone/data/image/resource-package.svg | 3 + Linphone/model/core/CoreModel.cpp | 3 + Linphone/model/setting/SettingsModel.cpp | 9 ++ Linphone/model/setting/SettingsModel.hpp | 2 + Linphone/model/tool/ToolModel.cpp | 10 ++ Linphone/model/tool/ToolModel.hpp | 3 + Linphone/tool/Utils.cpp | 12 --- Linphone/tool/Utils.hpp | 2 +- Linphone/tool/config.h.cmake | 38 -------- .../Layout/Settings/DebugSettingsLayout.qml | 96 ++++++++++++++++--- Linphone/view/Page/Main/Help/HelpPage.qml | 2 +- Linphone/view/Style/AppIcons.qml | 2 + 17 files changed, 175 insertions(+), 66 deletions(-) create mode 100644 Linphone/data/image/app-window.svg create mode 100644 Linphone/data/image/resource-package.svg delete mode 100644 Linphone/tool/config.h.cmake diff --git a/Linphone/CMakeLists.txt b/Linphone/CMakeLists.txt index 4674ff1f7..03d38a016 100644 --- a/Linphone/CMakeLists.txt +++ b/Linphone/CMakeLists.txt @@ -59,6 +59,24 @@ set(LINPHONE_MICRO_VERSION) set(LINPHONE_BRANCH_VERSION) bc_parse_full_version(${LINPHONEAPP_VERSION} LINPHONE_MAJOR_VERSION LINPHONE_MINOR_VERSION LINPHONE_MICRO_VERSION LINPHONE_BRANCH_VERSION) +set(LINPHONEAPP_SHORT_VERSION "${LINPHONE_MAJOR_VERSION}.${LINPHONE_MINOR_VERSION}.${LINPHONE_MICRO_VERSION}") + +set(GIT_BRANCH_NAME) +execute_process( + COMMAND git name-rev --name-only HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH_NAME + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +set(LINPHONESDK_VERSION) +execute_process( + COMMAND git describe + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/external/linphone-sdk + OUTPUT_VARIABLE LINPHONESDK_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE +) + include(application_info.cmake) string(TIMESTAMP CURRENT_YEAR "%Y") if(NOT APPLICATION_START_LICENCE OR "${CURRENT_YEAR}" STREQUAL "${APPLICATION_START_LICENCE}") diff --git a/Linphone/config.h.cmake b/Linphone/config.h.cmake index 1c6dda0d6..f462cbfaf 100644 --- a/Linphone/config.h.cmake +++ b/Linphone/config.h.cmake @@ -36,4 +36,6 @@ #cmakedefine ENABLE_SCREENSHARING "${ENABLE_SCREENSHARING}" #cmakedefine QTKEYCHAIN_TARGET_NAME ${QTKEYCHAIN_TARGET_NAME} #cmakedefine PDF_ENABLED - +#cmakedefine LINPHONEAPP_SHORT_VERSION "${LINPHONEAPP_SHORT_VERSION}" +#cmakedefine GIT_BRANCH_NAME "${GIT_BRANCH_NAME}" +#cmakedefine LINPHONESDK_VERSION "${LINPHONESDK_VERSION}" diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index 1daba6654..660dd2c89 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -1069,3 +1069,31 @@ void App::setLocale(QString configLocale) { QLocale App::getLocale() { return mLocale; } + +//----------------------------------------------------------- +// Version infos. +//----------------------------------------------------------- + +QString App::getShortApplicationVersion() { +#ifdef LINPHONEAPP_SHORT_VERSION + return QStringLiteral(LINPHONEAPP_SHORT_VERSION); +#else + return tr("inconnue"); +#endif +} + +QString App::getGitBranchName() { +#ifdef GIT_BRANCH_NAME + return QStringLiteral(GIT_BRANCH_NAME); +#else + return tr("inconnue"); +#endif +} + +QString App::getSdkVersion() { +#ifdef LINPHONESDK_VERSION + return QStringLiteral(LINPHONESDK_VERSION); +#else + return tr("inconnue"); +#endif +} diff --git a/Linphone/core/App.hpp b/Linphone/core/App.hpp index c10c2a371..9ff636be2 100644 --- a/Linphone/core/App.hpp +++ b/Linphone/core/App.hpp @@ -41,6 +41,10 @@ class App : public SingleApplication, public AbstractObject { Q_PROPERTY(bool coreStarted READ getCoreStarted WRITE setCoreStarted NOTIFY coreStartedChanged) Q_PROPERTY(AccountList *accounts READ getAccounts NOTIFY accountsChanged) Q_PROPERTY(CallList *calls READ getCalls NOTIFY callsChanged) + Q_PROPERTY(QString shortApplicationVersion READ getShortApplicationVersion CONSTANT) + Q_PROPERTY(QString gitBranchName READ getGitBranchName CONSTANT) + Q_PROPERTY(QString sdkVersion READ getSdkVersion CONSTANT) + public: App(int &argc, char *argv[]); ~App(); @@ -137,6 +141,10 @@ public: void onExitOnCloseChanged(); // Can be used for UniqueConnection + QString getShortApplicationVersion(); + QString getGitBranchName(); + QString getSdkVersion(); + #ifdef Q_OS_LINUX Q_INVOKABLE void exportDesktopFile(); diff --git a/Linphone/data/image/app-window.svg b/Linphone/data/image/app-window.svg new file mode 100644 index 000000000..7b315e720 --- /dev/null +++ b/Linphone/data/image/app-window.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Linphone/data/image/resource-package.svg b/Linphone/data/image/resource-package.svg new file mode 100644 index 000000000..3003b374f --- /dev/null +++ b/Linphone/data/image/resource-package.svg @@ -0,0 +1,3 @@ + + + diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index 2a9718532..636bc3943 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -31,6 +31,7 @@ #include "core/App.hpp" #include "core/notifier/Notifier.hpp" #include "core/path/Paths.hpp" +#include "model/tool/ToolModel.hpp" #include "tool/Utils.hpp" // ============================================================================= @@ -90,6 +91,8 @@ void CoreModel::start() { } mCore->enableVideoPreview(false); // SDK doesn't write the state in configuration if not ready. config->setInt("video", "show_local", 0); // So : write ourself to turn off camera before starting the core. + QString userAgent = ToolModel::computeUserAgent(config); + mCore->setUserAgent(Utils::appStringToCoreString(userAgent), LINPHONESDK_VERSION); mCore->start(); setPathAfterStart(); mCore->enableFriendListSubscription(true); diff --git a/Linphone/model/setting/SettingsModel.cpp b/Linphone/model/setting/SettingsModel.cpp index bfc0ae484..8e335573b 100644 --- a/Linphone/model/setting/SettingsModel.cpp +++ b/Linphone/model/setting/SettingsModel.cpp @@ -545,6 +545,15 @@ void SettingsModel::setCarddavListForNewFriends(std::string name) { } } +// ============================================================================= +// Device name. +// ============================================================================= + +QString SettingsModel::getDeviceName(const std::shared_ptr &config) { + return Utils::coreStringToAppString( + config->getString(UiSection, "device_name", Utils::appStringToCoreString(QSysInfo::machineHostName()))); +} + // ============================================================================= // Ui. // ============================================================================= diff --git a/Linphone/model/setting/SettingsModel.hpp b/Linphone/model/setting/SettingsModel.hpp index 25d5364e0..3b4064703 100644 --- a/Linphone/model/setting/SettingsModel.hpp +++ b/Linphone/model/setting/SettingsModel.hpp @@ -132,6 +132,8 @@ public: static const std::shared_ptr getCarddavListForNewFriends(); static void setCarddavListForNewFriends(std::string listName); + static QString getDeviceName(const std::shared_ptr &config); + // UI DECLARE_GETSET(bool, disableChatFeature, DisableChatFeature) DECLARE_GETSET(bool, disableMeetingsFeature, DisableMeetingsFeature) diff --git a/Linphone/model/tool/ToolModel.cpp b/Linphone/model/tool/ToolModel.cpp index 65f29d0c0..610e7172f 100644 --- a/Linphone/model/tool/ToolModel.cpp +++ b/Linphone/model/tool/ToolModel.cpp @@ -358,3 +358,13 @@ QVariantMap ToolModel::createVariant(const std::shared_ptr &config) { + return QStringLiteral("%1 (%2) %3 Qt/%4 LinphoneSDK") + .arg(Utils::getApplicationProduct()) + .arg(SettingsModel::getDeviceName(config).replace('\\', "\\\\").replace('(', "\\(").replace(')', "\\)")) + .arg(Utils::getOsProduct()) + .arg(qVersion()); +} diff --git a/Linphone/model/tool/ToolModel.hpp b/Linphone/model/tool/ToolModel.hpp index 402ec32e2..8b9fff8a2 100644 --- a/Linphone/model/tool/ToolModel.hpp +++ b/Linphone/model/tool/ToolModel.hpp @@ -70,6 +70,9 @@ public: static QVariantMap createVariant(const std::shared_ptr &device); + static QString getOsProduct(); + static QString computeUserAgent(const std::shared_ptr &config); + private: DECLARE_ABSTRACT_OBJECT }; diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index e4771f3e8..845e76455 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -505,18 +505,6 @@ QString Utils::getOsProduct() { return product + "/" + version; } -QString Utils::computeUserAgent() { - // Placeholder - return "Linphone 6.0"; - /* - const std::shared_ptr &config - return QStringLiteral("%1 (%2) %3 Qt/%4 LinphoneSDK") - .arg(Utils::getApplicationProduct()) - .arg(SettingsModel::getDeviceName(config).replace('\\', "\\\\").replace('(', "\\(").replace(')', "\\)")) - .arg(Utils::getOsProduct()) - .arg(qVersion()); - */ -} QString Utils::getCountryName(const QLocale::Territory &p_country) { QString countryName; switch (p_country) { diff --git a/Linphone/tool/Utils.hpp b/Linphone/tool/Utils.hpp index 6c57f3b23..ba8f3bd0a 100644 --- a/Linphone/tool/Utils.hpp +++ b/Linphone/tool/Utils.hpp @@ -137,7 +137,7 @@ public: static QString getApplicationProduct(); static QString getOsProduct(); - static QString computeUserAgent(); + static QList> getDownloadableVideoPayloadTypes(); static void checkDownloadedCodecsUpdates(); diff --git a/Linphone/tool/config.h.cmake b/Linphone/tool/config.h.cmake deleted file mode 100644 index 8999ffb85..000000000 --- a/Linphone/tool/config.h.cmake +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* -* config.h.cmake -* Copyright (C) 2017-2024 Belledonne Communications, Grenoble France -* -******************************************************************************** -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*******************************************************************************/ - -#cmakedefine APPLICATION_DESCRIPTION "${APPLICATION_DESCRIPTION}" -#cmakedefine APPLICATION_ID "${APPLICATION_ID}" -#cmakedefine APPLICATION_NAME "${APPLICATION_NAME}" -#cmakedefine APPLICATION_VENDOR "${APPLICATION_VENDOR}" -#cmakedefine APPLICATION_URL "${APPLICATION_URL}" -#cmakedefine APPLICATION_LICENCE "${APPLICATION_LICENCE}" -#cmakedefine APPLICATION_LICENCE_URL "${APPLICATION_LICENCE_URL}" -#cmakedefine APPLICATION_SEMVER "${APPLICATION_SEMVER}" -#cmakedefine COPYRIGHT_RANGE_DATE "${COPYRIGHT_RANGE_DATE}" -#cmakedefine ENABLE_UPDATE_CHECK 1 -#cmakedefine EXECUTABLE_NAME "${EXECUTABLE_NAME}" -#cmakedefine MSPLUGINS_DIR "${MSPLUGINS_DIR}" -#cmakedefine ENABLE_APP_WEBVIEW "${ENABLE_APP_WEBVIEW}" -#cmakedefine QTKEYCHAIN_TARGET_NAME ${QTKEYCHAIN_TARGET_NAME} -#cmakedefine PDF_ENABLED - diff --git a/Linphone/view/Page/Layout/Settings/DebugSettingsLayout.qml b/Linphone/view/Page/Layout/Settings/DebugSettingsLayout.qml index c972c3f62..7a9078ba4 100644 --- a/Linphone/view/Page/Layout/Settings/DebugSettingsLayout.qml +++ b/Linphone/view/Page/Layout/Settings/DebugSettingsLayout.qml @@ -16,7 +16,12 @@ AbstractSettingsLayout { { title: "", subTitle: "", - contentComponent: content + contentComponent: versionContent + }, + { + title: "", + subTitle: "", + contentComponent: logContent } ] @@ -53,9 +58,9 @@ AbstractSettingsLayout { } Component { - id: content + id: logContent ColumnLayout { - spacing: 40 * DefaultStyle.dp + spacing: 20 * DefaultStyle.dp SwitchSetting { titleText: qsTr("Activer les traces de débogage") propertyName: "logsEnabled" @@ -66,18 +71,83 @@ AbstractSettingsLayout { propertyName: "fullLogsEnabled" propertyOwner: SettingsCpp } - MediumButton { - text: qsTr("Supprimer les traces") - onClicked: { - deleteLogs.open() + RowLayout { + spacing: 20 * DefaultStyle.dp + Layout.alignment: Qt.AlignRight + MediumButton { + text: qsTr("Supprimer les traces") + onClicked: { + deleteLogs.open() + } + } + MediumButton { + text: qsTr("Partager les traces") + enabled: SettingsCpp.logsEnabled || SettingsCpp.fullLogsEnabled + onClicked: { + UtilsCpp.getMainWindow().showLoadingPopup(qsTr("Téléversement des traces en cours ...")) + SettingsCpp.sendLogs() + } } } - MediumButton { - text: qsTr("Partager les traces") - enabled: SettingsCpp.logsEnabled || SettingsCpp.fullLogsEnabled - onClicked: { - UtilsCpp.getMainWindow().showLoadingPopup(qsTr("Téléversement des traces en cours ...")) - SettingsCpp.sendLogs() + } + } + + Component { + id: versionContent + ColumnLayout { + spacing: 20 * DefaultStyle.dp + RowLayout { + EffectImage { + imageSource: AppIcons.appWindow + colorizationColor: DefaultStyle.main1_500_main + Layout.preferredWidth: 24 * DefaultStyle.dp + Layout.preferredHeight: 24 * DefaultStyle.dp + imageWidth: 24 * DefaultStyle.dp + imageHeight: 24 * DefaultStyle.dp + Layout.alignment: Qt.AlignTop + } + ColumnLayout { + Text { + text: qsTr("Version de l'application") + font: Typography.p2l + wrapMode: Text.WordWrap + color: DefaultStyle.main2_600 + Layout.fillWidth: true + } + Text { + text: AppCpp.applicationVersion + ' ('+ AppCpp.gitBranchName + ')' + font: Typography.p1 + wrapMode: Text.WordWrap + color: DefaultStyle.main2_600 + Layout.fillWidth: true + } + } + } + RowLayout { + EffectImage { + imageSource: AppIcons.resourcePackage + colorizationColor: DefaultStyle.main1_500_main + Layout.preferredWidth: 24 * DefaultStyle.dp + Layout.preferredHeight: 24 * DefaultStyle.dp + imageWidth: 24 * DefaultStyle.dp + imageHeight: 24 * DefaultStyle.dp + Layout.alignment: Qt.AlignTop + } + ColumnLayout { + Text { + text: qsTr("Version du SDK") + font: Typography.p2l + wrapMode: Text.WordWrap + color: DefaultStyle.main2_600 + Layout.fillWidth: true + } + Text { + text: AppCpp.sdkVersion + font: Typography.p1 + wrapMode: Text.WordWrap + color: DefaultStyle.main2_600 + Layout.fillWidth: true + } } } } diff --git a/Linphone/view/Page/Main/Help/HelpPage.qml b/Linphone/view/Page/Main/Help/HelpPage.qml index ed3ee2bc6..2a39814e0 100644 --- a/Linphone/view/Page/Main/Help/HelpPage.qml +++ b/Linphone/view/Page/Main/Help/HelpPage.qml @@ -75,7 +75,7 @@ AbstractMainPage { Layout.fillWidth: true iconSource: AppIcons.info title: qsTr("Version") - subTitle: qsTr("1.0") + subTitle: AppCpp.shortApplicationVersion onClicked: {} } HelpIconLabelButton { diff --git a/Linphone/view/Style/AppIcons.qml b/Linphone/view/Style/AppIcons.qml index 8c2540408..a15bf6a66 100644 --- a/Linphone/view/Style/AppIcons.qml +++ b/Linphone/view/Style/AppIcons.qml @@ -122,4 +122,6 @@ QtObject { property string bellRinger: "image://internal/bell-ringer.svg" property string voicemail: "image://internal/voicemail.svg" property string power: "image://internal/power.svg" + property string resourcePackage: "image://internal/resource-package.svg" + property string appWindow: "image://internal/app-window.svg" }