summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-02-26 08:33:18 +0100
committerMarcel Holtmann <marcel@holtmann.org>2008-02-26 08:33:18 +0100
commit0b7a3348208dfc4981a48bc22bf783c5d55e5b96 (patch)
treeefb0eaaaa24ff56694d3dd6ef5245a575c30a735 /src
parent49b002eae97659e1ffc06fd7d49a1413b6a8296c (diff)
downloadconnman-0b7a3348208dfc4981a48bc22bf783c5d55e5b96.tar.gz
connman-0b7a3348208dfc4981a48bc22bf783c5d55e5b96.tar.bz2
connman-0b7a3348208dfc4981a48bc22bf783c5d55e5b96.zip
Add support for storing last network and passphrases
Diffstat (limited to 'src')
-rw-r--r--src/iface-storage.c83
1 files changed, 15 insertions, 68 deletions
diff --git a/src/iface-storage.c b/src/iface-storage.c
index 0f14ebd0..750aa43e 100644
--- a/src/iface-storage.c
+++ b/src/iface-storage.c
@@ -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)