From a507edb67a0edc1ac126261f9bf02bc0d389245a Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 7 Nov 2022 12:39:07 +0400 Subject: [PATCH] Get rid of workarounds for old flatpak versions The minimal supported flatpak version since Qt 6.x is 1.14.0. Flatpak shares temp directory and runtime directory between launches since 1.11.1. FLATPAK_ID is defined since 1.1.2. --- Telegram/SourceFiles/core/utils.h | 16 ++------- .../platform/linux/specific_linux.cpp | 34 +------------------ Telegram/SourceFiles/stdafx.h | 1 - 3 files changed, 3 insertions(+), 48 deletions(-) diff --git a/Telegram/SourceFiles/core/utils.h b/Telegram/SourceFiles/core/utils.h index 0e74a5664..02ba16b1e 100644 --- a/Telegram/SourceFiles/core/utils.h +++ b/Telegram/SourceFiles/core/utils.h @@ -51,22 +51,10 @@ inline QList GetMimeUrls(const QMimeData *data) { } #endif -#if __has_include() && defined DeclareReadSetting -inline QString FlatpakID() { - static const auto Result = [] { - if (!qEnvironmentVariableIsEmpty("FLATPAK_ID")) { - return qEnvironmentVariable("FLATPAK_ID"); - } else { - return cExeName(); - } - }(); - - return Result; -} - +#if __has_include() inline QString IconName() { static const auto Result = KSandbox::isFlatpak() - ? FlatpakID() + ? qEnvironmentVariable("FLATPAK_ID") : qsl("telegram"); return Result; } diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 28e0dc5ee..6a63aff42 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -247,29 +247,6 @@ bool GenerateDesktopFile( } } -QString AppRuntimeDirectory() { - static const auto Result = [&] { - auto runtimeDir = QStandardPaths::writableLocation( - QStandardPaths::RuntimeLocation); - - if (KSandbox::isFlatpak()) { - runtimeDir += qsl("/app/") + base::FlatpakID(); - } - - if (!QFileInfo::exists(runtimeDir)) { // non-systemd distros - runtimeDir = QDir::tempPath(); - } - - if (!runtimeDir.endsWith('/')) { - runtimeDir += '/'; - } - - return runtimeDir; - }(); - - return Result; -} - } // namespace void SetApplicationIcon(const QIcon &icon) { @@ -277,16 +254,7 @@ void SetApplicationIcon(const QIcon &icon) { } QString SingleInstanceLocalServerName(const QString &hash) { - const auto idealSocketPath = AppRuntimeDirectory() - + hash - + '-' - + cGUIDStr(); - - if ((idealSocketPath.size() + 1) >= sizeof(sockaddr_un().sun_path)) { - return AppRuntimeDirectory() + hash; - } else { - return idealSocketPath; - } + return QDir::tempPath() + '/' + hash + '-' + cGUIDStr(); } std::optional IsDarkMode() { diff --git a/Telegram/SourceFiles/stdafx.h b/Telegram/SourceFiles/stdafx.h index 70a690949..3dd24bd70 100644 --- a/Telegram/SourceFiles/stdafx.h +++ b/Telegram/SourceFiles/stdafx.h @@ -119,7 +119,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/basic_types.h" #include "logs.h" -#include "settings.h" #include "core/utils.h" #include "config.h"