dbus help needed in sending an a{sv}

c_c cchandel at yahoo.com
Thu Aug 20 06:45:49 CEST 2009

  I'm trying to write the c equivalent of the following python code (without
the line break)

'mdbus -s org.freesmartphone.opimd /org/freesmartphone/PIM/Messages
org.freesmartphone.PIM.Messages.Query {}'

  essentially this means sending a array -> dict -> one string(key) -> one
variant(value). In order to send a query with the key="Direction" and
value="in" I use the following code

	key = "Direction";
	value = "in";
	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_append_basic(&dict, DBUS_TYPE_STRING, &key);
	dbus_message_iter_open_container(&dict, DBUS_TYPE_VARIANT,
	dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &value);
	dbus_message_iter_close_container(&dict, &variant);
	dbus_message_iter_close_container(&array, &dict);
	dbus_message_iter_close_container(&iter, &array);
  and it works fine.
  But - how do I send a NULL key,value? I assume I'm sending a NULL - not
sure if that's the way to go about it.
  Using the code above with key and value = "" or " " causes segmentation
fault. I'm definitely doing something wrong - but I don't know what.
 Can anyone help?
View this message in context: http://n2.nabble.com/dbus-help-needed-in-sending-an-a%7Bsv%7D-tp3476909p3476909.html
Sent from the Openmoko Devel mailing list archive at Nabble.com.

More information about the devel mailing list