diff options
author | Simon McVittie <smcv@collabora.com> | 2017-06-09 15:57:30 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2017-11-06 14:07:21 +0000 |
commit | f58b77f968a66b5a86fcc7697bc6d46cd656fbb7 (patch) | |
tree | 77511942c568beef6677bcb87ddd2a615d3f8b14 /dbus/dbus-asv-util.c | |
parent | d5742550ca566317eaddea0ff7db04098f9f044f (diff) | |
download | dbus-f58b77f968a66b5a86fcc7697bc6d46cd656fbb7.tar.gz |
_dbus_asv_add_object_path: Add
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354
Diffstat (limited to 'dbus/dbus-asv-util.c')
-rw-r--r-- | dbus/dbus-asv-util.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/dbus/dbus-asv-util.c b/dbus/dbus-asv-util.c index fbb2e51e..09c9fb56 100644 --- a/dbus/dbus-asv-util.c +++ b/dbus/dbus-asv-util.c @@ -261,6 +261,42 @@ _dbus_asv_add_string (DBusMessageIter *arr_iter, /** * Create a new entry in an a{sv} (map from string to variant) + * with an object-path value. + * + * If this function fails, the a{sv} must be abandoned, for instance + * with _dbus_asv_abandon(). + * + * @param arr_iter the iterator which is appending to the array + * @param key a UTF-8 key for the map + * @param value the value + * @returns #TRUE on success, or #FALSE if not enough memory + */ +dbus_bool_t +_dbus_asv_add_object_path (DBusMessageIter *arr_iter, + const char *key, + const char *value) +{ + DBusMessageIter entry_iter, var_iter; + + if (!_dbus_asv_open_entry (arr_iter, &entry_iter, key, + DBUS_TYPE_OBJECT_PATH_AS_STRING, &var_iter)) + return FALSE; + + if (!dbus_message_iter_append_basic (&var_iter, DBUS_TYPE_OBJECT_PATH, + &value)) + { + _dbus_asv_abandon_entry (arr_iter, &entry_iter, &var_iter); + return FALSE; + } + + if (!_dbus_asv_close_entry (arr_iter, &entry_iter, &var_iter)) + return FALSE; + + return TRUE; +} + +/** + * Create a new entry in an a{sv} (map from string to variant) * with a byte array value. * * If this function fails, the a{sv} must be abandoned, for instance |