diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2009-12-19 12:10:17 -0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-12-19 12:10:17 -0800 |
commit | 6f3c263d0724911ca629b42becca229d49f605dc (patch) | |
tree | 7709b83f94bf257b5958915a01a2bf845e07923c /src/dbus.c | |
parent | cd9d9e6b485cf730275680d8a4260003b206a1ae (diff) | |
download | connman-6f3c263d0724911ca629b42becca229d49f605dc.tar.gz connman-6f3c263d0724911ca629b42becca229d49f605dc.tar.bz2 connman-6f3c263d0724911ca629b42becca229d49f605dc.zip |
Create another helper for fixed array properties
Diffstat (limited to 'src/dbus.c')
-rw-r--r-- | src/dbus.c | 54 |
1 files changed, 31 insertions, 23 deletions
@@ -118,6 +118,34 @@ void connman_dbus_property_append_variant(DBusMessageIter *iter, dbus_message_iter_close_container(iter, &value); } +void connman_dbus_property_append_fixed_array(DBusMessageIter *iter, + const char *key, int type, void *val, int len) +{ + DBusMessageIter value, array; + const char *variant_sig, *array_sig; + + switch (type) { + case DBUS_TYPE_BYTE: + variant_sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING; + array_sig = DBUS_TYPE_BYTE_AS_STRING; + break; + default: + return; + } + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &key); + + dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, + variant_sig, &value); + + dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, + array_sig, &array); + dbus_message_iter_append_fixed_array(&array, type, val, len); + dbus_message_iter_close_container(&value, &array); + + dbus_message_iter_close_container(iter, &value); +} + void connman_dbus_property_append_variable_array(DBusMessageIter *iter, const char *key, int type, connman_dbus_append_cb_t function) { @@ -167,32 +195,12 @@ void connman_dbus_dict_append_variant(DBusMessageIter *dict, void connman_dbus_dict_append_fixed_array(DBusMessageIter *dict, const char *key, int type, void *val, int len) { - DBusMessageIter entry, value, array; - const char *variant_sig, *array_sig; - - switch (type) { - case DBUS_TYPE_BYTE: - variant_sig = DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING; - array_sig = DBUS_TYPE_BYTE_AS_STRING; - break; - default: - return; - } + 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_open_container(&entry, DBUS_TYPE_VARIANT, - variant_sig, &value); - - dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, - array_sig, &array); - dbus_message_iter_append_fixed_array(&array, type, val, len); - dbus_message_iter_close_container(&value, &array); - - dbus_message_iter_close_container(&entry, &value); + connman_dbus_property_append_fixed_array(&entry, key, type, val, len); dbus_message_iter_close_container(dict, &entry); } @@ -207,7 +215,7 @@ void connman_dbus_dict_append_variable_array(DBusMessageIter *dict, connman_dbus_property_append_variable_array(&entry, key, type, function); - + dbus_message_iter_close_container(dict, &entry); } |