2.4 Detecting object paths and interfaces.

The first elements, to be introspected for a D-Bus object, are further object paths and interfaces.

Function: dbus-introspect-get-node-names bus service path

This function returns all node names of service in D-Bus bus at object path path as a list of strings. Example:

(dbus-introspect-get-node-names
 :session "org.gnome.seahorse" "/org/gnome/seahorse")

⇒ ("crypto" "keys")

The node names stand for further object paths of the D-Bus service, relative to path. In the example, ‘/org/gnome/seahorse/crypto’ and ‘/org/gnome/seahorse/keys’ are also object paths of the D-Bus service ‘org.gnome.seahorse’.

Function: dbus-introspect-get-all-nodes bus service path

This function returns all node names of service in D-Bus bus at object path path. It returns a list of strings with all object paths of service, starting at path. Example:

(dbus-introspect-get-all-nodes :session "org.gnome.seahorse" "/")

⇒ ("/" "/org" "/org/gnome" "/org/gnome/seahorse"
    "/org/gnome/seahorse/crypto"
    "/org/gnome/seahorse/keys"
    "/org/gnome/seahorse/keys/openpgp"
    "/org/gnome/seahorse/keys/openpgp/local"
    "/org/gnome/seahorse/keys/openssh"
    "/org/gnome/seahorse/keys/openssh/local")
Function: dbus-introspect-get-interface-names bus service path

This function returns a list strings of all interface names of service in D-Bus bus at object path path. This list will contain the default interface ‘org.freedesktop.DBus.Introspectable’.

Another default interface is ‘org.freedesktop.DBus.Properties’. If present, interface elements can also have property children. Example:

(dbus-introspect-get-interface-names
 :system "org.freedesktop.Hal"
 "/org/freedesktop/Hal/devices/computer")

⇒ ("org.freedesktop.DBus.Introspectable"
    "org.freedesktop.Hal.Device"
    "org.freedesktop.Hal.Device.SystemPowerManagement"
    "org.freedesktop.Hal.Device.CPUFreq")
Function: dbus-introspect-get-interface bus service path interface

This function returns interface of service in D-Bus bus at object path path. The return value is an XML element. interface must be a string and a member of the list returned by dbus-introspect-get-interface-names. Example:

(dbus-introspect-get-interface
 :session "org.freedesktop.xesam.searcher"
 "/org/freedesktop/xesam/searcher/main"
 "org.freedesktop.xesam.Search")

⇒ (interface ((name . "org.freedesktop.xesam.Search"))
     (method ((name . "GetHitData"))
       (arg ((name . "search") (type . "s") (direction . "in")))
       (arg ((name . "hit_ids") (type . "au") (direction . "in")))
       (arg ((name . "fields") (type . "as") (direction . "in")))
       (arg ((name . "hit_data") (type . "aav") (direction . "out"))))
     …
     (signal ((name . "HitsAdded"))
       (arg ((name . "search") (type . "s")))
       (arg ((name . "count") (type . "u")))))

With these functions, it is possible to retrieve all introspection data from a running system:

(progn
  (pop-to-buffer "*introspect*")
  (erase-buffer)
  (dolist (service (dbus-list-known-names :session))
    (dolist (path (dbus-introspect-get-all-nodes :session service "/"))
      ;; We want to introspect only elements, which have more than
      ;; the default interface "org.freedesktop.DBus.Introspectable".
      (when (delete
             "org.freedesktop.DBus.Introspectable"
             (dbus-introspect-get-interface-names :session service path))
        (insert (format "\nservice: \"%s\" path: \"%s\"\n" service path)
                (dbus-introspect :session service path))
        (redisplay t)))))