emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r107500: * notifications.el: Fix prev


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107500: * notifications.el: Fix previous patch.
Date: Sun, 04 Mar 2012 14:43:13 +0100
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107500
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Sun 2012-03-04 14:43:13 +0100
message:
  * notifications.el: Fix previous patch.
modified:
  lisp/ChangeLog
  lisp/notifications.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-03-04 13:34:33 +0000
+++ b/lisp/ChangeLog    2012-03-04 13:43:13 +0000
@@ -6,11 +6,11 @@
 
 2012-03-04  Michael Albinus  <address@hidden>
 
-       * notifications.el (notifications-unique-name): New defvar.
-       (notifications-on-action-signal, notifications-on-closed-signal):
-       Check for unique service name of incoming event.
+       * notifications.el (notifications-on-action-signal)
+       (notifications-on-closed-signal): Check for unique service name of
+       incoming event.  Fix error in removing entry.
        (top): Register for signals with wildcard service name.
-       (notifications-notify): Remember daemon unique service name.
+       (notifications-notify): Use daemon unique service name for map entries.
 
 2012-03-04  Chong Yidong  <address@hidden>
 

=== modified file 'lisp/notifications.el'
--- a/lisp/notifications.el     2012-03-04 11:21:31 +0000
+++ b/lisp/notifications.el     2012-03-04 13:43:13 +0000
@@ -91,19 +91,13 @@
 (defvar notifications-on-close-map nil
   "Mapping between notification and close callback functions.")
 
-(defvar notifications-unique-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-unique-name
-                            (dbus-event-service-name last-input-event)))
+  (let* ((unique-name (dbus-event-service-name last-input-event))
+        (entry (assoc (cons unique-name id) notifications-on-action-map)))
+    (when entry
       (funcall (cadr entry) id action)
-      (remove entry 'notifications-on-action-map))))
+      (remove entry notifications-on-action-map))))
 
 (when (fboundp 'dbus-register-signal)
   (dbus-register-signal
@@ -118,14 +112,13 @@
   "Dispatch signals to callback functions from `notifications-on-closed-map'."
   ;; notification-daemon prior 0.4.0 does not send a reason.  So we
   ;; 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-unique-name
-                            (dbus-event-service-name last-input-event)))
+  (let* ((unique-name (dbus-event-service-name last-input-event))
+        (entry (assoc (cons unique-name 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))))
+      (remove entry notifications-on-close-map))))
 
 (when (fboundp 'dbus-register-signal)
   (dbus-register-signal
@@ -286,17 +279,18 @@
                             (or hints '(:array :signature "{sv}"))
                             :int32 (or timeout -1)))
 
-    ;; Remember daemon unique service name.
-    (setq notifications-unique-name
-         (dbus-get-name-owner :session notifications-service))
-
-    ;; Register close/action callback function
+    ;; Register close/action callback function.  We must also
+    ;; remmember the daemon's unique name, because the daemon could
+    ;; have restarted.
     (let ((on-action (plist-get params :on-action))
-          (on-close (plist-get params :on-close)))
+          (on-close (plist-get params :on-close))
+         (unique-name (dbus-get-name-owner :session notifications-service)))
       (when on-action
-        (add-to-list 'notifications-on-action-map (list id on-action)))
+        (add-to-list 'notifications-on-action-map
+                    (list (cons unique-name id) on-action)))
       (when on-close
-        (add-to-list 'notifications-on-close-map (list id on-close))))
+        (add-to-list 'notifications-on-close-map
+                    (list (cons unique-name id) on-close))))
 
     ;; Return notification id
     id))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]