From 62c72bd0e58d2839db559f7bd32f6cff5d7a2121 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Mon, 16 Jan 2023 15:37:02 +0100 Subject: [PATCH] Fix user agent to be more compliant. --- CHANGELOG.md | 1 + linphone-app/src/utils/Utils.cpp | 17 ++++++++++++++--- linphone-app/src/utils/Utils.hpp | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af730647b..f4bfa9b0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Mini views layout on actives speaker. - Set 1 month to default message expires. +- User-agent format compliance ## 5.0.6 - 2023-01-10 diff --git a/linphone-app/src/utils/Utils.cpp b/linphone-app/src/utils/Utils.cpp index 5b8cf8025..5eb884ee0 100644 --- a/linphone-app/src/utils/Utils.cpp +++ b/linphone-app/src/utils/Utils.cpp @@ -542,11 +542,22 @@ std::shared_ptr Utils::getConfigIfExists (const QString &confi return linphone::Config::newWithFactory(configPath.toStdString(), factoryPath); } +QString Utils::getApplicationProduct(){ +// Note: Keep '-' as a separator between application name and application type + return QString(APPLICATION_NAME"-Desktop").remove(' ')+"/"+QCoreApplication::applicationVersion(); +} + +QString Utils::getOsProduct(){ + QString version = QSysInfo::productVersion().remove(' ');// A version can be "Server 2016" (for Windows Server 2016) + QString product = QSysInfo::productType().replace(' ', '-'); // Just in case + return product+"/"+version; +} + QString Utils::computeUserAgent(const std::shared_ptr& config){ - return QStringLiteral(APPLICATION_NAME" Desktop/%1 (%2) %3, Qt %4 LinphoneCore") - .arg(QCoreApplication::applicationVersion()) + return QStringLiteral("%1 (%2) %3 Qt/%4 LinphoneSDK") + .arg(Utils::getApplicationProduct()) .arg(SettingsModel::getDeviceName(config)) - .arg(QSysInfo::prettyProductName()) + .arg(Utils::getOsProduct()) .arg(qVersion()); } diff --git a/linphone-app/src/utils/Utils.hpp b/linphone-app/src/utils/Utils.hpp index 8c8fcc8b5..4c117bcd2 100644 --- a/linphone-app/src/utils/Utils.hpp +++ b/linphone-app/src/utils/Utils.hpp @@ -142,6 +142,8 @@ public: static void copyDir(QString from, QString to);// Copy a folder recursively without erasing old file static QString getDisplayName(const std::shared_ptr& address); // Get the displayname from addres in this order : Friends, Contact, Display address, Username address static std::shared_ptr getConfigIfExists (const QString& configPath); + static QString getApplicationProduct(); + static QString getOsProduct(); static QString computeUserAgent(const std::shared_ptr& config); static bool isMe(const std::shared_ptr& address);