diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2008-03-11 21:49:57 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2008-03-11 21:49:57 +0000 |
commit | ba93fb91ea81a35be0834ac395650e020a6b3fd3 (patch) | |
tree | e7f3754fd3d609da301a3643c5fc4cf3143b80ad | |
parent | 272f467beabf0af74ae2beaf3529d076c36a3ee0 (diff) |
Added array support for dict
-rw-r--r-- | common/dbus-helper.c | 19 | ||||
-rw-r--r-- | hcid/device.c | 4 |
2 files changed, 21 insertions, 2 deletions
diff --git a/common/dbus-helper.c b/common/dbus-helper.c index 67dd91ed..cf68d82f 100644 --- a/common/dbus-helper.c +++ b/common/dbus-helper.c @@ -415,11 +415,17 @@ dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection, return TRUE; } +static void append_array_item_string(const char *val, DBusMessageIter *iter) +{ + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &val); +} + void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, const char *key, int type, void *val) { DBusMessageIter entry; DBusMessageIter value; + DBusMessageIter array; char *sig; dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); @@ -442,6 +448,9 @@ void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, case DBUS_TYPE_BOOLEAN: sig = DBUS_TYPE_BOOLEAN_AS_STRING; break; + case DBUS_TYPE_ARRAY: + sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING; + break; default: sig = DBUS_TYPE_VARIANT_AS_STRING; break; @@ -449,7 +458,15 @@ void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, sig, &value); - dbus_message_iter_append_basic(&value, type, val); + if (type == DBUS_TYPE_ARRAY) { + dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, + DBUS_TYPE_STRING_AS_STRING, &array); + g_slist_foreach((GSList*) val, (GFunc) append_array_item_string, + &array); + + dbus_message_iter_close_container(&value, &array); + } else + dbus_message_iter_append_basic(&value, type, val); dbus_message_iter_close_container(&entry, &value); diff --git a/hcid/device.c b/hcid/device.c index c7e8f509..a098f873 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -873,7 +873,9 @@ static DBusHandlerResult get_properties(DBusConnection *conn, dbus_message_iter_append_dict_entry(&dict, "Connected", DBUS_TYPE_BOOLEAN, &boolean); - /* TODO: UUIDs */ + /* UUIDs */ + dbus_message_iter_append_dict_entry(&dict, "UUID", + DBUS_TYPE_ARRAY, device->uuids); dbus_message_iter_close_container(&iter, &dict); |