Disabled in container environment
[platform/upstream/connman.git] / src / main.c
index 0700304..2dae72a 100755 (executable)
@@ -48,6 +48,7 @@
 
 #if defined TIZEN_EXT
 #define DEFAULT_WIFI_INTERFACE "wlan0"
+#define CONTAINER_FILE "/run/systemd/container"
 #endif
 
 #define MAINFILE "main.conf"
@@ -104,6 +105,9 @@ static struct {
        char *global_nameserver;
        bool supplicant_debug;
        char *def_wifi_ifname;
+       bool file_log;
+       bool dlog_log;
+       bool simple_log;
 #endif
 } connman_settings  = {
        .bg_scan = true,
@@ -134,6 +138,9 @@ static struct {
        .global_nameserver = NULL,
        .supplicant_debug = false,
        .def_wifi_ifname = DEFAULT_WIFI_INTERFACE,
+       .file_log = true,
+       .dlog_log = true,
+       .simple_log = true,
 #endif
 };
 
@@ -221,6 +228,9 @@ static struct {
 #define CONF_GLOBAL_NAMESERVER          "GlobalNameserver"
 #define CONF_CONNMAN_SUPPLICANT_DEBUG   "ConnmanSupplicantDebug"
 #define CONF_CONNMAN_WIFI_DEF_IFNAME    "DefaultWifiInterface"
+#define CONF_CONNMAN_FILE_LOG           "FileLogging"
+#define CONF_CONNMAN_DLOG_LOG           "DlogLogging"
+#define CONF_CONNMAN_SIMPLIFIED_LOG     "SimplifiedLog"
 #endif
 
 #if defined TIZEN_EXT
@@ -279,6 +289,9 @@ static const char *supported_options[] = {
        CONF_GLOBAL_NAMESERVER,
        CONF_CONNMAN_SUPPLICANT_DEBUG,
        CONF_CONNMAN_WIFI_DEF_IFNAME,
+       CONF_CONNMAN_FILE_LOG,
+       CONF_CONNMAN_DLOG_LOG,
+       CONF_CONNMAN_SIMPLIFIED_LOG,
 #endif
        NULL
 };
@@ -666,6 +679,27 @@ static void check_Tizen_configuration(GKeyFile *config)
 
        g_clear_error(&error);
 
+       boolean = __connman_config_get_bool(config, "General",
+                       CONF_CONNMAN_FILE_LOG, &error);
+       if (!error)
+               connman_settings.file_log = boolean;
+
+       g_clear_error(&error);
+
+       boolean = __connman_config_get_bool(config, "General",
+                       CONF_CONNMAN_DLOG_LOG, &error);
+       if (!error)
+               connman_settings.dlog_log = boolean;
+
+       g_clear_error(&error);
+
+       boolean = __connman_config_get_bool(config, "General",
+                       CONF_CONNMAN_SIMPLIFIED_LOG, &error);
+       if (!error)
+               connman_settings.simple_log = boolean;
+
+       g_clear_error(&error);
+
        check_Tizen_INS_configuration(config);
 }
 
@@ -733,6 +767,8 @@ static void parse_config(GKeyFile *config)
                connman_settings.auto_connect =
                        parse_service_types(default_auto_connect, CONF_ARRAY_SIZE(default_auto_connect));
 
+       g_strfreev(str_list);
+
        g_clear_error(&error);
 
        str_list = __connman_config_get_string_list(config, "General",
@@ -908,6 +944,11 @@ static int config_init(const char *file)
        if (config)
                g_key_file_free(config);
 
+#if defined TIZEN_EXT
+       set_simple_log_option(connman_settings.simple_log);
+       set_dlog_logging_option(connman_settings.dlog_log);
+       set_file_logging_option(connman_settings.file_log);
+#endif
        return 0;
 }
 
@@ -1134,6 +1175,15 @@ bool connman_setting_get_bool(const char *key)
 
        if (g_str_equal(key, CONF_CONNMAN_SUPPLICANT_DEBUG))
                return connman_settings.supplicant_debug;
+
+       if (g_str_equal(key, CONF_CONNMAN_FILE_LOG))
+               return connman_settings.file_log;
+
+       if (g_str_equal(key, CONF_CONNMAN_DLOG_LOG))
+               return connman_settings.dlog_log;
+
+       if (g_str_equal(key, CONF_CONNMAN_SIMPLIFIED_LOG))
+               return connman_settings.simple_log;
 #endif
 
 #if defined TIZEN_EXT
@@ -1310,6 +1360,15 @@ int main(int argc, char *argv[])
 
        signal = setup_signalfd();
 
+#if defined TIZEN_EXT
+       if (access(CONTAINER_FILE, F_OK) == 0) {
+               g_main_loop_run(main_loop);
+
+               g_source_remove(signal);
+               return 0;
+       }
+#endif
+
        dbus_error_init(&err);
 
        conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, CONNMAN_SERVICE, &err);
@@ -1360,7 +1419,11 @@ int main(int argc, char *argv[])
        __connman_clock_init();
 
        __connman_ipconfig_init();
+#if defined TIZEN_EXT
+       __connman_rtnl_init(GIO_SOCKET_RETRY_COUNT);
+#else /* TIZEN_EXT */
        __connman_rtnl_init();
+#endif /* TIZEN_EXT */
        __connman_task_init();
        __connman_proxy_init();
        __connman_detect_init();