summaryrefslogtreecommitdiff
path: root/gsupplicant
diff options
context:
space:
mode:
authorMohamed Abbas <mohamed.abbas@intel.com>2011-09-13 06:55:15 (GMT)
committerSamuel Ortiz <sameo@linux.intel.com>2011-09-13 08:53:52 (GMT)
commitf251712760f3741a00458b652c5571c5ba39a700 (patch)
tree0956b5d9df525dbb39de9b2d42f83fc0b2f5d117 /gsupplicant
parentff76ad35726a05cd5bf66ab09c2681f3bee8912d (diff)
downloadconnman-f251712760f3741a00458b652c5571c5ba39a700.zip
connman-f251712760f3741a00458b652c5571c5ba39a700.tar.gz
connman-f251712760f3741a00458b652c5571c5ba39a700.tar.bz2
gsupplicant: Add support to append char ** entries to dbus dict
Diffstat (limited to 'gsupplicant')
-rw-r--r--gsupplicant/dbus.c34
-rw-r--r--gsupplicant/dbus.h20
2 files changed, 54 insertions, 0 deletions
diff --git a/gsupplicant/dbus.c b/gsupplicant/dbus.c
index e014265..7d427be 100644
--- a/gsupplicant/dbus.c
+++ b/gsupplicant/dbus.c
@@ -520,3 +520,37 @@ void supplicant_dbus_property_append_fixed_array(DBusMessageIter *iter,
dbus_message_iter_close_container(iter, &value);
}
+
+void supplicant_dbus_property_append_array(DBusMessageIter *iter,
+ const char *key, int type,
+ supplicant_dbus_array_function function,
+ void *user_data)
+{
+ DBusMessageIter value, array;
+ const char *variant_sig, *array_sig;
+
+ switch (type) {
+ case DBUS_TYPE_STRING:
+ variant_sig = DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_TYPE_BYTE_AS_STRING;
+ array_sig = DBUS_TYPE_ARRAY_AS_STRING 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);
+ if (function)
+ function(&array, user_data);
+
+ dbus_message_iter_close_container(&value, &array);
+
+ dbus_message_iter_close_container(iter, &value);
+}
diff --git a/gsupplicant/dbus.h b/gsupplicant/dbus.h
index 642e8b1..fbada07 100644
--- a/gsupplicant/dbus.h
+++ b/gsupplicant/dbus.h
@@ -37,6 +37,11 @@ typedef void (*supplicant_dbus_setup_function) (DBusMessageIter *iter,
typedef void (*supplicant_dbus_result_function) (const char *error,
DBusMessageIter *iter, void *user_data);
+void supplicant_dbus_property_append_array(DBusMessageIter *iter,
+ const char *key, int type,
+ supplicant_dbus_array_function function,
+ void *user_data);
+
void supplicant_dbus_setup(DBusConnection *conn);
void supplicant_dbus_array_foreach(DBusMessageIter *iter,
@@ -111,3 +116,18 @@ supplicant_dbus_dict_append_fixed_array(DBusMessageIter *dict,
supplicant_dbus_property_append_fixed_array(&entry, key, type, val, len);
dbus_message_iter_close_container(dict, &entry);
}
+
+static inline void
+supplicant_dbus_dict_append_array(DBusMessageIter *dict,
+ const char *key, int type,
+ supplicant_dbus_array_function function,
+ void *user_data)
+{
+ DBusMessageIter entry;
+
+ dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY,
+ NULL, &entry);
+ supplicant_dbus_property_append_array(&entry, key, type,
+ function, user_data);
+ dbus_message_iter_close_container(dict, &entry);
+}