determining remote caller when using GLib bindings?

Ross Burton ross at burtonini.com
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);

Easy!

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
http://svn.o-hand.com/view/eds-dbus/trunk/addressbook/libedata-book-dbus/, specifically e-data-book.xml::getBookView() and e-data-book-c:impl_Addressbook_Book_getBookView().

Ross
-- 
Ross Burton                                 mail: ross at burtonini.com
                                          jabber: ross at burtonini.com
                                     www: http://www.burtonini.com./
 PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF





More information about the dbus mailing list