summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-04-16 21:34:08 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-04-16 21:34:08 +0000
commit28a77bb7c841ce428071f6b6edd3539e1f8dc16a (patch)
tree73927203a3e2ad599246a708f6c96311cd3234b1 /common
parentef29c39ffc97adc9893841165f9e9a3f6a1e9a0a (diff)
Move append_dict_entry to utils/common and change the name to dbus_message_iter_append_dict_entry.
Diffstat (limited to 'common')
-rw-r--r--common/dbus-helper.c35
-rw-r--r--common/dbus-helper.h3
2 files changed, 38 insertions, 0 deletions
diff --git a/common/dbus-helper.c b/common/dbus-helper.c
index 7c14952b..d0082451 100644
--- a/common/dbus-helper.c
+++ b/common/dbus-helper.c
@@ -209,3 +209,38 @@ dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection,
{
return TRUE;
}
+
+void dbus_message_iter_append_dict_entry(DBusMessageIter *dict,
+ const char *key, int type, void *val)
+{
+ DBusMessageIter entry;
+ DBusMessageIter value;
+ char *sig;
+
+ dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+
+ switch (type) {
+ case DBUS_TYPE_STRING:
+ sig = DBUS_TYPE_STRING_AS_STRING;
+ break;
+ case DBUS_TYPE_UINT32:
+ sig = DBUS_TYPE_UINT32_AS_STRING;
+ break;
+ case DBUS_TYPE_BOOLEAN:
+ sig = DBUS_TYPE_BOOLEAN_AS_STRING;
+ break;
+ default:
+ sig = DBUS_TYPE_VARIANT_AS_STRING;
+ break;
+ }
+
+ dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, sig, &value);
+
+ dbus_message_iter_append_basic(&value, type, val);
+
+ dbus_message_iter_close_container(&entry, &value);
+
+ dbus_message_iter_close_container(dict, &entry);
+}
diff --git a/common/dbus-helper.h b/common/dbus-helper.h
index 0c33a04f..312ab9b5 100644
--- a/common/dbus-helper.h
+++ b/common/dbus-helper.h
@@ -55,3 +55,6 @@ dbus_bool_t dbus_connection_register_interface(DBusConnection *connection,
dbus_bool_t dbus_connection_unregister_interface(DBusConnection *connection,
const char *path, const char *interface);
+void dbus_message_iter_append_dict_entry(DBusMessageIter *dict,
+ const char *key, int type, void *val);
+