summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-04-04 09:02:30 +0200
committerMarcel Holtmann <marcel@holtmann.org>2008-04-04 09:02:30 +0200
commitef19693f6f7ba2bc47241204e52dbdbe54a12019 (patch)
treeed5dfcf0b447e6b51ecccfeea613d2b86b7eefc6 /src
parent52ecd928d7c84ad694f1c977c981ab01784d228e (diff)
downloadconnman-ef19693f6f7ba2bc47241204e52dbdbe54a12019.tar.gz
connman-ef19693f6f7ba2bc47241204e52dbdbe54a12019.tar.bz2
connman-ef19693f6f7ba2bc47241204e52dbdbe54a12019.zip
Add callbacks for loading known networks
Diffstat (limited to 'src')
-rw-r--r--src/connman.h1
-rw-r--r--src/iface-storage.c42
-rw-r--r--src/iface.c2
3 files changed, 45 insertions, 0 deletions
diff --git a/src/connman.h b/src/connman.h
index 4232616b..c989fcb4 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -80,6 +80,7 @@ char *__connman_iface_find_passphrase(struct connman_iface *iface,
int __connman_iface_load(struct connman_iface *iface);
int __connman_iface_store(struct connman_iface *iface);
int __connman_iface_store_current_network(struct connman_iface *iface);
+int __connman_iface_load_networks(struct connman_iface *iface);
const char *__connman_iface_type2string(enum connman_iface_type type);
const char *__connman_iface_state2string(enum connman_iface_state state);
diff --git a/src/iface-storage.c b/src/iface-storage.c
index ec59490c..29a1eff2 100644
--- a/src/iface-storage.c
+++ b/src/iface-storage.c
@@ -254,3 +254,45 @@ done:
return 0;
}
+
+int __connman_iface_load_networks(struct connman_iface *iface)
+{
+ GKeyFile *keyfile;
+ gchar *pathname;
+ gchar **list;
+ gsize list_len;
+ int i;
+
+ if (iface->identifier == NULL)
+ return -1;
+
+ pathname = g_strdup_printf("%s/%s.conf", STORAGEDIR,
+ iface->identifier);
+ if (pathname == NULL)
+ return -1;
+
+ keyfile = g_key_file_new();
+
+ g_key_file_set_list_separator(keyfile, ',');
+
+ if (g_key_file_load_from_file(keyfile, pathname, 0, NULL) == FALSE)
+ goto done;
+
+ if (g_key_file_has_group(keyfile, GROUP_CONFIG) == FALSE)
+ goto done;
+
+ 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]);
+ }
+
+ g_strfreev(list);
+
+done:
+ g_key_file_free(keyfile);
+
+ g_free(pathname);
+
+ return 0;
+}
diff --git a/src/iface.c b/src/iface.c
index 27bae8f1..e6e88ce6 100644
--- a/src/iface.c
+++ b/src/iface.c
@@ -1203,6 +1203,8 @@ static int probe_device(LibHalContext *ctx,
DBUS_TYPE_OBJECT_PATH, &iface->path,
DBUS_TYPE_INVALID);
+ __connman_iface_load_networks(iface);
+
switch_policy(iface);
state_changed(iface);