INCLUDE(FindPkgConfig)
pkg_check_modules(pkg REQUIRED
- ail
dlog
aul
vconf
badge-service
libsmack
shortcut
+ pkgmgr-info
libsystemd-daemon
)
IF (LIVEBOX)
pkg_check_modules(pkg_livebox REQUIRED
- livebox-service
+ dynamicbox_service
)
ENDIF (LIVEBOX)
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)
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\"")
src/badge_service.c
src/notification_service.c
src/service_common.c
- src/conf.c
)
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
IF (X11_SUPPORT)
ADD_DEFINITIONS("-DHAVE_X11")
- SET(BUILD_SOURCE
+ SET(BUILD_SOURCE
${BUILD_SOURCE}
src/xmonitor.c
src/buffer_handler.c
IF (WAYLAND_SUPPORT)
ADD_DEFINITIONS("-DHAVE_WAYLAND")
- SET(BUILD_SOURCE
+ SET(BUILD_SOURCE
${BUILD_SOURCE}
src/util_wayland.c
)
IF (X11_SUPPORT)
ADD_DEFINITIONS("-DHAVE_X11")
- SET(BUILD_SOURCE
+ SET(BUILD_SOURCE
${BUILD_SOURCE}
src/util_x11.c
)
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
+++ /dev/null
-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
+++ /dev/null
-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
-#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)
[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
[app]
package=/APPID/
-
-[dali]
-package=provider.multi-livebox
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
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
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
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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
-base_width=320
-base_height=320
+base_width=360
+base_height=360
minimum_period=1.0
#script=edje
#default_abi=c
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
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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/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
+++ /dev/null
-#!/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
--- /dev/null
+[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/
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
-base_width=720
-base_height=1280
+base_width=360
+base_height=360
minimum_period=1.0
#script=edje
#default_abi=c
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
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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
+++ /dev/null
-#
-# 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
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
* \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
/*!
* \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.
/*!
* \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);
* \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
* \post
* \sa
*/
-extern int buffer_handler_raw_close(struct buffer *buffer);
+extern int buffer_handler_raw_close(dynamicbox_fb_t buffer);
/*!
* \brief
* \post
* \sa
*/
-extern void *buffer_handler_raw_data(struct buffer *buffer);
+extern void *buffer_handler_raw_data(dynamicbox_fb_t buffer);
/*!
* \brief
* \post
* \sa
*/
-extern int buffer_handler_raw_size(struct buffer *buffer);
+extern int buffer_handler_raw_size(dynamicbox_fb_t buffer);
/*!
* \brief
* \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)
/*!
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 */
*/
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"
#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 */
#define PERF_MARK(tag)
#endif
+#define HAPI __attribute__((visibility("hidden")))
+
/* End of a file */
*/
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 */
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);
* 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
* 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.
* 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.
*
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 */
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;
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);
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);
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);
*/
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);
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);
/*!
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
extern int instance_event_callback_add(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
extern int instance_event_callback_del(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
+extern int instance_event_callback_is_added(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
/*!
*/
extern int 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 */
* 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))
/*!
* \}
* 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
*/
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);
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);
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
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);
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);
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 */
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,
* \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
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);
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);
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 */
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);
<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" />
<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" />
<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>
%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)
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)
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
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}
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)
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
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
%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
-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
sqlite3
libxml-2.0
db-util
- livebox-service
+ dynamicbox_service
)
FOREACH(flag ${bin_pkgs_CFLAGS})
<?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">
MUSIC_PLAYED_FREQUENTLY(DATA_PROVIDER, TIME_SPAN, RESULT_SIZE)
-->
</group>
-</livebox>
+</dynamicbox>
</manifest>
--- /dev/null
+<?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>
--- /dev/null
+/*
+ * 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("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
+#define ErrPrint(format, arg...) SECURE_LOGE("[\e[32m%s/%s\e[0m:%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("[\e[32m%s/%s\e[0m:%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 */
+++ /dev/null
-/*
- * 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("[\e[32m%s/%s\e[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
-#define ErrPrint(format, arg...) SECURE_LOGE("[\e[32m%s/%s\e[0m:%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("[\e[32m%s/%s\e[0m:%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 */
-#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
#include <Eina.h>
#include <dlog.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#include "util.h"
#include "debug.h"
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);
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)
_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) {
}
DbgFree(_pkgname);
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
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)
#include <dlog.h>
#if defined(HAVE_LIVEBOX)
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#else
#include "lite-errno.h"
#endif
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);
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);
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);
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);
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);
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);
{
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) {
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;
}
}
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 */
#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"
#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.
*/
{
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;
.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;
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;
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;
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;
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?
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;
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;
}
}
-static inline int destroy_pixmap(struct buffer *buffer)
+static inline int destroy_pixmap(dynamicbox_fb_t buffer)
{
struct gem_data *gem;
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;
}
/*!
*/
gem = (struct gem_data *)buffer->data;
if (!gem) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (s_info.fd >= 0) {
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);
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);
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 */
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);
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;
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 */
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);
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;
}
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);
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)
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) {
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)
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;
}
/*!
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)
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;
}
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;
buffer = info->buffer;
- if (info->type == BUFFER_TYPE_PIXMAP) {
+ if (info->type == DBOX_FB_TYPE_PIXMAP) {
void *canvas;
int ret;
EAPI int buffer_handler_pixmap(const struct buffer_info *info)
{
- struct buffer *buf;
+ dynamicbox_fb_t buf;
struct gem_data *gem;
if (!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;
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");
EAPI void *buffer_handler_pixmap_buffer(struct buffer_info *info)
{
- struct buffer *buffer;
+ dynamicbox_fb_t buffer;
struct gem_data *gem;
if (!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;
}
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) {
*/
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;
}
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;
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;
}
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;
}
/*!
*/
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);
info->buffer = NULL;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI int buffer_handler_is_loaded(const struct buffer_info *info)
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);
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) {
*h = info->h;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
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;
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;
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);
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;
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);
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;
buffer = info->buffer;
- if (buffer->type == BUFFER_TYPE_PIXMAP) {
+ if (buffer->type == DBOX_FB_TYPE_PIXMAP) {
if (s_info.fd > 0) {
//return;
//PERF_INIT();
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));
}
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));
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);
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);
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);
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)
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;
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;
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;
}
return buffer;
}
-static inline int raw_close_shm(struct buffer *buffer)
+static inline int raw_close_shm(dynamicbox_fb_t buffer)
{
int ret;
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:
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;
}
/*!
* 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) {
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;
}
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");
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");
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));
return NULL;
}
- info->lock = NULL;
- info->lock_fd = -1;
+ info->lock_info = NULL;
info->w = w;
info->h = h;
info->pixel_size = pixel_size;
#include <dlog.h>
#include <packet.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#include "debug.h"
#include "conf.h"
int w;
int h;
int pixel_size;
+ int auto_align;
int is_loaded;
struct inst_info *inst;
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) {
DbgFree(info->lock);
info->lock = NULL;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
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 ;) */
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)
int ret;
if (buffer->lock_fd < 0) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
flock.l_type = F_WRLCK;
}
} while (ret == EINTR);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
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;
}
} while (ret == EINTR);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
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();
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;
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)
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);
ErrPrint("%s shmctl: %s\n", info->id, strerror(errno));
}
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
buffer->type = BUFFER_TYPE_SHM;
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);
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)
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_PIXMAP:
default:
ErrPrint("Invalid buffer\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
break;
}
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);
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)
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) {
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)
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_PIXMAP:
default:
ErrPrint("Invalid buffer\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
break;
}
EAPI int buffer_handler_pixmap_release_buffer(void *canvas)
{
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
/*!
*/
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)
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);
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) {
*h = info->h;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
EAPI struct inst_info *buffer_handler_instance(struct buffer_info *info)
*/
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)
* \TODO
* Implement this for wayland
*/
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline struct buffer *raw_open_file(const char *filename)
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;
break;
case BUFFER_TYPE_PIXMAP:
default:
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
break;
}
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);
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);
{
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)
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;
info->inst = inst;
info->buffer = NULL;
info->data = NULL;
+ info->auto_align = auto_align;
return info;
}
#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"
Eina_List *subscribe_list;
int faulted;
+ char *direct_addr;
};
static inline void invoke_global_destroyed_cb(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);
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;
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);
/*!
* 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;
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;
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;
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)
if (!cb) {
ErrPrint("Invalid callback (cb == NULL)\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
switch (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;
client->event_activate_list = eina_list_remove(client->event_activate_list, item);
DbgFree(item);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
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)
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)
HAPI int client_init(void)
{
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void client_fini(void)
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;
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)
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;
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;
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)
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);
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)
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)
int cnt;
if (!cb || !cluster || !category) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
cnt = 0;
}
if (cb(client, data) < 0) {
- return LB_STATUS_ERROR_CANCEL;
+ return DBOX_STATUS_ERROR_CANCEL;
}
cnt++;
}
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 */
#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"
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);
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);
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)
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));
}
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)
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);
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)
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;
-/*
- * 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 */
#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
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) {
int ret;
if (!s_info.fp) {
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
CRITICAL_SECTION_BEGIN(&s_info.cri_lock);
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) {
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;
}
#include <dlog.h>
#include <Eina.h>
+#include <dynamicbox_service.h> /* destroy_type for instance.h */
#include "slave_life.h"
#include "client_life.h"
#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"
#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;
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,
.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;
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)
int offset = 0;
int readsize = 0;
int fd;
-
- DbgPrint("Initiated\n");
+ char event_ch;
while (1) {
FD_ZERO(&set);
break;
} else if (ret == 0) {
ErrPrint("Timeout expired\n");
- ret = LB_STATUS_ERROR_TIMEOUT;
+ ret = DBOX_STATUS_ERROR_TIMEOUT;
break;
}
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;
}
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:
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;
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) {
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) {
}
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) {
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));
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);
}
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;
}
/*!
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) {
} 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);
}
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)
#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"
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");
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));
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");
}
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;
}
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;
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);
* 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)
} 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);
info = malloc(sizeof(*info));
if (!info) {
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
info->slave = slave;
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);
DbgFree(info->filename);
DbgFree(info->pkgname);
DbgFree(info);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
info->timestamp = util_timestamp();
s_info.call_list = eina_list_append(s_info.call_list, info);
s_info.fault_mark_count++;
- return 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)
return 0;
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
/* End of a file */
#include <dlog.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
#include <packet.h>
#include <com-core.h>
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)
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)
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;
}
/*!
* 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)
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;
}
/*!
* 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 */
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)) {
* \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;
}
break;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int send_file(int handle, const struct request_item *item)
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;
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);
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);
}
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);
}
CLOSE_PIPE(s_info.request_pipe);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
/*!
*/
DbgPrint("Successfully initiated\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* MAIN THREAD */
void *retval;
if (!s_info.svc_ctx) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ch = PUSH_EXIT;
CLOSE_PIPE(s_info.request_pipe);
DbgPrint("Successfully Finalized\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* End of a file */
#include <dlog.h>
#include <Eina.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#include "util.h"
#include "debug.h"
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);
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)
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);
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)
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)
}
destroy_category(category);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI struct category *group_find_category(struct cluster *cluster, const char *name)
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)
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;
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} */
if (!cluster) {
ErrPrint("Failed to get cluster\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CATEGORY;
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;
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;
default:
ErrPrint("Invalid state\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
DbgFree(name);
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) {
if (!cluster) {
ErrPrint("Failed to get cluster\n");
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
state = CATEGORY;
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) {
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;
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;
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) {
default:
ErrPrint("Invalid state (%s)\n", name);
DbgFree(name);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
DbgFree(name);
} 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;
} 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);
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;
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;
} 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) {
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;
}
}
- 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)
destroy_cluster(cluster);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* End of a file */
#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"
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 {
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;
char *icon;
char *name;
- enum livebox_visible_state visible;
+ enum dynamicbox_visible_state visible;
struct {
int width;
struct buffer_info *buffer;
} canvas;
+ struct buffer_info **extra_buffer;
+
double period;
- } lb;
+ } dbox;
struct {
int width;
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,
#endif
}
-
static int viewer_deactivated_cb(struct client_node *client, void *data)
{
struct inst_info *inst = 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);
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;
}
{
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");
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 {
}
}
-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");
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 {
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;
}
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);
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);
}
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) {
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);
}
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) {
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;
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)
inst->delete_event_list = eina_list_remove(inst->delete_event_list, item);
DbgFree(item);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
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;
}
}
EINA_LIST_FREE(inst->delete_event_list, item) {
DbgFree(item);
}
+
DbgFree(inst->icon);
DbgFree(inst->name);
DbgFree(inst->category);
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 {
}
}
- 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)
}
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) {
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);
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;
}
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.
/*!
* \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;
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
* 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);
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);
}
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");
}
* 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);
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) {
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));
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);
}
/* 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);
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;
}
* \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,
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) {
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,
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);
}
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) {
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,
inst->state = INST_REQUEST_TO_ACTIVATE;
inst->requested_state = INST_ACTIVATED;
- inst->changing_state = 1;
+ inst->changing_state++;
/*!
* \note
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;
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;
}
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;
(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;
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);
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;
}
if (priority >= 0.0f && priority <= 1.0f) {
- inst->lb.priority = priority;
+ inst->dbox.priority = priority;
}
}
}
}
-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)
struct set_pinup_cbdata *cbdata = data;
const char *content;
struct packet *result;
+ unsigned int cmd = CMD_RESULT_PINUP;
int ret;
if (!packet) {
* \todo
* Send pinup failed event to client.
*/
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
* \todo
* Send pinup failed event to client
*/
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
* \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);
* 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 {
{
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);
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;
}
}
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)
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;
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,
* 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);
{
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);
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);
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 {
{
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 {
}
}
- 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 {
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);
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);
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);
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);
{
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;
}
ErrPrint("Invalid packet\n");
DbgFree(cbdata->cluster);
DbgFree(cbdata->category);
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
}
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 {
{
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);
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);
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)
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)
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)
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:
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;
}
/*!
{
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)) {
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;
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;
}
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;
/*!
* \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
*/
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) {
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;
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;
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);
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);
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;
}
/*!
/*!
* \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);
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)
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)
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);
item->data = data;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void *instance_del_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 */
#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"
int errno;
+#define MAX_ABI 256
+#define MAX_PKGNAME 512
+
static struct {
sqlite3 *handle;
} s_info = {
fp = fopen("/usr/share/"PACKAGE"/abi.ini", "rt");
if (!fp) {
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
state = INIT;
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;
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) {
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));
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;
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) {
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
sqlite3_finalize(stmt);
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
appid = (const char *)sqlite3_column_text(stmt, 14);
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
sqlite3_finalize(stmt);
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
package_set_network(info, sqlite3_column_int(stmt, 0));
package_set_abi(info, tmp);
}
- package_set_lb_type(info, sqlite3_column_int(stmt, 3));
+ package_set_dbox_type(info, sqlite3_column_int(stmt, 3));
tmp = (const char *)sqlite3_column_text(stmt, 4);
if (tmp && strlen(tmp)) {
- package_set_lb_path(info, tmp);
+ package_set_dbox_path(info, tmp);
tmp = (const char *)sqlite3_column_text(stmt, 5);
if (tmp && strlen(tmp)) {
- package_set_lb_group(info, tmp);
+ package_set_dbox_group(info, tmp);
}
}
- package_set_pd_type(info, sqlite3_column_int(stmt, 6));
+ package_set_gbar_type(info, sqlite3_column_int(stmt, 6));
tmp = (const char *)sqlite3_column_text(stmt, 7);
if (tmp && strlen(tmp)) {
- package_set_pd_path(info, tmp);
+ package_set_gbar_path(info, tmp);
tmp = (const char *)sqlite3_column_text(stmt, 8);
if (tmp && strlen(tmp)) {
- package_set_pd_group(info, tmp);
+ package_set_gbar_group(info, tmp);
}
}
}
package_set_pinup(info, sqlite3_column_int(stmt, 13));
+ package_set_direct_input(info, sqlite3_column_int(stmt, 15));
+ package_set_hw_acceleration(info, (const char *)sqlite3_column_text(stmt, 16));
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
sqlite3_finalize(stmt);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int build_box_size_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;
}
size_list = 0;
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
sqlite3_finalize(stmt);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int load_context_option(struct context_item *item, int id)
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_int(stmt, 1, id);
if (ret != SQLITE_OK) {
ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = LB_STATUS_ERROR_IO;
+ ret = DBOX_STATUS_ERROR_IO_ERROR;
goto out;
}
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
while (sqlite3_step(stmt) == SQLITE_ROW) {
key = (const char *)sqlite3_column_text(stmt, 0);
if (!key || !strlen(key)) {
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_int(stmt, 1, id);
if (ret != SQLITE_OK) {
ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = LB_STATUS_ERROR_IO;
+ ret = DBOX_STATUS_ERROR_IO_ERROR;
goto out;
}
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
while (sqlite3_step(stmt) == SQLITE_ROW) {
ctx_item = (const char *)sqlite3_column_text(stmt, 0);
option_id = sqlite3_column_int(stmt, 1);
item = group_add_context_item(info, ctx_item);
if (!item) {
ErrPrint("Failed to add a new context item\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
break;
}
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 package name(%s)\n", package_name(info));
sqlite3_finalize(stmt);
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
while (sqlite3_step(stmt) == SQLITE_ROW) {
if (ctx_info) {
ret = load_context_item(ctx_info, id);
if (ret < 0) {
- if (ret == (int)LB_STATUS_ERROR_NOT_EXIST) {
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST) {
DbgPrint("Has no specific context info\n");
} else {
DbgPrint("Context info is not valid\n");
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
sqlite3_finalize(stmt);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int io_is_exists(const char *lbid)
if (!s_info.handle) {
ErrPrint("DB is not ready\n");
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
ret = sqlite3_prepare_v2(s_info.handle, "SELECT COUNT(pkgid) FROM pkgmap WHERE pkgid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
ret = sqlite3_bind_text(stmt, 1, lbid, -1, SQLITE_TRANSIENT);
if (ret != SQLITE_OK) {
ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = LB_STATUS_ERROR_IO;
+ ret = DBOX_STATUS_ERROR_IO_ERROR;
goto out;
}
if (sqlite3_step(stmt) != SQLITE_ROW) {
ErrPrint("%s has no record (%s)\n", lbid, sqlite3_errmsg(s_info.handle));
- ret = LB_STATUS_ERROR_IO;
+ ret = DBOX_STATUS_ERROR_IO_ERROR;
goto out;
}
return ret;
}
-HAPI char *io_livebox_pkgname(const char *pkgname)
+HAPI char *io_dynamicbox_pkgname(const char *pkgname)
{
sqlite3_stmt *stmt;
char *pkgid;
return pkgid;
}
-HAPI int io_crawling_liveboxes(int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data)
+HAPI int io_crawling_dynamicboxes(int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data)
{
DIR *dir;
if (cb(pkgid, lbid, prime, data) < 0) {
sqlite3_reset(stmt);
sqlite3_finalize(stmt);
- return LB_STATUS_ERROR_CANCEL;
+ return DBOX_STATUS_ERROR_CANCEL;
}
}
}
}
- dir = opendir(ROOT_PATH);
+ dir = opendir(DYNAMICBOX_CONF_ROOT_PATH);
if (!dir) {
ErrPrint("Error: %s\n", strerror(errno));
} else {
if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
}
- return LB_STATUS_ERROR_CANCEL;
+ return DBOX_STATUS_ERROR_CANCEL;
}
}
}
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI int io_update_livebox_package(const char *pkgid, int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data)
+HAPI int io_update_dynamicbox_package(const char *pkgid, int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data)
{
sqlite3_stmt *stmt;
char *lbid;
int ret;
if (!cb || !pkgid) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (!s_info.handle) {
ErrPrint("DB is not ready\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ret = sqlite3_prepare_v2(s_info.handle, "SELECT pkgid, prime FROM pkgmap WHERE appid = ?", -1, &stmt, NULL);
if (ret != SQLITE_OK) {
ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_TRANSIENT);
if (ret != SQLITE_OK) {
ErrPrint("Error: %s\n", sqlite3_errmsg(s_info.handle));
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
if (!s_info.handle) {
ErrPrint("DB is not ready\n");
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
ret = build_provider_info(info);
return ret;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int db_init(void)
int ret;
struct stat stat;
- ret = db_util_open_with_options(DBFILE, &s_info.handle, SQLITE_OPEN_READONLY, NULL);
+ ret = db_util_open_with_options(DYNAMICBOX_CONF_DBFILE, &s_info.handle, SQLITE_OPEN_READONLY, NULL);
if (ret != SQLITE_OK) {
ErrPrint("Failed to open a DB\n");
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
- if (lstat(DBFILE, &stat) < 0) {
+ if (lstat(DYNAMICBOX_CONF_DBFILE, &stat) < 0) {
db_util_close(s_info.handle);
s_info.handle = NULL;
ErrPrint("%s\n", strerror(errno));
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
if (!S_ISREG(stat.st_mode)) {
ErrPrint("Invalid file\n");
db_util_close(s_info.handle);
s_info.handle = NULL;
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (stat.st_size <= 0) {
DbgPrint("Size is %d (But use this ;)\n", stat.st_size);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int db_fini(void)
{
if (!s_info.handle) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
db_util_close(s_info.handle);
s_info.handle = NULL;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int io_init(void)
DbgPrint("ABI table is loaded: %d\n", ret);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int io_fini(void)
if (ret < 0) {
DbgPrint("DB finalized: %d\n", ret);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* End of a file */
#include <Eina.h>
#include <dlog.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#include "util.h"
#include "debug.h"
info->fp = fopen(info->fifo_name, "w");
if (!info->fp) {
ErrPrint("open: %s\n", strerror(errno));
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void liveinfo_close_fifo(struct liveinfo *info)
#include <sys/signalfd.h>
#include <ctype.h>
+#include <systemd/sd-daemon.h>
+
#include <Ecore.h>
#include <glib.h>
#include <glib-object.h>
#include <packet.h>
#include <dlog.h>
-#include <systemd/sd-daemon.h>
-
#if defined(HAVE_LIVEBOX)
+
+#include <dynamicbox_service.h>
+#include <dynamicbox_conf.h>
+
#include "slave_life.h"
#include "slave_rpc.h"
#include "client_life.h"
#include "badge_service.h"
#if defined(FLOG)
+#define TMP_LOG_FILE "/tmp/live.log"
FILE *__file_log_fp;
#endif
{
int ret;
- if (access(SLAVE_LOG_PATH, R_OK | W_OK) != 0) {
- if (mkdir(SLAVE_LOG_PATH, 0755) < 0) {
- ErrPrint("Failed to create %s (%s)\n", SLAVE_LOG_PATH, strerror(errno));
+ if (access(DYNAMICBOX_CONF_LOG_PATH, R_OK | W_OK) != 0) {
+ if (mkdir(DYNAMICBOX_CONF_LOG_PATH, 0755) < 0) {
+ ErrPrint("Failed to create %s (%s)\n", DYNAMICBOX_CONF_LOG_PATH, strerror(errno));
}
}
script_init();
- if (util_service_is_enabled(SERVICE_FILE)) {
+ if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_FILE)) {
file_service_init();
}
- if (util_service_is_enabled(SERVICE_UTILITY)) {
+ if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_UTILITY)) {
utility_service_init();
}
#endif
- if (util_service_is_enabled(SERVICE_SHORTCUT)) {
+ if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_SHORTCUT)) {
shortcut_service_init();
}
- if (util_service_is_enabled(SERVICE_NOTIFICATION)) {
+ if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_NOTIFICATION)) {
notification_service_init();
}
- if (util_service_is_enabled(SERVICE_BADGE)) {
+ if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_BADGE)) {
badge_service_init();
}
{
int ret;
- if (util_service_is_enabled(SERVICE_BADGE)) {
+ if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_BADGE)) {
ret = badge_service_fini();
if (ret < 0) {
DbgPrint("badge: %d\n", ret);
}
}
- if (util_service_is_enabled(SERVICE_NOTIFICATION)) {
+ if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_NOTIFICATION)) {
ret = notification_service_fini();
if (ret < 0) {
DbgPrint("noti: %d\n", ret);
}
}
- if (util_service_is_enabled(SERVICE_SHORTCUT)) {
+ if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_SHORTCUT)) {
ret = shortcut_service_fini();
if (ret < 0) {
DbgPrint("shortcut: %d\n", ret);
}
#if defined(HAVE_LIVEBOX)
- if (util_service_is_enabled(SERVICE_FILE)) {
+ if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_FILE)) {
ret = file_service_fini();
if (ret < 0) {
DbgPrint("Finalize the file service: %d\n", ret);
DbgPrint("dead signal handler finalized: %d\n", ret);
}
- if (util_service_is_enabled(SERVICE_UTILITY)) {
+ if (util_service_is_enabled(DYNAMICBOX_CONF_SERVICE_UTILITY)) {
ret = utility_service_fini();
if (ret < 0) {
DbgPrint("utility: %d\n", ret);
fd = ecore_main_fd_handler_fd_get(handler);
if (fd < 0) {
ErrPrint("Unable to get FD\n");
+ ecore_main_fd_handler_del(handler);
return ECORE_CALLBACK_CANCEL;
}
size = read(fd, &fdsi, sizeof(fdsi));
if (size != sizeof(fdsi)) {
ErrPrint("Unable to get siginfo: %s\n", strerror(errno));
+ ecore_main_fd_handler_del(handler);
return ECORE_CALLBACK_CANCEL;
}
sigset_t mask;
Ecore_Fd_Handler *signal_handler = NULL;
-#if defined(HAVE_LIVEBOX)
- conf_init();
- conf_loader();
+#if defined(FLOG)
+ __file_log_fp = fopen(TMP_LOG_FILE, "w+t");
+ if (!__file_log_fp) {
+ __file_log_fp = fdopen(1, "w+t");
+ }
#endif
- /*!
- * \note
- * Clear old contents files before start the master provider.
- */
- (void)util_unlink_files(ALWAYS_PATH);
- (void)util_unlink_files(READER_PATH);
- (void)util_unlink_files(IMAGE_PATH);
- (void)util_unlink_files(SLAVE_LOG_PATH);
+ /* appcore_agent_terminate */
+ if (ecore_init() <= 0) {
+ return -EFAULT;
+ }
- if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
- util_remove_emergency_disk();
- util_prepare_emergency_disk();
+ if (util_screen_init() <= 0) {
+ ecore_shutdown();
+ return -EFAULT;
}
- util_setup_log_disk();
+ dynamicbox_conf_init();
+ dynamicbox_conf_load();
/*!
* How could we care this return values?
ErrPrint("Failed to init the critical log\n");
}
-#if defined(FLOG)
- __file_log_fp = fopen("/tmp/live.log", "w+t");
- if (!__file_log_fp) {
- __file_log_fp = fdopen(1, "w+t");
- }
-#endif
- /* appcore_agent_terminate */
- if (ecore_init() <= 0) {
- CRITICAL_LOG("Failed to initiate ecore\n");
- critical_log_fini();
- return -EFAULT;
+ /*!
+ * \note
+ * Clear old contents files before start the master provider.
+ */
+ (void)util_unlink_files(DYNAMICBOX_CONF_ALWAYS_PATH);
+ (void)util_unlink_files(DYNAMICBOX_CONF_READER_PATH);
+ (void)util_unlink_files(DYNAMICBOX_CONF_IMAGE_PATH);
+ (void)util_unlink_files(DYNAMICBOX_CONF_LOG_PATH);
+
+ if (util_free_space(DYNAMICBOX_CONF_IMAGE_PATH) < DYNAMICBOX_CONF_MINIMUM_SPACE) {
+ util_remove_emergency_disk();
+ util_prepare_emergency_disk();
}
+ util_setup_log_disk();
+
sigemptyset(&mask);
ret = sigaddset(&mask, SIGTERM);
CRITICAL_LOG("Signal handler initiated: %d\n", ret);
}
- if (util_screen_init() <= 0) {
- CRITICAL_LOG("Failed to ecore x init\n");
- ecore_shutdown();
- critical_log_fini();
- return -EFAULT;
- }
-
ecore_app_args_set(argc, (const char **)argv);
#if (GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 36)
g_type_init();
#endif
-#if defined(HAVE_LIVEBOX)
- /*!
- * \note
- * conf_update_size requires util_screen_init.
- */
- conf_update_size();
-#endif
-
app_create();
-
sd_notify(0, "READY=1");
vconf_get_int(VCONFKEY_MASTER_RESTART_COUNT, &restart_count);
}
#endif
- conf_reset();
+ dynamicbox_conf_reset();
return 0;
}
#include <dlog.h>
#if defined(HAVE_LIVEBOX)
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#else
#include "lite-errno.h"
#endif
#include <security-server.h>
#include <vconf.h>
+#include <notification.h>
+#include <notification_internal.h>
#include <notification_ipc.h>
#include <notification_noti.h>
-#include <notification_error.h>
#include <notification_setting_service.h>
#include "service_common.h"
static inline struct packet *_packet_create_with_list(int op_num, int *list, int start_index) {
return packet_create(
- "del_noti_multiple",
- "iiiiiiiiiii",
- ((op_num - start_index) > NOTIFICATION_DEL_PACKET_UNIT) ? NOTIFICATION_DEL_PACKET_UNIT : op_num - start_index,
- _priv_id_get_from_list(op_num, list, start_index),
- _priv_id_get_from_list(op_num, list, start_index + 1),
- _priv_id_get_from_list(op_num, list, start_index + 2),
- _priv_id_get_from_list(op_num, list, start_index + 3),
- _priv_id_get_from_list(op_num, list, start_index + 4),
- _priv_id_get_from_list(op_num, list, start_index + 5),
- _priv_id_get_from_list(op_num, list, start_index + 6),
- _priv_id_get_from_list(op_num, list, start_index + 7),
- _priv_id_get_from_list(op_num, list, start_index + 8),
- _priv_id_get_from_list(op_num, list, start_index + 9)
- );
+ "del_noti_multiple",
+ "iiiiiiiiiii",
+ ((op_num - start_index) > NOTIFICATION_DEL_PACKET_UNIT) ? NOTIFICATION_DEL_PACKET_UNIT : op_num - start_index,
+ _priv_id_get_from_list(op_num, list, start_index),
+ _priv_id_get_from_list(op_num, list, start_index + 1),
+ _priv_id_get_from_list(op_num, list, start_index + 2),
+ _priv_id_get_from_list(op_num, list, start_index + 3),
+ _priv_id_get_from_list(op_num, list, start_index + 4),
+ _priv_id_get_from_list(op_num, list, start_index + 5),
+ _priv_id_get_from_list(op_num, list, start_index + 6),
+ _priv_id_get_from_list(op_num, list, start_index + 7),
+ _priv_id_get_from_list(op_num, list, start_index + 8),
+ _priv_id_get_from_list(op_num, list, start_index + 9)
+ );
}
/*!
* SERVICE HANDLER
*/
-static void _handler_insert(struct tcb *tcb, struct packet *packet, void *data)
+static void _handler_insert_noti(struct tcb *tcb, struct packet *packet, notification_h noti, void *data)
{
int ret = 0, ret_p = 0;
int priv_id = 0;
struct packet *packet_reply = NULL;
struct packet *packet_service = NULL;
+
+ ret = notification_noti_insert(noti);
+ notification_get_id(noti, NULL, &priv_id);
+ DbgPrint("priv_id: [%d]\n", priv_id);
+ packet_reply = packet_create_reply(packet, "ii", ret, priv_id);
+ if (packet_reply) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ ErrPrint("failed to send reply packet: %d\n", ret_p);
+ }
+ packet_destroy(packet_reply);
+ } else {
+ ErrPrint("failed to create a reply packet\n");
+ }
+
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ErrPrint("failed to insert a notification: %d\n", ret);
+ return ;
+ }
+
+ packet_service = notification_ipc_make_packet_from_noti(noti, "add_noti", 2);
+ if (packet_service != NULL) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ ErrPrint("failed to send a multicast packet: %d\n", ret_p);
+ }
+ packet_destroy(packet_service);
+ } else {
+ ErrPrint("failed to create a multicats packet\n");
+ }
+}
+
+/*static void _handler_insert(struct tcb *tcb, struct packet *packet, void *data) // not used
+ {
+ notification_h noti = NULL;
+
+ noti = notification_create(NOTIFICATION_TYPE_NOTI);
+ if (noti != NULL) {
+ if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE) {
+ _handler_insert_noti(tcb, packet, noti, data);
+ } else {
+ ErrPrint("Failed to create the packet");
+ }
+ notification_free(noti);
+ }
+ }*/
+
+static void _handler_update_noti(struct tcb *tcb, struct packet *packet, notification_h noti, void *data)
+{
+ int ret = 0, ret_p = 0;
+ int priv_id = 0;
+ struct packet *packet_reply = NULL;
+ struct packet *packet_service = NULL;
+
+ ret = notification_noti_update(noti);
+
+ notification_get_id(noti, NULL, &priv_id);
+ DbgPrint("priv_id: [%d]\n", priv_id);
+ packet_reply = packet_create_reply(packet, "ii", ret, priv_id);
+ if (packet_reply) {
+ if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ ErrPrint("failed to send reply packet:%d\n", ret_p);
+ }
+ packet_destroy(packet_reply);
+ } else {
+ ErrPrint("failed to create a reply packet\n");
+ }
+
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ ErrPrint("failed to update a notification:%d\n", ret);
+ return ;
+ }
+
+ packet_service = notification_ipc_make_packet_from_noti(noti, "update_noti", 2);
+ if (packet_service != NULL) {
+ if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ ErrPrint("failed to send a multicast packet: %d\n", ret_p);
+ }
+ packet_destroy(packet_service);
+ }
+}
+
+static void _handler_update(struct tcb *tcb, struct packet *packet, void *data)
+{
notification_h noti = NULL;
noti = notification_create(NOTIFICATION_TYPE_NOTI);
if (noti != NULL) {
if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE) {
- ret = notification_noti_insert(noti);
- notification_get_id(noti, NULL, &priv_id);
- DbgPrint("priv_id: [%d]\n", priv_id);
- packet_reply = packet_create_reply(packet, "ii", ret, priv_id);
- if (packet_reply) {
- if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
- ErrPrint("failed to send reply packet: %d\n", ret_p);
- }
- packet_destroy(packet_reply);
- } else {
- ErrPrint("failed to create a reply packet\n");
- }
+ _handler_update_noti(tcb, packet, noti, data);
+ } else {
+ ErrPrint("Failed to create the packet");
+ }
+ notification_free(noti);
+ }
+}
- if (ret != NOTIFICATION_ERROR_NONE) {
- ErrPrint("failed to insert a notification: %d\n", ret);
- notification_free(noti);
- return ;
- }
+static void _handler_check_noti_by_tag(struct tcb *tcb, struct packet *packet, void *data)
+{
+ int ret = 0;
+ notification_h noti = NULL;
- packet_service = notification_ipc_make_packet_from_noti(noti, "add_noti", 2);
- if (packet_service != NULL) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
- ErrPrint("failed to send a multicast packet: %d\n", ret_p);
- }
- packet_destroy(packet_service);
- } else {
- ErrPrint("failed to create a multicats packet\n");
+ noti = notification_create(NOTIFICATION_TYPE_NOTI);
+ if (noti != NULL) {
+ if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE) {
+ ret = notification_noti_check_tag(noti);
+ if (ret == NOTIFICATION_ERROR_NOT_EXIST_ID) {
+ _handler_insert_noti(tcb, packet, noti, data);
+ } else if (ret == NOTIFICATION_ERROR_ALREADY_EXIST_ID) {
+ _handler_update_noti(tcb, packet, noti, data);
}
- } else {
- ErrPrint("Failed to create the packet");
}
notification_free(noti);
}
}
-static void _handler_update(struct tcb *tcb, struct packet *packet, void *data)
+static void _handler_load_noti_by_tag(struct tcb *tcb, struct packet *packet, void *data)
{
int ret = 0, ret_p = 0;
- int priv_id = 0;
+ char* tag;
+ char* pkgname;
struct packet *packet_reply = NULL;
- struct packet *packet_service = NULL;
notification_h noti = NULL;
noti = notification_create(NOTIFICATION_TYPE_NOTI);
if (noti != NULL) {
- if (notification_ipc_make_noti_from_packet(noti, packet) == NOTIFICATION_ERROR_NONE) {
- ret = notification_noti_update(noti);
-
- notification_get_id(noti, NULL, &priv_id);
- DbgPrint("priv_id: [%d]\n", priv_id);
- packet_reply = packet_create_reply(packet, "ii", ret, priv_id);
+ if (packet_get(packet, "ss", &pkgname, &tag) == 2) {
+ ret = notification_noti_get_by_tag(noti, pkgname, tag);
+ packet_reply = notification_ipc_make_reply_packet_from_noti(noti, packet);
if (packet_reply) {
if ((ret_p = service_common_unicast_packet(tcb, packet_reply)) < 0) {
- ErrPrint("failed to send reply packet:%d\n", ret_p);
+ ErrPrint("failed to send reply packet: %d\n", ret_p);
}
packet_destroy(packet_reply);
} else {
}
if (ret != NOTIFICATION_ERROR_NONE) {
- ErrPrint("failed to update a notification:%d\n", ret);
+ ErrPrint("failed to load_noti_by_tag : %d\n", ret);
notification_free(noti);
return ;
}
-
- packet_service = notification_ipc_make_packet_from_noti(noti, "update_noti", 2);
- if (packet_service != NULL) {
- if ((ret_p = service_common_multicast_packet(tcb, packet_service, TCB_CLIENT_TYPE_SERVICE)) < 0) {
- ErrPrint("failed to send a multicast packet: %d\n", ret_p);
- }
- packet_destroy(packet_service);
- }
} else {
ErrPrint("Failed to create the packet");
}
}
}
+
static void _handler_refresh(struct tcb *tcb, struct packet *packet, void *data)
{
int ret = 0;
}
}
+static void _handler_post_toast_message(struct tcb *tcb, struct packet *packet, void *data)
+{
+ int ret = 0;
+ struct packet *packet_reply = NULL;
+
+ packet_reply = packet_create_reply(packet, "i", ret);
+ if (packet_reply) {
+ if ((ret = service_common_unicast_packet(tcb, packet_reply)) < 0) {
+ ErrPrint("failed to send reply packet:%d\n", ret);
+ }
+ packet_destroy(packet_reply);
+ } else {
+ ErrPrint("failed to create a reply packet\n");
+ }
+
+ if ((ret = service_common_multicast_packet(tcb, packet, TCB_CLIENT_TYPE_SERVICE)) < 0) {
+ ErrPrint("failed to send a multicast packet:%d\n", ret);
+ }
+
+}
+
/*!
* SERVICE PERMISSION CHECK
*/
{
int i = 0;
const char *command;
+
static struct noti_service service_req_table[] = {
{
.cmd = "add_noti",
- .handler = _handler_insert,
+ .handler = _handler_check_noti_by_tag,
.rule = "data-provider-master::notification.client",
.access = "w",
.handler_access_error = _permission_check_common,
.handler_access_error = _permission_check_common,
},
{
+ .cmd = "load_noti_by_tag",
+ .handler = _handler_load_noti_by_tag,
+ .rule = "data-provider-master::notification.client",
+ .access = "r",
+ .handler_access_error = _permission_check_common,
+ },
+ {
.cmd = "refresh_noti",
.handler = _handler_refresh,
.rule = "data-provider-master::notification.client",
.handler_access_error = NULL,
},
{
+ .cmd = "post_toast",
+ .handler = _handler_post_toast_message,
+ .rule = NULL,
+ .access = NULL,
+ .handler_access_error = NULL,
+ },
+ {
.cmd = NULL,
.handler = NULL,
.rule = NULL,
{
if (s_info.svc_ctx) {
ErrPrint("Already initialized\n");
- return LB_STATUS_ERROR_ALREADY;
+ return DBOX_STATUS_ERROR_ALREADY;
}
_notification_init();
s_info.svc_ctx = service_common_create(NOTIFICATION_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), NOTIFICATION_SMACK_LABEL, SMACK_LABEL_IPOUT) != 0) {
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;
}
}
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 notification_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 */
#include <Eina.h>
#include <packet.h>
-#include <livebox-errno.h>
-#include <livebox-service.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_conf.h>
+#include <pkgmgr-info.h>
#include <ail.h>
#include "critical_log.h"
struct pkg_info {
char *pkgid;
- char *lbid;
+ char *dbox_id;
struct {
- enum lb_type type;
+ enum dynamicbox_dbox_type type;
union {
struct {
int timeout;
double period;
char *libexec;
- } lb;
+ } dbox;
struct {
- enum pd_type type;
+ enum dynamicbox_gbar_type type;
union {
struct {
unsigned int width;
unsigned int height;
- } pd;
+ } gbar;
int network;
int secured;
+ int direct_input;
char *script; /* script type: edje, ... */
char *abi;
+ char *hw_acceleration;
int fault_count;
struct fault_info *fault_info;
DbgPrint("Slave critical fault - package: %s (by slave fault %s\n", package_name(info), slave_name(slave));
EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
DbgPrint("Destroy instance %p\n", inst);
- instance_destroyed(inst, LB_STATUS_ERROR_FAULT);
+ instance_destroyed(inst, DBOX_STATUS_ERROR_FAULT);
}
return 0;
if (info->fault_info) {
EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
- instance_destroyed(inst, LB_STATUS_ERROR_FAULT);
+ instance_destroyed(inst, DBOX_STATUS_ERROR_FAULT);
}
} else {
EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
static inline void destroy_package(struct pkg_info *info)
{
eina_list_free(info->ctx_list);
- /* This items will be deleted from group_del_livebox */
+ /* This items will be deleted from group_del_dynamicbox */
info->ctx_list = NULL;
- group_del_livebox(info->lbid);
+ group_del_dynamicbox(info->dbox_id);
package_clear_fault(info);
s_info.pkg_list = eina_list_remove(s_info.pkg_list, info);
- if (info->lb.type == LB_TYPE_SCRIPT) {
- DbgFree(info->lb.info.script.path);
- DbgFree(info->lb.info.script.group);
+ if (info->dbox.type == DBOX_TYPE_SCRIPT) {
+ DbgFree(info->dbox.info.script.path);
+ DbgFree(info->dbox.info.script.group);
}
- if (info->pd.type == PD_TYPE_SCRIPT) {
- DbgFree(info->pd.info.script.path);
- DbgFree(info->pd.info.script.group);
+ if (info->gbar.type == GBAR_TYPE_SCRIPT) {
+ DbgFree(info->gbar.info.script.path);
+ DbgFree(info->gbar.info.script.group);
}
DbgFree(info->script);
DbgFree(info->abi);
- DbgFree(info->lbid);
- DbgFree(info->lb.libexec);
- DbgFree(info->lb.auto_launch);
+ DbgFree(info->dbox_id);
+ DbgFree(info->dbox.libexec);
+ DbgFree(info->dbox.auto_launch);
DbgFree(info->pkgid);
+ DbgFree(info->hw_acceleration);
DbgFree(info);
}
const char *str;
const char *group;
- parser = parser_load(info->lbid);
+ parser = parser_load(info->dbox_id);
if (!parser) {
- info->lb.size_list = 0x01; /* Default */
+ info->dbox.size_list = 0x01; /* Default */
- info->script = strdup(DEFAULT_SCRIPT);
+ info->script = strdup(DYNAMICBOX_CONF_DEFAULT_SCRIPT);
if (!info->script) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- info->abi = strdup(DEFAULT_ABI);
+ info->abi = strdup(DYNAMICBOX_CONF_DEFAULT_ABI);
if (!info->abi) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(info->script);
info->script = NULL;
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- info->pd.width = g_conf.width;
- info->pd.height = g_conf.height >> 2;
- info->lb.pinup = 1;
- return LB_STATUS_SUCCESS;
+ info->gbar.width = DYNAMICBOX_CONF_BASE_W;
+ info->gbar.height = DYNAMICBOX_CONF_BASE_H >> 2;
+ info->dbox.pinup = 1;
+ return DBOX_STATUS_ERROR_NONE;
}
- info->lb.type = LB_TYPE_FILE;
- if (parser_text_lb(parser)) {
- info->lb.type = LB_TYPE_TEXT;
- } else if (parser_buffer_lb(parser)) {
- info->lb.type = LB_TYPE_BUFFER;
+ info->dbox.type = DBOX_TYPE_FILE;
+ if (parser_text_dbox(parser)) {
+ info->dbox.type = DBOX_TYPE_TEXT;
+ } else if (parser_buffer_dbox(parser)) {
+ info->dbox.type = DBOX_TYPE_BUFFER;
} else {
- str = parser_lb_path(parser);
+ str = parser_dbox_path(parser);
if (str) {
- info->lb.type = LB_TYPE_SCRIPT;
+ info->dbox.type = DBOX_TYPE_SCRIPT;
- info->lb.info.script.path = strdup(str);
- if (!info->lb.info.script.path) {
+ info->dbox.info.script.path = strdup(str);
+ if (!info->dbox.info.script.path) {
ErrPrint("Heap: %s\n", strerror(errno));
parser_unload(parser);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- str = parser_lb_group(parser);
+ str = parser_dbox_group(parser);
if (str) {
- info->lb.info.script.group = strdup(str);
- if (!info->lb.info.script.group) {
+ info->dbox.info.script.group = strdup(str);
+ if (!info->dbox.info.script.group) {
ErrPrint("Heap: %s\n", strerror(errno));
- DbgFree(info->lb.info.script.path);
+ DbgFree(info->dbox.info.script.path);
parser_unload(parser);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
}
}
}
- if (parser_text_pd(parser)) {
- info->pd.type = PD_TYPE_TEXT;
- } else if (parser_buffer_pd(parser)) {
- info->pd.type = PD_TYPE_BUFFER;
+ if (parser_text_gbar(parser)) {
+ info->gbar.type = GBAR_TYPE_TEXT;
+ } else if (parser_buffer_gbar(parser)) {
+ info->gbar.type = GBAR_TYPE_BUFFER;
} else {
- str = parser_pd_path(parser);
+ str = parser_gbar_path(parser);
if (str) {
- info->pd.type = PD_TYPE_SCRIPT;
- info->pd.info.script.path = strdup(str);
- if (!info->pd.info.script.path) {
+ info->gbar.type = GBAR_TYPE_SCRIPT;
+ info->gbar.info.script.path = strdup(str);
+ if (!info->gbar.info.script.path) {
ErrPrint("Heap: %s\n", strerror(errno));
- if (info->lb.type == LB_TYPE_SCRIPT) {
- DbgFree(info->lb.info.script.path);
- DbgFree(info->lb.info.script.group);
+ if (info->dbox.type == DBOX_TYPE_SCRIPT) {
+ DbgFree(info->dbox.info.script.path);
+ DbgFree(info->dbox.info.script.group);
}
parser_unload(parser);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- str = parser_pd_group(parser);
+ str = parser_gbar_group(parser);
if (str) {
- info->pd.info.script.group = strdup(str);
- if (!info->pd.info.script.group) {
+ info->gbar.info.script.group = strdup(str);
+ if (!info->gbar.info.script.group) {
ErrPrint("Heap: %s\n", strerror(errno));
- DbgFree(info->pd.info.script.path);
- if (info->lb.type == LB_TYPE_SCRIPT) {
- DbgFree(info->lb.info.script.path);
- DbgFree(info->lb.info.script.group);
+ DbgFree(info->gbar.info.script.path);
+ if (info->dbox.type == DBOX_TYPE_SCRIPT) {
+ DbgFree(info->dbox.info.script.path);
+ DbgFree(info->dbox.info.script.group);
}
parser_unload(parser);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
}
}
}
str = parser_script(parser);
- str = str ? str : DEFAULT_SCRIPT;
+ str = str ? str : DYNAMICBOX_CONF_DEFAULT_SCRIPT;
info->script = strdup(str);
if (!info->script) {
ErrPrint("Heap: %s\n", strerror(errno));
- if (info->pd.type == PD_TYPE_SCRIPT) {
- DbgFree(info->pd.info.script.path);
- DbgFree(info->pd.info.script.group);
+ if (info->gbar.type == GBAR_TYPE_SCRIPT) {
+ DbgFree(info->gbar.info.script.path);
+ DbgFree(info->gbar.info.script.group);
}
- if (info->lb.type == LB_TYPE_SCRIPT) {
- DbgFree(info->lb.info.script.path);
- DbgFree(info->lb.info.script.group);
+ if (info->dbox.type == DBOX_TYPE_SCRIPT) {
+ DbgFree(info->dbox.info.script.path);
+ DbgFree(info->dbox.info.script.group);
}
parser_unload(parser);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
str = parser_abi(parser);
- str = str ? str : DEFAULT_ABI;
+ str = str ? str : DYNAMICBOX_CONF_DEFAULT_ABI;
info->abi = strdup(str);
if (!info->abi) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(info->script);
- if (info->pd.type == PD_TYPE_SCRIPT) {
- DbgFree(info->pd.info.script.path);
- DbgFree(info->pd.info.script.group);
+ if (info->gbar.type == GBAR_TYPE_SCRIPT) {
+ DbgFree(info->gbar.info.script.path);
+ DbgFree(info->gbar.info.script.group);
}
- if (info->lb.type == LB_TYPE_SCRIPT) {
- DbgFree(info->lb.info.script.path);
- DbgFree(info->lb.info.script.group);
+ if (info->dbox.type == DBOX_TYPE_SCRIPT) {
+ DbgFree(info->dbox.info.script.path);
+ DbgFree(info->dbox.info.script.group);
}
parser_unload(parser);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- info->lb.timeout = parser_timeout(parser);
+ info->dbox.timeout = parser_timeout(parser);
info->network = parser_network(parser);
- info->lb.period = parser_period(parser);
- if (info->lb.period < 0.0f) {
- info->lb.period = 0.0f;
- } else if (info->lb.period > 0.0f && info->lb.period < MINIMUM_PERIOD) {
- info->lb.period = MINIMUM_PERIOD;
+ info->dbox.period = parser_period(parser);
+ if (info->dbox.period < 0.0f) {
+ info->dbox.period = 0.0f;
+ } else if (info->dbox.period > 0.0f && info->dbox.period < DYNAMICBOX_CONF_MINIMUM_PERIOD) {
+ info->dbox.period = DYNAMICBOX_CONF_MINIMUM_PERIOD;
}
- info->lb.size_list = parser_size(parser);
+ info->dbox.size_list = parser_size(parser);
str = parser_auto_launch(parser);
str = str ? str : "";
- info->lb.auto_launch = strdup(str);
- if (!info->lb.auto_launch) {
+ info->dbox.auto_launch = strdup(str);
+ if (!info->dbox.auto_launch) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(info->abi);
DbgFree(info->script);
- if (info->pd.type == PD_TYPE_SCRIPT) {
- DbgFree(info->pd.info.script.path);
- DbgFree(info->pd.info.script.group);
+ if (info->gbar.type == GBAR_TYPE_SCRIPT) {
+ DbgFree(info->gbar.info.script.path);
+ DbgFree(info->gbar.info.script.group);
}
- if (info->lb.type == LB_TYPE_SCRIPT) {
- DbgFree(info->lb.info.script.path);
- DbgFree(info->lb.info.script.group);
+ if (info->dbox.type == DBOX_TYPE_SCRIPT) {
+ DbgFree(info->dbox.info.script.path);
+ DbgFree(info->dbox.info.script.group);
}
parser_unload(parser);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
info->secured = parser_secured(parser);
- info->lb.pinup = parser_pinup(parser);
+ info->dbox.pinup = parser_pinup(parser);
- parser_get_pdsize(parser, &info->pd.width, &info->pd.height);
+ parser_get_gbar_size(parser, &info->gbar.width, &info->gbar.height);
group = parser_group_str(parser);
- if (group && group_add_livebox(group, info->lbid) < 0) {
- ErrPrint("Failed to build cluster tree for %s{%s}\n", info->lbid, group);
+ if (group && group_add_dynamicbox(group, info->dbox_id) < 0) {
+ ErrPrint("Failed to build cluster tree for %s{%s}\n", info->dbox_id, group);
}
parser_unload(parser);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI struct pkg_info *package_create(const char *pkgid, const char *lbid)
+HAPI struct pkg_info *package_create(const char *pkgid, const char *dbox_id)
{
struct pkg_info *pkginfo;
return NULL;
}
- pkginfo->lbid = io_livebox_pkgname(lbid);
- if (!pkginfo->lbid) {
+ pkginfo->dbox_id = io_dynamicbox_pkgname(dbox_id);
+ if (!pkginfo->dbox_id) {
ErrPrint("Failed to get pkgname, fallback to fs checker\n");
- if (util_validate_livebox_package(lbid) < 0) {
- ErrPrint("Invalid package name: %s\n", lbid);
- DbgFree(pkginfo->pkgid);
- DbgFree(pkginfo);
- return NULL;
- }
-
- pkginfo->lbid = strdup(lbid);
- if (!pkginfo->lbid) {
+ pkginfo->dbox_id = strdup(dbox_id);
+ if (!pkginfo->dbox_id) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(pkginfo->pkgid);
DbgFree(pkginfo);
ErrPrint("Failed to load DB, fall back to conf file loader\n");
if (load_conf(pkginfo) < 0) {
ErrPrint("Failed to initiate the conf file loader\n");
- DbgFree(pkginfo->lbid);
+ DbgFree(pkginfo->dbox_id);
DbgFree(pkginfo->pkgid);
DbgFree(pkginfo);
return NULL;
HAPI int package_destroy(struct pkg_info *info)
{
package_unref(info);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI Eina_List *package_ctx_info(struct pkg_info *pkginfo)
pkginfo->ctx_list = eina_list_remove(pkginfo->ctx_list, info);
}
-HAPI char *package_lb_pkgname(const char *pkgname)
+HAPI char *package_dbox_pkgname(const char *pkgname)
{
- char *lbid;
+ char *dbox_id;
- lbid = io_livebox_pkgname(pkgname);
- if (!lbid) {
- if (util_validate_livebox_package(pkgname) < 0) {
- return NULL;
- }
-
- lbid = strdup(pkgname);
- if (!lbid) {
+ dbox_id = io_dynamicbox_pkgname(pkgname);
+ if (!dbox_id) {
+ dbox_id = strdup(pkgname);
+ if (!dbox_id) {
ErrPrint("Heap: %s\n", strerror(errno));
return NULL;
}
}
- return lbid;
+ return dbox_id;
}
-HAPI int package_is_lb_pkgname(const char *pkgname)
+HAPI int package_is_dbox_pkgname(const char *pkgname)
{
- char *lbid;
+ char *dbox_id;
int ret;
- lbid = package_lb_pkgname(pkgname);
- ret = !!lbid;
- DbgFree(lbid);
+ dbox_id = package_dbox_pkgname(pkgname);
+ ret = !!dbox_id;
+ DbgFree(dbox_id);
return ret;
}
-HAPI struct pkg_info *package_find(const char *lbid)
+HAPI struct pkg_info *package_find(const char *dbox_id)
{
Eina_List *l;
struct pkg_info *info;
- if (!lbid) {
+ if (!dbox_id) {
return NULL;
}
EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
- if (!strcmp(info->lbid, lbid)) {
+ if (!strcmp(info->dbox_id, dbox_id)) {
return info;
}
}
return NULL;
}
-HAPI struct inst_info *package_find_instance_by_id(const char *lbid, const char *id)
+HAPI struct inst_info *package_find_instance_by_id(const char *dbox_id, const char *id)
{
Eina_List *l;
struct inst_info *inst;
struct pkg_info *info;
- info = package_find(lbid);
+ info = package_find(dbox_id);
if (!info) {
- ErrPrint("Package %s is not exists\n", lbid);
+ ErrPrint("Package %s is not exists\n", dbox_id);
return NULL;
}
return NULL;
}
-HAPI struct inst_info *package_find_instance_by_timestamp(const char *lbid, double timestamp)
+HAPI struct inst_info *package_find_instance_by_timestamp(const char *dbox_id, double timestamp)
{
Eina_List *l;
struct inst_info *inst;
struct pkg_info *info;
- info = package_find(lbid);
+ info = package_find(dbox_id);
if (!info) {
- ErrPrint("Package %s is not exists\n", lbid);
+ ErrPrint("Package %s is not exists\n", dbox_id);
return NULL;
}
HAPI int package_dump_fault_info(struct pkg_info *info)
{
if (!info->fault_info) {
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
CRITICAL_LOG("=============\n");
CRITICAL_LOG("faulted at %lf\n", info->fault_info->timestamp);
- CRITICAL_LOG("Package: %s\n", info->lbid);
+ CRITICAL_LOG("Package: %s\n", info->dbox_id);
CRITICAL_LOG("Function: %s\n", info->fault_info->function);
CRITICAL_LOG("InstanceID: %s\n", info->fault_info->filename);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int package_get_fault_info(struct pkg_info *info, double *timestamp, const char **filename, const char **function)
{
if (!info->fault_info) {
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
*timestamp = info->fault_info->timestamp;
*filename = info->fault_info->filename;
*function = info->fault_info->function;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int package_set_fault_info(struct pkg_info *info, double timestamp, const char *filename, const char *function)
fault = calloc(1, sizeof(*fault));
if (!fault) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
fault->timestamp = timestamp;
if (!fault->filename) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(fault);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
fault->function = strdup(function);
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(fault->filename);
DbgFree(fault);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
info->fault_info = fault;
info->fault_count++;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int package_clear_fault(struct pkg_info *info)
{
if (!info->fault_info) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
-
+
package_dump_fault_info(info);
DbgFree(info->fault_info->function);
DbgFree(info->fault_info->filename);
DbgFree(info->fault_info);
info->fault_info = NULL;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI const int const package_is_fault(const struct pkg_info *info)
HAPI const int const package_timeout(const struct pkg_info *info)
{
- return info->lb.timeout;
+ return info->dbox.timeout;
}
HAPI void package_set_timeout(struct pkg_info *info, int timeout)
{
- info->lb.timeout = timeout;
+ info->dbox.timeout = timeout;
}
HAPI const double const package_period(const struct pkg_info *info)
{
- return info->lb.period;
+ return info->dbox.period;
}
HAPI void package_set_period(struct pkg_info *info, double period)
{
- info->lb.period = period;
+ info->dbox.period = period;
}
HAPI const int const package_secured(const struct pkg_info *info)
tmp = strdup(script);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
DbgFree(info->script);
info->script = tmp;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI const char * const package_abi(const struct pkg_info *info)
tmp = strdup(abi);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
DbgFree(info->abi);
info->abi = tmp;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI const char * const package_lb_path(const struct pkg_info *info)
+HAPI const char * const package_dbox_path(const struct pkg_info *info)
{
- if (info->lb.type != LB_TYPE_SCRIPT) {
+ if (info->dbox.type != DBOX_TYPE_SCRIPT) {
return NULL;
}
- return info->lb.info.script.path;
+ return info->dbox.info.script.path;
}
-HAPI int package_set_lb_path(struct pkg_info *info, const char *path)
+HAPI int package_set_dbox_path(struct pkg_info *info, const char *path)
{
char *tmp;
- if (info->lb.type != LB_TYPE_SCRIPT) {
- return LB_STATUS_ERROR_INVALID;
+ if (info->dbox.type != DBOX_TYPE_SCRIPT) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
tmp = strdup(path);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- DbgFree(info->lb.info.script.path);
- info->lb.info.script.path = tmp;
- return LB_STATUS_SUCCESS;
+ DbgFree(info->dbox.info.script.path);
+ info->dbox.info.script.path = tmp;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI const char * const package_lb_group(const struct pkg_info *info)
+HAPI const char * const package_dbox_group(const struct pkg_info *info)
{
- if (info->lb.type != LB_TYPE_SCRIPT) {
+ if (info->dbox.type != DBOX_TYPE_SCRIPT) {
return NULL;
}
- return info->lb.info.script.group;
+ return info->dbox.info.script.group;
}
-HAPI int package_set_lb_group(struct pkg_info *info, const char *group)
+HAPI int package_set_dbox_group(struct pkg_info *info, const char *group)
{
char *tmp;
- if (info->lb.type != LB_TYPE_SCRIPT) {
- return LB_STATUS_ERROR_INVALID;
+ if (info->dbox.type != DBOX_TYPE_SCRIPT) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
tmp = strdup(group);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- DbgFree(info->lb.info.script.group);
- info->lb.info.script.group = tmp;
- return LB_STATUS_SUCCESS;
+ DbgFree(info->dbox.info.script.group);
+ info->dbox.info.script.group = tmp;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI const char * const package_pd_path(const struct pkg_info *info)
+HAPI const char * const package_gbar_path(const struct pkg_info *info)
{
- if (info->pd.type != PD_TYPE_SCRIPT) {
+ if (info->gbar.type != GBAR_TYPE_SCRIPT) {
return NULL;
}
- return info->pd.info.script.path;
+ return info->gbar.info.script.path;
}
-HAPI int package_set_pd_path(struct pkg_info *info, const char *path)
+HAPI int package_set_gbar_path(struct pkg_info *info, const char *path)
{
char *tmp;
- if (info->pd.type != PD_TYPE_SCRIPT) {
- return LB_STATUS_ERROR_INVALID;
+ if (info->gbar.type != GBAR_TYPE_SCRIPT) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
tmp = strdup(path);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- DbgFree(info->pd.info.script.path);
- info->pd.info.script.path = tmp;
- return LB_STATUS_SUCCESS;
+ DbgFree(info->gbar.info.script.path);
+ info->gbar.info.script.path = tmp;
+ return DBOX_STATUS_ERROR_NONE;
}
-HAPI const char * const package_pd_group(const struct pkg_info *info)
+HAPI const char * const package_gbar_group(const struct pkg_info *info)
{
- if (info->pd.type != PD_TYPE_SCRIPT) {
+ if (info->gbar.type != GBAR_TYPE_SCRIPT) {
return NULL;
}
- return info->pd.info.script.group;
+ return info->gbar.info.script.group;
}
-HAPI int package_set_pd_group(struct pkg_info *info, const char *group)
+HAPI int package_set_gbar_group(struct pkg_info *info, const char *group)
{
char *tmp;
- if (info->pd.type != PD_TYPE_SCRIPT) {
- return LB_STATUS_ERROR_INVALID;
+ if (info->gbar.type != GBAR_TYPE_SCRIPT) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
tmp = strdup(group);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- DbgFree(info->pd.info.script.group);
- info->pd.info.script.group = tmp;
- return LB_STATUS_SUCCESS;
+ DbgFree(info->gbar.info.script.group);
+ info->gbar.info.script.group = tmp;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI const int const package_pinup(const struct pkg_info *info)
{
- return info->lb.pinup;
+ return info->dbox.pinup;
}
HAPI void package_set_pinup(struct pkg_info *info, int pinup)
{
- info->lb.pinup = pinup;
+ info->dbox.pinup = pinup;
}
HAPI const char * const package_auto_launch(const struct pkg_info *info)
{
- return info->lb.auto_launch;
+ return info->dbox.auto_launch;
}
HAPI void package_set_auto_launch(struct pkg_info *info, const char *auto_launch)
auto_launch = "";
}
- info->lb.auto_launch = strdup(auto_launch);
- if (!info->lb.auto_launch) {
+ info->dbox.auto_launch = strdup(auto_launch);
+ if (!info->dbox.auto_launch) {
ErrPrint("Heap: %s\n", strerror(errno));
return;
}
HAPI const unsigned int const package_size_list(const struct pkg_info *info)
{
- return info->lb.size_list;
+ return info->dbox.size_list;
}
HAPI void package_set_size_list(struct pkg_info *info, unsigned int size_list)
{
- info->lb.size_list = size_list;
+ info->dbox.size_list = size_list;
}
-HAPI const int const package_pd_width(const struct pkg_info *info)
+HAPI const int const package_gbar_width(const struct pkg_info *info)
{
- return info->pd.width;
+ return info->gbar.width;
}
-HAPI void package_set_pd_width(struct pkg_info *info, int width)
+HAPI void package_set_gbar_width(struct pkg_info *info, int width)
{
- info->pd.width = width;
+ info->gbar.width = width;
}
-HAPI const int const package_pd_height(const struct pkg_info *info)
+HAPI const int const package_gbar_height(const struct pkg_info *info)
{
- return info->pd.height;
+ return info->gbar.height;
}
-HAPI void package_set_pd_height(struct pkg_info *info, int height)
+HAPI void package_set_gbar_height(struct pkg_info *info, int height)
{
- info->pd.height = height;
+ info->gbar.height = height;
}
HAPI struct pkg_info * const package_ref(struct pkg_info *info)
return info->refcnt;
}
-HAPI const enum lb_type package_lb_type(const struct pkg_info *info)
+HAPI const enum dynamicbox_dbox_type package_dbox_type(const struct pkg_info *info)
{
- return info ? info->lb.type : LB_TYPE_NONE;
+ return info ? info->dbox.type : DBOX_TYPE_NONE;
}
-HAPI void package_set_lb_type(struct pkg_info *info, enum lb_type type)
+HAPI void package_set_dbox_type(struct pkg_info *info, enum dynamicbox_dbox_type type)
{
- info->lb.type = type;
+ info->dbox.type = type;
}
HAPI const char * const package_libexec(struct pkg_info *info)
{
- return info->lb.libexec;
+ return info->dbox.libexec;
}
HAPI int package_set_libexec(struct pkg_info *info, const char *libexec)
tmp = strdup(libexec);
if (!tmp) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- DbgFree(info->lb.libexec);
- info->lb.libexec = tmp;
- return LB_STATUS_SUCCESS;
+ DbgFree(info->dbox.libexec);
+ info->dbox.libexec = tmp;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int package_network(struct pkg_info *info)
info->network = network;
}
-HAPI const enum pd_type const package_pd_type(const struct pkg_info *info)
+HAPI void package_set_direct_input(struct pkg_info *info, int direct_input)
+{
+ info->direct_input = direct_input;
+}
+
+HAPI int package_direct_input(const struct pkg_info *info)
+{
+ return info->direct_input;
+}
+
+HAPI const enum dynamicbox_gbar_type const package_gbar_type(const struct pkg_info *info)
+{
+ return info ? info->gbar.type : GBAR_TYPE_NONE;
+}
+
+HAPI void package_set_gbar_type(struct pkg_info *info, enum dynamicbox_gbar_type type)
+{
+ info->gbar.type = type;
+}
+
+HAPI const char *package_hw_acceleration(struct pkg_info *info)
{
- return info ? info->pd.type : PD_TYPE_NONE;
+ return info->hw_acceleration;
}
-HAPI void package_set_pd_type(struct pkg_info *info, enum pd_type type)
+HAPI int package_set_hw_acceleration(struct pkg_info *info, const char *hw_acceleration)
{
- info->pd.type = type;
+ char *tmp;
+
+ if (!hw_acceleration || !info) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ tmp = strdup(hw_acceleration);
+ if (!tmp) {
+ ErrPrint("strdup: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ DbgFree(info->hw_acceleration);
+ info->hw_acceleration = tmp;
+ return DBOX_STATUS_ERROR_NONE;
}
/*!
* Add the instance to the package info.
* If a package has no slave, assign a new slave.
*/
-static inline int assign_new_slave(struct pkg_info *info)
+static inline int assign_new_slave(const char *slave_pkgname, struct pkg_info *info)
{
char *s_name;
- char *s_pkgname;
- const char *tmp;
s_name = util_slavename();
if (!s_name) {
ErrPrint("Failed to get a new slave name\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- tmp = abi_find_slave(info->abi);
- if (!tmp) {
- DbgFree(s_name);
- ErrPrint("Failed to find a proper pkgname of a slave\n");
- return LB_STATUS_ERROR_INVALID;
- }
-
- s_pkgname = util_replace_string(tmp, REPLACE_TAG_APPID, info->lbid);
- if (!s_pkgname) {
- DbgPrint("Failed to get replaced string\n");
- s_pkgname = strdup(tmp);
- if (!s_pkgname) {
- ErrPrint("Heap: %s\n", strerror(errno));
- DbgFree(s_name);
- return LB_STATUS_ERROR_MEMORY;
- }
- }
-
- DbgPrint("New slave[%s] is assigned for %s (using %s / abi[%s])\n", s_name, info->lbid, s_pkgname, info->abi);
- info->slave = slave_create(s_name, info->secured, info->abi, s_pkgname, info->network);
+ DbgPrint("New slave[%s] is assigned for %s (using %s / abi[%s] / accel[%s])\n", s_name, info->dbox_id, slave_pkgname, info->abi, info->hw_acceleration);
+ info->slave = slave_create(s_name, info->secured, info->abi, slave_pkgname, info->network, info->hw_acceleration);
DbgFree(s_name);
- DbgFree(s_pkgname);
if (!info->slave) {
/*!
* If the list method couldn't find an "info" from the list,
* it just do nothing so I'll leave this.
*/
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
/*!
* \note
* Slave is not activated yet.
*/
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int package_add_instance(struct pkg_info *info, struct inst_info *inst)
{
if (!info->inst_list) {
- info->slave = slave_find_available(info->abi, info->secured, info->network);
+ char *slave_pkgname;
+
+ slave_pkgname = slave_package_name(info->abi, info->dbox_id);
+ if (!slave_pkgname) {
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+ info->slave = slave_find_available(slave_pkgname, info->abi, info->secured, info->network, info->hw_acceleration);
if (!info->slave) {
int ret;
- ret = assign_new_slave(info);
+ ret = assign_new_slave(slave_pkgname, info);
+ DbgFree(slave_pkgname);
if (ret < 0) {
return ret;
}
} else {
- DbgPrint("Slave %s is used for %s\n", slave_name(info->slave), info->lbid);
+ DbgFree(slave_pkgname);
+ DbgPrint("Slave %s is used for %s\n", slave_name(info->slave), info->dbox_id);
}
(void)slave_ref(info->slave);
(void)slave_event_callback_add(info->slave, SLAVE_EVENT_ACTIVATE, slave_activated_cb, info);
(void)slave_event_callback_add(info->slave, SLAVE_EVENT_FAULT, slave_fault_cb, info);
- if (info->secured) {
+ if (info->secured || (DBOX_IS_INHOUSE(package_abi(info)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL)) {
(void)slave_event_callback_add(info->slave, SLAVE_EVENT_PAUSE, slave_paused_cb, info);
(void)slave_event_callback_add(info->slave, SLAVE_EVENT_RESUME, slave_resumed_cb, info);
}
info->inst_list = eina_list_append(info->inst_list, inst);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int package_del_instance(struct pkg_info *info, struct inst_info *inst)
info->inst_list = eina_list_remove(info->inst_list, inst);
if (info->inst_list) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
if (info->slave) {
slave_event_callback_del(info->slave, SLAVE_EVENT_DEACTIVATE, slave_deactivated_cb, info);
slave_event_callback_del(info->slave, SLAVE_EVENT_ACTIVATE, slave_activated_cb, info);
- if (info->secured) {
+ if (info->secured || (DBOX_IS_INHOUSE(package_abi(info)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL)) {
slave_event_callback_del(info->slave, SLAVE_EVENT_PAUSE, slave_paused_cb, info);
slave_event_callback_del(info->slave, SLAVE_EVENT_RESUME, slave_resumed_cb, info);
package_destroy(info);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI Eina_List *package_instance_list(struct pkg_info *info)
EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
if (info->fault_info) {
- fault_unicast_info(client, info->lbid, info->fault_info->filename, info->fault_info->function);
+ fault_unicast_info(client, info->dbox_id, info->fault_info->filename, info->fault_info->function);
continue;
}
*/
if (client_is_subscribed(client, instance_cluster(inst), instance_category(inst))) {
instance_unicast_created_event(inst, client);
- DbgPrint("(Subscribed) Created package: %s\n", info->lbid);
+ DbgPrint("(Subscribed) Created package: %s\n", info->dbox_id);
}
}
return 0;
}
-static int io_uninstall_cb(const char *pkgid, const char *lbid, int prime, void *data)
+static int io_uninstall_cb(const char *pkgid, const char *dbox_id, int prime, void *data)
{
struct pkg_info *info;
Eina_List *l;
Eina_List *n;
struct inst_info *inst;
- DbgPrint("Package %s is uninstalled\n", lbid);
- info = package_find(lbid);
+ DbgPrint("Package %s is uninstalled\n", dbox_id);
+ info = package_find(dbox_id);
if (!info) {
- DbgPrint("%s is not yet loaded\n", lbid);
+ DbgPrint("%s is not yet loaded\n", dbox_id);
return 0;
}
*/
if (info->inst_list) {
EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
- instance_destroy(inst, INSTANCE_DESTROY_UNINSTALL);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_UNINSTALL);
}
} else {
package_destroy(info);
DbgPrint("Already exists, try to update it\n");
- old_period = info->lb.period;
+ old_period = info->dbox.period;
- group_del_livebox(info->lbid);
+ group_del_dynamicbox(info->dbox_id);
package_clear_fault(info);
/*!
* Without "is_uninstalled", the package will be kept
*/
EINA_LIST_FOREACH_SAFE(info->inst_list, l, n, inst) {
- width = instance_lb_width(inst);
- height = instance_lb_height(inst);
- size_type = livebox_service_size_type(width, height);
- if (info->lb.size_list & size_type) {
+ width = instance_dbox_width(inst);
+ height = instance_dbox_height(inst);
+ size_type = dynamicbox_service_size_type(width, height);
+ if (info->dbox.size_list & size_type) {
if (instance_period(inst) == old_period) {
instance_reload_period(inst, package_period(info));
}
- instance_reload(inst, INSTANCE_DESTROY_UPGRADE);
+ instance_reload(inst, DBOX_DESTROY_TYPE_UPGRADE);
} else {
- instance_destroy(inst, INSTANCE_DESTROY_UNINSTALL);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_UNINSTALL);
}
}
}
-static int io_install_cb(const char *pkgid, const char *lbid, int prime, void *data)
+static int io_install_cb(const char *pkgid, const char *dbox_id, int prime, void *data)
{
struct pkg_info *info;
- info = package_find(lbid);
+ info = package_find(dbox_id);
if (info) {
/*!
* Already exists. skip to create this.
return 0;
}
- info = package_create(pkgid, lbid);
+ info = package_create(pkgid, dbox_id);
if (!info) {
- ErrPrint("Failed to build an info %s\n", lbid);
+ ErrPrint("Failed to build an info %s\n", dbox_id);
} else {
- DbgPrint("Livebox %s is built\n", lbid);
+ DbgPrint("Dynamicbox %s is built\n", dbox_id);
}
return 0;
EINA_LIST_FOREACH_SAFE(s_info.pkg_list, l, n, info) {
if (!strcmp(info->pkgid, pkgname)) {
- io_uninstall_cb(pkgname, info->lbid, -1, NULL);
+ io_uninstall_cb(pkgname, info->dbox_id, -1, NULL);
}
}
EINA_LIST_FOREACH_SAFE(s_info.pkg_list, l, n, info) {
if (!strcmp(info->pkgid, pkgname)) {
- DbgPrint("Update lbid: %s\n", info->lbid);
- if (io_is_exists(info->lbid) == 1) {
+ DbgPrint("Update dbox_id: %s\n", info->dbox_id);
+ if (io_is_exists(info->dbox_id) == 1) {
reload_package_info(info);
} else {
- io_uninstall_cb(pkgname, info->lbid, -1, NULL);
+ io_uninstall_cb(pkgname, info->dbox_id, -1, NULL);
}
}
}
- (void)io_update_livebox_package(pkgname, io_install_cb, NULL);
+ (void)io_update_dynamicbox_package(pkgname, io_install_cb, NULL);
return 0;
}
-static int crawling_liveboxes(const char *pkgid, const char *lbid, int prime, void *data)
+static int crawling_dynamicboxes(const char *pkgid, const char *dbox_id, int prime, void *data)
{
- if (package_find(lbid)) {
- ErrPrint("Information of %s is already built\n", lbid);
+ if (package_find(dbox_id)) {
+ ErrPrint("Information of %s is already built\n", dbox_id);
} else {
struct pkg_info *info;
- info = package_create(pkgid, lbid);
+ info = package_create(pkgid, dbox_id);
if (info) {
- DbgPrint("[%s] information is built prime(%d)\n", lbid, prime);
+ DbgPrint("[%s] information is built prime(%d)\n", dbox_id, prime);
}
}
pkgmgr_add_event_callback(PKGMGR_EVENT_UNINSTALL, uninstall_cb, NULL);
pkgmgr_add_event_callback(PKGMGR_EVENT_UPDATE, update_cb, NULL);
- io_crawling_liveboxes(crawling_liveboxes, NULL);
+ io_crawling_dynamicboxes(crawling_dynamicboxes, NULL);
return 0;
}
EINA_LIST_FOREACH_SAFE(s_info.pkg_list, p_l, p_n, info) {
EINA_LIST_FOREACH_SAFE(info->inst_list, i_l, i_n, inst) {
instance_state_reset(inst);
- instance_destroy(inst, INSTANCE_DESTROY_TERMINATE);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_TERMINATE);
}
package_destroy(info);
EINA_LIST_FOREACH(s_info.pkg_list, l, info) {
if (info->slave == slave) {
- return info->lbid;
+ return info->dbox_id;
}
}
HAPI const char * const package_name(const struct pkg_info *info)
{
- return info->lbid;
+ return info->dbox_id;
}
/*!
if (!instance_has_client(inst, client)) {
instance_unicast_created_event(inst, client);
instance_add_client(inst, client);
- DbgPrint("(Subscribed) Created package: %s\n", info->lbid);
+ DbgPrint("(Subscribed) Created package: %s\n", info->dbox_id);
}
break;
case ALTER_DESTROY:
if (instance_has_client(inst, client)) {
- instance_unicast_deleted_event(inst, client, LB_STATUS_SUCCESS);
+ instance_unicast_deleted_event(inst, client, DBOX_STATUS_ERROR_NONE);
instance_del_client(inst, client);
}
break;
HAPI int package_is_enabled(const char *appid)
{
- ail_appinfo_h ai;
+ pkgmgrinfo_appinfo_h handle;
bool enabled;
int ret;
- ret = ail_get_appinfo(appid, &ai);
- if (ret != AIL_ERROR_OK) {
- ErrPrint("Unable to get appinfo: %d\n", ret);
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+ if (ret != PMINFO_R_OK) {
+ ErrPrint("Failed to get info\n");
return 0;
}
- if (ail_appinfo_get_bool(ai, AIL_PROP_X_SLP_ENABLED_BOOL, &enabled) != AIL_ERROR_OK) {
+ ret = pkgmgrinfo_appinfo_is_enabled(handle, &enabled);
+ if (ret != PMINFO_R_OK) {
+ ErrPrint("Failed to get info\n");
enabled = false;
}
- ail_destroy_appinfo(ai);
-
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
return enabled == true;
}
slave = package_slave(pkg);
if (!slave) {
ErrPrint("Package has no slave?\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
/* Emulated fault routine */
DbgPrint("package: %s (forucely faulted %s)\n", package_name(pkg), slave_name(slave));
EINA_LIST_FOREACH_SAFE(pkg->inst_list, l, n, inst) {
DbgPrint("Destroy instance %p\n", inst);
- instance_destroy(inst, INSTANCE_DESTROY_FAULT);
+ instance_destroy(inst, DBOX_DESTROY_TYPE_FAULT);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* End of a file */
#include <Eina.h>
#include <dlog.h>
-#include <livebox-service.h>
-#include <livebox-errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_conf.h>
#include "util.h"
#include "debug.h"
int network;
char *auto_launch;
unsigned int size;
- unsigned int pd_width;
- unsigned int pd_height;
+ unsigned int gbar_width;
+ unsigned int gbar_height;
char *group;
int secured;
- char *pd_path;
- char *pd_group;
+ char *gbar_path;
+ char *gbar_group;
- char *lb_path;
- char *lb_group;
+ char *dbox_path;
+ char *dbox_group;
int pinup;
- int text_pd;
+ int text_gbar;
int text_lb;
- int buffer_pd;
+ int buffer_gbar;
int buffer_lb;
char *abi;
return handle->size;
}
-HAPI const char *parser_lb_path(struct parser *handle)
+HAPI const char *parser_dbox_path(struct parser *handle)
{
- return handle->lb_path;
+ return handle->dbox_path;
}
-HAPI const char *parser_lb_group(struct parser *handle)
+HAPI const char *parser_dbox_group(struct parser *handle)
{
- return handle->lb_group;
+ return handle->dbox_group;
}
-HAPI const char *parser_pd_path(struct parser *handle)
+HAPI const char *parser_gbar_path(struct parser *handle)
{
- return handle->pd_path;
+ return handle->gbar_path;
}
-HAPI const char *parser_pd_group(struct parser *handle)
+HAPI const char *parser_gbar_group(struct parser *handle)
{
- return handle->pd_group;
+ return handle->gbar_group;
}
HAPI const char *parser_group_str(struct parser *handle)
return handle->secured;
}
-HAPI void parser_get_pdsize(struct parser *handle, unsigned int *width, unsigned int *height)
+HAPI void parser_get_gbar_size(struct parser *handle, unsigned int *width, unsigned int *height)
{
- *width = handle->pd_width;
- *height = handle->pd_height;
+ *width = handle->gbar_width;
+ *height = handle->gbar_height;
}
HAPI int parser_pinup(struct parser *handle)
return handle->pinup;
}
-HAPI int parser_text_lb(struct parser *handle)
+HAPI int parser_text_dbox(struct parser *handle)
{
return handle->text_lb;
}
-HAPI int parser_text_pd(struct parser *handle)
+HAPI int parser_text_gbar(struct parser *handle)
{
- return handle->text_pd;
+ return handle->text_gbar;
}
-HAPI int parser_buffer_lb(struct parser *handle)
+HAPI int parser_buffer_dbox(struct parser *handle)
{
return handle->buffer_lb;
}
-HAPI int parser_buffer_pd(struct parser *handle)
+HAPI int parser_buffer_gbar(struct parser *handle)
{
- return handle->buffer_pd;
+ return handle->buffer_gbar;
}
HAPI RETURN_TYPE parser_find(const char *pkgname)
int len;
int ret;
- len = strlen(pkgname) * 2 + strlen(CONF_PATH);
+ len = strlen(pkgname) * 2 + strlen(DYNAMICBOX_CONF_CONF_PATH);
filename = malloc(len);
if (!filename) {
return (RETURN_TYPE)0;
}
- ret = snprintf(filename, len, CONF_PATH, pkgname, pkgname);
+ ret = snprintf(filename, len, DYNAMICBOX_CONF_CONF_PATH, pkgname, pkgname);
if (ret < 0) {
DbgFree(filename);
return (RETURN_TYPE)0;
break;
case STOP:
if (w == 1 && h == 1) {
- *size |= LB_SIZE_TYPE_1x1;
+ *size |= DBOX_SIZE_TYPE_1x1;
} else if (w == 2 && h == 1) {
- *size |= LB_SIZE_TYPE_2x1;
+ *size |= DBOX_SIZE_TYPE_2x1;
} else if (w == 2 && h == 2) {
- *size |= LB_SIZE_TYPE_2x2;
+ *size |= DBOX_SIZE_TYPE_2x2;
} else if (w == 4 && h == 1) {
- *size |= LB_SIZE_TYPE_4x1;
+ *size |= DBOX_SIZE_TYPE_4x1;
} else if (w == 4 && h == 2) {
- *size |= LB_SIZE_TYPE_4x2;
+ *size |= DBOX_SIZE_TYPE_4x2;
} else if (w == 4 && h == 3) {
- *size |= LB_SIZE_TYPE_4x3;
+ *size |= DBOX_SIZE_TYPE_4x3;
} else if (w == 4 && h == 4) {
- *size |= LB_SIZE_TYPE_4x4;
+ *size |= DBOX_SIZE_TYPE_4x4;
} else if (w == 21 && h == 21) {
- *size |= LB_SIZE_TYPE_EASY_1x1;
+ *size |= DBOX_SIZE_TYPE_EASY_1x1;
} else if (w == 23 && h == 21) {
- *size |= LB_SIZE_TYPE_EASY_3x1;
+ *size |= DBOX_SIZE_TYPE_EASY_3x1;
} else if (w == 23 && h == 23) {
- *size |= LB_SIZE_TYPE_EASY_3x3;
+ *size |= DBOX_SIZE_TYPE_EASY_3x3;
} else {
ErrPrint("Invalid size type: %dx%d\n", w, h);
}
}
}
-static void pd_size_handler(struct parser *item, char *buffer)
+static void gbar_size_handler(struct parser *item, char *buffer)
{
- if (sscanf(buffer, "%ux%u", &item->pd_width, &item->pd_height) != 2) {
+ if (sscanf(buffer, "%ux%u", &item->gbar_width, &item->gbar_height) != 2) {
ErrPrint("parse pd size\n");
}
}
-static void text_lb_handler(struct parser *item, char *buffer)
+static void text_dbox_handler(struct parser *item, char *buffer)
{
if (!rtrim(buffer)) {
return;
item->script = dup_rtrim(buffer);
}
-static void buffer_pd_handler(struct parser *item, char *buffer)
+static void buffer_gbar_handler(struct parser *item, char *buffer)
{
if (!rtrim(buffer)) {
return;
}
- item->buffer_pd = !!atoi(buffer);
+ item->buffer_gbar = !!atoi(buffer);
}
-static void buffer_lb_handler(struct parser *item, char *buffer)
+static void buffer_dbox_handler(struct parser *item, char *buffer)
{
if (!rtrim(buffer)) {
return;
item->buffer_lb = !!atoi(buffer);
}
-static void text_pd_handler(struct parser *item, char *buffer)
+static void text_gbar_handler(struct parser *item, char *buffer)
{
if (!rtrim(buffer)) {
return;
}
- item->text_pd = !!atoi(buffer);
+ item->text_gbar = !!atoi(buffer);
}
static void pinup_handler(struct parser *item, char *buffer)
item->pinup = !!atoi(buffer);
}
-static void lb_path_handler(struct parser *item, char *buffer)
+static void dbox_path_handler(struct parser *item, char *buffer)
{
- if (item->lb_path) {
- DbgFree(item->lb_path);
+ if (item->dbox_path) {
+ DbgFree(item->dbox_path);
}
- item->lb_path = dup_rtrim(buffer);
- if (!item->lb_path) {
+ item->dbox_path = dup_rtrim(buffer);
+ if (!item->dbox_path) {
ErrPrint("Error: %s\n", strerror(errno));
}
}
item->secured = !!atoi(buffer);
}
-static void lb_group_handler(struct parser *item, char *buffer)
+static void dbox_group_handler(struct parser *item, char *buffer)
{
- if (item->lb_group) {
- DbgFree(item->lb_group);
+ if (item->dbox_group) {
+ DbgFree(item->dbox_group);
}
- item->lb_group = dup_rtrim(buffer);
- if (!item->lb_group) {
+ item->dbox_group = dup_rtrim(buffer);
+ if (!item->dbox_group) {
ErrPrint("Error: %s\n", strerror(errno));
}
}
-static void pd_path_handler(struct parser *item, char *buffer)
+static void gbar_path_handler(struct parser *item, char *buffer)
{
- if (item->pd_path) {
- DbgFree(item->pd_path);
+ if (item->gbar_path) {
+ DbgFree(item->gbar_path);
}
- item->pd_path = dup_rtrim(buffer);
- if (!item->pd_path) {
+ item->gbar_path = dup_rtrim(buffer);
+ if (!item->gbar_path) {
ErrPrint("Error: %s\n", strerror(errno));
}
}
-static void pd_group_handler(struct parser *item, char *buffer)
+static void gbar_group_handler(struct parser *item, char *buffer)
{
- if (item->pd_group) {
- DbgFree(item->pd_group);
+ if (item->gbar_group) {
+ DbgFree(item->gbar_group);
}
- item->pd_group = dup_rtrim(buffer);
- if (!item->pd_group) {
+ item->gbar_group = dup_rtrim(buffer);
+ if (!item->gbar_group) {
ErrPrint("Error: %s\n", strerror(errno));
}
}
.handler = secured_handler,
},
{
- .name = "livebox_path",
- .handler = lb_path_handler,
+ .name = "dynamicbox_path",
+ .handler = dbox_path_handler,
},
{
- .name = "livebox_group",
- .handler = lb_group_handler,
+ .name = "dynamicbox_group",
+ .handler = dbox_group_handler,
},
{
- .name = "pd_path",
- .handler = pd_path_handler,
+ .name = "gbar_path",
+ .handler = gbar_path_handler,
},
{
- .name = "pd_group",
- .handler = pd_group_handler,
+ .name = "gbar_group",
+ .handler = gbar_group_handler,
},
{
- .name = "pd_size",
- .handler = pd_size_handler,
+ .name = "gbar_size",
+ .handler = gbar_size_handler,
},
{
.name = "pinup",
.handler = pinup_handler,
},
{
- .name = "text_livebox",
- .handler = text_lb_handler,
+ .name = "text_dynamicbox",
+ .handler = text_dbox_handler,
},
{
- .name = "text_pd",
- .handler = text_pd_handler,
+ .name = "text_gbar",
+ .handler = text_gbar_handler,
},
{
- .name = "buffer_livebox",
- .handler = buffer_lb_handler,
+ .name = "buffer_dynamicbox",
+ .handler = buffer_dbox_handler,
},
{
- .name = "buffer_pd",
- .handler = buffer_pd_handler,
+ .name = "buffer_gbar",
+ .handler = buffer_gbar_handler,
},
{
.name = "script",
}
/* live-, .conf */
- len = strlen(CONF_PATH) + strlen(pkgname) * 2;
+ len = strlen(DYNAMICBOX_CONF_CONF_PATH) + strlen(pkgname) * 2;
item->filename = malloc(len);
if (!item->filename) {
ErrPrint("Error: %s\n", strerror(errno));
return 0;
}
- ret = snprintf(item->filename, len, CONF_PATH, pkgname, pkgname);
+ ret = snprintf(item->filename, len, DYNAMICBOX_CONF_CONF_PATH, pkgname, pkgname);
if (ret < 0) {
ErrPrint("Error: %s\n", strerror(errno));
DbgFree(item->filename);
return 0;
}
- item->lb_path = NULL;
- item->lb_group = NULL;
- item->pd_width = 0;
- item->pd_height = 0;
+ item->dbox_path = NULL;
+ item->dbox_group = NULL;
+ item->gbar_width = 0;
+ item->gbar_height = 0;
item->auto_launch = NULL;
item->size = 0x00000001;
item->group = NULL;
}
linelen++;
- } while (c != EOF);
+ } while (c != EOF);
if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
DbgFree(item->abi);
DbgFree(item->script);
DbgFree(item->group);
- DbgFree(item->pd_group);
- DbgFree(item->pd_path);
- DbgFree(item->lb_group);
- DbgFree(item->lb_path);
+ DbgFree(item->gbar_group);
+ DbgFree(item->gbar_path);
+ DbgFree(item->dbox_group);
+ DbgFree(item->dbox_path);
DbgFree(item->filename);
DbgFree(item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* End of a file */
#include <dlog.h>
#include <package-manager.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#include <Ecore.h>
#include "util.h"
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->pkgname = strdup(pkgname);
if (!item->pkgname) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(item);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
item->status = PKGMGR_STATUS_START;
DbgFree(item->pkgname);
DbgFree(item);
ErrPrint("Invalid val: %s\n", val);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
s_info.item_list = eina_list_append(s_info.item_list, item);
invoke_callback(pkgname, item, 0.0f);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int icon_path_cb(const char *pkgname, const char *val, void *data)
item = find_item(pkgname);
if (!item) {
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
if (item->icon) {
item->icon = strdup(val);
if (!item->icon) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int command_cb(const char *pkgname, const char *val, void *data)
item = find_item(pkgname);
if (!item) {
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
if (!is_valid_status(item, val)) {
DbgPrint("Invalid status: %d, %s\n", item->type, val);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
item->status = PKGMGR_STATUS_COMMAND;
invoke_callback(pkgname, item, 0.0f);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int error_cb(const char *pkgname, const char *val, void *data)
item = find_item(pkgname);
if (!item) {
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
item->status = PKGMGR_STATUS_ERROR;
invoke_callback(pkgname, item, 0.0f);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int change_pkgname_cb(const char *pkgname, const char *val, void *data)
item = find_item(pkgname);
if (!item) {
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
new_pkgname = strdup(val);
if (!new_pkgname) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
DbgFree(item->pkgname);
item->pkgname = new_pkgname;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int download_cb(const char *pkgname, const char *val, void *data)
item = find_item(pkgname);
if (!item) {
DbgPrint("ITEM is not started from the start_cb\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (item->type != PKGMGR_EVENT_DOWNLOAD) {
break;
default:
ErrPrint("Invalid state [%s, %s]\n", pkgname, val);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (val) {
if (sscanf(val, "%lf", &value) != 1) {
- value = (double)LB_STATUS_ERROR_INVALID;
+ value = (double)DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
} else {
- value = (double)LB_STATUS_ERROR_INVALID;
+ value = (double)DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
invoke_download_event_handler(pkgname, item->status, value);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int progress_cb(const char *pkgname, const char *val, void *data)
item = find_item(pkgname);
if (!item) {
ErrPrint("ITEM is not started from the start_cb\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
switch (item->status) {
break;
default:
ErrPrint("Invalid state [%s, %s]\n", pkgname, val);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (val) {
if (sscanf(val, "%lf", &value) != 1) {
- value = (double)LB_STATUS_ERROR_INVALID;
+ value = (double)DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
} else {
- value = (double)LB_STATUS_ERROR_INVALID;
+ value = (double)DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
invoke_callback(pkgname, item, value);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static int end_cb(const char *pkgname, const char *val, void *data)
item = find_item(pkgname);
if (!item) {
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
item->status = !strcasecmp(val, "ok") ? PKGMGR_STATUS_END : PKGMGR_STATUS_ERROR;
DbgFree(item->icon);
DbgFree(item->pkgname);
DbgFree(item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static struct pkgmgr_handler {
ret = handler[i].func(pkgname, val, data);
if (ret < 0) {
DbgPrint("REQ[%d] pkgname[%s], type[%s], key[%s], val[%s], ret = %d\n",
- req_id, pkgname, type, key, val, ret);
+ req_id, pkgname, type, key, val, ret);
}
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int pkgmgr_init(void)
{
if (s_info.listen_pc) {
- return LB_STATUS_ERROR_ALREADY;
+ return DBOX_STATUS_ERROR_ALREADY;
}
s_info.listen_pc = pkgmgr_client_new(PC_LISTENING);
if (!s_info.listen_pc) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (pkgmgr_client_listen_status(s_info.listen_pc, pkgmgr_cb, NULL) != PKGMGR_R_OK) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int pkgmgr_fini(void)
struct item *ctx;
if (!s_info.listen_pc) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (pkgmgr_client_free(s_info.listen_pc) != PKGMGR_R_OK) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
s_info.listen_pc = NULL;
DbgFree(ctx);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int pkgmgr_add_event_callback(enum pkgmgr_event_type type, int (*cb)(const char *pkgname, enum pkgmgr_status status, double value, void *data), void *data)
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->cb = cb;
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 void *pkgmgr_del_event_callback(enum pkgmgr_event_type type, int (*cb)(const char *pkgname, enum pkgmgr_status status, double value, void *data), void *data)
#include <dlog.h>
#include <packet.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_conf.h>
#include "slave_life.h"
#include "slave_rpc.h"
static struct info {
Eina_List *script_port_list;
- enum buffer_type env_buf_type;
+ enum dynamicbox_fb_type env_buf_type;
} s_info = {
.script_port_list = NULL,
- .env_buf_type = BUFFER_TYPE_FILE,
+ .env_buf_type = DBOX_FB_TYPE_FILE,
};
struct script_port {
char *path;
int pathlen;
- dir = opendir(SCRIPT_PORT_PATH);
+ dir = opendir(DYNAMICBOX_CONF_SCRIPT_PORT_PATH);
if (!dir) {
ErrPrint("Error: %s\n", strerror(errno));
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
while ((ent = readdir(dir))) {
continue;
}
- pathlen = strlen(ent->d_name) + strlen(SCRIPT_PORT_PATH) + 1;
+ pathlen = strlen(ent->d_name) + strlen(DYNAMICBOX_CONF_SCRIPT_PORT_PATH) + 1;
path = malloc(pathlen);
if (!path) {
ErrPrint("Heap: %s %d\n", strerror(errno), pathlen);
if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
}
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
- snprintf(path, pathlen, "%s%s", SCRIPT_PORT_PATH, ent->d_name);
+ snprintf(path, pathlen, "%s%s", DYNAMICBOX_CONF_SCRIPT_PORT_PATH, ent->d_name);
item = malloc(sizeof(*item));
if (!item) {
if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
}
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
DbgPrint("Open SCRIPT PORT: %s\n", path);
if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
}
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
item->magic_id = dlsym(item->handle, "script_magic_id");
goto errout;
}
- if (item->init(SCALE_WIDTH_FACTOR, PREMULTIPLIED_COLOR) < 0) {
+ if (item->init(DYNAMICBOX_CONF_SCALE_WIDTH_FACTOR, DYNAMICBOX_CONF_PREMULTIPLIED_COLOR) < 0) {
ErrPrint("Failed to initialize script engine\n");
goto errout;
}
ErrPrint("closedir: %s\n", strerror(errno));
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
errout:
ErrPrint("Error: %s\n", dlerror());
if (closedir(dir) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
}
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
static inline struct script_port *find_port(const char *magic_id)
if (instance_state(inst) != INST_ACTIVATED) {
ErrPrint("Render post invoked but instance is not activated\n");
PERF_MARK(__func__);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- info = instance_lb_script(inst);
+ info = instance_dbox_script(inst);
if (info && info == data) {
buffer_handler_flush(buffer_handle);
- instance_lb_updated_by_instance(inst, NULL);
+ instance_dbox_updated_by_instance(inst, NULL, info->x, info->y, info->w, info->h);
PERF_MARK("lb,update");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
- info = instance_pd_script(inst);
+ info = instance_gbar_script(inst);
if (info && info == data) {
buffer_handler_flush(buffer_handle);
- instance_pd_updated_by_instance(inst, NULL);
+ instance_gbar_updated_by_instance(inst, NULL, info->x, info->y, info->w, info->h);
PERF_MARK("pd,update");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
out:
ErrPrint("Failed to sync\n");
PERF_MARK(__func__);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
/*!
if (!buffer_handle) {
ErrPrint("Invalid handle\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
info = buffer_handler_data(buffer_handle);
if (!info) {
ErrPrint("Invalid handle\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
inst = buffer_handler_instance(buffer_handle);
if (!inst) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (!signal || strlen(signal) == 0) {
return;
}
- is_pd = instance_pd_script(inst) == info;
+ is_pd = instance_gbar_script(inst) == info;
EINA_LIST_FREE(info->cached_blocks, block) {
consuming_parsed_block(inst, is_pd, block);
if (!info || !info->port) {
ErrPrint("Script handler is not created\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (info->loaded > 0) {
info->loaded++;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
if (info->port->load(info->port_data, NULL, render_post_cb, info) < 0) {
ErrPrint("Unable to load the script\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
info->loaded = 1;
inst = buffer_handler_instance(info->buffer_handle);
if (inst) {
script_signal_emit(info->buffer_handle, instance_id(inst),
- is_pd ? "pd,show" : "lb,show", 0.0f, 0.0f, 0.0f, 0.0f);
+ is_pd ? "gbar,show" : "dbox,show", 0.0f, 0.0f, 0.0f, 0.0f);
}
buffer_handler_flush(info->buffer_handle);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int script_handler_unload(struct script_info *info, int is_pd)
struct inst_info *inst;
if (!info || !info->port) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
info->loaded--;
if (info->loaded > 0) {
- return LB_STATUS_ERROR_BUSY;
+ return DBOX_STATUS_ERROR_BUSY;
}
if (info->loaded < 0) {
info->loaded = 0;
- return LB_STATUS_ERROR_ALREADY;
+ return DBOX_STATUS_ERROR_ALREADY;
}
inst = buffer_handler_instance(info->buffer_handle);
if (inst) {
script_signal_emit(info->buffer_handle, instance_id(inst),
- is_pd ? "pd,hide" : "lb,hide", 0.0f, 0.0f, 0.0f, 0.0f);
+ is_pd ? "gbar,hide" : "dbox,hide", 0.0f, 0.0f, 0.0f, 0.0f);
}
if (info->port->unload(info->port_data) < 0) {
ErrPrint("Failed to unload script object. but go ahead\n");
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI struct script_info *script_handler_create(struct inst_info *inst, const char *file, const char *option, int w, int h)
return NULL;
}
- info->buffer_handle = buffer_handler_create(inst, s_info.env_buf_type, w, h, DEFAULT_PIXELS);
+ info->buffer_handle = buffer_handler_create(inst, s_info.env_buf_type, w, h, DYNAMICBOX_CONF_DEFAULT_PIXELS);
if (!info->buffer_handle) {
/* buffer_handler_create will prints some log */
DbgFree(info);
info->port = find_port(package_script(instance_package(inst)));
if (!info->port) {
ErrPrint("Failed to find a proper port for [%s]%s\n",
- instance_package(inst), package_script(instance_package(inst)));
+ instance_package(inst), package_script(instance_package(inst)));
buffer_handler_destroy(info->buffer_handle);
DbgFree(info);
return NULL;
if (!info || !info->port) {
ErrPrint("port is not valid\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (info->loaded != 0) {
ErrPrint("Script handler is not unloaded\n");
- return LB_STATUS_ERROR_BUSY;
+ return DBOX_STATUS_ERROR_BUSY;
}
ret = info->port->destroy(info->port_data);
}
DbgFree(info);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int script_handler_is_loaded(struct script_info *info)
if (!block || !block->part || !block->data) {
ErrPrint("Block or part or data is not valid\n");
PERF_MARK("color");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
if (!info) {
ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
PERF_MARK("color");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (!info->port) {
ErrPrint("info->port is NIL (%d, %s)\n", is_pd, instance_id(inst));
PERF_MARK("color");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ret = info->port->update_color(info->port_data, block->id, block->part, block->data);
if (!block || !block->part || !block->data) {
ErrPrint("Block or part or data is not valid\n");
PERF_MARK("text");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
if (!info) {
ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
PERF_MARK("text");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (!info->port) {
ErrPrint("info->port is NIL\n");
PERF_MARK("text");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
DbgPrint("[%s] %s (%s)\n", block->id, block->part, block->data);
ret = info->port->update_text(info->port_data, block->id, block->part, block->data);
-
+
PERF_MARK("text");
return ret;
}
if (!block || !block->part) {
ErrPrint("Block or part is not valid\n");
PERF_MARK("image");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
if (!info) {
ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
PERF_MARK("image");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (!info->port) {
ErrPrint("info->port is NIL\n");
PERF_MARK("image");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
DbgPrint("[%s] %s (%s)\n", block->id, block->part, block->data);
if (!block || !block->part) {
ErrPrint("Block or block->part is NIL\n");
PERF_MARK("access");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
if (!info) {
ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
PERF_MARK("access");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (!info->port) {
ErrPrint("info->port is NIL\n");
PERF_MARK("access");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ret = info->port->update_access(info->port_data, block->id, block->part, block->data, block->option);
if (!block || !block->part) {
ErrPrint("Block or block->part is NIL\n");
PERF_MARK("operate_access");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
if (!info) {
ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
PERF_MARK("operate_access");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (!info->port) {
ErrPrint("info->port is NIL\n");
PERF_MARK("operate_access");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ret = info->port->operate_access(info->port_data, block->id, block->part, block->data, block->option);
if (!block || !block->part) {
ErrPrint("Block or part is NIL\n");
PERF_MARK("script");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
if (!info) {
ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
PERF_MARK("script");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (!info->port) {
ErrPrint("info->port is NIL\n");
PERF_MARK("script");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ret = info->port->update_script(info->port_data, block->id, block->target, block->part, block->data, block->option);
if (!block) {
ErrPrint("block is NIL\n");
PERF_MARK("signal");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
if (!info) {
ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
PERF_MARK("signal");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (!info->port) {
ErrPrint("info->port is NIL\n");
PERF_MARK("signal");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ret = info->port->update_signal(info->port_data, block->id, block->part, block->data);
if (!block || !block->data || !block->part) {
ErrPrint("block or block->data or block->part is NIL\n");
PERF_MARK("drag");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
if (!info) {
ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
PERF_MARK("drag");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (sscanf(block->data, "%lfx%lf", &dx, &dy) != 2) {
ErrPrint("Invalid format of data (DRAG data [%s])\n", block->data);
PERF_MARK("drag");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (!info->port) {
ErrPrint("info->port is NIL\n");
PERF_MARK("drag");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ret = info->port->update_drag(info->port_data, block->id, block->part, dx, dy);
(void)info->port->update_size(info->port_data, NULL, w, h);
}
- if (instance_lb_script(inst) == info) {
- instance_set_lb_size(inst, w, h);
- } else if (instance_pd_script(inst) == info) {
- instance_set_pd_size(inst, w, h);
+ if (instance_dbox_script(inst) == info) {
+ instance_set_dbox_size(inst, w, h);
+ } else if (instance_gbar_script(inst) == info) {
+ instance_set_gbar_size(inst, w, h);
} else {
ErrPrint("Unknown script\n");
}
if (!info) {
ErrPrint("info[%p] resize is ignored\n", info);
PERF_MARK("resize");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
inst = buffer_handler_instance(info->buffer_handle);
if (!inst) {
ErrPrint("Instance is not valid\n");
PERF_MARK("resize");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
update_size_for_script(info, inst, w, h);
PERF_MARK("resize");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI const char *script_handler_buffer_id(struct script_info *info)
if (!block || !block->part || !block->data) {
ErrPrint("block or block->part or block->data is NIL\n");
PERF_MARK("info");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
if (!info) {
ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
PERF_MARK("info");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (!info->port) {
ErrPrint("info->port is NIL\n");
PERF_MARK("info");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (!strcasecmp(block->part, INFO_SIZE)) {
if (sscanf(block->data, "%dx%d", &w, &h) != 2) {
ErrPrint("Invalid format for SIZE(%s)\n", block->data);
PERF_MARK("info");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (!block->id) {
}
PERF_MARK("info");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline void consuming_parsed_block(struct inst_info *inst, int is_pd, struct block *block)
NULL
};
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
if (!info) {
ErrPrint("info is NIL (%d, %s)\n", is_pd, instance_id(inst));
goto free_out;
HAPI int script_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;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int script_fini(void)
HAPI int script_handler_update_pointer(struct script_info *info, int x, int y, int down)
{
if (!info) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
info->x = x;
info->down = 1;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int script_handler_update_keycode(struct script_info *info, unsigned int keycode)
{
if (!info) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
info->keycode = keycode;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int script_handler_feed_event(struct script_info *info, int event, double timestamp)
if (!info->port) {
ErrPrint("info->port is NIL\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ret = info->port->feed_event(info->port_data, event, info->x, info->y, info->down, info->keycode, timestamp);
}
#endif
-
HAPI int script_handler_parse_desc(struct inst_info *inst, const char *filename, int is_pd)
{
PERF_INIT();
filebuf = load_file(filename);
if (!filebuf) {
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
fileptr = filebuf;
case DONE:
if (isspace(*fileptr)) {
} else if (*fileptr == '}') {
- state = BEGIN;
- block->filename = filename;
- block_list = eina_list_append(block_list, block);
- block = NULL;
+ state = BEGIN;
+ block->filename = filename;
+ block_list = eina_list_append(block_list, block);
+ block = NULL;
} else {
state = FIELD;
continue;
}
PERF_MARK("parser");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
block = eina_list_data_get(eina_list_last(block_list));
/*!
* Doesn't need to force to render the contents.
- struct script_info *info;
- info = is_pd ? instance_pd_script(inst) : instance_lb_script(inst);
- if (info && info->ee) {
- ecore_evas_manual_render(info->ee);
- }
- */
+ struct script_info *info;
+ info = is_pd ? instance_gbar_script(inst) : instance_dbox_script(inst);
+ if (info && info->ee) {
+ ecore_evas_manual_render(info->ee);
+ }
+ */
#endif
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* End of a file */
#include <unistd.h>
#include <errno.h>
+#include <sys/smack.h>
+
#include <dlog.h>
#include <aul.h>
#include <Ecore.h>
#include <packet.h>
#include <com-core_packet.h>
-#include <livebox-errno.h>
-#include <livebox-service.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_cmd_list.h>
+#include <dynamicbox_conf.h>
+#include <dynamicbox_script.h>
#include "critical_log.h"
#include "conf.h"
#include "io.h"
#include "event.h"
-#define PD_OPEN_MONITOR_TAG "pd,open,monitor"
-#define PD_RESIZE_MONITOR_TAG "pd,resize,monitor"
-#define PD_CLOSE_MONITOR_TAG "pd,close,monitor"
+#define GBAR_OPEN_MONITOR_TAG "gbar,open,monitor"
+#define GBAR_RESIZE_MONITOR_TAG "gbar,resize,monitor"
+#define GBAR_CLOSE_MONITOR_TAG "gbar,close,monitor"
+
+#define LAZY_GBAR_OPEN_TAG "lazy,gbar,open"
+#define LAZY_GBAR_CLOSE_TAG "lazy,gbar,close"
-#define LAZY_PD_OPEN_TAG "lazy,pd,open"
-#define LAZY_PD_CLOSE_TAG "lazy,pd,close"
+#define ACCESS_TYPE_DOWN 0
+#define ACCESS_TYPE_MOVE 1
+#define ACCESS_TYPE_UP 2
+#define ACCESS_TYPE_CUR 0
+#define ACCESS_TYPE_NEXT 1
+#define ACCESS_TYPE_PREV 2
+#define ACCESS_TYPE_OFF 3
static struct info {
int info_fd;
.remote_client_fd = -1,
};
+struct access_info {
+ int x;
+ int y;
+ int type;
+};
+
/* Share this with provider */
enum target_type {
- TYPE_LB,
- TYPE_PD,
+ TYPE_DBOX,
+ TYPE_GBAR,
TYPE_ERROR
};
struct inst_info *inst;
};
-static int forward_lb_event_packet(const struct pkg_info *pkg, struct inst_info *inst, const struct packet *packet)
+static Eina_Bool lazy_key_status_cb(void *data)
+{
+ struct event_cbdata *cbdata = data;
+
+ if (instance_unref(cbdata->inst)) {
+ instance_send_key_status(cbdata->inst, cbdata->status);
+ } else {
+ DbgPrint("Skip sending key status (%d)\n", cbdata->status);
+ }
+ /*!
+ * If instance_unref returns NULL,
+ * The instance is destroyed. it means, we don't need to send event to the viewer
+ */
+ DbgFree(cbdata);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool lazy_access_status_cb(void *data)
+{
+ struct event_cbdata *cbdata = data;
+
+ if (instance_unref(cbdata->inst)) {
+ instance_send_access_status(cbdata->inst, cbdata->status);
+ } else {
+ DbgPrint("Skip sending access status (%d)\n", cbdata->status);
+ }
+ /*!
+ * If instance_unref returns NULL,
+ * The instance is destroyed. it means, we don't need to send event to the viewer
+ */
+ DbgFree(cbdata);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+int send_delayed_key_status(struct inst_info *inst, int ret)
+{
+ struct event_cbdata *cbdata;
+
+ cbdata = malloc(sizeof(*cbdata));
+ if (!cbdata) {
+ ret = DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ } else {
+ cbdata->inst = instance_ref(inst);
+ cbdata->status = ret;
+
+ if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
+ (void)instance_unref(cbdata->inst);
+ DbgFree(cbdata);
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else {
+ ret = DBOX_STATUS_ERROR_NONE;
+ }
+ }
+
+ return ret;
+}
+
+int send_delayed_access_status(struct inst_info *inst, int ret)
+{
+ struct event_cbdata *cbdata;
+
+ cbdata = malloc(sizeof(*cbdata));
+ if (!cbdata) {
+ ret = DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ } else {
+ cbdata->inst = instance_ref(inst);
+ cbdata->status = ret;
+
+ if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
+ (void)instance_unref(cbdata->inst);
+ DbgFree(cbdata);
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else {
+ ret = DBOX_STATUS_ERROR_NONE;
+ }
+ }
+
+ return ret;
+}
+
+static int forward_dbox_event_packet(const struct pkg_info *pkg, struct inst_info *inst, const struct packet *packet)
{
struct buffer_info *buffer;
struct slave_node *slave;
int ret;
- buffer = instance_lb_buffer(inst);
+ buffer = instance_dbox_buffer(inst);
if (!buffer) {
ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
slave = package_slave(pkg);
if (!slave) {
ErrPrint("Package[%s] has no slave\n", package_name(pkg));
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
return ret;
}
-static int forward_pd_event_packet(const struct pkg_info *pkg, struct inst_info *inst, const struct packet *packet)
+static int forward_gbar_event_packet(const struct pkg_info *pkg, struct inst_info *inst, const struct packet *packet)
{
struct buffer_info *buffer;
struct slave_node *slave;
int ret;
- buffer = instance_pd_buffer(inst);
+ buffer = instance_gbar_buffer(inst);
if (!buffer) {
ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
slave = package_slave(pkg);
if (!slave) {
ErrPrint("Package[%s] has no slave\n", package_name(pkg));
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
return ret;
}
-static int forward_pd_access_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, int x, int y)
+static int forward_gbar_access_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, struct access_info *event)
{
int ret;
struct buffer_info *buffer;
struct slave_node *slave;
struct packet *p;
- buffer = instance_pd_buffer(inst);
+ buffer = instance_gbar_buffer(inst);
if (!buffer) {
ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
slave = package_slave(pkg);
if (!slave) {
ErrPrint("Package[%s] has no slave\n", package_name(pkg));
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
- p = packet_create_noack(command, "ssdii", package_name(pkg), instance_id(inst), timestamp, x, y);
+ p = packet_create_noack(command, "ssdiii", package_name(pkg), instance_id(inst), timestamp, event->x, event->y, event->type);
ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
out:
return ret;
}
-static int forward_lb_access_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, int x, int y)
+static int forward_dbox_access_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, struct access_info *event)
{
int ret;
struct buffer_info *buffer;
struct slave_node *slave;
struct packet *p;
- buffer = instance_lb_buffer(inst);
+ buffer = instance_dbox_buffer(inst);
if (!buffer) {
ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
slave = package_slave(pkg);
if (!slave) {
ErrPrint("Package[%s] has no slave\n", package_name(pkg));
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
- p = packet_create_noack(command, "ssdii", package_name(pkg), instance_id(inst), timestamp, x, y);
+ p = packet_create_noack(command, "ssdiii", package_name(pkg), instance_id(inst), timestamp, event->x, event->y, event->type);
ret = slave_rpc_request_only(slave, package_name(pkg), p, 0);
out:
return ret;
}
-static int forward_pd_key_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, unsigned int keycode)
+static int forward_gbar_key_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, unsigned int keycode)
{
int ret;
struct buffer_info *buffer;
struct slave_node *slave;
struct packet *p;
- buffer = instance_lb_buffer(inst);
+ buffer = instance_dbox_buffer(inst);
if (!buffer) {
ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
slave = package_slave(pkg);
if (!slave) {
ErrPrint("Package[%s] has no slave\n", package_name(pkg));
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
return ret;
}
-static int forward_lb_key_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, unsigned int keycode)
+static int forward_dbox_key_packet(const struct pkg_info *pkg, struct inst_info *inst, const char *command, double timestamp, unsigned int keycode)
{
int ret;
struct buffer_info *buffer;
struct slave_node *slave;
struct packet *p;
- buffer = instance_lb_buffer(inst);
+ buffer = instance_dbox_buffer(inst);
if (!buffer) {
ErrPrint("Instance[%s] has no buffer\n", instance_id(inst));
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
slave = package_slave(pkg);
if (!slave) {
ErrPrint("Package[%s] has no slave\n", package_name(pkg));
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
return ret;
}
-static Eina_Bool lazy_key_status_cb(void *data)
-{
- struct event_cbdata *cbdata = data;
-
- if (instance_unref(cbdata->inst)) {
- instance_send_key_status(cbdata->inst, cbdata->status);
- } else {
- DbgPrint("Skip sending key status (%d)\n", cbdata->status);
- }
- /*!
- * If instance_unref returns NULL,
- * The instance is destroyed. it means, we don't need to send event to the viewer
- */
- DbgFree(cbdata);
- return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool lazy_access_status_cb(void *data)
-{
- struct event_cbdata *cbdata = data;
-
- if (instance_unref(cbdata->inst)) {
- instance_send_access_status(cbdata->inst, cbdata->status);
- } else {
- DbgPrint("Skip sending access status (%d)\n", cbdata->status);
- }
- /*!
- * If instance_unref returns NULL,
- * The instance is destroyed. it means, we don't need to send event to the viewer
- */
- DbgFree(cbdata);
- return ECORE_CALLBACK_CANCEL;
-}
-
static int slave_fault_open_script_cb(struct slave_node *slave, void *data)
{
Ecore_Timer *timer;
- (void)script_handler_unload(instance_pd_script(data), 1);
- (void)instance_slave_close_pd(data, instance_pd_owner(data), LB_CLOSE_PD_FAULT);
- (void)instance_client_pd_created(data, LB_STATUS_ERROR_FAULT);
+ (void)script_handler_unload(instance_gbar_script(data), 1);
+ (void)instance_slave_close_gbar(data, instance_gbar_owner(data), DBOX_CLOSE_GBAR_FAULT);
+ (void)instance_client_gbar_created(data, DBOX_STATUS_ERROR_FAULT);
- timer = instance_del_data(data, LAZY_PD_OPEN_TAG);
+ timer = instance_del_data(data, LAZY_GBAR_OPEN_TAG);
if (timer) {
ecore_timer_del(timer);
}
{
Ecore_Timer *timer;
- (void)instance_slave_close_pd(data, instance_pd_owner(data), LB_CLOSE_PD_FAULT);
- (void)instance_client_pd_created(data, LB_STATUS_ERROR_FAULT);
+ (void)instance_slave_close_gbar(data, instance_gbar_owner(data), DBOX_CLOSE_GBAR_FAULT);
+ (void)instance_client_gbar_created(data, DBOX_STATUS_ERROR_FAULT);
- timer = instance_del_data(data, PD_OPEN_MONITOR_TAG);
+ timer = instance_del_data(data, GBAR_OPEN_MONITOR_TAG);
if (timer) {
ecore_timer_del(timer);
}
{
Ecore_Timer *timer;
- (void)instance_client_pd_destroyed(data, LB_STATUS_ERROR_FAULT);
+ (void)instance_client_gbar_destroyed(data, DBOX_STATUS_ERROR_FAULT);
- timer = instance_del_data(data, LAZY_PD_CLOSE_TAG);
+ timer = instance_del_data(data, LAZY_GBAR_CLOSE_TAG);
if (timer) {
ecore_timer_del(timer);
}
{
Ecore_Timer *timer;
- (void)instance_client_pd_destroyed(data, LB_STATUS_ERROR_FAULT);
+ (void)instance_client_gbar_destroyed(data, DBOX_STATUS_ERROR_FAULT);
- timer = instance_del_data(data, LAZY_PD_CLOSE_TAG);
+ timer = instance_del_data(data, LAZY_GBAR_CLOSE_TAG);
if (!timer) {
- timer = instance_del_data(data, PD_CLOSE_MONITOR_TAG);
+ timer = instance_del_data(data, GBAR_CLOSE_MONITOR_TAG);
}
if (timer) {
{
Ecore_Timer *timer;
- (void)instance_slave_close_pd(data, instance_pd_owner(data), LB_CLOSE_PD_FAULT);
- (void)instance_client_pd_destroyed(data, LB_STATUS_ERROR_FAULT);
+ (void)instance_slave_close_gbar(data, instance_gbar_owner(data), DBOX_CLOSE_GBAR_FAULT);
+ (void)instance_client_gbar_destroyed(data, DBOX_STATUS_ERROR_FAULT);
- timer = instance_del_data(data, PD_RESIZE_MONITOR_TAG);
+ timer = instance_del_data(data, GBAR_RESIZE_MONITOR_TAG);
if (timer) {
ecore_timer_del(timer);
}
return -1; /* remove this handler */
}
-static int key_event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
+static int key_event_dbox_route_cb(enum event_state state, struct event_data *event_info, void *data)
{
struct inst_info *inst = data;
const struct pkg_info *pkg;
struct slave_node *slave;
struct packet *packet;
- const char *cmdstr;
+ unsigned int cmd;
+
+ if (!inst) {
+ DbgPrint("Instance is deleted.\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
pkg = instance_package(inst);
if (!pkg) {
- 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;
}
switch (state) {
case EVENT_STATE_ACTIVATE:
- cmdstr = "lb_key_down";
+ cmd = CMD_DBOX_KEY_DOWN;
break;
case EVENT_STATE_ACTIVATED:
- cmdstr = "lb_key_down";
+ cmd = CMD_DBOX_KEY_DOWN;
break;
case EVENT_STATE_DEACTIVATE:
- cmdstr = "lb_key_up";
+ cmd = CMD_DBOX_KEY_UP;
break;
default:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack(cmdstr, "ssdi", package_name(pkg), instance_id(inst), util_timestamp(), event_info->keycode);
+ packet = packet_create_noack((const char *)&cmd, "ssdi", package_name(pkg), instance_id(inst), event_info->tv, event_info->keycode);
if (!packet) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
}
-static int mouse_event_lb_route_cb(enum event_state state, struct event_data *event_info, void *data)
+static int mouse_event_dbox_route_cb(enum event_state state, struct event_data *event_info, void *data)
{
struct inst_info *inst = data;
const struct pkg_info *pkg;
struct slave_node *slave;
struct packet *packet;
- const char *cmdstr;
+ unsigned int cmd;
+
+ if (!inst) {
+ DbgPrint("Instance is deleted.\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
pkg = instance_package(inst);
if (!pkg) {
- 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;
}
switch (state) {
case EVENT_STATE_ACTIVATE:
- cmdstr = "lb_mouse_down";
+ cmd = CMD_DBOX_MOUSE_DOWN;
break;
case EVENT_STATE_ACTIVATED:
- cmdstr = "lb_mouse_move";
+ cmd = CMD_DBOX_MOUSE_MOVE;
break;
case EVENT_STATE_DEACTIVATE:
- cmdstr = "lb_mouse_up";
+ cmd = CMD_DBOX_MOUSE_UP;
break;
default:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
+ packet = packet_create_noack((const char *)&cmd, "ssdii", package_name(pkg), instance_id(inst), event_info->tv, event_info->x, event_info->y);
if (!packet) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
}
-static int key_event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+static int key_event_dbox_consume_cb(enum event_state state, struct event_data *event_info, void *data)
{
struct script_info *script;
struct inst_info *inst = data;
return 0;
}
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- timestamp = util_timestamp();
+ timestamp = event_info->tv;
switch (state) {
case EVENT_STATE_ACTIVATE:
script_handler_update_keycode(script, event_info->keycode);
- (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_KEY_DOWN, timestamp);
break;
case EVENT_STATE_ACTIVATED:
script_handler_update_keycode(script, event_info->keycode);
- (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_KEY_DOWN, timestamp);
break;
case EVENT_STATE_DEACTIVATE:
script_handler_update_keycode(script, event_info->keycode);
- (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_UP, timestamp);
break;
default:
ErrPrint("Unknown event\n");
return 0;
}
-static int mouse_event_lb_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+static int mouse_event_dbox_consume_cb(enum event_state state, struct event_data *event_info, void *data)
{
struct script_info *script;
struct inst_info *inst = data;
return 0;
}
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- timestamp = util_timestamp();
+ timestamp = event_info->tv;
switch (state) {
case EVENT_STATE_ACTIVATE:
script_handler_update_pointer(script, event_info->x, event_info->y, 1);
- (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_DOWN, timestamp);
break;
case EVENT_STATE_ACTIVATED:
script_handler_update_pointer(script, event_info->x, event_info->y, -1);
- (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_MOVE, timestamp);
break;
case EVENT_STATE_DEACTIVATE:
script_handler_update_pointer(script, event_info->x, event_info->y, 0);
- (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_UP, timestamp);
break;
default:
break;
return 0;
}
-static int key_event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
+static int key_event_gbar_route_cb(enum event_state state, struct event_data *event_info, void *data)
{
struct inst_info *inst = data;
const struct pkg_info *pkg;
struct slave_node *slave;
struct packet *packet;
- const char *cmdstr;
+ unsigned int cmd;
+
+ if (!inst) {
+ DbgPrint("Instance is deleted.\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
pkg = instance_package(inst);
if (!pkg) {
- 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;
}
switch (state) {
case EVENT_STATE_ACTIVATE:
- cmdstr = "pd_key_down";
+ cmd = CMD_GBAR_KEY_DOWN;
break;
case EVENT_STATE_ACTIVATED:
- cmdstr = "pd_key_down";
+ cmd = CMD_GBAR_KEY_DOWN;
break;
case EVENT_STATE_DEACTIVATE:
- cmdstr = "pd_key_up";
+ cmd = CMD_GBAR_KEY_UP;
break;
default:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack(cmdstr, "ssdi", package_name(pkg), instance_id(inst), util_timestamp(), event_info->keycode);
+ packet = packet_create_noack((const char *)&cmd, "ssdi", package_name(pkg), instance_id(inst), event_info->tv, event_info->keycode);
if (!packet) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
}
-static int mouse_event_pd_route_cb(enum event_state state, struct event_data *event_info, void *data)
+static int mouse_event_gbar_route_cb(enum event_state state, struct event_data *event_info, void *data)
{
struct inst_info *inst = data;
const struct pkg_info *pkg;
struct slave_node *slave;
struct packet *packet;
- const char *cmdstr;
+ unsigned int cmd;
+
+ if (!inst) {
+ DbgPrint("Instance is deleted.\n");
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
pkg = instance_package(inst);
if (!pkg) {
- 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;
}
switch (state) {
case EVENT_STATE_ACTIVATE:
- cmdstr = "pd_mouse_down";
+ cmd = CMD_GBAR_MOUSE_DOWN;
break;
case EVENT_STATE_ACTIVATED:
- cmdstr = "pd_mouse_move";
+ cmd = CMD_GBAR_MOUSE_MOVE;
break;
case EVENT_STATE_DEACTIVATE:
- cmdstr = "pd_mouse_up";
+ cmd = CMD_GBAR_MOUSE_UP;
break;
default:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- packet = packet_create_noack(cmdstr, "ssdii", package_name(pkg), instance_id(inst), util_timestamp(), event_info->x, event_info->y);
+ packet = packet_create_noack((const char *)&cmd, "ssdii", package_name(pkg), instance_id(inst), event_info->tv, event_info->x, event_info->y);
if (!packet) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
return slave_rpc_request_only(slave, package_name(pkg), packet, 0);
}
-static int key_event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+static int key_event_gbar_consume_cb(enum event_state state, struct event_data *event_info, void *data)
{
struct script_info *script;
struct inst_info *inst = data;
return 0;
}
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- timestamp = util_timestamp();
+ timestamp = event_info->tv;
switch (state) {
case EVENT_STATE_ACTIVATE:
script_handler_update_keycode(script, event_info->keycode);
- (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_KEY_DOWN, timestamp);
break;
case EVENT_STATE_ACTIVATED:
script_handler_update_keycode(script, event_info->keycode);
- (void)script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_KEY_DOWN, timestamp);
break;
case EVENT_STATE_DEACTIVATE:
script_handler_update_keycode(script, event_info->keycode);
- (void)script_handler_feed_event(script, LB_SCRIPT_KEY_UP, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_KEY_UP, timestamp);
break;
default:
ErrPrint("Unknown event\n");
return 0;
}
-static int mouse_event_pd_consume_cb(enum event_state state, struct event_data *event_info, void *data)
+static int mouse_event_gbar_consume_cb(enum event_state state, struct event_data *event_info, void *data)
{
struct script_info *script;
struct inst_info *inst = data;
return 0;
}
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- timestamp = util_timestamp();
+ timestamp = event_info->tv;
switch (state) {
case EVENT_STATE_ACTIVATE:
script_handler_update_pointer(script, event_info->x, event_info->y, 1);
- (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_DOWN, timestamp);
break;
case EVENT_STATE_ACTIVATED:
script_handler_update_pointer(script, event_info->x, event_info->y, -1);
- (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_MOVE, timestamp);
break;
case EVENT_STATE_DEACTIVATE:
script_handler_update_pointer(script, event_info->x, event_info->y, 0);
- (void)script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
+ (void)script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_UP, timestamp);
break;
default:
break;
{
struct client_node *client;
struct packet *result;
+ const char *direct_addr;
double timestamp;
int ret;
client = client_find_by_rpc_handle(handle);
if (client) {
ErrPrint("Client is already exists %d\n", pid);
- ret = LB_STATUS_ERROR_EXIST;
+ ret = DBOX_STATUS_ERROR_EXIST;
goto out;
}
- if (packet_get(packet, "d", ×tamp) != 1) {
+ if (packet_get(packet, "ds", ×tamp, &direct_addr) != 2) {
ErrPrint("Invalid arguemnt\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
* \note
* client_create will invoke the client created callback
*/
- client = client_create(pid, handle);
+ client = client_create(pid, handle, direct_addr);
if (!client) {
ErrPrint("Failed to create a new client for %d\n", pid);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
}
out:
- result = packet_create_reply(packet, "i", ret);
+ result = packet_create_reply(packet, "ii", ret, DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT);
if (!result) {
ErrPrint("Failed to create a packet\n");
}
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
inst = package_find_instance_by_id(pkgname, id);
if (!inst) {
ErrPrint("Instance is not exists (%s)\n", id);
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
pkg = instance_package(inst);
if (!pkg) {
ErrPrint("System error - instance has no package?\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (package_is_fault(pkg)) {
ErrPrint("Faulted package: %s\n", pkgname);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (out_inst) {
*out_pkg = pkg;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/*!< pid, pkgname, filename, event, timestamp, x, y, ret */
/*!
* \NOTE:
* Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
+ * The package has to be a dynamicbox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
(void)instance_clicked(inst, event, timestamp, x, y);
}
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = packet_get(packet, "ssi", &pkgname, &id, &active_update);
if (ret != 3) {
ErrPrint("Invalid argument\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
/*!
* \note
* Send change update mode request to a slave
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssssdddd", &pkgname, &id, &emission, &source, &sx, &sy, &ex, &ey);
if (ret != 8) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
/*!
* \NOTE:
* Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
+ * The package has to be a dynamicbox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
}
* So check it again
*/
if (instance_has_client(item->inst, item->client)) {
- (void)instance_unicast_deleted_event(item->inst, item->client, LB_STATUS_SUCCESS);
+ (void)instance_unicast_deleted_event(item->inst, item->client, DBOX_STATUS_ERROR_NONE);
(void)instance_del_client(item->inst, item->client);
}
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssid", &pkgname, &id, &type, ×tamp);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
/*!
* \note
- * Below two types must has to be sync'd with livebox-viewer
+ * Below two types must has to be sync'd with dynamicbox-viewer
*
- * LB_DELETE_PERMANENTLY = 0x01,
- * LB_DELETE_TEMPORARY = 0x02,
+ * DBOX_DELETE_PERMANENTLY = 0x01,
+ * DBOX_DELETE_TEMPORARY = 0x02,
*
*/
/*!
* \NOTE:
* Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
+ * The package has to be a dynamicbox package name.
*/
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
DbgPrint("Failed to find by id(%s), try to find it using timestamp(%lf)\n", id, timestamp);
inst = package_find_instance_by_timestamp(pkgname, timestamp);
if (!inst) {
if (package_is_fault(pkg)) {
DbgPrint("Faulted package. will be deleted soon: %s\n", id);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- ret = LB_STATUS_ERROR_MEMORY;
+ ret = DBOX_STATUS_ERROR_OUT_OF_MEMORY;
} else {
/*!
* \NOTE:
(void)client_unref(client);
(void)instance_unref(inst);
DbgFree(item);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
} else {
- ret = LB_STATUS_SUCCESS;
+ ret = DBOX_STATUS_ERROR_NONE;
}
}
} else {
ErrPrint("Client has no permission\n");
- ret = LB_STATUS_ERROR_PERMISSION;
+ ret = DBOX_STATUS_ERROR_PERMISSION_DENIED;
}
} else {
switch (type) {
- case LB_DELETE_PERMANENTLY:
- ret = instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
+ case DBOX_DELETE_PERMANENTLY:
+ ret = instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
break;
- case LB_DELETE_TEMPORARY:
- ret = instance_destroy(inst, INSTANCE_DESTROY_TEMPORARY);
+ case DBOX_DELETE_TEMPORARY:
+ ret = instance_destroy(inst, DBOX_DESTROY_TYPE_TEMPORARY);
break;
default:
break;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssii", &pkgname, &id, &w, &h);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
/*!
* \NOTE:
* Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
+ * The package has to be a dynamicbox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
if (instance_client(inst) != client) {
- ret = LB_STATUS_ERROR_PERMISSION;
+ ret = DBOX_STATUS_ERROR_PERMISSION_DENIED;
} else {
ret = instance_resize(inst, w, h);
}
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "dssssdii", ×tamp, &pkgname, &content, &cluster, &category, &period, &width, &height);
if (ret != 8) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
DbgPrint("pid[%d] period[%lf] pkgname[%s] content[%s] cluster[%s] category[%s] period[%lf]\n",
- pid, timestamp, pkgname, content, cluster, category, period);
+ pid, timestamp, pkgname, content, cluster, category, period);
- lbid = package_lb_pkgname(pkgname);
+ lbid = package_dbox_pkgname(pkgname);
if (!lbid) {
- ErrPrint("This %s has no livebox package\n", pkgname);
- ret = LB_STATUS_ERROR_INVALID;
+ ErrPrint("This %s has no dynamicbox package\n", pkgname);
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
- mainappid = livebox_service_mainappid(lbid);
+ mainappid = dynamicbox_service_mainappid(lbid);
if (!package_is_enabled(mainappid)) {
DbgFree(mainappid);
DbgFree(lbid);
- ret = LB_STATUS_ERROR_DISABLED;
+ ret = DBOX_STATUS_ERROR_DISABLED;
goto out;
}
DbgFree(mainappid);
info = package_find(lbid);
if (!info) {
char *pkgid;
- pkgid = livebox_service_appid(lbid);
+ pkgid = dynamicbox_service_package_id(lbid);
if (!pkgid) {
DbgFree(mainappid);
DbgFree(lbid);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
}
if (!info) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
} else if (package_is_fault(info)) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (util_free_space(IMAGE_PATH) <= MINIMUM_SPACE) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else if (util_free_space(DYNAMICBOX_CONF_IMAGE_PATH) <= DYNAMICBOX_CONF_MINIMUM_SPACE) {
ErrPrint("Not enough space\n");
- ret = LB_STATUS_ERROR_NO_SPACE;
+ ret = DBOX_STATUS_ERROR_NO_SPACE;
} else {
struct inst_info *inst;
- if (period > 0.0f && period < MINIMUM_PERIOD) {
- period = MINIMUM_PERIOD;
+ if (period > 0.0f && period < DYNAMICBOX_CONF_MINIMUM_PERIOD) {
+ period = DYNAMICBOX_CONF_MINIMUM_PERIOD;
}
inst = instance_create(client, timestamp, lbid, content, cluster, category, period, width, height);
* \note
* Using the "inst" without validate its value is at my disposal. ;)
*/
- ret = inst ? 0 : LB_STATUS_ERROR_FAULT;
+ ret = inst ? 0 : DBOX_STATUS_ERROR_FAULT;
}
DbgFree(lbid);
struct client_node *client;
const char *pkgname;
const char *id;
- enum livebox_visible_state state;
+ enum dynamicbox_visible_state state;
int ret;
struct inst_info *inst;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssi", &pkgname, &id, (int *)&state);
if (ret != 3) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
/*!
* \NOTE:
* Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
+ * The package has to be a dynamicbox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
if (instance_client(inst) != client) {
- ret = LB_STATUS_ERROR_PERMISSION;
+ ret = DBOX_STATUS_ERROR_PERMISSION_DENIED;
} else {
ret = instance_set_visible_state(inst, state);
}
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssd", &pkgname, &id, &period);
if (ret != 3) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
/*!
* \NOTE:
* Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
+ * The package has to be a dynamicbox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
if (instance_client(inst) != client) {
- ret = LB_STATUS_ERROR_PERMISSION;
+ ret = DBOX_STATUS_ERROR_PERMISSION_DENIED;
} else {
ret = instance_set_period(inst, period);
}
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssss", &pkgname, &id, &cluster, &category);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
/*!
* \NOTE:
* Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
+ * The package has to be a dynamicbox package name.
*/
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
if (instance_client(inst) != client) {
- ret = LB_STATUS_ERROR_PERMISSION;
+ ret = DBOX_STATUS_ERROR_PERMISSION_DENIED;
} else {
ret = instance_change_group(inst, cluster, category);
}
return result;
}
-static struct packet *client_pd_mouse_enter(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_mouse_enter(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_event_packet(pkg, inst, packet);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_event_packet(pkg, inst, packet);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_IN, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_mouse_leave(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_mouse_leave(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_event_packet(pkg, inst, packet);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_event_packet(pkg, inst, packet);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_OUT, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_mouse_down(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, id, width, height, timestamp, x, y, ret */
+static struct packet *client_gbar_mouse_down(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, id, width, height, timestamp, x, y, ret */
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_event_packet(pkg, inst, packet);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_event_packet(pkg, inst, packet);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, 1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_DOWN, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_mouse_up(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+static struct packet *client_gbar_mouse_up(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_event_packet(pkg, inst, packet);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_event_packet(pkg, inst, packet);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, 0);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_UP, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_mouse_move(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+static struct packet *client_gbar_mouse_move(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_event_packet(pkg, inst, packet);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_event_packet(pkg, inst, packet);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_MOVE, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_lb_mouse_move(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+static struct packet *client_dbox_mouse_move(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_event_packet(pkg, inst, packet);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_event_packet(pkg, inst, packet);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_MOVE, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_MOVE, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
static int inst_del_cb(struct inst_info *inst, void *data)
{
+ int ret;
+
+ /*
+ * If you deactivate the event thread,
+ * It will calls event callbacks.
+ * And the event callbacks will try to access the "inst"
+ */
(void)event_deactivate(data, inst);
+
+ /* Reset callback data to prevent accessing inst from event callback */
+ ret = event_reset_cbdata(data, inst, NULL);
+ DbgPrint("Instance delete callback called: %s (%d)\n", instance_id(inst), ret);
+
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(instance_package(inst)), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF);
+ }
+
return -1; /* Delete this callback */
}
-static struct packet *client_pd_key_set(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_key_set(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = event_activate(0, 0, key_event_pd_route_cb, inst);
- if (ret == 0) {
- instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_route_cb);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = event_activate(0, 0, key_event_gbar_route_cb, inst);
+ if (ret == DBOX_STATUS_ERROR_NONE) {
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON);
+ }
+ if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_route_cb) <= 0) {
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_route_cb);
+ }
}
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
- ret = event_activate(0, 0, key_event_pd_consume_cb, inst);
- if (ret == 0) {
- instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_consume_cb);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
+ ret = event_activate(0, 0, key_event_gbar_consume_cb, inst);
+ if (ret == DBOX_STATUS_ERROR_NONE) {
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON);
+ }
+ if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_consume_cb) <= 0) {
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_consume_cb);
+ }
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_key_unset(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_key_unset(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = event_deactivate(key_event_pd_route_cb, inst);
- if (ret == 0) {
- instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_route_cb);
- }
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
- ret = event_deactivate(key_event_pd_consume_cb, inst);
- if (ret == 0) {
- instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_pd_consume_cb);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = event_deactivate(key_event_gbar_route_cb, inst);
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF);
}
+ /*
+ * This delete callback will be removed when the instance will be destroyed.
+ if (ret == 0) {
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_route_cb);
+ }
+ */
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
+ ret = event_deactivate(key_event_gbar_consume_cb, inst);
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF);
+ }
+ /*
+ * This delete callback will be removed when the instance will be destroyed.
+ if (ret == 0) {
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_gbar_consume_cb);
+ }
+ */
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_key_set(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_key_set(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = event_activate(0, 0, key_event_lb_route_cb, inst);
- if (ret == 0) {
- instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_route_cb);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = event_activate(0, 0, key_event_dbox_route_cb, inst);
+ if (ret == DBOX_STATUS_ERROR_NONE) {
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON);
+ }
+ if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_dbox_route_cb) <= 0) {
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_dbox_route_cb);
+ }
}
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
- ret = event_activate(0, 0, key_event_lb_consume_cb, inst);
- if (ret == 0) {
- instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_consume_cb);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
+ ret = event_activate(0, 0, key_event_dbox_consume_cb, inst);
+ if (ret == DBOX_STATUS_ERROR_NONE) {
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON);
+ }
+ if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_dbox_consume_cb) <= 0) {
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_dbox_consume_cb);
+ }
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_key_unset(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_key_unset(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = event_deactivate(key_event_lb_route_cb, inst);
- if (ret == 0) {
- instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_route_cb);
- }
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
- ret = event_deactivate(key_event_lb_consume_cb, inst);
- if (ret == 0) {
- instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_lb_consume_cb);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = event_deactivate(key_event_dbox_route_cb, inst);
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF);
}
+ /*
+ * This delete callback will be removed when the instance will be destroyed.
+ if (ret == 0) {
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_dbox_route_cb);
+ }
+ */
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
+ ret = event_deactivate(key_event_dbox_consume_cb, inst);
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF);
+ }
+ /*
+ * This delete callback will be removed when the instance will be destroyed.
+ if (ret == 0) {
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, key_event_dbox_consume_cb);
+ }
+ */
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_mouse_set(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_mouse_set(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = event_activate(x, y, mouse_event_lb_route_cb, inst);
- if (ret == 0) {
- instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_route_cb);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ if (package_direct_input(pkg) == 0 || packet_set_fd((struct packet *)packet, event_input_fd()) < 0) {
+ ret = event_activate(x, y, mouse_event_dbox_route_cb, inst);
+ if (ret == DBOX_STATUS_ERROR_NONE) {
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON);
+ }
+ if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_dbox_route_cb) <= 0) {
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_dbox_route_cb);
+ }
+ }
+ } else {
+ struct slave_node *slave;
+
+ DbgPrint("Direct input is enabled(set for %s:%d)\n", id, packet_fd(packet));
+ slave = package_slave(pkg);
+ if (slave) {
+ packet_ref((struct packet *)packet);
+ ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
+ } else {
+ ErrPrint("Unable to find a slave for %s\n", pkgname);
+ ret = DBOX_STATUS_ERROR_FAULT;
+ }
}
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
- ret = event_activate(x, y, mouse_event_lb_consume_cb, inst);
- if (ret == 0) {
- instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_consume_cb);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
+ ret = event_activate(x, y, mouse_event_dbox_consume_cb, inst);
+ if (ret == DBOX_STATUS_ERROR_NONE) {
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON);
+ }
+ if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_dbox_consume_cb) <= 0) {
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_dbox_consume_cb);
+ }
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_lb_mouse_unset(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_mouse_unset(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = event_deactivate(mouse_event_lb_route_cb, inst);
- if (ret == 0) {
- instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_route_cb);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ if (package_direct_input(pkg) == 0) {
+ ret = event_deactivate(mouse_event_dbox_route_cb, inst);
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF);
+ }
+ /*
+ * This delete callback will be removed when the instance will be destroyed.
+ if (ret == 0) {
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_dbox_route_cb);
+ }
+ */
+ } else {
+ struct slave_node *slave;
+
+ DbgPrint("Direct input is enabled(unset) for %s\n", id);
+ slave = package_slave(pkg);
+ if (slave) {
+ packet_ref((struct packet *)packet);
+ ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
+ } else {
+ ErrPrint("Unable to find a slave for %s\n", pkgname);
+ ret = DBOX_STATUS_ERROR_FAULT;
+ }
}
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
- ret = event_deactivate(mouse_event_lb_consume_cb, inst);
- if (ret == 0) {
- instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_lb_consume_cb);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
+ ret = event_deactivate(mouse_event_dbox_consume_cb, inst);
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF);
}
+ /*
+ * This delete callback will be removed when the instance will be destroyed.
+ if (ret == 0) {
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_dbox_consume_cb);
+ }
+ */
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_mouse_set(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_mouse_set(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = event_activate(x, y, mouse_event_pd_route_cb, inst);
- if (ret == 0) {
- instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_route_cb);
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ if (package_direct_input(pkg) == 0 || packet_set_fd((struct packet *)packet, event_input_fd()) < 0) {
+ ret = event_activate(x, y, mouse_event_gbar_route_cb, inst);
+ if (ret == DBOX_STATUS_ERROR_NONE) {
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON);
+ }
+ if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_route_cb) <= 0) {
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_route_cb);
+ }
+ }
+ } else {
+ struct slave_node *slave;
+
+ DbgPrint("Direct input is enabled(set for %s:%d)\n", id, packet_fd(packet));
+ slave = package_slave(pkg);
+ if (slave) {
+ packet_ref((struct packet *)packet);
+ ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
+ } else {
+ ErrPrint("Unable to find a slave for %s\n", pkgname);
+ ret = DBOX_STATUS_ERROR_FAULT;
+ }
}
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
- ret = event_activate(x, y, mouse_event_pd_consume_cb, inst);
- if (ret == 0) {
- instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_consume_cb);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
+ ret = event_activate(x, y, mouse_event_gbar_consume_cb, inst);
+ if (ret == DBOX_STATUS_ERROR_NONE) {
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON);
+ }
+ if (instance_event_callback_is_added(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_consume_cb) <= 0) {
+ instance_event_callback_add(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_consume_cb);
+ }
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_lb_mouse_on_scroll(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_mouse_on_scroll(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_event_packet(pkg, inst, packet);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_event_packet(pkg, inst, packet);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_ON_SCROLL, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_ON_SCROLL, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_lb_mouse_off_scroll(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_mouse_off_scroll(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_event_packet(pkg, inst, packet);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_event_packet(pkg, inst, packet);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_OFF_SCROLL, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_OFF_SCROLL, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_lb_mouse_on_hold(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_mouse_on_hold(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_event_packet(pkg, inst, packet);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_event_packet(pkg, inst, packet);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_ON_HOLD, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_ON_HOLD, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_lb_mouse_off_hold(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_mouse_off_hold(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_event_packet(pkg, inst, packet);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_event_packet(pkg, inst, packet);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_OFF_HOLD, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_OFF_HOLD, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_mouse_on_scroll(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_mouse_on_scroll(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_event_packet(pkg, inst, packet);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_event_packet(pkg, inst, packet);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_ON_SCROLL, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_ON_SCROLL, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_mouse_off_scroll(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_mouse_off_scroll(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_event_packet(pkg, inst, packet);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_event_packet(pkg, inst, packet);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_OFF_SCROLL, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_OFF_SCROLL, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_mouse_on_hold(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_mouse_on_hold(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_event_packet(pkg, inst, packet);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_event_packet(pkg, inst, packet);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_ON_HOLD, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_ON_HOLD, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_mouse_off_hold(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_mouse_off_hold(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_event_packet(pkg, inst, packet);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_event_packet(pkg, inst, packet);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_OFF_HOLD, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_OFF_HOLD, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_mouse_unset(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_mouse_unset(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = event_deactivate(mouse_event_pd_route_cb, inst);
- if (ret == 0) {
- instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_route_cb);
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ if (package_direct_input(pkg) == 0) {
+ ret = event_deactivate(mouse_event_gbar_route_cb, inst);
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF);
+ }
+ /*
+ * This delete callback will be removed when the instance will be destroyed.
+ if (ret == 0) {
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_route_cb);
+ }
+ */
+ } else {
+ struct slave_node *slave;
+
+ DbgPrint("Direct input is enabled(unset) for %s\n", id);
+ slave = package_slave(pkg);
+ if (slave) {
+ packet_ref((struct packet *)packet);
+ ret = slave_rpc_request_only(slave, pkgname, (struct packet *)packet, 0);
+ } else {
+ ErrPrint("Unable to find a slave for %s\n", pkgname);
+ ret = DBOX_STATUS_ERROR_FAULT;
+ }
}
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
- ret = event_deactivate(mouse_event_pd_consume_cb, inst);
- if (ret == 0) {
- instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_pd_consume_cb);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
+ ret = event_deactivate(mouse_event_gbar_consume_cb, inst);
+ if (DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF != DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_ON) {
+ (void)slave_set_priority(package_slave(pkg), DYNAMICBOX_CONF_SLAVE_EVENT_BOOST_OFF);
}
+ /*
+ * This delete callback will be removed when the instance will be destroyed.
+ if (ret == 0) {
+ instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb, mouse_event_gbar_consume_cb);
+ }
+ */
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_lb_mouse_enter(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+static struct packet *client_dbox_mouse_enter(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_event_packet(pkg, inst, packet);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_event_packet(pkg, inst, packet);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_IN, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_IN, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_lb_mouse_leave(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+static struct packet *client_dbox_mouse_leave(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_event_packet(pkg, inst, packet);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_event_packet(pkg, inst, packet);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, -1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_OUT, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_OUT, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_lb_mouse_down(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+static struct packet *client_dbox_mouse_down(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_event_packet(pkg, inst, packet);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_event_packet(pkg, inst, packet);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, 1);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_DOWN, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_DOWN, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_lb_mouse_up(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+static struct packet *client_dbox_mouse_up(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_event_packet(pkg, inst, packet);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_event_packet(pkg, inst, packet);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_pointer(script, x, y, 0);
- script_handler_feed_event(script, LB_SCRIPT_MOUSE_UP, timestamp);
+ script_handler_feed_event(script, DBOX_SCRIPT_MOUSE_UP, timestamp);
ret = 0;
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return NULL;
}
-static struct packet *client_pd_access_action_up(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_access_action(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, 0);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_ACTION, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_access_action_down(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_access_scroll(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, 1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_SCROLL, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_access_value_change(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, 1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_VALUE_CHANGE, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_access_mouse(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_MOUSE, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_access_back(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, 0);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_BACK, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_access_over(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *pkgname;
const char *id;
- int x;
- int y;
- struct inst_info *inst = NULL;
- const struct pkg_info *pkg = NULL;
int ret;
double timestamp;
+ struct access_info event;
+ struct inst_info *inst = NULL;
+ const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_OVER, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
+
out:
result = packet_create_reply(packet, "i", ret);
if (!result) {
return result;
}
-static struct packet *client_pd_access_hl(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_access_read(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_READ, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_access_enable(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
+ int type;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
- if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
+ type = (event.type == 0) ? DBOX_SCRIPT_ACCESS_DISABLE : DBOX_SCRIPT_ACCESS_ENABLE;
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, type, timestamp);
+ if (ret >= 0) {
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_access_hl_next(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_access_hl(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
+ int type;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ErrPrint("Script is not created yet\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
- if (ret >= 0) {
- struct event_cbdata *cbdata;
+ switch (event.type) {
+ case ACCESS_TYPE_CUR:
+ type = DBOX_SCRIPT_ACCESS_HIGHLIGHT;
+ break;
+ case ACCESS_TYPE_NEXT:
+ type = DBOX_SCRIPT_ACCESS_HIGHLIGHT_NEXT;
+ break;
+ case ACCESS_TYPE_PREV:
+ type = DBOX_SCRIPT_ACCESS_HIGHLIGHT_PREV;
+ break;
+ case ACCESS_TYPE_OFF:
+ type = DBOX_SCRIPT_ACCESS_UNHIGHLIGHT;
+ break;
+ default:
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ErrPrint("Heap: %s\n", strerror(errno));
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- ErrPrint("Failed to add timer\n");
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
- } else {
- DbgPrint("Returns: %d\n", ret);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, type, timestamp);
+ if (ret >= 0) {
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_access_activate(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_access_activate(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_ACTIVATE, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_key_focus_in(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_key_focus_in(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_keycode(script, keycode);
- ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_IN, timestamp);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_KEY_FOCUS_IN, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_key_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_key_focus_out(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_key_focus_out(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_keycode(script, keycode);
- ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_OUT, timestamp);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_KEY_FOCUS_OUT, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_key_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_pd_key_down(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_key_down(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_keycode(script, keycode);
- ret = script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_KEY_DOWN, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_key_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is paused - manually reported\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "d", ×tamp);
if (ret != 1) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
- if (USE_XMONITOR) {
+ if (DYNAMICBOX_CONF_USE_XMONITOR) {
DbgPrint("XMONITOR enabled. ignore client paused request\n");
} else {
xmonitor_pause(client);
goto out;
}
- if (USE_XMONITOR) {
+ if (DYNAMICBOX_CONF_USE_XMONITOR) {
DbgPrint("XMONITOR enabled. ignore client resumed request\n");
} else {
xmonitor_resume(client);
return NULL;
}
-static struct packet *client_pd_key_up(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_key_up(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- ret = forward_pd_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ ret = forward_gbar_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_pd_script(inst);
+ script = instance_gbar_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_keycode(script, keycode);
- ret = script_handler_feed_event(script, LB_SCRIPT_KEY_UP, timestamp);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_KEY_UP, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_key_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_access_hl(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_access_hl(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
+ int type;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT, timestamp);
- if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
+ switch (event.type) {
+ case ACCESS_TYPE_CUR:
+ type = DBOX_SCRIPT_ACCESS_HIGHLIGHT;
+ break;
+ case ACCESS_TYPE_NEXT:
+ type = DBOX_SCRIPT_ACCESS_HIGHLIGHT_NEXT;
+ break;
+ case ACCESS_TYPE_PREV:
+ type = DBOX_SCRIPT_ACCESS_HIGHLIGHT_PREV;
+ break;
+ case ACCESS_TYPE_OFF:
+ type = DBOX_SCRIPT_ACCESS_UNHIGHLIGHT;
+ break;
+ default:
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, type, timestamp);
+ if (ret >= 0) {
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_access_hl_prev(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_access_action(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
- struct inst_info *inst;
- const struct pkg_info *pkg;
+ struct inst_info *inst = NULL;
+ const struct pkg_info *pkg = NULL;
+ struct access_info event;
client = client_find_by_rpc_handle(handle);
if (!client) {
- ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ErrPrint("Client %d is not exist\n", pid);
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ /*!
+ * Enen if it fails to send packet,
+ * The packet will be unref'd
+ * So we don't need to check the ret value.
+ */
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ErrPrint("Instance has no script\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_PREV, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_ACTION, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_access_hl_next(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_access_scroll(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
+ struct access_info event;
client = client_find_by_rpc_handle(handle);
if (!client) {
- ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ErrPrint("Client %d is not exist\n", pid);
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ /*!
+ * Enen if it fails to send packet,
+ * The packet will be unref'd
+ * So we don't need to check the ret value.
+ */
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ErrPrint("Instance has no script\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_SCROLL, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_access_action_up(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_access_value_change(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
double timestamp;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
- int x;
- int y;
+ struct access_info event;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exist\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
/*!
* Enen if it fails to send packet,
* The packet will be unref'd
* So we don't need to check the ret value.
*/
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
ErrPrint("Instance has no script\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, 0);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_VALUE_CHANGE, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_access_action_down(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_access_mouse(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- struct inst_info *inst;
- const struct pkg_info *pkg;
- int x;
- int y;
+ struct inst_info *inst = NULL;
+ const struct pkg_info *pkg = NULL;
+ struct access_info event;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exist\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
/*!
* Enen if it fails to send packet,
* The packet will be unref'd
* So we don't need to check the ret value.
*/
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
ErrPrint("Instance has no script\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, 1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTION, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_MOUSE, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_access_unhighlight(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_access_back(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
+ struct access_info event;
client = client_find_by_rpc_handle(handle);
if (!client) {
- ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ErrPrint("Client %d is not exist\n", pid);
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ /*!
+ * Enen if it fails to send packet,
+ * The packet will be unref'd
+ * So we don't need to check the ret value.
+ */
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ErrPrint("Instance has no script\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_UNHIGHLIGHT, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_BACK, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_access_scroll_down(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_access_over(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
double timestamp;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
- int x;
- int y;
+ struct access_info event;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exist\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
/*!
* Enen if it fails to send packet,
* The packet will be unref'd
* So we don't need to check the ret value.
*/
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
ErrPrint("Instance has no script\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, 1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_OVER, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_access_scroll_move(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_access_read(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
double timestamp;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
- int x;
- int y;
+ struct access_info event;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exist\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
/*!
* Enen if it fails to send packet,
* The packet will be unref'd
* So we don't need to check the ret value.
*/
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
ErrPrint("Instance has no script\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_READ, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_access_scroll_up(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_access_enable(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- struct inst_info *inst;
- const struct pkg_info *pkg;
- int x;
- int y;
+ struct inst_info *inst = NULL;
+ const struct pkg_info *pkg = NULL;
+ struct access_info event;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exist\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
/*!
* Enen if it fails to send packet,
* The packet will be unref'd
* So we don't need to check the ret value.
*/
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
+ int type;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
ErrPrint("Instance has no script\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, 0);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_SCROLL, timestamp);
- if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
+ type = (event.type == 0) ? DBOX_SCRIPT_ACCESS_DISABLE : DBOX_SCRIPT_ACCESS_ENABLE;
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, type, timestamp);
+ if (ret >= 0) {
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_access_activate(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_access_activate(pid_t pid, int handle, const struct packet *packet)
{
struct packet *result;
struct client_node *client;
const char *id;
int ret;
double timestamp;
- int x;
- int y;
+ struct access_info event;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
+ ret = packet_get(packet, "ssdiii", &pkgname, &id, ×tamp, &event.x, &event.y, &event.type);
+ if (ret != 6) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_access_packet(pkg, inst, packet_command(packet), timestamp, x, y);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_access_packet(pkg, inst, packet_command(packet), timestamp, &event);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
ErrPrint("Instance has no script\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- script_handler_update_pointer(script, x, y, -1);
- ret = script_handler_feed_event(script, LB_SCRIPT_ACCESS_ACTIVATE, timestamp);
+ script_handler_update_pointer(script, event.x, event.y, event.type);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_ACCESS_ACTIVATE, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_access_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_access_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_key_down(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_key_down(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_keycode(script, keycode);
- ret = script_handler_feed_event(script, LB_SCRIPT_KEY_DOWN, timestamp);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_KEY_DOWN, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_key_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_key_focus_in(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_key_focus_in(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_keycode(script, keycode);
- ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_IN, timestamp);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_KEY_FOCUS_IN, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_key_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_key_focus_out(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_key_focus_out(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_keycode(script, keycode);
- ret = script_handler_feed_event(script, LB_SCRIPT_KEY_FOCUS_OUT, timestamp);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_KEY_FOCUS_OUT, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_key_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_lb_key_up(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_key_up(pid_t pid, int handle, const struct packet *packet)
{
struct client_node *client;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdi", &pkgname, &id, ×tamp, &keycode);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = forward_lb_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
- } else if (package_lb_type(pkg) == LB_TYPE_SCRIPT) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = forward_dbox_key_packet(pkg, inst, packet_command(packet), timestamp, keycode);
+ } else if (package_dbox_type(pkg) == DBOX_TYPE_SCRIPT) {
struct script_info *script;
- script = instance_lb_script(inst);
+ script = instance_dbox_script(inst);
if (!script) {
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
script_handler_update_keycode(script, keycode);
- ret = script_handler_feed_event(script, LB_SCRIPT_KEY_UP, timestamp);
+ ret = script_handler_feed_event(script, DBOX_SCRIPT_KEY_UP, timestamp);
if (ret >= 0) {
- struct event_cbdata *cbdata;
-
- cbdata = malloc(sizeof(*cbdata));
- if (!cbdata) {
- ret = LB_STATUS_ERROR_MEMORY;
- } else {
- cbdata->inst = instance_ref(inst);
- cbdata->status = ret;
-
- if (!ecore_timer_add(DELAY_TIME, lazy_key_status_cb, cbdata)) {
- (void)instance_unref(cbdata->inst);
- DbgFree(cbdata);
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- ret = LB_STATUS_SUCCESS;
- }
- }
+ ret = send_delayed_key_status(inst, ret);
}
} else {
ErrPrint("Unsupported package\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return -1; /* Delete this callback */
}
-static struct packet *client_lb_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+
+static struct packet *client_dbox_acquire_xpixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+{
+ struct packet *result;
+ const char *pkgname;
+ const char *id;
+ struct client_node *client;
+ struct inst_info *inst;
+ int ret;
+ int pixmap = 0;
+ void *buf_ptr;
+ struct buffer_info *buffer;
+ int idx;
+
+ client = client_find_by_rpc_handle(handle);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &idx);
+ if (ret != 3) {
+ ErrPrint("Parameter is not matched\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ if (idx >= DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT || idx < 0) {
+ DbgPrint("Index is not valid: %d\n", idx);
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto out;
+ }
+
+ buffer = instance_dbox_extra_buffer(inst, idx);
+ if (!buffer) {
+ ErrPrint("Extra buffer for %d is not available\n", idx);
+ goto out;
+ }
+
+ buf_ptr = buffer_handler_pixmap_ref(buffer);
+ if (!buf_ptr) {
+ ErrPrint("Failed to ref pixmap\n");
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ goto out;
+ }
+
+ ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
+ if (ret < 0) {
+ ErrPrint("Failed to add a new client deactivate callback\n");
+ buffer_handler_pixmap_unref(buf_ptr);
+ } else {
+ pixmap = buffer_handler_pixmap(buffer);
+ ret = DBOX_STATUS_ERROR_NONE;
+ }
+
+out:
+ result = packet_create_reply(packet, "ii", pixmap, ret);
+ if (!result) {
+ ErrPrint("Failed to create a reply packet\n");
+ }
+
+ return result;
+}
+
+static struct packet *client_dbox_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct packet *result;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = packet_get(packet, "ss", &pkgname, &id);
if (ret != 2) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- buffer = instance_lb_buffer(inst);
+ buffer = instance_dbox_buffer(inst);
if (!buffer) {
struct script_info *script_info;
- script_info = instance_lb_script(inst);
+ script_info = instance_dbox_script(inst);
if (!script_info) {
- ErrPrint("Unable to get LB buffer: %s\n", id);
- ret = LB_STATUS_ERROR_FAULT;
+ ErrPrint("Unable to get DBOX buffer: %s\n", id);
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
buffer = script_handler_buffer_info(script_info);
if (!buffer) {
ErrPrint("Unable to get buffer_info: %s\n", id);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
}
buf_ptr = buffer_handler_pixmap_ref(buffer);
if (!buf_ptr) {
ErrPrint("Failed to ref pixmap\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
buffer_handler_pixmap_unref(buf_ptr);
} else {
pixmap = buffer_handler_pixmap(buffer);
- ret = LB_STATUS_SUCCESS;
+ ret = DBOX_STATUS_ERROR_NONE;
}
out:
return result;
}
-static struct packet *client_lb_release_pixmap(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_dbox_release_pixmap(pid_t pid, int handle, const struct packet *packet)
{
const char *pkgname;
const char *id;
}
ret = validate_request(pkgname, id, NULL, NULL);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
DbgPrint("It seems that the instance is already deleted: %s\n", id);
}
}
out:
- /*! \note No reply packet */
+ /**
+ * @note No reply packet
+ */
return NULL;
}
-static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+static struct packet *client_gbar_acquire_xpixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+{
+ struct packet *result;
+ const char *pkgname;
+ const char *id;
+ struct client_node *client;
+ struct inst_info *inst;
+ int ret;
+ int pixmap = 0;
+ void *buf_ptr;
+ struct buffer_info *buffer;
+ int idx;
+
+ client = client_find_by_rpc_handle(handle);
+ if (!client) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ ErrPrint("Client %d is not exists\n", pid);
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssi", &pkgname, &id, &idx);
+ if (ret != 3) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ ErrPrint("Parameter is not matched\n");
+ goto out;
+ }
+
+ if (idx >= DYNAMICBOX_CONF_EXTRA_BUFFER_COUNT || idx < 0) {
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
+
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto out;
+ }
+
+ buffer = instance_gbar_extra_buffer(inst, idx);
+ if (!buffer) {
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ goto out;
+ }
+
+ buf_ptr = buffer_handler_pixmap_ref(buffer);
+ if (!buf_ptr) {
+ ErrPrint("Failed to ref pixmap\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto out;
+ }
+
+ ret = client_event_callback_add(client, CLIENT_EVENT_DEACTIVATE, release_pixmap_cb, buf_ptr);
+ if (ret < 0) {
+ ErrPrint("Failed to add a new client deactivate callback\n");
+ buffer_handler_pixmap_unref(buf_ptr);
+ } else {
+ pixmap = buffer_handler_pixmap(buffer);
+ ret = DBOX_STATUS_ERROR_NONE;
+ }
+
+out:
+ result = packet_create_reply(packet, "ii", pixmap, ret);
+ if (!result) {
+ ErrPrint("Failed to create a reply packet\n");
+ }
+
+ return result;
+}
+
+static struct packet *client_gbar_acquire_pixmap(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
{
struct packet *result;
const char *pkgname;
client = client_find_by_rpc_handle(handle);
if (!client) {
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
ErrPrint("Client %d is not exists\n", pid);
goto out;
}
ret = packet_get(packet, "ss", &pkgname, &id);
if (ret != 2) {
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
ErrPrint("Parameter is not matched\n");
goto out;
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (instance_get_data(inst, PD_RESIZE_MONITOR_TAG)) {
- ret = LB_STATUS_ERROR_BUSY;
+ if (instance_get_data(inst, GBAR_RESIZE_MONITOR_TAG)) {
+ ret = DBOX_STATUS_ERROR_BUSY;
goto out;
}
- buffer = instance_pd_buffer(inst);
+ buffer = instance_gbar_buffer(inst);
if (!buffer) {
struct script_info *script_info;
- script_info = instance_pd_script(inst);
+ script_info = instance_gbar_script(inst);
if (!script_info) {
- ErrPrint("Unable to get LB buffer: %s\n", id);
- ret = LB_STATUS_ERROR_FAULT;
+ ErrPrint("Unable to get DBOX buffer: %s\n", id);
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
buffer = script_handler_buffer_info(script_info);
if (!buffer) {
ErrPrint("Unable to get buffer_info: %s\n", id);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
}
buf_ptr = buffer_handler_pixmap_ref(buffer);
if (!buf_ptr) {
ErrPrint("Failed to ref pixmap\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
buffer_handler_pixmap_unref(buf_ptr);
} else {
pixmap = buffer_handler_pixmap(buffer);
- ret = LB_STATUS_SUCCESS;
+ ret = DBOX_STATUS_ERROR_NONE;
}
out:
return result;
}
-static struct packet *client_pd_release_pixmap(pid_t pid, int handle, const struct packet *packet)
+static struct packet *client_gbar_release_pixmap(pid_t pid, int handle, const struct packet *packet)
{
const char *pkgname;
const char *id;
}
ret = validate_request(pkgname, id, NULL, NULL);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
DbgPrint("It seems that the instance is already deleted: %s\n", id);
}
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
pinup = 0;
goto out;
}
ret = packet_get(packet, "ssi", &pkgname, &id, &pinup);
if (ret != 3) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
pinup = 0;
goto out;
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
ret = instance_set_pinup(inst, pinup);
}
return result;
}
-static Eina_Bool lazy_pd_created_cb(void *inst)
+static Eina_Bool lazy_gbar_created_cb(void *inst)
{
struct pkg_info *pkg;
- if (!instance_del_data(inst, LAZY_PD_OPEN_TAG)) {
+ if (!instance_del_data(inst, LAZY_GBAR_OPEN_TAG)) {
ErrPrint("lazy,pd,open is already deleted.\n");
return ECORE_CALLBACK_CANCEL;
}
/*!
* After unref instance first,
- * if the instance is not destroyed, try to notify the created PD event to the client.
+ * if the instance is not destroyed, try to notify the created GBAR event to the client.
*/
if (instance_unref(inst)) {
int ret;
- ret = instance_client_pd_created(inst, LB_STATUS_SUCCESS);
+ ret = instance_client_gbar_created(inst, DBOX_STATUS_ERROR_NONE);
if (ret < 0) {
- DbgPrint("Send PD Create event (%d) to client\n", ret);
+ DbgPrint("Send GBAR Create event (%d) to client\n", ret);
}
}
return ECORE_CALLBACK_CANCEL;
}
-static Eina_Bool lazy_pd_destroyed_cb(void *inst)
+static Eina_Bool lazy_gbar_destroyed_cb(void *inst)
{
struct pkg_info *pkg;
struct slave_node *slave;
- if (!instance_del_data(inst, LAZY_PD_CLOSE_TAG)) {
+ if (!instance_del_data(inst, LAZY_GBAR_CLOSE_TAG)) {
ErrPrint("lazy,pd,close is already deleted.\n");
return ECORE_CALLBACK_CANCEL;
}
if (pkg) {
slave = package_slave(pkg);
if (slave) {
- if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
DbgPrint("Delete script type close callback\n");
(void)slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_script_cb, inst);
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
DbgPrint("Delete buffer type close callback\n");
(void)slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst);
}
if (instance_unref(inst)) {
int ret;
-
+
/*!
* If the instance is not deleted, we should send pd-destroy event from here.
*/
- ret = instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
+ ret = instance_client_gbar_destroyed(inst, DBOX_STATUS_ERROR_NONE);
if (ret < 0) {
- ErrPrint("Failed sending PD Destroy event (%d)\n", ret);
+ ErrPrint("Failed sending GBAR Destroy event (%d)\n", ret);
}
}
return ECORE_CALLBACK_CANCEL;
}
-static struct packet *client_pd_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
+static struct packet *client_gbar_move(pid_t pid, int handle, const struct packet *packet) /* pkgname, id, x, y */
{
struct client_node *client;
struct inst_info *inst;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
if (ret != 4) {
ErrPrint("Parameter is not correct\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- instance_slave_set_pd_pos(inst, x, y);
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ instance_slave_set_gbar_pos(inst, x, y);
ret = instance_signal_emit(inst, "pd,move", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
int ix;
int iy;
- instance_slave_set_pd_pos(inst, x, y);
- ix = x * instance_pd_width(inst);
- iy = y * instance_pd_height(inst);
- script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
+ instance_slave_set_gbar_pos(inst, x, y);
+ ix = x * instance_gbar_width(inst);
+ iy = y * instance_gbar_height(inst);
+ script_handler_update_pointer(instance_gbar_script(inst), ix, iy, 0);
ret = instance_signal_emit(inst, "pd,move", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
} else {
- ErrPrint("Invalid PD type\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ErrPrint("Invalid GBAR type\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
- DbgPrint("Update PD position: %d\n", ret);
+ DbgPrint("Update GBAR position: %d\n", ret);
return NULL;
}
-static Eina_Bool pd_open_monitor_cb(void *inst)
+static Eina_Bool gbar_open_monitor_cb(void *inst)
{
struct pkg_info *pkg;
}
}
- (void)instance_slave_close_pd(inst, instance_pd_owner(inst), LB_CLOSE_PD_TIMEOUT);
- (void)instance_client_pd_created(inst, LB_STATUS_ERROR_TIMEOUT);
- (void)instance_del_data(inst, PD_OPEN_MONITOR_TAG);
+ (void)instance_slave_close_gbar(inst, instance_gbar_owner(inst), DBOX_CLOSE_GBAR_TIMEOUT);
+ (void)instance_client_gbar_created(inst, DBOX_STATUS_ERROR_TIMEOUT);
+ (void)instance_del_data(inst, GBAR_OPEN_MONITOR_TAG);
(void)instance_unref(inst);
- ErrPrint("PD Open request is timed-out (%lf)\n", PD_REQUEST_TIMEOUT);
+ ErrPrint("GBAR Open request is timed-out (%lf)\n", DYNAMICBOX_CONF_GBAR_REQUEST_TIMEOUT);
return ECORE_CALLBACK_CANCEL;
}
-static Eina_Bool pd_close_monitor_cb(void *inst)
+static Eina_Bool gbar_close_monitor_cb(void *inst)
{
struct pkg_info *pkg;
}
}
- (void)instance_client_pd_destroyed(inst, LB_STATUS_ERROR_TIMEOUT);
- (void)instance_del_data(inst, PD_CLOSE_MONITOR_TAG);
+ (void)instance_client_gbar_destroyed(inst, DBOX_STATUS_ERROR_TIMEOUT);
+ (void)instance_del_data(inst, GBAR_CLOSE_MONITOR_TAG);
(void)instance_unref(inst);
- ErrPrint("PD Close request is not processed in %lf seconds\n", PD_REQUEST_TIMEOUT);
+ ErrPrint("GBAR Close request is not processed in %lf seconds\n", DYNAMICBOX_CONF_GBAR_REQUEST_TIMEOUT);
return ECORE_CALLBACK_CANCEL;
}
-static Eina_Bool pd_resize_monitor_cb(void *inst)
+static Eina_Bool gbar_resize_monitor_cb(void *inst)
{
struct pkg_info *pkg;
}
}
- (void)instance_slave_close_pd(inst, instance_pd_owner(inst), LB_CLOSE_PD_TIMEOUT);
- (void)instance_client_pd_destroyed(inst, LB_STATUS_ERROR_TIMEOUT);
- (void)instance_del_data(inst, PD_RESIZE_MONITOR_TAG);
+ (void)instance_slave_close_gbar(inst, instance_gbar_owner(inst), DBOX_CLOSE_GBAR_TIMEOUT);
+ (void)instance_client_gbar_destroyed(inst, DBOX_STATUS_ERROR_TIMEOUT);
+ (void)instance_del_data(inst, GBAR_RESIZE_MONITOR_TAG);
(void)instance_unref(inst);
- ErrPrint("PD Resize request is not processed in %lf seconds\n", PD_REQUEST_TIMEOUT);
+ ErrPrint("GBAR Resize request is not processed in %lf seconds\n", DYNAMICBOX_CONF_GBAR_REQUEST_TIMEOUT);
return ECORE_CALLBACK_CANCEL;
}
-static struct packet *client_create_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
+static struct packet *client_create_gbar(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
{
struct client_node *client;
struct packet *result;
int ret;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
- Ecore_Timer *pd_monitor;
+ Ecore_Timer *gbar_monitor;
double x;
double y;
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ssdd", &pkgname, &id, &x, &y);
if (ret != 4) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- if (instance_pd_owner(inst)) {
- ErrPrint("PD is already owned\n");
- ret = LB_STATUS_ERROR_ALREADY;
- } else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
- pd_monitor = instance_get_data(inst, LAZY_PD_CLOSE_TAG);
- if (pd_monitor) {
- ecore_timer_del(pd_monitor);
+ if (instance_gbar_owner(inst)) {
+ ErrPrint("GBAR is already owned\n");
+ ret = DBOX_STATUS_ERROR_ALREADY;
+ } else if (package_gbar_type(instance_package(inst)) == GBAR_TYPE_BUFFER) {
+ gbar_monitor = instance_get_data(inst, LAZY_GBAR_CLOSE_TAG);
+ if (gbar_monitor) {
+ ecore_timer_del(gbar_monitor);
/* This timer attribute will be deleted */
- lazy_pd_destroyed_cb(inst);
+ lazy_gbar_destroyed_cb(inst);
}
-
- if (instance_get_data(inst, PD_OPEN_MONITOR_TAG)) {
- DbgPrint("PD Open request is already processed\n");
- ret = LB_STATUS_ERROR_ALREADY;
+
+ if (instance_get_data(inst, GBAR_OPEN_MONITOR_TAG)) {
+ DbgPrint("GBAR Open request is already processed\n");
+ ret = DBOX_STATUS_ERROR_ALREADY;
goto out;
}
- if (instance_get_data(inst, PD_CLOSE_MONITOR_TAG)) {
- DbgPrint("PD Close request is already in process\n");
- ret = LB_STATUS_ERROR_BUSY;
+ if (instance_get_data(inst, GBAR_CLOSE_MONITOR_TAG)) {
+ DbgPrint("GBAR Close request is already in process\n");
+ ret = DBOX_STATUS_ERROR_BUSY;
goto out;
}
- if (instance_get_data(inst, PD_RESIZE_MONITOR_TAG)) {
- DbgPrint("PD resize request is already in process\n");
- ret = LB_STATUS_ERROR_BUSY;
+ if (instance_get_data(inst, GBAR_RESIZE_MONITOR_TAG)) {
+ DbgPrint("GBAR resize request is already in process\n");
+ ret = DBOX_STATUS_ERROR_BUSY;
goto out;
}
- instance_slave_set_pd_pos(inst, x, y);
+ instance_slave_set_gbar_pos(inst, x, y);
/*!
* \note
* Send request to the slave.
* The SLAVE must has to repsonse this via "release_buffer" method.
*/
- ret = instance_slave_open_pd(inst, client);
- if (ret == (int)LB_STATUS_SUCCESS) {
- ret = instance_signal_emit(inst, "pd,show", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
- if (ret != LB_STATUS_SUCCESS) {
+ ret = instance_slave_open_gbar(inst, client);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ ret = instance_signal_emit(inst, "gbar,show", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
+ if (ret != DBOX_STATUS_ERROR_NONE) {
int tmp_ret;
- tmp_ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_FAULT);
+ tmp_ret = instance_slave_close_gbar(inst, client, DBOX_CLOSE_GBAR_FAULT);
if (tmp_ret < 0) {
- ErrPrint("Unable to send script event for openning PD [%s], %d\n", pkgname, tmp_ret);
+ ErrPrint("Unable to send script event for openning GBAR [%s], %d\n", pkgname, tmp_ret);
}
} else {
- pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_open_monitor_cb, instance_ref(inst));
- if (!pd_monitor) {
+ gbar_monitor = ecore_timer_add(DYNAMICBOX_CONF_GBAR_REQUEST_TIMEOUT, gbar_open_monitor_cb, instance_ref(inst));
+ if (!gbar_monitor) {
(void)instance_unref(inst);
- ErrPrint("Failed to create a timer for PD Open monitor\n");
+ ErrPrint("Failed to create a timer for GBAR Open monitor\n");
} else {
struct slave_node *slave;
- (void)instance_set_data(inst, PD_OPEN_MONITOR_TAG, pd_monitor);
+ (void)instance_set_data(inst, GBAR_OPEN_MONITOR_TAG, gbar_monitor);
slave = package_slave(pkg);
if (!slave) {
goto out;
}
- if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst) != LB_STATUS_SUCCESS) {
+ if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst) != DBOX_STATUS_ERROR_NONE) {
ErrPrint("Failed to add fault handler: %s\n");
}
}
}
} else {
- ErrPrint("Unable to send request for openning PD [%s]\n", pkgname);
+ ErrPrint("Unable to send request for openning GBAR [%s]\n", pkgname);
}
/*!
* \note
- * PD craeted event will be send by the acquire_buffer function.
+ * GBAR craeted event will be send by the acquire_buffer function.
* Because the slave will make request the acquire_buffer to
- * render the PD
+ * render the GBAR
*
- * instance_client_pd_created(inst);
+ * instance_client_gbar_created(inst);
*/
- } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
+ } else if (package_gbar_type(instance_package(inst)) == GBAR_TYPE_SCRIPT) {
int ix;
int iy;
- pd_monitor = instance_get_data(inst, LAZY_PD_CLOSE_TAG);
- if (pd_monitor) {
- ecore_timer_del(pd_monitor);
+ gbar_monitor = instance_get_data(inst, LAZY_GBAR_CLOSE_TAG);
+ if (gbar_monitor) {
+ ecore_timer_del(gbar_monitor);
/* lazy,pd,close will be deleted */
- lazy_pd_destroyed_cb(inst);
+ lazy_gbar_destroyed_cb(inst);
}
/*!
* we ignore this for this moment, so we have to handle this error later.
*
* if ret is less than 0, the slave has some problem.
- * but the script mode doesn't need slave for rendering default view of PD
+ * but the script mode doesn't need slave for rendering default view of GBAR
* so we can hanle it later.
*/
- instance_slave_set_pd_pos(inst, x, y);
- ix = x * instance_pd_width(inst);
- iy = y * instance_pd_height(inst);
+ instance_slave_set_gbar_pos(inst, x, y);
+ ix = x * instance_gbar_width(inst);
+ iy = y * instance_gbar_height(inst);
- script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
+ script_handler_update_pointer(instance_gbar_script(inst), ix, iy, 0);
- ret = instance_slave_open_pd(inst, client);
- if (ret == (int)LB_STATUS_SUCCESS) {
- ret = script_handler_load(instance_pd_script(inst), 1);
+ ret = instance_slave_open_gbar(inst, client);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ ret = script_handler_load(instance_gbar_script(inst), 1);
/*!
* \note
- * Send the PD created event to the clients,
+ * Send the GBAR created event to the clients,
*/
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
/*!
* \note
* \note
* At here, we don't need to rememeber the timer object.
* Even if the timer callback is called, after the instance is destroyed.
- * lazy_pd_created_cb will decrease the instance refcnt first.
+ * lazy_gbar_created_cb will decrease the instance refcnt first.
* At that time, if the instance is released, the timer callback will do nothing.
*
* 13-05-28
* But I just add it to the tagged-data of the instance.
* Just reserve for future-use.
*/
- pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_created_cb, inst);
- if (!pd_monitor) {
- ret = script_handler_unload(instance_pd_script(inst), 1);
+ gbar_monitor = ecore_timer_add(DELAY_TIME, lazy_gbar_created_cb, inst);
+ if (!gbar_monitor) {
+ ret = script_handler_unload(instance_gbar_script(inst), 1);
ErrPrint("Unload script: %d\n", ret);
- ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_NORMAL);
- ErrPrint("Close PD %d\n", ret);
+ ret = instance_slave_close_gbar(inst, client, DBOX_CLOSE_GBAR_NORMAL);
+ ErrPrint("Close GBAR %d\n", ret);
inst = instance_unref(inst);
if (!inst) {
ErrPrint("Instance: %s\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
} else {
struct slave_node *slave;
- (void)instance_set_data(inst, LAZY_PD_OPEN_TAG, pd_monitor);
+ (void)instance_set_data(inst, LAZY_GBAR_OPEN_TAG, gbar_monitor);
slave = package_slave(pkg);
if (!slave) {
goto out;
}
- if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_script_cb, inst) != LB_STATUS_SUCCESS) {
+ if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_script_cb, inst) != DBOX_STATUS_ERROR_NONE) {
ErrPrint("Failed to add fault callback: %s\n", pkgname);
}
}
} else {
int tmp_ret;
- tmp_ret = instance_slave_close_pd(inst, client, LB_CLOSE_PD_FAULT);
+ tmp_ret = instance_slave_close_gbar(inst, client, DBOX_CLOSE_GBAR_FAULT);
if (tmp_ret < 0) {
ErrPrint("Unable to load script: %d, (close: %d)\n", ret, tmp_ret);
}
}
} else {
- ErrPrint("Unable open PD(%s): %d\n", pkgname, ret);
+ ErrPrint("Unable open GBAR(%s): %d\n", pkgname, ret);
}
} else {
- ErrPrint("Invalid PD TYPE\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ErrPrint("Invalid GBAR TYPE\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
return result;
}
-static struct packet *client_destroy_pd(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
+static struct packet *client_destroy_gbar(pid_t pid, int handle, const struct packet *packet) /* pid, pkgname, filename, ret */
{
struct client_node *client;
struct packet *result;
int ret;
struct inst_info *inst = NULL;
const struct pkg_info *pkg = NULL;
- Ecore_Timer *pd_monitor;
+ Ecore_Timer *gbar_monitor;
struct slave_node *slave;
DbgPrint("PERF_DBOX\n");
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ss", &pkgname, &id);
if (ret != 2) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
slave = package_slave(pkg);
if (!slave) {
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
- if (instance_pd_owner(inst) != client) {
- if (instance_pd_owner(inst) == NULL) {
- ErrPrint("PD looks already closed\n");
- ret = LB_STATUS_ERROR_ALREADY;
+ if (instance_gbar_owner(inst) != client) {
+ if (instance_gbar_owner(inst) == NULL) {
+ ErrPrint("GBAR looks already closed\n");
+ ret = DBOX_STATUS_ERROR_ALREADY;
} else {
- ErrPrint("PD owner mimatched\n");
- ret = LB_STATUS_ERROR_PERMISSION;
+ ErrPrint("GBAR owner mimatched\n");
+ ret = DBOX_STATUS_ERROR_PERMISSION_DENIED;
}
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- DbgPrint("Buffer type PD\n");
- pd_monitor = instance_del_data(inst, PD_OPEN_MONITOR_TAG);
- if (pd_monitor) {
- ErrPrint("PD Open request is found. cancel it [%s]\n", pkgname);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ DbgPrint("Buffer type GBAR\n");
+ gbar_monitor = instance_del_data(inst, GBAR_OPEN_MONITOR_TAG);
+ if (gbar_monitor) {
+ ErrPrint("GBAR Open request is found. cancel it [%s]\n", pkgname);
if (slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst) < 0) {
DbgPrint("Failed to delete a deactivate callback\n");
* The client will permanently waiting destroyed event.
* Because they understand that the destroy request is successfully processed.
*/
- ret = instance_client_pd_created(inst, LB_STATUS_ERROR_CANCEL);
+ ret = instance_client_gbar_created(inst, DBOX_STATUS_ERROR_CANCEL);
if (ret < 0) {
- ErrPrint("PD client create event: %d\n", ret);
+ ErrPrint("GBAR client create event: %d\n", ret);
}
- ret = instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
+ ret = instance_client_gbar_destroyed(inst, DBOX_STATUS_ERROR_NONE);
if (ret < 0) {
- ErrPrint("PD client destroy event: %d\n", ret);
+ ErrPrint("GBAR client destroy event: %d\n", ret);
}
- ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
+ ret = instance_signal_emit(inst, "gbar,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
if (ret < 0) {
- ErrPrint("PD close signal emit failed: %d\n", ret);
+ ErrPrint("GBAR close signal emit failed: %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) {
- ErrPrint("PD close request failed: %d\n", ret);
+ ErrPrint("GBAR close request failed: %d\n", ret);
}
- ecore_timer_del(pd_monitor);
+ ecore_timer_del(gbar_monitor);
inst = instance_unref(inst);
if (!inst) {
DbgPrint("Instance is deleted\n");
}
- } else if (instance_get_data(inst, LAZY_PD_CLOSE_TAG) || instance_get_data(inst, PD_CLOSE_MONITOR_TAG)) {
+ } else if (instance_get_data(inst, LAZY_GBAR_CLOSE_TAG) || instance_get_data(inst, GBAR_CLOSE_MONITOR_TAG)) {
DbgPrint("Close monitor is already fired\n");
- ret = LB_STATUS_ERROR_ALREADY;
+ ret = DBOX_STATUS_ERROR_ALREADY;
} else {
int resize_aborted = 0;
- pd_monitor = instance_del_data(inst, PD_RESIZE_MONITOR_TAG);
- if (pd_monitor) {
- ErrPrint("PD Resize request is found. clear it [%s]\n", pkgname);
+ gbar_monitor = instance_del_data(inst, GBAR_RESIZE_MONITOR_TAG);
+ if (gbar_monitor) {
+ ErrPrint("GBAR Resize request is found. clear it [%s]\n", pkgname);
if (slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst) < 0) {
DbgPrint("Failed to delete a deactivate callback\n");
}
- ecore_timer_del(pd_monitor);
+ ecore_timer_del(gbar_monitor);
inst = instance_unref(inst);
if (!inst) {
resize_aborted = 1;
}
- ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
+ ret = instance_signal_emit(inst, "gbar,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
if (ret < 0) {
- ErrPrint("PD close signal emit failed: %d\n", ret);
+ ErrPrint("GBAR close signal emit failed: %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) {
- ErrPrint("PD close request failed: %d\n", ret);
+ ErrPrint("GBAR close request failed: %d\n", ret);
} else if (resize_aborted) {
- pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, instance_ref(inst));
- if (!pd_monitor) {
+ gbar_monitor = ecore_timer_add(DELAY_TIME, lazy_gbar_destroyed_cb, instance_ref(inst));
+ if (!gbar_monitor) {
ErrPrint("Failed to create a timer: %s\n", pkgname);
inst = instance_unref(inst);
if (!inst) {
}
} else {
DbgPrint("Resize is aborted\n");
- (void)instance_set_data(inst, LAZY_PD_CLOSE_TAG, pd_monitor);
+ (void)instance_set_data(inst, LAZY_GBAR_CLOSE_TAG, gbar_monitor);
if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst) < 0) {
ErrPrint("Failed to add a slave event callback\n");
}
}
} else {
- pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_close_monitor_cb, instance_ref(inst));
- if (!pd_monitor) {
+ gbar_monitor = ecore_timer_add(DYNAMICBOX_CONF_GBAR_REQUEST_TIMEOUT, gbar_close_monitor_cb, instance_ref(inst));
+ if (!gbar_monitor) {
ErrPrint("Failed to add pd close monitor\n");
inst = instance_unref(inst);
if (!inst) {
- ErrPrint("Instance is deleted while closing PD\n");
+ ErrPrint("Instance is deleted while closing GBAR\n");
}
} else {
DbgPrint("Add close monitor\n");
- (void)instance_set_data(inst, PD_CLOSE_MONITOR_TAG, pd_monitor);
+ (void)instance_set_data(inst, GBAR_CLOSE_MONITOR_TAG, gbar_monitor);
if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst) < 0) {
ErrPrint("Failed to add SLAVE EVENT callback\n");
}
/*!
* \note
* release_buffer will be called by the slave after this routine.
- * It will send the "pd_destroyed" event to the client
+ * It will send the "gbar_destroyed" event to the client
*
- * instance_client_pd_destroyed(inst, LB_STATUS_SUCCESS);
+ * instance_client_gbar_destroyed(inst, DBOX_STATUS_ERROR_NONE);
*
- * Or the "pd_close_monitor_cb" or "lazy_pd_destroyed_cb" will be called.
+ * Or the "gbar_close_monitor_cb" or "lazy_gbar_destroyed_cb" will be called.
*/
}
- } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
- DbgPrint("Script TYPE PD\n");
- pd_monitor = instance_get_data(inst, LAZY_PD_OPEN_TAG);
- if (pd_monitor) {
- ecore_timer_del(pd_monitor);
- (void)lazy_pd_created_cb(inst);
+ } else if (package_gbar_type(pkg) == GBAR_TYPE_SCRIPT) {
+ DbgPrint("Script TYPE GBAR\n");
+ gbar_monitor = instance_get_data(inst, LAZY_GBAR_OPEN_TAG);
+ if (gbar_monitor) {
+ ecore_timer_del(gbar_monitor);
+ (void)lazy_gbar_created_cb(inst);
}
- ret = script_handler_unload(instance_pd_script(inst), 1);
+ ret = script_handler_unload(instance_gbar_script(inst), 1);
if (ret < 0) {
ErrPrint("Unable to unload the script: %s, %d\n", pkgname, ret);
}
* Send request to the slave.
* The SLAVE must has to repsonse this via "release_buffer" method.
*/
- 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) {
- ErrPrint("Unable to close the PD: %s, %d\n", pkgname, ret);
+ ErrPrint("Unable to close the GBAR: %s, %d\n", pkgname, ret);
}
/*!
* \note
- * Send the destroyed PD event to the client
+ * Send the destroyed GBAR event to the client
*/
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
/*!
* \note
* 13-05-28
* But I just add it to the tagged-data of the instance.
* Just reserve for future-use.
*/
- DbgPrint("Add lazy PD destroy timer\n");
- pd_monitor = ecore_timer_add(DELAY_TIME, lazy_pd_destroyed_cb, instance_ref(inst));
- if (!pd_monitor) {
+ DbgPrint("Add lazy GBAR destroy timer\n");
+ gbar_monitor = ecore_timer_add(DELAY_TIME, lazy_gbar_destroyed_cb, instance_ref(inst));
+ if (!gbar_monitor) {
ErrPrint("Failed to create a timer: %s\n", pkgname);
inst = instance_unref(inst);
if (!inst) {
DbgPrint("instance is deleted\n");
}
} else {
- (void)instance_set_data(inst, LAZY_PD_CLOSE_TAG, pd_monitor);
+ (void)instance_set_data(inst, LAZY_GBAR_CLOSE_TAG, gbar_monitor);
if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_script_cb, inst) < 0) {
ErrPrint("Failed to add a event callback for slave\n");
}
}
}
} else {
- ErrPrint("Invalid PD TYPE\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ErrPrint("Invalid GBAR TYPE\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
out:
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
pkgname = "";
goto out;
}
ret = packet_get(packet, "s", &pkgname);
if (ret != 1) {
ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
pkgname = "";
goto out;
}
/*!
* \NOTE:
- * Validate the livebox package name.
+ * Validate the dynamicbox package name.
*/
- if (!package_is_lb_pkgname(pkgname)) {
- ErrPrint("%s is not a valid livebox package\n", pkgname);
+ if (!package_is_dbox_pkgname(pkgname)) {
+ ErrPrint("%s is not a valid dynamicbox package\n", pkgname);
pkgname = "";
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
info = package_find(pkgname);
if (!info) {
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
} else {
ret = package_clear_fault(info);
}
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ss", &cluster, &category);
if (ret != 2) {
ErrPrint("Invalid argument\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
- if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
+ if (!strlen(cluster) || !strcasecmp(cluster, DYNAMICBOX_CONF_DEFAULT_CLUSTER)) {
ErrPrint("Invalid cluster name\n");
goto out;
}
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "s", &cluster);
if (ret != 1) {
ErrPrint("Invalid parameters\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
DbgPrint("pid[%d] cluster[%s]\n", pid, cluster);
- if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
+ if (!strlen(cluster) || !strcasecmp(cluster, DYNAMICBOX_CONF_DEFAULT_CLUSTER)) {
ErrPrint("Invalid cluster: %s\n", cluster);
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
/*!
* \todo
*/
- ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ ret = DBOX_STATUS_ERROR_NOT_IMPLEMENTED;
out:
result = packet_create_reply(packet, "i", ret);
slave_rpc_request_update(pkgname, "", c_name, s_name, NULL, force);
/* Just try to create a new package */
- if (util_free_space(IMAGE_PATH) > MINIMUM_SPACE) {
+ if (util_free_space(DYNAMICBOX_CONF_IMAGE_PATH) > DYNAMICBOX_CONF_MINIMUM_SPACE) {
double timestamp;
struct inst_info *inst;
* Because this callback is called by the requests of clients.
* It means. some clients wants to handle this instances ;)
*/
- inst = instance_create(NULL, timestamp, pkgname, "", c_name, s_name, DEFAULT_PERIOD, 0, 0);
+ inst = instance_create(NULL, timestamp, pkgname, "", c_name, s_name, DYNAMICBOX_CONF_DEFAULT_PERIOD, 0, 0);
if (!inst) {
ErrPrint("Failed to create a new instance\n");
}
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster_id, category_id);
- if (!strlen(cluster_id) || !strcasecmp(cluster_id, DEFAULT_CLUSTER)) {
+ if (!strlen(cluster_id) || !strcasecmp(cluster_id, DYNAMICBOX_CONF_DEFAULT_CLUSTER)) {
ErrPrint("Invalid cluster name: %s\n", cluster_id);
goto out;
}
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ss", &cluster, &category);
if (ret != 2) {
ErrPrint("Invalid paramenters\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
DbgPrint("pid[%d] cluster[%s] category[%s]\n", pid, cluster, category);
- if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
+ if (!strlen(cluster) || !strcasecmp(cluster, DYNAMICBOX_CONF_DEFAULT_CLUSTER)) {
ErrPrint("Invalid cluster: %s\n", cluster);
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
/*!
* \todo
*/
- ret = LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ ret = DBOX_STATUS_ERROR_NOT_IMPLEMENTED;
out:
result = packet_create_reply(packet, "i", ret);
client = client_find_by_rpc_handle(handle);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
ret = packet_get(packet, "ss", &cluster, &category);
if (ret != 2) {
ErrPrint("Invalid argument\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
DbgPrint("[%d] cluster[%s] category[%s]\n", pid, cluster, category);
- if (!strlen(cluster) || !strcasecmp(cluster, DEFAULT_CLUSTER)) {
+ if (!strlen(cluster) || !strcasecmp(cluster, DYNAMICBOX_CONF_DEFAULT_CLUSTER)) {
ErrPrint("Invalid cluster name: %s\n", cluster);
goto out;
}
}
if (!slave) {
- if (DEBUG_MODE) {
+ if (DYNAMICBOX_CONF_DEBUG_MODE || g_conf.debug_mode) {
char pkgname[pathconf("/", _PC_PATH_MAX)];
const char *abi;
if (!slave) {
abi = abi_find_by_pkgname(pkgname);
if (!abi) {
- abi = DEFAULT_ABI;
+ abi = DYNAMICBOX_CONF_DEFAULT_ABI;
DbgPrint("Slave pkgname is invalid, ABI is replaced with '%s'(default)\n", abi);
}
- slave = slave_create(slavename, 1, abi, pkgname, 0);
+ slave = slave_create(slavename, 1, abi, pkgname, 0, NULL);
if (!slave) {
ErrPrint("Failed to create a new slave for %s\n", slavename);
goto out;
abi = slave_abi(slave);
if (!abi) {
ErrPrint("ABI is not valid: %s\n", slavename);
- abi = DEFAULT_ABI;
+ abi = DYNAMICBOX_CONF_DEFAULT_ABI;
}
}
if (slave_pid(slave) > 0) {
CRITICAL_LOG("Slave(%s) is already assigned to %d\n", slave_name(slave), slave_pid(slave));
if (pid > 0) {
- ret = aul_terminate_pid(pid);
+ ret = aul_terminate_pid_async(pid);
CRITICAL_LOG("Terminate %d (ret: %d)\n", pid, ret);
}
goto out;
return NULL;
}
-static struct packet *slave_lb_update_begin(pid_t pid, int handle, const struct packet *packet)
+static struct packet *slave_dbox_update_begin(pid_t pid, int handle, const struct packet *packet)
{
struct slave_node *slave;
struct inst_info *inst;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = instance_lb_update_begin(inst, priority, content, title);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = instance_dbox_update_begin(inst, priority, content, title);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
slave_freeze_ttl(slave);
}
} else {
return NULL;
}
-static struct packet *slave_lb_update_end(pid_t pid, int handle, const struct packet *packet)
+static struct packet *slave_dbox_update_end(pid_t pid, int handle, const struct packet *packet)
{
struct slave_node *slave;
struct inst_info *inst;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
goto out;
}
- if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
- ret = instance_lb_update_end(inst);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ ret = instance_dbox_update_end(inst);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
slave_thaw_ttl(slave);
}
} else {
return NULL;
}
-static struct packet *slave_pd_update_begin(pid_t pid, int handle, const struct packet *packet)
+static struct packet *slave_gbar_update_begin(pid_t pid, int handle, const struct packet *packet)
{
struct slave_node *slave;
const struct pkg_info *pkg;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- (void)instance_pd_update_begin(inst);
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ (void)instance_gbar_update_begin(inst);
} else {
ErrPrint("Invalid request[%s]\n", id);
}
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
} else {
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
} else {
return NULL;
}
-static struct packet *slave_close_pd(pid_t pid, int handle, const struct packet *packet)
+static struct packet *slave_close_gbar(pid_t pid, int handle, const struct packet *packet)
{
struct slave_node *slave;
struct inst_info *inst;
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
} else {
return NULL;
}
-static struct packet *slave_pd_update_end(pid_t pid, int handle, const struct packet *packet)
+static struct packet *slave_gbar_update_end(pid_t pid, int handle, const struct packet *packet)
{
struct slave_node *slave;
const struct pkg_info *pkg;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
goto out;
}
- if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
- (void)instance_pd_update_end(inst);
+ if (package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ (void)instance_gbar_update_end(inst);
} else {
ErrPrint("Invalid request[%s]\n", id);
}
return NULL;
}
-static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, priority, ret */
+static struct packet *slave_extra_info(pid_t pid, int handle, const struct packet *packet)
{
struct slave_node *slave;
const char *pkgname;
- const char *safe_filename;
const char *id;
const char *content_info;
const char *title;
const char *icon;
const char *name;
- int w;
- int h;
double priority;
int ret;
struct inst_info *inst;
goto out;
}
- ret = packet_get(packet, "ssiidsssss", &pkgname, &id,
- &w, &h, &priority,
- &content_info, &title,
- &safe_filename, &icon, &name);
- if (ret != 10) {
- ErrPrint("Parameter is not matched\n");
+ ret = packet_get(packet, "ssssssd", &pkgname, &id, &content_info, &title, &icon, &name, &priority);
+ if (ret != 7) {
+ ErrPrint("Parameter is not matchd\n");
goto out;
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
goto out;
}
- instance_set_lb_info(inst, priority, content_info, title);
+ instance_set_dbox_info(inst, priority, content_info, title);
instance_set_alt_info(inst, icon, name);
+ instance_extra_info_updated_by_instance(inst);
+ slave_give_more_ttl(slave);
+ }
+
+out:
+ return NULL;
+}
+
+static struct packet *slave_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, width, height, ret */
+{
+ struct slave_node *slave;
+ const char *pkgname;
+ const char *safe_filename;
+ const char *id;
+ int w;
+ int h;
+ int x;
+ int y;
+ int ret;
+ struct inst_info *inst;
+
+ slave = slave_find_by_pid(pid);
+ if (!slave) {
+ ErrPrint("Slave %d is not exists\n", pid);
+ goto out;
+ }
- switch (package_lb_type(instance_package(inst))) {
- case LB_TYPE_SCRIPT:
- script_handler_resize(instance_lb_script(inst), w, h);
+ ret = packet_get(packet, "sssiiii", &pkgname, &id, &safe_filename, &x, &y, &w, &h);
+ if (ret != 7) {
+ ErrPrint("Parameter is not matched\n");
+ goto out;
+ }
+
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ if (instance_state(inst) == INST_DESTROYED) {
+ ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
+ goto out;
+ }
+
+ switch (package_dbox_type(instance_package(inst))) {
+ case DBOX_TYPE_SCRIPT:
+ script_handler_resize(instance_dbox_script(inst), w, h);
if (safe_filename) {
(void)script_handler_parse_desc(inst, safe_filename, 0);
} else {
ErrPrint("unlink: %s - %s\n", strerror(errno), safe_filename);
}
break;
- case LB_TYPE_BUFFER:
+ case DBOX_TYPE_BUFFER:
default:
/*!
* \check
* text format (inst)
*/
- instance_set_lb_size(inst, w, h);
- instance_lb_updated_by_instance(inst, safe_filename);
+ instance_dbox_updated_by_instance(inst, safe_filename, x, y, w, h);
break;
}
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
} else {
return NULL;
}
+static struct packet *slave_extra_updated(pid_t pid, int handle, const struct packet *packet)
+{
+ struct slave_node *slave;
+ const char *pkgname;
+ const char *id;
+ int idx;
+ int x;
+ int y;
+ int w;
+ int h;
+ int ret;
+ int is_gbar;
+ struct inst_info *inst;
+
+ slave = slave_find_by_pid(pid);
+ if (!slave) {
+ ErrPrint("Slave %d is not exists\n", pid);
+ goto out;
+ }
+
+ ret = packet_get(packet, "ssiiiiii", &pkgname, &id, &is_gbar, &idx, &x, &y, &w, &h);
+ if (ret != 8) {
+ ErrPrint("Parameter is not matched\n");
+ goto out;
+ }
+
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto out;
+ }
+
+ if (instance_state(inst) == INST_DESTROYED) {
+ ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
+ goto out;
+ }
+
+ (void)instance_extra_updated_by_instance(inst, is_gbar, idx, x, y, w, h);
+out:
+ return NULL;
+}
+
static struct packet *slave_desc_updated(pid_t pid, int handle, const struct packet *packet) /* slave_name, pkgname, filename, decsfile, ret */
{
struct slave_node *slave;
const char *pkgname;
const char *id;
const char *descfile;
+ int x;
+ int y;
+ int w;
+ int h;
int ret;
struct inst_info *inst;
goto out;
}
- ret = packet_get(packet, "sss", &pkgname, &id, &descfile);
- if (ret != 3) {
+ ret = packet_get(packet, "sssiiii", &pkgname, &id, &descfile, &x, &y, &w, &h);
+ if (ret != 7) {
ErrPrint("Parameter is not matched\n");
goto out;
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
goto out;
}
- switch (package_pd_type(instance_package(inst))) {
- case PD_TYPE_SCRIPT:
+ switch (package_gbar_type(instance_package(inst))) {
+ case GBAR_TYPE_SCRIPT:
DbgPrint("%s updated (%s)\n", instance_id(inst), descfile);
- if (script_handler_is_loaded(instance_pd_script(inst))) {
+ if (script_handler_is_loaded(instance_gbar_script(inst))) {
(void)script_handler_parse_desc(inst, descfile, 1);
}
break;
- case PD_TYPE_TEXT:
- instance_set_pd_size(inst, 0, 0);
- case PD_TYPE_BUFFER:
- instance_pd_updated(pkgname, id, descfile);
+ case GBAR_TYPE_TEXT:
+ instance_set_gbar_size(inst, 0, 0);
+ case GBAR_TYPE_BUFFER:
+ instance_gbar_updated(pkgname, id, descfile, x, y, w, h);
break;
default:
DbgPrint("Ignore updated DESC(%s)\n", pkgname);
}
ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
- ret = instance_destroyed(inst, LB_STATUS_SUCCESS);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ ret = instance_destroyed(inst, DBOX_STATUS_ERROR_NONE);
}
out:
if (!slave) {
ErrPrint("Failed to find a slave\n");
id = "";
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
if (ret != 6) {
ErrPrint("Invalid argument\n");
id = "";
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
id = "";
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
goto out;
}
- if (target == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (target == TYPE_DBOX && package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
struct buffer_info *info;
- info = instance_lb_buffer(inst);
+ info = instance_dbox_buffer(inst);
if (!info) {
- if (!instance_create_lb_buffer(inst, pixel_size)) {
- ErrPrint("Failed to create a LB buffer\n");
- ret = LB_STATUS_ERROR_FAULT;
+ if (!instance_create_dbox_buffer(inst, pixel_size)) {
+ ErrPrint("Failed to create a DBOX buffer\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
- info = instance_lb_buffer(inst);
+ info = instance_dbox_buffer(inst);
if (!info) {
- ErrPrint("LB buffer is not valid\n");
+ ErrPrint("DBOX buffer is not valid\n");
/*!
* \NOTE
* ret value should not be changed.
ret = buffer_handler_resize(info, w, h);
ret = buffer_handler_load(info);
if (ret == 0) {
- instance_set_lb_size(inst, w, h);
- instance_set_lb_info(inst, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
+ instance_set_dbox_size(inst, w, h);
+ instance_set_dbox_info(inst, DYNAMICBOX_CONF_PRIORITY_NO_CHANGE, DYNAMICBOX_CONF_CONTENT_NO_CHANGE, DYNAMICBOX_CONF_TITLE_NO_CHANGE);
id = buffer_handler_id(info);
} else {
ErrPrint("Failed to load a buffer(%d)\n", ret);
}
- } else if (target == TYPE_PD && package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ } else if (target == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
struct buffer_info *info;
- Ecore_Timer *pd_monitor;
+ Ecore_Timer *gbar_monitor;
int is_resize;
is_resize = 0;
- pd_monitor = instance_del_data(inst, PD_OPEN_MONITOR_TAG);
- if (!pd_monitor) {
- pd_monitor = instance_del_data(inst, PD_RESIZE_MONITOR_TAG);
- is_resize = !!pd_monitor;
+ gbar_monitor = instance_del_data(inst, GBAR_OPEN_MONITOR_TAG);
+ if (!gbar_monitor) {
+ gbar_monitor = instance_del_data(inst, GBAR_RESIZE_MONITOR_TAG);
+ is_resize = !!gbar_monitor;
if (!is_resize) {
/* Invalid request. Reject this */
ErrPrint("Invalid request\n");
slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_open_buffer_cb, inst);
}
- ecore_timer_del(pd_monitor);
+ ecore_timer_del(gbar_monitor);
inst = instance_unref(inst);
if (!inst) {
ErrPrint("Instance refcnt is ZERO: %s\n", pkgname);
goto out;
}
- info = instance_pd_buffer(inst);
+ info = instance_gbar_buffer(inst);
if (!info) {
- if (!instance_create_pd_buffer(inst, pixel_size)) {
- ErrPrint("Failed to create a PD buffer\n");
- ret = LB_STATUS_ERROR_FAULT;
- instance_client_pd_created(inst, ret);
+ if (!instance_create_gbar_buffer(inst, pixel_size)) {
+ ErrPrint("Failed to create a GBAR buffer\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ instance_client_gbar_created(inst, ret);
goto out;
}
- info = instance_pd_buffer(inst);
+ info = instance_gbar_buffer(inst);
if (!info) {
- ErrPrint("PD buffer is not valid\n");
+ ErrPrint("GBAR buffer is not valid\n");
/*!
* \NOTE
* ret value should not be changed.
*/
- instance_client_pd_created(inst, ret);
+ instance_client_gbar_created(inst, ret);
goto out;
}
}
ret = buffer_handler_resize(info, w, h);
ret = buffer_handler_load(info);
if (ret == 0) {
- instance_set_pd_size(inst, w, h);
+ instance_set_gbar_size(inst, w, h);
id = buffer_handler_id(info);
} else {
ErrPrint("Failed to load a buffer (%d)\n", ret);
}
/*!
- * Send the PD created event to the client
+ * Send the GBAR created event to the client
*/
if (!is_resize) {
- instance_client_pd_created(inst, ret);
+ instance_client_gbar_created(inst, ret);
}
}
out:
result = packet_create_reply(packet, "is", ret, id);
if (!result) {
- ErrPrint("Failed to create a packet\n");
+ ErrPrint("Failed to create a reply packet\n");
}
return result;
}
-static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
+static struct packet *slave_acquire_extra_buffer(pid_t pid, int handle, const struct packet *packet)
{
struct slave_node *slave;
+ struct inst_info *inst;
struct packet *result;
- enum target_type type;
+ const struct pkg_info *pkg;
const char *pkgname;
const char *id;
+ int pixel_size;
+ int target;
+ int idx;
+ int ret;
int w;
int h;
- struct inst_info *inst = NULL;
- const struct pkg_info *pkg = NULL;
- int ret;
slave = slave_find_by_pid(pid);
if (!slave) {
- ErrPrint("Failed to find a slave\n");
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ErrPrint("Slave %d is not exists\n", pid);
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
id = "";
goto out;
}
- ret = packet_get(packet, "issii", &type, &pkgname, &id, &w, &h);
- if (ret != 5) {
- ErrPrint("Invalid argument\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = packet_get(packet, "issiiii", &target, &pkgname, &id, &w, &h, &pixel_size, &idx);
+ if (ret != 7) {
+ ErrPrint("Invalid parameters\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
id = "";
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
id = "";
- if (ret != LB_STATUS_SUCCESS) {
+
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- ret = LB_STATUS_ERROR_INVALID;
- /*!
- * \note
- * Reset "id", It will be re-used from here
- */
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
if (instance_state(inst) == INST_DESTROYED) {
ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
goto out;
}
- if (type == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (target == TYPE_DBOX && package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
struct buffer_info *info;
- info = instance_lb_buffer(inst);
+ info = instance_dbox_extra_buffer(inst, idx);
if (!info) {
- goto out;
+ if (!instance_create_dbox_extra_buffer(inst, pixel_size, idx)) {
+ ErrPrint("Failed to create a DBOX buffer\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto out;
+ }
+
+ info = instance_dbox_extra_buffer(inst, idx);
+ if (!info) {
+ ErrPrint("DBOX extra buffer is not valid\n");
+ /*!
+ * \NOTE
+ * ret value should not be changed.
+ */
+ goto out;
+ }
}
ret = buffer_handler_resize(info, w, h);
- /*!
- * \note
- * id is resued for newly assigned ID
- */
- if (ret == (int)LB_STATUS_SUCCESS) {
+ ret = buffer_handler_load(info);
+ if (ret == 0) {
+ /**
+ * @todo
+ * Send the extra buffer info to the viewer.
+ * Then the viewer will try to acquire extra pixmap(aka, resource id) information
+ */
id = buffer_handler_id(info);
- instance_set_lb_size(inst, w, h);
- instance_set_lb_info(inst, PRIORITY_NO_CHANGE, CONTENT_NO_CHANGE, TITLE_NO_CHANGE);
+ DbgPrint("Extra buffer is loaded: %s\n", id);
+ (void)instance_client_dbox_extra_buffer_created(inst, idx);
+ } else {
+ ErrPrint("Failed to load a buffer(%d)\n", ret);
}
- } else if (type == TYPE_PD && package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ } else if (target == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
struct buffer_info *info;
- info = instance_pd_buffer(inst);
+ info = instance_gbar_extra_buffer(inst, idx);
if (!info) {
- goto out;
- }
+ if (!instance_create_gbar_extra_buffer(inst, pixel_size, idx)) {
+ ErrPrint("Failed to create a GBAR buffer\n");
+ ret = DBOX_STATUS_ERROR_FAULT;
+ goto out;
+ }
+
+ info = instance_gbar_extra_buffer(inst, idx);
+ if (!info) {
+ ErrPrint("GBAR buffer is not valid\n");
+ /*!
+ * \NOTE
+ * ret value should not be changed.
+ */
+ goto out;
+ }
+ }
+
+ ret = buffer_handler_resize(info, w, h);
+ ret = buffer_handler_load(info);
+ if (ret == 0) {
+ id = buffer_handler_id(info);
+ /**
+ * @todo
+ * Send the extra buffer acquired event to the viewer
+ */
+ DbgPrint("Extra buffer is loaded: %s\n", id);
+ (void)instance_client_gbar_extra_buffer_created(inst, idx);
+ } else {
+ ErrPrint("Failed to load a buffer (%d)\n", ret);
+ }
+ }
+
+out:
+ result = packet_create_reply(packet, "is", ret, id);
+ if (!result) {
+ ErrPrint("Failed to create a reply packet\n");
+ }
+
+ return result;
+}
+
+static struct packet *slave_resize_buffer(pid_t pid, int handle, const struct packet *packet)
+{
+ struct slave_node *slave;
+ struct packet *result;
+ enum target_type type;
+ const char *pkgname;
+ const char *id;
+ int w;
+ int h;
+ struct inst_info *inst = NULL;
+ const struct pkg_info *pkg = NULL;
+ int ret;
+
+ slave = slave_find_by_pid(pid);
+ if (!slave) {
+ ErrPrint("Failed to find a slave\n");
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ id = "";
+ goto out;
+ }
+
+ ret = packet_get(packet, "issii", &type, &pkgname, &id, &w, &h);
+ if (ret != 5) {
+ ErrPrint("Invalid argument\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ id = "";
+ goto out;
+ }
+
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ id = "";
+
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto out;
+ }
+
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ /*!
+ * \note
+ * Reset "id", It will be re-used from here
+ */
+
+ if (instance_state(inst) == INST_DESTROYED) {
+ ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
+ goto out;
+ }
+
+ if (type == TYPE_DBOX && package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ struct buffer_info *info;
+
+ info = instance_dbox_buffer(inst);
+ if (!info) {
+ goto out;
+ }
+
+ ret = buffer_handler_resize(info, w, h);
+ /*!
+ * \note
+ * id is resued for newly assigned ID
+ */
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ id = buffer_handler_id(info);
+ instance_set_dbox_size(inst, w, h);
+ instance_set_dbox_info(inst, DYNAMICBOX_CONF_PRIORITY_NO_CHANGE, DYNAMICBOX_CONF_CONTENT_NO_CHANGE, DYNAMICBOX_CONF_TITLE_NO_CHANGE);
+ }
+ } else if (type == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ struct buffer_info *info;
+
+ info = instance_gbar_buffer(inst);
+ if (!info) {
+ goto out;
+ }
ret = buffer_handler_resize(info, w, h);
/*!
* \note
* id is resued for newly assigned ID
*/
- if (ret == (int)LB_STATUS_SUCCESS) {
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
id = buffer_handler_id(info);
- instance_set_pd_size(inst, w, h);
+ instance_set_gbar_size(inst, w, h);
}
}
slave = slave_find_by_pid(pid);
if (!slave) {
ErrPrint("Failed to find a slave\n");
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
goto out;
}
if (packet_get(packet, "iss", &type, &pkgname, &id) != 3) {
ErrPrint("Inavlid argument\n");
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
goto out;
}
ret = validate_request(pkgname, id, &inst, &pkg);
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto out;
}
- ret = LB_STATUS_ERROR_INVALID;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
- if (type == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (type == TYPE_DBOX && package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
struct buffer_info *info;
- info = instance_lb_buffer(inst);
+ info = instance_dbox_buffer(inst);
ret = buffer_handler_unload(info);
- } else if (type == TYPE_PD && package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ } else if (type == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
struct buffer_info *info;
- Ecore_Timer *pd_monitor;
+ Ecore_Timer *gbar_monitor;
- pd_monitor = instance_del_data(inst, PD_CLOSE_MONITOR_TAG);
- if (!pd_monitor && !package_is_fault(pkg)) {
+ gbar_monitor = instance_del_data(inst, GBAR_CLOSE_MONITOR_TAG);
+ if (!gbar_monitor && !package_is_fault(pkg)) {
ErrPrint("Slave requests to release a buffer\n");
- /*!
- * \note
+ /**
+ * @note
* In this case just keep going to release buffer,
- * Even if a user(client) doesn't wants to destroy the PD.
+ * Even if a user(client) doesn't wants to destroy the GBAR.
*
- * If the slave tries to destroy PD buffer, it should be
+ * If the slave tries to destroy GBAR buffer, it should be
* released and reported to the client about its status.
*
* Even if the pd is destroyed by timeout handler,
- * instance_client_pd_destroyed function will be ignored
+ * instance_client_gbar_destroyed function will be ignored
* by pd.need_to_send_close_event flag.
- * which will be checked by instance_client_pd_destroyed function.
+ * which will be checked by instance_client_gbar_destroyed function.
*/
- /*!
- * \note
+ /**
+ * @note
* provider can try to resize the buffer size.
* in that case, it will release the buffer first.
- * Then even though the client doesn't request to close the PD,
+ * Then even though the client doesn't request to close the GBAR,
* the provider can release it.
* If we send the close event to the client,
- * The client will not able to allocate PD again.
+ * The client will not able to allocate GBAR again.
* In this case, add the pd,monitor again. from here.
* to wait the re-allocate buffer.
* If the client doesn't request buffer reallocation,
- * Treat it as a fault. and close the PD.
+ * Treat it as a fault. and close the GBAR.
*/
- info = instance_pd_buffer(inst);
+ info = instance_gbar_buffer(inst);
ret = buffer_handler_unload(info);
- if (ret == (int)LB_STATUS_SUCCESS) {
- pd_monitor = ecore_timer_add(PD_REQUEST_TIMEOUT, pd_resize_monitor_cb, instance_ref(inst));
- if (!pd_monitor) {
- ErrPrint("Failed to create a timer for PD Open monitor\n");
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ gbar_monitor = ecore_timer_add(DYNAMICBOX_CONF_GBAR_REQUEST_TIMEOUT, gbar_resize_monitor_cb, instance_ref(inst));
+ if (!gbar_monitor) {
+ ErrPrint("Failed to create a timer for GBAR Open monitor\n");
inst = instance_unref(inst);
if (!inst) {
DbgPrint("Instance is deleted\n");
}
} else {
- (void)instance_set_data(inst, PD_RESIZE_MONITOR_TAG, pd_monitor);
- if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst) != LB_STATUS_SUCCESS) {
+ (void)instance_set_data(inst, GBAR_RESIZE_MONITOR_TAG, gbar_monitor);
+ if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_resize_buffer_cb, inst) != DBOX_STATUS_ERROR_NONE) {
ErrPrint("Failed to add event handler: %s\n", pkgname);
}
}
}
} else {
- if (pd_monitor) {
- /*!
- * \note
- * If the instance has pd_monitor, the pd close requested from client via client_destroy_pd.
+ if (gbar_monitor) {
+ /**
+ * @note
+ * If the instance has gbar_monitor, the pd close requested from client via client_destroy_gbar.
*/
slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_fault_close_buffer_cb, inst);
- ecore_timer_del(pd_monitor);
+ ecore_timer_del(gbar_monitor);
inst = instance_unref(inst);
if (!inst) {
ErrPrint("Instance is released: %s\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
goto out;
}
} /* else {
- \note
- This case means that the package is faulted so the service provider tries to release the buffer
- */
+ @note
+ This case means that the package is faulted so the service provider tries to release the buffer
+ */
- info = instance_pd_buffer(inst);
+ info = instance_gbar_buffer(inst);
ret = buffer_handler_unload(info);
- /*!
- * \note
- * Send the PD destroyed event to the client
+ /**
+ * @note
+ * Send the GBAR destroyed event to the client
*/
- instance_client_pd_destroyed(inst, ret);
+ instance_client_gbar_destroyed(inst, ret);
+ }
}
- }
out:
- result = packet_create_reply(packet, "i", ret);
- if (!result) {
- ErrPrint("Failed to create a packet\n");
+ result = packet_create_reply(packet, "i", ret);
+ if (!result) {
+ ErrPrint("Failed to create a packet\n");
+ }
+
+ return result;
}
- return result;
-}
+ static struct packet *slave_release_extra_buffer(pid_t pid, int handle, const struct packet *packet)
+ {
+ struct slave_node *slave;
+ struct packet *result;
+ const char *id;
+ struct buffer_info *info = NULL;
+ int ret;
+ int idx;
+ int type;
+ const char *pkgname;
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
-static struct packet *service_change_period(pid_t pid, int handle, const struct packet *packet)
-{
- struct inst_info *inst;
- struct packet *result;
- const char *pkgname;
- const char *id;
- double period;
- int ret;
+ slave = slave_find_by_pid(pid);
+ if (!slave) {
+ ErrPrint("Slave %d is not exists\n", pid);
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ goto out;
+ }
- ret = packet_get(packet, "ssd", &pkgname, &id, &period);
- if (ret != 3) {
- ErrPrint("Invalid packet\n");
- ret = LB_STATUS_ERROR_INVALID;
- goto out;
- }
+ if (packet_get(packet, "issi", &type, &pkgname, &id, &idx) != 4) {
+ ErrPrint("Inavlid argument\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
- if (!strlen(id)) {
- struct pkg_info *pkg;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != DBOX_STATUS_ERROR_NONE) {
+ goto out;
+ }
- pkg = package_find(pkgname);
- if (!pkg) {
- ret = LB_STATUS_ERROR_NOT_EXIST;
- } else if (package_is_fault(pkg)) {
- ret = LB_STATUS_ERROR_FAULT;
- } else {
- Eina_List *inst_list;
- Eina_List *l;
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
- inst_list = package_instance_list(pkg);
- EINA_LIST_FOREACH(inst_list, l, inst) {
- ret = instance_set_period(inst, period);
- if (ret < 0) {
- ErrPrint("Failed to change the period of %s to (%lf)\n", pkgname, period);
- }
- }
+ if (type == TYPE_DBOX && package_dbox_type(pkg) == DBOX_TYPE_BUFFER) {
+ info = instance_dbox_extra_buffer(inst, idx);
+ (void)instance_client_dbox_extra_buffer_destroyed(inst, idx);
+ } else if (type == TYPE_GBAR && package_gbar_type(pkg) == GBAR_TYPE_BUFFER) {
+ info = instance_gbar_extra_buffer(inst, idx);
+ (void)instance_client_gbar_extra_buffer_destroyed(inst, idx);
}
- } else {
- ret = validate_request(pkgname, id, &inst, NULL);
- if (ret == (int)LB_STATUS_SUCCESS) {
- if (instance_state(inst) == INST_DESTROYED) {
- ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
- ret = LB_STATUS_ERROR_INVALID;
- goto out;
- }
- ret = instance_set_period(inst, period);
+ if (info) {
+ ret = buffer_handler_unload(info);
}
- }
- DbgPrint("Change the update period: %s, %lf : %d\n", pkgname, period, ret);
out:
- result = packet_create_reply(packet, "i", ret);
- if (!result) {
- ErrPrint("Failed to create a packet\n");
- }
-
- return result;
-}
-
-static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
-{
- Eina_List *inst_list;
- struct pkg_info *pkg;
- struct packet *result;
- const char *pkgname;
- const char *id;
- const char *cluster;
- const char *category;
- const char *content;
- int force;
- char *lbid;
- int ret;
+ result = packet_create_reply(packet, "i", ret);
+ if (!result) {
+ ErrPrint("Failed to create a reply packet\n");
+ }
- ret = packet_get(packet, "sssssi", &pkgname, &id, &cluster, &category, &content, &force);
- if (ret != 6) {
- ErrPrint("Invalid Packet\n");
- ret = LB_STATUS_ERROR_INVALID;
- goto out;
+ return result;
}
- lbid = package_lb_pkgname(pkgname);
- if (!lbid) {
- ErrPrint("Invalid package %s\n", pkgname);
- ret = LB_STATUS_ERROR_INVALID;
- goto out;
- }
+ static struct packet *service_instance_count(pid_t pid, int handle, const struct packet *packet)
+ {
+ struct packet *result;
+ struct pkg_info *pkg;
+ double timestamp;
+ const char *pkgname;
+ const char *cluster;
+ const char *category;
+ Eina_List *pkg_list;
+ Eina_List *l;
+ Eina_List *inst_list;
+ Eina_List *inst_l;
+ struct inst_info *inst;
+ int ret;
- pkg = package_find(lbid);
- if (!pkg) {
- ret = LB_STATUS_ERROR_NOT_EXIST;
- DbgFree(lbid);
- goto out;
- }
+ ret = packet_get(packet, "sssd", &pkgname, &cluster, &category, ×tamp);
+ if (ret != 4) {
+ ErrPrint("Invalid packet\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
- if (package_is_fault(pkg)) {
- ret = LB_STATUS_ERROR_FAULT;
- DbgFree(lbid);
- goto out;
- }
+ pkg_list = (Eina_List *)package_list();
- inst_list = package_instance_list(pkg);
- if (!eina_list_count(inst_list)) {
- ret = LB_STATUS_ERROR_NOT_EXIST;
- DbgFree(lbid);
- goto out;
- }
+ ret = 0;
+ EINA_LIST_FOREACH(pkg_list, l, pkg) {
+ if (pkgname && pkgname[0]) {
+ if (strcmp(package_name(pkg), pkgname)) {
+ continue;
+ }
+ }
- if (id && strlen(id)) {
- Eina_List *l;
- struct inst_info *inst;
+ inst_list = package_instance_list(pkg);
+ EINA_LIST_FOREACH(inst_list, inst_l, inst) {
+ if (cluster && cluster[0]) {
+ if (strcmp(instance_cluster(inst), cluster)) {
+ continue;
+ }
+ }
- ret = LB_STATUS_ERROR_NOT_EXIST;
- EINA_LIST_FOREACH(inst_list, l, inst) {
- if (!strcmp(instance_id(inst), id)) {
- ret = LB_STATUS_SUCCESS;
- break;
+ if (category && category[0]) {
+ if (strcmp(instance_category(inst), category)) {
+ continue;
+ }
+ }
+
+ ret++;
}
}
- if (ret == (int)LB_STATUS_ERROR_NOT_EXIST) {
- DbgFree(lbid);
- goto out;
+out:
+ result = packet_create_reply(packet, "i", ret);
+ if (!result) {
+ ErrPrint("Failed to create a packet\n");
}
- }
-
- /*!
- * \TODO
- * Validate the update requstor.
- */
- slave_rpc_request_update(lbid, id, cluster, category, content, force);
- DbgFree(lbid);
- ret = LB_STATUS_SUCCESS;
-out:
- result = packet_create_reply(packet, "i", ret);
- if (!result) {
- ErrPrint("Failed to create a packet\n");
+ return result;
}
- return result;
-}
-
-static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet *packet)
-{
- struct liveinfo *info;
- struct packet *result;
- int ret;
- const char *fifo_name;
- double timestamp;
+ static struct packet *service_change_period(pid_t pid, int handle, const struct packet *packet)
+ {
+ struct inst_info *inst;
+ struct packet *result;
+ const char *pkgname;
+ const char *id;
+ double period;
+ int ret;
- DbgPrint("Request arrived from %d\n", pid);
+ ret = packet_get(packet, "ssd", &pkgname, &id, &period);
+ if (ret != 3) {
+ ErrPrint("Invalid packet\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
- if (packet_get(packet, "d", ×tamp) != 1) {
- ErrPrint("Invalid packet\n");
- fifo_name = "";
- ret = LB_STATUS_ERROR_INVALID;
- goto out;
- }
+ if (!strlen(id)) {
+ struct pkg_info *pkg;
- info = liveinfo_create(pid, handle);
- if (!info) {
- ErrPrint("Failed to create a liveinfo object\n");
- fifo_name = "";
- ret = LB_STATUS_ERROR_INVALID;
- goto out;
- }
+ pkg = package_find(pkgname);
+ if (!pkg) {
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ } else if (package_is_fault(pkg)) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ } else {
+ Eina_List *inst_list;
+ Eina_List *l;
+
+ inst_list = package_instance_list(pkg);
+ EINA_LIST_FOREACH(inst_list, l, inst) {
+ ret = instance_set_period(inst, period);
+ if (ret < 0) {
+ ErrPrint("Failed to change the period of %s to (%lf)\n", pkgname, period);
+ }
+ }
+ }
+ } else {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == (int)DBOX_STATUS_ERROR_NONE) {
+ if (instance_state(inst) == INST_DESTROYED) {
+ ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
- ret = 0;
- fifo_name = liveinfo_filename(info);
- DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
+ ret = instance_set_period(inst, period);
+ }
+ }
+ DbgPrint("Change the update period: %s, %lf : %d\n", pkgname, period, ret);
out:
- result = packet_create_reply(packet, "si", fifo_name, ret);
- if (!result) {
- ErrPrint("Failed to create a result packet\n");
+ result = packet_create_reply(packet, "i", ret);
+ if (!result) {
+ ErrPrint("Failed to create a packet\n");
+ }
+
+ return result;
}
- return result;
-}
+ static struct packet *service_update(pid_t pid, int handle, const struct packet *packet)
+ {
+ Eina_List *inst_list;
+ struct pkg_info *pkg;
+ struct packet *result;
+ const char *pkgname;
+ const char *id;
+ const char *cluster;
+ const char *category;
+ const char *content;
+ int force;
+ char *lbid;
+ int ret;
-static Eina_Bool lazy_slave_list_cb(void *info)
-{
- FILE *fp;
- Eina_List *list;
- Eina_List *l;
- struct slave_node *slave;
+ ret = packet_get(packet, "sssssi", &pkgname, &id, &cluster, &category, &content, &force);
+ if (ret != 6) {
+ ErrPrint("Invalid Packet\n");
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
- liveinfo_open_fifo(info);
- fp = liveinfo_fifo(info);
- if (!fp) {
- liveinfo_close_fifo(info);
- return ECORE_CALLBACK_CANCEL;
- }
+ lbid = package_dbox_pkgname(pkgname);
+ if (!lbid) {
+ ErrPrint("Invalid package %s\n", pkgname);
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
- list = (Eina_List *)slave_list();
- EINA_LIST_FOREACH(list, l, slave) {
- fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n",
- slave_pid(slave),
- slave_name(slave),
- slave_pkgname(slave),
- slave_abi(slave),
- slave_is_secured(slave),
- slave_refcnt(slave),
- slave_fault_count(slave),
- slave_state_string(slave),
- slave_loaded_instance(slave),
- slave_loaded_package(slave),
- slave_ttl(slave)
- );
- }
-
- fprintf(fp, "EOD\n");
- liveinfo_close_fifo(info);
- return ECORE_CALLBACK_CANCEL;
-}
+ pkg = package_find(lbid);
+ if (!pkg) {
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ DbgFree(lbid);
+ goto out;
+ }
-static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct packet *packet)
-{
- struct liveinfo *info;
- double timestamp;
+ if (package_is_fault(pkg)) {
+ ret = DBOX_STATUS_ERROR_FAULT;
+ DbgFree(lbid);
+ goto out;
+ }
- if (packet_get(packet, "d", ×tamp) != 1) {
- ErrPrint("Invalid argument\n");
- goto out;
- }
+ inst_list = package_instance_list(pkg);
+ if (!eina_list_count(inst_list)) {
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ DbgFree(lbid);
+ goto out;
+ }
- info = liveinfo_find_by_pid(pid);
- if (!info) {
- ErrPrint("Invalid request\n");
- goto out;
- }
+ if (id && strlen(id)) {
+ Eina_List *l;
+ struct inst_info *inst;
+
+ ret = DBOX_STATUS_ERROR_NOT_EXIST;
+ EINA_LIST_FOREACH(inst_list, l, inst) {
+ if (!strcmp(instance_id(inst), id)) {
+ ret = DBOX_STATUS_ERROR_NONE;
+ break;
+ }
+ }
+
+ if (ret == (int)DBOX_STATUS_ERROR_NOT_EXIST) {
+ DbgFree(lbid);
+ goto out;
+ }
+ }
+
+ /*!
+ * \TODO
+ * Validate the update requstor.
+ */
+ slave_rpc_request_update(lbid, id, cluster, category, content, force);
+ DbgFree(lbid);
+ ret = DBOX_STATUS_ERROR_NONE;
- lazy_slave_list_cb(info);
out:
- return NULL;
-}
+ result = packet_create_reply(packet, "i", ret);
+ if (!result) {
+ ErrPrint("Failed to create a packet\n");
+ }
-static inline const char *visible_state_string(enum livebox_visible_state state)
-{
- switch (state) {
- case LB_SHOW:
- return "Show";
- case LB_HIDE:
- return "Hide";
- case LB_HIDE_WITH_PAUSE:
- return "Paused";
- default:
- break;
+ return result;
}
- return "Unknown";
-}
+ static struct packet *liveinfo_hello(pid_t pid, int handle, const struct packet *packet)
+ {
+ struct liveinfo *info;
+ struct packet *result;
+ int ret;
+ const char *fifo_name;
+ double timestamp;
-static Eina_Bool inst_list_cb(void *info)
-{
- FILE *fp;
- char *pkgname;
- struct pkg_info *pkg;
- Eina_List *l;
- Eina_List *inst_list;
- struct inst_info *inst;
+ DbgPrint("Request arrived from %d\n", pid);
- pkgname = liveinfo_data(info);
- if (!pkgname) {
- return ECORE_CALLBACK_CANCEL;
- }
+ if (packet_get(packet, "d", ×tamp) != 1) {
+ ErrPrint("Invalid packet\n");
+ fifo_name = "";
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
- liveinfo_open_fifo(info);
- fp = liveinfo_fifo(info);
- if (!fp) {
- ErrPrint("Invalid fp\n");
- liveinfo_close_fifo(info);
- free(pkgname);
- return ECORE_CALLBACK_CANCEL;
- }
+ info = liveinfo_create(pid, handle);
+ if (!info) {
+ ErrPrint("Failed to create a liveinfo object\n");
+ fifo_name = "";
+ ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ goto out;
+ }
- if (!package_is_lb_pkgname(pkgname)) {
- ErrPrint("Invalid package name\n");
- free(pkgname);
- goto close_out;
- }
+ ret = 0;
+ fifo_name = liveinfo_filename(info);
+ DbgPrint("FIFO Created: %s (Serve for %d)\n", fifo_name, pid);
- pkg = package_find(pkgname);
- free(pkgname);
- if (!pkg) {
- ErrPrint("Package is not exists\n");
- goto close_out;
+out:
+ result = packet_create_reply(packet, "si", fifo_name, ret);
+ if (!result) {
+ ErrPrint("Failed to create a result packet\n");
+ }
+
+ return result;
}
- inst_list = package_instance_list(pkg);
- EINA_LIST_FOREACH(inst_list, l, inst) {
- fprintf(fp, "%s %s %s %lf %s %d %d\n",
- instance_id(inst),
- instance_cluster(inst),
- instance_category(inst),
- instance_period(inst),
- visible_state_string(instance_visible_state(inst)),
- instance_lb_width(inst),
- instance_lb_height(inst));
+ static Eina_Bool lazy_slave_list_cb(void *info)
+ {
+ FILE *fp;
+ Eina_List *list;
+ Eina_List *l;
+ struct slave_node *slave;
+
+ liveinfo_open_fifo(info);
+ fp = liveinfo_fifo(info);
+ if (!fp) {
+ liveinfo_close_fifo(info);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ list = (Eina_List *)slave_list();
+ EINA_LIST_FOREACH(list, l, slave) {
+ fprintf(fp, "%d %s %s %s %d %d %d %s %d %d %lf\n",
+ slave_pid(slave),
+ slave_name(slave),
+ slave_pkgname(slave),
+ slave_abi(slave),
+ slave_is_secured(slave),
+ slave_refcnt(slave),
+ slave_fault_count(slave),
+ slave_state_string(slave),
+ slave_loaded_instance(slave),
+ slave_loaded_package(slave),
+ slave_ttl(slave)
+ );
+ }
+
+ fprintf(fp, "EOD\n");
+ liveinfo_close_fifo(info);
+ return ECORE_CALLBACK_CANCEL;
}
-close_out:
- fprintf(fp, "EOD\n");
- liveinfo_close_fifo(info);
+ static struct packet *liveinfo_slave_list(pid_t pid, int handle, const struct packet *packet)
+ {
+ struct liveinfo *info;
+ double timestamp;
- return ECORE_CALLBACK_CANCEL;
-}
+ if (packet_get(packet, "d", ×tamp) != 1) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
-static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct packet *packet)
-{
- const char *pkgname;
- char *dup_pkgname;
- struct liveinfo *info;
+ info = liveinfo_find_by_pid(pid);
+ if (!info) {
+ ErrPrint("Invalid request\n");
+ goto out;
+ }
- if (packet_get(packet, "s", &pkgname) != 1) {
- ErrPrint("Invalid argument\n");
- goto out;
+ lazy_slave_list_cb(info);
+out:
+ return NULL;
}
- info = liveinfo_find_by_pid(pid);
- if (!info) {
- ErrPrint("Invalid request\n");
- goto out;
- }
+ static inline const char *visible_state_string(enum dynamicbox_visible_state state)
+ {
+ switch (state) {
+ case DBOX_SHOW:
+ return "Show";
+ case DBOX_HIDE:
+ return "Hide";
+ case DBOX_HIDE_WITH_PAUSE:
+ return "Paused";
+ default:
+ break;
+ }
- dup_pkgname = strdup(pkgname);
- if (!dup_pkgname) {
- ErrPrint("Invalid request\n");
- goto out;
+ return "Unknown";
}
- liveinfo_set_data(info, dup_pkgname);
- inst_list_cb(info);
+ static Eina_Bool inst_list_cb(void *info)
+ {
+ FILE *fp;
+ char *pkgname;
+ struct pkg_info *pkg;
+ Eina_List *l;
+ Eina_List *inst_list;
+ struct inst_info *inst;
-out:
- return NULL;
-}
+ pkgname = liveinfo_data(info);
+ if (!pkgname) {
+ return ECORE_CALLBACK_CANCEL;
+ }
-static Eina_Bool pkg_list_cb(void *info)
-{
- FILE *fp;
- Eina_List *l;
- Eina_List *list;
- Eina_List *inst_list;
- struct pkg_info *pkg;
- struct slave_node *slave;
- const char *slavename;
- pid_t pid;
+ liveinfo_open_fifo(info);
+ fp = liveinfo_fifo(info);
+ if (!fp) {
+ ErrPrint("Invalid fp\n");
+ liveinfo_close_fifo(info);
+ free(pkgname);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (!package_is_dbox_pkgname(pkgname)) {
+ ErrPrint("Invalid package name\n");
+ free(pkgname);
+ goto close_out;
+ }
+
+ pkg = package_find(pkgname);
+ free(pkgname);
+ if (!pkg) {
+ ErrPrint("Package is not exists\n");
+ goto close_out;
+ }
- liveinfo_open_fifo(info);
- fp = liveinfo_fifo(info);
- if (!fp) {
- DbgPrint("Failed to open a pipe\n");
+ inst_list = package_instance_list(pkg);
+ EINA_LIST_FOREACH(inst_list, l, inst) {
+ fprintf(fp, "%s %s %s %s %lf %s %d %d\n",
+ instance_id(inst),
+ buffer_handler_id(instance_dbox_buffer(inst)),
+ instance_cluster(inst),
+ instance_category(inst),
+ instance_period(inst),
+ visible_state_string(instance_visible_state(inst)),
+ instance_dbox_width(inst),
+ instance_dbox_height(inst));
+ }
+
+close_out:
+ fprintf(fp, "EOD\n");
liveinfo_close_fifo(info);
+
return ECORE_CALLBACK_CANCEL;
}
- list = (Eina_List *)package_list();
- EINA_LIST_FOREACH(list, l, pkg) {
- slave = package_slave(pkg);
-
- if (slave) {
- slavename = slave_name(slave);
- pid = slave_pid(slave);
- } else {
- pid = (pid_t)-1;
- slavename = "";
- }
-
- inst_list = (Eina_List *)package_instance_list(pkg);
- fprintf(fp, "%d %s %s %s %d %d %d\n",
- pid,
- strlen(slavename) ? slavename : "(none)",
- package_name(pkg),
- package_abi(pkg),
- package_refcnt(pkg),
- package_fault_count(pkg),
- eina_list_count(inst_list)
- );
- DbgPrint("%d %s %s %s %d %d %d\n",
- pid,
- strlen(slavename) ? slavename : "(none)",
- package_name(pkg),
- package_abi(pkg),
- package_refcnt(pkg),
- package_fault_count(pkg),
- eina_list_count(inst_list)
- );
- }
-
- fprintf(fp, "EOD\n");
- DbgPrint("EOD\n");
- liveinfo_close_fifo(info);
- return ECORE_CALLBACK_CANCEL;
-}
+ static struct packet *liveinfo_inst_list(pid_t pid, int handle, const struct packet *packet)
+ {
+ const char *pkgname;
+ char *dup_pkgname;
+ struct liveinfo *info;
-static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct packet *packet)
-{
- struct liveinfo *info;
- double timestamp;
+ if (packet_get(packet, "s", &pkgname) != 1) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
- if (packet_get(packet, "d", ×tamp) != 1) {
- ErrPrint("Invalid argument\n");
- goto out;
- }
+ info = liveinfo_find_by_pid(pid);
+ if (!info) {
+ ErrPrint("Invalid request\n");
+ goto out;
+ }
- DbgPrint("Package List: %lf\n", timestamp);
+ dup_pkgname = strdup(pkgname);
+ if (!dup_pkgname) {
+ ErrPrint("Invalid request\n");
+ goto out;
+ }
- info = liveinfo_find_by_pid(pid);
- if (!info) {
- ErrPrint("Invalid request\n");
- goto out;
- }
+ liveinfo_set_data(info, dup_pkgname);
+ inst_list_cb(info);
- pkg_list_cb(info);
out:
- return NULL;
-}
+ return NULL;
+ }
-static struct packet *liveinfo_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
-{
- return NULL;
-}
+ static Eina_Bool pkg_list_cb(void *info)
+ {
+ FILE *fp;
+ Eina_List *l;
+ Eina_List *list;
+ Eina_List *inst_list;
+ struct pkg_info *pkg;
+ struct slave_node *slave;
+ const char *slavename;
+ pid_t pid;
-static Eina_Bool pkg_ctrl_rmpack_cb(void *info)
-{
- FILE *fp;
- liveinfo_open_fifo(info);
- fp = liveinfo_fifo(info);
- if (!fp) {
- liveinfo_close_fifo(info);
- return ECORE_CALLBACK_CANCEL;
- }
+ liveinfo_open_fifo(info);
+ fp = liveinfo_fifo(info);
+ if (!fp) {
+ DbgPrint("Failed to open a pipe\n");
+ liveinfo_close_fifo(info);
+ return ECORE_CALLBACK_CANCEL;
+ }
- fprintf(fp, "%d\n", ENOSYS);
- fprintf(fp, "EOD\n");
- liveinfo_close_fifo(info);
- return ECORE_CALLBACK_CANCEL;
-}
+ list = (Eina_List *)package_list();
+ EINA_LIST_FOREACH(list, l, pkg) {
+ slave = package_slave(pkg);
-static Eina_Bool pkg_ctrl_rminst_cb(void *info)
-{
- FILE *fp;
+ if (slave) {
+ slavename = slave_name(slave);
+ pid = slave_pid(slave);
+ } else {
+ pid = (pid_t)-1;
+ slavename = "";
+ }
- liveinfo_open_fifo(info);
- fp = liveinfo_fifo(info);
- if (!fp) {
+ inst_list = (Eina_List *)package_instance_list(pkg);
+ fprintf(fp, "%d %s %s %s %d %d %d\n",
+ pid,
+ strlen(slavename) ? slavename : "(none)",
+ package_name(pkg),
+ package_abi(pkg),
+ package_refcnt(pkg),
+ package_fault_count(pkg),
+ eina_list_count(inst_list)
+ );
+ DbgPrint("%d %s %s %s %d %d %d\n",
+ pid,
+ strlen(slavename) ? slavename : "(none)",
+ package_name(pkg),
+ package_abi(pkg),
+ package_refcnt(pkg),
+ package_fault_count(pkg),
+ eina_list_count(inst_list)
+ );
+ }
+
+ fprintf(fp, "EOD\n");
+ DbgPrint("EOD\n");
liveinfo_close_fifo(info);
return ECORE_CALLBACK_CANCEL;
}
- fprintf(fp, "%d\n", (int)liveinfo_data(info));
- fprintf(fp, "EOD\n");
- liveinfo_close_fifo(info);
- return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool pkg_ctrl_faultinst_cb(void *info)
-{
- FILE *fp;
+ static struct packet *liveinfo_pkg_list(pid_t pid, int handle, const struct packet *packet)
+ {
+ struct liveinfo *info;
+ double timestamp;
- liveinfo_open_fifo(info);
- fp = liveinfo_fifo(info);
- if (!fp) {
- liveinfo_close_fifo(info);
- return ECORE_CALLBACK_CANCEL;
- }
+ if (packet_get(packet, "d", ×tamp) != 1) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
- fprintf(fp, "%d\n", (int)liveinfo_data(info));
- fprintf(fp, "EOD\n");
- liveinfo_close_fifo(info);
- return ECORE_CALLBACK_CANCEL;
-}
+ DbgPrint("Package List: %lf\n", timestamp);
-static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
-{
- struct liveinfo *info;
- char *cmd;
- char *pkgname;
- char *id;
+ info = liveinfo_find_by_pid(pid);
+ if (!info) {
+ ErrPrint("Invalid request\n");
+ goto out;
+ }
- if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
- ErrPrint("Invalid argument\n");
- goto out;
+ pkg_list_cb(info);
+out:
+ return NULL;
}
- info = liveinfo_find_by_pid(pid);
- if (!info) {
- ErrPrint("Invalid request\n");
- goto out;
+ static struct packet *liveinfo_slave_ctrl(pid_t pid, int handle, const struct packet *packet)
+ {
+ return NULL;
}
- if (!strcmp(cmd, "rmpack")) {
- pkg_ctrl_rmpack_cb(info);
- } else if (!strcmp(cmd, "rminst")) {
- struct inst_info *inst;
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- liveinfo_set_data(info, (void *)ENOENT);
- } else {
- (void)instance_destroy(inst, INSTANCE_DESTROY_DEFAULT);
- liveinfo_set_data(info, (void *)0);
- }
-
- pkg_ctrl_rminst_cb(info);
- } else if (!strcmp(cmd, "faultinst")) {
- struct inst_info *inst;
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- liveinfo_set_data(info, (void *)ENOENT);
- } else {
- struct pkg_info *pkg;
-
- pkg = instance_package(inst);
- if (!pkg) {
- liveinfo_set_data(info, (void *)EFAULT);
- } else {
- (void)package_faulted(pkg, 1);
- liveinfo_set_data(info, (void *)0);
- }
+ static Eina_Bool pkg_ctrl_rmpack_cb(void *info)
+ {
+ FILE *fp;
+ liveinfo_open_fifo(info);
+ fp = liveinfo_fifo(info);
+ if (!fp) {
+ liveinfo_close_fifo(info);
+ return ECORE_CALLBACK_CANCEL;
}
- pkg_ctrl_faultinst_cb(info);
+ fprintf(fp, "%d\n", ENOSYS);
+ fprintf(fp, "EOD\n");
+ liveinfo_close_fifo(info);
+ return ECORE_CALLBACK_CANCEL;
}
-out:
- return NULL;
-}
+ static Eina_Bool pkg_ctrl_rminst_cb(void *info)
+ {
+ FILE *fp;
-static Eina_Bool master_ctrl_cb(void *info)
-{
- FILE *fp;
+ liveinfo_open_fifo(info);
+ fp = liveinfo_fifo(info);
+ if (!fp) {
+ liveinfo_close_fifo(info);
+ return ECORE_CALLBACK_CANCEL;
+ }
- liveinfo_open_fifo(info);
- fp = liveinfo_fifo(info);
- if (!fp) {
+ fprintf(fp, "%d\n", (int)liveinfo_data(info));
+ fprintf(fp, "EOD\n");
liveinfo_close_fifo(info);
return ECORE_CALLBACK_CANCEL;
}
- fprintf(fp, "%d\nEOD\n", (int)liveinfo_data(info));
- liveinfo_close_fifo(info);
- return ECORE_CALLBACK_CANCEL;
-}
+ static Eina_Bool pkg_ctrl_faultinst_cb(void *info)
+ {
+ FILE *fp;
-static struct packet *liveinfo_master_ctrl(pid_t pid, int handle, const struct packet *packet)
-{
- struct liveinfo *info;
- char *cmd;
- char *var;
- char *val;
- int ret = LB_STATUS_ERROR_INVALID;
+ liveinfo_open_fifo(info);
+ fp = liveinfo_fifo(info);
+ if (!fp) {
+ liveinfo_close_fifo(info);
+ return ECORE_CALLBACK_CANCEL;
+ }
- if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
- ErrPrint("Invalid argument\n");
- goto out;
+ fprintf(fp, "%d\n", (int)liveinfo_data(info));
+ fprintf(fp, "EOD\n");
+ liveinfo_close_fifo(info);
+ return ECORE_CALLBACK_CANCEL;
}
- info = liveinfo_find_by_pid(pid);
- if (!info) {
- ErrPrint("Invalid request\n");
- goto out;
- }
+ static struct packet *liveinfo_pkg_ctrl(pid_t pid, int handle, const struct packet *packet)
+ {
+ struct liveinfo *info;
+ char *cmd;
+ char *pkgname;
+ char *id;
- if (!strcasecmp(var, "debug")) {
- if (!strcasecmp(cmd, "set")) {
- g_conf.debug_mode = !strcasecmp(val, "on");
- } else if (!strcasecmp(cmd, "get")) {
+ if (packet_get(packet, "sss", &cmd, &pkgname, &id) != 3) {
+ ErrPrint("Invalid argument\n");
+ goto out;
}
- ret = g_conf.debug_mode;
- } else if (!strcasecmp(var, "slave_max_load")) {
- if (!strcasecmp(cmd, "set")) {
- g_conf.slave_max_load = atoi(val);
- } else if (!strcasecmp(cmd, "get")) {
+
+ info = liveinfo_find_by_pid(pid);
+ if (!info) {
+ ErrPrint("Invalid request\n");
+ goto out;
}
- ret = g_conf.slave_max_load;
- }
- liveinfo_set_data(info, (void *)ret);
- master_ctrl_cb(info);
+ if (!strcmp(cmd, "rmpack")) {
+ pkg_ctrl_rmpack_cb(info);
+ } else if (!strcmp(cmd, "rminst")) {
+ struct inst_info *inst;
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ liveinfo_set_data(info, (void *)ENOENT);
+ } else {
+ (void)instance_destroy(inst, DBOX_DESTROY_TYPE_DEFAULT);
+ liveinfo_set_data(info, (void *)0);
+ }
-out:
- return NULL;
-}
+ pkg_ctrl_rminst_cb(info);
+ } else if (!strcmp(cmd, "faultinst")) {
+ struct inst_info *inst;
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ liveinfo_set_data(info, (void *)ENOENT);
+ } else {
+ struct pkg_info *pkg;
-static struct method s_info_table[] = {
- {
- .cmd = "liveinfo_hello",
- .handler = liveinfo_hello,
- },
- {
- .cmd = "slave_list",
- .handler = liveinfo_slave_list,
- },
- {
- .cmd = "pkg_list",
- .handler = liveinfo_pkg_list,
- },
- {
- .cmd = "inst_list",
- .handler = liveinfo_inst_list,
- },
- {
- .cmd = "slave_ctrl",
- .handler = liveinfo_slave_ctrl,
- },
- {
- .cmd = "pkg_ctrl",
- .handler = liveinfo_pkg_ctrl,
- },
- {
- .cmd = "master_ctrl",
- .handler = liveinfo_master_ctrl,
- },
- {
- .cmd = NULL,
- .handler = NULL,
- },
-};
+ pkg = instance_package(inst);
+ if (!pkg) {
+ liveinfo_set_data(info, (void *)EFAULT);
+ } else {
+ (void)package_faulted(pkg, 1);
+ liveinfo_set_data(info, (void *)0);
+ }
+ }
-static struct method s_client_table[] = {
- {
- .cmd = "pd_mouse_move",
- .handler = client_pd_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
- },
- {
- .cmd = "lb_mouse_move",
- .handler = client_lb_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
- },
- {
- .cmd = "pd_mouse_down",
- .handler = client_pd_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
- },
- {
- .cmd = "pd_mouse_up",
- .handler = client_pd_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
- },
- {
- .cmd = "lb_mouse_down",
- .handler = client_lb_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
- },
- {
- .cmd = "lb_mouse_up",
- .handler = client_lb_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
- },
- {
- .cmd = "pd_mouse_enter",
- .handler = client_pd_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
- },
- {
- .cmd = "pd_mouse_leave",
- .handler = client_pd_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
- },
- {
- .cmd = "lb_mouse_enter",
- .handler = client_lb_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
- },
- {
- .cmd = "lb_mouse_leave",
- .handler = client_lb_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
- },
- {
- .cmd = "lb_mouse_set",
- .handler = client_lb_mouse_set,
- },
- {
- .cmd = "lb_mouse_unset",
- .handler = client_lb_mouse_unset,
- },
- {
- .cmd = "pd_mouse_set",
- .handler = client_pd_mouse_set,
- },
- {
- .cmd = "pd_mouse_unset",
- .handler = client_pd_mouse_unset,
- },
- {
- .cmd = "lb_mouse_on_scroll",
- .handler = client_lb_mouse_on_scroll,
- },
- {
- .cmd = "lb_mouse_off_scroll",
- .handler = client_lb_mouse_off_scroll,
- },
- {
- .cmd = "pd_mouse_on_scroll",
- .handler = client_pd_mouse_on_scroll,
- },
- {
- .cmd = "pd_mouse_off_scroll",
- .handler = client_pd_mouse_off_scroll,
- },
- {
- .cmd = "lb_mouse_on_hold",
- .handler = client_lb_mouse_on_hold,
- },
- {
- .cmd = "lb_mouse_off_hold",
- .handler = client_lb_mouse_off_hold,
- },
- {
- .cmd = "pd_mouse_on_hold",
- .handler = client_pd_mouse_on_hold,
- },
- {
- .cmd = "pd_mouse_off_hold",
- .handler = client_pd_mouse_off_hold,
- },
- {
- .cmd = "change,visibility",
- .handler = client_change_visibility,
- },
- {
- .cmd = "lb_acquire_pixmap",
- .handler = client_lb_acquire_pixmap,
- },
- {
- .cmd = "lb_release_pixmap",
- .handler = client_lb_release_pixmap,
- },
- {
- .cmd = "pd_acquire_pixmap",
- .handler = client_pd_acquire_pixmap,
- },
- {
- .cmd = "pd_release_pixmap",
- .handler = client_pd_release_pixmap,
- },
- {
- .cmd = "acquire",
- .handler = client_acquire, /*!< pid, ret */
- },
- {
- .cmd = "release",
- .handler = cilent_release, /*!< pid, ret */
- },
- {
- .cmd = "clicked",
- .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
- },
- {
- .cmd = "text_signal",
- .handler = client_text_signal, /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
- },
- {
- .cmd = "delete",
- .handler = client_delete, /* pid, pkgname, filename, ret */
- },
- {
- .cmd = "resize",
- .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
- },
- {
- .cmd = "new",
- .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
- },
- {
- .cmd = "set_period",
- .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
- },
- {
- .cmd = "change_group",
- .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
- },
- {
- .cmd = "pinup_changed",
- .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
- },
- {
- .cmd = "create_pd",
- .handler = client_create_pd, /* pid, pkgname, filename, ret */
- },
- {
- .cmd = "pd_move",
- .handler = client_pd_move, /* pkgname, id, x, y */
- },
- {
- .cmd = "destroy_pd",
- .handler = client_destroy_pd, /* pid, pkgname, filename, ret */
- },
- {
- .cmd = "activate_package",
- .handler = client_activate_package, /* pid, pkgname, ret */
- },
- {
- .cmd = "subscribe", /* pid, cluster, sub-cluster */
- .handler = client_subscribed,
- },
- {
- .cmd = "unsubscribe", /* pid, cluster, sub-cluster */
- .handler = client_unsubscribed,
- },
- {
- .cmd = "delete_cluster",
- .handler = client_delete_cluster,
- },
- {
- .cmd = "delete_category",
- .handler = client_delete_category,
- },
- {
- .cmd = "refresh_group",
- .handler = client_refresh_group,
- },
- {
- .cmd = "update",
- .handler = client_update,
- },
+ pkg_ctrl_faultinst_cb(info);
+ }
- {
- .cmd = "pd_access_hl",
- .handler = client_pd_access_hl,
- },
- {
- .cmd = "pd_access_hl_prev",
- .handler = client_pd_access_hl_prev,
- },
- {
- .cmd = "pd_access_hl_next",
- .handler = client_pd_access_hl_next,
- },
- {
- .cmd = "pd_access_activate",
- .handler = client_pd_access_activate,
- },
- {
- .cmd = "pd_access_action_up",
- .handler = client_pd_access_action_up,
- },
- {
- .cmd = "pd_access_action_down",
- .handler = client_pd_access_action_down,
- },
- {
- .cmd = "pd_access_unhighlight",
- .handler = client_pd_access_unhighlight,
- },
- {
- .cmd = "pd_access_scroll_down",
- .handler = client_pd_access_scroll_down,
- },
- {
- .cmd = "pd_access_scroll_move",
- .handler = client_pd_access_scroll_move,
- },
- {
- .cmd = "pd_access_scroll_up",
- .handler = client_pd_access_scroll_up,
- },
+out:
+ return NULL;
+ }
+ static Eina_Bool master_ctrl_cb(void *info)
{
- .cmd = "lb_access_hl",
- .handler = client_lb_access_hl,
- },
- {
- .cmd = "lb_access_hl_prev",
- .handler = client_lb_access_hl_prev,
- },
- {
- .cmd = "lb_access_hl_next",
- .handler = client_lb_access_hl_next,
- },
- {
- .cmd = "lb_access_activate",
- .handler = client_lb_access_activate,
- },
- {
- .cmd = "lb_access_action_up",
- .handler = client_lb_access_action_up,
- },
- {
- .cmd = "lb_access_action_down",
- .handler = client_lb_access_action_down,
- },
- {
- .cmd = "lb_access_unhighlight",
- .handler = client_lb_access_unhighlight,
- },
- {
- .cmd = "lb_access_scroll_down",
- .handler = client_lb_access_scroll_down,
- },
- {
- .cmd = "lb_access_scroll_move",
- .handler = client_lb_access_scroll_move,
- },
- {
- .cmd = "lb_access_scroll_up",
- .handler = client_lb_access_scroll_up,
- },
+ FILE *fp;
- {
- .cmd = "lb_key_down",
- .handler = client_lb_key_down,
- },
- {
- .cmd = "lb_key_up",
- .handler = client_lb_key_up,
- },
- {
- .cmd = "lb_key_focus_in",
- .handler = client_lb_key_focus_in,
- },
- {
- .cmd = "lb_key_focus_out",
- .handler = client_lb_key_focus_out,
- },
- {
- .cmd = "lb_key_set",
- .handler = client_lb_key_set,
- },
- {
- .cmd = "lb_key_unset",
- .handler = client_lb_key_unset,
- },
+ liveinfo_open_fifo(info);
+ fp = liveinfo_fifo(info);
+ if (!fp) {
+ liveinfo_close_fifo(info);
+ return ECORE_CALLBACK_CANCEL;
+ }
+ fprintf(fp, "%d\nEOD\n", (int)liveinfo_data(info));
+ liveinfo_close_fifo(info);
- {
- .cmd = "pd_key_down",
- .handler = client_pd_key_down,
- },
- {
- .cmd = "pd_key_up",
- .handler = client_pd_key_up,
- },
- {
- .cmd = "pd_key_focus_in",
- .handler = client_pd_key_focus_in,
- },
- {
- .cmd = "pd_key_focus_out",
- .handler = client_pd_key_focus_out,
- },
- {
- .cmd = "pd_key_set",
- .handler = client_pd_key_set,
- },
- {
- .cmd = "pd_key_unset",
- .handler = client_pd_key_unset,
- },
+ return ECORE_CALLBACK_CANCEL;
+ }
+ static struct packet *liveinfo_master_ctrl(pid_t pid, int handle, const struct packet *packet)
{
- .cmd = "client_paused",
- .handler = client_pause_request,
- },
- {
- .cmd = "client_resumed",
- .handler = client_resume_request,
- },
+ struct liveinfo *info;
+ char *cmd;
+ char *var;
+ char *val;
+ int ret = DBOX_STATUS_ERROR_INVALID_PARAMETER;
+
+ if (packet_get(packet, "sss", &cmd, &var, &val) != 3) {
+ ErrPrint("Invalid argument\n");
+ goto out;
+ }
- {
- .cmd = "update_mode",
- .handler = client_update_mode,
- },
+ info = liveinfo_find_by_pid(pid);
+ if (!info) {
+ ErrPrint("Invalid request\n");
+ goto out;
+ }
- {
- .cmd = NULL,
- .handler = NULL,
- },
-};
+ if (!strcasecmp(var, "debug")) {
+ if (!strcasecmp(cmd, "set")) {
+ g_conf.debug_mode = !strcasecmp(val, "on");
+ } else if (!strcasecmp(cmd, "get")) {
+ }
+ ret = g_conf.debug_mode;
+ } else if (!strcasecmp(var, "slave_max_load")) {
+ if (!strcasecmp(cmd, "set")) {
+ g_conf.slave_max_load = atoi(val);
+ } else if (!strcasecmp(cmd, "get")) {
+ }
+ ret = g_conf.slave_max_load;
+ }
-static struct method s_service_table[] = {
- {
- .cmd = "service_update",
- .handler = service_update,
- },
- {
- .cmd = "service_change_period",
- .handler = service_change_period,
- },
- {
- .cmd = NULL,
- .handler = NULL,
- },
-};
+ liveinfo_set_data(info, (void *)ret);
+ master_ctrl_cb(info);
-static struct method s_slave_table[] = {
- {
- .cmd = "call",
- .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
- },
- {
- .cmd = "ret",
- .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
- },
- {
- .cmd = "updated",
- .handler = slave_updated, /* slave_name, pkgname, filename, width, height, priority, ret */
- },
- {
- .cmd = "desc_updated",
- .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
- },
- {
- .cmd = "deleted",
- .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
- },
- {
- .cmd = "acquire_buffer",
- .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
- },
- {
- .cmd = "resize_buffer",
- .handler = slave_resize_buffer,
- },
- {
- .cmd = "release_buffer",
- .handler = slave_release_buffer, /* slave_name, id - ret */
- },
- {
- .cmd = "faulted",
- .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
- },
+out:
+ return NULL;
+ }
+
+ static struct method s_info_table[] = {
+ {
+ .cmd = CMD_STR_INFO_HELLO,
+ .handler = liveinfo_hello,
+ },
+ {
+ .cmd = CMD_STR_INFO_SLAVE_LIST,
+ .handler = liveinfo_slave_list,
+ },
+ {
+ .cmd = CMD_STR_INFO_PKG_LIST,
+ .handler = liveinfo_pkg_list,
+ },
+ {
+ .cmd = CMD_STR_INFO_INST_LIST,
+ .handler = liveinfo_inst_list,
+ },
+ {
+ .cmd = CMD_STR_INFO_SLAVE_CTRL,
+ .handler = liveinfo_slave_ctrl,
+ },
+ {
+ .cmd = CMD_STR_INFO_PKG_CTRL,
+ .handler = liveinfo_pkg_ctrl,
+ },
+ {
+ .cmd = CMD_STR_INFO_MASTER_CTRL,
+ .handler = liveinfo_master_ctrl,
+ },
+ {
+ .cmd = NULL,
+ .handler = NULL,
+ },
+ };
+
+ static struct method s_client_table[] = {
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_MOVE,
+ .handler = client_gbar_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_MOVE,
+ .handler = client_dbox_mouse_move, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_DOWN,
+ .handler = client_gbar_mouse_down, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_UP,
+ .handler = client_gbar_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_DOWN,
+ .handler = client_dbox_mouse_down, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_UP,
+ .handler = client_dbox_mouse_up, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_ENTER,
+ .handler = client_gbar_mouse_enter, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_LEAVE,
+ .handler = client_gbar_mouse_leave, /* pid, pkgname, id, width, height, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_ENTER,
+ .handler = client_dbox_mouse_enter, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_LEAVE,
+ .handler = client_dbox_mouse_leave, /* pid, pkgname, filename, width, height, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_ON_SCROLL,
+ .handler = client_dbox_mouse_on_scroll,
+ },
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_OFF_SCROLL,
+ .handler = client_dbox_mouse_off_scroll,
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_ON_SCROLL,
+ .handler = client_gbar_mouse_on_scroll,
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_OFF_SCROLL,
+ .handler = client_gbar_mouse_off_scroll,
+ },
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_ON_HOLD,
+ .handler = client_dbox_mouse_on_hold,
+ },
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_OFF_HOLD,
+ .handler = client_dbox_mouse_off_hold,
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_ON_HOLD,
+ .handler = client_gbar_mouse_on_hold,
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_OFF_HOLD,
+ .handler = client_gbar_mouse_off_hold,
+ },
+ {
+ .cmd = CMD_STR_CLICKED,
+ .handler = client_clicked, /*!< pid, pkgname, filename, event, timestamp, x, y, ret */
+ },
+ {
+ .cmd = CMD_STR_TEXT_SIGNAL,
+ .handler = client_text_signal, /* pid, pkgname, filename, emission, source, s, sy, ex, ey, ret */
+ },
+ {
+ .cmd = CMD_STR_DELETE,
+ .handler = client_delete, /* pid, pkgname, filename, ret */
+ },
+ {
+ .cmd = CMD_STR_RESIZE,
+ .handler = client_resize, /* pid, pkgname, filename, w, h, ret */
+ },
+ {
+ .cmd = CMD_STR_NEW,
+ .handler = client_new, /* pid, timestamp, pkgname, content, cluster, category, period, ret */
+ },
+ {
+ .cmd = CMD_STR_SET_PERIOD,
+ .handler = client_set_period, /* pid, pkgname, filename, period, ret, period */
+ },
+ {
+ .cmd = CMD_STR_CHANGE_GROUP,
+ .handler = client_change_group, /* pid, pkgname, filename, cluster, category, ret */
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOVE,
+ .handler = client_gbar_move, /* pkgname, id, x, y */
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACCESS_HL,
+ .handler = client_gbar_access_hl,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACCESS_ACTIVATE,
+ .handler = client_gbar_access_activate,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACCESS_ACTION,
+ .handler = client_gbar_access_action,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACCESS_SCROLL,
+ .handler = client_gbar_access_scroll,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACCESS_VALUE_CHANGE,
+ .handler = client_gbar_access_value_change,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACCESS_MOUSE,
+ .handler = client_gbar_access_mouse,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACCESS_BACK,
+ .handler = client_gbar_access_back,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACCESS_OVER,
+ .handler = client_gbar_access_over,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACCESS_READ,
+ .handler = client_gbar_access_read,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACCESS_ENABLE,
+ .handler = client_gbar_access_enable,
+ },
+
+ {
+ .cmd = CMD_STR_DBOX_ACCESS_HL,
+ .handler = client_dbox_access_hl,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACCESS_ACTIVATE,
+ .handler = client_dbox_access_activate,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACCESS_ACTION,
+ .handler = client_dbox_access_action,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACCESS_SCROLL,
+ .handler = client_dbox_access_scroll,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACCESS_VALUE_CHANGE,
+ .handler = client_dbox_access_value_change,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACCESS_MOUSE,
+ .handler = client_dbox_access_mouse,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACCESS_BACK,
+ .handler = client_dbox_access_back,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACCESS_OVER,
+ .handler = client_dbox_access_over,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACCESS_READ,
+ .handler = client_dbox_access_read,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACCESS_ENABLE,
+ .handler = client_dbox_access_enable,
+ },
+ {
+ .cmd = CMD_STR_DBOX_KEY_DOWN,
+ .handler = client_dbox_key_down,
+ },
+ {
+ .cmd = CMD_STR_DBOX_KEY_UP,
+ .handler = client_dbox_key_up,
+ },
+ {
+ .cmd = CMD_STR_DBOX_KEY_FOCUS_IN,
+ .handler = client_dbox_key_focus_in,
+ },
+ {
+ .cmd = CMD_STR_DBOX_KEY_FOCUS_OUT,
+ .handler = client_dbox_key_focus_out,
+ },
+ {
+ .cmd = CMD_STR_GBAR_KEY_DOWN,
+ .handler = client_gbar_key_down,
+ },
+ {
+ .cmd = CMD_STR_GBAR_KEY_UP,
+ .handler = client_gbar_key_up,
+ },
+ {
+ .cmd = CMD_STR_GBAR_KEY_FOCUS_IN,
+ .handler = client_gbar_key_focus_in,
+ },
+ {
+ .cmd = CMD_STR_GBAR_KEY_FOCUS_OUT,
+ .handler = client_gbar_key_focus_out,
+ },
+ {
+ .cmd = CMD_STR_UPDATE_MODE,
+ .handler = client_update_mode,
+ },
+ // Cut HERE. Above list must be sync'd with provider list.
+
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_SET,
+ .handler = client_dbox_mouse_set,
+ },
+ {
+ .cmd = CMD_STR_DBOX_MOUSE_UNSET,
+ .handler = client_dbox_mouse_unset,
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_SET,
+ .handler = client_gbar_mouse_set,
+ },
+ {
+ .cmd = CMD_STR_GBAR_MOUSE_UNSET,
+ .handler = client_gbar_mouse_unset,
+ },
+ {
+ .cmd = CMD_STR_CHANGE_VISIBILITY,
+ .handler = client_change_visibility,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACQUIRE_PIXMAP,
+ .handler = client_dbox_acquire_pixmap,
+ },
+ {
+ .cmd = CMD_STR_DBOX_RELEASE_PIXMAP,
+ .handler = client_dbox_release_pixmap,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACQUIRE_PIXMAP,
+ .handler = client_gbar_acquire_pixmap,
+ },
+ {
+ .cmd = CMD_STR_GBAR_RELEASE_PIXMAP,
+ .handler = client_gbar_release_pixmap,
+ },
+ {
+ .cmd = CMD_STR_ACQUIRE,
+ .handler = client_acquire, /*!< pid, ret */
+ },
+ {
+ .cmd = CMD_STR_RELEASE,
+ .handler = cilent_release, /*!< pid, ret */
+ },
+ {
+ .cmd = CMD_STR_PINUP_CHANGED,
+ .handler = client_pinup_changed, /* pid, pkgname, filename, pinup, ret */
+ },
+ {
+ .cmd = CMD_STR_CREATE_GBAR,
+ .handler = client_create_gbar, /* pid, pkgname, filename, ret */
+ },
+ {
+ .cmd = CMD_STR_DESTROY_GBAR,
+ .handler = client_destroy_gbar, /* pid, pkgname, filename, ret */
+ },
+ {
+ .cmd = CMD_STR_ACTIVATE_PACKAGE,
+ .handler = client_activate_package, /* pid, pkgname, ret */
+ },
+ {
+ .cmd = CMD_STR_SUBSCRIBE, /* pid, cluster, sub-cluster */
+ .handler = client_subscribed,
+ },
+ {
+ .cmd = CMD_STR_UNSUBSCRIBE, /* pid, cluster, sub-cluster */
+ .handler = client_unsubscribed,
+ },
+ {
+ .cmd = CMD_STR_DELETE_CLUSTER,
+ .handler = client_delete_cluster,
+ },
+ {
+ .cmd = CMD_STR_DELETE_CATEGORY,
+ .handler = client_delete_category,
+ },
+ {
+ .cmd = CMD_STR_REFRESH_GROUP,
+ .handler = client_refresh_group,
+ },
+ {
+ .cmd = CMD_STR_UPDATE,
+ .handler = client_update,
+ },
+
+ {
+ .cmd = CMD_STR_DBOX_KEY_SET,
+ .handler = client_dbox_key_set,
+ },
+ {
+ .cmd = CMD_STR_DBOX_KEY_UNSET,
+ .handler = client_dbox_key_unset,
+ },
+
+ {
+ .cmd = CMD_STR_GBAR_KEY_SET,
+ .handler = client_gbar_key_set,
+ },
+ {
+ .cmd = CMD_STR_GBAR_KEY_UNSET,
+ .handler = client_gbar_key_unset,
+ },
+
+ {
+ .cmd = CMD_STR_CLIENT_PAUSED,
+ .handler = client_pause_request,
+ },
+ {
+ .cmd = CMD_STR_CLIENT_RESUMED,
+ .handler = client_resume_request,
+ },
+ {
+ .cmd = CMD_STR_DBOX_ACQUIRE_XPIXMAP,
+ .handler = client_dbox_acquire_xpixmap,
+ },
+ {
+ .cmd = CMD_STR_GBAR_ACQUIRE_XPIXMAP,
+ .handler = client_gbar_acquire_xpixmap,
+ },
+
+ {
+ .cmd = NULL,
+ .handler = NULL,
+ },
+ };
+
+ static struct method s_service_table[] = {
+ {
+ .cmd = CMD_STR_SERVICE_UPDATE,
+ .handler = service_update,
+ },
+ {
+ .cmd = CMD_STR_SERVICE_CHANGE_PERIOD,
+ .handler = service_change_period,
+ },
+ {
+ .cmd = CMD_STR_SERVICE_INST_CNT,
+ .handler = service_instance_count,
+ },
+ {
+ .cmd = NULL,
+ .handler = NULL,
+ },
+ };
+
+ static struct method s_slave_table[] = {
+ {
+ .cmd = CMD_STR_UPDATED,
+ .handler = slave_updated, /* slave_name, pkgname, filename, width, height, ret */
+ },
+ {
+ .cmd = CMD_STR_DESC_UPDATED,
+ .handler = slave_desc_updated, /* slave_name, pkgname, filename, decsfile, ret */
+ },
+ {
+ .cmd = CMD_STR_EXTRA_UPDATED,
+ .handler = slave_extra_updated,
+ },
+ {
+ .cmd = CMD_STR_EXTRA_INFO,
+ .handler = slave_extra_info, /* slave_name, pkgname, filename, priority, content_info, title, icon, name */
+ },
+ {
+ .cmd = CMD_STR_DELETED,
+ .handler = slave_deleted, /* slave_name, pkgname, filename, ret */
+ },
+ {
+ .cmd = CMD_STR_FAULTED,
+ .handler = slave_faulted, /* slave_name, pkgname, id, funcname */
+ },
+ {
+ .cmd = CMD_STR_SCROLL,
+ .handler = slave_hold_scroll, /* slave_name, pkgname, id, seize */
+ },
+
+ {
+ .cmd = CMD_STR_DBOX_UPDATE_BEGIN,
+ .handler = slave_dbox_update_begin,
+ },
+ {
+ .cmd = CMD_STR_DBOX_UPDATE_END,
+ .handler = slave_dbox_update_end,
+ },
+ {
+ .cmd = CMD_STR_GBAR_UPDATE_BEGIN,
+ .handler = slave_gbar_update_begin,
+ },
+ {
+ .cmd = CMD_STR_GBAR_UPDATE_END,
+ .handler = slave_gbar_update_end,
+ },
+
+ {
+ .cmd = CMD_STR_ACCESS_STATUS,
+ .handler = slave_access_status,
+ },
+ {
+ .cmd = CMD_STR_KEY_STATUS,
+ .handler = slave_key_status,
+ },
+ {
+ .cmd = CMD_STR_CLOSE_GBAR,
+ .handler = slave_close_gbar,
+ },
+
+ {
+ .cmd = CMD_STR_CALL,
+ .handler = slave_call, /* slave_name, pkgname, filename, function, ret */
+ },
+ {
+ .cmd = CMD_STR_RET,
+ .handler = slave_ret, /* slave_name, pkgname, filename, function, ret */
+ },
+ {
+ .cmd = CMD_STR_ACQUIRE_BUFFER,
+ .handler = slave_acquire_buffer, /* slave_name, id, w, h, size, - out - type, shmid */
+ },
+ {
+ .cmd = CMD_STR_RESIZE_BUFFER,
+ .handler = slave_resize_buffer,
+ },
+ {
+ .cmd = CMD_STR_RELEASE_BUFFER,
+ .handler = slave_release_buffer, /* slave_name, id - ret */
+ },
+ {
+ .cmd = CMD_STR_HELLO,
+ .handler = slave_hello, /* slave_name, ret */
+ },
+ {
+ .cmd = CMD_STR_PING,
+ .handler = slave_ping, /* slave_name, ret */
+ },
+ {
+ .cmd = CMD_STR_CTRL,
+ .handler = slave_ctrl, /* control bits */
+ },
+
+ {
+ .cmd = CMD_STR_ACQUIRE_XBUFFER,
+ .handler = slave_acquire_extra_buffer,
+ },
+ {
+ .cmd = CMD_STR_RELEASE_XBUFFER,
+ .handler = slave_release_extra_buffer,
+ },
+
+ {
+ .cmd = NULL,
+ .handler = NULL,
+ },
+ };
+
+ HAPI int server_init(void)
{
- .cmd = "scroll",
- .handler = slave_hold_scroll, /* slave_name, pkgname, id, seize */
- },
+ com_core_packet_use_thread(DYNAMICBOX_CONF_COM_CORE_THREAD);
- {
- .cmd = "lb_update_begin",
- .handler = slave_lb_update_begin,
- },
- {
- .cmd = "lb_update_end",
- .handler = slave_lb_update_end,
- },
- {
- .cmd = "pd_update_begin",
- .handler = slave_pd_update_begin,
- },
- {
- .cmd = "pd_update_end",
- .handler = slave_pd_update_end,
- },
+ if (unlink(INFO_SOCKET) < 0) {
+ ErrPrint("info socket: %s\n", strerror(errno));
+ }
- {
- .cmd = "access_status",
- .handler = slave_access_status,
- },
- {
- .cmd = "key_status",
- .handler = slave_key_status,
- },
- {
- .cmd = "close_pd",
- .handler = slave_close_pd,
- },
+ if (unlink(SLAVE_SOCKET) < 0) {
+ ErrPrint("slave socket: %s\n", strerror(errno));
+ }
- {
- .cmd = "hello",
- .handler = slave_hello, /* slave_name, ret */
- },
- {
- .cmd = "ping",
- .handler = slave_ping, /* slave_name, ret */
- },
- {
- .cmd = "ctrl",
- .handler = slave_ctrl, /* control bits */
- },
+ if (unlink(CLIENT_SOCKET) < 0) {
+ ErrPrint("client socket: %s\n", strerror(errno));
+ }
- {
- .cmd = NULL,
- .handler = NULL,
- },
-};
+ if (unlink(SERVICE_SOCKET) < 0) {
+ ErrPrint("service socket: %s\n", strerror(errno));
+ }
-HAPI int server_init(void)
-{
- com_core_packet_use_thread(COM_CORE_THREAD);
+ s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
+ if (s_info.info_fd < 0) {
+ ErrPrint("Failed to create a info socket\n");
+ }
- if (unlink(INFO_SOCKET) < 0) {
- ErrPrint("info socket: %s\n", strerror(errno));
- }
+ s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
+ if (s_info.slave_fd < 0) {
+ ErrPrint("Failed to create a slave socket\n");
+ }
- if (unlink(SLAVE_SOCKET) < 0) {
- ErrPrint("slave socket: %s\n", strerror(errno));
- }
+ smack_fsetlabel(s_info.slave_fd, "data-provider-master::provider", SMACK_LABEL_IPIN);
+ smack_fsetlabel(s_info.slave_fd, "data-provider-master::provider", SMACK_LABEL_IPOUT);
- if (unlink(CLIENT_SOCKET) < 0) {
- ErrPrint("client socket: %s\n", strerror(errno));
- }
+ s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
+ if (s_info.client_fd < 0) {
+ ErrPrint("Failed to create a client socket\n");
+ }
- if (unlink(SERVICE_SOCKET) < 0) {
- ErrPrint("service socket: %s\n", strerror(errno));
- }
+ smack_fsetlabel(s_info.client_fd, "data-provider-master::client", SMACK_LABEL_IPIN);
+ smack_fsetlabel(s_info.client_fd, "data-provider-master::client", SMACK_LABEL_IPOUT);
- s_info.info_fd = com_core_packet_server_init(INFO_SOCKET, s_info_table);
- if (s_info.info_fd < 0) {
- ErrPrint("Failed to create a info socket\n");
- }
+ /*!
+ * \note
+ * remote://:8208
+ * Skip address to use the NULL.
+ */
+ s_info.remote_client_fd = com_core_packet_server_init("remote://:"CLIENT_PORT, s_client_table);
+ if (s_info.client_fd < 0) {
+ ErrPrint("Failed to create a remote client socket\n");
+ }
- s_info.slave_fd = com_core_packet_server_init(SLAVE_SOCKET, s_slave_table);
- if (s_info.slave_fd < 0) {
- ErrPrint("Failed to create a slave socket\n");
- }
+ smack_fsetlabel(s_info.remote_client_fd, "data-provider-master::client", SMACK_LABEL_IPIN);
+ smack_fsetlabel(s_info.remote_client_fd, "data-provider-master::client", SMACK_LABEL_IPOUT);
- s_info.client_fd = com_core_packet_server_init(CLIENT_SOCKET, s_client_table);
- if (s_info.client_fd < 0) {
- ErrPrint("Failed to create a client socket\n");
- }
+ s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
+ if (s_info.service_fd < 0) {
+ ErrPrint("Faild to create a service socket\n");
+ }
- /*!
- * \note
- * remote://:8208
- * Skip address to use the NULL.
- */
- s_info.remote_client_fd = com_core_packet_server_init("remote://:"CLIENT_PORT, s_client_table);
- if (s_info.client_fd < 0) {
- ErrPrint("Failed to create a remote client socket\n");
- }
+ smack_fsetlabel(s_info.service_fd, "data-provider-master", SMACK_LABEL_IPIN);
+ smack_fsetlabel(s_info.service_fd, "data-provider-master", SMACK_LABEL_IPOUT);
- s_info.service_fd = com_core_packet_server_init(SERVICE_SOCKET, s_service_table);
- if (s_info.service_fd < 0) {
- ErrPrint("Faild to create a service socket\n");
- }
+ if (chmod(INFO_SOCKET, 0600) < 0) {
+ ErrPrint("info socket: %s\n", strerror(errno));
+ }
- if (chmod(INFO_SOCKET, 0600) < 0) {
- ErrPrint("info socket: %s\n", strerror(errno));
- }
+ if (chmod(SLAVE_SOCKET, 0666) < 0) {
+ ErrPrint("slave socket: %s\n", strerror(errno));
+ }
- if (chmod(SLAVE_SOCKET, 0666) < 0) {
- ErrPrint("slave socket: %s\n", strerror(errno));
- }
+ if (chmod(CLIENT_SOCKET, 0666) < 0) {
+ ErrPrint("client socket: %s\n", strerror(errno));
+ }
- if (chmod(CLIENT_SOCKET, 0666) < 0) {
- ErrPrint("client socket: %s\n", strerror(errno));
- }
+ if (chmod(SERVICE_SOCKET, 0666) < 0) {
+ ErrPrint("service socket: %s\n", strerror(errno));
+ }
- if (chmod(SERVICE_SOCKET, 0666) < 0) {
- ErrPrint("service socket: %s\n", strerror(errno));
+ return 0;
}
- return 0;
-}
+ HAPI int server_fini(void)
+ {
+ if (s_info.info_fd > 0) {
+ com_core_packet_server_fini(s_info.info_fd);
+ s_info.info_fd = -1;
+ }
-HAPI int server_fini(void)
-{
- if (s_info.info_fd > 0) {
- com_core_packet_server_fini(s_info.info_fd);
- s_info.info_fd = -1;
- }
+ if (s_info.slave_fd > 0) {
+ com_core_packet_server_fini(s_info.slave_fd);
+ s_info.slave_fd = -1;
+ }
- if (s_info.slave_fd > 0) {
- com_core_packet_server_fini(s_info.slave_fd);
- s_info.slave_fd = -1;
- }
+ if (s_info.client_fd > 0) {
+ com_core_packet_server_fini(s_info.client_fd);
+ s_info.client_fd = -1;
+ }
- if (s_info.client_fd > 0) {
- com_core_packet_server_fini(s_info.client_fd);
- s_info.client_fd = -1;
- }
+ if (s_info.remote_client_fd > 0) {
+ com_core_packet_server_fini(s_info.remote_client_fd);
+ s_info.remote_client_fd = -1;
+ }
- if (s_info.remote_client_fd > 0) {
- com_core_packet_server_fini(s_info.remote_client_fd);
- s_info.remote_client_fd = -1;
- }
+ if (s_info.service_fd > 0) {
+ com_core_packet_server_fini(s_info.service_fd);
+ s_info.service_fd = -1;
+ }
- if (s_info.service_fd > 0) {
- com_core_packet_server_fini(s_info.service_fd);
- s_info.service_fd = -1;
+ return 0;
}
- return 0;
-}
-
-/* End of a file */
+ /* End of a file */
#include <Eina.h>
#include <com-core.h>
#if defined(HAVE_LIVEBOX)
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#else
#include <lite-errno.h>
#endif
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->tcb = tcb;
break;
default:
DbgFree(cbdata);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/*!
if (cbdata->tcb == tcb && cbdata->cb == cb && cbdata->data == data) {
svc_ctx->tcb_create_cb_list = eina_list_remove(svc_ctx->tcb_create_cb_list, cbdata);
DbgFree(cbdata);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
if (cbdata->tcb == tcb && cbdata->cb == cb && cbdata->data == data) {
svc_ctx->tcb_destroy_cb_list = eina_list_remove(svc_ctx->tcb_destroy_cb_list, cbdata);
DbgFree(cbdata);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
default:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
/*!
#include "critical_log.h"
#if defined(HAVE_LIVEBOX)
-#include <livebox-service.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_conf.h>
+#include <dynamicbox_errno.h>
#include "client_life.h"
#include "slave_life.h"
#include "xmonitor.h"
int errno;
+struct event_cbdata {
+ int (*handler)(enum oom_event_type type, void *data);
+ void *data;
+ int deleted;
+};
+
static struct {
int deactivated;
+ Eina_List *oom_event_list;
+ int oom_event_in_process;
} s_info = {
.deactivated = 0,
+ .oom_event_list = NULL,
+ .oom_event_in_process = 0,
};
static void lcd_state_cb(keynode_t *node, void *user_data)
{
int state;
+ if (!DYNAMICBOX_CONF_CHECK_LCD) {
+ /* Always turned on */
+ return 0;
+ }
+
if (vconf_get_int(VCONFKEY_PM_STATE, &state) != 0) {
ErrPrint("Idle lock state is not valid\n");
state = VCONFKEY_PM_STATE_NORMAL; /* UNLOCK */
}
- DbgPrint("State: %d, (%d:lcdoff, %d:sleep)\n", state, VCONFKEY_PM_STATE_LCDOFF, VCONFKEY_PM_STATE_SLEEP);
+ ErrPrint("State: %d, (%d:lcdoff, %d:sleep)\n", state, VCONFKEY_PM_STATE_LCDOFF, VCONFKEY_PM_STATE_SLEEP);
return state == VCONFKEY_PM_STATE_LCDOFF || state == VCONFKEY_PM_STATE_SLEEP;
}
static void power_off_cb(keynode_t *node, void *user_data)
{
- int val;
+ int val;
CRITICAL_LOG("Terminated(vconf)\n");
if (vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &val) != 0) {
static void region_changed_cb(keynode_t *node, void *user_data)
{
- char *region;
- char *r;
+ char *region;
+ char *r;
- region = vconf_get_str(VCONFKEY_REGIONFORMAT);
- if (!region) {
+ region = vconf_get_str(VCONFKEY_REGIONFORMAT);
+ if (!region) {
return;
}
static void lang_changed_cb(keynode_t *node, void *user_data)
{
- char *lang;
- char *r;
+ char *lang;
+ char *r;
- lang = vconf_get_str(VCONFKEY_LANGSET);
- if (!lang) {
+ lang = vconf_get_str(VCONFKEY_LANGSET);
+ if (!lang) {
return;
}
static void low_mem_cb(keynode_t *node, void *user_data)
{
int val;
+ Eina_List *l;
+ Eina_List *n;
+ struct event_cbdata *item;
val = vconf_keynode_get_int(node);
CRITICAL_LOG("Low memory: level %d\n", val);
if (s_info.deactivated == 0) {
s_info.deactivated = 1;
+
+ s_info.oom_event_in_process = 1;
+ EINA_LIST_FOREACH_SAFE(s_info.oom_event_list, l, n, item) {
+ if (item->deleted || item->handler(OOM_TYPE_LOW, item->data) < 0 || item->deleted) {
+ s_info.oom_event_list = eina_list_remove(s_info.oom_event_list, item);
+ free(item);
+ }
+ }
+ s_info.oom_event_in_process = 0;
+
//slave_deactivate_all(0, 1, 0);
malloc_trim(0);
ErrPrint("Fall into the low mem status\n");
CRITICAL_LOG("Normal memory: level %d\n", val);
if (s_info.deactivated == 1) {
s_info.deactivated = 0;
+
+ s_info.oom_event_in_process = 1;
+ EINA_LIST_FOREACH_SAFE(s_info.oom_event_list, l, n, item) {
+ if (item->deleted || item->handler(OOM_TYPE_NORMAL, item->data) < 0 || item->deleted) {
+ s_info.oom_event_list = eina_list_remove(s_info.oom_event_list, item);
+ free(item);
+ }
+ }
+ s_info.oom_event_in_process = 0;
+
//slave_activate_all();
ErrPrint("Recover from the low mem status\n");
}
}
}
+HAPI int setting_add_oom_event_callback(int (*handler)(enum oom_event_type type, void *data), void *data)
+{
+ struct event_cbdata *item;
+
+ item = malloc(sizeof(*item));
+ if (!item) {
+ ErrPrint("malloc: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
+ }
+
+ item->handler = handler;
+ item->data = data;
+ item->deleted = 0;
+
+ s_info.oom_event_list = eina_list_append(s_info.oom_event_list, item);
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+HAPI int setting_del_oom_event_callback(int (*handler)(enum oom_event_type type, void *data), void *data)
+{
+ struct event_cbdata *item;
+ Eina_List *l;
+ Eina_List *n;
+
+ EINA_LIST_FOREACH_SAFE(s_info.oom_event_list, l, n, item) {
+ if (handler == item->handler && item->data == data) {
+ if (s_info.oom_event_in_process) {
+ item->deleted = 1;
+ } else {
+ s_info.oom_event_list = eina_list_remove(s_info.oom_event_list, item);
+ free(item);
+ }
+ return DBOX_STATUS_ERROR_NONE;
+ }
+ }
+
+ return DBOX_STATUS_ERROR_NOT_EXIST;
+}
+
+HAPI enum oom_event_type setting_oom_level(void)
+{
+ int ret;
+ int status;
+
+ ret = vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &status);
+ if (ret == 0 && status >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING) {
+ return OOM_TYPE_LOW;
+ }
+
+ return OOM_TYPE_NORMAL;
+}
+
HAPI int setting_init(void)
{
int ret;
#include <dlog.h>
#if defined(HAVE_LIVEBOX)
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#else
#include "lite-errno.h"
#endif
ret = security_server_check_privilege_by_sockfd(tcb_fd(tcb), "data-provider-master::shortcut.livebox", "w");
if (ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
ErrPrint("SMACK:Access denied\n");
- send_reply_packet(tcb, packet, SHORTCUT_ERROR_PERMISSION);
+ send_reply_packet(tcb, packet, SHORTCUT_ERROR_PERMISSION_DENIED);
break;
}
ret = security_server_check_privilege_by_sockfd(tcb_fd(tcb), "data-provider-master::shortcut.shortcut", "w");
if (ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
ErrPrint("SMACK:Access denied\n");
- send_reply_packet(tcb, packet, SHORTCUT_ERROR_PERMISSION);
+ send_reply_packet(tcb, packet, SHORTCUT_ERROR_PERMISSION_DENIED);
break;
}
}
{
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(SHORTCUT_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), SHORTCUT_SMACK_LABEL, SMACK_LABEL_IPOUT) != 0) {
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;
}
}
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 shortcut_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 */
#include <pthread.h>
#include <malloc.h>
#include <sys/time.h>
+#include <sys/resource.h>
#include <Eina.h>
#include <Ecore.h>
#include <bundle.h>
#include <packet.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_conf.h>
+#include <dynamicbox_cmd_list.h>
+#include <dynamicbox_service.h>
#include "critical_log.h"
#include "slave_life.h"
#include "abi.h"
#include "xmonitor.h"
+#include "package.h"
+#include "instance.h"
+
+#define BUNDLE_SLAVE_SVC_OP_TYPE "__APP_SVC_OP_TYPE__"
+#define APP_CONTROL_OPERATION_MAIN "http://tizen.org/appcontrol/operation/main"
+#define LOW_PRIORITY 10
+
int errno;
struct slave_node {
char *name;
char *abi;
char *pkgname;
- int secured; /* Only A package(livebox) is loaded for security requirements */
+ int secured; /* Only A package(dynamicbox) is loaded for security requirements */
int refcnt;
int fault_count;
int critical_fault_count;
#else
struct timeval activated_at;
#endif
+
+ char *hw_acceleration;
};
struct event {
.deactivate_all_refcnt = 0,
};
+static Eina_Bool terminate_timer_cb(void *data)
+{
+ struct slave_node *slave = data;
+ int ret;
+
+ /*!
+ * \todo
+ * check the return value of the aul_terminate_pid
+ */
+ slave->state = SLAVE_REQUEST_TO_TERMINATE;
+ slave->terminate_timer = NULL;
+
+ DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
+ ret = aul_terminate_pid_async(slave->pid);
+ if (ret < 0) {
+ ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
+ slave = slave_deactivated(slave);
+ if (slave == NULL) {
+ DbgPrint("Slave is deleted\n");
+ }
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static struct slave_node *slave_deactivate(struct slave_node *slave, int no_timer)
+{
+ int ret;
+
+ /**
+ * @note
+ * The caller must has to check the slave's state.
+ * If it is not activated, this function must has not to be called.
+ */
+
+ if (slave_pid(slave) <= 0) {
+ return slave;
+ }
+
+ if (slave->ttl_timer) {
+ /**
+ * @note
+ * If there is an activated TTL timer,
+ * It has to be cleared before deactivate the slave.
+ */
+ ecore_timer_del(slave->ttl_timer);
+ slave->ttl_timer = NULL;
+ }
+
+ if ((slave->ctrl_option & PROVIDER_CTRL_MANUAL_TERMINATION) == PROVIDER_CTRL_MANUAL_TERMINATION) {
+ /*!
+ * \note
+ * In this case,
+ * The provider requests MANUAL TERMINATION control option.
+ * Master will not send terminate request in this case, the provider should be terminated by itself.
+ */
+ DbgPrint("Manual termination is turned on\n");
+ slave->state = SLAVE_REQUEST_TO_DISCONNECT;
+ (void)slave_rpc_disconnect(slave);
+ } else if (slave->terminate_timer) {
+ ErrPrint("Terminate timer is already fired (%d)\n", slave->pid);
+ } else if (!no_timer && !slave->secured) {
+ DbgPrint("Fire the terminate timer: %d\n", slave->pid);
+ slave->terminate_timer = ecore_timer_add(DYNAMICBOX_CONF_SLAVE_ACTIVATE_TIME, terminate_timer_cb, slave);
+ if (!slave->terminate_timer) {
+ /*!
+ * \note
+ * Normally, Call the terminate_timer_cb directly from here
+ * But in this case. if the aul_terminate_pid failed, Call the slave_deactivated function directly.
+ * Then the "slave" pointer can be changed. To trace it, Copy the body of terminate_timer_cb to here.
+ */
+ ErrPrint("Failed to add a new timer for terminating\n");
+ DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
+ /*!
+ * \todo
+ * check the return value of the aul_terminate_pid
+ */
+ slave->state = SLAVE_REQUEST_TO_TERMINATE;
+
+ ret = aul_terminate_pid_async(slave->pid);
+ if (ret < 0) {
+ ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
+ slave = slave_deactivated(slave);
+ }
+ }
+ } else {
+ /*!
+ * \todo
+ * check the return value of the aul_terminate_pid
+ */
+ slave->state = SLAVE_REQUEST_TO_TERMINATE;
+
+ DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
+ ret = aul_terminate_pid_async(slave->pid);
+ if (ret < 0) {
+ ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
+ slave = slave_deactivated(slave);
+ }
+ }
+
+ return slave;
+}
+
static Eina_Bool slave_ttl_cb(void *data)
{
+ struct pkg_info *info;
struct slave_node *slave = (struct slave_node *)data;
+ Eina_List *l;
+ Eina_List *pkg_list;
+
+ pkg_list = (Eina_List *)package_list();
+ EINA_LIST_FOREACH(pkg_list, l, info) {
+ if (package_slave(info) == slave) {
+ struct inst_info *inst;
+ Eina_List *inst_list;
+ Eina_List *n;
+
+ inst_list = (Eina_List *)package_instance_list(info);
+ EINA_LIST_FOREACH(inst_list, n, inst) {
+ if (instance_visible_state(inst) == DBOX_SHOW) {
+ DbgPrint("Instance is in show, give more ttl to %d for %s\n", slave_pid(slave), instance_id(inst));
+ return ECORE_CALLBACK_RENEW;
+ }
+ }
+ }
+ }
/*!
* \note
* ttl_timer must has to be set to NULL before deactivate the slave
- * It will be used for making decision of the expired TTL timer or the fault of a livebox.
+ * It will be used for making decision of the expired TTL timer or the fault of a dynamicbox.
*/
slave->ttl_timer = NULL;
- slave_set_reactivation(slave, 0);
- slave_set_reactivate_instances(slave, 1);
+ if (slave_is_activated(slave)) {
+ slave_set_reactivation(slave, 0);
+ slave_set_reactivate_instances(slave, 1);
- slave = slave_deactivate(slave, 1);
- if (!slave) {
- DbgPrint("Slave is deleted\n");
+ slave = slave_deactivate(slave, 1);
+ if (!slave) {
+ DbgPrint("Slave is deleted\n");
+ }
}
/*! To recover all instances state it is activated again */
static inline int xmonitor_pause_cb(void *data)
{
slave_pause(data);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int xmonitor_resume_cb(void *data)
{
slave_resume(data);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
-static inline struct slave_node *create_slave_node(const char *name, int is_secured, const char *abi, const char *pkgname, int network)
+static inline struct slave_node *create_slave_node(const char *name, int is_secured, const char *abi, const char *pkgname, int network, const char *hw_acceleration)
{
struct slave_node *slave;
return NULL;
}
+ if (hw_acceleration) {
+ slave->hw_acceleration = strdup(hw_acceleration);
+ if (!slave->hw_acceleration) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ DbgFree(slave->pkgname);
+ DbgFree(slave->abi);
+ DbgFree(slave->name);
+ DbgFree(slave);
+ return NULL;
+ }
+ }
+
slave->secured = is_secured;
slave->pid = (pid_t)-1;
slave->state = SLAVE_TERMINATED;
slave->network = network;
- slave->relaunch_count = SLAVE_RELAUNCH_COUNT;
+ slave->relaunch_count = DYNAMICBOX_CONF_SLAVE_RELAUNCH_COUNT;
xmonitor_add_event_callback(XMONITOR_PAUSED, xmonitor_pause_cb, slave);
xmonitor_add_event_callback(XMONITOR_RESUMED, xmonitor_resume_cb, slave);
DbgFree(slave->abi);
DbgFree(slave->name);
DbgFree(slave->pkgname);
+ DbgFree(slave->hw_acceleration);
DbgFree(slave);
return;
}
return slave;
}
}
-
+
return NULL;
}
return 0;
}
- if (!slave->secured) {
+ if (!slave->secured && !(DBOX_IS_INHOUSE(slave_abi(slave)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL)) {
return 0;
}
return slave->refcnt;
}
-HAPI struct slave_node *slave_create(const char *name, int is_secured, const char *abi, const char *pkgname, int network)
+HAPI struct slave_node *slave_create(const char *name, int is_secured, const char *abi, const char *pkgname, int network, const char *hw_acceleration)
{
struct slave_node *slave;
return slave;
}
- slave = create_slave_node(name, is_secured, abi, pkgname, network);
+ slave = create_slave_node(name, is_secured, abi, pkgname, network, hw_acceleration);
if (!slave) {
return NULL;
}
slave_unref(slave);
}
-static inline void invoke_fault_cb(struct slave_node *slave)
+static inline struct slave_node *invoke_fault_cb(struct slave_node *slave)
{
Eina_List *l;
Eina_List *n;
struct event *event;
+ slave_ref(slave);
slave->in_event_process |= SLAVE_EVENT_PROCESS_FAULT;
EINA_LIST_FOREACH_SAFE(slave->event_fault_list, l, n, event) {
if (event->deleted || event->evt_cb(event->slave, event->cbdata) < 0 || event->deleted) {
}
}
slave->in_event_process &= ~SLAVE_EVENT_PROCESS_FAULT;
+ slave = slave_unref(slave);
+
+ return slave;
}
static inline void invoke_activate_cb(struct slave_node *slave)
}
slave->fault_count++;
- invoke_fault_cb(slave);
+
+ if (invoke_fault_cb(slave) == NULL) {
+ ErrPrint("Slave is deleted while processing fault handler\n");
+ return ECORE_CALLBACK_CANCEL;
+ }
slave_set_reactivation(slave, 0);
slave_set_reactivate_instances(slave, 0);
if (slave_pid(slave) > 0) {
int ret;
DbgPrint("Try to terminate PID: %d\n", slave_pid(slave));
- ret = aul_terminate_pid(slave_pid(slave));
+ ret = aul_terminate_pid_async(slave_pid(slave));
if (ret < 0) {
ErrPrint("Terminate failed, pid %d (reason: %d)\n", slave_pid(slave), ret);
}
}
- CRITICAL_LOG("Slave is not activated in %lf sec (slave: %s)\n", SLAVE_ACTIVATE_TIME, slave_name(slave));
+ CRITICAL_LOG("Slave is not activated in %lf sec (slave: %s)\n", DYNAMICBOX_CONF_SLAVE_ACTIVATE_TIME, slave_name(slave));
slave = slave_deactivated(slave);
return ECORE_CALLBACK_CANCEL;
}
static inline void invoke_slave_fault_handler(struct slave_node *slave)
{
slave->fault_count++;
- invoke_fault_cb(slave);
+ if (invoke_fault_cb(slave) == NULL) {
+ ErrPrint("Slave is deleted while processing fault handler\n");
+ return;
+ }
slave_set_reactivation(slave, 0);
slave_set_reactivate_instances(slave, 0);
} else {
int ret;
DbgPrint("Try to terminate PID: %d\n", slave_pid(slave));
- ret = aul_terminate_pid(slave_pid(slave));
+ ret = aul_terminate_pid_async(slave_pid(slave));
if (ret < 0) {
ErrPrint("Terminate failed, pid %d (reason: %d)\n", slave_pid(slave), ret);
}
invoke_slave_fault_handler(slave);
} else {
- bundle_add(param, BUNDLE_SLAVE_NAME, slave_name(slave));
- bundle_add(param, BUNDLE_SLAVE_SECURED, slave->secured ? "true" : "false");
- bundle_add(param, BUNDLE_SLAVE_ABI, slave->abi);
+ bundle_add(param, BUNDLE_SLAVE_SVC_OP_TYPE, APP_CONTROL_OPERATION_MAIN);
+ bundle_add(param, DYNAMICBOX_CONF_BUNDLE_SLAVE_NAME, slave_name(slave));
+ bundle_add(param, DYNAMICBOX_CONF_BUNDLE_SLAVE_SECURED, ((DBOX_IS_INHOUSE(slave_abi(slave)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL) || slave->secured) ? "true" : "false");
+ bundle_add(param, DYNAMICBOX_CONF_BUNDLE_SLAVE_ABI, slave->abi);
+ bundle_add(param, DYNAMICBOX_CONF_BUNDLE_SLAVE_HW_ACCELERATION, slave->hw_acceleration);
slave->pid = (pid_t)aul_launch_app(slave_pkgname(slave), param);
bundle_free(param);
switch (slave->pid) {
-#if defined(WEARABLE)
case AUL_R_EHIDDENFORGUEST: /**< App hidden for guest mode */
-#endif
case AUL_R_ENOLAUNCHPAD: /**< no launchpad */
case AUL_R_EILLACC: /**< Illegal Access */
case AUL_R_EINVAL: /**< Invalid argument */
HAPI int slave_activate(struct slave_node *slave)
{
- /*!
- * \note
+ /**
+ * @todo
+ * If a slave is deactivated by OOM killer,
+ * We should not activate it again from here.
+ * Instead of this, it should be reactivated by user event or oom event(normal)
+ */
+
+ /**
+ * @note
* This check code can be replaced with the slave->state check code
* If the slave data has the PID, it means, it is activated
* Even if it is in the termiating sequence, it will have the PID
- * before terminated at last.
+ * until it is terminated at last.
* So we can use this simple code for checking the slave's last state.
- * about it is alive? or not.
+ * whether it is alive or not.
*/
if (slave_pid(slave) != (pid_t)-1) {
if (slave->terminate_timer) {
} else if (slave_state(slave) == SLAVE_REQUEST_TO_TERMINATE || slave_state(slave) == SLAVE_REQUEST_TO_DISCONNECT) {
slave_set_reactivation(slave, 1);
}
- return LB_STATUS_ERROR_ALREADY;
+ return DBOX_STATUS_ERROR_ALREADY;
} else if (slave_state(slave) == SLAVE_REQUEST_TO_LAUNCH) {
DbgPrint("Slave is already launched: but the AUL is timed out\n");
- return LB_STATUS_ERROR_ALREADY;
+ return DBOX_STATUS_ERROR_ALREADY;
}
- if (DEBUG_MODE) {
+ if (DYNAMICBOX_CONF_DEBUG_MODE || g_conf.debug_mode) {
DbgPrint("Debug Mode enabled. name[%s] secured[%d] abi[%s]\n", slave_name(slave), slave->secured, slave->abi);
} else {
bundle *param;
- slave->relaunch_count = SLAVE_RELAUNCH_COUNT;
+ slave->relaunch_count = DYNAMICBOX_CONF_SLAVE_RELAUNCH_COUNT;
param = bundle_create();
if (!param) {
ErrPrint("Failed to create a bundle\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
- bundle_add(param, BUNDLE_SLAVE_NAME, slave_name(slave));
- bundle_add(param, BUNDLE_SLAVE_SECURED, slave->secured ? "true" : "false");
- bundle_add(param, BUNDLE_SLAVE_ABI, slave->abi);
+ bundle_add(param, BUNDLE_SLAVE_SVC_OP_TYPE, APP_CONTROL_OPERATION_MAIN);
+ bundle_add(param, DYNAMICBOX_CONF_BUNDLE_SLAVE_NAME, slave_name(slave));
+ bundle_add(param, DYNAMICBOX_CONF_BUNDLE_SLAVE_SECURED, ((DBOX_IS_INHOUSE(slave_abi(slave)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL) || slave->secured) ? "true" : "false");
+ bundle_add(param, DYNAMICBOX_CONF_BUNDLE_SLAVE_ABI, slave->abi);
+ bundle_add(param, DYNAMICBOX_CONF_BUNDLE_SLAVE_HW_ACCELERATION, slave->hw_acceleration);
slave->pid = (pid_t)aul_launch_app(slave_pkgname(slave), param);
bundle_free(param);
switch (slave->pid) {
-#if defined(WEARABLE)
case AUL_R_EHIDDENFORGUEST: /**< App hidden for guest mode */
-#endif
case AUL_R_ENOLAUNCHPAD: /**< no launchpad */
case AUL_R_EILLACC: /**< Illegal Access */
case AUL_R_EINVAL: /**< Invalid argument */
case AUL_R_ECANCELED: /**< Operation canceled */
case AUL_R_ETIMEOUT: /**< Timeout */
CRITICAL_LOG("Try relaunch this soon %s (%d)\n", slave_name(slave), slave->pid);
- slave->relaunch_timer = ecore_timer_add(SLAVE_RELAUNCH_TIME, relaunch_timer_cb, slave);
+ slave->relaunch_timer = ecore_timer_add(DYNAMICBOX_CONF_SLAVE_RELAUNCH_TIME, relaunch_timer_cb, slave);
if (!slave->relaunch_timer) {
CRITICAL_LOG("Failed to register a relaunch timer (%s)\n", slave_name(slave));
slave->pid = (pid_t)-1;
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
/* Try again after a few secs later */
break;
break;
}
- slave->activate_timer = ecore_timer_add(SLAVE_ACTIVATE_TIME, activate_timer_cb, slave);
+ slave->activate_timer = ecore_timer_add(DYNAMICBOX_CONF_SLAVE_ACTIVATE_TIME, activate_timer_cb, slave);
if (!slave->activate_timer) {
ErrPrint("Failed to register an activate timer\n");
}
*/
(void)slave_ref(slave);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_give_more_ttl(struct slave_node *slave)
{
double delay;
- if (!slave->secured || !slave->ttl_timer) {
- return LB_STATUS_ERROR_INVALID;
+ if (!(DBOX_IS_INHOUSE(slave_abi(slave)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL) && (!slave->secured || !slave->ttl_timer)) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- delay = SLAVE_TTL - ecore_timer_pending_get(slave->ttl_timer);
+ delay = DYNAMICBOX_CONF_SLAVE_TTL - ecore_timer_pending_get(slave->ttl_timer);
ecore_timer_delay(slave->ttl_timer, delay);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_freeze_ttl(struct slave_node *slave)
{
- if (!slave->secured || !slave->ttl_timer) {
- return LB_STATUS_ERROR_INVALID;
+ if (!(DBOX_IS_INHOUSE(slave_abi(slave)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL) && (!slave->secured || !slave->ttl_timer)) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ecore_timer_freeze(slave->ttl_timer);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_thaw_ttl(struct slave_node *slave)
{
double delay;
- if (!slave->secured || !slave->ttl_timer) {
- return LB_STATUS_ERROR_INVALID;
+ if (!(DBOX_IS_INHOUSE(slave_abi(slave)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL) && (!slave->secured || !slave->ttl_timer)) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
ecore_timer_thaw(slave->ttl_timer);
- delay = SLAVE_TTL - ecore_timer_pending_get(slave->ttl_timer);
+ delay = DYNAMICBOX_CONF_SLAVE_TTL - ecore_timer_pending_get(slave->ttl_timer);
ecore_timer_delay(slave->ttl_timer, delay);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_activated(struct slave_node *slave)
slave_pause(slave);
}
- if (slave->secured == 1 && SLAVE_TTL > 0.0f) {
- DbgPrint("Slave deactivation timer is added (%s - %lf)\n", slave_name(slave), SLAVE_TTL);
- slave->ttl_timer = ecore_timer_add(SLAVE_TTL, slave_ttl_cb, slave);
+ if (((DBOX_IS_INHOUSE(slave_abi(slave)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL) || slave->secured == 1) && DYNAMICBOX_CONF_SLAVE_TTL > 0.0f) {
+ DbgPrint("Slave deactivation timer is added (%s - %lf)\n", slave_name(slave), DYNAMICBOX_CONF_SLAVE_TTL);
+ slave->ttl_timer = ecore_timer_add(DYNAMICBOX_CONF_SLAVE_TTL, slave_ttl_cb, slave);
if (!slave->ttl_timer) {
ErrPrint("Failed to create a TTL timer\n");
}
slave->relaunch_timer = NULL;
}
- return LB_STATUS_SUCCESS;
+ slave_set_priority(slave, LOW_PRIORITY);
+ return DBOX_STATUS_ERROR_NONE;
}
static inline int invoke_deactivate_cb(struct slave_node *slave)
return reactivate;
}
-static Eina_Bool terminate_timer_cb(void *data)
-{
- struct slave_node *slave = data;
- int ret;
-
- /*!
- * \todo
- * check the return value of the aul_terminate_pid
- */
- slave->state = SLAVE_REQUEST_TO_TERMINATE;
- slave->terminate_timer = NULL;
-
- DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
- ret = aul_terminate_pid(slave->pid);
- if (ret < 0) {
- ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
- slave = slave_deactivated(slave);
- if (slave == NULL) {
- DbgPrint("Slave is deleted\n");
- }
- }
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-HAPI struct slave_node *slave_deactivate(struct slave_node *slave, int no_timer)
-{
- int ret;
-
- if (!slave_is_activated(slave)) {
- ErrPrint("Slave is already deactivated\n");
- if (slave_loaded_instance(slave) == 0) {
- /*!
- * \note
- * If a slave has no more instances,
- * Destroy it
- */
- slave = slave_unref(slave);
- }
- return slave;
- }
-
- if (slave_pid(slave) <= 0) {
- return slave;
- }
-
- if ((slave->ctrl_option & PROVIDER_CTRL_MANUAL_TERMINATION) == PROVIDER_CTRL_MANUAL_TERMINATION) {
- /*!
- * \note
- * In this case,
- * The provider requests MANUAL TERMINATION control option.
- * Master will not send terminate request in this case, the provider should be terminated by itself.
- */
- DbgPrint("Manual termination is turned on\n");
- slave->state = SLAVE_REQUEST_TO_DISCONNECT;
- (void)slave_rpc_disconnect(slave);
- } else if (slave->terminate_timer) {
- ErrPrint("Terminate timer is already fired (%d)\n", slave->pid);
- } else if (!no_timer) {
- DbgPrint("Fire the terminate timer: %d\n", slave->pid);
- slave->terminate_timer = ecore_timer_add(SLAVE_ACTIVATE_TIME, terminate_timer_cb, slave);
- if (!slave->terminate_timer) {
- /*!
- * \note
- * Normally, Call the terminate_timer_cb directly from here
- * But in this case. if the aul_terminate_pid failed, Call the slave_deactivated function directly.
- * Then the "slave" pointer can be changed. To trace it, Copy the body of terminate_timer_cb to here.
- */
- ErrPrint("Failed to add a new timer for terminating\n");
- DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
- /*!
- * \todo
- * check the return value of the aul_terminate_pid
- */
- slave->state = SLAVE_REQUEST_TO_TERMINATE;
-
- ret = aul_terminate_pid(slave->pid);
- if (ret < 0) {
- ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
- slave = slave_deactivated(slave);
- }
- }
- } else {
- /*!
- * \todo
- * check the return value of the aul_terminate_pid
- */
- slave->state = SLAVE_REQUEST_TO_TERMINATE;
-
- DbgPrint("Terminate slave: %d (%s)\n", slave_pid(slave), slave_name(slave));
- ret = aul_terminate_pid(slave->pid);
- if (ret < 0) {
- ErrPrint("Terminate slave(%s) failed. pid %d (%d)\n", slave_name(slave), slave_pid(slave), ret);
- slave = slave_deactivated(slave);
- }
- }
-
- return slave;
-}
-
HAPI struct slave_node *slave_deactivated(struct slave_node *slave)
{
int reactivate;
slave->terminate_timer = NULL;
}
+ /**
+ * @note
+ * FOR SAFETY
+ * If the deactivated event callback is called for package.c
+ * It can delete the instance if it has fault information
+ * then it also try to delete the slave object again.
+ * To prevent from unexpected slave object deletetion while handling callback,
+ * increase the refcnt of slave
+ * when it get back from callback, try to decrease the refcnt of slave
+ * At that time, we can delete slave safely.
+ */
+ slave_ref(slave);
reactivate = invoke_deactivate_cb(slave);
+ slave = slave_unref(slave);
+ if (!slave) {
+ ErrPrint("Slave object is deleted\n");
+ return slave;
+ }
slave = slave_unref(slave);
if (!slave) {
* The master will not reactivate it automatically.
*/
DbgPrint("Manual reactivate option is turned on\n");
- } else if (reactivate && slave_need_to_reactivate(slave)) {
+ } else if (reactivate && slave_need_to_reactivate(slave) && setting_oom_level() == OOM_TYPE_NORMAL) {
int ret;
DbgPrint("Need to reactivate a slave\n");
ret = slave_activate(slave);
- if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY) {
+ if (ret < 0 && ret != DBOX_STATUS_ERROR_ALREADY) {
ErrPrint("Failed to reactivate a slave\n");
}
} else if (slave_loaded_instance(slave) == 0) {
int ret;
int reactivate = 1;
int reactivate_instances = 1;
+ int max_load;
+
+ if (g_conf.slave_max_load < 0) {
+ max_load = DYNAMICBOX_CONF_SLAVE_MAX_LOAD;
+ } else {
+ max_load = g_conf.slave_max_load;
+ }
if (!slave_is_activated(slave)) {
DbgPrint("Deactivating in progress\n");
if (slave_pid(slave) > 0) {
DbgPrint("Try to terminate PID: %d\n", slave_pid(slave));
- ret = aul_terminate_pid(slave_pid(slave));
+ ret = aul_terminate_pid_async(slave_pid(slave));
if (ret < 0) {
ErrPrint("Terminate failed, pid %d\n", slave_pid(slave));
}
double faulted_at;
faulted_at = ecore_time_get();
- if (faulted_at - slave->activated_at < MINIMUM_REACTIVATION_TIME) {
+ if (faulted_at - slave->activated_at < DYNAMICBOX_CONF_MINIMUM_REACTIVATION_TIME) {
slave->critical_fault_count++;
- if (!slave_loaded_instance(slave) || slave->critical_fault_count >= SLAVE_MAX_LOAD) {
+
+ if (!slave_loaded_instance(slave) || slave->critical_fault_count >= max_load) {
ErrPrint("Reactivation time is too fast and frequently occurred - Stop to auto reactivation\n");
reactivate = 0;
reactivate_instances = 0;
* \note
* Fault callback can access the slave information.
*/
- invoke_fault_cb(slave);
+ if (invoke_fault_cb(slave) == NULL) {
+ ErrPrint("Slave is deleted while processing fault handler\n");
+ return NULL;
+ }
} else {
slave->critical_fault_count = 0;
}
struct timeval rtv;
timersub(&faulted_at, &slave->activated_at, &rtv);
- if (rtv.tv_sec < MINIMUM_REACTIVATION_TIME) {
+ if (rtv.tv_sec < DYNAMICBOX_CONF_MINIMUM_REACTIVATION_TIME) {
slave->critical_fault_count++;
- if (!slave_loaded_instance(slave) || slave->critical_fault_count >= SLAVE_MAX_LOAD) {
+ if (!slave_loaded_instance(slave) || slave->critical_fault_count >= max_load) {
ErrPrint("Reactivation time is too fast and frequently occurred - Stop to auto reactivation\n");
reactivate = 0;
reactivate_instances = 0;
* \note
* Fault callback can access the slave information.
*/
- invoke_fault_cb(slave);
+ if (invoke_fault_cb(slave) == NULL) {
+ ErrPrint("Slave is deleted while processing fault handler\n");
+ return NULL;
+ }
}
} else {
slave->critical_fault_count = 0;
* To send the last request to the provider.
*/
case SLAVE_REQUEST_TO_LAUNCH:
- /* Not yet launched. but the slave incurred an unexpected error */
+ /* Not yet launched. but the slave incurred an unexpected error */
case SLAVE_REQUEST_TO_PAUSE:
case SLAVE_REQUEST_TO_RESUME:
case SLAVE_PAUSED:
ev = calloc(1, sizeof(*ev));
if (!ev) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
ev->slave = slave;
break;
default:
DbgFree(ev);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_event_callback_del(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data)
slave->event_deactivate_list = eina_list_remove(slave->event_deactivate_list, ev);
DbgFree(ev);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
slave->event_delete_list = eina_list_remove(slave->event_delete_list, ev);
DbgFree(ev);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
slave->event_activate_list = eina_list_remove(slave->event_activate_list, ev);
DbgFree(ev);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
slave->event_pause_list = eina_list_remove(slave->event_pause_list, ev);
DbgFree(ev);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
slave->event_resume_list = eina_list_remove(slave->event_resume_list, ev);
DbgFree(ev);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
slave->event_fault_list = eina_list_remove(slave->event_fault_list, ev);
DbgFree(ev);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
default:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
HAPI int slave_set_data(struct slave_node *slave, const char *tag, void *data)
priv = calloc(1, sizeof(*priv));
if (!priv) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
priv->tag = strdup(tag);
if (!priv->tag) {
ErrPrint("Heap: %s\n", strerror(errno));
DbgFree(priv);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
priv->data = data;
slave->data_list = eina_list_append(slave->data_list, priv);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void *slave_del_data(struct slave_node *slave, const char *tag)
return NULL;
}
-HAPI struct slave_node *slave_find_available(const char *abi, int secured, int network)
+HAPI struct slave_node *slave_find_available(const char *slave_pkgname, const char *abi, int secured, int network, const char *hw_acceleration)
{
Eina_List *l;
struct slave_node *slave;
continue;
}
+ if (strcasecmp(slave->pkgname, slave_pkgname)) {
+ continue;
+ }
+
+ if (slave->hw_acceleration != hw_acceleration) {
+ if (!slave->hw_acceleration || !hw_acceleration || strcasecmp(slave->hw_acceleration, hw_acceleration)) {
+ continue;
+ }
+ }
+
if (slave->secured) {
if (slave->loaded_package == 0) {
DbgPrint("Found secured slave - has no instances (%s)\n", slave_name(slave));
}
} else if (slave->network == network) {
DbgPrint("slave[%s] loaded_package[%d] net: [%d]\n", slave_name(slave), slave->loaded_package, slave->network);
- if (!strcasecmp(abi, DEFAULT_ABI)) {
- if (slave->loaded_package < SLAVE_MAX_LOAD) {
+ if (!strcasecmp(abi, DYNAMICBOX_CONF_DEFAULT_ABI)) {
+ int max_load;
+ if (g_conf.slave_max_load < 0) {
+ max_load = DYNAMICBOX_CONF_SLAVE_MAX_LOAD;
+ } else {
+ max_load = g_conf.slave_max_load;
+ }
+
+ if (slave->loaded_package < max_load) {
return slave;
}
} else {
return NULL;
}
+HAPI char *slave_package_name(const char *abi, const char *lbid)
+{
+ char *s_pkgname;
+ const char *tmp;
+
+ tmp = abi_find_slave(abi);
+ if (!tmp) {
+ ErrPrint("Failed to find a proper pkgname of a slave\n");
+ return NULL;
+ }
+
+ s_pkgname = util_replace_string(tmp, DYNAMICBOX_CONF_REPLACE_TAG_APPID, lbid);
+ if (!s_pkgname) {
+ DbgPrint("Failed to get replaced string\n");
+ s_pkgname = strdup(tmp);
+ if (!s_pkgname) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return NULL;
+ }
+ }
+
+ return s_pkgname;
+}
+
HAPI void slave_load_package(struct slave_node *slave)
{
slave->loaded_package++;
ErrPrint("Slave loaded package is not correct\n");
return;
}
-
+
slave->loaded_package--;
}
HAPI int slave_set_pid(struct slave_node *slave, pid_t pid)
{
if (!slave) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
DbgPrint("Slave PID is updated to %d from %d\n", pid, slave_pid(slave));
slave->pid = pid;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline void invoke_resumed_cb(struct slave_node *slave)
{
double timestamp;
struct packet *packet;
+ unsigned int cmd = CMD_RESUME;
switch (slave->state) {
case SLAVE_REQUEST_TO_DISCONNECT:
case SLAVE_REQUEST_TO_LAUNCH:
case SLAVE_REQUEST_TO_TERMINATE:
case SLAVE_TERMINATED:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
case SLAVE_RESUMED:
case SLAVE_REQUEST_TO_RESUME:
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
default:
break;
}
timestamp = util_timestamp();
- packet = packet_create("resume", "d", timestamp);
+ packet = packet_create((const char *)&cmd, "d", timestamp);
if (!packet) {
ErrPrint("Failed to prepare param\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
slave->state = SLAVE_REQUEST_TO_RESUME;
{
double timestamp;
struct packet *packet;
+ unsigned int cmd = CMD_PAUSE;
switch (slave->state) {
case SLAVE_REQUEST_TO_DISCONNECT:
case SLAVE_REQUEST_TO_LAUNCH:
case SLAVE_REQUEST_TO_TERMINATE:
case SLAVE_TERMINATED:
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
case SLAVE_PAUSED:
case SLAVE_REQUEST_TO_PAUSE:
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
default:
break;
}
timestamp = util_timestamp();
- packet = packet_create("pause", "d", timestamp);
+ packet = packet_create((const char *)&cmd, "d", timestamp);
if (!packet) {
ErrPrint("Failed to prepare param\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
slave->state = SLAVE_REQUEST_TO_PAUSE;
DbgPrint("Deactivate all\n");
EINA_LIST_FOREACH_SAFE(s_info.slave_list, l, n, slave) {
- slave_set_reactivate_instances(slave, reactivate_instances);
- slave_set_reactivation(slave, reactivate);
+ if (slave_is_activated(slave)) {
+ slave_set_reactivate_instances(slave, reactivate_instances);
+ slave_set_reactivation(slave, reactivate);
- if (!slave_deactivate(slave, no_timer)) {
- s_info.slave_list = eina_list_remove(s_info.slave_list, slave);
+ if (!slave_deactivate(slave, no_timer)) {
+ s_info.slave_list = eina_list_remove(s_info.slave_list, slave);
+ }
}
cnt++;
return slave->ctrl_option;
}
+HAPI int slave_set_priority(struct slave_node *slave, int priority)
+{
+ pid_t pid;
+
+ if (!slave) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ pid = slave_pid(slave);
+ if (pid < 0) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ if (setpriority(PRIO_PROCESS, slave_pid(slave), priority) < 0) {
+ ErrPrint("setpriority: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return DBOX_STATUS_ERROR_NONE;
+}
+
+HAPI int slave_priority(struct slave_node *slave)
+{
+ pid_t pid;
+ int priority;
+
+ if (!slave) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ pid = slave_pid(slave);
+ if (pid < 0) {
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
+ }
+
+ priority = getpriority(PRIO_PROCESS, pid);
+ if (priority < 0) {
+ ErrPrint("getpriority: %s\n", strerror(errno));
+ return DBOX_STATUS_ERROR_FAULT;
+ }
+
+ return priority;
+}
+
/* End of a file */
#include <packet.h>
#include <com-core_packet.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_service.h>
+#include <dynamicbox_cmd_list.h>
+#include <dynamicbox_conf.h>
#include "debug.h"
#include "slave_life.h"
#define DEFAULT_CMD_TTL 3
-static inline void prepend_command(struct command *command);
+static void prepend_command(struct command *command);
static inline struct command *create_command(struct slave_node *slave, const char *pkgname, struct packet *packet)
{
if (!command) {
ErrPrint("Command is NIL\n");
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/*!
* Slave will be deactivated from dead monitor if it lost its connections.
* So we don't need to care it again from here.
- command->slave = slave_deactivated_by_fault(command->slave);
+ command->slave = slave_deactivated_by_fault(command->slave);
*/
goto out;
out:
destroy_command(command);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static Eina_Bool command_consumer_cb(void *data)
return ECORE_CALLBACK_RENEW;
}
-static inline void prepend_command(struct command *command)
+static void prepend_command(struct command *command)
{
s_info.command_list = eina_list_prepend(s_info.command_list, command);
return;
}
- s_info.command_consuming_timer = ecore_timer_add(PACKET_TIME, command_consumer_cb, NULL);
+ s_info.command_consuming_timer = ecore_timer_add(DYNAMICBOX_CONF_PACKET_TIME, command_consumer_cb, NULL);
if (!s_info.command_consuming_timer) {
ErrPrint("Failed to add command consumer\n");
s_info.command_list = eina_list_remove(s_info.command_list, command);
}
}
-static inline void push_command(struct command *command)
+static void push_command(struct command *command)
{
s_info.command_list = eina_list_append(s_info.command_list, command);
return;
}
- s_info.command_consuming_timer = ecore_timer_add(PACKET_TIME, command_consumer_cb, NULL);
+ s_info.command_consuming_timer = ecore_timer_add(DYNAMICBOX_CONF_PACKET_TIME, command_consumer_cb, NULL);
if (!s_info.command_consuming_timer) {
ErrPrint("Failed to add command consumer\n");
s_info.command_list = eina_list_remove(s_info.command_list, command);
* \note
* Return negative value will remove this callback from the event list of the slave
*/
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (rpc->pong_timer) {
*/
rpc->ping_count = 0;
rpc->next_ping_count = 1;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static Eina_Bool ping_timeout_cb(void *data)
}
packet_unref(packet);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
command->ret_cb = ret_cb;
ret_cb(slave, NULL, data);
}
destroy_command(command);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (rpc->handle < 0) {
DbgPrint("RPC handle is not ready to use it\n");
- if (((slave_control_option(slave) & PROVIDER_CTRL_MANUAL_REACTIVATION) == PROVIDER_CTRL_MANUAL_REACTIVATION || slave_is_secured(slave))
- && !slave_is_activated(slave))
+ if (((slave_control_option(slave) & PROVIDER_CTRL_MANUAL_REACTIVATION) == PROVIDER_CTRL_MANUAL_REACTIVATION || slave_is_secured(slave) || (DBOX_IS_INHOUSE(slave_abi(slave)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL))
+ && !slave_is_activated(slave))
{
int ret;
DbgPrint("Activate slave forcely\n");
ret = slave_activate(slave);
- if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY) {
+ if (ret < 0 && ret != DBOX_STATUS_ERROR_ALREADY) {
if (ret_cb) {
ret_cb(slave, NULL, data);
rpc->pending_list = eina_list_append(rpc->pending_list, command);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
if (urgent) {
push_command(command);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_rpc_request_only(struct slave_node *slave, const char *pkgname, struct packet *packet, int urgent)
if (!command) {
ErrPrint("Failed to create a command\n");
packet_unref(packet);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
command->ret_cb = NULL;
if (!rpc) {
ErrPrint("Slave has no RPC\n");
destroy_command(command);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
if (rpc->handle < 0) {
DbgPrint("RPC handle is not ready to use it\n");
- if (((slave_control_option(slave) & PROVIDER_CTRL_MANUAL_REACTIVATION) == PROVIDER_CTRL_MANUAL_REACTIVATION || slave_is_secured(slave))
- && !slave_is_activated(slave))
- {
+ if (((slave_control_option(slave) & PROVIDER_CTRL_MANUAL_REACTIVATION) == PROVIDER_CTRL_MANUAL_REACTIVATION || slave_is_secured(slave) || (DBOX_IS_INHOUSE(slave_abi(slave)) && DYNAMICBOX_CONF_SLAVE_LIMIT_TO_TTL))
+ && !slave_is_activated(slave))
+ {
int ret;
DbgPrint("Activate slave forcely\n");
ret = slave_activate(slave);
- if (ret < 0 && ret != LB_STATUS_ERROR_ALREADY) {
+ if (ret < 0 && ret != DBOX_STATUS_ERROR_ALREADY) {
destroy_command(command);
return ret;
}
rpc->pending_list = eina_list_append(rpc->pending_list, command);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
if (urgent) {
push_command(command);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_rpc_update_handle(struct slave_node *slave, int handle)
rpc = slave_data(slave, "rpc");
if (!rpc) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
DbgPrint("SLAVE: New handle assigned for %d, %d\n", slave_pid(slave), handle);
ecore_timer_del(rpc->pong_timer);
}
- rpc->pong_timer = ecore_timer_add(DEFAULT_PING_TIME, ping_timeout_cb, slave);
+ rpc->pong_timer = ecore_timer_add(DYNAMICBOX_CONF_DEFAULT_PING_TIME, ping_timeout_cb, slave);
if (!rpc->pong_timer) {
ErrPrint("Failed to add ping timer\n");
}
push_command(command);
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_rpc_init(struct slave_node *slave)
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;
}
if (slave_set_data(slave, "rpc", rpc) < 0) {
DbgFree(rpc);
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
if (slave_event_callback_add(slave, SLAVE_EVENT_DEACTIVATE, slave_deactivate_cb, NULL) < 0) {
rpc->next_ping_count = 1;
rpc->handle = -1;
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_rpc_fini(struct slave_node *slave)
rpc = slave_del_data(slave, "rpc");
if (!rpc) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
slave_event_callback_del(slave, SLAVE_EVENT_DEACTIVATE, slave_deactivate_cb, NULL);
}
DbgFree(rpc);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_rpc_ping(struct slave_node *slave)
rpc = slave_data(slave, "rpc");
if (!rpc) {
ErrPrint("Slave RPC is not valid\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (!slave_is_activated(slave)) {
ErrPrint("Slave is not activated\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
rpc->ping_count++;
rpc->next_ping_count++;
ecore_timer_reset(rpc->pong_timer);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_rpc_ping_freeze(struct slave_node *slave)
rpc = slave_data(slave, "rpc");
if (!rpc) {
ErrPrint("Slave RPC is not valid\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (!slave_is_activated(slave)) {
ErrPrint("Slave is not activated\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
ecore_timer_freeze(rpc->pong_timer);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int slave_rpc_ping_thaw(struct slave_node *slave)
rpc = slave_data(slave, "rpc");
if (!rpc) {
ErrPrint("Slave RPC is not valid\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (!slave_is_activated(slave)) {
ErrPrint("Slave is not activated\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
ecore_timer_thaw(rpc->pong_timer);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void slave_rpc_request_update(const char *pkgname, const char *id, const char *cluster, const char *category, const char *content, int force)
struct slave_node *slave;
struct pkg_info *info;
struct packet *packet;
+ unsigned int cmd = CMD_UPDATE_CONTENT;
info = package_find(pkgname);
if (!info) {
return;
}
- packet = packet_create_noack("update_content", "sssssi", pkgname, id, cluster, category, content, force);
+ packet = packet_create_noack((const char *)&cmd, "sssssi", pkgname, id, cluster, category, content, force);
if (!packet) {
ErrPrint("Failed to create a new param\n");
return;
rpc = slave_data(slave, "rpc");
if (!rpc) {
DbgPrint("Slave RPC is not initiated\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
return rpc->handle;
HAPI int slave_rpc_disconnect(struct slave_node *slave)
{
struct packet *packet;
+ unsigned int cmd = CMD_DISCONNECT;
- packet = packet_create_noack("disconnect", "d", util_timestamp());
+ packet = packet_create_noack((const char *)&cmd, "d", util_timestamp());
if (!packet) {
ErrPrint("Failed to create a packet\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
DbgPrint("Send disconnection request packet\n");
#include <Eina.h>
#include <Ecore.h>
#if defined(HAVE_LIVEBOX)
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_conf.h>
#else
#include "lite-errno.h"
+#define DYNAMICBOX_CONF_IMAGE_PATH "/tmp/"
#endif
#include "util.h"
name_len = strlen(filename);
while (--name_len >= 0 && *check_ptr) {
if (filename[name_len] != *check_ptr) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
check_ptr ++;
}
- return LB_STATUS_SUCCESS;
-}
-
-static inline int check_native_livebox(const char *pkgname)
-{
- int len;
- char *path;
-
- len = strlen(pkgname) * 2;
- len += strlen(ROOT_PATH);
- len += strlen("%s/libexec/liblive-%s.so");
-
- path = malloc(len + 1);
- if (!path) {
- ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
- }
-
- snprintf(path, len, "%s%s/libexec/liblive-%s.so", ROOT_PATH, pkgname, pkgname);
- if (access(path, F_OK | R_OK) != 0) {
- ErrPrint("%s is not a valid package\n", pkgname);
- DbgFree(path);
- return LB_STATUS_ERROR_INVALID;
- }
-
- DbgFree(path);
- return LB_STATUS_SUCCESS;
-}
-
-static inline int check_web_livebox(const char *pkgname)
-{
- int len;
- char *path;
-
- len = strlen(pkgname) * 2;
- len += strlen("/opt/usr/apps/%s/res/wgt/livebox/index.html");
-
- path = malloc(len + 1);
- if (!path) {
- ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
- }
-
- snprintf(path, len, "/opt/usr/apps/%s/res/wgt/livebox/index.html", pkgname);
- if (access(path, F_OK | R_OK) != 0) {
- ErrPrint("%s is not a valid package\n", pkgname);
- DbgFree(path);
- return LB_STATUS_ERROR_INVALID;
- }
-
- DbgFree(path);
- return LB_STATUS_SUCCESS;
-}
-
-HAPI int util_validate_livebox_package(const char *pkgname)
-{
- if (!pkgname) {
- ErrPrint("Invalid argument\n");
- return LB_STATUS_ERROR_INVALID;
- }
-
- if (!check_native_livebox(pkgname) || !check_web_livebox(pkgname)) {
- return LB_STATUS_SUCCESS;
- }
-
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int util_unlink(const char *filename)
int ret;
if (!filename) {
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
desclen = strlen(filename) + 6; /* .desc */
descfile = malloc(desclen);
if (!descfile) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
ret = snprintf(descfile, desclen, "%s.desc", filename);
if (ret < 0) {
ErrPrint("Error: %s\n", strerror(errno));
DbgFree(descfile);
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
(void)unlink(descfile);
DbgFree(descfile);
(void)unlink(filename);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI char *util_slavename(void)
if (lstat(folder, &info) < 0) {
ErrPrint("Error: %s\n", strerror(errno));
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
if (!S_ISDIR(info.st_mode)) {
ErrPrint("Error: %s is not a folder", folder);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
handle = opendir(folder);
if (!handle) {
ErrPrint("Error: %s\n", strerror(errno));
- return LB_STATUS_ERROR_IO;
+ return DBOX_STATUS_ERROR_IO_ERROR;
}
while ((entry = readdir(handle))) {
if (closedir(handle) < 0) {
ErrPrint("closedir: %s\n", strerror(errno));
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void util_remove_emergency_disk(void)
{
int ret;
- ret = umount(IMAGE_PATH);
+ ret = umount(DYNAMICBOX_CONF_IMAGE_PATH);
if (ret < 0) {
ErrPrint("umount: %s\n", strerror(errno));
}
- DbgPrint("Try to unmount[%s] %d\n", IMAGE_PATH, ret);
+ DbgPrint("Try to unmount[%s] %d\n", DYNAMICBOX_CONF_IMAGE_PATH, ret);
s_info.emergency_mounted = 0;
}
TAG_ERROR
};
- buf = strdup(EMERGENCY_DISK);
+ buf = strdup(DYNAMICBOX_CONF_EMERGENCY_DISK);
if (!buf) {
ErrPrint("Failed to prepare emergency disk info\n");
return;
DbgPrint("source[%s] type[%s] option[%s]\n", source, type, option);
- ret = mount(source, IMAGE_PATH, type, MS_NOSUID | MS_NOEXEC, option);
+ ret = mount(source, DYNAMICBOX_CONF_IMAGE_PATH, type, MS_NOSUID | MS_NOEXEC, option);
DbgFree(buf);
if (ret < 0) {
ErrPrint("Failed to mount: %s\n", strerror(errno));
return;
}
- MINIMUM_SPACE = 0;
-
- ErrPrint("Disk space is not enough, use the tmpfs. Currently required minimum space is %lu bytes\n", MINIMUM_SPACE);
- if (chmod(IMAGE_PATH, 0750) < 0) {
+ ErrPrint("Disk space is not enough, use the tmpfs. Currently required minimum space is %lu bytes\n", DYNAMICBOX_CONF_MINIMUM_SPACE);
+ if (chmod(DYNAMICBOX_CONF_IMAGE_PATH, 0750) < 0) {
ErrPrint("chmod: %s\n", strerror(errno));
}
- if (chown(IMAGE_PATH, 5000, 5000) < 0) {
+ if (chown(DYNAMICBOX_CONF_IMAGE_PATH, 5000, 5000) < 0) {
ErrPrint("chown: %s\n", strerror(errno));
}
- ret = smack_setlabel(IMAGE_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
+ ret = smack_setlabel(DYNAMICBOX_CONF_IMAGE_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
if (ret != 0) {
- ErrPrint("Failed to set SMACK for %s (%d)\n", IMAGE_PATH, ret);
+ ErrPrint("Failed to set SMACK for %s (%d)\n", DYNAMICBOX_CONF_IMAGE_PATH, ret);
} else {
- ret = smack_setlabel(IMAGE_PATH, "1", SMACK_LABEL_TRANSMUTE);
- DbgPrint("[%s] is successfully created (t: %d)\n", IMAGE_PATH, ret);
+ ret = smack_setlabel(DYNAMICBOX_CONF_IMAGE_PATH, "1", SMACK_LABEL_TRANSMUTE);
+ DbgPrint("[%s] is successfully created (t: %d)\n", DYNAMICBOX_CONF_IMAGE_PATH, ret);
}
- if (mkdir(ALWAYS_PATH, 0755) < 0) {
- ErrPrint("mkdir: (%s) %s\n", ALWAYS_PATH, strerror(errno));
+ if (mkdir(DYNAMICBOX_CONF_ALWAYS_PATH, 0755) < 0) {
+ ErrPrint("mkdir: (%s) %s\n", DYNAMICBOX_CONF_ALWAYS_PATH, strerror(errno));
} else {
- if (chmod(ALWAYS_PATH, 0750) < 0) {
+ if (chmod(DYNAMICBOX_CONF_ALWAYS_PATH, 0750) < 0) {
ErrPrint("chmod: %s\n", strerror(errno));
}
- if (chown(ALWAYS_PATH, 5000, 5000) < 0) {
+ if (chown(DYNAMICBOX_CONF_ALWAYS_PATH, 5000, 5000) < 0) {
ErrPrint("chown: %s\n", strerror(errno));
}
- ret = smack_setlabel(ALWAYS_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
+ ret = smack_setlabel(DYNAMICBOX_CONF_ALWAYS_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
if (ret != 0) {
- ErrPrint("Failed to set SMACK for %s (%d)\n", ALWAYS_PATH, ret);
+ ErrPrint("Failed to set SMACK for %s (%d)\n", DYNAMICBOX_CONF_ALWAYS_PATH, ret);
} else {
- ret = smack_setlabel(ALWAYS_PATH, "1", SMACK_LABEL_TRANSMUTE);
- DbgPrint("[%s] is successfully created (t: %d)\n", ALWAYS_PATH, ret);
+ ret = smack_setlabel(DYNAMICBOX_CONF_ALWAYS_PATH, "1", SMACK_LABEL_TRANSMUTE);
+ DbgPrint("[%s] is successfully created (t: %d)\n", DYNAMICBOX_CONF_ALWAYS_PATH, ret);
}
}
- if (mkdir(READER_PATH, 0755) < 0) {
- ErrPrint("mkdir: (%s) %s\n", READER_PATH, strerror(errno));
+ if (mkdir(DYNAMICBOX_CONF_READER_PATH, 0755) < 0) {
+ ErrPrint("mkdir: (%s) %s\n", DYNAMICBOX_CONF_READER_PATH, strerror(errno));
} else {
- if (chmod(READER_PATH, 0750) < 0) {
+ if (chmod(DYNAMICBOX_CONF_READER_PATH, 0750) < 0) {
ErrPrint("chmod: %s\n", strerror(errno));
}
- if (chown(READER_PATH, 5000, 5000) < 0) {
+ if (chown(DYNAMICBOX_CONF_READER_PATH, 5000, 5000) < 0) {
ErrPrint("chown: %s\n", strerror(errno));
}
- ret = smack_setlabel(READER_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
+ ret = smack_setlabel(DYNAMICBOX_CONF_READER_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
if (ret != 0) {
- ErrPrint("Failed to set SMACK for %s (%d)\n", READER_PATH, ret);
+ ErrPrint("Failed to set SMACK for %s (%d)\n", DYNAMICBOX_CONF_READER_PATH, ret);
} else {
- ret = smack_setlabel(READER_PATH, "1", SMACK_LABEL_TRANSMUTE);
- DbgPrint("[%s] is successfully created (t: %d)\n", READER_PATH, ret);
+ ret = smack_setlabel(DYNAMICBOX_CONF_READER_PATH, "1", SMACK_LABEL_TRANSMUTE);
+ DbgPrint("[%s] is successfully created (t: %d)\n", DYNAMICBOX_CONF_READER_PATH, ret);
}
}
{
int ret;
- if (access(SLAVE_LOG_PATH, R_OK | W_OK | X_OK) == 0) {
- DbgPrint("[%s] is already accessible\n", SLAVE_LOG_PATH);
+ if (access(DYNAMICBOX_CONF_LOG_PATH, R_OK | W_OK | X_OK) == 0) {
+ DbgPrint("[%s] is already accessible\n", DYNAMICBOX_CONF_LOG_PATH);
return;
}
- DbgPrint("Initiate the critical log folder [%s]\n", SLAVE_LOG_PATH);
- if (mkdir(SLAVE_LOG_PATH, 0755) < 0) {
+ DbgPrint("Initiate the critical log folder [%s]\n", DYNAMICBOX_CONF_LOG_PATH);
+ if (mkdir(DYNAMICBOX_CONF_LOG_PATH, 0755) < 0) {
ErrPrint("mkdir: %s\n", strerror(errno));
} else {
- if (chmod(SLAVE_LOG_PATH, 0750) < 0) {
+ if (chmod(DYNAMICBOX_CONF_LOG_PATH, 0750) < 0) {
ErrPrint("chmod: %s\n", strerror(errno));
}
- if (chown(SLAVE_LOG_PATH, 5000, 5000) < 0) {
+ if (chown(DYNAMICBOX_CONF_LOG_PATH, 5000, 5000) < 0) {
ErrPrint("chown: %s\n", strerror(errno));
}
- ret = smack_setlabel(SLAVE_LOG_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
+ ret = smack_setlabel(DYNAMICBOX_CONF_LOG_PATH, DATA_SHARE_LABEL, SMACK_LABEL_ACCESS);
if (ret != 0) {
- ErrPrint("Failed to set SMACK for %s (%d)\n", SLAVE_LOG_PATH, ret);
+ ErrPrint("Failed to set SMACK for %s (%d)\n", DYNAMICBOX_CONF_LOG_PATH, ret);
} else {
- ret = smack_setlabel(SLAVE_LOG_PATH, "1", SMACK_LABEL_TRANSMUTE);
- DbgPrint("[%s] is successfully created (t: %d)\n", SLAVE_LOG_PATH, ret);
+ ret = smack_setlabel(DYNAMICBOX_CONF_LOG_PATH, "1", SMACK_LABEL_TRANSMUTE);
+ DbgPrint("[%s] is successfully created (t: %d)\n", DYNAMICBOX_CONF_LOG_PATH, ret);
}
}
}
HAPI int util_service_is_enabled(const char *tag)
{
- return !!strcasestr(SERVICES, tag);
+ return !!strcasestr(DYNAMICBOX_CONF_SERVICES, tag);
}
/* End of a file */
#include "util.h"
#if defined(HAVE_LIVEBOX)
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#else
#include "lite-errno.h"
#endif
{
*width = 0;
*height = 0;
- return LB_STATUS_ERROR_NOT_IMPLEMENTED;
+ return DBOX_STATUS_ERROR_NOT_IMPLEMENTED;
}
int util_screen_init(void)
{
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
int util_screen_fini(void)
{
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/* End of a file */
#include <Ecore_X.h>
+#include <dlog.h>
#if defined(HAVE_LIVEBOX)
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#else
#include "lite-errno.h"
#endif
#include "util.h"
+#include "debug.h"
+
+static struct info {
+ int initialized;
+} s_info = {
+ .initialized = 0,
+};
int util_screen_size_get(int *width, int *height)
{
+ if (!s_info.initialized) {
+ ErrPrint("Not initialized\n");
+ return DBOX_STATUS_ERROR_FAULT;
+ }
ecore_x_window_size_get(0, width, height);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
int util_screen_init(void)
{
+ s_info.initialized = 1;
return ecore_x_init(NULL);
}
int util_screen_fini(void)
{
+ s_info.initialized = 0;
return ecore_x_shutdown();
}
#include <dlog.h>
#include <aul.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#include <packet.h>
#include <sys/smack.h>
ctx = malloc(sizeof(*ctx));
if (!ctx) {
ErrPrint("Heap: %s\n", strerror(errno));
- return LB_STATUS_ERROR_MEMORY;
+ return DBOX_STATUS_ERROR_OUT_OF_MEMORY;
}
ctx->tcb = tcb;
s_info.context_list = eina_list_append(s_info.context_list, ctx);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline struct tcb *get_reply_tcb(double seq)
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->tcb = tcb;
if (!item->packet) {
DbgFree(item);
ErrPrint("Unable to ref packet\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
s_info.pending_list = eina_list_append(s_info.pending_list, item);
static int launch_svc(struct service_context *svc_ctx)
{
pid_t pid;
- int ret = LB_STATUS_SUCCESS;
+ int ret = DBOX_STATUS_ERROR_NONE;
pid = aul_launch_app(SVC_PKG, NULL);
switch (pid) {
-#if defined(WEARABLE)
case AUL_R_EHIDDENFORGUEST: /**< App hidden for guest mode */
-#endif
case AUL_R_ENOLAUNCHPAD: /**< no launchpad */
case AUL_R_EILLACC: /**< Illegal Access */
case AUL_R_EINVAL: /**< Invalid argument */
case AUL_R_ENOINIT: /**< AUL handler NOT initialized */
case AUL_R_ERROR: /**< General error */
ErrPrint("Failed to launch an app: %s(%d)\n", SVC_PKG, pid);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
break;
case AUL_R_ETIMEOUT: /**< Timeout */
case AUL_R_ECOMM: /**< Comunication Error */
s_info.delay_launcher = service_common_add_timer(svc_ctx, LAUNCH_TIMEOUT, lazy_launcher_cb, NULL);
if (!s_info.delay_launcher) {
ErrPrint("Unable to add delay launcher\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = DBOX_STATUS_ERROR_FAULT;
}
break;
case AUL_R_LOCAL: /**< Launch by himself */
static int ttl_timer_cb(struct service_context *svc_ctx, void *data)
{
DbgPrint("TTL Timer is expired: PID(%d)\n", s_info.svc_daemon_pid);
- (void)aul_terminate_pid(s_info.svc_daemon_pid);
+ (void)aul_terminate_pid_async(s_info.svc_daemon_pid);
s_info.ttl_timer = NULL;
s_info.svc_daemon_is_launched = 0;
}
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
cmd = packet_command(packet);
if (!cmd) {
ErrPrint("Invalid packet\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
switch (packet_type(packet)) {
case PACKET_REQ:
if (!s_info.svc_daemon_is_launched) {
ret = launch_svc(tcb_svc_ctx(tcb));
- if (ret != LB_STATUS_SUCCESS) {
+ if (ret != DBOX_STATUS_ERROR_NONE) {
goto reply_out;
}
}
if (!strcmp(cmd, "service_register")) {
if (!s_info.svc_daemon_is_launched) {
ErrPrint("Service daemon is not launched. but something tries to register a service\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (s_info.svc_daemon) {
ErrPrint("Service daemon is already prepared\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (s_info.launch_timer) {
if (!s_info.ttl_timer) {
ErrPrint("Failed to add TTL timer\n");
if (s_info.svc_daemon_pid > 0) {
- ret = aul_terminate_pid(s_info.svc_daemon_pid);
+ ret = aul_terminate_pid_async(s_info.svc_daemon_pid);
ErrPrint("Terminate: %d\n", ret);
s_info.svc_daemon_pid = -1;
}
s_info.svc_daemon_is_launched = 0;
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
DbgPrint("TTL Timer is added: %p\n", s_info.ttl_timer);
break;
default:
ErrPrint("Packet type is not valid[%s]\n", cmd);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
reply_out:
ErrPrint("Error: %d\n", ret);
{
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(UTILITY_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), UTILITY_SMACK_LABEL, SMACK_LABEL_IPOUT) != 0) {
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;
}
}
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;
}
int utility_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 */
#include <gio/gio.h>
#include <dlog.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
+#include <dynamicbox_conf.h>
#include "conf.h"
#include "debug.h"
static inline void touch_paused_file(void)
{
int fd;
- fd = creat(PAUSED_FILE, 0644);
+ fd = creat(DYNAMICBOX_CONF_PAUSED_FILE, 0644);
if (fd >= 0) {
if (close(fd) < 0) {
ErrPrint("close: %s\n", strerror(errno));
static inline void remove_paused_file(void)
{
- if (unlink(PAUSED_FILE) < 0) {
+ if (unlink(DYNAMICBOX_CONF_PAUSED_FILE) < 0) {
ErrPrint("Unlink .live.paused: %s\n", strerror(errno));
}
}
sizeof(int), &in_pid, &num) == EINA_FALSE) {
if (ecore_x_netwm_pid_get(win, &pid) == EINA_FALSE) {
ErrPrint("Failed to get PID from a window 0x%X\n", win);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
} else if (in_pid) {
pid = *(int *)in_pid;
DbgFree(in_pid);
} else {
ErrPrint("Failed to get PID\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
return pid;
touch_paused_file();
- sqlite3_release_memory(SQLITE_FLUSH_MAX);
+ sqlite3_release_memory(DYNAMICBOX_CONF_SQLITE_FLUSH_MAX);
malloc_trim(0);
} else {
remove_paused_file();
struct client_node *client;
int pid;
- if (!USE_XMONITOR || target_pid < 0) {
- return LB_STATUS_SUCCESS;
+ if (!DYNAMICBOX_CONF_USE_XMONITOR || target_pid < 0) {
+ return DBOX_STATUS_ERROR_NONE;
}
win = ecore_x_window_focus_get();
DbgPrint("Client window has no focus now\n");
client_paused(client);
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
client = client_find_by_pid(pid);
DbgPrint("Client window has no focus now\n");
client_paused(client);
}
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
if (target_pid != pid) {
}
xmonitor_handle_state_changes();
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static Eina_Bool client_cb(void *data, int type, void *event)
new_item->nr_of_wins = 0;
new_item->wins =
ecore_x_window_children_get(ret,
- &new_item->nr_of_wins);
+ &new_item->nr_of_wins);
if (new_item->wins) {
win_stack =
eina_list_append(win_stack, new_item);
DbgPrint("%d is paused\n", client_pid(client));
client_paused(client);
xmonitor_handle_state_changes();
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int xmonitor_resume(struct client_node *client)
DbgPrint("%d is resumed\n", client_pid(client));
client_resumed(client);
xmonitor_handle_state_changes();
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
static inline void disable_xmonitor(void)
s_info.create_handler =
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CREATE,
- create_cb, NULL);
+ create_cb, NULL);
if (!s_info.create_handler) {
ErrPrint("Failed to add create event handler\n");
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
s_info.destroy_handler =
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY,
- destroy_cb, NULL);
+ destroy_cb, NULL);
if (!s_info.destroy_handler) {
ErrPrint("Failed to add destroy event handler\n");
ecore_event_handler_del(s_info.create_handler);
s_info.create_handler = NULL;
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
s_info.client_handler =
ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
- client_cb, NULL);
+ client_cb, NULL);
if (!s_info.client_handler) {
ErrPrint("Failed to add focus out event handler\n");
ecore_event_handler_del(s_info.create_handler);
ecore_event_handler_del(s_info.destroy_handler);
s_info.create_handler = NULL;
s_info.destroy_handler = NULL;
- return LB_STATUS_ERROR_FAULT;
+ return DBOX_STATUS_ERROR_FAULT;
}
sniff_all_windows();
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int xmonitor_init(void)
{
- if (USE_XMONITOR) {
+ if (DYNAMICBOX_CONF_USE_XMONITOR) {
int ret;
ret = enable_xmonitor();
if (ret < 0) {
remove_paused_file();
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void xmonitor_fini(void)
{
- if (USE_XMONITOR) {
+ if (DYNAMICBOX_CONF_USE_XMONITOR) {
disable_xmonitor();
}
}
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;
default:
ErrPrint("Invalid event type\n");
DbgFree(item);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int xmonitor_del_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data)
if (item->cb == cb && item->user_data == user_data) {
s_info.pause_list = eina_list_remove(s_info.pause_list, item);
DbgFree(item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
if (item->cb == cb && item->user_data == user_data) {
s_info.resume_list = eina_list_remove(s_info.resume_list, item);
DbgFree(item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
default:
ErrPrint("Invalid event type\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
HAPI int xmonitor_is_paused(void)
#include <gio/gio.h>
#include <dlog.h>
-#include <livebox-errno.h>
+#include <dynamicbox_errno.h>
#include "conf.h"
#include "debug.h"
struct client_node *client;
if (!USE_XMONITOR || target_pid < 0) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
/*!
*/
xmonitor_handle_state_changes();
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int xmonitor_pause(struct client_node *client)
DbgPrint("%d is paused\n", client_pid(client));
client_paused(client);
xmonitor_handle_state_changes();
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int xmonitor_resume(struct client_node *client)
DbgPrint("%d is resumed\n", client_pid(client));
client_resumed(client);
xmonitor_handle_state_changes();
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int xmonitor_init(void)
{
if (USE_XMONITOR) {
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
s_info.paused = client_is_all_paused() || setting_is_lcd_off();
remove_paused_file();
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI void xmonitor_fini(void)
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;
default:
ErrPrint("Invalid event type\n");
DbgFree(item);
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
HAPI int xmonitor_del_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data)
if (item->cb == cb && item->user_data == user_data) {
s_info.pause_list = eina_list_remove(s_info.pause_list, item);
DbgFree(item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
if (item->cb == cb && item->user_data == user_data) {
s_info.resume_list = eina_list_remove(s_info.resume_list, item);
DbgFree(item);
- return LB_STATUS_SUCCESS;
+ return DBOX_STATUS_ERROR_NONE;
}
}
break;
default:
ErrPrint("Invalid event type\n");
- return LB_STATUS_ERROR_INVALID;
+ return DBOX_STATUS_ERROR_INVALID_PARAMETER;
}
- return LB_STATUS_ERROR_NOT_EXIST;
+ return DBOX_STATUS_ERROR_NOT_EXIST;
}
HAPI int xmonitor_is_paused(void)
ecore
glib-2.0
gio-2.0
- livebox-service
+ dynamicbox_service
xdamage
xfixes
x11
struct node;
-#define NODE_READ 0x01
-#define NODE_WRITE 0x02
-#define NODE_EXEC 0x04
+#define NODE_READ 0x01
+#define NODE_WRITE 0x02
+#define NODE_EXEC 0x04
extern struct node *node_find(const struct node *node, const char *path);
-extern struct node *node_create(struct node *parent, const char *name, enum node_type type);
+extern struct node *node_create(struct node *parent, const char *name, enum node_type type, int mode);
extern void *node_destroy(struct node *node);
extern struct node * const node_next_sibling(const struct node *node);
#include <termios.h>
#include <sys/shm.h>
#include <sys/ipc.h>
+#include <ctype.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xdamage.h>
#include <com-core_packet.h>
#include <com-core.h>
-#include <livebox-service.h>
+#include <dynamicbox_service.h>
#include <Ecore.h>
#include "node.h"
#define PROMPT "liveinfo "
+#define PROVIDER_FOLDER "provider"
+#define PACKAGE_FOLDER "package"
struct package {
- int primary;
- char *pkgid;
-
- int pid;
- char *slavename;
- char *abi;
- int refcnt;
- int fault_count;
- int inst_count;
+ int primary;
+ char *pkgid;
+
+ int pid;
+ char *slavename;
+ char *abi;
+ int refcnt;
+ int fault_count;
+ int inst_count;
};
struct instance {
- char *id;
- char *cluster;
- char *category;
- double period;
- char *state;
- int width;
- int height;
+ char *id;
+ char *buf_id;
+ char *cluster;
+ char *category;
+ double period;
+ char *state;
+ int width;
+ int height;
};
struct slave {
- int pid;
- char *pkgname;
- char *abi;
- int secured;
- int refcnt;
- int fault_count;
- char *state;
- int loaded_inst;
- int loaded_pkg;
- double ttl;
+ int pid;
+ char *pkgname;
+ char *abi;
+ int secured;
+ int refcnt;
+ int fault_count;
+ char *state;
+ int loaded_inst;
+ int loaded_pkg;
+ double ttl;
};
enum command {
- NOP,
- PKG_LIST,
- INST_LIST,
- SLAVE_LIST,
- INST_CTRL,
- SLAVE_CTRL,
- MASTER_CTRL,
+ NOP,
+ PKG_LIST,
+ INST_LIST,
+ SLAVE_LIST,
+ INST_CTRL,
+ SLAVE_CTRL,
+ MASTER_CTRL,
};
static struct info {
- int fifo_handle;
- int fd;
- Ecore_Fd_Handler *fd_handler;
- Ecore_Fd_Handler *in_handler;
+ int fifo_handle;
+ int fd;
+ Ecore_Fd_Handler *fd_handler;
+ Ecore_Fd_Handler *in_handler;
- struct node *rootdir;
- struct node *curdir;
- struct node *targetdir;
+ struct node *rootdir;
+ struct node *curdir;
+ struct node *targetdir;
- enum command cmd;
+ enum command cmd;
- int input_fd;
- int verbose;
+ int input_fd;
+ int verbose;
- int age;
+ int age;
- char *history[1024];
- int history_top;
- int history_idx;
+ char *history[1024];
+ int history_top;
+ int history_idx;
- struct node *quick_search_node;
- int quick_idx;
+ struct node *quick_search_node;
+ int quick_idx;
+
+ int dump;
} s_info = {
- .fifo_handle = -EINVAL,
- .fd = -EINVAL,
- .fd_handler = NULL,
- .in_handler = NULL,
- .rootdir = NULL,
- .curdir = NULL,
- .targetdir = NULL,
- .cmd = NOP,
- .input_fd = STDIN_FILENO,
- .verbose = 0,
- .age = 0,
- .history = { 0, },
- .history_top = 0,
- .history_idx = 0,
- .quick_search_node = NULL,
- .quick_idx = 0,
+ .fifo_handle = -EINVAL,
+ .fd = -EINVAL,
+ .fd_handler = NULL,
+ .in_handler = NULL,
+ .rootdir = NULL,
+ .curdir = NULL,
+ .targetdir = NULL,
+ .cmd = NOP,
+ .input_fd = STDIN_FILENO,
+ .verbose = 0,
+ .age = 0,
+ .history = { 0, },
+ .history_top = 0,
+ .history_idx = 0,
+ .quick_search_node = NULL,
+ .quick_idx = 0,
+ .dump = 0,
};
char *optarg;
static Eina_Bool process_line_cb(void *data)
{
- input_cb(NULL, NULL);
- return ECORE_CALLBACK_CANCEL;
+ input_cb(NULL, NULL);
+ return ECORE_CALLBACK_CANCEL;
}
-static void prompt(const char *cmdline)
+static inline void prompt(const char *cmdline)
{
- char *path;
+ char *path;
- if (s_info.input_fd != STDIN_FILENO) {
- /* To prevent recursive call, add function to the main loop (idler) */
- ecore_idler_add(process_line_cb, NULL);
- return;
- }
+ if (s_info.input_fd != STDIN_FILENO) {
+ /* To prevent recursive call, add function to the main loop (idler) */
+ ecore_idler_add(process_line_cb, NULL);
+ return;
+ }
- path = node_to_abspath(s_info.curdir);
- printf(PROMPT"%s # %s", path, cmdline ? cmdline : "");
- free(path);
+ path = node_to_abspath(s_info.curdir);
+ printf(PROMPT"%s # %s", path, cmdline ? cmdline : "");
+ free(path);
}
static void provider_del_cb(struct node *node)
{
- struct slave *info;
+ struct slave *info;
- info = node_data(node);
- if (!info) {
- return;
- }
+ info = node_data(node);
+ if (!info) {
+ return;
+ }
- free(info->pkgname);
- free(info->abi);
- free(info->state);
- free(info);
+ free(info->pkgname);
+ free(info->abi);
+ free(info->state);
+ free(info);
}
static void package_del_cb(struct node *node)
{
- struct package *info;
+ struct package *info;
- info = node_data(node);
- if (!info) {
- return;
- }
+ info = node_data(node);
+ if (!info) {
+ return;
+ }
- free(info->pkgid);
- free(info->slavename);
- free(info->abi);
- free(info);
+ free(info->pkgid);
+ free(info->slavename);
+ free(info->abi);
+ free(info);
}
static void inst_del_cb(struct node *node)
{
- struct instance *info;
-
- info = node_data(node);
- if (!info) {
- return;
- }
+ struct instance *info;
- free(info->id);
- free(info->cluster);
- free(info->category);
- free(info->state);
- free(info);
+ info = node_data(node);
+ if (!info) {
+ return;
+ }
+
+ free(info->id);
+ free(info->buf_id);
+ free(info->cluster);
+ free(info->category);
+ free(info->state);
+ free(info);
}
static void ls(void)
{
- struct node *node;
- int cnt = 0;
- int is_package;
- int is_provider;
- int is_instance;
- struct node *next_node;
-
- if (!(node_mode(s_info.targetdir) & NODE_READ)) {
- printf("Access denied\n");
- return;
- }
-
- is_package = node_name(s_info.targetdir) && !strcmp(node_name(s_info.targetdir), "package");
- is_provider = !is_package && node_name(s_info.targetdir) && !strcmp(node_name(s_info.targetdir), "provider");
- is_instance = !is_package && !is_provider && node_parent(s_info.targetdir) && node_name(node_parent(s_info.targetdir)) && !strcmp(node_name(node_parent(s_info.targetdir)), "package");
-
- node = node_child(s_info.targetdir);
- while (node) {
- if (is_package) {
- struct package *info;
-
- next_node = node_next_sibling(node);
- if (node_age(node) != s_info.age) {
- node_delete(node, package_del_cb);
- node = next_node;
- continue;
- }
-
- info = node_data(node);
- printf(" %3d %20s %5s ", info->inst_count, info->slavename ? info->slavename : "(none)", info->abi ? info->abi : "?");
- } else if (is_provider) {
- struct slave *info;
-
- next_node = node_next_sibling(node);
- if (node_age(node) != s_info.age) {
- node_delete(node, provider_del_cb);
- node = next_node;
- continue;
- }
-
- info = node_data(node);
- printf("%6d %3d %5s %5.2f ", info->pid, info->loaded_inst, info->abi ? info->abi : "?", info->ttl);
- } else if (is_instance) {
- struct instance *info;
- struct stat stat;
- char buf[4096];
-
- next_node = node_next_sibling(node);
-
- if (node_age(node) != s_info.age) {
- node_delete(node, inst_del_cb);
- node = next_node;
- continue;
- }
-
- info = node_data(node);
-
- printf(" %5.2f %6s %10s %10s %4dx%-4d ", info->period, info->state, info->cluster, info->category, info->width, info->height);
- snprintf(buf, sizeof(buf), "/opt/usr/share/live_magazine/reader/%s", node_name(node));
- if (lstat(buf, &stat) < 0) {
- printf("%3d ERR ", errno);
- } else {
- printf("%2.2lf KB ", (double)stat.st_size / 1024.0f);
- }
- }
-
- if (node_type(node) == NODE_DIR) {
- printf("%s/", node_name(node));
- } else if (node_type(node) == NODE_FILE) {
- printf("%s", node_name(node));
- }
-
- printf("\n");
- node = node_next_sibling(node);
- cnt++;
- }
-
- printf("Total: %d\n", cnt);
+ struct node *node;
+ int cnt = 0;
+ int is_package;
+ int is_provider;
+ int is_instance;
+ struct node *next_node;
+
+ if (!(node_mode(s_info.targetdir) & NODE_READ)) {
+ printf("Access denied\n");
+ return;
+ }
+
+ is_package = node_name(s_info.targetdir) && !strcmp(node_name(s_info.targetdir), PACKAGE_FOLDER);
+ is_provider = !is_package && node_name(s_info.targetdir) && !strcmp(node_name(s_info.targetdir), PROVIDER_FOLDER);
+ is_instance = !is_package && !is_provider && node_parent(s_info.targetdir) && node_name(node_parent(s_info.targetdir)) && !strcmp(node_name(node_parent(s_info.targetdir)), PACKAGE_FOLDER);
+
+ node = node_child(s_info.targetdir);
+ while (node) {
+ if (is_package) {
+ struct package *info;
+
+ next_node = node_next_sibling(node);
+ if (node_age(node) != s_info.age) {
+ node_delete(node, package_del_cb);
+ node = next_node;
+ continue;
+ }
+
+ info = node_data(node);
+ printf(" %3d %20s %5s ", info->inst_count, info->slavename ? info->slavename : "(none)", info->abi ? info->abi : "?");
+ } else if (is_provider) {
+ struct slave *info;
+
+ next_node = node_next_sibling(node);
+ if (node_age(node) != s_info.age) {
+ node_delete(node, provider_del_cb);
+ node = next_node;
+ continue;
+ }
+
+ info = node_data(node);
+ printf("%6d %3d %5s %5.2f ", info->pid, info->loaded_inst, info->abi ? info->abi : "?", info->ttl);
+ } else if (is_instance) {
+ struct instance *info;
+ struct stat stat;
+ char buf[4096];
+
+ next_node = node_next_sibling(node);
+
+ if (node_age(node) != s_info.age) {
+ node_delete(node, inst_del_cb);
+ node = next_node;
+ continue;
+ }
+
+ info = node_data(node);
+
+ printf(" %5.2f %s %6s %10s %10s %4dx%-4d ", info->period, info->buf_id, info->state, info->cluster, info->category, info->width, info->height);
+ snprintf(buf, sizeof(buf), "/opt/usr/share/live_magazine/reader/%s", node_name(node));
+ if (lstat(buf, &stat) < 0) {
+ printf("%3d ERR ", errno);
+ } else {
+ printf("%2.2lf KB ", (double)stat.st_size / 1024.0f);
+ }
+ }
+
+ if (node_type(node) == NODE_DIR) {
+ printf("%s/", node_name(node));
+ } else if (node_type(node) == NODE_FILE) {
+ printf("%s", node_name(node));
+ }
+
+ printf("\n");
+ node = node_next_sibling(node);
+ cnt++;
+ }
+
+ printf("Total: %d\n", cnt);
}
static void send_slave_list(void)
{
- struct packet *packet;
- int ret;
+ struct packet *packet;
+ int ret;
- if (s_info.cmd != NOP) {
- printf("Previous command is not finished\n");
- return;
- }
+ if (s_info.cmd != NOP) {
+ printf("Previous command is not finished\n");
+ return;
+ }
- packet = packet_create_noack("slave_list", "d", 0.0f);
- if (!packet) {
- printf("Failed to create a packet\n");
- return;
- }
+ packet = packet_create_noack("slave_list", "d", 0.0f);
+ if (!packet) {
+ printf("Failed to create a packet\n");
+ return;
+ }
- ret = com_core_packet_send_only(s_info.fd, packet);
- packet_destroy(packet);
- if (ret < 0) {
- printf("Failed to send a packet: %d\n", ret);
- return;
- }
+ ret = com_core_packet_send_only(s_info.fd, packet);
+ packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to send a packet: %d\n", ret);
+ return;
+ }
- s_info.cmd = SLAVE_LIST;
- s_info.age++;
+ s_info.cmd = SLAVE_LIST;
+ s_info.age++;
}
/*!
*/
static void send_command(const char *cmd, const char *var, const char *val)
{
- struct packet *packet;
- int ret;
+ struct packet *packet;
+ int ret;
- if (s_info.cmd != NOP) {
- printf("Previous command is not finished\n");
- return;
- }
+ if (s_info.cmd != NOP) {
+ printf("Previous command is not finished\n");
+ return;
+ }
- packet = packet_create_noack("master_ctrl", "sss", cmd, var, val);
- if (!packet) {
- printf("Failed to create a ctrl packet\n");
- return;
- }
+ packet = packet_create_noack("master_ctrl", "sss", cmd, var, val);
+ if (!packet) {
+ printf("Failed to create a ctrl packet\n");
+ return;
+ }
- ret = com_core_packet_send_only(s_info.fd, packet);
- packet_destroy(packet);
- if (ret < 0) {
- printf("Failed to send packet ctrl\n");
- return;
- }
+ ret = com_core_packet_send_only(s_info.fd, packet);
+ packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to send packet ctrl\n");
+ return;
+ }
- s_info.cmd = MASTER_CTRL;
- s_info.age++;
+ s_info.cmd = MASTER_CTRL;
+ s_info.age++;
}
static int pkglist_cb(const char *appid, const char *lbid, int is_prime, void *data)
{
- struct node *parent = data;
- struct node *node;
- struct package *info;
-
- node = node_find(parent, lbid);
- if (node) {
- info = node_data(node);
- if (!info) {
- printf("Invalid node\n");
- return -EINVAL;
- }
-
- free(info->pkgid);
- info->pkgid = strdup(appid);
- if (!info->pkgid) {
- printf("Error: %s\n", strerror(errno));
- return -ENOMEM;
- }
+ struct node *parent = data;
+ struct node *node;
+ struct package *info;
- node_set_age(node, s_info.age);
- return 0;
- }
-
- info = calloc(1, sizeof(*info));
+ node = node_find(parent, lbid);
+ if (node) {
+ info = node_data(node);
if (!info) {
- printf("Error: %s\n", strerror(errno));
- return -ENOMEM;
+ printf("Invalid node\n");
+ return -EINVAL;
}
+ free(info->pkgid);
info->pkgid = strdup(appid);
if (!info->pkgid) {
- printf("Error: %s\n", strerror(errno));
- free(info);
- return -ENOMEM;
- }
-
- info->primary = is_prime;
-
- node = node_create(parent, lbid, NODE_DIR);
- if (!node) {
- free(info->pkgid);
- free(info);
- return -ENOMEM;
+ printf("Error: %s\n", strerror(errno));
+ return -ENOMEM;
}
- node_set_mode(node, NODE_READ | NODE_EXEC);
- node_set_data(node, info);
node_set_age(node, s_info.age);
return 0;
+ }
+
+ info = calloc(1, sizeof(*info));
+ if (!info) {
+ printf("Error: %s\n", strerror(errno));
+ return -ENOMEM;
+ }
+
+ info->pkgid = strdup(appid);
+ if (!info->pkgid) {
+ printf("Error: %s\n", strerror(errno));
+ free(info);
+ return -ENOMEM;
+ }
+
+ info->primary = is_prime;
+
+ node = node_create(parent, lbid, NODE_DIR, NODE_READ | NODE_EXEC);
+ if (!node) {
+ free(info->pkgid);
+ free(info);
+ return -ENOMEM;
+ }
+
+ node_set_data(node, info);
+ node_set_age(node, s_info.age);
+ return 0;
}
static void send_pkg_list(void)
{
- struct packet *packet;
- int ret;
+ struct packet *packet;
+ int ret;
- if (s_info.cmd != NOP) {
- printf("Previous command is not finished\n");
- return;
- }
+ if (s_info.cmd != NOP) {
+ printf("Previous command is not finished\n");
+ return;
+ }
- packet = packet_create_noack("pkg_list", "d", 0.0f);
- if (!packet) {
- printf("Failed to create a packet\n");
- return;
- }
+ packet = packet_create_noack("pkg_list", "d", 0.0f);
+ if (!packet) {
+ printf("Failed to create a packet\n");
+ return;
+ }
- ret = com_core_packet_send_only(s_info.fd, packet);
- packet_destroy(packet);
- if (ret < 0) {
- printf("Failed to create a packet\n");
- return;
- }
+ ret = com_core_packet_send_only(s_info.fd, packet);
+ packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to create a packet\n");
+ return;
+ }
- s_info.cmd = PKG_LIST;
- s_info.age++;
+ s_info.cmd = PKG_LIST;
+ s_info.age++;
- livebox_service_get_pkglist(pkglist_cb, s_info.targetdir);
+ dynamicbox_service_get_pkglist(pkglist_cb, s_info.targetdir);
}
static void send_inst_delete(void)
{
- struct packet *packet;
- struct node *parent;
- const char *name;
- struct instance *inst;
- int ret;
-
- if (s_info.cmd != NOP) {
- printf("Previous command is not finished\n");
- return;
- }
+ struct packet *packet;
+ struct node *parent;
+ const char *name;
+ struct instance *inst;
+ int ret;
+
+ if (s_info.cmd != NOP) {
+ printf("Previous command is not finished\n");
+ return;
+ }
- parent = node_parent(s_info.targetdir);
- if (!parent) {
- printf("Invalid argument\n");
- return;
- }
+ parent = node_parent(s_info.targetdir);
+ if (!parent) {
+ printf("Invalid argument\n");
+ return;
+ }
- if (!node_parent(parent)) {
- printf("Invalid argument\n");
- return;
- }
+ if (!node_parent(parent)) {
+ printf("Invalid argument\n");
+ return;
+ }
- name = node_name(node_parent(parent));
- if (!name || strcmp(name, "package")) {
- printf("Invalid argument\n");
- return;
- }
+ name = node_name(node_parent(parent));
+ if (!name || strcmp(name, PACKAGE_FOLDER)) {
+ printf("Invalid argument\n");
+ return;
+ }
- inst = node_data(s_info.targetdir);
- name = node_name(parent);
+ inst = node_data(s_info.targetdir);
+ name = node_name(parent);
- packet = packet_create_noack("pkg_ctrl", "sss", "rminst", name, inst->id);
- if (!packet) {
- printf("Failed to create a packet\n");
- return;
- }
+ packet = packet_create_noack("pkg_ctrl", "sss", "rminst", name, inst->id);
+ if (!packet) {
+ printf("Failed to create a packet\n");
+ return;
+ }
- ret = com_core_packet_send_only(s_info.fd, packet);
- packet_destroy(packet);
- if (ret < 0) {
- printf("Failed to send a packet: %d\n", ret);
- return;
- }
+ ret = com_core_packet_send_only(s_info.fd, packet);
+ packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to send a packet: %d\n", ret);
+ return;
+ }
- s_info.cmd = INST_CTRL;
- s_info.age++;
+ s_info.cmd = INST_CTRL;
+ s_info.age++;
}
static void send_inst_fault(void)
{
- struct packet *packet;
- struct node *parent;
- const char *name;
- struct instance *inst;
- int ret;
-
- if (s_info.cmd != NOP) {
- printf("Previous command is not finished\n");
- return;
- }
+ struct packet *packet;
+ struct node *parent;
+ const char *name;
+ struct instance *inst;
+ int ret;
+
+ if (s_info.cmd != NOP) {
+ printf("Previous command is not finished\n");
+ return;
+ }
- parent = node_parent(s_info.targetdir);
- if (!parent) {
- printf("Invalid argument\n");
- return;
- }
+ parent = node_parent(s_info.targetdir);
+ if (!parent) {
+ printf("Invalid argument\n");
+ return;
+ }
- if (!node_parent(parent)) {
- printf("Invalid argument\n");
- return;
- }
+ if (!node_parent(parent)) {
+ printf("Invalid argument\n");
+ return;
+ }
- name = node_name(node_parent(parent));
- if (!name || strcmp(name, "package")) {
- printf("Invalid argument\n");
- return;
- }
+ name = node_name(node_parent(parent));
+ if (!name || strcmp(name, PACKAGE_FOLDER)) {
+ printf("Invalid argument\n");
+ return;
+ }
- inst = node_data(s_info.targetdir);
- name = node_name(parent);
+ inst = node_data(s_info.targetdir);
+ name = node_name(parent);
- packet = packet_create_noack("pkg_ctrl", "sss", "faultinst", name, inst->id);
- if (!packet) {
- printf("Failed to create a packet\n");
- return;
- }
+ packet = packet_create_noack("pkg_ctrl", "sss", "faultinst", name, inst->id);
+ if (!packet) {
+ printf("Failed to create a packet\n");
+ return;
+ }
- ret = com_core_packet_send_only(s_info.fd, packet);
- packet_destroy(packet);
- if (ret < 0) {
- printf("Failed to send a packet: %d\n", ret);
- return;
- }
+ ret = com_core_packet_send_only(s_info.fd, packet);
+ packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to send a packet: %d\n", ret);
+ return;
+ }
- s_info.cmd = INST_CTRL;
- s_info.age++;
+ s_info.cmd = INST_CTRL;
+ s_info.age++;
}
static void send_inst_list(const char *pkgname)
{
- struct packet *packet;
- int ret;
+ struct packet *packet;
+ int ret;
- if (s_info.cmd != NOP) {
- printf("Previous command is not finished\n");
- return;
- }
+ if (s_info.cmd != NOP) {
+ printf("Previous command is not finished\n");
+ return;
+ }
- packet = packet_create_noack("inst_list", "s", pkgname);
- if (!packet) {
- printf("Failed to create a packet\n");
- return;
- }
+ packet = packet_create_noack("inst_list", "s", pkgname);
+ if (!packet) {
+ printf("Failed to create a packet\n");
+ return;
+ }
- ret = com_core_packet_send_only(s_info.fd, packet);
- packet_destroy(packet);
- if (ret < 0) {
- printf("Failed to send a packet: %d\n", ret);
- return;
- }
+ ret = com_core_packet_send_only(s_info.fd, packet);
+ packet_destroy(packet);
+ if (ret < 0) {
+ printf("Failed to send a packet: %d\n", ret);
+ return;
+ }
- s_info.cmd = INST_LIST;
- s_info.age++;
+ s_info.cmd = INST_LIST;
+ s_info.age++;
}
static void help(void)
{
- printf("liveinfo - Livebox utility\n");
- printf("------------------------------ [Option] ------------------------------\n");
- printf("-b Batch mode\n");
- printf("-x execute command\n");
- printf("------------------------------ [Command list] ------------------------------\n");
- printf("\e[32mcd [PATH] - Change directory\e[0m\n");
- printf("\e[32mls [ | PATH] - List up content as a file\e[0m\n");
- printf("\e[32mrm [PKG_ID|INST_ID] - Delete package or instance\e[0m\n");
- printf("\e[32mstat [path] - Display the information of given path\e[0m\n");
- printf("\e[32mset [debug] [on|off] Set the control variable of master provider\e[0m\n");
- printf("\e[32mx damage Pix x y w h - Create damage event for given pixmap\e[0m\n");
- printf("\e[32mx move Pix x y - Move the window\e[0m\n");
- printf("\e[32mx resize Pix w h - Resize the window\e[0m\n");
- printf("\e[32mx map Pix - Show the window\e[0m\n");
- printf("\e[32mx unmap Pix - Hide the window\e[0m\n");
- printf("\e[32mx capture Pix outfile - Capture pixmap and save it to outfile\e[0m\n");
- printf("\e[32msh [command] Execute shell command, [command] should be abspath\e[0m\n");
- printf("\e[32mexit - \e[0m\n");
- printf("\e[32mquit - \e[0m\n");
- printf("----------------------------------------------------------------------------\n");
+ printf("liveinfo - DynamicBox utility\n");
+ printf("------------------------------ [Option] ------------------------------\n");
+ printf("-b Batch mode\n");
+ printf("-x execute command\n");
+ printf("------------------------------ [Command list] ------------------------------\n");
+ printf("\e[32mcd [PATH] - Change directory\e[0m\n");
+ printf("\e[32mls [ | PATH] - List up content as a file\e[0m\n");
+ printf("\e[32mrm [PKG_ID|INST_ID] - Delete package or instance\e[0m\n");
+ printf("\e[32mstat [path] - Display the information of given path\e[0m\n");
+ printf("\e[32mset [debug] [on|off] Set the control variable of master provider\e[0m\n");
+ printf("\e[32mx damage Pix x y w h - Create damage event for given pixmap\e[0m\n");
+ printf("\e[32mx move Pix x y - Move the window\e[0m\n");
+ printf("\e[32mx resize Pix w h - Resize the window\e[0m\n");
+ printf("\e[32mx map Pix - Show the window\e[0m\n");
+ printf("\e[32mx unmap Pix - Hide the window\e[0m\n");
+ printf("\e[32mx capture Pix outfile - Capture pixmap and save it to outfile\e[0m\n");
+ printf("\e[32msh [command] Execute shell command, [command] should be abspath\e[0m\n");
+ printf("\e[32mexit - \e[0m\n");
+ printf("\e[32mquit - \e[0m\n");
+ printf("----------------------------------------------------------------------------\n");
}
static inline void init_directory(void)
{
- struct node *node;
- s_info.rootdir = node_create(NULL, NULL, NODE_DIR);
- if (!s_info.rootdir) {
- return;
- }
- node_set_mode(s_info.rootdir, NODE_READ | NODE_EXEC);
-
- node = node_create(s_info.rootdir, "provider", NODE_DIR);
- if (!node) {
- node_destroy(s_info.rootdir);
- s_info.rootdir = NULL;
- return;
- }
- node_set_mode(node, NODE_READ | NODE_EXEC);
+ struct node *node;
+ s_info.rootdir = node_create(NULL, NULL, NODE_DIR, NODE_READ | NODE_EXEC);
+ if (!s_info.rootdir) {
+ return;
+ }
- node = node_create(s_info.rootdir, "package", NODE_DIR);
- if (!node) {
- node_destroy(node_child(s_info.rootdir));
- node_destroy(s_info.rootdir);
- s_info.rootdir = NULL;
- return;
- }
- node_set_mode(node, NODE_READ | NODE_EXEC);
+ node = node_create(s_info.rootdir, PROVIDER_FOLDER, NODE_DIR, NODE_READ | NODE_EXEC);
+ if (!node) {
+ node_destroy(s_info.rootdir);
+ s_info.rootdir = NULL;
+ return;
+ }
- s_info.curdir = s_info.rootdir;
+ node = node_create(s_info.rootdir, PACKAGE_FOLDER, NODE_DIR, NODE_READ | NODE_EXEC);
+ if (!node) {
+ node_destroy(node_child(s_info.rootdir));
+ node_destroy(s_info.rootdir);
+ s_info.rootdir = NULL;
return;
+ }
+
+ s_info.curdir = s_info.rootdir;
+ return;
}
static inline void fini_directory(void)
static struct node *update_target_dir(const char *cmd)
{
- struct node *node;
+ struct node *node;
- node = (*cmd == '/') ? s_info.rootdir : s_info.curdir;
- node = node_find(node, cmd);
+ node = (*cmd == '/') ? s_info.rootdir : s_info.curdir;
+ node = node_find(node, cmd);
- return node;
+ return node;
}
static int get_token(const char *src, char *out)
{
- int len = 0;
- while (*src && *src == ' ') src++;
+ int len = 0;
+ while (*src && *src == ' ') src++;
- if (!*src) {
- return 0;
- }
+ if (!*src) {
+ return 0;
+ }
- while (*src && *src != ' ') {
- *out++ = *src++;
- len++;
- }
+ while (*src && *src != ' ') {
+ *out++ = *src++;
+ len++;
+ }
- *out = '\0';
- return len;
+ *out = '\0';
+ return len;
}
static inline int do_stat(const char *cmd)
{
- int i;
- struct node *node;
- struct node *parent;
- char *tmp;
- enum stat_type {
- PKG_INSTANCE = 0x01,
- PKG,
- PROVIDER_INSTANCE,
- PROVIDER,
- ROOT,
- } type;
+ int i;
+ struct node *node;
+ struct node *parent;
+ char *tmp;
+ enum stat_type {
+ PKG_INSTANCE = 0x01,
+ PKG,
+ PROVIDER_INSTANCE,
+ PROVIDER,
+ ROOT,
+ } type;
+
+ cmd += 5;
+ while (*cmd && *cmd == ' ') cmd++;
+
+ if (!*cmd){
+ printf("Invalid argument\n");
+ return -EINVAL;
+ }
+
+ node = node_find(*cmd == '/' ? s_info.rootdir : s_info.curdir, cmd);
+ if (!node) {
+ printf("Invalid path\n");
+ return -EINVAL;
+ }
+
+ i = 0;
+ type = ROOT;
+ parent = node_parent(node);
+ while (parent) {
+ if (!node_name(parent)) {
+ printf("%s has no info\n", node_name(node));
+ return -EINVAL;
+ } else if (!strcmp(node_name(parent), PACKAGE_FOLDER)) {
+ type = (i == 0) ? PKG : PKG_INSTANCE;
+ break;
+ } else if (!strcmp(node_name(parent), PROVIDER_FOLDER)){
+ type = (i == 0) ? PROVIDER : PROVIDER_INSTANCE;
+ break;
+ }
+
+ parent = node_parent(parent);
+ i++;
+ if (i > 1) {
+ printf("%s is invalid path\n", node_name(node));
+ return -EINVAL;
+ }
+ }
+
+ switch (type){
+ case PKG:
+ tmp = dynamicbox_service_i18n_name(node_name(node), NULL);
+ printf("Name: %s (", tmp);
+ free(tmp);
- cmd += 5;
- while (*cmd && *cmd == ' ') cmd++;
+ i = dynamicbox_service_is_enabled(node_name(node));
+ printf("%s)\n", i ? "enabled" : "disabled");
- if (!*cmd){
- printf("Invalid argument\n");
- return -EINVAL;
- }
+ tmp = dynamicbox_service_i18n_icon(node_name(node), NULL);
+ printf("Icon: %s\n", tmp);
+ free(tmp);
- node = node_find(*cmd == '/' ? s_info.rootdir : s_info.curdir, cmd);
- if (!node) {
- printf("Invalid path\n");
- return -EINVAL;
- }
+ tmp = dynamicbox_service_provider_name(node_name(node));
+ printf("Provider: %s (content:", tmp);
+ free(tmp);
- i = 0;
- type = ROOT;
- parent = node_parent(node);
- while (parent) {
- if (!node_name(parent)) {
- printf("%s has no info\n", node_name(node));
- return -EINVAL;
- } else if (!strcmp(node_name(parent), "package")) {
- type = (i == 0) ? PKG : PKG_INSTANCE;
- break;
- } else if (!strcmp(node_name(parent), "provider")){
- type = (i == 0) ? PROVIDER : PROVIDER_INSTANCE;
- break;
- }
+ tmp = dynamicbox_service_content(node_name(node));
+ printf("%s)\n", tmp);
+ free(tmp);
- parent = node_parent(parent);
- i++;
- if (i > 1) {
- printf("%s is invalid path\n", node_name(node));
- return -EINVAL;
- }
- }
+ tmp = dynamicbox_service_dbox_script_path(node_name(node));
+ printf("LB Script: %s (", tmp);
+ free(tmp);
- switch (type){
- case PKG:
- tmp = livebox_service_i18n_name(node_name(node), NULL);
- printf("Name: %s (", tmp);
- free(tmp);
-
- i = livebox_service_is_enabled(node_name(node));
- printf("%s)\n", i ? "enabled" : "disabled");
-
- tmp = livebox_service_i18n_icon(node_name(node), NULL);
- printf("Icon: %s\n", tmp);
- free(tmp);
-
- tmp = livebox_service_provider_name(node_name(node));
- printf("Provider: %s (content:", tmp);
- free(tmp);
-
- tmp = livebox_service_content(node_name(node));
- printf("%s)\n", tmp);
- free(tmp);
-
- tmp = livebox_service_lb_script_path(node_name(node));
- printf("LB Script: %s (", tmp);
- free(tmp);
-
- tmp = livebox_service_lb_script_group(node_name(node));
- printf("%s)\n", tmp);
- free(tmp);
-
- tmp = livebox_service_pd_script_path(node_name(node));
- printf("PD Script: %s (", tmp);
- free(tmp);
-
- tmp = livebox_service_pd_script_group(node_name(node));
- printf("%s)\n", tmp);
- free(tmp);
-
- i = livebox_service_mouse_event(node_name(node), LB_SIZE_TYPE_1x1);
- printf("[1x1] Mouse event: %s\n", i ? "enabled" : "disabled");
- i = livebox_service_mouse_event(node_name(node), LB_SIZE_TYPE_2x1);
- printf("[2x1] Mouse event: %s\n", i ? "enabled" : "disabled");
- i = livebox_service_mouse_event(node_name(node), LB_SIZE_TYPE_2x2);
- printf("[2x2] Mouse event: %s\n", i ? "enabled" : "disabled");
- i = livebox_service_mouse_event(node_name(node), LB_SIZE_TYPE_4x1);
- printf("[4x1] Mouse event: %s\n", i ? "enabled" : "disabled");
- i = livebox_service_mouse_event(node_name(node), LB_SIZE_TYPE_4x2);
- printf("[4x2] Mouse event: %s\n", i ? "enabled" : "disabled");
- i = livebox_service_mouse_event(node_name(node), LB_SIZE_TYPE_4x3);
- printf("[4x3] Mouse event: %s\n", i ? "enabled" : "disabled");
- i = livebox_service_mouse_event(node_name(node), LB_SIZE_TYPE_4x4);
- printf("[4x4] Mouse event: %s\n", i ? "enabled" : "disabled");
- i = livebox_service_mouse_event(node_name(node), LB_SIZE_TYPE_4x5);
- printf("[4x5] Mouse event: %s\n", i ? "enabled" : "disabled");
- i = livebox_service_mouse_event(node_name(node), LB_SIZE_TYPE_4x6);
- printf("[4x6] Mouse event: %s\n", i ? "enabled" : "disabled");
+ tmp = dynamicbox_service_dbox_script_group(node_name(node));
+ printf("%s)\n", tmp);
+ free(tmp);
- break;
+ tmp = dynamicbox_service_gbar_script_path(node_name(node));
+ printf("PD Script: %s (", tmp);
+ free(tmp);
+
+ tmp = dynamicbox_service_gbar_script_group(node_name(node));
+ printf("%s)\n", tmp);
+ free(tmp);
+
+ break;
case PROVIDER:
- printf("Not supported yet\n");
- break;
+ printf("Not supported yet\n");
+ break;
case PKG_INSTANCE:
- printf("Not supported yet\n");
- break;
+ printf("Not supported yet\n");
+ break;
case PROVIDER_INSTANCE:
- printf("Not supported yet\n");
- break;
+ printf("Not supported yet\n");
+ break;
case ROOT:
- printf("Not supported yet\n");
- break;
- }
+ printf("Not supported yet\n");
+ break;
+ }
- return 0;
+ return 0;
}
static int do_set(const char *cmd)
{
- int i;
- char variable[4096] = { '0', };
+ int i;
+ char variable[4096] = { '0', };
- cmd += 4;
- i = get_token(cmd, variable);
+ cmd += 4;
+ i = get_token(cmd, variable);
- cmd += i;
- while (*cmd && *cmd == ' ') {
- cmd++;
- }
+ cmd += i;
+ while (*cmd && *cmd == ' ') {
+ cmd++;
+ }
- if (!i || !*cmd) {
- printf("Invalid argument(%s): set [VAR] [VAL]\n", cmd);
- return -EINVAL;
- }
+ if (!i || !*cmd) {
+ printf("Invalid argument(%s): set [VAR] [VAL]\n", cmd);
+ return -EINVAL;
+ }
- send_command("set", variable, cmd);
- return 0;
+ send_command("set", variable, cmd);
+ return 0;
}
static inline int do_get(const char *cmd)
{
- cmd += 4;
+ cmd += 4;
- while (*cmd && *cmd == ' ') cmd++;
- if (!*cmd) {
- printf("Invalid argument(%s): get [VAR]\n", cmd);
- return -EINVAL;
- }
+ while (*cmd && *cmd == ' ') cmd++;
+ if (!*cmd) {
+ printf("Invalid argument(%s): get [VAR]\n", cmd);
+ return -EINVAL;
+ }
- send_command("get", cmd, "");
- return 0;
+ send_command("get", cmd, "");
+ return 0;
}
static inline int do_ls(const char *cmd)
{
- const char *name;
- struct node *parent;
+ const char *name;
+ struct node *parent;
+
+ cmd += 2;
+
+ while (*cmd && *cmd == ' ') {
+ cmd++;
+ }
+
+ s_info.targetdir = *cmd ? update_target_dir(cmd) : s_info.curdir;
+ if (!s_info.targetdir) {
+ printf("%s is not exists\n", cmd);
+ return -ENOENT;
+ }
+
+ name = node_name(s_info.targetdir);
+ if (name) {
+ if (!strcmp(name, PACKAGE_FOLDER)) {
+ if (s_info.cmd == NOP) {
+ send_pkg_list();
+ return 0;
+ }
- cmd += 2;
+ printf("Waiting the server response\n");
+ return -EBUSY;
+ } else if (!strcmp(name, PROVIDER_FOLDER)) {
+ if (s_info.cmd == NOP) {
+ send_slave_list();
+ return 0;
+ }
- while (*cmd && *cmd == ' ') {
- cmd++;
+ printf("Waiting the server response\n");
+ return -EBUSY;
}
+ }
- s_info.targetdir = *cmd ? update_target_dir(cmd) : s_info.curdir;
- if (!s_info.targetdir) {
- printf("%s is not exists\n", cmd);
- return -ENOENT;
- }
+ parent = node_parent(s_info.targetdir);
+ if (parent && node_name(parent)) {
+ if (!strcmp(node_name(parent), PACKAGE_FOLDER)) {
+ if (s_info.cmd != NOP) {
+ printf("Waiting the server response\n");
+ return -EBUSY;
+ }
- name = node_name(s_info.targetdir);
- if (name) {
- if (!strcmp(name, "package")) {
- if (s_info.cmd == NOP) {
- send_pkg_list();
- return 0;
- }
-
- printf("Waiting the server response\n");
- return -EBUSY;
- } else if (!strcmp(name, "provider")) {
- if (s_info.cmd == NOP) {
- send_slave_list();
- return 0;
- }
-
- printf("Waiting the server response\n");
- return -EBUSY;
- }
+ send_inst_list(name);
+ return 0;
}
+ }
- parent = node_parent(s_info.targetdir);
- if (parent && node_name(parent)) {
- if (!strcmp(node_name(parent), "package")) {
- if (s_info.cmd != NOP) {
- printf("Waiting the server response\n");
- return -EBUSY;
- }
+ ls();
+ return -1;
+}
- send_inst_list(name);
- return 0;
- }
- }
+static inline int do_cd(const char *cmd)
+{
+ cmd += 2;
+
+ while (*cmd && *cmd == ' ') {
+ cmd++;
+ }
- ls();
+ if (!*cmd) {
return -1;
+ }
+
+ if (s_info.cmd != NOP) {
+ printf("Waiting the server response\n");
+ return -EBUSY;
+ }
+
+ s_info.targetdir = update_target_dir(cmd);
+ if (!s_info.targetdir) {
+ printf("%s is not exists\n", cmd);
+ return -ENOENT;
+ }
+
+ if (node_type(s_info.targetdir) != NODE_DIR) {
+ printf("Unable change directory to %s\n", cmd);
+ return -EINVAL;
+ }
+
+ if (!(node_mode(s_info.targetdir) & NODE_EXEC)) {
+ printf("Access denied %s\n", cmd);
+ return -EACCES;
+ }
+
+ s_info.curdir = s_info.targetdir;
+ return -1;
}
-static inline int do_cd(const char *cmd)
+static inline int do_rm(const char *cmd)
{
- cmd += 2;
+ cmd += 2;
+ while (*cmd && *cmd == ' ') cmd++;
+ if (!*cmd) {
+ return -1;
+ }
+
+ if (s_info.cmd != NOP) {
+ printf("Waiting the server response\n");
+ return -EBUSY;
+ }
+
+ s_info.targetdir = update_target_dir(cmd);
+ if (!s_info.targetdir) {
+ printf("%s is not exists\n", cmd);
+ return -ENOENT;
+ }
+
+ if (!(node_mode(s_info.targetdir) & NODE_WRITE)) {
+ printf("Access denied %s\n", cmd);
+ return -EACCES;
+ }
+
+ send_inst_delete();
+ return 0;
+}
- while (*cmd && *cmd == ' ') {
- cmd++;
- }
+static inline int do_fault(const char *cmd)
+{
+ cmd += 5;
+ while (*cmd && *cmd == ' ') cmd++;
+ if (!*cmd) {
+ return -1;
+ }
+
+ if (s_info.cmd != NOP) {
+ printf("Waiting the server response\n");
+ return -EBUSY;
+ }
+
+ s_info.targetdir = update_target_dir(cmd);
+ if (!s_info.targetdir) {
+ printf("%s is not exists\n", cmd);
+ return -ENOENT;
+ }
+
+ if (!(node_mode(s_info.targetdir) & NODE_WRITE)) {
+ printf("Access denied %s\n", cmd);
+ return -EACCES;
+ }
+
+ send_inst_fault();
+ return 0;
+}
- if (!*cmd) {
- return -1;
- }
+#if !defined(WCOREDUMP)
+#define WCOREDUMP(a) 0
+#endif
- if (s_info.cmd != NOP) {
- printf("Waiting the server response\n");
- return -EBUSY;
- }
+static void do_sh(const char *cmd)
+{
+ pid_t pid;
- s_info.targetdir = update_target_dir(cmd);
- if (!s_info.targetdir) {
- printf("%s is not exists\n", cmd);
- return -ENOENT;
- }
+ cmd += 3;
+
+ while (*cmd && *cmd == ' ') {
+ cmd++;
+ }
- if (node_type(s_info.targetdir) != NODE_DIR) {
- printf("Unable change directory to %s\n", cmd);
- return -EINVAL;
+ if (!*cmd) {
+ return;
+ }
+
+ pid = fork();
+ if (pid == 0) {
+ char command[256];
+ int idx;
+ idx = 0;
+
+ while (idx < (sizeof(command) - 1) && *cmd && *cmd != ' ') {
+ command[idx++] = *cmd++;
}
+ command[idx] = '\0';
- if (!(node_mode(s_info.targetdir) & NODE_EXEC)) {
- printf("Access denied %s\n", cmd);
- return -EACCES;
+ if (execl(command, cmd, NULL) < 0) {
+ printf("Failed to execute: %s\n", strerror(errno));
}
- s_info.curdir = s_info.targetdir;
- return -1;
+ exit(0);
+ } else if (pid < 0) {
+ printf("Failed to create a new process: %s\n", strerror(errno));
+ } else {
+ int status;
+ if (waitpid(pid, &status, 0) < 0) {
+ printf("error: %s\n", strerror(errno));
+ } else {
+ if (WIFEXITED(status)) {
+ printf("Exit: %d\n", WEXITSTATUS(status));
+ } else if (WIFSIGNALED(status)) {
+ printf("Terminated by %d %s\n", WTERMSIG(status), WCOREDUMP(status) ? " - core generated" : "");
+ } else if (WIFSTOPPED(status)) {
+ printf("Stopped by %d\n", WSTOPSIG(status));
+ } else if (WIFCONTINUED(status)) {
+ printf("Child is resumed\n");
+ }
+ }
+ }
}
-static inline int do_rm(const char *cmd)
+static inline int get_pixmap_size(Display *disp, Pixmap id, int *x, int *y, unsigned int *w, unsigned int *h)
{
- cmd += 2;
- while (*cmd && *cmd == ' ') cmd++;
- if (!*cmd) {
- return -1;
- }
+ Window dummy_win;
+ unsigned int dummy_border, dummy_depth;
+ int _x;
+ int _y;
- if (s_info.cmd != NOP) {
- printf("Waiting the server response\n");
- return -EBUSY;
- }
+ if (!x) {
+ x = &_x;
+ }
- s_info.targetdir = update_target_dir(cmd);
- if (!s_info.targetdir) {
- printf("%s is not exists\n", cmd);
- return -ENOENT;
- }
+ if (!y) {
+ y = &_y;
+ }
- if (!(node_mode(s_info.targetdir) & NODE_WRITE)) {
- printf("Access denied %s\n", cmd);
- return -EACCES;
- }
+ if (!XGetGeometry(disp, id, &dummy_win, x, y, w, h, &dummy_border, &dummy_depth)) {
+ return -EFAULT;
+ }
- send_inst_delete();
- return 0;
+ return 0;
}
-static inline int do_fault(const char *cmd)
+static inline int do_capture(Display *disp, Pixmap id, const char *filename)
{
- cmd += 5;
- while (*cmd && *cmd == ' ') cmd++;
- if (!*cmd) {
- return -1;
- }
+ XShmSegmentInfo si;
+ XImage *xim;
+ Visual *visual;
+ unsigned int w;
+ unsigned int h;
+ int bufsz;
+ int fd;
+ Screen *screen;
+
+ screen = DefaultScreenOfDisplay(disp);
+ visual = DefaultVisualOfScreen(screen);
+
+ if (get_pixmap_size(disp, id, NULL, NULL, &w, &h) < 0) {
+ printf("Failed to get size of a pixmap\n");
+ return -EINVAL;
+ }
+
+ printf("Pixmap size: %dx%d\n", w, h);
+ bufsz = w * h * sizeof(int);
+
+ si.shmid = shmget(IPC_PRIVATE, bufsz, IPC_CREAT | 0666);
+ if (si.shmid < 0) {
+ printf("shmget: %s\n", strerror(errno));
+ return -EFAULT;
+ }
+
+ si.readOnly = False;
+ si.shmaddr = shmat(si.shmid, NULL, 0);
+ if (si.shmaddr == (void *)-1) {
- if (s_info.cmd != NOP) {
- printf("Waiting the server response\n");
- return -EBUSY;
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
+ printf("shmctl: %s\n", strerror(errno));
}
- s_info.targetdir = update_target_dir(cmd);
- if (!s_info.targetdir) {
- printf("%s is not exists\n", cmd);
- return -ENOENT;
+ return -EFAULT;
+ }
+
+ /*!
+ * \NOTE
+ * Use the 24 bits Pixmap for Video player
+ */
+ xim = XShmCreateImage(disp, visual, 24 /* (depth << 3) */, ZPixmap, NULL, &si, w, h);
+ if (xim == NULL) {
+ if (shmdt(si.shmaddr) < 0) {
+ printf("shmdt: %s\n", strerror(errno));
}
- if (!(node_mode(s_info.targetdir) & NODE_WRITE)) {
- printf("Access denied %s\n", cmd);
- return -EACCES;
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
+ printf("shmctl: %s\n", strerror(errno));
}
- send_inst_fault();
- return 0;
-}
+ return -EFAULT;
+ }
-#if !defined(WCOREDUMP)
-#define WCOREDUMP(a) 0
-#endif
-
-static void do_sh(const char *cmd)
-{
- pid_t pid;
+ xim->data = si.shmaddr;
+ XShmAttach(disp, &si);
- cmd += 3;
+ XShmGetImage(disp, id, xim, 0, 0, 0xFFFFFFFF);
+ XSync(disp, False);
- while (*cmd && *cmd == ' ') {
- cmd++;
+ fd = open(filename, O_CREAT | O_RDWR, 0644);
+ if (fd >= 0) {
+ if (write(fd, xim->data, bufsz) != bufsz) {
+ printf("Data is not fully written\n");
}
- if (!*cmd) {
- return;
+ if (close(fd) < 0) {
+ printf("close: %s\n", strerror(errno));
}
+ } else {
+ printf("Error: %sn\n", strerror(errno));
+ }
- pid = fork();
- if (pid == 0) {
- char command[256];
- int idx;
- idx = 0;
+ XShmDetach(disp, &si);
+ XDestroyImage(xim);
- while (idx < (sizeof(command) - 1) && *cmd && *cmd != ' ') {
- command[idx++] = *cmd++;
- }
- command[idx] = '\0';
+ if (shmdt(si.shmaddr) < 0) {
+ printf("shmdt: %s\n", strerror(errno));
+ }
- if (execl(command, cmd, NULL) < 0) {
- printf("Failed to execute: %s\n", strerror(errno));
- }
+ if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
+ printf("shmctl: %s\n", strerror(errno));
+ }
- exit(0);
- } else if (pid < 0) {
- printf("Failed to create a new process: %s\n", strerror(errno));
- } else {
- int status;
- if (waitpid(pid, &status, 0) < 0) {
- printf("error: %s\n", strerror(errno));
- } else {
- if (WIFEXITED(status)) {
- printf("Exit: %d\n", WEXITSTATUS(status));
- } else if (WIFSIGNALED(status)) {
- printf("Terminated by %d %s\n", WTERMSIG(status), WCOREDUMP(status) ? " - core generated" : "");
- } else if (WIFSTOPPED(status)) {
- printf("Stopped by %d\n", WSTOPSIG(status));
- } else if (WIFCONTINUED(status)) {
- printf("Child is resumed\n");
- }
- }
- }
+ return 0;
}
-static inline int get_pixmap_size(Display *disp, Pixmap id, int *x, int *y, unsigned int *w, unsigned int *h)
+static void do_dump(const char *cmd)
{
- Window dummy_win;
- unsigned int dummy_border, dummy_depth;
- int _x;
- int _y;
+ char path[256];
+ int idx;
+ struct node *node;
+ struct node *curdir;
+ struct node *target;
- if (!x) {
- x = &_x;
- }
+ cmd += 5;
- if (!y) {
- y = &_y;
- }
-
- if (!XGetGeometry(disp, id, &dummy_win, x, y, w, h, &dummy_border, &dummy_depth)) {
- return -EFAULT;
- }
+ while (*cmd && *cmd == ' ') {
+ cmd++;
+ }
- return 0;
-}
+ if (!*cmd) {
+ return;
+ }
-static inline int do_capture(Display *disp, Pixmap id, const char *filename)
-{
- XShmSegmentInfo si;
- XImage *xim;
- Visual *visual;
- unsigned int w;
- unsigned int h;
- int bufsz;
- int fd;
- Screen *screen;
-
- screen = DefaultScreenOfDisplay(disp);
- visual = DefaultVisualOfScreen(screen);
-
- if (get_pixmap_size(disp, id, NULL, NULL, &w, &h) < 0) {
- printf("Failed to get size of a pixmap\n");
- return -EINVAL;
+ curdir = s_info.curdir;
+ do {
+ target = NULL;
+ idx = 0;
+ while (cmd[idx] != '/' && cmd[idx] != '\0' && cmd[idx] != ' ') {
+ idx++;
}
- printf("Pixmap size: %dx%d\n", w, h);
- bufsz = w * h * sizeof(int);
-
- si.shmid = shmget(IPC_PRIVATE, bufsz, IPC_CREAT | 0666);
- if (si.shmid < 0) {
- printf("shmget: %s\n", strerror(errno));
- return -EFAULT;
+ if (!idx) {
+ break;
}
- si.readOnly = False;
- si.shmaddr = shmat(si.shmid, NULL, 0);
- if (si.shmaddr == (void *)-1) {
+ strncpy(path, cmd, idx);
+ path[idx] = '\0';
+ cmd += idx;
- if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
- printf("shmctl: %s\n", strerror(errno));
- }
+ node = node_child(curdir);
+ while (node) {
+ if (!strcmp(node_name(node), path)) {
+ curdir = node;
+ target = curdir;
+ break;
+ }
- return -EFAULT;
+ node = node_next_sibling(node);
}
- /*!
- * \NOTE
- * Use the 24 bits Pixmap for Video player
- */
- xim = XShmCreateImage(disp, visual, 24 /* (depth << 3) */, ZPixmap, NULL, &si, w, h);
- if (xim == NULL) {
- if (shmdt(si.shmaddr) < 0) {
- printf("shmdt: %s\n", strerror(errno));
- }
-
- if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
- printf("shmctl: %s\n", strerror(errno));
- }
-
- return -EFAULT;
+ if (*cmd != '/') {
+ break;
}
+ } while ((*++cmd));
- xim->data = si.shmaddr;
- XShmAttach(disp, &si);
+ if (target && node_type(target) != NODE_DIR) {
+ struct instance *instinfo;
- XShmGetImage(disp, id, xim, 0, 0, 0xFFFFFFFF);
- XSync(disp, False);
+ if (node_type(target) == NODE_LINK) {
+ /* Follow up node */
+ }
- fd = open(filename, O_CREAT | O_RDWR, 0644);
- if (fd >= 0) {
- if (write(fd, xim->data, bufsz) != bufsz) {
- printf("Data is not fully written\n");
- }
+ instinfo = node_data(target);
+ if (instinfo) {
+ while (*cmd == ' ') {
+ cmd++;
+ }
- if (close(fd) < 0) {
- printf("close: %s\n", strerror(errno));
- }
- } else {
- printf("Error: %sn\n", strerror(errno));
- }
+ if (sscanf(cmd, "%255[^ ]", path) != 1) {
+ printf("dump file OUT_FILENAME\n");
+ return;
+ }
- XShmDetach(disp, &si);
- XDestroyImage(xim);
+ if (instinfo->buf_id) {
+ unsigned int pixmap;
+ int pixel_size;
+ if (sscanf(instinfo->buf_id, "pixmap://%u:%d", &pixmap, &pixel_size) == 2) {
+ Display *disp;
- if (shmdt(si.shmaddr) < 0) {
- printf("shmdt: %s\n", strerror(errno));
- }
+ disp = XOpenDisplay(NULL);
+ if (!disp) {
+ printf("Failed to connect to the X\n");
+ return;
+ }
- if (shmctl(si.shmid, IPC_RMID, 0) < 0) {
- printf("shmctl: %s\n", strerror(errno));
+ if (do_capture(disp, (Pixmap)pixmap, path) == 0) {
+ printf("Captured: %s\n", path);
+ }
+ XCloseDisplay(disp);
+ } else {
+ printf("Unsupported type\n");
+ }
+ } else {
+ printf("Buffer is not exists\n");
+ }
}
-
- return 0;
+ } else {
+ printf("target only can be a filename\n");
+ }
}
static void do_x(const char *cmd)
{
- Display *disp;
+ Display *disp;
- cmd += 2;
+ cmd += 2;
- while (*cmd && *cmd == ' ') {
- cmd++;
- }
+ while (*cmd && *cmd == ' ') {
+ cmd++;
+ }
- if (!*cmd) {
- return;
- }
+ if (!*cmd) {
+ return;
+ }
- disp = XOpenDisplay(NULL);
- if (!disp) {
- printf("Failed to connect to the X\n");
- return;
- }
+ disp = XOpenDisplay(NULL);
+ if (!disp) {
+ printf("Failed to connect to the X\n");
+ return;
+ }
- if (!strncasecmp(cmd, "damage ", 7)) {
- unsigned int winId;
- XRectangle rect;
- XserverRegion region;
- int x, y, w, h;
+ if (!strncasecmp(cmd, "damage ", 7)) {
+ unsigned int winId;
+ XRectangle rect;
+ XserverRegion region;
+ int x, y, w, h;
- cmd += 7;
+ cmd += 7;
- if (sscanf(cmd, "%u %d %d %d %d", &winId, &x, &y, &w, &h) != 5) {
- printf("Invalid argument\nx damage WINID_DEC X Y W H\n");
- return;
- }
- rect.x = x;
- rect.y = y;
- rect.width = w;
- rect.height = h;
- region = XFixesCreateRegion(disp, &rect, 1);
- XDamageAdd(disp, winId, region);
- XFixesDestroyRegion(disp, region);
- XFlush(disp);
-
- printf("Damage: %u %d %d %d %d\n", winId, x, y, w, h);
- } else if (!strncasecmp(cmd, "capture ", 8)) {
- unsigned int winId;
- char filename[256];
-
- cmd += 8;
-
- if (sscanf(cmd, "%u %255[^ ]", &winId, filename) != 2) {
- printf("Invalid argument\nx capture WINID_DEC FILENAME (%s)\n", cmd);
- return;
- }
- if (do_capture(disp, winId, filename) == 0) {
- printf("Captured: %s\n", filename);
- }
- } else if (!strncasecmp(cmd, "resize ", 7)) {
- unsigned int winId;
- int w;
- int h;
+ if (sscanf(cmd, "%u %d %d %d %d", &winId, &x, &y, &w, &h) != 5) {
+ printf("Invalid argument\nx damage WINID_DEC X Y W H\n");
+ return;
+ }
+ rect.x = x;
+ rect.y = y;
+ rect.width = w;
+ rect.height = h;
+ region = XFixesCreateRegion(disp, &rect, 1);
+ XDamageAdd(disp, winId, region);
+ XFixesDestroyRegion(disp, region);
+ XFlush(disp);
- cmd += 7;
+ printf("Damage: %u %d %d %d %d\n", winId, x, y, w, h);
+ } else if (!strncasecmp(cmd, "capture ", 8)) {
+ unsigned int winId;
+ char filename[256];
- if (sscanf(cmd, "%u %d %d", &winId, &w, &h) != 3) {
- printf("Invalid argument\nx resize WINID_DEC W H\n");
- return;
- }
+ cmd += 8;
- XResizeWindow(disp, winId, w, h);
- printf("Resize: %u %d %d\n", winId, w, h);
- } else if (!strncasecmp(cmd, "move ", 5)) {
- unsigned int winId;
- int x;
- int y;
+ if (sscanf(cmd, "%u %255[^ ]", &winId, filename) != 2) {
+ printf("Invalid argument\nx capture WINID_DEC FILENAME (%s)\n", cmd);
+ return;
+ }
+ if (do_capture(disp, winId, filename) == 0) {
+ printf("Captured: %s\n", filename);
+ }
+ } else if (!strncasecmp(cmd, "resize ", 7)) {
+ unsigned int winId;
+ int w;
+ int h;
- cmd += 5;
- if (sscanf(cmd, "%u %d %d", &winId, &x, &y) != 3) {
- printf("Invalid argument\nx move WINID_DEC X Y\n");
- return;
- }
+ cmd += 7;
- XMoveWindow(disp, winId, x, y);
- printf("Move: %u %d %d\n", winId, x, y);
- } else if (!strncasecmp(cmd, "map ", 4)) {
- unsigned int winId;
- cmd += 4;
- if (sscanf(cmd, "%u", &winId) != 1) {
- printf("Invalid argument\nx map WINID_DEC\n");
- return;
- }
- XMapRaised(disp, winId);
- printf("Map: %u\n", winId);
- } else if (!strncasecmp(cmd, "unmap ", 6)) {
- unsigned int winId;
- cmd += 6;
- if (sscanf(cmd, "%u", &winId) != 1) {
- printf("Invalid argument\nx unmap WINID_DEC\n");
- return;
- }
- XUnmapWindow(disp, winId);
- printf("Unmap: %u\n", winId);
- } else {
- printf("Unknown command\n");
+ if (sscanf(cmd, "%u %d %d", &winId, &w, &h) != 3) {
+ printf("Invalid argument\nx resize WINID_DEC W H\n");
+ return;
}
- XCloseDisplay(disp);
+ XResizeWindow(disp, winId, w, h);
+ printf("Resize: %u %d %d\n", winId, w, h);
+ } else if (!strncasecmp(cmd, "move ", 5)) {
+ unsigned int winId;
+ int x;
+ int y;
+
+ cmd += 5;
+ if (sscanf(cmd, "%u %d %d", &winId, &x, &y) != 3) {
+ printf("Invalid argument\nx move WINID_DEC X Y\n");
+ return;
+ }
+
+ XMoveWindow(disp, winId, x, y);
+ printf("Move: %u %d %d\n", winId, x, y);
+ } else if (!strncasecmp(cmd, "map ", 4)) {
+ unsigned int winId;
+ cmd += 4;
+ if (sscanf(cmd, "%u", &winId) != 1) {
+ printf("Invalid argument\nx map WINID_DEC\n");
+ return;
+ }
+ XMapRaised(disp, winId);
+ printf("Map: %u\n", winId);
+ } else if (!strncasecmp(cmd, "unmap ", 6)) {
+ unsigned int winId;
+ cmd += 6;
+ if (sscanf(cmd, "%u", &winId) != 1) {
+ printf("Invalid argument\nx unmap WINID_DEC\n");
+ return;
+ }
+ XUnmapWindow(disp, winId);
+ printf("Unmap: %u\n", winId);
+ } else {
+ printf("Unknown command\n");
+ }
+
+ XCloseDisplay(disp);
}
static inline void put_command(const char *cmd)
{
- if (s_info.history[s_info.history_top]) {
- free(s_info.history[s_info.history_top]);
- s_info.history[s_info.history_top] = NULL;
- }
+ if (s_info.history[s_info.history_top]) {
+ free(s_info.history[s_info.history_top]);
+ s_info.history[s_info.history_top] = NULL;
+ }
- s_info.history[s_info.history_top] = strdup(cmd);
- s_info.history_top = (s_info.history_top + !!s_info.history[s_info.history_top]) % (sizeof(s_info.history) / sizeof(s_info.history[0]));
+ s_info.history[s_info.history_top] = strdup(cmd);
+ s_info.history_top = (s_info.history_top + !!s_info.history[s_info.history_top]) % (sizeof(s_info.history) / sizeof(s_info.history[0]));
}
static inline const char *get_command(int idx)
{
- idx = s_info.history_top + idx;
- while (idx < 0) {
- idx += (sizeof(s_info.history) / sizeof(s_info.history[0]));
- }
+ idx = s_info.history_top + idx;
+ while (idx < 0) {
+ idx += (sizeof(s_info.history) / sizeof(s_info.history[0]));
+ }
- return s_info.history[idx];
+ return s_info.history[idx];
}
-static inline void do_command(const char *cmd)
+static void do_command(const char *cmd)
{
- /* Skip the first spaces */
- while (*cmd && *cmd == ' ') {
- cmd++;
- }
-
- if (strlen(cmd) && *cmd != '#') {
- if (!strncasecmp(cmd, "exit", 4) || !strncasecmp(cmd, "quit", 4)) {
- ecore_main_loop_quit();
- } else if (!strncasecmp(cmd, "set ", 4)) {
- if (do_set(cmd) == 0) {
- return;
- }
- } else if (!strncasecmp(cmd, "stat ", 5)) {
- do_stat(cmd);
- } else if (!strncasecmp(cmd, "get ", 4)) {
- if (do_get(cmd) == 0) {
- return;
- }
- } else if (!strncasecmp(cmd, "ls", 2)) {
- if (do_ls(cmd) == 0) {
- return;
- }
- } else if (!strncasecmp(cmd, "cd", 2)) {
- if (do_cd(cmd) == 0) {
- return;
- }
- } else if (!strncasecmp(cmd, "rm", 2)) {
- if (do_rm(cmd) == 0) {
- return;
- }
- } else if (!strncasecmp(cmd, "fault", 5)) {
- if (do_fault(cmd) == 0) {
- return;
- }
- } else if (!strncasecmp(cmd, "sh ", 3)) {
- do_sh(cmd);
- } else if (!strncasecmp(cmd, "x ", 2)) {
- do_x(cmd);
- } else {
- help();
- }
+ /* Skip the first spaces */
+ while (*cmd && *cmd == ' ') {
+ cmd++;
+ }
+
+ if (strlen(cmd) && *cmd != '#') {
+ if (!strncasecmp(cmd, "exit", 4) || !strncasecmp(cmd, "quit", 4)) {
+ ecore_main_loop_quit();
+ } else if (!strncasecmp(cmd, "set ", 4)) {
+ if (do_set(cmd) == 0) {
+ return;
+ }
+ } else if (!strncasecmp(cmd, "stat ", 5)) {
+ do_stat(cmd);
+ } else if (!strncasecmp(cmd, "get ", 4)) {
+ if (do_get(cmd) == 0) {
+ return;
+ }
+ } else if (!strncasecmp(cmd, "ls", 2)) {
+ if (do_ls(cmd) == 0) {
+ return;
+ }
+ } else if (!strncasecmp(cmd, "cd", 2)) {
+ if (do_cd(cmd) == 0) {
+ return;
+ }
+ } else if (!strncasecmp(cmd, "rm", 2)) {
+ if (do_rm(cmd) == 0) {
+ return;
+ }
+ } else if (!strncasecmp(cmd, "fault", 5)) {
+ if (do_fault(cmd) == 0) {
+ return;
+ }
+ } else if (!strncasecmp(cmd, "sh ", 3)) {
+ do_sh(cmd);
+ } else if (!strncasecmp(cmd, "x ", 2)) {
+ do_x(cmd);
+ } else if (!strncasecmp(cmd, "dump", 4)) {
+ do_dump(cmd);
+ } else {
+ help();
}
+ }
- prompt(NULL);
- return;
+ prompt(NULL);
+ return;
}
+#define CMD_BUFFER_SIZE 256
+
static Eina_Bool input_cb(void *data, Ecore_Fd_Handler *fd_handler)
{
- static int idx = 0;
- static char cmd_buffer[256];
- char ch;
- int fd;
- int ret;
- const char escape_str[] = { 0x1b, 0x5b, 0x0 };
- const char *escape_ptr = escape_str;
- const char *tmp;
-
- if (fd_handler) {
- fd = ecore_main_fd_handler_fd_get(fd_handler);
- if (fd < 0) {
- printf("FD is not valid: %d\n", fd);
- return ECORE_CALLBACK_CANCEL;
+ static int idx = 0;
+ static char cmd_buffer[CMD_BUFFER_SIZE];
+ unsigned char ch;
+ int fd;
+ int ret;
+ const char escape_str[] = { 0x1b, 0x5b, 0x0 };
+ const char *escape_ptr = escape_str;
+ const char *tmp;
+
+ if (fd_handler) {
+ fd = ecore_main_fd_handler_fd_get(fd_handler);
+ if (fd < 0) {
+ printf("FD is not valid: %d\n", fd);
+ return ECORE_CALLBACK_CANCEL;
+ }
+ } else {
+ fd = s_info.input_fd;
+ }
+
+ /*!
+ * \note
+ * Using this routine, we can implement the command recommend algorithm.
+ * When a few more characters are matched with history of command, we can show it to user
+ * Then the user will choose one or write new command
+ */
+
+ /* Silly.. Silly */
+ while ((ret = read(fd, &ch, sizeof(ch))) == sizeof(ch)) {
+ if (*escape_ptr == '\0') {
+ /* Function key */
+ switch (ch) {
+ case 0x41: /* UP */
+ printf("%s2K%s1G", escape_str, escape_str);
+ tmp = get_command(--s_info.history_idx);
+ if (!tmp) {
+ s_info.history_idx = 0;
+ cmd_buffer[0] = '\0';
+ prompt(NULL);
+ } else {
+ strcpy(cmd_buffer, tmp);
+ idx = strlen(cmd_buffer);
+ prompt(cmd_buffer);
+ }
+ break;
+ case 0x42: /* DOWN */
+ if (s_info.history_idx >= 0) {
+ break;
+ }
+
+ printf("%s2K%s1G", escape_str, escape_str);
+ tmp = get_command(++s_info.history_idx);
+ if (s_info.history_idx == 0) {
+ s_info.history_idx = 0;
+ cmd_buffer[0] = '\0';
+ prompt(NULL);
+ } else {
+ strncpy(cmd_buffer, tmp, CMD_BUFFER_SIZE - 1);
+ cmd_buffer[CMD_BUFFER_SIZE - 1] = '\0';
+ idx = strlen(cmd_buffer);
+ prompt(cmd_buffer);
+ }
+ break;
+ case 0x43: /* RIGHT */
+ break;
+ case 0x44: /* LEFT */
+ break;
+ default:
+ break;
+ }
+
+ escape_ptr = escape_str;
+ continue;
+ } else if (ch == *escape_ptr) {
+ escape_ptr++;
+ continue;
+ }
+
+ switch (ch) {
+ case 0x7F: /* BKSP */
+ case 0x80:
+ cmd_buffer[idx] = '\0';
+ if (idx > 0) {
+ idx--;
+ cmd_buffer[idx] = ' ';
+ putc('\r', stdout);
+ prompt(cmd_buffer);
}
- } else {
- fd = s_info.input_fd;
- }
- /*!
- * \note
- * Using this routine, we can implement the command recommend algorithm.
- * When a few more characters are matched with history of command, we can show it to user
- * Then the user will choose one or write new command
- */
-
- /* Silly.. Silly */
- while ((ret = read(fd, &ch, sizeof(ch))) == sizeof(ch)) {
- if (*escape_ptr == '\0') {
- /* Function key */
- switch (ch) {
- case 0x41: /* UP */
- printf("%s2K%s1G", escape_str, escape_str);
- tmp = get_command(--s_info.history_idx);
- if (!tmp) {
- s_info.history_idx = 0;
- cmd_buffer[0] = '\0';
- prompt(NULL);
- } else {
- strcpy(cmd_buffer, tmp);
- idx = strlen(cmd_buffer);
- prompt(cmd_buffer);
- }
- break;
- case 0x42: /* DOWN */
- if (s_info.history_idx >= 0) {
- break;
- }
-
- printf("%s2K%s1G", escape_str, escape_str);
- tmp = get_command(++s_info.history_idx);
- if (s_info.history_idx == 0) {
- s_info.history_idx = 0;
- cmd_buffer[0] = '\0';
- prompt(NULL);
- } else {
- strcpy(cmd_buffer, tmp);
- idx = strlen(cmd_buffer);
- prompt(cmd_buffer);
- }
- break;
- case 0x43: /* RIGHT */
- break;
- case 0x44: /* LEFT */
- break;
- default:
- break;
- }
-
- escape_ptr = escape_str;
- continue;
- } else if (ch == *escape_ptr) {
- escape_ptr++;
- continue;
+ cmd_buffer[idx] = '\0';
+ putc('\r', stdout);
+ prompt(cmd_buffer);
+ break;
+ case 0x09: /* TAB */
+ if (!s_info.quick_search_node) {
+ s_info.quick_search_node = node_child(s_info.curdir);
+ s_info.quick_idx = idx;
+ } else {
+ s_info.quick_search_node = node_next_sibling(s_info.quick_search_node);
+ idx = s_info.quick_idx;
}
- switch (ch) {
- case 0x08: /* BKSP */
- cmd_buffer[idx] = '\0';
- if (idx > 0) {
- idx--;
- cmd_buffer[idx] = ' ';
- putc('\r', stdout);
- prompt(cmd_buffer);
- }
+ if (!s_info.quick_search_node) {
+ break;
+ }
+ printf("%s2K%s1G", escape_str, escape_str);
+ strcpy(cmd_buffer + idx, node_name(s_info.quick_search_node));
+ idx += strlen(node_name(s_info.quick_search_node));
+ prompt(cmd_buffer);
+ break;
+ case '\n':
+ case '\r':
+ cmd_buffer[idx] = '\0';
+ idx = 0;
+ if (s_info.input_fd == STDIN_FILENO || s_info.verbose) {
+ putc((int)'\n', stdout);
+ }
+ do_command(cmd_buffer);
+ put_command(cmd_buffer);
+ memset(cmd_buffer, 0, sizeof(cmd_buffer));
+ s_info.history_idx = 0;
+ s_info.quick_search_node = NULL;
+
+ /* Make a main loop processing for command handling */
+ return ECORE_CALLBACK_RENEW;
+ default:
+ if (isascii(ch)) {
+ cmd_buffer[idx++] = ch;
+
+ if (s_info.input_fd == STDIN_FILENO || s_info.verbose) {
+ putc((int)ch, stdout);
+ }
+
+ if (idx == sizeof(cmd_buffer) - 1) {
cmd_buffer[idx] = '\0';
- putc('\r', stdout);
- prompt(cmd_buffer);
- break;
- case 0x09: /* TAB */
- if (!s_info.quick_search_node) {
- s_info.quick_search_node = node_child(s_info.curdir);
- s_info.quick_idx = idx;
- } else {
- s_info.quick_search_node = node_next_sibling(s_info.quick_search_node);
- idx = s_info.quick_idx;
- }
-
- if (!s_info.quick_search_node) {
- break;
- }
-
- printf("%s2K%s1G", escape_str, escape_str);
- strcpy(cmd_buffer + idx, node_name(s_info.quick_search_node));
- idx += strlen(node_name(s_info.quick_search_node));
- prompt(cmd_buffer);
- break;
- case '\n':
- case '\r':
- cmd_buffer[idx] = '\0';
+ printf("\nCommand buffer is overflow: %s\n", cmd_buffer);
idx = 0;
- if (s_info.input_fd == STDIN_FILENO || s_info.verbose) {
- putc((int)'\n', stdout);
- }
- do_command(cmd_buffer);
- put_command(cmd_buffer);
- memset(cmd_buffer, 0, sizeof(cmd_buffer));
- s_info.history_idx = 0;
- s_info.quick_search_node = NULL;
-
- /* Make a main loop processing for command handling */
- return ECORE_CALLBACK_RENEW;
- default:
- cmd_buffer[idx++] = ch;
-
- if (s_info.input_fd == STDIN_FILENO || s_info.verbose) {
- putc((int)ch, stdout);
- }
-
- if (idx == sizeof(cmd_buffer) - 1) {
- cmd_buffer[idx] = '\0';
- printf("\nCommand buffer is overflow: %s\n", cmd_buffer);
- idx = 0;
- }
- break;
+ }
+ } else {
+ printf("Unknown character: 0x%X\n", (unsigned int)ch);
}
+ break;
}
+ }
- if (ret < 0 && !fd_handler) {
- ecore_main_loop_quit();
- }
+ if (ret < 0 && !fd_handler) {
+ ecore_main_loop_quit();
+ }
- return ECORE_CALLBACK_RENEW;
+ return ECORE_CALLBACK_RENEW;
}
static void processing_line_buffer(const char *buffer)
{
- int pid;
- char slavename[256];
- char pkgname[256];
- char abi[256];
- char inst_id[4096];
- char cluster[256];
- char category[256];
- char state[10];
- int refcnt;
- int fault_count;
- int list_count;
- int loaded_inst;
- int loaded_pkg;
- double ttl;
- int secured;
- double period;
- int width;
- int height;
- struct node *node;
- struct package *pkginfo;
- struct instance *instinfo;
- struct slave *slaveinfo;
- int i;
-
- switch (s_info.cmd) {
+ int pid;
+ char slavename[256];
+ char pkgname[256];
+ char abi[256];
+ char inst_id[4096];
+ char buf_id[256];
+ char cluster[256];
+ char category[256];
+ char str_period[64];
+ char state[10];
+ int refcnt;
+ int fault_count;
+ int list_count;
+ int loaded_inst;
+ int loaded_pkg;
+ double ttl;
+ int secured;
+ double period;
+ int width;
+ int height;
+ struct node *node;
+ struct package *pkginfo;
+ struct instance *instinfo;
+ struct slave *slaveinfo;
+ int i;
+
+ switch (s_info.cmd) {
case PKG_LIST:
- if (sscanf(buffer, "%d %255[^ ] %255[^ ] %255[^ ] %d %d %d", &pid, slavename, pkgname, abi, &refcnt, &fault_count, &list_count) != 7) {
- printf("Invalid format : [%s]\n", buffer);
- return;
+ if (sscanf(buffer, "%d %255[^ ] %255[^ ] %255[^ ] %d %d %d", &pid, slavename, pkgname, abi, &refcnt, &fault_count, &list_count) != 7) {
+ printf("Invalid format : [%s]\n", buffer);
+ return;
+ }
+
+ node = node_find(s_info.targetdir, pkgname);
+ if (!node) {
+ pkginfo = calloc(1, sizeof(*pkginfo));
+ if (!pkginfo) {
+ printf("Error: %s\n", strerror(errno));
+ return;
}
- node = node_find(s_info.targetdir, pkgname);
- if (!node) {
- pkginfo = calloc(1, sizeof(*pkginfo));
- if (!pkginfo) {
- printf("Error: %s\n", strerror(errno));
- return;
- }
-
- pkginfo->pkgid = strdup("conf.file");
- if (!pkginfo->pkgid) {
- printf("Error: %s\n", strerror(errno));
- }
-
- pkginfo->primary = 1;
-
- node = node_create(s_info.targetdir, pkgname, NODE_DIR);
- if (!node) {
- free(pkginfo->pkgid);
- free(pkginfo);
- printf("Failed to create a new node (%s)\n", pkgname);
- return;
- }
-
- node_set_mode(node, NODE_READ | NODE_EXEC);
- node_set_data(node, pkginfo);
- } else {
- pkginfo = node_data(node);
- if (!pkginfo) {
- printf("Package info is inavlid\n");
- return;
- }
-
- free(pkginfo->slavename);
- free(pkginfo->abi);
-
- pkginfo->slavename = NULL;
- pkginfo->abi = NULL;
+ pkginfo->pkgid = strdup("conf.file");
+ if (!pkginfo->pkgid) {
+ printf("Error: %s\n", strerror(errno));
}
- node_set_age(node, s_info.age);
+ pkginfo->primary = 1;
- pkginfo->slavename = strdup(slavename);
- if (!pkginfo->slavename) {
- printf("Error: %s\n", strerror(errno));
+ node = node_create(s_info.targetdir, pkgname, NODE_DIR, NODE_READ | NODE_EXEC);
+ if (!node) {
+ free(pkginfo->pkgid);
+ free(pkginfo);
+ printf("Failed to create a new node (%s)\n", pkgname);
+ return;
}
- pkginfo->abi = strdup(abi);
- if (!pkginfo->abi) {
- printf("Error: %s\n", strerror(errno));
+ node_set_data(node, pkginfo);
+ } else {
+ pkginfo = node_data(node);
+ if (!pkginfo) {
+ printf("Package info is inavlid\n");
+ return;
}
- pkginfo->pid = pid;
- pkginfo->refcnt = refcnt;
- pkginfo->fault_count = fault_count;
- pkginfo->inst_count = list_count;
- break;
+ free(pkginfo->slavename);
+ free(pkginfo->abi);
+
+ pkginfo->slavename = NULL;
+ pkginfo->abi = NULL;
+ }
+
+ node_set_age(node, s_info.age);
+
+ pkginfo->slavename = strdup(slavename);
+ if (!pkginfo->slavename) {
+ printf("Error: %s\n", strerror(errno));
+ }
+
+ pkginfo->abi = strdup(abi);
+ if (!pkginfo->abi) {
+ printf("Error: %s\n", strerror(errno));
+ }
+
+ pkginfo->pid = pid;
+ pkginfo->refcnt = refcnt;
+ pkginfo->fault_count = fault_count;
+ pkginfo->inst_count = list_count;
+ break;
case SLAVE_LIST:
- if (sscanf(buffer, "%d %[^ ] %[^ ] %[^ ] %d %d %d %[^ ] %d %d %lf", &pid, slavename, pkgname, abi, &secured, &refcnt, &fault_count, state, &loaded_inst, &loaded_pkg, &ttl) != 11) {
- printf("Invalid format : [%s]\n", buffer);
- return;
+ if (sscanf(buffer, "%d %[^ ] %[^ ] %[^ ] %d %d %d %[^ ] %d %d %lf", &pid, slavename, pkgname, abi, &secured, &refcnt, &fault_count, state, &loaded_inst, &loaded_pkg, &ttl) != 11) {
+ printf("Invalid format : [%s]\n", buffer);
+ return;
+ }
+ node = node_find(s_info.targetdir, slavename);
+ if (!node) {
+ slaveinfo = calloc(1, sizeof(*slaveinfo));
+ if (!slaveinfo) {
+ printf("Error: %s\n", strerror(errno));
+ return;
}
- node = node_find(s_info.targetdir, slavename);
+
+ node = node_create(s_info.targetdir, slavename, NODE_DIR, NODE_READ | NODE_EXEC);
if (!node) {
- slaveinfo = calloc(1, sizeof(*slaveinfo));
- if (!slaveinfo) {
- printf("Error: %s\n", strerror(errno));
- return;
- }
-
- node = node_create(s_info.targetdir, slavename, NODE_DIR);
- if (!node) {
- free(slaveinfo);
- return;
- }
-
- node_set_mode(node, NODE_READ | NODE_EXEC);
- node_set_data(node, slaveinfo);
- } else {
- slaveinfo = node_data(node);
+ free(slaveinfo);
+ return;
}
- node_set_age(node, s_info.age);
+ node_set_data(node, slaveinfo);
+ } else {
+ slaveinfo = node_data(node);
+ }
- free(slaveinfo->pkgname);
- free(slaveinfo->abi);
- free(slaveinfo->state);
+ node_set_age(node, s_info.age);
- slaveinfo->pkgname = strdup(pkgname);
- if (!slaveinfo->pkgname) {
- printf("Error: %s\n", strerror(errno));
- }
+ free(slaveinfo->pkgname);
+ free(slaveinfo->abi);
+ free(slaveinfo->state);
- slaveinfo->abi = strdup(abi);
- if (!slaveinfo->abi) {
- printf("Error: %s\n", strerror(errno));
- }
+ slaveinfo->pkgname = strdup(pkgname);
+ if (!slaveinfo->pkgname) {
+ printf("Error: %s\n", strerror(errno));
+ }
- slaveinfo->state = strdup(state);
- if (!slaveinfo->state) {
- printf("Error: %s\n", strerror(errno));
- }
+ slaveinfo->abi = strdup(abi);
+ if (!slaveinfo->abi) {
+ printf("Error: %s\n", strerror(errno));
+ }
- slaveinfo->pid = pid;
- slaveinfo->secured = secured;
- slaveinfo->refcnt = refcnt;
- slaveinfo->fault_count = fault_count;
- slaveinfo->loaded_inst = loaded_inst;
- slaveinfo->loaded_pkg = loaded_pkg;
- slaveinfo->ttl = ttl;
- break;
+ slaveinfo->state = strdup(state);
+ if (!slaveinfo->state) {
+ printf("Error: %s\n", strerror(errno));
+ }
+
+ slaveinfo->pid = pid;
+ slaveinfo->secured = secured;
+ slaveinfo->refcnt = refcnt;
+ slaveinfo->fault_count = fault_count;
+ slaveinfo->loaded_inst = loaded_inst;
+ slaveinfo->loaded_pkg = loaded_pkg;
+ slaveinfo->ttl = ttl;
+ break;
case INST_LIST:
- if (sscanf(buffer, "%[^ ] %[^ ] %[^ ] %lf %[^ ] %d %d", inst_id, cluster, category, &period, state, &width, &height) != 7) {
- printf("Invalid format : [%s]\n", buffer);
- return;
- }
+ if (sscanf(buffer, "%[^ ] %[^ ] %[^ ] %[^ ] %[^ ] %[^ ] %d %d", inst_id, buf_id, cluster, category, str_period, state, &width, &height) != 8) {
+ printf("Invalid format : [%s]\n", buffer);
+ return;
+ }
+
+ period = strtod(str_period, NULL);
- for (i = strlen(inst_id); i > 0 && inst_id[i] != '/'; i--);
- i += (inst_id[i] == '/');
+ for (i = strlen(inst_id); i > 0 && inst_id[i] != '/'; i--);
+ i += (inst_id[i] == '/');
+
+ node = node_find(s_info.targetdir, inst_id + i);
+ if (!node) {
+ instinfo = calloc(1, sizeof(*instinfo));
+ if (!instinfo) {
+ printf("Error: %s\n", strerror(errno));
+ return;
+ }
- node = node_find(s_info.targetdir, inst_id + i);
+ node = node_create(s_info.targetdir, inst_id + i, NODE_FILE, NODE_READ | NODE_WRITE);
if (!node) {
- instinfo = calloc(1, sizeof(*instinfo));
- if (!instinfo) {
- printf("Error: %s\n", strerror(errno));
- return;
- }
-
- node = node_create(s_info.targetdir, inst_id + i, NODE_FILE);
- if (!node) {
- free(instinfo);
- return;
- }
-
- node_set_mode(node, NODE_READ | NODE_WRITE);
- node_set_data(node, instinfo);
- } else {
- instinfo = node_data(node);
+ free(instinfo);
+ return;
}
- node_set_age(node, s_info.age);
+ node_set_data(node, instinfo);
+ } else {
+ instinfo = node_data(node);
+ }
- free(instinfo->id);
- free(instinfo->cluster);
- free(instinfo->category);
- free(instinfo->state);
+ node_set_age(node, s_info.age);
- instinfo->id = strdup(inst_id);
- if (!instinfo->id) {
- printf("Error: %s\n", strerror(errno));
- }
+ free(instinfo->id);
+ free(instinfo->buf_id);
+ free(instinfo->cluster);
+ free(instinfo->category);
+ free(instinfo->state);
- instinfo->cluster = strdup(cluster);
- if (!instinfo->cluster) {
- printf("Error: %s\n", strerror(errno));
- }
+ instinfo->id = strdup(inst_id);
+ if (!instinfo->id) {
+ printf("Error: %s\n", strerror(errno));
+ }
- instinfo->category = strdup(category);
- if (!instinfo->category) {
- printf("Error: %s\n", strerror(errno));
- }
+ instinfo->cluster = strdup(cluster);
+ if (!instinfo->cluster) {
+ printf("Error: %s\n", strerror(errno));
+ }
- instinfo->state = strdup(state);
- if (!instinfo->state) {
- printf("Error: %s\n", strerror(errno));
- }
+ instinfo->category = strdup(category);
+ if (!instinfo->category) {
+ printf("Error: %s\n", strerror(errno));
+ }
- instinfo->period = period;
- instinfo->width = width;
- instinfo->height = height;
- break;
+ instinfo->state = strdup(state);
+ if (!instinfo->state) {
+ printf("Error: %s\n", strerror(errno));
+ }
+
+ if (strlen(buf_id)) {
+ instinfo->buf_id = strdup(buf_id);
+ }
+
+ instinfo->period = period;
+ instinfo->width = width;
+ instinfo->height = height;
+ break;
case INST_CTRL:
- sscanf(buffer, "%d", &i);
- printf("%s\n", strerror(i));
- printf("Result: %d\n", i);
- break;
+ sscanf(buffer, "%d", &i);
+ printf("%s\n", strerror(i));
+ printf("Result: %d\n", i);
+ break;
case SLAVE_CTRL:
- sscanf(buffer, "%d", &i);
- printf("Result: %d\n", i);
- break;
+ sscanf(buffer, "%d", &i);
+ printf("Result: %d\n", i);
+ break;
case MASTER_CTRL:
- sscanf(buffer, "%d", &i);
- printf("Result: %d\n", i);
- break;
+ sscanf(buffer, "%d", &i);
+ printf("Result: %d\n", i);
+ break;
default:
- break;
- }
+ break;
+ }
}
static inline void do_line_command(void)
{
- switch (s_info.cmd) {
+ switch (s_info.cmd) {
case PKG_LIST:
- ls();
- break;
+ ls();
+ break;
case INST_LIST:
- ls();
- break;
+ ls();
+ break;
case SLAVE_LIST:
- ls();
- break;
+ ls();
+ break;
case INST_CTRL:
- break;
+ break;
case SLAVE_CTRL:
- break;
+ break;
case MASTER_CTRL:
- break;
+ break;
default:
- break;
- }
- prompt(NULL);
+ break;
+ }
+ prompt(NULL);
}
static Eina_Bool read_cb(void *data, Ecore_Fd_Handler *fd_handler)
{
- int fd;
- static char *line_buffer = NULL;
- static int line_index = 0;
- static int bufsz = 256;
- char ch;
+ int fd;
+ static char *line_buffer = NULL;
+ static int line_index = 0;
+ static int bufsz = 256;
+ char ch;
+
+ fd = ecore_main_fd_handler_fd_get(fd_handler);
+ if (fd < 0) {
+ printf("FD is not valid: %d\n", fd);
+ return ECORE_CALLBACK_CANCEL;
+ }
- fd = ecore_main_fd_handler_fd_get(fd_handler);
- if (fd < 0) {
- printf("FD is not valid: %d\n", fd);
- return ECORE_CALLBACK_CANCEL;
+ if (read(fd, &ch, sizeof(ch)) != sizeof(ch)) {
+ printf("Error: %s\n", strerror(errno));
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (!line_buffer) {
+ line_index = 0;
+ line_buffer = malloc(bufsz);
+ if (!line_buffer) {
+ printf("Error: %s\n", strerror(errno));
+ return ECORE_CALLBACK_CANCEL;
}
+ }
- if (read(fd, &ch, sizeof(ch)) != sizeof(ch)) {
+ if (ch == '\n') { /* End of a line */
+ if (line_index == bufsz - 1) {
+ char *new_buf;
+ new_buf = realloc(line_buffer, bufsz + 2);
+ if (!new_buf) {
printf("Error: %s\n", strerror(errno));
+ free(line_buffer);
+ line_buffer = NULL;
+ line_index = 0;
+ bufsz = 256;
return ECORE_CALLBACK_CANCEL;
+ }
+
+ line_buffer = new_buf;
}
- if (!line_buffer) {
- line_index = 0;
- line_buffer = malloc(bufsz);
- if (!line_buffer) {
- printf("Error: %s\n", strerror(errno));
- return ECORE_CALLBACK_CANCEL;
- }
- }
-
- if (ch == '\n') { /* End of a line */
- if (line_index == bufsz - 1) {
- char *new_buf;
- new_buf = realloc(line_buffer, bufsz + 2);
- if (!new_buf) {
- printf("Error: %s\n", strerror(errno));
- free(line_buffer);
- line_buffer = NULL;
- line_index = 0;
- bufsz = 256;
- return ECORE_CALLBACK_CANCEL;
- }
-
- line_buffer = new_buf;
- }
+ line_buffer[line_index] = '\0';
- line_buffer[line_index] = '\0';
+ if (!strcmp(line_buffer, "EOD")) {
+ do_line_command();
+ s_info.cmd = NOP;
+ } else {
+ processing_line_buffer(line_buffer);
+ }
- if (!strcmp(line_buffer, "EOD")) {
- do_line_command();
- s_info.cmd = NOP;
- } else {
- processing_line_buffer(line_buffer);
- }
+ free(line_buffer);
+ line_buffer = NULL;
+ line_index = 0;
+ bufsz = 256;
+ } else {
+ char *new_buf;
+ line_buffer[line_index++] = ch;
+ if (line_index == bufsz - 1) {
+ bufsz += 256;
+ new_buf = realloc(line_buffer, bufsz);
+ if (!new_buf) {
+ printf("Error: %s\n", strerror(errno));
free(line_buffer);
line_buffer = NULL;
line_index = 0;
bufsz = 256;
- } else {
- char *new_buf;
-
- line_buffer[line_index++] = ch;
- if (line_index == bufsz - 1) {
- bufsz += 256;
- new_buf = realloc(line_buffer, bufsz);
- if (!new_buf) {
- printf("Error: %s\n", strerror(errno));
- free(line_buffer);
- line_buffer = NULL;
- line_index = 0;
- bufsz = 256;
- return ECORE_CALLBACK_CANCEL;
- }
-
- line_buffer = new_buf;
- }
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ line_buffer = new_buf;
}
+ }
- return ECORE_CALLBACK_RENEW;
+ return ECORE_CALLBACK_RENEW;
}
static int ret_cb(pid_t pid, int handle, const struct packet *packet, void *data)
{
- const char *fifo_name;
- int ret;
+ const char *fifo_name;
+ int ret;
- if (packet_get(packet, "si", &fifo_name, &ret) != 2) {
- printf("Invalid packet\n");
- return -EFAULT;
- }
+ if (packet_get(packet, "si", &fifo_name, &ret) != 2) {
+ printf("Invalid packet\n");
+ return -EFAULT;
+ }
- if (ret != 0) {
- printf("Returns %d\n", ret);
- return ret;
- }
+ if (ret != 0) {
+ printf("Returns %d\n", ret);
+ return ret;
+ }
- printf("FIFO: %s\n", fifo_name);
+ printf("FIFO: %s\n", fifo_name);
- s_info.fifo_handle = open(fifo_name, O_RDONLY | O_NONBLOCK);
- if (s_info.fifo_handle < 0) {
- printf("Error: %s\n", strerror(errno));
- s_info.fifo_handle = -EINVAL;
- ecore_main_loop_quit();
- return -EINVAL;
- }
+ s_info.fifo_handle = open(fifo_name, O_RDONLY | O_NONBLOCK);
+ if (s_info.fifo_handle < 0) {
+ printf("Error: %s\n", strerror(errno));
+ s_info.fifo_handle = -EINVAL;
+ ecore_main_loop_quit();
+ return -EINVAL;
+ }
- s_info.fd_handler = ecore_main_fd_handler_add(s_info.fifo_handle, ECORE_FD_READ, read_cb, NULL, NULL, NULL);
- if (!s_info.fd_handler) {
- printf("Failed to add a fd handler\n");
- if (close(s_info.fifo_handle) < 0) {
- printf("close: %s\n", strerror(errno));
- }
- s_info.fifo_handle = -EINVAL;
- ecore_main_loop_quit();
- return -EFAULT;
+ s_info.fd_handler = ecore_main_fd_handler_add(s_info.fifo_handle, ECORE_FD_READ, read_cb, NULL, NULL, NULL);
+ if (!s_info.fd_handler) {
+ printf("Failed to add a fd handler\n");
+ if (close(s_info.fifo_handle) < 0) {
+ printf("close: %s\n", strerror(errno));
}
+ s_info.fifo_handle = -EINVAL;
+ ecore_main_loop_quit();
+ return -EFAULT;
+ }
- prompt(NULL);
+ prompt(NULL);
- if (s_info.input_fd == STDIN_FILENO) {
- if (fcntl(s_info.input_fd, F_SETFL, O_NONBLOCK) < 0) {
- printf("Error: %s\n", strerror(errno));
- }
+ if (s_info.input_fd == STDIN_FILENO) {
+ if (fcntl(s_info.input_fd, F_SETFL, O_NONBLOCK) < 0) {
+ printf("Error: %s\n", strerror(errno));
+ }
- s_info.in_handler = ecore_main_fd_handler_add(s_info.input_fd, ECORE_FD_READ, input_cb, NULL, NULL, NULL);
- if (!s_info.in_handler) {
- printf("Failed to add a input handler\n");
- ecore_main_loop_quit();
- return -EFAULT;
- }
+ s_info.in_handler = ecore_main_fd_handler_add(s_info.input_fd, ECORE_FD_READ, input_cb, NULL, NULL, NULL);
+ if (!s_info.in_handler) {
+ printf("Failed to add a input handler\n");
+ ecore_main_loop_quit();
+ return -EFAULT;
}
+ }
- return 0;
+ return 0;
}
static int disconnected_cb(int handle, void *data)
{
- printf("Disconnected\n");
- ecore_main_loop_quit();
- return 0;
+ printf("Disconnected\n");
+ ecore_main_loop_quit();
+ return 0;
}
static int connected_cb(int handle, void *data)
{
- struct packet *packet;
-
- printf("Connected\n");
+ struct packet *packet;
- packet = packet_create("liveinfo_hello", "d", 0.0f);
- if (!packet) {
- printf("Failed to build a packet for hello\n");
- com_core_packet_client_fini(s_info.fd);
- s_info.fd = -EINVAL;
- return -EFAULT;
- }
+ printf("Connected\n");
- s_info.fd = handle;
+ packet = packet_create("liveinfo_hello", "d", 0.0f);
+ if (!packet) {
+ printf("Failed to build a packet for hello\n");
+ com_core_packet_client_fini(s_info.fd);
+ s_info.fd = -EINVAL;
+ return -EFAULT;
+ }
- if (com_core_packet_async_send(s_info.fd, packet, 0.0f, ret_cb, NULL) < 0) {
- printf("Failed to send a packet hello\n");
- packet_destroy(packet);
- com_core_packet_client_fini(s_info.fd);
- s_info.fd = -EINVAL;
- return -EFAULT;
- }
+ s_info.fd = handle;
+ if (com_core_packet_async_send(s_info.fd, packet, 0.0f, ret_cb, NULL) < 0) {
+ printf("Failed to send a packet hello\n");
packet_destroy(packet);
- return 0;
+ com_core_packet_client_fini(s_info.fd);
+ s_info.fd = -EINVAL;
+ return -EFAULT;
+ }
+
+ packet_destroy(packet);
+ return 0;
}
int main(int argc, char *argv[])
{
- struct termios ttystate;
- static struct method s_table[] = {
- {
- .cmd = NULL,
- .handler = NULL,
- },
- };
- static struct option long_options[] = {
- { "batchmode", required_argument, 0, 'b' },
- { "help", no_argument, 0, 'h' },
- { "verbose", required_argument, 0, 'v' },
- { "execute", required_argument, 0, 'x' },
- { 0, 0, 0, 0 }
- };
- int option_index;
- int c;
-
- do {
- c = getopt_long(argc, argv, "b:hv:x:", long_options, &option_index);
- switch (c) {
- case 'b':
- if (!optarg || !*optarg) {
- printf("Invalid argument\n");
- help();
- return -EINVAL;
- }
-
- if (s_info.input_fd != STDIN_FILENO) {
- /* Close the previously, opened file */
- if (close(s_info.input_fd) < 0) {
- printf("close: %s\n", strerror(errno));
- }
- }
-
- s_info.input_fd = open(optarg, O_RDONLY);
- if (s_info.input_fd < 0) {
- printf("Unable to access %s (%s)\n", optarg, strerror(errno));
- return -EIO;
- }
- break;
- case 'h':
- help();
- return 0;
- case 'v':
- if (!optarg || !*optarg) {
- printf("Invalid argument\n");
- help();
- return -EINVAL;
- }
-
- s_info.verbose = !strcmp(optarg, "true");
- break;
- case 'x':
- if (!optarg || !*optarg) {
- printf("Invalid argument\n");
- help();
- return -EINVAL;
- }
- break;
- default:
- break;
+ struct termios ttystate;
+ static struct method s_table[] = {
+ {
+ .cmd = NULL,
+ .handler = NULL,
+ },
+ };
+ static struct option long_options[] = {
+ { "batchmode", required_argument, 0, 'b' },
+ { "help", no_argument, 0, 'h' },
+ { "verbose", required_argument, 0, 'v' },
+ { "execute", required_argument, 0, 'x' },
+ { 0, 0, 0, 0 }
+ };
+ int option_index;
+ int c;
+
+ do {
+ c = getopt_long(argc, argv, "b:hv:x:d", long_options, &option_index);
+ switch (c) {
+ case 'b':
+ if (!optarg || !*optarg) {
+ printf("Invalid argument\n");
+ help();
+ return -EINVAL;
}
- } while (c != -1);
- ecore_init();
+ if (s_info.input_fd != STDIN_FILENO) {
+ /* Close the previously, opened file */
+ if (close(s_info.input_fd) < 0) {
+ printf("close: %s\n", strerror(errno));
+ }
+ }
+
+ s_info.input_fd = open(optarg, O_RDONLY);
+ if (s_info.input_fd < 0) {
+ printf("Unable to access %s (%s)\n", optarg, strerror(errno));
+ return -EIO;
+ }
+ break;
+ case 'h':
+ help();
+ return 0;
+ case 'v':
+ if (!optarg || !*optarg) {
+ printf("Invalid argument\n");
+ help();
+ return -EINVAL;
+ }
+
+ s_info.verbose = !strcmp(optarg, "true");
+ break;
+ case 'x':
+ if (!optarg || !*optarg) {
+ printf("Invalid argument\n");
+ help();
+ return -EINVAL;
+ }
+ break;
+ case 'd':
+ /** Dump all buffer to a files */
+ s_info.dump = 1;
+ break;
+ default:
+ break;
+ }
+ } while (c != -1);
+
+ ecore_init();
#if (GLIB_MAJOR_VERSION <= 2 && GLIB_MINOR_VERSION < 36)
- g_type_init();
+ g_type_init();
#endif
- com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL);
- com_core_add_event_callback(CONNECTOR_CONNECTED, connected_cb, NULL);
- livebox_service_init();
+ com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL);
+ com_core_add_event_callback(CONNECTOR_CONNECTED, connected_cb, NULL);
+ dynamicbox_service_init();
- s_info.fd = com_core_packet_client_init(SOCKET_FILE, 0, s_table);
- if (s_info.fd < 0) {
- printf("Failed to make a connection\n");
- return -EIO;
- }
+ s_info.fd = com_core_packet_client_init(SOCKET_FILE, 0, s_table);
+ if (s_info.fd < 0) {
+ printf("Failed to make a connection\n");
+ return -EIO;
+ }
- if (s_info.input_fd == STDIN_FILENO) {
- printf("Type your command on below empty line\n");
+ if (s_info.input_fd == STDIN_FILENO) {
+ printf("Type your command on below empty line\n");
- if (tcgetattr(s_info.input_fd, &ttystate) < 0) {
- printf("Error: %s\n", strerror(errno));
- } else {
- ttystate.c_lflag &= ~(ICANON | ECHO);
- ttystate.c_cc[VMIN] = 1;
-
- if (tcsetattr(s_info.input_fd, TCSANOW, &ttystate) < 0) {
- printf("Error: %s\n", strerror(errno));
- }
- }
+ if (tcgetattr(s_info.input_fd, &ttystate) < 0) {
+ printf("Error: %s\n", strerror(errno));
} else {
- printf("Batch mode enabled\n");
- }
+ ttystate.c_lflag &= ~(ICANON | ECHO);
+ ttystate.c_cc[VMIN] = 1;
- if (setvbuf(stdout, (char *)NULL, _IONBF, 0) != 0) {
+ if (tcsetattr(s_info.input_fd, TCSANOW, &ttystate) < 0) {
printf("Error: %s\n", strerror(errno));
+ }
}
+ } else {
+ printf("Batch mode enabled\n");
+ }
- init_directory();
+ if (setvbuf(stdout, (char *)NULL, _IONBF, 0) != 0) {
+ printf("Error: %s\n", strerror(errno));
+ }
- ecore_main_loop_begin();
+ init_directory();
- fini_directory();
- livebox_service_fini();
+ ecore_main_loop_begin();
- if (s_info.fd > 0) {
- com_core_packet_client_fini(s_info.fd);
- s_info.fd = -EINVAL;
- }
+ fini_directory();
+ dynamicbox_service_fini();
- if (s_info.fd_handler) {
- ecore_main_fd_handler_del(s_info.fd_handler);
- s_info.fd_handler = NULL;
- }
+ if (s_info.fd > 0) {
+ com_core_packet_client_fini(s_info.fd);
+ s_info.fd = -EINVAL;
+ }
- if (s_info.input_fd == STDIN_FILENO) {
- ttystate.c_lflag |= ICANON | ECHO;
- if (tcsetattr(s_info.input_fd, TCSANOW, &ttystate) < 0) {
- printf("Error: %s\n", strerror(errno));
- }
- } else {
- if (close(s_info.input_fd) < 0) {
- printf("close: %s\n", strerror(errno));
- }
- }
+ if (s_info.fd_handler) {
+ ecore_main_fd_handler_del(s_info.fd_handler);
+ s_info.fd_handler = NULL;
+ }
- if (s_info.fifo_handle > 0) {
- if (close(s_info.fifo_handle) < 0) {
- printf("close: %s\n", strerror(errno));
- }
- s_info.fifo_handle = -EINVAL;
+ if (s_info.input_fd == STDIN_FILENO) {
+ ttystate.c_lflag |= ICANON | ECHO;
+ if (tcsetattr(s_info.input_fd, TCSANOW, &ttystate) < 0) {
+ printf("Error: %s\n", strerror(errno));
}
+ } else {
+ if (close(s_info.input_fd) < 0) {
+ printf("close: %s\n", strerror(errno));
+ }
+ }
- if (s_info.in_handler) {
- ecore_main_fd_handler_del(s_info.in_handler);
- s_info.in_handler = NULL;
+ if (s_info.fifo_handle > 0) {
+ if (close(s_info.fifo_handle) < 0) {
+ printf("close: %s\n", strerror(errno));
}
+ s_info.fifo_handle = -EINVAL;
+ }
- ecore_shutdown();
- putc((int)'\n', stdout);
- return 0;
+ if (s_info.in_handler) {
+ ecore_main_fd_handler_del(s_info.in_handler);
+ s_info.in_handler = NULL;
+ }
+
+ ecore_shutdown();
+ putc((int)'\n', stdout);
+ return 0;
}
/* End of a file */
#include "node.h"
struct node {
- char *name;
- enum node_type type;
+ char *name;
+ enum node_type type;
- void *data;
+ void *data;
- struct node *parent;
- unsigned char mode;
- int age;
+ struct node *parent;
+ unsigned char mode;
+ int age;
- struct {
- struct node *next;
- struct node *prev;
- } sibling;
+ struct {
+ struct node *next;
+ struct node *prev;
+ } sibling;
- struct node *child;
+ struct node *child;
};
int errno; /* External symbol */
char *node_to_abspath(const struct node *node)
{
- char *path;
- char *ptr;
- const struct node *tmp;
- int len = 0;
-
+ char *path;
+ char *ptr;
+ const struct node *tmp;
+ int len = 0;
+
+ tmp = node;
+ while (tmp && node_name(tmp)) {
+ len += strlen(node_name(tmp)) + 1; /* trail '/' */
+ tmp = node_parent(tmp);
+ }
+
+ path = malloc(len + 3); /* '/' and '\0' */
+ if (!path) {
+ return NULL;
+ }
+
+ if (!len) {
+ path[0] = '/';
+ path[1] = '\0';
+ } else {
+ ptr = path + len + 1;
+ *ptr = '\0';
+ ptr--;
+ *ptr = '/';
tmp = node;
while (tmp && node_name(tmp)) {
- len += strlen(node_name(tmp)) + 1; /* trail '/' */
- tmp = node_parent(tmp);
- }
-
- path = malloc(len + 3); /* '/' and '\0' */
- if (!path) {
- return NULL;
+ ptr -= (strlen(node_name(tmp)) + 1);
+ *ptr = '/';
+ strncpy(ptr + 1, node_name(tmp), strlen(node_name(tmp)));
+ tmp = node_parent(tmp);
}
+ }
- if (!len) {
- path[0] = '/';
- path[1] = '\0';
- } else {
- ptr = path + len + 1;
- *ptr = '\0';
- ptr--;
- *ptr = '/';
- tmp = node;
- while (tmp && node_name(tmp)) {
- ptr -= (strlen(node_name(tmp)) + 1);
- *ptr = '/';
- strncpy(ptr + 1, node_name(tmp), strlen(node_name(tmp)));
- tmp = node_parent(tmp);
- }
- }
-
- return path;
+ return path;
}
static inline int next_state(int from, char ch)
{
- switch (ch)
- {
+ switch (ch)
+ {
case '\0':
case '/':
- return 1;
+ return 1;
case '.':
- if (from == 1) {
- return 2;
- }
- if (from == 2) {
- return 3;
- }
- }
-
- return 4;
+ if (from == 1) {
+ return 2;
+ }
+ if (from == 2) {
+ return 3;
+ }
+ }
+
+ return 4;
}
static inline void abspath(const char* pBuffer, char* pRet)
{
- int idx=0;
- int state = 1;
- int from;
- int src_idx = 0;
- int src_len = strlen(pBuffer);
- pRet[idx] = '/';
- idx ++;
-
- while (src_idx <= src_len) {
- from = state;
- state = next_state(from, pBuffer[src_idx]);
-
- switch (from) {
- case 1:
- if (state != 1) {
- pRet[idx] = pBuffer[src_idx];
- idx++;
- }
- break;
- case 2:
- if (state == 1) {
- if (idx > 1) {
- idx--;
- }
- } else {
- pRet[idx] = pBuffer[src_idx];
- idx++;
- }
- break;
- case 3:
- // Only can go to the 1 or 4
- if (state == 1) {
- idx -= 2;
- if (idx < 1) {
- idx = 1;
- }
-
- while (idx > 1 && pRet[idx] != '/') {
- idx--; /* Remove .. */
- }
- if (idx > 1 && pRet[idx] == '/') {
- idx--;
- }
- while (idx > 1 && pRet[idx] != '/') {
- idx--; /* Remove parent folder */
- }
- }
- case 4:
- pRet[idx] = pBuffer[src_idx];
- idx++;
- break;
+ int idx=0;
+ int state = 1;
+ int from;
+ int src_idx = 0;
+ int src_len = strlen(pBuffer);
+ pRet[idx] = '/';
+ idx ++;
+
+ while (src_idx <= src_len) {
+ from = state;
+ state = next_state(from, pBuffer[src_idx]);
+
+ switch (from) {
+ case 1:
+ if (state != 1) {
+ pRet[idx] = pBuffer[src_idx];
+ idx++;
}
-
- pRet[idx] = '\0';
- src_idx++;
+ break;
+ case 2:
+ if (state == 1) {
+ if (idx > 1) {
+ idx--;
+ }
+ } else {
+ pRet[idx] = pBuffer[src_idx];
+ idx++;
+ }
+ break;
+ case 3:
+ // Only can go to the 1 or 4
+ if (state == 1) {
+ idx -= 2;
+ if (idx < 1) {
+ idx = 1;
+ }
+
+ while (idx > 1 && pRet[idx] != '/') {
+ idx--; /* Remove .. */
+ }
+ if (idx > 1 && pRet[idx] == '/') {
+ idx--;
+ }
+ while (idx > 1 && pRet[idx] != '/') {
+ idx--; /* Remove parent folder */
+ }
+ }
+ case 4:
+ pRet[idx] = pBuffer[src_idx];
+ idx++;
+ break;
}
+
+ pRet[idx] = '\0';
+ src_idx++;
+ }
}
struct node *node_find(const struct node *node, const char *path)
{
- int len = 0;
- char *ptr;
- char *buffer;
-
- if (*path != '/') {
- while (node->parent && path[0] == '.' && path[1] == '.') {
- if (path[2] != '/' && path[2] != '\0') {
- break;
- }
-
- path += 2;
- path += (path[2] == '/');
- node = node->parent;
- }
+ int len = 0;
+ char *ptr;
+ char *buffer;
+
+ if (*path != '/') {
+ while (node->parent && path[0] == '.' && path[1] == '.') {
+ if (path[2] != '/' && path[2] != '\0') {
+ break;
+ }
+
+ path += 2;
+ path += (path[2] == '/');
+ node = node->parent;
}
+ }
- buffer = malloc(strlen(path) + 3); /* add 2 more bytes */
- if (!buffer) {
- printf("Error: %s\n", strerror(errno));
- return NULL;
- }
+ buffer = malloc(strlen(path) + 3); /* add 2 more bytes */
+ if (!buffer) {
+ printf("Error: %s\n", strerror(errno));
+ return NULL;
+ }
- abspath(path, buffer);
+ abspath(path, buffer);
- ptr = buffer;
- do {
- ptr += (*ptr == '/');
- for (len = 0; ptr[len] && ptr[len] != '/'; len++);
- if (!len) {
- break;
- }
+ ptr = buffer;
+ do {
+ ptr += (*ptr == '/');
+ for (len = 0; ptr[len] && ptr[len] != '/'; len++);
+ if (!len) {
+ break;
+ }
- if (!strncmp("..", ptr, len)) {
- ptr += len;
- node = node->parent ? node->parent : node;
- continue;
- }
+ if (!strncmp("..", ptr, len)) {
+ ptr += len;
+ node = node->parent ? node->parent : node;
+ continue;
+ }
- if (!strncmp(".", ptr, len)) {
- ptr += len;
- continue;
- }
+ if (!strncmp(".", ptr, len)) {
+ ptr += len;
+ continue;
+ }
- node = node->child;
- if (!node) {
- break;
- }
+ node = node->child;
+ if (!node) {
+ break;
+ }
- while (node) {
- if (!strncmp(node->name, ptr, len) && node->name[len] == '\0') {
- ptr += len;
- break;
- }
+ while (node) {
+ if (!strncmp(node->name, ptr, len) && node->name[len] == '\0') {
+ ptr += len;
+ break;
+ }
- node = node->sibling.next;
- }
- } while (*ptr && node);
+ node = node->sibling.next;
+ }
+ } while (*ptr && node);
- free(buffer);
- return (struct node *)node;
+ free(buffer);
+ return (struct node *)node;
}
-struct node *node_create(struct node *parent, const char *name, enum node_type type)
+struct node *node_create(struct node *parent, const char *name, enum node_type type, int mode)
{
- struct node *node;
-
- node = malloc(sizeof(*node));
- if (!node) {
- printf("Error: %s\n", strerror(errno));
- return NULL;
+ struct node *node;
+
+ node = malloc(sizeof(*node));
+ if (!node) {
+ printf("Error: %s\n", strerror(errno));
+ return NULL;
+ }
+
+ node->parent = parent;
+
+ if (name) {
+ node->name = strdup(name);
+ if (!node->name) {
+ printf("Error: %s\n", strerror(errno));
+ free(node);
+ return NULL;
}
+ } else {
+ node->name = NULL;
+ }
- node->parent = parent;
-
- if (name) {
- node->name = strdup(name);
- if (!node->name) {
- printf("Error: %s\n", strerror(errno));
- free(node);
- return NULL;
- }
- } else {
- node->name = NULL;
- }
+ node->type = type;
- node->type = type;
+ node->sibling.next = NULL;
+ node->sibling.prev = NULL;
- node->sibling.next = NULL;
- node->sibling.prev = NULL;
+ node->child = NULL;
+ node->data = NULL;
- node->child = NULL;
- node->data = NULL;
+ if (parent) {
+ if (parent->child) {
+ struct node *tmp;
+ tmp = parent->child;
+ while (tmp->sibling.next) {
+ tmp = tmp->sibling.next;
+ }
- if (parent) {
- if (parent->child) {
- struct node *tmp;
- tmp = parent->child;
- while (tmp->sibling.next) {
- tmp = tmp->sibling.next;
- }
-
- tmp->sibling.next = node;
- node->sibling.prev = tmp;
- } else {
- parent->child = node;
- }
+ tmp->sibling.next = node;
+ node->sibling.prev = tmp;
+ } else {
+ parent->child = node;
}
- return node;
+ }
+
+ node->mode = mode;
+ return node;
}
void *node_destroy(struct node *node)
{
- void *data;
+ void *data;
- data = node->data;
- free(node->name);
- free(node);
+ data = node->data;
+ free(node->name);
+ free(node);
- return data;
+ return data;
}
void node_delete(struct node *node, void (del_cb)(struct node *node))
{
- struct node *tmp;
- struct node *next;
- struct node *parent;
+ struct node *tmp;
+ struct node *next;
+ struct node *parent;
- if (node->sibling.prev) {
- node->sibling.prev->sibling.next = node->sibling.next;
- }
+ if (node->sibling.prev) {
+ node->sibling.prev->sibling.next = node->sibling.next;
+ }
- if (node->sibling.next) {
- node->sibling.next->sibling.prev = node->sibling.prev;
- }
-
- /* Isolate the node */
- node->sibling.prev = NULL;
- node->sibling.next = NULL;
+ if (node->sibling.next) {
+ node->sibling.next->sibling.prev = node->sibling.prev;
+ }
- if (node->parent) {
- if (node->parent->child == node) {
- node->parent->child = NULL;
- }
+ /* Isolate the node */
+ node->sibling.prev = NULL;
+ node->sibling.next = NULL;
- node->parent = NULL;
+ if (node->parent) {
+ if (node->parent->child == node) {
+ node->parent->child = NULL;
}
- tmp = node;
- while (tmp) {
- /* Reach to the leaf node */
- while (tmp->child) {
- tmp = tmp->child;
- }
+ node->parent = NULL;
+ }
- parent = tmp->parent;
- next = tmp->sibling.next;
+ tmp = node;
+ while (tmp) {
+ /* Reach to the leaf node */
+ while (tmp->child) {
+ tmp = tmp->child;
+ }
- if (parent && parent->child == tmp) {
- parent->child = NULL;
- }
+ parent = tmp->parent;
+ next = tmp->sibling.next;
- if (del_cb) {
- del_cb(tmp);
- }
+ if (parent && parent->child == tmp) {
+ parent->child = NULL;
+ }
- node_destroy(tmp);
+ if (del_cb) {
+ del_cb(tmp);
+ }
- if (next) {
- tmp = next;
- } else if (parent) {
- tmp = parent;
- } else {
- tmp = NULL;
- }
+ node_destroy(tmp);
+
+ if (next) {
+ tmp = next;
+ } else if (parent) {
+ tmp = parent;
+ } else {
+ tmp = NULL;
}
+ }
}
struct node * const node_next_sibling(const struct node *node)
{
- return node->sibling.next;
+ return node->sibling.next;
}
struct node * const node_prev_sibling(const struct node *node)
{
- return node->sibling.prev;
+ return node->sibling.prev;
}
void node_set_mode(struct node *node, int mode)
{
- node->mode = mode;
+ node->mode = mode;
}
void node_set_data(struct node *node, void *data)
{
- node->data = data;
+ node->data = data;
}
void node_set_type(struct node *node, enum node_type type)
{
- node->type = type;
+ node->type = type;
}
struct node * const node_child(const struct node *node)
{
- return node->child;
+ return node->child;
}
struct node * const node_parent(const struct node *node)
{
- return node->parent;
+ return node->parent;
}
const int const node_mode(const struct node *node)
{
- return node->mode;
+ return node->mode;
}
void * const node_data(const struct node *node)
{
- return node->data;
+ return node->data;
}
const enum node_type const node_type(const struct node *node)
{
- return node->type;
+ return node->type;
}
const char * const node_name(const struct node *node)
{
- return node->name;
+ return node->name;
}
void node_set_age(struct node *node, int age)
{
- node->age = age;
+ node->age = age;
}
int node_age(struct node *node)
{
- return node->age;
+ return node->age;
}
/* End of a file */