Mercurial > emacs
comparison lisp/net/dbus.el @ 105926:2b4cc3e45a7b
* net/dbus.el (dbus-unregister-object): Release service, if no
other method is registered for it.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Mon, 09 Nov 2009 22:04:57 +0000 |
parents | d74b934b16e5 |
children | d91d3722b71f |
comparison
equal
deleted
inserted
replaced
105925:51ba0ef7cf24 | 105926:2b4cc3e45a7b |
---|---|
137 (unless (and (consp object) (not (null (car object))) (consp (cdr object))) | 137 (unless (and (consp object) (not (null (car object))) (consp (cdr object))) |
138 (signal 'wrong-type-argument (list 'D-Bus object))) | 138 (signal 'wrong-type-argument (list 'D-Bus object))) |
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. |
162 It calls the function stored in `dbus-registered-functions-table'. | 181 It calls the function stored in `dbus-registered-functions-table'. |
163 The result will be made available in `dbus-return-values-table'." | 182 The result will be made available in `dbus-return-values-table'." |