unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: "Peter Münster" <pmlists@free.fr>
Cc: help-gnu-emacs@gnu.org
Subject: Re: dbus problem: "notifications-notify :on-action" stops working
Date: Thu, 01 Mar 2012 15:18:35 +0100	[thread overview]
Message-ID: <87ty28o150.fsf@gmx.de> (raw)
In-Reply-To: <87ipirv0nm.fsf@micropit.couberia.bzh> ("Peter \=\?utf-8\?Q\?M\?\= \=\?utf-8\?Q\?\=C3\=BCnster\=22's\?\= message of "Tue, 28 Feb 2012 09:10:21 +0100")

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.



  reply	other threads:[~2012-03-01 14:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27  9:47 dbus problem: "notifications-notify :on-action" stops working Peter Münster
2012-02-27 10:17 ` Michael Albinus
2012-02-27 11:00   ` Peter Münster
2012-02-27 20:49     ` Michael Albinus
2012-02-28  8:10       ` Peter Münster
2012-03-01 14:18         ` Michael Albinus [this message]
2012-03-04 21:10           ` Peter Münster
2012-03-05  7:15             ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ty28o150.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=pmlists@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).