From ed5fbbe34fae30774d09b82da2bcd4c3df7dc972 Mon Sep 17 00:00:00 2001 From: Kyuho Jo Date: Wed, 29 Apr 2015 09:59:46 +0900 Subject: [PATCH 2/2] Merge from tizen 2.3.1 Change-Id: Ic170b7e62bd1be1b556969a3309f3f5404600a9b Signed-off-by: Kyuho Jo --- CMakeLists.txt | 226 + LICENSE | 206 + data-provider-master.rule | 33 + data/CMakeLists.txt | 4 + data/data-provider-master | 98 + data/data-provider-master.service | 34 + data/device/abi.ini | 14 + data/device/wayland.mobile.conf.ini | 38 + data/device/wayland.mobile.resolution.ini | 13 + data/device/wayland.wearable.conf.ini | 38 + data/device/wayland.wearable.resolution.ini | 14 + data/device/x11.mobile.320x480.conf.ini | 38 + data/device/x11.mobile.320x480.resolution.ini | 14 + data/device/x11.mobile.360x360.conf.ini | 0 data/device/x11.mobile.360x360.resolution.ini | 0 data/device/x11.mobile.360x480.conf.ini | 0 data/device/x11.mobile.360x480.resolution.ini | 0 data/device/x11.mobile.480x800.conf.ini | 45 + data/device/x11.mobile.480x800.resolution.ini | 14 + data/device/x11.mobile.conf.ini | 40 + data/device/x11.mobile.resolution.ini | 13 + data/device/x11.wearable.360x360.conf.ini | 39 + data/device/x11.wearable.360x360.resolution.ini | 14 + data/device/x11.wearable.360x480.conf.ini | 38 + data/device/x11.wearable.360x480.resolution.ini | 14 + data/device/x11.wearable.conf.ini | 40 + data/device/x11.wearable.resolution.ini | 14 + data/dump_widget.sh | 8 + data/emulator/abi.ini | 14 + data/emulator/wayland.mobile.conf.ini | 38 + data/emulator/wayland.mobile.resolution.ini | 13 + data/emulator/wayland.wearable.conf.ini | 38 + data/emulator/wayland.wearable.resolution.ini | 14 + data/emulator/x11.mobile.320x480.conf.ini | 38 + data/emulator/x11.mobile.320x480.resolution.ini | 14 + data/emulator/x11.mobile.360x360.conf.ini | 0 data/emulator/x11.mobile.360x360.resolution.ini | 0 data/emulator/x11.mobile.360x480.conf.ini | 0 data/emulator/x11.mobile.360x480.resolution.ini | 0 data/emulator/x11.mobile.480x800.conf.ini | 45 + data/emulator/x11.mobile.480x800.resolution.ini | 14 + data/emulator/x11.mobile.conf.ini | 40 + data/emulator/x11.mobile.resolution.ini | 13 + data/emulator/x11.wearable.360x360.conf.ini | 39 + data/emulator/x11.wearable.360x360.resolution.ini | 14 + data/emulator/x11.wearable.360x480.conf.ini | 38 + data/emulator/x11.wearable.360x480.resolution.ini | 14 + data/emulator/x11.wearable.conf.ini | 40 + data/emulator/x11.wearable.resolution.ini | 14 + include/badge_service.h | 20 + include/buffer_handler.h | 348 + include/client_life.h | 115 + include/client_rpc.h | 27 + include/conf.h | 38 + include/critical_log.h | 23 + include/dead_monitor.h | 22 + include/debug.h | 72 + include/event.h | 66 + include/fault_manager.h | 25 + include/file_service.h | 20 + include/group.h | 65 + include/instance.h | 277 + include/io.h | 25 + include/lite-errno.h | 64 + include/main.h | 16 + include/monitor.h | 35 + include/notification_service.h | 20 + include/package.h | 125 + include/parser.h | 45 + include/pkgmgr.h | 40 + include/rpc_to_slave.h | 29 + include/script_handler.h | 39 + include/server.h | 20 + include/service_common.h | 63 + include/setting.h | 31 + include/shortcut_service.h | 20 + include/slave_life.h | 221 + include/slave_rpc.h | 32 + include/util.h | 87 + include/utility_service.h | 21 + include/widget-mgr.h | 35 + include/xmonitor.h | 34 + packaging/data-provider-master.changes | 8 + packaging/data-provider-master.manifest | 87 + packaging/data-provider-master.spec | 203 + pkgmgr_widget/CMakeLists.txt | 27 + pkgmgr_widget/common/CMakeLists.txt | 15 + pkgmgr_widget/common/include/common.h | 59 + pkgmgr_widget/common/include/dlist.h | 43 + pkgmgr_widget/common/src/common.c | 3380 +++++++ pkgmgr_widget/common/src/dlist.c | 189 + pkgmgr_widget/watch/CMakeLists.txt | 15 + pkgmgr_widget/watch/src/service_watchapp.c | 185 + pkgmgr_widget/watch/watchapp.xml | 10 + pkgmgr_widget/watch/watchapp.xsd | 24 + pkgmgr_widget/widget.xml | 81 + pkgmgr_widget/widget.xsd | 88 + pkgmgr_widget/widget/CMakeLists.txt | 15 + pkgmgr_widget/widget/src/service_widget.c | 183 + res/CMakeLists.txt | 1 + res/edje/CMakeLists.txt | 1 + res/edje/master.edc | 112 + src/badge_service.c | 575 ++ src/buffer_handler.c | 1750 ++++ src/buffer_handler_wayland.c | 865 ++ src/client_life.c | 1026 +++ src/client_rpc.c | 286 + src/conf.c | 8 + src/critical_log.c | 180 + src/dead_monitor.c | 175 + src/event.c | 1108 +++ src/fault_manager.c | 377 + src/file_service.c | 720 ++ src/group.c | 889 ++ src/instance.c | 3921 +++++++++ src/io.c | 727 ++ src/main.c | 458 + src/monitor.c | 200 + src/notification_service.c | 792 ++ src/package.c | 1772 ++++ src/parser.c | 892 ++ src/pkgmgr.c | 626 ++ src/script_handler.c | 1513 ++++ src/server.c | 9796 +++++++++++++++++++++ src/service_common.c | 1193 +++ src/setting.c | 333 + src/shortcut_service.c | 238 + src/slave_life.c | 2000 +++++ src/slave_rpc.c | 712 ++ src/util.c | 584 ++ src/util_wayland.c | 42 + src/util_x11.c | 41 + src/utility_service.c | 432 + src/widget-mgr.c | 214 + src/xmonitor.c | 491 ++ src/xmonitor_wayland.c | 251 + widget-mgr/CMakeLists.txt | 39 + widget-mgr/include/node.h | 41 + widget-mgr/include/widget-info.h | 16 + widget-mgr/src/node.c | 391 + widget-mgr/src/widget-mgr.c | 2191 +++++ 141 files changed, 46200 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100644 data-provider-master.rule create mode 100755 data/CMakeLists.txt create mode 100755 data/data-provider-master create mode 100644 data/data-provider-master.service create mode 100755 data/device/abi.ini create mode 100755 data/device/wayland.mobile.conf.ini create mode 100644 data/device/wayland.mobile.resolution.ini create mode 100755 data/device/wayland.wearable.conf.ini create mode 100644 data/device/wayland.wearable.resolution.ini create mode 100755 data/device/x11.mobile.320x480.conf.ini create mode 100644 data/device/x11.mobile.320x480.resolution.ini create mode 100644 data/device/x11.mobile.360x360.conf.ini create mode 100644 data/device/x11.mobile.360x360.resolution.ini create mode 100644 data/device/x11.mobile.360x480.conf.ini create mode 100644 data/device/x11.mobile.360x480.resolution.ini create mode 100755 data/device/x11.mobile.480x800.conf.ini create mode 100644 data/device/x11.mobile.480x800.resolution.ini create mode 100755 data/device/x11.mobile.conf.ini create mode 100644 data/device/x11.mobile.resolution.ini create mode 100755 data/device/x11.wearable.360x360.conf.ini create mode 100644 data/device/x11.wearable.360x360.resolution.ini create mode 100755 data/device/x11.wearable.360x480.conf.ini create mode 100644 data/device/x11.wearable.360x480.resolution.ini create mode 100755 data/device/x11.wearable.conf.ini create mode 100644 data/device/x11.wearable.resolution.ini create mode 100755 data/dump_widget.sh create mode 100755 data/emulator/abi.ini create mode 100755 data/emulator/wayland.mobile.conf.ini create mode 100644 data/emulator/wayland.mobile.resolution.ini create mode 100755 data/emulator/wayland.wearable.conf.ini create mode 100644 data/emulator/wayland.wearable.resolution.ini create mode 100755 data/emulator/x11.mobile.320x480.conf.ini create mode 100644 data/emulator/x11.mobile.320x480.resolution.ini create mode 100644 data/emulator/x11.mobile.360x360.conf.ini create mode 100644 data/emulator/x11.mobile.360x360.resolution.ini create mode 100644 data/emulator/x11.mobile.360x480.conf.ini create mode 100644 data/emulator/x11.mobile.360x480.resolution.ini create mode 100755 data/emulator/x11.mobile.480x800.conf.ini create mode 100644 data/emulator/x11.mobile.480x800.resolution.ini create mode 100755 data/emulator/x11.mobile.conf.ini create mode 100644 data/emulator/x11.mobile.resolution.ini create mode 100755 data/emulator/x11.wearable.360x360.conf.ini create mode 100644 data/emulator/x11.wearable.360x360.resolution.ini create mode 100755 data/emulator/x11.wearable.360x480.conf.ini create mode 100644 data/emulator/x11.wearable.360x480.resolution.ini create mode 100755 data/emulator/x11.wearable.conf.ini create mode 100644 data/emulator/x11.wearable.resolution.ini create mode 100644 include/badge_service.h create mode 100644 include/buffer_handler.h create mode 100644 include/client_life.h create mode 100644 include/client_rpc.h create mode 100644 include/conf.h create mode 100644 include/critical_log.h create mode 100644 include/dead_monitor.h create mode 100644 include/debug.h create mode 100644 include/event.h create mode 100644 include/fault_manager.h create mode 100644 include/file_service.h create mode 100644 include/group.h create mode 100644 include/instance.h create mode 100644 include/io.h create mode 100644 include/lite-errno.h create mode 100644 include/main.h create mode 100644 include/monitor.h create mode 100644 include/notification_service.h create mode 100644 include/package.h create mode 100644 include/parser.h create mode 100644 include/pkgmgr.h create mode 100644 include/rpc_to_slave.h create mode 100644 include/script_handler.h create mode 100644 include/server.h create mode 100644 include/service_common.h create mode 100644 include/setting.h create mode 100644 include/shortcut_service.h create mode 100644 include/slave_life.h create mode 100644 include/slave_rpc.h create mode 100644 include/util.h create mode 100644 include/utility_service.h create mode 100644 include/widget-mgr.h create mode 100644 include/xmonitor.h create mode 100644 packaging/data-provider-master.changes create mode 100644 packaging/data-provider-master.manifest create mode 100644 packaging/data-provider-master.spec create mode 100644 pkgmgr_widget/CMakeLists.txt create mode 100644 pkgmgr_widget/common/CMakeLists.txt create mode 100644 pkgmgr_widget/common/include/common.h create mode 100644 pkgmgr_widget/common/include/dlist.h create mode 100644 pkgmgr_widget/common/src/common.c create mode 100644 pkgmgr_widget/common/src/dlist.c create mode 100644 pkgmgr_widget/watch/CMakeLists.txt create mode 100644 pkgmgr_widget/watch/src/service_watchapp.c create mode 100644 pkgmgr_widget/watch/watchapp.xml create mode 100644 pkgmgr_widget/watch/watchapp.xsd create mode 100644 pkgmgr_widget/widget.xml create mode 100644 pkgmgr_widget/widget.xsd create mode 100644 pkgmgr_widget/widget/CMakeLists.txt create mode 100644 pkgmgr_widget/widget/src/service_widget.c create mode 100644 res/CMakeLists.txt create mode 100644 res/edje/CMakeLists.txt create mode 100644 res/edje/master.edc create mode 100644 src/badge_service.c create mode 100644 src/buffer_handler.c create mode 100644 src/buffer_handler_wayland.c create mode 100644 src/client_life.c create mode 100644 src/client_rpc.c create mode 100644 src/conf.c create mode 100644 src/critical_log.c create mode 100644 src/dead_monitor.c create mode 100644 src/event.c create mode 100644 src/fault_manager.c create mode 100644 src/file_service.c create mode 100644 src/group.c create mode 100644 src/instance.c create mode 100644 src/io.c create mode 100644 src/main.c create mode 100644 src/monitor.c create mode 100644 src/notification_service.c create mode 100644 src/package.c create mode 100644 src/parser.c create mode 100644 src/pkgmgr.c create mode 100644 src/script_handler.c create mode 100644 src/server.c create mode 100644 src/service_common.c create mode 100644 src/setting.c create mode 100644 src/shortcut_service.c create mode 100644 src/slave_life.c create mode 100644 src/slave_rpc.c create mode 100644 src/util.c create mode 100644 src/util_wayland.c create mode 100644 src/util_x11.c create mode 100644 src/utility_service.c create mode 100644 src/widget-mgr.c create mode 100644 src/xmonitor.c create mode 100644 src/xmonitor_wayland.c create mode 100644 widget-mgr/CMakeLists.txt create mode 100644 widget-mgr/include/node.h create mode 100644 widget-mgr/include/widget-info.h create mode 100644 widget-mgr/src/node.c create mode 100644 widget-mgr/src/widget-mgr.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a9f8447 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,226 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(${NAME} C) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkg REQUIRED + dlog + aul + vconf + sqlite3 + db-util + glib-2.0 + gio-2.0 + bundle + ecore + eina + com-core + pkgmgr + notification + notification-service + badge + badge-service + libsmack + shortcut + pkgmgr-info + libsystemd-daemon +) + +IF (LIVEBOX) +pkg_check_modules(pkg_widget REQUIRED + widget_service +) +ENDIF (LIVEBOX) + +IF (X11_SUPPORT) +pkg_check_modules(pkg_extra REQUIRED + ecore-x + x11 + libdri2 + libdrm + libtbm + xfixes + dri2proto + xext + xdamage +) +ENDIF (X11_SUPPORT) + +IF (WAYLAND_SUPPORT) +pkg_check_modules(pkg_extra REQUIRED + ecore-wayland +) +ENDIF (WAYLAND_SUPPORT) + +SET(PACKAGE "${PROJECT_NAME}") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Winline -Werror -fno-builtin-malloc -fno-omit-frame-pointer -g -fPIE") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +#ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DPATH_MAX=256") +ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") +ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"") + +ADD_DEFINITIONS("-DINFO_SOCKET=\"/opt/usr/share/live_magazine/.live.socket\"") +ADD_DEFINITIONS("-DCLIENT_SOCKET=\"/opt/usr/share/live_magazine/.client.socket\"") +ADD_DEFINITIONS("-DSLAVE_SOCKET=\"/opt/usr/share/live_magazine/.slave.socket\"") +ADD_DEFINITIONS("-DSERVICE_SOCKET=\"/opt/usr/share/live_magazine/.service.socket\"") +ADD_DEFINITIONS("-DCATEGORY_WATCH_CLOCK=\"http://tizen.org/category/wearable_clock\"") + +ADD_DEFINITIONS("-DCLIENT_PORT=\"8208\"") + +ADD_DEFINITIONS("-DBADGE_SOCKET=\"/tmp/.badge.service\"") +ADD_DEFINITIONS("-DSHORTCUT_SOCKET=\"/tmp/.shortcut.service\"") +ADD_DEFINITIONS("-DNOTIFICATION_SOCKET=\"/tmp/.notification.service\"") +ADD_DEFINITIONS("-DUTILITY_SOCKET=\"/tmp/.utility.service\"") + +ADD_DEFINITIONS("-DUTILITY_SMACK_LABEL=\"${PROJECT_NAME}::utility\"") +ADD_DEFINITIONS("-DSHORTCUT_SMACK_LABEL=\"${PROJECT_NAME}::shortcut\"") +ADD_DEFINITIONS("-DNOTIFICATION_SMACK_LABEL=\"${PROJECT_NAME}::notification\"") +ADD_DEFINITIONS("-DBADGE_SMACK_LABEL=\"${PROJECT_NAME}::badge\"") +ADD_DEFINITIONS("-DDATA_SHARE_LABEL=\"${PROJECT_NAME}::share\"") +ADD_DEFINITIONS("-DDEFAULT_SMACK_LABEL=\"${PROJECT_NAME}\"") + +ADD_DEFINITIONS("-DDEFAULT_MASTER_CONF=\"/usr/share/${PROJECT_NAME}/conf.ini\"") + +ADD_DEFINITIONS("-DNDEBUG") + +ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET") + +IF (MOBILE) + ADD_DEFINITIONS("-DMOBILE") +ELSEIF (WEARABLE) + ADD_DEFINITIONS("-DWEARABLE") +ENDIF (MOBILE) + +SET(BUILD_SOURCE + src/main.c + src/util.c + src/setting.c + src/critical_log.c + src/shortcut_service.c + src/badge_service.c + src/notification_service.c + src/service_common.c +) + +IF (LIVEBOX) + ADD_DEFINITIONS("-DHAVE_LIVEBOX") + SET(BUILD_SOURCE + ${BUILD_SOURCE} + src/utility_service.c + src/dead_monitor.c + src/package.c + src/instance.c + src/server.c + src/fault_manager.c + src/parser.c + src/io.c + src/slave_life.c + src/slave_rpc.c + src/client_life.c + src/client_rpc.c + src/group.c + src/script_handler.c + src/widget-mgr.c + src/pkgmgr.c + src/event.c + src/file_service.c + src/conf.c + src/monitor.c + ) + + IF (WAYLAND_SUPPORT) + ADD_DEFINITIONS("-DHAVE_WAYLAND") + SET(BUILD_SOURCE + ${BUILD_SOURCE} + src/xmonitor_wayland.c + src/buffer_handler_wayland.c + src/util_wayland.c + ) + ENDIF (WAYLAND_SUPPORT) + + IF (X11_SUPPORT) + ADD_DEFINITIONS("-DHAVE_X11") + SET(BUILD_SOURCE + ${BUILD_SOURCE} + src/xmonitor.c + src/buffer_handler.c + src/util_x11.c + ) + ENDIF (X11_SUPPORT) +ENDIF (LIVEBOX) + +IF (WAYLAND_SUPPORT) + ADD_DEFINITIONS("-DHAVE_WAYLAND") + SET(BUILD_SOURCE + ${BUILD_SOURCE} + src/util_wayland.c + ) +ENDIF (WAYLAND_SUPPORT) + +IF (X11_SUPPORT) + ADD_DEFINITIONS("-DHAVE_X11") + SET(BUILD_SOURCE + ${BUILD_SOURCE} + src/util_x11.c + ) +ENDIF (X11_SUPPORT) + +#ADD_DEFINITIONS("-D_APPLY_SCRIPT_ASYNC_UPDATE") +#ADD_DEFINITIONS("-DFLOG") +ADD_DEFINITIONS(${pkg_CFLAGS}) +ADD_DEFINITIONS(${pkg_LDFLAGS}) +ADD_DEFINITIONS(${pkg_extra_CFLAGS}) +ADD_DEFINITIONS(${pkg_extra_LDFLAGS}) +ADD_DEFINITIONS(${pkg_widget_CFLAGS}) +ADD_DEFINITIONS(${pkg_widget_LDFLAGS}) + +ADD_EXECUTABLE(${PROJECT_NAME} ${BUILD_SOURCE}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} ${pkg_extra_LDFLAGS} ${pkg_widget_LDFLAGS} "-ldl -lrt -pie") + +IF (LIVEBOX) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/abi.ini DESTINATION /usr/share/${PROJECT_NAME} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PRODUCT}.conf.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PRODUCT}.resolution.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.320x480.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/320x480 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.320x480.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/320x480 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.480x800.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/480x800 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.480x800.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/480x800 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.360x480.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/360x480 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.360x480.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/360x480 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.360x360.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/360x360 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.360x360.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/360x360 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/720x1280 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.mobile.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/720x1280 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.conf.ini DESTINATION /usr/share/${PROJECT_NAME}/320x320 RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/x11.wearable.resolution.ini DESTINATION /usr/share/${PROJECT_NAME}/320x320 RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PRODUCT}.conf.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "conf.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${TARGET}/${PRODUCT}.resolution.ini DESTINATION /usr/share/${PROJECT_NAME} RENAME "resolution.ini" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +ENDIF (LIVEBOX) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "${PROJECT_NAME}") +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.rule DESTINATION /etc/smack/accesses.d RENAME ${PROJECT_NAME}) + +# INCLUDE FOR BUILD & INSTALL .PO FILES +ADD_SUBDIRECTORY(res) +ADD_SUBDIRECTORY(data) +IF (LIVEBOX) +ADD_SUBDIRECTORY(pkgmgr_widget) +ENDIF (LIVEBOX) + +IF (X11_SUPPORT) + IF ("${ENGINEER_BINARY}" STREQUAL "true") + ADD_SUBDIRECTORY(widget-mgr) + ENDIF ("${ENGINEER_BINARY}" STREQUAL "true") +ENDIF (X11_SUPPORT) + +# End of a file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..571fe79 --- /dev/null +++ b/LICENSE @@ -0,0 +1,206 @@ +Flora License + +Version 1.1, April, 2013 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Tizen Compliance Specification +and passes the Tizen Compliance Tests as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an addendum + to the NOTICE text from the Work, provided that such additional attribution + notices cannot be construed as modifying the License. You may add Your own + copyright statement to Your modifications and may provide additional or + different license terms and conditions for use, reproduction, or + distribution of Your modifications, or for any such Derivative Works + as a whole, provided Your use, reproduction, and distribution of + the Work otherwise complies with the conditions stated in this License + and your own copyright statement or terms and conditions do not conflict + the conditions stated in the License including section 3. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.1 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://floralicense.org/license/ + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/data-provider-master.rule b/data-provider-master.rule new file mode 100644 index 0000000..dafbe90 --- /dev/null +++ b/data-provider-master.rule @@ -0,0 +1,33 @@ +data-provider-master::bin samsung::vconf::dynamicbox rw---- ------ +data-provider-master::bin xorg rwx--- ------ +data-provider-master::bin tizen::vconf::setting::admin rw---- ------ +data-provider-master::bin tizen::vconf::platform::r r----- ------ +data-provider-master::bin device::app_logging -w---- ------ +data-provider-master::bin device::sys_logging -w---- ------ +data-provider-master::bin tizen::vconf::public::r r----l ------ +data-provider-master::bin data-provider-master::data r-x--- ------ +data-provider-master::bin data-provider-master::share rwx--- ------ +data-provider-master::bin data-provider-master::db rw---- ------ +data-provider-master::bin data-provider-master rwx--- ------ +data-provider-master::bin pkgmgr::db rw----- ------ +data-provider-master::bin _ rw---- ------ +data-provider-master::bin security-server::api-privilege-by-pid rw---- ------ +data-provider-master::bin wrt-security-daemon r----- ------ +data-provider-master::bin security-server r----- ------ +data-provider-master::bin aul::launch --x--- ------ +data-provider-master::bin device::input rw---- ------ +data-provider-master::bin resourced r----- ------ +data-provider-master::bin syslogd r-x--- ------ +data-provider-master::bin deviced r-x--- ------ +data-provider-master::bin alarm-server r-x--- ------ +data-provider-master::bin dbus r-x--- ------ +data-provider-master::bin secure-storage r-x-- ------ +data-provider-master::bin telephony_framework r-x-- ------ +data-provider-master::bin system::media r-x-- ------ +data-provider-master::bin system::vconf --x--- ------ +data-provider-master::bin system::vconf_system r----- ------ +data-provider-master::bin notification::db rw---- ------ +data-provider-master::bin shortcut-service::db rw---- ------ +data-provider-master::bin badge::db rw---- ------ +_ data-provider-master::bin r-x--- ------ +data-provider-master::bin sdbd r----- ------ diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt new file mode 100755 index 0000000..2edf919 --- /dev/null +++ b/data/CMakeLists.txt @@ -0,0 +1,4 @@ +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}.service DESTINATION /usr/lib/systemd/system/ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) +IF (LIVEBOX) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/dump_widget.sh DESTINATION /opt/etc/dump.d/module.d/ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +ENDIF (LIVEBOX) diff --git a/data/data-provider-master b/data/data-provider-master new file mode 100755 index 0000000..6dd2a92 --- /dev/null +++ b/data/data-provider-master @@ -0,0 +1,98 @@ +#!/bin/sh +# +# 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. +# + +launch_provider() +{ + RETRY_COUNT=0 + while [ ! -f "/tmp/.stop.provider" ]; do + # PROVIDER_HEAP_MONITOR_START=false + # PROVIDER_DISABLE_CALL_OPTION=false + # PROVIDER_METHOD="shm", "pixmap", "file" (default = "file") + BUFMGR_LOCK_TYPE="once" BUFMGR_MAP_CACHE="true" /usr/bin/data-provider-master + vconftool set -t bool memory/data-provider-master/started 0 -f + let RETRY_COUNT=$RETRY_COUNT+1 + if [ $RETRY_COUNT -gt 5 ]; then + echo "EXCEED THE MAXIMUM RETRY COUNT: $RETRY_COUNT (max 5)" + break; + fi + done + rm /tmp/.stop.provider +} + +start () +{ + OLDPID=`ps ax | grep /usr/bin/data-provider-master | grep -v grep | awk '{print $1}'` + if [ x"$OLDPID" != x"" ]; then + echo $OLDPID is already running. + exit 0 + fi + + rm /tmp/.stop.provider + launch_provider & +} + +stop () +{ + TMP=`which ps` + if [ $? -ne 0 ]; then + echo "'ps' is not exists" + exit 0 + fi + + TMP=`which grep` + if [ $? -ne 0 ]; then + echo "'grep' is not exists" + exit 0 + fi + + TMP=`which awk` + if [ $? -ne 0 ]; then + echo "'awk' is not exists" + exit 0 + fi + + if [ ! -f "/usr/bin/data-provider-master" ]; then + echo "Data provider master is not installed correctly"; + exit 0; + fi + + touch /tmp/.stop.provider + BIN_INODE=`stat -Lc "%i" /usr/bin/data-provider-master` + + PID=`ps ax | grep 'data-provider-master' | awk '{print $1}'` + for I in $PID; + do + if [ ! -f "/proc/$I/exe" ]; then + continue; + fi + + INODE=`stat -Lc "%i" /proc/$I/exe 2>/dev/null` + if [ x"$BIN_INODE" == x"$INODE" ]; then + echo "Send TERM to $I" + kill $I # Try to terminate a master which is launched already + break + fi + done +} + +case "$1" in + start|"") start;; + stop) stop;; + restart) stop; start;; +esac + +# End of a file diff --git a/data/data-provider-master.service b/data/data-provider-master.service new file mode 100644 index 0000000..283d13f --- /dev/null +++ b/data/data-provider-master.service @@ -0,0 +1,34 @@ +# +# 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. +# + +[Unit] +Description=Data Provider daemon +After=xorg.target + +[Service] +User=system +Group=system +SmackProcessLabel=data-provider-master::bin +Environment=BUFMGR_LOCK_TYPE="once" +Environment=BUFMGR_MAP_CACHE="true" +Type=notify +ExecStart=/usr/bin/data-provider-master +RestartSec=1 +Restart=always +MemoryLimit=50M + +[Install] +WantedBy=multi-user.target diff --git a/data/device/abi.ini b/data/device/abi.ini new file mode 100755 index 0000000..40407ed --- /dev/null +++ b/data/device/abi.ini @@ -0,0 +1,14 @@ +[c] +package=org.tizen.data-provider-slave + +[cpp] +package=org.tizen.data-provider-slave + +[html] +package=widget.web-provider + +[osp] +package=gi2qxenosh.osp-appwidget-service + +[app] +package=/APPID/ diff --git a/data/device/wayland.mobile.conf.ini b/data/device/wayland.mobile.conf.ini new file mode 100755 index 0000000..ea6dd0a --- /dev/null +++ b/data/device/wayland.mobile.conf.ini @@ -0,0 +1,38 @@ +base_width=720 +base_height=1280 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=104857600 +#replace_tag=/APPID/ +slave_ttl=30.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=shm +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +#input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=1 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +#auto_align=true diff --git a/data/device/wayland.mobile.resolution.ini b/data/device/wayland.mobile.resolution.ini new file mode 100644 index 0000000..e2b5a17 --- /dev/null +++ b/data/device/wayland.mobile.resolution.ini @@ -0,0 +1,13 @@ +1x1=175x175 +2x1=354x175 +2x2=354x354 +4x1=712x175 +4x2=712x354 +4x3=712x533 +4x4=712x712 +4x5=712x891 +4x6=712x1070 +21x21=224x215 +23x21=680x215 +23x23=680x653 +0x0=720x1280 diff --git a/data/device/wayland.wearable.conf.ini b/data/device/wayland.wearable.conf.ini new file mode 100755 index 0000000..eba043d --- /dev/null +++ b/data/device/wayland.wearable.conf.ini @@ -0,0 +1,38 @@ +base_width=320 +base_height=320 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=104857600 +#replace_tag=/APPID/ +slave_ttl=0.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=shm +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +#input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +#auto_align=true diff --git a/data/device/wayland.wearable.resolution.ini b/data/device/wayland.wearable.resolution.ini new file mode 100644 index 0000000..b9e7561 --- /dev/null +++ b/data/device/wayland.wearable.resolution.ini @@ -0,0 +1,14 @@ +1x1=320x320 +2x1=0x0 +2x2=320x320 +4x1=0x0 +4x2=0x0 +4x3=0x0 +4x4=0x0 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=320x320 +base=320x320 diff --git a/data/device/x11.mobile.320x480.conf.ini b/data/device/x11.mobile.320x480.conf.ini new file mode 100755 index 0000000..fc49048 --- /dev/null +++ b/data/device/x11.mobile.320x480.conf.ini @@ -0,0 +1,38 @@ +base_width=320 +base_height=480 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=1048576 +#replace_tag=/APPID/ +slave_ttl=30.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +#input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +#auto_align=true diff --git a/data/device/x11.mobile.320x480.resolution.ini b/data/device/x11.mobile.320x480.resolution.ini new file mode 100644 index 0000000..c848adf --- /dev/null +++ b/data/device/x11.mobile.320x480.resolution.ini @@ -0,0 +1,14 @@ +1x1=0x0 +2x1=0x0 +2x2=0x0 +4x1=0x0 +4x2=0x0 +4x3=0x0 +4x4=302x302 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=320x480 +base=320x480 diff --git a/data/device/x11.mobile.360x360.conf.ini b/data/device/x11.mobile.360x360.conf.ini new file mode 100644 index 0000000..e69de29 diff --git a/data/device/x11.mobile.360x360.resolution.ini b/data/device/x11.mobile.360x360.resolution.ini new file mode 100644 index 0000000..e69de29 diff --git a/data/device/x11.mobile.360x480.conf.ini b/data/device/x11.mobile.360x480.conf.ini new file mode 100644 index 0000000..e69de29 diff --git a/data/device/x11.mobile.360x480.resolution.ini b/data/device/x11.mobile.360x480.resolution.ini new file mode 100644 index 0000000..e69de29 diff --git a/data/device/x11.mobile.480x800.conf.ini b/data/device/x11.mobile.480x800.conf.ini new file mode 100755 index 0000000..7593188 --- /dev/null +++ b/data/device/x11.mobile.480x800.conf.ini @@ -0,0 +1,45 @@ +base_width=480 +base_height=800 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=1048576 +#replace_tag=/APPID/ +slave_ttl=30.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=20.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event1 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +auto_align=false +use_event_time=true +use_gettimeofday=false +slave_event_boost_on=-10 +slave_event_boost_off=0 +event_filter=0.5 +#slave_limit_to_ttl=true +#frame_skip=5 diff --git a/data/device/x11.mobile.480x800.resolution.ini b/data/device/x11.mobile.480x800.resolution.ini new file mode 100644 index 0000000..63ad36e --- /dev/null +++ b/data/device/x11.mobile.480x800.resolution.ini @@ -0,0 +1,14 @@ +1x1=126x126 +2x1=0x0 +2x2=0x0 +4x1=0x0 +4x2=470x234 +4x3=0x0 +4x4=470x470 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=480x800 +base=480x800 diff --git a/data/device/x11.mobile.conf.ini b/data/device/x11.mobile.conf.ini new file mode 100755 index 0000000..2f732fa --- /dev/null +++ b/data/device/x11.mobile.conf.ini @@ -0,0 +1,40 @@ +base_width=720 +base_height=1280 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=104857600 +#replace_tag=/APPID/ +slave_ttl=0.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +#input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +#auto_align=true +#use_event_time=true +event_filter=0.5 diff --git a/data/device/x11.mobile.resolution.ini b/data/device/x11.mobile.resolution.ini new file mode 100644 index 0000000..e2b5a17 --- /dev/null +++ b/data/device/x11.mobile.resolution.ini @@ -0,0 +1,13 @@ +1x1=175x175 +2x1=354x175 +2x2=354x354 +4x1=712x175 +4x2=712x354 +4x3=712x533 +4x4=712x712 +4x5=712x891 +4x6=712x1070 +21x21=224x215 +23x21=680x215 +23x23=680x653 +0x0=720x1280 diff --git a/data/device/x11.wearable.360x360.conf.ini b/data/device/x11.wearable.360x360.conf.ini new file mode 100755 index 0000000..c0cda7c --- /dev/null +++ b/data/device/x11.wearable.360x360.conf.ini @@ -0,0 +1,39 @@ +base_width=360 +base_height=360 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=1048576 +#replace_tag=/APPID/ +slave_ttl=0.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event0 +pd_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +auto_align=false +check_lcd=false diff --git a/data/device/x11.wearable.360x360.resolution.ini b/data/device/x11.wearable.360x360.resolution.ini new file mode 100644 index 0000000..b54c8a9 --- /dev/null +++ b/data/device/x11.wearable.360x360.resolution.ini @@ -0,0 +1,14 @@ +1x1=170x170 +2x1=0x0 +2x2=360x360 +4x1=0x0 +4x2=0x0 +4x3=0x0 +4x4=0x0 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=360x360 +base=360x360 diff --git a/data/device/x11.wearable.360x480.conf.ini b/data/device/x11.wearable.360x480.conf.ini new file mode 100755 index 0000000..b4276b2 --- /dev/null +++ b/data/device/x11.wearable.360x480.conf.ini @@ -0,0 +1,38 @@ +base_width=360 +base_height=480 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=1048576 +#replace_tag=/APPID/ +slave_ttl=0.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event0 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +check_lcd=false diff --git a/data/device/x11.wearable.360x480.resolution.ini b/data/device/x11.wearable.360x480.resolution.ini new file mode 100644 index 0000000..fea1ffa --- /dev/null +++ b/data/device/x11.wearable.360x480.resolution.ini @@ -0,0 +1,14 @@ +1x1=170x170 +2x1=0x0 +2x2=360x480 +4x1=0x0 +4x2=0x0 +4x3=0x0 +4x4=0x0 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=360x480 +base=360x480 diff --git a/data/device/x11.wearable.conf.ini b/data/device/x11.wearable.conf.ini new file mode 100755 index 0000000..336af73 --- /dev/null +++ b/data/device/x11.wearable.conf.ini @@ -0,0 +1,40 @@ +base_width=320 +base_height=320 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=104857600 +#replace_tag=/APPID/ +slave_ttl=0.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +#input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +#auto_align=true +#use_event_time=true +check_lcd=false diff --git a/data/device/x11.wearable.resolution.ini b/data/device/x11.wearable.resolution.ini new file mode 100644 index 0000000..5b6923e --- /dev/null +++ b/data/device/x11.wearable.resolution.ini @@ -0,0 +1,14 @@ +1x1=170x170 +2x1=0x0 +2x2=320x320 +4x1=0x0 +4x2=0x0 +4x3=0x0 +4x4=0x0 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=320x320 +base=320x320 diff --git a/data/dump_widget.sh b/data/dump_widget.sh new file mode 100755 index 0000000..2963bbb --- /dev/null +++ b/data/dump_widget.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +WIDGET_DEBUG=$1/widget +mkdir -p ${WIDGET_DEBUG} +/bin/cp -r /opt/usr/share/live_magazine ${WIDGET_DEBUG} +/bin/cp -r /tmp/.widget.service ${WIDGET_DEBUG}/log +/bin/cp -r /opt/dbspace/.widget.db ${WIDGET_DEBUG} +ls -la /tmp/ | /bin/grep srw > ${WIDGET_DEBUG}/log/tmp.hidden_files diff --git a/data/emulator/abi.ini b/data/emulator/abi.ini new file mode 100755 index 0000000..40407ed --- /dev/null +++ b/data/emulator/abi.ini @@ -0,0 +1,14 @@ +[c] +package=org.tizen.data-provider-slave + +[cpp] +package=org.tizen.data-provider-slave + +[html] +package=widget.web-provider + +[osp] +package=gi2qxenosh.osp-appwidget-service + +[app] +package=/APPID/ diff --git a/data/emulator/wayland.mobile.conf.ini b/data/emulator/wayland.mobile.conf.ini new file mode 100755 index 0000000..8c432f7 --- /dev/null +++ b/data/emulator/wayland.mobile.conf.ini @@ -0,0 +1,38 @@ +base_width=720 +base_height=1280 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=104857600 +#replace_tag=/APPID/ +slave_ttl=30.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=shm +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=1 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +#auto_align=true diff --git a/data/emulator/wayland.mobile.resolution.ini b/data/emulator/wayland.mobile.resolution.ini new file mode 100644 index 0000000..e2b5a17 --- /dev/null +++ b/data/emulator/wayland.mobile.resolution.ini @@ -0,0 +1,13 @@ +1x1=175x175 +2x1=354x175 +2x2=354x354 +4x1=712x175 +4x2=712x354 +4x3=712x533 +4x4=712x712 +4x5=712x891 +4x6=712x1070 +21x21=224x215 +23x21=680x215 +23x23=680x653 +0x0=720x1280 diff --git a/data/emulator/wayland.wearable.conf.ini b/data/emulator/wayland.wearable.conf.ini new file mode 100755 index 0000000..1da65e8 --- /dev/null +++ b/data/emulator/wayland.wearable.conf.ini @@ -0,0 +1,38 @@ +base_width=320 +base_height=320 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=104857600 +#replace_tag=/APPID/ +slave_ttl=0.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=shm +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[badge] +#auto_align=true diff --git a/data/emulator/wayland.wearable.resolution.ini b/data/emulator/wayland.wearable.resolution.ini new file mode 100644 index 0000000..b9e7561 --- /dev/null +++ b/data/emulator/wayland.wearable.resolution.ini @@ -0,0 +1,14 @@ +1x1=320x320 +2x1=0x0 +2x2=320x320 +4x1=0x0 +4x2=0x0 +4x3=0x0 +4x4=0x0 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=320x320 +base=320x320 diff --git a/data/emulator/x11.mobile.320x480.conf.ini b/data/emulator/x11.mobile.320x480.conf.ini new file mode 100755 index 0000000..9341273 --- /dev/null +++ b/data/emulator/x11.mobile.320x480.conf.ini @@ -0,0 +1,38 @@ +base_width=320 +base_height=480 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=1048576 +#replace_tag=/APPID/ +slave_ttl=30.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +#auto_align=true diff --git a/data/emulator/x11.mobile.320x480.resolution.ini b/data/emulator/x11.mobile.320x480.resolution.ini new file mode 100644 index 0000000..c848adf --- /dev/null +++ b/data/emulator/x11.mobile.320x480.resolution.ini @@ -0,0 +1,14 @@ +1x1=0x0 +2x1=0x0 +2x2=0x0 +4x1=0x0 +4x2=0x0 +4x3=0x0 +4x4=302x302 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=320x480 +base=320x480 diff --git a/data/emulator/x11.mobile.360x360.conf.ini b/data/emulator/x11.mobile.360x360.conf.ini new file mode 100644 index 0000000..e69de29 diff --git a/data/emulator/x11.mobile.360x360.resolution.ini b/data/emulator/x11.mobile.360x360.resolution.ini new file mode 100644 index 0000000..e69de29 diff --git a/data/emulator/x11.mobile.360x480.conf.ini b/data/emulator/x11.mobile.360x480.conf.ini new file mode 100644 index 0000000..e69de29 diff --git a/data/emulator/x11.mobile.360x480.resolution.ini b/data/emulator/x11.mobile.360x480.resolution.ini new file mode 100644 index 0000000..e69de29 diff --git a/data/emulator/x11.mobile.480x800.conf.ini b/data/emulator/x11.mobile.480x800.conf.ini new file mode 100755 index 0000000..f6a9e8b --- /dev/null +++ b/data/emulator/x11.mobile.480x800.conf.ini @@ -0,0 +1,45 @@ +base_width=480 +base_height=800 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=1048576 +#replace_tag=/APPID/ +slave_ttl=30.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=20.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +auto_align=false +use_event_time=true +use_gettimeofday=false +slave_event_boost_on=-10 +slave_event_boost_off=0 +event_filter=0.5 +#slave_limit_to_ttl=true +#frame_skip=5 diff --git a/data/emulator/x11.mobile.480x800.resolution.ini b/data/emulator/x11.mobile.480x800.resolution.ini new file mode 100644 index 0000000..63ad36e --- /dev/null +++ b/data/emulator/x11.mobile.480x800.resolution.ini @@ -0,0 +1,14 @@ +1x1=126x126 +2x1=0x0 +2x2=0x0 +4x1=0x0 +4x2=470x234 +4x3=0x0 +4x4=470x470 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=480x800 +base=480x800 diff --git a/data/emulator/x11.mobile.conf.ini b/data/emulator/x11.mobile.conf.ini new file mode 100755 index 0000000..67818c6 --- /dev/null +++ b/data/emulator/x11.mobile.conf.ini @@ -0,0 +1,40 @@ +base_width=720 +base_height=1280 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=104857600 +#replace_tag=/APPID/ +slave_ttl=0.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[utility],[badge] +#auto_align=true +#use_event_time=true +event_filter=0.5 diff --git a/data/emulator/x11.mobile.resolution.ini b/data/emulator/x11.mobile.resolution.ini new file mode 100644 index 0000000..e2b5a17 --- /dev/null +++ b/data/emulator/x11.mobile.resolution.ini @@ -0,0 +1,13 @@ +1x1=175x175 +2x1=354x175 +2x2=354x354 +4x1=712x175 +4x2=712x354 +4x3=712x533 +4x4=712x712 +4x5=712x891 +4x6=712x1070 +21x21=224x215 +23x21=680x215 +23x23=680x653 +0x0=720x1280 diff --git a/data/emulator/x11.wearable.360x360.conf.ini b/data/emulator/x11.wearable.360x360.conf.ini new file mode 100755 index 0000000..a277980 --- /dev/null +++ b/data/emulator/x11.wearable.360x360.conf.ini @@ -0,0 +1,39 @@ +base_width=360 +base_height=360 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=1048576 +#replace_tag=/APPID/ +slave_ttl=0.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event2 +pd_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +auto_align=false +check_lcd=false diff --git a/data/emulator/x11.wearable.360x360.resolution.ini b/data/emulator/x11.wearable.360x360.resolution.ini new file mode 100644 index 0000000..b54c8a9 --- /dev/null +++ b/data/emulator/x11.wearable.360x360.resolution.ini @@ -0,0 +1,14 @@ +1x1=170x170 +2x1=0x0 +2x2=360x360 +4x1=0x0 +4x2=0x0 +4x3=0x0 +4x4=0x0 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=360x360 +base=360x360 diff --git a/data/emulator/x11.wearable.360x480.conf.ini b/data/emulator/x11.wearable.360x480.conf.ini new file mode 100755 index 0000000..a8511a2 --- /dev/null +++ b/data/emulator/x11.wearable.360x480.conf.ini @@ -0,0 +1,38 @@ +base_width=360 +base_height=480 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=1048576 +#replace_tag=/APPID/ +slave_ttl=0.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[notification],[badge] +check_lcd=false diff --git a/data/emulator/x11.wearable.360x480.resolution.ini b/data/emulator/x11.wearable.360x480.resolution.ini new file mode 100644 index 0000000..fea1ffa --- /dev/null +++ b/data/emulator/x11.wearable.360x480.resolution.ini @@ -0,0 +1,14 @@ +1x1=170x170 +2x1=0x0 +2x2=360x480 +4x1=0x0 +4x2=0x0 +4x3=0x0 +4x4=0x0 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=360x480 +base=360x480 diff --git a/data/emulator/x11.wearable.conf.ini b/data/emulator/x11.wearable.conf.ini new file mode 100755 index 0000000..e0fc7e4 --- /dev/null +++ b/data/emulator/x11.wearable.conf.ini @@ -0,0 +1,40 @@ +base_width=320 +base_height=320 +minimum_period=1.0 +#script=edje +#default_abi=c +#default_group=disclosure +default_period=-1.0 +default_packet_time=0.0001 +#default_content=default +minimum_space=104857600 +#replace_tag=/APPID/ +slave_ttl=0.0 +slave_activate_time=30.0 +slave_relaunch_time=3.0 +slave_relaunch_count=3 +max_log_line=1000 +max_log_file=3 +sqilte_flush_max=1048576 +#db_path=/opt/dbspace/.widget.db +#share_path=/opt/usr/share/live_magazine/ +log_path=/tmp/.widget.service +#always_path=/opt/usr/share/live_magazine/always +#reader_path=/opt/usr/share/live_magazine/reader +#script_port_path=/usr/share/data-provider-master/plugin-script/ +ping_interval=240.0 +slave_max_load=30 +use_sw_backend=false +provider_method=pixmap +debug_mode=false +overwrite_content=false +com_core_thread=true +use_xmonitor=false +input=/dev/input/event2 +gbar_request_timeout=5.0 +premultiplied=0 +#emergency_disk=source=tmpfs;type=tmpfs;option=size=6M +services=[widget],[shortcut],[badge] +#auto_align=true +#use_event_time=true +check_lcd=false diff --git a/data/emulator/x11.wearable.resolution.ini b/data/emulator/x11.wearable.resolution.ini new file mode 100644 index 0000000..5b6923e --- /dev/null +++ b/data/emulator/x11.wearable.resolution.ini @@ -0,0 +1,14 @@ +1x1=170x170 +2x1=0x0 +2x2=320x320 +4x1=0x0 +4x2=0x0 +4x3=0x0 +4x4=0x0 +4x5=0x0 +4x6=0x0 +21x21=0x0 +23x21=0x0 +23x23=0x0 +0x0=320x320 +base=320x320 diff --git a/include/badge_service.h b/include/badge_service.h new file mode 100644 index 0000000..ed49c9f --- /dev/null +++ b/include/badge_service.h @@ -0,0 +1,20 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int badge_service_init(void); +extern int badge_service_fini(void); + +/* End of a file */ diff --git a/include/buffer_handler.h b/include/buffer_handler.h new file mode 100644 index 0000000..9931c52 --- /dev/null +++ b/include/buffer_handler.h @@ -0,0 +1,348 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct buffer_info; +struct inst_info; +struct buffer; + +#include + +/*! + * \brief + * \param[in] type + * \param[in] w + * \param[in] h + * \param[in] pixel_size + * \return buffer_info + */ +extern struct buffer_info *buffer_handler_create(struct inst_info *inst, enum widget_fb_type type, int w, int h, int pixel_size); + +/*! + * \brief + * \param[in] info + * \return int + */ +extern int buffer_handler_destroy(struct buffer_info *info); + +/*! + * \brief + * \param[in] info + * \return int + */ +extern int buffer_handler_load(struct buffer_info *info); + +/*! + * \brief + * \param[in] info + * \return int + */ +extern int buffer_handler_unload(struct buffer_info *info); + +/*! + * \brief + * \param[in] info + * \return int + */ +extern int buffer_handler_is_loaded(const struct buffer_info *info); + +/*! + * \brief Reallocate buffer + * \param[in] info + * \param[in] w + * \param[in] h + * \return int + */ +extern int buffer_handler_resize(struct buffer_info *info, int w, int h); + +/*! + * \brief Only update the size information + * \param[in] info + * \param[in] w + * \param[in] h + * \return void + */ +extern void buffer_handler_update_size(struct buffer_info *info, int w, int h); + +/*! + * \brief + * \param[in] info + * \return const char * + */ +extern const char *buffer_handler_id(const struct buffer_info *info); + +/*! + * \param[in] info + * \return widget_fb_type + */ +extern enum widget_fb_type buffer_handler_type(const struct buffer_info *info); + +/*! + * \brief This API is not supported for Pixmap. + * \param[in] info + * \return void* + */ +extern void *buffer_handler_fb(struct buffer_info *info); + +/*! + * \brief + * \param[in] info + * \param[out] w + * \param[out] h + * \return int + */ +extern int buffer_handler_get_size(struct buffer_info *info, int *w, int *h); + +/*! + * \brief This API only can be used for file type buffer + * \param[in] info + * \return void + */ +extern void buffer_handler_flush(struct buffer_info *info); + +/*! + * \brief + * \param[in] info + * \return 0 if fails. Return value should be casted to Pixmap type + */ +extern int buffer_handler_pixmap(const struct buffer_info *info); + +/*! + * \brief + * \param[in] info + * \return buffer + */ +extern void *buffer_handler_pixmap_acquire_buffer(struct buffer_info *info); + +/*! + * \brief + * \param[in] info + * \return int + */ +extern int buffer_handler_pixmap_release_buffer(void *canvas); + +/*! + * \brief + * \param[in] info + * \return int + */ +extern int buffer_handler_stride(struct buffer_info *info); + +/*! + * \brief + * \param[in] info + * \return int + */ +extern int buffer_handler_pixels(struct buffer_info *info); + +/*! + * \brief + * \param[in] info + * \return int + */ +extern int buffer_handler_auto_align(void); + +/*! + * \brief + * \return int + */ +extern int buffer_handler_init(void); + +/*! + * \brief + * \details + * \remarks + * \return int + * \retval + * \pre + * \post + * \sa + */ +extern int buffer_handler_fini(void); + +/*! + * \brief + * \details + * \remarks + * \param[in] info + * \return void * + * \retval NULL + * \retval address + * \pre + * \post + * \sa + */ +extern void *buffer_handler_pixmap_ref(struct buffer_info *info); + +/*! + * \brief + * \details + * \remarks + * \param[in] buffer_ptr + * \return int + * \retval + * \pre + * \post + * \sa + */ +extern int buffer_handler_pixmap_unref(void *buffer_ptr); + +/*! + * \brief + * \details + * \remarks + * \param[in] pixmap + * \return void * + * \retval + * \pre + * \post + * \sa + */ +extern void *buffer_handler_pixmap_find(int pixmap); + +/*! + * \brief + * \details + * \remarks + * \param[in] info + * \return void * + * \retval + * \pre + * \post + * \sa + */ +extern void *buffer_handler_pixmap_buffer(struct buffer_info *info); + +/*! + * \brief + * \details + * \remarks + * \param[in] info + * \return struct inst_info * + * \retval + * \pre + * \post + * \sa + */ +extern struct inst_info *buffer_handler_instance(struct buffer_info *info); + +/*! + * \brief + * \details + * \remarks + * \param[in] type + * \param[in] resource + * \return widget_fb_t + * \retval NULL + * \retval address + * \pre + * \post + * \sa + */ +extern widget_fb_t buffer_handler_raw_open(enum widget_fb_type type, void *resource); + +/*! + * \brief + * \details + * \remarks + * \param[in] buffer + * \return int + * \retval + * \pre + * \post + * \sa + */ +extern int buffer_handler_raw_close(widget_fb_t buffer); + +/*! + * \brief + * \details + * \remarks + * \param[in] buffer + * \return void * + * \retval NULL + * \pre + * \post + * \sa + */ +extern void *buffer_handler_raw_data(widget_fb_t buffer); + +/*! + * \brief + * \details + * \remarks + * \param[in] buffer + * \return int + * \retval + * \pre + * \post + * \sa + */ +extern int buffer_handler_raw_size(widget_fb_t buffer); + +/*! + * \brief + * \details + * \remarks + * \param[in] buffer + * \return int + * \retval + * \pre + * \post + * \sa + */ +extern int buffer_handler_lock(struct buffer_info *buffer); + +/*! + * \brief + * \details + * \remarks + * \param[in] buffer + * \return int + * \retval + * \pre + * \post + * \sa + */ +extern int buffer_handler_unlock(struct buffer_info *buffer); + +/*! + * \brief + * \details + * \remarks + * \param[in] buffer + * \param[in] data + * \return int + * \retval + * \pre + * \post + * \sa + */ +extern int buffer_handler_set_data(struct buffer_info *buffer, void *data); + +/*! + * \brief + * \details + * \remarks + * \param[in] buffer + * \return void * + * \retval NULL + * \retval address + * \pre + * \post + * \sa + */ +extern void *buffer_handler_data(struct buffer_info *buffer); +/* End of a file */ diff --git a/include/client_life.h b/include/client_life.h new file mode 100644 index 0000000..e4fa187 --- /dev/null +++ b/include/client_life.h @@ -0,0 +1,115 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +enum client_event { + CLIENT_EVENT_ACTIVATE, + CLIENT_EVENT_DEACTIVATE +}; + +enum client_global_event { + CLIENT_GLOBAL_EVENT_CREATE, + CLIENT_GLOBAL_EVENT_DESTROY +}; + +struct inst_info; +struct packet; + +/*! + * \note + * Create & Destroy + */ +extern struct client_node *client_create(pid_t pid, int handle, const char *direct_addr); +#define client_destroy(client) client_unref(client) + +/*! + * \note + * Reference count + */ +extern struct client_node *client_ref(struct client_node *client); +extern struct client_node *client_unref(struct client_node *client); +extern const int const client_refcnt(const struct client_node *client); + +/*! + * \note + * Information of client PID + */ +extern const pid_t const client_pid(const struct client_node *client); +extern struct client_node *client_find_by_pid(pid_t pid); +extern struct client_node *client_find_by_rpc_handle(int handle); + +/*! + * \note + * Statistics for state of client + */ +extern const int const client_count_paused(void); +extern int client_is_all_paused(void); +extern int client_count(void); + +/*! + * \note + * For dead signal handler + */ +extern struct client_node *client_deactivated_by_fault(struct client_node *client); +extern void client_reset_fault(struct client_node *client); +extern const int const client_is_faulted(const struct client_node *client); + +/*! + * \note + * For other components which wants to know the state of a client + */ +extern int client_event_callback_add(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data); +extern int client_event_callback_del(struct client_node *client, enum client_event event, int (*cb)(struct client_node *, void *), void *data); + +extern int client_global_event_handler_del(enum client_global_event event_type, int (*cb)(struct client_node *, void *), void *data); +extern int client_global_event_handler_add(enum client_global_event event_type, int (*cb)(struct client_node *client, void *data), void *data); + +/*! + * \note + * Private data set & get + */ +extern int client_set_data(struct client_node *client, const char *tag, void *data); +extern void *client_data(struct client_node *client, const char *tag); +extern void *client_del_data(struct client_node *client, const char *tag); + +/*! + * Handling the client statues + * Paused or Resumed + */ +extern void client_paused(struct client_node *client); +extern void client_resumed(struct client_node *client); + +/* Related with Context-Aware service */ +extern int client_subscribe_group(struct client_node *client, const char *cluster, const char *category); +extern int client_unsubscribe_group(struct client_node *client, const char *cluster, const char *category); +extern int client_is_subscribed_group(struct client_node *client, const char *cluster, const char *category); + +/* Related with category */ +extern int client_subscribe_category(struct client_node *client, const char *category); +extern int client_unsubscribe_category(struct client_node *client, const char *category); +extern int client_is_subscribed_by_category(struct client_node *client, const char *category); + +extern int client_init(void); +extern void client_fini(void); + +extern int client_browse_group_list(const char *cluster, const char *category, int (*cb)(struct client_node *client, void *data), void *data); +extern int client_count_of_group_subscriber(const char *cluster, const char *category); + +extern int client_browse_category_list(const char *category, int (*cb)(struct client_node *client, void *data), void *data); + +extern int client_broadcast(struct inst_info *inst, struct packet *packet); + +extern const char *client_direct_addr(const struct client_node *client); +/* End of a file */ diff --git a/include/client_rpc.h b/include/client_rpc.h new file mode 100644 index 0000000..20a8a38 --- /dev/null +++ b/include/client_rpc.h @@ -0,0 +1,27 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*! + */ +extern int client_rpc_async_request(struct client_node *client, struct packet *packet); +extern int client_rpc_handle(struct client_node *client); + +/*! + */ +extern int client_rpc_init(struct client_node *client, int handle); +extern int client_rpc_fini(struct client_node *client); + +/* End of a file */ diff --git a/include/conf.h b/include/conf.h new file mode 100644 index 0000000..a4d0603 --- /dev/null +++ b/include/conf.h @@ -0,0 +1,38 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct conf { + int debug_mode; + int slave_max_load; +}; + +extern struct conf g_conf; + +#define DELAY_TIME 0.0000001f +#define HAPI __attribute__((visibility("hidden"))) + +#if !defined(VCONFKEY_MASTER_STARTED) +#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started" +#endif + +#if !defined(VCONFKEY_MASTER_RESTART_COUNT) +#define VCONFKEY_MASTER_RESTART_COUNT "memory/private/data-provider-master/restart_count" +#endif + +#define CR 13 +#define LF 10 + +/* End of a file */ diff --git a/include/critical_log.h b/include/critical_log.h new file mode 100644 index 0000000..f060ce1 --- /dev/null +++ b/include/critical_log.h @@ -0,0 +1,23 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int critical_log(const char *func, int line, const char *fmt, ...); +extern int critical_log_init(const char *tag); +extern void critical_log_fini(void); + +#define CRITICAL_LOG(args...) critical_log(__func__, __LINE__, args) + +/* End of a file */ diff --git a/include/dead_monitor.h b/include/dead_monitor.h new file mode 100644 index 0000000..52ebbe4 --- /dev/null +++ b/include/dead_monitor.h @@ -0,0 +1,22 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int dead_init(void); +extern int dead_fini(void); +extern int dead_callback_add(int handle, void (*dead_cb)(int handle, void *data), void *data); +extern void *dead_callback_del(int handle, void (*dead_cb)(int handle, void *data)); + +/* End of a file */ diff --git a/include/debug.h b/include/debug.h new file mode 100644 index 0000000..cbf1ea0 --- /dev/null +++ b/include/debug.h @@ -0,0 +1,72 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if !defined(FLOG) +#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) +#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) +#define WarnPrint(format, arg...) SECURE_LOGW(format, ##arg) +#else +extern FILE *__file_log_fp; +#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) +#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) +#define WarnPrint(format, arg...) do { fprintf(__file_log_fp, "[WRN] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) +#endif + +// DbgPrint("FREE\n"); +#define DbgFree(a) do { \ + free(a); \ +} while (0) + +#define DbgXFree(a) do { \ + DbgPrint("XFree\n"); \ + XFree(a); \ +} while (0) + + +#if defined(LOG_TAG) +#undef LOG_TAG +#endif + +#define LOG_TAG "DATA_PROVIDER_MASTER" + +#if defined(_ENABLE_PERF) +#define PERF_INIT() \ + struct timeval __stv; \ + struct timeval __etv; \ + struct timeval __rtv + +#define PERF_BEGIN() do { \ + if (gettimeofday(&__stv, NULL) < 0) { \ + ErrPrint("gettimeofday: %d\n", errno); \ + } \ +} while (0) + +#define PERF_MARK(tag) do { \ + if (gettimeofday(&__etv, NULL) < 0) { \ + ErrPrint("gettimeofday: %d\n", errno); \ + } \ + timersub(&__etv, &__stv, &__rtv); \ + DbgPrint("[%s] %u.%06u\n", tag, __rtv.tv_sec, __rtv.tv_usec); \ +} while (0) +#else +#define PERF_INIT() +#define PERF_BEGIN() +#define PERF_MARK(tag) +#endif + +#define HAPI __attribute__((visibility("hidden"))) + +/* End of a file */ diff --git a/include/event.h b/include/event.h new file mode 100644 index 0000000..b16ce31 --- /dev/null +++ b/include/event.h @@ -0,0 +1,66 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct event_data { + int x; + int y; + unsigned int keycode; + int device; + int slot; + struct { + int major; + int minor; + } touch; + struct { + int major; + int minor; + } width; + int distance; /* Hovering */ + int orientation; + int pressure; + int updated; /* Timestamp is updated */ + double tv; +}; + +enum event_state { + EVENT_STATE_DEACTIVATED, + EVENT_STATE_ACTIVATE, + EVENT_STATE_ACTIVATED, + EVENT_STATE_DEACTIVATE, + EVENT_STATE_ERROR +}; + +enum event_handler_activate_type { + EVENT_HANDLER_DEACTIVATED = 0x00, + EVENT_HANDLER_ACTIVATED_BY_MOUSE_SET = 0x01, + EVENT_HANDLER_ACTIVATED_BY_SHOW = 0x02, + EVENT_HANDLER_UNKNOWN = 0x04 +}; + +extern int event_init(void); +extern int event_fini(void); +extern int event_input_fd(void); +extern int event_activate(int 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); + +extern void event_set_mouse_xy(int x, int y, double timestamp); + +/* End of a file */ diff --git a/include/fault_manager.h b/include/fault_manager.h new file mode 100644 index 0000000..cfc1bec --- /dev/null +++ b/include/fault_manager.h @@ -0,0 +1,25 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int fault_check_pkgs(struct slave_node *node); +extern int fault_func_call(struct slave_node *node, const char *pkgname, const char *filename, const char *func); +extern int fault_func_ret(struct slave_node *node, const char *pkgname, const char *filename, const char *func); +extern int const fault_is_occured(void); +extern void fault_unicast_info(struct client_node *client, const char *pkgname, const char *filename, const char *func); +extern void fault_broadcast_info(const char *pkgname, const char *filename, const char *func); +extern int fault_info_set(struct slave_node *slave, const char *pkgname, const char *id, const char *func); + +/* End of a file */ diff --git a/include/file_service.h b/include/file_service.h new file mode 100644 index 0000000..208f739 --- /dev/null +++ b/include/file_service.h @@ -0,0 +1,20 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int file_service_init(void); +extern int file_service_fini(void); + +/* End of a file */ diff --git a/include/group.h b/include/group.h new file mode 100644 index 0000000..b321977 --- /dev/null +++ b/include/group.h @@ -0,0 +1,65 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct cluster; +struct category; +struct pkg_info; +struct context_info; +struct context_item; +struct context_option; + +extern struct cluster *group_create_cluster(const char *name); +extern struct cluster *group_find_cluster(const char *name); +extern int group_destroy_cluster(struct cluster *cluster); + +extern struct category *group_create_category(struct cluster *cluster, const char *name); +extern struct category *group_find_category(struct cluster *cluster, const char *name); +extern int group_destroy_category(struct category *category); + +extern const char * const group_category_name(struct category *category); +extern const char * const group_cluster_name(struct cluster *cluster); +extern const char *group_cluster_name_by_category(struct category *category); + +extern int group_add_package(struct category *category, const char *pkgname); +extern int group_del_package(struct category *category, const char *pkgname); + +extern int group_add_widget(const char *group, const char *pkgname); +extern int group_del_widget(const char *pkgname); + +extern int group_init(void); +extern int group_fini(void); + +extern struct context_info *group_create_context_info(struct category *category, const char *pkgname); +extern struct context_item *group_add_context_item(struct context_info *info, const char *ctx_item); +extern int group_add_option(struct context_item *item, const char *key, const char *value); +extern int group_destroy_context_info(struct context_info *info); + +extern Eina_List * const group_context_info_list(struct category *category); +extern Eina_List * const group_context_item_list(struct context_info *info); +extern Eina_List * const group_context_option_list(struct context_item *item); +extern Eina_List * const group_cluster_list(void); +extern Eina_List * const group_category_list(struct cluster *cluster); +extern struct context_info * const group_context_info_from_item(struct context_item *item); +extern struct category * const group_category_from_context_info(struct context_info *info); +extern const char * const group_option_item_key(struct context_option *option); +extern const char * const group_option_item_value(struct context_option *option); +extern const char * const group_context_item(struct context_item *item); +extern const char * const group_pkgname_from_context_info(struct context_info *info); + +extern void *group_context_item_del_data(struct context_item *item, const char *tag); +extern void *group_context_item_data(struct context_item *item, const char *tag); +extern int group_context_item_add_data(struct context_item *item, const char *tag, void *data); +/* End of a file */ diff --git a/include/instance.h b/include/instance.h new file mode 100644 index 0000000..f8e7f7b --- /dev/null +++ b/include/instance.h @@ -0,0 +1,277 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*! + * \note + * An instance has three states. + * ACTIVATED, DEACTIVATED, DESTROYED + * + * When the master is launched and someone requires to create this instance, + * The master just allocate a heap for new instance. + * We defined this as "DEACTIVATED" state. + * + * After master successfully allocate heap for an instance, + * It will send a load request to a specified slave + * (The slave will be specified when a package informaion is + * prepared via configuration file of each widget packages.) + * We defined this as "REQUEST_TO_ACTIVATE" state. + * + * After the slave create a new instance, it will sends back + * "created" event to the master. + * Then the master will change the state of the instance to + * "ACTIVATED". + * + * Sometimes, slaves can meet some unexpected problems then + * it will tries to clear all problems and tries to keep them in safe env. + * To do this, master or slave can be terminated. + * In this case, the master has to find the fault module(crashed widget) + * and prevent it from loading at the slave. + * And it will send requests for re-creating all other normal widgetes. + * We defined this as "REQUEST_TO_REACTIVATE". + * + * After slave is launched again(recovered from fault situation), it will + * receives "re-create" event from the master, then it will create all + * instances of requested widgetes. + * + * When the master receives "created" event from the slaves, + * It will change the instance's state to "ACTIVATED" + * But now, the master will not send "created" event to the clients. + * + * Because the clients don't want to know the re-created widgetes. + * They just want to know about fault widgetes to display deactivated + * message. + * + * Sometimes the master can send requests to the slave to unload instances. + * We defined this as "REQUEST_TO_DEACTIVATE". + * + * After the slave successfully destroy instances, + * The master will change the instance's state to "DEACTIVATED" + * It is same state with the first time when it is created in the master. + * + * Sometimes, the instances can be deleted permanently from the master and slave. + * We called this "destorying an instance". + * So we defined its states as "DESTROYED". + * It can make confusing us, the "DESTROYED" means like the instance is already deleted from the + * heap,. + * Yes, it is right. But the instance cannot be deleted directly. + * Because some callbacks still reference it to complete its job. + * So the instance needs to keep this DESTROYED state for a while + * until all callbacks are done for their remained jobs. + * + * To unload the instance from the slave, + * The master should send a request to the slave, + * And the master should keep the instance until it receives "deleted" event from the slave. + * We defined this state as "REQUEST_TO_DESTROY". + * + * After master receives "deleted" event from the slave, + * It will change the state of an master to "DESTROYED" + * + * There is one more event to change the state of an instance to "DESTROYED". + * In case of system created widget, it could be destroyed itself. + * So the slave will send "deleted" event to the master directly. + * Even if the master doesn't requests to delete it. + * + * In this case, the master will change the state of an instance to + * "DESTROYED" state. but it will wait to delete it from the heap until + * reference count of an instance reaches to ZERO. + */ + +enum instance_event { + INSTANCE_EVENT_DESTROY, + INSTNACE_EVENT_UNKNOWN +}; + +enum instance_state { + INST_INIT = 0x0, /*!< Only keeps in the master */ + + /*! + */ + INST_ACTIVATED, /*!< This instance is loaded to the slave */ + INST_REQUEST_TO_ACTIVATE, /*!< Sent a request to a slave to load this */ + INST_REQUEST_TO_REACTIVATE, /*!< Sent a request to a slave to load this without "created" event for clients(viewer) */ + + /*! + */ + INST_DESTROYED, /*!< Instance is unloaded and also it requires to be deleted from the master */ + INST_REQUEST_TO_DESTROY /*!< Sent a request to a slave, when the master receives deleted event, the master will delete this */ +}; + +enum widget_visible_state { /*!< Must be sync'd with widget-viewer */ + WIDGET_SHOW = 0x00, /*!< widget is showed. Default state */ + WIDGET_HIDE = 0x01, /*!< widget is hide, with no update event, but keep update timer */ + + WIDGET_HIDE_WITH_PAUSE = 0x02, /*!< widget is hide, it needs to be paused (with freezed update timer) */ + + WIDGET_VISIBLE_ERROR = 0xFFFFFFFF /* To enlarge the size of this enumeration type */ +}; + +#define IS_GBAR 1 +#define IS_WIDGET 0 + +struct inst_info; +struct pkg_info; +struct script_handle; +struct client_node; + +extern struct inst_info *instance_create(struct client_node *client, double timestamp, const char *pkgname, const char *content, const char *cluster, const char *category, double period, int width, int height); +extern int instance_destroy(struct inst_info *inst, widget_destroy_type_e type); +extern int instance_reload(struct inst_info *inst, widget_destroy_type_e type); + +extern struct inst_info * instance_ref(struct inst_info *inst); +extern struct inst_info * instance_unref(struct inst_info *inst); + +extern int instance_state_reset(struct inst_info *inst); +extern int instance_destroyed(struct inst_info *inst, int reason); + +extern int instance_reactivate(struct inst_info *inst); +extern int instance_activate(struct inst_info *inst); + +extern int instance_recover_state(struct inst_info *inst); +extern int instance_need_slave(struct inst_info *inst); + +extern void instance_set_widget_info(struct inst_info *inst, double priority, const char *content, const char *title); +extern void instance_set_widget_size(struct inst_info *inst, int w, int h); +extern void instance_set_gbar_size(struct inst_info *inst, int w, int h); +extern void instance_set_alt_info(struct inst_info *inst, const char *icon, const char *name); + +extern int instance_set_pinup(struct inst_info *inst, int pinup); +extern int instance_resize(struct inst_info *inst, int w, int h); +extern int instance_hold_scroll(struct inst_info *inst, int seize); +extern int instance_set_period(struct inst_info *inst, double period); +extern int instance_clicked(struct inst_info *inst, const char *event, double timestamp, double x, double y); +extern int instance_text_signal_emit(struct inst_info *inst, const char *signal_name, const char *source, double sx, double sy, double ex, double ey); +extern int instance_signal_emit(struct inst_info *inst, const char *signal_name, const char *source, double sx, double sy, double ex, double ey, double x, double y, int down); +extern int instance_change_group(struct inst_info *inst, const char *cluster, const char *category); +extern int instance_set_visible_state(struct inst_info *inst, enum widget_visible_state state); +extern enum widget_visible_state instance_visible_state(struct inst_info *inst); +extern int instance_set_update_mode(struct inst_info *inst, int active_update); +extern int instance_active_update(struct inst_info *inst); + +/*! + * \note + * getter + */ +extern const double const instance_timestamp(const struct inst_info *inst); +extern struct pkg_info * const instance_package(const struct inst_info *inst); +extern struct script_info * const instance_widget_script(const struct inst_info *inst); +extern struct script_info * const instance_gbar_script(const struct inst_info *inst); +extern struct buffer_info * const instance_gbar_buffer(const struct inst_info *inst); +extern struct buffer_info * const instance_gbar_extra_buffer(const struct inst_info *inst, int idx); +extern struct buffer_info * const instance_widget_buffer(const struct inst_info *inst); +extern struct buffer_info * const instance_widget_extra_buffer(const struct inst_info *inst, int idx); +extern const char * const instance_id(const struct inst_info *inst); +extern const char * const instance_content(const struct inst_info *inst); +extern const char * const instance_category(const struct inst_info *inst); +extern const char * const instance_cluster(const struct inst_info *inst); +extern const char * const instance_title(const struct inst_info *inst); +extern const char * const instance_auto_launch(const struct inst_info *inst); +extern const int const instance_priority(const struct inst_info *inst); +extern const struct client_node * const instance_client(const struct inst_info *inst); +extern const double const instance_period(const struct inst_info *inst); +extern const int const instance_timeout(const struct inst_info *inst); +extern const int const instance_widget_width(const struct inst_info *inst); +extern const int const instance_widget_height(const struct inst_info *inst); +extern const int const instance_gbar_width(const struct inst_info *inst); +extern const int const instance_gbar_height(const struct inst_info *inst); +extern const enum instance_state const instance_state(const struct inst_info *inst); + +/*! + * event + */ +extern int instance_unicast_created_event(struct inst_info *inst, struct client_node *client); +extern int instance_unicast_deleted_event(struct inst_info *inst, struct client_node *client, int reason); + +extern int instance_create_widget_buffer(struct inst_info *inst, int pixels); +extern int instance_create_widget_extra_buffer(struct inst_info *inst, int pixels, int idx); +extern int instance_create_gbar_buffer(struct inst_info *inst, int pixels); +extern int instance_create_gbar_extra_buffer(struct inst_info *inst, int pixels, int idx); + +extern void instance_slave_set_gbar_pos(struct inst_info *inst, double x, double y); +extern void instance_slave_get_gbar_pos(struct inst_info *inst, double *x, double *y); + +extern int instance_slave_open_gbar(struct inst_info *inst, struct client_node *client); +extern int instance_slave_close_gbar(struct inst_info *inst, struct client_node *client, int reason); + +extern int instance_freeze_updator(struct inst_info *inst); +extern int instance_thaw_updator(struct inst_info *inst); + +extern int instance_send_access_event(struct inst_info *inst, int status); + +extern int instance_widget_update_begin(struct inst_info *inst, double priority, const char *content, const char *title); +extern int instance_widget_update_end(struct inst_info *inst); + +extern int instance_gbar_update_begin(struct inst_info *inst); +extern int instance_gbar_update_end(struct inst_info *inst); + +extern void instance_gbar_updated(const char *pkgname, const char *id, const char *descfile, int x, int y, int w, int h); +extern void instance_widget_updated_by_instance(struct inst_info *inst, const char *safe_file, int x, int y, int w, int h); +extern void instance_gbar_updated_by_instance(struct inst_info *inst, const char *descfile, int x, int y, int w, int h); +extern void instance_extra_updated_by_instance(struct inst_info *inst, int is_gbar, int idx, int x, int y, int w, int h); +extern void instance_extra_info_updated_by_instance(struct inst_info *inst); + +/*! + * \note + * if the status is WIDGET_ERROR_FAULT (slave is faulted) + * even though the GBAR is not created, this will forcely send the GBAR_DESTROYED event to the client. + */ +extern int instance_client_gbar_destroyed(struct inst_info *inst, int status); +extern int instance_client_gbar_created(struct inst_info *inst, int status); + +extern int instance_client_gbar_extra_buffer_created(struct inst_info *inst, int idx); +extern int instance_client_gbar_extra_buffer_destroyed(struct inst_info *inst, int idx); + +extern int instance_client_widget_extra_buffer_created(struct inst_info *inst, int idx); +extern int instance_client_widget_extra_buffer_destroyed(struct inst_info *inst, int idx); + +extern int instance_send_access_status(struct inst_info *inst, int status); +extern int instance_send_key_status(struct inst_info *inst, int status); +extern int instance_forward_packet(struct inst_info *inst, struct packet *packet); + +extern struct client_node *instance_gbar_owner(struct inst_info *inst); + +/*! + * Multiple viewer + */ +extern int instance_add_client(struct inst_info *inst, struct client_node *client); +extern int instance_del_client(struct inst_info *inst, struct client_node *client); +extern int instance_has_client(struct inst_info *inst, struct client_node *client); +extern void *instance_client_list(struct inst_info *inst); + +extern int instance_init(void); +extern int instance_fini(void); + +extern int instance_event_callback_add(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data); +extern int instance_event_callback_del(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data); +extern int instance_event_callback_is_added(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data); + +/*! + */ +extern int instance_set_data(struct inst_info *inst, const char *tag, void *data); +extern void *instance_del_data(struct inst_info *inst, const char *tag); +extern void *instance_get_data(struct inst_info *inst, const char *tag); + +extern void instance_reload_period(struct inst_info *inst, double period); + +/** + * For the hello_sync or prepare_hello_sync command + */ +extern struct packet *instance_duplicate_packet_create(const struct packet *packet, struct inst_info *inst, struct pkg_info *info, int width, int height); +extern struct packet *instance_watch_create(const struct packet *packet, const char *pkgname, int width, int height); + +extern void instance_set_orientation(struct inst_info *inst, int orientation); +extern int instance_orientation(struct inst_info *inst); + +/* End of a file */ diff --git a/include/io.h b/include/io.h new file mode 100644 index 0000000..a2e15ba --- /dev/null +++ b/include/io.h @@ -0,0 +1,25 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int io_init(void); +extern int io_fini(void); +extern int io_load_package_db(struct pkg_info *info); +extern char *io_widget_pkgname(const char *pkgname); +extern int io_update_widget_package(const char *pkgname, int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data); +extern int io_crawling_widgetes(int (*cb)(const char *pkgid, const char *lbid, int prime, void *data), void *data); +extern int io_is_exists(const char *lbid); + +/* End of a file */ diff --git a/include/lite-errno.h b/include/lite-errno.h new file mode 100644 index 0000000..c5cb74e --- /dev/null +++ b/include/lite-errno.h @@ -0,0 +1,64 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __WIDGET_ERRNO_H +#define __WIDGET_ERRNO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_WIDGET_SERVICE_MODULE + * @{ + */ + +/** + * @brief + * Definitions for the result status of widget operation. + */ +#if 0 +enum widget_status { + WIDGET_ERROR_NONE = 0x00000000, /**< Operation is successfully completed */ + WIDGET_STATUS_ERROR = 0x80000000, /**< This will be OR'd with other specific error value */ + WIDGET_ERROR_INVALID_PARAMETER = WIDGET_STATUS_ERROR | 0x0001, /**< Invalid request */ + WIDGET_ERROR_FAULT = WIDGET_STATUS_ERROR | 0x0002, /**< Fault - Unable to recover from the error */ + WIDGET_ERROR_OUT_OF_MEMORY = WIDGET_STATUS_ERROR | 0x0004, /**< Memory is not enough to do this operation */ + WIDGET_ERROR_ALREADY_EXIST = WIDGET_STATUS_ERROR | 0x0008, /**< Already exists */ + WIDGET_ERROR_RESOURCE_BUSY = WIDGET_STATUS_ERROR | 0x0010, /**< Busy so the operation is not started(accepted), try again */ + WIDGET_ERROR_PERMISSION_DENIED = WIDGET_STATUS_ERROR | 0x0020, /**< Permission error */ + WIDGET_ERROR_ALREADY = WIDGET_STATUS_ERROR | 0x0040, /**< Operation is already started */ + WIDGET_ERROR_CANCELED = WIDGET_STATUS_ERROR | 0x0080, /**< Operation is canceled */ + WIDGET_ERROR_IO_ERROR = WIDGET_STATUS_ERROR | 0x0100, /**< I/O Error */ + WIDGET_ERROR_NOT_EXIST = WIDGET_STATUS_ERROR | 0x0200, /**< Not exists */ + WIDGET_ERROR_TIMEOUT = WIDGET_STATUS_ERROR | 0x0400, /**< Timeout */ + WIDGET_ERROR_NOT_SUPPORTED = WIDGET_STATUS_ERROR | 0x0800, /**< Operation is not implemented */ + WIDGET_ERROR_NO_SPACE = WIDGET_STATUS_ERROR | 0x1000, /**< No space to operate */ + WIDGET_ERROR_DISABLED = WIDGET_STATUS_ERROR | 0x2000 /**< Disabled */ +}; +#endif + +/*! + * \} + */ + +#ifdef __cplusplus +} +#endif + +#endif +/* End of a file */ + diff --git a/include/main.h b/include/main.h new file mode 100644 index 0000000..67a71d8 --- /dev/null +++ b/include/main.h @@ -0,0 +1,16 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + diff --git a/include/monitor.h b/include/monitor.h new file mode 100644 index 0000000..c08bc2d --- /dev/null +++ b/include/monitor.h @@ -0,0 +1,35 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +enum monitor_event_type { + MONITOR_EVENT_UNKNOWN = 0x0, + MONITOR_EVENT_CREATED = CMD_MONITOR_CREATE, + MONITOR_EVENT_DESTROYED = CMD_MONITOR_DESTROY, + MONITOR_EVENT_PAUSED = CMD_MONITOR_PAUSE, + MONITOR_EVENT_RESUMED = CMD_MONITOR_RESUME +}; + +struct monitor_client; + +extern struct monitor_client *monitor_create_client(const char *widget_id, pid_t pid, int handle); +extern int monitor_destroy_client(struct monitor_client *monitor); + +extern struct monitor_client *monitor_find_client_by_pid(const char *widget_id, pid_t pid); +extern struct monitor_client *monitor_find_client_by_handle(const char *widget_id, int handle); + +extern int monitor_multicast_state_change_event(const char *widget_id, enum monitor_event_type event, const char *instance_id, const char *content_info); + +/* End of a file */ diff --git a/include/notification_service.h b/include/notification_service.h new file mode 100644 index 0000000..e02dfa3 --- /dev/null +++ b/include/notification_service.h @@ -0,0 +1,20 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int notification_service_init(void); +extern int notification_service_fini(void); + +/* End of a file */ diff --git a/include/package.h b/include/package.h new file mode 100644 index 0000000..8922ac7 --- /dev/null +++ b/include/package.h @@ -0,0 +1,125 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +enum alter_type { + ALTER_CREATE, + ALTER_DESTROY +}; + +struct pkg_info; +struct inst_info; +struct context_info; +struct slave_node; + +/*! + * \brief + * Construction & Destruction + */ +extern struct pkg_info *package_create(const char *pkgid, const char *lbid); +extern int package_destroy(struct pkg_info *info); +extern char *package_widget_pkgname(const char *pkgname); +extern int package_is_widget_pkgname(const char *pkgname); +extern struct pkg_info *package_find(const char *pkgname); +extern const char *package_find_by_secured_slave(struct slave_node *slave); +extern struct inst_info *package_find_instance_by_id(const char *pkgname, const char *id); +extern struct inst_info *package_find_instance_by_timestamp(const char *pkgname, double timestamp); +extern int package_dump_fault_info(struct pkg_info *info); +extern int package_set_fault_info(struct pkg_info *info, double timestamp, const char *filename, const char *function); +extern int package_get_fault_info(struct pkg_info *info, double *timestmap, const char **filename, const char **function); +extern int package_set_category(struct pkg_info *info, const char *category); + +/*! + * \brief + * Readonly functions + */ +extern const int const package_is_fault(const struct pkg_info *info); +extern struct slave_node * const package_slave(const struct pkg_info *info); +extern const int const package_timeout(const struct pkg_info *info); +extern const double const package_period(const struct pkg_info *info); +extern const int const package_secured(const struct pkg_info *info); +extern const char * const package_script(const struct pkg_info *info); +extern const char * const package_abi(const struct pkg_info *info); +extern const char * const package_widget_path(const struct pkg_info *info); +extern const char * const package_widget_group(const struct pkg_info *info); +extern const char * const package_gbar_path(const struct pkg_info *info); +extern const char * const package_gbar_group(const struct pkg_info *info); +extern const int const package_pinup(const struct pkg_info *info); +extern const char * const package_auto_launch(const struct pkg_info *info); +extern const unsigned int const package_size_list(const struct pkg_info *info); +extern const int const package_gbar_width(const struct pkg_info *info); +extern const int const package_gbar_height(const struct pkg_info *info); +extern const char * const package_name(const struct pkg_info *info); +extern const char * const package_libexec(struct pkg_info *info); +extern const char *package_category(struct pkg_info *info); +extern int package_network(struct pkg_info *info); +extern Eina_List *package_ctx_info(struct pkg_info *pkginfo); + +extern int package_set_libexec(struct pkg_info *info, const char *libexec); +extern void package_set_pinup(struct pkg_info *info, int pinup); +extern void package_set_auto_launch(struct pkg_info *info, const char *auto_launch); +extern void package_set_size_list(struct pkg_info *info, unsigned int size_list); +extern void package_set_widget_type(struct pkg_info *info, enum widget_widget_type type); +extern void package_set_gbar_type(struct pkg_info *info, enum widget_gbar_type type); +extern int package_set_widget_group(struct pkg_info *info, const char *group); +extern int package_set_widget_path(struct pkg_info *info, const char *path); +extern int package_set_gbar_group(struct pkg_info *info, const char *group); +extern int package_set_gbar_path(struct pkg_info *info, const char *path); +extern int package_set_script(struct pkg_info *info, const char *script); +extern void package_set_secured(struct pkg_info *info, int secured); +extern void package_set_period(struct pkg_info *info, double period); +extern void package_set_timeout(struct pkg_info *info, int timeout); +extern void package_set_network(struct pkg_info *info, int network); +extern void package_set_gbar_height(struct pkg_info *info, int height); +extern void package_set_gbar_width(struct pkg_info *info, int width); +extern int package_set_abi(struct pkg_info *info, const char *abi); +extern void package_add_ctx_info(struct pkg_info *pkginfo, struct context_info *info); +extern void package_del_ctx_info(struct pkg_info *pkginfo, struct context_info *info); +extern void package_set_direct_input(struct pkg_info *info, int direct_input); +extern int package_direct_input(const struct pkg_info *info); +extern const char *package_hw_acceleration(struct pkg_info *info); +extern int package_set_hw_acceleration(struct pkg_info *info, const char *hw_acceleration); + +/*! + * \brief + * Reference counter + */ +extern struct pkg_info * const package_ref(struct pkg_info *info); +extern struct pkg_info * const package_unref(struct pkg_info *info); +extern const int const package_refcnt(const struct pkg_info *info); + +extern const enum widget_gbar_type const package_gbar_type(const struct pkg_info *info); +extern const enum widget_widget_type const package_widget_type(const struct pkg_info *info); + +extern int package_add_instance(struct pkg_info *info, struct inst_info *inst); +extern int package_del_instance(struct pkg_info *info, struct inst_info *inst); +extern Eina_List *package_instance_list(struct pkg_info *info); + +extern int package_clear_fault(struct pkg_info *info); +extern int package_alter_instances_to_client(struct client_node *client, enum alter_type alter); + +extern const Eina_List *package_list(void); +extern int const package_fault_count(struct pkg_info *info); + +extern int package_init(void); +extern int package_fini(void); + +extern int package_is_enabled(const char *appid); +extern int package_faulted(struct pkg_info *info, int broadcast); +extern char *package_get_pkgid(const char *appid); + +extern int package_del_instance_by_category(const char *category, const char *except_widget_id); +extern int package_instance_count(struct pkg_info *info); +/* End of a file */ diff --git a/include/parser.h b/include/parser.h new file mode 100644 index 0000000..2fce3d8 --- /dev/null +++ b/include/parser.h @@ -0,0 +1,45 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct parser; + +extern struct parser *parser_load(const char *filename); +extern int parser_unload(struct parser *handle); +extern double parser_period(struct parser *handle); +extern int parser_network(struct parser *handle); +extern int parser_timeout(struct parser *handle); +extern const char *parser_auto_launch(struct parser *handle); +extern unsigned int parser_size(struct parser *handle); +extern void parser_get_gbar_size(struct parser *handle, unsigned int *width, unsigned int *height); +extern const char *parser_group_str(struct parser *handle); +extern int parser_secured(struct parser *handle); +extern int parser_pinup(struct parser *handler); + +extern const char *parser_widget_path(struct parser *handle); +extern const char *parser_widget_group(struct parser *handle); +extern const char *parser_gbar_path(struct parser *handle); +extern const char *parser_gbar_group(struct parser *handle); + +extern const char *parser_abi(struct parser *handle); + +extern int parser_text_gbar(struct parser *handle); +extern int parser_text_widget(struct parser *handle); +extern int parser_buffer_widget(struct parser *handle); +extern int parser_buffer_gbar(struct parser *handle); + +extern const char *parser_script(struct parser *handle); + +/* End of a file */ diff --git a/include/pkgmgr.h b/include/pkgmgr.h new file mode 100644 index 0000000..e4fe4c2 --- /dev/null +++ b/include/pkgmgr.h @@ -0,0 +1,40 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +enum pkgmgr_event_type { + PKGMGR_EVENT_DOWNLOAD, + PKGMGR_EVENT_INSTALL, + PKGMGR_EVENT_UPDATE, + PKGMGR_EVENT_UNINSTALL, + PKGMGR_EVENT_RECOVER +}; + +enum pkgmgr_status { + PKGMGR_STATUS_START, + PKGMGR_STATUS_PROCESSING, + PKGMGR_STATUS_COMMAND, + PKGMGR_STATUS_END, + PKGMGR_STATUS_ERROR +}; + +extern int pkgmgr_init(void); +extern int pkgmgr_fini(void); + +extern 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); + +extern 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); + +/* End of a file */ diff --git a/include/rpc_to_slave.h b/include/rpc_to_slave.h new file mode 100644 index 0000000..d80c021 --- /dev/null +++ b/include/rpc_to_slave.h @@ -0,0 +1,29 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int rpc_send_new(struct inst_info *inst, void (*ret_cb)(const char *funcname, GVariant *result, void *data), void *data, int skip_need_to_create); +extern int rpc_send_renew(struct inst_info *inst, void (*ret_cb)(const char *funcname, GVariant *result, void *data), void *data); + +extern void rpc_send_update_request(const char *pkgname, const char *cluster, const char *category); +/*! + * \brief + * \param[in] period if it is negative value, the data provider will use the default period + */ +extern struct inst_info *rpc_send_create_request(struct client_node *client, const char *pkgname, const char *content, const char *cluster, const char *category, double timestamp, double period); +extern void rpc_send_resume_request(void); +extern void rpc_send_pause_request(void); + +/* End of a file */ diff --git a/include/script_handler.h b/include/script_handler.h new file mode 100644 index 0000000..5e84f2b --- /dev/null +++ b/include/script_handler.h @@ -0,0 +1,39 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct script_info; +struct fb_info; + +extern struct script_info *script_handler_create(struct inst_info *inst, const char *file, const char *group, int w, int h); +extern int script_handler_destroy(struct script_info *info); +extern int script_handler_parse_desc(struct inst_info *inst, const char *descfile, int is_pd); +extern int script_handler_unload(struct script_info *info, int is_pd); +extern int script_handler_load(struct script_info *info, int is_pd); +extern int script_handler_is_loaded(struct script_info *info); +extern int script_handler_feed_event(struct script_info *info, int event, double timestamp); + +extern int script_init(void); +extern int script_fini(void); + +extern int script_signal_emit(void *buffer_handle, const char *part, const char *signal, double sx, double sy, double ex, double ey); + +extern int script_handler_update_pointer(struct script_info *inst, int x, int y, int down); +extern int script_handler_update_keycode(struct script_info *info, unsigned int keycode); +extern int script_handler_resize(struct script_info *info, int w, int h); +extern const char *script_handler_buffer_id(struct script_info *info); +extern struct buffer_info *script_handler_buffer_info(struct script_info *info); + +/* End of a file */ diff --git a/include/server.h b/include/server.h new file mode 100644 index 0000000..457ab15 --- /dev/null +++ b/include/server.h @@ -0,0 +1,20 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int server_init(void); +extern int server_fini(void); + +/* End of a file */ diff --git a/include/service_common.h b/include/service_common.h new file mode 100644 index 0000000..93c951b --- /dev/null +++ b/include/service_common.h @@ -0,0 +1,63 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +enum tcb_type { + TCB_CLIENT_TYPE_APP = 0x00, + TCB_CLIENT_TYPE_SERVICE = 0x01, + TCB_CLIENT_TYPE_UNKNOWN = 0xff +}; + +enum tcb_event_type { + TCB_EVENT_CREATE = 0x01, + TCB_EVENT_DESTROY = 0x02 +}; + +struct tcb; +struct service_context; +struct service_event_item; + +extern int tcb_fd(struct tcb *tcb); + +/*! + * \remarks This function will return valid pid only after it gets the packet from a client. + * or it will returns -1. + * \param[in] Thread Control Block + * \return pid Process Id + * \retval -1 TCB is not valid or the client is remote host. so we cannot get the PID of it. + * \retval >0 Process Id (PID) + */ +extern int tcb_pid(struct tcb *tcb); + +extern struct service_context *tcb_svc_ctx(struct tcb *tcb); +extern int tcb_client_type(struct tcb *tcb); +extern int tcb_client_type_set(struct tcb *tcb, enum tcb_type type); +extern int tcb_is_valid(struct service_context *svc_ctx, struct tcb *tcb); + +extern struct service_context *service_common_create(const char *addr, const char *label, int (*service_thread_main)(struct tcb *tcb, struct packet *packet, void *data), void *data); +extern int service_common_destroy(struct service_context *svc_ctx); + +extern int service_common_multicast_packet(struct tcb *tcb, struct packet *packet, int type); +extern int service_common_unicast_packet(struct tcb *tcb, struct packet *packet); + +extern struct service_event_item *service_common_add_timer(struct service_context *svc_ctx, double timer, int (*timer_cb)(struct service_context *svc_cx, void *data), void *data); +extern int service_common_update_timer(struct service_event_item *item, double timer); +extern int service_common_del_timer(struct service_context *svc_ctx, struct service_event_item *item); + +extern int service_common_fd(struct service_context *ctx); + +extern int service_register_tcb_callback(struct service_context *svc_ctx, struct tcb *tcb, enum tcb_event_type event, void (*cb)(struct service_context *svc_ctx, struct tcb *tcb, void *data), void *data); +extern int service_unregister_tcb_callback(struct service_context *svc_ctx, struct tcb *tcb, enum tcb_event_type event, void (*cb)(struct service_context *svc_ctx, struct tcb *tcb, void *data), void *data); + +/* End of a file */ diff --git a/include/setting.h b/include/setting.h new file mode 100644 index 0000000..d2138a5 --- /dev/null +++ b/include/setting.h @@ -0,0 +1,31 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int setting_is_lcd_off(void); +extern int setting_init(void); +extern int setting_fini(void); + +enum oom_event_type { + OOM_TYPE_NORMAL = 0x00, + OOM_TYPE_LOW = 0x01, + OOM_ERROR = 0xFF +}; + +extern int setting_add_oom_event_callback(int (*handler)(enum oom_event_type type, void *data), void *data); +extern int setting_del_oom_event_callback(int (*handler)(enum oom_event_type type, void *data), void *data); +extern enum oom_event_type setting_oom_level(void); + +/* End of a file */ diff --git a/include/shortcut_service.h b/include/shortcut_service.h new file mode 100644 index 0000000..2810039 --- /dev/null +++ b/include/shortcut_service.h @@ -0,0 +1,20 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int shortcut_service_init(void); +extern int shortcut_service_fini(void); + +/* End of a file */ diff --git a/include/slave_life.h b/include/slave_life.h new file mode 100644 index 0000000..a2fce01 --- /dev/null +++ b/include/slave_life.h @@ -0,0 +1,221 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*! + * Managing the reference counter of a slave + */ + +struct slave_node; + +enum slave_event { + SLAVE_EVENT_ACTIVATE, + SLAVE_EVENT_DEACTIVATE, /* deactivate callback, can return REACTIVATE, DEFAULT */ + SLAVE_EVENT_DELETE, /* Callbacks for this event type, must has not to do something with slave object. + use this only for just notice the state of slave */ + SLAVE_EVENT_FAULT, /* Critical fault */ + + SLAVE_EVENT_PAUSE, + SLAVE_EVENT_RESUME, + + SLAVE_NEED_TO_REACTIVATE +}; + +enum slave_state { + /*! + * Launch the slave but not yet receives "hello" packet + */ + SLAVE_REQUEST_TO_LAUNCH, + + /*! + * \note + * Terminate the slave but not yet receives dead signal + */ + SLAVE_REQUEST_TO_TERMINATE, + + /*! + * \note + * No slave process exists, just slave object created + */ + SLAVE_TERMINATED, + + /*! + * \note + * State change request is sent, + */ + SLAVE_REQUEST_TO_PAUSE, + SLAVE_REQUEST_TO_RESUME, + + /*! + * \note + * Request an action for disconnecting to master from the provider side. + * This flag should be treated as an activated state. + */ + SLAVE_REQUEST_TO_DISCONNECT, + + /*! + * \note + * SLAVE_ACTIVATED = { SLAVE_PAUSED, SLAVE_RESUMED } + */ + SLAVE_PAUSED, + SLAVE_RESUMED, + + SLAVE_ERROR = 0xFF /* Explicitly define the size of this enum type */ +}; + +enum PROVIDER_CTRL { + PROVIDER_CTRL_DEFAULT = 0x00, /*!< Set default control operation */ + PROVIDER_CTRL_MANUAL_TERMINATION = 0x01, /*!< Terminate process manually */ + PROVIDER_CTRL_MANUAL_REACTIVATION = 0x02, /*!< Reactivate process manually */ +}; + +extern struct slave_node *slave_ref(struct slave_node *slave); +extern struct slave_node *slave_unref(struct slave_node *slave); +extern const int const slave_refcnt(struct slave_node *slave); + +/*! + * \brief + * Create a new slave object or destroy it + * + * \param[in] name + * \param[in] is_secured + * \param[in] abi + * \param[in] pkgname + * \param[in] period + * \return slave_node + */ +extern struct slave_node *slave_create(const char *name, int is_secured, const char *abi, const char *pkgname, int network, const char *hw_acceleration, int launch_async); + +/*! + * \brief + * \param[in] slave + * \return void + */ +extern void slave_destroy(struct slave_node *slave); + +/*! + * \brief + * Launch or terminate a slave + * \param[in] slave + * \return int + */ +extern int slave_activate(struct slave_node *slave); + +/*! + * To check the slave's activation state + */ +extern const int const slave_is_activated(struct slave_node *slave); +extern int slave_activated(struct slave_node *slave); + +extern int slave_give_more_ttl(struct slave_node *slave); +extern int slave_freeze_ttl(struct slave_node *slave); +extern int slave_thaw_ttl(struct slave_node *slave); +extern int slave_expired_ttl(struct slave_node *slave); + +/*! + * \NOTE + * To mangage the unexpected termination of a slave + * After this function call, the slave object can be deleted + */ +extern struct slave_node *slave_deactivated_by_fault(struct slave_node *slave) __attribute__((warn_unused_result)); + +/*! + * \NOTE + * After this function, the slave object can be deleted + */ +extern struct slave_node *slave_deactivated(struct slave_node *slave) __attribute__((warn_unused_result)); + +extern int slave_event_callback_add(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data); +extern int slave_event_callback_del(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data); + +extern int slave_set_data(struct slave_node *slave, const char *tag, void *data); +extern void *slave_del_data(struct slave_node *slave, const char *tag); +extern void *slave_data(struct slave_node *slave, const char *tag); + +extern struct slave_node *slave_find_by_pid(pid_t pid); +extern struct slave_node *slave_find_by_name(const char *name); +extern struct slave_node *slave_find_by_pkgname(const char *pkgname); +extern struct slave_node *slave_find_by_rpc_handle(int handle); + +extern void slave_dead_handler(struct slave_node *slave); +extern const int const slave_is_secured(const struct slave_node *slave); +extern const int const slave_is_app(const struct slave_node *slave); +extern const char * const slave_name(const struct slave_node *slave); +extern const pid_t const slave_pid(const struct slave_node *slave); +extern const char * const slave_abi(const struct slave_node *slave); +extern int slave_set_pid(struct slave_node *slave, pid_t pid); + +/*! + * \note + * Used for making decision of destroying a slave or not + * Used for balancing load of the slave. + */ +extern void slave_load_package(struct slave_node *slave); +extern void slave_unload_package(struct slave_node *slave); +extern int const slave_loaded_package(struct slave_node *slave); +extern struct slave_node *slave_find_available(const char *slave_pkgname, const char *abi, int secured, int network, const char *hw_acceleration); + +extern double const slave_ttl(const struct slave_node *slave); + +/*! + * \note + * Used for making decision of activating a slave or not + */ +extern void slave_load_instance(struct slave_node *slave); + +/*! + * \NOTE + * After this function call, the slave object can be deleted. + */ +extern struct slave_node *slave_unload_instance(struct slave_node *slave) __attribute__((warn_unused_result)); + +extern int const slave_loaded_instance(struct slave_node *slave); + +extern int slave_resume(struct slave_node *slave); +extern int slave_pause(struct slave_node *slave); + +extern const char *slave_pkgname(const struct slave_node *slave); +extern const char *slave_state_string(const struct slave_node *slave); + +extern enum slave_state slave_state(const struct slave_node *slave); +extern void slave_set_state(struct slave_node *slave, enum slave_state state); + +extern const void *slave_list(void); +extern int const slave_fault_count(const struct slave_node *slave); + +extern int slave_need_to_reactivate_instances(struct slave_node *slave); +extern void slave_set_reactivate_instances(struct slave_node *slave, int reactivate); + +extern void slave_set_reactivation(struct slave_node *slave, int flag); +extern int slave_need_to_reactivate(struct slave_node *slave); + +extern int slave_network(const struct slave_node *slave); +extern void slave_set_network(struct slave_node *slave, int network); + +extern int slave_deactivate_all(int reactivate, int reactivate_instances, int no_timer); +extern int slave_activate_all(void); + +extern void slave_set_control_option(struct slave_node *slave, int ctrl); +extern int slave_control_option(struct slave_node *slave); + +extern char *slave_package_name(const char *abi, const char *lbid); + +extern int slave_priority(struct slave_node *slave); +extern int slave_set_priority(struct slave_node *slave, int priority); + +extern int slave_valid(const struct slave_node *slave); +extern void slave_set_valid(struct slave_node *slave); + +/* End of a file */ diff --git a/include/slave_rpc.h b/include/slave_rpc.h new file mode 100644 index 0000000..6784b94 --- /dev/null +++ b/include/slave_rpc.h @@ -0,0 +1,32 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int slave_rpc_async_request(struct slave_node *slave, const char *pkgname, struct packet *packet, void (*ret_cb)(struct slave_node *slave, const struct packet *packet, void *data), void *data, int urgent); +extern int slave_rpc_request_only(struct slave_node *slave, const char *pkgname, struct packet *packet, int urgent); + +extern int slave_rpc_update_handle(struct slave_node *slave, int handle, int delete_pending_packet); +extern int slave_rpc_ping(struct slave_node *slave); +extern void slave_rpc_request_update(const char *pkgname, const char *id, const char *cluster, const char *category, const char *content, int force); +extern int slave_rpc_handle(struct slave_node *slave); +extern int slave_rpc_ping_freeze(struct slave_node *slave); +extern int slave_rpc_ping_thaw(struct slave_node *slave); + +extern int slave_rpc_disconnect(struct slave_node *slave); + +extern int slave_rpc_init(struct slave_node *slave); +extern int slave_rpc_fini(struct slave_node *slave); + +/* End of a file */ diff --git a/include/util.h b/include/util.h new file mode 100644 index 0000000..132bfda --- /dev/null +++ b/include/util.h @@ -0,0 +1,87 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern unsigned long util_string_hash(const char *str); +extern double util_timestamp(void); +extern int util_check_ext(const char *filename, const char *check_ptr); +extern int util_unlink(const char *filename); +extern int util_unlink_files(const char *folder); +extern char *util_slavename(void); +extern const char *util_basename(const char *name); +extern unsigned long long util_free_space(const char *path); +extern void *util_timer_add(double interval, Eina_Bool (*cb)(void *data), void *data); +extern void util_timer_interval_set(void *timer, double interval); +extern double util_time_delay_for_compensation(double period); +extern void util_setup_log_disk(void); +extern void util_remove_emergency_disk(void); +extern void util_prepare_emergency_disk(void); +extern int util_emergency_disk_is_mounted(void); +extern int util_service_is_enabled(const char *tag); +extern int util_string_is_in_list(const char *str, const char *haystack); + +extern int util_screen_size_get(int *width, int *height); +extern int util_screen_init(void); +extern int util_screen_fini(void); + +#define SCHEMA_FILE "file://" +#define SCHEMA_PIXMAP "pixmap://" +#define SCHEMA_SHM "shm://" + +#define CRITICAL_SECTION_BEGIN(handle) \ +do { \ + int ret; \ + ret = pthread_mutex_lock(handle); \ + if (ret != 0) \ + ErrPrint("pthread_mutex_lock: %d\n", ret); \ +} while (0) + +#define CRITICAL_SECTION_END(handle) \ +do { \ + int ret; \ + ret = pthread_mutex_unlock(handle); \ + if (ret != 0) \ + ErrPrint("pthread_mutex_unlock: %d\n", ret); \ +} while (0) + +#define CANCEL_SECTION_BEGIN() do { \ + int ret; \ + ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); \ + if (ret != 0) \ + ErrPrint("Unable to set cancelate state: %d\n", ret); \ +} while (0) + +#define CANCEL_SECTION_END() do { \ + int ret; \ + ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); \ + if (ret != 0) \ + ErrPrint("Unable to set cancelate state: %d\n", ret); \ +} while (0) + +#define CLOSE_PIPE(p) do { \ + int status; \ + status = close(p[PIPE_READ]); \ + if (status < 0) \ + ErrPrint("close: %d\n", errno); \ + status = close(p[PIPE_WRITE]); \ + if (status < 0) \ + ErrPrint("close: %d\n", errno); \ +} while (0) + +#define PIPE_READ 0 +#define PIPE_WRITE 1 +#define PIPE_MAX 2 + +/* End of a file */ diff --git a/include/utility_service.h b/include/utility_service.h new file mode 100644 index 0000000..db80cd0 --- /dev/null +++ b/include/utility_service.h @@ -0,0 +1,21 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +extern int utility_service_init(void); +extern int utility_service_fini(void); + +/* End of a file */ + diff --git a/include/widget-mgr.h b/include/widget-mgr.h new file mode 100644 index 0000000..7061548 --- /dev/null +++ b/include/widget-mgr.h @@ -0,0 +1,35 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct widget_mgr; + +extern int widget_mgr_init(void); +extern void widget_mgr_fini(void); +extern struct widget_mgr *widget_mgr_create(pid_t pid, int handle); +extern void widget_mgr_destroy(struct widget_mgr *info); + +extern struct widget_mgr *widget_mgr_find_by_pid(pid_t pid); +extern struct widget_mgr *widget_mgr_find_by_handle(int handle); + +extern const char *widget_mgr_filename(struct widget_mgr *info); +extern pid_t widget_mgr_pid(struct widget_mgr *info); +extern FILE *widget_mgr_fifo(struct widget_mgr *info); +extern int widget_mgr_open_fifo(struct widget_mgr *info); +extern void widget_mgr_close_fifo(struct widget_mgr *info); +extern void widget_mgr_set_data(struct widget_mgr *info, void *data); +extern void *widget_mgr_data(struct widget_mgr *info); + +/* End of a file */ diff --git a/include/xmonitor.h b/include/xmonitor.h new file mode 100644 index 0000000..3e01722 --- /dev/null +++ b/include/xmonitor.h @@ -0,0 +1,34 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +enum xmonitor_event { + XMONITOR_PAUSED, + XMONITOR_RESUMED, + + XMONITOR_ERROR = 0xFFFFFFFF /* To specify the size of this enum */ +}; + +extern int xmonitor_init(void); +extern void xmonitor_fini(void); +extern int xmonitor_update_state(int pid); +extern int xmonitor_add_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data); +extern int xmonitor_del_event_callback(enum xmonitor_event event, int (*cb)(void *user_data), void *user_data); +extern int xmonitor_is_paused(void); +extern void xmonitor_handle_state_changes(void); +extern int xmonitor_resume(struct client_node *client); +extern int xmonitor_pause(struct client_node *client); + +/* End of a file */ diff --git a/packaging/data-provider-master.changes b/packaging/data-provider-master.changes new file mode 100644 index 0000000..5e22b27 --- /dev/null +++ b/packaging/data-provider-master.changes @@ -0,0 +1,8 @@ +* Wed Sep 11 2013 Rusty Lynch accepted/tizen/20130620.160431@d15ede1 +- Add support for systemd socket activation for notification service + +* Thu Jun 20 2013 Victor Hakoun accepted/tizen/20130620.115235@e8bd452 +- Replace manifest with default floor + +* Fri Jun 07 2013 Victor Hakoun accepted/tizen/20130530.164904@68752b5 +- Fix build x86_64 diff --git a/packaging/data-provider-master.manifest b/packaging/data-provider-master.manifest new file mode 100644 index 0000000..850aa0a --- /dev/null +++ b/packaging/data-provider-master.manifest @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec new file mode 100644 index 0000000..51eae2e --- /dev/null +++ b/packaging/data-provider-master.spec @@ -0,0 +1,203 @@ +%bcond_with wayland + +Name: data-provider-master +Summary: Master service provider for widgetes +Version: 1.1.5 +Release: 1 +Group: HomeTF/widget +License: Flora +Source0: %{name}-%{version}.tar.gz +Source1001: %{name}.manifest +BuildRequires: cmake, gettext-tools, smack, coreutils +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(aul) +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(sqlite3) +BuildRequires: pkgconfig(db-util) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gio-2.0) +BuildRequires: pkgconfig(libsmack) +BuildRequires: pkgconfig(bundle) + +%if %{with wayland} +BuildRequires: pkgconfig(ecore-wayland) +%else +BuildRequires: pkgconfig(ecore-x) +BuildRequires: pkgconfig(x11) +BuildRequires: pkgconfig(libdri2) +BuildRequires: pkgconfig(libdrm) +BuildRequires: pkgconfig(libtbm) +BuildRequires: pkgconfig(xfixes) +BuildRequires: pkgconfig(dri2proto) +BuildRequires: pkgconfig(xext) +BuildRequires: pkgconfig(xdamage) +%endif + +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(eina) +BuildRequires: pkgconfig(com-core) +BuildRequires: pkgconfig(libxml-2.0) +BuildRequires: pkgconfig(pkgmgr) +BuildRequires: pkgconfig(pkgmgr-info) +BuildRequires: pkgconfig(widget_service) +BuildRequires: pkgconfig(notification) +BuildRequires: pkgconfig(notification-service) +BuildRequires: pkgconfig(badge) +BuildRequires: pkgconfig(badge-service) +BuildRequires: pkgconfig(shortcut) +BuildRequires: pkgconfig(security-server) +BuildRequires: pkgconfig(libsystemd-daemon) +BuildRequires: model-build-features +Requires(post): sys-assert +Requires(post): dbus + +%description +Manage the 2nd stage widget service provider and communicate with the viewer application. +Keep trace on the life-cycle of the widget and status of the service providers, viewer applications. + +%prep +%setup -q +cp %{SOURCE1001} . + +%build +%if 0%{?sec_build_binary_debug_enable} +export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" +export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" +%endif + +export ENGINEER=false +%if 0%{?tizen_build_binary_release_type_eng} +export CFLAGS="${CFLAGS} -DTIZEN_ENGINEER_MODE" +export CXXFLAGS="${CXXFLAGS} -DTIZEN_ENGINEER_MODE" +export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE" +export ENGINEER=true +%endif + +%if %{with wayland} +export WAYLAND_SUPPORT=On +export X11_SUPPORT=Off +export LIVEBOX_SHM=wayland +%else +export WAYLAND_SUPPORT=Off +export X11_SUPPORT=On +export LIVEBOX_SHM=x11 +%endif + +%if "%{_repository}" == "wearable" +export LIVEBOX_SHM="${LIVEBOX_SHM}.wearable" +export MOBILE=Off +export WEARABLE=On +%else +export LIVEBOX_SHM="${LIVEBOX_SHM}.mobile" +export MOBILE=On +export WEARABLE=Off +%endif + +export LIVEBOX_SHM="${LIVEBOX_SHM}.480x800" +export LIVEBOX=On + +%ifarch %ix86 +export TARGET=emulator +%else +export TARGET=device +%endif + +%cmake . -DNAME=%{name} -DPRODUCT=${LIVEBOX_SHM} -DENGINEER_BINARY=${ENGINEER} -DWAYLAND_SUPPORT=${WAYLAND_SUPPORT} -DX11_SUPPORT=${X11_SUPPORT} -DMOBILE=${MOBILE} -DWEARABLE=${WEARABLE} -DLIVEBOX=${LIVEBOX} -DTARGET=${TARGET} + +CFLAGS="${CFLAGS} -Wall -Winline -Werror" LDFLAGS="${LDFLAGS}" make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install +mkdir -p %{buildroot}/%{_datarootdir}/license +mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants +ln -sf ../%{name}.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/%{name}.service +mkdir -p %{buildroot}/opt/usr/share/live_magazine +mkdir -p %{buildroot}/opt/usr/share/live_magazine/log +mkdir -p %{buildroot}/opt/usr/share/live_magazine/reader +mkdir -p %{buildroot}/opt/usr/share/live_magazine/always +mkdir -p %{buildroot}/opt/usr/devel/usr/bin +mkdir -p %{buildroot}/opt/dbspace + +echo "widget DB file is not exists, initiate it" +sqlite3 %{buildroot}/opt/dbspace/.widget.db-new < 755) +chmod 755 /opt/usr/share/live_magazine +chown ${APP_UID}:${APP_GID} /opt/usr/share/live_magazine/log +chmod 750 /opt/usr/share/live_magazine/log +chown ${APP_UID}:${APP_GID} /opt/usr/share/live_magazine/reader +chmod 750 /opt/usr/share/live_magazine/reader +chown ${APP_UID}:${APP_GID} /opt/usr/share/live_magazine/always +chmod 750 /opt/usr/share/live_magazine/always +chown ${SYSTEM}:${APP_GID} /opt/dbspace/.widget.db +chmod 640 /opt/dbspace/.widget.db +chown ${SYSTEM}:${APP_GID} /opt/dbspace/.widget.db-journal +chmod 640 /opt/dbspace/.widget.db-journal + +vconftool set -t bool "memory/%{name}/started" 0 -i -u ${APP_UID} -f -s system::vconf_system +vconftool set -t int "memory/private/%{name}/restart_count" 0 -i -u ${APP_UID} -f -s %{name} +vconftool set -t string "db/%{name}/serveraddr" "/opt/usr/share/live_magazine/.client.socket" -i -u ${APP_UID} -f -s system::vconf_system + +echo "Successfully installed. Please start a daemon again manually" + +%files -n %{name} +%manifest %{name}.manifest +%defattr(-,system,system,-) +%caps(cap_chown,cap_dac_override,cap_dac_read_search,cap_sys_admin,cap_sys_nice,cap_mac_override,cap_mac_admin+ep) %{_bindir}/%{name} +%{_libdir}/systemd/system/multi-user.target.wants/%{name}.service +%{_libdir}/systemd/system/%{name}.service +%{_datarootdir}/license/* +%if 0%{?tizen_build_binary_release_type_eng} +/opt/usr/devel/usr/bin/* +%endif +%{_prefix}/etc/package-manager/parserlib/* +%{_datarootdir}/%{name}/* +/opt/etc/dump.d/module.d/dump_widget.sh +/opt/usr/share/live_magazine/* +/opt/dbspace/.widget.db* +%{_sysconfdir}/smack/accesses.d/%{name} + +# End of a file diff --git a/pkgmgr_widget/CMakeLists.txt b/pkgmgr_widget/CMakeLists.txt new file mode 100644 index 0000000..dc47d02 --- /dev/null +++ b/pkgmgr_widget/CMakeLists.txt @@ -0,0 +1,27 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(pkgmgr_plugin C) + +INCLUDE(FindPkgConfig) +pkg_check_modules(bin_pkgs REQUIRED + dlog + sqlite3 + libxml-2.0 + db-util + widget_service +) + +FOREACH(flag ${bin_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Wall -Werror") +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common/include) + +ADD_SUBDIRECTORY(common) +ADD_SUBDIRECTORY(watch) +ADD_SUBDIRECTORY(widget) + +ADD_DEPENDENCIES("watch-application" "common") +ADD_DEPENDENCIES("widget" "common") + +# End of a file diff --git a/pkgmgr_widget/common/CMakeLists.txt b/pkgmgr_widget/common/CMakeLists.txt new file mode 100644 index 0000000..e946380 --- /dev/null +++ b/pkgmgr_widget/common/CMakeLists.txt @@ -0,0 +1,15 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(common C) + +ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) +ADD_LIBRARY(${PROJECT_NAME} STATIC + src/common.c + src/dlist.c +) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${bin_pkgs_LDFLAGS}) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION "etc/package-manager/parserlib") + +# End of a file diff --git a/pkgmgr_widget/common/include/common.h b/pkgmgr_widget/common/include/common.h new file mode 100644 index 0000000..9c2441a --- /dev/null +++ b/pkgmgr_widget/common/include/common.h @@ -0,0 +1,59 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include "dlist.h" + +#if !defined(FLOG) +#define DbgPrint(format, arg...) SECURE_LOGD("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg) +#define ErrPrint(format, arg...) SECURE_LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg) +#define ErrPrintWithConsole(format, arg...) do { fprintf(stderr, "[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); SECURE_LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); } while (0) +#endif + +#define CUR_VER 5 +#define DEFAULT_CATEGORY "http://tizen.org/category/default" + +extern int begin_transaction(void); +extern int commit_transaction(void); + +extern int pkglist_get_via_callback(const char *appid, int is_watch_widget, void (*cb)(const char *appid, const char *pkgid, int prime, void *data), void *data); + +extern void db_upgrade_db_schema(void); + +extern int db_install_widget(xmlNodePtr node, const char *appid); +extern int db_install_watchapp(xmlNodePtr node, const char *appid); +extern int db_init(void); +extern int db_fini(void); + +extern int db_check(void); +extern void delete_record_cb(const char *appid, const char *pkgid, int prime, void *data); + +/* End of a file */ diff --git a/pkgmgr_widget/common/include/dlist.h b/pkgmgr_widget/common/include/dlist.h new file mode 100644 index 0000000..cd1a421 --- /dev/null +++ b/pkgmgr_widget/common/include/dlist.h @@ -0,0 +1,43 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define dlist_remove_data(list, data) do { \ + struct dlist *l; \ + l = dlist_find_data(list, data); \ + list = dlist_remove(list, l); \ +} while (0) + +#define dlist_foreach(list, l, data) \ + for ((l) = (list); (l) && ((data) = dlist_data(l)); (l) = dlist_next(l)) + +#define dlist_foreach_safe(list, l, n, data) \ + for ((l) = (list), (n) = dlist_next(l); \ + (l) && ((data) = dlist_data(l)); \ + (l) = (n), (n) = dlist_next(l)) + +struct dlist; + +extern struct dlist *dlist_append(struct dlist *list, void *data); +extern struct dlist *dlist_prepend(struct dlist *list, void *data); +extern struct dlist *dlist_remove(struct dlist *list, struct dlist *l); +extern struct dlist *dlist_find_data(struct dlist *list, void *data); +extern void *dlist_data(struct dlist *l); +extern struct dlist *dlist_next(struct dlist *l); +extern struct dlist *dlist_prev(struct dlist *l); +extern int dlist_count(struct dlist *l); +extern struct dlist *dlist_nth(struct dlist *l, int nth); + +/* End of a file */ diff --git a/pkgmgr_widget/common/src/common.c b/pkgmgr_widget/common/src/common.c new file mode 100644 index 0000000..f1d24a3 --- /dev/null +++ b/pkgmgr_widget/common/src/common.c @@ -0,0 +1,3380 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "dlist.h" +#include "common.h" + +#if !defined(FLOG) +#define DbgPrint(format, arg...) SECURE_LOGD("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg) +#define ErrPrint(format, arg...) SECURE_LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg) +#define ErrPrintWithConsole(format, arg...) do { fprintf(stderr, "[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); SECURE_LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); } while (0) +#endif + +#define CUR_VER 5 +#define DEFAULT_CATEGORY "http://tizen.org/category/default" + +#if !defined(WIDGET_COUNT_OF_SIZE_TYPE) +#define WIDGET_COUNT_OF_SIZE_TYPE 13 +#endif + +/** + * @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_WIDGET2" + +int errno; + +struct i18n { + xmlChar *lang; + xmlChar *name; + xmlChar *icon; +}; + +struct widget { + 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 widget? */ + 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 widget */ + int default_touch_effect; + int default_need_frame; + + enum widget_widget_type widget_type; + xmlChar *widget_src; + xmlChar *widget_group; + int size_list; /* 1x1, 2x1, 2x2, 4x1, 4x2, 4x3, 4x4 */ + + xmlChar *preview[WIDGET_COUNT_OF_SIZE_TYPE]; + int touch_effect[WIDGET_COUNT_OF_SIZE_TYPE]; /* Touch effect of a widget */ + int need_frame[WIDGET_COUNT_OF_SIZE_TYPE]; /* Box needs frame which should be cared by viewer */ + int mouse_event[WIDGET_COUNT_OF_SIZE_TYPE]; + + enum widget_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/.widget.db", + .handle = NULL, +}; + +static inline int next_state(int from, char ch) +{ + switch (ch) { + case '\0': + case '/': + return 1; + case '.': + if (from == 1) { + return 2; + } + if (from == 2) { + return 3; + } + } + + return 4; +} + +static inline void abspath(const char* pBuffer, char* pRet) +{ + int idx=0; + int state = 1; + int from; + int src_idx = 0; + int src_len = strlen(pBuffer); + pRet[idx] = '/'; + idx ++; + + while (src_idx <= src_len) { + from = state; + state = next_state(from, pBuffer[src_idx]); + + switch (from) { + case 1: + if (state != 1) { + pRet[idx] = pBuffer[src_idx]; + idx++; + } + break; + case 2: + if (state == 1) { + if (idx > 1) { + idx--; + } + } else { + pRet[idx] = pBuffer[src_idx]; + idx++; + } + break; + case 3: + // Only can go to the 1 or 4 + if (state == 1) { + idx -= 2; + if (idx < 1) { + idx = 1; + } + + while (idx > 1 && pRet[idx] != '/') { + idx--; /* Remove .. */ + } + if (idx > 1 && pRet[idx] == '/') { + idx--; + } + while (idx > 1 && pRet[idx] != '/') { + idx--; /* Remove parent folder */ + } + } + case 4: + pRet[idx] = pBuffer[src_idx]; + idx++; + break; + } + + pRet[idx] = '\0'; + src_idx++; + } +} + +static inline xmlChar *abspath_strdup(xmlChar *src) +{ + return xmlMalloc(xmlStrlen(src) + 2); +} + +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; +} + +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 widget. + * Every widget 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; +} + +void db_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 widget *widget) +{ + static const char *dml; + int ret; + sqlite3_stmt *stmt; + char *abi = (char *)widget->abi; + char *box_src = (char *)widget->widget_src; + char *box_group = (char *)widget->widget_group; + char *gbar_src = (char *)widget->gbar_src; + char *gbar_group = (char *)widget->gbar_group; + char *libexec = (char *)widget->libexec; + char *timeout = (char *)widget->timeout; + char *period = (char *)widget->period; + char *script = (char *)widget->script; + char *hw_acceleration = (char *)widget->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 *)widget->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, widget->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, widget->secured); + if (ret != SQLITE_OK) { + ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle)); + ret = -EIO; + goto out; + } + + ret = sqlite3_bind_int(stmt, 5, widget->widget_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, widget->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, widget->pinup); + if (ret != SQLITE_OK) { + ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle)); + ret = -EIO; + goto out; + } + + ret = sqlite3_bind_int(stmt, 16, widget->count); + if (ret != SQLITE_OK) { + ErrPrintWithConsole("Error: %s\n", sqlite3_errmsg(s_info.handle)); + ret = -EIO; + goto out; + } + + ret = sqlite3_bind_int(stmt, 17, widget->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 widget *widget) +{ + 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 *)widget->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 *)widget->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 *)widget->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 *)widget->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 *)widget->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 *)widget->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, widget->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 *)widget->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(); +} + +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("%d\n", 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; +} + +int db_fini(void) +{ + if (!s_info.handle) { + return 0; + } + + db_util_close(s_info.handle); + s_info.handle = NULL; + + return 0; +} + +int db_check(void) +{ + if (s_info.handle == NULL) + { + return 0; + } + + return 1; +} + +static int validate_pkgid(const char *appid, const char *pkgid) +{ + /* Just return 1 Always */ + return 1 || !strncmp(appid, pkgid, strlen(appid)); +} + +static int widget_destroy(struct widget *widget) +{ + struct dlist *l; + struct dlist *n; + struct i18n *i18n; + struct group *group; + struct option *option; + struct dlist *il; + struct dlist *in; + + xmlFree(widget->auto_launch); + xmlFree(widget->pkgid); + xmlFree(widget->abi); + xmlFree(widget->name); + xmlFree(widget->icon); + xmlFree(widget->widget_src); + xmlFree(widget->widget_group); + xmlFree(widget->gbar_src); + xmlFree(widget->gbar_group); + xmlFree(widget->gbar_size); + xmlFree(widget->libexec); + xmlFree(widget->script); + xmlFree(widget->period); + xmlFree(widget->content); + xmlFree(widget->setup); + xmlFree(widget->category); + xmlFree(widget->preview[0]); /* 1x1 */ + xmlFree(widget->preview[1]); /* 2x1 */ + xmlFree(widget->preview[2]); /* 2x2 */ + xmlFree(widget->preview[3]); /* 4x1 */ + xmlFree(widget->preview[4]); /* 4x2 */ + xmlFree(widget->preview[5]); /* 4x3 */ + xmlFree(widget->preview[6]); /* 4x4 */ + xmlFree(widget->preview[7]); /* 4x5 */ + xmlFree(widget->preview[8]); /* 4x6 */ + xmlFree(widget->preview[9]); /* easy 1x1 */ + xmlFree(widget->preview[10]); /* easy 3x1 */ + xmlFree(widget->preview[11]); /* easy 3x3 */ + xmlFree(widget->preview[12]); /* full */ + xmlFree(widget->hw_acceleration); + + dlist_foreach_safe(widget->i18n_list, l, n, i18n) { + widget->i18n_list = dlist_remove(widget->i18n_list, l); + xmlFree(i18n->name); + xmlFree(i18n->icon); + xmlFree(i18n->lang); + free(i18n); + } + + dlist_foreach_safe(widget->group_list, l, n, group) { + widget->group_list = dlist_remove(widget->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(widget); + return 0; +} + +static void update_i18n_name(struct widget *widget, 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 (widget->name) { + DbgPrint("Override default name: %s\n", widget->name); + xmlFree(widget->name); + } + + widget->name = name; + return; + } + + dlist_foreach(widget->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("calloc: %d\n", errno); + xmlFree(name); + xmlFree(lang); + return; + } + + i18n->name = name; + i18n->lang = lang; + DbgPrint("Label[%s] - [%s] added\n", i18n->lang, i18n->name); + widget->i18n_list = dlist_append(widget->i18n_list, i18n); +} + +static void update_i18n_icon(struct widget *widget, 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 (widget->icon) { + DbgPrint("Override default icon: %s\n", widget->icon); + xmlFree(widget->icon); + } + + widget->icon = icon; + return; + } + + dlist_foreach(widget->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; + icon = abspath_strdup(i18n->icon); + if (!icon) { + ErrPrint("strdup: %d\n", errno); + } else { + abspath((char *)i18n->icon, (char *)icon); + xmlFree(i18n->icon); + i18n->icon = icon; + } + return; + } + } + + i18n = calloc(1, sizeof(*i18n)); + if (!i18n) { + ErrPrint("calloc: %d\n", errno); + xmlFree(icon); + xmlFree(lang); + return; + } + + i18n->icon = icon; + icon = abspath_strdup(i18n->icon); + if (!icon) { + ErrPrint("strdup: %d\n", errno); + } else { + abspath((char *)i18n->icon, (char *)icon); + xmlFree(i18n->icon); + i18n->icon = icon; + } + i18n->lang = lang; + DbgPrint("Icon[%s] - [%s] added\n", i18n->lang, i18n->icon); + widget->i18n_list = dlist_append(widget->i18n_list, i18n); +} + +static void update_launch(struct widget *widget, xmlNodePtr node) +{ + xmlChar *launch; + + launch = xmlNodeGetContent(node); + if (!launch) { + DbgPrint("Has no launch\n"); + return; + } + + if (widget->auto_launch) { + xmlFree(widget->auto_launch); + } + + widget->auto_launch = xmlStrdup(launch); + if (!widget->auto_launch) { + ErrPrint("Failed to duplicate string: %s\n", (char *)launch); + return; + } +} + +static int update_category(struct widget *widget, xmlNodePtr node) +{ + xmlChar *category; + + category = xmlGetProp(node, (const xmlChar *)"name"); + if (!category) { + DbgPrint("Has no valid category\n"); + return 0; + } + + if (!xmlStrcasecmp(category, (const xmlChar *)CATEGORY_WATCH_CLOCK)) { + ErrPrint("Widget tries to install WATCH: %s\n", widget->pkgid); + return -EINVAL; + } + + if (widget->category) { + xmlFree(widget->category); + } + + widget->category = xmlStrdup(category); + if (!widget->category) { + ErrPrint("Failed to duplicate string: %s\n", (char *)category); + return -EINVAL; + } + + return 0; +} + +static void update_ui_appid(struct widget *widget, xmlNodePtr node) +{ + xmlChar *uiapp; + uiapp = xmlNodeGetContent(node); + if (!uiapp) { + DbgPrint("Has no valid ui-appid\n"); + return; + } + + if (widget->uiapp) { + xmlFree(widget->uiapp); + } + + widget->uiapp = xmlStrdup(uiapp); + if (!widget->uiapp) { + ErrPrint("Failed to duplicate string: %s\n", (char *)uiapp); + return; + } +} + +static void update_setup(struct widget *widget, xmlNodePtr node) +{ + xmlChar *setup; + setup = xmlNodeGetContent(node); + if (!setup) { + DbgPrint("Has no setup\n"); + return; + } + + if (widget->setup) { + xmlFree(widget->setup); + } + + widget->setup = xmlStrdup(setup); + if (!widget->setup) { + ErrPrint("Failed to duplicate string: %s\n", (char *)setup); + return; + } +} + +static void update_content(struct widget *widget, xmlNodePtr node) +{ + xmlChar *content; + content = xmlNodeGetContent(node); + if (!content) { + DbgPrint("Has no content\n"); + return; + } + + if (widget->content) { + xmlFree(widget->content); + } + + widget->content = xmlStrdup(content); + if (!widget->content) { + ErrPrint("Failed to duplicate string: %s\n", (char *)content); + return; + } +} + +static void update_size_info(struct widget *widget, int idx, xmlNodePtr node) +{ + if (xmlHasProp(node, (const xmlChar *)"preview")) { + xmlChar *tmp_preview; + + widget->preview[idx] = xmlGetProp(node, (const xmlChar *)"preview"); + + tmp_preview = abspath_strdup(widget->preview[idx]); + if (!tmp_preview) { + ErrPrint("strdup: %d\n", errno); + } else { + abspath((char *)widget->preview[idx], (char *)tmp_preview); + xmlFree(widget->preview[idx]); + widget->preview[idx] = tmp_preview; + } + } + + if (xmlHasProp(node, (const xmlChar *)"need_frame")) { + xmlChar *need_frame; + + need_frame = xmlGetProp(node, (const xmlChar *)"need_frame"); + if (need_frame) { + widget->need_frame[idx] = !xmlStrcasecmp(need_frame, (const xmlChar *)"true"); + xmlFree(need_frame); + } else { + widget->need_frame[idx] = widget->default_need_frame; + } + } else { + widget->need_frame[idx] = widget->default_need_frame; + } + + if (xmlHasProp(node, (const xmlChar *)"touch_effect")) { + xmlChar *touch_effect; + + touch_effect = xmlGetProp(node, (const xmlChar *)"touch_effect"); + if (touch_effect) { + widget->touch_effect[idx] = !xmlStrcasecmp(touch_effect, (const xmlChar *)"true"); + xmlFree(touch_effect); + } else { + widget->touch_effect[idx] = widget->default_touch_effect; + } + } else { + widget->touch_effect[idx] = widget->default_touch_effect; + } + + if (xmlHasProp(node, (const xmlChar *)"mouse_event")) { + xmlChar *mouse_event; + + mouse_event = xmlGetProp(node, (const xmlChar *)"mouse_event"); + if (mouse_event) { + widget->mouse_event[idx] = !xmlStrcasecmp(mouse_event, (const xmlChar *)"true"); + xmlFree(mouse_event); + } else { + widget->mouse_event[idx] = widget->default_mouse_event; + } + } else { + widget->mouse_event[idx] = widget->default_mouse_event; + } +} + +static void update_box(struct widget *widget, xmlNodePtr node) +{ + if (!xmlHasProp(node, (const xmlChar *)"type")) { + widget->widget_type = WIDGET_TYPE_FILE; + } else { + xmlChar *type; + + type = xmlGetProp(node, (const xmlChar *)"type"); + if (!type) { + ErrPrint("Type is NIL\n"); + widget->widget_type = WIDGET_TYPE_FILE; + } else { + if (!xmlStrcasecmp(type, (const xmlChar *)"text")) { + widget->widget_type = WIDGET_TYPE_TEXT; + } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) { + widget->widget_type = WIDGET_TYPE_BUFFER; + } else if (!xmlStrcasecmp(type, (const xmlChar *)"script")) { + widget->widget_type = WIDGET_TYPE_SCRIPT; + } else if (!xmlStrcasecmp(type, (const xmlChar *)"elm")) { + widget->widget_type = WIDGET_TYPE_UIFW; + } else { /* Default */ + widget->widget_type = WIDGET_TYPE_FILE; + } + + xmlFree(type); + } + } + + if (!xmlHasProp(node, (const xmlChar *)"mouse_event")) { + widget->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"); + widget->default_mouse_event = 0; + } else { + widget->default_mouse_event = !xmlStrcasecmp(mouse_event, (const xmlChar *)"true"); + xmlFree(mouse_event); + } + } + + if (!xmlHasProp(node, (const xmlChar *)"touch_effect")) { + widget->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"); + widget->default_touch_effect = 1; + } else { + widget->default_touch_effect = !xmlStrcasecmp(touch_effect, (const xmlChar *)"true"); + xmlFree(touch_effect); + } + } + + if (!xmlHasProp(node, (const xmlChar *)"need_frame")) { + widget->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"); + widget->default_need_frame = 0; + } else { + widget->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) { + widget->size_list |= WIDGET_SIZE_TYPE_EASY_1x1; + update_size_info(widget, 9, node); + } else { + widget->size_list |= WIDGET_SIZE_TYPE_1x1; + update_size_info(widget, 0, node); + } + } else if (!xmlStrcasecmp(size, (const xmlChar *)"3x1")) { + if (is_easy) { + widget->size_list |= WIDGET_SIZE_TYPE_EASY_3x1; + update_size_info(widget, 10, node); + } else { + ErrPrint("Invalid size tag (%s)\n", size); + } + } else if (!xmlStrcasecmp(size, (const xmlChar *)"3x3")) { + if (is_easy) { + widget->size_list |= WIDGET_SIZE_TYPE_EASY_3x3; + update_size_info(widget, 11, node); + } else { + ErrPrint("Invalid size tag (%s)\n", size); + } + } else if (!xmlStrcasecmp(size, (const xmlChar *)"2x1")) { + widget->size_list |= WIDGET_SIZE_TYPE_2x1; + update_size_info(widget, 1, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"2x2")) { + widget->size_list |= WIDGET_SIZE_TYPE_2x2; + update_size_info(widget, 2, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x1")) { + widget->size_list |= WIDGET_SIZE_TYPE_4x1; + update_size_info(widget, 3, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x2")) { + widget->size_list |= WIDGET_SIZE_TYPE_4x2; + update_size_info(widget, 4, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x3")) { + widget->size_list |= WIDGET_SIZE_TYPE_4x3; + update_size_info(widget, 5, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x4")) { + widget->size_list |= WIDGET_SIZE_TYPE_4x4; + update_size_info(widget, 6, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x5")) { + widget->size_list |= WIDGET_SIZE_TYPE_4x5; + update_size_info(widget, 7, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"4x6")) { + widget->size_list |= WIDGET_SIZE_TYPE_4x6; + update_size_info(widget, 8, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"21x21")) { + widget->size_list |= WIDGET_SIZE_TYPE_EASY_1x1; + update_size_info(widget, 9, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"23x21")) { + widget->size_list |= WIDGET_SIZE_TYPE_EASY_3x1; + update_size_info(widget, 10, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"23x23")) { + widget->size_list |= WIDGET_SIZE_TYPE_EASY_3x3; + update_size_info(widget, 11, node); + } else if (!xmlStrcasecmp(size, (const xmlChar *)"0x0")) { + widget->size_list |= WIDGET_SIZE_TYPE_FULL; + update_size_info(widget, 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 (widget->widget_src) { + DbgPrint("Override lb src: %s\n", widget->widget_src); + xmlFree(widget->widget_src); + } + + widget->widget_src = src; + src = abspath_strdup(widget->widget_src); + if (!src) { + ErrPrint("strdup: %d\n", errno); + } else { + abspath((char *)widget->widget_src, (char *)src); + xmlFree(widget->widget_src); + widget->widget_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 (widget->widget_group) { + DbgPrint("Override lb group: %s\n", widget->widget_group); + xmlFree(widget->widget_group); + } + + widget->widget_group = group; + } + } + } + } +} + +static void update_group(struct widget *widget, 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("calloc: %d\n", errno); + xmlFree(category_name); + continue; + } + + group->cluster = xmlStrdup(cluster_name); + if (!group->cluster) { + ErrPrint("xmlStrdup: %d\n", errno); + xmlFree(category_name); + free(group); + continue; + } + + group->category = category_name; + widget->group_list = dlist_append(widget->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("calloc: %d\n", 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 void update_glance_bar(struct widget *widget, xmlNodePtr node) +{ + if (!xmlHasProp(node, (const xmlChar *)"type")) { + widget->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")) { + widget->gbar_type = GBAR_TYPE_TEXT; + } else if (!xmlStrcasecmp(type, (const xmlChar *)"buffer")) { + widget->gbar_type = GBAR_TYPE_BUFFER; + } else if (!xmlStrcasecmp(type, (const xmlChar *)"elm")) { + widget->gbar_type = GBAR_TYPE_UIFW; + } else { + widget->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 (widget->gbar_size) { + DbgPrint("Override pd size: %s\n", widget->gbar_size); + xmlFree(widget->gbar_size); + } + widget->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 (widget->gbar_src) { + DbgPrint("Overide PD src: %s\n", widget->gbar_src); + xmlFree(widget->gbar_src); + } + + widget->gbar_src = src; + src = abspath_strdup(widget->gbar_src); + if (!src) { + ErrPrint("strdup: %d\n", errno); + } else { + abspath((char *)widget->gbar_src, (char *)src); + xmlFree(widget->gbar_src); + widget->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 (widget->gbar_group) { + DbgPrint("Override PD group : %s\n", widget->gbar_group); + xmlFree(widget->gbar_group); + } + + widget->gbar_group = group; + } + } + } // script + } // for +} + +static int db_insert_widget(struct widget *widget, 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 *)widget->pkgid, (char *)widget->uiapp, widget->primary, (char *)widget->category); + if (ret < 0) { + goto errout; + } + + ret = db_insert_provider(widget); + if (ret < 0) { + goto errout; + } + + ret = db_insert_client(widget); + if (ret < 0) { + goto errout; + } + + dlist_foreach(widget->i18n_list, l, i18n) { + ret = db_insert_i18n((char *)widget->pkgid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_1x1) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_1x1, (char *)widget->preview[0], widget->touch_effect[0], widget->need_frame[0], widget->mouse_event[0]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_2x1) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_2x1, (char *)widget->preview[1], widget->touch_effect[1], widget->need_frame[1], widget->mouse_event[1]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_2x2) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_2x2, (char *)widget->preview[2], widget->touch_effect[2], widget->need_frame[2], widget->mouse_event[2]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_4x1) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x1, (char *)widget->preview[3], widget->touch_effect[3], widget->need_frame[3], widget->mouse_event[3]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_4x2) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x2, (char *)widget->preview[4], widget->touch_effect[4], widget->need_frame[4], widget->mouse_event[4]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_4x3) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x3, (char *)widget->preview[5], widget->touch_effect[5], widget->need_frame[5], widget->mouse_event[5]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_4x4) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x4, (char *)widget->preview[6], widget->touch_effect[6], widget->need_frame[6], widget->mouse_event[6]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_4x5) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x5, (char *)widget->preview[7], widget->touch_effect[7], widget->need_frame[7], widget->mouse_event[7]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_4x6) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_4x6, (char *)widget->preview[8], widget->touch_effect[8], widget->need_frame[8], widget->mouse_event[8]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_EASY_1x1) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_EASY_1x1, (char *)widget->preview[9], widget->touch_effect[9], widget->need_frame[9], widget->mouse_event[9]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_EASY_3x1) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_EASY_3x1, (char *)widget->preview[10], widget->touch_effect[10], widget->need_frame[10], widget->mouse_event[10]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_EASY_3x3) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_EASY_3x3, (char *)widget->preview[11], widget->touch_effect[11], widget->need_frame[11], widget->mouse_event[11]); + if (ret < 0) { + goto errout; + } + } + + if (widget->size_list & WIDGET_SIZE_TYPE_FULL) { + ret = db_insert_box_size((char *)widget->pkgid, WIDGET_SIZE_TYPE_FULL, (char *)widget->preview[12], widget->touch_effect[12], widget->need_frame[12], widget->mouse_event[12]); + if (ret < 0) { + goto errout; + } + } + + dlist_foreach(widget->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 *)widget->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 *)widget->pkgid, (char *)group->ctx_item); + if (ret < 0) { + goto errout; + } + + /* REUSE "id" from here , option ID */ + id = db_get_option_id(id, (char *)widget->pkgid, (char *)group->ctx_item); + if (id < 0) { + goto errout; + } + + dlist_foreach(group->option_list, il, option) { + ret = db_insert_option((char *)widget->pkgid, id, (char *)option->key, (char *)option->value); + if (ret < 0) { + goto errout; + } + } + } + + commit_transaction(); + widget_destroy(widget); + return 0; + +errout: + ErrPrint("ROLLBACK\n"); + rollback_transaction(); + widget_destroy(widget); + return ret; +} + +int db_install_widget(xmlNodePtr node, const char *appid) +{ + struct widget *widget; + 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); + + widget = calloc(1, sizeof(*widget)); + if (!widget) { + ErrPrint("calloc: %d\n", errno); + xmlFree(pkgid); + return -ENOMEM; + } + + widget->pkgid = pkgid; + + if (xmlHasProp(node, (const xmlChar *)"count")) { + tmp = xmlGetProp(node, (const xmlChar *)"count"); + if (tmp && sscanf((const char *)tmp, "%d", &widget->count) != 1) { + ErrPrint("Invalid syntax: %s\n", (const char *)tmp); + } + xmlFree(tmp); + } + + if (xmlHasProp(node, (const xmlChar *)"primary")) { + tmp = xmlGetProp(node, (const xmlChar *)"primary"); + widget->primary = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true"); + xmlFree(tmp); + } + + if (xmlHasProp(node, (const xmlChar *)"script")) { + widget->script = xmlGetProp(node, (const xmlChar *)"script"); + if (!widget->script) { + ErrPrint("script is NIL\n"); + } + } + + if (xmlHasProp(node, (const xmlChar *)"nodisplay")) { + tmp = xmlGetProp(node, (const xmlChar *)"nodisplay"); + widget->nodisplay = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true"); + xmlFree(tmp); + } + + if (xmlHasProp(node, (const xmlChar *)"pinup")) { + tmp = xmlGetProp(node, (const xmlChar *)"pinup"); + widget->pinup = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true"); + xmlFree(tmp); + } + + if (xmlHasProp(node, (const xmlChar *)"period")) { + widget->period = xmlGetProp(node, (const xmlChar *)"period"); + if (!widget->period) { + ErrPrint("Period is NIL\n"); + } + } + + if (xmlHasProp(node, (const xmlChar *)"timeout")) { + widget->timeout = xmlGetProp(node, (const xmlChar *)"timeout"); + if (!widget->timeout) { + ErrPrint("Timeout is NIL\n"); + } + } + + if (xmlHasProp(node, (const xmlChar *)"secured")) { + tmp = xmlGetProp(node, (const xmlChar *)"secured"); + widget->secured = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true"); + xmlFree(tmp); + } + + if (xmlHasProp(node, (const xmlChar *)"network")) { + tmp = xmlGetProp(node, (const xmlChar *)"network"); + widget->network = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true"); + xmlFree(tmp); + } + + if (xmlHasProp(node, (const xmlChar *)"direct_input")) { + tmp = xmlGetProp(node, (const xmlChar *)"direct_input"); + widget->direct_input = tmp && !xmlStrcasecmp(tmp, (const xmlChar *)"true"); + xmlFree(tmp); + } + + if (xmlHasProp(node, (const xmlChar *)"hw-acceleration")) { + widget->hw_acceleration = xmlGetProp(node, (const xmlChar *)"hw-acceleration"); + if (!widget->hw_acceleration) { + ErrPrint("hw-acceleration is NIL\n"); + } + } + + if (xmlHasProp(node, (const xmlChar *)"abi")) { + widget->abi = xmlGetProp(node, (const xmlChar *)"abi"); + if (!widget->abi) { + ErrPrint("ABI is NIL\n"); + widget_destroy(widget); + return -EFAULT; + } + } else { + widget->abi = xmlStrdup((const xmlChar *)"c"); + if (!widget->abi) { + ErrPrint("xmlstrdup: %d\n", errno); + widget_destroy(widget); + return -ENOMEM; + } + } + + if (xmlHasProp(node, (const xmlChar *)"libexec")) { + xmlChar *tmp_libexec; + + widget->libexec = xmlGetProp(node, (const xmlChar *)"libexec"); + if (!widget->libexec) { + ErrPrint("libexec is NIL\n"); + widget_destroy(widget); + return -EFAULT; + } + + tmp_libexec = abspath_strdup(widget->libexec); + if (!tmp_libexec) { + ErrPrint("strdup: %d\n", errno); + widget_destroy(widget); + return -EFAULT; + } + + abspath((char *)widget->libexec, (char *)tmp_libexec); + xmlFree(widget->libexec); + widget->libexec = tmp_libexec; + } else if (!xmlStrcasecmp(widget->abi, (const xmlChar *)"c") || !xmlStrcasecmp(widget->abi, (const xmlChar *)"cpp")) { + char *filename; + int len; + + len = strlen((char *)widget->pkgid) + strlen("/libexec/liblive-.so") + 1; + + filename = malloc(len); + if (!filename) { + widget_destroy(widget); + return -ENOMEM; + } + + snprintf(filename, len, "/libexec/liblive-%s.so", widget->pkgid); + widget->libexec = xmlStrdup((xmlChar *)filename); + DbgPrint("Use the default libexec: %s\n", filename); + free(filename); + + if (!widget->libexec) { + widget_destroy(widget); + 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(widget, node); + continue; + } + + if (!xmlStrcasecmp(node->name, (const xmlChar *)"icon")) { + update_i18n_icon(widget, node); + continue; + } + + if (!xmlStrcasecmp(node->name, (const xmlChar *)"box")) { + update_box(widget, node); + continue; + } + + if (!xmlStrcasecmp(node->name, (const xmlChar *)"glancebar")) { + update_glance_bar(widget, node); + continue; + } + + if (!xmlStrcasecmp(node->name, (const xmlChar *)"group")) { + update_group(widget, node); + continue; + } + + if (!xmlStrcasecmp(node->name, (const xmlChar *)"content")) { + update_content(widget, node); + continue; + } + + if (!xmlStrcasecmp(node->name, (const xmlChar *)"setup")) { + update_setup(widget, node); + continue; + } + + if (!xmlStrcasecmp(node->name, (const xmlChar *)"launch")) { + update_launch(widget, node); + continue; + } + + if (!xmlStrcasecmp(node->name, (const xmlChar *)"ui-appid")) { + update_ui_appid(widget, node); + continue; + } + + if (!xmlStrcasecmp(node->name, (const xmlChar *)"category")) { + if (update_category(widget, node) < 0) { + widget_destroy(widget); + return -EINVAL; + } + + continue; + } + } + + return db_insert_widget(widget, appid); +} + +int db_install_watchapp(xmlNodePtr node, const char *appid) +{ + struct widget *widget; + xmlChar *pkgid; + + 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); + + widget = calloc(1, sizeof(*widget)); + if (!widget) { + ErrPrint("strdup: %d\n", errno); + xmlFree(pkgid); + return -ENOMEM; + } + + widget->pkgid = pkgid; + + widget->primary = 1; + widget->secured = 1; + widget->nodisplay = 1; + widget->hw_acceleration = xmlStrdup((const xmlChar *)"use-sw"); //use-gl + widget->abi = xmlStrdup((const xmlChar *)"app"); + widget->category = xmlStrdup((const xmlChar *)CATEGORY_WATCH_CLOCK); + + widget->widget_type = WIDGET_TYPE_BUFFER; + widget->default_mouse_event = 1; + widget->default_touch_effect = 0; + widget->default_need_frame = 0; + widget->size_list = WIDGET_SIZE_TYPE_2x2; + + if (xmlHasProp(node, (const xmlChar *)"exec")) { + widget->libexec = xmlGetProp(node, (const xmlChar *)"exec"); + if (!widget->libexec) { + ErrPrint("libexec is NIL\n"); + widget_destroy(widget); + return -EFAULT; + } + } + + 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(widget, node); + continue; + } + + if (!xmlStrcasecmp(node->name, (const xmlChar *)"icon")) { + update_i18n_icon(widget, node); + continue; + } + } + + return db_insert_widget(widget, appid); +} + +int db_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((const char *)pkgid); + if (ret < 0) { + goto errout; + } + + ret = db_remove_i18n((const char *)pkgid); + if (ret < 0) { + goto errout; + } + + ret = db_remove_client((const char *)pkgid); + if (ret < 0) { + goto errout; + } + + ret = db_remove_provider((const char *)pkgid); + if (ret < 0) { + goto errout; + } + + ret = db_remove_option((const char *)pkgid); + DbgPrint("Remove option: %d\n", ret); + + ret = db_remove_groupmap((const char *)pkgid); + DbgPrint("Remove groupmap: %d\n", ret); + + ret = db_remove_group((const char *)pkgid); + if (ret < 0) { + goto errout; + } + + ret = db_remove_pkgmap((const char *)pkgid); + if (ret < 0) { + goto errout; + } + + commit_transaction(); + xmlFree(pkgid); + + return 0; + +errout: + rollback_transaction(); + xmlFree(pkgid); + return ret; +} + +int pkglist_get_via_callback(const char *appid, int is_watch_widget, void (*cb)(const char *appid, const char *pkgid, int prime, void *data), void *data) +{ + const char *dml; + 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; + } + } + + if (is_watch_widget) { /* Watch */ + dml = "SELECT pkgid, prime FROM pkgmap WHERE appid = ? AND category = '" CATEGORY_WATCH_CLOCK "'"; + } else { /* Widget */ + dml = "SELECT pkgid, prime FROM pkgmap WHERE appid = ? AND (category IS NULL OR category <> '" CATEGORY_WATCH_CLOCK "')"; + } + + 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; +} + +void delete_record_cb(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); + } +} + +/* End of a file */ diff --git a/pkgmgr_widget/common/src/dlist.c b/pkgmgr_widget/common/src/dlist.c new file mode 100644 index 0000000..3ae571b --- /dev/null +++ b/pkgmgr_widget/common/src/dlist.c @@ -0,0 +1,189 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include "dlist.h" + +/*! + * \brief + * This dlist is called Modified Doubly Linked List. + * + * Noramlly, The dobule linked list contains address of previous and next element. + * This dlist also contains them, but the tail element only contains prev address. + * + * The head element's prev pointer indicates the last element. + * But the last element's next pointer indicates NIL. + * + * So we can find the last element while crawling this DList + * But we have to remember the address of the head element. + */ + +struct dlist { + struct dlist *next; + struct dlist *prev; + void *data; +}; + +struct dlist *dlist_append(struct dlist *list, void *data) +{ + struct dlist *item; + + item = malloc(sizeof(*item)); + if (!item) { + return NULL; + } + + item->next = NULL; + item->data = data; + + if (!list) { + item->prev = item; + + list = item; + } else { + item->prev = list->prev; + item->prev->next = item; + list->prev = item; + } + + assert(!list->prev->next && "item NEXT"); + + return list; +} + +struct dlist *dlist_prepend(struct dlist *list, void *data) +{ + struct dlist *item; + + item = malloc(sizeof(*item)); + if (!item) { + return NULL; + } + + item->data = data; + + if (!list) { + item->prev = item; + item->next = NULL; + } else { + if (list->prev->next) { + list->prev->next = item; + } + + item->prev = list->prev; + item->next = list; + + list->prev = item; + + } + + return item; +} + +struct dlist *dlist_remove(struct dlist *list, struct dlist *l) +{ + if (!list || !l) { + return NULL; + } + + if (l == list) { + list = l->next; + } else { + l->prev->next = l->next; + } + + if (l->next) { + l->next->prev = l->prev; + } + /*! + * \note + * If the removed entry 'l' has no next element, it is the last element. + * In this case, check the existence of the list first, + * and if the list is not empty, update the 'prev' of the list (which is a head element of the list) + * + * If we didn't care about this, the head element(list) can indicates the invalid element. + */ + else if (list) { + list->prev = l->prev; + } + + free(l); + return list; +} + +struct dlist *dlist_find_data(struct dlist *list, void *data) +{ + struct dlist *l; + void *_data; + + dlist_foreach(list, l, _data) { + if (data == _data) { + return l; + } + } + + return NULL; +} + +void *dlist_data(struct dlist *l) +{ + return l ? l->data : NULL; +} + +struct dlist *dlist_next(struct dlist *l) +{ + return l ? l->next : NULL; +} + +struct dlist *dlist_prev(struct dlist *l) +{ + return l ? l->prev : NULL; +} + +int dlist_count(struct dlist *l) +{ + register int i; + struct dlist *n; + void *data; + + i = 0; + dlist_foreach(l, n, data) { + i++; + } + + return i; +} + +struct dlist *dlist_nth(struct dlist *l, int nth) +{ + register int i; + struct dlist *n; + + i = 0; + for (n = l; n; n = n->next) { + if (i == nth) { + return n; + } + i++; + } + + return NULL; +} + +/* End of a file */ diff --git a/pkgmgr_widget/watch/CMakeLists.txt b/pkgmgr_widget/watch/CMakeLists.txt new file mode 100644 index 0000000..7ec0c53 --- /dev/null +++ b/pkgmgr_widget/watch/CMakeLists.txt @@ -0,0 +1,15 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(watch-application C) + +ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) +ADD_LIBRARY(${PROJECT_NAME} MODULE + src/service_watchapp.c +) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${bin_pkgs_LDFLAGS} common) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION "etc/package-manager/parserlib") + +# End of a file diff --git a/pkgmgr_widget/watch/src/service_watchapp.c b/pkgmgr_widget/watch/src/service_watchapp.c new file mode 100644 index 0000000..fe36772 --- /dev/null +++ b/pkgmgr_widget/watch/src/service_watchapp.c @@ -0,0 +1,185 @@ +/* + * 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 "common.h" + +#define WATCH_APP_TAG "watch-application" +#define EAPI __attribute__((visibility("default"))) + +static inline int remove_all_watch(const char *appid) +{ + int cnt; + + begin_transaction(); + cnt = pkglist_get_via_callback(appid, 1, delete_record_cb, NULL); + commit_transaction(); + + if (cnt > 0) { + DbgPrint("Package[%s] is not deleted: %d\n", appid, cnt); + } + + return 0; +} + +EAPI int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *appid) +{ + ErrPrintWithConsole("%s\n", appid); + + if (!db_check()) { + if (db_init() < 0) { + ErrPrintWithConsole("Failed to init DB\n"); + return -EIO; + } + } + + db_upgrade_db_schema(); + + return remove_all_watch(appid); +} + +EAPI int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *appid) +{ + ErrPrintWithConsole("[%s]\n", appid); + db_fini(); + return 0; +} + +EAPI int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid) +{ + xmlNodePtr node; + int ret; + + ErrPrintWithConsole("[%s]\n", appid); + + if (!db_check()) { + 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 *)WATCH_APP_TAG)) { + ret = db_install_watchapp(node, appid); + if (ret < 0) { + DbgPrint("Returns: %d\n", ret); + } + } + } + + return 0; +} + +EAPI int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *appid) +{ + ErrPrintWithConsole("[%s]\n", appid); + + if (!db_check()) { + if (db_init() < 0) { + ErrPrint("Failed to init DB\n"); + return -EIO; + } + } + + db_upgrade_db_schema(); + + return remove_all_watch(appid); +} + +EAPI int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *appid) +{ + ErrPrintWithConsole("[%s]\n", appid); + db_fini(); + return 0; +} + +EAPI int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char *appid) +{ + xmlNodePtr node; + int ret; + + ErrPrintWithConsole("[%s]\n", appid); + + if (!db_check()) { + 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 *)WATCH_APP_TAG)) { + ret = db_install_watchapp(node, appid); + if (ret < 0) { + DbgPrint("Returns: %d\n", ret); + } + } + } + + return 0; +} + +EAPI int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *appid) +{ + ErrPrintWithConsole("[%s]\n", appid); + + if (!db_check()) { + if (db_init() < 0) { + ErrPrint("Failed to init DB\n"); + return -EIO; + } + } + + db_upgrade_db_schema(); + return 0; +} + +EAPI int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *appid) +{ + ErrPrintWithConsole("[%s]\n", appid); + + if (!db_check()) { + return -EIO; + } + + remove_all_watch(appid); + + db_fini(); + return 0; +} + +EAPI int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *appid) +{ + ErrPrintWithConsole("[%s]\n", appid); + if (!db_check()) { + return -EIO; + } + + /* Doesn't need to do anything from here, we already dealt it with this */ + + return 0; +} + +/* End of a file */ diff --git a/pkgmgr_widget/watch/watchapp.xml b/pkgmgr_widget/watch/watchapp.xml new file mode 100644 index 0000000..b4e96c6 --- /dev/null +++ b/pkgmgr_widget/watch/watchapp.xml @@ -0,0 +1,10 @@ + + + + + + /usr/share/icons/small/org.tizen.live-watch.png + + + + diff --git a/pkgmgr_widget/watch/watchapp.xsd b/pkgmgr_widget/watch/watchapp.xsd new file mode 100644 index 0000000..23baef2 --- /dev/null +++ b/pkgmgr_widget/watch/watchapp.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pkgmgr_widget/widget.xml b/pkgmgr_widget/widget.xml new file mode 100644 index 0000000..b2fe578 --- /dev/null +++ b/pkgmgr_widget/widget.xml @@ -0,0 +1,81 @@ + + + + + + /usr/share/icons/small/org.tizen.live-nicesj.png + + + Content information + + + org.tizen.nicesj + + org.tizen.nicesj + + + + 1x1 + + 2x1 + 2x2 + 4x1 + 4x2 + 4x3 + 4x4 + + + 21x21 + 23x21 + 23x23 + + + 0x0 +