configuration-filesdbus

what is the purpose of dbus interface xml file?


I am reading D-Bus API Design Guidelines:

Interface files for public API should be installed to $(datadir)/dbus-1/interfaces so that other services can load them.

OK... in order to understand how these interface files work, I open the file /usr/share/dbus-1/interfaces/org.gnome.Shell.Screenshot.xml (I'm using Ubuntu 20.04)

<node>
  <interface name="org.gnome.Shell.Screenshot">
  ...
    <method name="PickColor">
      <arg type="a{sv}" direction="out" name="result"/>
    </method>

Well, I see the interface name, I see the method name, but that is not enough. If I want to call this method using dbus-send

$ dbus-send --print-reply --dest=<service.name> </path/to/object> org.gnome.Shell.Screenshot.PickColor

I need <service.name> and <path/to/object>, which this xml-file does not provide.

The queston is: what is the purpose of this file if it does not provide full information about the service interface? Is it used by dbus-daemon or by any other programs? Are such files really needed for something? Should I make a conclusion that an xml-file, which does not provide a path to object in , is incomplete? Should such file also mention a service known name (org.gnome.Shell.Screenshot in this case)?


Solution

  • The answer is in the name: it’s a D-Bus interface file. It defines an interface, not an instantiation of that interface. There may be zero or more instantiations of an interface in D-Bus, and they may be dynamic. So their paths can’t be specified in an XML file.

    If D-Bus was designed now, perhaps this XML file would have been structured or implemented differently. But this is what there is.