Instantiate a local dbus server for webview IPC

This commit is contained in:
Ilya Fedin 2021-11-28 23:15:51 +04:00 committed by John Preston
parent bd0e4c0075
commit 2ad20d6c4a
4 changed files with 12 additions and 20 deletions

View File

@ -13,11 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtWidgets/QApplication>
#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>
#include <sys/wait.h>
@ -56,15 +51,10 @@ Launcher::Launcher(int argc, char *argv[])
}
int Launcher::exec() {
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
Glib::init();
Gio::init();
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
for (auto i = begin(_arguments), e = end(_arguments); i != e; ++i) {
if (*i == "-webviewhelper" && std::distance(i, e) > 2) {
Webview::WebKit2Gtk::SetServiceName(*(i + 2));
return Webview::WebKit2Gtk::Exec(*(i + 1));
if (*i == "-webviewhelper" && std::distance(i, e) > 1) {
Webview::WebKit2Gtk::SetSocketPath(*(i + 1));
return Webview::WebKit2Gtk::Exec();
}
}

View File

@ -709,6 +709,9 @@ void start() {
qputenv("PULSE_PROP_application.icon_name", GetIconName().toLatin1());
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
Glib::init();
Gio::init();
Glib::set_prgname(cExeName().toStdString());
Glib::set_application_name(std::string(AppName));
@ -742,8 +745,11 @@ void start() {
char h[33] = { 0 };
hashMd5Hex(d.constData(), d.size(), h);
Webview::WebKit2Gtk::SetServiceName(
kWebviewService.utf16().arg(h).arg("%1").toStdString());
Webview::WebKit2Gtk::SetSocketPath(qsl("%1/%2-%3-webview-%4").arg(
QDir::tempPath(),
h,
cGUIDStr(),
qsl("%1")).toStdString());
}
void finish() {

@ -1 +1 @@
Subproject commit f82ad9d608000171ef3822713712346f38aee50d
Subproject commit 754657aededfaa646bc6e8f48a18141982762785

View File

@ -68,10 +68,6 @@ plugs:
default-provider: gtk-common-themes
slots:
tdesktop-dbus:
interface: dbus
bus: session
name: org.telegram.desktop
tdesktop-mpris:
interface: mpris
name: tdesktop