diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-03-13 22:20:54 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2008-03-13 22:20:54 +0000 |
commit | 095a8af653e9d5f7c2cf9c82c19f1281e8ad8b92 (patch) | |
tree | a08d924e88bc2b39a32dba1254324f9383571767 | |
parent | cd78bb42ed0538e99b45bfbd2153a581595119ec (diff) |
Introduce dbus_message_iter_append_dict and dbus_message_iter_append_dict_valist.
-rw-r--r-- | common/dbus-helper.c | 35 | ||||
-rw-r--r-- | common/dbus-helper.h | 6 |
2 files changed, 40 insertions, 1 deletions
diff --git a/common/dbus-helper.c b/common/dbus-helper.c index aacae487..003d9837 100644 --- a/common/dbus-helper.c +++ b/common/dbus-helper.c @@ -479,6 +479,41 @@ void dbus_message_iter_append_dict_entry(DBusMessageIter *dict, dbus_message_iter_close_container(dict, &entry); } +void dbus_message_iter_append_dict_valist(DBusMessageIter *iter, + const char *first_key, + va_list var_args) +{ + DBusMessageIter dict; + const char *key; + int type; + void *val; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); + + key = first_key; + while (key) { + type = va_arg(var_args, int); + val = va_arg(var_args, void *); + dbus_message_iter_append_dict_entry(&dict, key, type, val); + key = va_arg(var_args, char *); + } + + dbus_message_iter_close_container(iter, &dict); +} + +void dbus_message_iter_append_dict(DBusMessageIter *iter, + const char *first_key, ...) +{ + va_list var_args; + + va_start(var_args, first_key); + dbus_message_iter_append_dict_valist(iter, first_key, var_args); + va_end(var_args); +} + dbus_bool_t dbus_connection_emit_signal_valist(DBusConnection *conn, const char *path, const char *interface, diff --git a/common/dbus-helper.h b/common/dbus-helper.h index b95d79c4..57c3d09b 100644 --- a/common/dbus-helper.h +++ b/common/dbus-helper.h @@ -73,7 +73,11 @@ dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection, 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); - +void dbus_message_iter_append_dict_valist(DBusMessageIter *iter, + const char *first_key, + va_list var_args); +void dbus_message_iter_append_dict(DBusMessageIter *iter, + const char *first_key, ...); dbus_bool_t dbus_connection_emit_signal(DBusConnection *conn, const char *path, const char *interface, const char *name, int first, ...); |