[PATCH 03/15] WPS: event signal support added in gsupplicant library.

Tomasz Bursztyka tomasz.bursztyka at nokia.com
Tue Jan 11 05:53:56 PST 2011


---
 gsupplicant/gsupplicant.h |    7 ++++++
 gsupplicant/supplicant.c  |   52 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 4f507e3..05f5c35 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -97,6 +97,12 @@ typedef enum {
 	G_SUPPLICANT_STATE_COMPLETED,
 } GSupplicantState;
 
+typedef enum {
+	G_SUPPLICANT_WPS_STATE_UNKNOWN,
+	G_SUPPLICANT_WPS_STATE_SUCCESS,
+	G_SUPPLICANT_WPS_STATE_FAIL,
+} GSupplicantWpsState;
+
 struct _GSupplicantSSID {
 	const void *ssid;
 	unsigned int ssid_len;
@@ -158,6 +164,7 @@ GSupplicantState g_supplicant_interface_get_state(GSupplicantInterface *interfac
 const char *g_supplicant_interface_get_wps_key(GSupplicantInterface *interface);
 const void *g_supplicant_interface_get_wps_ssid(GSupplicantInterface *interface,
 							unsigned int *ssid_len);
+GSupplicantWpsState g_supplicant_interface_get_wps_state(GSupplicantInterface *interface);
 
 /* Network API */
 struct _GSupplicantNetwork;
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index a0d2414..653246d 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -137,6 +137,7 @@ static GHashTable *interface_table;
 static GHashTable *bss_mapping;
 
 struct _GSupplicantWpsCredentials {
+	GSupplicantWpsState state;
 	unsigned char ssid[32];
 	unsigned int ssid_len;
 	char *key;
@@ -675,6 +676,15 @@ const void *g_supplicant_interface_get_wps_ssid(GSupplicantInterface *interface,
 	return interface->wps_cred.ssid;
 }
 
+GSupplicantWpsState g_supplicant_interface_get_wps_state(
+					GSupplicantInterface *interface)
+{
+	if (interface == NULL)
+		return G_SUPPLICANT_WPS_STATE_UNKNOWN;
+
+	return interface->wps_cred.state;
+}
+
 GSupplicantInterface *g_supplicant_network_get_interface(
 					GSupplicantNetwork *network)
 {
@@ -1860,6 +1870,47 @@ static void signal_wps_credentials(const char *path, DBusMessageIter *iter)
 	supplicant_dbus_property_foreach(iter, wps_credentials, interface);
 }
 
+static void wps_event_args(const char *key, DBusMessageIter *iter,
+			void *user_data)
+{
+	GSupplicantInterface *interface = user_data;
+
+	if (key == NULL || interface == NULL)
+		return;
+
+	SUPPLICANT_DBG("Arg Key %s", key);
+}
+
+static void signal_wps_event(const char *path, DBusMessageIter *iter)
+{
+	GSupplicantInterface *interface;
+	const char *name = NULL;
+
+	SUPPLICANT_DBG("");
+
+	interface = g_hash_table_lookup(interface_table, path);
+	if (interface == NULL)
+		return;
+
+	dbus_message_iter_get_basic(iter, &name);
+
+	SUPPLICANT_DBG("Name: %s", name);
+
+	if (g_strcmp0(name, "success") == 0)
+		interface->wps_cred.state = G_SUPPLICANT_WPS_STATE_SUCCESS;
+	else if (g_strcmp0(name, "failed") == 0)
+		interface->wps_cred.state = G_SUPPLICANT_WPS_STATE_FAIL;
+	else
+		interface->wps_cred.state = G_SUPPLICANT_WPS_STATE_UNKNOWN;
+
+	if (!dbus_message_iter_has_next(iter))
+		return;
+
+	dbus_message_iter_next(iter);
+
+	supplicant_dbus_property_foreach(iter, wps_event_args, interface);
+}
+
 static struct {
 	const char *interface;
 	const char *member;
@@ -1882,6 +1933,7 @@ static struct {
 	{ SUPPLICANT_INTERFACE ".BSS", "PropertiesChanged", signal_bss_changed   },
 
 	{ SUPPLICANT_INTERFACE ".Interface.WPS", "Credentials", signal_wps_credentials },
+	{ SUPPLICANT_INTERFACE ".Interface.WPS", "Event",       signal_wps_event       },
 
 	{ }
 };
-- 
1.7.2.3




More information about the connman mailing list