determining remote caller when using GLib bindings?

Ross Burton ross at
Mon Jun 12 09:56:40 PDT 2006

On Mon, 2006-06-12 at 09:38 -0700, Justin Morey wrote:
> I'm implementing a remote object using DBUS and its GLib bindings, and
> am interested in finding a way to verify the identity of the process
> which is invoking the object's methods.  I've reviewed the APIs and
> examples, but don't see any way to get the name of the caller's
> connection when running inside the method.  Am I missing something?
> If not, how would y'all feel about adding this functionality?

If you add the async annotation to the method in the XML file:

<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>

Then the prototype of the method changes to pass a
DBusGMethodInvocation* instead of a GError* (and there are no out
arguments).  You can then do:

char *sender;
sender = dbus_g_method_get_sender (context);


Just because you mark the method as async doesn't mean that you have to
return in some other context, at the end where you would normally set
the out pointers and return TRUE simply call:

dbus_g_method_return (context, out_arg1, out_arg2, ...;

For an example see, specifically e-data-book.xml::getBookView() and e-data-book-c:impl_Addressbook_Book_getBookView().

Ross Burton                                 mail: ross at
                                          jabber: ross at
 PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF

More information about the dbus mailing list