Hi Alok,
I did already a patchset for that, it was rejected so I guess this patch
is useless too.
The point of moving to storage is to use only one function for loading
the keyfile. this patch adds
anyway an "in-beetwen" function call.
At least that's my point of view, which of course can be debated ;)
(it's a subjective part, no direct way of doing it)
From: Alok Barsode<[email protected]>
Add __connman_storage_load_mainconf to load
values from main.conf.
---
src/connman.h | 1 +
src/main.c | 41 ++++++++---------------------------------
src/storage.c | 17 +++++++++++++++++
3 files changed, 26 insertions(+), 33 deletions(-)
diff --git a/src/connman.h b/src/connman.h
index a13927a..68aa26e 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -164,6 +164,7 @@ GKeyFile *__connman_storage_open_global();
GKeyFile *__connman_storage_load_global();
void __connman_storage_save_global(GKeyFile *keyfile);
void __connman_storage_delete_global();
+GKeyFile *__connman_storage_load_mainconf();
GKeyFile *__connman_storage_load_config(const char *ident);
void __connman_storage_save_config(GKeyFile *keyfile, const char *ident);
diff --git a/src/main.c b/src/main.c
index ded3bb1..6c69523 100644
--- a/src/main.c
+++ b/src/main.c
@@ -48,45 +48,26 @@ static struct {
.bg_scan = TRUE,
};
-static GKeyFile *load_config(const char *file)
+static void parse_config()
{
- GError *err = NULL;
GKeyFile *keyfile;
-
- keyfile = g_key_file_new();
-
- g_key_file_set_list_separator(keyfile, ',');
-
- if (!g_key_file_load_from_file(keyfile, file, 0,&err)) {
- if (err->code != G_FILE_ERROR_NOENT) {
- connman_error("Parsing %s failed: %s", file,
- err->message);
- }
-
- g_error_free(err);
- g_key_file_free(keyfile);
- return NULL;
- }
-
- return keyfile;
-}
-
-static void parse_config(GKeyFile *config)
-{
GError *error = NULL;
gboolean boolean;
- if (config == NULL)
+ keyfile = __connman_storage_load_mainconf();
+ if (keyfile == NULL)
return;
DBG("parsing main.conf");
- boolean = g_key_file_get_boolean(config, "General",
+ boolean = g_key_file_get_boolean(keyfile, "General",
"BackgroundScanning",&error);
if (error == NULL)
connman_settings.bg_scan = boolean;
+ else
+ g_clear_error(&error);
- g_clear_error(&error);
+ g_key_file_free(keyfile);
}
static GMainLoop *main_loop = NULL;
@@ -243,7 +224,6 @@ int main(int argc, char *argv[])
GError *error = NULL;
DBusConnection *conn;
DBusError err;
- GKeyFile *config;
guint signal;
#ifdef HAVE_CAPNG
@@ -324,9 +304,7 @@ int main(int argc, char *argv[])
__connman_dbus_init(conn);
- config = load_config(CONFIGDIR "/main.conf");
-
- parse_config(config);
+ parse_config();
__connman_storage_migrate();
__connman_technology_init();
@@ -416,9 +394,6 @@ int main(int argc, char *argv[])
g_main_loop_unref(main_loop);
- if (config)
- g_key_file_free(config);
At least that would be a quick possible fix: moving these two lines just
after parse_config(config)
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman