diff options
| author | Michael Albinus | 2012-03-04 14:43:13 +0100 |
|---|---|---|
| committer | Michael Albinus | 2012-03-04 14:43:13 +0100 |
| commit | a41a6cf4444fa19fecf0f8b29fcc1dcc58918e64 (patch) | |
| tree | cc6cd97e149778dc5c1c73713cf00db24e124565 | |
| parent | e627be4c9ddaec9e4037166ebbac2d09b5bce28a (diff) | |
| download | emacs-a41a6cf4444fa19fecf0f8b29fcc1dcc58918e64.tar.gz emacs-a41a6cf4444fa19fecf0f8b29fcc1dcc58918e64.zip | |
* notifications.el: Fix previous patch.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/notifications.el | 42 |
2 files changed, 22 insertions, 28 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 102ef01d772..e338a6d2ebf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -6,11 +6,11 @@ | |||
| 6 | 6 | ||
| 7 | 2012-03-04 Michael Albinus <michael.albinus@gmx.de> | 7 | 2012-03-04 Michael Albinus <michael.albinus@gmx.de> |
| 8 | 8 | ||
| 9 | * notifications.el (notifications-unique-name): New defvar. | 9 | * notifications.el (notifications-on-action-signal) |
| 10 | (notifications-on-action-signal, notifications-on-closed-signal): | 10 | (notifications-on-closed-signal): Check for unique service name of |
| 11 | Check for unique service name of incoming event. | 11 | incoming event. Fix error in removing entry. |
| 12 | (top): Register for signals with wildcard service name. | 12 | (top): Register for signals with wildcard service name. |
| 13 | (notifications-notify): Remember daemon unique service name. | 13 | (notifications-notify): Use daemon unique service name for map entries. |
| 14 | 14 | ||
| 15 | 2012-03-04 Chong Yidong <cyd@gnu.org> | 15 | 2012-03-04 Chong Yidong <cyd@gnu.org> |
| 16 | 16 | ||
diff --git a/lisp/notifications.el b/lisp/notifications.el index e0817631140..c85f8799856 100644 --- a/lisp/notifications.el +++ b/lisp/notifications.el | |||
| @@ -91,19 +91,13 @@ | |||
| 91 | (defvar notifications-on-close-map nil | 91 | (defvar notifications-on-close-map nil |
| 92 | "Mapping between notification and close callback functions.") | 92 | "Mapping between notification and close callback functions.") |
| 93 | 93 | ||
| 94 | (defvar notifications-unique-name "" | ||
| 95 | "Unique service name of notification daemon. | ||
| 96 | This must be kept, because the notification daemon could be | ||
| 97 | restarted, and the registered signals cannot be identified anymore.") | ||
| 98 | |||
| 99 | (defun notifications-on-action-signal (id action) | 94 | (defun notifications-on-action-signal (id action) |
| 100 | "Dispatch signals to callback functions from `notifications-on-action-map'." | 95 | "Dispatch signals to callback functions from `notifications-on-action-map'." |
| 101 | (let ((entry (assoc id notifications-on-action-map))) | 96 | (let* ((unique-name (dbus-event-service-name last-input-event)) |
| 102 | (when (and entry | 97 | (entry (assoc (cons unique-name id) notifications-on-action-map))) |
| 103 | (string-equal notifications-unique-name | 98 | (when entry |
| 104 | (dbus-event-service-name last-input-event))) | ||
| 105 | (funcall (cadr entry) id action) | 99 | (funcall (cadr entry) id action) |
| 106 | (remove entry 'notifications-on-action-map)))) | 100 | (remove entry notifications-on-action-map)))) |
| 107 | 101 | ||
| 108 | (when (fboundp 'dbus-register-signal) | 102 | (when (fboundp 'dbus-register-signal) |
| 109 | (dbus-register-signal | 103 | (dbus-register-signal |
| @@ -118,14 +112,13 @@ restarted, and the registered signals cannot be identified anymore.") | |||
| 118 | "Dispatch signals to callback functions from `notifications-on-closed-map'." | 112 | "Dispatch signals to callback functions from `notifications-on-closed-map'." |
| 119 | ;; notification-daemon prior 0.4.0 does not send a reason. So we | 113 | ;; notification-daemon prior 0.4.0 does not send a reason. So we |
| 120 | ;; make it optional, and assume `undefined' as default. | 114 | ;; make it optional, and assume `undefined' as default. |
| 121 | (let ((entry (assoc id notifications-on-close-map)) | 115 | (let* ((unique-name (dbus-event-service-name last-input-event)) |
| 122 | (reason (or reason 4))) | 116 | (entry (assoc (cons unique-name id) notifications-on-close-map)) |
| 123 | (when (and entry | 117 | (reason (or reason 4))) |
| 124 | (string-equal notifications-unique-name | 118 | (when entry |
| 125 | (dbus-event-service-name last-input-event))) | ||
| 126 | (funcall (cadr entry) | 119 | (funcall (cadr entry) |
| 127 | id (cadr (assoc reason notifications-closed-reason))) | 120 | id (cadr (assoc reason notifications-closed-reason))) |
| 128 | (remove entry 'notifications-on-close-map)))) | 121 | (remove entry notifications-on-close-map)))) |
| 129 | 122 | ||
| 130 | (when (fboundp 'dbus-register-signal) | 123 | (when (fboundp 'dbus-register-signal) |
| 131 | (dbus-register-signal | 124 | (dbus-register-signal |
| @@ -286,17 +279,18 @@ used to manipulate the notification item with | |||
| 286 | (or hints '(:array :signature "{sv}")) | 279 | (or hints '(:array :signature "{sv}")) |
| 287 | :int32 (or timeout -1))) | 280 | :int32 (or timeout -1))) |
| 288 | 281 | ||
| 289 | ;; Remember daemon unique service name. | 282 | ;; Register close/action callback function. We must also |
| 290 | (setq notifications-unique-name | 283 | ;; remmember the daemon's unique name, because the daemon could |
| 291 | (dbus-get-name-owner :session notifications-service)) | 284 | ;; have restarted. |
| 292 | |||
| 293 | ;; Register close/action callback function | ||
| 294 | (let ((on-action (plist-get params :on-action)) | 285 | (let ((on-action (plist-get params :on-action)) |
| 295 | (on-close (plist-get params :on-close))) | 286 | (on-close (plist-get params :on-close)) |
| 287 | (unique-name (dbus-get-name-owner :session notifications-service))) | ||
| 296 | (when on-action | 288 | (when on-action |
| 297 | (add-to-list 'notifications-on-action-map (list id on-action))) | 289 | (add-to-list 'notifications-on-action-map |
| 290 | (list (cons unique-name id) on-action))) | ||
| 298 | (when on-close | 291 | (when on-close |
| 299 | (add-to-list 'notifications-on-close-map (list id on-close)))) | 292 | (add-to-list 'notifications-on-close-map |
| 293 | (list (cons unique-name id) on-close)))) | ||
| 300 | 294 | ||
| 301 | ;; Return notification id | 295 | ;; Return notification id |
| 302 | id)) | 296 | id)) |