Remove Profile Build Dependency (1/2): do it at runtime
[platform/upstream/connman.git] / src / main.c
index 5bd7e16..28e3edb 100755 (executable)
@@ -30,6 +30,8 @@
 #include <string.h>
 #include <signal.h>
 #include <sys/signalfd.h>
+#include <sys/types.h>
+#include <sys/resource.h>
 #include <getopt.h>
 #include <sys/stat.h>
 #include <net/if.h>
@@ -76,6 +78,7 @@ static struct {
        bool enable_6to4;
 #if defined TIZEN_EXT
        char **cellular_interfaces;
+       bool tizen_tv_extension;
 #endif
 } connman_settings  = {
        .bg_scan = true,
@@ -93,6 +96,7 @@ static struct {
        .enable_6to4 = false,
 #if defined TIZEN_EXT
        .cellular_interfaces = NULL,
+       .tizen_tv_extension = false,
 #endif
 };
 
@@ -111,6 +115,7 @@ static struct {
 #define CONF_ENABLE_6TO4                "Enable6to4"
 #if defined TIZEN_EXT
 #define CONF_CELLULAR_INTERFACE         "NetworkCellularInterfaceList"
+#define CONF_TIZEN_TV_EXT              "TizenTVExtension"
 #endif
 
 static const char *supported_options[] = {
@@ -129,6 +134,7 @@ static const char *supported_options[] = {
        CONF_ENABLE_6TO4,
 #if defined TIZEN_EXT
        CONF_CELLULAR_INTERFACE,
+       CONF_TIZEN_TV_EXT,
 #endif
        NULL
 };
@@ -249,6 +255,7 @@ static void check_Tizen_configuration(GKeyFile *config)
 {
        GError *error = NULL;
        char **cellular_interfaces;
+       bool boolean;
        gsize len;
 
        cellular_interfaces = g_key_file_get_string_list(config, "General",
@@ -258,6 +265,28 @@ static void check_Tizen_configuration(GKeyFile *config)
                connman_settings.cellular_interfaces = cellular_interfaces;
 
        g_clear_error(&error);
+
+       boolean = __connman_config_get_bool(config, "General",
+                       CONF_TIZEN_TV_EXT, &error);
+       if (!error)
+               connman_settings.tizen_tv_extension = boolean;
+
+       g_clear_error(&error);
+}
+
+static void set_nofile_inc(void)
+{
+       int err;
+       struct rlimit rlim;
+
+       rlim.rlim_cur = 8192;
+       rlim.rlim_max = 8192;
+
+       err = setrlimit(RLIMIT_NOFILE, &rlim);
+       if (err)
+               DBG("fail to increase FILENO err(%d)", err);
+
+       return;
 }
 #endif
 
@@ -404,6 +433,9 @@ static int config_init(const char *file)
 {
        GKeyFile *config;
 
+#if defined TIZEN_EXT
+       set_nofile_inc();
+#endif
        config = load_config(file);
        check_config(config);
        parse_config(config);
@@ -721,9 +753,7 @@ int main(int argc, char *argv[])
        __connman_proxy_init();
        __connman_detect_init();
        __connman_session_init();
-#if !defined TIZEN_EXT || defined TIZEN_CONNMAN_NTP
        __connman_timeserver_init();
-#endif
        __connman_connection_init();
 
        __connman_plugin_init(option_plugin, option_noplugin);
@@ -733,7 +763,9 @@ int main(int argc, char *argv[])
        __connman_dhcpv6_init();
        __connman_wpad_init();
        __connman_wispr_init();
+#if !defined TIZEN_EXT
        __connman_rfkill_init();
+#endif
        __connman_machine_init();
 
        g_free(option_config);
@@ -747,7 +779,9 @@ int main(int argc, char *argv[])
        g_source_remove(signal);
 
        __connman_machine_cleanup();
+#if !defined TIZEN_EXT
        __connman_rfkill_cleanup();
+#endif
        __connman_wispr_cleanup();
        __connman_wpad_cleanup();
        __connman_dhcpv6_cleanup();
@@ -755,9 +789,7 @@ int main(int argc, char *argv[])
        __connman_plugin_cleanup();
        __connman_provider_cleanup();
        __connman_connection_cleanup();
-#if !defined TIZEN_EXT || defined TIZEN_CONNMAN_NTP
        __connman_timeserver_cleanup();
-#endif
        __connman_detect_cleanup();
        __connman_proxy_cleanup();
        __connman_task_cleanup();