send a very complex stuct by dbus with dbus-glib

ivan fernandez calvo ivan.fernandez at sacnet.es
Mon Apr 7 02:27:07 PDT 2008


this is a reduced version of the problem that i want resolved put an
array of structs into a struct.

<method name="methodExample">
  <arg type="(ua(bb))" name="stcElement" direction="in" />
</method>

GValueArray* IN_stcElement= g_value_array_new(2);

// boolean value
GValue *pbData = g_try_new0(GValue,1);
g_value_init (pbData,G_TYPE_BOOLEAN);
g_value_set_boolean (pbData,TRUE);

//array of struct
GPtrArray *pArrayValues = g_ptr_array_new();
GValueArray *pStructItem= g_value_array_new(2);
GValue *pbValue1 = g_try_new0(GValue,1);
GValue *pbValue2 = g_try_new0(GValue,1);
g_value_init (pbValue1,G_TYPE_BOOLEAN);
g_value_init (pbValue2,G_TYPE_BOOLEAN);
g_value_set_boolean (pbValue1,TRUE);
g_value_set_boolean (pbValue2,TRUE);
g_value_array_append (pStructItem,pbValue1);
g_value_array_append (pStructItem,pbValue2);
g_ptr_array_add(pArrayValues,pStructItem);

//Gvalue container for a GPtrArray
GValue *pContainer = g_try_new0(GValue,1);
//G_TYPE_POINTER or G_TYPE_VALUE or G_TYPE_VALUE_ARRAY
g_value_init (pContainer,G_TYPE_POINTER);
g_value_set_boxed (pContainer,pArrayValues);

g_value_array_append (IN_stcElement,pbData);
g_value_array_append (IN_stcElement,pArrayValues);

i think that the problem is to select the correct GValue container I do
not know how is it.


On sáb, 2008-04-05 at 11:47 -0400, Colin Walters wrote:
> On Tue, Apr 1, 2008 at 10:31 AM, ivan fernandez calvo
> <ivan.fernandez at sacnet.es> wrote:
> > I am trying to send a messge with this struct
> >                 <method name="cambioElemento">
> >                         <!--
> >                                          uint32 nData; id del data
> >                                          string sElemento; nombre del elemento
> 
> Hi, do you think you might be able to reduce this to a smaller test case?
-- 
Un Saludo
Ivan Fernandez Calvo



More information about the dbus mailing list