Passing structure over DBUS API

Wilson Khoo wilson_ua at yahoo.com
Thu Apr 3 08:49:20 PDT 2008


Hi
    I am new with Dbus and I am not using any Binding tool. I am attempting to pass a structure similar to Glib GArray over DBUS. How can I do that.
Is there any example out there can 1 point me to? Can someone explain the function dbus_message_iter_open_container and dbus_message_iter_append_fixed_array. The 3rd argument used in dbus_message_iter_open_container is contained_signature, whats a contained_signature? Must the contained_signature match the arguments passed into dbus_message_iter_append_fixed_array?

I have tried the below and it kept crashing on me in the dbus_message_iter_append_fixed_array.

static void send(char *num)
{
   DBusMessage         *msg;
   DBusMessageIter     args, arrayIter;   
   char                        *num_unicode;
   int                             len = strlen(num);              

   //convert num to unicode
   num_unicode  = malloc(len *2); 
   for (int count=0; count < len; count++)
   {
        num_unicode[2*count]       = 0;
        num_unicode[(2*count) + 1] = num[count];
   }

   len = len * 2;

    dbus_message_new_method_call( ...);

   // append arguments
   dbus_message_iter_init_append(msg, &args);
 
   if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_BYTE, &len)) 
   {
       fprintf(stderr, "Out Of Memory!\n"); 
       exit(1);
   }

   if (!dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, "ay", &arrayIter))
   {
        fprintf(stderr, "Out Of Memory!\n"); 
       exit(1);
   }


   if (!dbus_message_iter_append_fixed_array (&arrayIter, DBUS_TYPE_ARRAY, &num_unicode, sizeof(num_unicode ))
   {
        fprintf (stderr, "No memory!\n");
   }
....





      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com



More information about the dbus mailing list