static DBusConnection *connection = NULL;
-static void append_variant(DBusMessageIter *iter, int type, void *val)
-{
- DBusMessageIter value;
- char sig[2] = { type, '\0' };
-
- dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value);
-
- dbus_message_iter_append_basic(&value, type, val);
-
- dbus_message_iter_close_container(iter, &value);
-}
-
-static void append_array_variant(DBusMessageIter *iter, int type, void *val,
- int n_elements)
-{
- DBusMessageIter variant, array;
- char type_sig[2] = { type, '\0' };
- char array_sig[3] = { DBUS_TYPE_ARRAY, type, '\0' };
-
- dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT,
- array_sig, &variant);
-
- dbus_message_iter_open_container(&variant, DBUS_TYPE_ARRAY,
- type_sig, &array);
-
- if (dbus_type_is_fixed(type) == TRUE) {
- dbus_message_iter_append_fixed_array(&array, type, val,
- n_elements);
- } else if (type == DBUS_TYPE_STRING || type == DBUS_TYPE_OBJECT_PATH) {
- const char ***str_array = val;
- int i;
-
- for (i = 0; i < n_elements; i++)
- dbus_message_iter_append_basic(&array, type,
- &((*str_array)[i]));
- }
-
- dbus_message_iter_close_container(&variant, &array);
-
- dbus_message_iter_close_container(iter, &variant);
-}
-
-void dict_append_basic(DBusMessageIter *dict, int key_type, const void *key,
- int type, void *val)
-{
- DBusMessageIter entry;
-
- if (type == DBUS_TYPE_STRING) {
- const char *str = *((const char **) val);
- if (str == NULL)
- return;
- }
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, key_type, key);
-
- append_variant(&entry, type, val);
-
- dbus_message_iter_close_container(dict, &entry);
-
-}
-
void dict_append_entry(DBusMessageIter *dict,
const char *key, int type, void *val)
{
- dict_append_basic(dict, DBUS_TYPE_STRING, &key, type, val);
-}
-
-void dict_append_basic_array(DBusMessageIter *dict, int key_type,
- const void *key, int type, void *val,
- int n_elements)
-{
- DBusMessageIter entry;
-
- dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
- NULL, &entry);
-
- dbus_message_iter_append_basic(&entry, key_type, key);
-
- append_array_variant(&entry, type, val, n_elements);
-
- dbus_message_iter_close_container(dict, &entry);
+ g_dbus_dict_append_entry(dict, key, type, val);
}
void dict_append_array(DBusMessageIter *dict, const char *key, int type,
void *val, int n_elements)
{
- dict_append_basic_array(dict, DBUS_TYPE_STRING, &key, type, val,
- n_elements);
+ g_dbus_dict_append_array(dict, key, type, val, n_elements);
}
void set_dbus_connection(DBusConnection *conn)