How to get the name of the caller of a method in glib-dbus

Ali Abdallah aliov at xfce.org
Fri Aug 28 01:30:48 PDT 2009


Till Wimmer wrote:
> Hello,
>
> i wrote a daemon which exposes a method ("invoke") to the bus:
>
>   dbus_g_object_type_install_info(...)
>   dbus_g_connection_register_g_object(...)
>
> This works fine.
>
> Now i'd like to find the unique connection name of the client who calls 
> the exposed method.
>   
<method name="YourMethod">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
  <arg....... >
</method>

Then the exposed method in your GObject can be like:

method_name (YourObject, args, DBusGMethodInvocation *context)

And from the context you get
dbus_g_method_get_sender (context); /* The unique name */

Don't forget to return something with dbus_g_method_return at the end.

Hope this is what you want.
Cheers,
Ali.


More information about the dbus mailing list