IS it feasible

aji.kumar at accenture.com aji.kumar at accenture.com
Mon Apr 11 06:00:01 PDT 2011


Hi Simon,

Thanks for your prompt reply.

The solution for using GDBUS may not be immediately feasible for me, but surely I will consider this for future.

Coming to implementing the signatures, although if it doesn't make sense you are saying it is still possible to implement this.

They can you check what is wrong with this piece of code and why I am getting segmentation fault trying to run it.

//outer value structure
  GValueArray *structInst2;
  structInst2 = g_value_array_new (1);

  GValue *valueArray3 = g_try_new0(GValue,1);

  //array of structure containing BD_Address
  GPtrArray* arrayOfBDAddr;
  arrayOfBDAddr = g_ptr_array_sized_new(1);

  //structure containing BD_adrress
  GValueArray *structInst3;

  structInst3 = g_value_array_new (1);

  GValue *valueArray1 = g_try_new0(GValue,1);
  g_value_init(valueArray1, DBUS_TYPE_G_UCHAR_ARRAY);
  g_value_set_boxed(valueArray1, bdaddress);
  //adding BD_address on to the struture
  g_value_array_append(structInst3, valueArray1);

 //adding the structure of ay on to the array
  g_ptr_array_add (arrayOfBDAddr, (gpointer)structInst3);

  GValue *pContainer = g_try_new0(GValue,1);

  g_value_init(pContainer,G_TYPE_POINTER);
  g_value_set_pointer(pContainer,arrayOfBDAddr);
  //adding the second element to the outermost structure
  g_value_array_append(structInst2, pContainer);

  g_value_init(valueArray3, G_TYPE_INT);
  g_value_set_int(valueArray3, valueToStore);
  /* adding integer to the outer most structure */
  g_value_array_append(structInst2, valueArray3);

Am I doing things right here???, is there any other g_value_init/g_value_set function I need to use while putting an array of structures on to the Outer structure.

Any help appreciated.
Thanks and regards
Aji.

-----Original Message-----
From: dbus-bounces+aji.kumar=accenture.com at lists.freedesktop.org [mailto:dbus-bounces+aji.kumar=accenture.com at lists.freedesktop.org] On Behalf Of Simon McVittie
Sent: Monday, April 11, 2011 3:44 PM
To: dbus at lists.freedesktop.org
Subject: Re: IS it feasible

On Mon, 11 Apr 2011 at 12:26:20 +0530, aji.kumar at accenture.com wrote:
> 1. "(a(ay)q)" -> What my understanding is this is a outer structure(GValueArray) containing an array(GPtrArray) of structures(GValueArray) containing array of Bytes and a unsigned short.

I recommend using GDBus instead of dbus-glib for any new GLib-based,
D-Bus-using code. If you really need to do dbus-glib, the
corresponding structure (in C++-like pseudocode) is indeed a

    GValueArray<GPtrArray<GValueArray<GArray<guchar>>>, guint>

But don't do that: you're adding extra layers of GValueArray that you don't
need. (aayq) would come out as a GValueArray<GPtrArray<GArray<guchar>>, guint>
which contains the same information and is easier to deal with.

dbus-glib doesn't really support 16-bit types, so the 16-bit types are
represented the same as the 32-bit types; stricter bindings like QtDBus will
tend to have trouble with this. Either use GDBus, or don't use 16-bit integers
in your API.

Also note that GArray<guchar> is not the same thing as GByteArray.

> 2. "(a((ay)s(i))q)" - this should be achievable once above is achieved.

Similarly, that's not a useful type: (a(aysi)q) contains the same information
and is much easier to construct. That'd be a

    GValueArray<GPtrArray<GValueArray<GArray<guchar>, gchar *, gint>>>, guint>

Regards,
    S
_______________________________________________
dbus mailing list
dbus at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dbus


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information.  If you have received it in error, please notify the sender immediately and delete the original.  Any other use of the email by you is prohibited.


More information about the dbus mailing list