From: Sung-jae Park Date: Tue, 24 Sep 2013 12:45:43 +0000 (+0900) Subject: Add new function for setting the configuration value via argument X-Git-Tag: accepted/tizen/20131022.083701^2~5 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fframework%2Fweb%2Flivebox-viewer.git;a=commitdiff_plain;h=e1b16fd0bc3f0f31f305f5381a674bc820164054 Add new function for setting the configuration value via argument Change-Id: I4a740555a80629a84f853c8e206c508d72b7c426 --- diff --git a/include/livebox.h b/include/livebox.h index da6414d..c57f193 100644 --- a/include/livebox.h +++ b/include/livebox.h @@ -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 diff --git a/packaging/liblivebox-viewer.spec b/packaging/liblivebox-viewer.spec index f31055d..2e5f95b 100644 --- a/packaging/liblivebox-viewer.spec +++ b/packaging/liblivebox-viewer.spec @@ -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 diff --git a/src/livebox.c b/src/livebox.c index fe23d5c..a139f7a 100644 --- a/src/livebox.c +++ b/src/livebox.c @@ -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; }