Getting method call metadata in dbus-glib servers

Matt Hoosier matt.hoosier at gmail.com
Thu May 29 08:55:44 PDT 2008


Hi,

I've a service implemented using the GLib server as supported by
dbus-binding-tool. I would like to have this service automatically
dispose of resources allocated on behalf of a client as various method
calls are serviced, when that clients disconnects.

I can manually attach to the org.freedesktop.DBus service and monitor
for NameOwnerChanged messages, and infer when a client has
disconnected from these. But I'm not clear on a technique for
discovering the client's bus name (e.g., ":1.90") or other unique
identifier at the time that the resources are initially allocated.

For example, suppose I have an interface exposing some method marked
up in the XML interface description:

  <interface name="org.foo">
    <method name="Bar"/>
  </interface>

Then in my hand-written sources the expectation is that there's an
implementation on some GObject-derived type:

  gboolean
  org_foo_Bar (ServerType *server, GError **error)
  {
    /* allocate some resource here that needs to be disposed when
client disconnects */
  }

It seems that (probably by design) the bindings here are abstracting
away all of the machinery of inspecting and processing the message
objects.

Is there some trickery available in the dbus-glib API that will allow
me to query for the bus name of the client on whose behalf the current
instance of the "Bar" method is being dispatched?

--Matt


More information about the dbus mailing list