summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-02-01 04:06:58 (GMT)
committerjk7744.park <jk7744.park@samsung.com>2015-02-01 04:06:58 (GMT)
commit5c0922653889209693ca3f6495c50e6cf900cc1e (patch)
tree54957d4196c4f2428de14b558054cf3f33117a29
parent61a319403b0dd277ab47a2e08a1ce6a6e1cd9e0a (diff)
downloaddata-provider-master-tizen_2.3.zip
data-provider-master-tizen_2.3.tar.gz
data-provider-master-tizen_2.3.tar.bz2
-rw-r--r--[-rwxr-xr-x]CMakeLists.txt55
-rw-r--r--data-provider-master.desktop9
-rw-r--r--data-provider-master.rule5
-rw-r--r--data/CMakeLists.txt9
-rw-r--r--data/data-provider-master.service12
-rw-r--r--data/device/abi.ini (renamed from data/abi.ini)3
-rw-r--r--data/device/wayland.mobile.conf.ini (renamed from data/wayland.mobile.conf.ini)7
-rw-r--r--data/device/wayland.mobile.resolution.ini (renamed from data/wayland.mobile.resolution.ini)0
-rw-r--r--data/device/wayland.wearable.conf.ini (renamed from data/wayland.wearable.conf.ini)7
-rw-r--r--data/device/wayland.wearable.resolution.ini (renamed from data/wayland.wearable.resolution.ini)0
-rw-r--r--data/device/x11.mobile.320x480.conf.ini38
-rw-r--r--data/device/x11.mobile.320x480.resolution.ini14
-rw-r--r--data/device/x11.mobile.360x360.conf.ini0
-rw-r--r--data/device/x11.mobile.360x360.resolution.ini0
-rw-r--r--data/device/x11.mobile.360x480.conf.ini0
-rw-r--r--data/device/x11.mobile.360x480.resolution.ini0
-rw-r--r--data/device/x11.mobile.480x800.conf.ini45
-rw-r--r--data/device/x11.mobile.480x800.resolution.ini14
-rw-r--r--data/device/x11.mobile.conf.ini40
-rw-r--r--data/device/x11.mobile.resolution.ini (renamed from data/x11.mobile.resolution.ini)0
-rw-r--r--data/device/x11.wearable.360x360.conf.ini (renamed from data/x11.wearable.conf.ini)10
-rw-r--r--data/device/x11.wearable.360x360.resolution.ini14
-rw-r--r--data/device/x11.wearable.360x480.conf.ini38
-rw-r--r--data/device/x11.wearable.360x480.resolution.ini14
-rw-r--r--data/device/x11.wearable.conf.ini40
-rw-r--r--data/device/x11.wearable.resolution.ini14
-rw-r--r--data/dump_dynamicbox.sh8
-rw-r--r--data/dump_livebox.sh7
-rw-r--r--data/emulator/abi.ini14
-rw-r--r--data/emulator/wayland.mobile.conf.ini38
-rw-r--r--data/emulator/wayland.mobile.resolution.ini13
-rw-r--r--data/emulator/wayland.wearable.conf.ini38
-rw-r--r--data/emulator/wayland.wearable.resolution.ini (renamed from data/x11.wearable.resolution.ini)0
-rw-r--r--data/emulator/x11.mobile.320x480.conf.ini38
-rw-r--r--data/emulator/x11.mobile.320x480.resolution.ini14
-rw-r--r--data/emulator/x11.mobile.360x360.conf.ini0
-rw-r--r--data/emulator/x11.mobile.360x360.resolution.ini0
-rw-r--r--data/emulator/x11.mobile.360x480.conf.ini0
-rw-r--r--data/emulator/x11.mobile.360x480.resolution.ini0
-rw-r--r--data/emulator/x11.mobile.480x800.conf.ini45
-rw-r--r--data/emulator/x11.mobile.480x800.resolution.ini14
-rw-r--r--data/emulator/x11.mobile.conf.ini40
-rw-r--r--data/emulator/x11.mobile.resolution.ini13
-rw-r--r--data/emulator/x11.wearable.360x360.conf.ini (renamed from data/x11.mobile.conf.ini)14
-rw-r--r--data/emulator/x11.wearable.360x360.resolution.ini14
-rw-r--r--data/emulator/x11.wearable.360x480.conf.ini38
-rw-r--r--data/emulator/x11.wearable.360x480.resolution.ini14
-rw-r--r--data/emulator/x11.wearable.conf.ini40
-rw-r--r--data/emulator/x11.wearable.resolution.ini14
-rw-r--r--data/mobile.data-provider-master.service29
-rw-r--r--include/buffer_handler.h44
-rw-r--r--include/client_life.h4
-rw-r--r--include/conf.h173
-rw-r--r--include/debug.h2
-rw-r--r--include/event.h59
-rw-r--r--include/group.h4
-rw-r--r--include/instance.h117
-rw-r--r--include/io.h6
-rw-r--r--include/lite-errno.h53
-rw-r--r--include/package.h55
-rw-r--r--include/parser.h18
-rw-r--r--include/setting.h10
-rw-r--r--include/slave_life.h18
-rw-r--r--include/util.h1
-rw-r--r--packaging/data-provider-master.manifest31
-rwxr-xr-xpackaging/data-provider-master.spec82
-rw-r--r--pkgmgr_dynamicbox/CMakeLists.txt (renamed from pkgmgr_livebox/CMakeLists.txt)6
-rw-r--r--pkgmgr_dynamicbox/dynamicbox.xml (renamed from pkgmgr_livebox/livebox.xml)35
-rw-r--r--pkgmgr_dynamicbox/dynamicbox.xsd88
-rw-r--r--pkgmgr_dynamicbox/include/dlist.h (renamed from pkgmgr_livebox/include/dlist.h)0
-rw-r--r--pkgmgr_dynamicbox/src/dlist.c (renamed from pkgmgr_livebox/src/dlist.c)0
-rw-r--r--pkgmgr_dynamicbox/src/service_register.c3308
-rw-r--r--pkgmgr_livebox/src/service_register.c3194
-rw-r--r--res/edje/CMakeLists.txt8
-rw-r--r--src/abi.c18
-rw-r--r--src/badge_service.c28
-rw-r--r--src/buffer_handler.c650
-rw-r--r--src/buffer_handler_wayland.c116
-rw-r--r--src/client_life.c86
-rw-r--r--src/client_rpc.c26
-rw-r--r--src/conf.c953
-rw-r--r--src/critical_log.c27
-rw-r--r--src/dead_monitor.c1
-rw-r--r--src/event.c930
-rw-r--r--src/fault_manager.c38
-rw-r--r--src/file_service.c53
-rw-r--r--src/group.c92
-rw-r--r--src/instance.c1619
-rw-r--r--src/io.c137
-rw-r--r--src/liveinfo.c6
-rw-r--r--src/main.c109
-rw-r--r--src/notification_service.c243
-rw-r--r--src/package.c636
-rw-r--r--src/parser.c195
-rw-r--r--src/pkgmgr.c80
-rw-r--r--src/script_handler.c225
-rw-r--r--src/server.c5996
-rw-r--r--src/service_common.c16
-rw-r--r--src/setting.c114
-rw-r--r--src/shortcut_service.c20
-rw-r--r--src/slave_life.c594
-rw-r--r--src/slave_rpc.c99
-rw-r--r--src/util.c167
-rw-r--r--src/util_wayland.c8
-rw-r--r--src/util_x11.c18
-rw-r--r--src/utility_service.c52
-rw-r--r--src/xmonitor.c63
-rw-r--r--src/xmonitor_wayland.c28
-rw-r--r--util_liveinfo/CMakeLists.txt2
-rw-r--r--util_liveinfo/include/node.h8
-rw-r--r--util_liveinfo/src/liveinfo.c3133
-rw-r--r--util_liveinfo/src/node.c508
112 files changed, 13247 insertions, 11996 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f11d495..c0a6f7f 100755..100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,6 @@ PROJECT(data-provider-master C)
INCLUDE(FindPkgConfig)
pkg_check_modules(pkg REQUIRED
- ail
dlog
aul
vconf
@@ -22,12 +21,13 @@ pkg_check_modules(pkg REQUIRED
badge-service
libsmack
shortcut
+ pkgmgr-info
libsystemd-daemon
)
IF (LIVEBOX)
pkg_check_modules(pkg_livebox REQUIRED
- livebox-service
+ dynamicbox_service
)
ENDIF (LIVEBOX)
@@ -52,7 +52,7 @@ pkg_check_modules(pkg_extra REQUIRED
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")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Winline -Werror -fno-builtin-malloc -fno-omit-frame-pointer -g -fPIE")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
@@ -78,6 +78,7 @@ ADD_DEFINITIONS("-DSHORTCUT_SMACK_LABEL=\"data-provider-master::shortcut\"")
ADD_DEFINITIONS("-DNOTIFICATION_SMACK_LABEL=\"data-provider-master::notification\"")
ADD_DEFINITIONS("-DBADGE_SMACK_LABEL=\"data-provider-master::badge\"")
ADD_DEFINITIONS("-DDATA_SHARE_LABEL=\"data-provider-master::share\"")
+ADD_DEFINITIONS("-DDEFAULT_SMACK_LABEL=\"data-provider-master\"")
ADD_DEFINITIONS("-DDEFAULT_MASTER_CONF=\"/usr/share/data-provider-master/conf.ini\"")
@@ -100,7 +101,6 @@ SET(BUILD_SOURCE
src/badge_service.c
src/notification_service.c
src/service_common.c
- src/conf.c
)
IF (LIVEBOX)
@@ -126,11 +126,12 @@ IF (LIVEBOX)
src/pkgmgr.c
src/event.c
src/file_service.c
+ src/conf.c
)
IF (WAYLAND_SUPPORT)
ADD_DEFINITIONS("-DHAVE_WAYLAND")
- SET(BUILD_SOURCE
+ SET(BUILD_SOURCE
${BUILD_SOURCE}
src/xmonitor_wayland.c
src/buffer_handler_wayland.c
@@ -140,7 +141,7 @@ IF (LIVEBOX)
IF (X11_SUPPORT)
ADD_DEFINITIONS("-DHAVE_X11")
- SET(BUILD_SOURCE
+ SET(BUILD_SOURCE
${BUILD_SOURCE}
src/xmonitor.c
src/buffer_handler.c
@@ -151,7 +152,7 @@ ENDIF (LIVEBOX)
IF (WAYLAND_SUPPORT)
ADD_DEFINITIONS("-DHAVE_WAYLAND")
- SET(BUILD_SOURCE
+ SET(BUILD_SOURCE
${BUILD_SOURCE}
src/util_wayland.c
)
@@ -159,7 +160,7 @@ ENDIF (WAYLAND_SUPPORT)
IF (X11_SUPPORT)
ADD_DEFINITIONS("-DHAVE_X11")
- SET(BUILD_SOURCE
+ SET(BUILD_SOURCE
${BUILD_SOURCE}
src/util_x11.c
)
@@ -176,32 +177,48 @@ ADD_DEFINITIONS(${pkg_livebox_LDFLAGS})
ADD_EXECUTABLE(${PROJECT_NAME} ${BUILD_SOURCE})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} ${pkg_extra_LDFLAGS} ${pkg_livebox_LDFLAGS} "-ldl -lrt")
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} ${pkg_extra_LDFLAGS} ${pkg_livebox_LDFLAGS} "-ldl -lrt -pie")
IF (LIVEBOX)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/abi.ini DESTINATION /usr/share/data-provider-master PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PRODUCT}.conf.ini DESTINATION /usr/share/data-provider-master RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PRODUCT}.resolution.ini DESTINATION /usr/share/data-provider-master RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/abi.ini DESTINATION /usr/share/data-provider-master PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PRODUCT}.conf.ini DESTINATION /usr/share/data-provider-master 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/data-provider-master RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.320x480.conf.ini DESTINATION /usr/share/data-provider-master/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/data-provider-master/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/data-provider-master/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/data-provider-master/480x800 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.360x480.conf.ini DESTINATION /usr/share/data-provider-master/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/data-provider-master/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/data-provider-master/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/data-provider-master/360x360 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/data-provider-master/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/data-provider-master/720x1280 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/data-provider-master/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/data-provider-master/320x320 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PRODUCT}.conf.ini DESTINATION /usr/share/data-provider-master 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/data-provider-master 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}")
-IF (MOBILE)
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.rule DESTINATION /opt/etc/smack/accesses.d)
-ELSE (MOBILE)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-ENDIF (MOBILE)
# INCLUDE FOR BUILD & INSTALL .PO FILES
ADD_SUBDIRECTORY(res)
ADD_SUBDIRECTORY(data)
IF (LIVEBOX)
-ADD_SUBDIRECTORY(pkgmgr_livebox)
+ADD_SUBDIRECTORY(pkgmgr_dynamicbox)
+ENDIF (LIVEBOX)
IF (X11_SUPPORT)
IF ("${ENGINEER_BINARY}" STREQUAL "true")
ADD_SUBDIRECTORY(util_liveinfo)
ENDIF ("${ENGINEER_BINARY}" STREQUAL "true")
ENDIF (X11_SUPPORT)
-ENDIF (LIVEBOX)
# End of a file
diff --git a/data-provider-master.desktop b/data-provider-master.desktop
deleted file mode 100644
index 77d74ae..0000000
--- a/data-provider-master.desktop
+++ /dev/null
@@ -1,9 +0,0 @@
-Name=Live Data Provider - Master
-Type=Application
-Exec=/usr/bin/data-provider-master
-Icon=data-provider-master.png
-NoDisplay=True
-Network=True
-Comment=Homescreen-Live Box content data provider (master)
-X-TIZEN-TaskManage=False
-X-TIZEN-Multiple=False
diff --git a/data-provider-master.rule b/data-provider-master.rule
deleted file mode 100644
index c8dc2de..0000000
--- a/data-provider-master.rule
+++ /dev/null
@@ -1,5 +0,0 @@
-data-provider-master notification::db rw
-data-provider-master ail::db rw
-data-provider-master svi-data x
-data-provider-master data-provider-master::db rw
-data-provider-master system::vconf_system rwxat
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index af462e3..56d64c4 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -1,7 +1,4 @@
-#INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/data-provider-master DESTINATION /etc/rc.d/init.d/ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-IF (MOBILE)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/mobile.data-provider-master.service DESTINATION /usr/lib/systemd/user/ RENAME data-provider-master.service PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-ELSE (MOBILE)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/data-provider-master.service DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/dump_livebox.sh DESTINATION /opt/etc/dump.d/module.d/ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
-ENDIF (MOBILE)
+IF (LIVEBOX)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/dump_dynamicbox.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)
diff --git a/data/data-provider-master.service b/data/data-provider-master.service
index e359660..4994f4e 100644
--- a/data/data-provider-master.service
+++ b/data/data-provider-master.service
@@ -16,20 +16,12 @@
[Unit]
Description=Data Provider daemon
-DefaultDependencies=no
-After=check-mount.service
+After=xorg.target
[Service]
-Environment=MULTISENSE_SND_PLAYER=tizen_snd_player
-Environment=ELM_MODULES=ctxpopup_copypasteUI>entry/api:datetime_input_popup>datetime/api:object_dump>win/api:access_output_tts>access/api
-Environment=EINA_LOG_LEVEL=1
-Environment=ECORE_INPUT_TIMEOUT_FIX=0
-Environment=EINA_LOG_LEVELS=ecore_x:4,evas_main:1
Environment=BUFMGR_LOCK_TYPE="once"
Environment=BUFMGR_MAP_CACHE="true"
-Environment=ELM_PROFILE=mobile
-EnvironmentFile=-/run/tizen-mobile-env
-Type=simple
+Type=notify
ExecStart=/usr/bin/data-provider-master
RestartSec=1
Restart=always
diff --git a/data/abi.ini b/data/device/abi.ini
index ad8eec3..a587be5 100644
--- a/data/abi.ini
+++ b/data/device/abi.ini
@@ -12,6 +12,3 @@ package=gi2qxenosh.osp-appwidget-service
[app]
package=/APPID/
-
-[dali]
-package=provider.multi-livebox
diff --git a/data/wayland.mobile.conf.ini b/data/device/wayland.mobile.conf.ini
index c9b95c7..468b696 100644
--- a/data/wayland.mobile.conf.ini
+++ b/data/device/wayland.mobile.conf.ini
@@ -16,7 +16,7 @@ slave_relaunch_count=3
max_log_line=1000
max_log_file=3
sqilte_flush_max=1048576
-#db_path=/opt/dbspace/.livebox.db
+#db_path=/opt/dbspace/.dynamicbox.db
#share_path=/opt/usr/share/live_magazine/
log_path=/tmp/.dbox.service
#always_path=/opt/usr/share/live_magazine/always
@@ -31,7 +31,8 @@ overwrite_content=false
com_core_thread=true
use_xmonitor=false
#input=/dev/input/event2
-pd_request_timeout=5.0
+gbar_request_timeout=5.0
premultiplied=1
#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-#services=[livebox],[shortcut],[notification],[utility],[badge],[file]
+#services=[dynamicbox],[shortcut],[notification],[utility],[badge],[file]
+#auto_align=true
diff --git a/data/wayland.mobile.resolution.ini b/data/device/wayland.mobile.resolution.ini
index e2b5a17..e2b5a17 100644
--- a/data/wayland.mobile.resolution.ini
+++ b/data/device/wayland.mobile.resolution.ini
diff --git a/data/wayland.wearable.conf.ini b/data/device/wayland.wearable.conf.ini
index 2866b74..034a081 100644
--- a/data/wayland.wearable.conf.ini
+++ b/data/device/wayland.wearable.conf.ini
@@ -16,7 +16,7 @@ slave_relaunch_count=3
max_log_line=1000
max_log_file=3
sqilte_flush_max=1048576
-#db_path=/opt/dbspace/.livebox.db
+#db_path=/opt/dbspace/.dynamicbox.db
#share_path=/opt/usr/share/live_magazine/
log_path=/tmp/.dbox.service
#always_path=/opt/usr/share/live_magazine/always
@@ -31,7 +31,8 @@ overwrite_content=false
com_core_thread=true
use_xmonitor=false
#input=/dev/input/event2
-pd_request_timeout=5.0
+gbar_request_timeout=5.0
premultiplied=0
#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-services=[livebox],[shortcut],[badge]
+services=[dynamicbox],[shortcut],[badge]
+#auto_align=true
diff --git a/data/wayland.wearable.resolution.ini b/data/device/wayland.wearable.resolution.ini
index b9e7561..b9e7561 100644
--- a/data/wayland.wearable.resolution.ini
+++ b/data/device/wayland.wearable.resolution.ini
diff --git a/data/device/x11.mobile.320x480.conf.ini b/data/device/x11.mobile.320x480.conf.ini
new file mode 100644
index 0000000..4811331
--- /dev/null
+++ b/data/device/x11.mobile.320x480.conf.ini
@@ -0,0 +1,38 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[notification],[utility],[badge],[file]
+#auto_align=true
diff --git a/data/device/x11.mobile.320x480.resolution.ini b/data/device/x11.mobile.320x480.resolution.ini
new file mode 100644
index 0000000..c848adf
--- /dev/null
+++ b/data/device/x11.mobile.320x480.resolution.ini
@@ -0,0 +1,14 @@
+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
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/device/x11.mobile.360x360.conf.ini
diff --git a/data/device/x11.mobile.360x360.resolution.ini b/data/device/x11.mobile.360x360.resolution.ini
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/device/x11.mobile.360x360.resolution.ini
diff --git a/data/device/x11.mobile.360x480.conf.ini b/data/device/x11.mobile.360x480.conf.ini
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/device/x11.mobile.360x480.conf.ini
diff --git a/data/device/x11.mobile.360x480.resolution.ini b/data/device/x11.mobile.360x480.resolution.ini
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/device/x11.mobile.360x480.resolution.ini
diff --git a/data/device/x11.mobile.480x800.conf.ini b/data/device/x11.mobile.480x800.conf.ini
new file mode 100644
index 0000000..0519334
--- /dev/null
+++ b/data/device/x11.mobile.480x800.conf.ini
@@ -0,0 +1,45 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[notification],[utility],[badge],[file]
+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
new file mode 100644
index 0000000..63ad36e
--- /dev/null
+++ b/data/device/x11.mobile.480x800.resolution.ini
@@ -0,0 +1,14 @@
+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/x11.mobile.conf.ini b/data/device/x11.mobile.conf.ini
new file mode 100644
index 0000000..174ff1a
--- /dev/null
+++ b/data/device/x11.mobile.conf.ini
@@ -0,0 +1,40 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[notification],[utility],[badge],[file]
+#auto_align=true
+#use_event_time=true
+event_filter=0.5
diff --git a/data/x11.mobile.resolution.ini b/data/device/x11.mobile.resolution.ini
index e2b5a17..e2b5a17 100644
--- a/data/x11.mobile.resolution.ini
+++ b/data/device/x11.mobile.resolution.ini
diff --git a/data/x11.wearable.conf.ini b/data/device/x11.wearable.360x360.conf.ini
index 260dadb..0e5aff4 100644
--- a/data/x11.wearable.conf.ini
+++ b/data/device/x11.wearable.360x360.conf.ini
@@ -1,5 +1,5 @@
-base_width=320
-base_height=320
+base_width=360
+base_height=360
minimum_period=1.0
#script=edje
#default_abi=c
@@ -7,7 +7,7 @@ minimum_period=1.0
default_period=-1.0
default_packet_time=0.0001
#default_content=default
-minimum_space=104857600
+minimum_space=1048576
#replace_tag=/APPID/
slave_ttl=0.0
slave_activate_time=30.0
@@ -30,8 +30,10 @@ debug_mode=false
overwrite_content=false
com_core_thread=true
use_xmonitor=false
-#input=/dev/input/event2
+input=/dev/input/event0
pd_request_timeout=5.0
premultiplied=0
#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
services=[livebox],[shortcut],[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
new file mode 100644
index 0000000..b54c8a9
--- /dev/null
+++ b/data/device/x11.wearable.360x360.resolution.ini
@@ -0,0 +1,14 @@
+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
new file mode 100644
index 0000000..f540ec3
--- /dev/null
+++ b/data/device/x11.wearable.360x480.conf.ini
@@ -0,0 +1,38 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[badge]
+check_lcd=false
diff --git a/data/device/x11.wearable.360x480.resolution.ini b/data/device/x11.wearable.360x480.resolution.ini
new file mode 100644
index 0000000..fea1ffa
--- /dev/null
+++ b/data/device/x11.wearable.360x480.resolution.ini
@@ -0,0 +1,14 @@
+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
new file mode 100644
index 0000000..6119d57
--- /dev/null
+++ b/data/device/x11.wearable.conf.ini
@@ -0,0 +1,40 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[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
new file mode 100644
index 0000000..5b6923e
--- /dev/null
+++ b/data/device/x11.wearable.resolution.ini
@@ -0,0 +1,14 @@
+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_dynamicbox.sh b/data/dump_dynamicbox.sh
new file mode 100644
index 0000000..1791a31
--- /dev/null
+++ b/data/dump_dynamicbox.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+DBOX_DEBUG=$1/dynamicbox
+mkdir -p ${DBOX_DEBUG}
+/bin/cp -r /opt/usr/share/live_magazine ${DBOX_DEBUG}
+/bin/cp -r /tmp/.dbox.service ${DBOX_DEBUG}/log
+/bin/cp -r /opt/dbspace/.dynamicbox.db ${DBOX_DEBUG}
+ls -la /tmp/ | /bin/grep srw > ${DBOX_DEBUG}/log/tmp.hidden_files
diff --git a/data/dump_livebox.sh b/data/dump_livebox.sh
deleted file mode 100644
index 2fb6c32..0000000
--- a/data/dump_livebox.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-LIVEBOX_DEBUG=$1/livebox
-mkdir -p ${LIVEBOX_DEBUG}
-/bin/cp -r /opt/usr/share/live_magazine ${LIVEBOX_DEBUG}
-/bin/cp -r /tmp/.dbox.service ${LIVEBOX_DEBUG}/log
-ls -la /tmp/ | /bin/grep srw > ${LIVEBOX_DEBUG}/log/tmp.hidden_files
diff --git a/data/emulator/abi.ini b/data/emulator/abi.ini
new file mode 100644
index 0000000..a587be5
--- /dev/null
+++ b/data/emulator/abi.ini
@@ -0,0 +1,14 @@
+[c]
+package=org.tizen.data-provider-slave
+
+[cpp]
+package=org.tizen.data-provider-slave
+
+[html]
+package=dbox.web-provider
+
+[osp]
+package=gi2qxenosh.osp-appwidget-service
+
+[app]
+package=/APPID/
diff --git a/data/emulator/wayland.mobile.conf.ini b/data/emulator/wayland.mobile.conf.ini
new file mode 100644
index 0000000..f58503f
--- /dev/null
+++ b/data/emulator/wayland.mobile.conf.ini
@@ -0,0 +1,38 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[notification],[utility],[badge],[file]
+#auto_align=true
diff --git a/data/emulator/wayland.mobile.resolution.ini b/data/emulator/wayland.mobile.resolution.ini
new file mode 100644
index 0000000..e2b5a17
--- /dev/null
+++ b/data/emulator/wayland.mobile.resolution.ini
@@ -0,0 +1,13 @@
+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.conf.ini b/data/emulator/wayland.wearable.conf.ini
new file mode 100644
index 0000000..a57f6ba
--- /dev/null
+++ b/data/emulator/wayland.wearable.conf.ini
@@ -0,0 +1,38 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[badge]
+#auto_align=true
diff --git a/data/x11.wearable.resolution.ini b/data/emulator/wayland.wearable.resolution.ini
index b9e7561..b9e7561 100644
--- a/data/x11.wearable.resolution.ini
+++ b/data/emulator/wayland.wearable.resolution.ini
diff --git a/data/emulator/x11.mobile.320x480.conf.ini b/data/emulator/x11.mobile.320x480.conf.ini
new file mode 100644
index 0000000..74a4407
--- /dev/null
+++ b/data/emulator/x11.mobile.320x480.conf.ini
@@ -0,0 +1,38 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[notification],[utility],[badge],[file]
+#auto_align=true
diff --git a/data/emulator/x11.mobile.320x480.resolution.ini b/data/emulator/x11.mobile.320x480.resolution.ini
new file mode 100644
index 0000000..c848adf
--- /dev/null
+++ b/data/emulator/x11.mobile.320x480.resolution.ini
@@ -0,0 +1,14 @@
+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
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/emulator/x11.mobile.360x360.conf.ini
diff --git a/data/emulator/x11.mobile.360x360.resolution.ini b/data/emulator/x11.mobile.360x360.resolution.ini
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/emulator/x11.mobile.360x360.resolution.ini
diff --git a/data/emulator/x11.mobile.360x480.conf.ini b/data/emulator/x11.mobile.360x480.conf.ini
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/emulator/x11.mobile.360x480.conf.ini
diff --git a/data/emulator/x11.mobile.360x480.resolution.ini b/data/emulator/x11.mobile.360x480.resolution.ini
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/data/emulator/x11.mobile.360x480.resolution.ini
diff --git a/data/emulator/x11.mobile.480x800.conf.ini b/data/emulator/x11.mobile.480x800.conf.ini
new file mode 100644
index 0000000..3b54d0a
--- /dev/null
+++ b/data/emulator/x11.mobile.480x800.conf.ini
@@ -0,0 +1,45 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[notification],[utility],[badge],[file]
+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
new file mode 100644
index 0000000..63ad36e
--- /dev/null
+++ b/data/emulator/x11.mobile.480x800.resolution.ini
@@ -0,0 +1,14 @@
+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/x11.mobile.conf.ini b/data/emulator/x11.mobile.conf.ini
new file mode 100644
index 0000000..f177788
--- /dev/null
+++ b/data/emulator/x11.mobile.conf.ini
@@ -0,0 +1,40 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[notification],[utility],[badge],[file]
+#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
new file mode 100644
index 0000000..e2b5a17
--- /dev/null
+++ b/data/emulator/x11.mobile.resolution.ini
@@ -0,0 +1,13 @@
+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/x11.mobile.conf.ini b/data/emulator/x11.wearable.360x360.conf.ini
index d0bdfb5..8f07e8a 100644
--- a/data/x11.mobile.conf.ini
+++ b/data/emulator/x11.wearable.360x360.conf.ini
@@ -1,5 +1,5 @@
-base_width=720
-base_height=1280
+base_width=360
+base_height=360
minimum_period=1.0
#script=edje
#default_abi=c
@@ -7,9 +7,9 @@ minimum_period=1.0
default_period=-1.0
default_packet_time=0.0001
#default_content=default
-minimum_space=104857600
+minimum_space=1048576
#replace_tag=/APPID/
-slave_ttl=30.0
+slave_ttl=0.0
slave_activate_time=30.0
slave_relaunch_time=3.0
slave_relaunch_count=3
@@ -30,8 +30,10 @@ debug_mode=false
overwrite_content=false
com_core_thread=true
use_xmonitor=false
-#input=/dev/input/event2
+input=/dev/input/event2
pd_request_timeout=5.0
premultiplied=0
#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M
-#services=[livebox],[shortcut],[notification],[utility],[badge],[file]
+services=[livebox],[shortcut],[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
new file mode 100644
index 0000000..b54c8a9
--- /dev/null
+++ b/data/emulator/x11.wearable.360x360.resolution.ini
@@ -0,0 +1,14 @@
+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
new file mode 100644
index 0000000..9fdd7f6
--- /dev/null
+++ b/data/emulator/x11.wearable.360x480.conf.ini
@@ -0,0 +1,38 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[shortcut],[badge]
+check_lcd=false
diff --git a/data/emulator/x11.wearable.360x480.resolution.ini b/data/emulator/x11.wearable.360x480.resolution.ini
new file mode 100644
index 0000000..fea1ffa
--- /dev/null
+++ b/data/emulator/x11.wearable.360x480.resolution.ini
@@ -0,0 +1,14 @@
+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
new file mode 100644
index 0000000..f28220a
--- /dev/null
+++ b/data/emulator/x11.wearable.conf.ini
@@ -0,0 +1,40 @@
+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=/opt/dbspace/.dynamicbox.db
+#share_path=/opt/usr/share/live_magazine/
+log_path=/tmp/.dbox.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=[dynamicbox],[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
new file mode 100644
index 0000000..5b6923e
--- /dev/null
+++ b/data/emulator/x11.wearable.resolution.ini
@@ -0,0 +1,14 @@
+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/mobile.data-provider-master.service b/data/mobile.data-provider-master.service
deleted file mode 100644
index ee61361..0000000
--- a/data/mobile.data-provider-master.service
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright 2012 Samsung Electronics Co., Ltd
-#
-# Licensed under the Flora License, Version 1.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.tizenopensource.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.
-#
-
-[Unit]
-Description=Data Provider daemon
-After=xorg.target
-
-[Service]
-Type=notify
-Environment=BUFMGR_LOCK_TYPE="once"
-Environment=BUFMGR_MAP_CACHE="true"
-ExecStart=/usr/bin/data-provider-master
-RestartSec=1
-
-[Install]
-WantedBy=tizen-middleware.target
diff --git a/include/buffer_handler.h b/include/buffer_handler.h
index e3aa982..ff5cf1d 100644
--- a/include/buffer_handler.h
+++ b/include/buffer_handler.h
@@ -18,12 +18,7 @@ struct buffer_info;
struct inst_info;
struct buffer;
-enum buffer_type { /*!< Must have to be sync with libprovider, liblivebox-viewer, liblivebox-edje */
- BUFFER_TYPE_FILE,
- BUFFER_TYPE_SHM,
- BUFFER_TYPE_PIXMAP,
- BUFFER_TYPE_ERROR
-};
+#include <dynamicbox_buffer.h>
/*!
* \brief
@@ -33,7 +28,7 @@ enum buffer_type { /*!< Must have to be sync with libprovider, liblivebox-viewer
* \param[in] pixel_size
* \return buffer_info
*/
-extern struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buffer_type type, int w, int h, int pixel_size);
+extern struct buffer_info *buffer_handler_create(struct inst_info *inst, enum dynamicbox_fb_type type, int w, int h, int pixel_size);
/*!
* \brief
@@ -90,9 +85,9 @@ extern const char *buffer_handler_id(const struct buffer_info *info);
/*!
* \param[in] info
- * \return buffer_type
+ * \return dynamicbox_fb_type
*/
-extern enum buffer_type buffer_handler_type(const struct buffer_info *info);
+extern enum dynamicbox_fb_type buffer_handler_type(const struct buffer_info *info);
/*!
* \brief This API is not supported for Pixmap.
@@ -140,6 +135,27 @@ 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);
@@ -228,14 +244,14 @@ extern struct inst_info *buffer_handler_instance(struct buffer_info *info);
* \remarks
* \param[in] type
* \param[in] resource
- * \return struct buffer *
+ * \return dynamicbox_fb_t
* \retval NULL
* \retval address
* \pre
* \post
* \sa
*/
-extern struct buffer *buffer_handler_raw_open(enum buffer_type type, void *resource);
+extern dynamicbox_fb_t buffer_handler_raw_open(enum dynamicbox_fb_type type, void *resource);
/*!
* \brief
@@ -248,7 +264,7 @@ extern struct buffer *buffer_handler_raw_open(enum buffer_type type, void *resou
* \post
* \sa
*/
-extern int buffer_handler_raw_close(struct buffer *buffer);
+extern int buffer_handler_raw_close(dynamicbox_fb_t buffer);
/*!
* \brief
@@ -261,7 +277,7 @@ extern int buffer_handler_raw_close(struct buffer *buffer);
* \post
* \sa
*/
-extern void *buffer_handler_raw_data(struct buffer *buffer);
+extern void *buffer_handler_raw_data(dynamicbox_fb_t buffer);
/*!
* \brief
@@ -274,7 +290,7 @@ extern void *buffer_handler_raw_data(struct buffer *buffer);
* \post
* \sa
*/
-extern int buffer_handler_raw_size(struct buffer *buffer);
+extern int buffer_handler_raw_size(dynamicbox_fb_t buffer);
/*!
* \brief
diff --git a/include/client_life.h b/include/client_life.h
index fa88612..b844659 100644
--- a/include/client_life.h
+++ b/include/client_life.h
@@ -31,7 +31,7 @@ struct packet;
* \note
* Create & Destroy
*/
-extern struct client_node *client_create(pid_t pid, int handle);
+extern struct client_node *client_create(pid_t pid, int handle, const char *direct_addr);
#define client_destroy(client) client_unref(client)
/*!
@@ -102,4 +102,6 @@ extern int client_browse_list(const char *cluster, const char *category, int (*c
extern int client_nr_of_subscriber(const char *cluster, const char *category);
extern int client_broadcast(struct inst_info *inst, struct packet *packet);
+
+extern const char *client_direct_addr(const struct client_node *client);
/* End of a file */
diff --git a/include/conf.h b/include/conf.h
index aab11d1..a4d0603 100644
--- a/include/conf.h
+++ b/include/conf.h
@@ -15,173 +15,14 @@
*/
struct conf {
- int width;
- int height;
-
- int base_width;
- int base_height;
- double minimum_period;
-
- struct {
- char *script;
- char *abi;
- char *pd_group;
- double period;
- int pixels;
- } default_conf;
-
- struct {
- char *name;
- char *secured;
- char *abi;
- } launch_key;
-
- double default_packet_time;
-
- char *empty_content;
- char *empty_title;
-
- char *default_content;
- char *default_title;
-
- unsigned long minimum_space;
-
- char *replace_tag;
-
- double slave_ttl;
- double slave_activate_time;
- double slave_relaunch_time;
- int slave_relaunch_count;
-
- int max_log_line;
- int max_log_file;
-
- unsigned long sqlite_flush_max;
-
- struct {
- char *conf;
- char *image;
- char *script;
- char *root;
- char *script_port;
- char *slave_log;
- char *reader;
- char *always;
- char *db;
- char *input;
- } path;
-
- int max_size_type;
-
- int slave_max_load;
-
- double ping_time;
-
- char *vconf_sys_cluster;
- int max_pended_ctx_events;
-
- int use_sw_backend;
- char *provider_method;
int debug_mode;
- int overwrite_content;
- int com_core_thread;
- int use_xmonitor;
- int premultiplied;
-
- double scale_width_factor;
- double scale_height_factor;
-
- double pd_request_timeout;
-
- char *emergency_disk;
- char *services;
+ int slave_max_load;
};
extern struct conf g_conf;
-extern int conf_loader(void);
-extern void conf_update_size(void);
-extern void conf_reset(void);
-extern void conf_init(void);
-
-#define BASE_W g_conf.base_width
-#define BASE_H g_conf.base_height
-
-#define CR 13
-#define LF 10
-
-#define EMERGENCY_DISK g_conf.emergency_disk
-#define SCALE_WIDTH_FACTOR g_conf.scale_width_factor
-#define SCALE_HEIGHT_FACTOR g_conf.scale_height_factor
-
-#define USE_SW_BACKEND g_conf.use_sw_backend
-#define PROVIDER_METHOD g_conf.provider_method
-#define DEBUG_MODE g_conf.debug_mode
-#define OVERWRITE_CONTENT g_conf.overwrite_content
-#define COM_CORE_THREAD g_conf.com_core_thread
-
-#define MINIMUM_PERIOD g_conf.minimum_period
-
-#define DEFAULT_SCRIPT g_conf.default_conf.script
-#define DEFAULT_ABI g_conf.default_conf.abi
-#define DEFAULT_GROUP g_conf.default_conf.pd_group
-#define DEFAULT_PERIOD g_conf.default_conf.period
-#define DEFAULT_PIXELS g_conf.default_conf.pixels
-#define PRIORITY_NO_CHANGE -1.0f
-
-#define BUNDLE_SLAVE_NAME g_conf.launch_key.name
-#define BUNDLE_SLAVE_SECURED g_conf.launch_key.secured
-#define BUNDLE_SLAVE_ABI g_conf.launch_key.abi
-#define PACKET_TIME g_conf.default_packet_time
-#define CONTENT_NO_CHANGE g_conf.empty_content
-#define TITLE_NO_CHANGE g_conf.empty_title
-#define DEFAULT_TITLE g_conf.default_title
-#define DEFAULT_CONTENT g_conf.default_content
-#define MINIMUM_SPACE g_conf.minimum_space
-
-#define IMAGE_PATH g_conf.path.image
-#define SCRIPT_PATH g_conf.path.script
-#define SCRIPT_PORT_PATH g_conf.path.script_port
-#define CONF_PATH g_conf.path.conf
-#define ROOT_PATH g_conf.path.root
-#define SLAVE_LOG_PATH g_conf.path.slave_log
-#define READER_PATH g_conf.path.reader
-#define ALWAYS_PATH g_conf.path.always
-#define INPUT_PATH g_conf.path.input
-
-#define REPLACE_TAG_APPID g_conf.replace_tag
-#define SLAVE_TTL g_conf.slave_ttl
-#define SLAVE_ACTIVATE_TIME g_conf.slave_activate_time
-#define SLAVE_RELAUNCH_TIME g_conf.slave_relaunch_time
-#define SLAVE_RELAUNCH_COUNT g_conf.slave_relaunch_count
-
-#define MAX_LOG_LINE g_conf.max_log_line
-#define MAX_LOG_FILE g_conf.max_log_file
-
-#define SQLITE_FLUSH_MAX g_conf.sqlite_flush_max
-#define DBFILE g_conf.path.db
-
-#define PD_REQUEST_TIMEOUT g_conf.pd_request_timeout
-
-#define SLAVE_MAX_LOAD g_conf.slave_max_load
-#define DEFAULT_PING_TIME g_conf.ping_time
-#define PREMULTIPLIED_COLOR g_conf.premultiplied
-#define SERVICES g_conf.services
-
-#define SERVICE_LIVEBOX "[livebox]"
-#define SERVICE_NOTIFICATION "[notification]"
-#define SERVICE_BADGE "[badge]"
-#define SERVICE_SHORTCUT "[shortcut]"
-#define SERVICE_UTILITY "[utility]"
-#define SERVICE_FILE "[file]"
-
-#define PAUSED_FILE "/tmp/.live.paused"
-
-#define MAX_ABI 256
-#define MAX_PKGNAME 512
-#define DELAY_TIME 0.0000001f
-#define DEFAULT_CLUSTER "user,created"
-#define MINIMUM_REACTIVATION_TIME 10
+#define DELAY_TIME 0.0000001f
+#define HAPI __attribute__((visibility("hidden")))
#if !defined(VCONFKEY_MASTER_STARTED)
#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started"
@@ -191,11 +32,7 @@ extern void conf_init(void);
#define VCONFKEY_MASTER_RESTART_COUNT "memory/private/data-provider-master/restart_count"
#endif
-#define USE_XMONITOR g_conf.use_xmonitor
-
-#define HAPI __attribute__((visibility("hidden")))
-/*!
- * EAPI is defined from eina.h
- */
+#define CR 13
+#define LF 10
/* End of a file */
diff --git a/include/debug.h b/include/debug.h
index cc4911f..ac1a079 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -67,4 +67,6 @@ extern FILE *__file_log_fp;
#define PERF_MARK(tag)
#endif
+#define HAPI __attribute__((visibility("hidden")))
+
/* End of a file */
diff --git a/include/event.h b/include/event.h
index 800b071..81ce421 100644
--- a/include/event.h
+++ b/include/event.h
@@ -15,39 +15,50 @@
*/
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 */
-#if defined(_USE_ECORE_TIME_GET)
- double tv;
-#else
- struct timeval tv;
-#endif
+ 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;
};
enum event_state {
- EVENT_STATE_DEACTIVATED,
- EVENT_STATE_ACTIVATE,
- EVENT_STATE_ACTIVATED,
- EVENT_STATE_DEACTIVATE,
- EVENT_STATE_ERROR
+ 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 x, int y, int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data);
extern int event_deactivate(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);
/* End of a file */
diff --git a/include/group.h b/include/group.h
index 04dfddd..8cda595 100644
--- a/include/group.h
+++ b/include/group.h
@@ -36,8 +36,8 @@ 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_livebox(const char *group, const char *pkgname);
-extern int group_del_livebox(const char *pkgname);
+extern int group_add_dynamicbox(const char *group, const char *pkgname);
+extern int group_del_dynamicbox(const char *pkgname);
extern int group_init(void);
extern int group_fini(void);
diff --git a/include/instance.h b/include/instance.h
index a61c32c..781b7a8 100644
--- a/include/instance.h
+++ b/include/instance.h
@@ -26,7 +26,7 @@
* 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 livebox packages.)
+ * prepared via configuration file of each dynamicbox packages.)
* We defined this as "REQUEST_TO_ACTIVATE" state.
*
* After the slave create a new instance, it will sends back
@@ -37,21 +37,21 @@
* 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 livebox)
+ * In this case, the master has to find the fault module(crashed dynamicbox)
* and prevent it from loading at the slave.
- * And it will send requests for re-creating all other normal liveboxes.
+ * And it will send requests for re-creating all other normal dynamicboxes.
* 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 liveboxes.
+ * instances of requested dynamicboxes.
*
* 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 liveboxes.
- * They just want to know about fault liveboxes to display deactivated
+ * Because the clients don't want to know the re-created dynamicboxes.
+ * They just want to know about fault dynamicboxes to display deactivated
* message.
*
* Sometimes the master can send requests to the slave to unload instances.
@@ -80,7 +80,7 @@
* 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 livebox, it could be destroyed itself.
+ * In case of system created dynamicbox, 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.
*
@@ -94,16 +94,6 @@ enum instance_event {
INSTNACE_EVENT_UNKNOWN
};
-enum instance_destroy_type {
- INSTANCE_DESTROY_DEFAULT = 0x00,
- INSTANCE_DESTROY_UPGRADE = 0x01,
- INSTANCE_DESTROY_UNINSTALL = 0x02,
- INSTANCE_DESTROY_TERMINATE = 0x03,
- INSTANCE_DESTROY_FAULT = 0x04,
- INSTANCE_DESTROY_TEMPORARY = 0x05,
- INSTANCE_DESTROY_UNKNOWN = 0x06
-};
-
enum instance_state {
INST_INIT = 0x0, /*!< Only keeps in the master */
@@ -119,17 +109,17 @@ enum instance_state {
INST_REQUEST_TO_DESTROY /*!< Sent a request to a slave, when the master receives deleted event, the master will delete this */
};
-enum livebox_visible_state { /*!< Must be sync'd with livebox-viewer */
- LB_SHOW = 0x00, /*!< Livebox is showed. Default state */
- LB_HIDE = 0x01, /*!< Livebox is hide, with no update event, but keep update timer */
+enum dynamicbox_visible_state { /*!< Must be sync'd with dynamicbox-viewer */
+ DBOX_SHOW = 0x00, /*!< Dynamicbox is showed. Default state */
+ DBOX_HIDE = 0x01, /*!< Dynamicbox is hide, with no update event, but keep update timer */
- LB_HIDE_WITH_PAUSE = 0x02, /*!< Livebix is hide, it needs to be paused (with freezed update timer) */
+ DBOX_HIDE_WITH_PAUSE = 0x02, /*!< Dynamicbox is hide, it needs to be paused (with freezed update timer) */
- LB_VISIBLE_ERROR = 0xFFFFFFFF /* To enlarge the size of this enumeration type */
+ DBOX_VISIBLE_ERROR = 0xFFFFFFFF /* To enlarge the size of this enumeration type */
};
-#define IS_PD 1
-#define IS_LB 0
+#define IS_GBAR 1
+#define IS_DBOX 0
struct inst_info;
struct pkg_info;
@@ -137,8 +127,8 @@ 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, enum instance_destroy_type type);
-extern int instance_reload(struct inst_info *inst, enum instance_destroy_type type);
+extern int instance_destroy(struct inst_info *inst, dynamicbox_destroy_type_e type);
+extern int instance_reload(struct inst_info *inst, dynamicbox_destroy_type_e type);
extern struct inst_info * instance_ref(struct inst_info *inst);
extern struct inst_info * instance_unref(struct inst_info *inst);
@@ -152,9 +142,9 @@ 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_lb_info(struct inst_info *inst, double priority, const char *content, const char *title);
-extern void instance_set_lb_size(struct inst_info *inst, int w, int h);
-extern void instance_set_pd_size(struct inst_info *inst, int w, int h);
+extern void instance_set_dbox_info(struct inst_info *inst, double priority, const char *content, const char *title);
+extern void instance_set_dbox_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);
@@ -165,8 +155,8 @@ extern int instance_clicked(struct inst_info *inst, const char *event, double ti
extern int instance_text_signal_emit(struct inst_info *inst, const char *emission, const char *source, double sx, double sy, double ex, double ey);
extern int instance_signal_emit(struct inst_info *inst, const char *emission, 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 livebox_visible_state state);
-extern enum livebox_visible_state instance_visible_state(struct inst_info *inst);
+extern int instance_set_visible_state(struct inst_info *inst, enum dynamicbox_visible_state state);
+extern enum dynamicbox_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);
@@ -176,10 +166,12 @@ extern int instance_active_update(struct inst_info *inst);
*/
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_lb_script(const struct inst_info *inst);
-extern struct script_info * const instance_pd_script(const struct inst_info *inst);
-extern struct buffer_info * const instance_pd_buffer(const struct inst_info *inst);
-extern struct buffer_info * const instance_lb_buffer(const struct inst_info *inst);
+extern struct script_info * const instance_dbox_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_dbox_buffer(const struct inst_info *inst);
+extern struct buffer_info * const instance_dbox_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);
@@ -190,10 +182,10 @@ 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_lb_width(const struct inst_info *inst);
-extern const int const instance_lb_height(const struct inst_info *inst);
-extern const int const instance_pd_width(const struct inst_info *inst);
-extern const int const instance_pd_height(const struct inst_info *inst);
+extern const int const instance_dbox_width(const struct inst_info *inst);
+extern const int const instance_dbox_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);
/*!
@@ -202,43 +194,53 @@ extern const enum instance_state const instance_state(const struct inst_info *in
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_lb_buffer(struct inst_info *inst, int pixels);
-extern int instance_create_pd_buffer(struct inst_info *inst, int pixels);
+extern int instance_create_dbox_buffer(struct inst_info *inst, int pixels);
+extern int instance_create_dbox_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_pd_pos(struct inst_info *inst, double x, double y);
-extern void instance_slave_get_pd_pos(struct inst_info *inst, double *x, double *y);
+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_pd(struct inst_info *inst, struct client_node *client);
-extern int instance_slave_close_pd(struct inst_info *inst, struct client_node *client, int reason);
+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_lb_update_begin(struct inst_info *inst, double priority, const char *content, const char *title);
-extern int instance_lb_update_end(struct inst_info *inst);
+extern int instance_dbox_update_begin(struct inst_info *inst, double priority, const char *content, const char *title);
+extern int instance_dbox_update_end(struct inst_info *inst);
-extern int instance_pd_update_begin(struct inst_info *inst);
-extern int instance_pd_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_pd_updated(const char *pkgname, const char *id, const char *descfile);
-extern void instance_lb_updated_by_instance(struct inst_info *inst, const char *safe_file);
-extern void instance_pd_updated_by_instance(struct inst_info *inst, const char *descfile);
+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_dbox_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 LB_STATUS_ERROR_FAULT (slave is faulted)
- * even though the PD is not created, this will forcely send the PD_DESTROYED event to the client.
+ * if the status is DBOX_STATUS_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_pd_destroyed(struct inst_info *inst, int status);
-extern int instance_client_pd_created(struct inst_info *inst, int status);
+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_dbox_extra_buffer_created(struct inst_info *inst, int idx);
+extern int instance_client_dbox_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_pd_owner(struct inst_info *inst);
+extern struct client_node *instance_gbar_owner(struct inst_info *inst);
/*!
* Multiple viewer
@@ -253,6 +255,7 @@ 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);
/*!
*/
diff --git a/include/io.h b/include/io.h
index c3d83b4..5647d52 100644
--- a/include/io.h
+++ b/include/io.h
@@ -17,9 +17,9 @@
extern int io_init(void);
extern int io_fini(void);
extern int io_load_package_db(struct pkg_info *info);
-extern char *io_livebox_pkgname(const char *pkgname);
-extern int io_update_livebox_package(const char *pkgname, int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data);
-extern int io_crawling_liveboxes(int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data);
+extern char *io_dynamicbox_pkgname(const char *pkgname);
+extern int io_update_dynamicbox_package(const char *pkgname, int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data);
+extern int io_crawling_dynamicboxes(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
index a46b9f5..3046725 100644
--- a/include/lite-errno.h
+++ b/include/lite-errno.h
@@ -14,47 +14,48 @@
* limitations under the License.
*/
-#ifndef __LIVEBOX_ERRNO_H
-#define __LIVEBOX_ERRNO_H
+#ifndef __DYNAMICBOX_ERRNO_H
+#define __DYNAMICBOX_ERRNO_H
#ifdef __cplusplus
extern "C" {
#endif
-/*!
- * \addtogroup CAPI_LIVEBOX_SERVICE_MODULE
- * \{
+/**
+ * @addtogroup CAPI_DYNAMICBOX_SERVICE_MODULE
+ * @{
*/
-/*!
- * \brief
- * Definitions for the result status of livebox operation.
+/**
+ * @brief
+ * Definitions for the result status of dynamicbox operation.
*/
-enum livebox_status {
- LB_STATUS_SUCCESS = 0x00000000, /*!< Operation is successfully completed */
- LB_STATUS_ERROR = 0x80000000, /*!< This will be OR'd with other specific error value */
- LB_STATUS_ERROR_INVALID = LB_STATUS_ERROR | 0x0001, /*!< Invalid request */
- LB_STATUS_ERROR_FAULT = LB_STATUS_ERROR | 0x0002, /*!< Fault - Unable to recover from the error */
- LB_STATUS_ERROR_MEMORY = LB_STATUS_ERROR | 0x0004, /*!< Memory is not enough to do this operation */
- LB_STATUS_ERROR_EXIST = LB_STATUS_ERROR | 0x0008, /*!< Already exists */
- LB_STATUS_ERROR_BUSY = LB_STATUS_ERROR | 0x0010, /*!< Busy so the operation is not started(accepted), try again */
- LB_STATUS_ERROR_PERMISSION = LB_STATUS_ERROR | 0x0020, /*!< Permission error */
- LB_STATUS_ERROR_ALREADY = LB_STATUS_ERROR | 0x0040, /*!< Operation is already started */
- LB_STATUS_ERROR_CANCEL = LB_STATUS_ERROR | 0x0080, /*!< Operation is canceled */
- LB_STATUS_ERROR_IO = LB_STATUS_ERROR | 0x0100, /*!< I/O Error */
- LB_STATUS_ERROR_NOT_EXIST = LB_STATUS_ERROR | 0x0200, /*!< Not exists */
- LB_STATUS_ERROR_TIMEOUT = LB_STATUS_ERROR | 0x0400, /*!< Timeout */
- LB_STATUS_ERROR_NOT_IMPLEMENTED = LB_STATUS_ERROR | 0x0800, /*!< Operation is not implemented */
- LB_STATUS_ERROR_NO_SPACE = LB_STATUS_ERROR | 0x1000, /*!< No space to operate */
- LB_STATUS_ERROR_DISABLED = LB_STATUS_ERROR | 0x2000 /*!< Disabled */
+enum dynamicbox_status {
+ DBOX_STATUS_ERROR_NONE = 0x00000000, /**< Operation is successfully completed */
+ DBOX_STATUS_ERROR = 0x80000000, /**< This will be OR'd with other specific error value */
+ DBOX_STATUS_ERROR_INVALID_PARAMETER = DBOX_STATUS_ERROR | 0x0001, /**< Invalid request */
+ DBOX_STATUS_ERROR_FAULT = DBOX_STATUS_ERROR | 0x0002, /**< Fault - Unable to recover from the error */
+ DBOX_STATUS_ERROR_OUT_OF_MEMORY = DBOX_STATUS_ERROR | 0x0004, /**< Memory is not enough to do this operation */
+ DBOX_STATUS_ERROR_EXIST = DBOX_STATUS_ERROR | 0x0008, /**< Already exists */
+ DBOX_STATUS_ERROR_BUSY = DBOX_STATUS_ERROR | 0x0010, /**< Busy so the operation is not started(accepted), try again */
+ DBOX_STATUS_ERROR_PERMISSION_DENIED = DBOX_STATUS_ERROR | 0x0020, /**< Permission error */
+ DBOX_STATUS_ERROR_ALREADY = DBOX_STATUS_ERROR | 0x0040, /**< Operation is already started */
+ DBOX_STATUS_ERROR_CANCEL = DBOX_STATUS_ERROR | 0x0080, /**< Operation is canceled */
+ DBOX_STATUS_ERROR_IO_ERROR = DBOX_STATUS_ERROR | 0x0100, /**< I/O Error */
+ DBOX_STATUS_ERROR_NOT_EXIST = DBOX_STATUS_ERROR | 0x0200, /**< Not exists */
+ DBOX_STATUS_ERROR_TIMEOUT = DBOX_STATUS_ERROR | 0x0400, /**< Timeout */
+ DBOX_STATUS_ERROR_NOT_IMPLEMENTED = DBOX_STATUS_ERROR | 0x0800, /**< Operation is not implemented */
+ DBOX_STATUS_ERROR_NO_SPACE = DBOX_STATUS_ERROR | 0x1000, /**< No space to operate */
+ DBOX_STATUS_ERROR_DISABLED = DBOX_STATUS_ERROR | 0x2000 /**< Disabled */
};
+
/*!
* \brief Check whether given code value indicates error or not.
* \param[in] s
* \return 1 or 0
*/
-#define LB_STATUS_IS_ERROR(s) (!!((s) & LB_STATUS_ERROR))
+#define DBOX_STATUS_IS_ERROR(s) (!!((s) & DBOX_STATUS_ERROR))
/*!
* \}
diff --git a/include/package.h b/include/package.h
index dd5d3f6..4107702 100644
--- a/include/package.h
+++ b/include/package.h
@@ -14,21 +14,6 @@
* limitations under the License.
*/
-enum lb_type {
- LB_TYPE_NONE = 0x0,
- LB_TYPE_SCRIPT,
- LB_TYPE_FILE,
- LB_TYPE_TEXT,
- LB_TYPE_BUFFER
-};
-
-enum pd_type {
- PD_TYPE_NONE = 0x0,
- PD_TYPE_SCRIPT,
- PD_TYPE_TEXT,
- PD_TYPE_BUFFER
-};
-
enum alter_type {
ALTER_CREATE,
ALTER_DESTROY
@@ -45,8 +30,8 @@ struct slave_node;
*/
extern struct pkg_info *package_create(const char *pkgid, const char *lbid);
extern int package_destroy(struct pkg_info *info);
-extern char *package_lb_pkgname(const char *pkgname);
-extern int package_is_lb_pkgname(const char *pkgname);
+extern char *package_dbox_pkgname(const char *pkgname);
+extern int package_is_dbox_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);
@@ -66,15 +51,15 @@ 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_lb_path(const struct pkg_info *info);
-extern const char * const package_lb_group(const struct pkg_info *info);
-extern const char * const package_pd_path(const struct pkg_info *info);
-extern const char * const package_pd_group(const struct pkg_info *info);
+extern const char * const package_dbox_path(const struct pkg_info *info);
+extern const char * const package_dbox_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_pd_width(const struct pkg_info *info);
-extern const int const package_pd_height(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 int package_network(struct pkg_info *info);
@@ -84,22 +69,26 @@ 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_lb_type(struct pkg_info *info, enum lb_type type);
-extern void package_set_pd_type(struct pkg_info *info, enum pd_type type);
-extern int package_set_lb_group(struct pkg_info *info, const char *group);
-extern int package_set_lb_path(struct pkg_info *info, const char *path);
-extern int package_set_pd_group(struct pkg_info *info, const char *group);
-extern int package_set_pd_path(struct pkg_info *info, const char *path);
+extern void package_set_dbox_type(struct pkg_info *info, enum dynamicbox_dbox_type type);
+extern void package_set_gbar_type(struct pkg_info *info, enum dynamicbox_gbar_type type);
+extern int package_set_dbox_group(struct pkg_info *info, const char *group);
+extern int package_set_dbox_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_pd_height(struct pkg_info *info, int height);
-extern void package_set_pd_width(struct pkg_info *info, int width);
+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 const char *package_hw_acceleration(struct pkg_info *info);
+extern int package_set_hw_acceleration(struct pkg_info *info, const char *hw_acceleration);
/*!
* \brief
@@ -109,8 +98,8 @@ 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 pd_type const package_pd_type(const struct pkg_info *info);
-extern const enum lb_type const package_lb_type(const struct pkg_info *info);
+extern const enum dynamicbox_gbar_type const package_gbar_type(const struct pkg_info *info);
+extern const enum dynamicbox_dbox_type const package_dbox_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);
diff --git a/include/parser.h b/include/parser.h
index 16e297a..71349e5 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -23,22 +23,22 @@ 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_pdsize(struct parser *handle, unsigned int *width, unsigned int *height);
+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_lb_path(struct parser *handle);
-extern const char *parser_lb_group(struct parser *handle);
-extern const char *parser_pd_path(struct parser *handle);
-extern const char *parser_pd_group(struct parser *handle);
+extern const char *parser_dbox_path(struct parser *handle);
+extern const char *parser_dbox_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_pd(struct parser *handle);
-extern int parser_text_lb(struct parser *handle);
-extern int parser_buffer_lb(struct parser *handle);
-extern int parser_buffer_pd(struct parser *handle);
+extern int parser_text_gbar(struct parser *handle);
+extern int parser_text_dbox(struct parser *handle);
+extern int parser_buffer_dbox(struct parser *handle);
+extern int parser_buffer_gbar(struct parser *handle);
extern const char *parser_script(struct parser *handle);
diff --git a/include/setting.h b/include/setting.h
index 6d0700f..d2138a5 100644
--- a/include/setting.h
+++ b/include/setting.h
@@ -18,4 +18,14 @@ 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/slave_life.h b/include/slave_life.h
index 7f477f3..07e8130 100644
--- a/include/slave_life.h
+++ b/include/slave_life.h
@@ -23,7 +23,8 @@ struct slave_node;
enum slave_event {
SLAVE_EVENT_ACTIVATE,
SLAVE_EVENT_DEACTIVATE, /* deactivate callback, can return REACTIVATE, DEFAULT */
- SLAVE_EVENT_DELETE,
+ 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,
@@ -95,7 +96,7 @@ extern const int const slave_refcnt(struct slave_node *slave);
* \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);
+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
@@ -113,12 +114,6 @@ extern void slave_destroy(struct slave_node *slave);
extern int slave_activate(struct slave_node *slave);
/*!
- * \brief After this function call, the slave object can be deleted
- * \param[in] slave
- */
-extern struct slave_node *slave_deactivate(struct slave_node *slave, int direct) __attribute__((warn_unused_result));
-
-/*!
* To check the slave's activation state
*/
extern const int const slave_is_activated(struct slave_node *slave);
@@ -169,7 +164,7 @@ extern int slave_set_pid(struct slave_node *slave, pid_t pid);
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 *abi, int secured, int network);
+extern struct slave_node *slave_find_available(const char *slave_pkgname, const char *abi, int secured, int network, const char *hw_acceleration);
extern double const slave_ttl(const struct slave_node *slave);
@@ -212,4 +207,9 @@ 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);
+
/* End of a file */
diff --git a/include/util.h b/include/util.h
index 4f32a76..56348f1 100644
--- a/include/util.h
+++ b/include/util.h
@@ -17,7 +17,6 @@
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_validate_livebox_package(const char *pkgname);
extern int util_unlink(const char *filename);
extern int util_unlink_files(const char *folder);
extern char *util_slavename(void);
diff --git a/packaging/data-provider-master.manifest b/packaging/data-provider-master.manifest
index 5efa5e7..3c5ea52 100644
--- a/packaging/data-provider-master.manifest
+++ b/packaging/data-provider-master.manifest
@@ -15,6 +15,9 @@
<label name="data-provider-master::notification" />
<label name="data-provider-master::notification.client" />
<label name="data-provider-master::utility" />
+ <label name="data-provider-master::client" />
+ <label name="data-provider-master::provider" />
+ <label name="data-provider-master::bin" />
</provide>
<request>
<smack request="sys-assert::core" type="rwxat" />
@@ -34,19 +37,33 @@
<assign>
<!-- Executable file -->
- <filesystem path="/usr/bin/data-provider-master" label="data-provider-master" exec_label="data-provider-master" />
- <filesystem path="/opt/usr/devel/usr/bin/liveinfo" label="data-provider-master" exec_label="data-provider-master" />
+ <filesystem path="/usr/bin/data-provider-master" label="data-provider-master::bin" exec_label="data-provider-master::bin" />
+ <filesystem path="/opt/usr/devel/usr/bin/liveinfo" label="data-provider-master::bin" exec_label="data-provider-master::bin" />
<filesystem path="/opt/usr/devel/usr/bin" label="_" />
<!-- Configuration data -->
<filesystem path="/usr/share/data-provider-master" label="data-provider-master::data" />
<filesystem path="/usr/share/data-provider-master/abi.ini" label="data-provider-master::data" />
- <!-- livebox-service is able to access the resolution.ini file -->
+ <!-- dynamicbox_service is able to access the resolution.ini file -->
<filesystem path="/usr/share/data-provider-master/resolution.ini" label="_" />
+ <filesystem path="/usr/share/data-provider-master/320x480/resolution.ini" label="_" />
+ <filesystem path="/usr/share/data-provider-master/800x480/resolution.ini" label="_" />
+ <filesystem path="/usr/share/data-provider-master/360x480/resolution.ini" label="_" />
+ <filesystem path="/usr/share/data-provider-master/720x1280/resolution.ini" label="_" />
+ <filesystem path="/usr/share/data-provider-master/320x320/resolution.ini" label="_" />
+ <filesystem path="/usr/share/data-provider-master/360x360/resolution.ini" label="_" />
+ <filesystem path="/usr/share/data-provider-master/480x800/resolution.ini" label="_" />
<!-- Slave provider and the master provider are able to access the conf.ini file -->
<filesystem path="/usr/share/data-provider-master/conf.ini" label="data-provider-master::data" />
+ <filesystem path="/usr/share/data-provider-master/320x480/conf.ini" label="data-provider-master::data" />
+ <filesystem path="/usr/share/data-provider-master/800x480/conf.ini" label="data-provider-master::data" />
+ <filesystem path="/usr/share/data-provider-master/360x480/conf.ini" label="data-provider-master::data" />
+ <filesystem path="/usr/share/data-provider-master/720x1280/conf.ini" label="data-provider-master::data" />
+ <filesystem path="/usr/share/data-provider-master/320x320/conf.ini" label="data-provider-master::data" />
+ <filesystem path="/usr/share/data-provider-master/360x360/conf.ini" label="data-provider-master::data" />
+ <filesystem path="/usr/share/data-provider-master/480x800/conf.ini" label="data-provider-master::data" />
<!-- Shared data folder -->
<filesystem path="/opt/usr/share/live_magazine" label="data-provider-master::share" type="transmutable" />
@@ -55,16 +72,16 @@
<filesystem path="/opt/usr/share/live_magazine/always" label="data-provider-master::share" type="transmutable" />
<!-- Database -->
- <filesystem path="/opt/dbspace/.livebox.db" label="data-provider-master::db" />
- <filesystem path="/opt/dbspace/.livebox.db-journal" label="data-provider-master::db" />
+ <filesystem path="/opt/dbspace/.dynamicbox.db" label="data-provider-master::db" />
+ <filesystem path="/opt/dbspace/.dynamicbox.db-journal" label="data-provider-master::db" />
<filesystem path="/usr/lib/systemd/system/data-provider-master.service" label="_" />
<filesystem path="/usr/lib/systemd/system/multi-user.target.wants/data-provider-master.service" label="_" />
<!-- Package manager plugin -->
- <filesystem path="/usr/etc/package-manager/parserlib/liblivebox.so" label="_" />
+ <filesystem path="/usr/etc/package-manager/parserlib/libdynamicbox.so" label="_" />
<!-- Logdump script -->
- <filesystem path="/opt/etc/dump.d/module.d/dump_livebox.sh" label="_" exec_label="_" />
+ <filesystem path="/opt/etc/dump.d/module.d/dump_dynamicbox.sh" label="_" exec_label="_" />
</assign>
</manifest>
diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec
index ad79dc6..bbf9b71 100755
--- a/packaging/data-provider-master.spec
+++ b/packaging/data-provider-master.spec
@@ -1,15 +1,14 @@
%bcond_with wayland
Name: data-provider-master
-Summary: Master service provider for liveboxes
-Version: 0.43.2
+Summary: Master service provider for dynamicboxes
+Version: 1.0.0
Release: 1
-Group: HomeTF/Livebox
+Group: HomeTF/DynamicBox
License: Flora
Source0: %{name}-%{version}.tar.gz
Source1001: %{name}.manifest
BuildRequires: cmake, gettext-tools, smack, coreutils
-BuildRequires: pkgconfig(ail)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(vconf)
@@ -39,11 +38,8 @@ BuildRequires: pkgconfig(eina)
BuildRequires: pkgconfig(com-core)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(pkgmgr)
-
-%if "%{sec_product_feature_livebox}" != "0"
-BuildRequires: pkgconfig(livebox-service)
-%endif
-
+BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(dynamicbox_service)
BuildRequires: pkgconfig(notification)
BuildRequires: pkgconfig(notification-service)
BuildRequires: pkgconfig(badge)
@@ -51,12 +47,13 @@ BuildRequires: pkgconfig(badge-service)
BuildRequires: pkgconfig(shortcut)
BuildRequires: pkgconfig(security-server)
BuildRequires: pkgconfig(libsystemd-daemon)
+BuildRequires: model-build-features
Requires(post): sys-assert
Requires(post): dbus
%description
-Manage the 2nd stage livebox service provider and communicate with the viewer application.
-Keep trace on the life-cycle of the livebox and status of the service providers, viewer applications.
+Manage the 2nd stage dynamicbox service provider and communicate with the viewer application.
+Keep trace on the life-cycle of the dynamicbox and status of the service providers, viewer applications.
%prep
%setup -q
@@ -97,13 +94,16 @@ export MOBILE=On
export WEARABLE=Off
%endif
-%if "%{sec_product_feature_livebox}" == "0"
-export LIVEBOX=Off
-%else
+export LIVEBOX_SHM="${LIVEBOX_SHM}.480x800"
export LIVEBOX=On
+
+%ifarch %ix86
+export TARGET=emulator
+%else
+export TARGET=device
%endif
-%cmake . -DPRODUCT=${LIVEBOX_SHM} -DENGINEER_BINARY=${ENGINEER} -DWAYLAND_SUPPORT=${WAYLAND_SUPPORT} -DX11_SUPPORT=${X11_SUPPORT} -DMOBILE=${MOBILE} -DWEARABLE=${WEARABLE} -DLIVEBOX=${LIVEBOX}
+%cmake . -DPRODUCT=${LIVEBOX_SHM} -DENGINEER_BINARY=${ENGINEER} -DWAYLAND_SUPPORT=${WAYLAND_SUPPORT} -DX11_SUPPORT=${X11_SUPPORT} -DMOBILE=${MOBILE} -DWEARABLE=${WEARABLE} -DLIVEBOX=${LIVEBOX} -DTARGET=${TARGET}
CFLAGS="${CFLAGS} -Wall -Winline -Werror" LDFLAGS="${LDFLAGS}" make %{?jobs:-j%jobs}
@@ -111,40 +111,30 @@ CFLAGS="${CFLAGS} -Wall -Winline -Werror" LDFLAGS="${LDFLAGS}" make %{?jobs:-j%j
rm -rf %{buildroot}
%make_install
mkdir -p %{buildroot}/%{_datarootdir}/license
-%if "%{_repository}" == "wearable"
mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
ln -sf ../data-provider-master.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/data-provider-master.service
-%else
-mkdir -p %{buildroot}/%{_libdir}/systemd/user/tizen-middleware.target.wants
-ln -sf %{_libdir}/systemd/user/data-provider-master.service %{buildroot}/%{_libdir}/systemd/user/tizen-middleware.target.wants/data-provider-master.service
-%endif
-
-%if "%{sec_product_feature_livebox}" == "0"
-# Nothing provides
-%else
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/devel/usr/bin
mkdir -p %{buildroot}/opt/dbspace
-touch %{buildroot}/opt/dbspace/.livebox.db
-touch %{buildroot}/opt/dbspace/.livebox.db-journal
-if [ ! -s %{buildroot}/opt/dbspace/.livebox.db ]; then
-echo "LiveBox DB file is not exists, initiate it"
-sqlite3 %{buildroot}/opt/dbspace/.livebox.db <<EOF
+touch %{buildroot}/opt/dbspace/.dynamicbox.db
+touch %{buildroot}/opt/dbspace/.dynamicbox.db-journal
+if [ ! -s %{buildroot}/opt/dbspace/.dynamicbox.db ]; then
+echo "DynamicBox DB file is not exists, initiate it"
+sqlite3 %{buildroot}/opt/dbspace/.dynamicbox.db <<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, pd_size TEXT, content TEXT, nodisplay INTEGER, setup TEXT, 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, pd_type INTEGER, pd_src TEXT, pd_group TEXT, libexec TEXT, timeout INTEGER, period TEXT, script TEXT, pinup INTEGER, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
+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 '', FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE);
EOF
fi
-%endif
%pre
# Executing the stop script for stopping the service of installed provider (old version)
@@ -153,9 +143,6 @@ if [ -x %{_sysconfdir}/rc.d/init.d/data-provider-master ]; then
fi
%post
-%if "%{sec_product_feature_livebox}" == "0"
-#Nothing provides
-%else
chown 5000:5000 /opt/usr/share/live_magazine
chmod 750 /opt/usr/share/live_magazine
chown 5000:5000 /opt/usr/share/live_magazine/log
@@ -164,11 +151,10 @@ chown 5000:5000 /opt/usr/share/live_magazine/reader
chmod 750 /opt/usr/share/live_magazine/reader
chown 5000:5000 /opt/usr/share/live_magazine/always
chmod 750 /opt/usr/share/live_magazine/always
-chown 0:5000 /opt/dbspace/.livebox.db
-chmod 640 /opt/dbspace/.livebox.db
-chown 0:5000 /opt/dbspace/.livebox.db-journal
-chmod 640 /opt/dbspace/.livebox.db-journal
-%endif
+chown 0:5000 /opt/dbspace/.dynamicbox.db
+chmod 640 /opt/dbspace/.dynamicbox.db
+chown 0:5000 /opt/dbspace/.dynamicbox.db-journal
+chmod 640 /opt/dbspace/.dynamicbox.db-journal
vconftool set -t bool "memory/data-provider-master/started" 0 -i -u 5000 -f -s system::vconf_system
vconftool set -t int "memory/private/data-provider-master/restart_count" 0 -i -u 5000 -f -s data-provider-master
vconftool set -t string "db/data-provider-master/serveraddr" "/opt/usr/share/live_magazine/.client.socket" -i -u 5000 -f -s system::vconf_system
@@ -179,27 +165,17 @@ echo "%{_sysconfdir}/init.d/data-provider-master start"
%manifest %{name}.manifest
%defattr(-,root,root,-)
%{_bindir}/data-provider-master
-%if "%{_repository}" == "wearable"
%{_libdir}/systemd/system/multi-user.target.wants/data-provider-master.service
%{_libdir}/systemd/system/data-provider-master.service
-/opt/etc/dump.d/module.d/dump_livebox.sh
-%else
-%{_libdir}/systemd/user/data-provider-master.service
-%{_libdir}/systemd/user/tizen-middleware.target.wants/data-provider-master.service
-/opt/etc/smack/accesses.d
-%endif
%{_datarootdir}/license/*
-%if "%{sec_product_feature_livebox}" == "0"
-# Nothing provides
-%else
%if 0%{?tizen_build_binary_release_type_eng}
/opt/usr/devel/usr/bin/*
%endif
%{_prefix}/etc/package-manager/parserlib/*
%{_datarootdir}/data-provider-master/*
+/opt/etc/dump.d/module.d/dump_dynamicbox.sh
/opt/usr/share/live_magazine/*
-/opt/dbspace/.livebox.db
-/opt/dbspace/.livebox.db-journal
-%endif
+/opt/dbspace/.dynamicbox.db
+/opt/dbspace/.dynamicbox.db-journal
# End of a file
diff --git a/pkgmgr_livebox/CMakeLists.txt b/pkgmgr_dynamicbox/CMakeLists.txt
index c20b5c1..06ad219 100644
--- a/pkgmgr_livebox/CMakeLists.txt
+++ b/pkgmgr_dynamicbox/CMakeLists.txt
@@ -1,6 +1,6 @@
-PROJECT(livebox C)
+PROJECT(dynamicbox C)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/pkgmgr_livebox/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/pkgmgr_dynamicbox/include)
INCLUDE(FindPkgConfig)
pkg_check_modules(bin_pkgs REQUIRED
@@ -8,7 +8,7 @@ pkg_check_modules(bin_pkgs REQUIRED
sqlite3
libxml-2.0
db-util
- livebox-service
+ dynamicbox_service
)
FOREACH(flag ${bin_pkgs_CFLAGS})
diff --git a/pkgmgr_livebox/livebox.xml b/pkgmgr_dynamicbox/dynamicbox.xml
index e14cdea..b7f36cb 100644
--- a/pkgmgr_livebox/livebox.xml
+++ b/pkgmgr_dynamicbox/dynamicbox.xml
@@ -1,40 +1,43 @@
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.nicesj" version="1.0" install-location="auto">
-<livebox appid="org.tizen.nicesj.livebox" primary="true" secured="false" network="false" abi="c" timeout="20" period="10.0" libexec="/usr/apps/org.tizen.myapp/libexec/liblive-org.tizen.nicesj.so" pinup="false" script="edje" nodisplay="false">
- <label>My livebox</label>
+<dynamicbox appid="org.tizen.nicesj.dynamicbox" primary="true" secured="false" network="false" abi="c" timeout="20" period="10.0" libexec="/usr/apps/org.tizen.myapp/libexec/liblive-org.tizen.nicesj.so" pinup="false" script="edje" nodisplay="false">
+ <label>My Dynamic Box</label>
<icon>/usr/share/icons/small/org.tizen.live-nicesj.png</icon>
<label xml:lang="en_US">Sample</label>
<label xml:lang="ko_KR">Hangul</label>
- <content>Content information</content>
+ <content>Content information</content> <!-- This string will be passed to the dynamicbox_create -->
+ <category name="http://tizen.org/dynamicbox/default"></category> <!-- Used for categorizing a package -->
- <launch>org.tizen.nicesj</launch>
+ <launch>org.tizen.nicesj</launch> <!-- Launch this app from homescreen directly -->
- <setup>org.tizen.nicesj</setup>
+ <setup>org.tizen.nicesj</setup> <!-- If the box needs to be setting up before adding it to the homscreen, this app will be launched -->
- <box type="image" mouse_event="false">
- <size touch_effect="true" preview="ABSPATH">1x1</size>
- <size touch_effect="true" preview="ABSPATH">2x1</size>
- <size touch_effect="true" need_frame="true">2x2</size>
+ <box type="image" mouse_event="false" count="0">
+ <!-- 1x1 should be exists, mandatory size -->
+ <size touch_effect="true" preview="ABSPATH" mouse_event="false">1x1</size>
+
+ <size touch_effect="true" preview="ABSPATH" mouse_event="false">2x1</size>
+ <size touch_effect="true" need_frame="true" mouse_event="false">2x2</size>
<size>4x1</size>
<size need_frame="true">4x2</size>
- <size touch_effect="false" need_frame="true">4x3</size>
- <size touch_effect="false">4x4</size>
+ <size touch_effect="false" need_frame="true" mouse_event="false">4x3</size>
+ <size touch_effect="false" mouse_event="false">4x4</size>
- <!-- Easy home -->
+ <!-- Only for the Easy home -->
<size>21x21</size>
<size preview="ABSPATH">23x21</size>
<size>23x23</size>
- <!-- Only supported for special livebox - inhouse / commercialization target only -->
+ <!-- Only supported for special Dynamic Box - inhouse / commercialization target only -->
<size>0x0</size>
<script src="/opt/usr/apps/org.tizen.myapp/res/script/my.edj" group="my_group" />
</box>
- <pd type="script">
+ <glancebar type="script">
<size>720x100</size>
<script src="/opt/usr/apps/org.tizen.myapp/res/script/mypd.edj" group="group_string" />
- </pd>
+ </glancebar>
<group>
<cluster name="cluster1">
@@ -74,5 +77,5 @@
MUSIC_PLAYED_FREQUENTLY(DATA_PROVIDER, TIME_SPAN, RESULT_SIZE)
-->
</group>
-</livebox>
+</dynamicbox>
</manifest>
diff --git a/pkgmgr_dynamicbox/dynamicbox.xsd b/pkgmgr_dynamicbox/dynamicbox.xsd
new file mode 100644
index 0000000..cc58e22
--- /dev/null
+++ b/pkgmgr_dynamicbox/dynamicbox.xsd
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tizen.org/ns/packages" xmlns:packages="http://tizen.org/ns/packages">
+
+ <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
+
+ <xs:element name="dynamicbox">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="label">
+ <xs:complexType mixed="true">
+ <xs:attribute ref="xml:lang"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="icon">
+ <xs:complexType mixed="true">
+ <xs:attribute ref="xml:lang"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="content"/>
+ <xs:element name="launch"/>
+ <xs:element name="setup"/>
+ <xs:element name="category">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:choice maxOccurs="unbounded">
+ <xs:any minOccurs="0" processContents="lax"/>
+ </xs:choice>
+ </xs:sequence>
+ <xs:anyAttribute processContents="lax"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element nmae="glancebar">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:choice maxOccurs="unbounded" minOccurs="0">
+ <xs:element name="size"/>
+ <xs:element name="script">
+ <xs:complexType>
+ <xs:attribute name="src" type="xs:string"/>
+ <xs:attribute name="group" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:choice>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="box">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:choice maxOccurs="unbounded" minOccurs="0">
+ <xs:element name="size">
+ <xs:complexType>
+ <xs:attribute name="touch_effect" type="xs:boolean"/>
+ <xs:attribute name="mouse_event" type="xs:boolean"/>
+ <xs:attribute name="need_frame" type="xs:boolean"/>
+ <xs:attribute name="preview" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="script">
+ <xs:complexType>
+ <xs:attribute name="src" type="xs:string"/>
+ <xs:attribute name="group" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute name="type" type="xs:string"/>
+ <xs:attribute name="mouse_event" type="xs:boolean"/>
+ <xs:attribute name="count" type="xs:decimal"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="appid" use="required" type="xs:string"/>
+ <xs:attribute name="primary" use="required" type="xs:boolean"/>
+ <xs:attribute name="secured" type="xs:boolean"/>
+ <xs:attribute name="network" use="required" type="xs:boolean"/>
+ <xs:attribute name="abi" type="xs:string"/>
+ <xs:attribute name="timeout" use="required" type="xs:string"/>
+ <xs:attribute name="period" use="required" type="xs:string"/>
+ <xs:attribute name="libexec" type="xs:string"/>
+ <xs:attribute name="pinup" type="xs:string"/>
+ <xs:attribute name="script" type="xs:string"/>
+ <xs:attribute name="nodisplay" type="xs:boolean"/>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
diff --git a/pkgmgr_livebox/include/dlist.h b/pkgmgr_dynamicbox/include/dlist.h
index cd1a421..cd1a421 100644
--- a/pkgmgr_livebox/include/dlist.h
+++ b/pkgmgr_dynamicbox/include/dlist.h
diff --git a/pkgmgr_livebox/src/dlist.c b/pkgmgr_dynamicbox/src/dlist.c
index 3ae571b..3ae571b 100644
--- a/pkgmgr_livebox/src/dlist.c
+++ b/pkgmgr_dynamicbox/src/dlist.c
diff --git a/pkgmgr_dynamicbox/src/service_register.c b/pkgmgr_dynamicbox/src/service_register.c
new file mode 100644
index 0000000..e38795f
--- /dev/null
+++ b/pkgmgr_dynamicbox/src/service_register.c
@@ -0,0 +1,3308 @@
+/*
+ * 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 <sys/stat.h>
+#include <unistd.h>
+#include <libgen.h>
+#include <string.h>
+
+#include <sqlite3.h>
+#include <db-util.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <dlog.h>
+
+#include <dynamicbox_service.h>
+
+#include "dlist.h"
+
+#if !defined(FLOG)
+#define DbgPrint(format, arg...) SECURE_LOGD("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
+#define ErrPrint(format, arg...) SECURE_LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
+#define ErrPrintWithConsole(format, arg...) do { fprintf(stderr, "[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); SECURE_LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); } while (0)
+#endif
+
+#define CUR_VER 5
+#define DEFAULT_CATEGORY "http://tizen.org/category/default"
+
+/*!
+ * \note
+ * DB Table schema
+ *
+ * version
+ * +---------+
+ * | version |
+ * +---------+
+ * | - |
+ * +---------+
+ * CREATE TABLE version ( version INTEGER )
+ *
+ *
+ * pkgmap
+ * +-------+-------+-------+-------+-------------------+
+ * | appid | pkgid | uiapp | prime | categ(from ver 2) |
+ * +-------+-------+-------+-------+-------------------+
+ * | - | - | - | - | - |
+ * +-------+-------+-------+-------+-------------------+
+ * CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER, category TEXT )
+ *
+ *
+ * provider
+ * +-------+---------+-----+---------+----------+---------+-----------+---------+--------+----------+---------+---------+--------+--------+-------+-----------------------+
+ * | pkgid | network | abi | secured | box_type | box_src | box_group | gbar_type | gbar_src | gbar_group | libexec | timeout | period | script | pinup | count(from ver 4) | direct_input | hw_acceleration |
+ * +-------+---------+-----+---------+----------+---------+-----------+---------+--------+----------+---------+---------+--------+--------+-------+-----------------------+-------|---------------|
+ * | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
+ * +-------+---------+-----+---------+----------+---------+-----------+---------+--------+----------+---------+---------+--------+--------+-------+-----------------------+-------|---------------|
+ * 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 TEXT, 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 'none', FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid))
+ *
+ * = box_type = { text | buffer | script | image }
+ * = gbar_type = { text | buffer | script }
+ * = network = { 1 | 0 }
+ * = secured = { 1 | 0 }
+ *
+ *
+ * client
+ * +-------+------+---------+-------------+-----------+---------+-----------+-------+
+ * | pkgid | Icon | Name | auto_launch | gbar_size | content | nodisplay | setup |
+ * +-------+------+---------+-------------+-----------+---------+-----------+-------+
+ * | - | - | - | - | - | - | - | - |
+ * +-------+------+---------+-------------+-----------+---------+-----------+-------+
+ * 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) )
+ *
+ * = auto_launch = UI-APPID
+ * = gbar_size = WIDTHxHEIGHT
+ *
+ *
+ * i18n
+ * +-------+------+------+------+
+ * | fk | lang | name | icon |
+ * +-------+------+------+------+
+ * | pkgid | - | - | - |
+ * +-------+------+------+------+
+ * CREATE TABLE i18n ( pkgid TEXT NOT NULL, lang TEXT COLLATE NOCASE, name TEXT, icon TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
+ *
+ *
+ * box_size
+ * +-------+-----------+---------+--------------+------------+-------------------------+
+ * | pkgid | size_type | preview | touch_effect | need_frame | mouse_event(from ver 3) |
+ * +-------+-----------+---------+--------------+------------+-------------------------+
+ * | - | - | - | - | - | - |
+ * +-------+-----------+---------+--------------+------------+-------------------------+
+ * CREATE TABLE box_size ( pkgid TEXT NOT NULL, size_type INTEGER, preview TEXT, INTEGER, touch_effect INTEGER, need_frame INTEGER, mouse_event INTEGER, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
+ *
+ * = box_size_list = { WIDTHxHEIGHT; WIDTHxHEIGHT; ... }
+ *
+ * groupinfo
+ * +----+---------+----------+-------+
+ * | id | cluster | category | pkgid |
+ * +----+---------+----------+-------+
+ * | - | - | - | - |
+ * +----+---------+----------+-------|
+ * CREATE TABLE groupinfo ( id INTEGER PRIMARY KEY AUTOINCREMENT, cluster TEXT NOT NULL, category TEXT NOT NULL, appid TEXT NOT NULL, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ))
+ *
+ * groupmap
+ * +-------+----+----------+-----------+
+ * | pkgid | id | ctx_item | option_id |
+ * +-------+----+----------+-----------+
+ * 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) )
+ *
+ *
+ * option
+ * +-------+-----------+-----+-------+
+ * | pkgid | option_id | key | value |
+ * +-------+-----------+-----+-------+
+ * 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) )
+ */
+
+#if !defined(LIBXML_TREE_ENABLED)
+ #error "LIBXML is not supporting the tree"
+#endif
+
+#if defined(LOG_TAG)
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "PKGMGR_DYNAMICBOX"
+
+ int errno;
+
+ struct i18n {
+ xmlChar *lang;
+ xmlChar *name;
+ xmlChar *icon;
+ };
+
+struct dynamicbox {
+ xmlChar *pkgid;
+ int secured;
+ int network;
+ xmlChar *auto_launch;
+ xmlChar *abi;
+ xmlChar *name; /* Default name */
+ xmlChar *icon; /* Default icon */
+ xmlChar *libexec; /* Path of the SO file */
+ xmlChar *timeout; /* INTEGER, timeout */
+ xmlChar *period; /* DOUBLE, update period */
+ xmlChar *script; /* Script engine */
+ xmlChar *content; /* Content information */
+ xmlChar *setup;
+ xmlChar *uiapp; /* UI App Id */
+ xmlChar *category; /* Category of this box */
+
+ int pinup; /* Is this support the pinup feature? */
+ int primary; /* Is this primary dynamicbox? */
+ int nodisplay;
+ int count; /* Max count of instances */
+ int direct_input; /* Use the input node to get the event directly */
+
+ int default_mouse_event; /* Mouse event processing option for dynamicbox */
+ int default_touch_effect;
+ int default_need_frame;
+
+ enum dynamicbox_dbox_type dbox_type;
+ xmlChar *dbox_src;
+ xmlChar *dbox_group;
+ int size_list; /* 1x1, 2x1, 2x2, 4x1, 4x2, 4x3, 4x4 */
+
+ xmlChar *preview[DBOX_NR_OF_SIZE_LIST];
+ int touch_effect[DBOX_NR_OF_SIZE_LIST]; /* Touch effect of a dynamicbox */
+ int need_frame[DBOX_NR_OF_SIZE_LIST]; /* Box needs frame which should be cared by viewer */
+ int mouse_event[DBOX_NR_OF_SIZE_LIST];
+
+ enum dynamicbox_gbar_type gbar_type;
+ xmlChar *gbar_src;
+ xmlChar *gbar_group;
+ xmlChar *gbar_size; /* Default PD size */
+ xmlChar *hw_acceleration;
+
+ struct dlist *i18n_list;
+ struct dlist *group_list;
+};
+
+struct group {
+ xmlChar *cluster;
+ xmlChar *category;
+ xmlChar *ctx_item;
+ struct dlist *option_list;
+};
+
+struct option {
+ xmlChar *key;
+ xmlChar *value;
+};
+
+static struct {
+ const char *dbfile;
+ sqlite3 *handle;
+} s_info = {
+ .dbfile = "/opt/dbspace/.dynamicbox.db",
+ .handle = NULL,
+};
+
+static inline int begin_transaction(void)
+{
+ sqlite3_stmt *stmt;
+ int ret;
+
+ ret = sqlite3_prepare_v2(s_info.handle, "BEGIN TRANSACTION", -1, &stmt, NULL);
+
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return EXIT_FAILURE;
+ }
+
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Failed to do update (%s)\n",
+ sqlite3_errmsg(s_info.handle));
+ sqlite3_finalize(stmt);
+ return EXIT_FAILURE;
+ }
+
+ sqlite3_finalize(stmt);
+ return EXIT_SUCCESS;
+}
+
+static inline int rollback_transaction(void)
+{
+ int ret;
+ sqlite3_stmt *stmt;
+
+ ret = sqlite3_prepare_v2(s_info.handle, "ROLLBACK TRANSACTION", -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return EXIT_FAILURE;
+ }
+
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Failed to do update (%s)\n",
+ sqlite3_errmsg(s_info.handle));
+ sqlite3_finalize(stmt);
+ return EXIT_FAILURE;
+ }
+
+ sqlite3_finalize(stmt);
+ return EXIT_SUCCESS;
+}
+
+static inline int commit_transaction(void)
+{
+ sqlite3_stmt *stmt;
+ int ret;
+
+ ret = sqlite3_prepare_v2(s_info.handle, "COMMIT TRANSACTION", -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return EXIT_FAILURE;
+ }
+
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Failed to do update (%s)\n",
+ sqlite3_errmsg(s_info.handle));
+ sqlite3_finalize(stmt);
+ return EXIT_FAILURE;
+ }
+
+ sqlite3_finalize(stmt);
+ return EXIT_SUCCESS;
+}
+
+static void db_create_version(void)
+{
+ static const char *ddl = "CREATE TABLE version (version INTEGER)";
+ char *err;
+
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+}
+
+static int set_version(int version)
+{
+ static const char *dml = "INSERT INTO version (version) VALUES (?)";
+ sqlite3_stmt *stmt;
+ int ret;
+
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) {
+ ErrPrint("Failed to bind a id(%s)\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_step(stmt);
+ if (ret != SQLITE_DONE) {
+ ErrPrint("Failed to execute the DML for version: %d\n", ret);
+ ret = -EIO;
+ } else {
+ ret = 0;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static int update_version(int version)
+{
+ static const char *dml = "UPDATE version SET version = ?";
+ sqlite3_stmt *stmt;
+ int ret;
+
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) {
+ ErrPrint("Failed to bind a version: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_step(stmt);
+ if (ret != SQLITE_DONE) {
+ ErrPrint("Failed to execute DML: %d\n", ret);
+ ret = -EIO;
+ } else {
+ ret = 0;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static int get_version(void)
+{
+ static const char *dml = "SELECT version FROM version";
+ sqlite3_stmt *stmt;
+ int ret;
+
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ return -ENOSYS;
+ }
+
+ if (sqlite3_step(stmt) != SQLITE_ROW) {
+ ret = -ENOENT;
+ } else {
+ ret = sqlite3_column_int(stmt, 0);
+ }
+
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+/*!
+ * \note
+ * From version 1 to 2
+ */
+static void upgrade_pkgmap_for_category(void)
+{
+ char *err;
+ static const char *ddl;
+
+ ddl = "ALTER TABLE pkgmap ADD COLUMN category TEXT DEFAULT \"" DEFAULT_CATEGORY "\"";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return;
+}
+
+/**
+ * From version 4 to 5
+ * "provider" table should have "direct_input" column.
+ * "direct_input" will be used for selecting input event path.
+ * if it is "true", the provider must has to get all events from device node directly.
+ * The file descriptor will be given by data-provider-master
+ */
+static void upgrade_to_version_5(void)
+{
+ char *err;
+ static const char *ddl;
+
+ /*
+ * Step 1
+ * Create a new column "direct_input" for provider table
+ */
+ ddl = "ALTER TABLE provider ADD COLUMN direct_input INTEGER DEFAULT 0";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ /*
+ * Step 2
+ * Create a new column "hw_acceleration" for provider table
+ */
+ ddl = "ALTER TABLE provider ADD COLUMN hw_acceleration TEXT DEFAULT 'none'";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+}
+
+/*!
+ * \note
+ * From version 3 to 4
+ * "provider" table should have "count" column.
+ * "count" will be used for limiting creatable count of instances for each dynamicbox.
+ * Every dynamicbox developer should describe their max count of creatable instances.
+ */
+static void upgrade_to_version_4(void)
+{
+ char *err;
+ static const char *ddl;
+
+ /*
+ * Step 1
+ * Create a new column for count to provider table.
+ */
+ ddl = "ALTER TABLE provider ADD COLUMN count INTEGER DEFAULT 0";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+}
+
+/*!
+ * \note
+ * From version 2 to 3
+ * mouse_event is deleted from client table
+ * mouse_event is added to box_size table
+ *
+ * Every size has their own configuration for mouse_event flag.
+ */
+static void upgrade_to_version_3(void)
+{
+ char *err;
+ static const char *ddl;
+ static const char *dml;
+ sqlite3_stmt *select_stmt;
+ int ret;
+
+ /*
+ * Step 1
+ * Create a new column for mouse_event to box_size table.
+ */
+ ddl = "ALTER TABLE box_size ADD COLUMN mouse_event INTEGER DEFAULT 0";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ /*
+ * Step 2
+ * Copy mouse_event values from the client to the box_size table.
+ */
+ dml = "SELECT pkgid, mouse_event FROM client";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &select_stmt, NULL);
+ if (ret == SQLITE_OK) {
+ sqlite3_stmt *update_stmt;
+
+ dml = "UPDATE box_size SET mouse_event = ? WHERE pkgid = ?";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &update_stmt, NULL);
+ if (ret == SQLITE_OK) {
+ int mouse_event;
+ const char *pkgid;
+
+ while (sqlite3_step(select_stmt) == SQLITE_ROW) {
+ pkgid = (const char *)sqlite3_column_text(select_stmt, 0);
+ if (!pkgid) {
+ ErrPrint("Package Id is not valid\n");
+ continue;
+ }
+
+ mouse_event = sqlite3_column_int(select_stmt, 1);
+
+ ret = sqlite3_bind_int(update_stmt, 1, mouse_event);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Failed to bind mouse_event [%s], [%d]\n", pkgid, mouse_event);
+ sqlite3_reset(update_stmt);
+ sqlite3_clear_bindings(update_stmt);
+ continue;
+ }
+
+ ret = sqlite3_bind_text(update_stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Failed to bind pkgid [%s], [%d]\n", pkgid, mouse_event);
+ sqlite3_reset(update_stmt);
+ sqlite3_clear_bindings(update_stmt);
+ continue;
+ }
+
+ ret = sqlite3_step(update_stmt);
+ if (ret != SQLITE_DONE) {
+ ErrPrint("Failed to execute DML: %d\n", ret);
+ sqlite3_reset(update_stmt);
+ sqlite3_clear_bindings(update_stmt);
+ continue;
+ }
+
+ sqlite3_reset(update_stmt);
+ sqlite3_clear_bindings(update_stmt);
+ }
+
+ sqlite3_finalize(update_stmt);
+ } else {
+ ErrPrint("Failed to execute DML\n");
+ }
+
+ sqlite3_reset(select_stmt);
+ sqlite3_clear_bindings(select_stmt);
+ sqlite3_finalize(select_stmt);
+ } else {
+ ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
+ }
+
+ /*
+ * Step 3
+ * Drop a column from the client table
+ */
+ ddl = "ALTER TABLE client DROP COLUMN mouse_event";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return;
+}
+
+static void do_upgrade_db_schema(void)
+{
+ int version;
+
+ version = get_version();
+
+ switch (version) {
+ case -ENOSYS:
+ db_create_version();
+ /* Need to create version table */
+ case -ENOENT:
+ if (set_version(CUR_VER) < 0) {
+ ErrPrint("Failed to set version\n");
+ }
+ /* Need to set version */
+ case 1:
+ upgrade_pkgmap_for_category();
+ case 2:
+ upgrade_to_version_3();
+ case 3:
+ upgrade_to_version_4();
+ case 4:
+ upgrade_to_version_5();
+ default:
+ /* Need to update version */
+ DbgPrint("Old version: %d\n", version);
+ if (update_version(CUR_VER) < 0) {
+ ErrPrint("Failed to update version\n");
+ }
+ case CUR_VER:
+ break;
+ }
+}
+
+static inline int db_create_pkgmap(void)
+{
+ char *err;
+ static const char *ddl;
+
+ ddl = "CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER, category TEXT )";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return 0;
+}
+
+static inline int db_insert_pkgmap(const char *appid, const char *pkgid, const char *uiappid, int primary, const char *category)
+{
+ int ret;
+ static const char *dml;
+ sqlite3_stmt *stmt;
+
+ dml = "INSERT INTO pkgmap ( appid, pkgid, uiapp, prime, category ) VALUES (? ,?, ?, ?, ?)";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 3, uiappid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 4, primary);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 5, category, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_remove_pkgmap(const char *pkgid)
+{
+ int ret;
+ static const char *dml;
+ sqlite3_stmt *stmt;
+
+ dml = "DELETE FROM pkgmap WHERE pkgid = ?";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_create_provider(void)
+{
+ char *err;
+ static const char *ddl;
+
+ ddl = "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 'none', "\
+ "FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
+
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return 0;
+}
+
+static inline int db_remove_provider(const char *pkgid)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "DELETE FROM provider WHERE pkgid = ?";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+static int db_insert_provider(struct dynamicbox *dynamicbox)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+ char *abi = (char *)dynamicbox->abi;
+ char *box_src = (char *)dynamicbox->dbox_src;
+ char *box_group = (char *)dynamicbox->dbox_group;
+ char *gbar_src = (char *)dynamicbox->gbar_src;
+ char *gbar_group = (char *)dynamicbox->gbar_group;
+ char *libexec = (char *)dynamicbox->libexec;
+ char *timeout = (char *)dynamicbox->timeout;
+ char *period = (char *)dynamicbox->period;
+ char *script = (char *)dynamicbox->script;
+ char *hw_acceleration = (char *)dynamicbox->hw_acceleration;
+
+ if (!abi) {
+ abi = "c";
+ }
+
+ if (!timeout) {
+ timeout = "10";
+ }
+
+ if (!period) {
+ period = "0.0";
+ }
+
+ if (!script) {
+ script = "edje";
+ }
+
+ if (!hw_acceleration) {
+ hw_acceleration = "none";
+ }
+
+ dml = "INSERT INTO provider ( pkgid, network, abi, secured, box_type, box_src, box_group, gbar_type, gbar_src, gbar_group, libexec, timeout, period, script, pinup, count, direct_input, hw_acceleration) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, (char *)dynamicbox->pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 2, dynamicbox->network);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 3, abi, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+ ret = sqlite3_bind_int(stmt, 4, dynamicbox->secured);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 5, dynamicbox->dbox_type);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 6, box_src, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 7, box_group, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 8, dynamicbox->gbar_type);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 9, gbar_src, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 10, gbar_group, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 11, libexec, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 12, atoi(timeout));
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 13, period, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 14, script, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 15, dynamicbox->pinup);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 16, dynamicbox->count);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 17, dynamicbox->direct_input);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 18, hw_acceleration, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_create_client(void)
+{
+ char *err;
+ static const char *ddl;
+
+ ddl = "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)";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return 0;
+}
+
+static inline int db_insert_client(struct dynamicbox *dynamicbox)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "INSERT INTO client ( pkgid, icon, name, auto_launch, gbar_size, content, nodisplay, setup ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, (char *)dynamicbox->pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 2, (char *)dynamicbox->icon, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 3, (char *)dynamicbox->name, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 4, (char *)dynamicbox->auto_launch, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 5, (char *)dynamicbox->gbar_size, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 6, (char *)dynamicbox->content, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 7, dynamicbox->nodisplay);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 8, (char *)dynamicbox->setup, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_remove_client(const char *pkgid)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "DELETE FROM client WHERE pkgid = ?";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_create_i18n(void)
+{
+ char *err;
+ static const char *ddl;
+
+ ddl = "CREATE TABLE i18n ( pkgid TEXT NOT NULL, lang TEXT COLLATE NOCASE, name TEXT, " \
+ "icon TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return 0;
+}
+
+static inline int db_insert_i18n(const char *pkgid, const char *lang, const char *name, const char *icon)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ DbgPrint("%s - lang[%s] name[%s] icon[%s]\n", pkgid, lang, name, icon);
+ dml = "INSERT INTO i18n ( pkgid, lang, name, icon ) VALUES (?, ?, ?, ?)";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 2, lang, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 3, name, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 4, icon, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_remove_i18n(const char *pkgid)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "DELETE FROM i18n WHERE pkgid = ?";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ DbgPrint("No changes\n");
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_create_group(void)
+{
+ char *err;
+ static const char *ddl;
+
+ ddl = "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)";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return 0;
+}
+
+static inline int db_insert_group(const char *pkgid, const char *cluster, const char *category)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "INSERT INTO groupinfo ( cluster, category, pkgid ) VALUES (?, ?, ?)";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 3, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static int db_get_group_id(const char *cluster, const char *category)
+{
+ static const char *dml = "SELECT id FROM groupinfo WHERE cluster = ? AND category = ?";
+ sqlite3_stmt *stmt;
+ int ret;
+
+ if (!cluster || !category) {
+ ErrPrint("Invalid argument\n");
+ return -EINVAL;
+ }
+
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = -EIO;
+ if (sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
+ ErrPrint("Failed to bind a cluster(%s) - %s\n", cluster, sqlite3_errmsg(s_info.handle));
+ goto out;
+ }
+
+ if (sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
+ ErrPrint("Failed to bind a category(%s) - %s\n", category, sqlite3_errmsg(s_info.handle));
+ goto out;
+ }
+
+ if (sqlite3_step(stmt) != SQLITE_ROW) {
+ ErrPrint("Failed to execute the DML for %s - %s\n", cluster, category);
+ goto out;
+ }
+
+ ret = sqlite3_column_int(stmt, 0);
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_remove_group(const char *pkgid)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "DELETE FROM groupinfo WHERE pkgid = ?";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ DbgPrint("No changes\n");
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_create_groupmap(void)
+{
+ char *err;
+ static const char *ddl;
+
+ ddl = "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)";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return 0;
+}
+
+static inline int db_get_option_id(int id, const char *pkgid, const char *ctx_item)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "SELECT option_id FROM groupmap WHERE id = ? AND pkgid = ? AND ctx_item = ?";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_int(stmt, 1, id);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 3, ctx_item, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_ROW) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_column_int(stmt, 0);
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_insert_groupmap(int id, const char *pkgid, const char *ctx_item)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ DbgPrint("%d (%s) add to groupmap\n", id, pkgid);
+
+ dml = "INSERT INTO groupmap ( id, pkgid, ctx_item ) VALUES (?, ?, ?)";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_int(stmt, 1, id);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 3, ctx_item, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_remove_groupmap(const char *pkgid)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "DELETE FROM groupmap WHERE pkgid = ?";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ DbgPrint("No changes\n");
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_create_option(void)
+{
+ char *err;
+ static const char *ddl;
+
+ ddl = "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)";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return 0;
+}
+
+static inline int db_insert_option(const char *pkgid, int option_id, const char *key, const char *value)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "INSERT INTO option (pkgid, option_id, key, value) VALUES (?, ?, ?, ?)";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 2, option_id);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 3, key, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 4, value, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_remove_option(const char *pkgid)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "DELETE FROM option WHERE pkgid = ?";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ DbgPrint("No changes\n");
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_create_box_size(void)
+{
+ char *err;
+ static const char *ddl;
+
+ ddl = "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)";
+ if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
+ ErrPrint("Failed to execute the DDL (%s)\n", err);
+ return -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ ErrPrint("No changes to DB\n");
+ }
+
+ return 0;
+}
+
+static int db_insert_box_size(const char *pkgid, int size_type, const char *preview, int touch_effect, int need_frame, int mouse_event)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ DbgPrint("box size: %s - %d (%s) is added\n", pkgid, size_type, preview);
+ dml = "INSERT INTO box_size ( pkgid, size_type, preview, touch_effect, need_frame, mouse_event ) VALUES (?, ?, ?, ?, ?, ?)";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 2, size_type);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_text(stmt, 3, preview, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 4, touch_effect);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 5, need_frame);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = sqlite3_bind_int(stmt, 6, mouse_event);
+ if (ret != SQLITE_OK) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline int db_remove_box_size(const char *pkgid)
+{
+ static const char *dml;
+ int ret;
+ sqlite3_stmt *stmt;
+
+ dml = "DELETE FROM box_size WHERE pkgid = ?";
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
+ if (ret != SQLITE_OK) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ goto out;
+ }
+
+ ret = 0;
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
+ ret = -EIO;
+ }
+
+ if (sqlite3_changes(s_info.handle) == 0) {
+ DbgPrint("No changes\n");
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return ret;
+}
+
+static inline void db_create_table(void)
+{
+ int ret;
+ begin_transaction();
+
+ ret = db_create_pkgmap();
+ if (ret < 0) {
+ rollback_transaction();
+ return;
+ }
+
+ ret = db_create_provider();
+ if (ret < 0) {
+ rollback_transaction();
+ return;
+ }
+
+ ret = db_create_client();
+ if (ret < 0) {
+ rollback_transaction();
+ return;
+ }
+
+ ret = db_create_i18n();
+ if (ret < 0) {
+ rollback_transaction();
+ return;
+ }
+
+ ret = db_create_box_size();
+ if (ret < 0) {
+ rollback_transaction();
+ return;
+ }
+
+ ret = db_create_group();
+ if (ret < 0) {
+ rollback_transaction();
+ return;
+ }
+
+ ret = db_create_option();
+ if (ret < 0) {
+ rollback_transaction();
+ return;
+ }
+
+ ret = db_create_groupmap();
+ if (ret < 0) {
+ rollback_transaction();
+ return;
+ }
+
+ commit_transaction();
+}
+
+static int db_init(void)
+{
+ int ret;
+ struct stat stat;
+
+ ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Failed to open a DB\n");
+ return -EIO;
+ }
+
+ if (lstat(s_info.dbfile, &stat) < 0) {
+ ErrPrint("%s\n", strerror(errno));
+ db_util_close(s_info.handle);
+ s_info.handle = NULL;
+ return -EIO;
+ }
+
+ if (!S_ISREG(stat.st_mode)) {
+ ErrPrint("Invalid file\n");
+ db_util_close(s_info.handle);
+ s_info.handle = NULL;
+ return -EINVAL;
+ }
+
+ if (!stat.st_size) {
+ db_create_table();
+ }
+
+ return 0;
+}
+
+static inline int db_fini(void)
+{
+ if (!s_info.handle) {
+ return 0;
+ }
+
+ db_util_close(s_info.handle);
+ s_info.handle = NULL;
+
+ return 0;
+}
+
+static inline int validate_pkgid(const char *appid, const char *pkgid)
+{
+ /* Just return 1 Always */
+ return 1 || !strncmp(appid, pkgid, strlen(appid));
+}
+
+static int dynamicbox_destroy(struct dynamicbox *dynamicbox)
+{
+ struct dlist *l;
+ struct dlist *n;
+ struct i18n *i18n;
+ struct group *group;
+ struct option *option;
+ struct dlist *il;
+ struct dlist *in;
+
+ xmlFree(dynamicbox->auto_launch);
+ xmlFree(dynamicbox->pkgid);
+ xmlFree(dynamicbox->abi);
+ xmlFree(dynamicbox->name);
+ xmlFree(dynamicbox->icon);
+ xmlFree(dynamicbox->dbox_src);
+ xmlFree(dynamicbox->dbox_group);
+ xmlFree(dynamicbox->gbar_src);
+ xmlFree(dynamicbox->gbar_group);
+ xmlFree(dynamicbox->gbar_size);
+ xmlFree(dynamicbox->libexec);
+ xmlFree(dynamicbox->script);
+ xmlFree(dynamicbox->period);
+ xmlFree(dynamicbox->content);
+ xmlFree(dynamicbox->setup);
+ xmlFree(dynamicbox->category);
+ xmlFree(dynamicbox->preview[0]); /* 1x1 */
+ xmlFree(dynamicbox->preview[1]); /* 2x1 */
+ xmlFree(dynamicbox->preview[2]); /* 2x2 */
+ xmlFree(dynamicbox->preview[3]); /* 4x1 */
+ xmlFree(dynamicbox->preview[4]); /* 4x2 */
+ xmlFree(dynamicbox->preview[5]); /* 4x3 */
+ xmlFree(dynamicbox->preview[6]); /* 4x4 */
+ xmlFree(dynamicbox->preview[7]); /* 4x5 */
+ xmlFree(dynamicbox->preview[8]); /* 4x6 */
+ xmlFree(dynamicbox->preview[9]); /* easy 1x1 */
+ xmlFree(dynamicbox->preview[10]); /* easy 3x1 */
+ xmlFree(dynamicbox->preview[11]); /* easy 3x3 */
+ xmlFree(dynamicbox->preview[12]); /* full */
+ xmlFree(dynamicbox->hw_acceleration);
+
+ dlist_foreach_safe(dynamicbox->i18n_list, l, n, i18n) {
+ dynamicbox->i18n_list = dlist_remove(dynamicbox->i18n_list, l);
+ xmlFree(i18n->name);
+ xmlFree(i18n->icon);
+ xmlFree(i18n->lang);
+ free(i18n);
+ }
+
+ dlist_foreach_safe(dynamicbox->group_list, l, n, group) {
+ dynamicbox->group_list = dlist_remove(dynamicbox->group_list, l);
+ DbgPrint("Release %s/%s\n", group->cluster, group->category);
+
+ if (group->ctx_item) {
+ dlist_foreach_safe(group->option_list, il, in, option) {
+ group->option_list = dlist_remove(group->option_list, il);
+ DbgPrint("Release option %s(%s)\n", option->key, option->value);
+ xmlFree(option->key);
+ xmlFree(option->value);
+ free(option);
+ }
+ xmlFree(group->ctx_item);
+ }
+
+ xmlFree(group->cluster);
+ xmlFree(group->category);
+ free(group);
+ }
+
+ free(dynamicbox);
+ return 0;
+}
+
+static inline void update_i18n_name(struct dynamicbox *dynamicbox, xmlNodePtr node)
+{
+ struct i18n *i18n;
+ struct dlist *l;
+ xmlChar *lang;
+ xmlChar *name;
+
+ name = xmlNodeGetContent(node);
+ if (!name) {
+ ErrPrint("Invalid tag\n");
+ return;
+ }
+
+ lang = xmlNodeGetLang(node);
+ if (!lang) {
+ if (dynamicbox->name) {
+ DbgPrint("Override default name: %s\n", dynamicbox->name);
+ xmlFree(dynamicbox->name);
+ }
+
+ dynamicbox->name = name;
+ return;
+ }
+
+ dlist_foreach(dynamicbox->i18n_list, l, i18n) {
+ if (!xmlStrcasecmp(i18n->lang, lang)) {
+ if (i18n->name) {
+ DbgPrint("Override name: %s\n", i18n->name);
+ xmlFree(i18n->name);
+ }
+
+ i18n->name = name;
+ return;
+ }
+ }
+
+ i18n = calloc(1, sizeof(*i18n));
+ if (!i18n) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ xmlFree(name);
+ xmlFree(lang);
+ return;
+ }
+
+ i18n->name = name;
+ i18n->lang = lang;
+ DbgPrint("Label[%s] - [%s] added\n", i18n->lang, i18n->name);
+ dynamicbox->i18n_list = dlist_append(dynamicbox->i18n_list, i18n);
+}
+
+static inline void update_i18n_icon(struct dynamicbox *dynamicbox, xmlNodePtr node)
+{
+ struct i18n *i18n;
+ struct dlist *l;
+ xmlChar *lang;
+ xmlChar *icon;
+
+ icon = xmlNodeGetContent(node);
+ if (!icon) {
+ ErrPrint("Invalid tag\n");
+ return;
+ }
+
+ lang = xmlNodeGetLang(node);
+ if (!lang) {
+ if (dynamicbox->icon) {
+ DbgPrint("Override default icon: %s\n", dynamicbox->icon);
+ xmlFree(dynamicbox->icon);
+ }
+
+ dynamicbox->icon = icon;
+ return;
+ }
+
+ dlist_foreach(dynamicbox->i18n_list, l, i18n) {
+ if (!xmlStrcasecmp(i18n->lang, lang)) {
+ if (i18n->icon) {
+ DbgPrint("Override icon %s for %s\n", i18n->icon, i18n->name);
+ xmlFree(i18n->icon);
+ }
+
+ i18n->icon = icon;
+ return;
+ }
+ }
+
+ i18n = calloc(1, sizeof(*i18n));
+ if (!i18n) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ xmlFree(icon);
+ xmlFree(lang);
+ return;
+ }
+
+ i18n->icon = icon;
+ i18n->lang = lang;
+ DbgPrint("Icon[%s] - [%s] added\n", i18n->lang, i18n->icon);
+ dynamicbox->i18n_list = dlist_append(dynamicbox->i18n_list, i18n);
+}
+
+static inline void update_launch(struct dynamicbox *dynamicbox, xmlNodePtr node)
+{
+ xmlChar *launch;
+
+ launch = xmlNodeGetContent(node);
+ if (!launch) {
+ DbgPrint("Has no launch\n");
+ return;
+ }
+
+ if (dynamicbox->auto_launch) {
+ xmlFree(dynamicbox->auto_launch);
+ }
+
+ dynamicbox->auto_launch = xmlStrdup(launch);
+ if (!dynamicbox->auto_launch) {
+ ErrPrint("Failed to duplicate string: %s\n", (char *)launch);
+ return;
+ }
+}
+
+static inline void update_category(struct dynamicbox *dynamicbox, xmlNodePtr node)
+{
+ xmlChar *category;
+
+ category = xmlGetProp(node, (const xmlChar *)"name");
+ if (!category) {
+ DbgPrint("Has no valid category\n");
+ return;
+ }
+
+ if (dynamicbox->category) {
+ xmlFree(dynamicbox->category);
+ }
+
+ dynamicbox->category = xmlStrdup(category);
+ if (!dynamicbox->category) {
+ ErrPrint("Failed to duplicate string: %s\n", (char *)category);
+ return;
+ }
+}
+
+static inline void update_ui_appid(struct dynamicbox *dynamicbox, xmlNodePtr node)
+{
+ xmlChar *uiapp;
+ uiapp = xmlNodeGetContent(node);
+ if (!uiapp) {
+ DbgPrint("Has no valid ui-appid\n");
+ return;
+ }
+
+ if (dynamicbox->uiapp) {
+ xmlFree(dynamicbox->uiapp);
+ }
+
+ dynamicbox->uiapp = xmlStrdup(uiapp);
+ if (!dynamicbox->uiapp) {
+ ErrPrint("Failed to duplicate string: %s\n", (char *)uiapp);
+ return;
+ }
+}
+
+static inline void update_setup(struct dynamicbox *dynamicbox, xmlNodePtr node)
+{
+ xmlChar *setup;
+ setup = xmlNodeGetContent(node);
+ if (!setup) {
+ DbgPrint("Has no setup\n");
+ return;
+ }
+
+ if (dynamicbox->setup) {
+ xmlFree(dynamicbox->setup);
+ }
+
+ dynamicbox->setup = xmlStrdup(setup);
+ if (!dynamicbox->setup) {
+ ErrPrint("Failed to duplicate string: %s\n", (char *)setup);
+ return;
+ }
+}
+
+static inline void update_content(struct dynamicbox *dynamicbox, xmlNodePtr node)
+{
+ xmlChar *content;
+ content = xmlNodeGetContent(node);
+ if (!content) {
+ DbgPrint("Has no content\n");
+ return;
+ }
+
+ if (dynamicbox->content) {
+ xmlFree(dynamicbox->content);
+ }
+
+ dynamicbox->content = xmlStrdup(content);
+ if (!dynamicbox->content) {
+ ErrPrint("Failed to duplicate string: %s\n", (char *)content);
+ return;
+ }
+}
+
+static void update_size_info(struct dynamicbox *dynamicbox, int idx, xmlNodePtr node)
+{
+ if (xmlHasProp(node, (const xmlChar *)"preview")) {
+ dynamicbox->preview[idx] = xmlGetProp(node, (const xmlChar *)"preview");
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"need_frame")) {
+ xmlChar *need_frame;
+
+ need_frame = xmlGetProp(node, (const xmlChar *)"need_frame");
+ if (need_frame) {
+ dynamicbox->need_frame[idx] = !xmlStrcasecmp(need_frame, (const xmlChar *)"true");
+ xmlFree(need_frame);
+ } else {
+ dynamicbox->need_frame[idx] = dynamicbox->default_need_frame;
+ }
+ } else {
+ dynamicbox->need_frame[idx] = dynamicbox->default_need_frame;
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"touch_effect")) {
+ xmlChar *touch_effect;
+
+ touch_effect = xmlGetProp(node, (const xmlChar *)"touch_effect");
+ if (touch_effect) {
+ dynamicbox->touch_effect[idx] = !xmlStrcasecmp(touch_effect, (const xmlChar *)"true");
+ xmlFree(touch_effect);
+ } else {
+ dynamicbox->touch_effect[idx] = dynamicbox->default_touch_effect;
+ }
+ } else {
+ dynamicbox->touch_effect[idx] = dynamicbox->default_touch_effect;
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"mouse_event")) {
+ xmlChar *mouse_event;
+
+ mouse_event = xmlGetProp(node, (const xmlChar *)"mouse_event");
+ if (mouse_event) {
+ dynamicbox->mouse_event[idx] = !xmlStrcasecmp(mouse_event, (const xmlChar *)"true");
+ xmlFree(mouse_event);
+ } else {
+ dynamicbox->mouse_event[idx] = dynamicbox->default_mouse_event;
+ }
+ } else {
+ dynamicbox->mouse_event[idx] = dynamicbox->default_mouse_event;
+ }
+}
+
+static void update_box(struct dynamicbox *dynamicbox, xmlNodePtr node)
+{
+ if (!xmlHasProp(node, (const xmlChar *)"type")) {
+ dynamicbox->dbox_type = DBOX_TYPE_FILE;
+ } else {
+ xmlChar *type;
+
+ type = xmlGetProp(node, (const xmlChar *)"type");
+ if (!type) {
+ ErrPrint("Type is NIL\n");
+ dynamicbox->dbox_type = DBOX_TYPE_FILE;
+ } else {
+ if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
+ dynamicbox->dbox_type = DBOX_TYPE_TEXT;
+ } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
+ dynamicbox->dbox_type = DBOX_TYPE_BUFFER;
+ } else if (!xmlStrcasecmp(type, (const xmlChar *)"script")) {
+ dynamicbox->dbox_type = DBOX_TYPE_SCRIPT;
+ } else if (!xmlStrcasecmp(type, (const xmlChar *)"elm")) {
+ dynamicbox->dbox_type = DBOX_TYPE_UIFW;
+ } else { /* Default */
+ dynamicbox->dbox_type = DBOX_TYPE_FILE;
+ }
+
+ xmlFree(type);
+ }
+ }
+
+ if (!xmlHasProp(node, (const xmlChar *)"mouse_event")) {
+ dynamicbox->default_mouse_event = 0;
+ } else {
+ xmlChar *mouse_event;
+
+ mouse_event = xmlGetProp(node, (const xmlChar *)"mouse_event");
+ if (!mouse_event) {
+ ErrPrint("mouse_event is NIL\n");
+ dynamicbox->default_mouse_event = 0;
+ } else {
+ dynamicbox->default_mouse_event = !xmlStrcasecmp(mouse_event, (const xmlChar *)"true");
+ xmlFree(mouse_event);
+ }
+ }
+
+ if (!xmlHasProp(node, (const xmlChar *)"touch_effect")) {
+ dynamicbox->default_touch_effect = 1;
+ } else {
+ xmlChar *touch_effect;
+
+ touch_effect = xmlGetProp(node, (const xmlChar *)"touch_effect");
+ if (!touch_effect) {
+ ErrPrint("default touch_effect is NIL\n");
+ dynamicbox->default_touch_effect = 1;
+ } else {
+ dynamicbox->default_touch_effect = !xmlStrcasecmp(touch_effect, (const xmlChar *)"true");
+ xmlFree(touch_effect);
+ }
+ }
+
+ if (!xmlHasProp(node, (const xmlChar *)"need_frame")) {
+ dynamicbox->default_need_frame = 0;
+ } else {
+ xmlChar *need_frame;
+
+ need_frame = xmlGetProp(node, (const xmlChar *)"need_frame");
+ if (!need_frame) {
+ ErrPrint("default need_frame is NIL\n");
+ dynamicbox->default_need_frame = 0;
+ } else {
+ dynamicbox->default_need_frame = !xmlStrcasecmp(need_frame, (const xmlChar *)"true");
+ xmlFree(need_frame);
+ }
+ }
+
+ for (node = node->children; node; node = node->next) {
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"size")) {
+ xmlChar *size;
+ int is_easy = 0;
+
+ size = xmlNodeGetContent(node);
+ if (!size) {
+ ErrPrint("Invalid size tag\n");
+ continue;
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"mode")) {
+ xmlChar *mode;
+ mode = xmlGetProp(node, (const xmlChar *)"mode");
+ if (mode) {
+ DbgPrint("Easy mode: %s\n", mode);
+ is_easy = !xmlStrcasecmp(mode, (const xmlChar *)"easy");
+ xmlFree(mode);
+ }
+ }
+
+ if (!xmlStrcasecmp(size, (const xmlChar *)"1x1")) {
+ if (is_easy) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_1x1;
+ update_size_info(dynamicbox, 9, node);
+ } else {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_1x1;
+ update_size_info(dynamicbox, 0, node);
+ }
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"3x1")) {
+ if (is_easy) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_3x1;
+ update_size_info(dynamicbox, 10, node);
+ } else {
+ ErrPrint("Invalid size tag (%s)\n", size);
+ }
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"3x3")) {
+ if (is_easy) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_3x3;
+ update_size_info(dynamicbox, 11, node);
+ } else {
+ ErrPrint("Invalid size tag (%s)\n", size);
+ }
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"2x1")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_2x1;
+ update_size_info(dynamicbox, 1, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"2x2")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_2x2;
+ update_size_info(dynamicbox, 2, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x1")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_4x1;
+ update_size_info(dynamicbox, 3, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x2")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_4x2;
+ update_size_info(dynamicbox, 4, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x3")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_4x3;
+ update_size_info(dynamicbox, 5, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x4")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_4x4;
+ update_size_info(dynamicbox, 6, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x5")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_4x5;
+ update_size_info(dynamicbox, 7, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x6")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_4x6;
+ update_size_info(dynamicbox, 8, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"21x21")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_1x1;
+ update_size_info(dynamicbox, 9, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"23x21")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_3x1;
+ update_size_info(dynamicbox, 10, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"23x23")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_EASY_3x3;
+ update_size_info(dynamicbox, 11, node);
+ } else if (!xmlStrcasecmp(size, (const xmlChar *)"0x0")) {
+ dynamicbox->size_list |= DBOX_SIZE_TYPE_0x0;
+ update_size_info(dynamicbox, 12, node);
+ } else {
+ ErrPrint("Invalid size tag (%s)\n", size);
+ }
+
+ xmlFree(size);
+ } else if (!xmlStrcasecmp(node->name, (const xmlChar *)"script")) {
+ xmlChar *src;
+
+ if (!xmlHasProp(node, (const xmlChar *)"src")) {
+ ErrPrint("Invalid script tag. has no src\n");
+ continue;
+ }
+
+ src = xmlGetProp(node, (const xmlChar *)"src");
+ if (!src) {
+ ErrPrint("Invalid script tag. src is NIL\n");
+ continue;
+ }
+
+ if (dynamicbox->dbox_src) {
+ DbgPrint("Override lb src: %s\n", dynamicbox->dbox_src);
+ xmlFree(dynamicbox->dbox_src);
+ }
+
+ dynamicbox->dbox_src = src;
+
+ if (xmlHasProp(node, (const xmlChar *)"group")) {
+ xmlChar *group;
+ group = xmlGetProp(node, (const xmlChar *)"group");
+ if (!group) {
+ ErrPrint("Group is NIL\n");
+ } else {
+ if (dynamicbox->dbox_group) {
+ DbgPrint("Override lb group: %s\n", dynamicbox->dbox_group);
+ xmlFree(dynamicbox->dbox_group);
+ }
+
+ dynamicbox->dbox_group = group;
+ }
+ }
+ }
+ }
+}
+
+static inline void update_group(struct dynamicbox *dynamicbox, xmlNodePtr node)
+{
+ xmlNodePtr cluster;
+ xmlNodePtr category;
+ xmlNodePtr option_item;
+ xmlChar *cluster_name;
+ xmlChar *category_name;
+ xmlChar *ctx_item;
+
+ xmlChar *key;
+ xmlChar *value;
+
+ struct group *group;
+ struct option *option;
+
+ cluster = node;
+ for (cluster = cluster->children; cluster; cluster = cluster->next) {
+ if (xmlStrcasecmp(cluster->name, (const xmlChar *)"cluster")) {
+ DbgPrint("Skip: %s\n", cluster->name);
+ continue;
+ }
+
+ if (!xmlHasProp(cluster, (const xmlChar *)"name")) {
+ ErrPrint("Invalid cluster, has no name\n");
+ continue;
+ }
+
+ cluster_name = xmlGetProp(cluster, (const xmlChar *)"name");
+ if (!cluster_name) {
+ ErrPrint("Invalid cluster name. NIL\n");
+ continue;
+ }
+
+ for (category = cluster->children; category; category = category->next) {
+ if (xmlStrcasecmp(category->name, (const xmlChar *)"category")) {
+ DbgPrint("Skip: %s\n", category->name);
+ continue;
+ }
+
+ if (!xmlHasProp(category, (const xmlChar *)"name")) {
+ ErrPrint("Invalid category, has no name\n");
+ continue;
+ }
+
+ category_name = xmlGetProp(category, (const xmlChar *)"name");
+ if (!category_name) {
+ ErrPrint("Invalid category name. NIL\n");
+ continue;
+ }
+
+ group = calloc(1, sizeof(*group));
+ if (!group) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ xmlFree(category_name);
+ continue;
+ }
+
+ group->cluster = xmlStrdup(cluster_name);
+ if (!group->cluster) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ xmlFree(category_name);
+ free(group);
+ continue;
+ }
+
+ group->category = category_name;
+ dynamicbox->group_list = dlist_append(dynamicbox->group_list, group);
+
+ if (!xmlHasProp(category, (const xmlChar *)"context")) {
+ DbgPrint("%s, %s has no ctx info\n", group->cluster, group->category);
+ continue;
+ }
+
+ ctx_item = xmlGetProp(category, (const xmlChar *)"context");
+ if (!ctx_item) {
+ ErrPrint("Failed to get context ID (%s, %s)\n", group->cluster, group->category);
+ continue;
+ }
+
+ group->ctx_item = ctx_item;
+ DbgPrint("Build group item: %s - %s - %s\n", group->cluster, group->category, group->ctx_item);
+
+ for (option_item = category->children; option_item; option_item = option_item->next) {
+ if (xmlStrcasecmp(option_item->name, (const xmlChar *)"option")) {
+ DbgPrint("Skip: %s\n", option_item->name);
+ continue;
+ }
+
+ if (!xmlHasProp(option_item, (const xmlChar *)"key")) {
+ ErrPrint("Invalid option, has no key\n");
+ continue;
+ }
+
+ if (!xmlHasProp(option_item, (const xmlChar *)"value")) {
+ ErrPrint("Invalid option, has no value\n");
+ continue;
+ }
+
+ key = xmlGetProp(option_item, (const xmlChar *)"key");
+ if (!key) {
+ ErrPrint("Invalid key. NIL\n");
+ continue;
+ }
+
+ value = xmlGetProp(option_item, (const xmlChar *)"value");
+ if (!value) {
+ ErrPrint("Invalid valid. NIL\n");
+ xmlFree(key);
+ continue;
+ }
+
+ option = calloc(1, sizeof(*option));
+ if (!option) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ xmlFree(key);
+ xmlFree(value);
+ continue;
+ }
+
+ option->key = key;
+ option->value = value;
+
+ group->option_list = dlist_append(group->option_list, option);
+ }
+ }
+
+ xmlFree(cluster_name);
+ }
+}
+
+static inline void update_pd(struct dynamicbox *dynamicbox, xmlNodePtr node)
+{
+ if (!xmlHasProp(node, (const xmlChar *)"type")) {
+ dynamicbox->gbar_type = GBAR_TYPE_SCRIPT;
+ } else {
+ xmlChar *type;
+
+ type = xmlGetProp(node, (const xmlChar *)"type");
+ if (!type) {
+ ErrPrint("type is NIL\n");
+ return;
+ }
+
+ if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
+ dynamicbox->gbar_type = GBAR_TYPE_TEXT;
+ } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
+ dynamicbox->gbar_type = GBAR_TYPE_BUFFER;
+ } else if (!xmlStrcasecmp(type, (const xmlChar *)"elm")) {
+ dynamicbox->gbar_type = GBAR_TYPE_UIFW;
+ } else {
+ dynamicbox->gbar_type = GBAR_TYPE_SCRIPT;
+ }
+
+ xmlFree(type);
+ }
+
+ for (node = node->children; node; node = node->next) {
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"size")) {
+ xmlChar *size;
+
+ size = xmlNodeGetContent(node);
+ if (!size) {
+ ErrPrint("Invalid size tag\n");
+ continue;
+ }
+
+ if (dynamicbox->gbar_size) {
+ DbgPrint("Override pd size: %s\n", dynamicbox->gbar_size);
+ xmlFree(dynamicbox->gbar_size);
+ }
+ dynamicbox->gbar_size = size;
+ } else if (!xmlStrcasecmp(node->name, (const xmlChar *)"script")) {
+ xmlChar *src;
+
+ if (!xmlHasProp(node, (const xmlChar *)"src")) {
+ ErrPrint("Invalid script tag, has no src\n");
+ continue;
+ }
+
+ src = xmlGetProp(node, (const xmlChar *)"src");
+ if (!src) {
+ ErrPrint("src is NIL\n");
+ continue;
+ }
+
+ if (dynamicbox->gbar_src) {
+ DbgPrint("Overide PD src: %s\n", dynamicbox->gbar_src);
+ xmlFree(dynamicbox->gbar_src);
+ }
+
+ dynamicbox->gbar_src = src;
+
+ if (xmlHasProp(node, (const xmlChar *)"group")) {
+ xmlChar *group;
+ group = xmlGetProp(node, (const xmlChar *)"group");
+ if (!group) {
+ ErrPrint("Group is NIL\n");
+ } else {
+ if (dynamicbox->gbar_group) {
+ DbgPrint("Override PD group : %s\n", dynamicbox->gbar_group);
+ xmlFree(dynamicbox->gbar_group);
+ }
+
+ dynamicbox->gbar_group = group;
+ }
+ }
+ }
+ }
+}
+
+static int db_insert_dynamicbox(struct dynamicbox *dynamicbox, const char *appid)
+{
+ struct dlist *l;
+ struct dlist *il;
+ struct i18n *i18n;
+ struct group *group;
+ int ret;
+ int id;
+ struct option *option;
+
+ begin_transaction();
+ ret = db_insert_pkgmap(appid, (char *)dynamicbox->pkgid, (char *)dynamicbox->uiapp, dynamicbox->primary, (char *)dynamicbox->category);
+ if (ret < 0) {
+ goto errout;
+ }
+
+ ret = db_insert_provider(dynamicbox);
+ if (ret < 0) {
+ goto errout;
+ }
+
+ ret = db_insert_client(dynamicbox);
+ if (ret < 0) {
+ goto errout;
+ }
+
+ dlist_foreach(dynamicbox->i18n_list, l, i18n) {
+ ret = db_insert_i18n((char *)dynamicbox->pkgid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_1x1) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_1x1, (char *)dynamicbox->preview[0], dynamicbox->touch_effect[0], dynamicbox->need_frame[0], dynamicbox->mouse_event[0]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_2x1) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_2x1, (char *)dynamicbox->preview[1], dynamicbox->touch_effect[1], dynamicbox->need_frame[1], dynamicbox->mouse_event[1]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_2x2) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_2x2, (char *)dynamicbox->preview[2], dynamicbox->touch_effect[2], dynamicbox->need_frame[2], dynamicbox->mouse_event[2]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x1) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x1, (char *)dynamicbox->preview[3], dynamicbox->touch_effect[3], dynamicbox->need_frame[3], dynamicbox->mouse_event[3]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x2) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x2, (char *)dynamicbox->preview[4], dynamicbox->touch_effect[4], dynamicbox->need_frame[4], dynamicbox->mouse_event[4]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x3) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x3, (char *)dynamicbox->preview[5], dynamicbox->touch_effect[5], dynamicbox->need_frame[5], dynamicbox->mouse_event[5]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x4) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x4, (char *)dynamicbox->preview[6], dynamicbox->touch_effect[6], dynamicbox->need_frame[6], dynamicbox->mouse_event[6]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x5) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x5, (char *)dynamicbox->preview[7], dynamicbox->touch_effect[7], dynamicbox->need_frame[7], dynamicbox->mouse_event[7]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_4x6) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_4x6, (char *)dynamicbox->preview[8], dynamicbox->touch_effect[8], dynamicbox->need_frame[8], dynamicbox->mouse_event[8]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_EASY_1x1) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_EASY_1x1, (char *)dynamicbox->preview[9], dynamicbox->touch_effect[9], dynamicbox->need_frame[9], dynamicbox->mouse_event[9]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_EASY_3x1) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_EASY_3x1, (char *)dynamicbox->preview[10], dynamicbox->touch_effect[10], dynamicbox->need_frame[10], dynamicbox->mouse_event[10]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_EASY_3x3) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_EASY_3x3, (char *)dynamicbox->preview[11], dynamicbox->touch_effect[11], dynamicbox->need_frame[11], dynamicbox->mouse_event[11]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ if (dynamicbox->size_list & DBOX_SIZE_TYPE_0x0) {
+ ret = db_insert_box_size((char *)dynamicbox->pkgid, DBOX_SIZE_TYPE_0x0, (char *)dynamicbox->preview[12], dynamicbox->touch_effect[12], dynamicbox->need_frame[12], dynamicbox->mouse_event[12]);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+
+ dlist_foreach(dynamicbox->group_list, l, group) {
+ /* group ID "id" */
+ id = db_get_group_id((char *)group->cluster, (char *)group->category);
+ if (id < 0) {
+ int ret;
+
+ ret = db_insert_group((char *)dynamicbox->pkgid, (char *)group->cluster, (char *)group->category);
+ if (ret < 0) {
+ ErrPrint("[%s]-[%s] is not exists\n", group->cluster, group->category);
+ continue;
+ }
+
+ DbgPrint("New group name is built - %s/%s\n", group->cluster, group->category);
+ id = db_get_group_id((char *)group->cluster, (char *)group->category);
+ if (id < 0) {
+ ErrPrint("Failed to get group id for %s/%s\n", group->cluster, group->category);
+ continue;
+ }
+ }
+
+ if (!group->ctx_item) {
+ DbgPrint("%s, %s - has no ctx info\n", group->cluster, group->category);
+ continue;
+ }
+
+ ret = db_insert_groupmap(id, (char *)dynamicbox->pkgid, (char *)group->ctx_item);
+ if (ret < 0) {
+ goto errout;
+ }
+
+ /* REUSE "id" from here , option ID */
+ id = db_get_option_id(id, (char *)dynamicbox->pkgid, (char *)group->ctx_item);
+ if (id < 0) {
+ goto errout;
+ }
+
+ dlist_foreach(group->option_list, il, option) {
+ ret = db_insert_option((char *)dynamicbox->pkgid, id, (char *)option->key, (char *)option->value);
+ if (ret < 0) {
+ goto errout;
+ }
+ }
+ }
+
+ commit_transaction();
+ dynamicbox_destroy(dynamicbox);
+ return 0;
+
+errout:
+ ErrPrint("ROLLBACK\n");
+ rollback_transaction();
+ dynamicbox_destroy(dynamicbox);
+ return ret;
+}
+
+static int do_install(xmlNodePtr node, const char *appid)
+{
+ struct dynamicbox *dynamicbox;
+ xmlChar *pkgid;
+ xmlChar *tmp;
+
+ if (!xmlHasProp(node, (const xmlChar *)"appid")) {
+ ErrPrint("Missing appid\n");
+ return -EINVAL;
+ }
+
+ pkgid = xmlGetProp(node, (const xmlChar *)"appid");
+ if (!pkgid || !validate_pkgid(appid, (char *)pkgid)) {
+ ErrPrint("Invalid appid\n");
+ xmlFree(pkgid);
+ return -EINVAL;
+ }
+
+ DbgPrint("appid: %s\n", (char *)pkgid);
+
+ dynamicbox = calloc(1, sizeof(*dynamicbox));
+ if (!dynamicbox) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ xmlFree(pkgid);
+ return -ENOMEM;
+ }
+
+ dynamicbox->pkgid = pkgid;
+
+ if (xmlHasProp(node, (const xmlChar *)"count")) {
+ tmp = xmlGetProp(node, (const xmlChar *)"count");
+ if (sscanf((const char *)tmp, "%d", &dynamicbox->count) != 1) {
+ ErrPrint("Invalid syntax: %s\n", (const char *)tmp);
+ }
+ xmlFree(tmp);
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"primary")) {
+ tmp = xmlGetProp(node, (const xmlChar *)"primary");
+ dynamicbox->primary = !xmlStrcasecmp(tmp, (const xmlChar *)"true");
+ xmlFree(tmp);
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"script")) {
+ dynamicbox->script = xmlGetProp(node, (const xmlChar *)"script");
+ if (!dynamicbox->script) {
+ ErrPrint("script is NIL\n");
+ }
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"nodisplay")) {
+ tmp = xmlGetProp(node, (const xmlChar *)"nodisplay");
+ dynamicbox->nodisplay = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
+ xmlFree(tmp);
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"pinup")) {
+ tmp = xmlGetProp(node, (const xmlChar *)"pinup");
+ dynamicbox->pinup = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
+ xmlFree(tmp);
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"period")) {
+ dynamicbox->period = xmlGetProp(node, (const xmlChar *)"period");
+ if (!dynamicbox->period) {
+ ErrPrint("Period is NIL\n");
+ }
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"timeout")) {
+ dynamicbox->timeout = xmlGetProp(node, (const xmlChar *)"timeout");
+ if (!dynamicbox->timeout) {
+ ErrPrint("Timeout is NIL\n");
+ }
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"secured")) {
+ tmp = xmlGetProp(node, (const xmlChar *)"secured");
+ dynamicbox->secured = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
+ xmlFree(tmp);
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"network")) {
+ tmp = xmlGetProp(node, (const xmlChar *)"network");
+ dynamicbox->network = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
+ xmlFree(tmp);
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"direct_input")) {
+ tmp = xmlGetProp(node, (const xmlChar *)"direct_input");
+ dynamicbox->direct_input = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
+ xmlFree(tmp);
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"hw-acceleration")) {
+ dynamicbox->hw_acceleration = xmlGetProp(node, (const xmlChar *)"hw-acceleration");
+ if (!dynamicbox->hw_acceleration) {
+ ErrPrint("hw-acceleration is NIL\n");
+ }
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"abi")) {
+ dynamicbox->abi = xmlGetProp(node, (const xmlChar *)"abi");
+ if (!dynamicbox->abi) {
+ ErrPrint("ABI is NIL\n");
+ dynamicbox_destroy(dynamicbox);
+ return -EFAULT;
+ }
+ } else {
+ dynamicbox->abi = xmlStrdup((const xmlChar *)"c");
+ if (!dynamicbox->abi) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ dynamicbox_destroy(dynamicbox);
+ return -ENOMEM;
+ }
+ }
+
+ if (xmlHasProp(node, (const xmlChar *)"libexec")) {
+ dynamicbox->libexec = xmlGetProp(node, (const xmlChar *)"libexec");
+ if (!dynamicbox->libexec) {
+ ErrPrint("libexec is NIL\n");
+ dynamicbox_destroy(dynamicbox);
+ return -EFAULT;
+ }
+ } else if (!xmlStrcasecmp(dynamicbox->abi, (const xmlChar *)"c") || !xmlStrcasecmp(dynamicbox->abi, (const xmlChar *)"cpp")) {
+ char *filename;
+ int len;
+
+ len = strlen((char *)dynamicbox->pkgid) + strlen("/libexec/liblive-.so") + 1;
+
+ filename = malloc(len);
+ if (!filename) {
+ dynamicbox_destroy(dynamicbox);
+ return -ENOMEM;
+ }
+
+ snprintf(filename, len, "/libexec/liblive-%s.so", dynamicbox->pkgid);
+ dynamicbox->libexec = xmlStrdup((xmlChar *)filename);
+ DbgPrint("Use the default libexec: %s\n", filename);
+ free(filename);
+
+ if (!dynamicbox->libexec) {
+ dynamicbox_destroy(dynamicbox);
+ return -ENOMEM;
+ }
+ }
+
+ for (node = node->children; node; node = node->next) {
+ if (!xmlStrcmp(node->name, (const xmlChar *)"text")) {
+ continue;
+ }
+
+ DbgPrint("Nodename: %s\n", node->name);
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"label")) {
+ update_i18n_name(dynamicbox, node);
+ continue;
+ }
+
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"icon")) {
+ update_i18n_icon(dynamicbox, node);
+ continue;
+ }
+
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"box")) {
+ update_box(dynamicbox, node);
+ continue;
+ }
+
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"glancebar")) {
+ update_pd(dynamicbox, node);
+ continue;
+ }
+
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"group")) {
+ update_group(dynamicbox, node);
+ continue;
+ }
+
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"content")) {
+ update_content(dynamicbox, node);
+ continue;
+ }
+
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"setup")) {
+ update_setup(dynamicbox, node);
+ continue;
+ }
+
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"launch")) {
+ update_launch(dynamicbox, node);
+ continue;
+ }
+
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"ui-appid")) {
+ update_ui_appid(dynamicbox, node);
+ continue;
+ }
+
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"category")) {
+ update_category(dynamicbox, node);
+ continue;
+ }
+ }
+
+ return db_insert_dynamicbox(dynamicbox, appid);
+}
+
+static inline int do_uninstall(xmlNodePtr node, const char *appid)
+{
+ xmlChar *pkgid;
+ int ret;
+
+ if (!xmlHasProp(node, (const xmlChar *)"appid")) {
+ ErrPrint("Missing appid\n");
+ return -EINVAL;
+ }
+
+ pkgid = xmlGetProp(node, (const xmlChar *)"appid");
+ if (!validate_pkgid(appid, (char *)pkgid)) {
+ ErrPrint("Invalid package\n");
+ xmlFree(pkgid);
+ return -EINVAL;
+ }
+
+ begin_transaction();
+ ret = db_remove_box_size((char *)pkgid);
+ if (ret < 0) {
+ goto errout;
+ }
+
+ ret = db_remove_i18n((char *)pkgid);
+ if (ret < 0) {
+ goto errout;
+ }
+
+ ret = db_remove_client((char *)pkgid);
+ if (ret < 0) {
+ goto errout;
+ }
+
+ ret = db_remove_provider((char *)pkgid);
+ if (ret < 0) {
+ goto errout;
+ }
+
+ ret = db_remove_option((char *)pkgid);
+ DbgPrint("Remove option: %d\n", ret);
+
+ ret = db_remove_groupmap((char *)pkgid);
+ DbgPrint("Remove groupmap: %d\n", ret);
+
+ ret = db_remove_group((char *)pkgid);
+ if (ret < 0) {
+ goto errout;
+ }
+
+ ret = db_remove_pkgmap((char *)pkgid);
+ if (ret < 0) {
+ goto errout;
+ }
+
+ commit_transaction();
+ xmlFree(pkgid);
+
+ return 0;
+
+errout:
+ rollback_transaction();
+ xmlFree(pkgid);
+ return ret;
+}
+
+static int pkglist_get_via_callback(const char *appid, void (*cb)(const char *appid, const char *pkgid, int prime, void *data), void *data)
+{
+ const char *dml = "SELECT pkgid, prime FROM pkgmap WHERE appid = ?";
+ int ret;
+ sqlite3_stmt *stmt;
+ const char *pkgid;
+ int prime;
+ int cnt = 0;
+
+ if (!cb || !appid || !strlen(appid)) {
+ return -EINVAL;
+ }
+
+ if (!s_info.handle) {
+ if (db_init() < 0) {
+ ErrPrint("Failed to init DB\n");
+ return -EIO;
+ }
+ }
+
+ ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ ErrPrint("Failed to prepare the intial DML(%s)\n", sqlite3_errmsg(s_info.handle));
+ return -EIO;
+ }
+
+ ret = -EIO;
+ if (sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
+ ErrPrint("Failed to bind a cluster - %s\n", sqlite3_errmsg(s_info.handle));
+ goto out;
+ }
+
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ pkgid = (const char *)sqlite3_column_text(stmt, 0);
+ if (!pkgid || !strlen(pkgid)) {
+ continue;
+ }
+
+ prime = sqlite3_column_int(stmt, 1);
+ cb(appid, pkgid, prime, data);
+ cnt++;
+ }
+
+out:
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ return cnt;
+}
+
+static void clear_all_pkg(const char *appid, const char *pkgid, int prime, void *data)
+{
+ int ret;
+
+ ErrPrintWithConsole("Remove old package info: appid(%s), pkgid(%s)\n", appid, pkgid);
+
+ ret = db_remove_box_size((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove box size: %d\n", ret);
+ }
+
+ ret = db_remove_i18n((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove i18n: %d\n", ret);
+ }
+
+ ret = db_remove_client((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove client: %d\n", ret);
+ }
+
+ ret = db_remove_provider((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove provider: %d\n", ret);
+ }
+
+ ret = db_remove_option((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove option: %d\n", ret);
+ }
+
+ ret = db_remove_groupmap((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove groupmap: %d\n", ret);
+ }
+
+ ret = db_remove_group((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove group: %d\n", ret);
+ }
+
+ ret = db_remove_pkgmap((char *)pkgid);
+ if (ret < 0) {
+ ErrPrint("Remove pkgmap: %d\n", ret);
+ }
+}
+
+int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *appid)
+{
+ int cnt;
+
+ ErrPrintWithConsole("%s\n", appid);
+
+ if (!s_info.handle) {
+ if (db_init() < 0) {
+ ErrPrintWithConsole("Failed to init DB\n");
+ return -EIO;
+ }
+ }
+
+ do_upgrade_db_schema();
+
+ begin_transaction();
+ cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
+ commit_transaction();
+
+ if (cnt > 0) {
+ DbgPrint("Package[%s] is not deleted: %d\n", appid, cnt);
+ }
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *appid)
+{
+ ErrPrintWithConsole("[%s]\n", appid);
+ db_fini();
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
+{
+ xmlNodePtr node;
+ int ret;
+
+ ErrPrintWithConsole("[%s]\n", appid);
+
+ if (!s_info.handle) {
+ ErrPrintWithConsole("Failed to init DB\n");
+ return -EIO;
+ }
+
+ node = xmlDocGetRootElement(docPtr);
+ if (!node) {
+ ErrPrintWithConsole("Invalid document\n");
+ return -EINVAL;
+ }
+
+ for (node = node->children; node; node = node->next) {
+ DbgPrint("node->name: %s\n", node->name);
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"dynamicbox")) {
+ ret = do_install(node, appid);
+ if (ret < 0) {
+ DbgPrint("Returns: %d\n", ret);
+ }
+ }
+ }
+
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *appid)
+{
+ int cnt;
+
+ ErrPrintWithConsole("[%s]\n", appid);
+
+ if (!s_info.handle) {
+ if (db_init() < 0) {
+ ErrPrint("Failed to init DB\n");
+ return -EIO;
+ }
+ }
+
+ do_upgrade_db_schema();
+
+ begin_transaction();
+ cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
+ commit_transaction();
+
+ if (cnt > 0) {
+ DbgPrint("Package %s is deleted: %d\n", appid, cnt);
+ }
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *appid)
+{
+ ErrPrintWithConsole("[%s]\n", appid);
+ db_fini();
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
+{
+ xmlNodePtr node;
+ int ret;
+
+ ErrPrintWithConsole("[%s]\n", appid);
+
+ if (!s_info.handle) {
+ ErrPrint("Failed to init DB\n");
+ return -EIO;
+ }
+
+ node = xmlDocGetRootElement(docPtr);
+ if (!node) {
+ ErrPrint("Invalid document\n");
+ return -EINVAL;
+ }
+
+ for (node = node->children; node; node = node->next) {
+ if (!xmlStrcasecmp(node->name, (const xmlChar *)"dynamicbox")) {
+ ret = do_install(node, appid);
+ if (ret < 0) {
+ DbgPrint("Returns: %d\n", ret);
+ }
+ }
+ }
+
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *appid)
+{
+ ErrPrintWithConsole("[%s]\n", appid);
+
+ if (!s_info.handle) {
+ if (db_init() < 0) {
+ ErrPrint("Failed to init DB\n");
+ return -EIO;
+ }
+ }
+
+ do_upgrade_db_schema();
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *appid)
+{
+ int cnt;
+
+ ErrPrintWithConsole("[%s]\n", appid);
+
+ if (!s_info.handle) {
+ return -EIO;
+ }
+
+ begin_transaction();
+ cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
+ commit_transaction();
+
+ if (cnt > 0) {
+ DbgPrint("Package %s is deleted: %d\n", appid, cnt);
+ }
+ db_fini();
+ return 0;
+}
+
+int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
+{
+ ErrPrintWithConsole("[%s]\n", appid);
+ if (!s_info.handle) {
+ return -EIO;
+ }
+ /* Doesn't need to do anything from here, we already dealt it with this */
+ return 0;
+}
+
+/* End of a file */
diff --git a/pkgmgr_livebox/src/service_register.c b/pkgmgr_livebox/src/service_register.c
deleted file mode 100644
index 17e7726..0000000
--- a/pkgmgr_livebox/src/service_register.c
+++ /dev/null
@@ -1,3194 +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 <sys/stat.h>
-#include <unistd.h>
-#include <libgen.h>
-#include <string.h>
-
-#include <sqlite3.h>
-#include <db-util.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <dlog.h>
-
-#include <livebox-service.h>
-
-#include "dlist.h"
-
-#if !defined(FLOG)
-#define DbgPrint(format, arg...) SECURE_LOGD("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
-#define ErrPrint(format, arg...) SECURE_LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
-#define ErrPrintWithConsole(format, arg...) do { fprintf(stderr, "[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); SECURE_LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); } while (0)
-#endif
-
-#define CUR_VER 3
-#define DEFAULT_CATEGORY "http://tizen.org/category/default"
-
-/*!
- * \note
- * DB Table schema
- *
- * version
- * +---------+
- * | version |
- * +---------+
- * | - |
- * +---------+
- * CREATE TABLE version ( version INTEGER )
- *
- *
- * pkgmap
- * +-------+-------+-------+-------+-------------------+
- * | appid | pkgid | uiapp | prime | categ(from ver 2) |
- * +-------+-------+-------+-------+-------------------+
- * | - | - | - | - | - |
- * +-------+-------+-------+-------+-------------------+
- * CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER, category TEXT )
- *
- *
- * provider
- * +-------+---------+-----+---------+----------+---------+-----------+---------+--------+----------+---------+---------+--------+--------+-------+
- * | pkgid | network | abi | secured | box_type | box_src | box_group | pd_type | pd_src | pd_group | libexec | timeout | period | script | pinup |
- * +-------+---------+-----+---------+----------+---------+-----------+---------+--------+----------+---------+---------+--------+--------+-------+
- * | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
- * +-------+---------+-----+---------+----------+---------+-----------+---------+--------+----------+---------+---------+--------+--------+-------+
- * CREATE TABLE provider ( pkgid TEXT PRIMARY KEY NOT NULL, network INTEGER, abi TEXT, secured INTEGER, box_type INTEGER, box_src TEXT, box_group TEXT, pd_type TEXT, pd_src TEXT, pd_group TEXT, libexec TEXT, timeout INTEGER, period TEXT, script TEXT, pinup INTEGER, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid))
- *
- * = box_type = { text | buffer | script | image }
- * = pd_type = { text | buffer | script }
- * = network = { 1 | 0 }
- * = secured = { 1 | 0 }
- *
- *
- * client
- * +-------+------+---------+-------------+---------+---------+-----------+-------+
- * | pkgid | Icon | Name | auto_launch | pd_size | content | nodisplay | setup |
- * +-------+------+---------+-------------+---------+---------+-----------+-------+
- * | - | - | - | - | - | - | - | - |
- * +-------+------+---------+-------------+---------+---------+-----------+-------+
- * CREATE TABLE client ( pkgid TEXT PRIMARY KEY NOT NULL, icon TEXT, name TEXT, auto_launch TEXT, pd_size TEXT, content TEXT, nodisplay INTEGER, setup TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
- *
- * = auto_launch = UI-APPID
- * = pd_size = WIDTHxHEIGHT
- *
- *
- * i18n
- * +-------+------+------+------+
- * | fk | lang | name | icon |
- * +-------+------+------+------+
- * | pkgid | - | - | - |
- * +-------+------+------+------+
- * CREATE TABLE i18n ( pkgid TEXT NOT NULL, lang TEXT COLLATE NOCASE, name TEXT, icon TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
- *
- *
- * box_size
- * +-------+-----------+---------+--------------+------------+-------------------------+
- * | pkgid | size_type | preview | touch_effect | need_frame | mouse_event(from ver 3) |
- * +-------+-----------+---------+--------------+------------+-------------------------+
- * | - | - | - | - | - | - |
- * +-------+-----------+---------+--------------+------------+-------------------------+
- * CREATE TABLE box_size ( pkgid TEXT NOT NULL, size_type INTEGER, preview TEXT, INTEGER, touch_effect INTEGER, need_frame INTEGER, mouse_event INTEGER, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) )
- *
- * = box_size_list = { WIDTHxHEIGHT; WIDTHxHEIGHT; ... }
- *
- * groupinfo
- * +----+---------+----------+-------+
- * | id | cluster | category | pkgid |
- * +----+---------+----------+-------+
- * | - | - | - | - |
- * +----+---------+----------+-------|
- * CREATE TABLE groupinfo ( id INTEGER PRIMARY KEY AUTOINCREMENT, cluster TEXT NOT NULL, category TEXT NOT NULL, appid TEXT NOT NULL, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ))
- *
- * groupmap
- * +-------+----+----------+-----------+
- * | pkgid | id | ctx_item | option_id |
- * +-------+----+----------+-----------+
- * 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) )
- *
- *
- * option
- * +-------+-----------+-----+-------+
- * | pkgid | option_id | key | value |
- * +-------+-----------+-----+-------+
- * 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) )
- */
-
-#if !defined(LIBXML_TREE_ENABLED)
- #error "LIBXML is not supporting the tree"
-#endif
-
-#if defined(LOG_TAG)
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "PKGMGR_LIVEBOX"
-
-int errno;
-
-struct i18n {
- xmlChar *lang;
- xmlChar *name;
- xmlChar *icon;
-};
-
-enum lb_type {
- LB_TYPE_NONE = 0x0,
- LB_TYPE_SCRIPT,
- LB_TYPE_FILE,
- LB_TYPE_TEXT,
- LB_TYPE_BUFFER,
-};
-
-enum pd_type {
- PD_TYPE_NONE = 0x0,
- PD_TYPE_SCRIPT,
- PD_TYPE_TEXT,
- PD_TYPE_BUFFER,
-};
-
-struct livebox {
- xmlChar *pkgid;
- int secured;
- int network;
- xmlChar *auto_launch;
- xmlChar *abi;
- xmlChar *name; /* Default name */
- xmlChar *icon; /* Default icon */
- xmlChar *libexec; /* Path of the SO file */
- xmlChar *timeout; /* INTEGER, timeout */
- xmlChar *period; /* DOUBLE, update period */
- xmlChar *script; /* Script engine */
- xmlChar *content; /* Content information */
- xmlChar *setup;
- xmlChar *uiapp; /* UI App Id */
- xmlChar *category; /* Category of this box */
-
- int pinup; /* Is this support the pinup feature? */
- int primary; /* Is this primary livebox? */
- int nodisplay;
-
- int default_mouse_event; /* Mouse event processing option for livebox */
- int default_touch_effect;
- int default_need_frame;
-
- enum lb_type lb_type;
- xmlChar *lb_src;
- xmlChar *lb_group;
- int size_list; /* 1x1, 2x1, 2x2, 4x1, 4x2, 4x3, 4x4 */
-
- xmlChar *preview[NR_OF_SIZE_LIST];
- int touch_effect[NR_OF_SIZE_LIST]; /* Touch effect of a livebox */
- int need_frame[NR_OF_SIZE_LIST]; /* Box needs frame which should be cared by viewer */
- int mouse_event[NR_OF_SIZE_LIST];
-
- enum pd_type pd_type;
- xmlChar *pd_src;
- xmlChar *pd_group;
- xmlChar *pd_size; /* Default PD size */
-
- struct dlist *i18n_list;
- struct dlist *group_list;
-};
-
-struct group {
- xmlChar *cluster;
- xmlChar *category;
- xmlChar *ctx_item;
- struct dlist *option_list;
-};
-
-struct option {
- xmlChar *key;
- xmlChar *value;
-};
-
-static struct {
- const char *dbfile;
- sqlite3 *handle;
-} s_info = {
- .dbfile = "/opt/dbspace/.livebox.db",
- .handle = NULL,
-};
-
-static inline int begin_transaction(void)
-{
- sqlite3_stmt *stmt;
- int ret;
-
- ret = sqlite3_prepare_v2(s_info.handle, "BEGIN TRANSACTION", -1, &stmt, NULL);
-
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return EXIT_FAILURE;
- }
-
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Failed to do update (%s)\n",
- sqlite3_errmsg(s_info.handle));
- sqlite3_finalize(stmt);
- return EXIT_FAILURE;
- }
-
- sqlite3_finalize(stmt);
- return EXIT_SUCCESS;
-}
-
-static inline int rollback_transaction(void)
-{
- int ret;
- sqlite3_stmt *stmt;
-
- ret = sqlite3_prepare_v2(s_info.handle, "ROLLBACK TRANSACTION", -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return EXIT_FAILURE;
- }
-
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Failed to do update (%s)\n",
- sqlite3_errmsg(s_info.handle));
- sqlite3_finalize(stmt);
- return EXIT_FAILURE;
- }
-
- sqlite3_finalize(stmt);
- return EXIT_SUCCESS;
-}
-
-static inline int commit_transaction(void)
-{
- sqlite3_stmt *stmt;
- int ret;
-
- ret = sqlite3_prepare_v2(s_info.handle, "COMMIT TRANSACTION", -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return EXIT_FAILURE;
- }
-
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Failed to do update (%s)\n",
- sqlite3_errmsg(s_info.handle));
- sqlite3_finalize(stmt);
- return EXIT_FAILURE;
- }
-
- sqlite3_finalize(stmt);
- return EXIT_SUCCESS;
-}
-
-static void db_create_version(void)
-{
- static const char *ddl = "CREATE TABLE version (version INTEGER)";
- char *err;
-
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-}
-
-static int set_version(int version)
-{
- static const char *dml = "INSERT INTO version (version) VALUES (?)";
- sqlite3_stmt *stmt;
- int ret;
-
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) {
- ErrPrint("Failed to bind a id(%s)\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_step(stmt);
- if (ret != SQLITE_DONE) {
- ErrPrint("Failed to execute the DML for version: %d\n", ret);
- ret = -EIO;
- } else {
- ret = 0;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static int update_version(int version)
-{
- static const char *dml = "UPDATE version SET version = ?";
- sqlite3_stmt *stmt;
- int ret;
-
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- if (sqlite3_bind_int(stmt, 1, version) != SQLITE_OK) {
- ErrPrint("Failed to bind a version: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_step(stmt);
- if (ret != SQLITE_DONE) {
- ErrPrint("Failed to execute DML: %d\n", ret);
- ret = -EIO;
- } else {
- ret = 0;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static int get_version(void)
-{
- static const char *dml = "SELECT version FROM version";
- sqlite3_stmt *stmt;
- int ret;
-
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- return -ENOSYS;
- }
-
- if (sqlite3_step(stmt) != SQLITE_ROW) {
- ret = -ENOENT;
- } else {
- ret = sqlite3_column_int(stmt, 0);
- }
-
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-/*!
- * \note
- * From version 1 to 2
- */
-static void upgrade_pkgmap_for_category(void)
-{
- char *err;
- static const char *ddl;
-
- ddl = "ALTER TABLE pkgmap ADD COLUMN category TEXT DEFAULT \"" DEFAULT_CATEGORY "\"";
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- return;
-}
-
-/*!
- * \note
- * From version 2 to 3
- * mouse_event is deleted from client table
- * mouse_event is added to box_size table
- *
- * Every size has their own configuration for mouse_event flag.
- */
-static void upgrade_to_version_3(void)
-{
- char *err;
- static const char *ddl;
- static const char *dml;
- sqlite3_stmt *select_stmt;
- int ret;
-
- /*
- * Step 1
- * Create a new column for mouse_event to box_size table.
- */
- ddl = "ALTER TABLE box_size ADD COLUMN mouse_event INTEGER DEFAULT 0";
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- /*
- * Step 2
- * Copy mouse_event values from the client to the box_size table.
- */
- dml = "SELECT pkgid, mouse_event FROM client";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &select_stmt, NULL);
- if (ret == SQLITE_OK) {
- sqlite3_stmt *update_stmt;
-
- dml = "UPDATE box_size SET mouse_event = ? WHERE pkgid = ?";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &update_stmt, NULL);
- if (ret == SQLITE_OK) {
- int mouse_event;
- const char *pkgid;
-
- while (sqlite3_step(select_stmt) == SQLITE_ROW) {
- pkgid = (const char *)sqlite3_column_text(select_stmt, 0);
- if (!pkgid) {
- ErrPrint("Package Id is not valid\n");
- continue;
- }
-
- mouse_event = sqlite3_column_int(select_stmt, 1);
-
- ret = sqlite3_bind_int(update_stmt, 1, mouse_event);
- if (ret != SQLITE_OK) {
- ErrPrint("Failed to bind mouse_event [%s], [%d]\n", pkgid, mouse_event);
- sqlite3_reset(update_stmt);
- sqlite3_clear_bindings(update_stmt);
- continue;
- }
-
- ret = sqlite3_bind_text(update_stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrint("Failed to bind pkgid [%s], [%d]\n", pkgid, mouse_event);
- sqlite3_reset(update_stmt);
- sqlite3_clear_bindings(update_stmt);
- continue;
- }
-
- ret = sqlite3_step(update_stmt);
- if (ret != SQLITE_DONE) {
- ErrPrint("Failed to execute DML: %d\n", ret);
- sqlite3_reset(update_stmt);
- sqlite3_clear_bindings(update_stmt);
- continue;
- }
-
- sqlite3_reset(update_stmt);
- sqlite3_clear_bindings(update_stmt);
- }
-
- sqlite3_finalize(update_stmt);
- } else {
- ErrPrint("Failed to execute DML\n");
- }
-
- sqlite3_reset(select_stmt);
- sqlite3_clear_bindings(select_stmt);
- sqlite3_finalize(select_stmt);
- } else {
- ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
- }
-
- /*
- * Step 3
- * Drop a column from the client table
- */
- ddl = "ALTER TABLE client DROP COLUMN mouse_event";
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- return;
-}
-
-static void do_upgrade_db_schema(void)
-{
- int version;
-
- version = get_version();
-
- switch (version) {
- case -ENOSYS:
- db_create_version();
- /* Need to create version table */
- case -ENOENT:
- if (set_version(CUR_VER) < 0) {
- ErrPrint("Failed to set version\n");
- }
- /* Need to set version */
- case 1:
- upgrade_pkgmap_for_category();
- case 2:
- upgrade_to_version_3();
- default:
- /* Need to update version */
- DbgPrint("Old version: %d\n", version);
- if (update_version(CUR_VER) < 0) {
- ErrPrint("Failed to update version\n");
- }
- case CUR_VER:
- break;
- }
-}
-
-static inline int db_create_pkgmap(void)
-{
- char *err;
- static const char *ddl;
-
- ddl = "CREATE TABLE pkgmap ( pkgid TEXT PRIMARY KEY NOT NULL, appid TEXT, uiapp TEXT, prime INTEGER, category TEXT )";
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- return 0;
-}
-
-static inline int db_insert_pkgmap(const char *appid, const char *pkgid, const char *uiappid, int primary, const char *category)
-{
- int ret;
- static const char *dml;
- sqlite3_stmt *stmt;
-
- dml = "INSERT INTO pkgmap ( appid, pkgid, uiapp, prime, category ) VALUES (? ,?, ?, ?, ?)";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 3, uiappid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 4, primary);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 5, category, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_remove_pkgmap(const char *pkgid)
-{
- int ret;
- static const char *dml;
- sqlite3_stmt *stmt;
-
- dml = "DELETE FROM pkgmap WHERE pkgid = ?";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_create_provider(void)
-{
- char *err;
- static const char *ddl;
-
- ddl = "CREATE TABLE provider (" \
- "pkgid TEXT PRIMARY KEY NOT NULL, network INTEGER, " \
- "abi TEXT, secured INTEGER, box_type INTEGER, " \
- "box_src TEXT, box_group TEXT, pd_type INTEGER, " \
- "pd_src TEXT, pd_group TEXT, libexec TEXT, timeout INTEGER, period TEXT, script TEXT, pinup INTEGER, "\
- "FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
-
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- return 0;
-}
-
-static inline int db_remove_provider(const char *pkgid)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "DELETE FROM provider WHERE pkgid = ?";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-static int db_insert_provider(struct livebox *livebox)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
- char *abi = (char *)livebox->abi;
- char *box_src = (char *)livebox->lb_src;
- char *box_group = (char *)livebox->lb_group;
- char *pd_src = (char *)livebox->pd_src;
- char *pd_group = (char *)livebox->pd_group;
- char *libexec = (char *)livebox->libexec;
- char *timeout = (char *)livebox->timeout;
- char *period = (char *)livebox->period;
- char *script = (char *)livebox->script;
-
- if (!abi) {
- abi = "c";
- }
-
- if (!timeout) {
- timeout = "10";
- }
-
- if (!period) {
- period = "0.0";
- }
-
- if (!script) {
- script = "edje";
- }
-
- dml = "INSERT INTO provider ( pkgid, network, abi, secured, box_type, box_src, box_group, pd_type, pd_src, pd_group, libexec, timeout, period, script, pinup ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, (char *)livebox->pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 2, livebox->network);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 3, abi, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
- ret = sqlite3_bind_int(stmt, 4, livebox->secured);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 5, livebox->lb_type);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 6, box_src, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 7, box_group, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 8, livebox->pd_type);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 9, pd_src, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 10, pd_group, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 11, libexec, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 12, atoi(timeout));
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 13, period, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 14, script, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 15, livebox->pinup);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_create_client(void)
-{
- char *err;
- static const char *ddl;
-
- ddl = "CREATE TABLE client (" \
- "pkgid TEXT PRIMARY KEY NOT NULL, icon TEXT, name TEXT, " \
- "auto_launch TEXT, pd_size TEXT, content TEXT, nodisplay INTEGER, setup TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- return 0;
-}
-
-static inline int db_insert_client(struct livebox *livebox)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "INSERT INTO client ( pkgid, icon, name, auto_launch, pd_size, content, nodisplay, setup ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, (char *)livebox->pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 2, (char *)livebox->icon, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 3, (char *)livebox->name, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 4, (char *)livebox->auto_launch, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 5, (char *)livebox->pd_size, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 6, (char *)livebox->content, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 7, livebox->nodisplay);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 8, (char *)livebox->setup, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_remove_client(const char *pkgid)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "DELETE FROM client WHERE pkgid = ?";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_create_i18n(void)
-{
- char *err;
- static const char *ddl;
-
- ddl = "CREATE TABLE i18n ( pkgid TEXT NOT NULL, lang TEXT COLLATE NOCASE, name TEXT, " \
- "icon TEXT, FOREIGN KEY(pkgid) REFERENCES pkgmap(pkgid) ON DELETE CASCADE)";
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- return 0;
-}
-
-static inline int db_insert_i18n(const char *pkgid, const char *lang, const char *name, const char *icon)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- DbgPrint("%s - lang[%s] name[%s] icon[%s]\n", pkgid, lang, name, icon);
- dml = "INSERT INTO i18n ( pkgid, lang, name, icon ) VALUES (?, ?, ?, ?)";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 2, lang, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 3, name, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 4, icon, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_remove_i18n(const char *pkgid)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "DELETE FROM i18n WHERE pkgid = ?";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- DbgPrint("No changes\n");
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_create_group(void)
-{
- char *err;
- static const char *ddl;
-
- ddl = "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)";
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- return 0;
-}
-
-static inline int db_insert_group(const char *pkgid, const char *cluster, const char *category)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "INSERT INTO groupinfo ( cluster, category, pkgid ) VALUES (?, ?, ?)";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 3, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static int db_get_group_id(const char *cluster, const char *category)
-{
- static const char *dml = "SELECT id FROM groupinfo WHERE cluster = ? AND category = ?";
- sqlite3_stmt *stmt;
- int ret;
-
- if (!cluster || !category) {
- ErrPrint("Invalid argument\n");
- return -EINVAL;
- }
-
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Failed to prepare the initial DML(%s)\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = -EIO;
- if (sqlite3_bind_text(stmt, 1, cluster, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
- ErrPrint("Failed to bind a cluster(%s) - %s\n", cluster, sqlite3_errmsg(s_info.handle));
- goto out;
- }
-
- if (sqlite3_bind_text(stmt, 2, category, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
- ErrPrint("Failed to bind a category(%s) - %s\n", category, sqlite3_errmsg(s_info.handle));
- goto out;
- }
-
- if (sqlite3_step(stmt) != SQLITE_ROW) {
- ErrPrint("Failed to execute the DML for %s - %s\n", cluster, category);
- goto out;
- }
-
- ret = sqlite3_column_int(stmt, 0);
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_remove_group(const char *pkgid)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "DELETE FROM groupinfo WHERE pkgid = ?";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- DbgPrint("No changes\n");
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_create_groupmap(void)
-{
- char *err;
- static const char *ddl;
-
- ddl = "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)";
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- return 0;
-}
-
-static inline int db_get_option_id(int id, const char *pkgid, const char *ctx_item)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "SELECT option_id FROM groupmap WHERE id = ? AND pkgid = ? AND ctx_item = ?";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_int(stmt, 1, id);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 3, ctx_item, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_ROW) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_column_int(stmt, 0);
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_insert_groupmap(int id, const char *pkgid, const char *ctx_item)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- DbgPrint("%d (%s) add to groupmap\n", id, pkgid);
-
- dml = "INSERT INTO groupmap ( id, pkgid, ctx_item ) VALUES (?, ?, ?)";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_int(stmt, 1, id);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 2, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 3, ctx_item, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_remove_groupmap(const char *pkgid)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "DELETE FROM groupmap WHERE pkgid = ?";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- DbgPrint("No changes\n");
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_create_option(void)
-{
- char *err;
- static const char *ddl;
-
- ddl = "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)";
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- return 0;
-}
-
-static inline int db_insert_option(const char *pkgid, int option_id, const char *key, const char *value)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "INSERT INTO option (pkgid, option_id, key, value) VALUES (?, ?, ?, ?)";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 2, option_id);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 3, key, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 4, value, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_remove_option(const char *pkgid)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "DELETE FROM option WHERE pkgid = ?";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- DbgPrint("No changes\n");
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_create_box_size(void)
-{
- char *err;
- static const char *ddl;
-
- ddl = "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)";
- if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
- ErrPrint("Failed to execute the DDL (%s)\n", err);
- return -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- ErrPrint("No changes to DB\n");
- }
-
- return 0;
-}
-
-static int db_insert_box_size(const char *pkgid, int size_type, const char *preview, int touch_effect, int need_frame, int mouse_event)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- DbgPrint("box size: %s - %d (%s) is added\n", pkgid, size_type, preview);
- dml = "INSERT INTO box_size ( pkgid, size_type, preview, touch_effect, need_frame, mouse_event ) VALUES (?, ?, ?, ?, ?, ?)";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 2, size_type);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_text(stmt, 3, preview, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 4, touch_effect);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 5, need_frame);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = sqlite3_bind_int(stmt, 6, mouse_event);
- if (ret != SQLITE_OK) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline int db_remove_box_size(const char *pkgid)
-{
- static const char *dml;
- int ret;
- sqlite3_stmt *stmt;
-
- dml = "DELETE FROM box_size WHERE pkgid = ?";
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
- if (ret != SQLITE_OK) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- goto out;
- }
-
- ret = 0;
- if (sqlite3_step(stmt) != SQLITE_DONE) {
- DbgPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = -EIO;
- }
-
- if (sqlite3_changes(s_info.handle) == 0) {
- DbgPrint("No changes\n");
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return ret;
-}
-
-static inline void db_create_table(void)
-{
- int ret;
- begin_transaction();
-
- ret = db_create_pkgmap();
- if (ret < 0) {
- rollback_transaction();
- return;
- }
-
- ret = db_create_provider();
- if (ret < 0) {
- rollback_transaction();
- return;
- }
-
- ret = db_create_client();
- if (ret < 0) {
- rollback_transaction();
- return;
- }
-
- ret = db_create_i18n();
- if (ret < 0) {
- rollback_transaction();
- return;
- }
-
- ret = db_create_box_size();
- if (ret < 0) {
- rollback_transaction();
- return;
- }
-
- ret = db_create_group();
- if (ret < 0) {
- rollback_transaction();
- return;
- }
-
- ret = db_create_option();
- if (ret < 0) {
- rollback_transaction();
- return;
- }
-
- ret = db_create_groupmap();
- if (ret < 0) {
- rollback_transaction();
- return;
- }
-
- commit_transaction();
-}
-
-static int db_init(void)
-{
- int ret;
- struct stat stat;
-
- ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD);
- if (ret != SQLITE_OK) {
- ErrPrint("Failed to open a DB\n");
- return -EIO;
- }
-
- if (lstat(s_info.dbfile, &stat) < 0) {
- ErrPrint("%s\n", strerror(errno));
- db_util_close(s_info.handle);
- s_info.handle = NULL;
- return -EIO;
- }
-
- if (!S_ISREG(stat.st_mode)) {
- ErrPrint("Invalid file\n");
- db_util_close(s_info.handle);
- s_info.handle = NULL;
- return -EINVAL;
- }
-
- if (!stat.st_size) {
- db_create_table();
- }
-
- return 0;
-}
-
-static inline int db_fini(void)
-{
- if (!s_info.handle) {
- return 0;
- }
-
- db_util_close(s_info.handle);
- s_info.handle = NULL;
-
- return 0;
-}
-
-static inline int validate_pkgid(const char *appid, const char *pkgid)
-{
- /* Just return 1 Always */
- return 1 || !strncmp(appid, pkgid, strlen(appid));
-}
-
-static int livebox_destroy(struct livebox *livebox)
-{
- struct dlist *l;
- struct dlist *n;
- struct i18n *i18n;
- struct group *group;
- struct option *option;
- struct dlist *il;
- struct dlist *in;
-
- xmlFree(livebox->auto_launch);
- xmlFree(livebox->pkgid);
- xmlFree(livebox->abi);
- xmlFree(livebox->name);
- xmlFree(livebox->icon);
- xmlFree(livebox->lb_src);
- xmlFree(livebox->lb_group);
- xmlFree(livebox->pd_src);
- xmlFree(livebox->pd_group);
- xmlFree(livebox->pd_size);
- xmlFree(livebox->libexec);
- xmlFree(livebox->script);
- xmlFree(livebox->period);
- xmlFree(livebox->content);
- xmlFree(livebox->setup);
- xmlFree(livebox->category);
- xmlFree(livebox->preview[0]); /* 1x1 */
- xmlFree(livebox->preview[1]); /* 2x1 */
- xmlFree(livebox->preview[2]); /* 2x2 */
- xmlFree(livebox->preview[3]); /* 4x1 */
- xmlFree(livebox->preview[4]); /* 4x2 */
- xmlFree(livebox->preview[5]); /* 4x3 */
- xmlFree(livebox->preview[6]); /* 4x4 */
- xmlFree(livebox->preview[7]); /* 4x5 */
- xmlFree(livebox->preview[8]); /* 4x6 */
- xmlFree(livebox->preview[9]); /* easy 1x1 */
- xmlFree(livebox->preview[10]); /* easy 3x1 */
- xmlFree(livebox->preview[11]); /* easy 3x3 */
- xmlFree(livebox->preview[12]); /* full */
-
- dlist_foreach_safe(livebox->i18n_list, l, n, i18n) {
- livebox->i18n_list = dlist_remove(livebox->i18n_list, l);
- xmlFree(i18n->name);
- xmlFree(i18n->icon);
- xmlFree(i18n->lang);
- free(i18n);
- }
-
- dlist_foreach_safe(livebox->group_list, l, n, group) {
- livebox->group_list = dlist_remove(livebox->group_list, l);
- DbgPrint("Release %s/%s\n", group->cluster, group->category);
-
- if (group->ctx_item) {
- dlist_foreach_safe(group->option_list, il, in, option) {
- group->option_list = dlist_remove(group->option_list, il);
- DbgPrint("Release option %s(%s)\n", option->key, option->value);
- xmlFree(option->key);
- xmlFree(option->value);
- free(option);
- }
- xmlFree(group->ctx_item);
- }
-
- xmlFree(group->cluster);
- xmlFree(group->category);
- free(group);
- }
-
- free(livebox);
- return 0;
-}
-
-static inline void update_i18n_name(struct livebox *livebox, xmlNodePtr node)
-{
- struct i18n *i18n;
- struct dlist *l;
- xmlChar *lang;
- xmlChar *name;
-
- name = xmlNodeGetContent(node);
- if (!name) {
- ErrPrint("Invalid tag\n");
- return;
- }
-
- lang = xmlNodeGetLang(node);
- if (!lang) {
- if (livebox->name) {
- DbgPrint("Override default name: %s\n", livebox->name);
- xmlFree(livebox->name);
- }
-
- livebox->name = name;
- return;
- }
-
- dlist_foreach(livebox->i18n_list, l, i18n) {
- if (!xmlStrcasecmp(i18n->lang, lang)) {
- if (i18n->name) {
- DbgPrint("Override name: %s\n", i18n->name);
- xmlFree(i18n->name);
- }
-
- i18n->name = name;
- return;
- }
- }
-
- i18n = calloc(1, sizeof(*i18n));
- if (!i18n) {
- ErrPrint("Heap: %s\n", strerror(errno));
- xmlFree(name);
- xmlFree(lang);
- return;
- }
-
- i18n->name = name;
- i18n->lang = lang;
- DbgPrint("Label[%s] - [%s] added\n", i18n->lang, i18n->name);
- livebox->i18n_list = dlist_append(livebox->i18n_list, i18n);
-}
-
-static inline void update_i18n_icon(struct livebox *livebox, xmlNodePtr node)
-{
- struct i18n *i18n;
- struct dlist *l;
- xmlChar *lang;
- xmlChar *icon;
-
- icon = xmlNodeGetContent(node);
- if (!icon) {
- ErrPrint("Invalid tag\n");
- return;
- }
-
- lang = xmlNodeGetLang(node);
- if (!lang) {
- if (livebox->icon) {
- DbgPrint("Override default icon: %s\n", livebox->icon);
- xmlFree(livebox->icon);
- }
-
- livebox->icon = icon;
- return;
- }
-
- dlist_foreach(livebox->i18n_list, l, i18n) {
- if (!xmlStrcasecmp(i18n->lang, lang)) {
- if (i18n->icon) {
- DbgPrint("Override icon %s for %s\n", i18n->icon, i18n->name);
- xmlFree(i18n->icon);
- }
-
- i18n->icon = icon;
- return;
- }
- }
-
- i18n = calloc(1, sizeof(*i18n));
- if (!i18n) {
- ErrPrint("Heap: %s\n", strerror(errno));
- xmlFree(icon);
- xmlFree(lang);
- return;
- }
-
- i18n->icon = icon;
- i18n->lang = lang;
- DbgPrint("Icon[%s] - [%s] added\n", i18n->lang, i18n->icon);
- livebox->i18n_list = dlist_append(livebox->i18n_list, i18n);
-}
-
-static inline void update_launch(struct livebox *livebox, xmlNodePtr node)
-{
- xmlChar *launch;
-
- launch = xmlNodeGetContent(node);
- if (!launch) {
- DbgPrint("Has no launch\n");
- return;
- }
-
- if (livebox->auto_launch) {
- xmlFree(livebox->auto_launch);
- }
-
- livebox->auto_launch = xmlStrdup(launch);
- if (!livebox->auto_launch) {
- ErrPrint("Failed to duplicate string: %s\n", (char *)launch);
- return;
- }
-}
-
-static inline void update_category(struct livebox *livebox, xmlNodePtr node)
-{
- xmlChar *category;
- category = xmlNodeGetContent(node);
- if (!category) {
- DbgPrint("Has no valid category\n");
- return;
- }
-
- if (livebox->category) {
- xmlFree(livebox->category);
- }
-
- livebox->category = xmlStrdup(category);
- if (!livebox->category) {
- ErrPrint("Failed to duplicate string: %s\n", (char *)category);
- return;
- }
-}
-
-static inline void update_ui_appid(struct livebox *livebox, xmlNodePtr node)
-{
- xmlChar *uiapp;
- uiapp = xmlNodeGetContent(node);
- if (!uiapp) {
- DbgPrint("Has no valid ui-appid\n");
- return;
- }
-
- if (livebox->uiapp) {
- xmlFree(livebox->uiapp);
- }
-
- livebox->uiapp = xmlStrdup(uiapp);
- if (!livebox->uiapp) {
- ErrPrint("Failed to duplicate string: %s\n", (char *)uiapp);
- return;
- }
-}
-
-static inline void update_setup(struct livebox *livebox, xmlNodePtr node)
-{
- xmlChar *setup;
- setup = xmlNodeGetContent(node);
- if (!setup) {
- DbgPrint("Has no setup\n");
- return;
- }
-
- if (livebox->setup) {
- xmlFree(livebox->setup);
- }
-
- livebox->setup = xmlStrdup(setup);
- if (!livebox->setup) {
- ErrPrint("Failed to duplicate string: %s\n", (char *)setup);
- return;
- }
-}
-
-static inline void update_content(struct livebox *livebox, xmlNodePtr node)
-{
- xmlChar *content;
- content = xmlNodeGetContent(node);
- if (!content) {
- DbgPrint("Has no content\n");
- return;
- }
-
- if (livebox->content) {
- xmlFree(livebox->content);
- }
-
- livebox->content = xmlStrdup(content);
- if (!livebox->content) {
- ErrPrint("Failed to duplicate string: %s\n", (char *)content);
- return;
- }
-}
-
-static void update_size_info(struct livebox *livebox, int idx, xmlNodePtr node)
-{
- if (xmlHasProp(node, (const xmlChar *)"preview")) {
- livebox->preview[idx] = xmlGetProp(node, (const xmlChar *)"preview");
- }
-
- if (xmlHasProp(node, (const xmlChar *)"need_frame")) {
- xmlChar *need_frame;
-
- need_frame = xmlGetProp(node, (const xmlChar *)"need_frame");
- if (need_frame) {
- livebox->need_frame[idx] = !xmlStrcasecmp(need_frame, (const xmlChar *)"true");
- xmlFree(need_frame);
- } else {
- livebox->need_frame[idx] = livebox->default_need_frame;
- }
- } else {
- livebox->need_frame[idx] = livebox->default_need_frame;
- }
-
- if (xmlHasProp(node, (const xmlChar *)"touch_effect")) {
- xmlChar *touch_effect;
-
- touch_effect = xmlGetProp(node, (const xmlChar *)"touch_effect");
- if (touch_effect) {
- livebox->touch_effect[idx] = !xmlStrcasecmp(touch_effect, (const xmlChar *)"true");
- xmlFree(touch_effect);
- } else {
- livebox->touch_effect[idx] = livebox->default_touch_effect;
- }
- } else {
- livebox->touch_effect[idx] = livebox->default_touch_effect;
- }
-
- if (xmlHasProp(node, (const xmlChar *)"mouse_event")) {
- xmlChar *mouse_event;
-
- mouse_event = xmlGetProp(node, (const xmlChar *)"mouse_event");
- if (mouse_event) {
- livebox->mouse_event[idx] = !xmlStrcasecmp(mouse_event, (const xmlChar *)"true");
- xmlFree(mouse_event);
- } else {
- livebox->mouse_event[idx] = livebox->default_mouse_event;
- }
- } else {
- livebox->mouse_event[idx] = livebox->default_mouse_event;
- }
-}
-
-static inline void update_box(struct livebox *livebox, xmlNodePtr node)
-{
- if (!xmlHasProp(node, (const xmlChar *)"type")) {
- livebox->lb_type = LB_TYPE_FILE;
- } else {
- xmlChar *type;
-
- type = xmlGetProp(node, (const xmlChar *)"type");
- if (!type) {
- ErrPrint("Type is NIL\n");
- livebox->lb_type = LB_TYPE_FILE;
- } else {
- if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
- livebox->lb_type = LB_TYPE_TEXT;
- } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
- livebox->lb_type = LB_TYPE_BUFFER;
- } else if (!xmlStrcasecmp(type, (const xmlChar *)"script")) {
- livebox->lb_type = LB_TYPE_SCRIPT;
- } else { /* Default */
- livebox->lb_type = LB_TYPE_FILE;
- }
-
- xmlFree(type);
- }
- }
-
- if (!xmlHasProp(node, (const xmlChar *)"mouse_event")) {
- livebox->default_mouse_event = 0;
- } else {
- xmlChar *mouse_event;
-
- mouse_event = xmlGetProp(node, (const xmlChar *)"mouse_event");
- if (!mouse_event) {
- ErrPrint("mouse_event is NIL\n");
- livebox->default_mouse_event = 0;
- } else {
- livebox->default_mouse_event = !xmlStrcasecmp(mouse_event, (const xmlChar *)"true");
- xmlFree(mouse_event);
- }
- }
-
- if (!xmlHasProp(node, (const xmlChar *)"touch_effect")) {
- livebox->default_touch_effect = 1;
- } else {
- xmlChar *touch_effect;
-
- touch_effect = xmlGetProp(node, (const xmlChar *)"touch_effect");
- if (!touch_effect) {
- ErrPrint("default touch_effect is NIL\n");
- livebox->default_touch_effect = 1;
- } else {
- livebox->default_touch_effect = !xmlStrcasecmp(touch_effect, (const xmlChar *)"true");
- xmlFree(touch_effect);
- }
- }
-
- if (!xmlHasProp(node, (const xmlChar *)"need_frame")) {
- livebox->default_need_frame = 0;
- } else {
- xmlChar *need_frame;
-
- need_frame = xmlGetProp(node, (const xmlChar *)"need_frame");
- if (!need_frame) {
- ErrPrint("default need_frame is NIL\n");
- livebox->default_need_frame = 0;
- } else {
- livebox->default_need_frame = !xmlStrcasecmp(need_frame, (const xmlChar *)"true");
- xmlFree(need_frame);
- }
- }
-
- for (node = node->children; node; node = node->next) {
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"size")) {
- xmlChar *size;
- int is_easy = 0;
-
- size = xmlNodeGetContent(node);
- if (!size) {
- ErrPrint("Invalid size tag\n");
- continue;
- }
-
- if (xmlHasProp(node, (const xmlChar *)"mode")) {
- xmlChar *mode;
- mode = xmlGetProp(node, (const xmlChar *)"mode");
- if (mode) {
- DbgPrint("Easy mode: %s\n", mode);
- is_easy = !xmlStrcasecmp(mode, (const xmlChar *)"easy");
- xmlFree(mode);
- }
- }
-
- if (!xmlStrcasecmp(size, (const xmlChar *)"1x1")) {
- if (is_easy) {
- livebox->size_list |= LB_SIZE_TYPE_EASY_1x1;
- update_size_info(livebox, 9, node);
- } else {
- livebox->size_list |= LB_SIZE_TYPE_1x1;
- update_size_info(livebox, 0, node);
- }
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"3x1")) {
- if (is_easy) {
- livebox->size_list |= LB_SIZE_TYPE_EASY_3x1;
- update_size_info(livebox, 10, node);
- } else {
- ErrPrint("Invalid size tag (%s)\n", size);
- }
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"3x3")) {
- if (is_easy) {
- livebox->size_list |= LB_SIZE_TYPE_EASY_3x3;
- update_size_info(livebox, 11, node);
- } else {
- ErrPrint("Invalid size tag (%s)\n", size);
- }
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"2x1")) {
- livebox->size_list |= LB_SIZE_TYPE_2x1;
- update_size_info(livebox, 1, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"2x2")) {
- livebox->size_list |= LB_SIZE_TYPE_2x2;
- update_size_info(livebox, 2, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x1")) {
- livebox->size_list |= LB_SIZE_TYPE_4x1;
- update_size_info(livebox, 3, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x2")) {
- livebox->size_list |= LB_SIZE_TYPE_4x2;
- update_size_info(livebox, 4, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x3")) {
- livebox->size_list |= LB_SIZE_TYPE_4x3;
- update_size_info(livebox, 5, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x4")) {
- livebox->size_list |= LB_SIZE_TYPE_4x4;
- update_size_info(livebox, 6, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x5")) {
- livebox->size_list |= LB_SIZE_TYPE_4x5;
- update_size_info(livebox, 7, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x6")) {
- livebox->size_list |= LB_SIZE_TYPE_4x6;
- update_size_info(livebox, 8, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"21x21")) {
- livebox->size_list |= LB_SIZE_TYPE_EASY_1x1;
- update_size_info(livebox, 9, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"23x21")) {
- livebox->size_list |= LB_SIZE_TYPE_EASY_3x1;
- update_size_info(livebox, 10, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"23x23")) {
- livebox->size_list |= LB_SIZE_TYPE_EASY_3x3;
- update_size_info(livebox, 11, node);
- } else if (!xmlStrcasecmp(size, (const xmlChar *)"0x0")) {
- livebox->size_list |= LB_SIZE_TYPE_0x0;
- update_size_info(livebox, 12, node);
- } else {
- ErrPrint("Invalid size tag (%s)\n", size);
- }
-
- xmlFree(size);
- } else if (!xmlStrcasecmp(node->name, (const xmlChar *)"script")) {
- xmlChar *src;
-
- if (!xmlHasProp(node, (const xmlChar *)"src")) {
- ErrPrint("Invalid script tag. has no src\n");
- continue;
- }
-
- src = xmlGetProp(node, (const xmlChar *)"src");
- if (!src) {
- ErrPrint("Invalid script tag. src is NIL\n");
- continue;
- }
-
- if (livebox->lb_src) {
- DbgPrint("Override lb src: %s\n", livebox->lb_src);
- xmlFree(livebox->lb_src);
- }
-
- livebox->lb_src = src;
-
- if (xmlHasProp(node, (const xmlChar *)"group")) {
- xmlChar *group;
- group = xmlGetProp(node, (const xmlChar *)"group");
- if (!group) {
- ErrPrint("Group is NIL\n");
- } else {
- if (livebox->lb_group) {
- DbgPrint("Override lb group: %s\n", livebox->lb_group);
- xmlFree(livebox->lb_group);
- }
-
- livebox->lb_group = group;
- }
- }
- }
- }
-}
-
-static inline void update_group(struct livebox *livebox, xmlNodePtr node)
-{
- xmlNodePtr cluster;
- xmlNodePtr category;
- xmlNodePtr option_item;
- xmlChar *cluster_name;
- xmlChar *category_name;
- xmlChar *ctx_item;
-
- xmlChar *key;
- xmlChar *value;
-
- struct group *group;
- struct option *option;
-
- cluster = node;
- for (cluster = cluster->children; cluster; cluster = cluster->next) {
- if (xmlStrcasecmp(cluster->name, (const xmlChar *)"cluster")) {
- DbgPrint("Skip: %s\n", cluster->name);
- continue;
- }
-
- if (!xmlHasProp(cluster, (const xmlChar *)"name")) {
- ErrPrint("Invalid cluster, has no name\n");
- continue;
- }
-
- cluster_name = xmlGetProp(cluster, (const xmlChar *)"name");
- if (!cluster_name) {
- ErrPrint("Invalid cluster name. NIL\n");
- continue;
- }
-
- for (category = cluster->children; category; category = category->next) {
- if (xmlStrcasecmp(category->name, (const xmlChar *)"category")) {
- DbgPrint("Skip: %s\n", category->name);
- continue;
- }
-
- if (!xmlHasProp(category, (const xmlChar *)"name")) {
- ErrPrint("Invalid category, has no name\n");
- continue;
- }
-
- category_name = xmlGetProp(category, (const xmlChar *)"name");
- if (!category_name) {
- ErrPrint("Invalid category name. NIL\n");
- continue;
- }
-
- group = calloc(1, sizeof(*group));
- if (!group) {
- ErrPrint("Heap: %s\n", strerror(errno));
- xmlFree(category_name);
- continue;
- }
-
- group->cluster = xmlStrdup(cluster_name);
- if (!group->cluster) {
- ErrPrint("Heap: %s\n", strerror(errno));
- xmlFree(category_name);
- free(group);
- continue;
- }
-
- group->category = category_name;
- livebox->group_list = dlist_append(livebox->group_list, group);
-
- if (!xmlHasProp(category, (const xmlChar *)"context")) {
- DbgPrint("%s, %s has no ctx info\n", group->cluster, group->category);
- continue;
- }
-
- ctx_item = xmlGetProp(category, (const xmlChar *)"context");
- if (!ctx_item) {
- ErrPrint("Failed to get context ID (%s, %s)\n", group->cluster, group->category);
- continue;
- }
-
- group->ctx_item = ctx_item;
- DbgPrint("Build group item: %s - %s - %s\n", group->cluster, group->category, group->ctx_item);
-
- for (option_item = category->children; option_item; option_item = option_item->next) {
- if (xmlStrcasecmp(option_item->name, (const xmlChar *)"option")) {
- DbgPrint("Skip: %s\n", option_item->name);
- continue;
- }
-
- if (!xmlHasProp(option_item, (const xmlChar *)"key")) {
- ErrPrint("Invalid option, has no key\n");
- continue;
- }
-
- if (!xmlHasProp(option_item, (const xmlChar *)"value")) {
- ErrPrint("Invalid option, has no value\n");
- continue;
- }
-
- key = xmlGetProp(option_item, (const xmlChar *)"key");
- if (!key) {
- ErrPrint("Invalid key. NIL\n");
- continue;
- }
-
- value = xmlGetProp(option_item, (const xmlChar *)"value");
- if (!value) {
- ErrPrint("Invalid valid. NIL\n");
- xmlFree(key);
- continue;
- }
-
- option = calloc(1, sizeof(*option));
- if (!option) {
- ErrPrint("Heap: %s\n", strerror(errno));
- xmlFree(key);
- xmlFree(value);
- continue;
- }
-
- option->key = key;
- option->value = value;
-
- group->option_list = dlist_append(group->option_list, option);
- }
- }
-
- xmlFree(cluster_name);
- }
-}
-
-static inline void update_pd(struct livebox *livebox, xmlNodePtr node)
-{
- if (!xmlHasProp(node, (const xmlChar *)"type")) {
- livebox->pd_type = PD_TYPE_SCRIPT;
- } else {
- xmlChar *type;
-
- type = xmlGetProp(node, (const xmlChar *)"type");
- if (!type) {
- ErrPrint("type is NIL\n");
- return;
- }
-
- if (!xmlStrcasecmp(type, (const xmlChar *)"text")) {
- livebox->pd_type = PD_TYPE_TEXT;
- } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) {
- livebox->pd_type = PD_TYPE_BUFFER;
- } else {
- livebox->pd_type = PD_TYPE_SCRIPT;
- }
-
- xmlFree(type);
- }
-
- for (node = node->children; node; node = node->next) {
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"size")) {
- xmlChar *size;
-
- size = xmlNodeGetContent(node);
- if (!size) {
- ErrPrint("Invalid size tag\n");
- continue;
- }
-
- if (livebox->pd_size) {
- DbgPrint("Override pd size: %s\n", livebox->pd_size);
- xmlFree(livebox->pd_size);
- }
- livebox->pd_size = size;
- } else if (!xmlStrcasecmp(node->name, (const xmlChar *)"script")) {
- xmlChar *src;
-
- if (!xmlHasProp(node, (const xmlChar *)"src")) {
- ErrPrint("Invalid script tag, has no src\n");
- continue;
- }
-
- src = xmlGetProp(node, (const xmlChar *)"src");
- if (!src) {
- ErrPrint("src is NIL\n");
- continue;
- }
-
- if (livebox->pd_src) {
- DbgPrint("Overide PD src: %s\n", livebox->pd_src);
- xmlFree(livebox->pd_src);
- }
-
- livebox->pd_src = src;
-
- if (xmlHasProp(node, (const xmlChar *)"group")) {
- xmlChar *group;
- group = xmlGetProp(node, (const xmlChar *)"group");
- if (!group) {
- ErrPrint("Group is NIL\n");
- } else {
- if (livebox->pd_group) {
- DbgPrint("Override PD group : %s\n", livebox->pd_group);
- xmlFree(livebox->pd_group);
- }
-
- livebox->pd_group = group;
- }
- }
- }
- }
-}
-
-static int db_insert_livebox(struct livebox *livebox, const char *appid)
-{
- struct dlist *l;
- struct dlist *il;
- struct i18n *i18n;
- struct group *group;
- int ret;
- int id;
- struct option *option;
-
- begin_transaction();
- ret = db_insert_pkgmap(appid, (char *)livebox->pkgid, (char *)livebox->uiapp, livebox->primary, (char *)livebox->category);
- if (ret < 0) {
- goto errout;
- }
-
- ret = db_insert_provider(livebox);
- if (ret < 0) {
- goto errout;
- }
-
- ret = db_insert_client(livebox);
- if (ret < 0) {
- goto errout;
- }
-
- dlist_foreach(livebox->i18n_list, l, i18n) {
- ret = db_insert_i18n((char *)livebox->pkgid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_1x1) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_1x1, (char *)livebox->preview[0], livebox->touch_effect[0], livebox->need_frame[0], livebox->mouse_event[0]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_2x1) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_2x1, (char *)livebox->preview[1], livebox->touch_effect[1], livebox->need_frame[1], livebox->mouse_event[1]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_2x2) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_2x2, (char *)livebox->preview[2], livebox->touch_effect[2], livebox->need_frame[2], livebox->mouse_event[2]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_4x1) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x1, (char *)livebox->preview[3], livebox->touch_effect[3], livebox->need_frame[3], livebox->mouse_event[3]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_4x2) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x2, (char *)livebox->preview[4], livebox->touch_effect[4], livebox->need_frame[4], livebox->mouse_event[4]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_4x3) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x3, (char *)livebox->preview[5], livebox->touch_effect[5], livebox->need_frame[5], livebox->mouse_event[5]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_4x4) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x4, (char *)livebox->preview[6], livebox->touch_effect[6], livebox->need_frame[6], livebox->mouse_event[6]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_4x5) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x5, (char *)livebox->preview[7], livebox->touch_effect[7], livebox->need_frame[7], livebox->mouse_event[7]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_4x6) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_4x6, (char *)livebox->preview[8], livebox->touch_effect[8], livebox->need_frame[8], livebox->mouse_event[8]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_EASY_1x1) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_EASY_1x1, (char *)livebox->preview[9], livebox->touch_effect[9], livebox->need_frame[9], livebox->mouse_event[9]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_EASY_3x1) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_EASY_3x1, (char *)livebox->preview[10], livebox->touch_effect[10], livebox->need_frame[10], livebox->mouse_event[10]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_EASY_3x3) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_EASY_3x3, (char *)livebox->preview[11], livebox->touch_effect[11], livebox->need_frame[11], livebox->mouse_event[11]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- if (livebox->size_list & LB_SIZE_TYPE_0x0) {
- ret = db_insert_box_size((char *)livebox->pkgid, LB_SIZE_TYPE_0x0, (char *)livebox->preview[12], livebox->touch_effect[12], livebox->need_frame[12], livebox->mouse_event[12]);
- if (ret < 0) {
- goto errout;
- }
- }
-
- dlist_foreach(livebox->group_list, l, group) {
- /* group ID "id" */
- id = db_get_group_id((char *)group->cluster, (char *)group->category);
- if (id < 0) {
- int ret;
-
- ret = db_insert_group((char *)livebox->pkgid, (char *)group->cluster, (char *)group->category);
- if (ret < 0) {
- ErrPrint("[%s]-[%s] is not exists\n", group->cluster, group->category);
- continue;
- }
-
- DbgPrint("New group name is built - %s/%s\n", group->cluster, group->category);
- id = db_get_group_id((char *)group->cluster, (char *)group->category);
- if (id < 0) {
- ErrPrint("Failed to get group id for %s/%s\n", group->cluster, group->category);
- continue;
- }
- }
-
- if (!group->ctx_item) {
- DbgPrint("%s, %s - has no ctx info\n", group->cluster, group->category);
- continue;
- }
-
- ret = db_insert_groupmap(id, (char *)livebox->pkgid, (char *)group->ctx_item);
- if (ret < 0) {
- goto errout;
- }
-
- /* REUSE "id" from here , option ID */
- id = db_get_option_id(id, (char *)livebox->pkgid, (char *)group->ctx_item);
- if (id < 0) {
- goto errout;
- }
-
- dlist_foreach(group->option_list, il, option) {
- ret = db_insert_option((char *)livebox->pkgid, id, (char *)option->key, (char *)option->value);
- if (ret < 0) {
- goto errout;
- }
- }
- }
-
- commit_transaction();
- livebox_destroy(livebox);
- return 0;
-
-errout:
- ErrPrint("ROLLBACK\n");
- rollback_transaction();
- livebox_destroy(livebox);
- return ret;
-}
-
-static int do_install(xmlNodePtr node, const char *appid)
-{
- struct livebox *livebox;
- xmlChar *pkgid;
- xmlChar *tmp;
-
- if (!xmlHasProp(node, (const xmlChar *)"appid")) {
- ErrPrint("Missing appid\n");
- return -EINVAL;
- }
-
- pkgid = xmlGetProp(node, (const xmlChar *)"appid");
- if (!pkgid || !validate_pkgid(appid, (char *)pkgid)) {
- ErrPrint("Invalid appid\n");
- xmlFree(pkgid);
- return -EINVAL;
- }
-
- DbgPrint("appid: %s\n", (char *)pkgid);
-
- livebox = calloc(1, sizeof(*livebox));
- if (!livebox) {
- ErrPrint("Heap: %s\n", strerror(errno));
- xmlFree(pkgid);
- return -ENOMEM;
- }
-
- livebox->pkgid = pkgid;
-
- if (xmlHasProp(node, (const xmlChar *)"primary")) {
- tmp = xmlGetProp(node, (const xmlChar *)"primary");
- livebox->primary = !xmlStrcasecmp(tmp, (const xmlChar *)"true");
- xmlFree(tmp);
- }
-
- if (xmlHasProp(node, (const xmlChar *)"script")) {
- livebox->script = xmlGetProp(node, (const xmlChar *)"script");
- if (!livebox->script) {
- ErrPrint("script is NIL\n");
- }
- }
-
- if (xmlHasProp(node, (const xmlChar *)"nodisplay")) {
- tmp = xmlGetProp(node, (const xmlChar *)"nodisplay");
- livebox->nodisplay = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
- xmlFree(tmp);
- }
-
- if (xmlHasProp(node, (const xmlChar *)"pinup")) {
- tmp = xmlGetProp(node, (const xmlChar *)"pinup");
- livebox->pinup = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
- xmlFree(tmp);
- }
-
- if (xmlHasProp(node, (const xmlChar *)"period")) {
- livebox->period = xmlGetProp(node, (const xmlChar *)"period");
- if (!livebox->period) {
- ErrPrint("Period is NIL\n");
- }
- }
-
- if (xmlHasProp(node, (const xmlChar *)"timeout")) {
- livebox->timeout = xmlGetProp(node, (const xmlChar *)"timeout");
- if (!livebox->timeout) {
- ErrPrint("Timeout is NIL\n");
- }
- }
-
- if (xmlHasProp(node, (const xmlChar *)"secured")) {
- tmp = xmlGetProp(node, (const xmlChar *)"secured");
- livebox->secured = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
- xmlFree(tmp);
- }
-
- if (xmlHasProp(node, (const xmlChar *)"network")) {
- tmp = xmlGetProp(node, (const xmlChar *)"network");
- livebox->network = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true");
- xmlFree(tmp);
- }
-
- if (xmlHasProp(node, (const xmlChar *)"abi")) {
- livebox->abi = xmlGetProp(node, (const xmlChar *)"abi");
- if (!livebox->abi) {
- ErrPrint("ABI is NIL\n");
- livebox_destroy(livebox);
- return -EFAULT;
- }
- } else {
- livebox->abi = xmlStrdup((const xmlChar *)"c");
- if (!livebox->abi) {
- ErrPrint("Heap: %s\n", strerror(errno));
- livebox_destroy(livebox);
- return -ENOMEM;
- }
- }
-
- if (xmlHasProp(node, (const xmlChar *)"libexec")) {
- livebox->libexec = xmlGetProp(node, (const xmlChar *)"libexec");
- if (!livebox->libexec) {
- ErrPrint("libexec is NIL\n");
- livebox_destroy(livebox);
- return -EFAULT;
- }
- } else if (!xmlStrcasecmp(livebox->abi, (const xmlChar *)"c") || !xmlStrcasecmp(livebox->abi, (const xmlChar *)"cpp")) {
- char *filename;
- int len;
-
- len = strlen((char *)livebox->pkgid) + strlen("/libexec/liblive-.so") + 1;
-
- filename = malloc(len);
- if (!filename) {
- livebox_destroy(livebox);
- return -ENOMEM;
- }
-
- snprintf(filename, len, "/libexec/liblive-%s.so", livebox->pkgid);
- livebox->libexec = xmlStrdup((xmlChar *)filename);
- DbgPrint("Use the default libexec: %s\n", filename);
- free(filename);
-
- if (!livebox->libexec) {
- livebox_destroy(livebox);
- return -ENOMEM;
- }
- }
-
- for (node = node->children; node; node = node->next) {
- if (!xmlStrcmp(node->name, (const xmlChar *)"text")) {
- continue;
- }
-
- DbgPrint("Nodename: %s\n", node->name);
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"label")) {
- update_i18n_name(livebox, node);
- continue;
- }
-
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"icon")) {
- update_i18n_icon(livebox, node);
- continue;
- }
-
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"box")) {
- update_box(livebox, node);
- continue;
- }
-
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"pd")) {
- update_pd(livebox, node);
- continue;
- }
-
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"group")) {
- update_group(livebox, node);
- continue;
- }
-
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"content")) {
- update_content(livebox, node);
- continue;
- }
-
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"setup")) {
- update_setup(livebox, node);
- continue;
- }
-
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"launch")) {
- update_launch(livebox, node);
- continue;
- }
-
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"ui-appid")) {
- update_ui_appid(livebox, node);
- continue;
- }
-
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"category")) {
- update_category(livebox, node);
- continue;
- }
- }
-
- return db_insert_livebox(livebox, appid);
-}
-
-static inline int do_uninstall(xmlNodePtr node, const char *appid)
-{
- xmlChar *pkgid;
- int ret;
-
- if (!xmlHasProp(node, (const xmlChar *)"appid")) {
- ErrPrint("Missing appid\n");
- return -EINVAL;
- }
-
- pkgid = xmlGetProp(node, (const xmlChar *)"appid");
- if (!validate_pkgid(appid, (char *)pkgid)) {
- ErrPrint("Invalid package\n");
- xmlFree(pkgid);
- return -EINVAL;
- }
-
- begin_transaction();
- ret = db_remove_box_size((char *)pkgid);
- if (ret < 0) {
- goto errout;
- }
-
- ret = db_remove_i18n((char *)pkgid);
- if (ret < 0) {
- goto errout;
- }
-
- ret = db_remove_client((char *)pkgid);
- if (ret < 0) {
- goto errout;
- }
-
- ret = db_remove_provider((char *)pkgid);
- if (ret < 0) {
- goto errout;
- }
-
- ret = db_remove_option((char *)pkgid);
- DbgPrint("Remove option: %d\n", ret);
-
- ret = db_remove_groupmap((char *)pkgid);
- DbgPrint("Remove groupmap: %d\n", ret);
-
- ret = db_remove_group((char *)pkgid);
- if (ret < 0) {
- goto errout;
- }
-
- ret = db_remove_pkgmap((char *)pkgid);
- if (ret < 0) {
- goto errout;
- }
-
- commit_transaction();
- xmlFree(pkgid);
-
- return 0;
-
-errout:
- rollback_transaction();
- xmlFree(pkgid);
- return ret;
-}
-
-static int pkglist_get_via_callback(const char *appid, void (*cb)(const char *appid, const char *pkgid, int prime, void *data), void *data)
-{
- const char *dml = "SELECT pkgid, prime FROM pkgmap WHERE appid = ?";
- int ret;
- sqlite3_stmt *stmt;
- const char *pkgid;
- int prime;
- int cnt = 0;
-
- if (!cb || !appid || !strlen(appid)) {
- return -EINVAL;
- }
-
- if (!s_info.handle) {
- if (db_init() < 0) {
- ErrPrint("Failed to init DB\n");
- return -EIO;
- }
- }
-
- ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
- ErrPrint("Failed to prepare the intial DML(%s)\n", sqlite3_errmsg(s_info.handle));
- return -EIO;
- }
-
- ret = -EIO;
- if (sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT) != SQLITE_OK) {
- ErrPrint("Failed to bind a cluster - %s\n", sqlite3_errmsg(s_info.handle));
- goto out;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- pkgid = (const char *)sqlite3_column_text(stmt, 0);
- if (!pkgid || !strlen(pkgid)) {
- continue;
- }
-
- prime = sqlite3_column_int(stmt, 1);
- cb(appid, pkgid, prime, data);
- cnt++;
- }
-
-out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
- return cnt;
-}
-
-static void clear_all_pkg(const char *appid, const char *pkgid, int prime, void *data)
-{
- int ret;
-
- ErrPrintWithConsole("Remove old package info: appid(%s), pkgid(%s)\n", appid, pkgid);
-
- ret = db_remove_box_size((char *)pkgid);
- if (ret < 0) {
- ErrPrint("Remove box size: %d\n", ret);
- }
-
- ret = db_remove_i18n((char *)pkgid);
- if (ret < 0) {
- ErrPrint("Remove i18n: %d\n", ret);
- }
-
- ret = db_remove_client((char *)pkgid);
- if (ret < 0) {
- ErrPrint("Remove client: %d\n", ret);
- }
-
- ret = db_remove_provider((char *)pkgid);
- if (ret < 0) {
- ErrPrint("Remove provider: %d\n", ret);
- }
-
- ret = db_remove_option((char *)pkgid);
- if (ret < 0) {
- ErrPrint("Remove option: %d\n", ret);
- }
-
- ret = db_remove_groupmap((char *)pkgid);
- if (ret < 0) {
- ErrPrint("Remove groupmap: %d\n", ret);
- }
-
- ret = db_remove_group((char *)pkgid);
- if (ret < 0) {
- ErrPrint("Remove group: %d\n", ret);
- }
-
- ret = db_remove_pkgmap((char *)pkgid);
- if (ret < 0) {
- ErrPrint("Remove pkgmap: %d\n", ret);
- }
-}
-
-int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *appid)
-{
- int cnt;
-
- ErrPrintWithConsole("%s\n", appid);
-
- if (!s_info.handle) {
- if (db_init() < 0) {
- ErrPrintWithConsole("Failed to init DB\n");
- return -EIO;
- }
- }
-
- do_upgrade_db_schema();
-
- begin_transaction();
- cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
- commit_transaction();
-
- if (cnt > 0) {
- DbgPrint("Package[%s] is not deleted: %d\n", appid, cnt);
- }
- return 0;
-}
-
-int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *appid)
-{
- ErrPrintWithConsole("[%s]\n", appid);
- db_fini();
- return 0;
-}
-
-int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
-{
- xmlNodePtr node;
- int ret;
-
- ErrPrintWithConsole("[%s]\n", appid);
-
- if (!s_info.handle) {
- ErrPrintWithConsole("Failed to init DB\n");
- return -EIO;
- }
-
- node = xmlDocGetRootElement(docPtr);
- if (!node) {
- ErrPrintWithConsole("Invalid document\n");
- return -EINVAL;
- }
-
- for (node = node->children; node; node = node->next) {
- DbgPrint("node->name: %s\n", node->name);
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"livebox")) {
- ret = do_install(node, appid);
- if (ret < 0) {
- DbgPrint("Returns: %d\n", ret);
- }
- }
- }
-
- return 0;
-}
-
-int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *appid)
-{
- int cnt;
-
- ErrPrintWithConsole("[%s]\n", appid);
-
- if (!s_info.handle) {
- if (db_init() < 0) {
- ErrPrint("Failed to init DB\n");
- return -EIO;
- }
- }
-
- do_upgrade_db_schema();
-
- begin_transaction();
- cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
- commit_transaction();
-
- if (cnt > 0) {
- DbgPrint("Package %s is deleted: %d\n", appid, cnt);
- }
- return 0;
-}
-
-int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *appid)
-{
- ErrPrintWithConsole("[%s]\n", appid);
- db_fini();
- return 0;
-}
-
-int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid)
-{
- xmlNodePtr node;
- int ret;
-
- ErrPrintWithConsole("[%s]\n", appid);
-
- if (!s_info.handle) {
- ErrPrint("Failed to init DB\n");
- return -EIO;
- }
-
- node = xmlDocGetRootElement(docPtr);
- if (!node) {
- ErrPrint("Invalid document\n");
- return -EINVAL;
- }
-
- for (node = node->children; node; node = node->next) {
- if (!xmlStrcasecmp(node->name, (const xmlChar *)"livebox")) {
- ret = do_install(node, appid);
- if (ret < 0) {
- DbgPrint("Returns: %d\n", ret);
- }
- }
- }
-
- return 0;
-}
-
-int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *appid)
-{
- ErrPrintWithConsole("[%s]\n", appid);
-
- if (!s_info.handle) {
- if (db_init() < 0) {
- ErrPrint("Failed to init DB\n");
- return -EIO;
- }
- }
-
- do_upgrade_db_schema();
- return 0;
-}
-
-int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *appid)
-{
- int cnt;
-
- ErrPrintWithConsole("[%s]\n", appid);
-
- if (!s_info.handle) {
- return -EIO;
- }
-
- begin_transaction();
- cnt = pkglist_get_via_callback(appid, clear_all_pkg, NULL);
- commit_transaction();
-
- if (cnt > 0) {
- DbgPrint("Package %s is deleted: %d\n", appid, cnt);
- }
- db_fini();
- return 0;
-}
-
-int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid)
-{
- ErrPrintWithConsole("[%s]\n", appid);
- if (!s_info.handle) {
- return -EIO;
- }
- /* Doesn't need to do anything from here, we already dealt it with this */
- return 0;
-}
-
-/* End of a file */
diff --git a/res/edje/CMakeLists.txt b/res/edje/CMakeLists.txt
index ec7f868..ff341c3 100644
--- a/res/edje/CMakeLists.txt
+++ b/res/edje/CMakeLists.txt
@@ -1,9 +1 @@
-#ADD_CUSTOM_TARGET(master.edj
-# COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/image ${EDJE_CFLAGS}
-# ${CMAKE_CURRENT_SOURCE_DIR}/master.edc master.edj
-# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/master.edc
-#)
-#ADD_DEPENDENCIES(${PROJECT_NAME} master.edj)
-#INSTALL(FILES master.edj DESTINATION "/opt/apps/org.tizen.${PROJECT_NAME}/res/edje")
-
# End of a file
diff --git a/src/abi.c b/src/abi.c
index edbfa21..dfc9251 100644
--- a/src/abi.c
+++ b/src/abi.c
@@ -20,7 +20,7 @@
#include <Eina.h>
#include <dlog.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#include "util.h"
#include "debug.h"
@@ -46,14 +46,14 @@ HAPI int abi_add_entry(const char *abi, const char *pkgname)
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Failed to add a new entry for abi[%s - %s]\n", abi, pkgname);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
item->abi = strdup(abi);
if (!item->abi) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(item);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
item->pkgname = strdup(pkgname);
@@ -61,11 +61,11 @@ HAPI int abi_add_entry(const char *abi, const char *pkgname)
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(item->abi);
DbgFree(item);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
s_abi.list = eina_list_append(s_abi.list, item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int abi_update_entry(const char *abi, const char *pkgname)
@@ -78,7 +78,7 @@ HAPI int abi_update_entry(const char *abi, const char *pkgname)
_pkgname = strdup(pkgname);
if (!_pkgname) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
EINA_LIST_FOREACH_SAFE(s_abi.list, l, n, item) {
@@ -90,7 +90,7 @@ HAPI int abi_update_entry(const char *abi, const char *pkgname)
}
DbgFree(_pkgname);
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
HAPI int abi_del_entry(const char *abi)
@@ -105,11 +105,11 @@ HAPI int abi_del_entry(const char *abi)
DbgFree(item->abi);
DbgFree(item->pkgname);
DbgFree(item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
HAPI void abi_del_all(void)
diff --git a/src/badge_service.c b/src/badge_service.c
index 2b1dc0b..5502245 100644
--- a/src/badge_service.c
+++ b/src/badge_service.c
@@ -20,7 +20,7 @@
#include <dlog.h>
#if defined(HAVE_LIVEBOX)
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#else
#include "lite-errno.h"
#endif
@@ -127,7 +127,7 @@ static void _handler_insert_badge(struct tcb *tcb, struct packet *packet, void *
if (pkgname != NULL && writable_pkg != NULL && caller != NULL) {
ret = badge_db_insert(pkgname, writable_pkg, caller);
} else {
- ret = BADGE_ERROR_INVALID_DATA;
+ ret = BADGE_ERROR_INVALID_PARAMETER;
}
packet_reply = packet_create_reply(packet, "i", ret);
@@ -177,7 +177,7 @@ static void _handler_delete_badge(struct tcb *tcb, struct packet *packet, void *
ret = badge_db_delete(pkgname, caller);
}
} else {
- ret = BADGE_ERROR_INVALID_DATA;
+ ret = BADGE_ERROR_INVALID_PARAMETER;
}
packet_reply = packet_create_reply(packet, "i", ret);
@@ -224,7 +224,7 @@ static void _handler_set_badge_count(struct tcb *tcb, struct packet *packet, voi
if (pkgname != NULL && caller != NULL) {
ret = badge_db_set_count(pkgname, caller, count);
} else {
- ret = BADGE_ERROR_INVALID_DATA;
+ ret = BADGE_ERROR_INVALID_PARAMETER;
}
packet_reply = packet_create_reply(packet, "i", ret);
@@ -271,7 +271,7 @@ static void _handler_set_display_option(struct tcb *tcb, struct packet *packet,
if (pkgname != NULL && caller != NULL) {
ret = badge_db_set_display_option(pkgname, caller, is_display);
} else {
- ret = BADGE_ERROR_INVALID_DATA;
+ ret = BADGE_ERROR_INVALID_PARAMETER;
}
packet_reply = packet_create_reply(packet, "i", ret);
@@ -320,7 +320,7 @@ static void _handler_set_setting_property(struct tcb *tcb, struct packet *packet
if (pkgname != NULL && property != NULL && value != NULL) {
ret = badge_setting_db_set(pkgname, property, value);
} else {
- ret = BADGE_ERROR_INVALID_DATA;
+ ret = BADGE_ERROR_INVALID_PARAMETER;
}
packet_reply = packet_create_reply(packet, "ii", ret, ret);
@@ -374,7 +374,7 @@ static void _handler_get_setting_property(struct tcb *tcb, struct packet *packet
if (pkgname != NULL && property != NULL) {
ret = badge_setting_db_get(pkgname, property, &value);
} else {
- ret = BADGE_ERROR_INVALID_DATA;
+ ret = BADGE_ERROR_INVALID_PARAMETER;
}
packet_reply = packet_create_reply(packet, "is", ret, value);
@@ -547,13 +547,13 @@ HAPI int badge_service_init(void)
{
if (s_info.svc_ctx) {
ErrPrint("Already initialized\n");
- return LB_STATUS_ERROR_ALREADY;
+ return DBOX_STATUS_ERROR_ALREADY;
}
s_info.svc_ctx = service_common_create(BADGE_SOCKET, service_thread_main, NULL);
if (!s_info.svc_ctx) {
ErrPrint("Unable to activate service thread\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (smack_fsetlabel(service_common_fd(s_info.svc_ctx), BADGE_SMACK_LABEL, SMACK_LABEL_IPOUT) != 0) {
@@ -561,7 +561,7 @@ HAPI int badge_service_init(void)
ErrPrint("Unable to set SMACK label(%d)\n", errno);
service_common_destroy(s_info.svc_ctx);
s_info.svc_ctx = NULL;
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
}
@@ -570,24 +570,24 @@ HAPI int badge_service_init(void)
ErrPrint("Unable to set SMACK label(%d)\n", errno);
service_common_destroy(s_info.svc_ctx);
s_info.svc_ctx = NULL;
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
}
DbgPrint("Successfully initiated\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int badge_service_fini(void)
{
if (!s_info.svc_ctx) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
service_common_destroy(s_info.svc_ctx);
s_info.svc_ctx = NULL;
DbgPrint("Successfully finalized\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* End of a file */
diff --git a/src/buffer_handler.c b/src/buffer_handler.c
index c27eecf..416fea6 100644
--- a/src/buffer_handler.c
+++ b/src/buffer_handler.c
@@ -42,7 +42,10 @@
#include <dlog.h>
#include <packet.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_buffer.h>
+#include <dynamicbox_conf.h>
#include "debug.h"
#include "conf.h"
@@ -54,17 +57,6 @@
#include "buffer_handler.h"
#include "script_handler.h" // Reverse dependency. must has to be broken
-struct buffer {
- enum {
- CREATED = 0x00beef00,
- DESTROYED = 0x00dead00
- } state;
- enum buffer_type type;
- int refcnt;
- void *info;
- char data[];
-};
-
/*!
* \brief Allocate this in the buffer->data.
*/
@@ -88,10 +80,9 @@ struct buffer_info
{
void *buffer;
char *id;
- char *lock;
- int lock_fd;
+ dynamicbox_lock_info_t lock_info;
- enum buffer_type type;
+ enum dynamicbox_fb_type type;
int w;
int h;
@@ -116,127 +107,10 @@ static struct {
.pixmap_list = NULL,
};
-static int destroy_lock_file(struct buffer_info *info)
-{
- if (!info->inst) {
- return LB_STATUS_ERROR_INVALID;
- }
-
- if (!info->lock) {
- return LB_STATUS_ERROR_INVALID;
- }
-
- if (close(info->lock_fd) < 0) {
- ErrPrint("close: %s\n", strerror(errno));
- }
- info->lock_fd = -1;
-
- if (unlink(info->lock) < 0) {
- ErrPrint("unlink: %s\n", strerror(errno));
- }
-
- DbgFree(info->lock);
- info->lock = NULL;
- return LB_STATUS_SUCCESS;
-}
-
-static int create_lock_file(struct buffer_info *info)
-{
- const char *id;
- int len;
- char *file;
- char target[3] = "pd";
-
- if (!info->inst) {
- return LB_STATUS_ERROR_INVALID;
- }
-
- id = instance_id(info->inst);
- if (!id) {
- return LB_STATUS_ERROR_INVALID;
- }
-
- len = strlen(id);
- file = malloc(len + 20);
- if (!file) {
- ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
- }
-
- if (script_handler_buffer_info(instance_pd_script(info->inst)) != info && instance_pd_buffer(info->inst) != info) {
- target[0] = 'l';
- target[1] = 'b';
- /* target[2] = '\0'; // We already have this ;) */
- }
-
- snprintf(file, len + 20, "%s.%s.lck", util_uri_to_path(id), target);
- info->lock_fd = open(file, O_WRONLY|O_CREAT, 0644);
- if (info->lock_fd < 0) {
- ErrPrint("open: %s\n", strerror(errno));
- DbgFree(file);
- return LB_STATUS_ERROR_IO;
- }
-
- info->lock = file;
- return LB_STATUS_SUCCESS;
-}
-
-static int do_buffer_lock(struct buffer_info *buffer)
-{
- struct flock flock;
- int ret;
-
- if (buffer->lock_fd < 0) {
- return LB_STATUS_SUCCESS;
- }
-
- flock.l_type = F_WRLCK;
- flock.l_whence = SEEK_SET;
- flock.l_start = 0;
- flock.l_len = 0;
- flock.l_pid = getpid();
-
- do {
- ret = fcntl(buffer->lock_fd, F_SETLKW, &flock);
- if (ret < 0) {
- ret = errno;
- ErrPrint("fcntl: %s\n", strerror(errno));
- }
- } while (ret == EINTR);
-
- return LB_STATUS_SUCCESS;
-}
-
-static int do_buffer_unlock(struct buffer_info *buffer)
-{
- struct flock flock;
- int ret;
-
- if (buffer->lock_fd < 0) {
- return LB_STATUS_SUCCESS;
- }
-
- flock.l_type = F_UNLCK;
- flock.l_whence = SEEK_SET;
- flock.l_start = 0;
- flock.l_len = 0;
- flock.l_pid = getpid();
-
- do {
- ret = fcntl(buffer->lock_fd, F_SETLKW, &flock);
- if (ret < 0) {
- ret = errno;
- ErrPrint("fcntl: %s\n", strerror(errno));
- }
- } while (ret == EINTR);
-
- return LB_STATUS_SUCCESS;
-}
-
-static inline struct buffer *create_pixmap(struct buffer_info *info)
+static inline dynamicbox_fb_t create_pixmap(struct buffer_info *info)
{
struct gem_data *gem;
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
Display *disp;
Window parent;
XGCValues gcv;
@@ -257,9 +131,9 @@ static inline struct buffer *create_pixmap(struct buffer_info *info)
gem = (struct gem_data *)buffer->data;
- buffer->type = BUFFER_TYPE_PIXMAP;
+ buffer->type = DBOX_FB_TYPE_PIXMAP;
buffer->refcnt = 1;
- buffer->state = CREATED;
+ buffer->state = DBOX_FB_STATE_CREATED;
gem->attachments[0] = DRI2BufferFrontLeft;
gem->count = 1;
@@ -297,7 +171,7 @@ static inline struct buffer *create_pixmap(struct buffer_info *info)
return buffer;
}
-static inline int create_gem(struct buffer *buffer)
+static inline int create_gem(dynamicbox_fb_t buffer)
{
struct gem_data *gem;
Display *disp;
@@ -305,7 +179,7 @@ static inline int create_gem(struct buffer *buffer)
disp = ecore_x_display_get();
if (!disp) {
ErrPrint("Failed to get display\n");
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
gem = (struct gem_data *)buffer->data;
@@ -314,21 +188,21 @@ static inline int create_gem(struct buffer *buffer)
gem->data = calloc(1, gem->w * gem->h * gem->depth);
if (!gem->data) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
ErrPrint("DRI2(gem) is not supported - Fallback to the S/W Backend\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
DRI2CreateDrawable(disp, gem->pixmap);
gem->dri2_buffer = DRI2GetBuffers(disp, gem->pixmap,
- &gem->w, &gem->h, gem->attachments, gem->count, &gem->buf_count);
+ &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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
/*!
* \How can I destroy this?
@@ -337,24 +211,24 @@ static inline int create_gem(struct buffer *buffer)
if (!gem->pixmap_bo) {
ErrPrint("Failed to import BO\n");
DRI2DestroyDrawable(disp, gem->pixmap);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- if (gem->dri2_buffer->pitch != gem->w * gem->depth) {
+ if (DYNAMICBOX_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\n",
- gem->dri2_buffer, gem->dri2_buffer->name, gem->w, gem->h,
- gem->dri2_buffer->pitch, gem->buf_count, gem->depth, gem->compensate_data);
+ 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, DYNAMICBOX_CONF_AUTO_ALIGN);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-static inline void *acquire_gem(struct buffer *buffer)
+static inline void *acquire_gem(dynamicbox_fb_t buffer)
{
struct gem_data *gem;
@@ -394,7 +268,7 @@ static inline void *acquire_gem(struct buffer *buffer)
return gem->compensate_data ? gem->compensate_data : gem->data;
}
-static inline void release_gem(struct buffer *buffer)
+static inline void release_gem(dynamicbox_fb_t buffer)
{
struct gem_data *gem;
@@ -453,7 +327,7 @@ static inline void release_gem(struct buffer *buffer)
}
}
-static inline int destroy_pixmap(struct buffer *buffer)
+static inline int destroy_pixmap(dynamicbox_fb_t buffer)
{
struct gem_data *gem;
@@ -464,24 +338,24 @@ static inline int destroy_pixmap(struct buffer *buffer)
disp = ecore_x_display_get();
if (!disp) {
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
DbgPrint("pixmap %lu\n", gem->pixmap);
XFreePixmap(disp, gem->pixmap);
}
- buffer->state = DESTROYED;
+ buffer->state = DBOX_FB_STATE_DESTROYED;
DbgFree(buffer);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-static inline int destroy_gem(struct buffer *buffer)
+static inline int destroy_gem(dynamicbox_fb_t buffer)
{
struct gem_data *gem;
if (!buffer) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
/*!
@@ -489,7 +363,7 @@ static inline int destroy_gem(struct buffer *buffer)
*/
gem = (struct gem_data *)buffer->data;
if (!gem) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (s_info.fd >= 0) {
@@ -512,44 +386,44 @@ static inline int destroy_gem(struct buffer *buffer)
gem->data = NULL;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int load_file_buffer(struct buffer_info *info)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
double timestamp;
int size;
char *new_id;
int len;
- len = strlen(IMAGE_PATH) + 40;
+ len = strlen(DYNAMICBOX_CONF_IMAGE_PATH) + 40;
new_id = malloc(len);
if (!new_id) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
timestamp = util_timestamp();
- snprintf(new_id, len, SCHEMA_FILE "%s%lf", IMAGE_PATH, timestamp);
+ snprintf(new_id, len, SCHEMA_FILE "%s%lf", DYNAMICBOX_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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
buffer = calloc(1, size);
if (!buffer) {
ErrPrint("Failed to allocate buffer\n");
DbgFree(new_id);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- buffer->type = BUFFER_TYPE_FILE;
+ buffer->type = DBOX_FB_TYPE_FILE;
buffer->refcnt = 0;
- buffer->state = CREATED;
+ buffer->state = DBOX_FB_STATE_CREATED;
buffer->info = info;
DbgFree(info->id);
@@ -558,27 +432,27 @@ static inline int load_file_buffer(struct buffer_info *info)
info->is_loaded = 1;
DbgPrint("FILE type %d created\n", size);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int load_shm_buffer(struct buffer_info *info)
{
int id;
int size;
- struct buffer *buffer; /* Just for getting a size */
+ dynamicbox_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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
id = shmget(IPC_PRIVATE, size + sizeof(*buffer), IPC_CREAT | 0666);
if (id < 0) {
ErrPrint("shmget: %s\n", strerror(errno));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
buffer = shmat(id, NULL, 0);
@@ -589,12 +463,12 @@ static inline int load_shm_buffer(struct buffer_info *info)
ErrPrint("%s shmctl: %s\n", info->id, strerror(errno));
}
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- buffer->type = BUFFER_TYPE_SHM;
+ buffer->type = DBOX_FB_TYPE_SHM;
buffer->refcnt = id;
- buffer->state = CREATED; /*!< Needless */
+ buffer->state = DBOX_FB_STATE_CREATED; /*!< Needless */
buffer->info = (void *)size; /*!< Use this field to indicates the size of SHM */
len = strlen(SCHEMA_SHM) + 30; /* strlen("shm://") + 30 */
@@ -610,7 +484,7 @@ static inline int load_shm_buffer(struct buffer_info *info)
ErrPrint("shmctl: %s\n", strerror(errno));
}
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
snprintf(new_id, len, SCHEMA_SHM "%d", id);
@@ -619,12 +493,12 @@ static inline int load_shm_buffer(struct buffer_info *info)
info->id = new_id;
info->buffer = buffer;
info->is_loaded = 1;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int load_pixmap_buffer(struct buffer_info *info)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
struct gem_data *gem;
char *new_id;
int len;
@@ -645,7 +519,7 @@ static inline int load_pixmap_buffer(struct buffer_info *info)
if (!buffer) {
DbgPrint("Failed to make a reference of a pixmap\n");
info->is_loaded = 0;
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
len = strlen(SCHEMA_PIXMAP) + 30; /* strlen("pixmap://") + 30 */
@@ -654,7 +528,7 @@ static inline int load_pixmap_buffer(struct buffer_info *info)
ErrPrint("Heap: %s\n", strerror(errno));
info->is_loaded = 0;
buffer_handler_pixmap_unref(buffer);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
DbgFree(info->id);
@@ -664,38 +538,47 @@ static inline int load_pixmap_buffer(struct buffer_info *info)
snprintf(info->id, len, SCHEMA_PIXMAP "%d:%d", (int)gem->pixmap, info->pixel_size);
DbgPrint("Loaded pixmap(info->id): %s\n", info->id);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI int buffer_handler_load(struct buffer_info *info)
{
int ret;
+ dynamicbox_target_type_e type = DBOX_TYPE_GBAR;
if (!info) {
ErrPrint("buffer handler is nil\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (info->is_loaded) {
DbgPrint("Buffer is already loaded\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
switch (info->type) {
- case BUFFER_TYPE_FILE:
+ case DBOX_FB_TYPE_FILE:
ret = load_file_buffer(info);
- (void)create_lock_file(info);
+
+ if (script_handler_buffer_info(instance_gbar_script(info->inst)) != info && instance_gbar_buffer(info->inst) != info) {
+ type = DBOX_TYPE_DBOX;
+ }
+ info->lock_info = dynamicbox_service_create_lock(instance_id(info->inst), type, DBOX_LOCK_WRITE);
break;
- case BUFFER_TYPE_SHM:
+ case DBOX_FB_TYPE_SHM:
ret = load_shm_buffer(info);
- (void)create_lock_file(info);
+
+ if (script_handler_buffer_info(instance_gbar_script(info->inst)) != info && instance_gbar_buffer(info->inst) != info) {
+ type = DBOX_TYPE_DBOX;
+ }
+ info->lock_info = dynamicbox_service_create_lock(instance_id(info->inst), type, DBOX_LOCK_WRITE);
break;
- case BUFFER_TYPE_PIXMAP:
+ case DBOX_FB_TYPE_PIXMAP:
ret = load_pixmap_buffer(info);
break;
default:
ErrPrint("Invalid buffer\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
break;
}
@@ -710,7 +593,7 @@ static inline int unload_file_buffer(struct buffer_info *info)
new_id = strdup(SCHEMA_FILE "/tmp/.live.undefined");
if (!new_id) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
DbgFree(info->buffer);
@@ -723,7 +606,7 @@ static inline int unload_file_buffer(struct buffer_info *info)
DbgFree(info->id);
info->id = new_id;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int unload_shm_buffer(struct buffer_info *info)
@@ -734,19 +617,19 @@ static inline int unload_shm_buffer(struct buffer_info *info)
new_id = strdup(SCHEMA_SHM "-1");
if (!new_id) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
if (sscanf(info->id, SCHEMA_SHM "%d", &id) != 1) {
ErrPrint("%s Invalid ID\n", info->id);
DbgFree(new_id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (id < 0) {
ErrPrint("(%s) Invalid id: %d\n", info->id, id);
DbgFree(new_id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (shmdt(info->buffer) < 0) {
@@ -761,7 +644,7 @@ static inline int unload_shm_buffer(struct buffer_info *info)
DbgFree(info->id);
info->id = new_id;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int unload_pixmap_buffer(struct buffer_info *info)
@@ -773,19 +656,19 @@ static inline int unload_pixmap_buffer(struct buffer_info *info)
new_id = strdup(SCHEMA_PIXMAP "0:0");
if (!new_id) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (id == 0) {
ErrPrint("(%s) Invalid id: %d\n", info->id, id);
DbgFree(new_id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
/*!
@@ -802,7 +685,7 @@ static inline int unload_pixmap_buffer(struct buffer_info *info)
DbgFree(info->id);
info->id = new_id;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI int buffer_handler_unload(struct buffer_info *info)
@@ -811,29 +694,31 @@ EAPI int buffer_handler_unload(struct buffer_info *info)
if (!info) {
ErrPrint("buffer handler is NIL\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (!info->is_loaded) {
ErrPrint("Buffer is not loaded\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
switch (info->type) {
- case BUFFER_TYPE_FILE:
- (void)destroy_lock_file(info);
+ case DBOX_FB_TYPE_FILE:
+ dynamicbox_service_destroy_lock(info->lock_info);
+ info->lock_info = NULL;
ret = unload_file_buffer(info);
break;
- case BUFFER_TYPE_SHM:
- (void)destroy_lock_file(info);
+ case DBOX_FB_TYPE_SHM:
+ dynamicbox_service_destroy_lock(info->lock_info);
+ info->lock_info = NULL;
ret = unload_shm_buffer(info);
break;
- case BUFFER_TYPE_PIXMAP:
+ case DBOX_FB_TYPE_PIXMAP:
ret = unload_pixmap_buffer(info);
break;
default:
ErrPrint("Invalid buffer\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
break;
}
@@ -849,14 +734,14 @@ EAPI const char *buffer_handler_id(const struct buffer_info *info)
return info ? info->id : "";
}
-EAPI enum buffer_type buffer_handler_type(const struct buffer_info *info)
+EAPI enum dynamicbox_fb_type buffer_handler_type(const struct buffer_info *info)
{
- return info ? info->type : BUFFER_TYPE_ERROR;
+ return info ? info->type : DBOX_FB_TYPE_ERROR;
}
EAPI void *buffer_handler_fb(struct buffer_info *info)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
if (!info) {
return NULL;
@@ -864,7 +749,7 @@ EAPI void *buffer_handler_fb(struct buffer_info *info)
buffer = info->buffer;
- if (info->type == BUFFER_TYPE_PIXMAP) {
+ if (info->type == DBOX_FB_TYPE_PIXMAP) {
void *canvas;
int ret;
@@ -885,7 +770,7 @@ EAPI void *buffer_handler_fb(struct buffer_info *info)
EAPI int buffer_handler_pixmap(const struct buffer_info *info)
{
- struct buffer *buf;
+ dynamicbox_fb_t buf;
struct gem_data *gem;
if (!info) {
@@ -893,12 +778,12 @@ EAPI int buffer_handler_pixmap(const struct buffer_info *info)
return 0;
}
- if (info->type != BUFFER_TYPE_PIXMAP) {
+ if (info->type != DBOX_FB_TYPE_PIXMAP) {
ErrPrint("Invalid buffer type\n");
return 0;
}
- buf = (struct buffer *)info->buffer;
+ buf = (dynamicbox_fb_t)info->buffer;
if (!buf) {
ErrPrint("Invalid buffer data\n");
return 0;
@@ -910,7 +795,7 @@ EAPI int buffer_handler_pixmap(const struct buffer_info *info)
EAPI void *buffer_handler_pixmap_acquire_buffer(struct buffer_info *info)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
if (!info || !info->is_loaded) {
ErrPrint("Buffer is not loaded\n");
@@ -927,7 +812,7 @@ EAPI void *buffer_handler_pixmap_acquire_buffer(struct buffer_info *info)
EAPI void *buffer_handler_pixmap_buffer(struct buffer_info *info)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
struct gem_data *gem;
if (!info) {
@@ -948,19 +833,19 @@ EAPI void *buffer_handler_pixmap_buffer(struct buffer_info *info)
return gem->compensate_data ? gem->compensate_data : gem->data;
}
-/*!
- * \return "buffer" object (Not the buffer_info)
+/**
+ * @return "buffer" object (Not the buffer_info)
*/
EAPI void *buffer_handler_pixmap_ref(struct buffer_info *info)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
if (!info->is_loaded) {
ErrPrint("Buffer is not loaded\n");
return NULL;
}
- if (info->type != BUFFER_TYPE_PIXMAP) {
+ if (info->type != DBOX_FB_TYPE_PIXMAP) {
ErrPrint("Buffer type is not matched\n");
return NULL;
}
@@ -980,24 +865,43 @@ EAPI void *buffer_handler_pixmap_ref(struct buffer_info *info)
if (info->inst) {
struct pkg_info *pkg;
- if (instance_lb_buffer(info->inst) == info) {
- pkg = instance_package(info->inst);
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ pkg = instance_package(info->inst);
+
+ if (instance_dbox_buffer(info->inst) == info) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
need_gem = 0;
}
- } else if (instance_pd_buffer(info->inst) == info) {
- pkg = instance_package(info->inst);
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ } 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 < DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT; idx++) {
+ if (instance_dbox_extra_buffer(info->inst, idx) == info) {
+ if (package_dbox_type(pkg) == DBOX_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) {
- create_gem(buffer);
+ if (create_gem(buffer) < 0) {
+ /* okay, something goes wrong */
+ }
}
-
- } else if (buffer->state != CREATED || buffer->type != BUFFER_TYPE_PIXMAP) {
+ } else if (buffer->state != DBOX_FB_STATE_CREATED || buffer->type != DBOX_FB_TYPE_PIXMAP) {
ErrPrint("Invalid buffer\n");
return NULL;
} else if (buffer->refcnt > 0) {
@@ -1014,7 +918,7 @@ EAPI void *buffer_handler_pixmap_ref(struct buffer_info *info)
*/
EAPI void *buffer_handler_pixmap_find(int pixmap)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
struct gem_data *gem;
Eina_List *l;
Eina_List *n;
@@ -1024,7 +928,7 @@ EAPI void *buffer_handler_pixmap_find(int pixmap)
}
EINA_LIST_FOREACH_SAFE(s_info.pixmap_list, l, n, buffer) {
- if (!buffer || buffer->state != CREATED || buffer->type != BUFFER_TYPE_PIXMAP) {
+ if (!buffer || buffer->state != DBOX_FB_STATE_CREATED || buffer->type != DBOX_FB_TYPE_PIXMAP) {
s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
DbgPrint("Invalid buffer (List Removed: %p)\n", buffer);
continue;
@@ -1041,18 +945,18 @@ EAPI void *buffer_handler_pixmap_find(int pixmap)
EAPI int buffer_handler_pixmap_release_buffer(void *canvas)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
struct gem_data *gem;
Eina_List *l;
Eina_List *n;
void *_ptr;
if (!canvas) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
EINA_LIST_FOREACH_SAFE(s_info.pixmap_list, l, n, buffer) {
- if (!buffer || buffer->state != CREATED || buffer->type != BUFFER_TYPE_PIXMAP) {
+ if (!buffer || buffer->state != DBOX_FB_STATE_CREATED || buffer->type != DBOX_FB_TYPE_PIXMAP) {
s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
continue;
}
@@ -1067,11 +971,11 @@ EAPI int buffer_handler_pixmap_release_buffer(void *canvas)
if (_ptr == canvas) {
release_gem(buffer);
buffer_handler_pixmap_unref(buffer);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
/*!
@@ -1082,12 +986,12 @@ EAPI int buffer_handler_pixmap_release_buffer(void *canvas)
*/
EAPI int buffer_handler_pixmap_unref(void *buffer_ptr)
{
- struct buffer *buffer = buffer_ptr;
+ dynamicbox_fb_t buffer = buffer_ptr;
struct buffer_info *info;
buffer->refcnt--;
if (buffer->refcnt > 0) {
- return LB_STATUS_SUCCESS; /* Return NULL means, gem buffer still in use */
+ return DBOX_STATUS_ERROR_NONE; /* Return NULL means, gem buffer still in use */
}
s_info.pixmap_list = eina_list_remove(s_info.pixmap_list, buffer);
@@ -1106,7 +1010,7 @@ EAPI int buffer_handler_pixmap_unref(void *buffer_ptr)
info->buffer = NULL;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI int buffer_handler_is_loaded(const struct buffer_info *info)
@@ -1130,19 +1034,19 @@ EAPI int buffer_handler_resize(struct buffer_info *info, int w, int h)
if (!info) {
ErrPrint("Invalid handler\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (info->w == w && info->h == h) {
DbgPrint("No changes\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
buffer_handler_update_size(info, w, h);
if (!info->is_loaded) {
DbgPrint("Buffer size is updated[%dx%d]\n", w, h);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
ret = buffer_handler_unload(info);
@@ -1155,13 +1059,13 @@ EAPI int buffer_handler_resize(struct buffer_info *info, int w, int h)
ErrPrint("Load: %d\n", ret);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
{
if (!info) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (w) {
@@ -1171,7 +1075,7 @@ EAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
*h = info->h;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI struct inst_info *buffer_handler_instance(struct buffer_info *info)
@@ -1183,7 +1087,7 @@ EAPI struct inst_info *buffer_handler_instance(struct buffer_info *info)
* \note
* Only for used S/W Backend
*/
-static inline int sync_for_pixmap(struct buffer *buffer)
+static inline int sync_for_pixmap(dynamicbox_fb_t buffer)
{
XShmSegmentInfo si;
XImage *xim;
@@ -1193,32 +1097,32 @@ static inline int sync_for_pixmap(struct buffer *buffer)
Screen *screen;
Visual *visual;
- if (buffer->state != CREATED) {
+ if (buffer->state != DBOX_FB_STATE_CREATED) {
ErrPrint("Invalid state of a FB\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- if (buffer->type != BUFFER_TYPE_PIXMAP) {
+ if (buffer->type != DBOX_FB_TYPE_PIXMAP) {
ErrPrint("Invalid buffer\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
disp = ecore_x_display_get();
if (!disp) {
ErrPrint("Failed to get a display\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
gem = (struct gem_data *)buffer->data;
if (gem->w == 0 || gem->h == 0) {
DbgPrint("Nothing can be sync\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
si.shmid = shmget(IPC_PRIVATE, gem->w * gem->h * gem->depth, IPC_CREAT | 0666);
if (si.shmid < 0) {
ErrPrint("shmget: %s\n", strerror(errno));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
si.readOnly = False;
@@ -1227,7 +1131,7 @@ static inline int sync_for_pixmap(struct buffer *buffer)
if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
}
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
screen = DefaultScreenOfDisplay(disp);
@@ -1245,7 +1149,7 @@ static inline int sync_for_pixmap(struct buffer *buffer)
if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
ErrPrint("shmctl: %s\n", strerror(errno));
}
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
xim->data = si.shmaddr;
@@ -1265,7 +1169,7 @@ static inline int sync_for_pixmap(struct buffer *buffer)
ErrPrint("shmctl: %s\n", strerror(errno));
}
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
memcpy(xim->data, gem->data, gem->w * gem->h * gem->depth);
@@ -1289,14 +1193,14 @@ static inline int sync_for_pixmap(struct buffer *buffer)
ErrPrint("shmctl: %s\n", strerror(errno));
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI void buffer_handler_flush(struct buffer_info *info)
{
int fd;
int size;
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
if (!info || !info->buffer) {
return;
@@ -1304,7 +1208,7 @@ EAPI void buffer_handler_flush(struct buffer_info *info)
buffer = info->buffer;
- if (buffer->type == BUFFER_TYPE_PIXMAP) {
+ if (buffer->type == DBOX_FB_TYPE_PIXMAP) {
if (s_info.fd > 0) {
//return;
//PERF_INIT();
@@ -1327,7 +1231,7 @@ EAPI void buffer_handler_flush(struct buffer_info *info)
ErrPrint("Failed to sync via S/W Backend\n");
}
}
- } else if (buffer->type == BUFFER_TYPE_FILE) {
+ } else if (buffer->type == DBOX_FB_TYPE_FILE) {
fd = open(util_uri_to_path(info->id), O_WRONLY | O_CREAT, 0644);
if (fd < 0) {
ErrPrint("%s open falied: %s\n", util_uri_to_path(info->id), strerror(errno));
@@ -1335,11 +1239,11 @@ EAPI void buffer_handler_flush(struct buffer_info *info)
}
size = info->w * info->h * info->pixel_size;
- do_buffer_lock(info);
+ dynamicbox_service_acquire_lock(info->lock_info);
if (write(fd, info->buffer, size) != size) {
ErrPrint("Write is not completed: %s\n", strerror(errno));
}
- do_buffer_unlock(info);
+ dynamicbox_service_release_lock(info->lock_info);
if (close(fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
@@ -1357,30 +1261,30 @@ HAPI int buffer_handler_init(void)
if (!DRI2QueryExtension(ecore_x_display_get(), &s_info.evt_base, &s_info.err_base)) {
ErrPrint("DRI2 is not supported\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
if (!DRI2QueryVersion(ecore_x_display_get(), &dri2Major, &dri2Minor)) {
ErrPrint("DRI2 is not supported\n");
s_info.evt_base = 0;
s_info.err_base = 0;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
if (!DRI2Connect(ecore_x_display_get(), DefaultRootWindow(ecore_x_display_get()), &driverName, &deviceName)) {
ErrPrint("DRI2 is not supported\n");
s_info.evt_base = 0;
s_info.err_base = 0;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
- if (USE_SW_BACKEND) {
+ if (DYNAMICBOX_CONF_USE_SW_BACKEND) {
DbgPrint("Fallback to the S/W Backend\n");
s_info.evt_base = 0;
s_info.err_base = 0;
DbgFree(deviceName);
DbgFree(driverName);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
s_info.fd = open(deviceName, O_RDWR);
@@ -1390,7 +1294,7 @@ HAPI int buffer_handler_init(void)
ErrPrint("Failed to open a drm device: (%s)\n", strerror(errno));
s_info.evt_base = 0;
s_info.err_base = 0;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
drmGetMagic(s_info.fd, &magic);
@@ -1403,7 +1307,7 @@ HAPI int buffer_handler_init(void)
s_info.fd = -1;
s_info.evt_base = 0;
s_info.err_base = 0;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
s_info.slp_bufmgr = tbm_bufmgr_init(s_info.fd);
@@ -1415,10 +1319,10 @@ HAPI int buffer_handler_init(void)
s_info.fd = -1;
s_info.evt_base = 0;
s_info.err_base = 0;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int buffer_handler_fini(void)
@@ -1435,12 +1339,12 @@ HAPI int buffer_handler_fini(void)
s_info.slp_bufmgr = NULL;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-static inline struct buffer *raw_open_file(const char *filename)
+static inline dynamicbox_fb_t raw_open_file(const char *filename)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
int fd;
off_t off;
int ret;
@@ -1483,8 +1387,8 @@ static inline struct buffer *raw_open_file(const char *filename)
return NULL;
}
- buffer->state = CREATED;
- buffer->type = BUFFER_TYPE_FILE;
+ buffer->state = DBOX_FB_STATE_CREATED;
+ buffer->type = DBOX_FB_TYPE_FILE;
buffer->refcnt = 0;
buffer->info = (void *)off;
@@ -1507,18 +1411,18 @@ static inline struct buffer *raw_open_file(const char *filename)
return buffer;
}
-static inline int raw_close_file(struct buffer *buffer)
+static inline int raw_close_file(dynamicbox_fb_t buffer)
{
DbgFree(buffer);
return 0;
}
-static inline struct buffer *raw_open_shm(int shm)
+static inline dynamicbox_fb_t raw_open_shm(int shm)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
- buffer = (struct buffer *)shmat(shm, NULL, SHM_RDONLY);
- if (buffer == (struct buffer *)-1) {
+ buffer = (dynamicbox_fb_t)shmat(shm, NULL, SHM_RDONLY);
+ if (buffer == (dynamicbox_fb_t)-1) {
ErrPrint("shmat: %s\n", strerror(errno));
return NULL;
}
@@ -1526,7 +1430,7 @@ static inline struct buffer *raw_open_shm(int shm)
return buffer;
}
-static inline int raw_close_shm(struct buffer *buffer)
+static inline int raw_close_shm(dynamicbox_fb_t buffer)
{
int ret;
@@ -1538,58 +1442,58 @@ static inline int raw_close_shm(struct buffer *buffer)
return ret;
}
-static inline struct buffer *raw_open_pixmap(unsigned int pixmap)
+static inline dynamicbox_fb_t raw_open_pixmap(unsigned int pixmap)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
- buffer = calloc(1, sizeof(*buffer) + DEFAULT_PIXELS);
+ buffer = calloc(1, sizeof(*buffer) + DYNAMICBOX_CONF_DEFAULT_PIXELS);
if (!buffer) {
ErrPrint("Heap: %s\n", strerror(errno));
return NULL;
}
- buffer->state = CREATED;
- buffer->type = BUFFER_TYPE_PIXMAP;
+ buffer->state = DBOX_FB_STATE_CREATED;
+ buffer->type = DBOX_FB_TYPE_PIXMAP;
return buffer;
}
-static inline int raw_close_pixmap(struct buffer *buffer)
+static inline int raw_close_pixmap(dynamicbox_fb_t buffer)
{
DbgFree(buffer);
return 0;
}
-EAPI void *buffer_handler_raw_data(struct buffer *buffer)
+EAPI void *buffer_handler_raw_data(dynamicbox_fb_t buffer)
{
- if (!buffer || buffer->state != CREATED) {
+ if (!buffer || buffer->state != DBOX_FB_STATE_CREATED) {
return NULL;
}
return buffer->data;
}
-EAPI int buffer_handler_raw_size(struct buffer *buffer)
+EAPI int buffer_handler_raw_size(dynamicbox_fb_t buffer)
{
- if (!buffer || buffer->state != CREATED) {
- return LB_STATUS_ERROR_INVALID;
+ if (!buffer || buffer->state != DBOX_FB_STATE_CREATED) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
return (int)buffer->info;
}
-EAPI struct buffer *buffer_handler_raw_open(enum buffer_type buffer_type, void *resource)
+EAPI dynamicbox_fb_t buffer_handler_raw_open(enum dynamicbox_fb_type dynamicbox_fb_type, void *resource)
{
- struct buffer *handle;
+ dynamicbox_fb_t handle;
- switch (buffer_type) {
- case BUFFER_TYPE_SHM:
+ switch (dynamicbox_fb_type) {
+ case DBOX_FB_TYPE_SHM:
handle = raw_open_shm((int)resource);
break;
- case BUFFER_TYPE_FILE:
+ case DBOX_FB_TYPE_FILE:
handle = raw_open_file(resource);
break;
- case BUFFER_TYPE_PIXMAP:
+ case DBOX_FB_TYPE_PIXMAP:
handle = raw_open_pixmap((unsigned int)resource);
break;
default:
@@ -1600,52 +1504,125 @@ EAPI struct buffer *buffer_handler_raw_open(enum buffer_type buffer_type, void *
return handle;
}
-EAPI int buffer_handler_raw_close(struct buffer *buffer)
+EAPI int buffer_handler_raw_close(dynamicbox_fb_t buffer)
{
int ret;
+ if (!buffer || buffer->state != DBOX_FB_STATE_CREATED) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
switch (buffer->type) {
- case BUFFER_TYPE_SHM:
+ case DBOX_FB_TYPE_SHM:
ret = raw_close_shm(buffer);
break;
- case BUFFER_TYPE_FILE:
+ case DBOX_FB_TYPE_FILE:
ret = raw_close_file(buffer);
break;
- case BUFFER_TYPE_PIXMAP:
+ case DBOX_FB_TYPE_PIXMAP:
ret = raw_close_pixmap(buffer);
break;
default:
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
break;
}
return ret;
}
-EAPI int buffer_handler_lock(struct buffer_info *buffer)
+EAPI int buffer_handler_lock(struct buffer_info *info)
+{
+ if (!info) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (info->type == DBOX_FB_TYPE_PIXMAP) {
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ if (info->type == DBOX_FB_TYPE_FILE) {
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ return dynamicbox_service_acquire_lock(info->lock_info);
+}
+
+EAPI int buffer_handler_unlock(struct buffer_info *info)
{
- if (buffer->type == BUFFER_TYPE_PIXMAP) {
- return LB_STATUS_SUCCESS;
+ if (!info) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (info->type == DBOX_FB_TYPE_PIXMAP) {
+ return DBOX_STATUS_ERROR_NONE;
}
- if (buffer->type == BUFFER_TYPE_FILE) {
- return LB_STATUS_SUCCESS;
+ if (info->type == DBOX_FB_TYPE_FILE) {
+ return DBOX_STATUS_ERROR_NONE;
+ }
+
+ return dynamicbox_service_release_lock(info->lock_info);
+}
+
+EAPI int buffer_handler_pixels(struct buffer_info *info)
+{
+ if (!info) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return do_buffer_lock(buffer);
+ return info->pixel_size;
}
-EAPI int buffer_handler_unlock(struct buffer_info *buffer)
+EAPI int buffer_handler_auto_align(void)
{
- if (buffer->type == BUFFER_TYPE_PIXMAP) {
- return LB_STATUS_SUCCESS;
+ return DYNAMICBOX_CONF_AUTO_ALIGN;
+}
+
+EAPI int buffer_handler_stride(struct buffer_info *info)
+{
+ dynamicbox_fb_t buffer;
+ struct gem_data *gem;
+ int stride;
+
+ if (!info) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- if (buffer->type == BUFFER_TYPE_FILE) {
- return LB_STATUS_SUCCESS;
+ switch (info->type) {
+ case DBOX_FB_TYPE_FILE:
+ case DBOX_FB_TYPE_SHM:
+ stride = info->w * info->pixel_size;
+ break;
+ case DBOX_FB_TYPE_PIXMAP:
+ buffer = info->buffer;
+ if (!buffer) {
+ stride = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ gem = (struct gem_data *)buffer->data;
+ if (!gem) {
+ stride = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ if (!gem->dri2_buffer) {
+ /*
+ * Uhm...
+ */
+ ErrPrint("dri2_buffer info is not ready yet!\n");
+ stride = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ stride = gem->dri2_buffer->pitch;
+ break;
+ default:
+ stride = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ break;
}
- return do_buffer_unlock(buffer);
+ return stride;
}
/*!
@@ -1654,35 +1631,35 @@ EAPI int buffer_handler_unlock(struct buffer_info *buffer)
* Plugin cannot access the user data
*/
-HAPI int buffer_handler_set_data(struct buffer_info *buffer, void *data)
+HAPI int buffer_handler_set_data(struct buffer_info *info, void *data)
{
- if (!buffer) {
+ if (!info) {
ErrPrint("Invalid handle\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- buffer->data = data;
- return LB_STATUS_SUCCESS;
+ info->data = data;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI void *buffer_handler_data(struct buffer_info *buffer)
+HAPI void *buffer_handler_data(struct buffer_info *info)
{
- if (!buffer) {
+ if (!info) {
ErrPrint("Invalid handle\n");
return NULL;
}
- return buffer->data;
+ return info->data;
}
HAPI int buffer_handler_destroy(struct buffer_info *info)
{
Eina_List *l;
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
if (!info) {
DbgPrint("Buffer is not created yet. info is NIL\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EINA_LIST_FOREACH(s_info.pixmap_list, l, buffer) {
@@ -1694,10 +1671,10 @@ HAPI int buffer_handler_destroy(struct buffer_info *info)
buffer_handler_unload(info);
DbgFree(info->id);
DbgFree(info);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buffer_type type, int w, int h, int pixel_size)
+HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum dynamicbox_fb_type type, int w, int h, int pixel_size)
{
struct buffer_info *info;
@@ -1708,10 +1685,10 @@ HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buff
}
switch (type) {
- case BUFFER_TYPE_SHM:
- if (pixel_size != DEFAULT_PIXELS) {
- DbgPrint("SHM only supportes %d bytes pixels (requested: %d)\n", DEFAULT_PIXELS, pixel_size);
- pixel_size = DEFAULT_PIXELS;
+ case DBOX_FB_TYPE_SHM:
+ if (pixel_size != DYNAMICBOX_CONF_DEFAULT_PIXELS) {
+ DbgPrint("SHM only supportes %d bytes pixels (requested: %d)\n", DYNAMICBOX_CONF_DEFAULT_PIXELS, pixel_size);
+ pixel_size = DYNAMICBOX_CONF_DEFAULT_PIXELS;
}
info->id = strdup(SCHEMA_SHM "-1");
@@ -1721,10 +1698,10 @@ HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buff
return NULL;
}
break;
- case BUFFER_TYPE_FILE:
- if (pixel_size != DEFAULT_PIXELS) {
- DbgPrint("FILE only supportes %d bytes pixels (requested: %d)\n", DEFAULT_PIXELS, pixel_size);
- pixel_size = DEFAULT_PIXELS;
+ case DBOX_FB_TYPE_FILE:
+ if (pixel_size != DYNAMICBOX_CONF_DEFAULT_PIXELS) {
+ DbgPrint("FILE only supportes %d bytes pixels (requested: %d)\n", DYNAMICBOX_CONF_DEFAULT_PIXELS, pixel_size);
+ pixel_size = DYNAMICBOX_CONF_DEFAULT_PIXELS;
}
info->id = strdup(SCHEMA_FILE "/tmp/.live.undefined");
@@ -1734,7 +1711,7 @@ HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buff
return NULL;
}
break;
- case BUFFER_TYPE_PIXMAP:
+ case DBOX_FB_TYPE_PIXMAP:
info->id = strdup(SCHEMA_PIXMAP "0:0");
if (!info->id) {
ErrPrint("Heap: %s\n", strerror(errno));
@@ -1748,8 +1725,7 @@ HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buff
return NULL;
}
- info->lock = NULL;
- info->lock_fd = -1;
+ info->lock_info = NULL;
info->w = w;
info->h = h;
info->pixel_size = pixel_size;
diff --git a/src/buffer_handler_wayland.c b/src/buffer_handler_wayland.c
index 947e1b4..8530dd5 100644
--- a/src/buffer_handler_wayland.c
+++ b/src/buffer_handler_wayland.c
@@ -30,7 +30,7 @@
#include <dlog.h>
#include <packet.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#include "debug.h"
#include "conf.h"
@@ -65,6 +65,7 @@ struct buffer_info
int w;
int h;
int pixel_size;
+ int auto_align;
int is_loaded;
struct inst_info *inst;
@@ -74,11 +75,11 @@ struct buffer_info
static int destroy_lock_file(struct buffer_info *info)
{
if (!info->inst) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (!info->lock) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (close(info->lock_fd) < 0) {
@@ -92,7 +93,7 @@ static int destroy_lock_file(struct buffer_info *info)
DbgFree(info->lock);
info->lock = NULL;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int create_lock_file(struct buffer_info *info)
@@ -103,22 +104,22 @@ static int create_lock_file(struct buffer_info *info)
char target[3] = "pd";
if (!info->inst) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
id = instance_id(info->inst);
if (!id) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
len = strlen(id);
file = malloc(len + 20);
if (!file) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- if (script_handler_buffer_info(instance_pd_script(info->inst)) != info && instance_pd_buffer(info->inst) != info) {
+ if (script_handler_buffer_info(instance_gbar_script(info->inst)) != info && instance_gbar_buffer(info->inst) != info) {
target[0] = 'l';
target[1] = 'b';
/* target[2] = '\0'; // We already have this ;) */
@@ -129,11 +130,11 @@ static int create_lock_file(struct buffer_info *info)
if (info->lock_fd < 0) {
ErrPrint("open: %s\n", strerror(errno));
DbgFree(file);
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
info->lock = file;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int do_buffer_lock(struct buffer_info *buffer)
@@ -142,7 +143,7 @@ static int do_buffer_lock(struct buffer_info *buffer)
int ret;
if (buffer->lock_fd < 0) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
flock.l_type = F_WRLCK;
@@ -159,7 +160,7 @@ static int do_buffer_lock(struct buffer_info *buffer)
}
} while (ret == EINTR);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int do_buffer_unlock(struct buffer_info *buffer)
@@ -168,7 +169,7 @@ static int do_buffer_unlock(struct buffer_info *buffer)
int ret;
if (buffer->lock_fd < 0) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
flock.l_type = F_UNLCK;
@@ -185,7 +186,7 @@ static int do_buffer_unlock(struct buffer_info *buffer)
}
} while (ret == EINTR);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int load_file_buffer(struct buffer_info *info)
@@ -200,7 +201,7 @@ static inline int load_file_buffer(struct buffer_info *info)
new_id = malloc(len);
if (!new_id) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
timestamp = util_timestamp();
@@ -210,14 +211,14 @@ static inline int load_file_buffer(struct buffer_info *info)
if (!size) {
ErrPrint("Canvas buffer size is ZERO\n");
DbgFree(new_id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
buffer = calloc(1, size);
if (!buffer) {
ErrPrint("Failed to allocate buffer\n");
DbgFree(new_id);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
buffer->type = BUFFER_TYPE_FILE;
@@ -231,7 +232,7 @@ static inline int load_file_buffer(struct buffer_info *info)
info->is_loaded = 1;
DbgPrint("FILE type %d created\n", size);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int load_shm_buffer(struct buffer_info *info)
@@ -245,13 +246,13 @@ static inline int load_shm_buffer(struct buffer_info *info)
size = info->w * info->h * info->pixel_size;
if (!size) {
ErrPrint("Invalid buffer size\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
id = shmget(IPC_PRIVATE, size + sizeof(*buffer), IPC_CREAT | 0666);
if (id < 0) {
ErrPrint("shmget: %s\n", strerror(errno));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
buffer = shmat(id, NULL, 0);
@@ -262,7 +263,7 @@ static inline int load_shm_buffer(struct buffer_info *info)
ErrPrint("%s shmctl: %s\n", info->id, strerror(errno));
}
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
buffer->type = BUFFER_TYPE_SHM;
@@ -283,7 +284,7 @@ static inline int load_shm_buffer(struct buffer_info *info)
ErrPrint("shmctl: %s\n", strerror(errno));
}
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
snprintf(new_id, len, SCHEMA_SHM "%d", id);
@@ -292,7 +293,7 @@ static inline int load_shm_buffer(struct buffer_info *info)
info->id = new_id;
info->buffer = buffer;
info->is_loaded = 1;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI int buffer_handler_load(struct buffer_info *info)
@@ -301,12 +302,12 @@ EAPI int buffer_handler_load(struct buffer_info *info)
if (!info) {
ErrPrint("buffer handler is nil\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (info->is_loaded) {
DbgPrint("Buffer is already loaded\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
switch (info->type) {
@@ -321,7 +322,7 @@ EAPI int buffer_handler_load(struct buffer_info *info)
case BUFFER_TYPE_PIXMAP:
default:
ErrPrint("Invalid buffer\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
break;
}
@@ -336,7 +337,7 @@ static inline int unload_file_buffer(struct buffer_info *info)
new_id = strdup(SCHEMA_FILE "/tmp/.live.undefined");
if (!new_id) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
DbgFree(info->buffer);
@@ -349,7 +350,7 @@ static inline int unload_file_buffer(struct buffer_info *info)
DbgFree(info->id);
info->id = new_id;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int unload_shm_buffer(struct buffer_info *info)
@@ -360,19 +361,19 @@ static inline int unload_shm_buffer(struct buffer_info *info)
new_id = strdup(SCHEMA_SHM "-1");
if (!new_id) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
if (sscanf(info->id, SCHEMA_SHM "%d", &id) != 1) {
ErrPrint("%s Invalid ID\n", info->id);
DbgFree(new_id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (id < 0) {
ErrPrint("(%s) Invalid id: %d\n", info->id, id);
DbgFree(new_id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (shmdt(info->buffer) < 0) {
@@ -387,7 +388,7 @@ static inline int unload_shm_buffer(struct buffer_info *info)
DbgFree(info->id);
info->id = new_id;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI int buffer_handler_unload(struct buffer_info *info)
@@ -396,12 +397,12 @@ EAPI int buffer_handler_unload(struct buffer_info *info)
if (!info) {
ErrPrint("buffer handler is NIL\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (!info->is_loaded) {
ErrPrint("Buffer is not loaded\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
switch (info->type) {
@@ -416,7 +417,7 @@ EAPI int buffer_handler_unload(struct buffer_info *info)
case BUFFER_TYPE_PIXMAP:
default:
ErrPrint("Invalid buffer\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
break;
}
@@ -487,7 +488,7 @@ EAPI void *buffer_handler_pixmap_find(int pixmap)
EAPI int buffer_handler_pixmap_release_buffer(void *canvas)
{
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
/*!
@@ -498,7 +499,7 @@ EAPI int buffer_handler_pixmap_release_buffer(void *canvas)
*/
EAPI int buffer_handler_pixmap_unref(void *buffer_ptr)
{
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI int buffer_handler_is_loaded(const struct buffer_info *info)
@@ -522,19 +523,19 @@ EAPI int buffer_handler_resize(struct buffer_info *info, int w, int h)
if (!info) {
ErrPrint("Invalid handler\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (info->w == w && info->h == h) {
DbgPrint("No changes\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
buffer_handler_update_size(info, w, h);
if (!info->is_loaded) {
DbgPrint("Buffer size is updated[%dx%d]\n", w, h);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
ret = buffer_handler_unload(info);
@@ -547,13 +548,13 @@ EAPI int buffer_handler_resize(struct buffer_info *info, int w, int h)
ErrPrint("Load: %d\n", ret);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
{
if (!info) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (w) {
@@ -563,7 +564,7 @@ EAPI int buffer_handler_get_size(struct buffer_info *info, int *w, int *h)
*h = info->h;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI struct inst_info *buffer_handler_instance(struct buffer_info *info)
@@ -618,10 +619,10 @@ HAPI int buffer_handler_init(void)
*/
if (USE_SW_BACKEND) {
DbgPrint("Fallback to the S/W Backend\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int buffer_handler_fini(void)
@@ -630,7 +631,7 @@ HAPI int buffer_handler_fini(void)
* \TODO
* Implement this for wayland
*/
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline struct buffer *raw_open_file(const char *filename)
@@ -745,7 +746,7 @@ EAPI void *buffer_handler_raw_data(struct buffer *buffer)
EAPI int buffer_handler_raw_size(struct buffer *buffer)
{
if (!buffer || buffer->state != CREATED) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
return (int)buffer->info;
@@ -784,7 +785,7 @@ EAPI int buffer_handler_raw_close(struct buffer *buffer)
break;
case BUFFER_TYPE_PIXMAP:
default:
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
break;
}
@@ -794,11 +795,11 @@ EAPI int buffer_handler_raw_close(struct buffer *buffer)
EAPI int buffer_handler_lock(struct buffer_info *buffer)
{
if (buffer->type == BUFFER_TYPE_PIXMAP) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
if (buffer->type == BUFFER_TYPE_FILE) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
return do_buffer_lock(buffer);
@@ -807,11 +808,11 @@ EAPI int buffer_handler_lock(struct buffer_info *buffer)
EAPI int buffer_handler_unlock(struct buffer_info *buffer)
{
if (buffer->type == BUFFER_TYPE_PIXMAP) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
if (buffer->type == BUFFER_TYPE_FILE) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
return do_buffer_unlock(buffer);
@@ -827,11 +828,11 @@ HAPI int buffer_handler_set_data(struct buffer_info *buffer, void *data)
{
if (!buffer) {
ErrPrint("Invalid handle\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
buffer->data = data;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void *buffer_handler_data(struct buffer_info *buffer)
@@ -851,16 +852,16 @@ HAPI int buffer_handler_destroy(struct buffer_info *info)
if (!info) {
DbgPrint("Buffer is not created yet. info is NIL\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
buffer_handler_unload(info);
DbgFree(info->id);
DbgFree(info);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buffer_type type, int w, int h, int pixel_size)
+HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buffer_type type, int w, int h, int pixel_size, int auto_align)
{
struct buffer_info *info;
@@ -914,6 +915,7 @@ HAPI struct buffer_info *buffer_handler_create(struct inst_info *inst, enum buff
info->inst = inst;
info->buffer = NULL;
info->data = NULL;
+ info->auto_align = auto_align;
return info;
}
diff --git a/src/client_life.c b/src/client_life.c
index d01dc2a..edb5048 100644
--- a/src/client_life.c
+++ b/src/client_life.c
@@ -16,13 +16,19 @@
#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 <dlog.h>
#include <packet.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
#include "client_life.h"
#include "instance.h"
@@ -96,6 +102,7 @@ struct client_node {
Eina_List *subscribe_list;
int faulted;
+ char *direct_addr;
};
static inline void invoke_global_destroyed_cb(struct client_node *client)
@@ -234,6 +241,11 @@ static inline void destroy_client_data(struct client_node *client)
s_info.nr_of_paused_clients--;
}
+ if (client->direct_addr) {
+ (void)unlink(client->direct_addr);
+ DbgFree(client->direct_addr);
+ }
+
s_info.client_list = eina_list_remove(s_info.client_list, client);
DbgFree(client);
@@ -245,7 +257,7 @@ static inline void destroy_client_data(struct client_node *client)
xmonitor_handle_state_changes();
}
-static inline struct client_node *create_client_data(pid_t pid)
+static inline struct client_node *create_client_data(pid_t pid, const char *direct_addr)
{
struct client_node *client;
@@ -258,6 +270,13 @@ static inline struct client_node *create_client_data(pid_t pid)
client->pid = pid;
client->refcnt = 1;
+ 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);
/*!
@@ -293,7 +312,7 @@ static Eina_Bool created_cb(void *data)
* 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)
+HAPI struct client_node *client_create(pid_t pid, int handle, const char *direct_addr)
{
struct client_node *client;
int ret;
@@ -304,7 +323,7 @@ HAPI struct client_node *client_create(pid_t pid, int handle)
return client;
}
- client = create_client_data(pid);
+ client = create_client_data(pid, direct_addr);
if (!client) {
ErrPrint("Failed to create a new client (%d)\n", pid);
return NULL;
@@ -468,13 +487,13 @@ HAPI int client_event_callback_add(struct client_node *client, enum client_event
if (!cb) {
ErrPrint("Invalid callback (cb == NULL)\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
item->cb = cb;
@@ -508,10 +527,10 @@ HAPI int client_event_callback_add(struct client_node *client, enum client_event
break;
default:
DbgFree(item);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int client_event_callback_del(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data)
@@ -522,7 +541,7 @@ HAPI int client_event_callback_del(struct client_node *client, enum client_event
if (!cb) {
ErrPrint("Invalid callback (cb == NULL)\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
switch (event) {
@@ -535,7 +554,7 @@ HAPI int client_event_callback_del(struct client_node *client, enum client_event
client->event_deactivate_list = eina_list_remove(client->event_deactivate_list, item);
DbgFree(item);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
@@ -549,7 +568,7 @@ HAPI int client_event_callback_del(struct client_node *client, enum client_event
client->event_activate_list = eina_list_remove(client->event_activate_list, item);
DbgFree(item);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
@@ -559,7 +578,7 @@ HAPI int client_event_callback_del(struct client_node *client, enum client_event
break;
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
HAPI int client_set_data(struct client_node *client, const char *tag, void *data)
@@ -569,20 +588,20 @@ HAPI int client_set_data(struct client_node *client, const char *tag, void *data
item = calloc(1, sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
item->tag = strdup(tag);
if (!item->tag) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(item);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
item->data = data;
client->data_list = eina_list_append(client->data_list, item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void *client_data(struct client_node *client, const char *tag)
@@ -641,7 +660,7 @@ HAPI void client_resumed(struct client_node *client)
HAPI int client_init(void)
{
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void client_fini(void)
@@ -671,7 +690,7 @@ HAPI int client_global_event_handler_add(enum client_global_event event_type, in
handler = malloc(sizeof(*handler));
if (!handler) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
handler->cbdata = data;
@@ -687,10 +706,10 @@ HAPI int client_global_event_handler_add(enum client_global_event event_type, in
break;
default:
DbgFree(handler);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int client_global_event_handler_del(enum client_global_event event_type, int (*cb)(struct client_node *, void *), void *data)
@@ -709,7 +728,7 @@ HAPI int client_global_event_handler_del(enum client_global_event event_type, in
s_info.create_event_list = eina_list_remove(s_info.create_event_list, item);
DbgFree(item);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
@@ -722,7 +741,7 @@ HAPI int client_global_event_handler_del(enum client_global_event event_type, in
s_info.destroy_event_list = eina_list_remove(s_info.destroy_event_list, item);
DbgFree(item);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
@@ -730,7 +749,7 @@ HAPI int client_global_event_handler_del(enum client_global_event event_type, in
break;
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
HAPI int client_subscribe(struct client_node *client, const char *cluster, const char *category)
@@ -740,14 +759,14 @@ HAPI int client_subscribe(struct client_node *client, const char *cluster, const
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
item->cluster = strdup(cluster);
if (!item->cluster) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(item);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
item->category = strdup(category);
@@ -755,11 +774,11 @@ HAPI int client_subscribe(struct client_node *client, const char *cluster, const
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(item->cluster);
DbgFree(item);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
client->subscribe_list = eina_list_append(client->subscribe_list, item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int client_unsubscribe(struct client_node *client, const char *cluster, const char *category)
@@ -774,11 +793,11 @@ HAPI int client_unsubscribe(struct client_node *client, const char *cluster, con
DbgFree(item->cluster);
DbgFree(item->category);
DbgFree(item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
HAPI int client_is_subscribed(struct client_node *client, const char *cluster, const char *category)
@@ -814,7 +833,7 @@ HAPI int client_browse_list(const char *cluster, const char *category, int (*cb)
int cnt;
if (!cb || !cluster || !category) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
cnt = 0;
@@ -824,7 +843,7 @@ HAPI int client_browse_list(const char *cluster, const char *category, int (*cb)
}
if (cb(client, data) < 0) {
- return LB_STATUS_ERROR_CANCEL;
+ return DBOX_STATUS_ERROR_CANCEL;
}
cnt++;
@@ -864,7 +883,12 @@ HAPI int client_broadcast(struct inst_info *inst, struct packet *packet)
}
packet_unref(packet);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+HAPI const char *client_direct_addr(const struct client_node *client)
+{
+ return client ? client->direct_addr : NULL;
}
/* End of a file */
diff --git a/src/client_rpc.c b/src/client_rpc.c
index a9b00f4..fb9c99f 100644
--- a/src/client_rpc.c
+++ b/src/client_rpc.c
@@ -23,7 +23,9 @@
#include <dlog.h>
#include <com-core_packet.h>
#include <packet.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_conf.h>
+#include <dynamicbox_service.h>
#include "client_life.h"
#include "instance.h"
@@ -151,7 +153,7 @@ static inline void push_command(struct command *command)
return;
}
- s_info.command_consumer = ecore_timer_add(PACKET_TIME, command_consumer_cb, NULL);
+ s_info.command_consumer = ecore_timer_add(DYNAMICBOX_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);
@@ -165,13 +167,13 @@ HAPI int client_rpc_async_request(struct client_node *client, struct packet *pac
struct client_rpc *rpc;
if (!client || !packet) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (client_is_faulted(client)) {
ErrPrint("Client[%p] is faulted\n", client);
packet_unref(packet);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
rpc = client_data(client, RPC_TAG);
@@ -182,12 +184,12 @@ HAPI int client_rpc_async_request(struct client_node *client, struct packet *pac
command = create_command(client, packet);
if (!command) {
packet_unref(packet);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
push_command(command);
packet_unref(packet);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int deactivated_cb(struct client_node *client, void *data)
@@ -200,7 +202,7 @@ static int deactivated_cb(struct client_node *client, void *data)
rpc = client_data(client, RPC_TAG);
if (!rpc) {
ErrPrint("client is not valid\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
DbgPrint("Reset handle for %d\n", client_pid(client));
@@ -215,7 +217,7 @@ static int deactivated_cb(struct client_node *client, void *data)
}
DbgPrint("End: Destroying command\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int client_rpc_init(struct client_node *client, int handle)
@@ -226,7 +228,7 @@ HAPI int client_rpc_init(struct client_node *client, int handle)
rpc = calloc(1, sizeof(*rpc));
if (!rpc) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
ret = client_set_data(client, RPC_TAG, rpc);
@@ -259,12 +261,12 @@ HAPI int client_rpc_fini(struct client_node *client)
rpc = client_del_data(client, RPC_TAG);
if (!rpc) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, deactivated_cb, NULL);
DbgFree(rpc);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int client_rpc_handle(struct client_node *client)
@@ -274,7 +276,7 @@ HAPI int client_rpc_handle(struct client_node *client)
rpc = client_data(client, RPC_TAG);
if (!rpc) {
DbgPrint("Client has no RPC\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
return rpc->handle;
diff --git a/src/conf.c b/src/conf.c
index 53941ca..8f52983 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -1,953 +1,8 @@
-/*
- * 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 <errno.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include <dlog.h>
-#if defined(HAVE_LIVEBOX)
-#include <livebox-errno.h>
-#else
-#include "lite-errno.h"
-#endif
-#include <Eina.h>
-
#include "conf.h"
-#include "util.h"
-#include "debug.h"
-
-static const char *CONF_DEFAULT_SERVICES = "[livebox],[shortcut],[notification],[badge],[utility],[file]";
-static const char *CONF_DEFAULT_EMERGENCY_DISK = "source=tmpfs;type=tmpfs;option=size=6M";
-static const char *CONF_DEFAULT_PATH_CONF = "/opt/usr/live/%s/etc/%s.conf";
-static const char *CONF_DEFAULT_PATH_IMAGE = "/opt/usr/share/live_magazine/";
-static const char *CONF_DEFAULT_PATH_LOG = "/opt/usr/share/live_magazine/log";
-static const char *CONF_DEFAULT_PATH_READER = "/opt/usr/share/live_magazine/reader";
-static const char *CONF_DEFAULT_PATH_ALWAYS = "/opt/usr/share/live_magazine/always";
-static const char *CONF_DEFAULT_PATH_SCRIPT = "/opt/usr/live/%s/res/script/%s.edj";
-static const char *CONF_DEFAULT_PATH_ROOT = "/opt/usr/live/";
-static const char *CONF_DEFAULT_PATH_SCRIPT_PORT = "/usr/share/data-provider-master/plugin-script/";
-static const char *CONF_DEFAULT_PATH_DB = "/opt/dbspace/.livebox.db";
-static const char *CONF_DEFAULT_PATH_INPUT = "/dev/input/event2";
-static const char *CONF_DEFAULT_SCRIPT_TYPE = "edje";
-static const char *CONF_DEFAULT_ABI = "c";
-static const char *CONF_DEFAULT_PD_GROUP = "disclosure";
-static const char *CONF_DEFAULT_LAUNCH_BUNDLE_NAME = "name";
-static const char *CONF_DEFAULT_LAUNCH_BUNDLE_SECURED = "secured";
-static const char *CONF_DEFAULT_LAUNCH_BUNDLE_ABI = "abi";
-static const char *CONF_DEFAULT_CONTENT = "default";
-static const char *CONF_DEFAULT_TITLE = "";
-static const char *CONF_DEFAULT_EMPTY_CONTENT = "";
-static const char *CONF_DEFAULT_EMPTY_TITLE = "";
-static const char *CONF_DEFAULT_REPLACE_TAG = "/APPID/";
-static const char *CONF_DEFAULT_PROVIDER_METHOD = "pixmap";
-static const int CONF_DEFAULT_WIDTH = 0;
-static const int CONF_DEFAULT_HEIGHT = 0;
-static const int CONF_DEFAULT_BASE_WIDTH = 720;
-static const int CONF_DEFAULT_BASE_HEIGHT = 1280;
-static const double CONF_DEFAULT_MINIMUM_PERIOD = 1.0f;
-static const double CONF_DEFAULT_PERIOD = -1.0f;
-static const double CONF_DEFAULT_PACKET_TIME = 0.0001f;
-static const unsigned long CONF_DEFAULT_MINIMUM_SPACE = 5242880;
-static const double CONF_DEFAULT_SLAVE_TTL = 30.0f;
-static const double CONF_DEFAULT_SLAVE_ACTIVATE_TIME = 30.0f;
-static const double CONF_DEFAULT_SLAVE_RELAUNCH_TIME = 3.0f;
-static const int CONF_DEFAULT_SLAVE_RELAUNCH_COUNT = 3;
-static const int CONF_DEFAULT_MAX_LOG_LINE = 1000;
-static const int CONF_DEFAULT_MAX_LOG_FILE = 3;
-static const int CONF_DEFAULT_SQLITE_FLUSH_MAX = 1048576;
-static const double CONF_DEFAULT_PING_TIME = 240.0f;
-static const int CONF_DEFAULT_SLAVE_MAX_LOAD = 30;
-static const int CONF_DEFAULT_USE_SW_BACKEND = 0;
-static const int CONF_DEFAULT_DEBUG_MODE = 0;
-static const int CONF_DEFAULT_OVERWRITE_CONTENT = 0;
-static const int CONF_DEFAULT_COM_CORE_THREAD = 1;
-static const int CONF_DEFAULT_USE_XMONITOR = 0;
-static const int CONF_DEFAULT_PREMULTIPLIED = 1;
-static const double CONF_DEFAULT_SCALE_WIDTH_FACTOR = 1.0f;
-static const double CONF_DEFAULT_SCALE_HEIGHT_FACTOR = 1.0f;
-static const double CONF_DEFAULT_PD_REQUEST_TIMEOUT = 5.0f;
-static const int CONF_DEFAULT_PIXELS = sizeof(int);
-
-int errno;
-
-HAPI struct conf g_conf;
-
-HAPI void conf_update_size(void)
-{
- util_screen_size_get(&g_conf.width, &g_conf.height);
-
- g_conf.scale_width_factor = (double)g_conf.width / (double)BASE_W;
- g_conf.scale_height_factor = (double)g_conf.height / (double)BASE_H;
-}
-
-static void use_xmonitor(char *buffer)
-{
- g_conf.use_xmonitor = !strcasecmp(buffer, "true");
-}
-
-static void emergency_disk_handler(char *buffer)
-{
- g_conf.emergency_disk = strdup(buffer);
- if (!g_conf.emergency_disk) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void services_handler(char *buffer)
-{
- g_conf.services = strdup(buffer);
- if (!g_conf.services) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void use_sw_backend_handler(char *buffer)
-{
- g_conf.use_sw_backend = !strcasecmp(buffer, "true");
-}
-
-static void provider_method_handler(char *buffer)
-{
- g_conf.provider_method = strdup(buffer);
- if (!g_conf.provider_method) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void debug_mode_handler(char *buffer)
-{
- g_conf.debug_mode = !strcasecmp(buffer, "true");
-}
-
-static void overwrite_content_handler(char *buffer)
-{
- g_conf.overwrite_content = !strcasecmp(buffer, "true");
-}
-
-static void com_core_thread_handler(char *buffer)
-{
- g_conf.com_core_thread = !strcasecmp(buffer, "true");
-}
-
-static void base_width_handler(char *buffer)
-{
- if (sscanf(buffer, "%d", &g_conf.base_width) != 1) {
- ErrPrint("Failed to parse the base_width\n");
- }
-}
-
-static void base_height_handler(char *buffer)
-{
- if (sscanf(buffer, "%d", &g_conf.base_height) != 1) {
- ErrPrint("Failed to parse the base_height\n");
- }
-}
-
-static void minimum_period_handler(char *buffer)
-{
- if (sscanf(buffer, "%lf", &g_conf.minimum_period) != 1) {
- ErrPrint("Failed to parse the minimum_period\n");
- }
- DbgPrint("Minimum period: %lf\n", g_conf.minimum_period);
-}
-
-static void pixels_handler(char *buffer)
-{
- if (sscanf(buffer, "%d", &g_conf.default_conf.pixels) != 1) {
- ErrPrint("Failed to parse the minimum_period\n");
- }
- DbgPrint("Default pixels: %lf\n", g_conf.default_conf.pixels);
-}
-
-static void script_handler(char *buffer)
-{
- g_conf.default_conf.script = strdup(buffer);
- if (!g_conf.default_conf.script) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void default_abi_handler(char *buffer)
-{
- g_conf.default_conf.abi = strdup(buffer);
- if (!g_conf.default_conf.abi) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void default_group_handler(char *buffer)
-{
- g_conf.default_conf.pd_group = strdup(buffer);
- if (!g_conf.default_conf.pd_group) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void default_period_handler(char *buffer)
-{
- if (sscanf(buffer, "%lf", &g_conf.default_conf.period) != 1) {
- ErrPrint("Failed to parse the default_period\n");
- }
- DbgPrint("Default Period: %lf\n", g_conf.default_conf.period);
-}
-
-static void default_packet_time_handler(char *buffer)
-{
- if (sscanf(buffer, "%lf", &g_conf.default_packet_time) != 1) {
- ErrPrint("Failed to parse the default_packet_time\n");
- }
- DbgPrint("Default packet time: %lf\n", g_conf.default_packet_time);
-}
-
-static void default_content_handler(char *buffer)
-{
- g_conf.default_content = strdup(buffer);
- if (!g_conf.default_content) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void default_title_handler(char *buffer)
-{
- g_conf.default_title = strdup(buffer);
- if (!g_conf.default_title) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void minimum_space_handler(char *buffer)
-{
- if (sscanf(buffer, "%lu", &g_conf.minimum_space) != 1) {
- ErrPrint("Failed to parse the minimum_space\n");
- }
-}
-
-static void replace_tag_handler(char *buffer)
-{
- g_conf.replace_tag = strdup(buffer);
- if (!g_conf.replace_tag) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void slave_ttl_handler(char *buffer)
-{
- if (sscanf(buffer, "%lf", &g_conf.slave_ttl) != 1) {
- ErrPrint("Failed to parse the slave_ttl\n");
- }
- DbgPrint("Slave TTL: %lf\n", g_conf.slave_ttl);
-}
-
-static void slave_activate_time_handler(char *buffer)
-{
- if (sscanf(buffer, "%lf", &g_conf.slave_activate_time) != 1) {
- ErrPrint("Failed to parse the slave_activate_time\n");
- }
- DbgPrint("Slave activate time: %lf\n", g_conf.slave_activate_time);
-}
-
-static void slave_relaunch_time_handler(char *buffer)
-{
- if (sscanf(buffer, "%lf", &g_conf.slave_relaunch_time) != 1) {
- ErrPrint("Failed to parse the slave_activate_time\n");
- }
- DbgPrint("Slave relaunch time: %lf\n", g_conf.slave_relaunch_time);
-}
-
-static void slave_relaunch_count_handler(char *buffer)
-{
- if (sscanf(buffer, "%d", &g_conf.slave_relaunch_count) != 1) {
- ErrPrint("Failed to parse the max_log_line\n");
- }
-}
-
-static void max_log_line_handler(char *buffer)
-{
- if (sscanf(buffer, "%d", &g_conf.max_log_line) != 1) {
- ErrPrint("Failed to parse the max_log_line\n");
- }
-}
-
-static void max_log_file_handler(char *buffer)
-{
- if (sscanf(buffer, "%d", &g_conf.max_log_file) != 1) {
- ErrPrint("Failed to parse the max_log_file\n");
- }
-}
-
-static void sqlite_flush_max_handler(char *buffer)
-{
- if (sscanf(buffer, "%lu", &g_conf.sqlite_flush_max) != 1) {
- ErrPrint("Failed to parse the sqlite_flush_max\n");
- }
-}
-
-static void db_path_handler(char *buffer)
-{
- g_conf.path.db = strdup(buffer);
- if (!g_conf.path.db) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void reader_path_handler(char *buffer)
-{
- g_conf.path.reader = strdup(buffer);
- if (!g_conf.path.reader) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void always_path_handler(char *buffer)
-{
- g_conf.path.always = strdup(buffer);
- if (!g_conf.path.always) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void log_path_handler(char *buffer)
-{
- g_conf.path.slave_log = strdup(buffer);
- if (!g_conf.path.slave_log) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void script_port_path_handler(char *buffer)
-{
- g_conf.path.script_port = strdup(buffer);
- if (!g_conf.path.script_port) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void share_path_handler(char *buffer)
-{
- g_conf.path.image = strdup(buffer);
- if (!g_conf.path.image) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void input_path_handler(char *buffer)
-{
- g_conf.path.input = strdup(buffer);
- if (!g_conf.path.input) {
- ErrPrint("Heap: %s\n", strerror(errno));
- }
-}
-
-static void ping_time_handler(char *buffer)
-{
- if (sscanf(buffer, "%lf", &g_conf.ping_time) != 1) {
- ErrPrint("Failed to parse the ping_time\n");
- }
- DbgPrint("Default ping time: %lf\n", g_conf.ping_time);
-}
-
-static void slave_max_loader(char *buffer)
-{
- if (sscanf(buffer, "%d", &g_conf.slave_max_load) != 1) {
- ErrPrint("Failed to parse the slave_max_load\n");
- }
-}
-
-static void premultiplied_handler(char *buffer)
-{
- if (sscanf(buffer, "%d", &g_conf.premultiplied) != 1) {
- ErrPrint("Failed to parse the premultiplied color\n");
- }
-
- DbgPrint("Premultiplied: %d\n", g_conf.premultiplied);
-}
-
-static void pd_request_timeout_handler(char *buffer)
-{
- if (sscanf(buffer, "%lf", &g_conf.pd_request_timeout) != 1) {
- ErrPrint("Failed to parse the request_timeout\n");
- }
- DbgPrint("Default PD request timeout: %lf\n", g_conf.pd_request_timeout);
-}
-
-HAPI void conf_init(void)
-{
- g_conf.width = CONF_DEFAULT_WIDTH;
- g_conf.height = CONF_DEFAULT_HEIGHT;
- g_conf.base_width = CONF_DEFAULT_BASE_WIDTH;
- g_conf.base_height = CONF_DEFAULT_BASE_HEIGHT;
- g_conf.minimum_period = CONF_DEFAULT_MINIMUM_PERIOD;
- g_conf.default_conf.period = CONF_DEFAULT_PERIOD;
- g_conf.default_conf.pixels = CONF_DEFAULT_PIXELS;
- g_conf.minimum_space = CONF_DEFAULT_MINIMUM_SPACE;
- g_conf.default_packet_time = CONF_DEFAULT_PACKET_TIME;
- g_conf.slave_ttl = CONF_DEFAULT_SLAVE_TTL;
- g_conf.slave_activate_time = CONF_DEFAULT_SLAVE_ACTIVATE_TIME;
- g_conf.slave_relaunch_time = CONF_DEFAULT_SLAVE_RELAUNCH_TIME;
- g_conf.slave_relaunch_count = CONF_DEFAULT_SLAVE_RELAUNCH_COUNT;
- g_conf.max_log_line = CONF_DEFAULT_MAX_LOG_LINE;
- g_conf.max_log_file = CONF_DEFAULT_MAX_LOG_FILE;
- g_conf.sqlite_flush_max = CONF_DEFAULT_SQLITE_FLUSH_MAX;
- g_conf.ping_time = CONF_DEFAULT_PING_TIME;
- g_conf.slave_max_load = CONF_DEFAULT_SLAVE_MAX_LOAD;
- g_conf.use_sw_backend = CONF_DEFAULT_USE_SW_BACKEND;
- g_conf.debug_mode = CONF_DEFAULT_DEBUG_MODE;
- g_conf.overwrite_content = CONF_DEFAULT_OVERWRITE_CONTENT;
- g_conf.com_core_thread = CONF_DEFAULT_COM_CORE_THREAD;
- g_conf.use_xmonitor = CONF_DEFAULT_USE_XMONITOR;
- g_conf.scale_width_factor = CONF_DEFAULT_SCALE_WIDTH_FACTOR;
- g_conf.scale_height_factor = CONF_DEFAULT_SCALE_HEIGHT_FACTOR;
- g_conf.pd_request_timeout = CONF_DEFAULT_PD_REQUEST_TIMEOUT;
- g_conf.premultiplied = CONF_DEFAULT_PREMULTIPLIED;
- g_conf.default_conf.script = (char *)CONF_DEFAULT_SCRIPT_TYPE;
- g_conf.default_conf.abi = (char *)CONF_DEFAULT_ABI;
- g_conf.default_conf.pd_group = (char *)CONF_DEFAULT_PD_GROUP;
- g_conf.launch_key.name = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_NAME;
- g_conf.launch_key.secured = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_SECURED;
- g_conf.launch_key.abi = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_ABI;
- g_conf.empty_content = (char *)CONF_DEFAULT_EMPTY_CONTENT;
- g_conf.empty_title = (char *)CONF_DEFAULT_EMPTY_TITLE;
- g_conf.default_content = (char *)CONF_DEFAULT_CONTENT;
- g_conf.default_title = (char *)CONF_DEFAULT_TITLE;
- g_conf.replace_tag = (char *)CONF_DEFAULT_REPLACE_TAG;
- g_conf.path.conf = (char *)CONF_DEFAULT_PATH_CONF;
- g_conf.path.image = (char *)CONF_DEFAULT_PATH_IMAGE;
- g_conf.path.slave_log = (char *)CONF_DEFAULT_PATH_LOG;
- g_conf.path.reader = (char *)CONF_DEFAULT_PATH_READER;
- g_conf.path.always = (char *)CONF_DEFAULT_PATH_ALWAYS;
- g_conf.path.script = (char *)CONF_DEFAULT_PATH_SCRIPT;
- g_conf.path.root = (char *)CONF_DEFAULT_PATH_ROOT;
- g_conf.path.script_port = (char *)CONF_DEFAULT_PATH_SCRIPT_PORT;
- g_conf.path.db = (char *)CONF_DEFAULT_PATH_DB;
- g_conf.path.input = (char *)CONF_DEFAULT_PATH_INPUT;
- g_conf.provider_method = (char *)CONF_DEFAULT_PROVIDER_METHOD;
- g_conf.emergency_disk = (char *)CONF_DEFAULT_EMERGENCY_DISK;
- g_conf.services = (char *)CONF_DEFAULT_SERVICES;
-}
-
-HAPI int conf_loader(void)
-{
- 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 linelen;
- char buffer[256];
- static const struct token_parser {
- const char *name;
- void (*handler)(char *buffer);
- } token_handler[] = {
- {
- .name = "base_width",
- .handler = base_width_handler,
- },
- {
- .name = "base_height",
- .handler = base_height_handler,
- },
- {
- .name = "minimum_period",
- .handler = minimum_period_handler,
- },
- {
- .name = "script",
- .handler = script_handler,
- },
- {
- .name = "pixels",
- .handler = pixels_handler,
- },
- {
- .name = "default_abi",
- .handler = default_abi_handler,
- },
- {
- .name = "default_group",
- .handler = default_group_handler,
- },
- {
- .name = "default_period",
- .handler = default_period_handler,
- },
- {
- .name = "default_packet_time",
- .handler = default_packet_time_handler,
- },
- {
- .name = "default_content",
- .handler = default_content_handler,
- },
- {
- .name = "default_title",
- .handler = default_title_handler,
- },
- {
- .name = "minimum_space",
- .handler = minimum_space_handler,
- },
- {
- .name = "replace_tag",
- .handler = replace_tag_handler,
- },
- {
- .name = "slave_ttl",
- .handler = slave_ttl_handler,
- },
- {
- .name = "slave_activate_time",
- .handler = slave_activate_time_handler,
- },
- {
- .name = "slave_relaunch_time",
- .handler = slave_relaunch_time_handler,
- },
- {
- .name = "slave_relaunch_count",
- .handler = slave_relaunch_count_handler,
- },
- {
- .name = "max_log_line",
- .handler = max_log_line_handler,
- },
- {
- .name = "max_log_file",
- .handler = max_log_file_handler,
- },
- {
- .name = "sqilte_flush_max",
- .handler = sqlite_flush_max_handler,
- },
- {
- .name = "db_path",
- .handler = db_path_handler,
- },
- {
- .name = "log_path",
- .handler = log_path_handler,
- },
- {
- .name = "reader_path",
- .handler = reader_path_handler,
- },
- {
- .name = "always_path",
- .handler = always_path_handler,
- },
- {
- .name = "share_path",
- .handler = share_path_handler,
- },
- {
- .name = "script_port_path",
- .handler = script_port_path_handler,
- },
- {
- .name = "ping_interval",
- .handler = ping_time_handler,
- },
- {
- .name = "slave_max_load",
- .handler = slave_max_loader,
- },
- {
- .name = "use_sw_backend",
- .handler = use_sw_backend_handler,
- },
- {
- .name = "emergency_disk",
- .handler = emergency_disk_handler,
- },
- {
- .name = "services",
- .handler = services_handler,
- },
- {
- .name = "use_xmonitor",
- .handler = use_xmonitor,
- },
- {
- .name = "provider_method",
- .handler = provider_method_handler,
- },
- {
- .name = "debug_mode",
- .handler = debug_mode_handler,
- },
- {
- .name = "overwrite_content",
- .handler = overwrite_content_handler,
- },
- {
- .name = "com_core_thread",
- .handler = com_core_thread_handler,
- },
- {
- .name = "input",
- .handler = input_path_handler,
- },
- {
- .name = "pd_request_timeout",
- .handler = pd_request_timeout_handler,
- },
- {
- .name = "premultiplied",
- .handler = premultiplied_handler,
- },
- {
- .name = NULL,
- .handler = NULL,
- },
- };
-
- fp = fopen(DEFAULT_MASTER_CONF, "rt");
- if (!fp) {
- ErrPrint("Error: %s\n", strerror(errno));
- return LB_STATUS_ERROR_IO;
- }
-
- state = START;
- ch_idx = 0;
- token_idx = -1;
- buffer_idx = 0;
- quote = 0;
- linelen = 0;
- do {
- c = getc(fp);
- if ((c == EOF) && (state == VALUE)) {
- DbgPrint("[%s:%d] VALUE state EOF\n", __func__, __LINE__);
- 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;
-
- if (token_idx >= 0 && token_handler[token_idx].handler) {
- buffer[buffer_idx] = '\0';
- token_handler[token_idx].handler(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: %s\n", strerror(errno));
- }
- return LB_STATUS_SUCCESS;
-}
-
-HAPI void conf_reset(void)
-{
- g_conf.width = CONF_DEFAULT_WIDTH;
- g_conf.height = CONF_DEFAULT_HEIGHT;
- g_conf.base_width = CONF_DEFAULT_BASE_WIDTH;
- g_conf.base_height = CONF_DEFAULT_BASE_HEIGHT;
- g_conf.minimum_period = CONF_DEFAULT_MINIMUM_PERIOD;
- g_conf.default_conf.period = CONF_DEFAULT_PERIOD;
- g_conf.minimum_space = CONF_DEFAULT_MINIMUM_SPACE;
- g_conf.default_packet_time = CONF_DEFAULT_PACKET_TIME;
- g_conf.slave_ttl = CONF_DEFAULT_SLAVE_TTL;
- g_conf.slave_activate_time = CONF_DEFAULT_SLAVE_ACTIVATE_TIME;
- g_conf.slave_relaunch_time = CONF_DEFAULT_SLAVE_RELAUNCH_TIME;
- g_conf.slave_relaunch_count = CONF_DEFAULT_SLAVE_RELAUNCH_COUNT;
- g_conf.max_log_line = CONF_DEFAULT_MAX_LOG_LINE;
- g_conf.max_log_file = CONF_DEFAULT_MAX_LOG_FILE;
- g_conf.sqlite_flush_max = CONF_DEFAULT_SQLITE_FLUSH_MAX;
- g_conf.ping_time = CONF_DEFAULT_PING_TIME;
- g_conf.slave_max_load = CONF_DEFAULT_SLAVE_MAX_LOAD;
- g_conf.use_sw_backend = CONF_DEFAULT_USE_SW_BACKEND;
- g_conf.debug_mode = CONF_DEFAULT_DEBUG_MODE;
- g_conf.overwrite_content = CONF_DEFAULT_OVERWRITE_CONTENT;
- g_conf.com_core_thread = CONF_DEFAULT_COM_CORE_THREAD;
- g_conf.use_xmonitor = CONF_DEFAULT_USE_XMONITOR;
- g_conf.scale_width_factor = CONF_DEFAULT_SCALE_WIDTH_FACTOR;
- g_conf.scale_height_factor = CONF_DEFAULT_SCALE_HEIGHT_FACTOR;
- g_conf.pd_request_timeout = CONF_DEFAULT_PD_REQUEST_TIMEOUT;
- g_conf.premultiplied = CONF_DEFAULT_PREMULTIPLIED;
- g_conf.default_conf.pixels = CONF_DEFAULT_PIXELS;
-
- if (g_conf.default_conf.script != CONF_DEFAULT_SCRIPT_TYPE) {
- DbgFree(g_conf.default_conf.script);
- g_conf.default_conf.script = (char *)CONF_DEFAULT_SCRIPT_TYPE;
- }
-
- if (g_conf.default_conf.abi != CONF_DEFAULT_ABI) {
- DbgFree(g_conf.default_conf.abi);
- g_conf.default_conf.abi = (char *)CONF_DEFAULT_ABI;
- }
-
- if (g_conf.default_conf.pd_group != CONF_DEFAULT_PD_GROUP) {
- DbgFree(g_conf.default_conf.pd_group);
- g_conf.default_conf.pd_group = (char *)CONF_DEFAULT_PD_GROUP;
- }
-
- if (g_conf.launch_key.name != CONF_DEFAULT_LAUNCH_BUNDLE_NAME) {
- DbgFree(g_conf.launch_key.name);
- g_conf.launch_key.name = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_NAME;
- }
-
- if (g_conf.launch_key.secured != CONF_DEFAULT_LAUNCH_BUNDLE_SECURED) {
- DbgFree(g_conf.launch_key.secured);
- g_conf.launch_key.secured = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_SECURED;
- }
-
- if (g_conf.launch_key.abi != CONF_DEFAULT_LAUNCH_BUNDLE_ABI) {
- DbgFree(g_conf.launch_key.abi);
- g_conf.launch_key.abi = (char *)CONF_DEFAULT_LAUNCH_BUNDLE_ABI;
- }
-
- if (g_conf.empty_content != CONF_DEFAULT_EMPTY_CONTENT) {
- DbgFree(g_conf.empty_content);
- g_conf.empty_content = (char *)CONF_DEFAULT_EMPTY_CONTENT;
- }
-
- if (g_conf.empty_title != CONF_DEFAULT_EMPTY_TITLE) {
- DbgFree(g_conf.empty_title);
- g_conf.empty_title = (char *)CONF_DEFAULT_EMPTY_TITLE;
- }
-
- if (g_conf.default_content != CONF_DEFAULT_CONTENT) {
- DbgFree(g_conf.default_content);
- g_conf.default_content = (char *)CONF_DEFAULT_CONTENT;
- }
-
- if (g_conf.default_title != CONF_DEFAULT_TITLE) {
- DbgFree(g_conf.default_title);
- g_conf.default_title = (char *)CONF_DEFAULT_TITLE;
- }
-
- if (g_conf.replace_tag != CONF_DEFAULT_REPLACE_TAG) {
- DbgFree(g_conf.replace_tag);
- g_conf.replace_tag = (char *)CONF_DEFAULT_REPLACE_TAG;
- }
-
- if (g_conf.path.conf != CONF_DEFAULT_PATH_CONF) {
- DbgFree(g_conf.path.conf);
- g_conf.path.conf = (char *)CONF_DEFAULT_PATH_CONF;
- }
-
- if (g_conf.path.image != CONF_DEFAULT_PATH_IMAGE) {
- DbgFree(g_conf.path.image);
- g_conf.path.image = (char *)CONF_DEFAULT_PATH_IMAGE;
- }
-
- if (g_conf.path.slave_log != CONF_DEFAULT_PATH_LOG) {
- DbgFree(g_conf.path.slave_log);
- g_conf.path.slave_log = (char *)CONF_DEFAULT_PATH_LOG;
- }
-
- if (g_conf.path.reader != CONF_DEFAULT_PATH_READER) {
- DbgFree(g_conf.path.reader);
- g_conf.path.reader = (char *)CONF_DEFAULT_PATH_READER;
- }
-
- if (g_conf.path.always != CONF_DEFAULT_PATH_ALWAYS) {
- DbgFree(g_conf.path.always);
- g_conf.path.always = (char *)CONF_DEFAULT_PATH_ALWAYS;
- }
-
- if (g_conf.path.script != CONF_DEFAULT_PATH_SCRIPT) {
- DbgFree(g_conf.path.script);
- g_conf.path.script = (char *)CONF_DEFAULT_PATH_SCRIPT;
- }
-
- if (g_conf.path.root != CONF_DEFAULT_PATH_ROOT) {
- DbgFree(g_conf.path.root);
- g_conf.path.root = (char *)CONF_DEFAULT_PATH_ROOT;
- }
-
- if (g_conf.path.script_port != CONF_DEFAULT_PATH_SCRIPT_PORT) {
- DbgFree(g_conf.path.script_port);
- g_conf.path.script_port = (char *)CONF_DEFAULT_PATH_SCRIPT_PORT;
- }
-
- if (g_conf.path.db != CONF_DEFAULT_PATH_DB) {
- DbgFree(g_conf.path.db);
- g_conf.path.db = (char *)CONF_DEFAULT_PATH_DB;
- }
-
- if (g_conf.path.input != CONF_DEFAULT_PATH_INPUT) {
- DbgFree(g_conf.path.input);
- g_conf.path.input = (char *)CONF_DEFAULT_PATH_INPUT;
- }
-
- if (g_conf.provider_method != CONF_DEFAULT_PROVIDER_METHOD) {
- DbgFree(g_conf.provider_method);
- g_conf.provider_method = (char *)CONF_DEFAULT_PROVIDER_METHOD;
- }
-
- if (g_conf.emergency_disk != CONF_DEFAULT_EMERGENCY_DISK) {
- DbgFree(g_conf.emergency_disk);
- g_conf.emergency_disk = (char *)CONF_DEFAULT_EMERGENCY_DISK;
- }
- if (g_conf.services != CONF_DEFAULT_SERVICES) {
- DbgFree(g_conf.services);
- g_conf.services = (char *)CONF_DEFAULT_SERVICES;
- }
-}
+struct conf g_conf = {
+ .debug_mode = 0,
+ .slave_max_load = -1,
+};
/* End of a file */
diff --git a/src/critical_log.c b/src/critical_log.c
index 6bf10d6..2ff1e7d 100644
--- a/src/critical_log.c
+++ b/src/critical_log.c
@@ -28,7 +28,8 @@
#include <dlog.h>
#include <Eina.h>
#if defined(HAVE_LIVEBOX)
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_conf.h>
#else
#include "lite-errno.h"
#endif
@@ -59,16 +60,16 @@ static inline void rotate_log(void)
char *filename;
int namelen;
- if (s_info.nr_of_lines < MAX_LOG_LINE) {
+ if (s_info.nr_of_lines < DYNAMICBOX_CONF_MAX_LOG_LINE) {
return;
}
- s_info.file_id = (s_info.file_id + 1) % MAX_LOG_FILE;
+ s_info.file_id = (s_info.file_id + 1) % DYNAMICBOX_CONF_MAX_LOG_FILE;
- namelen = strlen(s_info.filename) + strlen(SLAVE_LOG_PATH) + 30;
+ namelen = strlen(s_info.filename) + strlen(DYNAMICBOX_CONF_LOG_PATH) + 30;
filename = malloc(namelen);
if (filename) {
- snprintf(filename, namelen, "%s/%d_%s.%d", SLAVE_LOG_PATH, s_info.file_id, s_info.filename, getpid());
+ snprintf(filename, namelen, "%s/%d_%s.%d", DYNAMICBOX_CONF_LOG_PATH, s_info.file_id, s_info.filename, getpid());
if (s_info.fp) {
if (fclose(s_info.fp) != 0) {
@@ -95,7 +96,7 @@ HAPI int critical_log(const char *func, int line, const char *fmt, ...)
int ret;
if (!s_info.fp) {
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
CRITICAL_SECTION_BEGIN(&s_info.cri_lock);
@@ -123,26 +124,26 @@ HAPI int critical_log_init(const char *name)
char *filename;
if (s_info.fp) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
s_info.filename = strdup(name);
if (!s_info.filename) {
ErrPrint("Failed to create a log file\n");
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- namelen = strlen(name) + strlen(SLAVE_LOG_PATH) + 30;
+ namelen = strlen(name) + strlen(DYNAMICBOX_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 LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- snprintf(filename, namelen, "%s/%d_%s.%d", SLAVE_LOG_PATH, s_info.file_id, name, getpid());
+ snprintf(filename, namelen, "%s/%d_%s.%d", DYNAMICBOX_CONF_LOG_PATH, s_info.file_id, name, getpid());
s_info.fp = fopen(filename, "w+");
if (!s_info.fp) {
@@ -150,11 +151,11 @@ HAPI int critical_log_init(const char *name)
DbgFree(s_info.filename);
s_info.filename = NULL;
DbgFree(filename);
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
DbgFree(filename);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
diff --git a/src/dead_monitor.c b/src/dead_monitor.c
index 313327f..bd2a0ee 100644
--- a/src/dead_monitor.c
+++ b/src/dead_monitor.c
@@ -23,6 +23,7 @@
#include <dlog.h>
#include <Eina.h>
+#include <dynamicbox_service.h> /* destroy_type for instance.h */
#include "slave_life.h"
#include "client_life.h"
diff --git a/src/event.c b/src/event.c
index 0604c11..64f46ca 100644
--- a/src/event.c
+++ b/src/event.c
@@ -29,7 +29,8 @@
#include <Eina.h>
#include <Ecore.h>
#include <dlog.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_conf.h>
#include "util.h"
#include "debug.h"
@@ -37,13 +38,18 @@
#include "event.h"
#define EVENT_CH 'e'
+#define EVENT_EXIT 'x'
-#if !defined(ABS_MT_TOOL_X)
-#define ABS_MT_TOOL_X 0x3c /* Center X tool position */
-#endif
+#define PRESSURE 10
+#define DELAY_COMPENSATOR 0.1f
-#if !defined(ABS_MT_TOOL_Y)
-#define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */
+#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;
@@ -58,13 +64,20 @@ static struct info {
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,
@@ -74,105 +87,369 @@ static struct info {
.keycode = 0,
},
+ .skipped_event_data = {
+ .x = -1,
+ .y = -1,
+ .device = -1,
+ .slot = -1,
+ .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;
-#if defined(_USE_ECORE_TIME_GET)
double tv;
-#else
- struct timeval tv; /* Recording Activate / Deactivate time */
-#endif
int x; /* RelX */
int y; /* RelY */
};
-static int activate_thread(void);
+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: %s\n", strerror(ret));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- return LB_STATUS_SUCCESS;
+
+ return DBOX_STATUS_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 failed: %s\n", strerror(ret));
}
- return LB_STATUS_SUCCESS;
+
+ return DBOX_STATUS_ERROR_NONE;
}
-static inline int processing_input_event(struct input_event *event)
+/*
+ * This function can be called Event Thread.
+ */
+static int push_event_item(void)
{
struct event_data *item;
- switch (event->type) {
- case EV_SYN:
- switch (event->code) {
- break;
- case SYN_CONFIG:
- break;
- case SYN_MT_REPORT:
- case SYN_REPORT:
- if (s_info.event_data.x < 0 || s_info.event_data.y < 0) {
- /* Waiting full event packet */
- break;
- }
+ if (s_info.event_data.x < 0 || s_info.event_data.y < 0) {
+ /* Waiting full event packet */
+ return DBOX_STATUS_ERROR_NONE;
+ }
- item = malloc(sizeof(*item));
- if (item) {
- char event_ch = EVENT_CH;
+ item = malloc(sizeof(*item));
+ if (item) {
+ char event_ch = EVENT_CH;
-#if defined(_USE_ECORE_TIME_GET)
- s_info.event_data.tv = ecore_time_get();
-#else
- if (gettimeofday(&s_info.event_data.tv, NULL) < 0) {
- ErrPrint("gettimeofday: %s\n", strerror(errno));
- }
+ 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("Unable to send an event: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_IO_ERROR;
+ }
+
+ /* Take a breathe */
+ pthread_yield();
+ } else {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+static double current_time_get(void)
+{
+ double ret;
+
+ if (DYNAMICBOX_CONF_USE_GETTIMEOFDAY) {
+ struct timeval tv;
+ if (gettimeofday(&tv, NULL) < 0) {
+ ErrPrint("gettimeofday: %s\n", strerror(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;
+ }
- memcpy(item, &s_info.event_data, sizeof(*item));
+ return;
+}
- 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);
+/*
+ * Called by Event Thread
+ */
+static inline int processing_input_event(struct input_event *event)
+{
+ int ret;
- if (write(s_info.evt_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
- ErrPrint("Unable to send an event: %s\n", strerror(errno));
- return LB_STATUS_ERROR_IO;
- }
+ if (s_info.timestamp_updated == 0) {
+ update_timestamp(event);
+ }
- /* Take a breathe */
- pthread_yield();
- } else {
- ErrPrint("Heap: %s\n", strerror(errno));
+ 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;
}
- if (s_info.event_data.device < 0) {
- s_info.event_data.x = -1;
- s_info.event_data.y = -1;
- s_info.event_data.slot = -1;
- }
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;
@@ -183,66 +460,25 @@ static inline int processing_input_event(struct input_event *event)
s_info.event_data.keycode = event->value;
break;
case EV_REL:
+ DbgPrint("EV_REL: 0x%X\n", event->value);
break;
case EV_ABS:
- switch (event->code) {
- case ABS_DISTANCE:
- s_info.event_data.distance = event->value;
- break;
- case ABS_MT_TOOL_X:
- case ABS_MT_TOOL_Y:
- break;
- case ABS_MT_POSITION_X:
- s_info.event_data.x = event->value;
- break;
- case ABS_MT_POSITION_Y:
- s_info.event_data.y = event->value;
- break;
- case ABS_MT_SLOT:
- s_info.event_data.slot = event->value;
- break;
- case ABS_MT_TRACKING_ID:
- s_info.event_data.device = event->value;
- break;
- case ABS_MT_TOUCH_MAJOR:
- s_info.event_data.touch.major = event->value;
- break;
- case ABS_MT_TOUCH_MINOR:
- s_info.event_data.touch.minor = event->value;
- break;
- case ABS_MT_WIDTH_MAJOR:
- s_info.event_data.width.major = event->value;
- break;
- case ABS_MT_WIDTH_MINOR:
- s_info.event_data.width.minor = event->value;
- break;
- default:
- DbgPrint("EV_ABS, 0x%x\n", event->code);
- break;
- }
+ processing_ev_abs(event);
break;
case EV_MSC:
- break;
case EV_SW:
- break;
case EV_LED:
- break;
case EV_SND:
- break;
case EV_REP:
- break;
case EV_FF:
- break;
case EV_PWR:
- break;
case EV_FF_STATUS:
- break;
default:
DbgPrint("0x%X, 0x%X\n", event->type, event->code);
break;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static void *event_thread_main(void *data)
@@ -254,8 +490,7 @@ static void *event_thread_main(void *data)
int offset = 0;
int readsize = 0;
int fd;
-
- DbgPrint("Initiated\n");
+ char event_ch;
while (1) {
FD_ZERO(&set);
@@ -274,7 +509,7 @@ static void *event_thread_main(void *data)
break;
} else if (ret == 0) {
ErrPrint("Timeout expired\n");
- ret = LB_STATUS_ERROR_TIMEOUT;
+ ret = DBOX_STATUS_ERROR_TIMEOUT;
break;
}
@@ -282,7 +517,7 @@ static void *event_thread_main(void *data)
readsize = read(s_info.handle, ptr + offset, sizeof(input_event) - offset);
if (readsize < 0) {
ErrPrint("Unable to read device: %s / fd: %d / offset: %d / size: %d - %d\n", strerror(errno), s_info.handle, offset, sizeof(input_event), readsize);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
break;
}
@@ -290,48 +525,104 @@ static void *event_thread_main(void *data)
if (offset == sizeof(input_event)) {
offset = 0;
if (processing_input_event(&input_event) < 0) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
break;
}
}
- }
-
- if (FD_ISSET(s_info.tcb_pipe[PIPE_READ], &set)) {
- char event_ch;
+ /*
+ * 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("Unable to read TCB_PIPE: %s\n", strerror(errno));
}
- ret = LB_STATUS_ERROR_CANCEL;
+ ret = DBOX_STATUS_ERROR_CANCEL;
break;
}
}
+ event_ch = EVENT_EXIT;
+ if (write(s_info.evt_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
+ ErrPrint("Unable to send an event: %s\n", strerror(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;
+
+ if (!DYNAMICBOX_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_all_listener_list(void)
{
struct event_listener *listener;
enum event_state next_state;
+ struct event_data event_data;
+ struct event_data *p_event_data;
Eina_List *l;
Eina_List *n;
- s_info.event_handler = NULL;
- CLOSE_PIPE(s_info.evt_pipe);
+ 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);
+ }
while (s_info.event_listener_list) {
EINA_LIST_FOREACH_SAFE(s_info.event_listener_list, l, n, 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:
- next_state = EVENT_STATE_DEACTIVATED;
+ 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:
@@ -340,19 +631,32 @@ static inline void clear_all_listener_list(void)
continue;
}
- if (listener->event_cb(listener->state, &s_info.event_data, 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);
- continue;
- }
+ if (invoke_event_cb(listener, p_event_data)) {
+ continue;
}
+ /*!
+ * Changing state of listener will affect to the event collecting thread.
+ */
+ listener->prev_state = listener->state;
listener->state = next_state;
}
}
}
+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;
@@ -362,8 +666,6 @@ static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler)
Eina_List *l;
Eina_List *n;
enum event_state next_state;
- enum event_state cur_state;
- struct event_data modified_item;
fd = ecore_main_fd_handler_fd_get(handler);
if (fd < 0) {
@@ -376,6 +678,37 @@ static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler)
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");
+ }
+ }
+
CRITICAL_SECTION_BEGIN(&s_info.event_list_lock);
item = eina_list_nth(s_info.event_list, 0);
if (item) {
@@ -383,108 +716,86 @@ static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler)
}
CRITICAL_SECTION_END(&s_info.event_list_lock);
- if (item) {
- EINA_LIST_FOREACH_SAFE(s_info.event_listener_list, l, n, listener) {
- switch (listener->state) {
- case EVENT_STATE_ACTIVATE:
-#if defined(_USE_ECORE_TIME_GET)
- if (listener->tv > item->tv) {
- continue;
- }
-#else
- if (timercmp(&listener->tv, &item->tv, >)) {
- /* Ignore previous events before activating this listener */
- continue;
- }
-#endif
-
- next_state = EVENT_STATE_ACTIVATED;
- cur_state = listener->state;
- break;
- case EVENT_STATE_DEACTIVATE:
-#if defined(_USE_ECORE_TIME_GET)
- if (listener->tv > item->tv) {
- /* Consuming all events occurred while activating this listener */
- cur_state = EVENT_STATE_ACTIVATED;
- next_state = EVENT_STATE_ACTIVATED;
- break;
- }
-#else
- if (timercmp(&listener->tv, &item->tv, >)) {
- /* Consuming all events occurred while activating this listener */
- cur_state = EVENT_STATE_ACTIVATED;
- next_state = EVENT_STATE_ACTIVATED;
- break;
- }
-#endif
-
- cur_state = listener->state;
- next_state = EVENT_STATE_DEACTIVATED;
- break;
- case EVENT_STATE_ACTIVATED:
- cur_state = listener->state;
- 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);
- }
+ 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) {
+ 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;
}
- memcpy(&modified_item, item, sizeof(modified_item));
- modified_item.x -= listener->x;
- modified_item.y -= listener->y;
-
- if (listener->event_cb(cur_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);
+ next_state = EVENT_STATE_ACTIVATED;
+ break;
+ case EVENT_STATE_DEACTIVATE:
+ if (compare_timestamp(listener, item) < 0) {
+ /* Consuming all events occurred while activating this listener */
+ listener->prev_state = listener->state;
+ listener->state = EVENT_STATE_ACTIVATED;
+ if (invoke_event_cb(listener, item) == 1) {
+ /* listener is deleted */
continue;
}
- }
-
- listener->state = next_state;
- }
- DbgFree(item);
- }
+ listener->prev_state = listener->state;
+ listener->state = EVENT_STATE_DEACTIVATE;
+ } else {
+ memcpy(&s_info.skipped_event_data, item, sizeof(s_info.skipped_event_data));
+ }
- if (s_info.handle < 0 && !s_info.event_list) {
- /* This callback must has to clear all listeners in this case */
- clear_all_listener_list();
+ /* 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);
+ }
- EINA_LIST_FREE(s_info.reactivate_list, listener) {
- s_info.event_listener_list = eina_list_append(s_info.event_listener_list, listener);
+ continue;
}
- if (s_info.event_listener_list) {
- if (activate_thread() < 0) {
- EINA_LIST_FREE(s_info.event_listener_list, listener) {
- (void)listener->event_cb(EVENT_STATE_ERROR, NULL, listener->cbdata);
- }
- }
+ if (invoke_event_cb(listener, item) == 1) {
+ continue;
}
- return ECORE_CALLBACK_CANCEL;
+ listener->prev_state = listener->state;
+ listener->state = next_state;
}
+ DbgFree(item);
+
return ECORE_CALLBACK_RENEW;
}
-static int activate_thread(void)
+static int event_control_init(void)
{
int status;
+ unsigned int clockId = CLOCK_MONOTONIC;
+
+ DbgPrint("Initializing event controller\n");
+ if (s_info.handle != -1) {
+ return DBOX_STATUS_ERROR_NONE;
+ }
- s_info.handle = open(INPUT_PATH, O_RDONLY);
+ s_info.handle = open(DYNAMICBOX_CONF_INPUT_PATH, O_RDONLY);
if (s_info.handle < 0) {
ErrPrint("Unable to access the device: %s\n", strerror(errno));
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
if (fcntl(s_info.handle, F_SETFD, FD_CLOEXEC) < 0) {
@@ -495,6 +806,13 @@ static int activate_thread(void)
ErrPrint("Error: %s\n", strerror(errno));
}
+ if (DYNAMICBOX_CONF_USE_EVENT_TIME && !DYNAMICBOX_CONF_USE_GETTIMEOFDAY) {
+ DbgPrint("Change timestamp to monotonic\n");
+ if (ioctl(s_info.handle, EVIOCSCLOCKID, &clockId) < 0) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ }
+ }
+
status = pipe2(s_info.evt_pipe, O_CLOEXEC);
if (status < 0) {
ErrPrint("Unable to prepare evt pipe: %s\n", strerror(errno));
@@ -502,7 +820,7 @@ static int activate_thread(void)
ErrPrint("Failed to close handle: %s\n", strerror(errno));
}
s_info.handle = -1;
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
status = pipe2(s_info.tcb_pipe, O_CLOEXEC);
@@ -513,39 +831,98 @@ static int activate_thread(void)
}
s_info.handle = -1;
CLOSE_PIPE(s_info.evt_pipe);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- 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) {
+ return DBOX_STATUS_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("Failed to close handle: %s\n", strerror(errno));
+ ErrPrint("Unable to release the fd: %s\n", strerror(errno));
}
+
s_info.handle = -1;
+ }
- CLOSE_PIPE(s_info.tcb_pipe);
- CLOSE_PIPE(s_info.evt_pipe);
- return LB_STATUS_ERROR_FAULT;
+ 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();
}
- status = pthread_create(&s_info.tid, NULL, event_thread_main, NULL);
- if (status != 0) {
- ErrPrint("Failed to initiate the thread: %s\n", strerror(status));
+ CLOSE_PIPE(s_info.tcb_pipe);
+ CLOSE_PIPE(s_info.evt_pipe);
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+int event_activate_thread(enum event_handler_activate_type activate_type)
+{
+ int ret;
+
+ ret = event_control_init();
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ return ret;
+ }
+
+ if (s_info.event_handler) {
+ ErrPrint("Event handler is already registered\n");
+ return DBOX_STATUS_ERROR_ALREADY;
+ }
+
+ 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 DBOX_STATUS_ERROR_FAULT;
+ }
+
+ ret = pthread_create(&s_info.tid, NULL, event_thread_main, NULL);
+ if (ret != 0) {
+ ErrPrint("Failed to initiate the thread: %s\n", strerror(ret));
ecore_main_fd_handler_del(s_info.event_handler);
s_info.event_handler = NULL;
+ return DBOX_STATUS_ERROR_FAULT;
+ }
- if (close(s_info.handle) < 0) {
- ErrPrint("close: %s\n", strerror(errno));
- }
- s_info.handle = -1;
+ DbgPrint("Event handler activated\n");
+ s_info.event_handler_activated = activate_type;
+ return DBOX_STATUS_ERROR_NONE;
+}
- CLOSE_PIPE(s_info.tcb_pipe);
- CLOSE_PIPE(s_info.evt_pipe);
- return LB_STATUS_ERROR_FAULT;
+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 DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- DbgPrint("Event handler activated\n");
- return LB_STATUS_SUCCESS;
+ /* Terminating thread */
+ if (write(s_info.tcb_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
+ ErrPrint("Unable to write tcb_pipe: %s\n", strerror(errno));
+ }
+
+ status = pthread_join(s_info.tid, &ret);
+ if (status != 0) {
+ ErrPrint("Failed to join a thread: %s\n", strerror(errno));
+ } else {
+ DbgPrint("Thread returns: %p\n", ret);
+ }
+
+ s_info.event_handler_activated = EVENT_HANDLER_DEACTIVATED;
+ return DBOX_STATUS_ERROR_NONE;
}
/*!
@@ -554,36 +931,38 @@ static int activate_thread(void)
HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data)
{
struct event_listener *listener;
- int ret = LB_STATUS_SUCCESS;
+ int ret = DBOX_STATUS_ERROR_NONE;
+ Eina_List *l;
+
+ EINA_LIST_FOREACH(s_info.event_listener_list, l, listener) {
+ if (listener->event_cb == event_cb && listener->cbdata == data) {
+ ErrPrint("Already registered\n");
+ return DBOX_STATUS_ERROR_ALREADY;
+ }
+ }
listener = malloc(sizeof(*listener));
if (!listener) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
-#if defined(_USE_ECORE_TIME_GET)
- listener->tv = ecore_time_get();
-#else
- if (gettimeofday(&listener->tv, NULL) < 0) {
- ErrPrint("gettimeofday: %s\n", strerror(errno));
- DbgFree(listener);
- return LB_STATUS_ERROR_FAULT;
- }
-#endif
+ 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;
- if (s_info.handle < 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 not thread,
+ * 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) {
@@ -592,7 +971,7 @@ HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, st
} else {
s_info.event_listener_list = eina_list_append(s_info.event_listener_list, listener);
- if ((ret = activate_thread()) < 0) {
+ 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);
}
@@ -604,68 +983,81 @@ HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, st
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 (*event_cb)(enum event_state state, struct event_data *event, void *data), void *data)
{
- int status;
- void *ret;
- char event_ch = EVENT_CH;
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, listener) {
- if (listener->event_cb == event_cb && listener->cbdata == data) {
- listener->state = EVENT_STATE_DEACTIVATE;
+ EINA_LIST_FOREACH(s_info.event_listener_list, l, item) {
+ if (item->event_cb == event_cb && item->cbdata == data) {
+ 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 += (listener->state == EVENT_STATE_ACTIVATE || listener->state == EVENT_STATE_ACTIVATED);
+ keep_thread += (item->state == EVENT_STATE_ACTIVATE || item->state == EVENT_STATE_ACTIVATED);
}
if (!listener) {
- ErrPrint("Listener is not registered\n");
- return LB_STATUS_ERROR_NOT_EXIST;
+ ErrPrint("Listener is not registered or already deactivated\n");
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
- if (s_info.handle < 0) {
+ 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 LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
if (keep_thread) {
- return LB_STATUS_SUCCESS;
+ DbgPrint("Keep thread\n");
+ return DBOX_STATUS_ERROR_NONE;
}
- /* Terminating thread */
- if (write(s_info.tcb_pipe[PIPE_WRITE], &event_ch, sizeof(event_ch)) != sizeof(event_ch)) {
- ErrPrint("Unable to write tcb_pipe: %s\n", strerror(errno));
- }
+ event_deactivate_thread(EVENT_HANDLER_ACTIVATED_BY_MOUSE_SET);
- status = pthread_join(s_info.tid, &ret);
- if (status != 0) {
- ErrPrint("Failed to join a thread: %s\n", strerror(errno));
- } else {
- DbgPrint("Thread returns: %p\n", ret);
- }
-
- if (close(s_info.handle) < 0) {
- ErrPrint("Unable to release the fd: %s\n", strerror(errno));
- }
+ return DBOX_STATUS_ERROR_NONE;
+}
- s_info.handle = -1;
- DbgPrint("Event handler deactivated\n");
+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;
- CLOSE_PIPE(s_info.tcb_pipe);
+ EINA_LIST_FOREACH(s_info.event_listener_list, l, item) {
+ if (item->event_cb == event_cb && item->cbdata == data) {
+ item->cbdata = new_data;
+ updated++;
+ }
+ }
- if (!eina_list_count(s_info.event_list)) {
- ecore_main_fd_handler_del(s_info.event_handler);
- clear_all_listener_list();
+ EINA_LIST_FOREACH(s_info.reactivate_list, l, item) {
+ if (item->event_cb == event_cb && item->cbdata == data) {
+ item->cbdata = new_data;
+ updated++;
+ }
}
- s_info.event_data.x = -1;
- s_info.event_data.y = -1;
- s_info.event_data.slot = -1;
- return LB_STATUS_SUCCESS;
+ return updated;
}
HAPI int event_is_activated(void)
diff --git a/src/fault_manager.c b/src/fault_manager.c
index 1ec4398..4029229 100644
--- a/src/fault_manager.c
+++ b/src/fault_manager.c
@@ -23,8 +23,10 @@
#include <Eina.h>
#include <packet.h>
#include <dlog.h>
-#include <livebox-errno.h>
-#include <livebox-service.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_conf.h>
+#include <dynamicbox_cmd_list.h>
#include "util.h"
#include "debug.h"
@@ -63,7 +65,7 @@ static void clear_log_file(struct slave_node *slave)
char filename[BUFSIZ];
int ret;
- ret = snprintf(filename, sizeof(filename) - 1, "%s/slave.%d", SLAVE_LOG_PATH, slave_pid(slave));
+ ret = snprintf(filename, sizeof(filename) - 1, "%s/slave.%d", DYNAMICBOX_CONF_LOG_PATH, slave_pid(slave));
if (ret == sizeof(filename) - 1) {
filename[sizeof(filename) - 1] = '\0';
ErrPrint("filename buffer is overflowed\n");
@@ -81,7 +83,7 @@ static char *check_log_file(struct slave_node *slave)
FILE *fp;
char filename[BUFSIZ];
- snprintf(filename, sizeof(filename), "%s/slave.%d", SLAVE_LOG_PATH, slave_pid(slave));
+ snprintf(filename, sizeof(filename), "%s/slave.%d", DYNAMICBOX_CONF_LOG_PATH, slave_pid(slave));
fp = fopen(filename, "rt");
if (!fp) {
ErrPrint("No log file found [%s]\n", strerror(errno));
@@ -102,7 +104,7 @@ static char *check_log_file(struct slave_node *slave)
ErrPrint("Failed to unlink %s\n", filename);
}
- ptr = livebox_service_pkgname_by_libexec(libexec);
+ ptr = dynamicbox_service_dbox_id_by_libexec(libexec);
if (!ptr) {
ErrPrint("Failed to find the faulted package\n");
}
@@ -114,12 +116,13 @@ static char *check_log_file(struct slave_node *slave)
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("fault_package", "sss", pkgname, filename, func);
+ packet = packet_create_noack((const char *)&cmd, "sss", pkgname, filename, func);
if (!packet) {
return;
}
@@ -130,8 +133,9 @@ HAPI void fault_unicast_info(struct client_node *client, const char *pkgname, co
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("fault_package", "sss", pkgname, filename, func);
+ packet = packet_create_noack((const char *)&cmd, "sss", pkgname, filename, func);
if (!packet) {
ErrPrint("Failed to create a param\n");
return;
@@ -155,12 +159,12 @@ HAPI int fault_info_set(struct slave_node *slave, const char *pkgname, const cha
pkg = package_find(pkgname);
if (!pkg) {
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
ret = package_set_fault_info(pkg, util_timestamp(), id, func);
if (ret < 0) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
dump_fault_info(slave_name(slave), slave_pid(slave), pkgname, id, func);
@@ -172,7 +176,7 @@ HAPI int fault_info_set(struct slave_node *slave, const char *pkgname, const cha
* Update statistics
*/
s_info.fault_mark_count++;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int fault_check_pkgs(struct slave_node *slave)
@@ -273,7 +277,7 @@ HAPI int fault_check_pkgs(struct slave_node *slave)
} else {
DbgPrint("Treated as a false log\n");
dump_fault_info(
- slave_name(info->slave), slave_pid(info->slave), info->pkgname, filename, func);
+ 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);
@@ -297,7 +301,7 @@ HAPI int fault_func_call(struct slave_node *slave, const char *pkgname, const ch
info = malloc(sizeof(*info));
if (!info) {
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
info->slave = slave;
@@ -305,14 +309,14 @@ HAPI int fault_func_call(struct slave_node *slave, const char *pkgname, const ch
info->pkgname = strdup(pkgname);
if (!info->pkgname) {
DbgFree(info);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
info->filename = strdup(filename);
if (!info->filename) {
DbgFree(info->pkgname);
DbgFree(info);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
info->func = strdup(func);
@@ -320,7 +324,7 @@ HAPI int fault_func_call(struct slave_node *slave, const char *pkgname, const ch
DbgFree(info->filename);
DbgFree(info->pkgname);
DbgFree(info);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
info->timestamp = util_timestamp();
@@ -328,7 +332,7 @@ HAPI int fault_func_call(struct slave_node *slave, const char *pkgname, const ch
s_info.call_list = eina_list_append(s_info.call_list, info);
s_info.fault_mark_count++;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int fault_func_ret(struct slave_node *slave, const char *pkgname, const char *filename, const char *func)
@@ -363,7 +367,7 @@ HAPI int fault_func_ret(struct slave_node *slave, const char *pkgname, const cha
return 0;
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
/* End of a file */
diff --git a/src/file_service.c b/src/file_service.c
index f473ade..ce33d03 100644
--- a/src/file_service.c
+++ b/src/file_service.c
@@ -27,7 +27,8 @@
#include <dlog.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
#include <packet.h>
#include <com-core.h>
@@ -139,11 +140,11 @@ static inline int destroy_request_item(struct request_item *item)
case REQUEST_TYPE_PIXMAP:
break;
default:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
DbgFree(item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int request_file_handler(struct tcb *tcb, struct packet *packet, struct request_item **item)
@@ -152,11 +153,11 @@ static int request_file_handler(struct tcb *tcb, struct packet *packet, struct r
if (packet_get(packet, "s", &filename) != 1) {
ErrPrint("Invalid packet\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
*item = create_request_item(tcb, REQUEST_TYPE_FILE, (void *)filename);
- return *item ? LB_STATUS_SUCCESS : LB_STATUS_ERROR_MEMORY;
+ return *item ? DBOX_STATUS_ERROR_NONE : DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
static int request_pixmap_handler(struct tcb *tcb, struct packet *packet, struct request_item **item)
@@ -165,12 +166,12 @@ static int request_pixmap_handler(struct tcb *tcb, struct packet *packet, struct
if (packet_get(packet, "i", &pixmap) != 1) {
ErrPrint("Invalid packet\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (pixmap == 0) {
ErrPrint("pixmap is not valid\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
/*!
@@ -178,7 +179,7 @@ static int request_pixmap_handler(struct tcb *tcb, struct packet *packet, struct
* Attach to pixmap and copy its data to the client
*/
*item = create_request_item(tcb, REQUEST_TYPE_PIXMAP, (void *)pixmap);
- return *item ? LB_STATUS_SUCCESS : LB_STATUS_ERROR_MEMORY;
+ return *item ? DBOX_STATUS_ERROR_NONE : DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
static int request_shm_handler(struct tcb *tcb, struct packet *packet, struct request_item **item)
@@ -187,12 +188,12 @@ static int request_shm_handler(struct tcb *tcb, struct packet *packet, struct re
if (packet_get(packet, "i", &shm) != 1) {
ErrPrint("Invalid packet\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (shm < 0) {
ErrPrint("shm is not valid: %d\n", shm);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
/*!
@@ -200,7 +201,7 @@ static int request_shm_handler(struct tcb *tcb, struct packet *packet, struct re
* Attach to SHM and copy its buffer to the client
*/
*item = create_request_item(tcb, REQUEST_TYPE_SHM, (void *)shm);
- return *item ? LB_STATUS_SUCCESS : LB_STATUS_ERROR_MEMORY;
+ return *item ? DBOX_STATUS_ERROR_NONE : DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
/* SERVER THREAD */
@@ -236,13 +237,13 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
if (!packet) {
DbgPrint("TCB %p is disconnected\n", tcb);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
cmd = packet_command(packet);
if (!cmd) {
ErrPrint("Invalid packet. cmd is not valid\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
switch (packet_type(packet)) {
@@ -279,7 +280,7 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
* \note
* After send the reply packet, file push thread can sending a file
*/
- if (ret != LB_STATUS_SUCCESS || !item) {
+ if (ret != DBOX_STATUS_ERROR_NONE || !item) {
break;
}
@@ -316,7 +317,7 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
break;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int send_file(int handle, const struct request_item *item)
@@ -445,7 +446,7 @@ errout:
static int send_buffer(int handle, const struct request_item *item)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
struct burst_head *head;
struct burst_data *body;
char *data;
@@ -456,9 +457,9 @@ static int send_buffer(int handle, const struct request_item *item)
int type;
if (item->type == REQUEST_TYPE_SHM) {
- type = BUFFER_TYPE_SHM;
+ type = DBOX_FB_TYPE_SHM;
} else {
- type = BUFFER_TYPE_PIXMAP;
+ type = DBOX_FB_TYPE_PIXMAP;
}
buffer = buffer_handler_raw_open(type, (void *)item->data.shm);
@@ -615,19 +616,19 @@ int file_service_init(void)
if (s_info.svc_ctx) {
ErrPrint("Already initialized\n");
- return LB_STATUS_ERROR_ALREADY;
+ return DBOX_STATUS_ERROR_ALREADY;
}
if (pipe2(s_info.request_pipe, O_CLOEXEC) < 0) {
ErrPrint("pipe: %s\n", strerror(errno));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
status = pthread_mutex_init(&s_info.request_list_lock, NULL);
if (status != 0) {
ErrPrint("Failed to create lock: %s\n", strerror(status));
CLOSE_PIPE(s_info.request_pipe);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
s_info.svc_ctx = service_common_create(FILE_SERVICE_ADDR, service_thread_main, NULL);
@@ -640,7 +641,7 @@ int file_service_init(void)
}
CLOSE_PIPE(s_info.request_pipe);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
status = pthread_create(&s_info.push_thid, NULL, push_main, NULL);
@@ -656,7 +657,7 @@ int file_service_init(void)
}
CLOSE_PIPE(s_info.request_pipe);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
/*!
@@ -665,7 +666,7 @@ int file_service_init(void)
*/
DbgPrint("Successfully initiated\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* MAIN THREAD */
@@ -677,7 +678,7 @@ int file_service_fini(void)
void *retval;
if (!s_info.svc_ctx) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ch = PUSH_EXIT;
@@ -713,7 +714,7 @@ int file_service_fini(void)
CLOSE_PIPE(s_info.request_pipe);
DbgPrint("Successfully Finalized\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* End of a file */
diff --git a/src/group.c b/src/group.c
index ff03488..21627cf 100644
--- a/src/group.c
+++ b/src/group.c
@@ -22,7 +22,7 @@
#include <dlog.h>
#include <Eina.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#include "util.h"
#include "debug.h"
@@ -145,14 +145,14 @@ HAPI int group_add_option(struct context_item *item, const char *key, const char
option = calloc(1, sizeof(*option));
if (!option) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
option->key = strdup(key);
if (!option->key) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(option);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
option->value = strdup(value);
@@ -160,12 +160,12 @@ HAPI int group_add_option(struct context_item *item, const char *key, const char
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(option->key);
DbgFree(option);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
option->item = item;
item->option_list = eina_list_append(item->option_list, option);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int group_destroy_context_info(struct context_info *info)
@@ -175,7 +175,7 @@ HAPI int group_destroy_context_info(struct context_info *info)
category = info->category;
if (!category) {
ErrPrint("No category found\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
category->info_list = eina_list_remove(category->info_list, info);
@@ -183,7 +183,7 @@ HAPI int group_destroy_context_info(struct context_info *info)
del_context_item(info);
DbgFree(info->pkgname);
DbgFree(info);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI struct cluster *group_create_cluster(const char *name)
@@ -271,11 +271,11 @@ HAPI int group_destroy_cluster(struct cluster *cluster)
if (item == cluster) {
s_info.cluster_list = eina_list_remove_list(s_info.cluster_list, l);
destroy_cluster(cluster);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
static inline void destroy_category(struct category *category)
@@ -302,7 +302,7 @@ HAPI int group_destroy_category(struct category *category)
}
destroy_category(category);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI struct category *group_find_category(struct cluster *cluster, const char *name)
@@ -380,18 +380,18 @@ HAPI int group_context_item_add_data(struct context_item *item, const char *tag,
tmp = malloc(sizeof(*tmp));
if (!tmp) {
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
tmp->tag = strdup(tag);
if (!tmp->tag) {
DbgFree(tmp);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
tmp->data = data;
item->data_list = eina_list_append(item->data_list, tmp);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void *group_context_item_data(struct context_item *item, const char *tag)
@@ -481,7 +481,7 @@ static inline char *get_token(char *ptr, int *len)
return name;
}
-HAPI int group_add_livebox(const char *group, const char *pkgname)
+HAPI int group_add_dynamicbox(const char *group, const char *pkgname)
{
struct cluster *cluster;
struct category *category;
@@ -516,7 +516,7 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
name = get_token(ptr, &len);
if (!name) {
ErrPrint("Failed to get token\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
/* cluster{category{context{key=value,key=value},context{key=value}}} */
/* cluster{category} */
@@ -531,7 +531,7 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (!cluster) {
ErrPrint("Failed to get cluster\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CATEGORY;
@@ -546,14 +546,14 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (!category) {
ErrPrint("Failed to get category\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
info = group_create_context_info(category, pkgname);
if (!info) {
ErrPrint("Failed to create ctx info\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CONTEXT_ITEM;
@@ -564,7 +564,7 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (!item) {
ErrPrint("Failed to create a context item\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CONTEXT_OPTION_KEY;
@@ -575,7 +575,7 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
default:
ErrPrint("Invalid state\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
DbgFree(name);
@@ -599,7 +599,7 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (is_open != 0) {
ErrPrint("Invalid state\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
cluster = group_find_cluster(name);
if (!cluster) {
@@ -609,7 +609,7 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (!cluster) {
ErrPrint("Failed to get cluster\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CATEGORY;
@@ -619,7 +619,7 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (is_open != 1) {
ErrPrint("Invalid state\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
category = group_find_category(cluster, name);
if (!category) {
@@ -629,14 +629,14 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (!category) {
ErrPrint("Failed to get category\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
info = group_create_context_info(category, pkgname);
if (!info) {
ErrPrint("Failed to create ctx info\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CONTEXT_ITEM;
@@ -651,27 +651,27 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (!category) {
ErrPrint("Failed to get category\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
info = group_create_context_info(category, pkgname);
if (!info) {
ErrPrint("Failed to create ctx info\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CONTEXT_OPTION_KEY;
} else {
ErrPrint("Invalid state\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
break;
@@ -679,7 +679,7 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (is_open != 3) {
ErrPrint("Invalid state\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (group_add_option(item, key, name) < 0) {
@@ -695,7 +695,7 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
default:
ErrPrint("Invalid state (%s)\n", name);
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
DbgFree(name);
@@ -706,13 +706,13 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
} else if (*ptr == '=') {
if (is_open != 3 || state != CONTEXT_OPTION_KEY) {
ErrPrint("Invalid state\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
key = get_token(ptr, &len);
if (!key) {
ErrPrint("Failed to get token\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CONTEXT_OPTION_VALUE;
@@ -723,7 +723,7 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
} else if (*ptr == '}') {
if (is_open <= 0) {
ErrPrint("Invalid state\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
name = get_token(ptr, &len);
@@ -746,14 +746,14 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (!category) {
ErrPrint("Failed to get category\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
info = group_create_context_info(category, pkgname);
if (!info) {
ErrPrint("Failed to create ctx info\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CLUSTER;
@@ -768,14 +768,14 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
if (!category) {
ErrPrint("Failed to get category\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
info = group_create_context_info(category, pkgname);
if (!info) {
ErrPrint("Failed to create ctx info\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CLUSTER;
@@ -784,14 +784,14 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
} else {
ErrPrint("Invalid state\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
break;
case CONTEXT_OPTION_VALUE:
if (is_open != 2) {
ErrPrint("Invalid state (%s)\n", name);
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (group_add_option(item, key, name) < 0) {
@@ -826,13 +826,13 @@ HAPI int group_add_livebox(const char *group, const char *pkgname)
DbgFree(key);
if (state != CLUSTER) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI int group_del_livebox(const char *pkgname)
+HAPI int group_del_dynamicbox(const char *pkgname)
{
Eina_List *l;
Eina_List *n;
@@ -862,12 +862,12 @@ HAPI int group_del_livebox(const char *pkgname)
}
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int group_init(void)
{
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int group_fini(void)
@@ -883,7 +883,7 @@ HAPI int group_fini(void)
destroy_cluster(cluster);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* End of a file */
diff --git a/src/instance.c b/src/instance.c
index 32e6b91..1bc8b23 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -25,8 +25,11 @@
#include <packet.h>
#include <com-core_packet.h>
-#include <livebox-service.h>
-#include <livebox-errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_cmd_list.h>
+#include <dynamicbox_buffer.h>
+#include <dynamicbox_conf.h>
#include "conf.h"
#include "util.h"
@@ -44,9 +47,9 @@
int errno;
static struct info {
- enum buffer_type env_buf_type;
+ enum dynamicbox_fb_type env_buf_type;
} s_info = {
- .env_buf_type = BUFFER_TYPE_FILE,
+ .env_buf_type = DBOX_FB_TYPE_FILE,
};
struct set_pinup_cbdata {
@@ -92,8 +95,9 @@ struct inst_info {
enum instance_state state; /*!< Represents current state */
enum instance_state requested_state; /*!< Only ACTIVATED | DESTROYED is acceptable */
- enum instance_destroy_type destroy_type;
+ dynamicbox_destroy_type_e destroy_type;
int changing_state;
+ int unicast_delete_event;
char *id;
double timestamp;
@@ -110,7 +114,7 @@ struct inst_info {
char *icon;
char *name;
- enum livebox_visible_state visible;
+ enum dynamicbox_visible_state visible;
struct {
int width;
@@ -122,8 +126,10 @@ struct inst_info {
struct buffer_info *buffer;
} canvas;
+ struct buffer_info **extra_buffer;
+
double period;
- } lb;
+ } dbox;
struct {
int width;
@@ -136,18 +142,20 @@ struct inst_info {
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;
- } pd;
+ } gbar;
struct client_node *client; /*!< Owner - creator */
Eina_List *client_list; /*!< Viewer list */
int refcnt;
- Ecore_Timer *update_timer; /*!< Only used for secured livebox */
+ Ecore_Timer *update_timer; /*!< Only used for secured dynamicbox */
enum event_process {
INST_EVENT_PROCESS_IDLE = 0x00,
@@ -208,7 +216,6 @@ static inline void timer_freeze(struct inst_info *inst)
#endif
}
-
static int viewer_deactivated_cb(struct client_node *client, void *data)
{
struct inst_info *inst = data;
@@ -216,41 +223,43 @@ static int viewer_deactivated_cb(struct client_node *client, void *data)
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 LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
inst->client_list = eina_list_remove(inst->client_list, client);
if (!inst->client_list && !inst->client) {
DbgPrint("Has no clients\n");
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_FAULT);
}
instance_unref(inst);
return -1; /*!< Remove this callback from the cb list */
}
-static int pause_livebox(struct inst_info *inst)
+static int pause_dynamicbox(struct inst_info *inst)
{
struct packet *packet;
+ unsigned int cmd = CMD_DBOX_PAUSE;
- packet = packet_create_noack("lb_pause", "ss", package_name(inst->info), inst->id);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_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_livebox(struct inst_info *inst)
+static int resume_dynamicbox(struct inst_info *inst)
{
struct packet *packet;
+ unsigned int cmd = CMD_DBOX_RESUME;
- packet = packet_create_noack("lb_resume", "ss", package_name(inst->info), inst->id);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0);
@@ -261,19 +270,19 @@ static inline int instance_recover_visible_state(struct inst_info *inst)
int ret;
switch (inst->visible) {
- case LB_SHOW:
- case LB_HIDE:
+ case DBOX_SHOW:
+ case DBOX_HIDE:
instance_thaw_updator(inst);
ret = 0;
break;
- case LB_HIDE_WITH_PAUSE:
- ret = pause_livebox(inst);
+ case DBOX_HIDE_WITH_PAUSE:
+ ret = pause_dynamicbox(inst);
instance_freeze_updator(inst);
break;
default:
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
break;
}
@@ -285,6 +294,7 @@ static inline void instance_send_update_mode_event(struct inst_info *inst, int a
{
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");
@@ -293,7 +303,7 @@ static inline void instance_send_update_mode_event(struct inst_info *inst, int a
pkgname = package_name(inst->info);
- packet = packet_create_noack("update_mode", "ssii", pkgname, inst->id, status, active_mode);
+ packet = packet_create_noack((const char *)&cmd, "ssii", pkgname, inst->id, status, active_mode);
if (packet) {
CLIENT_SEND_EVENT(inst, packet);
} else {
@@ -301,12 +311,26 @@ static inline void instance_send_update_mode_event(struct inst_info *inst, int a
}
}
-static inline void instance_send_resized_event(struct inst_info *inst, int is_pd, int w, int h, int status)
+static inline void instance_send_update_id(struct inst_info *inst)
{
struct packet *packet;
- enum lb_type lb_type;
+ 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);
+ } 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 dynamicbox_dbox_type dbox_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");
@@ -315,16 +339,16 @@ static inline void instance_send_resized_event(struct inst_info *inst, int is_pd
pkgname = package_name(inst->info);
- lb_type = package_lb_type(inst->info);
- if (lb_type == LB_TYPE_SCRIPT) {
- id = script_handler_buffer_id(inst->lb.canvas.script);
- } else if (lb_type == LB_TYPE_BUFFER) {
- id = buffer_handler_id(inst->lb.canvas.buffer);
+ dbox_type = package_dbox_type(inst->info);
+ if (dbox_type == DBOX_TYPE_SCRIPT) {
+ id = script_handler_buffer_id(inst->dbox.canvas.script);
+ } else if (dbox_type == DBOX_TYPE_BUFFER) {
+ id = buffer_handler_id(inst->dbox.canvas.buffer);
} else {
id = "";
}
- packet = packet_create_noack("size_changed", "sssiiii", pkgname, inst->id, id, is_pd, w, h, status);
+ packet = packet_create_noack((const char *)&cmd, "sssiiii", pkgname, inst->id, id, is_gbar, w, h, status);
if (packet) {
CLIENT_SEND_EVENT(inst, packet);
} else {
@@ -339,17 +363,17 @@ static void update_mode_cb(struct slave_node *slave, const struct packet *packet
if (!packet) {
ErrPrint("Invalid packet\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
if (packet_get(packet, "i", &ret) != 1) {
ErrPrint("Invalid parameters\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
cbdata->inst->active_update = cbdata->active_update;
}
@@ -362,55 +386,56 @@ out:
HAPI int instance_unicast_created_event(struct inst_info *inst, struct client_node *client)
{
struct packet *packet;
- enum lb_type lb_type;
- enum pd_type pd_type;
- const char *lb_file;
- const char *pd_file;
+ enum dynamicbox_dbox_type dbox_type;
+ enum dynamicbox_gbar_type gbar_type;
+ const char *dbox_file;
+ const char *gbar_file;
+ unsigned int cmd = CMD_CREATED;
if (!client) {
client = inst->client;
if (!client) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
- lb_type = package_lb_type(inst->info);
- pd_type = package_pd_type(inst->info);
+ dbox_type = package_dbox_type(inst->info);
+ gbar_type = package_gbar_type(inst->info);
- if (lb_type == LB_TYPE_SCRIPT) {
- lb_file = script_handler_buffer_id(inst->lb.canvas.script);
- } else if (lb_type == LB_TYPE_BUFFER) {
- lb_file = buffer_handler_id(inst->lb.canvas.buffer);
+ if (dbox_type == DBOX_TYPE_SCRIPT) {
+ dbox_file = script_handler_buffer_id(inst->dbox.canvas.script);
+ } else if (dbox_type == DBOX_TYPE_BUFFER) {
+ dbox_file = buffer_handler_id(inst->dbox.canvas.buffer);
} else {
- lb_file = "";
+ dbox_file = "";
}
- if (pd_type == PD_TYPE_SCRIPT) {
- pd_file = script_handler_buffer_id(inst->pd.canvas.script);
- } else if (pd_type == PD_TYPE_BUFFER) {
- pd_file = buffer_handler_id(inst->pd.canvas.buffer);
+ 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 {
- pd_file = "";
+ gbar_file = "";
}
- packet = packet_create_noack("created", "dsssiiiisssssdiiiiidsi",
+ packet = packet_create_noack((const char *)&cmd, "dsssiiiisssssdiiiiidsi",
inst->timestamp,
package_name(inst->info), inst->id, inst->content,
- inst->lb.width, inst->lb.height,
- inst->pd.width, inst->pd.height,
+ inst->dbox.width, inst->dbox.height,
+ inst->gbar.width, inst->gbar.height,
inst->cluster, inst->category,
- lb_file, pd_file,
+ dbox_file, gbar_file,
package_auto_launch(inst->info),
- inst->lb.priority,
+ inst->dbox.priority,
package_size_list(inst->info),
!!inst->client,
package_pinup(inst->info),
- lb_type, pd_type,
- inst->lb.period, inst->title,
+ dbox_type, gbar_type,
+ inst->dbox.period, inst->title,
inst->is_pinned_up);
if (!packet) {
ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return client_rpc_async_request(client, packet);
@@ -424,80 +449,83 @@ static int update_client_list(struct client_node *client, void *data)
instance_add_client(inst, client);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int instance_broadcast_created_event(struct inst_info *inst)
{
struct packet *packet;
- enum lb_type lb_type;
- enum pd_type pd_type;
- const char *lb_file;
- const char *pd_file;
-
- lb_type = package_lb_type(inst->info);
- pd_type = package_pd_type(inst->info);
-
- if (lb_type == LB_TYPE_SCRIPT) {
- lb_file = script_handler_buffer_id(inst->lb.canvas.script);
- } else if (lb_type == LB_TYPE_BUFFER) {
- lb_file = buffer_handler_id(inst->lb.canvas.buffer);
+ enum dynamicbox_dbox_type dbox_type;
+ enum dynamicbox_gbar_type gbar_type;
+ const char *dbox_file;
+ const char *gbar_file;
+ unsigned int cmd = CMD_CREATED;
+
+ dbox_type = package_dbox_type(inst->info);
+ gbar_type = package_gbar_type(inst->info);
+
+ if (dbox_type == DBOX_TYPE_SCRIPT) {
+ dbox_file = script_handler_buffer_id(inst->dbox.canvas.script);
+ } else if (dbox_type == DBOX_TYPE_BUFFER) {
+ dbox_file = buffer_handler_id(inst->dbox.canvas.buffer);
} else {
- lb_file = "";
+ dbox_file = "";
}
- if (pd_type == PD_TYPE_SCRIPT) {
- pd_file = script_handler_buffer_id(inst->pd.canvas.script);
- } else if (pd_type == PD_TYPE_BUFFER) {
- pd_file = buffer_handler_id(inst->pd.canvas.buffer);
+ 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 {
- pd_file = "";
+ gbar_file = "";
}
if (!inst->client) {
client_browse_list(inst->cluster, inst->category, update_client_list, inst);
}
- packet = packet_create_noack("created", "dsssiiiisssssdiiiiidsi",
+ packet = packet_create_noack((const char *)&cmd, "dsssiiiisssssdiiiiidsi",
inst->timestamp,
package_name(inst->info), inst->id, inst->content,
- inst->lb.width, inst->lb.height,
- inst->pd.width, inst->pd.height,
+ inst->dbox.width, inst->dbox.height,
+ inst->gbar.width, inst->gbar.height,
inst->cluster, inst->category,
- lb_file, pd_file,
+ dbox_file, gbar_file,
package_auto_launch(inst->info),
- inst->lb.priority,
+ inst->dbox.priority,
package_size_list(inst->info),
!!inst->client,
package_pinup(inst->info),
- lb_type, pd_type,
- inst->lb.period, inst->title,
+ dbox_type, gbar_type,
+ inst->dbox.period, inst->title,
inst->is_pinned_up);
if (!packet) {
ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
+ inst->unicast_delete_event = 0;
return CLIENT_SEND_EVENT(inst, packet);
}
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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
}
- packet = packet_create_noack("deleted", "ssdi", package_name(inst->info), inst->id, inst->timestamp, reason);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
-
+
return client_rpc_async_request(client, packet);
}
@@ -508,13 +536,14 @@ static int instance_broadcast_deleted_event(struct inst_info *inst, int reason)
Eina_List *l;
Eina_List *n;
int ret;
+ unsigned int cmd = CMD_DELETED;
- packet = packet_create_noack("deleted", "ssdi", package_name(inst->info), inst->id, inst->timestamp, reason);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
-
+
ret = CLIENT_SEND_EVENT(inst, packet);
EINA_LIST_FOREACH_SAFE(inst->client_list, l, n, client) {
@@ -527,26 +556,27 @@ static int instance_broadcast_deleted_event(struct inst_info *inst, int reason)
static int client_deactivated_cb(struct client_node *client, void *data)
{
struct inst_info *inst = data;
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
- return LB_STATUS_SUCCESS;
+ instance_destroy(inst, DBOX_DESTROY_TYPE_FAULT);
+ return DBOX_STATUS_ERROR_NONE;
}
-static int send_pd_destroyed_to_client(struct inst_info *inst, int status)
+static int send_gbar_destroyed_to_client(struct inst_info *inst, int status)
{
struct packet *packet;
+ unsigned int cmd = CMD_GBAR_DESTROYED;
- if (!inst->pd.need_to_send_close_event && status != LB_STATUS_ERROR_FAULT) {
- ErrPrint("PD is not created\n");
- return LB_STATUS_ERROR_INVALID;
+ if (!inst->gbar.need_to_send_close_event && status != DBOX_STATUS_ERROR_FAULT) {
+ ErrPrint("GBAR is not created\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack("pd_destroyed", "ssi", package_name(inst->info), inst->id, status);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- inst->pd.need_to_send_close_event = 0;
+ inst->gbar.need_to_send_close_event = 0;
return CLIENT_SEND_EVENT(inst, packet);
}
@@ -567,12 +597,37 @@ static inline void invoke_delete_callbacks(struct inst_info *inst)
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 DBOX_STATUS_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 DBOX_STATUS_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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
switch (type) {
@@ -580,7 +635,7 @@ HAPI int instance_event_callback_add(struct inst_info *inst, enum instance_event
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
item->event_cb = event_cb;
@@ -590,10 +645,10 @@ HAPI int instance_event_callback_add(struct inst_info *inst, enum instance_event
inst->delete_event_list = eina_list_append(inst->delete_event_list, item);
break;
default:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_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)
@@ -612,7 +667,7 @@ HAPI int instance_event_callback_del(struct inst_info *inst, enum instance_event
inst->delete_event_list = eina_list_remove(inst->delete_event_list, item);
DbgFree(item);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
@@ -620,51 +675,86 @@ HAPI int instance_event_callback_del(struct inst_info *inst, enum instance_event
break;
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
static inline void destroy_instance(struct inst_info *inst)
{
struct pkg_info *pkg;
- enum lb_type lb_type;
- enum pd_type pd_type;
+ enum dynamicbox_dbox_type dbox_type;
+ enum dynamicbox_gbar_type gbar_type;
struct slave_node *slave;
struct event_item *item;
struct tag_item *tag_item;
- (void)send_pd_destroyed_to_client(inst, LB_STATUS_SUCCESS);
+ (void)send_gbar_destroyed_to_client(inst, DBOX_STATUS_ERROR_NONE);
invoke_delete_callbacks(inst);
pkg = inst->info;
- lb_type = package_lb_type(pkg);
- pd_type = package_pd_type(pkg);
+ dbox_type = package_dbox_type(pkg);
+ gbar_type = package_gbar_type(pkg);
slave = package_slave(inst->info);
DbgPrint("Instance is destroyed (%p), slave(%p)\n", inst, slave);
- if (lb_type == LB_TYPE_SCRIPT) {
- (void)script_handler_unload(inst->lb.canvas.script, 0);
- if (script_handler_destroy(inst->lb.canvas.script) == (int)LB_STATUS_SUCCESS) {
- inst->lb.canvas.script = NULL;
+ if (dbox_type == DBOX_TYPE_SCRIPT) {
+ (void)script_handler_unload(inst->dbox.canvas.script, 0);
+ if (script_handler_destroy(inst->dbox.canvas.script) == (int)DBOX_STATUS_ERROR_NONE) {
+ inst->dbox.canvas.script = NULL;
+ }
+ } else if (dbox_type == DBOX_TYPE_BUFFER) {
+ (void)buffer_handler_unload(inst->dbox.canvas.buffer);
+ if (buffer_handler_destroy(inst->dbox.canvas.buffer) == (int)DBOX_STATUS_ERROR_NONE) {
+ inst->dbox.canvas.buffer = NULL;
}
- } else if (lb_type == LB_TYPE_BUFFER) {
- (void)buffer_handler_unload(inst->lb.canvas.buffer);
- if (buffer_handler_destroy(inst->lb.canvas.buffer) == (int)LB_STATUS_SUCCESS) {
- inst->lb.canvas.buffer = NULL;
+
+ if (inst->dbox.extra_buffer) {
+ int i;
+
+ for (i = 0; i < DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT; i++) {
+ if (!inst->dbox.extra_buffer[i]) {
+ continue;
+ }
+
+ (void)buffer_handler_unload(inst->dbox.extra_buffer[i]);
+ if (buffer_handler_destroy(inst->dbox.extra_buffer[i]) == (int)DBOX_STATUS_ERROR_NONE) {
+ inst->dbox.extra_buffer[i] = NULL;
+ }
+ }
+
+ DbgFree(inst->dbox.extra_buffer);
+ inst->dbox.extra_buffer = NULL;
}
}
- if (pd_type == PD_TYPE_SCRIPT) {
- (void)script_handler_unload(inst->pd.canvas.script, 1);
- if (script_handler_destroy(inst->pd.canvas.script) == (int)LB_STATUS_SUCCESS) {
- inst->pd.canvas.script = 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)DBOX_STATUS_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)DBOX_STATUS_ERROR_NONE) {
+ inst->gbar.canvas.buffer = NULL;
}
- } else if (pd_type == PD_TYPE_BUFFER) {
- (void)buffer_handler_unload(inst->pd.canvas.buffer);
- if (buffer_handler_destroy(inst->pd.canvas.buffer) == (int)LB_STATUS_SUCCESS) {
- inst->pd.canvas.buffer = NULL;
+ if (inst->gbar.extra_buffer) {
+ int i;
+
+ for (i = 0; i < DYNAMICBOX_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)DBOX_STATUS_ERROR_NONE) {
+ inst->gbar.extra_buffer[i] = NULL;
+ }
+ }
+
+ DbgFree(inst->gbar.extra_buffer);
+ inst->gbar.extra_buffer = NULL;
}
}
@@ -686,6 +776,7 @@ static inline void destroy_instance(struct inst_info *inst)
EINA_LIST_FREE(inst->delete_event_list, item) {
DbgFree(item);
}
+
DbgFree(inst->icon);
DbgFree(inst->name);
DbgFree(inst->category);
@@ -716,27 +807,27 @@ static inline int fork_package(struct inst_info *inst, const char *pkgname)
info = package_find(pkgname);
if (!info) {
ErrPrint("%s is not found\n", pkgname);
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
- len = strlen(SCHEMA_FILE "%s%s_%d_%lf.png") + strlen(IMAGE_PATH) + strlen(package_name(info)) + 50;
+ len = strlen(SCHEMA_FILE "%s%s_%d_%lf.png") + strlen(DYNAMICBOX_CONF_IMAGE_PATH) + strlen(package_name(info)) + 50;
inst->id = malloc(len);
if (!inst->id) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- snprintf(inst->id, len, SCHEMA_FILE "%s%s_%d_%lf.png", IMAGE_PATH, package_name(info), client_pid(inst->client), inst->timestamp);
+ snprintf(inst->id, len, SCHEMA_FILE "%s%s_%d_%lf.png", DYNAMICBOX_CONF_IMAGE_PATH, package_name(info), client_pid(inst->client), inst->timestamp);
- instance_set_pd_size(inst, package_pd_width(info), package_pd_height(info));
+ instance_set_gbar_size(inst, package_gbar_width(info), package_gbar_height(info));
- inst->lb.period = package_period(info);
+ inst->dbox.period = package_period(info);
inst->info = info;
- if (package_secured(info)) {
- if (inst->lb.period > 0.0f) {
- inst->update_timer = util_timer_add(inst->lb.period, update_timer_cb, inst);
+ if (package_secured(info) || (DBOX_IS_INHOUSE(package_abi(info)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL)) {
+ if (inst->dbox.period > 0.0f) {
+ inst->update_timer = util_timer_add(inst->dbox.period, update_timer_cb, inst);
if (!inst->update_timer) {
ErrPrint("Failed to add an update timer for instance %s\n", inst->id);
} else {
@@ -747,7 +838,7 @@ static inline int fork_package(struct inst_info *inst, const char *pkgname)
}
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_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)
@@ -761,8 +852,8 @@ HAPI struct inst_info *instance_create(struct client_node *client, double timest
}
inst->timestamp = timestamp;
- inst->lb.width = width;
- inst->lb.height = height;
+ inst->dbox.width = width;
+ inst->dbox.height = height;
inst->content = strdup(content);
if (!inst->content) {
@@ -788,7 +879,7 @@ HAPI struct inst_info *instance_create(struct client_node *client, double timest
return NULL;
}
- inst->title = strdup(DEFAULT_TITLE); /*!< Use the DEFAULT Title "" */
+ inst->title = strdup(DYNAMICBOX_CONF_DEFAULT_TITLE); /*!< Use the DEFAULT Title "" */
if (!inst->title) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(inst->category);
@@ -815,20 +906,35 @@ HAPI struct inst_info *instance_create(struct client_node *client, double timest
return NULL;
}
+ inst->unicast_delete_event = 1;
inst->state = INST_INIT;
inst->requested_state = INST_INIT;
+ if (DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT) {
+ inst->dbox.extra_buffer = calloc(DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT, sizeof(*inst->dbox.extra_buffer));
+ if (!inst->dbox.extra_buffer) {
+ ErrPrint("Failed to allocate buffer for dbox extra buffer\n");
+ }
+
+ inst->gbar.extra_buffer = calloc(DYNAMICBOX_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) {
- instance_destroy(inst, INSTANCE_DESTROY_FAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_FAULT);
return NULL;
}
slave_load_instance(package_slave(inst->info));
+ // 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, INSTANCE_DESTROY_FAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_FAULT);
inst = NULL;
}
@@ -913,21 +1019,25 @@ static void deactivate_cb(struct slave_node *slave, const struct packet *packet,
instance_reactivate(inst);
break;
case INST_DESTROYED:
- instance_broadcast_deleted_event(inst, ret);
+ 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, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
default:
/*!< Unable to reach here */
break;
}
break;
- case LB_STATUS_ERROR_INVALID:
+ case DBOX_STATUS_ERROR_INVALID_PARAMETER:
/*!
* \note
* Slave has no instance of this package.
*/
- case LB_STATUS_ERROR_NOT_EXIST:
+ case DBOX_STATUS_ERROR_NOT_EXIST:
/*!
* \note
* This instance's previous state is only can be the INST_ACTIVATED.
@@ -944,25 +1054,28 @@ static void deactivate_cb(struct slave_node *slave, const struct packet *packet,
/*!
* \note
* Failed to unload this instance.
- * This is not possible, slave will always return LB_STATUS_ERROR_NOT_EXIST, LB_STATUS_ERROR_INVALID, or 0.
+ * This is not possible, slave will always return DBOX_STATUS_ERROR_NOT_EXIST, DBOX_STATUS_ERROR_INVALID_PARAMETER, or 0.
* but care this exceptional case.
*/
instance_broadcast_deleted_event(inst, ret);
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
}
out:
- inst->changing_state = 0;
+ 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 lb_type lb_type;
- enum pd_type pd_type;
+ enum dynamicbox_dbox_type dbox_type;
+ enum dynamicbox_gbar_type gbar_type;
int ret;
const char *content;
const char *title;
@@ -1022,12 +1135,12 @@ static void reactivate_cb(struct slave_node *slave, const struct packet *packet,
inst->state = INST_ACTIVATED;
switch (inst->requested_state) {
case INST_DESTROYED:
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
case INST_ACTIVATED:
inst->is_pinned_up = is_pinned_up;
- lb_type = package_lb_type(inst->info);
- pd_type = package_pd_type(inst->info);
+ dbox_type = package_dbox_type(inst->info);
+ gbar_type = package_gbar_type(inst->info);
/*!
* \note
@@ -1041,64 +1154,64 @@ static void reactivate_cb(struct slave_node *slave, const struct packet *packet,
* Just leave it only for now.
*/
- if (lb_type == LB_TYPE_SCRIPT && inst->lb.canvas.script) {
- script_handler_load(inst->lb.canvas.script, 0);
- } else if (lb_type == LB_TYPE_BUFFER && inst->lb.canvas.buffer) {
- buffer_handler_load(inst->lb.canvas.buffer);
+ if (dbox_type == DBOX_TYPE_SCRIPT && inst->dbox.canvas.script) {
+ script_handler_load(inst->dbox.canvas.script, 0);
+ } else if (dbox_type == DBOX_TYPE_BUFFER && inst->dbox.canvas.buffer) {
+ buffer_handler_load(inst->dbox.canvas.buffer);
}
- if (pd_type == PD_TYPE_SCRIPT && inst->pd.canvas.script && inst->pd.is_opened_for_reactivate) {
+ 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 PD to slave.
- * if we didn't send it, the slave will not recognize the state of a PD.
- * We have to keep the view of PD seamless even if the livebox is reactivated.
+ * 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 dynamicbox is reactivated.
* To do that, send open request from here.
*/
- ret = instance_slave_open_pd(inst, NULL);
- instance_slave_get_pd_pos(inst, &x, &y);
+ ret = instance_slave_open_gbar(inst, NULL);
+ instance_slave_get_gbar_pos(inst, &x, &y);
/*!
* \note
- * In this case, master already loads the PD script.
- * So just send the pd,show event to the slave again.
+ * 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, "pd,show", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
- } else if (pd_type == PD_TYPE_BUFFER && inst->pd.canvas.buffer && inst->pd.is_opened_for_reactivate) {
+ 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->pd.canvas.buffer);
- instance_slave_get_pd_pos(inst, &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 PD to slave.
- * if we didn't send it, the slave will not recognize the state of a PD.
- * We have to keep the view of PD seamless even if the livebox is reactivated.
+ * 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 dynamicbox is reactivated.
* To do that, send open request from here.
*/
- ret = instance_slave_open_pd(inst, NULL);
+ ret = instance_slave_open_gbar(inst, NULL);
/*!
* \note
- * In this case, just send the pd,show event for keeping the compatibility
+ * In this case, just send the gbar,show event for keeping the compatibility
*/
- ret = instance_signal_emit(inst, "pd,show", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
+ 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 livebox.
- * instance_resize(inst, inst->lb.width, inst->lb.height);
+ * Send resize request to the dynamicbox.
+ * instance_resize(inst, inst->dbox.width, inst->dbox.height);
*
- * renew request will resize the livebox while creating it again
+ * renew request will resize the dynamicbox while creating it again
*/
/*!
* \note
- * This function will check the visiblity of a livebox and
+ * This function will check the visiblity of a dynamicbox and
* make decision whether it thaw the update timer or not.
*/
instance_recover_visible_state(inst);
@@ -1109,12 +1222,15 @@ static void reactivate_cb(struct slave_node *slave, const struct packet *packet,
default:
instance_broadcast_deleted_event(inst, ret);
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
}
out:
- inst->changing_state = 0;
+ inst->changing_state--;
+ if (inst->changing_state < 0) {
+ ErrPrint("Changing state is not correct: %d\n", inst->changing_state);
+ }
instance_unref(inst);
}
@@ -1156,11 +1272,11 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v
switch (ret) {
case 1: /*!< need to create */
- if (util_free_space(IMAGE_PATH) > MINIMUM_SPACE) {
+ if (util_free_space(DYNAMICBOX_CONF_IMAGE_PATH) > DYNAMICBOX_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->lb.period, 0, 0);
+ inst->content, inst->cluster, inst->category,
+ inst->dbox.period, 0, 0);
if (!new_inst) {
ErrPrint("Failed to create a new instance\n");
}
@@ -1174,58 +1290,59 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v
* just increase the loaded instance counter
* And then reset jobs.
*/
- instance_set_lb_size(inst, w, h);
- instance_set_lb_info(inst, priority, content, title);
+ instance_set_dbox_size(inst, w, h);
+ instance_set_dbox_info(inst, priority, content, title);
inst->state = INST_ACTIVATED;
switch (inst->requested_state) {
case INST_DESTROYED:
- instance_unicast_deleted_event(inst, NULL, ret);
- instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ /**
+ * In this case, we should destroy the instance.
+ */
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
case INST_ACTIVATED:
default:
- /*!
- * \note
- * LB should be created at the create time
+ /**
+ * @note
+ * DBOX should be created at the create time
*/
inst->is_pinned_up = is_pinned_up;
- if (package_lb_type(inst->info) == LB_TYPE_SCRIPT) {
- if (inst->lb.width == 0 && inst->lb.height == 0) {
- livebox_service_get_size(LB_SIZE_TYPE_1x1, &inst->lb.width, &inst->lb.height);
+ if (package_dbox_type(inst->info) == DBOX_TYPE_SCRIPT) {
+ if (inst->dbox.width == 0 && inst->dbox.height == 0) {
+ dynamicbox_service_get_size(DBOX_SIZE_TYPE_1x1, &inst->dbox.width, &inst->dbox.height);
}
- inst->lb.canvas.script = script_handler_create(inst,
- package_lb_path(inst->info),
- package_lb_group(inst->info),
- inst->lb.width, inst->lb.height);
+ inst->dbox.canvas.script = script_handler_create(inst,
+ package_dbox_path(inst->info),
+ package_dbox_group(inst->info),
+ inst->dbox.width, inst->dbox.height);
- if (!inst->lb.canvas.script) {
- ErrPrint("Failed to create LB\n");
+ if (!inst->dbox.canvas.script) {
+ ErrPrint("Failed to create DBOX\n");
} else {
- script_handler_load(inst->lb.canvas.script, 0);
+ script_handler_load(inst->dbox.canvas.script, 0);
}
- } else if (package_lb_type(inst->info) == LB_TYPE_BUFFER) {
- instance_create_lb_buffer(inst, DEFAULT_PIXELS);
+ } else if (package_dbox_type(inst->info) == DBOX_TYPE_BUFFER) {
+ instance_create_dbox_buffer(inst, DYNAMICBOX_CONF_DEFAULT_PIXELS);
}
- if (package_pd_type(inst->info) == PD_TYPE_SCRIPT) {
- if (inst->pd.width == 0 && inst->pd.height == 0) {
- instance_set_pd_size(inst, package_pd_width(inst->info), package_pd_height(inst->info));
+ 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->pd.canvas.script = script_handler_create(inst,
- package_pd_path(inst->info),
- package_pd_group(inst->info),
- inst->pd.width, inst->pd.height);
+ 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->pd.canvas.script) {
- ErrPrint("Failed to create PD\n");
+ if (!inst->gbar.canvas.script) {
+ ErrPrint("Failed to create GBAR\n");
}
- } else if (package_pd_type(inst->info) == PD_TYPE_BUFFER) {
- instance_create_pd_buffer(inst, DEFAULT_PIXELS);
+ } else if (package_gbar_type(inst->info) == GBAR_TYPE_BUFFER) {
+ instance_create_gbar_buffer(inst, DYNAMICBOX_CONF_DEFAULT_PIXELS);
}
instance_broadcast_created_event(inst);
@@ -1237,59 +1354,103 @@ static void activate_cb(struct slave_node *slave, const struct packet *packet, v
default:
instance_unicast_deleted_event(inst, NULL, ret);
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
}
out:
- inst->changing_state = 0;
+ 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_pd_buffer(struct inst_info *inst, int pixels)
+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->pd.width == 0 && inst->pd.height == 0) {
- instance_set_pd_size(inst, package_pd_width(inst->info), package_pd_height(inst->info));
+ 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->pd.canvas.buffer) {
- inst->pd.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->pd.width, inst->pd.height, pixels);
- if (!inst->pd.canvas.buffer) {
- ErrPrint("Failed to create PD Buffer\n");
+ 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->pd.canvas.buffer;
+ return !!inst->gbar.extra_buffer[idx];
}
-HAPI int instance_create_lb_buffer(struct inst_info *inst, int pixels)
+HAPI int instance_create_dbox_buffer(struct inst_info *inst, int pixels)
{
- if (inst->lb.width == 0 && inst->lb.height == 0) {
- livebox_service_get_size(LB_SIZE_TYPE_1x1, &inst->lb.width, &inst->lb.height);
+ if (inst->dbox.width == 0 && inst->dbox.height == 0) {
+ dynamicbox_service_get_size(DBOX_SIZE_TYPE_1x1, &inst->dbox.width, &inst->dbox.height);
}
- if (!inst->lb.canvas.buffer) {
+ if (!inst->dbox.canvas.buffer) {
/*!
* \note
* Slave doesn't call the acquire_buffer.
* In this case, create the buffer from here.
*/
- inst->lb.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->lb.width, inst->lb.height, pixels);
- if (!inst->lb.canvas.buffer) {
- ErrPrint("Failed to create LB\n");
+ inst->dbox.canvas.buffer = buffer_handler_create(inst, s_info.env_buf_type, inst->dbox.width, inst->dbox.height, pixels);
+ if (!inst->dbox.canvas.buffer) {
+ ErrPrint("Failed to create DBOX\n");
}
}
- return !!inst->lb.canvas.buffer;
+ return !!inst->dbox.canvas.buffer;
}
-HAPI int instance_destroy(struct inst_info *inst, enum instance_destroy_type type)
+HAPI int instance_create_dbox_extra_buffer(struct inst_info *inst, int pixels, int idx)
+{
+ if (!inst->dbox.extra_buffer) {
+ return 0;
+ }
+
+ if (inst->dbox.width == 0 && inst->dbox.height == 0) {
+ dynamicbox_service_get_size(DBOX_SIZE_TYPE_1x1, &inst->dbox.width, &inst->dbox.height);
+ }
+
+ if (!inst->dbox.extra_buffer[idx]) {
+ inst->dbox.extra_buffer[idx] = buffer_handler_create(inst, s_info.env_buf_type, inst->dbox.width, inst->dbox.height, pixels);
+ if (!inst->dbox.extra_buffer[idx]) {
+ ErrPrint("Failed to create DBox Extra buffer\n");
+ }
+ }
+
+ return !!inst->dbox.extra_buffer[idx];
+}
+
+HAPI int instance_destroy(struct inst_info *inst, dynamicbox_destroy_type_e type)
{
struct packet *packet;
+ unsigned int cmd = CMD_DELETE;
if (!inst) {
ErrPrint("Invalid instance handle\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
switch (inst->state) {
@@ -1297,40 +1458,41 @@ HAPI int instance_destroy(struct inst_info *inst, enum instance_destroy_type typ
case INST_REQUEST_TO_DESTROY:
case INST_REQUEST_TO_REACTIVATE:
inst->requested_state = INST_DESTROYED;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
case INST_INIT:
inst->state = INST_DESTROYED;
inst->requested_state = INST_DESTROYED;
(void)instance_unref(inst);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
case INST_DESTROYED:
inst->requested_state = INST_DESTROYED;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
default:
break;
}
- packet = packet_create("delete", "ssi", package_name(inst->info), inst->id, type);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
inst->destroy_type = type;
inst->requested_state = INST_DESTROYED;
inst->state = INST_REQUEST_TO_DESTROY;
- inst->changing_state = 1;
+ 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, enum instance_destroy_type type)
+HAPI int instance_reload(struct inst_info *inst, dynamicbox_destroy_type_e type)
{
struct packet *packet;
+ unsigned int cmd = CMD_DELETE;
int ret;
if (!inst) {
ErrPrint("Invalid instance handle\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
DbgPrint("Reload instance (%s)\n", instance_id(inst));
@@ -1338,42 +1500,42 @@ HAPI int instance_reload(struct inst_info *inst, enum instance_destroy_type type
switch (inst->state) {
case INST_REQUEST_TO_ACTIVATE:
case INST_REQUEST_TO_REACTIVATE:
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_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 LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
case INST_DESTROYED:
case INST_REQUEST_TO_DESTROY:
DbgPrint("Instance is destroying now\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
default:
break;
}
- packet = packet_create("delete", "ssi", package_name(inst->info), inst->id, type);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
inst->destroy_type = type;
inst->requested_state = INST_ACTIVATED;
inst->state = INST_REQUEST_TO_DESTROY;
- inst->changing_state = 1;
+ 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 pd_buffer_close_cb(struct client_node *client, void *inst)
+static int gbar_buffer_close_cb(struct client_node *client, void *inst)
{
int ret;
- ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_NORMAL);
+ ret = instance_slave_close_gbar(inst, client, DBOX_CLOSE_GBAR_NORMAL);
if (ret < 0) {
- DbgPrint("Forcely close the PD ret: %d\n", ret);
+ DbgPrint("Forcely close the GBAR ret: %d\n", ret);
}
instance_unref(inst);
@@ -1382,18 +1544,18 @@ static int pd_buffer_close_cb(struct client_node *client, void *inst)
}
/* Client Deactivated Callback */
-static int pd_script_close_cb(struct client_node *client, void *inst)
+static int gbar_script_close_cb(struct client_node *client, void *inst)
{
int ret;
- ret = script_handler_unload(instance_pd_script(inst), 1);
+ ret = script_handler_unload(instance_gbar_script(inst), 1);
if (ret < 0) {
DbgPrint("Unload script: %d\n", ret);
}
- ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_NORMAL);
+ ret = instance_slave_close_gbar(inst, client, DBOX_CLOSE_GBAR_NORMAL);
if (ret < 0) {
- DbgPrint("Forcely close the PD ret: %d\n", ret);
+ DbgPrint("Forcely close the GBAR ret: %d\n", ret);
}
instance_unref(inst);
@@ -1401,10 +1563,10 @@ static int pd_script_close_cb(struct client_node *client, void *inst)
return -1; /* Delete this callback */
}
-static inline void release_resource_for_closing_pd(struct pkg_info *info, struct inst_info *inst, struct client_node *client)
+static inline void release_resource_for_closing_gbar(struct pkg_info *info, struct inst_info *inst, struct client_node *client)
{
if (!client) {
- client = inst->pd.owner;
+ client = inst->gbar.owner;
if (!client) {
return;
}
@@ -1414,17 +1576,17 @@ static inline void release_resource_for_closing_pd(struct pkg_info *info, struct
* \note
* Clean up the resources
*/
- if (package_pd_type(info) == PD_TYPE_BUFFER) {
- if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, pd_buffer_close_cb, inst) == 0) {
+ 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 pd_buffer_close_cb,
+ * 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_pd_type(info) == PD_TYPE_SCRIPT) {
- if (client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, pd_script_close_cb, inst) == 0) {
+ } 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,
@@ -1433,63 +1595,64 @@ static inline void release_resource_for_closing_pd(struct pkg_info *info, struct
instance_unref(inst);
}
} else {
- ErrPrint("Unknown PD type\n");
+ ErrPrint("Unknown GBAR type\n");
}
}
HAPI int instance_state_reset(struct inst_info *inst)
{
- enum lb_type lb_type;
- enum pd_type pd_type;
+ enum dynamicbox_dbox_type dbox_type;
+ enum dynamicbox_gbar_type gbar_type;
if (!inst) {
ErrPrint("Invalid instance handle\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (inst->state == INST_DESTROYED) {
goto out;
}
- lb_type = package_lb_type(inst->info);
- pd_type = package_pd_type(inst->info);
+ dbox_type = package_dbox_type(inst->info);
+ gbar_type = package_gbar_type(inst->info);
- if (lb_type == LB_TYPE_SCRIPT && inst->lb.canvas.script) {
- script_handler_unload(inst->lb.canvas.script, 0);
- } else if (lb_type == LB_TYPE_BUFFER && inst->lb.canvas.buffer) {
- buffer_handler_unload(inst->lb.canvas.buffer);
+ if (dbox_type == DBOX_TYPE_SCRIPT && inst->dbox.canvas.script) {
+ script_handler_unload(inst->dbox.canvas.script, 0);
+ } else if (dbox_type == DBOX_TYPE_BUFFER && inst->dbox.canvas.buffer) {
+ buffer_handler_unload(inst->dbox.canvas.buffer);
}
- if (pd_type == PD_TYPE_SCRIPT && inst->pd.canvas.script) {
- inst->pd.is_opened_for_reactivate = script_handler_is_loaded(inst->pd.canvas.script);
- release_resource_for_closing_pd(instance_package(inst), inst, NULL);
- script_handler_unload(inst->pd.canvas.script, 1);
- } else if (pd_type == PD_TYPE_BUFFER && inst->pd.canvas.buffer) {
- inst->pd.is_opened_for_reactivate = buffer_handler_is_loaded(inst->pd.canvas.buffer);
- release_resource_for_closing_pd(instance_package(inst), inst, NULL);
- buffer_handler_unload(inst->pd.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 LB_STATUS_SUCCESS;
+ return DBOX_STATUS_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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (package_is_fault(inst->info)) {
ErrPrint("Fault package [%s]\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
switch (inst->state) {
@@ -1497,35 +1660,36 @@ HAPI int instance_reactivate(struct inst_info *inst)
case INST_REQUEST_TO_ACTIVATE:
case INST_REQUEST_TO_REACTIVATE:
inst->requested_state = INST_ACTIVATED;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
case INST_DESTROYED:
case INST_ACTIVATED:
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
case INST_INIT:
default:
break;
}
- packet = packet_create("renew", "sssiidssiisii",
+ packet = packet_create((const char *)&cmd, "sssiidssiisiis",
package_name(inst->info),
inst->id,
inst->content,
package_timeout(inst->info),
- !!package_lb_path(inst->info),
- inst->lb.period,
+ !!package_dbox_path(inst->info),
+ inst->dbox.period,
inst->cluster,
inst->category,
- inst->lb.width, inst->lb.height,
+ inst->dbox.width, inst->dbox.height,
package_abi(inst->info),
inst->scroll_locked,
- inst->active_update);
+ inst->active_update,
+ client_direct_addr(inst->client));
if (!packet) {
ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
ret = slave_activate(package_slave(inst->info));
- if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY) {
+ if (ret < 0 && ret != DBOX_STATUS_ERROR_ALREADY) {
/*!
* \note
* If the master failed to launch the slave,
@@ -1538,7 +1702,7 @@ HAPI int instance_reactivate(struct inst_info *inst)
inst->requested_state = INST_ACTIVATED;
inst->state = INST_REQUEST_TO_REACTIVATE;
- inst->changing_state = 1;
+ inst->changing_state++;
return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, reactivate_cb, instance_ref(inst), 1);
}
@@ -1546,16 +1710,17 @@ HAPI int instance_reactivate(struct inst_info *inst)
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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (package_is_fault(inst->info)) {
ErrPrint("Fault package [%s]\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
switch (inst->state) {
@@ -1563,35 +1728,36 @@ HAPI int instance_activate(struct inst_info *inst)
case INST_REQUEST_TO_ACTIVATE:
case INST_REQUEST_TO_DESTROY:
inst->requested_state = INST_ACTIVATED;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
case INST_ACTIVATED:
case INST_DESTROYED:
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
case INST_INIT:
default:
break;
}
- packet = packet_create("new", "sssiidssisii",
+ packet = packet_create((const char *)&cmd, "sssiidssisiis",
package_name(inst->info),
inst->id,
inst->content,
package_timeout(inst->info),
- !!package_lb_path(inst->info),
- inst->lb.period,
+ !!package_dbox_path(inst->info),
+ inst->dbox.period,
inst->cluster,
inst->category,
!!inst->client,
package_abi(inst->info),
- inst->lb.width,
- inst->lb.height);
+ inst->dbox.width,
+ inst->dbox.height,
+ client_direct_addr(inst->client));
if (!packet) {
ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
ret = slave_activate(package_slave(inst->info));
- if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY) {
+ if (ret < 0 && ret != DBOX_STATUS_ERROR_ALREADY) {
/*!
* \note
* If the master failed to launch the slave,
@@ -1604,7 +1770,7 @@ HAPI int instance_activate(struct inst_info *inst)
inst->state = INST_REQUEST_TO_ACTIVATE;
inst->requested_state = INST_ACTIVATED;
- inst->changing_state = 1;
+ inst->changing_state++;
/*!
* \note
@@ -1613,210 +1779,244 @@ HAPI int instance_activate(struct inst_info *inst)
return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, activate_cb, instance_ref(inst), 1);
}
-HAPI int instance_lb_update_begin(struct inst_info *inst, double priority, const char *content, const char *title)
+HAPI int instance_dbox_update_begin(struct inst_info *inst, double priority, const char *content, const char *title)
{
struct packet *packet;
const char *fbfile;
+ unsigned int cmd = CMD_DBOX_UPDATE_BEGIN;
if (!inst->active_update) {
ErrPrint("Invalid request [%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- switch (package_lb_type(inst->info)) {
- case LB_TYPE_BUFFER:
- if (!inst->lb.canvas.buffer) {
+ switch (package_dbox_type(inst->info)) {
+ case DBOX_TYPE_BUFFER:
+ if (!inst->dbox.canvas.buffer) {
ErrPrint("Buffer is null [%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- fbfile = buffer_handler_id(inst->lb.canvas.buffer);
+ fbfile = buffer_handler_id(inst->dbox.canvas.buffer);
break;
- case LB_TYPE_SCRIPT:
- if (!inst->lb.canvas.script) {
+ case DBOX_TYPE_SCRIPT:
+ if (!inst->dbox.canvas.script) {
ErrPrint("Script is null [%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- fbfile = script_handler_buffer_id(inst->lb.canvas.script);
+ fbfile = script_handler_buffer_id(inst->dbox.canvas.script);
break;
default:
ErrPrint("Invalid request[%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack("lb_update_begin", "ssdsss", package_name(inst->info), inst->id, priority, content, title, fbfile);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return CLIENT_SEND_EVENT(inst, packet);
}
-HAPI int instance_lb_update_end(struct inst_info *inst)
+HAPI int instance_dbox_update_end(struct inst_info *inst)
{
struct packet *packet;
+ unsigned int cmd = CMD_DBOX_UPDATE_END;
if (!inst->active_update) {
ErrPrint("Invalid request [%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- switch (package_lb_type(inst->info)) {
- case LB_TYPE_BUFFER:
- if (!inst->lb.canvas.buffer) {
+ switch (package_dbox_type(inst->info)) {
+ case DBOX_TYPE_BUFFER:
+ if (!inst->dbox.canvas.buffer) {
ErrPrint("Buffer is null [%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
break;
- case LB_TYPE_SCRIPT:
- if (!inst->lb.canvas.script) {
+ case DBOX_TYPE_SCRIPT:
+ if (!inst->dbox.canvas.script) {
ErrPrint("Script is null [%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
break;
default:
ErrPrint("Invalid request[%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack("lb_update_end", "ss", package_name(inst->info), inst->id);
+ packet = packet_create_noack((const char *)&cmd, "ss", package_name(inst->info), inst->id);
if (!packet) {
ErrPrint("Unable to create a packet\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return CLIENT_SEND_EVENT(inst, packet);
}
-HAPI int instance_pd_update_begin(struct inst_info *inst)
+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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- switch (package_pd_type(inst->info)) {
- case PD_TYPE_BUFFER:
- if (!inst->pd.canvas.buffer) {
+ switch (package_gbar_type(inst->info)) {
+ case GBAR_TYPE_BUFFER:
+ if (!inst->gbar.canvas.buffer) {
ErrPrint("Buffer is null [%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- fbfile = buffer_handler_id(inst->pd.canvas.buffer);
+ fbfile = buffer_handler_id(inst->gbar.canvas.buffer);
break;
- case PD_TYPE_SCRIPT:
- if (!inst->pd.canvas.script) {
+ case GBAR_TYPE_SCRIPT:
+ if (!inst->gbar.canvas.script) {
ErrPrint("Script is null [%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- fbfile = script_handler_buffer_id(inst->pd.canvas.script);
+ fbfile = script_handler_buffer_id(inst->gbar.canvas.script);
break;
default:
ErrPrint("Invalid request[%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack("pd_update_begin", "sss", package_name(inst->info), inst->id, fbfile);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return CLIENT_SEND_EVENT(inst, packet);
}
-HAPI int instance_pd_update_end(struct inst_info *inst)
+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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- switch (package_pd_type(inst->info)) {
- case PD_TYPE_BUFFER:
- if (!inst->pd.canvas.buffer) {
+ switch (package_gbar_type(inst->info)) {
+ case GBAR_TYPE_BUFFER:
+ if (!inst->gbar.canvas.buffer) {
ErrPrint("Buffer is null [%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
break;
- case PD_TYPE_SCRIPT:
- if (!inst->pd.canvas.script) {
+ case GBAR_TYPE_SCRIPT:
+ if (!inst->gbar.canvas.script) {
ErrPrint("Script is null [%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
break;
default:
ErrPrint("Invalid request[%s]\n", inst->id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack("pd_update_end", "ss", package_name(inst->info), inst->id);
+ packet = packet_create_noack((const char *)&cmd, "ss", package_name(inst->info), inst->id);
if (!packet) {
ErrPrint("Unable to create a packet\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return CLIENT_SEND_EVENT(inst, packet);
}
-HAPI void instance_lb_updated_by_instance(struct inst_info *inst, const char *safe_file)
+HAPI void instance_extra_info_updated_by_instance(struct inst_info *inst)
{
struct packet *packet;
- const char *id;
- enum lb_type lb_type;
- const char *title;
- const char *content;
- const char *icon;
- const char *name;
+ unsigned int cmd = CMD_EXTRA_INFO;
- if (inst->client && inst->visible != LB_SHOW) {
- if (inst->visible == LB_HIDE) {
- DbgPrint("Ignore update event %s(HIDE)\n", inst->id);
+ packet = packet_create_noack((const char *)&cmd, "ssssssd", package_name(inst->info), inst->id,
+ inst->content, inst->title,
+ inst->icon, inst->name,
+ inst->dbox.priority);
+ if (!packet) {
+ ErrPrint("Failed to create param (%s - %s)\n", package_name(inst->info), inst->id);
+ return;
+ }
+
+ (void)CLIENT_SEND_EVENT(inst, packet);
+}
+
+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 dynamicbox_dbox_type dbox_type;
+ unsigned int cmd = CMD_EXTRA_UPDATED;
+
+ if (idx < 0 || idx > DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT) {
+ ErrPrint("Invalid index\n");
+ return;
+ }
+
+ if (is_gbar == 0) {
+ if (!inst->dbox.extra_buffer || inst->dbox.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;
}
- DbgPrint("Livebox(%s) is PAUSED. But content is updated.\n", inst->id);
}
- lb_type = package_lb_type(inst->info);
- if (lb_type == LB_TYPE_SCRIPT) {
- id = script_handler_buffer_id(inst->lb.canvas.script);
- } else if (lb_type == LB_TYPE_BUFFER) {
- id = buffer_handler_id(inst->lb.canvas.buffer);
- } else {
- id = "";
+ if (inst->client && inst->visible != DBOX_SHOW) {
+ if (inst->visible == DBOX_HIDE) {
+ DbgPrint("Ignore update event %s(HIDE)\n", inst->id);
+ return;
+ }
}
- if (inst->content) {
- content = inst->content;
- } else {
- content = "";
+ dbox_type = package_dbox_type(inst->info);
+ if (dbox_type != DBOX_TYPE_BUFFER) {
+ ErrPrint("Unsupported type\n");
+ return;
}
- if (inst->title) {
- title = inst->title;
- } else {
- title = "";
+ 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;
}
- if (inst->icon) {
- icon = inst->icon;
- } else {
- icon = "";
+ (void)CLIENT_SEND_EVENT(inst, packet);
+}
+
+HAPI void instance_dbox_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 dynamicbox_dbox_type dbox_type;
+ unsigned int cmd = CMD_DBOX_UPDATED;
+
+ if (inst->client && inst->visible != DBOX_SHOW) {
+ if (inst->visible == DBOX_HIDE) {
+ DbgPrint("Ignore update event %s(HIDE)\n", inst->id);
+ return;
+ }
}
- if (inst->name) {
- name = inst->name;
- } else {
- name = "";
+ dbox_type = package_dbox_type(inst->info);
+ if (dbox_type == DBOX_TYPE_SCRIPT) {
+ id = script_handler_buffer_id(inst->dbox.canvas.script);
+ } else if (dbox_type == DBOX_TYPE_BUFFER) {
+ id = buffer_handler_id(inst->dbox.canvas.buffer);
}
- packet = packet_create_noack("lb_updated", "sssiidsssss",
- package_name(inst->info), inst->id, id,
- inst->lb.width, inst->lb.height, inst->lb.priority, content, title, safe_file, icon, name);
+ 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;
@@ -1828,48 +2028,50 @@ HAPI void instance_lb_updated_by_instance(struct inst_info *inst, const char *sa
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 LB_STATUS_ERROR_ALREADY;
+ return DBOX_STATUS_ERROR_ALREADY;
}
- packet = packet_create_noack("scroll", "ssi", package_name(inst->info), inst->id, hold);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
inst->scroll_locked = hold;
return CLIENT_SEND_EVENT(inst, packet);
}
-HAPI void instance_pd_updated_by_instance(struct inst_info *inst, const char *descfile)
+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 != LB_SHOW) {
- DbgPrint("Livebox is hidden. ignore update event\n");
+ if (inst->client && inst->visible != DBOX_SHOW) {
+ DbgPrint("Dynamicbox is hidden. ignore update event\n");
return;
}
- if (!inst->pd.need_to_send_close_event) {
- DbgPrint("PD is not created yet. Ignore update event - %s\n", descfile);
+ if (!inst->gbar.need_to_send_close_event) {
+ DbgPrint("GBAR is not created yet. Ignore update event - %s\n", descfile);
- if (inst->pd.pended_update_desc) {
- DbgFree(inst->pd.pended_update_desc);
- inst->pd.pended_update_desc = NULL;
+ if (inst->gbar.pended_update_desc) {
+ DbgFree(inst->gbar.pended_update_desc);
+ inst->gbar.pended_update_desc = NULL;
}
if (descfile) {
- inst->pd.pended_update_desc = strdup(descfile);
- if (!inst->pd.pended_update_desc) {
+ inst->gbar.pended_update_desc = strdup(descfile);
+ if (!inst->gbar.pended_update_desc) {
ErrPrint("Heap: %s\n", strerror(errno));
}
}
- inst->pd.pended_update_cnt++;
+ inst->gbar.pended_update_cnt++;
return;
}
@@ -1877,22 +2079,20 @@ HAPI void instance_pd_updated_by_instance(struct inst_info *inst, const char *de
descfile = inst->id;
}
- switch (package_pd_type(inst->info)) {
- case PD_TYPE_SCRIPT:
- id = script_handler_buffer_id(inst->pd.canvas.script);
+ switch (package_gbar_type(inst->info)) {
+ case GBAR_TYPE_SCRIPT:
+ id = script_handler_buffer_id(inst->gbar.canvas.script);
break;
- case PD_TYPE_BUFFER:
- id = buffer_handler_id(inst->pd.canvas.buffer);
+ case GBAR_TYPE_BUFFER:
+ id = buffer_handler_id(inst->gbar.canvas.buffer);
break;
- case PD_TYPE_TEXT:
+ case GBAR_TYPE_TEXT:
default:
id = "";
break;
}
- packet = packet_create_noack("pd_updated", "ssssii",
- package_name(inst->info), inst->id, descfile, id,
- inst->pd.width, inst->pd.height);
+ 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;
@@ -1901,7 +2101,7 @@ HAPI void instance_pd_updated_by_instance(struct inst_info *inst, const char *de
(void)CLIENT_SEND_EVENT(inst, packet);
}
-HAPI void instance_pd_updated(const char *pkgname, const char *id, const char *descfile)
+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;
@@ -1910,40 +2110,41 @@ HAPI void instance_pd_updated(const char *pkgname, const char *id, const char *d
return;
}
- instance_pd_updated_by_instance(inst, descfile);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (inst->active_update == active_update) {
DbgPrint("Active update is not changed: %d\n", inst->active_update);
- return LB_STATUS_ERROR_ALREADY;
+ return DBOX_STATUS_ERROR_ALREADY;
}
cbdata = malloc(sizeof(*cbdata));
if (!cbdata) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
cbdata->inst = instance_ref(inst);
cbdata->active_update = active_update;
/* NOTE: param is resued from here */
- packet = packet_create("update_mode", "ssi", package_name(inst->info), inst->id, active_update);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, update_mode_cb, cbdata, 0);
@@ -1954,7 +2155,7 @@ HAPI int instance_active_update(struct inst_info *inst)
return inst->active_update;
}
-HAPI void instance_set_lb_info(struct inst_info *inst, double priority, const char *content, const char *title)
+HAPI void instance_set_dbox_info(struct inst_info *inst, double priority, const char *content, const char *title)
{
char *_content = NULL;
char *_title = NULL;
@@ -1984,7 +2185,7 @@ HAPI void instance_set_lb_info(struct inst_info *inst, double priority, const ch
}
if (priority >= 0.0f && priority <= 1.0f) {
- inst->lb.priority = priority;
+ inst->dbox.priority = priority;
}
}
@@ -2018,24 +2219,24 @@ HAPI void instance_set_alt_info(struct inst_info *inst, const char *icon, const
}
}
-HAPI void instance_set_lb_size(struct inst_info *inst, int w, int h)
+HAPI void instance_set_dbox_size(struct inst_info *inst, int w, int h)
{
- if (inst->lb.width != w || inst->lb.height != h) {
- instance_send_resized_event(inst, IS_LB, w, h, LB_STATUS_SUCCESS);
+ if (inst->dbox.width != w || inst->dbox.height != h) {
+ instance_send_resized_event(inst, IS_DBOX, w, h, DBOX_STATUS_ERROR_NONE);
}
- inst->lb.width = w;
- inst->lb.height = h;
+ inst->dbox.width = w;
+ inst->dbox.height = h;
}
-HAPI void instance_set_pd_size(struct inst_info *inst, int w, int h)
+HAPI void instance_set_gbar_size(struct inst_info *inst, int w, int h)
{
- if (inst->pd.width != w || inst->pd.height != h) {
- instance_send_resized_event(inst, IS_PD, w, h, LB_STATUS_SUCCESS);
+ if (inst->gbar.width != w || inst->gbar.height != h) {
+ instance_send_resized_event(inst, IS_GBAR, w, h, DBOX_STATUS_ERROR_NONE);
}
- inst->pd.width = w;
- inst->pd.height = h;
+ inst->gbar.width = w;
+ inst->gbar.height = h;
}
static void pinup_cb(struct slave_node *slave, const struct packet *packet, void *data)
@@ -2043,6 +2244,7 @@ static void pinup_cb(struct slave_node *slave, const struct packet *packet, void
struct set_pinup_cbdata *cbdata = data;
const char *content;
struct packet *result;
+ unsigned int cmd = CMD_RESULT_PINUP;
int ret;
if (!packet) {
@@ -2050,7 +2252,7 @@ static void pinup_cb(struct slave_node *slave, const struct packet *packet, void
* \todo
* Send pinup failed event to client.
*/
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
@@ -2059,7 +2261,7 @@ static void pinup_cb(struct slave_node *slave, const struct packet *packet, void
* \todo
* Send pinup failed event to client
*/
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
@@ -2073,10 +2275,10 @@ static void pinup_cb(struct slave_node *slave, const struct packet *packet, void
* \note
* send pinup failed event to client
*/
- ret = LB_STATUS_ERROR_MEMORY;
+ ret = DBOX_STATUS_ERROR_OUT_OF_MEMORY;
goto out;
}
-
+
cbdata->inst->is_pinned_up = cbdata->pinup;
DbgFree(cbdata->inst->content);
@@ -2089,8 +2291,8 @@ out:
* Send PINUP Result to client.
* Client should wait this event.
*/
- result = packet_create_noack("pinup", "iisss", ret, cbdata->inst->is_pinned_up,
- package_name(cbdata->inst->info), cbdata->inst->id, cbdata->inst->content);
+ 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);
} else {
@@ -2105,39 +2307,40 @@ 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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (package_is_fault(inst->info)) {
ErrPrint("Fault package [%s]\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (!package_pinup(inst->info)) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (pinup == inst->is_pinned_up) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
cbdata = malloc(sizeof(*cbdata));
if (!cbdata) {
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
cbdata->inst = instance_ref(inst);
cbdata->pinup = pinup;
- packet = packet_create("pinup", "ssi", package_name(inst->info), inst->id, 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, pinup_cb, cbdata, 0);
@@ -2146,47 +2349,47 @@ HAPI int instance_set_pinup(struct inst_info *inst, int pinup)
HAPI int instance_freeze_updator(struct inst_info *inst)
{
if (!inst->update_timer) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
timer_freeze(inst);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int instance_thaw_updator(struct inst_info *inst)
{
if (!inst->update_timer) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (client_is_all_paused() || setting_is_lcd_off()) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- if (inst->visible == LB_HIDE_WITH_PAUSE) {
- return LB_STATUS_ERROR_INVALID;
+ if (inst->visible == DBOX_HIDE_WITH_PAUSE) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
timer_thaw(inst);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI enum livebox_visible_state instance_visible_state(struct inst_info *inst)
+HAPI enum dynamicbox_visible_state instance_visible_state(struct inst_info *inst)
{
return inst->visible;
}
-HAPI int instance_set_visible_state(struct inst_info *inst, enum livebox_visible_state state)
+HAPI int instance_set_visible_state(struct inst_info *inst, enum dynamicbox_visible_state state)
{
if (inst->visible == state) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
switch (state) {
- case LB_SHOW:
- case LB_HIDE:
- if (inst->visible == LB_HIDE_WITH_PAUSE) {
- if (resume_livebox(inst) == 0) {
+ case DBOX_SHOW:
+ case DBOX_HIDE:
+ if (inst->visible == DBOX_HIDE_WITH_PAUSE) {
+ if (resume_dynamicbox(inst) == 0) {
inst->visible = state;
}
@@ -2196,19 +2399,19 @@ HAPI int instance_set_visible_state(struct inst_info *inst, enum livebox_visible
}
break;
- case LB_HIDE_WITH_PAUSE:
- if (pause_livebox(inst) == 0) {
- inst->visible = LB_HIDE_WITH_PAUSE;
+ case DBOX_HIDE_WITH_PAUSE:
+ if (pause_dynamicbox(inst) == 0) {
+ inst->visible = DBOX_HIDE_WITH_PAUSE;
}
instance_freeze_updator(inst);
break;
default:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static void resize_cb(struct slave_node *slave, const struct packet *packet, void *data)
@@ -2218,7 +2421,7 @@ static void resize_cb(struct slave_node *slave, const struct packet *packet, voi
if (!packet) {
ErrPrint("RESIZE: Invalid packet\n");
- instance_send_resized_event(cbdata->inst, IS_LB, cbdata->inst->lb.width, cbdata->inst->lb.height, LB_STATUS_ERROR_FAULT);
+ instance_send_resized_event(cbdata->inst, IS_DBOX, cbdata->inst->dbox.width, cbdata->inst->dbox.height, DBOX_STATUS_ERROR_FAULT);
instance_unref(cbdata->inst);
DbgFree(cbdata);
return;
@@ -2226,18 +2429,18 @@ static void resize_cb(struct slave_node *slave, const struct packet *packet, voi
if (packet_get(packet, "i", &ret) != 1) {
ErrPrint("RESIZE: Invalid parameter\n");
- instance_send_resized_event(cbdata->inst, IS_LB, cbdata->inst->lb.width, cbdata->inst->lb.height, LB_STATUS_ERROR_INVALID);
+ instance_send_resized_event(cbdata->inst, IS_DBOX, cbdata->inst->dbox.width, cbdata->inst->dbox.height, DBOX_STATUS_ERROR_INVALID_PARAMETER);
instance_unref(cbdata->inst);
DbgFree(cbdata);
return;
}
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
/*!
* \note
* else waiting the first update with new size
*/
- if (cbdata->inst->lb.width == cbdata->w && cbdata->inst->lb.height == cbdata->h) {
+ if (cbdata->inst->dbox.width == cbdata->w && cbdata->inst->dbox.height == cbdata->h) {
/*!
* \note
* Right after the viewer adds a new box,
@@ -2265,14 +2468,14 @@ static void resize_cb(struct slave_node *slave, const struct packet *packet, voi
* 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_LB, cbdata->inst->lb.width, cbdata->inst->lb.height, LB_STATUS_ERROR_ALREADY);
- DbgPrint("RESIZE: Livebox is already resized [%s - %dx%d]\n", instance_id(cbdata->inst), cbdata->w, cbdata->h);
+ instance_send_resized_event(cbdata->inst, IS_DBOX, cbdata->inst->dbox.width, cbdata->inst->dbox.height, DBOX_STATUS_ERROR_ALREADY);
+ DbgPrint("RESIZE: Dynamicbox 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: Livebox 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_LB, cbdata->inst->lb.width, cbdata->inst->lb.height, ret);
+ DbgPrint("RESIZE: Dynamicbox 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_DBOX, cbdata->inst->dbox.width, cbdata->inst->dbox.height, ret);
}
instance_unref(cbdata->inst);
@@ -2283,22 +2486,23 @@ 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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (package_is_fault(inst->info)) {
ErrPrint("Fault package: %s\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
cbdata = malloc(sizeof(*cbdata));
if (!cbdata) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
cbdata->inst = instance_ref(inst);
@@ -2306,12 +2510,12 @@ HAPI int instance_resize(struct inst_info *inst, int w, int h)
cbdata->h = h;
/* NOTE: param is resued from here */
- packet = packet_create("resize", "ssii", package_name(inst->info), inst->id, w, h);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
DbgPrint("RESIZE: [%s] resize[%dx%d]\n", instance_id(inst), w, h);
@@ -2321,28 +2525,29 @@ HAPI int instance_resize(struct inst_info *inst, int w, int h)
static void set_period_cb(struct slave_node *slave, const struct packet *packet, void *data)
{
- int ret;
struct period_cbdata *cbdata = data;
+ unsigned int cmd = CMD_PERIOD_CHANGED;
struct packet *result;
+ int ret;
if (!packet) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
if (packet_get(packet, "i", &ret) != 1) {
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
if (ret == 0) {
- cbdata->inst->lb.period = cbdata->period;
+ cbdata->inst->dbox.period = cbdata->period;
} else {
ErrPrint("Failed to set period %d\n", ret);
}
out:
- result = packet_create_noack("period_changed", "idss", ret, cbdata->inst->lb.period, package_name(cbdata->inst->info), cbdata->inst->id);
+ result = packet_create_noack((const char *)&cmd, "idss", ret, cbdata->inst->dbox.period, package_name(cbdata->inst->info), cbdata->inst->id);
if (result) {
(void)CLIENT_SEND_EVENT(cbdata->inst, result);
} else {
@@ -2358,23 +2563,24 @@ static Eina_Bool timer_updator_cb(void *data)
{
struct period_cbdata *cbdata = data;
struct inst_info *inst;
- double period;
struct packet *result;
+ unsigned int cmd = CMD_PERIOD_CHANGED;
+ double period;
period = cbdata->period;
inst = cbdata->inst;
DbgFree(cbdata);
- inst->lb.period = period;
+ inst->dbox.period = period;
if (inst->update_timer) {
- if (inst->lb.period == 0.0f) {
+ if (inst->dbox.period == 0.0f) {
ecore_timer_del(inst->update_timer);
inst->update_timer = NULL;
} else {
- util_timer_interval_set(inst->update_timer, inst->lb.period);
+ util_timer_interval_set(inst->update_timer, inst->dbox.period);
}
- } else if (inst->lb.period > 0.0f) {
- inst->update_timer = util_timer_add(inst->lb.period, update_timer_cb, inst);
+ } else if (inst->dbox.period > 0.0f) {
+ inst->update_timer = util_timer_add(inst->dbox.period, update_timer_cb, inst);
if (!inst->update_timer) {
ErrPrint("Failed to add an update timer for instance %s\n", inst->id);
} else {
@@ -2382,7 +2588,7 @@ static Eina_Bool timer_updator_cb(void *data)
}
}
- result = packet_create_noack("period_changed", "idss", 0, inst->lb.period, package_name(inst->info), inst->id);
+ result = packet_create_noack((const char *)&cmd, "idss", 0, inst->dbox.period, package_name(inst->info), inst->id);
if (result) {
(void)CLIENT_SEND_EVENT(inst, result);
} else {
@@ -2395,59 +2601,60 @@ static Eina_Bool timer_updator_cb(void *data)
HAPI void instance_reload_period(struct inst_info *inst, double period)
{
- inst->lb.period = period;
+ inst->dbox.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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (package_is_fault(inst->info)) {
ErrPrint("Fault package [%s]\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (period < 0.0f) { /* Use the default period */
period = package_period(inst->info);
- } else if (period > 0.0f && period < MINIMUM_PERIOD) {
- period = MINIMUM_PERIOD; /* defined at conf.h */
+ } else if (period > 0.0f && period < DYNAMICBOX_CONF_MINIMUM_PERIOD) {
+ period = DYNAMICBOX_CONF_MINIMUM_PERIOD; /* defined at conf.h */
}
cbdata = malloc(sizeof(*cbdata));
if (!cbdata) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
cbdata->period = period;
cbdata->inst = instance_ref(inst);
- if (package_secured(inst->info)) {
+ if (package_secured(inst->info) || (DBOX_IS_INHOUSE(package_abi(inst->info)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL)) {
/*!
* \note
- * Secured livebox doesn't need to send its update period to the slave.
- * Slave has no local timer for updating liveboxes
+ * Secured dynamicbox doesn't need to send its update period to the slave.
+ * Slave has no local timer for updating dynamicboxes
*
* So update its timer at here.
*/
if (!ecore_timer_add(DELAY_TIME, timer_updator_cb, cbdata)) {
timer_updator_cb(cbdata);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
- packet = packet_create("set_period", "ssd", package_name(inst->info), inst->id, period);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, set_period_cb, cbdata, 0);
@@ -2456,22 +2663,23 @@ HAPI int instance_set_period(struct inst_info *inst, double period)
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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (package_is_fault(inst->info)) {
ErrPrint("Fault package [%s]\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
/* NOTE: param is resued from here */
- packet = packet_create_noack("clicked", "sssddd", package_name(inst->info), inst->id, event, timestamp, x, y);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0);
@@ -2484,26 +2692,27 @@ HAPI int instance_signal_emit(struct inst_info *inst, const char *signal, const
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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
slave = package_slave(pkg);
if (!slave) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack("script", "ssssddddddi",
+ packet = packet_create_noack((const char *)&cmd, "ssssddddddi",
pkgname, id,
signal, part,
sx, sy, ex, ey,
x, y, down);
if (!packet) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_request_only(slave, pkgname, packet, 0);
@@ -2512,21 +2721,22 @@ HAPI int instance_signal_emit(struct inst_info *inst, const char *signal, const
HAPI int instance_text_signal_emit(struct inst_info *inst, const char *emission, 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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (package_is_fault(inst->info)) {
ErrPrint("Fault package [%s]\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- packet = packet_create_noack("text_signal", "ssssdddd", package_name(inst->info), inst->id, emission, source, sx, sy, ex, ey);
+ packet = packet_create_noack((const char *)&cmd, "ssssdddd", package_name(inst->info), inst->id, emission, source, sx, sy, ex, ey);
if (!packet) {
ErrPrint("Failed to build a packet for %s\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_request_only(package_slave(inst->info), package_name(inst->info), packet, 0);
@@ -2536,12 +2746,13 @@ static void change_group_cb(struct slave_node *slave, const struct packet *packe
{
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 = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
@@ -2549,7 +2760,7 @@ static void change_group_cb(struct slave_node *slave, const struct packet *packe
ErrPrint("Invalid packet\n");
DbgFree(cbdata->cluster);
DbgFree(cbdata->category);
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
@@ -2565,9 +2776,9 @@ static void change_group_cb(struct slave_node *slave, const struct packet *packe
}
out:
- result = packet_create_noack("group_changed", "ssiss",
- package_name(cbdata->inst->info), cbdata->inst->id, ret,
- cbdata->inst->cluster, cbdata->inst->category);
+ 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 {
@@ -2582,28 +2793,29 @@ HAPI int instance_change_group(struct inst_info *inst, const char *cluster, cons
{
struct packet *packet;
struct change_group_cbdata *cbdata;
+ unsigned int cmd = CMD_CHANGE_GROUP;
if (!inst) {
ErrPrint("Invalid instance handle\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (package_is_fault(inst->info)) {
ErrPrint("Fault package [%s]\n", package_name(inst->info));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
cbdata = malloc(sizeof(*cbdata));
if (!cbdata) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
cbdata->cluster = strdup(cluster);
if (!cbdata->cluster) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(cbdata);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
cbdata->category = strdup(category);
@@ -2611,19 +2823,19 @@ HAPI int instance_change_group(struct inst_info *inst, const char *cluster, cons
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(cbdata->cluster);
DbgFree(cbdata);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
cbdata->inst = instance_ref(inst);
- packet = packet_create("change_group","ssss", package_name(inst->info), inst->id, cluster, category);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_async_request(package_slave(inst->info), package_name(inst->info), packet, change_group_cb, cbdata, 0);
@@ -2636,7 +2848,7 @@ HAPI const char * const instance_auto_launch(const struct inst_info *inst)
HAPI const int const instance_priority(const struct inst_info *inst)
{
- return inst->lb.priority;
+ return inst->dbox.priority;
}
HAPI const struct client_node *const instance_client(const struct inst_info *inst)
@@ -2651,27 +2863,27 @@ HAPI const int const instance_timeout(const struct inst_info *inst)
HAPI const double const instance_period(const struct inst_info *inst)
{
- return inst->lb.period;
+ return inst->dbox.period;
}
-HAPI const int const instance_lb_width(const struct inst_info *inst)
+HAPI const int const instance_dbox_width(const struct inst_info *inst)
{
- return inst->lb.width;
+ return inst->dbox.width;
}
-HAPI const int const instance_lb_height(const struct inst_info *inst)
+HAPI const int const instance_dbox_height(const struct inst_info *inst)
{
- return inst->lb.height;
+ return inst->dbox.height;
}
-HAPI const int const instance_pd_width(const struct inst_info *inst)
+HAPI const int const instance_gbar_width(const struct inst_info *inst)
{
- return inst->pd.width;
+ return inst->gbar.width;
}
-HAPI const int const instance_pd_height(const struct inst_info *inst)
+HAPI const int const instance_gbar_height(const struct inst_info *inst)
{
- return inst->pd.height;
+ return inst->gbar.height;
}
HAPI struct pkg_info *const instance_package(const struct inst_info *inst)
@@ -2679,24 +2891,34 @@ HAPI struct pkg_info *const instance_package(const struct inst_info *inst)
return inst->info;
}
-HAPI struct script_info *const instance_lb_script(const struct inst_info *inst)
+HAPI struct script_info *const instance_dbox_script(const struct inst_info *inst)
+{
+ return (package_dbox_type(inst->info) == DBOX_TYPE_SCRIPT) ? inst->dbox.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_dbox_buffer(const struct inst_info *inst)
{
- return (package_lb_type(inst->info) == LB_TYPE_SCRIPT) ? inst->lb.canvas.script : NULL;
+ return (package_dbox_type(inst->info) == DBOX_TYPE_BUFFER) ? inst->dbox.canvas.buffer : NULL;
}
-HAPI struct script_info *const instance_pd_script(const struct inst_info *inst)
+HAPI struct buffer_info *const instance_gbar_buffer(const struct inst_info *inst)
{
- return (package_pd_type(inst->info) == PD_TYPE_SCRIPT) ? inst->pd.canvas.script : NULL;
+ return (package_gbar_type(inst->info) == GBAR_TYPE_BUFFER) ? inst->gbar.canvas.buffer : NULL;
}
-HAPI struct buffer_info *const instance_lb_buffer(const struct inst_info *inst)
+HAPI struct buffer_info *const instance_dbox_extra_buffer(const struct inst_info *inst, int idx)
{
- return (package_lb_type(inst->info) == LB_TYPE_BUFFER) ? inst->lb.canvas.buffer : NULL;
+ return (package_dbox_type(inst->info) == DBOX_TYPE_BUFFER) ? (inst->dbox.extra_buffer ? inst->dbox.extra_buffer[idx] : NULL) : NULL;
}
-HAPI struct buffer_info *const instance_pd_buffer(const struct inst_info *inst)
+HAPI struct buffer_info *const instance_gbar_extra_buffer(const struct inst_info *inst, int idx)
{
- return (package_pd_type(inst->info) == PD_TYPE_BUFFER) ? inst->pd.canvas.buffer : NULL;
+ 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)
@@ -2739,16 +2961,20 @@ HAPI int instance_destroyed(struct inst_info *inst, int reason)
switch (inst->state) {
case INST_INIT:
case INST_REQUEST_TO_ACTIVATE:
- /*!
- * \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);
+ 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, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
case INST_REQUEST_TO_REACTIVATE:
case INST_REQUEST_TO_DESTROY:
@@ -2756,14 +2982,14 @@ HAPI int instance_destroyed(struct inst_info *inst, int reason)
DbgPrint("Send deleted event - multicast\n");
instance_broadcast_deleted_event(inst, reason);
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
case INST_DESTROYED:
break;
default:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/*!
@@ -2773,9 +2999,9 @@ HAPI int instance_recover_state(struct inst_info *inst)
{
int ret = 0;
- if (inst->changing_state) {
+ if (inst->changing_state > 0) {
DbgPrint("Doesn't need to recover the state\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
if (package_is_fault(inst->info)) {
@@ -2797,7 +3023,7 @@ HAPI int instance_recover_state(struct inst_info *inst)
case INST_DESTROYED:
DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info));
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
default:
break;
@@ -2812,9 +3038,9 @@ HAPI int instance_recover_state(struct inst_info *inst)
instance_state_reset(inst);
if (instance_activate(inst) < 0) {
DbgPrint("Failed to reactivate the instance\n");
- instance_broadcast_deleted_event(inst, LB_STATUS_ERROR_FAULT);
+ instance_broadcast_deleted_event(inst, DBOX_STATUS_ERROR_FAULT);
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
} else {
ret = 1;
}
@@ -2822,7 +3048,7 @@ HAPI int instance_recover_state(struct inst_info *inst)
case INST_DESTROYED:
DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info));
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
default:
break;
@@ -2847,7 +3073,7 @@ HAPI int instance_need_slave(struct inst_info *inst)
/*!
* \note
* In this case, the client is faulted(disconnected)
- * when the client is deactivated, its liveboxes should be removed too.
+ * when the client is deactivated, its dynamicboxes 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
*/
@@ -2860,13 +3086,13 @@ HAPI int instance_need_slave(struct inst_info *inst)
case INST_REQUEST_TO_DESTROY:
case INST_REQUEST_TO_ACTIVATE:
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
case INST_DESTROYED:
break;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
switch (inst->state) {
@@ -2882,7 +3108,7 @@ HAPI int instance_need_slave(struct inst_info *inst)
case INST_DESTROYED:
DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info));
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
default:
break;
@@ -2899,7 +3125,7 @@ HAPI int instance_need_slave(struct inst_info *inst)
case INST_DESTROYED:
DbgPrint("Req. to DESTROYED (%s)\n", package_name(inst->info));
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
default:
break;
@@ -2921,11 +3147,12 @@ HAPI int instance_forward_packet(struct inst_info *inst, struct packet *packet)
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("key_status", "ssi", package_name(inst->info), inst->id, 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return CLIENT_SEND_EVENT(inst, packet);
@@ -2934,65 +3161,67 @@ HAPI int instance_send_key_status(struct inst_info *inst, int status)
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("access_status", "ssi", package_name(inst->info), inst->id, 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return CLIENT_SEND_EVENT(inst, packet);
}
-HAPI void instance_slave_set_pd_pos(struct inst_info *inst, double x, double y)
+HAPI void instance_slave_set_gbar_pos(struct inst_info *inst, double x, double y)
{
- inst->pd.x = x;
- inst->pd.y = y;
+ inst->gbar.x = x;
+ inst->gbar.y = y;
}
-HAPI void instance_slave_get_pd_pos(struct inst_info *inst, double *x, double *y)
+HAPI void instance_slave_get_gbar_pos(struct inst_info *inst, double *x, double *y)
{
if (x) {
- *x = inst->pd.x;
+ *x = inst->gbar.x;
}
if (y) {
- *y = inst->pd.y;
+ *y = inst->gbar.y;
}
}
-HAPI int instance_slave_open_pd(struct inst_info *inst, struct client_node *client)
+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->pd.owner;
+ client = inst->gbar.owner;
if (!client) {
ErrPrint("Client is not valid\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- } else if (inst->pd.owner) {
- if (inst->pd.owner != client) {
+ } else if (inst->gbar.owner) {
+ if (inst->gbar.owner != client) {
ErrPrint("Client is already owned\n");
- return LB_STATUS_ERROR_ALREADY;
+ return DBOX_STATUS_ERROR_ALREADY;
}
}
info = instance_package(inst);
if (!info) {
ErrPrint("No package info\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
slave = package_slave(info);
if (!slave) {
ErrPrint("No slave\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
pkgname = package_name(info);
@@ -3000,13 +3229,13 @@ HAPI int instance_slave_open_pd(struct inst_info *inst, struct client_node *clie
if (!pkgname || !id) {
ErrPrint("pkgname[%s] id[%s]\n", pkgname, id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack("pd_show", "ssiidd", pkgname, id, instance_pd_width(inst), instance_pd_height(inst), inst->pd.x, inst->pd.y);
+ 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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
/*!
@@ -3031,50 +3260,51 @@ HAPI int instance_slave_open_pd(struct inst_info *inst, struct client_node *clie
/*!
* \note
- * If a client is disconnected, the slave has to close the PD
- * So the pd_buffer_close_cb/pd_script_close_cb will catch the disconnection event
+ * 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_pd_type(info) == PD_TYPE_BUFFER) {
+ if (package_gbar_type(info) == GBAR_TYPE_BUFFER) {
instance_ref(inst);
- if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_buffer_close_cb, inst) < 0) {
+ if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, gbar_buffer_close_cb, inst) < 0) {
instance_unref(inst);
}
- } else if (package_pd_type(info) == PD_TYPE_SCRIPT) {
+ } else if (package_gbar_type(info) == GBAR_TYPE_SCRIPT) {
instance_ref(inst);
- if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, pd_script_close_cb, inst) < 0) {
+ if (client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, gbar_script_close_cb, inst) < 0) {
instance_unref(inst);
}
}
- inst->pd.owner = client;
+ inst->gbar.owner = client;
return ret;
}
-HAPI int instance_slave_close_pd(struct inst_info *inst, struct client_node *client, int reason)
+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->pd.owner != client) {
+ if (inst->gbar.owner != client) {
ErrPrint("Has no permission\n");
- return LB_STATUS_ERROR_PERMISSION;
+ return DBOX_STATUS_ERROR_PERMISSION_DENIED;
}
pkg = instance_package(inst);
if (!pkg) {
ErrPrint("No package info\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
slave = package_slave(pkg);
if (!slave) {
ErrPrint("No assigned slave\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
pkgname = package_name(pkg);
@@ -3082,104 +3312,189 @@ HAPI int instance_slave_close_pd(struct inst_info *inst, struct client_node *cli
if (!pkgname || !id) {
ErrPrint("pkgname[%s] & id[%s] is not valid\n", pkgname, id);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack("pd_hide", "ssi", pkgname, id, reason);
+ packet = packet_create_noack((const char *)&cmd, "ssi", pkgname, id, reason);
if (!packet) {
ErrPrint("Failed to create a packet\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
slave_thaw_ttl(slave);
ret = slave_rpc_request_only(slave, pkgname, packet, 0);
- release_resource_for_closing_pd(pkg, inst, client);
- inst->pd.owner = NULL;
+ release_resource_for_closing_gbar(pkg, inst, client);
+ inst->gbar.owner = NULL;
DbgPrint("PERF_DBOX\n");
return ret;
}
-HAPI int instance_client_pd_created(struct inst_info *inst, int status)
+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->pd.need_to_send_close_event) {
- DbgPrint("PD is already created\n");
- return LB_STATUS_ERROR_INVALID;
+ if (inst->gbar.need_to_send_close_event) {
+ DbgPrint("GBAR is already created\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- switch (package_pd_type(inst->info)) {
- case PD_TYPE_SCRIPT:
- buf_id = script_handler_buffer_id(inst->pd.canvas.script);
+ switch (package_gbar_type(inst->info)) {
+ case GBAR_TYPE_SCRIPT:
+ buf_id = script_handler_buffer_id(inst->gbar.canvas.script);
break;
- case PD_TYPE_BUFFER:
- buf_id = buffer_handler_id(inst->pd.canvas.buffer);
+ case GBAR_TYPE_BUFFER:
+ buf_id = buffer_handler_id(inst->gbar.canvas.buffer);
break;
- case PD_TYPE_TEXT:
+ case GBAR_TYPE_TEXT:
default:
buf_id = "";
break;
}
- inst->pd.need_to_send_close_event = (status == 0);
+ inst->gbar.need_to_send_close_event = (status == 0);
- packet = packet_create_noack("pd_created", "sssiii",
+ packet = packet_create_noack((const char *)&cmd, "sssiii",
package_name(inst->info), inst->id, buf_id,
- inst->pd.width, inst->pd.height, status);
+ inst->gbar.width, inst->gbar.height, status);
if (!packet) {
ErrPrint("Failed to create a packet\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
ret = CLIENT_SEND_EVENT(inst, packet);
- if (inst->pd.need_to_send_close_event && inst->pd.pended_update_cnt) {
- DbgPrint("Apply pended desc(%d) - %s\n", inst->pd.pended_update_cnt, inst->pd.pended_update_desc);
- instance_pd_updated_by_instance(inst, inst->pd.pended_update_desc);
- inst->pd.pended_update_cnt = 0;
- DbgFree(inst->pd.pended_update_desc);
- inst->pd.pended_update_desc = 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_pd_destroyed(struct inst_info *inst, int status)
+HAPI int instance_client_gbar_destroyed(struct inst_info *inst, int status)
{
- return send_pd_destroyed_to_client(inst, 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 DBOX_STATUS_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 DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return CLIENT_SEND_EVENT(inst, packet);
+}
+
+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 DBOX_STATUS_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 DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return CLIENT_SEND_EVENT(inst, packet);
+}
+
+HAPI int instance_client_dbox_extra_buffer_created(struct inst_info *inst, int idx)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_DBOX_CREATE_XBUF;
+ int pixmap;
+
+ pixmap = buffer_handler_pixmap(inst->dbox.extra_buffer[idx]);
+ if (pixmap == 0) {
+ ErrPrint("Invalid buffer\n");
+ return DBOX_STATUS_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 DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return CLIENT_SEND_EVENT(inst, packet);
+}
+
+HAPI int instance_client_dbox_extra_buffer_destroyed(struct inst_info *inst, int idx)
+{
+ struct packet *packet;
+ unsigned int cmd = CMD_DBOX_DESTROY_XBUF;
+ int pixmap;
+
+ pixmap = buffer_handler_pixmap(inst->dbox.extra_buffer[idx]);
+ if (pixmap == 0) {
+ ErrPrint("Invalid buffer\n");
+ return DBOX_STATUS_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 DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return CLIENT_SEND_EVENT(inst, packet);
}
HAPI int instance_add_client(struct inst_info *inst, struct client_node *client)
{
if (inst->client == client) {
ErrPrint("Owner cannot be the viewer\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_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 LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
instance_ref(inst);
inst->client_list = eina_list_append(inst->client_list, client);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
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 LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
client_event_callback_del(client, CLIENT_EVENT_DEACTIVATE, viewer_deactivated_cb, inst);
viewer_deactivated_cb(client, inst);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int instance_has_client(struct inst_info *inst, struct client_node *client)
@@ -3194,19 +3509,19 @@ HAPI void *instance_client_list(struct inst_info *inst)
HAPI int instance_init(void)
{
- if (!strcasecmp(PROVIDER_METHOD, "shm")) {
- s_info.env_buf_type = BUFFER_TYPE_SHM;
- } else if (!strcasecmp(PROVIDER_METHOD, "pixmap")) {
- s_info.env_buf_type = BUFFER_TYPE_PIXMAP;
+ if (!strcasecmp(DYNAMICBOX_CONF_PROVIDER_METHOD, "shm")) {
+ s_info.env_buf_type = DBOX_FB_TYPE_SHM;
+ } else if (!strcasecmp(DYNAMICBOX_CONF_PROVIDER_METHOD, "pixmap")) {
+ s_info.env_buf_type = DBOX_FB_TYPE_PIXMAP;
}
- /* Default method is BUFFER_TYPE_FILE */
+ /* Default method is DBOX_FB_TYPE_FILE */
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int instance_fini(void)
{
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline struct tag_item *find_tag_item(struct inst_info *inst, const char *tag)
@@ -3232,14 +3547,14 @@ HAPI int instance_set_data(struct inst_info *inst, const char *tag, void *data)
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
item->tag = strdup(tag);
if (!item->tag) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(item);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
inst->data_list = eina_list_append(inst->data_list, item);
@@ -3253,7 +3568,7 @@ HAPI int instance_set_data(struct inst_info *inst, const char *tag, void *data)
item->data = data;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void *instance_del_data(struct inst_info *inst, const char *tag)
@@ -3286,9 +3601,9 @@ HAPI void *instance_get_data(struct inst_info *inst, const char *tag)
return item->data;
}
-HAPI struct client_node *instance_pd_owner(struct inst_info *inst)
+HAPI struct client_node *instance_gbar_owner(struct inst_info *inst)
{
- return inst->pd.owner;
+ return inst->gbar.owner;
}
/* End of a file */
diff --git a/src/io.c b/src/io.c
index 8593ab7..fbd9ccb 100644
--- a/src/io.c
+++ b/src/io.c
@@ -27,7 +27,9 @@
#include <Eina.h>
#include <sqlite3.h>
#include <db-util.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_conf.h>
#include "debug.h"
#include "conf.h"
@@ -42,6 +44,9 @@
int errno;
+#define MAX_ABI 256
+#define MAX_PKGNAME 512
+
static struct {
sqlite3 *handle;
} s_info = {
@@ -75,7 +80,7 @@ static int load_abi_table(void)
fp = fopen("/usr/share/"PACKAGE"/abi.ini", "rt");
if (!fp) {
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
state = INIT;
@@ -211,12 +216,12 @@ static int load_abi_table(void)
if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int build_client_info(struct pkg_info *info)
{
- static const char *dml = "SELECT auto_launch, pd_size FROM client WHERE pkgid = ?";
+ static const char *dml = "SELECT auto_launch, gbar_size FROM client WHERE pkgid = ?";
sqlite3_stmt *stmt;
int width;
int height;
@@ -226,14 +231,14 @@ static inline int build_client_info(struct pkg_info *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 LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_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 LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
if (sqlite3_step(stmt) != SQLITE_ROW) {
@@ -241,7 +246,7 @@ static inline int build_client_info(struct pkg_info *info)
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
sqlite3_finalize(stmt);
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
package_set_auto_launch(info, (const char *)sqlite3_column_text(stmt, 0));
@@ -249,22 +254,22 @@ static inline int build_client_info(struct pkg_info *info)
tmp = (const char *)sqlite3_column_text(stmt, 1);
if (tmp && strlen(tmp)) {
if (sscanf(tmp, "%dx%d", &width, &height) != 2) {
- ErrPrint("Failed to get PD width and Height (%s)\n", tmp);
+ ErrPrint("Failed to get GBAR width and Height (%s)\n", tmp);
} else {
- package_set_pd_width(info, width);
- package_set_pd_height(info, height);
+ package_set_gbar_width(info, width);
+ package_set_gbar_height(info, height);
}
}
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
sqlite3_finalize(stmt);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_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.pd_type, provider.pd_src, provider.pd_group, provider.libexec, provider.timeout, provider.period, provider.script, provider.pinup, pkgmap.appid FROM provider, pkgmap WHERE pkgmap.pkgid = ? AND provider.pkgid = ?";
+ 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 FROM provider, pkgmap WHERE pkgmap.pkgid = ? AND provider.pkgid = ?";
sqlite3_stmt *stmt;
int ret;
const char *tmp;
@@ -273,19 +278,19 @@ static inline int build_provider_info(struct pkg_info *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 LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_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 LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_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 LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
if (sqlite3_step(stmt) != SQLITE_ROW) {