Add new function for setting the configuration value via argument
[platform/framework/web/livebox-viewer.git] / src / livebox.c
index fe23d5c..a139f7a 100644 (file)
@@ -621,6 +621,44 @@ static int send_mouse_event(struct livebox *handler, const char *event, int x, i
        return master_rpc_request_only(handler, packet);
 }
 
+static void initialize_livebox(void *disp)
+{
+#if defined(FLOG)
+       char filename[BUFSIZ];
+       snprintf(filename, sizeof(filename), "/tmp/%d.box.log", getpid());
+       __file_log_fp = fopen(filename, "w+t");
+       if (!__file_log_fp) {
+               __file_log_fp = fdopen(1, "w+t");
+       }
+#endif
+       critical_log_init("viewer");
+       livebox_service_init();
+       fb_init(disp);
+
+       client_init();
+
+       s_info.init_count++;
+}
+
+EAPI int livebox_init_with_options(void *disp, int prevent_overwrite, double event_filter)
+{
+       if (s_info.init_count > 0) {
+               s_info.init_count++;
+               return LB_STATUS_SUCCESS;
+       }
+
+       /*!
+        * \note
+        * Some application doesn't want to use the environment value.
+        * So set them using arguments.
+        */
+       s_info.prevent_overwrite = prevent_overwrite;
+       MINIMUM_EVENT = event_filter;
+
+       initialize_livebox(disp);
+       return LB_STATUS_SUCCESS;
+}
+
 EAPI int livebox_init(void *disp)
 {
        const char *env;
@@ -629,6 +667,7 @@ EAPI int livebox_init(void *disp)
                s_info.init_count++;
                return LB_STATUS_SUCCESS;
        }
+
        env = getenv("PROVIDER_DISABLE_PREVENT_OVERWRITE");
        if (env && !strcasecmp(env, "true")) {
                s_info.prevent_overwrite = 1;
@@ -639,21 +678,7 @@ EAPI int livebox_init(void *disp)
                sscanf(env, "%lf", &MINIMUM_EVENT);
        }
 
-#if defined(FLOG)
-       char filename[BUFSIZ];
-       snprintf(filename, sizeof(filename), "/tmp/%d.box.log", getpid());
-       __file_log_fp = fopen(filename, "w+t");
-       if (!__file_log_fp) {
-               __file_log_fp = fdopen(1, "w+t");
-       }
-#endif
-       critical_log_init("viewer");
-       livebox_service_init();
-       fb_init(disp);
-
-       client_init();
-
-       s_info.init_count++;
+       initialize_livebox(disp);
        return LB_STATUS_SUCCESS;
 }