Function: dbus-register-service
dbus-register-service is a byte-compiled function defined in
dbus.el.gz.
Signature
(dbus-register-service BUS SERVICE &rest FLAGS)
Documentation
Register known name SERVICE on the D-Bus BUS.
BUS is either a Lisp keyword, :system or :session, or a string denoting the bus address.
SERVICE is the D-Bus service name that should be registered. It must be a known name.
FLAGS are keywords, which control how the service name is registered. The following keywords are recognized:
:allow-replacement: Allow another service to become the primary
owner if requested.
:replace-existing: Request to replace the current primary owner.
:do-not-queue: If we can not become the primary owner do not place
us in the queue.
The function returns a keyword, indicating the result of the operation. One of the following keywords is returned:
:primary-owner: Service has become the primary owner of the
requested name.
:in-queue: Service could not become the primary owner and has been
placed in the queue.
:exists: Service is already in the queue.
:already-owner: Service is already the primary owner.
Probably introduced at or before Emacs version 24.1.
Source Code
;; Defined in /usr/src/emacs/lisp/net/dbus.el.gz
(defun dbus-register-service (bus service &rest flags)
"Register known name SERVICE on the D-Bus BUS.
BUS is either a Lisp keyword, `:system' or `:session', or a
string denoting the bus address.
SERVICE is the D-Bus service name that should be registered. It must
be a known name.
FLAGS are keywords, which control how the service name is registered.
The following keywords are recognized:
`:allow-replacement': Allow another service to become the primary
owner if requested.
`:replace-existing': Request to replace the current primary owner.
`:do-not-queue': If we can not become the primary owner do not place
us in the queue.
The function returns a keyword, indicating the result of the
operation. One of the following keywords is returned:
`:primary-owner': Service has become the primary owner of the
requested name.
`:in-queue': Service could not become the primary owner and has been
placed in the queue.
`:exists': Service is already in the queue.
`:already-owner': Service is already the primary owner."
;; Add Peer handler.
(dbus-register-method
bus service nil dbus-interface-peer "Ping"
#'dbus-peer-handler 'dont-register)
;; Add ObjectManager handler.
(dbus-register-method
bus service nil dbus-interface-objectmanager "GetManagedObjects"
#'dbus-managed-objects-handler 'dont-register)
(let ((arg 0)
reply)
(dolist (flag flags)
(setq arg
(+ arg
(pcase flag
(:allow-replacement 1)
(:replace-existing 2)
(:do-not-queue 4)
(_ (signal 'wrong-type-argument (list flag)))))))
(setq reply (dbus-call-method
bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus
"RequestName" service arg))
(pcase reply
(1 :primary-owner)
(2 :in-queue)
(3 :exists)
(4 :already-owner)
(_ (signal 'dbus-error (list "Could not register service" service))))))