diff options
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/net/dbus.el | 35 |
2 files changed, 32 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 96d72aed5cc..7a3777bb6be 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2009-11-09 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/dbus.el (dbus-unregister-object): Release service, if no | ||
| 4 | other method is registered for it. | ||
| 5 | |||
| 1 | 2009-11-08 Markus Rost <rost@math.uni-bielefeld.de> | 6 | 2009-11-08 Markus Rost <rost@math.uni-bielefeld.de> |
| 2 | 7 | ||
| 3 | * bookmark.el (bookmark-completing-read): Sort bookmark names if | 8 | * bookmark.el (bookmark-completing-read): Sort bookmark names if |
diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index 6f829c6f709..306d4973f98 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el | |||
| @@ -139,23 +139,42 @@ been unregistered, `nil' otherwise." | |||
| 139 | 139 | ||
| 140 | ;; Find the corresponding entry in the hash table. | 140 | ;; Find the corresponding entry in the hash table. |
| 141 | (let* ((key (car object)) | 141 | (let* ((key (car object)) |
| 142 | (value (gethash key dbus-registered-functions-table))) | 142 | (value (gethash key dbus-registered-functions-table)) |
| 143 | (bus (car key)) | ||
| 144 | ret) | ||
| 143 | ;; Loop over the registered functions. | 145 | ;; Loop over the registered functions. |
| 144 | (while (consp value) | 146 | (dolist (val value) |
| 145 | ;; (car value) has the structure (UNAME SERVICE PATH HANDLER). | 147 | ;; val has the structure (UNAME SERVICE PATH HANDLER). |
| 146 | ;; (cdr object) has the structure ((SERVICE PATH HANDLER) ...). | 148 | ;; (cdr object) has the structure ((SERVICE PATH HANDLER) ...). |
| 147 | (if (not (equal (cdr (car value)) (car (cdr object)))) | 149 | (when (equal (cdr val) (car (cdr object))) |
| 148 | (setq value (cdr value)) | ||
| 149 | ;; Compute new hash value. If it is empty, remove it from | 150 | ;; Compute new hash value. If it is empty, remove it from |
| 150 | ;; hash table. | 151 | ;; hash table. |
| 151 | (unless | 152 | (unless |
| 152 | (puthash | 153 | (puthash |
| 153 | key | 154 | key |
| 154 | (delete (car value) (gethash key dbus-registered-functions-table)) | 155 | (delete val (gethash key dbus-registered-functions-table)) |
| 155 | dbus-registered-functions-table) | 156 | dbus-registered-functions-table) |
| 156 | (remhash key dbus-registered-functions-table)) | 157 | (remhash key dbus-registered-functions-table)) |
| 157 | (setq value t))) | 158 | (setq ret t))) |
| 158 | value)) | 159 | ;; Check, whether there is still a registered function for the |
| 160 | ;; given service. If not, unregister the service from the bus. | ||
| 161 | (dolist (val value) | ||
| 162 | (let ((service (cadr val)) | ||
| 163 | found) | ||
| 164 | (maphash | ||
| 165 | (lambda (k v) | ||
| 166 | (dolist (val v) | ||
| 167 | (ignore-errors | ||
| 168 | (when (and (equal bus (car k)) | ||
| 169 | (string-equal service (cadr val)))) | ||
| 170 | (setq found t)))) | ||
| 171 | dbus-registered-functions-table) | ||
| 172 | (unless found | ||
| 173 | (dbus-call-method | ||
| 174 | bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus | ||
| 175 | "ReleaseName" service)))) | ||
| 176 | ;; Return. | ||
| 177 | ret)) | ||
| 159 | 178 | ||
| 160 | (defun dbus-call-method-non-blocking-handler (&rest args) | 179 | (defun dbus-call-method-non-blocking-handler (&rest args) |
| 161 | "Handler for reply messages of asynchronous D-Bus message calls. | 180 | "Handler for reply messages of asynchronous D-Bus message calls. |