Add new function for setting the configuration value via argument
authorSung-jae Park <nicesj.park@samsung.com>
Tue, 24 Sep 2013 12:45:43 +0000 (21:45 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 24 Sep 2013 12:45:43 +0000 (21:45 +0900)
Change-Id: I4a740555a80629a84f853c8e206c508d72b7c426

include/livebox.h
packaging/liblivebox-viewer.spec
src/livebox.c

index da6414d..c57f193 100644 (file)
@@ -272,6 +272,24 @@ typedef void (*ret_cb_t)(struct livebox *handle, int ret, void *data);
 extern int livebox_init(void *disp);
 
 /*!
+ * \brief Initialize the livebox system with some options
+ * \details livebox_init function uses environment value to initiate some configurable values
+ *          But some application doesn't want to use the env value.
+ *          For them, this API will give a chance to set default options using given arguments
+ * \remarks N/A
+ * \param[in] disp
+ * \param[in] prevent_overwrite
+ * \param[in] event_filter
+ * \return int
+ * \retval LB_STATUS_SUCCESS if success
+ * \pre N/A
+ * \post N/A
+ * \see livebox_init
+ * \see livebox_fini
+ */
+extern int livebox_init_with_options(void *disp, int prevent_overwrite, double event_filter);
+
+/*!
  * \brief Finalize the livebox system
  * \details N/A
  * \remarks N/A
index f31055d..2e5f95b 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox-viewer
 Summary: Library for developing the application.
-Version: 0.14.2
+Version: 0.14.3
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
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;
 }