dbus help needed in sending an a{sv}

M_o_n_k_e_y cavaldan at tin.it
Sat Dec 19 10:10:03 CET 2009

For a nabble is hard to understand using d-bus, there is many libraries and
few documentation. I am trying to use lowlevel API (
http://dbus.freedesktop.org/doc/dbus/libdbus-tutorial.html Lowlevel API ).
I wrote the code under but don't work.
When arrive at "dbus_pending_call_block(pending)" application block to
infinity loop.
Any suggestion will be appreciated 
// connect to the bus  
dbus_bus_get(DBUS_BUS_SESSION, &err);
// request a name on the bus  
ret = dbus_bus_request_name(conn, "org.freesmartphone.opimd",
         , &err); 
char* stat; 
DBusMessage* msg;                                                               
DBusMessageIter iter,array,dict;                                             
DBusPendingCall* pending;                                                    
msg = dbus_message_new_method_call("org.freesmartphone.opimd", // target for
the method call              
"/org/freesmartphone/PIM/Contacts", // object to call on               
"org.freesmartphone.PIM.Contacts", // interface to call on             
// append arguments                                                          
dbus_message_iter_init_append(msg, &iter);                              
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &array)
dbus_message_iter_open_container(&array, DBUS_TYPE_DICT_ENTRY, 0, &dict)
dbus_message_iter_close_container(&iter, &array);                       
// send message and get a handle for a reply                                 
if (!dbus_connection_send_with_reply (conn, msg, &pending, -1)) { // -1 is
    fprintf(stderr, "Out Of Memory!\n");                                      
    // free message                                                              
    // block until we receive a reply                                            
    // get the reply message                                                     
    msg = dbus_pending_call_steal_reply(pending);                                
    if (NULL == msg) {                                                           
	fprintf(stderr, "Reply Null\n");                                          
    // free the pending message handle                                           
    // read the parameters                                                       
    if (!dbus_message_iter_init(msg, &iter))                                     
	fprintf(stderr, "Message has no arguments!\n");                           
    else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&iter))          
	fprintf(stderr, "Argument is not string\n");                              
	dbus_message_iter_get_basic(&iter, &stat);     
    printf("----->Got Reply: %s    --   \n",stat );                              
    // free reply and close connection                                           

View this message in context: http://n2.nabble.com/dbus-help-needed-in-sending-an-a-sv-tp3476909p4190808.html
Sent from the Openmoko Devel mailing list archive at Nabble.com.

More information about the devel mailing list