From: Sung-jae Park Date: Thu, 30 Oct 2014 01:43:11 +0000 (+0900) Subject: Replace livebox with master X-Git-Tag: accepted/tizen/mobile/20150530.065423^2~18^2~11^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e88c3bb48ab0d2aba3270950f2c8ac97855e5d12;p=apps%2Fnative%2Fwidget%2Fwidget.git Replace livebox with master [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: Ia070ec9fe1b2a5f6c709b400a78e8c9b3ba9e91f --- diff --git a/TC/testcase/utc_livebox.c b/TC/testcase/utc_livebox.c index c52495e..ddca292 100644 --- a/TC/testcase/utc_livebox.c +++ b/TC/testcase/utc_livebox.c @@ -26,21 +26,21 @@ #include enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, }; static void startup(void) { - /* start of TC */ - tet_printf("\n TC start"); + /* start of TC */ + tet_printf("\n TC start"); } static void cleanup(void) { - /* end of TC */ - tet_printf("\n TC end"); + /* end of TC */ + tet_printf("\n TC end"); } void (*tet_startup)(void) = startup; @@ -52,535 +52,535 @@ void (*tet_cleanup)(void) = cleanup; static void utc_livebox_desc_open_n(void) { - LOGD(""); - struct livebox_desc *handle; + LOGD(""); + struct livebox_desc *handle; - handle = livebox_desc_open(DUMMY_INVALID_ID, 0); - if (handle) { - (void)livebox_desc_close(handle); - } + handle = livebox_desc_open(DUMMY_INVALID_ID, 0); + if (handle) { + (void)livebox_desc_close(handle); + } dts_check_eq("livebox_desc_open", handle, NULL, "Must return NULL in case of invalid id is used"); } static void utc_livebox_desc_open_p(void) { - LOGD(""); - struct livebox_desc *handle; + LOGD(""); + struct livebox_desc *handle; - handle = livebox_desc_open(DUMMY_ID, 0); + handle = livebox_desc_open(DUMMY_ID, 0); dts_check_ne("livebox_desc_open", handle, NULL, "Must return valid handle"); } static void utc_livebox_desc_close_n(void) { - LOGD(""); - int ret; + LOGD(""); + int ret; - ret = livebox_desc_close(NULL); - dts_check_eq("livebox_desc_close", ret, LB_STATUS_ERROR_INVALID, "Must returns LB_STATUS_ERROR_INVALID"); + ret = livebox_desc_close(NULL); + dts_check_eq("livebox_desc_close", ret, LB_STATUS_ERROR_INVALID, "Must returns LB_STATUS_ERROR_INVALID"); } static void utc_livebox_desc_close_p(void) { - LOGD(""); - struct livebox_desc *handle; - int ret; + LOGD(""); + struct livebox_desc *handle; + int ret; - handle = livebox_desc_open(DUMMY_ID, 0); - if (!handle) { - dts_check_ne("livebox_desc_close", handle, NULL, "Failed to create a handle"); - return; - } + handle = livebox_desc_open(DUMMY_ID, 0); + if (!handle) { + dts_check_ne("livebox_desc_close", handle, NULL, "Failed to create a handle"); + return; + } - ret = livebox_desc_close(handle); - dts_check_eq("livebox_desc_close", ret, LB_STATUS_SUCCESS, "Must returns LB_STATUS_SUCCESS"); + ret = livebox_desc_close(handle); + dts_check_eq("livebox_desc_close", ret, LB_STATUS_SUCCESS, "Must returns LB_STATUS_SUCCESS"); } static void utc_livebox_desc_set_category_n(void) { - LOGD(""); - int ret; - ret = livebox_desc_set_category(NULL, NULL, NULL); + LOGD(""); + int ret; + ret = livebox_desc_set_category(NULL, NULL, NULL); - dts_check_eq("livebox_desc_set_category", ret, LB_STATUS_ERROR_INVALID, "Invalid parameter used, LB_STATUS_ERROR_INVALID should be returned"); + dts_check_eq("livebox_desc_set_category", ret, LB_STATUS_ERROR_INVALID, "Invalid parameter used, LB_STATUS_ERROR_INVALID should be returned"); } static void utc_livebox_desc_set_category_p(void) { - LOGD(""); - struct livebox_desc *handle; - int ret; + LOGD(""); + struct livebox_desc *handle; + int ret; - handle = livebox_desc_open(DUMMY_ID, 0); - if (!handle) { - dts_check_ne("livebox_desc_set_category", handle, NULL, "Failed to create a handle"); - return; - } + handle = livebox_desc_open(DUMMY_ID, 0); + if (!handle) { + dts_check_ne("livebox_desc_set_category", handle, NULL, "Failed to create a handle"); + return; + } - ret = livebox_desc_set_category(handle, NULL, "New Category"); - (void)livebox_desc_close(handle); - dts_check_eq("livebox_desc_set_category", ret, LB_STATUS_SUCCESS, "LB_STATUS_SUCCESS should be returned\n"); + ret = livebox_desc_set_category(handle, NULL, "New Category"); + (void)livebox_desc_close(handle); + dts_check_eq("livebox_desc_set_category", ret, LB_STATUS_SUCCESS, "LB_STATUS_SUCCESS should be returned\n"); } static void utc_livebox_desc_set_id_n(void) { - LOGD(""); - struct livebox_desc *handle; - int ret; + LOGD(""); + struct livebox_desc *handle; + int ret; - handle = livebox_desc_open(DUMMY_ID, 0); - if (!handle) { - dts_check_ne("livebox_desc_set_id", handle, NULL, "Failed to create a handle"); - return; - } - ret = livebox_desc_set_id(handle, -1, NULL); - (void)livebox_desc_close(handle); - dts_check_eq("livebox_desc_set_id", ret, LB_STATUS_ERROR_NOT_EXIST, "LB_STATUS_ERROR_NOT_EXIST should be returned\n"); + handle = livebox_desc_open(DUMMY_ID, 0); + if (!handle) { + dts_check_ne("livebox_desc_set_id", handle, NULL, "Failed to create a handle"); + return; + } + ret = livebox_desc_set_id(handle, -1, NULL); + (void)livebox_desc_close(handle); + dts_check_eq("livebox_desc_set_id", ret, LB_STATUS_ERROR_NOT_EXIST, "LB_STATUS_ERROR_NOT_EXIST should be returned\n"); } static void utc_livebox_desc_set_id_p(void) { - LOGD(""); - struct livebox_desc *handle; - int ret; - int idx; + LOGD(""); + struct livebox_desc *handle; + int ret; + int idx; - handle = livebox_desc_open(DUMMY_ID, 0); - if (!handle) { - dts_check_ne("livebox_desc_set_id", handle, NULL, "Failed to create a handle"); - return; - } - idx = livebox_desc_add_block(handle, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group"); - if (idx < 0) { - dts_check_ge("livebox_desc_set_id", idx, 0, "Failed to add a desc block"); - (void)livebox_desc_close(handle); - return; - } + handle = livebox_desc_open(DUMMY_ID, 0); + if (!handle) { + dts_check_ne("livebox_desc_set_id", handle, NULL, "Failed to create a handle"); + return; + } + idx = livebox_desc_add_block(handle, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group"); + if (idx < 0) { + dts_check_ge("livebox_desc_set_id", idx, 0, "Failed to add a desc block"); + (void)livebox_desc_close(handle); + return; + } - ret = livebox_desc_set_id(handle, idx, "new,id"); - (void)livebox_desc_close(handle); - dts_check_eq("livebox_desc_set_id", ret, LB_STATUS_SUCCESS, "LB_STATUS_SUCCESS should be returned\n"); + ret = livebox_desc_set_id(handle, idx, "new,id"); + (void)livebox_desc_close(handle); + dts_check_eq("livebox_desc_set_id", ret, LB_STATUS_SUCCESS, "LB_STATUS_SUCCESS should be returned\n"); } static void utc_livebox_desc_add_block_n(void) { - LOGD(""); - int idx; + LOGD(""); + int idx; - idx = livebox_desc_add_block(NULL, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group"); - dts_check_eq("livebox_desc_add_block", idx, LB_STATUS_ERROR_INVALID, "LB_STATUS_ERROR_INVALID should be returned\n"); + idx = livebox_desc_add_block(NULL, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group"); + dts_check_eq("livebox_desc_add_block", idx, LB_STATUS_ERROR_INVALID, "LB_STATUS_ERROR_INVALID should be returned\n"); } static void utc_livebox_desc_add_block_p(void) { - LOGD(""); - struct livebox_desc *handle; - int idx; + LOGD(""); + struct livebox_desc *handle; + int idx; - handle = livebox_desc_open(DUMMY_ID, 0); - if (!handle) { - dts_check_ne("livebox_desc_add_block", handle, NULL, "Failed to create a handle"); - return; - } + handle = livebox_desc_open(DUMMY_ID, 0); + if (!handle) { + dts_check_ne("livebox_desc_add_block", handle, NULL, "Failed to create a handle"); + return; + } - idx = livebox_desc_add_block(handle, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group"); - dts_check_ge("livebox_desc_add_block", idx, 0, "idx should not be less than 0\n"); - (void)livebox_desc_close(handle); + idx = livebox_desc_add_block(handle, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group"); + dts_check_ge("livebox_desc_add_block", idx, 0, "idx should not be less than 0\n"); + (void)livebox_desc_close(handle); } static void utc_livebox_desc_del_block_n(void) { - LOGD(""); - struct livebox_desc *handle; - int ret; + LOGD(""); + struct livebox_desc *handle; + int ret; - handle = livebox_desc_open(DUMMY_ID, 0); - if (!handle) { - dts_check_ne("livebox_desc_del_block", handle, NULL, "Failed to create a handle"); - return; - } + handle = livebox_desc_open(DUMMY_ID, 0); + if (!handle) { + dts_check_ne("livebox_desc_del_block", handle, NULL, "Failed to create a handle"); + return; + } - ret = livebox_desc_del_block(handle, 0); - dts_check_eq("livebox_desc_del_block", ret, LB_STATUS_ERROR_NOT_EXIST, "Block is not found, LB_STATUS_ERROR_NOT_EXIST should be returned\n"); + ret = livebox_desc_del_block(handle, 0); + dts_check_eq("livebox_desc_del_block", ret, LB_STATUS_ERROR_NOT_EXIST, "Block is not found, LB_STATUS_ERROR_NOT_EXIST should be returned\n"); } static void utc_livebox_desc_del_block_p(void) { - LOGD(""); - struct livebox_desc *handle; - int idx; - int ret; - - handle = livebox_desc_open(DUMMY_ID, 0); - if (handle == NULL) { - dts_check_ne("livebox_desc_del_block", handle, NULL, "Failed to create desc handle"); - return; - } - idx = livebox_desc_add_block(handle, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group"); - if (idx < 0) { - dts_check_ge("livebox_desc_del_block", idx, 0, "Failed to add a desc block"); - (void)livebox_desc_close(handle); - return; - } - ret = livebox_desc_del_block(handle, idx); - (void)livebox_desc_close(handle); - dts_check_eq("livebox_desc_del_block", ret, LB_STATUS_SUCCESS, "del_block should returns LB_STATUS_SUCCESS\n"); + LOGD(""); + struct livebox_desc *handle; + int idx; + int ret; + + handle = livebox_desc_open(DUMMY_ID, 0); + if (handle == NULL) { + dts_check_ne("livebox_desc_del_block", handle, NULL, "Failed to create desc handle"); + return; + } + idx = livebox_desc_add_block(handle, NULL, LB_DESC_TYPE_SCRIPT, "swallow,part", "/usr/apps/com.samsung.test-app/res/edje/test.edj", "test,group"); + if (idx < 0) { + dts_check_ge("livebox_desc_del_block", idx, 0, "Failed to add a desc block"); + (void)livebox_desc_close(handle); + return; + } + ret = livebox_desc_del_block(handle, idx); + (void)livebox_desc_close(handle); + dts_check_eq("livebox_desc_del_block", ret, LB_STATUS_SUCCESS, "del_block should returns LB_STATUS_SUCCESS\n"); } int livebox_trigger_update_monitor(const char *id, int is_pd) { - if (!id) { - return LB_STATUS_ERROR_INVALID; - } + if (!id) { + return LB_STATUS_ERROR_INVALID; + } - return LB_STATUS_SUCCESS; + return LB_STATUS_SUCCESS; } static void utc_livebox_content_is_updated_n(void) { - LOGD(""); - int ret; + LOGD(""); + int ret; - ret = livebox_content_is_updated(NULL, 0); - dts_check_eq("livebox_content_is_updated", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); + ret = livebox_content_is_updated(NULL, 0); + dts_check_eq("livebox_content_is_updated", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); } static void utc_livebox_content_is_updated_p(void) { - LOGD(""); - int ret; - ret = livebox_content_is_updated(DUMMY_ID, 0); - dts_check_eq("livebox_content_is_updated", ret, LB_STATUS_SUCCESS, "should returns LB_STATUS_SUCCESS\n"); + LOGD(""); + int ret; + ret = livebox_content_is_updated(DUMMY_ID, 0); + dts_check_eq("livebox_content_is_updated", ret, LB_STATUS_SUCCESS, "should returns LB_STATUS_SUCCESS\n"); } static void utc_livebox_request_close_pd_n(void) { - LOGD(""); - int ret; + LOGD(""); + int ret; - ret = livebox_request_close_pd(DUMMY_PKGNAME, DUMMY_ID, LB_STATUS_SUCCESS); - dts_check_eq("livebox_request_close_pd", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); + ret = livebox_request_close_pd(DUMMY_PKGNAME, DUMMY_ID, LB_STATUS_SUCCESS); + dts_check_eq("livebox_request_close_pd", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); } static void utc_livebox_request_close_pd_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_request_close_pd", "pass negative test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_request_close_pd", "pass negative test"); } static void utc_livebox_request_update_n(void) { - LOGD(""); - int ret; - ret = livebox_request_update(NULL); - dts_check_eq("livebox_request_update", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID"); + LOGD(""); + int ret; + ret = livebox_request_update(NULL); + dts_check_eq("livebox_request_update", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID"); } static void utc_livebox_request_update_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_request_update", "pass negative test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_request_update", "pass negative test"); } static void utc_livebox_util_nl2br_n(void) { - LOGD(""); - char *nl2br; + LOGD(""); + char *nl2br; - nl2br = livebox_util_nl2br(NULL); - dts_check_eq("livebox_util_nl2br", nl2br, NULL, "should returns NULL\n"); + nl2br = livebox_util_nl2br(NULL); + dts_check_eq("livebox_util_nl2br", nl2br, NULL, "should returns NULL\n"); } static void utc_livebox_util_nl2br_p(void) { - LOGD(""); - char *nl2br; - nl2br = livebox_util_nl2br("hello\nworld"); - LOGD("[%s]", nl2br); - dts_check_str_eq("livebox_util_nl2br", nl2br, "hello
world", "should returns \"hello
world\""); - LOGD(""); + LOGD(""); + char *nl2br; + nl2br = livebox_util_nl2br("hello\nworld"); + LOGD("[%s]", nl2br); + dts_check_str_eq("livebox_util_nl2br", nl2br, "hello
world", "should returns \"hello
world\""); + LOGD(""); } static void utc_livebox_acquire_buffer_n(void) { - LOGD(""); - struct livebox_buffer *handle; + LOGD(""); + struct livebox_buffer *handle; - handle = livebox_acquire_buffer(NULL, 0, 720, 200, NULL, NULL); - dts_check_eq("livebox_acquire_buffer", handle, NULL, "should returns NULL\n"); + handle = livebox_acquire_buffer(NULL, 0, 720, 200, NULL, NULL); + dts_check_eq("livebox_acquire_buffer", handle, NULL, "should returns NULL\n"); } static void utc_livebox_acquire_buffer_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_acquire_buffer", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_acquire_buffer", "pass positive test"); } static void utc_livebox_acquire_buffer_NEW_n(void) { - LOGD(""); - struct livebox_buffer *handle; + LOGD(""); + struct livebox_buffer *handle; - handle = livebox_acquire_buffer_NEW(NULL, 0, 720, 200, sizeof(int), NULL, NULL); - dts_check_eq("livebox_acquire_buffer_NEW", handle, NULL, "should returns NULL\n"); + handle = livebox_acquire_buffer_NEW(NULL, 0, 720, 200, sizeof(int), NULL, NULL); + dts_check_eq("livebox_acquire_buffer_NEW", handle, NULL, "should returns NULL\n"); } static void utc_livebox_acquire_buffer_NEW_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_acquire_buffer_NEW", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_acquire_buffer_NEW", "pass positive test"); } static void utc_livebox_pixmap_id_n(void) { - LOGD(""); - unsigned long pixmap; + LOGD(""); + unsigned long pixmap; - pixmap = livebox_pixmap_id(NULL); - dts_check_eq("livebox_pixmap_id", pixmap, 0, "should returns 0\n"); + pixmap = livebox_pixmap_id(NULL); + dts_check_eq("livebox_pixmap_id", pixmap, 0, "should returns 0\n"); } static void utc_livebox_pixmap_id_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_pixmap_id", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_pixmap_id", "pass positive test"); } static void utc_livebox_ref_buffer_n(void) { - LOGD(""); - void *ret; - ret = livebox_ref_buffer(NULL); - dts_check_eq("livebox_ref_buffer", ret, NULL, "should returns NULL\n"); + LOGD(""); + void *ret; + ret = livebox_ref_buffer(NULL); + dts_check_eq("livebox_ref_buffer", ret, NULL, "should returns NULL\n"); } static void utc_livebox_ref_buffer_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_ref_buffer", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_ref_buffer", "pass positive test"); } static void utc_livebox_sync_buffer_n(void) { - LOGD(""); - int ret; - ret = livebox_sync_buffer(NULL); - dts_check_eq("livebox_sync_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); + LOGD(""); + int ret; + ret = livebox_sync_buffer(NULL); + dts_check_eq("livebox_sync_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); } static void utc_livebox_sync_buffer_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_sync_buffer", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_sync_buffer", "pass positive test"); } static void utc_livebox_support_hw_buffer_n(void) { - LOGD(""); - int ret; - ret = livebox_support_hw_buffer(NULL); - dts_check_eq("livebox_support_hw_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); + LOGD(""); + int ret; + ret = livebox_support_hw_buffer(NULL); + dts_check_eq("livebox_support_hw_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); } static void utc_livebox_support_hw_buffer_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_support_hw_buffer", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_support_hw_buffer", "pass positive test"); } static void utc_livebox_create_hw_buffer_n(void) { - LOGD(""); - int ret; - ret = livebox_create_hw_buffer(NULL); - dts_check_eq("livebox_create_hw_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); + LOGD(""); + int ret; + ret = livebox_create_hw_buffer(NULL); + dts_check_eq("livebox_create_hw_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); } static void utc_livebox_create_hw_buffer_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_create_hw_buffer", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_create_hw_buffer", "pass positive test"); } static void utc_livebox_destroy_hw_buffer_n(void) { - LOGD(""); - int ret; - ret = livebox_destroy_hw_buffer(NULL); - dts_check_eq("livebox_destroy_hw_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); + LOGD(""); + int ret; + ret = livebox_destroy_hw_buffer(NULL); + dts_check_eq("livebox_destroy_hw_buffer", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); } static void utc_livebox_destroy_hw_buffer_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_destroy_hw_buffer", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_destroy_hw_buffer", "pass positive test"); } static void utc_livebox_buffer_hw_buffer_n(void) { - LOGD(""); - void *ret; - ret = livebox_buffer_hw_buffer(NULL); - dts_check_eq("livebox_buffer_hw_buffer", ret, NULL, "should returns LB_STATUS_ERROR_INVALID"); + LOGD(""); + void *ret; + ret = livebox_buffer_hw_buffer(NULL); + dts_check_eq("livebox_buffer_hw_buffer", ret, NULL, "should returns LB_STATUS_ERROR_INVALID"); } static void utc_livebox_buffer_hw_buffer_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_buffer_hw_buffer", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_buffer_hw_buffer", "pass positive test"); } static void utc_livebox_buffer_pre_render_n(void) { - LOGD(""); - int ret; - ret = livebox_buffer_pre_render(NULL); - dts_check_eq("livebox_buffer_pre_render", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); + LOGD(""); + int ret; + ret = livebox_buffer_pre_render(NULL); + dts_check_eq("livebox_buffer_pre_render", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); } static void utc_livebox_buffer_pre_render_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_buffer_pre_render", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_buffer_pre_render", "pass positive test"); } static void utc_livebox_buffer_post_render_n(void) { - LOGD(""); - int ret; - ret = livebox_buffer_post_render(NULL); - dts_check_eq("livebox_buffer_post_render", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); + LOGD(""); + int ret; + ret = livebox_buffer_post_render(NULL); + dts_check_eq("livebox_buffer_post_render", ret, LB_STATUS_ERROR_INVALID, "should returns LB_STATUS_ERROR_INVALID\n"); } static void utc_livebox_buffer_post_render_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_buffer_post_render", "pass positive test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_buffer_post_render", "pass positive test"); } static void utc_livebox_get_evas_object_n(void) { - LOGD(""); - Evas_Object *obj; + LOGD(""); + Evas_Object *obj; - obj = livebox_get_evas_object(NULL, 1); - dts_check_eq("livebox_get_evas_object", obj, NULL, "should returns NULL\n"); + obj = livebox_get_evas_object(NULL, 1); + dts_check_eq("livebox_get_evas_object", obj, NULL, "should returns NULL\n"); } static void utc_livebox_get_evas_object_p(void) { - LOGD(""); - /*! - * \note - * Unable to test the positive case - */ - dts_pass("livebox_get_evas_object", "pass positve test"); + LOGD(""); + /*! + * \note + * Unable to test the positive case + */ + dts_pass("livebox_get_evas_object", "pass positve test"); } struct tet_testlist tet_testlist[] = { - { utc_livebox_desc_open_n, NEGATIVE_TC_IDX }, - { utc_livebox_desc_open_p, POSITIVE_TC_IDX }, - { utc_livebox_desc_close_n, NEGATIVE_TC_IDX }, - { utc_livebox_desc_close_p, POSITIVE_TC_IDX }, - { utc_livebox_desc_set_category_n, NEGATIVE_TC_IDX }, - { utc_livebox_desc_set_category_p, POSITIVE_TC_IDX }, - { utc_livebox_desc_set_id_n, NEGATIVE_TC_IDX }, - { utc_livebox_desc_set_id_p, POSITIVE_TC_IDX }, - { utc_livebox_desc_add_block_n, NEGATIVE_TC_IDX }, - { utc_livebox_desc_add_block_p, POSITIVE_TC_IDX }, - { utc_livebox_desc_del_block_n, NEGATIVE_TC_IDX }, - { utc_livebox_desc_del_block_p, POSITIVE_TC_IDX }, - { utc_livebox_content_is_updated_n, NEGATIVE_TC_IDX }, - { utc_livebox_content_is_updated_p, POSITIVE_TC_IDX }, - { utc_livebox_request_close_pd_n, NEGATIVE_TC_IDX }, - { utc_livebox_request_close_pd_p, POSITIVE_TC_IDX }, - { utc_livebox_request_update_n, NEGATIVE_TC_IDX }, - { utc_livebox_request_update_p, POSITIVE_TC_IDX }, - { utc_livebox_util_nl2br_n, NEGATIVE_TC_IDX }, - { utc_livebox_util_nl2br_p, POSITIVE_TC_IDX }, - - { utc_livebox_acquire_buffer_n, NEGATIVE_TC_IDX }, - { utc_livebox_acquire_buffer_p, POSITIVE_TC_IDX }, - { utc_livebox_acquire_buffer_NEW_n, NEGATIVE_TC_IDX }, - { utc_livebox_acquire_buffer_NEW_p, POSITIVE_TC_IDX }, - - { utc_livebox_pixmap_id_n, NEGATIVE_TC_IDX }, - { utc_livebox_pixmap_id_p, POSITIVE_TC_IDX }, - - { utc_livebox_ref_buffer_n, NEGATIVE_TC_IDX }, - { utc_livebox_ref_buffer_p, POSITIVE_TC_IDX }, - - { utc_livebox_sync_buffer_n, NEGATIVE_TC_IDX }, - { utc_livebox_sync_buffer_p, POSITIVE_TC_IDX }, - - { utc_livebox_support_hw_buffer_n, NEGATIVE_TC_IDX }, - { utc_livebox_support_hw_buffer_p, POSITIVE_TC_IDX }, - { utc_livebox_create_hw_buffer_n, NEGATIVE_TC_IDX }, - { utc_livebox_create_hw_buffer_p, POSITIVE_TC_IDX }, - { utc_livebox_destroy_hw_buffer_n, NEGATIVE_TC_IDX }, - { utc_livebox_destroy_hw_buffer_p, POSITIVE_TC_IDX }, - { utc_livebox_buffer_hw_buffer_n, NEGATIVE_TC_IDX }, - { utc_livebox_buffer_hw_buffer_p, POSITIVE_TC_IDX }, - { utc_livebox_buffer_pre_render_n, NEGATIVE_TC_IDX }, - { utc_livebox_buffer_pre_render_p, POSITIVE_TC_IDX }, - { utc_livebox_buffer_post_render_n, NEGATIVE_TC_IDX }, - { utc_livebox_buffer_post_render_p, POSITIVE_TC_IDX }, - { utc_livebox_get_evas_object_n, NEGATIVE_TC_IDX }, - { utc_livebox_get_evas_object_p, POSITIVE_TC_IDX }, - - { NULL, 0 }, + { utc_livebox_desc_open_n, NEGATIVE_TC_IDX }, + { utc_livebox_desc_open_p, POSITIVE_TC_IDX }, + { utc_livebox_desc_close_n, NEGATIVE_TC_IDX }, + { utc_livebox_desc_close_p, POSITIVE_TC_IDX }, + { utc_livebox_desc_set_category_n, NEGATIVE_TC_IDX }, + { utc_livebox_desc_set_category_p, POSITIVE_TC_IDX }, + { utc_livebox_desc_set_id_n, NEGATIVE_TC_IDX }, + { utc_livebox_desc_set_id_p, POSITIVE_TC_IDX }, + { utc_livebox_desc_add_block_n, NEGATIVE_TC_IDX }, + { utc_livebox_desc_add_block_p, POSITIVE_TC_IDX }, + { utc_livebox_desc_del_block_n, NEGATIVE_TC_IDX }, + { utc_livebox_desc_del_block_p, POSITIVE_TC_IDX }, + { utc_livebox_content_is_updated_n, NEGATIVE_TC_IDX }, + { utc_livebox_content_is_updated_p, POSITIVE_TC_IDX }, + { utc_livebox_request_close_pd_n, NEGATIVE_TC_IDX }, + { utc_livebox_request_close_pd_p, POSITIVE_TC_IDX }, + { utc_livebox_request_update_n, NEGATIVE_TC_IDX }, + { utc_livebox_request_update_p, POSITIVE_TC_IDX }, + { utc_livebox_util_nl2br_n, NEGATIVE_TC_IDX }, + { utc_livebox_util_nl2br_p, POSITIVE_TC_IDX }, + + { utc_livebox_acquire_buffer_n, NEGATIVE_TC_IDX }, + { utc_livebox_acquire_buffer_p, POSITIVE_TC_IDX }, + { utc_livebox_acquire_buffer_NEW_n, NEGATIVE_TC_IDX }, + { utc_livebox_acquire_buffer_NEW_p, POSITIVE_TC_IDX }, + + { utc_livebox_pixmap_id_n, NEGATIVE_TC_IDX }, + { utc_livebox_pixmap_id_p, POSITIVE_TC_IDX }, + + { utc_livebox_ref_buffer_n, NEGATIVE_TC_IDX }, + { utc_livebox_ref_buffer_p, POSITIVE_TC_IDX }, + + { utc_livebox_sync_buffer_n, NEGATIVE_TC_IDX }, + { utc_livebox_sync_buffer_p, POSITIVE_TC_IDX }, + + { utc_livebox_support_hw_buffer_n, NEGATIVE_TC_IDX }, + { utc_livebox_support_hw_buffer_p, POSITIVE_TC_IDX }, + { utc_livebox_create_hw_buffer_n, NEGATIVE_TC_IDX }, + { utc_livebox_create_hw_buffer_p, POSITIVE_TC_IDX }, + { utc_livebox_destroy_hw_buffer_n, NEGATIVE_TC_IDX }, + { utc_livebox_destroy_hw_buffer_p, POSITIVE_TC_IDX }, + { utc_livebox_buffer_hw_buffer_n, NEGATIVE_TC_IDX }, + { utc_livebox_buffer_hw_buffer_p, POSITIVE_TC_IDX }, + { utc_livebox_buffer_pre_render_n, NEGATIVE_TC_IDX }, + { utc_livebox_buffer_pre_render_p, POSITIVE_TC_IDX }, + { utc_livebox_buffer_post_render_n, NEGATIVE_TC_IDX }, + { utc_livebox_buffer_post_render_p, POSITIVE_TC_IDX }, + { utc_livebox_get_evas_object_n, NEGATIVE_TC_IDX }, + { utc_livebox_get_evas_object_p, POSITIVE_TC_IDX }, + + { NULL, 0 }, }; diff --git a/doc/dynamicbox_doc.h b/doc/dynamicbox_doc.h index e00ba37..f20bc65 100644 --- a/doc/dynamicbox_doc.h +++ b/doc/dynamicbox_doc.h @@ -41,7 +41,7 @@ int idx; desc_handle = dynamicbox_desc_open(id, 0); if (!desc_handle) { - // Error + // Error } dynamicbox_desc_set_size(desc_handle, id, 720, 360); @@ -69,13 +69,13 @@ Evas_Object *win; parent = dynamicbox_get_evas_object(id, 0); if (!parent) { - // Error + // Error } win = elm_win_add(parent, "Dynamic Box Window", ELM_WIN_DYNAMIC_BOX); evas_object_del(parent); if (!win) { - // Error + // Error } @endcode diff --git a/include/debug.h b/include/debug.h index d278fc4..abda5f1 100644 --- a/include/debug.h +++ b/include/debug.h @@ -14,7 +14,8 @@ * limitations under the License. */ -#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) -#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) -#define WarnPrint(format, arg...) SECURE_LOGW(format, ##arg) +#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) +#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) +#define WarnPrint(format, arg...) SECURE_LOGW(format, ##arg) + /* End of a file */ diff --git a/include/dlist.h b/include/dlist.h index 6ce75e0..4a4ac3e 100644 --- a/include/dlist.h +++ b/include/dlist.h @@ -15,18 +15,18 @@ */ #define dlist_remove_data(list, data) do { \ - struct dlist *l; \ - l = dlist_find_data(list, data); \ - list = dlist_remove(list, l); \ + struct dlist *l; \ + l = dlist_find_data(list, data); \ + list = dlist_remove(list, l); \ } while (0) #define dlist_foreach(list, l, data) \ - for ((l) = (list); ((data) = dlist_data(l)); (l) = dlist_next(l)) + for ((l) = (list); ((data) = dlist_data(l)); (l) = dlist_next(l)) #define dlist_foreach_safe(list, l, n, data) \ - for ((l) = (list), (n) = dlist_next(l); \ - ((data) = dlist_data(l)); \ - (l) = (n), (n) = dlist_next(l)) + for ((l) = (list), (n) = dlist_next(l); \ + ((data) = dlist_data(l)); \ + (l) = (n), (n) = dlist_next(l)) struct dlist; diff --git a/include/dynamicbox.h b/include/dynamicbox.h index f1b8a9b..6dc16a9 100644 --- a/include/dynamicbox.h +++ b/include/dynamicbox.h @@ -90,7 +90,7 @@ extern "C" { * @brief Definition for accessibility operation. * @since_tizen 2.3 */ -#define DBOX_DESC_TYPE_ACCESS_OPERATION "access,operation" +#define DBOX_DESC_TYPE_ACCESS_OPERATION "access,operation" /** * @brief Definition for set highlight on specified part. @@ -157,7 +157,7 @@ typedef void (*dynamicbox_flush_cb)(void *snapshot_window, const char *id, int s * @param[in] id Dynamic Box Instance Id * @param[in] gbar 1 for Glance Bar or 0 * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return Handle of desc instance * @pre Should be loaded by data-provider-slave. * @post Should be destroyed(flushed) using dynamicbox_desc_close() API. @@ -172,7 +172,7 @@ extern dynamicbox_desc_h dynamicbox_desc_open(const char *id, int gbar); * @remarks Must be used only by Inhouse Dynamic Box. * @param[in] handle Handle which is created by dynamicbox_desc_open() function * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return int type * @retval #DBOX_STATUS_ERROR_NONE If the flushing description data is successfully done * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER If the given handle is not valid @@ -274,7 +274,7 @@ extern int dynamicbox_desc_del_block(dynamicbox_desc_h handle, int idx); * @param[in] id Instance Id * @param[in] gbar 1 if this object is created for Glance Bar or 0 (for Dynamic Box) * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return void* Object type * @retval Address Valid evas object * @retval @c NULL failed to create @@ -459,7 +459,7 @@ extern int dynamicbox_content_is_updated(const char *id, int gbar); * @param[in] handler Event handling callback * @param[in] data User data for event handling callback * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return Buffer handle * @retval @c NULL Failed to acquire buffer * @retval handler Handle object @@ -467,7 +467,28 @@ extern int dynamicbox_content_is_updated(const char *id, int gbar); * @post Allocated buffer object must be released via dynamicbox_release_buffer(). * @see dynamicbox_release_buffer() */ -extern dynamicbox_buffer_h dynamicbox_acquire_buffer(const char *id, int gbar, int width, int height, int pixels, int auto_align, int (*handler)(dynamicbox_buffer_h, dynamicbox_buffer_event_data_t, void *), void *data); +extern dynamicbox_buffer_h dynamicbox_create_buffer(const char *id, int gbar, int auto_align, int (*handler)(dynamicbox_buffer_h, dynamicbox_buffer_event_data_t, void *), void *data); + +/** + * @internal + * @brief Acquire a buffer for GBar or DBox. + * @since_tizen 2.3 + * @param[in] handle Buffer handle + * @param[in] idx Index of a buffer, DBOX_PRIMARY_BUFFER is used for accessing primary buffer + * @param[in] width Width of a buffer + * @param[in] height Height of a buffer + * @param[in] pixels Pixel size in byte + * @privlevel public + * @privilege %http://tizen.org/privilege/core/dynamicbox + * @return int status + * @retval #DBOX_STATUS_ERROR_NONE Successfully allocated + * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred + * @pre dynamicbox_create_buffer() must be called + * @see dynamicbox_create_buffer() + * @see dynamicbox_release_buffer() + */ +extern int dynamicbox_acquire_buffer(dynamicbox_buffer_h handle, int idx, int width, int height, int pixels); /** * @internal @@ -476,37 +497,54 @@ extern dynamicbox_buffer_h dynamicbox_acquire_buffer(const char *id, int gbar, i * @since_tizen 2.3 * @remarks Pixmap Id can be destroyed if you call the dynamicbox_release_buffer(). Then this Resource Id is not guaranteed to use. * @param[in] handle Buffer handle + * @param[in] idx Index of a buffer, #c DBOX_PRIMARY_BUFFER is used for accessing the primary buffer * @return unsigned int Resource Id * @retval >0 Resource Id * @retval 0 Failed to get Resource Id * @pre The system must be set to use the Resource Id method for content sharing. * @see dynamicbox_acquire_buffer() */ -extern unsigned int dynamicbox_resource_id(dynamicbox_buffer_h handle); +extern unsigned int dynamicbox_resource_id(dynamicbox_buffer_h handle, int idx); /** * @internal * @brief Releases the buffer of dynamicbox. * @since_tizen 2.3 * @param[in] handle Buffer handle + * @param[in] idx Index of a buffer, #c DBOX_PRIMARY_BUFFER is used for accessing the primary buffer * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider - * @return int type + * @privilege %http://tizen.org/privilege/core/dynamicbox + * @return int status * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument * @retval #DBOX_STATUS_ERROR_NONE Successfully released * @pre Handle must be created using dynamicbox_acquire_buffer(). * @see dynamicbox_acquire_buffer() */ -extern int dynamicbox_release_buffer(dynamicbox_buffer_h handle); +extern int dynamicbox_release_buffer(dynamicbox_buffer_h handle, int idx); + +/** + * @internal + * @brief Destroy a buffer of dynamicbox + * @since_tizen 2.3 + * @param[in] handle buffer handle + * @privlevel public + * @privilege %http://tizen.org/privilege/core/dynamicbox + * @return int status + * @retval #DBOX_STATUS_ERROR_INVALID_PARAMTER Invalid argument + * @retval #DBOX_STATUS_ERROR_NONE Successfully destroyed + * @see dynamicbox_create_buffer() + */ +extern int dynamicbox_destroy_buffer(dynamicbox_buffer_h handle); /** * @internal * @brief Gets the address of buffer for S/W rendering. * @details If you try to use this, after dynamicbox_create_hw_buffer(), you will get @c NULL. + * This API only be used for primary buffer. you cannot access the extra buffer * @since_tizen 2.3 * @param[in] handle Buffer handle * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return void* address of the render buffer * @retval @c NULL If it falis to get buffer address * @retval address If it succeed to get the buffer address @@ -520,7 +558,7 @@ extern void *dynamicbox_ref_buffer(dynamicbox_buffer_h handle); * @since_tizen 2.3 * @param[in] buffer Address of render buffer * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return int type * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid handle * @retval #DBOX_STATUS_ERROR_NONE Successfully unreference @@ -533,10 +571,11 @@ extern int dynamicbox_unref_buffer(void *buffer); * @internal * @brief Synchronizes the updated buffer. * @details This is only needed for non-H/W accelerated buffer. + * This API is only supported for primary buffer (#c DBOX_PRIMARY_BUFFER) * @since_tizen 2.3 * @param[in] handle Buffer handle * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return int type * @retval #DBOX_STATUS_ERROR_NONE Successfully sync'd * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument @@ -547,10 +586,11 @@ extern int dynamicbox_sync_buffer(dynamicbox_buffer_h handle); /** * @internal * @brief Requests to schedule the update operation to a provider. + * Your DBox will get the update request, if the @a id is specified, specific box only will get it. * @since_tizen 2.3 * @param[in] id Instance Id which is passed to you via the first parameter of every dynamicbox_XXXX interface functions * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return If succes returns 0 or return less than 0 * @retval #DBOX_STATUS_ERROR_NONE Successfully triggered * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument @@ -562,6 +602,7 @@ extern int dynamicbox_request_update(const char *id); /** * @internal * @brief Checks whether the dynamicbox supports H/W acceleration or not. + * This API is only supported for primary buffer (#c DBOX_PRIMARY_BUFFER) * @since_tizen 2.3 * @param[in] handle Buffer handle * @return int type @@ -574,10 +615,11 @@ extern int dynamicbox_support_hw_buffer(dynamicbox_buffer_h handle); /** * @internal * @brief Creates the H/W accelerated buffer. + * This API is only supported for primary buffer (#c DBOX_PRIMARY_BUFFER) * @since_tizen 2.3 * @param[in] handle Buffer handle * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return int type * @retval #DBOX_STATUS_ERROR_ALREADY H/W buffer is already created * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument @@ -591,10 +633,11 @@ extern int dynamicbox_create_hw_buffer(dynamicbox_buffer_h handle); /** * @internal * @brief Destroys the H/W accelerated buffer. + * This API is only supported for primary buffer (#c DBOX_PRIMARY_BUFFER) * @since_tizen 2.3 * @param[in] handle Buffer handle * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return int type * @retval #DBOX_STATUS_ERROR_NONE Successfully destroyed * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument @@ -606,10 +649,11 @@ extern int dynamicbox_destroy_hw_buffer(dynamicbox_buffer_h handle); /** * @internal * @brief Gets the address of the accelerated H/W buffer. + * This API is only supported for primary buffer (#c DBOX_PRIMARY_BUFFER) * @since_tizen 2.3 * @param[in] handle Buffer handle * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return void* type * @retval @c NULL Failed to get H/W accelerated buffer address * @retval addr H/W accelerated buffer address @@ -620,12 +664,13 @@ extern void *dynamicbox_buffer_hw_buffer(dynamicbox_buffer_h handle); /** * @internal * @brief Get the stride information from the buffer info + * This API is only supported for primary buffer (#c DBOX_PRIMARY_BUFFER) * @since_tizen 2.3 * @param[in] handle Buffer handle * @return int stride size * @retval positive_value length of stride - * @return DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid parameter - * @return DBOX_STATUS_ERROR_FAULT Unrecoverable error + * @return #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid parameter + * @return #DBOX_STATUS_ERROR_FAULT Unrecoverable error * @see dynamicbox_create_hw_buffer() */ extern int dynamicbox_buffer_stride(dynamicbox_buffer_h handle); @@ -637,7 +682,7 @@ extern int dynamicbox_buffer_stride(dynamicbox_buffer_h handle); * @since_tizen 2.3 * @param[in] handle Buffer handle * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return int type * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid handle * @retval #DBOX_STATUS_ERROR_NONE Successfully done @@ -653,7 +698,7 @@ extern int dynamicbox_buffer_pre_render(dynamicbox_buffer_h handle); * @since_tizen 2.3 * @param[in] handle Buffer handle * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return If succes returns 0 or return less than 0 * @retval #DBOX_STATUS_ERROR_NONE If succeed * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument @@ -670,16 +715,16 @@ extern int dynamicbox_buffer_post_render(dynamicbox_buffer_h handle); * @since_tizen 2.3 * @param[in] dboxid Dynamic Box Package Id * @param[in] id Instance Id which is passed to you via the first parameter of every dynamicbox_XXXX interface functions - * @param[in] reason DBOX_STATUS_ERROR_NONE(0) + * @param[in] reason #DBOX_STATUS_ERROR_NONE(0) * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return int type * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid parameters * @retval #DBOX_STATUS_ERROR_OUT_OF_MEMORY Out of memory * @retval #DBOX_STATUS_ERROR_FAULT Failed to send a request * @retval #DBOX_STATUS_ERROR_NONE Successfully requested */ -extern int dynamicbox_request_close_gbar(const char *dboxid, const char *id, int reason); +extern int dynamicbox_request_close_glance_bar(const char *dboxid, const char *id, int reason); /** * @internal @@ -692,7 +737,7 @@ extern int dynamicbox_request_close_gbar(const char *dboxid, const char *id, int * @param[in] dboxid Dynamic Box Package Id * @param[in] id Instance Id which is passed to you via the first parameter of every dynamicbox_XXXX interface functions * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return int type * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid parameters * @retval #DBOX_STATUS_ERROR_OUT_OF_MEMORY Out of memory @@ -713,7 +758,7 @@ extern int dynamicbox_freeze_scroller(const char *dboxid, const char *id); * @param[in] dboxid Dynamic Box Package Id * @param[in] id Instance Id which is passed to you via the first parameter of every dynamicbox_XXXX interface functions * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return int type * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid parameters * @retval #DBOX_STATUS_ERROR_OUT_OF_MEMORY Out of memory @@ -735,10 +780,10 @@ extern int dynamicbox_thaw_scroller(const char *dboxid, const char *id); * @param[in] id * @param[in] size_type * @privlevel public - * @privilege %http://tizen.org/privilege/core/dynamicbox.provider + * @privilege %http://tizen.org/privilege/core/dynamicbox * @return void* window - * @retval #NULL failed to create a snapshot window - * @retval elm_win window object + * @retval @c NULL failed to create a snapshot window + * @retval Object window object (ex, elementary window) * @see dynamicbox_snapshot_window_flush() */ extern void *dynamicbox_snapshot_window_add(const char *id, int size_type); @@ -746,7 +791,6 @@ extern void *dynamicbox_snapshot_window_add(const char *id, int size_type); /** * @internal * @brief Flush to a file for snapshot window - * @details N/A * @since_tizen 2.3 * @param[in] snapshot_win Snapshot window * @param[in] timeout After this, the image file will be created @@ -761,6 +805,17 @@ extern void *dynamicbox_snapshot_window_add(const char *id, int size_type); extern int dynamicbox_snapshot_window_flush(void *snapshot_win, double timeout, dynamicbox_flush_cb flush_cb, void *data); /** + * @internal + * @brief Sending the updated event to the viewer + * @since_tizen 2.3 + * @param[in] handle Dynamicbox Buffer Handle + * @param[in] idx Index of a buffer + * @return int status + * @retval #DBOX_STATUS_ERROR_NONE Successfully sent + */ +extern int dynamicbox_send_updated_by_idx(dynamicbox_buffer_h handle, int idx); + +/** * @} */ diff --git a/src/dlist.c b/src/dlist.c index b545904..44178c5 100644 --- a/src/dlist.c +++ b/src/dlist.c @@ -21,140 +21,140 @@ #include "dlist.h" struct dlist { - struct dlist *next; - struct dlist *prev; - void *data; + struct dlist *next; + struct dlist *prev; + void *data; }; struct dlist *dlist_append(struct dlist *list, void *data) { - struct dlist *item; + struct dlist *item; - item = malloc(sizeof(*item)); - if (!item) { - return NULL; - } + item = malloc(sizeof(*item)); + if (!item) { + return NULL; + } - item->next = NULL; - item->data = data; + item->next = NULL; + item->data = data; - if (!list) { - item->prev = item; + if (!list) { + item->prev = item; - list = item; - } else { - item->prev = list->prev; - item->prev->next = item; + list = item; + } else { + item->prev = list->prev; + item->prev->next = item; - list->prev = item; - } + list->prev = item; + } - assert(!list->prev->next && "item NEXT"); + assert(!list->prev->next && "item NEXT"); - return list; + return list; } struct dlist *dlist_prepend(struct dlist *list, void *data) { - struct dlist *item; - - item = malloc(sizeof(*item)); - if (!item) { - return NULL; - } - - if (!list) { - item->prev = item; - item->next = NULL; - } else { - item->prev = list->prev; - list->prev = item; - item->next = list; - } - - return item; + struct dlist *item; + + item = malloc(sizeof(*item)); + if (!item) { + return NULL; + } + + if (!list) { + item->prev = item; + item->next = NULL; + } else { + item->prev = list->prev; + list->prev = item; + item->next = list; + } + + return item; } struct dlist *dlist_remove(struct dlist *list, struct dlist *l) { - if (!list || !l) { - return NULL; - } - - if (l == list) { - l->prev = list->prev; - list = l->next; - } else { - l->prev->next = l->next; - } - - if (l->next) { - l->next->prev = l->prev; - } - - free(l); - return list; + if (!list || !l) { + return NULL; + } + + if (l == list) { + l->prev = list->prev; + list = l->next; + } else { + l->prev->next = l->next; + } + + if (l->next) { + l->next->prev = l->prev; + } + + free(l); + return list; } struct dlist *dlist_find_data(struct dlist *list, void *data) { - struct dlist *l; - void *_data; + struct dlist *l; + void *_data; - dlist_foreach(list, l, _data) { - if (data == _data) { - return l; - } - } + dlist_foreach(list, l, _data) { + if (data == _data) { + return l; + } + } - return NULL; + return NULL; } void *dlist_data(struct dlist *l) { - return l ? l->data : NULL; + return l ? l->data : NULL; } struct dlist *dlist_next(struct dlist *l) { - return l ? l->next : NULL; + return l ? l->next : NULL; } struct dlist *dlist_prev(struct dlist *l) { - return l ? l->prev : NULL; + return l ? l->prev : NULL; } int dlist_count(struct dlist *l) { - register int i; - struct dlist *n; - void *data; + register int i; + struct dlist *n; + void *data; - i = 0; - dlist_foreach(l, n, data) { - i++; - } + i = 0; + dlist_foreach(l, n, data) { + i++; + } - return i; + return i; } struct dlist *dlist_nth(struct dlist *l, int nth) { - register int i; - struct dlist *n; - void *data; + register int i; + struct dlist *n; + void *data; - i = 0; - dlist_foreach(l, n, data) { - if (i == nth) { - return l; - } + i = 0; + dlist_foreach(l, n, data) { + if (i == nth) { + return l; + } - i++; - } + i++; + } - return NULL; + return NULL; } /* End of a file */ diff --git a/src/dynamicbox.c b/src/dynamicbox.c index c0390ed..1c2002d 100644 --- a/src/dynamicbox.c +++ b/src/dynamicbox.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include "debug.h" @@ -37,236 +39,212 @@ #define PUBLIC __attribute__((visibility("default"))) -#define FILE_SCHEMA "file://" +#define FILE_SCHEMA "file://" struct block { - unsigned int idx; - - char *type; - char *part; - char *data; - char *option; - char *id; - char *file; - char *target_id; + unsigned int idx; + + char *type; + char *part; + char *data; + char *option; + char *id; + char *file; + char *target_id; }; struct dynamicbox_desc { - FILE *fp; - int for_pd; + FILE *fp; + int for_pd; - unsigned int last_idx; + unsigned int last_idx; - struct dlist *block_list; + struct dlist *block_list; }; struct dynamicbox_buffer_data { - int is_gbar; - int accelerated; + int is_gbar; + int accelerated; - /* for Buffer event wrapper */ - int (*handler)(dynamicbox_buffer_h , dynamicbox_buffer_event_data_t, void *); - void *cbdata; + /* for Buffer event wrapper */ + int (*handler)(dynamicbox_buffer_h , dynamicbox_buffer_event_data_t, void *); + void *cbdata; - char *content; - char *title; - char *icon; - char *name; + char *content; + char *title; + char *icon; + char *name; }; /** * @brief These functions are defined in the data-provider-slave */ static struct info { - const char *(*find_pkgname)(const char *filename); - int (*request_update_by_id)(const char *uri); - int (*trigger_update_monitor)(const char *id, int is_gbar); - int (*update_extra_info)(const char *id, const char *content, const char *title, const char *icon, const char *name); - - int is_slave; - union _updated { - struct _slave { - int (*dbox)(const char *pkgname, const char *id, int x, int y, int w, int h); - int (*gbar)(const char *pkgname, const char *id, const char *descfile, int x, int y, int w, int h); - } slave; - - struct _app { - int (*dbox)(const char *id, int x, int y, int w, int h); - int (*gbar)(const char *id, int x, int y, int w, int h); - } app; - } updated; + const char *(*find_pkgname)(const char *filename); + int (*request_update_by_id)(const char *uri); + int (*trigger_update_monitor)(const char *id, int is_gbar); + int (*update_extra_info)(const char *id, const char *content, const char *title, const char *icon, const char *name); + + enum load_type { + LOAD_TYPE_UNKNOWN = -1, + LOAD_TYPE_SLAVE = 0, + LOAD_TYPE_APP = 1 + } type; + + union _updated { + struct _slave { + int (*send)(const char *pkgname, const char *id, int idx, int x, int y, int w, int h, int gbar, const char *descfile); + } slave; + + struct _app { + int (*send)(const char *id, int idx, int x, int y, int w, int h, int gbar); + } app; + } updated; } s_info = { - .find_pkgname = NULL, - .request_update_by_id = NULL, - .trigger_update_monitor = NULL, - .update_extra_info = NULL, - .is_slave = -1, /* Not initialized */ + .find_pkgname = NULL, + .request_update_by_id = NULL, + .trigger_update_monitor = NULL, + .update_extra_info = NULL, + .type = LOAD_TYPE_UNKNOWN, /* Not initialized */ }; -static int send_dbox_updated(const char *pkgname, const char *id, int x, int y, int w, int h) +#define FUNC_PREFIX "dynamicbox_" +#define FUNC_DYNAMICBOX_SEND_UPDATED FUNC_PREFIX "send_updated" +#define FUNC_DYNAMICBOX_PROVIDER_APP_UPDATED FUNC_PREFIX "provider_app_updated" +#define FUNC_DYNAMICBOX_FIND_PKGNAME FUNC_PREFIX "find_pkgname" +#define FUNC_DYNAMICBOX_REQUEST_UPDATE_BY_ID FUNC_PREFIX "request_update_by_id" +#define FUNC_DYNAMICBOX_TRIGGER_UPDATE_MONITOR FUNC_PREFIX "trigger_update_monitor" +#define FUNC_DYNAMICBOX_UPDATE_EXTRA_INFO FUNC_PREFIX "update_extra_info" + +static inline void load_update_function(void) { - int ret = DBOX_STATUS_ERROR_INVALID_PARAMETER; - - if (s_info.is_slave < 0) { - /* Must to be checked the slave function first. */ - s_info.updated.slave.dbox = dlsym(RTLD_DEFAULT, "dynamicbox_send_updated"); - s_info.updated.slave.gbar = dlsym(RTLD_DEFAULT, "dynamicbox_send_desc_updated"); - if (s_info.updated.slave.dbox && s_info.updated.slave.gbar) { - s_info.is_slave = 1; - DbgPrint("Slave detected\n"); - } else { - s_info.updated.app.dbox = dlsym(RTLD_DEFAULT, "dynamicbox_provider_app_dbox_updated"); - s_info.updated.app.gbar = dlsym(RTLD_DEFAULT, "dynamicbox_provider_app_gbar_updated"); - if (s_info.updated.app.dbox && s_info.updated.app.gbar) { - s_info.is_slave = 0; - DbgPrint("App detected\n"); - } - } - } - - if (s_info.is_slave == 0) { - ret = s_info.updated.app.dbox(id, x, y, w, h); - } else if (s_info.is_slave == 1) { - ret = s_info.updated.slave.dbox(pkgname, id, x, y, w, h); - } else { - dynamicbox_damage_region_t region = { - .x = x, - .y = y, - .w = w, - .h = h, - }; - ret = dynamicbox_provider_send_updated(pkgname, id, ®ion); - } - - return ret; + /* Must to be checked the slave function first. */ + s_info.updated.slave.send = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_SEND_UPDATED); + if (s_info.updated.slave.send) { + s_info.type = LOAD_TYPE_SLAVE; + DbgPrint("Slave detected\n"); + } else { + s_info.updated.app.send = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_PROVIDER_APP_UPDATED); + if (s_info.updated.app.send) { + s_info.type = LOAD_TYPE_APP; + DbgPrint("App detected\n"); + } + } } -static int send_gbar_updated(const char *pkgname, const char *id, const char *descfile, int x, int y, int w, int h) +static int send_updated(const char *pkgname, const char *id, int idx, int x, int y, int w, int h, int gbar, const char *descfile) { - int ret = DBOX_STATUS_ERROR_INVALID_PARAMETER; - - if (s_info.is_slave < 0) { - /* Must to be checked the slave function first. */ - s_info.updated.slave.dbox = dlsym(RTLD_DEFAULT, "dynamicbox_send_updated"); - s_info.updated.slave.gbar = dlsym(RTLD_DEFAULT, "dynamicbox_send_desc_updated"); - if (s_info.updated.slave.dbox && s_info.updated.slave.gbar) { - s_info.is_slave = 1; - DbgPrint("Slave detected\n"); - } else { - s_info.updated.app.dbox = dlsym(RTLD_DEFAULT, "dynamicbox_provider_app_dbox_updated"); - s_info.updated.app.gbar = dlsym(RTLD_DEFAULT, "dynamicbox_provider_app_gbar_updated"); - if (s_info.updated.app.dbox && s_info.updated.app.gbar) { - s_info.is_slave = 0; - DbgPrint("App detected\n"); - } - } - } - - if (s_info.is_slave == 0) { - ret = s_info.updated.app.gbar(id, x, y, w, h); - } else if (s_info.is_slave == 1) { - ret = s_info.updated.slave.gbar(pkgname, id, descfile, x, y, w, h); - } else { - dynamicbox_damage_region_t region = { - .x = x, - .y = y, - .w = w, - .h = h, - }; - ret = dynamicbox_provider_send_desc_updated(pkgname, id, descfile, ®ion); - } - - return ret; + int ret = DBOX_STATUS_ERROR_INVALID_PARAMETER; + + if (s_info.type == LOAD_TYPE_UNKNOWN) { + load_update_function(); + } + + if (s_info.type == LOAD_TYPE_APP) { + ret = s_info.updated.app.send(id, idx, x, y, w, h, gbar); + } else if (s_info.type == LOAD_TYPE_SLAVE) { + ret = s_info.updated.slave.send(pkgname, id, idx, x, y, w, h, gbar, descfile); + } else { + dynamicbox_damage_region_t region = { + .x = x, + .y = y, + .w = w, + .h = h, + }; + ret = dynamicbox_provider_send_updated(pkgname, id, idx, ®ion, gbar, descfile); + } + + return ret; } static char *id_to_uri(const char *id) { - char *uri; - int uri_len; + char *uri; + int uri_len; - uri_len = strlen(id) + strlen(FILE_SCHEMA) + 1; + uri_len = strlen(id) + strlen(FILE_SCHEMA) + 1; - uri = malloc(uri_len); - if (!uri) { - return NULL; - } + uri = malloc(uri_len); + if (!uri) { + return NULL; + } - snprintf(uri, uri_len, FILE_SCHEMA "%s", id); - return uri; + snprintf(uri, uri_len, FILE_SCHEMA "%s", id); + return uri; } static inline int event_handler_wrapper(dynamicbox_buffer_h buffer, dynamicbox_buffer_event_data_t event_info, void *data) { - const char *pkgname; - const char *id; - struct dynamicbox_buffer_data *cbdata = data; - int ret; - - pkgname = dynamicbox_provider_buffer_pkgname(buffer); - if (!pkgname) { - ErrPrint("pkgname is not valid\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - id = dynamicbox_provider_buffer_id(buffer); - if (!id) { - ErrPrint("id is not valid[%s]\n", pkgname); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - if (cbdata->handler) { - ret = cbdata->handler(buffer, event_info, cbdata->cbdata); - } else { - ret = DBOX_STATUS_ERROR_FAULT; - } - - switch (event_info->type) { - case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT: - case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT: - case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV: - case DBOX_BUFFER_EVENT_ACCESS_ACTIVATE: - case DBOX_BUFFER_EVENT_ACCESS_ACTION_UP: - case DBOX_BUFFER_EVENT_ACCESS_ACTION_DOWN: - case DBOX_BUFFER_EVENT_ACCESS_SCROLL_UP: - case DBOX_BUFFER_EVENT_ACCESS_SCROLL_MOVE: - case DBOX_BUFFER_EVENT_ACCESS_SCROLL_DOWN: - case DBOX_BUFFER_EVENT_ACCESS_UNHIGHLIGHT: - case DBOX_BUFFER_EVENT_ACCESS_VALUE_CHANGE: - case DBOX_BUFFER_EVENT_ACCESS_MOUSE: - case DBOX_BUFFER_EVENT_ACCESS_BACK: - case DBOX_BUFFER_EVENT_ACCESS_OVER: - case DBOX_BUFFER_EVENT_ACCESS_READ: - case DBOX_BUFFER_EVENT_ACCESS_ENABLE: - case DBOX_BUFFER_EVENT_ACCESS_DISABLE: - DbgPrint("Accessibility event: %d\n", event_info->type); - if (ret < 0) { - (void)dynamicbox_provider_send_access_status(pkgname, id, DBOX_ACCESS_STATUS_ERROR); - } else { - (void)dynamicbox_provider_send_access_status(pkgname, id, ret); - } - break; - case DBOX_BUFFER_EVENT_KEY_UP: - case DBOX_BUFFER_EVENT_KEY_DOWN: - case DBOX_BUFFER_EVENT_KEY_FOCUS_IN: - case DBOX_BUFFER_EVENT_KEY_FOCUS_OUT: - DbgPrint("Key event: %d\n", event_info->type); - if (ret < 0) { - (void)dynamicbox_provider_send_key_status(pkgname, id, DBOX_KEY_STATUS_ERROR); - } else { - (void)dynamicbox_provider_send_key_status(pkgname, id, ret); - } - break; - default: - break; - } - - return ret; + const char *pkgname; + const char *id; + struct dynamicbox_buffer_data *cbdata = data; + int ret; + + pkgname = dynamicbox_provider_buffer_pkgname(buffer); + if (!pkgname) { + ErrPrint("pkgname is not valid\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + id = dynamicbox_provider_buffer_id(buffer); + if (!id) { + ErrPrint("id is not valid[%s]\n", pkgname); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + if (cbdata->handler) { + ret = cbdata->handler(buffer, event_info, cbdata->cbdata); + } else { + ret = DBOX_STATUS_ERROR_FAULT; + } + + switch (event_info->type) { + case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT: + case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT: + case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV: + case DBOX_BUFFER_EVENT_ACCESS_ACTIVATE: + case DBOX_BUFFER_EVENT_ACCESS_ACTION_UP: + case DBOX_BUFFER_EVENT_ACCESS_ACTION_DOWN: + case DBOX_BUFFER_EVENT_ACCESS_SCROLL_UP: + case DBOX_BUFFER_EVENT_ACCESS_SCROLL_MOVE: + case DBOX_BUFFER_EVENT_ACCESS_SCROLL_DOWN: + case DBOX_BUFFER_EVENT_ACCESS_UNHIGHLIGHT: + case DBOX_BUFFER_EVENT_ACCESS_VALUE_CHANGE: + case DBOX_BUFFER_EVENT_ACCESS_MOUSE: + case DBOX_BUFFER_EVENT_ACCESS_BACK: + case DBOX_BUFFER_EVENT_ACCESS_OVER: + case DBOX_BUFFER_EVENT_ACCESS_READ: + case DBOX_BUFFER_EVENT_ACCESS_ENABLE: + case DBOX_BUFFER_EVENT_ACCESS_DISABLE: + DbgPrint("Accessibility event: %d\n", event_info->type); + if (ret < 0) { + (void)dynamicbox_provider_send_access_status(pkgname, id, DBOX_ACCESS_STATUS_ERROR); + } else { + (void)dynamicbox_provider_send_access_status(pkgname, id, ret); + } + break; + case DBOX_BUFFER_EVENT_KEY_UP: + case DBOX_BUFFER_EVENT_KEY_DOWN: + case DBOX_BUFFER_EVENT_KEY_FOCUS_IN: + case DBOX_BUFFER_EVENT_KEY_FOCUS_OUT: + DbgPrint("Key event: %d\n", event_info->type); + if (ret < 0) { + (void)dynamicbox_provider_send_key_status(pkgname, id, DBOX_KEY_STATUS_ERROR); + } else { + (void)dynamicbox_provider_send_key_status(pkgname, id, ret); + } + break; + default: + break; + } + + return ret; } static inline int default_event_handler(dynamicbox_buffer_h buffer, dynamicbox_buffer_event_data_t event_info, void *data) { - /* NOP */ - return 0; + /* NOP */ + return 0; } PUBLIC const int DBOX_DONE = 0x00; @@ -290,235 +268,235 @@ PUBLIC const int DBOX_SYS_EVENT_DELETED = 0x0800; PUBLIC struct dynamicbox_desc *dynamicbox_desc_open(const char *filename, int for_pd) { - struct dynamicbox_desc *handle; - char *new_fname; - - handle = calloc(1, sizeof(*handle)); - if (!handle) { - ErrPrint("Error: %s\n", strerror(errno)); - return NULL; - } - - if (for_pd) { - int len; - len = strlen(filename) + strlen(".desc") + 1; - new_fname = malloc(len); - if (!new_fname) { - ErrPrint("Error: %s\n", strerror(errno)); - free(handle); - return NULL; - } - snprintf(new_fname, len, "%s.desc", filename); - } else { - new_fname = strdup(filename); - if (!new_fname) { - ErrPrint("Error: %s\n", strerror(errno)); - free(handle); - return NULL; - } - } - - DbgPrint("Open a file %s with merge mode %s\n", - new_fname, - access(new_fname, F_OK) == 0 ? "enabled" : "disabled"); - - handle->fp = fopen(new_fname, "at"); - free(new_fname); - if (!handle->fp) { - ErrPrint("Failed to open a file: %s\n", strerror(errno)); - free(handle); - return NULL; - } - - return handle; + struct dynamicbox_desc *handle; + char *new_fname; + + handle = calloc(1, sizeof(*handle)); + if (!handle) { + ErrPrint("Error: %s\n", strerror(errno)); + return NULL; + } + + if (for_pd) { + int len; + len = strlen(filename) + strlen(".desc") + 1; + new_fname = malloc(len); + if (!new_fname) { + ErrPrint("Error: %s\n", strerror(errno)); + free(handle); + return NULL; + } + snprintf(new_fname, len, "%s.desc", filename); + } else { + new_fname = strdup(filename); + if (!new_fname) { + ErrPrint("Error: %s\n", strerror(errno)); + free(handle); + return NULL; + } + } + + DbgPrint("Open a file %s with merge mode %s\n", + new_fname, + access(new_fname, F_OK) == 0 ? "enabled" : "disabled"); + + handle->fp = fopen(new_fname, "at"); + free(new_fname); + if (!handle->fp) { + ErrPrint("Failed to open a file: %s\n", strerror(errno)); + free(handle); + return NULL; + } + + return handle; } PUBLIC int dynamicbox_desc_close(struct dynamicbox_desc *handle) { - struct dlist *l; - struct dlist *n; - struct block *block; - - if (!handle) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - dlist_foreach_safe(handle->block_list, l, n, block) { - handle->block_list = dlist_remove(handle->block_list, l); - - fprintf(handle->fp, "{\n"); - if (block->type) { - fprintf(handle->fp, "type=%s\n", block->type); - } - - if (block->part) { - fprintf(handle->fp, "part=%s\n", block->part); - } - - if (block->data) { - fprintf(handle->fp, "data=%s\n", block->data); - } - - if (block->option) { - fprintf(handle->fp, "option=%s\n", block->option); - } - - if (block->id) { - fprintf(handle->fp, "id=%s\n", block->id); - } - - if (block->target_id) { - fprintf(handle->fp, "target=%s\n", block->target_id); - } - fprintf(handle->fp, "}\n"); - - free(block->type); - free(block->part); - free(block->data); - free(block->option); - free(block->id); - free(block->target_id); - free(block); - } - - if (fclose(handle->fp) != 0) { - ErrPrint("fclose: %s\n", strerror(errno)); - } - free(handle); - return DBOX_STATUS_ERROR_NONE; + struct dlist *l; + struct dlist *n; + struct block *block; + + if (!handle) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + dlist_foreach_safe(handle->block_list, l, n, block) { + handle->block_list = dlist_remove(handle->block_list, l); + + fprintf(handle->fp, "{\n"); + if (block->type) { + fprintf(handle->fp, "type=%s\n", block->type); + } + + if (block->part) { + fprintf(handle->fp, "part=%s\n", block->part); + } + + if (block->data) { + fprintf(handle->fp, "data=%s\n", block->data); + } + + if (block->option) { + fprintf(handle->fp, "option=%s\n", block->option); + } + + if (block->id) { + fprintf(handle->fp, "id=%s\n", block->id); + } + + if (block->target_id) { + fprintf(handle->fp, "target=%s\n", block->target_id); + } + fprintf(handle->fp, "}\n"); + + free(block->type); + free(block->part); + free(block->data); + free(block->option); + free(block->id); + free(block->target_id); + free(block); + } + + if (fclose(handle->fp) != 0) { + ErrPrint("fclose: %s\n", strerror(errno)); + } + free(handle); + return DBOX_STATUS_ERROR_NONE; } PUBLIC int dynamicbox_desc_set_category(struct dynamicbox_desc *handle, const char *id, const char *category) { - struct block *block; - - if (!handle || !category) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - block = calloc(1, sizeof(*block)); - if (!block) { - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - block->type = strdup(DBOX_DESC_TYPE_INFO); - if (!block->type) { - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - block->part = strdup("category"); - if (!block->part) { - free(block->type); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - block->data = strdup(category); - if (!block->data) { - free(block->type); - free(block->part); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - if (id) { - block->id = strdup(id); - if (!block->id) { - free(block->data); - free(block->type); - free(block->part); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - } - - block->idx = handle->last_idx++; - handle->block_list = dlist_append(handle->block_list, block); - return block->idx; + struct block *block; + + if (!handle || !category) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + block = calloc(1, sizeof(*block)); + if (!block) { + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + block->type = strdup(DBOX_DESC_TYPE_INFO); + if (!block->type) { + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + block->part = strdup("category"); + if (!block->part) { + free(block->type); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + block->data = strdup(category); + if (!block->data) { + free(block->type); + free(block->part); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + if (id) { + block->id = strdup(id); + if (!block->id) { + free(block->data); + free(block->type); + free(block->part); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + } + + block->idx = handle->last_idx++; + handle->block_list = dlist_append(handle->block_list, block); + return block->idx; } PUBLIC int dynamicbox_desc_set_size(struct dynamicbox_desc *handle, const char *id, int w, int h) { - struct block *block; - char buffer[BUFSIZ]; - - if (!handle) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - block = calloc(1, sizeof(*block)); - if (!block) { - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - block->type = strdup(DBOX_DESC_TYPE_INFO); - if (!block->type) { - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - block->part = strdup("size"); - if (!block->part) { - free(block->type); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - if (id) { - block->id = strdup(id); - if (!block->id) { - free(block->part); - free(block->type); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - } - - snprintf(buffer, sizeof(buffer), "%dx%d", w, h); - block->data = strdup(buffer); - if (!block->data) { - free(block->part); - free(block->type); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - block->idx = handle->last_idx++; - handle->block_list = dlist_append(handle->block_list, block); - return block->idx; + struct block *block; + char buffer[BUFSIZ]; + + if (!handle) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + block = calloc(1, sizeof(*block)); + if (!block) { + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + block->type = strdup(DBOX_DESC_TYPE_INFO); + if (!block->type) { + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + block->part = strdup("size"); + if (!block->part) { + free(block->type); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + if (id) { + block->id = strdup(id); + if (!block->id) { + free(block->part); + free(block->type); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + } + + snprintf(buffer, sizeof(buffer), "%dx%d", w, h); + block->data = strdup(buffer); + if (!block->data) { + free(block->part); + free(block->type); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + block->idx = handle->last_idx++; + handle->block_list = dlist_append(handle->block_list, block); + return block->idx; } PUBLIC int dynamicbox_desc_set_id(struct dynamicbox_desc *handle, int idx, const char *id) { - struct dlist *l; - struct block *block; - - dlist_foreach(handle->block_list, l, block) { - if (block->idx == idx) { - if (strcasecmp(block->type, DBOX_DESC_TYPE_SCRIPT)) { - ErrPrint("Invalid block is used\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - free(block->target_id); - block->target_id = NULL; - - if (!id || !strlen(id)) { - return DBOX_STATUS_ERROR_NONE; - } - - block->target_id = strdup(id); - if (!block->target_id) { - ErrPrint("Heap: %s\n", strerror(errno)); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - return DBOX_STATUS_ERROR_NONE; - } - } - - return DBOX_STATUS_ERROR_NOT_EXIST; + struct dlist *l; + struct block *block; + + dlist_foreach(handle->block_list, l, block) { + if (block->idx == idx) { + if (strcasecmp(block->type, DBOX_DESC_TYPE_SCRIPT)) { + ErrPrint("Invalid block is used\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + free(block->target_id); + block->target_id = NULL; + + if (!id || !strlen(id)) { + return DBOX_STATUS_ERROR_NONE; + } + + block->target_id = strdup(id); + if (!block->target_id) { + ErrPrint("Heap: %s\n", strerror(errno)); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + return DBOX_STATUS_ERROR_NONE; + } + } + + return DBOX_STATUS_ERROR_NOT_EXIST; } /*! @@ -526,690 +504,771 @@ PUBLIC int dynamicbox_desc_set_id(struct dynamicbox_desc *handle, int idx, const */ PUBLIC int dynamicbox_desc_add_block(struct dynamicbox_desc *handle, const char *id, const char *type, const char *part, const char *data, const char *option) { - struct block *block; - - if (!handle || !type) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - if (!part) { - part = ""; - } - - if (!data) { - data = ""; - } - - block = calloc(1, sizeof(*block)); - if (!block) { - ErrPrint("Heap: %s\n", strerror(errno)); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - block->type = strdup(type); - if (!block->type) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - block->part = strdup(part); - if (!block->part) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->type); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - block->data = strdup(data); - if (!block->data) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->type); - free(block->part); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - if (option) { - block->option = strdup(option); - if (!block->option) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->data); - free(block->type); - free(block->part); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - } - - if (id) { - block->id = strdup(id); - if (!block->id) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(block->option); - free(block->data); - free(block->type); - free(block->part); - free(block); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - } - - block->idx = handle->last_idx++; - handle->block_list = dlist_append(handle->block_list, block); - return block->idx; + struct block *block; + + if (!handle || !type) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + if (!part) { + part = ""; + } + + if (!data) { + data = ""; + } + + block = calloc(1, sizeof(*block)); + if (!block) { + ErrPrint("Heap: %s\n", strerror(errno)); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + block->type = strdup(type); + if (!block->type) { + ErrPrint("Heap: %s\n", strerror(errno)); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + block->part = strdup(part); + if (!block->part) { + ErrPrint("Heap: %s\n", strerror(errno)); + free(block->type); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + block->data = strdup(data); + if (!block->data) { + ErrPrint("Heap: %s\n", strerror(errno)); + free(block->type); + free(block->part); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + if (option) { + block->option = strdup(option); + if (!block->option) { + ErrPrint("Heap: %s\n", strerror(errno)); + free(block->data); + free(block->type); + free(block->part); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + } + + if (id) { + block->id = strdup(id); + if (!block->id) { + ErrPrint("Heap: %s\n", strerror(errno)); + free(block->option); + free(block->data); + free(block->type); + free(block->part); + free(block); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + } + + block->idx = handle->last_idx++; + handle->block_list = dlist_append(handle->block_list, block); + return block->idx; } PUBLIC int dynamicbox_desc_del_block(struct dynamicbox_desc *handle, int idx) { - struct dlist *l; - struct block *block; - - if (!handle || idx < 0) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - dlist_foreach(handle->block_list, l, block) { - if (block->idx == idx) { - handle->block_list = dlist_remove(handle->block_list, l); - free(block->type); - free(block->part); - free(block->data); - free(block->option); - free(block->id); - free(block->target_id); - free(block); - return DBOX_STATUS_ERROR_NONE; - } - } - - return DBOX_STATUS_ERROR_NOT_EXIST; + struct dlist *l; + struct block *block; + + if (!handle || idx < 0) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + dlist_foreach(handle->block_list, l, block) { + if (block->idx == idx) { + handle->block_list = dlist_remove(handle->block_list, l); + free(block->type); + free(block->part); + free(block->data); + free(block->option); + free(block->id); + free(block->target_id); + free(block); + return DBOX_STATUS_ERROR_NONE; + } + } + + return DBOX_STATUS_ERROR_NOT_EXIST; +} + +PUBLIC int dynamicbox_acquire_buffer(dynamicbox_buffer_h handle, int idx, int width, int height, int pixel_size) +{ + int ret; + + if (!handle || width <= 0 || height <= 0 || pixel_size <= 0 || idx > DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + if (idx >= 0) { + int _width = 0; + int _height = 0; + int _pixel_size = 0; + /* To validate the buffer */ + if (dynamicbox_provider_buffer_get_size(handle, &_width, &_height, &_pixel_size) < 0) { + ErrPrint("Failed to get buffer size\n"); + } + + if (_width != width || _height != height || pixel_size != _pixel_size) { + DbgPrint("Extra buffer's geometry is not matched with primary one\n"); + } + + ret = dynamicbox_provider_buffer_extra_acquire(handle, idx, width, height, pixel_size); + } else { + ret = dynamicbox_provider_buffer_acquire(handle, width, height, pixel_size); + } + + return ret; } -PUBLIC dynamicbox_buffer_h dynamicbox_acquire_buffer(const char *filename, int is_gbar, int width, int height, int pixels, int auto_align, int (*handler)(dynamicbox_buffer_h , dynamicbox_buffer_event_data_t, void *), void *data) +PUBLIC dynamicbox_buffer_h dynamicbox_create_buffer(const char *filename, int is_gbar, int auto_align, int (*handler)(dynamicbox_buffer_h , dynamicbox_buffer_event_data_t, void *), void *data) { - struct dynamicbox_buffer_data *user_data; - const char *pkgname; - dynamicbox_buffer_h handle; - char *uri; - - if (!filename || !width || !height) { - ErrPrint("Invalid argument: %p(%dx%d)\n", filename, width, height); - return NULL; - } - - user_data = calloc(1, sizeof(*user_data)); - if (!user_data) { - ErrPrint("Heap: %s\n", strerror(errno)); - return NULL; - } - - user_data->is_gbar = is_gbar; - user_data->handler = handler ? handler : default_event_handler; - user_data->cbdata = data; - - uri = id_to_uri(filename); - if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(user_data); - return NULL; - } - - if (!s_info.find_pkgname) { - s_info.find_pkgname = dlsym(RTLD_DEFAULT, "dynamicbox_find_pkgname"); - if (!s_info.find_pkgname) { - ErrPrint("Failed to find a \"dynamicbox_find_pkgname\"\n"); - free(user_data); - free(uri); - return NULL; - } - } - - pkgname = s_info.find_pkgname(uri); - if (!pkgname) { - ErrPrint("Invalid Request\n"); - free(user_data); - free(uri); - return NULL; - } - - handle = dynamicbox_provider_buffer_create((!!is_gbar) ? DBOX_TYPE_GBAR : DBOX_TYPE_DBOX, pkgname, uri, auto_align, event_handler_wrapper, user_data); - free(uri); - if (!handle) { - free(user_data); - return NULL; - } - - if (dynamicbox_provider_buffer_acquire(handle, width, height, pixels) < 0) { - dynamicbox_provider_buffer_destroy(handle); - free(user_data); - return NULL; - } - - (void)dynamicbox_provider_buffer_set_user_data(handle, user_data); - return handle; + struct dynamicbox_buffer_data *user_data; + const char *pkgname; + dynamicbox_buffer_h handle; + char *uri; + + if (!filename) { + ErrPrint("Invalid argument: %p(%dx%d)\n", filename); + return NULL; + } + + user_data = calloc(1, sizeof(*user_data)); + if (!user_data) { + ErrPrint("Heap: %s\n", strerror(errno)); + return NULL; + } + + user_data->is_gbar = is_gbar; + user_data->handler = handler ? handler : default_event_handler; + user_data->cbdata = data; + + uri = id_to_uri(filename); + if (!uri) { + ErrPrint("Heap: %s\n", strerror(errno)); + free(user_data); + return NULL; + } + + if (!s_info.find_pkgname) { + s_info.find_pkgname = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_FIND_PKGNAME); + if (!s_info.find_pkgname) { + ErrPrint("Failed to find a \"dynamicbox_find_pkgname\"\n"); + free(user_data); + free(uri); + return NULL; + } + } + + pkgname = s_info.find_pkgname(uri); + if (!pkgname) { + ErrPrint("Invalid Request\n"); + free(user_data); + free(uri); + return NULL; + } + + handle = dynamicbox_provider_buffer_create((!!is_gbar) ? DBOX_TYPE_GBAR : DBOX_TYPE_DBOX, pkgname, uri, auto_align, event_handler_wrapper, user_data); + free(uri); + if (!handle) { + free(user_data); + return NULL; + } + + (void)dynamicbox_provider_buffer_set_user_data(handle, user_data); + return handle; } PUBLIC int dynamicbox_request_update(const char *filename) { - char *uri; - int ret; - - if (!filename) { - ErrPrint("Invalid argument\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - uri = id_to_uri(filename); - if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - if (!s_info.request_update_by_id) { - s_info.request_update_by_id = dlsym(RTLD_DEFAULT, "dynamicbox_request_update_by_id"); - if (!s_info.request_update_by_id) { - ErrPrint("\"dynamicbox_request_update_by_id\" is not exists\n"); - free(uri); - return DBOX_STATUS_ERROR_FAULT; - } - } - ret = s_info.request_update_by_id(uri); - free(uri); - return ret; + char *uri; + int ret; + + if (!filename) { + ErrPrint("Invalid argument\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + uri = id_to_uri(filename); + if (!uri) { + ErrPrint("Heap: %s\n", strerror(errno)); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + if (!s_info.request_update_by_id) { + s_info.request_update_by_id = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_REQUEST_UPDATE_BY_ID); + if (!s_info.request_update_by_id) { + ErrPrint("\"dynamicbox_request_update_by_id\" is not exists\n"); + free(uri); + return DBOX_STATUS_ERROR_FAULT; + } + } + + ret = s_info.request_update_by_id(uri); + free(uri); + return ret; +} + +PUBLIC unsigned int dynamicbox_resource_id(dynamicbox_buffer_h handle, int idx) +{ + int ret; + + if (!handle || idx > DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + if (idx >= 0) { + ret = dynamicbox_provider_buffer_extra_resource_id(handle, idx); + } else { + ret = dynamicbox_provider_buffer_resource_id(handle); + } + + return ret; } -PUBLIC unsigned int dynamicbox_resource_id(dynamicbox_buffer_h handle) +PUBLIC int dynamicbox_release_buffer(dynamicbox_buffer_h handle, int idx) { - return dynamicbox_provider_buffer_resource_id(handle); + int ret; + + if (!handle || idx > DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + if (idx >= 0) { + ret = dynamicbox_provider_buffer_extra_release(handle, idx); + } else { + ret = dynamicbox_provider_buffer_release(handle); + } + + DbgPrint("Release buffer: %d (%d)\n", idx, ret); + return ret; } -PUBLIC int dynamicbox_release_buffer(dynamicbox_buffer_h handle) +PUBLIC int dynamicbox_destroy_buffer(dynamicbox_buffer_h handle) { - struct dynamicbox_buffer_data *user_data; - - if (!handle) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - user_data = dynamicbox_provider_buffer_user_data(handle); - if (user_data) { - free(user_data->content); - free(user_data->title); - free(user_data->icon); - free(user_data->name); - free(user_data); - dynamicbox_provider_buffer_set_user_data(handle, NULL); - } - - (void)dynamicbox_provider_buffer_release(handle); - (void)dynamicbox_provider_buffer_destroy(handle); - - DbgPrint("Release buffer\n"); - return 0; + struct dynamicbox_buffer_data *user_data; + + if (!handle) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + user_data = dynamicbox_provider_buffer_user_data(handle); + if (user_data) { + free(user_data->content); + free(user_data->title); + free(user_data->icon); + free(user_data->name); + free(user_data); + dynamicbox_provider_buffer_set_user_data(handle, NULL); + } + + DbgPrint("Destroy buffer\n"); + return dynamicbox_provider_buffer_destroy(handle); } PUBLIC void *dynamicbox_ref_buffer(dynamicbox_buffer_h handle) { - struct dynamicbox_buffer_data *user_data; - void *data; - int w, h, size; - int ret; - - if (!handle) { - return NULL; - } - - user_data = dynamicbox_provider_buffer_user_data(handle); - if (!user_data) { - return NULL; - } - - if (user_data->accelerated) { - DbgPrint("H/W accelerated buffer is allocated\n"); - return NULL; - } - - ret = dynamicbox_provider_buffer_get_size(handle, &w, &h, &size); - - data = dynamicbox_provider_buffer_ref(handle); - if (data && !ret && w > 0 && h > 0 && size > 0) { - memset(data, 0, w * h * size); - (void)dynamicbox_provider_buffer_sync(handle); - } - - DbgPrint("Ref buffer %ds%d(%d)\n", w, h, size); - return data; + struct dynamicbox_buffer_data *user_data; + void *data; + int w, h, size; + int ret; + + if (!handle) { + return NULL; + } + + user_data = dynamicbox_provider_buffer_user_data(handle); + if (!user_data) { + return NULL; + } + + if (user_data->accelerated) { + DbgPrint("H/W accelerated buffer is allocated\n"); + return NULL; + } + + ret = dynamicbox_provider_buffer_get_size(handle, &w, &h, &size); + + data = dynamicbox_provider_buffer_ref(handle); + if (data && !ret && w > 0 && h > 0 && size > 0) { + memset(data, 0, w * h * size); + (void)dynamicbox_provider_buffer_sync(handle); + } + + DbgPrint("Ref buffer %ds%d(%d)\n", w, h, size); + return data; } PUBLIC int dynamicbox_unref_buffer(void *buffer) { - if (!buffer) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } + if (!buffer) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } - DbgPrint("Unref buffer\n"); - return dynamicbox_provider_buffer_unref(buffer); + DbgPrint("Unref buffer\n"); + return dynamicbox_provider_buffer_unref(buffer); } PUBLIC int dynamicbox_sync_buffer(dynamicbox_buffer_h handle) { - struct dynamicbox_buffer_data *user_data; - const char *pkgname; - const char *id; - int w; - int h; - int pixel_size; - - if (!handle) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - user_data = dynamicbox_provider_buffer_user_data(handle); - if (!user_data) { - ErrPrint("Invalid buffer\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - if (user_data->accelerated) { - DbgPrint("H/W Buffer allocated. skip the sync buffer\n"); - return DBOX_STATUS_ERROR_NONE; - } - - pkgname = dynamicbox_provider_buffer_pkgname(handle); - if (!pkgname) { - ErrPrint("Invalid buffer handler\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - id = dynamicbox_provider_buffer_id(handle); - if (!id) { - ErrPrint("Invalid buffer handler\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - (void)dynamicbox_provider_buffer_sync(handle); - - if (dynamicbox_provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) { - ErrPrint("Failed to get size (%s)\n", id); - } - - /** - * @todo - * manipulate the damaged region, so send update event only for the damaged region. - * to make more efficient updates - */ - - if (user_data->is_gbar == 1) { - if (send_gbar_updated(pkgname, id, NULL, 0, 0, w, h) < 0) { - ErrPrint("Failed to send PD updated (%s)\n", id); - } - } else { - if (send_dbox_updated(pkgname, id, 0, 0, w, h) < 0) { - ErrPrint("Failed to send updated (%s)\n", id); - } - } - - return DBOX_STATUS_ERROR_NONE; + struct dynamicbox_buffer_data *user_data; + const char *pkgname; + const char *id; + int w; + int h; + int pixel_size; + + if (!handle) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + user_data = dynamicbox_provider_buffer_user_data(handle); + if (!user_data) { + ErrPrint("Invalid buffer\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + if (user_data->accelerated) { + DbgPrint("H/W Buffer allocated. skip the sync buffer\n"); + return DBOX_STATUS_ERROR_NONE; + } + + pkgname = dynamicbox_provider_buffer_pkgname(handle); + if (!pkgname) { + ErrPrint("Invalid buffer handler\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + id = dynamicbox_provider_buffer_id(handle); + if (!id) { + ErrPrint("Invalid buffer handler\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + (void)dynamicbox_provider_buffer_sync(handle); + + if (dynamicbox_provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) { + ErrPrint("Failed to get size (%s)\n", id); + } + + /** + * @todo + * manipulate the damaged region, so send update event only for the damaged region. + * to make more efficient updates + */ + + if (user_data->is_gbar == 1) { + if (send_updated(pkgname, id, DBOX_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL) < 0) { + ErrPrint("Failed to send GBAR updated (%s)\n", id); + } + } else { + if (send_updated(pkgname, id, DBOX_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL) < 0) { + ErrPrint("Failed to send updated (%s)\n", id); + } + } + + return DBOX_STATUS_ERROR_NONE; +} + +PUBLIC int dynamicbox_send_updated_by_idx(dynamicbox_buffer_h handle, int idx) +{ + struct dynamicbox_buffer_data *user_data; + const char *pkgname; + const char *id; + int w; + int h; + int pixel_size; + + user_data = dynamicbox_provider_buffer_user_data(handle); + if (!user_data) { + ErrPrint("Invalid buffer\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + pkgname = dynamicbox_provider_buffer_pkgname(handle); + if (!pkgname) { + ErrPrint("Invalid buffer handler\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + id = dynamicbox_provider_buffer_id(handle); + if (!id) { + ErrPrint("Invalid buffer handler\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + if (dynamicbox_provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) { + ErrPrint("Failed to get size (%s)\n", id); + } + + if (send_updated(pkgname, id, idx, 0, 0, w, h, user_data->is_gbar, NULL) < 0) { + ErrPrint("Failed to send GBAR updated (%s) %d\n", id, idx); + } } PUBLIC int dynamicbox_support_hw_buffer(dynamicbox_buffer_h handle) { - if (!handle) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } + if (!handle) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } - return dynamicbox_provider_buffer_is_support_hw(handle); + return dynamicbox_provider_buffer_is_support_hw(handle); } PUBLIC int dynamicbox_create_hw_buffer(dynamicbox_buffer_h handle) { - struct dynamicbox_buffer_data *user_data; - int ret; + struct dynamicbox_buffer_data *user_data; + int ret; - if (!handle) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } + if (!handle) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } - user_data = dynamicbox_provider_buffer_user_data(handle); - if (!user_data) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } + user_data = dynamicbox_provider_buffer_user_data(handle); + if (!user_data) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } - if (user_data->accelerated) { - return DBOX_STATUS_ERROR_ALREADY; - } + if (user_data->accelerated) { + return DBOX_STATUS_ERROR_ALREADY; + } - ret = dynamicbox_provider_buffer_create_hw(handle); - user_data->accelerated = (ret == 0); - return ret; + ret = dynamicbox_provider_buffer_create_hw(handle); + user_data->accelerated = (ret == 0); + return ret; } PUBLIC int dynamicbox_destroy_hw_buffer(dynamicbox_buffer_h handle) { - struct dynamicbox_buffer_data *user_data; + struct dynamicbox_buffer_data *user_data; - if (!handle) { - LOGD("handle is NULL\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } + if (!handle) { + LOGD("handle is NULL\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } - user_data = dynamicbox_provider_buffer_user_data(handle); - if (!user_data || !user_data->accelerated) { - LOGD("user_data is NULL\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } + user_data = dynamicbox_provider_buffer_user_data(handle); + if (!user_data || !user_data->accelerated) { + LOGD("user_data is NULL\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } - user_data->accelerated = 0; + user_data->accelerated = 0; - return dynamicbox_provider_buffer_destroy_hw(handle); + return dynamicbox_provider_buffer_destroy_hw(handle); } PUBLIC void *dynamicbox_buffer_hw_buffer(dynamicbox_buffer_h handle) { - struct dynamicbox_buffer_data *user_data; + struct dynamicbox_buffer_data *user_data; - if (!handle) { - return NULL; - } + if (!handle) { + return NULL; + } - user_data = dynamicbox_provider_buffer_user_data(handle); - if (!user_data || !user_data->accelerated) { - return NULL; - } + user_data = dynamicbox_provider_buffer_user_data(handle); + if (!user_data || !user_data->accelerated) { + return NULL; + } - return dynamicbox_provider_buffer_hw_addr(handle); + return dynamicbox_provider_buffer_hw_addr(handle); } PUBLIC int dynamicbox_buffer_pre_render(dynamicbox_buffer_h handle) { - struct dynamicbox_buffer_data *user_data; - - if (!handle) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - user_data = dynamicbox_provider_buffer_user_data(handle); - if (!user_data) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - if (!user_data->accelerated) { - return DBOX_STATUS_ERROR_NONE; - } - - /*! - * \note - * Do preprocessing for accessing the H/W render buffer - */ - return dynamicbox_provider_buffer_pre_render(handle); + struct dynamicbox_buffer_data *user_data; + + if (!handle) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + user_data = dynamicbox_provider_buffer_user_data(handle); + if (!user_data) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + if (!user_data->accelerated) { + return DBOX_STATUS_ERROR_NONE; + } + + /*! + * \note + * Do preprocessing for accessing the H/W render buffer + */ + return dynamicbox_provider_buffer_pre_render(handle); } PUBLIC int dynamicbox_buffer_post_render(dynamicbox_buffer_h handle) { - int ret; - const char *pkgname; - const char *id; - struct dynamicbox_buffer_data *user_data; - int w; - int h; - int pixel_size; - - if (!handle) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - user_data = dynamicbox_provider_buffer_user_data(handle); - if (!user_data) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - if (!user_data->accelerated) { - return DBOX_STATUS_ERROR_NONE; - } - - pkgname = dynamicbox_provider_buffer_pkgname(handle); - if (!pkgname) { - ErrPrint("Invalid buffer handle\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - id = dynamicbox_provider_buffer_id(handle); - if (!id) { - ErrPrint("Invalid buffer handler\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - ret = dynamicbox_provider_buffer_post_render(handle); - if (ret < 0) { - ErrPrint("Failed to post render processing\n"); - return ret; - } - - if (dynamicbox_provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) { - ErrPrint("Failed to get size (%s)\n", id); - } - - /** - * @todo - * manipulate the damaged region, so send update event only for the damaged region. - * to make more efficient updates - */ - - if (user_data->is_gbar == 1) { - if (send_gbar_updated(pkgname, id, NULL, 0, 0, w, h) < 0) { - ErrPrint("Failed to send PD updated (%s)\n", id); - } - } else { - if (send_dbox_updated(pkgname, id, 0, 0, w, h) < 0) { - ErrPrint("Failed to send updated (%s)\n", id); - } - } - - return DBOX_STATUS_ERROR_NONE; + int ret; + const char *pkgname; + const char *id; + struct dynamicbox_buffer_data *user_data; + int w; + int h; + int pixel_size; + + if (!handle) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + user_data = dynamicbox_provider_buffer_user_data(handle); + if (!user_data) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + if (!user_data->accelerated) { + return DBOX_STATUS_ERROR_NONE; + } + + pkgname = dynamicbox_provider_buffer_pkgname(handle); + if (!pkgname) { + ErrPrint("Invalid buffer handle\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + id = dynamicbox_provider_buffer_id(handle); + if (!id) { + ErrPrint("Invalid buffer handler\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + ret = dynamicbox_provider_buffer_post_render(handle); + if (ret < 0) { + ErrPrint("Failed to post render processing\n"); + return ret; + } + + if (dynamicbox_provider_buffer_get_size(handle, &w, &h, &pixel_size) < 0) { + ErrPrint("Failed to get size (%s)\n", id); + } + + /** + * @todo + * manipulate the damaged region, so send update event only for the damaged region. + * to make more efficient updates + */ + + if (send_updated(pkgname, id, DBOX_PRIMARY_BUFFER, 0, 0, w, h, user_data->is_gbar, NULL) < 0) { + ErrPrint("Failed to send GBAR updated (%s)\n", id); + } + + return DBOX_STATUS_ERROR_NONE; } PUBLIC int dynamicbox_buffer_stride(dynamicbox_buffer_h handle) { - if (!handle) { - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } + if (!handle) { + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } - return dynamicbox_provider_buffer_stride(handle); + return dynamicbox_provider_buffer_stride(handle); } PUBLIC int dynamicbox_content_is_updated(const char *filename, int is_gbar) { - if (!s_info.trigger_update_monitor) { - s_info.trigger_update_monitor = dlsym(RTLD_DEFAULT, "dynamicbox_trigger_update_monitor"); - if (!s_info.trigger_update_monitor) { - ErrPrint("Trigger update monitor function is not exists\n"); - return DBOX_STATUS_ERROR_FAULT; - } - } - - return s_info.trigger_update_monitor(filename, is_gbar); + if (!s_info.trigger_update_monitor) { + s_info.trigger_update_monitor = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_TRIGGER_UPDATE_MONITOR); + if (!s_info.trigger_update_monitor) { + ErrPrint("Trigger update monitor function is not exists\n"); + return DBOX_STATUS_ERROR_FAULT; + } + } + + return s_info.trigger_update_monitor(filename, is_gbar); } -PUBLIC int dynamicbox_request_close_gbar(const char *pkgname, const char *id, int reason) +PUBLIC int dynamicbox_request_close_glance_bar(const char *pkgname, const char *id, int reason) { - char *uri; - int schema_len = strlen(FILE_SCHEMA); - int ret; - - if (!pkgname || !id) { - ErrPrint("Invalid parameters (%s) (%s)\n", pkgname, id); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - if (strncmp(id, FILE_SCHEMA, schema_len)) { - uri = id_to_uri(id); - if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - } else { - uri = strdup(id); - if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - } - - ret = dynamicbox_provider_send_request_close_gbar(pkgname, uri, reason); - free(uri); - return ret; + char *uri; + int schema_len = strlen(FILE_SCHEMA); + int ret; + + if (!pkgname || !id) { + ErrPrint("Invalid parameters (%s) (%s)\n", pkgname, id); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + if (strncmp(id, FILE_SCHEMA, schema_len)) { + uri = id_to_uri(id); + if (!uri) { + ErrPrint("Heap: %s\n", strerror(errno)); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + } else { + uri = strdup(id); + if (!uri) { + ErrPrint("Heap: %s\n", strerror(errno)); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + } + + ret = dynamicbox_provider_send_request_close_gbar(pkgname, uri, reason); + free(uri); + return ret; } PUBLIC int dynamicbox_freeze_scroller(const char *pkgname, const char *id) { - char *uri; - int ret; - - uri = id_to_uri(id); - if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - ret = dynamicbox_provider_send_hold_scroll(pkgname, uri, 1); - free(uri); - return ret; + char *uri; + int ret; + + uri = id_to_uri(id); + if (!uri) { + ErrPrint("Heap: %s\n", strerror(errno)); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + ret = dynamicbox_provider_send_hold_scroll(pkgname, uri, 1); + free(uri); + return ret; } PUBLIC int dynamicbox_thaw_scroller(const char *pkgname, const char *id) { - char *uri; - int ret; - - uri = id_to_uri(id); - if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - ret = dynamicbox_provider_send_hold_scroll(pkgname, uri, 0); - free(uri); - return ret; + char *uri; + int ret; + + uri = id_to_uri(id); + if (!uri) { + ErrPrint("Heap: %s\n", strerror(errno)); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + ret = dynamicbox_provider_send_hold_scroll(pkgname, uri, 0); + free(uri); + return ret; } PUBLIC int dynamicbox_set_extra_info(const char *id, const char *content, const char *title, const char *icon, const char *name) { - dynamicbox_buffer_h handle; - const char *pkgname; - char *uri; - - uri = id_to_uri(id); - if (!uri) { - ErrPrint("Heap: %s\n", strerror(errno)); - return DBOX_STATUS_ERROR_OUT_OF_MEMORY; - } - - if (!s_info.find_pkgname) { - s_info.find_pkgname = dlsym(RTLD_DEFAULT, "dynamicbox_find_pkgname"); - if (!s_info.find_pkgname) { - ErrPrint("Failed to find a \"dynamicbox_find_pkgname\"\n"); - free(uri); - return DBOX_STATUS_ERROR_FAULT; - } - } - - pkgname = s_info.find_pkgname(uri); - if (!pkgname) { - ErrPrint("Failed to find a package (%s)\n", uri); - free(uri); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - handle = dynamicbox_provider_buffer_find_buffer(DBOX_TYPE_DBOX, pkgname, uri); - if (handle) { - struct dynamicbox_buffer_data *user_data; - - user_data = dynamicbox_provider_buffer_user_data(handle); - if (!user_data) { - ErrPrint("User data is not available\n"); - free(uri); - return DBOX_STATUS_ERROR_FAULT; - } - - if (content && strlen(content)) { - char *_content; - - _content = strdup(content); - if (_content) { - if (user_data->content) { - free(user_data->content); - } - - user_data->content = _content; - } else { - ErrPrint("Heap: %s\n", strerror(errno)); - } - } - - if (title && strlen(title)) { - char *_title; - - _title = strdup(title); - if (_title) { - if (user_data->title) { - free(user_data->title); - } - - user_data->title = _title; - } else { - ErrPrint("Heap: %s\n", strerror(errno)); - } - } - - if (icon && strlen(icon)) { - char *_icon; - - _icon = strdup(icon); - if (_icon) { - if (user_data->icon) { - free(user_data->icon); - } - - user_data->icon = _icon; - } else { - ErrPrint("Heap: %s\n", strerror(errno)); - } - } - - if (name && strlen(name)) { - char *_name; - - _name = strdup(name); - if (_name) { - if (user_data->name) { - free(user_data->name); - } - - user_data->name = _name; - } else { - ErrPrint("Heap: %s\n", strerror(errno)); - } - } - - if (dynamicbox_provider_send_extra_info(pkgname, uri, -1.0f, user_data->content, user_data->title, user_data->icon, user_data->name) < 0) { - ErrPrint("Failed to send extra info (%s)\n", id); - } - - free(uri); - return DBOX_STATUS_ERROR_NONE; - } - free(uri); - - if (!s_info.update_extra_info) { - s_info.update_extra_info = dlsym(RTLD_DEFAULT, "dynamicbox_update_extra_info"); - if (!s_info.update_extra_info) { - ErrPrint("Failed to find a \"dynamicbox_update_extra_info\"\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - } - - return s_info.update_extra_info(id, content, title, icon, name); + dynamicbox_buffer_h handle; + const char *pkgname; + char *uri; + + uri = id_to_uri(id); + if (!uri) { + ErrPrint("Heap: %s\n", strerror(errno)); + return DBOX_STATUS_ERROR_OUT_OF_MEMORY; + } + + if (!s_info.find_pkgname) { + s_info.find_pkgname = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_FIND_PKGNAME); + if (!s_info.find_pkgname) { + ErrPrint("Failed to find a \"dynamicbox_find_pkgname\"\n"); + free(uri); + return DBOX_STATUS_ERROR_FAULT; + } + } + + pkgname = s_info.find_pkgname(uri); + if (!pkgname) { + ErrPrint("Failed to find a package (%s)\n", uri); + free(uri); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + handle = dynamicbox_provider_buffer_find_buffer(DBOX_TYPE_DBOX, pkgname, uri); + if (handle) { + struct dynamicbox_buffer_data *user_data; + + user_data = dynamicbox_provider_buffer_user_data(handle); + if (!user_data) { + ErrPrint("User data is not available\n"); + free(uri); + return DBOX_STATUS_ERROR_FAULT; + } + + if (content && strlen(content)) { + char *_content; + + _content = strdup(content); + if (_content) { + if (user_data->content) { + free(user_data->content); + } + + user_data->content = _content; + } else { + ErrPrint("Heap: %s\n", strerror(errno)); + } + } + + if (title && strlen(title)) { + char *_title; + + _title = strdup(title); + if (_title) { + if (user_data->title) { + free(user_data->title); + } + + user_data->title = _title; + } else { + ErrPrint("Heap: %s\n", strerror(errno)); + } + } + + if (icon && strlen(icon)) { + char *_icon; + + _icon = strdup(icon); + if (_icon) { + if (user_data->icon) { + free(user_data->icon); + } + + user_data->icon = _icon; + } else { + ErrPrint("Heap: %s\n", strerror(errno)); + } + } + + if (name && strlen(name)) { + char *_name; + + _name = strdup(name); + if (_name) { + if (user_data->name) { + free(user_data->name); + } + + user_data->name = _name; + } else { + ErrPrint("Heap: %s\n", strerror(errno)); + } + } + + if (dynamicbox_provider_send_extra_info(pkgname, uri, -1.0f, user_data->content, user_data->title, user_data->icon, user_data->name) < 0) { + ErrPrint("Failed to send extra info (%s)\n", id); + } + + free(uri); + return DBOX_STATUS_ERROR_NONE; + } + free(uri); + + if (!s_info.update_extra_info) { + s_info.update_extra_info = dlsym(RTLD_DEFAULT, FUNC_DYNAMICBOX_UPDATE_EXTRA_INFO); + if (!s_info.update_extra_info) { + ErrPrint("Failed to find a \"dynamicbox_update_extra_info\"\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + } + + return s_info.update_extra_info(id, content, title, icon, name); } /* End of a file */ diff --git a/src/snapshot_window.c b/src/snapshot_window.c index 3b7ad24..2fcdaf8 100644 --- a/src/snapshot_window.c +++ b/src/snapshot_window.c @@ -1,3 +1,19 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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. + */ + #include #include #include @@ -17,14 +33,14 @@ struct snapshot_info { - char *id; - dynamicbox_flush_cb flush_cb; - void *data; + char *id; + dynamicbox_flush_cb flush_cb; + void *data; - Ecore_Timer *flush_timer; + Ecore_Timer *flush_timer; - int render_cnt; - double timeout; + int render_cnt; + double timeout; }; static void post_render_cb(void *data, Evas *e, void *event_info); @@ -44,8 +60,8 @@ static inline Evas *create_virtual_canvas(int w, int h) return NULL; } - ecore_evas_alpha_set(internal_ee, EINA_TRUE); - ecore_evas_manual_render_set(internal_ee, EINA_FALSE); + ecore_evas_alpha_set(internal_ee, EINA_TRUE); + ecore_evas_manual_render_set(internal_ee, EINA_FALSE); // Get the "Evas" object from a virtual canvas internal_e = ecore_evas_get(internal_ee); @@ -66,7 +82,7 @@ static inline int flush_data_to_file(Evas *e, char *data, const char *filename, output = evas_object_image_add(e); if (!output) { - DbgPrint("Failed to create an image object\n"); + DbgPrint("Failed to create an image object\n"); return DBOX_STATUS_ERROR_FAULT; } @@ -76,24 +92,24 @@ static inline int flush_data_to_file(Evas *e, char *data, const char *filename, evas_object_image_size_set(output, w, h); evas_object_image_smooth_scale_set(output, EINA_TRUE); evas_object_image_data_set(output, data); - evas_object_image_fill_set(output, 0, 0, w, h); + evas_object_image_fill_set(output, 0, 0, w, h); evas_object_image_data_update_add(output, 0, 0, w, h); if (evas_object_image_save(output, filename, NULL, QUALITY_N_COMPRESS) == EINA_FALSE) { evas_object_del(output); - DbgPrint("Faield to save a captured image (%s)\n", filename); + DbgPrint("Faield to save a captured image (%s)\n", filename); return DBOX_STATUS_ERROR_IO_ERROR; } - evas_object_del(output); + evas_object_del(output); if (access(filename, F_OK) != 0) { - DbgPrint("File %s is not found\n", filename); + DbgPrint("File %s is not found\n", filename); return DBOX_STATUS_ERROR_IO_ERROR; } - DbgPrint("Flush data to a file (%s)\n", filename); - return DBOX_STATUS_ERROR_NONE; + DbgPrint("Flush data to a file (%s)\n", filename); + return DBOX_STATUS_ERROR_NONE; } @@ -104,7 +120,7 @@ static inline int destroy_virtual_canvas(Evas *e) ee = ecore_evas_ecore_evas_get(e); if (!ee) { - DbgPrint("Failed to ecore evas object\n"); + DbgPrint("Failed to ecore evas object\n"); return DBOX_STATUS_ERROR_FAULT; } @@ -114,396 +130,396 @@ static inline int destroy_virtual_canvas(Evas *e) -static inline int flush_to_file(void *canvas, const char *filename, int w, int h) +static inline int flush_to_file(const void *canvas, const char *filename, int w, int h) { - int status; - Evas *shot_e; - Ecore_Evas *shot_ee; + int status; + Evas *shot_e; + Ecore_Evas *shot_ee; - shot_e = create_virtual_canvas(w, h); - if (!shot_e) { - ErrPrint("Unable to create a new virtual window\n"); - return DBOX_STATUS_ERROR_FAULT; - } + shot_e = create_virtual_canvas(w, h); + if (!shot_e) { + ErrPrint("Unable to create a new virtual window\n"); + return DBOX_STATUS_ERROR_FAULT; + } - shot_ee = ecore_evas_ecore_evas_get(shot_e); - if (!shot_ee) { - ErrPrint("Unable to get Ecore_Evas\n"); - destroy_virtual_canvas(shot_e); - return DBOX_STATUS_ERROR_FAULT; - } + shot_ee = ecore_evas_ecore_evas_get(shot_e); + if (!shot_ee) { + ErrPrint("Unable to get Ecore_Evas\n"); + destroy_virtual_canvas(shot_e); + return DBOX_STATUS_ERROR_FAULT; + } - ecore_evas_manual_render_set(shot_ee, EINA_TRUE); + ecore_evas_manual_render_set(shot_ee, EINA_TRUE); - status = flush_data_to_file(shot_e, canvas, filename, w, h); - destroy_virtual_canvas(shot_e); + status = flush_data_to_file(shot_e, canvas, filename, w, h); + destroy_virtual_canvas(shot_e); - return status; + return status; } static Eina_Bool snapshot_cb(void *data) { - Evas_Object *snapshot_win = data; - struct snapshot_info *info; - Evas *e; - Ecore_Evas *ee; - void *canvas; - dynamicbox_flush_cb flush_cb; - int status = DBOX_STATUS_ERROR_NONE; - - info = evas_object_data_get(snapshot_win, "snapshot,info"); - if (!info) { - ErrPrint("Invalid object\n"); - return ECORE_CALLBACK_CANCEL; - } - - if (info->flush_timer) { - info->flush_timer = NULL; - } else { - status = DBOX_STATUS_ERROR_CANCEL; - } - - flush_cb = info->flush_cb; - info->flush_cb = NULL; /* To prevent call this from the delete callback */ - - e = evas_object_evas_get(snapshot_win); - if (!e) { - ErrPrint("Invalid object\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - ee = ecore_evas_ecore_evas_get(e); - if (!ee) { - ErrPrint("Invalid object (ee)\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - canvas = (void*)ecore_evas_buffer_pixels_get(ee); - if (!canvas) { - DbgPrint("Failed to get pixel canvas\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - if (flush_cb) { - int w; - int h; - int ret; - - ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - - DbgPrint("Flush size: %dx%d\n", w, h); - ret = flush_to_file(canvas, info->id, w, h); - if (status == DBOX_STATUS_ERROR_NONE) { - status = ret; - } - - flush_cb(snapshot_win, info->id, status, info->data); - /** - * Do not access info after this. - */ - } - - return ECORE_CALLBACK_CANCEL; + Evas_Object *snapshot_win = data; + struct snapshot_info *info; + Evas *e; + Ecore_Evas *ee; + void *canvas; + dynamicbox_flush_cb flush_cb; + int status = DBOX_STATUS_ERROR_NONE; + + info = evas_object_data_get(snapshot_win, "snapshot,info"); + if (!info) { + ErrPrint("Invalid object\n"); + return ECORE_CALLBACK_CANCEL; + } + + if (info->flush_timer) { + info->flush_timer = NULL; + } else { + status = DBOX_STATUS_ERROR_CANCEL; + } + + flush_cb = info->flush_cb; + info->flush_cb = NULL; /* To prevent call this from the delete callback */ + + e = evas_object_evas_get(snapshot_win); + if (!e) { + ErrPrint("Invalid object\n"); + if (flush_cb) { + flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); + } + return ECORE_CALLBACK_CANCEL; + } + + ee = ecore_evas_ecore_evas_get(e); + if (!ee) { + ErrPrint("Invalid object (ee)\n"); + if (flush_cb) { + flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); + } + return ECORE_CALLBACK_CANCEL; + } + + canvas = (void*)ecore_evas_buffer_pixels_get(ee); + if (!canvas) { + DbgPrint("Failed to get pixel canvas\n"); + if (flush_cb) { + flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); + } + return ECORE_CALLBACK_CANCEL; + } + + if (flush_cb) { + int w; + int h; + int ret; + + ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); + + DbgPrint("Flush size: %dx%d\n", w, h); + ret = flush_to_file(canvas, info->id, w, h); + if (status == DBOX_STATUS_ERROR_NONE) { + status = ret; + } + + flush_cb(snapshot_win, info->id, status, info->data); + /** + * Do not access info after this. + */ + } + + return ECORE_CALLBACK_CANCEL; } static void del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { - struct snapshot_info *info; + struct snapshot_info *info; - info = evas_object_data_del(obj, "snapshot,info"); - if (!info) { - return; - } + info = evas_object_data_del(obj, "snapshot,info"); + if (!info) { + return; + } - DbgPrint("Delete object (%s)\n", info->id); + DbgPrint("Delete object (%s)\n", info->id); - evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, post_render_cb); - evas_event_callback_del(e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb); + evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, post_render_cb); + evas_event_callback_del(e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb); - if (info->flush_timer) { - ecore_timer_del(info->flush_timer); - info->flush_timer = NULL; + if (info->flush_timer) { + ecore_timer_del(info->flush_timer); + info->flush_timer = NULL; - (void)snapshot_cb(obj); - DbgPrint("Flush is canceled\n"); - } + (void)snapshot_cb(obj); + DbgPrint("Flush is canceled\n"); + } - /** - * @note - * Render callback will be deleted. - */ - free(info->id); - free(info); + /** + * @note + * Render callback will be deleted. + */ + free(info->id); + free(info); } static Eina_Bool direct_snapshot_cb(void *data) { - Evas *e; - Ecore_Evas *ee; - void *canvas; - int status; - int w; - int h; - dynamicbox_flush_cb flush_cb; - Evas_Object *snapshot_win = data; - struct snapshot_info *info; - - info = evas_object_data_get(snapshot_win, "snapshot,info"); - if (!info) { - ErrPrint("Unable to get snapshot info\n"); - return ECORE_CALLBACK_CANCEL; - } - - info->flush_timer = NULL; - flush_cb = info->flush_cb; - info->flush_cb = NULL; /* To prevent call this from the delete callback */ - - e = evas_object_evas_get(snapshot_win); - if (!e) { - ErrPrint("Invalid object, failed to get Evas\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - ee = ecore_evas_ecore_evas_get(e); - if (!ee) { - ErrPrint("Unable to get Ecore_Evas object\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - ecore_evas_manual_render_set(ee, EINA_TRUE); - - canvas = ecore_evas_buffer_pixels_get(ee); - if (!canvas) { - ErrPrint("Failed to get canvas\n"); - if (flush_cb) { - flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); - } - return ECORE_CALLBACK_CANCEL; - } - - status = flush_to_file(canvas, info->id, w, h); - if (flush_cb) { - flush_cb(snapshot_win, info->id, status, info->data); - } - return ECORE_CALLBACK_CANCEL; + Evas *e; + Ecore_Evas *ee; + const void *canvas; + int status; + int w; + int h; + dynamicbox_flush_cb flush_cb; + Evas_Object *snapshot_win = data; + struct snapshot_info *info; + + info = evas_object_data_get(snapshot_win, "snapshot,info"); + if (!info) { + ErrPrint("Unable to get snapshot info\n"); + return ECORE_CALLBACK_CANCEL; + } + + info->flush_timer = NULL; + flush_cb = info->flush_cb; + info->flush_cb = NULL; /* To prevent call this from the delete callback */ + + e = evas_object_evas_get(snapshot_win); + if (!e) { + ErrPrint("Invalid object, failed to get Evas\n"); + if (flush_cb) { + flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); + } + return ECORE_CALLBACK_CANCEL; + } + + ee = ecore_evas_ecore_evas_get(e); + if (!ee) { + ErrPrint("Unable to get Ecore_Evas object\n"); + if (flush_cb) { + flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); + } + return ECORE_CALLBACK_CANCEL; + } + + ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); + ecore_evas_manual_render_set(ee, EINA_TRUE); + + canvas = ecore_evas_buffer_pixels_get(ee); + if (!canvas) { + ErrPrint("Failed to get canvas\n"); + if (flush_cb) { + flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); + } + return ECORE_CALLBACK_CANCEL; + } + + status = flush_to_file(canvas, info->id, w, h); + if (flush_cb) { + flush_cb(snapshot_win, info->id, status, info->data); + } + return ECORE_CALLBACK_CANCEL; } static void post_render_cb(void *data, Evas *e, void *event_info) { - Evas_Object *snapshot_win = data; - struct snapshot_info *info; - - info = evas_object_data_get(snapshot_win, "snapshot,info"); - if (!info) { - ErrPrint("snapshot info is not valid\n"); - return; - } - - info->render_cnt++; - - if (info->flush_timer) { - /** - * @note - * This has not to be happens. - */ - ErrPrint("Flush timer is not cleared\n"); - ecore_timer_del(info->flush_timer); - info->flush_timer = NULL; - } - - if (!info->flush_cb) { - DbgPrint("Flush request is not initiated yet\n"); - return; - } - - /*! - * \NOTE - * Even if tehre is no timer registered, we should capture the content - * from out of this callback. - * Or we can met unexpected problems. - * To avoid it, use the 0.0001f to get timer callback ASAP, not in this function. - */ - DbgPrint("Fire the flush timer %lf (%d)\n", info->timeout, info->render_cnt); - info->flush_timer = ecore_timer_add(info->timeout, snapshot_cb, snapshot_win); - if (!info->flush_timer) { - dynamicbox_flush_cb flush_cb; - - ErrPrint("Unalbe to add timer for getting the snapshot\n"); - flush_cb = info->flush_cb; - info->flush_cb = NULL; - - if (flush_cb) { - flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); - } - /*! - * \note - * Do not access info after from here. - */ - } + Evas_Object *snapshot_win = data; + struct snapshot_info *info; + + info = evas_object_data_get(snapshot_win, "snapshot,info"); + if (!info) { + ErrPrint("snapshot info is not valid\n"); + return; + } + + info->render_cnt++; + + if (info->flush_timer) { + /** + * @note + * This has not to be happens. + */ + ErrPrint("Flush timer is not cleared\n"); + ecore_timer_del(info->flush_timer); + info->flush_timer = NULL; + } + + if (!info->flush_cb) { + DbgPrint("Flush request is not initiated yet\n"); + return; + } + + /*! + * \NOTE + * Even if tehre is no timer registered, we should capture the content + * from out of this callback. + * Or we can met unexpected problems. + * To avoid it, use the 0.0001f to get timer callback ASAP, not in this function. + */ + DbgPrint("Fire the flush timer %lf (%d)\n", info->timeout, info->render_cnt); + info->flush_timer = ecore_timer_add(info->timeout, snapshot_cb, snapshot_win); + if (!info->flush_timer) { + dynamicbox_flush_cb flush_cb; + + ErrPrint("Unalbe to add timer for getting the snapshot\n"); + flush_cb = info->flush_cb; + info->flush_cb = NULL; + + if (flush_cb) { + flush_cb(snapshot_win, info->id, DBOX_STATUS_ERROR_FAULT, info->data); + } + /*! + * \note + * Do not access info after from here. + */ + } } static void pre_render_cb(void *data, Evas *e, void *event_info) { - Evas_Object *snapshot_win = data; - struct snapshot_info *info; - - info = evas_object_data_get(snapshot_win, "snapshot,info"); - if (!info) { - ErrPrint("snapshot info is not valid\n"); - return; - } - - if (info->flush_timer) { - ecore_timer_del(info->flush_timer); - info->flush_timer = NULL; - DbgPrint("Clear the flush timer\n"); - } - - DbgPrint("Pre-render callback\n"); + Evas_Object *snapshot_win = data; + struct snapshot_info *info; + + info = evas_object_data_get(snapshot_win, "snapshot,info"); + if (!info) { + ErrPrint("snapshot info is not valid\n"); + return; + } + + if (info->flush_timer) { + ecore_timer_del(info->flush_timer); + info->flush_timer = NULL; + DbgPrint("Clear the flush timer\n"); + } + + DbgPrint("Pre-render callback\n"); } PUBLIC void *dynamicbox_snapshot_window_add(const char *id, int size_type) { - struct snapshot_info *info; - Evas_Object *snapshot_win; - Evas_Object *parent; - Evas *e; - int w; - int h; - - if (dynamicbox_service_get_size(size_type, &w, &h) != DBOX_STATUS_ERROR_NONE) { - ErrPrint("Invalid size\n"); - return NULL; - } - - info = malloc(sizeof(*info)); - if (!info) { - ErrPrint("Heap: %s\n", strerror(errno)); - return NULL; - } - - info->id = strdup(id); - if (!info->id) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(info); - return NULL; - } - - info->flush_cb = NULL; - info->data = NULL; - info->flush_timer = NULL; - info->render_cnt = 0; - - e = create_virtual_canvas(w, h); - if (!e) { - free(info->id); - free(info); - return NULL; - } - - parent = evas_object_rectangle_add(e); - if (!parent) { - destroy_virtual_canvas(e); - free(info->id); - free(info); - return NULL; - } - - snapshot_win = elm_win_add(parent, "DBox,Snapshot", ELM_WIN_DYNAMIC_BOX); - evas_object_del(parent); - if (!snapshot_win) { - destroy_virtual_canvas(e); - free(info->id); - free(info); - return NULL; - } - - DbgPrint("Create a new window %dx%d for %s\n", w, h, id); - evas_object_event_callback_add(snapshot_win, EVAS_CALLBACK_DEL, del_cb, NULL); - evas_object_resize(snapshot_win, w, h); - evas_object_show(snapshot_win); - - evas_object_data_set(snapshot_win, "snapshot,info", info); - - evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, post_render_cb, snapshot_win); - evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, snapshot_win); - - return snapshot_win; + struct snapshot_info *info; + Evas_Object *snapshot_win; + Evas_Object *parent; + Evas *e; + int w; + int h; + + if (dynamicbox_service_get_size(size_type, &w, &h) != DBOX_STATUS_ERROR_NONE) { + ErrPrint("Invalid size\n"); + return NULL; + } + + info = malloc(sizeof(*info)); + if (!info) { + ErrPrint("Heap: %s\n", strerror(errno)); + return NULL; + } + + info->id = strdup(id); + if (!info->id) { + ErrPrint("Heap: %s\n", strerror(errno)); + free(info); + return NULL; + } + + info->flush_cb = NULL; + info->data = NULL; + info->flush_timer = NULL; + info->render_cnt = 0; + + e = create_virtual_canvas(w, h); + if (!e) { + free(info->id); + free(info); + return NULL; + } + + parent = evas_object_rectangle_add(e); + if (!parent) { + destroy_virtual_canvas(e); + free(info->id); + free(info); + return NULL; + } + + snapshot_win = elm_win_add(parent, "DBox,Snapshot", ELM_WIN_DYNAMIC_BOX); + evas_object_del(parent); + if (!snapshot_win) { + destroy_virtual_canvas(e); + free(info->id); + free(info); + return NULL; + } + + DbgPrint("Create a new window %dx%d for %s\n", w, h, id); + evas_object_event_callback_add(snapshot_win, EVAS_CALLBACK_DEL, del_cb, NULL); + evas_object_resize(snapshot_win, w, h); + evas_object_show(snapshot_win); + + evas_object_data_set(snapshot_win, "snapshot,info", info); + + evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, post_render_cb, snapshot_win); + evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, snapshot_win); + + return snapshot_win; } PUBLIC int dynamicbox_snapshot_window_flush(void *snapshot_win, double timeout, dynamicbox_flush_cb flush_cb, void *data) { - struct snapshot_info *info; - - if (!flush_cb || timeout < 0.0f) { - ErrPrint("Invalid argument (%p, %lf)\n", flush_cb, timeout); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - info = evas_object_data_get(snapshot_win, "snapshot,info"); - if (!info) { - ErrPrint("Invalid argument\n"); - return DBOX_STATUS_ERROR_INVALID_PARAMETER; - } - - info->timeout = timeout; - - if (timeout == 0.0f) { - /*! - * This timer is just used for guarantees same behavious even if it flushes content directly, - * The callback should be called from next loop. - * or the developer will get confused - */ - info->flush_timer = ecore_timer_add(0.0001f, direct_snapshot_cb, snapshot_win); - if (!info->flush_timer) { - return DBOX_STATUS_ERROR_FAULT; - } - } else if (info->render_cnt) { - /*! - * Try to watit pre-render callback. - * If there is rendered contents. - */ - DbgPrint("Rendered %d times already\n", info->render_cnt); - info->flush_timer = ecore_timer_add(info->timeout, snapshot_cb, snapshot_win); - if (!info->flush_timer) { - return DBOX_STATUS_ERROR_FAULT; - } - } - - info->flush_cb = flush_cb; - info->data = data; - - return DBOX_STATUS_ERROR_NONE; + struct snapshot_info *info; + + if (!flush_cb || timeout < 0.0f) { + ErrPrint("Invalid argument (%p, %lf)\n", flush_cb, timeout); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + info = evas_object_data_get(snapshot_win, "snapshot,info"); + if (!info) { + ErrPrint("Invalid argument\n"); + return DBOX_STATUS_ERROR_INVALID_PARAMETER; + } + + info->timeout = timeout; + + if (timeout == 0.0f) { + /*! + * This timer is just used for guarantees same behavious even if it flushes content directly, + * The callback should be called from next loop. + * or the developer will get confused + */ + info->flush_timer = ecore_timer_add(0.0001f, direct_snapshot_cb, snapshot_win); + if (!info->flush_timer) { + return DBOX_STATUS_ERROR_FAULT; + } + } else if (info->render_cnt) { + /*! + * Try to watit pre-render callback. + * If there is rendered contents. + */ + DbgPrint("Rendered %d times already\n", info->render_cnt); + info->flush_timer = ecore_timer_add(info->timeout, snapshot_cb, snapshot_win); + if (!info->flush_timer) { + return DBOX_STATUS_ERROR_FAULT; + } + } + + info->flush_cb = flush_cb; + info->data = data; + + return DBOX_STATUS_ERROR_NONE; } diff --git a/src/util.c b/src/util.c index 208ee6c..1c74ecc 100644 --- a/src/util.c +++ b/src/util.c @@ -29,29 +29,29 @@ int errno; int util_check_extension(const char *filename, const char *check_ptr) { - int name_len; + int name_len; - name_len = strlen(filename); - while (--name_len >= 0 && *check_ptr) { - if (filename[name_len] != *check_ptr) - return -EINVAL; + name_len = strlen(filename); + while (--name_len >= 0 && *check_ptr) { + if (filename[name_len] != *check_ptr) + return -EINVAL; - check_ptr ++; - } + check_ptr ++; + } - return 0; + return 0; } double util_timestamp(void) { #if defined(_USE_ECORE_TIME_GET) - return ecore_time_get(); + return ecore_time_get(); #else - struct timeval tv; + struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, NULL); - return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; + return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; #endif } diff --git a/src/virtual_window.c b/src/virtual_window.c index 4f482ff..c349aa6 100644 --- a/src/virtual_window.c +++ b/src/virtual_window.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -29,718 +30,927 @@ #include #include #include +#include #include "dynamicbox.h" #include "debug.h" -#define IS_PD 1 +#define IS_GBAR 1 #define PUBLIC __attribute__((visibility("default"))) #define DBOX_WIN_TAG "dynamic,box,win" +#define DBOX_DEFAULT_WIDTH 1 +#define DBOX_DEFAULT_HEIGHT 1 +#define GL_ENGINE "opengl_x11" + static struct static_info { - Ecore_Evas *(*alloc_canvas)(int w, int h, void *(*a)(void *data, int size), void (*f)(void *data, void *ptr), void *data); - Ecore_Evas *(*alloc_canvas_with_stride)(int w, int h, void *(*a)(void *data, int size, int *stride, int *bpp), void (*f)(void *data, void *ptr), void *data); + Ecore_Evas *(*alloc_canvas)(int w, int h, void *(*a)(void *data, int size), void (*f)(void *data, void *ptr), void *data); + Ecore_Evas *(*alloc_canvas_with_stride)(int w, int h, void *(*a)(void *data, int size, int *stride, int *bpp), void (*f)(void *data, void *ptr), void *data); + Ecore_Evas *(*alloc_canvas_with_pixmap)(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h, Ecore_X_Pixmap (*alloc_cb)(void *data, Ecore_X_Window parent, int w, int h, int *depth), void (*free_cb)(void *data, Ecore_X_Pixmap pixmap), void *data); } s_info = { - .alloc_canvas = NULL, - .alloc_canvas_with_stride = NULL, + .alloc_canvas = NULL, + .alloc_canvas_with_stride = NULL, + .alloc_canvas_with_pixmap = NULL, }; /** * @brief * Abstracted Data Type of Virtual Window */ -struct info { - char *id; /**< Identification */ - struct dynamicbox_buffer *handle; /**< Livebox buffer handle */ - int is_hw; /**< 1 if a buffer is created on the H/W accelerated place or 0 */ - Ecore_Evas *ee; - Evas *e; - int is_gbar; - int deleted; - int w; - int h; -}; +typedef struct virtual_window_info { + char *id; /**< Identification */ + dynamicbox_buffer_h handle; /**< Livebox buffer handle */ + enum win_type { + VWIN_SW_BUF = 0x00, /**< S/W buffer */ + VWIN_GEM = 0x01, /**< GEM buffer */ + VWIN_PIXMAP = 0x02, /**< PIXMAP */ + VWIN_ERROR = 0x03 /**< Unknown */ + } type; + Ecore_Evas *ee; + Evas *e; + int is_gbar; + int deleted; + int w; + int h; + unsigned int *resource_array; + int resource_cnt; + + unsigned int front_resource_id; +} *vwin_info_t; static inline Evas_Object *get_highlighted_object(Evas_Object *obj) { - Evas_Object *o, *ho; + Evas_Object *o, *ho; - o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp"); - if (!o) return NULL; + o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp"); + if (!o) return NULL; - ho = evas_object_data_get(o, "_elm_access_target"); - return ho; + ho = evas_object_data_get(o, "_elm_access_target"); + return ho; } /** * @note * Every user event (mouse) on the buffer will be passed via this event callback */ -static int event_handler_cb(struct dynamicbox_buffer *handler, struct dynamicbox_buffer_event_data *event_info, void *data) +static int event_handler_cb(dynamicbox_buffer_h handler, struct dynamicbox_buffer_event_data *event_info, void *data) +{ + vwin_info_t info = data; + Elm_Access_Action_Info action_info; + Elm_Access_Action_Type action_type; + int ret = 0; + Evas_Object *parent_elm; + KeySym *key_symbol; + unsigned int flags = 0; + + if (!info->handle) { + /* Just ignore this event */ + return 0; + } + + /** + * @note + * Feed up events + */ + switch (event_info->type) { + case DBOX_BUFFER_EVENT_ON_HOLD: + flags = evas_event_default_flags_get(info->e); + flags |= EVAS_EVENT_FLAG_ON_HOLD; + evas_event_default_flags_set(info->e, flags); + break; + case DBOX_BUFFER_EVENT_OFF_HOLD: + flags = evas_event_default_flags_get(info->e); + flags &= ~EVAS_EVENT_FLAG_ON_HOLD; + evas_event_default_flags_set(info->e, flags); + break; + case DBOX_BUFFER_EVENT_ON_SCROLL: + flags = evas_event_default_flags_get(info->e); + flags |= EVAS_EVENT_FLAG_ON_SCROLL; + evas_event_default_flags_set(info->e, flags); + break; + case DBOX_BUFFER_EVENT_OFF_SCROLL: + flags = evas_event_default_flags_get(info->e); + flags &= ~EVAS_EVENT_FLAG_ON_SCROLL; + evas_event_default_flags_set(info->e, flags); + break; + case DBOX_BUFFER_EVENT_ENTER: + evas_event_feed_mouse_in(info->e, event_info->timestamp * 1000, NULL); + break; + case DBOX_BUFFER_EVENT_LEAVE: + evas_event_feed_mouse_out(info->e, event_info->timestamp * 1000, NULL); + break; + case DBOX_BUFFER_EVENT_DOWN: + /** + * @note + * Before processing the DOWN event, + * Reset the evas event flags regarding ON_HOLD option. + * It can be re-enabled while processing down-move-up events. + */ + flags = evas_event_default_flags_get(info->e); + flags &= ~EVAS_EVENT_FLAG_ON_SCROLL; + flags &= ~EVAS_EVENT_FLAG_ON_HOLD; + evas_event_default_flags_set(info->e, flags); + /** + * @note + * Calculate the event occurred X & Y on the buffer + */ + evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, event_info->timestamp * 1000, NULL); + evas_event_feed_mouse_down(info->e, 1, EVAS_BUTTON_NONE, event_info->timestamp * 1000, NULL); /* + 0.2f just for fake event */ + break; + case DBOX_BUFFER_EVENT_MOVE: + /** + * @note + * Calculate the event occurred X & Y on the buffer + */ + evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, event_info->timestamp * 1000, NULL); + break; + case DBOX_BUFFER_EVENT_UP: + evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, event_info->timestamp * 1000, NULL); + evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, event_info->timestamp * 1000, NULL); + /** + * @note + * We have to keep the event flags, so we should not clear them from here. + * Sometimes, asynchronously callable Callbacks can refer the evas event flags after up event. + * so if we reset them from here, those kind of callbacks will fails to do their job properly. + */ + break; + case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_HIGHLIGHT; + /** + * @note + * Calculate the event occurred X & Y on the buffer + */ + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + ret = elm_access_action(parent_elm, action_type, &action_info); + if (ret == EINA_TRUE) { + if (!get_highlighted_object(parent_elm)) { + ErrPrint("Highlighted object is not found\n"); + ret = DBOX_ACCESS_STATUS_ERROR; + } else { + DbgPrint("Highlighted object is found\n"); + ret = DBOX_ACCESS_STATUS_DONE; + } + } else { + ErrPrint("Action error\n"); + ret = DBOX_ACCESS_STATUS_ERROR; + } + break; + case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT; + action_info.highlight_cycle = EINA_FALSE; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_LAST : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV; + action_info.highlight_cycle = EINA_FALSE; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_FIRST : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_ACTIVATE: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_ACTIVATE; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_ACTION_UP: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_UP; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_ACTION_DOWN: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_DOWN; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_SCROLL_UP: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_SCROLL; + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + action_info.mouse_type = event_info->info.access.mouse_type; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_SCROLL_MOVE: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_SCROLL; + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + action_info.mouse_type = event_info->info.access.mouse_type; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_SCROLL_DOWN: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_SCROLL; + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + action_info.mouse_type = event_info->info.access.mouse_type; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_UNHIGHLIGHT: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_VALUE_CHANGE: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_VALUE_CHANGE; + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + action_info.mouse_type = event_info->info.access.mouse_type; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_MOUSE: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_MOUSE; + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + action_info.mouse_type = event_info->info.access.mouse_type; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_BACK: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_BACK; + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + action_info.mouse_type = event_info->info.access.mouse_type; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_OVER: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_OVER; + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + action_info.mouse_type = event_info->info.access.mouse_type; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_READ: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_READ; + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + action_info.mouse_type = event_info->info.access.mouse_type; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_ENABLE: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_ENABLE; + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + action_info.mouse_type = event_info->info.access.mouse_type; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_DISABLE: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_DISABLE; + action_info.x = event_info->info.access.x; + action_info.y = event_info->info.access.y; + action_info.mouse_type = event_info->info.access.mouse_type; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_KEY_DOWN: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + + key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); + if (key_symbol) { + char *key_name; + char *key_string; + + key_string = XKeysymToString(*key_symbol); + key_name = XKeysymToString(*key_symbol); + DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); + XFree(key_symbol); + XFree(key_name); + XFree(key_string); + } + ret = DBOX_KEY_STATUS_ERROR; + break; + case DBOX_BUFFER_EVENT_KEY_UP: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + + key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); + if (key_symbol) { + char *key_name; + char *key_string; + + key_string = XKeysymToString(*key_symbol); + key_name = XKeysymToString(*key_symbol); + DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); + XFree(key_symbol); + XFree(key_name); + XFree(key_string); + } + ret = DBOX_KEY_STATUS_ERROR; + break; + case DBOX_BUFFER_EVENT_KEY_FOCUS_IN: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + + key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); + if (key_symbol) { + char *key_name; + char *key_string; + + key_string = XKeysymToString(*key_symbol); + key_name = XKeysymToString(*key_symbol); + DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); + XFree(key_symbol); + XFree(key_name); + XFree(key_string); + } + ret = DBOX_KEY_STATUS_ERROR; + break; + case DBOX_BUFFER_EVENT_KEY_FOCUS_OUT: + parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + + key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); + if (key_symbol) { + char *key_name; + char *key_string; + + key_string = XKeysymToString(*key_symbol); + key_name = XKeysymToString(*key_symbol); + DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); + XFree(key_symbol); + XFree(key_name); + XFree(key_string); + } + ret = DBOX_KEY_STATUS_ERROR; + break; + default: + DbgPrint("Unhandled buffer event (%d)\n", event_info->type); + break; + } + + return ret; +} + +/** + * @note + * This callback can be called twice (or more) to get a several pixmaps + * Acquired pixmaps are used for double/tripple buffering for canvas + */ +static Ecore_X_Pixmap alloc_pixmap_cb(void *data, Ecore_X_Window parent, int w, int h, int *depth) { - struct info *info = data; - Elm_Access_Action_Info action_info; - Elm_Access_Action_Type action_type; - int ret = 0; - Evas_Object *parent_elm; - KeySym *key_symbol; - unsigned int flags = 0; - - if (!info->handle) { - /* Just ignore this event */ - return 0; - } - - /** - * @note - * Feed up events - */ - switch (event_info->type) { - case DBOX_BUFFER_EVENT_ON_HOLD: - flags = evas_event_default_flags_get(info->e); - flags |= EVAS_EVENT_FLAG_ON_HOLD; - evas_event_default_flags_set(info->e, flags); - break; - case DBOX_BUFFER_EVENT_OFF_HOLD: - flags = evas_event_default_flags_get(info->e); - flags &= ~EVAS_EVENT_FLAG_ON_HOLD; - evas_event_default_flags_set(info->e, flags); - break; - case DBOX_BUFFER_EVENT_ON_SCROLL: - flags = evas_event_default_flags_get(info->e); - flags |= EVAS_EVENT_FLAG_ON_SCROLL; - evas_event_default_flags_set(info->e, flags); - break; - case DBOX_BUFFER_EVENT_OFF_SCROLL: - flags = evas_event_default_flags_get(info->e); - flags &= ~EVAS_EVENT_FLAG_ON_SCROLL; - evas_event_default_flags_set(info->e, flags); - break; - case DBOX_BUFFER_EVENT_ENTER: - evas_event_feed_mouse_in(info->e, event_info->timestamp * 1000, NULL); - break; - case DBOX_BUFFER_EVENT_LEAVE: - evas_event_feed_mouse_out(info->e, event_info->timestamp * 1000, NULL); - break; - case DBOX_BUFFER_EVENT_DOWN: - /** - * @note - * Before processing the DOWN event, - * Reset the evas event flags regarding ON_HOLD option. - * It can be re-enabled while processing down-move-up events. - */ - flags = evas_event_default_flags_get(info->e); - flags &= ~EVAS_EVENT_FLAG_ON_SCROLL; - flags &= ~EVAS_EVENT_FLAG_ON_HOLD; - evas_event_default_flags_set(info->e, flags); - /** - * @note - * Calculate the event occurred X & Y on the buffer - */ - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, event_info->timestamp * 1000, NULL); - evas_event_feed_mouse_down(info->e, 1, EVAS_BUTTON_NONE, event_info->timestamp * 1000, NULL); /* + 0.2f just for fake event */ - break; - case DBOX_BUFFER_EVENT_MOVE: - /** - * @note - * Calculate the event occurred X & Y on the buffer - */ - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, event_info->timestamp * 1000, NULL); - break; - case DBOX_BUFFER_EVENT_UP: - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, event_info->timestamp * 1000, NULL); - evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, event_info->timestamp * 1000, NULL); - /** - * @note - * We have to keep the event flags, so we should not clear them from here. - * Sometimes, asynchronously callable Callbacks can refer the evas event flags after up event. - * so if we reset them from here, those kind of callbacks will fails to do their job properly. - */ - break; - case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT; - /** - * @note - * Calculate the event occurred X & Y on the buffer - */ - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - ret = elm_access_action(parent_elm, action_type, &action_info); - if (ret == EINA_TRUE) { - if (!get_highlighted_object(parent_elm)) { - ErrPrint("Highlighted object is not found\n"); - ret = DBOX_ACCESS_STATUS_ERROR; - } else { - DbgPrint("Highlighted object is found\n"); - ret = DBOX_ACCESS_STATUS_DONE; - } - } else { - ErrPrint("Action error\n"); - ret = DBOX_ACCESS_STATUS_ERROR; - } - break; - case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT; - action_info.highlight_cycle = EINA_FALSE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_LAST : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV; - action_info.highlight_cycle = EINA_FALSE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_FIRST : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_ACTIVATE: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_ACTIVATE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_ACTION_UP: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_UP; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_ACTION_DOWN: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_DOWN; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_SCROLL_UP: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_SCROLL_MOVE: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_SCROLL_DOWN: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_UNHIGHLIGHT: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_VALUE_CHANGE: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_VALUE_CHANGE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_MOUSE: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_MOUSE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_BACK: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_BACK; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_OVER: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_OVER; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_READ: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_READ; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_ENABLE: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_ENABLE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_DISABLE: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_DISABLE; - action_info.x = event_info->info.access.x; - action_info.y = event_info->info.access.y; - action_info.mouse_type = event_info->info.access.mouse_type; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_KEY_DOWN: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = DBOX_KEY_STATUS_ERROR; - break; - case DBOX_BUFFER_EVENT_KEY_UP: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = DBOX_KEY_STATUS_ERROR; - break; - case DBOX_BUFFER_EVENT_KEY_FOCUS_IN: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = DBOX_KEY_STATUS_ERROR; - break; - case DBOX_BUFFER_EVENT_KEY_FOCUS_OUT: - parent_elm = ecore_evas_data_get(info->ee, DBOX_WIN_TAG); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - - key_symbol = XGetKeyboardMapping(ecore_x_display_get(), event_info->info.keycode, 1, &ret); - if (key_symbol) { - char *key_name; - char *key_string; - - key_string = XKeysymToString(*key_symbol); - key_name = XKeysymToString(*key_symbol); - DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name); - XFree(key_symbol); - XFree(key_name); - XFree(key_string); - } - ret = DBOX_KEY_STATUS_ERROR; - break; - default: - DbgPrint("Unhandled buffer event (%d)\n", event_info->type); - break; - } - - return ret; + vwin_info_t info = data; + Ecore_X_Pixmap pixmap; + int pixel_size = DYNAMICBOX_CONF_DEFAULT_PIXELS; + + if (!info->handle) { + ErrPrint("Invalid handle\n"); + return 0u; + } + + info->w = w; + info->h = h; + *depth = pixel_size << 3; + DbgPrint("Size of ee is updated: %dx%d - %d (info: %p)\n", info->w, info->h, pixel_size, info); + + if (dynamicbox_resource_id(info->handle, DBOX_PRIMARY_BUFFER) == 0u) { + /** + * @note + * Need to allocate a primary buffer + */ + dynamicbox_acquire_buffer(info->handle, DBOX_PRIMARY_BUFFER, info->w, info->h, pixel_size); + if (!info->handle) { + ErrPrint("Failed to get the buffer\n"); + return 0u; + } + + pixmap = (Ecore_X_Pixmap)dynamicbox_resource_id(info->handle, DBOX_PRIMARY_BUFFER); + } else if (DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT > 0) { + int idx; + + if (!info->resource_array) { + info->resource_array = calloc(DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT, sizeof(*info->resource_array)); + if (!info->resource_array) { + ErrPrint("Out of memory: %s\n", strerror(errno)); + return 0u; + } + + idx = 0; + } else { + for (idx = 0; idx < DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT; idx++) { + if (info->resource_array[idx] == 0u) { + break; + } + } + + if (idx == DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT) { + ErrPrint("Out of index: %d\n", idx); + return 0u; + } + } + + if (dynamicbox_acquire_buffer(info->handle, idx, info->w, info->h, pixel_size) < 0) { + ErrPrint("Failed to acquire a buffer for %d\n", idx); + return 0u; + } + + info->resource_array[idx] = dynamicbox_resource_id(info->handle, idx); + if (info->resource_array[idx] == 0u) { + ErrPrint("Failed to allocate pixmap\n"); + } + + DbgPrint("Allocated index: %d/%d - %u\n", idx, DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT, info->resource_array[idx]); + pixmap = info->resource_array[idx]; + } + + /** + * Acquire a buffer for canvas. + */ + info->type = VWIN_PIXMAP; + info->resource_cnt += !!pixmap; + return pixmap; +} + +static void free_pixmap_cb(void *data, Ecore_X_Pixmap pixmap) +{ + vwin_info_t info = data; + + if (!info->handle) { + return; + } + + if (info->type != VWIN_PIXMAP) { + ErrPrint("Impossible\n"); + } + + if (dynamicbox_resource_id(info->handle, DBOX_PRIMARY_BUFFER) == pixmap) { + if (dynamicbox_release_buffer(info->handle, DBOX_PRIMARY_BUFFER) < 0) { + DbgPrint("Failed to release buffer\n"); + } + info->resource_cnt--; + } else { + int idx; + + for (idx = 0; idx < DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT; idx++) { + /** + * @note + * Find a index to release it + */ + if (info->resource_array[idx] == pixmap) { + if (dynamicbox_release_extra_buffer(info->handle, idx) < 0) { + DbgPrint("Failed to release buffer\n"); + } + info->resource_array[idx] = 0u; + info->resource_cnt--; + break; + } + } + } + + if (info->deleted && info->resource_cnt == 0) { + DbgPrint("Destroy buffer handle\n"); + + dynamicbox_destroy_buffer(info->handle); + free(info->resource_array); + free(info->id); + free(info); + } } static void *alloc_fb(void *data, int size) { - struct info *info = data; - void *buffer; - - if (info->ee) { - ecore_evas_geometry_get(info->ee, NULL, NULL, &info->w, &info->h); - DbgPrint("Size of ee is updated: %dx%d (info: %p)\n", info->w, info->h, info); - } - - /** - * Acquire a buffer for canvas. - */ - info->handle = dynamicbox_acquire_buffer(info->id, info->is_gbar, - info->w, info->h, sizeof(int), (dynamicbox_conf_auto_align() || !s_info.alloc_canvas_with_stride), - event_handler_cb, info); - - /** - * If it supports the H/W accelerated buffer, - * Use it. - */ - if (dynamicbox_support_hw_buffer(info->handle)) { - if (dynamicbox_create_hw_buffer(info->handle) == 0) { - buffer = dynamicbox_buffer_hw_buffer(info->handle); - if (buffer) { - DbgPrint("HW Accelerated buffer is created %p, (%dx%d)\n", info, info->w, info->h); - info->is_hw = 1; - return buffer; - } - } - - ErrPrint("Failed to allocate HW Accelerated buffer\n"); - } - - /** - * Or use the buffer of a S/W backend. - */ - buffer = dynamicbox_ref_buffer(info->handle); - DbgPrint("SW buffer is created (%dx%d)\n", info->w, info->h); - info->is_hw = 0; - return buffer; + vwin_info_t info = data; + void *buffer; + + if (info->ee) { + ecore_evas_geometry_get(info->ee, NULL, NULL, &info->w, &info->h); + DbgPrint("Size of ee is updated: %dx%d (info: %p)\n", info->w, info->h, info); + } + + if (!info->handle) { + ErrPrint("Failed to create a buffer\n"); + return NULL; + } + + if (dynamicbox_acquire_buffer(info->handle, DBOX_PRIMARY_BUFFER, info->w, info->h, sizeof(int)) < 0) { + ErrPrint("Failed to acquire buffer\n"); + return NULL; + } + + /** + * If it supports the H/W accelerated buffer, + * Use it. + */ + if (dynamicbox_support_hw_buffer(info->handle)) { + if (dynamicbox_create_hw_buffer(info->handle) == 0) { + buffer = dynamicbox_buffer_hw_buffer(info->handle); + if (buffer) { + DbgPrint("HW Accelerated buffer is created %p, (%dx%d)\n", info, info->w, info->h); + info->type = VWIN_GEM; + return buffer; + } + } + + ErrPrint("Failed to allocate HW Accelerated buffer\n"); + } + + /** + * Or use the buffer of a S/W backend. + */ + buffer = dynamicbox_ref_buffer(info->handle); + DbgPrint("SW buffer is created (%dx%d)\n", info->w, info->h); + info->type = VWIN_SW_BUF; + return buffer; } static void *alloc_stride_fb(void *data, int size, int *stride, int *bpp) { - void *buffer; + void *buffer; - buffer = alloc_fb(data, size); - if (buffer) { - struct info *info = data; - int _stride; + buffer = alloc_fb(data, size); + if (buffer) { + vwin_info_t info = data; + int _stride; - *bpp = sizeof(int); - _stride = dynamicbox_buffer_stride(info->handle); - if (_stride < 0) { - _stride = info->w * *bpp; - } + *bpp = sizeof(int); + _stride = dynamicbox_buffer_stride(info->handle); + if (_stride < 0) { + _stride = info->w * *bpp; + } - *stride = _stride; - *bpp <<= 3; - DbgPrint("bpp: %d, stride: %d\n", *bpp, *stride); - } + *stride = _stride; + *bpp <<= 3; + DbgPrint("bpp: %d, stride: %d\n", *bpp, *stride); + } - return buffer; + return buffer; } static void free_fb(void *data, void *ptr) { - struct info *info = data; - - if (!info->handle) { - return; - } - - if (info->is_hw) { - if (dynamicbox_destroy_hw_buffer(info->handle) == 0) { - DbgPrint("HW Accelerated buffer is destroyed\n"); - } - } else { - DbgPrint("SW buffer is destroyed, %p\n", info); - dynamicbox_unref_buffer(ptr); - } - - dynamicbox_release_buffer(info->handle); - info->handle = NULL; - - if (info->deleted) { - free(info->id); - info->id = NULL; - - free(info); - } + vwin_info_t info = data; + + if (!info->handle) { + return; + } + + if (info->type == VWIN_GEM) { + if (dynamicbox_destroy_hw_buffer(info->handle) == 0) { + DbgPrint("HW Accelerated buffer is destroyed\n"); + } + } else if (info->type == VWIN_SW_BUF) { + DbgPrint("SW buffer is destroyed, %p\n", info); + dynamicbox_unref_buffer(ptr); + } else if (info->type == VWIN_PIXMAP) { + ErrPrint("Unable to reach to here\n"); + } + + if (dynamicbox_release_buffer(info->handle, DBOX_PRIMARY_BUFFER) < 0) { + ErrPrint("Failed to release buffer\n"); + } + + if (info->deleted) { + dynamicbox_destroy_buffer(info->handle); + free(info->resource_array); + free(info->id); + free(info); + } } static void pre_render_cb(void *data, Evas *e, void *event_info) { - struct info *info = data; - - if (!info->handle) { - return; - } - - if (dynamicbox_conf_premultiplied_alpha()) { - Evas_Coord w; - Evas_Coord h; - - ecore_evas_geometry_get(info->ee, NULL, NULL, &w, &h); - evas_damage_rectangle_add(e, 0, 0, w, h); - } - - if (info->is_hw) { - dynamicbox_buffer_pre_render(info->handle); - } + vwin_info_t info = data; + + if (!info->handle) { + return; + } + + if (dynamicbox_conf_premultiplied_alpha()) { + Evas_Coord w; + Evas_Coord h; + + ecore_evas_geometry_get(info->ee, NULL, NULL, &w, &h); + evas_damage_rectangle_add(e, 0, 0, w, h); + } + + if (info->type == VWIN_GEM) { + dynamicbox_buffer_pre_render(info->handle); + } else if (info->type == VWIN_PIXMAP) { + /** + * Only the pixmap type Ecore_Evas uses this variable + */ + info->front_resource_id = ecore_evas_gl_x11_pixmap_get(info->ee); + } else if (info->type == VWIN_SW_BUF) { + /* Do nothing */ + } } static void post_render_cb(void *data, Evas *e, void *event_info) { - struct info *info = data; - - if (!info->handle) { - return; - } - - if (dynamicbox_conf_premultiplied_alpha()) { - void *canvas; - int x, y, w, h; - - // Get a pointer of a buffer of the virtual canvas - canvas = (void *)ecore_evas_buffer_pixels_get(info->ee); - if (!canvas) { - ErrPrint("Failed to get pixel canvas\n"); - return; - } - - ecore_evas_geometry_get(info->ee, &x, &y, &w, &h); - evas_data_argb_unpremul(canvas, w * h); - } - - if (info->is_hw) { - dynamicbox_buffer_post_render(info->handle); - } else { - dynamicbox_sync_buffer(info->handle); - } + vwin_info_t info = data; + + if (!info->handle) { + return; + } + + if (dynamicbox_conf_premultiplied_alpha()) { + void *canvas; + int x, y, w, h; + + // Get a pointer of a buffer of the virtual canvas + canvas = (void *)ecore_evas_buffer_pixels_get(info->ee); + if (!canvas) { + ErrPrint("Failed to get pixel canvas\n"); + return; + } + + ecore_evas_geometry_get(info->ee, &x, &y, &w, &h); + evas_data_argb_unpremul(canvas, w * h); + } + + if (info->type == VWIN_GEM) { + dynamicbox_buffer_post_render(info->handle); + } else if (info->type == VWIN_PIXMAP) { + int idx; + + for (idx = 0; idx < DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT; idx++) { + if (info->front_resource_id == info->resource_array[idx]) { + /** + */ + dynamicbox_send_updated_by_idx(info->handle, idx); + break; + } + } + + if (idx == DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT) { + /* Send updated event for PRIMARY BUFFER */ + dynamicbox_send_updated_by_idx(info->handle, DBOX_PRIMARY_BUFFER); + } + } else if (info->type == VWIN_SW_BUF) { + dynamicbox_sync_buffer(info->handle); + } } static void ecore_evas_free_cb(Ecore_Evas *ee) { - struct info *info; + vwin_info_t info; - info = ecore_evas_data_get(ee, "dynamic,box,info"); - if (!info) { - DbgPrint("Info is not valid\n"); - return; - } + info = ecore_evas_data_get(ee, "dynamic,box,info"); + if (!info) { + DbgPrint("Info is not valid\n"); + return; + } - if (info->e) { - evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb); - evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb); - } + if (info->e) { + evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb); + evas_event_callback_del(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb); + } - info->deleted = 1; - info->ee = NULL; + info->deleted = 1; + info->ee = NULL; } PUBLIC void *dynamicbox_get_evas_object(const char *id, int is_gbar) { - struct info *info; - Evas_Object *rect; - - if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride) { - s_info.alloc_canvas_with_stride = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_with_stride_new"); - if (!s_info.alloc_canvas_with_stride) { - DbgPrint("allocfunc_with_stirde_new is not found\n"); - } - - s_info.alloc_canvas = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_new"); - if (!s_info.alloc_canvas) { - ErrPrint("allocfunc_new is not found\n"); - } - - if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas) { - ErrPrint("No way to allocate canvas\n"); - return NULL; - } - } - - if (!id) { - ErrPrint("Invalid parameter\n"); - return NULL; - } - - info = calloc(1, sizeof(*info)); - if (!info) { - ErrPrint("Heap: %s\n", strerror(errno)); - return NULL; - } - - info->id = strdup(id); - if (!info->id) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(info); - return NULL; - } - - info->is_gbar = is_gbar; - - /** - * Size information must be initialized before call the ecore_evas_buffer_new. - */ - info->w = 1; - info->h = 1; - - if (!dynamicbox_conf_auto_align() && s_info.alloc_canvas_with_stride) { - info->ee = s_info.alloc_canvas_with_stride(1, 1, alloc_stride_fb, free_fb, info); - } else if (s_info.alloc_canvas) { - info->ee = s_info.alloc_canvas(1, 1, alloc_fb, free_fb, info); - } - - if (!info->ee) { - ErrPrint("Failed to create ecore_evas (%dx%d)\n", 1, 1); - free(info->id); - free(info); - return NULL; - } - - ecore_evas_data_set(info->ee, "dynamic,box,info", info); - ecore_evas_callback_pre_free_set(info->ee, ecore_evas_free_cb); - - info->e = ecore_evas_get(info->ee); - if (!info->e) { - ErrPrint("Failed to get evas\n"); - ecore_evas_free(info->ee); - return NULL; - } - - pre_render_cb(info, NULL, NULL); - ecore_evas_alpha_set(info->ee, EINA_TRUE); - post_render_cb(info, NULL, NULL); - - ecore_evas_manual_render_set(info->ee, EINA_FALSE); - ecore_evas_resize(info->ee, 1, 1); - - evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb, info); - evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, info); - - rect = evas_object_rectangle_add(info->e); - if (!rect) { - ErrPrint("Failed to create evas_object\n"); - ecore_evas_free(info->ee); - return NULL; - } - - evas_object_resize(rect, 1, 1); - evas_object_color_set(rect, 0, 0, 0, 0); - return rect; + vwin_info_t info; + Evas_Object *rect; + const char *engine; + + if (!s_info.alloc_canvas && !s_info.alloc_canvas_with_stride && !s_info.alloc_canvas_with_pixmap) { + s_info.alloc_canvas_with_pixmap = dlsym(RTLD_DEFAULT, "ecore_evas_gl_x11_pixmap_allocfunc_new"); + if (!s_info.alloc_canvas_with_pixmap) { + DbgPrint("pixmap_allocfunc_new is not found\n"); + } + + s_info.alloc_canvas_with_stride = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_with_stride_new"); + if (!s_info.alloc_canvas_with_stride) { + DbgPrint("allocfunc_with_stirde_new is not found\n"); + } + + s_info.alloc_canvas = dlsym(RTLD_DEFAULT, "ecore_evas_buffer_allocfunc_new"); + if (!s_info.alloc_canvas) { + ErrPrint("allocfunc_new is not found\n"); + } + + if (!s_info.alloc_canvas_with_stride && !s_info.alloc_canvas && !s_info.alloc_canvas_with_pixmap) { + ErrPrint("No way to allocate canvas\n"); + return NULL; + } + } + + if (!id) { + ErrPrint("Invalid parameter\n"); + return NULL; + } + + info = calloc(1, sizeof(*info)); + if (!info) { + ErrPrint("Heap: %s\n", strerror(errno)); + return NULL; + } + + info->id = strdup(id); + if (!info->id) { + ErrPrint("Heap: %s\n", strerror(errno)); + free(info); + return NULL; + } + + info->is_gbar = is_gbar; + + /** + * Acquire a buffer for canvas. + */ + info->handle = dynamicbox_create_buffer(info->id, info->is_gbar, + (dynamicbox_conf_auto_align() || !s_info.alloc_canvas_with_stride), + event_handler_cb, info); + + if (!info->handle) { + ErrPrint("Failed to create a dynamicbox buffer\n"); + free(info->id); + free(info); + return NULL; + } + + /** + * Size information must be initialized before call the ecore_evas_buffer_new. + */ + info->w = DBOX_DEFAULT_WIDTH; + info->h = DBOX_DEFAULT_HEIGHT; + + engine = elm_config_preferred_engine_get(); + DbgPrint("Preferred engine: %s (%s)\n", engine, GL_ENGINE); + if (engine && !strcmp(engine, GL_ENGINE)) { + if (s_info.alloc_canvas_with_pixmap) { + info->ee = s_info.alloc_canvas_with_pixmap(NULL, 0u, 0, 0, info->w, info->h, alloc_pixmap_cb, free_pixmap_cb, info); + if (!info->ee) { + ErrPrint("Unable to create a ee for pixmap\n"); + } + } + } + + if (!info->ee) { + if (!dynamicbox_conf_auto_align() && s_info.alloc_canvas_with_stride) { + info->ee = s_info.alloc_canvas_with_stride(info->w, info->h, alloc_stride_fb, free_fb, info); + } else if (s_info.alloc_canvas) { + info->ee = s_info.alloc_canvas(info->w, info->h, alloc_fb, free_fb, info); + } + } + + if (!info->ee) { + ErrPrint("Failed to create ecore_evas (%dx%d)\n", info->w, info->h); + dynamicbox_destroy_buffer(info->handle); + free(info->id); + free(info); + return NULL; + } + + ecore_evas_data_set(info->ee, "dynamic,box,info", info); + + /** + * @note + * Free callback must be prepared before use the ecore_evas_free() + */ + ecore_evas_callback_pre_free_set(info->ee, ecore_evas_free_cb); + + info->e = ecore_evas_get(info->ee); + if (!info->e) { + ErrPrint("Failed to get evas\n"); + ecore_evas_free(info->ee); + return NULL; + } + + pre_render_cb(info, NULL, NULL); + ecore_evas_alpha_set(info->ee, EINA_TRUE); + post_render_cb(info, NULL, NULL); + + ecore_evas_manual_render_set(info->ee, EINA_FALSE); + ecore_evas_resize(info->ee, info->w, info->h); + + evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb, info); + evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, info); + + rect = evas_object_rectangle_add(info->e); + if (!rect) { + ErrPrint("Failed to create evas_object\n"); + ecore_evas_free(info->ee); + return NULL; + } + + evas_object_resize(rect, info->w, info->h); + evas_object_color_set(rect, 0, 0, 0, 0); + return rect; } /* End of a file */ diff --git a/src/virtual_window_wayland.c b/src/virtual_window_wayland.c index bbc240e..b9c5f26 100644 --- a/src/virtual_window_wayland.c +++ b/src/virtual_window_wayland.c @@ -1,3 +1,19 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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. + */ + #include #include #include @@ -20,23 +36,23 @@ * Abstracted Data Type of Virtual Window */ struct info { - char *id; /*!< Identification */ - struct dynamicbox_buffer *handle; /*!< Livebox buffer handle */ - int is_hw; /*!< 1 if a buffer is created on the H/W accelerated place or 0 */ - Ecore_Evas *ee; - Evas *e; - int is_gbar; + char *id; /*!< Identification */ + struct dynamicbox_buffer *handle; /*!< Livebox buffer handle */ + int is_hw; /*!< 1 if a buffer is created on the H/W accelerated place or 0 */ + Ecore_Evas *ee; + Evas *e; + int is_gbar; }; static inline Evas_Object *get_highlighted_object(Evas_Object *obj) { - Evas_Object *o, *ho; + Evas_Object *o, *ho; - o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp"); - if (!o) return NULL; + o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp"); + if (!o) return NULL; - ho = evas_object_data_get(o, "_elm_access_target"); - return ho; + ho = evas_object_data_get(o, "_elm_access_target"); + return ho; } /*! @@ -45,389 +61,389 @@ static inline Evas_Object *get_highlighted_object(Evas_Object *obj) */ static int event_handler_cb(struct dynamicbox_buffer *handler, struct dynamicbox_buffer_event_data *event_info, void *data) { - struct info *info = data; - Elm_Access_Action_Info action_info; - Elm_Access_Action_Type action_type; - int ret = 0; - Evas_Object *parent_elm; - - - if (!info->handle) { - /* Just ignore this event */ - return 0; - } - - /*! - * \note - * Feed up events - */ - switch (event_info->type) { - case DBOX_BUFFER_EVENT_ENTER: - evas_event_feed_mouse_in(info->e, event_info->timestamp * 1000, NULL); - break; - case DBOX_BUFFER_EVENT_LEAVE: - evas_event_feed_mouse_out(info->e, event_info->timestamp * 1000, NULL); - break; - case DBOX_BUFFER_EVENT_DOWN: - /*! - * \note - * Calculate the event occurred X & Y on the buffer - */ - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, (event_info->timestamp - 0.001f) * 1000, NULL); /* + 0.1f just for fake event */ - evas_event_feed_mouse_down(info->e, 1, EVAS_BUTTON_NONE, event_info->timestamp * 1000, NULL); /* + 0.2f just for fake event */ - break; - case DBOX_BUFFER_EVENT_MOVE: - /*! - * \note - * Calculate the event occurred X & Y on the buffer - */ - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, event_info->timestamp * 1000, NULL); - break; - case DBOX_BUFFER_EVENT_UP: - evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, event_info->timestamp * 1000, NULL); - evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, (event_info->timestamp + 0.001f) * 1000, NULL); - break; - case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT; - /*! - * \note - * Calculate the event occurred X & Y on the buffer - */ - action_info.x = event_info->info.pointer.x; - action_info.y = event_info->info.pointer.y; - ret = elm_access_action(parent_elm, action_type, &action_info); - if (ret == EINA_TRUE) { - if (!get_highlighted_object(parent_elm)) { - LOGE("Highlighted object is not found\n"); - ret = DBOX_ACCESS_STATUS_ERROR; - } else { - LOGD("Highlighted object is found\n"); - ret = DBOX_ACCESS_STATUS_DONE; - } - } else { - LOGE("Action error\n"); - ret = DBOX_ACCESS_STATUS_ERROR; - } - break; - case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT; - action_info.highlight_cycle = EINA_FALSE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_LAST : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV; - action_info.highlight_cycle = EINA_FALSE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_FIRST : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_ACTIVATE: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_ACTIVATE; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_ACTION_UP: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_UP; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_ACTION_DOWN: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_DOWN; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_SCROLL_UP: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.pointer.x; - action_info.y = event_info->info.pointer.y; - action_info.mouse_type = 2; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_SCROLL_MOVE: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.pointer.x; - action_info.y = event_info->info.pointer.y; - action_info.mouse_type = 1; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_SCROLL_DOWN: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_SCROLL; - action_info.x = event_info->info.pointer.x; - action_info.y = event_info->info.pointer.y; - action_info.mouse_type = 0; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_ACCESS_UNHIGHLIGHT: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - memset(&action_info, 0, sizeof(action_info)); - action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT; - ret = elm_access_action(parent_elm, action_type, &action_info); - ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; - break; - case DBOX_BUFFER_EVENT_KEY_DOWN: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - - ret = DBOX_KEY_STATUS_ERROR; - break; - case DBOX_BUFFER_EVENT_KEY_UP: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - - ret = DBOX_KEY_STATUS_ERROR; - break; - case DBOX_BUFFER_EVENT_KEY_FOCUS_IN: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - - ret = DBOX_KEY_STATUS_ERROR; - break; - case DBOX_BUFFER_EVENT_KEY_FOCUS_OUT: - parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); - if (!parent_elm) { - ret = DBOX_ACCESS_STATUS_ERROR; - break; - } - - ret = DBOX_KEY_STATUS_ERROR; - break; - default: - LOGD("Unhandled buffer event (%d)\n", event_info->type); - break; - } - - return ret; + struct info *info = data; + Elm_Access_Action_Info action_info; + Elm_Access_Action_Type action_type; + int ret = 0; + Evas_Object *parent_elm; + + + if (!info->handle) { + /* Just ignore this event */ + return 0; + } + + /*! + * \note + * Feed up events + */ + switch (event_info->type) { + case DBOX_BUFFER_EVENT_ENTER: + evas_event_feed_mouse_in(info->e, event_info->timestamp * 1000, NULL); + break; + case DBOX_BUFFER_EVENT_LEAVE: + evas_event_feed_mouse_out(info->e, event_info->timestamp * 1000, NULL); + break; + case DBOX_BUFFER_EVENT_DOWN: + /*! + * \note + * Calculate the event occurred X & Y on the buffer + */ + evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, (event_info->timestamp - 0.001f) * 1000, NULL); /* + 0.1f just for fake event */ + evas_event_feed_mouse_down(info->e, 1, EVAS_BUTTON_NONE, event_info->timestamp * 1000, NULL); /* + 0.2f just for fake event */ + break; + case DBOX_BUFFER_EVENT_MOVE: + /*! + * \note + * Calculate the event occurred X & Y on the buffer + */ + evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, event_info->timestamp * 1000, NULL); + break; + case DBOX_BUFFER_EVENT_UP: + evas_event_feed_mouse_move(info->e, event_info->info.pointer.x, event_info->info.pointer.y, event_info->timestamp * 1000, NULL); + evas_event_feed_mouse_up(info->e, 1, EVAS_BUTTON_NONE, (event_info->timestamp + 0.001f) * 1000, NULL); + break; + case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_HIGHLIGHT; + /*! + * \note + * Calculate the event occurred X & Y on the buffer + */ + action_info.x = event_info->info.pointer.x; + action_info.y = event_info->info.pointer.y; + ret = elm_access_action(parent_elm, action_type, &action_info); + if (ret == EINA_TRUE) { + if (!get_highlighted_object(parent_elm)) { + LOGE("Highlighted object is not found\n"); + ret = DBOX_ACCESS_STATUS_ERROR; + } else { + LOGD("Highlighted object is found\n"); + ret = DBOX_ACCESS_STATUS_DONE; + } + } else { + LOGE("Action error\n"); + ret = DBOX_ACCESS_STATUS_ERROR; + } + break; + case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_NEXT: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT; + action_info.highlight_cycle = EINA_FALSE; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_LAST : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_HIGHLIGHT_PREV: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_HIGHLIGHT_PREV; + action_info.highlight_cycle = EINA_FALSE; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_FIRST : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_ACTIVATE: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_ACTIVATE; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_ACTION_UP: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_UP; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_ACTION_DOWN: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_DOWN; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_SCROLL_UP: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_SCROLL; + action_info.x = event_info->info.pointer.x; + action_info.y = event_info->info.pointer.y; + action_info.mouse_type = 2; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_SCROLL_MOVE: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_SCROLL; + action_info.x = event_info->info.pointer.x; + action_info.y = event_info->info.pointer.y; + action_info.mouse_type = 1; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_SCROLL_DOWN: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_SCROLL; + action_info.x = event_info->info.pointer.x; + action_info.y = event_info->info.pointer.y; + action_info.mouse_type = 0; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_ACCESS_UNHIGHLIGHT: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + memset(&action_info, 0, sizeof(action_info)); + action_type = ELM_ACCESS_ACTION_UNHIGHLIGHT; + ret = elm_access_action(parent_elm, action_type, &action_info); + ret = (ret == EINA_FALSE) ? DBOX_ACCESS_STATUS_ERROR : DBOX_ACCESS_STATUS_DONE; + break; + case DBOX_BUFFER_EVENT_KEY_DOWN: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + + ret = DBOX_KEY_STATUS_ERROR; + break; + case DBOX_BUFFER_EVENT_KEY_UP: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + + ret = DBOX_KEY_STATUS_ERROR; + break; + case DBOX_BUFFER_EVENT_KEY_FOCUS_IN: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + + ret = DBOX_KEY_STATUS_ERROR; + break; + case DBOX_BUFFER_EVENT_KEY_FOCUS_OUT: + parent_elm = ecore_evas_data_get(info->ee, "dynamic,box,win"); + if (!parent_elm) { + ret = DBOX_ACCESS_STATUS_ERROR; + break; + } + + ret = DBOX_KEY_STATUS_ERROR; + break; + default: + LOGD("Unhandled buffer event (%d)\n", event_info->type); + break; + } + + return ret; } static void *alloc_fb(void *data, int size) { - struct info *info = data; - void *buffer; - int width = 0; - int height = 0; - - if (info->ee == NULL) { - width = 1; - height = 1; - } else { - ecore_evas_geometry_get(info->ee, NULL, NULL, &width, &height); - } - - /*! - * Acquire a buffer for canvas. - */ - info->handle = dynamicbox_acquire_buffer(info->id, info->is_gbar, - width, height, - event_handler_cb, info); - - /*! - * If it supports the H/W accelerated buffer, - * Use it. - */ - if (dynamicbox_support_hw_buffer(info->handle)) { - if (dynamicbox_create_hw_buffer(info->handle) == 0) { - buffer = dynamicbox_buffer_hw_buffer(info->handle); - if (buffer) { - LOGD("HW Accelerated buffer is created\n"); - info->is_hw = 1; - return buffer; - } - } - - LOGE("Failed to allocate HW Accelerated buffer\n"); - } - - /*! - * Or use the buffer of a S/W backend. - */ - buffer = dynamicbox_ref_buffer(info->handle); - LOGD("SW buffer is created\n"); - info->is_hw = 0; - return buffer; + struct info *info = data; + void *buffer; + int width = 0; + int height = 0; + + if (info->ee == NULL) { + width = 1; + height = 1; + } else { + ecore_evas_geometry_get(info->ee, NULL, NULL, &width, &height); + } + + /*! + * Acquire a buffer for canvas. + */ + info->handle = dynamicbox_acquire_buffer(info->id, info->is_gbar, + width, height, + event_handler_cb, info); + + /*! + * If it supports the H/W accelerated buffer, + * Use it. + */ + if (dynamicbox_support_hw_buffer(info->handle)) { + if (dynamicbox_create_hw_buffer(info->handle) == 0) { + buffer = dynamicbox_buffer_hw_buffer(info->handle); + if (buffer) { + LOGD("HW Accelerated buffer is created\n"); + info->is_hw = 1; + return buffer; + } + } + + LOGE("Failed to allocate HW Accelerated buffer\n"); + } + + /*! + * Or use the buffer of a S/W backend. + */ + buffer = dynamicbox_ref_buffer(info->handle); + LOGD("SW buffer is created\n"); + info->is_hw = 0; + return buffer; } static void free_fb(void *data, void *ptr) { - struct info *info = data; + struct info *info = data; - if (!info->handle) { - return; - } + if (!info->handle) { + return; + } - if (info->is_hw) { - if (dynamicbox_destroy_hw_buffer(info->handle) == 0) { - LOGD("HW Accelerated buffer is destroyed\n"); - goto out; - } - } + if (info->is_hw) { + if (dynamicbox_destroy_hw_buffer(info->handle) == 0) { + LOGD("HW Accelerated buffer is destroyed\n"); + goto out; + } + } - dynamicbox_unref_buffer(ptr); - LOGD("SW buffer is destroyed\n"); + dynamicbox_unref_buffer(ptr); + LOGD("SW buffer is destroyed\n"); out: - dynamicbox_release_buffer(info->handle); - info->handle = NULL; + dynamicbox_release_buffer(info->handle); + info->handle = NULL; } static void pre_render_cb(void *data, Evas *e, void *event_info) { - struct info *info = data; + struct info *info = data; - if (!info->handle) { - return; - } + if (!info->handle) { + return; + } - if (info->is_hw) { - dynamicbox_buffer_pre_render(info->handle); - } + if (info->is_hw) { + dynamicbox_buffer_pre_render(info->handle); + } } static void post_render_cb(void *data, Evas *e, void *event_info) { - struct info *info = data; + struct info *info = data; - if (!info->handle) { - return; - } + if (!info->handle) { + return; + } - if (info->is_hw) { - dynamicbox_buffer_post_render(info->handle); - } else { - dynamicbox_sync_buffer(info->handle); - } + if (info->is_hw) { + dynamicbox_buffer_post_render(info->handle); + } else { + dynamicbox_sync_buffer(info->handle); + } } PUBLIC void *dynamicbox_get_evas_object(const char *id, int is_gbar) { - struct info *info; - Evas_Object *rect; - - if (!id) { - ErrPrint("Invalid parameter\n"); - return NULL; - } - - info = calloc(1, sizeof(*info)); - if (!info) { - ErrPrint("Heap: %s\n", strerror(errno)); - return NULL; - } - - info->id = strdup(id); - if (!info->id) { - ErrPrint("Heap: %s\n", strerror(errno)); - free(info); - return NULL; - } - - info->is_gbar = is_gbar; - - info->ee = ecore_evas_buffer_allocfunc_new(1, 1, alloc_fb, free_fb, info); - if (!info->ee) { - ErrPrint("Failed to create ecore_evas (%dx%d)\n", 1, 1); - free(info->id); - free(info); - return NULL; - } - - pre_render_cb(info, NULL, NULL); - ecore_evas_alpha_set(info->ee, EINA_TRUE); - post_render_cb(info, NULL, NULL); - - ecore_evas_data_set(info->ee, "dynamic,box,info", info); - - ecore_evas_manual_render_set(info->ee, EINA_FALSE); - ecore_evas_resize(info->ee, 1, 1); - - info->e = ecore_evas_get(info->ee); - if (!info->e) { - ErrPrint("Failed to get evas\n"); - ecore_evas_free(info->ee); - return NULL; - } - - evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb, info); - evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, info); - - rect = evas_object_rectangle_add(info->e); - if (!rect) { - ErrPrint("Failed to create evas_object\n"); - ecore_evas_free(info->ee); - return NULL; - } - - evas_object_resize(rect, 1, 1); - evas_object_color_set(rect, 0, 0, 0, 0); - return rect; + struct info *info; + Evas_Object *rect; + + if (!id) { + ErrPrint("Invalid parameter\n"); + return NULL; + } + + info = calloc(1, sizeof(*info)); + if (!info) { + ErrPrint("Heap: %s\n", strerror(errno)); + return NULL; + } + + info->id = strdup(id); + if (!info->id) { + ErrPrint("Heap: %s\n", strerror(errno)); + free(info); + return NULL; + } + + info->is_gbar = is_gbar; + + info->ee = ecore_evas_buffer_allocfunc_new(1, 1, alloc_fb, free_fb, info); + if (!info->ee) { + ErrPrint("Failed to create ecore_evas (%dx%d)\n", 1, 1); + free(info->id); + free(info); + return NULL; + } + + pre_render_cb(info, NULL, NULL); + ecore_evas_alpha_set(info->ee, EINA_TRUE); + post_render_cb(info, NULL, NULL); + + ecore_evas_data_set(info->ee, "dynamic,box,info", info); + + ecore_evas_manual_render_set(info->ee, EINA_FALSE); + ecore_evas_resize(info->ee, 1, 1); + + info->e = ecore_evas_get(info->ee); + if (!info->e) { + ErrPrint("Failed to get evas\n"); + ecore_evas_free(info->ee); + return NULL; + } + + evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_POST, post_render_cb, info); + evas_event_callback_add(info->e, EVAS_CALLBACK_RENDER_PRE, pre_render_cb, info); + + rect = evas_object_rectangle_add(info->e); + if (!rect) { + ErrPrint("Failed to create evas_object\n"); + ecore_evas_free(info->ee); + return NULL; + } + + evas_object_resize(rect, 1, 1); + evas_object_color_set(rect, 0, 0, 0, 0); + return rect; } /* End of a file */