Add callbacks for loading known networks
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 4 Apr 2008 07:02:30 +0000 (09:02 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 4 Apr 2008 07:02:30 +0000 (09:02 +0200)
src/connman.h
src/iface-storage.c
src/iface.c

index 4232616..c989fcb 100644 (file)
@@ -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);
index ec59490..29a1eff 100644 (file)
@@ -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;
+}
index 27bae8f..e6e88ce 100644 (file)
@@ -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);