Improve selecting of networks
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 4 Apr 2008 06:13:06 +0000 (08:13 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 4 Apr 2008 06:13:06 +0000 (08:13 +0200)
src/iface-storage.c
src/iface.c

index d73ef6a..ec59490 100644 (file)
@@ -62,11 +62,7 @@ char *__connman_iface_find_passphrase(struct connman_iface *iface,
        list = g_key_file_get_string_list(keyfile, GROUP_CONFIG,
                                        "KnownNetworks", &list_len, NULL);
        for (i = 0; i < list_len; i++) {
-               DBG("known network %s", list[i]);
-
                if (g_str_equal(list[i], network) == TRUE) {
-                       DBG("found network %s", network);
-
                        result = g_key_file_get_string(keyfile, network,
                                                                "PSK", NULL);
                        if (result == NULL)
index a1e136d..27bae8f 100644 (file)
@@ -850,17 +850,25 @@ static DBusMessage *select_network(DBusConnection *conn,
        struct connman_iface *iface = data;
        DBusMessage *reply;
        const char *network;
+       gchar *passphrase;
 
        DBG("conn %p", conn);
 
        dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &network,
                                                        DBUS_TYPE_INVALID);
 
+       passphrase = __connman_iface_find_passphrase(iface, network);
+       if (passphrase == NULL)
+               goto done;
+
        g_free(iface->network.identifier);
        iface->network.identifier = g_strdup(network);
+       g_free(iface->network.passphrase);
+       iface->network.passphrase = passphrase;
 
        __connman_iface_connect(iface, &iface->network);
 
+done:
        reply = dbus_message_new_method_return(msg);
        if (reply == NULL)
                return NULL;