summaryrefslogtreecommitdiff
path: root/gsupplicant
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@nokia.com>2011-01-26 10:09:32 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2011-01-27 12:11:42 +0100
commitda4e20faacfb86123b53c6b723408e1141f09f8c (patch)
tree6c8a6d9d38af23031531801fc88c3b1b3b480c20 /gsupplicant
parent53887ea0c454b58f06c32876a484c1765d44ffd9 (diff)
downloadconnman-da4e20faacfb86123b53c6b723408e1141f09f8c.tar.gz
connman-da4e20faacfb86123b53c6b723408e1141f09f8c.tar.bz2
connman-da4e20faacfb86123b53c6b723408e1141f09f8c.zip
gsupplicant: WPS event signal support
Diffstat (limited to 'gsupplicant')
-rw-r--r--gsupplicant/gsupplicant.h7
-rw-r--r--gsupplicant/supplicant.c52
2 files changed, 59 insertions, 0 deletions
diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 4f507e3b..05f5c358 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 6cb691ee..a3349b35 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -162,6 +162,7 @@ struct _GSupplicantInterface {
char *driver;
char *bridge;
struct _GSupplicantWpsCredentials wps_cred;
+ GSupplicantWpsState wps_state;
GHashTable *network_table;
GHashTable *net_mapping;
GHashTable *bss_mapping;
@@ -676,6 +677,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_state;
+}
+
GSupplicantInterface *g_supplicant_network_get_interface(
GSupplicantNetwork *network)
{
@@ -1867,6 +1877,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_state = G_SUPPLICANT_WPS_STATE_SUCCESS;
+ else if (g_strcmp0(name, "failed") == 0)
+ interface->wps_state = G_SUPPLICANT_WPS_STATE_FAIL;
+ else
+ interface->wps_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;
@@ -1889,6 +1940,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 },
{ }
};