diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-03-12 13:35:30 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-03-12 13:35:30 +0000 |
commit | fb9cc5a68f4d046b88e3bc065c680b5e35202550 (patch) | |
tree | f80dde20f1791bc6af820bc70df54ec7f1d8d8aa /common | |
parent | 4022022321e7422cfb9200e44f40573a19edd206 (diff) |
Introduce dbus_message_iter_append_variant to libhelper.
Diffstat (limited to 'common')
-rw-r--r-- | common/dbus-helper.c | 28 | ||||
-rw-r--r-- | common/dbus-helper.h | 1 |
2 files changed, 18 insertions, 11 deletions
diff --git a/common/dbus-helper.c b/common/dbus-helper.c index cf68d82f..6fa90ff1 100644 --- a/common/dbus-helper.c +++ b/common/dbus-helper.c @@ -420,18 +420,12 @@ 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) +void dbus_message_iter_append_variant(DBusMessageIter *iter, int type, void *val) { - DBusMessageIter entry; DBusMessageIter value; DBusMessageIter array; char *sig; - dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); - - dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); - switch (type) { case DBUS_TYPE_STRING: sig = DBUS_TYPE_STRING_AS_STRING; @@ -452,11 +446,11 @@ void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING; break; default: - sig = DBUS_TYPE_VARIANT_AS_STRING; - break; + error("Could not append variant with type %d", type); + return; } - dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, sig, &value); + dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value); if (type == DBUS_TYPE_ARRAY) { dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, @@ -468,7 +462,19 @@ void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, } else dbus_message_iter_append_basic(&value, type, val); - dbus_message_iter_close_container(&entry, &value); + dbus_message_iter_close_container(iter, &value); +} + +void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, + const char *key, int type, void *val) +{ + DBusMessageIter entry; + + dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); + + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); + + dbus_message_iter_append_variant(&entry, type, val); dbus_message_iter_close_container(dict, &entry); } diff --git a/common/dbus-helper.h b/common/dbus-helper.h index 62810260..e5db24ba 100644 --- a/common/dbus-helper.h +++ b/common/dbus-helper.h @@ -70,6 +70,7 @@ dbus_bool_t dbus_connection_register_interface(DBusConnection *connection, dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection, const char *path, const char *name); +void dbus_message_iter_append_variant(DBusMessageIter *iter, int type, void *val); void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, const char *key, int type, void *val); |