From 4fc2b1f1a319c599e32a5dc2545d50371e5cf38b Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 15 Mar 2021 20:14:29 +0400 Subject: [PATCH] Append x64 to app_version on Windows. --- .../SourceFiles/mtproto/session_private.cpp | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/Telegram/SourceFiles/mtproto/session_private.cpp b/Telegram/SourceFiles/mtproto/session_private.cpp index 2698a49e99..e7aa978ab9 100644 --- a/Telegram/SourceFiles/mtproto/session_private.cpp +++ b/Telegram/SourceFiles/mtproto/session_private.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/openssl_help.h" #include "base/qthelp_url.h" #include "base/unixtime.h" +#include "base/platform/base_platform_info.h" #include "zlib.h" namespace MTP { @@ -81,6 +82,25 @@ using namespace details; return idsStr + "]"; } +[[nodiscard]] QString ComputeAppVersion() { + return QString::fromLatin1(AppVersionStr) + ([] { +#if defined OS_MAC_STORE + return u" Mac App Store"_q; +#elif defined OS_WIN_STORE // OS_MAC_STORE + return (Platform::IsWindows64Bit() ? u" x64"_q : QString()) + + u" Microsoft Store"_q; +#elif defined Q_OS_UNIX && !defined Q_OS_MAC // OS_MAC_STORE || OS_WIN_STORE + return Platform::InFlatpak() + ? u" Flatpak"_q + : Platform::InSnap() + ? u" Snap"_q + : QString(); +#else // OS_MAC_STORE || OS_WIN_STORE || (defined Q_OS_UNIX && !defined Q_OS_MAC) + return Platform::IsWindows64Bit() ? u" x64"_q : QString(); +#endif // OS_MAC_STORE || OS_WIN_STORE || (defined Q_OS_UNIX && !defined Q_OS_MAC) + })(); +} + void WrapInvokeAfter( SerializedRequest &to, const SerializedRequest &from, @@ -632,26 +652,7 @@ void SessionPrivate::tryToSend() { const auto systemVersion = (_currentDcType == DcType::Cdn) ? "n/a" : _instance->systemVersion(); -#if defined OS_MAC_STORE - const auto appVersion = QString::fromLatin1(AppVersionStr) - + " Mac App Store"; -#elif defined OS_WIN_STORE // OS_MAC_STORE - const auto appVersion = QString::fromLatin1(AppVersionStr) - + " Microsoft Store"; -#elif defined Q_OS_UNIX && !defined Q_OS_MAC // OS_MAC_STORE || OS_WIN_STORE - const auto appVersion = [] { - if (Platform::InFlatpak()) { - return QString::fromLatin1(AppVersionStr) - + " Flatpak"; - } else if (Platform::InSnap()) { - return QString::fromLatin1(AppVersionStr) - + " Snap"; - } - return QString::fromLatin1(AppVersionStr); - }(); -#else // OS_MAC_STORE || OS_WIN_STORE || (defined Q_OS_UNIX && !defined Q_OS_MAC) - const auto appVersion = QString::fromLatin1(AppVersionStr); -#endif // OS_MAC_STORE || OS_WIN_STORE || (defined Q_OS_UNIX && !defined Q_OS_MAC) + const auto appVersion = ComputeAppVersion(); const auto proxyType = _options->proxy.type; const auto mtprotoProxy = (proxyType == ProxyData::Type::Mtproto); const auto clientProxyFields = mtprotoProxy