include/dbus.h include/rfkill.h include/option.h \
include/profile.h include/provider.h \
include/utsname.h include/timeserver.h include/proxy.h \
- include/location.h include/technology.h
+ include/location.h include/technology.h \
+ include/configuration.h
local_headers = $(foreach file,$(include_HEADERS) $(nodist_include_HEADERS) \
$(noinst_HEADERS), include/connman/$(notdir $(file)))
storagedir = $(localstatedir)/lib/connman
+configdir = ${sysconfdir}/connman
+
if MAINTAINER_MODE
build_plugindir = $(abs_top_srcdir)/plugins/.libs
build_scriptdir = $(abs_top_srcdir)/scripts
-DSTATEDIR=\""$(statedir)"\" \
-DPLUGINDIR=\""$(build_plugindir)"\" \
-DSCRIPTDIR=\""$(build_scriptdir)"\" \
- -DSTORAGEDIR=\""$(storagedir)\""
+ -DSTORAGEDIR=\""$(storagedir)\"" \
+ -DCONFIGDIR=\""$(configdir)\""
INCLUDES = -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus
--- /dev/null
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2011 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef __CONNMAN_CONFIGURATION_H
+#define __CONNMAN_CONFIGURATION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+connman_bool_t connman_configuration_get_bool(const char *key);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONNMAN_CONFIGURATION_H */
#include <connman/option.h>
+#include <connman/configuration.h>
+
#include <connman/plugin.h>
int __connman_plugin_init(const char *pattern, const char *exclude);
#include "connman.h"
+struct connman_conf {
+ connman_bool_t bg_scan;
+};
+
+static struct connman_conf main_conf = {
+ .bg_scan = TRUE,
+};
+
+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)) {
+ 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)
+ return;
+
+ DBG("parsing main.conf");
+
+ boolean = g_key_file_get_boolean(config, "General",
+ "BackgroundScanning", &error);
+ if (error == NULL)
+ main_conf.bg_scan = boolean;
+
+ g_clear_error(&error);
+}
+
static GMainLoop *main_loop = NULL;
static void sig_term(int sig)
return NULL;
}
+connman_bool_t connman_configuration_get_bool(const char *key)
+{
+ if (g_str_equal(key, "BackgroundScanning") == TRUE)
+ return main_conf.bg_scan;
+
+ return FALSE;
+}
+
int main(int argc, char *argv[])
{
GOptionContext *context;
DBusError err;
struct sigaction sa;
mode_t old_umask;
+ GKeyFile *config;
#ifdef HAVE_CAPNG
/* Drop capabilities */
__connman_dbus_init(conn);
+ config = load_config(CONFIGDIR "/main.conf");
+
+ parse_config(config);
+
__connman_storage_init();
__connman_element_init(option_device, option_nodevice);
g_main_loop_unref(main_loop);
+ if (config)
+ g_key_file_free(config);
+
return 0;
}