From 0a011db483eaaf4f9eec33c6af77d3bdf049c816 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 6 May 2023 02:34:14 +0400 Subject: [PATCH] Get rid of DESKTOP_APP_DISABLE_DBUS_INTEGRATION Desktop App Toolkit uses GLib as the D-Bus library for quite long time, but GLib is not only a D-Bus library, it's more a basic library providing native Linux APIs implementing various specs. The situation right now is that DESKTOP_APP_DISABLE_DBUS_INTEGRATION disables not only D-Bus code but all the native API integration such as MIME handling or .desktop file parsing. In other words, the option disables native Linux APIs on Linux what is absurd and doesn't have any sense. --- .github/workflows/linux.yml | 1 - Telegram/CMakeLists.txt | 23 ++------ .../platform/linux/file_utilities_linux.cpp | 10 ---- .../platform/linux/main_window_linux.cpp | 11 +--- .../notifications_manager_linux_dummy.cpp | 56 ------------------- .../platform/linux/specific_linux.cpp | 27 +-------- .../window/notifications_manager.cpp | 10 ++-- Telegram/lib_base | 2 +- Telegram/lib_ui | 2 +- Telegram/lib_webview | 2 +- cmake | 2 +- 11 files changed, 17 insertions(+), 129 deletions(-) delete mode 100644 Telegram/SourceFiles/platform/linux/notifications_manager_linux_dummy.cpp diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 6f2ec36ec8..162b6224df 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -57,7 +57,6 @@ jobs: matrix: defines: - "" - - "DESKTOP_APP_DISABLE_DBUS_INTEGRATION" - "DESKTOP_APP_DISABLE_X11_INTEGRATION" - "DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION" diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 008c71b159..02b9b8cdb0 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1082,7 +1082,6 @@ PRIVATE platform/linux/integration_linux.h platform/linux/main_window_linux.cpp platform/linux/main_window_linux.h - platform/linux/notifications_manager_linux_dummy.cpp platform/linux/notifications_manager_linux.cpp platform/linux/notifications_manager_linux.h platform/linux/overlay_widget_linux.h @@ -1401,18 +1400,6 @@ if (NOT build_winstore) ) endif() -if (DESKTOP_APP_DISABLE_DBUS_INTEGRATION) - remove_target_sources(Telegram ${src_loc} - platform/linux/linux_xdp_open_with_dialog.cpp - platform/linux/linux_xdp_open_with_dialog.h - platform/linux/notifications_manager_linux.cpp - ) -else() - remove_target_sources(Telegram ${src_loc} - platform/linux/notifications_manager_linux_dummy.cpp - ) -endif() - if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION) remove_target_sources(Telegram ${src_loc} platform/linux/linux_wayland_integration.cpp @@ -1522,12 +1509,10 @@ elseif (APPLE) endif() endif() else() - if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) - target_link_libraries(Telegram - PRIVATE - desktop-app::external_glibmm - ) - endif() + target_link_libraries(Telegram + PRIVATE + desktop-app::external_glibmm + ) if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) target_link_libraries(Telegram diff --git a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp index b90b70a45b..aad9fe1676 100644 --- a/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/file_utilities_linux.cpp @@ -7,23 +7,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "platform/linux/file_utilities_linux.h" -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION #include "base/platform/linux/base_linux_app_launch_context.h" #include "platform/linux/linux_xdp_open_with_dialog.h" -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION #include -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION #include #include -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION namespace Platform { namespace File { void UnsafeOpenUrl(const QString &url) { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION try { if (Gio::AppInfo::launch_default_for_uri( url.toStdString(), @@ -33,7 +28,6 @@ void UnsafeOpenUrl(const QString &url) { } catch (const std::exception &e) { LOG(("App Error: %1").arg(QString::fromStdString(e.what()))); } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION QDesktopServices::openUrl(url); } @@ -43,17 +37,14 @@ void UnsafeOpenEmailLink(const QString &email) { } bool UnsafeShowOpenWith(const QString &filepath) { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION if (internal::ShowXDPOpenWithDialog(filepath)) { return true; } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION return false; } void UnsafeLaunch(const QString &filepath) { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION try { if (Gio::AppInfo::launch_default_for_uri( Glib::filename_to_uri(filepath.toStdString()), @@ -67,7 +58,6 @@ void UnsafeLaunch(const QString &filepath) { if (UnsafeShowOpenWith(filepath)) { return; } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION QDesktopServices::openUrl(QUrl::fromLocalFile(filepath)); } diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index ada8cd6ed3..ac9b092010 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -26,15 +26,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_controller.h" #include "window/window_session_controller.h" #include "base/platform/base_platform_info.h" +#include "base/platform/linux/base_linux_glibmm_helper.h" #include "base/event_filter.h" #include "ui/widgets/popup_menu.h" #include "ui/widgets/input_fields.h" #include "ui/ui_utility.h" -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#include "base/platform/linux/base_linux_glibmm_helper.h" -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION - #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION #include "base/platform/linux/base_linux_xcb_utilities.h" #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION @@ -44,10 +41,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION #include #include -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION namespace Platform { namespace { @@ -177,7 +172,6 @@ void ForceDisabled(QAction *action, bool disabled) { } } -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION uint djbStringHash(const std::string &string) { uint hash = 5381; for (const auto &curChar : string) { @@ -185,7 +179,6 @@ uint djbStringHash(const std::string &string) { } return hash; } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION } // namespace @@ -245,7 +238,6 @@ void MainWindow::updateWindowIcon() { } void MainWindow::updateUnityCounter() { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION const auto launcherUrl = Glib::ustring( "application://" + QGuiApplication::desktopFileName().toStdString()); @@ -281,7 +273,6 @@ void MainWindow::updateUnityCounter() { })); } catch (...) { } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION } void MainWindow::createGlobalMenu() { diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux_dummy.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux_dummy.cpp deleted file mode 100644 index e5ac40868c..0000000000 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux_dummy.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "platform/linux/notifications_manager_linux.h" - -#include "base/platform/base_platform_info.h" - -namespace Platform { -namespace Notifications { - -bool SkipToastForCustom() { - return false; -} - -void MaybePlaySoundForCustom(Fn playSound) { - playSound(); -} - -void MaybeFlashBounceForCustom(Fn flashBounce) { - flashBounce(); -} - -bool WaitForInputForCustom() { - return true; -} - -bool Supported() { - return false; -} - -bool Enforced() { - // Wayland doesn't support positioning - // and custom notifications don't work here - return IsWayland(); -} - -bool ByDefault() { - return false; -} - -void Create(Window::Notifications::System *system) { - if (Enforced()) { - using DummyManager = Window::Notifications::DummyManager; - system->setManager(std::make_unique(system)); - } else { - system->setManager(nullptr); - } -} - -} // namespace Notifications -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index a8b2c6a3e1..2c29f1dd21 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -10,6 +10,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/random.h" #include "base/options.h" #include "base/platform/base_platform_info.h" +#include "base/platform/linux/base_linux_glibmm_helper.h" +#include "base/platform/linux/base_linux_dbus_utilities.h" +#include "base/platform/linux/base_linux_xdp_utilities.h" #include "platform/linux/linux_desktop_environment.h" #include "platform/linux/linux_wayland_integration.h" #include "platform/platform_launcher.h" @@ -24,12 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_controller.h" #include "webview/platform/linux/webview_linux_webkitgtk.h" -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#include "base/platform/linux/base_linux_glibmm_helper.h" -#include "base/platform/linux/base_linux_dbus_utilities.h" -#include "base/platform/linux/base_linux_xdp_utilities.h" -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION - #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION #include "base/platform/linux/base_linux_xcb_utilities.h" #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION @@ -42,10 +39,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION #include #include -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION #include #include @@ -68,7 +63,6 @@ typedef int (*XErrorHandler)(Display*, XErrorEvent*); typedef XErrorHandler (*LPXSETERRORHANDLER)(XErrorHandler); #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION typedef GApplication TDesktopApplication; typedef GApplicationClass TDesktopApplicationClass; @@ -119,14 +113,12 @@ static void t_desktop_application_class_init( static void t_desktop_application_init(TDesktopApplication *application) { } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION namespace Platform { namespace { constexpr auto kDesktopFile = ":/misc/org.telegram.desktop.desktop"_cs; -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION bool PortalAutostart(bool start, bool silent) { if (cExeName().isEmpty()) { return false; @@ -564,7 +556,6 @@ void InstallLauncher() { applicationsPath }); } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION } // namespace @@ -584,7 +575,6 @@ QString SingleInstanceLocalServerName(const QString &hash) { } std::optional IsDarkMode() { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION [[maybe_unused]] static const auto Inited = [] { using XDPSettingWatcher = base::Platform::XDP::SettingWatcher; static const XDPSettingWatcher Watcher( @@ -619,21 +609,15 @@ std::optional IsDarkMode() { } } catch (...) { } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION return std::nullopt; } bool AutostartSupported() { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION return true; -#else // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION - return false; -#endif // DESKTOP_APP_DISABLE_DBUS_INTEGRATION } void AutostartToggle(bool enabled, Fn done) { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION const auto success = [&] { const auto silent = !done; @@ -660,7 +644,6 @@ void AutostartToggle(bool enabled, Fn done) { if (done) { done(enabled && success); } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION } bool AutostartSkip() { @@ -775,7 +758,6 @@ void start() { qputenv("PULSE_PROP_application.name", AppName.utf8()); qputenv("PULSE_PROP_application.icon_name", base::IconName().toLatin1()); -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION Glib::set_prgname(cExeName().toStdString()); Glib::set_application_name(AppName.data()); @@ -793,7 +775,6 @@ void start() { "Application was built without embedded fonts, " "this may lead to font issues."); #endif // DESKTOP_APP_USE_PACKAGED_FONTS -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION Webview::WebKitGTK::SetSocketPath(u"%1/%2-%3-webview-%4"_q.arg( QDir::tempPath(), @@ -887,10 +868,8 @@ void start() { } #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION InstallLauncher(); LaunchGApplication(); -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION } void finish() { diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 1d69be114d..da8bc9a1fe 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -40,9 +40,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#if __has_include() #include -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#endif // __has_include() namespace Window { namespace Notifications { @@ -90,11 +90,11 @@ base::options::toggle OptionGNotification({ .description = "Force enable GLib's GNotification." " When disabled, autodetect is used.", .scope = [] { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#if __has_include() return bool(Gio::Application::get_default()); -#else // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#else // __has_include() return false; -#endif // DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#endif // __has_include() }, .restartRequired = true, }); diff --git a/Telegram/lib_base b/Telegram/lib_base index 02462671e5..05f50c86bc 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit 02462671e56bcf5498f1ae00806a680791be3b0a +Subproject commit 05f50c86bc721d67df2378d27d5a48c4890a8f07 diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 7c9aa94533..e8857f5792 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 7c9aa94533276d693942ed0ffb39d3d66a49e124 +Subproject commit e8857f5792c8c8bc721be0607e07ccd5616b939b diff --git a/Telegram/lib_webview b/Telegram/lib_webview index f632fc84cb..2e313690d9 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit f632fc84cbc62ae8abbbd05f81d472757a337c11 +Subproject commit 2e313690d9765f28fc98c6c79473296de3a3d85c diff --git a/cmake b/cmake index d625b4d1ba..9abd685bf4 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit d625b4d1ba9dbcbb2f7a8f6555e1658569aaa093 +Subproject commit 9abd685bf498f2410dfbc42f77c99e35ddedca94