How do I dispatch a signal containing a variant with DBus-GLib?

David Tucker David.Tucker at hillcrestlabs.com
Mon Oct 12 12:09:47 PDT 2009


I'm really sorry!  I made a silly mistake on the client side (the client
was expecting the wrong signal prototype).  This code works fine.

 

________________________________

From: dbus-bounces at lists.freedesktop.org
[mailto:dbus-bounces at lists.freedesktop.org] On Behalf Of David Tucker
Sent: Friday, October 09, 2009 6:44 PM
To: dbus at lists.freedesktop.org
Subject: How do I dispatch a signal containing a variant with DBus-GLib?

 

Hi all,

 

I'm using the DBus-GLib bindings and would like to dispatch a signal
containing a GValue variant type.  I am not able to receive signals that
contain a variant type, but I am able to dispatch and receive signals
using non-variant types. 

I'm also able to send and receive GValue types using method calls just
fine. 

 

I'm using the following code: 

(again, this works fine when sending a char*, or other non-variant,
instead of GValue)

 

Introspection:

<signal name="VariantSignal">

<arg type="v" name="value" />

</signal>

 

C code fragments:

--to create the signal ----

signals[VARIANT_SIGNAL] =

    g_signal_new ("VariantSignal",

                  G_OBJECT_CLASS_TYPE (klass),

                  (GSignalFlags) (G_SIGNAL_RUN_LAST |
G_SIGNAL_DETAILED),

                  0,

                  NULL, NULL,

                  g_cclosure_marshal_VOID__BOXED,

                  G_TYPE_NONE, 1, G_TYPE_VALUE);

 

----- to dispatch the signal  ---

    GValue gv = {0};

    g_value_init(&gv, G_TYPE_STRING);    

    g_value_set_string(&gv, "Hello");    

    g_signal_emit (obj, signals[VARIANT_SIGNAL], 0, value);

    return TRUE;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20091012/919ffa3d/attachment.htm 


More information about the dbus mailing list