From: Sung-jae Park Date: Tue, 24 Sep 2013 12:18:50 +0000 (+0900) Subject: Add new API for avoid accessing env value X-Git-Tag: submit/tizen_mobile/20150527.071719~1^2~30^2~14^2~47^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=387db261bbb028b52365c6869f8e2316840cfaad;p=platform%2Fcore%2Fappfw%2Fwidget-viewer.git Add new API for avoid accessing env value Even if it trying to get some env value, it could brings crashes if the get/setenv is called from other threads. So the new API will not use the env value, instead of it, it will get some configuration data from arguments. Change-Id: I8e7ac92a51cbb3b6594e816ca74ec42cfcd4e999 --- 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 4e943fb..249221a 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; }