dbusServices/notifications: Stop broadcasting signals
All fd.o Notifications signals are emitted for a particular notification, so debugging aside, only the owner of said notification has a legitimate reason to act on it. So far we (and other implementations like the old notification-daemon) have relied on the client-side to properly filter the signals (like libnotify), but at least the QT implementation is known to not do that. Enforce correct client behavior by only emitting the signal to the original sender. https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5008 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2153>
This commit is contained in:
parent
4de96ac737
commit
0cbab09044
@ -17,6 +17,8 @@ var NotificationDaemon = class extends ServiceImplementation {
|
||||
|
||||
this._autoShutdown = false;
|
||||
|
||||
this._activeNotifications = new Map();
|
||||
|
||||
this._proxy = new NotificationsProxy(Gio.DBus.session,
|
||||
'org.gnome.Shell',
|
||||
'/org/freedesktop/Notifications',
|
||||
@ -27,16 +29,43 @@ var NotificationDaemon = class extends ServiceImplementation {
|
||||
|
||||
this._proxy.connectSignal('ActionInvoked',
|
||||
(proxy, sender, params) => {
|
||||
this._dbusImpl.emit_signal('ActionInvoked',
|
||||
const [id] = params;
|
||||
this._emitSignal(
|
||||
this._activeNotifications.get(id),
|
||||
'ActionInvoked',
|
||||
new GLib.Variant('(us)', params));
|
||||
});
|
||||
this._proxy.connectSignal('NotificationClosed',
|
||||
(proxy, sender, params) => {
|
||||
this._dbusImpl.emit_signal('NotificationClosed',
|
||||
const [id] = params;
|
||||
this._emitSignal(
|
||||
this._activeNotifications.get(id),
|
||||
'NotificationClosed',
|
||||
new GLib.Variant('(uu)', params));
|
||||
this._activeNotifications.delete(id);
|
||||
});
|
||||
}
|
||||
|
||||
_emitSignal(sender, signalName, params) {
|
||||
if (!sender)
|
||||
return;
|
||||
this._dbusImpl.get_connection()?.emit_signal(
|
||||
sender,
|
||||
this._dbusImpl.get_object_path(),
|
||||
'org.freedesktop.Notifications',
|
||||
signalName,
|
||||
params);
|
||||
}
|
||||
|
||||
_untrackSender(sender) {
|
||||
super._untrackSender(sender);
|
||||
|
||||
this._activeNotifications.forEach((value, key) => {
|
||||
if (value === sender)
|
||||
this._activeNotifications.delete(key);
|
||||
});
|
||||
}
|
||||
|
||||
register() {
|
||||
Gio.DBus.session.own_name(
|
||||
'org.freedesktop.Notifications',
|
||||
@ -45,7 +74,8 @@ var NotificationDaemon = class extends ServiceImplementation {
|
||||
}
|
||||
|
||||
async NotifyAsync(params, invocation) {
|
||||
const pid = await this._getSenderPid(invocation.get_sender());
|
||||
const sender = invocation.get_sender();
|
||||
const pid = await this._getSenderPid(sender);
|
||||
const hints = params[6];
|
||||
|
||||
params[6] = {
|
||||
@ -57,6 +87,8 @@ var NotificationDaemon = class extends ServiceImplementation {
|
||||
if (this._handleError(invocation, error))
|
||||
return;
|
||||
|
||||
const [id] = res;
|
||||
this._activeNotifications.set(id, sender);
|
||||
invocation.return_value(new GLib.Variant('(u)', res));
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user