[PATCH v3 1/4] dbus: Function for adding array of object paths and dictionaries

patrik.flykt at linux.intel.com patrik.flykt at linux.intel.com
Mon Feb 20 01:43:41 PST 2012


From: Patrik Flykt <patrik.flykt at linux.intel.com>

Function for adding an array of object paths and dictionaries to
D-Bus messages.
---
v3: Patch added

 src/connman.h |    2 ++
 src/dbus.c    |   26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 916ced9..1d52b6c 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -25,6 +25,8 @@
 
 #include <connman/dbus.h>
 
+dbus_bool_t __connman_dbus_append_objpath_dict_array(DBusMessage *msg,
+		connman_dbus_append_cb_t function, void *user_data);
 int __connman_dbus_init(DBusConnection *conn);
 void __connman_dbus_cleanup(void);
 
diff --git a/src/dbus.c b/src/dbus.c
index 225eefb..e203991 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -362,6 +362,32 @@ dbus_bool_t connman_dbus_setting_changed_array(const char *owner,
 	return TRUE;
 }
 
+dbus_bool_t __connman_dbus_append_objpath_dict_array(DBusMessage *msg,
+		connman_dbus_append_cb_t function, void *user_data)
+{
+	DBusMessageIter iter, array;
+
+	if (msg == NULL || function == NULL)
+		return FALSE;
+
+	dbus_message_iter_init_append(msg, &iter);
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+			DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+			DBUS_TYPE_OBJECT_PATH_AS_STRING
+			DBUS_TYPE_ARRAY_AS_STRING
+				DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+					DBUS_TYPE_STRING_AS_STRING
+					DBUS_TYPE_VARIANT_AS_STRING
+				DBUS_DICT_ENTRY_END_CHAR_AS_STRING
+			DBUS_STRUCT_END_CHAR_AS_STRING, &array);
+
+	function(&array, user_data);
+
+	dbus_message_iter_close_container(&iter, &array);
+
+	return TRUE;
+}
+
 DBusConnection *connman_dbus_get_connection(void)
 {
 	if (connection == NULL)
-- 
1.7.9




More information about the connman mailing list