From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.help Subject: Re: dbus problem: "notifications-notify :on-action" stops working Date: Thu, 01 Mar 2012 15:18:35 +0100 Message-ID: <87ty28o150.fsf@gmx.de> References: <87zkc4ehgo.fsf@micropit.couberia.bzh> <87wr78poks.fsf@gmx.de> <87ty2cee1r.fsf@micropit.couberia.bzh> <87y5rot319.fsf@gmx.de> <87ipirv0nm.fsf@micropit.couberia.bzh> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1330611560 12766 80.91.229.3 (1 Mar 2012 14:19:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 1 Mar 2012 14:19:20 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Peter =?utf-8?Q?M=C3=BCnster?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 01 15:19:17 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1S36qi-0005Ne-Vc for geh-help-gnu-emacs@m.gmane.org; Thu, 01 Mar 2012 15:19:17 +0100 Original-Received: from localhost ([::1]:60897 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S36qe-0004te-Ii for geh-help-gnu-emacs@m.gmane.org; Thu, 01 Mar 2012 09:19:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:41923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S36qR-0004ri-AY for help-gnu-emacs@gnu.org; Thu, 01 Mar 2012 09:19:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S36qK-0003v5-PC for help-gnu-emacs@gnu.org; Thu, 01 Mar 2012 09:18:58 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:37266) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1S36qK-0003ut-G1 for help-gnu-emacs@gnu.org; Thu, 01 Mar 2012 09:18:52 -0500 Original-Received: (qmail invoked by alias); 01 Mar 2012 14:18:47 -0000 Original-Received: from p57BB9B17.dip0.t-ipconnect.de (EHLO detlef.gmx.de) [87.187.155.23] by mail.gmx.net (mp017) with SMTP; 01 Mar 2012 15:18:47 +0100 X-Authenticated: #3708877 X-Provags-ID: V01U2FsdGVkX1/IUxo2EofIsytA64NbdHWucWPNZkGjeq36NAtJiP 6+swHs+UHgCBYo 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") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 213.165.64.23 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:83914 Archived-At: Peter M=C3=BCnster 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.00000= 0000 +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-m= ap'." (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-m= ap'." (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.