DBus/P2P: Rectified type of SecondaryDeviceTypes in device property Get

Sane, Jayant jayant.sane at intel.com
Fri Jul 1 16:26:52 EDT 2011


To be consistent with what it expected in corresponding Set property as byte[][]

Signed-off-by: Jayant Sane <jayant.sane at intel.com>
---
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c |   33 ++++++++++++++++++---------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index ea84163..22f9293 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -660,8 +660,8 @@ DBusMessage *wpas_dbus_getter_p2p_device_properties(DBusMessage * message,
 {
 	DBusMessage *reply = NULL;
 	DBusMessageIter iter, variant_iter, dict_iter;
+	DBusMessageIter iter_secdev_dict_entry, iter_secdev_dict_val, iter_secdev_dict_array;
 	const char *dev_name;
-	int num_sec_dev_types = 0;
 	int num_vendor_extensions = 0;
 	int i;
 	const struct wpabuf *vendor_ext[P2P_MAX_WPS_VENDOR_EXT];
@@ -694,17 +694,28 @@ DBusMessage *wpas_dbus_getter_p2p_device_properties(DBusMessage * message,
 		goto err_no_mem;
 
 	/* Secondary device types */
-	for (i = 0; i < MAX_SEC_DEVICE_TYPES; i++) {
-		if (wpa_s->conf->sec_device_type[i] == NULL)
-			break;
-		num_sec_dev_types++;
-	}
+	if (wpa_s->conf->num_sec_device_types) {
+		if (!wpa_dbus_dict_begin_array(&dict_iter, 
+						"SecondaryDeviceTypes",
+						DBUS_TYPE_ARRAY_AS_STRING
+						DBUS_TYPE_BYTE_AS_STRING,
+						&iter_secdev_dict_entry,
+						&iter_secdev_dict_val,
+						&iter_secdev_dict_array))
+			goto err_no_mem;
 
-	if (!wpa_dbus_dict_append_string_array(
-			&dict_iter, "SecondaryDeviceTypes",
-			(const char **)wpa_s->conf->sec_device_type,
-			num_sec_dev_types))
-		goto err_no_mem;
+		for (i=0; i < wpa_s->conf->num_sec_device_types; i++)
+			wpa_dbus_dict_bin_array_add_element(
+				&iter_secdev_dict_array,
+				wpa_s->conf->sec_device_type[i],
+				WPS_DEV_TYPE_LEN);
+
+		if (!wpa_dbus_dict_end_array(&dict_iter,
+						&iter_secdev_dict_entry,
+						&iter_secdev_dict_val,
+						&iter_secdev_dict_array))
+			goto err_no_mem;
+	}
 
 	/* Vendor Extensions */
 	for (i = 0; i < P2P_MAX_WPS_VENDOR_EXT; i++) {
-- 
1.7.1




More information about the HostAP mailing list