[polari] telepathyClient: Monitor gnome-shell's built-in chat client
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] telepathyClient: Monitor gnome-shell's built-in chat client
- Date: Tue, 2 Apr 2019 16:36:46 +0000 (UTC)
commit 2cd26e82a209bd45400d1c7c9ad0a99613af2ff2
Author: Florian Müllner <fmuellner gnome org>
Date: Sun Mar 10 23:25:51 2019 +0100
telepathyClient: Monitor gnome-shell's built-in chat client
We currently assume that notifications for private chats are handled
by gnome-shell's chat integration, but that
- is obviously only available on the GNOME desktop
- has been optional for some time
Before we can start handling notifications for private chats as well, we
need to know when should do that. So as a first step, monitor the session
bus for gnome-shell's built-in chat client.
https://gitlab.gnome.org/GNOME/polari/issues/18
flatpak/org.gnome.Polari.json | 1 +
src/telepathyClient.js | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
---
diff --git a/flatpak/org.gnome.Polari.json b/flatpak/org.gnome.Polari.json
index fd720f0..e588d6c 100644
--- a/flatpak/org.gnome.Polari.json
+++ b/flatpak/org.gnome.Polari.json
@@ -21,6 +21,7 @@
"--talk-name=org.freedesktop.Telepathy.AccountManager",
"--talk-name=org.freedesktop.Telepathy.ChannelDispatcher",
"--talk-name=org.freedesktop.Telepathy.Connection.idle.irc.*",
+ "--talk-name=org.freedesktop.Telepathy.Client.GnomeShell.*",
"--own-name=org.freedesktop.Telepathy.Client.TpGLibRequestAndHandle.*",
/* Telepathy names owned by bundled services */
"--own-name=org.freedesktop.Telepathy.AccountManager",
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index 35f9972..72646d3 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -6,6 +6,8 @@ const { AccountsMonitor } = imports.accountsMonitor;
const { RoomManager } = imports.roomManager;
const Utils = imports.utils;
+const SHELL_CLIENT_PREFIX = 'org.freedesktop.Telepathy.Client.GnomeShell';
+
const SASLAuthenticationIface = '<node> \
<interface name="org.freedesktop.Telepathy.Channel.Interface.SASLAuthentication"> \
<method name="StartMechanismWithData"> \
@@ -131,6 +133,47 @@ class TelepathyClient extends Tp.BaseClient {
});
this._accountsMonitor = AccountsMonitor.getDefault();
this._accountsMonitor.prepare(this._onPrepared.bind(this));
+
+ this._shellHandlesPrivateChats = false;
+
+ // Track whether gnome-shell's built-in chat client is
+ // running; unfortunately it uses :uniquify-name, so
+ // we cannot simply use Gio.watch_bus_name()
+ let conn = this._app.get_dbus_connection();
+ conn.signal_subscribe(
+ 'org.freedesktop.DBus', /* sender */
+ 'org.freedesktop.DBus', /* iface */
+ 'NameOwnerChanged', /* member */
+ '/org/freedesktop/DBus', /* path */
+ SHELL_CLIENT_PREFIX, /* arg0 */
+ Gio.DBusSignalFlags.MATCH_ARG0_NAMESPACE,
+ (_conn, _sender, _path, _iface, _signal, params) => {
+ let [name_, oldOwner_, newOwner] = params.deep_unpack();
+ this._shellHandlesPrivateChats = (newOwner != '');
+ });
+
+ conn.call(
+ 'org.freedesktop.DBus',
+ '/org/freedesktop/DBus',
+ 'org.freedesktop.DBus',
+ 'ListNames',
+ null, /* params */
+ new GLib.VariantType('(as)'),
+ Gio.DBusCallFlags.NONE,
+ -1,
+ null, /* cancellable */
+ (_o, res) => {
+ let names = [];
+
+ try {
+ [names] = conn.call_finish(res).deep_unpack();
+ } catch (e) {
+ debug(`Failed to list bus names: ${e}`);
+ }
+
+ this._shellHandlesPrivateChats =
+ names.find(n => n.startsWith(SHELL_CLIENT_PREFIX)) != null;
+ });
}
_onPrepared() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]