Function: dbus-get-all-managed-objects
dbus-get-all-managed-objects is a byte-compiled function defined in
dbus.el.gz.
Signature
(dbus-get-all-managed-objects BUS SERVICE PATH)
Documentation
Return all objects at BUS, SERVICE, PATH, and the children of PATH.
The result is a list of objects. Every object is a cons of an
existing path name, and the list of available interface objects.
An interface object is another cons, whose car is the interface
name and cdr is the list of properties as returned by
dbus-get-all-properties for that path and interface. Example:
(dbus-get-all-managed-objects :session "org.gnome.SettingsDaemon" "/")
=> (("/org/gnome/SettingsDaemon/MediaKeys"
("org.gnome.SettingsDaemon.MediaKeys")
("org.freedesktop.DBus.Peer")
("org.freedesktop.DBus.Introspectable")
("org.freedesktop.DBus.Properties")
("org.freedesktop.DBus.ObjectManager"))
("/org/gnome/SettingsDaemon/Power"
("org.gnome.SettingsDaemon.Power.Keyboard")
("org.gnome.SettingsDaemon.Power.Screen")
("org.gnome.SettingsDaemon.Power"
("Icon" . ". GThemedIcon battery-full-charged-symbolic ")
("Tooltip" . "Laptop battery is charged"))
("org.freedesktop.DBus.Peer")
("org.freedesktop.DBus.Introspectable")
("org.freedesktop.DBus.Properties")
("org.freedesktop.DBus.ObjectManager"))
...)
If possible, "org.freedesktop.DBus.ObjectManager.GetManagedObjects" is used for retrieving the information. Otherwise, the information is collected via "org.freedesktop.DBus.Introspectable.Introspect" and "org.freedesktop.DBus.Properties.GetAll", which is slow.
Source Code
;; Defined in /usr/src/emacs/lisp/net/dbus.el.gz
;;; D-Bus object manager.
(defun dbus-get-all-managed-objects (bus service path)
"Return all objects at BUS, SERVICE, PATH, and the children of PATH.
The result is a list of objects. Every object is a cons of an
existing path name, and the list of available interface objects.
An interface object is another cons, whose car is the interface
name and cdr is the list of properties as returned by
`dbus-get-all-properties' for that path and interface. Example:
\(dbus-get-all-managed-objects :session \"org.gnome.SettingsDaemon\" \"/\")
=> ((\"/org/gnome/SettingsDaemon/MediaKeys\"
(\"org.gnome.SettingsDaemon.MediaKeys\")
(\"org.freedesktop.DBus.Peer\")
(\"org.freedesktop.DBus.Introspectable\")
(\"org.freedesktop.DBus.Properties\")
(\"org.freedesktop.DBus.ObjectManager\"))
(\"/org/gnome/SettingsDaemon/Power\"
(\"org.gnome.SettingsDaemon.Power.Keyboard\")
(\"org.gnome.SettingsDaemon.Power.Screen\")
(\"org.gnome.SettingsDaemon.Power\"
(\"Icon\" . \". GThemedIcon battery-full-charged-symbolic \")
(\"Tooltip\" . \"Laptop battery is charged\"))
(\"org.freedesktop.DBus.Peer\")
(\"org.freedesktop.DBus.Introspectable\")
(\"org.freedesktop.DBus.Properties\")
(\"org.freedesktop.DBus.ObjectManager\"))
...)
If possible, \"org.freedesktop.DBus.ObjectManager.GetManagedObjects\"
is used for retrieving the information. Otherwise, the information
is collected via \"org.freedesktop.DBus.Introspectable.Introspect\"
and \"org.freedesktop.DBus.Properties.GetAll\", which is slow."
(let ((result
;; Direct call. Fails, if the target does not support the
;; object manager interface.
(let (dbus-debug)
(dbus-ignore-errors
(dbus-call-method
bus service path dbus-interface-objectmanager
"GetManagedObjects" :timeout 1000)))))
(if result
;; Massage the returned structure.
(dolist (entry result result)
;; "a{oa{sa{sv}}}".
(dolist (entry1 (cdr entry))
;; "a{sa{sv}}".
(dolist (entry2 entry1)
;; "a{sv}".
(if (cadr entry2)
;; "sv".
(dolist (entry3 (cadr entry2))
(setcdr entry3 (caadr entry3)))
(setcdr entry2 nil)))))
;; Fallback: collect the information. Slooow!
(dolist (object
(dbus-introspect-get-all-nodes bus service path)
result)
(let (result1)
(dolist
(interface
(dbus-introspect-get-interface-names bus service object)
result1)
(push
(cons interface
(dbus-get-all-properties bus service object interface))
result1))
(when result1
(push (cons object result1) result)))))))