diff --git a/src/dbus-common.c b/src/dbus-common.c index 936616bdf..adb0a7a4e 100644 --- a/src/dbus-common.c +++ b/src/dbus-common.c @@ -83,8 +83,8 @@ static void append_array_variant(DBusMessageIter *iter, int type, void *val, dbus_message_iter_close_container(iter, &variant); } -void dict_append_entry(DBusMessageIter *dict, - const char *key, int type, void *val) +void dict_append_basic(DBusMessageIter *dict, int key_type, const void *key, + int type, void *val) { DBusMessageIter entry; @@ -97,26 +97,41 @@ void dict_append_entry(DBusMessageIter *dict, 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_basic(&entry, key_type, key); append_variant(&entry, type, val); + dbus_message_iter_close_container(dict, &entry); + +} + +void dict_append_entry(DBusMessageIter *dict, + const char *key, int type, void *val) +{ + dict_append_basic(dict, DBUS_TYPE_STRING, &key, type, val); +} + +void dict_append_basic_array(DBusMessageIter *dict, int key_type, + const void *key, int type, void *val, + int n_elements) +{ + DBusMessageIter entry; + + dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, + NULL, &entry); + + dbus_message_iter_append_basic(&entry, key_type, key); + + append_array_variant(&entry, type, val, n_elements); + dbus_message_iter_close_container(dict, &entry); } void dict_append_array(DBusMessageIter *dict, const char *key, int type, void *val, int n_elements) { - DBusMessageIter entry; - - dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, - NULL, &entry); - - dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); - - append_array_variant(&entry, type, val, n_elements); - - dbus_message_iter_close_container(dict, &entry); + dict_append_basic_array(dict, DBUS_TYPE_STRING, &key, type, val, + n_elements); } void set_dbus_connection(DBusConnection *conn) diff --git a/src/dbus-common.h b/src/dbus-common.h index f331b2f6d..2e7d51e84 100644 --- a/src/dbus-common.h +++ b/src/dbus-common.h @@ -21,9 +21,14 @@ * */ +void dict_append_basic(DBusMessageIter *dict, int key_type, const void *key, + int type, void *val); void dict_append_entry(DBusMessageIter *dict, const char *key, int type, void *val); +void dict_append_basic_array(DBusMessageIter *dict, int key_type, + const void *key, int type, void *val, + int n_elements); void dict_append_array(DBusMessageIter *dict, const char *key, int type, void *val, int n_elements);