provider: Factor out keyfile loading
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 25 Jan 2012 11:49:41 +0000 (13:49 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 27 Jan 2012 10:21:24 +0000 (11:21 +0100)
Factor out keyfile loading from connman_provider_load() into
a fuction of its own.

src/provider.c

index a041f91..1f95282 100644 (file)
@@ -76,20 +76,14 @@ void __connman_provider_append_properties(struct connman_provider *provider,
                                                 &provider->type);
 }
 
-static int connman_provider_load(struct connman_provider *provider)
+static int provider_load_from_keyfile(struct connman_provider *provider,
+               GKeyFile *keyfile)
 {
        gsize idx = 0;
-       GKeyFile *keyfile;
        gchar **settings;
        gchar *key, *value;
        gsize length;
 
-       DBG("provider %p", provider);
-
-       keyfile = __connman_storage_load_provider(provider->identifier);
-       if (keyfile == NULL)
-               return -ENOENT;
-
        settings = g_key_file_get_keys(keyfile, provider->identifier, &length,
                                NULL);
        if (settings == NULL) {
@@ -99,7 +93,6 @@ static int connman_provider_load(struct connman_provider *provider)
 
        while (idx < length) {
                key = settings[idx];
-               DBG("found key %s", key);
                if (key != NULL) {
                        value = g_key_file_get_string(keyfile,
                                                provider->identifier,
@@ -111,6 +104,21 @@ static int connman_provider_load(struct connman_provider *provider)
        }
        g_strfreev(settings);
 
+       return 0;
+}
+
+static int connman_provider_load(struct connman_provider *provider)
+{
+       GKeyFile *keyfile;
+
+       DBG("provider %p", provider);
+
+       keyfile = __connman_storage_load_provider(provider->identifier);
+       if (keyfile == NULL)
+               return -ENOENT;
+
+       provider_load_from_keyfile(provider, keyfile);
+
        g_key_file_free(keyfile);
        return 0;
 }