summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-02-01 04:07:33 (GMT)
committerjk7744.park <jk7744.park@samsung.com>2015-02-01 04:07:33 (GMT)
commit3a0041b2cb0ac93493b0d09028fd7a6aa000ce25 (patch)
treecb77e7a98de2fceb5fe600850f7118996e2595ad
parent04f10f139af88753993d4ee89d53d7a8ed04d648 (diff)
downloadlivebox-viewer-tizen_2.3.zip
livebox-viewer-tizen_2.3.tar.gz
livebox-viewer-tizen_2.3.tar.bz2
-rw-r--r--CMakeLists.txt95
-rw-r--r--TC/testcase/Makefile27
-rw-r--r--TC/testcase/tslist2
-rwxr-xr-xTC/testcase/utc_livebox_viewerbin247137 -> 0 bytes
-rw-r--r--TC/testcase/utc_livebox_viewer.c2456
-rw-r--r--doc/livebox-viewer_doc.h125
-rw-r--r--dynamicbox_viewer/CMakeLists.txt98
-rw-r--r--dynamicbox_viewer/LICENSE (renamed from LICENSE)0
-rw-r--r--dynamicbox_viewer/doc/dynamicbox_viewer_doc.h197
-rw-r--r--dynamicbox_viewer/doc/image/PD.png (renamed from doc/image/PD.png)bin23224 -> 23224 bytes
-rw-r--r--dynamicbox_viewer/doc/image/download_folder.png (renamed from doc/image/download_folder.png)bin34630 -> 34630 bytes
-rw-r--r--dynamicbox_viewer/doc/image/front.jpg (renamed from doc/image/front.jpg)bin61126 -> 61126 bytes
-rw-r--r--dynamicbox_viewer/doc/image/image_format.png (renamed from doc/image/image_format.png)bin82415 -> 82415 bytes
-rw-r--r--dynamicbox_viewer/doc/image/message.png (renamed from doc/image/message.png)bin28543 -> 28543 bytes
-rw-r--r--dynamicbox_viewer/doc/image/preload_folder.png (renamed from doc/image/preload_folder.png)bin39070 -> 39070 bytes
-rw-r--r--dynamicbox_viewer/doc/image/script_format.png (renamed from doc/image/script_format.png)bin82052 -> 82052 bytes
-rw-r--r--dynamicbox_viewer/doc/image/stock.png (renamed from doc/image/stock.png)bin19879 -> 19879 bytes
-rw-r--r--dynamicbox_viewer/doc/image/text_format.png (renamed from doc/image/text_format.png)bin84551 -> 84551 bytes
-rw-r--r--dynamicbox_viewer/doc/image/twitter.png (renamed from doc/image/twitter.png)bin45791 -> 45791 bytes
-rw-r--r--dynamicbox_viewer/doc/image/weather.png (renamed from doc/image/weather.png)bin58862 -> 58862 bytes
-rw-r--r--dynamicbox_viewer/dynamicbox_viewer.pc.in12
-rw-r--r--dynamicbox_viewer/include/client.h (renamed from include/client.h)2
-rw-r--r--dynamicbox_viewer/include/conf.h (renamed from include/conf.h)14
-rw-r--r--dynamicbox_viewer/include/debug.h (renamed from include/debug.h)4
-rw-r--r--dynamicbox_viewer/include/desc_parser.h (renamed from include/desc_parser.h)2
-rw-r--r--dynamicbox_viewer/include/dlist.h (renamed from live.viewer/include/dlist.h)14
-rw-r--r--dynamicbox_viewer/include/dynamicbox.h1675
-rw-r--r--dynamicbox_viewer/include/dynamicbox_internal.h270
-rw-r--r--dynamicbox_viewer/include/fb.h (renamed from include/fb.h)9
-rw-r--r--dynamicbox_viewer/include/file_service.h (renamed from include/file_service.h)0
-rw-r--r--dynamicbox_viewer/include/master_rpc.h (renamed from include/master_rpc.h)4
-rw-r--r--dynamicbox_viewer/include/util.h (renamed from include/util.h)7
-rw-r--r--dynamicbox_viewer/src/client.c2296
-rw-r--r--dynamicbox_viewer/src/conf.c82
-rw-r--r--dynamicbox_viewer/src/desc_parser.c698
-rw-r--r--dynamicbox_viewer/src/dlist.c189
-rw-r--r--dynamicbox_viewer/src/dynamicbox.c4115
-rw-r--r--dynamicbox_viewer/src/dynamicbox_internal.c1058
-rw-r--r--dynamicbox_viewer/src/fb.c674
-rw-r--r--dynamicbox_viewer/src/fb_wayland.c451
-rw-r--r--dynamicbox_viewer/src/file_service.c715
-rw-r--r--dynamicbox_viewer/src/master_rpc.c318
-rw-r--r--dynamicbox_viewer/src/util.c150
-rw-r--r--include/dlist.h43
-rw-r--r--include/livebox.h1753
-rw-r--r--include/livebox_internal.h255
-rw-r--r--live.viewer/CMakeLists.txt48
-rw-r--r--live.viewer/image/folder0
-rw-r--r--live.viewer/include/debug.h27
-rw-r--r--live.viewer/include/lb.h21
-rw-r--r--live.viewer/include/live_scroller.h57
-rw-r--r--live.viewer/include/main.h17
-rw-r--r--live.viewer/include/scroller.h44
-rw-r--r--live.viewer/include/util.h19
-rw-r--r--live.viewer/live.viewer.xml12
-rw-r--r--live.viewer/packaging/live.viewer.spec41
-rw-r--r--live.viewer/res/CMakeLists.txt7
-rw-r--r--live.viewer/res/live-viewer.edc175
-rw-r--r--live.viewer/src/dlist.c180
-rw-r--r--live.viewer/src/lb.c966
-rw-r--r--live.viewer/src/live_scroller.c1457
-rw-r--r--live.viewer/src/main.c189
-rw-r--r--live.viewer/src/scroller.c524
-rw-r--r--live.viewer/src/util.c43
-rw-r--r--livebox-viewer/CMakeLists.txt55
-rw-r--r--livebox-viewer/LICENSE206
-rw-r--r--livebox-viewer/include/livebox.h1471
-rw-r--r--livebox-viewer/livebox-viewer.pc.in (renamed from livebox-viewer.pc.in)1
-rw-r--r--livebox-viewer/src/livebox.c595
-rw-r--r--packaging/libdynamicbox_viewer.manifest (renamed from packaging/liblivebox-viewer.manifest)0
-rw-r--r--packaging/libdynamicbox_viewer.spec123
-rw-r--r--packaging/liblivebox-viewer.spec91
-rw-r--r--src/client.c1770
-rw-r--r--src/conf.c57
-rw-r--r--src/desc_parser.c697
-rw-r--r--src/dlist.c189
-rw-r--r--src/fb.c622
-rw-r--r--src/fb_wayland.c447
-rw-r--r--src/file_service.c715
-rw-r--r--src/livebox.c4885
-rw-r--r--src/master_rpc.c317
-rw-r--r--src/util.c214
82 files changed, 15480 insertions, 18612 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e12dbc0..954b639 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,95 +1,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(livebox-viewer C)
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "\${prefix}")
-SET(PROJECT_NAME "${PROJECT_NAME}")
-SET(LIBDIR "\${exec_prefix}/lib")
-SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
-SET(VERSION_MAJOR 0)
-SET(VERSION "${VERSION_MAJOR}.0.1")
+ADD_SUBDIRECTORY(dynamicbox_viewer)
+ADD_SUBDIRECTORY(livebox-viewer)
-SET(CMAKE_SKIP_BUILD_RPATH true)
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED
- dlog
- aul
- glib-2.0
- gio-2.0
- com-core
- sqlite3
- db-util
- livebox-service
- vconf
-)
-
-SET(BUILD_SOURCE
- src/dlist.c
- src/livebox.c
- src/util.c
- src/desc_parser.c
- src/master_rpc.c
- src/client.c
- src/file_service.c
- src/conf.c
-)
-
-IF (X11_SUPPORT)
-pkg_check_modules(pkgs_extra REQUIRED
- x11
- xext
-)
-
-SET(BUILD_SOURCE
- ${BUILD_SOURCE}
- src/fb.c
-)
-ADD_DEFINITIONS("-DHAVE_X11")
-ENDIF (X11_SUPPORT)
-
-IF (WAYLAND_SUPPORT)
-SET(BUILD_SOURCE
- ${BUILD_SOURCE}
- src/fb_wayland.c
-)
-ADD_DEFINITIONS("-DHAVE_WAYLAND")
-ENDIF (WAYLAND_SUPPORT)
-
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-FOREACH(flag ${pkgs_extra_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline -g")
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
-ADD_DEFINITIONS("-DLOG_TAG=\"LIVEBOX_VIEWER\"")
-ADD_DEFINITIONS("-DNDEBUG")
-ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET")
-#ADD_DEFINITIONS("-DFLOG")
-ADD_DEFINITIONS("-DMASTER_PKGNAME=\"data-provider-master\"")
-ADD_DEFINITIONS("-DINFO_SOCKET=\"/opt/usr/share/live_magazine/.live.socket\"")
-ADD_DEFINITIONS("-DCLIENT_SOCKET=\"/opt/usr/share/live_magazine/.client.socket\"")
-ADD_DEFINITIONS("-DSLAVE_SOCKET=\"/opt/usr/share/live_magazine/.slave.socket\"")
-ADD_DEFINITIONS("-DSERVICE_SOCKET=\"/opt/usr/share/live_magazine/.service.socket\"")
-ADD_LIBRARY(${PROJECT_NAME} SHARED ${BUILD_SOURCE})
-
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${pkgs_extra_LDFLAGS} "-lpthread")
-
-CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
-SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc")
-
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/livebox.h DESTINATION include/${PROJECT_NAME})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "lib${PROJECT_NAME}")
+ADD_DEPENDENCIES(livebox-viewer dynamicbox_viewer)
diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile
deleted file mode 100644
index 79b2c02..0000000
--- a/TC/testcase/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-include ../config
-
-CC ?= gcc
-
-C_FILES = $(shell ls *.c)
-
-PKGS = $(PKG_NAME)
-PKGS += glib-2.0
-PKGS += livebox-service
-LDFLAGS = `pkg-config --libs $(PKGS)`
-LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
-LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
-LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
-
-CFLAGS = -I. `pkg-config --cflags $(PKGS)`
-CFLAGS += -I$(TET_ROOT)/inc/tet3
-CFLAGS += -Wall
-
-TCS := $(shell ls -1 *.c | cut -d. -f1)
-
-all: $(TCS)
-
-%: %.c
- $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
-
-clean:
- rm -f $(TCS)
diff --git a/TC/testcase/tslist b/TC/testcase/tslist
deleted file mode 100644
index 51eca81..0000000
--- a/TC/testcase/tslist
+++ /dev/null
@@ -1,2 +0,0 @@
-/testcase/utc_livebox_viewer
-
diff --git a/TC/testcase/utc_livebox_viewer b/TC/testcase/utc_livebox_viewer
deleted file mode 100755
index 1f24379..0000000
--- a/TC/testcase/utc_livebox_viewer
+++ /dev/null
Binary files differ
diff --git a/TC/testcase/utc_livebox_viewer.c b/TC/testcase/utc_livebox_viewer.c
deleted file mode 100644
index 160cb38..0000000
--- a/TC/testcase/utc_livebox_viewer.c
+++ /dev/null
@@ -1,2456 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <tet_api.h>
-#include <stdlib.h>
-
-#include <livebox.h>
-#include <livebox-service.h>
-#include <livebox-errno.h>
-
-#define MUSIC_APP "org.tizen.music-player"
-#define EMAIL_APP "org.tizen.email"
-#define EMAIL_LIVEBOX EMAIL_APP ".livebox"
-#define MUSIC_LIVEBOX MUSIC_APP ".livebox"
-#define MUSIC_EASYBOX "org.tizen.music-player.easymode.livebox"
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-static void startup(void)
-{
- int ret;
- /* start of TC */
- ret = livebox_init_with_options(NULL, 1, 0.01, 1);
- tet_printf("\n TC start: ret = %d", ret);
-}
-
-
-static void cleanup(void)
-{
- /* end of TC */
- tet_printf("\n TC end");
- livebox_fini();
-}
-
-void (*tet_startup)(void) = startup;
-void (*tet_cleanup)(void) = cleanup;
-
-static void utc_livebox_client_paused_n(void)
-{
- /*!
- * \note
- * Unable to test negative case
- */
- dts_pass("livebox_client_paused", "skip negative test");
-}
-
-static void utc_livebox_client_paused_p(void)
-{
- int ret;
-
- ret = livebox_client_paused();
- dts_check_eq("livebox_client_paused", ret, LB_STATUS_SUCCESS, "Success");
-}
-
-static void utc_livebox_client_resumed_n(void)
-{
- /*!
- * \note
- * Unable to test negative case
- */
- dts_pass("livebox_client_resumed", "skip negative test");
-}
-
-static void utc_livebox_client_resumed_p(void)
-{
- int ret;
-
- ret = livebox_client_resumed();
- dts_check_eq("livebox_client_resumed", ret, LB_STATUS_SUCCESS, "Success");
-}
-
-static void create_ret_cb(struct livebox *handle, int ret, void *data)
-{
- dts_check_eq("livebox_add", ret, LB_STATUS_SUCCESS, "Request to add a new box");
-}
-
-static void utc_livebox_add_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, create_ret_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_add", handle, NULL, "handle must not be NULL");
- }
-}
-
-static void utc_livebox_add_n(void)
-{
- struct livebox *handle;
-
- handle = livebox_add(NULL, NULL, NULL, NULL, -1.0f, create_ret_cb, NULL);
- if (handle == NULL) {
- dts_check_eq("livebox_add", handle, NULL, "Handle is NULL");
- }
-}
-
-static void create_ret_with_size_cb(struct livebox *handle, int ret, void *data)
-{
- dts_check_eq("livebox_add_with_size", ret, LB_STATUS_SUCCESS, "Request to add a new box with size");
-}
-
-static void utc_livebox_add_with_size_n(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(NULL, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, create_ret_with_size_cb, NULL);
- dts_check_eq("livebox_add_with_size", handle, NULL, "Error");
-}
-
-static void utc_livebox_add_with_size_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, create_ret_with_size_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_add_with_size", handle, NULL, "Error");
- }
-}
-
-static void utc_livebox_del_n(void)
-{
- int ret;
-
- ret = livebox_del(NULL, NULL, NULL);
- dts_check_ne("livebox_del", ret, LB_STATUS_SUCCESS, "Failed");
-}
-
-static void del_ret_cb(struct livebox *handle, int ret, void *data)
-{
- dts_check_eq("livebox_del", ret, LB_STATUS_SUCCESS, "Success");
-}
-
-static void create_cb_for_testing_del(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_del", ret, LB_STATUS_SUCCESS, "create failed");
- return;
- }
-
- ret = livebox_del(handle, del_ret_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_del", ret, LB_STATUS_SUCCESS, "Success");
- }
-}
-
-static void utc_livebox_del_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, create_cb_for_testing_del, NULL);
- if (!handle) {
- dts_check_ne("livebox_del", handle, NULL, "Failed to create a box");
- }
-}
-
-static void utc_livebox_del_NEW_n(void)
-{
- int ret;
-
- ret = livebox_del_NEW(NULL, LB_DELETE_PERMANENTLY, NULL, NULL);
- dts_check_eq("livebox_del_NEW", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void del_NEW_ret_cb(struct livebox *handle, int ret, void *data)
-{
- dts_check_eq("livebox_del_NEW", ret, LB_STATUS_SUCCESS, "Success");
-}
-
-static void create_cb_for_testing_del_NEW(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_del_NEW", ret, LB_STATUS_SUCCESS, "Create failed");
- return;
- }
-
- ret = livebox_del_NEW(handle, LB_DELETE_PERMANENTLY, del_NEW_ret_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_del_NEW", ret, LB_STATUS_SUCCESS, "Success");
- }
-}
-
-static void utc_livebox_del_NEW_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, create_cb_for_testing_del_NEW, NULL);
- if (!handle) {
- dts_check_ne("livebox_del_NEW", handle, NULL, "Failed to add a new box\n");
- }
-}
-
-static int event_handler(struct livebox *handler, enum livebox_event_type event, void *data)
-{
- return 0;
-}
-
-static void utc_livebox_set_event_handler_n(void)
-{
- int ret;
-
- ret = livebox_set_event_handler(NULL, NULL);
- dts_check_eq("livebox_set_event_handler", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void utc_livebox_set_event_handler_p(void)
-{
- int ret;
-
- ret = livebox_set_event_handler(event_handler, (void *)123);
- dts_check_eq("livebox_set_event_handler", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void utc_livebox_unset_event_handler_n(void)
-{
- /*!
- * \note
- * Unable to unset event handler
- */
- dts_pass("livebox_unset_event_handler", "skip negative test");
-}
-
-static void utc_livebox_unset_event_handler_p(void)
-{
- void *data;
-
- data = livebox_unset_event_handler(event_handler);
- dts_check_eq("livebox_unset_event_handler", data, (void *)123, "Unset");
-}
-
-static int fault_handler(enum livebox_fault_type type, const char *pkgname, const char *id, const char *func_name, void *data)
-{
- return 0;
-}
-
-static void utc_livebox_set_fault_handler_n(void)
-{
- int ret;
- ret = livebox_set_fault_handler(NULL, NULL);
- dts_check_eq("livebox_set_fault_handler", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void utc_livebox_set_fault_handler_p(void)
-{
- int ret;
- ret = livebox_set_fault_handler(fault_handler, (void *)123);
- dts_check_eq("livebox_set_fault_handler", ret, LB_STATUS_SUCCESS, "Success");
-}
-
-static void utc_livebox_unset_fault_handler_n(void)
-{
- /*!
- * Unable to test negative case
- */
- dts_pass("livebox_unset_fault_handler", "skip negative test");
-}
-
-static void utc_livebox_unset_fault_handler_p(void)
-{
- void *data;
-
- data = livebox_unset_fault_handler(fault_handler);
- dts_check_eq("livebox_unset_fault_handler", data, (void *)123, "Unset success");
-}
-
-static void utc_livebox_activate_n(void)
-{
- int ret;
-
- ret = livebox_activate(NULL, NULL, NULL);
- dts_check_eq("livebox_activate", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void activate_ret_cb(struct livebox *handle, int ret, void *data)
-{
- dts_check_eq("livebox_activate", ret, LB_STATUS_SUCCESS, "Success");
-}
-
-static void utc_livebox_activate_p(void)
-{
- int ret;
-
- ret = livebox_activate(MUSIC_LIVEBOX, activate_ret_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_activate", ret, LB_STATUS_SUCCESS, "Success");
- }
-}
-
-static void resize_cb(struct livebox *handle, int ret, void *data)
-{
- dts_check_eq("livebox_resize", ret, LB_STATUS_SUCCESS, "Success");
-}
-
-static void resize_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret == LB_STATUS_SUCCESS) {
- ret = livebox_resize(handle, LB_SIZE_TYPE_2x2, resize_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_resize", ret, LB_STATUS_SUCCESS, "Success");
- }
- } else {
- dts_check_eq("livebox_resize", ret, LB_STATUS_SUCCESS, "resize,create,callback");
- }
-}
-
-static void utc_livebox_resize_n(void)
-{
- int ret;
- ret = livebox_resize(NULL, LB_SIZE_TYPE_2x2, NULL, NULL);
- dts_check_eq("livebox_resize", ret, LB_STATUS_ERROR_INVALID, "resize");
-}
-
-static void utc_livebox_resize_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, resize_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_resize", handle, NULL, "Resize");
- }
-}
-
-static void utc_livebox_click_n(void)
-{
- int ret;
-
- ret = livebox_click(NULL, 0.5f, 0.5f);
- dts_check_eq("livebox_click", ret, LB_STATUS_ERROR_INVALID, "Success");
-}
-
-static void click_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_click", ret, LB_STATUS_SUCCESS, "click,create");
- } else {
- ret = livebox_click(handle, 0.5f, 0.5f);
- dts_check_eq("livebox_click", ret, LB_STATUS_SUCCESS, "click");
- }
-}
-
-static void utc_livebox_click_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, click_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_click", handle, NULL, "click,create");
- }
-}
-
-static void utc_livebox_set_group_n(void)
-{
- int ret;
-
- ret = livebox_set_group(NULL, NULL, NULL, NULL, NULL);
- dts_check_eq("livebox_set_group", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void set_group_cb(struct livebox *handle, int ret, void *data)
-{
- dts_check_eq("livebox_set_group", ret, LB_STATUS_SUCCESS, "Success");
-}
-
-static void set_group_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_set_group", ret, LB_STATUS_SUCCESS, "set_group,create_cb");
- } else {
- ret = livebox_set_group(handle, "my,cluster", "my,category", set_group_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_set_group", ret, LB_STATUS_SUCCESS, "set_group,request");
- }
- }
-}
-
-static void utc_livebox_set_group_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, set_group_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_set_group", handle, NULL, "create,set,group");
- }
-}
-
-static void utc_livebox_get_group_n(void)
-{
- int ret;
-
- ret = livebox_get_group(NULL, NULL, NULL);
- dts_check_eq("livebox_get_group", ret, LB_STATUS_ERROR_INVALID, "Success");
-}
-
-static void get_group_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_get_group", ret, LB_STATUS_SUCCESS, "get_group,create");
- } else {
- const char *cluster;
- const char *category;
-
- ret = livebox_get_group(handle, &cluster, &category);
- dts_check_eq("livebox_get_group", ret, LB_STATUS_SUCCESS, "Success");
- }
-}
-
-static void utc_livebox_get_group_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, get_group_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_get_group", handle, NULL, "get_group,create");
- }
-}
-
-static void utc_livebox_period_n(void)
-{
- double period;
-
- period = livebox_period(NULL);
- dts_check_eq("livebox_period", period, 0.0f, "Success");
-}
-
-static void period_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_period", ret, LB_STATUS_SUCCESS, "period,create");
- } else {
- double period;
-
- period = livebox_period(handle);
- dts_check_ge("livebox_period", period, 0.0f, "Success");
- }
-}
-
-static void utc_livebox_period_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, period_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_add_with_size", handle, NULL, "livebox_add_with_size");
- }
-}
-
-static void utc_livebox_set_period_n(void)
-{
- int ret;
-
- ret = livebox_set_period(NULL, 20.0f, NULL, NULL);
- dts_check_gt("livebox_period", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void set_period_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_period", ret, LB_STATUS_SUCCESS, "Success");
- } else {
- ret = livebox_set_period(handle, 20.0f, NULL, NULL);
- dts_check_eq("livebox_period", ret, LB_STATUS_SUCCESS, "Success");
- }
-}
-
-static void utc_livebox_set_period_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, set_period_create_cb, NULL);
- if (!handle) {
- dts_check_eq("livebox_set_period", handle, NULL, "set_period,create");
- }
-}
-
-static void utc_livebox_lb_type_n(void)
-{
- int ret;
-
- ret = livebox_lb_type(NULL);
- dts_check_eq("livebox_lb_type", ret, LB_TYPE_INVALID, "Success");
-}
-
-static void lb_type_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_lb_type", ret, LB_STATUS_SUCCESS, "lb_type,create");
- } else {
- ret = livebox_lb_type(handle);
- dts_check_ne("livebox_lb_type", ret, LB_TYPE_INVALID, "Success");
- }
-}
-
-static void utc_livebox_lb_type_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, lb_type_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_lb_type", handle, NULL, "lb,type,create");
- }
-}
-
-static void utc_livebox_is_user_n(void)
-{
- int ret;
-
- ret = livebox_is_user(NULL);
- dts_check_eq("livebox_is_user", ret, LB_STATUS_ERROR_INVALID, "Success");
-}
-
-static void livebox_is_user_create_cb(struct livebox *handle, int ret, void *data)
-{
- return;
-}
-
-static void utc_livebox_is_user_p(void)
-{
- struct livebox *handle;
- int ret;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, livebox_is_user_create_cb, NULL);
- if (handle == NULL) {
- dts_check_ne("livebox_is_user", handle, NULL, "handle is NULL");
- return;
- }
-
- ret = livebox_is_user(handle);
- dts_check_eq("livebox_is_user", ret, 1, "Success");
-}
-
-static void utc_livebox_content_n(void)
-{
- const char *content;
-
- content = livebox_content(NULL);
- dts_check_eq("livebox_content", content, NULL, "Success");
-}
-
-static void content_create_cb(struct livebox *handle, int ret, void *data)
-{
- const char *content;
-
- content = livebox_content(handle);
- dts_check_ne("livebox_content", content, NULL, "Success");
-}
-
-static void utc_livebox_content_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, content_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_content", handle, NULL, "Create for content\n");
- }
-}
-
-static void utc_livebox_category_title_n(void)
-{
- const char *title;
- title = livebox_category_title(NULL);
- dts_check_eq("livebox_category_title", title, NULL, "Success");
-}
-
-static void category_create_cb(struct livebox *handle, int ret, void *data)
-{
- const char *title;
- title = livebox_category_title(handle);
- dts_check_ne("livebox_category_title", title, NULL, "Success");
-}
-
-static void utc_livebox_category_title_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, category_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_category_title", handle, NULL, "Create for category_title");
- }
-}
-
-static void utc_livebox_filename_n(void)
-{
- const char *filename;
- filename = livebox_filename(NULL);
- dts_check_eq("livebox_filename", filename, NULL, "Success");
-}
-
-static void filename_create_cb(struct livebox *handle, int ret, void *data)
-{
- const char *filename;
- filename = livebox_filename(handle);
- dts_check_ne("livebox_filename", filename, NULL, "Success");
-}
-
-static void utc_livebox_filename_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, filename_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_category_title", handle, NULL, "Create for category_title");
- }
-}
-
-static void utc_livebox_pkgname_n(void)
-{
- const char *pkgname;
- pkgname = livebox_pkgname(NULL);
- dts_check_eq("livebox_pkgname", pkgname, NULL, "Success");
-}
-
-static void utc_livebox_pkgname_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, NULL, NULL);
- if (!handle) {
- dts_check_ne("livebox_pkgname", handle, NULL, "Create for pkgname");
- } else {
- const char *pkgname;
-
- pkgname = livebox_pkgname(handle);
- dts_check_ne("livebox_pkgname", pkgname, NULL, "pkgname");
- }
-}
-
-static void utc_livebox_priority_n(void)
-{
- double priority;
-
- priority = livebox_priority(NULL);
- dts_check_eq("livebox_priority", priority, 0.0f, "Success");
-}
-
-static void priority_create_cb(struct livebox *handle, int ret, void *data)
-{
- double priority;
-
- priority = livebox_priority(handle);
- dts_check_ge("livebox_priority", priority, 0.0f, "Success");
-}
-
-static void utc_livebox_priority_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, priority_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_priority", handle, NULL, "Create for priority");
- }
-}
-
-static void utc_livebox_acquire_fb_n(void)
-{
- void *data;
-
- data = livebox_acquire_fb(NULL);
- dts_check_eq("livebox_acquire_fb", data, NULL, "Success");
-}
-
-static void acquire_fb_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_fb", ret, LB_STATUS_SUCCESS, "acquire_fb");
- } else {
- void *data;
- data = livebox_acquire_fb(handle);
- dts_check_ne("livebox_acquire_fb", data, NULL, "acquire_fb");
- livebox_release_fb(data);
- }
-}
-
-static void utc_livebox_acquire_fb_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, acquire_fb_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_priority", handle, NULL, "Create for priority");
- }
-}
-
-static void utc_livebox_release_fb_n(void)
-{
- int ret;
-
- ret = livebox_release_fb(NULL);
- dts_check_eq("livebox_release_fb", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void release_fb_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_release_fb", ret, LB_STATUS_SUCCESS, "release_fb");
- } else {
- void *data;
-
- data = livebox_acquire_fb(handle);
-
- ret = livebox_release_fb(data);
- dts_check_eq("livebox_release_fb", ret, LB_STATUS_SUCCESS, "release_fb");
- }
-}
-
-static void utc_livebox_release_fb_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, release_fb_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_priority", handle, NULL, "Create for priority");
- }
-}
-
-static void refcnt_fb_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_fb_refcnt", ret, LB_STATUS_SUCCESS, "refcnt");
- } else {
- void *data;
-
- data = livebox_acquire_fb(handle);
-
- ret = livebox_fb_refcnt(data);
- dts_check_ge("livebox_fb_refcnt", ret, 0, "refcnt");
-
- (void)livebox_release_fb(data);
- }
-}
-
-static void utc_livebox_fb_refcnt_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, refcnt_fb_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_priority", handle, NULL, "Create for priority");
- }
-}
-
-static void utc_livebox_fb_refcnt_n(void)
-{
- int ret;
-
- ret = livebox_fb_refcnt(NULL);
- dts_check_eq("livebox_fb_refcnt", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void acquire_pdfb_pd_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_pdfb", ret, LB_STATUS_SUCCESS, "create pd failed");
- return;
- }
-
- data = livebox_acquire_pdfb(handle);
- dts_check_ne("livebox_acquire_pdfb", data, NULL, "acquire_pdfb");
- (void)livebox_release_pdfb(data);
-}
-
-static void acquire_pdfb_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_pdfb", ret, LB_STATUS_SUCCESS, "refcnt");
- } else {
- ret = livebox_create_pd(handle, acquire_pdfb_pd_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_pdfb", ret, LB_STATUS_SUCCESS, "refcnt");
- }
- }
-}
-
-static void utc_livebox_acquire_pdfb_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, acquire_pdfb_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_priority", handle, NULL, "Create for priority");
- }
-}
-
-static void utc_livebox_acquire_pdfb_n(void)
-{
- void *data;
-
- data = livebox_acquire_pdfb(NULL);
- dts_check_eq("livebox_acquire_pdfb", data, NULL, "invalid");
-}
-
-static void release_pdfb_pd_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_release_pdfb", ret, LB_STATUS_SUCCESS, "create pd");
- return;
- }
-
- data = livebox_acquire_pdfb(handle);
- ret = livebox_release_pdfb(data);
- dts_check_eq("livebox_release_pdfb", ret, LB_STATUS_SUCCESS, "release_pdfb");
-}
-
-static void release_pdfb_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_pdfb", ret, LB_STATUS_SUCCESS, "refcnt");
- } else {
- ret = livebox_create_pd(handle, release_pdfb_pd_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_pdfb", ret, LB_STATUS_SUCCESS, "refcnt");
- }
- }
-}
-
-static void utc_livebox_release_pdfb_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, release_pdfb_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_priority", handle, NULL, "Create for priority");
- }
-}
-
-static void utc_livebox_release_pdfb_n(void)
-{
- int ret;
- ret = livebox_release_pdfb(NULL);
- dts_check_eq("livebox_release_pdfb", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void utc_livebox_pdfb_refcnt_n(void)
-{
- int ret;
- ret = livebox_pdfb_refcnt(NULL);
- dts_check_eq("livebox_pdfb_refcnt", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void refcnt_pdfb_pd_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_pdfb_refcnt", ret, LB_STATUS_SUCCESS, "create pd");
- return;
- }
-
- data = livebox_acquire_pdfb(handle);
- ret = livebox_pdfb_refcnt(data);
- dts_check_ge("livebox_pdfb_refcnt", ret, 0, "refcnt_pdfb");
- (void)livebox_release_pdfb(data);
-}
-
-static void refcnt_pdfb_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_pdfb_refcnt", ret, LB_STATUS_SUCCESS, "refcnt");
- } else {
- ret = livebox_create_pd(handle, refcnt_pdfb_pd_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_pdfb_refcnt", ret, LB_STATUS_SUCCESS, "refcnt");
- }
- }
-}
-
-static void utc_livebox_pdfb_refcnt_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, refcnt_pdfb_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_pdfb_refcnt", handle, NULL, "Create for pdfb refcnt");
- }
-}
-
-static void size_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_size", ret, LB_STATUS_SUCCESS, "size");
- } else {
- int size;
- size = livebox_size(handle);
- dts_check_eq("livebox_size", size, LB_SIZE_TYPE_1x1, "size");
- }
-}
-
-static void utc_livebox_size_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, size_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_size", handle, NULL, "Create for size");
- }
-}
-
-static void utc_livebox_size_n(void)
-{
- int ret;
- ret = livebox_size(NULL);
- dts_check_eq("livebox_size", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void utc_livebox_get_pdsize_n(void)
-{
- int ret;
- ret = livebox_get_pdsize(NULL, NULL, NULL);
- dts_check_eq("livebox_get_pdsize", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void pdsize_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_get_pdsize", ret, LB_STATUS_SUCCESS, "pdsize");
- } else {
- int w;
- int h;
-
- ret = livebox_get_pdsize(handle, &w, &h);
- dts_check_eq("livebox_get_pdsize", ret, LB_STATUS_SUCCESS, "pdsize");
- }
-}
-
-static void utc_livebox_get_pdsize_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, pdsize_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_get_pdsize", handle, NULL, "Create for priority");
- }
-}
-
-static void utc_livebox_get_supported_sizes_n(void)
-{
- int ret;
-
- ret = livebox_get_supported_sizes(NULL, NULL, NULL);
- dts_check_eq("livebox_get_supported_sizes", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void size_list_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_get_supported_sizes", ret, LB_STATUS_SUCCESS, "size_list");
- } else {
- int cnt = 20;
- int size_list[20];
-
- ret = livebox_get_supported_sizes(handle, &cnt, size_list);
- dts_check_eq("livebox_get_supported_sizes", ret, LB_STATUS_SUCCESS, "size_list");
- }
-}
-
-static void utc_livebox_get_supported_sizes_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, size_list_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_get_supported_sizes", handle, NULL, "Create for supported_sizes");
- }
-}
-
-static void utc_livebox_lbfb_bufsz_n(void)
-{
- int ret;
- ret = livebox_lbfb_bufsz(NULL);
- dts_check_eq("livebox_lbfb_bufsz", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void lbfb_bufsz_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_lbfb_bufsz", ret, LB_STATUS_SUCCESS, "size_list");
- } else {
- int bufsz;
- bufsz = livebox_lbfb_bufsz(handle);
- dts_check_gt("livebox_lbfb_bufsz", bufsz, 0, "lbfb_bufsz");
- }
-}
-
-static void utc_livebox_lbfb_bufsz_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, lbfb_bufsz_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_lbfb_bufsz", handle, NULL, "Create for supported_sizes");
- }
-}
-
-static void utc_livebox_pdfb_bufsz_n(void)
-{
- int ret;
- ret = livebox_pdfb_bufsz(NULL);
- dts_check_eq("livebox_pdfb_bufsz", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void pdfb_bufsz_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_pdfb_bufsz", ret, LB_STATUS_SUCCESS, "size_list");
- } else {
- int bufsz;
- bufsz = livebox_pdfb_bufsz(handle);
- dts_check_gt("livebox_pdfb_bufsz", bufsz, 0, "pdfb_bufsz");
- }
-}
-
-static void utc_livebox_pdfb_bufsz_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, pdfb_bufsz_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_pdfb_bufsz", handle, NULL, "Create for supported_sizes");
- }
-}
-
-static void utc_livebox_content_event_n(void)
-{
- int ret;
-
- ret = livebox_content_event(NULL, PD_MOUSE_DOWN, 0.0f, 0.0f);
- dts_check_eq("livebox_content_event", ret, LB_STATUS_ERROR_INVALID, "Invalid");
-}
-
-static void content_event_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_content_event", ret, LB_STATUS_SUCCESS, "content_event");
- } else {
- ret = livebox_content_event(handle, PD_MOUSE_DOWN, 0.0f, 0.0f);
- dts_check_eq("livebox_content_event", ret, LB_STATUS_SUCCESS, "content_event");
- }
-}
-
-static void utc_livebox_content_event_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, content_event_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_content_event", handle, NULL, "Create for content_event");
- }
-}
-
-static void utc_livebox_mouse_event_n(void)
-{
- int ret;
- ret = livebox_mouse_event(NULL, PD_MOUSE_DOWN, 0.0f, 0.0f);
- dts_check_eq("livebox_mouse_event", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void mouse_event_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_content_event", ret, LB_STATUS_SUCCESS, "content_event");
- } else {
- ret = livebox_content_event(handle, PD_MOUSE_DOWN, 0.0f, 0.0f);
- dts_check_eq("livebox_content_event", ret, LB_STATUS_SUCCESS, "content_event");
- }
-}
-
-static void utc_livebox_mouse_event_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, mouse_event_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_content_event", handle, NULL, "Create for content_event");
- }
-}
-
-static void utc_livebox_access_event_n(void)
-{
- int ret;
- ret = livebox_access_event(NULL, ACCESS_EVENT_ACTION_DOWN, 0.0f, 0.0f, NULL, NULL);
- dts_check_eq("livebox_mouse_event", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void access_event_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_access_event", ret, LB_STATUS_SUCCESS, "access_event");
- } else {
- ret = livebox_access_event(handle, ACCESS_EVENT_ACTION_DOWN, 0.0f, 0.0f, NULL, NULL);
- dts_check_eq("livebox_access_event", ret, LB_STATUS_SUCCESS, "access_event");
- }
-}
-
-static void utc_livebox_access_event_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, access_event_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_access_event", handle, NULL, "Create for access_event");
- }
-}
-
-static void utc_livebox_key_event_n(void)
-{
- int ret;
- ret = livebox_key_event(NULL, PD_KEY_DOWN, 13, NULL, NULL);
- dts_check_eq("livebox_key_event", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void key_event_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_key_event", ret, LB_STATUS_SUCCESS, "key_event");
- } else {
- ret = livebox_key_event(handle, LB_KEY_DOWN, 13, NULL, NULL);
- dts_check_eq("livebox_key_event", ret, LB_STATUS_SUCCESS, "key_event");
- }
-}
-
-static void utc_livebox_key_event_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, key_event_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_key_event", handle, NULL, "Create for key_event");
- }
-}
-
-static void utc_livebox_set_pinup_n(void)
-{
- int ret;
- ret = livebox_set_pinup(NULL, 0, NULL, NULL);
- dts_check_eq("livebox_set_pinup", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void pinup_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_set_pinup", ret, LB_STATUS_SUCCESS, "key_event");
- } else {
- ret = livebox_set_pinup(handle, 0, NULL, NULL);
- dts_check_eq("livebox_set_pinup", ret, LB_STATUS_ERROR_ALREADY, "already");
- }
-}
-
-static void utc_livebox_set_pinup_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, pinup_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_set_pinup", handle, NULL, "Create for pinup");
- }
-}
-
-static void utc_livebox_is_pinned_up_n(void)
-{
- int ret;
- ret = livebox_is_pinned_up(NULL);
- dts_check_eq("livebox_is_pinned_up", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void is_pinup_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_is_pinned_up", ret, LB_STATUS_SUCCESS, "key_event");
- } else {
- ret = livebox_is_pinned_up(handle);
- dts_check_eq("livebox_is_pinned_up", ret, LB_STATUS_ERROR_ALREADY, "already");
- }
-}
-
-static void utc_livebox_is_pinned_up_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, is_pinup_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_is_pinned_up", handle, NULL, "Create for is_pinned_up");
- }
-}
-
-static void utc_livebox_has_pinup_n(void)
-{
- int ret;
- ret = livebox_has_pinup(NULL);
- dts_check_eq("livebox_has_pinup", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void has_pinup_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_has_pinup", ret, LB_STATUS_SUCCESS, "has_pinup");
- } else {
- ret = livebox_has_pinup(handle);
- dts_check_eq("livebox_has_pinup", ret, 0, "not supported");
- }
-}
-
-static void utc_livebox_has_pinup_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, has_pinup_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_has_pinup", handle, NULL, "Create for has_pinup");
- }
-}
-
-static void has_pd_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_has_pd", ret, LB_STATUS_SUCCESS, "has_pd");
- } else {
- ret = livebox_has_pd(handle);
- dts_check_eq("livebox_has_pd", ret, 1, "PD supported");
- }
-}
-
-static void utc_livebox_has_pd_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, has_pd_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_has_pinup", handle, NULL, "Create for has_pinup");
- }
-}
-
-static void utc_livebox_has_pd_n(void)
-{
- int ret;
- ret = livebox_has_pd(NULL);
- dts_check_eq("livebox_has_pd", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void utc_livebox_create_pd_n(void)
-{
- int ret;
- ret = livebox_create_pd(NULL, NULL, NULL);
- dts_check_eq("livebox_create_pd", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void create_pd_cb(struct livebox *handle, int ret, void *data)
-{
- dts_check_eq("livebox_create_pd", ret, LB_STATUS_SUCCESS, "create_pd");
- (void)livebox_destroy_pd(handle, NULL, NULL);
-}
-
-static void create_pd_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_create_pd", ret, LB_STATUS_SUCCESS, "create_pd");
- } else {
- ret = livebox_create_pd(handle, create_pd_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_create_pd", ret, LB_STATUS_SUCCESS, "create_pd");
- }
- }
-}
-
-static void utc_livebox_create_pd_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, create_pd_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_has_pinup", handle, NULL, "Create for has_pinup");
- }
-}
-
-static void utc_livebox_create_pd_with_position_n(void)
-{
- int ret;
- ret = livebox_create_pd_with_position(NULL, 0.0f, 0.0f, NULL, NULL);
- dts_check_eq("livebox_create_pd_with_position", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void create_pd_pos_cb(struct livebox *handle, int ret, void *data)
-{
- dts_check_eq("livebox_create_pd_with_position", ret, LB_STATUS_SUCCESS, "PD,create");
- (void)livebox_destroy_pd(handle, NULL, NULL);
-}
-
-static void create_pd_pos_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_create_pd_with_position", ret, LB_STATUS_SUCCESS, "create_pd_w/h_position");
- } else {
- ret = livebox_create_pd_with_position(handle, 0.0f, 0.0f, create_pd_pos_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_create_pd_with_position", ret, LB_STATUS_SUCCESS, "create_pd_w/h_position");
- }
- }
-}
-
-static void utc_livebox_create_pd_with_position_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, create_pd_pos_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_create_pd_with_position", handle, NULL, "Create for create_pd_with_position");
- }
-}
-
-static void utc_livebox_move_pd_n(void)
-{
- int ret;
- ret = livebox_move_pd(NULL, 0.0f, 0.0f);
- dts_check_eq("livebox_move_pd", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void create_move_pd_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_move_pd", ret, LB_STATUS_SUCCESS, "invalid");
- } else {
- ret = livebox_move_pd(handle, 0.5f, 0.5f);
- dts_check_eq("livebox_move_pd", ret, LB_STATUS_SUCCESS, "invalid");
- }
-}
-
-static void move_pd_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_move_pd", ret, LB_STATUS_SUCCESS, "invalid");
- } else {
- ret = livebox_create_pd_with_position(handle, 0.0f, 0.0f, create_move_pd_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_move_pd", ret, LB_STATUS_SUCCESS, "invalid");
- }
- }
-}
-
-static void utc_livebox_move_pd_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, move_pd_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_move_pd", handle, NULL, "Create for move_pd");
- }
-}
-
-static void utc_livebox_destroy_pd_n(void)
-{
- int ret;
- ret = livebox_destroy_pd(NULL, NULL, NULL);
- dts_check_eq("livebox_destroy_pd", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void destroy_pd_cb(struct livebox *handle, int ret, void *data)
-{
- dts_check_eq("livebox_destroy_pd", ret, LB_STATUS_SUCCESS, "destroy_pd");
-}
-
-static void destroy_pd_create_pd_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_destroy_pd", ret, LB_STATUS_SUCCESS, "destroy_pd");
- } else {
- ret = livebox_destroy_pd(handle, destroy_pd_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_destroy_pd", ret, LB_STATUS_SUCCESS, "destroy_pd");
- }
- }
-}
-
-static void destroy_pd_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_destroy_pd", ret, LB_STATUS_SUCCESS, "destroy_pd");
- } else {
- ret = livebox_create_pd_with_position(handle, 0.0f, 0.0f, destroy_pd_create_pd_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_destroy_pd", ret, LB_STATUS_SUCCESS, "invalid");
- }
- }
-}
-
-static void utc_livebox_destroy_pd_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, destroy_pd_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_destroy_pd", handle, NULL, "Create for destroy_pd");
- }
-}
-
-static void utc_livebox_pd_is_created_n(void)
-{
- int ret;
- ret = livebox_pd_is_created(NULL);
- dts_check_eq("livebox_pd_is_created", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void pd_is_created_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_pd_is_created", ret, LB_STATUS_SUCCESS, "pd_is_created");
- } else {
- ret = livebox_pd_is_created(handle);
- dts_check_eq("livebox_pd_is_created", ret, 0, "pd_is_created");
- (void)livebox_del(handle, NULL, NULL);
- }
-}
-
-static void utc_livebox_pd_is_created_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, pd_is_created_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_pd_is_created", handle, NULL, "create for pd_is_created");
- }
-}
-
-static void utc_livebox_pd_type_n(void)
-{
- int type;
- type = livebox_pd_type(NULL);
- dts_check_eq("livebox_pd_type", type, PD_TYPE_INVALID, "invalid");
-}
-
-static void pd_type_created_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_pd_type", ret, LB_STATUS_SUCCESS, "pd_type");
- } else {
- ret = livebox_pd_type(handle);
- dts_check_ne("livebox_pd_type", ret, PD_TYPE_INVALID, "pd_type");
- }
-}
-
-static void utc_livebox_pd_type_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, pd_type_created_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_pd_type", handle, NULL, "create for pd_is_created");
- }
-}
-
-static void utc_livebox_is_exists_n(void)
-{
- int ret;
- ret = livebox_is_exists(NULL);
- dts_check_eq("livebox_is_exists", ret, 0, "not exists");
-}
-
-static void utc_livebox_is_exists_p(void)
-{
- int ret;
- ret = livebox_is_exists(MUSIC_APP);
- dts_check_eq("livebox_is_exists", ret, 1, "exists");
-}
-
-static void utc_livebox_set_text_handler_n(void)
-{
- int ret;
- ret = livebox_set_text_handler(NULL, NULL);
- dts_check_eq("livebox_set_text_handler", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void set_text_handler_created_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_set_text_handler", ret, LB_STATUS_SUCCESS, "set_text_handler");
- } else {
- struct livebox_script_operators ops = {
- .update_begin = NULL,
- .update_end = NULL,
- .update_text = NULL,
- .update_image = NULL,
- .update_script = NULL,
- .update_signal = NULL,
- .update_drag = NULL,
- .update_info_size = NULL,
- .update_info_category = NULL,
- .update_access = NULL,
- .operate_access = NULL,
- };
-
- ret = livebox_set_text_handler(handle, &ops);
- dts_check_eq("livebox_set_text_handler", ret, LB_STATUS_SUCCESS, "set_text_handler");
- }
-}
-
-static void utc_livebox_set_text_handler_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, set_text_handler_created_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_set_text_handler", handle, NULL, "create for pd_is_created");
- }
-}
-
-static void utc_livebox_set_pd_text_handler_n(void)
-{
- int ret;
- ret = livebox_set_pd_text_handler(NULL, NULL);
- dts_check_eq("livebox_set_pd_text_handler", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void set_pd_text_handler_created_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_set_pd_text_handler", ret, LB_STATUS_SUCCESS, "set_text_handler");
- } else {
- struct livebox_script_operators ops = {
- .update_begin = NULL,
- .update_end = NULL,
- .update_text = NULL,
- .update_image = NULL,
- .update_script = NULL,
- .update_signal = NULL,
- .update_drag = NULL,
- .update_info_size = NULL,
- .update_info_category = NULL,
- .update_access = NULL,
- .operate_access = NULL,
- };
-
- ret = livebox_set_pd_text_handler(handle, &ops);
- dts_check_eq("livebox_set_pd_text_handler", ret, LB_STATUS_SUCCESS, "set_text_handler");
- }
-}
-
-static void utc_livebox_set_pd_text_handler_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, set_pd_text_handler_created_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_set_pd_text_handler", handle, NULL, "create for pd_is_created");
- }
-}
-
-static void utc_livebox_emit_text_signal_n(void)
-{
- int ret;
- ret = livebox_emit_text_signal(NULL, NULL, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL, NULL);
- dts_check_eq("livebox_emit_text_signal", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void emit_signal_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_emit_text_signal", ret, LB_STATUS_SUCCESS, "set_text_handler");
- } else {
- ret = livebox_emit_text_signal(handle, NULL, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL, NULL);
- dts_check_eq("livebox_emit_text_signal", ret, LB_STATUS_ERROR_INVALID, "text_handler");
- }
-}
-
-static void utc_livebox_emit_text_signal_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, emit_signal_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_emit_text_signal", handle, NULL, "create for pd_is_created");
- }
-}
-
-static void utc_livebox_set_data_n(void)
-{
- int ret;
- ret = livebox_set_data(NULL, NULL);
- dts_check_eq("livebox_set_data", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void utc_livebox_set_data_p(void)
-{
- struct livebox *handle;
- int ret;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, emit_signal_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_set_data", handle, NULL, "create for pd_is_created");
- return;
- }
-
- ret = livebox_set_data(handle, (void *)123);
- dts_check_eq("livebox_set_data", ret, LB_STATUS_SUCCESS, "set_data");
-}
-
-static void utc_livebox_get_data_p(void)
-{
- struct livebox *handle;
- void *data;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, emit_signal_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_set_data", handle, NULL, "create for pd_is_created");
- return;
- }
-
- data = livebox_get_data(handle);
- dts_check_eq("livebox_get_data", data, NULL, "get_data");
-}
-
-static void utc_livebox_get_data_n(void)
-{
- void *data;
- data = livebox_get_data(NULL);
- dts_check_eq("livebox_get_data", data, NULL, "data");
-}
-
-static void utc_livebox_subscribe_group_n(void)
-{
- /*!
- * \note
- * Unable to test negative case
- */
- dts_pass("livebox_subscribe_group", "pass negative test");
-}
-
-static void utc_livebox_subscribe_group_p(void)
-{
- int ret;
- ret = livebox_subscribe_group("my,cluster", "my,category");
- dts_check_eq("livebox_subscribe_group", ret, LB_STATUS_SUCCESS, "subscribe");
-}
-
-static void utc_livebox_unsubscribe_group_n(void)
-{
- /*!
- * \note
- * Unable to test negative case
- */
- dts_pass("livebox_unsubscribe_group", "pass negative test");
-}
-
-static void utc_livebox_unsubscribe_group_p(void)
-{
- int ret;
- ret = livebox_unsubscribe_group("my,cluster", "my,category");
- dts_check_eq("livebox_unsubscribe_group", ret, LB_STATUS_SUCCESS, "unsubscribe");
-}
-
-static void utc_livebox_refresh_group_n(void)
-{
- int ret;
- ret = livebox_refresh_group(NULL, NULL, 0);
- dts_check_eq("livebox_refresh_group", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void utc_livebox_refresh_group_p(void)
-{
- int ret;
- ret = livebox_refresh_group("my,cluster", "my,category", 0);
- dts_check_eq("livebox_refresh_group", ret, LB_STATUS_SUCCESS, "refresh_group");
-}
-
-static void refresh_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_refresh", ret, LB_STATUS_SUCCESS, "refresh");
- } else {
- ret = livebox_refresh(handle, 0);
- dts_check_eq("livebox_refresh", ret, LB_STATUS_SUCCESS, "refresh");
- }
-}
-
-static void utc_livebox_refresh_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, refresh_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_set_data", handle, NULL, "create for pd_is_created");
- return;
- }
-}
-
-static void utc_livebox_refresh_n(void)
-{
- int ret;
- ret = livebox_refresh(NULL, 0);
- dts_check_eq("livebox_refresh", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-
-static void utc_livebox_lb_pixmap_n(void)
-{
- int ret;
- ret = livebox_lb_pixmap(NULL);
- dts_check_eq("livebox_lb_pixmap", ret, 0, "invalid");
-}
-
-static void lb_pixmap_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_lb_pixmap", ret, LB_STATUS_SUCCESS, "lb_pixmap");
- } else {
- ret = livebox_lb_pixmap(handle);
- dts_check_ne("livebox_lb_pixmap", ret, 0, "lb_pixmap");
- }
-}
-
-static void utc_livebox_lb_pixmap_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, lb_pixmap_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_lb_pixmap", handle, NULL, "create for lb_pixmap");
- return;
- }
-}
-
-static void pd_pixmap_create_pd_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_pd_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- } else {
- ret = livebox_pd_pixmap(handle);
- dts_check_ne("livebox_pd_pixmap", ret, 0, "pd_pixmap");
- }
-}
-
-static void pd_pixmap_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_pd_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- } else {
- ret = livebox_create_pd(handle, pd_pixmap_create_pd_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_pd_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- }
- }
-}
-
-static void utc_livebox_pd_pixmap_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, pd_pixmap_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_pd_pixmap", handle, NULL, "create for pd_pixmap");
- }
-}
-
-static void utc_livebox_pd_pixmap_n(void)
-{
- int ret;
- ret = livebox_pd_pixmap(NULL);
- dts_check_eq("livebox_pd_pixmap", ret, 0, "invalid");
-}
-
-static void utc_livebox_acquire_pd_pixmap_n(void)
-{
- int ret;
- ret = livebox_acquire_pd_pixmap(NULL, NULL, NULL);
- dts_check_eq("livebox_acquire_pd_pixmap", ret, 0, "invalid");
-}
-
-static void acquire_pd_pixmap_cb(struct livebox *handle, int pixmap, void *data)
-{
- dts_check_ne("livebox_acquire_pd_pixmap", pixmap, 0, "acquire_pd_pixmap");
- (void)livebox_release_pd_pixmap(handle, pixmap);
-}
-
-static void pd_acquire_pixmap_pd_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_pd_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- } else {
- ret = livebox_acquire_pd_pixmap(handle, acquire_pd_pixmap_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_pd_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- }
- }
-}
-
-static void pd_acquire_pixmap_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_pd_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- } else {
- ret = livebox_create_pd(handle, pd_acquire_pixmap_pd_create_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_pd_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- }
- }
-}
-
-static void utc_livebox_acquire_pd_pixmap_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, pd_acquire_pixmap_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_pd_pixmap", handle, NULL, "create for pd_pixmap");
- }
-}
-
-static void utc_livebox_release_pd_pixmap_n(void)
-{
- int ret;
- ret = livebox_release_pd_pixmap(NULL, 0);
- dts_check_eq("livebox_release_pd_pixmap", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void release_pd_pixmap_cb(struct livebox *handle, int pixmap, void *data)
-{
- int ret;
-
- if (pixmap == 0) {
- dts_check_ne("livebox_release_pd_pixmap", pixmap, 0, "release_pd_pixmap");
- return;
- }
-
- ret = livebox_release_pd_pixmap(handle, pixmap);
- dts_check_eq("livebox_release_pd_pixmap", ret, LB_STATUS_SUCCESS, "release_pd_pixmap");
-}
-
-static void pd_release_pixmap_pd_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_release_pd_pixmap", ret, LB_STATUS_SUCCESS, "release_pd_pixmap");
- } else {
- ret = livebox_acquire_pd_pixmap(handle, release_pd_pixmap_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_release_pd_pixmap", ret, LB_STATUS_SUCCESS, "release_pd_pixmap");
- }
- }
-}
-
-static void pd_release_pixmap_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_release_pd_pixmap", ret, LB_STATUS_SUCCESS, "release_pd_pixmap");
- } else {
- ret = livebox_create_pd(handle, pd_release_pixmap_pd_create_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_release_pd_pixmap", ret, LB_STATUS_SUCCESS, "release_pd_pixmap");
- }
- }
-}
-
-static void utc_livebox_release_pd_pixmap_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, pd_release_pixmap_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_release_pd_pixmap", handle, NULL, "create for release_pd_pixmap");
- }
-}
-
-static void acquire_lb_pixmap_cb(struct livebox *handle, int pixmap, void *data)
-{
- dts_check_ne("livebox_acquire_lb_pixmap", pixmap, 0, "acquire_lb_pixmap");
- (void)livebox_release_lb_pixmap(handle, pixmap);
-}
-
-static void lb_acquire_pixmap_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_lb_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- } else {
- ret = livebox_acquire_lb_pixmap(handle, acquire_lb_pixmap_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_lb_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- }
- }
-}
-
-static void utc_livebox_acquire_lb_pixmap_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, lb_acquire_pixmap_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_acquire_lb_pixmap", handle, NULL, "create for lb_pixmap");
- }
-}
-
-static void utc_livebox_acquire_lb_pixmap_n(void)
-{
- int ret;
- ret = livebox_acquire_lb_pixmap(NULL, NULL, NULL);
- dts_check_eq("livebox_acquire_lb_pixmap", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void release_lb_pixmap_cb(struct livebox *handle, int pixmap, void *data)
-{
- if (pixmap == 0) {
- dts_check_ne("livebox_release_lb_pixmap", pixmap, 0, "release_lb_pixmap");
- } else {
- int ret;
- ret = livebox_release_lb_pixmap(handle, pixmap);
- dts_check_eq("livebox_release_lb_pixmap", ret, LB_STATUS_SUCCESS, "release_lb_pixmap");
- }
-}
-
-static void lb_release_pixmap_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_release_lb_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- } else {
- ret = livebox_acquire_lb_pixmap(handle, release_lb_pixmap_cb, NULL);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_release_lb_pixmap", ret, LB_STATUS_SUCCESS, "invalid");
- }
- }
-}
-
-static void utc_livebox_release_lb_pixmap_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, lb_release_pixmap_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_release_lb_pixmap", handle, NULL, "create for lb_pixmap");
- }
-}
-
-static void utc_livebox_release_lb_pixmap_n(void)
-{
- int ret;
- ret = livebox_release_lb_pixmap(NULL, 0);
- dts_check_eq("livebox_release_lb_pixmap", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void set_visibility_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_ne("livebox_set_visibility", ret, LB_STATUS_SUCCESS, "visibility_set");
- } else {
- ret = livebox_set_visibility(handle, LB_SHOW);
- dts_check_eq("livebox_set_visibility", ret, LB_STATUS_SUCCESS, "visibility_set");
- }
-}
-
-static void utc_livebox_set_visibility_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, set_visibility_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_set_visibility", handle, NULL, "create for set_visibility");
- }
-}
-
-static void utc_livebox_set_visibility_n(void)
-{
- int ret;
- ret = livebox_set_visibility(NULL, LB_SHOW);
- dts_check_eq("livebox_set_visibility", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void visibility_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_ne("livebox_visibility", ret, LB_STATUS_SUCCESS, "visibility");
- } else {
- ret = livebox_visibility(handle);
- dts_check_eq("livebox_visibility", ret, LB_HIDE_WITH_PAUSE, "visibility_set");
- }
-}
-
-static void utc_livebox_visibility_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, visibility_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_visibility", handle, NULL, "create for visibility");
- }
-}
-
-static void utc_livebox_visibility_n(void)
-{
- int ret;
-
- ret = livebox_visibility(NULL);
- dts_check_eq("livebox_visibility", ret, LB_VISIBLE_ERROR, "invalid");
-}
-
-static void utc_livebox_set_update_mode_n(void)
-{
- int ret;
-
- ret = livebox_set_update_mode(NULL, 0, NULL, NULL);
- dts_check_eq("livebox_set_update_mode", ret,LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void set_update_mode_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_set_update_mode", ret, LB_STATUS_SUCCESS, "set_update_mode");
- } else {
- ret = livebox_set_update_mode(handle, 0, NULL, NULL);
- dts_check_eq("livebox_set_update_mode", ret, LB_STATUS_ERROR_ALREADY, "set_update_mode");
- }
-}
-
-static void utc_livebox_set_update_mode_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, set_update_mode_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_set_update_mode", handle, NULL, "create for set_update_mode");
- }
-}
-
-static void utc_livebox_is_active_update_n(void)
-{
- int ret;
- ret = livebox_is_active_update(NULL);
- dts_check_eq("livebox_is_active_update", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void is_active_update_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_is_active_update", ret, LB_STATUS_SUCCESS, "is_activate_update");
- } else {
- ret = livebox_is_active_update(handle);
- dts_check_eq("livebox_is_active_update", ret, 0, "is_activate_update");
- }
-}
-
-static void utc_livebox_is_active_update_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, is_active_update_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_is_active_update", handle, NULL, "create for is_active_update");
- }
-}
-
-static void utc_livebox_set_manual_sync_n(void)
-{
- /*!
- * \note
- * Unable to test negative case
- */
- dts_pass("livebox_set_manual_sync", "negative pass");
-}
-
-static void utc_livebox_set_manual_sync_p(void)
-{
- livebox_set_option(LB_OPTION_MANUAL_SYNC, 0);
- dts_pass("livebox_set_manual_sync", "Pass!");
-}
-
-static void utc_livebox_manual_sync_p(void)
-{
- int ret;
-
- ret = livebox_option(LB_OPTION_MANUAL_SYNC);
- dts_check_eq("livebox_manual_sync", ret, 0, "ok");
-}
-
-static void utc_livebox_manual_sync_n(void)
-{
- /*!
- * \note
- * Unable to test negative case
- */
- dts_pass("livebox_manual_sync", "negative Pass");
-}
-
-static void utc_livebox_set_frame_drop_for_resizing_n(void)
-{
- /*!
- * \note
- * Unable to test negative case
- */
- dts_pass("livebox_set_frame_drop_for_resizing", "pass");
-}
-
-static void utc_livebox_set_frame_drop_for_resizing_p(void)
-{
- livebox_set_option(LB_OPTION_FRAME_DROP_FOR_RESIZE, 1);
- dts_pass("livebox_set_frame_drop_for_resizing", "pass");
-}
-
-static void utc_livebox_frame_drop_for_resizing_n(void)
-{
- /*!
- * \note
- * Unable to test negative case
- */
- dts_pass("livebox_frame_drop_for_resizing", "pass");
-}
-
-static void utc_livebox_frame_drop_for_resizing_p(void)
-{
- int ret;
-
- ret = livebox_option(LB_OPTION_FRAME_DROP_FOR_RESIZE);
- dts_check_eq("livebox_frame_drop_for_resizing", ret, 1, "drop_for_resizing");
-}
-
-static void utc_livebox_sync_pd_fb_n(void)
-{
- int ret;
- ret = livebox_sync_pd_fb(NULL);
- dts_check_eq("livebox_sync_pd_fb", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void sync_pd_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_sync_pd_fb", ret, LB_STATUS_SUCCESS, "sync_pd_fb");
- } else {
- ret = livebox_sync_pd_fb(handle);
- dts_check_eq("livebox_sync_pd_fb", ret, LB_STATUS_SUCCESS, "sync_pd_fb");
- }
-}
-
-static void utc_livebox_sync_pd_fb_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, sync_pd_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_sync_pd_fb", handle, NULL, "create for sync_pd_fb");
- }
-}
-
-static void sync_lb_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_sync_lb_fb", ret, LB_STATUS_SUCCESS, "sync_lb_fb");
- } else {
- ret = livebox_sync_lb_fb(handle);
- dts_check_eq("livebox_sync_lb_fb", ret, LB_STATUS_SUCCESS, "sync_lb_fb");
- }
-}
-
-static void utc_livebox_sync_lb_fb_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, sync_lb_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_sync_pd_fb", handle, NULL, "create for sync_pd_fb");
- }
-}
-
-static void utc_livebox_sync_lb_fb_n(void)
-{
- int ret;
- ret = livebox_sync_lb_fb(NULL);
- dts_check_eq("livebox_sync_lb_fb", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void alt_icon_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_alt_name", ret, LB_STATUS_SUCCESS, "alt_name");
- } else {
- const char *alt_icon;
-
- alt_icon = livebox_alt_icon(handle);
- dts_check_ne("livebox_alt_icon", alt_icon, NULL, "alt_icon");
- }
-}
-
-static void utc_livebox_alt_icon_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, alt_icon_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_alt_icon", handle, NULL, "alt_icon");
- }
-}
-
-static void utc_livebox_alt_icon_n(void)
-{
- const char *alt_icon;
-
- alt_icon = livebox_alt_icon(NULL);
- dts_check_eq("livebox_alt_icon", alt_icon, NULL, "invalid");
-}
-
-static void alt_name_create_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_alt_name", ret, LB_STATUS_SUCCESS, "alt_name");
- } else {
- const char *alt_name;
-
- alt_name = livebox_alt_name(handle);
- dts_check_ne("livebox_alt_name", alt_name, NULL, "alt_name");
- }
-}
-
-static void utc_livebox_alt_name_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(MUSIC_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, alt_name_create_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_alt_name", handle, NULL, "alt_name");
- }
-}
-
-static void utc_livebox_alt_name_n(void)
-{
- const char *alt_name;
- alt_name = livebox_alt_name(NULL);
- dts_check_eq("livebox_alt_icon", alt_name, NULL, "invalid");
-}
-
-static void utc_livebox_acquire_fb_lock_n(void)
-{
- int ret;
- ret = livebox_acquire_fb_lock(NULL, 0);
- dts_check_eq("livebox_acquire_fb_lock", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void acquire_fb_lock_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_acquire_fb_lock", ret, LB_STATUS_SUCCESS, "acquire_fb_lock");
- } else {
- ret = livebox_acquire_fb_lock(handle, 0);
- dts_check_eq("livebox_acquire_fb_lock", ret, LB_STATUS_SUCCESS, "acquire_fb_lock");
- (void)livebox_release_fb_lock(handle, 0);
- }
-}
-
-static void utc_livebox_acquire_fb_lock_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, acquire_fb_lock_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_acquire_fb_lock", handle, NULL, "create for acquire_fb_lock");
- }
-}
-
-static void utc_livebox_release_fb_lock_n(void)
-{
- int ret;
- ret = livebox_release_fb_lock(NULL, 0);
- dts_check_eq("livebox_release_fb_lock", ret, LB_STATUS_ERROR_INVALID, "invalid");
-}
-
-static void release_fb_lock_cb(struct livebox *handle, int ret, void *data)
-{
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_release_fb_lock", ret, LB_STATUS_SUCCESS, "release_fb_lock");
- } else {
- ret = livebox_acquire_fb_lock(handle, 0);
- if (ret != LB_STATUS_SUCCESS) {
- dts_check_eq("livebox_release_fb_lock", ret, LB_STATUS_SUCCESS, "release_fb_lock");
- return;
- }
-
- ret = livebox_release_fb_lock(handle, 0);
- dts_check_eq("livebox_acquire_fb_lock", ret, LB_STATUS_SUCCESS, "release_fb_lock");
- }
-}
-
-static void utc_livebox_release_fb_lock_p(void)
-{
- struct livebox *handle;
-
- handle = livebox_add_with_size(EMAIL_LIVEBOX, NULL, NULL, NULL, -1.0f, LB_SIZE_TYPE_1x1, release_fb_lock_cb, NULL);
- if (!handle) {
- dts_check_ne("livebox_release_fb_lock", handle, NULL, "create for release_fb_lock");
- }
-}
-
-struct tet_testlist tet_testlist[] = {
- { utc_livebox_client_paused_n, NEGATIVE_TC_IDX },
- { utc_livebox_client_paused_p, POSITIVE_TC_IDX },
- { utc_livebox_client_resumed_n, NEGATIVE_TC_IDX },
- { utc_livebox_client_resumed_p, POSITIVE_TC_IDX },
- { utc_livebox_add_p, POSITIVE_TC_IDX },
- { utc_livebox_add_n, NEGATIVE_TC_IDX },
- { utc_livebox_add_with_size_n, NEGATIVE_TC_IDX },
- { utc_livebox_add_with_size_p, POSITIVE_TC_IDX },
- { utc_livebox_del_n, NEGATIVE_TC_IDX },
- { utc_livebox_del_p, POSITIVE_TC_IDX },
- { utc_livebox_del_NEW_n, NEGATIVE_TC_IDX },
- { utc_livebox_del_NEW_p, POSITIVE_TC_IDX },
- { utc_livebox_set_event_handler_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_event_handler_p, POSITIVE_TC_IDX },
- { utc_livebox_unset_event_handler_n, NEGATIVE_TC_IDX },
- { utc_livebox_unset_event_handler_p, POSITIVE_TC_IDX },
- { utc_livebox_set_fault_handler_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_fault_handler_p, POSITIVE_TC_IDX },
- { utc_livebox_unset_fault_handler_n, NEGATIVE_TC_IDX },
- { utc_livebox_unset_fault_handler_p, POSITIVE_TC_IDX },
- { utc_livebox_activate_n, NEGATIVE_TC_IDX },
- { utc_livebox_activate_p, POSITIVE_TC_IDX },
- { utc_livebox_resize_n, NEGATIVE_TC_IDX },
- { utc_livebox_resize_p, POSITIVE_TC_IDX },
- { utc_livebox_click_n, NEGATIVE_TC_IDX },
- { utc_livebox_click_p, POSITIVE_TC_IDX },
- { utc_livebox_set_group_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_group_p, POSITIVE_TC_IDX },
- { utc_livebox_get_group_n, NEGATIVE_TC_IDX },
- { utc_livebox_get_group_p, POSITIVE_TC_IDX },
- { utc_livebox_period_n, NEGATIVE_TC_IDX },
- { utc_livebox_period_p, POSITIVE_TC_IDX },
- { utc_livebox_set_period_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_period_p, POSITIVE_TC_IDX },
- { utc_livebox_lb_type_n, NEGATIVE_TC_IDX },
- { utc_livebox_lb_type_p, POSITIVE_TC_IDX },
- { utc_livebox_is_user_n, NEGATIVE_TC_IDX },
- { utc_livebox_is_user_p, POSITIVE_TC_IDX },
- { utc_livebox_content_n, NEGATIVE_TC_IDX },
- { utc_livebox_content_p, POSITIVE_TC_IDX },
- { utc_livebox_category_title_n, NEGATIVE_TC_IDX },
- { utc_livebox_category_title_p, POSITIVE_TC_IDX },
- { utc_livebox_filename_n, NEGATIVE_TC_IDX },
- { utc_livebox_filename_p, POSITIVE_TC_IDX },
- { utc_livebox_pkgname_n, NEGATIVE_TC_IDX },
- { utc_livebox_pkgname_p, POSITIVE_TC_IDX },
- { utc_livebox_priority_n, NEGATIVE_TC_IDX },
- { utc_livebox_priority_p, POSITIVE_TC_IDX },
- { utc_livebox_acquire_fb_n, NEGATIVE_TC_IDX },
- { utc_livebox_acquire_fb_p, POSITIVE_TC_IDX },
- { utc_livebox_release_fb_n, NEGATIVE_TC_IDX },
- { utc_livebox_release_fb_p, POSITIVE_TC_IDX },
- { utc_livebox_fb_refcnt_p, POSITIVE_TC_IDX },
- { utc_livebox_fb_refcnt_n, NEGATIVE_TC_IDX },
- { utc_livebox_acquire_pdfb_p, POSITIVE_TC_IDX },
- { utc_livebox_acquire_pdfb_n, NEGATIVE_TC_IDX },
- { utc_livebox_release_pdfb_p, POSITIVE_TC_IDX },
- { utc_livebox_release_pdfb_n, NEGATIVE_TC_IDX },
- { utc_livebox_pdfb_refcnt_n, NEGATIVE_TC_IDX },
- { utc_livebox_pdfb_refcnt_p, POSITIVE_TC_IDX },
- { utc_livebox_size_p, POSITIVE_TC_IDX },
- { utc_livebox_size_n, NEGATIVE_TC_IDX },
- { utc_livebox_get_pdsize_n, NEGATIVE_TC_IDX },
- { utc_livebox_get_pdsize_p, POSITIVE_TC_IDX },
- { utc_livebox_get_supported_sizes_n, NEGATIVE_TC_IDX },
- { utc_livebox_get_supported_sizes_p, POSITIVE_TC_IDX },
- { utc_livebox_lbfb_bufsz_n, NEGATIVE_TC_IDX },
- { utc_livebox_lbfb_bufsz_p, POSITIVE_TC_IDX },
- { utc_livebox_pdfb_bufsz_n, NEGATIVE_TC_IDX },
- { utc_livebox_pdfb_bufsz_p, POSITIVE_TC_IDX },
- { utc_livebox_content_event_n, NEGATIVE_TC_IDX },
- { utc_livebox_content_event_p, POSITIVE_TC_IDX },
- { utc_livebox_mouse_event_n, NEGATIVE_TC_IDX },
- { utc_livebox_mouse_event_p, POSITIVE_TC_IDX },
- { utc_livebox_access_event_n, NEGATIVE_TC_IDX },
- { utc_livebox_access_event_p, POSITIVE_TC_IDX },
- { utc_livebox_key_event_n, NEGATIVE_TC_IDX },
- { utc_livebox_key_event_p, POSITIVE_TC_IDX },
- { utc_livebox_set_pinup_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_pinup_p, POSITIVE_TC_IDX },
- { utc_livebox_is_pinned_up_n, NEGATIVE_TC_IDX },
- { utc_livebox_is_pinned_up_p, POSITIVE_TC_IDX },
- { utc_livebox_has_pinup_n, NEGATIVE_TC_IDX },
- { utc_livebox_has_pinup_p, POSITIVE_TC_IDX },
- { utc_livebox_has_pd_p, POSITIVE_TC_IDX },
- { utc_livebox_has_pd_n, NEGATIVE_TC_IDX },
- { utc_livebox_create_pd_n, NEGATIVE_TC_IDX },
- { utc_livebox_create_pd_p, POSITIVE_TC_IDX },
- { utc_livebox_create_pd_with_position_n, NEGATIVE_TC_IDX },
- { utc_livebox_create_pd_with_position_p, POSITIVE_TC_IDX },
- { utc_livebox_move_pd_n, NEGATIVE_TC_IDX },
- { utc_livebox_move_pd_p, POSITIVE_TC_IDX },
- { utc_livebox_destroy_pd_n, NEGATIVE_TC_IDX },
- { utc_livebox_destroy_pd_p, POSITIVE_TC_IDX },
- { utc_livebox_pd_is_created_n, NEGATIVE_TC_IDX },
- { utc_livebox_pd_is_created_p, POSITIVE_TC_IDX },
- { utc_livebox_pd_type_n, NEGATIVE_TC_IDX },
- { utc_livebox_pd_type_p, POSITIVE_TC_IDX },
- { utc_livebox_is_exists_n, NEGATIVE_TC_IDX },
- { utc_livebox_is_exists_p, POSITIVE_TC_IDX },
- { utc_livebox_set_text_handler_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_text_handler_p, POSITIVE_TC_IDX },
- { utc_livebox_set_pd_text_handler_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_pd_text_handler_p, POSITIVE_TC_IDX },
- { utc_livebox_emit_text_signal_n, NEGATIVE_TC_IDX },
- { utc_livebox_emit_text_signal_p, POSITIVE_TC_IDX },
- { utc_livebox_set_data_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_data_p, POSITIVE_TC_IDX },
- { utc_livebox_get_data_p, POSITIVE_TC_IDX },
- { utc_livebox_get_data_n, NEGATIVE_TC_IDX },
- { utc_livebox_subscribe_group_n, NEGATIVE_TC_IDX },
- { utc_livebox_subscribe_group_p, POSITIVE_TC_IDX },
- { utc_livebox_unsubscribe_group_n, NEGATIVE_TC_IDX },
- { utc_livebox_unsubscribe_group_p, POSITIVE_TC_IDX },
- { utc_livebox_refresh_group_n, NEGATIVE_TC_IDX },
- { utc_livebox_refresh_group_p, POSITIVE_TC_IDX },
- { utc_livebox_refresh_p, POSITIVE_TC_IDX },
- { utc_livebox_refresh_n, NEGATIVE_TC_IDX },
- { utc_livebox_lb_pixmap_n, NEGATIVE_TC_IDX },
- { utc_livebox_lb_pixmap_p, POSITIVE_TC_IDX },
- { utc_livebox_pd_pixmap_p, POSITIVE_TC_IDX },
- { utc_livebox_pd_pixmap_n, NEGATIVE_TC_IDX },
- { utc_livebox_acquire_pd_pixmap_n, NEGATIVE_TC_IDX },
- { utc_livebox_acquire_pd_pixmap_p, POSITIVE_TC_IDX },
- { utc_livebox_release_pd_pixmap_n, NEGATIVE_TC_IDX },
- { utc_livebox_release_pd_pixmap_p, POSITIVE_TC_IDX },
- { utc_livebox_acquire_lb_pixmap_p, POSITIVE_TC_IDX },
- { utc_livebox_acquire_lb_pixmap_n, NEGATIVE_TC_IDX },
- { utc_livebox_release_lb_pixmap_p, POSITIVE_TC_IDX },
- { utc_livebox_release_lb_pixmap_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_visibility_p, POSITIVE_TC_IDX },
- { utc_livebox_set_visibility_n, NEGATIVE_TC_IDX },
- { utc_livebox_visibility_p, POSITIVE_TC_IDX },
- { utc_livebox_visibility_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_update_mode_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_update_mode_p, POSITIVE_TC_IDX },
- { utc_livebox_is_active_update_n, NEGATIVE_TC_IDX },
- { utc_livebox_is_active_update_p, POSITIVE_TC_IDX },
- { utc_livebox_set_manual_sync_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_manual_sync_p, POSITIVE_TC_IDX },
- { utc_livebox_manual_sync_p, POSITIVE_TC_IDX },
- { utc_livebox_manual_sync_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_frame_drop_for_resizing_n, NEGATIVE_TC_IDX },
- { utc_livebox_set_frame_drop_for_resizing_p, POSITIVE_TC_IDX },
- { utc_livebox_frame_drop_for_resizing_n, NEGATIVE_TC_IDX },
- { utc_livebox_frame_drop_for_resizing_p, POSITIVE_TC_IDX },
- { utc_livebox_sync_pd_fb_n, NEGATIVE_TC_IDX },
- { utc_livebox_sync_pd_fb_p, POSITIVE_TC_IDX },
- { utc_livebox_sync_lb_fb_p, POSITIVE_TC_IDX },
- { utc_livebox_sync_lb_fb_n, NEGATIVE_TC_IDX },
- { utc_livebox_alt_icon_p, POSITIVE_TC_IDX },
- { utc_livebox_alt_icon_n, NEGATIVE_TC_IDX },
- { utc_livebox_alt_name_p, POSITIVE_TC_IDX },
- { utc_livebox_alt_name_n, NEGATIVE_TC_IDX },
- { utc_livebox_acquire_fb_lock_n, NEGATIVE_TC_IDX },
- { utc_livebox_acquire_fb_lock_p, POSITIVE_TC_IDX },
- { utc_livebox_release_fb_lock_n, NEGATIVE_TC_IDX },
- { utc_livebox_release_fb_lock_p, POSITIVE_TC_IDX },
- { NULL, 0 },
-};
-
diff --git a/doc/livebox-viewer_doc.h b/doc/livebox-viewer_doc.h
deleted file mode 100644
index 850d08d..0000000
--- a/doc/livebox-viewer_doc.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.
- */
-
-/*!
- * \ingroup CAPI_LIVEBOX_FRAMEWORK
- * \defgroup CAPI_LIVEBOX_VIEWER_MODULE Livebox Viewer
- * \brief API for livebox viewer (widget screen, home screen, ...)
- * \section CAPI_LIVEBOX_VIEWER_MODULE_HEADER Required Header
- * \#include <livebox.h>
- * \section CAPI_LIVEBOX_VIEWER_MODULE_OVERVIEW Overview
- * Tizen(SLP) homescreen S/W framework is supporing the live box. (aka widget which is similiar with the android widget)
- *
- * \image html front.jpg
- *
- * \subsection WhatIsTheLivebox 1. What is the Livebox
- * The live box is the widget of the TIZEN.
- *
- * It works as a small application displayed on other applications' (such as homescreen, lockscreen, etc ...) view.
- * Each live box can have (not a mandatory option) a PD (progressive disclosure) in which more detailed information can be found.
- * The content of PD can be exposed when a certain gesture (e.g., flick-down) has been applied to the live box.
- * If you are interested in developing a livebox, there are things you should know prior to making any source code for the box.
- * To make your live box added to any live box viewer application (e.g., live panel in our case), then you need to create and prepare
- * controller(SO file), layout script (EDJE for a PD if necessary), configuration files.
- *
- * A livebox is managed by data provider, since each SO file of a livebox is loaded on and controlled by data provider using predefined ABI.
- * A viewer will receive any livebox's content in forms of "image file", "buffer" or "text" and display the content in various formats on its window.
- * A livebox developer needs to make sure that your live box generates desirable content in-time on a explicit update-request or periodic update.
- *
- * After a data provider loads a livebox's SO file, it then assigns a specific "file name" for the livebox via an argument of a livebox function.
- * Since then the livebox just generates content using then given file name.
- * Passing an image file (whose name is the previously given name) is the basic method for providing contents to the viewer.
- * But if you want play animation or handles user event in real-time, you can use the buffer type.
- *
- * And you should prepare the content of the Progressive Disclosure.
- * The Progressive Dislcosure is only updated by the "buffer" type. so you should prepare the layout script for it.
- * If you didn't install any script file for progressive disclosure, the viewer will ignore the "flick down" event from your livebox.
- *
- * \subsubsection Livebox 1.1 Livebox
- * Live box is a default content of your widget. It always displays on the screen and updated periodically.
- * It looks like below captured images.
- * \image html weather.png Weather Livebox
- * \image html stock.png Stock Livebox
- * \image html twitter.png Twitter Livebox
- *
- * \subsubsection ProgressiveDisclosure 1.2 Progressive Disclosure
- * \image html PD.png Progressive Disclosure
- * Progressive disclosure will be displayed when a user flicks down a livebox. (basically it depends on the implementation of the view applications)
- * To supports this, a developer should prepare the layout script (EDJE only for the moment) of the livebox's PD. (or you can use the buffer directly)
- * Data provider supports EDJE script but the developer can use various scripts if (which is BIG IF) their interpreters can be implemented based on evas & ecore.
- *
- * When a layout script has been installed, data provider can load and rendering the given layout on the buffer.
- * The content on the buffer can be shared between applications that need to display the content on their window.
- * Description data file is necessary to place proper content components in rendered layout.
- * Check this page Description Data.
- *
- * \subsubsection ClusterCategory 1.3 What is the "cluster" and "category"
- * The cluster and the sub-cluster is just like the grouping concept.
- * It is used for creating/destorying your livebox instance when the data provider receives any context event from the context engine.
- * You will only get "user,created" cluster and "default" category(sub cluster) info.
- *
- * \subsection LiveboxContent 2. How the livebox can draw contents for viewer?
- * There are several ways to update the content of a livebox.
- *
- * \li Image file based content updating
- * \li Description file based content updating (with the layout script file)
- * \li Buffer based content updating
- *
- * Each method has specific benefit for implementing the livebox.
- *
- * \subsubsection ImageFormat 2.1 Via image file
- * This is the basic method for providing content of a livebox to the viewer application.
- * But this can be used only for the livebox. (Unavailable for the progressive disclosure).
- * When your livebox is created, the provider will assign an unique ID for your livebox(it would be a filename).
- * You should keep that ID until your livebox is running. The ID will be passed to you via livebox_create function.
- * \image html image_format.png
- *
- * When you need to update the output of your livebox, you should generate the image file using given ID(filename).
- * Then the data provider will recognize the event of updated output of a livebox and it will send that event to the viewer to reload it on the screen.
- *
- * \subsubsection ScriptFormat 2.2 Via layout script
- * \image html script_format.png
- * This method is supported for static layout & various contents (text & image)
- * When you develop your livebox, first design the layout of box content using script (edje is default)
- * Then the provider will load it to the content buffer and start rendering.
- * After the sciprt is loaded, you can fill it using description data format.
- * liblivebox defines description data handling functions.
- *
- * \subsubsection TextFormat 2.3 Via text data
- * \image html text_format.png
- * This is the simplified method to update the content of livebox.
- * So your box only need to update the text data using description data format.
- * Then the viewer will parse it to fill its screen.
- * So there is no buffer area, just viewer decide how handles it.
- *
- * \subsubsection BufferFormat 2.4 Via buffer
- * This method is very complex to implement.
- * The provider will give a content buffer to you, then your box should render its contents on this buffer.
- * This type is only supported for 3rd party livebox such as OSP and WEB.
- * Inhouse(EFL) livebox is not able to use this buffer type for the box content.
- *
- * \subsection PackageNTools 3. How can I get the development packages or tools?
- *
- * \subsection DevelopLivebox 4. How can I write a new livebox
- *
- * \subsection TestLivebox 5. How can I test my livebox
- *
- * \subsection LiveboxDirectory 6. Livebox directory hierachy
- * \image html preload_folder.png
- * \image html download_folder.png
- *
- */
-
diff --git a/dynamicbox_viewer/CMakeLists.txt b/dynamicbox_viewer/CMakeLists.txt
new file mode 100644
index 0000000..ed8efa1
--- /dev/null
+++ b/dynamicbox_viewer/CMakeLists.txt
@@ -0,0 +1,98 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(dynamicbox_viewer C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(PROJECT_NAME "${PROJECT_NAME}")
+SET(LIBDIR "\${exec_prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+SET(VERSION_MAJOR 1)
+SET(VERSION "${VERSION_MAJOR}.0.0")
+
+SET(CMAKE_SKIP_BUILD_RPATH true)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ dlog
+ aul
+ glib-2.0
+ gio-2.0
+ com-core
+ sqlite3
+ db-util
+ dynamicbox_service
+ vconf
+)
+
+SET(BUILD_SOURCE
+ src/client.c
+ src/conf.c
+ src/desc_parser.c
+ src/dlist.c
+ src/dynamicbox.c
+ src/dynamicbox_internal.c
+ src/file_service.c
+ src/master_rpc.c
+ src/util.c
+)
+
+IF (X11_SUPPORT)
+pkg_check_modules(pkgs_extra REQUIRED
+ x11
+ xext
+)
+
+SET(BUILD_SOURCE
+ ${BUILD_SOURCE}
+ src/fb.c
+)
+ADD_DEFINITIONS("-DHAVE_X11")
+ENDIF (X11_SUPPORT)
+
+IF (WAYLAND_SUPPORT)
+SET(BUILD_SOURCE
+ ${BUILD_SOURCE}
+ src/fb_wayland.c
+)
+ADD_DEFINITIONS("-DHAVE_WAYLAND")
+ENDIF (WAYLAND_SUPPORT)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+FOREACH(flag ${pkgs_extra_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline -g")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DLOG_TAG=\"DYNAMICBOX_VIEWER\"")
+ADD_DEFINITIONS("-DNDEBUG")
+ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET")
+#ADD_DEFINITIONS("-DFLOG")
+ADD_DEFINITIONS("-DMASTER_PKGNAME=\"data-provider-master\"")
+ADD_DEFINITIONS("-DINFO_SOCKET=\"/opt/usr/share/live_magazine/.live.socket\"")
+ADD_DEFINITIONS("-DCLIENT_SOCKET=\"/opt/usr/share/live_magazine/.client.socket\"")
+ADD_DEFINITIONS("-DSLAVE_SOCKET=\"/opt/usr/share/live_magazine/.slave.socket\"")
+ADD_DEFINITIONS("-DSERVICE_SOCKET=\"/opt/usr/share/live_magazine/.service.socket\"")
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${BUILD_SOURCE})
+
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${pkgs_extra_LDFLAGS} "-lpthread")
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc")
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/dynamicbox.h DESTINATION include/${PROJECT_NAME})
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "lib${PROJECT_NAME}")
diff --git a/LICENSE b/dynamicbox_viewer/LICENSE
index 571fe79..571fe79 100644
--- a/LICENSE
+++ b/dynamicbox_viewer/LICENSE
diff --git a/dynamicbox_viewer/doc/dynamicbox_viewer_doc.h b/dynamicbox_viewer/doc/dynamicbox_viewer_doc.h
new file mode 100644
index 0000000..bc13a86
--- /dev/null
+++ b/dynamicbox_viewer/doc/dynamicbox_viewer_doc.h
@@ -0,0 +1,197 @@
+/*
+ * 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.
+ */
+
+/**
+ * @ingroup CAPI_DYNAMICBOX_FRAMEWORK
+ * @defgroup DYNAMICBOX_VIEWER_MODULE Dynamic Box Viewer
+ * @brief API for dynamic box viewer (widget screen, home screen, ...)
+ * @section DYNAMICBOX_VIEWER_MODULE_HEADER Required Header
+ * \#include <dynamicbox.h>
+ * @section DYNAMICBOX_VIEWER_MODULE_OVERVIEW Overview
+ * Tizen homescreen S/W framework is supporing the Dynamic Box. (aka widget which is similiar with the android widget)
+ *
+ * @image html front.jpg
+ *
+ * @subsection WhatIsTheDynamicBox 1. What is the Dynamic Box
+ * The Dynamic Box is the widget of the TIZEN.
+ *
+ * It works as a small application displayed on other applications' (such as homescreen, lockscreen, etc ...) view.
+ * Each Dynamic Box can have (not a mandatory option) a Glance Bar (Glance Bar) in which more detailed information can be found.
+ * The content of Glance Bar can be exposed when a certain gesture (e.g., flick-down) has been applied to the Dynamic Box.
+ * If you are interested in developing a dynamic box, there are things you should know prior to making any source code for the box.
+ * To make your Dynamic Box added to any Dynamic Box viewer application (e.g., live panel in our case), then you need to create and prepare
+ * controller(SO file), layout script (EDJE for a Glance Bar if necessary), configuration files.
+ *
+ * A dynamic box is managed by data provider, since each SO file of a dynamic box is loaded on and controlled by data provider using predefined ABI.
+ * A viewer will receive any dynamic box's content in forms of "image file", "buffer" or "text" and display the content in various formats on its window.
+ * A dynamic box developer needs to make sure that your Dynamic Box generates desirable content in-time on a explicit update-request or periodic update.
+ *
+ * After a data provider loads a dynamic box's SO file, it then assigns a specific "file name" for the dynamic box via an argument of a dynamic box function.
+ * Since then the dynamic box just generates content using then given file name.
+ * Passing an image file (whose name is the previously given name) is the basic method for providing contents to the viewer.
+ * But if you want play animation or handles user event in real-time, you can use the buffer type.
+ *
+ * And you should prepare the content of the Glance Bar.
+ * The Glance Bar is only updated by the "buffer" type. so you should prepare the layout script for it.
+ * If you didn't install any script file for Glance Bar, the viewer will ignore the "flick down" event from your dynamic box.
+ *
+ * @subsubsection DynamicBox 1.1 Dynamic Box
+ * Live box is a default content of your widget. It always displays on the screen and updated periodically.
+ * It looks like below captured images.
+ * @image html weather.png Weather Dynamic Box
+ * @image html stock.png Stock Dynamic Box
+ * @image html twitter.png Twitter Dynamic Box
+ *
+ * @subsubsection GlanceBar 1.2 Glance Bar
+ * @image html PD.png Glance Bar
+ * Glance Bar will be displayed when a user flicks down a dynamic box. (basically it depends on the implementation of the viewer applications)
+ * To supports this, a developer should prepare the layout script (EDJE only for the moment) of the dynamic box's Glance Bar. (or you can use the buffer directly)
+ * Data provider supports EDJE script but the developer can use various scripts if (which is BIG IF) their interpreters can be implemented based on evas & ecore.
+ *
+ * When a layout script has been installed, data provider can load and rendering the given layout on the buffer.
+ * The content on the buffer can be shared between applications that need to display the content on their window.
+ * Description data file is necessary to place proper content components in rendered layout.
+ * Check this page Description Data.
+ *
+ * @subsubsection ClusterCategory 1.3 What is the "cluster" and "category"
+ * The cluster and the sub-cluster is just like the grouping concept.
+ * It is used for creating/destorying your dynamic box instance when the data provider receives any context event from the context engine.
+ * You will only get "user,created" cluster and "default" category(sub cluster) info.
+ *
+ * @subsection DynamicBoxContent 2. How the dynamic box can draw contents for viewer?
+ * There are several ways to update the content of a dynamic box.
+ *
+ * @li Image file based content updating
+ * @li Description file based content updating (with the layout script file)
+ * @li Buffer based content updating
+ *
+ * Each method has specific benefit for implementing the dynamic box.
+ *
+ * @subsubsection ImageFormat 2.1 Via image file
+ * This is the basic method for providing content of a dynamic box to the viewer application.
+ * But this can be used only for the dynamic box. (Unavailable for the Glance Bar).
+ * When your dynamic box is created, the provider will assign an unique ID for your dynamic box(it would be a filename).
+ * You should keep that ID until your dynamic box is running. The ID will be passed to you via dynamicbox_create function.
+ * \image html image_format.png
+ *
+ * When you need to update the output of your dynamic box, you should generate the image file using given ID(filename).
+ * Then the data provider will recognize the event of updated output of a dynamic box and it will send that event to the viewer to reload it on the screen.
+ *
+ * @subsubsection ScriptFormat 2.2 Via layout script
+ * @image html script_format.png
+ * This method is supported for static layout & various contents (text & image)
+ * When you develop your dynamic box, first design the layout of box content using script (edje is default)
+ * Then the provider will load it to the content buffer and start rendering.
+ * After the sciprt is loaded, you can fill it using description data format.
+ * libdynamicbox defines description data handling functions.
+ *
+ * @subsubsection TextFormat 2.3 Via text data
+ * @image html text_format.png
+ * This is the simplified method to update the content of dynamic box.
+ * So your box only need to update the text data using description data format.
+ * Then the viewer will parse it to fill its screen.
+ * So there is no buffer area, just viewer decide how handles it.
+ *
+ * @subsubsection BufferFormat 2.4 Via buffer
+ * This method is very complex to implement.
+ * The provider will give a content buffer to you, then your box should render its contents on this buffer.
+ * This type is only supported for 3rd party dynamic box such as OSP and WEB.
+ * Inhouse(EFL) dynamic box is not able to use this buffer type for the box content.
+ *
+ * @subsection DynamicBoxDirectory 3. Dynamic Box directory hierachy
+ * @image html preload_folder.png
+ * @image html download_folder.png
+ *
+ * @subsection WritingViewerApp 4. Writing a new application for displaying Dynamic Boxes
+ * If you want install dynamic boxes on your application screen, you should initialize the viewer system first.
+ *
+ * @code
+ * extern int dynamicbox_init(void *disp, int prevent_overwrite, double event_filter, int use_thread);
+ * @endcode
+ *
+ * @a disp should be current display object. if we are on X11 based windowing system, it will give you a Display Object, when you connect to X Server.
+ * Viewer application also needs it to preparing rendering buffer to display contents of dynamic boxes.
+ *
+ * @a prevent_overwirte flag is used for image or script type dynamic boxes.
+ * If this option is turn on, the viewer library will copy the image file of dyanmic box content to "reader" folder.
+ * To prevent from overwriting content image file.
+ *
+ * @a event_filter is used for feeding events.
+ * Basically, the dynamic box can be feed touch event by viewer application or master widget controller. (aka, data-provider-master).
+ * If a viewer feeds event to the dynamic box, it could more slow than data-provider-master's direct feeding.
+ * But sometimes, the viewer requires to feeds event by itself.
+ * In that case, we should choose the feeding option. feeding every events can be slow down.
+ * To save it, this event_filter will be used. if the event is generated in this time-gap, it will be ignored.
+ *
+ * @a use_thread if this flag is turned on, the viewer library will create a new thread for handling the IPC packets only.
+ * It will helps to increase the throughput of main thread. because it will not be interrupted to handles IPC packets.
+ *
+ * After the viewer is initiated, you can create a new box and locate it in your screen.
+ *
+ * Opposite function is "dynamicbox_fini"
+ *
+ * @code
+ * extern int dynamicbox_fini(void);
+ * @endcode
+ *
+ * Here is a sample code
+ *
+ * @code
+ * #include <stdio.h>
+ * #include <errno.h>
+ * #include <dynamicbox.h>
+ * #include <app.h>
+ *
+ * #include <dlog.h>
+ *
+ * int errno;
+ *
+ * static bool _create_cb(void *data)
+ * {
+ * int ret;
+ * ret = dynamicbox_init(NULL, 1, 0.0f, 1);
+ * if (ret != DBOX_STATUS_ERROR_NONE) {
+ * LOGE("Failed to initialize the dynamic box viewer");
+ * }
+ * return true;
+ * }
+ *
+ * static void _terminate_cb(void *data)
+ * {
+ * dynamicbox_fini();
+ * }
+ *
+ * int main(int argc, char *argv[])
+ * {
+ * app_event_callback_s event_callback;
+ * event_callback.create = _create_cb;
+ * event_callback.terminate = _terminate_cb;
+ * event_callback.pause = _pause_cb;
+ * event_callback.resume = _resume_cb;
+ * event_callback.app_control = _app_control;
+ * event_callback.low_memory = NULL;
+ * event_callback.low_battery = NULL;
+ * event_callback.device_orientation = NULL;
+ * event_callback.language_changed = _language_changed;
+ * event_callback.region_format_changed = NULL;
+ *
+ * return app_efl_main(&argc, &argv, &event_callback, &main_info);
+ * }
+ * @endocde
+ *
+ * If you want add a new dynamic box, you can call "dynamicbox_add()" function.
+ *
+ */
diff --git a/doc/image/PD.png b/dynamicbox_viewer/doc/image/PD.png
index ebb7367..ebb7367 100644
--- a/doc/image/PD.png
+++ b/dynamicbox_viewer/doc/image/PD.png
Binary files differ
diff --git a/doc/image/download_folder.png b/dynamicbox_viewer/doc/image/download_folder.png
index 1e5e01b..1e5e01b 100644
--- a/doc/image/download_folder.png
+++ b/dynamicbox_viewer/doc/image/download_folder.png
Binary files differ
diff --git a/doc/image/front.jpg b/dynamicbox_viewer/doc/image/front.jpg
index 9d46441..9d46441 100644
--- a/doc/image/front.jpg
+++ b/dynamicbox_viewer/doc/image/front.jpg
Binary files differ
diff --git a/doc/image/image_format.png b/dynamicbox_viewer/doc/image/image_format.png
index 8f79a0c..8f79a0c 100644
--- a/doc/image/image_format.png
+++ b/dynamicbox_viewer/doc/image/image_format.png
Binary files differ
diff --git a/doc/image/message.png b/dynamicbox_viewer/doc/image/message.png
index 4cb7760..4cb7760 100644
--- a/doc/image/message.png
+++ b/dynamicbox_viewer/doc/image/message.png
Binary files differ
diff --git a/doc/image/preload_folder.png b/dynamicbox_viewer/doc/image/preload_folder.png
index 3dbbf64..3dbbf64 100644
--- a/doc/image/preload_folder.png
+++ b/dynamicbox_viewer/doc/image/preload_folder.png
Binary files differ
diff --git a/doc/image/script_format.png b/dynamicbox_viewer/doc/image/script_format.png
index 1fec88a..1fec88a 100644
--- a/doc/image/script_format.png
+++ b/dynamicbox_viewer/doc/image/script_format.png
Binary files differ
diff --git a/doc/image/stock.png b/dynamicbox_viewer/doc/image/stock.png
index fd274fe..fd274fe 100644
--- a/doc/image/stock.png
+++ b/dynamicbox_viewer/doc/image/stock.png
Binary files differ
diff --git a/doc/image/text_format.png b/dynamicbox_viewer/doc/image/text_format.png
index b492883..b492883 100644
--- a/doc/image/text_format.png
+++ b/dynamicbox_viewer/doc/image/text_format.png
Binary files differ
diff --git a/doc/image/twitter.png b/dynamicbox_viewer/doc/image/twitter.png
index 36bce25..36bce25 100644
--- a/doc/image/twitter.png
+++ b/dynamicbox_viewer/doc/image/twitter.png
Binary files differ
diff --git a/doc/image/weather.png b/dynamicbox_viewer/doc/image/weather.png
index 2f41af1..2f41af1 100644
--- a/doc/image/weather.png
+++ b/dynamicbox_viewer/doc/image/weather.png
Binary files differ
diff --git a/dynamicbox_viewer/dynamicbox_viewer.pc.in b/dynamicbox_viewer/dynamicbox_viewer.pc.in
new file mode 100644
index 0000000..8d1c185
--- /dev/null
+++ b/dynamicbox_viewer/dynamicbox_viewer.pc.in
@@ -0,0 +1,12 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: dynamicbox-viewer
+Description: Support development of the Dynamic Box Viewer
+Version: @VERSION@
+Requires.private: dynamicbox_service
+Libs: -L${libdir} -ldynamicbox_viewer
+Cflags: -I${includedir}
+cppflags: -I${includedir}
diff --git a/include/client.h b/dynamicbox_viewer/include/client.h
index db8a931..dc7a744 100644
--- a/include/client.h
+++ b/dynamicbox_viewer/include/client.h
@@ -17,6 +17,8 @@
extern int client_init(int use_thread);
extern int client_fd(void);
extern const char *client_addr(void);
+extern const char *client_direct_addr(void);
+extern int client_direct_fd(void);
extern int client_fini(void);
/* End of a file */
diff --git a/include/conf.h b/dynamicbox_viewer/include/conf.h
index 83f2ff4..de5375a 100644
--- a/include/conf.h
+++ b/dynamicbox_viewer/include/conf.h
@@ -18,12 +18,12 @@
* \note
* milli seconds
*/
-#define MAX_LOG_FILE 3
-#define MAX_LOG_LINE 1000
-#define SLAVE_LOG_PATH "/tmp/.dbox.service/log/"
+#define MAX_LOG_FILE 3
+#define MAX_LOG_LINE 1000
+#define SLAVE_LOG_PATH "/tmp/.dbox.service/log/"
#if !defined(VCONFKEY_MASTER_STARTED)
-#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started"
+#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started"
#endif
#if !defined(VCONFKEY_MASTER_CLIENT_ADDR)
@@ -38,5 +38,11 @@ extern void conf_set_shared_content(int flag);
extern int conf_shared_content(void);
extern double conf_event_filter(void);
extern void conf_set_event_filter(double filter);
+extern void conf_set_direct_update(int flag);
+extern int conf_direct_update(void);
+extern int conf_extra_buffer_count(void);
+extern void conf_set_extra_buffer_count(int buffer_count);
+extern dynamicbox_status_e conf_last_status(void);
+extern void conf_set_last_status(dynamicbox_status_e status);
/* End of a file */
diff --git a/include/debug.h b/dynamicbox_viewer/include/debug.h
index d06862c..a6563ee 100644
--- a/include/debug.h
+++ b/dynamicbox_viewer/include/debug.h
@@ -15,8 +15,8 @@
*/
#if !defined(FLOG)
-#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg)
-#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg)
+#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg)
+#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg)
#else
extern FILE *__file_log_fp;
#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
diff --git a/include/desc_parser.h b/dynamicbox_viewer/include/desc_parser.h
index a7e0092..ccc7800 100644
--- a/include/desc_parser.h
+++ b/dynamicbox_viewer/include/desc_parser.h
@@ -14,6 +14,6 @@
* limitations under the License.
*/
-extern int parse_desc(struct livebox_common *common, const char *filename, int is_pd);
+extern int parse_desc(struct dynamicbox_common *common, const char *filename, int is_pd);
/* End of a file */
diff --git a/live.viewer/include/dlist.h b/dynamicbox_viewer/include/dlist.h
index cd1a421..3f19827 100644
--- a/live.viewer/include/dlist.h
+++ b/dynamicbox_viewer/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); (l) && ((data) = dlist_data(l)); (l) = dlist_next(l))
+ for ((l) = (list); (l) && ((data) = dlist_data(l)); (l) = dlist_next(l))
#define dlist_foreach_safe(list, l, n, data) \
- for ((l) = (list), (n) = dlist_next(l); \
- (l) && ((data) = dlist_data(l)); \
- (l) = (n), (n) = dlist_next(l))
+ for ((l) = (list), (n) = dlist_next(l); \
+ (l) && ((data) = dlist_data(l)); \
+ (l) = (n), (n) = dlist_next(l))
struct dlist;
diff --git a/dynamicbox_viewer/include/dynamicbox.h b/dynamicbox_viewer/include/dynamicbox.h
new file mode 100644
index 0000000..703a760
--- /dev/null
+++ b/dynamicbox_viewer/include/dynamicbox.h
@@ -0,0 +1,1675 @@
+/*
+ * 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 <dynamicbox_service.h>
+
+#ifndef __DYNAMICBOX_VIEWER_H
+#define __DYNAMICBOX_VIEWER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file dynamicbox.h
+ * @brief This file declares API of libdynamicbox-viewer library
+ * @since_tizen 2.3
+ */
+
+/**
+ * @addtogroup CAPI_DYNAMICBOX_VIEWER_MODULE
+ * @{
+ */
+
+/**
+ * @internal
+ * @brief Structure definition for a Dynamic Box instance.
+ * @since_tizen 2.3
+ */
+typedef struct dynamicbox *dynamicbox_h;
+
+/**
+ * @internal
+ * @brief Definition for a default update period for Dynamicbox (defined in the package manifest file).
+ * @since_tizen 2.3
+ */
+#define DBOX_DEFAULT_PERIOD -1.0f
+
+/**
+ * @internal
+ * @brief Enumeration for Mouse & Key event for buffer type Dynamic Box or Glance Bar.
+ * @details Viewer should send these events to dynamicbox.
+ * @since_tizen 2.3
+ */
+typedef enum dynamicbox_mouse_event_type {
+ DBOX_MOUSE_EVENT_MASK = 0x20000000, /**< Mask value for mouse event */
+ DBOX_MOUSE_EVENT_GBAR_MASK = 0x10000000, /**< Mask value for Glance Bar event */
+ DBOX_MOUSE_EVENT_DBOX_MASK = 0x40000000, /**< Mask value for Dynamic Box event */
+
+ DBOX_MOUSE_EVENT_DOWN = 0x00000001, /**< Dynamic Box mouse down event for dynamicbox */
+ DBOX_MOUSE_EVENT_UP = 0x00000002, /**< Dynamic Box mouse up event for dynamicbox */
+ DBOX_MOUSE_EVENT_MOVE = 0x00000004, /**< Dynamic Box mouse move event for dynamicbox */
+ DBOX_MOUSE_EVENT_ENTER = 0x00000008, /**< Dynamic Box mouse enter event for dynamicbox */
+ DBOX_MOUSE_EVENT_LEAVE = 0x00000010, /**< Dynamic Box mouse leave event for dynamicbox */
+ DBOX_MOUSE_EVENT_SET = 0x00000020, /**< Dynamic Box mouse set auto event for dynamicbox */
+ DBOX_MOUSE_EVENT_UNSET = 0x00000040, /**< Dynamic Box mouse unset auto event for dynamicbox */
+
+ DBOX_MOUSE_EVENT_ON_SCROLL = 0x00000080, /**< Dynamic Box On scrolling */
+ DBOX_MOUSE_EVENT_ON_HOLD = 0x00000100, /**< Dynamic Box On holding */
+ DBOX_MOUSE_EVENT_OFF_SCROLL = 0x00000200, /**< Dynamic Box Stop scrolling */
+ DBOX_MOUSE_EVENT_OFF_HOLD = 0x00000400, /**< Dynamic Box Stop holding */
+
+ DBOX_MOUSE_ON_SCROLL = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_ON_SCROLL, /**< Mouse event occurs while scrolling */
+ DBOX_MOUSE_ON_HOLD = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_ON_HOLD, /**< Mouse event occurs on holding */
+ DBOX_MOUSE_OFF_SCROLL = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_OFF_SCROLL, /**< Scrolling stopped */
+ DBOX_MOUSE_OFF_HOLD = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_OFF_HOLD, /**< Holding stopped */
+
+ DBOX_MOUSE_DOWN = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_DOWN, /**< Mouse down on the dynamicbox */
+ DBOX_MOUSE_UP = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_UP, /**< Mouse up on the dynamicbox */
+ DBOX_MOUSE_MOVE = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_MOVE, /**< Move move on the dynamicbox */
+ DBOX_MOUSE_ENTER = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_ENTER, /**< Mouse enter to the dynamicbox */
+ DBOX_MOUSE_LEAVE = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_LEAVE, /**< Mouse leave from the dynamicbox */
+ DBOX_MOUSE_SET = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_SET, /**< Mouse event, start feeding event by master */
+ DBOX_MOUSE_UNSET = DBOX_MOUSE_EVENT_DBOX_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_UNSET, /**< Mouse event, stop feeding event by master */
+
+ DBOX_GBAR_MOUSE_ON_SCROLL = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_ON_SCROLL, /**< Mouse event occurs while scrolling */
+ DBOX_GBAR_MOUSE_ON_HOLD = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_ON_HOLD, /**< Mouse event occurs on holding */
+ DBOX_GBAR_MOUSE_OFF_SCROLL = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_OFF_SCROLL, /**< Scrolling stopped */
+ DBOX_GBAR_MOUSE_OFF_HOLD = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_OFF_HOLD, /**< Holding stopped */
+
+ DBOX_GBAR_MOUSE_DOWN = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_DOWN, /**< Mouse down on the Glance Bar */
+ DBOX_GBAR_MOUSE_UP = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_UP, /**< Mouse up on the Glance Bar */
+ DBOX_GBAR_MOUSE_MOVE = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_MOVE, /**< Mouse move on the Glance Bar */
+ DBOX_GBAR_MOUSE_ENTER = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_ENTER, /**< Mouse enter to the Glance Bar */
+ DBOX_GBAR_MOUSE_LEAVE = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_LEAVE, /**< Mouse leave from the Glance Bar */
+ DBOX_GBAR_MOUSE_SET = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_SET, /**< Mouse event, start feeding event by master */
+ DBOX_GBAR_MOUSE_UNSET = DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_MASK | DBOX_MOUSE_EVENT_UNSET, /**< Mouse event, stop feeding event by master */
+
+ DBOX_MOUSE_EVENT_MAX = 0xFFFFFFFF /**< Unknown event */
+} dynamicbox_mouse_event_type_e;
+
+typedef enum dynamicbox_key_event_type {
+ DBOX_KEY_EVENT_MASK = 0x80000000, /**< Mask value for key event */
+ DBOX_KEY_EVENT_GBAR_MASK = 0x10000000, /**< Mask value for Glance Bar event */
+ DBOX_KEY_EVENT_DBOX_MASK = 0x40000000, /**< Mask value for Dynamic Box event */
+
+ DBOX_KEY_EVENT_DOWN = 0x00000001, /**< Dynamic Box key press */
+ DBOX_KEY_EVENT_UP = 0x00000002, /**< Dynamic Box key release */
+ DBOX_KEY_EVENT_FOCUS_IN = 0x00000008, /**< Dynamic Box key focused in */
+ DBOX_KEY_EVENT_FOCUS_OUT = 0x00000010, /**< Dynamic Box key focused out */
+ DBOX_KEY_EVENT_SET = 0x00000020, /**< Dynamic Box Key, start feeding event by master */
+ DBOX_KEY_EVENT_UNSET = 0x00000040, /**< Dynamic Box key, stop feeding event by master */
+
+ DBOX_KEY_DOWN = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_DBOX_MASK | DBOX_KEY_EVENT_DOWN, /**< Key down on the dynamicbox */
+ DBOX_KEY_UP = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_DBOX_MASK | DBOX_KEY_EVENT_UP, /**< Key up on the dynamicbox */
+ DBOX_KEY_SET = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_DBOX_MASK | DBOX_KEY_EVENT_SET, /**< Key event, start feeding event by master */
+ DBOX_KEY_UNSET = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_DBOX_MASK | DBOX_KEY_EVENT_UNSET, /**< Key event, stop feeding event by master */
+ DBOX_KEY_FOCUS_IN = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_DBOX_MASK | DBOX_KEY_EVENT_FOCUS_IN, /**< Key event, focus in */
+ DBOX_KEY_FOCUS_OUT = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_DBOX_MASK | DBOX_KEY_EVENT_FOCUS_OUT, /**< Key event, foucs out */
+
+ DBOX_GBAR_KEY_DOWN = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_GBAR_MASK | DBOX_KEY_EVENT_DOWN, /**< Key down on the dynamicbox */
+ DBOX_GBAR_KEY_UP = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_GBAR_MASK | DBOX_KEY_EVENT_UP, /**< Key up on the dynamicbox */
+ DBOX_GBAR_KEY_SET = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_GBAR_MASK | DBOX_KEY_EVENT_SET, /**< Key event, start feeding event by master */
+ DBOX_GBAR_KEY_UNSET = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_GBAR_MASK | DBOX_KEY_EVENT_UNSET, /**< Key event, stop feeding event by master */
+ DBOX_GBAR_KEY_FOCUS_IN = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_GBAR_MASK | DBOX_KEY_EVENT_FOCUS_IN, /**< Key event, focus in */
+ DBOX_GBAR_KEY_FOCUS_OUT = DBOX_KEY_EVENT_MASK | DBOX_KEY_EVENT_GBAR_MASK | DBOX_KEY_EVENT_FOCUS_OUT, /**< Key event, focus out */
+
+ DBOX_KEY_EVENT_MAX = 0xFFFFFFFF /**< Unknown event */
+} dynamicbox_key_event_type_e;
+
+/**
+ * @internal
+ * @brief Enumeration for Accessibility event for buffer type Dynamic Box or Glance Bar.
+ * @details These events are sync'd with Tizen accessibility event set.
+ * @since_tizen 2.3
+ */
+typedef enum dynamicbox_access_event_type {
+ DBOX_ACCESS_EVENT_GBAR_MASK = 0x10000000, /**< Glance Bar Accessibilivent mask */
+ DBOX_ACCESS_EVENT_DBOX_MASK = 0x20000000, /**< Dynamic Box Accessibility event mask */
+
+ DBOX_ACCESS_EVENT_HIGHLIGHT = 0x00000100, /**< Dynamic Box accessibility: Hightlight a object, Next, Prev,Unhighlight */
+ DBOX_ACCESS_EVENT_ACTIVATE = 0x00000200, /**< Dynamic Box accessibility activate */
+ DBOX_ACCESS_EVENT_ACTION = 0x00000400, /**< Dynamic Box accessibility value changed, Up, Down */
+ DBOX_ACCESS_EVENT_SCROLL = 0x00000800, /**< Dynamic Box accessibility scroll down, move, up */
+ DBOX_ACCESS_EVENT_VALUE_CHANGE = 0x00001000, /**< LB accessibility value change */
+ DBOX_ACCESS_EVENT_MOUSE = 0x00002000, /**< Give mouse event to highlight object, down, move, up */
+ DBOX_ACCESS_EVENT_BACK = 0x00004000, /**< Go back to a previous view ex: pop naviframe item */
+ DBOX_ACCESS_EVENT_OVER = 0x00008000, /**< Mouse over an object */
+ DBOX_ACCESS_EVENT_READ = 0x00010000, /**< Highlight an object */
+ DBOX_ACCESS_EVENT_ENABLE = 0x00020000, /**< Disable highlight and read ability, disable, enable */
+
+ DBOX_ACCESS_HIGHLIGHT = DBOX_ACCESS_EVENT_DBOX_MASK | DBOX_ACCESS_EVENT_HIGHLIGHT, /**< Access event - Highlight an object in the dynamicbox */
+ DBOX_ACCESS_ACTIVATE = DBOX_ACCESS_EVENT_DBOX_MASK | DBOX_ACCESS_EVENT_ACTIVATE, /**< Access event - Launch or activate the highlighted object */
+ DBOX_ACCESS_ACTION = DBOX_ACCESS_EVENT_DBOX_MASK | DBOX_ACCESS_EVENT_ACTION, /**< Access event - down */
+ DBOX_ACCESS_SCROLL = DBOX_ACCESS_EVENT_DBOX_MASK | DBOX_ACCESS_EVENT_SCROLL, /**< Access event - scroll down */
+ DBOX_ACCESS_VALUE_CHANGE = DBOX_ACCESS_EVENT_DBOX_MASK | DBOX_ACCESS_EVENT_VALUE_CHANGE, /**< LB accessibility value change */
+ DBOX_ACCESS_MOUSE = DBOX_ACCESS_EVENT_DBOX_MASK | DBOX_ACCESS_EVENT_MOUSE, /**< Give mouse event to highlight object */
+ DBOX_ACCESS_BACK = DBOX_ACCESS_EVENT_DBOX_MASK | DBOX_ACCESS_EVENT_BACK, /**< Go back to a previous view ex: pop naviframe item */
+ DBOX_ACCESS_OVER = DBOX_ACCESS_EVENT_DBOX_MASK | DBOX_ACCESS_EVENT_OVER, /**< Mouse over an object */
+ DBOX_ACCESS_READ = DBOX_ACCESS_EVENT_DBOX_MASK | DBOX_ACCESS_EVENT_READ, /**< Highlight an object */
+ DBOX_ACCESS_ENABLE = DBOX_ACCESS_EVENT_DBOX_MASK | DBOX_ACCESS_EVENT_ENABLE, /**< Enable highlight and read ability */
+
+ DBOX_GBAR_ACCESS_HIGHLIGHT = DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_HIGHLIGHT, /**< Access event - Highlight an object in the Glance Bar */
+ DBOX_GBAR_ACCESS_ACTIVATE = DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_ACTIVATE, /**< Access event - Launch or activate the highlighted object */
+ DBOX_GBAR_ACCESS_ACTION = DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_ACTION, /**< Access event - down */
+ DBOX_GBAR_ACCESS_SCROLL = DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_SCROLL, /**< Access event - scroll down */
+ DBOX_GBAR_ACCESS_VALUE_CHANGE = DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_VALUE_CHANGE, /**< LB accessibility value change */
+ DBOX_GBAR_ACCESS_MOUSE = DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_MOUSE, /**< Give mouse event to highlight object */
+ DBOX_GBAR_ACCESS_BACK = DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_BACK, /**< Go back to a previous view ex: pop naviframe item */
+ DBOX_GBAR_ACCESS_OVER = DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_OVER, /**< Mouse over an object */
+ DBOX_GBAR_ACCESS_READ = DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_READ, /**< Highlight an object */
+ DBOX_GBAR_ACCESS_ENABLE = DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_ENABLE, /**< Enable highlight and read ability */
+ DBOX_GBAR_ACCESS_EVENT_MAX = 0xFFFFFFFF
+} dynamicbox_access_event_type_e;
+
+/**
+ * @internal
+ * @brief Enumeration for Dynamic Box content type.
+ * @since_tizen 2.3
+ */
+typedef enum dynamicbox_type {
+ DBOX_CONTENT_TYPE_IMAGE = 0x01, /**< Contents of a dynamicbox is based on the image file */
+ DBOX_CONTENT_TYPE_BUFFER = 0x02, /**< Contents of a dynamicbox is based on canvas buffer(shared) */
+ DBOX_CONTENT_TYPE_TEXT = 0x04, /**< Contents of a dynamicbox is based on formatted text file */
+ DBOX_CONTENT_TYPE_RESOURCE_ID = 0x08, /**< Contens of a dynamicbox is shared by the resource id(depends on window system) */
+ DBOX_CONTENT_TYPE_UIFW = 0x10, /**< Using UI F/W resource for sharing content & event */
+ DBOX_CONTENT_TYPE_INVALID = 0xFF /**< Unknown Dynamic Box type */
+} dynamicbox_type_e;
+
+/**
+ * @internal
+ * @brief Enumeration for Dynamicbox event type.
+ * @details These events will be sent from the provider.
+ * @since_tizen 2.3
+ */
+typedef enum dynamicbox_event_type { /**< dynamicbox_event_handler_set Event list */
+ DBOX_EVENT_DBOX_UPDATED, /**< Contents of the given dynamicbox is updated */
+ DBOX_EVENT_DBOX_EXTRA_UPDATED,
+ DBOX_EVENT_GBAR_UPDATED, /**< Contents of the given pd is updated */
+ DBOX_EVENT_GBAR_EXTRA_UPDATED,
+
+ DBOX_EVENT_CREATED, /**< A new dynamicbox is created */
+ DBOX_EVENT_DELETED, /**< A dynamicbox is deleted */
+
+ DBOX_EVENT_GROUP_CHANGED, /**< Group (Cluster/Sub-cluster) information is changed */
+ DBOX_EVENT_PINUP_CHANGED, /**< PINUP status is changed */
+ DBOX_EVENT_PERIOD_CHANGED, /**< Update period is changed */
+
+ DBOX_EVENT_DBOX_SIZE_CHANGED, /**< Dynamicbox size is changed */
+ DBOX_EVENT_GBAR_SIZE_CHANGED, /**< Glance Bar size is changed */
+
+ DBOX_EVENT_GBAR_CREATED, /**< If a Glance Bar is created even if you didn't call the dynamicbox_create_glance_bar API */
+ DBOX_EVENT_GBAR_DESTROYED, /**< If a Glance Bar is destroyed even if you didn't call the dynamicbox_destroy_glance_bar API */
+
+ DBOX_EVENT_HOLD_SCROLL, /**< If the screen should be freezed */
+ DBOX_EVENT_RELEASE_SCROLL, /**< If the screen can be scrolled */
+
+ DBOX_EVENT_DBOX_UPDATE_BEGIN, /**< Dynamic Box content update is started */
+ DBOX_EVENT_DBOX_UPDATE_END, /**< Dynamic Box content update is finished */
+
+ DBOX_EVENT_GBAR_UPDATE_BEGIN, /**< Glance Bar content update is started */
+ DBOX_EVENT_GBAR_UPDATE_END, /**< Glance Bar content update is finished */
+
+ DBOX_EVENT_UPDATE_MODE_CHANGED, /**< Dynamic Box Update mode is changed */
+
+ DBOX_EVENT_REQUEST_CLOSE_GBAR, /**< Dynamic Box requests to close the Glance Bar */
+
+ DBOX_EVENT_EXTRA_INFO_UPDATED, /**< Extra information is updated */
+
+ DBOX_EVENT_DBOX_EXTRA_BUFFER_CREATED, /**< DBOX Extra Buffer created event */
+ DBOX_EVENT_GBAR_EXTRA_BUFFER_CREATED, /**< GBAR Extra Buffer created event */
+
+ DBOX_EVENT_DBOX_EXTRA_BUFFER_DESTROYED, /**< DBOX Extra Buffer destroyed event */
+ DBOX_EVENT_GBAR_EXTRA_BUFFER_DESTROYED, /**< DBOX Extra Buffer destroyed event */
+
+ DBOX_EVENT_IGNORED = 0xFF /**< Request is ignored */
+} dynamicbox_event_type_e;
+
+/**
+ * @internal
+ * @brief Enumeration for Dynamicbox option types.
+ * @since_tizen 2.3
+ */
+typedef enum dynamicbox_option_type {
+ DBOX_OPTION_MANUAL_SYNC, /**< Sync frame manually */
+ DBOX_OPTION_FRAME_DROP_FOR_RESIZE, /**< Drop frames while resizing */
+ DBOX_OPTION_SHARED_CONTENT, /**< Use only one real instance for multiple fake instances if user creates dbox for same content */
+ DBOX_OPTION_DIRECT_UPDATE, /**< Use the private socket for receiving updated event */
+ DBOX_OPTION_EXTRA_BUFFER_CNT, /**< Extra buffer count, ReadOnly value */
+
+ DBOX_OPTION_ERROR = 0xFFFFFFFF /**< To specify the size of this enumeration type */
+} dynamicbox_option_type_e;
+
+/**
+ * @internal
+ * @brief Reason of faults
+ * @since_tizen 2.3
+ */
+typedef enum dynamicbox_fault_type {
+ DBOX_FAULT_DEACTIVATED, /**< Dynamicbox is deactivated by its fault operation */
+ DBOX_FAULT_PROVIDER_DISCONNECTED, /**< Provider is disconnected */
+ DBOX_FAULT_MAX = 0xFF /**< To specify the size of this enumeration type, some compiler enjoy of this kind of notation */
+} dynamicbox_fault_type_e;
+
+/**
+ * @internal
+ * @brief Enumeration for Dynamicbox visible states.
+ * @details Must be sync'd with a provider.
+ * @since_tizen 2.3
+ */
+typedef enum dynamicbox_visible_state {
+ DBOX_SHOW = 0x00, /**< Dynamicbox is shown. Default state */
+ DBOX_HIDE = 0x01, /**< Dynamicbox is hidden, Update timer will not be freezed. but you cannot receive any updates events. */
+
+ DBOX_HIDE_WITH_PAUSE = 0x02, /**< Dynamicbox is hidden, it will pause the update timer, but if a dynamicbox updates its contents, update event will be triggered */
+
+ DBOX_VISIBLE_ERROR = 0xFF /**< To specify the size of this enumeration type */
+} dynamicbox_visible_state_e;
+
+/**
+ * @internal
+ * @brief Accessibility Event type
+ * @since_tizen 2.3
+ * @see dynamicbox_feed_access_event()
+ */
+typedef enum dynamicbox_access_info_type {
+ DBOX_ACCESS_TYPE_NONE = 0x00, /**< Initialized */
+
+ DBOX_ACCESS_TYPE_DOWN = 0x00, /**< Mouse down */
+ DBOX_ACCESS_TYPE_MOVE = 0x01, /**< Mouse move */
+ DBOX_ACCESS_TYPE_UP = 0x02, /**< Mouse up */
+
+ DBOX_ACCESS_TYPE_HIGHLIGHT = 0x00, /**< Highlight */
+ DBOX_ACCESS_TYPE_HIGHLIGHT_NEXT = 0x01, /**< Highlight next */
+ DBOX_ACCESS_TYPE_HIGHLIGHT_PREV = 0x02, /**< Highlight prev */
+ DBOX_ACCESS_TYPE_UNHIGHLIGHT = 0x03, /**< Unhighlight */
+
+ DBOX_ACCESS_TYPE_DISABLE = 0x00, /**< Disable */
+ DBOX_ACCESS_TYPE_ENABLE = 0x01 /**< Enable */
+} dynamicbox_access_info_type_e;
+
+/**
+ * @internal
+ * @brief Accessibility Event Information
+ * @since_tizen 2.3
+ */
+typedef struct dynamicbox_access_event_info {
+ double x; /**< X Coordinates that the event occurred */
+ double y; /**< Y Coordinates that the event occurred */
+ dynamicbox_access_info_type_e type; /**< Accessibility event type */
+ int info; /**< Extra information for this event */
+} *dynamicbox_access_event_info_t;
+
+/**
+ * @internal
+ * @brief Damaged Region representation
+ * @since_tizen 2.3
+ */
+typedef struct dynamicbox_damage_region {
+ int x; /**< Coordinates X of Left-Top corner */
+ int y; /**< Coordinates Y of Left-Top corner */
+ int w; /**< Damage'd Width */
+ int h; /**< Damage'd Height */
+} dynamicbox_damage_region_t;
+
+/**
+ * @internal
+ * @brief Mouse Event Information
+ * @since_tizen 2.3
+ */
+typedef struct dynamicbox_mouse_event_info {
+ double x; /**< X coordinates of Mouse Event */
+ double y; /**< Y coordinates of Mouse Event */
+} *dynamicbox_mouse_event_info_t;
+
+/**
+ * @internal
+ * @brief Key Event Information
+ * @since_tizen 2.3
+ */
+typedef struct dynamicbox_key_event_info {
+ unsigned int keycode; /**< Key code */
+} *dynamicbox_key_event_info_t;
+
+/**
+ * @internal
+ * @brief Text Event Information
+ * @since_tizen 2.3
+ */
+typedef struct dynamicbox_text_event {
+ const char *emission;
+ const char *source;
+ struct {
+ double sx;
+ double sy;
+ double ex;
+ double ey;
+ } geometry;
+} *dynamicbox_text_event_t;
+
+/**
+ * @internal
+ * @brief Structure for TEXT type dynamicbox contents handling opertators.
+ * @since_tizen 2.3
+ */
+typedef struct dynamicbox_script_operators {
+ int (*update_begin)(dynamicbox_h handle); /**< Content parser is started */
+ int (*update_end)(dynamicbox_h handle); /**< Content parser is finished */
+
+ /* Listed functions will be called when parser meets each typed content */
+ int (*update_text)(dynamicbox_h handle, const char *id, const char *part, const char *data); /**< Update text content */
+ int (*update_image)(dynamicbox_h handle, const char *id, const char *part, const char *data, const char *option); /**< Update image content */
+ int (*update_script)(dynamicbox_h handle, const char *id, const char *new_id, const char *part, const char *file, const char *group); /**< Update script content */
+ int (*update_signal)(dynamicbox_h handle, const char *id, const char *emission, const char *signal); /**< Update signal */
+ int (*update_drag)(dynamicbox_h handle, const char *id, const char *part, double dx, double dy); /**< Update drag info */
+ int (*update_info_size)(dynamicbox_h handle, const char *id, int w, int h); /**< Update content size */
+ int (*update_info_category)(dynamicbox_h handle, const char *id, const char *category); /**< Update content category info */
+ int (*update_access)(dynamicbox_h handle, const char *id, const char *part, const char *text, const char *option); /**< Update access information */
+ int (*operate_access)(dynamicbox_h handle, const char *id, const char *part, const char *operation, const char *option); /**< Update access operation */
+ int (*update_color)(dynamicbox_h handle, const char *id, const char *part, const char *data); /**< Update color */
+} *dynamicbox_script_operator_t;
+
+/**
+ * @internal
+ * @brief Called for every async function.
+ * @details Prototype of the return callback of every async functions.
+ * @since_tizen 2.3
+ * @param[in] handle Handle of the dynamicbox instance
+ * @param[in] ret Result status of operation (DBOX_STATUS_XXX defined from libdynamicbox-service)
+ * @param[in] data Data for result callback
+ * @return void
+ * @see dynamicbox_add()
+ * @see dynamicbox_del()
+ * @see dynamicbox_activate()
+ * @see dynamicbox_resize()
+ * @see dynamicbox_set_group()
+ * @see dynamicbox_set_period()
+ * @see dynamicbox_access_event()
+ * @see dynamicbox_set_pinup()
+ * @see dynamicbox_create_glance_bar()
+ * @see dynamicbox_destroy_glance_bar()
+ * @see dynamicbox_emit_text_signal()
+ * @see dynamicbox_acquire_resource_id()
+ * @see dynamicbox_set_update_mode()
+ */
+typedef void (*dynamicbox_ret_cb)(dynamicbox_h handle, int ret, void *data);
+
+/**
+ * @internal
+ * @brief Fault event handler
+ * @param[in] type Type of fault event.
+ * @param[in] dbox_id Faulted DynamicBox Id
+ * @param[in] file faulted filename (implementation file if it is supported)
+ * @param[in] func faulted function name (if it is supported)
+ * @param[in] data Callback data
+ * @return int status
+ * @retval @c EXIT_FAILURE delete this event callback from the event callback list
+ * @retval @c EXIT_SUCCESS successfully handled, keep this callback in the event callback list
+ */
+typedef int (*dynamicbox_fault_handler_cb)(enum dynamicbox_fault_type type, const char *dbox_id, const char *file, const char *func, void *data);
+
+/**
+ * @internal
+ * @brief Event handler
+ * @since_tizen 2.3
+ * @param[in] handler Dynamic Box Event handler
+ * @param[in] event Event type for Dynamic Box
+ * @param[in] data Callback Data
+ * @return int status
+ * @return @c EXIT_FAILURE delete this event callback from the event callback list
+ * @return @c EXIT_SUCCESS successfully handled, keep this callback in the event callback list
+ */
+typedef int (*dynamicbox_event_handler_cb)(dynamicbox_h handler, dynamicbox_event_type_e event, void *data);
+
+/**
+ * @internal
+ * @brief Auto launch handler
+ * @since_tizen 2.3
+ * @param[in] handler DynamicBox Handler
+ * @param[in] appid UI Application Id, which should be launched
+ * @param[in] data callback data
+ */
+typedef int (*dynamicbox_auto_launch_handler_cb)(dynamicbox_h handler, const char *appid, void *data);
+
+/**
+ * @internal
+ * @brief Initializes the dynamicbox system with some options.
+ * @details dynamicbox_init function uses environment value to initiate some configurable values.
+ * But some applications do not want to use the env value.
+ * For them, this API will give a chance to set default options using given arguments.
+ * @a disp is a Display object which is used to hold a connection with a display server (eg, Xorg)
+ * @since_tizen 2.3
+ * @param[in] disp Display, If @a disp is @c NULL, the library will try to acquire a new connection to display server
+ * @param[in] prevent_overwrite Overwrite flag (when the content of an image type dynamicbox is updated, it will be overwriten (0) or not (1))
+ * @param[in] event_filter If the dynamicbox_feed_mouse_event() is called again in this secs, it will be ignored and the dynamicbox_feed_mouse_event() will returns DBOX_STATUS_ERROR_BUSY status code
+ * @param[in] use_thread If this value has true, the viewer library will create a new thread to communicate with master service
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int Integer, Dynamicbox status code
+ * @retval #DBOX_STATUS_ERROR_NONE if successfully initialized.
+ * @retval #DBOX_STATUS_ERROR_OUT_OF_MEMORY If a memory is not enough to do this operation.
+ * @retval #DBOX_STATUS_ERROR_IO_ERROR If fails to access dynamicbox database.
+ * @see dynamicbox_fini()
+ * @see dynamicbox_feed_mouse_event()
+ */
+extern int dynamicbox_init(void *disp, int prevent_overwrite, double event_filter, int use_thread);
+
+/**
+ * @internal
+ * @brief Finalizes the dynamicbox system.
+ * @since_tizen 2.3
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_SUCCES if success
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER if dynamicbox_init is not called
+ * @see dynamicbox_init()
+ */
+extern int dynamicbox_fini(void);
+
+/**
+ * @internal
+ * @brief Notifies the status of a client ("it is paused") to the provider.
+ * @since_tizen 2.3
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE if success
+ * @retval #DBOX_STATUS_ERROR_FAULT if it failed to send state (paused) info
+ * @see dynamicbox_client_set_resumed()
+ */
+extern int dynamicbox_viewer_set_paused(void);
+
+/**
+ * @internal
+ * @brief Notifies the status of client ("it is resumed") to the provider.
+ * @since_tizen 2.3
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE if success
+ * @retval #DBOX_STATUS_ERROR_FAULT if it failed to send state (resumed) info
+ * @see dynamicbox_client_set_paused()
+ */
+extern int dynamicbox_viewer_set_resumed(void);
+
+/**
+ * @internal
+ * @brief Adds a new dynamicbox.
+ * @details If the screen size is "1280x720", the below size lists are used for default.
+ * Or you can find the default sizes in pixel from /usr/share/data-provider-master/resolution.ini.
+ * Size types are defined from the libdynamicbox-service package (dynamicbox-service.h).
+ *
+ * Normal mode dynamicbox
+ * 1x1=175x175, #DBOX_SIZE_TYPE_1x1
+ * 2x1=354x175, #DBOX_SIZE_TYPE_2x1
+ * 2x2=354x354, #DBOX_SIZE_TYPE_2x2
+ * 4x1=712x175, #DBOX_SIZE_TYPE_4x1
+ * 4x2=712x354, #DBOX_SIZE_TYPE_4x2
+ * 4x4=712x712, #DBOX_SIZE_TYPE_4x4
+ *
+ * Extended sizes
+ * 4x3=712x533, #DBOX_SIZE_TYPE_4x3
+ * 4x5=712x891, #DBOX_SIZE_TYPE_4x5
+ * 4x6=712x1070, #DBOX_SIZE_TYPE_4x6
+ *
+ * Easy mode dynamicbox
+ * 21x21=224x215, #DBOX_SIZE_TYPE_EASY_1x1
+ * 23x21=680x215, #DBOX_SIZE_TYPE_EASY_3x1
+ * 23x23=680x653, #DBOX_SIZE_TYPE_EASY_3x3
+ *
+ * Special dynamicbox
+ * 0x0=720x1280, #DBOX_SIZE_TYPE_0x0
+ * @since_tizen 2.3
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * Even if you get a handle from the return value of this function, it is not a created instance.
+ * So you have to consider it as a not initialized handle.
+ * It can be initialized only after getting the return callback with "ret == #DBOX_STATUS_ERROR_NONE"
+ * This function is Asynchronous, so you will get result of add requst from @a cb, if you failed to send request to create a new dynamicbox,
+ * This function will returns proper error code
+ * If this returns @c NULL, you can get the reason of failure using dynamicbox_last_status()
+ * @param[in] dbox_id DynamicBox Id
+ * @param[in] content Contents that will be given to the dynamicbox instance
+ * @param[in] cluster Main group
+ * @param[in] category Sub group
+ * @param[in] period Update period (@c DBOX_DEFAULT_PERIOD can be used for this; this argument will be used to specify the period of updating contents of a dynamicbox)
+ * @param[in] type Size type (defined from libdynamicbox-service package)
+ * @param[in] cb After the request is sent to the master provider, this callback will be called
+ * @param[in] data This data will be passed to the callback
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return handle
+ * @retval Handle Dynamicbox handle but not yet initialized
+ * @retval @c NULL if it fails to create a handle
+ * @see dynamicbox_ret_cb
+ */
+extern dynamicbox_h dynamicbox_add(const char *dbox_id, const char *content, const char *cluster, const char *category, double period, dynamicbox_size_type_e type, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Deletes a dynamicbox (will replace dynamicbox_del).
+ * @since_tizen 2.3
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * If you call this with an uninitialized handle, the return callback will be called synchronously.
+ * So before returning from this function, the return callback will be called first.
+ * This function is Asynchronous, so you will get result of add requst from @a cb, if you failed to send request to create a new dynamicbox,
+ * This function will returns proper error code
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] type Deletion type (DBOX_DELETE_PERMANENTLY or DBOX_DELETE_TEMPORARY)
+ * @param[in] cb Return callback
+ * @param[in] data User data for return callback
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_BUSY Already in process
+ * @retval #DBOX_STATUS_ERROR_FAULT Failed to create a request packet
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully sent, return callack will be called
+ * @see dynamicbox_ret_cb
+ */
+extern int dynamicbox_del(dynamicbox_h handler, dynamicbox_delete_type_e type, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Sets a dynamicbox events callback.
+ * @details To get the event which is pushed from the provider, Register the event callback using this API.
+ * The registered callback will be invoked if there are any events from the provider.
+ * @since_tizen 2.3
+ * @param[in] cb Event handler
+ * @param[in] data User data for the event handler
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE If succeed to set event handler
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_OUT_OF_MEMORY Not enough memory
+ * @see dynamicbox_unset_event_handler()
+ */
+extern int dynamicbox_add_event_handler(dynamicbox_event_handler_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Unsets the dynamicbox event handler.
+ * @since_tizen 2.3
+ * @param[in] cb Event handler
+ * @return void * Event handler data
+ * @retval pointer Pointer of 'data' which is used with the dynamicbox_set_event_handler
+ * @see dynamicbox_set_event_handler()
+ */
+extern void *dynamicbox_remove_event_handler(dynamicbox_event_handler_cb cb);
+
+/**
+ * @internal
+ * @brief Registers the dynamicbox fault event handler.
+ * @details Argument list: event, pkgname, filename, funcname.
+ * @since_tizen 2.3
+ * @param[in] cb Event handler
+ * @param[in] data Event handler data
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE If succeed to set fault event handler
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_OUT_OF_MEMORY Not enough memory
+ * @see dynamicbox_unset_fault_handler()
+ */
+extern int dynamicbox_add_fault_handler(dynamicbox_fault_handler_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Unsets the dynamicbox fault event handler.
+ * @since_tizen 2.3
+ * @param[in] cb Event handler
+ * @return void * Callback data which is set via dynamicbox_set_fault_handler
+ * @retval pointer Pointer of 'data' which is used with the dynamicbox_set_fault_handler
+ * @see dynamicbox_set_fault_handler()
+ */
+extern void *dynamicbox_remove_fault_handler(dynamicbox_fault_handler_cb cb);
+
+/**
+ * @internal
+ * @brief Activates the faulted dynamicbox.
+ * @details Request result will be returned via return callback.
+ * @since_tizen 2.3
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * Even though this function returns ERROR_NONE, it means that it just successfully sent a request to the provider.
+ * So you have to check the return callback and its "ret" argument.
+ * This function is Asynchronous, so you will get result of add requst from @a cb, if you failed to send request to create a new dynamicbox,
+ * This function will returns proper error code
+ * @param[in] dbox_id Package name which should be activated
+ * @param[in] cb Result callback
+ * @param[in] data Callback data
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int type
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully sent a request
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_FAULT Failed to make a request
+ * @see dynamicbox_ret_cb
+ */
+extern int dynamicbox_activate(const char *dbox_id, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Resizes the dynamicbox.
+ * @details
+ * Normal mode dynamicbox size
+ * 1x1=175x175, DBOX_SIZE_TYPE_1x1
+ * 2x1=354x175, DBOX_SIZE_TYPE_2x1
+ * 2x2=354x354, DBOX_SIZE_TYPE_2x2
+ * 4x1=712x175, DBOX_SIZE_TYPE_4x1
+ * 4x2=712x354, DBOX_SIZE_TYPE_4x2
+ * 4x4=712x712, DBOX_SIZE_TYPE_4x4
+ *
+ * Extended dynamicbox size
+ * 4x3=712x533, DBOX_SIZE_TYPE_4x3
+ * 4x5=712x891, DBOX_SIZE_TYPE_4x5
+ * 4x6=712x1070, DBOX_SIZE_TYPE_4x6
+ *
+ * Easy mode dynamicbox size
+ * 21x21=224x215, DBOX_SIZE_TYPE_EASY_1x1
+ * 23x21=680x215, DBOX_SIZE_TYPE_EASY_3x1
+ * 23x23=680x653, DBOX_SIZE_TYPE_EASY_3x3
+ *
+ * Special mode dynamicbox size
+ * 0x0=720x1280, DBOX_SIZE_TYPE_0x0
+ * @since_tizen 2.3
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * This function is Asynchronous, so you will get result of add requst from @a cb, if you failed to send request to create a new dynamicbox,
+ * This function will returns proper error code
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] type Type of a dynamicbox size (e.g., DBOX_SIZE_TYPE_1x1, ...)
+ * @param[in] cb Result callback of the resize operation
+ * @param[in] data User data for return callback
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int type
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_BUSY Previous request of resize is in progress
+ * @retval #DBOX_STATUS_ERROR_ALREADY Already resized, there is no differences between current size and requested size
+ * @retval #DBOX_STATUS_ERROR_PERMISSION_DENIED Permission denied, you only have view the content of this box
+ * @retval #DBOX_STATUS_ERROR_FAULT Failed to make a request
+ * @see dynamicbox_ret_cb
+ */
+extern int dynamicbox_resize(dynamicbox_h handler, dynamicbox_size_type_e type, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Sends the click event to a dynamicbox, This is not related with mouse_event, viewer can send "clicked" event directly.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] x Rational X of the content width
+ * @param[in] y Rational Y of the content height
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ */
+extern int dynamicbox_click(dynamicbox_h handler, double x, double y);
+
+/**
+ * @internal
+ * @brief Changes the cluster/sub-cluster name of the given dynamicbox handler.
+ * @since_tizen 2.3
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * This function is Asynchronous, so you will get result of add requst from @a cb, if you failed to send request to create a new dynamicbox,
+ * This function will returns proper error code
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] cluster New cluster of a dynamicbox
+ * @param[in] category New category of a dynamicbox
+ * @param[in] cb Result callback for changing the cluster/category of a dynamicbox
+ * @param[in] data User data for the result callback
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE Request is successfully sent. the return callback will be called
+ * @retval #DBOX_STATUS_ERROR_BUSY Previous request is not finished yet
+ * @retval #DBOX_STATUS_ERROR_ALREADY Group name is same with current one
+ * @retval #DBOX_STATUS_ERROR_PERMISSION_DENIED You have no permission to change property of this dynamicbox instance
+ * @retval #DBOX_STATUS_ERROR_FAULT Failed to make a request
+ * @see dynamicbox_ret_cb
+ */
+extern int dynamicbox_set_group(dynamicbox_h handler, const char *cluster, const char *category, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Gets the cluster and category (sub-cluster) name of the given dynamicbox (it is not I18N format, only English).
+ * @since_tizen 2.3
+ * @remarks You have to do not release the cluster & category.
+ * It is allocated inside of a given dynamicbox instance, so you can only read it.
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[out] cluster Storage(memory) for containing the cluster name
+ * @param[out] category Storage(memory) for containing the category name
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ */
+extern int dynamicbox_get_group(dynamicbox_h handler, const char **cluster, const char **category);
+
+/**
+ * @internal
+ * @brief Gets the period of the dynamicbox handler.
+ * @since_tizen 2.3
+ * @remarks If this function returns 0.0f, it means the dynamicbox has no update period or the handle is not valid.
+ * This function only works after the return callback of dynamicbox_create fucntion is called.
+ * If this returns negative value, you can get the reason of failure using dynamicbox_last_status()
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return double
+ * @retval >0 Current update period of a dynamicbox
+ * @retval 0.0f The box has no update period
+ * @retval -1.0f Failed to get the period info
+ */
+extern double dynamicbox_period(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Changes the update period.
+ * @since_tizen 2.3
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * This function is Asynchronous, so you will get result of add requst from @a cb, if you failed to send request to create a new dynamicbox,
+ * This function will returns proper error code
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] period New update period of a dynamicbox
+ * @param[in] cb Result callback of changing the update period of this dynamicbox
+ * @param[in] data User data for the result callback
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_BUSY
+ * @retval #DBOX_STATUS_ERROR_ALREADY
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @see dynamicbox_ret_cb
+ */
+extern int dynamicbox_set_period(dynamicbox_h handler, double period, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Checks whether the given dynamicbox is a text type or not.
+ * @remarks
+ * If this returns DBOX_CONTENT_TYPE_INVALID, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @return dynamicbox_type
+ * @retval #DBOX_CONTENT_TYPE_IMAGE Contents of a dynamicbox is based on the image file
+ * @retval #DBOX_CONTENT_TYPE_BUFFER Contents of a dynamicbox is based on canvas buffer(shared)
+ * @retval #DBOX_CONTENT_TYPE_TEXT Contents of a dynamicbox is based on formatted text file
+ * @retval #DBOX_CONTENT_TYPE_RESOURCE_ID Contens of a dynamicbox is shared by the resource id (depends on the Window system, eg, Xorg)
+ * @retval #DBOX_CONTENT_TYPE_UIFW UI F/W supported content type for dynamic box
+ * @retval #DBOX_CONTENT_TYPE_INVALID Invalid type
+ * @see dynamicbox_type()
+ */
+extern dynamicbox_type_e dynamicbox_type(dynamicbox_h handler, int gbar);
+
+/**
+ * @internal
+ * @brief Checks if the given dynamicbox is created by user or not.
+ * @remarks if this returns negative value, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @details If the dynamicbox instance is created by a system this will return 0.
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval 0 Automatically created dynamicbox by the provider
+ * @retval 1 Created by user via dynamicbox_add()
+ * @see dynamicbox_add()
+ * @see dynamicbox_set_event_handler()
+ */
+extern int dynamicbox_is_created_by_user(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Gets content information string of the given dynamicbox.
+ * @remarks if this returns @c NULL, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return const char *
+ * @retval content_info Dynamicbox content info that can be used again via content_info argument of dynamicbox_add()
+ * @see dynamicbox_add()
+ */
+extern const char *dynamicbox_content(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Gets the sub cluster title string of the given dynamicbox.
+ * @details This API is now used for accessibility.
+ * Each box should set their content as a string to be read by TTS.
+ * So if the box has focused on the homescreen, the homescreen will read text using this API.
+ * @since_tizen 2.3
+ * @remarks The title returned by this API can be read by TTS.
+ * But it is just recomendation for the homescreen.
+ * So, to read it or not depends on its implementation.
+ * if this returns @c NULL, you can get the reason of failure using dynamicbox_last_status()
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return const char *
+ * @retval sub Cluster name
+ * @retval @c NULL
+ */
+extern const char *dynamicbox_title(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Gets the filename of the given dynamicbox, if it is an IMAGE type dynamicbox.
+ * @details If the box is developed as an image format to represent its contents, the homescreen should know its image file name.
+ * @remarks if this returns @c NULL, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return const char *
+ * @retval filename If the dynamicbox type is image this function will give you a abs-path of an image file (content is rendered)
+ * @retval @c NULL If this has no image file or type is not image file.
+ */
+extern const char *dynamicbox_filename(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Gets the package name of the given dynamicbox handler.
+ * @remarks if this returns @c NULL, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return const char *
+ * @retval pkgname Package name
+ * @retval @c NULL If the handler is not valid
+ */
+extern const char *dynamicbox_pkgname(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Gets the priority of a current content.
+ * @remarks if this returns negative value, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return double
+ * @retval 0.0f Handler is @c NULL
+ * @retval -1.0f Handler is not valid (not yet initialized)
+ * @retval real Number between 0.0 and 1.0
+ */
+extern double dynamicbox_priority(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Acquires the buffer of a given dynamicbox (only for the buffer type).
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return void *
+ * @retval address Address of a Frame Buffer
+ * @retval @c NULL If it fails to get buffer address
+ */
+extern void *dynamicbox_acquire_buffer(dynamicbox_h handler, int gbar);
+
+/**
+ * @internal
+ * @brief Releases the buffer of a dynamicbox (only for the buffer type).
+ * @since_tizen 2.3
+ * @param[in] buffer Buffer
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ * @see dynamicbox_acquire_buffer()
+ */
+extern int dynamicbox_release_buffer(void *buffer);
+
+/**
+ * @internal
+ * @brief Gets the reference count of Dynamicbox buffer (only for the buffer type).
+ * @since_tizen 2.3
+ * @param[in] buffer Buffer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval refcnt Positive integer value including ZERO
+ */
+extern int dynamicbox_buffer_refcnt(void *buffer);
+
+/**
+ * @internal
+ * @brief Gets the size of the Dynamicbox.
+ * @remarks
+ * If this returns DBOX_SIZE_TYPE_UNKNOWN, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return dynamicbox_size_type_e
+ * @retval #DBOX_SIZE_TYPE_NxM N by M size
+ * @retval #DBOX_SIZE_TYPE_UNKNOWN Invalid handler or size type is not defined yet
+ */
+extern dynamicbox_size_type_e dynamicbox_size(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Gets the size of the Glance Bar.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[out] w Width of glance bar in pixels
+ * @param[out] h Height of glance bar in pixels
+ * @return int type
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid parameters are used
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ */
+extern int dynamicbox_get_glance_bar_size(dynamicbox_h handler, int *w, int *h);
+
+/**
+ * @internal
+ * @brief Gets a list of the supported sizes of a given handler.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] size_list Array buffer for getting the size types
+ * @param[in] cnt size of array
+ * @param[out] cnt Count of returned size types
+ * @param[out] size_list Array of size types
+ * @return int type
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ */
+extern int dynamicbox_get_supported_sizes(dynamicbox_h handler, int *cnt, dynamicbox_size_type_e *size_list);
+
+/**
+ * @internal
+ * @brief Gets BUFFER SIZE of the dynamicbox if it is a buffer type.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval size Size in bytes of the dynamicbox buffer
+ */
+extern int dynamicbox_buffer_size(dynamicbox_h handler, int gbar);
+
+/**
+ * @internal
+ * @brief Sends a content event (for buffer type) to the provider (dynamicbox).
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] type Event type
+ * @param[in] x Coordinates of X axis
+ * @param[in] y Coordinates of Y axis
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_BUSY Previous operation is not finished yet
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully sent
+ * @see dynamicbox_feed_access_event()
+ * @see dynamicbox_feed_key_event()
+ */
+extern int dynamicbox_feed_mouse_event(dynamicbox_h handler, dynamicbox_mouse_event_type_e type, dynamicbox_mouse_event_info_t info);
+
+/**
+ * @internal
+ * @brief Sends an access event (for buffer type) to the provider (dynamicbox).
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] type Event type
+ * @param[in] x Coordinates of X axsis
+ * @param[in] y Coordinates of Y axsis
+ * @param[in] cb Result callback function
+ * @param[in] data Callback data
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_BUSY Previous operation is not finished yet
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully sent
+ * @see dynamicbox_feed_mouse_event()
+ * @see dynamicbox_feed_key_event()
+ */
+extern int dynamicbox_feed_access_event(dynamicbox_h handler, dynamicbox_access_event_type_e type, dynamicbox_access_event_info_t info, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Sends a key event (for buffer type) to the provider (dynamicbox).
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] type Key event type
+ * @param[in] keycode Code of key
+ * @param[in] cb Result callback
+ * @param[in] data Callback data
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_BUSY Previous operation is not finished yet
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully sent
+ * @see dynamicbox_feed_mouse_event()
+ * @see dynamicbox_feed_access_event()
+ */
+extern int dynamicbox_feed_key_event(dynamicbox_h handler, dynamicbox_key_event_type_e type, dynamicbox_key_event_info_t info, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Sets pin-up status of the given handler.
+ * @details If the dynamicbox supports the pinup feature,
+ * you can freeze the update of the given dynamicbox.
+ * But it is different from pause.
+ * The box will be updated and it will decide wheter update its content or not when the pinup is on.
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] flag Pinup value
+ * @param[in] cb Result callback
+ * @param[in] data Callback data
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid parameters
+ * @see dynamicbox_ret_cb
+ * @see dynamicbox_set_visibility()
+ * @see dynamicbox_is_pinned_up()
+ */
+extern int dynamicbox_set_pinup(dynamicbox_h handler, int flag, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Checks the PIN-UP status of the given handler.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid parameters
+ * @retval 1 Box is pinned up
+ * @retval 0 Box is not pinned up
+ * @see dynamicbox_set_pinup()
+ */
+extern int dynamicbox_is_pinned_up(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Checks the availability of the PIN-UP feature for the given handler.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval 1 If the box support Pinup feature
+ * @retval 0 If the box does not support the Pinup feature
+ * @see dynamicbox_is_pinned_up()
+ * @see dynamicbox_set_pinup()
+ */
+extern int dynamicbox_has_pinup(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Checks the existence of Glance Bar for the given handler.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval 1 If the box support the Glance Bar
+ * @retval 0 If the box has no Glance Bar
+ */
+extern int dynamicbox_has_glance_bar(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Creates Glance Bar of the given handler with the relative position from dynamicbox.
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] x 0.0 ~ 1.0
+ * @param[in] y 0.0 ~ 1.0
+ * @param[in] cb Result callback
+ * @param[in] data Callback data
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_BUSY Previous operation is not finished yet
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @see dynamicbox_create_glance_bar()
+ * @see dynamicbox_destroy_glance_bar()
+ * @see dynamicbox_move_glance_bar()
+ */
+extern int dynamicbox_create_glance_bar(dynamicbox_h handler, double x, double y, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Updates a position of the given Glance Bar.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] x 0.0 ~ 1.0, 0.0 indicates the coordinate X of left of dynamicbox
+ * @param[in] y 0.0 ~ 1.0, 0.0 indicates the coordinate Y of top of dynamicbox
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE If sending a request for updating position of the Glance Bar has been done successfully
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ */
+extern int dynamicbox_move_glance_bar(dynamicbox_h handler, double x, double y);
+
+/**
+ * @internal
+ * @brief Destroys the Glance Bar of the given handler if it is created.
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] cb Callback function
+ * @param[in] data Callback data
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ * @see dynamicbox_ret_cb
+ */
+extern int dynamicbox_destroy_glance_bar(dynamicbox_h handler, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Checks the create status of the given dynamicbox handler.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval 0 Glance Bar is not created
+ * @retval 1 Glance Bar is created
+ */
+extern int dynamicbox_glance_bar_is_created(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Sets a function table for parsing the text content of a dynamicbox.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @param[in] ops
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @see dynamicbox_set_gbar_text_handler()
+ */
+extern int dynamicbox_set_text_handler(dynamicbox_h handler, int gbar, dynamicbox_script_operator_t ops);
+
+/**
+ * @internal
+ * @brief Emits a text signal to the given dynamicbox only if it is a text type.
+ * @since_tizen 2.3
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * This function is Asynchronous, so you will get result of add requst from @a cb, if you failed to send request to create a new dynamicbox,
+ * This function will returns proper error code
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] emission Emission string
+ * @param[in] source Source string
+ * @param[in] sx Start X
+ * @param[in] sy Start Y
+ * @param[in] ex End X
+ * @param[in] ey End Y
+ * @param[in] cb Result callback
+ * @param[in] data Callback data
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid parameters
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully emitted
+ * @see dynamicbox_ret_cb
+ */
+extern int dynamicbox_emit_text_signal(dynamicbox_h handler, dynamicbox_text_event_t event_info, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Sets a private data pointer to carry it using the given handler.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] data Data pointer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully registered
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @see dynamicbox_data()
+ */
+extern int dynamicbox_set_data(dynamicbox_h handler, void *data);
+
+/**
+ * @internal
+ * @brief Gets a private data pointer which is carried by a given handler.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return void *
+ * @retval data Data pointer
+ * @retval @c NULL If there is no data
+ * @see dynamicbox_set_data()
+ */
+extern void *dynamicbox_data(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Subscribes an event for dynamicboxes only in a given cluster and sub-cluster.
+ * @details If you wrote a view-only client,
+ * you can receive the event of specific dynamicboxes which belong to a given cluster/category.
+ * But you cannot modify their attributes (such as size, ...).
+ * @since_tizen 2.3
+ * @param[in] cluster Cluster ("*" can be used for subscribe all cluster's dynamicboxes event; If you use the "*", value in the category will be ignored)
+ * @param[in] category Category ("*" can be used for subscribe dynamicboxes events of all category(sub-cluster) in a given "cluster")
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully requested
+ * @see dynamicbox_unsubscribe_group()
+ */
+extern int dynamicbox_subscribe_group(const char *cluster, const char *category);
+
+/**
+ * @internal
+ * @brief Unsubscribes an event for the dynamicboxes, but you will receive already added dynamicboxes events.
+ * @since_tizen 2.3
+ * @param[in] cluster Cluster("*" can be used for subscribe all cluster's dynamicboxes event; If you use the "*", value in the category will be ignored)
+ * @param[in] category Category ("*" can be used for subscribe all sub-cluster's dynamicboxes event in a given "cluster")
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully requested
+ * @see dynamicbox_subscribe_group()
+ */
+extern int dynamicbox_unsubscribe_group(const char *cluster, const char *category);
+
+/**
+ * @internal
+ * @brief Refreshes the group (cluster/sub-cluser (aka. category)).
+ * @details This function will trigger the update of all dynamicboxes in a given cluster/category group.
+ * @since_tizen 2.3
+ * @remarks Basically, a default dynamicbox system doesn't use the cluster/category concept.
+ * But you can use it. So if you decide to use it, then you can trigger the update of all dynamicboxes in the given group.
+ * @param[in] cluster Cluster ID
+ * @param[in] category Sub-cluster ID
+ * @param[in] force 1 if the boxes should be updated even if they are paused
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully requested
+ * @see dynamicbox_refresh()
+ */
+extern int dynamicbox_refresh_group(const char *cluster, const char *category, int force);
+
+/**
+ * @internal
+ * @brief Refreshes a dynamicbox.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] force 1 if the box should be updated even if it is paused
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully requested
+ * @see dynamicbox_refresh_group()
+ */
+extern int dynamicbox_refresh(dynamicbox_h handler, int force);
+
+/**
+ * @internal
+ * @brief Gets Resource Id of a dynamicbox content.
+ * @details This function doesn't guarantee the life-cycle of the resource id.
+ * If the service provider destroyed the resource id, you will not know about it.
+ * So you should validate it before accessing it.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @return int
+ * @retval 0 If the resource id is not created
+ * @retval ResourceId Resource Id
+ * @see dynamicbox_resource_id()
+ */
+extern unsigned int dynamicbox_resource_id(const dynamicbox_h handler, int gbar);
+
+/**
+ * @internal
+ * @brief Gets the Resource Id of a dynamicbox.
+ * @details Even if a render process releases the Resource Id, the Resource Id will be kept before being released by dynamicbox_release_resource_id.
+ * You should release the resource id manually.
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @param[in] cb Callback function which will be called with result of acquiring dbox resource id
+ * @param[in] data Callback data
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully requested
+ * @pre Dynamicbox service system should support the ResourceId type buffer.
+ * The dynamicbox should be designed to use the buffer (or script).
+ * @see dynamicbox_release_resource_id()
+ * @see dynamicbox_ret_cb
+ */
+extern int dynamicbox_acquire_resource_id(dynamicbox_h handler, int gbar, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Get the Resource Id of a dynamicbox for Extra buffer
+ * @details Even if a render process(provider) released the Resource Id, it will be kept while release it by viewer.\n
+ * This will prevent from unexpected resource releasing for viewer.\n
+ * You should release this using dynamicbox_release_resource_id()
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @param[in] idx Index of extra buffer, it is limited to dynamicbox configuration
+ * @param[in] cb Callback function which will be called with result of acquiring dbox resource id
+ * @param[in] data Callback data
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully requested
+ * @pre Dynamicbox service system should support the resource id type buffer.
+ * The dynamicbox should be designed to use the buffer (or script)
+ * @see dynamicbox_release_resource_id()
+ * @see dynamicbox_ret_cb
+ */
+extern int dynamicbox_acquire_extra_resource_id(dynamicbox_h handler, int gbar, int idx, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Releases the Resource Id of a dynamicbox.
+ * @details After a client gets a new Resource Id or does not need to keep the current Resource Id anymore, use this function to release it.
+ * If there is no user for a given Resource Id, the Resource Id will be destroyed.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @param[in] resource_id Resource Id of given dynamicbox handler
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ * @pre The Resource Id should be acquired by dynamicbox_acquire_resource_id
+ * @see dynamicbox_acquire_resource_id()
+ */
+extern int dynamicbox_release_resource_id(dynamicbox_h handler, int gbar, unsigned int resource_id);
+
+/**
+ * @internal
+ * @brief Updates a visible state of the dynamicbox.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] state Configure the current visible state of a dynamicbox
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_BUSY
+ * @retval #DBOX_STATUS_ERROR_PERMISSION_DENIED
+ * @retval #DBOX_STATUS_ERROR_ALREADY
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ */
+extern int dynamicbox_set_visibility(dynamicbox_h handler, dynamicbox_visible_state_e state);
+
+/**
+ * @internal
+ * @brief Gets the current visible state of a dynamicbox.
+ * @remarks
+ * If this returns DBOX_VISIBLE_ERROR, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return dynamicbox_visible_state
+ * @retval #DBOX_SHOW Dynamicbox is shown (Default state)
+ * @retval #DBOX_HIDE Dynamicbox is hidden, Update timer is not frozen (but a user cannot receive any updated events; a user should refresh(reload) the content of a dynamicbox when a user make this show again)
+ * @retval #DBOX_HIDE_WITH_PAUSE Dynamicbox is hidden, it will pause the update timer, but if a dynamicbox updates its contents, update event will occur
+ * @retval #DBOX_VISIBLE_ERROR To enlarge the size of this enumeration type
+ */
+extern dynamicbox_visible_state_e dynamicbox_visibility(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Sets an update mode of the current dynamicbox.
+ * @details If you set 1 for active update mode, you should get a buffer without updated event from provider.
+ * But if it is passive mode, you have to update content of a box when you get updated events.
+ * Default is Passive mode.
+ * @since_tizen 2.3
+ * @remarks
+ * This is an ASYNCHRONOUS API.
+ * This function is Asynchronous, so you will get result of add requst from @a cb, if you failed to send request to create a new dynamicbox,
+ * This function will returns proper error code
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] active_update 1 means active update, 0 means passive update (default)
+ * @param[in] cb Result callback function
+ * @param[in] data Callback data
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_BUSY
+ * @retval #DBOX_STATUS_ERROR_PERMISSION_DENIED
+ * @retval #DBOX_STATUS_ERROR_ALREADY
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ * @see dynamicbox_ret_cb
+ */
+extern int dynamicbox_set_update_mode(dynamicbox_h handler, int active_update, dynamicbox_ret_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Checks the active update mode of the given dynamicbox.
+ * @remarks
+ * If this returns negative value, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return int
+ * @retval 0 If passive mode
+ * @retval 1 If active mode or error code
+ */
+extern int dynamicbox_is_active_update(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Syncs manually
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE If success
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid handle
+ * @see dynamicbox_set_manual_sync()
+ * @see dynamicbox_manual_sync()
+ */
+extern int dynamicbox_sync_buffer(dynamicbox_h handler, int gbar);
+
+/**
+ * @internal
+ * @brief Getting the damaged region info
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @param[out] region Readonly information for damaged area
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_NONE if success
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid handle
+ */
+extern int dynamicbox_damage_region_get(dynamicbox_h handler, int gbar, const dynamicbox_damage_region_t *region);
+
+/**
+ * @internal
+ * @brief Gets an alternative icon of the given dynamicbox instance.
+ * @details If the box should be represented as a shortcut icon, this function will get the alternative icon.
+ * @remarks
+ * If this returns @c NULL, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return const char *
+ * @retval address Absolute path of an alternative icon file
+ * @retval @c NULL Dynamicbox has no alternative icon file
+ * @see dynamicbox_alt_name()
+ */
+extern const char *dynamicbox_alternative_icon(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Gets an alternative name of the given dynamicbox instance.
+ * @details If the box should be represented as a shortcut name, this function will get the alternative name.
+ * @remarks
+ * If this returns @c NULL, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @return const char *
+ * @retval name Alternative name of a dynamicbox
+ * @retval @c NULL Dynamicbox has no alternative name
+ * @see dynamicbox_alt_icon()
+ */
+extern const char *dynamicbox_alternative_name(dynamicbox_h handler);
+
+/**
+ * @internal
+ * @brief Gets a lock for a frame buffer.
+ * @details This function should be used to prevent from rendering to the frame buffer while reading it.
+ * And the locking area should be short and must be released ASAP, or the render thread will be hanged.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ * @see dynamicbox_release_buffer_lock()
+ */
+extern int dynamicbox_acquire_buffer_lock(dynamicbox_h handler, int gbar);
+
+/**
+ * @internal
+ * @brief Releases a lock of the frame buffer.
+ * @details This function should be called ASAP after acquiring a lock of FB, or the render process will be blocked.
+ * @since_tizen 2.3
+ * @param[in] handler Handler of a dynamicbox instance
+ * @param[in] gbar 1 for Glance Bar or 0
+ * @privlevel platform
+ * @privilege %http://developer.samsung.com/tizen/privilege/dynamicbox.viewer
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_FAULT Unrecoverable error occurred
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully done
+ * @see dynamicbox_acquire_buffer_lock()
+ */
+extern int dynamicbox_release_buffer_lock(dynamicbox_h handler, int gbar);
+
+/**
+ * @internal
+ * @brief Sets options for controlling a dynamicbox sub-system.
+ * @details
+ * #DBOX_OPTION_FRAME_DROP_FOR_RESIZE
+ * While resizing the box, viewer doesn't want to know the updated frames of an old size content anymore.
+ * In that case, turn this on, the provider will not send the updated event to the viewer about an old content.
+ * So the viewer can reduce its burden to update unnecessary frames.
+ * #DBOX_OPTION_MANUAL_SYNC
+ * If you don't want to update frames automatically, or you want only reload the frames by your hands, (manually)
+ * Turn this on.
+ * After turnning it on, you should sync it using dynamicbox_sync_buffer().
+ * #DBOX_OPTION_SHARED_CONTENT
+ * If this option is turnned on, even though you create a new dynamicbox,
+ * if there are already added same instances that have same contents, the instance will not be created again.
+ * Instead of creating a new instance, a viewer will provide an old instance with a new handle.
+ * @since_tizen 2.3
+ * @param[in] option Option which will be affected by this call
+ * @param[in] state New value for given option
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Unknown option
+ * @retval #DBOX_STATUS_ERROR_FAULT Failed to change the state of option
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully changed
+ * @see dynamicbox_get_option()
+ * @see dynamicbox_sync_buffer()
+ */
+extern int dynamicbox_set_option(dynamicbox_option_type_e option, int state);
+
+/**
+ * @internal
+ * @brief Gets options of a dynamicbox sub-system.
+ * @remarks
+ * If this returns negative value, you can get the reason of failure using dynamicbox_last_status()
+ * @since_tizen 2.3
+ * @param[in] option Type of option
+ * @return int
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Invalid option
+ * @retval #DBOX_STATUS_ERROR_FAULT Failed to get option
+ * @retval >=0 Value of given option (must be >=0)
+ * @see dynamicbox_set_option()
+ */
+extern int dynamicbox_option(dynamicbox_option_type_e option);
+
+/**
+ * @internal
+ * @brief Set a handler for launching an app by auto-launch feature
+ * @details If a user clicks a box, which box enabled auto-launch option, the launcher_handler will be called.
+ * From that callback, you should launch an app using given ui-app id.
+ * @since_tizen 2.3
+ * @param[in] launch_handler Handler for launching an app manually
+ * @param[in] data Callback data which will be given a data for launch_handler
+ * @return int type
+ * @retval #DBOX_STATUS_ERROR_NONE Succeed to set new handler. there is no other cases
+ */
+extern int dynamicbox_set_auto_launch_handler(dynamicbox_auto_launch_handler_cb cb, void *data);
+
+/**
+ * @internal
+ * @brief Get the last extra buffer index and its id.
+ * @details
+ * If there is an event of #DBOX_EVENT_DBOX_EXTRA_BUFFER_CREATED or #DBOX_EVENT_GBAR_EXTRA_BUFFER_CREATED,
+ * #DBOX_EVENT_DBOX_EXTRA_BUFFER_DESTROYED or #DBOX_EVENT_GBAR_EXTRA_BUFFER_DESTROYED
+ * you can use this to get the last created buffer info
+ * @since_tizen 2.3
+ * @param[in] handler Dynamicbox handler
+ * @param[in] gbar 1 if you want get the glance bar's info or 0
+ * @param[out] idx Index of buffer
+ * @param[out] resource_id Resource Id
+ * @return status
+ * @retval #DBOX_STATUS_ERROR_NONE Successfully get
+ * @retval #DBOX_STATUS_ERROR_INVALID_PARAMETER Handler is not valid
+ * @retval #DBOX_STATUS_ERROR_NOT_EXIST There is no extra buffer
+ */
+extern int dynamicbox_get_affected_extra_buffer(dynamicbox_h handler, int gbar, int *idx, unsigned int *resource_id);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __DYNAMICBOX_VIEWER_H
diff --git a/dynamicbox_viewer/include/dynamicbox_internal.h b/dynamicbox_viewer/include/dynamicbox_internal.h
new file mode 100644
index 0000000..ad3f7d7
--- /dev/null
+++ b/dynamicbox_viewer/include/dynamicbox_internal.h
@@ -0,0 +1,270 @@
+/*
+ * 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.
+ */
+
+struct cb_info {
+ dynamicbox_ret_cb cb;
+ void *data;
+};
+
+extern void dbox_invoke_event_handler(struct dynamicbox *handler, dynamicbox_event_type_e event);
+extern void dbox_invoke_fault_handler(dynamicbox_fault_type_e type, const char *pkgname, const char *filename, const char *function);
+
+extern struct dynamicbox_common *dbox_find_common_handle(const char *pkgname, const char *filename);
+extern struct dynamicbox *dbox_new_dynamicbox(const char *pkgname, const char *id, double timestamp, const char *cluster, const char *category);
+extern struct dynamicbox_common *dbox_find_common_handle_by_timestamp(double timestamp);
+
+extern int dbox_set_group(struct dynamicbox_common *common, const char *cluster, const char *category);
+extern void dbox_set_size(struct dynamicbox_common *common, int w, int h);
+extern void dbox_set_gbarsize(struct dynamicbox_common *common, int w, int h);
+extern void dbox_set_default_gbarsize(struct dynamicbox_common *common, int w, int h);
+extern int dbox_set_content(struct dynamicbox_common *common, const char *content);
+extern int dbox_set_title(struct dynamicbox_common *handler, const char *title);
+extern void dbox_set_auto_launch(struct dynamicbox_common *handler, const char *auto_launch);
+extern void dbox_set_id(struct dynamicbox_common *handler, const char *id);
+extern void dbox_set_size_list(struct dynamicbox_common *handler, int size_list);
+extern void dbox_set_priority(struct dynamicbox_common *handler, double priority);
+extern int dbox_set_dbox_fb(struct dynamicbox_common *handler, const char *filename);
+extern int dbox_set_gbar_fb(struct dynamicbox_common *handler, const char *filename);
+extern struct fb_info *dbox_get_gbar_fb(struct dynamicbox_common *handler);
+extern struct fb_info *dbox_get_dbox_fb(struct dynamicbox_common *handler);
+extern void dbox_set_user(struct dynamicbox_common *handler, int user);
+extern void dbox_set_pinup(struct dynamicbox_common *handler, int pinup);
+extern void dbox_set_text_dbox(struct dynamicbox_common *handler);
+extern void dbox_set_text_gbar(struct dynamicbox_common *handler);
+extern int dbox_text_dbox(struct dynamicbox_common *handler);
+extern int dbox_text_gbar(struct dynamicbox_common *handler);
+extern void dbox_set_period(struct dynamicbox_common *handler, double period);
+extern void dbox_set_update_mode(struct dynamicbox_common *handler, int active_mode);
+extern void dbox_set_filename(struct dynamicbox_common *handler, const char *filename);
+extern void dbox_unlink_filename(struct dynamicbox_common *common);
+extern void dbox_set_alt_icon(struct dynamicbox_common *handler, const char *icon);
+extern void dbox_set_alt_name(struct dynamicbox_common *handle, const char *name);
+extern int dbox_destroy_common_handle(struct dynamicbox_common *common);
+extern struct dynamicbox_common *dbox_create_common_handle(struct dynamicbox *handle, const char *pkgname, const char *cluster, const char *category);
+extern int dbox_sync_gbar_fb(struct dynamicbox_common *common);
+extern int dbox_sync_dbox_fb(struct dynamicbox_common *common);
+extern int dbox_common_unref(struct dynamicbox_common *common, struct dynamicbox *handle);
+extern int dbox_common_ref(struct dynamicbox_common *common, struct dynamicbox *handle);
+extern struct dynamicbox_common *dbox_find_sharable_common_handle(const char *pkgname, const char *content, int w, int h, const char *cluster, const char *category);
+extern struct dynamicbox *dbox_find_dbox_in_show(struct dynamicbox_common *common);
+extern struct dynamicbox *dbox_get_dbox_nth(struct dynamicbox_common *common, int nth);
+extern void *dbox_remove_event_handler(dynamicbox_event_handler_cb dbox_cb);
+extern int dbox_add_event_handler(dynamicbox_event_handler_cb dbox_cb, void *data);
+extern int dbox_add_fault_handler(dynamicbox_fault_handler_cb dbox_cb, void *data);
+extern void *dbox_remove_fault_handler(dynamicbox_fault_handler_cb dbox_cb);
+extern struct cb_info *dbox_create_cb_info(dynamicbox_ret_cb cb, void *data);
+extern void dbox_destroy_cb_info(struct cb_info *info);
+
+extern struct dynamicbox *dbox_ref(struct dynamicbox *handler);
+extern struct dynamicbox *dbox_unref(struct dynamicbox *handler, int destroy_common);
+extern int dbox_send_delete(struct dynamicbox *handler, int type, dynamicbox_ret_cb cb, void *data);
+extern int dbox_delete_all(void);
+
+typedef enum dynamicbox_state {
+ DBOX_STATE_CREATE = 0xBEEFbeef,
+ DBOX_STATE_DELETE = 0xDEADdead, /* Delete only for this client */
+ DBOX_STATE_DESTROYED = 0x00DEAD00
+} dynamicbox_state_e;
+
+struct dynamicbox_common {
+ dynamicbox_state_e state;
+
+ struct dlist *dynamicbox_list;
+ int refcnt;
+
+ char *cluster;
+ char *category;
+
+ char *pkgname;
+ char *id;
+
+ char *content;
+ char *title;
+ char *filename;
+
+ double timestamp;
+
+ struct alt_info {
+ char *icon;
+ char *name;
+ } alt;
+
+ dynamicbox_delete_type_e delete_type;
+
+ int is_user;
+ int is_gbar_created;
+ int is_pinned_up;
+ int is_active_update;
+ dynamicbox_visible_state_e visible;
+
+ struct {
+ dynamicbox_dbox_type_e type;
+ struct fb_info *fb;
+
+ int size_list;
+
+ int width;
+ int height;
+ double priority;
+
+ char *auto_launch;
+ double period;
+ int pinup_supported;
+ int mouse_event;
+
+ /* For the filtering event */
+ double x;
+ double y;
+
+ /* For the extra buffer */
+ unsigned int *extra_buffer;
+ int last_extra_buffer_idx;
+
+ /* Lock */
+ dynamicbox_lock_info_t lock;
+
+ /* For damaged region */
+ struct dynamicbox_damage_region last_damage;
+ } dbox;
+
+ struct {
+ dynamicbox_gbar_type_e type;
+ struct fb_info *fb;
+
+ int width;
+ int height;
+
+ int default_width;
+ int default_height;
+
+ /* For the filtering event */
+ double x;
+ double y;
+
+ /* For the extra buffer */
+ unsigned int *extra_buffer;
+ int last_extra_buffer_idx;
+
+ /* Lock */
+ dynamicbox_lock_info_t lock;
+
+ /* For damaged region */
+ struct dynamicbox_damage_region last_damage;
+ } gbar;
+
+ int nr_of_sizes;
+
+ struct requested_flag {
+ unsigned int created:1;
+ unsigned int deleted:1;
+ unsigned int pinup:1;
+ unsigned int group_changed:1;
+ unsigned int period_changed:1;
+ unsigned int size_changed:1;
+ unsigned int gbar_created:1;
+ unsigned int gbar_destroyed:1;
+ unsigned int update_mode:1;
+ unsigned int access_event:1;
+ unsigned int key_event:1;
+
+ /*!
+ * \note
+ * Reserved
+ */
+ unsigned int reserved:21;
+ } request;
+};
+
+struct job_item {
+ struct dynamicbox *handle;
+ dynamicbox_ret_cb cb;
+ int ret;
+ void *data;
+};
+
+struct dynamicbox {
+ dynamicbox_state_e state;
+
+ int refcnt;
+ int paused_updating;
+
+ dynamicbox_visible_state_e visible;
+ struct dynamicbox_common *common;
+
+ void *data;
+
+ struct callback_table {
+ struct dynamicbox_script_operators dbox_ops;
+ struct dynamicbox_script_operators gbar_ops;
+
+ struct created {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } created;
+
+ struct deleted {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } deleted;
+
+ struct pinup {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } pinup;
+
+ struct group_changed {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } group_changed;
+
+ struct period_changed {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } period_changed;
+
+ struct size_changed {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } size_changed;
+
+ struct gbar_created {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } gbar_created;
+
+ struct gbar_destroyed {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } gbar_destroyed;
+
+ struct update_mode {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } update_mode;
+
+ struct access_event {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } access_event;
+
+ struct key_event {
+ dynamicbox_ret_cb cb;
+ void *data;
+ } key_event;
+ } cbs;
+};
+
+/* End of a file */
diff --git a/include/fb.h b/dynamicbox_viewer/include/fb.h
index 9e567dd..e7b8543 100644
--- a/include/fb.h
+++ b/dynamicbox_viewer/include/fb.h
@@ -16,18 +16,11 @@
struct fb_info;
-enum buffer_type { /*!< Must have to be sync with libprovider, liblivebox-viewer */
- BUFFER_TYPE_FILE,
- BUFFER_TYPE_SHM,
- BUFFER_TYPE_PIXMAP,
- BUFFER_TYPE_ERROR
-};
-
extern int fb_init(void *disp);
extern int fb_fini(void);
extern const char *fb_id(struct fb_info *info);
extern int fb_get_size(struct fb_info *info, int *w, int *h);
-extern int fb_sync(struct fb_info *info);
+extern int fb_sync(struct fb_info *info, int x, int y, int w, int h);
extern int fb_size(struct fb_info *info);
extern int fb_refcnt(void *data);
extern int fb_is_created(struct fb_info *info);
diff --git a/include/file_service.h b/dynamicbox_viewer/include/file_service.h
index 9212d03..9212d03 100644
--- a/include/file_service.h
+++ b/dynamicbox_viewer/include/file_service.h
diff --git a/include/master_rpc.h b/dynamicbox_viewer/include/master_rpc.h
index d850bfd..7dde9ed 100644
--- a/include/master_rpc.h
+++ b/dynamicbox_viewer/include/master_rpc.h
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-extern int master_rpc_async_request(struct livebox *handler, struct packet *packet, int urgent, void (*ret_cb)(struct livebox *handler, const struct packet *result, void *data), void *data);
+extern int master_rpc_async_request(struct dynamicbox *handler, struct packet *packet, int urgent, void (*ret_cb)(struct dynamicbox *handler, const struct packet *result, void *data), void *data);
extern int master_rpc_sync_request(struct packet *packet);
extern void master_rpc_check_and_fire_consumer(void);
-extern int master_rpc_request_only(struct livebox *handler, struct packet *packet);
+extern int master_rpc_request_only(struct dynamicbox *handler, struct packet *packet);
extern int master_rpc_clear_fault_package(const char *pkgname);
extern int master_rpc_clear_all_request(void);
diff --git a/include/util.h b/dynamicbox_viewer/include/util.h
index b66b542..498a249 100644
--- a/include/util.h
+++ b/dynamicbox_viewer/include/util.h
@@ -17,13 +17,12 @@
extern int util_check_extension(const char *filename, const char *check_ptr);
extern double util_timestamp(void);
extern const char *util_basename(const char *name);
-extern int util_validate_livebox_package(const char *pkgname);
extern const char *util_uri_to_path(const char *uri);
extern int util_unlink(const char *filename);
-#define SCHEMA_FILE "file://"
-#define SCHEMA_PIXMAP "pixmap://"
-#define SCHEMA_SHM "shm://"
+#define SCHEMA_FILE "file://"
+#define SCHEMA_PIXMAP "pixmap://"
+#define SCHEMA_SHM "shm://"
#define container_of(ptr, type, member) \
({ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
diff --git a/dynamicbox_viewer/src/client.c b/dynamicbox_viewer/src/client.c
new file mode 100644
index 0000000..61ae62d
--- /dev/null
+++ b/dynamicbox_viewer/src/client.c
@@ -0,0 +1,2296 @@
+/*
+ * 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 <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/types.h>
+
+#include <dlog.h>
+#include <glib.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <packet.h>
+#include <com-core.h>
+#include <com-core_packet.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_cmd_list.h>
+#include <dynamicbox_buffer.h>
+#include <secure_socket.h>
+
+#include "debug.h"
+#include "client.h"
+#include "dynamicbox.h"
+#include "dynamicbox_internal.h"
+#include "desc_parser.h"
+#include "fb.h"
+#include "util.h"
+#include "master_rpc.h"
+#include "conf.h"
+#include "file_service.h"
+#include "dlist.h"
+
+int errno;
+
+#define MAX_DIRECT_ADDR 256
+
+static struct info {
+ int fd;
+ int direct_fd;
+ guint timer_id;
+ char *client_addr;
+ char *direct_addr;
+} s_info = {
+ .fd = -1,
+ .direct_fd = -1,
+ .timer_id = 0,
+ .client_addr = NULL,
+ .direct_addr = NULL,
+};
+
+static struct packet *master_fault_package(pid_t pid, int handle, const struct packet *packet)
+{
+ const char *pkgname;
+ const char *id;
+ const char *function;
+
+ if (packet_get(packet, "sss", &pkgname, &id, &function) != 3) {
+ ErrPrint("Invalid arguments\n");
+ return NULL;
+ }
+
+ DbgPrint("[%s]\n", pkgname);
+ master_rpc_clear_fault_package(pkgname);
+ dbox_invoke_fault_handler(DBOX_FAULT_DEACTIVATED, pkgname, id, function);
+ return NULL;
+}
+
+static struct packet *master_hold_scroll(pid_t pid, int handle, const struct packet *packet)
+{
+ struct dynamicbox_common *common;
+ dynamicbox_h dynamicbox;
+ const char *pkgname;
+ const char *id;
+ int seize;
+ int ret;
+ struct dlist *l;
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &seize);
+ if (ret != 3) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance(%s) is not exists\n", id);
+ goto out;
+ }
+
+ DbgPrint("HOLD: [%s] seize(%d)\n", id, seize);
+ seize = seize ? DBOX_EVENT_HOLD_SCROLL : DBOX_EVENT_RELEASE_SCROLL;
+ dlist_foreach(common->dynamicbox_list, l, dynamicbox) {
+ dbox_invoke_event_handler(dynamicbox, seize);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_pinup(pid_t pid, int handle, const struct packet *packet)
+{
+ const char *pkgname;
+ const char *id;
+ const char *content;
+ dynamicbox_h handler;
+ struct dlist *l;
+ struct dlist *n;
+ struct dynamicbox_common *common;
+ char *new_content;
+ int ret;
+ int status;
+ int pinup;
+
+ ret = packet_get(packet, "iisss", &status, &pinup, &pkgname, &id, &content);
+ if (ret != 5) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance (%s) is not exists\n", id);
+ goto out;
+ }
+
+ if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ new_content = strdup(content);
+ if (new_content) {
+ free(common->content);
+ common->content = new_content;
+ common->is_pinned_up = pinup;
+ } else {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ status = DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+ }
+
+ common->request.pinup = 0;
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ if (handler->cbs.pinup.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ /* Make sure that user can call pinup API in its result callback */
+ cb = handler->cbs.pinup.cb;
+ cbdata = handler->cbs.pinup.data;
+
+ handler->cbs.pinup.cb = NULL;
+ handler->cbs.pinup.data = NULL;
+
+ cb(handler, status, cbdata);
+ } else if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_PINUP_CHANGED);
+ }
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_deleted(pid_t pid, int handle, const struct packet *packet)
+{
+ const char *pkgname;
+ const char *id;
+ double timestamp;
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ struct dlist *l;
+ struct dlist *n;
+ int reason;
+
+ if (packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &reason) != 4) {
+ ErrPrint("Invalid arguemnt\n");
+ goto out;
+ }
+
+ DbgPrint("[%s]\n", pkgname);
+ common = dbox_find_common_handle_by_timestamp(timestamp);
+ if (!common) {
+ /*!
+ * \note
+ * This can be happens only if the user delete a dynamicbox
+ * right after create it before receive created event.
+ */
+ goto out;
+ }
+
+ /*!< Check validity of this "handler" */
+ if (common->state != DBOX_STATE_CREATE) {
+ if (common->state != DBOX_STATE_DELETE) {
+ /*!
+ * \note
+ * This is not possible
+ */
+ ErrPrint("Already deleted handler (%s - %s)\n", pkgname, id);
+ return NULL;
+ }
+ }
+
+ common->request.deleted = 0;
+ /*!
+ * We should change the state of "common handler' before handling the callbacks.
+ * Because if user tries to create a new handle in the callbacks,
+ * find_sharable_common_handle will returns destroying object.
+ * Then we will get panic.
+ * To prevent it, we should change its state first.
+ */
+ common->state = DBOX_STATE_DELETE;
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ if (handler->cbs.created.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+ /*!
+ * \note
+ *
+ * "if (handler->id == NULL) {"
+ *
+ * The instance is not created yet.
+ * But the master forcely destroy it and send destroyed event to this
+ * without the created event.
+ *
+ * It could be destroyed when a slave has critical error(fault)
+ * before creating an instance successfully.
+ */
+ if (handler->cbs.created.cb == handler->cbs.deleted.cb) {
+ if (handler->cbs.created.data != handler->cbs.deleted.data) {
+ DbgPrint("cb is same but cbdata is different (%s - %s)\n", pkgname, id);
+ }
+
+ handler->cbs.deleted.cb = NULL;
+ handler->cbs.deleted.data = NULL;
+ }
+
+ cb = handler->cbs.created.cb;
+ cbdata = handler->cbs.created.data;
+
+ handler->cbs.created.cb = NULL;
+ handler->cbs.created.data = NULL;
+
+ if (reason == (int)DBOX_STATUS_ERROR_NONE) {
+ reason = DBOX_STATUS_ERROR_CANCEL;
+ }
+
+ cb(handler, reason, cbdata);
+ } else if (common->id) {
+ if (handler->cbs.deleted.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = handler->cbs.deleted.cb;
+ cbdata = handler->cbs.deleted.data;
+
+ handler->cbs.deleted.cb = NULL;
+ handler->cbs.deleted.data = NULL;
+
+ cb(handler, reason, cbdata);
+ } else {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ }
+ }
+
+ /* Just try to delete it, if a user didn't remove it from the live box list */
+ dbox_unref(handler, 1);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_dbox_update_begin(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ const char *id;
+ const char *content;
+ const char *title;
+ const char *fbfile;
+ double priority;
+ int ret;
+
+ ret = packet_get(packet, "ssdsss", &pkgname, &id, &priority, &content, &title, &fbfile);
+ if (ret != 6) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("(%s) is not created\n", id);
+ goto out;
+ }
+
+ dbox_set_priority(common, priority);
+ dbox_set_content(common, content);
+ dbox_set_title(common, title);
+
+ /*!
+ * \NOTE
+ * Width & Height is not changed in this case.
+ * If the active update is began, the size should not be changed,
+ * And if the size is changed, the provider should finish the updating first.
+ * And then begin updating again after change its size.
+ */
+ if (dbox_get_dbox_fb(common)) {
+ (void)dbox_set_dbox_fb(common, fbfile);
+
+ ret = dbox_sync_dbox_fb(common);
+
+ if (ret != (int)DBOX_STATUS_ERROR_NONE) {
+ ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, fbfile, ret);
+ } else {
+ struct dlist *l;
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DBOX_UPDATE_BEGIN);
+ }
+ }
+ } else {
+ ErrPrint("Invalid request[%s], %s\n", id, fbfile);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_gbar_update_begin(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ const char *id;
+ const char *fbfile;
+ int ret;
+
+ ret = packet_get(packet, "sss", &pkgname, &id, &fbfile);
+ if (ret != 2) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (dbox_get_gbar_fb(common)) {
+ (void)dbox_set_gbar_fb(common, fbfile);
+
+ ret = dbox_sync_gbar_fb(common);
+ if (ret != (int)DBOX_STATUS_ERROR_NONE) {
+ ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, fbfile, ret);
+ } else {
+ struct dlist *l;
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_GBAR_UPDATE_BEGIN);
+ }
+ }
+ } else {
+ ErrPrint("Invalid request[%s], %s\n", id, fbfile);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_dbox_update_end(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ const char *id;
+ int ret;
+
+ ret = packet_get(packet, "ss", &pkgname, &id);
+ if (ret != 2) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (dbox_get_dbox_fb(common)) {
+ struct dlist *l;
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DBOX_UPDATE_END);
+ }
+ } else {
+ ErrPrint("Invalid request[%s]\n", id);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_key_status(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ struct dlist *l;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ int status;
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &status);
+ if (ret != 3) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ common->request.key_event = 0;
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ if (handler->cbs.key_event.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = handler->cbs.key_event.cb;
+ cbdata = handler->cbs.key_event.data;
+
+ handler->cbs.key_event.cb = NULL;
+ handler->cbs.key_event.data = NULL;
+
+ cb(handler, status, cbdata);
+ } else {
+ ErrPrint("Invalid event[%s]\n", id);
+ }
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_request_close_gbar(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ struct dlist *l;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ int reason;
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &reason);
+ if (ret != 3) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (!common->is_gbar_created) {
+ DbgPrint("GBAR is not created, closing what?(%s)\n", id);
+ goto out;
+ }
+
+ DbgPrint("Reason: %d\n", reason);
+
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_REQUEST_CLOSE_GBAR);
+ }
+out:
+ return NULL;
+}
+
+static struct packet *master_access_status(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ struct dlist *l;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ int status;
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &status);
+ if (ret != 3) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ common->request.access_event = 0;
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ if (handler->cbs.access_event.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = handler->cbs.access_event.cb;
+ cbdata = handler->cbs.access_event.data;
+
+ handler->cbs.access_event.cb = NULL;
+ handler->cbs.access_event.data = NULL;
+
+ cb(handler, status, cbdata);
+ }
+ }
+out:
+ return NULL;
+}
+
+static struct packet *master_gbar_update_end(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ const char *id;
+ int ret;
+
+ ret = packet_get(packet, "ss", &pkgname, &id);
+ if (ret != 2) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance[%s] is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("[%s] is not created\n", id);
+ goto out;
+ }
+
+ if (dbox_get_dbox_fb(common)) {
+ struct dlist *l;
+
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_GBAR_UPDATE_END);
+ }
+ } else {
+ ErrPrint("Invalid request[%s]", id);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_extra_info(pid_t pid, int handle, const struct packet *packet)
+{
+ const char *pkgname;
+ const char *id;
+ const char *content;
+ const char *title;
+ const char *icon;
+ const char *name;
+ double priority;
+ int ret;
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ struct dlist *l;
+ struct dlist *n;
+
+ ret = packet_get(packet, "ssssssd", &pkgname, &id,
+ &content, &title,
+ &icon, &name,
+ &priority);
+ if (ret != 7) {
+ ErrPrint("Invalid parameters\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("instance(%s) is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ /*!
+ * \note
+ * Already deleted by the user.
+ * Don't try to notice anything with this, Just ignore all events
+ * Beacuse the user doesn't wants know about this anymore
+ */
+ ErrPrint("(%s) is not exists, but updated\n", id);
+ goto out;
+ }
+
+ dbox_set_priority(common, priority);
+ dbox_set_content(common, content);
+ dbox_set_title(common, title);
+ dbox_set_alt_icon(common, icon);
+ dbox_set_alt_name(common, name);
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_EXTRA_INFO_UPDATED);
+ }
+out:
+ return NULL;
+}
+
+static struct packet *master_extra_updated(pid_t pid, int handle, const struct packet *packet)
+{
+ const char *pkgname;
+ const char *id;
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ int ret;
+ int x;
+ int y;
+ int w;
+ int h;
+ int is_gbar;
+ int event_type;
+ int idx;
+
+ ret = packet_get(packet, "ssiiiiii", &pkgname, &id, &is_gbar, &idx, &x, &y, &w, &h);
+ if (ret != 8) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("instance(%s) is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ /*!
+ * \note
+ * Already deleted by the user.
+ * Don't try to notice anything with this, Just ignore all events
+ * Beacuse the user doesn't wants know about this anymore
+ */
+ ErrPrint("(%s) is not exists, but updated\n", id);
+ goto out;
+ }
+
+ if (is_gbar) {
+ common->gbar.last_damage.x = x;
+ common->gbar.last_damage.y = y;
+ common->gbar.last_damage.w = w;
+ common->gbar.last_damage.h = h;
+ common->gbar.last_extra_buffer_idx = idx;
+
+ event_type = DBOX_EVENT_GBAR_EXTRA_UPDATED;
+ } else {
+ common->dbox.last_damage.x = x;
+ common->dbox.last_damage.y = y;
+ common->dbox.last_damage.w = w;
+ common->dbox.last_damage.h = h;
+ common->dbox.last_extra_buffer_idx = idx;
+
+ event_type = DBOX_EVENT_DBOX_EXTRA_UPDATED;
+
+ if (conf_frame_drop_for_resizing() && common->request.size_changed) {
+ /* Just for skipping the update event callback call, After request to resize buffer, update event will be discarded */
+ DbgPrint("Discards obsoloted update event\n");
+ ret = DBOX_STATUS_ERROR_BUSY;
+ } else {
+ if (!conf_manual_sync()) {
+ ret = dbox_sync_dbox_fb(common);
+ if (ret != (int)DBOX_STATUS_ERROR_NONE) {
+ ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, util_basename(util_uri_to_path(id)), ret);
+ }
+ } else {
+ ret = DBOX_STATUS_ERROR_NONE;
+ }
+ }
+ }
+
+ if (!common->request.created && ret == (int)DBOX_STATUS_ERROR_NONE) {
+ struct dlist *l;
+ struct dlist *n;
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ dbox_invoke_event_handler(handler, event_type);
+ }
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_dbox_updated(pid_t pid, int handle, const struct packet *packet)
+{
+ const char *pkgname;
+ const char *id;
+ const char *fbfile;
+ const char *safe_file;
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ int ret;
+ int x;
+ int y;
+ int w;
+ int h;
+
+ ret = packet_get(packet, "ssssiiii", &pkgname, &id, &fbfile, &safe_file, &x, &y, &w, &h);
+ if (ret != 8) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("instance(%s) is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ /*!
+ * \note
+ * Already deleted by the user.
+ * Don't try to notice anything with this, Just ignore all events
+ * Beacuse the user doesn't wants know about this anymore
+ */
+ ErrPrint("(%s) is not exists, but updated\n", id);
+ goto out;
+ }
+
+ common->dbox.last_damage.x = x;
+ common->dbox.last_damage.y = y;
+ common->dbox.last_damage.w = w;
+ common->dbox.last_damage.h = h;
+ common->dbox.last_extra_buffer_idx = DBOX_PRIMARY_BUFFER;
+ dbox_set_filename(common, safe_file);
+
+ if (dbox_text_dbox(common)) {
+ const char *common_filename;
+
+ common_filename = common->filename ? common->filename : util_uri_to_path(common->id);
+
+ (void)parse_desc(common, common_filename, 0);
+ /*!
+ * \note
+ * DESC parser will call the "text event callback".
+ * Don't need to call global event callback in this case.
+ */
+ dbox_unlink_filename(common);
+ goto out;
+ } else if (dbox_get_dbox_fb(common)) {
+ /*!
+ * \todo
+ * replace this with "flag" instead of "callback address"
+ */
+ if (conf_frame_drop_for_resizing() && common->request.size_changed) {
+ /* Just for skipping the update event callback call, After request to resize buffer, update event will be discarded */
+ DbgPrint("Discards obsoloted update event\n");
+ ret = DBOX_STATUS_ERROR_BUSY;
+ } else {
+ (void)dbox_set_dbox_fb(common, fbfile);
+
+ if (!conf_manual_sync()) {
+ ret = dbox_sync_dbox_fb(common);
+ if (ret != (int)DBOX_STATUS_ERROR_NONE) {
+ ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, util_basename(util_uri_to_path(id)), ret);
+ }
+ } else {
+ ret = DBOX_STATUS_ERROR_NONE;
+ }
+ }
+ } else {
+ ret = DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (ret == (int)DBOX_STATUS_ERROR_NONE && !common->request.created) {
+ struct dlist *l;
+ struct dlist *n;
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DBOX_UPDATED);
+ }
+ }
+ dbox_unlink_filename(common);
+
+out:
+ return NULL;
+}
+
+static struct packet *master_gbar_created(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ const char *id;
+ const char *buf_id;
+ struct dlist *l;
+ struct dlist *n;
+ int width;
+ int height;
+ int ret;
+ int status;
+
+ ret = packet_get(packet, "sssiii", &pkgname, &id, &buf_id, &width, &height, &status);
+ if (ret != 6) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ DbgPrint("[%s]\n", pkgname);
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance(%s) is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Instance(%s) is not created\n", id);
+ goto out;
+ }
+
+ if (!common->request.gbar_created) {
+ ErrPrint("GBAR create request is canceled\n");
+ goto out;
+ }
+
+ common->is_gbar_created = (status == (int)DBOX_STATUS_ERROR_NONE);
+ common->request.gbar_created = 0;
+
+ if (common->is_gbar_created) {
+ dbox_set_gbarsize(common, width, height);
+ if (dbox_text_gbar(common)) {
+ DbgPrint("Text TYPE does not need to handle this\n");
+ } else {
+ (void)dbox_set_gbar_fb(common, buf_id);
+
+ switch (common->gbar.type) {
+ case GBAR_TYPE_SCRIPT:
+ case GBAR_TYPE_BUFFER:
+ switch (fb_type(dbox_get_gbar_fb(common))) {
+ case DBOX_FB_TYPE_FILE:
+ case DBOX_FB_TYPE_SHM:
+ common->gbar.lock = dynamicbox_service_create_lock(common->id, DBOX_TYPE_GBAR, DBOX_LOCK_READ);
+ break;
+ case DBOX_FB_TYPE_PIXMAP:
+ case DBOX_FB_TYPE_ERROR:
+ default:
+ break;
+ }
+ break;
+ case GBAR_TYPE_UIFW:
+ case GBAR_TYPE_TEXT:
+ default:
+ break;
+ }
+
+ ret = dbox_sync_gbar_fb(common);
+ if (ret < 0) {
+ ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id)));
+ }
+ }
+ }
+
+ DbgPrint("PERF_DBOX\n");
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ if (handler->cbs.gbar_created.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = handler->cbs.gbar_created.cb;
+ cbdata = handler->cbs.gbar_created.data;
+
+ handler->cbs.gbar_created.cb = NULL;
+ handler->cbs.gbar_created.data = NULL;
+
+ /*!
+ * Before call the Callback function,
+ * gbar_create_cb must be reset.
+ * Because, in the create callback, user can call create_gbar function again.
+ */
+ cb(handler, status, cbdata);
+ } else if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_GBAR_CREATED);
+ }
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_gbar_destroyed(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dlist *l;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ int status;
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &status);
+ if (ret != 3) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ DbgPrint("[%s]\n", pkgname);
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance(%s) is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Instance(%s) is not created\n", id);
+ goto out;
+ }
+
+ if (common->is_gbar_created == 0) {
+ ErrPrint("GBAR is not created, event is ignored\n");
+ goto out;
+ }
+
+ common->is_gbar_created = 0;
+ common->request.gbar_destroyed = 0;
+
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ if (handler->cbs.gbar_destroyed.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = handler->cbs.gbar_destroyed.cb;
+ cbdata = handler->cbs.gbar_destroyed.data;
+
+ handler->cbs.gbar_destroyed.cb = NULL;
+ handler->cbs.gbar_destroyed.data = NULL;
+
+ /*!
+ * Before call the Callback function,
+ * gbar_destroyed_cb must be reset.
+ * Because, in the create callback, user can call destroy_gbar function again.
+ */
+ cb(handler, status, cbdata);
+ } else if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_GBAR_DESTROYED);
+ }
+ }
+
+ /*!
+ * \note
+ * Lock file should be deleted after all callbacks are processed.
+ */
+ switch (common->gbar.type) {
+ case GBAR_TYPE_SCRIPT:
+ case GBAR_TYPE_BUFFER:
+ switch (fb_type(dbox_get_gbar_fb(common))) {
+ case DBOX_FB_TYPE_FILE:
+ case DBOX_FB_TYPE_SHM:
+ dynamicbox_service_destroy_lock(common->gbar.lock);
+ common->gbar.lock = NULL;
+ break;
+ case DBOX_FB_TYPE_PIXMAP:
+ case DBOX_FB_TYPE_ERROR:
+ default:
+ break;
+ }
+ break;
+ case GBAR_TYPE_UIFW:
+ case GBAR_TYPE_TEXT:
+ default:
+ break;
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_gbar_updated(pid_t pid, int handle, const struct packet *packet)
+{
+ const char *pkgname;
+ const char *id;
+ const char *descfile;
+ const char *fbfile;
+ int ret;
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ struct dlist *l;
+ int x;
+ int y;
+ int w;
+ int h;
+
+ ret = packet_get(packet, "ssssiiii", &pkgname, &id, &fbfile, &descfile, &x, &y, &w, &h);
+ if (ret != 8) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("Instance(%s) is not exists\n", id);
+ goto out;
+ }
+
+ common->gbar.last_damage.x = x;
+ common->gbar.last_damage.y = y;
+ common->gbar.last_damage.w = w;
+ common->gbar.last_damage.h = h;
+
+ if (common->state != DBOX_STATE_CREATE) {
+ /*!
+ * \note
+ * This handler is already deleted by the user.
+ * So don't try to notice anything about this anymore.
+ * Just ignore all events.
+ */
+ ErrPrint("Instance(%s) is not created\n", id);
+ goto out;
+ }
+
+ if (dbox_text_gbar(common)) {
+ (void)parse_desc(common, descfile, 1);
+ } else {
+ if (conf_frame_drop_for_resizing() && common->request.size_changed) {
+ /* Just for skipping the update event callback call, After request to resize buffer, update event will be discarded */
+ DbgPrint("Discards obsoloted update event\n");
+ } else {
+ (void)dbox_set_gbar_fb(common, fbfile);
+
+ if (!conf_manual_sync()) {
+ ret = dbox_sync_gbar_fb(common);
+ if (ret < 0) {
+ ErrPrint("Failed to do sync FB (%s - %s), %d\n", pkgname, util_basename(util_uri_to_path(id)), ret);
+ } else {
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_GBAR_UPDATED);
+ }
+ }
+ } else {
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_GBAR_UPDATED);
+ }
+ }
+ }
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_gbar_extra_buffer_destroyed(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ struct dlist *l;
+ struct dlist *n;
+ const char *id;
+ int pixmap;
+ int idx;
+ int ret;
+
+ if (!packet) {
+ ErrPrint("Invalid packet\n");
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssii", &pkgname, &id, &pixmap, &idx);
+ if (ret != 4) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ if (idx < 0 || idx >= conf_extra_buffer_count()) {
+ ErrPrint("Extra buffer count is not matched\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("DBOX(%s) is not found\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("DBOX(%s) is not created yet\n", id);
+ goto out;
+ }
+
+ if (!common->gbar.extra_buffer && conf_extra_buffer_count()) {
+ common->gbar.extra_buffer = calloc(conf_extra_buffer_count(), sizeof(*common->gbar.extra_buffer));
+ if (!common->gbar.extra_buffer) {
+ ErrPrint("DBOX(%s) calloc: %s\n", id, strerror(errno));
+ }
+ }
+
+ common->gbar.last_extra_buffer_idx = idx;
+ if (common->gbar.extra_buffer[idx] != pixmap) {
+ DbgPrint("Extra buffer Pixmap is not matched %u <> %u\n", common->dbox.extra_buffer[idx], pixmap);
+ }
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_GBAR_EXTRA_BUFFER_DESTROYED);
+ }
+out:
+ return NULL;
+}
+
+static struct packet *master_dbox_extra_buffer_destroyed(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ struct dlist *l;
+ struct dlist *n;
+ const char *id;
+ int idx;
+ int pixmap;
+ int ret;
+
+ if (!packet) {
+ ErrPrint("Invalid packet\n");
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssii", &pkgname, &id, &pixmap, &idx);
+ if (ret != 4) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ if (idx < 0 || idx >= conf_extra_buffer_count()) {
+ ErrPrint("Extra buffer count is not matched\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("DBOX(%s) is not found\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("DBOX(%s) is not created yet\n", id);
+ goto out;
+ }
+
+ if (!common->dbox.extra_buffer && conf_extra_buffer_count()) {
+ common->dbox.extra_buffer = calloc(conf_extra_buffer_count(), sizeof(*common->dbox.extra_buffer));
+ if (!common->dbox.extra_buffer) {
+ ErrPrint("DBOX(%s) calloc: %s\n", id, strerror(errno));
+ }
+ }
+
+ common->dbox.last_extra_buffer_idx = idx;
+ if (common->dbox.extra_buffer[idx] != pixmap) {
+ DbgPrint("Extra buffer Pixmap is not matched %u <> %u\n", common->dbox.extra_buffer[idx], pixmap);
+ }
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DBOX_EXTRA_BUFFER_DESTROYED);
+ }
+out:
+ return NULL;
+}
+
+static struct packet *master_dbox_extra_buffer_created(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ struct dlist *l;
+ struct dlist *n;
+ const char *id;
+ int idx;
+ int pixmap;
+ int ret;
+
+ if (!packet) {
+ ErrPrint("Invalid packet\n");
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssii", &pkgname, &id, &pixmap, &idx);
+ if (ret != 4) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ if (idx < 0 || idx >= conf_extra_buffer_count()) {
+ ErrPrint("Extra buffer count is not matched\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("DBOX(%s) is not found\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("DBOX(%s) is not created yet\n", id);
+ goto out;
+ }
+
+ if (!common->dbox.extra_buffer && conf_extra_buffer_count()) {
+ common->dbox.extra_buffer = calloc(conf_extra_buffer_count(), sizeof(*common->dbox.extra_buffer));
+ if (!common->dbox.extra_buffer) {
+ ErrPrint("DBOX(%s) calloc: %s\n", id, strerror(errno));
+ }
+ }
+
+ common->dbox.last_extra_buffer_idx = idx;
+ common->dbox.extra_buffer[idx] = pixmap;
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DBOX_EXTRA_BUFFER_CREATED);
+ }
+out:
+ return NULL;
+}
+
+static struct packet *master_gbar_extra_buffer_created(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ struct dlist *l;
+ struct dlist *n;
+ const char *id;
+ int pixmap;
+ int idx;
+ int ret;
+
+ if (!packet) {
+ ErrPrint("Invalid packet\n");
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssii", &pkgname, &id, &pixmap, &idx);
+ if (ret != 4) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ if (idx < 0 || idx >= conf_extra_buffer_count()) {
+ ErrPrint("Extra buffer count is not matched\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("DBOX(%s) is not found\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("DBOX(%s) is not created yet\n", id);
+ goto out;
+ }
+
+ if (!common->gbar.extra_buffer && conf_extra_buffer_count()) {
+ common->gbar.extra_buffer = calloc(conf_extra_buffer_count(), sizeof(*common->gbar.extra_buffer));
+ if (!common->gbar.extra_buffer) {
+ ErrPrint("DBOX(%s) calloc: %s\n", id, strerror(errno));
+ }
+ }
+
+ common->gbar.last_extra_buffer_idx = idx;
+ common->gbar.extra_buffer[idx] = pixmap;
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_GBAR_EXTRA_BUFFER_CREATED);
+ }
+out:
+ return NULL;
+}
+
+static struct packet *master_update_mode(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ struct dlist *l;
+ struct dlist *n;
+ const char *pkgname;
+ const char *id;
+ int active_mode;
+ int status;
+ int ret;
+
+ if (!packet) {
+ ErrPrint("Invalid packet\n");
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssii", &pkgname, &id, &status, &active_mode);
+ if (ret != 4) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("DBOX(%s) is not found\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("DBOX(%s) is not created yet\n", id);
+ goto out;
+ }
+
+ if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ dbox_set_update_mode(common, active_mode);
+ }
+
+ common->request.update_mode = 0;
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ if (handler->cbs.update_mode.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = handler->cbs.update_mode.cb;
+ cbdata = handler->cbs.update_mode.data;
+
+ handler->cbs.update_mode.cb = NULL;
+ handler->cbs.update_mode.data = NULL;
+
+ cb(handler, status, cbdata);
+ } else if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_UPDATE_MODE_CHANGED);
+ }
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_size_changed(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ const char *pkgname;
+ const char *id;
+ const char *fbfile;
+ int status;
+ int ret;
+ int w;
+ int h;
+ int is_gbar;
+
+ if (!packet) {
+ ErrPrint("Invalid packet\n");
+ goto out;
+ }
+
+ ret = packet_get(packet, "sssiiii", &pkgname, &id, &fbfile, &is_gbar, &w, &h, &status);
+ if (ret != 7) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("DBOX(%s) is not found\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("DBOX(%s) is not created yet\n", id);
+ goto out;
+ }
+
+ common->request.size_changed = 0;
+ if (is_gbar) {
+ /*!
+ * \NOTE
+ * GBAR is not able to resized by the client.
+ * GBAR is only can be managed by the provider.
+ * So the GBAR has no private resized event handler.
+ * Notify it via global event handler only.
+ */
+ if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ struct dlist *l;
+
+ dbox_set_gbarsize(common, w, h);
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_GBAR_SIZE_CHANGED);
+ }
+ } else {
+ ErrPrint("This is not possible. GBAR Size is changed but the return value is not ZERO (%d)\n", status);
+ }
+ } else {
+ struct dlist *l;
+ struct dlist *n;
+
+ if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ dbox_set_size(common, w, h);
+
+ /*!
+ * \NOTE
+ * If there is a created DBOX FB,
+ * Update it too.
+ */
+ if (dbox_get_dbox_fb(common)) {
+ (void)dbox_set_dbox_fb(common, fbfile);
+
+ ret = dbox_sync_dbox_fb(common);
+ if (ret < 0) {
+ ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id)));
+ }
+
+ /* Just update the size info only. */
+ }
+ }
+
+ /*!
+ * \NOTE
+ * I cannot believe client.
+ * So I added some log before & after call the user callback.
+ */
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ if (handler->cbs.size_changed.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = handler->cbs.size_changed.cb;
+ cbdata = handler->cbs.size_changed.data;
+
+ handler->cbs.size_changed.cb = NULL;
+ handler->cbs.size_changed.data = NULL;
+
+ cb(handler, status, cbdata);
+ } else if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DBOX_SIZE_CHANGED);
+ }
+ }
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_period_changed(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ struct dlist *l;
+ struct dlist *n;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ double period;
+ int status;
+
+ ret = packet_get(packet, "idss", &status, &period, &pkgname, &id);
+ if (ret != 4) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("DBOX(%s) is not found\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ ErrPrint("DBOX(%s) is not created\n", id);
+ goto out;
+ }
+
+ if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ dbox_set_period(common, period);
+ }
+
+ common->request.period_changed = 0;
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ if (handler->cbs.period_changed.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = handler->cbs.period_changed.cb;
+ cbdata = handler->cbs.period_changed.data;
+
+ handler->cbs.period_changed.cb = NULL;
+ handler->cbs.period_changed.data = NULL;
+
+ cb(handler, status, cbdata);
+ } else if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_PERIOD_CHANGED);
+ }
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_group_changed(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ struct dlist *l;
+ struct dlist *n;
+ const char *pkgname;
+ const char *id;
+ int ret;
+ const char *cluster;
+ const char *category;
+ int status;
+
+ ret = packet_get(packet, "ssiss", &pkgname, &id, &status, &cluster, &category);
+ if (ret != 5) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
+
+ common = dbox_find_common_handle(pkgname, id);
+ if (!common) {
+ ErrPrint("DBOX(%s) is not exists\n", id);
+ goto out;
+ }
+
+ if (common->state != DBOX_STATE_CREATE) {
+ /*!
+ * \note
+ * Do no access this handler,
+ * You cannot believe this handler anymore.
+ */
+ ErrPrint("DBOX(%s) is not created\n", id);
+ goto out;
+ }
+
+ if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ (void)dbox_set_group(common, cluster, category);
+ }
+
+ common->request.group_changed = 0;
+
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ if (handler->cbs.group_changed.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = handler->cbs.group_changed.cb;
+ cbdata = handler->cbs.group_changed.data;
+
+ handler->cbs.group_changed.cb = NULL;
+ handler->cbs.group_changed.data = NULL;
+
+ cb(handler, status, cbdata);
+ } else if (status == (int)DBOX_STATUS_ERROR_NONE) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_GROUP_CHANGED);
+ }
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *master_update_id(pid_t pid, int handle, const struct packet *packet)
+{
+ int ret;
+ double timestamp;
+ const char *id;
+ struct dynamicbox_common *common;
+
+ if (!packet) {
+ ErrPrint("Invalid packet\n");
+ return NULL;
+ }
+
+ ret = packet_get(packet, "ds", &timestamp, &id);
+ if (ret != 2) {
+ ErrPrint("Invalid paramter\n");
+ return NULL;
+ }
+
+ common = dbox_find_common_handle_by_timestamp(timestamp);
+ if (!common) {
+ ErrPrint("Handle is not found for %d\n", timestamp);
+ return NULL;
+ }
+
+ dbox_set_id(common, id);
+ DbgPrint("Update ID(%s) for %lf\n", id, timestamp);
+ return NULL;
+}
+
+static struct packet *master_created(pid_t pid, int handle, const struct packet *packet)
+{
+ dynamicbox_h handler;
+ struct dynamicbox_common *common;
+ struct dlist *l;
+
+ int dbox_w;
+ int dbox_h;
+ int gbar_w;
+ int gbar_h;
+ const char *pkgname;
+ const char *id;
+
+ const char *content;
+ const char *cluster;
+ const char *category;
+ const char *dbox_fname;
+ const char *gbar_fname;
+ const char *title;
+
+ double timestamp;
+ const char *auto_launch;
+ double priority;
+ int size_list;
+ int user;
+ int pinup_supported;
+ dynamicbox_dbox_type_e dbox_type;
+ dynamicbox_gbar_type_e gbar_type;
+ double period;
+ int is_pinned_up;
+
+ int old_state = DBOX_STATE_DESTROYED;
+
+ int ret;
+
+ ret = packet_get(packet, "dsssiiiisssssdiiiiidsi",
+ &timestamp,
+ &pkgname, &id, &content,
+ &dbox_w, &dbox_h, &gbar_w, &gbar_h,
+ &cluster, &category, &dbox_fname, &gbar_fname,
+ &auto_launch, &priority, &size_list, &user, &pinup_supported,
+ &dbox_type, &gbar_type, &period, &title, &is_pinned_up);
+ if (ret != 22) {
+ ErrPrint("Invalid argument\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ ErrPrint("[%lf] pkgname: %s, id: %s, content: %s, "
+ "gbar_w: %d, gbar_h: %d, dbox_w: %d, dbox_h: %d, "
+ "cluster: %s, category: %s, dbox_fname: \"%s\", gbar_fname: \"%s\", "
+ "auto_launch: %s, priority: %lf, size_list: %d, user: %d, pinup: %d, "
+ "dbox_type: %d, gbar_type: %d, period: %lf, title: [%s], is_pinned_up: %d\n",
+ timestamp, pkgname, id, content,
+ gbar_w, gbar_h, dbox_w, dbox_h,
+ cluster, category, dbox_fname, gbar_fname,
+ auto_launch, priority, size_list, user, pinup_supported,
+ dbox_type, gbar_type, period, title, is_pinned_up);
+
+ common = dbox_find_common_handle_by_timestamp(timestamp);
+ if (!common) {
+ handler = dbox_new_dynamicbox(pkgname, id, timestamp, cluster, category);
+ if (!handler) {
+ ErrPrint("Failed to create a new dynamicbox\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto out;
+ }
+ common = handler->common;
+ old_state = common->state;
+ } else {
+ if (common->state != DBOX_STATE_CREATE) {
+ if (common->state != DBOX_STATE_DELETE) {
+ /*!
+ * \note
+ * This is not possible!!!
+ */
+ ErrPrint("Invalid handler\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ /*!
+ * \note
+ * After get the delete states,
+ * call the create callback with deleted result.
+ */
+ }
+
+ old_state = common->state;
+
+ if (common->id && common->request.created == 0) {
+ ErrPrint("Already created: timestamp[%lf] "
+ "pkgname[%s], id[%s] content[%s] "
+ "cluster[%s] category[%s] dbox_fname[%s] gbar_fname[%s]\n",
+ timestamp, pkgname, id,
+ content, cluster, category,
+ dbox_fname, gbar_fname);
+
+ ret = DBOX_STATUS_ERROR_ALREADY;
+ goto out;
+ }
+
+ dbox_set_id(common, id);
+ }
+
+ common->request.created = 0;
+ dbox_set_size(common, dbox_w, dbox_h);
+ common->dbox.type = dbox_type;
+ common->is_pinned_up = is_pinned_up;
+
+ switch (dbox_type) {
+ case DBOX_TYPE_UIFW:
+ case DBOX_TYPE_FILE:
+ break;
+ case DBOX_TYPE_SCRIPT:
+ case DBOX_TYPE_BUFFER:
+ if (!strlen(dbox_fname)) {
+ break;
+ }
+ (void)dbox_set_dbox_fb(common, dbox_fname);
+
+ /*!
+ * \note
+ * DBOX should create the lock file from here.
+ * Even if the old_state == DBOX_STATE_DELETE,
+ * the lock file will be deleted from deleted event callback.
+ */
+ switch (fb_type(dbox_get_dbox_fb(common))) {
+ case DBOX_FB_TYPE_FILE:
+ case DBOX_FB_TYPE_SHM:
+ common->dbox.lock = dynamicbox_service_create_lock(common->id, DBOX_TYPE_DBOX, DBOX_LOCK_READ);
+ break;
+ case DBOX_FB_TYPE_PIXMAP:
+ case DBOX_FB_TYPE_ERROR:
+ default:
+ break;
+ }
+
+ ret = dbox_sync_dbox_fb(common);
+ if (ret < 0) {
+ ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id)));
+ }
+ break;
+ case DBOX_TYPE_TEXT:
+ dbox_set_text_dbox(common);
+ break;
+ default:
+ break;
+ }
+
+ common->gbar.type = gbar_type;
+ dbox_set_gbarsize(common, gbar_w, gbar_h);
+ dbox_set_default_gbarsize(common, gbar_w, gbar_h);
+ switch (gbar_type) {
+ case GBAR_TYPE_SCRIPT:
+ case GBAR_TYPE_BUFFER:
+ if (!strlen(gbar_fname)) {
+ break;
+ }
+
+ dbox_set_gbar_fb(common, gbar_fname);
+
+ ret = dbox_sync_gbar_fb(common);
+ if (ret < 0) {
+ ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id)));
+ }
+
+ /*!
+ * \brief
+ * GBAR doesn't need to create the lock file from here.
+ * Just create it from GBAR_CREATED event.
+ */
+
+ break;
+ case GBAR_TYPE_TEXT:
+ dbox_set_text_gbar(common);
+ break;
+ case GBAR_TYPE_UIFW:
+ default:
+ break;
+ }
+
+ dbox_set_priority(common, priority);
+
+ dbox_set_size_list(common, size_list);
+ dbox_set_group(common, cluster, category);
+
+ dbox_set_content(common, content);
+ dbox_set_title(common, title);
+
+ dbox_set_user(common, user);
+
+ dbox_set_auto_launch(common, auto_launch);
+ dbox_set_pinup(common, pinup_supported);
+
+ dbox_set_period(common, period);
+
+ ret = 0;
+
+ if (common->state == DBOX_STATE_CREATE) {
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ /*!
+ * \note
+ * These callback can change the handler->state.
+ * So we have to use the "old_state" which stored state before call these callbacks
+ */
+
+ if (handler->cbs.created.cb) {
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = handler->cbs.created.cb;
+ cbdata = handler->cbs.created.data;
+
+ handler->cbs.created.cb = NULL;
+ handler->cbs.created.data = NULL;
+
+ cb(handler, ret, cbdata);
+ } else {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_CREATED);
+ }
+
+ /**
+ * If there is any updates before get this event,
+ * Invoke all update event forcely
+ */
+ switch (common->dbox.last_extra_buffer_idx) {
+ case DBOX_UNKNOWN_BUFFER:
+ break;
+ case DBOX_PRIMARY_BUFFER:
+ DbgPrint("Primary buffer updated\n");
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DBOX_UPDATED);
+ break;
+ default:
+ DbgPrint("Extra buffer updated\n");
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DBOX_EXTRA_UPDATED);
+ break;
+ }
+ }
+ }
+
+out:
+ if (ret == 0 && old_state == DBOX_STATE_DELETE) {
+ struct dlist *n;
+
+ DbgPrint("Take place an unexpected case [%d]\n", common->refcnt);
+ dlist_foreach_safe(common->dynamicbox_list, l, n, handler) {
+ if (handler->cbs.created.cb) {
+ if (!handler->common->request.deleted) {
+ if (dbox_send_delete(handler, common->delete_type, handler->cbs.created.cb, handler->cbs.created.data) < 0) {
+ /*!
+ * \note
+ * Already sent or something else happens.
+ * Callback will be called in any cases
+ */
+ }
+ } else if (handler->state != DBOX_STATE_DELETE) {
+ handler->cbs.created.cb(handler, DBOX_STATUS_ERROR_CANCEL, handler->cbs.created.data);
+ dbox_unref(handler, 1);
+ }
+ } else {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+
+ /*!
+ * \note
+ * handler->cbs.created.cb = NULL;
+ * handler->cbs.created.data = NULL;
+ *
+ * Do not clear this to use this from the deleted event callback.
+ * if this value is not cleared when the deleted event callback check it,
+ * it means that the created function is not called yet.
+ * Then the call the deleted event callback with DBOX_STATUS_ERROR_CANCEL errno.
+ */
+ }
+
+ return NULL;
+}
+
+static struct method s_table[] = {
+ { /* DBOX_UPDATED */
+ .cmd = CMD_STR_DBOX_UPDATED, /* pkgname, id, dbox_w, dbox_h, priority, ret */
+ .handler = master_dbox_updated,
+ },
+ { /* GBAR_UPDATED */
+ .cmd = CMD_STR_GBAR_UPDATED, /* pkgname, id, descfile, pd_w, pd_h, ret */
+ .handler = master_gbar_updated,
+ },
+ { /* EXTRA_UPDATED */
+ .cmd = CMD_STR_EXTRA_UPDATED,
+ .handler = master_extra_updated,
+ },
+ { /* EXTRA_INFO */
+ .cmd = CMD_STR_EXTRA_INFO,
+ .handler = master_extra_info,
+ },
+ { /* DELETED */
+ .cmd = CMD_STR_DELETED, /* pkgname, id, timestamp, ret */
+ .handler = master_deleted,
+ },
+ { /* FAULTED */
+ .cmd = CMD_STR_FAULT_PACKAGE, /* pkgname, id, function, ret */
+ .handler = master_fault_package,
+ },
+ { /* SCROLL */
+ .cmd = CMD_STR_SCROLL,
+ .handler = master_hold_scroll,
+ },
+ { /* DBOX_UPDATE_BEGIN */
+ .cmd = CMD_STR_DBOX_UPDATE_BEGIN,
+ .handler = master_dbox_update_begin,
+ },
+ { /* DBOX_UPDATE_END */
+ .cmd = CMD_STR_DBOX_UPDATE_END,
+ .handler = master_dbox_update_end,
+ },
+ { /* GBAR_UPDATE_BEGIN */
+ .cmd = CMD_STR_GBAR_UPDATE_BEGIN,
+ .handler = master_gbar_update_begin,
+ },
+ { /* GBAR_UPDATE_END */
+ .cmd = CMD_STR_GBAR_UPDATE_END,
+ .handler = master_gbar_update_end,
+ },
+ { /* ACCESS_STATUS */
+ .cmd = CMD_STR_ACCESS_STATUS,
+ .handler = master_access_status,
+ },
+ { /* KEY_STATUS */
+ .cmd = CMD_STR_KEY_STATUS,
+ .handler = master_key_status,
+ },
+ { /* CLOSE_GBAR */
+ .cmd = CMD_STR_CLOSE_GBAR,
+ .handler = master_request_close_gbar,
+ },
+ { /* GBAR_CREATED */
+ .cmd = CMD_STR_GBAR_CREATED,
+ .handler = master_gbar_created,
+ },
+ { /* GBAR_DESTROYED */
+ .cmd = CMD_STR_GBAR_DESTROYED,
+ .handler = master_gbar_destroyed,
+ },
+ { /* CREATED */
+ .cmd = CMD_STR_CREATED,
+ .handler = master_created,
+ },
+ { /* GROUP_CHANGED */
+ .cmd = CMD_STR_GROUP_CHANGED,
+ .handler = master_group_changed,
+ },
+ { /* PERIOD_CHANGED */
+ .cmd = CMD_STR_PERIOD_CHANGED,
+ .handler = master_period_changed,
+ },
+ { /* SIZE_CHANGED */
+ .cmd = CMD_STR_SIZE_CHANGED,
+ .handler = master_size_changed,
+ },
+ { /* PINUP */
+ .cmd = CMD_STR_PINUP,
+ .handler = master_pinup,
+ },
+ { /* UPDATE_MODE */
+ .cmd = CMD_STR_UPDATE_MODE,
+ .handler = master_update_mode,
+ },
+ { /* DBOX_CREATE_XBUF */
+ .cmd = CMD_STR_DBOX_CREATE_XBUF,
+ .handler = master_dbox_extra_buffer_created,
+ },
+ { /* GBAR_CREATE_XBUF */
+ .cmd = CMD_STR_GBAR_CREATE_XBUF,
+ .handler = master_gbar_extra_buffer_created,
+ },
+ { /* DBOX_DESTROY_XBUF */
+ .cmd = CMD_STR_DBOX_DESTROY_XBUF,
+ .handler = master_dbox_extra_buffer_destroyed,
+ },
+ { /* GBAR_DESTROY_XBUF */
+ .cmd = CMD_STR_GBAR_DESTROY_XBUF,
+ .handler = master_gbar_extra_buffer_destroyed,
+ },
+ { /* UPDATE_ID */
+ .cmd = CMD_STR_UPDATE_ID,
+ .handler = master_update_id,
+ },
+ {
+ .cmd = NULL,
+ .handler = NULL,
+ },
+};
+
+static void acquire_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ if (!result) {
+ DbgPrint("Result packet is not valid\n");
+ } else {
+ int ret;
+ int extra_buffer_count;
+
+ if (packet_get(result, "ii", &ret, &extra_buffer_count) != 2) {
+ ErrPrint("Invalid argument\n");
+ } else {
+ DbgPrint("Acquire returns: %d (%d)\n", ret, extra_buffer_count);
+ conf_set_extra_buffer_count(extra_buffer_count);
+ }
+ }
+
+ return;
+}
+
+static inline int make_connection(void)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_ACQUIRE;
+ int ret;
+
+ DbgPrint("Let's making connection!\n");
+
+ s_info.fd = com_core_packet_client_init(client_addr(), 0, s_table);
+ if (s_info.fd < 0) {
+ ErrPrint("Try this again later\n");
+ return DBOX_STATUS_ERROR_IO_ERROR;
+ }
+
+ packet = packet_create((const char *)&cmd, "ds", util_timestamp(), client_direct_addr());
+ if (!packet) {
+ com_core_packet_client_fini(s_info.fd);
+ s_info.fd = -1;
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(NULL, packet, 1, acquire_cb, NULL);
+ if (ret < 0) {
+ ErrPrint("Master RPC returns %d\n", ret);
+ com_core_packet_client_fini(s_info.fd);
+ s_info.fd = -1;
+ return DBOX_STATUS_ERROR_IO_ERROR;
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+static int connected_cb(int handle, void *data)
+{
+ master_rpc_check_and_fire_consumer();
+ return 0;
+}
+
+static void master_started_cb(keynode_t *node, void *data)
+{
+ int state = 0;
+
+ if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &state) < 0) {
+ ErrPrint("Unable to get [%s]\n", VCONFKEY_MASTER_STARTED);
+ }
+
+ DbgPrint("Master state: %d\n", state);
+ if (state == 1 && make_connection() == (int)DBOX_STATUS_ERROR_NONE) {
+ int ret;
+ ret = vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb);
+ if (ret < 0) {
+ DbgPrint("master_started vconf key de-registered [%d]\n", ret);
+ }
+ }
+}
+
+static gboolean timeout_cb(gpointer data)
+{
+ if (vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL) < 0) {
+ ErrPrint("Failed to add vconf for monitoring service state\n");
+ } else {
+ DbgPrint("vconf event callback is registered\n");
+ }
+
+ master_started_cb(NULL, NULL);
+
+ s_info.timer_id = 0;
+ return FALSE;
+}
+
+static int disconnected_cb(int handle, void *data)
+{
+ if (s_info.fd != handle) {
+ /*!< This handle is not my favor */
+ return 0;
+ }
+
+ s_info.fd = -1; /*!< Disconnected */
+
+ master_rpc_clear_all_request();
+ dbox_invoke_fault_handler(DBOX_FAULT_PROVIDER_DISCONNECTED, MASTER_PKGNAME, "default", "disconnected");
+
+ dbox_delete_all();
+
+ /* Try to reconnect after 1 sec later */
+ if (!s_info.timer_id) {
+ DbgPrint("Reconnecting timer is added\n");
+ s_info.timer_id = g_timeout_add(1000, timeout_cb, NULL);
+ if (s_info.timer_id == 0) {
+ ErrPrint("Unable to add reconnecting timer\n");
+ return 0;
+ }
+ } else {
+ ErrPrint("Reconnecting timer is already exists\n");
+ }
+
+ return 0;
+}
+
+static struct method s_direct_table[] = {
+ {
+ .cmd = CMD_STR_DBOX_UPDATED, /* pkgname, id, lb_w, lb_h, priority, ret */
+ .handler = master_dbox_updated,
+ },
+ {
+ .cmd = CMD_STR_GBAR_UPDATED, /* pkgname, id, descfile, pd_w, pd_h, ret */
+ .handler = master_gbar_updated,
+ },
+ {
+ .cmd = CMD_STR_EXTRA_UPDATED,
+ .handler = master_extra_updated,
+ },
+ {
+ .cmd = NULL,
+ .handler = NULL,
+ },
+};
+
+static void prepare_direct_update(void)
+{
+ char path[MAX_DIRECT_ADDR];
+
+ if (!conf_direct_update()) {
+ return;
+ }
+
+ if (!strncmp(s_info.client_addr, COM_CORE_REMOTE_SCHEME, strlen(COM_CORE_REMOTE_SCHEME))) {
+ ErrPrint("Remote model is not support this\n");
+ return;
+ }
+
+ snprintf(path, sizeof(path) - 1, "/tmp/.%d.%lf.dbox.viewer", getpid(), util_timestamp());
+
+ s_info.direct_addr = strdup(path);
+ if (!s_info.direct_addr) {
+ ErrPrint("strdup: %s\n", strerror(errno));
+ return;
+ }
+
+ s_info.direct_fd = com_core_packet_server_init(client_direct_addr(), s_direct_table);
+ if (s_info.direct_fd < 0) {
+ ErrPrint("Failed to prepare server: %s\n", client_direct_addr());
+ return;
+ }
+
+ DbgPrint("Direct update is prepared: %s - %d\n", client_direct_addr(), client_direct_fd());
+}
+
+int client_init(int use_thread)
+{
+ com_core_packet_use_thread(use_thread);
+
+ s_info.client_addr = vconf_get_str(VCONFKEY_MASTER_CLIENT_ADDR);
+ if (!s_info.client_addr) {
+ s_info.client_addr = strdup(CLIENT_SOCKET);
+ if (!s_info.client_addr) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+ }
+
+ (void)file_service_init();
+
+ DbgPrint("Server Address: %s\n", s_info.client_addr);
+
+ com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL);
+ com_core_add_event_callback(CONNECTOR_CONNECTED, connected_cb, NULL);
+
+ /**
+ * @note
+ * Before creating a connection with master,
+ * Initiate the private channel for getting the updated event from providers
+ * How could we propagates the our address to every providers?
+ */
+ prepare_direct_update();
+
+ if (vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL) < 0) {
+ ErrPrint("Failed to add vconf for service state\n");
+ } else {
+ DbgPrint("vconf event callback is registered\n");
+ }
+
+ master_started_cb(NULL, NULL);
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int client_fd(void)
+{
+ return s_info.fd;
+}
+
+const char *client_addr(void)
+{
+ return s_info.client_addr;
+}
+
+const char *client_direct_addr(void)
+{
+ return s_info.direct_addr;
+}
+
+int client_direct_fd(void)
+{
+ return s_info.direct_fd;
+}
+
+int client_fini(void)
+{
+ int ret;
+
+ (void)file_service_fini();
+
+ ret = vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb);
+ if (ret < 0) {
+ DbgPrint("Ignore vconf key: %d\n", ret);
+ }
+
+ com_core_del_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL);
+ com_core_del_event_callback(CONNECTOR_CONNECTED, connected_cb, NULL);
+ com_core_packet_client_fini(s_info.fd);
+ s_info.fd = -1;
+
+ if (s_info.direct_fd >= 0) {
+ com_core_packet_server_fini(s_info.direct_fd);
+ s_info.direct_fd = -1;
+ }
+
+ free(s_info.client_addr);
+ s_info.client_addr = NULL;
+
+ free(s_info.direct_addr);
+ s_info.direct_addr = NULL;
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+/* End of a file */
diff --git a/dynamicbox_viewer/src/conf.c b/dynamicbox_viewer/src/conf.c
new file mode 100644
index 0000000..fe0a448
--- /dev/null
+++ b/dynamicbox_viewer/src/conf.c
@@ -0,0 +1,82 @@
+#include <stdio.h>
+#include <dynamicbox_errno.h>
+
+static struct info {
+ int manual_sync;
+ int frame_drop_for_resizing;
+ int shared_content;
+ int direct_update;
+ int extra_buffer_count;
+
+ double event_filter;
+} s_info = {
+ .manual_sync = 0,
+ .frame_drop_for_resizing = 1,
+ .shared_content = 0,
+ .direct_update = 0,
+ .extra_buffer_count = 0,
+
+ .event_filter = 0.01f,
+};
+
+void conf_set_direct_update(int flag)
+{
+ s_info.direct_update = flag;
+}
+
+int conf_direct_update(void)
+{
+ return s_info.direct_update;
+}
+
+void conf_set_manual_sync(int flag)
+{
+ s_info.manual_sync = flag;
+}
+
+int conf_manual_sync(void)
+{
+ return s_info.manual_sync;
+}
+
+void conf_set_frame_drop_for_resizing(int flag)
+{
+ s_info.frame_drop_for_resizing = flag;
+}
+
+int conf_frame_drop_for_resizing(void)
+{
+ return s_info.frame_drop_for_resizing;
+}
+
+void conf_set_shared_content(int flag)
+{
+ s_info.shared_content = flag;
+}
+
+int conf_shared_content(void)
+{
+ return s_info.shared_content;
+}
+
+double conf_event_filter(void)
+{
+ return s_info.event_filter;
+}
+
+void conf_set_event_filter(double filter)
+{
+ s_info.event_filter = filter;
+}
+
+void conf_set_extra_buffer_count(int buffer_count)
+{
+ s_info.extra_buffer_count = buffer_count;
+}
+
+int conf_extra_buffer_count(void)
+{
+ return s_info.extra_buffer_count;
+}
+
+/* End of a file */
diff --git a/dynamicbox_viewer/src/desc_parser.c b/dynamicbox_viewer/src/desc_parser.c
new file mode 100644
index 0000000..4103b90
--- /dev/null
+++ b/dynamicbox_viewer/src/desc_parser.c
@@ -0,0 +1,698 @@
+/*
+ * 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 <stdio.h>
+#include <errno.h>
+#include <stdlib.h> /* malloc */
+#include <string.h> /* strdup */
+#include <ctype.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <gio/gio.h>
+#include <dlog.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_buffer.h>
+
+#include "debug.h"
+#include "dynamicbox.h"
+#include "dynamicbox_internal.h"
+#include "desc_parser.h"
+#include "dlist.h"
+#include "util.h"
+
+#define INFO_SIZE "size"
+#define INFO_CATEGORY "category"
+
+static const char *type_list[] = {
+ "access",
+ "access,operation",
+ "color",
+ "drag",
+ "image",
+ "info",
+ "script",
+ "signal",
+ "text",
+ NULL
+};
+
+static const char *field_list[] = {
+ "type",
+ "part",
+ "data",
+ "option",
+ "id",
+ "target",
+ "file",
+ NULL
+};
+
+enum block_type {
+ TYPE_ACCESS,
+ TYPE_ACCESS_OP,
+ TYPE_COLOR,
+ TYPE_DRAG,
+ TYPE_IMAGE,
+ TYPE_INFO,
+ TYPE_SCRIPT,
+ TYPE_SIGNAL,
+ TYPE_TEXT,
+ TYPE_MAX
+};
+
+enum field_type {
+ FIELD_TYPE,
+ FIELD_PART,
+ FIELD_DATA,
+ FIELD_OPTION,
+ FIELD_ID,
+ FIELD_TARGET,
+ FIELD_FILE
+};
+
+struct block {
+ enum block_type type;
+ char *part;
+ char *data;
+ char *option;
+ char *id;
+ char *target;
+ char *file;
+
+ /* Should be released */
+ char *filebuf;
+ const char *filename;
+};
+
+static int update_text(dynamicbox_h handle, struct block *block, int is_gbar)
+{
+ struct dynamicbox_script_operators *ops;
+
+ if (!block || !block->part || !block->data) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (ops->update_text) {
+ ops->update_text(handle, (const char *)block->id, (const char *)block->part, (const char *)block->data);
+ }
+
+ return 0;
+}
+
+static int update_image(dynamicbox_h handle, struct block *block, int is_gbar)
+{
+ struct dynamicbox_script_operators *ops;
+
+ if (!block || !block->part) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (ops->update_image) {
+ ops->update_image(handle, block->id, block->part, block->data, block->option);
+ }
+
+ return 0;
+}
+
+static int update_script(dynamicbox_h handle, struct block *block, int is_gbar)
+{
+ struct dynamicbox_script_operators *ops;
+
+ if (!block || !block->part) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (ops->update_script) {
+ ops->update_script(handle, block->id, block->target, block->part, block->data, block->option);
+ }
+
+ return 0;
+}
+
+static int update_signal(dynamicbox_h handle, struct block *block, int is_gbar)
+{
+ struct dynamicbox_script_operators *ops;
+
+ if (!block) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (ops->update_signal) {
+ ops->update_signal(handle, block->id, block->data, block->part);
+ }
+
+ return 0;
+}
+
+static int update_drag(dynamicbox_h handle, struct block *block, int is_gbar)
+{
+ double dx, dy;
+ struct dynamicbox_script_operators *ops;
+
+ if (!block || !block->data || !block->part) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (sscanf(block->data, "%lfx%lf", &dx, &dy) != 2) {
+ ErrPrint("Invalid format of data\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (ops->update_drag) {
+ ops->update_drag(handle, block->id, block->part, dx, dy);
+ }
+
+ return 0;
+}
+
+static int update_info(dynamicbox_h handle, struct block *block, int is_gbar)
+{
+ struct dynamicbox_script_operators *ops;
+
+ if (!block || !block->part || !block->data) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (!strcasecmp(block->part, INFO_SIZE)) {
+ int w, h;
+
+ if (sscanf(block->data, "%dx%d", &w, &h) != 2) {
+ ErrPrint("Invalid format (%s)\n", block->data);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (ops->update_info_size) {
+ ops->update_info_size(handle, block->id, w, h);
+ }
+ } else if (!strcasecmp(block->part, INFO_CATEGORY)) {
+ if (ops->update_info_category) {
+ ops->update_info_category(handle, block->id, block->data);
+ }
+ }
+
+ return 0;
+}
+
+static int update_access(dynamicbox_h handle, struct block *block, int is_gbar)
+{
+ struct dynamicbox_script_operators *ops;
+
+ if (!block) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (ops->update_access) {
+ ops->update_access(handle, block->id, block->part, block->data, block->option);
+ }
+
+ return 0;
+}
+
+static int operate_access(dynamicbox_h handle, struct block *block, int is_gbar)
+{
+ struct dynamicbox_script_operators *ops;
+
+ if (!block) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (ops->operate_access) {
+ ops->operate_access(handle, block->id, block->part, block->data, block->option);
+ }
+
+ return 0;
+}
+
+static int update_color(dynamicbox_h handle, struct block *block, int is_gbar)
+{
+ struct dynamicbox_script_operators *ops;
+
+ if (!block) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (ops->update_color) {
+ ops->update_color(handle, block->id, block->part, block->data);
+ }
+
+ return 0;
+}
+
+static inline int update_begin(dynamicbox_h handle, int is_gbar)
+{
+ struct dynamicbox_script_operators *ops;
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (ops->update_begin) {
+ ops->update_begin(handle);
+ }
+
+ return 0;
+}
+
+static inline int update_end(dynamicbox_h handle, int is_gbar)
+{
+ struct dynamicbox_script_operators *ops;
+
+ ops = is_gbar ? &handle->cbs.gbar_ops : &handle->cbs.dbox_ops;
+ if (ops->update_end) {
+ ops->update_end(handle);
+ }
+
+ return 0;
+}
+
+static inline void delete_block(struct block *block)
+{
+ free(block->filebuf);
+ free(block);
+}
+
+static inline void consuming_parsed_block(dynamicbox_h handle, int is_gbar, struct block *block)
+{
+ typedef int (*update_function_t)(dynamicbox_h handle, struct block *block, int is_gbar);
+ static update_function_t updators[] = {
+ update_access,
+ operate_access,
+ update_color,
+ update_drag,
+ update_image,
+ update_info,
+ update_script,
+ update_signal,
+ update_text,
+ NULL
+ };
+
+ if (block->type >= 0 || block->type < TYPE_MAX) {
+ (void)updators[block->type](handle, block, is_gbar);
+ } else {
+ ErrPrint("Block type[%d] is not valid\n", block->type);
+ }
+}
+
+static inline char *load_file(const char *filename)
+{
+ char *filebuf = NULL;
+ int fd;
+ off_t filesize;
+ int ret;
+ size_t readsize = 0;
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ ErrPrint("open: %s (%s)\n", strerror(errno), filename);
+ return NULL;
+ }
+
+ filesize = lseek(fd, 0L, SEEK_END);
+ if (filesize == (off_t)-1) {
+ ErrPrint("lseek: %s\n", strerror(errno));
+ goto errout;
+ }
+
+ if (lseek(fd, 0L, SEEK_SET) < 0) {
+ ErrPrint("lseek: %s\n", strerror(errno));
+ goto errout;
+ }
+
+ filebuf = malloc(filesize + 1);
+ if (!filebuf) {
+ ErrPrint("malloc: %s\n", strerror(errno));
+ goto errout;
+ }
+
+ while (readsize < filesize) {
+ ret = read(fd, filebuf + readsize, (size_t)filesize - readsize);
+ if (ret < 0) {
+ if (errno == EINTR) {
+ DbgPrint("Read is interrupted\n");
+ continue;
+ }
+
+ ErrPrint("read: %s\n", strerror(errno));
+ free(filebuf);
+ filebuf = NULL;
+ break;
+ }
+
+ readsize += ret;
+ }
+
+ if (filebuf) {
+ filebuf[readsize] = '\0';
+ }
+
+ /*!
+ * \note
+ * Now, we are ready to parse the filebuf.
+ */
+
+errout:
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
+
+ return filebuf;
+}
+
+int parse_desc(struct dynamicbox_common *common, const char *filename, int is_gbar)
+{
+ int type_idx = 0;
+ int type_len = 0;
+ int field_idx = 0;
+ int field_len = 0;
+ char *filebuf;
+ char *fileptr;
+ char *ptr = NULL;
+ struct block *block = NULL;
+ struct dlist *block_list = NULL;
+ struct dlist *l;
+ struct dlist *n;
+ struct dlist *handle_iterator;
+ dynamicbox_h handler;
+ enum state {
+ BEGIN,
+ FIELD,
+ DATA,
+ END,
+ DONE,
+ ERROR,
+ } state;
+
+ filebuf = load_file(filename);
+ if (!filebuf) {
+ return DBOX_STATUS_ERROR_IO_ERROR;
+ }
+
+ fileptr = filebuf;
+
+ state = BEGIN;
+ while (*fileptr && state != ERROR) {
+ switch (state) {
+ case BEGIN:
+ if (*fileptr == '{') {
+ block = calloc(1, sizeof(*block));
+ if (!block) {
+ ErrPrint("calloc: %s\n", strerror(errno));
+ state = ERROR;
+ continue;
+ }
+ state = FIELD;
+ ptr = NULL;
+ }
+ break;
+ case FIELD:
+ if (isspace(*fileptr)) {
+ if (ptr != NULL) {
+ *fileptr = '\0';
+ }
+ } else if (*fileptr == '=') {
+ *fileptr = '\0';
+ ptr = NULL;
+ state = DATA;
+ } else if (ptr == NULL) {
+ ptr = fileptr;
+ field_idx = 0;
+ field_len = 0;
+
+ while (field_list[field_idx]) {
+ if (field_list[field_idx][field_len] == *fileptr) {
+ break;
+ }
+ field_idx++;
+ }
+
+ if (!field_list[field_idx]) {
+ ErrPrint("Invalid field\n");
+ state = ERROR;
+ continue;
+ }
+
+ field_len++;
+ } else {
+ if (field_list[field_idx][field_len] != *fileptr) {
+ field_idx++;
+ while (field_list[field_idx]) {
+ if (!strncmp(field_list[field_idx], fileptr - field_len, field_len)) {
+ break;
+ } else {
+ field_idx++;
+ }
+ }
+
+ if (!field_list[field_idx]) {
+ state = ERROR;
+ ErrPrint("field is not valid\n");
+ continue;
+ }
+ }
+
+ field_len++;
+ }
+ break;
+ case DATA:
+ switch (field_idx) {
+ case FIELD_TYPE:
+ if (ptr == NULL) {
+ if (isspace(*fileptr)) {
+ break;
+ }
+
+ if (*fileptr == '\0') {
+ state = ERROR;
+ ErrPrint("Type is not valid\n");
+ continue;
+ }
+
+ ptr = fileptr;
+ type_idx = 0;
+ type_len = 0;
+ }
+
+ if (*fileptr && (*fileptr == '\n' || *fileptr == '\r' || *fileptr == '\f')) {
+ *fileptr = '\0';
+ }
+
+ if (type_list[type_idx][type_len] != *fileptr) {
+ type_idx++;
+ while (type_list[type_idx]) {
+ if (!strncmp(type_list[type_idx], fileptr - type_len, type_len)) {
+ break;
+ } else {
+ type_idx++;
+ }
+ }
+
+ if (!type_list[type_idx]) {
+ state = ERROR;
+ ErrPrint("type is not valid (%s)\n", fileptr - type_len);
+ continue;
+ }
+ }
+
+ if (!*fileptr) {
+ block->type = type_idx;
+ state = DONE;
+ ptr = NULL;
+ }
+
+ type_len++;
+ break;
+ case FIELD_PART:
+ if (ptr == NULL) {
+ ptr = fileptr;
+ }
+
+ if (*fileptr && (*fileptr == '\n' || *fileptr == '\r' || *fileptr == '\f')) {
+ *fileptr = '\0';
+ }
+
+ if (!*fileptr) {
+ block->part = ptr;
+ state = DONE;
+ ptr = NULL;
+ }
+ break;
+ case FIELD_DATA:
+ if (ptr == NULL) {
+ ptr = fileptr;
+ }
+
+ if (*fileptr && (*fileptr == '\n' || *fileptr == '\r' || *fileptr == '\f')) {
+ *fileptr = '\0';
+ }
+
+ if (!*fileptr) {
+ block->data = ptr;
+ state = DONE;
+ ptr = NULL;
+ }
+ break;
+ case FIELD_OPTION:
+ if (ptr == NULL) {
+ ptr = fileptr;
+ }
+
+ if (*fileptr && (*fileptr == '\n' || *fileptr == '\r' || *fileptr == '\f')) {
+ *fileptr = '\0';
+ }
+
+ if (!*fileptr) {
+ block->option = ptr;
+ state = DONE;
+ ptr = NULL;
+ }
+ break;
+ case FIELD_ID:
+ if (ptr == NULL) {
+ ptr = fileptr;
+ }
+
+ if (*fileptr && (*fileptr == '\n' || *fileptr == '\r' || *fileptr == '\f')) {
+ *fileptr = '\0';
+ }
+
+ if (!*fileptr) {
+ block->id = ptr;
+ state = DONE;
+ ptr = NULL;
+ }
+ break;
+ case FIELD_TARGET:
+ if (ptr == NULL) {
+ ptr = fileptr;
+ }
+
+ if (*fileptr && (*fileptr == '\n' || *fileptr == '\r' || *fileptr == '\f')) {
+ *fileptr = '\0';
+ }
+
+ if (!*fileptr) {
+ block->target = ptr;
+ state = DONE;
+ ptr = NULL;
+ }
+ break;
+ case FIELD_FILE:
+ if (ptr == NULL) {
+ ptr = fileptr;
+ }
+
+ if (*fileptr && (*fileptr == '\n' || *fileptr == '\r' || *fileptr == '\f')) {
+ *fileptr = '\0';
+ }
+
+ if (!*fileptr) {
+ block->target = ptr;
+ state = DONE;
+ ptr = NULL;
+ }
+ default:
+ break;
+ }
+
+ break;
+ case DONE:
+ if (isspace(*fileptr)) {
+ } else if (*fileptr == '}') {
+ state = BEGIN;
+ block->filename = filename;
+ block_list = dlist_append(block_list, block);
+ block = NULL;
+ } else {
+ state = FIELD;
+ continue;
+ }
+ break;
+ case END:
+ default:
+ break;
+ }
+
+ fileptr++;
+ }
+
+ if (state != BEGIN) {
+ struct dlist *l;
+ struct dlist *n;
+ ErrPrint("State %d\n", state);
+
+ free(filebuf);
+ free(block);
+
+ dlist_foreach_safe(block_list, l, n, block) {
+ free(block);
+ block_list = dlist_remove(block_list, l);
+ }
+
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+
+ block = dlist_data(dlist_prev(block_list));
+ if (block) {
+ block->filebuf = filebuf;
+ } else {
+ ErrPrint("Last block is not exists (There is no parsed block)\n");
+ free(filebuf);
+ }
+
+ ErrPrint("Begin: Set content for object\n");
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ update_begin(handler, is_gbar);
+ }
+
+ dlist_foreach_safe(block_list, l, n, block) {
+ dlist_foreach(common->dynamicbox_list, handle_iterator, handler) {
+ consuming_parsed_block(handler, is_gbar, block);
+ }
+
+ block_list = dlist_remove(block_list, l);
+ delete_block(block);
+ }
+
+ dlist_foreach(common->dynamicbox_list, l, handler) {
+ update_end(handler, is_gbar);
+ }
+ ErrPrint("End: Set content for object\n");
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+/* End of a file */
diff --git a/dynamicbox_viewer/src/dlist.c b/dynamicbox_viewer/src/dlist.c
new file mode 100644
index 0000000..9aa8caa
--- /dev/null
+++ b/dynamicbox_viewer/src/dlist.c
@@ -0,0 +1,189 @@
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "dlist.h"
+
+/*!
+ * \brief
+ * This dlist is called Modified Doubly Linked List.
+ *
+ * Noramlly, The dobule linked list contains address of previous and next element.
+ * This dlist also contains them, but the tail element only contains prev address.
+ *
+ * The head element's prev pointer indicates the last element.
+ * But the last element's next pointer indicates NIL.
+ *
+ * So we can find the last element while crawling this DList
+ * But we have to remember the address of the head element.
+ */
+
+struct dlist {
+ struct dlist *next;
+ struct dlist *prev;
+ void *data;
+};
+
+struct dlist *dlist_append(struct dlist *list, void *data)
+{
+ struct dlist *item;
+
+ item = malloc(sizeof(*item));
+ if (!item) {
+ return NULL;
+ }
+
+ item->next = NULL;
+ item->data = data;
+
+ if (!list) {
+ item->prev = item;
+
+ list = item;
+ } else {
+ item->prev = list->prev;
+ item->prev->next = item;
+ list->prev = item;
+ }
+
+ assert(!list->prev->next && "item NEXT");
+
+ return list;
+}
+
+struct dlist *dlist_prepend(struct dlist *list, void *data)
+{
+ struct dlist *item;
+
+ item = malloc(sizeof(*item));
+ if (!item) {
+ return NULL;
+ }
+
+ item->data = data;
+
+ if (!list) {
+ item->prev = item;
+ item->next = NULL;
+ } else {
+ if (list->prev->next) {
+ list->prev->next = item;
+ }
+
+ item->prev = list->prev;
+ item->next = list;
+
+ list->prev = item;
+
+ }
+
+ return item;
+}
+
+struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
+{
+ if (!list || !l) {
+ return NULL;
+ }
+
+ if (l == list) {
+ list = l->next;
+ } else {
+ l->prev->next = l->next;
+ }
+
+ if (l->next) {
+ l->next->prev = l->prev;
+ }
+ /*!
+ * \note
+ * If the removed entry 'l' has no next element, it is the last element.
+ * In this case, check the existence of the list first,
+ * and if the list is not empty, update the 'prev' of the list (which is a head element of the list)
+ *
+ * If we didn't care about this, the head element(list) can indicates the invalid element.
+ */
+ else if (list) {
+ list->prev = l->prev;
+ }
+
+ free(l);
+ return list;
+}
+
+struct dlist *dlist_find_data(struct dlist *list, void *data)
+{
+ struct dlist *l;
+ void *_data;
+
+ dlist_foreach(list, l, _data) {
+ if (data == _data) {
+ return l;
+ }
+ }
+
+ return NULL;
+}
+
+void *dlist_data(struct dlist *l)
+{
+ return l ? l->data : NULL;
+}
+
+struct dlist *dlist_next(struct dlist *l)
+{
+ return l ? l->next : NULL;
+}
+
+struct dlist *dlist_prev(struct dlist *l)
+{
+ return l ? l->prev : NULL;
+}
+
+int dlist_count(struct dlist *l)
+{
+ register int i;
+ struct dlist *n;
+ void *data;
+
+ i = 0;
+ dlist_foreach(l, n, data) {
+ i++;
+ }
+
+ return i;
+}
+
+struct dlist *dlist_nth(struct dlist *l, int nth)
+{
+ register int i;
+ struct dlist *n;
+
+ i = 0;
+ for (n = l; n; n = n->next) {
+ if (i == nth) {
+ return n;
+ }
+ i++;
+ }
+
+ return NULL;
+}
+
+/* End of a file */
diff --git a/dynamicbox_viewer/src/dynamicbox.c b/dynamicbox_viewer/src/dynamicbox.c
new file mode 100644
index 0000000..4526e28
--- /dev/null
+++ b/dynamicbox_viewer/src/dynamicbox.c
@@ -0,0 +1,4115 @@
+/*
+ * Copyright 2014 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 <stdio.h>
+#include <errno.h>
+#include <stdlib.h> /* malloc */
+#include <string.h> /* strdup */
+#include <math.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <gio/gio.h>
+#include <aul.h>
+#include <dlog.h>
+
+#include <com-core_packet.h>
+#include <packet.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_cmd_list.h>
+#include <dynamicbox_buffer.h>
+
+#include "debug.h"
+#include "fb.h"
+#include "dynamicbox.h"
+#include "dynamicbox_internal.h"
+#include "dlist.h"
+#include "util.h"
+#include "master_rpc.h"
+#include "client.h"
+#include "conf.h"
+
+#define EAPI __attribute__((visibility("default")))
+
+#if defined(FLOG)
+FILE *__file_log_fp;
+#endif
+
+static int default_launch_handler(dynamicbox_h handler, const char *appid, void *data);
+
+static struct info {
+ int init_count;
+ int prevent_overwrite;
+ guint job_timer;
+ struct dlist *job_list;
+
+ struct launch {
+ int (*handler)(dynamicbox_h handler, const char *appid, void *data);
+ void *data;
+ } launch;
+} s_info = {
+ .init_count = 0,
+ .prevent_overwrite = 0,
+ .job_timer = 0,
+ .job_list = NULL,
+ .launch = {
+ .handler = default_launch_handler,
+ .data = NULL,
+ },
+};
+
+static void dbox_pixmap_acquired_cb(dynamicbox_h handler, const struct packet *result, void *data);
+static void gbar_pixmap_acquired_cb(dynamicbox_h handler, const struct packet *result, void *data);
+static void gbar_xpixmap_acquired_cb(dynamicbox_h handler, const struct packet *result, void *data);
+static void dbox_xpixmap_acquired_cb(dynamicbox_h handler, const struct packet *result, void *data);
+
+static int default_launch_handler(dynamicbox_h handler, const char *appid, void *data)
+{
+ int ret;
+
+ ret = aul_launch_app(appid, NULL);
+ if (ret <= 0) {
+ ErrPrint("Failed to launch an app %s (%d)\n", appid, ret);
+ }
+
+ /*
+ app_control_h service;
+
+ DbgPrint("AUTO_LAUNCH [%s]\n", handler->common->dbox.auto_launch);
+
+ ret = app_control_create(&service);
+ if (ret == APP_CONTROL_ERROR_NONE) {
+ app_control_set_package(service, handler->common->dbox.auto_launch);
+ app_control_send_launch_request(service, NULL, NULL);
+ app_control_destroy(service);
+ } else {
+ ErrPrint("Failed to launch an app %s (%d)\n", handler->common->dbox.auto_launch, ret);
+ }
+ */
+
+ return ret > 0 ? DBOX_STATUS_ERROR_NONE : DBOX_STATUS_ERROR_FAULT;
+}
+
+static inline void default_create_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default created event handler: %d\n", ret);
+}
+
+static inline void default_pinup_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default pinup event handler: %d\n", ret);
+}
+
+static inline void default_group_changed_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default group changed event handler: %d\n", ret);
+}
+
+static inline void default_period_changed_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default period changed event handler: %d\n", ret);
+}
+
+static inline void default_gbar_created_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default GBAR created event handler: %d\n", ret);
+}
+
+static inline void default_gbar_destroyed_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default GBAR destroyed event handler: %d\n", ret);
+}
+
+static inline void default_dbox_size_changed_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default DBOX size changed event handler: %d\n", ret);
+}
+
+static inline void default_update_mode_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default update mode set event handler: %d\n", ret);
+}
+
+static inline void default_access_event_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default access event handler: %d\n", ret);
+}
+
+static inline void default_key_event_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default key event handler: %d\n", ret);
+}
+
+static void update_mode_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto errout;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ErrPrint("Invalid argument\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto errout;
+ }
+
+ if (ret < 0) {
+ ErrPrint("Resize request is failed: %d\n", ret);
+ goto errout;
+ }
+
+ return;
+
+errout:
+ handler->cbs.update_mode.cb(handler, ret, handler->cbs.update_mode.data);
+ handler->cbs.update_mode.cb = NULL;
+ handler->cbs.update_mode.data = NULL;
+ handler->common->request.update_mode = 0;
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+}
+
+static void resize_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto errout;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ErrPrint("Invalid argument\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto errout;
+ }
+
+ /*!
+ * \note
+ * In case of resize request,
+ * The dynamicbox handler will not have resized value right after this callback,
+ * It can only get the new size when it makes updates.
+ *
+ * So the user can only get the resized value(result) from the first update event
+ * after this request.
+ */
+ if (ret < 0) {
+ ErrPrint("Resize request is failed: %d\n", ret);
+ goto errout;
+ }
+
+ return;
+
+errout:
+ handler->cbs.size_changed.cb(handler, ret, handler->cbs.size_changed.data);
+ handler->cbs.size_changed.cb = NULL;
+ handler->cbs.size_changed.data = NULL;
+ handler->common->request.size_changed = 0;
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+}
+
+static void text_signal_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+ void *cbdata;
+ struct cb_info *info = data;
+ dynamicbox_ret_cb cb;
+
+ cbdata = info->data;
+ cb = info->cb;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ErrPrint("Invalid argument\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (cb) {
+ cb(handler, ret, cbdata);
+ }
+ return;
+}
+
+static void set_group_ret_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto errout;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ErrPrint("Invalid argument\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto errout;
+ }
+
+ if (ret < 0) {
+ goto errout;
+ }
+
+ return;
+
+errout:
+ handler->cbs.group_changed.cb(handler, ret, handler->cbs.group_changed.data);
+ handler->cbs.group_changed.cb = NULL;
+ handler->cbs.group_changed.data = NULL;
+ handler->common->request.group_changed = 0;
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+}
+
+static void period_ret_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto errout;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ErrPrint("Invalid argument\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto errout;
+ }
+
+ if (ret < 0) {
+ goto errout;
+ }
+
+ return;
+
+errout:
+ handler->cbs.period_changed.cb(handler, ret, handler->cbs.period_changed.data);
+ handler->cbs.period_changed.cb = NULL;
+ handler->cbs.period_changed.data = NULL;
+ handler->common->request.period_changed = 0;
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+}
+
+static void gbar_create_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto errout;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto errout;
+ }
+
+ if (ret < 0) {
+ ErrPrint("Failed to create a GBAR[%d]\n", ret);
+ goto errout;
+ }
+
+ return;
+
+errout:
+ handler->cbs.gbar_created.cb(handler, ret, handler->cbs.gbar_created.data);
+ handler->cbs.gbar_created.cb = NULL;
+ handler->cbs.gbar_created.data = NULL;
+ handler->common->request.gbar_created = 0;
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+}
+
+static void activated_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+ struct cb_info *info = data;
+ void *cbdata;
+ dynamicbox_ret_cb cb;
+ const char *pkgname = "";
+
+ cbdata = info->data;
+ cb = info->cb;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else if (packet_get(result, "is", &ret, &pkgname) != 2) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (cb) {
+ cb(handler, ret, cbdata);
+ }
+}
+
+static void gbar_destroy_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+ struct cb_info *info = data;
+
+ cbdata = info->data;
+ cb = info->cb;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ ErrPrint("Result is NIL (may connection lost)\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ErrPrint("Invalid parameter\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ handler->cbs.gbar_destroyed.cb = cb;
+ handler->cbs.gbar_destroyed.data = cbdata;
+ } else {
+ handler->common->is_gbar_created = 0;
+ handler->common->request.gbar_destroyed = 0;
+
+ if (cb) {
+ cb(handler, ret, cbdata);
+ }
+ }
+}
+
+static void delete_cluster_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ struct cb_info *info = data;
+ int ret;
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = info->cb;
+ cbdata = info->data;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (cb) {
+ cb(handler, ret, cbdata);
+ }
+}
+
+static void delete_category_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ struct cb_info *info = data;
+ int ret;
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = info->cb;
+ cbdata = info->data;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (cb) {
+ cb(handler, ret, cbdata);
+ }
+}
+
+static int dbox_acquire_dbox_pixmap(dynamicbox_h handler, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ struct cb_info *cbinfo;
+ const char *id;
+ unsigned int cmd = CMD_DBOX_ACQUIRE_PIXMAP;
+ int ret;
+
+ id = fb_id(handler->common->dbox.fb);
+ if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet = packet_create((const char *)&cmd, "ss", handler->common->pkgname, handler->common->id);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, dbox_pixmap_acquired_cb, cbinfo);
+ if (ret < 0) {
+ dbox_destroy_cb_info(cbinfo);
+ }
+
+ return ret;
+}
+
+static void dbox_pixmap_acquired_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int pixmap;
+ int ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+ struct cb_info *info = data;
+
+ cb = info->cb;
+ cbdata = info->data;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ pixmap = 0; /* PIXMAP 0 means error */
+ } else if (packet_get(result, "ii", &pixmap, &ret) != 2) {
+ pixmap = 0;
+ }
+
+ if (ret == (int)DBOX_STATUS_ERROR_BUSY) {
+ ret = dbox_acquire_dbox_pixmap(handler, cb, cbdata);
+ DbgPrint("Busy, Try again: %d\n", ret);
+ /* Try again */
+ } else if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ if (cb) {
+ cb(handler, pixmap, cbdata);
+ }
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ } else {
+ if (cb) {
+ cb(handler, pixmap, cbdata);
+ }
+ }
+}
+
+static void dbox_xpixmap_acquired_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int pixmap;
+ int ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+ struct cb_info *info = data;
+
+ cb = info->cb;
+ cbdata = info->data;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ pixmap = 0;
+ } else if (packet_get(result, "ii", &pixmap, &ret) != 2) {
+ pixmap = 0;
+ }
+
+ if (cb) {
+ cb(handler, pixmap, cbdata);
+ }
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+}
+
+static int dbox_acquire_gbar_extra_pixmap(dynamicbox_h handler, int idx, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ struct cb_info *cbinfo;
+ unsigned int cmd = CMD_GBAR_ACQUIRE_XPIXMAP;
+ int ret;
+
+ packet = packet_create((const char *)&cmd, "ssi", handler->common->pkgname, handler->common->id, idx);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, gbar_xpixmap_acquired_cb, cbinfo);
+ if (ret < 0) {
+ /*!
+ * \note
+ * Packet will be destroyed by master_rpc_async_request
+ */
+ dbox_destroy_cb_info(cbinfo);
+ }
+
+ return ret;
+}
+
+static int dbox_acquire_dbox_extra_pixmap(dynamicbox_h handler, int idx, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ struct cb_info *cbinfo;
+ unsigned int cmd = CMD_DBOX_ACQUIRE_XPIXMAP;
+ int ret;
+
+ packet = packet_create((const char *)&cmd, "ssi", handler->common->pkgname, handler->common->id, idx);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, dbox_xpixmap_acquired_cb, cbinfo);
+ if (ret < 0) {
+ /*!
+ * \note
+ * Packet will be destroyed by master_rpc_async_request
+ */
+ dbox_destroy_cb_info(cbinfo);
+ }
+
+ return ret;
+}
+
+static int dbox_acquire_gbar_pixmap(dynamicbox_h handler, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ struct cb_info *cbinfo;
+ unsigned int cmd = CMD_GBAR_ACQUIRE_PIXMAP;
+ const char *id;
+ int ret;
+
+ id = fb_id(handler->common->gbar.fb);
+ if (!id || strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet = packet_create((const char *)&cmd, "ss", handler->common->pkgname, handler->common->id);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, gbar_pixmap_acquired_cb, cbinfo);
+ if (ret < 0) {
+ /*!
+ * \note
+ * Packet will be destroyed by master_rpc_async_request
+ */
+ dbox_destroy_cb_info(cbinfo);
+ }
+
+ return ret;
+}
+
+static void gbar_xpixmap_acquired_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int pixmap;
+ int ret;
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+ struct cb_info *info = data;
+
+ cb = info->cb;
+ cbdata = info->data;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ pixmap = 0; /* PIXMAP 0 means error */
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else if (packet_get(result, "ii", &pixmap, &ret) != 2) {
+ pixmap = 0;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (cb) {
+ DbgPrint("ret: %x, pixmap: %d\n", ret, pixmap);
+ cb(handler, pixmap, cbdata);
+ }
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+}
+
+static void gbar_pixmap_acquired_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int pixmap;
+ int ret;
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+ struct cb_info *info = data;
+
+ cb = info->cb;
+ cbdata = info->data;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ pixmap = 0; /* PIXMAP 0 means error */
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else if (packet_get(result, "ii", &pixmap, &ret) != 2) {
+ pixmap = 0;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (ret == (int)DBOX_STATUS_ERROR_BUSY) {
+ ret = dbox_acquire_gbar_pixmap(handler, cb, cbdata);
+ DbgPrint("Busy, Try again: %d\n", ret);
+ /* Try again */
+ } else if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ if (cb) {
+ cb(handler, pixmap, cbdata);
+ }
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ } else {
+ if (cb) {
+ DbgPrint("ret: %d, pixmap: %d\n", ret, pixmap);
+ cb(handler, pixmap, cbdata);
+ }
+ }
+}
+
+static void pinup_done_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto errout;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ goto errout;
+ }
+
+ if (ret < 0) {
+ goto errout;
+ }
+
+ return;
+
+errout:
+ handler->cbs.pinup.cb(handler, ret, handler->cbs.pinup.data);
+ handler->cbs.pinup.cb = NULL;
+ handler->cbs.pinup.data = NULL;
+ handler->common->request.pinup = 0;
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+}
+
+static void key_ret_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ return;
+ }
+
+ if (packet_get(result, "i", &ret) != 1) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ return;
+ }
+
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto errout;
+ }
+
+ return;
+errout:
+ handler->cbs.key_event.cb(handler, ret, handler->cbs.key_event.data);
+ handler->cbs.key_event.cb = NULL;
+ handler->cbs.key_event.data = NULL;
+ handler->common->request.key_event = 0;
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+}
+
+static void access_ret_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ return;
+ }
+
+ if (packet_get(result, "i", &ret) != 1) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ return;
+ }
+
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto errout;
+ }
+
+ return;
+
+errout:
+ handler->cbs.access_event.cb(handler, ret, handler->cbs.access_event.data);
+ handler->cbs.access_event.cb = NULL;
+ handler->cbs.access_event.data = NULL;
+ handler->common->request.access_event = 0;
+
+ if (handler->common->state != DBOX_STATE_DELETE) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST && handler->refcnt == 2) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+ }
+}
+
+static int send_access_event(dynamicbox_h handler, const char *event, int x, int y, int type)
+{
+ struct packet *packet;
+ double timestamp;
+
+ timestamp = util_timestamp();
+
+ packet = packet_create(event, "ssdiii", handler->common->pkgname, handler->common->id, timestamp, x, y, type);
+ if (!packet) {
+ ErrPrint("Failed to build packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_async_request(handler, packet, 0, access_ret_cb, NULL);
+}
+
+static int send_key_event(dynamicbox_h handler, const char *event, unsigned int keycode)
+{
+ struct packet *packet;
+ double timestamp;
+
+ timestamp = util_timestamp();
+ packet = packet_create(event, "ssdi", handler->common->pkgname, handler->common->id, timestamp, keycode);
+ if (!packet) {
+ ErrPrint("Failed to build packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_async_request(handler, packet, 0, key_ret_cb, NULL);
+}
+
+static int send_mouse_event(dynamicbox_h handler, const char *event, int x, int y)
+{
+ struct packet *packet;
+ double timestamp;
+
+ timestamp = util_timestamp();
+ packet = packet_create_noack(event, "ssdii", handler->common->pkgname, handler->common->id, timestamp, x, y);
+ if (!packet) {
+ ErrPrint("Failed to build param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_request_only(handler, packet);
+}
+
+static int initialize_dynamicbox(void *disp, int use_thread)
+{
+ int ret;
+#if defined(FLOG)
+ char filename[BUFSIZ];
+ snprintf(filename, sizeof(filename), "/tmp/%d.box.log", getpid());
+ __file_log_fp = fopen(filename, "w+t");
+ if (!__file_log_fp) {
+ __file_log_fp = fdopen(1, "w+t");
+ }
+#endif
+ ret = dynamicbox_service_init();
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ return ret;
+ }
+
+ ret = fb_init(disp);
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ dynamicbox_service_fini();
+ return ret;
+ }
+
+ ret = client_init(use_thread);
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ fb_fini();
+ dynamicbox_service_fini();
+ return ret;
+ }
+
+ s_info.init_count++;
+ return ret;
+}
+
+static inline char *dbox_pkgname(const char *pkgname)
+{
+ char *dbox;
+
+ dbox = dynamicbox_service_dbox_id(pkgname);
+ if (!dbox) {
+ dbox = strdup(pkgname);
+ }
+
+ return dbox;
+}
+
+static gboolean job_execute_cb(void *data)
+{
+ struct job_item *item;
+ struct dlist *l;
+
+ l = dlist_nth(s_info.job_list, 0);
+ if (!l) {
+ s_info.job_timer = 0;
+ return FALSE;
+ }
+
+ item = dlist_data(l);
+ s_info.job_list = dlist_remove(s_info.job_list, l);
+
+ if (item) {
+ item->cb(item->handle, item->ret, item->data);
+ dbox_unref(item->handle, 1);
+ free(item);
+ }
+
+ return TRUE;
+}
+
+static int job_add(dynamicbox_h handle, dynamicbox_ret_cb job_cb, int ret, void *data)
+{
+ struct job_item *item;
+
+ if (!job_cb) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ item = malloc(sizeof(*item));
+ if (!item) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ item->handle = dbox_ref(handle);
+ item->cb = job_cb;
+ item->data = data;
+ item->ret = ret;
+
+ s_info.job_list = dlist_append(s_info.job_list, item);
+
+ if (!s_info.job_timer) {
+ s_info.job_timer = g_timeout_add(1, job_execute_cb, NULL);
+ if (!s_info.job_timer) {
+ ErrPrint("Failed to create a job timer\n");
+ }
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+static void new_ret_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ int ret;
+ struct cb_info *info = data;
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = info->cb;
+ cbdata = info->data;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (ret >= 0) {
+ handler->cbs.created.cb = cb;
+ handler->cbs.created.data = cbdata;
+
+ /*!
+ * \note
+ * Don't go anymore ;)
+ */
+ return;
+ } else if (cb) {
+ /*!
+ * \note
+ * It means the current instance is not created,
+ * so user has to know about this.
+ * notice it to user using "deleted" event.
+ */
+ cb(handler, ret, cbdata);
+ }
+
+ dbox_unref(handler, 1);
+}
+
+static int create_real_instance(dynamicbox_h handler, dynamicbox_ret_cb cb, void *data)
+{
+ struct cb_info *cbinfo;
+ struct packet *packet;
+ struct dynamicbox_common *common;
+ unsigned int cmd = CMD_NEW;
+ int ret;
+
+ common = handler->common;
+
+ packet = packet_create((const char *)&cmd, "dssssdii",
+ common->timestamp, common->pkgname, common->content,
+ common->cluster, common->category,
+ common->dbox.period, common->dbox.width, common->dbox.height);
+ if (!packet) {
+ ErrPrint("Failed to create a new packet\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_FAULT);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ ErrPrint("Failed to create a cbinfo\n");
+ packet_destroy(packet);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_OUT_OF_MEMORY);
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ /*!
+ * \note
+ * master_rpc_async_request will destroy the packet (decrease the refcnt)
+ * So be aware the packet object after return from master_rpc_async_request.
+ */
+ ret = master_rpc_async_request(handler, packet, 0, new_ret_cb, cbinfo);
+ if (ret < 0) {
+ ErrPrint("Failed to send a new packet\n");
+ dbox_destroy_cb_info(cbinfo);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_FAULT);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+ handler->common->request.created = 1;
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+static void create_cb(dynamicbox_h handle, int ret, void *data)
+{
+ struct cb_info *cbinfo = data;
+
+ if (cbinfo->cb) {
+ cbinfo->cb(handle, ret, cbinfo->data);
+ }
+
+ dbox_destroy_cb_info(cbinfo);
+
+ /*!
+ * \note
+ * Forcely generate "updated" event
+ */
+ dbox_invoke_event_handler(handle, DBOX_EVENT_DBOX_UPDATED);
+}
+
+static int create_fake_instance(dynamicbox_h handler, dynamicbox_ret_cb cb, void *data)
+{
+ struct cb_info *cbinfo;
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ ErrPrint("Failed to create a cbinfo\n");
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (job_add(handler, create_cb, DBOX_STATUS_ERROR_NONE, cbinfo) != DBOX_STATUS_ERROR_NONE) {
+ dbox_destroy_cb_info(cbinfo);
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+static void refresh_for_paused_updating_cb(dynamicbox_h handle, int ret, void *data)
+{
+ if (handle->paused_updating == 0) {
+ DbgPrint("Paused updates are cleared\n");
+ return;
+ }
+
+ DbgPrint("Pending updates are found\n");
+ dbox_invoke_event_handler(handle, DBOX_EVENT_DBOX_UPDATED);
+}
+
+static int dbox_set_visibility(dynamicbox_h handler, dynamicbox_visible_state_e state)
+{
+ struct packet *packet;
+ int need_to_add_job = 0;
+ unsigned int cmd = CMD_CHANGE_VISIBILITY;
+ int ret;
+
+ if (handler->common->visible != DBOX_SHOW && state == DBOX_SHOW) {
+ need_to_add_job = !!handler->paused_updating;
+ } else if (handler->common->visible == DBOX_SHOW && state != DBOX_SHOW) {
+ if (!!dbox_find_dbox_in_show(handler->common)) {
+ return DBOX_STATUS_ERROR_NONE;
+ }
+ } else if (handler->common->visible == DBOX_SHOW && state == DBOX_SHOW && handler->paused_updating) {
+ if (job_add(handler, refresh_for_paused_updating_cb, DBOX_STATUS_ERROR_NONE, NULL) < 0) {
+ ErrPrint("Unable to add a new job for refreshing box\n");
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+ } else {
+ /*!
+ * \brief
+ * No need to send this to the master
+ */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ packet = packet_create_noack((const char *)&cmd, "ssi", handler->common->pkgname, handler->common->id, (int)state);
+ if (!packet) {
+ ErrPrint("Failed to create a packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_request_only(handler, packet);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ DbgPrint("[%s] visibility is changed 0x[%x]\n", handler->common->pkgname, state);
+ handler->common->visible = state;
+
+ if (need_to_add_job) {
+ if (job_add(handler, refresh_for_paused_updating_cb, DBOX_STATUS_ERROR_NONE, NULL) < 0) {
+ ErrPrint("Unable to add a new job for refreshing box\n");
+ }
+ }
+ }
+
+ return ret;
+}
+
+static void dbox_update_visibility(struct dynamicbox_common *old_common)
+{
+ dynamicbox_h item;
+
+ item = dbox_find_dbox_in_show(old_common);
+ if (!item) {
+ item = dbox_get_dbox_nth(old_common, 0);
+ if (item) {
+ dbox_set_visibility(item, DBOX_HIDE_WITH_PAUSE);
+ } else {
+ ErrPrint("Unable to get the valid handle from common handler\n");
+ }
+ } else {
+ dbox_set_visibility(item, DBOX_SHOW);
+ }
+}
+
+/*!
+ * \note
+ * The second parameter should be the "return value",
+ * But in this case, we will use it for "type of deleting instance".
+ */
+static void job_del_cb(dynamicbox_h handle, int type, void *data)
+{
+ struct cb_info *cbinfo = data;
+ dynamicbox_ret_cb cb;
+
+ if (handle->visible == DBOX_SHOW) {
+ dbox_update_visibility(handle->common);
+ }
+
+ cb = cbinfo->cb;
+ data = cbinfo->data;
+ dbox_destroy_cb_info(cbinfo);
+
+ if (handle->common->state != DBOX_STATE_CREATE) {
+ DbgPrint("[%s] %d\n", handle->common->pkgname, handle->refcnt);
+ if (cb) {
+ cb(handle, DBOX_STATUS_ERROR_NONE, data);
+ }
+
+ return;
+ }
+
+ if (handle->common->refcnt == 1) {
+ handle->common->delete_type = type;
+ handle->common->state = DBOX_STATE_DELETE;
+
+ if (!handle->common->id) {
+ /*!
+ * \note
+ * The id is not determined yet.
+ * It means a user didn't receive created event yet.
+ * Then just stop to delete procedure from here.
+ * Because the "created" event handle will release this.
+ * By the way, if the user adds any callback for getting return status of this,
+ * call it at here.
+ */
+ if (cb) {
+ cb(handle, DBOX_STATUS_ERROR_NONE, data);
+ }
+ }
+
+ DbgPrint("Send delete request\n");
+ dbox_send_delete(handle, type, cb, data);
+ } else {
+ if (cb) {
+ cb(handle, DBOX_STATUS_ERROR_NONE, data);
+ }
+
+ DbgPrint("Before unref: %d\n", handle->common->refcnt);
+ dbox_unref(handle, 1);
+ }
+}
+
+static void resize_job_cb(dynamicbox_h handler, int ret, void *data)
+{
+ struct cb_info *info = data;
+
+ if (info->cb) {
+ info->cb(handler, ret, info->data);
+ }
+
+ free(info);
+
+ /*!
+ * \note
+ * Forcely update the box
+ */
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DBOX_UPDATED);
+}
+
+static void turn_off_gbar_destroyed_flag_cb(dynamicbox_h handler, int ret, void *data)
+{
+ if (handler->common->request.gbar_destroyed) {
+ dynamicbox_ret_cb cb;
+ void *data;
+
+ DbgPrint("gbar_destroyed request is canceled\n");
+ handler->common->request.gbar_destroyed = 0;
+ cb = handler->cbs.gbar_destroyed.cb;
+ data = handler->cbs.gbar_destroyed.data;
+ handler->cbs.gbar_destroyed.cb = NULL;
+ handler->cbs.gbar_destroyed.data = NULL;
+
+ if (cb) {
+ cb(handler, ret, data);
+ }
+ }
+}
+
+static void turn_off_gbar_created_flag_cb(dynamicbox_h handler, int ret, void *data)
+{
+ if (handler->common->request.gbar_created) {
+ dynamicbox_ret_cb cb;
+ void *data;
+
+ DbgPrint("gbar_created request is canceled\n");
+ handler->common->request.gbar_created = 0;
+ cb = handler->cbs.gbar_created.cb;
+ data = handler->cbs.gbar_created.data;
+ handler->cbs.gbar_created.cb = NULL;
+ handler->cbs.gbar_created.data = NULL;
+
+ if (cb) {
+ cb(handler, ret, data);
+ }
+ }
+}
+
+EAPI int dynamicbox_init(void *disp, int prevent_overwrite, double event_filter, int use_thread)
+{
+ if (s_info.init_count > 0) {
+ s_info.init_count++;
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ /*!
+ * \note
+ * Some application doesn't want to use the environment value.
+ * So set them using arguments.
+ */
+ s_info.prevent_overwrite = prevent_overwrite;
+ conf_set_event_filter(event_filter);
+
+ return initialize_dynamicbox(disp, use_thread);
+}
+
+EAPI int dynamicbox_fini(void)
+{
+ if (s_info.init_count <= 0) {
+ ErrPrint("Doesn't initialized\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ s_info.init_count--;
+ if (s_info.init_count > 0) {
+ ErrPrint("init count : %d\n", s_info.init_count);
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ client_fini();
+ fb_fini();
+ dynamicbox_service_fini();
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+EAPI dynamicbox_h dynamicbox_add(const char *pkgname, const char *content, const char *cluster, const char *category, double period, dynamicbox_size_type_e type, dynamicbox_ret_cb cb, void *data)
+{
+ char *dboxid;
+ dynamicbox_h handler;
+ int w = 0;
+ int h = 0;
+
+ if (!pkgname || !cluster || !category) {
+ ErrPrint("Invalid arguments: pkgname[%p], cluster[%p], category[%p]\n",
+ pkgname, cluster, category);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ dboxid = dbox_pkgname(pkgname);
+ if (!dboxid) {
+ ErrPrint("Invalid package: %s\n", pkgname);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (dynamicbox_service_is_enabled(dboxid) == 0) {
+ DbgPrint("Livebox [%s](%s) is disabled package\n", dboxid, pkgname);
+ free(dboxid);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_DISABLED);
+ return NULL;
+ }
+
+ if (type != DBOX_SIZE_TYPE_UNKNOWN) {
+ (void)dynamicbox_service_get_size(type, &w, &h);
+ }
+
+ handler = calloc(1, sizeof(*handler));
+ if (!handler) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ free(dboxid);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ if (!cb) {
+ cb = default_create_cb;
+ }
+
+ handler->common = dbox_find_sharable_common_handle(dboxid, content, w, h, cluster, category);
+ if (!handler->common) {
+ handler->common = dbox_create_common_handle(handler, dboxid, cluster, category);
+ free(dboxid);
+ if (!handler->common) {
+ ErrPrint("Failed to find common handle\n");
+ free(handler);
+ return NULL;
+ }
+
+ if (!content || !strlen(content)) {
+ char *pc;
+ /**
+ * @note
+ * I know the content should not be modified. use it temporarly without "const"
+ */
+ pc = dynamicbox_service_content(handler->common->pkgname);
+ dbox_set_content(handler->common, pc);
+ free(pc);
+ } else {
+ dbox_set_content(handler->common, content);
+ }
+
+ dbox_set_period(handler->common, period);
+ dbox_set_size(handler->common, w, h);
+ dbox_common_ref(handler->common, handler);
+
+ if (create_real_instance(handler, cb, data) < 0) {
+ if (dbox_common_unref(handler->common, handler) == 0) {
+ /*!
+ * Delete common
+ */
+ dbox_destroy_common_handle(handler->common);
+ handler->common = NULL;
+ }
+ free(handler);
+ return NULL;
+ }
+ } else {
+ free(dboxid);
+
+ dbox_common_ref(handler->common, handler);
+
+ if (handler->common->request.created) {
+ /*!
+ * If a box is in creating, wait its result too
+ */
+ handler->cbs.created.cb = cb;
+ handler->cbs.created.data = data;
+ } else {
+ /*!
+ * or fire the fake created_event
+ */
+ if (create_fake_instance(handler, cb, data) < 0) {
+ if (dbox_common_unref(handler->common, handler) == 0) {
+ /*!
+ * Delete common
+ */
+ dbox_destroy_common_handle(handler->common);
+ }
+ free(handler);
+ return NULL;
+ }
+ }
+ }
+
+ handler->visible = DBOX_SHOW;
+ handler->state = DBOX_STATE_CREATE;
+ handler = dbox_ref(handler);
+
+ if (handler->common->visible != DBOX_SHOW) {
+ dbox_set_visibility(handler, DBOX_SHOW);
+ }
+
+ return handler;
+}
+
+EAPI double dynamicbox_period(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return -1.0f;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return -1.0f;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Hnalder is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return -1.0f;
+ }
+
+ return handler->common->dbox.period;
+}
+
+EAPI int dynamicbox_set_period(dynamicbox_h handler, double period, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_SET_PERIOD;
+ int ret;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->common->request.period_changed) {
+ ErrPrint("Previous request for changing period is not finished\n");
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+
+ if (!handler->common->is_user) {
+ ErrPrint("CA Livebox is not able to change the period\n");
+ return DBOX_STATUS_ERROR_PERMISSION_DENIED;
+ }
+
+ if (handler->common->dbox.period == period) {
+ DbgPrint("No changes\n");
+ return DBOX_STATUS_ERROR_ALREADY;
+ }
+
+ packet = packet_create((const char *)&cmd, "ssd", handler->common->pkgname, handler->common->id, period);
+ if (!packet) {
+ ErrPrint("Failed to build a packet %s\n", handler->common->pkgname);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ if (!cb) {
+ cb = default_period_changed_cb;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, period_ret_cb, NULL);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ handler->cbs.period_changed.cb = cb;
+ handler->cbs.period_changed.data = data;
+ handler->common->request.period_changed = 1;
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_del(dynamicbox_h handler, dynamicbox_delete_type_e type, dynamicbox_ret_cb cb, void *data)
+{
+ struct cb_info *cbinfo;
+
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is already deleted\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ handler->state = DBOX_STATE_DELETE;
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ ErrPrint("Failed to create a cbinfo\n");
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (job_add(handler, job_del_cb, type, cbinfo) != DBOX_STATUS_ERROR_NONE) {
+ ErrPrint("Failed to add a new job\n");
+ dbox_destroy_cb_info(cbinfo);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+EAPI int dynamicbox_add_fault_handler(dynamicbox_fault_handler_cb dbox_cb, void *data)
+{
+ if (!dbox_cb) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return dbox_add_fault_handler(dbox_cb, data);
+}
+
+EAPI void *dynamicbox_remove_fault_handler(dynamicbox_fault_handler_cb dbox_cb)
+{
+ if (!dbox_cb) {
+ return NULL;
+ }
+
+ return dbox_remove_fault_handler(dbox_cb);
+}
+
+EAPI int dynamicbox_add_event_handler(dynamicbox_event_handler_cb dbox_cb, void *data)
+{
+ if (!dbox_cb) {
+ ErrPrint("Invalid argument dbox_cb is nil\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return dbox_add_event_handler(dbox_cb, data);
+}
+
+EAPI void *dynamicbox_remove_event_handler(dynamicbox_event_handler_cb dbox_cb)
+{
+ if (!dbox_cb) {
+ return NULL;
+ }
+
+ return dbox_remove_event_handler(dbox_cb);
+}
+
+EAPI int dynamicbox_set_update_mode(dynamicbox_h handler, int active_update, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_UPDATE_MODE;
+ int ret;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is Invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is Invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is Invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->common->request.update_mode) {
+ ErrPrint("Previous update_mode cb is not finished yet\n");
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+
+ if (handler->common->is_active_update == active_update) {
+ return DBOX_STATUS_ERROR_ALREADY;
+ }
+
+ if (!handler->common->is_user) {
+ return DBOX_STATUS_ERROR_PERMISSION_DENIED;
+ }
+
+ packet = packet_create((const char *)&cmd, "ssi", handler->common->pkgname, handler->common->id, active_update);
+ if (!packet) {
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ if (!cb) {
+ cb = default_update_mode_cb;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, update_mode_cb, NULL);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ handler->cbs.update_mode.cb = cb;
+ handler->cbs.update_mode.data = data;
+ handler->common->request.update_mode = 1;
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_is_active_update(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is Invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is Invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return handler->common->is_active_update;
+}
+
+EAPI int dynamicbox_resize(dynamicbox_h handler, dynamicbox_size_type_e type, dynamicbox_ret_cb cb, void *data)
+{
+ struct dynamicbox_common *common;
+ int w;
+ int h;
+ int ret;
+
+ /*!
+ * \TODO
+ * If this handle is host instance or link instance,
+ * Create a new instance or find another linkable instance.
+ */
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ /*!
+ * \note
+ * resize operation should be separated by each handler.
+ * If a handler is resizing, the other handler can request resize too.
+ * So we should not use the common->request.size_changed flag.
+ */
+ if (handler->cbs.size_changed.cb) {
+ ErrPrint("Previous resize request is not finished yet\n");
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+
+ if (dynamicbox_service_get_size(type, &w, &h) != 0) {
+ ErrPrint("Invalid size type\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->common->dbox.width == w && handler->common->dbox.height == h) {
+ DbgPrint("No changes\n");
+ return DBOX_STATUS_ERROR_ALREADY;
+ }
+
+ if (!handler->common->is_user) {
+ ErrPrint("CA Livebox is not able to be resized\n");
+ return DBOX_STATUS_ERROR_PERMISSION_DENIED;
+ }
+
+ if (handler->common->refcnt <= 1) {
+ struct packet *packet;
+ unsigned int cmd = CMD_RESIZE;
+
+ /* Only 1 instance */
+ packet = packet_create((const char *)&cmd, "ssii", handler->common->pkgname, handler->common->id, w, h);
+ if (!packet) {
+ ErrPrint("Failed to build param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ if (!cb) {
+ cb = default_dbox_size_changed_cb;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, resize_cb, NULL);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ handler->cbs.size_changed.cb = cb;
+ handler->cbs.size_changed.data = data;
+ handler->common->request.size_changed = 1;
+ }
+ } else {
+ common = dbox_find_sharable_common_handle(handler->common->pkgname, handler->common->content, w, h, handler->common->cluster, handler->common->category);
+ if (!common) {
+ struct dynamicbox_common *old_common;
+ /*!
+ * \note
+ * If the common handler is in resizing,
+ * if user tries to resize a hander, then simply create new one even if the requested size is same with this.
+
+ if (handler->common->request.size_changed) {
+ }
+
+ */
+
+ old_common = handler->common;
+
+ common = dbox_create_common_handle(handler, old_common->pkgname, old_common->cluster, old_common->category);
+ if (!common) {
+ ErrPrint("Failed to create common handle\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ dbox_set_size(common, w, h);
+ dbox_set_content(common, old_common->content);
+ dbox_set_period(common, old_common->dbox.period);
+
+ /*!
+ * \note
+ * Disconnecting from old one.
+ */
+ if (dbox_common_unref(old_common, handler) == 0) {
+ /*!
+ * \note
+ * Impossible
+ */
+ ErrPrint("Common has no associated handler\n");
+ }
+
+ dbox_common_ref(common, handler);
+
+ /*!
+ * Connect to a new one
+ */
+ handler->common = common;
+
+ /*!
+ * \TODO
+ * Need to care, if it fails to create a common handle,
+ * the resize operation will be failed.
+ * in that case, we should reuse the old common handle
+ */
+ ret = create_real_instance(handler, cb, data);
+ if (ret < 0) {
+ dbox_common_unref(common, handler);
+ dbox_destroy_common_handle(common);
+
+ dbox_common_ref(old_common, handler);
+ handler->common = old_common;
+ } else {
+ /*!
+ * In this case, we should update visibility of old_common's dynamicboxes
+ */
+ if (handler->visible == DBOX_SHOW) {
+ dbox_update_visibility(old_common);
+ }
+ }
+ } else {
+ struct cb_info *cbinfo;
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ ErrPrint("Failed to create a cbinfo\n");
+ ret = DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ } else {
+ ret = job_add(handler, resize_job_cb, DBOX_STATUS_ERROR_NONE, cbinfo);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ struct dynamicbox_common *old_common;
+
+ old_common = handler->common;
+
+ if (dbox_common_unref(handler->common, handler) == 0) {
+ ErrPrint("Old common has no associated handler\n");
+ }
+
+ dbox_common_ref(common, handler);
+ handler->common = common;
+
+ if (handler->visible == DBOX_SHOW) {
+ dbox_update_visibility(old_common); /* To update visibility: Show --> Paused */
+ dbox_update_visibility(common); /* To update visibility: Paused --> Show */
+ }
+ } else {
+ dbox_destroy_cb_info(cbinfo);
+ }
+ }
+ }
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_click(dynamicbox_h handler, double x, double y)
+{
+ struct packet *packet;
+ double timestamp;
+ unsigned int cmd = CMD_CLICKED;
+ int ret;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->common->dbox.auto_launch) {
+ if (s_info.launch.handler) {
+ ret = s_info.launch.handler(handler, handler->common->dbox.auto_launch, s_info.launch.data);
+ if (ret < 0) {
+ ErrPrint("launch handler app %s (%d)\n", handler->common->dbox.auto_launch, ret);
+ }
+ }
+ }
+
+ timestamp = util_timestamp();
+ DbgPrint("CLICKED: %lf\n", timestamp);
+
+ packet = packet_create_noack((const char *)&cmd, "sssddd", handler->common->pkgname, handler->common->id, "clicked", timestamp, x, y);
+ if (!packet) {
+ ErrPrint("Failed to build param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_request_only(handler, packet);
+ return ret;
+}
+
+EAPI int dynamicbox_has_glance_bar(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return !!handler->common->gbar.fb;
+}
+
+EAPI int dynamicbox_glance_bar_is_created(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->gbar.fb || !handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return handler->common->is_gbar_created;
+}
+
+EAPI int dynamicbox_create_glance_bar(dynamicbox_h handler, double x, double y, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_CREATE_GBAR;
+ int ret;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->gbar.fb || !handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ /*!
+ * \note
+ * Only one handler can have a GBAR
+ */
+ if (handler->common->is_gbar_created) {
+ DbgPrint("GBAR is already created\n");
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (handler->common->request.gbar_created) {
+ ErrPrint("Previous request is not completed yet\n");
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+
+ /*!
+ * \note
+ * Turn off the gbar_destroyed request flag
+ */
+ if (handler->common->request.gbar_destroyed) {
+ if (job_add(handler, turn_off_gbar_destroyed_flag_cb, DBOX_STATUS_ERROR_CANCEL, NULL) < 0) {
+ ErrPrint("Failed to add gbar_destroyed job\n");
+ }
+ }
+
+ packet = packet_create((const char *)&cmd, "ssdd", handler->common->pkgname, handler->common->id, x, y);
+ if (!packet) {
+ ErrPrint("Failed to build param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ if (!cb) {
+ cb = default_gbar_created_cb;
+ }
+
+ DbgPrint("PERF_DBOX\n");
+ ret = master_rpc_async_request(handler, packet, 0, gbar_create_cb, NULL);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ handler->cbs.gbar_created.cb = cb;
+ handler->cbs.gbar_created.data = data;
+ handler->common->request.gbar_created = 1;
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_move_glance_bar(dynamicbox_h handler, double x, double y)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_GBAR_MOVE;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->gbar.fb || !handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->is_gbar_created) {
+ ErrPrint("GBAR is not created\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet = packet_create_noack((const char *)&cmd, "ssdd", handler->common->pkgname, handler->common->id, x, y);
+ if (!packet) {
+ ErrPrint("Failed to build param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_request_only(handler, packet);
+}
+
+EAPI int dynamicbox_activate(const char *pkgname, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ struct cb_info *cbinfo;
+ unsigned int cmd = CMD_ACTIVATE_PACKAGE;
+ int ret;
+
+ if (!pkgname) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet = packet_create((const char *)&cmd, "s", pkgname);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ ErrPrint("Unable to create cbinfo\n");
+ packet_destroy(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(NULL, packet, 0, activated_cb, cbinfo);
+ if (ret < 0) {
+ dbox_destroy_cb_info(cbinfo);
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_destroy_glance_bar(dynamicbox_h handler, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ struct cb_info *cbinfo;
+ unsigned int cmd = CMD_DESTROY_GBAR;
+ int ret;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->gbar.fb || !handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ /*!
+ * \FIXME
+ * Replace the callback check code.
+ * Use the flag instead of callback.
+ * the flag should be in the ADT "common"
+ */
+ if (!handler->common->is_gbar_created && !handler->common->request.gbar_created) {
+ ErrPrint("GBAR is not created\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->common->request.gbar_destroyed) {
+ ErrPrint("GBAR destroy request is already sent\n");
+ return DBOX_STATUS_ERROR_ALREADY;
+ }
+
+ /*!
+ * \note
+ * Disable the gbar_created request flag
+ */
+ if (handler->common->request.gbar_created) {
+ if (job_add(handler, turn_off_gbar_created_flag_cb, DBOX_STATUS_ERROR_CANCEL, NULL) < 0) {
+ ErrPrint("Failed to add a new job\n");
+ }
+ }
+
+ DbgPrint("[%s]\n", handler->common->pkgname);
+
+ packet = packet_create((const char *)&cmd, "ss", handler->common->pkgname, handler->common->id);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ if (!cb) {
+ cb = default_gbar_destroyed_cb;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, gbar_destroy_cb, cbinfo);
+ if (ret < 0) {
+ dbox_destroy_cb_info(cbinfo);
+ } else {
+ handler->common->request.gbar_destroyed = 1;
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_feed_access_event(dynamicbox_h handler, dynamicbox_access_event_type_e type, dynamicbox_access_event_info_t info, dynamicbox_ret_cb cb, void *data)
+{
+ int w = 1;
+ int h = 1;
+ unsigned int cmd;
+ int ret = 0; /* re-used for sending event type */
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->common->request.access_event) {
+ ErrPrint("Previous access event is not yet done\n");
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+
+ if (type & DBOX_ACCESS_EVENT_GBAR_MASK) {
+ if (!handler->common->is_gbar_created) {
+ ErrPrint("GBAR is not created\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ w = handler->common->gbar.width;
+ h = handler->common->gbar.height;
+
+ switch (type & ~(DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_DBOX_MASK)) {
+ case DBOX_ACCESS_EVENT_HIGHLIGHT:
+ cmd = CMD_GBAR_ACCESS_HL;
+ ret = (int)info->type;
+ break;
+ case DBOX_ACCESS_EVENT_ACTIVATE:
+ cmd = CMD_GBAR_ACCESS_ACTIVATE;
+ break;
+ case DBOX_ACCESS_EVENT_ACTION:
+ cmd = CMD_GBAR_ACCESS_ACTION;
+ ret = (int)info->type;
+ break;
+ case DBOX_ACCESS_EVENT_SCROLL:
+ cmd = CMD_GBAR_ACCESS_SCROLL;
+ ret = (int)info->type;
+ break;
+ case DBOX_ACCESS_EVENT_VALUE_CHANGE:
+ cmd = CMD_GBAR_ACCESS_VALUE_CHANGE;
+ break;
+ case DBOX_ACCESS_EVENT_MOUSE:
+ cmd = CMD_GBAR_ACCESS_MOUSE;
+ ret = (int)info->type;
+ break;
+ case DBOX_ACCESS_EVENT_BACK:
+ cmd = CMD_GBAR_ACCESS_BACK;
+ break;
+ case DBOX_ACCESS_EVENT_OVER:
+ cmd = CMD_GBAR_ACCESS_OVER;
+ break;
+ case DBOX_ACCESS_EVENT_READ:
+ cmd = CMD_GBAR_ACCESS_READ;
+ break;
+ case DBOX_ACCESS_EVENT_ENABLE:
+ cmd = CMD_GBAR_ACCESS_ENABLE;
+ ret = info->type;
+ break;
+ default:
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ } else if (type & DBOX_ACCESS_EVENT_DBOX_MASK) {
+ w = handler->common->dbox.width;
+ h = handler->common->dbox.height;
+ switch (type & ~(DBOX_ACCESS_EVENT_GBAR_MASK | DBOX_ACCESS_EVENT_DBOX_MASK)) {
+ case DBOX_ACCESS_EVENT_HIGHLIGHT:
+ cmd = CMD_DBOX_ACCESS_HL;
+ ret = (int)info->type;
+ break;
+ case DBOX_ACCESS_EVENT_ACTIVATE:
+ cmd = CMD_DBOX_ACCESS_ACTIVATE;
+ break;
+ case DBOX_ACCESS_EVENT_ACTION:
+ cmd = CMD_DBOX_ACCESS_ACTION;
+ ret = (int)info->type;
+ break;
+ case DBOX_ACCESS_EVENT_SCROLL:
+ cmd = CMD_DBOX_ACCESS_SCROLL;
+ ret = (int)info->type;
+ break;
+ case DBOX_ACCESS_EVENT_VALUE_CHANGE:
+ cmd = CMD_DBOX_ACCESS_VALUE_CHANGE;
+ break;
+ case DBOX_ACCESS_EVENT_MOUSE:
+ cmd = CMD_DBOX_ACCESS_MOUSE;
+ ret = (int)info->type;
+ break;
+ case DBOX_ACCESS_EVENT_BACK:
+ cmd = CMD_DBOX_ACCESS_BACK;
+ break;
+ case DBOX_ACCESS_EVENT_OVER:
+ cmd = CMD_DBOX_ACCESS_OVER;
+ break;
+ case DBOX_ACCESS_EVENT_READ:
+ cmd = CMD_DBOX_ACCESS_READ;
+ break;
+ case DBOX_ACCESS_EVENT_ENABLE:
+ cmd = CMD_DBOX_ACCESS_ENABLE;
+ ret = info->type;
+ break;
+ default:
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ ErrPrint("Invalid event type\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!cb) {
+ cb = default_access_event_cb;
+ }
+
+ ret = send_access_event(handler, (const char *)&cmd, info->x * w, info->y * h, ret);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ handler->cbs.access_event.cb = cb;
+ handler->cbs.access_event.data = data;
+ handler->common->request.access_event = 1;
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_feed_mouse_event(dynamicbox_h handler, dynamicbox_mouse_event_type_e type, dynamicbox_mouse_event_info_t info)
+{
+ int w = 1;
+ int h = 1;
+ unsigned int cmd;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!(type & DBOX_MOUSE_EVENT_MASK)) {
+ ErrPrint("Invalid content event is used\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (type & DBOX_MOUSE_EVENT_GBAR_MASK) {
+ int flag = 1;
+
+ if (!handler->common->is_gbar_created) {
+ ErrPrint("GBAR is not created\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->gbar.fb) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (type & DBOX_MOUSE_EVENT_MOVE) {
+ if (fabs(info->x - handler->common->gbar.x) < conf_event_filter() && fabs(info->y - handler->common->gbar.y) < conf_event_filter()) {
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+ } else if (type & DBOX_MOUSE_EVENT_SET) {
+ flag = 0;
+ }
+
+ if (flag) {
+ handler->common->gbar.x = info->x;
+ handler->common->gbar.y = info->y;
+ w = handler->common->gbar.width;
+ h = handler->common->gbar.height;
+ }
+
+ switch ((type & ~(DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_DBOX_MASK))) {
+ case DBOX_MOUSE_EVENT_ENTER | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_ENTER;
+ break;
+ case DBOX_MOUSE_EVENT_LEAVE | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_LEAVE;
+ break;
+ case DBOX_MOUSE_EVENT_UP | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_UP;
+ break;
+ case DBOX_MOUSE_EVENT_DOWN | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_DOWN;
+ break;
+ case DBOX_MOUSE_EVENT_MOVE | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_MOVE;
+ break;
+ case DBOX_MOUSE_EVENT_SET | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_SET;
+ break;
+ case DBOX_MOUSE_EVENT_UNSET | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_UNSET;
+ break;
+ case DBOX_MOUSE_EVENT_ON_SCROLL | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_ON_SCROLL;
+ break;
+ case DBOX_MOUSE_EVENT_ON_HOLD | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_ON_HOLD;
+ break;
+ case DBOX_MOUSE_EVENT_OFF_SCROLL | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_OFF_SCROLL;
+ break;
+ case DBOX_MOUSE_EVENT_OFF_HOLD | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_GBAR_MOUSE_OFF_HOLD;
+ break;
+ default:
+ ErrPrint("Invalid event type\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ } else if (type & DBOX_MOUSE_EVENT_DBOX_MASK) {
+ int flag = 1;
+
+ if (!handler->common->dbox.fb) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (type & DBOX_MOUSE_EVENT_MOVE) {
+ if (fabs(info->x - handler->common->dbox.x) < conf_event_filter() && fabs(info->y - handler->common->dbox.y) < conf_event_filter()) {
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+ } else if (type & DBOX_MOUSE_EVENT_SET) {
+ flag = 0;
+ }
+
+ if (flag) {
+ handler->common->dbox.x = info->x;
+ handler->common->dbox.y = info->y;
+ w = handler->common->dbox.width;
+ h = handler->common->dbox.height;
+ }
+
+ switch ((type & ~(DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_DBOX_MASK))) {
+ case DBOX_MOUSE_EVENT_ENTER | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_DBOX_MOUSE_ENTER;
+ break;
+ case DBOX_MOUSE_EVENT_LEAVE | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_DBOX_MOUSE_LEAVE;
+ break;
+ case DBOX_MOUSE_EVENT_UP | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_DBOX_MOUSE_UP;
+ break;
+ case DBOX_MOUSE_EVENT_DOWN | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_DBOX_MOUSE_DOWN;
+ break;
+ case DBOX_MOUSE_EVENT_MOVE | DBOX_MOUSE_EVENT_MASK:
+ if (!handler->common->dbox.mouse_event) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+ cmd = CMD_DBOX_MOUSE_MOVE;
+ break;
+ case DBOX_MOUSE_EVENT_SET | DBOX_MOUSE_EVENT_MASK:
+ if (!handler->common->dbox.mouse_event) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+ cmd = CMD_DBOX_MOUSE_SET;
+ break;
+ case DBOX_MOUSE_EVENT_UNSET | DBOX_MOUSE_EVENT_MASK:
+ if (!handler->common->dbox.mouse_event) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+ cmd = CMD_DBOX_MOUSE_UNSET;
+ break;
+ case DBOX_MOUSE_EVENT_ON_SCROLL | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_DBOX_MOUSE_ON_SCROLL;
+ break;
+ case DBOX_MOUSE_EVENT_ON_HOLD | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_DBOX_MOUSE_ON_HOLD;
+ break;
+ case DBOX_MOUSE_EVENT_OFF_SCROLL | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_DBOX_MOUSE_OFF_SCROLL;
+ break;
+ case DBOX_MOUSE_EVENT_OFF_HOLD | DBOX_MOUSE_EVENT_MASK:
+ cmd = CMD_DBOX_MOUSE_OFF_HOLD;
+ break;
+ default:
+ ErrPrint("Invalid event type\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ ErrPrint("Invalid event type\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return send_mouse_event(handler, (const char *)&cmd, info->x * w, info->y * h);
+}
+
+EAPI int dynamicbox_feed_key_event(dynamicbox_h handler, dynamicbox_key_event_type_e type, dynamicbox_key_event_info_t info, dynamicbox_ret_cb cb, void *data)
+{
+ int ret;
+ unsigned int cmd;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!(type & DBOX_KEY_EVENT_MASK)) {
+ ErrPrint("Invalid key event is used\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->common->request.key_event) {
+ ErrPrint("Previous key event is not completed yet\n");
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+
+ if (type & DBOX_MOUSE_EVENT_GBAR_MASK) {
+ if (!handler->common->is_gbar_created) {
+ ErrPrint("GBAR is not created\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->gbar.fb) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (type & DBOX_KEY_EVENT_DOWN) {
+ /*!
+ * \TODO
+ * filtering the reproduced events if it is too fast
+ */
+ } else if (type & DBOX_KEY_EVENT_SET) {
+ /*!
+ * \TODO
+ * What can I do for this case?
+ */
+ }
+
+ /*!
+ * Must be short than 29 bytes.
+ */
+ switch ((type & ~(DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_DBOX_MASK))) {
+ case DBOX_KEY_EVENT_FOCUS_IN | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_GBAR_KEY_FOCUS_IN;
+ break;
+ case DBOX_KEY_EVENT_FOCUS_OUT | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_GBAR_KEY_FOCUS_OUT;
+ break;
+ case DBOX_KEY_EVENT_UP | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_GBAR_KEY_UP;
+ break;
+ case DBOX_KEY_EVENT_DOWN | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_GBAR_KEY_DOWN;
+ break;
+ case DBOX_KEY_EVENT_SET | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_GBAR_KEY_SET;
+ break;
+ case DBOX_KEY_EVENT_UNSET | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_GBAR_KEY_UNSET;
+ break;
+ default:
+ ErrPrint("Invalid event type\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ } else if (type & DBOX_MOUSE_EVENT_DBOX_MASK) {
+ if (!handler->common->dbox.fb) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (type & DBOX_KEY_EVENT_DOWN) {
+ /*!
+ * \TODO
+ * filtering the reproduced events if it is too fast
+ */
+ } else if (type & DBOX_KEY_EVENT_SET) {
+ /*!
+ * What can I do for this case?
+ */
+ }
+
+ switch ((type & ~(DBOX_MOUSE_EVENT_GBAR_MASK | DBOX_MOUSE_EVENT_DBOX_MASK))) {
+ case DBOX_KEY_EVENT_FOCUS_IN | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_DBOX_KEY_FOCUS_IN;
+ break;
+ case DBOX_KEY_EVENT_FOCUS_OUT | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_DBOX_KEY_FOCUS_OUT;
+ break;
+ case DBOX_KEY_EVENT_UP | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_DBOX_KEY_UP;
+ break;
+ case DBOX_KEY_EVENT_DOWN | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_DBOX_KEY_DOWN;
+ break;
+ case DBOX_KEY_EVENT_SET | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_DBOX_KEY_SET;
+ break;
+ case DBOX_KEY_EVENT_UNSET | DBOX_KEY_EVENT_MASK:
+ cmd = CMD_DBOX_KEY_UNSET;
+ break;
+ default:
+ ErrPrint("Invalid event type\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ ErrPrint("Invalid event type\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!cb) {
+ cb = default_key_event_cb;
+ }
+
+ ret = send_key_event(handler, (const char *)&cmd, info->keycode);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ handler->cbs.key_event.cb = cb;
+ handler->cbs.key_event.data = data;
+ handler->common->request.key_event = 1;
+ }
+
+ return ret;
+}
+
+EAPI const char *dynamicbox_filename(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return NULL;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return NULL;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return NULL;
+ }
+
+ if (handler->common->filename) {
+ return handler->common->filename;
+ }
+
+ /* Oooops */
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_NONE);
+ return util_uri_to_path(handler->common->id);
+}
+
+EAPI int dynamicbox_get_glance_bar_size(dynamicbox_h handler, int *w, int *h)
+{
+ int _w;
+ int _h;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!w) {
+ w = &_w;
+ }
+ if (!h) {
+ h = &_h;
+ }
+
+ if (!handler->common->is_gbar_created) {
+ *w = handler->common->gbar.default_width;
+ *h = handler->common->gbar.default_height;
+ } else {
+ *w = handler->common->gbar.width;
+ *h = handler->common->gbar.height;
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+EAPI dynamicbox_size_type_e dynamicbox_size(dynamicbox_h handler)
+{
+ int w;
+ int h;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_SIZE_TYPE_UNKNOWN;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_SIZE_TYPE_UNKNOWN;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_SIZE_TYPE_UNKNOWN;
+ }
+
+ w = handler->common->dbox.width;
+ h = handler->common->dbox.height;
+
+ switch (handler->common->dbox.type) {
+ case DBOX_TYPE_BUFFER:
+ case DBOX_TYPE_SCRIPT:
+ if (!fb_is_created(handler->common->dbox.fb)) {
+ w = 0;
+ h = 0;
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_NOT_EXIST);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return dynamicbox_service_size_type(w, h);
+}
+
+EAPI int dynamicbox_set_group(dynamicbox_h handler, const char *cluster, const char *category, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_CHANGE_GROUP;
+ int ret;
+
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!cluster || !category || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->common->request.group_changed) {
+ ErrPrint("Previous group changing request is not finished yet\n");
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+
+ if (!handler->common->is_user) {
+ ErrPrint("CA Livebox is not able to change the group\n");
+ return DBOX_STATUS_ERROR_PERMISSION_DENIED;
+ }
+
+ if (!strcmp(handler->common->cluster, cluster) && !strcmp(handler->common->category, category)) {
+ DbgPrint("No changes\n");
+ return DBOX_STATUS_ERROR_ALREADY;
+ }
+
+ packet = packet_create((const char *)&cmd, "ssss", handler->common->pkgname, handler->common->id, cluster, category);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ if (!cb) {
+ cb = default_group_changed_cb;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, set_group_ret_cb, NULL);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ handler->cbs.group_changed.cb = cb;
+ handler->cbs.group_changed.data = data;
+ handler->common->request.group_changed = 1;
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_get_group(dynamicbox_h handler, const char **cluster, const char **category)
+{
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!cluster || !category || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ *cluster = handler->common->cluster;
+ *category = handler->common->category;
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+EAPI int dynamicbox_get_supported_sizes(dynamicbox_h handler, int *cnt, dynamicbox_size_type_e *size_list)
+{
+ register int i;
+ register int j;
+
+ if (!handler || !size_list) {
+ ErrPrint("Invalid argument, handler(%p), size_list(%p)\n", handler, size_list);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!cnt || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ for (j = i = 0; i < DBOX_NR_OF_SIZE_LIST; i++) {
+ if (handler->common->dbox.size_list & (0x01 << i)) {
+ if (j == *cnt) {
+ break;
+ }
+
+ size_list[j++] = (dynamicbox_size_type_e)(0x01 << i);
+ }
+ }
+
+ *cnt = j;
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+EAPI const char *dynamicbox_pkgname(dynamicbox_h handler)
+{
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_NONE);
+ return handler->common->pkgname;
+}
+
+EAPI double dynamicbox_priority(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return -1.0f;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return -1.0f;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid (%p)\n", handler);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return -1.0f;
+ }
+
+ return handler->common->dbox.priority;
+}
+
+EAPI int dynamicbox_delete_cluster(const char *cluster, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ struct cb_info *cbinfo;
+ unsigned int cmd = CMD_DELETE_CLUSTER;
+ int ret;
+
+ packet = packet_create((const char *)&cmd, "s", cluster);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(NULL, packet, 0, delete_cluster_cb, cbinfo);
+ if (ret < 0) {
+ dbox_destroy_cb_info(cbinfo);
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_delete_category(const char *cluster, const char *category, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ struct cb_info *cbinfo;
+ unsigned int cmd = CMD_DELETE_CATEGORY;
+ int ret;
+
+ packet = packet_create((const char *)&cmd, "ss", cluster, category);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(NULL, packet, 0, delete_category_cb, cbinfo);
+ if (ret < 0) {
+ dbox_destroy_cb_info(cbinfo);
+ }
+
+ return ret;
+}
+
+EAPI dynamicbox_type_e dynamicbox_type(dynamicbox_h handler, int gbar)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_CONTENT_TYPE_INVALID;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_CONTENT_TYPE_INVALID;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_CONTENT_TYPE_INVALID;
+ }
+
+ if (gbar) {
+ switch (handler->common->gbar.type) {
+ case GBAR_TYPE_TEXT:
+ return DBOX_CONTENT_TYPE_TEXT;
+ case GBAR_TYPE_BUFFER:
+ case GBAR_TYPE_SCRIPT:
+ {
+ const char *id;
+ id = fb_id(handler->common->gbar.fb);
+ if (id && !strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
+ return DBOX_CONTENT_TYPE_RESOURCE_ID;
+ }
+ }
+ return DBOX_CONTENT_TYPE_BUFFER;
+ case GBAR_TYPE_UIFW:
+ return DBOX_CONTENT_TYPE_UIFW;
+ default:
+ break;
+ }
+ } else {
+ switch (handler->common->dbox.type) {
+ case DBOX_TYPE_FILE:
+ return DBOX_CONTENT_TYPE_IMAGE;
+ case DBOX_TYPE_BUFFER:
+ case DBOX_TYPE_SCRIPT:
+ {
+ const char *id;
+ id = fb_id(handler->common->dbox.fb);
+ if (id && !strncasecmp(id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
+ return DBOX_CONTENT_TYPE_RESOURCE_ID;
+ }
+ }
+ return DBOX_CONTENT_TYPE_BUFFER;
+ case DBOX_TYPE_TEXT:
+ return DBOX_CONTENT_TYPE_TEXT;
+ case DBOX_TYPE_UIFW:
+ return DBOX_CONTENT_TYPE_UIFW;
+ default:
+ break;
+ }
+ }
+
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_CONTENT_TYPE_INVALID;
+}
+
+EAPI int dynamicbox_set_text_handler(dynamicbox_h handler, int gbar, struct dynamicbox_script_operators *ops)
+{
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (gbar) {
+ memcpy(&handler->cbs.gbar_ops, ops, sizeof(*ops));
+ } else {
+ memcpy(&handler->cbs.dbox_ops, ops, sizeof(*ops));
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+EAPI int dynamicbox_acquire_extra_resource_id(dynamicbox_h handler, int gbar, int idx, dynamicbox_ret_cb cb, void *data)
+{
+ if (idx < 0) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (gbar) {
+ /**
+ * This can be called from extra_resource_created event.
+ * and it can be called before get the created event.
+ * then we didn't know this handler's buffer type yet
+ * so we cannot use its type to validate handle
+ *
+ * handler->common.gbar.type == unknown
+ */
+ if (!handler->common->gbar.extra_buffer) {
+ return DBOX_STATUS_ERROR_NOT_EXIST;
+ }
+
+ if (idx >= conf_extra_buffer_count()) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return dbox_acquire_gbar_extra_pixmap(handler, idx, cb, data);
+ } else {
+ /**
+ * This can be called from extra_resource_created event.
+ * and it can be called before get the created event.
+ * then we didn't know this handler's buffer type yet
+ * so we cannot use its type to validate handle
+ *
+ * handler->common.dbox.type == unknown
+ */
+ if (!handler->common->dbox.extra_buffer) {
+ ErrPrint("Extra buffer is not prepared\n");
+ return DBOX_STATUS_ERROR_NOT_EXIST;
+ }
+
+ if (idx >= conf_extra_buffer_count()) {
+ ErrPrint("Invalid parameter: %d / %d\n", idx, conf_extra_buffer_count());
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return dbox_acquire_dbox_extra_pixmap(handler, idx, cb, data);
+ }
+}
+
+EAPI int dynamicbox_acquire_resource_id(dynamicbox_h handler, int gbar, dynamicbox_ret_cb cb, void *data)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (gbar) {
+ if (handler->common->gbar.type != GBAR_TYPE_SCRIPT && handler->common->gbar.type != GBAR_TYPE_BUFFER) {
+ ErrPrint("Handler is not valid type\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return dbox_acquire_gbar_pixmap(handler, cb, data);
+ } else {
+ if (handler->common->dbox.type != DBOX_TYPE_SCRIPT && handler->common->dbox.type != DBOX_TYPE_BUFFER) {
+ ErrPrint("Handler is not valid type\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return dbox_acquire_dbox_pixmap(handler, cb, data);
+ }
+}
+
+/*!
+ * \note
+ * Do not check the state of handler and common-handler.
+ * If this function is used in the deleted callback,
+ * the handler and common-handler's state would be DELETE
+ * if this function check the state of handles,
+ * user cannot release the pixmap.
+ */
+EAPI int dynamicbox_release_resource_id(dynamicbox_h handler, int gbar, unsigned int resource_id)
+{
+ struct packet *packet;
+ const char *pkgname;
+ const char *id;
+ unsigned int cmd;
+
+ if (resource_id == 0 /* || handler->state != DBOX_STATE_CREATE */) {
+ ErrPrint("Pixmap is invalid [%d]\n", resource_id);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (gbar) {
+ if (!handler) {
+ /*!
+ * \note
+ * Even though the handler is NULL, we should send the release request to the master.
+ * Because the resource_id resource can be released after the handler is destroyed.
+ * Pixmap resource is used by client. and it cannot be guaranteed to release resource_id.
+ * In some cases, the resource_id can be released after the handler is deleted.
+ *
+ * Its implementation is up to the viewer app.
+ * But we cannot force it to use only with valid handler.
+ */
+ DbgPrint("Using NULL handler\n");
+ pkgname = NULL;
+ id = NULL;
+ /*!
+ * \note
+ * Master will try to find the buffer handler using given resource_id. if the pkgname and id is not valid.
+ */
+ } else {
+ if (!handler->common /* || handler-common->state != DBOX_STATE_CREATE */) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ /**
+ * This can be called from extra_resource_created event.
+ * and it can be called before get the created event.
+ * then we didn't know this handler's buffer type yet
+ * so we cannot use its type to validate handle
+ *
+ * handler->common.gbar.type == unknown
+ */
+
+ pkgname = handler->common->pkgname;
+ id = handler->common->id;
+ }
+
+ cmd = CMD_GBAR_RELEASE_PIXMAP;
+ } else {
+ if (!handler) {
+ /*!
+ * \note
+ * Even though the handler is NULL, we should send the release request to the master.
+ * Because the resource_id resource can be released after the handler is destroyed.
+ * Pixmap resource is used by client. and it cannot be guaranteed to release resource_id.
+ * In some cases, the resource_id can be released after the handler is deleted.
+ *
+ * Its implementation is up to the viewer app.
+ * But we cannot force it to use only with valid handler.
+ */
+ DbgPrint("Using NULL handler\n");
+ pkgname = NULL;
+ id = NULL;
+ /*!
+ * \note
+ * Master will try to find the buffer handler using given resource_id. if the pkgname and id is not valid.
+ */
+ } else {
+ if (!handler->common /* || handler->common->state != DBOX_STATE_CREATE */) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ /**
+ * This can be called from extra_resource_created event.
+ * and it can be called before get the created event.
+ * then we didn't know this handler's buffer type yet
+ * so we cannot use its type to validate handle
+ *
+ * handler->common.dbox.type == unknown
+ */
+
+ pkgname = handler->common->pkgname;
+ id = handler->common->id;
+ }
+
+ cmd = CMD_DBOX_RELEASE_PIXMAP;
+ }
+
+ packet = packet_create_noack((const char *)&cmd, "ssi", pkgname, id, resource_id);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_request_only(handler, packet);
+}
+
+EAPI unsigned int dynamicbox_extra_resource_id(const dynamicbox_h handler, int gbar, int idx)
+{
+ if (idx < 0) {
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handler\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+
+ if (gbar) {
+ /**
+ * This can be called from extra_resource_created event.
+ * and it can be called before get the created event.
+ * then we didn't know this handler's buffer type yet
+ * so we cannot use its type to validate handle
+ *
+ * handler->common.gbar.type == unknown
+ */
+
+ if (!handler->common->gbar.extra_buffer || handler->common->gbar.last_extra_buffer_idx < 0) {
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_NOT_EXIST);
+ return 0u;
+ }
+
+ return handler->common->gbar.extra_buffer[handler->common->gbar.last_extra_buffer_idx];
+ } else {
+ /**
+ * This can be called from extra_resource_created event.
+ * and it can be called before get the created event.
+ * then we didn't know this handler's buffer type yet
+ * so we cannot use its type to validate handle
+ *
+ * handler->common.dbox.type == unknown
+ */
+
+ if (!handler->common->dbox.extra_buffer || handler->common->dbox.last_extra_buffer_idx < 0) {
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_NOT_EXIST);
+ return 0u;
+ }
+
+ return handler->common->dbox.extra_buffer[handler->common->dbox.last_extra_buffer_idx];
+ }
+}
+
+EAPI unsigned int dynamicbox_resource_id(const dynamicbox_h handler, int gbar)
+{
+ const char *id;
+ unsigned int pixmap = 0u;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handler\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+
+ if (gbar) {
+ if (handler->common->gbar.type != GBAR_TYPE_SCRIPT && handler->common->gbar.type != GBAR_TYPE_BUFFER) {
+ ErrPrint("Invalid handler\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+
+ id = fb_id(handler->common->gbar.fb);
+ if (id && sscanf(id, SCHEMA_PIXMAP "%u", &pixmap) != 1) {
+ ErrPrint("PIXMAP Id is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+ } else {
+ if (handler->common->dbox.type != DBOX_TYPE_SCRIPT && handler->common->dbox.type != DBOX_TYPE_BUFFER) {
+ ErrPrint("Invalid handler\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+
+ id = fb_id(handler->common->dbox.fb);
+ if (id && sscanf(id, SCHEMA_PIXMAP "%u", &pixmap) != 1) {
+ ErrPrint("PIXMAP Id is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0u;
+ }
+ }
+
+ return pixmap;
+}
+
+EAPI void *dynamicbox_acquire_buffer(dynamicbox_h handler, int gbar)
+{
+ if (gbar) {
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handler\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (handler->common->gbar.type != GBAR_TYPE_SCRIPT && handler->common->gbar.type != GBAR_TYPE_BUFFER) {
+ ErrPrint("Handler is not valid type\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ return fb_acquire_buffer(handler->common->gbar.fb);
+ } else {
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handle\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (handler->common->dbox.type != DBOX_TYPE_SCRIPT && handler->common->dbox.type != DBOX_TYPE_BUFFER) {
+ ErrPrint("Handler is not valid type\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ return fb_acquire_buffer(handler->common->dbox.fb);
+ }
+}
+
+EAPI int dynamicbox_release_buffer(void *buffer)
+{
+ return fb_release_buffer(buffer);
+}
+
+EAPI int dynamicbox_buffer_refcnt(void *buffer)
+{
+ return fb_refcnt(buffer);
+}
+
+EAPI int dynamicbox_buffer_size(dynamicbox_h handler, int gbar)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handler\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (gbar) {
+ return fb_size(handler->common->gbar.fb);
+ } else {
+ return fb_size(handler->common->dbox.fb);
+ }
+}
+
+EAPI int dynamicbox_is_created_by_user(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handler\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return handler->common->is_user;
+}
+
+EAPI int dynamicbox_set_pinup(dynamicbox_h handler, int flag, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_PINUP_CHANGED;
+ int ret;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handler\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->common->request.pinup) {
+ ErrPrint("Previous pinup request is not finished\n");
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+
+ if (handler->common->is_pinned_up == flag) {
+ DbgPrint("No changes\n");
+ return DBOX_STATUS_ERROR_ALREADY;
+ }
+
+ packet = packet_create((const char *)&cmd, "ssi", handler->common->pkgname, handler->common->id, flag);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ if (!cb) {
+ cb = default_pinup_cb;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, pinup_done_cb, NULL);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ handler->cbs.pinup.cb = cb;
+ handler->cbs.pinup.data = data;
+ handler->common->request.pinup = 1;
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_is_pinned_up(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handler\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return handler->common->is_pinned_up;
+}
+
+EAPI int dynamicbox_has_pinup(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handler\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ return handler->common->dbox.pinup_supported;
+}
+
+EAPI int dynamicbox_set_data(dynamicbox_h handler, void *data)
+{
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ handler->data = data;
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+EAPI void *dynamicbox_data(dynamicbox_h handler)
+{
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ return handler->data;
+}
+
+EAPI const char *dynamicbox_content(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_NONE);
+ return handler->common->content;
+}
+
+EAPI const char *dynamicbox_title(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_NONE);
+ return handler->common->title;
+}
+
+EAPI int dynamicbox_emit_text_signal(dynamicbox_h handler, dynamicbox_text_event_t event_info, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ struct cb_info *cbinfo;
+ unsigned int cmd = CMD_TEXT_SIGNAL;
+ int ret;
+ const char *emission;
+ const char *source;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (handler->common->dbox.type != DBOX_TYPE_TEXT && handler->common->gbar.type != GBAR_TYPE_TEXT) {
+ DbgPrint("Not a text box, but send signal\n");
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!event_info) {
+ ErrPrint("Invalid event info\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ emission = event_info->emission;
+ if (!emission) {
+ emission = "";
+ }
+
+ source = event_info->source;
+ if (!source) {
+ source = "";
+ }
+
+ packet = packet_create((const char *)&cmd, "ssssdddd",
+ handler->common->pkgname, handler->common->id,
+ emission, source,
+ event_info->geometry.sx, event_info->geometry.sy,
+ event_info->geometry.ex, event_info->geometry.ey);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, text_signal_cb, cbinfo);
+ if (ret < 0) {
+ dbox_destroy_cb_info(cbinfo);
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_subscribe_group(const char *cluster, const char *category)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_SUBSCRIBE;
+
+ /*!
+ * \todo
+ * Validate the group info using DB
+ * If the group info is not valid, do not send this request
+ */
+
+ packet = packet_create_noack((const char *)&cmd, "ss", cluster ? cluster : "", category ? category : "");
+ if (!packet) {
+ ErrPrint("Failed to create a packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_request_only(NULL, packet);
+}
+
+EAPI int dynamicbox_unsubscribe_group(const char *cluster, const char *category)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_UNSUBSCRIBE;
+
+ /*!
+ * \todo
+ * Validate the group info using DB
+ * If the group info is not valid, do not send this request
+ * AND Check the subscribed or not too
+ */
+
+ packet = packet_create_noack((const char *)&cmd, "ss", cluster ? cluster : "", category ? category : "");
+ if (!packet) {
+ ErrPrint("Failed to create a packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_request_only(NULL, packet);
+}
+
+EAPI int dynamicbox_refresh(dynamicbox_h handler, int force)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_UPDATE;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet = packet_create_noack((const char *)&cmd, "ssi", handler->common->pkgname, handler->common->id, force);
+ if (!packet) {
+ ErrPrint("Failed to create a packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_request_only(handler, packet);
+}
+
+EAPI int dynamicbox_refresh_group(const char *cluster, const char *category, int force)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_REFRESH_GROUP;
+
+ if (!cluster || !category) {
+ ErrPrint("Invalid argument\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet = packet_create_noack((const char *)&cmd, "ssi", cluster, category, force);
+ if (!packet) {
+ ErrPrint("Failed to create a packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_request_only(NULL, packet);
+}
+
+EAPI int dynamicbox_set_visibility(dynamicbox_h handler, dynamicbox_visible_state_e state)
+{
+ int old_state;
+ int ret;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->is_user) {
+ /* System cluster dynamicbox cannot be changed its visible states */
+ if (state == DBOX_HIDE_WITH_PAUSE) {
+ ErrPrint("CA Livebox is not able to change the visibility\n");
+ return DBOX_STATUS_ERROR_PERMISSION_DENIED;
+ }
+ }
+
+ if (handler->visible == state) {
+ DbgPrint("%s has no changes\n", handler->common->pkgname);
+ return DBOX_STATUS_ERROR_ALREADY;
+ }
+
+ old_state = handler->visible;
+ handler->visible = state;
+
+ ret = dbox_set_visibility(handler, state);
+ if (ret < 0) {
+ handler->visible = old_state;
+ }
+
+ return ret;
+}
+
+EAPI dynamicbox_visible_state_e dynamicbox_visibility(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is invalid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_VISIBLE_ERROR;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_VISIBLE_ERROR;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_VISIBLE_ERROR;
+ }
+
+ return handler->visible;
+}
+
+EAPI int dynamicbox_viewer_set_paused(void)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_CLIENT_PAUSED;
+
+ packet = packet_create_noack((const char *)&cmd, "d", util_timestamp());
+ if (!packet) {
+ ErrPrint("Failed to create a pause packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_request_only(NULL, packet);
+}
+
+EAPI int dynamicbox_viewer_set_resumed(void)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_CLIENT_RESUMED;
+
+ packet = packet_create_noack((const char *)&cmd, "d", util_timestamp());
+ if (!packet) {
+ ErrPrint("Failed to create a resume packet\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return master_rpc_request_only(NULL, packet);
+}
+
+EAPI int dynamicbox_sync_buffer(dynamicbox_h handler, int gbar)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (gbar) {
+ return dbox_sync_gbar_fb(handler->common);
+ } else {
+ return dbox_sync_dbox_fb(handler->common);
+ }
+}
+
+EAPI const char *dynamicbox_alternative_icon(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ return handler->common->alt.icon;
+}
+
+EAPI const char *dynamicbox_alternative_name(dynamicbox_h handler)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ return handler->common->alt.name;
+}
+
+EAPI int dynamicbox_acquire_buffer_lock(dynamicbox_h handler, int is_gbar)
+{
+ int ret = DBOX_STATUS_ERROR_NONE;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Handler is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (is_gbar) {
+ ret = dynamicbox_service_acquire_lock(handler->common->gbar.lock);
+ } else {
+ ret = dynamicbox_service_acquire_lock(handler->common->dbox.lock);
+ }
+
+ return ret == 0 ? DBOX_STATUS_ERROR_NONE : DBOX_STATUS_ERROR_FAULT;
+}
+
+EAPI int dynamicbox_release_buffer_lock(dynamicbox_h handler, int is_gbar)
+{
+ int ret = DBOX_STATUS_ERROR_NONE;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (is_gbar) {
+ ret = dynamicbox_service_release_lock(handler->common->gbar.lock);
+ } else {
+ ret = dynamicbox_service_release_lock(handler->common->dbox.lock);
+ }
+
+ return ret == 0 ? DBOX_STATUS_ERROR_NONE : DBOX_STATUS_ERROR_FAULT;
+}
+
+EAPI int dynamicbox_set_option(dynamicbox_option_type_e option, int state)
+{
+ int ret = DBOX_STATUS_ERROR_NONE;
+
+ switch (option) {
+ case DBOX_OPTION_MANUAL_SYNC:
+ conf_set_manual_sync(state);
+ break;
+ case DBOX_OPTION_FRAME_DROP_FOR_RESIZE:
+ conf_set_frame_drop_for_resizing(state);
+ break;
+ case DBOX_OPTION_SHARED_CONTENT:
+ conf_set_shared_content(state);
+ break;
+ case DBOX_OPTION_DIRECT_UPDATE:
+ if (s_info.init_count) {
+ DbgPrint("Already intialized, this option is not applied\n");
+ }
+ conf_set_direct_update(state);
+ break;
+ case DBOX_OPTION_EXTRA_BUFFER_CNT:
+ ErrPrint("Permission denied\n");
+ ret = DBOX_STATUS_ERROR_PERMISSION_DENIED;
+ break;
+ default:
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_option(dynamicbox_option_type_e option)
+{
+ int ret;
+
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_NONE);
+ switch (option) {
+ case DBOX_OPTION_MANUAL_SYNC:
+ ret = conf_manual_sync();
+ break;
+ case DBOX_OPTION_FRAME_DROP_FOR_RESIZE:
+ ret = conf_frame_drop_for_resizing();
+ break;
+ case DBOX_OPTION_SHARED_CONTENT:
+ ret = conf_shared_content();
+ break;
+ case DBOX_OPTION_DIRECT_UPDATE:
+ ret = conf_direct_update();
+ break;
+ case DBOX_OPTION_EXTRA_BUFFER_CNT:
+ ret = conf_extra_buffer_count();
+ break;
+ default:
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ break;
+ }
+
+ return ret;
+}
+
+EAPI int dynamicbox_set_auto_launch_handler(dynamicbox_auto_launch_handler_cb dbox_launch_handler, void *data)
+{
+ s_info.launch.handler = dbox_launch_handler;
+ s_info.launch.data = data;
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+EAPI int dynamicbox_damage_region_get(dynamicbox_h handler, int gbar, const dynamicbox_damage_region_t *region)
+{
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (gbar) {
+ region = &handler->common->dbox.last_damage;
+ } else {
+ region = &handler->common->gbar.last_damage;
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+EAPI int dynamicbox_get_affected_extra_buffer(dynamicbox_h handler, int gbar, int *idx, unsigned int *resource_id)
+{
+ int _idx;
+ unsigned int _resource_id;
+
+ if (!handler || handler->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common || handler->common->state != DBOX_STATE_CREATE) {
+ ErrPrint("Invalid handle\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!handler->common->id) {
+ ErrPrint("Handler is not valid[%p]\n", handler);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!idx) {
+ idx = &_idx;
+ }
+
+ if (!resource_id) {
+ resource_id = &_resource_id;
+ }
+
+ if (gbar) {
+ if (!handler->common->gbar.extra_buffer || handler->common->gbar.last_extra_buffer_idx < 0) {
+ return DBOX_STATUS_ERROR_NOT_EXIST;
+ }
+
+ *idx = handler->common->gbar.last_extra_buffer_idx;
+ *resource_id = handler->common->gbar.extra_buffer[*idx];
+ } else {
+ if (!handler->common->dbox.extra_buffer || handler->common->dbox.last_extra_buffer_idx < 0) {
+ return DBOX_STATUS_ERROR_NOT_EXIST;
+ }
+
+ *idx = handler->common->dbox.last_extra_buffer_idx;
+ *resource_id = handler->common->dbox.extra_buffer[*idx];
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+/* End of a file */
diff --git a/dynamicbox_viewer/src/dynamicbox_internal.c b/dynamicbox_viewer/src/dynamicbox_internal.c
new file mode 100644
index 0000000..4b3e034
--- /dev/null
+++ b/dynamicbox_viewer/src/dynamicbox_internal.c
@@ -0,0 +1,1058 @@
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+
+#include <dlog.h>
+
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_buffer.h>
+
+#include <packet.h>
+
+#include "dlist.h"
+#include "debug.h"
+#include "dynamicbox.h"
+#include "dynamicbox_internal.h"
+#include "fb.h"
+#include "conf.h"
+#include "util.h"
+#include "master_rpc.h"
+
+int errno;
+
+typedef enum event_state {
+ INFO_STATE_CALLBACK_IN_IDLE = 0x00,
+ INFO_STATE_CALLBACK_IN_PROCESSING = 0x01
+} event_state_e;
+
+struct event_info {
+ int is_deleted;
+ int (*handler)(dynamicbox_h handler, dynamicbox_event_type_e event, void *data);
+ void *user_data;
+};
+
+struct fault_info {
+ int is_deleted;
+ int (*handler)(dynamicbox_fault_type_e event, const char *pkgname, const char *filename, const char *func, void *data);
+ void *user_data;
+};
+
+static struct info {
+ struct dlist *dynamicbox_common_list;
+ struct dlist *dynamicbox_list;
+ struct dlist *event_list;
+ struct dlist *fault_list;
+ event_state_e event_state;
+ event_state_e fault_state;
+} s_info = {
+ .dynamicbox_common_list = NULL,
+ .dynamicbox_list = NULL,
+ .event_list = NULL,
+ .fault_list = NULL,
+ .event_state = INFO_STATE_CALLBACK_IN_IDLE,
+ .fault_state = INFO_STATE_CALLBACK_IN_IDLE,
+};
+
+static inline void default_delete_cb(dynamicbox_h handler, int ret, void *data)
+{
+ DbgPrint("Default deleted event handler: %d\n", ret);
+}
+
+static void del_ret_cb(dynamicbox_h handler, const struct packet *result, void *data)
+{
+ struct cb_info *info = data;
+ int ret;
+ dynamicbox_ret_cb cb;
+ void *cbdata;
+
+ cb = info->cb;
+ cbdata = info->data;
+ dbox_destroy_cb_info(info);
+
+ if (!result) {
+ ErrPrint("Connection lost?\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else if (packet_get(result, "i", &ret) != 1) {
+ ErrPrint("Invalid argument\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (ret == 0) {
+ handler->cbs.deleted.cb = cb;
+ handler->cbs.deleted.data = cbdata;
+ } else if (cb) {
+ cb(handler, ret, cbdata);
+ }
+
+ /*!
+ * \note
+ * Do not call the deleted callback from here.
+ * master will send the "deleted" event.
+ * Then invoke this callback.
+ *
+ * if (handler->cbs.deleted.cb)
+ * handler->cbs.deleted.cb(handler, ret, handler->cbs.deleted.data);
+ */
+}
+
+struct dynamicbox_common *dbox_create_common_handle(dynamicbox_h handle, const char *pkgname, const char *cluster, const char *category)
+{
+ struct dynamicbox_common *common;
+
+ common = calloc(1, sizeof(*common));
+ if (!common) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ common->pkgname = strdup(pkgname);
+ if (!common->pkgname) {
+ free(common);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ common->cluster = strdup(cluster);
+ if (!common->cluster) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ free(common->pkgname);
+ free(common);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ common->category = strdup(category);
+ if (!common->category) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ free(common->cluster);
+ free(common->pkgname);
+ free(common);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ /* Data provider will set this */
+ common->dbox.type = DBOX_TYPE_FILE;
+ common->gbar.type = GBAR_TYPE_SCRIPT;
+
+ /* Used for handling the mouse event on a box */
+ common->dbox.mouse_event = 0;
+
+ /* Cluster infomration is not determined yet */
+ common->nr_of_sizes = 0x01;
+
+ common->timestamp = util_timestamp();
+ common->is_user = 1;
+ common->delete_type = DBOX_DELETE_PERMANENTLY;
+
+ common->gbar.lock = NULL;
+ common->gbar.last_extra_buffer_idx = DBOX_UNKNOWN_BUFFER;
+
+ common->dbox.lock = NULL;
+ common->dbox.last_extra_buffer_idx = DBOX_UNKNOWN_BUFFER;
+
+ common->state = DBOX_STATE_CREATE;
+ common->visible = DBOX_SHOW;
+
+ s_info.dynamicbox_common_list = dlist_append(s_info.dynamicbox_common_list, common);
+ return common;
+}
+
+int dbox_destroy_common_handle(struct dynamicbox_common *common)
+{
+ dlist_remove_data(s_info.dynamicbox_common_list, common);
+
+ common->state = DBOX_STATE_DESTROYED;
+
+ if (common->filename) {
+ (void)util_unlink(common->filename);
+ }
+
+ free(common->cluster);
+ free(common->category);
+ free(common->id);
+ free(common->pkgname);
+ free(common->filename);
+ free(common->dbox.auto_launch);
+ free(common->alt.icon);
+ free(common->alt.name);
+
+ if (common->dbox.fb) {
+ fb_destroy(common->dbox.fb);
+ common->dbox.fb = NULL;
+ }
+
+ if (common->gbar.fb) {
+ fb_destroy(common->gbar.fb);
+ common->gbar.fb = NULL;
+ }
+
+ return 0;
+}
+
+int dbox_common_ref(struct dynamicbox_common *common, dynamicbox_h handle)
+{
+ common->dynamicbox_list = dlist_append(common->dynamicbox_list, handle);
+ common->refcnt++;
+
+ return common->refcnt;
+}
+
+int dbox_common_unref(struct dynamicbox_common *common, dynamicbox_h handle)
+{
+ int refcnt;
+ dlist_remove_data(common->dynamicbox_list, handle);
+ refcnt = --common->refcnt;
+
+ return refcnt;
+}
+
+int dbox_set_group(struct dynamicbox_common *common, const char *cluster, const char *category)
+{
+ void *pc = NULL;
+ void *ps = NULL;
+
+ if (cluster) {
+ pc = strdup(cluster);
+ if (!pc) {
+ ErrPrint("Heap: %s (cluster: %s)\n", strerror(errno), cluster);
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+ }
+
+ if (category) {
+ ps = strdup(category);
+ if (!ps) {
+ ErrPrint("Heap: %s (category: %s)\n", strerror(errno), category);
+ free(pc);
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+ }
+
+ if (common->cluster) {
+ free(common->cluster);
+ }
+
+ if (common->category) {
+ free(common->category);
+ }
+
+ common->cluster = pc;
+ common->category = ps;
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+void dbox_set_size(struct dynamicbox_common *common, int w, int h)
+{
+ int size_type;
+
+ common->dbox.width = w;
+ common->dbox.height = h;
+
+ size_type = dynamicbox_service_size_type(w, h);
+ if (size_type != DBOX_SIZE_TYPE_UNKNOWN) {
+ common->dbox.mouse_event = dynamicbox_service_mouse_event(common->pkgname, size_type);
+ }
+}
+
+void dbox_set_update_mode(struct dynamicbox_common *common, int active_mode)
+{
+ common->is_active_update = active_mode;
+}
+
+void dbox_set_gbarsize(struct dynamicbox_common *common, int w, int h)
+{
+ common->gbar.width = w;
+ common->gbar.height = h;
+}
+
+void dbox_set_default_gbarsize(struct dynamicbox_common *common, int w, int h)
+{
+ common->gbar.default_width = w;
+ common->gbar.default_height = h;
+}
+
+void dbox_invoke_fault_handler(dynamicbox_fault_type_e event, const char *pkgname, const char *file, const char *func)
+{
+ struct dlist *l;
+ struct dlist *n;
+ struct fault_info *info;
+
+ s_info.fault_state = INFO_STATE_CALLBACK_IN_PROCESSING;
+
+ dlist_foreach_safe(s_info.fault_list, l, n, info) {
+ if (!info->is_deleted && info->handler(event, pkgname, file, func, info->user_data) == EXIT_FAILURE) {
+ info->is_deleted = 1;
+ }
+
+ if (info->is_deleted) {
+ s_info.fault_list = dlist_remove(s_info.fault_list, l);
+ free(info);
+ }
+ }
+
+ s_info.fault_state &= ~INFO_STATE_CALLBACK_IN_PROCESSING;
+}
+
+void dbox_invoke_event_handler(dynamicbox_h handler, dynamicbox_event_type_e event)
+{
+ struct dlist *l;
+ struct dlist *n;
+ struct event_info *info;
+
+ if (event == DBOX_EVENT_DBOX_UPDATED && handler->common->refcnt > 1) {
+ if (handler->visible != DBOX_SHOW) {
+ DbgPrint("Update requested(pending) - %s\n", handler->common->pkgname);
+ handler->paused_updating++;
+ return;
+ } else {
+ handler->paused_updating = 0;
+ }
+ }
+
+ s_info.event_state = INFO_STATE_CALLBACK_IN_PROCESSING;
+
+ dlist_foreach_safe(s_info.event_list, l, n, info) {
+ if (!info->is_deleted && info->handler(handler, event, info->user_data) == EXIT_FAILURE) {
+ DbgPrint("Event handler returns EXIT_FAILURE\n");
+ info->is_deleted = 1;
+ }
+
+ if (info->is_deleted) {
+ s_info.event_list = dlist_remove(s_info.event_list, l);
+ free(info);
+ }
+ }
+
+ s_info.event_state &= ~INFO_STATE_CALLBACK_IN_PROCESSING;
+}
+
+struct dynamicbox_common *dbox_find_common_handle(const char *pkgname, const char *id)
+{
+ struct dlist *l;
+ struct dynamicbox_common *common;
+
+ dlist_foreach(s_info.dynamicbox_common_list, l, common) {
+ if (!common->id) {
+ continue;
+ }
+
+ if (!strcmp(common->pkgname, pkgname) && !strcmp(common->id, id)) {
+ return common;
+ }
+ }
+
+ return NULL;
+}
+
+struct dynamicbox_common *dbox_find_common_handle_by_timestamp(double timestamp)
+{
+ struct dlist *l;
+ struct dynamicbox_common *common;
+
+ dlist_foreach(s_info.dynamicbox_common_list, l, common) {
+ if (common->timestamp == timestamp) {
+ return common;
+ }
+ }
+
+ return NULL;
+}
+
+dynamicbox_h dbox_new_dynamicbox(const char *pkgname, const char *id, double timestamp, const char *cluster, const char *category)
+{
+ dynamicbox_h handler;
+
+ handler = calloc(1, sizeof(*handler));
+ if (!handler) {
+ ErrPrint("Failed to create a new dynamicbox\n");
+ return NULL;
+ }
+
+ handler->common = dbox_create_common_handle(handler, pkgname, cluster, category);
+ if (!handler->common) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ free(handler);
+ return NULL;
+ }
+
+ dbox_common_ref(handler->common, handler);
+ dbox_set_id(handler->common, id);
+ handler->common->timestamp = timestamp;
+ handler->common->state = DBOX_STATE_CREATE;
+ handler->visible = DBOX_SHOW;
+ s_info.dynamicbox_list = dlist_append(s_info.dynamicbox_list, handler);
+
+ return dbox_ref(handler);
+}
+
+int dbox_delete_all(void)
+{
+ struct dlist *l;
+ struct dlist *n;
+ dynamicbox_h handler;
+
+ dlist_foreach_safe(s_info.dynamicbox_list, l, n, handler) {
+ dbox_invoke_event_handler(handler, DBOX_EVENT_DELETED);
+ dbox_unref(handler, 1);
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int dbox_set_content(struct dynamicbox_common *common, const char *content)
+{
+ char *pc = NULL;
+
+ if (content) {
+ pc = strdup(content);
+ if (!pc) {
+ ErrPrint("heap: %s [%s]\n", strerror(errno), content);
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+ }
+
+ free(common->content);
+ common->content = pc;
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int dbox_set_title(struct dynamicbox_common *common, const char *title)
+{
+ char *pt = NULL;
+
+ if (title) {
+ pt = strdup(title);
+ if (!pt) {
+ ErrPrint("heap: %s [%s]\n", strerror(errno), title);
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+ }
+
+ free(common->title);
+ common->title = pt;
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+void dbox_set_size_list(struct dynamicbox_common *common, int size_list)
+{
+ common->dbox.size_list = size_list;
+}
+
+void dbox_set_auto_launch(struct dynamicbox_common *common, const char *auto_launch)
+{
+ char *pa = NULL;
+
+ if (!auto_launch || !strlen(auto_launch)) {
+ return;
+ }
+
+ pa = strdup(auto_launch);
+ if (!pa) {
+ ErrPrint("heap: %s, [%s]\n", strerror(errno), auto_launch);
+ return;
+ }
+
+ free(common->dbox.auto_launch);
+ common->dbox.auto_launch = pa;
+}
+
+void dbox_set_priority(struct dynamicbox_common *common, double priority)
+{
+ common->dbox.priority = priority;
+}
+
+void dbox_set_id(struct dynamicbox_common *common, const char *id)
+{
+ char *pi = NULL;
+
+ if (id) {
+ pi = strdup(id);
+ if (!pi) {
+ ErrPrint("heap: %s [%s]\n", strerror(errno), pi);
+ return;
+ }
+ }
+
+ free(common->id);
+ common->id = pi;
+}
+
+void dbox_unlink_filename(struct dynamicbox_common *common)
+{
+ if (common->dbox.type == DBOX_TYPE_FILE || common->dbox.type == DBOX_TYPE_TEXT) {
+ if (common->filename && common->filename[0] && unlink(common->filename) < 0) {
+ ErrPrint("unlink: %s (%s)\n", strerror(errno), common->filename);
+ }
+ }
+}
+
+void dbox_set_filename(struct dynamicbox_common *common, const char *filename)
+{
+ if (common->filename) {
+ free(common->filename);
+ }
+
+ common->filename = strdup(filename);
+ if (!common->filename) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ }
+}
+
+void dbox_set_alt_icon(struct dynamicbox_common *common, const char *icon)
+{
+ char *_icon = NULL;
+
+ if (icon && strlen(icon)) {
+ _icon = strdup(icon);
+ if (!_icon) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ }
+ }
+
+ free(common->alt.icon);
+ common->alt.icon = _icon;
+}
+
+void dbox_set_alt_name(struct dynamicbox_common *common, const char *name)
+{
+ char *_name = NULL;
+
+ if (name && strlen(name)) {
+ _name = strdup(name);
+ if (!_name) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ }
+ }
+
+ free(common->alt.name);
+ common->alt.name = _name;
+}
+
+int dbox_set_dbox_fb(struct dynamicbox_common *common, const char *filename)
+{
+ struct fb_info *fb;
+
+ if (!common) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ fb = common->dbox.fb;
+ if (fb && !strcmp(fb_id(fb), filename)) { /*!< BUFFER is not changed, */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ common->dbox.fb = NULL;
+
+ if (!filename || filename[0] == '\0') {
+ if (fb) {
+ fb_destroy(fb);
+ }
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ common->dbox.fb = fb_create(filename, common->dbox.width, common->dbox.height);
+ if (!common->dbox.fb) {
+ ErrPrint("Faield to create a FB\n");
+ if (fb) {
+ fb_destroy(fb);
+ }
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ if (fb) {
+ fb_destroy(fb);
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int dbox_set_gbar_fb(struct dynamicbox_common *common, const char *filename)
+{
+ struct fb_info *fb;
+
+ if (!common || common->state != DBOX_STATE_CREATE) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ fb = common->gbar.fb;
+ if (fb && !strcmp(fb_id(fb), filename)) {
+ /* BUFFER is not changed, just update the content */
+ return DBOX_STATUS_ERROR_EXIST;
+ }
+ common->gbar.fb = NULL;
+
+ if (!filename || filename[0] == '\0') {
+ if (fb) {
+ fb_destroy(fb);
+ }
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ common->gbar.fb = fb_create(filename, common->gbar.width, common->gbar.height);
+ if (!common->gbar.fb) {
+ ErrPrint("Failed to create a FB\n");
+ if (fb) {
+ fb_destroy(fb);
+ }
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ if (fb) {
+ fb_destroy(fb);
+ }
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+struct fb_info *dbox_get_dbox_fb(struct dynamicbox_common *common)
+{
+ return common->dbox.fb;
+}
+
+struct fb_info *dbox_get_gbar_fb(struct dynamicbox_common *common)
+{
+ return common->gbar.fb;
+}
+
+void dbox_set_user(struct dynamicbox_common *common, int user)
+{
+ common->is_user = user;
+}
+
+void dbox_set_pinup(struct dynamicbox_common *common, int pinup_supported)
+{
+ common->dbox.pinup_supported = pinup_supported;
+}
+
+void dbox_set_text_dbox(struct dynamicbox_common *common)
+{
+ common->dbox.type = DBOX_TYPE_TEXT;
+}
+
+void dbox_set_text_gbar(struct dynamicbox_common *common)
+{
+ common->gbar.type = GBAR_TYPE_TEXT;
+}
+
+int dbox_text_dbox(struct dynamicbox_common *common)
+{
+ return common->dbox.type == DBOX_TYPE_TEXT;
+}
+
+int dbox_text_gbar(struct dynamicbox_common *common)
+{
+ return common->gbar.type == GBAR_TYPE_TEXT;
+}
+
+void dbox_set_period(struct dynamicbox_common *common, double period)
+{
+ common->dbox.period = period;
+}
+
+dynamicbox_h dbox_ref(dynamicbox_h handler)
+{
+ if (!handler) {
+ return NULL;
+ }
+
+ handler->refcnt++;
+ return handler;
+}
+
+dynamicbox_h dbox_unref(dynamicbox_h handler, int destroy_common)
+{
+ if (!handler) {
+ return NULL;
+ }
+
+ handler->refcnt--;
+ if (handler->refcnt > 0) {
+ return handler;
+ }
+
+ if (handler->cbs.created.cb) {
+ handler->cbs.created.cb(handler, DBOX_STATUS_ERROR_FAULT, handler->cbs.created.data);
+ handler->cbs.created.cb = NULL;
+ handler->cbs.created.data = NULL;
+ }
+
+ if (handler->cbs.deleted.cb) {
+ handler->cbs.deleted.cb(handler, DBOX_STATUS_ERROR_FAULT, handler->cbs.deleted.data);
+ handler->cbs.deleted.cb = NULL;
+ handler->cbs.deleted.data = NULL;
+ }
+
+ if (handler->cbs.pinup.cb) {
+ handler->cbs.pinup.cb(handler, DBOX_STATUS_ERROR_FAULT, handler->cbs.pinup.data);
+ handler->cbs.pinup.cb = NULL;
+ handler->cbs.pinup.data = NULL;
+ }
+
+ if (handler->cbs.group_changed.cb) {
+ handler->cbs.group_changed.cb(handler, DBOX_STATUS_ERROR_FAULT, handler->cbs.group_changed.data);
+ handler->cbs.group_changed.cb = NULL;
+ handler->cbs.group_changed.data = NULL;
+ }
+
+ if (handler->cbs.period_changed.cb) {
+ handler->cbs.period_changed.cb(handler, DBOX_STATUS_ERROR_FAULT, handler->cbs.period_changed.data);
+ handler->cbs.period_changed.cb = NULL;
+ handler->cbs.period_changed.data = NULL;
+ }
+
+ if (handler->cbs.size_changed.cb) {
+ handler->cbs.size_changed.cb(handler, DBOX_STATUS_ERROR_FAULT, handler->cbs.size_changed.data);
+ handler->cbs.size_changed.cb = NULL;
+ handler->cbs.size_changed.data = NULL;
+ }
+
+ if (handler->cbs.gbar_created.cb) {
+ handler->cbs.gbar_created.cb(handler, DBOX_STATUS_ERROR_FAULT, handler->cbs.gbar_created.data);
+ handler->cbs.gbar_created.cb = NULL;
+ handler->cbs.gbar_created.data = NULL;
+ }
+
+ if (handler->cbs.gbar_destroyed.cb) {
+ handler->cbs.gbar_destroyed.cb(handler, DBOX_STATUS_ERROR_FAULT, handler->cbs.gbar_destroyed.data);
+ handler->cbs.gbar_destroyed.cb = NULL;
+ handler->cbs.gbar_destroyed.data = NULL;
+ }
+
+ if (handler->cbs.update_mode.cb) {
+ handler->cbs.update_mode.cb(handler, DBOX_STATUS_ERROR_FAULT, handler->cbs.update_mode.data);
+ handler->cbs.update_mode.cb = NULL;
+ handler->cbs.update_mode.data = NULL;
+ }
+
+ if (handler->cbs.access_event.cb) {
+ handler->cbs.access_event.cb(handler, DBOX_ACCESS_STATUS_ERROR, handler->cbs.access_event.data);
+ handler->cbs.access_event.cb = NULL;
+ handler->cbs.access_event.data = NULL;
+ }
+
+ if (handler->cbs.key_event.cb) {
+ handler->cbs.key_event.cb(handler, DBOX_KEY_STATUS_ERROR, handler->cbs.key_event.data);
+ handler->cbs.key_event.cb = NULL;
+ handler->cbs.key_event.data = NULL;
+ }
+
+ dlist_remove_data(s_info.dynamicbox_list, handler);
+
+ handler->state = DBOX_STATE_DESTROYED;
+ if (dbox_common_unref(handler->common, handler) == 0) {
+ if (destroy_common) {
+ /*!
+ * \note
+ * Lock file should be deleted after all callbacks are processed.
+ */
+ (void)dynamicbox_service_destroy_lock(handler->common->dbox.lock);
+ handler->common->dbox.lock = NULL;
+ dbox_destroy_common_handle(handler->common);
+ }
+ }
+ free(handler);
+ DbgPrint("Handler is released\n");
+ return NULL;
+}
+
+int dbox_send_delete(dynamicbox_h handler, int type, dynamicbox_ret_cb cb, void *data)
+{
+ struct packet *packet;
+ struct cb_info *cbinfo;
+ int ret;
+
+ if (handler->common->request.deleted) {
+ ErrPrint("Already in-progress\n");
+ if (cb) {
+ cb(handler, DBOX_STATUS_ERROR_NONE, data);
+ }
+ return DBOX_STATUS_ERROR_BUSY;
+ }
+
+ if (!cb) {
+ cb = default_delete_cb;
+ }
+
+ packet = packet_create("delete", "ssid", handler->common->pkgname, handler->common->id, type, handler->common->timestamp);
+ if (!packet) {
+ ErrPrint("Failed to build a param\n");
+ if (cb) {
+ cb(handler, DBOX_STATUS_ERROR_FAULT, data);
+ }
+
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ cbinfo = dbox_create_cb_info(cb, data);
+ if (!cbinfo) {
+ packet_destroy(packet);
+ ErrPrint("Failed to create cbinfo\n");
+ if (cb) {
+ cb(handler, DBOX_STATUS_ERROR_FAULT, data);
+ }
+
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = master_rpc_async_request(handler, packet, 0, del_ret_cb, cbinfo);
+ if (ret < 0) {
+ /*!
+ * Packet is destroyed by master_rpc_async_request.
+ */
+ dbox_destroy_cb_info(cbinfo);
+
+ if (cb) {
+ cb(handler, DBOX_STATUS_ERROR_FAULT, data);
+ }
+ } else {
+ handler->common->request.deleted = 1;
+ }
+
+ return ret;
+}
+
+int dbox_sync_dbox_fb(struct dynamicbox_common *common)
+{
+ int ret;
+
+ if (fb_type(dbox_get_dbox_fb(common)) == DBOX_FB_TYPE_FILE) {
+ (void)dynamicbox_service_acquire_lock(common->dbox.lock);
+ ret = fb_sync(dbox_get_dbox_fb(common), common->dbox.last_damage.x, common->dbox.last_damage.y, common->dbox.last_damage.w, common->dbox.last_damage.h);
+ (void)dynamicbox_service_release_lock(common->dbox.lock);
+ } else {
+ ret = fb_sync(dbox_get_dbox_fb(common), common->dbox.last_damage.x, common->dbox.last_damage.y, common->dbox.last_damage.w, common->dbox.last_damage.h);
+ }
+
+ return ret;
+}
+
+int dbox_sync_gbar_fb(struct dynamicbox_common *common)
+{
+ int ret;
+
+ if (fb_type(dbox_get_gbar_fb(common)) == DBOX_FB_TYPE_FILE) {
+ (void)dynamicbox_service_acquire_lock(common->gbar.lock);
+ ret = fb_sync(dbox_get_gbar_fb(common), common->gbar.last_damage.x, common->gbar.last_damage.y, common->gbar.last_damage.w, common->gbar.last_damage.h);
+ (void)dynamicbox_service_release_lock(common->gbar.lock);
+ } else {
+ ret = fb_sync(dbox_get_gbar_fb(common), common->gbar.last_damage.x, common->gbar.last_damage.y, common->gbar.last_damage.w, common->gbar.last_damage.h);
+ }
+
+ return ret;
+}
+
+struct dynamicbox_common *dbox_find_sharable_common_handle(const char *pkgname, const char *content, int w, int h, const char *cluster, const char *category)
+{
+ struct dlist *l;
+ struct dynamicbox_common *common;
+
+ if (!conf_shared_content()) {
+ /*!
+ * Shared content option is turnned off.
+ */
+ return NULL;
+ }
+
+ dlist_foreach(s_info.dynamicbox_common_list, l, common) {
+ if (common->state != DBOX_STATE_CREATE) {
+ continue;
+ }
+
+ if (strcmp(common->pkgname, pkgname)) {
+ continue;
+ }
+
+ if (strcmp(common->cluster, cluster)) {
+ DbgPrint("Cluster mismatched\n");
+ continue;
+ }
+
+ if (strcmp(common->category, category)) {
+ DbgPrint("Category mismatched\n");
+ continue;
+ }
+
+ if (common->content && content) {
+ if (strcmp(common->content, content)) {
+ DbgPrint("%s Content ([%s] <> [%s])\n", common->pkgname, common->content, content);
+ continue;
+ }
+ } else {
+ int c1_len;
+ int c2_len;
+
+ /*!
+ * \note
+ * We assumes "" (ZERO length string) to NULL
+ */
+ c1_len = common->content ? strlen(common->content) : 0;
+ c2_len = content ? strlen(content) : 0;
+ if (c1_len != c2_len) {
+ DbgPrint("%s Content %p <> %p\n", common->pkgname, common->content, content);
+ continue;
+ }
+ }
+
+ if (common->request.size_changed) {
+ DbgPrint("Changing size\n");
+ /*!
+ * \note
+ * Do not re-use resizing instance.
+ * We will not use predicted size.
+ */
+ continue;
+ }
+
+ if (common->request.created) {
+ DbgPrint("Creating now but re-use it (%s)\n", common->pkgname);
+ }
+
+ if (common->dbox.width != w || common->dbox.height != h) {
+ DbgPrint("Size mismatched\n");
+ continue;
+ }
+
+ DbgPrint("common handle is found: %p\n", common);
+ return common;
+ }
+
+ return NULL;
+}
+
+dynamicbox_h dbox_find_dbox_in_show(struct dynamicbox_common *common)
+{
+ struct dlist *l;
+ dynamicbox_h item;
+
+ dlist_foreach(common->dynamicbox_list, l, item) {
+ if (item->visible == DBOX_SHOW) {
+ DbgPrint("%s visibility is not changed\n", common->pkgname);
+ return item;
+ }
+ }
+
+ return NULL;
+}
+
+dynamicbox_h dbox_get_dbox_nth(struct dynamicbox_common *common, int nth)
+{
+ dynamicbox_h item;
+ struct dlist *l;
+
+ l = dlist_nth(common->dynamicbox_list, nth);
+ item = dlist_data(l);
+
+ return item;
+}
+
+int dbox_add_event_handler(dynamicbox_event_handler_cb dbox_cb, void *data)
+{
+ struct event_info *info;
+ info = malloc(sizeof(*info));
+ if (!info) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ info->handler = dbox_cb;
+ info->user_data = data;
+ info->is_deleted = 0;
+
+ s_info.event_list = dlist_append(s_info.event_list, info);
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+void *dbox_remove_event_handler(dynamicbox_event_handler_cb dbox_cb)
+{
+ struct event_info *info;
+ struct dlist *l;
+
+ dlist_foreach(s_info.event_list, l, info) {
+ if (info->handler == dbox_cb) {
+ void *data;
+
+ data = info->user_data;
+
+ if (s_info.event_state == INFO_STATE_CALLBACK_IN_PROCESSING) {
+ info->is_deleted = 1;
+ } else {
+ s_info.event_list = dlist_remove(s_info.event_list, l);
+ free(info);
+ }
+
+ return data;
+ }
+ }
+
+ return NULL;
+}
+
+int dbox_add_fault_handler(dynamicbox_fault_handler_cb dbox_cb, void *data)
+{
+ struct fault_info *info;
+ info = malloc(sizeof(*info));
+ if (!info) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ info->handler = dbox_cb;
+ info->user_data = data;
+ info->is_deleted = 0;
+
+ s_info.fault_list = dlist_append(s_info.fault_list, info);
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+void *dbox_remove_fault_handler(dynamicbox_fault_handler_cb dbox_cb)
+{
+ struct fault_info *info;
+ struct dlist *l;
+
+ dlist_foreach(s_info.fault_list, l, info) {
+ if (info->handler == dbox_cb) {
+ void *data;
+
+ data = info->user_data;
+
+ if (s_info.fault_state == INFO_STATE_CALLBACK_IN_PROCESSING) {
+ info->is_deleted = 1;
+ } else {
+ s_info.fault_list = dlist_remove(s_info.fault_list, l);
+ free(info);
+ }
+
+ return data;
+ }
+ }
+
+ return NULL;
+}
+
+struct cb_info *dbox_create_cb_info(dynamicbox_ret_cb cb, void *data)
+{
+ struct cb_info *info;
+
+ info = malloc(sizeof(*info));
+ if (!info) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return NULL;
+ }
+
+ info->cb = cb;
+ info->data = data;
+ return info;
+}
+
+void dbox_destroy_cb_info(struct cb_info *info)
+{
+ free(info);
+}
+
+/* End of a file */
diff --git a/dynamicbox_viewer/src/fb.c b/dynamicbox_viewer/src/fb.c
new file mode 100644
index 0000000..6f0d1f6
--- /dev/null
+++ b/dynamicbox_viewer/src/fb.c
@@ -0,0 +1,674 @@
+/*
+ * 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 <stdio.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stddef.h>
+#include <sys/shm.h>
+#include <sys/ipc.h>
+
+#include <X11/Xlib.h>
+#include <X11/extensions/XShm.h>
+#include <X11/Xutil.h>
+
+#include <dlog.h>
+#include <dynamicbox_errno.h> /* For error code */
+#include <dynamicbox_service.h> /* For buffer event data */
+#include <dynamicbox_buffer.h>
+
+#include "debug.h"
+#include "util.h"
+#include "fb.h"
+
+int errno;
+
+static struct {
+ Display *disp;
+ int screen;
+ Visual *visual;
+ int disp_is_opened;
+} s_info = {
+ .disp = NULL,
+ .disp_is_opened = 0,
+ .screen = -1,
+ .visual = NULL,
+};
+
+int fb_init(void *disp)
+{
+ s_info.disp = disp;
+ if (s_info.disp) {
+ Screen *screen;
+
+ screen = DefaultScreenOfDisplay(s_info.disp);
+
+ s_info.screen = DefaultScreen(s_info.disp);
+ s_info.visual = DefaultVisualOfScreen(screen);
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int fb_fini(void)
+{
+ if (s_info.disp_is_opened && s_info.disp) {
+ XCloseDisplay(s_info.disp);
+ }
+
+ s_info.disp = NULL;
+ s_info.disp_is_opened = 0;
+ s_info.visual = NULL;
+ s_info.screen = -1;
+ return 0;
+}
+
+static inline void update_fb_size(struct fb_info *info)
+{
+ info->bufsz = info->w * info->h * info->pixels;
+}
+
+static int sync_for_file(struct fb_info *info, int x, int y, int w, int h)
+{
+ int fd;
+ dynamicbox_fb_t buffer;
+
+ buffer = info->buffer;
+
+ if (!buffer) { /* Ignore this sync request */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (buffer->state != DBOX_FB_STATE_CREATED) {
+ ErrPrint("Invalid state of a FB\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (buffer->type != DBOX_FB_TYPE_FILE) {
+ ErrPrint("Invalid buffer\n");
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ fd = open(util_uri_to_path(info->id), O_RDONLY);
+ if (fd < 0) {
+ ErrPrint("Failed to open a file (%s) because of (%s)\n",
+ util_uri_to_path(info->id), strerror(errno));
+
+ /**
+ * @note
+ * But return ZERO, even if we couldn't get a buffer file,
+ * the viewer can draw empty screen.
+ *
+ * and then update it after it gots update events
+ */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ /**
+ * @note
+ * Could we get some advantage if we load a part of file instead of loading all of them?
+ */
+ if (x != 0 || y != 0 || info->w != w || info->h != h) {
+ int iy;
+ register int index;
+ register int width;
+
+ for (iy = y; iy < h; iy++) {
+ index = iy * info->w + x;
+ width = w * info->pixels;
+
+ if (lseek(fd, index * info->pixels, SEEK_SET) != index * info->pixels) {
+ ErrPrint("lseek: %s\n", strerror(errno));
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
+ /**
+ * @note
+ * But return ZERO, even if we couldn't get a buffer file,
+ * the viewer can draw empty screen.
+ *
+ * and then update it after it gots update events
+ */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (read(fd, ((unsigned int *)buffer->data) + index, width) != width) {
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
+ /**
+ * @note
+ * But return ZERO, even if we couldn't get a buffer file,
+ * the viewer can draw empty screen.
+ *
+ * and then update it after it gots update events
+ */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+ }
+ } else {
+ if (read(fd, buffer->data, info->bufsz) != info->bufsz) {
+ ErrPrint("read: %s\n", strerror(errno));
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
+
+ /**
+ * @note
+ * But return ZERO, even if we couldn't get a buffer file,
+ * the viewer can draw empty screen.
+ *
+ * and then update it after it gots update events
+ */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+ }
+
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+static int sync_for_pixmap(struct fb_info *info, int x, int y, int w, int h)
+{
+ dynamicbox_fb_t buffer;
+ XShmSegmentInfo si;
+ XImage *xim;
+
+ buffer = info->buffer;
+ if (!buffer) { /*!< Ignore this sync request */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (buffer->state != DBOX_FB_STATE_CREATED) {
+ ErrPrint("Invalid state of a FB\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (buffer->type != DBOX_FB_TYPE_PIXMAP) {
+ ErrPrint("Invalid buffer\n");
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (!s_info.disp) {
+ s_info.disp = XOpenDisplay(NULL);
+ if (s_info.disp) {
+ Screen *screen;
+
+ s_info.disp_is_opened = 1;
+
+ screen = DefaultScreenOfDisplay(s_info.disp);
+
+ s_info.screen = DefaultScreen(s_info.disp);
+ s_info.visual = DefaultVisualOfScreen(screen);
+ } else {
+ ErrPrint("Failed to open a display\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+ }
+
+ if (info->handle == 0) {
+ ErrPrint("Pixmap ID is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (info->bufsz == 0) {
+ /*!
+ * If the client does not acquire the buffer,
+ * This function will do nothing.
+ * It will work only if the buffer is acquired.
+ * To sync its contents.
+ */
+ DbgPrint("Nothing can be sync\n");
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ si.shmid = shmget(IPC_PRIVATE, info->bufsz, IPC_CREAT | 0666);
+ if (si.shmid < 0) {
+ ErrPrint("shmget: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ si.readOnly = False;
+ si.shmaddr = shmat(si.shmid, NULL, 0);
+ if (si.shmaddr == (void *)-1) {
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
+ ErrPrint("shmctl: %s\n", strerror(errno));
+ }
+
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ /*!
+ * \NOTE
+ * Use the 24 bits Pixmap for Video player
+ */
+ xim = XShmCreateImage(s_info.disp, s_info.visual,
+ (info->pixels << 3), ZPixmap, NULL,
+ &si,
+ info->w, info->h);
+ if (xim == NULL) {
+ if (shmdt(si.shmaddr) < 0) {
+ ErrPrint("shmdt: %s\n", strerror(errno));
+ }
+
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
+ ErrPrint("shmctl: %s\n", strerror(errno));
+ }
+
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ xim->data = si.shmaddr;
+ XShmAttach(s_info.disp, &si);
+
+ XShmGetImage(s_info.disp, info->handle, xim, 0, 0, 0xFFFFFFFF);
+ XSync(s_info.disp, False);
+
+ if (x != 0 || y != 0 || info->w != w || info->h != h) {
+ int ix;
+ int iy;
+ register int index;
+
+ for (iy = y; iy < h; iy++) {
+ for (ix = x; ix < w; ix++) {
+ index = iy * info->w + x;
+ *(((unsigned int *)buffer->data) + index) = *(((unsigned int *)xim->data) + index);
+ }
+ }
+ } else {
+ memcpy(buffer->data, xim->data, info->bufsz);
+ }
+
+ XShmDetach(s_info.disp, &si);
+ XDestroyImage(xim);
+
+ if (shmdt(si.shmaddr) < 0) {
+ ErrPrint("shmdt: %s\n", strerror(errno));
+ }
+
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
+ ErrPrint("shmctl: %s\n", strerror(errno));
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int fb_sync(struct fb_info *info, int x, int y, int w, int h)
+{
+ if (!info) {
+ ErrPrint("FB Handle is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!info->id || info->id[0] == '\0') {
+ DbgPrint("Ingore sync\n");
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) {
+ return sync_for_file(info, x, y, w, h);
+ } else if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
+ return sync_for_pixmap(info, x, y, w, h);
+ } else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM))) {
+ /* No need to do sync */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+}
+
+struct fb_info *fb_create(const char *id, int w, int h)
+{
+ struct fb_info *info;
+
+ if (!id || id[0] == '\0') {
+ ErrPrint("Invalid ID\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->pixels = sizeof(int); /* Use the default pixels(depth) */
+
+ if (sscanf(info->id, SCHEMA_SHM "%d", &info->handle) == 1) {
+ DbgPrint("SHMID: %d is gotten\n", info->handle);
+ } else if (sscanf(info->id, SCHEMA_PIXMAP "%d:%d", &info->handle, &info->pixels) == 2) {
+ DbgPrint("PIXMAP-SHMID: %d is gotten (%d)\n", info->handle, info->pixels);
+ } else {
+ info->handle = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ info->bufsz = 0;
+ info->buffer = NULL;
+ info->w = w;
+ info->h = h;
+
+ return info;
+}
+
+int fb_destroy(struct fb_info *info)
+{
+ if (!info) {
+ ErrPrint("Handle is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (info->buffer) {
+ dynamicbox_fb_t buffer;
+ buffer = info->buffer;
+
+ buffer->info = NULL;
+ }
+
+ free(info->id);
+ free(info);
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int fb_is_created(struct fb_info *info)
+{
+ if (!info) {
+ ErrPrint("Handle is not valid\n");
+ return 0;
+ }
+
+ if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)) && info->handle != 0) {
+ return 1;
+ } else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM)) && info->handle > 0) {
+ return 1;
+ } else {
+ const char *path;
+ path = util_uri_to_path(info->id);
+ if (path && access(path, F_OK | R_OK) == 0) {
+ return 1;
+ } else {
+ ErrPrint("access: %s (%s)\n", strerror(errno), path);
+ }
+ }
+
+ return 0;
+}
+
+void *fb_acquire_buffer(struct fb_info *info)
+{
+ dynamicbox_fb_t buffer;
+
+ if (!info) {
+ ErrPrint("info == NIL\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!info->buffer) {
+ if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
+ update_fb_size(info);
+
+ buffer = calloc(1, sizeof(*buffer) + info->bufsz);
+ if (!buffer) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_OUT_OF_MEMORY);
+ info->bufsz = 0;
+ return NULL;
+ }
+
+ buffer->type = DBOX_FB_TYPE_PIXMAP;
+ buffer->refcnt = 0;
+ buffer->state = DBOX_FB_STATE_CREATED;
+ buffer->info = info;
+ info->buffer = buffer;
+
+ /*!
+ * \note
+ * Just update from here.
+ */
+ sync_for_pixmap(info, 0, 0, info->w, info->h);
+ } else if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) {
+ update_fb_size(info);
+
+ buffer = calloc(1, sizeof(*buffer) + info->bufsz);
+ if (!buffer) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ info->bufsz = 0;
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ buffer->type = DBOX_FB_TYPE_FILE;
+ buffer->refcnt = 0;
+ buffer->state = DBOX_FB_STATE_CREATED;
+ buffer->info = info;
+ info->buffer = buffer;
+
+ sync_for_file(info, 0, 0, info->w, info->h);
+ } else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM))) {
+ buffer = shmat(info->handle, NULL, 0);
+ if (buffer == (void *)-1) {
+ ErrPrint("shmat: %s (%d)\n", strerror(errno), info->handle);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_FAULT);
+ return NULL;
+ }
+
+ return buffer->data;
+ } else {
+ ErrPrint("Buffer is not created (%s)\n", info->id);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+ }
+
+ buffer = info->buffer;
+
+ switch (buffer->type) {
+ case DBOX_FB_TYPE_PIXMAP:
+ buffer->refcnt++;
+ break;
+ case DBOX_FB_TYPE_FILE:
+ buffer->refcnt++;
+ break;
+ default:
+ DbgPrint("Unknwon FP: %d\n", buffer->type);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ break;
+ }
+
+ return buffer->data;
+}
+
+int fb_release_buffer(void *data)
+{
+ dynamicbox_fb_t buffer;
+
+ if (!data) {
+ ErrPrint("buffer data == NIL\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ buffer = container_of(data, struct dynamicbox_fb, data);
+
+ if (buffer->state != DBOX_FB_STATE_CREATED) {
+ ErrPrint("Invalid handle\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (buffer->type) {
+ case DBOX_FB_TYPE_SHM:
+ if (shmdt(buffer) < 0) {
+ ErrPrint("shmdt: %s\n", strerror(errno));
+ }
+ break;
+ case DBOX_FB_TYPE_PIXMAP:
+ buffer->refcnt--;
+ if (buffer->refcnt == 0) {
+ struct fb_info *info;
+ info = buffer->info;
+
+ buffer->state = DBOX_FB_STATE_DESTROYED;
+
+ if (info && info->buffer == buffer) {
+ info->buffer = NULL;
+ }
+ free(buffer);
+ }
+ break;
+ case DBOX_FB_TYPE_FILE:
+ buffer->refcnt--;
+ if (buffer->refcnt == 0) {
+ struct fb_info *info;
+ info = buffer->info;
+
+ buffer->state = DBOX_FB_STATE_DESTROYED;
+
+ if (info && info->buffer == buffer) {
+ info->buffer = NULL;
+ }
+
+ free(buffer);
+ }
+ break;
+ default:
+ ErrPrint("Unknwon buffer type\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ break;
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int fb_refcnt(void *data)
+{
+ dynamicbox_fb_t buffer;
+ struct shmid_ds buf;
+ int ret;
+
+ if (!data) {
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ buffer = container_of(data, struct dynamicbox_fb, data);
+
+ if (buffer->state != DBOX_FB_STATE_CREATED) {
+ ErrPrint("Invalid handle\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (buffer->type) {
+ case DBOX_FB_TYPE_SHM:
+ if (shmctl(buffer->refcnt, IPC_STAT, &buf) < 0) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_FAULT);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = buf.shm_nattch;
+ break;
+ case DBOX_FB_TYPE_PIXMAP:
+ ret = buffer->refcnt;
+ break;
+ case DBOX_FB_TYPE_FILE:
+ ret = buffer->refcnt;
+ break;
+ default:
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ return ret;
+}
+
+const char *fb_id(struct fb_info *info)
+{
+ return info ? info->id : NULL;
+}
+
+int fb_get_size(struct fb_info *info, int *w, int *h)
+{
+ if (!info) {
+ ErrPrint("Handle is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ *w = info->w;
+ *h = info->h;
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int fb_size(struct fb_info *info)
+{
+ if (!info) {
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ update_fb_size(info);
+
+ return info->bufsz;
+}
+
+int fb_type(struct fb_info *info)
+{
+ dynamicbox_fb_t buffer;
+
+ if (!info) {
+ return DBOX_FB_TYPE_ERROR;
+ }
+
+ buffer = info->buffer;
+ if (!buffer) {
+ int type = DBOX_FB_TYPE_ERROR;
+ /*!
+ * \note
+ * Try to get this from SCHEMA
+ */
+ if (info->id) {
+ if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) {
+ type = DBOX_FB_TYPE_FILE;
+ } else if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
+ type = DBOX_FB_TYPE_PIXMAP;
+ } else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM))) {
+ type = DBOX_FB_TYPE_SHM;
+ }
+ }
+
+ return type;
+ }
+
+ return buffer->type;
+}
+/* End of a file */
diff --git a/dynamicbox_viewer/src/fb_wayland.c b/dynamicbox_viewer/src/fb_wayland.c
new file mode 100644
index 0000000..786f922
--- /dev/null
+++ b/dynamicbox_viewer/src/fb_wayland.c
@@ -0,0 +1,451 @@
+/*
+ * 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 <stdio.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stddef.h>
+#include <sys/shm.h>
+#include <sys/ipc.h>
+
+#include <dlog.h>
+#include <dynamicbox_errno.h> /* For error code */
+#include <dynamicbox_buffer.h>
+
+#include "debug.h"
+#include "util.h"
+#include "fb.h"
+
+int errno;
+
+struct fb_info {
+ char *id;
+ int w;
+ int h;
+ int bufsz;
+ void *buffer;
+
+ int pixels;
+ int handle;
+};
+
+static struct {
+} s_info = {
+};
+
+int fb_init(void *disp)
+{
+ return 0;
+}
+
+int fb_fini(void)
+{
+ return 0;
+}
+
+static inline void update_fb_size(struct fb_info *info)
+{
+ info->bufsz = info->w * info->h * info->pixels;
+}
+
+static inline int sync_for_file(struct fb_info *info)
+{
+ int fd;
+ struct buffer *buffer;
+
+ buffer = info->buffer;
+
+ if (!buffer) { /* Ignore this sync request */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (buffer->state != CREATED) {
+ ErrPrint("Invalid state of a FB\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (buffer->type != DBOX_BUFFER_TYPE_FILE) {
+ ErrPrint("Invalid buffer\n");
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ fd = open(util_uri_to_path(info->id), O_RDONLY);
+ if (fd < 0) {
+ ErrPrint("Failed to open a file (%s) because of (%s)\n",
+ util_uri_to_path(info->id), strerror(errno));
+
+ /*!
+ * \note
+ * But return ZERO, even if we couldn't get a buffer file,
+ * the viewer can draw empty screen.
+ *
+ * and then update it after it gots update events
+ */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (read(fd, buffer->data, info->bufsz) != info->bufsz) {
+ ErrPrint("read: %s\n", strerror(errno));
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
+
+ /*!
+ * \note
+ * But return ZERO, even if we couldn't get a buffer file,
+ * the viewer can draw empty screen.
+ *
+ * and then update it after it gots update events
+ */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (close(fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int fb_sync(struct fb_info *info, int x, int y, int w, int h)
+{
+ if (!info) {
+ ErrPrint("FB Handle is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!info->id || info->id[0] == '\0') {
+ DbgPrint("Ingore sync\n");
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) {
+ return sync_for_file(info);
+ } else if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
+ } else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM))) {
+ /* No need to do sync */
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+}
+
+struct fb_info *fb_create(const char *id, int w, int h)
+{
+ struct fb_info *info;
+
+ if (!id || id[0] == '\0') {
+ ErrPrint("Invalid ID\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->pixels = sizeof(int); /* Use the default pixels(depth) */
+
+ if (sscanf(info->id, SCHEMA_SHM "%d", &info->handle) == 1) {
+ DbgPrint("SHMID: %d is gotten\n", info->handle);
+ } else if (sscanf(info->id, SCHEMA_PIXMAP "%d:%d", &info->handle, &info->pixels) == 2) {
+ DbgPrint("PIXMAP-SHMID: %d is gotten (%d)\n", info->handle, info->pixels);
+ ErrPrint("Unsupported\n");
+ free(info);
+ return NULL;
+ } else {
+ info->handle = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ info->bufsz = 0;
+ info->buffer = NULL;
+ info->w = w;
+ info->h = h;
+
+ return info;
+}
+
+int fb_destroy(struct fb_info *info)
+{
+ if (!info) {
+ ErrPrint("Handle is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (info->buffer) {
+ struct buffer *buffer;
+ buffer = info->buffer;
+
+ buffer->info = NULL;
+ }
+
+ free(info->id);
+ free(info);
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int fb_is_created(struct fb_info *info)
+{
+ if (!info) {
+ ErrPrint("Handle is not valid\n");
+ return 0;
+ }
+
+ if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP)) && info->handle != 0) {
+ return 1;
+ } else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM)) && info->handle > 0) {
+ return 1;
+ } else {
+ const char *path;
+ path = util_uri_to_path(info->id);
+ if (path && access(path, F_OK | R_OK) == 0) {
+ return 1;
+ } else {
+ ErrPrint("access: %s (%s)\n", strerror(errno), path);
+ }
+ }
+
+ return 0;
+}
+
+void *fb_acquire_buffer(struct fb_info *info)
+{
+ struct buffer *buffer;
+
+ if (!info) {
+ ErrPrint("info == NIL\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!info->buffer) {
+ if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
+ ErrPrint("Unsupported Type\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ } else if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) {
+ update_fb_size(info);
+
+ buffer = calloc(1, sizeof(*buffer) + info->bufsz);
+ if (!buffer) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ info->bufsz = 0;
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
+ buffer->type = DBOX_BUFFER_TYPE_FILE;
+ buffer->refcnt = 0;
+ buffer->state = CREATED;
+ buffer->info = info;
+ info->buffer = buffer;
+
+ sync_for_file(info);
+ } else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM))) {
+ buffer = shmat(info->handle, NULL, 0);
+ if (buffer == (void *)-1) {
+ ErrPrint("shmat: %s (%d)\n", strerror(errno), info->handle);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_FAULT);
+ return NULL;
+ }
+
+ return buffer->data;
+ } else {
+ ErrPrint("Buffer is not created (%s)\n", info->id);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+ }
+
+ buffer = info->buffer;
+
+ switch (buffer->type) {
+ case DBOX_BUFFER_TYPE_FILE:
+ buffer->refcnt++;
+ break;
+ case DBOX_BUFFER_TYPE_PIXMAP:
+ default:
+ DbgPrint("Unknwon FP: %d\n", buffer->type);
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ break;
+ }
+
+ return buffer->data;
+}
+
+int fb_release_buffer(void *data)
+{
+ struct buffer *buffer;
+
+ if (!data) {
+ ErrPrint("buffer data == NIL\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ buffer = container_of(data, struct buffer, data);
+
+ if (buffer->state != CREATED) {
+ ErrPrint("Invalid handle\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (buffer->type) {
+ case DBOX_BUFFER_TYPE_SHM:
+ if (shmdt(buffer) < 0) {
+ ErrPrint("shmdt: %s\n", strerror(errno));
+ }
+ break;
+ case DBOX_BUFFER_TYPE_FILE:
+ buffer->refcnt--;
+ if (buffer->refcnt == 0) {
+ struct fb_info *info;
+ info = buffer->info;
+
+ buffer->state = DBOX_FB_STATE_DESTROYED;
+ free(buffer);
+
+ if (info && info->buffer == buffer) {
+ info->buffer = NULL;
+ }
+ }
+ break;
+ case DBOX_BUFFER_TYPE_PIXMAP:
+ default:
+ ErrPrint("Unknwon buffer type\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ break;
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int fb_refcnt(void *data)
+{
+ struct buffer *buffer;
+ struct shmid_ds buf;
+ int ret;
+
+ if (!data) {
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ buffer = container_of(data, struct buffer, data);
+
+ if (buffer->state != CREATED) {
+ ErrPrint("Invalid handle\n");
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (buffer->type) {
+ case DBOX_BUFFER_TYPE_SHM:
+ if (shmctl(buffer->refcnt, IPC_STAT, &buf) < 0) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_FAULT);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = buf.shm_nattch;
+ break;
+ case DBOX_BUFFER_TYPE_FILE:
+ ret = buffer->refcnt;
+ break;
+ case DBOX_BUFFER_TYPE_PIXMAP:
+ default:
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ return ret;
+}
+
+const char *fb_id(struct fb_info *info)
+{
+ return info ? info->id : NULL;
+}
+
+int fb_get_size(struct fb_info *info, int *w, int *h)
+{
+ if (!info) {
+ ErrPrint("Handle is not valid\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ *w = info->w;
+ *h = info->h;
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int fb_size(struct fb_info *info)
+{
+ if (!info) {
+ dynamicbox_set_last_status(DBOX_STATUS_ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ update_fb_size(info);
+
+ return info->bufsz;
+}
+
+int fb_type(struct fb_info *info)
+{
+ struct buffer *buffer;
+
+ if (!info) {
+ return DBOX_BUFFER_TYPE_ERROR;
+ }
+
+ buffer = info->buffer;
+ if (!buffer) {
+ int type = DBOX_BUFFER_TYPE_ERROR;
+ /*!
+ * \note
+ * Try to get this from SCHEMA
+ */
+ if (info->id) {
+ if (!strncasecmp(info->id, SCHEMA_FILE, strlen(SCHEMA_FILE))) {
+ type = DBOX_BUFFER_TYPE_FILE;
+ } else if (!strncasecmp(info->id, SCHEMA_PIXMAP, strlen(SCHEMA_PIXMAP))) {
+ /* Unsupported type */
+ } else if (!strncasecmp(info->id, SCHEMA_SHM, strlen(SCHEMA_SHM))) {
+ type = DBOX_BUFFER_TYPE_SHM;
+ }
+ }
+
+ return type;
+ }
+
+ return buffer->type;
+}
+/* End of a file */
diff --git a/dynamicbox_viewer/src/file_service.c b/dynamicbox_viewer/src/file_service.c
new file mode 100644
index 0000000..12e3000
--- /dev/null
+++ b/dynamicbox_viewer/src/file_service.c
@@ -0,0 +1,715 @@
+/*
+ * 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.
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <glib.h>
+
+#include <dlog.h>
+#include <secure_socket.h>
+#include <dynamicbox_errno.h>
+
+#include "client.h"
+#include "debug.h"
+#include "dlist.h"
+
+#define FILE_SERVICE_PORT 8209
+
+#define CRITICAL_SECTION_BEGIN(handle) \
+ do { \
+ int ret; \
+ ret = pthread_mutex_lock(handle); \
+ if (ret != 0) { \
+ ErrPrint("Failed to lock: %s\n", strerror(ret)); \
+ } \
+ } while (0)
+
+#define CRITICAL_SECTION_END(handle) \
+ do { \
+ int ret; \
+ ret = pthread_mutex_unlock(handle); \
+ if (ret != 0) { \
+ ErrPrint("Failed to unlock: %s\n", strerror(ret)); \
+ } \
+ } while (0)
+
+#define CANCEL_SECTION_BEGIN() do { \
+ int ret; \
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); \
+ if (ret != 0) { \
+ ErrPrint("Unable to set cancelate state: %s\n", strerror(ret)); \
+ } \
+} while (0)
+
+#define CANCEL_SECTION_END() do { \
+ int ret; \
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); \
+ if (ret != 0) { \
+ ErrPrint("Unable to set cancelate state: %s\n", strerror(ret)); \
+ } \
+} while (0)
+
+#define CLOSE_PIPE(p) do { \
+ int status; \
+ status = close(p[PIPE_READ]); \
+ if (status < 0) { \
+ ErrPrint("close: %s\n", strerror(errno)); \
+ } \
+ status = close(p[PIPE_WRITE]); \
+ if (status < 0) { \
+ ErrPrint("close: %s\n", strerror(errno)); \
+ } \
+} while (0)
+
+#define PIPE_READ 0
+#define PIPE_WRITE 1
+#define PIPE_MAX 2
+
+#define EVT_END_CH 'c'
+#define EVT_CH 'e'
+
+static struct {
+ pthread_t file_svc_thid;
+ pthread_mutex_t file_svc_lock;
+ int ctrl_pipe[PIPE_MAX];
+ int evt_pipe[PIPE_MAX];
+ struct dlist *request_list;
+ int file_service_fd;
+} s_info = {
+ .ctrl_pipe = { -1, -1 },
+ .evt_pipe = { -1, -1 },
+ .request_list = NULL,
+ .file_service_fd = -1,
+};
+
+struct request_item {
+ char *filename;
+ char *save_to;
+ void (*result_cb)(const char *filename, const char *save_to, int ret, void *data);
+ void *data;
+ int ret;
+};
+
+/*!
+ * File transfer header.
+ * This must should be shared with client.
+ */
+struct burst_head {
+ off_t size;
+ int flen;
+ char fname[];
+};
+
+struct burst_data {
+ int size;
+ char data[];
+};
+
+static inline int put_event_ch(int fd, char ch)
+{
+ int ret;
+
+ ret = write(fd, &ch, sizeof(ch));
+ if (ret != sizeof(ch)) {
+ ErrPrint("write: %s\n", strerror(errno));
+ return ret;
+ }
+
+ return 0;
+}
+
+static inline int get_event_ch(int fd)
+{
+ int ret;
+ char ch;
+
+ ret = read(fd, &ch, sizeof(ch));
+ if (ret != sizeof(ch)) {
+ ErrPrint("read: %s\n", strerror(errno));
+ return ret;
+ }
+
+ ret = (int)((unsigned int)ch);
+ return ret;
+}
+
+static inline int file_service_close(int fd)
+{
+ return secure_socket_destroy_handle(fd);
+}
+
+static inline int file_service_open(void)
+{
+ char *addr;
+ int port;
+ char *file_addr;
+ int len;
+ int fd;
+
+ addr = malloc(strlen(client_addr()) + 1);
+ if (!addr) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return -ENOMEM;
+ }
+
+ if (sscanf(client_addr(), COM_CORE_REMOTE_SCHEME"%[^:]:%d", addr, &port) != 2) {
+ ErrPrint("Invalid URL\n");
+ free(addr);
+ return -EINVAL;
+ }
+
+ len = strlen(COM_CORE_REMOTE_SCHEME);
+ len+= strlen(addr);
+ len+= 6; /* Port length? */
+
+ file_addr = malloc(len);
+ if (!file_addr) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ free(addr);
+ return -ENOMEM;
+ }
+
+ snprintf(file_addr, len, COM_CORE_REMOTE_SCHEME"%s:%d", addr, FILE_SERVICE_PORT);
+ DbgPrint("File service: %s\n", file_addr);
+ fd = secure_socket_create_client(file_addr);
+ free(file_addr);
+ free(addr);
+
+ return fd;
+}
+
+/*!
+ * Service Thread
+ */
+static void write_item_to_pipe(struct request_item *item, int ret)
+{
+ item->ret = DBOX_STATUS_ERROR_FAULT;
+ if (write(s_info.evt_pipe[PIPE_WRITE], &item, sizeof(item)) != sizeof(item)) {
+ ErrPrint("write: %s\n", strerror(errno));
+ free(item->filename);
+ free(item->save_to);
+ free(item);
+ item = NULL;
+ }
+}
+
+/*!
+ * Service Thread
+ */
+static void *file_service_main(void *data)
+{
+ int ret = 0;
+ int select_fd;
+ struct timeval tv;
+ fd_set set;
+ int offset;
+ enum {
+ RECV_INIT,
+ RECV_HEADER,
+ RECV_DATA,
+ } recv_state;
+ struct burst_head *head;
+ struct burst_data *body;
+ int recvsz;
+ struct request_item *item;
+ int file_offset;
+ int file_fd;
+
+ head = NULL;
+ item = NULL;
+ recv_state = RECV_INIT;
+ select_fd = (s_info.file_service_fd > s_info.ctrl_pipe[PIPE_READ] ? s_info.file_service_fd : s_info.ctrl_pipe[PIPE_READ]) + 1;
+ while (ret == 0) {
+ FD_ZERO(&set);
+ FD_SET(s_info.file_service_fd, &set);
+ FD_SET(s_info.ctrl_pipe[PIPE_READ], &set);
+
+ tv.tv_sec = 3;
+ tv.tv_usec = 0;
+ ret = select(select_fd , &set, NULL, NULL, &tv);
+ if (ret < 0) {
+ ret = -errno;
+ if (errno == EINTR) {
+ ErrPrint("INTERRUPTED\n");
+ ret = 0;
+ continue;
+ }
+ ErrPrint("Error: %s\n", strerror(errno));
+ break;
+ } else if (ret == 0) {
+ ErrPrint("Timeout\n");
+ ret = -ETIMEDOUT;
+ break;
+ }
+
+ if (item && FD_ISSET(s_info.file_service_fd, &set)) {
+ switch (recv_state) {
+ case RECV_INIT:
+ if (head == NULL) {
+ recvsz = sizeof(*head);
+
+ head = malloc(recvsz);
+ if (!head) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ ret = DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ }
+
+ offset = 0;
+ recv_state = RECV_HEADER;
+ }
+ case RECV_HEADER:
+ if (offset < recvsz) {
+ ret = secure_socket_recv(s_info.file_service_fd, (char *)head + offset, recvsz - offset, NULL);
+ if (ret > 0) {
+ offset += ret;
+ } else {
+ free(head);
+ head = NULL;
+ recv_state = RECV_INIT;
+ ret = DBOX_STATUS_ERROR_FAULT;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ }
+ }
+
+ if (offset == sizeof(*head)) {
+ void *tmp;
+
+ recvsz += head->flen;
+
+ tmp = realloc(head, recvsz);
+ if (!tmp) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+
+ free(head);
+ head = NULL;
+ recv_state = RECV_INIT;
+
+ ret = DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ }
+
+ head = tmp;
+ } else if (offset == recvsz) {
+ DbgPrint("Filesize: %d, name[%s]\n", head->size, head->fname);
+ if (strcmp(item->filename, head->fname)) {
+ ErrPrint("Invalid data sequence (%s <> %s)\n", item->filename, head->fname);
+
+ free(head);
+ head = NULL;
+ recv_state = RECV_INIT;
+ ret = DBOX_STATUS_ERROR_FAULT;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ }
+
+ file_fd = open(item->save_to, O_WRONLY|O_CREAT, 0644);
+ if (file_fd < 0) {
+ ErrPrint("open: %s\n", strerror(errno));
+ free(head);
+ head = NULL;
+ recv_state = RECV_INIT;
+
+ ret = DBOX_STATUS_ERROR_IO_ERROR;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ }
+
+ recv_state = RECV_DATA;
+ body = NULL;
+
+ } else {
+ ErrPrint("Invalid state\n");
+ free(head);
+ head = NULL;
+ recv_state = RECV_INIT;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ }
+ break;
+ case RECV_DATA:
+ if (!body) {
+ body = malloc(sizeof(*body));
+ if (!body) {
+ free(head);
+ head = NULL;
+ recv_state = RECV_INIT;
+ ret = DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ }
+
+ recvsz = sizeof(*body);
+ offset = 0;
+ }
+
+ ret = secure_socket_recv(s_info.file_service_fd, (char *)body + offset, recvsz - offset, NULL);
+ if (ret > 0) {
+ offset += ret;
+ } else {
+ free(head);
+ head = NULL;
+ free(body);
+ body = NULL;
+ recv_state = RECV_INIT;
+ ret = DBOX_STATUS_ERROR_FAULT;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ }
+
+ if (offset == sizeof(*body)) {
+ void *tmp;
+
+ if (body->size < 0) {
+ ErrPrint("body->size: %d\n", body->size);
+ free(head);
+ head = NULL;
+ free(body);
+ body = NULL;
+ recv_state = RECV_INIT;
+ ret = DBOX_STATUS_ERROR_FAULT;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ }
+
+ recvsz += body->size;
+
+ tmp = realloc(body, recvsz);
+ if (!tmp) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ free(head);
+ head = NULL;
+
+ free(body);
+ body = NULL;
+ recv_state = RECV_INIT;
+
+ ret = DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ }
+ } else if (offset == recvsz) {
+ /* Flush this to the file */
+ ret = write(file_fd, body->data, body->size);
+ if (ret < 0) {
+ ErrPrint("write: %s\n", strerror(errno));
+ free(head);
+ head = NULL;
+
+ free(body);
+ body = NULL;
+ recv_state = RECV_INIT;
+
+ ret = DBOX_STATUS_ERROR_IO_ERROR;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ } else {
+ if (body->size != ret) {
+ DbgPrint("Body is not flushed correctly: %d, %d\n", ret, body->size);
+ ret = body->size;
+ }
+
+ file_offset += ret;
+ if (file_offset == head->size) {
+ if (close(file_fd) < 0) {
+ ErrPrint("close: %s\n", strerror(errno));
+ }
+ ret = DBOX_STATUS_ERROR_NONE;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ }
+ }
+
+ free(body);
+ body = NULL;
+
+ free(head);
+ head = NULL;
+
+ recv_state = RECV_INIT;
+ } else {
+ ErrPrint("Invalid state\n");
+
+ ret = -EFAULT;
+ free(body);
+ body = NULL;
+ free(head);
+ head = NULL;
+ recv_state = RECV_INIT;
+
+ ret = DBOX_STATUS_ERROR_FAULT;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ }
+ break;
+ default:
+ ErrPrint("Unknown event: %d\n", recv_state);
+ ret = DBOX_STATUS_ERROR_FAULT;
+ write_item_to_pipe(item, ret);
+ item = NULL;
+ break;
+ }
+ } else if (item == NULL && recv_state == RECV_INIT && FD_ISSET(s_info.ctrl_pipe[PIPE_READ], &set)) {
+ int ch;
+ struct dlist *l;
+
+ /* Only if the recv state is not changed, we can get next request item */
+ ch = get_event_ch(s_info.ctrl_pipe[PIPE_READ]);
+ if (ch == EVT_END_CH) {
+ DbgPrint("Service thread is canceled\n");
+ break;
+ }
+
+ CRITICAL_SECTION_BEGIN(&s_info.file_svc_lock);
+ l = dlist_nth(s_info.request_list, 0);
+ item = dlist_data(l);
+ s_info.request_list = dlist_remove(s_info.request_list, l);
+ CRITICAL_SECTION_END(&s_info.file_svc_lock);
+ }
+ }
+
+ return (void *)ret;
+}
+
+/* Master */
+static gboolean evt_cb(GIOChannel *src, GIOCondition cond, gpointer data)
+{
+ int fd;
+ struct request_item *item;
+
+ fd = g_io_channel_unix_get_fd(src);
+
+ if (!(cond & G_IO_IN)) {
+ DbgPrint("Client is disconencted\n");
+ return FALSE;
+ }
+
+ if ((cond & G_IO_ERR) || (cond & G_IO_HUP) || (cond & G_IO_NVAL)) {
+ DbgPrint("Client connection is lost\n");
+ return FALSE;
+ }
+
+ if (read(fd, &item, sizeof(item)) != sizeof(item)) {
+ ErrPrint("read: %s\n", strerror(errno));
+ } else {
+ if (item->result_cb) {
+ item->result_cb(item->filename, item->save_to, item->ret, item->data);
+ }
+
+ free(item->filename);
+ free(item->save_to);
+ free(item);
+ }
+
+ return TRUE;
+}
+
+int file_service_send_request(const char *filename, const char *save_to, void (*result_cb)(const char *filename, const char *save_to, int ret, void *data), void *data)
+{
+ struct request_item *item;
+
+ item = malloc(sizeof(*item));
+ if (!item) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return -ENOMEM;
+ }
+
+ item->filename = strdup(filename);
+ if (!item->filename) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ free(item);
+ return -ENOMEM;
+ }
+
+ item->save_to = strdup(save_to);
+ if (!item->save_to) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ free(item->filename);
+ free(item);
+ return -ENOMEM;
+ }
+
+ item->result_cb = result_cb;
+ item->data = data;
+
+ CRITICAL_SECTION_BEGIN(&s_info.file_svc_lock);
+ s_info.request_list = dlist_append(s_info.request_list, item);
+ CRITICAL_SECTION_END(&s_info.file_svc_lock);
+ return 0;
+}
+
+int file_service_init(void)
+{
+ int status;
+ GIOChannel *gio;
+ guint id;
+
+ if (strncmp(client_addr(), COM_CORE_REMOTE_SCHEME, strlen(COM_CORE_REMOTE_SCHEME))) {
+ return 0;
+ }
+
+ s_info.file_service_fd = file_service_open();
+ if (s_info.file_service_fd < 0) {
+ return -EFAULT;
+ }
+
+ if (pipe2(s_info.ctrl_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {
+ ErrPrint("file service: %s\n", strerror(errno));
+ file_service_close(s_info.file_service_fd);
+ s_info.file_service_fd = -1;
+ return -EFAULT;
+ }
+
+ if (pipe2(s_info.evt_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {
+ ErrPrint("file service: %s\n", strerror(errno));
+ CLOSE_PIPE(s_info.ctrl_pipe);
+ file_service_close(s_info.file_service_fd);
+ s_info.file_service_fd = -1;
+ return -EFAULT;
+ }
+
+ status = pthread_mutex_init(&s_info.file_svc_lock, NULL);
+ if (status != 0) {
+ ErrPrint("Mutex: %s\n", strerror(status));
+ CLOSE_PIPE(s_info.ctrl_pipe);
+ CLOSE_PIPE(s_info.evt_pipe);
+ file_service_close(s_info.file_service_fd);
+ s_info.file_service_fd = -1;
+ return -EFAULT;
+ }
+
+ gio = g_io_channel_unix_new(s_info.evt_pipe[PIPE_READ]);
+ if (!gio) {
+ ErrPrint("io channel new\n");
+ status = pthread_mutex_destroy(&s_info.file_svc_lock);
+ if (status != 0) {
+ ErrPrint("destroy: %s\n", strerror(status));
+ }
+ CLOSE_PIPE(s_info.ctrl_pipe);
+ CLOSE_PIPE(s_info.evt_pipe);
+ file_service_close(s_info.file_service_fd);
+ s_info.file_service_fd = -1;
+ return -EFAULT;
+ }
+
+ g_io_channel_set_close_on_unref(gio, FALSE);
+
+ id = g_io_add_watch(gio, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, (GIOFunc)evt_cb, NULL);
+ if (id <= 0) {
+ GError *err = NULL;
+ ErrPrint("Failed to add IO watch\n");
+ g_io_channel_shutdown(gio, TRUE, &err);
+ if (err) {
+ ErrPrint("Shutdown: %s\n", err->message);
+ g_error_free(err);
+ }
+ g_io_channel_unref(gio);
+
+ status = pthread_mutex_destroy(&s_info.file_svc_lock);
+ if (status != 0) {
+ ErrPrint("destroy: %s\n", strerror(status));
+ }
+ CLOSE_PIPE(s_info.ctrl_pipe);
+ CLOSE_PIPE(s_info.evt_pipe);
+ file_service_close(s_info.file_service_fd);
+ s_info.file_service_fd = -1;
+ return -EIO;
+ }
+
+ status = pthread_create(&s_info.file_svc_thid, NULL, file_service_main, NULL);
+ if (status != 0) {
+ GError *err = NULL;
+ ErrPrint("Failed to add IO watch\n");
+ g_io_channel_shutdown(gio, TRUE, &err);
+ if (err) {
+ ErrPrint("Shutdown: %s\n", err->message);
+ g_error_free(err);
+ }
+ g_io_channel_unref(gio);
+
+ ErrPrint("file service: %s\n", strerror(status));
+ CLOSE_PIPE(s_info.ctrl_pipe);
+ CLOSE_PIPE(s_info.evt_pipe);
+ file_service_close(s_info.file_service_fd);
+ s_info.file_service_fd = -1;
+
+ status = pthread_mutex_destroy(&s_info.file_svc_lock);
+ if (status != 0) {
+ ErrPrint("destroy: %s\n", strerror(status));
+ }
+
+ return -EFAULT;
+ }
+
+ g_io_channel_unref(gio);
+ return 0;
+}
+
+int file_service_fini(void)
+{
+ void *svc_ret;
+ int ret;
+
+ if (strncmp(client_addr(), COM_CORE_REMOTE_SCHEME, strlen(COM_CORE_REMOTE_SCHEME))) {
+ return 0;
+ }
+
+ (void)put_event_ch(s_info.ctrl_pipe[PIPE_WRITE], EVT_END_CH);
+
+ ret = pthread_join(s_info.file_svc_thid, &svc_ret);
+ if (ret != 0) {
+ ErrPrint("join: %s\n", strerror(ret));
+ } else {
+ DbgPrint("file svc returns: %d\n", (int)svc_ret);
+ }
+
+ ret = pthread_mutex_destroy(&s_info.file_svc_lock);
+ if (ret != 0) {
+ ErrPrint("destroy: %s\n", strerror(ret));
+ }
+
+ CLOSE_PIPE(s_info.evt_pipe);
+ CLOSE_PIPE(s_info.ctrl_pipe);
+
+ return 0;
+}
+
+/* End of a file */
diff --git a/dynamicbox_viewer/src/master_rpc.c b/dynamicbox_viewer/src/master_rpc.c
new file mode 100644
index 0000000..8e8ea0e
--- /dev/null
+++ b/dynamicbox_viewer/src/master_rpc.c
@@ -0,0 +1,318 @@
+/*
+ * 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 <stdio.h>
+#include <gio/gio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <dlog.h>
+
+#include <packet.h>
+#include <com-core_packet.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_buffer.h>
+
+#include "debug.h"
+#include "dlist.h"
+#include "dynamicbox.h"
+#include "dynamicbox_internal.h"
+#include "master_rpc.h"
+#include "client.h"
+#include "util.h"
+
+#define DEFAULT_TTL 10
+#define REQUEST_DELAY 10
+
+struct command {
+ int ttl;
+ struct packet *packet;
+ dynamicbox_h handler;
+ void (*ret_cb)(dynamicbox_h handler, const struct packet *result, void *data);
+ void *data;
+ enum {
+ TYPE_ACK,
+ TYPE_NOACK
+ } type;
+};
+
+int errno;
+
+static struct {
+ guint cmd_timer;
+ struct dlist *cmd_list;
+} s_info = {
+ .cmd_timer = 0,
+ .cmd_list = NULL,
+};
+
+static int done_cb(pid_t pid, int handle, const struct packet *packet, void *data);
+
+static inline struct command *pop_command(void)
+{
+ struct dlist *l;
+ struct command *command;
+
+ l = dlist_nth(s_info.cmd_list, 0);
+ if (!l) {
+ return NULL;
+ }
+
+ command = dlist_data(l);
+ s_info.cmd_list = dlist_remove(s_info.cmd_list, l);
+ return command;
+}
+
+static inline struct command *create_command(dynamicbox_h handler, struct packet *packet)
+{
+ struct command *command;
+
+ command = malloc(sizeof(*command));
+ if (!command) {
+ ErrPrint("Failed to allocate mem for command\n");
+ return NULL;
+ }
+
+ command->handler = dbox_ref(handler);
+ command->packet = packet_ref(packet);
+ return command;
+}
+
+static inline void destroy_command(struct command *command)
+{
+ packet_unref(command->packet);
+ dbox_unref(command->handler, 1);
+ free(command);
+}
+
+static gboolean cmd_consumer(gpointer user_data)
+{
+ struct command *command;
+
+ command = pop_command();
+ if (!command) {
+ s_info.cmd_timer = 0;
+ return FALSE;
+ }
+
+ /*!
+ * \NOTE:
+ * Item will be deleted in the "done_cb"
+ *
+ * item->param be release by the g_dbus_proxy_call
+ * so to use it again from the done_cb function,
+ * increate the reference counter of the item->param
+ */
+ if (command->type == TYPE_NOACK) {
+ if (com_core_packet_send_only(client_fd(), command->packet) < 0) {
+ ErrPrint("Failed to send a packet to master\n");
+ }
+
+ destroy_command(command);
+ } else {
+ if (com_core_packet_async_send(client_fd(), command->packet, 0u, done_cb, command) < 0) {
+ ErrPrint("Failed to send a packet to master\n");
+ if (command->ret_cb) {
+ command->ret_cb(command->handler, NULL, command->data);
+ }
+ destroy_command(command);
+ }
+ }
+ return TRUE;
+}
+
+static inline void prepend_command(struct command *command)
+{
+ s_info.cmd_list = dlist_prepend(s_info.cmd_list, command);
+ master_rpc_check_and_fire_consumer();
+}
+
+void master_rpc_check_and_fire_consumer(void)
+{
+ if (!s_info.cmd_list || s_info.cmd_timer || client_fd() < 0) {
+ return;
+ }
+
+ s_info.cmd_timer = g_timeout_add(REQUEST_DELAY, cmd_consumer, NULL);
+ if (!s_info.cmd_timer) {
+ ErrPrint("Failed to add timer\n");
+ }
+}
+
+static int done_cb(pid_t pid, int handle, const struct packet *packet, void *data)
+{
+ struct command *command;
+ int ret;
+
+ command = data;
+
+ if (!packet) {
+ /*! \NOTE:
+ * Release resource even if
+ * we failed to finish the method call
+ */
+ command->ttl--;
+ if (command->ttl > 0) {
+ prepend_command(command);
+ return 0;
+ }
+
+ goto out;
+ }
+
+ if (packet_get(packet, "i", &ret) != 1) {
+ ErrPrint("Invalid result packet\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+out:
+ if (command->ret_cb) {
+ command->ret_cb(command->handler, packet, command->data);
+ }
+
+ destroy_command(command);
+ return 0;
+}
+
+static inline void push_command(struct command *command)
+{
+ s_info.cmd_list = dlist_append(s_info.cmd_list, command);
+ master_rpc_check_and_fire_consumer();
+}
+
+/*!
+ * \note
+ * "handler" could be NULL
+ */
+int master_rpc_async_request(dynamicbox_h handler, struct packet *packet, int urgent, void (*ret_cb)(dynamicbox_h handler, const struct packet *result, void *data), void *data)
+{
+ struct command *command;
+
+ command = create_command(handler, packet);
+ if (!command) {
+ ErrPrint("Failed to create a command\n");
+ packet_unref(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ command->ret_cb = ret_cb;
+ command->data = data;
+ command->ttl = DEFAULT_TTL;
+ command->type = TYPE_ACK;
+
+ if (urgent) {
+ prepend_command(command);
+ } else {
+ push_command(command);
+ }
+
+ packet_unref(packet);
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int master_rpc_request_only(dynamicbox_h handler, struct packet *packet)
+{
+ struct command *command;
+
+ command = create_command(handler, packet);
+ if (!command) {
+ ErrPrint("Failed to create a command\n");
+ packet_unref(packet);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ command->ret_cb = NULL;
+ command->data = NULL;
+ command->ttl = 0;
+ command->type = TYPE_NOACK;
+
+ push_command(command);
+ packet_unref(packet);
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int master_rpc_clear_fault_package(const char *pkgname)
+{
+ struct dlist *l;
+ struct dlist *n;
+ struct command *command;
+
+ if (!pkgname) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ dlist_foreach_safe(s_info.cmd_list, l, n, command) {
+ if (!command->handler) {
+ continue;
+ }
+
+ if (!strcmp(command->handler->common->pkgname, pkgname)) {
+ s_info.cmd_list = dlist_remove(s_info.cmd_list, l);
+ if (command->ret_cb) {
+ command->ret_cb(command->handler, NULL, command->data);
+ }
+
+ destroy_command(command);
+ }
+ }
+
+ return 0;
+}
+
+int master_rpc_clear_all_request(void)
+{
+ struct command *command;
+ struct dlist *l;
+ struct dlist *n;
+
+ dlist_foreach_safe(s_info.cmd_list, l, n, command) {
+ s_info.cmd_list = dlist_remove(s_info.cmd_list, l);
+
+ if (command->ret_cb) {
+ command->ret_cb(command->handler, NULL, command->data);
+ }
+
+ destroy_command(command);
+ }
+
+ return 0;
+}
+
+int master_rpc_sync_request(struct packet *packet)
+{
+ struct packet *result;
+ int ret;
+
+ result = com_core_packet_oneshot_send(client_addr(), packet, 0.0f);
+ if (result) {
+ if (packet_get(result, "i", &ret) != 1) {
+ ErrPrint("Invalid result packet\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ packet_unref(result);
+ } else {
+ ErrPrint("Failed to send a sync request\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ }
+
+ packet_unref(packet);
+ return ret;
+}
+
+/* End of a file */
diff --git a/dynamicbox_viewer/src/util.c b/dynamicbox_viewer/src/util.c
new file mode 100644
index 0000000..59204ec
--- /dev/null
+++ b/dynamicbox_viewer/src/util.c
@@ -0,0 +1,150 @@
+/*
+ * 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 <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include <dlog.h>
+#include <dynamicbox_errno.h> /* For error code */
+
+#include "debug.h"
+#include "util.h"
+
+int errno;
+#if defined(_USE_ECORE_TIME_GET)
+static struct {
+ clockid_t type;
+} s_info = {
+ .type = CLOCK_MONOTONIC,
+};
+#endif
+
+int util_check_extension(const char *filename, const char *check_ptr)
+{
+ int name_len;
+
+ name_len = strlen(filename);
+ while (--name_len >= 0 && *check_ptr) {
+ if (filename[name_len] != *check_ptr) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ check_ptr ++;
+ }
+
+ return 0;
+}
+
+double util_timestamp(void)
+{
+#if defined(_USE_ECORE_TIME_GET)
+ struct timespec ts;
+
+ do {
+ if (clock_gettime(s_info.type, &ts) == 0) {
+ return ts.tv_sec + ts.tv_nsec / 1000000000.0f;
+ }
+
+ ErrPrint("%d: %s\n", s_info.type, strerror(errno));
+ if (s_info.type == CLOCK_MONOTONIC) {
+ s_info.type = CLOCK_REALTIME;
+ } else if (s_info.type == CLOCK_REALTIME) {
+ struct timeval tv;
+ if (gettimeofday(&tv, NULL) < 0) {
+ ErrPrint("gettimeofday: %s\n", strerror(errno));
+ break;
+ }
+
+ return tv.tv_sec + tv.tv_usec / 1000000.0f;
+ }
+ } while (1);
+
+ return 0.0f;
+#else
+ struct timeval tv;
+
+ if (gettimeofday(&tv, NULL) < 0) {
+ ErrPrint("gettimeofday: %s\n", strerror(errno));
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ }
+
+ return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f;
+#endif
+}
+
+const char *util_basename(const char *name)
+{
+ int length;
+ length = name ? strlen(name) : 0;
+ if (!length) {
+ return ".";
+ }
+
+ while (--length > 0 && name[length] != '/');
+
+ return length <= 0 ? name : name + length + (name[length] == '/');
+}
+
+const char *util_uri_to_path(const char *uri)
+{
+ int len;
+
+ len = strlen(SCHEMA_FILE);
+ if (strncasecmp(uri, SCHEMA_FILE, len)) {
+ return NULL;
+ }
+
+ return uri + len;
+}
+
+int util_unlink(const char *filename)
+{
+ char *descfile;
+ int desclen;
+ int ret;
+
+ if (!filename) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ desclen = strlen(filename) + 6; /* .desc */
+ descfile = malloc(desclen);
+ if (!descfile) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ ret = snprintf(descfile, desclen, "%s.desc", filename);
+ if (ret < 0) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ free(descfile);
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ (void)unlink(descfile);
+ free(descfile);
+ (void)unlink(filename);
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+/* End of a file */
diff --git a/include/dlist.h b/include/dlist.h
deleted file mode 100644
index cd1a421..0000000
--- a/include/dlist.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-
-#define dlist_remove_data(list, data) do { \
- 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); (l) && ((data) = dlist_data(l)); (l) = dlist_next(l))
-
-#define dlist_foreach_safe(list, l, n, data) \
- for ((l) = (list), (n) = dlist_next(l); \
- (l) && ((data) = dlist_data(l)); \
- (l) = (n), (n) = dlist_next(l))
-
-struct dlist;
-
-extern struct dlist *dlist_append(struct dlist *list, void *data);
-extern struct dlist *dlist_prepend(struct dlist *list, void *data);
-extern struct dlist *dlist_remove(struct dlist *list, struct dlist *l);
-extern struct dlist *dlist_find_data(struct dlist *list, void *data);
-extern void *dlist_data(struct dlist *l);
-extern struct dlist *dlist_next(struct dlist *l);
-extern struct dlist *dlist_prev(struct dlist *l);
-extern int dlist_count(struct dlist *l);
-extern struct dlist *dlist_nth(struct dlist *l, int nth);
-
-/* End of a file */
diff --git a/include/livebox.h b/include/livebox.h
deleted file mode 100644
index 2e00248..0000000
--- a/include/livebox.h
+++ /dev/null
@@ -1,1753 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef __LIVEBOX_H
-#define __LIVEBOX_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*!
- * \addtogroup CAPI_LIVEBOX_VIEWER_MODULE
- * \{
- */
-
-/*!
- * \brief
- * Structure for a Livebox instance
- */
-struct livebox;
-
-/*!
- * \brief
- * Use the default update period which is defined in the package manifest file of a livebox.
- */
-#define DEFAULT_PERIOD -1.0f
-
-/*!
- * \brief
- * Mouse & Key event for buffer type Livebox or PD
- * Viewer should send these events to livebox.
- */
-enum content_event_type {
- CONTENT_EVENT_MOUSE_DOWN = 0x00000001, /*!< LB mouse down event for livebox */
- CONTENT_EVENT_MOUSE_UP = 0x00000002, /*!< LB mouse up event for livebox */
- CONTENT_EVENT_MOUSE_MOVE = 0x00000004, /*!< LB mouse move event for livebox */
- CONTENT_EVENT_MOUSE_ENTER = 0x00000008, /*!< LB mouse enter event for livebox */
- CONTENT_EVENT_MOUSE_LEAVE = 0x00000010, /*!< LB mouse leave event for livebox */
- CONTENT_EVENT_MOUSE_SET = 0x00000020, /*!< LB mouse set auto event for livebox */
- CONTENT_EVENT_MOUSE_UNSET = 0x00000040, /*!< LB mouse unset auto event for livebox */
-
- CONTENT_EVENT_KEY_DOWN = 0x00000001, /*!< LB key press */
- CONTENT_EVENT_KEY_UP = 0x00000002, /*!< LB key release */
- CONTENT_EVENT_KEY_FOCUS_IN = 0x00000008, /*!< LB key focused in */
- CONTENT_EVENT_KEY_FOCUS_OUT = 0x00000010, /*!< LB key focused out */
- CONTENT_EVENT_KEY_SET = 0x00000020, /*!< LB Key, start feeding event by master */
- CONTENT_EVENT_KEY_UNSET = 0x00000040, /*!< LB key, stop feeding event by master */
-
- CONTENT_EVENT_ON_SCROLL = 0x00000080, /*!< LB On scrolling */
- CONTENT_EVENT_ON_HOLD = 0x00000100, /*!< LB On holding */
- CONTENT_EVENT_OFF_SCROLL = 0x00000200, /*!< LB Stop scrolling */
- CONTENT_EVENT_OFF_HOLD = 0x00000400, /*!< LB Stop holding */
-
- CONTENT_EVENT_KEY_MASK = 0x80000000,
- CONTENT_EVENT_MOUSE_MASK = 0x20000000,
- CONTENT_EVENT_PD_MASK = 0x10000000,
- CONTENT_EVENT_LB_MASK = 0x40000000,
-
- LB_MOUSE_ON_SCROLL = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_ON_SCROLL, /*!< Mouse event occurs while scrolling */
- LB_MOUSE_ON_HOLD = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_ON_HOLD, /*!< Mouse event occurs on holding */
- LB_MOUSE_OFF_SCROLL = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_OFF_SCROLL, /*!< Scrolling stopped */
- LB_MOUSE_OFF_HOLD = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_OFF_HOLD, /*!< Holding stopped */
-
- LB_MOUSE_DOWN = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_DOWN, /*!< Mouse down on the livebox */
- LB_MOUSE_UP = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UP, /*!< Mouse up on the livebox */
- LB_MOUSE_MOVE = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_MOVE, /*!< Move move on the livebox */
- LB_MOUSE_ENTER = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_ENTER, /*!< Mouse enter to the livebox */
- LB_MOUSE_LEAVE = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_LEAVE, /*!< Mouse leave from the livebox */
- LB_MOUSE_SET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_SET, /*!< Mouse event, start feeding event by master */
- LB_MOUSE_UNSET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UNSET, /*!< Mouse event, stop feeding event by master */
-
- PD_MOUSE_ON_SCROLL = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_ON_SCROLL, /*!< Mouse event occurs while scrolling */
- PD_MOUSE_ON_HOLD = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_ON_HOLD, /*!< Mouse event occurs on holding */
- PD_MOUSE_OFF_SCROLL = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_OFF_SCROLL, /*!< Scrolling stopped */
- PD_MOUSE_OFF_HOLD = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_OFF_HOLD, /*!< Holding stopped */
-
- PD_MOUSE_DOWN = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_DOWN, /*!< Mouse down on the PD */
- PD_MOUSE_UP = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UP, /*!< Mouse up on the PD */
- PD_MOUSE_MOVE = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_MOVE, /*!< Mouse move on the PD */
- PD_MOUSE_ENTER = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_ENTER, /*!< Mouse enter to the PD */
- PD_MOUSE_LEAVE = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_LEAVE, /*!< Mouse leave from the PD */
- PD_MOUSE_SET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_SET, /*!< Mouse event, start feeding event by master */
- PD_MOUSE_UNSET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_MOUSE_MASK | CONTENT_EVENT_MOUSE_UNSET, /*!< Mouse event, stop feeding event by master */
-
- LB_KEY_DOWN = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_DOWN, /*!< Key down on the livebox */
- LB_KEY_UP = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UP, /*!< Key up on the livebox */
- LB_KEY_SET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_SET, /*!< Key event, start feeding event by master */
- LB_KEY_UNSET = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UNSET, /*!< Key event, stop feeding event by master */
- LB_KEY_FOCUS_IN = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_FOCUS_IN, /*!< Key event, focus in */
- LB_KEY_FOCUS_OUT = CONTENT_EVENT_LB_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_FOCUS_OUT, /*!< Key event, foucs out */
-
- PD_KEY_DOWN = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_DOWN, /*!< Key down on the livebox */
- PD_KEY_UP = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UP, /*!< Key up on the livebox */
- PD_KEY_SET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_SET, /*!< Key event, start feeding event by master */
- PD_KEY_UNSET = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_UNSET, /*!< Key event, stop feeding event by master */
- PD_KEY_FOCUS_IN = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_FOCUS_IN, /*!< Key event, focus in */
- PD_KEY_FOCUS_OUT = CONTENT_EVENT_PD_MASK | CONTENT_EVENT_KEY_MASK | CONTENT_EVENT_KEY_FOCUS_OUT, /*!< Key event, focus out */
-
- CONTENT_EVENT_MAX = 0xFFFFFFFF
-};
-
-/*!
- * \brief
- * Accessibility event for buffer type Livebox or PD.
- * These event set are sync'd with Tizen accessibility event set.
- */
-enum access_event_type {
- ACCESS_EVENT_PD_MASK = 0x10000000,
- ACCESS_EVENT_LB_MASK = 0x20000000,
-
- ACCESS_EVENT_HIGHLIGHT = 0x00000100, /*!< LB accessibility: Hightlight a object */
- ACCESS_EVENT_HIGHLIGHT_NEXT = 0x00000200, /*!< LB accessibility: Set highlight to next object */
- ACCESS_EVENT_HIGHLIGHT_PREV = 0x00000400, /*!< LB accessibility: Set highlight to prev object */
- ACCESS_EVENT_UNHIGHLIGHT = 0x00000800, /*!< LB accessibility unhighlight */
- ACCESS_EVENT_ACTIVATE = 0x00001000, /*!< LB accessibility activate */
- ACCESS_EVENT_ACTION_DOWN = 0x00010000, /*!< LB accessibility value changed */
- ACCESS_EVENT_ACTION_UP = 0x00020000, /*!< LB accessibility value changed */
- ACCESS_EVENT_SCROLL_DOWN = 0x00100000, /*!< LB accessibility scroll down */
- ACCESS_EVENT_SCROLL_MOVE = 0x00200000, /*!< LB accessibility scroll move */
- ACCESS_EVENT_SCROLL_UP = 0x00400000, /*!< LB accessibility scroll up */
-
- LB_ACCESS_HIGHLIGHT = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_HIGHLIGHT, /*!< Access event - Highlight an object in the livebox */
- LB_ACCESS_HIGHLIGHT_NEXT = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_HIGHLIGHT_NEXT, /*!< Access event - Move highlight to the next object in a livebox */
- LB_ACCESS_HIGHLIGHT_PREV = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_HIGHLIGHT_PREV, /*!< Access event - Move highlight to the prev object in a livebox */
- LB_ACCESS_UNHIGHLIGHT = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_UNHIGHLIGHT, /*!< Access event - Delete highlight from the livebox */
- LB_ACCESS_ACTIVATE = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_ACTIVATE, /*!< Access event - Launch or activate the highlighted object */
- LB_ACCESS_ACTION_DOWN = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_ACTION_DOWN, /*!< Access event - down */
- LB_ACCESS_ACTION_UP = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_ACTION_UP, /*!< Access event - up */
- LB_ACCESS_SCROLL_DOWN = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_SCROLL_DOWN, /*!< Access event - scroll down */
- LB_ACCESS_SCROLL_MOVE = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_SCROLL_MOVE, /*!< Access event - scroll move */
- LB_ACCESS_SCROLL_UP = ACCESS_EVENT_LB_MASK | ACCESS_EVENT_SCROLL_UP, /*!< Access event - scroll up */
-
- PD_ACCESS_HIGHLIGHT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT, /*!< Access event - Highlight an object in the PD */
- PD_ACCESS_HIGHLIGHT_NEXT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT_NEXT, /*!< Access event - Move highlight to the next object in a PD */
- PD_ACCESS_HIGHLIGHT_PREV = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_HIGHLIGHT_PREV, /*!< Access event - Move highlight to the prev object in a PD */
- PD_ACCESS_UNHIGHLIGHT = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_UNHIGHLIGHT, /*!< Access event - Delet highlight from the PD */
- PD_ACCESS_ACTIVATE = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_ACTIVATE, /*!< Access event - Launch or activate the highlighted object */
- PD_ACCESS_ACTION_DOWN = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_ACTION_DOWN, /*!< Access event - down */
- PD_ACCESS_ACTION_UP = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_ACTION_UP, /*!< Access event - up */
- PD_ACCESS_SCROLL_DOWN = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_SCROLL_DOWN, /*!< Access event - scroll down */
- PD_ACCESS_SCROLL_MOVE = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_SCROLL_MOVE, /*!< Access event - scroll move */
- PD_ACCESS_SCROLL_UP = ACCESS_EVENT_PD_MASK | ACCESS_EVENT_SCROLL_UP /*!< Access event - scroll up */
-};
-
-/*!
- * \brief
- * Livebox LB content type
- */
-enum livebox_lb_type {
- LB_TYPE_IMAGE = 0x01, /*!< Contents of a livebox is based on the image file */
- LB_TYPE_BUFFER = 0x02, /*!< Contents of a livebox is based on canvas buffer(shared) */
- LB_TYPE_TEXT = 0x04, /*!< Contents of a livebox is based on formatted text file */
- LB_TYPE_PIXMAP = 0x08, /*!< Contens of a livebox is shared by the pixmap(depends on X) */
-
- LB_TYPE_INVALID = 0xFF
-};
-
-/*!
- * \brief
- * Livebox PD content type
- */
-enum livebox_pd_type {
- PD_TYPE_BUFFER = 0x01, /*!< Contents of a PD is based on canvas buffer(shared) */
- PD_TYPE_TEXT = 0x02, /*!< Contents of a PD is based on formatted text file */
- PD_TYPE_PIXMAP = 0x04, /*!< Contents of a livebox is shared by the pixmap(depends on X) */
-
- PD_TYPE_INVALID = 0xFF
-};
-
-/*!
- * \brief
- * Livebox event type.
- * These event will be sent from the provider.
- */
-enum livebox_event_type { /*!< livebox_event_handler_set Event list */
- LB_EVENT_LB_UPDATED, /*!< Contents of the given livebox is updated */
- LB_EVENT_PD_UPDATED, /*!< Contents of the given pd is updated */
-
- LB_EVENT_CREATED, /*!< A new livebox is created */
- LB_EVENT_DELETED, /*!< A livebox is deleted */
-
- LB_EVENT_GROUP_CHANGED, /*!< Group (Cluster/Sub-cluster) information is changed */
- LB_EVENT_PINUP_CHANGED, /*!< PINUP status is changed */
- LB_EVENT_PERIOD_CHANGED, /*!< Update period is changed */
-
- LB_EVENT_LB_SIZE_CHANGED, /*!< Livebox size is changed */
- LB_EVENT_PD_SIZE_CHANGED, /*!< PD size is changed */
-
- LB_EVENT_PD_CREATED, /*!< If a PD is created even if you didn't call the livebox_create_pd API */
- LB_EVENT_PD_DESTROYED, /*!< If a PD is destroyed even if you didn't call the livebox_destroy_pd API */
-
- LB_EVENT_HOLD_SCROLL, /*!< If the screen should be freezed */
- LB_EVENT_RELEASE_SCROLL, /*!< If the screen can be scrolled */
-
- LB_EVENT_LB_UPDATE_BEGIN, /*!< Livebox LB content update is started */
- LB_EVENT_LB_UPDATE_END, /*!< Livebox LB content update is finished */
-
- LB_EVENT_PD_UPDATE_BEGIN, /*!< Livebox PD content update is started */
- LB_EVENT_PD_UPDATE_END, /*!< Livebox PD content update is finished */
-
- LB_EVENT_UPDATE_MODE_CHANGED, /*!< Livebox Update mode is changed */
-
- LB_EVENT_REQUEST_CLOSE_PD, /*!< Livebox requests to close the PD */
-
- LB_EVENT_IGNORED /*!< Request is ignored */
-};
-
-enum livebox_option_type {
- LB_OPTION_MANUAL_SYNC, /*!< Sync manually */
- LB_OPTION_FRAME_DROP_FOR_RESIZE, /*!< Drop frames while resizing */
- LB_OPTION_SHARED_CONTENT, /*!< Use only one real instance for multiple fake instances if user creates it using same content */
-
- LB_OPTION_ERROR = 0xFFFFFFFF /*!< To specify the size of this enumeration type */
-};
-
-enum livebox_fault_type {
- LB_FAULT_DEACTIVATED, /*!< Livebox is deactivated by its fault operation */
- LB_FAULT_PROVIDER_DISCONNECTED /*!< Provider is disconnected */
-};
-
-/*!
- * \brief
- * Must be sync'd with the provider
- */
-enum livebox_visible_state {
- LB_SHOW = 0x00, /*!< Livebox is shown. Default state */
- LB_HIDE = 0x01, /*!< Livebox is hidden, Update timer will not be freezed. but you cannot receive any updates events. */
-
- LB_HIDE_WITH_PAUSE = 0x02, /*!< Livebix is hidden, it will pause the update timer, but if a livebox updates its contents, update event will be triggered */
-
- LB_VISIBLE_ERROR = 0xFFFFFFFF /*!< To specify the size of this enumeration type */
-};
-
-/*!
- * \brief
- * TEXT type livebox contents handling opertators.
- */
-struct livebox_script_operators {
- int (*update_begin)(struct livebox *handle); /*!< Content parser is started */
- int (*update_end)(struct livebox *handle); /*!< Content parser is finished */
-
- /*!
- * \brief
- * Listed functions will be called when parser meets each typed content
- */
- int (*update_text)(struct livebox *handle, const char *id, const char *part, const char *data); /*!< Update text content */
- int (*update_image)(struct livebox *handle, const char *id, const char *part, const char *data, const char *option); /*!< Update image content */
- int (*update_script)(struct livebox *handle, const char *id, const char *new_id, const char *part, const char *file, const char *group); /*!< Update script content */
- int (*update_signal)(struct livebox *handle, const char *id, const char *emission, const char *signal); /*!< Update signal */
- int (*update_drag)(struct livebox *handle, const char *id, const char *part, double dx, double dy); /*!< Update drag info */
- int (*update_info_size)(struct livebox *handle, const char *id, int w, int h); /*!< Update content size */
- int (*update_info_category)(struct livebox *handle, const char *id, const char *category); /*!< Update content category info */
- int (*update_access)(struct livebox *handle, const char *id, const char *part, const char *text, const char *option); /*!< Update access information */
- int (*operate_access)(struct livebox *handle, const char *id, const char *part, const char *operation, const char *option); /*!< Update access operation */
- int (*update_color)(struct livebox *handle, const char *id, const char *part, const char *data); /*!< Update color */
-};
-
-/*!
- * \brief Prototype of the return callback of every async functions
- * \details N/A
- * \remarks N/A
- * \param[in] handle Handle of the livebox instance
- * \param[in] ret Result status of operation. LB_STATUS_XXX defined from liblivebox-service
- * \param[in] data data for result callback
- * \return void
- * \pre N/A
- * \post N/A
- * \see livebox_add
- * \see livebox_add_with_size
- * \see livebox_del
- * \see livebox_activate
- * \see livebox_resize
- * \see livebox_set_group
- * \see livebox_set_period
- * \see livebox_access_event
- * \see livebox_set_pinup
- * \see livebox_create_pd
- * \see livebox_create_pd_with_position
- * \see livebox_destroy_pd
- * \see livebox_emit_text_signal
- * \see livebox_acquire_pd_pixmap
- * \see livebox_acquire_lb_pixmap
- * \see livebox_set_update_mode
- */
-typedef void (*ret_cb_t)(struct livebox *handle, int ret, void *data);
-
-/*!
- * \brief Initialize the livebox system
- * \details N/A
- * \remarks
- * This API uses get/setenv APIs.
- * Those APIs are not thread-safe.
- * So you have to consider to use the livebox_init_with_options instead of this if you are developing multi-threaded viewer.
- * \param[in] disp If you have X Display connection object already, you can re-use it. but you should care its life cycle.
- * It must be alive before call the livebox_fini
- * \return int
- * \retval LB_STATUS_SUCCESS if success
- * \pre N/A
- * \post N/A
- * \see livebox_fini
- * \see livebox_init_with_options
- */
-extern int livebox_init(void *disp);
-
-/*!
- * \brief Initialize the livebox system with some options
- * \details livebox_init function uses environment value to initiate some configurable values
- * But some application doesn't want to use the env value.
- * For them, this API will give a chance to set default options using given arguments
- * \remarks N/A
- * \param[in] disp if this display is NULL, the library will try to acquire a new connection with X
- * \param[in] prevent_overwrite If the content of image type livebox is updated, don't overwrite it(1) or overwrite old file(0)
- * \param[in] event_filter If the next event comes in this period, ignore it. It is too fast to processing it in time.
- * \param[in] use_thread Use the receive thread.
- * \return int Integer, Livebox status code
- * \retval LB_STATUS_SUCCESS if success
- * \pre N/A
- * \post N/A
- * \see livebox_init
- * \see livebox_fini
- */
-extern int livebox_init_with_options(void *disp, int prevent_overwrite, double event_filter, int use_thread);
-
-/*!
- * \brief Finalize the livebox system
- * \details N/A
- * \remarks N/A
- * \return int
- * \retval LB_STATUS_SUCCES if success
- * \retval LB_STATUS_ERROR_INVALID if livebox_init is not called.
- * \pre N/A
- * \post N/A
- * \see livebox_init
- * \see livebox_init_with_options
- */
-extern int livebox_fini(void);
-
-/*!
- * \brief Notify the status of client to the provider. "it is paused".
- * \details N/A
- * \remarks N/A
- * \return int
- * \retval LB_STATUS_SUCCESS if success
- * \retval LB_STATUS_ERROR_FAULT if it failed to send state(paused) info
- * \pre N/A
- * \post N/A
- * \see livebox_client_resumed
- */
-extern int livebox_client_paused(void);
-
-/*!
- * \brief Notify the status of client to the provider. "it is resumed".
- * \details N/A
- * \remarks N/A
- * \return int
- * \retval LB_STATUS_SUCCESS if success
- * \retval LB_STATUS_ERROR_FAULT if it failed to send state(resumed) info
- * \pre N/A
- * \post N/A
- * \see livebox_client_paused
- */
-extern int livebox_client_resumed(void);
-
-/*!
- * \brief Add a new livebox
- * \details N/A
- * \remarks
- * Even though you get the livebox handle from return value of this function,
- * it is not matured before return callback called.
- * You have to use the handle after get the return callback with "ret == LB_STATUS_SUCCESS"
- * \param[in] pkgname Livebox Id
- * \param[in] content Will be passed to the livebox instance.
- * \param[in] cluster Main group
- * \param[in] category Sub group
- * \param[in] period Update period. if you set DEFAULT_PERIOD, the provider will use the default period which is described in the manifest.
- * \param[in] cb After send the request to the provider, its result will be passed
- * \param[in] data
- * \return handle
- * \retval NULL if it fails to add a new instance
- * \retval handle livebox handle
- * \pre N/A
- * \post
- * \see ret_cb_t
- * \see livebox_add_with_size
- */
-extern struct livebox *livebox_add(const char *pkgname, const char *content, const char *cluster, const char *category, double period, ret_cb_t cb, void *data);
-
-/*!
- * \brief Add a new livebox
- * \details
- * If the screen size if "1280x720"
- * Below size lists are used for default.
- * Or you can find the default sizes in pixel from /usr/share/data-provider-master/resolution.ini
- * Size types are defined from the liblivebox-service package. (livebox-service.h)
- *
- * Normal mode livebox
- * 1x1=175x175, LB_SIZE_TYPE_1x1
- * 2x1=354x175, LB_SIZE_TYPE_2x1
- * 2x2=354x354, LB_SIZE_TYPE_2x2
- * 4x1=712x175, LB_SIZE_TYPE_4x1
- * 4x2=712x354, LB_SIZE_TYPE_4x2
- * 4x4=712x712, LB_SIZE_TYPE_4x4
- *
- * Extended sizes
- * 4x3=712x533, LB_SIZE_TYPE_4x3
- * 4x5=712x891, LB_SIZE_TYPE_4x5
- * 4x6=712x1070, LB_SIZE_TYPE_4x6
- *
- * Easy mode livebox
- * 21x21=224x215, LB_SIZE_TYPE_EASY_1x1
- * 23x21=680x215, LB_SIZE_TYPE_EASY_3x1
- * 23x23=680x653, LB_SIZE_TYPE_EASY_3x3
- *
- * Special livebox
- * 0x0=720x1280, LB_SIZE_TYPE_0x0
- *
- * \remarks
- * Even if you get the handle by return value of this function, it is not created instance.
- * So you have to deal it as not initialized handle.
- * Only it can be initialized after get the return callback with "ret == LB_STATUS_SUCCESS".
- * \param[in] pkgname Livebox Id
- * \param[in] content Will be passed to the livebox instance.
- * \param[in] cluster Main group
- * \param[in] category Sub group
- * \param[in] period DEFAULT_PERIOD can be used for this. this argument will be used to specify the period of update content of livebox.
- * \param[in] type Size type - which are defined from liblivebox-service package.
- * \param[in] cb After the request is sent to the master provider, this callback will be called.
- * \param[in] data This data will be passed to the callback.
- * \return handle
- * \retval handle Livebox handle but not yet initialized
- * \retval NULL if it fails to create a handle
- * \see ret_cb_t
- * \see livebox_add
- */
-extern struct livebox *livebox_add_with_size(const char *pkgname, const char *content, const char *cluster, const char *category, double period, int type, ret_cb_t cb, void *data);
-
-/*!
- * \brief Delete a livebox (deprecated)
- * \details N/A
- * \remarks
- * If you call this with uninitialized handle, the return callback will be called synchronously.
- * So before return from this function, the return callback will be called first.
- * \param[in] handler Handler of a livebox instance
- * \param[in] cb return callback
- * \param[in] data user data for return callback
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY already in process
- * \retval LB_STATUS_ERROR_FAULT failed to create a request packet
- * \retval LB_STATUS_SUCCESS successfully sent, return callack will be called
- * \pre N/A
- * \post N/A
- * \see ret_cb_t
- */
-extern int livebox_del(struct livebox *handler, ret_cb_t cb, void *data);
-
-/*!
- * \brief Delete a livebox (will be replaced with livebox_del)
- * \details N/A
- * \remarks
- * If you call this with uninitialized handle, the return callback will be called synchronously.
- * So before return from this function, the return callback will be called first.
- * \param[in] handler Handler of a livebox instance
- * \param[in] type Deletion type, LB_DELETE_PERMANENTLY or LB_DELETE_TEMPORARY
- * \param[in] cb return callback
- * \param[in] data user data for return callback
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY already in process
- * \retval LB_STATUS_ERROR_FAULT failed to create a request packet
- * \retval LB_STATUS_SUCCESS successfully sent, return callack will be called
- * \pre N/A
- * \post N/A
- * \see ret_cb_t
- */
-extern int livebox_del_NEW(struct livebox *handler, int type, ret_cb_t cb, void *data);
-
-/*!
- * \brief Set a livebox events callback
- * \details
- * To get the events push from the provider, register the event callback using this function
- * The callback will be called if there is any events from the provider.
- * \remarks N/A
- * \param[in] cb Event handler
- * \param[in] data User data for the event handler
- * \return int
- * \retval LB_STATUS_SUCCESS if succeed to set event handler
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_MEMORY Not enough memory
- * \pre NULL
- * \post NULL
- * \see livebox_unset_event_handler
- */
-extern int livebox_set_event_handler(int (*cb)(struct livebox *handler, enum livebox_event_type event, void *data), void *data);
-
-/*!
- * \brief Unset the livebox event handler
- * \details N/A
- * \remarks N/A
- * \param[in] cb Event handler
- * \return void * Event handler data
- * \retval pointer of 'data' which is used with the livebox_set_event_handler
- * \pre N/A
- * \post N/A
- * \see livebox_set_event_handler
- */
-extern void *livebox_unset_event_handler(int (*cb)(struct livebox *handler, enum livebox_event_type event, void *data));
-
-/*!
- * \brief Live box fault event handler registeration function
- * argument list
- * event, pkgname, filename, funcname
- * \details N/A
- * \remarks N/A
- * \param[in] cb Event handler
- * \param[in] data Event handler data
- * \return int
- * \retval LB_STATUS_SUCCESS if succeed to set fault event handler
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_MEMORY Not enough memory
- * \pre N/A
- * \post N/A
- * \see livebox_unset_fault_handler
- */
-extern int livebox_set_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *), void *data);
-
-/*!
- * \brief Unset the live box fault event handler
- * \details N/A
- * \remarks N/A
- * \param[in] cb Event handler
- * \return void * Callback data which is set via livebox_set_fault_handler
- * \retval pointer of 'data' which is used with the livebox_set_fault_handler
- * \pre N/A
- * \post N/A
- * \see livebox_set_fault_handler
- */
-extern void *livebox_unset_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *));
-
-/*!
- * \brief Activate the faulted livebox.
- * \details
- * Request result will be back via return callback.
- * \remarks
- * Even though this function returns SUCCESS, it means just successfully sent a request to provider.
- * So you have to check the return callback. and its "ret" argument.
- * \param[in] pkgname Package name which should be activated
- * \param[in] cb Result callback
- * \param[in] data Callback data
- * \return int
- * \retval LB_STATUS_SUCCESS Successfully sent a request
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Failed to make a request
- * \pre N/A
- * \post N/A
- * \see ret_cb_t
- */
-extern int livebox_activate(const char *pkgname, ret_cb_t cb, void *data);
-
-/*!
- * \brief Resize the livebox
- * \details
- * Normal mode livebox size
- * 1x1=175x175, LB_SIZE_TYPE_1x1
- * 2x1=354x175, LB_SIZE_TYPE_2x1
- * 2x2=354x354, LB_SIZE_TYPE_2x2
- * 4x1=712x175, LB_SIZE_TYPE_4x1
- * 4x2=712x354, LB_SIZE_TYPE_4x2
- * 4x4=712x712, LB_SIZE_TYPE_4x4
- *
- * Extended livebox size
- * 4x3=712x533, LB_SIZE_TYPE_4x3
- * 4x5=712x891, LB_SIZE_TYPE_4x5
- * 4x6=712x1070, LB_SIZE_TYPE_4x6
- *
- * Easy mode livebox size
- * 21x21=224x215, LB_SIZE_TYPE_EASY_1x1
- * 23x21=680x215, LB_SIZE_TYPE_EASY_3x1
- * 23x23=680x653, LB_SIZE_TYPE_EASY_3x3
- *
- * Special mode livebox size
- * 0x0=720x1280, LB_SIZE_TYPE_0x0
- * \remarks
- * You have to check the return callback.
- * \param[in] handler Handler of a livebox instance
- * \param[in] type Type of a livebox size, LB_SIZE_TYPE_1x1, ...
- * \param[in] cb Result callback of the resize operation.
- * \param[in] data User data for return callback
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY Previous request of resize is in progress.
- * \retval LB_STATUS_ERROR_ALREADY Already resized, there is no differences between current size and requested size.
- * \retval LB_STATUS_ERROR_PERMISSION Permission denied, you only have view the content of this box.
- * \retval LB_STATUS_ERROR_FAULT Failed to make a request
- * \pre N/A
- * \post N/A
- * \see ret_cb_t
- */
-extern int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *data);
-
-/*!
- * \brief Send the click event for a livebox.
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] x Rational X of the content width.
- * \param[in] y Rational Y of the content height.
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_click(struct livebox *handler, double x, double y);
-
-/*!
- * \brief Change the cluster/sub-cluster name of given livebox handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] cluster New cluster of a livebox
- * \param[in] category New category of a livebox
- * \param[in] cb Result callback for changing the cluster/category of a livebox
- * \param[in] data User data for the result callback
- * \return int
- * \retval LB_STATUS_SUCCESS Request is successfully sent. the return callback will be called.
- * \retval LB_STATUS_ERROR_BUSY previous request is not finished yet.
- * \retval LB_STATUS_ERROR_ALREADY group name is same with current one.
- * \retval LB_STATUS_ERROR_PERMISSION you have no permission to change property of this livebox instance.
- * \retval LB_STATUS_ERROR_FAULT Failed to make a request.
- * \pre N/A
- * \post N/A
- * \see ret_cb_t
- */
-extern int livebox_set_group(struct livebox *handler, const char *cluster, const char *category, ret_cb_t cb, void *data);
-
-/*!
- * \brief Get the cluster and category(sub-cluster) name of given livebox (It is not I18N format, only english)
- * \details N/A
- * \remarks
- * You have to do not release the cluster & category.
- * It is allocated inside of given livebox instance, so you can only read it.
- * \param[in] handler Handler of a livebox instance
- * \param[out] cluster Storage(memory) for containing the cluster name
- * \param[out] category Storage(memory) for containing the category name
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_get_group(struct livebox *handler, const char **cluster, const char **category);
-
-/*!
- * \brief Get the period of this livebox handler
- * \details N/A
- * \remarks
- * if this function returns 0.0f, it means the livebox has no update period.
- * or the handle is not valid.
- * This function only can be works after the return callback of livebox_create fucntion is called.
- * \param[in] handler Handler of a livebox instance
- * \return double
- * \retval Current update period of a livebox
- * \retval 0.0f it means the box has no update period, or it can returns 0.0 if the handles is not valid.
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern double livebox_period(struct livebox *handler);
-
-/*!
- * \brief Change the update period
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] period New update period of a livebox
- * \param[in] cb Result callback of changing the update period of this livebox
- * \param[in] data User data for the result callback
- * \return int
- * \retval LB_STATUS_SUCCESS Successfully done
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY
- * \retval LB_STATUS_ERROR_ALREADY
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \pre N/A
- * \post N/A
- * \see ret_cb_t
- */
-extern int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb, void *data);
-
-/*!
- * \brief Is this an text type livebox?
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return livebox_lb_type
- * \retval LB_TYPE_IMAGE Contents of a livebox is based on the image file
- * \retval LB_TYPE_BUFFER Contents of a livebox is based on canvas buffer(shared)
- * \retval LB_TYPE_TEXT Contents of a livebox is based on formatted text file
- * \retval LB_TYPE_PIXMAP Contens of a livebox is shared by the pixmap(depends on X)
- * \retval LB_TYPE_INVALID
- * \pre N/A
- * \post N/A
- * \see livebox_lb_type
- */
-extern enum livebox_lb_type livebox_lb_type(struct livebox *handler);
-
-/*!
- * \brief Is this livebox is created by a user?
- * \details
- * If the livebox instance is created by system this will returns 0.
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval 0 automatically created livebox by the provider
- * \retval 1 created by user via livebox_add or livebox_add_with_size
- * \pre N/A
- * \post N/A
- * \see livebox_add
- * \see livebox_add_with_size
- * \see livebox_set_event_handler
- */
-extern int livebox_is_user(struct livebox *handler);
-
-/*!
- * \brief Get the content information string of given livebox
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return const char *
- * \retval content_info Livebox content info that can be used again via content_info argument of livebox_add or livebox_add_with_size.
- * \pre N/A
- * \post N/A
- * \see livebox_add
- * \see livebox_add_with_size
- */
-extern const char *livebox_content(struct livebox *handler);
-
-/*!
- * \brief Get the sub cluster title string of given livebox
- * \details
- * This API is now used for accessibility.
- * Each box should set their content as a string to read by TTS.
- * So if the box has focus on the homescreen, the homescreen will read a text using this API.
- * \remarks
- * The title which is returned by this, the TTS should read it.
- * But it is just recomended to a homescreen.
- * So read it or not is depends on implementation of the homescreen.
- * \param[in] handler Handler of a livebox instance
- * \return const char *
- * \retval sub cluster name
- * \retval NULL
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern const char *livebox_category_title(struct livebox *handler);
-
-/*!
- * \brief Get the filename of given livebox, if it is an IMAGE type livebox
- * \details
- * If the box is developed as image format to represent its contents,
- * The homescreen should know its image file name.
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return const char *
- * \retval filename if the livebox type is image this function will give you a abspath of an image file (content is rendered)
- * \retval NULL if this has no image file or type is not image file.
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern const char *livebox_filename(struct livebox *handler);
-
-/*!
- * \brief Get the package name of given livebox handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return const char *
- * \retval pkgname package name
- * \retval NULL if the handler is not valid
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern const char *livebox_pkgname(struct livebox *handler);
-
-/*!
- * \brief Get the priority of a current content.
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return double
- * \retval 0.0f handler is NULL
- * \retval -1.0f Handler is not valid (not yet initialized)
- * \retval real number between 0.0 and 1.0
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern double livebox_priority(struct livebox *handler);
-
-/*!
- * \brief Acquire the buffer of given livebox (Only for the buffer type)
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return void *
- * \retval address of a FB
- * \retval NULL if it fails to get fb address
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern void *livebox_acquire_fb(struct livebox *handler);
-
-/*!
- * \brief Release the buffer of a livebox (Only for the buffer type)
- * \details N/A
- * \remarks N/A
- * \param[in] buffer
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see livebox_acquire_fb
- */
-extern int livebox_release_fb(void *buffer);
-
-/*!
- * \brief Get the reference count of Livebox buffer (Only for the buffer type)
- * \details N/A
- * \remarks N/A
- * \param[in] buffer
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval refcnt positive integer including ZERO
- * \pre N/A
- * \post N/A
- * \see livebox_pdfb_refcnt
- */
-extern int livebox_fb_refcnt(void *buffer);
-
-/*!
- * \brief Acquire the buffer of a PD frame (Only for the buffer type)
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval NULL
- * \retval adress of buffer of PD
- * \pre N/A
- * \post N/A
- * \see livebox_release_pdfb
- */
-extern void *livebox_acquire_pdfb(struct livebox *handler);
-
-/*!
- * \brief Release the acquired buffer of the PD Frame (Only for the buffer type)
- * \details N/A
- * \remarks N/A
- * \param[in] buffer
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see livebox_acquire_pdfb
- */
-extern int livebox_release_pdfb(void *buffer);
-
-/*!
- * \brief Reference count of given PD buffer (Only for the buffer type)
- * \details N/A
- * \remarks N/A
- * \param[in] buffer
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval reference count
- * \pre N/A
- * \post N/A
- * \see livebox_fb_refcnt
- */
-extern int livebox_pdfb_refcnt(void *buffer);
-
-/*!
- * \brief Get the size of the Livebox
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval LB_SIZE_TYPE_NxM
- * \retval LB_SIZE_TYPE_INVALID
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_size(struct livebox *handler);
-
-/*!
- * \brief Get the size of the Progressive Disclosure
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[out] w
- * \param[out] h
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_get_pdsize(struct livebox *handler, int *w, int *h);
-
-/*!
- * \brief List of supported sizes of given handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[out] cnt
- * \param[out] size_list
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_get_supported_sizes(struct livebox *handler, int *cnt, int *size_list);
-
-/*!
- * \brief BUFFER SIZE of the livebox if it is a buffer type
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval size of livebox buffer
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_lbfb_bufsz(struct livebox *handler);
-
-/*!
- * \brief BUFFER SIZE of the progiressive disclosure if it is a buffer type
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval size of PD buffer
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_pdfb_bufsz(struct livebox *handler);
-
-/*!
- * \brief Send the content event (for buffer type) to provider(livebox)
- * \details N/A
- * \remarks DEPRECATED
- * Use the livebox_mouse_event function instead of this.
- * \param[in] handler Handler of a livebox instance
- * \param[in] type Event type
- * \param[in] x coordinates of X axis
- * \param[in] y coordinates of Y axis
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY Previous operaion is not finished yet
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully sent
- * \pre N/A
- * \post N/A
- * \see livebox_mouse_event
- * \see livebox_access_event
- * \see livebox_key_event
- */
-extern int livebox_content_event(struct livebox *handler, enum content_event_type type, double x, double y);
-
-/*!
- * \brief Send the content event (for buffer type) to provider(livebox)
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] type Event type
- * \param[in] x coordinates of X axis
- * \param[in] y coordinates of Y axis
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY Previous operation is not finished yet
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully sent
- * \pre N/A
- * \post N/A
- * \see livebox_content_event
- * \see livebox_access_event
- * \see livebox_key_event
- */
-extern int livebox_mouse_event(struct livebox *handler, enum content_event_type type, double x, double y);
-
-/*!
- * \brief Send the access event(for buffer type) to provider(livebox).
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] type Event type
- * \param[in] x coordinates of X axsis
- * \param[in] y coordinates of Y axsis
- * \param[in] cb Result callback function
- * \param[in] data Callback data
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY Previous operation is not finished yet
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully sent
- * \pre N/A
- * \post N/A
- * \see livebox_mouse_event
- * \see livebox_key_event
- */
-extern int livebox_access_event(struct livebox *handler, enum access_event_type type, double x, double y, ret_cb_t cb, void *data);
-
-/*!
- * \brief Send the key event(for buffer type) to provider(livebox).
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] type Key event type
- * \param[in] keycode Code of key
- * \param[in] cb Result callback
- * \param[in] data Callback data
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY Previous operation is not finished yet
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully sent
- * \pre N/A
- * \post N/A
- * \see livebox_mouse_event
- * \see livebox_access_event
- */
-extern int livebox_key_event(struct livebox *handler, enum content_event_type type, unsigned int keycode, ret_cb_t cb, void *data);
-
-/*!
- * \brief Do pin up or not.
- * \details
- * If the livebox supports the pinup feature,
- * you can freeze the update of given livebox.
- * But it is different with pause.
- * The box will be updated and it will decide wheter update its content or not when the pinup is on.
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] flag Pinup value
- * \param[in] cb Result callback
- * \param[in] data Callback data
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid parameters
- * \see ret_cb_t
- * \see livebox_set_visibility
- * \see livebox_is_pinned_up
- */
-extern int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, void *data);
-
-/*!
- * \brief Check the PIN-UP status of given handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid parameters
- * \retval 1 box is pinned up
- * \retval 0 box is not pinned up
- * \see livebox_set_pinup
- */
-extern int livebox_is_pinned_up(struct livebox *handler);
-
-/*!
- * \brief Check the PINUP feature availability of the given handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval 1 if the box support Pinup feature
- * \retval 0 if the box does not support the Pinup feature
- * \pre N/A
- * \post N/A
- * \see livebox_is_pinned_up
- * \see livebox_set_pinup
- */
-extern int livebox_has_pinup(struct livebox *handler);
-
-/*!
- * \brief Check the PD existence of given handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval 1 if the box support the PD
- * \retval 0 if the box has no PD
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_has_pd(struct livebox *handler);
-
-/*!
- * \brief Create the PD of given handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] cb Result callback
- * \param[in] data Callback data
- * \return int
- * \retval LB_STATUS_SUCCESS Successfully done
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY Previous operation is not finished yet
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \pre N/A
- * \post N/A
- * \see ret_cb_t
- * \see livebox_create_pd_with_position
- * \see livebox_move_pd
- * \see livebox_destroy_pd
- */
-extern int livebox_create_pd(struct livebox *handler, ret_cb_t cb, void *data);
-
-/*!
- * \brief Create the PD of given handler with the relative position from livebox
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] x 0.0 ~ 1.0
- * \param[in] y 0.0 ~ 1.0
- * \param[in] cb Result callback
- * \param[in] data Callback data
- * \return int
- * \retval LB_STATUS_SUCCESS Successfully done
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY Previous operation is not finished yet
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \pre N/A
- * \post N/A
- * \see livebox_create_pd
- * \see livebox_destroy_pd
- * \see livebox_move_pd
- */
-extern int livebox_create_pd_with_position(struct livebox *handler, double x, double y, ret_cb_t cb, void *data);
-
-/*!
- * \brief PD position is updated.
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] x 0.0 ~ 1.0
- * \param[in] y 0.0 ~ 1.0
- * \return int
- * \retval LB_STATUS_SUCCESS if succeed to send request for updating position of the PD.
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_move_pd(struct livebox *handler, double x, double y);
-
-/*!
- * \brief Destroy the PD of given handler if it is created.
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] cb
- * \param[in] data
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see ret_cb_t
- */
-extern int livebox_destroy_pd(struct livebox *handler, ret_cb_t cb, void *data);
-
-/*!
- * \brief Check the create status of given livebox handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval 0 PD is not created
- * \retval 1 PD is created
- */
-extern int livebox_pd_is_created(struct livebox *handler);
-
-/*!
- * \brief Check the content type of the progressive disclosure of given handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval PD_TYPE_BUFFER Contents of a PD is based on canvas buffer(shared)
- * \retval PD_TYPE_TEXT Contents of a PD is based on formatted text file
- * \retval PD_TYPE_PIXMAP Contents of a livebox is shared by the pixmap(depends on X)
- * \retval PD_TYPE_INVALID
- * \pre N/A
- * \post N/A
- * \see livebox_pd_type
- */
-extern enum livebox_pd_type livebox_pd_type(struct livebox *handler);
-
-/*!
- * \brief Check the existence of a livebox about given package name
- * \details N/A
- * \remarks N/A
- * \param[in] pkgname
- * \return int
- * \retval 1 if the box is exists
- * \retval 0 if the box is not exists
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_is_exists(const char *pkgname);
-
-/*!
- * \brief Set function table for parsing the text content of a livebox
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] ops
- * \return int
- * \retval LB_STATUS_SUCCESS Successfully done
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \see livebox_set_pd_text_handler
- */
-extern int livebox_set_text_handler(struct livebox *handler, struct livebox_script_operators *ops);
-
-/*!
- * \brief Set function table for parsing the text content of a Progressive Disclosure
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] ops
- * \return int
- * \retval LB_STATUS_SUCCESS Successfully done
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \see livebox_set_text_handler
- */
-extern int livebox_set_pd_text_handler(struct livebox *handler, struct livebox_script_operators *ops);
-
-/*!
- * \brief Emit a text signal to given livebox only if it is a text type.
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] emission Emission string
- * \param[in] source Source string
- * \param[in] sx start X
- * \param[in] sy start Y
- * \param[in] ex end X
- * \param[in] ey end Y
- * \param[in] cb Result callback
- * \param[in] data Callback data
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid parameters
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully emitted
- * \see ret_cb_t
- */
-extern int livebox_emit_text_signal(struct livebox *handler, const char *emission, const char *source, double sx, double sy, double ex, double ey, ret_cb_t cb, void *data);
-
-/*!
- * \brief Set a private data pointer to carry it using given handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] data data pointer
- * \return int
- * \retval LB_STATUS_SUCCESS Successfully registered
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \pre N/A
- * \post N/A
- * \see livebox_get_data
- */
-extern int livebox_set_data(struct livebox *handler, void *data);
-
-/*!
- * \brief Get private data pointer which is carried by given handler
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return void *
- * \retval data pointer
- * \retval NULL if there is not data
- * \pre N/A
- * \post N/A
- * \see livebox_set_data
- */
-extern void *livebox_get_data(struct livebox *handler);
-
-/*!
- * \brief Subscribe the event for liveboxes only in given cluster and sub-cluster
- * \details
- * If you wrote a view-only client.
- * you can receive the event of specific liveboxes which are grouped in given cluster/category
- * But you cannot modify their attributes (such as size, ...).
- * \remarks N/A
- * \param[in] cluster "*" can be used for subscribe all cluster's liveboxes event.
- * If you use the "*", value in the category will be ignored.
- * \param[in] category "*" can be used for subscribe liveboxes events of all category(sub-cluster) in given "cluster"
- * \return int
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully requested
- * \pre N/A
- * \post N/A
- * \see livebox_unsubscribe_group
- */
-extern int livebox_subscribe_group(const char *cluster, const char *category);
-
-/*!
- * \brief Unsubscribe the event for the liveboxes, but you will receive already added liveboxes event.
- * \details N/A
- * \remarks N/A
- * \param[in] cluster "*" can be used for subscribe all cluster's liveboxes event.
- * If you use the "*", value in the category will be ignored.
- * \param[in] category "*" can be used for subscribe all sub-cluster's liveboxes event in given "cluster"
- * \return int
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully requested
- * \pre N/A
- * \post N/A
- * \see livebox_subscribe_group
- */
-extern int livebox_unsubscribe_group(const char *cluster, const char *category);
-
-/*!
- * \brief Refresh the group(cluster/sub-cluser(aka. category))
- * \details
- * This function will trigger the update of all liveboxes in given cluster/category group
- * \remarks
- * Basically default livebox system doesn't use the cluster/category concept.
- * But you can use it. so if you decide to use it then you can trigger the update of all liveboxes in given group.
- * \param[in] cluster Cluster ID
- * \param[in] category Sub-cluster ID
- * \param[in] force 1 if the boxes should be updated even if they are paused
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully requested
- * \pre N/A
- * \post N/A
- * \see livebox_refresh
- */
-extern int livebox_refresh_group(const char *cluster, const char *category, int force);
-
-/*!
- * \brief Refresh a livebox
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] force 1 if the box should be updated even if it is paused
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully requested
- * \pre N/A
- * \post N/A
- * \see livebox_refresh_group
- */
-extern int livebox_refresh(struct livebox *handler, int force);
-
-/*!
- * \brief Pixmap Id of a livebox content
- * \details
- * This function doesn't guarantees the life-cycle of the pixmap.
- * If the service provider destroy the pixmap, you will not know about it.
- * So you should validate it before access it.
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval 0 if the pixmap is not created
- * \retval pixmap Pixmap Id need to be casted to (unsigned int) type
- * \pre N/A
- * \post N/A
- * \see livebox_pd_pixmap
- */
-extern int livebox_lb_pixmap(const struct livebox *handler);
-
-/*!
- * \brief Pixmap Id of a PD content
- * \details
- * This function doesn't guarantees the life-cycle of the pixmap.
- * If the service provider destroy the pixmap, you will not know about it.
- * So you should validate it before access it.
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval 0 if the pixmap is not created
- * \retval pixmap Pixmap Id need to be casted to (unsigned int) type
- * \pre N/A
- * \post N/A
- * \see livebox_lb_pixmap
- */
-extern int livebox_pd_pixmap(const struct livebox *handler);
-
-/*!
- * \brief Acquire the pixmap of PD
- * \details
- * After acquire the pixmap of PD, it will not be destroyed
- * So if the new update is comming with new pixmap Id, you should release old pixmap manually
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance.
- * \param[in] cb Result callback for acquiring request
- * \param[in] data Callback Data
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Failed to send a request to the service provider or there is critical error that is unrecoverable
- * \retval LB_STATUS_SUCCESS Successfully requested to acquire the pixmap of PD
- * \pre N/A
- * \post N/A
- * \see livebox_release_pd_pixmap
- * \see livebox_acquire_lb_pixmap
- * \see ret_cb_t
- */
-extern int livebox_acquire_pd_pixmap(struct livebox *handler, ret_cb_t cb, void *data);
-
-/*!
- * \brief Release the acquired pixmap ID
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance, This can be NULL, only if the handler is deleted.
- * \param[in] pixmap Pixmap Id to release it
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully released (request is sent)
- * \pre N/A
- * \post N/A
- * \see livebox_acquire_pd_pixmap
- * \see livebox_release_lb_pixmap
- */
-extern int livebox_release_pd_pixmap(struct livebox *handler, int pixmap);
-
-/*!
- * \brief Getting the PIXMAP of a livebox
- * \details
- * Even if the render process release the pixmap, the pixmap will be kept before released by livebox_release_lb_pixmap
- * You should release the pixmap manually.
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] cb Callback function which will be called with result of acquiring lb pixmap
- * \param[in] data Callback data
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully requested
- * \pre
- * Livebox service system should support the PIXMAP type buffer.
- * The livebox should be designed to use the buffer (script type)
- * \post N/A
- * \see livebox_release_lb_pixmap
- * \see livebox_acquire_pd_pixmap
- * \see ret_cb_t
- */
-extern int livebox_acquire_lb_pixmap(struct livebox *handler, ret_cb_t cb, void *data);
-
-/*!
- * \brief Release the pixmap of a livebox
- * \details
- * After the client gets new pixmap or no more need to keep current pixmap, use this to release it.
- * If there is no user for given pixmap, the pixmap will be destroyed.
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance, This can be NULL, only if the handler is deleted.
- * \param[in] pixmap Pixmap Id of given livebox handler
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre
- * The pixmap should be acquired by livebox_acquire_lb_pixmap
- * \post N/A
- * \see livebox_acquire_lb_pixmap
- * \see livebox_release_pd_pixmap
- */
-extern int livebox_release_lb_pixmap(struct livebox *handler, int pixmap);
-
-/*!
- * \brief Update the visible state of a livebox
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] state Configure the current visible state of a livebox
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY
- * \retval LB_STATUS_ERROR_PERMISSION
- * \retval LB_STATUS_ERROR_ALREADY
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_set_visibility(struct livebox *handler, enum livebox_visible_state state);
-
-/*!
- * \brief Current visible state of a livebox
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return livebox_visible_state
- * \retval LB_SHOW Livebox is showed. Default state
- * \retval LB_HIDE Livebox is hide, Update timer is not be freezed. but you cannot receive any updates events. you should refresh(reload) the content of a livebox when you make this show again
- * \retval LB_HIDE_WITH_PAUSE Livebix is hide, it will paused the update timer, but if a livebox update its contents, update event will come to you
- * \retval LB_VISIBLE_ERROR To enlarge the size of this enumeration type
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern enum livebox_visible_state livebox_visibility(struct livebox *handler);
-
-/*!
- * \brief Set the update mode of current livebox
- * \details N/A
- * \remarks N/A
- * if you set 1 for active update mode, you should get buffer without updated event from provider.
- * But is passive mode, you have to update content of a box when you get updated event.
- * Default is Passive mode.
- * \param[in] handler Handler of a livebox instance
- * \param[in] active_update 1 means active update, 0 means passive update (default)
- * \param[in] cb Result callback function
- * \param[in] data Callback data
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_ERROR_BUSY
- * \retval LB_STATUS_ERROR_PERMISSION
- * \retval LB_STATUS_ERROR_ALREADY
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see ret_cb_t
- */
-extern int livebox_set_update_mode(struct livebox *handler, int active_update, ret_cb_t cb, void *data);
-
-/*!
- * \brief Is this box in the active update mode?
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return int
- * \retval 0 if passive mode
- * \retval 1 if active mode or error code
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_is_active_update(struct livebox *handler);
-
-/*!
- * \brief Sync manually
- * \details N/A
- * \remarks N/A
- * param[in] handler Handler of a livebox instance
- * \return void
- * \retval LB_STATUS_SUCCESS If success
- * \retval LB_STATUS_ERROR_INVALID Invalid handle
- * \pre N/A
- * \post N/A
- * \see livebox_set_manual_sync
- * \see livebox_manual_sync
- * \see livebox_sync_lb_fb
- */
-extern int livebox_sync_pd_fb(struct livebox *handler);
-
-/*!
- * \brief Sync manually
- * \details N/A
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return void
- * \retval LB_STATUS_SUCCESS If success
- * \retval LB_STATUS_ERROR_INVALID Invalid handle
- * \pre N/A
- * \post N/A
- * \see livebox_set_manual_sync
- * \see livebox_manual_sync
- * \see livebox_sync_pd_fb
- */
-extern int livebox_sync_lb_fb(struct livebox *handler);
-
-/*!
- * \brief Getting the alternative icon of given livebox instance.
- * \details If the box should be represented as a shortcut icon, this function will get the alternative icon.
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return const char *
- * \retval address Absolute path of an alternative icon file
- * \retval NULL Livebox has no alternative icon file
- * \pre N/A
- * \post N/A
- * \see livebox_alt_name
- */
-extern const char *livebox_alt_icon(struct livebox *handler);
-
-/*!
- * \brief Getting the alternative name of given livebox instance.
- * \details If the box should be represented as a shortcut name, this function will get the alternative name.
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \return const char *
- * \retval name Alternative name of a livebox
- * \retval NULL Livebox has no alternative name
- * \pre N/A
- * \post N/A
- * \see livebox_alt_icon
- */
-extern const char *livebox_alt_name(struct livebox *handler);
-
-/*!
- * \brief Get the lock for frame buffer.
- * \details
- * This function should be used to prevent from rendering to the frame buffer while reading it.
- * And the locking area should be short and must be released ASAP
- * Or the render thread will be hang'd.
- * \remarks
- * \param[in] handler Handler of a livebox instance
- * \param[in] is_pd 1 for PD or 0
- * \return int
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see livebox_release_fb_lock
- */
-extern int livebox_acquire_fb_lock(struct livebox *handler, int is_pd);
-
-/*!
- * \brief Release the lock of frame buffer
- * \details
- * This function should be called ASAP after acquire a lock of FB.
- * Or the render process will be blocked.
- * \remarks N/A
- * \param[in] handler Handler of a livebox instance
- * \param[in] is_pd 1 for PD or 0
- * \return int
- * \retval LB_STATUS_ERROR_FAULT Unrecoverable error occurred
- * \retval LB_STATUS_ERROR_INVALID Invalid argument
- * \retval LB_STATUS_SUCCESS Successfully done
- * \pre N/A
- * \post N/A
- * \see livebox_acquire_fb_lock
- */
-extern int livebox_release_fb_lock(struct livebox *handler, int is_pd);
-
-/*!
- * \brief Set options for controlling livebox sub-system.
- * \details
- * LB_OPTION_FRAME_DROP_FOR_RESIZE
- * While resizing the box, viewer doesn't want to know the updated frames of old size content anymore,
- * In that case, turn this on, the provider will not send the updated event to the viewer about old content.
- * So the viewer can reduce its burden to update unnecessary frames
- * LB_OPTION_MANUAL_SYNC
- * If you don't want updates frame automatically,
- * Only you want reload the frames by your hands,(manually)
- * Turn it on.
- * After turnned it on, you should sync it using
- * livebox_sync_pd_fb
- * livebox_sync_lb_pfb
- * LB_OPTION_SHARED_CONTENT
- * If this option is turnned on, even though you create a new livebox,
- * If there are already added same instance has same content, the instance will not be created again
- * Instead of creating a new instance, viewer will provides old instance with new handle.
- * \remarks N/A
- * \param[in] option option which will be affected by this call
- * \param[in] state new value for given option
- * \return int
- * \retval LB_STATUS_ERROR_INVALID Unknown option
- * \retval LB_STATUS_ERROR_FAULT Failed to change the state of option
- * \retval LB_STATUS_SUCCESS Successfully changed
- * \pre N/A
- * \post N/A
- * \see livebox_get_option
- * \see livebox_sync_pd_fb
- * \see livebox_sync_lb_fb
- */
-extern int livebox_set_option(enum livebox_option_type option, int state);
-
-/*!
- * \brief Get options livebox sub-system
- * \details N/A
- * \remarks N/A
- * \param[in] option type of option
- * \return int
- * \retval LB_STATUS_ERROR_INVALID invalid option
- * \retval LB_STATUS_ERROR_FAULT Failed to get option
- * \retval >=0 Value of given option. must has to be >=0
- * \pre N/A
- * \post N/A
- * \see livebox_set_option
- */
-extern int livebox_option(enum livebox_option_type option);
-
-
-/*!
- * \brief Set a handler for launching an app for auto-launch feature
- * \details If a user clicks a box, and the box uses auto-launch option, the launcher_handler will be called.
- * \remarks N/A
- * \param[in] launch_handler Handler for launching an app manually
- * \param[in] data Callback data which will be given a data for launch_handler
- * \return int
- * \retval
- * \pre N/A
- * \post N/A
- * \see N/A
- */
-extern int livebox_set_auto_launch_handler(int (*launch_handler)(struct livebox *handler, const char *appid, void *data), void *data);
-
-/*!
- * \}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/include/livebox_internal.h b/include/livebox_internal.h
deleted file mode 100644
index a6f92f9..0000000
--- a/include/livebox_internal.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * 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.
- */
-
-extern void lb_invoke_event_handler(struct livebox *handler, enum livebox_event_type event);
-extern void lb_invoke_fault_handler(enum livebox_fault_type type, const char *pkgname, const char *filename, const char *function);
-
-extern struct livebox_common *lb_find_common_handle(const char *pkgname, const char *filename);
-extern struct livebox *lb_new_livebox(const char *pkgname, const char *id, double timestamp, const char *cluster, const char *category);
-extern struct livebox_common *lb_find_common_handle_by_timestamp(double timestamp);
-
-extern int lb_set_group(struct livebox_common *common, const char *cluster, const char *category);
-extern void lb_set_size(struct livebox_common *common, int w, int h);
-extern void lb_set_pdsize(struct livebox_common *common, int w, int h);
-extern void lb_set_default_pdsize(struct livebox_common *common, int w, int h);
-extern int lb_set_content(struct livebox_common *common, const char *content);
-extern int lb_set_title(struct livebox_common *handler, const char *title);
-extern void lb_set_auto_launch(struct livebox_common *handler, const char *auto_launch);
-extern void lb_set_id(struct livebox_common *handler, const char *id);
-extern void lb_set_size_list(struct livebox_common *handler, int size_list);
-extern void lb_set_priority(struct livebox_common *handler, double priority);
-extern int lb_set_lb_fb(struct livebox_common *handler, const char *filename);
-extern int lb_set_pd_fb(struct livebox_common *handler, const char *filename);
-extern struct fb_info *lb_get_pd_fb(struct livebox_common *handler);
-extern struct fb_info *lb_get_lb_fb(struct livebox_common *handler);
-extern void lb_set_user(struct livebox_common *handler, int user);
-extern void lb_set_pinup(struct livebox_common *handler, int pinup);
-extern void lb_set_text_lb(struct livebox_common *handler);
-extern void lb_set_text_pd(struct livebox_common *handler);
-extern int lb_text_lb(struct livebox_common *handler);
-extern int lb_text_pd(struct livebox_common *handler);
-extern void lb_set_period(struct livebox_common *handler, double period);
-extern void lb_set_update_mode(struct livebox_common *handler, int active_mode);
-extern void lb_set_filename(struct livebox_common *handler, const char *filename);
-extern void lb_set_alt_info(struct livebox_common *handler, const char *icon, const char *name);
-extern int lb_destroy_lock_file(struct livebox_common *common, int is_pd);
-extern int lb_create_lock_file(struct livebox_common *common, int is_pd);
-extern int lb_destroy_common_handle(struct livebox_common *common);
-extern struct livebox_common *lb_create_common_handle(struct livebox *handle, const char *pkgname, const char *cluster, const char *category);
-extern int lb_sync_pd_fb(struct livebox_common *common);
-extern int lb_sync_lb_fb(struct livebox_common *common);
-extern int lb_common_unref(struct livebox_common *common, struct livebox *handle);
-extern int lb_common_ref(struct livebox_common *common, struct livebox *handle);
-
-extern struct livebox *lb_ref(struct livebox *handler);
-extern struct livebox *lb_unref(struct livebox *handler, int destroy_common);
-extern int lb_send_delete(struct livebox *handler, int type, ret_cb_t cb, void *data);
-extern int lb_delete_all(void);
-
-enum lb_type { /*!< Must have to be sync with data-provider-master */
- _LB_TYPE_NONE = 0x0,
- _LB_TYPE_SCRIPT,
- _LB_TYPE_FILE,
- _LB_TYPE_TEXT,
- _LB_TYPE_BUFFER
-};
-
-enum pd_type { /*!< Must have to be sync with data-provider-master */
- _PD_TYPE_NONE = 0x0,
- _PD_TYPE_SCRIPT,
- _PD_TYPE_TEXT,
- _PD_TYPE_BUFFER
-};
-
-enum livebox_state {
- CREATE = 0xBEEFbeef,
- DELETE = 0xDEADdead, /* Delete only for this client */
- DESTROYED = 0x00DEAD00
-};
-
-struct livebox_common {
- enum livebox_state state;
-
- struct dlist *livebox_list;
- int refcnt;
-
- char *cluster;
- char *category;
-
- char *pkgname;
- char *id;
-
- char *content;
- char *title;
- char *filename;
-
- double timestamp;
-
- struct alt_info {
- char *icon;
- char *name;
- } alt;
-
- enum livebox_delete_type delete_type;
-
- int is_user;
- int is_pd_created;
- int is_pinned_up;
- int is_active_update;
- enum livebox_visible_state visible;
-
- struct {
- enum lb_type type;
- struct fb_info *fb;
-
- int size_list;
-
- int width;
- int height;
- double priority;
-
- char *auto_launch;
- double period;
- int pinup_supported;
- int mouse_event;
-
- /* For the filtering event */
- double x;
- double y;
- char *lock;
- int lock_fd;
- } lb;
-
- struct {
- enum pd_type type;
- struct fb_info *fb;
-
- int width;
- int height;
-
- int default_width;
- int default_height;
-
- /* For the filtering event */
- double x;
- double y;
- char *lock;
- int lock_fd;
- } pd;
-
- int nr_of_sizes;
-
- struct requested_flag {
- unsigned int created:1;
- unsigned int deleted:1;
- unsigned int pinup:1;
- unsigned int group_changed:1;
- unsigned int period_changed:1;
- unsigned int size_changed:1;
- unsigned int pd_created:1;
- unsigned int pd_destroyed:1;
- unsigned int update_mode:1;
- unsigned int access_event:1;
- unsigned int key_event:1;
-
- /*!
- * \note
- * Reserved
- */
- unsigned int reserved:21;
- } request;
-};
-
-struct job_item {
- struct livebox *handle;
- ret_cb_t cb;
- int ret;
- void *data;
-};
-
-struct livebox {
- enum livebox_state state;
-
- int refcnt;
- int paused_updating;
-
- enum livebox_visible_state visible;
- struct livebox_common *common;
-
- void *data;
-
- struct callback_table {
- struct livebox_script_operators lb_ops;
- struct livebox_script_operators pd_ops;
-
- struct created {
- ret_cb_t cb;
- void *data;
- } created;
-
- struct deleted {
- ret_cb_t cb;
- void *data;
- } deleted;
-
- struct pinup {
- ret_cb_t cb;
- void *data;
- } pinup;
-
- struct group_changed {
- ret_cb_t cb;
- void *data;
- } group_changed;
-
- struct period_changed {
- ret_cb_t cb;
- void *data;
- } period_changed;
-
- struct size_changed {
- ret_cb_t cb;
- void *data;
- } size_changed;
-
- struct pd_created {
- ret_cb_t cb;
- void *data;
- } pd_created;
-
- struct pd_destroyed {
- ret_cb_t cb;
- void *data;
- } pd_destroyed;
-
- struct update_mode {
- ret_cb_t cb;
- void *data;
- } update_mode;
-
- struct access_event {
- ret_cb_t cb;
- void *data;
- } access_event;
-
- struct key_event {
- ret_cb_t cb;
- void *data;
- } key_event;
- } cbs;
-};
-
-/* End of a file */
diff --git a/live.viewer/CMakeLists.txt b/live.viewer/CMakeLists.txt
deleted file mode 100644
index 9be5a14..0000000
--- a/live.viewer/CMakeLists.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-PROJECT(live-viewer C)
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED
- capi-appfw-application
- capi-appfw-app-manager
- ail
- bundle
- dlog
- elementary
- ecore-x
- appcore-efl
- livebox-viewer
- livebox-service
-)
-
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror -Winline -g")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-SET(PKGROOT "/opt/usr/apps/live.viewer")
-ADD_DEFINITIONS("-DNDEBUG")
-ADD_DEFINITIONS("-DPKGROOT=\"${PKGROOT}\"")
-#ADD_DEFINITIONS("-DFLOG")
-ADD_DEFINITIONS("-DLOG_TAG=\"${PROJECT_NAME}\"")
-ADD_DEFINITIONS(${pkgs_CFLAGS})
-ADD_DEFINITIONS(${pkgs_LDFLAGS})
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-
-ADD_EXECUTABLE(${PROJECT_NAME}
- src/main.c
- src/dlist.c
- src/live_scroller.c
- src/util.c
- src/scroller.c
- src/lb.c
-)
-
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${PKGROOT}/bin)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/live.viewer.xml DESTINATION /opt/share/packages)
-
-ADD_SUBDIRECTORY(res)
diff --git a/live.viewer/image/folder b/live.viewer/image/folder
deleted file mode 100644
index e69de29..0000000
--- a/live.viewer/image/folder
+++ /dev/null
diff --git a/live.viewer/include/debug.h b/live.viewer/include/debug.h
deleted file mode 100644
index 2efc6dc..0000000
--- a/live.viewer/include/debug.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.
- */
-
-#if !defined(FLOG)
-#define DbgPrint(format, arg...) SECURE_LOGD("[%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg)
-#define ErrPrint(format, arg...) SECURE_LOGE("[%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg)
-#else
-extern FILE *__file_log_fp;
-#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
-
-#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
-#endif
-
-/* End of a file */
diff --git a/live.viewer/include/lb.h b/live.viewer/include/lb.h
deleted file mode 100644
index 37c48ac..0000000
--- a/live.viewer/include/lb.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.
- */
-
-extern int lb_init(void);
-extern int lb_fini(void);
-extern int lb_add(Evas_Object *sc, const char *pkgname);
-
-/* End of a file */
diff --git a/live.viewer/include/live_scroller.h b/live.viewer/include/live_scroller.h
deleted file mode 100644
index 02b2450..0000000
--- a/live.viewer/include/live_scroller.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.
- */
-
-struct live_sc_event_info {
- int curidx;
- int toidx;
-};
-
-struct live_sc_drag_info {
- int dx;
- int dy;
-};
-
-struct live_sc_move_info {
- Evas_Object *item;
- Evas_Coord x;
- Evas_Coord y;
- Evas_Coord w;
- Evas_Coord h;
-
- double relx;
- double rely;
-};
-
-extern Evas_Object *live_scroller_add(Evas_Object *parent);
-extern int live_scroller_append(Evas_Object *scroller, Evas_Object *item);
-extern Evas_Object *live_scroller_remove(Evas_Object *scroller, int idx);
-extern Evas_Object *live_scroller_get_item(Evas_Object *scroller, int idx);
-extern int live_scroller_get_current(Evas_Object *scroller);
-extern int live_scroller_loop_set(Evas_Object *scroller, int is_loop);
-
-extern int live_scroller_freeze(Evas_Object *scroller);
-extern int live_scroller_thaw(Evas_Object *scroller);
-
-extern int live_scroller_anim_to(Evas_Object *scroller, double fps, int offset);
-extern int live_scroller_go_to(Evas_Object *scroller, int idx);
-
-extern int live_scroller_update(Evas_Object *scroller);
-
-extern int live_scroller_remove_by_obj(Evas_Object *scroller, Evas_Object *obj);
-extern int live_scroller_get_item_index(Evas_Object *scroller, Evas_Object *item);
-extern int live_scroller_get_item_count(Evas_Object *scroller);
-
-/* End of a file */
diff --git a/live.viewer/include/main.h b/live.viewer/include/main.h
deleted file mode 100644
index 3c142be..0000000
--- a/live.viewer/include/main.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * 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.
- */
-
-extern Evas_Object *main_get_window(void);
diff --git a/live.viewer/include/scroller.h b/live.viewer/include/scroller.h
deleted file mode 100644
index f69575f..0000000
--- a/live.viewer/include/scroller.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.
- */
-
-extern Evas_Object *scroller_create(Evas_Object *parent);
-extern Evas_Object *scroller_peek_by_idx(Evas_Object *sc, int idx);
-extern int scroller_peek_by_obj(Evas_Object *sc, Evas_Object *obj);
-extern int scroller_append(Evas_Object *sc, Evas_Object *child);
-extern int scroller_get_current_idx(Evas_Object *sc);
-extern int scroller_peek_by_obj(Evas_Object *sc, Evas_Object *obj);
-extern Evas_Object *scroller_get_page(Evas_Object *sc, int idx);
-extern int scroller_is_scrolling(Evas_Object *sc);
-
-extern int scroller_add_stop_cb(Evas_Object *scroller, int (*cb)(Evas_Object *sc, void *data), void *data);
-extern void scroller_del_stop_cb(Evas_Object *scroller, int (*cb)(Evas_Object *sc, void *data), void *data);
-
-extern int scroller_get_page_index(Evas_Object *sc, Evas_Object *page);
-
-extern void scroller_unlock(Evas_Object *sc);
-extern void scroller_lock(Evas_Object *sc);
-
-extern int scroller_get_page_count(Evas_Object *sc);
-extern int scroller_scroll_to(Evas_Object *sc, int idx);
-extern int scroller_jump_to(Evas_Object *sc, int idx);
-
-extern int scroller_destroy(Evas_Object *sc);
-extern int scroller_update(Evas_Object *sc, void *data);
-extern int scroller_fast_scroll(Evas_Object *sc, int idx);
-extern void scroller_loop_set(Evas_Object *sc, Eina_Bool val);
-extern void scroller_quick_navi(Evas_Object *sc, Eina_Bool val);
-
-/* End of a file */
diff --git a/live.viewer/include/util.h b/live.viewer/include/util.h
deleted file mode 100644
index 79ab46b..0000000
--- a/live.viewer/include/util.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * 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.
- */
-
-extern const char *util_basename(const char *name);
-
-/* End of a file */
diff --git a/live.viewer/live.viewer.xml b/live.viewer/live.viewer.xml
deleted file mode 100644
index 7a55872..0000000
--- a/live.viewer/live.viewer.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<manifest xmlns="http://tizen.org/ns/packages" package="live.viewer" version="0.0.1" install-location="auto">
- <label>Live viewer (native)</label>
- <author email="nicesj.park@samsung.com" href="www.samsung.com">Sung-jae Park</author>
- <description>Live box simple viewer (native)</description>
-
- <ui-application appid="live.viewer" exec="/opt/usr/apps/live.viewer/bin/live-viewer" nodisplay="false" multiple="false" type="capp" taskmanage="true">
- <icon>live-viewer.png</icon>
- <label>Live box simple viewer (native)</label>
- <label xml:lang="en-us">Live box simple viewer (native)</label>
- </ui-application>
-</manifest>
diff --git a/live.viewer/packaging/live.viewer.spec b/live.viewer/packaging/live.viewer.spec
deleted file mode 100644
index f817c32..0000000
--- a/live.viewer/packaging/live.viewer.spec
+++ /dev/null
@@ -1,41 +0,0 @@
-Name: live.viewer
-Summary: viewer
-Version: 0.0.1
-Release: 1
-Group: main/app
-License: Flora License
-Source0: %{name}-%{version}.tar.gz
-BuildRequires: cmake, gettext-tools
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(ail)
-BuildRequires: pkgconfig(elementary)
-BuildRequires: pkgconfig(appcore-efl)
-BuildRequires: pkgconfig(livebox-viewer)
-BuildRequires: pkgconfig(ecore-x)
-BuildRequires: pkgconfig(livebox-service)
-BuildRequires: pkgconfig(bundle)
-BuildRequires: pkgconfig(capi-appfw-application)
-BuildRequires: pkgconfig(capi-appfw-app-manager)
-BuildRequires: edje-bin
-
-%description
-Livebox viewer development library
-
-%prep
-%setup -q
-
-%build
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
-make %{?jobs:-j%jobs}
-
-%install
-rm -rf %{buildroot}
-%make_install
-
-%post
-
-%files
-%defattr(-,root,root,-)
-/opt/usr/apps/live.viewer/*
-/opt/share/*
diff --git a/live.viewer/res/CMakeLists.txt b/live.viewer/res/CMakeLists.txt
deleted file mode 100644
index 5f6447c..0000000
--- a/live.viewer/res/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-ADD_CUSTOM_TARGET(live-viewer.edj ALL
- COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/res/image
- ${CMAKE_CURRENT_SOURCE_DIR}/live-viewer.edc live-viewer.edj
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/live-viewer.edc
-)
-ADD_DEPENDENCIES(${PROJECT_NAME} live-viewer.edj)
-INSTALL(FILES live-viewer.edj DESTINATION ${PKGROOT}/res/edje)
diff --git a/live.viewer/res/live-viewer.edc b/live.viewer/res/live-viewer.edc
deleted file mode 100644
index fac023d..0000000
--- a/live.viewer/res/live-viewer.edc
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * 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.
- */
-
-images {
- /* image: "a" COMP; */
-}
-
-collections {
- group {
- name: "layout";
- parts {
- part {
- name: "indicator";
- type: RECT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- rel1 { relative: 0.0 0.0; }
- rel2 { relative: 1.0 100/1280; }
- color: 0 0 0 0;
- }
- }
-
- part {
- name: "delete,btn";
- type: SWALLOW;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- rel1 { relative: 4/720 1.0; to_y, "viewer"; }
- rel2 { relative: 716/720 900/1280; }
- }
- }
-
- part {
- name: "controller"; /* size list */
- type: SWALLOW;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- rel1 { relative: 0.0 1.0; to_y, "delete,btn"; }
- rel2 { relative: 0.3 1.0; }
- }
- }
-
- part {
- name: "logger";
- type: SWALLOW;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- rel1 { relative: 1.0 1.0; to_x: "controller"; to_y: "delete,btn"; }
- rel2 { relative: 1.0 1.0; }
- }
- }
-
- part {
- name: "viewer";
- type: RECT;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- rel1 { relative: 4/720 1.0; to, "indicator"; }
- rel2 { relative: 716/720 800/1280; }
- color: 255 255 255 255;
- }
- }
-
- part {
- name: "event,blocker";
- type: RECT;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- rel1 { relative: 0.0 0.0; }
- rel2 { relative: 1.0 1.0; }
- color: 0 0 0 0;
- visible: 0;
- }
- description {
- state: "show" 0.0;
- inherit: "default" 0.0;
- color: 50 50 50 50;
- visible: 1;
- }
- }
-
- part {
- name: "livebox";
- type: SWALLOW;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- rel1 { relative: 0.4 0.4; to, "viewer"; }
- rel2 { relative: 0.6 0.6; to, "viewer"; }
- }
- }
-
- part {
- name: "pd";
- type: SWALLOW;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- rel1 { relative: 0.0 0.95; to_y, "livebox"; }
- rel2 { relative: 1.0 1.0; to_y, "livebox"; }
- visible: 0;
- align: 0.0 0.0;
- }
-
- description {
- state: "show" 0.0;
- rel1 { relative: 0.0 1.0; to_y, "livebox"; }
- rel2 { relative: 1.0 1.0; }
- visible: 1;
- align: 0.0 0.0;
- }
- }
- }
-
- programs {
- program {
- name: "open,pd";
- source: "pd";
- signal: "open";
- action: STATE_SET "show" 0.0;
- target: "pd";
- target: "event,blocker";
- transition: LINEAR 0.2;
- }
- program {
- name: "hide,pd";
- source: "pd";
- signal: "close";
- action: STATE_SET "default" 0.0;
- target: "pd";
- target: "event,blocker";
- transition: LINEAR 0.1;
- after: "hide,pd,done";
- }
-
- program {
- name: "hide,pd,done";
- action: SIGNAL_EMIT "hide,done" "pd";
- }
-
- program {
- name: "event,blocker";
- source: "event,blocker";
- signal: "mouse,clicked,1";
- action: SIGNAL_EMIT "close" "pd";
- }
-
- program {
- name: "pd,close,pd";
- source: "viewer";
- signal: "mouse,clicked,1";
- action: SIGNAL_EMIT "close" "pd";
- }
- }
- }
-}
diff --git a/live.viewer/src/dlist.c b/live.viewer/src/dlist.c
deleted file mode 100644
index fa3082a..0000000
--- a/live.viewer/src/dlist.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "dlist.h"
-
-/*!
- * \brief
- * This dlist is called Modified Doubly Linked List.
- *
- * Noramlly, The dobule linked list contains address of previous and next element.
- * This dlist also contains them, but the tail element only contains prev address.
- *
- * The head element's prev pointer indicates the last element.
- * But the last element's next pointer indicates NIL.
- *
- * So we can find the last element while crawling this DList
- * But we have to remember the address of the head element.
- */
-
-struct dlist {
- struct dlist *next;
- struct dlist *prev;
- void *data;
-};
-
-struct dlist *dlist_append(struct dlist *list, void *data)
-{
- struct dlist *item;
-
- item = malloc(sizeof(*item));
- if (!item)
- return NULL;
-
- item->next = NULL;
- item->data = data;
-
- if (!list) {
- item->prev = item;
-
- list = item;
- } else {
- item->prev = list->prev;
- item->prev->next = item;
- list->prev = item;
- }
-
- assert(!list->prev->next && "item NEXT");
-
- return list;
-}
-
-struct dlist *dlist_prepend(struct dlist *list, void *data)
-{
- struct dlist *item;
-
- item = malloc(sizeof(*item));
- if (!item)
- return NULL;
-
- item->data = data;
-
- if (!list) {
- item->prev = item;
- item->next = NULL;
- } else {
- if (list->prev->next)
- list->prev->next = item;
-
- item->prev = list->prev;
- item->next = list;
-
- list->prev = item;
-
- }
-
- return item;
-}
-
-struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
-{
- if (!list || !l)
- return NULL;
-
- if (l == list)
- list = l->next;
- else
- l->prev->next = l->next;
-
- if (l->next)
- l->next->prev = l->prev;
- /*!
- * \note
- * If the removed entry 'l' has no next element, it is the last element.
- * In this case, check the existence of the list first,
- * and if the list is not empty, update the 'prev' of the list (which is a head element of the list)
- *
- * If we didn't care about this, the head element(list) can indicates the invalid element.
- */
- else if (list)
- list->prev = l->prev;
-
- free(l);
- return list;
-}
-
-struct dlist *dlist_find_data(struct dlist *list, void *data)
-{
- struct dlist *l;
- void *_data;
-
- dlist_foreach(list, l, _data) {
- if (data == _data)
- return l;
- }
-
- return NULL;
-}
-
-void *dlist_data(struct dlist *l)
-{
- return l ? l->data : NULL;
-}
-
-struct dlist *dlist_next(struct dlist *l)
-{
- return l ? l->next : NULL;
-}
-
-struct dlist *dlist_prev(struct dlist *l)
-{
- return l ? l->prev : NULL;
-}
-
-int dlist_count(struct dlist *l)
-{
- register int i;
- struct dlist *n;
- void *data;
-
- i = 0;
- dlist_foreach(l, n, data) {
- i++;
- }
-
- return i;
-}
-
-struct dlist *dlist_nth(struct dlist *l, int nth)
-{
- register int i;
- struct dlist *n;
-
- i = 0;
- for (n = l; n; n = n->next) {
- if (i == nth)
- return n;
- i++;
- }
-
- return NULL;
-}
-
-/* End of a file */
diff --git a/live.viewer/src/lb.c b/live.viewer/src/lb.c
deleted file mode 100644
index 9870b4a..0000000
--- a/live.viewer/src/lb.c
+++ /dev/null
@@ -1,966 +0,0 @@
-/*
- * 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/
- *
- * Unle