remove widget related code 14/55314/2
authorDaehyeon Jung <darrenh.jung@samsung.com>
Wed, 23 Dec 2015 05:01:32 +0000 (14:01 +0900)
committerDaehyeon Jung <darrenh.jung@samsung.com>
Mon, 28 Dec 2015 05:50:08 +0000 (14:50 +0900)
Change-Id: I37feb05f8bf446d1b4e2f6905ec1ec1fd0e613f0

149 files changed:
CMakeLists.txt
data/CMakeLists.txt
data/device/abi.ini [deleted file]
data/device/wayland.mobile.320x480.conf.ini [deleted file]
data/device/wayland.mobile.320x480.resolution.ini [deleted file]
data/device/wayland.mobile.360x360.conf.ini [deleted file]
data/device/wayland.mobile.360x360.resolution.ini [deleted file]
data/device/wayland.mobile.360x480.conf.ini [deleted file]
data/device/wayland.mobile.360x480.resolution.ini [deleted file]
data/device/wayland.mobile.480x800.conf.ini [deleted file]
data/device/wayland.mobile.480x800.resolution.ini [deleted file]
data/device/wayland.mobile.540x960.conf.ini [deleted file]
data/device/wayland.mobile.540x960.resolution.ini [deleted file]
data/device/wayland.mobile.conf.ini [deleted file]
data/device/wayland.mobile.resolution.ini [deleted file]
data/device/wayland.wearable.360x360.conf.ini [deleted file]
data/device/wayland.wearable.360x360.resolution.ini [deleted file]
data/device/wayland.wearable.360x480.conf.ini [deleted file]
data/device/wayland.wearable.360x480.resolution.ini [deleted file]
data/device/wayland.wearable.conf.ini [deleted file]
data/device/wayland.wearable.resolution.ini [deleted file]
data/device/x11.mobile.320x480.conf.ini [deleted file]
data/device/x11.mobile.320x480.resolution.ini [deleted file]
data/device/x11.mobile.360x360.conf.ini [deleted file]
data/device/x11.mobile.360x360.resolution.ini [deleted file]
data/device/x11.mobile.360x480.conf.ini [deleted file]
data/device/x11.mobile.360x480.resolution.ini [deleted file]
data/device/x11.mobile.480x800.conf.ini [deleted file]
data/device/x11.mobile.480x800.resolution.ini [deleted file]
data/device/x11.mobile.540x960.conf.ini [deleted file]
data/device/x11.mobile.540x960.resolution.ini [deleted file]
data/device/x11.mobile.conf.ini [deleted file]
data/device/x11.mobile.resolution.ini [deleted file]
data/device/x11.wearable.360x360.conf.ini [deleted file]
data/device/x11.wearable.360x360.resolution.ini [deleted file]
data/device/x11.wearable.360x480.conf.ini [deleted file]
data/device/x11.wearable.360x480.resolution.ini [deleted file]
data/device/x11.wearable.conf.ini [deleted file]
data/device/x11.wearable.resolution.ini [deleted file]
data/dump_widget.sh [deleted file]
data/emulator/abi.ini [deleted file]
data/emulator/wayland.mobile.320x480.conf.ini [deleted file]
data/emulator/wayland.mobile.320x480.resolution.ini [deleted file]
data/emulator/wayland.mobile.360x360.conf.ini [deleted file]
data/emulator/wayland.mobile.360x360.resolution.ini [deleted file]
data/emulator/wayland.mobile.360x480.conf.ini [deleted file]
data/emulator/wayland.mobile.360x480.resolution.ini [deleted file]
data/emulator/wayland.mobile.480x800.conf.ini [deleted file]
data/emulator/wayland.mobile.480x800.resolution.ini [deleted file]
data/emulator/wayland.mobile.540x960.conf.ini [deleted file]
data/emulator/wayland.mobile.540x960.resolution.ini [deleted file]
data/emulator/wayland.mobile.conf.ini [deleted file]
data/emulator/wayland.mobile.resolution.ini [deleted file]
data/emulator/wayland.wearable.360x360.conf.ini [deleted file]
data/emulator/wayland.wearable.360x360.resolution.ini [deleted file]
data/emulator/wayland.wearable.360x480.conf.ini [deleted file]
data/emulator/wayland.wearable.360x480.resolution.ini [deleted file]
data/emulator/wayland.wearable.conf.ini [deleted file]
data/emulator/wayland.wearable.resolution.ini [deleted file]
data/emulator/x11.mobile.320x480.conf.ini [deleted file]
data/emulator/x11.mobile.320x480.resolution.ini [deleted file]
data/emulator/x11.mobile.360x360.conf.ini [deleted file]
data/emulator/x11.mobile.360x360.resolution.ini [deleted file]
data/emulator/x11.mobile.360x480.conf.ini [deleted file]
data/emulator/x11.mobile.360x480.resolution.ini [deleted file]
data/emulator/x11.mobile.480x800.conf.ini [deleted file]
data/emulator/x11.mobile.480x800.resolution.ini [deleted file]
data/emulator/x11.mobile.540x960.conf.ini [deleted file]
data/emulator/x11.mobile.540x960.resolution.ini [deleted file]
data/emulator/x11.mobile.conf.ini [deleted file]
data/emulator/x11.mobile.resolution.ini [deleted file]
data/emulator/x11.wearable.360x360.conf.ini [deleted file]
data/emulator/x11.wearable.360x360.resolution.ini [deleted file]
data/emulator/x11.wearable.360x480.conf.ini [deleted file]
data/emulator/x11.wearable.360x480.resolution.ini [deleted file]
data/emulator/x11.wearable.conf.ini [deleted file]
data/emulator/x11.wearable.resolution.ini [deleted file]
include/buffer_handler.h [deleted file]
include/client_life.h [deleted file]
include/client_rpc.h [deleted file]
include/conf.h
include/dead_monitor.h [deleted file]
include/event.h [deleted file]
include/fault_manager.h [deleted file]
include/file_service.h [deleted file]
include/group.h [deleted file]
include/instance.h [deleted file]
include/io.h [deleted file]
include/lite-errno.h [deleted file]
include/main.h [deleted file]
include/monitor.h [deleted file]
include/package.h [deleted file]
include/parser.h [deleted file]
include/rpc_to_slave.h [deleted file]
include/script_handler.h [deleted file]
include/server.h [deleted file]
include/service_common.h
include/setting.h [deleted file]
include/shared_fd_service.h [deleted file]
include/slave_life.h [deleted file]
include/slave_rpc.h [deleted file]
include/util.h
include/utility_service.h [deleted file]
include/widget-mgr.h [deleted file]
include/xmonitor.h [deleted file]
packaging/data-provider-master.spec
res/CMakeLists.txt [deleted file]
res/edje/CMakeLists.txt [deleted file]
res/edje/master.edc [deleted file]
src/badge_service.c
src/buffer_handler.c [deleted file]
src/buffer_handler_wayland.c [deleted file]
src/client_life.c [deleted file]
src/client_rpc.c [deleted file]
src/conf.c [deleted file]
src/critical_log.c
src/dead_monitor.c [deleted file]
src/event.c [deleted file]
src/fault_manager.c [deleted file]
src/file_service.c [deleted file]
src/group.c [deleted file]
src/instance.c [deleted file]
src/io.c [deleted file]
src/main.c
src/monitor.c [deleted file]
src/notification_service.c
src/package.c [deleted file]
src/parser.c [deleted file]
src/pkgmgr.c
src/script_handler.c [deleted file]
src/server.c [deleted file]
src/service_common.c
src/setting.c [deleted file]
src/shared_fd_service.c [deleted file]
src/shortcut_service.c
src/slave_life.c [deleted file]
src/slave_rpc.c [deleted file]
src/util.c
src/util_wayland.c [deleted file]
src/util_x11.c [deleted file]
src/utility_service.c [deleted file]
src/widget-mgr.c [deleted file]
src/xmonitor.c [deleted file]
src/xmonitor_wayland.c [deleted file]
widget-mgr/CMakeLists.txt [deleted file]
widget-mgr/include/node.h [deleted file]
widget-mgr/include/widget-info.h [deleted file]
widget-mgr/src/node.c [deleted file]
widget-mgr/src/widget-mgr.c [deleted file]

index e9bbe55..235a48f 100644 (file)
@@ -22,37 +22,12 @@ pkg_check_modules(pkg REQUIRED
        shortcut
        pkgmgr-info
        libsystemd-daemon
-       libtbm
        capi-appfw-app-manager
        cynara-client
        cynara-session
        cynara-creds-socket
 )
 
-IF (LIVEBOX)
-pkg_check_modules(pkg_widget REQUIRED
-       widget_service
-)
-ENDIF (LIVEBOX)
-
-IF (X11_SUPPORT)
-pkg_check_modules(pkg_extra REQUIRED
-       ecore-x
-       x11
-       xfixes
-       xext
-       xdamage
-       libdri2
-       dri2proto
-)
-ENDIF (X11_SUPPORT)
-
-IF (WAYLAND_SUPPORT)
-pkg_check_modules(pkg_extra REQUIRED
-       ecore-wayland
-)
-ENDIF (WAYLAND_SUPPORT)
-
 SET(PACKAGE "${PROJECT_NAME}")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Winline -Werror -fno-builtin-malloc -fno-omit-frame-pointer -g -fPIE")
 
@@ -66,30 +41,22 @@ ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
 ADD_DEFINITIONS("-D_GNU_SOURCE")
 ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
 
-ADD_DEFINITIONS("-DINFO_SOCKET=\"/opt/usr/share/live_magazine/.live.socket\"")
 ADD_DEFINITIONS("-DCLIENT_SOCKET=\"/tmp/.data-provider-master-client.socket\"")
 ADD_DEFINITIONS("-DSLAVE_SOCKET=\"/tmp/.data-provider-master-slave.socket\"")
 ADD_DEFINITIONS("-DSERVICE_SOCKET=\"/tmp/.data-provider-master-service.socket\"")
-ADD_DEFINITIONS("-DSHARED_SOCKET=\"/tmp/.data-provider-master-fd.socket\"")
-
-ADD_DEFINITIONS("-DCATEGORY_WATCH_CLOCK=\"http://tizen.org/category/wearable_clock\"")
 
 ADD_DEFINITIONS("-DCLIENT_PORT=\"8208\"")
 
 ADD_DEFINITIONS("-DBADGE_SOCKET=\"/tmp/.badge.service\"")
 ADD_DEFINITIONS("-DSHORTCUT_SOCKET=\"/tmp/.shortcut.service\"")
 ADD_DEFINITIONS("-DNOTIFICATION_SOCKET=\"/tmp/.notification.service\"")
-ADD_DEFINITIONS("-DUTILITY_SOCKET=\"/tmp/.utility.service\"")
 
-ADD_DEFINITIONS("-DUTILITY_SMACK_LABEL=NULL")
 ADD_DEFINITIONS("-DSHORTCUT_SMACK_LABEL=NULL")
 ADD_DEFINITIONS("-DNOTIFICATION_SMACK_LABEL=NULL")
 ADD_DEFINITIONS("-DBADGE_SMACK_LABEL=NULL")
 ADD_DEFINITIONS("-DDATA_SHARE_LABEL=NULL")
 ADD_DEFINITIONS("-DDEFAULT_SMACK_LABEL=NULL")
 
-ADD_DEFINITIONS("-DDEFAULT_MASTER_CONF=\"/usr/share/${PROJECT_NAME}/conf.ini\"")
-
 ADD_DEFINITIONS("-DNDEBUG")
 
 ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET")
@@ -103,7 +70,7 @@ ENDIF (MOBILE)
 SET(BUILD_SOURCE
        src/main.c
        src/util.c
-       src/setting.c
+       src/pkgmgr.c
        src/critical_log.c
        src/shortcut_service.c
        src/badge_service.c
@@ -111,154 +78,22 @@ SET(BUILD_SOURCE
        src/service_common.c
 )
 
-IF (LIVEBOX)
-       ADD_DEFINITIONS("-DHAVE_LIVEBOX")
-       SET(BUILD_SOURCE
-               ${BUILD_SOURCE}
-               src/utility_service.c
-               src/dead_monitor.c
-               src/package.c
-               src/instance.c
-               src/server.c
-               src/fault_manager.c
-               src/parser.c
-               src/io.c
-               src/slave_life.c
-               src/slave_rpc.c
-               src/client_life.c
-               src/client_rpc.c
-               src/group.c
-               src/script_handler.c
-               src/widget-mgr.c
-               src/pkgmgr.c
-               src/event.c
-               src/file_service.c
-               src/conf.c
-               src/monitor.c
-               src/shared_fd_service.c
-       )
-
-       IF (WAYLAND_SUPPORT)
-               ADD_DEFINITIONS("-DHAVE_WAYLAND")
-               SET(BUILD_SOURCE
-                       ${BUILD_SOURCE}
-                       src/xmonitor_wayland.c
-                       src/buffer_handler_wayland.c
-                       src/util_wayland.c
-               )
-       ENDIF (WAYLAND_SUPPORT)
-
-       IF (X11_SUPPORT)
-               ADD_DEFINITIONS("-DHAVE_X11")
-               SET(BUILD_SOURCE
-                       ${BUILD_SOURCE}
-                       src/xmonitor.c
-                       src/buffer_handler.c
-                       src/util_x11.c
-               )
-       ENDIF (X11_SUPPORT)
-ENDIF (LIVEBOX)
-
-IF (WAYLAND_SUPPORT)
-       ADD_DEFINITIONS("-DHAVE_WAYLAND")
-       SET(BUILD_SOURCE
-               ${BUILD_SOURCE}
-               src/util_wayland.c
-       )
-ENDIF (WAYLAND_SUPPORT)
-
-IF (X11_SUPPORT)
-       ADD_DEFINITIONS("-DHAVE_X11")
-       SET(BUILD_SOURCE
-               ${BUILD_SOURCE}
-               src/util_x11.c
-       )
-ENDIF (X11_SUPPORT)
-
 STRING(REPLACE "-L-l" "-l" pkg_fixed_LDFLAGS ${pkg_LDFLAGS})
 STRING(REPLACE "-l" " -l" pkg_LDFLAGS ${pkg_fixed_LDFLAGS})
 STRING(REPLACE "-L" " -L" pkg_fixed_LDFLAGS ${pkg_LDFLAGS})
 STRING(REGEX REPLACE "^ " "" pkg_LDFLAGS ${pkg_fixed_LDFLAGS})
 
-#ADD_DEFINITIONS("-D_APPLY_SCRIPT_ASYNC_UPDATE")
-#ADD_DEFINITIONS("-DFLOG")
 ADD_DEFINITIONS(${pkg_CFLAGS})
 ADD_DEFINITIONS(${pkg_LDFLAGS})
-ADD_DEFINITIONS(${pkg_extra_CFLAGS})
-ADD_DEFINITIONS(${pkg_extra_LDFLAGS})
-ADD_DEFINITIONS(${pkg_widget_CFLAGS})
-ADD_DEFINITIONS(${pkg_widget_LDFLAGS})
 
 ADD_EXECUTABLE(${PROJECT_NAME} ${BUILD_SOURCE})
 
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} ${pkg_extra_LDFLAGS} ${pkg_widget_LDFLAGS} "-ldl -lrt -pie")
-
-IF (LIVEBOX)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/abi.ini DESTINATION /usr/share/${PROJECT_NAME} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PRODUCT}.conf.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PRODUCT}.resolution.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-
-IF (WAYLAND_SUPPORT)
-       IF (WEARABLE)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.360x480.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/360x480 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.360x480.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/360x480 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.360x360.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/360x360 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.360x360.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/360x360 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/320x320 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.wearable.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/320x320 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-       ELSE (WEARABLE)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.320x480.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/320x480 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.320x480.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/320x480 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.480x800.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/480x800 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.480x800.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/480x800 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/720x1280 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/720x1280 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.540x960.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/540x960 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/wayland.mobile.540x960.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/540x960 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-       ENDIF (WEARABLE)
-ELSE (WAYLAND_SUPPORT)
-       IF (WEARABLE)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.360x480.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/360x480 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.360x480.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/360x480 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.360x360.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/360x360 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.360x360.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/360x360 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/320x320 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/320x320 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} "-ldl -lrt -pie")
 
-       ELSE (WEARABLE)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.320x480.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/320x480 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.320x480.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/320x480 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.480x800.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/480x800 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.480x800.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/480x800 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/720x1280 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/720x1280 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.540x960.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/540x960 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-               INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.540x960.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/540x960 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-       ENDIF (WEARABLE)
-ENDIF (WAYLAND_SUPPORT)
-
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PRODUCT}.conf.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PRODUCT}.resolution.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-ENDIF (LIVEBOX)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "${PROJECT_NAME}")
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-#INSTALL(FILES ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.rule DESTINATION /etc/smack/accesses.d RENAME ${PROJECT_NAME})
 
 # INCLUDE FOR BUILD & INSTALL .PO FILES
-ADD_SUBDIRECTORY(res)
 ADD_SUBDIRECTORY(data)
-IF (LIVEBOX)
-ENDIF (LIVEBOX)
-
-IF (X11_SUPPORT)
-       IF ("${ENGINEER_BINARY}" STREQUAL "true")
-               ADD_SUBDIRECTORY(widget-mgr)
-       ENDIF ("${ENGINEER_BINARY}" STREQUAL "true")
-ENDIF (X11_SUPPORT)
 
 # End of a file
index 30205e4..791e98c 100644 (file)
@@ -1,13 +1,6 @@
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}.service DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-IF (LIVEBOX)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/dump_widget.sh DESTINATION /opt/etc/dump.d/module.d/ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-ENDIF (LIVEBOX)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}.target DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-client.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-provider.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-fd.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-service.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-badge.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-notification.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-shortcut.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}-utility.socket DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
diff --git a/data/device/abi.ini b/data/device/abi.ini
deleted file mode 100644 (file)
index 3b57cd0..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-[c]
-package=org.tizen.data-provider-slave
-
-[cpp]
-package=org.tizen.data-provider-slave
-
-[html]
-package=widget.web-provider
-
-[osp]
-package=gi2qxenosh.osp-appwidget-service
-
-[app]
-package=/APPID/
-
-[svc]
-package=org.tizen.data-provider-slave.svc
-
-[meta]
-package=meta-key
diff --git a/data/device/wayland.mobile.320x480.conf.ini b/data/device/wayland.mobile.320x480.conf.ini
deleted file mode 100644 (file)
index ff5b5bc..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=320
-base_height=480
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-#input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-#auto_align=true
diff --git a/data/device/wayland.mobile.320x480.resolution.ini b/data/device/wayland.mobile.320x480.resolution.ini
deleted file mode 100644 (file)
index c848adf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=0x0
-2x1=0x0
-2x2=0x0
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=302x302
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=320x480
-base=320x480
diff --git a/data/device/wayland.mobile.360x360.conf.ini b/data/device/wayland.mobile.360x360.conf.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/device/wayland.mobile.360x360.resolution.ini b/data/device/wayland.mobile.360x360.resolution.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/device/wayland.mobile.360x480.conf.ini b/data/device/wayland.mobile.360x480.conf.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/device/wayland.mobile.360x480.resolution.ini b/data/device/wayland.mobile.360x480.resolution.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/device/wayland.mobile.480x800.conf.ini b/data/device/wayland.mobile.480x800.conf.ini
deleted file mode 100644 (file)
index 993296f..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-base_width=480
-base_height=800
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=20.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event1
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-use_event_time=true
-use_gettimeofday=false
-slave_event_boost_on=-10
-slave_event_boost_off=0
-event_filter=0.5
-#slave_limit_to_ttl=true
-#frame_skip=5
diff --git a/data/device/wayland.mobile.480x800.resolution.ini b/data/device/wayland.mobile.480x800.resolution.ini
deleted file mode 100644 (file)
index 63ad36e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=126x126
-2x1=0x0
-2x2=0x0
-4x1=0x0
-4x2=470x234
-4x3=0x0
-4x4=470x470
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=480x800
-base=480x800
diff --git a/data/device/wayland.mobile.540x960.conf.ini b/data/device/wayland.mobile.540x960.conf.ini
deleted file mode 100644 (file)
index d50f449..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-base_width=540
-base_height=960
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=20.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=sec_touchscreen
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-use_event_time=true
-use_gettimeofday=false
-slave_event_boost_on=-10
-slave_event_boost_off=0
-event_filter=0.5
-#slave_limit_to_ttl=true
-#frame_skip=5
diff --git a/data/device/wayland.mobile.540x960.resolution.ini b/data/device/wayland.mobile.540x960.resolution.ini
deleted file mode 100644 (file)
index 31566cf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=130x150
-2x1=264x150
-2x2=264x304
-4x1=534x150
-4x2=534x304
-4x3=534x458
-4x4=534x612
-4x5=534x766
-4x6=534x920
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=540x960
-base=540x960
diff --git a/data/device/wayland.mobile.conf.ini b/data/device/wayland.mobile.conf.ini
deleted file mode 100644 (file)
index 6d667e1..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=720
-base_height=1280
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=104857600
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=shm
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-#input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-#auto_align=true
diff --git a/data/device/wayland.mobile.resolution.ini b/data/device/wayland.mobile.resolution.ini
deleted file mode 100644 (file)
index e2b5a17..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-1x1=175x175
-2x1=354x175
-2x2=354x354
-4x1=712x175
-4x2=712x354
-4x3=712x533
-4x4=712x712
-4x5=712x891
-4x6=712x1070
-21x21=224x215
-23x21=680x215
-23x23=680x653
-0x0=720x1280
diff --git a/data/device/wayland.wearable.360x360.conf.ini b/data/device/wayland.wearable.360x360.conf.ini
deleted file mode 100644 (file)
index b562eb4..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-base_width=360
-base_height=360
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event0
-pd_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-check_lcd=false
diff --git a/data/device/wayland.wearable.360x360.resolution.ini b/data/device/wayland.wearable.360x360.resolution.ini
deleted file mode 100644 (file)
index b54c8a9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=170x170
-2x1=0x0
-2x2=360x360
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=360x360
-base=360x360
diff --git a/data/device/wayland.wearable.360x480.conf.ini b/data/device/wayland.wearable.360x480.conf.ini
deleted file mode 100644 (file)
index 7a695cf..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=360
-base_height=480
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event0
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-check_lcd=false
diff --git a/data/device/wayland.wearable.360x480.resolution.ini b/data/device/wayland.wearable.360x480.resolution.ini
deleted file mode 100644 (file)
index fea1ffa..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=170x170
-2x1=0x0
-2x2=360x480
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=360x480
-base=360x480
diff --git a/data/device/wayland.wearable.conf.ini b/data/device/wayland.wearable.conf.ini
deleted file mode 100644 (file)
index c6514c6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=320
-base_height=320
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=104857600
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=shm
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-#input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-#auto_align=true
diff --git a/data/device/wayland.wearable.resolution.ini b/data/device/wayland.wearable.resolution.ini
deleted file mode 100644 (file)
index b9e7561..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=320x320
-2x1=0x0
-2x2=320x320
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=320x320
-base=320x320
diff --git a/data/device/x11.mobile.320x480.conf.ini b/data/device/x11.mobile.320x480.conf.ini
deleted file mode 100644 (file)
index ff5b5bc..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=320
-base_height=480
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-#input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-#auto_align=true
diff --git a/data/device/x11.mobile.320x480.resolution.ini b/data/device/x11.mobile.320x480.resolution.ini
deleted file mode 100644 (file)
index c848adf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=0x0
-2x1=0x0
-2x2=0x0
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=302x302
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=320x480
-base=320x480
diff --git a/data/device/x11.mobile.360x360.conf.ini b/data/device/x11.mobile.360x360.conf.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/device/x11.mobile.360x360.resolution.ini b/data/device/x11.mobile.360x360.resolution.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/device/x11.mobile.360x480.conf.ini b/data/device/x11.mobile.360x480.conf.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/device/x11.mobile.360x480.resolution.ini b/data/device/x11.mobile.360x480.resolution.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/device/x11.mobile.480x800.conf.ini b/data/device/x11.mobile.480x800.conf.ini
deleted file mode 100644 (file)
index 993296f..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-base_width=480
-base_height=800
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=20.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event1
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-use_event_time=true
-use_gettimeofday=false
-slave_event_boost_on=-10
-slave_event_boost_off=0
-event_filter=0.5
-#slave_limit_to_ttl=true
-#frame_skip=5
diff --git a/data/device/x11.mobile.480x800.resolution.ini b/data/device/x11.mobile.480x800.resolution.ini
deleted file mode 100644 (file)
index 2f8f4b7..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=116x116
-2x1=234x116
-2x2=234x234
-4x1=470x116
-4x2=470x234
-4x3=470x352
-4x4=470x470
-4x5=470x588
-4x6=470x706
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=480x800
-base=480x800
diff --git a/data/device/x11.mobile.540x960.conf.ini b/data/device/x11.mobile.540x960.conf.ini
deleted file mode 100644 (file)
index d50f449..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-base_width=540
-base_height=960
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=20.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=sec_touchscreen
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-use_event_time=true
-use_gettimeofday=false
-slave_event_boost_on=-10
-slave_event_boost_off=0
-event_filter=0.5
-#slave_limit_to_ttl=true
-#frame_skip=5
diff --git a/data/device/x11.mobile.540x960.resolution.ini b/data/device/x11.mobile.540x960.resolution.ini
deleted file mode 100644 (file)
index 31566cf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=130x150
-2x1=264x150
-2x2=264x304
-4x1=534x150
-4x2=534x304
-4x3=534x458
-4x4=534x612
-4x5=534x766
-4x6=534x920
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=540x960
-base=540x960
diff --git a/data/device/x11.mobile.conf.ini b/data/device/x11.mobile.conf.ini
deleted file mode 100644 (file)
index 3de8d17..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-base_width=720
-base_height=1280
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=104857600
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-#input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-#auto_align=true
-#use_event_time=true
-event_filter=0.5
diff --git a/data/device/x11.mobile.resolution.ini b/data/device/x11.mobile.resolution.ini
deleted file mode 100644 (file)
index e2b5a17..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-1x1=175x175
-2x1=354x175
-2x2=354x354
-4x1=712x175
-4x2=712x354
-4x3=712x533
-4x4=712x712
-4x5=712x891
-4x6=712x1070
-21x21=224x215
-23x21=680x215
-23x23=680x653
-0x0=720x1280
diff --git a/data/device/x11.wearable.360x360.conf.ini b/data/device/x11.wearable.360x360.conf.ini
deleted file mode 100644 (file)
index b562eb4..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-base_width=360
-base_height=360
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event0
-pd_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-check_lcd=false
diff --git a/data/device/x11.wearable.360x360.resolution.ini b/data/device/x11.wearable.360x360.resolution.ini
deleted file mode 100644 (file)
index b54c8a9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=170x170
-2x1=0x0
-2x2=360x360
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=360x360
-base=360x360
diff --git a/data/device/x11.wearable.360x480.conf.ini b/data/device/x11.wearable.360x480.conf.ini
deleted file mode 100644 (file)
index 7a695cf..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=360
-base_height=480
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event0
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-check_lcd=false
diff --git a/data/device/x11.wearable.360x480.resolution.ini b/data/device/x11.wearable.360x480.resolution.ini
deleted file mode 100644 (file)
index fea1ffa..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=170x170
-2x1=0x0
-2x2=360x480
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=360x480
-base=360x480
diff --git a/data/device/x11.wearable.conf.ini b/data/device/x11.wearable.conf.ini
deleted file mode 100644 (file)
index 37b61a5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-base_width=320
-base_height=320
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=104857600
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-#input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-#auto_align=true
-#use_event_time=true
-check_lcd=false
diff --git a/data/device/x11.wearable.resolution.ini b/data/device/x11.wearable.resolution.ini
deleted file mode 100644 (file)
index 5b6923e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=170x170
-2x1=0x0
-2x2=320x320
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=320x320
-base=320x320
diff --git a/data/dump_widget.sh b/data/dump_widget.sh
deleted file mode 100644 (file)
index 5af7857..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-WIDGET_DEBUG=$1/widget
-mkdir -p ${WIDGET_DEBUG}
-/bin/cp -r /opt/usr/share/live_magazine ${WIDGET_DEBUG}
-/bin/cp -r /tmp/.widget.service ${WIDGET_DEBUG}/log
-/bin/cp -r /usr/dbspace/.widget.db ${WIDGET_DEBUG}
-ls -la /tmp/ | /bin/grep srw > ${WIDGET_DEBUG}/log/tmp.hidden_files
diff --git a/data/emulator/abi.ini b/data/emulator/abi.ini
deleted file mode 100644 (file)
index 3b57cd0..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-[c]
-package=org.tizen.data-provider-slave
-
-[cpp]
-package=org.tizen.data-provider-slave
-
-[html]
-package=widget.web-provider
-
-[osp]
-package=gi2qxenosh.osp-appwidget-service
-
-[app]
-package=/APPID/
-
-[svc]
-package=org.tizen.data-provider-slave.svc
-
-[meta]
-package=meta-key
diff --git a/data/emulator/wayland.mobile.320x480.conf.ini b/data/emulator/wayland.mobile.320x480.conf.ini
deleted file mode 100644 (file)
index ff5b5bc..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=320
-base_height=480
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-#input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-#auto_align=true
diff --git a/data/emulator/wayland.mobile.320x480.resolution.ini b/data/emulator/wayland.mobile.320x480.resolution.ini
deleted file mode 100644 (file)
index c848adf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=0x0
-2x1=0x0
-2x2=0x0
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=302x302
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=320x480
-base=320x480
diff --git a/data/emulator/wayland.mobile.360x360.conf.ini b/data/emulator/wayland.mobile.360x360.conf.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/emulator/wayland.mobile.360x360.resolution.ini b/data/emulator/wayland.mobile.360x360.resolution.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/emulator/wayland.mobile.360x480.conf.ini b/data/emulator/wayland.mobile.360x480.conf.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/emulator/wayland.mobile.360x480.resolution.ini b/data/emulator/wayland.mobile.360x480.resolution.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/emulator/wayland.mobile.480x800.conf.ini b/data/emulator/wayland.mobile.480x800.conf.ini
deleted file mode 100644 (file)
index 993296f..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-base_width=480
-base_height=800
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=20.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event1
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-use_event_time=true
-use_gettimeofday=false
-slave_event_boost_on=-10
-slave_event_boost_off=0
-event_filter=0.5
-#slave_limit_to_ttl=true
-#frame_skip=5
diff --git a/data/emulator/wayland.mobile.480x800.resolution.ini b/data/emulator/wayland.mobile.480x800.resolution.ini
deleted file mode 100644 (file)
index 63ad36e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=126x126
-2x1=0x0
-2x2=0x0
-4x1=0x0
-4x2=470x234
-4x3=0x0
-4x4=470x470
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=480x800
-base=480x800
diff --git a/data/emulator/wayland.mobile.540x960.conf.ini b/data/emulator/wayland.mobile.540x960.conf.ini
deleted file mode 100644 (file)
index 5bf3240..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-base_width=540
-base_height=960
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=20.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-use_event_time=true
-use_gettimeofday=false
-slave_event_boost_on=-10
-slave_event_boost_off=0
-event_filter=0.5
-#slave_limit_to_ttl=true
-#frame_skip=5
diff --git a/data/emulator/wayland.mobile.540x960.resolution.ini b/data/emulator/wayland.mobile.540x960.resolution.ini
deleted file mode 100644 (file)
index 31566cf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=130x150
-2x1=264x150
-2x2=264x304
-4x1=534x150
-4x2=534x304
-4x3=534x458
-4x4=534x612
-4x5=534x766
-4x6=534x920
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=540x960
-base=540x960
diff --git a/data/emulator/wayland.mobile.conf.ini b/data/emulator/wayland.mobile.conf.ini
deleted file mode 100644 (file)
index 84e2f02..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=720
-base_height=1280
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=104857600
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=shm
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-#input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=1
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-#auto_align=true
diff --git a/data/emulator/wayland.mobile.resolution.ini b/data/emulator/wayland.mobile.resolution.ini
deleted file mode 100644 (file)
index e2b5a17..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-1x1=175x175
-2x1=354x175
-2x2=354x354
-4x1=712x175
-4x2=712x354
-4x3=712x533
-4x4=712x712
-4x5=712x891
-4x6=712x1070
-21x21=224x215
-23x21=680x215
-23x23=680x653
-0x0=720x1280
diff --git a/data/emulator/wayland.wearable.360x360.conf.ini b/data/emulator/wayland.wearable.360x360.conf.ini
deleted file mode 100644 (file)
index b562eb4..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-base_width=360
-base_height=360
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event0
-pd_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-check_lcd=false
diff --git a/data/emulator/wayland.wearable.360x360.resolution.ini b/data/emulator/wayland.wearable.360x360.resolution.ini
deleted file mode 100644 (file)
index b54c8a9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=170x170
-2x1=0x0
-2x2=360x360
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=360x360
-base=360x360
diff --git a/data/emulator/wayland.wearable.360x480.conf.ini b/data/emulator/wayland.wearable.360x480.conf.ini
deleted file mode 100644 (file)
index 7a695cf..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=360
-base_height=480
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event0
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-check_lcd=false
diff --git a/data/emulator/wayland.wearable.360x480.resolution.ini b/data/emulator/wayland.wearable.360x480.resolution.ini
deleted file mode 100644 (file)
index fea1ffa..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=170x170
-2x1=0x0
-2x2=360x480
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=360x480
-base=360x480
diff --git a/data/emulator/wayland.wearable.conf.ini b/data/emulator/wayland.wearable.conf.ini
deleted file mode 100644 (file)
index c6514c6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=320
-base_height=320
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=104857600
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=shm
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-#input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-#auto_align=true
diff --git a/data/emulator/wayland.wearable.resolution.ini b/data/emulator/wayland.wearable.resolution.ini
deleted file mode 100644 (file)
index b9e7561..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=320x320
-2x1=0x0
-2x2=320x320
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=320x320
-base=320x320
diff --git a/data/emulator/x11.mobile.320x480.conf.ini b/data/emulator/x11.mobile.320x480.conf.ini
deleted file mode 100644 (file)
index 9f208a7..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=320
-base_height=480
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-#auto_align=true
diff --git a/data/emulator/x11.mobile.320x480.resolution.ini b/data/emulator/x11.mobile.320x480.resolution.ini
deleted file mode 100644 (file)
index c848adf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=0x0
-2x1=0x0
-2x2=0x0
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=302x302
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=320x480
-base=320x480
diff --git a/data/emulator/x11.mobile.360x360.conf.ini b/data/emulator/x11.mobile.360x360.conf.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/emulator/x11.mobile.360x360.resolution.ini b/data/emulator/x11.mobile.360x360.resolution.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/emulator/x11.mobile.360x480.conf.ini b/data/emulator/x11.mobile.360x480.conf.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/emulator/x11.mobile.360x480.resolution.ini b/data/emulator/x11.mobile.360x480.resolution.ini
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/data/emulator/x11.mobile.480x800.conf.ini b/data/emulator/x11.mobile.480x800.conf.ini
deleted file mode 100644 (file)
index 2b3cacf..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-base_width=480
-base_height=800
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=20.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-use_event_time=true
-use_gettimeofday=false
-slave_event_boost_on=-10
-slave_event_boost_off=0
-event_filter=0.5
-#slave_limit_to_ttl=true
-#frame_skip=5
diff --git a/data/emulator/x11.mobile.480x800.resolution.ini b/data/emulator/x11.mobile.480x800.resolution.ini
deleted file mode 100644 (file)
index 2f8f4b7..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=116x116
-2x1=234x116
-2x2=234x234
-4x1=470x116
-4x2=470x234
-4x3=470x352
-4x4=470x470
-4x5=470x588
-4x6=470x706
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=480x800
-base=480x800
diff --git a/data/emulator/x11.mobile.540x960.conf.ini b/data/emulator/x11.mobile.540x960.conf.ini
deleted file mode 100644 (file)
index 5bf3240..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-base_width=540
-base_height=960
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=30.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=20.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-use_event_time=true
-use_gettimeofday=false
-slave_event_boost_on=-10
-slave_event_boost_off=0
-event_filter=0.5
-#slave_limit_to_ttl=true
-#frame_skip=5
diff --git a/data/emulator/x11.mobile.540x960.resolution.ini b/data/emulator/x11.mobile.540x960.resolution.ini
deleted file mode 100644 (file)
index 31566cf..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=130x150
-2x1=264x150
-2x2=264x304
-4x1=534x150
-4x2=534x304
-4x3=534x458
-4x4=534x612
-4x5=534x766
-4x6=534x920
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=540x960
-base=540x960
diff --git a/data/emulator/x11.mobile.conf.ini b/data/emulator/x11.mobile.conf.ini
deleted file mode 100644 (file)
index 2dc2bf0..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-base_width=720
-base_height=1280
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=104857600
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[utility],[badge]
-#auto_align=true
-#use_event_time=true
-event_filter=0.5
diff --git a/data/emulator/x11.mobile.resolution.ini b/data/emulator/x11.mobile.resolution.ini
deleted file mode 100644 (file)
index e2b5a17..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-1x1=175x175
-2x1=354x175
-2x2=354x354
-4x1=712x175
-4x2=712x354
-4x3=712x533
-4x4=712x712
-4x5=712x891
-4x6=712x1070
-21x21=224x215
-23x21=680x215
-23x23=680x653
-0x0=720x1280
diff --git a/data/emulator/x11.wearable.360x360.conf.ini b/data/emulator/x11.wearable.360x360.conf.ini
deleted file mode 100644 (file)
index 2595602..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-base_width=360
-base_height=360
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event2
-pd_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-auto_align=false
-check_lcd=false
diff --git a/data/emulator/x11.wearable.360x360.resolution.ini b/data/emulator/x11.wearable.360x360.resolution.ini
deleted file mode 100644 (file)
index b54c8a9..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=170x170
-2x1=0x0
-2x2=360x360
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=360x360
-base=360x360
diff --git a/data/emulator/x11.wearable.360x480.conf.ini b/data/emulator/x11.wearable.360x480.conf.ini
deleted file mode 100644 (file)
index 4a2181a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-base_width=360
-base_height=480
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=1048576
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[notification],[badge]
-check_lcd=false
diff --git a/data/emulator/x11.wearable.360x480.resolution.ini b/data/emulator/x11.wearable.360x480.resolution.ini
deleted file mode 100644 (file)
index fea1ffa..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=170x170
-2x1=0x0
-2x2=360x480
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=360x480
-base=360x480
diff --git a/data/emulator/x11.wearable.conf.ini b/data/emulator/x11.wearable.conf.ini
deleted file mode 100644 (file)
index 987ce52..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-base_width=320
-base_height=320
-minimum_period=1.0
-#script=edje
-#default_abi=c
-#default_group=disclosure
-default_period=-1.0
-default_packet_time=0.0001
-#default_content=default
-minimum_space=104857600
-#replace_tag=/APPID/
-slave_ttl=0.0
-slave_activate_time=30.0
-slave_relaunch_time=3.0
-slave_relaunch_count=3
-max_log_line=1000
-max_log_file=3
-sqilte_flush_max=1048576
-#db_path=/usr/dbspace/.widget.db
-#share_path=/opt/usr/share/live_magazine/
-log_path=/tmp/.widget.service
-#always_path=/opt/usr/share/live_magazine/always
-#reader_path=/opt/usr/share/live_magazine/reader
-#script_port_path=/usr/share/data-provider-master/plugin-script/
-ping_interval=240.0
-slave_max_load=30
-use_sw_backend=false
-provider_method=pixmap
-debug_mode=false
-overwrite_content=false
-com_core_thread=true
-use_xmonitor=false
-input=/dev/input/event2
-gbar_request_timeout=5.0
-premultiplied=0
-#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[widget],[shortcut],[badge]
-#auto_align=true
-#use_event_time=true
-check_lcd=false
diff --git a/data/emulator/x11.wearable.resolution.ini b/data/emulator/x11.wearable.resolution.ini
deleted file mode 100644 (file)
index 5b6923e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1x1=170x170
-2x1=0x0
-2x2=320x320
-4x1=0x0
-4x2=0x0
-4x3=0x0
-4x4=0x0
-4x5=0x0
-4x6=0x0
-21x21=0x0
-23x21=0x0
-23x23=0x0
-0x0=320x320
-base=320x320
diff --git a/include/buffer_handler.h b/include/buffer_handler.h
deleted file mode 100644 (file)
index f3b0b3d..0000000
+++ /dev/null
@@ -1,348 +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 buffer_info;
-struct inst_info;
-struct buffer;
-
-#include <widget_buffer.h>
-
-/*!
- * \brief
- * \param[in] type
- * \param[in] w
- * \param[in] h
- * \param[in] pixel_size
- * \return buffer_info
- */
-extern struct buffer_info *buffer_handler_create(struct inst_info *inst, enum widget_fb_type type, int w, int h, int pixel_size);
-
-/*!
- * \brief
- * \param[in] info
- * \return int
- */
-extern int buffer_handler_destroy(struct buffer_info *info);
-
-/*!
- * \brief
- * \param[in] info
- * \return int
- */
-extern int buffer_handler_load(struct buffer_info *info);
-
-/*!
- * \brief
- * \param[in] info
- * \return int
- */
-extern int buffer_handler_unload(struct buffer_info *info);
-
-/*!
- * \brief
- * \param[in] info
- * \return int
- */
-extern int buffer_handler_is_loaded(const struct buffer_info *info);
-
-/*!
- * \brief Reallocate buffer
- * \param[in] info
- * \param[in] w
- * \param[in] h
- * \return int
- */
-extern int buffer_handler_resize(struct buffer_info *info, int w, int h, int pixel_size);
-
-/*!
- * \brief Only update the size information
- * \param[in] info
- * \param[in] w
- * \param[in] h
- * \return void
- */
-extern void buffer_handler_update_size(struct buffer_info *info, int w, int h);
-
-/*!
- * \brief
- * \param[in] info
- * \return const char *
- */
-extern const char *buffer_handler_id(const struct buffer_info *info);
-
-/*!
- * \param[in] info
- * \return widget_fb_type
- */
-extern enum widget_fb_type buffer_handler_type(const struct buffer_info *info);
-
-/*!
- * \brief This API is not supported for Pixmap.
- * \param[in] info
- * \return void*
- */
-extern void *buffer_handler_fb(struct buffer_info *info);
-
-/*!
- * \brief
- * \param[in] info
- * \param[out] w
- * \param[out] h
- * \return int
- */
-extern int buffer_handler_get_size(struct buffer_info *info, int *w, int *h);
-
-/*!
- * \brief This API only can be used for file type buffer
- * \param[in] info
- * \return void
- */
-extern void buffer_handler_flush(struct buffer_info *info);
-
-/*!
- * \brief
- * \param[in] info
- * \return 0 if fails. Return value should be casted to Pixmap type
- */
-extern int buffer_handler_pixmap(const struct buffer_info *info);
-
-/*!
- * \brief
- * \param[in] info
- * \return buffer
- */
-extern void *buffer_handler_pixmap_acquire_buffer(struct buffer_info *info);
-
-/*!
- * \brief
- * \param[in] info
- * \return int
- */
-extern int buffer_handler_pixmap_release_buffer(void *canvas);
-
-/*!
- * \brief
- * \param[in] info
- * \return int
- */
-extern int buffer_handler_stride(struct buffer_info *info);
-
-/*!
- * \brief
- * \param[in] info
- * \return int
- */
-extern int buffer_handler_pixels(struct buffer_info *info);
-
-/*!
- * \brief
- * \param[in] info
- * \return int
- */
-extern int buffer_handler_auto_align(void);
-
-/*!
- * \brief
- * \return int
- */
-extern int buffer_handler_init(void);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \return int
- * \retval
- * \pre
- * \post
- * \sa
- */
-extern int buffer_handler_fini(void);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] info
- * \return void *
- * \retval NULL
- * \retval address
- * \pre
- * \post
- * \sa
- */
-extern void *buffer_handler_pixmap_ref(struct buffer_info *info);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] buffer_ptr
- * \return int
- * \retval 
- * \pre
- * \post
- * \sa
- */
-extern int buffer_handler_pixmap_unref(void *buffer_ptr);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] pixmap
- * \return void *
- * \retval
- * \pre
- * \post
- * \sa
- */
-extern void *buffer_handler_pixmap_find(int pixmap);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] info
- * \return void *
- * \retval
- * \pre
- * \post
- * \sa
- */
-extern void *buffer_handler_pixmap_buffer(struct buffer_info *info);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] info
- * \return struct inst_info *
- * \retval
- * \pre
- * \post
- * \sa
- */
-extern struct inst_info *buffer_handler_instance(struct buffer_info *info);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] type
- * \param[in] resource
- * \return widget_fb_t 
- * \retval NULL
- * \retval address
- * \pre
- * \post
- * \sa
- */
-extern widget_fb_t buffer_handler_raw_open(enum widget_fb_type type, void *resource);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] buffer
- * \return int
- * \retval
- * \pre
- * \post
- * \sa
- */
-extern int buffer_handler_raw_close(widget_fb_t buffer);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] buffer
- * \return void *
- * \retval NULL
- * \pre
- * \post
- * \sa
- */
-extern void *buffer_handler_raw_data(widget_fb_t buffer);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] buffer
- * \return int
- * \retval
- * \pre
- * \post
- * \sa
- */
-extern int buffer_handler_raw_size(widget_fb_t buffer);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] buffer
- * \return int
- * \retval
- * \pre
- * \post
- * \sa
- */
-extern int buffer_handler_lock(struct buffer_info *buffer);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] buffer
- * \return int
- * \retval
- * \pre
- * \post
- * \sa
- */
-extern int buffer_handler_unlock(struct buffer_info *buffer);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] buffer
- * \param[in] data
- * \return int
- * \retval
- * \pre
- * \post
- * \sa
- */
-extern int buffer_handler_set_data(struct buffer_info *buffer, void *data);
-
-/*!
- * \brief
- * \details
- * \remarks
- * \param[in] buffer
- * \return void *
- * \retval NULL
- * \retval address
- * \pre
- * \post
- * \sa
- */
-extern void *buffer_handler_data(struct buffer_info *buffer);
-/* End of a file */
diff --git a/include/client_life.h b/include/client_life.h
deleted file mode 100644 (file)
index e96d103..0000000
+++ /dev/null
@@ -1,124 +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.
- */
-
-enum client_event {
-       CLIENT_EVENT_ACTIVATE,
-       CLIENT_EVENT_DEACTIVATE
-};
-
-enum client_global_event {
-       CLIENT_GLOBAL_EVENT_CREATE,
-       CLIENT_GLOBAL_EVENT_DESTROY
-};
-
-struct inst_info;
-struct packet;
-
-/*!
- * \note
- * Create & Destroy
- */
-extern struct client_node *client_create(pid_t pid, int handle, const char *direct_addr);
-#define client_destroy(client) client_unref(client)
-
-/*!
- * \note
- * Reference count
- */
-extern struct client_node *client_ref(struct client_node *client);
-extern struct client_node *client_unref(struct client_node *client);
-extern const int const client_refcnt(const struct client_node *client);
-
-/*!
- * \note
- * Information of client PID
- */
-extern const pid_t const client_pid(const struct client_node *client);
-extern struct client_node *client_find_by_pid(pid_t pid);
-extern struct client_node *client_find_by_rpc_handle(int handle);
-
-/*!
- * \note
- * Statistics for state of client
- */
-extern const int const client_count_paused(void);
-extern int client_is_all_paused(void);
-extern int client_count(void);
-
-/*!
- * \note
- * For dead signal handler
- */
-extern struct client_node *client_deactivated_by_fault(struct client_node *client);
-extern void client_reset_fault(struct client_node *client);
-extern const int const client_is_faulted(const struct client_node *client);
-
-/*!
- * \note
- * For other components which wants to know the state of a client
- */
-extern int client_event_callback_add(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data);
-extern int client_event_callback_del(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data);
-
-extern int client_global_event_handler_del(enum client_global_event event_type, int (*cb)(struct client_node *, void *), void *data);
-extern int client_global_event_handler_add(enum client_global_event event_type, int (*cb)(struct client_node *client, void *data), void *data);
-
-/*!
- * \note
- * Private data set & get
- */
-extern int client_set_data(struct client_node *client, const char *tag, void *data);
-extern void *client_data(struct client_node *client, const char *tag);
-extern void *client_del_data(struct client_node *client, const char *tag);
-
-/*!
- * Handling the client statues
- * Paused or Resumed
- */
-extern void client_paused(struct client_node *client);
-extern void client_resumed(struct client_node *client);
-
-/* Related with Context-Aware service */
-extern int client_subscribe_group(struct client_node *client, const char *cluster, const char *category);
-extern int client_unsubscribe_group(struct client_node *client, const char *cluster, const char *category);
-extern int client_is_subscribed_group(struct client_node *client, const char *cluster, const char *category);
-
-/* Related with category */
-extern int client_subscribe_category(struct client_node *client, const char *category);
-extern int client_unsubscribe_category(struct client_node *client, const char *category);
-extern int client_is_subscribed_by_category(struct client_node *client, const char *category);
-
-extern int client_init(void);
-extern void client_fini(void);
-
-extern int client_browse_group_list(const char *cluster, const char *category, int (*cb)(struct client_node *client, void *data), void *data);
-extern int client_count_of_group_subscriber(const char *cluster, const char *category);
-
-extern int client_browse_category_list(const char *category, int (*cb)(struct client_node *client, void *data), void *data);
-
-extern int client_broadcast(struct inst_info *inst, struct packet *packet);
-
-extern const char *client_direct_addr(const struct client_node *client);
-extern struct client_node *client_find_by_direct_addr(const char *direct_addr);
-extern void client_set_direct_fd(struct client_node *client, int fd);
-extern int client_direct_fd(struct client_node *client);
-
-extern int client_orientation(const struct client_node *client);
-extern void client_set_orientation(struct client_node *client, int orientation);
-
-extern const char *client_appid(const struct client_node *client);
-extern int client_is_sdk_viewer(const struct client_node *client);
-/* End of a file */
diff --git a/include/client_rpc.h b/include/client_rpc.h
deleted file mode 100644 (file)
index 20a8a38..0000000
+++ /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.
- */
-
-/*!
- */
-extern int client_rpc_async_request(struct client_node *client, struct packet *packet);
-extern int client_rpc_handle(struct client_node *client);
-
-/*!
- */
-extern int client_rpc_init(struct client_node *client, int handle);
-extern int client_rpc_fini(struct client_node *client);
-
-/* End of a file */
index a4d0603..bf52189 100644 (file)
  * limitations under the License.
  */
 
-struct conf {
-       int debug_mode;
-       int slave_max_load;
-};
-
-extern struct conf g_conf;
-
 #define DELAY_TIME 0.0000001f
 #define HAPI __attribute__((visibility("hidden")))
 
@@ -32,6 +25,10 @@ extern struct conf g_conf;
 #define VCONFKEY_MASTER_RESTART_COUNT  "memory/private/data-provider-master/restart_count"
 #endif
 
+#define CONF_LOG_PATH "/tmp/.widget.service"
+#define CONF_MAX_LOG_LINE 1000
+#define CONF_MAX_LOG_FILE 3
+
 #define CR 13
 #define LF 10
 
diff --git a/include/dead_monitor.h b/include/dead_monitor.h
deleted file mode 100644 (file)
index 35ce0f1..0000000
+++ /dev/null
@@ -1,22 +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 dead_init(void);
-extern int dead_fini(void);
-extern int dead_callback_add(int handle, void (*dead_cb)(int handle, void *data), void *data);
-extern void *dead_callback_del(int handle, void (*dead_cb)(int handle, void *data), void *data);
-
-/* End of a file */
diff --git a/include/event.h b/include/event.h
deleted file mode 100644 (file)
index 8943ab1..0000000
+++ /dev/null
@@ -1,69 +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 event_data {
-       int x;
-       int y;
-       unsigned int keycode;
-       int device;
-       int slot;
-       struct {
-               int major;
-               int minor;
-       } touch;
-       struct {
-               int major;
-               int minor;
-       } width;
-       int distance;   /* Hovering */
-       int orientation;
-       int pressure;
-       int updated; /* Timestamp is updated */
-       double tv;
-       input_event_source_e source;
-       double ratio_w;
-       double ratio_h;
-};
-
-enum event_state {
-       EVENT_STATE_DEACTIVATED,
-       EVENT_STATE_ACTIVATE,
-       EVENT_STATE_ACTIVATED,
-       EVENT_STATE_DEACTIVATE,
-       EVENT_STATE_ERROR
-};
-
-enum event_handler_activate_type {
-       EVENT_HANDLER_DEACTIVATED = 0x00,
-       EVENT_HANDLER_ACTIVATED_BY_MOUSE_SET = 0x01,
-       EVENT_HANDLER_ACTIVATED_BY_SHOW = 0x02,
-       EVENT_HANDLER_UNKNOWN = 0x04
-};
-
-extern int event_init(void);
-extern int event_fini(void);
-extern int event_input_fd(void);
-extern int event_activate(int device, int x, int y, double ratio_w, double ratio_h, int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data);
-extern int event_deactivate(int device, int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data);
-extern int event_is_activated(void);
-extern int event_reset_cbdata(int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data, void *new_data);
-
-extern int event_deactivate_thread(enum event_handler_activate_type activate_type);
-extern int event_activate_thread(enum event_handler_activate_type activate_type);
-
-extern void event_set_mouse_xy(int device, int x, int y, double ratio_w, double ratio_h, double timestamp);
-
-/* End of a file */
diff --git a/include/fault_manager.h b/include/fault_manager.h
deleted file mode 100644 (file)
index cfc1bec..0000000
+++ /dev/null
@@ -1,25 +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 fault_check_pkgs(struct slave_node *node);
-extern int fault_func_call(struct slave_node *node, const char *pkgname, const char *filename, const char *func);
-extern int fault_func_ret(struct slave_node *node, const char *pkgname, const char *filename, const char *func);
-extern int const fault_is_occured(void);
-extern void fault_unicast_info(struct client_node *client, const char *pkgname, const char *filename, const char *func);
-extern void fault_broadcast_info(const char *pkgname, const char *filename, const char *func);
-extern int fault_info_set(struct slave_node *slave, const char *pkgname, const char *id, const char *func);
-
-/* End of a file */
diff --git a/include/file_service.h b/include/file_service.h
deleted file mode 100644 (file)
index 208f739..0000000
+++ /dev/null
@@ -1,20 +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 file_service_init(void);
-extern int file_service_fini(void);
-
-/* End of a file */
diff --git a/include/group.h b/include/group.h
deleted file mode 100644 (file)
index b321977..0000000
+++ /dev/null
@@ -1,65 +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 cluster;
-struct category;
-struct pkg_info;
-struct context_info;
-struct context_item;
-struct context_option;
-
-extern struct cluster *group_create_cluster(const char *name);
-extern struct cluster *group_find_cluster(const char *name);
-extern int group_destroy_cluster(struct cluster *cluster);
-
-extern struct category *group_create_category(struct cluster *cluster, const char *name);
-extern struct category *group_find_category(struct cluster *cluster, const char *name);
-extern int group_destroy_category(struct category *category);
-
-extern const char * const group_category_name(struct category *category);
-extern const char * const group_cluster_name(struct cluster *cluster);
-extern const char *group_cluster_name_by_category(struct category *category);
-
-extern int group_add_package(struct category *category, const char *pkgname);
-extern int group_del_package(struct category *category, const char *pkgname);
-
-extern int group_add_widget(const char *group, const char *pkgname);
-extern int group_del_widget(const char *pkgname);
-
-extern int group_init(void);
-extern int group_fini(void);
-
-extern struct context_info *group_create_context_info(struct category *category, const char *pkgname);
-extern struct context_item *group_add_context_item(struct context_info *info, const char *ctx_item);
-extern int group_add_option(struct context_item *item, const char *key, const char *value);
-extern int group_destroy_context_info(struct context_info *info);
-
-extern Eina_List * const group_context_info_list(struct category *category);
-extern Eina_List * const group_context_item_list(struct context_info *info);
-extern Eina_List * const group_context_option_list(struct context_item *item);
-extern Eina_List * const group_cluster_list(void);
-extern Eina_List * const group_category_list(struct cluster *cluster);
-extern struct context_info * const group_context_info_from_item(struct context_item *item);
-extern struct category * const group_category_from_context_info(struct context_info *info);
-extern const char * const group_option_item_key(struct context_option *option);
-extern const char * const group_option_item_value(struct context_option *option);
-extern const char * const group_context_item(struct context_item *item);
-extern const char * const group_pkgname_from_context_info(struct context_info *info);
-
-extern void *group_context_item_del_data(struct context_item *item, const char *tag);
-extern void *group_context_item_data(struct context_item *item, const char *tag);
-extern int group_context_item_add_data(struct context_item *item, const char *tag, void *data);
-/* End of a file */
diff --git a/include/instance.h b/include/instance.h
deleted file mode 100644 (file)
index 6c84d34..0000000
+++ /dev/null
@@ -1,281 +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.
- */
-
-/*!
- * \note
- * An instance has three states.
- * ACTIVATED, DEACTIVATED, DESTROYED
- *
- * When the master is launched and someone requires to create this instance,
- * The master just allocate a heap for new instance.
- * We defined this as "DEACTIVATED" state.
- *
- * After master successfully allocate heap for an instance,
- * It will send a load request to a specified slave
- * (The slave will be specified when a package informaion is
- * prepared via configuration file of each widget packages.)
- * We defined this as "REQUEST_TO_ACTIVATE" state.
- *
- * After the slave create a new instance, it will sends back
- * "created" event to the master.
- * Then the master will change the state of the instance to
- * "ACTIVATED".
- *
- * Sometimes, slaves can meet some unexpected problems then
- * it will tries to clear all problems and tries to keep them in safe env.
- * To do this, master or slave can be terminated.
- * In this case, the master has to find the fault module(crashed widget)
- * and prevent it from loading at the slave.
- * And it will send requests for re-creating all other normal widgetes.
- * We defined this as "REQUEST_TO_REACTIVATE".
- *
- * After slave is launched again(recovered from fault situation), it will
- * receives "re-create" event from the master, then it will create all
- * instances of requested widgetes.
- *
- * When the master receives "created" event from the slaves,
- * It will change the instance's state to "ACTIVATED"
- * But now, the master will not send "created" event to the clients.
- *
- * Because the clients don't want to know the re-created widgetes.
- * They just want to know about fault widgetes to display deactivated
- * message.
- *
- * Sometimes the master can send requests to the slave to unload instances.
- * We defined this as "REQUEST_TO_DEACTIVATE".
- *
- * After the slave successfully destroy instances,
- * The master will change the instance's state to "DEACTIVATED"
- * It is same state with the first time when it is created in the master.
- *
- * Sometimes, the instances can be deleted permanently from the master and slave.
- * We called this "destorying an instance".
- * So we defined its states as "DESTROYED".
- * It can make confusing us, the "DESTROYED" means like the instance is already deleted from the
- * heap,. 
- * Yes, it is right. But the instance cannot be deleted directly.
- * Because some callbacks still reference it to complete its job.
- * So the instance needs to keep this DESTROYED state for a while
- * until all callbacks are done for their remained jobs.
- *
- * To unload the instance from the slave,
- * The master should send a request to the slave,
- * And the master should keep the instance until it receives "deleted" event from the slave.
- * We defined this state as "REQUEST_TO_DESTROY".
- * 
- * After master receives "deleted" event from the slave,
- * It will change the state of an master to "DESTROYED"
- *
- * There is one more event to change the state of an instance to "DESTROYED".
- * In case of system created widget, it could be destroyed itself.
- * So the slave will send "deleted" event to the master directly.
- * Even if the master doesn't requests to delete it.
- *
- * In this case, the master will change the state of an instance to
- * "DESTROYED" state. but it will wait to delete it from the heap until
- * reference count of an instance reaches to ZERO.
- */
-
-enum instance_event {
-       INSTANCE_EVENT_DESTROY,
-       INSTNACE_EVENT_UNKNOWN
-};
-
-enum instance_state {
-       INST_INIT = 0x0, /*!< Only keeps in the master */
-
-       /*!
-        */
-       INST_ACTIVATED, /*!< This instance is loaded to the slave */
-       INST_REQUEST_TO_ACTIVATE, /*!< Sent a request to a slave to load this */
-       INST_REQUEST_TO_REACTIVATE, /*!< Sent a request to a slave to load this without "created" event for clients(viewer) */
-
-       /*!
-        */
-       INST_DESTROYED, /*!< Instance is unloaded and also it requires to be deleted from the master */
-       INST_REQUEST_TO_DESTROY /*!< Sent a request to a slave, when the master receives deleted event, the master will delete this */
-};
-
-enum widget_visible_state { /*!< Must be sync'd with widget-viewer */
-       WIDGET_SHOW = 0x00, /*!< widget is showed. Default state */
-       WIDGET_HIDE = 0x01, /*!< widget is hide, with no update event, but keep update timer */
-
-       WIDGET_HIDE_WITH_PAUSE = 0x02, /*!< widget is hide, it needs to be paused (with freezed update timer) */
-
-       WIDGET_VISIBLE_ERROR = 0xFFFFFFFF /* To enlarge the size of this enumeration type */
-};
-
-#define IS_GBAR 1
-#define IS_WIDGET 0
-
-struct inst_info;
-struct pkg_info;
-struct script_handle;
-struct client_node;
-
-extern struct inst_info *instance_create(struct client_node *client, double timestamp, const char *pkgname, const char *content, const char *cluster, const char *category, double period, int width, int height);
-extern int instance_destroy(struct inst_info *inst, widget_destroy_type_e type);
-extern int instance_reload(struct inst_info *inst, widget_destroy_type_e type);
-
-extern struct inst_info * instance_ref(struct inst_info *inst);
-extern struct inst_info * instance_unref(struct inst_info *inst);
-
-extern int instance_state_reset(struct inst_info *inst);
-extern int instance_destroyed(struct inst_info *inst, int reason);
-
-extern int instance_reactivate(struct inst_info *inst);
-extern int instance_activate(struct inst_info *inst);
-
-extern int instance_recover_state(struct inst_info *inst);
-extern int instance_need_slave(struct inst_info *inst);
-
-extern void instance_set_widget_info(struct inst_info *inst, double priority, const char *content, const char *title);
-extern void instance_set_widget_size(struct inst_info *inst, int w, int h);
-extern void instance_set_gbar_size(struct inst_info *inst, int w, int h);
-extern void instance_set_alt_info(struct inst_info *inst, const char *icon, const char *name);
-
-extern int instance_set_pinup(struct inst_info *inst, int pinup);
-extern int instance_resize(struct inst_info *inst, int w, int h);
-extern int instance_hold_scroll(struct inst_info *inst, int seize);
-extern int instance_set_period(struct inst_info *inst, double period);
-extern int instance_clicked(struct inst_info *inst, const char *event, double timestamp, double x, double y);
-extern int instance_text_signal_emit(struct inst_info *inst, const char *signal_name, const char *source, double sx, double sy, double ex, double ey);
-extern int instance_signal_emit(struct inst_info *inst, const char *signal_name, const char *source, double sx, double sy, double ex, double ey, double x, double y, int down);
-extern int instance_change_group(struct inst_info *inst, const char *cluster, const char *category);
-extern int instance_set_visible_state(struct inst_info *inst, enum widget_visible_state state);
-extern enum widget_visible_state instance_visible_state(struct inst_info *inst);
-extern int instance_set_update_mode(struct inst_info *inst, int active_update);
-extern int instance_active_update(struct inst_info *inst);
-
-/*!
- * \note
- * getter
- */
-extern const double const instance_timestamp(const struct inst_info *inst);
-extern struct pkg_info * const instance_package(const struct inst_info *inst);
-extern struct script_info * const instance_widget_script(const struct inst_info *inst);
-extern struct script_info * const instance_gbar_script(const struct inst_info *inst);
-extern struct buffer_info * const instance_gbar_buffer(const struct inst_info *inst);
-extern struct buffer_info * const instance_gbar_extra_buffer(const struct inst_info *inst, int idx);
-extern struct buffer_info * const instance_widget_buffer(const struct inst_info *inst);
-extern struct buffer_info * const instance_widget_extra_buffer(const struct inst_info *inst, int idx);
-extern const char * const instance_id(const struct inst_info *inst);
-extern const char * const instance_content(const struct inst_info *inst);
-extern const char * const instance_category(const struct inst_info *inst);
-extern const char * const instance_cluster(const struct inst_info *inst);
-extern const char * const instance_title(const struct inst_info *inst);
-extern const char * const instance_auto_launch(const struct inst_info *inst);
-extern const int const instance_priority(const struct inst_info *inst);
-extern const struct client_node * const instance_client(const struct inst_info *inst);
-extern const double const instance_period(const struct inst_info *inst);
-extern const int const instance_timeout(const struct inst_info *inst);
-extern const int const instance_widget_width(const struct inst_info *inst);
-extern const int const instance_widget_height(const struct inst_info *inst);
-extern const int const instance_gbar_width(const struct inst_info *inst);
-extern const int const instance_gbar_height(const struct inst_info *inst);
-extern const enum instance_state const instance_state(const struct inst_info *inst);
-
-/*!
- * event
- */
-extern int instance_unicast_created_event(struct inst_info *inst, struct client_node *client);
-extern int instance_unicast_deleted_event(struct inst_info *inst, struct client_node *client, int reason);
-
-extern int instance_create_widget_buffer(struct inst_info *inst, int pixels);
-extern int instance_create_widget_extra_buffer(struct inst_info *inst, int pixels, int idx);
-extern int instance_create_gbar_buffer(struct inst_info *inst, int pixels);
-extern int instance_create_gbar_extra_buffer(struct inst_info *inst, int pixels, int idx);
-
-extern void instance_slave_set_gbar_pos(struct inst_info *inst, double x, double y);
-extern void instance_slave_get_gbar_pos(struct inst_info *inst, double *x, double *y);
-
-extern int instance_slave_open_gbar(struct inst_info *inst, struct client_node *client);
-extern int instance_slave_close_gbar(struct inst_info *inst, struct client_node *client, int reason);
-
-extern int instance_freeze_updator(struct inst_info *inst);
-extern int instance_thaw_updator(struct inst_info *inst);
-
-extern int instance_send_access_event(struct inst_info *inst, int status);
-
-extern int instance_widget_update_begin(struct inst_info *inst, double priority, const char *content, const char *title);
-extern int instance_widget_update_end(struct inst_info *inst);
-
-extern int instance_gbar_update_begin(struct inst_info *inst);
-extern int instance_gbar_update_end(struct inst_info *inst);
-
-extern void instance_gbar_updated(const char *pkgname, const char *id, const char *descfile, int x, int y, int w, int h);
-extern void instance_widget_updated_by_instance(struct inst_info *inst, const char *safe_file, int x, int y, int w, int h);
-extern void instance_gbar_updated_by_instance(struct inst_info *inst, const char *descfile, int x, int y, int w, int h);
-extern void instance_extra_updated_by_instance(struct inst_info *inst, int is_gbar, int idx, int x, int y, int w, int h);
-extern void instance_extra_info_updated_by_instance(struct inst_info *inst);
-
-/*!
- * \note
- * if the status is WIDGET_ERROR_FAULT (slave is faulted)
- * even though the GBAR is not created, this will forcely send the GBAR_DESTROYED event to the client.
- */
-extern int instance_client_gbar_destroyed(struct inst_info *inst, int status);
-extern int instance_client_gbar_created(struct inst_info *inst, int status);
-
-extern int instance_client_gbar_extra_buffer_created(struct inst_info *inst, int idx);
-extern int instance_client_gbar_extra_buffer_destroyed(struct inst_info *inst, int idx);
-
-extern int instance_client_widget_extra_buffer_created(struct inst_info *inst, int idx);
-extern int instance_client_widget_extra_buffer_destroyed(struct inst_info *inst, int idx);
-
-extern int instance_send_access_status(struct inst_info *inst, int status);
-extern int instance_send_key_status(struct inst_info *inst, int status);
-extern int instance_forward_packet(struct inst_info *inst, struct packet *packet);
-
-extern struct client_node *instance_gbar_owner(struct inst_info *inst);
-
-/*!
- * Multiple viewer
- */
-extern int instance_add_client(struct inst_info *inst, struct client_node *client);
-extern int instance_del_client(struct inst_info *inst, struct client_node *client);
-extern int instance_has_client(struct inst_info *inst, struct client_node *client);
-extern void *instance_client_list(struct inst_info *inst);
-
-extern int instance_init(void);
-extern int instance_fini(void);
-
-extern int instance_event_callback_add(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
-extern int instance_event_callback_del(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
-extern int instance_event_callback_is_added(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
-
-/*!
- */
-extern int instance_set_data(struct inst_info *inst, const char *tag, void *data);
-extern void *instance_del_data(struct inst_info *inst, const char *tag);
-extern void *instance_get_data(struct inst_info *inst, const char *tag);
-
-extern void instance_reload_period(struct inst_info *inst, double period);
-
-/**
- * For the hello_sync or prepare_hello_sync command
- */
-extern struct packet *instance_duplicate_packet_create(const struct packet *packet, struct inst_info *inst, int width, int height);
-
-extern void instance_set_orientation(struct inst_info *inst, int orientation);
-extern int instance_orientation(struct inst_info *inst);
-
-extern void instance_watch_set_need_to_recover(struct inst_info *inst, int recover);
-extern int instance_watch_need_to_recover(struct inst_info *inst);
-extern int instance_watch_recover_visible_state(struct inst_info *inst);
-extern int instance_watch_change_package_info(struct inst_info *inst, struct pkg_info *info);
-
-/* End of a file */
diff --git a/include/io.h b/include/io.h
deleted file mode 100644 (file)
index a2e15ba..0000000
+++ /dev/null
@@ -1,25 +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 io_init(void);
-extern int io_fini(void);
-extern int io_load_package_db(struct pkg_info *info);
-extern char *io_widget_pkgname(const char *pkgname);
-extern int io_update_widget_package(const char *pkgname, int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data);
-extern int io_crawling_widgetes(int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data);
-extern int io_is_exists(const char *lbid);
-
-/* End of a file */
diff --git a/include/lite-errno.h b/include/lite-errno.h
deleted file mode 100644 (file)
index c5cb74e..0000000
+++ /dev/null
@@ -1,64 +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 __WIDGET_ERRNO_H
-#define __WIDGET_ERRNO_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup CAPI_WIDGET_SERVICE_MODULE
- * @{
- */
-
-/**
- * @brief
- * Definitions for the result status of widget operation.
- */
-#if 0
-enum widget_status {
-       WIDGET_ERROR_NONE = 0x00000000, /**< Operation is successfully completed */
-       WIDGET_STATUS_ERROR = 0x80000000, /**< This will be OR'd with other specific error value */
-       WIDGET_ERROR_INVALID_PARAMETER = WIDGET_STATUS_ERROR | 0x0001, /**< Invalid request */
-       WIDGET_ERROR_FAULT = WIDGET_STATUS_ERROR | 0x0002, /**< Fault - Unable to recover from the error */
-       WIDGET_ERROR_OUT_OF_MEMORY = WIDGET_STATUS_ERROR | 0x0004, /**< Memory is not enough to do this operation */
-       WIDGET_ERROR_ALREADY_EXIST = WIDGET_STATUS_ERROR | 0x0008, /**< Already exists */
-       WIDGET_ERROR_RESOURCE_BUSY = WIDGET_STATUS_ERROR | 0x0010, /**< Busy so the operation is not started(accepted), try again */
-       WIDGET_ERROR_PERMISSION_DENIED = WIDGET_STATUS_ERROR | 0x0020, /**< Permission error */
-       WIDGET_ERROR_ALREADY = WIDGET_STATUS_ERROR | 0x0040, /**< Operation is already started */
-       WIDGET_ERROR_CANCELED = WIDGET_STATUS_ERROR | 0x0080, /**< Operation is canceled */
-       WIDGET_ERROR_IO_ERROR = WIDGET_STATUS_ERROR | 0x0100, /**< I/O Error */
-       WIDGET_ERROR_NOT_EXIST = WIDGET_STATUS_ERROR | 0x0200, /**< Not exists */
-       WIDGET_ERROR_TIMEOUT = WIDGET_STATUS_ERROR | 0x0400, /**< Timeout */
-       WIDGET_ERROR_NOT_SUPPORTED = WIDGET_STATUS_ERROR | 0x0800, /**< Operation is not implemented */
-       WIDGET_ERROR_NO_SPACE = WIDGET_STATUS_ERROR | 0x1000, /**< No space to operate */
-       WIDGET_ERROR_DISABLED = WIDGET_STATUS_ERROR | 0x2000 /**< Disabled */
-};
-#endif
-
-/*!
- * \}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-/* End of a file */
-
diff --git a/include/main.h b/include/main.h
deleted file mode 100644 (file)
index 67a71d8..0000000
+++ /dev/null
@@ -1,16 +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.
- */
-
diff --git a/include/monitor.h b/include/monitor.h
deleted file mode 100644 (file)
index c08bc2d..0000000
+++ /dev/null
@@ -1,35 +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.
- */
-
-enum monitor_event_type {
-       MONITOR_EVENT_UNKNOWN = 0x0,
-       MONITOR_EVENT_CREATED = CMD_MONITOR_CREATE,
-       MONITOR_EVENT_DESTROYED = CMD_MONITOR_DESTROY,
-       MONITOR_EVENT_PAUSED = CMD_MONITOR_PAUSE,
-       MONITOR_EVENT_RESUMED = CMD_MONITOR_RESUME
-};
-
-struct monitor_client;
-
-extern struct monitor_client *monitor_create_client(const char *widget_id, pid_t pid, int handle);
-extern int monitor_destroy_client(struct monitor_client *monitor);
-
-extern struct monitor_client *monitor_find_client_by_pid(const char *widget_id, pid_t pid);
-extern struct monitor_client *monitor_find_client_by_handle(const char *widget_id, int handle);
-
-extern int monitor_multicast_state_change_event(const char *widget_id, enum monitor_event_type event, const char *instance_id, const char *content_info);
-
-/* End of a file */
diff --git a/include/package.h b/include/package.h
deleted file mode 100644 (file)
index bc92e8e..0000000
+++ /dev/null
@@ -1,128 +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.
- */
-
-enum alter_type {
-       ALTER_CREATE,
-       ALTER_DESTROY
-};
-
-struct pkg_info;
-struct inst_info;
-struct context_info;
-struct slave_node;
-
-/*!
- * \brief
- * Construction & Destruction
- */
-extern struct pkg_info *package_create(const char *pkgid, const char *lbid);
-extern int package_destroy(struct pkg_info *info);
-extern char *package_widget_pkgname(const char *pkgname);
-extern int package_is_widget_pkgname(const char *pkgname);
-extern struct pkg_info *package_find(const char *pkgname);
-extern const char *package_find_by_secured_slave(struct slave_node *slave);
-extern struct inst_info *package_find_instance_by_id(const char *pkgname, const char *id);
-extern struct inst_info *package_find_instance_by_timestamp(const char *pkgname, double timestamp);
-extern int package_dump_fault_info(struct pkg_info *info);
-extern int package_set_fault_info(struct pkg_info *info, double timestamp, const char *filename, const char *function);
-extern int package_get_fault_info(struct pkg_info *info, double *timestmap, const char **filename, const char **function);
-extern int package_set_category(struct pkg_info *info, const char *category);
-
-/*!
- * \brief
- * Readonly functions
- */
-extern const int const package_is_fault(const struct pkg_info *info);
-extern struct slave_node * const package_slave(const struct pkg_info *info);
-extern const int const package_timeout(const struct pkg_info *info);
-extern const double const package_period(const struct pkg_info *info);
-extern const int const package_secured(const struct pkg_info *info);
-extern const char * const package_script(const struct pkg_info *info);
-extern const char * const package_abi(const struct pkg_info *info);
-extern const char * const package_widget_path(const struct pkg_info *info);
-extern const char * const package_widget_group(const struct pkg_info *info);
-extern const char * const package_gbar_path(const struct pkg_info *info);
-extern const char * const package_gbar_group(const struct pkg_info *info);
-extern const int const package_pinup(const struct pkg_info *info);
-extern const char * const package_auto_launch(const struct pkg_info *info);
-extern const unsigned int const package_size_list(const struct pkg_info *info);
-extern const int const package_gbar_width(const struct pkg_info *info);
-extern const int const package_gbar_height(const struct pkg_info *info);
-extern const char * const package_name(const struct pkg_info *info);
-extern const char * const package_libexec(struct pkg_info *info);
-extern const char *package_category(const struct pkg_info *info);
-extern int package_network(struct pkg_info *info);
-extern Eina_List *package_ctx_info(struct pkg_info *pkginfo);
-
-extern int package_set_libexec(struct pkg_info *info, const char *libexec);
-extern void package_set_pinup(struct pkg_info *info, int pinup);
-extern void package_set_auto_launch(struct pkg_info *info, const char *auto_launch);
-extern void package_set_size_list(struct pkg_info *info, unsigned int size_list);
-extern void package_set_widget_type(struct pkg_info *info, enum widget_widget_type type);
-extern void package_set_gbar_type(struct pkg_info *info, enum widget_gbar_type type);
-extern int package_set_widget_group(struct pkg_info *info, const char *group);
-extern int package_set_widget_path(struct pkg_info *info, const char *path);
-extern int package_set_gbar_group(struct pkg_info *info, const char *group);
-extern int package_set_gbar_path(struct pkg_info *info, const char *path);
-extern int package_set_script(struct pkg_info *info, const char *script);
-extern void package_set_secured(struct pkg_info *info, int secured);
-extern void package_set_period(struct pkg_info *info, double period);
-extern void package_set_timeout(struct pkg_info *info, int timeout);
-extern void package_set_network(struct pkg_info *info, int network);
-extern void package_set_gbar_height(struct pkg_info *info, int height);
-extern void package_set_gbar_width(struct pkg_info *info, int width);
-extern int package_set_abi(struct pkg_info *info, const char *abi);
-extern void package_add_ctx_info(struct pkg_info *pkginfo, struct context_info *info);
-extern void package_del_ctx_info(struct pkg_info *pkginfo, struct context_info *info);
-extern void package_set_direct_input(struct pkg_info *info, int direct_input);
-extern int package_direct_input(const struct pkg_info *info);
-extern void package_set_auto_align(struct pkg_info *info, int auto_align);
-extern int package_auto_align(const struct pkg_info *info);
-extern const char *package_hw_acceleration(struct pkg_info *info);
-extern int package_set_hw_acceleration(struct pkg_info *info, const char *hw_acceleration);
-
-/*!
- * \brief
- * Reference counter
- */
-extern struct pkg_info * const package_ref(struct pkg_info *info);
-extern struct pkg_info * const package_unref(struct pkg_info *info);
-extern const int const package_refcnt(const struct pkg_info *info);
-
-extern const enum widget_gbar_type const package_gbar_type(const struct pkg_info *info);
-extern const enum widget_widget_type const package_widget_type(const struct pkg_info *info);
-
-extern int package_add_instance(struct pkg_info *info, struct inst_info *inst);
-extern int package_del_instance(struct pkg_info *info, struct inst_info *inst);
-extern Eina_List *package_instance_list(struct pkg_info *info);
-
-extern int package_clear_fault(struct pkg_info *info);
-extern int package_alter_instances_to_client(struct client_node *client, enum alter_type alter);
-
-extern const Eina_List *package_list(void);
-extern int const package_fault_count(struct pkg_info *info);
-
-extern int package_init(void);
-extern int package_fini(void);
-
-extern int package_is_enabled(const char *appid);
-extern int package_faulted(struct pkg_info *info, int broadcast);
-extern char *package_get_pkgid(const char *appid);
-
-extern int package_instance_count(struct pkg_info *info, int include_deleting);
-extern char *package_meta_tag(const char *appid, const char *meta_tag);
-
-/* End of a file */
diff --git a/include/parser.h b/include/parser.h
deleted file mode 100644 (file)
index 2fce3d8..0000000
+++ /dev/null
@@ -1,45 +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 parser;
-
-extern struct parser *parser_load(const char *filename);
-extern int parser_unload(struct parser *handle);
-extern double parser_period(struct parser *handle);
-extern int parser_network(struct parser *handle);
-extern int parser_timeout(struct parser *handle);
-extern const char *parser_auto_launch(struct parser *handle);
-extern unsigned int parser_size(struct parser *handle);
-extern void parser_get_gbar_size(struct parser *handle, unsigned int *width, unsigned int *height);
-extern const char *parser_group_str(struct parser *handle);
-extern int parser_secured(struct parser *handle);
-extern int parser_pinup(struct parser *handler);
-
-extern const char *parser_widget_path(struct parser *handle);
-extern const char *parser_widget_group(struct parser *handle);
-extern const char *parser_gbar_path(struct parser *handle);
-extern const char *parser_gbar_group(struct parser *handle);
-
-extern const char *parser_abi(struct parser *handle);
-
-extern int parser_text_gbar(struct parser *handle);
-extern int parser_text_widget(struct parser *handle);
-extern int parser_buffer_widget(struct parser *handle);
-extern int parser_buffer_gbar(struct parser *handle);
-
-extern const char *parser_script(struct parser *handle);
-
-/* End of a file */
diff --git a/include/rpc_to_slave.h b/include/rpc_to_slave.h
deleted file mode 100644 (file)
index d80c021..0000000
+++ /dev/null
@@ -1,29 +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 rpc_send_new(struct inst_info *inst, void (*ret_cb)(const char *funcname, GVariant *result, void *data), void *data, int skip_need_to_create);
-extern int rpc_send_renew(struct inst_info *inst, void (*ret_cb)(const char *funcname, GVariant *result, void *data), void *data);
-
-extern void rpc_send_update_request(const char *pkgname, const char *cluster, const char *category);
-/*!
- * \brief
- * \param[in] period if it is negative value, the data provider will use the default period
- */
-extern struct inst_info *rpc_send_create_request(struct client_node *client, const char *pkgname, const char *content, const char *cluster, const char *category, double timestamp, double period);
-extern void rpc_send_resume_request(void);
-extern void rpc_send_pause_request(void);
-
-/* End of a file */
diff --git a/include/script_handler.h b/include/script_handler.h
deleted file mode 100644 (file)
index 933c557..0000000
+++ /dev/null
@@ -1,39 +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 script_info;
-struct fb_info;
-
-extern struct script_info *script_handler_create(struct inst_info *inst, const char *file, const char *group, int w, int h);
-extern int script_handler_destroy(struct script_info *info);
-extern int script_handler_parse_desc(struct inst_info *inst, const char *descfile, int is_pd);
-extern int script_handler_unload(struct script_info *info, int is_pd);
-extern int script_handler_load(struct script_info *info, int is_pd);
-extern int script_handler_is_loaded(struct script_info *info);
-extern int script_handler_feed_event(struct script_info *info, int event, double timestamp);
-
-extern int script_init(void);
-extern int script_fini(void);
-
-extern int script_signal_emit(void *buffer_handle, const char *part, const char *signal, double sx, double sy, double ex, double ey);
-
-extern int script_handler_update_pointer(struct script_info *info, int device, int x, int y, int down);
-extern int script_handler_update_keycode(struct script_info *info, unsigned int keycode);
-extern int script_handler_resize(struct script_info *info, int w, int h);
-extern const char *script_handler_buffer_id(struct script_info *info);
-extern struct buffer_info *script_handler_buffer_info(struct script_info *info);
-
-/* End of a file */
diff --git a/include/server.h b/include/server.h
deleted file mode 100644 (file)
index 457ab15..0000000
+++ /dev/null
@@ -1,20 +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 server_init(void);
-extern int server_fini(void);
-
-/* End of a file */
index 97f597c..f4b22e6 100644 (file)
@@ -13,6 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+#include <packet.h>
+
 enum tcb_type {
        TCB_CLIENT_TYPE_APP     = 0x00,
        TCB_CLIENT_TYPE_SERVICE = 0x01,
@@ -24,6 +27,18 @@ enum tcb_event_type {
        TCB_EVENT_DESTROY = 0x02
 };
 
+enum service_common_error {
+       SERVICE_COMMON_ERROR_NONE = 0,
+       SERVICE_COMMON_ERROR_INVALID_PARAMETER = -1,
+       SERVICE_COMMON_ERROR_ALREADY_STARTED = -2,
+       SERVICE_COMMON_ERROR_FAULT = -3,
+       SERVICE_COMMON_ERROR_PERMISSION_DENIED = -4,
+       SERVICE_COMMON_ERROR_IO_ERROR = -5,
+       SERVICE_COMMON_ERROR_OUT_OF_MEMORY = -6,
+       SERVICE_COMMON_ERROR_NOT_EXIST = -7,
+       SERVICE_COMMON_ERROR_ALREADY_EXIST = -8,
+};
+
 struct tcb;
 struct service_context;
 struct service_event_item;
diff --git a/include/setting.h b/include/setting.h
deleted file mode 100644 (file)
index d2138a5..0000000
+++ /dev/null
@@ -1,31 +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 setting_is_lcd_off(void);
-extern int setting_init(void);
-extern int setting_fini(void);
-
-enum oom_event_type {
-    OOM_TYPE_NORMAL = 0x00,
-    OOM_TYPE_LOW = 0x01,
-    OOM_ERROR = 0xFF
-};
-
-extern int setting_add_oom_event_callback(int (*handler)(enum oom_event_type type, void *data), void *data);
-extern int setting_del_oom_event_callback(int (*handler)(enum oom_event_type type, void *data), void *data);
-extern enum oom_event_type setting_oom_level(void);
-
-/* End of a file */
diff --git a/include/shared_fd_service.h b/include/shared_fd_service.h
deleted file mode 100644 (file)
index 4c2475c..0000000
+++ /dev/null
@@ -1,20 +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 shared_fd_service_init(void);
-extern int shared_fd_service_fini(void);
-
-/* End of a file */
diff --git a/include/slave_life.h b/include/slave_life.h
deleted file mode 100644 (file)
index 1afb032..0000000
+++ /dev/null
@@ -1,234 +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.
- */
-
-/*!
- * Managing the reference counter of a slave
- */
-
-struct slave_node;
-
-enum slave_event {
-       SLAVE_EVENT_ACTIVATE,
-       SLAVE_EVENT_DEACTIVATE, /* deactivate callback, can return REACTIVATE, DEFAULT */
-       SLAVE_EVENT_DELETE, /* Callbacks for this event type, must has not to do something with slave object.
-                              use this only for just notice the state of slave */
-       SLAVE_EVENT_FAULT, /* Critical fault */
-
-       SLAVE_EVENT_PAUSE,
-       SLAVE_EVENT_RESUME,
-
-       SLAVE_NEED_TO_REACTIVATE
-};
-
-enum slave_state {
-       /**
-        * @note
-        * Launch the slave but not yet receives "hello" packet
-        */
-       SLAVE_REQUEST_TO_LAUNCH,
-
-       /**
-        * @note
-        * Terminate the slave but not yet receives dead signal
-        */
-       SLAVE_REQUEST_TO_TERMINATE,
-
-       /**
-        * @note
-        * No slave process exists, just slave object created
-        */
-       SLAVE_TERMINATED,
-
-       /**
-        * @note
-        * State change request is sent,
-        */
-       SLAVE_REQUEST_TO_PAUSE,
-       SLAVE_REQUEST_TO_RESUME,
-
-       /**
-        * @note
-        * Request an action for disconnecting to master from the provider side.
-        * This flag should be treated as an activated state.
-        */
-       SLAVE_REQUEST_TO_DISCONNECT,
-
-       /**
-        * @note
-        * SLAVE_ACTIVATED = { SLAVE_PAUSED, SLAVE_RESUMED }
-        */
-       SLAVE_PAUSED,
-       SLAVE_RESUMED,
-
-       SLAVE_ERROR = 0xFF /* Explicitly define the size of this enum type */
-};
-
-enum PROVIDER_CTRL {
-       PROVIDER_CTRL_DEFAULT = 0x00,                   /*!< Set default control operation */
-       PROVIDER_CTRL_MANUAL_TERMINATION = 0x01,        /*!< Terminate process manually */
-       PROVIDER_CTRL_MANUAL_REACTIVATION = 0x02,       /*!< Reactivate process manually */
-};
-
-extern struct slave_node *slave_ref(struct slave_node *slave);
-extern struct slave_node *slave_unref(struct slave_node *slave);
-extern const int const slave_refcnt(struct slave_node *slave);
-
-/*!
- * \brief
- * Create a new slave object or destroy it
- *
- * \param[in] name
- * \param[in] is_secured
- * \param[in] abi
- * \param[in] pkgname
- * \param[in] period
- * \return slave_node
- */
-extern struct slave_node *slave_create(const char *name, int is_secured, const char *abi, const char *pkgname, int network, const char *hw_acceleration);
-
-/*!
- * \brief
- * \param[in] slave
- * \return void
- */
-extern void slave_destroy(struct slave_node *slave);
-
-/*!
- * \brief
- * Launch or terminate a slave
- * \param[in] slave
- * \return int
- */
-extern int slave_activate(struct slave_node *slave);
-
-/*!
- * To check the slave's activation state
- */
-extern const int const slave_is_activated(struct slave_node *slave);
-extern int slave_activated(struct slave_node *slave);
-
-extern int slave_give_more_ttl(struct slave_node *slave);
-extern int slave_freeze_ttl(struct slave_node *slave);
-extern int slave_thaw_ttl(struct slave_node *slave);
-extern int slave_expired_ttl(struct slave_node *slave);
-
-/*!
- * \NOTE
- * To mangage the unexpected termination of a slave
- * After this function call, the slave object can be deleted
- */
-extern struct slave_node *slave_deactivated_by_fault(struct slave_node *slave) __attribute__((warn_unused_result));
-
-/*!
- * \NOTE
- * After this function, the slave object can be deleted
- */
-extern struct slave_node *slave_deactivated(struct slave_node *slave) __attribute__((warn_unused_result));
-
-extern int slave_event_callback_add(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data);
-extern int slave_event_callback_del(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data);
-
-extern int slave_set_data(struct slave_node *slave, const char *tag, void *data);
-extern void *slave_del_data(struct slave_node *slave, const char *tag);
-extern void *slave_data(struct slave_node *slave, const char *tag);
-
-extern struct slave_node *slave_find_by_pid(pid_t pid);
-extern struct slave_node *slave_find_by_name(const char *name);
-extern struct slave_node *slave_find_by_pkgname(const char *pkgname);
-extern struct slave_node *slave_find_by_rpc_handle(int handle);
-
-extern void slave_dead_handler(struct slave_node *slave);
-extern const int const slave_is_secured(const struct slave_node *slave);
-extern const int const slave_is_app(const struct slave_node *slave);
-extern const char * const slave_name(const struct slave_node *slave);
-extern const pid_t const slave_pid(const struct slave_node *slave);
-extern const char * const slave_abi(const struct slave_node *slave);
-extern int slave_set_pid(struct slave_node *slave, pid_t pid);
-
-/*!
- * \note
- * Used for making decision of destroying a slave or not
- * Used for balancing load of the slave.
- */
-extern void slave_load_package(struct slave_node *slave);
-extern void slave_unload_package(struct slave_node *slave);
-extern int const slave_loaded_package(struct slave_node *slave);
-extern struct slave_node *slave_find_available(const char *slave_pkgname, const char *abi, int secured, int network, const char *hw_acceleration, int auto_align);
-
-extern double const slave_ttl(const struct slave_node *slave);
-
-/*!
- * \note
- * Used for making decision of activating a slave or not
- */
-extern void slave_load_instance(struct slave_node *slave);
-
-/*!
- * \NOTE
- * After this function call, the slave object can be deleted.
- */
-extern struct slave_node *slave_unload_instance(struct slave_node *slave) __attribute__((warn_unused_result));
-
-extern int const slave_loaded_instance(struct slave_node *slave);
-
-extern int slave_resume(struct slave_node *slave);
-extern int slave_pause(struct slave_node *slave);
-
-extern const char *slave_pkgname(const struct slave_node *slave);
-extern const char *slave_state_string(const struct slave_node *slave);
-
-extern enum slave_state slave_state(const struct slave_node *slave);
-extern void slave_set_state(struct slave_node *slave, enum slave_state state);
-
-extern const void *slave_list(void);
-extern int const slave_fault_count(const struct slave_node *slave);
-
-extern int slave_need_to_reactivate_instances(struct slave_node *slave);
-extern void slave_set_reactivate_instances(struct slave_node *slave, int reactivate);
-
-extern void slave_set_reactivation(struct slave_node *slave, int flag);
-extern int slave_need_to_reactivate(struct slave_node *slave);
-
-extern int slave_network(const struct slave_node *slave);
-extern void slave_set_network(struct slave_node *slave, int network);
-
-extern int slave_deactivate_all(int reactivate, int reactivate_instances, int no_timer);
-extern int slave_activate_all(void);
-
-extern void slave_set_control_option(struct slave_node *slave, int ctrl);
-extern int slave_control_option(struct slave_node *slave);
-
-extern char *slave_package_name(const char *abi, const char *lbid);
-
-extern int slave_priority(struct slave_node *slave);
-extern int slave_set_priority(struct slave_node *slave, int priority);
-
-extern int slave_valid(const struct slave_node *slave);
-extern void slave_set_valid(struct slave_node *slave);
-
-extern void slave_set_extra_bundle_data(struct slave_node *slave, const char *extra_bundle_data);
-extern const char *slave_extra_bundle_data(struct slave_node *slave);
-
-extern int slave_is_watch(struct slave_node *slave);
-extern void slave_set_is_watch(struct slave_node *slave, int flag);
-
-extern int slave_set_resource_limit(struct slave_node *slave, unsigned int soft, unsigned int hard);
-extern int slave_get_resource_limit(struct slave_node *slave, unsigned int *soft, unsigned int *hard);
-
-extern void slave_set_wait_deactivation(struct slave_node *slave, int wait);
-extern int slave_wait_deactivation(struct slave_node *slave);
-
-/* End of a file */
diff --git a/include/slave_rpc.h b/include/slave_rpc.h
deleted file mode 100644 (file)
index e166374..0000000
+++ /dev/null
@@ -1,32 +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 slave_rpc_async_request(struct slave_node *slave, const char *pkgname, struct packet *packet, void (*ret_cb)(struct slave_node *slave, const struct packet *packet, void *data), void *data, int urgent);
-extern int slave_rpc_request_only(struct slave_node *slave, const char *pkgname, struct packet *packet, int urgent);
-
-extern int slave_rpc_update_handle(struct slave_node *slave, int handle, int delete_pended_created_packet);
-extern int slave_rpc_ping(struct slave_node *slave);
-extern void slave_rpc_request_update(const char *pkgname, const char *id, const char *cluster, const char *category, const char *content, int force);
-extern int slave_rpc_handle(struct slave_node *slave);
-extern int slave_rpc_ping_freeze(struct slave_node *slave);
-extern int slave_rpc_ping_thaw(struct slave_node *slave);
-
-extern int slave_rpc_disconnect(struct slave_node *slave);
-
-extern int slave_rpc_init(struct slave_node *slave);
-extern int slave_rpc_fini(struct slave_node *slave);
-
-/* End of a file */
index 91ee9fc..4cda6a7 100644 (file)
  * limitations under the License.
  */
 
-extern unsigned long util_string_hash(const char *str);
 extern double util_timestamp(void);
-extern int util_check_ext(const char *filename, const char *check_ptr);
-extern int util_unlink(const char *filename);
-extern int util_unlink_files(const char *folder);
-extern char *util_slavename(void);
-extern unsigned long long util_free_space(const char *path);
-extern void *util_timer_add(double interval, Eina_Bool (*cb)(void *data), void *data);
-extern void util_timer_interval_set(void *timer, double interval);
-extern double util_time_delay_for_compensation(double period);
 extern void util_setup_log_disk(void);
-extern int util_service_is_enabled(const char *tag);
-extern int util_string_is_in_list(const char *str, const char *haystack);
-
-extern int util_screen_size_get(int *width, int *height);
-extern int util_screen_init(void);
-extern int util_screen_fini(void);
+extern const char *util_basename(const char *name);
 
 #define SCHEMA_FILE    "file://"
 #define SCHEMA_PIXMAP  "pixmap://"
diff --git a/include/utility_service.h b/include/utility_service.h
deleted file mode 100644 (file)
index db80cd0..0000000
+++ /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 utility_service_init(void);
-extern int utility_service_fini(void);
-
-/* End of a file */
-
diff --git a/include/widget-mgr.h b/include/widget-mgr.h
deleted file mode 100644 (file)
index 908fe0e..0000000
+++ /dev/null
@@ -1,36 +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 widget_mgr;
-
-extern int widget_mgr_init(void);
-extern void widget_mgr_fini(void);
-extern struct widget_mgr *widget_mgr_create(pid_t pid, int handle);
-extern void widget_mgr_destroy(struct widget_mgr *info);
-
-extern struct widget_mgr *widget_mgr_find_by_pid(pid_t pid);
-extern struct widget_mgr *widget_mgr_find_by_handle(int handle);
-
-extern const char *widget_mgr_filename(struct widget_mgr *info);
-extern pid_t widget_mgr_pid(struct widget_mgr *info);
-extern FILE *widget_mgr_fifo(struct widget_mgr *info);
-extern int widget_mgr_open_fifo(struct widget_mgr *info);
-extern void widget_mgr_close_fifo(struct widget_mgr *info);
-extern void widget_mgr_set_data(struct widget_mgr *info, void *data);
-extern void *widget_mgr_data(struct widget_mgr *info);
-
-extern int widget_mgr_is_valid_requestor(pid_t pid);
-/* End of a file */
diff --git a/include/xmonitor.h b/include/xmonitor.h
deleted file mode 100644 (file)
index 3e01722..0000000
+++ /dev/null
@@ -1,34 +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.
- */
-
-enum xmonitor_event {
-       XMONITOR_PAUSED,
-       XMONITOR_RESUMED,
-
-       XMONITOR_ERROR = 0xFFFFFFFF /* To specify the size of this enum */
-};
-
-extern int xmonitor_init(void);
-extern void xmonitor_fini(void);
-extern int xmonitor_update_state(int pid);
-extern int xmonitor_add_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data);
-extern int xmonitor_del_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data);
-extern int xmonitor_is_paused(void);
-extern void xmonitor_handle_state_changes(void);
-extern int xmonitor_resume(struct client_node *client);
-extern int xmonitor_pause(struct client_node *client);
-
-/* End of a file */
index ff8aa7f..a2789d0 100644 (file)
@@ -1,7 +1,7 @@
 %bcond_with wayland
 
 Name: data-provider-master
-Summary: Master service provider for widgetes
+Summary: Master service provider for badge, shortcut, notification
 Version: 1.3.0
 Release: 1
 Group: Applications/Core Applications
@@ -20,26 +20,12 @@ BuildRequires: pkgconfig(libsmack)
 BuildRequires: pkgconfig(bundle)
 BuildRequires: pkgconfig(capi-appfw-app-manager)
 
-%if %{with wayland}
-BuildRequires: pkgconfig(ecore-wayland)
-%else
-BuildRequires: pkgconfig(ecore-x)
-BuildRequires: pkgconfig(x11)
-BuildRequires: pkgconfig(xfixes)
-BuildRequires: pkgconfig(xext)
-BuildRequires: pkgconfig(libdri2)
-BuildRequires: pkgconfig(xdamage)
-BuildRequires: pkgconfig(dri2proto)
-%endif
-
-BuildRequires: pkgconfig(libtbm)
 BuildRequires: pkgconfig(ecore)
 BuildRequires: pkgconfig(eina)
 BuildRequires: pkgconfig(com-core)
 BuildRequires: pkgconfig(libxml-2.0)
 BuildRequires: pkgconfig(pkgmgr)
 BuildRequires: pkgconfig(pkgmgr-info)
-BuildRequires: pkgconfig(widget_service)
 BuildRequires: pkgconfig(notification)
 BuildRequires: pkgconfig(badge)
 BuildRequires: pkgconfig(badge-service)
@@ -54,8 +40,6 @@ Requires(post): sys-assert
 Requires(post): dbus
 
 %description
-Manage the 2nd stage widget service provider and communicate with the viewer application.
-Keep trace on the life-cycle of the widget and status of the service providers, viewer applications.
 
 %prep
 %setup -q
@@ -76,36 +60,21 @@ export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE"
 export ENGINEER=true
 %endif
 
-%if %{with wayland}
-export WAYLAND_SUPPORT=On
-export X11_SUPPORT=Off
-export LIVEBOX_SHM=wayland
-%else
-export WAYLAND_SUPPORT=Off
-export X11_SUPPORT=On
-export LIVEBOX_SHM=x11
-%endif
-
 %if "%{_repository}" == "wearable"
-export LIVEBOX_SHM="${LIVEBOX_SHM}.wearable"
 export MOBILE=Off
 export WEARABLE=On
 %else
-export LIVEBOX_SHM="${LIVEBOX_SHM}.mobile"
 export MOBILE=On
 export WEARABLE=Off
 %endif
 
-export LIVEBOX_SHM="${LIVEBOX_SHM}.480x800"
-export LIVEBOX=On
-
 %ifarch %ix86
 export TARGET=emulator
 %else
 export TARGET=device
 %endif
 
-%cmake . -DNAME=%{name} -DPRODUCT=${LIVEBOX_SHM} -DENGINEER_BINARY=${ENGINEER} -DWAYLAND_SUPPORT=${WAYLAND_SUPPORT} -DX11_SUPPORT=${X11_SUPPORT} -DMOBILE=${MOBILE} -DWEARABLE=${WEARABLE} -DLIVEBOX=${LIVEBOX} -DTARGET=${TARGET}
+%cmake . -DNAME=%{name} -DENGINEER_BINARY=${ENGINEER} -DMOBILE=${MOBILE} -DWEARABLE=${WEARABLE} -DTARGET=${TARGET}
 
 CFLAGS="${CFLAGS} -Wall -Winline -Werror" LDFLAGS="${LDFLAGS}" make %{?jobs:-j%jobs}
 
@@ -115,27 +84,7 @@ rm -rf %{buildroot}
 mkdir -p %{buildroot}/%{_datarootdir}/license
 mkdir -p %{buildroot}%{_prefix}/lib/systemd/system/multi-user.target.wants
 ln -sf ../%{name}.service %{buildroot}%{_prefix}/lib/systemd/system/multi-user.target.wants/%{name}.service
-mkdir -p %{buildroot}/opt/usr/share/live_magazine
-mkdir -p %{buildroot}/opt/usr/share/live_magazine/log
-mkdir -p %{buildroot}/opt/usr/share/live_magazine/reader
-mkdir -p %{buildroot}/opt/usr/share/live_magazine/always
-mkdir -p %{buildroot}/opt/usr/share/live_magazine/widget.lck
 mkdir -p %{buildroot}/opt/usr/devel/usr/bin
-mkdir -p %{buildroot}/usr/dbspace
-
-echo "widget DB file is not exists, initiate it"
-sqlite3 %{buildroot}/usr/dbspace/.widget.db-new <<EOF
-CREATE TABLE version ( version INTEGER );
-CREATE TABLE box_size ( pkgid TEXT NOT NULL, size_type INTEGER, preview TEXT, touch_effect INTEGER, need_frame INTEGER, mouse_event INTEGER, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
-CREATE TABLE client (pkgid TEXT PRIMARY KEY NOT NULL, icon TEXT, name TEXT, auto_launch TEXT, gbar_size TEXT, content TEXT, nodisplay INTEGER, setup TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
-CREATE TABLE groupinfo ( id INTEGER PRIMARY KEY AUTOINCREMENT, cluster TEXT NOT NULL, category TEXT NOT NULL, pkgid TEXT NOT NULL, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
-CREATE TABLE groupmap (option_id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER, pkgid TEXT NOT NULL, ctx_item TEXT NOT NULL, FOREIGN KEY(id) REFERENCES groupinfo(id), FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
-CREATE TABLE i18n ( pkgid TEXT NOT NULL, lang TEXT COLLATE NOCASE, name TEXT, icon TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
-CREATE TABLE option ( pkgid TEXT NOT NULL, option_id INTEGER, key TEXT NOT NULL, value TEXT NOT NULL, FOREIGN KEY(option_id) REFERENCES groupmap(option_id), FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
-CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER, category TEXT DEFAULT 'http://tizen.org/category/default' );
-CREATE TABLE provider ( pkgid TEXT PRIMARY KEY NOT NULL, network INTEGER, abi TEXT, secured INTEGER, box_type INTEGER, box_src TEXT, box_group TEXT, gbar_type INTEGER, gbar_src TEXT, gbar_group TEXT, libexec TEXT, timeout INTEGER, period TEXT, script TEXT, pinup INTEGER, count INTEGER, direct_input INTEGER DEFAULT 0, hw_acceleration TEXT DEFAULT '', auto_align INTEGER DEFAULT 0, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
-EOF
-
 %pre
 # Executing the stop script for stopping the service of installed provider (old version)
 if [ -x %{_sysconfdir}/rc.d/init.d/%{name} ]; then
@@ -143,53 +92,6 @@ if [ -x %{_sysconfdir}/rc.d/init.d/%{name} ]; then
 fi
 
 %post
-#
-# NOTE:
-# This SYSTEM_UID should be updated properly.
-# In the SPIN, system user id is 1000
-SYSTEM_UID=1000
-APP_UID=380
-APP_GID=0
-
-if [ ! -s /usr/dbspace/.widget.db ]; then
-       echo "DB is not exists"
-       mv /usr/dbspace/.widget.db-new /usr/dbspace/.widget.db
-       mv /usr/dbspace/.widget.db-new-journal /usr/dbspace/.widget.db-journal
-else
-       VERSION=`sqlite3 /usr/dbspace/.widget.db "SELECT * FROM version"`
-       echo "DB is already exists (Version: $VERSION)"
-       echo "==============================================="
-       sqlite3 /usr/dbspace/.widget.db "SELECT * FROM pkgmap"
-       echo "==============================================="
-       rm -rf /usr/dbspace/.widget.db-new
-       rm -rf /usr/dbspace/.widget.db-new-journal
-fi
-
-chown ${APP_UID}:${APP_GID} /opt/usr/share/live_magazine
-# System tool(widget-mgr) should be able to access this folder.
-# So give the "rx" permission to the other group. (750 -> 755)
-chmod 755 /opt/usr/share/live_magazine
-
-chown ${APP_UID}:${APP_GID} /opt/usr/share/live_magazine/log
-chmod 750 /opt/usr/share/live_magazine/log
-
-chown ${APP_UID}:${APP_GID} /opt/usr/share/live_magazine/reader
-chmod 750 /opt/usr/share/live_magazine/reader
-
-chown ${APP_UID}:${APP_GID} /opt/usr/share/live_magazine/always
-chmod 750 /opt/usr/share/live_magazine/always
-
-chown ${APP_UID}:${APP_GID} /opt/usr/share/live_magazine/widget.lck
-chmod 770 /opt/usr/share/live_magazine/widget.lck
-mv /opt/usr/share/live_magazine/widget.lck /opt/usr/share/live_magazine/.widget.lck
-
-chown ${APP_UID}:${APP_GID} %{_prefix}/dbspace/.widget.db
-chmod 644 %{_prefix}/dbspace/.widget.db
-chown ${APP_UID}:${APP_GID} /opt/dbspace/.widget.db-journal
-chmod 644 %{_prefix}/dbspace/.widget.db-journal
-
-echo "Successfully installed. Please start a daemon again manually"
-
 %files -n %{name}
 %manifest %{name}.manifest
 %defattr(-,system,system,-)
@@ -198,22 +100,14 @@ echo "Successfully installed. Please start a daemon again manually"
 %{_prefix}/lib/systemd/system/%{name}.service
 %{_prefix}/lib/systemd/system/%{name}.target
 %{_prefix}/bin/%{name}
-%{_prefix}/lib/systemd/system/%{name}-client.socket
-%{_prefix}/lib/systemd/system/%{name}-provider.socket
 %{_prefix}/lib/systemd/system/%{name}-service.socket
 %{_prefix}/lib/systemd/system/%{name}-badge.socket
 %{_prefix}/lib/systemd/system/%{name}-notification.socket
 %{_prefix}/lib/systemd/system/%{name}-shortcut.socket
-%{_prefix}/lib/systemd/system/%{name}-utility.socket
-%{_prefix}/lib/systemd/system/%{name}-fd.socket
 %{_datarootdir}/license/*
 %if 0%{?tizen_build_binary_release_type_eng}
 /opt/usr/devel/usr/bin/*
 %endif
-%{_datarootdir}/%{name}/*
-/opt/etc/dump.d/module.d/dump_widget.sh
 #%defattr(-,owner,users,-)
-/opt/usr/share/live_magazine/*
-%{_prefix}/dbspace/.widget.db*
 
 # End of a file
diff --git a/res/CMakeLists.txt b/res/CMakeLists.txt
deleted file mode 100644 (file)
index 2ab7c7b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-ADD_SUBDIRECTORY(edje)
diff --git a/res/edje/CMakeLists.txt b/res/edje/CMakeLists.txt
deleted file mode 100644 (file)
index ff341c3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-# End of a file
diff --git a/res/edje/master.edc b/res/edje/master.edc
deleted file mode 100644 (file)
index 38fcf7e..0000000
+++ /dev/null
@@ -1,112 +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.
- */
-
-collections {
-       group {
-               name: "error";
-               parts {
-                       part {
-                               name: "image";
-                               type: SWALLOW;
-                               description {
-                                       state: "default" 0.0;
-                                       rel1 { relative: 0.0 0.0; }
-                                       rel2 { relative: 1.0 1.0; }
-                               }
-                       }
-
-                       part {
-                               name: "bg";
-                               type: RECT;
-                               description {
-                                       state: "default" 0.0;
-                                       rel1 { relative: 0.0 0.0; }
-                                       rel2 { relative: 1.0 1.0; }
-                                       color: 50 50 50 50;
-                               }
-                       }
-
-                       part {
-                               name: "pkgname";
-                               type: TEXT;
-                               description {
-                                       state: "default" 0.0;
-                                       rel1 { relative: 0.25 0.2; to, "bg"; }
-                                       rel2 { relative: 0.75 0.35; to, "bg"; }
-                                       text {
-                                               font: "SLP:style=medium";
-                                               size: 20;
-                                               fit: 1 1;
-                                               text: "pkgname";
-                                               align: 0.5 0.5;
-                                       }
-                               }
-                       }
-                       part {
-                               name: "function";
-                               type: TEXT;
-                               description {
-                                       state: "default" 0.0;
-                                       rel1 { relative: 0.25 0.35; to, "bg"; }
-                                       rel2 { relative: 0.75 0.5; to, "bg"; }
-                                       text {
-                                               font: "SLP:style=medium";
-                                               size: 20;
-                                               fit: 1 1;
-                                               text: "function";
-                                               align: 0.5 0.5;
-                                       }
-                               }
-                       }
-                       part {
-                               name: "slave_pid";
-                               type: TEXT;
-                               description {
-                                       state: "default" 0.0;
-                                       rel1 { relative: 0.25 0.5; to, "bg"; }
-                                       rel2 { relative: 0.75 0.65; to, "bg"; }
-                                       text {
-                                               font: "SLP:style=medium";
-                                               size: 20;
-                                               fit: 1 1;
-                                               text: "slave_pid";
-                                               align: 0.5 0.5;
-                                       }
-                               }
-                       }
-                       part {
-                               name: "filename";
-                               type: TEXT;
-                               description {
-                                       state: "default" 0.0;
-                                       rel1 { relative: 0.0 0.65; to, "bg"; }
-                                       rel2 { relative: 1.0 0.8; to, "bg"; }
-                                       text {
-                                               font: "SLP:style=medium";
-                                               size: 20;
-                                               fit: 1 1;
-                                               text: "filename";
-                                               align: 0.5 0.5;
-                                       }
-                               }
-                       }
-               } // parts
-       }
-} // collections
-
-
-
-// End of a file
index c8f8084..825d264 100644 (file)
 #include <Eina.h>
 
 #include <dlog.h>
-#if defined(HAVE_LIVEBOX)
-#include <widget_errno.h>
-#else
-#include "lite-errno.h"
-#endif
 #include <packet.h>
 
 #include <sys/smack.h>
@@ -514,29 +509,29 @@ HAPI int badge_service_init(void)
 {
        if (s_info.svc_ctx) {
                ErrPrint("Already initialized\n");
-               return WIDGET_ERROR_ALREADY_STARTED;
+               return SERVICE_COMMON_ERROR_ALREADY_STARTED;
        }
 
        s_info.svc_ctx = service_common_create(BADGE_SOCKET, BADGE_SMACK_LABEL, service_thread_main, NULL);
        if (!s_info.svc_ctx) {
                ErrPrint("Unable to activate service thread\n");
-               return WIDGET_ERROR_FAULT;
+               return SERVICE_COMMON_ERROR_FAULT;
        }
 
        DbgPrint("Successfully initiated\n");
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 HAPI int badge_service_fini(void)
 {
        if (!s_info.svc_ctx) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        service_common_destroy(s_info.svc_ctx);
        s_info.svc_ctx = NULL;
        DbgPrint("Successfully finalized\n");
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 /* End of a file */
diff --git a/src/buffer_handler.c b/src/buffer_handler.c
deleted file mode 100644 (file)
index b1065a1..0000000
+++ /dev/null
@@ -1,1713 +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(_FILE_OFFSET_BITS)
-#undef _FILE_OFFSET_BITS
-#endif
-
-#include <stdio.h>
-#include <unistd.h> /* access */
-#include <sys/mman.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/shm.h>
-#include <sys/ipc.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <Ecore.h>
-#include <Ecore_X.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xproto.h>
-#include <X11/extensions/Xdamage.h>
-#include <X11/extensions/Xfixes.h>
-#include <X11/extensions/XShm.h>
-
-#include <dri2.h>
-#include <tbm_bufmgr.h>
-
-#include <dlog.h>
-#include <packet.h>
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_conf.h>
-#include <widget_util.h>
-#include <widget_buffer.h>
-
-#include "debug.h"
-#include "conf.h"
-#include "util.h"
-#include "instance.h"
-#include "package.h"
-#include "client_life.h"
-#include "client_rpc.h"
-#include "buffer_handler.h"
-#include "script_handler.h" // Reverse dependency. must has to be broken
-
-/*!
- * \brief Allocate this in the buffer->data.
- */
-struct gem_data {
-       DRI2Buffer *dri2_buffer;
-       unsigned int attachments[1];
-       tbm_bo pixmap_bo;
-       int count;
-       int buf_count;
-       int w;
-       int h;
-       int depth;
-       Pixmap pixmap;
-       void *data; /* Gem layer */
-       int refcnt;
-       widget_resource_lock_t resource_lock;
-
-       void *compensate_data; /* Check the pitch value, copy this to data */
-};
-
-struct buffer_info
-{
-       void *buffer;
-       char *id;
-       widget_lock_info_t lock_info;
-
-       enum widget_fb_type type;
-
-       int w;
-       int h;
-       int pixel_size;
-       int is_loaded;
-
-       struct inst_info *inst;
-       void *data;
-};
-
-static struct {
-       tbm_bufmgr slp_bufmgr;
-       int fd;
-       Eina_List *pixmap_list;
-} s_info = {
-       .slp_bufmgr = NULL,
-       .fd = -1,
-       .pixmap_list = NULL,
-};
-
-static inline widget_fb_t create_pixmap(struct buffer_info *info)
-{
-       struct gem_data *gem;
-       widget_fb_t buffer;
-       Display *disp;
-       Window parent;
-       XGCValues gcv;
-       GC gc;
-
-       disp = ecore_x_display_get();
-       if (!disp) {
-               return NULL;
-       }
-
-       parent = DefaultRootWindow(disp);
-
-       buffer = calloc(1, sizeof(*buffer) + sizeof(*gem));
-       if (!buffer) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       gem = (struct gem_data *)buffer->data;
-
-       buffer->type = WIDGET_FB_TYPE_PIXMAP;
-       buffer->refcnt = 1;
-       buffer->state = WIDGET_FB_STATE_CREATED;
-
-       gem->attachments[0] = DRI2BufferFrontLeft;
-       gem->count = 1;
-       gem->w = info->w; /*!< This can be changed by DRI2GetBuffers */
-       gem->h = info->h; /*!< This can be changed by DRI2GetBuffers */
-       gem->depth = info->pixel_size;
-       /*!
-        * \NOTE
-        * Use the 24 Bits
-        * 32 Bits is not supported for video playing.
-        * But for the transparent background, use the 32 bits, and give up video.
-        */
-       gem->pixmap = XCreatePixmap(disp, parent, info->w, info->h, (info->pixel_size << 3));
-       if (gem->pixmap == (Pixmap)0) {
-               ErrPrint("Failed to create a pixmap\n");
-               DbgFree(buffer);
-               return NULL;
-       }
-
-       /*!
-        * \note
-        * Clear pixmap
-        */
-       memset(&gcv, 0, sizeof(gcv));
-       gc = XCreateGC(disp, gem->pixmap, GCForeground, &gcv);
-       if (gc) {
-               XFillRectangle(disp, gem->pixmap, gc, 0, 0, info->w, info->h);
-               XSync(disp, False);
-               XFreeGC(disp, gc);
-       } else {
-               XSync(disp, False);
-               ErrPrint("Unable to clear the pixmap\n");
-       }
-
-       if (WIDGET_CONF_ENABLE_RESOURCE_LOCK) {
-               gem->resource_lock = widget_service_create_resource_lock(gem->pixmap, WIDGET_LOCK_WRITE);
-               if (!gem->resource_lock) {
-                       ErrPrint("Failed to create a resource lock: %u\n", gem->pixmap);
-               }
-       }
-
-       return buffer;
-}
-
-static inline int create_gem(widget_fb_t buffer)
-{
-       struct gem_data *gem;
-       Display *disp;
-
-       disp = ecore_x_display_get();
-       if (!disp) {
-               ErrPrint("Failed to get display\n");
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       gem = (struct gem_data *)buffer->data;
-
-       if (s_info.fd < 0) {
-               gem->data = calloc(1, gem->w * gem->h * gem->depth);
-               if (!gem->data) {
-                       ErrPrint("calloc: %d\n", errno);
-                       return WIDGET_ERROR_OUT_OF_MEMORY;
-               }
-
-               ErrPrint("DRI2(gem) is not supported - Fallback to the S/W Backend\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       DRI2CreateDrawable(disp, gem->pixmap);
-
-       gem->dri2_buffer = DRI2GetBuffers(disp, gem->pixmap,
-                       &gem->w, &gem->h, gem->attachments, gem->count, &gem->buf_count);
-       if (!gem->dri2_buffer || !gem->dri2_buffer->name) {
-               ErrPrint("Failed to get a gem buffer\n");
-               DRI2DestroyDrawable(disp, gem->pixmap);
-               return WIDGET_ERROR_FAULT;
-       }
-       /*!
-        * \How can I destroy this?
-        */
-       gem->pixmap_bo = tbm_bo_import(s_info.slp_bufmgr, gem->dri2_buffer->name);
-       if (!gem->pixmap_bo) {
-               ErrPrint("Failed to import BO\n");
-               DRI2DestroyDrawable(disp, gem->pixmap);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (WIDGET_CONF_AUTO_ALIGN && gem->dri2_buffer->pitch != gem->w * gem->depth) {
-               gem->compensate_data = calloc(1, gem->w * gem->h * gem->depth);
-               if (!gem->compensate_data) {
-                       ErrPrint("Failed to allocate heap\n");
-               }
-       }
-
-       DbgPrint("dri2_buffer: %p, name: %p, %dx%d, pitch: %d, buf_count: %d, depth: %d, compensate: %p (%d)\n",
-                       gem->dri2_buffer, gem->dri2_buffer->name, gem->w, gem->h,
-                       gem->dri2_buffer->pitch, gem->buf_count, gem->depth, gem->compensate_data, WIDGET_CONF_AUTO_ALIGN);
-
-       return WIDGET_ERROR_NONE;
-}
-
-static inline void *acquire_gem(widget_fb_t buffer)
-{
-       struct gem_data *gem;
-
-       if (!buffer) {
-               return NULL;
-       }
-
-       gem = (struct gem_data *)buffer->data;
-       if (s_info.fd < 0) {
-               ErrPrint("GEM is not supported - Use the fake gem buffer\n");
-       } else {
-               if (!gem->pixmap_bo) {
-                       ErrPrint("GEM is not created\n");
-                       return NULL;
-               }
-
-               if (!gem->data) {
-                       tbm_bo_handle handle;
-
-                       if (gem->refcnt) {
-                               ErrPrint("Already acquired. but the buffer is not valid\n");
-                               return NULL;
-                       }
-
-                       handle = tbm_bo_map(gem->pixmap_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
-                       gem->data = handle.ptr;
-               }
-       }
-
-       gem->refcnt++;
-
-       /*!
-        * \note
-        * If there is a compensate canvas buffer,
-        * use it
-        */
-       return gem->compensate_data ? gem->compensate_data : gem->data;
-}
-
-static inline void release_gem(widget_fb_t buffer)
-{
-       struct gem_data *gem;
-
-       gem = (struct gem_data *)buffer->data;
-       if (s_info.fd >= 0 && !gem->pixmap_bo) {
-               ErrPrint("GEM is not created\n");
-               return;
-       }
-
-       if (!gem->data) {
-               if (gem->refcnt > 0) {
-                       ErrPrint("Reference count is not valid %d\n", gem->refcnt);
-                       gem->refcnt = 0;
-               }
-               return;
-       }
-
-       gem->refcnt--;
-       if (gem->refcnt == 0) {
-               if (s_info.fd < 0) {
-                       DbgPrint("S/W Gem buffer has no reference\n");
-               } else {
-                       /*!
-                        * \note
-                        * Update the gem buffer using compensate data buffer if it is exists
-                        */
-                       if (gem->compensate_data) {
-                               register int x;
-                               register int y;
-                               int *gem_pixel;
-                               int *pixel;
-                               int gap;
-
-                               pixel = gem->compensate_data;
-                               gem_pixel = gem->data;
-                               gap = gem->dri2_buffer->pitch - (gem->w * gem->depth);
-
-                               for (y = 0; y < gem->h; y++) {
-                                       for (x = 0; x < gem->w; x++) {
-                                               *gem_pixel++ = *pixel++;
-                                       }
-
-                                       gem_pixel = (int *)(((char *)gem_pixel) + gap);
-                               }
-                       }
-
-                       if (gem->pixmap_bo) {
-                               tbm_bo_unmap(gem->pixmap_bo);
-                       }
-
-                       gem->data = NULL;
-               }
-       } else if (gem->refcnt < 0) {
-               ErrPrint("Invalid refcnt: %d (reset)\n", gem->refcnt);
-               gem->refcnt = 0;
-       }
-}
-
-static inline int destroy_pixmap(widget_fb_t buffer)
-{
-       struct gem_data *gem;
-
-       gem = (struct gem_data *)buffer->data;
-
-       if (gem->pixmap) {
-               Display *disp;
-
-               disp = ecore_x_display_get();
-               if (!disp) {
-                       return WIDGET_ERROR_IO_ERROR;
-               }
-
-               DbgPrint("pixmap %lu\n", gem->pixmap);
-               XFreePixmap(disp, gem->pixmap);
-
-               if (WIDGET_CONF_ENABLE_RESOURCE_LOCK) {
-                       if (gem->resource_lock) {
-                               if (widget_service_destroy_resource_lock(gem->resource_lock, 1) != WIDGET_ERROR_NONE) {
-                                       ErrPrint("Failed to destroy resource lock\n");
-                               }
-                               gem->resource_lock = NULL;
-                       }
-               }
-       }
-
-       buffer->state = WIDGET_FB_STATE_DESTROYED;
-       DbgFree(buffer);
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int destroy_gem(widget_fb_t buffer)
-{
-       struct gem_data *gem;
-
-       /*!
-        * Forcely release the acquire_buffer.
-        */
-       gem = (struct gem_data *)buffer->data;
-       if (!gem) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (s_info.fd >= 0) {
-               if (gem->compensate_data) {
-                       DbgPrint("Release compensate buffer %p\n", gem->compensate_data);
-                       DbgFree(gem->compensate_data);
-                       gem->compensate_data = NULL;
-               }
-
-               if (gem->pixmap_bo) {
-                       DbgPrint("unref pixmap bo\n");
-                       tbm_bo_unref(gem->pixmap_bo);
-                       gem->pixmap_bo = NULL;
-
-                       DRI2DestroyDrawable(ecore_x_display_get(), gem->pixmap);
-               }
-       } else if (gem->data) {
-               DbgPrint("Release fake gem buffer\n");
-               DbgFree(gem->data);
-               gem->data = NULL;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int load_file_buffer(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-       double timestamp;
-       int size;
-       char *new_id;
-       int len;
-
-       len = strlen(WIDGET_CONF_IMAGE_PATH) + 40;
-       new_id = malloc(len);
-       if (!new_id) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       timestamp = util_timestamp();
-       snprintf(new_id, len, SCHEMA_FILE "%s%lf", WIDGET_CONF_IMAGE_PATH, timestamp);
-
-       size = sizeof(*buffer) + info->w * info->h * info->pixel_size;
-       if (!size) {
-               ErrPrint("Canvas buffer size is ZERO\n");
-               DbgFree(new_id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       buffer = calloc(1, size);
-       if (!buffer) {
-               ErrPrint("Failed to allocate buffer\n");
-               DbgFree(new_id);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       buffer->type = WIDGET_FB_TYPE_FILE;
-       buffer->refcnt = 0;
-       buffer->state = WIDGET_FB_STATE_CREATED;
-       buffer->info = info;
-
-       DbgFree(info->id);
-       info->id = new_id;
-       info->buffer = buffer;
-       info->is_loaded = 1;
-
-       DbgPrint("FILE type %d created\n", size);
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int load_shm_buffer(struct buffer_info *info)
-{
-       int id;
-       int size;
-       widget_fb_t buffer; /* Just for getting a size */
-       char *new_id;
-       int len;
-
-       size = info->w * info->h * info->pixel_size;
-       if (!size) {
-               ErrPrint("Invalid buffer size\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       id = shmget(IPC_PRIVATE, size + sizeof(*buffer), IPC_CREAT | 0666);
-       if (id < 0) {
-               ErrPrint("shmget: %d\n", errno);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       buffer = shmat(id, NULL, 0);
-       if (buffer == (void *)-1) {
-               ErrPrint("%s shmat: %d\n", info->id, errno);
-
-               if (shmctl(id, IPC_RMID, 0) < 0) {
-                       ErrPrint("%s shmctl: %d\n", info->id, errno);
-               }
-
-               return WIDGET_ERROR_FAULT;
-       }
-
-       buffer->type = WIDGET_FB_TYPE_SHM;
-       buffer->refcnt = id;
-       buffer->state = WIDGET_FB_STATE_CREATED; /*!< Needless */
-       buffer->info = (void *)((long)size); /*!< Use this field to indicates the size of SHM */
-
-       len = strlen(SCHEMA_SHM) + 30; /* strlen("shm://") + 30 */
-
-       new_id = malloc(len);
-       if (!new_id) {
-               ErrPrint("malloc: %d\n", errno);
-               if (shmdt(buffer) < 0) {
-                       ErrPrint("shmdt: %d\n", errno);
-               }
-
-               if (shmctl(id, IPC_RMID, 0) < 0) {
-                       ErrPrint("shmctl: %d\n", errno);
-               }
-
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       snprintf(new_id, len, SCHEMA_SHM "%d", id);
-
-       DbgFree(info->id);
-       info->id = new_id;
-       info->buffer = buffer;
-       info->is_loaded = 1;
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int load_pixmap_buffer(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-       struct gem_data *gem;
-       char *new_id;
-       int len;
-
-       /*!
-        * \NOTE
-        * Before call the buffer_handler_pixmap_ref function,
-        * You should make sure that the is_loaded value is toggled (1)
-        * Or the buffer_handler_pixmap_ref function will return NULL
-        */
-       info->is_loaded = 1;
-
-       if (info->buffer) {
-               DbgPrint("Buffer is already exists, but override it with new one\n");
-       }
-
-       buffer = buffer_handler_pixmap_ref(info);
-       if (!buffer) {
-               DbgPrint("Failed to make a reference of a pixmap\n");
-               info->is_loaded = 0;
-               return WIDGET_ERROR_FAULT;
-       }
-
-       len = strlen(SCHEMA_PIXMAP) + 30; /* strlen("pixmap://") + 30 */
-       new_id = malloc(len);
-       if (!new_id) {
-               ErrPrint("malloc: %d\n", errno);
-               info->is_loaded = 0;
-               buffer_handler_pixmap_unref(buffer);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->id);
-       info->id = new_id;
-
-       gem = (struct gem_data *)buffer->data;
-
-       snprintf(info->id, len, SCHEMA_PIXMAP "%d:%d", (int)gem->pixmap, info->pixel_size);
-       DbgPrint("Loaded pixmap(info->id): %s\n", info->id);
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI int buffer_handler_load(struct buffer_info *info)
-{
-       int ret;
-       widget_target_type_e type = WIDGET_TYPE_GBAR;
-
-       if (!info) {
-               ErrPrint("buffer handler is nil\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (info->is_loaded) {
-               DbgPrint("Buffer is already loaded\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       switch (info->type) {
-       case WIDGET_FB_TYPE_FILE:
-               ret = load_file_buffer(info);
-
-               if (script_handler_buffer_info(instance_gbar_script(info->inst)) != info && instance_gbar_buffer(info->inst) != info) {
-                       type = WIDGET_TYPE_WIDGET;
-               }
-               info->lock_info = widget_service_create_lock(instance_id(info->inst), type, WIDGET_LOCK_WRITE);
-               break;
-       case WIDGET_FB_TYPE_SHM:
-               ret = load_shm_buffer(info);
-
-               if (script_handler_buffer_info(instance_gbar_script(info->inst)) != info && instance_gbar_buffer(info->inst) != info) {
-                       type = WIDGET_TYPE_WIDGET;
-               }
-               info->lock_info = widget_service_create_lock(instance_id(info->inst), type, WIDGET_LOCK_WRITE);
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               ret = load_pixmap_buffer(info);
-               break;
-       default:
-               ErrPrint("Invalid buffer\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               break;
-       }
-
-       return ret;
-}
-
-static inline int unload_file_buffer(struct buffer_info *info)
-{
-       const char *path;
-       char *new_id;
-
-       new_id = strdup(SCHEMA_FILE "/tmp/.live.undefined");
-       if (!new_id) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->buffer);
-       info->buffer = NULL;
-
-       path = widget_util_uri_to_path(info->id);
-       if (path && unlink(path) < 0) {
-               ErrPrint("unlink: %d\n", errno);
-       }
-
-       DbgFree(info->id);
-       info->id = new_id;
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int unload_shm_buffer(struct buffer_info *info)
-{
-       int id;
-       char *new_id;
-
-       new_id = strdup(SCHEMA_SHM "-1");
-       if (!new_id) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       if (sscanf(info->id, SCHEMA_SHM "%d", &id) != 1) {
-               ErrPrint("%s Invalid ID\n", info->id);
-               DbgFree(new_id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (id < 0) {
-               ErrPrint("(%s) Invalid id: %d\n", info->id, id);
-               DbgFree(new_id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (shmdt(info->buffer) < 0) {
-               ErrPrint("shmdt: %d\n", errno);
-       }
-
-       if (shmctl(id, IPC_RMID, 0) < 0) {
-               ErrPrint("shmctl: %d\n", errno);
-       }
-
-       info->buffer = NULL;
-
-       DbgFree(info->id);
-       info->id = new_id;
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int unload_pixmap_buffer(struct buffer_info *info)
-{
-       int id;
-       char *new_id;
-       int pixels;
-
-       new_id = strdup(SCHEMA_PIXMAP "0:0");
-       if (!new_id) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       if (sscanf(info->id, SCHEMA_PIXMAP "%d:%d", &id, &pixels) != 2) {
-               ErrPrint("Invalid ID (%s)\n", info->id);
-               DbgFree(new_id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (id == 0) {
-               ErrPrint("(%s) Invalid id: %d\n", info->id, id);
-               DbgFree(new_id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       /*!
-        * Decrease the reference counter.
-        */
-       buffer_handler_pixmap_unref(info->buffer);
-
-       /*!
-        * \note
-        * Just clear the info->buffer.
-        * It will be reallocated again.
-        */
-       info->buffer = NULL;
-
-       DbgFree(info->id);
-       info->id = new_id;
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI int buffer_handler_unload(struct buffer_info *info)
-{
-       int ret;
-
-       if (!info) {
-               ErrPrint("buffer handler is NIL\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (!info->is_loaded) {
-               ErrPrint("Buffer is not loaded\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (info->type) {
-       case WIDGET_FB_TYPE_FILE:
-               widget_service_destroy_lock(info->lock_info, 1);
-               info->lock_info = NULL;
-               ret = unload_file_buffer(info);
-               break;
-       case WIDGET_FB_TYPE_SHM:
-               widget_service_destroy_lock(info->lock_info, 1);
-               info->lock_info = NULL;
-               ret = unload_shm_buffer(info);
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               ret = unload_pixmap_buffer(info);
-               break;
-       default:
-               ErrPrint("Invalid buffer\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               break;
-       }
-
-       if (ret == 0) {
-               info->is_loaded = 0;
-       }
-
-       return ret;
-}
-
-EAPI const char *buffer_handler_id(const struct buffer_info *info)
-{
-       return info ? info->id : "";
-}
-
-EAPI enum widget_fb_type buffer_handler_type(const struct buffer_info *info)
-{
-       return info ? info->type : WIDGET_FB_TYPE_ERROR;
-}
-
-EAPI void *buffer_handler_fb(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-
-       if (!info) {
-               return NULL;
-       }
-
-       buffer = info->buffer;
-
-       if (info->type == WIDGET_FB_TYPE_PIXMAP) {
-               void *canvas;
-               int ret;
-
-               /*!
-                * \note
-                * For getting the buffer address of gem.
-                */
-               canvas = buffer_handler_pixmap_acquire_buffer(info);
-               ret = buffer_handler_pixmap_release_buffer(canvas);
-               if (ret < 0) {
-                       ErrPrint("Failed to release buffer: %d\n", ret);
-               }
-               return canvas;
-       }
-
-       return buffer->data;
-}
-
-EAPI int buffer_handler_pixmap(const struct buffer_info *info)
-{
-       widget_fb_t buf;
-       struct gem_data *gem;
-
-       if (!info) {
-               ErrPrint("Inavlid buffer handler\n");
-               return 0;
-       }
-
-       if (info->type != WIDGET_FB_TYPE_PIXMAP) {
-               ErrPrint("Invalid buffer type\n");
-               return 0;
-       }
-
-       buf = (widget_fb_t)info->buffer;
-       if (!buf) {
-               ErrPrint("Invalid buffer data\n");
-               return 0;
-       }
-
-       gem = (struct gem_data *)buf->data;
-       return gem->pixmap;
-}
-
-EAPI void *buffer_handler_pixmap_acquire_buffer(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-
-       if (!info || !info->is_loaded) {
-               ErrPrint("Buffer is not loaded\n");
-               return NULL;
-       }
-
-       buffer = buffer_handler_pixmap_ref(info);
-       if (!buffer) {
-               return NULL;
-       }
-
-       return acquire_gem(buffer);
-}
-
-EAPI void *buffer_handler_pixmap_buffer(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-       struct gem_data *gem;
-
-       if (!info) {
-               return NULL;
-       }
-
-       if (!info->is_loaded) {
-               ErrPrint("Buffer is not loaded\n");
-               return NULL;
-       }
-
-       buffer = info->buffer;
-       if (!buffer) {
-               return NULL;
-       }
-
-       gem = (struct gem_data *)buffer->data;
-       return gem->compensate_data ? gem->compensate_data : gem->data;
-}
-
-/**
- * @return "buffer" object (Not the buffer_info)
- */
-EAPI void *buffer_handler_pixmap_ref(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-
-       if (!info->is_loaded) {
-               ErrPrint("Buffer is not loaded\n");
-               return NULL;
-       }
-
-       if (info->type != WIDGET_FB_TYPE_PIXMAP) {
-               ErrPrint("Buffer type is not matched\n");
-               return NULL;
-       }
-
-       buffer = info->buffer;
-       if (!buffer) {
-               int need_gem = 1;
-
-               buffer = create_pixmap(info);
-               if (!buffer) {
-                       ErrPrint("Failed to create a pixmap\n");
-                       return NULL;
-               }
-
-               info->buffer = buffer;
-
-               if (info->inst) {
-                       struct pkg_info *pkg;
-
-                       pkg = instance_package(info->inst);
-
-                       if (instance_widget_buffer(info->inst) == info) {
-                               if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-                                       need_gem = 0;
-                               }
-                       } else if (instance_gbar_buffer(info->inst) == info) {
-                               if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-                                       need_gem = 0;
-                               }
-                       } else {
-                               int idx;
-
-                               for (idx = 0; idx < WIDGET_CONF_EXTRA_BUFFER_COUNT; idx++) {
-                                       if (instance_widget_extra_buffer(info->inst, idx) == info) {
-                                               if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-                                                       need_gem = 0;
-                                                       break;
-                                               }
-                                       }
-
-                                       if (instance_gbar_extra_buffer(info->inst, idx) == info) {
-                                               if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-                                                       need_gem = 0;
-                                                       break;
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               if (need_gem) {
-                       if (create_gem(buffer) < 0) {
-                               /* okay, something goes wrong */
-                       }
-               }
-       } else if (buffer->state != WIDGET_FB_STATE_CREATED || buffer->type != WIDGET_FB_TYPE_PIXMAP) {
-               ErrPrint("Invalid buffer\n");
-               return NULL;
-       } else if (buffer->refcnt > 0) {
-               buffer->refcnt++;
-               return buffer;
-       }
-
-       s_info.pixmap_list = eina_list_append(s_info.pixmap_list, buffer);
-       return buffer;
-}
-
-/*!
- * \return "buffer"
- */
-EAPI void *buffer_handler_pixmap_find(int pixmap)
-{
-       widget_fb_t buffer;
-       struct gem_data *gem;
-       Eina_List *l;
-       Eina_List *n;
-
-       if (pixmap == 0) {
-               return NULL;
-       }
-
-       EINA_LIST_FOREACH_SAFE(s_info.pixmap_list, l, n, buffer) {
-               if (!buffer || buffer->state != WIDGET_FB_STATE_CREATED || buffer->type != WIDGET_FB_TYPE_PIXMAP) {
-                       s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
-                       DbgPrint("Invalid buffer (List Removed: %p)\n", buffer);
-                       continue;
-               }
-
-               gem = (struct gem_data *)buffer->data;
-               if (gem->pixmap == pixmap) {
-                       return buffer;
-               }
-       }
-
-       return NULL;
-}
-
-EAPI int buffer_handler_pixmap_release_buffer(void *canvas)
-{
-       widget_fb_t buffer;
-       struct gem_data *gem;
-       Eina_List *l;
-       Eina_List *n;
-       void *_ptr;
-
-       if (!canvas) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       EINA_LIST_FOREACH_SAFE(s_info.pixmap_list, l, n, buffer) {
-               if (!buffer || buffer->state != WIDGET_FB_STATE_CREATED || buffer->type != WIDGET_FB_TYPE_PIXMAP) {
-                       s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
-                       continue;
-               }
-
-               gem = (struct gem_data *)buffer->data;
-               _ptr = gem->compensate_data ? gem->compensate_data : gem->data;
-
-               if (!_ptr) {
-                       continue;
-               }
-
-               if (_ptr == canvas) {
-                       release_gem(buffer);
-                       buffer_handler_pixmap_unref(buffer);
-                       return WIDGET_ERROR_NONE;
-               }
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-/*!
- * \note
- *
- * \return Return NULL if the buffer is in still uses.
- *        Return buffer_ptr if it needs to destroy
- */
-EAPI int buffer_handler_pixmap_unref(void *buffer_ptr)
-{
-       widget_fb_t buffer = buffer_ptr;
-       struct buffer_info *info;
-
-       buffer->refcnt--;
-       if (buffer->refcnt > 0) {
-               return WIDGET_ERROR_NONE; /* Return NULL means, gem buffer still in use */
-       }
-
-       s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
-
-       info = buffer->info;
-
-       if (destroy_gem(buffer) < 0) {
-               ErrPrint("Failed to destroy gem buffer\n");
-       }
-
-       if (info && info->buffer == buffer) {
-               info->buffer = NULL;
-       }
-
-       if (destroy_pixmap(buffer) < 0) {
-               ErrPrint("Failed to destroy pixmap\n");
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI int buffer_handler_is_loaded(const struct buffer_info *info)
-{
-       return info ? info->is_loaded : 0;
-}
-
-EAPI void buffer_handler_update_size(struct buffer_info *info, int w, int h)
-{
-       if (!info) {
-               return;
-       }
-
-       info->w = w;
-       info->h = h;
-}
-
-EAPI int buffer_handler_resize(struct buffer_info *info, int w, int h)
-{
-       int ret;
-
-       if (!info) {
-               ErrPrint("Invalid handler\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (info->w == w && info->h == h) {
-               DbgPrint("No changes\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       buffer_handler_update_size(info, w, h);
-
-       if (!info->is_loaded) {
-               DbgPrint("Buffer size is updated[%dx%d]\n", w, h);
-               return WIDGET_ERROR_NONE;
-       }
-
-       ret = buffer_handler_unload(info);
-       if (ret < 0) {
-               ErrPrint("Unload: %d\n", ret);
-       }
-
-       ret = buffer_handler_load(info);
-       if (ret < 0) {
-               ErrPrint("Load: %d\n", ret);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
-{
-       if (!info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (w) {
-               *w = info->w;
-       }
-       if (h) {
-               *h = info->h;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI struct inst_info *buffer_handler_instance(struct buffer_info *info)
-{
-       return info->inst;
-}
-
-/*!
- * \note
- * Only for used S/W Backend
- */
-static inline int sync_for_pixmap(widget_fb_t buffer)
-{
-       XShmSegmentInfo si;
-       XImage *xim;
-       GC gc;
-       Display *disp;
-       struct gem_data *gem;
-       Screen *screen;
-       Visual *visual;
-
-       if (buffer->state != WIDGET_FB_STATE_CREATED) {
-               ErrPrint("Invalid state of a FB\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (buffer->type != WIDGET_FB_TYPE_PIXMAP) {
-               ErrPrint("Invalid buffer\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       disp = ecore_x_display_get();
-       if (!disp) {
-               ErrPrint("Failed to get a display\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       gem = (struct gem_data *)buffer->data;
-       if (gem->w == 0 || gem->h == 0) {
-               DbgPrint("Nothing can be sync\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       si.shmid = shmget(IPC_PRIVATE, gem->w * gem->h * gem->depth, IPC_CREAT | 0666);
-       if (si.shmid < 0) {
-               ErrPrint("shmget: %d\n", errno);
-               return WIDGET_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: %d\n", errno);
-               }
-               return WIDGET_ERROR_FAULT;
-       }
-
-       screen = DefaultScreenOfDisplay(disp);
-       visual = DefaultVisualOfScreen(screen);
-       /*!
-        * \NOTE
-        * XCreatePixmap can only uses 24 bits depth only.
-        */
-       xim = XShmCreateImage(disp, visual, (gem->depth << 3), ZPixmap, NULL, &si, gem->w, gem->h);
-       if (xim == NULL) {
-               if (shmdt(si.shmaddr) < 0) {
-                       ErrPrint("shmdt: %d\n", errno);
-               }
-
-               if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
-                       ErrPrint("shmctl: %d\n", errno);
-               }
-               return WIDGET_ERROR_FAULT;
-       }
-
-       xim->data = si.shmaddr;
-       XShmAttach(disp, &si);
-       XSync(disp, False);
-
-       gc = XCreateGC(disp, gem->pixmap, 0, NULL);
-       if (!gc) {
-               XShmDetach(disp, &si);
-               XDestroyImage(xim);
-
-               if (shmdt(si.shmaddr) < 0) {
-                       ErrPrint("shmdt: %d\n", errno);
-               }
-
-               if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
-                       ErrPrint("shmctl: %d\n", errno);
-               }
-
-               return WIDGET_ERROR_FAULT;
-       }
-
-       memcpy(xim->data, gem->data, gem->w * gem->h * gem->depth);
-
-       /*!
-        * \note Do not send the event.
-        *       Instead of X event, master will send the updated event to the viewer
-        */
-       XShmPutImage(disp, gem->pixmap, gc, xim, 0, 0, 0, 0, gem->w, gem->h, False);
-       XSync(disp, False);
-
-       XFreeGC(disp, gc);
-       XShmDetach(disp, &si);
-       XDestroyImage(xim);
-
-       if (shmdt(si.shmaddr) < 0) {
-               ErrPrint("shmdt: %d\n", errno);
-       }
-
-       if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
-               ErrPrint("shmctl: %d\n", errno);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI void buffer_handler_flush(struct buffer_info *info)
-{
-       int fd;
-       int size;
-       widget_fb_t buffer;
-
-       if (!info || !info->buffer) {
-               return;
-       }
-
-       buffer = info->buffer;
-
-       if (buffer->type == WIDGET_FB_TYPE_PIXMAP) {
-               if (s_info.fd > 0) {
-                       //return;
-                       //PERF_INIT();
-                       //PERF_BEGIN();
-                       XRectangle rect;
-                       XserverRegion region;
-
-                       rect.x = 0;
-                       rect.y = 0;
-                       rect.width = info->w;
-                       rect.height = info->h;
-
-                       region = XFixesCreateRegion(ecore_x_display_get(), &rect, 1);
-                       XDamageAdd(ecore_x_display_get(), buffer_handler_pixmap(info), region);
-                       XFixesDestroyRegion(ecore_x_display_get(), region);
-                       XFlush(ecore_x_display_get());
-                       //PERF_MARK("XFlush");
-               } else {
-                       if (sync_for_pixmap(buffer) < 0) {
-                               ErrPrint("Failed to sync via S/W Backend\n");
-                       }
-               }
-       } else if (buffer->type == WIDGET_FB_TYPE_FILE) {
-               const char *path;
-
-               path = widget_util_uri_to_path(info->id);
-               if (!path) {
-                       ErrPrint("Invalid id: [%s]\n", info->id);
-                       return;
-               }
-
-               fd = open(path, O_WRONLY | O_CREAT, 0644);
-               if (fd < 0) {
-                       ErrPrint("%s open: %d\n", widget_util_uri_to_path(info->id), errno);
-                       return;
-               }
-
-               size = info->w * info->h * info->pixel_size;
-               widget_service_acquire_lock(info->lock_info);
-               if (write(fd, info->buffer, size) != size) {
-                       ErrPrint("write: %d\n", errno);
-               }
-               widget_service_release_lock(info->lock_info);
-
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-       } else {
-               DbgPrint("Flush nothing\n");
-       }
-}
-
-HAPI int buffer_handler_init(void)
-{
-       int ret;
-
-       if (WIDGET_CONF_USE_SW_BACKEND) {
-               DbgPrint("Fallback to the S/W Backend\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       ret = widget_util_get_drm_fd(ecore_x_display_get(), &s_info.fd);
-       if (ret != WIDGET_ERROR_NONE || s_info.fd < 0) {
-               ErrPrint("Fallback to the S/W Backend\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       s_info.slp_bufmgr = tbm_bufmgr_init(s_info.fd);
-       if (!s_info.slp_bufmgr) {
-               ErrPrint("Failed to init bufmgr\n");
-               widget_util_release_drm_fd(s_info.fd);
-               s_info.fd = -1;
-               return WIDGET_ERROR_NONE;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int buffer_handler_fini(void)
-{
-       if (s_info.slp_bufmgr) {
-               tbm_bufmgr_deinit(s_info.slp_bufmgr);
-               s_info.slp_bufmgr = NULL;
-       }
-
-       if (s_info.fd >= 0) {
-               widget_util_release_drm_fd(s_info.fd);
-               s_info.fd = -1;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static inline widget_fb_t raw_open_file(const char *filename)
-{
-       widget_fb_t buffer;
-       int fd;
-       off_t off;
-       int ret;
-
-       fd = open(filename, O_RDONLY);
-       if (fd < 0) {
-               ErrPrint("open: %d\n", errno);
-               return NULL;
-       }
-
-       off = lseek(fd, 0L, SEEK_END);
-       if (off == (off_t)-1) {
-               ErrPrint("lseek: %d\n", errno);
-
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-
-               return NULL;
-       }
-
-       if (lseek(fd, 0L, SEEK_SET) == (off_t)-1) {
-               ErrPrint("lseek: %d\n", errno);
-
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-
-               return NULL;
-       }
-
-       buffer = calloc(1, sizeof(*buffer) + off);
-       if (!buffer) {
-               ErrPrint("Heap: %d\n", errno);
-
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-
-               return NULL;
-       }
-
-       buffer->state = WIDGET_FB_STATE_CREATED;
-       buffer->type = WIDGET_FB_TYPE_FILE;
-       buffer->refcnt = 0;
-       buffer->info = ((void *)off);
-
-       ret = read(fd, buffer->data, off);
-       if (ret < 0) {
-               ErrPrint("read: %d\n", errno);
-               DbgFree(buffer);
-
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-
-               return NULL;
-       }
-
-       if (close(fd) < 0) {
-               ErrPrint("close: %d\n", errno);
-       }
-
-       return buffer;
-}
-
-static inline int raw_close_file(widget_fb_t buffer)
-{
-       DbgFree(buffer);
-       return 0;
-}
-
-static inline widget_fb_t raw_open_shm(int shm)
-{
-       widget_fb_t buffer;
-
-       buffer = (widget_fb_t)shmat(shm, NULL, SHM_RDONLY);
-       if (buffer == (widget_fb_t)-1) {
-               ErrPrint("shmat: %d\n", errno);
-               return NULL;
-       }
-
-       return buffer;
-}
-
-static inline int raw_close_shm(widget_fb_t buffer)
-{
-       int ret;
-
-       ret = shmdt(buffer);
-       if (ret < 0) {
-               ErrPrint("shmdt: %d\n", errno);
-       }
-
-       return ret;
-}
-
-static inline widget_fb_t raw_open_pixmap(unsigned int pixmap)
-{
-       widget_fb_t buffer;
-
-       buffer = calloc(1, sizeof(*buffer) + WIDGET_CONF_DEFAULT_PIXELS);
-       if (!buffer) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       buffer->state = WIDGET_FB_STATE_CREATED;
-       buffer->type = WIDGET_FB_TYPE_PIXMAP;
-
-       return buffer;
-}
-
-static inline int raw_close_pixmap(widget_fb_t buffer)
-{
-       DbgFree(buffer);
-       return 0;
-}
-
-EAPI void *buffer_handler_raw_data(widget_fb_t buffer)
-{
-       if (!buffer || buffer->state != WIDGET_FB_STATE_CREATED) {
-               return NULL;
-       }
-
-       return buffer->data;
-}
-
-EAPI int buffer_handler_raw_size(widget_fb_t buffer)
-{
-       if (!buffer || buffer->state != WIDGET_FB_STATE_CREATED) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return (int)((long)buffer->info);
-}
-
-EAPI widget_fb_t buffer_handler_raw_open(enum widget_fb_type widget_fb_type, void *resource)
-{
-       widget_fb_t handle;
-
-       switch (widget_fb_type) {
-       case WIDGET_FB_TYPE_SHM:
-               handle = raw_open_shm((int)((long)resource));
-               break;
-       case WIDGET_FB_TYPE_FILE:
-               handle = raw_open_file(resource);
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               handle = raw_open_pixmap((unsigned int)((long)resource));
-               break;
-       default:
-               handle = NULL;
-               break;
-       }
-
-       return handle;
-}
-
-EAPI int buffer_handler_raw_close(widget_fb_t buffer)
-{
-       int ret;
-
-       if (!buffer || buffer->state != WIDGET_FB_STATE_CREATED) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (buffer->type) {
-       case WIDGET_FB_TYPE_SHM:
-               ret = raw_close_shm(buffer);
-               break;
-       case WIDGET_FB_TYPE_FILE:
-               ret = raw_close_file(buffer);
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               ret = raw_close_pixmap(buffer);
-               break;
-       default:
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               break;
-       }
-
-       return ret;
-}
-
-EAPI int buffer_handler_lock(struct buffer_info *info)
-{
-       if (!info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (info->type == WIDGET_FB_TYPE_PIXMAP) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (info->type == WIDGET_FB_TYPE_FILE) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       return widget_service_acquire_lock(info->lock_info);
-}
-
-EAPI int buffer_handler_unlock(struct buffer_info *info)
-{
-       if (!info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (info->type == WIDGET_FB_TYPE_PIXMAP) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (info->type == WIDGET_FB_TYPE_FILE) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       return widget_service_release_lock(info->lock_info);
-}
-
-EAPI int buffer_handler_pixels(struct buffer_info *info)
-{
-       if (!info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return info->pixel_size;
-}
-
-EAPI int buffer_handler_auto_align(void)
-{
-       return WIDGET_CONF_AUTO_ALIGN;
-}
-
-EAPI int buffer_handler_stride(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-       struct gem_data *gem;
-       int stride;
-
-       if (!info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (info->type) {
-       case WIDGET_FB_TYPE_FILE:
-       case WIDGET_FB_TYPE_SHM:
-               stride = info->w * info->pixel_size;
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               buffer = info->buffer;
-               if (!buffer) {
-                       stride = WIDGET_ERROR_INVALID_PARAMETER;
-                       break;
-               }
-
-               gem = (struct gem_data *)buffer->data;
-               if (!gem) {
-                       stride = WIDGET_ERROR_INVALID_PARAMETER;
-                       break;
-               }
-
-               if (!gem->dri2_buffer) {
-                       /*
-                        * Uhm...
-                        */
-                       ErrPrint("dri2_buffer info is not ready yet!\n");
-                       stride = WIDGET_ERROR_INVALID_PARAMETER;
-                       break;
-               }
-
-               stride = gem->dri2_buffer->pitch;
-               break;
-       default:
-               stride = WIDGET_ERROR_INVALID_PARAMETER;
-               break;
-       }
-
-       return stride;
-}
-
-/*!
- * \note
- * Only can be used by master.
- * Plugin cannot access the user data
- */
-
-HAPI int buffer_handler_set_data(struct buffer_info *info, void *data)
-{
-       if (!info) {
-               ErrPrint("Invalid handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info->data = data;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void *buffer_handler_data(struct buffer_info *info)
-{
-       if (!info) {
-               ErrPrint("Invalid handle\n");
-               return NULL;
-       }
-
-       return info->data;
-}
-
-HAPI int buffer_handler_destroy(struct buffer_info *info)
-{
-       Eina_List *l;
-       widget_fb_t buffer;
-
-       if (!info) {
-               DbgPrint("Buffer is not created yet. info is NIL\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       EINA_LIST_FOREACH(s_info.pixmap_list, l, buffer) {
-               if (buffer->info == info) {
-                       buffer->info = NULL;
-               }
-       }
-
-       buffer_handler_unload(info);
-       DbgFree(info->id);
-       DbgFree(info);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum widget_fb_type type, int w, int h, int pixel_size)
-{
-       struct buffer_info *info;
-
-       info = malloc(sizeof(*info));
-       if (!info) {
-               ErrPrint("malloc: %d\n", errno);
-               return NULL;
-       }
-
-       switch (type) {
-       case WIDGET_FB_TYPE_SHM:
-               if (pixel_size != WIDGET_CONF_DEFAULT_PIXELS) {
-                       DbgPrint("SHM only supportes %d bytes pixels (requested: %d)\n", WIDGET_CONF_DEFAULT_PIXELS, pixel_size);
-                       pixel_size = WIDGET_CONF_DEFAULT_PIXELS;
-               }
-
-               info->id = strdup(SCHEMA_SHM "-1");
-               if (!info->id) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(info);
-                       return NULL;
-               }
-               break;
-       case WIDGET_FB_TYPE_FILE:
-               if (pixel_size != WIDGET_CONF_DEFAULT_PIXELS) {
-                       DbgPrint("FILE only supportes %d bytes pixels (requested: %d)\n", WIDGET_CONF_DEFAULT_PIXELS, pixel_size);
-                       pixel_size = WIDGET_CONF_DEFAULT_PIXELS;
-               }
-
-               info->id = strdup(SCHEMA_FILE "/tmp/.live.undefined");
-               if (!info->id) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(info);
-                       return NULL;
-               }
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               info->id = strdup(SCHEMA_PIXMAP "0:0");
-               if (!info->id) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(info);
-                       return NULL;
-               }
-               break;
-       default:
-               ErrPrint("Invalid type\n");
-               DbgFree(info);
-               return NULL;
-       }
-
-       info->lock_info = NULL;
-       info->w = w;
-       info->h = h;
-       info->pixel_size = pixel_size;
-       info->type = type;
-       info->is_loaded = 0;
-       info->inst = inst;
-       info->buffer = NULL;
-       info->data = NULL;
-
-       return info;
-}
-
-/* End of a file */
diff --git a/src/buffer_handler_wayland.c b/src/buffer_handler_wayland.c
deleted file mode 100644 (file)
index c3eaa73..0000000
+++ /dev/null
@@ -1,1391 +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 <unistd.h> /* access */
-#include <sys/mman.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/shm.h>
-#include <sys/ipc.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <Ecore.h>
-#include <Ecore_Wayland.h> /* wayland_client.h is included by this header */
-
-#include <tbm_bufmgr.h>
-
-#include <dlog.h>
-#include <packet.h>
-#include <widget_errno.h>
-#include <widget_util.h>
-#include <widget_conf.h>
-#include <widget_buffer.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-
-#include "debug.h"
-#include "conf.h"
-#include "util.h"
-#include "instance.h"
-#include "package.h"
-#include "client_life.h"
-#include "client_rpc.h"
-#include "buffer_handler.h"
-#include "script_handler.h" // Reverse dependency. must has to be broken
-
-struct gem_data {
-       tbm_bo pixmap_bo;
-       int count;
-       int buf_count;
-       int w;
-       int h;
-       int depth;
-       void *data; /* Gem layer */
-       int refcnt;
-       int pixmap; /* FD in case of wayland */
-};
-
-struct buffer_info
-{
-       void *buffer;
-       char *id;
-       widget_lock_info_t lock_info;
-
-       enum widget_fb_type type;
-
-       int w;
-       int h;
-       int pixel_size;
-       int is_loaded;
-
-       struct inst_info *inst;
-       void *data;
-};
-
-static struct {
-       tbm_bufmgr slp_bufmgr;
-       int fd;
-       Eina_List *pixmap_list;
-} s_info = {
-       .slp_bufmgr = NULL,
-       .fd = -1,
-       .pixmap_list = NULL,
-};
-
-
-static inline widget_fb_t create_pixmap(struct buffer_info *info)
-{
-       struct gem_data *gem;
-       widget_fb_t buffer;
-
-       buffer = calloc(1, sizeof(*buffer) + sizeof(*gem));
-       if (!buffer) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       gem = (struct gem_data *)buffer->data;
-
-       buffer->type = WIDGET_FB_TYPE_PIXMAP;
-       buffer->refcnt = 1;
-       buffer->state = WIDGET_FB_STATE_CREATED;
-
-       gem->count = 1;
-       gem->w = info->w;
-       gem->h = info->h;
-       gem->depth = WIDGET_CONF_DEFAULT_PIXELS;
-
-       return buffer;
-}
-
-static inline void *acquire_gem(widget_fb_t buffer)
-{
-       struct gem_data *gem;
-
-       if (!buffer) {
-               return NULL;
-       }
-
-       gem = (struct gem_data *)buffer->data;
-       if (s_info.fd < 0) {
-               ErrPrint("GEM is not supported - Use the fake gem buffer\n");
-       } else {
-               if (!gem->pixmap_bo) {
-                       ErrPrint("GEM is not created\n");
-                       return NULL;
-               }
-
-               if (!gem->data) {
-                       tbm_bo_handle handle;
-
-                       if (gem->refcnt) {
-                               ErrPrint("Already acquired. but the buffer is not valid\n");
-                               return NULL;
-                       }
-
-                       handle = tbm_bo_map(gem->pixmap_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
-                       gem->data = handle.ptr;
-               }
-       }
-
-       gem->refcnt++;
-       return gem->data;
-}
-
-static inline void release_gem(widget_fb_t buffer)
-{
-       struct gem_data *gem;
-
-       gem = (struct gem_data *)buffer->data;
-       if (s_info.fd >= 0 && !gem->pixmap_bo) {
-               ErrPrint("GEM is not created\n");
-               return;
-       }
-
-       if (!gem->data) {
-               if (gem->refcnt > 0) {
-                       ErrPrint("Reference count is not valid %d\n", gem->refcnt);
-                       gem->refcnt = 0;
-               }
-               return;
-       }
-
-       gem->refcnt--;
-       if (gem->refcnt == 0) {
-               if (s_info.fd < 0) {
-                       DbgPrint("S/W Gem buffer has no reference\n");
-               } else {
-                       if (gem->pixmap_bo) {
-                               tbm_bo_unmap(gem->pixmap_bo);
-                               gem->pixmap_bo = NULL;
-                       }
-
-                       gem->data = NULL;
-               }
-       } else if (gem->refcnt < 0) {
-               ErrPrint("Invalid refcnt: %d (reset)\n", gem->refcnt);
-               gem->refcnt = 0;
-       }
-}
-
-
-static inline int destroy_pixmap(widget_fb_t buffer)
-{
-       /**
-        * @note
-        * gem data should be destroyed first.
-        */
-       buffer->state = WIDGET_FB_STATE_DESTROYED;
-       DbgFree(buffer);
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int create_gem(widget_fb_t buffer)
-{
-       struct gem_data *gem;
-
-       gem = (struct gem_data *)buffer->data;
-
-       gem->pixmap_bo = tbm_bo_alloc(s_info.slp_bufmgr, gem->w * gem->h * gem->depth, TBM_BO_DEFAULT);
-       if (!gem->pixmap_bo) {
-               ErrPrint("Failed to create Buffer Object\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       gem->pixmap = tbm_bo_export(gem->pixmap_bo);
-       if (gem->pixmap < 0) {
-               ErrPrint("Failed to export FD\n");
-               tbm_bo_unref(gem->pixmap_bo);
-               gem->pixmap_bo = NULL;
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int destroy_gem(widget_fb_t buffer)
-{
-       struct gem_data *gem;
-
-       if (!buffer) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       /*!
-        * Forcely release the acquire_buffer.
-        */
-       gem = (struct gem_data *)buffer->data;
-       if (!gem) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (s_info.fd >= 0) {
-               if (gem->pixmap_bo) {
-                       DbgPrint("unref pixmap bo\n");
-                       tbm_bo_unref(gem->pixmap_bo);
-                       gem->pixmap_bo = NULL;
-                       gem->pixmap = 0;
-               }
-       } else if (gem->data) {
-               DbgPrint("Release fake gem buffer\n");
-               DbgFree(gem->data);
-               gem->data = NULL;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int load_file_buffer(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-       double timestamp;
-       int size;
-       char *new_id;
-       int len;
-
-       len = strlen(WIDGET_CONF_IMAGE_PATH) + 40;
-       new_id = malloc(len);
-       if (!new_id) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       timestamp = util_timestamp();
-       snprintf(new_id, len, SCHEMA_FILE "%s%lf", WIDGET_CONF_IMAGE_PATH, timestamp);
-
-       size = sizeof(*buffer) + info->w * info->h * info->pixel_size;
-       if (!size) {
-               ErrPrint("Canvas buffer size is ZERO\n");
-               DbgFree(new_id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       buffer = calloc(1, size);
-       if (!buffer) {
-               ErrPrint("Failed to allocate buffer\n");
-               DbgFree(new_id);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       buffer->type = WIDGET_FB_TYPE_FILE;
-       buffer->refcnt = 0;
-       buffer->state = WIDGET_FB_STATE_CREATED;
-       buffer->info = info;
-
-       DbgFree(info->id);
-       info->id = new_id;
-       info->buffer = buffer;
-       info->is_loaded = 1;
-
-       DbgPrint("FILE type %d created\n", size);
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int load_shm_buffer(struct buffer_info *info)
-{
-       int id;
-       int size;
-       widget_fb_t buffer; /* Just for getting a size */
-       char *new_id;
-       int len;
-
-       size = info->w * info->h * info->pixel_size;
-       if (!size) {
-               ErrPrint("Invalid buffer size\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       id = shmget(IPC_PRIVATE, size + sizeof(*buffer), IPC_CREAT | 0666);
-       if (id < 0) {
-               ErrPrint("shmget: %d\n", errno);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       buffer = shmat(id, NULL, 0);
-       if (buffer == (void *)-1) {
-               ErrPrint("%s shmat: %d\n", info->id, errno);
-
-               if (shmctl(id, IPC_RMID, 0) < 0) {
-                       ErrPrint("%s shmctl: %d\n", info->id, errno);
-               }
-
-               return WIDGET_ERROR_FAULT;
-       }
-
-       buffer->type = WIDGET_FB_TYPE_SHM;
-       buffer->refcnt = id;
-       buffer->state = WIDGET_FB_STATE_CREATED; /*!< Needless */
-       buffer->info = (void *)((long)size); /*!< Use this field to indicates the size of SHM */
-
-       len = strlen(SCHEMA_SHM) + 30; /* strlen("shm://") + 30 */
-
-       new_id = malloc(len);
-       if (!new_id) {
-               ErrPrint("malloc: %d\n", errno);
-               if (shmdt(buffer) < 0) {
-                       ErrPrint("shmdt: %d\n", errno);
-               }
-
-               if (shmctl(id, IPC_RMID, 0) < 0) {
-                       ErrPrint("shmctl: %d\n", errno);
-               }
-
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       snprintf(new_id, len, SCHEMA_SHM "%d", id);
-
-       DbgFree(info->id);
-       info->id = new_id;
-       info->buffer = buffer;
-       info->is_loaded = 1;
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int load_pixmap_buffer(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-       struct gem_data *gem;
-       char *new_id;
-       int len;
-
-       /*!
-        * \NOTE
-        * Before call the buffer_handler_pixmap_ref function,
-        * You should make sure that the is_loaded value is toggled (1)
-        * Or the buffer_handler_pixmap_ref function will return NULL
-        */
-       info->is_loaded = 1;
-
-       if (info->buffer) {
-               DbgPrint("Buffer is already exists, but override it with new one\n");
-       }
-
-       buffer = buffer_handler_pixmap_ref(info);
-       if (!buffer) {
-               DbgPrint("Failed to make a reference of a pixmap\n");
-               info->is_loaded = 0;
-               return WIDGET_ERROR_FAULT;
-       }
-
-       len = strlen(SCHEMA_PIXMAP) + 30; /* strlen("pixmap://") + 30 */
-       new_id = malloc(len);
-       if (!new_id) {
-               ErrPrint("malloc: %d\n", errno);
-               info->is_loaded = 0;
-               buffer_handler_pixmap_unref(buffer);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->id);
-       info->id = new_id;
-
-       gem = (struct gem_data *)buffer->data;
-
-       snprintf(info->id, len, SCHEMA_PIXMAP "%d:%d", (int)gem->pixmap, info->pixel_size);
-       DbgPrint("Loaded pixmap(info->id): %s\n", info->id);
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI int buffer_handler_load(struct buffer_info *info)
-{
-       int ret;
-       widget_target_type_e type = WIDGET_TYPE_GBAR;
-
-       if (!info) {
-               ErrPrint("buffer handler is nil\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (info->is_loaded) {
-               DbgPrint("Buffer is already loaded\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       switch (info->type) {
-       case WIDGET_FB_TYPE_FILE:
-               ret = load_file_buffer(info);
-               if (script_handler_buffer_info(instance_gbar_script(info->inst)) != info && instance_gbar_buffer(info->inst) != info) {
-                       type = WIDGET_TYPE_WIDGET;
-               }
-               info->lock_info = widget_service_create_lock(instance_id(info->inst), type, WIDGET_LOCK_WRITE);
-               break;
-       case WIDGET_FB_TYPE_SHM:
-               ret = load_shm_buffer(info);
-               if (script_handler_buffer_info(instance_gbar_script(info->inst)) != info && instance_gbar_buffer(info->inst) != info) {
-                       type = WIDGET_TYPE_WIDGET;
-               }
-               info->lock_info = widget_service_create_lock(instance_id(info->inst), type, WIDGET_LOCK_WRITE);
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               ret = load_pixmap_buffer(info);
-               break;
-       default:
-               ErrPrint("Invalid buffer\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               break;
-       }
-
-       return ret;
-}
-
-static inline int unload_file_buffer(struct buffer_info *info)
-{
-       const char *path;
-       char *new_id;
-
-       new_id = strdup(SCHEMA_FILE "/tmp/.live.undefined");
-       if (!new_id) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->buffer);
-       info->buffer = NULL;
-
-       path = widget_util_uri_to_path(info->id);
-       if (path && unlink(path) < 0) {
-               ErrPrint("unlink: %s\n", errno);
-       }
-
-       DbgFree(info->id);
-       info->id = new_id;
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int unload_shm_buffer(struct buffer_info *info)
-{
-       int id;
-       char *new_id;
-
-       new_id = strdup(SCHEMA_SHM "-1");
-       if (!new_id) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       if (sscanf(info->id, SCHEMA_SHM "%d", &id) != 1) {
-               ErrPrint("%s Invalid ID\n", info->id);
-               DbgFree(new_id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (id < 0) {
-               ErrPrint("(%s) Invalid id: %d\n", info->id, id);
-               DbgFree(new_id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (shmdt(info->buffer) < 0) {
-               ErrPrint("shmdt: %d\n", errno);
-       }
-
-       if (shmctl(id, IPC_RMID, 0) < 0) {
-               ErrPrint("shmctl: %d\n", errno);
-       }
-
-       info->buffer = NULL;
-
-       DbgFree(info->id);
-       info->id = new_id;
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int unload_pixmap_buffer(struct buffer_info *info)
-{
-       int id;
-       char *new_id;
-       int pixels;
-
-       new_id = strdup(SCHEMA_PIXMAP "0:0");
-       if (!new_id) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       if (sscanf(info->id, SCHEMA_PIXMAP "%d:%d", &id, &pixels) != 2) {
-               ErrPrint("Invalid ID (%s)\n", info->id);
-               DbgFree(new_id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (id == 0) {
-               ErrPrint("(%s) Invalid id: %d\n", info->id, id);
-               DbgFree(new_id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       /*!
-        * Decrease the reference counter.
-        */
-       buffer_handler_pixmap_unref(info->buffer);
-
-       /*!
-        * \note
-        * Just clear the info->buffer.
-        * It will be reallocated again.
-        */
-       info->buffer = NULL;
-
-       DbgFree(info->id);
-       info->id = new_id;
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI int buffer_handler_unload(struct buffer_info *info)
-{
-       int ret;
-
-       if (!info) {
-               ErrPrint("buffer handler is NIL\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (!info->is_loaded) {
-               ErrPrint("Buffer is not loaded\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (info->type) {
-       case WIDGET_FB_TYPE_FILE:
-               widget_service_destroy_lock(info->lock_info, 1);
-               info->lock_info = NULL;
-               ret = unload_file_buffer(info);
-               break;
-       case WIDGET_FB_TYPE_SHM:
-               widget_service_destroy_lock(info->lock_info, 1);
-               info->lock_info = NULL;
-               ret = unload_shm_buffer(info);
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               ret = unload_pixmap_buffer(info);
-               break;
-       default:
-               ErrPrint("Invalid buffer\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               break;
-       }
-
-       if (ret == 0) {
-               info->is_loaded = 0;
-       }
-
-       return ret;
-}
-
-EAPI const char *buffer_handler_id(const struct buffer_info *info)
-{
-       return info ? info->id : "";
-}
-
-EAPI enum widget_fb_type buffer_handler_type(const struct buffer_info *info)
-{
-       return info ? info->type : WIDGET_FB_TYPE_ERROR;
-}
-
-EAPI void *buffer_handler_fb(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-
-       if (!info) {
-               return NULL;
-       }
-
-       buffer = info->buffer;
-
-       if (info->type == WIDGET_FB_TYPE_PIXMAP) {
-               void *canvas;
-               int ret;
-
-               /*!
-                * \note
-                * For getting the buffer address of gem.
-                */
-               canvas = buffer_handler_pixmap_acquire_buffer(info);
-               ret = buffer_handler_pixmap_release_buffer(canvas);
-               if (ret < 0) {
-                       ErrPrint("Failed to release buffer: %d\n", ret);
-               }
-               return canvas;
-       }
-
-       return buffer->data;
-}
-
-EAPI int buffer_handler_pixmap(const struct buffer_info *info)
-{
-       widget_fb_t buf;
-       struct gem_data *gem;
-
-       if (!info) {
-               ErrPrint("Inavlid buffer handler\n");
-               return 0;
-       }
-
-       if (info->type != WIDGET_FB_TYPE_PIXMAP) {
-               ErrPrint("Invalid buffer type\n");
-               return 0;
-       }
-
-       buf = (widget_fb_t)info->buffer;
-       if (!buf) {
-               ErrPrint("Invalid buffer data\n");
-               return 0;
-       }
-
-       gem = (struct gem_data *)buf->data;
-       return gem->pixmap;
-}
-
-EAPI void *buffer_handler_pixmap_acquire_buffer(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-
-       if (!info || !info->is_loaded) {
-               ErrPrint("Buffer is not loaded\n");
-               return NULL;
-       }
-
-       buffer = buffer_handler_pixmap_ref(info);
-       if (!buffer) {
-               return NULL;
-       }
-
-       return acquire_gem(buffer);
-}
-
-EAPI void *buffer_handler_pixmap_buffer(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-       struct gem_data *gem;
-
-       if (!info) {
-               return NULL;
-       }
-
-       if (!info->is_loaded) {
-               ErrPrint("Buffer is not loaded\n");
-               return NULL;
-       }
-
-       buffer = info->buffer;
-       if (!buffer) {
-               return NULL;
-       }
-
-       gem = (struct gem_data *)buffer->data;
-       return gem->data;
-}
-
-/*!
- * \return "buffer" object (Not the buffer_info)
- */
-EAPI void *buffer_handler_pixmap_ref(struct buffer_info *info)
-{
-       widget_fb_t buffer;
-
-       if (!info->is_loaded) {
-               ErrPrint("Buffer is not loaded\n");
-               return NULL;
-       }
-
-       if (info->type != WIDGET_FB_TYPE_PIXMAP) {
-               ErrPrint("Buffer type is not matched\n");
-               return NULL;
-       }
-
-       buffer = info->buffer;
-       if (!buffer) {
-               int need_gem = 1;
-
-               buffer = create_pixmap(info);
-               if (!buffer) {
-                       ErrPrint("Failed to create a pixmap\n");
-                       return NULL;
-               }
-
-               info->buffer = buffer;
-
-               if (info->inst) {
-                       struct pkg_info *pkg;
-
-                       pkg = instance_package(info->inst);
-
-                       if (instance_widget_buffer(info->inst) == info) {
-                               if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-                                       need_gem = 0;
-                               }
-                       } else if (instance_gbar_buffer(info->inst) == info) {
-                               if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-                                       need_gem = 0;
-                               }
-                       } else {
-                               int idx;
-
-                               for (idx = 0; idx < WIDGET_CONF_EXTRA_BUFFER_COUNT; idx++) {
-                                       if (instance_widget_extra_buffer(info->inst, idx) == info) {
-                                               if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-                                                       need_gem = 0;
-                                                       break;
-                                               }
-                                       }
-
-                                       if (instance_gbar_extra_buffer(info->inst, idx) == info) {
-                                               if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-                                                       need_gem = 0;
-                                                       break;
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               if (need_gem) {
-                       if (create_gem(buffer) < 0) {
-                               /* okay, something goes wrong */
-                       }
-               }
-       } else if (buffer->state != WIDGET_FB_STATE_CREATED || buffer->type != WIDGET_FB_TYPE_PIXMAP) {
-               ErrPrint("Invalid buffer\n");
-               return NULL;
-       } else if (buffer->refcnt > 0) {
-               buffer->refcnt++;
-               return buffer;
-       }
-
-       s_info.pixmap_list = eina_list_append(s_info.pixmap_list, buffer);
-       return buffer;
-}
-
-/*!
- * \return "buffer"
- */
-EAPI void *buffer_handler_pixmap_find(int pixmap)
-{
-       widget_fb_t buffer;
-       struct gem_data *gem;
-       Eina_List *l;
-       Eina_List *n;
-
-       if (pixmap < 0) {
-               return NULL;
-       }
-
-       EINA_LIST_FOREACH_SAFE(s_info.pixmap_list, l, n, buffer) {
-               if (!buffer || buffer->state != WIDGET_FB_STATE_CREATED || buffer->type != WIDGET_FB_TYPE_PIXMAP) {
-                       s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
-                       DbgPrint("Invalid buffer (List Removed: %p)\n", buffer);
-                       continue;
-               }
-
-               gem = (struct gem_data *)buffer->data;
-               if (gem->pixmap == pixmap) {
-                       return buffer;
-               }
-       }
-
-       return NULL;
-}
-
-EAPI int buffer_handler_pixmap_release_buffer(void *canvas)
-{
-       widget_fb_t buffer;
-       struct gem_data *gem;
-       Eina_List *l;
-       Eina_List *n;
-       void *_ptr;
-
-       if (!canvas) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       EINA_LIST_FOREACH_SAFE(s_info.pixmap_list, l, n, buffer) {
-               if (!buffer || buffer->state != WIDGET_FB_STATE_CREATED || buffer->type != WIDGET_FB_TYPE_PIXMAP) {
-                       s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
-                       continue;
-               }
-
-               gem = (struct gem_data *)buffer->data;
-               _ptr = gem->data;
-
-               if (!_ptr) {
-                       continue;
-               }
-
-               if (_ptr == canvas) {
-                       release_gem(buffer);
-                       buffer_handler_pixmap_unref(buffer);
-                       return WIDGET_ERROR_NONE;
-               }
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-/*!
- * \note
- *
- * \return Return NULL if the buffer is in still uses.
- *        Return buffer_ptr if it needs to destroy
- */
-EAPI int buffer_handler_pixmap_unref(void *buffer_ptr)
-{
-       widget_fb_t buffer = buffer_ptr;
-       struct buffer_info *info;
-
-       buffer->refcnt--;
-       if (buffer->refcnt > 0) {
-               return WIDGET_ERROR_NONE; /* Return NULL means, gem buffer still in use */
-       }
-
-       s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
-
-       info = buffer->info;
-
-       if (destroy_gem(buffer) < 0) {
-               ErrPrint("Failed to destroy gem buffer\n");
-       }
-
-       if (info && info->buffer == buffer) {
-               info->buffer = NULL;
-       }
-
-       if (destroy_pixmap(buffer) < 0) {
-               ErrPrint("Failed to destroy pixmap\n");
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI int buffer_handler_is_loaded(const struct buffer_info *info)
-{
-       return info ? info->is_loaded : 0;
-}
-
-EAPI void buffer_handler_update_size(struct buffer_info *info, int w, int h)
-{
-       if (!info) {
-               return;
-       }
-
-       info->w = w;
-       info->h = h;
-}
-
-EAPI int buffer_handler_resize(struct buffer_info *info, int w, int h, int pixel_size)
-{
-       int ret;
-
-       if (!info) {
-               ErrPrint("Invalid handler\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (info->w == w && info->h == h) {
-               if (pixel_size == 0 || info->pixel_size == pixel_size) {
-                       DbgPrint("No changes\n");
-                       return WIDGET_ERROR_NONE;
-               }
-       }
-
-       buffer_handler_update_size(info, w, h);
-
-       if (!info->is_loaded) {
-               DbgPrint("Buffer size is updated[%dx%d]\n", w, h);
-               return WIDGET_ERROR_NONE;
-       }
-
-       ret = buffer_handler_unload(info);
-       if (ret < 0) {
-               ErrPrint("Unload: %d\n", ret);
-       }
-
-       ret = buffer_handler_load(info);
-       if (ret < 0) {
-               ErrPrint("Load: %d\n", ret);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
-{
-       if (!info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (w) {
-               *w = info->w;
-       }
-       if (h) {
-               *h = info->h;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-EAPI struct inst_info *buffer_handler_instance(struct buffer_info *info)
-{
-       return info->inst;
-}
-
-EAPI void buffer_handler_flush(struct buffer_info *info)
-{
-       int fd;
-       int size;
-       widget_fb_t buffer;
-
-       if (!info || !info->buffer) {
-               return;
-       }
-
-       buffer = info->buffer;
-
-       if (buffer->type == WIDGET_FB_TYPE_PIXMAP) {
-               /**
-                * @TODO
-                * WL_XXX
-                * Not supported for wayland or this should be ported correctly
-                */
-       } else if (buffer->type == WIDGET_FB_TYPE_FILE) {
-               fd = open(widget_util_uri_to_path(info->id), O_WRONLY | O_CREAT, 0644);
-               if (fd < 0) {
-                       ErrPrint("%s open falied: %d\n", widget_util_uri_to_path(info->id), errno);
-                       return;
-               }
-
-               size = info->w * info->h * info->pixel_size;
-               widget_service_acquire_lock(info->lock_info);
-               if (write(fd, info->buffer, size) != size) {
-                       ErrPrint("write: %d\n", errno);
-               }
-               widget_service_release_lock(info->lock_info);
-
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-       } else {
-               DbgPrint("Flush nothing\n");
-       }
-}
-
-HAPI int buffer_handler_init(void)
-{
-       int ret;
-
-       if (WIDGET_CONF_USE_SW_BACKEND) {
-               DbgPrint("Fallback to the S/W Backend\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       ret = widget_util_get_drm_fd(ecore_wl_display_get(), &s_info.fd);
-       if (ret != WIDGET_ERROR_NONE || s_info.fd < 0) {
-               ErrPrint("Fallback to the S/W Backend\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       s_info.slp_bufmgr = tbm_bufmgr_init(s_info.fd);
-       if (!s_info.slp_bufmgr) {
-               widget_util_release_drm_fd(s_info.fd);
-               s_info.fd = -1;
-               return WIDGET_ERROR_NONE;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int buffer_handler_fini(void)
-{
-       if (s_info.slp_bufmgr) {
-               tbm_bufmgr_deinit(s_info.slp_bufmgr);
-               s_info.slp_bufmgr = NULL;
-       }
-
-       if (s_info.fd >= 0) {
-               widget_util_release_drm_fd(s_info.fd);
-               s_info.fd = -1;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static inline widget_fb_t raw_open_file(const char *filename)
-{
-       widget_fb_t buffer;
-       int fd;
-       off_t off;
-       int ret;
-
-       fd = open(filename, O_RDONLY);
-       if (fd < 0) {
-               ErrPrint("open: %d\n", errno);
-               return NULL;
-       }
-
-       off = lseek(fd, 0L, SEEK_END);
-       if (off == (off_t)-1) {
-               ErrPrint("lseek: %d\n", errno);
-
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-
-               return NULL;
-       }
-
-       if (lseek(fd, 0L, SEEK_SET) == (off_t)-1) {
-               ErrPrint("lseek: %d\n", errno);
-
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-
-               return NULL;
-       }
-
-       buffer = calloc(1, sizeof(*buffer) + off);
-       if (!buffer) {
-               ErrPrint("calloc: %d\n", errno);
-
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-
-               return NULL;
-       }
-
-       buffer->state = WIDGET_FB_STATE_CREATED;
-       buffer->type = WIDGET_FB_TYPE_FILE;
-       buffer->refcnt = 0;
-       buffer->info = (void *)((long)off);
-
-       ret = read(fd, buffer->data, off);
-       if (ret < 0) {
-               ErrPrint("read: %d\n", errno);
-               DbgFree(buffer);
-
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-
-               return NULL;
-       }
-
-       if (close(fd) < 0) {
-               ErrPrint("close: %d\n", errno);
-       }
-
-       return buffer;
-}
-
-static inline int raw_close_file(widget_fb_t buffer)
-{
-       DbgFree(buffer);
-       return 0;
-}
-
-static inline widget_fb_t raw_open_shm(int shm)
-{
-       widget_fb_t buffer;
-
-       buffer = (widget_fb_t)shmat(shm, NULL, SHM_RDONLY);
-       if (buffer == (widget_fb_t )-1) {
-               ErrPrint("shmat: %d\n", errno);
-               return NULL;
-       }
-
-       return buffer;
-}
-
-static inline int raw_close_shm(widget_fb_t buffer)
-{
-       int ret;
-
-       ret = shmdt(buffer);
-       if (ret < 0) {
-               ErrPrint("shmdt: %d\n", errno);
-       }
-
-       return ret;
-}
-
-static inline widget_fb_t raw_open_pixmap(unsigned int pixmap)
-{
-       widget_fb_t buffer;
-
-       buffer = calloc(1, sizeof(*buffer) + WIDGET_CONF_DEFAULT_PIXELS);
-       if (!buffer) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       buffer->state = WIDGET_FB_STATE_CREATED;
-       buffer->type = WIDGET_FB_TYPE_PIXMAP;
-
-       return buffer;
-}
-
-static inline int raw_close_pixmap(widget_fb_t buffer)
-{
-       DbgFree(buffer);
-       return 0;
-}
-
-EAPI void *buffer_handler_raw_data(widget_fb_t buffer)
-{
-       if (!buffer || buffer->state != WIDGET_FB_STATE_CREATED) {
-               return NULL;
-       }
-
-       return buffer->data;
-}
-
-EAPI int buffer_handler_raw_size(widget_fb_t buffer)
-{
-       if (!buffer || buffer->state != WIDGET_FB_STATE_CREATED) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return (int)((long)buffer->info);
-}
-
-EAPI widget_fb_t buffer_handler_raw_open(enum widget_fb_type widget_fb_type, void *resource)
-{
-       widget_fb_t handle;
-
-       switch (widget_fb_type) {
-       case WIDGET_FB_TYPE_SHM:
-               handle = raw_open_shm((int)((long)resource));
-               break;
-       case WIDGET_FB_TYPE_FILE:
-               handle = raw_open_file(resource);
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               handle = raw_open_pixmap((unsigned int)((long)resource));
-               break;
-       default:
-               handle = NULL;
-               break;
-       }
-
-       return handle;
-}
-
-EAPI int buffer_handler_raw_close(widget_fb_t buffer)
-{
-       int ret;
-
-       if (!buffer || buffer->state != WIDGET_FB_STATE_CREATED) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (buffer->type) {
-       case WIDGET_FB_TYPE_SHM:
-               ret = raw_close_shm(buffer);
-               break;
-       case WIDGET_FB_TYPE_FILE:
-               ret = raw_close_file(buffer);
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               ret = raw_close_pixmap(buffer);
-               break;
-       default:
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               break;
-       }
-
-       return ret;
-}
-
-EAPI int buffer_handler_lock(struct buffer_info *info)
-{
-       if (!info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (info->type == WIDGET_FB_TYPE_PIXMAP) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (info->type == WIDGET_FB_TYPE_FILE) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       return widget_service_acquire_lock(info->lock_info);
-}
-
-EAPI int buffer_handler_unlock(struct buffer_info *info)
-{
-       if (!info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (info->type == WIDGET_FB_TYPE_PIXMAP) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (info->type == WIDGET_FB_TYPE_FILE) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       return widget_service_release_lock(info->lock_info);
-}
-
-EAPI int buffer_handler_auto_align(void)
-{
-       return 1;
-}
-
-EAPI int buffer_handler_stride(struct buffer_info *info)
-{
-       int stride;
-
-       if (!info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (info->type) {
-       case WIDGET_FB_TYPE_FILE:
-       case WIDGET_FB_TYPE_SHM:
-       case WIDGET_FB_TYPE_PIXMAP:
-               stride = info->w * info->pixel_size;
-               break;
-       default:
-               stride = WIDGET_ERROR_INVALID_PARAMETER;
-               break;
-       }
-
-       return stride;
-}
-
-/*!
- * \note
- * Only can be used by master.
- * Plugin cannot access the user data
- */
-
-HAPI int buffer_handler_set_data(struct buffer_info *buffer, void *data)
-{
-       if (!buffer) {
-               ErrPrint("Invalid handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       buffer->data = data;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void *buffer_handler_data(struct buffer_info *buffer)
-{
-       if (!buffer) {
-               ErrPrint("Invalid handle\n");
-               return NULL;
-       }
-
-       return buffer->data;
-}
-
-HAPI int buffer_handler_destroy(struct buffer_info *info)
-{
-       Eina_List *l;
-       widget_fb_t buffer;
-
-       if (!info) {
-               DbgPrint("Buffer is not created yet. info is NIL\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       EINA_LIST_FOREACH(s_info.pixmap_list, l, buffer) {
-               if (buffer->info == info) {
-                       buffer->info = NULL;
-               }
-       }
-
-       buffer_handler_unload(info);
-       DbgFree(info->id);
-       DbgFree(info);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum widget_fb_type type, int w, int h, int pixel_size)
-{
-       struct buffer_info *info;
-
-       info = malloc(sizeof(*info));
-       if (!info) {
-               ErrPrint("malloc: %d\n", errno);
-               return NULL;
-       }
-
-       switch (type) {
-       case WIDGET_FB_TYPE_SHM:
-               if (pixel_size != WIDGET_CONF_DEFAULT_PIXELS) {
-                       DbgPrint("SHM only supportes %d bytes pixels (requested: %d)\n", WIDGET_CONF_DEFAULT_PIXELS, pixel_size);
-                       pixel_size = WIDGET_CONF_DEFAULT_PIXELS;
-               }
-
-               info->id = strdup(SCHEMA_SHM "-1");
-               if (!info->id) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(info);
-                       return NULL;
-               }
-               break;
-       case WIDGET_FB_TYPE_FILE:
-               if (pixel_size != WIDGET_CONF_DEFAULT_PIXELS) {
-                       DbgPrint("FILE only supportes %d bytes pixels (requested: %d)\n", WIDGET_CONF_DEFAULT_PIXELS, pixel_size);
-                       pixel_size = WIDGET_CONF_DEFAULT_PIXELS;
-               }
-
-               info->id = strdup(SCHEMA_FILE "/tmp/.live.undefined");
-               if (!info->id) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(info);
-                       return NULL;
-               }
-               break;
-       case WIDGET_FB_TYPE_PIXMAP:
-               info->id = strdup(SCHEMA_PIXMAP "0:0");
-               if (!info->id) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(info);
-                       return NULL;
-               }
-               break;
-       default:
-               ErrPrint("Invalid type\n");
-               DbgFree(info);
-               return NULL;
-       }
-
-       info->lock_info = NULL;
-       info->w = w;
-       info->h = h;
-       info->pixel_size = pixel_size;
-       info->type = type;
-       info->is_loaded = 0;
-       info->inst = inst;
-       info->buffer = NULL;
-       info->data = NULL;
-
-       return info;
-}
-
-/* End of a file */
diff --git a/src/client_life.c b/src/client_life.c
deleted file mode 100644 (file)
index fb3c99d..0000000
+++ /dev/null
@@ -1,1104 +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 <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/smack.h>
-
-#include <Eina.h>
-#include <Ecore.h>
-
-#include <aul.h>
-#include <dlog.h>
-
-#include <packet.h>
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_conf.h>
-
-#include "client_life.h"
-#include "instance.h"
-#include "client_rpc.h"
-#include "debug.h"
-#include "util.h"
-#include "slave_life.h"
-#include "xmonitor.h"
-#include "conf.h"
-
-int errno;
-
-static struct {
-       Eina_List *client_list;
-       int nr_of_paused_clients;
-
-       enum global_event_process {
-               GLOBAL_EVENT_PROCESS_IDLE = 0x00,
-               GLOBAL_EVENT_PROCESS_CREATE = 0x01,
-               GLOBAL_EVENT_PROCESS_DESTROY = 0x02
-       } in_event_process;
-
-       Eina_List *create_event_list;
-       Eina_List *destroy_event_list;
-
-} s_info = {
-       .client_list = NULL,
-       .nr_of_paused_clients = 0,
-       .in_event_process = GLOBAL_EVENT_PROCESS_IDLE,
-       .create_event_list = NULL,
-       .destroy_event_list = NULL,
-};
-
-struct subscribe_item {        /* Cluster & Sub-cluster. related with Context-aware service */
-       char *cluster;
-       char *category;
-};
-
-struct category_subscribe_item {
-       char *category;
-};
-
-struct global_event_item {
-       void *cbdata;
-       int (*cb)(struct client_node *client, void *data);
-       int deleted;
-};
-
-struct event_item {
-       void *data;
-       int (*cb)(struct client_node *, void *);
-       int deleted;
-};
-
-struct data_item {
-       char *tag;
-       void *data;
-};
-
-struct client_node {
-       char *appid;
-       pid_t pid;
-       int refcnt;
-
-       int paused;
-
-       enum client_event_process {
-               CLIENT_EVENT_PROCESS_IDLE = 0x00,
-               CLIENT_EVENT_PROCESS_DEACTIVATE = 0x01,
-               CLIENT_EVENT_PROCESS_ACTIVATE = 0x02
-       } in_event_process;
-       Eina_List *event_deactivate_list;
-       Eina_List *event_activate_list;
-
-       Eina_List *data_list;
-       Eina_List *subscribe_list;
-       Eina_List *category_subscribe_list;
-
-       int faulted;
-       int orientation;
-       int is_sdk_viewer;
-       struct _direct {
-               char *addr;
-               int fd;
-       } direct;
-};
-
-static inline void invoke_global_destroyed_cb(struct client_node *client)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct global_event_item *item;
-
-       s_info.in_event_process |= GLOBAL_EVENT_PROCESS_DESTROY;
-       EINA_LIST_FOREACH_SAFE(s_info.destroy_event_list, l, n, item) {
-               /*!
-                * The first,
-                * item->deleted will be checked, so if it is deleted, remove item from the list
-                * The second, if the first routine takes false path,
-                * item->cb will be called, if it returns negative value, remove item from the list
-                * The third, if the second routine takes false path,
-                * Check the item->deleted again, so if it is turnned on, remove item from the list
-                */
-               if (item->deleted || item->cb(client, item->cbdata) < 0 || item->deleted) {
-                       s_info.destroy_event_list = eina_list_remove(s_info.destroy_event_list, item);
-                       DbgFree(item);
-               }
-       }
-       s_info.in_event_process &= ~GLOBAL_EVENT_PROCESS_DESTROY;
-}
-
-static inline void invoke_global_created_cb(struct client_node *client)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct global_event_item *item;
-
-       s_info.in_event_process |= GLOBAL_EVENT_PROCESS_CREATE;
-       EINA_LIST_FOREACH_SAFE(s_info.create_event_list, l, n, item) {
-               /*!
-                * The first,
-                * item->deleted will be checked, so if it is deleted, remove item from the list
-                * The second, if the first routine takes false path,
-                * item->cb will be called, if it returns negative value, remove item from the list
-                * The third, if the second routine takes false path,
-                * Check the item->deleted again, so if it is turnned on, remove item from the list
-                */
-
-               if (item->deleted || item->cb(client, item->cbdata) < 0 || item->deleted) {
-                       s_info.create_event_list = eina_list_remove(s_info.create_event_list, item);
-                       DbgFree(item);
-               }
-       }
-       s_info.in_event_process &= ~GLOBAL_EVENT_PROCESS_CREATE;
-}
-
-static inline void invoke_deactivated_cb(struct client_node *client)
-{
-       struct event_item *item;
-       Eina_List *l;
-       Eina_List *n;
-
-       client->in_event_process |= CLIENT_EVENT_PROCESS_DEACTIVATE;
-       EINA_LIST_FOREACH_SAFE(client->event_deactivate_list, l, n, item) {
-               /*!
-                * The first,
-                * item->deleted will be checked, so if it is deleted, remove item from the list
-                * The second, if the first routine takes false path,
-                * item->cb will be called, if it returns negative value, remove item from the list
-                * The third, if the second routine takes false path,
-                * Check the item->deleted again, so if it is turnned on, remove item from the list
-                */
-
-               if (item->deleted || item->cb(client, item->data) < 0 || item->deleted) {
-                       client->event_deactivate_list = eina_list_remove(client->event_deactivate_list, item);
-                       DbgFree(item);
-               }
-       }
-       client->in_event_process &= ~CLIENT_EVENT_PROCESS_DEACTIVATE;
-}
-
-static inline void invoke_activated_cb(struct client_node *client)
-{
-       struct event_item *item;
-       Eina_List *l;
-       Eina_List *n;
-
-       client->in_event_process |= CLIENT_EVENT_PROCESS_ACTIVATE;
-       EINA_LIST_FOREACH_SAFE(client->event_activate_list, l, n, item) {
-               /*!
-                * The first,
-                * item->deleted will be checked, so if it is deleted, remove item from the list
-                * The second, if the first routine takes false path,
-                * item->cb will be called, if it returns negative value, remove item from the list
-                * The third, if the second routine takes false path,
-                * Check the item->deleted again, so if it is turnned on, remove item from the list
-                */
-
-               if (item->deleted || item->cb(client, item->data) < 0 || item->deleted) {
-                       client->event_activate_list = eina_list_remove(client->event_activate_list, item);
-                       DbgFree(item);
-               }
-       }
-       client->in_event_process &= ~CLIENT_EVENT_PROCESS_ACTIVATE;
-}
-
-static inline void destroy_client_data(struct client_node *client)
-{
-       struct event_item *event;
-       struct data_item *data;
-       struct subscribe_item *item;
-       struct category_subscribe_item *category_item;
-       Ecore_Timer *timer;
-
-       timer = client_del_data(client, "create,timer");
-       if (timer) {
-               ecore_timer_del(timer);
-       }
-
-       DbgPrint("Destroy client: %p\n", client);
-
-       invoke_global_destroyed_cb(client);
-       client_rpc_fini(client); /*!< Finalize the RPC after invoke destroy callbacks */
-
-       EINA_LIST_FREE(client->data_list, data) {
-               DbgPrint("Tag is not cleared (%s)\n", data->tag);
-               DbgFree(data->tag);
-               DbgFree(data);
-       }
-
-       EINA_LIST_FREE(client->event_deactivate_list, event) {
-               DbgFree(event);
-       }
-
-       EINA_LIST_FREE(client->subscribe_list, item) {
-               DbgFree(item->cluster);
-               DbgFree(item->category);
-               DbgFree(item);
-       }
-
-       EINA_LIST_FREE(client->category_subscribe_list, category_item) {
-               DbgFree(category_item->category);
-               DbgFree(category_item);
-       }
-
-       if (client->paused) {
-               s_info.nr_of_paused_clients--;
-       }
-
-       if (client->direct.addr) {
-               (void)unlink(client->direct.addr);
-               DbgFree(client->direct.addr);
-       }
-
-       if (client->direct.fd >= 0) {
-               if (close(client->direct.fd) < 0) {
-                       ErrPrint("Client FD: %d\n", errno);
-               }
-       }
-
-       DbgFree(client->appid);
-
-       s_info.client_list = eina_list_remove(s_info.client_list, client);
-       DbgFree(client);
-
-       /*!
-        * \note
-        * If there is any changes of clients,
-        * We should check the pause/resume states again.
-        */
-       xmonitor_handle_state_changes();
-}
-
-static struct client_node *create_client_data(pid_t pid, const char *direct_addr)
-{
-       struct client_node *client;
-       char pid_pkgname[256];
-
-       client = calloc(1, sizeof(*client));
-       if (!client) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       client->pid = pid;
-       client->refcnt = 1;
-       client->direct.fd = -1;
-
-       if (aul_app_get_pkgname_bypid(pid, pid_pkgname, sizeof(pid_pkgname)) == AUL_R_OK) {
-               client->appid = strdup(pid_pkgname);
-               if (client->appid) {
-                       if (WIDGET_CONF_SDK_VIEWER) {
-                               client->is_sdk_viewer = !strcmp(client->appid, WIDGET_CONF_SDK_VIEWER);
-                       }
-               } else {
-                       ErrPrint("strdup: %d\n", errno);
-               }
-       }
-
-       if (direct_addr && direct_addr[0]) {
-               client->direct.addr = strdup(direct_addr);
-               if (!client->direct.addr) {
-                       ErrPrint("Failed to allocate direct_addr (%s)\n", direct_addr);
-               }
-       }
-
-       s_info.client_list = eina_list_append(s_info.client_list, client);
-
-       /*!
-        * \note
-        * Right after create a client ADT,
-        * We assume that the client is paused.
-        */
-       client_paused(client);
-       xmonitor_handle_state_changes();
-       return client;
-}
-
-static Eina_Bool created_cb(void *data)
-{
-       (void)client_del_data(data, "create,timer");
-
-       invoke_global_created_cb(data);
-       invoke_activated_cb(data);
-       /*!
-        * \note
-        * Client PAUSE/RESUME event must has to be sent after created event.
-        */
-       xmonitor_update_state(client_pid(data));
-
-       (void)client_unref(data);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-/*!
- * \note
- * Noramlly, client ADT is created when it send the "acquire" packet.
- * It means we have the handle for communicating with the client already,
- * So we just create its ADT in this function.
- * And invoke the global created event & activated event callbacks
- */
-HAPI struct client_node *client_create(pid_t pid, int handle, const char *direct_addr)
-{
-       struct client_node *client;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (client) {
-               ErrPrint("Client %d(%d) is already exists\n", pid, handle);
-               return client;
-       }
-
-       client = create_client_data(pid, direct_addr);
-       if (!client) {
-               ErrPrint("Failed to create a new client (%d)\n", pid);
-               return NULL;
-       }
-
-       ret = client_rpc_init(client, handle);
-       if (ret < 0) {
-               client = client_unref(client);
-               ErrPrint("Failed to initialize the RPC for %d, Destroy client data %p(has to be 0x0)\n", pid, client);
-       } else {
-               Ecore_Timer *create_timer;
-               /*!
-                * \note
-                * To save the time to send reply packet to the client.
-                */
-               create_timer = ecore_timer_add(DELAY_TIME, created_cb, client_ref(client));
-               if (create_timer == NULL) {
-                       ErrPrint("Failed to add a timer for client created event\n");
-                       client = client_unref(client); /* Decrease refcnt for argument */
-                       client = client_unref(client); /* Destroy client object */
-                       return NULL;
-               }
-
-               ret = client_set_data(client, "create,timer", create_timer);
-               DbgPrint("Set data: %d\n", ret);
-       }
-
-       return client;
-}
-
-HAPI struct client_node *client_ref(struct client_node *client)
-{
-       if (!client) {
-               return NULL;
-       }
-
-       client->refcnt++;
-       return client;
-}
-
-HAPI struct client_node *client_unref(struct client_node *client)
-{
-       if (!client) {
-               return NULL;
-       }
-
-       if (client->refcnt == 0) {
-               ErrPrint("Client refcnt is not managed correctly\n");
-               return NULL;
-       }
-
-       client->refcnt--;
-       if (client->refcnt == 0) {
-               destroy_client_data(client);
-               client = NULL;
-       }
-
-       return client;
-}
-
-HAPI const int const client_refcnt(const struct client_node *client)
-{
-       return client->refcnt;
-}
-
-HAPI const pid_t const client_pid(const struct client_node *client)
-{
-       return client ? client->pid : (pid_t)-1;
-}
-
-HAPI struct client_node *client_find_by_pid(pid_t pid)
-{
-       Eina_List *l;
-       struct client_node *client;
-
-       EINA_LIST_FOREACH(s_info.client_list, l, client) {
-               if (client->pid == pid) {
-                       return client;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI struct client_node *client_find_by_rpc_handle(int handle)
-{
-       Eina_List *l;
-       struct client_node *client;
-
-       if (handle <= 0) {
-               ErrPrint("Invalid handle %d\n", handle);
-               return NULL;
-       }
-
-       EINA_LIST_FOREACH(s_info.client_list, l, client) {
-               if (client_rpc_handle(client) == handle) {
-                       return client;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI const int const client_count_paused(void)
-{
-       return s_info.nr_of_paused_clients;
-}
-
-HAPI int client_is_all_paused(void)
-{
-       DbgPrint("%d, %d\n", eina_list_count(s_info.client_list), s_info.nr_of_paused_clients);
-       return eina_list_count(s_info.client_list) == s_info.nr_of_paused_clients;
-}
-
-HAPI int client_count(void)
-{
-       return eina_list_count(s_info.client_list);
-}
-
-HAPI struct client_node *client_deactivated_by_fault(struct client_node *client)
-{
-       if (!client || client->faulted) {
-               return client;
-       }
-
-       ErrPrint("Client[%p] is faulted(%d), pid(%d)\n", client, client->refcnt, client->pid);
-       client->faulted = 1;
-       client->pid = (pid_t)-1;
-
-       invoke_deactivated_cb(client);
-       client = client_destroy(client);
-       /*!
-        * \todo
-        * Who invokes this function has to care the reference counter of a client
-        * do I need to invoke the deactivated callback from here?
-        * client->pid = (pid_t)-1;
-        * slave_unref(client)
-        */
-       return client;
-}
-
-HAPI const int const client_is_faulted(const struct client_node *client)
-{
-       /*!
-        * \note
-        * If the "client" is NIL, I assume that it is fault so returns TRUE(1)
-        */
-       return client ? client->faulted : 1;
-}
-
-HAPI void client_reset_fault(struct client_node *client)
-{
-       if (client) {
-               client->faulted = 0;
-       }
-}
-
-HAPI int client_event_callback_add(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data)
-{
-       struct event_item *item;
-
-       if (!cb) {
-               ErrPrint("Invalid callback (cb == NULL)\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->cb = cb;
-       item->data = data;
-       item->deleted = 0;
-
-       /*!
-        * \note
-        * Use the eina_list_prepend API.
-        * To keep the sequence of a callback invocation.
-        *
-        * Here is an example sequence.
-        *
-        * client_event_callback_add(CALLBACK_01);
-        * client_event_callback_add(CALLBACK_02);
-        * client_event_callback_add(CALLBACK_03);
-        *
-        * Then the invoke_event_callback function will call the CALLBACKS as below sequence
-        *
-        * invoke_CALLBACK_03
-        * invoke_CALLBACK_02
-        * invoke_CALLBACK_01
-        */
-
-       switch (event) {
-       case CLIENT_EVENT_DEACTIVATE:
-               client->event_deactivate_list = eina_list_prepend(client->event_deactivate_list, item);
-               break;
-       case CLIENT_EVENT_ACTIVATE:
-               client->event_activate_list = eina_list_prepend(client->event_activate_list, item);
-               break;
-       default:
-               DbgFree(item);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int client_event_callback_del(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data)
-{
-       struct event_item *item;
-       Eina_List *l;
-       Eina_List *n;
-
-       if (!cb) {
-               ErrPrint("Invalid callback (cb == NULL)\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (event) {
-       case CLIENT_EVENT_DEACTIVATE:
-               EINA_LIST_FOREACH_SAFE(client->event_deactivate_list, l, n, item) {
-                       if (item->cb == cb && item->data == data) {
-                               if (client->in_event_process & CLIENT_EVENT_PROCESS_DEACTIVATE) {
-                                       item->deleted = 1;
-                               } else {
-                                       client->event_deactivate_list = eina_list_remove(client->event_deactivate_list, item);
-                                       DbgFree(item);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-
-       case CLIENT_EVENT_ACTIVATE:
-               EINA_LIST_FOREACH_SAFE(client->event_activate_list, l, n, item) {
-                       if (item->cb == cb && item->data == data) {
-                               if (client->in_event_process & CLIENT_EVENT_PROCESS_ACTIVATE) {
-                                       item->deleted = 1;
-                               } else {
-                                       client->event_activate_list = eina_list_remove(client->event_activate_list, item);
-                                       DbgFree(item);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-
-       default:
-               ErrPrint("Invalid event\n");
-               break;
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-HAPI int client_set_data(struct client_node *client, const char *tag, void *data)
-{
-       struct data_item *item;
-
-       item = calloc(1, sizeof(*item));
-       if (!item) {
-               ErrPrint("calloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->tag = strdup(tag);
-       if (!item->tag) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(item);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->data = data;
-
-       client->data_list = eina_list_append(client->data_list, item);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void *client_data(struct client_node *client, const char *tag)
-{
-       Eina_List *l;
-       struct data_item *item;
-
-       EINA_LIST_FOREACH(client->data_list, l, item) {
-               if (!strcmp(item->tag, tag)) {
-                       return item->data;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI void *client_del_data(struct client_node *client, const char *tag)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct data_item *item;
-
-       EINA_LIST_FOREACH_SAFE(client->data_list, l, n, item) {
-               if (!strcmp(item->tag, tag)) {
-                       void *data;
-                       client->data_list = eina_list_remove(client->data_list, item);
-                       data = item->data;
-                       DbgFree(item->tag);
-                       DbgFree(item);
-                       return data;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI void client_paused(struct client_node *client)
-{
-       if (client->paused) {
-               return;
-       }
-
-       client->paused = 1;
-       s_info.nr_of_paused_clients++;
-}
-
-HAPI void client_resumed(struct client_node *client)
-{
-       if (client->paused == 0) {
-               return;
-       }
-
-       client->paused = 0;
-       s_info.nr_of_paused_clients--;
-}
-
-HAPI int client_init(void)
-{
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void client_fini(void)
-{
-       struct global_event_item *handler;
-       struct client_node *client;
-       Eina_List *l;
-       Eina_List *n;
-
-       EINA_LIST_FOREACH_SAFE(s_info.client_list, l, n, client) {
-               (void)client_destroy(client);
-       }
-
-       EINA_LIST_FREE(s_info.create_event_list, handler) {
-               DbgFree(handler);
-       }
-
-       EINA_LIST_FREE(s_info.destroy_event_list, handler) {
-               DbgFree(handler);
-       }
-}
-
-HAPI int client_global_event_handler_add(enum client_global_event event_type, int (*cb)(struct client_node *client, void *data), void *data)
-{
-       struct global_event_item *handler;
-
-       handler = malloc(sizeof(*handler));
-       if (!handler) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       handler->cbdata = data;
-       handler->cb = cb;
-       handler->deleted = 0;
-
-       switch (event_type) {
-       case CLIENT_GLOBAL_EVENT_CREATE:
-               s_info.create_event_list = eina_list_prepend(s_info.create_event_list, handler);
-               break;
-       case CLIENT_GLOBAL_EVENT_DESTROY:
-               s_info.destroy_event_list = eina_list_prepend(s_info.destroy_event_list, handler);
-               break;
-       default:
-               DbgFree(handler);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int client_global_event_handler_del(enum client_global_event event_type, int (*cb)(struct client_node *, void *), void *data)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct global_event_item *item;
-
-       switch (event_type) {
-       case CLIENT_GLOBAL_EVENT_CREATE:
-               EINA_LIST_FOREACH_SAFE(s_info.create_event_list, l, n, item) {
-                       if (item->cb == cb && item->cbdata == data) {
-                               if (s_info.in_event_process & GLOBAL_EVENT_PROCESS_CREATE) {
-                                       item->deleted = 1;
-                               } else {
-                                       s_info.create_event_list = eina_list_remove(s_info.create_event_list, item);
-                                       DbgFree(item);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       case CLIENT_GLOBAL_EVENT_DESTROY:
-               EINA_LIST_FOREACH_SAFE(s_info.destroy_event_list, l, n, item) {
-                       if (item->cb == cb && item->cbdata == data) {
-                               if (s_info.in_event_process & GLOBAL_EVENT_PROCESS_DESTROY) {
-                                       item->deleted = 1;
-                               } else {
-                                       s_info.destroy_event_list = eina_list_remove(s_info.destroy_event_list, item);
-                                       DbgFree(item);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       default:
-               break;
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-HAPI int client_subscribe_category(struct client_node *client, const char *category)
-{
-       struct category_subscribe_item *item;
-       Eina_List *l;
-
-       if (!category) {
-               ErrPrint("category: %p\n", category);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       EINA_LIST_FOREACH(client->category_subscribe_list, l, item) {
-               DbgPrint("item[%p], item->category[%p], category[%p]\n", item, item->category, category);
-               if (!strcasecmp(item->category, category)) {
-                       DbgPrint("[%s] is already subscribed\n");
-                       return WIDGET_ERROR_ALREADY_EXIST;
-               }
-       }
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->category = strdup(category);
-       if (!item->category) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(item);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgPrint("Subscribe category[%s]\n", item->category);
-       client->category_subscribe_list = eina_list_append(client->category_subscribe_list, item);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int client_unsubscribe_category(struct client_node *client, const char *category)
-{
-       struct category_subscribe_item *item;
-       Eina_List *l;
-       Eina_List *n;
-
-       if (!category) {
-               ErrPrint("category: %p\n", category);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       EINA_LIST_FOREACH_SAFE(client->category_subscribe_list, l, n, item) {
-               if (!strcasecmp(category, item->category)) {
-                       client->category_subscribe_list = eina_list_remove(client->category_subscribe_list, item);
-                       DbgFree(item->category);
-                       DbgFree(item);
-                       return WIDGET_ERROR_NONE;
-               }
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-HAPI int client_is_subscribed_by_category(struct client_node *client, const char *category)
-{
-       struct category_subscribe_item *item;
-       Eina_List *l;
-
-       if (!category) {
-               DbgPrint("category[%p]\n", category);
-               return 0;
-       }
-
-       EINA_LIST_FOREACH(client->category_subscribe_list, l, item) {
-               DbgPrint("item[%p], item->cateogyr[%p], category[%p]\n", item, item->category, category);
-               if (!strcasecmp(item->category, category)) {
-                       return 1;
-               }
-       }
-
-       return 0;
-}
-
-HAPI int client_subscribe_group(struct client_node *client, const char *cluster, const char *category)
-{
-       struct subscribe_item *item;
-
-       if (!cluster || !category) {
-               ErrPrint("Cluster[%p] Category[%p]\n", cluster, category);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->cluster = strdup(cluster);
-       if (!item->cluster) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(item);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->category = strdup(category);
-       if (!item->category) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(item->cluster);
-               DbgFree(item);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       client->subscribe_list = eina_list_append(client->subscribe_list, item);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int client_unsubscribe_group(struct client_node *client, const char *cluster, const char *category)
-{
-       struct subscribe_item *item;
-       Eina_List *l;
-       Eina_List *n;
-
-       if (!cluster || !category) {
-               ErrPrint("cluster: %p, category: %p\n", cluster, category);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       EINA_LIST_FOREACH_SAFE(client->subscribe_list, l, n, item) {
-               if (!strcasecmp(cluster, item->cluster) && !strcasecmp(category, item->category)) {
-                       client->subscribe_list = eina_list_remove(client->subscribe_list, item);
-                       DbgFree(item->cluster);
-                       DbgFree(item->category);
-                       DbgFree(item);
-                       return WIDGET_ERROR_NONE;
-               }
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-HAPI int client_is_subscribed_group(struct client_node *client, const char *cluster, const char *category)
-{
-       struct subscribe_item *item;
-       Eina_List *l;
-
-       if (!cluster || !category) {
-               ErrPrint("cluster: %p, category: %p\n", cluster, category);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       EINA_LIST_FOREACH(client->subscribe_list, l, item) {
-               if (!strcmp(item->cluster, "*")) {
-                       return 1;
-               }
-
-               if (strcasecmp(item->cluster, cluster)) {
-                       continue;
-               }
-
-               if (!strcmp(item->category, "*")) {
-                       return 1;
-               }
-
-               if (!strcasecmp(item->category, category)) {
-                       return 1;
-               }
-       }
-
-       return 0;
-}
-
-HAPI int client_browse_group_list(const char *cluster, const char *category, int (*cb)(struct client_node *client, void *data), void *data)
-{
-       Eina_List *l;
-       struct client_node *client;
-       int cnt;
-
-       if (!cb || !cluster || !category) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       cnt = 0;
-       EINA_LIST_FOREACH(s_info.client_list, l, client) {
-               if (!client_is_subscribed_group(client, cluster, category)) {
-                       continue;
-               }
-
-               if (cb(client, data) < 0) {
-                       return WIDGET_ERROR_CANCELED;
-               }
-
-               cnt++;
-       }
-
-       return cnt;
-}
-
-HAPI int client_browse_category_list(const char *category, int (*cb)(struct client_node *client, void *data), void *data)
-{
-       Eina_List *l;
-       struct client_node *client;
-       int cnt;
-
-       if (!cb || !category) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       cnt = 0;
-       EINA_LIST_FOREACH(s_info.client_list, l, client) {
-               if (!client_is_subscribed_by_category(client, category)) {
-                       continue;
-               }
-
-               if (cb(client, data) < 0) {
-                       return WIDGET_ERROR_CANCELED;
-               }
-
-               cnt++;
-       }
-
-       return cnt;
-}
-
-HAPI int client_count_of_group_subscriber(const char *cluster, const char *category)
-{
-       Eina_List *l;
-       struct client_node *client;
-       int cnt;
-
-       cnt = 0;
-       EINA_LIST_FOREACH(s_info.client_list, l, client) {
-               cnt += !!client_is_subscribed_group(client, cluster, category);
-       }
-
-       return cnt;
-}
-
-HAPI int client_broadcast(struct inst_info *inst, struct packet *packet)
-{
-       Eina_List *l;
-       Eina_List *list;
-       struct client_node *client;
-
-       list = inst ? instance_client_list(inst) : s_info.client_list;
-       EINA_LIST_FOREACH(list, l, client) {
-               if (client_pid(client) == -1) {
-                       ErrPrint("Client[%p] has PID[%d]\n", client, client_pid(client));
-                       continue;
-               }
-
-               (void)client_rpc_async_request(client, packet_ref(packet));
-       }
-
-       packet_unref(packet);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI const char *client_direct_addr(const struct client_node *client)
-{
-       return client ? client->direct.addr : NULL;
-}
-
-HAPI void client_set_orientation(struct client_node *client, int orientation)
-{
-       client->orientation = orientation;
-}
-
-HAPI int client_orientation(const struct client_node *client)
-{
-       return client->orientation;
-}
-
-HAPI const char *client_appid(const struct client_node *client)
-{
-       return client->appid;
-}
-
-HAPI int client_is_sdk_viewer(const struct client_node *client)
-{
-       return client ? client->is_sdk_viewer : 0;
-}
-
-HAPI struct client_node *client_find_by_direct_addr(const char *direct_addr)
-{
-       Eina_List *l;
-       struct client_node *client;
-
-       if (!direct_addr) {
-               return NULL;
-       }
-
-       EINA_LIST_FOREACH(s_info.client_list, l, client) {
-               if (client->direct.addr && !strcmp(client->direct.addr, direct_addr)) {
-                       return client;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI void client_set_direct_fd(struct client_node *client, int fd)
-{
-       client->direct.fd = fd;
-}
-
-HAPI int client_direct_fd(struct client_node *client)
-{
-       return client->direct.fd;
-}
-
-/* End of a file */
diff --git a/src/client_rpc.c b/src/client_rpc.c
deleted file mode 100644 (file)
index 67d3ba6..0000000
+++ /dev/null
@@ -1,286 +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 <errno.h>
-
-#include <Eina.h>
-#include <Ecore.h>
-
-#include <dlog.h>
-#include <com-core_packet.h>
-#include <packet.h>
-#include <widget_errno.h>
-#include <widget_conf.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-
-#include "client_life.h"
-#include "instance.h"
-#include "client_rpc.h"
-#include "debug.h"
-#include "conf.h"
-#include "util.h"
-
-#define RPC_TAG "rpc"
-
-/*!
- * \note
- * Static component information structure.
- */
-static struct info {
-       Eina_List *command_list; /*!< Packet Q: Before sending the request, all request commands will stay here */
-       Ecore_Timer *command_consumer; /*!< This timer will consuming the command Q. sending them to the specified client */
-} s_info = {
-       .command_list = NULL,
-       .command_consumer = NULL,
-};
-
-struct client_rpc {
-       int handle; /*!< Handler for communication with client */
-};
-
-struct command {
-       struct packet *packet;
-       struct client_node *client; /*!< Target client. who should receive this command */
-};
-
-/*!
- * \brief
- * Creating or Destroying command object
- */
-static inline struct command *create_command(struct client_node *client, struct packet *packet)
-{
-       struct command *command;
-
-       command = calloc(1, sizeof(*command));
-       if (!command) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       command->packet = packet_ref(packet);
-       command->client = client_ref(client);
-
-       return command;
-}
-
-static inline void destroy_command(struct command *command)
-{
-       client_unref(command->client);
-       packet_unref(command->packet);
-       DbgFree(command);
-}
-
-static inline int count_command(void)
-{
-       return eina_list_count(s_info.command_list);
-}
-
-static inline struct command *pop_command(void)
-{
-       struct command *command;
-
-       command = eina_list_nth(s_info.command_list, 0);
-       if (!command) {
-               return NULL;
-       }
-
-       s_info.command_list = eina_list_remove(s_info.command_list, command);
-       return command;
-}
-
-static Eina_Bool command_consumer_cb(void *data)
-{
-       struct command *command;
-       struct client_rpc *rpc;
-       int ret;
-
-       command = pop_command();
-       if (!command) {
-               s_info.command_consumer = NULL;
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       if (!command->client) {
-               DbgPrint("Has no client\n");
-               goto out;
-       }
-
-       if (client_is_faulted(command->client)) {
-               ErrPrint("Client[%p] is faulted, discard command\n", command->client);
-               goto out;
-       }
-
-       rpc = client_data(command->client, RPC_TAG);
-       if (!rpc) {
-               ErrPrint("Client is not activated\n");
-               goto out;
-       }
-
-       if (rpc->handle < 0) {
-               DbgPrint("RPC is not initialized\n");
-               goto out;
-       }
-
-       ret = com_core_packet_send_only(rpc->handle, command->packet);
-       if (ret < 0) {
-               ErrPrint("Failed to send packet %d\n", ret);
-       }
-
-out:
-       destroy_command(command);
-       return ECORE_CALLBACK_RENEW;
-}
-
-static inline void push_command(struct command *command)
-{
-       s_info.command_list = eina_list_append(s_info.command_list, command);
-
-       if (s_info.command_consumer) {
-               return;
-       }
-
-       s_info.command_consumer = ecore_timer_add(WIDGET_CONF_PACKET_TIME, command_consumer_cb, NULL);
-       if (!s_info.command_consumer) {
-               ErrPrint("Failed to add command consumer\n");
-               s_info.command_list = eina_list_remove(s_info.command_list, command);
-               destroy_command(command);
-       }
-}
-
-HAPI int client_rpc_async_request(struct client_node *client, struct packet *packet)
-{
-       struct command *command;
-       struct client_rpc *rpc;
-
-       if (!client || !packet) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (client_is_faulted(client)) {
-               ErrPrint("Client[%p] is faulted\n", client);
-               packet_unref(packet);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       rpc = client_data(client, RPC_TAG);
-       if (!rpc) {
-               ErrPrint("Client[%p] is not ready for communication (%s)\n", client, packet_command(packet));
-       }
-
-       command = create_command(client, packet);
-       if (!command) {
-               packet_unref(packet);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       push_command(command);
-       packet_unref(packet);
-       return WIDGET_ERROR_NONE;
-}
-
-static int deactivated_cb(struct client_node *client, void *data)
-{
-       struct client_rpc *rpc;
-       struct command *command;
-       Eina_List *l;
-       Eina_List *n;
-
-       rpc = client_data(client, RPC_TAG);
-       if (!rpc) {
-               ErrPrint("client is not valid\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       DbgPrint("Reset handle for %d\n", client_pid(client));
-       rpc->handle = -1;
-
-       DbgPrint("Begin: Destroying command\n");
-       EINA_LIST_FOREACH_SAFE(s_info.command_list, l, n, command) {
-               if (command->client == client) {
-                       s_info.command_list = eina_list_remove(s_info.command_list, command);
-                       destroy_command(command);
-               }
-       }
-       DbgPrint("End: Destroying command\n");
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int client_rpc_init(struct client_node *client, int handle)
-{
-       struct client_rpc *rpc;
-       int ret;
-
-       rpc = calloc(1, sizeof(*rpc));
-       if (!rpc) {
-               ErrPrint("calloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       ret = client_set_data(client, RPC_TAG, rpc);
-       if (ret < 0) {
-               ErrPrint("Failed to set \"rpc\" for client\n");
-               DbgFree(rpc);
-               return ret;
-       }
-
-       DbgPrint("CLIENT: New handle assigned for %d, %d (old: %d)\n", client_pid(client), handle, rpc->handle);
-       rpc->handle = handle;
-
-       ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, deactivated_cb, NULL);
-       if (ret < 0) {
-               struct client_rpc *weird;
-
-               weird = client_del_data(client, RPC_TAG);
-               if (weird != rpc) {
-                       ErrPrint("What happens? (%p <> %p)\n", weird, rpc);
-               }
-               DbgFree(rpc);
-       }
-
-       return ret;
-}
-
-HAPI int client_rpc_fini(struct client_node *client)
-{
-       struct client_rpc *rpc;
-
-       rpc = client_del_data(client, RPC_TAG);
-       if (!rpc) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, deactivated_cb, NULL);
-       DbgFree(rpc);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int client_rpc_handle(struct client_node *client)
-{
-       struct client_rpc *rpc;
-
-       rpc = client_data(client, RPC_TAG);
-       if (!rpc) {
-               DbgPrint("Client has no RPC\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return rpc->handle;
-}
-
-/* End of a file */
diff --git a/src/conf.c b/src/conf.c
deleted file mode 100644 (file)
index 8f52983..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "conf.h"
-
-struct conf g_conf = {
-       .debug_mode = 0,
-       .slave_max_load = -1,
-};
-
-/* End of a file */
index 703be15..a671a1b 100644 (file)
 
 #include <dlog.h>
 #include <Eina.h>
-#if defined(HAVE_LIVEBOX)
-#include <widget_errno.h>
-#include <widget_conf.h>
-#include <widget_util.h>
-#else
-#include "lite-errno.h"
-#endif
 
 #include "conf.h"
 #include "debug.h"
 #include "util.h"
+#include "service_common.h"
 #include "critical_log.h"
 
 static struct {
@@ -61,16 +55,16 @@ static inline void rotate_log(void)
        char *filename;
        int namelen;
 
-       if (s_info.nr_of_lines < WIDGET_CONF_MAX_LOG_LINE) {
+       if (s_info.nr_of_lines < CONF_MAX_LOG_LINE) {
                return;
        }
 
-       s_info.file_id = (s_info.file_id + 1) % WIDGET_CONF_MAX_LOG_FILE;
+       s_info.file_id = (s_info.file_id + 1) % CONF_MAX_LOG_FILE;
 
-       namelen = strlen(s_info.filename) + strlen(WIDGET_CONF_LOG_PATH) + 30;
+       namelen = strlen(s_info.filename) + strlen(CONF_LOG_PATH) + 30;
        filename = malloc(namelen);
        if (filename) {
-               snprintf(filename, namelen, "%s/%d_%s.%d", WIDGET_CONF_LOG_PATH, s_info.file_id, s_info.filename, getpid());
+               snprintf(filename, namelen, "%s/%d_%s.%d", CONF_LOG_PATH, s_info.file_id, s_info.filename, getpid());
 
                if (s_info.fp) {
                        if (fclose(s_info.fp) != 0) {
@@ -97,12 +91,12 @@ HAPI int critical_log(const char *func, int line, const char *fmt, ...)
        int ret;
 
        if (!s_info.fp) {
-               return WIDGET_ERROR_IO_ERROR;
+               return SERVICE_COMMON_ERROR_IO_ERROR;
        }
 
        CRITICAL_SECTION_BEGIN(&s_info.cri_lock);
 
-       fprintf(s_info.fp, "%lf [%s:%d] ", util_timestamp(), widget_util_basename((char *)func), line);
+       fprintf(s_info.fp, "%lf [%s:%d] ", util_timestamp(), util_basename((char *)func), line);
 
        va_start(ap, fmt);
        ret = vfprintf(s_info.fp, fmt, ap);
@@ -125,26 +119,26 @@ HAPI int critical_log_init(const char *name)
        char *filename;
 
        if (s_info.fp) {
-               return WIDGET_ERROR_NONE;
+               return SERVICE_COMMON_ERROR_NONE;
        }
 
        s_info.filename = strdup(name);
        if (!s_info.filename) {
                ErrPrint("Failed to create a log file\n");
-               return WIDGET_ERROR_OUT_OF_MEMORY;
+               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
-       namelen = strlen(name) + strlen(WIDGET_CONF_LOG_PATH) + 30;
+       namelen = strlen(name) + strlen(CONF_LOG_PATH) + 30;
 
        filename = malloc(namelen);
        if (!filename) {
                ErrPrint("Failed to create a log file\n");
                DbgFree(s_info.filename);
                s_info.filename = NULL;
-               return WIDGET_ERROR_OUT_OF_MEMORY;
+               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
-       snprintf(filename, namelen, "%s/%d_%s.%d", WIDGET_CONF_LOG_PATH, s_info.file_id, name, getpid());
+       snprintf(filename, namelen, "%s/%d_%s.%d", CONF_LOG_PATH, s_info.file_id, name, getpid());
 
        s_info.fp = fopen(filename, "w+");
        if (!s_info.fp) {
@@ -152,11 +146,11 @@ HAPI int critical_log_init(const char *name)
                DbgFree(s_info.filename);
                s_info.filename = NULL;
                DbgFree(filename);
-               return WIDGET_ERROR_IO_ERROR;
+               return SERVICE_COMMON_ERROR_IO_ERROR;
        }
 
        DbgFree(filename);
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 
diff --git a/src/dead_monitor.c b/src/dead_monitor.c
deleted file mode 100644 (file)
index 009dd23..0000000
+++ /dev/null
@@ -1,206 +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 <unistd.h>
-
-#include <gio/gio.h>
-#include <packet.h>
-#include <com-core.h>
-#include <dlog.h>
-
-#include <Eina.h>
-#include <widget_errno.h>
-#include <widget_service.h> /* destroy_type for instance.h */
-#include <widget_service_internal.h> /* destroy_type for instance.h */
-
-#include "slave_life.h"
-#include "client_life.h"
-#include "instance.h"
-#include "fault_manager.h"
-#include "util.h"
-#include "debug.h"
-#include "widget-mgr.h"
-#include "conf.h"
-
-struct cb_item {
-       int handle;
-       int disconnected;
-       void (*dead_cb)(int handle, void *data);
-       void *data;
-};
-
-static struct info {
-       Eina_List *cb_list;
-} s_info = {
-       .cb_list = NULL,
-};
-
-static int evt_cb(int handle, void *data)
-{
-       struct slave_node *slave;
-       struct client_node *client;
-       struct widget_mgr *widget_mgr;
-       struct cb_item *dead_item;
-       Eina_List *l;
-       Eina_List *n;
-
-       EINA_LIST_FOREACH_SAFE(s_info.cb_list, l, n, dead_item) {
-               /**
-                * If the callback is called already,
-                * Do not call it again.
-                * Using "disconnected" varaible, prevent from duplicated callback call.
-                */
-               if (dead_item->handle == handle) {
-                       if (dead_item->disconnected == 0) {
-                               dead_item->dead_cb(dead_item->handle, dead_item->data);
-                               dead_item->disconnected = 1;
-                               break;
-                       }
-               }
-       }
-
-       slave = slave_find_by_rpc_handle(handle);
-       if (slave) {
-               if (slave_pid(slave) != (pid_t)-1) {
-                       switch (slave_state(slave)) {
-                       case SLAVE_REQUEST_TO_DISCONNECT:
-                               DbgPrint("Disconnected from %d\n", slave_pid(slave));
-                       case SLAVE_REQUEST_TO_TERMINATE:
-                               slave = slave_deactivated(slave);
-                               break;
-                       default:
-                               if (slave_wait_deactivation(slave)) {
-                                       /**
-                                        * @note
-                                        * Slave is waiting the termination,
-                                        * in this case, it should be dealt as a normal termination.
-                                        */
-
-                                       DbgPrint("Slave is waiting deactivation, Do not re-activate automatically in this case\n");
-                                       slave_set_wait_deactivation(slave, 0);
-                                       slave_set_reactivation(slave, 0);
-                                       slave_set_reactivate_instances(slave, 1);
-
-                                       slave = slave_deactivated(slave);
-                               } else {
-                                       slave = slave_deactivated_by_fault(slave);
-                               }
-                               break;
-                       }
-               }
-
-               if (!slave) {
-                       DbgPrint("Slave is deleted\n");
-               }
-
-               return 0;
-       }
-
-       client = client_find_by_rpc_handle(handle);
-       if (client) {
-               if (client_pid(client) != (pid_t)-1) {
-                       client = client_deactivated_by_fault(client);
-               }
-
-               if (!client) {
-                       DbgPrint("Client is deleted\n");
-               }
-
-               return 0;
-       }
-
-       widget_mgr = widget_mgr_find_by_handle(handle);
-       if (widget_mgr) {
-               widget_mgr_destroy(widget_mgr);
-               return 0;
-       }
-
-       return 0;
-}
-
-HAPI int dead_init(void)
-{
-       com_core_add_event_callback(CONNECTOR_DISCONNECTED, evt_cb, NULL);
-       return 0;
-}
-
-HAPI int dead_fini(void)
-{
-       struct cb_item *item;
-
-       com_core_del_event_callback(CONNECTOR_DISCONNECTED, evt_cb, NULL);
-
-       EINA_LIST_FREE(s_info.cb_list, item) {
-               DbgFree(item);
-       }
-
-       return 0;
-}
-
-HAPI int dead_callback_add(int handle, void (*dead_cb)(int handle, void *data), void *data)
-{
-       struct cb_item *item;
-       Eina_List *l;
-
-       EINA_LIST_FOREACH(s_info.cb_list, l, item) {
-               if (item->handle == handle && item->disconnected == 0) {
-                       return WIDGET_ERROR_ALREADY_EXIST;
-               }
-       }
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->handle = handle;
-       item->dead_cb = dead_cb;
-       item->data = data;
-       /**
-        * Handle can be reallocated if the first connection is disconnected,
-        * The kernel can resue the last handle (index) for newly comming connection.
-        * So we have to check the callback data using disconnected field.
-        * If the connection is disconnected first, we have to toggle this to true.
-        */
-       item->disconnected = 0;
-
-       s_info.cb_list = eina_list_append(s_info.cb_list, item);
-       return 0;
-}
-
-HAPI void *dead_callback_del(int handle, void (*dead_cb)(int handle, void *data), void *data)
-{
-       struct cb_item *item;
-       Eina_List *l;
-       Eina_List *n;
-
-       EINA_LIST_FOREACH_SAFE(s_info.cb_list, l, n, item) {
-               if (item->handle == handle && item->dead_cb == dead_cb && item->data == data) {
-                       void *cbdata;
-
-                       s_info.cb_list = eina_list_remove(s_info.cb_list, item);
-                       cbdata = item->data;
-                       DbgFree(item);
-
-                       return cbdata;
-               }
-       }
-
-       return NULL;
-}
-
-/* End of a file */
diff --git a/src/event.c b/src/event.c
deleted file mode 100644 (file)
index d95707d..0000000
+++ /dev/null
@@ -1,1197 +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 <errno.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <linux/input.h>
-
-#include <Eina.h>
-#include <Ecore.h>
-#include <dlog.h>
-#include <widget_errno.h>
-#include <widget_service_internal.h>
-#include <widget_conf.h>
-
-#include "util.h"
-#include "debug.h"
-#include "conf.h"
-#include "event.h"
-
-#define EVENT_CH       'e'
-#define EVENT_EXIT     'x'
-
-#define PRESSURE 10
-#define DELAY_COMPENSATOR 0.1f
-
-#if !defined(EVIOCSCLOCKID)
-/**
- * @note
- * I just copy this from the latest input.h file.
- * It could not be compatible with the latest one.
- */
-#define EVIOCSCLOCKID           _IOW('E', 0xa0, int)                    /* Set clockid to be used for timestamps */
-#endif
-
-int errno;
-
-static struct info {
-       pthread_t tid;
-       Eina_List *event_list;
-       int handle;
-       pthread_mutex_t event_list_lock;
-       int evt_pipe[PIPE_MAX];
-       int tcb_pipe[PIPE_MAX];
-       Ecore_Fd_Handler *event_handler;
-
-       struct event_data event_data;
-       struct event_data skipped_event_data;
-
-       Eina_List *event_listener_list;
-       Eina_List *reactivate_list;
-
-       enum event_handler_activate_type event_handler_activated;
-       int timestamp_updated;
-} s_info = {
-       .event_handler_activated = EVENT_HANDLER_DEACTIVATED,
-       .event_list = NULL,
-       .handle = -1,
-       .event_handler = NULL,
-       .evt_pipe = { -1, -1 },
-       .tcb_pipe = { -1, -1 },
-
-       .event_data = {
-               .x = -1,
-               .y = -1,
-               .device = -1,
-               .slot = 0,
-               .keycode = 0,
-       },
-
-       .skipped_event_data = {
-               .x = -1,
-               .y = -1,
-               .device = -1,
-               .slot = 0,
-               .keycode = 0,
-       },
-
-       .event_listener_list = NULL,
-       .reactivate_list = NULL,
-       .timestamp_updated = 0,
-};
-
-struct event_listener {
-       int (*event_cb)(enum event_state state, struct event_data *event, void *data);
-       void *cbdata;
-
-       enum event_state prev_state;
-       enum event_state state;
-
-       double tv;
-       int x; /* RelX */
-       int y; /* RelY */
-       double ratio_w;
-       double ratio_h;
-       int slot;
-
-       int unset_done;
-};
-
-static int event_control_fini(void);
-
-HAPI int event_init(void)
-{
-       int ret;
-
-       ret = pthread_mutex_init(&s_info.event_list_lock, NULL);
-       if (ret != 0) {
-               ErrPrint("Mutex: %d\n", ret);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int event_fini(void)
-{
-       int ret;
-
-       event_control_fini();
-
-       ret = pthread_mutex_destroy(&s_info.event_list_lock);
-       if (ret != 0) {
-               ErrPrint("Mutex destroy: %d\n", ret);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-/*
- * This function can be called Event Thread.
- */
-static int push_event_item(void)
-{
-       struct event_data *item;
-
-       if (s_info.event_data.x < 0 || s_info.event_data.y < 0) {
-               /* Waiting full event packet */
-               return WIDGET_ERROR_NONE;
-       }
-
-       item = malloc(sizeof(*item));
-       if (item) {
-               char event_ch = EVENT_CH;
-
-               memcpy(item, &s_info.event_data, sizeof(*item));
-
-               CRITICAL_SECTION_BEGIN(&s_info.event_list_lock);
-               s_info.event_list = eina_list_append(s_info.event_list, item);
-               CRITICAL_SECTION_END(&s_info.event_list_lock);
-
-               if (write(s_info.evt_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
-                       ErrPrint("write: %d\n", errno);
-                       return WIDGET_ERROR_IO_ERROR;
-               }
-
-               /* Take a breathe */
-               pthread_yield();
-       } else {
-               ErrPrint("malloc: %d\n", errno);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static struct event_data *pop_event_item(void)
-{
-       struct event_data *item;
-
-       CRITICAL_SECTION_BEGIN(&s_info.event_list_lock);
-       item = eina_list_nth(s_info.event_list, 0);
-       if (item) {
-               s_info.event_list = eina_list_remove(s_info.event_list, item);
-       }
-       CRITICAL_SECTION_END(&s_info.event_list_lock);
-
-       return item;
-}
-
-static double current_time_get(void)
-{
-       double ret;
-
-       if (WIDGET_CONF_USE_GETTIMEOFDAY) {
-               struct timeval tv;
-               if (gettimeofday(&tv, NULL) < 0) {
-                       ErrPrint("gettimeofday: %d\n", errno);
-                       ret = ecore_time_get();
-               } else {
-                       ret = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0f);
-               }
-       } else {
-               ret = ecore_time_get();
-       }
-
-       return ret;
-}
-
-static void update_timestamp(struct input_event *event)
-{
-       /*
-        * Input event uses timeval instead of timespec,
-        * but its value is same as MONOTIC CLOCK TIME
-        * So we should handles it properly.
-        */
-       s_info.event_data.tv = (double)event->time.tv_sec + (double)event->time.tv_usec / 1000000.0f;
-       s_info.timestamp_updated = 1;
-}
-
-static void processing_ev_abs(struct input_event *event)
-{
-       switch (event->code) {
-#if defined(ABS_X)
-       case ABS_X:
-               break;
-#endif
-#if defined(ABS_Y)
-       case ABS_Y:
-               break;
-#endif
-#if defined(ABS_Z)
-       case ABS_Z:
-               break;
-#endif
-#if defined(ABS_RX)
-       case ABS_RX:
-               break;
-#endif
-#if defined(ABS_RY)
-       case ABS_RY:
-               break;
-#endif
-#if defined(ABS_RZ)
-       case ABS_RZ:
-               break;
-#endif
-#if defined(ABS_THROTTLE)
-       case ABS_THROTTLE:
-               break;
-#endif
-#if defined(ABS_RUDDER)
-       case ABS_RUDDER:
-               break;
-#endif
-#if defined(ABS_WHEEL)
-       case ABS_WHEEL:
-               break;
-#endif
-#if defined(ABS_GAS)
-       case ABS_GAS:
-               break;
-#endif
-#if defined(ABS_BRAKE)
-       case ABS_BRAKE:
-               break;
-#endif
-#if defined(ABS_HAT0X)
-       case ABS_HAT0X:
-               break;
-#endif
-#if defined(ABS_HAT0Y)
-       case ABS_HAT0Y:
-               break;
-#endif
-#if defined(ABS_HAT1X)
-       case ABS_HAT1X:
-               break;
-#endif
-#if defined(ABS_HAT1Y)
-       case ABS_HAT1Y:
-               break;
-#endif
-#if defined(ABS_HAT2X)
-       case ABS_HAT2X:
-               break;
-#endif
-#if defined(ABS_HAT2Y)
-       case ABS_HAT2Y:
-               break;
-#endif
-#if defined(ABS_HAT3X)
-       case ABS_HAT3X:
-               break;
-#endif
-#if defined(ABS_HAT3Y)
-       case ABS_HAT3Y:
-               break;
-#endif
-#if defined(ABS_PRESSURE)
-       case ABS_PRESSURE:
-               break;
-#endif
-#if defined(ABS_TILT_X)
-       case ABS_TILT_X:
-               break;
-#endif
-#if defined(ABS_TILT_Y)
-       case ABS_TILT_Y:
-               break;
-#endif
-#if defined(ABS_TOOL_WIDTH)
-       case ABS_TOOL_WIDTH:
-               break;
-#endif
-#if defined(ABS_VOLUME)
-       case ABS_VOLUME:
-               break;
-#endif
-#if defined(ABS_MISC)
-       case ABS_MISC:
-               break;
-#endif
-#if defined(ABS_DISTANCE)
-       case ABS_DISTANCE:
-               s_info.event_data.distance = event->value;
-               break;
-#endif
-#if defined(ABS_MT_POSITION_X)
-       case ABS_MT_POSITION_X:
-               s_info.event_data.x = event->value;
-               break;
-#endif
-#if defined(ABS_MT_POSITION_Y)
-       case ABS_MT_POSITION_Y:
-               s_info.event_data.y = event->value;
-               break;
-#endif
-#if defined(ABS_MT_SLOT)
-       case ABS_MT_SLOT:
-               s_info.event_data.slot = event->value;
-               break;
-#endif
-#if defined(ABS_MT_TRACKING_ID)
-       case ABS_MT_TRACKING_ID:
-               s_info.event_data.device = event->value;
-               break;
-#endif
-#if defined(ABS_MT_TOUCH_MAJOR)
-       case ABS_MT_TOUCH_MAJOR:
-               s_info.event_data.touch.major = event->value;
-               break;
-#endif
-#if defined(ABS_MT_TOUCH_MINOR)
-       case ABS_MT_TOUCH_MINOR:
-               s_info.event_data.touch.minor = event->value;
-               break;
-#endif
-#if defined(ABS_MT_WIDTH_MAJOR)
-       case ABS_MT_WIDTH_MAJOR:
-               s_info.event_data.width.major = event->value;
-               break;
-#endif
-#if defined(ABS_MT_WIDTH_MINOR)
-       case ABS_MT_WIDTH_MINOR:
-               s_info.event_data.width.minor = event->value;
-               break;
-#endif
-#if defined(ABS_MT_ORIENTATION)
-       case ABS_MT_ORIENTATION:
-               s_info.event_data.orientation = event->value;
-               break;
-#endif
-#if defined(ABS_MT_PRESSURE)
-       case ABS_MT_PRESSURE:
-               s_info.event_data.pressure = event->value;
-               break;
-#endif
-#if defined(ABS_MT_TOOL_X)
-       case ABS_MT_TOOL_X:
-               DbgPrint("TOOL_X: %d\n", event->value);
-               break;
-#endif
-#if defined(ABS_MT_TOOL_Y)
-       case ABS_MT_TOOL_Y:
-               DbgPrint("TOOL_Y: %d\n", event->value);
-               break;
-#endif
-#if defined(ABS_MT_TOOL_TYPE)
-       case ABS_MT_TOOL_TYPE:
-               DbgPrint("TOOL_TYPE: %d\n", event->value);
-               break;
-#endif
-#if defined(ABS_MT_BLOB_ID)
-       case ABS_MT_BLOB_ID:
-               DbgPrint("BLOB_ID: %d\n", event->value);
-               break;
-#endif
-#if defined(ABS_MT_DISTANCE)
-       case ABS_MT_DISTANCE:
-               DbgPrint("DISTANCE: %d\n", event->value);
-               break;
-#endif
-#if defined(ABS_MT_PALM)
-       case ABS_MT_PALM:
-               DbgPrint("PALM: %d\n", event->value);
-               break;
-#endif
-       default:
-#if defined(ABS_MT_COMPONENT)
-               if (event->code == ABS_MT_COMPONENT) {
-                       DbgPrint("COMPONENT: %d\n", event->value);
-                       break;
-               }
-#endif
-#if defined(ABS_MT_ANGLE)
-               if (event->code == ABS_MT_ANGLE) {
-                       DbgPrint("ANGLE: %d\n", event->value);
-                       break;
-               }
-#endif
-#if defined(ABS_MT_SUMSIZE)
-               if (event->code == ABS_MT_SUMSIZE) {
-                       DbgPrint("SUMSIZE: %d\n", event->value);
-                       break;
-               }
-#endif
-               break;
-       }
-
-       return;
-}
-
-/*
- * Called by Event Thread
- */
-static inline int processing_input_event(struct input_event *event)
-{
-       int ret;
-
-       if (s_info.timestamp_updated == 0) {
-               update_timestamp(event);
-       }
-
-       switch (event->type) {
-       case EV_SYN:
-               switch (event->code) {
-               case SYN_CONFIG:
-                       break;
-               case SYN_MT_REPORT:
-               case SYN_REPORT:
-                       s_info.timestamp_updated = 0;
-                       ret = push_event_item();
-                       if (ret < 0) {
-                               return ret;
-                       }
-
-                       break;
-#if defined(SYN_DROPPED)
-               case SYN_DROPPED:
-                       DbgPrint("EV_SYN, SYN_DROPPED\n");
-                       break;
-#endif
-               default:
-                       DbgPrint("EV_SYN, 0x%x\n", event->code);
-                       break;
-               }
-               break;
-       case EV_KEY:
-               DbgPrint("EV_KEY: 0x%X\n", event->value);
-               s_info.event_data.keycode = event->value;
-               s_info.event_data.source = INPUT_EVENT_SOURCE_NODE;
-               break;
-       case EV_REL:
-               DbgPrint("EV_REL: 0x%X\n", event->value);
-               break;
-       case EV_ABS:
-               processing_ev_abs(event);
-               s_info.event_data.source = INPUT_EVENT_SOURCE_NODE;
-               break;
-       case EV_MSC:
-       case EV_SW:
-       case EV_LED:
-       case EV_SND:
-       case EV_REP:
-       case EV_FF:
-       case EV_PWR:
-       case EV_FF_STATUS:
-       default:
-               DbgPrint("0x%X, 0x%X\n", event->type, event->code);
-               break;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static void *event_thread_main(void *data)
-{
-       fd_set set;
-       long ret = 0;
-       struct input_event input_event;
-       char *ptr = (char *)&input_event;
-       int offset = 0;
-       int readsize = 0;
-       int fd;
-       char event_ch;
-
-       s_info.event_data.x = -1;
-       s_info.event_data.y = -1;
-       s_info.event_data.slot = 0;
-
-       while (1) {
-               FD_ZERO(&set);
-               FD_SET(s_info.handle, &set);
-               FD_SET(s_info.tcb_pipe[PIPE_READ], &set);
-
-               fd = s_info.handle > s_info.tcb_pipe[PIPE_READ] ? s_info.handle : s_info.tcb_pipe[PIPE_READ];
-               ret = select(fd + 1, &set, NULL, NULL, NULL);
-               if (ret < 0) {
-                       ret = -errno;
-                       if (errno == EINTR) {
-                               DbgPrint("Select receives INTR\n");
-                               continue;
-                       }
-                       ErrPrint("select: %d\n", errno);
-                       break;
-               } else if (ret == 0) {
-                       ErrPrint("Timeout expired\n");
-                       ret = WIDGET_ERROR_TIMED_OUT;
-                       break;
-               }
-
-               if (FD_ISSET(s_info.handle, &set)) {
-                       readsize = read(s_info.handle, ptr + offset, sizeof(input_event) - offset);
-                       if (readsize < 0) {
-                               ErrPrint("read: %d / fd: %d / offset: %d / size: %d - %d\n", errno, s_info.handle, offset, sizeof(input_event), readsize);
-                               ret = WIDGET_ERROR_FAULT;
-                               break;
-                       }
-
-                       offset += readsize;
-                       if (offset == sizeof(input_event)) {
-                               offset = 0;
-                               if (processing_input_event(&input_event) < 0) {
-                                       ret = WIDGET_ERROR_FAULT;
-                                       break;
-                               }
-                       }
-
-                       /*
-                        * If there is input event,
-                        * Try again to get the input event.
-                        */
-               } else if (!s_info.timestamp_updated && FD_ISSET(s_info.tcb_pipe[PIPE_READ], &set)) {
-                       /*!
-                        * Check the s_info.timestamp_updated flag.
-                        * If it is not ZERO, it means, there is event to be processed.
-                        * So we have to wait it to be finished.
-                        */
-                       if (read(s_info.tcb_pipe[PIPE_READ], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
-                               ErrPrint("read: %d\n", errno);
-                       }
-
-                       ret = WIDGET_ERROR_CANCELED;
-                       break;
-               }
-       }
-
-       event_ch = EVENT_EXIT;
-       if (write(s_info.evt_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
-               ErrPrint("write: %d\n", errno);
-       }
-
-       return (void *)ret;
-}
-
-static int invoke_event_cb(struct event_listener *listener, struct event_data *item)
-{
-       struct event_data modified_item;
-
-       memcpy(&modified_item, item, sizeof(modified_item));
-
-       modified_item.x -= listener->x;
-       modified_item.y -= listener->y;
-       modified_item.ratio_w = listener->ratio_w;
-       modified_item.ratio_h = listener->ratio_h;
-
-       if (!WIDGET_CONF_USE_EVENT_TIME) {
-               item->tv = current_time_get();
-       }
-
-       if (listener->event_cb(listener->state, &modified_item, listener->cbdata) < 0) {
-               if (eina_list_data_find(s_info.event_listener_list, listener)) {
-                       s_info.event_listener_list = eina_list_remove(s_info.event_listener_list, listener);
-                       DbgFree(listener);
-                       return 1;
-               }
-       }
-
-       return 0;
-}
-
-static inline void clear_listener(struct event_listener *listener)
-{
-       enum event_state next_state;
-       struct event_data event_data;
-       struct event_data *p_event_data;
-
-       /**
-        * @note
-        * terminate this listener. with keep its event state (DOWN -> MOVE -> UP)
-        */
-       while (listener) {
-               DbgPrint("listener[%p] prev[%x] state[%x]\n", listener, listener->prev_state, listener->state);
-
-               switch (listener->state) {
-               case EVENT_STATE_ACTIVATE:
-                       p_event_data = &s_info.event_data;
-                       next_state = EVENT_STATE_ACTIVATED;
-                       break;
-               case EVENT_STATE_ACTIVATED:
-                       p_event_data = &s_info.event_data;
-                       next_state = EVENT_STATE_DEACTIVATE;
-                       break;
-               case EVENT_STATE_DEACTIVATE:
-                       memcpy(&event_data, &s_info.event_data, sizeof(event_data));
-                       p_event_data = &event_data;
-
-                       if (listener->prev_state == EVENT_STATE_ACTIVATE) {
-                               /* There is no move event. we have to emulate it */
-                               DbgPrint ("Let's emulate move event (%dx%d)\n", p_event_data->x, p_event_data->y);
-                               listener->state = EVENT_STATE_ACTIVATE;
-                               next_state = EVENT_STATE_ACTIVATED;
-                       } else {
-                               next_state = EVENT_STATE_DEACTIVATED;
-                       }
-                       break;
-               case EVENT_STATE_DEACTIVATED:
-               default:
-                       s_info.event_listener_list = eina_list_remove(s_info.event_listener_list, listener);
-                       DbgFree(listener);
-                       listener = NULL;
-                       continue;
-               }
-
-               p_event_data->slot = listener->slot;
-               if (invoke_event_cb(listener, p_event_data)) {
-                       /**
-                        * @note
-                        * listener is deleted.
-                        */
-                       listener = NULL;
-                       continue;
-               }
-
-               /*!
-                * Changing state of listener will affect to the event collecting thread.
-                */
-               listener->prev_state = listener->state;
-               listener->state = next_state;
-       }
-}
-
-static inline void clear_all_listener_list(void)
-{
-       struct event_listener *listener;
-       Eina_List *l;
-       Eina_List *n;
-
-       DbgPrint("event listeners: %d\n", eina_list_count(s_info.event_listener_list));
-
-       if (s_info.event_data.x == -1 || s_info.event_data.y == -1) {
-               memcpy(&s_info.event_data, &s_info.skipped_event_data, sizeof(s_info.event_data));
-               DbgPrint("Use skipped event: %dx%d\n", s_info.skipped_event_data.x, s_info.skipped_event_data.y);
-       }
-
-       EINA_LIST_FOREACH_SAFE(s_info.event_listener_list, l, n, listener) {
-               clear_listener(listener);
-       }
-}
-
-static int compare_timestamp(struct event_listener *listener, struct event_data *item)
-{
-       int ret;
-       if (listener->tv > item->tv) {
-               ret = 1;
-       } else if (listener->tv < item->tv) {
-               ret = -1;
-       } else {
-               ret = 0;
-       }
-       return ret;
-}
-
-static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler)
-{
-       int fd;
-       struct event_data *item;
-       char event_ch;
-       struct event_listener *listener;
-       Eina_List *l;
-       Eina_List *n;
-       enum event_state next_state;
-       int state;
-
-       fd = ecore_main_fd_handler_fd_get(handler);
-       if (fd < 0) {
-               ErrPrint("Invalid fd\n");
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       if (read(fd, &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
-               ErrPrint("read: %d\n", errno);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       if (event_ch == EVENT_EXIT) {
-               /*!
-                * If the master gets event exit from evt_pipe,
-                * The event item list should be empty.
-                */
-               if (!s_info.event_list) {
-                       /* This callback must has to clear all listeners in this case */
-                       ecore_main_fd_handler_del(s_info.event_handler);
-                       s_info.event_handler = NULL;
-                       clear_all_listener_list();
-
-                       EINA_LIST_FREE(s_info.reactivate_list, listener) {
-                               s_info.event_listener_list = eina_list_append(s_info.event_listener_list, listener);
-                       }
-                       DbgPrint("Reactivate: %p\n", s_info.event_listener_list);
-
-                       if (s_info.event_listener_list) {
-                               if (event_activate_thread(EVENT_HANDLER_ACTIVATED_BY_MOUSE_SET) < 0) {
-                                       EINA_LIST_FREE(s_info.event_listener_list, listener) {
-                                               (void)listener->event_cb(EVENT_STATE_ERROR, NULL, listener->cbdata);
-                                       }
-                               }
-                       }
-
-                       DbgPrint("Event read callback finshed (%p)\n", s_info.event_listener_list);
-                       return ECORE_CALLBACK_CANCEL;
-               } else {
-                       ErrPrint("Something goes wrong, the event_list is not flushed\n");
-               }
-       }
-
-       item = pop_event_item();
-       if (!item) {
-               ErrPrint("There is no remained event\n");
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       EINA_LIST_FOREACH_SAFE(s_info.event_listener_list, l, n, listener) {
-               if (item->slot != listener->slot) {
-                       continue;
-               }
-
-               if (item->device == -1) {
-                       DbgPrint("Touch released (%d) listener state(%x)\n", item->slot, listener->state);
-               }
-
-               switch (listener->state) {
-               case EVENT_STATE_ACTIVATE:
-                       if (compare_timestamp(listener, item) > 0) {
-                               memcpy(&s_info.skipped_event_data, item, sizeof(s_info.skipped_event_data));
-                               continue;
-                       }
-
-                       next_state = EVENT_STATE_ACTIVATED;
-                       break;
-               case EVENT_STATE_DEACTIVATE:
-                       if (compare_timestamp(listener, item) < 0) {
-                               if (listener->unset_done == 1) {
-                                       /**
-                                        * @note
-                                        * in case of the multi=touch,
-                                        * The thread will not be terminated soon.
-                                        * in this case, we should send UP event and destroy listener properly.
-                                        */
-                                       clear_listener(listener);
-                                       /**
-                                        * @note
-                                        * Listener will be deleted.
-                                        * But event_item which is related with this listener can be remained.
-                                        * And it will be deleted soon.
-                                        */
-                                       continue;
-                               }
-
-                               /* Consuming all events occurred while activating this listener */
-                               state = listener->prev_state;
-                               listener->prev_state = listener->state;
-
-                               if (state == EVENT_STATE_ACTIVATE) {
-                                       /**
-                                        * @note
-                                        * If the previous state is ACTIVATE
-                                        * We should create DOWN event first.
-                                        */
-                                       listener->state = EVENT_STATE_ACTIVATE;
-                               } else {
-                                       listener->state = EVENT_STATE_ACTIVATED;
-                               }
-
-                               if (invoke_event_cb(listener, item) == 1) {
-                                       /**
-                                        * @note
-                                        * listener is deleted
-                                        */
-                                       continue;
-                               }
-
-                               if (listener->state == EVENT_STATE_ACTIVATE) {
-                                       /**
-                                        * @note
-                                        * We are already jumped into the DEACTIVATE state
-                                        * But the state is ACTIVATE, it means, we forcely chnaged it from LINE 747
-                                        * We successfully sent the DOWN event.
-                                        * We only need to send UP (or move) event.
-                                        * So change the previous states to ACTIVATED and then change current states to
-                                        * DEACTIVATE again.
-                                        */
-                                       listener->prev_state = EVENT_STATE_ACTIVATED;
-                               } else {
-                                       listener->prev_state = listener->state;
-                               }
-
-                               listener->state = EVENT_STATE_DEACTIVATE;
-                       } else {
-                               memcpy(&s_info.skipped_event_data, item, sizeof(s_info.skipped_event_data));
-                       }
-
-                       /**
-                        * @note
-                        * Do not terminate this listener, until this mets EVENT_EXIT
-                        */
-                       continue;
-               case EVENT_STATE_ACTIVATED:
-                       if (compare_timestamp(listener, item) > 0) {
-                               DbgPrint("Drop event (%lf > %lf)\n", listener->tv, item->tv);
-                               memcpy(&s_info.skipped_event_data, item, sizeof(s_info.skipped_event_data));
-                               continue;
-                       }
-                       next_state = listener->state;
-                       break;
-               case EVENT_STATE_DEACTIVATED:
-               default:
-                       /* Remove this from the list */
-                       /* Check the item again. the listener can be deleted from the callback */
-                       if (eina_list_data_find(s_info.event_listener_list, listener)) {
-                               s_info.event_listener_list = eina_list_remove(s_info.event_listener_list, listener);
-                               DbgFree(listener);
-                       }
-
-                       continue;
-               }
-
-               if (invoke_event_cb(listener, item) == 1) {
-                       /**
-                        * @note
-                        * listener is deleted.
-                        */
-                       continue;
-               }
-
-               listener->prev_state = listener->state;
-               listener->state = next_state;
-       }
-
-       DbgFree(item);
-
-       return ECORE_CALLBACK_RENEW;
-}
-
-static int event_control_init(void)
-{
-       int status;
-       unsigned int clockId = CLOCK_MONOTONIC;
-
-       DbgPrint("Initializing event controller\n");
-       if (s_info.handle != -1) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       s_info.handle = open(WIDGET_CONF_INPUT_PATH, O_RDONLY);
-       if (s_info.handle < 0) {
-               ErrPrint("open: %d\n", errno);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       if (fcntl(s_info.handle, F_SETFD, FD_CLOEXEC) < 0) {
-               ErrPrint("fcntl: %d\n", errno);
-       }
-
-       if (fcntl(s_info.handle, F_SETFL, O_NONBLOCK) < 0) {
-               ErrPrint("fcntl: %d\n", errno);
-       }
-
-       if (WIDGET_CONF_USE_EVENT_TIME && !WIDGET_CONF_USE_GETTIMEOFDAY) {
-               DbgPrint("Change timestamp to monotonic\n");
-               if (ioctl(s_info.handle, EVIOCSCLOCKID, &clockId) < 0) {
-                       ErrPrint("ioctl: %d\n", errno);
-               }
-       }
-
-       status = pipe2(s_info.evt_pipe, O_CLOEXEC);
-       if (status < 0) {
-               ErrPrint("pipe2: %d\n", errno);
-               if (close(s_info.handle) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-               s_info.handle = -1;
-               return WIDGET_ERROR_FAULT;
-       }
-
-       status = pipe2(s_info.tcb_pipe, O_CLOEXEC);
-       if (status < 0) {
-               ErrPrint("pipe2: %d\n", errno);
-               if (close(s_info.handle) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-               s_info.handle = -1;
-               CLOSE_PIPE(s_info.evt_pipe);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-/*!
- * This function must has to be called after event collecting thread is terminated
- */
-static int event_control_fini(void)
-{
-       DbgPrint("Finalizing event controller\n");
-       if (s_info.handle != -1) {
-               if (close(s_info.handle) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-
-               s_info.handle = -1;
-       }
-
-       if (!eina_list_count(s_info.event_list)) {
-               if (s_info.event_handler) {
-                       ecore_main_fd_handler_del(s_info.event_handler);
-                       s_info.event_handler = NULL;
-               }
-               clear_all_listener_list();
-       }
-
-       CLOSE_PIPE(s_info.tcb_pipe);
-       CLOSE_PIPE(s_info.evt_pipe);
-
-       return WIDGET_ERROR_NONE;
-}
-
-int event_activate_thread(enum event_handler_activate_type activate_type)
-{
-       int ret;
-
-       ret = event_control_init();
-       if (ret != WIDGET_ERROR_NONE) {
-               return ret;
-       }
-
-       if (s_info.event_handler) {
-               ErrPrint("Event handler is already registered\n");
-               return WIDGET_ERROR_ALREADY_EXIST;
-       }
-
-       s_info.event_handler = ecore_main_fd_handler_add(s_info.evt_pipe[PIPE_READ], ECORE_FD_READ, event_read_cb, NULL, NULL, NULL);
-       if (!s_info.event_handler) {
-               ErrPrint("Failed to add monitor for EVT READ\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       ret = pthread_create(&s_info.tid, NULL, event_thread_main, NULL);
-       if (ret != 0) {
-               ErrPrint("pthread_create: %d\n", ret);
-               ecore_main_fd_handler_del(s_info.event_handler);
-               s_info.event_handler = NULL;
-               return WIDGET_ERROR_FAULT;
-       }
-
-       DbgPrint("Event handler activated\n");
-       s_info.event_handler_activated = activate_type;
-       return WIDGET_ERROR_NONE;
-}
-
-int event_deactivate_thread(enum event_handler_activate_type activate_type)
-{
-       int status;
-       void *ret;
-       char event_ch = EVENT_CH;
-
-       if (s_info.event_handler_activated != activate_type) {
-               ErrPrint("Event handler activate type is mismatched\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Terminating thread */
-       if (write(s_info.tcb_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
-               ErrPrint("write: %d\n", errno);
-       }
-
-       status = pthread_join(s_info.tid, &ret);
-       if (status != 0) {
-               ErrPrint("pthread_join: %d\n", status);
-       } else {
-               DbgPrint("Thread returns: %p\n", ret);
-       }
-
-       s_info.event_handler_activated = EVENT_HANDLER_DEACTIVATED;
-       return WIDGET_ERROR_NONE;
-}
-
-/*!
- * x, y is the starting point.
- */
-HAPI int event_activate(int slot, int x, int y, double ratio_w, double ratio_h, int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data)
-{
-       struct event_listener *listener;
-       int ret = WIDGET_ERROR_NONE;
-       Eina_List *l;
-
-       EINA_LIST_FOREACH(s_info.event_listener_list, l, listener) {
-               if (listener->event_cb == event_cb && listener->cbdata == data && listener->slot == slot) {
-                       ErrPrint("Already registered\n");
-                       return WIDGET_ERROR_ALREADY_EXIST;
-               }
-       }
-
-       listener = malloc(sizeof(*listener));
-       if (!listener) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       listener->tv = current_time_get() - DELAY_COMPENSATOR; // Let's use the previous event.
-       DbgPrint("Activated at: %lf (%dx%d)\n", listener->tv, x, y);
-
-       listener->event_cb = event_cb;
-       listener->cbdata = data;
-       listener->prev_state = EVENT_STATE_DEACTIVATED;
-       listener->state = EVENT_STATE_ACTIVATE;
-       listener->x = x;
-       listener->y = y;
-       listener->ratio_w = ratio_w;
-       listener->ratio_h = ratio_h;
-       listener->slot = slot;
-       listener->unset_done = 0;
-
-       if (s_info.event_handler_activated == EVENT_HANDLER_DEACTIVATED) {
-               /*!
-                * \note
-                * We don't need to lock to access event_list here.
-                * If the _sinfo.handle is greater than 0, the event_list will not be touched.
-                * But if the s_info.handle is less than 0, it means, there is no thread,
-                * so we can access the event_list without lock.
-                */
-               if (s_info.event_list) {
-                       DbgPrint("Event thread is deactivating now. activating will be delayed\n");
-                       s_info.reactivate_list = eina_list_append(s_info.reactivate_list, listener);
-               } else {
-                       s_info.event_listener_list = eina_list_append(s_info.event_listener_list, listener);
-
-                       if ((ret = event_activate_thread(EVENT_HANDLER_ACTIVATED_BY_MOUSE_SET)) < 0) {
-                               s_info.event_listener_list = eina_list_remove(s_info.event_listener_list, listener);
-                               DbgFree(listener);
-                       }
-               }
-       } else {
-               s_info.event_listener_list = eina_list_append(s_info.event_listener_list, listener);
-       }
-
-       return ret;
-}
-
-HAPI int event_input_fd(void)
-{
-       event_control_init();
-       DbgPrint("Input event handler: %d\n", s_info.handle);
-       return s_info.handle;
-}
-
-HAPI int event_deactivate(int slot, int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data)
-{
-       struct event_listener *listener = NULL;
-       struct event_listener *item;
-       Eina_List *l;
-       int keep_thread = 0;
-
-       EINA_LIST_FOREACH(s_info.event_listener_list, l, item) {
-               if (item->event_cb == event_cb && item->cbdata == data && (slot < 0 || item->slot == slot)) {
-                       switch (item->state) {
-                       case EVENT_STATE_ACTIVATE:
-                       case EVENT_STATE_ACTIVATED:
-                               item->prev_state = item->state;
-                               item->state = EVENT_STATE_DEACTIVATE;
-                               listener = item;
-                               break;
-                       default:
-                               /* Item is already deactivated */
-                               break;
-                       }
-               }
-
-               keep_thread += (item->state == EVENT_STATE_ACTIVATE || item->state == EVENT_STATE_ACTIVATED);
-       }
-
-       if (!listener) {
-               ErrPrint("Listener is not registered or already deactivated\n");
-               return WIDGET_ERROR_NOT_EXIST;
-       }
-
-       if (s_info.event_handler_activated == EVENT_HANDLER_DEACTIVATED) {
-               ErrPrint("Event handler is not actiavated\n");
-               s_info.event_listener_list = eina_list_remove(s_info.event_listener_list, listener);
-               DbgFree(listener);
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (keep_thread) {
-               DbgPrint("Keep thread\n");
-               listener->unset_done = 1;
-
-               /**
-                * @note
-                * This will invoke the event_read_cb callback with fake event data.
-                * At that time we should terminate this listener.
-                */
-               push_event_item();
-               return WIDGET_ERROR_NONE;
-       }
-
-       event_deactivate_thread(EVENT_HANDLER_ACTIVATED_BY_MOUSE_SET);
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int event_reset_cbdata(int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data, void *new_data)
-{
-       struct event_listener *item;
-       Eina_List *l;
-       int updated = 0;
-
-       EINA_LIST_FOREACH(s_info.event_listener_list, l, item) {
-               if (item->event_cb == event_cb && item->cbdata == data) {
-                       item->cbdata = new_data;
-                       updated++;
-               }
-       }
-
-       EINA_LIST_FOREACH(s_info.reactivate_list, l, item) {
-               if (item->event_cb == event_cb && item->cbdata == data) {
-                       item->cbdata = new_data;
-                       updated++;
-               }
-       }
-
-       return updated;
-}
-
-HAPI int event_is_activated(void)
-{
-       return s_info.handle >= 0;
-}
-
-HAPI void event_set_mouse_xy(int slot, int x, int y, double ratio_w, double ratio_h, double timestamp)
-{
-       s_info.event_data.x = x;
-       s_info.event_data.y = y;
-       s_info.event_data.ratio_w = ratio_w;
-       s_info.event_data.ratio_h = ratio_h;
-       s_info.event_data.tv = timestamp;
-       s_info.event_data.source = INPUT_EVENT_SOURCE_VIEWER;
-       s_info.event_data.slot = slot;
-       /**
-        * Don't touch the timestamp_updated variable.
-        * if we toggle it, the input thread will not be terminated correctly. SEE LINE: 537
-       if (!s_info.timestamp_updated) {
-               // NOP
-       }
-        */
-}
-
-/* End of a file */
diff --git a/src/fault_manager.c b/src/fault_manager.c
deleted file mode 100644 (file)
index 1728ff6..0000000
+++ /dev/null
@@ -1,377 +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 <string.h>
-#include <stdlib.h> /* free */
-
-#include <gio/gio.h>
-
-#include <Eina.h>
-#include <packet.h>
-#include <dlog.h>
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_conf.h>
-#include <widget_cmd_list.h>
-
-#include "util.h"
-#include "debug.h"
-#include "slave_life.h"
-#include "slave_rpc.h"
-#include "client_life.h"
-#include "instance.h"
-#include "client_rpc.h"
-#include "package.h"
-#include "conf.h"
-#include "critical_log.h"
-
-static struct info {
-       Eina_List *call_list;
-       int fault_mark_count;
-} s_info = {
-       .call_list = NULL,
-       .fault_mark_count = 0,
-};
-
-struct fault_info {
-       struct slave_node *slave;
-       double timestamp;
-       char *pkgname;
-       char *filename;
-       char *func;
-};
-
-HAPI int const fault_is_occured(void)
-{
-       return s_info.fault_mark_count;
-}
-
-static void clear_log_file(struct slave_node *slave)
-{
-       char filename[BUFSIZ];
-       int ret;
-
-       ret = snprintf(filename, sizeof(filename) - 1, "%s/slave.%d", WIDGET_CONF_LOG_PATH, slave_pid(slave));
-       if (ret == sizeof(filename) - 1) {
-               filename[sizeof(filename) - 1] = '\0';
-               ErrPrint("filename buffer is overflowed\n");
-       }
-
-       if (unlink(filename) < 0) {
-               ErrPrint("unlink: %d\n", errno);
-       }
-}
-
-static char *check_log_file(struct slave_node *slave)
-{
-       char libexec[BUFSIZ];
-       char *ptr;
-       FILE *fp;
-       char filename[BUFSIZ];
-
-       snprintf(filename, sizeof(filename), "%s/slave.%d", WIDGET_CONF_LOG_PATH, slave_pid(slave));
-       fp = fopen(filename, "rt");
-       if (!fp) {
-               ErrPrint("fopen [%d]\n", errno);
-               return NULL;
-       }
-
-       ptr = fgets(libexec, sizeof(libexec), fp);
-       if (fclose(fp) != 0) {
-               ErrPrint("fclose: %d\n", errno);
-       }
-
-       if (ptr != libexec) {
-               ErrPrint("Invalid log\n");
-               return NULL;
-       }
-
-       if (unlink(filename) < 0) {
-               ErrPrint("Failed to unlink %s\n", filename);
-       }
-
-       ptr = widget_service_get_widget_id_by_libexec(libexec);
-       if (!ptr) {
-               ErrPrint("Failed to find the faulted package\n");
-       }
-
-       DbgPrint("Faulted package: %s\n", ptr);
-       return ptr;
-}
-
-HAPI void fault_unicast_info(struct client_node *client, const char *pkgname, const char *filename, const char *func)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_FAULT_PACKAGE;
-
-       if (!client || !pkgname || !filename || !func) {
-               return;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "sss", pkgname, filename, func);
-       if (!packet) {
-               return;
-       }
-
-       client_rpc_async_request(client, packet);
-}
-
-HAPI void fault_broadcast_info(const char *pkgname, const char *filename, const char *func)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_FAULT_PACKAGE;
-
-       packet = packet_create_noack((const char *)&cmd, "sss", pkgname, filename, func);
-       if (!packet) {
-               ErrPrint("Failed to create a param\n");
-               return;
-       }
-
-       client_broadcast(NULL, packet);
-}
-
-static inline void dump_fault_info(const char *name, pid_t pid, const char *pkgname, const char *filename, const char *funcname)
-{
-       CRITICAL_LOG("Slavename: %s[%d]\n"      \
-                       "Package: %s\n"         \
-                       "Filename: %s\n"        \
-                       "Funcname: %s\n", name, pid, pkgname, filename, funcname);
-}
-
-HAPI int fault_info_set(struct slave_node *slave, const char *pkgname, const char *id, const char *func)
-{
-       struct pkg_info *pkg;
-       int ret;
-
-       pkg = package_find(pkgname);
-       if (!pkg) {
-               return WIDGET_ERROR_NOT_EXIST;
-       }
-
-       ret = package_set_fault_info(pkg, util_timestamp(), id, func);
-       if (ret < 0) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       dump_fault_info(slave_name(slave), slave_pid(slave), pkgname, id, func);
-       ErrPrint("Set fault %s(%d)\n", !ret ? "Success" : "Failed", ret);
-       fault_broadcast_info(pkgname, id, func);
-
-       /*!
-        * \note
-        * Update statistics
-        */
-       s_info.fault_mark_count++;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int fault_check_pkgs(struct slave_node *slave)
-{
-       struct fault_info *info;
-       struct pkg_info *pkg;
-       const char *pkgname;
-       Eina_List *l;
-       Eina_List *n;
-       int checked;
-
-       /*!
-        * \note
-        * First step.
-        * Check the log file
-        */
-       pkgname = (const char *)check_log_file(slave);
-       if (pkgname) {
-               pkg = package_find(pkgname);
-               if (pkg) {
-                       if (package_set_fault_info(pkg, util_timestamp(), NULL, NULL) != WIDGET_ERROR_CANCELED) {
-                               dump_fault_info(slave_name(slave), slave_pid(slave), pkgname, "", "");
-                               fault_broadcast_info(pkgname, "", "");
-                       }
-                       DbgFree((char *)pkgname);
-
-                       s_info.fault_mark_count = 0;
-                       clear_log_file(slave);
-                       EINA_LIST_REVERSE_FOREACH_SAFE(s_info.call_list, l, n, info) {
-                               if (info->slave != slave) {
-                                       continue;
-                               }
-
-                               s_info.call_list = eina_list_remove_list(s_info.call_list, l);
-
-                               DbgFree(info->pkgname);
-                               DbgFree(info->filename);
-                               DbgFree(info->func);
-                               DbgFree(info);
-                       }
-                       return 0;
-               }
-               DbgFree((char *)pkgname);
-       }
-
-       /*!
-        * \note
-        * Second step.
-        * Is it secured slave?
-        */
-       pkgname = package_find_by_secured_slave(slave);
-       if (pkgname) {
-               pkg = package_find(pkgname);
-               if (pkg) {
-                       if (package_set_fault_info(pkg, util_timestamp(), NULL, NULL) != WIDGET_ERROR_CANCELED) {
-                               dump_fault_info(slave_name(slave), slave_pid(slave), pkgname, "", "");
-                               fault_broadcast_info(pkgname, "", "");
-                       }
-
-                       s_info.fault_mark_count = 0;
-                       clear_log_file(slave);
-                       EINA_LIST_REVERSE_FOREACH_SAFE(s_info.call_list, l, n, info) {
-                               if (info->slave != slave) {
-                                       continue;
-                               }
-
-                               s_info.call_list = eina_list_remove_list(s_info.call_list, l);
-
-                               DbgFree(info->pkgname);
-                               DbgFree(info->filename);
-                               DbgFree(info->func);
-                               DbgFree(info);
-                       }
-
-                       return 0;
-               }
-       }
-
-       /*!
-        * \note
-        * At last, check the pair of function call and return mark
-        */
-       checked = 0;
-       EINA_LIST_REVERSE_FOREACH_SAFE(s_info.call_list, l, n, info) {
-               if (info->slave == slave) {
-                       const char *filename;
-                       const char *func;
-
-                       pkg = package_find(info->pkgname);
-                       if (!pkg) {
-                               ErrPrint("Failed to find a package %s\n", info->pkgname);
-                               continue;
-                       }
-
-                       filename = info->filename ? info->filename : "";
-                       func = info->func ? info->func : "";
-
-                       if (!checked) {
-                               if (package_set_fault_info(pkg, info->timestamp, info->filename, info->func) != WIDGET_ERROR_CANCELED) {
-                                       fault_broadcast_info(info->pkgname, info->filename, info->func);
-                               }
-                       } else {
-                               DbgPrint("Treated as a false log\n");
-                               dump_fault_info(slave_name(info->slave), slave_pid(info->slave), info->pkgname, filename, func);
-                       }
-
-                       s_info.call_list = eina_list_remove_list(s_info.call_list, l);
-
-                       DbgFree(info->pkgname);
-                       DbgFree(info->filename);
-                       DbgFree(info->func);
-                       DbgFree(info);
-                       checked = 1;
-               }
-       }
-
-       s_info.fault_mark_count = 0;
-       clear_log_file(slave);
-       return 0;
-}
-
-HAPI int fault_func_call(struct slave_node *slave, const char *pkgname, const char *filename, const char *func)
-{
-       struct fault_info *info;
-
-       info = malloc(sizeof(*info));
-       if (!info) {
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       info->slave = slave;
-
-       info->pkgname = strdup(pkgname);
-       if (!info->pkgname) {
-               DbgFree(info);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       info->filename = strdup(filename);
-       if (!info->filename) {
-               DbgFree(info->pkgname);
-               DbgFree(info);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       info->func = strdup(func);
-       if (!info->func) {
-               DbgFree(info->filename);
-               DbgFree(info->pkgname);
-               DbgFree(info);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       info->timestamp = util_timestamp();
-
-       s_info.call_list = eina_list_append(s_info.call_list, info);
-
-       s_info.fault_mark_count++;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int fault_func_ret(struct slave_node *slave, const char *pkgname, const char *filename, const char *func)
-{
-       struct fault_info *info;
-       Eina_List *l;
-
-       EINA_LIST_FOREACH(s_info.call_list, l, info) {
-               if (info->slave != slave) {
-                       continue;
-               }
-
-               if (strcmp(info->pkgname, pkgname)) {
-                       continue;
-               }
-
-               if (strcmp(info->filename, filename)) {
-                       continue;
-               }
-
-               if (strcmp(info->func, func)) {
-                       continue;
-               }
-
-               s_info.call_list = eina_list_remove_list(s_info.call_list, l);
-               DbgFree(info->filename);
-               DbgFree(info->pkgname);
-               DbgFree(info->func);
-               DbgFree(info);
-
-               s_info.fault_mark_count--;
-               return 0;
-       } 
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-/* End of a file */
diff --git a/src/file_service.c b/src/file_service.c
deleted file mode 100644 (file)
index e76adc3..0000000
+++ /dev/null
@@ -1,718 +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 <pthread.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <Eina.h>
-
-#include <dlog.h>
-
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <packet.h>
-#include <com-core.h>
-
-#include "file_service.h"
-#include "service_common.h"
-#include "debug.h"
-#include "util.h"
-#include "conf.h"
-#include "buffer_handler.h"
-
-#define FILE_SERVICE_ADDR      "remote://:8209"
-
-#define PUSH_EXIT      'e'
-#define PUSH_ITEM      'i'
-
-#define PKT_CHUNKSZ    4096
-
-static struct info {
-       struct service_context *svc_ctx;
-
-       pthread_t push_thid;
-
-       Eina_List *request_list;
-       pthread_mutex_t request_list_lock;
-
-       int request_pipe[PIPE_MAX];
-} s_info = {
-       .svc_ctx = NULL,
-       .request_list = NULL,
-       .request_list_lock = PTHREAD_MUTEX_INITIALIZER,
-       .request_pipe = { 0, },
-};
-
-struct request_item {
-       enum {
-               REQUEST_TYPE_FILE = 0x00,
-               REQUEST_TYPE_SHM = 0x01,
-               REQUEST_TYPE_PIXMAP = 0x02,
-               REQUEST_TYPE_MAX = 0x02,
-       } type;
-       union {
-               char *filename;
-               int shm;
-               unsigned int pixmap;
-       } data;
-       struct tcb *tcb;
-};
-
-typedef int (*send_data_func_t)(int fd, const struct request_item *item);
-
-/*!
- * 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 struct request_item *create_request_item(struct tcb *tcb, int type, void *data)
-{
-       struct request_item *item;
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               ErrPrint("malloc: %d\n", errno);
-               return NULL;
-       }
-
-       switch (type) {
-       case REQUEST_TYPE_FILE:
-               item->data.filename = strdup(data);
-               if (!item->data.filename) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(item);
-                       return NULL;
-               }
-               break;
-       case REQUEST_TYPE_PIXMAP:
-               item->data.pixmap = (unsigned int)((long)data);
-               break;
-       case REQUEST_TYPE_SHM:
-               item->data.shm = (int)((long)data);
-               break;
-       default:
-               ErrPrint("Invalid type of request\n");
-               DbgFree(item);
-               return NULL;
-       }
-
-       item->type = type;
-       item->tcb = tcb;
-       return item;
-}
-
-static inline int destroy_request_item(struct request_item *item)
-{
-       switch (item->type) {
-       case REQUEST_TYPE_FILE:
-               DbgFree(item->data.filename);
-               break;
-       case REQUEST_TYPE_SHM:
-       case REQUEST_TYPE_PIXMAP:
-               break;
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       DbgFree(item);
-       return WIDGET_ERROR_NONE;
-}
-
-static int request_file_handler(struct tcb *tcb, struct packet *packet, struct request_item **item)
-{
-       const char *filename;
-
-       if (packet_get(packet, "s", &filename) != 1) {
-               ErrPrint("Invalid packet\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       *item = create_request_item(tcb, REQUEST_TYPE_FILE, (void *)filename);
-       return *item ? WIDGET_ERROR_NONE : WIDGET_ERROR_OUT_OF_MEMORY;
-}
-
-static int request_pixmap_handler(struct tcb *tcb, struct packet *packet, struct request_item **item)
-{
-       unsigned long pixmap;
-
-       if (packet_get(packet, "i", &pixmap) != 1) {
-               ErrPrint("Invalid packet\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (pixmap == 0) {
-               ErrPrint("pixmap is not valid\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       /*!
-        * \TODO
-        * Attach to pixmap and copy its data to the client
-        */
-       *item = create_request_item(tcb, REQUEST_TYPE_PIXMAP, (void *)pixmap);
-       return *item ? WIDGET_ERROR_NONE : WIDGET_ERROR_OUT_OF_MEMORY;
-}
-
-static int request_shm_handler(struct tcb *tcb, struct packet *packet, struct request_item **item)
-{
-       int shm;
-
-       if (packet_get(packet, "i", &shm) != 1) {
-               ErrPrint("Invalid packet\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (shm < 0) {
-               ErrPrint("shm is not valid: %d\n", shm);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       /*!
-        * \TODO
-        * Attach to SHM and copy its buffer to the client
-        */
-       *item = create_request_item(tcb, REQUEST_TYPE_SHM, (void *)((long)shm));
-       return *item ? WIDGET_ERROR_NONE : WIDGET_ERROR_OUT_OF_MEMORY;
-}
-
-/* SERVER THREAD */
-static int service_thread_main(struct tcb *tcb, struct packet *packet, void *data)
-{
-       const char *cmd;
-       char ch = PUSH_ITEM;
-       int ret;
-       int i;
-       struct request_item *item;
-       struct packet *reply;
-       struct {
-               const char *cmd;
-               int (*request_handler)(struct tcb *tcb, struct packet *packet, struct request_item **item);
-       } cmd_table[] = {
-               {
-                       .cmd = "request,file",
-                       .request_handler = request_file_handler,
-               },
-               {
-                       .cmd = "request,pixmap",
-                       .request_handler = request_pixmap_handler,
-               },
-               {
-                       .cmd = "request,shm",
-                       .request_handler = request_shm_handler,
-               },
-               {
-                       .cmd = NULL,
-                       .request_handler = NULL,
-               },
-       };
-
-       if (!packet) {
-               DbgPrint("TCB %p is disconnected\n", tcb);
-               return WIDGET_ERROR_NONE;
-       }
-
-       cmd = packet_command(packet);
-       if (!cmd) {
-               ErrPrint("Invalid packet. cmd is not valid\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (packet_type(packet)) {
-       case PACKET_REQ:
-               for (i = 0; cmd_table[i].cmd; i++) {
-                       /*!
-                        * Protocol sequence
-                        * FILE REQUEST COMMAND (Client -> Server)
-                        * REPLY FOR REQUEST (Client <- Server)
-                        * PUSH FILE (Client <- Server)
-                        *
-                        * Client & Server must has to keep this communication sequence.
-                        */
-                       if (strcmp(cmd, cmd_table[i].cmd)) {
-                               continue;
-                       }
-
-                       item = NULL;
-                       ret = cmd_table[i].request_handler(tcb, packet, &item);
-
-                       reply = packet_create_reply(packet, "i", ret);
-                       if (!reply) {
-                               ErrPrint("Failed to create a reply packet\n");
-                               break;
-                       }
-
-                       if (service_common_unicast_packet(tcb, reply) < 0) {
-                               ErrPrint("Unable to send reply packet\n");
-                       }
-
-                       packet_destroy(reply);
-
-                       /*!
-                        * \note
-                        * After send the reply packet, file push thread can sending a file
-                        */
-                       if (ret != WIDGET_ERROR_NONE || !item) {
-                               break;
-                       }
-
-                       CRITICAL_SECTION_BEGIN(&s_info.request_list_lock);
-                       s_info.request_list = eina_list_append(s_info.request_list, item);
-                       CRITICAL_SECTION_END(&s_info.request_list_lock);
-
-                       ret = write(s_info.request_pipe[PIPE_WRITE], &ch, sizeof(ch));
-                       if (ret < 0) {
-                               ErrPrint("write: %d\n", errno);
-
-                               CRITICAL_SECTION_BEGIN(&s_info.request_list_lock);
-                               s_info.request_list = eina_list_remove(s_info.request_list, item);
-                               CRITICAL_SECTION_END(&s_info.request_list_lock);
-
-                               destroy_request_item(item);
-                               /*!
-                                * \note for the client
-                                * In this case, the client can waiting files forever.
-                                * So the client must has to wait only a few seconds.
-                                * If the client could not get the any data in that time,
-                                * it should cancel the waiting.
-                                */
-                       }
-               }
-
-               break;
-       case PACKET_REQ_NOACK:
-       case PACKET_ACK:
-               /* File service has no this case, it is passive service type */
-               ErrPrint("Invalid packet.\n");
-               break;
-       default:
-               break;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static int send_file(int handle, const struct request_item *item)
-{
-       struct burst_head *head;
-       struct burst_data *body;
-       int pktsz;
-       int flen;
-       off_t fsize;
-       int fd;
-       int ret = 0;
-
-       /* TODO: push a file to the client */
-       fd = open(item->data.filename, O_RDONLY);
-       if (fd < 0) {
-               ErrPrint("open: %d\n", errno);
-               return -EIO;
-       }
-
-       flen = strlen(item->data.filename);
-       if (flen == 0) {
-               ret = -EINVAL;
-               goto errout;
-       }
-
-       pktsz = sizeof(*head) + flen + 1;
-
-       head = malloc(pktsz);
-       if (!head) {
-               ErrPrint("malloc: %d\n", errno);
-               ret = -ENOMEM;
-               goto errout;
-       }
-
-       fsize = lseek(fd, 0L, SEEK_END);
-       if (fsize == (off_t)-1) {
-               ErrPrint("lseek: %d\n", errno);
-               DbgFree(head);
-               ret = -EIO;
-               goto errout;
-       }
-
-       head->flen = flen;
-       head->size = fsize;
-       strcpy(head->fname, item->data.filename);
-
-       /* Anytime we can fail to send packet */
-       ret = com_core_send(handle, (void *)head, pktsz, 2.0f);
-       DbgFree(head);
-       if (ret < 0) {
-               ret = -EFAULT;
-               goto errout;
-       }
-
-       if (lseek(fd, 0L, SEEK_SET) == (off_t)-1) {
-               ErrPrint("lseek: %s\n", errno);
-
-               body = malloc(sizeof(*body));
-               if (!body) {
-                       ErrPrint("malloc: %d\n", errno);
-                       ret = -ENOMEM;
-                       goto errout;
-               }
-
-               body->size = -1;
-               ret = com_core_send(handle, (void *)body, sizeof(*body), 2.0f);
-               DbgFree(body);
-
-               if (ret < 0) {
-                       ret = -EFAULT;
-               } else {
-                       ret = -EIO;
-               }
-
-               goto errout;
-       }
-
-       body = malloc(PKT_CHUNKSZ + sizeof(*body));
-       if (!body) {
-               ErrPrint("malloc: %d\n", errno);
-               goto errout;
-       }
-
-       /* Burst pushing. */
-       while (fsize > 0) {
-               if (fsize > PKT_CHUNKSZ) {
-                       body->size = PKT_CHUNKSZ;
-               } else {
-                       body->size = fsize;
-               }
-
-               ret = read(fd, body->data, body->size); 
-               if (ret < 0) {
-                       ErrPrint("read: %d\n", errno);
-                       break;
-               }
-
-               body->size = ret;
-               fsize -= ret;
-               pktsz = sizeof(*body) + body->size;
-
-               /* Send BODY */
-               ret = com_core_send(handle, (void *)body, pktsz, 2.0f);
-               if (ret != pktsz) {
-                       break;
-               }
-       }
-
-       /* Send EOF */
-       body->size = -1;
-       ret = com_core_send(handle, (void *)body, sizeof(*body), 2.0f);
-       if (ret < 0) {
-               ret = -EFAULT;
-       }
-
-       DbgFree(body);
-
-errout:
-       if (close(fd) < 0) {
-               ErrPrint("close: %d\n", errno);
-       }
-
-       return ret;
-}
-
-static int send_buffer(int handle, const struct request_item *item)
-{
-       widget_fb_t buffer;
-       struct burst_head *head;
-       struct burst_data *body;
-       char *data;
-       int pktsz;
-       int ret;
-       int size;
-       int offset;
-       int type;
-
-       if (item->type == REQUEST_TYPE_SHM) {
-               type = WIDGET_FB_TYPE_SHM;
-       } else {
-               type = WIDGET_FB_TYPE_PIXMAP;
-       }
-
-       buffer = buffer_handler_raw_open(type, (void *)(long)item->data.shm);
-       if (!buffer) {
-               return -EINVAL;
-       }
-
-       pktsz = sizeof(*head);
-
-       head = malloc(pktsz);
-       if (!head) {
-               ErrPrint("malloc: %d\n", errno);
-               (void)buffer_handler_raw_close(buffer);
-               return -ENOMEM;
-       }
-
-       size = head->size = buffer_handler_raw_size(buffer);
-       head->flen = 0;
-
-       /* Anytime we can fail to send packet */
-       ret = com_core_send(handle, (void *)head, pktsz, 2.0f);
-       DbgFree(head);
-       if (ret < 0) {
-               ret = -EFAULT;
-               goto errout;
-       }
-
-       body = malloc(sizeof(*body) + PKT_CHUNKSZ);
-       if (!body) {
-               ret = -ENOMEM;
-               goto errout;
-       }
-
-       data = (char *)buffer_handler_raw_data(buffer);
-       offset = 0;
-       while (offset < size) {
-               body->size = size - offset;
-
-               if (body->size > PKT_CHUNKSZ) {
-                       body->size = PKT_CHUNKSZ;
-               }
-
-               memcpy(body->data, data, body->size);
-               pktsz = sizeof(*body) + body->size;
-
-               ret = com_core_send(handle, (void *)body, pktsz, 2.0f);
-               if (ret < 0) {
-                       ret = -EFAULT;
-                       break;
-               }
-
-               offset += body->size;
-       }
-
-       DbgFree(body);
-
-errout:
-       (void)buffer_handler_raw_close(buffer);
-       return ret;
-}
-
-static void *push_main(void *data)
-{
-       fd_set set;
-       int ret;
-       char ch;
-       struct request_item *item;
-       int conn_fd;
-       send_data_func_t send_data[] = {
-               send_file,
-               send_buffer,
-               send_buffer,
-       };
-
-       while (1) {
-               FD_ZERO(&set);
-               FD_SET(s_info.request_pipe[PIPE_READ], &set);
-
-               ret = select(s_info.request_pipe[PIPE_READ] + 1, &set, NULL, NULL, NULL);
-               if (ret < 0) {
-                       ret = -errno;
-                       if (errno == EINTR) {
-                               ErrPrint("INTERRUPTED\n");
-                               ret = 0;
-                               continue;
-                       }
-                       ErrPrint("select: %d\n", errno);
-                       break;
-               } else if (ret == 0) {
-                       ErrPrint("Timeout\n");
-                       ret = -ETIMEDOUT;
-                       break;
-               }
-
-               if (!FD_ISSET(s_info.request_pipe[PIPE_READ], &set)) {
-                       DbgPrint("Unknown data\n");
-                       ret = -EINVAL;
-                       break;
-               }
-
-               ret = read(s_info.request_pipe[PIPE_READ], &ch, sizeof(ch));
-               if (ret != sizeof(ch)) {
-                       ErrPrint("read: %d\n", errno);
-                       ret = -EFAULT;
-                       break;
-               }
-
-               if (ch == PUSH_EXIT) {
-                       DbgPrint("Thread is terminating\n");
-                       ret = -ECANCELED;
-                       break;
-               }
-
-               CRITICAL_SECTION_BEGIN(&s_info.request_list_lock);
-               item = eina_list_nth(s_info.request_list, 0);
-               s_info.request_list = eina_list_remove(s_info.request_list, item);
-               CRITICAL_SECTION_END(&s_info.request_list_lock);
-
-               if (!item) {
-                       ErrPrint("Request item is not valid\n");
-                       continue;
-               }
-
-               /* Validate the TCB? */
-               conn_fd = tcb_is_valid(s_info.svc_ctx, item->tcb);
-               if (conn_fd < 0) {
-                       ErrPrint("TCB is not valid\n");
-                       destroy_request_item(item);
-                       continue;
-               }
-
-               /*
-                * \note
-                * From now, we cannot believe the conn_fd.
-                * It can be closed any time.
-                * Even though we using it.
-                */
-               if (item->type < REQUEST_TYPE_MAX && item->type >= 0) {
-                       (void)send_data[item->type](conn_fd, item);
-               } else {
-                       ErrPrint("Invalid type\n");
-               }
-
-               destroy_request_item(item);
-       }
-
-       return (void *)((long)ret);
-}
-
-/* MAIN THREAD */
-int file_service_init(void)
-{
-       int status;
-
-       if (s_info.svc_ctx) {
-               ErrPrint("Already initialized\n");
-               return WIDGET_ERROR_ALREADY_STARTED;
-       }
-
-       if (pipe2(s_info.request_pipe, O_CLOEXEC) < 0) {
-               ErrPrint("pipe: %d\n", errno);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       status = pthread_mutex_init(&s_info.request_list_lock, NULL);
-       if (status != 0) {
-               ErrPrint("Failed to create lock: %d\n", status);
-               CLOSE_PIPE(s_info.request_pipe);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       s_info.svc_ctx = service_common_create(FILE_SERVICE_ADDR, NULL, service_thread_main, NULL);
-       if (!s_info.svc_ctx) {
-               ErrPrint("Unable to activate service thread\n");
-
-               status = pthread_mutex_destroy(&s_info.request_list_lock);
-               if (status != 0) {
-                       ErrPrint("Destroy lock: %d\n", status);
-               }
-
-               CLOSE_PIPE(s_info.request_pipe);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       status = pthread_create(&s_info.push_thid, NULL, push_main, NULL);
-       if (status != 0) {
-               ErrPrint("Failed to create a push service: %d\n", status);
-
-               service_common_destroy(s_info.svc_ctx);
-               s_info.svc_ctx = NULL;
-
-               status = pthread_mutex_destroy(&s_info.request_list_lock);
-               if (status != 0) {
-                       ErrPrint("Destroy lock: %d\n", status);
-               }
-
-               CLOSE_PIPE(s_info.request_pipe);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       /*!
-        * \note
-        * Remote service doesn't need to set the additional SMAK label.
-        */
-
-       DbgPrint("Successfully initiated\n");
-       return WIDGET_ERROR_NONE;
-}
-
-/* MAIN THREAD */
-int file_service_fini(void)
-{
-       struct request_item *item;
-       int status;
-       char ch;
-       void *retval;
-
-       if (!s_info.svc_ctx) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ch = PUSH_EXIT;
-       status = write(s_info.request_pipe[PIPE_WRITE], &ch, sizeof(ch));
-       if (status != sizeof(ch)) {
-               ErrPrint("write: %d\n", errno);
-               /* Forcely terminate the thread */
-               status = pthread_cancel(s_info.push_thid);
-               if (status != 0) {
-                       ErrPrint("cancel: %d\n", status);
-               }
-       }
-
-       status = pthread_join(s_info.push_thid, &retval);
-       if (status != 0) {
-               ErrPrint("join: %d\n", status);
-       }
-
-       CRITICAL_SECTION_BEGIN(&s_info.request_list_lock);
-       EINA_LIST_FREE(s_info.request_list, item) {
-               destroy_request_item(item);
-       }
-       CRITICAL_SECTION_END(&s_info.request_list_lock);
-
-       service_common_destroy(s_info.svc_ctx);
-       s_info.svc_ctx = NULL;
-
-       status = pthread_mutex_destroy(&s_info.request_list_lock);
-       if (status != 0) {
-               ErrPrint("destroy mutex: %d\n", status);
-       }
-
-       CLOSE_PIPE(s_info.request_pipe);
-
-       DbgPrint("Successfully Finalized\n");
-       return WIDGET_ERROR_NONE;
-}
-
-/* End of a file */
diff --git a/src/group.c b/src/group.c
deleted file mode 100644 (file)
index 76b99e6..0000000
+++ /dev/null
@@ -1,889 +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 <ctype.h>
-#include <stdlib.h> /* malloc */
-#include <errno.h>
-#include <string.h> /* strdup */
-
-#include <dlog.h>
-#include <Eina.h>
-#include <widget_errno.h>
-
-#include "util.h"
-#include "debug.h"
-#include "group.h"
-#include "conf.h"
-
-int errno;
-
-static struct info {
-       Eina_List *cluster_list;
-} s_info = {
-       .cluster_list = NULL,
-};
-
-struct cluster {
-       char *name;
-       Eina_List *category_list;
-};
-
-struct category {
-       char *name;
-       struct cluster *cluster;
-       Eina_List *info_list; /* list of instances of the struct inst_info */
-};
-
-struct context_info {
-       char *pkgname;
-       struct category *category;
-       Eina_List *context_list; /* context item list */
-};
-
-struct context_item_data {
-       char *tag;
-       void *data;
-};
-
-struct context_item {
-       char *ctx_item;
-       struct context_info *info;
-       Eina_List *option_list;
-       Eina_List *data_list;
-};
-
-struct context_option {
-       struct context_item *item;
-       char *key;
-       char *value;
-};
-
-HAPI struct context_info *group_create_context_info(struct category *category, const char *pkgname)
-{
-       struct context_info *info;
-
-       info = calloc(1, sizeof(*info));
-       if (!info) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       info->pkgname = strdup(pkgname);
-       if (!info->pkgname) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(info);
-               return NULL;
-       }
-
-       info->category = category;
-       category->info_list = eina_list_append(category->info_list, info);
-       return info;
-}
-
-static inline void del_options(struct context_item *item)
-{
-       struct context_option *option;
-
-       EINA_LIST_FREE(item->option_list, option) {
-               DbgFree(option->key);
-               DbgFree(option->value);
-               DbgFree(option);
-       }
-}
-
-static inline void del_context_item(struct context_info *info)
-{
-       struct context_item *item;
-
-       EINA_LIST_FREE(info->context_list, item) {
-               del_options(item);
-               DbgFree(item->ctx_item);
-               DbgFree(item);
-       }
-}
-
-HAPI struct context_item *group_add_context_item(struct context_info *info, const char *ctx_item)
-{
-       struct context_item *item;
-
-       item = calloc(1, sizeof(*item));
-       if (!item) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       item->ctx_item = strdup(ctx_item);
-       if (!item->ctx_item) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(item);
-               return NULL;
-       }
-
-       item->info = info;
-       info->context_list = eina_list_append(info->context_list, item);
-       return item;
-}
-
-HAPI int group_add_option(struct context_item *item, const char *key, const char *value)
-{
-       struct context_option *option;
-
-       option = calloc(1, sizeof(*option));
-       if (!option) {
-               ErrPrint("calloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       option->key = strdup(key);
-       if (!option->key) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(option);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       option->value = strdup(value);
-       if (!option->value) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(option->key);
-               DbgFree(option);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       option->item = item;
-       item->option_list = eina_list_append(item->option_list, option);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int group_destroy_context_info(struct context_info *info)
-{
-       struct category *category;
-
-       category = info->category;
-       if (!category) {
-               ErrPrint("No category found\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       category->info_list = eina_list_remove(category->info_list, info);
-
-       del_context_item(info);
-       DbgFree(info->pkgname);
-       DbgFree(info);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI struct cluster *group_create_cluster(const char *name)
-{
-       struct cluster *cluster;
-
-       cluster = malloc(sizeof(*cluster));
-       if (!cluster) {
-               ErrPrint("malloc: %d\n", errno);
-               return NULL;
-       }
-
-       cluster->name = strdup(name);
-       if (!cluster->name) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(cluster);
-               return NULL;
-       }
-
-       cluster->category_list = NULL;
-
-       s_info.cluster_list = eina_list_append(s_info.cluster_list, cluster);
-       return cluster;
-}
-
-HAPI struct cluster *group_find_cluster(const char *name)
-{
-       Eina_List *l;
-       struct cluster *cluster;
-
-       EINA_LIST_FOREACH(s_info.cluster_list, l, cluster) {
-               if (!strcasecmp(cluster->name, name)) {
-                       return cluster;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI struct category *group_create_category(struct cluster *cluster, const char *name)
-{
-       struct category *category;
-
-       category = malloc(sizeof(*category));
-       if (!category) {
-               ErrPrint("malloc: %d\n", errno);
-               return NULL;
-       }
-
-       category->name = strdup(name);
-       if (!category->name) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(category);
-               return NULL;
-       }
-
-       category->cluster = cluster;
-       category->info_list = NULL;
-
-       cluster->category_list = eina_list_append(cluster->category_list, category);
-       return category;
-}
-
-static inline void destroy_cluster(struct cluster *cluster)
-{
-       struct category *category;
-       Eina_List *l;
-       Eina_List *n;
-
-       EINA_LIST_FOREACH_SAFE(cluster->category_list, l, n, category) {
-               group_destroy_category(category);
-       }
-
-       DbgFree(cluster->name);
-       DbgFree(cluster);
-}
-
-HAPI int group_destroy_cluster(struct cluster *cluster)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct cluster *item;
-
-       EINA_LIST_FOREACH_SAFE(s_info.cluster_list, l, n, item) {
-               if (item == cluster) {
-                       s_info.cluster_list = eina_list_remove_list(s_info.cluster_list, l);
-                       destroy_cluster(cluster);
-                       return WIDGET_ERROR_NONE;
-               }
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-static inline void destroy_category(struct category *category)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct context_info *info;
-
-       EINA_LIST_FOREACH_SAFE(category->info_list, l, n, info) {
-               group_destroy_context_info(info);
-       }
-
-       DbgFree(category->name);
-       DbgFree(category);
-}
-
-HAPI int group_destroy_category(struct category *category)
-{
-       struct cluster *cluster;
-
-       cluster = category->cluster;
-       if (cluster) {
-               cluster->category_list = eina_list_remove(cluster->category_list, category);
-       }
-
-       destroy_category(category);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI struct category *group_find_category(struct cluster *cluster, const char *name)
-{
-       struct category *category;
-       Eina_List *l;
-
-       EINA_LIST_FOREACH(cluster->category_list, l, category) {
-               if (!strcasecmp(category->name, name)) {
-                       return category;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI Eina_List * const group_context_info_list(struct category *category)
-{
-       return category->info_list;
-}
-
-HAPI Eina_List *const group_context_item_list(struct context_info *info)
-{
-       return info->context_list;
-}
-
-HAPI Eina_List *const group_context_option_list(struct context_item *item)
-{
-       return item->option_list;
-}
-
-HAPI Eina_List *const group_cluster_list(void)
-{
-       return s_info.cluster_list;
-}
-
-HAPI Eina_List * const group_category_list(struct cluster *cluster)
-{
-       return cluster->category_list;
-}
-
-HAPI struct context_info * const group_context_info_from_item(struct context_item *item)
-{
-       return item->info;
-}
-
-HAPI struct category * const group_category_from_context_info(struct context_info *info)
-{
-       return info->category;
-}
-
-HAPI const char * const group_pkgname_from_context_info(struct context_info *info)
-{
-       return info->pkgname;
-}
-
-HAPI const char * const group_option_item_key(struct context_option *option)
-{
-       return option->key;
-}
-
-HAPI const char * const group_option_item_value(struct context_option *option)
-{
-       return option->value;
-}
-
-HAPI const char * const group_context_item(struct context_item *item)
-{
-       return item->ctx_item;
-}
-
-HAPI int group_context_item_add_data(struct context_item *item, const char *tag, void *data)
-{
-       struct context_item_data *tmp;
-
-       tmp = malloc(sizeof(*tmp));
-       if (!tmp) {
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       tmp->tag = strdup(tag);
-       if (!tmp->tag) {
-               DbgFree(tmp);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       tmp->data = data;
-       item->data_list = eina_list_append(item->data_list, tmp);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void *group_context_item_data(struct context_item *item, const char *tag)
-{
-       struct context_item_data *tmp;
-       Eina_List *l;
-
-       EINA_LIST_FOREACH(item->data_list, l, tmp) {
-               if (!strcmp(tmp->tag, tag)) {
-                       return tmp->data;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI void *group_context_item_del_data(struct context_item *item, const char *tag)
-{
-       struct context_item_data *tmp;
-       Eina_List *l;
-       Eina_List *n;
-
-       EINA_LIST_FOREACH_SAFE(item->data_list, l, n, tmp) {
-               if (!strcmp(tmp->tag, tag)) {
-                       void *data;
-
-                       item->data_list = eina_list_remove(item->data_list, tmp);
-
-                       data = tmp->data;
-
-                       DbgFree(tmp->tag);
-                       DbgFree(tmp);
-
-                       return data;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI const char * const group_category_name(struct category *category)
-{
-       return category ? category->name : NULL;
-}
-
-HAPI const char * const group_cluster_name(struct cluster *cluster)
-{
-       return cluster ? cluster->name : NULL;
-}
-
-HAPI const char *group_cluster_name_by_category(struct category *category)
-{
-       return !category ? NULL : (category->cluster ? category->cluster->name : NULL);
-}
-
-static inline char *get_token(char *ptr, int *len)
-{
-       char *name;
-       int _len;
-
-       if (*len == 0) {
-               ErrPrint("Start brace but len = 0\n");
-               return NULL;
-       }
-
-       _len = *len;
-
-       while (_len > 0 && isspace(ptr[_len])) {
-               _len--;
-       }
-
-       if (_len == 0) {
-               ErrPrint("Token has no string\n");
-               return NULL;
-       }
-
-       name = malloc(_len + 1);
-       if (!name) {
-               ErrPrint("malloc: %d\n", errno);
-               return NULL;
-       }
-
-       strncpy(name, ptr - *len, _len);
-       name[_len] = '\0';
-
-       *len = _len;
-       return name;
-}
-
-HAPI int group_add_widget(const char *group, const char *pkgname)
-{
-       struct cluster *cluster;
-       struct category *category;
-       struct context_info *info = NULL;
-       struct context_item *item = NULL;
-       char *key;
-       char *name;
-       char *ptr;
-       int len;
-       int is_open = 0;
-       enum {
-               CLUSTER,
-               CATEGORY,
-               CONTEXT_ITEM,
-               CONTEXT_OPTION_KEY,
-               CONTEXT_OPTION_VALUE,
-               CONTEXT_ERROR = 0xFFFFFFFF
-       } state;
-
-       state = CLUSTER;
-
-       ptr = (char *)group;
-       len = 0;
-       key = NULL;
-
-       /* Skip the first space characters */
-       while (*ptr && isspace(*ptr)) ptr++;
-
-       cluster = NULL;
-       while (*ptr) {
-               if (*ptr == '{') {
-                       name = get_token(ptr, &len);
-                       if (!name) {
-                               ErrPrint("Failed to get token\n");
-                               return WIDGET_ERROR_FAULT;
-                       }
-                       /* cluster{category{context{key=value,key=value},context{key=value}}} */
-                       /* cluster{category} */
-
-                       switch (state) {
-                       case CLUSTER:
-                               cluster = group_find_cluster(name);
-                               if (!cluster) {
-                                       cluster = group_create_cluster(name);
-                               }
-
-                               if (!cluster) {
-                                       ErrPrint("Failed to get cluster\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               state = CATEGORY;
-                               break;
-
-                       case CATEGORY:
-                               category = group_find_category(cluster, name);
-                               if (!category) {
-                                       category = group_create_category(cluster, name);
-                               }
-
-                               if (!category) {
-                                       ErrPrint("Failed to get category\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               info = group_create_context_info(category, pkgname);
-                               if (!info) {
-                                       ErrPrint("Failed to create ctx info\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               state = CONTEXT_ITEM;
-                               break;
-
-                       case CONTEXT_ITEM:
-                               item = group_add_context_item(info, name);
-                               if (!item) {
-                                       ErrPrint("Failed to create a context item\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               state = CONTEXT_OPTION_KEY;
-                               break;
-
-                       case CONTEXT_OPTION_KEY:
-                       case CONTEXT_OPTION_VALUE:
-                       default:
-                               ErrPrint("Invalid state\n");
-                               DbgFree(name);
-                               return WIDGET_ERROR_FAULT;
-                       }
-
-                       DbgFree(name);
-                       is_open++;
-                       len = 0;
-                       ptr++;
-                       while (*ptr && isspace(*ptr)) ptr++;
-                       continue;
-               } else if (*ptr == ',') {
-                       name = get_token(ptr, &len);
-                       if (!name) {
-                               ErrPrint("Failed to get token (len:%d)\n", len);
-                               len = 0;
-                               ptr++;
-                               while (*ptr && isspace(*ptr)) ptr++;
-                               continue;
-                       }
-
-                       switch (state) {
-                       case CLUSTER:
-                               if (is_open != 0) {
-                                       ErrPrint("Invalid state\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-                               cluster = group_find_cluster(name);
-                               if (!cluster) {
-                                       cluster = group_create_cluster(name);
-                               }
-
-                               if (!cluster) {
-                                       ErrPrint("Failed to get cluster\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               state = CATEGORY;
-                               break;
-
-                       case CATEGORY:
-                               if (is_open != 1) {
-                                       ErrPrint("Invalid state\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-                               category = group_find_category(cluster, name);
-                               if (!category) {
-                                       category = group_create_category(cluster, name);
-                               }
-
-                               if (!category) {
-                                       ErrPrint("Failed to get category\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               info = group_create_context_info(category, pkgname);
-                               if (!info) {
-                                       ErrPrint("Failed to create ctx info\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               state = CONTEXT_ITEM;
-                               break;
-                       case CONTEXT_ITEM:
-                               if (is_open == 1) {
-                                       category = group_find_category(cluster, name);
-                                       if (!category) {
-                                               category = group_create_category(cluster, name);
-                                       }
-
-                                       if (!category) {
-                                               ErrPrint("Failed to get category\n");
-                                               DbgFree(name);
-                                               return WIDGET_ERROR_FAULT;
-                                       }
-
-                                       info = group_create_context_info(category, pkgname);
-                                       if (!info) {
-                                               ErrPrint("Failed to create ctx info\n");
-                                               DbgFree(name);
-                                               return WIDGET_ERROR_FAULT;
-                                       }
-                               } else if (is_open == 2) {
-                                       item = group_add_context_item(info, name);
-                                       if (!item) {
-                                               ErrPrint("Failed to create a context item\n");
-                                               DbgFree(name);
-                                               return WIDGET_ERROR_FAULT;
-                                       }
-                                       state = CONTEXT_OPTION_KEY;
-                               } else {
-                                       ErrPrint("Invalid state\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               break;
-                       case CONTEXT_OPTION_VALUE:
-                               if (is_open != 3) {
-                                       ErrPrint("Invalid state\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               if (group_add_option(item, key, name) < 0) {
-                                       ErrPrint("Failed to add a new option: %s - %s\n", key, name);
-                               }
-
-                               DbgFree(key);
-                               key = NULL;
-
-                               state = CONTEXT_OPTION_KEY;
-                               break;
-                       case CONTEXT_OPTION_KEY:
-                       default:
-                               ErrPrint("Invalid state (%s)\n", name);
-                               DbgFree(name);
-                               return WIDGET_ERROR_FAULT;
-                       }
-
-                       DbgFree(name);
-                       len = 0;
-                       ptr++;
-                       while (*ptr && isspace(*ptr)) ptr++;
-                       continue;
-               } else if (*ptr == '=') {
-                       if (is_open != 3 || state != CONTEXT_OPTION_KEY) {
-                               ErrPrint("Invalid state\n");
-                               return WIDGET_ERROR_FAULT;
-                       }
-
-                       key = get_token(ptr, &len);
-                       if (!key) {
-                               ErrPrint("Failed to get token\n");
-                               return WIDGET_ERROR_FAULT;
-                       }
-
-                       state = CONTEXT_OPTION_VALUE;
-                       len = 0;
-                       ptr++;
-                       while (*ptr && isspace(*ptr)) ptr++;
-                       continue;
-               } else if (*ptr == '}') {
-                       if (is_open <= 0) {
-                               ErrPrint("Invalid state\n");
-                               return WIDGET_ERROR_FAULT;
-                       }
-
-                       name = get_token(ptr, &len);
-                       if (!name) {
-                               ErrPrint("Failed to get token, len:%d\n", len);
-                               is_open--;
-                               len = 0;
-                               ptr++;
-                               while (*ptr && isspace(*ptr)) ptr++;
-                               continue;
-                       }
-
-                       switch (state) {
-                       case CATEGORY:
-                               category = group_find_category(cluster, name);
-                               if (!category) {
-                                       category = group_create_category(cluster, name);
-                               }
-
-                               if (!category) {
-                                       ErrPrint("Failed to get category\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               info = group_create_context_info(category, pkgname);
-                               if (!info) {
-                                       ErrPrint("Failed to create ctx info\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               state = CLUSTER;
-                               break;
-                       case CONTEXT_ITEM:
-                               if (is_open == 1) {
-                                       category = group_find_category(cluster, name);
-                                       if (!category) {
-                                               category = group_create_category(cluster, name);
-                                       }
-
-                                       if (!category) {
-                                               ErrPrint("Failed to get category\n");
-                                               DbgFree(name);
-                                               return WIDGET_ERROR_FAULT;
-                                       }
-
-                                       info = group_create_context_info(category, pkgname);
-                                       if (!info) {
-                                               ErrPrint("Failed to create ctx info\n");
-                                               DbgFree(name);
-                                               return WIDGET_ERROR_FAULT;
-                                       }
-
-                                       state = CLUSTER;
-                               } else if (is_open == 2) {
-                                       state = CATEGORY;
-                               } else {
-                                       ErrPrint("Invalid state\n");
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-                               break;
-                       case CONTEXT_OPTION_VALUE:
-                               if (is_open != 2) {
-                                       ErrPrint("Invalid state (%s)\n", name);
-                                       DbgFree(name);
-                                       return WIDGET_ERROR_FAULT;
-                               }
-
-                               if (group_add_option(item, key, name) < 0) {
-                                       ErrPrint("Failed to add a new option: %s - %s\n", key, name);
-                               }
-
-                               DbgFree(key);
-                               key = NULL;
-
-                               state = CONTEXT_ITEM;
-                               break;
-                       case CONTEXT_OPTION_KEY:
-                       case CLUSTER:
-                       default:
-                               ErrPrint("Invalid state (%s)\n", name);
-                               break;
-                       }
-
-                       DbgFree(name);
-                       is_open--;
-                       len = 0;
-                       ptr++;
-                       while (*ptr && isspace(*ptr)) ptr++;
-                       continue;
-               }
-
-               len++;
-               ptr++;
-       }
-
-       /* If some cases, the key is not released, try release it, doesn't need to check NULL */
-       DbgFree(key);
-
-       if (state != CLUSTER) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int group_del_widget(const char *pkgname)
-{
-       Eina_List *l;
-       Eina_List *n;
-       Eina_List *s_l;
-       Eina_List *s_n;
-       Eina_List *i_l;
-       Eina_List *i_n;
-       struct cluster *cluster;
-       struct category *category;
-       struct context_info *info;
-
-       EINA_LIST_FOREACH_SAFE(s_info.cluster_list, l, n, cluster) {
-               EINA_LIST_FOREACH_SAFE(cluster->category_list, s_l, s_n, category) {
-                       EINA_LIST_FOREACH_SAFE(category->info_list, i_l, i_n, info) {
-                               if (!strcmp(pkgname, info->pkgname)) {
-                                       group_destroy_context_info(info);
-                               }
-                       }
-
-                       if (!category->info_list) {
-                               group_destroy_category(category);
-                       }
-               }
-
-               if (!cluster->category_list) {
-                       group_destroy_cluster(cluster);
-               }
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int group_init(void)
-{
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int group_fini(void)
-{
-       struct cluster *cluster;
-       struct category *category;
-
-       EINA_LIST_FREE(s_info.cluster_list, cluster) {
-
-               EINA_LIST_FREE(cluster->category_list, category) {
-                       destroy_category(category);
-               }
-
-               destroy_cluster(cluster);
-       }
-       return WIDGET_ERROR_NONE;
-}
-
-/* End of a file */
diff --git a/src/instance.c b/src/instance.c
deleted file mode 100644 (file)
index c1498ca..0000000
+++ /dev/null
@@ -1,4035 +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 <errno.h>
-
-#include <dlog.h>
-#include <Eina.h>
-#include <gio/gio.h>
-#include <Ecore.h>
-
-#include <packet.h>
-#include <com-core_packet.h>
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_cmd_list.h>
-#include <widget_buffer.h>
-#include <widget_conf.h>
-#include <widget_util.h>
-
-#include "conf.h"
-#include "util.h"
-#include "debug.h"
-#include "slave_life.h"
-#include "slave_rpc.h"
-#include "client_life.h"
-#include "instance.h"
-#include "client_rpc.h"
-#include "package.h"
-#include "script_handler.h"
-#include "buffer_handler.h"
-#include "setting.h"
-#include "monitor.h"
-
-int errno;
-
-static struct info {
-       enum widget_fb_type env_buf_type;
-} s_info = {
-       .env_buf_type = WIDGET_FB_TYPE_FILE,
-};
-
-struct set_pinup_cbdata {
-       struct inst_info *inst;
-       int pinup;
-};
-
-struct resize_cbdata {
-       struct inst_info *inst;
-       int w;
-       int h;
-};
-
-struct update_mode_cbdata {
-       struct inst_info *inst;
-       int active_update;
-};
-
-struct change_group_cbdata {
-       struct inst_info *inst;
-       char *cluster;
-       char *category;
-};
-
-struct period_cbdata {
-       struct inst_info *inst;
-       double period;
-};
-
-struct event_item {
-       int (*event_cb)(struct inst_info *inst, void *data);
-       void *data;
-       int deleted;
-};
-
-struct tag_item {
-       char *tag;
-       void *data;
-};
-
-struct inst_info {
-       struct pkg_info *info;
-
-       enum instance_state state; /*!< Represents current state */
-       enum instance_state requested_state; /*!< Only ACTIVATED | DESTROYED is acceptable */
-       widget_destroy_type_e destroy_type;
-       int changing_state;
-       int unicast_delete_event;
-
-       char *id;
-       double timestamp;
-
-       char *content;
-       char *cluster;
-       char *category;
-       char *title;
-       int is_pinned_up;
-       double sleep_at;
-       int scroll_locked; /*!< Scroller which is in viewer is locked. */
-       int active_update; /*!< Viewer will reload the buffer by itself, so the provider doesn't need to send the updated event */
-
-       char *icon;
-       char *name;
-
-       enum widget_visible_state visible;
-
-       struct {
-               int need_to_recover;
-       } watch;
-
-       struct {
-               int width;
-               int height;
-               double priority;
-
-               union {
-                       struct script_info *script;
-                       struct buffer_info *buffer;
-               } canvas;
-
-               struct buffer_info **extra_buffer;
-
-               double period;
-       } widget;
-
-       struct {
-               int width;
-               int height;
-               double x;
-               double y;
-
-               union {
-                       struct script_info *script;
-                       struct buffer_info *buffer;
-               } canvas;
-
-               struct buffer_info **extra_buffer;
-
-               struct client_node *owner;
-               int is_opened_for_reactivate;
-               int need_to_send_close_event;
-               char *pended_update_desc;
-               int pended_update_cnt;
-       } gbar;
-
-       struct client_node *client; /*!< Owner - creator */
-       Eina_List *client_list; /*!< Viewer list */
-       int refcnt;
-
-       Ecore_Timer *update_timer; /*!< Only used for secured widget */
-       int update_timer_freezed; /*!< Tizen 2.3 doesn't support ecore_timer_freeze_get API. it is introduced in Tizen 2.4. For the compatibility, master uses this */
-
-       enum event_process {
-               INST_EVENT_PROCESS_IDLE = 0x00,
-               INST_EVENT_PROCESS_DELETE = 0x01
-       } in_event_process;
-       Eina_List *delete_event_list;
-
-       Eina_List *data_list;
-       int orientation;
-};
-
-static Eina_Bool update_timer_cb(void *data);
-
-static int client_send_event(struct inst_info *instance, struct packet *packet, struct packet *owner_packet)
-{
-       /*!
-        * \note
-        * If a instance has owner, send event to it first.
-        */
-       if (instance->client) {
-               /*
-                * To prevent from packet destruction
-                */
-               if (owner_packet) {
-                       client_rpc_async_request(instance->client, owner_packet);
-               } else if (packet) {
-                       packet_ref(packet);
-                       client_rpc_async_request(instance->client, packet);
-               }
-       }
-
-       /*!
-        * And then broadcast events to all client (viewer)
-        */
-       return client_broadcast(instance, packet);
-}
-
-static inline void timer_thaw(struct inst_info *inst)
-{
-       double pending;
-       double period;
-       double delay;
-       double sleep_time;
-
-       if (!inst->update_timer_freezed) {
-               return;
-       }
-
-       ecore_timer_thaw(inst->update_timer);
-       inst->update_timer_freezed = 0;
-
-       period = ecore_timer_interval_get(inst->update_timer);
-       pending = ecore_timer_pending_get(inst->update_timer);
-       delay = util_time_delay_for_compensation(period) - pending;
-       ecore_timer_delay(inst->update_timer, delay);
-
-       if (inst->sleep_at == 0.0f) {
-               return;
-       }
-
-       sleep_time = util_timestamp() - inst->sleep_at;
-       if (sleep_time > pending) {
-               (void)update_timer_cb(inst);
-       }
-
-       inst->sleep_at = 0.0f;
-}
-
-static inline void timer_freeze(struct inst_info *inst)
-{
-       if (inst->update_timer_freezed) {
-               return;
-       }
-
-       ecore_timer_freeze(inst->update_timer);
-       inst->update_timer_freezed = 1;
-
-       if (ecore_timer_interval_get(inst->update_timer) <= 1.0f) {
-               return;
-       }
-
-#if defined(_USE_ECORE_TIME_GET)
-       inst->sleep_at = ecore_time_get();
-#else
-       struct timeval tv;
-       if (gettimeofday(&tv, NULL) < 0) {
-               ErrPrint("gettimeofday: %d\n", errno);
-               tv.tv_sec = 0;
-               tv.tv_usec = 0;
-       }
-       inst->sleep_at = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f;
-#endif
-}
-
-static int viewer_deactivated_cb(struct client_node *client, void *data)
-{
-       struct inst_info *inst = data;
-       unsigned int cmd = CMD_VIEWER_DISCONNECTED;
-       struct packet *packet;
-
-       DbgPrint("%d is deleted from the list of viewer of %s(%s)\n", client_pid(client), package_name(instance_package(inst)), instance_id(inst));
-       if (!eina_list_data_find(inst->client_list, client)) {
-               ErrPrint("Not found\n");
-               return WIDGET_ERROR_NOT_EXIST;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "sss", package_name(inst->info), inst->id, client_direct_addr(inst->client));
-       if (packet) {
-               if (slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0) < 0) {
-                       ErrPrint("Failed to send request to slave: %s\n", package_name(inst->info));
-                       /*!
-                        * \note
-                        * From now, packet is not valid. because the slave_rpc_request_only will destroy it if it fails;)
-                        */
-               }
-       } else {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       inst->client_list = eina_list_remove(inst->client_list, client);
-       if (!inst->client_list && !inst->client) {
-               DbgPrint("Has no clients\n");
-               instance_destroy(inst, WIDGET_DESTROY_TYPE_FAULT);
-       }
-
-       instance_unref(inst);
-       return -1; /*!< Remove this callback from the cb list */
-}
-
-static int pause_widget(struct inst_info *inst)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_WIDGET_PAUSE;
-
-       packet = packet_create_noack((const char *)&cmd, "ss", package_name(inst->info), inst->id);
-       if (!packet) {
-               ErrPrint("Failed to create a new packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0);
-}
-
-/*! \TODO Wake up the freeze'd timer */
-static int resume_widget(struct inst_info *inst)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_WIDGET_RESUME;
-
-       packet = packet_create_noack((const char *)&cmd, "ss", package_name(inst->info), inst->id);
-       if (!packet) {
-               ErrPrint("Failed to create a new packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0);
-}
-
-static inline int instance_recover_visible_state(struct inst_info *inst)
-{
-       int ret;
-
-       switch (inst->visible) {
-       case WIDGET_SHOW:
-       case WIDGET_HIDE:
-               instance_thaw_updator(inst);
-
-               ret = 0;
-               break;
-       case WIDGET_HIDE_WITH_PAUSE:
-               ret = pause_widget(inst);
-               (void)instance_freeze_updator(inst);
-
-               break;
-       default:
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               break;
-       }
-
-       DbgPrint("Visible state is recovered to %d\n", ret);
-       return ret;
-}
-
-static inline void instance_send_update_mode_event(struct inst_info *inst, int active_mode, int status)
-{
-       struct packet *packet;
-       const char *pkgname;
-       unsigned int cmd = CMD_RESULT_UPDATE_MODE;
-
-       if (!inst->info) {
-               ErrPrint("Instance info is not ready to use\n");
-               return;
-       }
-
-       pkgname = package_name(inst->info);
-
-       packet = packet_create_noack((const char *)&cmd, "ssii", pkgname, inst->id, status, active_mode);
-       if (packet) {
-               client_send_event(inst, packet, NULL);
-       } else {
-               ErrPrint("Failed to send update mode event\n");
-       }
-}
-
-static inline void instance_send_update_id(struct inst_info *inst)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_UPDATE_ID;
-
-       packet = packet_create_noack((const char *)&cmd, "ds", inst->timestamp, inst->id);
-       if (packet) {
-               client_send_event(inst, packet, NULL);
-       } else {
-               ErrPrint("Failed to create update_id packet\n");
-       }
-}
-
-static inline void instance_send_resized_event(struct inst_info *inst, int is_gbar, int w, int h, int status)
-{
-       struct packet *packet;
-       enum widget_widget_type widget_type;
-       const char *pkgname;
-       const char *id;
-       unsigned int cmd = CMD_SIZE_CHANGED;
-
-       if (!inst->info) {
-               ErrPrint("Instance info is not ready to use\n");
-               return;
-       }
-
-       pkgname = package_name(inst->info);
-
-       widget_type = package_widget_type(inst->info);
-       if (widget_type == WIDGET_TYPE_SCRIPT) {
-               id = script_handler_buffer_id(inst->widget.canvas.script);
-       } else if (widget_type == WIDGET_TYPE_BUFFER) {
-               id = buffer_handler_id(inst->widget.canvas.buffer);
-       } else {
-               id = "";
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "sssiiii", pkgname, inst->id, id, is_gbar, w, h, status);
-       if (packet) {
-               client_send_event(inst, packet, NULL);
-       } else {
-               ErrPrint("Failed to send size changed event\n");
-       }
-}
-
-static void update_mode_cb(struct slave_node *slave, const struct packet *packet, void *data)
-{
-       struct update_mode_cbdata *cbdata = data;
-       int ret;
-
-       if (!packet) {
-               ErrPrint("Invalid packet\n");
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       if (packet_get(packet, "i", &ret) != 1) {
-               ErrPrint("Invalid parameters\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               cbdata->inst->active_update = cbdata->active_update;
-       }
-
-out:
-       instance_send_update_mode_event(cbdata->inst, cbdata->active_update, ret);
-       instance_unref(cbdata->inst);
-       DbgFree(cbdata);
-}
-
-HAPI int instance_unicast_created_event(struct inst_info *inst, struct client_node *client)
-{
-       struct packet *packet;
-       enum widget_widget_type widget_type;
-       enum widget_gbar_type gbar_type;
-       const char *widget_file;
-       const char *gbar_file;
-       unsigned int cmd = CMD_CREATED;
-
-       if (!client) {
-               client = inst->client;
-               if (!client) {
-                       return WIDGET_ERROR_NONE;
-               }
-       }
-
-       widget_type = package_widget_type(inst->info);
-       gbar_type = package_gbar_type(inst->info);
-
-       if (widget_type == WIDGET_TYPE_SCRIPT) {
-               widget_file = script_handler_buffer_id(inst->widget.canvas.script);
-       } else if (widget_type == WIDGET_TYPE_BUFFER) {
-               widget_file = buffer_handler_id(inst->widget.canvas.buffer);
-       } else {
-               widget_file = "";
-       }
-
-       if (gbar_type == GBAR_TYPE_SCRIPT) {
-               gbar_file = script_handler_buffer_id(inst->gbar.canvas.script);
-       } else if (gbar_type == GBAR_TYPE_BUFFER) {
-               gbar_file = buffer_handler_id(inst->gbar.canvas.buffer);
-       } else {
-               gbar_file = "";
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "dsssiiiisssssdiiiiidsi",
-                       inst->timestamp,
-                       package_name(inst->info), inst->id, inst->content,
-                       inst->widget.width, inst->widget.height,
-                       inst->gbar.width, inst->gbar.height,
-                       inst->cluster, inst->category,
-                       widget_file, gbar_file,
-                       package_auto_launch(inst->info),
-                       inst->widget.priority,
-                       package_size_list(inst->info),
-                       !!inst->client,
-                       package_pinup(inst->info),
-                       widget_type, gbar_type,
-                       inst->widget.period, inst->title,
-                       inst->is_pinned_up);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_rpc_async_request(client, packet);
-}
-
-static int update_client_list(struct client_node *client, void *data)
-{
-       struct inst_info *inst = data;
-
-       if (!instance_has_client(inst, client)) {
-               instance_add_client(inst, client);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static int instance_broadcast_created_event(struct inst_info *inst)
-{
-       struct packet *packet;
-       struct packet *owner_packet;
-       enum widget_widget_type widget_type;
-       enum widget_gbar_type gbar_type;
-       const char *widget_file;
-       const char *gbar_file;
-       unsigned int cmd = CMD_CREATED;
-       int ret;
-
-       widget_type = package_widget_type(inst->info);
-       gbar_type = package_gbar_type(inst->info);
-
-       if (widget_type == WIDGET_TYPE_SCRIPT) {
-               widget_file = script_handler_buffer_id(inst->widget.canvas.script);
-       } else if (widget_type == WIDGET_TYPE_BUFFER) {
-               widget_file = buffer_handler_id(inst->widget.canvas.buffer);
-       } else {
-               widget_file = "";
-       }
-
-       if (gbar_type == GBAR_TYPE_SCRIPT) {
-               gbar_file = script_handler_buffer_id(inst->gbar.canvas.script);
-       } else if (gbar_type == GBAR_TYPE_BUFFER) {
-               gbar_file = buffer_handler_id(inst->gbar.canvas.buffer);
-       } else {
-               gbar_file = "";
-       }
-
-       if (!inst->client) {
-               client_browse_group_list(inst->cluster, inst->category, update_client_list, inst);
-       }
-
-       client_browse_category_list(package_category(inst->info), update_client_list, inst);
-       inst->unicast_delete_event = 0;
-
-       packet = packet_create_noack((const char *)&cmd, "dsssiiiisssssdiiiiidsi", 
-                       inst->timestamp,
-                       package_name(inst->info), inst->id, inst->content,
-                       inst->widget.width, inst->widget.height,
-                       inst->gbar.width, inst->gbar.height,
-                       inst->cluster, inst->category,
-                       widget_file, gbar_file,
-                       package_auto_launch(inst->info),
-                       inst->widget.priority,
-                       package_size_list(inst->info),
-                       0, /* Assume, this is a system created widget (not the ower) */
-                       package_pinup(inst->info),
-                       widget_type, gbar_type,
-                       inst->widget.period, inst->title,
-                       inst->is_pinned_up);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (inst->client) {
-               owner_packet = packet_create_noack((const char *)&cmd, "dsssiiiisssssdiiiiidsi", 
-                               inst->timestamp,
-                               package_name(inst->info), inst->id, inst->content,
-                               inst->widget.width, inst->widget.height,
-                               inst->gbar.width, inst->gbar.height,
-                               inst->cluster, inst->category,
-                               widget_file, gbar_file,
-                               package_auto_launch(inst->info),
-                               inst->widget.priority,
-                               package_size_list(inst->info),
-                               1,
-                               package_pinup(inst->info),
-                               widget_type, gbar_type,
-                               inst->widget.period, inst->title,
-                               inst->is_pinned_up);
-               if (!owner_packet) {
-                       ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-                       return WIDGET_ERROR_FAULT;
-               }
-       } else {
-               owner_packet = NULL;
-       }
-
-       ret = client_send_event(inst, packet, owner_packet);
-
-       monitor_multicast_state_change_event(package_name(inst->info), MONITOR_EVENT_CREATED, instance_id(inst), instance_content(inst));
-
-       return ret;
-}
-
-HAPI int instance_unicast_deleted_event(struct inst_info *inst, struct client_node *client, int reason)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_DELETED;
-
-       if (!client) {
-               client = inst->client;
-               if (!client) {
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssdi", package_name(inst->info), inst->id, inst->timestamp, reason);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_rpc_async_request(client, packet);
-}
-
-static int instance_broadcast_deleted_event(struct inst_info *inst, int reason)
-{
-       struct packet *packet;
-       struct client_node *client;
-       Eina_List *l;
-       Eina_List *n;
-       int ret;
-       unsigned int cmd = CMD_DELETED;
-
-       packet = packet_create_noack((const char *)&cmd, "ssdi", package_name(inst->info), inst->id, inst->timestamp, reason);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       ret = client_send_event(inst, packet, NULL);
-
-       EINA_LIST_FOREACH_SAFE(inst->client_list, l, n, client) {
-               instance_del_client(inst, client);
-       }
-
-       monitor_multicast_state_change_event(package_name(inst->info), MONITOR_EVENT_DESTROYED, instance_id(inst), instance_content(inst));
-
-       return ret;
-}
-
-static int client_deactivated_cb(struct client_node *client, void *data)
-{
-       struct inst_info *inst = data;
-       instance_destroy(inst, WIDGET_DESTROY_TYPE_FAULT);
-       return WIDGET_ERROR_NONE;
-}
-
-static int send_gbar_destroyed_to_client(struct inst_info *inst, int status)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_GBAR_DESTROYED;
-
-       if (!inst->gbar.need_to_send_close_event && status != WIDGET_ERROR_FAULT) {
-               ErrPrint("GBAR is not created\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssi", package_name(inst->info), inst->id, status);
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       inst->gbar.need_to_send_close_event = 0;
-
-       return client_send_event(inst, packet, NULL);
-}
-
-static inline void invoke_delete_callbacks(struct inst_info *inst)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct event_item *item;
-
-       inst->in_event_process |= INST_EVENT_PROCESS_DELETE;
-       EINA_LIST_FOREACH_SAFE(inst->delete_event_list, l, n, item) {
-               if (item->deleted || item->event_cb(inst, item->data) < 0 || item->deleted) {
-                       inst->delete_event_list = eina_list_remove(inst->delete_event_list, item);
-                       DbgFree(item);
-               }
-       }
-       inst->in_event_process &= ~INST_EVENT_PROCESS_DELETE;
-}
-
-HAPI int instance_event_callback_is_added(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data)
-{
-       struct event_item *item;
-       Eina_List *l;
-
-       if (!event_cb) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (type) {
-       case INSTANCE_EVENT_DESTROY:
-               EINA_LIST_FOREACH(inst->delete_event_list, l, item) {
-                       if (item->event_cb == event_cb && item->data == data) {
-                               return 1;
-                       }
-               }
-
-               break;
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return 0;
-}
-
-HAPI int instance_event_callback_add(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data)
-{
-       struct event_item *item;
-
-       if (!event_cb) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (type) {
-       case INSTANCE_EVENT_DESTROY:
-               item = malloc(sizeof(*item));
-               if (!item) {
-                       ErrPrint("malloc: %d\n", errno);
-                       return WIDGET_ERROR_OUT_OF_MEMORY;
-               }
-
-               item->event_cb = event_cb;
-               item->data = data;
-               item->deleted = 0;
-
-               inst->delete_event_list = eina_list_append(inst->delete_event_list, item);
-               break;
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int instance_event_callback_del(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct event_item *item;
-
-       switch (type) {
-       case INSTANCE_EVENT_DESTROY:
-               EINA_LIST_FOREACH_SAFE(inst->delete_event_list, l, n, item) {
-                       if (item->event_cb == event_cb && item->data == data) {
-                               if (inst->in_event_process & INST_EVENT_PROCESS_DELETE) {
-                                       item->deleted = 1;
-                               } else {
-                                       inst->delete_event_list = eina_list_remove(inst->delete_event_list, item);
-                                       DbgFree(item);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       default:
-               break;
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-static inline void destroy_instance(struct inst_info *inst)
-{
-       struct pkg_info *pkg;
-       enum widget_widget_type widget_type;
-       enum widget_gbar_type gbar_type;
-       struct slave_node *slave;
-       struct event_item *item;
-       struct tag_item *tag_item;
-
-       (void)send_gbar_destroyed_to_client(inst, WIDGET_ERROR_NONE);
-
-       invoke_delete_callbacks(inst);
-
-       pkg = inst->info;
-
-       widget_type = package_widget_type(pkg);
-       gbar_type = package_gbar_type(pkg);
-       slave = package_slave(inst->info);
-
-       DbgPrint("Instance is destroyed (%p), slave(%p)\n", inst, slave);
-
-       if (widget_type == WIDGET_TYPE_SCRIPT) {
-               (void)script_handler_unload(inst->widget.canvas.script, 0);
-               if (script_handler_destroy(inst->widget.canvas.script) == (int)WIDGET_ERROR_NONE) {
-                       inst->widget.canvas.script = NULL;
-               }
-       } else if (widget_type == WIDGET_TYPE_BUFFER) {
-               (void)buffer_handler_unload(inst->widget.canvas.buffer);
-               if (buffer_handler_destroy(inst->widget.canvas.buffer) == (int)WIDGET_ERROR_NONE) {
-                       inst->widget.canvas.buffer = NULL;
-               }
-
-               if (inst->widget.extra_buffer) {
-                       int i;
-
-                       for (i = 0; i < WIDGET_CONF_EXTRA_BUFFER_COUNT; i++) {
-                               if (!inst->widget.extra_buffer[i]) {
-                                       continue;
-                               }
-
-                               (void)buffer_handler_unload(inst->widget.extra_buffer[i]);
-                               if (buffer_handler_destroy(inst->widget.extra_buffer[i]) == (int)WIDGET_ERROR_NONE) {
-                                       inst->widget.extra_buffer[i] = NULL;
-                               }
-                       }
-
-                       DbgFree(inst->widget.extra_buffer);
-                       inst->widget.extra_buffer = NULL;
-               }
-       }
-
-       if (gbar_type == GBAR_TYPE_SCRIPT) {
-               (void)script_handler_unload(inst->gbar.canvas.script, 1);
-               if (script_handler_destroy(inst->gbar.canvas.script) == (int)WIDGET_ERROR_NONE) {
-                       inst->gbar.canvas.script = NULL;
-               }
-       } else if (gbar_type == GBAR_TYPE_BUFFER) {
-               (void)buffer_handler_unload(inst->gbar.canvas.buffer);
-               if (buffer_handler_destroy(inst->gbar.canvas.buffer) == (int)WIDGET_ERROR_NONE) {
-                       inst->gbar.canvas.buffer = NULL;
-               }
-               if (inst->gbar.extra_buffer) {
-                       int i;
-
-                       for (i = 0; i < WIDGET_CONF_EXTRA_BUFFER_COUNT; i++) {
-                               if (!inst->gbar.extra_buffer[i]) {
-                                       continue;
-                               }
-
-                               (void)buffer_handler_unload(inst->gbar.extra_buffer[i]);
-                               if (buffer_handler_destroy(inst->gbar.extra_buffer[i]) == (int)WIDGET_ERROR_NONE) {
-                                       inst->gbar.extra_buffer[i] = NULL;
-                               }
-                       }
-
-                       DbgFree(inst->gbar.extra_buffer);
-                       inst->gbar.extra_buffer = NULL;
-               }
-       }
-
-       if (inst->client) {
-               client_event_callback_del(inst->client, CLIENT_EVENT_DEACTIVATE, client_deactivated_cb, inst);
-               client_unref(inst->client);
-       }
-
-       if (inst->update_timer) {
-               ecore_timer_del(inst->update_timer);
-       }
-
-       EINA_LIST_FREE(inst->data_list, tag_item) {
-               DbgPrint("Tagged item[%s] %p\n", tag_item->tag, tag_item->data);
-               DbgFree(tag_item->tag);
-               DbgFree(tag_item);
-       }
-
-       EINA_LIST_FREE(inst->delete_event_list, item) {
-               DbgFree(item);
-       }
-
-       DbgFree(inst->icon);
-       DbgFree(inst->name);
-       DbgFree(inst->category);
-       DbgFree(inst->cluster);
-       DbgFree(inst->content);
-       DbgFree(inst->title);
-       util_unlink(widget_util_uri_to_path(inst->id));
-       DbgFree(inst->id);
-       package_del_instance(inst->info, inst);
-       DbgFree(inst);
-
-       slave = slave_unload_instance(slave);
-}
-
-static Eina_Bool update_timer_cb(void *data)
-{
-       struct inst_info *inst = (struct inst_info *)data;
-
-       slave_rpc_request_update(package_name(inst->info), inst->id, inst->cluster, inst->category, NULL, 0);
-       return ECORE_CALLBACK_RENEW;
-}
-
-static inline void unfork_package(struct inst_info *inst)
-{
-       DbgFree(inst->id);
-       inst->id = NULL;
-
-       if (inst->update_timer) {
-               ecore_timer_del(inst->update_timer);
-               inst->update_timer = NULL;
-       }
-}
-
-static inline int fork_package(struct inst_info *inst, const char *pkgname)
-{
-       struct pkg_info *info;
-       int len;
-
-       info = package_find(pkgname);
-       if (!info) {
-               ErrPrint("%s is not found\n", pkgname);
-               return WIDGET_ERROR_NOT_EXIST;
-       }
-
-       len = strlen(SCHEMA_FILE "%s%s_%d_%lf.png") + strlen(WIDGET_CONF_IMAGE_PATH) + strlen(package_name(info)) + 50;
-       inst->id = malloc(len);
-       if (!inst->id) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       snprintf(inst->id, len, SCHEMA_FILE "%s%s_%d_%lf.png", WIDGET_CONF_IMAGE_PATH, package_name(info), client_pid(inst->client), inst->timestamp);
-
-       instance_set_gbar_size(inst, package_gbar_width(info), package_gbar_height(info));
-
-       inst->widget.period = package_period(info);
-
-       inst->info = info;
-
-       if (package_secured(info) || (WIDGET_IS_INHOUSE(package_abi(info)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL)) {
-               if (inst->widget.period > 0.0f) {
-                       inst->update_timer = util_timer_add(inst->widget.period, update_timer_cb, inst);
-                       (void)instance_freeze_updator(inst);
-               } else {
-                       inst->update_timer = NULL;
-               }
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI struct inst_info *instance_create(struct client_node *client, double timestamp, const char *pkgname, const char *content, const char *cluster, const char *category, double period, int width, int height)
-{
-       struct inst_info *inst;
-       char *extra_bundle_data = NULL;
-
-       inst = calloc(1, sizeof(*inst));
-       if (!inst) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       inst->timestamp = timestamp;
-       inst->widget.width = width;
-       inst->widget.height = height;
-
-       if (client_is_sdk_viewer(client)) {
-               char *tmp;
-
-               tmp = strdup(content);
-               if (tmp) {
-                       int length;
-                       char *ptr = tmp;
-
-                       if (sscanf(content, "%d:%s", &length, ptr) == 2) {
-                               extra_bundle_data = malloc(length + 1);
-                               if (extra_bundle_data) {
-                                       strncpy(extra_bundle_data, tmp, length);
-                                       extra_bundle_data[length] = '\0';
-                                       ptr += length;
-                                       DbgPrint("Extra Bundle Data extracted: [%s]\n", extra_bundle_data);
-                               }
-
-                               if (*ptr) {
-                                       inst->content = strdup(ptr);
-                                       if (!inst->content) {
-                                               ErrPrint("strdup: %d\n", errno);
-                                       }
-                                       DbgPrint("Content Info extracted: [%d]\n", inst->content);
-                               }
-                       }
-
-                       DbgFree(tmp);
-               }
-       } else {
-               inst->content = strdup(content);
-               if (!inst->content) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(extra_bundle_data);
-                       DbgFree(inst);
-                       return NULL;
-               }
-       }
-
-       inst->cluster = strdup(cluster);
-       if (!inst->cluster) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(extra_bundle_data);
-               DbgFree(inst->content);
-               DbgFree(inst);
-               return NULL;
-       }
-
-       inst->category = strdup(category);
-       if (!inst->category) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(extra_bundle_data);
-               DbgFree(inst->cluster);
-               DbgFree(inst->content);
-               DbgFree(inst);
-               return NULL;
-       }
-
-       inst->title = strdup(WIDGET_CONF_DEFAULT_TITLE); /*!< Use the DEFAULT Title "" */
-       if (!inst->title) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(extra_bundle_data);
-               DbgFree(inst->category);
-               DbgFree(inst->cluster);
-               DbgFree(inst->content);
-               DbgFree(inst);
-               return NULL;
-       }
-
-       if (client) {
-               inst->client = client_ref(client);
-               if (client_event_callback_add(inst->client, CLIENT_EVENT_DEACTIVATE, client_deactivated_cb, inst) < 0) {
-                       ErrPrint("Failed to add client event callback: %s\n", inst->id);
-               }
-               inst->orientation = client_orientation(client);
-       }
-
-       if (fork_package(inst, pkgname) < 0) {
-               (void)client_unref(inst->client);
-               DbgFree(extra_bundle_data);
-               DbgFree(inst->title);
-               DbgFree(inst->category);
-               DbgFree(inst->cluster);
-               DbgFree(inst->content);
-               DbgFree(inst);
-               return NULL;
-       }
-
-       inst->unicast_delete_event = 1;
-       inst->state = INST_INIT;
-       inst->requested_state = INST_INIT;
-       if (WIDGET_CONF_EXTRA_BUFFER_COUNT) {
-               inst->widget.extra_buffer = calloc(WIDGET_CONF_EXTRA_BUFFER_COUNT, sizeof(*inst->widget.extra_buffer));
-               if (!inst->widget.extra_buffer) {
-                       ErrPrint("Failed to allocate buffer for widget extra buffer\n");
-               }
-
-               inst->gbar.extra_buffer = calloc(WIDGET_CONF_EXTRA_BUFFER_COUNT, sizeof(*inst->gbar.extra_buffer));
-               if (!inst->gbar.extra_buffer) {
-                       ErrPrint("Failed to allocate buffer for gbar extra buffer\n");
-               }
-       }
-       instance_ref(inst);
-
-       if (package_add_instance(inst->info, inst) < 0) {
-               DbgFree(extra_bundle_data);
-               DbgFree(inst->widget.extra_buffer);
-               DbgFree(inst->gbar.extra_buffer);
-               unfork_package(inst);
-               (void)client_unref(inst->client);
-               DbgFree(inst->title);
-               DbgFree(inst->category);
-               DbgFree(inst->cluster);
-               DbgFree(inst->content);
-               DbgFree(inst);
-               return NULL;
-       }
-
-       slave_load_instance(package_slave(inst->info));
-       slave_set_extra_bundle_data(package_slave(inst->info), extra_bundle_data);
-       DbgFree(extra_bundle_data);
-
-       /**
-        * @note
-        * Before activate an instance,
-        * Update its Id first for client.
-        */
-       instance_send_update_id(inst);
-
-       if (instance_activate(inst) < 0) {
-               instance_state_reset(inst);
-               instance_destroy(inst, WIDGET_DESTROY_TYPE_FAULT);
-               inst = NULL;
-       } else {
-               inst->visible = WIDGET_HIDE_WITH_PAUSE;
-       }
-
-       return inst;
-}
-
-HAPI struct packet *instance_duplicate_packet_create(const struct packet *packet, struct inst_info *inst, int width, int height)
-{
-       struct packet *result;
-
-       /**
-        * Do not touch the "timestamp".
-        * It is assigned by Viewer, and will be used as a key to find this instance
-        */
-       instance_set_widget_size(inst, width, height);
-
-       /**
-        * @TODO
-        */
-       DbgPrint("[TODO] Instance package info: %p:%s\n", inst->info, package_name(inst->info));
-       // inst->info = info;
-
-       inst->unicast_delete_event = 1;
-       result = packet_create_reply(packet, "sssiidssisiis",
-                       package_name(inst->info),
-                       inst->id,
-                       inst->content,
-                       package_timeout(inst->info),
-                       !!package_widget_path(inst->info),
-                       inst->widget.period,
-                       inst->cluster,
-                       inst->category,
-                       !!inst->client,
-                       package_abi(inst->info),
-                       inst->widget.width,
-                       inst->widget.height,
-                       client_direct_addr(inst->client));
-       if (!result) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return NULL;
-       }
-
-       /**
-        * @note
-        * Is this really necessary?
-       inst->requested_state = INST_ACTIVATED;
-        */
-       DbgPrint("[TODO] Instance request_state is not touched\n");
-       inst->changing_state--;
-
-       inst->state = INST_ACTIVATED;
-
-       if (inst->requested_state == INST_DESTROYED) {
-               /**
-                * In this case, we should destroy the instance.
-                */
-               DbgPrint("Destroy Instance\n");
-               instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-       }
-
-       instance_create_widget_buffer(inst, WIDGET_CONF_DEFAULT_PIXELS);
-       instance_broadcast_created_event(inst);
-       instance_thaw_updator(inst);
-
-       return result;
-}
-
-HAPI struct inst_info *instance_ref(struct inst_info *inst)
-{
-       if (!inst) {
-               return NULL;
-       }
-
-       inst->refcnt++;
-       return inst;
-}
-
-HAPI struct inst_info *instance_unref(struct inst_info *inst)
-{
-       if (!inst) {
-               return NULL;
-       }
-
-       if (inst->refcnt == 0) {
-               ErrPrint("Instance refcnt is not valid\n");
-               return NULL;
-       }
-
-       inst->refcnt--;
-       if (inst->refcnt == 0) {
-               destroy_instance(inst);
-               inst = NULL;
-       }
-
-       return inst;
-}
-
-static void deactivate_cb(struct slave_node *slave, const struct packet *packet, void *data)
-{
-       struct inst_info *inst = data;
-       int ret;
-
-       /*!
-        * \note
-        * In this callback, we cannot trust the "client" information.
-        * It could be cleared before reach to here.
-        */
-
-       if (!packet) {
-               /*!
-                * \note
-                * The instance_reload will care this.
-                * And it will be called from the slave activate callback.
-                */
-               goto out;
-       }
-
-       if (packet_get(packet, "i", &ret) != 1) {
-               ErrPrint("Invalid argument\n");
-               goto out;
-       }
-
-       DbgPrint("[%s] %d (0x%X)\n", inst->id, ret, inst->state);
-
-       if (inst->state == INST_DESTROYED) {
-               /*!
-                * \note
-                * Already destroyed.
-                * Do nothing at here anymore.
-                */
-               goto out;
-       }
-
-       switch (ret) {
-       case 0:
-               /*!
-                * \note
-                * Successfully unloaded
-                */
-               switch (inst->requested_state) {
-               case INST_ACTIVATED:
-                       /**
-                        * @todo
-                        * How about watch? is it possible to be jumped into this case??
-                        */
-                       instance_state_reset(inst);
-                       instance_reactivate(inst);
-                       break;
-               case INST_DESTROYED:
-                       if (slave_is_watch(slave)) {
-                               /**
-                                * @note
-                                * In case of the watch app.
-                                * It will be terminated by itself if master send the instance destroy request.
-                                * So the master should not handles provider termination as a fault.
-                                * To do that, change the state of a provider too from here.
-                                * Only in case of the slave is watch app.
-                                *
-                                * Watch App will returns DESTROYED result to the master before terminate its process.
-                                * So we can change the state of slave from here.
-                                * The master will not change the states of the slave as a faulted one.
-                                */
-                               DbgPrint("Change the slave state for Watch app\n");
-                               slave_set_state(slave, SLAVE_REQUEST_TO_TERMINATE);
-                       }
-
-                       if (inst->unicast_delete_event) {
-                               instance_unicast_deleted_event(inst, NULL, ret);
-                       } else {
-                               instance_broadcast_deleted_event(inst, ret);
-                       }
-
-                       instance_state_reset(inst);
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-               default:
-                       /*!< Unable to reach here */
-                       break;
-               }
-
-               break;
-       case WIDGET_ERROR_INVALID_PARAMETER:
-               /**
-                * @note
-                * Slave has no instance of this package.
-                */
-       case WIDGET_ERROR_NOT_EXIST:
-               /**
-                * @note
-                * This instance's previous state is only can be the INST_ACTIVATED.
-                * So we should care the slave_unload_instance from here.
-                * And we should send notification to clients, about this is deleted.
-                */
-               /**
-                * @note
-                * Slave has no instance of this.
-                * In this case, ignore the requested_state
-                * Because, this instance is already met a problem.
-                */
-       default:
-               /**
-                * @note
-                * Failed to unload this instance.
-                * This is not possible, slave will always return WIDGET_ERROR_NOT_EXIST, WIDGET_ERROR_INVALID_PARAMETER, or 0.
-                * but care this exceptional case.
-                */
-
-               /**
-                * @todo
-                * How about watch? is it possible to be jumped into this case??
-                */
-               instance_broadcast_deleted_event(inst, ret);
-               instance_state_reset(inst);
-               instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-               break;
-       }
-
-out:
-       inst->changing_state--;
-       if (inst->changing_state < 0) {
-               ErrPrint("Changing state is not correct: %d\n", inst->changing_state);
-       }
-       instance_unref(inst);
-}
-
-static void reactivate_cb(struct slave_node *slave, const struct packet *packet, void *data)
-{
-       struct inst_info *inst = data;
-       enum widget_widget_type widget_type;
-       enum widget_gbar_type gbar_type;
-       int ret;
-       const char *content;
-       const char *title;
-       int is_pinned_up;
-
-       if (!packet) {
-               /*!
-                * \note
-                * instance_reload function will care this.
-                * and it will be called from the slave_activate callback
-                */
-               goto out;
-       }
-
-       if (packet_get(packet, "issi", &ret, &content, &title, &is_pinned_up) != 4) {
-               ErrPrint("Invalid parameter\n");
-               goto out;
-       }
-
-       if (strlen(content)) {
-               char *tmp;
-
-               tmp = strdup(content);
-               if (!tmp) {
-                       ErrPrint("strdup: %d\n", errno);
-                       goto out;
-               }
-
-               DbgFree(inst->content);
-               inst->content = tmp;
-       }
-
-       if (strlen(title)) {
-               char *tmp;
-
-               tmp = strdup(title);
-               if (!tmp) {
-                       ErrPrint("strdup: %d\n", errno);
-                       goto out;
-               }
-
-               DbgFree(inst->title);
-               inst->title = tmp;
-       }
-
-       if (inst->state == INST_DESTROYED) {
-               /*!
-                * \note
-                * Already destroyed.
-                * Do nothing at here anymore.
-                */
-               goto out;
-       }
-
-       switch (ret) {
-       case 0: /*!< normally created */
-               inst->state = INST_ACTIVATED;
-               switch (inst->requested_state) {
-               case INST_DESTROYED:
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-                       break;
-               case INST_ACTIVATED:
-                       inst->is_pinned_up = is_pinned_up;
-                       widget_type = package_widget_type(inst->info);
-                       gbar_type = package_gbar_type(inst->info);
-
-                       /*!
-                        * \note
-                        * Optimization point.
-                        *   In case of the BUFFER type,
-                        *   the slave will request the buffer to render its contents.
-                        *   so the buffer will be automatcially recreated when it gots the
-                        *   buffer request packet.
-                        *   so load a buffer from here is not neccessary.
-                        *   I should to revise it and concrete the concept.
-                        *   Just leave it only for now.
-                        */
-
-                       if (widget_type == WIDGET_TYPE_SCRIPT && inst->widget.canvas.script) {
-                               script_handler_load(inst->widget.canvas.script, 0);
-                       } else if (widget_type == WIDGET_TYPE_BUFFER && inst->widget.canvas.buffer) {
-                               buffer_handler_load(inst->widget.canvas.buffer);
-                       }
-
-                       if (gbar_type == GBAR_TYPE_SCRIPT && inst->gbar.canvas.script && inst->gbar.is_opened_for_reactivate) {
-                               double x, y;
-                               /*!
-                                * \note
-                                * We should to send a request to open a GBAR to slave.
-                                * if we didn't send it, the slave will not recognize the state of a GBAR.
-                                * We have to keep the view of GBAR seamless even if the widget is reactivated.
-                                * To do that, send open request from here.
-                                */
-                               ret = instance_slave_open_gbar(inst, NULL);
-                               instance_slave_get_gbar_pos(inst, &x, &y);
-
-                               /*!
-                                * \note
-                                * In this case, master already loads the GBAR script.
-                                * So just send the gbar,show event to the slave again.
-                                */
-                               ret = instance_signal_emit(inst, "gbar,show", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
-                       } else if (gbar_type == GBAR_TYPE_BUFFER && inst->gbar.canvas.buffer && inst->gbar.is_opened_for_reactivate) {
-                               double x, y;
-
-                               buffer_handler_load(inst->gbar.canvas.buffer);
-                               instance_slave_get_gbar_pos(inst, &x, &y);
-
-                               /*!
-                                * \note
-                                * We should to send a request to open a GBAR to slave.
-                                * if we didn't send it, the slave will not recognize the state of a GBAR.
-                                * We have to keep the view of GBAR seamless even if the widget is reactivated.
-                                * To do that, send open request from here.
-                                */
-                               ret = instance_slave_open_gbar(inst, NULL);
-
-                               /*!
-                                * \note
-                                * In this case, just send the gbar,show event for keeping the compatibility
-                                */
-                               ret = instance_signal_emit(inst, "gbar,show", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
-                       }
-
-                       /*!
-                        * \note
-                        * After create an instance again,
-                        * Send resize request to the widget.
-                        * instance_resize(inst, inst->widget.width, inst->widget.height);
-                        *
-                        * renew request will resize the widget while creating it again
-                        */
-
-                       /*!
-                        * \note
-                        * This function will check the visiblity of a widget and
-                        * make decision whether it thaw the update timer or not.
-                        */
-                       instance_recover_visible_state(inst);
-               default:
-                       break;
-               }
-               break;
-       default:
-               instance_broadcast_deleted_event(inst, ret);
-               instance_state_reset(inst);
-               instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-               break;
-       }
-
-out:
-       inst->changing_state--;
-       if (inst->changing_state < 0) {
-               ErrPrint("Changing state is not correct: %d\n", inst->changing_state);
-       }
-       instance_unref(inst);
-}
-
-static void activate_cb(struct slave_node *slave, const struct packet *packet, void *data)
-{
-       struct inst_info *inst = data;
-       int ret;
-       int w;
-       int h;
-       double priority;
-       char *content;
-       char *title;
-       int is_pinned_up;
-
-       if (!packet) {
-               /*!
-                * \note
-                * instance_reload will care this
-                * it will be called from the slave_activate callback
-                */
-               goto out;
-       }
-
-       if (packet_get(packet, "iiidssi", &ret, &w, &h, &priority, &content, &title, &is_pinned_up) != 7) {
-               ErrPrint("Invalid parameter\n");
-               goto out;
-       }
-
-       DbgPrint("[%s] returns %d (state: 0x%X)\n", inst->id, ret, inst->state);
-
-       if (inst->state == INST_DESTROYED) {
-               /*!
-                * \note
-                * Already destroyed.
-                * Do nothing at here anymore.
-                */
-               goto out;
-       }
-
-       switch (ret) {
-       case 1: /*!< need to create */
-               if (util_free_space(WIDGET_CONF_IMAGE_PATH) > WIDGET_CONF_MINIMUM_SPACE) {
-                       struct inst_info *new_inst;
-                       new_inst = instance_create(inst->client, util_timestamp(), package_name(inst->info),
-                                       inst->content, inst->cluster, inst->category,
-                                       inst->widget.period, 0, 0);
-                       if (!new_inst) {
-                               ErrPrint("Failed to create a new instance\n");
-                       }
-               } else {
-                       ErrPrint("Not enough space\n");
-               }
-       case 0: /*!< normally created */
-               /*!
-                * \note
-                * Anyway this instance is loaded to the slave,
-                * just increase the loaded instance counter
-                * And then reset jobs.
-                */
-               instance_set_widget_size(inst, w, h);
-               instance_set_widget_info(inst, priority, content, title);
-
-               inst->state = INST_ACTIVATED;
-
-               switch (inst->requested_state) {
-               case INST_DESTROYED:
-                       /**
-                        * In this case, we should destroy the instance.
-                        */
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-                       break;
-               case INST_ACTIVATED:
-               default:
-                       /**
-                        * @note
-                        * WIDGET should be created at the create time
-                        */
-                       inst->is_pinned_up = is_pinned_up;
-                       if (package_widget_type(inst->info) == WIDGET_TYPE_SCRIPT) {
-                               if (inst->widget.width == 0 && inst->widget.height == 0) {
-                                       widget_service_get_size(WIDGET_SIZE_TYPE_1x1, &inst->widget.width, &inst->widget.height);
-                               }
-
-                               inst->widget.canvas.script = script_handler_create(inst,
-                                               package_widget_path(inst->info),
-                                               package_widget_group(inst->info),
-                                               inst->widget.width, inst->widget.height);
-
-                               if (!inst->widget.canvas.script) {
-                                       ErrPrint("Failed to create WIDGET\n");
-                               } else {
-                                       script_handler_load(inst->widget.canvas.script, 0);
-                               }
-                       } else if (package_widget_type(inst->info) == WIDGET_TYPE_BUFFER) {
-                               instance_create_widget_buffer(inst, WIDGET_CONF_DEFAULT_PIXELS);
-                       }
-
-                       if (package_gbar_type(inst->info) == GBAR_TYPE_SCRIPT) {
-                               if (inst->gbar.width == 0 && inst->gbar.height == 0) {
-                                       instance_set_gbar_size(inst, package_gbar_width(inst->info), package_gbar_height(inst->info));
-                               }
-
-                               inst->gbar.canvas.script = script_handler_create(inst,
-                                               package_gbar_path(inst->info),
-                                               package_gbar_group(inst->info),
-                                               inst->gbar.width, inst->gbar.height);
-
-                               if (!inst->gbar.canvas.script) {
-                                       ErrPrint("Failed to create GBAR\n");
-                               }
-                       } else if (package_gbar_type(inst->info) == GBAR_TYPE_BUFFER) {
-                               instance_create_gbar_buffer(inst, WIDGET_CONF_DEFAULT_PIXELS);
-                       }
-
-                       instance_broadcast_created_event(inst);
-
-                       instance_thaw_updator(inst);
-                       break;
-               }
-               break;
-       default:
-               instance_unicast_deleted_event(inst, NULL, ret);
-               instance_state_reset(inst);
-               instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-               break;
-       }
-
-out:
-       inst->changing_state--;
-       if (inst->changing_state < 0) {
-               ErrPrint("Changing state is not correct: %d\n", inst->changing_state);
-       }
-       instance_unref(inst);
-}
-
-HAPI int instance_create_gbar_buffer(struct inst_info *inst, int pixels)
-{
-       if (inst->gbar.width == 0 && inst->gbar.height == 0) {
-               instance_set_gbar_size(inst, package_gbar_width(inst->info), package_gbar_height(inst->info));
-       }
-
-       if (!inst->gbar.canvas.buffer) {
-               inst->gbar.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->gbar.width, inst->gbar.height, pixels);
-               if (!inst->gbar.canvas.buffer) {
-                       ErrPrint("Failed to create GBAR Buffer\n");
-               }
-       }
-
-       return !!inst->gbar.canvas.buffer;
-}
-
-HAPI int instance_create_gbar_extra_buffer(struct inst_info *inst, int pixels, int idx)
-{
-       if (!inst->gbar.extra_buffer) {
-               return 0;
-       }
-
-       if (inst->gbar.width == 0 && inst->gbar.height == 0) {
-               instance_set_gbar_size(inst, package_gbar_width(inst->info), package_gbar_height(inst->info));
-       }
-
-       if (!inst->gbar.extra_buffer[idx]) {
-               inst->gbar.extra_buffer[idx] = buffer_handler_create(inst, s_info.env_buf_type, inst->gbar.width, inst->gbar.height, pixels);
-               if (!inst->gbar.extra_buffer[idx]) {
-                       ErrPrint("Failed to create GBAR Extra Buffer\n");
-               }
-       }
-
-       return !!inst->gbar.extra_buffer[idx];
-}
-
-HAPI int instance_create_widget_buffer(struct inst_info *inst, int pixels)
-{
-       if (inst->widget.width == 0 && inst->widget.height == 0) {
-               widget_service_get_size(WIDGET_SIZE_TYPE_1x1, &inst->widget.width, &inst->widget.height);
-       }
-
-       if (!inst->widget.canvas.buffer) {
-               /*!
-                * \note
-                * Slave doesn't call the acquire_buffer.
-                * In this case, create the buffer from here.
-                */
-               inst->widget.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->widget.width, inst->widget.height, pixels);
-               if (!inst->widget.canvas.buffer) {
-                       ErrPrint("Failed to create WIDGET\n");
-               }
-       }
-
-       return !!inst->widget.canvas.buffer;
-}
-
-HAPI int instance_create_widget_extra_buffer(struct inst_info *inst, int pixels, int idx)
-{
-       if (!inst->widget.extra_buffer) {
-               return 0;
-       }
-
-       if (inst->widget.width == 0 && inst->widget.height == 0) {
-               widget_service_get_size(WIDGET_SIZE_TYPE_1x1, &inst->widget.width, &inst->widget.height);
-       }
-
-       if (!inst->widget.extra_buffer[idx]) {
-               inst->widget.extra_buffer[idx] = buffer_handler_create(inst, s_info.env_buf_type, inst->widget.width, inst->widget.height, pixels);
-               if (!inst->widget.extra_buffer[idx]) {
-                       ErrPrint("Failed to create widget Extra buffer\n");
-               }
-       }
-
-       return !!inst->widget.extra_buffer[idx];
-}
-
-HAPI int instance_destroy(struct inst_info *inst, widget_destroy_type_e type)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_DELETE;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (inst->state) {
-       case INST_REQUEST_TO_ACTIVATE:
-       case INST_REQUEST_TO_DESTROY:
-       case INST_REQUEST_TO_REACTIVATE:
-               inst->requested_state = INST_DESTROYED;
-               return WIDGET_ERROR_NONE;
-       case INST_INIT:
-               inst->state = INST_DESTROYED;
-               inst->requested_state = INST_DESTROYED;
-               (void)instance_unref(inst);
-               return WIDGET_ERROR_NONE;
-       case INST_DESTROYED:
-               inst->requested_state = INST_DESTROYED;
-               return WIDGET_ERROR_NONE;
-       default:
-               if (type == WIDGET_DESTROY_TYPE_UNINSTALL || type == WIDGET_DESTROY_TYPE_UPGRADE) {
-                       struct pkg_info *pkg;
-
-                       /**
-                        * @note
-                        * In this case, we cannot re-activate the slave.
-                        * Because it is already uninstalled so there is no widget application anymore.
-                        * So just clear the instances from the homescreen
-                        */
-                       pkg = instance_package(inst);
-                       if (pkg) {
-                               struct slave_node *slave;
-
-                               slave = package_slave(pkg);
-                               if (slave) {
-                                       /**
-                                        * @note
-                                        * If a slave is not activated, (already deactivated)
-                                        * We don't need to try to destroy an instance.
-                                        * Just delete an instance from here.
-                                        */
-                                       if (!slave_is_activated(slave)) {
-                                               /**
-                                                * @note
-                                                * Notify deleted instance information to the viewer.
-                                                */
-                                               if (inst->unicast_delete_event) {
-                                                       instance_unicast_deleted_event(inst, NULL, WIDGET_ERROR_NONE);
-                                               } else {
-                                                       instance_broadcast_deleted_event(inst, WIDGET_ERROR_NONE);
-                                               }
-
-                                               DbgPrint("Slave is deactivated, delete an instance\n");
-                                               inst->state = INST_DESTROYED;
-                                               inst->requested_state = INST_DESTROYED;
-                                               (void)instance_unref(inst);
-                                               return WIDGET_ERROR_NONE;
-                                       }
-                               }
-                       }
-               }
-
-               break;
-       }
-
-       packet = packet_create((const char *)&cmd, "ssi", package_name(inst->info), inst->id, type);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       inst->destroy_type = type;
-       inst->requested_state = INST_DESTROYED;
-       inst->state = INST_REQUEST_TO_DESTROY;
-       inst->changing_state++;
-       return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, deactivate_cb, instance_ref(inst), 0);
-}
-
-HAPI int instance_reload(struct inst_info *inst, widget_destroy_type_e type)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_DELETE;
-       int ret;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       DbgPrint("Reload instance (%s)\n", instance_id(inst));
-
-       switch (inst->state) {
-       case INST_REQUEST_TO_ACTIVATE:
-       case INST_REQUEST_TO_REACTIVATE:
-               return WIDGET_ERROR_NONE;
-       case INST_INIT:
-               ret = instance_activate(inst);
-               if (ret < 0) {
-                       ErrPrint("Failed to activate instance: %d (%s)\n", ret, instance_id(inst));
-               }
-               return WIDGET_ERROR_NONE;
-       case INST_DESTROYED:
-       case INST_REQUEST_TO_DESTROY:
-               DbgPrint("Instance is destroying now\n");
-               return WIDGET_ERROR_NONE;
-       default:
-               if (type == WIDGET_DESTROY_TYPE_UNINSTALL || type == WIDGET_DESTROY_TYPE_UPGRADE) {
-                       struct pkg_info *pkg;
-
-                       pkg = instance_package(inst);
-                       if (pkg) {
-                               struct slave_node *slave;
-
-                               slave = package_slave(pkg);
-                               if (slave) {
-                                       /**
-                                        * @note
-                                        * If a slave is not activated, (already deactivated)
-                                        * We don't need to try to destroy an instance.
-                                        * Just re-activate an instance from here.
-                                        */
-                                       if (!slave_is_activated(slave)) {
-                                               inst->state = INST_INIT;
-                                               DbgPrint("Slave is deactivated, just activate an instasnce\n");
-                                               ret = instance_activate(inst);
-                                               if (ret < 0) {
-                                                       ErrPrint("Failed to activate instance: %d (%s)\n", ret, instance_id(inst));
-                                               }
-                                               return WIDGET_ERROR_NONE;
-                                       }
-                               }
-                       }
-               }
-               break;
-       }
-
-       packet = packet_create((const char *)&cmd, "ssi", package_name(inst->info), inst->id, type);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       inst->destroy_type = type;
-       inst->requested_state = INST_ACTIVATED;
-       inst->state = INST_REQUEST_TO_DESTROY;
-       inst->changing_state++;
-       return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, deactivate_cb, instance_ref(inst), 0);
-}
-
-/* Client Deactivated Callback */
-static int gbar_buffer_close_cb(struct client_node *client, void *inst)
-{
-       int ret;
-
-       ret = instance_slave_close_gbar(inst, client, WIDGET_CLOSE_GBAR_NORMAL);
-       if (ret < 0) {
-               DbgPrint("Forcely close the GBAR ret: %d\n", ret);
-       }
-
-       instance_unref(inst);
-
-       return -1; /* Delete this callback */
-}
-
-/* Client Deactivated Callback */
-static int gbar_script_close_cb(struct client_node *client, void *inst)
-{
-       int ret;
-
-       ret = script_handler_unload(instance_gbar_script(inst), 1);
-       if (ret < 0) {
-               DbgPrint("Unload script: %d\n", ret);
-       }
-
-       ret = instance_slave_close_gbar(inst, client, WIDGET_CLOSE_GBAR_NORMAL);
-       if (ret < 0) {
-               DbgPrint("Forcely close the GBAR ret: %d\n", ret);
-       }
-
-       instance_unref(inst);
-
-       return -1; /* Delete this callback */
-}
-
-static inline void release_resource_for_closing_gbar(struct pkg_info *info, struct inst_info *inst, struct client_node *client)
-{
-       if (!client) {
-               client = inst->gbar.owner;
-               if (!client) {
-                       return;
-               }
-       }
-
-       /*!
-        * \note
-        * Clean up the resources
-        */
-       if (package_gbar_type(info) == GBAR_TYPE_BUFFER) {
-               if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, gbar_buffer_close_cb, inst) == 0) {
-                       /*!
-                        * \note
-                        * Only if this function succeed to remove the gbar_buffer_close_cb,
-                        * Decrease the reference count of this instance
-                        */
-                       instance_unref(inst);
-               }
-       } else if (package_gbar_type(info) == GBAR_TYPE_SCRIPT) {
-               if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, gbar_script_close_cb, inst) == 0) {
-                       /*!
-                        * \note
-                        * Only if this function succeed to remove the script_close_cb,
-                        * Decrease the reference count of this instance
-                        */
-                       instance_unref(inst);
-               }
-       } else {
-               ErrPrint("Unknown GBAR type\n");
-       }
-
-}
-
-HAPI int instance_state_reset(struct inst_info *inst)
-{
-       enum widget_widget_type widget_type;
-       enum widget_gbar_type gbar_type;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (inst->state == INST_DESTROYED) {
-               goto out;
-       }
-
-       widget_type = package_widget_type(inst->info);
-       gbar_type = package_gbar_type(inst->info);
-
-       if (widget_type == WIDGET_TYPE_SCRIPT && inst->widget.canvas.script) {
-               script_handler_unload(inst->widget.canvas.script, 0);
-       } else if (widget_type == WIDGET_TYPE_BUFFER && inst->widget.canvas.buffer) {
-               buffer_handler_unload(inst->widget.canvas.buffer);
-       }
-
-       if (gbar_type == GBAR_TYPE_SCRIPT && inst->gbar.canvas.script) {
-               inst->gbar.is_opened_for_reactivate = script_handler_is_loaded(inst->gbar.canvas.script);
-               release_resource_for_closing_gbar(instance_package(inst), inst, NULL);
-               script_handler_unload(inst->gbar.canvas.script, 1);
-       } else if (gbar_type == GBAR_TYPE_BUFFER && inst->gbar.canvas.buffer) {
-               inst->gbar.is_opened_for_reactivate = buffer_handler_is_loaded(inst->gbar.canvas.buffer);
-               release_resource_for_closing_gbar(instance_package(inst), inst, NULL);
-               buffer_handler_unload(inst->gbar.canvas.buffer);
-       }
-
-out:
-       inst->state = INST_INIT;
-       inst->requested_state = INST_INIT;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int instance_reactivate(struct inst_info *inst)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_RENEW;
-       int ret;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (package_is_fault(inst->info)) {
-               ErrPrint("Fault package [%s]\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       switch (inst->state) {
-       case INST_REQUEST_TO_DESTROY:
-       case INST_REQUEST_TO_ACTIVATE:
-       case INST_REQUEST_TO_REACTIVATE:
-               inst->requested_state = INST_ACTIVATED;
-               return WIDGET_ERROR_NONE;
-       case INST_DESTROYED:
-       case INST_ACTIVATED:
-               return WIDGET_ERROR_NONE;
-       case INST_INIT:
-       default:
-               break;
-       }
-
-       packet = packet_create((const char *)&cmd, "sssiidssiisiisi",
-                       package_name(inst->info),
-                       inst->id,
-                       inst->content,
-                       package_timeout(inst->info),
-                       !!package_widget_path(inst->info),
-                       inst->widget.period,
-                       inst->cluster,
-                       inst->category,
-                       inst->widget.width, inst->widget.height,
-                       package_abi(inst->info),
-                       inst->scroll_locked,
-                       inst->active_update,
-                       client_direct_addr(inst->client),
-                       inst->orientation);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       ret = slave_activate(package_slave(inst->info));
-       if (ret < 0 && ret != WIDGET_ERROR_ALREADY_STARTED) {
-               /*!
-                * \note
-                * If the master failed to launch the slave,
-                * Do not send any requests to the slave.
-                */
-               ErrPrint("Failed to launch the slave\n");
-               packet_destroy(packet);
-               return ret;
-       }
-
-       inst->requested_state = INST_ACTIVATED;
-       inst->state = INST_REQUEST_TO_REACTIVATE;
-       inst->changing_state++;
-
-       return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, reactivate_cb, instance_ref(inst), 1);
-}
-
-HAPI int instance_activate(struct inst_info *inst)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_NEW;
-       int ret;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (package_is_fault(inst->info)) {
-               ErrPrint("Fault package [%s]\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       switch (inst->state) {
-       case INST_REQUEST_TO_REACTIVATE:
-       case INST_REQUEST_TO_ACTIVATE:
-       case INST_REQUEST_TO_DESTROY:
-               inst->requested_state = INST_ACTIVATED;
-               return WIDGET_ERROR_NONE;
-       case INST_ACTIVATED:
-       case INST_DESTROYED:
-               return WIDGET_ERROR_NONE;
-       case INST_INIT:
-       default:
-               break;
-       }
-
-       packet = packet_create((const char *)&cmd, "sssiidssisiisi",
-                       package_name(inst->info),
-                       inst->id,
-                       inst->content,
-                       package_timeout(inst->info),
-                       !!package_widget_path(inst->info),
-                       inst->widget.period,
-                       inst->cluster,
-                       inst->category,
-                       !!inst->client,
-                       package_abi(inst->info),
-                       inst->widget.width,
-                       inst->widget.height,
-                       client_direct_addr(inst->client),
-                       inst->orientation);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       ret = slave_activate(package_slave(inst->info));
-       if (ret < 0 && ret != WIDGET_ERROR_ALREADY_STARTED) {
-               /*!
-                * \note
-                * If the master failed to launch the slave,
-                * Do not send any requests to the slave.
-                */
-               ErrPrint("Failed to launch the slave\n");
-               packet_destroy(packet);
-               return ret;
-       }
-
-       inst->state = INST_REQUEST_TO_ACTIVATE;
-       inst->requested_state = INST_ACTIVATED;
-       inst->changing_state++;
-
-       /*!
-        * \note
-        * Try to activate a slave if it is not activated
-        */
-       return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, activate_cb, instance_ref(inst), 1);
-}
-
-HAPI int instance_widget_update_begin(struct inst_info *inst, double priority, const char *content, const char *title)
-{
-       struct packet *packet;
-       const char *fbfile;
-       unsigned int cmd = CMD_WIDGET_UPDATE_BEGIN;
-
-       if (!inst->active_update) {
-               ErrPrint("Invalid request [%s]\n", inst->id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (package_widget_type(inst->info)) {
-       case WIDGET_TYPE_BUFFER:
-               if (!inst->widget.canvas.buffer) {
-                       ErrPrint("Buffer is null [%s]\n", inst->id);
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-               fbfile = buffer_handler_id(inst->widget.canvas.buffer);
-               break;
-       case WIDGET_TYPE_SCRIPT:
-               if (!inst->widget.canvas.script) {
-                       ErrPrint("Script is null [%s]\n", inst->id);
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-               fbfile = script_handler_buffer_id(inst->widget.canvas.script);
-               break;
-       default:
-               ErrPrint("Invalid request[%s]\n", inst->id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssdsss", package_name(inst->info), inst->id, priority, content, title, fbfile);
-       if (!packet) {
-               ErrPrint("Unable to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI int instance_widget_update_end(struct inst_info *inst)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_WIDGET_UPDATE_END;
-
-       if (!inst->active_update) {
-               ErrPrint("Invalid request [%s]\n", inst->id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (package_widget_type(inst->info)) {
-       case WIDGET_TYPE_BUFFER:
-               if (!inst->widget.canvas.buffer) {
-                       ErrPrint("Buffer is null [%s]\n", inst->id);
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-               break;
-       case WIDGET_TYPE_SCRIPT:
-               if (!inst->widget.canvas.script) {
-                       ErrPrint("Script is null [%s]\n", inst->id);
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-               break;
-       default:
-               ErrPrint("Invalid request[%s]\n", inst->id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ss", package_name(inst->info), inst->id);
-       if (!packet) {
-               ErrPrint("Unable to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI int instance_gbar_update_begin(struct inst_info *inst)
-{
-       struct packet *packet;
-       const char *fbfile;
-       unsigned int cmd = CMD_GBAR_UPDATE_BEGIN;
-
-       if (!inst->active_update) {
-               ErrPrint("Invalid request [%s]\n", inst->id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (package_gbar_type(inst->info)) {
-       case GBAR_TYPE_BUFFER:
-               if (!inst->gbar.canvas.buffer) {
-                       ErrPrint("Buffer is null [%s]\n", inst->id);
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-               fbfile = buffer_handler_id(inst->gbar.canvas.buffer);
-               break;
-       case GBAR_TYPE_SCRIPT:
-               if (!inst->gbar.canvas.script) {
-                       ErrPrint("Script is null [%s]\n", inst->id);
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-               fbfile = script_handler_buffer_id(inst->gbar.canvas.script);
-               break;
-       default:
-               ErrPrint("Invalid request[%s]\n", inst->id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "sss", package_name(inst->info), inst->id, fbfile);
-       if (!packet) {
-               ErrPrint("Unable to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI int instance_gbar_update_end(struct inst_info *inst)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_GBAR_UPDATE_END;
-
-       if (!inst->active_update) {
-               ErrPrint("Invalid request [%s]\n", inst->id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (package_gbar_type(inst->info)) {
-       case GBAR_TYPE_BUFFER:
-               if (!inst->gbar.canvas.buffer) {
-                       ErrPrint("Buffer is null [%s]\n", inst->id);
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-               break;
-       case GBAR_TYPE_SCRIPT:
-               if (!inst->gbar.canvas.script) {
-                       ErrPrint("Script is null [%s]\n", inst->id);
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-               break;
-       default:
-               ErrPrint("Invalid request[%s]\n", inst->id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ss", package_name(inst->info), inst->id);
-       if (!packet) {
-               ErrPrint("Unable to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI void instance_extra_info_updated_by_instance(struct inst_info *inst)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_EXTRA_INFO;
-
-       packet = packet_create_noack((const char *)&cmd, "ssssssd", package_name(inst->info), inst->id,
-                       inst->content, inst->title,
-                       inst->icon, inst->name,
-                       inst->widget.priority);
-       if (!packet) {
-               ErrPrint("Failed to create param (%s - %s)\n", package_name(inst->info), inst->id);
-               return;
-       }
-
-       (void)client_send_event(inst, packet, NULL);
-}
-
-HAPI void instance_extra_updated_by_instance(struct inst_info *inst, int is_gbar, int idx, int x, int y, int w, int h)
-{
-       struct packet *packet;
-       enum widget_widget_type widget_type;
-       unsigned int cmd = CMD_EXTRA_UPDATED;
-
-       if (idx < 0 || idx > WIDGET_CONF_EXTRA_BUFFER_COUNT) {
-               ErrPrint("Invalid index\n");
-               return;
-       }
-
-       if (is_gbar == 0) {
-               if (!inst->widget.extra_buffer || inst->widget.extra_buffer[idx] == 0u) {
-                       ErrPrint("Invalid extra buffer\n");
-                       return;
-               }
-       } else {
-               if (!inst->gbar.extra_buffer || inst->gbar.extra_buffer[idx] == 0u) {
-                       ErrPrint("Invalid extra buffer\n");
-                       return;
-               }
-       }
-
-       if (inst->client && inst->visible != WIDGET_SHOW) {
-               if (inst->visible == WIDGET_HIDE) {
-                       DbgPrint("Ignore update event %s(HIDE)\n", inst->id);
-                       return;
-               }
-       }
-
-       widget_type = package_widget_type(inst->info);
-       if (widget_type != WIDGET_TYPE_BUFFER) {
-               ErrPrint("Unsupported type\n");
-               return;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssiiiiii", package_name(inst->info), inst->id, is_gbar, idx, x, y, w, h);
-       if (!packet) {
-               ErrPrint("Failed to create param (%s - %s)\n", package_name(inst->info), inst->id);
-               return;
-       }
-
-       (void)client_send_event(inst, packet, NULL);
-}
-
-HAPI void instance_widget_updated_by_instance(struct inst_info *inst, const char *safe_file, int x, int y, int w, int h)
-{
-       struct packet *packet;
-       const char *id = NULL;
-       enum widget_widget_type widget_type;
-       unsigned int cmd = CMD_WIDGET_UPDATED;
-
-       if (inst->client && inst->visible != WIDGET_SHOW) {
-               if (inst->visible == WIDGET_HIDE) {
-                       DbgPrint("Ignore update event %s(HIDE)\n", inst->id);
-                       return;
-               }
-       }
-
-       widget_type = package_widget_type(inst->info);
-       if (widget_type == WIDGET_TYPE_SCRIPT) {
-               id = script_handler_buffer_id(inst->widget.canvas.script);
-       } else if (widget_type == WIDGET_TYPE_BUFFER) {
-               id = buffer_handler_id(inst->widget.canvas.buffer);
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssssiiii", package_name(inst->info), inst->id, id, safe_file, x, y, w, h);
-       if (!packet) {
-               ErrPrint("Failed to create param (%s - %s)\n", package_name(inst->info), inst->id);
-               return;
-       }
-
-       (void)client_send_event(inst, packet, NULL);
-}
-
-HAPI int instance_hold_scroll(struct inst_info *inst, int hold)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_SCROLL;
-
-       DbgPrint("HOLD: (%s) %d\n", inst->id, hold);
-       if (inst->scroll_locked == hold) {
-               return WIDGET_ERROR_ALREADY_EXIST;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssi", package_name(inst->info), inst->id, hold);
-       if (!packet) {
-               ErrPrint("Failed to build a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       inst->scroll_locked = hold;
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI void instance_gbar_updated_by_instance(struct inst_info *inst, const char *descfile, int x, int y, int w, int h)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_GBAR_UPDATED;
-       const char *id;
-
-       if (inst->client && inst->visible != WIDGET_SHOW) {
-               DbgPrint("widget is hidden. ignore update event\n");
-               return;
-       }
-
-       if (!inst->gbar.need_to_send_close_event) {
-               DbgPrint("GBAR is not created yet. Ignore update event - %s\n", descfile);
-
-               if (inst->gbar.pended_update_desc) {
-                       DbgFree(inst->gbar.pended_update_desc);
-                       inst->gbar.pended_update_desc = NULL;
-               }
-
-               if (descfile) {
-                       inst->gbar.pended_update_desc = strdup(descfile);
-                       if (!inst->gbar.pended_update_desc) {
-                               ErrPrint("strdup: %d\n", errno);
-                       }
-               }
-
-               inst->gbar.pended_update_cnt++;
-               return;
-       }
-
-       if (!descfile) {
-               descfile = inst->id;
-       }
-
-       switch (package_gbar_type(inst->info)) {
-       case GBAR_TYPE_SCRIPT:
-               id = script_handler_buffer_id(inst->gbar.canvas.script);
-               break;
-       case GBAR_TYPE_BUFFER:
-               id = buffer_handler_id(inst->gbar.canvas.buffer);
-               break;
-       case GBAR_TYPE_TEXT:
-       default:
-               id = "";
-               break;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssssiiii", package_name(inst->info), inst->id, id, descfile, x, y, w, h);
-       if (!packet) {
-               ErrPrint("Failed to create param (%s - %s)\n", package_name(inst->info), inst->id);
-               return;
-       }
-
-       (void)client_send_event(inst, packet, NULL);
-}
-
-HAPI void instance_gbar_updated(const char *pkgname, const char *id, const char *descfile, int x, int y, int w, int h)
-{
-       struct inst_info *inst;
-
-       inst = package_find_instance_by_id(pkgname, id);
-       if (!inst) {
-               return;
-       }
-
-       instance_gbar_updated_by_instance(inst, descfile, x, y, w, h);
-}
-
-HAPI int instance_set_update_mode(struct inst_info *inst, int active_update)
-{
-       struct packet *packet;
-       struct update_mode_cbdata *cbdata;
-       unsigned int cmd = CMD_UPDATE_MODE;
-
-       if (package_is_fault(inst->info)) {
-               ErrPrint("Fault package [%s]\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (inst->active_update == active_update) {
-               DbgPrint("Active update is not changed: %d\n", inst->active_update);
-               return WIDGET_ERROR_ALREADY_EXIST;
-       }
-
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       cbdata->inst = instance_ref(inst);
-       cbdata->active_update = active_update;
-
-       /* NOTE: param is resued from here */
-       packet = packet_create((const char *)&cmd, "ssi", package_name(inst->info), inst->id, active_update);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               instance_unref(cbdata->inst);
-               DbgFree(cbdata);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, update_mode_cb, cbdata, 0);
-}
-
-HAPI int instance_active_update(struct inst_info *inst)
-{
-       return inst->active_update;
-}
-
-HAPI void instance_set_widget_info(struct inst_info *inst, double priority, const char *content, const char *title)
-{
-       char *_content = NULL;
-       char *_title = NULL;
-
-       if (content && strlen(content)) {
-               _content = strdup(content);
-               if (!_content) {
-                       ErrPrint("strdup: %d\n", errno);
-               }
-       }
-
-       if (title && strlen(title)) {
-               _title = strdup(title);
-               if (!_title) {
-                       ErrPrint("strdup: %d\n", errno);
-               }
-       }
-
-       if (_content) {
-               DbgFree(inst->content);
-               inst->content= _content;
-       }
-
-       if (_title) {
-               DbgFree(inst->title);
-               inst->title = _title;
-       }
-
-       if (priority >= 0.0f && priority <= 1.0f) {
-               inst->widget.priority = priority;
-       }
-}
-
-HAPI void instance_set_alt_info(struct inst_info *inst, const char *icon, const char *name)
-{
-       char *_icon = NULL;
-       char *_name = NULL;
-
-       if (icon && strlen(icon)) {
-               _icon = strdup(icon);
-               if (!_icon) {
-                       ErrPrint("strdup: %d\n", errno);
-               }
-       }
-
-       if (name && strlen(name)) {
-               _name = strdup(name);
-               if (!_name) {
-                       ErrPrint("strdup: %d\n", errno);
-               }
-       }
-
-       if (_icon) {
-               DbgFree(inst->icon);
-               inst->icon = _icon;
-       }
-
-       if (_name) {
-               DbgFree(inst->name);
-               inst->name = _name;
-       }
-}
-
-HAPI void instance_set_widget_size(struct inst_info *inst, int w, int h)
-{
-       if (inst->widget.width != w || inst->widget.height != h) {
-               instance_send_resized_event(inst, IS_WIDGET, w, h, WIDGET_ERROR_NONE);
-       }
-
-       inst->widget.width = w;
-       inst->widget.height = h;
-}
-
-HAPI void instance_set_gbar_size(struct inst_info *inst, int w, int h)
-{
-       if (inst->gbar.width != w || inst->gbar.height != h) {
-               instance_send_resized_event(inst, IS_GBAR, w, h, WIDGET_ERROR_NONE);
-       }
-
-       inst->gbar.width = w;
-       inst->gbar.height = h;
-}
-
-static void pinup_cb(struct slave_node *slave, const struct packet *packet, void *data)
-{
-       struct set_pinup_cbdata *cbdata = data;
-       const char *content;
-       struct packet *result;
-       unsigned int cmd = CMD_RESULT_PINUP;
-       int ret;
-
-       if (!packet) {
-               /*!
-                * \todo
-                * Send pinup failed event to client.
-                */
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (packet_get(packet, "is", &ret, &content) != 2) {
-               /*!
-                * \todo
-                * Send pinup failed event to client
-                */
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (ret == 0) {
-               char *new_content;
-
-               new_content = strdup(content);
-               if (!new_content) {
-                       ErrPrint("strdup: %d\n", errno);
-                       /*!
-                        * \note
-                        * send pinup failed event to client
-                        */
-                       ret = WIDGET_ERROR_OUT_OF_MEMORY;
-                       goto out;
-               }
-
-               cbdata->inst->is_pinned_up = cbdata->pinup;
-               DbgFree(cbdata->inst->content);
-
-               cbdata->inst->content = new_content;
-       }
-
-out:
-       /*!
-        * \node
-        * Send PINUP Result to client.
-        * Client should wait this event.
-        */
-       result = packet_create_noack((const char *)&cmd, "iisss", ret, cbdata->inst->is_pinned_up,
-                       package_name(cbdata->inst->info), cbdata->inst->id, cbdata->inst->content);
-       if (result) {
-               (void)client_send_event(cbdata->inst, result, NULL);
-       } else {
-               ErrPrint("Failed to build a packet for %s\n", package_name(cbdata->inst->info));
-       }
-
-       instance_unref(cbdata->inst);
-       DbgFree(cbdata);
-}
-
-HAPI int instance_set_pinup(struct inst_info *inst, int pinup)
-{
-       struct set_pinup_cbdata *cbdata;
-       struct packet *packet;
-       unsigned int cmd = CMD_PINUP;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (package_is_fault(inst->info)) {
-               ErrPrint("Fault package [%s]\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!package_pinup(inst->info)) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (pinup == inst->is_pinned_up) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       cbdata->inst = instance_ref(inst);
-       cbdata->pinup = pinup;
-
-       packet = packet_create((const char *)&cmd, "ssi", package_name(inst->info), inst->id, pinup);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               instance_unref(cbdata->inst);
-               DbgFree(cbdata);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, pinup_cb, cbdata, 0);
-}
-
-HAPI int instance_freeze_updator(struct inst_info *inst)
-{
-       if (WIDGET_CONF_UPDATE_ON_PAUSE) {
-               return WIDGET_ERROR_DISABLED;
-       }
-
-       if (!inst->update_timer) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       timer_freeze(inst);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int instance_thaw_updator(struct inst_info *inst)
-{
-       if (!inst->update_timer) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (client_is_all_paused() || setting_is_lcd_off()) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (inst->visible == WIDGET_HIDE_WITH_PAUSE) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       timer_thaw(inst);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI enum widget_visible_state instance_visible_state(struct inst_info *inst)
-{
-       return inst->visible;
-}
-
-HAPI int instance_set_visible_state(struct inst_info *inst, enum widget_visible_state state)
-{
-       if (inst->visible == state) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       switch (state) {
-       case WIDGET_SHOW:
-       case WIDGET_HIDE:
-               if (inst->visible == WIDGET_HIDE_WITH_PAUSE) {
-                       if (resume_widget(inst) == 0) {
-                               inst->visible = state;
-                       }
-
-                       instance_thaw_updator(inst);
-               } else {
-                       inst->visible = state;
-               }
-               monitor_multicast_state_change_event(package_name(inst->info), MONITOR_EVENT_RESUMED, instance_id(inst), instance_content(inst));
-               break;
-
-       case WIDGET_HIDE_WITH_PAUSE:
-               if (pause_widget(inst) == 0) {
-                       inst->visible = WIDGET_HIDE_WITH_PAUSE;
-               }
-
-               (void)instance_freeze_updator(inst);
-               monitor_multicast_state_change_event(package_name(inst->info), MONITOR_EVENT_PAUSED, instance_id(inst), instance_content(inst));
-               break;
-
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-/**
- * @note
- * Just touch the visible state again.
- */
-HAPI int instance_watch_recover_visible_state(struct inst_info *inst)
-{
-       switch (inst->visible) {
-       case WIDGET_SHOW:
-       case WIDGET_HIDE:
-               (void)resume_widget(inst);
-               instance_thaw_updator(inst);
-               /**
-                * @note
-                * We don't need to send the monitor event.
-                */
-               break;
-       case WIDGET_HIDE_WITH_PAUSE:
-               (void)pause_widget(inst);
-               (void)instance_freeze_updator(inst);
-               break;
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static void resize_cb(struct slave_node *slave, const struct packet *packet, void *data)
-{
-       struct resize_cbdata *cbdata = data;
-       int ret;
-
-       if (!packet) {
-               ErrPrint("RESIZE: Invalid packet\n");
-               instance_send_resized_event(cbdata->inst, IS_WIDGET, cbdata->inst->widget.width, cbdata->inst->widget.height, WIDGET_ERROR_FAULT);
-               instance_unref(cbdata->inst);
-               DbgFree(cbdata);
-               return;
-       }
-
-       if (packet_get(packet, "i", &ret) != 1) {
-               ErrPrint("RESIZE: Invalid parameter\n");
-               instance_send_resized_event(cbdata->inst, IS_WIDGET, cbdata->inst->widget.width, cbdata->inst->widget.height, WIDGET_ERROR_INVALID_PARAMETER);
-               instance_unref(cbdata->inst);
-               DbgFree(cbdata);
-               return;
-       }
-
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               /*!
-                * \note
-                * else waiting the first update with new size
-                */
-               if (cbdata->inst->widget.width == cbdata->w && cbdata->inst->widget.height == cbdata->h) {
-                       /*!
-                        * \note
-                        * Right after the viewer adds a new widget,
-                        * Box has no size information, then it will try to use the default size,
-                        * After a widget returns created event.
-                        *
-                        * A widget will start to generate default size content.
-                        * But the viewer doesn't know it,.
-                        *
-                        * So the viewer will try to change the size of a widget.
-                        *
-                        * At that time, the provider gots the size changed event from the widget.
-                        * So it sent the size changed event to the viewer.
-                        * But the viewer ignores it. if it doesn't care the size changed event.
-                        * (even if it cares the size changed event, there is a timing issue)
-                        *
-                        * And the provider receives resize request,
-                        * right before send the size changed event.
-                        * but there is no changes about the size.
-                        *
-                        * Now the view will waits size changed event forever.
-                        * To resolve this timing issue.
-                        *
-                        * Check the size of a widget from here.
-                        * And if the size is already updated, send the ALREADY event to the viewer
-                        * to get the size changed event callback correctly.
-                        */
-                       instance_send_resized_event(cbdata->inst, IS_WIDGET, cbdata->inst->widget.width, cbdata->inst->widget.height, WIDGET_ERROR_ALREADY_EXIST);
-                       DbgPrint("RESIZE: widget is already resized [%s - %dx%d]\n", instance_id(cbdata->inst), cbdata->w, cbdata->h);
-               } else {
-                       DbgPrint("RESIZE: Request is successfully sent [%s - %dx%d]\n", instance_id(cbdata->inst), cbdata->w, cbdata->h);
-               }
-       } else {
-               DbgPrint("RESIZE: widget rejects the new size: %s - %dx%d (%d)\n", instance_id(cbdata->inst), cbdata->w, cbdata->h, ret);
-               instance_send_resized_event(cbdata->inst, IS_WIDGET, cbdata->inst->widget.width, cbdata->inst->widget.height, ret);
-       }
-
-       instance_unref(cbdata->inst);
-       DbgFree(cbdata);
-}
-
-HAPI int instance_resize(struct inst_info *inst, int w, int h)
-{
-       struct resize_cbdata *cbdata;
-       struct packet *packet;
-       unsigned int cmd = CMD_RESIZE;
-       int ret;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (package_is_fault(inst->info)) {
-               ErrPrint("Fault package: %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       cbdata->inst = instance_ref(inst);
-       cbdata->w = w;
-       cbdata->h = h;
-
-       /* NOTE: param is resued from here */
-       packet = packet_create((const char *)&cmd, "ssii", package_name(inst->info), inst->id, w, h);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               instance_unref(cbdata->inst);
-               DbgFree(cbdata);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       DbgPrint("RESIZE: [%s] resize[%dx%d]\n", instance_id(inst), w, h);
-       ret = slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, resize_cb, cbdata, 0);
-       return ret;
-}
-
-static void set_period_cb(struct slave_node *slave, const struct packet *packet, void *data)
-{
-       struct period_cbdata *cbdata = data;
-       unsigned int cmd = CMD_PERIOD_CHANGED;
-       struct packet *result;
-       int ret;
-
-       if (!packet) {
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       if (packet_get(packet, "i", &ret) != 1) {
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (ret == 0) {
-               cbdata->inst->widget.period = cbdata->period;
-       } else {
-               ErrPrint("Failed to set period %d\n", ret);
-       }
-
-out:
-       result = packet_create_noack((const char *)&cmd, "idss", ret, cbdata->inst->widget.period, package_name(cbdata->inst->info), cbdata->inst->id);
-       if (result) {
-               (void)client_send_event(cbdata->inst, result, NULL);
-       } else {
-               ErrPrint("Failed to build a packet for %s\n", package_name(cbdata->inst->info));
-       }
-
-       instance_unref(cbdata->inst);
-       DbgFree(cbdata);
-       return;
-}
-
-static Eina_Bool timer_updator_cb(void *data)
-{
-       struct period_cbdata *cbdata = data;
-       struct inst_info *inst;
-       struct packet *result;
-       unsigned int cmd = CMD_PERIOD_CHANGED;
-       double period;
-
-       period = cbdata->period;
-       inst = cbdata->inst;
-       DbgFree(cbdata);
-
-       inst->widget.period = period;
-       if (inst->update_timer) {
-               if (inst->widget.period == 0.0f) {
-                       ecore_timer_del(inst->update_timer);
-                       inst->update_timer = NULL;
-               } else {
-                       util_timer_interval_set(inst->update_timer, inst->widget.period);
-               }
-       } else if (inst->widget.period > 0.0f) {
-               inst->update_timer = util_timer_add(inst->widget.period, update_timer_cb, inst);
-               (void)instance_freeze_updator(inst);
-       }
-
-       result = packet_create_noack((const char *)&cmd, "idss", 0, inst->widget.period, package_name(inst->info), inst->id);
-       if (result) {
-               (void)client_send_event(inst, result, NULL);
-       } else {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-       }
-
-       instance_unref(inst);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-HAPI void instance_reload_period(struct inst_info *inst, double period)
-{
-       inst->widget.period = period;
-}
-
-HAPI int instance_set_period(struct inst_info *inst, double period)
-{
-       struct packet *packet;
-       struct period_cbdata *cbdata;
-       unsigned int cmd = CMD_SET_PERIOD;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (package_is_fault(inst->info)) {
-               ErrPrint("Fault package [%s]\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (period < 0.0f) { /* Use the default period */
-               period = package_period(inst->info);
-       } else if (period > 0.0f && period < WIDGET_CONF_MINIMUM_PERIOD) {
-               period = WIDGET_CONF_MINIMUM_PERIOD; /* defined at conf.h */
-       }
-
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       cbdata->period = period;
-       cbdata->inst = instance_ref(inst);
-
-       if (package_secured(inst->info) || (WIDGET_IS_INHOUSE(package_abi(inst->info)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL)) {
-               /*!
-                * \note
-                * Secured widget doesn't need to send its update period to the slave.
-                * Slave has no local timer for updating widgetes
-                *
-                * So update its timer at here.
-                */
-               if (!ecore_timer_add(DELAY_TIME, timer_updator_cb, cbdata)) {
-                       timer_updator_cb(cbdata);
-               }
-               return WIDGET_ERROR_NONE;
-       }
-
-       packet = packet_create((const char *)&cmd, "ssd", package_name(inst->info), inst->id, period);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               instance_unref(cbdata->inst);
-               DbgFree(cbdata);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, set_period_cb, cbdata, 0);
-}
-
-HAPI int instance_clicked(struct inst_info *inst, const char *event, double timestamp, double x, double y)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_CLICKED;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (package_is_fault(inst->info)) {
-               ErrPrint("Fault package [%s]\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       /* NOTE: param is resued from here */
-       packet = packet_create_noack((const char *)&cmd, "sssddd", package_name(inst->info), inst->id, event, timestamp, x, y);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0);
-}
-
-HAPI int instance_signal_emit(struct inst_info *inst, const char *signal, const char *part, double sx, double sy, double ex, double ey, double x, double y, int down)
-{
-       const char *pkgname;
-       const char *id;
-       struct slave_node *slave;
-       struct packet *packet;
-       struct pkg_info *pkg;
-       unsigned int cmd = CMD_SCRIPT;
-
-       pkg = instance_package(inst);
-       pkgname = package_name(pkg);
-       id = instance_id(inst);
-       if (!pkgname || !id) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssssddddddi",
-                       pkgname, id,
-                       signal, part,
-                       sx, sy, ex, ey,
-                       x, y, down);
-       if (!packet) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_request_only(slave, pkgname, packet, 0); 
-}
-
-HAPI int instance_text_signal_emit(struct inst_info *inst, const char *signal_name, const char *source, double sx, double sy, double ex, double ey)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_TEXT_SIGNAL;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (package_is_fault(inst->info)) {
-               ErrPrint("Fault package [%s]\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssssdddd", package_name(inst->info), inst->id, signal_name, source, sx, sy, ex, ey);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0);
-}
-
-static void change_group_cb(struct slave_node *slave, const struct packet *packet, void *data)
-{
-       struct change_group_cbdata *cbdata = data;
-       struct packet *result;
-       unsigned int cmd = CMD_GROUP_CHANGED;
-       int ret;
-
-       if (!packet) {
-               DbgFree(cbdata->cluster);
-               DbgFree(cbdata->category);
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       if (packet_get(packet, "i", &ret) != 1) {
-               ErrPrint("Invalid packet\n");
-               DbgFree(cbdata->cluster);
-               DbgFree(cbdata->category);
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (ret == 0) {
-               DbgFree(cbdata->inst->cluster);
-               cbdata->inst->cluster = cbdata->cluster;
-
-               DbgFree(cbdata->inst->category);
-               cbdata->inst->category = cbdata->category;
-       } else {
-               DbgFree(cbdata->cluster);
-               DbgFree(cbdata->category);
-       }
-
-out:
-       result = packet_create_noack((const char *)&cmd, "ssiss",
-                       package_name(cbdata->inst->info), cbdata->inst->id, ret,
-                       cbdata->inst->cluster, cbdata->inst->category);
-       if (!result) {
-               ErrPrint("Failed to build a packet %s\n", package_name(cbdata->inst->info));
-       } else {
-               (void)client_send_event(cbdata->inst, result, NULL);
-       }
-
-       instance_unref(cbdata->inst);
-       DbgFree(cbdata);
-}
-
-HAPI int instance_change_group(struct inst_info *inst, const char *cluster, const char *category)
-{
-       struct packet *packet;
-       struct change_group_cbdata *cbdata;
-       unsigned int cmd = CMD_CHANGE_GROUP;
-
-       if (!inst) {
-               ErrPrint("Invalid instance handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (package_is_fault(inst->info)) {
-               ErrPrint("Fault package [%s]\n", package_name(inst->info));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               ErrPrint("mlloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       cbdata->cluster = strdup(cluster);
-       if (!cbdata->cluster) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(cbdata);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       cbdata->category = strdup(category);
-       if (!cbdata->category) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(cbdata->cluster);
-               DbgFree(cbdata);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       cbdata->inst = instance_ref(inst);
-
-       packet = packet_create((const char *)&cmd, "ssss", package_name(inst->info), inst->id, cluster, category);
-       if (!packet) {
-               ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
-               instance_unref(cbdata->inst);
-               DbgFree(cbdata->category);
-               DbgFree(cbdata->cluster);
-               DbgFree(cbdata);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, change_group_cb, cbdata, 0);
-}
-
-HAPI const char * const instance_auto_launch(const struct inst_info *inst)
-{
-       return package_auto_launch(inst->info);
-}
-
-HAPI const int const instance_priority(const struct inst_info *inst)
-{
-       return inst->widget.priority;
-}
-
-HAPI const struct client_node *const instance_client(const struct inst_info *inst)
-{
-       return inst->client;
-}
-
-HAPI const int const instance_timeout(const struct inst_info *inst)
-{
-       return package_timeout(inst->info);
-}
-
-HAPI const double const instance_period(const struct inst_info *inst)
-{
-       return inst->widget.period;
-}
-
-HAPI const int const instance_widget_width(const struct inst_info *inst)
-{
-       return inst->widget.width;
-}
-
-HAPI const int const instance_widget_height(const struct inst_info *inst)
-{
-       return inst->widget.height;
-}
-
-HAPI const int const instance_gbar_width(const struct inst_info *inst)
-{
-       return inst->gbar.width;
-}
-
-HAPI const int const instance_gbar_height(const struct inst_info *inst)
-{
-       return inst->gbar.height;
-}
-
-HAPI struct pkg_info *const instance_package(const struct inst_info *inst)
-{
-       return inst->info;
-}
-
-HAPI struct script_info *const instance_widget_script(const struct inst_info *inst)
-{
-       return (package_widget_type(inst->info) == WIDGET_TYPE_SCRIPT) ? inst->widget.canvas.script : NULL;
-}
-
-HAPI struct script_info *const instance_gbar_script(const struct inst_info *inst)
-{
-       return (package_gbar_type(inst->info) == GBAR_TYPE_SCRIPT) ? inst->gbar.canvas.script : NULL;
-}
-
-HAPI struct buffer_info *const instance_widget_buffer(const struct inst_info *inst)
-{
-       return (package_widget_type(inst->info) == WIDGET_TYPE_BUFFER) ? inst->widget.canvas.buffer : NULL;
-}
-
-HAPI struct buffer_info *const instance_gbar_buffer(const struct inst_info *inst)
-{
-       return (package_gbar_type(inst->info) == GBAR_TYPE_BUFFER) ? inst->gbar.canvas.buffer : NULL;
-}
-
-HAPI struct buffer_info *const instance_widget_extra_buffer(const struct inst_info *inst, int idx)
-{
-       return (package_widget_type(inst->info) == WIDGET_TYPE_BUFFER) ? (inst->widget.extra_buffer ? inst->widget.extra_buffer[idx] : NULL) : NULL;
-}
-
-HAPI struct buffer_info *const instance_gbar_extra_buffer(const struct inst_info *inst, int idx)
-{
-       return (package_gbar_type(inst->info) == GBAR_TYPE_BUFFER) ? (inst->gbar.extra_buffer ? inst->gbar.extra_buffer[idx] : NULL) : NULL;
-}
-
-HAPI const char *const instance_id(const struct inst_info *inst)
-{
-       return inst->id;
-}
-
-HAPI const char *const instance_content(const struct inst_info *inst)
-{
-       return inst->content;
-}
-
-HAPI const char *const instance_category(const struct inst_info *inst)
-{
-       return inst->category;
-}
-
-HAPI const char *const instance_cluster(const struct inst_info *inst)
-{
-       return inst->cluster;
-}
-
-HAPI const char * const instance_title(const struct inst_info *inst)
-{
-       return inst->title;
-}
-
-HAPI const double const instance_timestamp(const struct inst_info *inst)
-{
-       return inst->timestamp;
-}
-
-HAPI const enum instance_state const instance_state(const struct inst_info *inst)
-{
-       return inst->state;
-}
-
-HAPI int instance_destroyed(struct inst_info *inst, int reason)
-{
-       switch (inst->state) {
-       case INST_INIT:
-       case INST_REQUEST_TO_ACTIVATE:
-               if (inst->unicast_delete_event) {
-                       /*!
-                        * \note
-                        * No other clients know the existence of this instance,
-                        * only who added this knows it.
-                        * So send deleted event to only it.
-                        */
-                       DbgPrint("Send deleted event - unicast - %p\n", inst->client);
-                       instance_unicast_deleted_event(inst, NULL, reason);
-               } else {
-                       instance_broadcast_deleted_event(inst, reason);
-               }
-               instance_state_reset(inst);
-               instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-               break;
-       case INST_REQUEST_TO_REACTIVATE:
-       case INST_REQUEST_TO_DESTROY:
-       case INST_ACTIVATED:
-               DbgPrint("Send deleted event - multicast\n");
-               instance_broadcast_deleted_event(inst, reason);
-               instance_state_reset(inst);
-               instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-       case INST_DESTROYED:
-               break;
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-/*!
- * Invoked when a slave is activated
- */
-HAPI int instance_recover_state(struct inst_info *inst)
-{
-       int ret = 0;
-
-       if (inst->changing_state > 0) {
-               DbgPrint("Doesn't need to recover the state\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (package_is_fault(inst->info)) {
-               ErrPrint("Package is faulted(%s), Delete it\n", inst->id);
-               inst->requested_state = INST_DESTROYED;
-       }
-
-       switch (inst->state) {
-       case INST_ACTIVATED:
-       case INST_REQUEST_TO_REACTIVATE:
-       case INST_REQUEST_TO_DESTROY:
-               switch (inst->requested_state) {
-               case INST_ACTIVATED:
-                       DbgPrint("Req. to RE-ACTIVATED (%s)\n", package_name(inst->info));
-                       instance_state_reset(inst);
-                       instance_reactivate(inst);
-                       ret = 1;
-                       break;
-               case INST_DESTROYED:
-                       DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info));
-                       instance_state_reset(inst);
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-                       break;
-               default:
-                       break;
-               }
-               break;
-       case INST_INIT:
-       case INST_REQUEST_TO_ACTIVATE:
-               switch (inst->requested_state) {
-               case INST_ACTIVATED:
-               case INST_INIT:
-                       DbgPrint("Req. to ACTIVATED (%s)\n", package_name(inst->info));
-                       instance_state_reset(inst);
-                       if (instance_activate(inst) < 0) {
-                               DbgPrint("Failed to reactivate the instance\n");
-                               instance_broadcast_deleted_event(inst, WIDGET_ERROR_FAULT);
-                               instance_state_reset(inst);
-                               instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-                       } else {
-                               ret = 1;
-                       }
-                       break;
-               case INST_DESTROYED:
-                       DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info));
-                       instance_state_reset(inst);
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-                       break;
-               default:
-                       break;
-               }
-               break;
-       case INST_DESTROYED:
-       default:
-               break;
-       }
-
-       return ret;
-}
-
-/*!
- * Invoked when a slave is deactivated
- */
-HAPI int instance_need_slave(struct inst_info *inst)
-{
-       int ret = 0;
-
-       if (inst->client && client_is_faulted(inst->client)) {
-               /*!
-                * \note
-                * In this case, the client is faulted(disconnected)
-                * when the client is deactivated, its widgetes should be removed too.
-                * So if the current inst is created by the faulted client,
-                * remove it and don't try to recover its states
-                */
-
-               DbgPrint("CLIENT FAULT: Req. to DESTROYED (%s)\n", package_name(inst->info));
-               switch (inst->state) {
-               case INST_INIT:
-               case INST_ACTIVATED:
-               case INST_REQUEST_TO_REACTIVATE:
-               case INST_REQUEST_TO_DESTROY:
-               case INST_REQUEST_TO_ACTIVATE:
-                       instance_state_reset(inst);
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-                       break;
-               case INST_DESTROYED:
-                       break;
-               }
-
-               return WIDGET_ERROR_NONE;
-       }
-
-       switch (inst->state) {
-       case INST_ACTIVATED:
-       case INST_REQUEST_TO_REACTIVATE:
-       case INST_REQUEST_TO_DESTROY:
-               switch (inst->requested_state) {
-               case INST_INIT:
-               case INST_ACTIVATED:
-                       DbgPrint("Req. to ACTIVATED (%s)\n", package_name(inst->info));
-                       ret = 1;
-                       break;
-               case INST_DESTROYED:
-                       DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info));
-                       instance_state_reset(inst);
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-                       break;
-               default:
-                       break;
-               }
-               break;
-       case INST_INIT:
-       case INST_REQUEST_TO_ACTIVATE:
-               switch (inst->requested_state) {
-               case INST_INIT:
-               case INST_ACTIVATED:
-                       DbgPrint("Req. to ACTIVATED (%s)\n", package_name(inst->info));
-                       ret = 1;
-                       break;
-               case INST_DESTROYED:
-                       DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info));
-                       instance_state_reset(inst);
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-                       break;
-               default:
-                       break;
-               }
-               break;
-       case INST_DESTROYED:
-       default:
-               break;
-       }
-
-       return ret;
-}
-
-HAPI int instance_forward_packet(struct inst_info *inst, struct packet *packet)
-{
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI int instance_send_key_status(struct inst_info *inst, int status)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_KEY_STATUS;
-
-       packet = packet_create_noack((const char *)&cmd, "ssi", package_name(inst->info), inst->id, status);
-       if (!packet) {
-               ErrPrint("Failed to build a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI int instance_send_access_status(struct inst_info *inst, int status)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_ACCESS_STATUS;
-
-       packet = packet_create_noack((const char *)&cmd, "ssi", package_name(inst->info), inst->id, status);
-       if (!packet) {
-               ErrPrint("Failed to build a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI void instance_slave_set_gbar_pos(struct inst_info *inst, double x, double y)
-{
-       inst->gbar.x = x;
-       inst->gbar.y = y;
-}
-
-HAPI void instance_slave_get_gbar_pos(struct inst_info *inst, double *x, double *y)
-{
-       if (x) {
-               *x = inst->gbar.x;
-       }
-
-       if (y) {
-               *y = inst->gbar.y;
-       }
-}
-
-HAPI int instance_slave_open_gbar(struct inst_info *inst, struct client_node *client)
-{
-       const char *pkgname;
-       const char *id;
-       struct packet *packet;
-       struct slave_node *slave;
-       const struct pkg_info *info;
-       unsigned int cmd = CMD_GBAR_SHOW;
-       int ret;
-
-       if (!client) {
-               client = inst->gbar.owner;
-               if (!client) {
-                       ErrPrint("Client is not valid\n");
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-       } else if (inst->gbar.owner) {
-               if (inst->gbar.owner != client) {
-                       ErrPrint("Client is already owned\n");
-                       return WIDGET_ERROR_ALREADY_EXIST;
-               }
-       }
-
-       info = instance_package(inst);
-       if (!info) {
-               ErrPrint("No package info\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       slave = package_slave(info);
-       if (!slave) {
-               ErrPrint("No slave\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       pkgname = package_name(info);
-       id = instance_id(inst);
-
-       if (!pkgname || !id) {
-               ErrPrint("pkgname[%s] id[%s]\n", pkgname, id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssiidd", pkgname, id, instance_gbar_width(inst), instance_gbar_height(inst), inst->gbar.x, inst->gbar.y);
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       /*!
-        * \note
-        * Do not return from here even though we failed to freeze the TTL timer.
-        * Because the TTL timer is not able to be exists.
-        * So we can ignore this error.
-        */
-       (void)slave_freeze_ttl(slave);
-
-       DbgPrint("PERF_WIDGET\n");
-       ret = slave_rpc_request_only(slave, pkgname, packet, 0);
-       if (ret < 0) {
-               ErrPrint("Unable to send request to slave\n");
-               /*!
-                * \note
-                * Also we can ignore the TTL timer at here too ;)
-                */
-               (void)slave_thaw_ttl(slave);
-               return ret;
-       }
-
-       /*!
-        * \note
-        * If a client is disconnected, the slave has to close the GBAR
-        * So the gbar_buffer_close_cb/gbar_script_close_cb will catch the disconnection event
-        * then it will send the close request to the slave
-        */
-       if (package_gbar_type(info) == GBAR_TYPE_BUFFER) {
-               instance_ref(inst);
-               if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, gbar_buffer_close_cb, inst) < 0) {
-                       instance_unref(inst);
-               }
-       } else if (package_gbar_type(info) == GBAR_TYPE_SCRIPT) {
-               instance_ref(inst);
-               if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, gbar_script_close_cb, inst) < 0) {
-                       instance_unref(inst);
-               }
-       }
-
-       inst->gbar.owner = client;
-       return ret;
-}
-
-HAPI int instance_slave_close_gbar(struct inst_info *inst, struct client_node *client, int reason)
-{
-       const char *pkgname;
-       const char *id;
-       struct packet *packet;
-       struct slave_node *slave;
-       struct pkg_info *pkg;
-       unsigned int cmd = CMD_GBAR_HIDE;
-       int ret;
-
-       if (inst->gbar.owner != client) {
-               ErrPrint("Has no permission\n");
-               return WIDGET_ERROR_PERMISSION_DENIED;
-       }
-
-       pkg = instance_package(inst);
-       if (!pkg) {
-               ErrPrint("No package info\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               ErrPrint("No assigned slave\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       pkgname = package_name(pkg);
-       id = instance_id(inst);
-
-       if (!pkgname || !id) {
-               ErrPrint("pkgname[%s] & id[%s] is not valid\n", pkgname, id);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssi", pkgname, id, reason);
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       slave_thaw_ttl(slave);
-
-       ret = slave_rpc_request_only(slave, pkgname, packet, 0);
-       release_resource_for_closing_gbar(pkg, inst, client);
-       inst->gbar.owner = NULL;
-       DbgPrint("PERF_WIDGET\n");
-       return ret;
-}
-
-HAPI int instance_client_gbar_created(struct inst_info *inst, int status)
-{
-       struct packet *packet;
-       const char *buf_id;
-       unsigned int cmd = CMD_GBAR_CREATED;
-       int ret;
-
-       if (inst->gbar.need_to_send_close_event) {
-               DbgPrint("GBAR is already created\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (package_gbar_type(inst->info)) {
-       case GBAR_TYPE_SCRIPT:
-               buf_id = script_handler_buffer_id(inst->gbar.canvas.script);
-               break;
-       case GBAR_TYPE_BUFFER:
-               buf_id = buffer_handler_id(inst->gbar.canvas.buffer);
-               break;
-       case GBAR_TYPE_TEXT:
-       default:
-               buf_id = "";
-               break;
-       }
-
-       inst->gbar.need_to_send_close_event = (status == 0);
-
-       packet = packet_create_noack((const char *)&cmd, "sssiii", 
-                       package_name(inst->info), inst->id, buf_id,
-                       inst->gbar.width, inst->gbar.height, status);
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       ret = client_send_event(inst, packet, NULL);
-
-       if (inst->gbar.need_to_send_close_event && inst->gbar.pended_update_cnt) {
-               DbgPrint("Apply pended desc(%d) - %s\n", inst->gbar.pended_update_cnt, inst->gbar.pended_update_desc);
-               instance_gbar_updated_by_instance(inst, inst->gbar.pended_update_desc, 0, 0, inst->gbar.width, inst->gbar.height);
-               inst->gbar.pended_update_cnt = 0;
-               DbgFree(inst->gbar.pended_update_desc);
-               inst->gbar.pended_update_desc = NULL;
-       }
-
-       return ret;
-}
-
-HAPI int instance_client_gbar_destroyed(struct inst_info *inst, int status)
-{
-       return send_gbar_destroyed_to_client(inst, status);
-}
-
-HAPI int instance_client_gbar_extra_buffer_created(struct inst_info *inst, int idx)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_GBAR_CREATE_XBUF;
-       int pixmap;
-
-       pixmap = buffer_handler_pixmap(inst->gbar.extra_buffer[idx]);
-       if (pixmap == 0) {
-               ErrPrint("Invalid buffer\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI int instance_client_gbar_extra_buffer_destroyed(struct inst_info *inst, int idx)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_GBAR_DESTROY_XBUF;
-       int pixmap;
-
-       pixmap = buffer_handler_pixmap(inst->gbar.extra_buffer[idx]);
-       if (pixmap == 0) {
-               ErrPrint("Invalid buffer\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI int instance_client_widget_extra_buffer_created(struct inst_info *inst, int idx)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_WIDGET_CREATE_XBUF;
-       int pixmap;
-
-       pixmap = buffer_handler_pixmap(inst->widget.extra_buffer[idx]);
-       if (pixmap == 0) {
-               ErrPrint("Invalid buffer\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_send_event(inst, packet, NULL);
-}
-
-HAPI int instance_client_widget_extra_buffer_destroyed(struct inst_info *inst, int idx)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_WIDGET_DESTROY_XBUF;
-       int pixmap;
-
-       pixmap = buffer_handler_pixmap(inst->widget.extra_buffer[idx]);
-       if (pixmap == 0) {
-               ErrPrint("Invalid buffer\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssii", package_name(inst->info), inst->id, pixmap, idx);
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return client_send_event(inst, packet, NULL);
-}
-
-/**
- * \note
- *  this function will be called after checking the list.
- *  only if the client is not in the list, this will be called.
- */
-HAPI int instance_add_client(struct inst_info *inst, struct client_node *client)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_VIEWER_CONNECTED;
-
-       if (inst->client == client) {
-               ErrPrint("Owner cannot be the viewer\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       DbgPrint("%d is added to the list of viewer of %s(%s)\n", client_pid(client), package_name(instance_package(inst)), instance_id(inst));
-       if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, viewer_deactivated_cb, inst) < 0) {
-               ErrPrint("Failed to add a deactivate callback\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "sss", package_name(inst->info), inst->id, client_direct_addr(inst->client));
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, viewer_deactivated_cb, inst);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       instance_ref(inst);
-       inst->client_list = eina_list_append(inst->client_list, client);
-
-       return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0);
-}
-
-HAPI int instance_del_client(struct inst_info *inst, struct client_node *client)
-{
-       if (inst->client == client) {
-               ErrPrint("Owner is not in the viewer list\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, viewer_deactivated_cb, inst);
-       viewer_deactivated_cb(client, inst);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int instance_has_client(struct inst_info *inst, struct client_node *client)
-{
-       return !!eina_list_data_find(inst->client_list, client);
-}
-
-HAPI void *instance_client_list(struct inst_info *inst)
-{
-       return inst->client_list;
-}
-
-HAPI int instance_init(void)
-{
-       if (!strcasecmp(WIDGET_CONF_PROVIDER_METHOD, "shm")) {
-               s_info.env_buf_type = WIDGET_FB_TYPE_SHM;
-       } else if (!strcasecmp(WIDGET_CONF_PROVIDER_METHOD, "pixmap")) {
-               s_info.env_buf_type = WIDGET_FB_TYPE_PIXMAP;
-       }
-       /* Default method is WIDGET_FB_TYPE_FILE */
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int instance_fini(void)
-{
-       return WIDGET_ERROR_NONE;
-}
-
-static inline struct tag_item *find_tag_item(struct inst_info *inst, const char *tag)
-{
-       struct tag_item *item;
-       Eina_List *l;
-
-       EINA_LIST_FOREACH(inst->data_list, l, item) {
-               if (!strcmp(item->tag, tag)) {
-                       return item;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI int instance_set_data(struct inst_info *inst, const char *tag, void *data)
-{
-       struct tag_item *item;
-
-       item = find_tag_item(inst, tag);
-       if (!item) {
-               item = malloc(sizeof(*item));
-               if (!item) {
-                       ErrPrint("malloc: %d\n", errno);
-                       return WIDGET_ERROR_OUT_OF_MEMORY;
-               }
-
-               item->tag = strdup(tag);
-               if (!item->tag) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(item);
-                       return WIDGET_ERROR_OUT_OF_MEMORY;
-               }
-
-               inst->data_list = eina_list_append(inst->data_list, item);
-       }
-
-       if (!data) {
-               inst->data_list = eina_list_remove(inst->data_list, item);
-               DbgFree(item->tag);
-               DbgFree(item);
-       } else {
-               item->data = data;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void *instance_del_data(struct inst_info *inst, const char *tag)
-{
-       struct tag_item *item;
-       void *data;
-
-       item = find_tag_item(inst, tag);
-       if (!item) {
-               return NULL;
-       }
-
-       inst->data_list = eina_list_remove(inst->data_list, item);
-       data = item->data;
-       DbgFree(item->tag);
-       DbgFree(item);
-
-       return data;
-}
-
-HAPI void *instance_get_data(struct inst_info *inst, const char *tag)
-{
-       struct tag_item *item;
-
-       item = find_tag_item(inst, tag);
-       if (!item) {
-               return NULL;
-       }
-
-       return item->data;
-}
-
-HAPI struct client_node *instance_gbar_owner(struct inst_info *inst)
-{
-       return inst->gbar.owner;
-}
-
-HAPI void instance_set_orientation(struct inst_info *inst, int degree)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_ORIENTATION;
-
-       if (inst->orientation == degree) {
-               return;
-       }
-
-       inst->orientation = degree;
-
-       packet = packet_create_noack((const char *)&cmd, "ssi", package_name(inst->info), inst->id, degree);
-       if (!packet) {
-               ErrPrint("Failed to create a new packet\n");
-               return;
-       }
-
-       if (slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0) != WIDGET_ERROR_NONE) {
-               /* packet will be destroyed by slave_rpc_request_only if it fails */
-               ErrPrint("Failed to send a request\n");
-       }
-
-       return;
-}
-
-HAPI int instance_orientation(struct inst_info *inst)
-{
-       return inst->orientation;
-}
-
-HAPI void instance_watch_set_need_to_recover(struct inst_info *inst, int recover)
-{
-       inst->watch.need_to_recover = !!recover;
-}
-
-HAPI int instance_watch_need_to_recover(struct inst_info *inst)
-{
-       return inst->watch.need_to_recover;
-}
-
-HAPI int instance_watch_change_package_info(struct inst_info *inst, struct pkg_info *info)
-{
-       if (inst->info == info) {
-               DbgPrint("Package information is not touched (%s)\n", package_name(inst->info));
-               return WIDGET_ERROR_NONE;
-       }
-
-       DbgPrint("Instance[%p (%s)], info[%p (%s)]\n",
-                       inst->info, inst->info ? package_name(inst->info) : "unknown",
-                       info, info ? package_name(info) : "unknown");
-       /**
-        * @todo
-        * Handling me, if the instance has package info, it means, this instance is changed its package info...
-        */
-       if (inst->info != info) {
-               if (inst->info) {
-                       ErrPrint("[%s] is already specified for [%s]\n", package_name(inst->info), instance_id(inst));
-                       /**
-                        * @note
-                        * In this case, please handling me, we have to update package info's instance list in this case.
-                        */
-               }
-
-               ErrPrint("Package info is changed to [%s]\n", package_name(info));
-       }
-
-       inst->info = info;
-       return WIDGET_ERROR_NONE;
-}
-
-/* End of a file */
diff --git a/src/io.c b/src/io.c
deleted file mode 100644 (file)
index d5316d4..0000000
--- a/src/io.c
+++ /dev/null
@@ -1,728 +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 <errno.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include <dlog.h>
-#include <Eina.h>
-#include <sqlite3.h>
-#include <db-util.h>
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_conf.h>
-
-#include "debug.h"
-#include "conf.h"
-#include "parser.h"
-#include "group.h"
-#include "util.h"
-#include "client_life.h"
-#include "slave_life.h"
-#include "package.h"
-#include "io.h"
-
-int errno;
-
-static struct {
-       sqlite3 *handle;
-} s_info = {
-       .handle = NULL,
-};
-
-static inline int build_client_info(struct pkg_info *info)
-{
-       static const char *dml = "SELECT auto_launch, gbar_size FROM client WHERE pkgid = ?";
-       sqlite3_stmt *stmt;
-       int width;
-       int height;
-       int ret;
-       const char *tmp;
-
-       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       ret = sqlite3_bind_text(stmt, 1, package_name(info), -1, SQLITE_TRANSIENT);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Failed to bind a pkgname %s\n", package_name(info));
-               sqlite3_finalize(stmt);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       if (sqlite3_step(stmt) != SQLITE_ROW) {
-               ErrPrint("%s has no records (%s)\n", package_name(info), sqlite3_errmsg(s_info.handle));
-               sqlite3_reset(stmt);
-               sqlite3_clear_bindings(stmt);
-               sqlite3_finalize(stmt);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       package_set_auto_launch(info, (const char *)sqlite3_column_text(stmt, 0));
-
-       tmp = (const char *)sqlite3_column_text(stmt, 1);
-       if (tmp && strlen(tmp)) {
-               if (sscanf(tmp, "%dx%d", &width, &height) != 2) {
-                       ErrPrint("Failed to get GBAR width and Height (%s)\n", tmp);
-               } else {
-                       package_set_gbar_width(info, width);
-                       package_set_gbar_height(info, height);
-               }
-       }
-
-       sqlite3_reset(stmt);
-       sqlite3_clear_bindings(stmt);
-       sqlite3_finalize(stmt);
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int build_provider_info(struct pkg_info *info)
-{
-       static const char *dml = "SELECT provider.network, provider.abi, provider.secured, provider.box_type, provider.box_src, provider.box_group, provider.gbar_type, provider.gbar_src, provider.gbar_group, provider.libexec, provider.timeout, provider.period, provider.script, provider.pinup, pkgmap.appid, provider.direct_input, provider.hw_acceleration, pkgmap.category, provider.auto_align FROM provider, pkgmap WHERE pkgmap.pkgid = ? AND provider.pkgid = ?";
-       sqlite3_stmt *stmt;
-       int ret;
-       const char *tmp;
-       const char *appid;
-
-       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       if (sqlite3_bind_text(stmt, 1, package_name(info), -1, SQLITE_TRANSIENT) != SQLITE_OK) {
-               ErrPrint("Failed to bind a pkgname(%s) - %s\n", package_name(info), sqlite3_errmsg(s_info.handle));
-               sqlite3_finalize(stmt);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       if (sqlite3_bind_text(stmt, 2, package_name(info), -1, SQLITE_TRANSIENT) != SQLITE_OK) {
-               ErrPrint("Failed to bind a pkgname(%s) - %s\n", package_name(info), sqlite3_errmsg(s_info.handle));
-               sqlite3_finalize(stmt);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       if (sqlite3_step(stmt) != SQLITE_ROW) {
-               ErrPrint("%s has no record(%s)\n", package_name(info), sqlite3_errmsg(s_info.handle));
-               sqlite3_reset(stmt);
-               sqlite3_clear_bindings(stmt);
-               sqlite3_finalize(stmt);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       appid = (const char *)sqlite3_column_text(stmt, 14);
-       if (!appid || !strlen(appid)) {
-               ErrPrint("Failed to execute the DML for %s\n", package_name(info));
-               sqlite3_reset(stmt);
-               sqlite3_clear_bindings(stmt);
-               sqlite3_finalize(stmt);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       package_set_network(info, sqlite3_column_int(stmt, 0));
-       package_set_secured(info, sqlite3_column_int(stmt, 2));
-
-       tmp = (const char *)sqlite3_column_text(stmt, 1);
-       if (tmp && strlen(tmp)) {
-               package_set_abi(info, tmp);
-       }
-
-       package_set_widget_type(info, sqlite3_column_int(stmt, 3));
-       tmp = (const char *)sqlite3_column_text(stmt, 4);
-       if (tmp && strlen(tmp)) {
-               package_set_widget_path(info, tmp);
-
-               tmp = (const char *)sqlite3_column_text(stmt, 5);
-               if (tmp && strlen(tmp)) {
-                       package_set_widget_group(info, tmp);
-               }
-       }
-
-       package_set_gbar_type(info, sqlite3_column_int(stmt, 6));
-       tmp = (const char *)sqlite3_column_text(stmt, 7);
-       if (tmp && strlen(tmp)) {
-               package_set_gbar_path(info, tmp);
-
-               tmp = (const char *)sqlite3_column_text(stmt, 8);
-               if (tmp && strlen(tmp)) {
-                       package_set_gbar_group(info, tmp);
-               }
-       }
-
-       tmp = (const char *)sqlite3_column_text(stmt, 9);
-       if (tmp && strlen(tmp)) {
-               package_set_libexec(info, tmp);
-       }
-
-       package_set_timeout(info, sqlite3_column_int(stmt, 10));
-
-       tmp = (const char *)sqlite3_column_text(stmt, 11);
-       if (tmp && strlen(tmp)) {
-               package_set_period(info, atof(tmp));
-       }
-
-       tmp = (const char *)sqlite3_column_text(stmt, 12);
-       if (tmp && strlen(tmp)) {
-               package_set_script(info, tmp);
-       }
-
-       package_set_pinup(info, sqlite3_column_int(stmt, 13));
-       package_set_direct_input(info, sqlite3_column_int(stmt, 15));
-       package_set_hw_acceleration(info, (const char *)sqlite3_column_text(stmt, 16));
-       package_set_category(info, (const char *)sqlite3_column_text(stmt, 17));
-       package_set_auto_align(info, sqlite3_column_int(stmt, 18));
-
-       sqlite3_reset(stmt);
-       sqlite3_clear_bindings(stmt);
-       sqlite3_finalize(stmt);
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int build_box_size_info(struct pkg_info *info)
-{
-       static const char *dml = "SELECT size_type FROM box_size WHERE pkgid = ?";
-       sqlite3_stmt *stmt;
-       int ret;
-       unsigned int size_type;
-       unsigned int size_list;
-
-       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       if (sqlite3_bind_text(stmt, 1, package_name(info), -1, SQLITE_TRANSIENT) != SQLITE_OK) {
-               ErrPrint("Failed to bind a pkgname(%s) - %s\n", package_name(info), sqlite3_errmsg(s_info.handle));
-               sqlite3_finalize(stmt);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       size_list = 0;
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               size_type = sqlite3_column_int(stmt, 0);
-               size_list |= size_type;
-       }
-
-       package_set_size_list(info, size_list);
-
-       sqlite3_reset(stmt);
-       sqlite3_clear_bindings(stmt);
-       sqlite3_finalize(stmt);
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int load_context_option(struct context_item *item, int id)
-{
-       static const char *dml = "SELECT key, value FROM option WHERE option_id = ?";
-       sqlite3_stmt *stmt;
-       const char *key;
-       const char *value;
-       int ret;
-
-       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       ret = sqlite3_bind_int(stmt, 1, id);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               ret = WIDGET_ERROR_IO_ERROR;
-               goto out;
-       }
-
-       ret = WIDGET_ERROR_NOT_EXIST;
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               key = (const char *)sqlite3_column_text(stmt, 0);
-               if (!key || !strlen(key)) {
-                       ErrPrint("KEY is nil\n");
-                       continue;
-               }
-
-               value = (const char *)sqlite3_column_text(stmt, 1);
-               if (!value || !strlen(value)) {
-                       ErrPrint("VALUE is nil\n");
-                       continue;
-               }
-
-               ret = group_add_option(item, key, value);
-               if (ret < 0) {
-                       break;
-               }
-       }
-
-out:
-       sqlite3_reset(stmt);
-       sqlite3_clear_bindings(stmt);
-       sqlite3_finalize(stmt);
-       return ret;
-}
-
-static inline int load_context_item(struct context_info *info, int id)
-{
-       static const char *dml = "SELECT ctx_item, option_id FROM groupmap WHERE id = ?";
-       struct context_item *item;
-       sqlite3_stmt *stmt;
-       const char *ctx_item;
-       int option_id;
-       int ret;
-
-       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       ret = sqlite3_bind_int(stmt, 1, id);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               ret = WIDGET_ERROR_IO_ERROR;
-               goto out;
-       }
-
-       ret = WIDGET_ERROR_NOT_EXIST;
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               ctx_item = (const char *)sqlite3_column_text(stmt, 0);
-               option_id = sqlite3_column_int(stmt, 1);
-
-               item = group_add_context_item(info, ctx_item);
-               if (!item) {
-                       ErrPrint("Failed to add a new context item\n");
-                       ret = WIDGET_ERROR_FAULT;
-                       break;
-               }
-
-               ret = load_context_option(item, option_id);
-               if (ret < 0) {
-                       break;
-               }
-       }
-
-out:
-       sqlite3_reset(stmt);
-       sqlite3_clear_bindings(stmt);
-       sqlite3_finalize(stmt);
-       return ret;
-}
-
-static inline int build_group_info(struct pkg_info *info)
-{
-       static const char *dml = "SELECT id, cluster, category FROM groupinfo WHERE pkgid = ?";
-       sqlite3_stmt *stmt;
-       int ret;
-       int id;
-       const char *cluster_name;
-       const char *category_name;
-       struct cluster *cluster;
-       struct category *category;
-       struct context_info *ctx_info;
-
-       ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       ret = sqlite3_bind_text(stmt, 1, package_name(info), -1, SQLITE_TRANSIENT);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Failed to bind a package name(%s)\n", package_name(info));
-               sqlite3_finalize(stmt);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               id = sqlite3_column_int(stmt, 0);
-               cluster_name = (const char *)sqlite3_column_text(stmt, 1);
-               if (!cluster_name || !strlen(cluster_name)) {
-                       DbgPrint("Cluster name is not valid\n");
-                       continue;
-               }
-
-               category_name = (const char *)sqlite3_column_text(stmt, 2);
-               if (!category_name || !strlen(category_name)) {
-                       DbgPrint("Category name is not valid\n");
-                       continue;
-               }
-
-               cluster = group_find_cluster(cluster_name);
-               if (!cluster) {
-                       cluster = group_create_cluster(cluster_name);
-                       if (!cluster) {
-                               ErrPrint("Failed to create a cluster(%s)\n", cluster_name);
-                               continue;
-                       }
-               }
-
-               category = group_find_category(cluster, category_name);
-               if (!category) {
-                       category = group_create_category(cluster, category_name);
-                       if (!category) {
-                               ErrPrint("Failed to create a category(%s)\n", category_name);
-                               continue;
-                       }
-               }
-
-               /*!
-                * \TODO
-                * Step 1. Get the list of the context item from the DB using 'id'
-                *         {context_item, option_id}
-                * Step 2. Get the list of the options from the DB using option_id
-                *         key, value
-                */
-               ctx_info = group_create_context_info(category, package_name(info));
-               if (ctx_info) {
-                       ret = load_context_item(ctx_info, id);
-                       if (ret < 0) {
-                               if (ret == (int)WIDGET_ERROR_NOT_EXIST) {
-                                       DbgPrint("Has no specific context info\n");
-                               } else {
-                                       DbgPrint("Context info is not valid\n");
-                                       group_destroy_context_info(ctx_info);
-                                       ctx_info = NULL;
-                               }
-                       }
-
-                       if (ctx_info) {
-                               package_add_ctx_info(info, ctx_info);
-                       }
-               }
-       }
-
-       sqlite3_reset(stmt);
-       sqlite3_clear_bindings(stmt);
-       sqlite3_finalize(stmt);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int io_is_exists(const char *lbid)
-{
-       sqlite3_stmt *stmt;
-       int ret;
-
-       if (!s_info.handle) {
-               ErrPrint("DB is not ready\n");
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       ret = sqlite3_prepare_v2(s_info.handle, "SELECT COUNT(pkgid) FROM pkgmap WHERE pkgid = ?", -1, &stmt, NULL);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       ret = sqlite3_bind_text(stmt, 1, lbid, -1, SQLITE_TRANSIENT);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               ret = WIDGET_ERROR_IO_ERROR;
-               goto out;
-       }
-
-       if (sqlite3_step(stmt) != SQLITE_ROW) {
-               ErrPrint("%s has no record (%s)\n", lbid, sqlite3_errmsg(s_info.handle));
-               ret = WIDGET_ERROR_IO_ERROR;
-               goto out;
-       }
-
-       ret = sqlite3_column_int(stmt, 0);
-out:
-       sqlite3_reset(stmt);
-       sqlite3_finalize(stmt);
-       return ret;
-}
-
-HAPI char *io_widget_pkgname(const char *pkgname)
-{
-       sqlite3_stmt *stmt;
-       char *pkgid;
-       char *tmp;
-       int ret;
-
-       pkgid = NULL;
-
-       if (!s_info.handle) {
-               ErrPrint("DB is not ready\n");
-               return NULL;
-       }
-
-       ret = sqlite3_prepare_v2(s_info.handle, "SELECT pkgid FROM pkgmap WHERE (appid = ? AND prime = 1) OR pkgid = ?", -1, &stmt, NULL);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               return NULL;
-       }
-
-       ret = sqlite3_bind_text(stmt, 1, pkgname, -1, SQLITE_TRANSIENT);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               goto out;
-       }
-
-       ret = sqlite3_bind_text(stmt, 2, pkgname, -1, SQLITE_TRANSIENT);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               goto out;
-       }
-
-       if (sqlite3_step(stmt) != SQLITE_ROW) {
-               ErrPrint("%s has no record (%s)\n", pkgname, sqlite3_errmsg(s_info.handle));
-               goto out;
-       }
-
-       tmp = (char *)sqlite3_column_text(stmt, 0);
-       if (tmp && strlen(tmp)) {
-               pkgid = strdup(tmp);
-               if (!pkgid) {
-                       ErrPrint("strdup: %d\n", errno);
-               }
-       }
-
-out:
-       sqlite3_reset(stmt);
-       sqlite3_finalize(stmt);
-       return pkgid;
-}
-
-HAPI int io_crawling_widgetes(int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data)
-{
-       DIR *dir;
-
-       if (!s_info.handle) {
-               ErrPrint("DB is not ready\n");
-       } else {
-               int ret;
-               sqlite3_stmt *stmt;
-
-               ret = sqlite3_prepare_v2(s_info.handle, "SELECT appid, pkgid, prime FROM pkgmap", -1, &stmt, NULL);
-               if (ret != SQLITE_OK) {
-                       ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               } else {
-                       const char *lbid;
-                       const char *pkgid;
-                       int prime;
-
-                       while (sqlite3_step(stmt) == SQLITE_ROW) {
-                               pkgid = (const char *)sqlite3_column_text(stmt, 0);
-                               if (!pkgid || !strlen(pkgid)) {
-                                       continue;
-                               }
-
-                               lbid = (const char *)sqlite3_column_text(stmt, 1);
-                               if (!lbid || !strlen(lbid)) {
-                                       continue;
-                               }
-
-                               prime = (int)sqlite3_column_int(stmt, 1);
-
-                               if (cb(pkgid, lbid, prime, data) < 0) {
-                                       sqlite3_reset(stmt);
-                                       sqlite3_finalize(stmt);
-                                       return WIDGET_ERROR_CANCELED;
-                               }
-                       }
-
-                       sqlite3_reset(stmt);
-                       sqlite3_finalize(stmt);
-               }
-       }
-
-       dir = opendir(WIDGET_CONF_ROOT_PATH);
-       if (!dir) {
-               ErrPrint("opendir: %d\n", errno);
-       } else {
-               struct dirent *ent;
-
-               while ((ent = readdir(dir))) {
-                       if (ent->d_name[0] == '.') {
-                               continue;
-                       }
-
-                       if (cb(ent->d_name, ent->d_name, -2, data) < 0) {
-                               if (closedir(dir) < 0) {
-                                       ErrPrint("closedir: %d\n", errno);
-                               }
-                               return WIDGET_ERROR_CANCELED;
-                       }
-               }
-
-               if (closedir(dir) < 0) {
-                       ErrPrint("closedir: %d\n", errno);
-               }
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int io_update_widget_package(const char *pkgid, int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data)
-{
-       sqlite3_stmt *stmt;
-       char *lbid;
-       int prime;
-       int ret;
-
-       if (!cb || !pkgid) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (!s_info.handle) {
-               ErrPrint("DB is not ready\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = sqlite3_prepare_v2(s_info.handle, "SELECT pkgid, prime FROM pkgmap WHERE appid = ?", -1, &stmt, NULL);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       ret = 0;
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               lbid = (char *)sqlite3_column_text(stmt, 0);
-               if (!lbid || !strlen(lbid)) {
-                       continue;
-               }
-
-               prime = sqlite3_column_int(stmt, 1);
-
-               if (cb(pkgid, lbid, prime, data) < 0) {
-                       DbgPrint("Callback canceled\n");
-                       break;
-               }
-
-               ret++;
-       }
-out:
-       sqlite3_reset(stmt);
-       sqlite3_finalize(stmt);
-       return ret;
-}
-
-HAPI int io_load_package_db(struct pkg_info *info)
-{
-       int ret;
-
-       if (!s_info.handle) {
-               ErrPrint("DB is not ready\n");
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       ret = build_provider_info(info);
-       if (ret < 0) {
-               return ret;
-       }
-
-       ret = build_client_info(info);
-       if (ret < 0) {
-               return ret;
-       }
-
-       ret = build_box_size_info(info);
-       if (ret < 0) {
-               return ret;
-       }
-
-       ret = build_group_info(info);
-       if (ret < 0) {
-               return ret;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int db_init(void)
-{
-       int ret;
-       struct stat stat;
-
-       ret = db_util_open_with_options(WIDGET_CONF_DBFILE, &s_info.handle, SQLITE_OPEN_READONLY, NULL);
-       if (ret != SQLITE_OK) {
-               ErrPrint("Failed to open a DB\n");
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       if (lstat(WIDGET_CONF_DBFILE, &stat) < 0) {
-               ErrPrint("lstat: %d\n", errno);
-               db_util_close(s_info.handle);
-               s_info.handle = NULL;
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       if (!S_ISREG(stat.st_mode)) {
-               ErrPrint("Invalid file\n");
-               db_util_close(s_info.handle);
-               s_info.handle = NULL;
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (stat.st_size <= 0) {
-               DbgPrint("Size is %d (But use this ;)\n", stat.st_size);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int db_fini(void)
-{
-       if (!s_info.handle) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       db_util_close(s_info.handle);
-       s_info.handle = NULL;
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int io_init(void)
-{
-       int ret;
-
-       ret = db_init();
-       if (ret < 0) {
-               DbgPrint("DB initialized: %d\n", ret);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int io_fini(void)
-{
-       int ret;
-
-       ret = db_fini();
-       if (ret < 0) {
-               DbgPrint("DB finalized: %d\n", ret);
-       }
-       return WIDGET_ERROR_NONE;
-}
-
-/* End of a file */
index 7a390fe..f6fbf8c 100644 (file)
 #include <packet.h>
 #include <dlog.h>
 
-#if defined(HAVE_LIVEBOX)
-
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_conf.h>
-#include <widget_util.h>
-#include <widget_abi.h>
-
-#include <com-core_packet.h>
-
-#include "slave_life.h"
-#include "slave_rpc.h"
-#include "client_life.h"
-#include "instance.h"
-#include "buffer_handler.h"
-#include "script_handler.h"
-#include "package.h"
-#include "group.h"
-#include "dead_monitor.h"
-#include "io.h"
-#include "xmonitor.h"
-#include "server.h"
-#include "event.h"
-#include "file_service.h"
-#include "utility_service.h"
-#endif
-
 #include "conf.h"
-#include "setting.h"
 #include "util.h"
 #include "debug.h"
 #include "critical_log.h"
 #include "shortcut_service.h"
 #include "notification_service.h"
 #include "badge_service.h"
-#include "shared_fd_service.h"
-
-#if defined(FLOG)
-#define TMP_LOG_FILE "/tmp/live.log"
-FILE *__file_log_fp;
-#endif
-
-#define WIDGET_STATIC_LOCK_PATH "/opt/usr/share/live_magazine/.widget.lck"
 
 static inline int app_create(void)
 {
        int ret;
 
-       if (access(WIDGET_CONF_LOG_PATH, R_OK | W_OK) != 0) {
-               if (mkdir(WIDGET_CONF_LOG_PATH, 0755) < 0) {
-                       ErrPrint("mkdir %s (%d)\n", WIDGET_CONF_LOG_PATH, errno);
-               }
-       }
-
-       /*!
-        * \note
-        * Dead signal handler has to be initialized before
-        * initate package or client (slave and client).
-        *
-        * Because while creating slaves for packages.
-        * It could be crashed before complete the initation stage.
-        *
-        * Then the dead callback should be invoked to handle it properly.
-        *
-        * To enable the dead signal handler,
-        * dead_init should be done before other components are initiated.
-        */
-       ret = setting_init();
-       if (ret < 0) {
-               DbgPrint("Setting initialized: %d\n", ret);
-       }
-
-#if defined(HAVE_LIVEBOX)
-       ret = client_init();
-       if (ret < 0) {
-               DbgPrint("Client initialized: %d\n", ret);
-       }
-
-       ret = dead_init();
-       if (ret < 0) {
-               DbgPrint("Dead callback is registered: %d\n", ret);
-       }
-
-       ret = group_init();
-       if (ret < 0) {
-               DbgPrint("group init: %d\n", ret);
-       }
-
-       ret = io_init();
-       if (ret < 0) {
-               DbgPrint("Init I/O: %d\n", ret);
-       }
-
-       ret = package_init();
-       if (ret < 0) {
-               DbgPrint("pkgmgr initialized: %d\n", ret);
-       }
-
-       instance_init();
-
-       ret = xmonitor_init();
+       ret = shortcut_service_init();
        if (ret < 0) {
-               DbgPrint("XMonitor init is done: %d\n", ret);
+               DbgPrint("shortcut: %d\n", ret);
        }
 
-       ret = buffer_handler_init();
+       ret = notification_service_init();
        if (ret < 0) {
-               DbgPrint("Buffer handler init is done: %d\n", ret);
+               DbgPrint("noti: %d\n", ret);
        }
 
-       /**
-        * @note
-        * Use thread mode must has to be initialized before server or client initialization.
-        */
-       com_core_packet_use_thread(WIDGET_CONF_COM_CORE_THREAD);
 
-       ret = shared_fd_service_init();
-       if (ret < 0) {
-               DbgPrint("Shared FD service init is done: %d\n", ret);
-       }
-
-       /*!
-        * \note
-        * After initiate all other sub-systtems,
-        * Enable the server socket.
-        */
-       ret = server_init();
+       ret = badge_service_init();
        if (ret < 0) {
-               DbgPrint("Server initialized: %d\n", ret);
-       }
-
-       event_init();
-
-       script_init();
-
-       if (util_service_is_enabled(WIDGET_CONF_SERVICE_FILE)) {
-               file_service_init();
-       }
-
-       if (util_service_is_enabled(WIDGET_CONF_SERVICE_UTILITY)) {
-               utility_service_init();
-       }
-#endif
-
-       if (util_service_is_enabled(WIDGET_CONF_SERVICE_SHORTCUT)) {
-               shortcut_service_init();
-       }
-
-       if (util_service_is_enabled(WIDGET_CONF_SERVICE_NOTIFICATION)) {
-               notification_service_init();
-       }
-
-       if (util_service_is_enabled(WIDGET_CONF_SERVICE_BADGE)) {
-               badge_service_init();
+               DbgPrint("badge: %d\n", ret);
        }
 
        return 0;
@@ -198,102 +69,21 @@ static inline int app_terminate(void)
 {
        int ret;
 
-       if (util_service_is_enabled(WIDGET_CONF_SERVICE_BADGE)) {
-               ret = badge_service_fini();
-               if (ret < 0) {
-                       DbgPrint("badge: %d\n", ret);
-               }
-       }
-
-       if (util_service_is_enabled(WIDGET_CONF_SERVICE_NOTIFICATION)) {
-               ret = notification_service_fini();
-               if (ret < 0) {
-                       DbgPrint("noti: %d\n", ret);
-               }
-       }
-
-       if (util_service_is_enabled(WIDGET_CONF_SERVICE_SHORTCUT)) {
-               ret = shortcut_service_fini();
-               if (ret < 0) {
-                       DbgPrint("shortcut: %d\n", ret);
-               }
-       }
-
-#if defined(HAVE_LIVEBOX)
-       if (util_service_is_enabled(WIDGET_CONF_SERVICE_FILE)) {
-               ret = file_service_fini();
-               if (ret < 0) {
-                       DbgPrint("Finalize the file service: %d\n", ret);
-               }
-       }
-
-       ret = server_fini();
-       if (ret < 0) {
-               DbgPrint("Finalize server: %d\n", ret);
-       }
-
-       ret = shared_fd_service_fini();
-       if (ret < 0) {
-               DbgPrint("Finalize shared service: %d\n", ret);
-       }
-
-       ret = dead_fini();
-       if (ret < 0) {
-               DbgPrint("dead signal handler finalized: %d\n", ret);
-       }
-
-       if (util_service_is_enabled(WIDGET_CONF_SERVICE_UTILITY)) {
-               ret = utility_service_fini();
-               if (ret < 0) {
-                       DbgPrint("utility: %d\n", ret);
-               }
-       }
-
-       ret = event_fini();
-       if (ret < 0) {
-               DbgPrint("event: %d\n", ret);
-       }
-
-       ret = setting_fini();
-       if (ret < 0) {
-               DbgPrint("Finalize setting : %d\n", ret);
-       }
-
-       ret = instance_fini();
-       if (ret < 0) {
-               DbgPrint("Finalizing instances: %d\n", ret);
-       }
-
-       ret = package_fini();
+       ret = badge_service_fini();
        if (ret < 0) {
-               DbgPrint("Finalize package info: %d\n", ret);
+               DbgPrint("badge: %d\n", ret);
        }
 
-       ret = script_fini();
+       ret = notification_service_fini();
        if (ret < 0) {
-               DbgPrint("script: %d\n", ret);
+               DbgPrint("noti: %d\n", ret);
        }
 
-       ret = buffer_handler_fini();
+       ret = shortcut_service_fini();
        if (ret < 0) {
-               DbgPrint("buffer handler: %d\n", ret);
+               DbgPrint("shortcut: %d\n", ret);
        }
 
-       xmonitor_fini();
-
-       client_fini();
-
-       ret = io_fini();
-       if (ret < 0) {
-               DbgPrint("IO finalized: %d\n", ret);
-       }
-
-       ret = group_fini();
-       if (ret < 0) {
-               DbgPrint("Group finalized: %d\n", ret);
-       }
-#endif
-
        DbgPrint("Terminated\n");
        return 0;
 }
@@ -331,24 +121,6 @@ static Eina_Bool signal_cb(void *data, Ecore_Fd_Handler *handler)
                vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
                //exit(0);
                ecore_main_loop_quit();
-       } else if (fdsi.ssi_signo == SIGUSR1) {
-               /*!
-                * Turn off auto-reactivation
-                * Terminate all slaves
-                */
-#if defined(HAVE_LIVEBOX)
-               CRITICAL_LOG("USRS1, Deactivate ALL\n");
-               slave_deactivate_all(0, 1, 1);
-#endif
-       } else if (fdsi.ssi_signo == SIGUSR2) {
-               /*!
-                * Turn on auto-reactivation
-                * Launch all slaves again
-                */
-#if defined(HAVE_LIVEBOX)
-               CRITICAL_LOG("USR2, Activate ALL\n");
-               slave_activate_all();
-#endif
        } else {
                CRITICAL_LOG("Unknown SIG[%d] received\n", fdsi.ssi_signo);
        }
@@ -363,13 +135,6 @@ int main(int argc, char *argv[])
        sigset_t mask;
        Ecore_Fd_Handler *signal_handler = NULL;
 
-#if defined(FLOG)
-       __file_log_fp = fopen(TMP_LOG_FILE, "w+t");
-       if (!__file_log_fp) {
-               __file_log_fp = fdopen(1, "w+t");
-       }
-#endif
-
        /* appcore_agent_terminate */
        if (ecore_init() <= 0) {
                return -EFAULT;
@@ -381,27 +146,7 @@ int main(int argc, char *argv[])
        g_type_init();
 #endif
 
-       if (util_screen_init() <= 0) {
-               ecore_shutdown();
-               return -EFAULT;
-       }
-
-       widget_conf_init();
-       widget_conf_set_search_input_node(1);
-       widget_conf_load();
-       widget_abi_init();
-
-       if (vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count) < 0 || restart_count == 0) {
-               /*!
-                * \note
-                * Clear old contents files before start the master provider.
-                */
-               (void)util_unlink_files(WIDGET_CONF_ALWAYS_PATH);
-               (void)util_unlink_files(WIDGET_CONF_READER_PATH);
-               (void)util_unlink_files(WIDGET_CONF_IMAGE_PATH);
-               (void)util_unlink_files(WIDGET_CONF_LOG_PATH);
-               (void)util_unlink_files(WIDGET_STATIC_LOCK_PATH);
-       }
+       vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count);
 
        util_setup_log_disk();
 
@@ -409,7 +154,7 @@ int main(int argc, char *argv[])
         * How could we care this return values?
         * Is there any way to print something on the screen?
         */
-       ret = critical_log_init(widget_util_basename(argv[0]));
+       ret = critical_log_init(util_basename(argv[0]));
        if (ret < 0) {
                ErrPrint("Failed to init the critical log\n");
        }
@@ -421,16 +166,6 @@ int main(int argc, char *argv[])
                CRITICAL_LOG("sigaddset: %d\n", errno);
        }
 
-       ret = sigaddset(&mask, SIGUSR1);
-       if (ret < 0) {
-               CRITICAL_LOG("sigaddset: %d\n", errno);
-       }
-
-       ret = sigaddset(&mask, SIGUSR2);
-       if (ret < 0) {
-               CRITICAL_LOG("sigaddset: %d\n", errno);
-       }
-
        ret = sigprocmask(SIG_BLOCK, &mask, NULL);
        if (ret < 0) {
                CRITICAL_LOG("sigprocmask: %d\n", errno);
@@ -456,8 +191,6 @@ int main(int argc, char *argv[])
 
        app_terminate();
 
-       util_screen_fini();
-
        if (signal_handler) {
                ecore_main_fd_handler_del(signal_handler);
        }
@@ -465,14 +198,6 @@ int main(int argc, char *argv[])
        ecore_shutdown();
        critical_log_fini();
 
-#if defined(FLOG)
-       if (__file_log_fp) {
-               fclose(__file_log_fp);
-       }
-#endif
-
-       widget_conf_reset();
-       widget_abi_fini();
        return 0;
 }
 
diff --git a/src/monitor.c b/src/monitor.c
deleted file mode 100644 (file)
index a444914..0000000
+++ /dev/null
@@ -1,202 +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 <errno.h>
-#include <stdlib.h>
-
-#include <Eina.h>
-#include <dlog.h>
-
-#include <widget_errno.h>
-#include <widget_cmd_list.h>
-#include <packet.h>
-#include <com-core_packet.h>
-
-#include "debug.h"
-#include "dead_monitor.h"
-#include "monitor.h"
-#include "util.h"
-
-int errno;
-
-struct monitor_client {
-       char *widget_id;
-       pid_t pid;
-       int handle;
-};
-
-static struct info {
-       Eina_List *monitor_list;
-} s_info = {
-       .monitor_list = NULL,
-};
-
-static void monitor_disconnected_cb(int handle, void *data)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct monitor_client *monitor;
-
-       EINA_LIST_FOREACH_SAFE(s_info.monitor_list, l, n, monitor) {
-               if (monitor->handle == handle) {
-                       DbgPrint("monitor: %d is deleted (%s)\n", monitor->handle, monitor->widget_id);
-                       s_info.monitor_list = eina_list_remove(s_info.monitor_list, monitor);
-                       DbgFree(monitor->widget_id);
-                       DbgFree(monitor);
-               }
-       }
-}
-
-HAPI struct monitor_client *monitor_create_client(const char *widget_id, pid_t pid, int handle)
-{
-       struct monitor_client *monitor;
-
-       monitor = calloc(1, sizeof(*monitor));
-       if (!monitor) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       if (widget_id) {
-               monitor->widget_id = strdup(widget_id);
-               if (!monitor->widget_id) {
-                       ErrPrint("strdup: %s, %d\n", widget_id, errno);
-                       DbgFree(monitor);
-                       return NULL;
-               }
-       }
-       monitor->pid = pid;
-       monitor->handle = handle;
-
-       s_info.monitor_list = eina_list_append(s_info.monitor_list, monitor);
-
-       if (dead_callback_add(handle, monitor_disconnected_cb, NULL) < 0) {
-               ErrPrint("It's Okay. Dead callback is already registered for %d\n", handle);
-       }
-
-       return monitor;
-}
-
-HAPI int monitor_destroy_client(struct monitor_client *monitor)
-{
-       Eina_List *l;
-       struct monitor_client *item;
-       int handle;
-       int cnt;
-
-       s_info.monitor_list = eina_list_remove(s_info.monitor_list, monitor);
-       handle = monitor->handle;
-       DbgFree(monitor->widget_id);
-       DbgFree(monitor);
-
-       cnt = 0;
-       EINA_LIST_FOREACH(s_info.monitor_list, l, item) {
-               if (item->handle == handle) {
-                       cnt++;
-               }
-       }
-
-       if (cnt == 0) {
-               dead_callback_del(handle, monitor_disconnected_cb, NULL);
-               ErrPrint("Registered monitor object is not valid\n");
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI struct monitor_client *monitor_find_client_by_pid(const char *widget_id, pid_t pid)
-{
-       Eina_List *l;
-       struct monitor_client *monitor;
-
-       monitor = NULL;
-       EINA_LIST_FOREACH(s_info.monitor_list, l, monitor) {
-               if (monitor->pid == pid) {
-                       if (monitor->widget_id && widget_id) {
-                               if (!strcmp(monitor->widget_id, widget_id)) {
-                                       break;
-                               }
-                       } else if (monitor->widget_id == widget_id) {
-                               break;
-                       }
-               }
-
-               monitor = NULL;
-       }
-
-       return monitor;
-}
-
-HAPI struct monitor_client *monitor_find_client_by_handle(const char *widget_id, int handle)
-{
-       Eina_List *l;
-       struct monitor_client *monitor;
-
-       monitor = NULL;
-       EINA_LIST_FOREACH(s_info.monitor_list, l, monitor) {
-               if (monitor->handle == handle) {
-                       if (monitor->widget_id && widget_id) {
-                               if (!strcmp(monitor->widget_id, widget_id)) {
-                                       break;
-                               }
-                       } else if (monitor->widget_id == widget_id) {
-                               break;
-                       }
-               }
-
-               monitor = NULL;
-       }
-
-       return monitor;
-}
-
-HAPI int monitor_multicast_state_change_event(const char *widget_id, enum monitor_event_type event, const char *instance_id, const char *content_info)
-{
-       struct monitor_client *monitor;
-       Eina_List *l;
-       int cnt;
-       unsigned int cmd;
-       struct packet *packet;
-
-       cmd = (unsigned int)event;
-
-       packet = packet_create_noack((const char *)&cmd, "dsss", util_timestamp(), widget_id, instance_id, content_info);
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       cnt = 0;
-       EINA_LIST_FOREACH(s_info.monitor_list, l, monitor) {
-               if (widget_id && monitor->widget_id) {
-                       if (!strcmp(widget_id, monitor->widget_id)) {
-                               com_core_packet_send_only(monitor->handle, packet);
-                               cnt++;
-                       }
-               } else if (monitor->widget_id == NULL) {
-                       com_core_packet_send_only(monitor->handle, packet);
-                       cnt++;
-               }
-       }
-
-       packet_destroy(packet);
-
-       DbgPrint("%d events are multicasted\n", cnt);
-       return cnt;
-}
-
-/* End of a file */
index 92984c3..c36d1e1 100644 (file)
 #include <Eina.h>
 
 #include <dlog.h>
-#if defined(HAVE_LIVEBOX)
-#include <widget_errno.h>
-#else
-#include "lite-errno.h"
-#endif
 #include <packet.h>
 
 #include <sys/smack.h>
@@ -686,6 +681,7 @@ static void _notification_init(void) {
        if (ret == 0 && restart_count <= 1) {
                _notification_data_init();
        }
+
 }
 
 /*!
@@ -940,7 +936,7 @@ HAPI int notification_service_init(void)
 {
        if (s_info.svc_ctx) {
                ErrPrint("Already initialized\n");
-               return WIDGET_ERROR_ALREADY_STARTED;
+               return SERVICE_COMMON_ERROR_ALREADY_STARTED;
        }
 
        _notification_init();
@@ -948,28 +944,31 @@ HAPI int notification_service_init(void)
        s_info.svc_ctx = service_common_create(NOTIFICATION_SOCKET, NOTIFICATION_SMACK_LABEL, service_thread_main, NULL);
        if (!s_info.svc_ctx) {
                ErrPrint("Unable to activate service thread\n");
-               return WIDGET_ERROR_FAULT;
+               return SERVICE_COMMON_ERROR_FAULT;
        }
 
        notification_setting_refresh_setting_table();
 
+       pkgmgr_init();
        pkgmgr_add_event_callback(PKGMGR_EVENT_INSTALL, _package_install_cb, (void*)&s_info);
        /* pkgmgr_add_event_callback(PKGMGR_EVENT_UPDATE, _package_install_cb, (void*)&s_info); */
        pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, _package_uninstall_cb, (void*)&s_info);
        DbgPrint("Successfully initiated\n");
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 HAPI int notification_service_fini(void)
 {
        if (!s_info.svc_ctx) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
+       pkgmgr_fini();
+
        service_common_destroy(s_info.svc_ctx);
        s_info.svc_ctx = NULL;
        DbgPrint("Successfully Finalized\n");
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 /* End of a file */
diff --git a/src/package.c b/src/package.c
deleted file mode 100644 (file)
index 63e2b61..0000000
+++ /dev/null
@@ -1,1873 +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 <errno.h>
-#include <string.h> /* strcmp */
-#include <stdlib.h> /* free */
-
-#include <dlog.h>
-#include <Eina.h>
-
-#include <packet.h>
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_conf.h>
-#include <pkgmgr-info.h>
-
-#include "critical_log.h"
-#include "debug.h"
-#include "util.h"
-#include "parser.h"
-#include "conf.h"
-#include "slave_life.h"
-#include "slave_rpc.h"
-#include "client_life.h"
-#include "package.h"
-#include "fault_manager.h"
-#include "instance.h"
-#include "script_handler.h"
-#include "group.h"
-#include "io.h"
-#include "pkgmgr.h"
-#include "xmonitor.h"
-
-int errno;
-
-struct fault_info {
-       double timestamp;
-       char *filename;
-       char *function;
-};
-
-/*!
- * pkg_info describes the loaded package.
- */
-
-struct pkg_info {
-       char *pkgid;
-       char *widget_id;
-
-       struct {
-               enum widget_widget_type type;
-
-               union {
-                       struct {
-                               char *path;
-                               char *group;
-                       } script;
-
-                       struct {
-                               /*!< Reserved for future use */
-                       } file;
-
-                       struct {
-                               /*!< Reserved for future use */
-                       } text;
-
-                       struct {
-                               /*!< Reserved for future use */
-                       } buffer;
-               } info;
-
-               unsigned int size_list;
-               char *auto_launch;
-               int pinup;
-               int timeout;
-               double period;
-               char *libexec;
-       } widget;
-
-       struct {
-               enum widget_gbar_type type;
-
-               union {
-                       struct {
-                               char *path;
-                               char *group;
-                       } script;
-
-                       struct {
-                               /*!< Reserved for future use */
-                       } text;
-
-                       struct {
-                               /*!< Reserved for future use */
-                       } buffer;
-               } info;
-
-               unsigned int width;
-               unsigned int height;
-       } gbar;
-
-       char *script; /* script type: edje, ... */
-       char *abi;
-       char *hw_acceleration;
-       char *category;
-
-       double faulted_at; /* Fault started time */
-       int fault_count;
-       struct fault_info *fault_info;
-
-       struct slave_node *slave;
-       int refcnt;
-
-       Eina_List *inst_list;
-       Eina_List *ctx_list;
-
-       union _pkg_flags {
-               struct _pkg_field {
-                       unsigned int network: 1;
-                       unsigned int secured: 1;
-                       unsigned int direct_input: 1;
-                       unsigned int auto_align: 1;
-                       unsigned int is_uninstalled: 1;
-
-                       unsigned int reserved: 27;
-               } field;
-               unsigned int mask;
-       } flags;
-};
-
-static struct {
-       Eina_List *pkg_list;
-} s_info = {
-       .pkg_list = NULL,
-};
-
-static int slave_activated_cb(struct slave_node *slave, void *data)
-{
-       struct pkg_info *info = data;
-       struct inst_info *inst;
-       Eina_List *l;
-       Eina_List *n;
-       int cnt;
-       int ret;
-
-       if (!slave_need_to_reactivate_instances(slave)) {
-               DbgPrint("Do not need to reactivate instances\n");
-               return 0;
-       }
-
-       cnt = 0;
-       if (slave_is_watch(slave)) {
-               EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
-                       /**
-                        * @note
-                        * Watch will be recovered by SLAVE_SYNC_HELLO command.
-                        * Not from here.
-                        */
-                       instance_watch_set_need_to_recover(inst, EINA_TRUE);
-                       cnt++;
-               }
-               DbgPrint("Watch instance: %d\n", cnt);
-       } else {
-               EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
-                       ret = instance_recover_state(inst);
-                       if (!ret) {
-                               continue;
-                       }
-
-                       instance_thaw_updator(inst);
-                       cnt++;
-               }
-       }
-
-       DbgPrint("Recover state for %d instances of %s\n", cnt, package_name(info));
-       return 0;
-}
-
-static int slave_fault_cb(struct slave_node *slave, void *data)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct inst_info *inst;
-       struct pkg_info *info = (struct pkg_info *)data;
-
-       if (package_is_fault(info)) {
-               ErrPrint("Already faulted package: %s\n", package_name(info));
-               return 0;
-       }
-
-       (void)package_set_fault_info(info, util_timestamp(), slave_name(slave), __func__);
-       fault_broadcast_info(package_name(info), slave_name(slave), __func__);
-
-       DbgPrint("Slave critical fault - package: %s (by slave fault %s\n", package_name(info), slave_name(slave));
-       EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
-               DbgPrint("Destroy instance %p\n", inst);
-               instance_destroyed(inst, WIDGET_ERROR_FAULT);
-       }
-
-       return 0;
-}
-
-static int slave_deactivated_cb(struct slave_node *slave, void *data)
-{
-       struct pkg_info *info = data;
-       struct inst_info *inst;
-       Eina_List *l;
-       Eina_List *n;
-       int cnt = 0;
-
-       if (info->fault_info) {
-               EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
-                       instance_destroyed(inst, WIDGET_ERROR_FAULT);
-               }
-       } else {
-               EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
-                       cnt += instance_need_slave(inst);
-                       /*!
-                        * instance_deactivated will call the slave_unload_instance.
-                        * if the loaded instance counter meets 0,
-                        * the slave will be deactivated.
-                        * so we should not call the instance activate function
-                        * from here.
-                        *
-                        * activate slave when the slave is reactivated
-                        */
-               }
-       }
-
-       return cnt ? SLAVE_NEED_TO_REACTIVATE : 0;
-}
-
-static int xmonitor_paused_cb(void *data)
-{
-       struct pkg_info *info = (struct pkg_info *)data;
-       struct inst_info *inst;
-       Eina_List *l;
-
-       if (slave_state(info->slave) != SLAVE_TERMINATED) {
-               return 0;
-       }
-
-       EINA_LIST_FOREACH(info->inst_list, l, inst) {
-               (void)instance_freeze_updator(inst);
-       }
-
-       return 0;
-}
-
-static int xmonitor_resumed_cb(void *data)
-{
-       struct pkg_info *info = data;
-       struct inst_info *inst;
-       Eina_List *l;
-
-       if (slave_state(info->slave) != SLAVE_TERMINATED) {
-               return 0;
-       }
-
-       EINA_LIST_FOREACH(info->inst_list, l, inst) {
-               instance_thaw_updator(inst);
-       }
-
-       return 0;
-}
-
-static int slave_paused_cb(struct slave_node *slave, void *data)
-{
-       struct pkg_info *info = (struct pkg_info *)data;
-       struct inst_info *inst;
-       Eina_List *l;
-
-       EINA_LIST_FOREACH(info->inst_list, l, inst) {
-               (void)instance_freeze_updator(inst);
-       }
-
-       return 0;
-}
-
-static int slave_resumed_cb(struct slave_node *slave, void *data)
-{
-       struct pkg_info *info = (struct pkg_info *)data;
-       struct inst_info *inst;
-       Eina_List *l;
-
-       EINA_LIST_FOREACH(info->inst_list, l, inst) {
-               instance_thaw_updator(inst);
-       }
-
-       return 0;
-}
-
-static inline void destroy_package(struct pkg_info *info)
-{
-       eina_list_free(info->ctx_list);
-       /* This items will be deleted from group_del_widget */
-       info->ctx_list = NULL;
-
-       group_del_widget(info->widget_id);
-       package_clear_fault(info);
-
-       s_info.pkg_list = eina_list_remove(s_info.pkg_list, info);
-
-       if (info->widget.type == WIDGET_TYPE_SCRIPT) {
-               DbgFree(info->widget.info.script.path);
-               DbgFree(info->widget.info.script.group);
-       }
-
-       if (info->gbar.type == GBAR_TYPE_SCRIPT) {
-               DbgFree(info->gbar.info.script.path);
-               DbgFree(info->gbar.info.script.group);
-       }
-
-       DbgFree(info->script);
-       DbgFree(info->abi);
-       DbgFree(info->widget_id);
-       DbgFree(info->widget.libexec);
-       DbgFree(info->widget.auto_launch);
-       DbgFree(info->pkgid);
-       DbgFree(info->hw_acceleration);
-
-       DbgFree(info);
-}
-
-static inline int load_conf(struct pkg_info *info)
-{
-       struct parser *parser;
-       const char *str;
-       const char *group;
-
-       parser = parser_load(info->widget_id);
-       if (!parser) {
-               info->widget.size_list = 0x01; /* Default */
-
-               info->script = strdup(WIDGET_CONF_DEFAULT_SCRIPT);
-               if (!info->script) {
-                       ErrPrint("strdup: %d\n", errno);
-                       return WIDGET_ERROR_OUT_OF_MEMORY;
-               }
-
-               info->abi = strdup(WIDGET_CONF_DEFAULT_ABI);
-               if (!info->abi) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(info->script);
-                       info->script = NULL;
-                       return WIDGET_ERROR_OUT_OF_MEMORY;
-               }
-
-               info->gbar.width = WIDGET_CONF_BASE_W;
-               info->gbar.height = WIDGET_CONF_BASE_H >> 2;
-               info->widget.pinup = 1;
-               return WIDGET_ERROR_NONE;
-       }
-
-       info->widget.type = WIDGET_TYPE_FILE;
-       if (parser_text_widget(parser)) {
-               info->widget.type = WIDGET_TYPE_TEXT;
-       } else if (parser_buffer_widget(parser)) {
-               info->widget.type = WIDGET_TYPE_BUFFER;
-       } else {
-               str = parser_widget_path(parser);
-               if (str) {
-                       info->widget.type = WIDGET_TYPE_SCRIPT;
-
-                       info->widget.info.script.path = strdup(str);
-                       if (!info->widget.info.script.path) {
-                               ErrPrint("strdup: %d\n", errno);
-                               parser_unload(parser);
-                               return WIDGET_ERROR_OUT_OF_MEMORY;
-                       }
-
-                       str = parser_widget_group(parser);
-                       if (str) {
-                               info->widget.info.script.group = strdup(str);
-                               if (!info->widget.info.script.group) {
-                                       ErrPrint("strdup: %d\n", errno);
-                                       DbgFree(info->widget.info.script.path);
-                                       parser_unload(parser);
-                                       return WIDGET_ERROR_OUT_OF_MEMORY;
-                               }
-                       }
-               }
-       }
-
-       if (parser_text_gbar(parser)) {
-               info->gbar.type = GBAR_TYPE_TEXT;
-       } else if (parser_buffer_gbar(parser)) {
-               info->gbar.type = GBAR_TYPE_BUFFER;
-       } else {
-               str = parser_gbar_path(parser);
-               if (str) {
-                       info->gbar.type = GBAR_TYPE_SCRIPT;
-                       info->gbar.info.script.path = strdup(str);
-                       if (!info->gbar.info.script.path) {
-                               ErrPrint("strdup: %d\n", errno);
-                               if (info->widget.type == WIDGET_TYPE_SCRIPT) {
-                                       DbgFree(info->widget.info.script.path);
-                                       DbgFree(info->widget.info.script.group);
-                               }
-                               parser_unload(parser);
-                               return WIDGET_ERROR_OUT_OF_MEMORY;
-                       }
-
-                       str = parser_gbar_group(parser);
-                       if (str) {
-                               info->gbar.info.script.group = strdup(str);
-                               if (!info->gbar.info.script.group) {
-                                       ErrPrint("strdup: %d\n", errno);
-                                       DbgFree(info->gbar.info.script.path);
-                                       if (info->widget.type == WIDGET_TYPE_SCRIPT) {
-                                               DbgFree(info->widget.info.script.path);
-                                               DbgFree(info->widget.info.script.group);
-                                       }
-                                       parser_unload(parser);
-                                       return WIDGET_ERROR_OUT_OF_MEMORY;
-                               }
-                       }
-               }
-       }
-
-       str = parser_script(parser);
-       str = str ? str : WIDGET_CONF_DEFAULT_SCRIPT;
-       info->script = strdup(str);
-       if (!info->script) {
-               ErrPrint("strdup: %d\n", errno);
-               if (info->gbar.type == GBAR_TYPE_SCRIPT) {
-                       DbgFree(info->gbar.info.script.path);
-                       DbgFree(info->gbar.info.script.group);
-               }
-
-               if (info->widget.type == WIDGET_TYPE_SCRIPT) {
-                       DbgFree(info->widget.info.script.path);
-                       DbgFree(info->widget.info.script.group);
-               }
-
-               parser_unload(parser);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       str = parser_abi(parser);
-       str = str ? str : WIDGET_CONF_DEFAULT_ABI;
-       info->abi = strdup(str);
-       if (!info->abi) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(info->script);
-               if (info->gbar.type == GBAR_TYPE_SCRIPT) {
-                       DbgFree(info->gbar.info.script.path);
-                       DbgFree(info->gbar.info.script.group);
-               }
-
-               if (info->widget.type == WIDGET_TYPE_SCRIPT) {
-                       DbgFree(info->widget.info.script.path);
-                       DbgFree(info->widget.info.script.group);
-               }
-               parser_unload(parser);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       info->widget.timeout = parser_timeout(parser);
-       info->flags.field.network = parser_network(parser);
-
-       info->widget.period = parser_period(parser);
-       if (info->widget.period < 0.0f) {
-               info->widget.period = 0.0f;
-       } else if (info->widget.period > 0.0f && info->widget.period < WIDGET_CONF_MINIMUM_PERIOD) {
-               info->widget.period = WIDGET_CONF_MINIMUM_PERIOD;
-       }
-
-       info->widget.size_list = parser_size(parser);
-
-       str = parser_auto_launch(parser);
-       str = str ? str : "";
-       info->widget.auto_launch = strdup(str);
-       if (!info->widget.auto_launch) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(info->abi);
-               DbgFree(info->script);
-               if (info->gbar.type == GBAR_TYPE_SCRIPT) {
-                       DbgFree(info->gbar.info.script.path);
-                       DbgFree(info->gbar.info.script.group);
-               }
-
-               if (info->widget.type == WIDGET_TYPE_SCRIPT) {
-                       DbgFree(info->widget.info.script.path);
-                       DbgFree(info->widget.info.script.group);
-               }
-               parser_unload(parser);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       info->flags.field.secured = parser_secured(parser);
-       info->widget.pinup = parser_pinup(parser);
-
-       parser_get_gbar_size(parser, &info->gbar.width, &info->gbar.height);
-
-       group = parser_group_str(parser);
-       if (group && group_add_widget(group, info->widget_id) < 0) {
-               ErrPrint("Failed to build cluster tree for %s{%s}\n", info->widget_id, group);
-       }
-
-       parser_unload(parser);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI struct pkg_info *package_create(const char *pkgid, const char *widget_id)
-{
-       struct pkg_info *pkginfo;
-
-       pkginfo = calloc(1, sizeof(*pkginfo));
-       if (!pkginfo) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       pkginfo->pkgid = strdup(pkgid);
-       if (!pkginfo->pkgid) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(pkginfo);
-               return NULL;
-       }
-
-       pkginfo->widget_id = io_widget_pkgname(widget_id);
-       if (!pkginfo->widget_id) {
-               ErrPrint("Failed to get pkgname, fallback to fs checker\n");
-               pkginfo->widget_id = strdup(widget_id);
-               if (!pkginfo->widget_id) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(pkginfo->pkgid);
-                       DbgFree(pkginfo);
-                       return NULL;
-               }
-       }
-
-       package_ref(pkginfo);
-
-       if (io_load_package_db(pkginfo) < 0) {
-               ErrPrint("Failed to load DB, fall back to conf file loader\n");
-               if (load_conf(pkginfo) < 0) {
-                       ErrPrint("Failed to initiate the conf file loader\n");
-                       package_unref(pkginfo);
-                       return NULL;
-               }
-       }
-
-       s_info.pkg_list = eina_list_append(s_info.pkg_list, pkginfo);
-
-       return pkginfo;
-}
-
-HAPI int package_destroy(struct pkg_info *info)
-{
-       package_unref(info);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI Eina_List *package_ctx_info(struct pkg_info *pkginfo)
-{
-       return pkginfo->ctx_list;
-}
-
-HAPI void package_add_ctx_info(struct pkg_info *pkginfo, struct context_info *info)
-{
-       pkginfo->ctx_list = eina_list_append(pkginfo->ctx_list, info);
-}
-
-HAPI void package_del_ctx_info(struct pkg_info *pkginfo, struct context_info *info)
-{
-       pkginfo->ctx_list = eina_list_remove(pkginfo->ctx_list, info);
-}
-
-HAPI char *package_widget_pkgname(const char *pkgname)
-{
-       char *widget_id;
-
-       widget_id = io_widget_pkgname(pkgname);
-       if (!widget_id) {
-               widget_id = strdup(pkgname);
-               if (!widget_id) {
-                       ErrPrint("strdup: %d\n", errno);
-                       return NULL;
-               }
-       }
-
-       return widget_id;
-}
-
-HAPI int package_is_widget_pkgname(const char *pkgname)
-{
-       char *widget_id;
-       int ret;
-
-       widget_id = package_widget_pkgname(pkgname);
-       ret = !!widget_id;
-       DbgFree(widget_id);
-
-       return ret;
-}
-
-HAPI struct pkg_info *package_find(const char *widget_id)
-{
-       Eina_List *l;
-       struct pkg_info *info;
-
-       if (!widget_id) {
-               return NULL;
-       }
-
-       EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
-               if (!strcmp(info->widget_id, widget_id)) {
-                       return info;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI struct inst_info *package_find_instance_by_id(const char *widget_id, const char *id)
-{
-       Eina_List *l;
-       struct inst_info *inst;
-       struct pkg_info *info;
-
-       info = package_find(widget_id);
-       if (!info) {
-               ErrPrint("Package %s is not exists\n", widget_id);
-               return NULL;
-       }
-
-       EINA_LIST_FOREACH(info->inst_list, l, inst) {
-               if (!strcmp(instance_id(inst), id)) {
-                       return inst;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI struct inst_info *package_find_instance_by_timestamp(const char *widget_id, double timestamp)
-{
-       Eina_List *l;
-       struct inst_info *inst;
-       struct pkg_info *info;
-
-       info = package_find(widget_id);
-       if (!info) {
-               ErrPrint("Package %s is not exists\n", widget_id);
-               return NULL;
-       }
-
-       EINA_LIST_FOREACH(info->inst_list, l, inst) {
-               if (instance_timestamp(inst) == timestamp) {
-                       return inst;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI int package_dump_fault_info(struct pkg_info *info)
-{
-       if (!info->fault_info) {
-               return WIDGET_ERROR_NOT_EXIST;
-       }
-
-       CRITICAL_LOG("=============\n");
-       CRITICAL_LOG("faulted at %lf\n", info->fault_info->timestamp);
-       CRITICAL_LOG("Package: %s\n", info->widget_id);
-       CRITICAL_LOG("Function: %s\n", info->fault_info->function);
-       CRITICAL_LOG("InstanceID: %s\n", info->fault_info->filename);
-       return WIDGET_ERROR_NONE;
-}
-
-static int package_is_faulted(struct pkg_info *info, double timestamp)
-{
-       if ((timestamp - info->faulted_at) < WIDGET_CONF_FAULT_DETECT_IN_TIME) {
-               info->fault_count++;
-               DbgPrint("Triggered faulted_in_time (%lf)\n", WIDGET_CONF_FAULT_DETECT_IN_TIME);
-       } else {
-               info->fault_count = 1;
-               info->faulted_at = timestamp;
-       }
-
-       if (info->fault_count > WIDGET_CONF_FAULT_DETECT_COUNT) {
-               info->fault_count = 0;
-               info->faulted_at = timestamp;
-               DbgPrint("Triggered fault_count, return 1\n", WIDGET_CONF_FAULT_DETECT_COUNT);
-               return 1;
-       }
-
-       DbgPrint("Faulted: %d (%d / %lf)\n", info->fault_count, WIDGET_CONF_FAULT_DETECT_COUNT, WIDGET_CONF_FAULT_DETECT_IN_TIME);
-       return 0;
-}
-
-HAPI int package_get_fault_info(struct pkg_info *info, double *timestamp, const char **filename, const char **function)
-{
-       if (!info->fault_info) {
-               return WIDGET_ERROR_NOT_EXIST;
-       }
-
-       *timestamp = info->fault_info->timestamp;
-       *filename = info->fault_info->filename;
-       *function = info->fault_info->function;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int package_set_fault_info(struct pkg_info *info, double timestamp, const char *filename, const char *function)
-{
-       struct fault_info *fault;
-
-       if (!package_is_faulted(info, timestamp)) {
-               DbgPrint("Faulted but excused\n");
-               return WIDGET_ERROR_CANCELED;
-       }
-
-       package_clear_fault(info);
-
-       fault = calloc(1, sizeof(*fault));
-       if (!fault) {
-               ErrPrint("calloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       fault->timestamp = timestamp;
-       if (!filename) {
-               filename = "unknown";
-       }
-       if (!function) {
-               function = "unknown";
-       }
-
-       fault->filename = strdup(filename);
-       if (!fault->filename) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(fault);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       fault->function = strdup(function);
-       if (!fault->function) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(fault->filename);
-               DbgFree(fault);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       info->fault_info = fault;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int package_clear_fault(struct pkg_info *info)
-{
-       if (!info->fault_info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       package_dump_fault_info(info);
-
-       DbgFree(info->fault_info->function);
-       DbgFree(info->fault_info->filename);
-       DbgFree(info->fault_info);
-       info->fault_info = NULL;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI const int const package_is_fault(const struct pkg_info *info)
-{
-       return !!info->fault_info;
-}
-
-HAPI struct slave_node * const package_slave(const struct pkg_info *info)
-{
-       return info->slave;
-}
-
-HAPI const int const package_timeout(const struct pkg_info *info)
-{
-       return info->widget.timeout;
-}
-
-HAPI void package_set_timeout(struct pkg_info *info, int timeout)
-{
-       info->widget.timeout = timeout;
-}
-
-HAPI const double const package_period(const struct pkg_info *info)
-{
-       return info->widget.period;
-}
-
-HAPI void package_set_period(struct pkg_info *info, double period)
-{
-       info->widget.period = period;
-}
-
-HAPI const int const package_secured(const struct pkg_info *info)
-{
-       return info->flags.field.secured;
-}
-
-HAPI void package_set_secured(struct pkg_info *info, int secured)
-{
-       info->flags.field.secured = secured;
-}
-
-HAPI const char * const package_script(const struct pkg_info *info)
-{
-       return info->script;
-}
-
-HAPI int package_set_script(struct pkg_info *info, const char *script)
-{
-       char *tmp;
-
-       tmp = strdup(script);
-       if (!tmp) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->script);
-       info->script = tmp;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI const char * const package_abi(const struct pkg_info *info)
-{
-       return info->abi;
-}
-
-HAPI int package_set_abi(struct pkg_info *info, const char *abi)
-{
-       char *tmp;
-       tmp = strdup(abi);
-       if (!tmp) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->abi);
-       info->abi = tmp;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI const char * const package_widget_path(const struct pkg_info *info)
-{
-       if (info->widget.type != WIDGET_TYPE_SCRIPT) {
-               return NULL;
-       }
-
-       return info->widget.info.script.path;
-}
-
-HAPI int package_set_widget_path(struct pkg_info *info, const char *path)
-{
-       char *tmp;
-
-       if (info->widget.type != WIDGET_TYPE_SCRIPT) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       tmp = strdup(path);
-       if (!tmp) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->widget.info.script.path);
-       info->widget.info.script.path = tmp;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI const char * const package_widget_group(const struct pkg_info *info)
-{
-       if (info->widget.type != WIDGET_TYPE_SCRIPT) {
-               return NULL;
-       }
-
-       return info->widget.info.script.group;
-}
-
-HAPI int package_set_widget_group(struct pkg_info *info, const char *group)
-{
-       char *tmp;
-
-       if (info->widget.type != WIDGET_TYPE_SCRIPT) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       tmp = strdup(group);
-       if (!tmp) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->widget.info.script.group);
-       info->widget.info.script.group = tmp;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI const char * const package_gbar_path(const struct pkg_info *info)
-{
-       if (info->gbar.type != GBAR_TYPE_SCRIPT) {
-               return NULL;
-       }
-
-       return info->gbar.info.script.path;
-}
-
-HAPI int package_set_gbar_path(struct pkg_info *info, const char *path)
-{
-       char *tmp;
-
-       if (info->gbar.type != GBAR_TYPE_SCRIPT) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       tmp = strdup(path);
-       if (!tmp) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->gbar.info.script.path);
-       info->gbar.info.script.path = tmp;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI const char * const package_gbar_group(const struct pkg_info *info)
-{
-       if (info->gbar.type != GBAR_TYPE_SCRIPT) {
-               return NULL;
-       }
-
-       return info->gbar.info.script.group;
-}
-
-HAPI int package_set_gbar_group(struct pkg_info *info, const char *group)
-{
-       char *tmp;
-
-       if (info->gbar.type != GBAR_TYPE_SCRIPT) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       tmp = strdup(group);
-       if (!tmp) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->gbar.info.script.group);
-       info->gbar.info.script.group = tmp;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI const int const package_pinup(const struct pkg_info *info)
-{
-       return info->widget.pinup;
-}
-
-HAPI void package_set_pinup(struct pkg_info *info, int pinup)
-{
-       info->widget.pinup = pinup;
-}
-
-HAPI const char * const package_auto_launch(const struct pkg_info *info)
-{
-       return info->widget.auto_launch;
-}
-
-HAPI void package_set_auto_launch(struct pkg_info *info, const char *auto_launch)
-{
-       if (!auto_launch) {
-               auto_launch = "";
-       }
-
-       info->widget.auto_launch = strdup(auto_launch);
-       if (!info->widget.auto_launch) {
-               ErrPrint("strdup: %d\n", errno);
-               return;
-       }
-}
-
-HAPI const unsigned int const package_size_list(const struct pkg_info *info)
-{
-       return info->widget.size_list;
-}
-
-HAPI void package_set_size_list(struct pkg_info *info, unsigned int size_list)
-{
-       info->widget.size_list = size_list;
-}
-
-HAPI const int const package_gbar_width(const struct pkg_info *info)
-{
-       return info->gbar.width;
-}
-
-HAPI void package_set_gbar_width(struct pkg_info *info, int width)
-{
-       info->gbar.width = width;
-}
-
-HAPI const int const package_gbar_height(const struct pkg_info *info)
-{
-       return info->gbar.height;
-}
-
-HAPI void package_set_gbar_height(struct pkg_info *info, int height)
-{
-       info->gbar.height = height;
-}
-
-HAPI struct pkg_info * const package_ref(struct pkg_info *info)
-{
-       info->refcnt++;
-       return info;
-}
-
-HAPI struct pkg_info * const package_unref(struct pkg_info *info)
-{
-       if (info->refcnt == 0) {
-               ErrPrint("Invalid request\n");
-               return NULL;
-       }
-
-       info->refcnt--;
-       if (info->refcnt == 0) {
-               destroy_package(info);
-               info = NULL;
-       }
-
-       return info;
-}
-
-HAPI const int const package_refcnt(const struct pkg_info *info)
-{
-       return info->refcnt;
-}
-
-HAPI const enum widget_widget_type package_widget_type(const struct pkg_info *info)
-{
-       return info ? info->widget.type : WIDGET_TYPE_NONE;
-}
-
-HAPI void package_set_widget_type(struct pkg_info *info, enum widget_widget_type type)
-{
-       info->widget.type = type;
-}
-
-HAPI const char * const package_libexec(struct pkg_info *info)
-{
-       return info->widget.libexec;
-}
-
-HAPI int package_set_libexec(struct pkg_info *info, const char *libexec)
-{
-       char *tmp;
-
-       tmp = strdup(libexec);
-       if (!tmp) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->widget.libexec);
-       info->widget.libexec = tmp;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int package_network(struct pkg_info *info)
-{
-       return info->flags.field.network;
-}
-
-HAPI void package_set_network(struct pkg_info *info, int network)
-{
-       info->flags.field.network = network;
-}
-
-HAPI void package_set_direct_input(struct pkg_info *info, int direct_input)
-{
-       info->flags.field.direct_input = direct_input;
-}
-
-HAPI int package_direct_input(const struct pkg_info *info)
-{
-       return info->flags.field.direct_input;
-}
-
-HAPI void package_set_auto_align(struct pkg_info *info, int auto_align)
-{
-       info->flags.field.auto_align = auto_align;
-}
-
-HAPI int package_auto_align(const struct pkg_info *info)
-{
-       return info->flags.field.auto_align;
-}
-
-HAPI const enum widget_gbar_type const package_gbar_type(const struct pkg_info *info)
-{
-       return info ? info->gbar.type : GBAR_TYPE_NONE;
-}
-
-HAPI void package_set_gbar_type(struct pkg_info *info, enum widget_gbar_type type)
-{
-       info->gbar.type = type;
-}
-
-HAPI const char *package_hw_acceleration(struct pkg_info *info)
-{
-       return info->hw_acceleration;
-}
-
-HAPI int package_set_hw_acceleration(struct pkg_info *info, const char *hw_acceleration)
-{
-       char *tmp;
-
-       if (!hw_acceleration || !info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       tmp = strdup(hw_acceleration);
-       if (!tmp) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->hw_acceleration);
-       info->hw_acceleration = tmp;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int package_set_category(struct pkg_info *info, const char *category)
-{
-       char *tmp;
-
-       if (!category || !info) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       tmp = strdup(category);
-       if (!tmp) {
-               ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       DbgFree(info->category);
-       info->category = tmp;
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI const char *package_category(const struct pkg_info *info)
-{
-       return info->category;
-}
-
-/*!
- * \note
- * Add the instance to the package info.
- * If a package has no slave, assign a new slave.
- */
-static inline int assign_new_slave(const char *slave_pkgname, struct pkg_info *info)
-{
-       char *s_name;
-       const char *category;
-
-       s_name = util_slavename();
-       if (!s_name) {
-               ErrPrint("Failed to get a new slave name\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       DbgPrint("New slave[%s] is assigned for %s (using %s / abi[%s] / accel[%s]\n", s_name, info->widget_id, slave_pkgname, info->abi, info->hw_acceleration);
-       info->slave = slave_create(s_name, info->flags.field.secured, info->abi, slave_pkgname, info->flags.field.network, info->hw_acceleration);
-       DbgFree(s_name);
-       if (!info->slave) {
-               /*!
-                * \note
-                * package_destroy will try to remove "info" from the pkg_list.
-                * but we didn't add this to it yet.
-                * If the list method couldn't find an "info" from the list,
-                * it just do nothing so I'll leave this.
-                */
-               return WIDGET_ERROR_FAULT;
-       }
-
-       slave_set_resource_limit(info->slave, 0u, 0u);
-
-       /**
-        * @note
-        * At the first time, the slave is created, "is_watch" will be initialized.
-        */
-       category = package_category(info);
-       slave_set_is_watch(info->slave, (category && strcmp(CATEGORY_WATCH_CLOCK, category) == 0));
-
-       /*!
-        * \note
-        * Slave is not activated yet.
-        */
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int package_add_instance(struct pkg_info *info, struct inst_info *inst)
-{
-       if (!info->inst_list) {
-               char *slave_pkgname;
-
-               slave_pkgname = slave_package_name(info->abi, info->widget_id);
-               if (!slave_pkgname) {
-                       return WIDGET_ERROR_OUT_OF_MEMORY;
-               }
-
-               info->slave = slave_find_available(slave_pkgname, info->abi, info->flags.field.secured, info->flags.field.network, info->hw_acceleration, info->flags.field.auto_align);
-               if (!info->slave) {
-                       int ret;
-
-                       ret = assign_new_slave(slave_pkgname, info);
-                       DbgFree(slave_pkgname);
-                       if (ret < 0) {
-                               return ret;
-                       }
-               } else {
-                       DbgFree(slave_pkgname);
-                       DbgPrint("Slave %s is used for %s\n", slave_name(info->slave), info->widget_id);
-               }
-
-               (void)slave_ref(info->slave);
-               slave_load_package(info->slave);
-               (void)slave_event_callback_add(info->slave, SLAVE_EVENT_DEACTIVATE, slave_deactivated_cb, info);
-               (void)slave_event_callback_add(info->slave, SLAVE_EVENT_ACTIVATE, slave_activated_cb, info);
-               (void)slave_event_callback_add(info->slave, SLAVE_EVENT_FAULT, slave_fault_cb, info);
-
-               if (info->flags.field.secured || (WIDGET_IS_INHOUSE(package_abi(info)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL)) {
-                       (void)slave_event_callback_add(info->slave, SLAVE_EVENT_PAUSE, slave_paused_cb, info);
-                       (void)slave_event_callback_add(info->slave, SLAVE_EVENT_RESUME, slave_resumed_cb, info);
-
-                       /*!
-                        * \note
-                        * In case of the slave is terminated because of expired TTL timer,
-                        * Master should freeze the all update time.
-                        * But the callback should check the slave's state to prevent from duplicated freezing.
-                        *
-                        * This callback will freeze the timer only if a slave doesn't running.
-                        */
-                       (void)xmonitor_add_event_callback(XMONITOR_PAUSED, xmonitor_paused_cb, info);
-                       (void)xmonitor_add_event_callback(XMONITOR_RESUMED, xmonitor_resumed_cb, info);
-               }
-       }
-
-       info->inst_list = eina_list_append(info->inst_list, inst);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int package_del_instance(struct pkg_info *info, struct inst_info *inst)
-{
-       info->inst_list = eina_list_remove(info->inst_list, inst);
-
-       if (info->inst_list) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (info->slave) {
-               slave_unload_package(info->slave);
-
-               slave_event_callback_del(info->slave, SLAVE_EVENT_FAULT, slave_fault_cb, info);
-               slave_event_callback_del(info->slave, SLAVE_EVENT_DEACTIVATE, slave_deactivated_cb, info);
-               slave_event_callback_del(info->slave, SLAVE_EVENT_ACTIVATE, slave_activated_cb, info);
-
-               if (info->flags.field.secured || (WIDGET_IS_INHOUSE(package_abi(info)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL)) {
-                       slave_event_callback_del(info->slave, SLAVE_EVENT_PAUSE, slave_paused_cb, info);
-                       slave_event_callback_del(info->slave, SLAVE_EVENT_RESUME, slave_resumed_cb, info);
-
-                       xmonitor_del_event_callback(XMONITOR_PAUSED, xmonitor_paused_cb, info);
-                       xmonitor_del_event_callback(XMONITOR_RESUMED, xmonitor_resumed_cb, info);
-               }
-
-               slave_unref(info->slave);
-               info->slave = NULL;
-       }
-
-       if (info->flags.field.is_uninstalled) {
-               package_destroy(info);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI Eina_List *package_instance_list(struct pkg_info *info)
-{
-       return info->inst_list;
-}
-
-static int client_created_cb(struct client_node *client, void *data)
-{
-       struct pkg_info *info;
-       Eina_List *l;
-
-       struct inst_info *inst;
-       Eina_List *i_l;
-
-       EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
-               if (info->fault_info) {
-                       fault_unicast_info(client, info->widget_id, info->fault_info->filename, info->fault_info->function);
-                       continue;
-               }
-
-               EINA_LIST_FOREACH(info->inst_list, i_l, inst) {
-                       switch (instance_state(inst)) {
-                       case INST_INIT:
-                               /* Will be send a created event after the instance gets created event */
-                               break;
-                       case INST_ACTIVATED: /*!< This instance is actiavted, and used */
-                       case INST_REQUEST_TO_REACTIVATE: /*!< This instance will be reactivated soon */
-                       case INST_REQUEST_TO_DESTROY: /*!< This instance will be destroy soon */
-                               if (instance_client(inst) == client) {
-                                       instance_unicast_created_event(inst, client);
-                               } else if (instance_client(inst) == NULL) {
-                                       /*!
-                                        * \note
-                                        * Instances are lives in the system cluster/sub-cluster
-                                        */
-                                       if (client_is_subscribed_group(client, instance_cluster(inst), instance_category(inst))
-                                               || client_is_subscribed_by_category(client, package_category(instance_package(inst))))
-                                       {
-                                               instance_unicast_created_event(inst, client);
-                                               DbgPrint("(Subscribed) Created package: %s\n", info->widget_id);
-                                       }
-                               }
-
-                               break;
-                       default:
-                               DbgPrint("%s(%s) is not activated (%d)\n",
-                                               package_name(info), instance_id(inst), instance_state(inst));
-                               break;
-                       }
-               }
-       }
-
-       return 0;
-}
-
-static int io_uninstall_cb(const char *pkgid, const char *widget_id, int prime, void *data)
-{
-       struct pkg_info *info;
-       Eina_List *l;
-       Eina_List *n;
-       struct inst_info *inst;
-
-       DbgPrint("Package %s is uninstalled\n", widget_id);
-       info = package_find(widget_id);
-       if (!info) {
-               DbgPrint("%s is not yet loaded\n", widget_id);
-               return 0;
-       }
-
-       info->flags.field.is_uninstalled = 1;
-
-       /*!
-        * \NOTE
-        * Don't delete an item from the inst_list.
-        * destroy callback will use this list again.
-        * So, Don't touch it from here.
-        */
-       if (info->inst_list) {
-               EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_UNINSTALL);
-               }
-       } else {
-               package_destroy(info);
-       }
-
-       return 0;
-}
-
-static inline void reload_package_info(struct pkg_info *info)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct inst_info *inst;
-       widget_size_type_e size_type;
-       int width;
-       int height;
-       double old_period;
-
-       DbgPrint("Already exists, try to update it\n");
-
-       old_period = info->widget.period;
-
-       group_del_widget(info->widget_id);
-       package_clear_fault(info);
-
-       /*!
-        * \NOTE:
-        * Nested DB I/O
-        */
-       io_load_package_db(info);
-
-       /*!
-        * \note
-        * Without "is_uninstalled", the package will be kept
-        */
-       EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
-               width = instance_widget_width(inst);
-               height = instance_widget_height(inst);
-               DbgPrint("%dx%d\n", width, height);
-               if (widget_service_get_size_type(width, height, &size_type) == WIDGET_ERROR_NONE) {
-                       if ((info->widget.size_list & size_type) == size_type) {
-                               DbgPrint("Supported size type: %x\n", size_type);
-                               if (instance_period(inst) == old_period) {
-                                       instance_reload_period(inst, package_period(info));
-                               }
-                               instance_reload(inst, WIDGET_DESTROY_TYPE_UPGRADE);
-                       } else {
-                               DbgPrint("Unsupported size type: %x\n", size_type);
-                               instance_destroy(inst, WIDGET_DESTROY_TYPE_UNINSTALL);
-                       }
-               } else {
-                       DbgPrint("Invalid size\n");
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_UNINSTALL);
-               }
-       }
-}
-
-static int io_install_cb(const char *pkgid, const char *widget_id, int prime, void *data)
-{
-       struct pkg_info *info;
-
-       info = package_find(widget_id);
-       if (info) {
-               /*!
-                * Already exists. skip to create this.
-                */
-               return 0;
-       }
-
-       info = package_create(pkgid, widget_id);
-       if (!info) {
-               ErrPrint("Failed to build an info %s\n", widget_id);
-       } else {
-               DbgPrint("widget %s is built\n", widget_id);
-       }
-
-       return 0;
-}
-
-static int uninstall_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
-{
-       if (status == PKGMGR_STATUS_START) {
-               Eina_List *l;
-               Eina_List *n;
-               struct pkg_info *info;
-
-               EINA_LIST_FOREACH_SAFE(s_info.pkg_list, l, n, info) {
-                       if (!strcmp(info->pkgid, pkgname)) {
-                               struct slave_node *slave;
-                               /**
-                                * @note
-                                * While updating packages, the slave can be terminated,
-                                * Even if a slave is terminated, do not handles it as a faulted one.
-                                */
-                               slave = package_slave(info);
-                               DbgPrint("Update slave state : %p\n", slave);
-                               if (slave) {
-                                       slave_set_wait_deactivation(slave, 1);
-                               }
-                       }
-               }
-       } else if (status == PKGMGR_STATUS_END) {
-               Eina_List *l;
-               Eina_List *n;
-               struct pkg_info *info;
-
-               EINA_LIST_FOREACH_SAFE(s_info.pkg_list, l, n, info) {
-                       if (!strcmp(info->pkgid, pkgname)) {
-                               struct slave_node *slave;
-                               slave = package_slave(info);
-                               if (slave) {
-                                       slave_set_wait_deactivation(slave, 0);
-                               }
-                               io_uninstall_cb(pkgname, info->widget_id, -1, NULL);
-                       }
-               }
-       }
-
-       return 0;
-}
-
-static int update_cb(const char *pkgname, enum pkgmgr_status status, double value, void *data)
-{
-       if (status == PKGMGR_STATUS_START) {
-               Eina_List *l;
-               Eina_List *n;
-               struct pkg_info *info;
-
-               EINA_LIST_FOREACH_SAFE(s_info.pkg_list, l, n, info) {
-                       if (!strcmp(info->pkgid, pkgname)) {
-                               struct slave_node *slave;
-                               /**
-                                * @note
-                                * While updating packages, the slave can be terminated,
-                                * Even if a slave is terminated, do not handles it as a faulted one.
-                                */
-                               slave = package_slave(info);
-                               DbgPrint("Update slave state : %p\n", slave);
-                               if (slave) {
-                                       slave_set_wait_deactivation(slave, 1);
-                               }
-                       }
-               }
-       } else if (status == PKGMGR_STATUS_END) {
-               Eina_List *l;
-               Eina_List *n;
-               struct pkg_info *info;
-
-               EINA_LIST_FOREACH_SAFE(s_info.pkg_list, l, n, info) {
-                       if (!strcmp(info->pkgid, pkgname)) {
-                               struct slave_node *slave;
-
-                               slave = package_slave(info);
-                               if (slave) {
-                                       slave_set_wait_deactivation(slave, 0);
-                               }
-
-                               DbgPrint("Update widget_id: %s\n", info->widget_id);
-                               if (io_is_exists(info->widget_id) == 1) {
-                                       reload_package_info(info);
-                               } else {
-                                       io_uninstall_cb(pkgname, info->widget_id, -1, NULL);
-                               }
-                       }
-               }
-
-               (void)io_update_widget_package(pkgname, io_install_cb, NULL);
-       }
-
-       return 0;
-}
-
-static int crawling_widgetes(const char *pkgid, const char *widget_id, int prime, void *data)
-{
-       if (package_find(widget_id)) {
-               ErrPrint("Information of %s is already built\n", widget_id);
-       } else {
-               struct pkg_info *info;
-               info = package_create(pkgid, widget_id);
-               if (info) {
-                       DbgPrint("[%s] information is built prime(%d)\n", widget_id, prime);
-               }
-       }
-
-       return 0;
-}
-
-HAPI int package_init(void)
-{
-       client_global_event_handler_add(CLIENT_GLOBAL_EVENT_CREATE, client_created_cb, NULL);
-       pkgmgr_init();
-
-       pkgmgr_add_event_callback(PKGMGR_EVENT_INSTALL, update_cb, NULL);
-       pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, uninstall_cb, NULL);
-       pkgmgr_add_event_callback(PKGMGR_EVENT_UPDATE, update_cb, NULL);
-
-       io_crawling_widgetes(crawling_widgetes, NULL);
-       return 0;
-}
-
-HAPI int package_fini(void)
-{
-       Eina_List *p_l;
-       Eina_List *p_n;
-       Eina_List *i_l;
-       Eina_List *i_n;
-       struct pkg_info *info;
-       struct inst_info *inst;
-
-       pkgmgr_del_event_callback(PKGMGR_EVENT_INSTALL, update_cb, NULL);
-       pkgmgr_del_event_callback(PKGMGR_EVENT_UNINSTALL, uninstall_cb, NULL);
-       pkgmgr_del_event_callback(PKGMGR_EVENT_UPDATE, update_cb, NULL);
-       pkgmgr_fini();
-       client_global_event_handler_del(CLIENT_GLOBAL_EVENT_CREATE, client_created_cb, NULL);
-
-       EINA_LIST_FOREACH_SAFE(s_info.pkg_list, p_l, p_n, info) {
-               EINA_LIST_FOREACH_SAFE(info->inst_list, i_l, i_n, inst) {
-                       instance_state_reset(inst);
-                       instance_destroy(inst, WIDGET_DESTROY_TYPE_TERMINATE);
-               }
-
-               package_destroy(info);
-       }
-
-       return 0;
-}
-
-/**
- * Find a standalone provider
- */
-HAPI const char *package_find_by_secured_slave(struct slave_node *slave)
-{
-       Eina_List *l;
-       struct pkg_info *info;
-
-       if (!slave_is_secured(slave) && !slave_is_app(slave)) {
-               return NULL;
-       }
-
-       EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
-               if (info->slave == slave) {
-                       return info->widget_id;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI const char * const package_name(const struct pkg_info *info)
-{
-       return info->widget_id;
-}
-
-/*!
- * del_or_creat : 1 == create, 0 == delete
- */
-HAPI int package_alter_instances_to_client(struct client_node *client, enum alter_type alter)
-{
-       struct pkg_info *info;
-       Eina_List *l;
-
-       struct inst_info *inst;
-       Eina_List *i_l;
-
-       EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
-               EINA_LIST_FOREACH(info->inst_list, i_l, inst) {
-                       if (instance_client(inst) == client) {
-                               DbgPrint("Skip owner\n");
-                               continue;
-                       }
-
-                       if (!client_is_subscribed_group(client, instance_cluster(inst), instance_category(inst))
-                               && !client_is_subscribed_by_category(client, package_category(instance_package(inst))))
-                       {
-                               DbgPrint("Not subscribed [%s]\n", package_category(instance_package(inst)));
-                               continue;
-                       }
-
-                       switch (instance_state(inst)) {
-                       case INST_INIT:
-                       case INST_REQUEST_TO_ACTIVATE:
-                               /* Will be send a created event after the instance gets created event */
-                               switch (alter) {
-                               case ALTER_CREATE:
-                                       DbgPrint("ALTER_CREATE\n");
-                                       if (!instance_has_client(inst, client)) {
-                                               instance_add_client(inst, client);
-                                       }
-                                       break;
-                               case ALTER_DESTROY:
-                                       DbgPrint("ALTER_DESTROY\n");
-                                       if (instance_has_client(inst, client)) {
-                                               instance_del_client(inst, client);
-                                       }
-                                       break;
-                               default:
-                                       break;
-                               }
-                               break;
-                       case INST_ACTIVATED: /*!< This instance is actiavted, and used */
-                       case INST_REQUEST_TO_REACTIVATE: /*!< This instance will be reactivated soon */
-                       case INST_REQUEST_TO_DESTROY: /*!< This instance will be destroy soon */
-                               /*!
-                                * \note
-                                * Instances are lives in the system cluster/sub-cluster
-                                */
-                               switch (alter) {
-                               case ALTER_CREATE:
-                                       DbgPrint("ALTER_CREATE\n");
-                                       if (!instance_has_client(inst, client)) {
-                                               instance_unicast_created_event(inst, client);
-                                               instance_add_client(inst, client);
-                                               DbgPrint("(Subscribed) Created package: %s\n", info->widget_id);
-                                       }
-                                       break;
-                               case ALTER_DESTROY:
-                                       DbgPrint("ALTER_DESTROY\n");
-                                       if (instance_has_client(inst, client)) {
-                                               instance_unicast_deleted_event(inst, client, WIDGET_ERROR_NONE);
-                                               instance_del_client(inst, client);
-                                       }
-                                       break;
-                               default:
-                                       break;
-                               }
-
-                               break;
-                       default:
-                               DbgPrint("%s(%s) is not activated (%d)\n", package_name(info), instance_id(inst), instance_state(inst));
-                               break;
-                       }
-               }
-       }
-
-       return 0;
-}
-
-HAPI const Eina_List *package_list(void)
-{
-       return s_info.pkg_list;
-}
-
-HAPI int const package_fault_count(struct pkg_info *info)
-{
-       return info ? info->fault_count : 0;
-}
-
-HAPI int package_instance_count(struct pkg_info *info, int include_deleting)
-{
-       Eina_List *l;
-       struct inst_info *inst;
-       int count = 0;
-
-       EINA_LIST_FOREACH(info->inst_list, l, inst) {
-               switch (instance_state(inst)) {
-               case INST_INIT:
-               case INST_ACTIVATED:
-               case INST_REQUEST_TO_ACTIVATE:
-               case INST_REQUEST_TO_REACTIVATE:
-                       count++;
-                       break;
-               case INST_DESTROYED:
-               case INST_REQUEST_TO_DESTROY:
-                       count += !!include_deleting;
-               default:
-                       break;
-               }
-       }
-
-       return count;
-}
-
-HAPI int package_is_enabled(const char *appid)
-{
-       pkgmgrinfo_appinfo_h handle;
-       bool enabled;
-       int ret;
-
-       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
-       if (ret != PMINFO_R_OK) {
-               ErrPrint("Failed to get info\n");
-               return 0;
-       }
-
-       ret = pkgmgrinfo_appinfo_is_enabled(handle, &enabled);
-       if (ret != PMINFO_R_OK) {
-               ErrPrint("Failed to get info\n");
-               enabled = false;
-       }
-
-       pkgmgrinfo_appinfo_destroy_appinfo(handle);
-       return enabled == true;
-}
-
-HAPI char *package_meta_tag(const char *appid, const char *meta_tag)
-{
-       char *ret = NULL;
-       char *value = NULL;
-       int status;
-       pkgmgrinfo_appinfo_h handle;
-
-       if (!meta_tag || !appid) {
-               ErrPrint("meta(%s) is not valid (%s)\n", meta_tag, appid);
-               return NULL;
-       }
-
-       status = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
-       if (status != PMINFO_R_OK) {
-               return NULL;
-       }
-
-       /**
-        * @TODO
-        * Need to find replacement of this API
-        *
-       status = pkgmgrinfo_appinfo_get_metadata_value(handle, meta_tag, &value);
-       if (status != PMINFO_R_OK) {
-               pkgmgrinfo_appinfo_destroy_appinfo(handle);
-               return NULL;
-       }
-       */
-
-       if (value && value[0] != '\0') {
-               ret = strdup(value);
-       }
-
-       pkgmgrinfo_appinfo_destroy_appinfo(handle);
-       return ret;
-}
-
-HAPI int package_faulted(struct pkg_info *pkg, int broadcast)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct slave_node *slave;
-       struct inst_info *inst;
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               ErrPrint("Package has no slave?\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       /* Emulated fault routine */
-       // (void)package_set_fault_info(pkg, util_timestamp(), slave_name(slave), __func__);
-       if (broadcast) {
-               fault_broadcast_info(package_name(pkg), slave_name(slave), __func__);
-       }
-
-       DbgPrint("package: %s (forucely faulted %s)\n", package_name(pkg), slave_name(slave));
-       EINA_LIST_FOREACH_SAFE(pkg->inst_list, l, n, inst) {
-               DbgPrint("Destroy instance %p\n", inst);
-               instance_destroy(inst, WIDGET_DESTROY_TYPE_FAULT);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI char *package_get_pkgid(const char *appid)
-{
-       int ret;
-       pkgmgrinfo_appinfo_h handle;
-       char *new_appid = NULL;
-       char *pkgid = NULL;
-
-       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
-       if (ret != PMINFO_R_OK) {
-               ErrPrint("Failed to get appinfo\n");
-               return NULL;
-       }
-
-       ret = pkgmgrinfo_appinfo_get_pkgid(handle, &new_appid);
-       if (ret != PMINFO_R_OK) {
-               pkgmgrinfo_appinfo_destroy_appinfo(handle);
-               ErrPrint("Failed to get pkgname for (%s)\n", appid);
-               return NULL;
-       }
-
-       if (new_appid && new_appid[0] != '\0') {
-               pkgid = strdup(new_appid);
-               if (!pkgid) {
-                       ErrPrint("strdup: %d\n", errno);
-               }
-       }
-       pkgmgrinfo_appinfo_destroy_appinfo(handle);
-
-       return pkgid;
-}
-
-/* End of a file */
diff --git a/src/parser.c b/src/parser.c
deleted file mode 100644 (file)
index 41c4957..0000000
+++ /dev/null
@@ -1,888 +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> /* strtod */
-#include <errno.h>
-#include <ctype.h> /* isspace */
-
-#include <Eina.h>
-#include <dlog.h>
-
-#include <widget_service.h>
-#include <widget_errno.h>
-#include <widget_conf.h>
-
-#include "util.h"
-#include "debug.h"
-#include "conf.h"
-#include "parser.h"
-
-static Eina_List *s_list;
-int errno;
-
-#define RETURN_TYPE long
-
-struct parser {
-       char *filename;
-       double period;
-       int timeout;
-       int network;
-       char *auto_launch;
-       unsigned int size;
-       unsigned int gbar_width;
-       unsigned int gbar_height;
-       char *group;
-       int secured;
-
-       char *gbar_path;
-       char *gbar_group;
-
-       char *widget_path;
-       char *widget_group;
-       int pinup;
-       int text_gbar;
-       int text_lb;
-       int buffer_gbar;
-       int buffer_lb;
-
-       char *abi;
-
-       char *script;
-};
-
-HAPI double parser_period(struct parser *handle)
-{
-       return handle->period;
-}
-
-HAPI int parser_network(struct parser *handle)
-{
-       return handle->network;
-}
-
-HAPI int parser_timeout(struct parser *handle)
-{
-       return handle->timeout;
-}
-
-HAPI const char *parser_auto_launch(struct parser *handle)
-{
-       return handle->auto_launch;
-}
-
-HAPI const char *parser_script(struct parser *handle)
-{
-       return handle->script;
-}
-
-HAPI const char *parser_abi(struct parser *handle)
-{
-       return handle->abi;
-}
-
-HAPI unsigned int parser_size(struct parser *handle)
-{
-       return handle->size;
-}
-
-HAPI const char *parser_widget_path(struct parser *handle)
-{
-       return handle->widget_path;
-}
-
-HAPI const char *parser_widget_group(struct parser *handle)
-{
-       return handle->widget_group;
-}
-
-HAPI const char *parser_gbar_path(struct parser *handle)
-{
-       return handle->gbar_path;
-}
-
-HAPI const char *parser_gbar_group(struct parser *handle)
-{
-       return handle->gbar_group;
-}
-
-HAPI const char *parser_group_str(struct parser *handle)
-{
-       return handle->group;
-}
-
-HAPI int parser_secured(struct parser *handle)
-{
-       return handle->secured;
-}
-
-HAPI void parser_get_gbar_size(struct parser *handle, unsigned int *width, unsigned int *height)
-{
-       *width = handle->gbar_width;
-       *height = handle->gbar_height;
-}
-
-HAPI int parser_pinup(struct parser *handle)
-{
-       return handle->pinup;
-}
-
-HAPI int parser_text_widget(struct parser *handle)
-{
-       return handle->text_lb;
-}
-
-HAPI int parser_text_gbar(struct parser *handle)
-{
-       return handle->text_gbar;
-}
-
-HAPI int parser_buffer_widget(struct parser *handle)
-{
-       return handle->buffer_lb;
-}
-
-HAPI int parser_buffer_gbar(struct parser *handle)
-{
-       return handle->buffer_gbar;
-}
-
-HAPI RETURN_TYPE parser_find(const char *pkgname)
-{
-       Eina_List *l;
-       struct parser *item;
-       char *filename;
-       int len;
-       int ret;
-
-       len = strlen(pkgname) * 2 + strlen(WIDGET_CONF_CONF_PATH);
-
-       filename = malloc(len);
-       if (!filename) {
-               return (RETURN_TYPE)0;
-       }
-
-       ret = snprintf(filename, len, WIDGET_CONF_CONF_PATH, pkgname, pkgname);
-       if (ret < 0) {
-               DbgFree(filename);
-               return (RETURN_TYPE)0;
-       }
-
-       DbgPrint("Conf file %s for package %s\n", filename, pkgname);
-
-       EINA_LIST_FOREACH(s_list, l, item) {
-               if (!strcmp(item->filename, filename)) {
-                       DbgFree(filename);
-                       return (RETURN_TYPE)item;
-               }
-       }
-
-       DbgFree(filename);
-       return (RETURN_TYPE)0;
-}
-
-static inline int parse_size(const char *buffer, unsigned int *size)
-{
-       register int i;
-       int w;
-       int h;
-
-       enum {
-               START,
-               WIDTH,
-               DELIM,
-               HEIGHT,
-               ERROR,
-               STOP,
-               END
-       } state;
-
-       *size = 0;
-       state = START;
-       i = 0;
-       w = 0;
-       h = 0;
-
-       while (state != ERROR && state != END) {
-               switch (state) {
-               case START:
-                       switch (buffer[i]) {
-                       case '1'...'9':
-                               state = WIDTH;
-                               break;
-                       case ' ':
-                       case '\t':
-                       case ';':
-                               i++;
-                               break;
-                       case '\0':
-                               state = END;
-                               break;
-                       default:
-                               state = ERROR;
-                               break;
-                       }
-                       break;
-               case WIDTH:
-                       switch (buffer[i]) {
-                       case '0'...'9':
-                               w = (w * 10) + (buffer[i] - '0');
-                               i++;
-                               break;
-                       case 'x':
-                               state = DELIM;
-                               i++;
-                               break;
-                       default:
-                               state = ERROR;
-                               break;
-                       }
-
-                       break;
-               case DELIM:
-                       switch (buffer[i]) {
-                       case '1'...'9':
-                               state = HEIGHT;
-                               break;
-                       case ' ':
-                       case '\t':
-                               i++;
-                               break;
-                       default:
-                               state = ERROR;
-                               break;
-                       }
-                       break;
-               case HEIGHT:
-                       switch (buffer[i]) {
-                       case '0'...'9':
-                               h = (h * 10) + (buffer[i] - '0');
-                               i++;
-                               break;
-                       case ';':
-                       case '\0':
-                               state = STOP;
-                               break;
-                       default:
-                               state = ERROR;
-                               break;
-                       }
-                       break;
-               case STOP:
-                       if (w == 1 && h == 1) {
-                               *size |= WIDGET_SIZE_TYPE_1x1;
-                       } else if (w == 2 && h == 1) {
-                               *size |= WIDGET_SIZE_TYPE_2x1;
-                       } else if (w == 2 && h == 2) {
-                               *size |= WIDGET_SIZE_TYPE_2x2;
-                       } else if (w == 4 && h == 1) {
-                               *size |= WIDGET_SIZE_TYPE_4x1;
-                       } else if (w == 4 && h == 2) {
-                               *size |= WIDGET_SIZE_TYPE_4x2;
-                       } else if (w == 4 && h == 3) {
-                               *size |= WIDGET_SIZE_TYPE_4x3;
-                       } else if (w == 4 && h == 4) {
-                               *size |= WIDGET_SIZE_TYPE_4x4;
-                       } else if (w == 21 && h == 21) {
-                               *size |= WIDGET_SIZE_TYPE_EASY_1x1;
-                       } else if (w == 23 && h == 21) {
-                               *size |= WIDGET_SIZE_TYPE_EASY_3x1;
-                       } else if (w == 23 && h == 23) {
-                               *size |= WIDGET_SIZE_TYPE_EASY_3x3;
-                       } else {
-                               ErrPrint("Invalid size type: %dx%d\n", w, h);
-                       }
-
-                       if (buffer[i] == ';') {
-                               state = START;
-                       } else if (buffer[i] == '\0') {
-                               state = END;
-                       }
-
-                       w = 0;
-                       h = 0;
-                       break;
-               default:
-                       return -1;
-               }
-       }
-
-       return *size ? 0 : -1;
-}
-
-/*!
- * \note
- * This will change the value of "buffer"
- */
-static inline const char *rtrim(char *buffer)
-{
-       int len;
-
-       len = strlen(buffer);
-       while (len > 0 && isspace(buffer[len - 1])) {
-               len--;
-       }
-
-       if (len <= 0) {
-               return NULL;
-       }
-
-       buffer[len] = '\0';
-
-       return buffer;
-}
-
-/*!
- * \note
- * This will change the value of "buffer"
- */
-static inline char *dup_rtrim(char *buffer)
-{
-       char *ret;
-
-       if (!rtrim(buffer)) {
-               return NULL;
-       }
-
-       ret = strdup(buffer);
-       if (!ret) {
-               ErrPrint("strdup: %d\n", errno);
-               return NULL;
-       }
-
-       return ret;
-}
-
-static void period_handler(struct parser *item, char *buffer)
-{
-       char *tmp = NULL;
-
-       if (!rtrim(buffer)) {
-               return;
-       }
-
-       item->period = strtod(buffer, &tmp);
-}
-
-static void timeout_handler(struct parser *item, char *buffer)
-{
-       if (!rtrim(buffer)) {
-               return;
-       }
-
-       item->timeout = atoi(buffer);
-}
-
-static void network_handler(struct parser *item, char *buffer)
-{
-       if (!rtrim(buffer)) {
-               return;
-       }
-
-       item->network = !!atoi(buffer);
-}
-
-static void auto_launch_handler(struct parser *item, char *buffer)
-{
-       if (!rtrim(buffer)) {
-               return;
-       }
-
-       item->auto_launch = strdup(buffer);
-       if (!item->auto_launch) {
-               ErrPrint("strdup: %d\n", errno);
-               return;
-       }
-}
-
-static void size_handler(struct parser *item, char *buffer)
-{
-       if (parse_size(buffer, &item->size) == -1) {
-               ErrPrint("Failed to get size\n");
-               item->size = 0x00000001;
-       }
-}
-
-static void gbar_size_handler(struct parser *item, char *buffer)
-{
-       if (sscanf(buffer, "%ux%u", &item->gbar_width, &item->gbar_height) != 2) {
-               ErrPrint("parse pd size\n");
-       }
-}
-
-static void text_widget_handler(struct parser *item, char *buffer)
-{
-       if (!rtrim(buffer)) {
-               return;
-       }
-
-       item->text_lb = !!atoi(buffer);
-}
-
-static void abi_handler(struct parser *item, char *buffer)
-{
-       item->abi = dup_rtrim(buffer);
-}
-
-static void script_handler(struct parser *item, char *buffer)
-{
-       item->script = dup_rtrim(buffer);
-}
-
-static void buffer_gbar_handler(struct parser *item, char *buffer)
-{
-       if (!rtrim(buffer)) {
-               return;
-       }
-
-       item->buffer_gbar = !!atoi(buffer);
-}
-
-static void buffer_widget_handler(struct parser *item, char *buffer)
-{
-       if (!rtrim(buffer)) {
-               return;
-       }
-
-       item->buffer_lb = !!atoi(buffer);
-}
-
-static void text_gbar_handler(struct parser *item, char *buffer)
-{
-       if (!rtrim(buffer)) {
-               return;
-       }
-
-       item->text_gbar = !!atoi(buffer);
-}
-
-static void pinup_handler(struct parser *item, char *buffer)
-{
-       if (!rtrim(buffer)) {
-               return;
-       }
-
-       item->pinup = !!atoi(buffer);
-}
-
-static void widget_path_handler(struct parser *item, char *buffer)
-{
-       if (item->widget_path) {
-               DbgFree(item->widget_path);
-       }
-
-       item->widget_path = dup_rtrim(buffer);
-       if (!item->widget_path) {
-               ErrPrint("strdup: %d\n", errno);
-       }
-}
-
-static void group_handler(struct parser *item, char *buffer)
-{
-       if (item->group) {
-               DbgFree(item->group);
-       }
-
-       item->group = dup_rtrim(buffer);
-       if (!item->group) {
-               ErrPrint("strdup: %d\n", errno);
-       }
-}
-
-static void secured_handler(struct parser *item, char *buffer)
-{
-       if (!rtrim(buffer)) {
-               return;
-       }
-
-       item->secured = !!atoi(buffer);
-}
-
-static void widget_group_handler(struct parser *item, char *buffer)
-{
-       if (item->widget_group) {
-               DbgFree(item->widget_group);
-       }
-
-       item->widget_group = dup_rtrim(buffer);
-       if (!item->widget_group) {
-               ErrPrint("strdup: %d\n", errno);
-       }
-}
-
-static void gbar_path_handler(struct parser *item, char *buffer)
-{
-       if (item->gbar_path) {
-               DbgFree(item->gbar_path);
-       }
-
-       item->gbar_path = dup_rtrim(buffer);
-       if (!item->gbar_path) {
-               ErrPrint("strdup: %d\n", errno);
-       }
-}
-
-static void gbar_group_handler(struct parser *item, char *buffer)
-{
-       if (item->gbar_group) {
-               DbgFree(item->gbar_group);
-       }
-
-       item->gbar_group = dup_rtrim(buffer);
-       if (!item->gbar_group) {
-               ErrPrint("strdup: %d\n", errno);
-       }
-}
-
-HAPI struct parser *parser_load(const char *pkgname)
-{
-       struct parser *item;
-       FILE *fp;
-       int c;
-       enum state {
-               START,
-               SPACE,
-               TOKEN,
-               VALUE,
-               ERROR,
-               COMMENT,
-               END
-       } state;
-       int ch_idx;
-       int token_idx;
-       int buffer_idx;
-       int quote;
-       int len;
-       int linelen;
-       char buffer[256];
-       static const struct token_parser {
-               const char *name;
-               void (*handler)(struct parser *, char *buffer);
-       } token_handler[] = {
-               {
-                       .name = "period",
-                       .handler = period_handler,
-               },
-               {
-                       .name = "timeout",
-                       .handler = timeout_handler,
-               },
-               {
-                       .name = "network",
-                       .handler = network_handler,
-               },
-               {
-                       .name = "auto_launch",
-                       .handler = auto_launch_handler,
-               },
-               {
-                       .name = "size",
-                       .handler = size_handler,
-               },
-               {
-                       .name = "group",
-                       .handler = group_handler,
-               },
-               {
-                       .name = "secured",
-                       .handler = secured_handler,
-               },
-               {
-                       .name = "widget_path",
-                       .handler = widget_path_handler,
-               },
-               {
-                       .name = "widget_group",
-                       .handler = widget_group_handler,
-               },
-               {
-                       .name = "gbar_path",
-                       .handler = gbar_path_handler,
-               },
-               {
-                       .name = "gbar_group",
-                       .handler = gbar_group_handler,
-               },
-               {
-                       .name = "gbar_size",
-                       .handler = gbar_size_handler,
-               },
-               {
-                       .name = "pinup",
-                       .handler = pinup_handler,
-               },
-               {
-                       .name = "text_widget",
-                       .handler = text_widget_handler,
-               },
-               {
-                       .name = "text_gbar",
-                       .handler = text_gbar_handler,
-               },
-               {
-                       .name = "buffer_widget",
-                       .handler = buffer_widget_handler,
-               },
-               {
-                       .name = "buffer_gbar",
-                       .handler = buffer_gbar_handler,
-               },
-               {
-                       .name = "script",
-                       .handler = script_handler,
-               },
-               {
-                       .name = "abi",
-                       .handler = abi_handler,
-               },
-               {
-                       .name = NULL,
-                       .handler = NULL,
-               },
-       };
-       int ret;
-
-       item = calloc(1, sizeof(*item));
-       if (!item) {
-               return 0;
-       }
-
-       /* live-, .conf */
-       len = strlen(WIDGET_CONF_CONF_PATH) + strlen(pkgname) * 2;
-       item->filename = malloc(len);
-       if (!item->filename) {
-               ErrPrint("malloc: %d\n", errno);
-               DbgFree(item);
-               return 0;
-       }
-
-       ret = snprintf(item->filename, len, WIDGET_CONF_CONF_PATH, pkgname, pkgname);
-       if (ret < 0) {
-               ErrPrint("snprintf: %d\n", errno);
-               DbgFree(item->filename);
-               DbgFree(item);
-               return 0;
-       }
-
-       item->widget_path = NULL;
-       item->widget_group = NULL;
-       item->gbar_width = 0;
-       item->gbar_height = 0;
-       item->auto_launch = NULL;
-       item->size = 0x00000001;
-       item->group = NULL;
-       item->secured = 0;
-       item->pinup = 0;
-
-       fp = fopen(item->filename, "rt");
-       if (!fp) {
-               DbgFree(item->filename);
-               DbgFree(item);
-               return 0;
-       }
-
-       state = START;
-       ch_idx = 0;
-       token_idx = -1;
-       buffer_idx = 0;
-       quote = 0;
-       linelen = 0;
-       do {
-               c = getc(fp);
-               if ((c == EOF) && (state == VALUE)) {
-                       state = END;
-               }
-
-               switch (state) {
-               case COMMENT:
-                       if (c == CR || c == LF || c == EOF) {
-                               buffer[buffer_idx] = '\0';
-
-                               state = START;
-                               token_idx = -1;
-                               ch_idx = 0;
-                               buffer_idx = 0;
-                               linelen = -1; /* Will be ZERO by follwing increment code */
-                               quote = 0;
-                       } else {
-                               buffer[buffer_idx++] = c;
-                               if (buffer_idx == (sizeof(buffer) - 1)) {
-                                       buffer[buffer_idx] = '\0';
-                                       buffer_idx = 0;
-                               }
-                       }
-                       break;
-               case START:
-                       if (linelen == 0 && c == '#') {
-                               state = COMMENT;
-                       } else if (isspace(c)) {
-                               /* Ignore empty space */
-                       } else {
-                               state = TOKEN;
-                               ungetc(c, fp);
-                       }
-                       break;
-               case SPACE:
-                       if (c == '=') {
-                               state = VALUE;
-                       } else if (!isspace(c)) {
-                               state = ERROR;
-                       }
-                       break;
-               case VALUE:
-                       if (c == '"') {
-                               if (quote == 1) {
-                                       buffer[buffer_idx] = '\0';
-                                       state = END;
-                               } else if (buffer_idx != 0) {
-                                       buffer[buffer_idx++] = c;
-                                       if (buffer_idx >= sizeof(buffer)) {
-                                               state = ERROR;
-                                       }
-                               } else {
-                                       quote = 1;
-                               }
-                       } else if (isspace(c)) {
-                               if (buffer_idx == 0) {
-                                       /* Ignore */
-                               } else if (quote == 1) {
-                                       buffer[buffer_idx++] = c;
-                                       if (buffer_idx >= sizeof(buffer)) {
-                                               state = ERROR;
-                                       }
-                               } else {
-                                       buffer[buffer_idx] = '\0';
-                                       ungetc(c, fp);
-                                       state = END;
-                               }
-                       } else {
-                               buffer[buffer_idx++] = c;
-                               if (buffer_idx >= sizeof(buffer)) {
-                                       state = ERROR;
-                               }
-                       }
-                       break;
-               case TOKEN:
-                       if (c == '=') {
-                               if (token_idx < 0) {
-                                       state = ERROR;
-                               } else {
-                                       state = VALUE;
-                               }
-                       } else if (isspace(c)) {
-                               if (token_idx < 0) {
-                                       break;
-                               }
-
-                               if (token_handler[token_idx].name[ch_idx] != '\0') {
-                                       state = ERROR;
-                               } else {
-                                       state = SPACE;
-                               }
-                       } else  {
-                               if (token_idx < 0) {
-                                       /* Now start to find a token! */
-                                       token_idx = 0;
-                               }
-
-                               if (token_handler[token_idx].name[ch_idx] == c) {
-                                       ch_idx++;
-                               } else {
-                                       ungetc(c, fp);
-                                       while (ch_idx-- > 0) {
-                                               ungetc(token_handler[token_idx].name[ch_idx], fp);
-                                       }
-
-                                       token_idx++;
-
-                                       if (token_handler[token_idx].name == NULL) {
-                                               state = ERROR;
-                                       } else {
-                                               ch_idx = 0;
-                                       }
-                               }
-                       }
-                       break;
-               case ERROR:
-                       if (c == CR || c == LF || c == EOF) {
-                               state = START;
-                               token_idx = -1;
-                               buffer_idx = 0;
-                               ch_idx = 0;
-                               linelen = -1;
-                               quote = 0;
-                       }
-                       break;
-               case END:
-                       if (c == LF || c == CR || c == EOF) {
-                               state = START;
-
-                               /*!
-                                * \NOTE
-                                * Make the string terminator
-                                */
-                               buffer[buffer_idx] = '\0';
-
-                               if (token_idx >= 0 && token_handler[token_idx].handler) {
-                                       token_handler[token_idx].handler(item, buffer);
-                               }
-
-                               token_idx = -1;
-                               ch_idx = 0;
-                               buffer_idx = 0;
-                               linelen = -1;
-                               quote = 0;
-                               /* Finish */
-                       } else if (isspace(c)) {
-                               /* ignore */
-                       } else {
-                               state = ERROR;
-                       }
-                       break;
-               default:
-                       /* ?? */
-                       break;
-               }
-
-               linelen++;
-       } while (c != EOF);
-
-       if (fclose(fp) != 0) {
-               ErrPrint("fclose: %d\n", errno);
-       }
-
-       s_list = eina_list_append(s_list, item);
-       return item;
-}
-
-HAPI int parser_unload(struct parser *item)
-{
-       s_list = eina_list_remove(s_list, item);
-
-       DbgFree(item->auto_launch);
-       DbgFree(item->abi);
-       DbgFree(item->script);
-       DbgFree(item->group);
-       DbgFree(item->gbar_group);
-       DbgFree(item->gbar_path);
-       DbgFree(item->widget_group);
-       DbgFree(item->widget_path);
-       DbgFree(item->filename);
-       DbgFree(item);
-       return WIDGET_ERROR_NONE;
-}
-
-/* End of a file */
index 8201e0b..18fd5e8 100644 (file)
@@ -20,9 +20,9 @@
 
 #include <dlog.h>
 #include <package-manager.h>
-#include <widget_errno.h>
 
 #include <Ecore.h>
+#include "service_common.h"
 #include "util.h"
 #include "debug.h"
 #include "pkgmgr.h"
@@ -203,14 +203,14 @@ static int start_cb(const char *pkgname, const char *val, void *data)
        item = calloc(1, sizeof(*item));
        if (!item) {
                ErrPrint("calloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
+               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
        item->pkgname = strdup(pkgname);
        if (!item->pkgname) {
                ErrPrint("strdup: %d\n", errno);
                DbgFree(item);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
+               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
        item->status = PKGMGR_STATUS_START;
@@ -229,13 +229,13 @@ static int start_cb(const char *pkgname, const char *val, void *data)
                DbgFree(item->pkgname);
                DbgFree(item);
                ErrPrint("Invalid val: %s\n", val);
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        s_info.item_list = eina_list_append(s_info.item_list, item);
 
        invoke_callback(pkgname, item, 0.0f);
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 static int icon_path_cb(const char *pkgname, const char *val, void *data)
@@ -246,7 +246,7 @@ static int icon_path_cb(const char *pkgname, const char *val, void *data)
 
        item = find_item(pkgname);
        if (!item) {
-               return WIDGET_ERROR_NOT_EXIST;
+               return SERVICE_COMMON_ERROR_NOT_EXIST;
        }
 
        if (item->icon) {
@@ -256,10 +256,10 @@ static int icon_path_cb(const char *pkgname, const char *val, void *data)
        item->icon = strdup(val);
        if (!item->icon) {
                ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
+               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 static int command_cb(const char *pkgname, const char *val, void *data)
@@ -270,17 +270,17 @@ static int command_cb(const char *pkgname, const char *val, void *data)
 
        item = find_item(pkgname);
        if (!item) {
-               return WIDGET_ERROR_NOT_EXIST;
+               return SERVICE_COMMON_ERROR_NOT_EXIST;
        }
 
        if (!is_valid_status(item, val)) {
                DbgPrint("Invalid status: %d, %s\n", item->type, val);
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        item->status = PKGMGR_STATUS_COMMAND;
        invoke_callback(pkgname, item, 0.0f);
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 static int error_cb(const char *pkgname, const char *val, void *data)
@@ -292,12 +292,12 @@ static int error_cb(const char *pkgname, const char *val, void *data)
 
        item = find_item(pkgname);
        if (!item) {
-               return WIDGET_ERROR_NOT_EXIST;
+               return SERVICE_COMMON_ERROR_NOT_EXIST;
        }
 
        item->status = PKGMGR_STATUS_ERROR;
        invoke_callback(pkgname, item, 0.0f);
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 static int change_pkgname_cb(const char *pkgname, const char *val, void *data)
@@ -309,18 +309,18 @@ static int change_pkgname_cb(const char *pkgname, const char *val, void *data)
 
        item = find_item(pkgname);
        if (!item) {
-               return WIDGET_ERROR_NOT_EXIST;
+               return SERVICE_COMMON_ERROR_NOT_EXIST;
        }
 
        new_pkgname = strdup(val);
        if (!new_pkgname) {
                ErrPrint("strdup: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
+               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
        DbgFree(item->pkgname);
        item->pkgname = new_pkgname;
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 static int download_cb(const char *pkgname, const char *val, void *data)
@@ -334,7 +334,7 @@ static int download_cb(const char *pkgname, const char *val, void *data)
        item = find_item(pkgname);
        if (!item) {
                DbgPrint("ITEM is not started from the start_cb\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        if (item->type != PKGMGR_EVENT_DOWNLOAD) {
@@ -350,19 +350,19 @@ static int download_cb(const char *pkgname, const char *val, void *data)
                break;
        default:
                ErrPrint("Invalid state [%s, %s]\n", pkgname, val);
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        if (val) {
                if (sscanf(val, "%lf", &value) != 1) {
-                       value = (double)WIDGET_ERROR_INVALID_PARAMETER;
+                       value = (double)SERVICE_COMMON_ERROR_INVALID_PARAMETER;
                }
        } else {
-               value = (double)WIDGET_ERROR_INVALID_PARAMETER;
+               value = (double)SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        invoke_download_event_handler(pkgname, item->status, value);
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 static int progress_cb(const char *pkgname, const char *val, void *data)
@@ -376,7 +376,7 @@ static int progress_cb(const char *pkgname, const char *val, void *data)
        item = find_item(pkgname);
        if (!item) {
                ErrPrint("ITEM is not started from the start_cb\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        switch (item->status) {
@@ -387,19 +387,19 @@ static int progress_cb(const char *pkgname, const char *val, void *data)
                break;
        default:
                ErrPrint("Invalid state [%s, %s]\n", pkgname, val);
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        if (val) {
                if (sscanf(val, "%lf", &value) != 1) {
-                       value = (double)WIDGET_ERROR_INVALID_PARAMETER;
+                       value = (double)SERVICE_COMMON_ERROR_INVALID_PARAMETER;
                }
        } else {
-               value = (double)WIDGET_ERROR_INVALID_PARAMETER;
+               value = (double)SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        invoke_callback(pkgname, item, value);
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 static int end_cb(const char *pkgname, const char *val, void *data)
@@ -410,7 +410,7 @@ static int end_cb(const char *pkgname, const char *val, void *data)
 
        item = find_item(pkgname);
        if (!item) {
-               return WIDGET_ERROR_NOT_EXIST;
+               return SERVICE_COMMON_ERROR_NOT_EXIST;
        }
 
        item->status = !strcasecmp(val, "ok") ? PKGMGR_STATUS_END : PKGMGR_STATUS_ERROR;
@@ -421,7 +421,7 @@ static int end_cb(const char *pkgname, const char *val, void *data)
        DbgFree(item->icon);
        DbgFree(item->pkgname);
        DbgFree(item);
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 static struct pkgmgr_handler {
@@ -460,25 +460,25 @@ static int pkgmgr_cb(uid_t target_uid, int req_id, const char *type, const char
                }
        }
 
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 HAPI int pkgmgr_init(void)
 {
        if (s_info.listen_pc) {
-               return WIDGET_ERROR_ALREADY_EXIST;
+               return SERVICE_COMMON_ERROR_ALREADY_EXIST;
        }
 
        s_info.listen_pc = pkgmgr_client_new(PC_LISTENING);
        if (!s_info.listen_pc) {
-               return WIDGET_ERROR_FAULT;
+               return SERVICE_COMMON_ERROR_FAULT;
        }
 
        if (pkgmgr_client_listen_status(s_info.listen_pc, pkgmgr_cb, NULL) != PKGMGR_R_OK) {
-               return WIDGET_ERROR_FAULT;
+               return SERVICE_COMMON_ERROR_FAULT;
        }
 
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 HAPI int pkgmgr_fini(void)
@@ -487,11 +487,11 @@ HAPI int pkgmgr_fini(void)
        struct item *ctx;
 
        if (!s_info.listen_pc) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        if (pkgmgr_client_free(s_info.listen_pc) != PKGMGR_R_OK) {
-               return WIDGET_ERROR_FAULT;
+               return SERVICE_COMMON_ERROR_FAULT;
        }
 
        s_info.listen_pc = NULL;
@@ -522,7 +522,7 @@ HAPI int pkgmgr_fini(void)
                DbgFree(ctx);
        }
 
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 HAPI int pkgmgr_add_event_callback(enum pkgmgr_event_type type, int (*cb)(const char *pkgname, enum pkgmgr_status status, double value, void *data), void *data)
@@ -532,7 +532,7 @@ HAPI int pkgmgr_add_event_callback(enum pkgmgr_event_type type, int (*cb)(const
        item = calloc(1, sizeof(*item));
        if (!item) {
                ErrPrint("calloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
+               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
        item->cb = cb;
@@ -556,10 +556,10 @@ HAPI int pkgmgr_add_event_callback(enum pkgmgr_event_type type, int (*cb)(const
                break;
        default:
                DbgFree(item);
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 HAPI void *pkgmgr_del_event_callback(enum pkgmgr_event_type type, int (*cb)(const char *pkgname, enum pkgmgr_status status, double value, void *data), void *data)
diff --git a/src/script_handler.c b/src/script_handler.c
deleted file mode 100644 (file)
index aa82041..0000000
+++ /dev/null
@@ -1,1519 +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 <errno.h>
-#include <stdlib.h> /* free */
-#include <ctype.h>
-#include <dlfcn.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <Ecore.h>
-#include <Eina.h>
-
-#include <dlog.h>
-#include <packet.h>
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_conf.h>
-
-#include "slave_life.h"
-#include "slave_rpc.h"
-#include "client_life.h"
-#include "package.h"
-#include "instance.h"
-#include "buffer_handler.h"
-#include "script_handler.h"
-#include "debug.h"
-#include "conf.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
-};
-
-int errno;
-
-static struct info {
-       Eina_List *script_port_list;
-       enum widget_fb_type env_buf_type;
-} s_info = {
-       .script_port_list = NULL,
-       .env_buf_type = WIDGET_FB_TYPE_FILE,
-};
-
-struct script_port {
-       void *handle;
-
-       const char *(*magic_id)(void);
-       int (*update_color)(void *handle, const char *id, const char *part, const char *rgba);
-       int (*update_text)(void *handle, const char *id, const char *part, const char *text);
-       int (*update_image)(void *handle, const char *id, const char *part, const char *path, const char *option);
-       int (*update_access)(void *handle, const char *id, const char *part, const char *text, const char *option);
-       int (*operate_access)(void *handle, const char *id, const char *part, const char *operation, const char *option);
-       int (*update_script)(void *handle, const char *src_id, const char *target_id, const char *part, const char *path, const char *option);
-       int (*update_signal)(void *handle, const char *id, const char *part, const char *signal);
-       int (*update_drag)(void *handle, const char *id, const char *part, double x, double y);
-       int (*update_size)(void *handle, const char *id, int w, int h);
-       int (*update_category)(void *handle, const char *id, const char *category);
-       int (*feed_event)(void *handle, int event_type, int x, int y, int down, unsigned int keycode, double timestamp);
-
-       void *(*create)(void *buffer_info, const char *file, const char *option);
-       int (*destroy)(void *handle);
-
-       int (*load)(void *handle, int (*render_pre)(void *buffer_info, void *data), int (*render_post)(void *buffer_info, void *data), void *data);
-       int (*unload)(void *handle);
-
-       int (*init)(double scale, int premultiplied);
-       int (*fini)(void);
-};
-
-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;
-};
-
-struct script_info {
-       struct buffer_info *buffer_handle; 
-       int loaded;
-
-       int w;
-       int h;
-
-       int x;
-       int y;
-       int down;
-       int device;
-
-       unsigned int keycode;
-
-       struct script_port *port;
-       void *port_data;
-
-       Eina_List *cached_blocks;
-};
-
-static inline void consuming_parsed_block(struct inst_info *inst, int is_pd, struct block *block);
-
-static int load_all_ports(void)
-{
-       struct script_port *item;
-       struct dirent *ent;
-       DIR *dir;
-       char *path;
-       int pathlen;
-
-       dir = opendir(WIDGET_CONF_SCRIPT_PORT_PATH);
-       if (!dir) {
-               ErrPrint("opendir: %d\n", errno);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       while ((ent = readdir(dir))) {
-               if (ent->d_name[0] == '.') {
-                       continue;
-               }
-
-               pathlen = strlen(ent->d_name) + strlen(WIDGET_CONF_SCRIPT_PORT_PATH) + 1;
-               path = malloc(pathlen);
-               if (!path) {
-                       ErrPrint("malloc: %d %d\n", errno, pathlen);
-                       if (closedir(dir) < 0) {
-                               ErrPrint("closedir: %d\n", errno);
-                       }
-                       return WIDGET_ERROR_OUT_OF_MEMORY;
-               }
-
-               snprintf(path, pathlen, "%s%s", WIDGET_CONF_SCRIPT_PORT_PATH, ent->d_name);
-
-               item = malloc(sizeof(*item));
-               if (!item) {
-                       ErrPrint("malloc: %d\n", errno);
-                       DbgFree(path);
-                       if (closedir(dir) < 0) {
-                               ErrPrint("closedir: %d\n", errno);
-                       }
-                       return WIDGET_ERROR_OUT_OF_MEMORY;
-               }
-
-               DbgPrint("Open SCRIPT PORT: %s\n", path);
-               item->handle = dlopen(path, RTLD_GLOBAL | RTLD_NOW | RTLD_DEEPBIND);
-               DbgFree(path);
-               if (!item->handle) {
-                       ErrPrint("Error: %s\n", dlerror());
-                       DbgFree(item);
-                       if (closedir(dir) < 0) {
-                               ErrPrint("closedir: %d\n", errno);
-                       }
-                       return WIDGET_ERROR_FAULT;
-               }
-
-               item->magic_id = dlsym(item->handle, "script_magic_id");
-               if (!item->magic_id) {
-                       goto errout;
-               }
-
-               DbgPrint("SCRIPT PORT magic id: %s\n", item->magic_id());
-
-               item->update_color = dlsym(item->handle, "script_update_color");
-               if (!item->update_color) {
-                       goto errout;
-               }
-
-               item->update_text = dlsym(item->handle, "script_update_text");
-               if (!item->update_text) {
-                       goto errout;
-               }
-
-               item->update_image = dlsym(item->handle, "script_update_image");
-               if (!item->update_image) {
-                       goto errout;
-               }
-
-               item->update_access = dlsym(item->handle, "script_update_access");
-               if (!item->update_access) {
-                       goto errout;
-               }
-
-               item->operate_access = dlsym(item->handle, "script_operate_access");
-               if (!item->operate_access) {
-                       goto errout;
-               }
-
-               item->update_script = dlsym(item->handle, "script_update_script");
-               if (!item->update_script) {
-                       goto errout;
-               }
-
-               item->update_signal = dlsym(item->handle, "script_update_signal");
-               if (!item->update_signal) {
-                       goto errout;
-               }
-
-               item->update_drag = dlsym(item->handle, "script_update_drag");
-               if (!item->update_drag) {
-                       goto errout;
-               }
-
-               item->update_size = dlsym(item->handle, "script_update_size");
-               if (!item->update_size) {
-                       goto errout;
-               }
-
-               item->update_category = dlsym(item->handle, "script_update_category");
-               if (!item->update_category) {
-                       goto errout;
-               }
-
-               item->create = dlsym(item->handle, "script_create");
-               if (!item->create) {
-                       goto errout;
-               }
-
-               item->destroy = dlsym(item->handle, "script_destroy");
-               if (!item->destroy) {
-                       goto errout;
-               }
-
-               item->load = dlsym(item->handle, "script_load");
-               if (!item->load) {
-                       goto errout;
-               }
-
-               item->unload = dlsym(item->handle, "script_unload");
-               if (!item->unload) {
-                       goto errout;
-               }
-
-               item->init = dlsym(item->handle, "script_init");
-               if (!item->init) {
-                       goto errout;
-               }
-
-               item->fini = dlsym(item->handle, "script_fini");
-               if (!item->fini) {
-                       goto errout;
-               }
-
-               item->feed_event = dlsym(item->handle, "script_feed_event");
-               if (!item->feed_event) {
-                       goto errout;
-               }
-
-               if (item->init(WIDGET_CONF_SCALE_WIDTH_FACTOR, WIDGET_CONF_PREMULTIPLIED_COLOR) < 0) {
-                       ErrPrint("Failed to initialize script engine\n");
-                       goto errout;
-               }
-
-               s_info.script_port_list = eina_list_append(s_info.script_port_list, item);
-       }
-
-       if (closedir(dir) < 0) {
-               ErrPrint("closedir: %d\n", errno);
-       }
-
-       return WIDGET_ERROR_NONE;
-
-errout:
-       ErrPrint("Error: %s\n", dlerror());
-       if (dlclose(item->handle) != 0) {
-               ErrPrint("dlclose: %d\n", errno);
-       }
-       DbgFree(item);
-       if (closedir(dir) < 0) {
-               ErrPrint("closedir: %d\n", errno);
-       }
-       return WIDGET_ERROR_FAULT;
-}
-
-static inline struct script_port *find_port(const char *magic_id)
-{
-       Eina_List *l;
-       struct script_port *item;
-
-       if (!s_info.script_port_list) {
-               int ret;
-
-               ret = load_all_ports();
-               if (ret < 0) {
-                       ErrPrint("load_all_ports: %d\n", ret);
-               }
-       }
-
-       EINA_LIST_FOREACH(s_info.script_port_list, l, item) {
-               if (!strcmp(item->magic_id(), magic_id)) {
-                       return item;
-               }
-       }
-
-       return NULL;
-}
-
-static inline void delete_block(struct block *block)
-{
-       DbgFree(block->filebuf);
-       DbgFree(block);
-}
-
-static int render_post_cb(void *_buffer_handle, void *data)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct inst_info *inst;
-       struct buffer_info *buffer_handle = _buffer_handle;
-       struct script_info *info;
-
-       inst = buffer_handler_instance(buffer_handle);
-       if (!inst) {
-               goto out;
-       }
-
-       if (instance_state(inst) != INST_ACTIVATED) {
-               ErrPrint("Render post invoked but instance is not activated\n");
-               PERF_MARK(__func__);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = instance_widget_script(inst);
-       if (info && info == data) {
-               buffer_handler_flush(buffer_handle);
-               instance_widget_updated_by_instance(inst, NULL, info->x, info->y, info->w, info->h);
-               PERF_MARK("lb,update");
-               return WIDGET_ERROR_NONE;
-       }
-
-       info = instance_gbar_script(inst);
-       if (info && info == data) {
-               buffer_handler_flush(buffer_handle);
-               instance_gbar_updated_by_instance(inst, NULL, info->x, info->y, info->w, info->h);
-               PERF_MARK("pd,update");
-               return WIDGET_ERROR_NONE;
-       }
-
-out:
-       ErrPrint("Failed to sync\n");
-       PERF_MARK(__func__);
-       return WIDGET_ERROR_FAULT;
-}
-
-/*!
- * \NOTE
- * Exported API
- */
-EAPI int script_signal_emit(void *buffer_handle, const char *part, const char *signal, double sx, double sy, double ex, double ey)
-{
-       struct script_info *info;
-       struct inst_info *inst;
-       int w;
-       int h;
-       double fx;
-       double fy;
-
-       if (!buffer_handle) {
-               ErrPrint("Invalid handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = buffer_handler_data(buffer_handle);
-       if (!info) {
-               ErrPrint("Invalid handle\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       inst = buffer_handler_instance(buffer_handle);
-       if (!inst) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!signal || strlen(signal) == 0) {
-               signal = "";
-       }
-
-       if (!part || strlen(part) == 0) {
-               part = "";
-       }
-
-       buffer_handler_get_size(buffer_handle, &w, &h);
-
-       fx = (double)info->x / (double)w;
-       fy = (double)info->y / (double)h;
-
-       return instance_signal_emit(inst, signal, part, sx, sy, ex, ey, fx, fy, info->down);
-}
-
-static inline void flushing_cached_block(struct script_info *info)
-{
-       struct block *block;
-       struct inst_info *inst;
-       int is_pd;
-
-       inst = buffer_handler_instance(info->buffer_handle);
-       if (!inst) {
-               ErrPrint("Instance is not valid\n");
-               EINA_LIST_FREE(info->cached_blocks, block) {
-                       delete_block(block);
-               }
-               return;
-       }
-
-       is_pd = instance_gbar_script(inst) == info;
-
-       EINA_LIST_FREE(info->cached_blocks, block) {
-               consuming_parsed_block(inst, is_pd, block);
-       }
-}
-
-HAPI int script_handler_load(struct script_info *info, int is_pd)
-{
-       struct inst_info *inst;
-
-       if (!info || !info->port) {
-               ErrPrint("Script handler is not created\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (info->loaded > 0) {
-               info->loaded++;
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (info->port->load(info->port_data, NULL, render_post_cb, info) < 0) {
-               ErrPrint("Unable to load the script\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       info->loaded = 1;
-       flushing_cached_block(info);
-
-       inst = buffer_handler_instance(info->buffer_handle);
-       if (inst) {
-               script_signal_emit(info->buffer_handle, instance_id(inst),
-                               is_pd ? "gbar,show" : "widget,show", 0.0f, 0.0f, 0.0f, 0.0f);
-       }
-       buffer_handler_flush(info->buffer_handle);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int script_handler_unload(struct script_info *info, int is_pd)
-{
-       struct inst_info *inst;
-
-       if (!info || !info->port) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info->loaded--;
-       if (info->loaded > 0) {
-               return WIDGET_ERROR_RESOURCE_BUSY;
-       }
-
-       if (info->loaded < 0) {
-               info->loaded = 0;
-               return WIDGET_ERROR_ALREADY_EXIST;
-       }
-
-       inst = buffer_handler_instance(info->buffer_handle);
-       if (inst) {
-               script_signal_emit(info->buffer_handle, instance_id(inst),
-                               is_pd ? "gbar,hide" : "widget,hide", 0.0f, 0.0f, 0.0f, 0.0f);
-       }
-
-       if (info->port->unload(info->port_data) < 0) {
-               ErrPrint("Failed to unload script object. but go ahead\n");
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI struct script_info *script_handler_create(struct inst_info *inst, const char *file, const char *option, int w, int h)
-{
-       struct script_info *info;
-
-       DbgPrint("Create script: %s (%s) %dx%d\n", file, option, w, h);
-
-       if (!file) {
-               return NULL;
-       }
-
-       info = calloc(1, sizeof(*info));
-       if (!info) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       info->buffer_handle = buffer_handler_create(inst, s_info.env_buf_type, w, h, WIDGET_CONF_DEFAULT_PIXELS);
-       if (!info->buffer_handle) {
-               /* buffer_handler_create will prints some log */
-               DbgFree(info);
-               return NULL;
-       }
-
-       (void)buffer_handler_set_data(info->buffer_handle, info);
-
-       info->port = find_port(package_script(instance_package(inst)));
-       if (!info->port) {
-               ErrPrint("Failed to find a proper port for [%s]%s\n",
-                               instance_package(inst), package_script(instance_package(inst)));
-               buffer_handler_destroy(info->buffer_handle);
-               DbgFree(info);
-               return NULL;
-       }
-
-       info->port_data = info->port->create(info->buffer_handle, file, option);
-       if (!info->port_data) {
-               ErrPrint("Failed to create a port (%s - %s)\n", file, option);
-               buffer_handler_destroy(info->buffer_handle);
-               DbgFree(info);
-               return NULL;
-       }
-
-       return info;
-}
-
-HAPI int script_handler_destroy(struct script_info *info)
-{
-       struct block *block;
-       int ret;
-
-       if (!info || !info->port) {
-               ErrPrint("port is not valid\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (info->loaded != 0) {
-               ErrPrint("Script handler is not unloaded\n");
-               return WIDGET_ERROR_RESOURCE_BUSY;
-       }
-
-       ret = info->port->destroy(info->port_data);
-       if (ret < 0) {
-               ErrPrint("Failed to destroy port, but go ahead: %d\n", ret);
-       }
-
-       (void)buffer_handler_destroy(info->buffer_handle);
-
-       EINA_LIST_FREE(info->cached_blocks, block) {
-               delete_block(block);
-       }
-
-       DbgFree(info);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int script_handler_is_loaded(struct script_info *info)
-{
-       return info ? info->loaded > 0 : 0;
-}
-
-HAPI struct buffer_info *script_handler_buffer_info(struct script_info *info)
-{
-       if (!info) {
-               return NULL;
-       }
-
-       return info->buffer_handle;
-}
-
-static int update_script_color(struct inst_info *inst, struct block *block, int is_pd)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct script_info *info;
-       int ret;
-
-       if (!block || !block->part || !block->data) {
-               ErrPrint("Block or part or data is not valid\n");
-               PERF_MARK("color");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-       if (!info) {
-               ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               PERF_MARK("color");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!info->port) {
-               ErrPrint("info->port is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               PERF_MARK("color");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = info->port->update_color(info->port_data, block->id, block->part, block->data);
-       PERF_MARK("color");
-       return ret;
-}
-
-static int update_script_text(struct inst_info *inst, struct block *block, int is_pd)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct script_info *info;
-       int ret;
-
-       if (!block || !block->part || !block->data) {
-               ErrPrint("Block or part or data is not valid\n");
-               PERF_MARK("text");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-       if (!info) {
-               ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               PERF_MARK("text");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!info->port) {
-               ErrPrint("info->port is NIL\n");
-               PERF_MARK("text");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       DbgPrint("[%s] %s (%s)\n", block->id, block->part, block->data);
-       ret = info->port->update_text(info->port_data, block->id, block->part, block->data);
-
-       PERF_MARK("text");
-       return ret;
-}
-
-static int update_script_image(struct inst_info *inst, struct block *block, int is_pd)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct script_info *info;
-       int ret;
-
-       if (!block || !block->part) {
-               ErrPrint("Block or part is not valid\n");
-               PERF_MARK("image");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-       if (!info) {
-               ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               PERF_MARK("image");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!info->port) {
-               ErrPrint("info->port is NIL\n");
-               PERF_MARK("image");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       DbgPrint("[%s] %s (%s)\n", block->id, block->part, block->data);
-       ret = info->port->update_image(info->port_data, block->id, block->part, block->data, block->option);
-       PERF_MARK("image");
-       return ret;
-}
-
-static int update_access(struct inst_info *inst, struct block *block, int is_pd)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct script_info *info;
-       int ret;
-
-       if (!block || !block->part) {
-               ErrPrint("Block or block->part is NIL\n");
-               PERF_MARK("access");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-       if (!info) {
-               ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               PERF_MARK("access");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!info->port) {
-               ErrPrint("info->port is NIL\n");
-               PERF_MARK("access");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = info->port->update_access(info->port_data, block->id, block->part, block->data, block->option);
-       PERF_MARK("access");
-       return ret;
-}
-
-static int operate_access(struct inst_info *inst, struct block *block, int is_pd)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct script_info *info;
-       int ret;
-
-       if (!block || !block->part) {
-               ErrPrint("Block or block->part is NIL\n");
-               PERF_MARK("operate_access");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-       if (!info) {
-               ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               PERF_MARK("operate_access");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!info->port) {
-               ErrPrint("info->port is NIL\n");
-               PERF_MARK("operate_access");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = info->port->operate_access(info->port_data, block->id, block->part, block->data, block->option);
-       PERF_MARK("operate_access");
-       return ret;
-}
-
-static int update_script_script(struct inst_info *inst, struct block *block, int is_pd)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct script_info *info;
-       int ret;
-
-       if (!block || !block->part) {
-               ErrPrint("Block or part is NIL\n");
-               PERF_MARK("script");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-       if (!info) {
-               ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               PERF_MARK("script");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!info->port) {
-               ErrPrint("info->port is NIL\n");
-               PERF_MARK("script");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = info->port->update_script(info->port_data, block->id, block->target, block->part, block->data, block->option);
-       PERF_MARK("script");
-       return ret;
-}
-
-static int update_script_signal(struct inst_info *inst, struct block *block, int is_pd)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct script_info *info;
-       int ret;
-
-       if (!block) {
-               ErrPrint("block is NIL\n");
-               PERF_MARK("signal");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-       if (!info) {
-               ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               PERF_MARK("signal");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!info->port) {
-               ErrPrint("info->port is NIL\n");
-               PERF_MARK("signal");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = info->port->update_signal(info->port_data, block->id, block->part, block->data);
-       PERF_MARK("signal");
-       return ret;
-}
-
-static int update_script_drag(struct inst_info *inst, struct block *block, int is_pd)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct script_info *info;
-       double dx, dy;
-       int ret;
-
-       if (!block || !block->data || !block->part) {
-               ErrPrint("block or block->data or block->part is NIL\n");
-               PERF_MARK("drag");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-       if (!info) {
-               ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               PERF_MARK("drag");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (sscanf(block->data, "%lfx%lf", &dx, &dy) != 2) {
-               ErrPrint("Invalid format of data (DRAG data [%s])\n", block->data);
-               PERF_MARK("drag");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (!info->port) {
-               ErrPrint("info->port is NIL\n");
-               PERF_MARK("drag");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ret = info->port->update_drag(info->port_data, block->id, block->part, dx, dy);
-       PERF_MARK("drag");
-       return ret;
-}
-
-static void update_size_for_script(struct script_info *info, struct inst_info *inst, int w, int h)
-{
-       /*!
-        * \note
-        * After update the buffer size,
-        * If it required to be unload and load.
-        * New size of buffer will be allocated
-        */
-       buffer_handler_update_size(info->buffer_handle, w, h);
-
-       if (info->port->update_size) {
-               (void)info->port->update_size(info->port_data, NULL, w, h);
-       }
-
-       if (instance_widget_script(inst) == info) {
-               instance_set_widget_size(inst, w, h);
-       } else if (instance_gbar_script(inst) == info) {
-               instance_set_gbar_size(inst, w, h);
-       } else {
-               ErrPrint("Unknown script\n");
-       }
-}
-
-HAPI int script_handler_resize(struct script_info *info, int w, int h)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct inst_info *inst;
-
-       if (!info) {
-               ErrPrint("info[%p] resize is ignored\n", info);
-               PERF_MARK("resize");
-               return WIDGET_ERROR_NONE;
-       }
-
-       inst = buffer_handler_instance(info->buffer_handle);
-       if (!inst) {
-               ErrPrint("Instance is not valid\n");
-               PERF_MARK("resize");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       update_size_for_script(info, inst, w, h);
-
-       PERF_MARK("resize");
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI const char *script_handler_buffer_id(struct script_info *info)
-{
-       if (!info || !info->buffer_handle) {
-               ErrPrint("Invalid info\n");
-               return "";
-       }
-
-       return buffer_handler_id(info->buffer_handle);
-}
-
-static int update_info(struct inst_info *inst, struct block *block, int is_pd)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       struct script_info *info;
-
-       if (!block || !block->part || !block->data) {
-               ErrPrint("block or block->part or block->data is NIL\n");
-               PERF_MARK("info");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-       if (!info) {
-               ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               PERF_MARK("info");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!info->port) {
-               ErrPrint("info->port is NIL\n");
-               PERF_MARK("info");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (!strcasecmp(block->part, INFO_SIZE)) {
-               int w, h;
-
-               if (sscanf(block->data, "%dx%d", &w, &h) != 2) {
-                       ErrPrint("Invalid format for SIZE(%s)\n", block->data);
-                       PERF_MARK("info");
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-
-               if (!block->id) {
-                       update_size_for_script(info, inst, w, h);
-               } else {
-                       (void)info->port->update_size(info->port_data, block->id, w, h);
-               }
-       } else if (!strcasecmp(block->part, INFO_CATEGORY)) {
-               (void)info->port->update_category(info->port_data, block->id, block->data);
-       }
-       PERF_MARK("info");
-
-       return WIDGET_ERROR_NONE;
-}
-
-static inline void consuming_parsed_block(struct inst_info *inst, int is_pd, struct block *block)
-{
-       struct script_info *info;
-       typedef int (*update_function_t)(struct inst_info *inst, struct block *block, int is_pd);
-       update_function_t updators[] = {
-               update_access,
-               operate_access,
-               update_script_color,
-               update_script_drag,
-               update_script_image,
-               update_info,
-               update_script_script,
-               update_script_signal,
-               update_script_text,
-               NULL
-       };
-
-       info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-       if (!info) {
-               ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
-               goto free_out;
-       }
-
-       if (script_handler_is_loaded(info)) {
-               if (block->type >= 0 || block->type < TYPE_MAX) {
-                       (void)updators[block->type](inst, block, is_pd);
-               } else {
-                       ErrPrint("Block type[%d] is not valid\n", block->type);
-               }
-       } else {
-               info->cached_blocks = eina_list_append(info->cached_blocks, block);
-               DbgPrint("Block is cached (%p), %d, %s\n", block, eina_list_count(info->cached_blocks), instance_id(inst));
-               return;
-       }
-
-free_out:
-       delete_block(block);
-}
-
-HAPI int script_init(void)
-{
-       if (!strcasecmp(WIDGET_CONF_PROVIDER_METHOD, "shm")) {
-               s_info.env_buf_type = WIDGET_FB_TYPE_SHM;
-       } else if (!strcasecmp(WIDGET_CONF_PROVIDER_METHOD, "pixmap")) {
-               s_info.env_buf_type = WIDGET_FB_TYPE_PIXMAP;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int script_fini(void)
-{
-       struct script_port *item;
-       /*!
-        * \TODO: Release all handles
-        */
-       EINA_LIST_FREE(s_info.script_port_list, item) {
-               item->fini();
-               if (dlclose(item->handle) != 0) {
-                       ErrPrint("dlclose: %d\n", errno);
-               }
-               DbgFree(item);
-       }
-
-       return 0;
-}
-
-HAPI int script_handler_update_pointer(struct script_info *info, int device, int x, int y, int down)
-{
-       if (!info) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       info->x = x;
-       info->y = y;
-       info->device = device;
-
-       if (down == 0) {
-               info->down = 0;
-       } else if (down == 1) {
-               info->down = 1;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int script_handler_update_keycode(struct script_info *info, unsigned int keycode)
-{
-       if (!info) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       info->keycode = keycode;
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int script_handler_feed_event(struct script_info *info, int event, double timestamp)
-{
-       int ret;
-
-       if (!info->port) {
-               ErrPrint("info->port is NIL\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       /**
-        * @todo
-        * Feeds device info to the script loader.
-        */
-       ret = info->port->feed_event(info->port_data, event, info->x, info->y, info->down, info->keycode, timestamp);
-       return ret;
-}
-
-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: %d\n", errno);
-               return NULL;
-       }
-
-       filesize = lseek(fd, 0L, SEEK_END);
-       if (filesize == (off_t)-1) {
-               ErrPrint("lseek: %d\n", errno);
-               goto errout;
-       }
-
-       if (lseek(fd, 0L, SEEK_SET) < 0) {
-               ErrPrint("lseek: %d\n", errno);
-               goto errout;
-       }
-
-       filebuf = malloc(filesize + 1);
-       if (!filebuf) {
-               ErrPrint("malloc: %d\n", 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: %d\n", 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: %d\n", errno);
-       }
-
-       return filebuf;
-}
-
-#if defined(_APPLY_SCRIPT_ASYNC_UPDATE)
-struct apply_data {
-       struct inst_info *inst;
-       Eina_List *block_list;
-       int is_pd;
-};
-
-static Eina_Bool apply_changes_cb(void *_data)
-{
-       struct apply_data *data = _data;
-       struct block *block;
-
-       block = eina_list_nth(data->block_list, 0);
-       data->block_list = eina_list_remove(data->block_list, block);
-       consuming_parsed_block(data->inst, data->is_pd, block);
-
-       if (!data->block_list) {
-               free(data);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       return ECORE_CALLBACK_RENEW;
-}
-#endif
-
-HAPI int script_handler_parse_desc(struct inst_info *inst, const char *filename, int is_pd)
-{
-       PERF_INIT();
-       PERF_BEGIN();
-       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;
-       Eina_List *block_list = NULL;
-       enum state {
-               BEGIN,
-               FIELD,
-               DATA,
-               END,
-               DONE,
-               ERROR,
-       } state;
-
-       filebuf = load_file(filename);
-       if (!filebuf) {
-               return WIDGET_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: %d\n", 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 = eina_list_append(block_list, block);
-                               block = NULL;
-                       } else {
-                               state = FIELD;
-                               continue;
-                       }
-                       break;
-               case END:
-               default:
-                       break;
-               }
-
-               fileptr++;
-       }
-
-       if (state != BEGIN) {
-               ErrPrint("State %d\n", state);
-
-               free(filebuf);
-               free(block);
-
-               EINA_LIST_FREE(block_list, block) {
-                       free(block);
-               }
-
-               PERF_MARK("parser");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       block = eina_list_data_get(eina_list_last(block_list));
-       if (block) {
-               block->filebuf = filebuf;
-       } else {
-               ErrPrint("Last block is not exists (There is no parsed block)\n");
-               free(filebuf);
-       }
-
-       PERF_MARK("parser");
-
-#if defined(_APPLY_SCRIPT_ASYNC_UPDATE)
-       struct apply_data *data;
-
-       data = malloc(sizeof(*data));
-       if (data) {
-               data->inst = inst;
-               data->is_pd = is_pd;
-               data->block_list = block_list;
-               if (!ecore_timer_add(0.001f, apply_changes_cb, data)) {
-                       ErrPrint("Failed to add timer\n");
-                       free(data);
-                       EINA_LIST_FREE(block_list, block) {
-                               consuming_parsed_block(inst, is_pd, block);
-                       }
-               }
-       } else {
-               ErrPrint("malloc: %d\n", errno);
-               EINA_LIST_FREE(block_list, block) {
-                       consuming_parsed_block(inst, is_pd, block);
-               }
-       }
-#else
-       ErrPrint("Begin: Set content for EDJE object\n");
-       EINA_LIST_FREE(block_list, block) {
-               consuming_parsed_block(inst, is_pd, block);
-       }
-       ErrPrint("End: Set content for EDJE object\n");
-
-       /*!
-        * Doesn't need to force to render the contents.
-        struct script_info *info;
-        info = is_pd ? instance_gbar_script(inst) : instance_widget_script(inst);
-        if (info && info->ee) {
-        ecore_evas_manual_render(info->ee);
-        }
-        */
-#endif
-
-       return WIDGET_ERROR_NONE;
-}
-
-/* End of a file */
diff --git a/src/server.c b/src/server.c
deleted file mode 100644 (file)
index c50702e..0000000
+++ /dev/null
@@ -1,10006 +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 <unistd.h>
-#include <errno.h>
-
-#include <sys/smack.h>
-
-#include <dlog.h>
-#include <aul.h>
-#include <Ecore.h>
-
-#include <packet.h>
-#include <com-core_packet.h>
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_cmd_list.h>
-#include <widget_conf.h>
-#include <widget_abi.h>
-#include <widget_script.h>
-#include <widget_util.h>
-
-#include "critical_log.h"
-#include "conf.h"
-#include "debug.h"
-#include "server.h"
-#include "slave_life.h"
-#include "slave_rpc.h"
-#include "client_life.h"
-#include "instance.h"
-#include "client_rpc.h"
-#include "package.h"
-#include "script_handler.h"
-#include "buffer_handler.h"
-#include "util.h"
-#include "fault_manager.h"
-#include "group.h"
-#include "xmonitor.h"
-#include "widget-mgr.h"
-#include "io.h"
-#include "event.h"
-#include "dead_monitor.h"
-#include "monitor.h"
-
-#define GBAR_OPEN_MONITOR_TAG "gbar,open,monitor"
-#define GBAR_RESIZE_MONITOR_TAG "gbar,resize,monitor"
-#define GBAR_CLOSE_MONITOR_TAG "gbar,close,monitor"
-
-#define LAZY_GBAR_OPEN_TAG "lazy,gbar,open"
-#define LAZY_GBAR_CLOSE_TAG "lazy,gbar,close"
-
-#define ACCESS_TYPE_DOWN 0
-#define ACCESS_TYPE_MOVE 1
-#define ACCESS_TYPE_UP 2
-#define ACCESS_TYPE_CUR 0
-#define ACCESS_TYPE_NEXT 1
-#define ACCESS_TYPE_PREV 2
-#define ACCESS_TYPE_OFF 3
-
-#define PAGE_SIZE 4096
-
-#define aul_terminate_pid_async(a) aul_terminate_pid(a)
-
-struct sync_ctx_item {
-       int pid;
-       int handle;
-       char *pkgname;
-       double timestamp;
-       Ecore_Timer *prepare_sync_wait_timer;
-};
-
-static struct info {
-       int info_fd;
-       int client_fd;
-       int service_fd;
-       int slave_fd;
-
-       Eina_List *hello_sync_ctx_list;
-} s_info = {
-       .info_fd = -1,
-       .client_fd = -1,
-       .service_fd = -1,
-       .slave_fd = -1,
-       .hello_sync_ctx_list = NULL,
-};
-
-struct access_info {
-       int x;
-       int y;
-       int type;
-};
-
-/* Share this with provider */
-enum target_type {
-       TYPE_WIDGET,
-       TYPE_GBAR,
-       TYPE_ERROR
-};
-
-struct event_cbdata {
-       int status;
-       struct inst_info *inst;
-};
-
-struct deleted_item {
-       struct client_node *client;
-       struct inst_info *inst;
-};
-
-static int is_valid_service_requestor(pid_t pid, const char *pkgname)
-{
-       char pid_pkgname[pathconf("/", _PC_PATH_MAX)];
-       char *caller_pkgname;
-       char *widget_pkgname;
-       int ret;
-
-       if (aul_app_get_pkgname_bypid(pid, pid_pkgname, sizeof(pid_pkgname)) != AUL_R_OK) {
-               ret = widget_mgr_is_valid_requestor(pid);
-               if (ret == 0) {
-                       ErrPrint("pid[%d] is not authroized package\n", pid);
-               }
-               return ret;
-       }
-
-       caller_pkgname = package_get_pkgid(pid_pkgname);
-       if (!caller_pkgname) {
-               ErrPrint("Caller pkgname is not valid (%s, %s)\n", pid_pkgname, pkgname);
-               return 0;
-       }
-
-       widget_pkgname = widget_service_get_package_id(pkgname);
-       if (!widget_pkgname) {
-               DbgFree(caller_pkgname);
-               ErrPrint("Widget pkgname is not valid (%s, %s)\n", pid_pkgname, pkgname);
-               return 0;
-       }
-
-       ret = strcmp(caller_pkgname, widget_pkgname);
-       DbgFree(caller_pkgname);
-       DbgFree(widget_pkgname);
-
-       return ret == 0;
-}
-
-/**
- * Returns widget Id from provider Id
- */
-static char *is_valid_slave(pid_t pid, const char *abi, const char *provider_pkgname)
-{
-       char pid_pkgname[pathconf("/", _PC_PATH_MAX)];
-       const char *abi_pkgname;
-       widget_list_h list_handle;
-       char *pkgid;
-       char *widget_id;
-       char *converted_provider_pkgname = NULL;
-       int verified;
-
-       if (aul_app_get_pkgname_bypid(pid, pid_pkgname, sizeof(pid_pkgname)) != AUL_R_OK) {
-               if (WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode) {
-                       DbgPrint("Debug mode is enabled: [%s] [%s]\n", abi, provider_pkgname);
-                       if (provider_pkgname) {
-                               strncpy(pid_pkgname, provider_pkgname, sizeof(pid_pkgname));
-                               DbgPrint("[%d]_pkgname is updated to [%s]\n", pid, pid_pkgname);
-                       } else {
-                               DbgPrint("There is no way to get the pkgname of %d even though we are in the debug mode\n", pid);
-                               return NULL;
-                       }
-               } else {
-                       ErrPrint("pid[%d] is not authroized provider package\n", pid);
-                       return NULL;
-               }
-       }
-
-       abi_pkgname = widget_abi_get_pkgname_by_abi(abi);
-       if (!abi_pkgname) {
-               ErrPrint("ABI has no valid entry[%s]\n", abi);
-               return NULL;
-       }
-
-       if (!strcmp(abi, "meta")) {
-               converted_provider_pkgname = package_meta_tag(provider_pkgname, abi_pkgname);
-               if (!converted_provider_pkgname || strcmp(converted_provider_pkgname, pid_pkgname)) {
-                       DbgPrint("Meta tag is not matched: %s <> %s (%s)\n", converted_provider_pkgname, pid_pkgname, abi_pkgname);
-                       DbgFree(converted_provider_pkgname);
-                       return NULL;
-               }
-
-               DbgPrint("Meta package detected: %s\n", converted_provider_pkgname);
-               return converted_provider_pkgname;
-       }
-
-       if (!provider_pkgname) {
-               DbgPrint("provider_pkgname is NULL (%s)\n", pid_pkgname);
-               return NULL;
-       }
-
-       if (!strcmp(abi_pkgname, pid_pkgname)) {
-               /*!
-                * This request is comes from predefined service provider.
-                * In this case, we should believe its request.
-                */
-               DbgPrint("Provider pkgname[%s]\n", provider_pkgname);
-               return strdup(provider_pkgname);
-       } else if (WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode) {
-               DbgPrint("Debug mode is enabled, use the %s as a widget_id\n", provider_pkgname);
-               return strdup(provider_pkgname);
-       }
-
-       /*!
-        * This request is comes from standalone widget provider (not the predefined service provider)
-        */
-       pkgid = package_get_pkgid(provider_pkgname);
-       list_handle = widget_service_create_widget_list(pkgid, NULL);
-       DbgFree(pkgid);
-
-       verified = 0;
-       widget_id = NULL;
-       while (widget_service_get_item_from_widget_list(list_handle, NULL, &widget_id, NULL) == WIDGET_ERROR_NONE) {
-               if (!widget_id) {
-                       ErrPrint("Invalid widget_id\n");
-                       continue;
-               }
-
-               // tmp == /APPID/.provider <<- PROVIDER UI-APP
-               // widget_id == org.tizen.watch-hello <<-- WIDGET ID
-               // provider_pkgname == org.tizen.watch-hello.provider
-               converted_provider_pkgname = widget_util_replace_string(abi_pkgname, WIDGET_CONF_REPLACE_TAG_APPID, widget_id);
-               if (!converted_provider_pkgname) {
-                       DbgFree(widget_id);
-                       widget_id = NULL;
-                       continue;
-               }
-
-               /* Verify the Package Name */
-               verified = !strcmp(converted_provider_pkgname, provider_pkgname);
-               DbgFree(converted_provider_pkgname);
-
-               if (verified) {
-                       break;
-               }
-
-               DbgFree(widget_id);
-               widget_id = NULL;
-       }
-
-       widget_service_destroy_widget_list(list_handle);
-       return widget_id;
-}
-
-static Eina_Bool lazy_key_status_cb(void *data)
-{
-       struct event_cbdata *cbdata = data;
-
-       if (instance_unref(cbdata->inst)) {
-               instance_send_key_status(cbdata->inst, cbdata->status);
-       } else {
-               DbgPrint("Skip sending key status (%d)\n", cbdata->status);
-       }
-       /*!
-        * If instance_unref returns NULL,
-        * The instance is destroyed. it means, we don't need to send event to the viewer
-        */
-       DbgFree(cbdata);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool lazy_access_status_cb(void *data)
-{
-       struct event_cbdata *cbdata = data;
-
-       if (instance_unref(cbdata->inst)) {
-               instance_send_access_status(cbdata->inst, cbdata->status);
-       } else {
-               DbgPrint("Skip sending access status (%d)\n", cbdata->status);
-       }
-       /*!
-        * If instance_unref returns NULL,
-        * The instance is destroyed. it means, we don't need to send event to the viewer
-        */
-       DbgFree(cbdata);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-int send_delayed_key_status(struct inst_info *inst, int ret)
-{
-       struct event_cbdata *cbdata;
-
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               ret = WIDGET_ERROR_OUT_OF_MEMORY;
-       } else {
-               cbdata->inst = instance_ref(inst);
-               cbdata->status = ret;
-
-               if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
-                       (void)instance_unref(cbdata->inst);
-                       DbgFree(cbdata);
-                       ret = WIDGET_ERROR_FAULT;
-               } else {
-                       ret = WIDGET_ERROR_NONE;
-               }
-       }
-
-       return ret;
-}
-
-int send_delayed_access_status(struct inst_info *inst, int ret)
-{
-       struct event_cbdata *cbdata;
-
-       cbdata = malloc(sizeof(*cbdata));
-       if (!cbdata) {
-               ret = WIDGET_ERROR_OUT_OF_MEMORY;
-       } else {
-               cbdata->inst = instance_ref(inst);
-               cbdata->status = ret;
-
-               if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
-                       (void)instance_unref(cbdata->inst);
-                       DbgFree(cbdata);
-                       ret = WIDGET_ERROR_FAULT;
-               } else {
-                       ret = WIDGET_ERROR_NONE;
-               }
-       }
-
-       return ret;
-}
-
-static int forward_widget_event_packet(const struct pkg_info *pkg, struct inst_info *inst, const struct packet *packet)
-{
-       struct buffer_info *buffer;
-       struct slave_node *slave;
-       int ret;
-
-       buffer = instance_widget_buffer(inst);
-       if (!buffer) {
-               ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               ErrPrint("Package[%s] has no slave\n", package_name(pkg));
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       packet_ref((struct packet *)packet);
-       ret = slave_rpc_request_only(slave, package_name(pkg), (struct packet *)packet, 0);
-
-out:
-       return ret;
-}
-
-static int forward_gbar_event_packet(const struct pkg_info *pkg, struct inst_info *inst, const struct packet *packet)
-{
-       struct buffer_info *buffer;
-       struct slave_node *slave;
-       int ret;
-
-       buffer = instance_gbar_buffer(inst);
-       if (!buffer) {
-               ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               ErrPrint("Package[%s] has no slave\n", package_name(pkg));
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       packet_ref((struct packet *)packet);
-       ret = slave_rpc_request_only(slave, package_name(pkg), (struct packet *)packet, 0);
-
-out:
-       return ret;
-}
-
-static int forward_gbar_access_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, struct access_info *event)
-{
-       int ret;
-       struct buffer_info *buffer;
-       struct slave_node *slave;
-       struct packet *p;
-
-       buffer = instance_gbar_buffer(inst);
-       if (!buffer) {
-               ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               ErrPrint("Package[%s] has no slave\n", package_name(pkg));
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       p = packet_create_noack(command, "ssdiii", package_name(pkg), instance_id(inst), timestamp, event->x, event->y, event->type);
-       ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
-
-out:
-       return ret;
-}
-
-static int forward_widget_access_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, struct access_info *event)
-{
-       int ret;
-       struct buffer_info *buffer;
-       struct slave_node *slave;
-       struct packet *p;
-
-       buffer = instance_widget_buffer(inst);
-       if (!buffer) {
-               ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               ErrPrint("Package[%s] has no slave\n", package_name(pkg));
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       p = packet_create_noack(command, "ssdiii", package_name(pkg), instance_id(inst), timestamp, event->x, event->y, event->type);
-       ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
-
-out:
-       return ret;
-}
-
-static int forward_gbar_key_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, unsigned int keycode)
-{
-       int ret;
-       struct buffer_info *buffer;
-       struct slave_node *slave;
-       struct packet *p;
-
-       buffer = instance_widget_buffer(inst);
-       if (!buffer) {
-               ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               ErrPrint("Package[%s] has no slave\n", package_name(pkg));
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       p = packet_create_noack(command, "ssdi", package_name(pkg), instance_id(inst), timestamp, keycode);
-       ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
-
-out:
-       return ret;
-}
-
-static int forward_widget_key_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, unsigned int keycode)
-{
-       int ret;
-       struct buffer_info *buffer;
-       struct slave_node *slave;
-       struct packet *p;
-
-       buffer = instance_widget_buffer(inst);
-       if (!buffer) {
-               ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               ErrPrint("Package[%s] has no slave\n", package_name(pkg));
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       p = packet_create_noack(command, "ssdi", package_name(pkg), instance_id(inst), timestamp, keycode);
-       ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
-
-out:
-       return ret;
-}
-
-static int slave_fault_open_script_cb(struct slave_node *slave, void *data)
-{
-       Ecore_Timer *timer;
-
-       (void)script_handler_unload(instance_gbar_script(data), 1);
-       (void)instance_slave_close_gbar(data, instance_gbar_owner(data), WIDGET_CLOSE_GBAR_FAULT);
-       (void)instance_client_gbar_created(data, WIDGET_ERROR_FAULT);
-
-       timer = instance_del_data(data, LAZY_GBAR_OPEN_TAG);
-       if (timer) {
-               ecore_timer_del(timer);
-       }
-
-       (void)instance_unref(data);
-
-       return -1; /* remove this handler */
-}
-
-static int slave_fault_open_buffer_cb(struct slave_node *slave, void *data)
-{
-       Ecore_Timer *timer;
-
-       (void)instance_slave_close_gbar(data, instance_gbar_owner(data), WIDGET_CLOSE_GBAR_FAULT);
-       (void)instance_client_gbar_created(data, WIDGET_ERROR_FAULT);
-
-       timer = instance_del_data(data, GBAR_OPEN_MONITOR_TAG);
-       if (timer) {
-               ecore_timer_del(timer);
-       }
-
-       (void)instance_unref(data);
-
-       return -1; /* remove this handler */
-}
-
-static int slave_fault_close_script_cb(struct slave_node *slave, void *data)
-{
-       Ecore_Timer *timer;
-
-       (void)instance_client_gbar_destroyed(data, WIDGET_ERROR_FAULT);
-
-       timer = instance_del_data(data, LAZY_GBAR_CLOSE_TAG);
-       if (timer) {
-               ecore_timer_del(timer);
-       }
-
-       (void)instance_unref(data);
-
-       return -1; /* remove this handler */
-}
-
-static int slave_fault_close_buffer_cb(struct slave_node *slave, void *data)
-{
-       Ecore_Timer *timer;
-
-       (void)instance_client_gbar_destroyed(data, WIDGET_ERROR_FAULT);
-
-       timer = instance_del_data(data, LAZY_GBAR_CLOSE_TAG);
-       if (!timer) {
-               timer = instance_del_data(data, GBAR_CLOSE_MONITOR_TAG);
-       }
-
-       if (timer) {
-               ecore_timer_del(timer);
-       }
-
-       (void)instance_unref(data);
-
-       return -1; /* remove this handler */
-}
-
-static int slave_fault_resize_buffer_cb(struct slave_node *slave, void *data)
-{
-       Ecore_Timer *timer;
-
-       (void)instance_slave_close_gbar(data, instance_gbar_owner(data), WIDGET_CLOSE_GBAR_FAULT);
-       (void)instance_client_gbar_destroyed(data, WIDGET_ERROR_FAULT);
-
-       timer = instance_del_data(data, GBAR_RESIZE_MONITOR_TAG);
-       if (timer) {
-               ecore_timer_del(timer);
-       }
-
-       (void)instance_unref(data);
-
-       return -1; /* remove this handler */
-}
-
-static int key_event_widget_route_cb(enum event_state state, struct event_data *event_info, void *data)
-{
-       struct inst_info *inst = data;
-       const struct pkg_info *pkg;
-       struct slave_node *slave;
-       struct packet *packet;
-       unsigned int cmd;
-
-       if (!inst) {
-               DbgPrint("Instance is deleted.\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       pkg = instance_package(inst);
-       if (!pkg) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (state) {
-       case EVENT_STATE_ACTIVATE:
-               cmd = CMD_WIDGET_KEY_DOWN;
-               break;
-       case EVENT_STATE_ACTIVATED:
-               cmd = CMD_WIDGET_KEY_DOWN;
-               break;
-       case EVENT_STATE_DEACTIVATE:
-               cmd = CMD_WIDGET_KEY_UP;
-               break;
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssdii", package_name(pkg), instance_id(inst), event_info->tv, event_info->keycode, event_info->slot);
-       if (!packet) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
-}
-
-static int mouse_event_widget_route_cb(enum event_state state, struct event_data *event_info, void *data)
-{
-       struct inst_info *inst = data;
-       const struct pkg_info *pkg;
-       struct slave_node *slave;
-       struct packet *packet;
-       unsigned int cmd;
-
-       if (!inst) {
-               DbgPrint("Instance is deleted.\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       pkg = instance_package(inst);
-       if (!pkg) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (state) {
-       case EVENT_STATE_ACTIVATE:
-               cmd = CMD_WIDGET_MOUSE_DOWN;
-               break;
-       case EVENT_STATE_ACTIVATED:
-               cmd = CMD_WIDGET_MOUSE_MOVE;
-               break;
-       case EVENT_STATE_DEACTIVATE:
-               cmd = CMD_WIDGET_MOUSE_UP;
-               break;
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssdiiiddi", package_name(pkg), instance_id(inst), event_info->tv, event_info->x, event_info->y, (int)event_info->source, event_info->ratio_w, event_info->ratio_h, event_info->slot);
-       if (!packet) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
-}
-
-static int key_event_widget_consume_cb(enum event_state state, struct event_data *event_info, void *data)
-{
-       struct script_info *script;
-       struct inst_info *inst = data;
-       const struct pkg_info *pkg;
-       double timestamp;
-
-       pkg = instance_package(inst);
-       if (!pkg) {
-               return 0;
-       }
-
-       script = instance_widget_script(inst);
-       if (!script) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       timestamp = event_info->tv;
-
-       switch (state) {
-       case EVENT_STATE_ACTIVATE:
-               script_handler_update_keycode(script, event_info->keycode);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_KEY_DOWN, timestamp);
-               break;
-       case EVENT_STATE_ACTIVATED:
-               script_handler_update_keycode(script, event_info->keycode);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_KEY_DOWN, timestamp);
-               break;
-       case EVENT_STATE_DEACTIVATE:
-               script_handler_update_keycode(script, event_info->keycode);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_UP, timestamp);
-               break;
-       default:
-               ErrPrint("Unknown event\n");
-               break;
-       }
-
-       return 0;
-}
-
-static int mouse_event_widget_consume_cb(enum event_state state, struct event_data *event_info, void *data)
-{
-       struct script_info *script;
-       struct inst_info *inst = data;
-       const struct pkg_info *pkg;
-       double timestamp;
-
-       pkg = instance_package(inst);
-       if (!pkg) {
-               return 0;
-       }
-
-       script = instance_widget_script(inst);
-       if (!script) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       timestamp = event_info->tv;
-
-       /**
-        * @TODO
-        * Determines what will do for event coordinate.
-        * Whether it should be rotated or not.
-        */
-       switch (state) {
-       case EVENT_STATE_ACTIVATE:
-               script_handler_update_pointer(script, event_info->slot, event_info->x * event_info->ratio_w, event_info->y * event_info->ratio_h, 1);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_DOWN, timestamp);
-               break;
-       case EVENT_STATE_ACTIVATED:
-               script_handler_update_pointer(script, event_info->slot, event_info->x * event_info->ratio_w, event_info->y * event_info->ratio_h, -1);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_MOVE, timestamp);
-               break;
-       case EVENT_STATE_DEACTIVATE:
-               script_handler_update_pointer(script, event_info->slot, event_info->x * event_info->ratio_w, event_info->y * event_info->ratio_h, 0);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_UP, timestamp);
-               break;
-       default:
-               break;
-       }
-
-       return 0;
-}
-
-static int key_event_gbar_route_cb(enum event_state state, struct event_data *event_info, void *data)
-{
-       struct inst_info *inst = data;
-       const struct pkg_info *pkg;
-       struct slave_node *slave;
-       struct packet *packet;
-       unsigned int cmd;
-
-       if (!inst) {
-               DbgPrint("Instance is deleted.\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       pkg = instance_package(inst);
-       if (!pkg) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (state) {
-       case EVENT_STATE_ACTIVATE:
-               cmd = CMD_GBAR_KEY_DOWN;
-               break;
-       case EVENT_STATE_ACTIVATED:
-               cmd = CMD_GBAR_KEY_DOWN;
-               break;
-       case EVENT_STATE_DEACTIVATE:
-               cmd = CMD_GBAR_KEY_UP;
-               break;
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssdi", package_name(pkg), instance_id(inst), event_info->tv, event_info->keycode);
-       if (!packet) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
-}
-
-static int mouse_event_gbar_route_cb(enum event_state state, struct event_data *event_info, void *data)
-{
-       struct inst_info *inst = data;
-       const struct pkg_info *pkg;
-       struct slave_node *slave;
-       struct packet *packet;
-       unsigned int cmd;
-
-       if (!inst) {
-               DbgPrint("Instance is deleted.\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       pkg = instance_package(inst);
-       if (!pkg) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (state) {
-       case EVENT_STATE_ACTIVATE:
-               cmd = CMD_GBAR_MOUSE_DOWN;
-               break;
-       case EVENT_STATE_ACTIVATED:
-               cmd = CMD_GBAR_MOUSE_MOVE;
-               break;
-       case EVENT_STATE_DEACTIVATE:
-               cmd = CMD_GBAR_MOUSE_UP;
-               break;
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "ssdiiiddi", package_name(pkg), instance_id(inst), event_info->tv, event_info->x, event_info->y, (int)event_info->source, event_info->ratio_w, event_info->ratio_h, event_info->slot);
-       if (!packet) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
-}
-
-static int key_event_gbar_consume_cb(enum event_state state, struct event_data *event_info, void *data)
-{
-       struct script_info *script;
-       struct inst_info *inst = data;
-       const struct pkg_info *pkg;
-       double timestamp;
-
-       pkg = instance_package(inst);
-       if (!pkg) {
-               return 0;
-       }
-
-       script = instance_gbar_script(inst);
-       if (!script) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       timestamp = event_info->tv;
-
-       switch (state) {
-       case EVENT_STATE_ACTIVATE:
-               script_handler_update_keycode(script, event_info->keycode);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_KEY_DOWN, timestamp);
-               break;
-       case EVENT_STATE_ACTIVATED:
-               script_handler_update_keycode(script, event_info->keycode);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_KEY_DOWN, timestamp);
-               break;
-       case EVENT_STATE_DEACTIVATE:
-               script_handler_update_keycode(script, event_info->keycode);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_KEY_UP, timestamp);
-               break;
-       default:
-               ErrPrint("Unknown event\n");
-               break;
-       }
-
-       return 0;
-}
-
-static int mouse_event_gbar_consume_cb(enum event_state state, struct event_data *event_info, void *data)
-{
-       struct script_info *script;
-       struct inst_info *inst = data;
-       const struct pkg_info *pkg;
-       double timestamp;
-
-       pkg = instance_package(inst);
-       if (!pkg) {
-               return 0;
-       }
-
-       script = instance_gbar_script(inst);
-       if (!script) {
-               return WIDGET_ERROR_FAULT;
-       }
-
-       timestamp = event_info->tv;
-
-       /**
-        * @TODO
-        * Determines what will do for event coordinate.
-        * Whether it should be rotated or not.
-        */
-
-       switch (state) {
-       case EVENT_STATE_ACTIVATE:
-               script_handler_update_pointer(script, event_info->slot, event_info->x * event_info->ratio_w, event_info->y * event_info->ratio_h, 1);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_DOWN, timestamp);
-               break;
-       case EVENT_STATE_ACTIVATED:
-               script_handler_update_pointer(script, event_info->slot, event_info->x * event_info->ratio_w, event_info->y * event_info->ratio_h, -1);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_MOVE, timestamp);
-               break;
-       case EVENT_STATE_DEACTIVATE:
-               script_handler_update_pointer(script, event_info->slot, event_info->x * event_info->ratio_w, event_info->y * event_info->ratio_h, 0);
-               (void)script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_UP, timestamp);
-               break;
-       default:
-               break;
-       }
-       return 0;
-}
-
-static struct packet *client_acquire(pid_t pid, int handle, const struct packet *packet) /*!< timestamp, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *direct_addr;
-       double timestamp;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (client) {
-               ErrPrint("Client is already exists %d\n", pid);
-               ret = WIDGET_ERROR_ALREADY_EXIST;
-               goto out;
-       }
-
-       if (packet_get(packet, "ds", &timestamp, &direct_addr) != 2) {
-               ErrPrint("Invalid arguemnt\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = 0;
-       /*!
-        * \note
-        * client_create will invoke the client created callback
-        */
-       client = client_create(pid, handle, direct_addr);
-       if (!client) {
-               ErrPrint("Failed to create a new client for %d\n", pid);
-               ret = WIDGET_ERROR_FAULT;
-       }
-
-out:
-       result = packet_create_reply(packet, "ii", ret, WIDGET_CONF_EXTRA_BUFFER_COUNT);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *cilent_release(pid_t pid, int handle, const struct packet *packet) /*!< pid, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       client_destroy(client);
-       ret = 0;
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static int validate_request(pid_t pid, struct slave_node *slave, const char *pkgname, const char *id, struct inst_info **out_inst, const struct pkg_info **out_pkg)
-{
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-
-       if (slave) {
-               if (slave_valid(slave)) {
-                       inst = package_find_instance_by_id(pkgname, id);
-               } else {
-                       ErrPrint("slave is not valid (%s)\n", id);
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-       } else {
-               inst = package_find_instance_by_id(pkgname, id);
-       }
-
-       if (!inst) {
-               ErrPrint("Instance is not exists (%s)\n", id);
-               return WIDGET_ERROR_NOT_EXIST;
-       }
-
-       pkg = instance_package(inst);
-       if (!pkg) {
-               ErrPrint("System error - instance has no package?\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (package_is_fault(pkg)) {
-               ErrPrint("Faulted package: %s\n", package_name(pkg));
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (out_inst) {
-               *out_inst = inst;
-       }
-
-       if (out_pkg) {
-               *out_pkg = pkg;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-/*!< pid, pkgname, filename, event, timestamp, x, y, ret */
-static struct packet *client_clicked(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       const char *event;
-       double timestamp;
-       double x;
-       double y;
-       int ret;
-       struct inst_info *inst;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "sssddd", &pkgname, &id, &event, &timestamp, &x, &y);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       /*!
-        * \NOTE:
-        * Trust the package name which are sent by the client.
-        * The package has to be a widget package name.
-        */
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               (void)instance_clicked(inst, event, timestamp, x, y);
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_update_mode(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       int active_update;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       struct inst_info *inst;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &active_update);
-       if (ret != 3) {
-               ErrPrint("Invalid argument\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               /*!
-                * \note
-                * Send change update mode request to a slave
-                */
-               ret = instance_set_update_mode(inst, active_update);
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-/* pid, pkgname, filename, signal_name, source, s, sy, ex, ey, ret */
-static struct packet *client_text_signal(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       const char *signal_name;
-       const char *source;
-       double sx;
-       double sy;
-       double ex;
-       double ey;
-       struct inst_info *inst = NULL;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssssdddd", &pkgname, &id, &signal_name, &source, &sx, &sy, &ex, &ey);
-       if (ret != 8) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       /*!
-        * \NOTE:
-        * Trust the package name which are sent by the client.
-        * The package has to be a widget package name.
-        */
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               ret = instance_text_signal_emit(inst, signal_name, source, sx, sy, ex, ey);
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static Eina_Bool lazy_delete_cb(void *data)
-{
-       struct deleted_item *item = data;
-
-       DbgPrint("Lazy delete callback called\n");
-       /*!
-        * Before invoke this callback, the instance is able to already remove this client
-        * So check it again
-        */
-       if (instance_has_client(item->inst, item->client)) {
-               (void)instance_unicast_deleted_event(item->inst, item->client, WIDGET_ERROR_NONE);
-               (void)instance_del_client(item->inst, item->client);
-       }
-
-       (void)client_unref(item->client);
-       (void)instance_unref(item->inst);
-       DbgFree(item);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static struct packet *client_delete(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int ret;
-       int type;
-       double timestamp;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssid", &pkgname, &id, &type, &timestamp);
-       if (ret != 4) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-       /*!
-        * \note
-        * Below two types must has to be sync'd with widget-viewer
-        *
-        * WIDGET_DELETE_PERMANENTLY = 0x01,
-        * WIDGET_DELETE_TEMPORARY = 0x02,
-        *
-        */
-
-       /*!
-        * \NOTE:
-        * Trust the package name which are sent by the client.
-        * The package has to be a widget package name.
-        */
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               DbgPrint("Failed to find by id(%s), try to find it using timestamp(%lf)\n", id, timestamp);
-               inst = package_find_instance_by_timestamp(pkgname, timestamp);
-               if (!inst) {
-                       goto out;
-               }
-
-               pkg = instance_package(inst);
-               if (!pkg) {
-                       ErrPrint("Package info is not valid: %s\n", id);
-                       goto out;
-               }
-       }
-
-       if (package_is_fault(pkg)) {
-               DbgPrint("Faulted package. will be deleted soon: %s\n", id);
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       if (instance_client(inst) != client) {
-               if (instance_has_client(inst, client)) {
-                       struct deleted_item *item;
-
-                       item = malloc(sizeof(*item));
-                       if (!item) {
-                               ErrPrint("malloc: %d\n", errno);
-                               ret = WIDGET_ERROR_OUT_OF_MEMORY;
-                       } else {
-                               /*!
-                                * \NOTE:
-                                * Send DELETED EVENT to the client.
-                                * after return from this function.
-                                *
-                                * Client will prepare the deleted event after get this function's return value.
-                                * So We have to make a delay to send a deleted event.
-                                */
-
-                               item->client = client_ref(client);
-                               item->inst = instance_ref(inst);
-
-                               if (!ecore_timer_add(DELAY_TIME, lazy_delete_cb, item)) {
-                                       ErrPrint("Failed to add a delayzed delete callback\n");
-                                       (void)client_unref(client);
-                                       (void)instance_unref(inst);
-                                       DbgFree(item);
-                                       ret = WIDGET_ERROR_FAULT;
-                               } else {
-                                       ret = WIDGET_ERROR_NONE;
-                               }
-                       }
-               } else {
-                       ErrPrint("Client has no permission\n");
-                       ret = WIDGET_ERROR_PERMISSION_DENIED;
-               }
-       } else {
-               switch (type) {
-               case WIDGET_DELETE_PERMANENTLY:
-                       ret = instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-                       break;
-               case WIDGET_DELETE_TEMPORARY:
-                       ret = instance_destroy(inst, WIDGET_DESTROY_TYPE_TEMPORARY);
-                       break;
-               default:
-                       break;
-               }
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_resize(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, w, h, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       int w;
-       int h;
-       struct inst_info *inst = NULL;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssii", &pkgname, &id, &w, &h);
-       if (ret != 4) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       DbgPrint("RESIZE: Client request resize to %dx%d (pid: %d, pkgname: %s)\n", w, h, pid, pkgname);
-
-       /*!
-        * \NOTE:
-        * Trust the package name which are sent by the client.
-        * The package has to be a widget package name.
-        */
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_client(inst) != client) {
-               ret = WIDGET_ERROR_PERMISSION_DENIED;
-       } else {
-               ret = instance_resize(inst, w, h);
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_new(pid_t pid, int handle, const struct packet *packet) /* pid, timestamp, pkgname, content, cluster, category, period, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *pkgname;
-       const char *content;
-       const char *cluster;
-       const char *category;
-       double period;
-       double timestamp;
-       int ret;
-       struct pkg_info *info;
-       int width;
-       int height;
-       char *widget_id;
-       char *mainappid;
-       int max_count;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "dssssdii", &timestamp, &pkgname, &content, &cluster, &category, &period, &width, &height);
-       if (ret != 8) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
-                       pid, timestamp, pkgname, content, cluster, category, period);
-
-       widget_id = package_widget_pkgname(pkgname);
-       if (!widget_id) {
-               ErrPrint("This %s has no widget package\n", pkgname);
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       /**
-        * @TODO
-        * Should be replaced with package manager API to decide whether it is enabled or not.
-        */
-       mainappid = widget_service_get_main_app_id(widget_id);
-       if (!package_is_enabled(mainappid)) {
-               ErrPrint("%s is disabled\n", mainappid);
-               DbgFree(mainappid);
-               DbgFree(widget_id);
-               ret = WIDGET_ERROR_DISABLED;
-               goto out;
-       }
-       DbgFree(mainappid);
-       mainappid = NULL;
-
-       info = package_find(widget_id);
-       if (!info) {
-               char *pkgid;
-               pkgid = widget_service_get_package_id(widget_id);
-               if (!pkgid) {
-                       DbgFree(mainappid);
-                       DbgFree(widget_id);
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               info = package_create(pkgid, widget_id);
-               DbgFree(pkgid);
-       }
-
-       max_count = widget_service_get_widget_max_count(widget_id);
-       if (max_count < 0) {
-               ErrPrint("Failed to get max_count[%s] = %d\n", widget_id, max_count);
-               max_count = 0;
-       }
-
-       if (!info) {
-               ret = WIDGET_ERROR_FAULT;
-       } else if (package_is_fault(info)) {
-               ret = WIDGET_ERROR_FAULT;
-       } else if (util_free_space(WIDGET_CONF_IMAGE_PATH) <= WIDGET_CONF_MINIMUM_SPACE) {
-               ErrPrint("Not enough space\n");
-               ret = WIDGET_ERROR_FILE_NO_SPACE_ON_DEVICE;
-       } else if (max_count && max_count <= package_instance_count(info, 1)) {
-               ErrPrint("Reached to the max count of widgets %d, %d\n", max_count, package_instance_count(info, 1));
-               ret = WIDGET_ERROR_CANCELED;
-       } else {
-               struct inst_info *inst;
-
-               if (period > 0.0f && period < WIDGET_CONF_MINIMUM_PERIOD) {
-                       period = WIDGET_CONF_MINIMUM_PERIOD;
-               }
-
-               inst = instance_create(client, timestamp, widget_id, content, cluster, category, period, width, height);
-               /*!
-                * \note
-                * Using the "inst" without validate its value is at my disposal. ;)
-                */
-               ret = inst ? 0 : WIDGET_ERROR_FAULT;
-       }
-
-       DbgFree(widget_id);
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_change_visibility(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       enum widget_visible_state state;
-       int ret;
-       struct inst_info *inst;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, (int *)&state);
-       if (ret != 3) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       /*!
-        * \NOTE:
-        * Trust the package name which are sent by the client.
-        * The package has to be a widget package name.
-        */
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_client(inst) != client) {
-               ret = WIDGET_ERROR_PERMISSION_DENIED;
-       } else {
-               ret = instance_set_visible_state(inst, state);
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_set_period(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, period, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       double period;
-       int ret;
-       struct inst_info *inst = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssd", &pkgname, &id, &period);
-       if (ret != 3) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       DbgPrint("pid[%d] pkgname[%s] period[%lf]\n", pid, pkgname, period);
-
-       /*!
-        * \NOTE:
-        * Trust the package name which are sent by the client.
-        * The package has to be a widget package name.
-        */
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_client(inst) != client) {
-               ret = WIDGET_ERROR_PERMISSION_DENIED;
-       } else {
-               ret = instance_set_period(inst, period);
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_change_group(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, cluster, category, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       const char *cluster;
-       const char *category;
-       struct inst_info *inst = NULL;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
-       if (ret != 4) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       DbgPrint("pid[%d] pkgname[%s] cluster[%s] category[%s]\n", pid, pkgname, cluster, category);
-
-       /*!
-        * \NOTE:
-        * Trust the package name which are sent by the client.
-        * The package has to be a widget package name.
-        */
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_client(inst) != client) {
-               ret = WIDGET_ERROR_PERMISSION_DENIED;
-       } else {
-               ret = instance_change_group(inst, cluster, category);
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_mouse_enter(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_event_packet(pkg, inst, packet);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_IN, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_gbar_mouse_leave(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_event_packet(pkg, inst, packet);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_OUT, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_gbar_mouse_down(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, id, width, height, timestamp, x, y, ret */
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_event_packet(pkg, inst, packet);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, 1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_DOWN, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_gbar_mouse_up(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_event_packet(pkg, inst, packet);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, 0);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_UP, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_gbar_mouse_move(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_event_packet(pkg, inst, packet);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_MOVE, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_widget_mouse_move(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_event_packet(pkg, inst, packet);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_MOVE, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static int inst_del_cb(struct inst_info *inst, void *data)
-{
-       int ret;
-
-       /*
-        * If you deactivate the event thread,
-        * It will calls event callbacks.
-        * And the event callbacks will try to access the "inst"
-        */
-       (void)event_deactivate(-1, data, inst);
-
-       /* Reset callback data to prevent accessing inst from event callback */
-       ret = event_reset_cbdata(data, inst, NULL);
-       DbgPrint("Instance delete callback called: %s (%d)\n", instance_id(inst), ret);
-
-       if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-               (void)slave_set_priority(package_slave(instance_package(inst)), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
-       }
-
-       return -1; /* Delete this callback */
-}
-
-static struct packet *client_gbar_key_set(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &keycode, &device);
-       if (ret != 5) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = event_activate(device, 0, 0, 1.0f, 1.0f, key_event_gbar_route_cb, inst);
-               if (ret == WIDGET_ERROR_NONE) {
-                       if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                               (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_ON);
-                       }
-                       if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_route_cb) <= 0) {
-                               instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_route_cb);
-                       }
-               }
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               ret = event_activate(device, 0, 0, 1.0f, 1.0f, key_event_gbar_consume_cb, inst);
-               if (ret == WIDGET_ERROR_NONE) {
-                       if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                               (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_ON);
-                       }
-                       if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_consume_cb) <= 0) {
-                               instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_consume_cb);
-                       }
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_key_unset(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &keycode, &device);
-       if (ret != 5) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = event_deactivate(device, key_event_gbar_route_cb, inst);
-               if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                       (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
-               }
-               /*
-                * This delete callback will be removed when the instance will be destroyed.
-                if (ret == 0) {
-                instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_route_cb);
-                }
-                */
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               ret = event_deactivate(device, key_event_gbar_consume_cb, inst);
-               if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                       (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
-               }
-               /*
-                * This delete callback will be removed when the instance will be destroyed.
-                if (ret == 0) {
-                instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_consume_cb);
-                }
-                */
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_key_set(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &keycode, &device);
-       if (ret != 5) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = event_activate(device, 0, 0, 1.0f, 1.0f, key_event_widget_route_cb, inst);
-               if (ret == WIDGET_ERROR_NONE) {
-                       if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                               (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_ON);
-                       }
-                       if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_widget_route_cb) <= 0) {
-                               instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_widget_route_cb);
-                       }
-               }
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               ret = event_activate(device, 0, 0, 1.0f, 1.0f, key_event_widget_consume_cb, inst);
-               if (ret == WIDGET_ERROR_NONE) {
-                       if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                               (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_ON);
-                       }
-                       if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_widget_consume_cb) <= 0) {
-                               instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_widget_consume_cb);
-                       }
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_key_unset(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdii", &pkgname, &id, &timestamp, &keycode, &device);
-       if (ret != 5) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = event_deactivate(device, key_event_widget_route_cb, inst);
-               if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                       (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
-               }
-               /*
-                * This delete callback will be removed when the instance will be destroyed.
-                if (ret == 0) {
-                instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_widget_route_cb);
-                }
-                */
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               ret = event_deactivate(device, key_event_widget_consume_cb, inst);
-               if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                       (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
-               }
-               /*
-                * This delete callback will be removed when the instance will be destroyed.
-                if (ret == 0) {
-                instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_widget_consume_cb);
-                }
-                */
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_mouse_set(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               if (package_direct_input(pkg) == 0 || packet_set_fd((struct packet *)packet, event_input_fd()) < 0) {
-                       ret = event_activate(device, x, y, ratio_w, ratio_h, mouse_event_widget_route_cb, inst);
-                       if (ret == WIDGET_ERROR_NONE) {
-                               if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                                       (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_ON);
-                               }
-                               if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_widget_route_cb) <= 0) {
-                                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_widget_route_cb);
-                               }
-                       }
-               } else {
-                       struct slave_node *slave;
-
-                       DbgPrint("Direct input is enabled(set for %s:%d)\n", id, packet_fd(packet));
-                       slave = package_slave(pkg);
-                       if (slave) {
-                               packet_ref((struct packet *)packet);
-                               ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
-                       } else {
-                               ErrPrint("Unable to find a slave for %s\n", pkgname);
-                               ret = WIDGET_ERROR_FAULT;
-                       }
-               }
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               ret = event_activate(device, x, y, ratio_w, ratio_h, mouse_event_widget_consume_cb, inst);
-               if (ret == WIDGET_ERROR_NONE) {
-                       if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                               (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_ON);
-                       }
-                       if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_widget_consume_cb) <= 0) {
-                               instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_widget_consume_cb);
-                       }
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-out:
-       return NULL;
-}
-
-static struct packet *client_widget_mouse_unset(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               if (package_direct_input(pkg) == 0) {
-                       /* Forcely update the X,Y position using viewer's */
-                       event_set_mouse_xy(device, x, y, ratio_w, ratio_h, timestamp);
-
-                       ret = event_deactivate(device, mouse_event_widget_route_cb, inst);
-                       if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                               (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
-                       }
-                       /*
-                        * This delete callback will be removed when the instance will be destroyed.
-                        if (ret == 0) {
-                                instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_widget_route_cb);
-                        }
-                        */
-               } else {
-                       struct slave_node *slave;
-
-                       DbgPrint("Direct input is enabled(unset) for %s\n", id);
-                       slave = package_slave(pkg);
-                       if (slave) {
-                               packet_ref((struct packet *)packet);
-                               ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
-                       } else {
-                               ErrPrint("Unable to find a slave for %s\n", pkgname);
-                               ret = WIDGET_ERROR_FAULT;
-                       }
-               }
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               /* Forcely update the X,Y position using viewer's */
-               event_set_mouse_xy(device, x, y, ratio_w, ratio_h, timestamp);
-
-               ret = event_deactivate(device, mouse_event_widget_consume_cb, inst);
-               if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                       (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
-               }
-               /*
-                * This delete callback will be removed when the instance will be destroyed.
-                if (ret == 0) {
-                        instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_widget_consume_cb);
-                }
-                */
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-out:
-       return NULL;
-}
-
-static struct packet *client_gbar_mouse_set(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiidd", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               if (package_direct_input(pkg) == 0 || packet_set_fd((struct packet *)packet, event_input_fd()) < 0) {
-                       ret = event_activate(device, x, y, ratio_w, ratio_h, mouse_event_gbar_route_cb, inst);
-                       if (ret == WIDGET_ERROR_NONE) {
-                               if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                                       (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_ON);
-                               }
-                               if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_route_cb) <= 0) {
-                                       instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_route_cb);
-                               }
-                       }
-               } else {
-                       struct slave_node *slave;
-
-                       DbgPrint("Direct input is enabled(set for %s:%d)\n", id, packet_fd(packet));
-                       slave = package_slave(pkg);
-                       if (slave) {
-                               packet_ref((struct packet *)packet);
-                               ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
-                       } else {
-                               ErrPrint("Unable to find a slave for %s\n", pkgname);
-                               ret = WIDGET_ERROR_FAULT;
-                       }
-               }
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               ret = event_activate(device, x, y, ratio_w, ratio_h, mouse_event_gbar_consume_cb, inst);
-               if (ret == WIDGET_ERROR_NONE) {
-                       if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                               (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_ON);
-                       }
-                       if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_consume_cb) <= 0) {
-                               instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_consume_cb);
-                       }
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *client_widget_mouse_on_scroll(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_event_packet(pkg, inst, packet);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_ON_SCROLL, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_widget_mouse_off_scroll(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_event_packet(pkg, inst, packet);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_OFF_SCROLL, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_widget_mouse_on_hold(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_event_packet(pkg, inst, packet);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_ON_HOLD, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_widget_mouse_off_hold(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_event_packet(pkg, inst, packet);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_OFF_HOLD, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_gbar_mouse_on_scroll(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_event_packet(pkg, inst, packet);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_ON_SCROLL, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_gbar_mouse_off_scroll(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_event_packet(pkg, inst, packet);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_OFF_SCROLL, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_gbar_mouse_on_hold(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_event_packet(pkg, inst, packet);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_ON_HOLD, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_gbar_mouse_off_hold(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_event_packet(pkg, inst, packet);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_OFF_HOLD, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_gbar_mouse_unset(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               if (package_direct_input(pkg) == 0) {
-                       /* Forcely update the X,Y position using viewer's */
-                       event_set_mouse_xy(device, x, y, ratio_w, ratio_h, timestamp);
-
-                       ret = event_deactivate(device, mouse_event_gbar_route_cb, inst);
-                       if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                               (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
-                       }
-                       /*
-                        * This delete callback will be removed when the instance will be destroyed.
-                        if (ret == 0) {
-                                instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_route_cb);
-                        }
-                        */
-               } else {
-                       struct slave_node *slave;
-
-                       DbgPrint("Direct input is enabled(unset) for %s\n", id);
-                       slave = package_slave(pkg);
-                       if (slave) {
-                               packet_ref((struct packet *)packet);
-                               ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
-                       } else {
-                               ErrPrint("Unable to find a slave for %s\n", pkgname);
-                               ret = WIDGET_ERROR_FAULT;
-                       }
-               }
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               /* Forcely update the X,Y position using viewer's */
-               event_set_mouse_xy(device, x, y, ratio_w, ratio_h, timestamp);
-
-               ret = event_deactivate(device, mouse_event_gbar_consume_cb, inst);
-               if (WIDGET_CONF_SLAVE_EVENT_BOOST_OFF != WIDGET_CONF_SLAVE_EVENT_BOOST_ON) {
-                       (void)slave_set_priority(package_slave(pkg), WIDGET_CONF_SLAVE_EVENT_BOOST_OFF);
-               }
-               /*
-                * This delete callback will be removed when the instance will be destroyed.
-                if (ret == 0) {
-                       instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_consume_cb);
-                }
-                */
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-out:
-       return NULL;
-}
-
-static struct packet *client_widget_mouse_enter(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_event_packet(pkg, inst, packet);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_IN, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_widget_mouse_leave(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_event_packet(pkg, inst, packet);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, -1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_OUT, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_widget_mouse_down(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_event_packet(pkg, inst, packet);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, 1);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_DOWN, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_widget_mouse_up(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       int x;
-       int y;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int source;
-       double ratio_w;
-       double ratio_h;
-       int device;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiiiddi", &pkgname, &id, &timestamp, &x, &y, &source, &ratio_w, &ratio_h, &device);
-       if (ret != 9) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_event_packet(pkg, inst, packet);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, device, x * ratio_w, y * ratio_h, 0);
-               script_handler_feed_event(script, WIDGET_SCRIPT_MOUSE_UP, timestamp);
-               ret = 0;
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_gbar_access_action(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_ACTION, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_access_scroll(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_SCROLL, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_access_value_change(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_VALUE_CHANGE, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_access_mouse(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_MOUSE, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_access_back(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_BACK, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_access_over(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_OVER, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_access_read(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_READ, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_access_enable(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-               int type;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               type = (event.type == 0) ? WIDGET_SCRIPT_ACCESS_DISABLE : WIDGET_SCRIPT_ACCESS_ENABLE;
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, type, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_access_hl(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-               int type;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               switch (event.type) {
-               case ACCESS_TYPE_CUR:
-                       type = WIDGET_SCRIPT_ACCESS_HIGHLIGHT;
-                       break;
-               case ACCESS_TYPE_NEXT:
-                       type = WIDGET_SCRIPT_ACCESS_HIGHLIGHT_NEXT;
-                       break;
-               case ACCESS_TYPE_PREV:
-                       type = WIDGET_SCRIPT_ACCESS_HIGHLIGHT_PREV;
-                       break;
-               case ACCESS_TYPE_OFF:
-                       type = WIDGET_SCRIPT_ACCESS_UNHIGHLIGHT;
-                       break;
-               default:
-                       ret = WIDGET_ERROR_INVALID_PARAMETER;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, type, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_access_activate(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_ACTIVATE, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_key_focus_in(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
-       if (ret != 4) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_keycode(script, keycode);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_KEY_FOCUS_IN, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_key_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_key_focus_out(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
-       if (ret != 4) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_keycode(script, keycode);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_KEY_FOCUS_OUT, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_key_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_key_down(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
-       if (ret != 4) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_keycode(script, keycode);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_KEY_DOWN, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_key_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_pause_request(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       double timestamp;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is paused - manually reported\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "d", &timestamp);
-       if (ret != 1) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (WIDGET_CONF_USE_XMONITOR) {
-               DbgPrint("XMONITOR enabled. ignore client paused request\n");
-       } else {
-               xmonitor_pause(client);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *client_resume_request(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       double timestamp;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "d", &timestamp);
-       if (ret != 1) {
-               ErrPrint("Invalid parameter\n");
-               goto out;
-       }
-
-       if (WIDGET_CONF_USE_XMONITOR) {
-               DbgPrint("XMONITOR enabled. ignore client resumed request\n");
-       } else {
-               xmonitor_resume(client);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *client_change_orientation(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       double timestamp;
-       int degree;
-       int ret;
-       struct pkg_info *pkg;
-       Eina_List *pkg_list;
-       Eina_List *l;
-       Eina_List *inst_list;
-       Eina_List *inst_l;
-       struct inst_info *inst;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "di", &timestamp, &degree);
-       if (ret != 2) {
-               ErrPrint("Invalid parameter\n");
-               goto out;
-       }
-
-       ret = 0;
-
-       client_set_orientation(client, degree);
-
-       pkg_list = (Eina_List *)package_list();
-
-       EINA_LIST_FOREACH(pkg_list, l, pkg) {
-               inst_list = package_instance_list(pkg);
-               EINA_LIST_FOREACH(inst_list, inst_l, inst) {
-                       if (instance_client(inst) == client || instance_has_client(inst, client)) {
-                               instance_set_orientation(inst, degree);
-                               ret++;
-                       }
-               }
-       }
-       DbgPrint("%d instances are affected (orientation: %d)\n", ret, degree);
-out:
-       return NULL;
-}
-
-static struct packet *client_gbar_key_up(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
-       if (ret != 4) {
-               ErrPrint("Invalid parameter\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               ret = forward_gbar_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_gbar_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_keycode(script, keycode);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_KEY_UP, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_key_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_access_hl(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-               int type;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               switch (event.type) {
-               case ACCESS_TYPE_CUR:
-                       type = WIDGET_SCRIPT_ACCESS_HIGHLIGHT;
-                       break;
-               case ACCESS_TYPE_NEXT:
-                       type = WIDGET_SCRIPT_ACCESS_HIGHLIGHT_NEXT;
-                       break;
-               case ACCESS_TYPE_PREV:
-                       type = WIDGET_SCRIPT_ACCESS_HIGHLIGHT_PREV;
-                       break;
-               case ACCESS_TYPE_OFF:
-                       type = WIDGET_SCRIPT_ACCESS_UNHIGHLIGHT;
-                       break;
-               default:
-                       ret = WIDGET_ERROR_INVALID_PARAMETER;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, type, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_access_action(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       struct access_info event;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-               /*!
-                * Enen if it fails to send packet,
-                * The packet will be unref'd
-                * So we don't need to check the ret value.
-                */
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ErrPrint("Instance has no script\n");
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_ACTION, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_access_scroll(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       struct access_info event;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-               /*!
-                * Enen if it fails to send packet,
-                * The packet will be unref'd
-                * So we don't need to check the ret value.
-                */
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ErrPrint("Instance has no script\n");
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_SCROLL, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_access_value_change(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       struct access_info event;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-               /*!
-                * Enen if it fails to send packet,
-                * The packet will be unref'd
-                * So we don't need to check the ret value.
-                */
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ErrPrint("Instance has no script\n");
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_VALUE_CHANGE, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_access_mouse(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       struct access_info event;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-               /*!
-                * Enen if it fails to send packet,
-                * The packet will be unref'd
-                * So we don't need to check the ret value.
-                */
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ErrPrint("Instance has no script\n");
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_MOUSE, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_access_back(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       struct access_info event;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-               /*!
-                * Enen if it fails to send packet,
-                * The packet will be unref'd
-                * So we don't need to check the ret value.
-                */
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ErrPrint("Instance has no script\n");
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_BACK, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_access_over(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       struct access_info event;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-               /*!
-                * Enen if it fails to send packet,
-                * The packet will be unref'd
-                * So we don't need to check the ret value.
-                */
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ErrPrint("Instance has no script\n");
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_OVER, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_access_read(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       struct access_info event;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-               /*!
-                * Enen if it fails to send packet,
-                * The packet will be unref'd
-                * So we don't need to check the ret value.
-                */
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ErrPrint("Instance has no script\n");
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_READ, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_access_enable(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       struct access_info event;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exist\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-               /*!
-                * Enen if it fails to send packet,
-                * The packet will be unref'd
-                * So we don't need to check the ret value.
-                */
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-               int type;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ErrPrint("Instance has no script\n");
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               type = (event.type == 0) ? WIDGET_SCRIPT_ACCESS_DISABLE : WIDGET_SCRIPT_ACCESS_ENABLE;
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, type, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_access_activate(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       struct access_info event;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdiii", &pkgname, &id, &timestamp, &event.x, &event.y, &event.type);
-       if (ret != 6) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ErrPrint("Instance has no script\n");
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_pointer(script, 0, event.x, event.y, event.type);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_ACCESS_ACTIVATE, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_access_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_key_down(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
-       if (ret != 4) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_keycode(script, keycode);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_KEY_DOWN, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_key_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_key_focus_in(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
-       if (ret != 4) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_keycode(script, keycode);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_KEY_FOCUS_IN, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_key_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_key_focus_out(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
-       if (ret != 4) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_keycode(script, keycode);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_KEY_FOCUS_OUT, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_key_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_key_up(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       double timestamp;
-       unsigned int keycode;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       struct packet *result;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdi", &pkgname, &id, &timestamp, &keycode);
-       if (ret != 4) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = forward_widget_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
-       } else if (package_widget_type(pkg) == WIDGET_TYPE_SCRIPT) {
-               struct script_info *script;
-
-               script = instance_widget_script(inst);
-               if (!script) {
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               script_handler_update_keycode(script, keycode);
-               ret = script_handler_feed_event(script, WIDGET_SCRIPT_KEY_UP, timestamp);
-               if (ret >= 0) {
-                       ret = send_delayed_key_status(inst, ret);
-               }
-       } else {
-               ErrPrint("Unsupported package\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static int release_pixmap_cb(struct client_node *client, void *canvas)
-{
-       DbgPrint("Forcely unref the \"buffer\"\n");
-       buffer_handler_pixmap_unref(canvas);
-       return -1; /* Delete this callback */
-}
-
-static struct packet *client_widget_acquire_xpixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       struct client_node *client;
-       struct inst_info *inst;
-       int ret;
-       int pixmap = 0;
-       void *buf_ptr;
-       struct buffer_info *buffer;
-       int idx;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &idx);
-       if (ret != 3) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (idx >= WIDGET_CONF_EXTRA_BUFFER_COUNT || idx < 0) {
-               DbgPrint("Index is not valid: %d\n", idx);
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       buffer = instance_widget_extra_buffer(inst, idx);
-       if (!buffer) {
-               ErrPrint("Extra buffer for %d is not available\n", idx);
-               goto out;
-       }
-
-       buf_ptr = buffer_handler_pixmap_ref(buffer);
-       if (!buf_ptr) {
-               ErrPrint("Failed to ref pixmap\n");
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
-       if (ret < 0) {
-               ErrPrint("Failed to add a new client deactivate callback\n");
-               buffer_handler_pixmap_unref(buf_ptr);
-       } else {
-               pixmap = buffer_handler_pixmap(buffer);
-               ret = WIDGET_ERROR_NONE;
-       }
-
-out:
-       result = packet_create_reply(packet, "ii", pixmap, ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       struct client_node *client;
-       struct inst_info *inst;
-       int ret;
-       int pixmap = 0;
-       void *buf_ptr;
-       struct buffer_info *buffer;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ss", &pkgname, &id);
-       if (ret != 2) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       buffer = instance_widget_buffer(inst);
-       if (!buffer) {
-               struct script_info *script_info;
-
-               script_info = instance_widget_script(inst);
-               if (!script_info) {
-                       ErrPrint("Unable to get WIDGET buffer: %s\n", id);
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               buffer = script_handler_buffer_info(script_info);
-               if (!buffer) {
-                       ErrPrint("Unable to get buffer_info: %s\n", id);
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-       }
-
-       buf_ptr = buffer_handler_pixmap_ref(buffer);
-       if (!buf_ptr) {
-               ErrPrint("Failed to ref pixmap\n");
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
-       if (ret < 0) {
-               ErrPrint("Failed to add a new client deactivate callback\n");
-               buffer_handler_pixmap_unref(buf_ptr);
-       } else {
-               pixmap = buffer_handler_pixmap(buffer);
-               ret = WIDGET_ERROR_NONE;
-       }
-
-out:
-       result = packet_create_reply(packet, "ii", pixmap, ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_widget_release_pixmap(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *pkgname;
-       const char *id;
-       struct client_node *client;
-       int pixmap;
-       void *buf_ptr;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
-       if (ret != 3) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, NULL, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               DbgPrint("It seems that the instance is already deleted: %s\n", id);
-       }
-
-       buf_ptr = buffer_handler_pixmap_find(pixmap);
-       if (!buf_ptr) {
-               ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
-               goto out;
-       }
-
-       if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0) {
-               buffer_handler_pixmap_unref(buf_ptr);
-       }
-
-out:
-       /**
-        * @note No reply packet
-        */
-       return NULL;
-}
-
-static struct packet *client_gbar_acquire_xpixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       struct client_node *client;
-       struct inst_info *inst;
-       int ret;
-       int pixmap = 0;
-       void *buf_ptr;
-       struct buffer_info *buffer;
-       int idx;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               ErrPrint("Client %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &idx);
-       if (ret != 3) {
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       if (idx >= WIDGET_CONF_EXTRA_BUFFER_COUNT || idx < 0) {
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       buffer = instance_gbar_extra_buffer(inst, idx);
-       if (!buffer) {
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       buf_ptr = buffer_handler_pixmap_ref(buffer);
-       if (!buf_ptr) {
-               ErrPrint("Failed to ref pixmap\n");
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
-       if (ret < 0) {
-               ErrPrint("Failed to add a new client deactivate callback\n");
-               buffer_handler_pixmap_unref(buf_ptr);
-       } else {
-               pixmap = buffer_handler_pixmap(buffer);
-               ret = WIDGET_ERROR_NONE;
-       }
-
-out:
-       result = packet_create_reply(packet, "ii", pixmap, ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-{
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       struct client_node *client;
-       struct inst_info *inst;
-       int ret;
-       int pixmap = 0;
-       void *buf_ptr;
-       struct buffer_info *buffer;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               ErrPrint("Client %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ss", &pkgname, &id);
-       if (ret != 2) {
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_get_data(inst, GBAR_RESIZE_MONITOR_TAG)) {
-               ret = WIDGET_ERROR_RESOURCE_BUSY;
-               goto out;
-       }
-
-       buffer = instance_gbar_buffer(inst);
-       if (!buffer) {
-               struct script_info *script_info;
-
-               script_info = instance_gbar_script(inst);
-               if (!script_info) {
-                       ErrPrint("Unable to get WIDGET buffer: %s\n", id);
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               buffer = script_handler_buffer_info(script_info);
-               if (!buffer) {
-                       ErrPrint("Unable to get buffer_info: %s\n", id);
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-       }
-
-       buf_ptr = buffer_handler_pixmap_ref(buffer);
-       if (!buf_ptr) {
-               ErrPrint("Failed to ref pixmap\n");
-               ret = WIDGET_ERROR_FAULT;
-               goto out;
-       }
-
-       ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
-       if (ret < 0) {
-               ErrPrint("Failed to add a new client deactivate callback\n");
-               buffer_handler_pixmap_unref(buf_ptr);
-       } else {
-               pixmap = buffer_handler_pixmap(buffer);
-               ret = WIDGET_ERROR_NONE;
-       }
-
-out:
-       result = packet_create_reply(packet, "ii", pixmap, ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_gbar_release_pixmap(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *pkgname;
-       const char *id;
-       struct client_node *client;
-       int pixmap;
-       void *buf_ptr;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &pixmap);
-       if (ret != 3) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, NULL, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               DbgPrint("It seems that the instance is already deleted: %s\n", id);
-       }
-
-       buf_ptr = buffer_handler_pixmap_find(pixmap);
-       if (!buf_ptr) {
-               ErrPrint("Failed to find a buf_ptr of 0x%X\n", pixmap);
-               goto out;
-       }
-
-       if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr) == 0) {
-               buffer_handler_pixmap_unref(buf_ptr);
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_pinup_changed(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, pinup, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       int pinup;
-       int ret;
-       struct inst_info *inst;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               pinup = 0;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &pinup);
-       if (ret != 3) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               pinup = 0;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               ret = instance_set_pinup(inst, pinup);
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static Eina_Bool lazy_gbar_created_cb(void *inst)
-{
-       struct pkg_info *pkg;
-
-       if (!instance_del_data(inst, LAZY_GBAR_OPEN_TAG)) {
-               ErrPrint("lazy,pd,open is already deleted.\n");
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       pkg = instance_package(inst);
-       if (pkg) {
-               struct slave_node *slave;
-
-               slave = package_slave(pkg);
-               if (slave) {
-                       slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_script_cb, inst);
-               }
-       }
-
-       /*!
-        * After unref instance first,
-        * if the instance is not destroyed, try to notify the created GBAR event to the client.
-        */
-       if (instance_unref(inst)) {
-               int ret;
-               ret = instance_client_gbar_created(inst, WIDGET_ERROR_NONE);
-               if (ret < 0) {
-                       DbgPrint("Send GBAR Create event (%d) to client\n", ret);
-               }
-       }
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool lazy_gbar_destroyed_cb(void *inst)
-{
-       struct pkg_info *pkg;
-       struct slave_node *slave;
-
-       if (!instance_del_data(inst, LAZY_GBAR_CLOSE_TAG)) {
-               ErrPrint("lazy,pd,close is already deleted.\n");
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       pkg = instance_package(inst);
-       if (pkg) {
-               slave = package_slave(pkg);
-               if (slave) {
-                       if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-                               DbgPrint("Delete script type close callback\n");
-                               (void)slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_script_cb, inst);
-                       } else if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-                               DbgPrint("Delete buffer type close callback\n");
-                               (void)slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst);
-                       }
-               }
-       }
-
-       if (instance_unref(inst)) {
-               int ret;
-
-               /*!
-                * If the instance is not deleted, we should send pd-destroy event from here.
-                */
-               ret = instance_client_gbar_destroyed(inst, WIDGET_ERROR_NONE);
-               if (ret < 0) {
-                       ErrPrint("Failed sending GBAR Destroy event (%d)\n", ret);
-               }
-       }
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static struct packet *client_gbar_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
-{
-       struct client_node *client;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       const char *pkgname;
-       const char *id;
-       double x = 0.0f;
-       double y = 0.0f;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
-       if (ret != 4) {
-               ErrPrint("Parameter is not correct\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               instance_slave_set_gbar_pos(inst, x, y);
-               ret = instance_signal_emit(inst, "pd,move", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               int ix;
-               int iy;
-
-               instance_slave_set_gbar_pos(inst, x, y);
-               ix = x * instance_gbar_width(inst);
-               iy = y * instance_gbar_height(inst);
-               script_handler_update_pointer(instance_gbar_script(inst), 0, ix, iy, 0);
-               ret = instance_signal_emit(inst, "pd,move", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
-       } else {
-               ErrPrint("Invalid GBAR type\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-out:
-       DbgPrint("Update GBAR position: %d\n", ret);
-       return NULL;
-}
-
-static Eina_Bool gbar_open_monitor_cb(void *inst)
-{
-       struct pkg_info *pkg;
-
-       pkg = instance_package(inst);
-       if (pkg) {
-               struct slave_node *slave;
-
-               slave = package_slave(pkg);
-               if (slave) {
-                       slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst);
-               }
-       }
-
-       (void)instance_slave_close_gbar(inst, instance_gbar_owner(inst), WIDGET_CLOSE_GBAR_TIMEOUT);
-       (void)instance_client_gbar_created(inst, WIDGET_ERROR_TIMED_OUT);
-       (void)instance_del_data(inst, GBAR_OPEN_MONITOR_TAG);
-       (void)instance_unref(inst);
-       ErrPrint("GBAR Open request is timed-out (%lf)\n", WIDGET_CONF_GBAR_REQUEST_TIMEOUT);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool gbar_close_monitor_cb(void *inst)
-{
-       struct pkg_info *pkg;
-
-       pkg = instance_package(inst);
-       if (pkg) {
-               struct slave_node *slave;
-
-               slave = package_slave(pkg);
-               if (slave) {
-                       slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst);
-               }
-       }
-
-       (void)instance_client_gbar_destroyed(inst, WIDGET_ERROR_TIMED_OUT);
-       (void)instance_del_data(inst, GBAR_CLOSE_MONITOR_TAG);
-       (void)instance_unref(inst);
-       ErrPrint("GBAR Close request is not processed in %lf seconds\n", WIDGET_CONF_GBAR_REQUEST_TIMEOUT);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool gbar_resize_monitor_cb(void *inst)
-{
-       struct pkg_info *pkg;
-
-       pkg = instance_package(inst);
-       if (pkg) {
-               struct slave_node *slave;
-               slave = package_slave(pkg);
-               if (slave) {
-                       slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst);
-               }
-       }
-
-       (void)instance_slave_close_gbar(inst, instance_gbar_owner(inst), WIDGET_CLOSE_GBAR_TIMEOUT);
-       (void)instance_client_gbar_destroyed(inst, WIDGET_ERROR_TIMED_OUT);
-       (void)instance_del_data(inst, GBAR_RESIZE_MONITOR_TAG);
-       (void)instance_unref(inst);
-       ErrPrint("GBAR Resize request is not processed in %lf seconds\n", WIDGET_CONF_GBAR_REQUEST_TIMEOUT);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static struct packet *client_create_gbar(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       Ecore_Timer *gbar_monitor;
-       double x;
-       double y;
-
-       DbgPrint("PERF_WIDGET\n");
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
-       if (ret != 4) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_gbar_owner(inst)) {
-               ErrPrint("GBAR is already owned\n");
-               ret = WIDGET_ERROR_ALREADY_EXIST;
-       } else if (package_gbar_type(instance_package(inst)) == GBAR_TYPE_BUFFER) {
-               gbar_monitor = instance_get_data(inst, LAZY_GBAR_CLOSE_TAG);
-               if (gbar_monitor) {
-                       ecore_timer_del(gbar_monitor);
-                       /* This timer attribute will be deleted */
-                       lazy_gbar_destroyed_cb(inst);
-               }
-
-               if (instance_get_data(inst, GBAR_OPEN_MONITOR_TAG)) {
-                       DbgPrint("GBAR Open request is already processed\n");
-                       ret = WIDGET_ERROR_ALREADY_EXIST;
-                       goto out;
-               }
-
-               if (instance_get_data(inst, GBAR_CLOSE_MONITOR_TAG)) {
-                       DbgPrint("GBAR Close request is already in process\n");
-                       ret = WIDGET_ERROR_RESOURCE_BUSY;
-                       goto out;
-               }
-
-               if (instance_get_data(inst, GBAR_RESIZE_MONITOR_TAG)) {
-                       DbgPrint("GBAR resize request is already in process\n");
-                       ret = WIDGET_ERROR_RESOURCE_BUSY;
-                       goto out;
-               }
-
-               instance_slave_set_gbar_pos(inst, x, y);
-               /*!
-                * \note
-                * Send request to the slave.
-                * The SLAVE must has to repsonse this via "release_buffer" method.
-                */
-               ret = instance_slave_open_gbar(inst, client);
-               if (ret == (int)WIDGET_ERROR_NONE) {
-                       ret = instance_signal_emit(inst, "gbar,show", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
-                       if (ret != WIDGET_ERROR_NONE) {
-                               int tmp_ret;
-
-                               tmp_ret = instance_slave_close_gbar(inst, client, WIDGET_CLOSE_GBAR_FAULT);
-                               if (tmp_ret < 0) {
-                                       ErrPrint("Unable to send script event for openning GBAR [%s], %d\n", pkgname, tmp_ret);
-                               }
-                       } else {
-                               gbar_monitor = ecore_timer_add(WIDGET_CONF_GBAR_REQUEST_TIMEOUT, gbar_open_monitor_cb, instance_ref(inst));
-                               if (!gbar_monitor) {
-                                       (void)instance_unref(inst);
-                                       ErrPrint("Failed to create a timer for GBAR Open monitor\n");
-                               } else {
-                                       struct slave_node *slave;
-
-                                       (void)instance_set_data(inst, GBAR_OPEN_MONITOR_TAG, gbar_monitor);
-
-                                       slave = package_slave(pkg);
-                                       if (!slave) {
-                                               ErrPrint("Failed to get slave(%s)\n", pkgname);
-                                               goto out;
-                                       }
-
-                                       if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst) != WIDGET_ERROR_NONE) {
-                                               ErrPrint("Failed to add fault handler: %s\n");
-                                       }
-                               }
-                       }
-               } else {
-                       ErrPrint("Unable to send request for openning GBAR [%s]\n", pkgname);
-               }
-
-               /*!
-                * \note
-                * GBAR craeted event will be send by the acquire_buffer function.
-                * Because the slave will make request the acquire_buffer to
-                * render the GBAR
-                *
-                * instance_client_gbar_created(inst);
-                */
-       } else if (package_gbar_type(instance_package(inst)) == GBAR_TYPE_SCRIPT) {
-               int ix;
-               int iy;
-
-               gbar_monitor = instance_get_data(inst, LAZY_GBAR_CLOSE_TAG);
-               if (gbar_monitor) {
-                       ecore_timer_del(gbar_monitor);
-                       /* lazy,pd,close will be deleted */
-                       lazy_gbar_destroyed_cb(inst);
-               }
-
-               /*!
-                * \note
-                * ret value should be cared but in this case,
-                * we ignore this for this moment, so we have to handle this error later.
-                *
-                * if ret is less than 0, the slave has some problem.
-                * but the script mode doesn't need slave for rendering default view of GBAR
-                * so we can hanle it later.
-                */
-               instance_slave_set_gbar_pos(inst, x, y);
-               ix = x * instance_gbar_width(inst);
-               iy = y * instance_gbar_height(inst);
-
-               script_handler_update_pointer(instance_gbar_script(inst), 0, ix, iy, 0);
-
-               ret = instance_slave_open_gbar(inst, client);
-               if (ret == (int)WIDGET_ERROR_NONE) {
-                       ret = script_handler_load(instance_gbar_script(inst), 1);
-
-                       /*!
-                        * \note
-                        * Send the GBAR created event to the clients,
-                        */
-                       if (ret == (int)WIDGET_ERROR_NONE) {
-
-                               /*!
-                                * \note
-                                * But the created event has to be send afte return
-                                * from this function or the viewer couldn't care
-                                * the event correctly.
-                                */
-                               inst = instance_ref(inst); /* To guarantee the inst */
-
-                               /*!
-                                * \note
-                                * At here, we don't need to rememeber the timer object.
-                                * Even if the timer callback is called, after the instance is destroyed.
-                                * lazy_gbar_created_cb will decrease the instance refcnt first.
-                                * At that time, if the instance is released, the timer callback will do nothing.
-                                *
-                                * 13-05-28
-                                * I change my mind. There is no requirements to keep the timer handler.
-                                * But I just add it to the tagged-data of the instance.
-                                * Just reserve for future-use.
-                                */
-                               gbar_monitor = ecore_timer_add(DELAY_TIME, lazy_gbar_created_cb, inst);
-                               if (!gbar_monitor) {
-                                       ret = script_handler_unload(instance_gbar_script(inst), 1);
-                                       ErrPrint("Unload script: %d\n", ret);
-
-                                       ret = instance_slave_close_gbar(inst, client, WIDGET_CLOSE_GBAR_NORMAL);
-                                       ErrPrint("Close GBAR %d\n", ret);
-
-                                       inst = instance_unref(inst);
-                                       if (!inst) {
-                                               DbgPrint("Instance destroyed\n");
-                                       }
-
-                                       ErrPrint("Instance: %s\n", pkgname);
-
-                                       ret = WIDGET_ERROR_FAULT;
-                               } else {
-                                       struct slave_node *slave;
-
-                                       (void)instance_set_data(inst, LAZY_GBAR_OPEN_TAG, gbar_monitor);
-
-                                       slave = package_slave(pkg);
-                                       if (!slave) {
-                                               ErrPrint("Failed to get slave: %s\n", pkgname);
-                                               goto out;
-                                       }
-
-                                       if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_script_cb, inst) != WIDGET_ERROR_NONE) {
-                                               ErrPrint("Failed to add fault callback: %s\n", pkgname);
-                                       }
-                               }
-                       } else {
-                               int tmp_ret;
-                               tmp_ret = instance_slave_close_gbar(inst, client, WIDGET_CLOSE_GBAR_FAULT);
-                               if (tmp_ret < 0) {
-                                       ErrPrint("Unable to load script: %d, (close: %d)\n", ret, tmp_ret);
-                               }
-                       }
-               } else {
-                       ErrPrint("Unable open GBAR(%s): %d\n", pkgname, ret);
-               }
-       } else {
-               ErrPrint("Invalid GBAR TYPE\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_destroy_gbar(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       Ecore_Timer *gbar_monitor;
-       struct slave_node *slave;
-
-       DbgPrint("PERF_WIDGET\n");
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ss", &pkgname, &id);
-       if (ret != 2) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       slave = package_slave(pkg);
-       if (!slave) {
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (instance_gbar_owner(inst) != client) {
-               if (instance_gbar_owner(inst) == NULL) {
-                       ErrPrint("GBAR looks already closed\n");
-                       ret = WIDGET_ERROR_ALREADY_STARTED;
-               } else {
-                       ErrPrint("GBAR owner mimatched\n");
-                       ret = WIDGET_ERROR_PERMISSION_DENIED;
-               }
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               DbgPrint("Buffer type GBAR\n");
-               gbar_monitor = instance_del_data(inst, GBAR_OPEN_MONITOR_TAG);
-               if (gbar_monitor) {
-                       ErrPrint("GBAR Open request is found. cancel it [%s]\n", pkgname);
-
-                       if (slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst) < 0) {
-                               DbgPrint("Failed to delete a deactivate callback\n");
-                       }
-
-                       /*!
-                        * \note
-                        * We should return negative value
-                        * Or we have to send "destroyed" event to the client.
-                        * If we didn't send destroyed event after return SUCCESS from here,
-                        * The client will permanently waiting destroyed event.
-                        * Because they understand that the destroy request is successfully processed.
-                        */
-                       ret = instance_client_gbar_created(inst, WIDGET_ERROR_CANCELED);
-                       if (ret < 0) {
-                               ErrPrint("GBAR client create event: %d\n", ret);
-                       }
-
-                       ret = instance_client_gbar_destroyed(inst, WIDGET_ERROR_NONE);
-                       if (ret < 0) {
-                               ErrPrint("GBAR client destroy event: %d\n", ret);
-                       }
-
-                       ret = instance_signal_emit(inst, "gbar,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
-                       if (ret < 0) {
-                               ErrPrint("GBAR close signal emit failed: %d\n", ret);
-                       }
-
-                       ret = instance_slave_close_gbar(inst, client, WIDGET_CLOSE_GBAR_NORMAL);
-                       if (ret < 0) {
-                               ErrPrint("GBAR close request failed: %d\n", ret);
-                       }
-
-                       ecore_timer_del(gbar_monitor);
-                       inst = instance_unref(inst);
-                       if (!inst) {
-                               DbgPrint("Instance is deleted\n");
-                       }
-               } else if (instance_get_data(inst, LAZY_GBAR_CLOSE_TAG) || instance_get_data(inst, GBAR_CLOSE_MONITOR_TAG)) {
-                       DbgPrint("Close monitor is already fired\n");
-                       ret = WIDGET_ERROR_ALREADY_STARTED;
-               } else {
-                       int resize_aborted = 0;
-
-                       gbar_monitor = instance_del_data(inst, GBAR_RESIZE_MONITOR_TAG);
-                       if (gbar_monitor) {
-                               ErrPrint("GBAR Resize request is found. clear it [%s]\n", pkgname);
-                               if (slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst) < 0) {
-                                       DbgPrint("Failed to delete a deactivate callback\n");
-                               }
-
-                               ecore_timer_del(gbar_monitor);
-
-                               inst = instance_unref(inst);
-                               if (!inst) {
-                                       DbgPrint("Instance is destroyed while resizing\n");
-                                       goto out;
-                               }
-
-                               resize_aborted = 1;
-                       }
-
-                       ret = instance_signal_emit(inst, "gbar,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
-                       if (ret < 0) {
-                               ErrPrint("GBAR close signal emit failed: %d\n", ret);
-                       }
-
-                       ret = instance_slave_close_gbar(inst, client, WIDGET_CLOSE_GBAR_NORMAL);
-                       if (ret < 0) {
-                               ErrPrint("GBAR close request failed: %d\n", ret);
-                       } else if (resize_aborted) {
-                               gbar_monitor = ecore_timer_add(DELAY_TIME, lazy_gbar_destroyed_cb, instance_ref(inst));
-                               if (!gbar_monitor) {
-                                       ErrPrint("Failed to create a timer: %s\n", pkgname);
-                                       inst = instance_unref(inst);
-                                       if (!inst) {
-                                               DbgPrint("Instance is deleted\n");
-                                       }
-                               } else {
-                                       DbgPrint("Resize is aborted\n");
-                                       (void)instance_set_data(inst, LAZY_GBAR_CLOSE_TAG, gbar_monitor);
-                                       if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst) < 0) {
-                                               ErrPrint("Failed to add a slave event callback\n");
-                                       }
-                               }
-                       } else {
-                               gbar_monitor = ecore_timer_add(WIDGET_CONF_GBAR_REQUEST_TIMEOUT, gbar_close_monitor_cb, instance_ref(inst));
-                               if (!gbar_monitor) {
-                                       ErrPrint("Failed to add pd close monitor\n");
-                                       inst = instance_unref(inst);
-                                       if (!inst) {
-                                               ErrPrint("Instance is deleted while closing GBAR\n");
-                                       }
-                               } else {
-                                       DbgPrint("Add close monitor\n");
-                                       (void)instance_set_data(inst, GBAR_CLOSE_MONITOR_TAG, gbar_monitor);
-                                       if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst) < 0) {
-                                               ErrPrint("Failed to add SLAVE EVENT callback\n");
-                                       }
-                               }
-                       }
-
-                       /*!
-                        * \note
-                        * release_buffer will be called by the slave after this routine.
-                        * It will send the "gbar_destroyed" event to the client
-                        *
-                        * instance_client_gbar_destroyed(inst, WIDGET_ERROR_NONE);
-                        *
-                        * Or the "gbar_close_monitor_cb" or "lazy_gbar_destroyed_cb" will be called.
-                        */
-               }
-       } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
-               DbgPrint("Script TYPE GBAR\n");
-               gbar_monitor = instance_get_data(inst, LAZY_GBAR_OPEN_TAG);
-               if (gbar_monitor) {
-                       ecore_timer_del(gbar_monitor);
-                       (void)lazy_gbar_created_cb(inst);
-               }
-
-               ret = script_handler_unload(instance_gbar_script(inst), 1);
-               if (ret < 0) {
-                       ErrPrint("Unable to unload the script: %s, %d\n", pkgname, ret);
-               }
-
-               /*!
-                * \note
-                * Send request to the slave.
-                * The SLAVE must has to repsonse this via "release_buffer" method.
-                */
-               ret = instance_slave_close_gbar(inst, client, WIDGET_CLOSE_GBAR_NORMAL);
-               if (ret < 0) {
-                       ErrPrint("Unable to close the GBAR: %s, %d\n", pkgname, ret);
-               }
-
-               /*!
-                * \note
-                * Send the destroyed GBAR event to the client
-                */
-               if (ret == (int)WIDGET_ERROR_NONE) {
-                       /*!
-                        * \note
-                        * 13-05-28
-                        * I've changed my mind. There is no requirements to keep the timer handler.
-                        * But I just add it to the tagged-data of the instance.
-                        * Just reserve for future-use.
-                        */
-                       DbgPrint("Add lazy GBAR destroy timer\n");
-                       gbar_monitor = ecore_timer_add(DELAY_TIME, lazy_gbar_destroyed_cb, instance_ref(inst));
-                       if (!gbar_monitor) {
-                               ErrPrint("Failed to create a timer: %s\n", pkgname);
-                               inst = instance_unref(inst);
-                               if (!inst) {
-                                       DbgPrint("instance is deleted\n");
-                               }
-                       } else {
-                               (void)instance_set_data(inst, LAZY_GBAR_CLOSE_TAG, gbar_monitor);
-                               if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_script_cb, inst) < 0) {
-                                       ErrPrint("Failed to add a event callback for slave\n");
-                               }
-                       }
-               }
-       } else {
-               ErrPrint("Invalid GBAR TYPE\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_activate_package(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, ret */
-{
-       struct client_node *client;
-       struct packet *result;
-       const char *pkgname;
-       int ret;
-       struct pkg_info *info;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               pkgname = "";
-               goto out;
-       }
-
-       ret = packet_get(packet, "s", &pkgname);
-       if (ret != 1) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               pkgname = "";
-               goto out;
-       }
-
-       DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
-
-       /*!
-        * \NOTE:
-        * Validate the widget package name.
-        */
-       if (!package_is_widget_pkgname(pkgname)) {
-               ErrPrint("%s is not a valid widget package\n", pkgname);
-               pkgname = "";
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       info = package_find(pkgname);
-       if (!info) {
-               ret = WIDGET_ERROR_NOT_EXIST;
-       } else {
-               ret = package_clear_fault(info);
-       }
-
-out:
-       result = packet_create_reply(packet, "is", ret, pkgname);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_subscribed_group(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *cluster;
-       const char *category;
-       struct client_node *client;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ss", &cluster, &category);
-       if (ret != 2) {
-               ErrPrint("Invalid argument\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
-       if (!strlen(cluster) || !strcasecmp(cluster, WIDGET_CONF_DEFAULT_CLUSTER)) {
-               ErrPrint("Invalid cluster name\n");
-               goto out;
-       }
-
-       /*!
-        * \todo
-        * SUBSCRIBE cluster & sub-cluster for a client.
-        */
-       ret = client_subscribe_group(client, cluster, category);
-       if (ret == 0) {
-               package_alter_instances_to_client(client, ALTER_CREATE);
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_delete_cluster(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *cluster;
-       struct client_node *client;
-       struct packet *result;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "s", &cluster);
-       if (ret != 1) {
-               ErrPrint("Invalid parameters\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       DbgPrint("pid[%d] cluster[%s]\n", pid, cluster);
-
-       if (!strlen(cluster) || !strcasecmp(cluster, WIDGET_CONF_DEFAULT_CLUSTER)) {
-               ErrPrint("Invalid cluster: %s\n", cluster);
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       /*!
-        * \todo
-        */
-       ret = WIDGET_ERROR_NOT_SUPPORTED;
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static inline int update_pkg_cb(struct category *category, const char *pkgname, int force)
-{
-       const char *c_name;
-       const char *s_name;
-
-       c_name = group_cluster_name_by_category(category);
-       s_name = group_category_name(category);
-
-       if (!c_name || !s_name || !pkgname) {
-               ErrPrint("Name is not valid\n");
-               return EXIT_FAILURE;
-       }
-
-       DbgPrint("Send refresh request: %s (%s/%s)\n", pkgname, c_name, s_name);
-       slave_rpc_request_update(pkgname, "", c_name, s_name, NULL, force);
-
-       /* Just try to create a new package */
-       if (util_free_space(WIDGET_CONF_IMAGE_PATH) > WIDGET_CONF_MINIMUM_SPACE) {
-               double timestamp;
-               struct inst_info *inst;
-
-               timestamp = util_timestamp();
-               /*!
-                * \NOTE
-                * Don't need to check the subscribed clients.
-                * Because this callback is called by the requests of clients.
-                * It means. some clients wants to handle this instances ;)
-                */
-               inst = instance_create(NULL, timestamp, pkgname, "", c_name, s_name, WIDGET_CONF_DEFAULT_PERIOD, 0, 0);
-               if (!inst) {
-                       ErrPrint("Failed to create a new instance\n");
-               }
-       }
-
-       return EXIT_SUCCESS;
-}
-
-static struct packet *client_update(pid_t pid, int handle, const struct packet *packet)
-{
-       struct inst_info *inst;
-       struct client_node *client;
-       const char *pkgname;
-       const char *id;
-       int force;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Cilent %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &force);
-       if (ret != 3) {
-               ErrPrint("Invalid argument\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_client(inst) != client) {
-               /* PERMISSIONS */
-               ErrPrint("Insufficient permissions [%s] - %d\n", pkgname, pid);
-       } else {
-               slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst), NULL, force);
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_refresh_group(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *cluster_id;
-       const char *category_id;
-       struct client_node *client;
-       int ret;
-       struct cluster *cluster;
-       struct category *category;
-       struct context_info *info;
-       Eina_List *info_list;
-       Eina_List *l;
-       int force;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Cilent %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &cluster_id, &category_id, &force);
-       if (ret != 3) {
-               ErrPrint("Invalid parameter\n");
-               goto out;
-       }
-
-       DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster_id, category_id);
-
-       if (!strlen(cluster_id) || !strcasecmp(cluster_id, WIDGET_CONF_DEFAULT_CLUSTER)) {
-               ErrPrint("Invalid cluster name: %s\n", cluster_id);
-               goto out;
-       }
-
-       cluster = group_find_cluster(cluster_id);
-       if (!cluster) {
-               ErrPrint("Cluster [%s] is not registered\n", cluster_id);
-               goto out;
-       }
-
-       category = group_find_category(cluster, category_id);
-       if (!category) {
-               ErrPrint("Category [%s] is not registered\n", category_id);
-               goto out;
-       }
-
-       info_list = group_context_info_list(category);
-       EINA_LIST_FOREACH(info_list, l, info) {
-               update_pkg_cb(category, group_pkgname_from_context_info(info), force);
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_delete_category(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *cluster;
-       const char *category;
-       struct client_node *client;
-       struct packet *result;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ss", &cluster, &category);
-       if (ret != 2) {
-               ErrPrint("Invalid paramenters\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       DbgPrint("pid[%d] cluster[%s] category[%s]\n", pid, cluster, category);
-       if (!strlen(cluster) || !strcasecmp(cluster, WIDGET_CONF_DEFAULT_CLUSTER)) {
-               ErrPrint("Invalid cluster: %s\n", cluster);
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       /*!
-        * \todo
-        */
-       ret = WIDGET_ERROR_NOT_SUPPORTED;
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *client_unsubscribed_group(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *cluster;
-       const char *category;
-       struct client_node *client;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "ss", &cluster, &category);
-       if (ret != 2) {
-               ErrPrint("Invalid argument\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
-
-       if (!strlen(cluster) || !strcasecmp(cluster, WIDGET_CONF_DEFAULT_CLUSTER)) {
-               ErrPrint("Invalid cluster name: %s\n", cluster);
-               goto out;
-       }
-
-       /*!
-        * \todo
-        * UNSUBSCRIBE cluster & sub-cluster for a client.
-        */
-       ret = client_unsubscribe_group(client, cluster, category);
-       if (ret == 0) {
-               package_alter_instances_to_client(client, ALTER_DESTROY);
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_subscribed_category(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *category;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "s", &category);
-       if (ret != 1) {
-               ErrPrint("Invalid argument\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       DbgPrint("[%d] category[%s]\n", pid, category);
-       if (!strlen(category)) {
-               ErrPrint("Invalid category name: %s\n", category);
-               goto out;
-       }
-
-       /*!
-        * \TODO
-        * 1. Get a list of created widget instances which are categorized by given "category"
-        * 2. Send created events to the client.
-        * 3. Add this client to "client_only_view_list"
-        */
-       if (client_subscribe_category(client, category) == WIDGET_ERROR_NONE) {
-               package_alter_instances_to_client(client, ALTER_CREATE);
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static struct packet *client_unsubscribed_category(pid_t pid, int handle, const struct packet *packet)
-{
-       struct client_node *client;
-       const char *category;
-       int ret;
-
-       client = client_find_by_rpc_handle(handle);
-       if (!client) {
-               ErrPrint("Client %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "s", &category);
-       if (ret != 1) {
-               ErrPrint("Invalid argument\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       DbgPrint("[%d] category[%s]\n", pid, category);
-       if (!strlen(category)) {
-               ErrPrint("Invalid category name: %s\n", category);
-               goto out;
-       }
-
-       /*!
-        * \TODO
-        * 0. Is this client subscribed to given "category"?
-        * 1. Get a list of created widget instances
-        * 2. and then send destroyed event to this client.
-        * 3. Remove this client from the "client_only_view_list"
-        */
-       if (client_unsubscribe_category(client, category) == WIDGET_ERROR_NONE) {
-               package_alter_instances_to_client(client, ALTER_DESTROY);
-       }
-
-out:
-       /*! \note No reply packet */
-       return NULL;
-}
-
-static inline __attribute__((always_inline)) struct slave_node *debug_mode_enabled(struct slave_node *slave, int pid, const char *slavename, const char *pkgname, int secured, const char *abi, const char *acceleration)
-{
-       if (!slave) {
-               if (pkgname) {
-                       slave = slave_find_by_pkgname(pkgname);
-               }
-
-               if (!slave) {
-                       slave = slave_find_by_pid(pid);
-                       if (!slave) {
-                               slave = slave_create(slavename, secured, abi, pkgname, 0, acceleration);
-                               if (!slave) {
-                                       return NULL;
-                               }
-                       }
-
-                       DbgPrint("New slave is created net(%d) abi(%s) secured(%d) accel(%s)\n", 0, abi, secured, acceleration);
-               } else {
-                       DbgPrint("Registered slave is replaced with this new one\n");
-               }
-       }
-
-       slave_set_pid(slave, pid);
-       slave_set_valid(slave);
-
-       DbgPrint("Provider is forcely activated, pkgname(%s), abi(%s), slavename(%s)\n", pkgname, abi, slavename);
-       return slave;
-}
-
-static struct packet *slave_hello(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
-{
-       char _pkgname[pathconf("/", _PC_PATH_MAX)];
-       const char *pkgname = NULL;
-       struct slave_node *slave;
-       const char *acceleration;
-       const char *slavename;
-       const char *abi;
-       int secured;
-       int ret;
-
-       ret = packet_get(packet, "isss", &secured, &slavename, &acceleration, &abi);
-       if (ret != 4) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       if (acceleration[0] == '\0') {
-               acceleration = NULL;
-       }
-
-       DbgPrint("New slave[%s](%d) is arrived\n", slavename, pid);
-
-       slave = slave_find_by_name(slavename);
-       if (!slave) { /* Try again to find a slave using pid */
-               slave = slave_find_by_pid(pid);
-       }
-
-       if (aul_app_get_pkgname_bypid(pid, _pkgname, sizeof(_pkgname)) != AUL_R_OK) {
-               if (WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode) {
-                       DbgPrint("Debug mode is enabled. could not determine the pkgname for %d\n", pid);
-               } else {
-                       ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
-                       goto out;
-               }
-       } else {
-               pkgname = (const char *)_pkgname;
-       }
-
-       if (!slave) {
-               if (WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode) {
-                       /**
-                        * @note
-                        * In case of debugging mode,
-                        * Slave can be launched first even there are no instances.
-                        * If there is no slave object, the debug_mode_enabled function will create a slave object first.
-                        * So it can waiting service request of master.
-                        *
-                        * But if the slave is launched via valgrind or gdb,
-                        * the slave object cannot be created because the aul_app_get_pkgname_bypid will fails to get pkgname of given process.
-                        * "gdb" or "valgrind" pid is not exists in the package DB.
-                        */
-                       slave = debug_mode_enabled(slave, pid, slavename, pkgname, secured, abi, acceleration);
-                       if (!slave) {
-                               ErrPrint("Failed to create a new slave for %s\n", slavename);
-                               goto out;
-                       }
-               } else {
-                       /**
-                        * @note
-                        * If the master is not in the debug mode,
-                        * terminate slave process if it sends connection request which is not authorized.
-                        */
-                       ErrPrint("Request comes from unknown: %d\n", pid);
-                       ret = aul_terminate_pid_async(pid);
-                       DbgPrint("Terminate %d (%d)\n", pid, ret);
-                       goto out;
-               }
-       } else {
-               if (slave_pid(slave) != pid) {
-                       if (slave_pid(slave) > 0 && !slave_extra_bundle_data(slave) && !(WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode)) {
-                               ErrPrint("Slave(%s) is already assigned to %d\n", slave_name(slave), slave_pid(slave));
-                               if (pid > 0) {
-                                       ret = aul_terminate_pid_async(pid);
-                                       DbgPrint("Terminate %d (ret: %d)\n", pid, ret);
-                               }
-                               goto out;
-                       }
-                       DbgPrint("PID of slave(%s) is updated (%d -> %d) (launched by SDK maybe(%s))\n", slave_name(slave), slave_pid(slave), pid, slave_extra_bundle_data(slave));
-                       slave_set_pid(slave, pid);
-               }
-
-               if (!slave_valid(slave)) {
-                       char *widget_id;
-
-                       widget_id = is_valid_slave(pid, abi, pkgname);
-                       if (widget_id) {
-                               slave_set_valid(slave);
-                               DbgFree(widget_id);
-                       } else {
-                               if (WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode) {
-                                       DbgPrint("Forcely set to valid slave for debugging mode\n");
-                                       slave_set_valid(slave);
-                               } else {
-                                       ErrPrint("slave is not valid (%s)\n", pkgname);
-                                       goto out;
-                               }
-                       }
-               }
-       }
-
-       /*!
-        * \note
-        * After updating handle,
-        * slave activated callback will be called.
-        */
-       slave_rpc_update_handle(slave, handle, 0);
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_ctrl(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       int ctrl;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "i", &ctrl);
-       if (ret != 1) {
-               ErrPrint("Parameter is not matched\n");
-       } else {
-               slave_set_control_option(slave, ctrl);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_ping(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
-{
-       struct slave_node *slave;
-       const char *slavename;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "s", &slavename);
-       if (ret != 1) {
-               ErrPrint("Parameter is not matched\n");
-       } else {
-               (void)slave_rpc_ping(slave);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_faulted(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       struct pkg_info *pkg;
-       const char *pkgname;
-       const char *id;
-       const char *func;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "sss", &pkgname, &id, &func);
-       if (ret != 3) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = fault_info_set(slave, pkgname, id, func);
-       DbgPrint("Slave Faulted: %s (%d)\n", slave_name(slave), ret);
-
-       pkg = package_find(pkgname);
-       if (!pkg) {
-               ErrPrint("There is no package info found: %s\n", pkgname);
-       } else {
-               package_faulted(pkg, 0);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_widget_update_begin(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       const char *pkgname;
-       const char *id;
-       double priority;
-       const char *content;
-       const char *title;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssdss", &pkgname, &id, &priority, &content, &title);
-       if (ret != 5) {
-               ErrPrint("Invalid parameters\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_state(inst) == INST_DESTROYED) {
-               ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = instance_widget_update_begin(inst, priority, content, title);
-               if (ret == (int)WIDGET_ERROR_NONE) {
-                       slave_freeze_ttl(slave);
-               }
-       } else {
-               ErrPrint("Invalid request[%s]\n", id);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_widget_update_end(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       const char *pkgname;
-       const char *id;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ss", &pkgname, &id);
-       if (ret != 2) {
-               ErrPrint("Invalid parameters\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_state(inst) == INST_DESTROYED) {
-               ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               goto out;
-       }
-
-       if (package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               ret = instance_widget_update_end(inst);
-               if (ret == (int)WIDGET_ERROR_NONE) {
-                       slave_thaw_ttl(slave);
-               }
-       } else {
-               ErrPrint("Invalid request[%s]\n", id);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_gbar_update_begin(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       const struct pkg_info *pkg;
-       struct inst_info *inst;
-       const char *pkgname;
-       const char *id;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ss", &pkgname, &id);
-       if (ret != 2) {
-               ErrPrint("Invalid parameters\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_state(inst) == INST_DESTROYED) {
-               ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               (void)instance_gbar_update_begin(inst);
-       } else {
-               ErrPrint("Invalid request[%s]\n", id);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_key_status(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       struct inst_info *inst;
-       const char *pkgname;
-       const char *id;
-       int status;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &status);
-       if (ret != 3) {
-               ErrPrint("Invalid parameters\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               if (instance_state(inst) == INST_DESTROYED) {
-                       ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               } else {
-                       (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
-               }
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_access_status(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       struct inst_info *inst;
-       const char *pkgname;
-       const char *id;
-       int status;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &status);
-       if (ret != 3) {
-               ErrPrint("Invalid parameters\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               if (instance_state(inst) == INST_DESTROYED) {
-                       ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               } else {
-                       (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
-               }
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_close_gbar(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       struct inst_info *inst;
-       const char *pkgname;
-       const char *id;
-       int status;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &status);
-       if (ret != 3) {
-               ErrPrint("Invalid parameters\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               if (instance_state(inst) == INST_DESTROYED) {
-                       ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               } else {
-                       (void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
-               }
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_gbar_update_end(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       const struct pkg_info *pkg;
-       struct inst_info *inst;
-       const char *pkgname;
-       const char *id;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ss", &pkgname, &id);
-       if (ret != 2) {
-               ErrPrint("Invalid parameters\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_state(inst) == INST_DESTROYED) {
-               ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               goto out;
-       }
-
-       if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               (void)instance_gbar_update_end(inst);
-       } else {
-               ErrPrint("Invalid request[%s]\n", id);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_call(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
-{
-       struct slave_node *slave;
-       const char *pkgname;
-       const char *id;
-       const char *func;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "sss", &pkgname, &id, &func);
-       if (ret != 3) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = fault_func_call(slave, pkgname, id, func);
-       slave_give_more_ttl(slave);
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_ret(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, function, ret */
-{
-       struct slave_node *slave;
-       const char *pkgname;
-       const char *id;
-       const char *func;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "sss", &pkgname, &id, &func);
-       if (ret != 3) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = fault_func_ret(slave, pkgname, id, func);
-       slave_give_more_ttl(slave);
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_extra_info(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       const char *pkgname;
-       const char *id;
-       const char *content_info;
-       const char *title;
-       const char *icon;
-       const char *name;
-       double priority;
-       int ret;
-       struct inst_info *inst;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssssssd", &pkgname, &id, &content_info, &title, &icon, &name, &priority);
-       if (ret != 7) {
-               ErrPrint("Parameter is not matchd\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               if (instance_state(inst) == INST_DESTROYED) {
-                       ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-                       goto out;
-               }
-
-               instance_set_widget_info(inst, priority, content_info, title);
-               instance_set_alt_info(inst, icon, name);
-               instance_extra_info_updated_by_instance(inst);
-               slave_give_more_ttl(slave);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, ret */
-{
-       struct slave_node *slave;
-       const char *pkgname;
-       const char *safe_filename;
-       const char *id;
-       int w;
-       int h;
-       int x;
-       int y;
-       int ret;
-       struct inst_info *inst;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "sssiiii", &pkgname, &id, &safe_filename, &x, &y, &w, &h);
-       if (ret != 7) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               if (instance_state(inst) == INST_DESTROYED) {
-                       ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-                       goto out;
-               }
-
-               switch (package_widget_type(instance_package(inst))) {
-               case WIDGET_TYPE_SCRIPT:
-                       script_handler_resize(instance_widget_script(inst), w, h);
-                       if (safe_filename) {
-                               (void)script_handler_parse_desc(inst, safe_filename, 0);
-                       } else {
-                               safe_filename = widget_util_uri_to_path(id);
-                               (void)script_handler_parse_desc(inst, safe_filename, 0);
-                       }
-
-                       if (unlink(safe_filename) < 0) {
-                               ErrPrint("unlink: %d - %s\n", errno, safe_filename);
-                       }
-                       break;
-               case WIDGET_TYPE_BUFFER:
-               default:
-                       /*!
-                        * \check
-                        * text format (inst)
-                        */
-                       instance_widget_updated_by_instance(inst, safe_filename, x, y, w, h);
-                       break;
-               }
-
-               /**
-                * @todo
-                * If the slave has direct connection with viewer,
-                * How could master detects its update and how could it be expanded?
-                */
-               slave_give_more_ttl(slave);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_hold_scroll(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       struct inst_info *inst;
-       const char *pkgname;
-       const char *id;
-       int seize;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssi", &pkgname, &id, &seize);
-       if (ret != 3) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               if (instance_state(inst) == INST_DESTROYED) {
-                       ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               } else {
-                       (void)instance_hold_scroll(inst, seize);
-               }
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_extra_updated(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       const char *pkgname;
-       const char *id;
-       int idx;
-       int x;
-       int y;
-       int w;
-       int h;
-       int ret;
-       int is_gbar;
-       struct inst_info *inst;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ssiiiiii", &pkgname, &id, &is_gbar, &idx, &x, &y, &w, &h);
-       if (ret != 8) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_state(inst) == INST_DESTROYED) {
-               ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               goto out;
-       }
-
-       (void)instance_extra_updated_by_instance(inst, is_gbar, idx, x, y, w, h);
-out:
-       return NULL;
-}
-
-static struct packet *slave_desc_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, decsfile, ret */
-{
-       struct slave_node *slave;
-       const char *pkgname;
-       const char *id;
-       const char *descfile;
-       int x;
-       int y;
-       int w;
-       int h;
-       int ret;
-       struct inst_info *inst;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "sssiiii", &pkgname, &id, &descfile, &x, &y, &w, &h);
-       if (ret != 7) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, NULL);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       if (instance_state(inst) == INST_DESTROYED) {
-               ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               goto out;
-       }
-
-       switch (package_gbar_type(instance_package(inst))) {
-       case GBAR_TYPE_SCRIPT:
-               DbgPrint("%s updated (%s)\n", instance_id(inst), descfile);
-               if (script_handler_is_loaded(instance_gbar_script(inst))) {
-                       (void)script_handler_parse_desc(inst, descfile, 1);
-               }
-               break;
-       case GBAR_TYPE_TEXT:
-               instance_set_gbar_size(inst, 0, 0);
-       case GBAR_TYPE_BUFFER:
-               instance_gbar_updated(pkgname, id, descfile, x, y, w, h);
-               break;
-       default:
-               DbgPrint("Ignore updated DESC(%s)\n", pkgname);
-               break;
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *slave_deleted(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, id, ret */
-{
-       struct slave_node *slave;
-       const char *pkgname;
-       const char *id;
-       int ret;
-       struct inst_info *inst;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               goto out;
-       }
-
-       ret = packet_get(packet, "ss", &pkgname, &id);
-       if (ret != 2) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, NULL);
-       if (ret == (int)WIDGET_ERROR_NONE) {
-               ret = instance_destroyed(inst, WIDGET_ERROR_NONE);
-       }
-
-out:
-       return NULL;
-}
-
-/*!
- * \note for the BUFFER Type slave
- */
-static struct packet *slave_acquire_buffer(pid_t pid, int handle, const struct packet *packet) /* type, id, w, h, size */
-{
-       enum target_type target;
-       const char *pkgname;
-       const char *id;
-       int w;
-       int h;
-       int pixel_size;
-       struct packet *result;
-       struct slave_node *slave;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Failed to find a slave\n");
-               id = "";
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       ret = packet_get(packet, "issiii", &target, &pkgname, &id, &w, &h, &pixel_size);
-       if (ret != 6) {
-               ErrPrint("Invalid argument\n");
-               id = "";
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, &pkg);
-       id = "";
-
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       ret = WIDGET_ERROR_INVALID_PARAMETER;
-
-       if (instance_state(inst) == INST_DESTROYED) {
-               ErrPrint("Package[%s] instance is already destroyed\n", package_name(pkg));
-               goto out;
-       }
-
-       if (target == TYPE_WIDGET && package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               struct buffer_info *info;
-
-               info = instance_widget_buffer(inst);
-               if (!info) {
-                       if (!instance_create_widget_buffer(inst, pixel_size)) {
-                               ErrPrint("Failed to create a WIDGET buffer\n");
-                               ret = WIDGET_ERROR_FAULT;
-                               goto out;
-                       }
-
-                       info = instance_widget_buffer(inst);
-                       if (!info) {
-                               ErrPrint("WIDGET buffer is not valid\n");
-                               /*!
-                                * \NOTE
-                                * ret value should not be changed.
-                                */
-                               goto out;
-                       }
-               }
-
-               ret = buffer_handler_resize(info, w, h, pixel_size);
-               ret = buffer_handler_load(info);
-               if (ret == 0) {
-                       instance_set_widget_size(inst, w, h);
-                       instance_set_widget_info(inst, WIDGET_CONF_PRIORITY_NO_CHANGE, WIDGET_CONF_CONTENT_NO_CHANGE, WIDGET_CONF_TITLE_NO_CHANGE);
-                       id = buffer_handler_id(info);
-               } else {
-                       ErrPrint("Failed to load a buffer(%d)\n", ret);
-               }
-       } else if (target == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               struct buffer_info *info;
-               Ecore_Timer *gbar_monitor;
-               int is_resize;
-
-               is_resize = 0;
-               gbar_monitor = instance_del_data(inst, GBAR_OPEN_MONITOR_TAG);
-               if (!gbar_monitor) {
-                       gbar_monitor = instance_del_data(inst, GBAR_RESIZE_MONITOR_TAG);
-                       is_resize = !!gbar_monitor;
-                       if (!is_resize) {
-                               /* Invalid request. Reject this */
-                               ErrPrint("Invalid request\n");
-                               goto out;
-                       }
-
-                       slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst);
-               } else {
-                       slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst);
-               }
-
-               ecore_timer_del(gbar_monitor);
-               inst = instance_unref(inst);
-               if (!inst) {
-                       ErrPrint("Instance refcnt is ZERO: %s\n", package_name(pkg));
-                       goto out;
-               }
-
-               info = instance_gbar_buffer(inst);
-               if (!info) {
-                       if (!instance_create_gbar_buffer(inst, pixel_size)) {
-                               ErrPrint("Failed to create a GBAR buffer\n");
-                               ret = WIDGET_ERROR_FAULT;
-                               instance_client_gbar_created(inst, ret);
-                               goto out;
-                       }
-
-                       info = instance_gbar_buffer(inst);
-                       if (!info) {
-                               ErrPrint("GBAR buffer is not valid\n");
-                               /*!
-                                * \NOTE
-                                * ret value should not be changed.
-                                */
-                               instance_client_gbar_created(inst, ret);
-                               goto out;
-                       }
-               }
-
-               ret = buffer_handler_resize(info, w, h, pixel_size);
-               ret = buffer_handler_load(info);
-               if (ret == 0) {
-                       instance_set_gbar_size(inst, w, h);
-                       id = buffer_handler_id(info);
-               } else {
-                       ErrPrint("Failed to load a buffer (%d)\n", ret);
-               }
-
-               /*!
-                * Send the GBAR created event to the client
-                */
-               if (!is_resize) {
-                       instance_client_gbar_created(inst, ret);
-               }
-       }
-
-out:
-       result = packet_create_reply(packet, "is", ret, id);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *slave_acquire_extra_buffer(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       struct inst_info *inst;
-       struct packet *result;
-       const struct pkg_info *pkg;
-       const char *pkgname;
-       const char *id;
-       int pixel_size;
-       int target;
-       int idx;
-       int ret;
-       int w;
-       int h;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               id = "";
-               goto out;
-       }
-
-       ret = packet_get(packet, "issiiii", &target, &pkgname, &id, &w, &h, &pixel_size, &idx);
-       if (ret != 7) {
-               ErrPrint("Invalid parameters\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               id = "";
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, &pkg);
-       id = "";
-
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       ret = WIDGET_ERROR_INVALID_PARAMETER;
-
-       if (instance_state(inst) == INST_DESTROYED) {
-               ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               goto out;
-       }
-
-       if (target == TYPE_WIDGET && package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               struct buffer_info *info;
-
-               info = instance_widget_extra_buffer(inst, idx);
-               if (!info) {
-                       if (!instance_create_widget_extra_buffer(inst, pixel_size, idx)) {
-                               ErrPrint("Failed to create a WIDGET buffer\n");
-                               ret = WIDGET_ERROR_FAULT;
-                               goto out;
-                       }
-
-                       info = instance_widget_extra_buffer(inst, idx);
-                       if (!info) {
-                               ErrPrint("WIDGET extra buffer is not valid\n");
-                               /*!
-                                * \NOTE
-                                * ret value should not be changed.
-                                */
-                               goto out;
-                       }
-               }
-
-               ret = buffer_handler_resize(info, w, h, pixel_size);
-               ret = buffer_handler_load(info);
-               if (ret == 0) {
-                       /**
-                        * @todo
-                        * Send the extra buffer info to the viewer.
-                        * Then the viewer will try to acquire extra pixmap(aka, resource id) information
-                        */
-                       id = buffer_handler_id(info);
-                       DbgPrint("Extra buffer is loaded: %s\n", id);
-                       (void)instance_client_widget_extra_buffer_created(inst, idx);
-               } else {
-                       ErrPrint("Failed to load a buffer(%d)\n", ret);
-               }
-       } else if (target == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               struct buffer_info *info;
-
-               info = instance_gbar_extra_buffer(inst, idx);
-               if (!info) {
-                       if (!instance_create_gbar_extra_buffer(inst, pixel_size, idx)) {
-                               ErrPrint("Failed to create a GBAR buffer\n");
-                               ret = WIDGET_ERROR_FAULT;
-                               goto out;
-                       }
-
-                       info = instance_gbar_extra_buffer(inst, idx);
-                       if (!info) {
-                               ErrPrint("GBAR buffer is not valid\n");
-                               /*!
-                                * \NOTE
-                                * ret value should not be changed.
-                                */
-                               goto out;
-                       }
-               }
-
-               ret = buffer_handler_resize(info, w, h, pixel_size);
-               ret = buffer_handler_load(info);
-               if (ret == 0) {
-                       id = buffer_handler_id(info);
-                       /**
-                        * @todo
-                        * Send the extra buffer acquired event to the viewer
-                        */
-                       DbgPrint("Extra buffer is loaded: %s\n", id);
-                       (void)instance_client_gbar_extra_buffer_created(inst, idx);
-               } else {
-                       ErrPrint("Failed to load a buffer (%d)\n", ret);
-               }
-       }
-
-out:
-       result = packet_create_reply(packet, "is", ret, id);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       struct packet *result;
-       enum target_type type;
-       const char *pkgname;
-       const char *id;
-       int w;
-       int h;
-       struct inst_info *inst = NULL;
-       const struct pkg_info *pkg = NULL;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Failed to find a slave\n");
-               ret = WIDGET_ERROR_NOT_EXIST;
-               id = "";
-               goto out;
-       }
-
-       ret = packet_get(packet, "issii", &type, &pkgname, &id, &w, &h);
-       if (ret != 5) {
-               ErrPrint("Invalid argument\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               id = "";
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, &pkg);
-       id = "";
-
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       ret = WIDGET_ERROR_INVALID_PARAMETER;
-       /*!
-        * \note
-        * Reset "id", It will be re-used from here
-        */
-
-       if (instance_state(inst) == INST_DESTROYED) {
-               ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-               goto out;
-       }
-
-       if (type == TYPE_WIDGET && package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               struct buffer_info *info;
-
-               info = instance_widget_buffer(inst);
-               if (!info) {
-                       goto out;
-               }
-
-               ret = buffer_handler_resize(info, w, h, 0);
-               /*!
-                * \note
-                * id is resued for newly assigned ID
-                */
-               if (ret == (int)WIDGET_ERROR_NONE) {
-                       id = buffer_handler_id(info);
-                       instance_set_widget_size(inst, w, h);
-                       instance_set_widget_info(inst, WIDGET_CONF_PRIORITY_NO_CHANGE, WIDGET_CONF_CONTENT_NO_CHANGE, WIDGET_CONF_TITLE_NO_CHANGE);
-               }
-       } else if (type == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               struct buffer_info *info;
-
-               info = instance_gbar_buffer(inst);
-               if (!info) {
-                       goto out;
-               }
-
-               ret = buffer_handler_resize(info, w, h, 0);
-               /*!
-                * \note
-                * id is resued for newly assigned ID
-                */
-               if (ret == (int)WIDGET_ERROR_NONE) {
-                       id = buffer_handler_id(info);
-                       instance_set_gbar_size(inst, w, h);
-               }
-       }
-
-out:
-       result = packet_create_reply(packet, "is", ret, id);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *slave_release_buffer(pid_t pid, int handle, const struct packet *packet)
-{
-       enum target_type type;
-       const char *pkgname;
-       const char *id;
-       struct packet *result;
-       struct slave_node *slave;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-       int ret;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Failed to find a slave\n");
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       if (packet_get(packet, "iss", &type, &pkgname, &id) != 3) {
-               ErrPrint("Inavlid argument\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       ret = WIDGET_ERROR_INVALID_PARAMETER;
-
-       if (type == TYPE_WIDGET && package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               struct buffer_info *info;
-
-               info = instance_widget_buffer(inst);
-               ret = buffer_handler_unload(info);
-       } else if (type == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               struct buffer_info *info;
-               Ecore_Timer *gbar_monitor;
-
-               gbar_monitor = instance_del_data(inst, GBAR_CLOSE_MONITOR_TAG);
-               if (!gbar_monitor && !package_is_fault(pkg)) {
-                       ErrPrint("Slave requests to release a buffer\n");
-                       /**
-                        * @note
-                        * In this case just keep going to release buffer,
-                        * Even if a user(client) doesn't wants to destroy the GBAR.
-                        *
-                        * If the slave tries to destroy GBAR buffer, it should be
-                        * released and reported to the client about its status.
-                        *
-                        * Even if the pd is destroyed by timeout handler,
-                        * instance_client_gbar_destroyed function will be ignored
-                        * by pd.need_to_send_close_event flag.
-                        * which will be checked by instance_client_gbar_destroyed function.
-                        */
-
-                       /**
-                        * @note
-                        * provider can try to resize the buffer size.
-                        * in that case, it will release the buffer first.
-                        * Then even though the client doesn't request to close the GBAR,
-                        * the provider can release it.
-                        * If we send the close event to the client,
-                        * The client will not able to allocate GBAR again.
-                        * In this case, add the pd,monitor again. from here.
-                        * to wait the re-allocate buffer.
-                        * If the client doesn't request buffer reallocation,
-                        * Treat it as a fault. and close the GBAR.
-                        */
-                       info = instance_gbar_buffer(inst);
-                       ret = buffer_handler_unload(info);
-
-                       if (ret == (int)WIDGET_ERROR_NONE) {
-                               gbar_monitor = ecore_timer_add(WIDGET_CONF_GBAR_REQUEST_TIMEOUT, gbar_resize_monitor_cb, instance_ref(inst));
-                               if (!gbar_monitor) {
-                                       ErrPrint("Failed to create a timer for GBAR Open monitor\n");
-                                       inst = instance_unref(inst);
-                                       if (!inst) {
-                                               DbgPrint("Instance is deleted\n");
-                                       }
-                               } else {
-                                       (void)instance_set_data(inst, GBAR_RESIZE_MONITOR_TAG, gbar_monitor);
-                                       if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst) != WIDGET_ERROR_NONE) {
-                                               ErrPrint("Failed to add event handler: %s\n", pkgname);
-                                       }
-                               }
-                       }
-               } else {
-                       if (gbar_monitor) {
-                               /**
-                                * @note
-                                * If the instance has gbar_monitor, the pd close requested from client via client_destroy_gbar.
-                                */
-                               slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst);
-                               ecore_timer_del(gbar_monitor);
-
-                               inst = instance_unref(inst);
-                               if (!inst) {
-                                       ErrPrint("Instance is released: %s\n", pkgname);
-                                       ret = WIDGET_ERROR_FAULT;
-                                       goto out;
-                               }
-                       } /* else {
-                                @note
-                                This case means that the package is faulted so the service provider tries to release the buffer
-                          */
-
-                       info = instance_gbar_buffer(inst);
-                       ret = buffer_handler_unload(info);
-
-                       /**
-                        * @note
-                        * Send the GBAR destroyed event to the client
-                        */
-                       instance_client_gbar_destroyed(inst, ret);
-               }
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *slave_release_extra_buffer(pid_t pid, int handle, const struct packet *packet)
-{
-       struct slave_node *slave;
-       struct packet *result;
-       const char *id;
-       struct buffer_info *info = NULL;
-       int ret;
-       int idx;
-       int type;
-       const char *pkgname;
-       struct inst_info *inst;
-       const struct pkg_info *pkg;
-
-       slave = slave_find_by_pid(pid);
-       if (!slave) {
-               ErrPrint("Slave %d is not exists\n", pid);
-               ret = WIDGET_ERROR_NOT_EXIST;
-               goto out;
-       }
-
-       if (packet_get(packet, "issi", &type, &pkgname, &id, &idx) != 4) {
-               ErrPrint("Inavlid argument\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = validate_request(pid, slave, pkgname, id, &inst, &pkg);
-       if (ret != WIDGET_ERROR_NONE) {
-               goto out;
-       }
-
-       ret = WIDGET_ERROR_INVALID_PARAMETER;
-
-       if (type == TYPE_WIDGET && package_widget_type(pkg) == WIDGET_TYPE_BUFFER) {
-               info = instance_widget_extra_buffer(inst, idx);
-               (void)instance_client_widget_extra_buffer_destroyed(inst, idx);
-       } else if (type == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
-               info = instance_gbar_extra_buffer(inst, idx);
-               (void)instance_client_gbar_extra_buffer_destroyed(inst, idx);
-       }
-
-       if (info) {
-               ret = buffer_handler_unload(info);
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a reply packet\n");
-       }
-
-       return result;
-}
-
-static void delete_ctx_cb(int handle, void *data)
-{
-       struct sync_ctx_item *ctx = data;
-
-       s_info.hello_sync_ctx_list = eina_list_remove(s_info.hello_sync_ctx_list, ctx);
-
-       if (ctx->handle != handle) {
-               ErrPrint("Context is not valid (%s)\n", ctx->pkgname);
-       }
-
-       DbgFree(ctx->pkgname);
-       DbgFree(ctx);
-}
-
-static struct packet *slave_hello_sync_prepare(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
-{
-       char _pkgname[pathconf("/", _PC_PATH_MAX)];
-       const char *pkgname = NULL;
-       int ret;
-       struct sync_ctx_item *ctx;
-       double timestamp;
-       Eina_List *l;
-       Eina_List *n;
-
-       ret = packet_get(packet, "d", &timestamp);
-       if (ret != 1) {
-               ErrPrint("Parameter is not matched\n");
-               goto out;
-       }
-
-       if (aul_app_get_pkgname_bypid(pid, _pkgname, sizeof(_pkgname)) != AUL_R_OK) {
-               if (WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode) {
-                       DbgPrint("Failed to get pkgname of %d\n", pid);
-               } else {
-                       ErrPrint("pid[%d] is not authroized provider package, try to find it using its name\n", pid);
-                       goto out;
-               }
-       } else {
-               pkgname = (const char *)_pkgname;
-       }
-
-       ctx = NULL;
-       EINA_LIST_FOREACH_SAFE(s_info.hello_sync_ctx_list, l, n, ctx) {
-               if (ctx->timestamp == timestamp) {
-                       if (pkgname && ctx->pkgname) {
-                               if (strcmp(pkgname, ctx->pkgname)) {
-                                       ErrPrint("timestamp is valid, but pkgname is not matched: %s <> %s\n", pkgname, ctx->pkgname);
-                                       /* Go ahead */
-                               }
-                       } else {
-                               DbgPrint("Skip to pkgname comparison (%s <> %s)\n", pkgname, ctx->pkgname);
-                       }
-
-                       break;
-               }
-               ctx = NULL;
-       }
-
-       if (ctx) {
-               struct slave_node *slave;
-               /**
-                * @note
-                * This is only possible that the hello_sync comes first.
-                * In that case, we should activate the slave from here.
-                */
-               s_info.hello_sync_ctx_list  = eina_list_remove(s_info.hello_sync_ctx_list, ctx);
-               if (ctx->prepare_sync_wait_timer) {
-                       ecore_timer_del(ctx->prepare_sync_wait_timer);
-               }
-               DbgFree(ctx->pkgname);
-               DbgFree(ctx);
-
-               slave = slave_find_by_pid(pid);
-               if (!slave) {
-                       ErrPrint("Unable to activate slave %d\n", pid);
-                       goto out;
-               }
-
-               DbgPrint("Update handle for %s (%d)\n", pkgname, handle);
-               slave_rpc_update_handle(slave, handle, 1);
-       } else {
-               ctx = calloc(1, sizeof(*ctx));
-               if (!ctx) {
-                       ErrPrint("calloc: %d\n", errno);
-                       goto out;
-               }
-
-               ctx->timestamp = timestamp;
-
-               if (pkgname) {
-                       ctx->pkgname = strdup(pkgname);
-                       if (!ctx->pkgname) {
-                               ErrPrint("strdup: %d\n", errno);
-                               DbgFree(ctx);
-                               goto out;
-                       }
-               }
-
-               ctx->pid = pid;
-               ctx->handle = handle;
-
-               DbgPrint("Sync context created: %s (%d)\n", pkgname, pid);
-               s_info.hello_sync_ctx_list = eina_list_append(s_info.hello_sync_ctx_list, ctx);
-
-               if (dead_callback_add(handle, delete_ctx_cb, ctx) < 0) {
-                       ErrPrint("Failed to add dead callback\n");
-               }
-       }
-
-out:
-       return NULL;
-}
-
-static Eina_Bool prepare_sync_wait_cb(void *data)
-{
-       struct sync_ctx_item *item = data;
-
-       s_info.hello_sync_ctx_list = eina_list_remove(s_info.hello_sync_ctx_list, item);
-
-       ErrPrint("Sync timer(%lf) expired (%s), Terminate %d\n", WIDGET_CONF_SLAVE_ACTIVATE_TIME * 2.0f, item->pkgname, item->pid);
-
-       if (item->pid > 0) {
-               aul_terminate_pid_async(item->pid);
-       }
-
-       item->prepare_sync_wait_timer = NULL;
-       DbgFree(item->pkgname);
-       DbgFree(item);
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static struct packet *slave_hello_sync(pid_t pid, int handle, const struct packet *packet) /* slave_name, ret */
-{
-       struct packet *result = NULL;
-       struct slave_node *slave;
-       const char *slavename;
-       const char *slave_pkgname;
-       const char *acceleration;
-       const char *abi;
-       char *widget_id;
-       int secured;
-       int ret;
-       char _pkgname[pathconf("/", _PC_PATH_MAX)];
-       double timestamp;
-       const char *pkgname = NULL;
-
-       ret = packet_get(packet, "disssss", &timestamp, &secured, &slavename, &slave_pkgname, &acceleration, &abi, &widget_id);
-       if (ret != 7) {
-               ErrPrint("Parameter is not matched\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (acceleration[0] == '\0') {
-               acceleration = NULL;
-       }
-
-       DbgPrint("New slave[%s](%d) is arrived.\n", slavename, pid);
-
-       /**
-        * In case of watch-app, the slavename is declared by app itself.
-        * So slave_find_by_name will always fail.
-        * But the slave object can be found from slave_find_by_pid.
-        */
-       slave = slave_find_by_name(slavename);
-       if (!slave) { /* Try again to find a slave using pid */
-               slave = slave_find_by_pid(pid);
-               if (!slave) {
-                       slave = slave_find_by_pkgname(slave_pkgname);
-                       ErrPrint("Failed to find, Find it using pkgname(%s) - %p\n", slave_pkgname, slave);
-               }
-       }
-
-       if (aul_app_get_pkgname_bypid(pid, _pkgname, sizeof(_pkgname)) != AUL_R_OK) {
-               if (WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode) {
-                       pkgname = slave_pkgname;
-                       DbgPrint("Debug mode is enabled. could not determine the pkgname for %d use the slave_pkgname[%s]\n", pid, pkgname);
-               } else {
-                       ErrPrint("pid[%d] is not authroized provider package, try to find it using its name[%s]\n", pid, slavename);
-                       ret = WIDGET_ERROR_PERMISSION_DENIED;
-                       goto out;
-               }
-       } else {
-               pkgname = (const char *)_pkgname;
-       }
-
-       if (slave) {
-               struct sync_ctx_item *item;
-               Eina_List *l;
-               Eina_List *n;
-
-               item = NULL;
-               EINA_LIST_FOREACH_SAFE(s_info.hello_sync_ctx_list, l, n, item) {
-                       if (item->timestamp == timestamp && item->pid == pid) {
-                               s_info.hello_sync_ctx_list = eina_list_remove(s_info.hello_sync_ctx_list, item);
-                               break;
-                       }
-                       item = NULL;
-               }
-
-               if (!item) {
-                       ErrPrint("There is no such sync context (%d), Waiting prepare ctx\n", pid);
-
-                       item = calloc(1, sizeof(*item));
-                       if (!item) {
-                               ErrPrint("calloc: %d\n", errno);
-                               ret = WIDGET_ERROR_OUT_OF_MEMORY;
-                               goto out;
-                       }
-
-                       item->pkgname = strdup(pkgname);
-                       if (!item->pkgname) {
-                               ErrPrint("strdup: %d\n", errno);
-                               DbgFree(item);
-                               ret = WIDGET_ERROR_OUT_OF_MEMORY;
-                               goto out;
-                       }
-
-                       item->handle = -1;
-                       item->pid = pid;
-                       item->timestamp = timestamp;
-
-                       if (!(WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode)) {
-                               /**
-                                * @note
-                                * If the prepare sync doesn't come in ACTIVATE_TIME * 2.0f, there is a problem. we have to cancel it
-                                */
-                               item->prepare_sync_wait_timer = ecore_timer_add(WIDGET_CONF_SLAVE_ACTIVATE_TIME * 2.0f, prepare_sync_wait_cb, item);
-                       } else {
-                               DbgPrint("prepare sync wait timer is disabled for debugging\n");
-                       }
-
-                       /**
-                        * @note
-                        * How can we delete this if there is no prepare context?
-                        */
-                       s_info.hello_sync_ctx_list = eina_list_append(s_info.hello_sync_ctx_list, item);
-
-                       /**
-                        * @note
-                        * Reset the handle to prevent from updating RPC handle of SLAVE object
-                        */
-                       handle = -1;
-               } else {
-                       if (item->pkgname) {
-                               if (strcmp(item->pkgname, pkgname)) {
-                                       ErrPrint("HELLO_SYNC is comes from different package: %s <> %s\n", item->pkgname, pkgname);
-                               }
-                       } else {
-                               DbgPrint("item->pkgname[%s]\n", item->pkgname);
-                       }
-
-                       handle = item->handle;
-
-                       if (dead_callback_del(handle, delete_ctx_cb, item) != item) {
-                               ErrPrint("Dead callback is not valid\n");
-                       }
-
-                       DbgFree(item->pkgname);
-                       DbgFree(item);
-
-                       DbgPrint("Hello sync context found: %s\n", pkgname);
-               }
-       }
-
-       if (!slave) {
-               if (WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode) {
-                       slave = debug_mode_enabled(slave, pid, slavename, pkgname, secured, abi, acceleration);
-                       if (!slave) {
-                               ErrPrint("Failed to create a new slave for %s\n", slavename);
-                               ret = WIDGET_ERROR_FAULT;
-                               goto out;
-                       }
-               } else {
-                       ErrPrint("There is no valid slave instance. ignore this %s\n", slavename);
-                       ret = WIDGET_ERROR_NOT_EXIST;
-                       goto out;
-               }
-       } else {
-               struct pkg_info *info;
-               struct inst_info *inst;
-               int width, height;
-               unsigned int widget_size;
-               Eina_List *inst_list;
-               char *tmp_widget_id;
-
-               tmp_widget_id = is_valid_slave(pid, abi, pkgname);
-               if (!tmp_widget_id) {
-                       goto out;
-               }
-
-               if (strcmp(widget_id, tmp_widget_id)) {
-                       DbgPrint("[%s] <> [%s]\n", widget_id, tmp_widget_id);
-               }
-
-               DbgFree(tmp_widget_id);
-
-               if (!slave_is_watch(slave)) {
-                       ErrPrint("Slave is not watch(only watch can use hello_sync) [%s]\n", widget_id);
-                       goto out;
-               }
-
-               info = package_find(widget_id);
-               if (!info) {
-                       char *pkgid;
-
-                       pkgid = widget_service_get_package_id(widget_id);
-                       if (!pkgid) {
-                               goto out;
-                       }
-
-                       DbgPrint("Package information is not exists, create it for [%s]\n", widget_id);
-                       info = package_create(pkgid, widget_id);
-                       DbgFree(pkgid);
-
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               inst_list = package_instance_list(info);
-               inst = eina_list_data_get(eina_list_last(inst_list));
-               if (!inst) {
-                       ErrPrint("Instance is not available for [%s]\n", widget_id);
-                       ret = WIDGET_ERROR_FAULT;
-                       goto out;
-               }
-
-               DbgPrint("[%s] Instance Count: %d\n", widget_id, eina_list_count(inst_list));
-
-               if (slave_pid(slave) != pid) {
-                       if (slave_pid(slave) > 0 && !slave_extra_bundle_data(slave) && !(WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode)) {
-                               CRITICAL_LOG("Slave(%s) is already assigned to %d\n", slave_name(slave), slave_pid(slave));
-                               if (pid > 0) {
-                                       ret = aul_terminate_pid_async(pid);
-                                       CRITICAL_LOG("Terminate %d (ret: %d)\n", pid, ret);
-                               }
-                               ret = WIDGET_ERROR_NOT_EXIST;
-                               goto out;
-                       }
-                       DbgPrint("PID of slave(%s) is updated (%d -> %d)\n", slave_name(slave), slave_pid(slave), pid);
-                       slave_set_pid(slave, pid);
-               }
-
-               slave_set_valid(slave);
-
-               if (handle >= 0) {
-                       slave_rpc_update_handle(slave, handle, 1);
-
-                       /**
-                        * @note
-                        * This PAUSE/RESUME state will be sent to the provider after the instance is created.
-                        * Because, this command is sync. so there is no way to get the state packet first then create packet.
-                        */
-               } else {
-                       DbgPrint("Slave RPC should be updated soon (waiting prepare sync)\n");
-               }
-
-               DbgPrint("Slave is activated by request: %d (%s)/(%s)\n", pid, pkgname, slavename);
-               widget_size = package_size_list(info);
-
-               if (widget_size & WIDGET_SIZE_TYPE_2x2) {
-                       widget_service_get_size(WIDGET_SIZE_TYPE_2x2, &width, &height);
-               } else if (widget_size & WIDGET_SIZE_TYPE_4x4) {
-                       widget_service_get_size(WIDGET_SIZE_TYPE_4x4, &width, &height);
-               } else {
-                       widget_service_get_size(WIDGET_SIZE_TYPE_1x1, &width, &height);
-                       DbgPrint("widget(%s] does not support size [2x2], [4x4]\n",pkgname);
-               }
-
-               (void)instance_watch_change_package_info(inst, info);
-               result = instance_duplicate_packet_create(packet, inst, width, height);
-
-               if (instance_watch_need_to_recover(inst)) {
-                       /**
-                        * @note
-                        * Reset the state recover flag.
-                        */
-                       (void)instance_watch_set_need_to_recover(inst, EINA_FALSE);
-
-                       /**
-                        * @note
-                        * Re-send the visible state change request in this case.
-                        * But, this will be sent after return from this function.
-                        * Request will be sent from command comsumer which are running by timer callback.
-                        * (slave_rpc_request_only, slave_rpc_async_request, ...)
-                        */
-                       (void)instance_watch_recover_visible_state(inst);
-               }
-       }
-
-out:
-       if (!result) {
-               DbgPrint("## ret [%d]\n", ret);
-               result = packet_create_reply(packet, "i", ret);
-               if (!result) {
-                       ErrPrint("Failed to create a reply packet\n");
-               }
-       }
-       return result;
-}
-
-static struct packet *service_instance_count(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       struct pkg_info *pkg;
-       double timestamp;
-       const char *pkgname;
-       const char *cluster;
-       const char *category;
-       Eina_List *pkg_list;
-       Eina_List *l;
-       Eina_List *inst_list;
-       Eina_List *inst_l;
-       struct inst_info *inst;
-       int ret;
-
-       ret = packet_get(packet, "sssd", &pkgname, &cluster, &category, &timestamp);
-       if (ret != 4) {
-               ErrPrint("Invalid packet\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       pkg_list = (Eina_List *)package_list();
-
-       ret = 0;
-       EINA_LIST_FOREACH(pkg_list, l, pkg) {
-               if (pkgname && pkgname[0]) {
-                       if (strcmp(package_name(pkg), pkgname)) {
-                               continue;
-                       }
-               }
-
-               inst_list = package_instance_list(pkg);
-               EINA_LIST_FOREACH(inst_list, inst_l, inst) {
-                       if (cluster && cluster[0]) {
-                               if (strcmp(instance_cluster(inst), cluster)) {
-                                       continue;
-                               }
-                       }
-
-                       if (category && category[0]) {
-                               if (strcmp(instance_category(inst), category)) {
-                                       continue;
-                               }
-                       }
-
-                       ret++;
-               }
-       }
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *service_get_content(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *inst_id;
-       const char *widget_id;
-       struct inst_info *inst;
-       struct packet *result;
-
-       if (packet_get(packet, "ss", &widget_id, &inst_id) != 2) {
-               ErrPrint("Invalid parameter\n");
-               return NULL;
-       }
-
-       if (is_valid_service_requestor(pid, widget_id) == 0) {
-               ErrPrint("Invalid service requestor: %d %s\n", pid, widget_id);
-               result = packet_create_reply(packet, "is", WIDGET_ERROR_PERMISSION_DENIED, "?");
-               return result;
-       }
-
-       inst = package_find_instance_by_id(widget_id, inst_id);
-       if (!inst) {
-               result = packet_create_reply(packet, "is", WIDGET_ERROR_NOT_EXIST, "?");
-       } else {
-               result = packet_create_reply(packet, "is", WIDGET_ERROR_NONE, instance_content(inst));
-       }
-
-       if (!result) {
-               ErrPrint("Failed to create a result packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *service_get_inst_list(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *widget_id;
-       struct pkg_info *pkg;
-       struct packet *result;
-
-       if (packet_get(packet, "s", &widget_id) != 1) {
-               ErrPrint("Invalid parameter\n");
-               return NULL;
-       }
-
-       if (is_valid_service_requestor(pid, widget_id) == 0) {
-               ErrPrint("Invalid requestor: %d %s\n", pid, widget_id);
-               result = packet_create_reply(packet, "iis", WIDGET_ERROR_PERMISSION_DENIED, 0, NULL);
-               return result;
-       }
-
-       pkg = package_find(widget_id);
-       if (!pkg) {
-               result = packet_create_reply(packet, "iis", WIDGET_ERROR_NOT_EXIST, 0, NULL);
-       } else {
-               Eina_List *inst_list;
-
-               inst_list = package_instance_list(pkg);
-               if (!inst_list) {
-                       result = packet_create_reply(packet, "iis", WIDGET_ERROR_NOT_EXIST, 0, NULL);
-               } else {
-                       char *id_buffer;
-                       int size = sysconf(_SC_PAGESIZE);
-                       Eina_List *l;
-                       struct inst_info *inst;
-                       int offset;
-                       int len;
-                       int cnt = 0;
-
-                       if (size < 0) {
-                               ErrPrint("sysconf: %d\n", errno);
-                               size = PAGE_SIZE;
-                       }
-
-                       id_buffer = malloc(size);
-                       if (!id_buffer) {
-                               result = packet_create_reply(packet, "iis", WIDGET_ERROR_OUT_OF_MEMORY, 0, NULL);
-                               goto out;
-                       }
-
-                       offset = 0;
-                       EINA_LIST_FOREACH(inst_list, l, inst) {
-                               len = strlen(instance_id(inst));
-                               if (offset + len > size) {
-                                       /* Expanding the ID_BUFFER */
-                                       char *resized_buffer;
-                                       int more_size;
-                                       more_size = sysconf(_SC_PAGESIZE);
-                                       if (more_size < 0) {
-                                               ErrPrint("sysconf: %d\n", errno);
-                                               more_size = PAGE_SIZE;
-                                       }
-                                       size += more_size;
-
-                                       DbgPrint("Expanding heap to %d\n", size);
-
-                                       resized_buffer = realloc(id_buffer, size);
-                                       if (!resized_buffer) {
-                                               ErrPrint("realloc: %d\n", errno);
-                                               DbgFree(id_buffer);
-                                               result = packet_create_reply(packet, "iis", WIDGET_ERROR_OUT_OF_MEMORY, 0, NULL);
-                                               goto out;
-                                       }
-
-                                       id_buffer = resized_buffer;
-                                       cnt++;
-                               }
-
-                               strcpy(id_buffer + offset, instance_id(inst));
-                               /* Replace last NULL with NEW_LINE */
-                               id_buffer[offset + len] = '\n';
-                               offset += (len + 1);
-                       }
-
-                       id_buffer[offset] = '\0';
-                       result = packet_create_reply(packet, "iis", WIDGET_ERROR_NONE, cnt, id_buffer);
-                       DbgFree(id_buffer);
-               }
-       }
-
-out:
-       return result;
-}
-
-static struct packet *monitor_register(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *widget_id;
-
-       if (packet_get(packet, "s", &widget_id) != 1) {
-               ErrPrint("Invalid parameter\n");
-               goto out;
-       }
-
-       if (widget_id[0] == '*' && widget_id[1] == '\0') {
-               widget_id = NULL;
-       }
-
-       DbgPrint("Register monitor target for [%s]\n", widget_id);
-       if (!widget_id) {
-               /**
-                * @TODO
-                *  Only the authorized requstor can listens all widget's lifecycle event.
-               WIDGET_CONF_MONITOR_PACKAGE required
-                */
-               if (widget_mgr_is_valid_requestor(pid) == 0) {
-                       ErrPrint("All widget's lifecycle event listener is not registered\n");
-                       goto out;
-               }
-       } else {
-               if (is_valid_service_requestor(pid, widget_id) == 0) {
-                       goto out;
-               }
-       }
-
-       if (monitor_find_client_by_pid(widget_id, pid)) {
-               ErrPrint("Already registered: [%s], %d\n", widget_id, pid);
-       } else {
-               if (monitor_create_client(widget_id, pid, handle) == NULL) {
-                       ErrPrint("Failed to create a new monitor client\n");
-               }
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *monitor_unregister(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *widget_id;
-       struct monitor_client *monitor;
-
-       if (packet_get(packet, "s", &widget_id) != 1) {
-               ErrPrint("Invalid parameter\n");
-               goto out;
-       }
-
-       if (widget_id[0] == '*' && widget_id[1] == '\0') {
-               widget_id = NULL;
-       }
-
-       monitor = monitor_find_client_by_pid(widget_id, pid);
-       if (monitor) {
-               DbgPrint("Unregister monitor target: %s\n", widget_id);
-               monitor_destroy_client(monitor);
-       } else {
-               ErrPrint("Monitor for %s is not exists(%d)\n", widget_id, pid);
-       }
-
-out:
-       return NULL;
-}
-
-static struct packet *service_change_period(pid_t pid, int handle, const struct packet *packet)
-{
-       struct inst_info *inst;
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       double period;
-       int ret;
-
-       ret = packet_get(packet, "ssd", &pkgname, &id, &period);
-       if (ret != 3) {
-               ErrPrint("Invalid packet\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (is_valid_service_requestor(pid, pkgname) == 0) {
-               ErrPrint("Invalid requestor: %d (%s)\n", pid, pkgname);
-               ret = WIDGET_ERROR_PERMISSION_DENIED;
-               goto out;
-       }
-
-       if (!strlen(id)) {
-               struct pkg_info *pkg;
-
-               pkg = package_find(pkgname);
-               if (!pkg) {
-                       ret = WIDGET_ERROR_NOT_EXIST;
-               } else if (package_is_fault(pkg)) {
-                       ret = WIDGET_ERROR_FAULT;
-               } else {
-                       Eina_List *inst_list;
-                       Eina_List *l;
-
-                       inst_list = package_instance_list(pkg);
-                       EINA_LIST_FOREACH(inst_list, l, inst) {
-                               ret = instance_set_period(inst, period);
-                               if (ret < 0) {
-                                       ErrPrint("Failed to change the period of %s to (%lf)\n", pkgname, period);
-                               }
-                       }
-               }
-       } else {
-               ret = validate_request(pid, NULL, pkgname, id, &inst, NULL);
-               if (ret == (int)WIDGET_ERROR_NONE) {
-                       if (instance_state(inst) == INST_DESTROYED) {
-                               ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
-                               ret = WIDGET_ERROR_INVALID_PARAMETER;
-                               goto out;
-                       }
-
-                       ret = instance_set_period(inst, period);
-               }
-       }
-
-       DbgPrint("Change the update period: %s, %lf : %d\n", pkgname, period, ret);
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
-{
-       Eina_List *inst_list;
-       struct pkg_info *pkg;
-       struct packet *result;
-       const char *pkgname;
-       const char *id;
-       const char *cluster;
-       const char *category;
-       const char *content;
-       int force;
-       char *widget_id;
-       int ret;
-
-       ret = packet_get(packet, "sssssi", &pkgname, &id, &cluster, &category, &content, &force);
-       if (ret != 6) {
-               ErrPrint("Invalid Packet\n");
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       if (is_valid_service_requestor(pid, pkgname) == 0) {
-               ErrPrint("Requestor is not valid\n");
-               ret = WIDGET_ERROR_PERMISSION_DENIED;
-               goto out;
-       }
-
-       widget_id = package_widget_pkgname(pkgname);
-       if (!widget_id) {
-               ErrPrint("Invalid package %s\n", pkgname);
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       pkg = package_find(widget_id);
-       if (!pkg) {
-               ret = WIDGET_ERROR_NOT_EXIST;
-               DbgFree(widget_id);
-               goto out;
-       }
-
-       if (package_is_fault(pkg)) {
-               ret = WIDGET_ERROR_FAULT;
-               DbgFree(widget_id);
-               goto out;
-       }
-
-       inst_list = package_instance_list(pkg);
-       if (!eina_list_count(inst_list)) {
-               ret = WIDGET_ERROR_NOT_EXIST;
-               DbgFree(widget_id);
-               goto out;
-       }
-
-       if (id && strlen(id)) {
-               Eina_List *l;
-               struct inst_info *inst;
-
-               ret = WIDGET_ERROR_NOT_EXIST;
-               EINA_LIST_FOREACH(inst_list, l, inst) {
-                       if (!strcmp(instance_id(inst), id)) {
-                               ret = WIDGET_ERROR_NONE;
-                               break;
-                       }
-               }
-
-               if (ret == (int)WIDGET_ERROR_NOT_EXIST) {
-                       DbgFree(widget_id);
-                       goto out;
-               }
-       }
-
-       /*!
-        * \TODO
-        * Validate the update requstor.
-        */
-       slave_rpc_request_update(widget_id, id, cluster, category, content, force);
-       DbgFree(widget_id);
-       ret = WIDGET_ERROR_NONE;
-
-out:
-       result = packet_create_reply(packet, "i", ret);
-       if (!result) {
-               ErrPrint("Failed to create a packet\n");
-       }
-
-       return result;
-}
-
-static struct packet *widget_mgr_hello(pid_t pid, int handle, const struct packet *packet)
-{
-       struct widget_mgr *info;
-       struct packet *result;
-       int ret;
-       const char *fifo_name;
-       double timestamp;
-
-       DbgPrint("Request arrived from %d\n", pid);
-
-       if (packet_get(packet, "d", &timestamp) != 1) {
-               ErrPrint("Invalid packet\n");
-               fifo_name = "";
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       info = widget_mgr_create(pid, handle);
-       if (!info) {
-               ErrPrint("Failed to create a widget_mgr object\n");
-               fifo_name = "";
-               ret = WIDGET_ERROR_INVALID_PARAMETER;
-               goto out;
-       }
-
-       ret = 0;
-       fifo_name = widget_mgr_filename(info);
-       DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
-
-out:
-       result = packet_create_reply(packet, "si", fifo_name, ret);
-       if (!result) {
-               ErrPrint("Failed to create a result packet\n");
-       }
-
-       return result;
-}
-
-static Eina_Bool lazy_slave_list_cb(void *info)
-{
-       FILE *fp;
-       Eina_List *list;
-       Eina_List *l;
-       struct slave_node *slave;
-
-       widget_mgr_open_fifo(info);
-       fp = widget_mgr_fifo(info);
-       if (!fp) {
-               widget_mgr_close_fifo(info);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       list = (Eina_List *)slave_list();
-       EINA_LIST_FOREACH(list, l, slave) {
-               fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n", 
-                               slave_pid(slave),
-                               slave_name(slave),
-                               slave_pkgname(slave),
-                               slave_abi(slave),
-                               slave_is_secured(slave),
-                               slave_refcnt(slave),
-                               slave_fault_count(slave),
-                               slave_state_string(slave),
-                               slave_loaded_instance(slave),
-                               slave_loaded_package(slave),
-                               slave_ttl(slave)
-                          );
-       }
-
-       fprintf(fp, "EOD\n");
-       widget_mgr_close_fifo(info);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static struct packet *widget_mgr_slave_list(pid_t pid, int handle, const struct packet *packet)
-{
-       struct widget_mgr *info;
-       double timestamp;
-
-       if (packet_get(packet, "d", &timestamp) != 1) {
-               ErrPrint("Invalid argument\n");
-               goto out;
-       }
-
-       info = widget_mgr_find_by_pid(pid);
-       if (!info) {
-               ErrPrint("Invalid request\n");
-               goto out;
-       }
-
-       lazy_slave_list_cb(info);
-out:
-       return NULL;
-}
-
-static inline const char *visible_state_string(enum widget_visible_state state)
-{
-       switch (state) {
-       case WIDGET_SHOW:
-               return "Show";
-       case WIDGET_HIDE:
-               return "Hide";
-       case WIDGET_HIDE_WITH_PAUSE:
-               return "Paused";
-       default:
-               break;
-       }
-
-       return "Unknown";
-}
-
-static Eina_Bool inst_list_cb(void *info)
-{
-       FILE *fp;
-       char *pkgname;
-       struct pkg_info *pkg;
-       Eina_List *l;
-       Eina_List *inst_list;
-       struct inst_info *inst;
-
-       pkgname = widget_mgr_data(info);
-       if (!pkgname) {
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       widget_mgr_open_fifo(info);
-       fp = widget_mgr_fifo(info);
-       if (!fp) {
-               ErrPrint("Invalid fp\n");
-               widget_mgr_close_fifo(info);
-               free(pkgname);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       if (!package_is_widget_pkgname(pkgname)) {
-               ErrPrint("Invalid package name\n");
-               free(pkgname);
-               goto close_out;
-       }
-
-       pkg = package_find(pkgname);
-       free(pkgname);
-       if (!pkg) {
-               ErrPrint("Package is not exists\n");
-               goto close_out;
-       }
-
-       inst_list = package_instance_list(pkg);
-       EINA_LIST_FOREACH(inst_list, l, inst) {
-               fprintf(fp, "%s %s %s %s %lf %s %d %d\n",
-                               instance_id(inst),
-                               buffer_handler_id(instance_widget_buffer(inst)),
-                               instance_cluster(inst),
-                               instance_category(inst),
-                               instance_period(inst),
-                               visible_state_string(instance_visible_state(inst)),
-                               instance_widget_width(inst),
-                               instance_widget_height(inst));
-       }
-
-close_out:
-       fprintf(fp, "EOD\n");
-       widget_mgr_close_fifo(info);
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static struct packet *widget_mgr_inst_list(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *pkgname;
-       char *dup_pkgname;
-       struct widget_mgr *info;
-
-       if (packet_get(packet, "s", &pkgname) != 1) {
-               ErrPrint("Invalid argument\n");
-               goto out;
-       }
-
-       info = widget_mgr_find_by_pid(pid);
-       if (!info) {
-               ErrPrint("Invalid request\n");
-               goto out;
-       }
-
-       dup_pkgname = strdup(pkgname);
-       if (!dup_pkgname) {
-               ErrPrint("Invalid request\n");
-               goto out;
-       }
-
-       widget_mgr_set_data(info, dup_pkgname);
-       inst_list_cb(info);
-
-out:
-       return NULL;
-}
-
-static Eina_Bool pkg_list_cb(void *info)
-{
-       FILE *fp;
-       Eina_List *l;
-       Eina_List *list;
-       Eina_List *inst_list;
-       struct pkg_info *pkg;
-       struct slave_node *slave;
-       const char *slavename;
-       pid_t pid;
-
-       widget_mgr_open_fifo(info);
-       fp = widget_mgr_fifo(info);
-       if (!fp) {
-               DbgPrint("Failed to open a pipe\n");
-               widget_mgr_close_fifo(info);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       list = (Eina_List *)package_list();
-       EINA_LIST_FOREACH(list, l, pkg) {
-               slave = package_slave(pkg);
-
-               if (slave) {
-                       slavename = slave_name(slave);
-                       pid = slave_pid(slave);
-               } else {
-                       pid = (pid_t)-1;
-                       slavename = "";
-               }
-
-               inst_list = (Eina_List *)package_instance_list(pkg);
-               fprintf(fp, "%d %s %s %s %d %d %d\n",
-                               pid,
-                               strlen(slavename) ? slavename : "(none)",
-                               package_name(pkg),
-                               package_abi(pkg),
-                               package_refcnt(pkg),
-                               package_fault_count(pkg),
-                               eina_list_count(inst_list)
-                          );
-               DbgPrint("%d %s %s %s %d %d %d\n",
-                               pid,
-                               strlen(slavename) ? slavename : "(none)",
-                               package_name(pkg),
-                               package_abi(pkg),
-                               package_refcnt(pkg),
-                               package_fault_count(pkg),
-                               eina_list_count(inst_list)
-                               );
-       }
-
-       fprintf(fp, "EOD\n");
-       DbgPrint("EOD\n");
-       widget_mgr_close_fifo(info);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static struct packet *widget_mgr_pkg_list(pid_t pid, int handle, const struct packet *packet)
-{
-       struct widget_mgr *info;
-       double timestamp;
-
-       if (packet_get(packet, "d", &timestamp) != 1) {
-               ErrPrint("Invalid argument\n");
-               goto out;
-       }
-
-       DbgPrint("Package List: %lf\n", timestamp);
-
-       info = widget_mgr_find_by_pid(pid);
-       if (!info) {
-               ErrPrint("Invalid request\n");
-               goto out;
-       }
-
-       pkg_list_cb(info);
-out:
-       return NULL;
-}
-
-static struct packet *widget_mgr_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
-{
-       char *pkgname;
-       char *id;
-       int cmd;
-       int value;
-       int packet_cmd;
-       struct widget_mgr *mgr;
-       struct inst_info *inst;
-       struct pkg_info *info;
-       struct packet *ctrl_packet;
-
-       if (packet_get(packet, "ssii", &pkgname, &id, &cmd, &value) != 4) {
-               ErrPrint("Invalid argument\n");
-               goto out;
-       }
-
-       mgr = widget_mgr_find_by_pid(pid);
-       if (!mgr) {
-               ErrPrint("Invalid request\n");
-               goto out;
-       }
-
-       switch (cmd) {
-       case WIDGET_CTRL_MODE_DUMP_FRAME:
-               inst = package_find_instance_by_id(pkgname, id);
-               if (!inst) {
-                       ErrPrint("Instance not found: %s\n", id);
-                       goto out;
-               }
-
-               info = instance_package(inst);
-               if (!info) {
-                       ErrPrint("Unable to get pkginfo\n");
-                       goto out;
-               }
-
-               packet_cmd = CMD_CTRL_MODE;
-               ctrl_packet = packet_create_noack((const char *)&packet_cmd, "ssii", pkgname, id, cmd, value);
-               if (ctrl_packet) {
-                       if (slave_rpc_request_only(package_slave(info), package_name(info), ctrl_packet, 0) < 0) {
-                               ErrPrint("Failed to send request\n");
-                       }
-               }
-
-               DbgPrint("Dump frames: %d\n", value);
-               break;
-       default:
-               ErrPrint("Unknown command\n");
-               break;
-       }
-
-out:
-       return NULL;
-}
-
-static Eina_Bool pkg_ctrl_rmpack_cb(void *info)
-{
-       FILE *fp;
-       widget_mgr_open_fifo(info);
-       fp = widget_mgr_fifo(info);
-       if (!fp) {
-               widget_mgr_close_fifo(info);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       fprintf(fp, "%d\n", ENOSYS);
-       fprintf(fp, "EOD\n");
-       widget_mgr_close_fifo(info);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool pkg_ctrl_rminst_cb(void *info)
-{
-       FILE *fp;
-
-       widget_mgr_open_fifo(info);
-       fp = widget_mgr_fifo(info);
-       if (!fp) {
-               widget_mgr_close_fifo(info);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       fprintf(fp, "%ld\n", (long)widget_mgr_data(info));
-       fprintf(fp, "EOD\n");
-       widget_mgr_close_fifo(info);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool pkg_ctrl_faultinst_cb(void *info)
-{
-       FILE *fp;
-
-       widget_mgr_open_fifo(info);
-       fp = widget_mgr_fifo(info);
-       if (!fp) {
-               widget_mgr_close_fifo(info);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       fprintf(fp, "%ld\n", (long)widget_mgr_data(info));
-       fprintf(fp, "EOD\n");
-       widget_mgr_close_fifo(info);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static struct packet *widget_mgr_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
-{
-       struct widget_mgr *info;
-       char *cmd;
-       char *pkgname;
-       char *id;
-
-       if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
-               ErrPrint("Invalid argument\n");
-               goto out;
-       }
-
-       info = widget_mgr_find_by_pid(pid);
-       if (!info) {
-               ErrPrint("Invalid request\n");
-               goto out;
-       }
-
-       if (!strcmp(cmd, "rmpack")) {
-               pkg_ctrl_rmpack_cb(info);
-       } else if (!strcmp(cmd, "rminst")) {
-               struct inst_info *inst;
-               inst = package_find_instance_by_id(pkgname, id);
-               if (!inst) {
-                       widget_mgr_set_data(info, (void *)ENOENT);
-               } else {
-                       (void)instance_destroy(inst, WIDGET_DESTROY_TYPE_DEFAULT);
-                       widget_mgr_set_data(info, (void *)0);
-               }
-
-               pkg_ctrl_rminst_cb(info);
-       } else if (!strcmp(cmd, "faultinst")) {
-               struct inst_info *inst;
-               inst = package_find_instance_by_id(pkgname, id);
-               if (!inst) {
-                       widget_mgr_set_data(info, (void *)ENOENT);
-               } else {
-                       struct pkg_info *pkg;
-
-                       pkg = instance_package(inst);
-                       if (!pkg) {
-                               widget_mgr_set_data(info, (void *)EFAULT);
-                       } else {
-                               (void)package_faulted(pkg, 1);
-                               widget_mgr_set_data(info, (void *)0);
-                       }
-               }
-
-               pkg_ctrl_faultinst_cb(info);
-       }
-
-out:
-       return NULL;
-}
-
-static Eina_Bool master_ctrl_cb(void *info)
-{
-       FILE *fp;
-
-       widget_mgr_open_fifo(info);
-       fp = widget_mgr_fifo(info);
-       if (!fp) {
-               widget_mgr_close_fifo(info);
-               return ECORE_CALLBACK_CANCEL;
-       }
-       fprintf(fp, "%ld\nEOD\n", (long)widget_mgr_data(info));
-       widget_mgr_close_fifo(info);
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static struct packet *widget_mgr_master_ctrl(pid_t pid, int handle, const struct packet *packet)
-{
-       struct widget_mgr *info;
-       char *cmd;
-       char *var;
-       char *val;
-       long ret = WIDGET_ERROR_INVALID_PARAMETER;
-
-       if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
-               ErrPrint("Invalid argument\n");
-               goto out;
-       }
-
-       info = widget_mgr_find_by_pid(pid);
-       if (!info) {
-               ErrPrint("Invalid request\n");
-               goto out;
-       }
-
-       if (!strcasecmp(var, "debug")) {
-               if (!strcasecmp(cmd, "set")) {
-                       g_conf.debug_mode = !strcasecmp(val, "on");
-               } else if (!strcasecmp(cmd, "get")) {
-               }
-               ret = g_conf.debug_mode;
-       } else if (!strcasecmp(var, "slave_max_load")) {
-               if (!strcasecmp(cmd, "set")) {
-                       g_conf.slave_max_load = atoi(val);
-               } else if (!strcasecmp(cmd, "get")) {
-               }
-               ret = g_conf.slave_max_load;
-       }
-
-       widget_mgr_set_data(info, (void *)ret);
-       master_ctrl_cb(info);
-
-out:
-       return NULL;
-}
-
-static struct method s_info_table[] = {
-       {
-               .cmd = CMD_STR_INFO_HELLO,
-               .handler = widget_mgr_hello,
-       },
-       {
-               .cmd = CMD_STR_INFO_SLAVE_LIST,
-               .handler = widget_mgr_slave_list,
-       },
-       {
-               .cmd = CMD_STR_INFO_PKG_LIST,
-               .handler = widget_mgr_pkg_list,
-       },
-       {
-               .cmd = CMD_STR_INFO_INST_LIST,
-               .handler = widget_mgr_inst_list,
-       },
-       {
-               .cmd = CMD_STR_INFO_SLAVE_CTRL,
-               .handler = widget_mgr_slave_ctrl,
-       },
-       {
-               .cmd = CMD_STR_INFO_PKG_CTRL,
-               .handler = widget_mgr_pkg_ctrl,
-       },
-       {
-               .cmd = CMD_STR_INFO_MASTER_CTRL,
-               .handler = widget_mgr_master_ctrl,
-       },
-       {
-               .cmd = NULL,
-               .handler = NULL,
-       },
-};
-
-static struct method s_client_table[] = {
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_MOVE,
-               .handler = client_gbar_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_MOVE,
-               .handler = client_widget_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_DOWN,
-               .handler = client_gbar_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_UP,
-               .handler = client_gbar_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_DOWN,
-               .handler = client_widget_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_UP,
-               .handler = client_widget_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_ENTER,
-               .handler = client_gbar_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_LEAVE,
-               .handler = client_gbar_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_ENTER,
-               .handler = client_widget_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_LEAVE,
-               .handler = client_widget_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_ON_SCROLL,
-               .handler = client_widget_mouse_on_scroll,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_OFF_SCROLL,
-               .handler = client_widget_mouse_off_scroll,
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_ON_SCROLL,
-               .handler = client_gbar_mouse_on_scroll,
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_OFF_SCROLL,
-               .handler = client_gbar_mouse_off_scroll,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_ON_HOLD,
-               .handler = client_widget_mouse_on_hold,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_OFF_HOLD,
-               .handler = client_widget_mouse_off_hold,
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_ON_HOLD,
-               .handler = client_gbar_mouse_on_hold,
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_OFF_HOLD,
-               .handler = client_gbar_mouse_off_hold,
-       },
-       {
-               .cmd = CMD_STR_CLICKED,
-               .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
-       },
-       {
-               .cmd = CMD_STR_TEXT_SIGNAL,
-               .handler = client_text_signal, /* pid, pkgname, filename, signal_name, source, s, sy, ex, ey, ret */
-       },
-       {
-               .cmd = CMD_STR_DELETE,
-               .handler = client_delete, /* pid, pkgname, filename, ret */
-       },
-       {
-               .cmd = CMD_STR_RESIZE,
-               .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
-       },
-       {
-               .cmd = CMD_STR_NEW,
-               .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
-       },
-       {
-               .cmd = CMD_STR_SET_PERIOD,
-               .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
-       },
-       {
-               .cmd = CMD_STR_CHANGE_GROUP,
-               .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOVE,
-               .handler = client_gbar_move, /* pkgname, id, x, y */
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACCESS_HL,
-               .handler = client_gbar_access_hl,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACCESS_ACTIVATE,
-               .handler = client_gbar_access_activate,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACCESS_ACTION,
-               .handler = client_gbar_access_action,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACCESS_SCROLL,
-               .handler = client_gbar_access_scroll,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACCESS_VALUE_CHANGE,
-               .handler = client_gbar_access_value_change,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACCESS_MOUSE,
-               .handler = client_gbar_access_mouse,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACCESS_BACK,
-               .handler = client_gbar_access_back,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACCESS_OVER,
-               .handler = client_gbar_access_over,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACCESS_READ,
-               .handler = client_gbar_access_read,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACCESS_ENABLE,
-               .handler = client_gbar_access_enable,
-       },
-
-       {
-               .cmd = CMD_STR_WIDGET_ACCESS_HL,
-               .handler = client_widget_access_hl,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACCESS_ACTIVATE,
-               .handler = client_widget_access_activate,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACCESS_ACTION,
-               .handler = client_widget_access_action,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACCESS_SCROLL,
-               .handler = client_widget_access_scroll,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACCESS_VALUE_CHANGE,
-               .handler = client_widget_access_value_change,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACCESS_MOUSE,
-               .handler = client_widget_access_mouse,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACCESS_BACK,
-               .handler = client_widget_access_back,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACCESS_OVER,
-               .handler = client_widget_access_over,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACCESS_READ,
-               .handler = client_widget_access_read,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACCESS_ENABLE,
-               .handler = client_widget_access_enable,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_KEY_DOWN,
-               .handler = client_widget_key_down,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_KEY_UP,
-               .handler = client_widget_key_up,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_KEY_FOCUS_IN,
-               .handler = client_widget_key_focus_in,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_KEY_FOCUS_OUT,
-               .handler = client_widget_key_focus_out,
-       },
-       {
-               .cmd = CMD_STR_GBAR_KEY_DOWN,
-               .handler = client_gbar_key_down,
-       },
-       {
-               .cmd = CMD_STR_GBAR_KEY_UP,
-               .handler = client_gbar_key_up,
-       },
-       {
-               .cmd = CMD_STR_GBAR_KEY_FOCUS_IN,
-               .handler = client_gbar_key_focus_in,
-       },
-       {
-               .cmd = CMD_STR_GBAR_KEY_FOCUS_OUT,
-               .handler = client_gbar_key_focus_out,
-       },
-       {
-               .cmd = CMD_STR_UPDATE_MODE,
-               .handler = client_update_mode,
-       },
-       // Cut HERE. Above list must be sync'd with provider list.
-
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_SET,
-               .handler = client_widget_mouse_set,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_MOUSE_UNSET,
-               .handler = client_widget_mouse_unset,
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_SET,
-               .handler = client_gbar_mouse_set,
-       },
-       {
-               .cmd = CMD_STR_GBAR_MOUSE_UNSET,
-               .handler = client_gbar_mouse_unset,
-       },
-       {
-               .cmd = CMD_STR_ORIENTATION,
-               .handler = client_change_orientation,
-       },
-       {
-               .cmd = CMD_STR_CHANGE_VISIBILITY,
-               .handler = client_change_visibility,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACQUIRE_PIXMAP,
-               .handler = client_widget_acquire_pixmap,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_RELEASE_PIXMAP,
-               .handler = client_widget_release_pixmap,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACQUIRE_PIXMAP,
-               .handler = client_gbar_acquire_pixmap,
-       },
-       {
-               .cmd = CMD_STR_GBAR_RELEASE_PIXMAP,
-               .handler = client_gbar_release_pixmap,
-       },
-       {
-               .cmd = CMD_STR_ACQUIRE,
-               .handler = client_acquire, /*!< pid, ret */
-       },
-       {
-               .cmd = CMD_STR_RELEASE,
-               .handler = cilent_release, /*!< pid, ret */
-       },
-       {
-               .cmd = CMD_STR_PINUP_CHANGED,
-               .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
-       },
-       {
-               .cmd = CMD_STR_CREATE_GBAR,
-               .handler = client_create_gbar, /* pid, pkgname, filename, ret */
-       },
-       {
-               .cmd = CMD_STR_DESTROY_GBAR,
-               .handler = client_destroy_gbar, /* pid, pkgname, filename, ret */
-       },
-       {
-               .cmd = CMD_STR_ACTIVATE_PACKAGE,
-               .handler = client_activate_package, /* pid, pkgname, ret */
-       },
-       {
-               .cmd = CMD_STR_SUBSCRIBE, /* pid, cluster, sub-cluster */
-               .handler = client_subscribed_group,
-       },
-       {
-               .cmd = CMD_STR_UNSUBSCRIBE, /* pid, cluster, sub-cluster */
-               .handler = client_unsubscribed_group,
-       },
-       {
-               .cmd = CMD_STR_DELETE_CLUSTER,
-               .handler = client_delete_cluster,
-       },
-       {
-               .cmd = CMD_STR_DELETE_CATEGORY,
-               .handler = client_delete_category,
-       },
-       {
-               .cmd = CMD_STR_REFRESH_GROUP,
-               .handler = client_refresh_group,
-       },
-       {
-               .cmd = CMD_STR_UPDATE,
-               .handler = client_update,
-       },
-
-       {
-               .cmd = CMD_STR_WIDGET_KEY_SET,
-               .handler = client_widget_key_set,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_KEY_UNSET,
-               .handler = client_widget_key_unset,
-       },
-
-       {
-               .cmd = CMD_STR_GBAR_KEY_SET,
-               .handler = client_gbar_key_set,
-       },
-       {
-               .cmd = CMD_STR_GBAR_KEY_UNSET,
-               .handler = client_gbar_key_unset,
-       },
-
-       {
-               .cmd = CMD_STR_CLIENT_PAUSED,
-               .handler = client_pause_request,
-       },
-       {
-               .cmd = CMD_STR_CLIENT_RESUMED,
-               .handler = client_resume_request,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_ACQUIRE_XPIXMAP,
-               .handler = client_widget_acquire_xpixmap,
-       },
-       {
-               .cmd = CMD_STR_GBAR_ACQUIRE_XPIXMAP,
-               .handler = client_gbar_acquire_xpixmap,
-       },
-       {
-               .cmd = CMD_STR_SUBSCRIBE_CATEGORY,
-               .handler = client_subscribed_category,
-       },
-       {
-               .cmd = CMD_STR_UNSUBSCRIBE_CATEGORY,
-               .handler = client_unsubscribed_category,
-       },
-
-    {
-        .cmd = CMD_STR_HELLO_SYNC,
-        .handler = slave_hello_sync, /* slave_name, ret */
-    },
-    {
-        .cmd = CMD_STR_HELLO_SYNC_PREPARE,
-        .handler = slave_hello_sync_prepare, /* timestamp */
-    },
-
-       {
-               .cmd = NULL,
-               .handler = NULL,
-       },
-};
-
-static struct method s_service_table[] = {
-       {
-               .cmd = CMD_STR_SERVICE_UPDATE,
-               .handler = service_update,
-       },
-       {
-               .cmd = CMD_STR_SERVICE_CHANGE_PERIOD,
-               .handler = service_change_period,
-       },
-       {
-               .cmd = CMD_STR_SERVICE_INST_CNT,
-               .handler = service_instance_count,
-       },
-       {
-               .cmd = CMD_STR_MONITOR_REGISTER,
-               .handler = monitor_register,
-       },
-       {
-               .cmd = CMD_STR_MONITOR_UNREGISTER,
-               .handler = monitor_unregister,
-       },
-       {
-               .cmd = CMD_STR_SERVICE_GET_CONTENT,
-               .handler = service_get_content,
-       },
-       {
-               .cmd = CMD_STR_SERVICE_GET_INST_LIST,
-               .handler = service_get_inst_list,
-       },
-       {
-               .cmd = NULL,
-               .handler = NULL,
-       },
-};
-
-static struct method s_slave_table[] = {
-       {
-               .cmd = CMD_STR_UPDATED,
-               .handler = slave_updated, /* slave_name, pkgname, filename, width, height, ret */
-       },
-       {
-               .cmd = CMD_STR_DESC_UPDATED,
-               .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
-       },
-       {
-               .cmd = CMD_STR_EXTRA_UPDATED,
-               .handler = slave_extra_updated,
-       },
-       {
-               .cmd = CMD_STR_EXTRA_INFO,
-               .handler = slave_extra_info, /* slave_name, pkgname, filename, priority, content_info, title, icon, name */
-       },
-       {
-               .cmd = CMD_STR_DELETED,
-               .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
-       },
-       {
-               .cmd = CMD_STR_FAULTED,
-               .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
-       },
-       {
-               .cmd = CMD_STR_SCROLL,
-               .handler = slave_hold_scroll, /* slave_name, pkgname, id, seize */
-       },
-
-       {
-               .cmd = CMD_STR_WIDGET_UPDATE_BEGIN,
-               .handler = slave_widget_update_begin,
-       },
-       {
-               .cmd = CMD_STR_WIDGET_UPDATE_END,
-               .handler = slave_widget_update_end,
-       },
-       {
-               .cmd = CMD_STR_GBAR_UPDATE_BEGIN,
-               .handler = slave_gbar_update_begin,
-       },
-       {
-               .cmd = CMD_STR_GBAR_UPDATE_END,
-               .handler = slave_gbar_update_end,
-       },
-
-       {
-               .cmd = CMD_STR_ACCESS_STATUS,
-               .handler = slave_access_status,
-       },
-       {
-               .cmd = CMD_STR_KEY_STATUS,
-               .handler = slave_key_status,
-       },
-       {
-               .cmd = CMD_STR_CLOSE_GBAR,
-               .handler = slave_close_gbar,
-       },
-
-       {
-               .cmd = CMD_STR_CALL,
-               .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
-       },
-       {
-               .cmd = CMD_STR_RET,
-               .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
-       },
-       {
-               .cmd = CMD_STR_ACQUIRE_BUFFER,
-               .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
-       },
-       {
-               .cmd = CMD_STR_RESIZE_BUFFER,
-               .handler = slave_resize_buffer,
-       },
-       {
-               .cmd = CMD_STR_RELEASE_BUFFER,
-               .handler = slave_release_buffer, /* slave_name, id - ret */
-       },
-       {
-               .cmd = CMD_STR_HELLO,
-               .handler = slave_hello, /* slave_name, ret */
-       },
-       {
-               .cmd = CMD_STR_PING,
-               .handler = slave_ping, /* slave_name, ret */
-       },
-       {
-               .cmd = CMD_STR_CTRL,
-               .handler = slave_ctrl, /* control bits */
-       },
-
-       {
-               .cmd = CMD_STR_ACQUIRE_XBUFFER,
-               .handler = slave_acquire_extra_buffer,
-       },
-       {
-               .cmd = CMD_STR_RELEASE_XBUFFER,
-               .handler = slave_release_extra_buffer,
-       },
-
-    {
-        .cmd = CMD_STR_HELLO_SYNC,
-        .handler = slave_hello_sync, /* slave_name, ret */
-    },
-    {
-        .cmd = CMD_STR_HELLO_SYNC_PREPARE,
-        .handler = slave_hello_sync_prepare, /* timestamp */
-    },
-
-       {
-               .cmd = NULL,
-               .handler = NULL,
-       },
-};
-
-HAPI int server_init(void)
-{
-       if (unlink(INFO_SOCKET) < 0) {
-               ErrPrint("unlink info: %d\n", errno);
-       }
-
-       s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
-       if (s_info.info_fd < 0) {
-               ErrPrint("Failed to create a info socket\n");
-       }
-
-       s_info.slave_fd = com_core_packet_server_init_with_permission("sdlocal://"SLAVE_SOCKET, s_slave_table, NULL);
-       if (s_info.slave_fd < 0) {
-               ErrPrint("Failed to create a slave socket\n");
-       }
-
-       s_info.client_fd = com_core_packet_server_init_with_permission("sdlocal://"CLIENT_SOCKET, s_client_table, NULL);
-       if (s_info.client_fd < 0) {
-               ErrPrint("Failed to create a client socket\n");
-       }
-
-       s_info.service_fd = com_core_packet_server_init_with_permission("sdlocal://"SERVICE_SOCKET, s_service_table, NULL);
-       if (s_info.service_fd < 0) {
-               ErrPrint("Faild to create a service socket\n");
-       }
-
-       if (chmod(INFO_SOCKET, 0600) < 0) {
-               ErrPrint("chmod info: %d\n", errno);
-       }
-
-       return 0;
-}
-
-HAPI int server_fini(void)
-{
-       if (s_info.info_fd > 0) {
-               com_core_packet_server_fini(s_info.info_fd);
-               s_info.info_fd = -1;
-       }
-
-       if (s_info.slave_fd > 0) {
-               com_core_packet_server_fini(s_info.slave_fd);
-               s_info.slave_fd = -1;
-       }
-
-       if (s_info.client_fd > 0) {
-               com_core_packet_server_fini(s_info.client_fd);
-               s_info.client_fd = -1;
-       }
-
-       if (s_info.service_fd > 0) {
-               com_core_packet_server_fini(s_info.service_fd);
-               s_info.service_fd = -1;
-       }
-
-       return 0;
-}
-
-/* End of a file */
index b113460..290a843 100644 (file)
 #include <cynara-creds-socket.h>
 
 #include <com-core.h>
-#if defined(HAVE_LIVEBOX)
-#include <widget_errno.h>
-#else
-#include <lite-errno.h>
-#endif
 
 #include "service_common.h"
 #include "util.h"
@@ -417,7 +412,7 @@ HAPI int service_register_tcb_callback(struct service_context *svc_ctx, struct t
        cbdata = malloc(sizeof(*cbdata));
        if (!cbdata) {
                ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
+               return SERVICE_COMMON_ERROR_OUT_OF_MEMORY;
        }
 
        cbdata->tcb = tcb;
@@ -436,10 +431,10 @@ HAPI int service_register_tcb_callback(struct service_context *svc_ctx, struct t
                break;
        default:
                DbgFree(cbdata);
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 /*!
@@ -457,7 +452,7 @@ HAPI int service_unregister_tcb_callback(struct service_context *svc_ctx, struct
                        if (cbdata->tcb == tcb && cbdata->cb == cb && cbdata->data == data) {
                                svc_ctx->tcb_create_cb_list = eina_list_remove(svc_ctx->tcb_create_cb_list, cbdata);
                                DbgFree(cbdata);
-                               return WIDGET_ERROR_NONE;
+                               return SERVICE_COMMON_ERROR_NONE;
                        }
                }
                break;
@@ -466,15 +461,15 @@ HAPI int service_unregister_tcb_callback(struct service_context *svc_ctx, struct
                        if (cbdata->tcb == tcb && cbdata->cb == cb && cbdata->data == data) {
                                svc_ctx->tcb_destroy_cb_list = eina_list_remove(svc_ctx->tcb_destroy_cb_list, cbdata);
                                DbgFree(cbdata);
-                               return WIDGET_ERROR_NONE;
+                               return SERVICE_COMMON_ERROR_NONE;
                        }
                }
                break;
        default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
-       return WIDGET_ERROR_NOT_EXIST;
+       return SERVICE_COMMON_ERROR_NOT_EXIST;
 }
 
 /*!
@@ -575,7 +570,7 @@ static inline void tcb_teminate_all(struct service_context *svc_ctx)
 HAPI int service_common_destroy_tcb(struct service_context *svc_ctx, struct tcb *tcb)
 {
        if (!svc_ctx || !tcb) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
        /**
         * @note
@@ -585,7 +580,7 @@ HAPI int service_common_destroy_tcb(struct service_context *svc_ctx, struct tcb
                ErrPrint("write: %d\n", errno);
        }
 
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 /*!
diff --git a/src/setting.c b/src/setting.c
deleted file mode 100644 (file)
index 9e78193..0000000
+++ /dev/null
@@ -1,333 +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 <malloc.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <locale.h>
-
-#include <vconf.h>
-#include <dlog.h>
-
-#include <Ecore.h>
-#include <Eina.h>
-
-#include "setting.h"
-#include "util.h"
-#include "debug.h"
-#include "conf.h"
-#include "critical_log.h"
-
-#if defined(HAVE_LIVEBOX)
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_conf.h>
-#include "client_life.h"
-#include "slave_life.h"
-#include "xmonitor.h"
-#include "package.h"
-#include "instance.h"
-#else
-#define xmonitor_handle_state_changes()
-#endif
-
-int errno;
-
-struct event_cbdata {
-       int (*handler)(enum oom_event_type type, void *data);
-       void *data;
-       int deleted;
-};
-
-static struct {
-       int deactivated;
-       Eina_List *oom_event_list;
-       int oom_event_in_process;
-} s_info = {
-       .deactivated = 0,
-       .oom_event_list = NULL,
-       .oom_event_in_process = 0,
-};
-
-static void lcd_state_cb(keynode_t *node, void *user_data)
-{
-       if (!node) {
-               return;
-       }
-
-       xmonitor_handle_state_changes();
-}
-
-HAPI int setting_is_lcd_off(void)
-{
-       int state;
-
-       if (!WIDGET_CONF_CHECK_LCD) {
-               /* Always turned on */
-               return 0;
-       }
-
-       if (vconf_get_int(VCONFKEY_PM_STATE, &state) != 0) {
-               ErrPrint("Idle lock state is not valid\n");
-               state = VCONFKEY_PM_STATE_NORMAL; /* UNLOCK */
-       }
-
-       ErrPrint("State: %d, (%d:lcdoff, %d:sleep)\n", state, VCONFKEY_PM_STATE_LCDOFF, VCONFKEY_PM_STATE_SLEEP);
-       return state == VCONFKEY_PM_STATE_LCDOFF || state == VCONFKEY_PM_STATE_SLEEP;
-}
-
-static void power_off_cb(keynode_t *node, void *user_data)
-{
-       int val;
-       CRITICAL_LOG("Terminated(vconf)\n");
-
-       if (vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &val) != 0) {
-               ErrPrint("Failed to get power off status (%d)\n", val);
-               return;
-       }
-
-       if (val == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || val == VCONFKEY_SYSMAN_POWER_OFF_RESTART) {
-               DbgPrint("Power off requested: Ignored\n");
-       } else {
-               ErrPrint("Unknown power state: %d\n", val);
-       }
-}
-
-static void region_changed_cb(keynode_t *node, void *user_data)
-{
-       char *region;
-       char *r;
-
-       region = vconf_get_str(VCONFKEY_REGIONFORMAT);
-       if (!region) {
-               return;
-       }
-
-       setenv("LC_CTYPE", region, 1);
-       setenv("LC_NUMERIC", region, 1);
-       setenv("LC_TIME", region, 1);
-       setenv("LC_COLLATE", region, 1);
-       setenv("LC_MONETARY", region, 1);
-       setenv("LC_PAPER", region, 1);
-       setenv("LC_NAME", region, 1);
-       setenv("LC_ADDRESS", region, 1);
-       setenv("LC_TELEPHONE", region, 1);
-       setenv("LC_MEASUREMENT", region, 1);
-       setenv("LC_IDENTIFICATION", region, 1);
-
-       r = setlocale(LC_ALL, "");
-       if (r == NULL) {
-               ErrPrint("Failed to change region\n");
-       }
-
-       DbgFree(region);
-}
-
-static void lang_changed_cb(keynode_t *node, void *user_data)
-{
-       char *lang;
-       char *r;
-
-       lang = vconf_get_str(VCONFKEY_LANGSET);
-       if (!lang) {
-               return;
-       }
-
-       setenv("LANG", lang, 1);
-       setenv("LC_MESSAGES", lang, 1);
-
-       r = setlocale(LC_ALL, "");
-       if (!r) {
-               ErrPrint("Failed to change locale\n");
-       }
-
-       DbgPrint("Locale: %s\n", setlocale(LC_ALL, NULL));
-       DbgFree(lang);
-}
-
-static void low_mem_cb(keynode_t *node, void *user_data)
-{
-       int val;
-       Eina_List *l;
-       Eina_List *n;
-       struct event_cbdata *item;
-
-       val = vconf_keynode_get_int(node);
-
-       if (val >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING)     {
-               CRITICAL_LOG("Low memory: level %d\n", val);
-               if (s_info.deactivated == 0) {
-                       s_info.deactivated = 1;
-
-                       s_info.oom_event_in_process = 1;
-                       EINA_LIST_FOREACH_SAFE(s_info.oom_event_list, l, n, item) {
-                               if (item->deleted || item->handler(OOM_TYPE_LOW, item->data) < 0 || item->deleted) {
-                                       s_info.oom_event_list = eina_list_remove(s_info.oom_event_list, item);
-                                       free(item);
-                               }
-                       }
-                       s_info.oom_event_in_process = 0;
-
-                       //slave_deactivate_all(0, 1, 0);
-                       malloc_trim(0);
-                       ErrPrint("Fall into the low mem status\n");
-               }
-       } else {
-               CRITICAL_LOG("Normal memory: level %d\n", val);
-               if (s_info.deactivated == 1) {
-                       s_info.deactivated = 0;
-
-                       s_info.oom_event_in_process = 1;
-                       EINA_LIST_FOREACH_SAFE(s_info.oom_event_list, l, n, item) {
-                               if (item->deleted || item->handler(OOM_TYPE_NORMAL, item->data) < 0 || item->deleted) {
-                                       s_info.oom_event_list = eina_list_remove(s_info.oom_event_list, item);
-                                       free(item);
-                               }
-                       }
-                       s_info.oom_event_in_process = 0;
-
-                       //slave_activate_all();
-                       ErrPrint("Recover from the low mem status\n");
-               }
-       }
-}
-
-HAPI int setting_add_oom_event_callback(int (*handler)(enum oom_event_type type, void *data), void *data)
-{
-       struct event_cbdata *item;
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->handler = handler;
-       item->data = data;
-       item->deleted = 0;
-
-       s_info.oom_event_list = eina_list_append(s_info.oom_event_list, item);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int setting_del_oom_event_callback(int (*handler)(enum oom_event_type type, void *data), void *data)
-{
-       struct event_cbdata *item;
-       Eina_List *l;
-       Eina_List *n;
-
-       EINA_LIST_FOREACH_SAFE(s_info.oom_event_list, l, n, item) {
-               if (handler == item->handler && item->data == data) {
-                       if (s_info.oom_event_in_process) {
-                               item->deleted = 1;
-                       } else {
-                               s_info.oom_event_list = eina_list_remove(s_info.oom_event_list, item);
-                               free(item);
-                       }
-                       return WIDGET_ERROR_NONE;
-               }
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-HAPI enum oom_event_type setting_oom_level(void)
-{
-       int ret;
-       int status;
-
-       ret = vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &status);
-       if (ret == 0 && status >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING) {
-               return OOM_TYPE_LOW;
-       }
-
-       return OOM_TYPE_NORMAL;
-}
-
-HAPI int setting_init(void)
-{
-       int ret;
-
-       ret = vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_cb, NULL);
-       if (ret < 0) {
-               ErrPrint("Failed to add vconf for lock state: %d\n", ret);
-       }
-
-       ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, power_off_cb, NULL);
-       if (ret < 0) {
-               ErrPrint("Failed to add vconf for power state: %d \n", ret);
-       }
-
-       ret = vconf_notify_key_changed(VCONFKEY_LANGSET, lang_changed_cb, NULL);
-       if (ret < 0) {
-               ErrPrint("Failed to add vconf for lang change: %d\n", ret);
-       }
-
-       ret = vconf_notify_key_changed(VCONFKEY_REGIONFORMAT, region_changed_cb, NULL);
-       if (ret < 0) {
-               ErrPrint("Failed to add vconf for region change: %d\n", ret);
-       }
-
-       ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, low_mem_cb, NULL);
-       if (ret < 0) {
-               ErrPrint("Failed to add vconf for low mem monitor: %d\n", ret);
-       }
-
-       lang_changed_cb(NULL, NULL);
-       region_changed_cb(NULL, NULL);
-       return ret;
-}
-
-HAPI int setting_fini(void)
-{
-       int ret;
-
-       ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, low_mem_cb);
-       if (ret < 0) {
-               ErrPrint("Failed to ignore vconf key (%d)\n", ret);
-       }
-
-       ret = vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, region_changed_cb);
-       if (ret < 0) {
-               ErrPrint("Failed to ignore vconf key (%d)\n", ret);
-       }
-
-       ret = vconf_ignore_key_changed(VCONFKEY_LANGSET, lang_changed_cb);
-       if (ret < 0) {
-               ErrPrint("Failed to ignore vconf key (%d)\n", ret);
-       }
-
-       ret = vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_cb);
-       if (ret < 0) {
-               ErrPrint("Failed to ignore vconf key (%d)\n", ret);
-       }
-
-       ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, power_off_cb);
-       if (ret < 0) {
-               ErrPrint("Failed to ignore vconf key (%d)\n", ret);
-       }
-
-       return ret;
-}
-
-/* End of a file */
diff --git a/src/shared_fd_service.c b/src/shared_fd_service.c
deleted file mode 100644 (file)
index d153882..0000000
+++ /dev/null
@@ -1,158 +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 <pthread.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <Eina.h>
-
-#include <dlog.h>
-
-#include <widget_errno.h>
-#include <widget_cmd_list.h>
-#include <widget_service.h>
-#include <packet.h>
-#include <com-core_packet.h>
-
-#include "shared_fd_service.h"
-#include "service_common.h"
-#include "client_life.h"
-#include "client_rpc.h"
-#include "debug.h"
-#include "util.h"
-#include "conf.h"
-
-static struct info {
-       int fd;
-} s_info = {
-       .fd = -1,
-};
-
-static struct packet *direct_hello_handler(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *direct_addr;
-       struct client_node *client;
-
-       if (!packet) {
-               ErrPrint("%d is disconnected (%d)\n", pid, handle);
-               return NULL;
-       }
-
-       if (packet_get(packet, "s", &direct_addr) != 1) {
-               ErrPrint("Packet is not valid\n");
-               return NULL;
-       }
-
-       client = client_find_by_direct_addr(direct_addr);
-       if (!client) {
-               ErrPrint("Client is not exists: %s\n", direct_addr);
-               return NULL;
-       }
-
-       DbgPrint("Client Direct Handler is updated: %d\n", handle);
-       client_set_direct_fd(client, handle);
-       return NULL;
-}
-
-static struct packet *direct_connected_handler(pid_t pid, int handle, const struct packet *packet)
-{
-       struct packet *result;
-       const char *direct_addr;
-       struct client_node *client;
-
-       if (!packet) {
-               ErrPrint("%d is disconnected (%d)\n", pid, handle);
-               return NULL;
-       }
-
-       if (packet_get(packet, "s", &direct_addr) != 1) {
-               ErrPrint("Packet is not valid\n");
-               result = packet_create_reply(packet, "i", WIDGET_ERROR_INVALID_PARAMETER);
-               return result;
-       }
-
-       client = client_find_by_direct_addr(direct_addr);
-       if (!client) {
-               ErrPrint("Client is not exists: %s\n", direct_addr);
-               result = packet_create_reply(packet, "i", WIDGET_ERROR_NOT_EXIST);
-               return result;
-       }
-
-       result = packet_create_reply(packet, "i", WIDGET_ERROR_NONE);
-       packet_set_fd(result, client_direct_fd(client));
-       DbgPrint("Set FD Handle for (%s): %d\n", direct_addr, client_direct_fd(client));
-       return result;
-}
-
-static struct method s_table[] = {
-       {
-               .cmd = CMD_STR_DIRECT_HELLO,
-               .handler = direct_hello_handler,
-       },
-       {
-               .cmd = CMD_STR_DIRECT_CONNECTED,
-               .handler = direct_connected_handler,
-       },
-       {
-               .cmd = NULL,
-               .handler = NULL,
-       },
-};
-
-/**
- * @note
- * MAIN THREAD
- */
-HAPI int shared_fd_service_init(void)
-{
-       DbgPrint("Successfully initiated\n");
-       /**
-        * @todo
-        * 1. Accept FD (Get a new connection handle)
-        * 2. Waiting "hello" message from viewer.
-        * 3. Waiting "connected" message from provider
-        * 4. Send accepted FD to provider via result packet.
-        * 5. Provider will send a packet to the viewer via that FD.
-        */
-       s_info.fd = com_core_packet_server_init("sdlocal://"SHARED_SOCKET, s_table);
-       if (s_info.fd < 0) {
-               ErrPrint("Failed to make a server for %s\n", "sdlocal://"SHARED_SOCKET);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-/**
- * @note
- * MAIN THREAD
- */
-HAPI int shared_fd_service_fini(void)
-{
-       if (s_info.fd >= 0) {
-               com_core_packet_server_fini(s_info.fd);
-               s_info.fd = -1;
-       }
-
-       DbgPrint("Successfully Finalized\n");
-       return WIDGET_ERROR_NONE;
-}
-
-/* End of a file */
index 43ada70..9dd0e65 100644 (file)
 #include <Eina.h>
 
 #include <dlog.h>
-#if defined(HAVE_LIVEBOX)
-#include <widget_errno.h>
-#else
-#include "lite-errno.h"
-#endif
 #include <packet.h>
 
 #include <Eina.h>
@@ -213,29 +208,29 @@ HAPI int shortcut_service_init(void)
 {
        if (s_info.svc_ctx) {
                ErrPrint("Already initialized\n");
-               return WIDGET_ERROR_ALREADY_STARTED;
+               return SERVICE_COMMON_ERROR_ALREADY_STARTED;
        }
 
        s_info.svc_ctx = service_common_create(SHORTCUT_SOCKET, SHORTCUT_SMACK_LABEL, service_thread_main, NULL);
        if (!s_info.svc_ctx) {
                ErrPrint("Unable to activate service thread\n");
-               return WIDGET_ERROR_FAULT;
+               return SERVICE_COMMON_ERROR_FAULT;
        }
 
        DbgPrint("Successfully initiated\n");
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 HAPI int shortcut_service_fini(void)
 {
        if (!s_info.svc_ctx) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
+               return SERVICE_COMMON_ERROR_INVALID_PARAMETER;
        }
 
        service_common_destroy(s_info.svc_ctx);
        s_info.svc_ctx = NULL;
        DbgPrint("Successfully Finalized\n");
-       return WIDGET_ERROR_NONE;
+       return SERVICE_COMMON_ERROR_NONE;
 }
 
 /* End of a file */
diff --git a/src/slave_life.c b/src/slave_life.c
deleted file mode 100644 (file)
index d5b24a8..0000000
+++ /dev/null
@@ -1,2258 +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 <string.h> /* strerror */
-#include <errno.h> /* errno */
-#include <unistd.h> /* pid_t */
-#include <stdlib.h> /* free */
-#include <pthread.h>
-#include <malloc.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-#include <Eina.h>
-#include <Ecore.h>
-
-#include <aul.h> /* aul_launch_app */
-#include <dlog.h>
-#include <bundle.h>
-#include <app_manager.h>
-
-#include <packet.h>
-#include <widget_errno.h>
-#include <widget_conf.h>
-#include <widget_abi.h>
-#include <widget_util.h>
-#include <widget_cmd_list.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-
-#include "critical_log.h"
-#include "slave_life.h"
-#include "slave_rpc.h"
-#include "client_life.h"
-#include "fault_manager.h"
-#include "debug.h"
-#include "conf.h"
-#include "setting.h"
-#include "util.h"
-#include "xmonitor.h"
-
-#include "package.h"
-#include "instance.h"
-
-#define BUNDLE_SLAVE_SVC_OP_TYPE "__APP_SVC_OP_TYPE__"
-#define APP_CONTROL_OPERATION_MAIN "http://tizen.org/appcontrol/operation/main"
-#define LOW_PRIORITY   10
-#define SDK_SLAVE_ACTIVATE_TIME 5.0f
-
-#define aul_terminate_pid_async(a) aul_terminate_pid(a)
-
-int errno;
-
-struct slave_node {
-       char *name;
-       char *abi;
-       char *pkgname;
-       int refcnt;
-       int fault_count;
-       int critical_fault_count;
-       enum slave_state state;
-
-       int loaded_instance;
-       int loaded_package;
-
-       union _slave_flags {
-               struct _slave_fields {
-                       unsigned int reactivate_instances: 1;
-                       unsigned int reactivate_slave: 1;
-                       unsigned int secured: 1;        /* Only A package(widget) is loaded for security requirements */
-                       unsigned int network: 1;
-                       unsigned int auto_align: 1;
-                       unsigned int valid: 1;
-                       unsigned int is_watch: 1;       /*!< Specialized field. Only for the WATCH */
-                       unsigned int wait_deactivation: 1;
-
-                       unsigned int reserved: 24;
-               } field;
-               unsigned int mask;
-       } flags;
-
-       pid_t pid;
-
-       enum event_process {
-               SLAVE_EVENT_PROCESS_IDLE = 0x00,
-               SLAVE_EVENT_PROCESS_ACTIVATE = 0x01,
-               SLAVE_EVENT_PROCESS_DEACTIVATE = 0x02,
-               SLAVE_EVENT_PROCESS_DELETE = 0x04,
-               SLAVE_EVENT_PROCESS_FAULT = 0x08,
-               SLAVE_EVENT_PROCESS_PAUSE = 0x10,
-               SLAVE_EVENT_PROCESS_RESUME = 0x20
-       } in_event_process;
-       Eina_List *event_activate_list;
-       Eina_List *event_deactivate_list;
-       Eina_List *event_delete_list;
-       Eina_List *event_fault_list;
-       Eina_List *event_pause_list;
-       Eina_List *event_resume_list;
-
-       Eina_List *data_list;
-
-       Ecore_Timer *ttl_timer; /*!< Time to live */
-       Ecore_Timer *activate_timer; /*!< Waiting hello packet for this time */
-       Ecore_Timer *relaunch_timer; /*!< Try to relaunch service app */
-       Ecore_Timer *terminate_timer; /*!< Waiting this timer before terminate the service provider */
-       int relaunch_count;
-
-       int ctrl_option;
-
-#if defined(_USE_ECORE_TIME_GET)
-       double activated_at;
-#else
-       struct timeval activated_at;
-#endif
-
-       char *hw_acceleration;
-       char *extra_bundle_data;
-
-       struct _resource {
-               struct _memory {
-                       unsigned int soft;
-                       unsigned int hard;
-               } memory;
-       } resources;
-};
-
-struct event {
-       struct slave_node *slave;
-
-       int (*evt_cb)(struct slave_node *, void *);
-       void *cbdata;
-       int deleted;
-};
-
-struct priv_data {
-       char *tag;
-       void *data;
-};
-
-static struct {
-       Eina_List *slave_list;
-       int deactivate_all_refcnt;
-} s_info = {
-       .slave_list = NULL,
-       .deactivate_all_refcnt = 0,
-};
-
-static inline int apply_resource_limit(struct slave_node *slave)
-{
-       struct rlimit limit;
-       struct rlimit old_limit;
-
-       if (slave_pid(slave) <= 0 || (slave->resources.memory.soft == 0 && slave->resources.memory.hard == 0)) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       limit.rlim_cur = slave->resources.memory.soft;
-       limit.rlim_max = slave->resources.memory.hard;
-
-       if (prlimit(slave->pid, RLIMIT_AS, &limit, &old_limit) < 0) {
-               ErrPrint("prlimit: %d\n", errno);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       DbgPrint("Old: %lu - %lu / %lu - %lu\n", limit.rlim_cur, limit.rlim_max, old_limit.rlim_cur, old_limit.rlim_max);
-
-       return WIDGET_ERROR_NONE;
-}
-
-static Eina_Bool terminate_timer_cb(void *data)
-{
-       struct slave_node *slave = data;
-       int ret;
-
-       /**
-        * @todo
-        * Check the return value of the aul_terminate_pid
-        */
-       slave->state = SLAVE_REQUEST_TO_TERMINATE;
-       slave->terminate_timer = NULL;
-
-       DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
-       ret = aul_terminate_pid_async(slave->pid);
-       if (ret < 0) {
-               ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
-               slave = slave_deactivated(slave);
-               if (slave == NULL) {
-                       DbgPrint("Slave is deleted\n");
-               }
-       }
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static struct slave_node *slave_deactivate(struct slave_node *slave, int no_timer)
-{
-       int ret;
-
-       /**
-        * @note
-        * The caller must has to check the slave's state.
-        * If it is not activated, this function must has not to be called.
-        */
-
-       if (slave_pid(slave) <= 0) {
-               return slave;
-       }
-
-       if (slave->ttl_timer) {
-               /**
-                * @note
-                * If there is an activated TTL timer,
-                * It has to be cleared before deactivate the slave.
-                */
-               ecore_timer_del(slave->ttl_timer);
-               slave->ttl_timer = NULL;
-       }
-
-       if ((slave->ctrl_option & PROVIDER_CTRL_MANUAL_TERMINATION) == PROVIDER_CTRL_MANUAL_TERMINATION) {
-               /*!
-                * \note
-                * In this case,
-                * The provider requests MANUAL TERMINATION control option.
-                * Master will not send terminate request in this case, the provider should be terminated by itself.
-                */
-               DbgPrint("Manual termination is turned on\n");
-               slave->state = SLAVE_REQUEST_TO_DISCONNECT;
-               (void)slave_rpc_disconnect(slave);
-       } else if (slave->terminate_timer) {
-               ErrPrint("Terminate timer is already fired (%d)\n", slave->pid);
-       } else if (!slave->extra_bundle_data && ((!no_timer && !slave->flags.field.secured) || slave_is_app(slave)) && (!slave_is_watch(slave) && WIDGET_CONF_SLAVE_TERMINATE_TIME > 0.0f)) {
-               DbgPrint("Fire the terminate timer: %d (%d)\n", slave->pid, slave_is_app(slave));
-               slave->terminate_timer = ecore_timer_add(WIDGET_CONF_SLAVE_TERMINATE_TIME, terminate_timer_cb, slave);
-               if (!slave->terminate_timer) {
-                       /*!
-                        * \note
-                        * Normally, Call the terminate_timer_cb directly from here
-                        * But in this case. if the aul_terminate_pid failed, Call the slave_deactivated function directly.
-                        * Then the "slave" pointer can be changed. To trace it, Copy the body of terminate_timer_cb to here.
-                        */
-                       ErrPrint("Failed to add a new timer for terminating\n");
-                       DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
-                       /*!
-                        * \todo
-                        * check the return value of the aul_terminate_pid
-                        */
-                       slave->state = SLAVE_REQUEST_TO_TERMINATE;
-
-                       ret = aul_terminate_pid_async(slave->pid);
-                       if (ret < 0) {
-                               ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
-                               slave = slave_deactivated(slave);
-                       }
-               }
-       } else {
-               /**
-                * @todo
-                * check the return value of the aul_terminate_pid
-                *
-                * @note
-                * In case of the watch,
-                * There is no waiting timer for termination.
-                * Because the watch application cannot be re-used for new instance.
-                */
-               slave->state = SLAVE_REQUEST_TO_TERMINATE;
-
-               DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
-               ret = aul_terminate_pid_async(slave->pid);
-               if (ret < 0) {
-                       ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
-                       slave = slave_deactivated(slave);
-               }
-       }
-
-       return slave;
-}
-
-static Eina_Bool slave_ttl_cb(void *data)
-{
-       struct slave_node *slave = (struct slave_node *)data;
-
-       if (slave_state(slave) != SLAVE_REQUEST_TO_PAUSE && slave_state(slave) != SLAVE_PAUSED) {
-               Eina_List *l;
-               Eina_List *pkg_list;
-               struct pkg_info *info;
-
-               /**
-                * @note
-                * If the slave is not paused,
-                * Should check all instances in this slave.
-                */
-               pkg_list = (Eina_List *)package_list();
-               EINA_LIST_FOREACH(pkg_list, l, info) {
-                       if (package_slave(info) == slave) {
-                               struct inst_info *inst;
-                               Eina_List *inst_list;
-                               Eina_List *n;
-
-                               inst_list = (Eina_List *)package_instance_list(info);
-                               EINA_LIST_FOREACH(inst_list, n, inst) {
-                                       if (instance_visible_state(inst) == WIDGET_SHOW) {
-                                               DbgPrint("Instance is in show, give more ttl to %d for %s\n", slave_pid(slave), instance_id(inst));
-                                               return ECORE_CALLBACK_RENEW;
-                                       }
-                               }
-                       }
-               } // EINA_LIST_FOREACH
-       } else {
-               DbgPrint("Slave is paused, Terminate it now\n");
-       }
-
-       /**
-        * @note
-        * ttl_timer must has to be set to NULL before deactivate the slave
-        * It will be used for making decision of the expired TTL timer or the fault of a widget.
-        */
-       slave->ttl_timer = NULL;
-
-       if (slave_is_activated(slave)) {
-               slave_set_reactivation(slave, 0);
-               slave_set_reactivate_instances(slave, 1);
-
-               slave = slave_deactivate(slave, 1);
-               if (!slave) {
-                       DbgPrint("Slave is deleted\n");
-               }
-       }
-
-       /*! To recover all instances state it is activated again */
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static inline int xmonitor_pause_cb(void *data)
-{
-       slave_pause(data);
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int xmonitor_resume_cb(void *data)
-{
-       slave_resume(data);
-       return WIDGET_ERROR_NONE;
-}
-
-static inline struct slave_node *create_slave_node(const char *name, int is_secured, const char *abi, const char *pkgname, int network, const char *hw_acceleration)
-{
-       struct slave_node *slave;
-
-       slave = calloc(1, sizeof(*slave));
-       if (!slave) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       slave->name = strdup(name);
-       if (!slave->name) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(slave);
-               return NULL;
-       }
-
-       slave->abi = strdup(abi);
-       if (!slave->abi) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(slave->name);
-               DbgFree(slave);
-               return NULL;
-       }
-
-       slave->pkgname = strdup(pkgname);
-       if (!slave->pkgname) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(slave->abi);
-               DbgFree(slave->name);
-               DbgFree(slave);
-               return NULL;
-       }
-
-       if (hw_acceleration) {
-               slave->hw_acceleration = strdup(hw_acceleration);
-               if (!slave->hw_acceleration) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(slave->pkgname);
-                       DbgFree(slave->abi);
-                       DbgFree(slave->name);
-                       DbgFree(slave);
-                       return NULL;
-               }
-       }
-
-       slave->flags.field.secured = is_secured;
-       slave->pid = (pid_t)-1;
-       slave->state = SLAVE_TERMINATED;
-       slave->flags.field.network = network;
-       slave->relaunch_count = WIDGET_CONF_SLAVE_RELAUNCH_COUNT;
-
-       xmonitor_add_event_callback(XMONITOR_PAUSED, xmonitor_pause_cb, slave);
-       xmonitor_add_event_callback(XMONITOR_RESUMED, xmonitor_resume_cb, slave);
-
-       s_info.slave_list = eina_list_append(s_info.slave_list, slave);
-       return slave;
-}
-
-static inline void invoke_delete_cb(struct slave_node *slave)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct event *event;
-
-       slave->in_event_process |= SLAVE_EVENT_PROCESS_DELETE;
-       EINA_LIST_FOREACH_SAFE(slave->event_delete_list, l, n, event) {
-               if (event->deleted || event->evt_cb(event->slave, event->cbdata) < 0 || event->deleted) {
-                       slave->event_delete_list = eina_list_remove(slave->event_delete_list, event);
-                       DbgFree(event);
-               }
-       }
-       slave->in_event_process &= ~SLAVE_EVENT_PROCESS_DELETE;
-}
-
-static inline void destroy_slave_node(struct slave_node *slave)
-{
-       struct event *event;
-       struct priv_data *priv;
-
-       if (slave_pid(slave) != (pid_t)-1) {
-               ErrPrint("Slave is not deactivated\n");
-               return;
-       }
-
-       xmonitor_del_event_callback(XMONITOR_PAUSED, xmonitor_pause_cb, slave);
-       xmonitor_del_event_callback(XMONITOR_RESUMED, xmonitor_resume_cb, slave);
-
-       invoke_delete_cb(slave);
-       slave_rpc_fini(slave); /*!< Finalize the RPC after handling all delete callbacks */
-
-       EINA_LIST_FREE(slave->event_delete_list, event) {
-               DbgFree(event);
-       }
-
-       EINA_LIST_FREE(slave->event_activate_list, event) {
-               DbgFree(event);
-       }
-
-       EINA_LIST_FREE(slave->event_deactivate_list, event) {
-               DbgFree(event);
-       }
-
-       EINA_LIST_FREE(slave->event_fault_list, event) {
-               DbgFree(event);
-       }
-
-       EINA_LIST_FREE(slave->data_list, priv) {
-               DbgFree(priv->tag);
-               DbgFree(priv);
-       }
-
-       s_info.slave_list = eina_list_remove(s_info.slave_list, slave);
-
-       if (slave->ttl_timer) {
-               ecore_timer_del(slave->ttl_timer);
-       }
-
-       if (slave->activate_timer) {
-               ecore_timer_del(slave->activate_timer);
-       }
-
-       if (slave->relaunch_timer) {
-               ecore_timer_del(slave->relaunch_timer);
-       }
-
-       DbgFree(slave->abi);
-       DbgFree(slave->name);
-       DbgFree(slave->pkgname);
-       DbgFree(slave->hw_acceleration);
-       DbgFree(slave->extra_bundle_data);
-       DbgFree(slave);
-       return;
-}
-
-static inline struct slave_node *find_slave(const char *name)
-{
-       struct slave_node *slave;
-       Eina_List *l;
-
-       EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (!strcmp(slave->name, name)) {
-                       return slave;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI int slave_expired_ttl(struct slave_node *slave)
-{
-       if (!slave) {
-               return 0;
-       }
-
-       if (!slave_is_app(slave)
-               && !slave->flags.field.secured
-               && !(WIDGET_IS_INHOUSE(slave_abi(slave)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL))
-       {
-               return 0;
-       }
-
-       return !!slave->ttl_timer;
-}
-
-HAPI struct slave_node *slave_ref(struct slave_node *slave)
-{
-       if (!slave) {
-               return NULL;
-       }
-
-       slave->refcnt++;
-       return slave;
-}
-
-HAPI struct slave_node *slave_unref(struct slave_node *slave)
-{
-       if (!slave) {
-               return NULL;
-       }
-
-       if (slave->refcnt == 0) {
-               ErrPrint("Slave refcnt is not valid\n");
-               return NULL;
-       }
-
-       slave->refcnt--;
-       if (slave->refcnt == 0) {
-               destroy_slave_node(slave);
-               slave = NULL;
-       }
-
-       return slave;
-}
-
-HAPI const int const slave_refcnt(struct slave_node *slave)
-{
-       return slave->refcnt;
-}
-
-HAPI struct slave_node *slave_create(const char *name, int is_secured, const char *abi, const char *pkgname, int network, const char *hw_acceleration)
-{
-       struct slave_node *slave;
-
-       slave = find_slave(name);
-       if (slave) {
-               if (slave->flags.field.secured != is_secured) {
-                       ErrPrint("Exists slave and creating slave's security flag is not matched\n");
-               }
-               return slave;
-       }
-
-       if (!pkgname) {
-               ErrPrint("Slave pkgname is not valid[%s]\n", pkgname);
-               return NULL;
-       }
-
-       slave = create_slave_node(name, is_secured, abi, pkgname, network, hw_acceleration);
-       if (!slave) {
-               return NULL;
-       }
-
-       slave_ref(slave);
-       slave_rpc_init(slave);
-
-       return slave;
-}
-
-/*!
- * \note
- * Before destroying slave object,
- * you should check the RPC(slave_async_XXX) state and Private data field (slave_set_data)
- */
-HAPI void slave_destroy(struct slave_node *slave)
-{
-       slave_unref(slave);
-}
-
-static inline struct slave_node *invoke_fault_cb(struct slave_node *slave)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct event *event;
-
-       slave_ref(slave);
-       slave->in_event_process |= SLAVE_EVENT_PROCESS_FAULT;
-       EINA_LIST_FOREACH_SAFE(slave->event_fault_list, l, n, event) {
-               if (event->deleted || event->evt_cb(event->slave, event->cbdata) < 0 || event->deleted) {
-                       slave->event_fault_list = eina_list_remove(slave->event_fault_list, event);
-                       DbgFree(event);
-               }
-       }
-       slave->in_event_process &= ~SLAVE_EVENT_PROCESS_FAULT;
-       slave = slave_unref(slave);
-
-       return slave;
-}
-
-static inline void invoke_activate_cb(struct slave_node *slave)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct event *event;
-
-       slave->in_event_process |= SLAVE_EVENT_PROCESS_ACTIVATE;
-       EINA_LIST_FOREACH_SAFE(slave->event_activate_list, l, n, event) {
-               if (event->deleted || event->evt_cb(event->slave, event->cbdata) < 0 || event->deleted) {
-                       slave->event_activate_list = eina_list_remove(slave->event_activate_list, event);
-                       DbgFree(event);
-               }
-       }
-       slave->in_event_process &= ~SLAVE_EVENT_PROCESS_ACTIVATE;
-}
-
-static Eina_Bool activate_timer_cb(void *data)
-{
-       struct slave_node *slave = data;
-
-       if (slave->relaunch_timer) {
-               ecore_timer_del(slave->relaunch_timer);
-               slave->relaunch_timer = NULL;
-       }
-       slave->activate_timer = NULL;
-
-       slave->fault_count++;
-
-       if (invoke_fault_cb(slave) == NULL) {
-               ErrPrint("Slave is deleted while processing fault handler\n");
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       slave_set_reactivation(slave, 0);
-       slave_set_reactivate_instances(slave, 0);
-
-       if (slave_pid(slave) > 0) {
-               int ret;
-               DbgPrint("Try to terminate PID: %d\n", slave_pid(slave));
-               ret = aul_terminate_pid_async(slave_pid(slave));
-               if (ret < 0) {
-                       ErrPrint("Terminate failed, pid %d (reason: %d)\n", slave_pid(slave), ret);
-               }
-       }
-
-       CRITICAL_LOG("Slave is not activated in %lf sec (slave: %s)\n", WIDGET_CONF_SLAVE_ACTIVATE_TIME, slave_name(slave));
-       slave = slave_deactivated(slave);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool sdk_activate_timer_cb(void *data)
-{
-       struct slave_node *slave = data;
-       bool running = false;
-       int ret;
-
-       ret = app_manager_is_running(slave_pkgname(slave), &running);
-       if (ret != APP_MANAGER_ERROR_NONE) {
-               ErrPrint("Failed to get app context: %s (%d)\n", slave_pkgname(slave), ret);
-       }
-
-       if (running == true) {
-               DbgPrint("Maybe still in debug mode: %s\n", slave_pkgname(slave));
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       return activate_timer_cb(slave);
-}
-
-/**
- * @note
- * This callback is called only if the slave is not launched (or it doesn't send hello message to master)
- * If the slave is launched so it has valid PID, however it doesn't send hello message in time (activate time in conf file).
- */
-static inline void invoke_slave_fault_handler(struct slave_node *slave)
-{
-       slave->fault_count++;
-       if (invoke_fault_cb(slave) == NULL) {
-               ErrPrint("Slave is deleted while processing fault handler\n");
-               return;
-       }
-
-       slave_set_reactivation(slave, 0);
-       slave_set_reactivate_instances(slave, 0);
-
-       if (slave_pid(slave) > 0) {
-               /**
-                * @note
-                * Slave is launched but there is no connection (hello message).
-                */
-               if ((slave->ctrl_option & PROVIDER_CTRL_MANUAL_TERMINATION) == PROVIDER_CTRL_MANUAL_TERMINATION) {
-                       DbgPrint("Manual termination is turned on\n");
-                       (void)slave_rpc_disconnect(slave);
-               } else {
-                       int ret;
-                       DbgPrint("Try to terminate PID: %d\n", slave_pid(slave));
-                       ret = aul_terminate_pid_async(slave_pid(slave));
-                       if (ret < 0) {
-                               ErrPrint("Terminate failed, pid %d (reason: %d)\n", slave_pid(slave), ret);
-                       }
-               }
-       } else {
-               /**
-                * @note
-                * Slave is not launched yet.
-                */
-               DbgPrint("Slave is not launched before (%s)\n", slave_name(slave));
-       }
-
-       if (slave->state != SLAVE_TERMINATED) {
-               slave = slave_deactivated(slave);
-               DbgPrint("Slave deactivated: %p\n", slave);
-       }
-}
-
-static bundle *create_slave_param(struct slave_node *slave)
-{
-       bundle *param = NULL;
-
-       if (slave->extra_bundle_data) {
-               param = bundle_decode((bundle_raw *)slave->extra_bundle_data, strlen(slave->extra_bundle_data));
-               if (!param) {
-                       ErrPrint("Invalid extra_bundle_data[%s]\n", slave->extra_bundle_data);
-               }
-       }
-
-       if (!param) {
-               param = bundle_create();
-       }
-
-       if (param) {
-               if (bundle_add_str(param, BUNDLE_SLAVE_SVC_OP_TYPE, APP_CONTROL_OPERATION_MAIN) == BUNDLE_ERROR_KEY_EXISTS) {
-                       if (bundle_del(param, BUNDLE_SLAVE_SVC_OP_TYPE) == BUNDLE_ERROR_NONE) {
-                               DbgPrint("Main operation is deleted\n");
-                       }
-                       bundle_add_str(param, BUNDLE_SLAVE_SVC_OP_TYPE, APP_CONTROL_OPERATION_MAIN);
-               }
-               bundle_add_str(param, WIDGET_CONF_BUNDLE_SLAVE_NAME, slave_name(slave));
-               bundle_add_str(param, WIDGET_CONF_BUNDLE_SLAVE_SECURED, ((WIDGET_IS_INHOUSE(slave_abi(slave)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL) || slave_is_secured(slave)) ? "true" : "false");
-               bundle_add_str(param, WIDGET_CONF_BUNDLE_SLAVE_ABI, slave_abi(slave));
-               bundle_add_str(param, WIDGET_CONF_BUNDLE_SLAVE_HW_ACCELERATION, slave->hw_acceleration);
-               bundle_add_str(param, WIDGET_CONF_BUNDLE_SLAVE_AUTO_ALIGN, slave->flags.field.auto_align ? "true" : "false");
-       } else {
-               ErrPrint("Failed to create a bundle\n");
-       }
-
-       return param;
-}
-
-static Eina_Bool relaunch_timer_cb(void *data)
-{
-       struct slave_node *slave = data;
-       int ret = ECORE_CALLBACK_CANCEL;
-
-       if (!slave->activate_timer) {
-               ErrPrint("Activate timer is not valid\n");
-               slave->relaunch_timer = NULL;
-
-               invoke_slave_fault_handler(slave);
-       } else if (!slave->relaunch_count) {
-               ErrPrint("Relaunch count is exhahausted\n");
-               ecore_timer_del(slave->activate_timer);
-               slave->activate_timer = NULL;
-
-               slave->relaunch_timer = NULL;
-               invoke_slave_fault_handler(slave);
-       } else {
-               bundle *param;
-
-               param = create_slave_param(slave);
-               if (!param) {
-                       ErrPrint("Failed to create a bundle\n");
-
-                       ecore_timer_del(slave->activate_timer);
-                       slave->activate_timer = NULL;
-
-                       slave->relaunch_timer = NULL;
-
-                       invoke_slave_fault_handler(slave);
-               } else {
-                       ErrPrint("Launch App [%s]\n", slave_pkgname(slave));
-                       slave->pid = (pid_t)aul_launch_app(slave_pkgname(slave), param);
-                       bundle_free(param);
-
-                       switch (slave->pid) {
-                       case AUL_R_EHIDDENFORGUEST:     /**< App hidden for guest mode */
-                       case AUL_R_ENOLAUNCHPAD:        /**< no launchpad */
-                       case AUL_R_EILLACC:             /**< Illegal Access */
-                       case AUL_R_EINVAL:              /**< Invalid argument */
-                       case AUL_R_ENOINIT:             /**< AUL handler NOT initialized */
-                       case AUL_R_ERROR:               /**< General error */
-                               CRITICAL_LOG("Failed to launch a new slave %s (%d)\n", slave_name(slave), slave->pid);
-                               slave->pid = (pid_t)-1;
-                               ecore_timer_del(slave->activate_timer);
-                               slave->activate_timer = NULL;
-
-                               slave->relaunch_timer = NULL;
-
-                               invoke_slave_fault_handler(slave);
-                               /* Waiting app-launch result */
-                               break;
-                       case AUL_R_ETIMEOUT:            /**< Timeout */
-                       case AUL_R_ECOMM:               /**< Comunication Error */
-                       case AUL_R_ETERMINATING:        /**< application terminating */
-                       case AUL_R_ECANCELED:           /**< Operation canceled */
-                       case AUL_R_EREJECTED:
-                               slave->relaunch_count--;
-
-                               CRITICAL_LOG("Try relaunch again %s (%d), %d\n", slave_name(slave), slave->pid, slave->relaunch_count);
-                               slave->pid = (pid_t)-1;
-                               ret = ECORE_CALLBACK_RENEW;
-                               ecore_timer_reset(slave->activate_timer);
-                               /* Try again after a few secs later */
-                               break;
-                       case AUL_R_LOCAL:               /**< Launch by himself */
-                       case AUL_R_OK:                  /**< General success */
-                       default:
-                               DbgPrint("Slave %s is launched with %d as %s\n", slave_pkgname(slave), slave->pid, slave_name(slave));
-                               slave->relaunch_timer = NULL;
-                               ecore_timer_reset(slave->activate_timer);
-                               break;
-                       }
-               }
-       }
-
-       return ret;
-}
-
-HAPI int slave_activate(struct slave_node *slave)
-{
-       /**
-        * @todo
-        * If a slave is deactivated by OOM killer,
-        * We should not activate it again from here.
-        * Instead of this, it should be reactivated by user event or oom event(normal)
-        */
-
-       /**
-        * @note
-        * This check code can be replaced with the slave->state check code
-        * If the slave data has the PID, it means, it is activated
-        * Even if it is in the termiating sequence, it will have the PID
-        * until it is terminated at last.
-        * So we can use this simple code for checking the slave's last state.
-        * whether it is alive or not.
-        */
-       if (slave_pid(slave) != (pid_t)-1) {
-               if (slave->terminate_timer) {
-                       DbgPrint("Clear terminate timer. to reuse (%d)\n", slave->pid);
-                       ecore_timer_del(slave->terminate_timer);
-                       slave->terminate_timer = NULL;
-               } else if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE || slave_state(slave) == SLAVE_REQUEST_TO_DISCONNECT) {
-                       slave_set_reactivation(slave, 1);
-               }
-               return WIDGET_ERROR_ALREADY_STARTED;
-       } else if (slave_state(slave) == SLAVE_REQUEST_TO_LAUNCH) {
-               DbgPrint("Slave is already launched: but the AUL is timed out\n");
-               return WIDGET_ERROR_ALREADY_STARTED;
-       }
-
-       /**
-        * @note
-        * Slave state can be changed even though it is not activated, By calling the "slave_pause" or "slave_resume"
-        * In that case, this part of codes can be executed.
-        *
-        * We have to check the activate_timer or relaunch_timer.
-        * If one of them or all of them are exist, it means, the slave is not activated yet.
-        * But the activate request is sent.
-        * Then just return from here. with ALREADY_STARTED error code.
-        */
-       if (slave->activate_timer || slave->relaunch_timer) {
-               DbgPrint("Slave State[0x%X] is changed by pause/resume even though it is not activated yet\n", slave_state(slave));
-               return WIDGET_ERROR_ALREADY_STARTED;
-       }
-
-       if (WIDGET_CONF_DEBUG_MODE || g_conf.debug_mode) {
-               DbgPrint("Debug Mode enabled. name[%s] secured[%d] abi[%s]\n", slave_name(slave), slave->flags.field.secured, slave->abi);
-       } else {
-               bundle *param;
-
-               param = create_slave_param(slave);
-               if (!param) {
-                       ErrPrint("Failed to create a bundle\n");
-                       return WIDGET_ERROR_FAULT;
-               }
-
-               slave->relaunch_count = WIDGET_CONF_SLAVE_RELAUNCH_COUNT;
-
-               ErrPrint("Launch App [%s]\n", slave_pkgname(slave));
-               slave->pid = (pid_t)aul_launch_app(slave_pkgname(slave), param);
-
-               bundle_free(param);
-
-               switch (slave->pid) {
-               case AUL_R_EHIDDENFORGUEST:     /**< App hidden for guest mode */
-               case AUL_R_ENOLAUNCHPAD:        /**< no launchpad */
-               case AUL_R_EILLACC:             /**< Illegal Access */
-               case AUL_R_EINVAL:              /**< Invalid argument */
-               case AUL_R_ENOINIT:             /**< AUL handler NOT initialized */
-               case AUL_R_ERROR:               /**< General error */
-                       CRITICAL_LOG("Failed to launch a new slave %s (%d)\n", slave_name(slave), slave->pid);
-                       slave->pid = (pid_t)-1;
-                       /* Waiting app-launch result */
-                       break;
-               case AUL_R_ECOMM:               /**< Comunication Error */
-               case AUL_R_ETERMINATING:        /**< application terminating */
-               case AUL_R_ECANCELED:           /**< Operation canceled */
-               case AUL_R_ETIMEOUT:            /**< Timeout */
-               case AUL_R_EREJECTED:
-                       CRITICAL_LOG("Try relaunch this soon %s (%d)\n", slave_name(slave), slave->pid);
-                       slave->relaunch_timer = ecore_timer_add(WIDGET_CONF_SLAVE_RELAUNCH_TIME, relaunch_timer_cb, slave);
-                       if (!slave->relaunch_timer) {
-                               CRITICAL_LOG("Failed to register a relaunch timer (%s)\n", slave_name(slave));
-                               slave->pid = (pid_t)-1;
-                               return WIDGET_ERROR_FAULT;
-                       }
-                       /* Try again after a few secs later */
-                       break;
-               case AUL_R_LOCAL:               /**< Launch by himself */
-               case AUL_R_OK:                  /**< General success */
-               default:
-                       DbgPrint("Slave %s is launched with %d as %s\n", slave_pkgname(slave), slave->pid, slave_name(slave));
-                       break;
-               }
-
-               if (!slave->extra_bundle_data) {
-                       slave->activate_timer = ecore_timer_add(WIDGET_CONF_SLAVE_ACTIVATE_TIME, activate_timer_cb, slave);
-               } else {
-                       DbgPrint("SDK Viewer launches this. activate monitor timer (%lf)\n", SDK_SLAVE_ACTIVATE_TIME);
-                       slave->activate_timer = ecore_timer_add(SDK_SLAVE_ACTIVATE_TIME, sdk_activate_timer_cb, slave);
-               }
-               if (!slave->activate_timer) {
-                       ErrPrint("Failed to register an activate timer\n");
-               }
-       }
-
-       slave->state = SLAVE_REQUEST_TO_LAUNCH;
-       /*!
-        * \note
-        * Increase the refcnt of a slave,
-        * To prevent from making an orphan(slave).
-        */
-       (void)slave_ref(slave);
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_give_more_ttl(struct slave_node *slave)
-{
-       double delay;
-
-       if (!(WIDGET_IS_INHOUSE(slave_abi(slave)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL)
-               && ((!slave_is_app(slave) && !slave->flags.field.secured) || !slave->ttl_timer))
-       {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (WIDGET_CONF_FORCE_TO_TERMINATE) {
-               DbgPrint("Force to terminate is enabled: %s\n", slave_pkgname(slave));
-               return WIDGET_ERROR_DISABLED;
-       }
-
-       delay = WIDGET_CONF_SLAVE_TTL - ecore_timer_pending_get(slave->ttl_timer);
-       ecore_timer_delay(slave->ttl_timer, delay);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_freeze_ttl(struct slave_node *slave)
-{
-       if (!(WIDGET_IS_INHOUSE(slave_abi(slave)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL)
-               && ((!slave_is_app(slave) && !slave->flags.field.secured) || !slave->ttl_timer))
-       {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ecore_timer_freeze(slave->ttl_timer);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_thaw_ttl(struct slave_node *slave)
-{
-       double delay;
-
-       if (!(WIDGET_IS_INHOUSE(slave_abi(slave)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL)
-               && ((!slave_is_app(slave) && !slave->flags.field.secured) || !slave->ttl_timer))
-       {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ecore_timer_thaw(slave->ttl_timer);
-
-       delay = WIDGET_CONF_SLAVE_TTL - ecore_timer_pending_get(slave->ttl_timer);
-       ecore_timer_delay(slave->ttl_timer, delay);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_activated(struct slave_node *slave)
-{
-       /**
-        * @note
-        * Send the client's state to the provider.
-        * After the slave is activated.
-        */
-       if (xmonitor_is_paused()) {
-               slave_pause(slave);
-       } else {
-               slave_resume(slave);
-       }
-
-       /**
-        * Condition for activating TTL Timer
-        * 1. If the slave is INHOUSE(data-provider-slave) and LIMIT_TO_TTL is true, and SLAVE_TTL is greater than 0.0f
-        * 2. Service provider is "secured" and SLAVE_TTL is greater than 0.0f
-        * 3. If a slave is launched for sdk_viewer (widget debugging), Do not activate TTL
-        */
-       if (!slave->extra_bundle_data /* Launched by SDK Viewer */
-               && !slave_is_watch(slave) /* Not a watch */
-               && ((WIDGET_IS_INHOUSE(slave_abi(slave)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL) || slave->flags.field.secured == 1 || slave_is_app(slave))
-               && WIDGET_CONF_SLAVE_TTL > 0.0f)
-       {
-               DbgPrint("Slave deactivation timer is added (%s - %lf)\n", slave_name(slave), WIDGET_CONF_SLAVE_TTL);
-               slave->ttl_timer = ecore_timer_add(WIDGET_CONF_SLAVE_TTL, slave_ttl_cb, slave);
-               if (!slave->ttl_timer) {
-                       ErrPrint("Failed to create a TTL timer\n");
-               }
-       }
-
-       invoke_activate_cb(slave);
-
-       slave_set_reactivation(slave, 0);
-       slave_set_reactivate_instances(slave, 0);
-
-#if defined(_USE_ECORE_TIME_GET)
-       slave->activated_at = ecore_time_get();
-#else
-       if (gettimeofday(&slave->activated_at, NULL) < 0) {
-               ErrPrint("getimeofday: %d\n", errno);
-               slave->activated_at.tv_sec = 0;
-               slave->activated_at.tv_usec = 0;
-       }
-#endif
-
-       if (slave->activate_timer) {
-               ecore_timer_del(slave->activate_timer);
-               slave->activate_timer = NULL;
-       }
-
-       if (slave->relaunch_timer) {
-               ecore_timer_del(slave->relaunch_timer);
-               slave->relaunch_timer = NULL;
-       }
-
-       slave_set_priority(slave, LOW_PRIORITY);
-       (void)apply_resource_limit(slave);
-       return WIDGET_ERROR_NONE;
-}
-
-static inline int invoke_deactivate_cb(struct slave_node *slave)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct event *event;
-       int ret;
-       int reactivate = 0;
-
-       slave->in_event_process |= SLAVE_EVENT_PROCESS_DEACTIVATE;
-
-       EINA_LIST_FOREACH_SAFE(slave->event_deactivate_list, l, n, event) {
-               if (event->deleted) {
-                       slave->event_deactivate_list = eina_list_remove(slave->event_deactivate_list, event);
-                       DbgFree(event);
-                       continue;
-               }
-
-               ret = event->evt_cb(event->slave, event->cbdata);
-               if (ret < 0 || event->deleted) {
-                       slave->event_deactivate_list = eina_list_remove(slave->event_deactivate_list, event);
-                       DbgFree(event);
-               }
-
-               if (ret == SLAVE_NEED_TO_REACTIVATE) {
-                       reactivate++;
-               }
-       }
-
-       slave->in_event_process &= ~SLAVE_EVENT_PROCESS_DEACTIVATE;
-
-       return reactivate;
-}
-
-HAPI struct slave_node *slave_deactivated(struct slave_node *slave)
-{
-       int reactivate;
-
-       slave->pid = (pid_t)-1;
-       slave->state = SLAVE_TERMINATED;
-
-       if (slave->ttl_timer) {
-               ecore_timer_del(slave->ttl_timer);
-               slave->ttl_timer = NULL;
-       }
-
-       if (slave->activate_timer) {
-               ecore_timer_del(slave->activate_timer);
-               slave->activate_timer = NULL;
-       }
-
-       if (slave->relaunch_timer) {
-               ecore_timer_del(slave->relaunch_timer);
-               slave->relaunch_timer = NULL;
-       }
-
-       if (slave->terminate_timer) {
-               ecore_timer_del(slave->terminate_timer);
-               slave->terminate_timer = NULL;
-       }
-
-       /**
-        * @note
-        * FOR SAFETY
-        * If the deactivated event callback is called for package.c
-        * It can delete the instance if it has fault information
-        * then it also try to delete the slave object again.
-        * To prevent from unexpected slave object deletetion while handling callback,
-        * increase the refcnt of slave
-        * when it get back from callback, try to decrease the refcnt of slave
-        * At that time, we can delete slave safely.
-        */
-       slave_ref(slave);
-       reactivate = invoke_deactivate_cb(slave);
-       slave = slave_unref(slave);
-       if (!slave) {
-               ErrPrint("Slave object is deleted\n");
-               return slave;
-       }
-
-       slave = slave_unref(slave);
-       if (!slave) {
-               DbgPrint("SLAVE object is destroyed\n");
-               return slave;
-       }
-
-       if ((slave->ctrl_option & PROVIDER_CTRL_MANUAL_REACTIVATION) == PROVIDER_CTRL_MANUAL_REACTIVATION) {
-               /**
-                * @note
-                * In this case, the provider(Slave) should be reactivated by itself or user.
-                * The master will not reactivate it automatically.
-                */
-               DbgPrint("Manual reactivate option is turned on\n");
-       } else if (reactivate && slave_need_to_reactivate(slave) && setting_oom_level() == OOM_TYPE_NORMAL) {
-               int ret;
-
-               DbgPrint("Need to reactivate a slave\n");
-               ret = slave_activate(slave);
-               if (ret < 0 && ret != WIDGET_ERROR_ALREADY_STARTED) {
-                       ErrPrint("Failed to reactivate a slave\n");
-               }
-       } else if (slave_loaded_instance(slave) == 0) {
-               /**
-                * @note
-                * If a slave has no more instances,
-                * Destroy it
-                */
-               slave = slave_unref(slave);
-       }
-
-       return slave;
-}
-
-HAPI struct slave_node *slave_deactivated_by_fault(struct slave_node *slave)
-{
-       int ret;
-       int reactivate = 1;
-       int reactivate_instances = 1;
-       int max_load;
-
-       if (g_conf.slave_max_load < 0) {
-               max_load = WIDGET_CONF_SLAVE_MAX_LOAD;
-       } else {
-               max_load = g_conf.slave_max_load;
-       }
-
-       if (!slave_is_activated(slave)) {
-               DbgPrint("Deactivating in progress\n");
-               if (slave_loaded_instance(slave) == 0) {
-                       slave = slave_unref(slave);
-               }
-
-               return slave;
-       }
-
-       slave->fault_count++;
-
-       (void)fault_check_pkgs(slave);
-
-       if (slave_pid(slave) > 0) {
-               DbgPrint("Try to terminate PID: %d\n", slave_pid(slave));
-               ret = aul_terminate_pid_async(slave_pid(slave));
-               if (ret < 0) {
-                       ErrPrint("Terminate failed, pid %d\n", slave_pid(slave));
-               }
-       }
-
-#if defined(_USE_ECORE_TIME_GET)
-       double faulted_at;
-
-       faulted_at = ecore_time_get();
-       if (faulted_at - slave->activated_at < WIDGET_CONF_MINIMUM_REACTIVATION_TIME) {
-               slave->critical_fault_count++;
-
-               if (!slave_loaded_instance(slave) || slave->critical_fault_count >= max_load) {
-                       ErrPrint("Reactivation time is too fast and frequently occurred - Stop to auto reactivation\n");
-                       reactivate = 0;
-                       reactivate_instances = 0;
-                       slave->critical_fault_count = 0;
-                       /*!
-                        * \note
-                        * Fault callback can access the slave information.
-                        */
-                       if (invoke_fault_cb(slave) == NULL) {
-                               ErrPrint("Slave is deleted while processing fault handler\n");
-                               return NULL;
-                       }
-               } else {
-                       slave->critical_fault_count = 0;
-               }
-       }
-#else
-       struct timeval faulted_at;
-
-       if (gettimeofday(&faulted_at, NULL) == 0) {
-               struct timeval rtv;
-
-               timersub(&faulted_at, &slave->activated_at, &rtv);
-               if (rtv.tv_sec < WIDGET_CONF_MINIMUM_REACTIVATION_TIME) {
-                       slave->critical_fault_count++;
-                       if (!slave_loaded_instance(slave) || slave->critical_fault_count >= max_load) {
-                               ErrPrint("Reactivation time is too fast and frequently occurred - Stop to auto reactivation\n");
-                               reactivate = 0;
-                               reactivate_instances = 0;
-                               slave->critical_fault_count = 0;
-                               /*!
-                                * \note
-                                * Fault callback can access the slave information.
-                                */
-                               if (invoke_fault_cb(slave) == NULL) {
-                                       ErrPrint("Slave is deleted while processing fault handler\n");
-                                       return NULL;
-                               }
-                       }
-               } else {
-                       slave->critical_fault_count = 0;
-               }
-       } else {
-               ErrPrint("gettimeofday: %d\n", errno);
-       }
-#endif
-
-       slave_set_reactivation(slave, reactivate);
-       slave_set_reactivate_instances(slave, reactivate_instances);
-
-       slave = slave_deactivated(slave);
-       return slave;
-}
-
-HAPI const int const slave_is_activated(struct slave_node *slave)
-{
-       switch (slave->state) {
-       case SLAVE_REQUEST_TO_TERMINATE:
-       case SLAVE_TERMINATED:
-               return 0;
-       case SLAVE_REQUEST_TO_DISCONNECT:
-               /* This case should be treated as an activated state.
-                * To send the last request to the provider.
-                */
-       case SLAVE_REQUEST_TO_LAUNCH:
-               /* Not yet launched. but the slave incurred an unexpected error */
-       case SLAVE_REQUEST_TO_PAUSE:
-       case SLAVE_REQUEST_TO_RESUME:
-       case SLAVE_PAUSED:
-       case SLAVE_RESUMED:
-               return 1;
-       default:
-               return slave->pid != (pid_t)-1;
-       }
-
-       /* Could not be reach to here */
-       return 0;
-}
-
-HAPI int slave_event_callback_add(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data)
-{
-       struct event *ev;
-
-       ev = calloc(1, sizeof(*ev));
-       if (!ev) {
-               ErrPrint("calloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       ev->slave = slave;
-       ev->cbdata = data;
-       ev->evt_cb = cb;
-
-       /*!
-        * \note
-        * Use the eina_list_prepend API.
-        * To keep the sequence of a callback invocation.
-        *
-        * Here is an example sequence.
-        *
-        * slave_event_callback_add(CALLBACK_01);
-        * slave_event_callback_add(CALLBACK_02);
-        * slave_event_callback_add(CALLBACK_03);
-        *
-        * Then the invoke_event_callback function will call the CALLBACKS as below sequence
-        *
-        * invoke_CALLBACK_03
-        * invoke_CALLBACK_02
-        * invoke_CALLBACK_01
-        */
-
-       switch (event) {
-       case SLAVE_EVENT_ACTIVATE:
-               slave->event_activate_list = eina_list_prepend(slave->event_activate_list, ev);
-               break;
-       case SLAVE_EVENT_DELETE:
-               slave->event_delete_list = eina_list_prepend(slave->event_delete_list, ev);
-               break;
-       case SLAVE_EVENT_DEACTIVATE:
-               slave->event_deactivate_list = eina_list_prepend(slave->event_deactivate_list, ev);
-               break;
-       case SLAVE_EVENT_PAUSE:
-               slave->event_pause_list = eina_list_prepend(slave->event_pause_list, ev);
-               break;
-       case SLAVE_EVENT_RESUME:
-               slave->event_resume_list = eina_list_prepend(slave->event_resume_list, ev);
-               break;
-       case SLAVE_EVENT_FAULT:
-               slave->event_fault_list = eina_list_prepend(slave->event_fault_list, ev);
-               break;
-       default:
-               DbgFree(ev);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_event_callback_del(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data)
-{
-       struct event *ev;
-       Eina_List *l;
-       Eina_List *n;
-
-       switch (event) {
-       case SLAVE_EVENT_DEACTIVATE:
-               EINA_LIST_FOREACH_SAFE(slave->event_deactivate_list, l, n, ev) {
-                       if (ev->evt_cb == cb && ev->cbdata == data) {
-                               if (slave->in_event_process & SLAVE_EVENT_PROCESS_DEACTIVATE) {
-                                       ev->deleted = 1;
-                               } else {
-                                       slave->event_deactivate_list = eina_list_remove(slave->event_deactivate_list, ev);
-                                       DbgFree(ev);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       case SLAVE_EVENT_DELETE:
-               EINA_LIST_FOREACH_SAFE(slave->event_delete_list, l, n, ev) {
-                       if (ev->evt_cb == cb && ev->cbdata == data) {
-                               if (slave->in_event_process & SLAVE_EVENT_PROCESS_DELETE) {
-                                       ev->deleted = 1;
-                               } else {
-                                       slave->event_delete_list = eina_list_remove(slave->event_delete_list, ev);
-                                       DbgFree(ev);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       case SLAVE_EVENT_ACTIVATE:
-               EINA_LIST_FOREACH_SAFE(slave->event_activate_list, l, n, ev) {
-                       if (ev->evt_cb == cb && ev->cbdata == data) {
-                               if (slave->in_event_process & SLAVE_EVENT_PROCESS_ACTIVATE) {
-                                       ev->deleted = 1;
-                               } else {
-                                       slave->event_activate_list = eina_list_remove(slave->event_activate_list, ev);
-                                       DbgFree(ev);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       case SLAVE_EVENT_PAUSE:
-               EINA_LIST_FOREACH_SAFE(slave->event_pause_list, l, n, ev) {
-                       if (ev->evt_cb == cb && ev->cbdata == data) {
-                               if (slave->in_event_process & SLAVE_EVENT_PROCESS_PAUSE) {
-                                       ev->deleted = 1;
-                               } else {
-                                       slave->event_pause_list = eina_list_remove(slave->event_pause_list, ev);
-                                       DbgFree(ev);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       case SLAVE_EVENT_RESUME:
-               EINA_LIST_FOREACH_SAFE(slave->event_resume_list, l, n, ev) {
-                       if (ev->evt_cb == cb && ev->cbdata == data) {
-                               if (slave->in_event_process & SLAVE_EVENT_PROCESS_RESUME) {
-                                       ev->deleted = 1;
-                               } else {
-                                       slave->event_resume_list = eina_list_remove(slave->event_resume_list, ev);
-                                       DbgFree(ev);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       case SLAVE_EVENT_FAULT:
-               EINA_LIST_FOREACH_SAFE(slave->event_fault_list, l, n, ev) {
-                       if (ev->evt_cb == cb && ev->cbdata == data) {
-                               if (slave->in_event_process & SLAVE_EVENT_PROCESS_FAULT) {
-                                       ev->deleted = 1;
-                               } else {
-                                       slave->event_fault_list = eina_list_remove(slave->event_fault_list, ev);
-                                       DbgFree(ev);
-                               }
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       default:
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-HAPI int slave_set_data(struct slave_node *slave, const char *tag, void *data)
-{
-       struct priv_data *priv;
-
-       priv = calloc(1, sizeof(*priv));
-       if (!priv) {
-               ErrPrint("calloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       priv->tag = strdup(tag);
-       if (!priv->tag) {
-               ErrPrint("strdup: %d\n", errno);
-               DbgFree(priv);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       priv->data = data;
-       slave->data_list = eina_list_append(slave->data_list, priv);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void *slave_del_data(struct slave_node *slave, const char *tag)
-{
-       struct priv_data *priv;
-       void *data;
-       Eina_List *l;
-       Eina_List *n;
-
-       EINA_LIST_FOREACH_SAFE(slave->data_list, l, n, priv) {
-               if (!strcmp(priv->tag, tag)) {
-                       slave->data_list = eina_list_remove(slave->data_list, priv);
-
-                       data = priv->data;
-                       DbgFree(priv->tag);
-                       DbgFree(priv);
-                       return data;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI void *slave_data(struct slave_node *slave, const char *tag)
-{
-       struct priv_data *priv;
-       Eina_List *l;
-
-       EINA_LIST_FOREACH(slave->data_list, l, priv) {
-               if (!strcmp(priv->tag, tag)) {
-                       return priv->data;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI struct slave_node *slave_find_by_pid(pid_t pid)
-{
-       Eina_List *l;
-       struct slave_node *slave;
-
-       EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (slave_pid(slave) == pid) {
-                       return slave;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI struct slave_node *slave_find_by_name(const char *name)
-{
-       Eina_List *l;
-       struct slave_node *slave;
-
-       EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (!strcmp(slave_name(slave), name)) {
-                       return slave;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI struct slave_node *slave_find_available(const char *slave_pkgname, const char *abi, int secured, int network, const char *hw_acceleration, int auto_align)
-{
-       Eina_List *l;
-       struct slave_node *slave;
-
-       EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (slave->flags.field.secured != secured) {
-                       continue;
-               }
-
-               if ((slave->state == SLAVE_REQUEST_TO_TERMINATE || slave->state == SLAVE_REQUEST_TO_DISCONNECT) && slave->loaded_instance == 0) {
-                       /*!
-                        * \note
-                        * If a slave is in request_to_terminate state,
-                        * and the slave object has no more intances,
-                        * the slave object will be deleted soon.
-                        * so we cannot reuse it.
-                        *
-                        * This object is not usable.
-                        */
-                       continue;
-               }
-
-               if (strcasecmp(slave->abi, abi)) {
-                       continue;
-               }
-
-               if (strcasecmp(slave->pkgname, slave_pkgname)) {
-                       continue;
-               }
-
-               if (slave->hw_acceleration != hw_acceleration) {
-                       if (!slave->hw_acceleration || !hw_acceleration || strcasecmp(slave->hw_acceleration, hw_acceleration)) {
-                               continue;
-                       }
-               }
-
-               if (slave->flags.field.auto_align != auto_align) {
-                       continue;
-               }
-
-               if (slave->flags.field.secured) {
-                       if (slave->loaded_package == 0) {
-                               DbgPrint("Found secured slave - has no instances (%s)\n", slave_name(slave));
-                               return slave;
-                       }
-               } else if (slave->flags.field.network == network) {
-                       DbgPrint("slave[%s] loaded_package[%d] net: [%d]\n", slave_name(slave), slave->loaded_package, slave->flags.field.network);
-                       if (!strcasecmp(abi, WIDGET_CONF_DEFAULT_ABI)) {
-                               int max_load;
-                               if (g_conf.slave_max_load < 0) {
-                                       max_load = WIDGET_CONF_SLAVE_MAX_LOAD;
-                               } else {
-                                       max_load = g_conf.slave_max_load;
-                               }
-
-                               if (slave->loaded_package < max_load) {
-                                       return slave;
-                               }
-                       } else {
-                               return slave;
-                       }
-               }
-       }
-
-       return NULL;
-}
-
-HAPI struct slave_node *slave_find_by_pkgname(const char *pkgname)
-{
-       Eina_List *l;
-       struct slave_node *slave;
-
-       if (!pkgname) {
-               return NULL;
-       }
-
-       EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (!strcmp(slave_pkgname(slave), pkgname)) {
-                       if (slave_pid(slave) == (pid_t)-1 || slave_pid(slave) == (pid_t)0) {
-                               return slave;
-                       }
-               }
-       }
-
-       return NULL;
-}
-
-HAPI struct slave_node *slave_find_by_rpc_handle(int handle)
-{
-       Eina_List *l;
-       struct slave_node *slave;
-
-       if (handle <= 0) {
-               ErrPrint("Invalid RPC handle: %d\n", handle);
-               return NULL;
-       }
-
-       EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               if (slave_rpc_handle(slave) == handle) {
-                       return slave;
-               }
-       }
-
-       /* Not found */
-       return NULL;
-}
-
-HAPI char *slave_package_name(const char *abi, const char *lbid)
-{
-       char *s_pkgname;
-       const char *tmp;
-
-       tmp = widget_abi_get_pkgname_by_abi(abi);
-       if (!tmp) {
-               ErrPrint("Failed to find a proper pkgname of a slave\n");
-               return NULL;
-       }
-
-       if (!strcasecmp(abi, "meta")) {
-               s_pkgname = package_meta_tag(lbid, tmp);
-               if (!s_pkgname) {
-                       s_pkgname = strdup(lbid);
-                       ErrPrint("Meta tag is not valid[%s] - [%s], use [%s]\n", lbid, tmp, s_pkgname);
-               }
-       } else {
-               s_pkgname = widget_util_replace_string(tmp, WIDGET_CONF_REPLACE_TAG_APPID, lbid);
-               if (!s_pkgname) {
-                       DbgPrint("Failed to get replaced string\n");
-                       s_pkgname = strdup(tmp);
-                       if (!s_pkgname) {
-                               ErrPrint("strdup: %d\n", errno);
-                               return NULL;
-                       }
-               }
-       }
-
-       return s_pkgname;
-}
-
-HAPI void slave_load_package(struct slave_node *slave)
-{
-       slave->loaded_package++;
-}
-
-HAPI void slave_unload_package(struct slave_node *slave)
-{
-       if (!slave || slave->loaded_package == 0) {
-               ErrPrint("Slave loaded package is not correct\n");
-               return;
-       }
-
-       slave->loaded_package--;
-}
-
-HAPI void slave_load_instance(struct slave_node *slave)
-{
-       slave->loaded_instance++;
-       DbgPrint("Instance: (%d)%d\n", slave_pid(slave), slave->loaded_instance);
-}
-
-HAPI int const slave_loaded_instance(struct slave_node *slave)
-{
-       return slave->loaded_instance;
-}
-
-HAPI int const slave_loaded_package(struct slave_node *slave)
-{
-       return slave->loaded_package;
-}
-
-HAPI struct slave_node *slave_unload_instance(struct slave_node *slave)
-{
-       if (!slave || slave->loaded_instance == 0) {
-               ErrPrint("Slave loaded instance is not correct\n");
-               return slave;
-       }
-
-       slave->loaded_instance--;
-       DbgPrint("Instance: (%d)%d\n", slave_pid(slave), slave->loaded_instance);
-       if (slave->loaded_instance == 0 && slave_is_activated(slave)) {
-               slave_set_reactivation(slave, 0);
-               slave_set_reactivate_instances(slave, 0);
-
-               slave = slave_deactivate(slave, 0);
-       }
-
-       return slave;
-}
-
-HAPI const int const slave_is_secured(const struct slave_node *slave)
-{
-       return slave->flags.field.secured;
-}
-
-HAPI const int const slave_is_app(const struct slave_node *slave)
-{
-       return !strcasecmp(slave_abi(slave), WIDGET_CONF_APP_ABI);
-}
-
-HAPI const char * const slave_name(const struct slave_node *slave)
-{
-       return slave->name;
-}
-
-HAPI const char * const slave_abi(const struct slave_node *slave)
-{
-       return slave->abi;
-}
-
-HAPI const pid_t const slave_pid(const struct slave_node *slave)
-{
-       return slave->pid;
-}
-
-HAPI int slave_set_pid(struct slave_node *slave, pid_t pid)
-{
-       if (!slave) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       DbgPrint("Slave PID is updated to %d from %d\n", pid, slave_pid(slave));
-
-       slave->pid = pid;
-       return WIDGET_ERROR_NONE;
-}
-
-static inline void invoke_resumed_cb(struct slave_node *slave)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct event *event;
-
-       slave->in_event_process |= SLAVE_EVENT_PROCESS_RESUME;
-       EINA_LIST_FOREACH_SAFE(slave->event_resume_list, l, n, event) {
-               if (event->deleted || event->evt_cb(event->slave, event->cbdata) < 0 || event->deleted) {
-                       slave->event_resume_list = eina_list_remove(slave->event_resume_list, event);
-                       DbgFree(event);
-               }
-       }
-       slave->in_event_process &= ~SLAVE_EVENT_PROCESS_RESUME;
-}
-
-static void resume_cb(struct slave_node *slave, const struct packet *packet, void *data)
-{
-       int ret;
-
-       if (slave->state == SLAVE_REQUEST_TO_TERMINATE || slave->state == SLAVE_REQUEST_TO_DISCONNECT) {
-               DbgPrint("Slave is terminating now. ignore resume result\n");
-               return;
-       }
-
-       if (!packet) {
-               ErrPrint("Failed to change the state of the slave\n");
-               slave->state = SLAVE_PAUSED;
-               return;
-       }
-
-       if (packet_get(packet, "i", &ret) != 1) {
-               ErrPrint("Invalid parameter\n");
-               return;
-       }
-
-       if (ret == 0) {
-               slave->state = SLAVE_RESUMED;
-               (void)slave_rpc_ping_thaw(slave);
-               invoke_resumed_cb(slave);
-       }
-}
-
-static inline void invoke_paused_cb(struct slave_node *slave)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct event *event;
-
-       slave->in_event_process |= SLAVE_EVENT_PROCESS_PAUSE;
-       EINA_LIST_FOREACH_SAFE(slave->event_pause_list, l, n, event) {
-               if (event->deleted || event->evt_cb(event->slave, event->cbdata) < 0 || event->deleted) {
-                       slave->event_pause_list = eina_list_remove(slave->event_pause_list, event);
-                       DbgFree(event);
-               }
-       }
-       slave->in_event_process &= ~SLAVE_EVENT_PROCESS_PAUSE;
-}
-
-static void pause_cb(struct slave_node *slave, const struct packet *packet, void *data)
-{
-       int ret;
-
-       if (slave->state == SLAVE_REQUEST_TO_TERMINATE || slave->state == SLAVE_REQUEST_TO_DISCONNECT) {
-               DbgPrint("Slave is terminating now. ignore pause result\n");
-               return;
-       }
-
-       if (!packet) {
-               ErrPrint("Failed to change the state of the slave\n");
-               slave->state = SLAVE_RESUMED;
-               return;
-       }
-
-       if (packet_get(packet, "i", &ret) != 1) {
-               ErrPrint("Invalid parameter\n");
-               return;
-       }
-
-       if (ret == 0) {
-               slave->state = SLAVE_PAUSED;
-               (void)slave_rpc_ping_freeze(slave);
-               invoke_paused_cb(slave);
-       }
-}
-
-HAPI int slave_resume(struct slave_node *slave)
-{
-       double timestamp;
-       struct packet *packet;
-       unsigned int cmd = CMD_RESUME;
-
-       switch (slave->state) {
-       case SLAVE_REQUEST_TO_DISCONNECT:
-       case SLAVE_REQUEST_TO_TERMINATE:
-       case SLAVE_TERMINATED:
-               ErrPrint("Slave state[%d]\n", slave->state);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       case SLAVE_RESUMED:
-       case SLAVE_REQUEST_TO_RESUME:
-               ErrPrint("Slave state[%d]\n", slave->state);
-               return WIDGET_ERROR_NONE;
-       default:
-               break;
-       }
-
-       timestamp = util_timestamp();
-
-       packet = packet_create((const char *)&cmd, "d", timestamp);
-       if (!packet) {
-               ErrPrint("Failed to prepare param\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       slave->state = SLAVE_REQUEST_TO_RESUME;
-       return slave_rpc_async_request(slave, NULL, packet, resume_cb, NULL, 0);
-}
-
-HAPI int slave_pause(struct slave_node *slave)
-{
-       double timestamp;
-       struct packet *packet;
-       unsigned int cmd = CMD_PAUSE;
-
-       switch (slave->state) {
-       case SLAVE_REQUEST_TO_DISCONNECT:
-       case SLAVE_REQUEST_TO_TERMINATE:
-       case SLAVE_TERMINATED:
-               ErrPrint("Slave state[%d]\n", slave->state);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       case SLAVE_PAUSED:
-       case SLAVE_REQUEST_TO_PAUSE:
-               ErrPrint("Slave state[%d]\n", slave->state);
-               return WIDGET_ERROR_NONE;
-       default:
-               break;
-       }
-
-       timestamp = util_timestamp();
-
-       packet = packet_create((const char *)&cmd, "d", timestamp);
-       if (!packet) {
-               ErrPrint("Failed to prepare param\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       slave->state = SLAVE_REQUEST_TO_PAUSE;
-       return slave_rpc_async_request(slave, NULL, packet, pause_cb, NULL, 0);
-}
-
-HAPI const char *slave_pkgname(const struct slave_node *slave)
-{
-       return slave ? slave->pkgname : NULL;
-}
-
-HAPI enum slave_state slave_state(const struct slave_node *slave)
-{
-       return slave ? slave->state : SLAVE_ERROR;
-}
-
-HAPI void slave_set_state(struct slave_node *slave, enum slave_state state)
-{
-       slave->state = state;
-}
-
-HAPI const char *slave_state_string(const struct slave_node *slave)
-{
-       switch (slave->state) {
-       case SLAVE_REQUEST_TO_DISCONNECT:
-               return "RequestToDisconnect";
-       case SLAVE_REQUEST_TO_LAUNCH:
-               return "RequestToLaunch";
-       case SLAVE_REQUEST_TO_TERMINATE:
-               return "RequestToTerminate";
-       case SLAVE_TERMINATED:
-               return "Terminated";
-       case SLAVE_REQUEST_TO_PAUSE:
-               return "RequestToPause";
-       case SLAVE_REQUEST_TO_RESUME:
-               return "RequestToResume";
-       case SLAVE_PAUSED:
-               return "Paused";
-       case SLAVE_RESUMED:
-               return "Resumed";
-       case SLAVE_ERROR:
-               return "Error";
-       default:
-               break;
-       }
-
-       return "Unknown";
-}
-
-HAPI const void *slave_list(void)
-{
-       return s_info.slave_list;
-}
-
-HAPI int const slave_fault_count(const struct slave_node *slave)
-{
-       return slave->fault_count;
-}
-
-HAPI double const slave_ttl(const struct slave_node *slave)
-{
-       if (!slave->ttl_timer) {
-               return 0.0f;
-       }
-
-       return ecore_timer_pending_get(slave->ttl_timer);
-}
-
-HAPI void slave_set_reactivate_instances(struct slave_node *slave, int reactivate)
-{
-       slave->flags.field.reactivate_instances = !!reactivate;
-}
-
-HAPI int slave_need_to_reactivate_instances(struct slave_node *slave)
-{
-       return slave->flags.field.reactivate_instances;
-}
-
-HAPI void slave_set_reactivation(struct slave_node *slave, int flag)
-{
-       slave->flags.field.reactivate_slave = flag;
-}
-
-HAPI int slave_need_to_reactivate(struct slave_node *slave)
-{
-       int reactivate;
-
-       if (!WIDGET_CONF_REACTIVATE_ON_PAUSE) {
-               if (slave_is_watch(slave)) {
-                       /**
-                        * @note
-                        * If this slave serves WATCH-App, it must has to be reactivated.
-                        */
-                       DbgPrint("Watch should be activated anyway (%s)\n", slave_pkgname(slave));
-                       reactivate = 1;
-               } else {
-                       Eina_List *pkg_list;
-                       Eina_List *l;
-                       struct pkg_info *info;
-
-                       /**
-                        * @TODO
-                        * Check all instances on this slave, whether they are all paused or not.
-                        */
-                       pkg_list = (Eina_List *)package_list();
-
-                       reactivate = 0;
-
-                       EINA_LIST_FOREACH(pkg_list, l, info) {
-                               if (package_slave(info) == slave) {
-                                       struct inst_info *inst;
-                                       Eina_List *inst_list;
-                                       Eina_List *n;
-
-                                       inst_list = (Eina_List *)package_instance_list(info);
-                                       EINA_LIST_FOREACH(inst_list, n, inst) {
-                                               if (instance_visible_state(inst) == WIDGET_SHOW) {
-                                                       reactivate++;
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               DbgPrint("visible instances: %d\n", reactivate);
-       } else {
-               reactivate = 1;
-       }
-
-       return reactivate && slave->flags.field.reactivate_slave;
-}
-
-HAPI int slave_network(const struct slave_node *slave)
-{
-       return slave->flags.field.network;
-}
-
-HAPI void slave_set_network(struct slave_node *slave, int network)
-{
-       slave->flags.field.network = network;
-}
-
-HAPI int slave_deactivate_all(int reactivate, int reactivate_instances, int no_timer)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct slave_node *slave;
-       int cnt = 0;
-
-       s_info.deactivate_all_refcnt++;
-       if (s_info.deactivate_all_refcnt > 1) {
-               return 0;
-       }
-       DbgPrint("Deactivate all\n");
-
-       EINA_LIST_FOREACH_SAFE(s_info.slave_list, l, n, slave) {
-               if (slave_is_activated(slave)) {
-                       slave_set_reactivate_instances(slave, reactivate_instances);
-                       slave_set_reactivation(slave, reactivate);
-
-                       if (!slave_deactivate(slave, no_timer)) {
-                               s_info.slave_list = eina_list_remove(s_info.slave_list, slave);
-                       }
-               }
-
-               cnt++;
-       }
-
-       return cnt;
-}
-
-HAPI int slave_activate_all(void)
-{
-       Eina_List *l;
-       struct slave_node *slave;
-       int cnt = 0;
-
-       s_info.deactivate_all_refcnt--;
-       if (s_info.deactivate_all_refcnt > 0) {
-               return 0;
-       }
-       DbgPrint("Activate all\n");
-
-       EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
-               slave_activate(slave);
-               cnt++;
-       }
-
-       return cnt;
-}
-
-HAPI void slave_set_control_option(struct slave_node *slave, int ctrl)
-{
-       slave->ctrl_option = ctrl;
-}
-
-HAPI int slave_control_option(struct slave_node *slave)
-{
-       return slave->ctrl_option;
-}
-
-HAPI int slave_set_priority(struct slave_node *slave, int priority)
-{
-       pid_t pid;
-
-       if (!slave) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       pid = slave_pid(slave);
-       if (pid <= 0) {
-               DbgPrint("Skip for %d\n", pid);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (setpriority(PRIO_PROCESS, slave_pid(slave), priority) < 0) {
-               ErrPrint("setpriority: %d\n", errno);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_priority(struct slave_node *slave)
-{
-       pid_t pid;
-       int priority;
-
-       if (!slave) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       pid = slave_pid(slave);
-       if (pid <= 0) {
-               DbgPrint("Skip for %d\n", pid);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       priority = getpriority(PRIO_PROCESS, pid);
-       if (priority < 0) {
-               ErrPrint("getpriority: %d\n", errno);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       return priority;
-}
-
-HAPI int slave_valid(const struct slave_node *slave)
-{
-    if (!slave->flags.field.valid) {
-        DbgPrint("slave is invalid");
-    }
-
-    return slave->flags.field.valid;
-}
-
-HAPI void slave_set_valid(struct slave_node *slave)
-{
-    DbgPrint("slave is set valid\n");
-    slave->flags.field.valid = 1;
-}
-
-HAPI void slave_set_extra_bundle_data(struct slave_node *slave, const char *extra_bundle_data)
-{
-       char *tmp = NULL;
-
-       if (!slave) {
-               return;
-       }
-
-       if (extra_bundle_data) {
-               tmp = strdup(extra_bundle_data);
-               if (!tmp) {
-                       ErrPrint("strdup: %d\n", errno);
-                       return;
-               }
-       }
-
-       DbgFree(slave->extra_bundle_data);
-       slave->extra_bundle_data = tmp;
-}
-
-HAPI const char *slave_extra_bundle_data(struct slave_node *slave)
-{
-       return slave ? slave->extra_bundle_data : NULL;
-}
-
-HAPI int slave_is_watch(struct slave_node *slave)
-{
-       return slave ? slave->flags.field.is_watch : 0;
-}
-
-HAPI void slave_set_is_watch(struct slave_node *slave, int flag)
-{
-       if (!slave) {
-               return;
-       }
-
-       slave->flags.field.is_watch = flag;
-}
-
-HAPI int slave_set_resource_limit(struct slave_node *slave, unsigned int soft, unsigned int hard)
-{
-       if (!slave) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (soft > hard) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       slave->resources.memory.soft = soft;
-       slave->resources.memory.hard = hard;
-
-       (void)apply_resource_limit(slave);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_get_resource_limit(struct slave_node *slave, unsigned int *soft, unsigned int *hard)
-{
-       if (!slave) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (soft) {
-               *soft = slave->resources.memory.soft;
-       }
-
-       if (hard) {
-               *hard = slave->resources.memory.hard;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void slave_set_wait_deactivation(struct slave_node *slave, int wait)
-{
-       slave->flags.field.wait_deactivation = !!wait;
-}
-
-HAPI int slave_wait_deactivation(struct slave_node *slave)
-{
-       return slave->flags.field.wait_deactivation;
-}
-
-/* End of a file */
diff --git a/src/slave_rpc.c b/src/slave_rpc.c
deleted file mode 100644 (file)
index 099ee13..0000000
+++ /dev/null
@@ -1,767 +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 <string.h> /* strerror */
-#include <errno.h> /* errno */
-#include <unistd.h> /* pid_t */
-#include <stdlib.h> /* free */
-#include <assert.h>
-
-#include <Eina.h>
-#include <Ecore.h>
-
-#include <dlog.h>
-
-#include <packet.h>
-#include <com-core_packet.h>
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-#include <widget_cmd_list.h>
-#include <widget_conf.h>
-
-#include "debug.h"
-#include "slave_life.h"
-#include "slave_rpc.h"
-#include "client_life.h"
-#include "package.h"
-#include "fault_manager.h"
-#include "util.h"
-#include "conf.h"
-#include "instance.h"
-
-struct slave_rpc {
-       Ecore_Timer *pong_timer;
-       int handle;
-
-       unsigned long ping_count;
-       unsigned long next_ping_count;
-       Eina_List *pending_list;
-};
-
-struct command {
-       /* create_command, destroy_command will care these varaibles */
-       char *pkgname;
-       struct packet *packet;
-       struct slave_node *slave;
-       int ttl; /* If it fails to handle this, destroy this */
-
-       /* Don't need to care these data */
-       void (*ret_cb)(struct slave_node *slave, const struct packet *packet, void *cbdata);
-       void *cbdata;
-};
-
-static struct info {
-       Eina_List *command_list;
-       Ecore_Timer *command_consuming_timer;
-} s_info = {
-       .command_list = NULL,
-       .command_consuming_timer = NULL,
-};
-
-#define DEFAULT_CMD_TTL 3
-
-static void prepend_command(struct command *command);
-
-static inline struct command *create_command(struct slave_node *slave, const char *pkgname, struct packet *packet)
-{
-       struct command *command;
-
-       command = calloc(1, sizeof(*command));
-       if (!command) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       if (pkgname) {
-               command->pkgname = strdup(pkgname);
-               if (!command->pkgname) {
-                       ErrPrint("strdup: %d\n", errno);
-                       DbgFree(command);
-                       return NULL;
-               }
-       }
-
-       command->slave = slave_ref(slave); /*!< To prevent from destroying of the slave while communicating with the slave */
-       command->packet = packet_ref(packet);
-       command->ttl = DEFAULT_CMD_TTL;
-
-       return command;
-}
-
-static inline void destroy_command(struct command *command)
-{
-       slave_unref(command->slave);
-       packet_unref(command->packet);
-       DbgFree(command->pkgname);
-       DbgFree(command);
-}
-
-static inline struct command *pop_command(void)
-{
-       struct command *command;
-
-       command = eina_list_nth(s_info.command_list, 0);
-       if (!command) {
-               return NULL;
-       }
-
-       s_info.command_list = eina_list_remove(s_info.command_list, command);
-       return command;
-}
-
-static int slave_async_cb(pid_t pid, int handle, const struct packet *packet, void *data)
-{
-       struct command *command = data;
-
-       if (!command) {
-               ErrPrint("Command is NIL\n");
-               return WIDGET_ERROR_NONE;
-       }
-
-       /*!
-        * \note
-        * command->packet is not valid from here.
-        */
-       if (!slave_is_activated(command->slave)) {
-               ErrPrint("Slave is not activated (accidently dead)\n");
-               if (command->ret_cb) {
-                       command->ret_cb(command->slave, packet, command->cbdata);
-               }
-               goto out;
-       }
-
-       if (!packet) {
-               DbgPrint("packet == NULL\n");
-               if (command->ret_cb) {
-                       command->ret_cb(command->slave, packet, command->cbdata);
-               }
-
-               /*
-                * \NOTE
-                * Slave will be deactivated from dead monitor if it lost its connections.
-                * So we don't need to care it again from here.
-
-                command->slave = slave_deactivated_by_fault(command->slave);
-
-                */
-               goto out;
-       }
-
-       if (command->ret_cb) {
-               command->ret_cb(command->slave, packet, command->cbdata);
-       }
-
-out:
-       destroy_command(command);
-       return WIDGET_ERROR_NONE;
-}
-
-static Eina_Bool command_consumer_cb(void *data)
-{
-       struct command *command;
-       struct slave_rpc *rpc;
-
-       command = pop_command();
-       if (!command) {
-               s_info.command_consuming_timer = NULL;
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       if (!slave_is_activated(command->slave)) {
-               ErrPrint("Slave is not activated: %s(%d)\n",
-                               slave_name(command->slave), slave_pid(command->slave));
-               goto errout;
-       }
-
-       if (command->pkgname) {
-               struct pkg_info *info;
-
-               info = package_find(command->pkgname);
-               if (info && package_is_fault(info)) {
-                       ErrPrint("info: %p (%s) is fault package\n", info, command->pkgname);
-                       // goto errout;
-               }
-       }
-
-       rpc = slave_data(command->slave, "rpc");
-       if (!rpc || rpc->handle < 0) {
-               ErrPrint("Slave has no rpc info\n");
-               goto errout;
-       }
-
-       if (packet_type(command->packet) == PACKET_REQ_NOACK) {
-               if (com_core_packet_send_only(rpc->handle, command->packet) == 0) {
-                       /* Keep a slave alive, while processing events */
-                       slave_give_more_ttl(command->slave);
-                       destroy_command(command);
-                       return ECORE_CALLBACK_RENEW;
-               }
-       } else if (packet_type(command->packet) == PACKET_REQ) {
-               if (com_core_packet_async_send(rpc->handle, command->packet, 0.0f, slave_async_cb, command) == 0) {
-                       /* Keep a slave alive, while processing events */
-                       slave_give_more_ttl(command->slave);
-                       return ECORE_CALLBACK_RENEW;
-               }
-       }
-
-       /*!
-        * \WARN
-        * What happens at here?
-        * We are failed to send a packet!!!
-        * Let's try to send this again
-        */
-       /*!
-        * \todo
-        * Do we need to handle this error?
-        * Close current connection and make new one?
-        * how about pended command lists?
-        */
-       DbgPrint("Packet type: %d\n", packet_type(command->packet));
-       DbgPrint("Packet: %p\n", command->packet);
-       DbgPrint("Handle: %d\n", rpc->handle);
-       DbgPrint("PID: %d\n", slave_pid(command->slave));
-       DbgPrint("Name: %s\n", slave_name(command->slave));
-       DbgPrint("Package: %s\n", command->pkgname);
-       command->ttl--;
-       if (command->ttl == 0) {
-               DbgPrint("Discard packet (%d)\n", command->ttl);
-               destroy_command(command);
-       } else {
-               DbgPrint("Send again (%d)\n", command->ttl);
-               prepend_command(command);
-       }
-       return ECORE_CALLBACK_RENEW;
-
-errout:
-       if (command->ret_cb) {
-               command->ret_cb(command->slave, NULL, command->cbdata);
-       }
-
-       destroy_command(command);
-       return ECORE_CALLBACK_RENEW;
-}
-
-static void prepend_command(struct command *command)
-{
-       s_info.command_list = eina_list_prepend(s_info.command_list, command);
-
-       if (s_info.command_consuming_timer) {
-               return;
-       }
-
-       s_info.command_consuming_timer = ecore_timer_add(WIDGET_CONF_PACKET_TIME, command_consumer_cb, NULL);
-       if (!s_info.command_consuming_timer) {
-               ErrPrint("Failed to add command consumer\n");
-               s_info.command_list = eina_list_remove(s_info.command_list, command);
-               destroy_command(command);
-       }
-}
-
-static void push_command(struct command *command)
-{
-       s_info.command_list = eina_list_append(s_info.command_list, command);
-
-       if (s_info.command_consuming_timer) {
-               return;
-       }
-
-       s_info.command_consuming_timer = ecore_timer_add(WIDGET_CONF_PACKET_TIME, command_consumer_cb, NULL);
-       if (!s_info.command_consuming_timer) {
-               ErrPrint("Failed to add command consumer\n");
-               s_info.command_list = eina_list_remove(s_info.command_list, command);
-               destroy_command(command);
-       }
-}
-
-static int slave_deactivate_cb(struct slave_node *slave, void *data)
-{
-       struct slave_rpc *rpc;
-       struct command *command;
-       Eina_List *l;
-       Eina_List *n;
-
-       rpc = slave_data(slave, "rpc");
-       if (!rpc) {
-               /*!
-                * \note
-                * Return negative value will remove this callback from the event list of the slave
-                */
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (rpc->pong_timer) {
-               ecore_timer_del(rpc->pong_timer);
-               rpc->pong_timer = NULL;
-       } else {
-               ErrPrint("slave has no pong timer\n");
-       }
-
-       if (rpc->handle < 0) {
-               EINA_LIST_FREE(rpc->pending_list, command) {
-                       assert(command->slave == slave);
-                       if (command->ret_cb) {
-                               command->ret_cb(command->slave, NULL, command->cbdata);
-                       }
-                       destroy_command(command);
-               }
-       } else {
-               EINA_LIST_FOREACH_SAFE(s_info.command_list, l, n, command) {
-                       if (command->slave == slave) {
-                               s_info.command_list = eina_list_remove(s_info.command_list, command);
-                               if (command->ret_cb) {
-                                       command->ret_cb(command->slave, NULL, command->cbdata);
-                               }
-                               destroy_command(command);
-                       }
-               }
-       }
-
-       /*!
-        * \note
-        * Reset handle
-        */
-       DbgPrint("Reset handle for %d (%d)\n", slave_pid(slave), rpc->handle);
-       rpc->handle = -1;
-
-       /*!
-        * \todo
-        * Make statistics table
-        */
-       rpc->ping_count = 0;
-       rpc->next_ping_count = 1;
-       return WIDGET_ERROR_NONE;
-}
-
-static Eina_Bool ping_timeout_cb(void *data)
-{
-       struct slave_rpc *rpc;
-       struct slave_node *slave = data;
-
-       rpc = slave_data(slave, "rpc");
-       if (!rpc) {
-               ErrPrint("Slave RPC is not valid (%s)\n", slave_name(slave));
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       /*!
-        * \note
-        * Clear the pong_timer
-        */
-       rpc->pong_timer = NULL;
-
-       if (!slave_is_activated(slave)) {
-               ErrPrint("Slave is not activated (%s)\n", slave_name(slave));
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       /*!
-        * Dead callback will handling this
-        */
-       DbgPrint("Slave PING TIMEOUT: %s(%d) : %p\n", slave_name(slave), slave_pid(slave), slave);
-       slave = slave_deactivated_by_fault(slave);
-       if (!slave) {
-               DbgPrint("Slave is deleted\n");
-       }
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-HAPI int slave_rpc_async_request(struct slave_node *slave, const char *pkgname, struct packet *packet, void (*ret_cb)(struct slave_node *slave, const struct packet *packet, void *data), void *data, int urgent)
-{
-       struct command *command;
-       struct slave_rpc *rpc;
-
-       command = create_command(slave, pkgname, packet);
-       if (!command) {
-               ErrPrint("Failed to create command\n");
-
-               if (ret_cb) {
-                       ret_cb(slave, NULL, data);
-               }
-
-               packet_unref(packet);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       command->ret_cb = ret_cb;
-       command->cbdata = data;
-       packet_unref(packet);
-
-       rpc = slave_data(slave, "rpc");
-       if (!rpc) {
-               ErrPrint("Slave has no RPC\n");
-               if (ret_cb) {
-                       ret_cb(slave, NULL, data);
-               }
-               destroy_command(command);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (rpc->handle < 0) {
-               DbgPrint("RPC handle is not ready to use it\n");
-               if (((slave_control_option(slave) & PROVIDER_CTRL_MANUAL_REACTIVATION) == PROVIDER_CTRL_MANUAL_REACTIVATION || slave_is_secured(slave) || slave_is_app(slave) || (WIDGET_IS_INHOUSE(slave_abi(slave)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL))
-                               && !slave_is_activated(slave))
-               {
-                       int ret;
-                       DbgPrint("Activate slave forcely\n");
-                       ret = slave_activate(slave);
-                       if (ret < 0 && ret != WIDGET_ERROR_ALREADY_STARTED) {
-
-                               if (ret_cb) {
-                                       ret_cb(slave, NULL, data);
-                               }
-
-                               destroy_command(command);
-                               return ret;
-                       }
-               }
-
-               if (urgent) {
-                       rpc->pending_list = eina_list_prepend(rpc->pending_list, command);
-               } else {
-                       rpc->pending_list = eina_list_append(rpc->pending_list, command);
-               }
-
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (urgent) {
-               prepend_command(command);
-       } else {
-               push_command(command);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_rpc_request_only(struct slave_node *slave, const char *pkgname, struct packet *packet, int urgent)
-{
-       struct command *command;
-       struct slave_rpc *rpc;
-
-       command = create_command(slave, pkgname, packet);
-       if (!command) {
-               ErrPrint("Failed to create a command\n");
-               packet_unref(packet);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       command->ret_cb = NULL;
-       command->cbdata = NULL;
-       packet_unref(packet);
-
-       rpc = slave_data(slave, "rpc");
-       if (!rpc) {
-               ErrPrint("Slave has no RPC\n");
-               destroy_command(command);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (rpc->handle < 0) {
-               DbgPrint("RPC handle is not ready to use it\n");
-               if (((slave_control_option(slave) & PROVIDER_CTRL_MANUAL_REACTIVATION) == PROVIDER_CTRL_MANUAL_REACTIVATION || slave_is_secured(slave) || slave_is_app(slave) || (WIDGET_IS_INHOUSE(slave_abi(slave)) && WIDGET_CONF_SLAVE_LIMIT_TO_TTL))
-                               && !slave_is_activated(slave))
-               {
-                       int ret;
-
-                       DbgPrint("Activate slave forcely\n");
-                       ret = slave_activate(slave);
-                       if (ret < 0 && ret != WIDGET_ERROR_ALREADY_STARTED) {
-                               destroy_command(command);
-                               return ret;
-                       }
-               }
-
-               if (urgent) {
-                       rpc->pending_list = eina_list_prepend(rpc->pending_list, command);
-               } else {
-                       rpc->pending_list = eina_list_append(rpc->pending_list, command);
-               }
-
-               return WIDGET_ERROR_NONE;
-       }
-
-       if (urgent) {
-               prepend_command(command);
-       } else {
-               push_command(command);
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_rpc_update_handle(struct slave_node *slave, int handle, int delete_pended_create_packet)
-{
-       struct slave_rpc *rpc;
-       struct command *command;
-
-       rpc = slave_data(slave, "rpc");
-       if (!rpc) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       DbgPrint("SLAVE: New handle assigned for %d, %d\n", slave_pid(slave), handle);
-       rpc->handle = handle;
-       if (rpc->pong_timer) {
-               ecore_timer_del(rpc->pong_timer);
-       }
-
-       if (slave_extra_bundle_data(slave)) {
-               ErrPrint("Disable WATCHDOG for debugging\n");
-               rpc->pong_timer = NULL;
-       } else {
-               rpc->pong_timer = ecore_timer_add(WIDGET_CONF_DEFAULT_PING_TIME, ping_timeout_cb, slave);
-               if (!rpc->pong_timer) {
-                       ErrPrint("Failed to add ping timer\n");
-               }
-       }
-
-       /*!
-        * \note
-        * slave_activated will call the activated callback.
-        * activated callback will try to recover the normal instances state.
-        * so the reset_fault should be called after slave_activated function.
-        */
-       slave_activated(slave);
-
-       EINA_LIST_FREE(rpc->pending_list, command) {
-               if (delete_pended_create_packet) {
-                       const char *cmd;
-
-                       cmd = packet_command(command->packet);
-                       if (cmd) {
-                               if (cmd[0] == PACKET_CMD_INT_TAG) {
-                                       int cmd_idx;
-
-                                       cmd_idx = *((int *)cmd);
-                                       if (cmd_idx == CMD_NEW) {
-                                               /**
-                                                * @note
-                                                * CMD_NEW or CMD_STR_NEW will have instance via cbdata.
-                                                * And its refcnt is increased before put request packet in to pendling list.
-                                                * So, To destroy it, we should decrease its refcnt from here.
-                                                */
-                                               if (command->cbdata) {
-                                                       instance_unref((struct inst_info *)command->cbdata);
-                                                       command->cbdata = NULL;
-                                               }
-                                               destroy_command(command);
-                                       } else {
-                                               push_command(command);
-                                       }
-                               } else if (!strcmp(cmd, CMD_STR_NEW)) {
-                                       if (command->cbdata) {
-                                               instance_unref((struct inst_info *)command->cbdata);
-                                               command->cbdata = NULL;
-                                       }
-                                       destroy_command(command);
-                               } else {
-                                       push_command(command);
-                               }
-                       } else {
-                               ErrPrint("Invalid package: cmd is nil\n");
-                       }
-               } else {
-                       push_command(command);
-               }
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_rpc_init(struct slave_node *slave)
-{
-       struct slave_rpc *rpc;
-
-       rpc = calloc(1, sizeof(*rpc));
-       if (!rpc) {
-               ErrPrint("calloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       if (slave_set_data(slave, "rpc", rpc) < 0) {
-               DbgFree(rpc);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_deactivate_cb, NULL) < 0) {
-               ErrPrint("Failed to add deactivate event callback\n");
-       }
-
-       rpc->ping_count = 0;
-       rpc->next_ping_count = 1;
-       rpc->handle = -1;
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_rpc_fini(struct slave_node *slave)
-{
-       struct slave_rpc *rpc;
-
-       rpc = slave_del_data(slave, "rpc");
-       if (!rpc) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_deactivate_cb, NULL);
-
-       if (rpc->pong_timer) {
-               ecore_timer_del(rpc->pong_timer);
-       }
-
-       DbgFree(rpc);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_rpc_ping(struct slave_node *slave)
-{
-       struct slave_rpc *rpc;
-
-       rpc = slave_data(slave, "rpc");
-       if (!rpc) {
-               ErrPrint("Slave RPC is not valid\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (!slave_is_activated(slave)) {
-               ErrPrint("Slave is not activated\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!rpc->pong_timer) {
-               ErrPrint("Watchdog is not enabled\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       rpc->ping_count++;
-       if (rpc->ping_count != rpc->next_ping_count) {
-               ErrPrint("Ping count is not correct\n");
-               rpc->next_ping_count = rpc->ping_count;
-       }
-       rpc->next_ping_count++;
-
-       ecore_timer_reset(rpc->pong_timer);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_rpc_ping_freeze(struct slave_node *slave)
-{
-       struct slave_rpc *rpc;
-
-       rpc = slave_data(slave, "rpc");
-       if (!rpc) {
-               ErrPrint("Slave RPC is not valid\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (!slave_is_activated(slave)) {
-               ErrPrint("Slave is not activated\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!rpc->pong_timer) {
-               ErrPrint("Watchdog is not enabled\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ecore_timer_freeze(rpc->pong_timer);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int slave_rpc_ping_thaw(struct slave_node *slave)
-{
-       struct slave_rpc *rpc;
-
-       rpc = slave_data(slave, "rpc");
-       if (!rpc) {
-               ErrPrint("Slave RPC is not valid\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (!slave_is_activated(slave)) {
-               ErrPrint("Slave is not activated\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!rpc->pong_timer) {
-               ErrPrint("Watchdog is not enabled\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       ecore_timer_thaw(rpc->pong_timer);
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void slave_rpc_request_update(const char *pkgname, const char *id, const char *cluster, const char *category, const char *content, int force)
-{
-       struct slave_node *slave;
-       struct pkg_info *info;
-       struct packet *packet;
-       unsigned int cmd = CMD_UPDATE_CONTENT;
-
-       info = package_find(pkgname);
-       if (!info) {
-               ErrPrint("Failed to find a package\n");
-               return;
-       }
-
-       slave = package_slave(info);
-       if (!slave) {
-               ErrPrint("Failed to find a slave for %s\n", pkgname);
-               return;
-       }
-
-       packet = packet_create_noack((const char *)&cmd, "sssssi", pkgname, id, cluster, category, content, force);
-       if (!packet) {
-               ErrPrint("Failed to create a new param\n");
-               return;
-       }
-
-       (void)slave_rpc_request_only(slave, pkgname, packet, 0);
-}
-
-HAPI int slave_rpc_handle(struct slave_node *slave)
-{
-       struct slave_rpc *rpc;
-
-       rpc = slave_data(slave, "rpc");
-       if (!rpc) {
-               DbgPrint("Slave RPC is not initiated\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return rpc->handle;
-}
-
-HAPI int slave_rpc_disconnect(struct slave_node *slave)
-{
-       struct packet *packet;
-       unsigned int cmd = CMD_DISCONNECT;
-
-       packet = packet_create_noack((const char *)&cmd, "d", util_timestamp());
-       if (!packet) {
-               ErrPrint("Failed to create a packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       DbgPrint("Send disconnection request packet\n");
-       return slave_rpc_request_only(slave, NULL, packet, 0);
-}
-
-/* End of a file */
index 66211b8..d150b6d 100644 (file)
 #include <dlog.h>
 #include <Eina.h>
 #include <Ecore.h>
-#if defined(HAVE_LIVEBOX)
-#include <widget_errno.h>
-#include <widget_conf.h>
-#else
-#include "lite-errno.h"
-#define WIDGET_CONF_IMAGE_PATH "/tmp/"
-#endif
 
 #include "util.h"
 #include "debug.h"
 
 int errno;
 
-HAPI unsigned long util_string_hash(const char *str)
-{
-       unsigned long ret = 0;
-
-       while (*str) {
-               ret += (unsigned long)(*str++);
-       }
-
-       ret %= 371773;
-       return ret;
-}
-
 HAPI double util_timestamp(void)
 {
 #if defined(_USE_ECORE_TIME_GET)
@@ -77,277 +58,52 @@ HAPI double util_timestamp(void)
 #endif
 }
 
-HAPI int util_check_ext(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 WIDGET_ERROR_INVALID_PARAMETER;
-               }
-
-               check_ptr ++;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int util_unlink(const char *filename)
-{
-       char *descfile;
-       int desclen;
-       int ret;
-
-       if (!filename) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       desclen = strlen(filename) + 6; /* .desc */
-       descfile = malloc(desclen);
-       if (!descfile) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       ret = snprintf(descfile, desclen, "%s.desc", filename);
-       if (ret < 0) {
-               ErrPrint("snprintf: %d\n", errno);
-               DbgFree(descfile);
-               return WIDGET_ERROR_FAULT;
-       }
-
-       (void)unlink(descfile);
-       DbgFree(descfile);
-       (void)unlink(filename);
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI char *util_slavename(void)
-{
-       char slavename[BUFSIZ];
-       static unsigned long idx = 0;
-
-       snprintf(slavename, sizeof(slavename), "%lu_%lf", idx++, util_timestamp());
-       return strdup(slavename);
-}
-
-/*!
- * Return size of stroage in Bytes unit.
- */
-HAPI unsigned long long util_free_space(const char *path)
-{
-       struct statvfs st;
-       unsigned long long space;
-
-       if (statvfs(path, &st) < 0) {
-               ErrPrint("statvfs: %d\n", errno);
-               return 0lu;
-       }
-
-       space = (unsigned long long)st.f_bsize * (unsigned long long)st.f_bavail;
-       DbgPrint("Available size: %llu, f_bsize: %lu, f_bavail: %lu\n", space, st.f_bsize, st.f_bavail);
-       /*!
-        * \note
-        * Must have to check the overflow
-        */
-
-       return space;
-}
-
-static inline char *extend_heap(char *buffer, int *sz, int incsz)
-{
-       char *tmp;
-
-       *sz += incsz;
-       tmp = realloc(buffer, *sz);
-       if (!tmp) {
-               ErrPrint("realloc: %d\n", errno);
-               return NULL;
-       }
-
-       return tmp;
-}
-
-HAPI double util_time_delay_for_compensation(double period)
-{
-       unsigned long long curtime;
-       unsigned long long _period;
-       unsigned long long remain;
-       struct timeval tv;
-       double ret;
-
-       if (period == 0.0f) {
-               DbgPrint("Period is ZERO\n");
-               return 0.0f;
-       }
-
-       if (gettimeofday(&tv, NULL) < 0){
-               ErrPrint("gettimeofday: %d\n", errno);
-               return period;
-       }
-
-       curtime = (unsigned long long)tv.tv_sec * 1000000llu + (unsigned long long)tv.tv_usec;
-
-       _period = (unsigned long long)(period * (double)1000000);
-       if (_period == 0llu) {
-               ErrPrint("%lf <> %llu\n", period, _period);
-               return period;
-       }
-
-       remain = curtime % _period;
-
-       ret = (double)remain / (double)1000000;
-       return period - ret;
-}
-
-HAPI void *util_timer_add(double interval, Eina_Bool (*cb)(void *data), void *data)
-{
-       Ecore_Timer *timer;
-       double delay;
-
-       timer = ecore_timer_add(interval, cb, data);
-       if (!timer) {
-               return NULL;
-       }
-
-       delay = util_time_delay_for_compensation(interval) - interval;
-       ecore_timer_delay(timer, delay);
-       DbgPrint("Compensate timer: %lf\n", delay);
-
-       return timer;
-}
-
-HAPI void util_timer_interval_set(void *timer, double interval)
-{
-       double delay;
-       ecore_timer_interval_set(timer, interval);
-
-       delay = util_time_delay_for_compensation(interval) - interval;
-       ecore_timer_delay(timer, delay);
-}
-
-HAPI int util_unlink_files(const char *folder)
-{
-       struct stat info;
-       DIR *handle;
-       struct dirent *entry;
-       char *abspath;
-       int len;
-
-       if (lstat(folder, &info) < 0) {
-               ErrPrint("lstat: %d\n", errno);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       if (!S_ISDIR(info.st_mode)) {
-               ErrPrint("Error: %s is not a folder", folder);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       handle = opendir(folder);
-       if (!handle) {
-               ErrPrint("opendir: %d\n", errno);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       while ((entry = readdir(handle))) {
-               if (!strcmp(entry->d_name, ".")) {
-                       continue;
-               }
-
-               if (!strcmp(entry->d_name, "..")) {
-                       continue;
-               }
-
-               len = strlen(folder) + strlen(entry->d_name) + 3;
-               abspath = calloc(1, len);
-               if (!abspath) {
-                       ErrPrint("calloc: %d\n", errno);
-                       continue;
-               }
-               snprintf(abspath, len - 1, "%s/%s", folder, entry->d_name);
-
-               if (unlink(abspath) < 0) {
-                       DbgPrint("unlink: %d\n", errno);
-               }
-
-               DbgFree(abspath);
-       }
-
-       if (closedir(handle) < 0) {
-               ErrPrint("closedir: %d\n", errno);
-       }
-       return WIDGET_ERROR_NONE;
-}
-
 HAPI void util_setup_log_disk(void)
 {
+#if 0
        int ret;
+#endif
 
-       if (access(WIDGET_CONF_LOG_PATH, R_OK | W_OK | X_OK) == 0) {
-               DbgPrint("[%s] is already accessible\n", WIDGET_CONF_LOG_PATH);
+       if (access(CONF_LOG_PATH, R_OK | W_OK | X_OK) == 0) {
+               DbgPrint("[%s] is already accessible\n", CONF_LOG_PATH);
                return;
        }
 
-       DbgPrint("Initiate the critical log folder [%s]\n", WIDGET_CONF_LOG_PATH);
-       if (mkdir(WIDGET_CONF_LOG_PATH, 0755) < 0) {
+       DbgPrint("Initiate the critical log folder [%s]\n", CONF_LOG_PATH);
+       if (mkdir(CONF_LOG_PATH, 0755) < 0) {
                ErrPrint("mkdir: %d\n", errno);
        } else {
-               if (chmod(WIDGET_CONF_LOG_PATH, 0750) < 0) {
+#if 0
+               if (chmod(CONF_LOG_PATH, 0750) < 0) {
                        ErrPrint("chmod: %d\n", errno);
                }
 
-               if (chown(WIDGET_CONF_LOG_PATH, 5000, 5000) < 0) {
+               if (chown(CONF_LOG_PATH, 5000, 5000) < 0) {
                        ErrPrint("chown: %d\n", errno);
                }
 
-               ret = smack_setlabel(WIDGET_CONF_LOG_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
+               ret = smack_setlabel(CONF_LOG_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
                if (ret != 0) {
-                       ErrPrint("Failed to set SMACK for %s (%d)\n", WIDGET_CONF_LOG_PATH, ret);
+                       ErrPrint("Failed to set SMACK for %s (%d)\n", CONF_LOG_PATH, ret);
                } else {
-                       ret = smack_setlabel(WIDGET_CONF_LOG_PATH, "1", SMACK_LABEL_TRANSMUTE);
-                       DbgPrint("[%s] is successfully created (t: %d)\n", WIDGET_CONF_LOG_PATH, ret);
+                       ret = smack_setlabel(CONF_LOG_PATH, "1", SMACK_LABEL_TRANSMUTE);
+                       DbgPrint("[%s] is successfully created (t: %d)\n", CONF_LOG_PATH, ret);
                }
+#endif
        }
 }
 
-HAPI int util_service_is_enabled(const char *tag)
+HAPI const char *util_basename(const char *name)
 {
-       return !!strcasestr(WIDGET_CONF_SERVICES, tag);
-}
-
-HAPI int util_string_is_in_list(const char *str, const char *haystack)
-{
-       int len;
-       const char *ptr;
-       const char *check;
-
-       if (!str) {
-               return 0;
+       int length;
+       length = name ? strlen(name) : 0;
+       if (!length) {
+               return ".";
        }
 
-       check = ptr = haystack;
-       len = 0;
-       while (*ptr) {
-               switch (*ptr++) {
-               case DELIM:
-                       if (len > 0) {
-                               if (!strncasecmp(str, check, len) && str[len] == '\0') {
-                                       return 1;
-                               }
-                       }
-                       check = ptr;
-                       len = 0;
-                       break;
-               default:
-                       len++;
-                       break;
-               }
-       }
+       while (--length > 0 && name[length] != '/');
 
-       return (len > 0 && !strncmp(str, check, len) && str[len] == '\0');
+       return length <= 0 ? name : (name + length + (name[length] == '/'));
 }
 
 /* End of a file */
diff --git a/src/util_wayland.c b/src/util_wayland.c
deleted file mode 100644 (file)
index 340ad3c..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <Eina.h>
-#include <Ecore_Wayland.h>
-
-#include <dlog.h>
-
-#include "debug.h"
-#include "util.h"
-
-#if defined(HAVE_LIVEBOX)
-#include <widget_errno.h>
-#else
-#include "lite-errno.h"
-#endif
-
-static struct info {
-       int initialized;
-} s_info = {
-       .initialized = 0,
-};
-
-int util_screen_size_get(int *width, int *height)
-{
-       int _width;
-       int _height;
-
-       if (!s_info.initialized) {
-               ErrPrint("Not initialized\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       if (!width) {
-               width = &_width;
-       }
-
-       if (!height) {
-               height = &_height;
-       }
-
-       ecore_wl_screen_size_get(width, height);
-       return WIDGET_ERROR_NONE;
-}
-
-int util_screen_init(void)
-{
-       s_info.initialized = 1;
-       return ecore_wl_init(NULL);
-}
-
-int util_screen_fini(void)
-{
-       s_info.initialized = 0;
-       return ecore_wl_shutdown();
-}
-
-/* End of a file */
diff --git a/src/util_x11.c b/src/util_x11.c
deleted file mode 100644 (file)
index cc62b7f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <Ecore_X.h>
-#include <dlog.h>
-
-#if defined(HAVE_LIVEBOX)
-#include <widget_errno.h>
-#else
-#include "lite-errno.h"
-#endif
-#include "util.h"
-#include "debug.h"
-
-static struct info {
-       int initialized;
-} s_info = {
-       .initialized = 0,
-};
-
-int util_screen_size_get(int *width, int *height)
-{
-       if (!s_info.initialized) {
-               ErrPrint("Not initialized\n");
-               return WIDGET_ERROR_FAULT;
-       }
-       ecore_x_window_size_get(0, width, height);
-       return WIDGET_ERROR_NONE;
-}
-
-int util_screen_init(void)
-{
-       s_info.initialized = 1;
-       return ecore_x_init(NULL);
-}
-
-int util_screen_fini(void)
-{
-       s_info.initialized = 0;
-       return ecore_x_shutdown();
-}
-
-/* End of a file */
-
diff --git a/src/utility_service.c b/src/utility_service.c
deleted file mode 100644 (file)
index e861f5b..0000000
+++ /dev/null
@@ -1,434 +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 <Eina.h>
-
-#include <dlog.h>
-#include <aul.h>
-
-#include <widget_errno.h>
-#include <packet.h>
-
-#include <sys/smack.h>
-
-#include "critical_log.h"
-#include "service_common.h"
-#include "utility_service.h"
-#include "debug.h"
-#include "util.h"
-#include "conf.h"
-
-#ifndef SVC_PKG
-#define SVC_PKG                "org.tizen.data-provider-slave.icon"
-#endif
-
-#ifndef LAUNCH_TIMEOUT
-#define LAUNCH_TIMEOUT 10.0f
-#endif
-
-#ifndef TTL_TIMEOUT
-#define TTL_TIMEOUT    30.0f
-#endif
-
-#define aul_terminate_pid_async(a) aul_terminate_pid(a)
-
-static struct info {
-       Eina_List *pending_list;
-       Eina_List *context_list;
-       struct service_context *svc_ctx;
-
-       struct tcb *svc_daemon;
-       int svc_daemon_is_launched;
-       int svc_daemon_pid;
-
-       struct service_event_item *launch_timer; 
-       struct service_event_item *delay_launcher;
-       struct service_event_item *ttl_timer;
-} s_info = {
-       .pending_list = NULL,
-       .context_list = NULL, /*!< \WARN: This is only used for SERVICE THREAD */
-       .svc_ctx = NULL, /*!< \WARN: This is only used for MAIN THREAD */
-
-       .svc_daemon = NULL,
-       .svc_daemon_is_launched = 0,
-       .svc_daemon_pid = -1,
-
-       .launch_timer = NULL,
-       .delay_launcher = NULL,
-       .ttl_timer = NULL,
-};
-
-struct pending_item {
-       struct tcb *tcb;
-       struct packet *packet;
-};
-
-struct context {
-       struct tcb *tcb;
-       double seq;
-};
-
-static int lazy_launcher_cb(struct service_context *svc_ctx, void *data);
-
-static int put_reply_tcb(struct tcb *tcb, double seq)
-{
-       struct context *ctx;
-
-       ctx = malloc(sizeof(*ctx));
-       if (!ctx) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       ctx->tcb = tcb;
-       ctx->seq = seq;
-
-       s_info.context_list = eina_list_append(s_info.context_list, ctx);
-
-       return WIDGET_ERROR_NONE;
-}
-
-static inline struct tcb *get_reply_tcb(double seq)
-{
-       Eina_List *l;
-       Eina_List *n;
-       struct context *ctx;
-       struct tcb *tcb;
-
-       EINA_LIST_FOREACH_SAFE(s_info.context_list, l, n, ctx) {
-               if (ctx->seq != seq) {
-                       continue;
-               }
-
-               s_info.context_list = eina_list_remove(s_info.context_list, ctx);
-               tcb = ctx->tcb;
-               DbgFree(ctx);
-               return tcb;
-       }
-
-       return NULL;
-}
-
-static inline int flush_pended_request(void)
-{
-       /*!
-        * Flush all pended requests
-        */
-       struct pending_item *item;
-       int ret;
-
-       EINA_LIST_FREE(s_info.pending_list, item) {
-               if (tcb_is_valid(s_info.svc_ctx, s_info.svc_daemon) >= 0) {
-                       ret = service_common_unicast_packet(s_info.svc_daemon, item->packet);
-               } else {
-                       ret = -EFAULT;
-               }
-
-               if (ret < 0) {
-                       if (tcb_is_valid(s_info.svc_ctx, item->tcb) >= 0) {
-                               struct packet *reply;
-                               reply = packet_create_reply(item->packet, "i", ret);
-                               if (service_common_unicast_packet(item->tcb, reply) < 0) {
-                                       ErrPrint("Unable to send packet\n");
-                               }
-                               packet_destroy(reply);
-                       }
-               } else {
-                       put_reply_tcb(item->tcb, packet_seq(item->packet));
-               }
-               packet_unref(item->packet);
-               DbgFree(item);
-       }
-
-       return 0;
-}
-
-static inline int put_pended_request(struct tcb *tcb, struct packet *packet)
-{
-       struct pending_item *item;
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->tcb = tcb;
-       item->packet = packet_ref(packet);
-       if (!item->packet) {
-               DbgFree(item);
-               ErrPrint("Unable to ref packet\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       s_info.pending_list = eina_list_append(s_info.pending_list, item);
-       return 0;
-}
-
-static int launch_timeout_cb(struct service_context *svc_ctx, void *data)
-{
-       struct pending_item *item;
-       struct packet *reply;
-
-       EINA_LIST_FREE(s_info.pending_list, item) {
-               if (tcb_is_valid(s_info.svc_ctx, item->tcb) >= 0) {
-                       reply = packet_create_reply(item->packet, "i", -EFAULT);
-                       if (!reply) {
-                               ErrPrint("Unable to create a packet\n");
-                       } else {
-                               int ret;
-
-                               ret = service_common_unicast_packet(item->tcb, reply);
-                               if (ret < 0) {
-                                       ErrPrint("Failed to send reply packet: %d\n", ret);
-                               }
-
-                               packet_destroy(reply);
-                       }
-               } else {
-                       ErrPrint("TCB is already terminated\n");
-               }
-
-               packet_unref(item->packet);
-               DbgFree(item);
-       }
-
-       s_info.launch_timer = NULL;
-       s_info.svc_daemon_is_launched = 0;
-       s_info.svc_daemon_pid = -1;
-       return -ECANCELED; /* Delete this timer */
-}
-
-static int launch_svc(struct service_context *svc_ctx)
-{
-       pid_t pid;
-       int ret = WIDGET_ERROR_NONE;
-
-       pid = aul_launch_app(SVC_PKG, NULL);
-       switch (pid) {
-       case AUL_R_EHIDDENFORGUEST:     /**< App hidden for guest mode */
-       case AUL_R_ENOLAUNCHPAD:        /**< no launchpad */
-       case AUL_R_EILLACC:             /**< Illegal Access */
-       case AUL_R_EINVAL:              /**< Invalid argument */
-       case AUL_R_ENOINIT:             /**< AUL handler NOT initialized */
-       case AUL_R_ERROR:               /**< General error */
-               ErrPrint("Failed to launch an app: %s(%d)\n", SVC_PKG, pid);
-               ret = WIDGET_ERROR_FAULT;
-               break;
-       case AUL_R_ETIMEOUT:            /**< Timeout */
-       case AUL_R_ECOMM:               /**< Comunication Error */
-       case AUL_R_ETERMINATING:        /**< application terminating */
-       case AUL_R_ECANCELED:           /**< Operation canceled */
-               /* Need time to launch app again */
-               ErrPrint("Terminating now, try to launch this after few sec later: %s(%d)\n", SVC_PKG, pid);
-               s_info.svc_daemon_is_launched = 1;
-               s_info.delay_launcher = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, lazy_launcher_cb, NULL);
-               if (!s_info.delay_launcher) {
-                       ErrPrint("Unable to add delay launcher\n");
-                       ret = WIDGET_ERROR_FAULT;
-               }
-               break;
-       case AUL_R_LOCAL:               /**< Launch by himself */
-       case AUL_R_OK:                  /**< General success */
-       default:
-               DbgPrint("Launched: %s(%d)\n", SVC_PKG, pid);
-               s_info.svc_daemon_is_launched = 1;
-               s_info.svc_daemon_pid = pid;
-               s_info.launch_timer = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, launch_timeout_cb, NULL);
-               if (!s_info.launch_timer) {
-                       ErrPrint("Unable to create launch timer\n");
-               }
-       }
-
-       return ret;
-}
-
-static int lazy_launcher_cb(struct service_context *svc_ctx, void *data)
-{
-       s_info.delay_launcher = NULL;
-
-       (void)launch_svc(svc_ctx);
-       return -ECANCELED;
-}
-
-static int ttl_timer_cb(struct service_context *svc_ctx, void *data)
-{
-       DbgPrint("TTL Timer is expired: PID(%d)\n", s_info.svc_daemon_pid);
-       (void)aul_terminate_pid_async(s_info.svc_daemon_pid);
-
-       s_info.ttl_timer = NULL;
-       s_info.svc_daemon_is_launched = 0;
-       s_info.svc_daemon_pid = -1;
-       s_info.svc_daemon = NULL;
-       return -ECANCELED;
-}
-
-static int service_thread_main(struct tcb *tcb, struct packet *packet, void *data)
-{
-       struct packet *reply;
-       const char *cmd;
-       int ret;
-
-       if (!packet) {
-               DbgPrint("TCB %p is terminated (NIL packet), %d\n", tcb, s_info.svc_daemon_pid);
-
-               if (tcb == s_info.svc_daemon) {
-                       s_info.svc_daemon = NULL;
-                       s_info.svc_daemon_is_launched = 0;
-                       s_info.svc_daemon_pid = -1;
-
-                       if (s_info.ttl_timer) {
-                               service_common_del_timer(tcb_svc_ctx(tcb), s_info.ttl_timer);
-                               s_info.ttl_timer = NULL;
-                       }
-               }
-
-               return WIDGET_ERROR_NONE;
-       }
-
-       cmd = packet_command(packet);
-       if (!cmd) {
-               ErrPrint("Invalid packet\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       switch (packet_type(packet)) {
-       case PACKET_REQ:
-               if (!s_info.svc_daemon_is_launched) {
-                       ret = launch_svc(tcb_svc_ctx(tcb));
-                       if (ret != WIDGET_ERROR_NONE) {
-                               goto reply_out;
-                       }
-               }
-
-               if (!s_info.svc_daemon) {
-                       ret = put_pended_request(tcb, packet);
-                       if (ret < 0) {
-                               goto reply_out;
-                       }
-               } else if (tcb_is_valid(s_info.svc_ctx, s_info.svc_daemon) >= 0) { 
-                       ret = service_common_unicast_packet(s_info.svc_daemon, packet);
-                       if (ret <0) {
-                               goto reply_out;
-                       }
-
-                       put_reply_tcb(tcb, packet_seq(packet));
-
-                       if (s_info.ttl_timer && service_common_update_timer(s_info.ttl_timer, TTL_TIMEOUT) < 0) {
-                               ErrPrint("Failed to update timer\n");
-                       }
-               }
-
-               break;
-       case PACKET_REQ_NOACK:
-               if (!strcmp(cmd, "service_register")) {
-                       if (!s_info.svc_daemon_is_launched) {
-                               ErrPrint("Service daemon is not launched. but something tries to register a service\n");
-                               return WIDGET_ERROR_INVALID_PARAMETER;
-                       }
-
-                       if (s_info.svc_daemon) {
-                               ErrPrint("Service daemon is already prepared\n");
-                               return WIDGET_ERROR_INVALID_PARAMETER;
-                       }
-
-                       if (s_info.launch_timer) {
-                               service_common_del_timer(tcb_svc_ctx(tcb), s_info.launch_timer);
-                               s_info.launch_timer = NULL;
-                       }
-
-                       s_info.ttl_timer = service_common_add_timer(tcb_svc_ctx(tcb), TTL_TIMEOUT, ttl_timer_cb, NULL);
-                       if (!s_info.ttl_timer) {
-                               ErrPrint("Failed to add TTL timer\n");
-                               if (s_info.svc_daemon_pid > 0) {
-                                       ret = aul_terminate_pid_async(s_info.svc_daemon_pid);
-                                       ErrPrint("Terminate: %d\n", ret);
-                                       s_info.svc_daemon_pid = -1;
-                               }
-                               s_info.svc_daemon_is_launched = 0;
-                               return WIDGET_ERROR_FAULT;
-                       }
-                       DbgPrint("TTL Timer is added: %p\n", s_info.ttl_timer);
-
-                       s_info.svc_daemon = tcb;
-                       flush_pended_request();
-               }
-               break;
-       case PACKET_ACK:
-               tcb = get_reply_tcb(packet_seq(packet));
-               if (!tcb) {
-                       ErrPrint("Unable to find reply tcb\n");
-                       break;
-               }
-
-               if (tcb_is_valid(s_info.svc_ctx, tcb) < 0) {
-                       ErrPrint("TCB is not valid\n");
-                       break;
-               }
-
-               ret = service_common_unicast_packet(tcb, packet);
-               if (ret < 0) {
-                       ErrPrint("Unable to forward the reply packet\n");
-               }
-               break;
-       default:
-               ErrPrint("Packet type is not valid[%s]\n", cmd);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-
-reply_out:
-       ErrPrint("Error: %d\n", ret);
-       reply = packet_create_reply(packet, "i", ret);
-       if (service_common_unicast_packet(tcb, reply) < 0) {
-               ErrPrint("Unable to send reply packet\n");
-       }
-       packet_destroy(reply);
-       return ret;
-}
-
-int utility_service_init(void)
-{
-       if (s_info.svc_ctx) {
-               ErrPrint("Already initialized\n");
-               return WIDGET_ERROR_ALREADY_STARTED;
-       }
-
-       s_info.svc_ctx = service_common_create("sdlocal://"UTILITY_SOCKET, UTILITY_SMACK_LABEL, service_thread_main, NULL);
-       if (!s_info.svc_ctx) {
-               ErrPrint("Unable to activate service thread\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       DbgPrint("Successfully initiated\n");
-       return WIDGET_ERROR_NONE;
-}
-
-int utility_service_fini(void)
-{
-       if (!s_info.svc_ctx) {
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       service_common_destroy(s_info.svc_ctx);
-       s_info.svc_ctx = NULL;
-       DbgPrint("Successfully Finalized\n");
-       return WIDGET_ERROR_NONE;
-}
-
-/* End of a file */
diff --git a/src/widget-mgr.c b/src/widget-mgr.c
deleted file mode 100644 (file)
index f701ff3..0000000
+++ /dev/null
@@ -1,214 +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 <errno.h>
-#include <unistd.h>
-#include <libgen.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <Eina.h>
-
-#include <dlog.h>
-#include <widget_errno.h>
-
-#include "util.h"
-#include "debug.h"
-#include "conf.h"
-
-int errno;
-
-static struct info {
-       Eina_List *info_list;
-} s_info = {
-       .info_list = NULL,
-};
-
-struct widget_mgr {
-       FILE *fp;
-       char fifo_name[60];
-       pid_t pid;
-       int handle;
-       void *data;
-};
-
-HAPI int widget_mgr_init(void)
-{
-       return 0;
-}
-
-HAPI void widget_mgr_fini(void)
-{
-       struct widget_mgr *info;
-
-       EINA_LIST_FREE(s_info.info_list, info) {
-               if (fclose(info->fp) != 0) {
-                       ErrPrint("fclose: %d\n", errno);
-               }
-               if (unlink(info->fifo_name) < 0) {
-                       ErrPrint("unlink: %d\n", errno);
-               }
-               DbgFree(info);
-       }
-}
-
-HAPI int widget_mgr_is_valid_requestor(pid_t pid)
-{
-       char cmdline[60]; /* strlen("/proc/%d/cmdline") + 30 */
-       struct stat target;
-       struct stat src;
-
-       snprintf(cmdline, sizeof(cmdline), "/proc/%d/exe", pid);
-
-       DbgPrint("Open cmdline: %s (%d)\n", cmdline, pid);
-
-       if (stat(cmdline, &target) < 0) {
-               ErrPrint("Error: %d\n", errno);
-               return 0;
-       }
-
-       if (stat("/opt/usr/devel/usr/bin/widget-mgr", &src) < 0) {
-               ErrPrint("Error: %d\n", errno);
-               return 0;
-       }
-
-       return target.st_ino == src.st_ino;
-}
-
-HAPI void widget_mgr_set_data(struct widget_mgr *info, void *data)
-{
-       info->data = data;
-}
-
-HAPI void *widget_mgr_data(struct widget_mgr *info)
-{
-       return info->data;
-}
-
-HAPI struct widget_mgr *widget_mgr_create(pid_t pid, int handle)
-{
-       struct widget_mgr *info;
-
-       if (!widget_mgr_is_valid_requestor(pid)) {
-               ErrPrint("Invalid requestor\n");
-               return NULL;
-       }
-
-       info = calloc(1, sizeof(*info));
-       if (!info) {
-               ErrPrint("calloc: %d\n", errno);
-               return NULL;
-       }
-
-       snprintf(info->fifo_name, sizeof(info->fifo_name), "/tmp/.live_info.%lf", util_timestamp());
-       if (mkfifo(info->fifo_name, 0644) < 0) {
-               ErrPrint("mkfifo: %d\n", errno);
-               if (unlink(info->fifo_name) < 0) {
-                       ErrPrint("unlink: %d\n", errno);
-               }
-               DbgFree(info);
-               return NULL;
-       }
-
-       info->fp = NULL;
-       info->pid = pid;
-       info->handle = handle;
-
-       DbgPrint("Live info is successfully created\n");
-       s_info.info_list = eina_list_append(s_info.info_list, info);
-       return info;
-}
-
-HAPI int widget_mgr_open_fifo(struct widget_mgr *info)
-{
-       DbgPrint("FIFO is created (%s)\n", info->fifo_name);
-       info->fp = fopen(info->fifo_name, "w");
-       if (!info->fp) {
-               ErrPrint("open: %d\n", errno);
-               return WIDGET_ERROR_IO_ERROR;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void widget_mgr_close_fifo(struct widget_mgr *info)
-{
-       if (info->fp) {
-               if (fclose(info->fp) != 0) {
-                       ErrPrint("fclose: %d\n", errno);
-               }
-               info->fp = NULL;
-       }
-}
-
-HAPI void widget_mgr_destroy(struct widget_mgr *info)
-{
-       s_info.info_list = eina_list_remove(s_info.info_list, info);
-       widget_mgr_close_fifo(info);
-       if (unlink(info->fifo_name) < 0) {
-               ErrPrint("unlink: %d\n", errno);
-       }
-       DbgFree(info);
-}
-
-HAPI pid_t widget_mgr_pid(struct widget_mgr *info)
-{
-       return info ? info->pid : (pid_t)-1;
-}
-
-HAPI const char *widget_mgr_filename(struct widget_mgr *info)
-{
-       return info ? info->fifo_name : NULL;
-}
-
-HAPI FILE *widget_mgr_fifo(struct widget_mgr *info)
-{
-       return info ? info->fp : NULL;
-}
-
-HAPI struct widget_mgr *widget_mgr_find_by_pid(pid_t pid)
-{
-       Eina_List *l;
-       struct widget_mgr *info;
-
-       EINA_LIST_FOREACH(s_info.info_list, l, info) {
-               if (info->pid == pid) {
-                       return info;
-               }
-       }
-
-       return NULL;
-}
-
-HAPI struct widget_mgr *widget_mgr_find_by_handle(int handle)
-{
-       Eina_List *l;
-       struct widget_mgr *info;
-
-       EINA_LIST_FOREACH(s_info.info_list, l, info) {
-               if (info->handle == handle) {
-                       return info;
-               }
-       }
-
-       return NULL;
-}
-
-/* End of a file */
diff --git a/src/xmonitor.c b/src/xmonitor.c
deleted file mode 100644 (file)
index b2c8a6c..0000000
+++ /dev/null
@@ -1,491 +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 <sys/ipc.h>
-#include <sys/shm.h>
-#include <assert.h>
-#include <errno.h>
-#include <malloc.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <Ecore_X.h>
-#include <Ecore.h>
-
-#include <sqlite3.h>
-
-#include <gio/gio.h>
-#include <dlog.h>
-#include <widget_errno.h>
-#include <widget_conf.h>
-
-#include "conf.h"
-#include "debug.h"
-#include "client_life.h"
-#include "slave_life.h"
-#include "main.h"
-#include "util.h"
-#include "setting.h"
-#include "xmonitor.h"
-
-int errno;
-
-struct event_item {
-       int (*cb)(void *user_data);
-       void *user_data;
-};
-
-static struct info {
-       Ecore_Event_Handler *create_handler;
-       Ecore_Event_Handler *destroy_handler;
-       Ecore_Event_Handler *client_handler;
-
-       Eina_List *pause_list;
-       Eina_List *resume_list;
-
-       int paused;
-} s_info = {
-       .create_handler = NULL,
-       .destroy_handler = NULL,
-       .client_handler = NULL,
-
-       .pause_list = NULL,
-       .resume_list = NULL,
-
-       .paused = 1, /*!< The provider is treated as paused process when it is launched */
-};
-
-static inline void touch_paused_file(void)
-{
-       int fd;
-       fd = creat(WIDGET_CONF_PAUSED_FILE, 0644);
-       if (fd >= 0) {
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-       } else {
-               ErrPrint("Create .live.paused: %d\n", errno);
-       }
-}
-
-static inline void remove_paused_file(void)
-{
-       if (unlink(WIDGET_CONF_PAUSED_FILE) < 0) {
-               ErrPrint("Unlink .live.paused: %d\n", errno);
-       }
-}
-
-static inline int get_pid(Ecore_X_Window win)
-{
-       int pid;
-       Ecore_X_Atom atom;
-       unsigned char *in_pid = NULL;
-       int num;
-
-       atom = ecore_x_atom_get("X_CLIENT_PID");
-       if (ecore_x_window_prop_property_get(win, atom, ECORE_X_ATOM_CARDINAL,
-                               sizeof(int), &in_pid, &num) == EINA_FALSE) {
-               if (ecore_x_netwm_pid_get(win, &pid) == EINA_FALSE) {
-                       ErrPrint("Failed to get PID from a window 0x%X\n", win);
-                       return WIDGET_ERROR_INVALID_PARAMETER;
-               }
-       } else if (in_pid) {
-               pid = *(int *)in_pid;
-               DbgFree(in_pid);
-       } else {
-               ErrPrint("Failed to get PID\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return pid;
-}
-
-static Eina_Bool create_cb(void *data, int type, void *event)
-{
-       Ecore_X_Event_Window_Create *info = event;
-       ecore_x_window_client_sniff(info->win);
-       return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool destroy_cb(void *data, int type, void *event)
-{
-       // Ecore_X_Event_Window_Destroy *info = event;
-       return ECORE_CALLBACK_PASS_ON;
-}
-
-HAPI void xmonitor_handle_state_changes(void)
-{
-       int paused;
-       Eina_List *l;
-       struct event_item *item;
-
-       paused = client_is_all_paused() || setting_is_lcd_off();
-       if (s_info.paused == paused) {
-               return;
-       }
-
-       s_info.paused = paused;
-
-       if (s_info.paused) {
-               EINA_LIST_FOREACH(s_info.pause_list, l, item) {
-                       if (item->cb) {
-                               item->cb(item->user_data);
-                       }
-               }
-
-               touch_paused_file();
-
-               sqlite3_release_memory(WIDGET_CONF_SQLITE_FLUSH_MAX);
-               malloc_trim(0);
-       } else {
-               remove_paused_file();
-
-               EINA_LIST_FOREACH(s_info.resume_list, l, item) {
-                       if (item->cb) {
-                               item->cb(item->user_data);
-                       }
-               }
-       }
-}
-
-HAPI int xmonitor_update_state(int target_pid)
-{
-       Ecore_X_Window win;
-       struct client_node *client;
-       int pid;
-
-       if (!WIDGET_CONF_USE_XMONITOR || target_pid < 0) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       win = ecore_x_window_focus_get();
-
-       pid = get_pid(win);
-       if (pid <= 0) {
-               DbgPrint("Focused window has no PID %X\n", win);
-               client = client_find_by_pid(target_pid);
-               if (client) {
-                       DbgPrint("Client window has no focus now\n");
-                       client_paused(client);
-               }
-               return WIDGET_ERROR_NOT_EXIST;
-       }
-
-       client = client_find_by_pid(pid);
-       if (!client) {
-               DbgPrint("Client %d is not registered yet\n", pid);
-               client = client_find_by_pid(target_pid);
-               if (client) {
-                       DbgPrint("Client window has no focus now\n");
-                       client_paused(client);
-               }
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       if (target_pid != pid) {
-               DbgPrint("Client is paused\n");
-               client_paused(client);
-       } else {
-               DbgPrint("Client is resumed\n");
-               client_resumed(client);
-       }
-
-       xmonitor_handle_state_changes();
-       return WIDGET_ERROR_NONE;
-}
-
-static Eina_Bool client_cb(void *data, int type, void *event)
-{
-       Ecore_X_Event_Client_Message *info = event;
-       struct client_node *client;
-       char *name;
-       int pid;
-
-       pid = get_pid(info->win);
-       if (pid <= 0) {
-               return ECORE_CALLBACK_PASS_ON;
-       }
-
-       client = client_find_by_pid(pid);
-       if (!client) {
-               return ECORE_CALLBACK_PASS_ON;
-       }
-
-       name = ecore_x_atom_name_get(info->message_type);
-       if (!name) {
-               return ECORE_CALLBACK_PASS_ON;
-       }
-
-       if (!strcmp(name, "_X_ILLUME_DEACTIVATE_WINDOW")) {
-               xmonitor_pause(client);
-       } else if (!strcmp(name, "_X_ILLUME_ACTIVATE_WINDOW")) {
-               xmonitor_resume(client);
-       } else {
-               /* ignore event */
-       }
-
-       DbgFree(name);
-       return ECORE_CALLBACK_PASS_ON;
-}
-
-static inline void sniff_all_windows(void)
-{
-       Ecore_X_Window root;
-       Ecore_X_Window ret;
-       struct stack_item *new_item;
-       struct stack_item *item;
-       Eina_List *win_stack;
-       //int pid;
-       struct stack_item {
-               Ecore_X_Window *wins;
-               int nr_of_wins;
-               int i;
-       };
-
-       root = ecore_x_window_root_first_get();
-       ecore_x_window_sniff(root);
-
-       new_item = malloc(sizeof(*new_item));
-       if (!new_item) {
-               ErrPrint("Error(%d)\n", errno);
-               return;
-       }
-
-       new_item->nr_of_wins = 0;
-       new_item->wins =
-               ecore_x_window_children_get(root, &new_item->nr_of_wins);
-       new_item->i = 0;
-
-       win_stack = NULL;
-
-       if (new_item->wins) {
-               win_stack = eina_list_append(win_stack, new_item);
-       } else {
-               DbgFree(new_item);
-       }
-
-       while ((item = eina_list_nth(win_stack, 0))) {
-               win_stack = eina_list_remove(win_stack, item);
-
-               if (!item->wins) {
-                       DbgFree(item);
-                       continue;
-               }
-
-               while (item->i < item->nr_of_wins) {
-                       ret = item->wins[item->i];
-
-                       /*
-                        * Now we don't need to care about visibility of window,
-                        * just check whether it is registered or not.
-                        * (ecore_x_window_visible_get(ret))
-                        */
-                       ecore_x_window_client_sniff(ret);
-
-                       new_item = malloc(sizeof(*new_item));
-                       if (!new_item) {
-                               ErrPrint("Error %d\n", errno);
-                               item->i++;
-                               continue;
-                       }
-
-                       new_item->i = 0;
-                       new_item->nr_of_wins = 0;
-                       new_item->wins =
-                               ecore_x_window_children_get(ret,
-                                               &new_item->nr_of_wins);
-                       if (new_item->wins) {
-                               win_stack =
-                                       eina_list_append(win_stack, new_item);
-                       } else {
-                               DbgFree(new_item);
-                       }
-
-                       item->i++;
-               }
-
-               DbgFree(item->wins);
-               DbgFree(item);
-       }
-
-       return;
-}
-
-HAPI int xmonitor_pause(struct client_node *client)
-{
-       DbgPrint("%d is paused\n", client_pid(client));
-       client_paused(client);
-       xmonitor_handle_state_changes();
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int xmonitor_resume(struct client_node *client)
-{
-       DbgPrint("%d is resumed\n", client_pid(client));
-       client_resumed(client);
-       xmonitor_handle_state_changes();
-       return WIDGET_ERROR_NONE;
-}
-
-static inline void disable_xmonitor(void)
-{
-       ecore_event_handler_del(s_info.create_handler);
-       ecore_event_handler_del(s_info.destroy_handler);
-       ecore_event_handler_del(s_info.client_handler);
-
-       s_info.create_handler = NULL;
-       s_info.destroy_handler = NULL;
-       s_info.client_handler = NULL;
-}
-
-static inline int enable_xmonitor(void)
-{
-       if (ecore_x_composite_query() == EINA_FALSE) {
-               DbgPrint("====> COMPOSITOR IS NOT ENABLED\n");
-       }
-
-       s_info.create_handler =
-               ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CREATE,
-                               create_cb, NULL);
-       if (!s_info.create_handler) {
-               ErrPrint("Failed to add create event handler\n");
-               return WIDGET_ERROR_FAULT;
-       }
-
-       s_info.destroy_handler =
-               ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY,
-                               destroy_cb, NULL);
-       if (!s_info.destroy_handler) {
-               ErrPrint("Failed to add destroy event handler\n");
-               ecore_event_handler_del(s_info.create_handler);
-               s_info.create_handler = NULL;
-               return WIDGET_ERROR_FAULT;
-       }
-
-       s_info.client_handler =
-               ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
-                               client_cb, NULL);
-       if (!s_info.client_handler) {
-               ErrPrint("Failed to add focus out event handler\n");
-               ecore_event_handler_del(s_info.create_handler);
-               ecore_event_handler_del(s_info.destroy_handler);
-               s_info.create_handler = NULL;
-               s_info.destroy_handler = NULL;
-               return WIDGET_ERROR_FAULT;
-       }
-
-       sniff_all_windows();
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int xmonitor_init(void)
-{
-       if (WIDGET_CONF_USE_XMONITOR) {
-               int ret;
-               ret = enable_xmonitor();
-               if (ret < 0) {
-                       return ret;
-               }
-       }
-
-       s_info.paused = client_is_all_paused() || setting_is_lcd_off();
-       if (s_info.paused) {
-               touch_paused_file();
-       } else {
-               remove_paused_file();
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void xmonitor_fini(void)
-{
-       if (WIDGET_CONF_USE_XMONITOR) {
-               disable_xmonitor();
-       }
-}
-
-HAPI int xmonitor_add_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data)
-{
-       struct event_item *item;
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               ErrPrint("Heap: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->cb = cb;
-       item->user_data = user_data;
-
-       switch (event) {
-       case XMONITOR_PAUSED:
-               s_info.pause_list = eina_list_prepend(s_info.pause_list, item);
-               break;
-       case XMONITOR_RESUMED:
-               s_info.resume_list = eina_list_prepend(s_info.resume_list, item);
-               break;
-       default:
-               ErrPrint("Invalid event type\n");
-               DbgFree(item);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int xmonitor_del_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data)
-{
-       struct event_item *item;
-       Eina_List *l;
-       Eina_List *n;
-
-       switch (event) {
-       case XMONITOR_PAUSED:
-               EINA_LIST_FOREACH_SAFE(s_info.pause_list, l, n, item) {
-                       if (item->cb == cb && item->user_data == user_data) {
-                               s_info.pause_list = eina_list_remove(s_info.pause_list, item);
-                               DbgFree(item);
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-
-       case XMONITOR_RESUMED:
-               EINA_LIST_FOREACH_SAFE(s_info.resume_list, l, n, item) {
-                       if (item->cb == cb && item->user_data == user_data) {
-                               s_info.resume_list = eina_list_remove(s_info.resume_list, item);
-                               DbgFree(item);
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       default:
-               ErrPrint("Invalid event type\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-HAPI int xmonitor_is_paused(void)
-{
-       return s_info.paused;
-}
-
-/* End of a file */
diff --git a/src/xmonitor_wayland.c b/src/xmonitor_wayland.c
deleted file mode 100644 (file)
index fbd0643..0000000
+++ /dev/null
@@ -1,252 +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 <sys/ipc.h>
-#include <sys/shm.h>
-#include <assert.h>
-#include <errno.h>
-#include <malloc.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <sqlite3.h>
-
-#include <gio/gio.h>
-#include <dlog.h>
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_conf.h>
-#include <Ecore.h>
-
-#include "conf.h"
-#include "debug.h"
-#include "client_life.h"
-#include "slave_life.h"
-#include "main.h"
-#include "util.h"
-#include "setting.h"
-#include "xmonitor.h"
-
-int errno;
-
-struct event_item {
-       int (*cb)(void *user_data);
-       void *user_data;
-};
-
-static struct info {
-       Ecore_Event_Handler *create_handler;
-       Ecore_Event_Handler *destroy_handler;
-       Ecore_Event_Handler *client_handler;
-
-       Eina_List *pause_list;
-       Eina_List *resume_list;
-
-       int paused;
-} s_info = {
-       .create_handler = NULL,
-       .destroy_handler = NULL,
-       .client_handler = NULL,
-
-       .pause_list = NULL,
-       .resume_list = NULL,
-
-       .paused = 1, /*!< The provider is treated as paused process when it is launched */
-};
-
-static inline void touch_paused_file(void)
-{
-       int fd;
-       fd = creat(WIDGET_CONF_PAUSED_FILE, 0644);
-       if (fd >= 0) {
-               if (close(fd) < 0) {
-                       ErrPrint("close: %d\n", errno);
-               }
-       } else {
-               ErrPrint("Create .live.paused: %d\n", errno);
-       }
-}
-
-static inline void remove_paused_file(void)
-{
-       if (unlink(WIDGET_CONF_PAUSED_FILE) < 0) {
-               ErrPrint("Unlink .live.paused: %d\n", errno);
-       }
-}
-
-HAPI void xmonitor_handle_state_changes(void)
-{
-       int paused;
-       Eina_List *l;
-       struct event_item *item;
-
-       paused = client_is_all_paused() || setting_is_lcd_off();
-       if (s_info.paused == paused) {
-               return;
-       }
-
-       s_info.paused = paused;
-
-       if (s_info.paused) {
-               EINA_LIST_FOREACH(s_info.pause_list, l, item) {
-                       if (item->cb) {
-                               item->cb(item->user_data);
-                       }
-               }
-
-               touch_paused_file();
-
-               sqlite3_release_memory(WIDGET_CONF_SQLITE_FLUSH_MAX);
-               malloc_trim(0);
-       } else {
-               remove_paused_file();
-
-               EINA_LIST_FOREACH(s_info.resume_list, l, item) {
-                       if (item->cb) {
-                               item->cb(item->user_data);
-                       }
-               }
-       }
-}
-
-HAPI int xmonitor_update_state(int target_pid)
-{
-       if (!WIDGET_CONF_USE_XMONITOR || target_pid < 0) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       /*!
-        * \TODO
-        * Find the top(focuesd) window's PID
-        * Compare it with target_pid.
-        * If it is what we finding, call the
-        * xmonitor_pause or xmonitor_resume
-        */
-
-       xmonitor_handle_state_changes();
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int xmonitor_pause(struct client_node *client)
-{
-       DbgPrint("%d is paused\n", client_pid(client));
-       client_paused(client);
-       xmonitor_handle_state_changes();
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int xmonitor_resume(struct client_node *client)
-{
-       DbgPrint("%d is resumed\n", client_pid(client));
-       client_resumed(client);
-       xmonitor_handle_state_changes();
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int xmonitor_init(void)
-{
-       if (WIDGET_CONF_USE_XMONITOR) {
-               return WIDGET_ERROR_NONE;
-       }
-
-       s_info.paused = client_is_all_paused() || setting_is_lcd_off();
-       if (s_info.paused) {
-               touch_paused_file();
-       } else {
-               remove_paused_file();
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI void xmonitor_fini(void)
-{
-       if (WIDGET_CONF_USE_XMONITOR) {
-       }
-}
-
-HAPI int xmonitor_add_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data)
-{
-       struct event_item *item;
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               ErrPrint("malloc: %d\n", errno);
-               return WIDGET_ERROR_OUT_OF_MEMORY;
-       }
-
-       item->cb = cb;
-       item->user_data = user_data;
-
-       switch (event) {
-       case XMONITOR_PAUSED:
-               s_info.pause_list = eina_list_prepend(s_info.pause_list, item);
-               break;
-       case XMONITOR_RESUMED:
-               s_info.resume_list = eina_list_prepend(s_info.resume_list, item);
-               break;
-       default:
-               ErrPrint("Invalid event type\n");
-               DbgFree(item);
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NONE;
-}
-
-HAPI int xmonitor_del_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data)
-{
-       struct event_item *item;
-       Eina_List *l;
-       Eina_List *n;
-
-       switch (event) {
-       case XMONITOR_PAUSED:
-               EINA_LIST_FOREACH_SAFE(s_info.pause_list, l, n, item) {
-                       if (item->cb == cb && item->user_data == user_data) {
-                               s_info.pause_list = eina_list_remove(s_info.pause_list, item);
-                               DbgFree(item);
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-
-       case XMONITOR_RESUMED:
-               EINA_LIST_FOREACH_SAFE(s_info.resume_list, l, n, item) {
-                       if (item->cb == cb && item->user_data == user_data) {
-                               s_info.resume_list = eina_list_remove(s_info.resume_list, item);
-                               DbgFree(item);
-                               return WIDGET_ERROR_NONE;
-                       }
-               }
-               break;
-       default:
-               ErrPrint("Invalid event type\n");
-               return WIDGET_ERROR_INVALID_PARAMETER;
-       }
-
-       return WIDGET_ERROR_NOT_EXIST;
-}
-
-HAPI int xmonitor_is_paused(void)
-{
-       return s_info.paused;
-}
-
-/* End of a file */
-
diff --git a/widget-mgr/CMakeLists.txt b/widget-mgr/CMakeLists.txt
deleted file mode 100644 (file)
index 58b7601..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-PROJECT(widget-mgr C)
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/widget-mgr/include)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(info_pkgs REQUIRED
-       dlog
-       db-util
-       com-core
-       ecore
-       glib-2.0
-       gio-2.0
-       widget_service
-       xdamage
-       xfixes
-       x11
-       xext
-       bundle
-)
-
-FOREACH(flag ${info_pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Wall -Werror -fPIE")
-
-ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
-ADD_DEFINITIONS("-DSOCKET_FILE=\"/opt/usr/share/live_magazine/.live.socket\"")
-
-ADD_EXECUTABLE(${PROJECT_NAME}
-       src/widget-mgr.c
-       src/node.c
-)
-
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${info_pkgs_LDFLAGS} "-pie")
-
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /opt/usr/devel/usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-
-# End of a file
diff --git a/widget-mgr/include/node.h b/widget-mgr/include/node.h
deleted file mode 100644 (file)
index e3fe593..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-
-enum node_type {
-       NODE_DIR,
-       NODE_FILE,
-       NODE_LINK,
-};
-
-struct node;
-
-#define NODE_READ   0x01
-#define NODE_WRITE  0x02
-#define NODE_EXEC   0x04
-
-extern struct node *node_find(const struct node *node, const char *path);
-extern struct node *node_create(struct node *parent, const char *name, enum node_type type, int mode);
-extern void *node_destroy(struct node *node);
-
-extern struct node * const node_next_sibling(const struct node *node);
-extern struct node * const node_prev_sibling(const struct node *node);
-
-extern struct node * const node_child(const struct node *node);
-extern struct node * const node_parent(const struct node *node);
-
-extern void node_set_mode(struct node *node, int mode);
-extern void node_set_data(struct node *node, void *data);
-
-extern const int const node_mode(const struct node *node);
-extern void * const node_data(const struct node *node);
-
-extern void node_set_type(struct node *node, enum node_type type);
-extern const enum node_type const node_type(const struct node *node);
-
-extern const char * const node_name(const struct node *node);
-
-extern char *node_to_abspath(const struct node *node);
-
-extern int node_age(struct node *node);
-extern void node_set_age(struct node *node, int age);
-
-extern void node_delete(struct node *node, void (del_cb)(struct node *node));
-/* End of a file */
diff --git a/widget-mgr/include/widget-info.h b/widget-mgr/include/widget-info.h
deleted file mode 100644 (file)
index 67a71d8..0000000
+++ /dev/null
@@ -1,16 +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.
- */
-
diff --git a/widget-mgr/src/node.c b/widget-mgr/src/node.c
deleted file mode 100644 (file)
index 45c1dc7..0000000
+++ /dev/null
@@ -1,391 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include "node.h"
-
-struct node {
-       char *name;
-       enum node_type type;
-
-       void *data;
-
-       struct node *parent;
-       unsigned char mode;
-       int age;
-
-       struct {
-               struct node *next;
-               struct node *prev;
-       } sibling;
-
-       struct node *child;
-};
-
-int errno; /* External symbol */
-
-char *node_to_abspath(const struct node *node)
-{
-       char *path;
-       char *ptr;
-       const struct node *tmp;
-       int len = 0;
-
-       tmp = node;
-       while (tmp && node_name(tmp)) {
-               len += strlen(node_name(tmp)) + 1; /* trail '/' */
-               tmp = node_parent(tmp);
-       }
-
-       path = malloc(len + 3); /* '/' and '\0' */
-       if (!path) {
-               return NULL;
-       }
-
-       if (!len) {
-               path[0] = '/';
-               path[1] = '\0';
-       } else {
-               ptr = path + len + 1;
-               *ptr = '\0';
-               ptr--;
-               *ptr = '/';
-               tmp = node;
-               while (tmp && node_name(tmp)) {
-                       ptr -= (strlen(node_name(tmp)) + 1);
-                       *ptr = '/';
-                       strncpy(ptr + 1, node_name(tmp), strlen(node_name(tmp)));
-                       tmp = node_parent(tmp);
-               }
-       }
-
-       return path;
-}
-
-static inline int next_state(int from, char ch)
-{
-       switch (ch)
-       {
-       case '\0':
-       case '/':
-               return 1;
-       case '.':
-               if (from == 1) {
-                       return 2;
-               }
-               if (from == 2) {
-                       return 3;
-               }
-       }
-
-       return 4;
-}
-
-static inline void abspath(const char* pBuffer, char* pRet)
-{
-       int idx=0;
-       int state = 1;
-       int from;
-       int src_idx = 0;
-       int src_len = strlen(pBuffer);
-       pRet[idx] = '/';
-       idx ++;
-
-       while (src_idx <= src_len) {
-               from = state;
-               state = next_state(from, pBuffer[src_idx]);
-
-               switch (from) {
-               case 1:
-                       if (state != 1) {
-                               pRet[idx] = pBuffer[src_idx];
-                               idx++;
-                       }
-                       break;
-               case 2:
-                       if (state == 1) {
-                               if (idx > 1) {
-                                       idx--;
-                               }
-                       } else {
-                               pRet[idx] = pBuffer[src_idx];
-                               idx++;
-                       }
-                       break;
-               case 3:
-                       // Only can go to the 1 or 4
-                       if (state == 1) {
-                               idx -= 2;
-                               if (idx < 1) {
-                                       idx = 1;
-                               }
-
-                               while (idx > 1 && pRet[idx] != '/') {
-                                       idx--; /* Remove .. */
-                               }
-                               if (idx > 1 && pRet[idx] == '/') {
-                                       idx--;
-                               }
-                               while (idx > 1 && pRet[idx] != '/') {
-                                       idx--; /* Remove parent folder */
-                               }
-                       }
-               case 4:
-                       pRet[idx] = pBuffer[src_idx];
-                       idx++;
-                       break;
-               }
-
-               pRet[idx] = '\0';
-               src_idx++;
-       }
-}
-
-struct node *node_find(const struct node *node, const char *path)
-{
-       int len = 0;
-       char *ptr;
-       char *buffer;
-
-       if (*path != '/') {
-               while (node->parent && path[0] == '.' && path[1] == '.') {
-                       if (path[2] != '/' && path[2] != '\0') {
-                               break;
-                       }
-
-                       path += 2;
-                       path += (path[2] == '/');
-                       node = node->parent;
-               }
-       }
-
-       buffer = malloc(strlen(path) + 3); /* add 2 more bytes */
-       if (!buffer) {
-               printf("malloc: %d\n", errno);
-               return NULL;
-       }
-
-       abspath(path, buffer);
-
-       ptr = buffer;
-       do {
-               ptr += (*ptr == '/');
-               for (len = 0; ptr[len] && ptr[len] != '/'; len++);
-               if (!len) {
-                       break;
-               }
-
-               if (!strncmp("..", ptr, len)) {
-                       ptr += len;
-                       node = node->parent ? node->parent : node;
-                       continue;
-               }
-
-               if (!strncmp(".", ptr, len)) {
-                       ptr += len;
-                       continue;
-               }
-
-               node = node->child;
-               if (!node) {
-                       break;
-               }
-
-               while (node) {
-                       if (!strncmp(node->name, ptr, len) && node->name[len] == '\0') {
-                               ptr += len;
-                               break;
-                       }
-
-                       node = node->sibling.next;
-               }
-       } while (*ptr && node);
-
-       free(buffer);
-       return (struct node *)node;
-}
-
-struct node *node_create(struct node *parent, const char *name, enum node_type type, int mode)
-{
-       struct node *node;
-
-       node = malloc(sizeof(*node));
-       if (!node) {
-               printf("malloc: %d\n", errno);
-               return NULL;
-       }
-
-       node->parent = parent;
-
-       if (name) {
-               node->name = strdup(name);
-               if (!node->name) {
-                       printf("strdup: %d\n", errno);
-                       free(node);
-                       return NULL;
-               }
-       } else {
-               node->name = NULL;
-       }
-
-       node->type = type;
-
-       node->sibling.next = NULL;
-       node->sibling.prev = NULL;
-
-       node->child = NULL;
-       node->data = NULL;
-
-       if (parent) {
-               if (parent->child) {
-                       struct node *tmp;
-                       tmp = parent->child;
-                       while (tmp->sibling.next) {
-                               tmp = tmp->sibling.next;
-                       }
-
-                       tmp->sibling.next = node;
-                       node->sibling.prev = tmp;
-               } else {
-                       parent->child = node;
-               }
-       }
-
-       node->mode = mode;
-       return node;
-}
-
-void *node_destroy(struct node *node)
-{
-       void *data;
-
-       data = node->data;
-       free(node->name);
-       free(node);
-
-       return data;
-}
-
-void node_delete(struct node *node, void (del_cb)(struct node *node))
-{
-       struct node *tmp;
-       struct node *next;
-       struct node *parent;
-
-       if (node->sibling.prev) {
-               node->sibling.prev->sibling.next = node->sibling.next;
-       }
-
-       if (node->sibling.next) {
-               node->sibling.next->sibling.prev = node->sibling.prev;
-       }
-
-       /* Isolate the node */
-       node->sibling.prev = NULL;
-       node->sibling.next = NULL;
-
-       if (node->parent) {
-               if (node->parent->child == node) {
-                       node->parent->child = NULL;
-               }
-
-               node->parent = NULL;
-       }
-
-       tmp = node;
-       while (tmp) {
-               /* Reach to the leaf node */
-               while (tmp->child) {
-                       tmp = tmp->child;
-               }
-
-               parent = tmp->parent;
-               next = tmp->sibling.next;
-
-               if (parent && parent->child == tmp) {
-                       parent->child = NULL;
-               }
-
-               if (del_cb) {
-                       del_cb(tmp);
-               }
-
-               node_destroy(tmp);
-
-               if (next) {
-                       tmp = next;
-               } else if (parent) {
-                       tmp = parent;
-               } else {
-                       tmp = NULL;
-               }
-       }
-}
-
-struct node * const node_next_sibling(const struct node *node)
-{
-       return node->sibling.next;
-}
-
-struct node * const node_prev_sibling(const struct node *node)
-{
-       return node->sibling.prev;
-}
-
-void node_set_mode(struct node *node, int mode)
-{
-       node->mode = mode;
-}
-
-void node_set_data(struct node *node, void *data)
-{
-       node->data = data;
-}
-
-void node_set_type(struct node *node, enum node_type type)
-{
-       node->type = type;
-}
-
-struct node * const node_child(const struct node *node)
-{
-       return node->child;
-}
-
-struct node * const node_parent(const struct node *node)
-{
-       return node->parent;
-}
-
-const int const node_mode(const struct node *node)
-{
-       return node->mode;
-}
-
-void * const node_data(const struct node *node)
-{
-       return node->data;
-}
-
-const enum node_type const node_type(const struct node *node)
-{
-       return node->type;
-}
-
-const char * const node_name(const struct node *node)
-{
-       return node->name;
-}
-
-void node_set_age(struct node *node, int age)
-{
-       node->age = age;
-}
-
-int node_age(struct node *node)
-{
-       return node->age;
-}
-
-/* End of a file */
diff --git a/widget-mgr/src/widget-mgr.c b/widget-mgr/src/widget-mgr.c
deleted file mode 100644 (file)
index 5168ccc..0000000
+++ /dev/null
@@ -1,2260 +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 <unistd.h>
-#include <getopt.h>
-#include <errno.h>
-#include <libgen.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <sys/shm.h>
-#include <sys/ipc.h>
-#include <ctype.h>
-#include <bundle.h>
-
-#include <X11/Xlib.h>
-#include <X11/extensions/Xdamage.h>
-#include <X11/extensions/Xfixes.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xutil.h>
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include <packet.h>
-#include <com-core_packet.h>
-#include <com-core.h>
-
-#include <widget_errno.h>
-#include <widget_service.h>
-#include <widget_service_internal.h>
-
-#include <Ecore.h>
-
-#include "widget-info.h"
-#include "node.h"
-
-#define PROMPT "widget-mgr "
-#define PROVIDER_FOLDER "provider"
-#define PACKAGE_FOLDER "package"
-
-struct package {
-       int primary;
-       char *pkgid;
-
-       int pid;
-       char *slavename;
-       char *abi;
-       int refcnt;
-       int fault_count;
-       int inst_count;
-};
-
-struct instance {
-       char *id;
-       char *buf_id;
-       char *cluster;
-       char *category;
-       double period;
-       char *state;
-       int width;
-       int height;
-};
-
-struct slave {
-       int pid;
-       char *pkgname;
-       char *abi;
-       int secured;
-       int refcnt;
-       int fault_count;
-       char *state;
-       int loaded_inst;
-       int loaded_pkg;
-       double ttl;
-};
-
-enum command {
-       NOP,
-       PKG_LIST,
-       INST_LIST,
-       SLAVE_LIST,     
-       INST_CTRL,
-       SLAVE_CTRL,
-       MASTER_CTRL,
-};
-
-static struct info {
-       int fifo_handle;
-       int fd;
-       Ecore_Fd_Handler *fd_handler;
-       Ecore_Fd_Handler *in_handler;
-
-       struct node *rootdir;
-       struct node *curdir;
-       struct node *targetdir;
-
-       enum command cmd;
-
-       int input_fd;
-       int verbose;
-
-       int age;
-
-       char *history[1024];
-       int history_top;
-       int history_idx;
-
-       struct node *quick_search_node;
-       int quick_idx;
-
-       int dump;
-} s_info = {
-       .fifo_handle = -EINVAL,
-       .fd = -EINVAL,
-       .fd_handler = NULL,
-       .in_handler = NULL,
-       .rootdir = NULL,
-       .curdir = NULL,
-       .targetdir = NULL,
-       .cmd = NOP,
-       .input_fd = STDIN_FILENO,
-       .verbose = 0,
-       .age = 0,
-       .history = { 0, },
-       .history_top = 0,
-       .history_idx = 0,
-       .quick_search_node = NULL,
-       .quick_idx = 0,
-       .dump = 0,
-};
-
-char *optarg;
-int errno;
-int optind;
-int optopt;
-int opterr;
-
-static Eina_Bool input_cb(void *data, Ecore_Fd_Handler *fd_handler);
-
-static inline const char *trim_cmd(const char *cmd)
-{
-       while (*cmd && *cmd == ' ') cmd++;
-
-       return cmd;
-}
-
-static Eina_Bool process_line_cb(void *data)
-{
-       input_cb(NULL, NULL);
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static inline void prompt(const char *cmdline)
-{
-       char *path;
-
-       if (s_info.input_fd != STDIN_FILENO) {
-               /* To prevent recursive call, add function to the main loop (idler) */
-               ecore_idler_add(process_line_cb, NULL);
-               return;
-       }
-
-       path = node_to_abspath(s_info.curdir);
-       printf(PROMPT"%s # %s", path, cmdline ? cmdline : "");
-       free(path);
-}
-
-static void provider_del_cb(struct node *node)
-{
-       struct slave *info;
-
-       info = node_data(node);
-       if (!info) {
-               return;
-       }
-
-       free(info->pkgname);
-       free(info->abi);
-       free(info->state);
-       free(info);
-}
-
-static void package_del_cb(struct node *node)
-{
-       struct package *info;
-
-       info = node_data(node);
-       if (!info) {
-               return;
-       }
-
-       free(info->pkgid);
-       free(info->slavename);
-       free(info->abi);
-       free(info);
-}
-
-static void inst_del_cb(struct node *node)
-{
-       struct instance *info;
-
-       info = node_data(node);
-       if (!info) {
-               return;
-       }
-
-       free(info->id);
-       free(info->buf_id);
-       free(info->cluster);
-       free(info->category);
-       free(info->state);
-       free(info);
-}
-
-static void ls(void)
-{
-       struct node *node;
-       int cnt = 0;
-       int is_package;
-       int is_provider;
-       int is_instance;
-       struct node *next_node;
-
-       if (!(node_mode(s_info.targetdir) & NODE_READ)) {
-               printf("Access denied\n");
-               return;
-       }
-
-       is_package = node_name(s_info.targetdir) && !strcmp(node_name(s_info.targetdir), PACKAGE_FOLDER);
-       is_provider = !is_package && node_name(s_info.targetdir) && !strcmp(node_name(s_info.targetdir), PROVIDER_FOLDER);
-       is_instance = !is_package && !is_provider && node_parent(s_info.targetdir) && node_name(node_parent(s_info.targetdir)) && !strcmp(node_name(node_parent(s_info.targetdir)), PACKAGE_FOLDER);
-
-       node = node_child(s_info.targetdir);
-       while (node) {
-               if (is_package) {
-                       struct package *info;
-
-                       next_node = node_next_sibling(node);
-                       if (node_age(node) != s_info.age) {
-                               node_delete(node, package_del_cb);
-                               node = next_node;
-                               continue;
-                       }
-
-                       info = node_data(node);
-                       printf(" %3d %20s %5s ", info->inst_count, info->slavename ? info->slavename : "(none)", info->abi ? info->abi : "?");
-               } else if (is_provider) {
-                       struct slave *info;
-
-                       next_node = node_next_sibling(node);
-                       if (node_age(node) != s_info.age) {
-                               node_delete(node, provider_del_cb);
-                               node = next_node;
-                               continue;
-                       }
-
-                       info = node_data(node);
-                       printf("%6d %3d %5s %5.2f ", info->pid, info->loaded_inst, info->abi ? info->abi : "?", info->ttl);
-               } else if (is_instance) {
-                       struct instance *info;
-                       struct stat stat;
-                       char buf[4096];
-
-                       next_node = node_next_sibling(node);
-
-                       if (node_age(node) != s_info.age) {
-                               node_delete(node, inst_del_cb);
-                               node = next_node;
-                               continue;
-                       }
-
-                       info = node_data(node);
-
-                       printf(" %5.2f %s %6s %10s %10s %4dx%-4d ", info->period, info->buf_id, info->state, info->cluster, info->category, info->width, info->height);
-                       snprintf(buf, sizeof(buf), "/opt/usr/share/live_magazine/reader/%s", node_name(node));
-                       if (lstat(buf, &stat) < 0) {
-                               printf("%3d ERR ", errno);
-                       } else {
-                               printf("%2.2lf KB ", (double)stat.st_size / 1024.0f);
-                       }
-               }
-
-               if (node_type(node) == NODE_DIR) {
-                       printf("%s/", node_name(node));
-               } else if (node_type(node) == NODE_FILE) {
-                       printf("%s", node_name(node));
-               }
-
-               printf("\n");
-               node = node_next_sibling(node);
-               cnt++;
-       }
-
-       printf("Total: %d\n", cnt);
-}
-
-static void send_slave_list(void)
-{
-       struct packet *packet;
-       int ret;
-
-       if (s_info.cmd != NOP) {
-               printf("Previous command is not finished\n");
-               return;
-       }
-
-       packet = packet_create_noack("slave_list", "d", 0.0f);
-       if (!packet) {
-               printf("Failed to create a packet\n");
-               return;
-       }
-
-       ret = com_core_packet_send_only(s_info.fd, packet);
-       packet_destroy(packet);
-       if (ret < 0) {
-               printf("Failed to send a packet: %d\n", ret);
-               return;
-       }
-
-       s_info.cmd = SLAVE_LIST;
-       s_info.age++;
-}
-
-/*!
- * var = debug, slave_max_load
- * cmd = set / get
- */
-static void send_command(const char *cmd, const char *var, const char *val)
-{
-       struct packet *packet;
-       int ret;
-
-       if (s_info.cmd != NOP) {
-               printf("Previous command is not finished\n");
-               return;
-       }
-
-       packet = packet_create_noack("master_ctrl", "sss", cmd, var, val);
-       if (!packet) {
-               printf("Failed to create a ctrl packet\n");
-               return;
-       }
-
-       ret = com_core_packet_send_only(s_info.fd, packet);
-       packet_destroy(packet);
-       if (ret < 0) {
-               printf("Failed to send packet ctrl\n");
-               return;
-       }
-
-       s_info.cmd = MASTER_CTRL;
-       s_info.age++;
-}
-
-static int pkglist_cb(const char *appid, const char *lbid, int is_prime, void *data)
-{
-       struct node *parent = data;
-       struct node *node;
-       struct package *info;
-
-       node = node_find(parent, lbid);
-       if (node) {
-               info = node_data(node);
-               if (!info) {
-                       printf("Invalid node\n");
-                       return -EINVAL;
-               }
-
-               free(info->pkgid);
-               info->pkgid = strdup(appid);
-               if (!info->pkgid) {
-                       printf("strdup: %d\n", errno);
-                       return -ENOMEM;
-               }
-
-               node_set_age(node, s_info.age);
-               return 0;
-       }
-
-       info = calloc(1, sizeof(*info));
-       if (!info) {
-               printf("calloc: %d\n", errno);
-               return -ENOMEM;
-       }
-
-       info->pkgid = strdup(appid);
-       if (!info->pkgid) {
-               printf("strdup: %d\n", errno);
-               free(info);
-               return -ENOMEM;
-       }
-
-       info->primary = is_prime;
-
-       node = node_create(parent, lbid, NODE_DIR, NODE_READ | NODE_EXEC);
-       if (!node) {
-               free(info->pkgid);
-               free(info);
-               return -ENOMEM;
-       }
-
-       node_set_data(node, info);
-       node_set_age(node, s_info.age);
-       return 0;
-}
-
-static void send_pkg_list(void)
-{
-       struct packet *packet;
-       int ret;
-
-       if (s_info.cmd != NOP) {
-               printf("Previous command is not finished\n");
-               return;
-       }
-
-       packet = packet_create_noack("pkg_list", "d", 0.0f);
-       if (!packet) {
-               printf("Failed to create a packet\n");
-               return;
-       }
-
-       ret = com_core_packet_send_only(s_info.fd, packet);
-       packet_destroy(packet);
-       if (ret < 0) {
-               printf("Failed to create a packet\n");
-               return;
-       }
-
-       s_info.cmd = PKG_LIST;
-       s_info.age++;
-
-       widget_service_get_widget_list(pkglist_cb, s_info.targetdir);
-}
-
-static void send_inst_delete(void)
-{
-       struct packet *packet;
-       struct node *parent;
-       const char *name;
-       struct instance *inst;
-       int ret;
-
-       if (s_info.cmd != NOP) {
-               printf("Previous command is not finished\n");
-               return;
-       }
-
-       parent = node_parent(s_info.targetdir);
-       if (!parent) {
-               printf("Invalid argument\n");
-               return;
-       }
-
-       if (!node_parent(parent)) {
-               printf("Invalid argument\n");
-               return;
-       }
-
-       name = node_name(node_parent(parent));
-       if (!name || strcmp(name, PACKAGE_FOLDER)) {
-               printf("Invalid argument\n");
-               return;
-       }
-
-       inst = node_data(s_info.targetdir);
-       name = node_name(parent);
-
-       packet = packet_create_noack("pkg_ctrl", "sss", "rminst", name, inst->id);
-       if (!packet) {
-               printf("Failed to create a packet\n");
-               return;
-       }
-
-       ret = com_core_packet_send_only(s_info.fd, packet);
-       packet_destroy(packet);
-       if (ret < 0) {
-               printf("Failed to send a packet: %d\n", ret);
-               return;
-       }
-
-       s_info.cmd = INST_CTRL;
-       s_info.age++;
-}
-
-static void send_inst_fault(void)
-{
-       struct packet *packet;
-       struct node *parent;
-       const char *name;
-       struct instance *inst;
-       int ret;
-
-       if (s_info.cmd != NOP) {
-               printf("Previous command is not finished\n");
-               return;
-       }
-
-       parent = node_parent(s_info.targetdir);
-       if (!parent) {
-               printf("Invalid argument\n");
-               return;
-       }
-
-       if (!node_parent(parent)) {
-               printf("Invalid argument\n");
-               return;
-       }
-
-       name = node_name(node_parent(parent));
-       if (!name || strcmp(name, PACKAGE_FOLDER)) {
-               printf("Invalid argument\n");
-               return;
-       }
-
-       inst = node_data(s_info.targetdir);
-       name = node_name(parent);
-
-       packet = packet_create_noack("pkg_ctrl", "sss", "faultinst", name, inst->id);
-       if (!packet) {
-               printf("Failed to create a packet\n");
-               return;
-       }
-
-       ret = com_core_packet_send_only(s_info.fd, packet);
-       packet_destroy(packet);
-       if (ret < 0) {
-               printf("Failed to send a packet: %d\n", ret);
-               return;
-       }
-
-       s_info.cmd = INST_CTRL;
-       s_info.age++;
-}
-
-static void send_inst_list(const char *pkgname)
-{
-       struct packet *packet;
-       int ret;
-
-       if (s_info.cmd != NOP) {
-               printf("Previous command is not finished\n");
-               return;
-       }
-
-       packet = packet_create_noack("inst_list", "s", pkgname);
-       if (!packet) {
-               printf("Failed to create a packet\n");
-               return;
-       }
-
-       ret = com_core_packet_send_only(s_info.fd, packet);
-       packet_destroy(packet);
-       if (ret < 0) {
-               printf("Failed to send a packet: %d\n", ret);
-               return;
-       }
-
-       s_info.cmd = INST_LIST;
-       s_info.age++;
-}
-
-static void help(void)
-{
-       printf("widget-mgr - widget utility\n");
-       printf("------------------------------ [Option] ------------------------------\n");
-       printf("-b Batch mode\n");
-       printf("-x execute command\n");
-       printf("------------------------------ [Command list] ------------------------------\n");
-       printf("\e[32mcd [PATH] - Change directory\e[0m\n");
-       printf("\e[32mls [ | PATH] - List up content as a file\e[0m\n");
-       printf("\e[32mrm [PKG_ID|INST_ID] - Delete package or instance\e[0m\n");
-       printf("\e[32mstat [path] - Display the information of given path\e[0m\n");
-       printf("\e[32mset [debug] [on|off] Set the control variable of master provider\e[0m\n");
-       printf("\e[32mx damage Pix x y w h - Create damage event for given pixmap\e[0m\n");
-       printf("\e[32mx move Pix x y - Move the window\e[0m\n");
-       printf("\e[32mx resize Pix w h - Resize the window\e[0m\n");
-       printf("\e[32mx map Pix - Show the window\e[0m\n");
-       printf("\e[32mx unmap Pix - Hide the window\e[0m\n");
-       printf("\e[32mx capture Pix outfile - Capture pixmap and save it to outfile\e[0m\n");
-       printf("\e[32msh [command] Execute shell command, [command] should be abspath\e[0m\n");
-       printf("\e[32mexit - \e[0m\n");
-       printf("\e[32mquit - \e[0m\n");
-       printf("----------------------------------------------------------------------------\n");
-}
-
-static inline void init_directory(void)
-{
-       struct node *node;
-       s_info.rootdir = node_create(NULL, NULL, NODE_DIR, NODE_READ | NODE_EXEC);
-       if (!s_info.rootdir) {
-               return;
-       }
-
-       node = node_create(s_info.rootdir, PROVIDER_FOLDER, NODE_DIR, NODE_READ | NODE_EXEC);
-       if (!node) {
-               node_destroy(s_info.rootdir);
-               s_info.rootdir = NULL;
-               return;
-       }
-
-       node = node_create(s_info.rootdir, PACKAGE_FOLDER, NODE_DIR, NODE_READ | NODE_EXEC);
-       if (!node) {
-               node_destroy(node_child(s_info.rootdir));
-               node_destroy(s_info.rootdir);
-               s_info.rootdir = NULL;
-               return;
-       }
-
-       s_info.curdir = s_info.rootdir;
-       return;
-}
-
-static inline void fini_directory(void)
-{
-}
-
-static struct node *update_target_dir(const char *cmd)
-{
-       struct node *node;
-
-       node = (*cmd == '/') ? s_info.rootdir : s_info.curdir;
-       node = node_find(node, cmd);
-
-       return node;
-}
-
-static int get_token(const char *src, char *out)
-{
-       int len = 0;
-       while (*src && *src == ' ') src++;
-
-       if (!*src) {
-               return 0;
-       }
-
-       while (*src && *src != ' ') {
-               *out++ = *src++;
-               len++;
-       }
-
-       *out = '\0';
-       return len;
-}
-
-static inline int do_stat(const char *cmd)
-{
-       int i;
-       struct node *node;
-       struct node *parent;
-       char *tmp;
-       enum stat_type {
-               PKG_INSTANCE = 0x01,
-               PKG,
-               PROVIDER_INSTANCE,
-               PROVIDER,
-               ROOT,
-       } type;
-
-       cmd = trim_cmd(cmd + 5);
-       if (!*cmd){
-               printf("Invalid argument\n");
-               return -EINVAL;
-       }
-
-       node = node_find(*cmd == '/' ? s_info.rootdir : s_info.curdir, cmd);
-       if (!node) {
-               printf("Invalid path\n");
-               return -EINVAL;
-       }
-
-       i = 0;
-       type = ROOT;
-       parent = node_parent(node);
-       while (parent) {
-               if (!node_name(parent)) {
-                       printf("%s has no info\n", node_name(node));
-                       return -EINVAL;
-               } else if (!strcmp(node_name(parent), PACKAGE_FOLDER)) {
-                       type = (i == 0) ? PKG : PKG_INSTANCE;
-                       break;
-               } else if (!strcmp(node_name(parent), PROVIDER_FOLDER)){
-                       type = (i == 0) ? PROVIDER : PROVIDER_INSTANCE;
-                       break;
-               }
-
-               parent = node_parent(parent);
-               i++;
-               if (i > 1) {
-                       printf("%s is invalid path\n", node_name(node));
-                       return -EINVAL;
-               }
-       }
-
-       switch (type){
-       case PKG:
-               tmp = widget_service_get_name(node_name(node), NULL);
-               printf("Name: %s (", tmp);
-               free(tmp);
-
-               i = widget_service_is_enabled(node_name(node));
-               printf("%s)\n", i ? "enabled" : "disabled");
-
-               tmp = widget_service_get_icon(node_name(node), NULL);
-               printf("Icon: %s\n", tmp);
-               free(tmp);
-
-               tmp = widget_service_get_category(node_name(node));
-               printf("Category: %s\n", tmp);
-               free(tmp);
-
-               tmp = widget_service_get_provider_name(node_name(node));
-               printf("Provider: %s (content:", tmp);
-               free(tmp);
-
-               tmp = widget_service_get_content_string(node_name(node));
-               printf("%s)\n", tmp);
-               free(tmp);
-
-               tmp = widget_service_get_widget_script_path(node_name(node));
-               printf("LB Script: %s (", tmp);
-               free(tmp);
-
-               tmp = widget_service_get_widget_script_group(node_name(node));
-               printf("%s)\n", tmp);
-               free(tmp);
-
-               tmp = widget_service_get_gbar_script_path(node_name(node));
-               printf("PD Script: %s (", tmp);
-               free(tmp);
-
-               tmp = widget_service_get_gbar_script_group(node_name(node));
-               printf("%s)\n", tmp);
-               free(tmp);
-
-               break;
-       case PROVIDER:
-               printf("Not supported yet\n");
-               break;
-       case PKG_INSTANCE:
-               printf("Not supported yet\n");
-               break;
-       case PROVIDER_INSTANCE:
-               printf("Not supported yet\n");
-               break;
-       case ROOT:
-               printf("Not supported yet\n");
-               break;
-       }
-
-       return 0;
-}
-
-static int do_set(const char *cmd)
-{
-       int i;
-       char variable[4096] = { '0', };
-
-       cmd += 4;
-       i = get_token(cmd, variable);
-
-       cmd = trim_cmd(cmd + i);
-       if (!i || !*cmd) {
-               printf("Invalid argument(%s): set [VAR] [VAL]\n", cmd);
-               return -EINVAL;
-       }
-
-       send_command("set", variable, cmd);
-       return 0;
-}
-
-static inline int do_get(const char *cmd)
-{
-       cmd = trim_cmd(cmd + 4);
-       if (!*cmd) {
-               printf("Invalid argument(%s): get [VAR]\n", cmd);
-               return -EINVAL;
-       }
-
-       send_command("get", cmd, "");
-       return 0;
-}
-
-static inline int do_ls(const char *cmd)
-{
-       const char *name;
-       struct node *parent;
-
-       cmd = trim_cmd(cmd + 2);
-
-       s_info.targetdir = *cmd ? update_target_dir(cmd) : s_info.curdir;
-       if (!s_info.targetdir) {
-               printf("%s is not exists\n", cmd);
-               return -ENOENT;
-       }
-
-       name = node_name(s_info.targetdir);
-       if (name) {
-               if (!strcmp(name, PACKAGE_FOLDER)) {
-                       if (s_info.cmd == NOP) {
-                               send_pkg_list();
-                               return 0;
-                       }
-
-                       printf("Waiting the server response\n");
-                       return -EBUSY;
-               } else if (!strcmp(name, PROVIDER_FOLDER)) {
-                       if (s_info.cmd == NOP) {
-                               send_slave_list();
-                               return 0;
-                       }
-
-                       printf("Waiting the server response\n");
-                       return -EBUSY;
-               }
-       }
-
-       parent = node_parent(s_info.targetdir);
-       if (parent && node_name(parent)) {
-               if (!strcmp(node_name(parent), PACKAGE_FOLDER)) {
-                       if (s_info.cmd != NOP) {
-                               printf("Waiting the server response\n");
-                               return -EBUSY;
-                       }
-
-                       send_inst_list(name);
-                       return 0;
-               }
-       }
-
-       ls();
-       return -1;
-}
-
-static inline int do_cd(const char *cmd)
-{
-       cmd = trim_cmd(cmd + 2);
-       if (!*cmd) {
-               return -1;
-       }
-
-       if (s_info.cmd != NOP) {
-               printf("Waiting the server response\n");
-               return -EBUSY;
-       }
-
-       s_info.targetdir = update_target_dir(cmd);
-       if (!s_info.targetdir) {
-               printf("%s is not exists\n", cmd);
-               return -ENOENT;
-       }
-
-       if (node_type(s_info.targetdir) != NODE_DIR) {
-               printf("Unable change directory to %s\n", cmd);
-               return -EINVAL;
-       }
-
-       if (!(node_mode(s_info.targetdir) & NODE_EXEC)) {
-               printf("Access denied %s\n", cmd);
-               return -EACCES;
-       }
-
-       s_info.curdir = s_info.targetdir;
-       return -1;
-}
-
-static inline int do_rm(const char *cmd)
-{
-       cmd = trim_cmd(cmd + 2);
-       if (!*cmd) {
-               return -1;
-       }
-
-       if (s_info.cmd != NOP) {
-               printf("Waiting the server response\n");
-               return -EBUSY;
-       }
-
-       s_info.targetdir = update_target_dir(cmd);
-       if (!s_info.targetdir) {
-               printf("%s is not exists\n", cmd);
-               return -ENOENT;
-       }
-
-       if (!(node_mode(s_info.targetdir) & NODE_WRITE)) {
-               printf("Access denied %s\n", cmd);
-               return -EACCES;
-       }
-
-       send_inst_delete();
-       return 0;
-}
-
-static inline int do_fault(const char *cmd)
-{
-       cmd = trim_cmd(cmd + 5);
-       if (!*cmd) {
-               return -1;
-       }
-
-       if (s_info.cmd != NOP) {
-               printf("Waiting the server response\n");
-               return -EBUSY;
-       }
-
-       s_info.targetdir = update_target_dir(cmd);
-       if (!s_info.targetdir) {
-               printf("%s is not exists\n", cmd);
-               return -ENOENT;
-       }
-
-       if (!(node_mode(s_info.targetdir) & NODE_WRITE)) {
-               printf("Access denied %s\n", cmd);
-               return -EACCES;
-       }
-
-       send_inst_fault();
-       return 0;
-}
-
-#if !defined(WCOREDUMP)
-#define WCOREDUMP(a)   0
-#endif
-
-static void do_sh(const char *cmd)
-{
-       pid_t pid;
-
-       cmd = trim_cmd(cmd + 3);
-       if (!*cmd) {
-               return;
-       }
-
-       pid = fork();
-       if (pid == 0) {
-               char command[256];
-               int idx;
-               idx = 0;
-
-               while (idx < (sizeof(command) - 1) && *cmd && *cmd != ' ') {
-                       command[idx++] = *cmd++;
-               }
-               command[idx] = '\0';
-
-               if (execl(command, cmd, NULL) < 0) {
-                       printf("execl: %d\n", errno);
-               }
-
-               exit(0);
-       } else if (pid < 0) {
-               printf("Failed to create a new process: %d\n", errno);
-       } else {
-               int status;
-               if (waitpid(pid, &status, 0) < 0) {
-                       printf("waitpid: %d\n", errno);
-               } else {
-                       if (WIFEXITED(status)) {
-                               printf("Exit: %d\n", WEXITSTATUS(status));
-                       } else if (WIFSIGNALED(status)) {
-                               printf("Terminated by %d %s\n", WTERMSIG(status), WCOREDUMP(status) ? " - core generated" : "");
-                       } else if (WIFSTOPPED(status)) {
-                               printf("Stopped by %d\n", WSTOPSIG(status));
-                       } else if (WIFCONTINUED(status)) {
-                               printf("Child is resumed\n");
-                       }
-               }
-       }
-}
-
-static inline int get_pixmap_size(Display *disp, Pixmap id, int *x, int *y, unsigned int *w, unsigned int *h)
-{
-       Window dummy_win;
-       unsigned int dummy_border, dummy_depth;
-       int _x;
-       int _y;
-
-       if (!x) {
-               x = &_x;
-       }
-
-       if (!y) {
-               y = &_y;
-       }
-
-       if (!XGetGeometry(disp, id, &dummy_win, x, y, w, h, &dummy_border, &dummy_depth)) {
-               return -EFAULT;
-       }
-
-       return 0;
-}
-
-static inline int do_capture(Display *disp, Pixmap id, const char *filename)
-{
-       XShmSegmentInfo si;
-       XImage *xim;
-       Visual *visual;
-       unsigned int w;
-       unsigned int h;
-       int bufsz;
-       int fd;
-       Screen *screen;
-
-       screen = DefaultScreenOfDisplay(disp);
-       visual = DefaultVisualOfScreen(screen);
-
-       if (get_pixmap_size(disp, id, NULL, NULL, &w, &h) < 0) {
-               printf("Failed to get size of a pixmap\n");
-               return -EINVAL;
-       }
-
-       printf("Pixmap size: %dx%d\n", w, h);
-       bufsz = w * h * sizeof(int);
-
-       si.shmid = shmget(IPC_PRIVATE, bufsz, IPC_CREAT | 0666);
-       if (si.shmid < 0) {
-               printf("shmget: %d\n", errno);
-               return -EFAULT;
-       }
-
-       si.readOnly = False;
-       si.shmaddr = shmat(si.shmid, NULL, 0);
-       if (si.shmaddr == (void *)-1) {
-
-               if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
-                       printf("shmctl: %d\n", errno);
-               }
-
-               return -EFAULT;
-       }
-
-       /*!
-        * \NOTE
-        * Use the 24 bits Pixmap for Video player
-        */
-       xim = XShmCreateImage(disp, visual, 24 /* (depth << 3) */, ZPixmap, NULL, &si, w, h);
-       if (xim == NULL) {
-               if (shmdt(si.shmaddr) < 0) {
-                       printf("shmdt: %d\n", errno);
-               }
-
-               if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
-                       printf("shmctl: %d\n", errno);
-               }
-
-               return -EFAULT;
-       }
-
-       xim->data = si.shmaddr;
-       XShmAttach(disp, &si);
-
-       XShmGetImage(disp, id, xim, 0, 0, 0xFFFFFFFF);
-       XSync(disp, False);
-
-       fd = open(filename, O_CREAT | O_RDWR, 0644);
-       if (fd >= 0) {
-               if (write(fd, xim->data, bufsz) != bufsz) {
-                       printf("Data is not fully written\n");
-               }
-
-               if (close(fd) < 0) {
-                       printf("close: %d\n", errno);
-               }
-       } else {
-               printf("Error: %d\n", errno);
-       }
-
-       XShmDetach(disp, &si);
-       XDestroyImage(xim);
-
-       if (shmdt(si.shmaddr) < 0) {
-               printf("shmdt: %d\n", errno);
-       }
-
-       if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
-               printf("shmctl: %d\n", errno);
-       }
-
-       return 0;
-}
-
-static int widget_lifecycle_event(const char *widget_id, widget_lifecycle_event_e ev, const char *instance_id, void *data)
-{
-       printf("[%s] [%s] [STATE: 0x%X]\n", widget_id, instance_id, (unsigned int)ev);
-       return WIDGET_ERROR_NONE;
-}
-
-static void do_monitor(const char *cmd)
-{
-       cmd = trim_cmd(cmd + strlen("monitor"));
-
-       if (!*cmd) {
-               /* Monitor all instances */
-       } else {
-               /* Monitor one */
-               printf("Instance = [%s]\n", cmd);
-       }
-
-       widget_service_set_lifecycle_event_cb(*cmd ? cmd : NULL, widget_lifecycle_event, NULL);
-}
-
-static int widget_inst_list_cb(const char *widget_id, const char *instance_id, void *data)
-{
-       printf("Instance: %s\n", instance_id);
-       return WIDGET_ERROR_NONE;
-}
-
-static void do_get_list(const char *cmd)
-{
-       cmd = trim_cmd(cmd + strlen("get_list"));
-       if (!*cmd) {
-               return;
-       }
-
-       printf("Instance list of %s\n", cmd);
-       if (widget_service_get_widget_instance_list(cmd, widget_inst_list_cb, NULL) == WIDGET_ERROR_NONE) {
-               printf("=== Done\n");
-       } else {
-               printf("Failed to get instance list\n");
-       }
-}
-
-static int do_frame_dump(const char *cmd)
-{
-       struct instance *info;
-       struct packet *packet;
-       struct node *parent;
-       char widget_id[256];
-       int value;
-       int ret;
-
-       cmd = trim_cmd(cmd + strlen("frame_dump"));
-       if (!*cmd) {
-               return -EINVAL;
-       }
-
-       if (s_info.cmd != NOP) {
-               printf("Waiting the server response\n");
-               return -EBUSY;
-       }
-
-       if (sscanf(cmd, "%[^ ] %d", widget_id, &value) != 2) {
-               printf("Error[%s]\n", cmd);
-               return -EINVAL;
-       }
-
-       s_info.targetdir = update_target_dir(widget_id);
-       if (!s_info.targetdir) {
-               printf("%s is not exists\n", cmd);
-               return -ENOENT;
-       }
-
-       if (!(node_mode(s_info.targetdir) & NODE_WRITE)) {
-               printf("Access denied %s\n", cmd);
-               return -EACCES;
-       }
-
-       parent = node_parent(s_info.targetdir);
-       if (!parent) {
-               printf("Invalid folder: %s\n", cmd);
-               return -EFAULT;
-       }
-
-       info = node_data(s_info.targetdir);
-       printf("WidgetId: %s\n", info->id);
-       packet = packet_create_noack("slave_ctrl", "ssii", node_name(parent), info->id, WIDGET_CTRL_MODE_DUMP_FRAME, !!value);
-       ret = com_core_packet_send_only(s_info.fd, packet);
-       packet_destroy(packet);
-       if (ret < 0) {
-               printf("Failed to send a packet: %d\n", ret);
-               return ret;
-       }
-
-       printf("Dump frame %s (%s)\n", cmd, node_name(parent));
-       s_info.age++;
-
-       return 0;
-}
-
-static void do_get_content(const char *cmd)
-{
-       char widget_id[256];
-       char inst_id[256];
-       cmd = trim_cmd(cmd + strlen("get_content"));
-       if (!*cmd) {
-               return;
-       }
-
-       if (sscanf(cmd, "%[^ ] %s", widget_id, inst_id) == 2) {
-               bundle *b;
-               if (widget_service_get_content_of_widget_instance(widget_id, inst_id, &b) == WIDGET_ERROR_NONE) {
-                       int len;
-                       char *content = NULL;
-
-                       if (b && bundle_encode(b, (bundle_raw **)&content, &len) == BUNDLE_ERROR_NONE) {
-                               printf("Widget: %s\nInstance: %s\nContent: [%s]\n", widget_id, inst_id, content);
-                               bundle_free(b);
-                       } else {
-                               printf("Widget: %s\nInstance: %s\nbundle: %p\n", widget_id, inst_id, b);
-                       }
-
-                       free(content);
-               } else {
-                       printf("Failed to get content info for %s\n", inst_id);
-               }
-       }
-}
-
-static void do_demonitor(const char *cmd)
-{
-       cmd = trim_cmd(cmd + strlen("demonitor"));
-       if (!*cmd) {
-       } else {
-               printf("Instance = [%s]\n", cmd);
-       }
-
-       widget_service_unset_lifecycle_event_cb(*cmd ? cmd : NULL, NULL);
-}
-
-static void do_dump(const char *cmd)
-{
-       char path[256];
-       int idx;
-       struct node *node;
-       struct node *curdir;
-       struct node *target;
-
-       cmd = trim_cmd(cmd + 5);
-       if (!*cmd) {
-               return;
-       }
-
-       curdir = s_info.curdir;
-       do {
-               target = NULL;
-               idx = 0;
-               while (cmd[idx] != '/' && cmd[idx] != '\0' && cmd[idx] != ' ') {
-                       idx++;
-               }
-
-               if (!idx) {
-                       break;
-               }
-
-               strncpy(path, cmd, idx);
-               path[idx] = '\0';
-               cmd += idx;
-
-               node = node_child(curdir);
-               while (node) {
-                       if (!strcmp(node_name(node), path)) {
-                               curdir = node;
-                               target = curdir;
-                               break;
-                       }
-
-                       node = node_next_sibling(node);
-               }
-
-               if (*cmd != '/') {
-                       break;
-               }
-       } while ((*++cmd));
-
-       if (target && node_type(target) != NODE_DIR) {
-               struct instance *instinfo;
-
-               if (node_type(target) == NODE_LINK) {
-                       /* Follow up node */
-               }
-
-               instinfo = node_data(target);
-               if (instinfo) {
-                       while (*cmd == ' ') {
-                               cmd++;
-                       }
-
-                       if (sscanf(cmd, "%255[^ ]", path) != 1) {
-                               printf("dump file OUT_FILENAME\n");
-                               return;
-                       }
-
-                       if (instinfo->buf_id) {
-                               unsigned int pixmap;
-                               int pixel_size;
-                               if (sscanf(instinfo->buf_id, "pixmap://%u:%d", &pixmap, &pixel_size) == 2) {
-                                       Display *disp;
-
-                                       disp = XOpenDisplay(NULL);
-                                       if (!disp) {
-                                               printf("Failed to connect to the X\n");
-                                               return;
-                                       }
-
-                                       if (do_capture(disp, (Pixmap)pixmap, path) == 0) {
-                                               printf("Captured: %s\n", path);
-                                       }
-                                       XCloseDisplay(disp);
-                               } else {
-                                       printf("Unsupported type\n");
-                               }
-                       } else {
-                               printf("Buffer is not exists\n");
-                       }
-               }
-       } else {
-               printf("target only can be a filename\n");
-       }
-}
-
-static void do_x(const char *cmd)
-{
-       Display *disp;
-
-       cmd = trim_cmd(cmd + 2);
-       if (!*cmd) {
-               return;
-       }
-
-       disp = XOpenDisplay(NULL);
-       if (!disp) {
-               printf("Failed to connect to the X\n");
-               return;
-       }
-
-       if (!strncasecmp(cmd, "damage ", 7)) {
-               unsigned int winId;
-               XRectangle rect;
-               XserverRegion region;
-               int x, y, w, h;
-
-               cmd += 7;
-
-               if (sscanf(cmd, "%u %d %d %d %d", &winId, &x, &y, &w, &h) != 5) {
-                       printf("Invalid argument\nx damage WINID_DEC X Y W H\n");
-                       return;
-               }
-               rect.x = x;
-               rect.y = y;
-               rect.width = w;
-               rect.height = h;
-               region = XFixesCreateRegion(disp, &rect, 1);
-               XDamageAdd(disp, winId, region);
-               XFixesDestroyRegion(disp, region);
-               XFlush(disp);
-
-               printf("Damage: %u %d %d %d %d\n", winId, x, y, w, h);
-       } else if (!strncasecmp(cmd, "capture ", 8)) {
-               unsigned int winId;
-               char filename[256];
-
-               cmd += 8;
-
-               if (sscanf(cmd, "%u %255[^ ]", &winId, filename) != 2) {
-                       printf("Invalid argument\nx capture WINID_DEC FILENAME (%s)\n", cmd);
-                       return;
-               }
-               if (do_capture(disp, winId, filename) == 0) {
-                       printf("Captured: %s\n", filename);
-               }
-       } else if (!strncasecmp(cmd, "resize ", 7)) {
-               unsigned int winId;
-               int w;
-               int h;
-
-               cmd += 7;
-
-               if (sscanf(cmd, "%u %d %d", &winId, &w, &h) != 3) {
-                       printf("Invalid argument\nx resize WINID_DEC W H\n");
-                       return;
-               }
-
-               XResizeWindow(disp, winId, w, h);
-               printf("Resize: %u %d %d\n", winId, w, h);
-       } else if (!strncasecmp(cmd, "move ", 5)) {
-               unsigned int winId;
-               int x;
-               int y;
-
-               cmd += 5;
-               if (sscanf(cmd, "%u %d %d", &winId, &x, &y) != 3) {
-                       printf("Invalid argument\nx move WINID_DEC X Y\n");
-                       return;
-               }
-
-               XMoveWindow(disp, winId, x, y);
-               printf("Move: %u %d %d\n", winId, x, y);
-       } else if (!strncasecmp(cmd, "map ", 4)) {
-               unsigned int winId;
-               cmd += 4;
-               if (sscanf(cmd, "%u", &winId) != 1) {
-                       printf("Invalid argument\nx map WINID_DEC\n");
-                       return;
-               }
-               XMapRaised(disp, winId);
-               printf("Map: %u\n", winId);
-       } else if (!strncasecmp(cmd, "unmap ", 6)) {
-               unsigned int winId;
-               cmd += 6;
-               if (sscanf(cmd, "%u", &winId) != 1) {
-                       printf("Invalid argument\nx unmap WINID_DEC\n");
-                       return;
-               }
-               XUnmapWindow(disp, winId);
-               printf("Unmap: %u\n", winId);
-       } else {
-               printf("Unknown command\n");
-       }
-
-       XCloseDisplay(disp);
-}
-
-static inline void put_command(const char *cmd)
-{
-       if (s_info.history[s_info.history_top]) {
-               free(s_info.history[s_info.history_top]);
-               s_info.history[s_info.history_top] = NULL;
-       }
-
-       s_info.history[s_info.history_top] = strdup(cmd);
-       s_info.history_top = (s_info.history_top + !!s_info.history[s_info.history_top]) % (sizeof(s_info.history) / sizeof(s_info.history[0]));
-}
-
-static inline const char *get_command(int idx)
-{
-       idx = s_info.history_top + idx;
-       while (idx < 0) {
-               idx += (sizeof(s_info.history) / sizeof(s_info.history[0]));
-       }
-
-       return s_info.history[idx];
-}
-
-static void do_command(const char *cmd)
-{
-       /* Skip the first spaces */
-       cmd = trim_cmd(cmd);
-
-       if (strlen(cmd) && *cmd != '#') {
-               if (!strncasecmp(cmd, "exit", 4) || !strncasecmp(cmd, "quit", 4)) {
-                       ecore_main_loop_quit();
-               } else if (!strncasecmp(cmd, "set ", 4)) {
-                       if (do_set(cmd) == 0) {
-                               return;
-                       }
-               } else if (!strncasecmp(cmd, "stat ", 5)) {
-                       do_stat(cmd);
-               } else if (!strncasecmp(cmd, "get ", 4)) {
-                       if (do_get(cmd) == 0) {
-                               return;
-                       }
-               } else if (!strncasecmp(cmd, "ls", 2)) {
-                       if (do_ls(cmd) == 0) {
-                               return;
-                       }
-               } else if (!strncasecmp(cmd, "cd", 2)) {
-                       if (do_cd(cmd) == 0) {
-                               return;
-                       }
-               } else if (!strncasecmp(cmd, "rm", 2)) {
-                       if (do_rm(cmd) == 0) {
-                               return;
-                       }
-               } else if (!strncasecmp(cmd, "fault", 5)) {
-                       if (do_fault(cmd) == 0) {
-                               return;
-                       }
-               } else if (!strncasecmp(cmd, "sh ", strlen("sh "))) {
-                       do_sh(cmd);
-               } else if (!strncasecmp(cmd, "x ", strlen("x "))) {
-                       do_x(cmd);
-               } else if (!strncasecmp(cmd, "dump", strlen("dump"))) {
-                       do_dump(cmd);
-               } else if (!strncasecmp(cmd, "monitor", strlen("monitor"))) {
-                       do_monitor(cmd);
-               } else if (!strncasecmp(cmd, "demonitor", strlen("demonitor"))) {
-                       do_demonitor(cmd);
-               } else if (!strncasecmp(cmd, "get_content", strlen("get_content"))) {
-                       do_get_content(cmd);
-               } else if (!strncasecmp(cmd, "get_list", strlen("get_list"))) {
-                       do_get_list(cmd);
-               } else if (!strncasecmp(cmd, "frame_dump", strlen("frame_dump"))) {
-                       do_frame_dump(cmd);
-               } else {
-                       help();
-               }
-       }
-
-       prompt(NULL);
-       return;
-}
-
-#define CMD_BUFFER_SIZE 256
-
-static Eina_Bool input_cb(void *data, Ecore_Fd_Handler *fd_handler)
-{
-       static int idx = 0;
-       static char cmd_buffer[CMD_BUFFER_SIZE];
-       unsigned char ch;
-       int fd;
-       int ret;
-       const char escape_str[] = { 0x1b, 0x5b, 0x0 };
-       const char *escape_ptr = escape_str;
-       const char *tmp;
-
-       if (fd_handler) {
-               fd = ecore_main_fd_handler_fd_get(fd_handler);
-               if (fd < 0) {
-                       printf("FD is not valid: %d\n", fd);
-                       return ECORE_CALLBACK_CANCEL;
-               }
-       } else {
-               fd = s_info.input_fd;
-       }
-
-       /*!
-        * \note
-        * Using this routine, we can implement the command recommend algorithm.
-        * When a few more characters are matched with history of command, we can show it to user
-        * Then the user will choose one or write new command
-        */
-
-       /* Silly.. Silly */
-       while ((ret = read(fd, &ch, sizeof(ch))) == sizeof(ch)) {
-               if (*escape_ptr == '\0') {
-                       /* Function key */
-                       switch (ch) {
-                       case 0x41: /* UP */
-                               printf("%s2K%s1G", escape_str, escape_str);
-                               tmp = get_command(--s_info.history_idx);
-                               if (!tmp) {
-                                       s_info.history_idx = 0;
-                                       cmd_buffer[0] = '\0';
-                                       prompt(NULL);
-                               } else {
-                                       strncpy(cmd_buffer, tmp, CMD_BUFFER_SIZE - 1);
-                                       cmd_buffer[CMD_BUFFER_SIZE - 1]  = '\0';
-                                       idx = strlen(cmd_buffer);
-                                       prompt(cmd_buffer);
-                               }
-                               break;
-                       case 0x42: /* DOWN */
-                               if (s_info.history_idx >= 0) {
-                                       break;
-                               }
-
-                               printf("%s2K%s1G", escape_str, escape_str);
-                               tmp = get_command(++s_info.history_idx);
-                               if (s_info.history_idx == 0) {
-                                       s_info.history_idx = 0;
-                                       cmd_buffer[0] = '\0';
-                                       prompt(NULL);
-                               } else {
-                                       strncpy(cmd_buffer, tmp, CMD_BUFFER_SIZE - 1);
-                                       cmd_buffer[CMD_BUFFER_SIZE - 1]  = '\0';
-                                       idx = strlen(cmd_buffer);
-                                       prompt(cmd_buffer);
-                               }
-                               break;
-                       case 0x43: /* RIGHT */
-                               break;
-                       case 0x44: /* LEFT */
-                               break;
-                       default:
-                               break;
-                       }
-
-                       escape_ptr = escape_str;
-                       continue;
-               } else if (ch == *escape_ptr) {
-                       escape_ptr++;
-                       continue;
-               }
-
-               switch (ch) {
-               case 0x7F: /* BKSP */
-               case 0x80:
-                       cmd_buffer[idx] = '\0';
-                       if (idx > 0) {
-                               idx--;
-                               cmd_buffer[idx] = ' ';
-                               putc('\r', stdout);
-                               prompt(cmd_buffer);
-                       }
-
-                       cmd_buffer[idx] = '\0';
-                       putc('\r', stdout);
-                       prompt(cmd_buffer);
-                       break;
-               case 0x09: /* TAB */
-                       if (!s_info.quick_search_node) {
-                               s_info.quick_search_node = node_child(s_info.curdir);
-                               s_info.quick_idx = idx;
-                       } else {
-                               s_info.quick_search_node = node_next_sibling(s_info.quick_search_node);
-                               idx = s_info.quick_idx;
-                       }
-
-                       if (!s_info.quick_search_node) {
-                               break;
-                       }
-
-                       printf("%s2K%s1G", escape_str, escape_str);
-                       strcpy(cmd_buffer + idx, node_name(s_info.quick_search_node));
-                       idx += strlen(node_name(s_info.quick_search_node));
-                       prompt(cmd_buffer);
-                       break;
-               case '\n':
-               case '\r':
-                       cmd_buffer[idx] = '\0';
-                       idx = 0;
-                       if (s_info.input_fd == STDIN_FILENO || s_info.verbose) {
-                               putc((int)'\n', stdout);
-                       }
-                       do_command(cmd_buffer);
-                       put_command(cmd_buffer);
-                       memset(cmd_buffer, 0, sizeof(cmd_buffer));
-                       s_info.history_idx = 0;
-                       s_info.quick_search_node = NULL;
-
-                       /* Make a main loop processing for command handling */
-                       return ECORE_CALLBACK_RENEW;
-               default:
-                       if (isascii(ch)) {
-                               cmd_buffer[idx++] = ch;
-
-                               if (s_info.input_fd == STDIN_FILENO || s_info.verbose) {
-                                       putc((int)ch, stdout);
-                               }
-
-                               if (idx == sizeof(cmd_buffer) - 1) {
-                                       cmd_buffer[idx] = '\0';
-                                       printf("\nCommand buffer is overflow: %s\n", cmd_buffer);
-                                       idx = 0;
-                               }
-                       } else {
-                               printf("Unknown character: 0x%X\n", (unsigned int)ch);
-                       }
-                       break;
-               }
-       }
-
-       if (ret < 0 && !fd_handler) {
-               ecore_main_loop_quit();
-       }
-
-       return ECORE_CALLBACK_RENEW;
-}
-
-static void processing_line_buffer(const char *buffer)
-{
-       int pid;
-       char slavename[256];
-       char pkgname[256];
-       char abi[256];
-       char inst_id[4096];
-       char buf_id[256];
-       char cluster[256];
-       char category[256];
-       char str_period[64];
-       char state[10];
-       int refcnt;
-       int fault_count;
-       int list_count;
-       int loaded_inst;
-       int loaded_pkg;
-       double ttl;
-       int secured;
-       double period;
-       int width;
-       int height;
-       struct node *node;
-       struct package *pkginfo;
-       struct instance *instinfo;
-       struct slave *slaveinfo;
-       long i;
-
-       switch (s_info.cmd) {
-       case PKG_LIST:
-               if (sscanf(buffer, "%d %255[^ ] %255[^ ] %255[^ ] %d %d %d", &pid, slavename, pkgname, abi, &refcnt, &fault_count, &list_count) != 7) {
-                       printf("Invalid format : [%s]\n", buffer);
-                       return;
-               }
-
-               node = node_find(s_info.targetdir, pkgname);
-               if (!node) {
-                       pkginfo = calloc(1, sizeof(*pkginfo));
-                       if (!pkginfo) {
-                               printf("calloc: %d\n", errno);
-                               return;
-                       }
-
-                       pkginfo->pkgid = strdup("conf.file");
-                       if (!pkginfo->pkgid) {
-                               printf("strdup: %d\n", errno);
-                       }
-
-                       pkginfo->primary = 1;
-
-                       node = node_create(s_info.targetdir, pkgname, NODE_DIR, NODE_READ | NODE_EXEC);
-                       if (!node) {
-                               free(pkginfo->pkgid);
-                               free(pkginfo);
-                               printf("Failed to create a new node (%s)\n", pkgname);
-                               return;
-                       }
-
-                       node_set_data(node, pkginfo);
-               } else {
-                       pkginfo = node_data(node);
-                       if (!pkginfo) {
-                               printf("Package info is inavlid\n");
-                               return;
-                       }
-
-                       free(pkginfo->slavename);
-                       free(pkginfo->abi);
-
-                       pkginfo->slavename = NULL;
-                       pkginfo->abi = NULL;
-               }
-
-               node_set_age(node, s_info.age);
-
-               pkginfo->slavename = strdup(slavename);
-               if (!pkginfo->slavename) {
-                       printf("strdup: %d\n", errno);
-               }
-
-               pkginfo->abi = strdup(abi);
-               if (!pkginfo->abi) {
-                       printf("strdup: %d\n", errno);
-               }
-
-               pkginfo->pid = pid;
-               pkginfo->refcnt = refcnt;
-               pkginfo->fault_count = fault_count;
-               pkginfo->inst_count = list_count;
-               break;
-       case SLAVE_LIST:
-               if (sscanf(buffer, "%d %[^ ] %[^ ] %[^ ] %d %d %d %[^ ] %d %d %lf", &pid, slavename, pkgname, abi, &secured, &refcnt, &fault_count, state, &loaded_inst, &loaded_pkg, &ttl) != 11) {
-                       printf("Invalid format : [%s]\n", buffer);
-                       return;
-               }
-               node = node_find(s_info.targetdir, slavename);
-               if (!node) {
-                       slaveinfo = calloc(1, sizeof(*slaveinfo));
-                       if (!slaveinfo) {
-                               printf("Error: %d\n", errno);
-                               return;
-                       }
-
-                       node = node_create(s_info.targetdir, slavename, NODE_DIR, NODE_READ | NODE_EXEC);
-                       if (!node) {
-                               free(slaveinfo);
-                               return;
-                       }
-
-                       node_set_data(node, slaveinfo);
-               } else {
-                       slaveinfo = node_data(node);
-               }
-
-               node_set_age(node, s_info.age);
-
-               free(slaveinfo->pkgname);
-               free(slaveinfo->abi);
-               free(slaveinfo->state);
-
-               slaveinfo->pkgname = strdup(pkgname);
-               if (!slaveinfo->pkgname) {
-                       printf("strdup: %d\n", errno);
-               }
-
-               slaveinfo->abi = strdup(abi);
-               if (!slaveinfo->abi) {
-                       printf("strdup: %d\n", errno);
-               }
-
-               slaveinfo->state = strdup(state);
-               if (!slaveinfo->state) {
-                       printf("strdup: %d\n", errno);
-               }
-
-               slaveinfo->pid = pid;
-               slaveinfo->secured = secured;
-               slaveinfo->refcnt = refcnt;
-               slaveinfo->fault_count = fault_count;
-               slaveinfo->loaded_inst = loaded_inst;
-               slaveinfo->loaded_pkg = loaded_pkg;
-               slaveinfo->ttl = ttl;
-               break;
-       case INST_LIST:
-               if (sscanf(buffer, "%[^ ] %[^ ] %[^ ] %[^ ] %[^ ] %[^ ] %d %d", inst_id, buf_id, cluster, category, str_period, state, &width, &height) != 8) {
-                       if (sscanf(buffer, "%[^ ] %[^ ] %[^ ] %[^ ] %[^ ] %d %d", inst_id, cluster, category, str_period, state, &width, &height) != 7) {
-                               printf("Invalid format : [%s]\n", buffer);
-                               return;
-                       } else {
-                               buf_id[0] = '\0';
-                       }
-               }
-
-               period = strtod(str_period, NULL);
-
-               for (i = strlen(inst_id); i > 0 && inst_id[i] != '/'; i--);
-               i += (inst_id[i] == '/');
-
-               node = node_find(s_info.targetdir, inst_id + i);
-               if (!node) {
-                       instinfo = calloc(1, sizeof(*instinfo));
-                       if (!instinfo) {
-                               printf("calloc: %d\n", errno);
-                               return;
-                       }
-
-                       node = node_create(s_info.targetdir, inst_id + i, NODE_FILE, NODE_READ | NODE_WRITE);
-                       if (!node) {
-                               free(instinfo);
-                               return;
-                       }
-
-                       node_set_data(node, instinfo);
-               } else {
-                       instinfo = node_data(node);
-               }
-
-               node_set_age(node, s_info.age);
-
-               free(instinfo->id);
-               instinfo->id = NULL;
-               free(instinfo->buf_id);
-               instinfo->buf_id = NULL;
-               free(instinfo->cluster);
-               instinfo->cluster = NULL;
-               free(instinfo->category);
-               instinfo->category = NULL;
-               free(instinfo->state);
-               instinfo->state = NULL;
-
-               instinfo->id = strdup(inst_id);
-               if (!instinfo->id) {
-                       printf("strdup: %d\n", errno);
-               }
-
-               instinfo->cluster = strdup(cluster);
-               if (!instinfo->cluster) {
-                       printf("strdup: %d\n", errno);
-               }
-
-               instinfo->category = strdup(category);
-               if (!instinfo->category) {
-                       printf("strdup: %d\n", errno);
-               }
-
-               instinfo->state = strdup(state);
-               if (!instinfo->state) {
-                       printf("strdup: %d\n", errno);
-               }
-
-               if (strlen(buf_id)) {
-                       instinfo->buf_id = strdup(buf_id);
-               }
-
-               instinfo->period = period;
-               instinfo->width = width;
-               instinfo->height = height;
-               break;
-       case INST_CTRL:
-               sscanf(buffer, "%ld", &i);
-               printf("%ld\n", i);
-               printf("Result: %ld\n", i);
-               break;
-       case SLAVE_CTRL:
-               sscanf(buffer, "%ld", &i);
-               printf("Result: %ld\n", i);
-               break;
-       case MASTER_CTRL:
-               sscanf(buffer, "%ld", &i);
-               printf("Result: %ld\n", i);
-               break;
-       default:
-               break;
-       }
-}
-
-static inline void do_line_command(void)
-{
-       switch (s_info.cmd) {
-       case PKG_LIST:
-               ls();
-               break;
-       case INST_LIST:
-               ls();
-               break;
-       case SLAVE_LIST:
-               ls();
-               break;
-       case INST_CTRL:
-               break;
-       case SLAVE_CTRL:
-               break;
-       case MASTER_CTRL:
-               break;
-       default:
-               break;
-       }
-       prompt(NULL);
-}
-
-static Eina_Bool read_cb(void *data, Ecore_Fd_Handler *fd_handler)
-{
-       int fd;
-       static char *line_buffer = NULL;
-       static int line_index = 0;
-       static int bufsz = 256;
-       char ch;
-
-       fd = ecore_main_fd_handler_fd_get(fd_handler);
-       if (fd < 0) {
-               printf("FD is not valid: %d\n", fd);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       if (read(fd, &ch, sizeof(ch)) != sizeof(ch)) {
-               printf("read: %d\n", errno);
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       if (!line_buffer) {
-               line_index = 0;
-               line_buffer = malloc(bufsz);
-               if (!line_buffer) {
-                       printf("malloc: %d\n", errno);
-                       return ECORE_CALLBACK_CANCEL;
-               }
-       }       
-
-       if (ch == '\n') { /* End of a line */
-               if (line_index == bufsz - 1) {
-                       char *new_buf;
-                       new_buf = realloc(line_buffer, bufsz + 2);
-                       if (!new_buf) {
-                               printf("realloc: %d\n", errno);
-                               free(line_buffer);
-                               line_buffer = NULL;
-                               line_index = 0;
-                               bufsz = 256;
-                               return ECORE_CALLBACK_CANCEL;
-                       }
-
-                       line_buffer = new_buf;
-               }
-
-               line_buffer[line_index] = '\0';
-
-               if (!strcmp(line_buffer, "EOD")) {
-                       do_line_command();
-                       s_info.cmd = NOP;
-               } else {
-                       processing_line_buffer(line_buffer);
-               }
-
-               free(line_buffer);
-               line_buffer = NULL;
-               line_index = 0;
-               bufsz = 256;
-       } else {
-               char *new_buf;
-
-               line_buffer[line_index++] = ch;
-               if (line_index == bufsz - 1) {
-                       bufsz += 256;
-                       new_buf = realloc(line_buffer, bufsz);
-                       if (!new_buf) {
-                               printf("realloc: %d\n", errno);
-                               free(line_buffer);
-                               line_buffer = NULL;
-                               line_index = 0;
-                               bufsz = 256;
-                               return ECORE_CALLBACK_CANCEL;
-                       }
-
-                       line_buffer = new_buf;
-               }
-       }
-
-       return ECORE_CALLBACK_RENEW;
-}
-
-static int ret_cb(pid_t pid, int handle, const struct packet *packet, void *data)
-{
-       const char *fifo_name;
-       int ret;
-
-       if (packet_get(packet, "si", &fifo_name, &ret) != 2) {
-               printf("Invalid packet\n");
-               return -EFAULT;
-       }
-
-       if (ret != 0) {
-               printf("Returns %d\n", ret);
-               return ret;
-       }
-
-       printf("FIFO: %s\n", fifo_name);
-
-       s_info.fifo_handle = open(fifo_name, O_RDONLY | O_NONBLOCK);
-       if (s_info.fifo_handle < 0) {
-               printf("open: %d\n", errno);
-               s_info.fifo_handle = -EINVAL;
-               ecore_main_loop_quit();
-               return -EINVAL;
-       }
-
-       s_info.fd_handler = ecore_main_fd_handler_add(s_info.fifo_handle, ECORE_FD_READ, read_cb, NULL, NULL, NULL);
-       if (!s_info.fd_handler) {
-               printf("Failed to add a fd handler\n");
-               if (close(s_info.fifo_handle) < 0) {
-                       printf("close: %d\n", errno);
-               }
-               s_info.fifo_handle = -EINVAL;
-               ecore_main_loop_quit();
-               return -EFAULT;
-       }
-
-       prompt(NULL);
-
-       if (s_info.input_fd == STDIN_FILENO) {
-               if (fcntl(s_info.input_fd, F_SETFL, O_NONBLOCK) < 0) {
-                       printf("fcntl: %d\n", errno);
-               }
-
-               s_info.in_handler = ecore_main_fd_handler_add(s_info.input_fd, ECORE_FD_READ, input_cb, NULL, NULL, NULL);
-               if (!s_info.in_handler) {
-                       printf("Failed to add a input handler\n");
-                       ecore_main_loop_quit();
-                       return -EFAULT;
-               }
-       }
-
-       return 0;
-}
-
-static int disconnected_cb(int handle, void *data)
-{
-       if (s_info.fd == handle) {
-               printf("Disconnected\n");
-               ecore_main_loop_quit();
-       } else {
-               printf("Disconnected: %d <> %d\n", s_info.fd, handle);
-       }
-       return 0;
-}
-
-static int connected_cb(int handle, void *data)
-{
-       struct packet *packet;
-
-       if (s_info.fd != -EINVAL && s_info.fd != handle) {
-               printf("Connected: %d <> %d\n", s_info.fd, handle);
-               return 0;
-       }
-
-       printf("Connected\n");
-
-       packet = packet_create("widget_mgr_hello", "d", 0.0f);
-       if (!packet) {
-               printf("Failed to build a packet for hello\n");
-               com_core_packet_client_fini(s_info.fd);
-               s_info.fd = -EINVAL;
-               return -EFAULT;
-       }
-
-       s_info.fd = handle;
-
-       if (com_core_packet_async_send(s_info.fd, packet, 0.0f, ret_cb, NULL) < 0) {
-               printf("Failed to send a packet hello\n");
-               packet_destroy(packet);
-               com_core_packet_client_fini(s_info.fd);
-               s_info.fd = -EINVAL;
-               return -EFAULT;
-       }
-
-       packet_destroy(packet);
-       return 0;
-}
-
-int main(int argc, char *argv[])
-{
-       struct termios ttystate;
-       static struct method s_table[] = {
-               {
-                       .cmd = NULL,
-                       .handler = NULL,
-               },
-       };
-       static struct option long_options[] = {
-               { "batchmode", required_argument, 0, 'b' },
-               { "help", no_argument, 0, 'h' },
-               { "verbose", required_argument, 0, 'v' },
-               { "execute", required_argument, 0, 'x' },
-               { 0, 0, 0, 0 }
-       };
-       int option_index;
-       int c;
-
-       do {
-               c = getopt_long(argc, argv, "b:hv:x:d", long_options, &option_index);
-               switch (c) {
-               case 'b':
-                       if (!optarg || !*optarg) {
-                               printf("Invalid argument\n");
-                               help();
-                               return -EINVAL;
-                       }
-
-                       if (s_info.input_fd != STDIN_FILENO) {
-                               /* Close the previously, opened file */
-                               if (close(s_info.input_fd) < 0) {
-                                       printf("close: %d\n", errno);
-                               }
-                       }
-
-                       s_info.input_fd = open(optarg, O_RDONLY);
-                       if (s_info.input_fd < 0) {
-                               printf("Unable to access %s (%d)\n", optarg, errno);
-                               return -EIO;
-                       }
-                       break;
-               case 'h':
-                       help();
-                       return 0;
-               case 'v':
-                       if (!optarg || !*optarg) {
-                               printf("Invalid argument\n");
-                               help();
-                               return -EINVAL;
-                       }
-
-                       s_info.verbose = !strcmp(optarg, "true");
-                       break;
-               case 'x':
-                       if (!optarg || !*optarg) {
-                               printf("Invalid argument\n");
-                               help();
-                               return -EINVAL;
-                       }
-                       break;
-               case 'd':
-                       /** Dump all buffer to a files */
-                       s_info.dump = 1;
-                       break;
-               default:
-                       break;
-               }
-       } while (c != -1);
-
-       ecore_init();
-
-#if (GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 36)
-       g_type_init();
-#endif
-
-       /**
-        * Make the system daemon can access proc file to validate myself
-        */
-
-       com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL);
-       com_core_add_event_callback(CONNECTOR_CONNECTED, connected_cb, NULL);
-       widget_service_init();
-
-       s_info.fd = com_core_packet_client_init(SOCKET_FILE, 0, s_table);
-       if (s_info.fd < 0) {
-               printf("Failed to make a connection\n");
-               return -EIO;
-       }
-
-       if (s_info.input_fd == STDIN_FILENO) {
-               printf("Type your command on below empty line\n");
-
-               if (tcgetattr(s_info.input_fd, &ttystate) < 0) {
-                       printf("Error: %d\n", errno);
-               } else {
-                       ttystate.c_lflag &= ~(ICANON | ECHO);
-                       ttystate.c_cc[VMIN] = 1;
-
-                       if (tcsetattr(s_info.input_fd, TCSANOW, &ttystate) < 0) {
-                               printf("Error: %d\n", errno);
-                       }
-               }
-       } else {
-               printf("Batch mode enabled\n");
-       }
-
-       if (setvbuf(stdout, (char *)NULL, _IONBF, 0) != 0) {
-               printf("setvbuf: %d\n", errno);
-       }
-
-       init_directory();
-
-       ecore_main_loop_begin();
-
-       fini_directory();
-       widget_service_fini();
-
-       if (s_info.fd > 0) {
-               com_core_packet_client_fini(s_info.fd);
-               s_info.fd = -EINVAL;
-       }
-
-       if (s_info.fd_handler) {
-               ecore_main_fd_handler_del(s_info.fd_handler);
-               s_info.fd_handler = NULL;
-       }
-
-       if (s_info.input_fd == STDIN_FILENO) {
-               ttystate.c_lflag |= ICANON | ECHO;
-               if (tcsetattr(s_info.input_fd, TCSANOW, &ttystate) < 0) {
-                       printf("tcsetattr: %d\n", errno);
-               }
-       } else {
-               if (close(s_info.input_fd) < 0) {
-                       printf("close: %d\n", errno);
-               }
-       }
-
-       if (s_info.fifo_handle > 0) {
-               if (close(s_info.fifo_handle) < 0) {
-                       printf("close: %d\n", errno);
-               }
-               s_info.fifo_handle = -EINVAL;
-       }
-
-       if (s_info.in_handler) {
-               ecore_main_fd_handler_del(s_info.in_handler);
-               s_info.in_handler = NULL;
-       }
-
-       ecore_shutdown();
-       putc((int)'\n', stdout);
-       return 0;
-}
-
-/* End of a file */