Add support for storing last network and passphrases
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 26 Feb 2008 07:33:18 +0000 (08:33 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 26 Feb 2008 07:33:18 +0000 (08:33 +0100)
src/iface-storage.c

index 0f14ebd081940dfac18c1e7d07f2bad745872c02..750aa43ef8c32d45d82eeae38157c28aa55c92eb 100644 (file)
@@ -61,44 +61,22 @@ int __connman_iface_load(struct connman_iface *iface)
                g_free(str);
        }
 
-#if 0
-       str = g_key_file_get_string(keyfile, iface->identifier,
-                                                       "Network.ESSID", NULL);
+       str = g_key_file_get_string(keyfile, GROUP_CONFIG, "Network", NULL);
        if (str != NULL) {
                g_free(iface->network.essid);
                iface->network.essid = str;
                if (iface->driver->set_network)
                        iface->driver->set_network(iface, str);
-       }
-
-       str = g_key_file_get_string(keyfile, iface->identifier,
-                                                       "IPv4.Method", NULL);
-       if (str != NULL) {
-               iface->ipv4.method = __connman_ipv4_string2method(str);
-               g_free(str);
-       }
-
-       str = g_key_file_get_string(keyfile, iface->identifier,
-                                                       "IPv4.Address", NULL);
-       if (str != NULL) {
-               iface->ipv4.address.s_addr = inet_addr(str);
-               g_free(str);
-       }
-
-       str = g_key_file_get_string(keyfile, iface->identifier,
-                                                       "IPv4.Netmask", NULL);
-       if (str != NULL) {
-               iface->ipv4.netmask.s_addr = inet_addr(str);
-               g_free(str);
-       }
 
-       str = g_key_file_get_string(keyfile, iface->identifier,
-                                                       "IPv4.Gateway", NULL);
-       if (str != NULL) {
-               iface->ipv4.gateway.s_addr = inet_addr(str);
-               g_free(str);
+               str = g_key_file_get_string(keyfile, iface->network.essid,
+                                                               "PSK", NULL);
+               if (str != NULL) {
+                       g_free(iface->network.psk);
+                       iface->network.psk = str;
+                       if (iface->driver->set_passphrase)
+                               iface->driver->set_passphrase(iface, str);
+               }
        }
-#endif
 
 done:
        g_key_file_free(keyfile);
@@ -117,46 +95,15 @@ static void do_update(GKeyFile *keyfile, struct connman_iface *iface)
        str = __connman_iface_policy2string(iface->policy);
        g_key_file_set_string(keyfile, GROUP_CONFIG, "Policy", str);
 
-#if 0
        if (iface->network.essid != NULL) {
-               g_key_file_set_string(keyfile, iface->identifier,
-                                       "Network.ESSID", iface->network.essid);
-       } else
-               g_key_file_remove_key(keyfile, iface->identifier,
-                                                       "Network.ESSID", NULL);
-
-       if (iface->ipv4.method != CONNMAN_IPV4_METHOD_UNKNOWN) {
-               str = __connman_ipv4_method2string(iface->ipv4.method);
-               g_key_file_set_string(keyfile, iface->identifier,
-                                                       "IPv4.Method", str);
+               g_key_file_set_string(keyfile, GROUP_CONFIG,
+                                       "Network", iface->network.essid);
        } else
-               g_key_file_remove_key(keyfile, iface->identifier,
-                                                       "IPv4.Method", NULL);
+               g_key_file_remove_key(keyfile, GROUP_CONFIG, "Network", NULL);
 
-       if (iface->ipv4.address.s_addr != INADDR_ANY) {
-               str = inet_ntoa(iface->ipv4.address);
-               g_key_file_set_string(keyfile, iface->identifier,
-                                                       "IPv4.Address", str);
-       } else
-               g_key_file_remove_key(keyfile, iface->identifier,
-                                                       "IPv4.Address", NULL);
-
-       if (iface->ipv4.netmask.s_addr != INADDR_ANY) {
-               str = inet_ntoa(iface->ipv4.netmask);
-               g_key_file_set_string(keyfile, iface->identifier,
-                                                       "IPv4.Netmask", str);
-       } else
-               g_key_file_remove_key(keyfile, iface->identifier,
-                                                       "IPv4.Netmask", NULL);
-
-       if (iface->ipv4.gateway.s_addr != INADDR_ANY) {
-               str = inet_ntoa(iface->ipv4.gateway);
-               g_key_file_set_string(keyfile, iface->identifier,
-                                                       "IPv4.Gateway", str);
-       } else
-               g_key_file_remove_key(keyfile, iface->identifier,
-                                                       "IPv4.Gateway", NULL);
-#endif
+       if (iface->network.essid != NULL)
+               g_key_file_set_string(keyfile, iface->network.essid,
+                                               "PSK", iface->network.psk);
 }
 
 int __connman_iface_store(struct connman_iface *iface)