[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dbus problem: "notifications-notify :on-action" stops working
From: |
Michael Albinus |
Subject: |
Re: dbus problem: "notifications-notify :on-action" stops working |
Date: |
Thu, 01 Mar 2012 15:18:35 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) |
Peter Münster <pmlists@free.fr> writes:
> Hi Michael,
Hi Peter,
sorry for the delay, it took some hours to walk through the dbus-monitor
traces.
> Sometimes, I've started another "emacs -Q -l /tmp/init.el" just to see,
> if it works or not. Now, the problem appears again, at timestamp
> "1330414472". Here the "*Messages*":
According to the traces, you have two Emacs sessions running, sending
notifications to the notification service. It looks, like a notification
daemon wants to be unique for a given client, sending the
notifications. As long as you send notifications from the same client
(aka Emacs session), the daemon stays alive, and does the work.
If another client sends a notification message, the running daemon is
disabled in the D-Bus name owner queue, and a new notification daemon is
started for that client. The point is, that this new daemon is still
reachable via the known name "org.freedesktop.Notifications", but is has
another unique D-Bus name (like ":1.5" or so).
notifications.el registers for signals from the D-Bus service
"org.freedesktop.Notifications". But during registration, this service
name is translated into the D-Bus unique name of the daemon, running at
*this* time. When another daemon takes over the service name
"org.freedesktop.Notifications", it has another D-Bus unique name, for
which notifications.el has not registered. That's why you don't see the
signals anymore.
I have prepared a patch, which shall handle this situation. Could you,
please, check?
--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs/lisp/notifications.el.~107473~ 2012-03-01
15:08:08.000000000 +0100
--- /home/albinus/src/emacs/lisp/notifications.el 2012-03-01
15:08:09.000000000 +0100
***************
*** 91,107 ****
(defvar notifications-on-close-map nil
"Mapping between notification and close callback functions.")
(defun notifications-on-action-signal (id action)
"Dispatch signals to callback functions from `notifications-on-action-map'."
(let ((entry (assoc id notifications-on-action-map)))
! (when entry
(funcall (cadr entry) id action)
(remove entry 'notifications-on-action-map))))
(when (fboundp 'dbus-register-signal)
(dbus-register-signal
:session
! notifications-service
notifications-path
notifications-interface
notifications-action-signal
--- 91,114 ----
(defvar notifications-on-close-map nil
"Mapping between notification and close callback functions.")
+ (defvar notifications-service-name ""
+ "Unique service name of notification daemon.
+ This must be kept, because the notification daemon could be
+ restarted, and the registered signals cannot be identified anymore.")
+
(defun notifications-on-action-signal (id action)
"Dispatch signals to callback functions from `notifications-on-action-map'."
(let ((entry (assoc id notifications-on-action-map)))
! (when (and entry
! (string-equal notifications-service-name
! (dbus-event-service-name last-input-event)))
(funcall (cadr entry) id action)
(remove entry 'notifications-on-action-map))))
(when (fboundp 'dbus-register-signal)
(dbus-register-signal
:session
! nil
notifications-path
notifications-interface
notifications-action-signal
***************
*** 113,119 ****
;; make it optional, and assume `undefined' as default.
(let ((entry (assoc id notifications-on-close-map))
(reason (or reason 4)))
! (when entry
(funcall (cadr entry)
id (cadr (assoc reason notifications-closed-reason)))
(remove entry 'notifications-on-close-map))))
--- 120,128 ----
;; make it optional, and assume `undefined' as default.
(let ((entry (assoc id notifications-on-close-map))
(reason (or reason 4)))
! (when (and entry
! (string-equal notifications-service-name
! (dbus-event-service-name last-input-event)))
(funcall (cadr entry)
id (cadr (assoc reason notifications-closed-reason)))
(remove entry 'notifications-on-close-map))))
***************
*** 121,127 ****
(when (fboundp 'dbus-register-signal)
(dbus-register-signal
:session
! notifications-service
notifications-path
notifications-interface
notifications-closed-signal
--- 130,136 ----
(when (fboundp 'dbus-register-signal)
(dbus-register-signal
:session
! nil
notifications-path
notifications-interface
notifications-closed-signal
***************
*** 277,282 ****
--- 286,295 ----
(or hints '(:array :signature "{sv}"))
:int32 (or timeout -1)))
+ ;; Remember daemon unique service name.
+ (setq notifications-service-name
+ (dbus-get-name-owner :session notifications-service))
+
;; Register close/action callback function
(let ((on-action (plist-get params :on-action))
(on-close (plist-get params :on-close)))
--8<---------------cut here---------------end--------------->8---
> Thanks for your efforts,
Best regards, Michael.
- Re: dbus problem: "notifications-notify :on-action" stops working,
Michael Albinus <=