From: Gwanglim Lee Date: Wed, 11 Feb 2015 06:49:44 +0000 (+0900) Subject: Fix coding conventions and style. X-Git-Tag: submit/tizen/20150612.014854~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e61a8c43f5d5639f9a5b6ab6125231ec1b056a2c;p=platform%2Fcore%2Fapi%2Fefl-util.git Fix coding conventions and style. Change-Id: I20768c9261e3d0773dc75adbc2f04d8c20199e29 --- diff --git a/include/efl_util.h b/include/efl_util.h index 31c5e1d..1d4e244 100644 --- a/include/efl_util.h +++ b/include/efl_util.h @@ -14,7 +14,6 @@ * limitations under the License. */ - #ifndef __TIZEN_UI_EFL_UTIL_H__ #define __TIZEN_UI_EFL_UTIL_H__ @@ -40,11 +39,11 @@ extern "C" { */ typedef enum { - EFL_UTIL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - EFL_UTIL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - EFL_UTIL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - EFL_UTIL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permisson denied */ - EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE = TIZEN_ERROR_EFL_UTIL | 0x01 /**< Window type not supported */ + EFL_UTIL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + EFL_UTIL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + EFL_UTIL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + EFL_UTIL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permisson denied */ + EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE = TIZEN_ERROR_EFL_UTIL | 0x01 /**< Window type not supported */ } efl_util_error_e; /** @@ -53,12 +52,11 @@ typedef enum */ typedef enum { - EFL_UTIL_NOTIFICATION_LEVEL_1, /**< Default notification level */ - EFL_UTIL_NOTIFICATION_LEVEL_2, /**< Higher notification level than default */ - EFL_UTIL_NOTIFICATION_LEVEL_3, /**< The highest notification level */ + EFL_UTIL_NOTIFICATION_LEVEL_1, /**< Default notification level */ + EFL_UTIL_NOTIFICATION_LEVEL_2, /**< Higher notification level than default */ + EFL_UTIL_NOTIFICATION_LEVEL_3, /**< The highest notification level */ } efl_util_notification_level_e; - /** * @brief Sets the priority level for the specified notification window, asynchronously. * @since_tizen 2.3 @@ -67,13 +65,12 @@ typedef enum * @remarks This API can be used for a notification type window only. * @param[in] window The EFL window * @param[in] level The notification window level - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #EFL_UTIL_ERROR_NONE Successful * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter * @retval #EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE Window type not supported */ -int efl_util_set_notification_window_level (Evas_Object *window, efl_util_notification_level_e level); +int efl_util_set_notification_window_level(Evas_Object *window, efl_util_notification_level_e level); /** @@ -83,58 +80,51 @@ int efl_util_set_notification_window_level (Evas_Object *window, efl_util_notifi * @remarks This API can be used for a notification type window only. * @param[in] window The EFL window * @param[out] level The notification window level - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #EFL_UTIL_ERROR_NONE Successful * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter * @retval #EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE Window type not supported */ -int efl_util_get_notification_window_level (Evas_Object *window, efl_util_notification_level_e* level); - +int efl_util_get_notification_window_level(Evas_Object *window, efl_util_notification_level_e *level); /** * @brief Called when an error occurs for setting notification window level * @since_tizen 2.3 - * @param[in] window The EFL window - * @param[in] error_code The error code (#EFL_UTIL_ERROR_PERMISSION_DENIED) - * @param[in] user_data The user data passed from the callback registration function + * @param[in] window The EFL window + * @param[in] error_code The error code (#EFL_UTIL_ERROR_PERMISSION_DENIED) + * @param[in] user_data The user data passed from the callback registration function * @see efl_util_set_notification_window_level_error_cb() * @see efl_util_unset_notification_window_level_error_cb() */ typedef void (*efl_util_notification_window_level_error_cb)(Evas_Object *window, int error_code, void *user_data); - /** * @brief Registers a callback function to be invoked when an error which set the notification level occurs. * @since_tizen 2.3 - * @param[in] window The EFL window - * @param[in] callback The callback function to register + * @param[in] window The EFL window + * @param[in] callback The callback function to register * @param[in] user_data The user data to be passed to the callback function - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #EFL_UTIL_ERROR_NONE Successful * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter * @retval #EFL_UTIL_ERROR_OUT_OF_MEMORY Out of memory - * @post efl_util_notification_window_level_error_cb() will be invoked. + * @post efl_util_notification_window_level_error_cb() will be invoked. * @see efl_util_unset_notification_window_level_error_cb() * @see efl_util_notification_window_level_error_cb() */ int efl_util_set_notification_window_level_error_cb(Evas_Object *window, efl_util_notification_window_level_error_cb callback, void *user_data); - /** * @brief Unregisters the callback function. * @since_tizen 2.3 * @param[in] window The EFL window - * @return @c 0 on success, - * otherwise a negative error value + * @return @c 0 on success, otherwise a negative error value * @retval #EFL_UTIL_ERROR_NONE Successful * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter * @see efl_util_set_notification_window_level_error_cb() */ int efl_util_unset_notification_window_level_error_cb(Evas_Object *window); - /** * @} */ @@ -142,4 +132,4 @@ int efl_util_unset_notification_window_level_error_cb(Evas_Object *window); #ifdef __cplusplus } #endif -#endif /* __TIZEN_UI_EFL_UTIL_H__ */ +#endif /* __TIZEN_UI_EFL_UTIL_H__ */ diff --git a/src/efl_util.c b/src/efl_util.c index 98b9ce3..2b56db0 100644 --- a/src/efl_util.c +++ b/src/efl_util.c @@ -30,9 +30,9 @@ typedef struct _notification_error_cb_info { - Evas_Object *window; - efl_util_notification_window_level_error_cb err_cb; - void *user_data; + Evas_Object *window; + efl_util_notification_window_level_error_cb err_cb; + void *user_data; } notification_error_cb_info; Eina_List *_g_notification_error_cb_info_list; @@ -51,274 +51,277 @@ static notification_error_cb_info *_notification_error_cb_info_find_by_xwin(unsi #endif -int efl_util_set_notification_window_level (Evas_Object* window, efl_util_notification_level_e level) +int +efl_util_set_notification_window_level(Evas_Object *window, efl_util_notification_level_e level) { - EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER); - EINA_SAFETY_ON_FALSE_RETURN_VAL(level >= EFL_UTIL_NOTIFICATION_LEVEL_1 && - level <= EFL_UTIL_NOTIFICATION_LEVEL_3, - EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_1) && + (level <= EFL_UTIL_NOTIFICATION_LEVEL_3), + EFL_UTIL_ERROR_INVALID_PARAMETER); #if X11 - Ecore_X_Window xwin = elm_win_xwindow_get(window); - if (xwin) - { - Ecore_X_Window_Type window_type; - if(ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE) - { - // success to get window type - if(window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION) - { - // given EFL window's type is not notification type. - return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; - } - } - else - return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; - - utilx_set_system_notification_level(ecore_x_display_get(), xwin, - level); - return EFL_UTIL_ERROR_NONE; - } + Ecore_X_Window xwin = elm_win_xwindow_get(window); + if (xwin) + { + Ecore_X_Window_Type window_type; + if(ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE) + { + // success to get window type + if(window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION) + { + // given EFL window's type is not notification type. + return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; + } + } + else + return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; + + utilx_set_system_notification_level(ecore_x_display_get(), xwin, + level); + return EFL_UTIL_ERROR_NONE; + } #endif #if ECORE_WAYLAND_FOUND - Ecore_Wl_Window wl_win = elm_win_wl_window_get(window); - if (wl_win) - { - printf("not implemented for wayland yet\n"); - return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; - } + Ecore_Wl_Window wl_win = elm_win_wl_window_get(window); + if (wl_win) + { + printf("not implemented for wayland yet\n"); + return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; + } #endif - return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; + return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; } - - -int efl_util_get_notification_window_level (Evas_Object* window, efl_util_notification_level_e* level) +int +efl_util_get_notification_window_level(Evas_Object *window, efl_util_notification_level_e *level) { - - EINA_SAFETY_ON_NULL_RETURN_VAL(window, - EFL_UTIL_ERROR_INVALID_PARAMETER); - EINA_SAFETY_ON_NULL_RETURN_VAL(level, - EFL_UTIL_ERROR_INVALID_PARAMETER); + + EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER); #if X11 - Ecore_X_Window_Type window_type; - Utilx_Notification_Level utilx_level; - Ecore_X_Window xwin = elm_win_xwindow_get(window); - if (xwin) - { - if(ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE) - { - // success to get window type - if(window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION) - { - // given EFL window's type is not notification type. - return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; - } - - utilx_level = utilx_get_system_notification_level (ecore_x_display_get(), xwin); - - if(utilx_level == UTILX_NOTIFICATION_LEVEL_LOW) - { - *level = EFL_UTIL_NOTIFICATION_LEVEL_1; - } - else if(utilx_level == UTILX_NOTIFICATION_LEVEL_NORMAL) - { - *level = EFL_UTIL_NOTIFICATION_LEVEL_2; - } - else if(utilx_level == UTILX_NOTIFICATION_LEVEL_HIGH) - { - *level = EFL_UTIL_NOTIFICATION_LEVEL_3; - } - else - { - return EFL_UTIL_ERROR_INVALID_PARAMETER; - } - - } - else - { - // fail to get window type - return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; - } - - return EFL_UTIL_ERROR_NONE; - } + Ecore_X_Window_Type window_type; + Utilx_Notification_Level utilx_level; + Ecore_X_Window xwin = elm_win_xwindow_get(window); + if (xwin) + { + if(ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE) + { + // success to get window type + if(window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION) + { + // given EFL window's type is not notification type. + return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; + } + + utilx_level = utilx_get_system_notification_level (ecore_x_display_get(), xwin); + + if(utilx_level == UTILX_NOTIFICATION_LEVEL_LOW) + { + *level = EFL_UTIL_NOTIFICATION_LEVEL_1; + } + else if(utilx_level == UTILX_NOTIFICATION_LEVEL_NORMAL) + { + *level = EFL_UTIL_NOTIFICATION_LEVEL_2; + } + else if(utilx_level == UTILX_NOTIFICATION_LEVEL_HIGH) + { + *level = EFL_UTIL_NOTIFICATION_LEVEL_3; + } + else + { + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + } + else + { + // fail to get window type + return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; + } + + return EFL_UTIL_ERROR_NONE; + } #endif #if ECORE_WAYLAND_FOUND - Ecore_Wl_Window wl_win = elm_win_wl_window_get(window); - if (wl_win) - { - printf("not implemented for wayland yet\n"); - return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; - } + Ecore_Wl_Window wl_win = elm_win_wl_window_get(window); + if (wl_win) + { + printf("not implemented for wayland yet\n"); + return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; + } #endif - return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; + return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; } -int efl_util_set_notification_window_level_error_cb(Evas_Object *window, efl_util_notification_window_level_error_cb callback, void *user_data) +int +efl_util_set_notification_window_level_error_cb(Evas_Object *window, efl_util_notification_window_level_error_cb callback, void *user_data) { - Eina_Bool ret = EINA_FALSE; + Eina_Bool ret = EINA_FALSE; - EINA_SAFETY_ON_NULL_RETURN_VAL(window, - EFL_UTIL_ERROR_INVALID_PARAMETER); - EINA_SAFETY_ON_NULL_RETURN_VAL(callback, - EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER); - ret = _efl_util_notification_info_add(window, callback, user_data); - if (ret) - { + ret = _efl_util_notification_info_add(window, callback, user_data); + if (ret) + { #if X11 - if (!_noti_level_access_result_atom) - _noti_level_access_result_atom = ecore_x_atom_get("_E_NOTIFICATION_LEVEL_ACCESS_RESULT"); + if (!_noti_level_access_result_atom) + _noti_level_access_result_atom = ecore_x_atom_get("_E_NOTIFICATION_LEVEL_ACCESS_RESULT"); - if (!_noti_level_access_result_handler) - _noti_level_access_result_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _efl_util_client_message, NULL); - _noti_handler_count++; + if (!_noti_level_access_result_handler) + _noti_level_access_result_handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _efl_util_client_message, NULL); + _noti_handler_count++; - return EFL_UTIL_ERROR_NONE; + return EFL_UTIL_ERROR_NONE; #endif #if ECORE_WAYLAND_FOUND - printf("not implemented for wayland yet\n"); - return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; + printf("not implemented for wayland yet\n"); + return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE; #endif - } + } - return EFL_UTIL_ERROR_OUT_OF_MEMORY; + return EFL_UTIL_ERROR_OUT_OF_MEMORY; } -int efl_util_unset_notification_window_level_error_cb(Evas_Object *window) +int +efl_util_unset_notification_window_level_error_cb(Evas_Object *window) { - Eina_Bool ret = EINA_FALSE; - - EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER); - - ret = _efl_util_notification_info_del(window); - if (ret) - { - _noti_handler_count--; - if (_noti_handler_count == 0) - { - if (_noti_level_access_result_handler) - { - ecore_event_handler_del(_noti_level_access_result_handler); - _noti_level_access_result_handler = NULL; - } - } - return EFL_UTIL_ERROR_NONE; - } - - return EFL_UTIL_ERROR_INVALID_PARAMETER; + Eina_Bool ret = EINA_FALSE; + + EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER); + + ret = _efl_util_notification_info_del(window); + if (ret) + { + _noti_handler_count--; + if (_noti_handler_count == 0) + { + if (_noti_level_access_result_handler) + { + ecore_event_handler_del(_noti_level_access_result_handler); + _noti_level_access_result_handler = NULL; + } + } + return EFL_UTIL_ERROR_NONE; + } + + return EFL_UTIL_ERROR_INVALID_PARAMETER; } #if X11 -static Eina_Bool _efl_util_client_message(void *data, int type, void *event) +static Eina_Bool +_efl_util_client_message(void *data, int type, void *event) { - Ecore_X_Event_Client_Message *ev; - - ev = event; - if (!ev) return ECORE_CALLBACK_PASS_ON; - - if (ev->message_type == _noti_level_access_result_atom) - { - Ecore_X_Window xwin; - xwin = ev->win; - - notification_error_cb_info *cb_info = NULL; - cb_info = _notification_error_cb_info_find_by_xwin(xwin); - if (cb_info) - { - int access = ev->data.l[1]; - if (access == 0) // permission denied - { - if (cb_info->err_cb) - { - cb_info->err_cb(cb_info->window, EFL_UTIL_ERROR_PERMISSION_DENIED, cb_info->user_data); - } - } - } - } - - return ECORE_CALLBACK_PASS_ON; + Ecore_X_Event_Client_Message *ev; + + ev = event; + if (!ev) return ECORE_CALLBACK_PASS_ON; + + if (ev->message_type == _noti_level_access_result_atom) + { + Ecore_X_Window xwin; + xwin = ev->win; + + notification_error_cb_info *cb_info = NULL; + cb_info = _notification_error_cb_info_find_by_xwin(xwin); + if (cb_info) + { + int access = ev->data.l[1]; + if (access == 0) // permission denied + { + if (cb_info->err_cb) + { + cb_info->err_cb(cb_info->window, EFL_UTIL_ERROR_PERMISSION_DENIED, cb_info->user_data); + } + } + } + } + + return ECORE_CALLBACK_PASS_ON; } -static notification_error_cb_info *_notification_error_cb_info_find_by_xwin(unsigned int xwin) +static notification_error_cb_info * +_notification_error_cb_info_find_by_xwin(unsigned int xwin) { - Eina_List *l; - notification_error_cb_info* temp; - unsigned int temp_xwin; - - EINA_LIST_FOREACH(_g_notification_error_cb_info_list, l, temp) - { - if (temp->window) - { - temp_xwin = elm_win_xwindow_get(temp->window); - if (xwin == temp_xwin) - { - return temp; - } - } - } - - return NULL; + Eina_List *l; + notification_error_cb_info* temp; + unsigned int temp_xwin; + + EINA_LIST_FOREACH(_g_notification_error_cb_info_list, l, temp) + { + if (temp->window) + { + temp_xwin = elm_win_xwindow_get(temp->window); + if (xwin == temp_xwin) + { + return temp; + } + } + } + + return NULL; } #endif -static notification_error_cb_info *_notification_error_cb_info_find(Evas_Object *window) +static notification_error_cb_info * +_notification_error_cb_info_find(Evas_Object *window) { - Eina_List *l; - notification_error_cb_info* temp; - - EINA_LIST_FOREACH(_g_notification_error_cb_info_list, l, temp) - { - if (temp->window == window) - { - return temp; - } - } - - return NULL; + Eina_List *l; + notification_error_cb_info* temp; + + EINA_LIST_FOREACH(_g_notification_error_cb_info_list, l, temp) + { + if (temp->window == window) + { + return temp; + } + } + + return NULL; } -static Eina_Bool _efl_util_notification_info_add(Evas_Object *window, efl_util_notification_window_level_error_cb callback, void *user_data) +static Eina_Bool +_efl_util_notification_info_add(Evas_Object *window, efl_util_notification_window_level_error_cb callback, void *user_data) { - notification_error_cb_info* _err_info = _notification_error_cb_info_find(window); - - if (_err_info) - { - _g_notification_error_cb_info_list = eina_list_remove(_g_notification_error_cb_info_list, _err_info); - free(_err_info); - _err_info = NULL; - } - - _err_info = (notification_error_cb_info*)calloc(1, sizeof(notification_error_cb_info)); - if (!_err_info) - { - return EINA_FALSE; - } - _err_info->window = window; - _err_info->err_cb = callback; - _err_info->user_data = user_data; - - _g_notification_error_cb_info_list = eina_list_append(_g_notification_error_cb_info_list, _err_info); - - return EINA_TRUE; + notification_error_cb_info* _err_info = _notification_error_cb_info_find(window); + + if (_err_info) + { + _g_notification_error_cb_info_list = eina_list_remove(_g_notification_error_cb_info_list, _err_info); + free(_err_info); + _err_info = NULL; + } + + _err_info = (notification_error_cb_info*)calloc(1, sizeof(notification_error_cb_info)); + if (!_err_info) + { + return EINA_FALSE; + } + _err_info->window = window; + _err_info->err_cb = callback; + _err_info->user_data = user_data; + + _g_notification_error_cb_info_list = eina_list_append(_g_notification_error_cb_info_list, _err_info); + + return EINA_TRUE; } -static Eina_Bool _efl_util_notification_info_del(Evas_Object *window) +static Eina_Bool +_efl_util_notification_info_del(Evas_Object *window) { - notification_error_cb_info* _err_info = _notification_error_cb_info_find(window); - if (!_err_info) - { - return EINA_FALSE; - } + notification_error_cb_info* _err_info = _notification_error_cb_info_find(window); + if (!_err_info) + { + return EINA_FALSE; + } - _g_notification_error_cb_info_list = eina_list_remove(_g_notification_error_cb_info_list, _err_info); - free(_err_info); + _g_notification_error_cb_info_list = eina_list_remove(_g_notification_error_cb_info_list, _err_info); + free(_err_info); - return EINA_TRUE; + return EINA_TRUE; }