Function: dbus-unregister-object
dbus-unregister-object is a byte-compiled function defined in
dbus.el.gz.
Signature
(dbus-unregister-object OBJECT)
Documentation
Unregister OBJECT from D-Bus.
OBJECT must be the result of a preceding dbus-register-method,
dbus-register-signal, dbus-register-property or
dbus-register-monitor call. The function returns t if OBJECT
has been unregistered, nil otherwise.
When OBJECT identifies the last method or property, which is registered for the respective service, Emacs releases its association to the service from D-Bus.
Source Code
;; Defined in /usr/src/emacs/lisp/net/dbus.el.gz
(defun dbus-unregister-object (object)
"Unregister OBJECT from D-Bus.
OBJECT must be the result of a preceding `dbus-register-method',
`dbus-register-signal', `dbus-register-property' or
`dbus-register-monitor' call. The function returns t if OBJECT
has been unregistered, nil otherwise.
When OBJECT identifies the last method or property, which is
registered for the respective service, Emacs releases its
association to the service from D-Bus."
;; Check parameter.
(unless (and (consp object) (not (null (car object))) (consp (cdr object)))
(signal 'wrong-type-argument (list 'D-Bus object)))
;; Find the corresponding entry in the hash table.
(let* ((key (car object))
(type (car key))
(bus (cadr key))
(value (cadr object))
(service (car value))
(entry (gethash key dbus-registered-objects-table))
ret)
;; key has the structure (TYPE BUS INTERFACE MEMBER).
;; value has the structure (SERVICE PATH [HANDLER]).
;; entry has the structure ((UNAME SERVICE PATH MEMBER [RULE]) ...).
;; MEMBER is either a string (the handler), or a cons cell (a
;; property value). UNAME and property values are not taken into
;; account for comparison.
;; Loop over the registered functions.
(dolist (elt entry)
(when (equal value (take (length value) (cdr elt)))
(setq ret t)
;; Compute new hash value. If it is empty, remove it from the
;; hash table.
(unless (puthash key (delete elt entry) dbus-registered-objects-table)
(remhash key dbus-registered-objects-table))
;; Remove match rule of signals.
(when (eq type :signal)
(dbus-call-method
bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus
"RemoveMatch" (nth 4 elt)))
;; Delete monitor connection by reestablishing private bus.
(when (eq type :monitor)
(dbus-init-bus bus 'private))))
;; Check, whether there is still a registered function or property
;; for the given service. If not, unregister the service from the
;; bus.
(when (and service (memq type '(:method :property))
(not (catch :found
(progn
(maphash
(lambda (k v)
(when (consp v)
(dolist (e v)
(ignore-errors
(and
;; Type.
(eq type (car k))
;; Bus.
(equal bus (cadr k))
;; Service.
(string-equal service (cadr e))
;; Non-empty object path.
(nth 2 e)
(throw :found t))))))
dbus-registered-objects-table)
nil))))
(dbus-unregister-service bus service))
;; Return.
ret))