summaryrefslogtreecommitdiffstats
path: root/common/dbus-helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/dbus-helper.c')
-rw-r--r--common/dbus-helper.c19
1 files changed, 18 insertions, 1 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);