agent: Handle wpspin type as a PreviousPassphrase
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Tue, 10 Jul 2012 14:45:12 +0000 (17:45 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 13 Jul 2012 09:36:50 +0000 (06:36 -0300)
src/agent.c

index 5ce7ca9..b597a4f 100644 (file)
@@ -360,24 +360,33 @@ static void previous_passphrase_handler(DBusMessageIter *iter,
 {
        enum connman_service_security security;
        struct previous_passphrase_data data;
-
-       data.passphrase = __connman_service_get_passphrase(service);
-       if (data.passphrase == NULL)
-               return;
-
-       security = __connman_service_get_security(service);
-       switch (security) {
-       case CONNMAN_SERVICE_SECURITY_WEP:
-               data.type = "wep";
-               break;
-       case CONNMAN_SERVICE_SECURITY_PSK:
-               data.type  = "psk";
-               break;
-       /*
-        * This should never happen: no passphrase is set if security is not
-        * one of the above. */
-       default:
-               break;
+       struct connman_network *network;
+
+       network = __connman_service_get_network(service);
+       data.passphrase = connman_network_get_string(network, "WiFi.PinWPS");
+
+       if (connman_network_get_bool(network, "WiFi.UseWPS") == TRUE &&
+                                               data.passphrase != NULL) {
+               data.type = "wpspin";
+       } else {
+               data.passphrase = __connman_service_get_passphrase(service);
+               if (data.passphrase == NULL)
+                       return;
+
+               security = __connman_service_get_security(service);
+               switch (security) {
+               case CONNMAN_SERVICE_SECURITY_WEP:
+                       data.type = "wep";
+                       break;
+               case CONNMAN_SERVICE_SECURITY_PSK:
+                       data.type  = "psk";
+                       break;
+               /*
+                * This should never happen: no passphrase is set if security
+                * is not one of the above. */
+               default:
+                       break;
+               }
        }
 
        connman_dbus_dict_append_dict(iter, "PreviousPassphrase",