2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

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.
This commit is contained in:
Ilya Fedin
2023-05-06 02:34:14 +04:00
committed by John Preston
parent 37f5576c38
commit 0a011db483
11 changed files with 17 additions and 129 deletions

View File

@@ -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 <QtGui/QDesktopServices>
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
#include <glibmm.h>
#include <giomm.h>
#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));
}

View File

@@ -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 <QtGui/QWindow>
#include <QtWidgets/QMenuBar>
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
#include <glibmm.h>
#include <giomm.h>
#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() {

View File

@@ -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<void()> playSound) {
playSound();
}
void MaybeFlashBounceForCustom(Fn<void()> 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<DummyManager>(system));
} else {
system->setManager(nullptr);
}
}
} // namespace Notifications
} // namespace Platform

View File

@@ -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 <kshell.h>
#include <ksandbox.h>
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
#include <glibmm.h>
#include <giomm.h>
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
#include <sys/stat.h>
#include <sys/types.h>
@@ -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<bool> 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<bool> 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<void(bool)> done) {
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
const auto success = [&] {
const auto silent = !done;
@@ -660,7 +644,6 @@ void AutostartToggle(bool enabled, Fn<void(bool)> 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() {