+Doyoun Kang <doyoun.kang@samsung.com>
+Gwanglim Lee <gl77.lee@samsung.com>
Kyuhun Jung <kyuhun.jung@samsung.com>
static void utc_efl_util_set_notification_window_level_positive_1(void);
static void utc_efl_util_set_notification_window_level_positive_2(void);
+static void utc_efl_util_set_notification_window_level_positive_3(void);
static void utc_efl_util_get_notification_window_level_positive_1(void);
static void utc_efl_util_get_notification_window_level_positive_2(void);
+static void utc_efl_util_get_notification_window_level_positive_3(void);
struct tet_testlist tet_testlist[] = {
{ utc_efl_util_get_notification_window_level_negative_2, 1 },
{ utc_efl_util_set_notification_window_level_positive_1, 1 },
{ utc_efl_util_set_notification_window_level_positive_2, 1 },
+ { utc_efl_util_set_notification_window_level_positive_3, 1 },
{ utc_efl_util_get_notification_window_level_positive_1, 1 },
{ utc_efl_util_get_notification_window_level_positive_2, 1 },
+ { utc_efl_util_get_notification_window_level_positive_3, 1 },
{ NULL, 0 },
};
elm_win_borderless_set(eo, EINA_TRUE);
evas_object_smart_callback_add(eo, "delete,request",
win_del, NULL);
- elm_win_indicator_state_set(eo, EINA_TRUE);
+ elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
}
return eo;
elm_win_borderless_set(eo, EINA_TRUE);
evas_object_smart_callback_add(eo, "delete,request",
win_del, NULL);
- elm_win_indicator_state_set(eo, EINA_TRUE);
+ elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
}
return eo;
/**
* @brief Positive test case of efl_util_set_notification_window_level()
*/
+static void utc_efl_util_set_notification_window_level_positive_3(void)
+{
+ Evas_Object *win;
+ int ret1, ret2, ret3;
+
+ win = create_notification_win("Notification Type Window");
+ if (!win)
+ {
+ dts_fail(API_SET_NOTIFICATION_WINDOW_LEVEL, "failed to create window");
+ }
+
+ ret1 = efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_1);
+ ret2 = efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_2);
+ ret3 = efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_3);
+
+ if (ret3 == EFL_UTIL_ERROR_NONE)
+ {
+ dts_pass(API_SET_NOTIFICATION_WINDOW_LEVEL, "passed");
+ }
+ else
+ {
+ dts_fail(API_SET_NOTIFICATION_WINDOW_LEVEL, "failed");
+ }
+}
+
+
+/**
+ * @brief Positive test case of efl_util_set_notification_window_level()
+ */
static void utc_efl_util_get_notification_window_level_positive_1(void)
{
Evas_Object *win;
}
}
+
+/**
+ * @brief Positive test case of efl_util_set_notification_window_level()
+ */
+static void utc_efl_util_get_notification_window_level_positive_3(void)
+{
+ Evas_Object *win;
+ int ret;
+ int level;
+
+ win = create_notification_win("Notification Type Window");
+ if (!win)
+ {
+ dts_fail(API_GET_NOTIFICATION_WINDOW_LEVEL, "failed to create window");
+ }
+ efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_1);
+ efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_3);
+
+ level = -1;
+ ret = efl_util_get_notification_window_level(win, &level);
+
+ if (ret == EFL_UTIL_ERROR_NONE)
+ {
+ if (level == EFL_UTIL_NOTIFICATION_LEVEL_3)
+ {
+ dts_pass(API_GET_NOTIFICATION_WINDOW_LEVEL, "passed");
+ }
+ else
+ {
+ dts_fail(API_GET_NOTIFICATION_WINDOW_LEVEL, "failed - level is wrong");
+ }
+ }
+ else
+ {
+ dts_fail(API_GET_NOTIFICATION_WINDOW_LEVEL, "failed - return value is wrong");
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_UI_EFL_UTIL_DOC_H__
+#define __TIZEN_UI_EFL_UTIL_DOC_H__
+
+/**
+ * @ingroup CAPI_UI_FRAMEWORK
+ * @defgroup CAPI_EFL_UTIL_MODULE EFL UTIL
+ * @brief
+ *
+ * @section CAPI_EFL_UTIL_MODULE_HEADER Required Header
+ * \#include <efl_util.h>
+ *
+ * @section CAPI_EFL_UTIL_MODULE_OVERVIEW Overview
+ * The EFL UTIL API provides functions to get the level of given notification windows
+ * and to change the notification window levels with the given values.
+ *
+ * The notification window level is used in ordering the notification windows.
+ * The notification window which is set to #EFL_UTIL_NOTIFICATION_LEVEL_2 will be
+ * placed above the window which is set to #EFL_UTIL_NOTIFICATION_LEVEL_1.
+ * If there are notification windows that have the same levels, the latest created
+ * notification window is placed on top of the other window.
+ *
+ */
+
+#endif /* __TIZEN_UI_EFL_UTIL_DOC_H__ */
#endif
/**
+ * @file efl_util.h
+ */
+
+/**
* @addtogroup CAPI_EFL_UTIL_MODULE
* @{
*/
} Efl_Util_Notification_Level;
/**
- * @brief Enumerations of error code for EFL UTIL
+ * @brief Enumeration for EFL UTIL ERROR.
+ * @since_tizen 2.3
*/
typedef enum
{
EFL_UTIL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
EFL_UTIL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE = TIZEN_ERROR_APPLICATION_CLASS | 0x08 /**< Not supported window type */
+ 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 = -0x02800000 | 0x01 /**< Window type not supported */
+ //EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE = TIZEN_ERROR_EFL_UTIL | 0x01 /**< Window type not supported */
} efl_util_error_e;
// TODO: are we going to have more states than on/off shouldn't we move it to a bool in the API's
EFL_UTIL_OPAQUE_STATE_ON = 1, /**< Opaque state */
} Efl_Util_Opaque_State;
-/**
- * @brief Enumeration of notification window's priority level
- *
+/**
+ * @brief Enumeration of notification window's priority level.
+ * @since_tizen 2.3
*/
typedef enum
{
- EFL_UTIL_NOTIFICATION_LEVEL_1, /**< Default notification level*/
- EFL_UTIL_NOTIFICATION_LEVEL_2, /**< Higher notification level than default*/
+ 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;
typedef enum _Efl_Util_Effect_Type
/**
* @brief Sets the priority level for the specified notification window, asynchronously.
- *
- * @remark This API can be used for notification type window only
- * @param [in] window EFL window
- * @param [in] level The notification window level
- * @return 0 on success, otherwise a negative error value.
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/window.priority.set
+ * @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
* @retval #EFL_UTIL_ERROR_NONE Successful
* @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE Not supported window type
+ * @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);
/**
* @brief Gets the priority level for the specified notification window, asynchronously.
+ * @since_tizen 2.3
*
- * @remark This API can be used for notification type window only
- * @param [in] window EFL window
- * @param [out] level The notification window level
- * @return 0 on success, otherwise a negative error value.
+ * @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
* @retval #EFL_UTIL_ERROR_NONE Successful
* @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE Not supported window type
+ * @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);
+
+/**
+ * @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
+ * @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] user_data The user data to be passed to the callback function
+ * @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.
+ * @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
+ * @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);
+
+
/**
* @brief Grabs a key specfied by key_name for obj in grab_mode.
*
%bcond_with x
Name: capi-ui-efl-util
Summary: An EFL utility library in SLP C API
-Version: 0.1.0
+Version: 0.1.1
Release: 1
Group: Graphics & UI Framework/API
License: Apache-2.0
%if %{with x}
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(utilX)
+BuildRequires: pkgconfig(ecore-x)
%endif
BuildRequires: pkgconfig(elementary)
BuildRequires: pkgconfig(capi-base-common)
%install
%make_install
+# for license notification
+mkdir -p %{buildroot}/usr/share/license
+cp -a LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
+
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%manifest %{name}.manifest
%license LICENSE.APLv2
%{_libdir}/libcapi-ui-efl-util.so.*
+/usr/share/license/%{name}
%files devel
%manifest %{name}.manifest
-%{_includedir}/ui/*.h
+%{_includedir}/ui/efl_util.h
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libcapi-ui-efl-util.so
-
-
+%exclude %{_includedir}/ui/config.h
#include <utilX.h>
#endif
+typedef struct _notification_error_cb_info
+{
+ 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;
+static Ecore_Event_Handler* _noti_level_access_result_handler = NULL;
+static int _noti_handler_count = 0;
+static unsigned int _noti_level_access_result_atom = 0;
+
+static Eina_Bool _efl_util_client_message(void *data, int type, void *event);
+static notification_error_cb_info *_notification_error_cb_info_find(Evas_Object *window);
+static notification_error_cb_info *_notification_error_cb_info_find_by_xwin(unsigned int xwin);
+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_del(Evas_Object *window);
+
+
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_NOT_SUPPORTED_WINDOW_TYPE);
+ 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_2,
- EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
+ level <= EFL_UTIL_NOTIFICATION_LEVEL_3,
+ EFL_UTIL_ERROR_INVALID_PARAMETER);
#if ECORE_X_FOUND
Ecore_X_Window xwin = elm_win_xwindow_get(window);
{
EINA_SAFETY_ON_NULL_RETURN_VAL(window,
- EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
+ EFL_UTIL_ERROR_INVALID_PARAMETER);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(level,
+ EFL_UTIL_ERROR_INVALID_PARAMETER);
#if ECORE_X_FOUND
Ecore_X_Window_Type window_type;
}
else if(utilx_level == UTILX_NOTIFICATION_LEVEL_HIGH)
{
- *level = EFL_UTIL_NOTIFICATION_LEVEL_2;
+ *level = EFL_UTIL_NOTIFICATION_LEVEL_3;
}
else
{
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)
+{
+ 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);
+
+ ret = _efl_util_notification_info_add(window, callback, user_data);
+ if (ret)
+ {
+#if ECORE_X_FOUND
+ 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++;
+
+ 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;
+#endif
+ }
+
+ return EFL_UTIL_ERROR_OUT_OF_MEMORY;
+}
+
+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;
+}
+
int efl_util_grab_key (Evas_Object *obj, const char* key, int grab_mode)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, 0);
return 0;
}
+
+static Eina_Bool _efl_util_client_message(void *data, int type, void *event)
+{
+#if ECORE_X_FOUND
+ 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);
+ }
+ }
+ }
+ }
+#endif
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+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;
+}
+
+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;
+}
+
+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;
+}
+
+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;
+ }
+
+ _g_notification_error_cb_info_list = eina_list_remove(_g_notification_error_cb_info_list, _err_info);
+ free(_err_info);
+
+ return EINA_TRUE;
+}