---
src/main.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/ofono.h | 11 ++++++++++
2 files changed, 72 insertions(+), 1 deletions(-)
diff --git a/src/main.c b/src/main.c
index 3db8819..129d36c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,6 +41,7 @@
#define SHUTDOWN_GRACE_SECONDS 10
static GMainLoop *event_loop;
+struct main_opts main_opts;
void __ofono_exit(void)
{
@@ -92,6 +93,51 @@ static void system_bus_disconnected(DBusConnection *conn,
void *user_data)
g_main_loop_quit(event_loop);
}
+static GKeyFile *load_config(const char *file)
+{
+ 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)) {
+ ofono_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 *err = NULL;
+ char *str;
+
+ if (!config)
+ return;
+
+ str = g_key_file_get_string(config, "General", "DisablePlugins", &err);
+ if (err) {
+ DBG("%s", err->message);
+ g_clear_error(&err);
+ } else {
+ DBG("DisablePlugins=%s", str);
+ main_opts.noplugin = g_strdup(str);
+ main_opts.flags |= OFONO_SET_NOPLUGIN;
+ g_free(str);
+ }
+}
+
+static void init_defaults(void)
+{
+ /* Default oFono daemon settings */
+ memset(&main_opts, 0, sizeof(main_opts));
+}
+
static gchar *option_debug = NULL;
static gchar *option_plugin = NULL;
static gchar *option_noplugin = NULL;
@@ -135,6 +181,9 @@ int main(int argc, char **argv)
int signal_fd;
GIOChannel *signal_io;
int signal_source;
+ GKeyFile *config = NULL;
+
+ init_defaults();
#ifdef HAVE_CAPNG
/* Drop capabilities */
@@ -235,10 +284,18 @@ int main(int argc, char **argv)
__ofono_manager_init();
- __ofono_plugin_init(option_plugin, option_noplugin);
+ config = load_config(CONFIGDIR "/main.conf");
+
+ parse_config(config);
+
+ if (main_opts.flags & OFONO_SET_NOPLUGIN)
+ __ofono_plugin_init(option_plugin, main_opts.noplugin);
+ else
+ __ofono_plugin_init(option_plugin, option_noplugin);
g_free(option_plugin);
g_free(option_noplugin);
+ g_free(main_opts.noplugin);
g_main_loop_run(event_loop);
@@ -255,6 +312,9 @@ cleanup:
g_source_remove(signal_source);
g_main_loop_unref(event_loop);
+ if (config)
+ g_key_file_free(config);
+
__ofono_log_cleanup();
return 0;
diff --git a/src/ofono.h b/src/ofono.h
index e48dbf6..54de5a6 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -25,6 +25,17 @@
#include <ofono/types.h>
+struct main_opts {
+ char *noplugin;
+ unsigned long flags;
+};
+
+enum {
+ OFONO_SET_NOPLUGIN = 1,
+};
+
+extern struct main_opts main_opts;
+
void __ofono_exit(void);
int __ofono_manager_init(void);
--
1.7.1
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono