From: Sung-jae Park Date: Tue, 22 Oct 2013 03:43:10 +0000 (+0900) Subject: Merge branch 'tizen_2.2' of ssh://review.tizendev.org:29418/apps/livebox/data-provide... X-Git-Tag: submit/tizen/20131022.035939^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aa2246206ae09bd994f7eb2c66af7cac86a0ace0;hp=9f9a40690c0cc75dd6e1bac1ca95cb4793cbbd98;p=platform%2Fframework%2Fweb%2Fdata-provider-slave.git Merge branch 'tizen_2.2' of ssh://review.tizendev.org:29418/apps/livebox/data-provider-slave into work Sync with the latest tizen 2.2 implementations Conflicts: src/main.c Change-Id: Icd431d2b9d12006a33e70ee0056542a534d1e5ff --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7366c7c..6429e1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,6 @@ pkg_check_modules(pkg REQUIRED ecore-x ecore provider - heap-monitor livebox-service edje evas @@ -30,6 +29,8 @@ pkg_check_modules(pkg REQUIRED SET(PACKAGE "${PROJECT_NAME}") SET(LOCALEDIR "/usr/apps/org.tizen.${PROJECT_NAME}/res/locale") +SET(ICON_PROVIDER "icon-provider-slave") +SET(EXE_LOADER "${PROJECT_NAME}") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -39,15 +40,17 @@ ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DPATH_MAX=256") ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"") -ADD_DEFINITIONS("-DEXEC_NAME=\"${PROJECT_NAME}\"") +ADD_DEFINITIONS("-DEXEC_NAME=\"${PROJECT_NAME}.loader\"") ADD_DEFINITIONS("-DMASTER_PKGNAME=\"data-provider-master\"") ADD_DEFINITIONS("-DSLAVE_PKGNAME=\"org.tizen.data-provider-slave\"") ADD_DEFINITIONS("-DSOCKET_FILE=\"/opt/usr/share/live_magazine/.live.socket\"") +ADD_DEFINITIONS("-DCONF_FILE=\"/usr/share/data-provider-master/conf.ini\"") ADD_DEFINITIONS("-DNDEBUG") #ADD_DEFINITIONS("-D_ENABLE_MCHECK") ADD_DEFINITIONS("-DLOG_TAG=\"DATA_PROVIDER_SLAVE\"") +ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET") ADD_DEFINITIONS(${pkg_CFLAGS}) @@ -55,7 +58,7 @@ ADD_DEFINITIONS(${pkg_CFLAGS}) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Winline -g -fno-builtin-malloc") #SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") -ADD_EXECUTABLE(${PROJECT_NAME} +ADD_EXECUTABLE("${PROJECT_NAME}.loader" src/main.c src/so_handler.c src/fault.c @@ -66,22 +69,27 @@ ADD_EXECUTABLE(${PROJECT_NAME} src/client.c src/critical_log.c ) +TARGET_LINK_LIBRARIES("${PROJECT_NAME}.loader" ${pkg_LDFLAGS} "-ldl") -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkg_LDFLAGS} "-ldl") - -ADD_EXECUTABLE(icon-provider-slave +ADD_EXECUTABLE(${ICON_PROVIDER} icon_src/main.c icon_src/script_handler.c src/util.c ) -TARGET_LINK_LIBRARIES("icon-provider-slave" ${pkg_LDFLAGS} "-ldl") +TARGET_LINK_LIBRARIES(${ICON_PROVIDER} ${pkg_LDFLAGS} "-ldl") + +ADD_EXECUTABLE(${EXE_LOADER} + stub/main.c +) +TARGET_LINK_LIBRARIES(${EXE_LOADER} ${pkg_LDFLAGS} "-ldl") #INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.data-provider-slave.desktop DESTINATION /usr/share/applications) INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.data-provider-slave.xml DESTINATION /usr/share/packages) INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "org.tizen.${PROJECT_NAME}") -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/apps/org.tizen.${PROJECT_NAME}/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +INSTALL(TARGETS "${PROJECT_NAME}.loader" DESTINATION /usr/apps/org.tizen.${PROJECT_NAME}/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.data-provider-slave.rule DESTINATION /etc/smack/accesses.d) -INSTALL(TARGETS "icon-provider-slave" DESTINATION /usr/apps/org.tizen.${PROJECT_NAME}/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +INSTALL(TARGETS ${ICON_PROVIDER} DESTINATION /usr/apps/org.tizen.${PROJECT_NAME}/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +INSTALL(TARGETS ${EXE_LOADER} DESTINATION /usr/apps/org.tizen.${PROJECT_NAME}/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) # INCLUDE FOR BUILD & INSTALL .PO FILES ADD_SUBDIRECTORY(res) diff --git a/data/icon.edc b/data/icon.edc index cbe7632..cbf17ae 100644 --- a/data/icon.edc +++ b/data/icon.edc @@ -16,6 +16,7 @@ images { image: "icon_shadow.png" COMP; + image: "shortcut_bg_1x1.png" COMP; } collections { @@ -23,12 +24,23 @@ collections { name: "default,1x1"; parts { part { - name: "bg"; + name: "box,bg"; type: IMAGE; description { state: "default" 0.0; rel1 { relative: 0.0 0.0; } rel2 { relative: 1.0 1.0; } + image { normal: "shortcut_bg_1x1.png"; } + } + } + + part { + name: "bg"; + type: IMAGE; + description { + state: "default" 0.0; + rel1 { relative: 23/175 11/175; } + rel2 { relative: 152/175 140/175; } image { normal: "icon_shadow.png"; } align: 0.5 0.5; aspect: 1.0 1.0; @@ -36,44 +48,62 @@ collections { } } + part { + name: "icon"; + type: SWALLOW; + description { + rel1 { relative: 6/129 3/129; to, "bg"; } + rel2 { relative: 123/129 120/129; to, "bg"; } + } + } + part { - name: "icon"; - type: SWALLOW; + name: "name,shadow"; + type: TEXT; + // effect: FAR_SHADOW description { - rel1 { relative: 33.5/175 21/175; } - rel2 { relative: 141.5/175 129/175; } + rel1 { relative: 11/175 135/175; } + rel2 { relative: 166/175 169/175; } + color: 0 0 0 102; + text { + font: "Tizen:style=Bold"; + text_class: "tizen"; + align: 0.5 0.5; + size: 26; + } } } part { name: "name"; type: TEXT; - //effect: FAR_SHADOW; + // effect: FAR_SHADOW; description { - rel1 { relative: 8/175 134/175; } - rel2 { relative: 167/175 164/175; } - color: 70 70 70 255; - color3: 255 255 255 255; + rel1 { relative: 10/175 133/175; } + rel2 { relative: 165/175 167/175; } + color: 255 255 255 255; + //color3: 255 255 255 153; text { font: "Tizen:style=Bold"; text_class: "tizen"; align: 0.5 0.5; - size : 23; + size: 26; } } } } } + group { - name: "default,2x1"; + name: "default,2x1"; /* +89.5, 0 */ parts { part { name: "bg"; type: IMAGE; description { state: "default" 0.0; - rel1 { relative: 89.5/354 0.0; } - rel2 { relative: 264.5/354 1.0; } + rel1 { relative: 112.5/354 11/175; } + rel2 { relative: 241.5/354 140/175; } image { normal: "icon_shadow.png"; } align: 0.5 0.5; aspect: 1.0 1.0; @@ -81,44 +111,62 @@ collections { } } + part { + name: "icon"; + type: SWALLOW; + description { + rel1 { relative: 6/129 3/129; to, "bg"; } + rel2 { relative: 123/129 120/129; to, "bg"; } + } + } + part { - name: "icon"; - type: SWALLOW; + name: "name,shadow"; + type: TEXT; + // effect: FAR_SHADOW description { - rel1 { relative: 123/354 21/175; } - rel2 { relative: 231/354 129/175; } + rel1 { relative: 100.5/354 135/175; } + rel2 { relative: 255.5/354 169/175; } + color: 0 0 0 102; + text { + font: "Tizen:style=Bold"; + text_class: "tizen"; + align: 0.5 0.5; + size: 26; + } } } part { name: "name"; type: TEXT; - //effect: FAR_SHADOW; + // effect: FAR_SHADOW; description { - rel1 { relative: 97.5/354 134/175; } - rel2 { relative: 256.5/354 164/175; } - color: 70 70 70 255; - color3: 255 255 255 255; + rel1 { relative: 99.5/354 133/175; } + rel2 { relative: 254.5/354 167/175; } + color: 255 255 255 255; + //color3: 255 255 255 153; text { font: "Tizen:style=Bold"; text_class: "tizen"; align: 0.5 0.5; - size : 23; + size: 26; } } } } } + group { - name: "default,2x2"; + name: "default,2x2"; /* +89.5, +89.5 */ parts { part { name: "bg"; type: IMAGE; description { state: "default" 0.0; - rel1 { relative: 89.5/354 74.5/354; } - rel2 { relative: 264.5/354 249.5/354; } + rel1 { relative: 112.5/354 100.5/354; } + rel2 { relative: 241.5/354 229.5/354; } image { normal: "icon_shadow.png"; } align: 0.5 0.5; aspect: 1.0 1.0; @@ -126,44 +174,62 @@ collections { } } + part { + name: "icon"; + type: SWALLOW; + description { + rel1 { relative: 6/129 3/129; to, "bg"; } + rel2 { relative: 123/129 120/129; to, "bg"; } + } + } + part { - name: "icon"; - type: SWALLOW; + name: "name,shadow"; + type: TEXT; + // effect: FAR_SHADOW description { - rel1 { relative: 123/354 108/354; } - rel2 { relative: 231/354 216/354; } + rel1 { relative: 100.5/354 224.5/354; } + rel2 { relative: 255.5/354 258.5/354; } + color: 0 0 0 102; + text { + font: "Tizen:style=Bold"; + text_class: "tizen"; + align: 0.5 0.5; + size: 26; + } } } part { name: "name"; type: TEXT; - //effect: FAR_SHADOW; + // effect: FAR_SHADOW; description { - rel1 { relative: 97.5/354 221/354; } - rel2 { relative: 256.5/354 251/354; } - color: 70 70 70 255; - color3: 255 255 255 255; + rel1 { relative: 99.5/354 222.5/354; } + rel2 { relative: 254.5/354 256.5/354; } + color: 255 255 255 255; + //color3: 255 255 255 153; text { font: "Tizen:style=Bold"; text_class: "tizen"; align: 0.5 0.5; - size : 23; + size: 26; } } } } } + group { - name: "default,4x1"; + name: "default,4x1"; /* +268.5, 0 */ parts { part { name: "bg"; type: IMAGE; description { state: "default" 0.0; - rel1 { relative: 268.5/712 0.0; } - rel2 { relative: 443.5/712 1.0; } + rel1 { relative: 291.5/712 11/175; } + rel2 { relative: 420.5/712 140/175; } image { normal: "icon_shadow.png"; } align: 0.5 0.5; aspect: 1.0 1.0; @@ -171,44 +237,62 @@ collections { } } + part { + name: "icon"; + type: SWALLOW; + description { + rel1 { relative: 6/129 3/129; to, "bg"; } + rel2 { relative: 123/129 120/129; to, "bg"; } + } + } + part { - name: "icon"; - type: SWALLOW; + name: "name,shadow"; + type: TEXT; + // effect: FAR_SHADOW description { - rel1 { relative: 302/712 21/175; } - rel2 { relative: 410/712 129/175; } + rel1 { relative: 279.5/712 135/175; } + rel2 { relative: 434.5/712 169/175; } + color: 0 0 0 102; + text { + font: "Tizen:style=Bold"; + text_class: "tizen"; + align: 0.5 0.5; + size: 26; + } } } part { name: "name"; type: TEXT; - //effect: FAR_SHADOW; + // effect: FAR_SHADOW; description { - rel1 { relative: 276.5/712 134/175; } - rel2 { relative: 435.5/712 164/175; } - color: 70 70 70 255; - color3: 255 255 255 255; + rel1 { relative: 278.5/712 133/175; } + rel2 { relative: 433.5/712 167/175; } + color: 255 255 255 255; + //color3: 255 255 255 153; text { font: "Tizen:style=Bold"; text_class: "tizen"; align: 0.5 0.5; - size : 23; + size: 26; } } } } } + group { - name: "default,4x2"; + name: "default,4x2"; /* +268.5, +89.5 */ parts { part { name: "bg"; type: IMAGE; description { state: "default" 0.0; - rel1 { relative: 268.5/712 74.5/354; } - rel2 { relative: 443.5/712 249.5/354; } + rel1 { relative: 291.5/712 100.5/354; } + rel2 { relative: 420.5/712 229.5/354; } image { normal: "icon_shadow.png"; } align: 0.5 0.5; aspect: 1.0 1.0; @@ -216,44 +300,62 @@ collections { } } + part { + name: "icon"; + type: SWALLOW; + description { + rel1 { relative: 6/129 3/129; to, "bg"; } + rel2 { relative: 123/129 120/129; to, "bg"; } + } + } + part { - name: "icon"; - type: SWALLOW; + name: "name,shadow"; + type: TEXT; + // effect: FAR_SHADOW description { - rel1 { relative: 302/712 108/354; } - rel2 { relative: 410/712 218/354; } + rel1 { relative: 279.5/712 224.5/354; } + rel2 { relative: 434.5/712 258.5/354; } + color: 0 0 0 102; + text { + font: "Tizen:style=Bold"; + text_class: "tizen"; + align: 0.5 0.5; + size: 26; + } } } part { name: "name"; type: TEXT; - //effect: FAR_SHADOW; + // effect: FAR_SHADOW; description { - rel1 { relative: 276.5/712 223/354; } - rel2 { relative: 435.5/712 253/354; } - color: 70 70 70 255; - color3: 255 255 255 255; + rel1 { relative: 278.5/712 222.5/354; } + rel2 { relative: 433.5/712 256.5/354; } + color: 255 255 255 255; + //color3: 255 255 255 153; text { font: "Tizen:style=Bold"; text_class: "tizen"; align: 0.5 0.5; - size : 23; + size: 26; } } } } } + group { - name: "default,4x3"; + name: "default,4x3"; /* +268.5, +179 */ parts { part { name: "bg"; type: IMAGE; description { state: "default" 0.0; - rel1 { relative: 268.5/712 179/533; } - rel2 { relative: 443.5/712 354/533; } + rel1 { relative: 291.5/712 190/533; } + rel2 { relative: 420.5/712 319/533; } image { normal: "icon_shadow.png"; } align: 0.5 0.5; aspect: 1.0 1.0; @@ -261,161 +363,235 @@ collections { } } + part { + name: "icon"; + type: SWALLOW; + description { + rel1 { relative: 6/129 3/129; to, "bg"; } + rel2 { relative: 123/129 120/129; to, "bg"; } + } + } + part { - name: "icon"; - type: SWALLOW; + name: "name,shadow"; + type: TEXT; + // effect: FAR_SHADOW description { - rel1 { relative: 302/712 212.5/533; } - rel2 { relative: 410/712 320.5/533; } + rel1 { relative: 279.5/712 314/533; } + rel2 { relative: 434.5/712 348/533; } + color: 0 0 0 102; + text { + font: "Tizen:style=Bold"; + text_class: "tizen"; + align: 0.5 0.5; + size: 26; + } } } part { name: "name"; type: TEXT; - //effect: FAR_SHADOW; + // effect: FAR_SHADOW; description { - rel1 { relative: 276.5/712 325.5/533; } - rel2 { relative: 435.5/712 355.5/533; } - color: 70 70 70 255; - color3: 255 255 255 255; + rel1 { relative: 278.5/712 312/533; } + rel2 { relative: 433.5/712 346/533; } + color: 255 255 255 255; + //color3: 255 255 255 153; text { font: "Tizen:style=Bold"; text_class: "tizen"; align: 0.5 0.5; - size : 23; + size: 26; } } } } } + group { - name: "default,4x4"; + name: "default,4x4"; /* +268.5, +268.5 */ parts { part { name: "bg"; type: IMAGE; description { state: "default" 0.0; - rel1 { relative: 268.5/712 268.5/712; } - rel2 { relative: 443.5/712 443.5/712; } + rel1 { relative: 291.5/712 279.5/712; } + rel2 { relative: 420.5/712 408.5/712; } image { normal: "icon_shadow.png"; } align: 0.5 0.5; aspect: 1.0 1.0; aspect_preference: BOTH; } } + + part { + name: "icon"; + type: SWALLOW; + description { + rel1 { relative: 6/129 3/129; to, "bg"; } + rel2 { relative: 123/129 120/129; to, "bg"; } + } + } + part { - name: "icon"; - type: SWALLOW; + name: "name,shadow"; + type: TEXT; + // effect: FAR_SHADOW description { - rel1 { relative: 302/712 302/712; } - rel2 { relative: 410/712 410/712; } + rel1 { relative: 279.5/712 403.5/712; } + rel2 { relative: 434.5/712 437.5/712; } + color: 0 0 0 102; + text { + font: "Tizen:style=Bold"; + text_class: "tizen"; + align: 0.5 0.5; + size: 26; + } } } part { name: "name"; type: TEXT; - //effect: FAR_SHADOW; + // effect: FAR_SHADOW; description { - rel1 { relative: 276.5/712 415/712; } - rel2 { relative: 435.5/712 445/712; } - color: 70 70 70 255; - color3: 255 255 255 255; + rel1 { relative: 278.5/712 401.5/712; } + rel2 { relative: 433.5/712 435.5/712; } + color: 255 255 255 255; + //color3: 255 255 255 153; text { font: "Tizen:style=Bold"; text_class: "tizen"; align: 0.5 0.5; - size : 23; + size: 26; } } } } } + group { - name: "default,4x5"; + name: "default,4x5"; /* +268.5, +358 , 891 */ parts { part { name: "bg"; type: IMAGE; description { state: "default" 0.0; - rel1 { relative: 268.5/712 358/891; } - rel2 { relative: 443.5/712 533/891; } + rel1 { relative: 291.5/712 369/891; } + rel2 { relative: 420.5/712 498/891; } image { normal: "icon_shadow.png"; } align: 0.5 0.5; aspect: 1.0 1.0; aspect_preference: BOTH; } } + + part { + name: "icon"; + type: SWALLOW; + description { + rel1 { relative: 6/129 3/129; to, "bg"; } + rel2 { relative: 123/129 120/129; to, "bg"; } + } + } + part { - name: "icon"; - type: SWALLOW; + name: "name,shadow"; + type: TEXT; + // effect: FAR_SHADOW description { - rel1 { relative: 302/712 391.5/891; } - rel2 { relative: 410/712 499.5/891; } + rel1 { relative: 279.5/712 493/891; } + rel2 { relative: 434.5/712 527/891; } + color: 0 0 0 102; + text { + font: "Tizen:style=Bold"; + text_class: "tizen"; + align: 0.5 0.5; + size: 26; + } } } part { name: "name"; type: TEXT; - //effect: FAR_SHADOW; + // effect: FAR_SHADOW; description { - rel1 { relative: 276.5/712 504.5/891; } - rel2 { relative: 435.5/712 534.5/891; } - color: 70 70 70 255; - color3: 255 255 255 255; + rel1 { relative: 278.5/712 491/891; } + rel2 { relative: 433.5/712 525/891; } + color: 255 255 255 255; + //color3: 255 255 255 153; text { font: "Tizen:style=Bold"; text_class: "tizen"; align: 0.5 0.5; - size : 23; + size: 26; } } } } } + group { - name: "default,4x6"; + name: "default,4x6"; /* +268.5, +447.5, 1070 */ parts { part { name: "bg"; type: IMAGE; description { state: "default" 0.0; - rel1 { relative: 268.5/712 447.5/1070; } - rel2 { relative: 443.5/712 622.5/1070; } + rel1 { relative: 291.5/712 458.5/1070; } + rel2 { relative: 420.5/712 587.5/1070; } image { normal: "icon_shadow.png"; } align: 0.5 0.5; aspect: 1.0 1.0; aspect_preference: BOTH; } } + + part { + name: "icon"; + type: SWALLOW; + description { + rel1 { relative: 6/129 3/129; to, "bg"; } + rel2 { relative: 123/129 120/129; to, "bg"; } + } + } + part { - name: "icon"; - type: SWALLOW; + name: "name,shadow"; + type: TEXT; + // effect: FAR_SHADOW description { - rel1 { relative: 302/712 481/1070; } - rel2 { relative: 410/712 589/1070; } + rel1 { relative: 279.5/712 582.5/1070; } + rel2 { relative: 434.5/712 616.5/1070; } + color: 0 0 0 102; + text { + font: "Tizen:style=Bold"; + text_class: "tizen"; + align: 0.5 0.5; + size: 26; + } } } part { name: "name"; type: TEXT; - //effect: FAR_SHADOW; + // effect: FAR_SHADOW; description { - rel1 { relative: 276.5/712 594/1070; } - rel2 { relative: 435.5/712 624/1070; } - color: 70 70 70 255; - color3: 255 255 255 255; + rel1 { relative: 278.5/712 580.5/1070; } + rel2 { relative: 433.5/712 614.5/1070; } + color: 255 255 255 255; + //color3: 255 255 255 153; text { font: "Tizen:style=Bold"; text_class: "tizen"; align: 0.5 0.5; - size : 23; + size: 26; } } } diff --git a/data/icon_shadow.png b/data/icon_shadow.png index 4461323..65e836b 100755 Binary files a/data/icon_shadow.png and b/data/icon_shadow.png differ diff --git a/data/shortcut_bg_1x1.png b/data/shortcut_bg_1x1.png new file mode 100644 index 0000000..61f8058 Binary files /dev/null and b/data/shortcut_bg_1x1.png differ diff --git a/icon_src/main.c b/icon_src/main.c index 2490bf1..6597d94 100644 --- a/icon_src/main.c +++ b/icon_src/main.c @@ -34,12 +34,15 @@ #include #include +#include #include #include #include #include #include +#include + #include #include #include @@ -53,16 +56,21 @@ #define DEFAULT_ICON_LAYOUT "/usr/apps/org.tizen.data-provider-slave/res/edje/icon.edj" #define DEFAULT_ICON_GROUP "default" +#define TEXT_CLASS "tizen" +#define DEFAULT_FONT_SIZE -100 + int script_handler_parse_desc(Evas_Object *edje, const char *descfile); static struct info { Ecore_Timer *ttl_timer; int client_fd; const char *socket_file; + char *font_name; } s_info = { .ttl_timer = NULL, .client_fd = -1, .socket_file = UTILITY_ADDR, + .font_name = NULL, }; #define TTL 30.0f /* Can alive only 30 seconds from the last event */ @@ -78,7 +86,12 @@ const char *livebox_find_pkgname(const char *filename) int livebox_request_update_by_id(const char *filename) { - return -ENOSYS; + return LB_STATUS_ERROR_NOT_EXIST; +} + +int livebox_trigger_update_monitor(const char *id, int is_pd) +{ + return LB_STATUS_ERROR_INVALID; } static inline Evas *create_virtual_canvas(int w, int h) @@ -192,8 +205,9 @@ static inline int convert_shortcut_type_to_lb_type(int shortcut_type, char **str { char *_str; - if (!str) + if (!str) { str = &_str; + } switch (shortcut_type) { case LIVEBOX_TYPE_1x1: @@ -223,6 +237,15 @@ static inline int convert_shortcut_type_to_lb_type(int shortcut_type, char **str case LIVEBOX_TYPE_4x6: *str = "4x6"; return LB_SIZE_TYPE_4x6; + case LIVEBOX_TYPE_EASY_1x1: + *str = "easy,1x1"; + return LB_SIZE_TYPE_EASY_1x1; + case LIVEBOX_TYPE_EASY_3x1: + *str = "easy,3x1"; + return LB_SIZE_TYPE_EASY_3x1; + case LIVEBOX_TYPE_EASY_3x3: + *str = "easy,3x3"; + return LB_SIZE_TYPE_EASY_3x3; default: *str = "?x?"; return LB_SIZE_TYPE_UNKNOWN; @@ -245,8 +268,9 @@ static struct packet *icon_create(pid_t pid, int handle, const struct packet *pa char _group[16]; char *size_str; - if (s_info.ttl_timer) + if (s_info.ttl_timer) { ecore_timer_reset(s_info.ttl_timer); + } ret = packet_get(packet, "sssis", &edje_path, &group, &desc_file, &size_type, &output); if (ret != 5) { @@ -312,8 +336,9 @@ static struct packet *icon_create(pid_t pid, int handle, const struct packet *pa evas_object_resize(edje, w, h); evas_object_show(edje); - if (script_handler_parse_desc(edje, desc_file) != LB_STATUS_SUCCESS) + if (script_handler_parse_desc(edje, desc_file) != LB_STATUS_SUCCESS) { ErrPrint("Unable to parse the %s\n", desc_file); + } flush_to_file(e, output, w, h); evas_object_del(edje); @@ -321,6 +346,13 @@ static struct packet *icon_create(pid_t pid, int handle, const struct packet *pa destroy_virtual_canvas(e); out: + if (ret < 0) { + /* Desc file should be deleted if it fails to create an icon image */ + if (unlink(desc_file) < 0) { + ErrPrint("unlink(%s): %s\n", desc_file, strerror(errno)); + } + } + return packet_create_reply(packet, "i", ret); } @@ -390,8 +422,69 @@ static inline void client_fini(void) s_info.client_fd = -1; } +static void update_font_cb(void *data) +{ + Eina_List *list; + char *text; + + list = edje_text_class_list(); + DbgPrint("List: %p\n", list); + if (list) { + EINA_LIST_FREE(list, text) { + if (!strncasecmp(text, TEXT_CLASS, strlen(TEXT_CLASS))) { + DbgPrint("Update text class %s (%s, %d)\n", text, s_info.font_name, DEFAULT_FONT_SIZE); + edje_text_class_del(text); + edje_text_class_set(text, s_info.font_name, DEFAULT_FONT_SIZE); + } else { + DbgPrint("Skip text class %s\n", text); + } + } + } else { + DbgPrint("New (%s, %d)\n", s_info.font_name, DEFAULT_FONT_SIZE); + edje_text_class_set(TEXT_CLASS, s_info.font_name, DEFAULT_FONT_SIZE); + } +} + +static void font_changed_cb(keynode_t *node, void *user_data) +{ + char *font_name; + + if (s_info.font_name) { + font_name = vconf_get_str("db/setting/accessibility/font_name"); + if (!font_name) { + ErrPrint("Invalid font name (NULL)\n"); + return; + } + + if (!strcmp(s_info.font_name, font_name)) { + DbgPrint("Font is not changed (Old: %s(%p) <> New: %s(%p))\n", s_info.font_name, s_info.font_name, font_name, font_name); + free(font_name); + return; + } + + DbgPrint("Release old font name: %s(%p)\n", s_info.font_name, s_info.font_name); + free(s_info.font_name); + } else { + int ret; + + font_name = NULL; + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &font_name); + if (ret != SYSTEM_SETTINGS_ERROR_NONE || !font_name) { + ErrPrint("system settings: %d, font_name[%p]\n", ret, font_name); + return; + } + } + + s_info.font_name = font_name; + DbgPrint("Font name is changed to %s(%p)\n", s_info.font_name, s_info.font_name); + + update_font_cb(NULL); +} + static bool app_create(void *data) { + int ret; + if (client_init() < 0) { ErrPrint("Unable to initiate the client\n"); return FALSE; @@ -401,20 +494,33 @@ static bool app_create(void *data) * Send a request to reigister as a service. */ s_info.ttl_timer = ecore_timer_add(TTL, life_timer_cb, NULL); - if (!s_info.ttl_timer) + if (!s_info.ttl_timer) { ErrPrint("Unable to register a life timer\n"); + } + ret = vconf_notify_key_changed("db/setting/accessibility/font_name", font_changed_cb, NULL); + DbgPrint("System font is changed: %d\n", ret); + + font_changed_cb(NULL, NULL); return TRUE; } static void app_terminate(void *data) { + int ret; + + ret = vconf_ignore_key_changed("db/setting/accessibility/font_name", font_changed_cb); + DbgPrint("Remove font change callback: %d\n", ret); + if (s_info.ttl_timer) { ecore_timer_del(s_info.ttl_timer); s_info.ttl_timer = NULL; } client_fini(); + + free(s_info.font_name); + s_info.font_name = NULL; return; } diff --git a/icon_src/script_handler.c b/icon_src/script_handler.c index 1bb9ac3..78bbfce 100644 --- a/icon_src/script_handler.c +++ b/icon_src/script_handler.c @@ -111,8 +111,9 @@ static inline Evas_Object *find_edje(const char *id) EINA_LIST_FOREACH(s_info.obj_list, l, child) { obj_info = evas_object_data_get(child, "obj_info"); - if (!obj_info || strcmp(obj_info->id, id)) + if (!obj_info || strcmp(obj_info->id, id)) { continue; + } return child; } @@ -196,8 +197,9 @@ static void parse_aspect(struct image_option *img_opt, const char *value, int le len--; } - if (len < 4) + if (len < 4) { return; + } img_opt->aspect = !strncasecmp(value, "true", 4); DbgPrint("Parsed ASPECT: %d (%s)\n", img_opt->aspect, value); @@ -210,8 +212,9 @@ static void parse_orient(struct image_option *img_opt, const char *value, int le len--; } - if (len < 4) + if (len < 4) { return; + } img_opt->orient = !strncasecmp(value, "true", 4); DbgPrint("Parsed ORIENT: %d (%s)\n", img_opt->orient, value); @@ -252,12 +255,13 @@ static void parse_fill(struct image_option *img_opt, const char *value, int len) len--; } - if (!strncasecmp(value, "in-size", len)) + if (!strncasecmp(value, "in-size", len)) { img_opt->fill = FILL_IN_SIZE; - else if (!strncasecmp(value, "over-size", len)) + } else if (!strncasecmp(value, "over-size", len)) { img_opt->fill = FILL_OVER_SIZE; - else + } else { img_opt->fill = FILL_DISABLE; + } DbgPrint("Parsed FILL: %d (%s)\n", img_opt->fill, value); } @@ -299,8 +303,9 @@ static inline void parse_image_option(const char *option, struct image_option *i int idx; int tag; - if (!option || !*option) + if (!option || !*option) { return; + } state = STATE_START; /*! @@ -374,10 +379,11 @@ static inline void parse_image_option(const char *option, struct image_option *i } break; case STATE_ERROR: - if (*ptr == ';') + if (*ptr == ';') { state = STATE_START; - else if (*ptr == '\0') + } else if (*ptr == '\0') { state = STATE_END; + } break; default: break; @@ -420,8 +426,9 @@ static int update_script_image(Evas_Object *edje, struct block *block) Eina_List *n; EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) { - if (child->obj != img) + if (child->obj != img) { continue; + } obj_info->children = eina_list_remove(obj_info->children, child); free(child->part); @@ -504,12 +511,119 @@ static int update_script_image(Evas_Object *edje, struct block *block) w = (double)w * fh; } } - DbgPrint("Size: %dx%d\n", w, h); - evas_object_image_load_size_set(img, w, h); - evas_object_image_load_region_set(img, (w - part_w) / 2, (h - part_h) / 2, part_w, part_h); - evas_object_image_fill_set(img, 0, 0, part_w, part_h); - evas_object_image_reload(img); + if (!part_w || !part_h || !w || !h) { + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_INVALID; + } + + if (evas_object_image_region_support_get(img)) { + evas_object_image_load_region_set(img, (w - part_w) / 2, (h - part_h) / 2, part_w, part_h); + evas_object_image_load_size_set(img, part_w, part_h); + evas_object_image_filled_set(img, EINA_TRUE); + DbgPrint("Size: %dx%d (region: %dx%d - %dx%d)\n", w, h, (w - part_w) / 2, (h - part_h) / 2, part_w, part_h); + } else { + Ecore_Evas *ee; + Evas *e; + Evas_Object *src_img; + Evas_Coord rw, rh; + const void *data; + + DbgPrint("Part loading is not supported\n"); + ee = ecore_evas_buffer_new(part_w, part_h); + if (!ee) { + ErrPrint("Failed to create a EE\n"); + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_FAULT; + } + + ecore_evas_alpha_set(ee, EINA_TRUE); + + e = ecore_evas_get(ee); + if (!e) { + ErrPrint("Unable to get Evas\n"); + ecore_evas_free(ee); + + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_FAULT; + } + + src_img = evas_object_image_filled_add(e); + if (!src_img) { + ErrPrint("Unable to add an image\n"); + ecore_evas_free(ee); + + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_FAULT; + } + + evas_object_image_alpha_set(src_img, EINA_TRUE); + evas_object_image_colorspace_set(src_img, EVAS_COLORSPACE_ARGB8888); + evas_object_image_smooth_scale_set(src_img, EINA_TRUE); + evas_object_image_load_orientation_set(src_img, img_opt.orient); + evas_object_image_file_set(src_img, block->data, NULL); + err = evas_object_image_load_error_get(src_img); + if (err != EVAS_LOAD_ERROR_NONE) { + ErrPrint("Load error: %s\n", evas_load_error_str(err)); + evas_object_del(src_img); + ecore_evas_free(ee); + + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_IO; + } + evas_object_image_size_get(src_img, &rw, &rh); + evas_object_image_fill_set(src_img, 0, 0, rw, rh); + evas_object_resize(src_img, w, h); + evas_object_move(src_img, -(w - part_w) / 2, -(h - part_h) / 2); + evas_object_show(src_img); + + data = ecore_evas_buffer_pixels_get(ee); + if (!data) { + ErrPrint("Unable to get pixels\n"); + evas_object_del(src_img); + ecore_evas_free(ee); + + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_IO; + } + + e = evas_object_evas_get(img); + evas_object_del(img); + img = evas_object_image_filled_add(e); + if (!img) { + evas_object_del(src_img); + ecore_evas_free(ee); + + free(child->part); + free(child); + return LB_STATUS_ERROR_MEMORY; + } + + evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888); + evas_object_image_smooth_scale_set(img, EINA_TRUE); + evas_object_image_alpha_set(img, EINA_TRUE); + evas_object_image_data_set(img, NULL); + evas_object_image_size_set(img, part_w, part_h); + evas_object_resize(img, part_w, part_h); + evas_object_image_data_copy_set(img, (void *)data); + evas_object_image_fill_set(img, 0, 0, part_w, part_h); + evas_object_image_data_update_add(img, 0, 0, part_w, part_h); + + evas_object_del(src_img); + ecore_evas_free(ee); + } } else if (img_opt.fill == FILL_IN_SIZE) { Evas_Coord part_w; Evas_Coord part_h; @@ -594,8 +708,9 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info } EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) { - if (child->obj != obj) + if (child->obj != obj) { continue; + } obj_info->children = eina_list_remove(obj_info->children, child); free(child->part); @@ -618,8 +733,9 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info EINA_LIST_FREE(obj_info->children, child) { DbgPrint("delete object %s %p\n", child->part, child->obj); - if (child->obj) + if (child->obj) { evas_object_del(child->obj); + } free(child->part); free(child); @@ -658,8 +774,9 @@ static int update_script_script(Evas_Object *edje, struct block *block) Eina_List *n; EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) { - if (child->obj != obj) + if (child->obj != obj) { continue; + } obj_info->children = eina_list_remove(obj_info->children, child); @@ -822,17 +939,19 @@ static inline void consuming_parsed_block(Evas_Object *edje, int lineno, struct register int i; for (i = 0; handlers[i].type; i++) { - if (strcasecmp(handlers[i].type, block->type)) + if (strcasecmp(handlers[i].type, block->type)) { continue; + } handlers[i].handler(edje, block); break; } - delete_block(block); - - if (!handlers[i].type) + if (!handlers[i].type) { ErrPrint("%d: Unknown block type: %s\n", lineno, block->type); + } + + delete_block(block); return; } @@ -885,14 +1004,18 @@ HAPI int script_handler_parse_desc(Evas_Object *edje, const char *descfile) * \note * After open a descfile, we can delete it. */ - if (unlink(descfile) < 0) + if (unlink(descfile) < 0) { ErrPrint("Unable to delete file\n"); + } DbgPrint("Parsing %s\n", descfile); DbgPrint("Building obj_info\n"); info = malloc(sizeof(*info)); if (!info) { ErrPrint("Heap: %s\n", strerror(errno)); + if (fclose(fp) != 0) { + ErrPrint("fclose: %s\n", strerror(errno)); + } return LB_STATUS_ERROR_MEMORY; } info->id = NULL; @@ -908,8 +1031,9 @@ HAPI int script_handler_parse_desc(Evas_Object *edje, const char *descfile) block = NULL; while (!feof(fp)) { ch = getc(fp); - if (ch == '\n') + if (ch == '\n') { lineno++; + } switch (state) { case UNKNOWN: @@ -920,14 +1044,17 @@ HAPI int script_handler_parse_desc(Evas_Object *edje, const char *descfile) if (!isspace(ch) && ch != EOF) { ErrPrint("%d: Syntax error: Desc is not started with '{' or space - (%c = 0x%x)\n", lineno, ch, ch); - fclose(fp); + if (fclose(fp) != 0) { + ErrPrint("fclose: %s\n", strerror(errno)); + } return LB_STATUS_ERROR_INVALID; } break; case BLOCK_OPEN: - if (isblank(ch)) + if (isblank(ch)) { break; + } if (ch != '\n') { ErrPrint("%d: Syntax error: New line must has to be started right after '{'\n", lineno); @@ -937,7 +1064,9 @@ HAPI int script_handler_parse_desc(Evas_Object *edje, const char *descfile) block = calloc(1, sizeof(*block)); if (!block) { ErrPrint("Heap: %s\n", strerror(errno)); - fclose(fp); + if (fclose(fp) != 0) { + ErrPrint("fclose: %s\n", strerror(errno)); + } return LB_STATUS_ERROR_MEMORY; } @@ -947,8 +1076,9 @@ HAPI int script_handler_parse_desc(Evas_Object *edje, const char *descfile) break; case FIELD: - if (isspace(ch)) + if (isspace(ch)) { break; + } if (ch == '}') { state = BLOCK_CLOSE; @@ -1033,16 +1163,19 @@ HAPI int script_handler_parse_desc(Evas_Object *edje, const char *descfile) break; } - if (ch == '\n') + if (ch == '\n') { goto errout; + } if (field_name[field_idx][idx] != ch) { ungetc(ch, fp); - if (ch == '\n') + if (ch == '\n') { lineno--; + } - while (--idx >= 0) + while (--idx >= 0) { ungetc(field_name[field_idx][idx], fp); + } field_idx++; if (field_name[field_idx] == NULL) { @@ -1232,6 +1365,7 @@ HAPI int script_handler_parse_desc(Evas_Object *edje, const char *descfile) } consuming_parsed_block(edje, lineno, block); + block = NULL; state = UNKNOWN; break; @@ -1245,14 +1379,19 @@ HAPI int script_handler_parse_desc(Evas_Object *edje, const char *descfile) goto errout; } - fclose(fp); + if (fclose(fp) != 0) { + ErrPrint("fclose: %s\n", strerror(errno)); + } return LB_STATUS_SUCCESS; errout: ErrPrint("Parse error at %d file %s\n", lineno, util_basename(descfile)); - if (block) + if (block) { delete_block(block); - fclose(fp); + } + if (fclose(fp) != 0) { + ErrPrint("fclose: %s\n", strerror(errno)); + } return LB_STATUS_ERROR_INVALID; } diff --git a/include/conf.h b/include/conf.h index 2f80ff1..c8a3cc4 100644 --- a/include/conf.h +++ b/include/conf.h @@ -49,6 +49,8 @@ struct conf { double slave_ttl; double slave_activate_time; + double slave_relaunch_time; + int slave_relaunch_count; int max_log_line; int max_log_file; @@ -132,6 +134,8 @@ extern int conf_loader(void); #define REPLACE_TAG_APPID g_conf.replace_tag #define SLAVE_TTL g_conf.slave_ttl #define SLAVE_ACTIVATE_TIME g_conf.slave_activate_time +#define SLAVE_RELAUNCH_TIME g_conf.slave_relaunch_time +#define SLAVE_RELAUNCH_COUNT g_conf.slave_relaunch_count #define MAX_LOG_LINE g_conf.max_log_line #define MAX_LOG_FILE g_conf.max_log_file diff --git a/include/debug.h b/include/debug.h index 7ec29a5..d5a1b30 100644 --- a/include/debug.h +++ b/include/debug.h @@ -14,11 +14,23 @@ * limitations under the License. */ -#define DbgPrint(format, arg...) LOGD("[%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg) +#if !defined(SECURE_LOGD) +#define SECURE_LOGD LOGD +#endif -#define ErrPrint(format, arg...) LOGE("[%s/%s:%d] " format "", util_basename(__FILE__), __func__, __LINE__, ##arg) +#if !defined(SECURE_LOGE) +#define SECURE_LOGE LOGE +#endif -#define WarnPrint(format, arg...) LOGW("[%s/%s:%d] " format "", util_basename(__FILE__), __func__, __LINE__, ##arg) +#if !defined(SECURE_LOGW) +#define SECURE_LOGW LOGW +#endif + +#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) + +#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) + +#define WarnPrint(format, arg...) SECURE_LOGW(format, ##arg) #define DbgFree(a) do { \ free(a); \ diff --git a/include/lb.h b/include/lb.h index f9c7052..34bab45 100644 --- a/include/lb.h +++ b/include/lb.h @@ -46,11 +46,13 @@ extern int lb_is_pinned_up(const char *pkgname, const char *id); extern void lb_turn_secured_on(void); extern int lb_is_all_paused(void); +extern int lb_delete_all_deleteme(void); /*! * Exported API for each liveboxes */ extern const char *livebox_find_pkgname(const char *filename); extern int livebox_request_update_by_id(const char *filename); +extern int livebox_trigger_update_monitor(const char *id, int is_pd); /* End of a file */ diff --git a/include/main.h b/include/main.h index fa64b4e..c2ba761 100644 --- a/include/main.h +++ b/include/main.h @@ -15,5 +15,8 @@ */ extern int main_heap_monitor_is_enabled(void); +extern size_t main_heap_monitor_target_usage(const char *name); +extern int main_heap_monitor_add_target(const char *name); +extern int main_heap_monitor_del_target(const char *name); /* End of a file */ diff --git a/include/so_handler.h b/include/so_handler.h index a23b4d6..553825f 100644 --- a/include/so_handler.h +++ b/include/so_handler.h @@ -108,6 +108,24 @@ struct so_item { } adaptor; }; +enum current_operations { + LIVEBOX_OP_UNKNOWN, + LIVEBOX_OP_CREATE, + LIVEBOX_OP_RESIZE, + LIVEBOX_OP_CONTENT_EVENT, + LIVEBOX_OP_NEED_TO_UPDATE, + LIVEBOX_OP_NEED_TO_DESTROY, + LIVEBOX_OP_NEED_TO_CREATE, + LIVEBOX_OP_CHANGE_GROUP, + LIVEBOX_OP_GET_INFO, + LIVEBOX_OP_UPDATE_CONTENT, + LIVEBOX_OP_CLICKED, + LIVEBOX_OP_SYSTEM_EVENT, + LIVEBOX_OP_PINUP, + LIVEBOX_OP_IS_PINNED_UP, + LIVEBOX_OP_DESTROY +}; + extern struct instance *so_find_instance(const char *pkgname, const char *filename); extern int so_create(const char *pkgname, const char *filename, const char *content_info, int timeout, int has_livebox_script, const char *cluster, const char *category, const char *abi, struct instance **inst); extern int so_is_updated(struct instance *inst); @@ -124,4 +142,6 @@ extern char *so_pinup(struct instance *inst, int pinup); extern int so_is_pinned_up(struct instance *inst); extern int so_sys_event(struct instance *inst, int event); +extern enum current_operations so_current_op(void); + /* End of a file */ diff --git a/include/update_monitor.h b/include/update_monitor.h index e52a260..bd2b55c 100644 --- a/include/update_monitor.h +++ b/include/update_monitor.h @@ -21,5 +21,7 @@ extern int update_monitor_add_update_cb(const char *filename, int (*cb)(const ch extern int update_monitor_add_delete_cb(const char *filename, int (*cb)(const char *filename, void *data, int over), void *data); extern void *update_monitor_del_update_cb(const char *filename, int (*cb)(const char *filename, void *data, int over)); extern void *update_monitor_del_delete_cb(const char *filename, int (*cb)(const char *filename, void *data, int over)); +extern int update_monitor_trigger_update_cb(const char *filename, int over); +extern int update_monitor_trigger_delete_cb(const char *filename, int over); // End of a file diff --git a/org.tizen.data-provider-slave.manifest b/org.tizen.data-provider-slave.manifest index b61942c..16f8754 100644 --- a/org.tizen.data-provider-slave.manifest +++ b/org.tizen.data-provider-slave.manifest @@ -14,6 +14,8 @@ + + diff --git a/org.tizen.data-provider-slave.rule b/org.tizen.data-provider-slave.rule index ba3d8bb..61cfe4d 100644 --- a/org.tizen.data-provider-slave.rule +++ b/org.tizen.data-provider-slave.rule @@ -1,5 +1,7 @@ org.tizen.data-provider-slave device::app_logging w org.tizen.data-provider-slave system::vconf rwxat +org.tizen.data-provider-slave system::vconf_setting r +org.tizen.data-provider-slave system::vconf_system r org.tizen.data-provider-slave system::homedir rwxat org.tizen.data-provider-slave system::use_internet rw org.tizen.data-provider-slave system::media rwxat @@ -14,9 +16,13 @@ org.tizen.data-provider-slave data-provider-master::data rx org.tizen.data-provider-slave data-provider-master::share rwxat org.tizen.data-provider-slave data-provider-master::db rw org.tizen.data-provider-slave data-provider-master rw +org.tizen.data-provider-slave data-provider-master::utility rw org.tizen.data-provider-slave e17 rx +org.tizen.data-provider-slave dali x org.tizen.data-provider-slave pulseaudio rwxat org.tizen.data-provider-slave pkgmgr::db rw -org.tizen.data-provider-slave sys-assert::core rwxat e17 org.tizen.data-provider-slave rwx +org.tizen.app-tray org.tizen.data-provider-slave rx dbus org.tizen.data-provider-slave rwx +org.tizen.data-provider-slave sound_server rw +org.tizen.data-provider-slave tts-server rwx diff --git a/packaging/org.tizen.data-provider-slave.spec b/packaging/org.tizen.data-provider-slave.spec index 5e05282..49fdd13 100644 --- a/packaging/org.tizen.data-provider-slave.spec +++ b/packaging/org.tizen.data-provider-slave.spec @@ -2,7 +2,7 @@ Name: org.tizen.data-provider-slave Summary: Plugin type livebox service provider. -Version: 0.11.2 +Version: 0.12.13 Release: 1 Group: HomeTF/Livebox License: Flora License @@ -32,6 +32,7 @@ BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(com-core) BuildRequires: pkgconfig(shortcut) BuildRequires: pkgconfig(capi-system-system-settings) +BuildRequires: hash-signer Requires: data-provider-master %description @@ -43,6 +44,12 @@ Supporting the In-house livebox only. %setup -q %build +%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" +%endif + cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} #-fpie LDFLAGS="${LDFLAGS} -pie -O3" CFLAGS="${CFLAGS} -Wall -Winline -fno-builtin-malloc" make %{?jobs:-j%jobs} @@ -50,6 +57,11 @@ CFLAGS="${CFLAGS} -Wall -Winline -fno-builtin-malloc" make %{?jobs:-j%jobs} %install rm -rf %{buildroot} %make_install +%define tizen_sign 1 +%define tizen_sign_base %{_prefix}/apps/org.tizen.data-provider-slave +%define tizen_sign_level platform +%define tizen_author_sign 1 +%define tizen_dist_sign 1 mkdir -p %{buildroot}/%{_datarootdir}/license mkdir -p %{buildroot}%{app_data} @@ -60,9 +72,7 @@ chmod 755 %{app_data} %files -n org.tizen.data-provider-slave %manifest org.tizen.data-provider-slave.manifest %defattr(-,root,root,-) -%{_prefix}/apps/org.tizen.data-provider-slave/bin/data-provider-slave -%{_prefix}/apps/org.tizen.data-provider-slave/bin/icon-provider-slave -%{_prefix}/apps/org.tizen.data-provider-slave/res/edje/icon.edj +%{_prefix}/apps/org.tizen.data-provider-slave %{_datarootdir}/packages/org.tizen.data-provider-slave.xml %{_datarootdir}/license/* %{_sysconfdir}/smack/accesses.d/org.tizen.data-provider-slave.rule diff --git a/src/client.c b/src/client.c index d77236b..0348f64 100644 --- a/src/client.c +++ b/src/client.c @@ -271,8 +271,9 @@ static int method_update_content(struct event_arg *arg, void *data) static int method_pause(struct event_arg *arg, void *data) { lb_pause_all(); - if (s_info.ping_timer) + if (s_info.ping_timer) { ecore_timer_freeze(s_info.ping_timer); + } sqlite3_release_memory(SQLITE_FLUSH_MAX); malloc_trim(0); @@ -282,8 +283,9 @@ static int method_pause(struct event_arg *arg, void *data) static int method_resume(struct event_arg *arg, void *data) { lb_resume_all(); - if (s_info.ping_timer) + if (s_info.ping_timer) { ecore_timer_thaw(s_info.ping_timer); + } return LB_STATUS_SUCCESS; } @@ -310,8 +312,9 @@ static int method_connected(struct event_arg *arg, void *data) ret = provider_send_hello(); if (ret == 0) { s_info.ping_timer = ecore_timer_add(DEFAULT_PING_TIME, send_ping_cb, NULL); - if (!s_info.ping_timer) + if (!s_info.ping_timer) { ErrPrint("Failed to add a ping timer\n"); + } } return LB_STATUS_SUCCESS; diff --git a/src/conf.c b/src/conf.c index 4a7ad25..2d566cf 100644 --- a/src/conf.c +++ b/src/conf.c @@ -58,6 +58,7 @@ HAPI struct conf g_conf = { .slave_ttl = 30.0f, .slave_activate_time = 30.0f, + .slave_relaunch_time = 3.0f, .max_log_line = 1000, .max_log_file = 3, @@ -82,7 +83,7 @@ HAPI struct conf g_conf = { .input = "/dev/input/event1", }, - .ping_time = 240.0f, + .ping_time = 120.0f, .slave_max_load = 30, .use_sw_backend = 0, @@ -101,237 +102,251 @@ static void conf_update_size(void) static void use_xmonitor(char *buffer) { g_conf.use_xmonitor = !strcasecmp(buffer, "true"); - DbgPrint("Use xmonitor: %d\n", g_conf.use_xmonitor); } static void use_sw_backend_handler(char *buffer) { g_conf.use_sw_backend = !strcasecmp(buffer, "true"); - DbgPrint("SW Backend: %d\n", g_conf.use_sw_backend); } static void provider_method_handler(char *buffer) { g_conf.provider_method = strdup(buffer); - if (!g_conf.provider_method) + if (!g_conf.provider_method) { ErrPrint("Heap: %s\n", strerror(errno)); - - DbgPrint("Method: %s\n", g_conf.provider_method); + } } static void debug_mode_handler(char *buffer) { g_conf.debug_mode = !strcasecmp(buffer, "true"); - DbgPrint("Debug mode: %d\n", g_conf.debug_mode); } static void overwrite_content_handler(char *buffer) { g_conf.overwrite_content = !strcasecmp(buffer, "true"); - DbgPrint("Overwrite Content: %d\n", g_conf.overwrite_content); } static void com_core_thread_handler(char *buffer) { g_conf.com_core_thread = !strcasecmp(buffer, "true"); - DbgPrint("Com core thread: %d\n", g_conf.com_core_thread); } static void base_width_handler(char *buffer) { - if (sscanf(buffer, "%d", &g_conf.base_width) != 1) + if (sscanf(buffer, "%d", &g_conf.base_width) != 1) { ErrPrint("Failed to parse the base_width\n"); - - DbgPrint("Base width: %d\n", g_conf.base_width); + } } static void base_height_handler(char *buffer) { - if (sscanf(buffer, "%d", &g_conf.base_height) != 1) + if (sscanf(buffer, "%d", &g_conf.base_height) != 1) { ErrPrint("Failed to parse the base_height\n"); - DbgPrint("Base height: %d\n", g_conf.base_height); + } } static void minimum_period_handler(char *buffer) { - if (sscanf(buffer, "%lf", &g_conf.minimum_period) != 1) + if (sscanf(buffer, "%lf", &g_conf.minimum_period) != 1) { ErrPrint("Failed to parse the minimum_period\n"); + } DbgPrint("Minimum period: %lf\n", g_conf.minimum_period); } static void script_handler(char *buffer) { g_conf.default_conf.script = strdup(buffer); - if (!g_conf.default_conf.script) + if (!g_conf.default_conf.script) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Default script: %s\n", g_conf.default_conf.script); + } } static void default_abi_handler(char *buffer) { g_conf.default_conf.abi = strdup(buffer); - if (!g_conf.default_conf.abi) + if (!g_conf.default_conf.abi) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Default ABI: %s\n", g_conf.default_conf.abi); + } } static void default_group_handler(char *buffer) { g_conf.default_conf.pd_group = strdup(buffer); - if (!g_conf.default_conf.pd_group) + if (!g_conf.default_conf.pd_group) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Default PD Group: %s\n", g_conf.default_conf.pd_group); + } } static void default_period_handler(char *buffer) { - if (sscanf(buffer, "%lf", &g_conf.default_conf.period) != 1) + if (sscanf(buffer, "%lf", &g_conf.default_conf.period) != 1) { ErrPrint("Failed to parse the default_period\n"); + } DbgPrint("Default Period: %lf\n", g_conf.default_conf.period); } static void default_packet_time_handler(char *buffer) { - if (sscanf(buffer, "%lf", &g_conf.default_packet_time) != 1) + if (sscanf(buffer, "%lf", &g_conf.default_packet_time) != 1) { ErrPrint("Failed to parse the default_packet_time\n"); + } DbgPrint("Default packet time: %lf\n", g_conf.default_packet_time); } static void default_content_handler(char *buffer) { g_conf.default_content = strdup(buffer); - if (!g_conf.default_content) + if (!g_conf.default_content) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Default content: %s\n", g_conf.default_content); + } } static void default_title_handler(char *buffer) { g_conf.default_title = strdup(buffer); - if (!g_conf.default_title) + if (!g_conf.default_title) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Default title: %s\n", g_conf.default_title); + } } static void minimum_space_handler(char *buffer) { - if (sscanf(buffer, "%lu", &g_conf.minimum_space) != 1) + if (sscanf(buffer, "%lu", &g_conf.minimum_space) != 1) { ErrPrint("Failed to parse the minimum_space\n"); - DbgPrint("Minimum space: %lu\n", g_conf.minimum_space); + } } static void replace_tag_handler(char *buffer) { g_conf.replace_tag = strdup(buffer); - if (!g_conf.replace_tag) + if (!g_conf.replace_tag) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Replace Tag: %s\n", g_conf.replace_tag); + } } static void slave_ttl_handler(char *buffer) { - if (sscanf(buffer, "%lf", &g_conf.slave_ttl) != 1) + if (sscanf(buffer, "%lf", &g_conf.slave_ttl) != 1) { ErrPrint("Failed to parse the slave_ttl\n"); + } DbgPrint("Slave TTL: %lf\n", g_conf.slave_ttl); } static void slave_activate_time_handler(char *buffer) { - if (sscanf(buffer, "%lf", &g_conf.slave_activate_time) != 1) + if (sscanf(buffer, "%lf", &g_conf.slave_activate_time) != 1) { ErrPrint("Failed to parse the slave_activate_time\n"); + } DbgPrint("Slave activate time: %lf\n", g_conf.slave_activate_time); } +static void slave_relaunch_time_handler(char *buffer) +{ + if (sscanf(buffer, "%lf", &g_conf.slave_relaunch_time) != 1) { + ErrPrint("Failed to parse the slave_relaunch_time\n"); + } + DbgPrint("Slave relaunch time: %lf\n", g_conf.slave_relaunch_time); +} + +static void slave_relaunch_count_handler(char *buffer) +{ + if (sscanf(buffer, "%d", &g_conf.slave_relaunch_count) != 1) { + ErrPrint("Failed to parse the relaunch count\n"); + } +} + static void max_log_line_handler(char *buffer) { - if (sscanf(buffer, "%d", &g_conf.max_log_line) != 1) + if (sscanf(buffer, "%d", &g_conf.max_log_line) != 1) { ErrPrint("Failed to parse the max_log_line\n"); - DbgPrint("Max log line: %d\n", g_conf.max_log_line); + } } static void max_log_file_handler(char *buffer) { - if (sscanf(buffer, "%d", &g_conf.max_log_file) != 1) + if (sscanf(buffer, "%d", &g_conf.max_log_file) != 1) { ErrPrint("Failed to parse the max_log_file\n"); - DbgPrint("Max log file: %d\n", g_conf.max_log_file); + } } static void sqlite_flush_max_handler(char *buffer) { - if (sscanf(buffer, "%lu", &g_conf.sqlite_flush_max) != 1) + if (sscanf(buffer, "%lu", &g_conf.sqlite_flush_max) != 1) { ErrPrint("Failed to parse the sqlite_flush_max\n"); - DbgPrint("Flush size: %lu\n", g_conf.sqlite_flush_max); + } } static void db_path_handler(char *buffer) { g_conf.path.db = strdup(buffer); - if (!g_conf.path.db) + if (!g_conf.path.db) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("DB Path: %s\n", g_conf.path.db); + } } static void reader_path_handler(char *buffer) { g_conf.path.reader = strdup(buffer); - if (!g_conf.path.reader) + if (!g_conf.path.reader) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Reader Path: %s\n", g_conf.path.reader); + } } static void always_path_handler(char *buffer) { g_conf.path.always = strdup(buffer); - if (!g_conf.path.always) + if (!g_conf.path.always) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Always Path: %s\n", g_conf.path.always); + } } static void log_path_handler(char *buffer) { g_conf.path.slave_log = strdup(buffer); - if (!g_conf.path.slave_log) + if (!g_conf.path.slave_log) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("LOG Path: %s\n", g_conf.path.slave_log); + } } static void script_port_path_handler(char *buffer) { g_conf.path.script_port = strdup(buffer); - if (!g_conf.path.script_port) + if (!g_conf.path.script_port) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Script Port PATH: %s\n", g_conf.path.script_port); + } } static void share_path_handler(char *buffer) { g_conf.path.image = strdup(buffer); - if (!g_conf.path.image) + if (!g_conf.path.image) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Shared folder: %s\n", g_conf.path.image); + } } static void input_path_handler(char *buffer) { g_conf.path.input = strdup(buffer); - if (!g_conf.path.input) + if (!g_conf.path.input) { ErrPrint("Heap: %s\n", strerror(errno)); - DbgPrint("Input path: %s\n", g_conf.path.input); + } } static void ping_time_handler(char *buffer) { - if (sscanf(buffer, "%lf", &g_conf.ping_time) != 1) + if (sscanf(buffer, "%lf", &g_conf.ping_time) != 1) { ErrPrint("Failed to parse the ping_time\n"); + } g_conf.ping_time /= 2.0f; /*!< Half */ DbgPrint("Default ping time: %lf\n", g_conf.ping_time); } static void slave_max_loader(char *buffer) { - if (sscanf(buffer, "%d", &g_conf.slave_max_load) != 1) + if (sscanf(buffer, "%d", &g_conf.slave_max_load) != 1) { ErrPrint("Failed to parse the slave_max_load\n"); - DbgPrint("Max load: %d\n", g_conf.slave_max_load); + } } HAPI int conf_loader(void) @@ -345,7 +360,7 @@ HAPI int conf_loader(void) VALUE, ERROR, COMMENT, - END, + END } state; int ch_idx; int token_idx; @@ -414,6 +429,14 @@ HAPI int conf_loader(void) .handler = slave_activate_time_handler, }, { + .name = "slave_relaunch_time", + .handler = slave_relaunch_time_handler, + }, + { + .name = "slave_relaunch_count", + .handler = slave_relaunch_count_handler, + }, + { .name = "max_log_line", .handler = max_log_line_handler, }, @@ -493,7 +516,7 @@ HAPI int conf_loader(void) conf_update_size(); - fp = fopen("/usr/share/data-provider-master/conf.ini", "rt"); + fp = fopen(CONF_FILE, "rt"); if (!fp) { ErrPrint("Error: %s\n", strerror(errno)); return LB_STATUS_ERROR_IO; @@ -508,7 +531,7 @@ HAPI int conf_loader(void) do { c = getc(fp); if ((c == EOF) && (state == VALUE)) { - LOGD("[%s:%d] VALUE state EOF\n", __func__, __LINE__); + DbgPrint("[%s:%d] VALUE state EOF\n", __func__, __LINE__); state = END; } @@ -538,14 +561,17 @@ HAPI int conf_loader(void) /* Ignore empty space */ } else { state = TOKEN; - ungetc(c, fp); + if (ungetc(c, fp) != c) { + ErrPrint("ungetc: %s\n", strerror(errno)); + } } break; case SPACE: - if (c == '=') + if (c == '=') { state = VALUE; - else if (!isspace(c)) + } else if (!isspace(c)) { state = ERROR; + } break; case VALUE: if (c == '"') { @@ -554,8 +580,9 @@ HAPI int conf_loader(void) state = END; } else if (buffer_idx != 0) { buffer[buffer_idx++] = c; - if (buffer_idx >= sizeof(buffer)) + if (buffer_idx >= sizeof(buffer)) { state = ERROR; + } } else { quote = 1; } @@ -564,33 +591,40 @@ HAPI int conf_loader(void) /* Ignore */ } else if (quote == 1) { buffer[buffer_idx++] = c; - if (buffer_idx >= sizeof(buffer)) + if (buffer_idx >= sizeof(buffer)) { state = ERROR; + } } else { buffer[buffer_idx] = '\0'; - ungetc(c, fp); + if (ungetc(c, fp) != c) { + ErrPrint("ungetc: %s\n", strerror(errno)); + } state = END; } } else { buffer[buffer_idx++] = c; - if (buffer_idx >= sizeof(buffer)) + if (buffer_idx >= sizeof(buffer)) { state = ERROR; + } } break; case TOKEN: if (c == '=') { - if (token_idx < 0) + if (token_idx < 0) { state = ERROR; - else + } else { state = VALUE; + } } else if (isspace(c)) { - if (token_idx < 0) + if (token_idx < 0) { break; + } - if (token_handler[token_idx].name[ch_idx] != '\0') + if (token_handler[token_idx].name[ch_idx] != '\0') { state = ERROR; - else + } else { state = SPACE; + } } else { if (token_idx < 0) { /* Now start to find a token! */ @@ -600,16 +634,22 @@ HAPI int conf_loader(void) if (token_handler[token_idx].name[ch_idx] == c) { ch_idx++; } else { - ungetc(c, fp); - while (ch_idx-- > 0) - ungetc(token_handler[token_idx].name[ch_idx], fp); + if (ungetc(c, fp) != c) { + ErrPrint("ungetc: %s\n", strerror(errno)); + } + while (ch_idx-- > 0) { + if (ungetc(token_handler[token_idx].name[ch_idx], fp) != token_handler[token_idx].name[ch_idx]) { + ErrPrint("ungetc: %s\n", strerror(errno)); + } + } token_idx++; - if (token_handler[token_idx].name == NULL) + if (token_handler[token_idx].name == NULL) { state = ERROR; - else + } else { ch_idx = 0; + } } } break; @@ -629,7 +669,6 @@ HAPI int conf_loader(void) if (token_idx >= 0 && token_handler[token_idx].handler) { buffer[buffer_idx] = '\0'; - DbgPrint("BUFFER: [%s]\n", buffer); token_handler[token_idx].handler(buffer); } @@ -653,7 +692,9 @@ HAPI int conf_loader(void) linelen++; } while (c != EOF); - fclose(fp); + if (fclose(fp) != 0) { + ErrPrint("fclose: %s\n", strerror(errno)); + } return LB_STATUS_SUCCESS; } diff --git a/src/critical_log.c b/src/critical_log.c index 75d416c..cf5a94e 100644 --- a/src/critical_log.c +++ b/src/critical_log.c @@ -47,50 +47,62 @@ static struct { -HAPI int critical_log(const char *func, int line, const char *fmt, ...) +static inline void rotate_log(void) { - va_list ap; - int ret; - struct timeval tv; + char *filename; + int namelen; - if (!s_info.fp) - return LB_STATUS_ERROR_IO; + if (s_info.nr_of_lines < MAX_LOG_LINE) { + return; + } + + s_info.file_id = (s_info.file_id + 1) % MAX_LOG_FILE; + + namelen = strlen(s_info.filename) + strlen(SLAVE_LOG_PATH) + 30; + filename = malloc(namelen); + if (filename) { + snprintf(filename, namelen, "%s/%d_%s.%d", SLAVE_LOG_PATH, s_info.file_id, s_info.filename, getpid()); + + if (s_info.fp) { + if (fclose(s_info.fp) != 0) { + ErrPrint("fclose: %s\n", strerror(errno)); + } + } + + s_info.fp = fopen(filename, "w+"); + if (!s_info.fp) { + ErrPrint("Failed to open a file: %s\n", filename); + } - if (gettimeofday(&tv, NULL) < 0) { - ErrPrint("gettimeofday: %s\n", strerror(errno)); - tv.tv_sec = 0; - tv.tv_usec = 0; + DbgFree(filename); } - fprintf(s_info.fp, "%d %lu.%lu [%s:%d] ", getpid(), tv.tv_sec, tv.tv_usec, util_basename((char *)func), line); - va_start(ap, fmt); - ret = vfprintf(s_info.fp, fmt, ap); - va_end(ap); + s_info.nr_of_lines = 0; +} - s_info.nr_of_lines++; - if (s_info.nr_of_lines == MAX_LOG_LINE) { - char *filename; - int namelen; - s_info.file_id = (s_info.file_id + 1) % MAX_LOG_FILE; - namelen = strlen(s_info.filename) + strlen(SLAVE_LOG_PATH) + 20; - filename = malloc(namelen); - if (filename) { - snprintf(filename, namelen, "%s/%d_%s", SLAVE_LOG_PATH, s_info.file_id, s_info.filename); +HAPI int critical_log(const char *func, int line, const char *fmt, ...) +{ + va_list ap; + int ret; - if (s_info.fp) - fclose(s_info.fp); + if (!s_info.fp) { + return LB_STATUS_ERROR_IO; + } - s_info.fp = fopen(filename, "w+"); - if (!s_info.fp) - ErrPrint("Failed to open a file: %s\n", filename); + fprintf(s_info.fp, "%lf [%s:%d] ", util_timestamp(), util_basename((char *)func), line); - free(filename); - } + va_start(ap, fmt); + ret = vfprintf(s_info.fp, fmt, ap); + va_end(ap); - s_info.nr_of_lines = 0; + if (fflush(s_info.fp) != 0) { + ErrPrint("fflush: %s\n", strerror(errno)); } + + s_info.nr_of_lines++; + rotate_log(); return ret; } @@ -101,8 +113,9 @@ HAPI int critical_log_init(const char *name) int namelen; char *filename; - if (s_info.fp) + if (s_info.fp) { return LB_STATUS_SUCCESS; + } s_info.filename = strdup(name); if (!s_info.filename) { @@ -110,7 +123,7 @@ HAPI int critical_log_init(const char *name) return LB_STATUS_ERROR_MEMORY; } - namelen = strlen(name) + strlen(SLAVE_LOG_PATH) + 20; + namelen = strlen(name) + strlen(SLAVE_LOG_PATH) + 30; filename = malloc(namelen); if (!filename) { @@ -120,7 +133,7 @@ HAPI int critical_log_init(const char *name) return LB_STATUS_ERROR_MEMORY; } - snprintf(filename, namelen, "%s/%d_%s", SLAVE_LOG_PATH, s_info.file_id, name); + snprintf(filename, namelen, "%s/%d_%s.%d", SLAVE_LOG_PATH, s_info.file_id, name, getpid()); s_info.fp = fopen(filename, "w+"); if (!s_info.fp) { @@ -145,7 +158,9 @@ HAPI int critical_log_fini(void) } if (s_info.fp) { - fclose(s_info.fp); + if (fclose(s_info.fp) != 0) { + ErrPrint("fclose: %s\n", strerror(errno)); + } s_info.fp = NULL; } diff --git a/src/fault.c b/src/fault.c index 3c712d9..69344ba 100644 --- a/src/fault.c +++ b/src/fault.c @@ -30,6 +30,7 @@ #include #include +#include #include @@ -42,7 +43,11 @@ #include "util.h" static struct info { +#if defined(_USE_ECORE_TIME_GET) + double alarm_tv; +#else struct timeval alarm_tv; +#endif int marked; int disable_checker; } s_info = { @@ -58,14 +63,24 @@ static void signal_handler(int signum, siginfo_t *info, void *unused) so_fname = util_get_current_module(&symbol); if (info->si_signo == SIGALRM) { - struct timeval tv; - struct timeval res_tv; - if (!s_info.marked) { DbgPrint("Ignore false alarm signal [false]\n"); return; } +#if defined(_USE_ECORE_TIME_GET) + double tv; + tv = ecore_time_get(); + if (tv - s_info.alarm_tv < DEFAULT_LIFE_TIMER) { + DbgPrint("Ignore false alarm signal [%lf]\n", tv - s_info.alarm_tv); + return; + } + + CRITICAL_LOG("ALARM: %lf (%d, %d)\n", tv - s_info.alarm_tv, DEFAULT_LIFE_TIMER, DEFAULT_LOAD_TIMER); +#else + struct timeval tv; + struct timeval res_tv; + if (gettimeofday(&tv, NULL) < 0) { ErrPrint("gettimeofday: %s\n", strerror(errno)); tv.tv_sec = 0; @@ -83,8 +98,9 @@ static void signal_handler(int signum, siginfo_t *info, void *unused) return; } - DbgPrint("ALARM: %d.%d (%d, %d)\n", + CRITICAL_LOG("ALARM: %d.%d (%d, %d)\n", res_tv.tv_sec, res_tv.tv_usec, DEFAULT_LIFE_TIMER, DEFAULT_LOAD_TIMER); +#endif } else if (so_fname) { int fd; char log_fname[256]; @@ -92,18 +108,20 @@ static void signal_handler(int signum, siginfo_t *info, void *unused) snprintf(log_fname, sizeof(log_fname), "%s/slave.%d", SLAVE_LOG_PATH, getpid()); fd = open(log_fname, O_WRONLY|O_CREAT|O_SYNC, 0644); if (fd >= 0) { - if (write(fd, so_fname, strlen(so_fname)) != strlen(so_fname)) + if (write(fd, so_fname, strlen(so_fname)) != strlen(so_fname)) { ErrPrint("Failed to recording the fault SO filename (%s)\n", so_fname); - close(fd); + } + if (close(fd) < 0) { + ErrPrint("close: %s\n", strerror(errno)); + } } } - ErrPrint("=====\n"); - ErrPrint("SIGNAL> Received from PID[%d]\n", info->si_pid); - ErrPrint("SIGNAL> Signal: %d (%d)\n", signum, info->si_signo); - ErrPrint("SIGNAL> Error code: %d\n", info->si_code); - ErrPrint("SIGNAL> Address: %p\n", info->si_addr); - ErrPrint("Package: [%s] Symbol[%s]\n", so_fname, symbol); + CRITICAL_LOG("SIGNAL> Received from PID[%d]\n", info->si_pid); + CRITICAL_LOG("SIGNAL> Signal: %d (%d)\n", signum, info->si_signo); + CRITICAL_LOG("SIGNAL> Error code: %d\n", info->si_code); + CRITICAL_LOG("SIGNAL> Address: %p\n", info->si_addr); + CRITICAL_LOG("Package: [%s] Symbol[%s]\n", so_fname, symbol); free(so_fname); free(symbol); @@ -114,34 +132,54 @@ static void signal_handler(int signum, siginfo_t *info, void *unused) HAPI int fault_init(void) { struct sigaction act; - - if (access("/tmp/live.err", F_OK) == 0) - ErrPrint("Error log still exists (/tmp/live.err)\n"); + char *ecore_abort; act.sa_sigaction = signal_handler; act.sa_flags = SA_SIGINFO; - sigemptyset(&act.sa_mask); - sigaddset(&act.sa_mask, SIGSEGV); - sigaddset(&act.sa_mask, SIGABRT); - sigaddset(&act.sa_mask, SIGILL); - sigaddset(&act.sa_mask, SIGUSR1); - sigaddset(&act.sa_mask, SIGALRM); + if (sigemptyset(&act.sa_mask) != 0) { + ErrPrint("Failed to init signal: %s\n", strerror(errno)); + } + + if (sigaddset(&act.sa_mask, SIGUSR1) != 0) { + ErrPrint("Failed to add set: %s\n", strerror(errno)); + } + if (sigaddset(&act.sa_mask, SIGALRM) != 0) { + ErrPrint("Failed to add set: %s\n", strerror(errno)); + } + + ecore_abort = getenv("ECORE_ERROR_ABORT"); + if (!ecore_abort || ecore_abort[0] != '1') { + if (sigaddset(&act.sa_mask, SIGSEGV) != 0) { + ErrPrint("Failed to add set: %s\n", strerror(errno)); + } + if (sigaddset(&act.sa_mask, SIGABRT) != 0) { + ErrPrint("Failed to add set: %s\n", strerror(errno)); + } + if (sigaddset(&act.sa_mask, SIGILL) != 0) { + ErrPrint("Failed to add set: %s\n", strerror(errno)); + } - if (sigaction(SIGSEGV, &act, NULL) < 0) - ErrPrint("Failed to install the SEGV handler\n"); + if (sigaction(SIGSEGV, &act, NULL) < 0) { + ErrPrint("Failed to install the SEGV handler\n"); + } - if (sigaction(SIGABRT, &act, NULL) < 0) - ErrPrint("Faield to install the ABRT handler\n"); + if (sigaction(SIGABRT, &act, NULL) < 0) { + ErrPrint("Faield to install the ABRT handler\n"); + } - if (sigaction(SIGILL, &act, NULL) < 0) - ErrPrint("Faield to install the ILL handler\n"); + if (sigaction(SIGILL, &act, NULL) < 0) { + ErrPrint("Faield to install the ILL handler\n"); + } + } - if (sigaction(SIGUSR1, &act, NULL) < 0) + if (sigaction(SIGUSR1, &act, NULL) < 0) { ErrPrint("Failed to install the USR1 handler\n"); + } - if (sigaction(SIGALRM, &act, NULL) < 0) + if (sigaction(SIGALRM, &act, NULL) < 0) { ErrPrint("Failed to install the ALRM handler\n"); + } return 0; } @@ -157,8 +195,9 @@ HAPI int fault_fini(void) HAPI int fault_mark_call(const char *pkgname, const char *filename, const char *funcname, int noalarm, int life_time) { - if (!s_info.disable_checker) + if (!s_info.disable_checker) { provider_send_call(pkgname, filename, funcname); + } /*! * \NOTE * To use this "alarm", the livebox have to do not use the 'sleep' series functions. @@ -168,11 +207,15 @@ HAPI int fault_mark_call(const char *pkgname, const char *filename, const char * * Enable alarm for detecting infinite loop */ if (!noalarm) { +#if defined(_USE_ECORE_TIME_GET) + s_info.alarm_tv = ecore_time_get(); +#else if (gettimeofday(&s_info.alarm_tv, NULL) < 0) { ErrPrint("gettimeofday: %s\n", strerror(errno)); s_info.alarm_tv.tv_sec = 0; s_info.alarm_tv.tv_usec = 0; } +#endif s_info.marked = 1; alarm(life_time); } @@ -191,8 +234,9 @@ HAPI int fault_unmark_call(const char *pkgname, const char *filename, const char s_info.marked = 0; } - if (!s_info.disable_checker) + if (!s_info.disable_checker) { provider_send_ret(pkgname, filename, funcname); + } return 0; } diff --git a/src/lb.c b/src/lb.c index f0d7aaf..1d82a88 100644 --- a/src/lb.c +++ b/src/lb.c @@ -17,6 +17,7 @@ #include #include /* exit */ #include +#include /* access */ #include #include @@ -35,8 +36,14 @@ #include "fault.h" #include "util.h" +#define IS_LB_SHOWN(itm) (!(itm)->inst->item->has_livebox_script || ((itm)->inst->item->has_livebox_script && (itm)->is_lb_show)) + int errno; +#define UPDATE_ITEM_DELETED (-1) +#define UPDATE_INVOKED (-2) +#define UPDATE_NOT_INVOKED (0) + struct item { Ecore_Timer *timer; struct instance *inst; @@ -48,6 +55,8 @@ struct item { int is_paused; /* 1 is paused, 0 is resumed */ double sleep_at; + unsigned int updated_in_pause; + int is_lb_show; int is_pd_show; int is_lb_updated; @@ -55,7 +64,7 @@ struct item { static struct info { Eina_List *item_list; - struct item *update; + Eina_List *update_list; Eina_List *pending_list; Ecore_Timer *pending_timer; Eina_List *pd_open_pending_list; @@ -66,7 +75,7 @@ static struct info { int pending_timer_freezed; } s_info = { .item_list = NULL, - .update = NULL, + .update_list = NULL, .pending_list = NULL, .pending_timer = NULL, .pd_open_pending_list = NULL, @@ -93,8 +102,9 @@ static void pending_timer_freeze(void) static void pending_timer_thaw(void) { DbgPrint("Freezed Count: %d\n", s_info.pending_timer_freezed); - if (!s_info.pending_timer_freezed) + if (!s_info.pending_timer_freezed) { return; + } s_info.pending_timer_freezed--; if (s_info.pending_timer && !s_info.pending_timer_freezed) { @@ -117,7 +127,6 @@ static inline int pd_is_opened(const char *pkgname) i = 0; EINA_LIST_FOREACH(s_info.pd_list, l, tmp) { if (pkgname && !strcmp(pkgname, tmp)) { - DbgPrint("PD(%s) is opened\n", pkgname); return 1; } @@ -132,25 +141,29 @@ static Eina_Bool pd_open_pended_cmd_consumer_cb(void *data) struct item *item; item = eina_list_nth(s_info.pd_open_pending_list, 0); - if (!item) + if (!item) { goto cleanout; + } - if (s_info.update) + if (eina_list_data_find(s_info.update_list, item)) { return ECORE_CALLBACK_RENEW; + } s_info.pd_open_pending_list = eina_list_remove(s_info.pd_open_pending_list, item); - DbgPrint("Consuming pended item: %s\n", item->inst->id); /*! * \note * To prevent from checking the is_updated function */ - (void)updator_cb(item); - if (s_info.pd_open_pending_list) + if (updator_cb(item) == ECORE_CALLBACK_CANCEL) { + /* Item is destroyed */ + } + + if (s_info.pd_open_pending_list) { return ECORE_CALLBACK_RENEW; + } cleanout: s_info.pd_open_pending_timer = NULL; - DbgPrint("open pd pending list exhausted\n"); return ECORE_CALLBACK_CANCEL; } @@ -159,33 +172,38 @@ static Eina_Bool pended_cmd_consumer_cb(void *data) struct item *item; item = eina_list_nth(s_info.pending_list, 0); - if (!item) + if (!item) { goto cleanout; + } - if (s_info.update || pd_is_opened(item->inst->item->pkgname) < 0) + if (eina_list_data_find(s_info.update_list, item) || pd_is_opened(item->inst->item->pkgname) < 0) { return ECORE_CALLBACK_RENEW; + } s_info.pending_list = eina_list_remove(s_info.pending_list, item); - DbgPrint("Consuming pended item: %s\n", item->inst->id); /*! * \note * To prevent from checking the is_updated function */ - (void)updator_cb(item); - if (s_info.pending_list) + if (updator_cb(item) == ECORE_CALLBACK_CANCEL) { + /* item is destroyed */ + } + + if (s_info.pending_list) { return ECORE_CALLBACK_RENEW; + } cleanout: s_info.pending_timer = NULL; s_info.pending_timer_freezed = 0; - DbgPrint("pending list exhausted\n"); return ECORE_CALLBACK_CANCEL; } static inline __attribute__((always_inline)) int activate_pending_consumer(void) { - if (s_info.pending_timer) + if (s_info.pending_timer) { return 0; + } s_info.pending_timer = ecore_timer_add(0.000001f, pended_cmd_consumer_cb, NULL); if (!s_info.pending_timer) { @@ -198,7 +216,6 @@ static inline __attribute__((always_inline)) int activate_pending_consumer(void) * Just freeze the timer. */ if (s_info.pending_timer_freezed) { - DbgPrint("Pending timer created and freezed\n"); ecore_timer_freeze(s_info.pending_timer); } @@ -207,29 +224,30 @@ static inline __attribute__((always_inline)) int activate_pending_consumer(void) static inline void deactivate_pending_consumer(void) { - if (!s_info.pending_timer) + if (!s_info.pending_timer) { return; + } ecore_timer_del(s_info.pending_timer); s_info.pending_timer = NULL; s_info.pending_timer_freezed = 0; - DbgPrint("Clear the pending timer\n"); } static inline void deactivate_pd_open_pending_consumer(void) { - if (!s_info.pd_open_pending_timer) + if (!s_info.pd_open_pending_timer) { return; + } ecore_timer_del(s_info.pd_open_pending_timer); s_info.pd_open_pending_timer = NULL; - DbgPrint("Clear the open_pd_pending timer\n"); } static inline int __attribute__((always_inline)) activate_pd_open_pending_consumer(void) { - if (s_info.pd_open_pending_timer) + if (s_info.pd_open_pending_timer) { return 0; + } s_info.pd_open_pending_timer = ecore_timer_add(0.000001f, pd_open_pended_cmd_consumer_cb, NULL); if (!s_info.pd_open_pending_timer) { @@ -248,8 +266,9 @@ static inline void migrate_to_pd_open_pending_list(const char *pkgname) int cnt = 0; EINA_LIST_FOREACH_SAFE(s_info.pending_list, l, n, item) { - if (strcmp(pkgname, item->inst->item->pkgname)) + if (strcmp(pkgname, item->inst->item->pkgname)) { continue; + } s_info.pending_list = eina_list_remove(s_info.pending_list, item); s_info.pd_open_pending_list = eina_list_append(s_info.pd_open_pending_list, item); @@ -257,14 +276,12 @@ static inline void migrate_to_pd_open_pending_list(const char *pkgname) } if (s_info.pd_open_pending_list) { - DbgPrint("Activate PD open pending consumer (%s)\n", pkgname); activate_pd_open_pending_consumer(); } - if (!s_info.pending_list) + if (!s_info.pending_list) { deactivate_pending_consumer(); - - DbgPrint("%d items are migrated\n", cnt); + } } static inline void migrate_to_pending_list(const char *pkgname) @@ -275,24 +292,37 @@ static inline void migrate_to_pending_list(const char *pkgname) int cnt = 0; EINA_LIST_FOREACH_SAFE(s_info.pd_open_pending_list, l, n, item) { - if (strcmp(pkgname, item->inst->item->pkgname)) + if (strcmp(pkgname, item->inst->item->pkgname)) { continue; + } s_info.pd_open_pending_list = eina_list_remove(s_info.pd_open_pending_list, item); s_info.pending_list = eina_list_append(s_info.pending_list, item); cnt++; } - if (s_info.pending_list) + if (s_info.pending_list) { activate_pending_consumer(); + } - if (!s_info.pd_open_pending_list) + if (!s_info.pd_open_pending_list) { deactivate_pd_open_pending_consumer(); + } +} - DbgPrint("%d items are migrated\n", cnt); +static inline int is_pended_item(struct item *item) +{ + struct item *in_item; + if (pd_is_opened(item->inst->item->pkgname) == 1) { + in_item = eina_list_data_find(s_info.pd_open_pending_list, item); + } else { + in_item = eina_list_data_find(s_info.pending_list, item); + } + + return (in_item == item); } -static inline int append_pending_list(struct item *item) +static int append_pending_list(struct item *item) { if (pd_is_opened(item->inst->item->pkgname) == 1) { if (eina_list_data_find(s_info.pd_open_pending_list, item) == item) { @@ -300,7 +330,6 @@ static inline int append_pending_list(struct item *item) return LB_STATUS_ERROR_EXIST; } - DbgPrint("Activate PD open pending consumer (%s)\n", item->inst->item->pkgname); if (activate_pd_open_pending_consumer() < 0) { ErrPrint("Failed to activate PD open pending consumer\n"); return LB_STATUS_ERROR_FAULT; @@ -313,48 +342,73 @@ static inline int append_pending_list(struct item *item) return LB_STATUS_ERROR_EXIST; } - if (activate_pending_consumer() < 0) + if (activate_pending_consumer() < 0) { return LB_STATUS_ERROR_FAULT; + } s_info.pending_list = eina_list_append(s_info.pending_list, item); } return 0; } -static inline void timer_thaw(struct item *item) +/*! + * \brief + * This function can call the update callback + * return 0 if there is no changes + * return -1 the item is deleted + */ +static inline int timer_thaw(struct item *item) { double pending; double period; double delay; double sleep_time; + if (!item->timer) { + return 0; + } + ecore_timer_thaw(item->timer); period = ecore_timer_interval_get(item->timer); pending = ecore_timer_pending_get(item->timer); delay = util_time_delay_for_compensation(period) - pending; ecore_timer_delay(item->timer, delay); - DbgPrint("Compensated: %lf\n", delay); - if (item->sleep_at == 0.0f) - return; + if (item->sleep_at == 0.0f) { + return 0; + } sleep_time = util_timestamp() - item->sleep_at; + item->sleep_at = 0.0f; + if (sleep_time > pending) { - DbgPrint("Update time elapsed\n"); - (void)updator_cb(item); + if (updator_cb(item) == ECORE_CALLBACK_CANCEL) { + /* item is destroyed */ + return UPDATE_ITEM_DELETED; + } else { + return UPDATE_INVOKED; + } } - item->sleep_at = 0.0f; + return UPDATE_NOT_INVOKED; } -static inline void timer_freeze(struct item *item) +static void timer_freeze(struct item *item) { - struct timeval tv; + if (!item->timer) { + return; + } + ecore_timer_freeze(item->timer); - if (ecore_timer_interval_get(item->timer) <= 1.0f) + if (ecore_timer_interval_get(item->timer) <= 1.0f) { return; + } +#if defined(_USE_ECORE_TIME_GET) + item->sleep_at = ecore_time_get(); +#else + struct timeval tv; if (gettimeofday(&tv, NULL) < 0) { ErrPrint("gettimeofday: %s\n", strerror(errno)); tv.tv_sec = 0; @@ -362,6 +416,7 @@ static inline void timer_freeze(struct item *item) } item->sleep_at = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; +#endif } static inline void update_monitor_cnt(struct item *item) @@ -380,10 +435,22 @@ static inline void update_monitor_cnt(struct item *item) * And handling this heavy updating from the * file update callback. */ - if (interval >= MINIMUM_UPDATE_INTERVAL) - item->monitor_cnt++; - else + if (interval >= MINIMUM_UPDATE_INTERVAL) { + if (eina_list_data_find(s_info.update_list, item)) { + /*! + * \note + * If already in updating mode, + * reset the monitor_cnt to 1, + * all updated event will be merged into A inotify event + */ + DbgPrint("While waiting updated event, content is updated [%s]\n", item->inst->id); + item->monitor_cnt = 1; + } else { + item->monitor_cnt++; + } + } else { item->heavy_updating = 1; + } item->update_interval = now; } @@ -394,8 +461,9 @@ static inline Eina_List *find_item(struct instance *inst) struct item *item; EINA_LIST_FOREACH(s_info.item_list, l, item) { - if (item->inst == inst) + if (item->inst == inst) { return l; + } } return NULL; @@ -418,16 +486,16 @@ static inline int output_handler(struct item *item) } if (item->monitor_cnt == 0) { - if (!invalid) + if (!invalid) { fault_unmark_call(item->inst->item->pkgname, item->inst->id, "update,crashed", NO_ALARM); + } if (item->monitor) { ecore_timer_del(item->monitor); item->monitor = NULL; } - if (s_info.update == item) - s_info.update = NULL; + s_info.update_list = eina_list_remove(s_info.update_list, item); if (item->deleteme) { provider_send_deleted(item->inst->item->pkgname, item->inst->id); @@ -444,8 +512,9 @@ static int desc_updated_cb(const char *filename, void *data, int over) { struct item *item; - if (over) + if (over) { WarnPrint("Event Q overflow\n"); + } item = data; @@ -468,8 +537,9 @@ static int file_updated_cb(const char *filename, void *data, int over) char *title = NULL; int ret; - if (over) + if (over) { WarnPrint("Event Q overflow\n"); + } item = data; @@ -485,29 +555,48 @@ static int file_updated_cb(const char *filename, void *data, int over) return EXIT_SUCCESS; /*!< To keep the callback */ } - if (!item->inst->item->has_livebox_script || (item->inst->item->has_livebox_script && item->is_lb_show)) { + if (IS_LB_SHOWN(item)) { provider_send_updated(item->inst->item->pkgname, item->inst->id, - item->inst->w, item->inst->h, item->inst->priority, content, title); + item->inst->w, item->inst->h, item->inst->priority, + content, title); } else { - DbgPrint("Livebox script is not ready yet\n"); item->is_lb_updated++; } return output_handler(item); } +static void reset_lb_updated_flag(struct item *item) +{ + if (!item->is_lb_updated) { + return; + } + + DbgPrint("[%s] Updated %d times, (content: %s), (title: %s)\n", + item->inst->id, item->is_lb_updated, + item->inst->content, item->inst->title); + + provider_send_updated(item->inst->item->pkgname, item->inst->id, + item->inst->w, item->inst->h, item->inst->priority, + item->inst->content, item->inst->title); + + item->is_lb_updated = 0; +} + static inline int clear_from_pd_open_pending_list(struct item *item) { Eina_List *l; struct item *tmp; EINA_LIST_FOREACH(s_info.pd_open_pending_list, l, tmp) { - if (tmp != item) + if (tmp != item) { continue; + } s_info.pd_open_pending_list = eina_list_remove_list(s_info.pd_open_pending_list, l); - if (!s_info.pd_open_pending_list) + if (!s_info.pd_open_pending_list) { deactivate_pd_open_pending_consumer(); + } return LB_STATUS_SUCCESS; } @@ -520,12 +609,14 @@ static inline int clear_from_pending_list(struct item *item) struct item *tmp; EINA_LIST_FOREACH(s_info.pending_list, l, tmp) { - if (tmp != item) + if (tmp != item) { continue; + } s_info.pending_list = eina_list_remove_list(s_info.pending_list, l); - if (!s_info.pending_list) + if (!s_info.pending_list) { deactivate_pending_consumer(); + } return LB_STATUS_SUCCESS; } @@ -538,19 +629,25 @@ static Eina_Bool update_timeout_cb(void *data) item = data; - DbgPrint("UPDATE TIMEOUT ========> %s - %s\n", item->inst->item->pkgname, item->inst->id); + ErrPrint("UPDATE TIMEOUT ========> %s - %s\n", item->inst->item->pkgname, item->inst->id); - if (s_info.update != item) + if (!eina_list_data_find(s_info.update_list, item)) { ErrPrint("Updating item is not matched\n"); + } fault_unmark_call(item->inst->item->pkgname, item->inst->id, "update,crashed", NO_ALARM); fault_mark_call(item->inst->item->pkgname, item->inst->id, "update,timeout", NO_ALARM, DEFAULT_LIFE_TIMER); - s_info.update = NULL; + s_info.update_list = eina_list_remove(s_info.update_list, item); exit(ETIME); return ECORE_CALLBACK_CANCEL; } +/*! + * \note + * This must has to return ECORE_CALLBACK_CANCEL, only if the item is deleted. + * So every caller, should manage the deleted item correctly. + */ static Eina_Bool updator_cb(void *data) { struct item *item; @@ -558,26 +655,46 @@ static Eina_Bool updator_cb(void *data) item = data; - if (item->monitor) {/*!< If this item is already in update process */ + if (item->monitor) { /*!< If this item is already in update process */ + return ECORE_CALLBACK_RENEW; + } + + if (!IS_LB_SHOWN(item)) { + DbgPrint("%s is not shown yet. make delay for updates\n", item->inst->item->pkgname); + (void)append_pending_list(item); return ECORE_CALLBACK_RENEW; } + if (item->is_paused) { + item->updated_in_pause++; + DbgPrint("%s is paused[%d]. make delay for updating\n", item->inst->item->pkgname, item->updated_in_pause); + return ECORE_CALLBACK_RENEW; + } + + item->updated_in_pause = 0; + ret = so_is_updated(item->inst); if (ret <= 0) { if (so_need_to_destroy(item->inst) == NEED_TO_DESTROY) { provider_send_deleted(item->inst->item->pkgname, item->inst->id); lb_destroy(item->inst->item->pkgname, item->inst->id); - - ecore_timer_del(item->timer); - item->timer = NULL; + /*! + * \CRITICAL + * Every caller of this, must not access the item from now. + */ return ECORE_CALLBACK_CANCEL; } + reset_lb_updated_flag(item); return ECORE_CALLBACK_RENEW; } - if (s_info.update || pd_is_opened(item->inst->item->pkgname) < 0) { - DbgPrint("%s is busy\n", s_info.update ? s_info.update->inst->id : item->inst->id); + /*! + * \note + * Check the update_list, if you want make serialized update + */ + if (/*s_info.update_list || */pd_is_opened(item->inst->item->pkgname) < 0) { + DbgPrint("%s is busy\n", item->inst->id); (void)append_pending_list(item); return ECORE_CALLBACK_RENEW; } @@ -589,6 +706,14 @@ static Eina_Bool updator_cb(void *data) return ECORE_CALLBACK_RENEW; } + ret = so_update(item->inst); + if (ret < 0) { + ecore_timer_del(item->monitor); + item->monitor = NULL; + reset_lb_updated_flag(item); + return ECORE_CALLBACK_RENEW; + } + /*! * \note * Counter of the event monitor is only used for asynchronous content updating, @@ -597,18 +722,6 @@ static Eina_Bool updator_cb(void *data) */ item->monitor_cnt = 1; - s_info.update = item; - - ret = so_update(item->inst); - if (ret < 0) { - item->monitor_cnt--; - - ecore_timer_del(item->monitor); - item->monitor = NULL; - s_info.update = NULL; - return ECORE_CALLBACK_RENEW; - } - /*! * \note * While waiting the Callback function call, @@ -620,8 +733,24 @@ static Eina_Bool updator_cb(void *data) (void)append_pending_list(item); } - if (ret & OUTPUT_UPDATED) + if (ret & OUTPUT_UPDATED) { + /*! + * \NOTE + * In this case, there is potential issue + * 1. User added update CALLBACK -> Inotify event (Only once) + * > We have to detect this case. Is it possible to be a user callback called faster than inotify event handler? + * 2. Inotify event -> User added update CALLBACK -> Inotify event + * > Okay. What we want is this. + */ update_monitor_cnt(item); + } + + /* + * \NOTE + * This should be updated after "update_monitor_cnt" function call, + * because the update_monitor_cnt function will see the s_info.update variable, + */ + s_info.update_list = eina_list_append(s_info.update_list, item); return ECORE_CALLBACK_RENEW; } @@ -649,6 +778,7 @@ static inline int add_desc_update_monitor(const char *id, struct item *item) { char *filename; int len; + int ret; len = strlen(util_uri_to_path(id)) + strlen(".desc") + 1; filename = malloc(len); @@ -658,21 +788,14 @@ static inline int add_desc_update_monitor(const char *id, struct item *item) } snprintf(filename, len, "%s.desc", util_uri_to_path(id)); - DbgPrint("Add DESC monitor: %s\n", filename); - return update_monitor_add_update_cb(filename, desc_updated_cb, item); + ret = update_monitor_add_update_cb(filename, desc_updated_cb, item); + free(filename); + return ret; } static inline int add_file_update_monitor(const char *id, struct item *item) { - char *filename; - - filename = strdup(util_uri_to_path(id)); - if (!filename) { - ErrPrint("Heap: %s (%s)\n", strerror(errno), id); - return LB_STATUS_ERROR_MEMORY; - } - - return update_monitor_add_update_cb(filename, file_updated_cb, item); + return update_monitor_add_update_cb(util_uri_to_path(id), file_updated_cb, item); } static inline int update_monitor_add(const char *id, struct item *item) @@ -721,8 +844,9 @@ const char *livebox_find_pkgname(const char *filename) struct item *item; EINA_LIST_FOREACH(s_info.item_list, l, item) { - if (!strcmp(item->inst->id, filename)) + if (!strcmp(item->inst->id, filename)) { return item->inst->item->pkgname; + } } return NULL; @@ -733,6 +857,18 @@ int livebox_request_update_by_id(const char *filename) Eina_List *l; struct item *item; + if (so_current_op() != LIVEBOX_OP_UNKNOWN) { + ErrPrint("Current operation: %d\n", so_current_op()); + /*! + * \note + * Some case requires to update the content of other box from livebox_XXX ABI. + * In that case this function can be used so we have not to filter it from here. + * ex) Setting accessibility. + * Press the assistive light, turned on, need to update other instances too. + * Then the box will use this function from livebox_clicked function. + */ + } + EINA_LIST_FOREACH(s_info.item_list, l, item) { if (!strcmp(item->inst->id, filename)) { return append_pending_list(item); @@ -742,14 +878,55 @@ int livebox_request_update_by_id(const char *filename) return LB_STATUS_ERROR_NOT_EXIST; } +int livebox_trigger_update_monitor(const char *filename, int is_pd) +{ + char *fname; + int ret; + + if (so_current_op() != LIVEBOX_OP_UNKNOWN) { + ErrPrint("Current operation: %d\n", so_current_op()); + return LB_STATUS_ERROR_INVALID; + } + + if (is_pd) { + int len; + len = strlen(filename) + strlen(".desc"); + + fname = malloc(len + 1); + if (!fname) { + ErrPrint("Heap: %s\n", strerror(errno)); + return LB_STATUS_ERROR_MEMORY; + } + + snprintf(fname, len, "%s.desc", filename); + } else { + fname = strdup(filename); + if (!fname) { + ErrPrint("Heap: %s\n", strerror(errno)); + return LB_STATUS_ERROR_MEMORY; + } + } + + if (access(fname, R_OK | W_OK) != 0) { + ErrPrint("access: %s (%s)\n", fname, strerror(errno)); + ret = LB_STATUS_ERROR_IO; + } else { + ret = update_monitor_trigger_update_cb(fname, 0); + } + + free(fname); + return ret; +} + HAPI int lb_open_pd(const char *pkgname) { Eina_List *l; char *tmp; EINA_LIST_FOREACH(s_info.pd_list, l, tmp) { - if (!strcmp(pkgname, tmp)) + if (!strcmp(pkgname, tmp)) { return 0; + } } tmp = strdup(pkgname); @@ -758,8 +935,9 @@ HAPI int lb_open_pd(const char *pkgname) return LB_STATUS_ERROR_MEMORY; } - if (!s_info.pd_list) + if (!s_info.pd_list) { pending_timer_freeze(); + } s_info.pd_list = eina_list_append(s_info.pd_list, tmp); @@ -778,14 +956,16 @@ HAPI int lb_close_pd(const char *pkgname) char *tmp; EINA_LIST_FOREACH_SAFE(s_info.pd_list, l, n, tmp) { - if (strcmp(tmp, pkgname)) + if (strcmp(tmp, pkgname)) { continue; + } s_info.pd_list = eina_list_remove(s_info.pd_list, tmp); free(tmp); - if (!s_info.pd_list) + if (!s_info.pd_list) { pending_timer_thaw(); + } /*! * Move all items in pd_open_pending_list @@ -818,8 +998,9 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info if (!skip_need_to_create) { ret = so_create_needed(pkgname, cluster, category, abi); - if (ret != NEED_TO_CREATE) + if (ret != NEED_TO_CREATE) { return LB_STATUS_ERROR_PERMISSION; + } need_to_create = 1; } @@ -836,7 +1017,6 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info return ret; } - DbgPrint("Content: [%s]\n", content_info); create_ret = so_create(pkgname, id, content_info, timeout, has_livebox_script, cluster, category, abi, &inst); if (create_ret < 0) { update_monitor_del(id, item); @@ -855,13 +1035,14 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info if (!item->timer) { ErrPrint("Failed to add timer (%s - %s, content[%s], cluster[%s], category[%s], abi[%s]\n", pkgname, id, content_info, cluster, category, abi); update_monitor_del(id, item); - so_destroy(inst); + (void)so_destroy(inst); free(item); return LB_STATUS_ERROR_FAULT; } - if (s_info.paused) + if (s_info.paused) { timer_freeze(item); + } } else { DbgPrint("Local update timer is disabled: %lf (%d)\n", period, s_info.secured); item->timer = NULL; @@ -890,8 +1071,9 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info char *tmp; tmp = strdup(*out_content); - if (!tmp) + if (!tmp) { ErrPrint("Memory: %s\n", strerror(errno)); + } *out_content = tmp; } @@ -900,8 +1082,9 @@ HAPI int lb_create(const char *pkgname, const char *id, const char *content_info char *tmp; tmp = strdup(*out_title); - if (!tmp) + if (!tmp) { ErrPrint("Memory: %s\n", strerror(errno)); + } *out_title = tmp; } @@ -935,8 +1118,7 @@ HAPI int lb_destroy(const char *pkgname, const char *id) item = eina_list_data_get(l); s_info.item_list = eina_list_remove_list(s_info.item_list, l); - if (s_info.update == item) - s_info.update = NULL; + s_info.update_list = eina_list_remove(s_info.update_list, item); if (item->timer) { clear_from_pd_open_pending_list(item); @@ -944,10 +1126,11 @@ HAPI int lb_destroy(const char *pkgname, const char *id) ecore_timer_del(item->timer); item->timer = NULL; - if (item->monitor) + if (item->monitor) { item->deleteme = 1; - else + } else { update_monitor_del(id, item); + } } if (!item->monitor) { @@ -980,16 +1163,18 @@ HAPI int lb_resize(const char *pkgname, const char *id, int w, int h) item = eina_list_data_get(l); ret = so_resize(inst, w, h); - if (ret < 0) + if (ret < 0) { return ret; + } if (ret & NEED_TO_SCHEDULE) { DbgPrint("%s Returns NEED_TO_SCHEDULE\n", pkgname); (void)append_pending_list(item); } - if (ret & OUTPUT_UPDATED) + if (ret & OUTPUT_UPDATED) { update_monitor_cnt(item); + } return LB_STATUS_SUCCESS; } @@ -1044,8 +1229,9 @@ HAPI int lb_set_period(const char *pkgname, const char *id, double period) return LB_STATUS_ERROR_FAULT; } - if (s_info.paused) + if (s_info.paused) { timer_freeze(item); + } } } @@ -1074,16 +1260,18 @@ HAPI int lb_clicked(const char *pkgname, const char *id, const char *event, doub item = eina_list_data_get(l); ret = so_clicked(inst, event, timestamp, x, y); - if (ret < 0) + if (ret < 0) { return ret; + } if (ret & NEED_TO_SCHEDULE) { DbgPrint("%s Returns NEED_TO_SCHEDULE\n", pkgname); (void)append_pending_list(item); } - if (ret & OUTPUT_UPDATED) + if (ret & OUTPUT_UPDATED) { update_monitor_cnt(item); + } return LB_STATUS_SUCCESS; } @@ -1109,43 +1297,46 @@ HAPI int lb_script_event(const char *pkgname, const char *id, const char *emissi item = eina_list_data_get(l); - DbgPrint("source(%s) emission(%s) %d\n", source, emission, item->inst->item->has_livebox_script); - if (emission && source && !strcmp(source, util_uri_to_path(id))) { + if (emission && source && !strcmp(source, id)) { if (item->inst->item->has_livebox_script) { if (!strcmp(emission, "lb,show")) { - DbgPrint("Livebox(%s) script is ready now\n", id); item->is_lb_show = 1; - DbgPrint("Updated %d times, (content: %s), (title: %s)\n", item->is_lb_updated, item->inst->content, item->inst->title); - if (item->is_lb_updated) { - provider_send_updated(item->inst->item->pkgname, item->inst->id, - item->inst->w, item->inst->h, item->inst->priority, item->inst->content, item->inst->title); - item->is_lb_updated = 0; + if (item->is_lb_updated && !is_pended_item(item)) { + reset_lb_updated_flag(item); } + + source = util_uri_to_path(source); } else if (!strcmp(emission, "lb,hide")) { DbgPrint("Livebox(%s) script is hide now\n", id); item->is_lb_show = 0; + + source = util_uri_to_path(source); } } if (!strcmp(emission, "pd,show")) { item->is_pd_show = 1; + source = util_uri_to_path(source); } else if (!strcmp(emission, "pd,hide")) { item->is_pd_show = 0; + source = util_uri_to_path(source); } } ret = so_script_event(inst, emission, source, event_info); - if (ret < 0) + if (ret < 0) { return ret; + } if (ret & NEED_TO_SCHEDULE) { DbgPrint("%s Returns NEED_TO_SCHEDULE\n", pkgname); (void)append_pending_list(item); } - if (ret & OUTPUT_UPDATED) + if (ret & OUTPUT_UPDATED) { update_monitor_cnt(item); + } return LB_STATUS_SUCCESS; } @@ -1203,33 +1394,38 @@ HAPI int lb_change_group(const char *pkgname, const char *id, const char *cluste item = eina_list_data_get(l); ret = so_change_group(inst, cluster, category); - if (ret < 0) + if (ret < 0) { return ret; + } if (ret & NEED_TO_SCHEDULE) { DbgPrint("%s Returns NEED_TO_SCHEDULE\n", pkgname); (void)append_pending_list(item); } - if (ret & OUTPUT_UPDATED) + if (ret & OUTPUT_UPDATED) { update_monitor_cnt(item); + } return LB_STATUS_SUCCESS; } -static inline int lb_sys_event(struct instance *inst, struct item *item, int event) +static int lb_sys_event(struct instance *inst, struct item *item, int event) { int ret; ret = so_sys_event(inst, event); - if (ret < 0) + if (ret < 0) { return ret; + } - if (ret & NEED_TO_SCHEDULE) + if (ret & NEED_TO_SCHEDULE) { (void)append_pending_list(item); + } - if (ret & OUTPUT_UPDATED) + if (ret & OUTPUT_UPDATED) { update_monitor_cnt(item); + } return LB_STATUS_SUCCESS; } @@ -1287,14 +1483,17 @@ HAPI int lb_update_all(const char *pkgname, const char *cluster, const char *cat DbgPrint("Update content for %s\n", pkgname ? pkgname : "(all)"); EINA_LIST_FOREACH_SAFE(s_info.item_list, l, n, item) { - if (item->deleteme) + if (item->deleteme) { continue; + } - if (cluster && strcasecmp(item->inst->cluster, cluster)) + if (cluster && strcasecmp(item->inst->cluster, cluster)) { continue; + } - if (category && strcasecmp(item->inst->category, category)) + if (category && strcasecmp(item->inst->category, category)) { continue; + } if (pkgname && strlen(pkgname)) { if (!strcmp(item->inst->item->pkgname, pkgname)) { @@ -1308,6 +1507,28 @@ HAPI int lb_update_all(const char *pkgname, const char *cluster, const char *cat return LB_STATUS_SUCCESS; } +HAPI int lb_delete_all_deleteme(void) +{ + Eina_List *l; + Eina_List *n; + struct item *item; + int cnt = 0; + + EINA_LIST_FOREACH_SAFE(s_info.item_list, l, n, item) { + if (!item->deleteme) { + continue; + } + + update_monitor_del(item->inst->id, item); + (void)so_destroy(item->inst); + free(item); + cnt++; + } + + DbgPrint("Delete all deleteme: %d\n", cnt); + return LB_STATUS_SUCCESS; +} + HAPI int lb_system_event_all(int event) { Eina_List *l; @@ -1315,8 +1536,9 @@ HAPI int lb_system_event_all(int event) struct item *item; EINA_LIST_FOREACH_SAFE(s_info.item_list, l, n, item) { - if (item->deleteme) + if (item->deleteme) { continue; + } DbgPrint("System event for %s (%d)\n", item->inst->id, event); lb_sys_event(item->inst, item, event); @@ -1341,16 +1563,10 @@ HAPI void lb_pause_all(void) } if (item->is_paused) { - DbgPrint("Instance %s is already paused\n", item->inst->id); continue; } - if (item->timer) { - DbgPrint("Instance %s freeze timer\n", item->inst->item->pkgname); - timer_freeze(item); - } else { - DbgPrint("Instance %s has no timer\n", item->inst->item->pkgname); - } + timer_freeze(item); lb_sys_event(item->inst, item, LB_SYS_EVENT_PAUSED); } @@ -1359,29 +1575,40 @@ HAPI void lb_pause_all(void) HAPI void lb_resume_all(void) { Eina_List *l; + Eina_List *n; struct item *item; s_info.paused = 0; pending_timer_thaw(); - EINA_LIST_FOREACH(s_info.item_list, l, item) { + EINA_LIST_FOREACH_SAFE(s_info.item_list, l, n, item) { if (item->deleteme) { DbgPrint("Instance %s skip timer resume (deleteme)\n", item->inst->item->pkgname); continue; } if (item->is_paused) { - DbgPrint("Instance %s is still paused\n", item->inst->id); continue; } - if (item->timer) { - DbgPrint("Instance %s resume timer\n", item->inst->item->pkgname); - timer_thaw(item); + lb_sys_event(item->inst, item, LB_SYS_EVENT_RESUMED); + + if (item->updated_in_pause) { + (void)append_pending_list(item); + item->updated_in_pause = 0; } - lb_sys_event(item->inst, item, LB_SYS_EVENT_RESUMED); + /*! + * \note + * After send the resume callback, call this function. + * Because the timer_thaw can call the update function. + * Before resumed event is notified to the livebox, + * Do not call update function + */ + if (timer_thaw(item) == UPDATE_ITEM_DELETED) { + /* item is deleted */ + } } } @@ -1392,8 +1619,9 @@ HAPI int lb_pause(const char *pkgname, const char *id) struct item *item; inst = so_find_instance(pkgname, id); - if (!inst) + if (!inst) { return LB_STATUS_ERROR_INVALID; + } l = find_item(inst); if (!l) { @@ -1402,8 +1630,9 @@ HAPI int lb_pause(const char *pkgname, const char *id) } item = eina_list_data_get(l); - if (!item) + if (!item) { return LB_STATUS_ERROR_FAULT; + } if (item->deleteme) { DbgPrint("Instance %s will be deleted (%s)\n", item->inst->item->pkgname, item->inst->id); @@ -1413,12 +1642,10 @@ HAPI int lb_pause(const char *pkgname, const char *id) item->is_paused = 1; if (s_info.paused) { - DbgPrint("Already paused: %s\n", item->inst->id); return LB_STATUS_SUCCESS; } - if (item->timer) - timer_freeze(item); + timer_freeze(item); lb_sys_event(inst, item, LB_SYS_EVENT_PAUSED); @@ -1430,10 +1657,12 @@ HAPI int lb_resume(const char *pkgname, const char *id) struct instance *inst; Eina_List *l; struct item *item; + int ret; inst = so_find_instance(pkgname, id); - if (!inst) + if (!inst) { return LB_STATUS_ERROR_INVALID; + } l = find_item(inst); if (!l) { @@ -1442,8 +1671,9 @@ HAPI int lb_resume(const char *pkgname, const char *id) } item = eina_list_data_get(l); - if (!item) + if (!item) { return LB_STATUS_ERROR_FAULT; + } if (item->deleteme) { DbgPrint("Instance %s will be deleted (%s)\n", item->inst->item->pkgname, item->inst->id); @@ -1453,14 +1683,31 @@ HAPI int lb_resume(const char *pkgname, const char *id) item->is_paused = 0; if (s_info.paused) { - DbgPrint("Instance %s is still paused\n", item->inst->id); return LB_STATUS_SUCCESS; } - if (item->timer) - timer_thaw(item); - lb_sys_event(inst, item, LB_SYS_EVENT_RESUMED); + + ret = timer_thaw(item); + if (ret == UPDATE_ITEM_DELETED) { + /*! + * \note + * ITEM is deleted + */ + return LB_STATUS_SUCCESS; + } else if (ret == UPDATE_INVOKED) { + /*! + * \note + * if the update is successfully done, the updated_in_pause will be reset'd. + * or append it to the pending list + */ + } + + if (item->updated_in_pause) { + (void)append_pending_list(item); + item->updated_in_pause = 0; + } + return LB_STATUS_SUCCESS; } diff --git a/src/main.c b/src/main.c index 8bd502c..480d0e6 100644 --- a/src/main.c +++ b/src/main.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -35,7 +36,6 @@ #include #include -#include #include #include #include @@ -63,13 +63,21 @@ #endif static struct info { - int heap_monitor; char *font_name; int font_size; + int (*heap_monitor_initialized)(void); + size_t (*heap_monitor_target_usage)(const char *name); + int (*heap_monitor_add_target)(const char *name); + int (*heap_monitor_del_target)(const char *name); + void *heap_monitor; } s_info = { - .heap_monitor = 0, .font_name = NULL, .font_size = DEFAULT_FONT_SIZE, + .heap_monitor_initialized = NULL, + .heap_monitor_target_usage = NULL, + .heap_monitor_add_target = NULL, + .heap_monitor_del_target = NULL, + .heap_monitor = NULL, }; static void update_font_cb(void *data) @@ -102,22 +110,30 @@ static void font_changed_cb(keynode_t *node, void *user_data) { char *font_name; - font_name = vconf_get_str("db/setting/accessibility/font_name"); - if (!font_name) { - ErrPrint("Invalid font name (NULL)\n"); - return; - } + if (s_info.font_name) { + font_name = vconf_get_str("db/setting/accessibility/font_name"); + if (!font_name) { + ErrPrint("Invalid font name (NULL)\n"); + return; + } - if (s_info.font_name && !strcmp(s_info.font_name, font_name)) { - DbgPrint("Font is not changed (Old: %s(%p) <> New: %s(%p))\n", s_info.font_name, s_info.font_name, font_name, font_name); - free(font_name); - return; - } + if (!strcmp(s_info.font_name, font_name)) { + DbgPrint("Font is not changed (Old: %s(%p) <> New: %s(%p))\n", s_info.font_name, s_info.font_name, font_name, font_name); + free(font_name); + return; + } - if (s_info.font_name) { DbgPrint("Release old font name: %s(%p)\n", s_info.font_name, s_info.font_name); free(s_info.font_name); - s_info.font_name = NULL; + } else { + int ret; + + font_name = NULL; + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &font_name); + if (ret != SYSTEM_SETTINGS_ERROR_NONE || !font_name) { + ErrPrint("System settings: %d, font_name[%p]\n", ret, font_name); + return; + } } s_info.font_name = font_name; @@ -161,8 +177,9 @@ static void font_size_cb(system_settings_key_e key, void *user_data) { int size; - if (system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &size) != SYSTEM_SETTINGS_ERROR_NONE) + if (system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &size) != SYSTEM_SETTINGS_ERROR_NONE) { return; + } size = convert_font_size(size); @@ -183,8 +200,9 @@ static void mmc_changed_cb(keynode_t *node, void *user_data) static void time_changed_cb(keynode_t *node, void *user_data) { - if (vconf_keynode_get_int(node) != VCONFKEY_SYSMAN_STIME_CHANGED) + if (vconf_keynode_get_int(node) != VCONFKEY_SYSMAN_STIME_CHANGED) { return; + } DbgPrint("Time is changed\n"); lb_system_event_all(LB_SYS_EVENT_TIME_CHANGED); @@ -193,16 +211,21 @@ static void time_changed_cb(keynode_t *node, void *user_data) static bool app_create(void *data) { int ret; - int size = DEFAULT_FONT_SIZE; + + DbgPrint("Scale factor: %lf\n", elm_config_scale_get()); ret = conf_loader(); DbgPrint("Configureation manager is initiated: %d\n", ret); - DbgPrint("Scale factor: %lf\n", elm_config_scale_get()); - if (COM_CORE_THREAD) - setenv("PROVIDER_COM_CORE_THREAD", "true", 0); - else - setenv("PROVIDER_COM_CORE_THREAD", "false", 0); + if (COM_CORE_THREAD) { + if (setenv("PROVIDER_COM_CORE_THREAD", "true", 0) < 0) { + ErrPrint("setenv: %s\n", strerror(errno)); + } + } else { + if (setenv("PROVIDER_COM_CORE_THREAD", "false", 0) < 0){ + ErrPrint("setenv: %s\n", strerror(errno)); + } + } ret = livebox_service_init(); DbgPrint("Livebox service init: %d\n", ret); @@ -216,14 +239,15 @@ static bool app_create(void *data) */ ret = fault_init(); DbgPrint("Crash recover is initiated: %d\n", ret); + ret = update_monitor_init(); DbgPrint("Content update monitor is initiated: %d\n", ret); ret = vconf_notify_key_changed("db/setting/accessibility/font_name", font_changed_cb, NULL); - DbgPrint("System font is changed: %d\n", ret); + DbgPrint("System font changed callback is added: %d\n", ret); ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, font_size_cb, NULL); - DbgPrint("System font size is changed: %d\n", ret); + DbgPrint("System font size changed callback is added: %d\n", ret); ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_STIME, time_changed_cb, NULL); DbgPrint("System time changed event callback added: %d\n", ret); @@ -231,13 +255,8 @@ static bool app_create(void *data) ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, mmc_changed_cb, NULL); DbgPrint("MMC status changed event callback added: %d\n", ret); - s_info.font_name = vconf_get_str("db/setting/accessibility/font_name"); - DbgPrint("Current font: %s\n", s_info.font_name); - - ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &size); - s_info.font_size = convert_font_size(size); - DbgPrint("Current size: %d\n", s_info.font_size); - + font_changed_cb(NULL, NULL); + font_size_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, NULL); return TRUE; } @@ -245,8 +264,14 @@ static void app_terminate(void *data) { int ret; + ret = lb_delete_all_deleteme(); + DbgPrint("Delete all deleteme: %d\n", ret); + ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE); - ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE); + DbgPrint("unset fontsize: %d\n", ret); + + ret = vconf_ignore_key_changed("db/setting/accessibility/font_name", font_changed_cb); + DbgPrint("Remove font change callback: %d\n", ret); ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_STIME, time_changed_cb); DbgPrint("Remove time changed callback: %d\n", ret); @@ -256,6 +281,7 @@ static void app_terminate(void *data) ret = update_monitor_fini(); DbgPrint("Content update monitor is finalized: %d\n", ret); + ret = fault_fini(); DbgPrint("Crash recover is finalized: %d\n", ret); @@ -265,6 +291,8 @@ static void app_terminate(void *data) ret = livebox_service_fini(); DbgPrint("livebox service fini: %d\n", ret); + free(s_info.font_name); + s_info.font_name = NULL; return; } @@ -315,13 +343,7 @@ static void app_service(service_h service, void *data) return; } - if (!!strcasecmp(secured, "true")) { - if (s_info.heap_monitor) { - heap_monitor_start(); - /* Add GUARD */ - // heap_monitor_add_target("/usr/apps/org.tizen."EXEC_NAME"/bin/"EXEC_NAME); - } - } else { + if (!strcasecmp(secured, "true")) { /* Don't use the update timer */ lb_turn_secured_on(); } @@ -330,18 +352,12 @@ static void app_service(service_h service, void *data) DbgPrint("Secured: %s\n", secured); ret = client_init(name); free(name); + free(secured); initialized = 1; return; } -/*Define it as empty for libc < 2.14 */ -#ifndef __MALLOC_HOOK_VOLATILE -# define __MALLOC_HOOK_VOLATILE -#endif - -void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook)(void) = heap_monitor_init; - #if defined(_ENABLE_MCHECK) static inline void mcheck_cb(enum mcheck_status status) { @@ -371,22 +387,35 @@ static inline void mcheck_cb(enum mcheck_status status) } #endif +#define BIN_PATH "/usr/apps/org.tizen.data-provider-slave/bin/" int main(int argc, char *argv[]) { int ret; app_event_callback_s event_callback; const char *option; + memset(argv[0], 0, strlen(argv[0])); + strcpy(argv[0], BIN_PATH "data-provider-slave"); + DbgPrint("Replace argv[0] with %s\n", argv[0]); + #if defined(_ENABLE_MCHECK) mcheck(mcheck_cb); #endif option = getenv("PROVIDER_DISABLE_CALL_OPTION"); - if (option && !strcasecmp(option, "true")) + if (option && !strcasecmp(option, "true")) { fault_disable_call_option(); + } option = getenv("PROVIDER_HEAP_MONITOR_START"); - if (option && !strcasecmp(option, "true")) - s_info.heap_monitor = 1; + if (option && !strcasecmp(option, "true")) { + s_info.heap_monitor = dlopen("/usr/lib/libheap-monitor.so", RTLD_NOW); + if (s_info.heap_monitor) { + s_info.heap_monitor_initialized = dlsym(s_info.heap_monitor, "heap_monitor_initialized"); + s_info.heap_monitor_target_usage = dlsym(s_info.heap_monitor, "heap_monitor_target_usage"); + s_info.heap_monitor_add_target = dlsym(s_info.heap_monitor, "heap_monitor_add_target"); + s_info.heap_monitor_del_target = dlsym(s_info.heap_monitor, "heap_monitor_del_target"); + } + } setenv("BUFMGR_LOCK_TYPE", "once", 0); setenv("BUFMGR_MAP_CACHE", "true", 0); @@ -404,12 +433,34 @@ int main(int argc, char *argv[]) event_callback.region_format_changed = app_region_changed; ret = app_efl_main(&argc, &argv, &event_callback, NULL); critical_log_fini(); + ErrPrint("Failed to init: %d\n", ret); + if (s_info.heap_monitor) { + if (dlclose(s_info.heap_monitor) < 0) { + ErrPrint("dlclose: %s\n", strerror(errno)); + } + } + return ret; } HAPI int main_heap_monitor_is_enabled(void) { - return s_info.heap_monitor; + return s_info.heap_monitor_initialized ? s_info.heap_monitor_initialized() : 0; +} + +HAPI size_t main_heap_monitor_target_usage(const char *name) +{ + return s_info.heap_monitor_target_usage ? s_info.heap_monitor_target_usage(name) : 0; +} + +HAPI int main_heap_monitor_add_target(const char *name) +{ + return s_info.heap_monitor_add_target ? s_info.heap_monitor_add_target(name) : 0; +} + +HAPI int main_heap_monitor_del_target(const char *name) +{ + return s_info.heap_monitor_del_target ? s_info.heap_monitor_del_target(name) : 0; } /* End of a file */ diff --git a/src/so_handler.c b/src/so_handler.c index 3d2b13d..64f4342 100644 --- a/src/so_handler.c +++ b/src/so_handler.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -39,8 +38,10 @@ int errno; static struct info { Eina_List *livebox_list; + enum current_operations current_op; } s_info = { .livebox_list = NULL, + .current_op = LIVEBOX_OP_UNKNOWN, }; static inline struct so_item *find_livebox(const char *pkgname) @@ -49,8 +50,9 @@ static inline struct so_item *find_livebox(const char *pkgname) struct so_item *item; EINA_LIST_FOREACH(s_info.livebox_list, l, item) { - if (!strcmp(item->pkgname, pkgname)) + if (!strcmp(item->pkgname, pkgname)) { return item; + } } return NULL; @@ -122,8 +124,10 @@ static void delete_livebox(struct so_item *item) ErrPrint("Package %s, finalize returns %d\n", item->pkgname, ret); } - heap_monitor_del_target(item->so_fname); - dlclose(item->handle); + main_heap_monitor_del_target(item->so_fname); + if (dlclose(item->handle) != 0) { + ErrPrint("dlclose: %s\n", dlerror()); + } free(item->so_fname); free(item->pkgname); free(item); @@ -132,6 +136,7 @@ static void delete_livebox(struct so_item *item) static struct so_item *new_adaptor(const char *pkgname, const char *abi) { struct so_item *item; + char *errmsg; item = calloc(1, sizeof(*item)); if (!item) { @@ -175,6 +180,11 @@ static struct so_item *new_adaptor(const char *pkgname, const char *abi) } fault_unmark_call(pkgname, __func__, __func__, USE_ALARM); + errmsg = dlerror(); + if (errmsg) { + DbgPrint("dlerror(can be ignored): %s\n", errmsg); + } + item->adaptor.create = (adaptor_create_t)dlsym(item->handle, "livebox_create"); if (!item->adaptor.create) { ErrPrint("symbol: livebox_create - %s\n", dlerror()); @@ -190,60 +200,74 @@ static struct so_item *new_adaptor(const char *pkgname, const char *abi) } item->adaptor.pinup = (adaptor_pinup_t)dlsym(item->handle, "livebox_pinup"); - if (!item->adaptor.pinup) + if (!item->adaptor.pinup) { ErrPrint("symbol: livebox_pinup - %s\n", dlerror()); + } item->adaptor.is_updated = (adaptor_is_updated_t)dlsym(item->handle, "livebox_need_to_update"); - if (!item->adaptor.is_updated) + if (!item->adaptor.is_updated) { ErrPrint("symbol: livebox_need_to_update - %s\n", dlerror()); + } item->adaptor.update_content = (adaptor_update_content_t)dlsym(item->handle, "livebox_update_content"); - if (!item->adaptor.update_content) + if (!item->adaptor.update_content) { ErrPrint("symbol: livebox_update_content - %s\n", dlerror()); + } item->adaptor.clicked = (adaptor_clicked_t)dlsym(item->handle, "livebox_clicked"); - if (!item->adaptor.clicked) + if (!item->adaptor.clicked) { ErrPrint("symbol: livebox_clicked - %s\n", dlerror()); + } item->adaptor.script_event = (adaptor_script_t)dlsym(item->handle, "livebox_content_event"); - if (!item->adaptor.script_event) + if (!item->adaptor.script_event) { ErrPrint("symbol: livebox_content_event - %s\n", dlerror()); + } item->adaptor.resize = (adaptor_resize_t)dlsym(item->handle, "livebox_resize"); - if (!item->adaptor.resize) + if (!item->adaptor.resize) { ErrPrint("symbol: livebox_resize - %s\n", dlerror()); + } item->adaptor.create_needed = (adaptor_create_needed_t)dlsym(item->handle, "livebox_need_to_create"); - if (!item->adaptor.create_needed) + if (!item->adaptor.create_needed) { ErrPrint("symbol: livebox_need_to_create - %s\n", dlerror()); + } item->adaptor.change_group = (adaptor_change_group_t)dlsym(item->handle, "livebox_change_group"); - if (!item->adaptor.change_group) + if (!item->adaptor.change_group) { ErrPrint("symbol: livebox_change_group - %s\n", dlerror()); + } item->adaptor.get_output_info = (adaptor_get_output_info_t)dlsym(item->handle, "livebox_get_info"); - if (!item->adaptor.get_output_info) + if (!item->adaptor.get_output_info) { ErrPrint("symbol: livebox_get_info - %s\n", dlerror()); + } item->adaptor.initialize = (adaptor_initialize_t)dlsym(item->handle, "livebox_initialize"); - if (!item->adaptor.initialize) + if (!item->adaptor.initialize) { ErrPrint("symbol: livebox_initialize - %s\n", dlerror()); + } item->adaptor.finalize = (adaptor_finalize_t)dlsym(item->handle, "livebox_finalize"); - if (!item->adaptor.finalize) + if (!item->adaptor.finalize) { ErrPrint("symbol: livebox_finalize - %s\n", dlerror()); + } item->adaptor.need_to_destroy = (adaptor_need_to_destroy_t)dlsym(item->handle, "livebox_need_to_destroy"); - if (!item->adaptor.need_to_destroy) + if (!item->adaptor.need_to_destroy) { ErrPrint("symbol: livebox_need_to_destroy - %s\n", dlerror()); + } item->adaptor.sys_event = (adaptor_system_event_t)dlsym(item->handle, "livebox_system_event"); - if (!item->adaptor.sys_event) + if (!item->adaptor.sys_event) { ErrPrint("symbol: lievbox_system_event - %s\n", dlerror()); + } item->adaptor.is_pinned_up = (adaptor_is_pinned_up_t)dlsym(item->handle, "livebox_is_pinned_up"); - if (!item->adaptor.is_pinned_up) + if (!item->adaptor.is_pinned_up) { ErrPrint("symbol: livebox_is_pinned_up - %s\n", dlerror()); + } if (item->adaptor.initialize) { int ret; @@ -252,7 +276,7 @@ static struct so_item *new_adaptor(const char *pkgname, const char *abi) fault_unmark_call(pkgname, "initialize", __func__, USE_ALARM); if (ret < 0) { ErrPrint("Failed to initialize package %s\n", pkgname); - heap_monitor_del_target(item->so_fname); + main_heap_monitor_del_target(item->so_fname); delete_livebox(item); return NULL; } @@ -265,6 +289,7 @@ static struct so_item *new_adaptor(const char *pkgname, const char *abi) static struct so_item *new_livebox(const char *pkgname) { struct so_item *item; + char *errmsg; item = calloc(1, sizeof(*item)); if (!item) { @@ -308,6 +333,11 @@ static struct so_item *new_livebox(const char *pkgname) } fault_unmark_call(pkgname, __func__, __func__, USE_ALARM); + errmsg = dlerror(); + if (errmsg) { + DbgPrint("dlerror(can be ignored): %s\n", errmsg); + } + item->livebox.create = (create_t)dlsym(item->handle, "livebox_create"); if (!item->livebox.create) { ErrPrint("symbol: livebox_create - %s\n", dlerror()); @@ -323,62 +353,76 @@ static struct so_item *new_livebox(const char *pkgname) } item->livebox.pinup = (pinup_t)dlsym(item->handle, "livebox_pinup"); - if (!item->livebox.pinup) + if (!item->livebox.pinup) { ErrPrint("symbol: livebox_pinup - %s\n", dlerror()); + } item->livebox.is_updated = (is_updated_t)dlsym(item->handle, "livebox_need_to_update"); - if (!item->livebox.is_updated) + if (!item->livebox.is_updated) { ErrPrint("symbol: livebox_need_to_update - %s\n", dlerror()); + } item->livebox.update_content = (update_content_t)dlsym(item->handle, "livebox_update_content"); - if (!item->livebox.update_content) + if (!item->livebox.update_content) { ErrPrint("symbol: livebox_update_content - %s\n", dlerror()); + } item->livebox.clicked = (clicked_t)dlsym(item->handle, "livebox_clicked"); - if (!item->livebox.clicked) + if (!item->livebox.clicked) { ErrPrint("symbol: livebox_clicked - %s\n", dlerror()); + } item->livebox.script_event = (script_t)dlsym(item->handle, "livebox_content_event"); - if (!item->livebox.script_event) + if (!item->livebox.script_event) { ErrPrint("symbol: livebox_content_event - %s\n", dlerror()); + } item->livebox.resize = (resize_t)dlsym(item->handle, "livebox_resize"); - if (!item->livebox.resize) + if (!item->livebox.resize) { ErrPrint("symbol: livebox_resize - %s\n", dlerror()); + } item->livebox.create_needed = (create_needed_t)dlsym(item->handle, "livebox_need_to_create"); - if (!item->livebox.create_needed) + if (!item->livebox.create_needed) { ErrPrint("symbol: livebox_need_to_create - %s\n", dlerror()); + } item->livebox.change_group = (change_group_t)dlsym(item->handle, "livebox_change_group"); - if (!item->livebox.change_group) + if (!item->livebox.change_group) { ErrPrint("symbol: livebox_change_group - %s\n", dlerror()); + } item->livebox.get_output_info = (get_output_info_t)dlsym(item->handle, "livebox_get_info"); - if (!item->livebox.get_output_info) + if (!item->livebox.get_output_info) { ErrPrint("symbol: livebox_get_info - %s\n", dlerror()); + } item->livebox.initialize = (initialize_t)dlsym(item->handle, "livebox_initialize"); - if (!item->livebox.initialize) + if (!item->livebox.initialize) { ErrPrint("symbol: livebox_initialize - %s\n", dlerror()); + } item->livebox.finalize = (finalize_t)dlsym(item->handle, "livebox_finalize"); - if (!item->livebox.finalize) + if (!item->livebox.finalize) { ErrPrint("symbol: livebox_finalize - %s\n", dlerror()); + } item->livebox.need_to_destroy = (need_to_destroy_t)dlsym(item->handle, "livebox_need_to_destroy"); - if (!item->livebox.need_to_destroy) + if (!item->livebox.need_to_destroy) { ErrPrint("symbol: livebox_need_to_destroy - %s\n", dlerror()); + } item->livebox.sys_event = (system_event_t)dlsym(item->handle, "livebox_system_event"); - if (!item->livebox.sys_event) + if (!item->livebox.sys_event) { ErrPrint("symbol: livebox_system_event - %s\n", dlerror()); + } item->livebox.is_pinned_up = (is_pinned_up_t)dlsym(item->handle, "livebox_is_pinned_up"); - if (!item->livebox.is_pinned_up) + if (!item->livebox.is_pinned_up) { ErrPrint("symbol: livebox_is_pinned_up - %s\n", dlerror()); + } - heap_monitor_add_target(item->so_fname); + main_heap_monitor_add_target(item->so_fname); if (item->livebox.initialize) { int ret; @@ -387,7 +431,7 @@ static struct so_item *new_livebox(const char *pkgname) fault_unmark_call(pkgname, "initialize", __func__, USE_ALARM); if (ret < 0) { ErrPrint("Failed to initialize package %s\n", pkgname); - heap_monitor_del_target(item->so_fname); + main_heap_monitor_del_target(item->so_fname); delete_livebox(item); return NULL; } @@ -468,8 +512,9 @@ static inline struct instance *find_instance(struct so_item *item, const char *i Eina_List *l; EINA_LIST_FOREACH(item->inst_list, l, inst) { - if (!strcmp(inst->id, id)) + if (!strcmp(inst->id, id)) { return inst; + } } return NULL; @@ -480,8 +525,9 @@ HAPI struct instance *so_find_instance(const char *pkgname, const char *id) struct so_item *item; item = find_livebox(pkgname); - if (!item) + if (!item) { return NULL; + } return find_instance(item, id); } @@ -500,18 +546,22 @@ HAPI int so_create(const char *pkgname, const char *id, const char *content_info return LB_STATUS_ERROR_EXIST; } } else { - if (!strcasecmp(abi, "c")) + if (!strcasecmp(abi, "c")) { item = new_livebox(pkgname); - else + } else { item = new_adaptor(pkgname, abi); - if (!item) + } + + if (!item) { return LB_STATUS_ERROR_FAULT; + } } inst = new_instance(id, content_info, cluster, category); if (!inst) { - if (!item->inst_list) + if (!item->inst_list) { delete_livebox(item); + } return LB_STATUS_ERROR_FAULT; } @@ -522,12 +572,15 @@ HAPI int so_create(const char *pkgname, const char *id, const char *content_info fault_mark_call(pkgname, id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.create) + s_info.current_op = LIVEBOX_OP_CREATE; + if (item->adaptor.create) { ret = item->adaptor.create(pkgname, util_uri_to_path(id), content_info, cluster, category); - else if (item->livebox.create) + } else if (item->livebox.create) { ret = item->livebox.create(util_uri_to_path(id), content_info, cluster, category); - else /*! \NOTE: This is not possible, but for the exceptional handling */ + } else { /*! \NOTE: This is not possible, but for the exceptional handling */ ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(pkgname, id, __func__, USE_ALARM); @@ -554,17 +607,21 @@ HAPI int so_destroy(struct instance *inst) int ret; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.destroy) + s_info.current_op = LIVEBOX_OP_DESTROY; + if (item->adaptor.destroy) { ret = item->adaptor.destroy(item->pkgname, util_uri_to_path(inst->id)); - else if (item->livebox.destroy) + } else if (item->livebox.destroy) { ret = item->livebox.destroy(util_uri_to_path(inst->id)); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -585,16 +642,22 @@ HAPI char *so_pinup(struct instance *inst, int pinup) char *ret; item = inst->item; - if (!item) + if (!item) { return NULL; + } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.pinup) + + s_info.current_op = LIVEBOX_OP_PINUP; + if (item->adaptor.pinup) { ret = item->adaptor.pinup(item->pkgname, util_uri_to_path(inst->id), pinup); - else if (item->livebox.pinup) + } else if (item->livebox.pinup) { ret = item->livebox.pinup(util_uri_to_path(inst->id), pinup); - else + } else { ret = NULL; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; + fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); return ret; } @@ -605,16 +668,22 @@ HAPI int so_is_pinned_up(struct instance *inst) int ret; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.is_pinned_up) + + s_info.current_op = LIVEBOX_OP_IS_PINNED_UP; + if (item->adaptor.is_pinned_up) { ret = item->adaptor.is_pinned_up(item->pkgname, util_uri_to_path(inst->id)); - else if (item->livebox.is_pinned_up) + } else if (item->livebox.is_pinned_up) { ret = item->livebox.is_pinned_up(util_uri_to_path(inst->id)); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; + fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); return ret; } @@ -625,17 +694,21 @@ HAPI int so_is_updated(struct instance *inst) int ret; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.is_updated) + s_info.current_op = LIVEBOX_OP_NEED_TO_UPDATE; + if (item->adaptor.is_updated) { ret = item->adaptor.is_updated(item->pkgname, util_uri_to_path(inst->id)); - else if (item->livebox.is_updated) + } else if (item->livebox.is_updated) { ret = item->livebox.is_updated(util_uri_to_path(inst->id)); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -648,17 +721,21 @@ HAPI int so_need_to_destroy(struct instance *inst) int ret; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.need_to_destroy) + s_info.current_op = LIVEBOX_OP_NEED_TO_DESTROY; + if (item->adaptor.need_to_destroy) { ret = item->adaptor.need_to_destroy(item->pkgname, util_uri_to_path(inst->id)); - else if (item->livebox.need_to_destroy) + } else if (item->livebox.need_to_destroy) { ret = item->livebox.need_to_destroy(util_uri_to_path(inst->id)); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -671,17 +748,21 @@ HAPI int so_update(struct instance *inst) int ret; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.update_content) + s_info.current_op = LIVEBOX_OP_UPDATE_CONTENT; + if (item->adaptor.update_content) { ret = item->adaptor.update_content(item->pkgname, util_uri_to_path(inst->id)); - else if (item->livebox.update_content) + } else if (item->livebox.update_content) { ret = item->livebox.update_content(util_uri_to_path(inst->id)); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); return ret; @@ -693,18 +774,22 @@ HAPI int so_clicked(struct instance *inst, const char *event, double timestamp, int ret; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - DbgPrint("CLICKED: %lf\n", util_timestamp()); - if (item->adaptor.clicked) + DbgPrint("PERF_DBOX\n"); + s_info.current_op = LIVEBOX_OP_CLICKED; + if (item->adaptor.clicked) { ret = item->adaptor.clicked(item->pkgname, util_uri_to_path(inst->id), event, timestamp, x, y); - else if (item->livebox.clicked) + } else if (item->livebox.clicked) { ret = item->livebox.clicked(util_uri_to_path(inst->id), event, timestamp, x, y); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -717,17 +802,21 @@ HAPI int so_script_event(struct instance *inst, const char *emission, const char int ret; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.script_event) + s_info.current_op = LIVEBOX_OP_CONTENT_EVENT; + if (item->adaptor.script_event) { ret = item->adaptor.script_event(item->pkgname, util_uri_to_path(inst->id), emission, source, event_info); - else if (item->livebox.script_event) + } else if (item->livebox.script_event) { ret = item->livebox.script_event(util_uri_to_path(inst->id), emission, source, event_info); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -741,21 +830,26 @@ HAPI int so_resize(struct instance *inst, int w, int h) int type; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } type = livebox_service_size_type(w, h); - if (type == LB_SIZE_TYPE_UNKNOWN) + if (type == LB_SIZE_TYPE_UNKNOWN) { return LB_STATUS_ERROR_INVALID; + } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.resize) + s_info.current_op = LIVEBOX_OP_RESIZE; + if (item->adaptor.resize) { ret = item->adaptor.resize(item->pkgname, util_uri_to_path(inst->id), type); - else if (item->livebox.resize) + } else if (item->livebox.resize) { ret = item->livebox.resize(util_uri_to_path(inst->id), type); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); @@ -769,22 +863,28 @@ HAPI int so_create_needed(const char *pkgname, const char *cluster, const char * item = find_livebox(pkgname); if (!item) { - if (!strcasecmp(abi, "c")) + if (!strcasecmp(abi, "c")) { item = new_livebox(pkgname); - else + } else { item = new_adaptor(pkgname, abi); - if (!item) + } + + if (!item) { return LB_STATUS_ERROR_FAULT; + } } fault_mark_call(item->pkgname, __func__, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.create_needed) + s_info.current_op = LIVEBOX_OP_NEED_TO_CREATE; + if (item->adaptor.create_needed) { ret = item->adaptor.create_needed(pkgname, cluster, category); - else if (item->livebox.create_needed) + } else if (item->livebox.create_needed) { ret = item->livebox.create_needed(cluster, category); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, __func__, __func__, USE_ALARM); @@ -800,12 +900,14 @@ HAPI int so_change_group(struct instance *inst, const char *cluster, const char char *tmp_category; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } tmp_cluster = strdup(cluster); - if (!tmp_cluster) + if (!tmp_cluster) { return LB_STATUS_ERROR_MEMORY; + } tmp_category = strdup(category); if (!tmp_category) { @@ -815,12 +917,15 @@ HAPI int so_change_group(struct instance *inst, const char *cluster, const char fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.change_group) + s_info.current_op = LIVEBOX_OP_CHANGE_GROUP; + if (item->adaptor.change_group) { ret = item->adaptor.change_group(item->pkgname, util_uri_to_path(inst->id), cluster, category); - else if (item->livebox.change_group) + } else if (item->livebox.change_group) { ret = item->livebox.change_group(util_uri_to_path(inst->id), cluster, category); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); if (ret >= 0) { @@ -843,20 +948,24 @@ HAPI int so_get_output_info(struct instance *inst, int *w, int *h, double *prior int ret; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } *content = NULL; *title = NULL; fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.get_output_info) + s_info.current_op = LIVEBOX_OP_GET_INFO; + if (item->adaptor.get_output_info) { ret = item->adaptor.get_output_info(item->pkgname, util_uri_to_path(inst->id), w, h, priority, content, title); - else if (item->livebox.get_output_info) + } else if (item->livebox.get_output_info) { ret = item->livebox.get_output_info(util_uri_to_path(inst->id), w, h, priority, content, title); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); if (ret >= 0) { @@ -881,8 +990,9 @@ HAPI int so_get_output_info(struct instance *inst, int *w, int *h, double *prior } } - if (main_heap_monitor_is_enabled()) - DbgPrint("%s allocates %d bytes\n", item->pkgname, heap_monitor_target_usage(item->so_fname)); + if (main_heap_monitor_is_enabled()) { + DbgPrint("%s allocates %d bytes\n", item->pkgname, main_heap_monitor_target_usage(item->so_fname)); + } return ret; } @@ -893,19 +1003,29 @@ HAPI int so_sys_event(struct instance *inst, int event) int ret; item = inst->item; - if (!item) + if (!item) { return LB_STATUS_ERROR_INVALID; + } fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER); - if (item->adaptor.sys_event) + + s_info.current_op = LIVEBOX_OP_SYSTEM_EVENT; + if (item->adaptor.sys_event) { ret = item->adaptor.sys_event(item->pkgname, util_uri_to_path(inst->id), event); - else if (item->livebox.sys_event) + } else if (item->livebox.sys_event) { ret = item->livebox.sys_event(util_uri_to_path(inst->id), event); - else + } else { ret = LB_STATUS_ERROR_NOT_IMPLEMENTED; + } + s_info.current_op = LIVEBOX_OP_UNKNOWN; fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM); return ret; } +HAPI enum current_operations so_current_op(void) +{ + return s_info.current_op; +} + /* End of a file */ diff --git a/src/update_monitor.c b/src/update_monitor.c index bf19c10..9162e3d 100644 --- a/src/update_monitor.c +++ b/src/update_monitor.c @@ -60,9 +60,6 @@ static Eina_Bool monitor_cb(void *data, Ecore_Fd_Handler *handler) { int fd; int read_size; - Eina_List *l; - Eina_List *n; - struct cb_item *item; char *buffer; register int i; struct inotify_event *evt; @@ -105,7 +102,9 @@ static Eina_Bool monitor_cb(void *data, Ecore_Fd_Handler *handler) if (util_check_ext(evt->name, "gnp.") == 0 && util_check_ext(evt->name, "csed.") == 0) + { continue; + } len = strlen(evt->name) + strlen(IMAGE_PATH) + 1; filename = malloc(len); @@ -128,21 +127,9 @@ static Eina_Bool monitor_cb(void *data, Ecore_Fd_Handler *handler) } if (evt->mask & (IN_DELETE | IN_MOVED_FROM)) { - EINA_LIST_FOREACH_SAFE(s_info.delete_list, l, n, item) { - if (!strcmp(filename, item->filename) && item->cb(filename, item->data, !!(evt->mask & IN_Q_OVERFLOW)) == EXIT_FAILURE) { - s_info.delete_list = eina_list_remove_list(s_info.delete_list, l); - free(item->filename); - free(item); - } - } + update_monitor_trigger_delete_cb(filename, !!(evt->mask & IN_Q_OVERFLOW)); } else if (evt->mask & (IN_CLOSE_WRITE | IN_MOVED_TO)) { - EINA_LIST_FOREACH_SAFE(s_info.update_list, l, n, item) { - if (!strcmp(filename, item->filename) && item->cb(filename, item->data, !!(evt->mask & IN_Q_OVERFLOW)) == EXIT_FAILURE) { - s_info.update_list = eina_list_remove_list(s_info.update_list, l); - free(item->filename); - free(item); - } - } + update_monitor_trigger_update_cb(filename, !!(evt->mask & IN_Q_OVERFLOW)); } free(filename); @@ -170,7 +157,9 @@ HAPI int update_monitor_init(void) if (s_info.iwd < 0) { ErrPrint("Error: %s\n", strerror(errno)); - close(s_info.ifd); + if (close(s_info.ifd) < 0) { + ErrPrint("close: %s\n", strerror(errno)); + } s_info.ifd = LB_STATUS_ERROR_INVALID; return LB_STATUS_ERROR_IO; } @@ -179,11 +168,14 @@ HAPI int update_monitor_init(void) ECORE_FD_READ, monitor_cb, NULL, NULL, NULL); if (!s_info.handler) { ErrPrint("Failed to add a FD handler\n"); - if (inotify_rm_watch(s_info.ifd, s_info.iwd) < 0) + if (inotify_rm_watch(s_info.ifd, s_info.iwd) < 0) { ErrPrint("inotify_rm_watch: %s", strerror(errno)); + } s_info.iwd = -EINVAL; - close(s_info.ifd); + if (close(s_info.ifd) < 0) { + ErrPrint("close: %s\n", strerror(errno)); + } s_info.ifd = LB_STATUS_ERROR_INVALID; return LB_STATUS_ERROR_FAULT; } @@ -202,18 +194,59 @@ HAPI int update_monitor_fini(void) } if (s_info.ifd >= 0) { - if (inotify_rm_watch(s_info.ifd, s_info.iwd) < 0) + if (inotify_rm_watch(s_info.ifd, s_info.iwd) < 0) { ErrPrint("inotify_rm_watch:%s", strerror(errno)); + } s_info.iwd = LB_STATUS_ERROR_INVALID; - close(s_info.ifd); + if (close(s_info.ifd) < 0) { + ErrPrint("close: %s\n", strerror(errno)); + } s_info.ifd = LB_STATUS_ERROR_INVALID; } return LB_STATUS_SUCCESS; } +HAPI int update_monitor_trigger_update_cb(const char *filename, int over) +{ + Eina_List *l; + Eina_List *n; + struct cb_item *item; + int cnt = 0; + + EINA_LIST_FOREACH_SAFE(s_info.update_list, l, n, item) { + if (!strcmp(filename, item->filename) && item->cb(filename, item->data, over) == EXIT_FAILURE) { + s_info.update_list = eina_list_remove_list(s_info.update_list, l); + free(item->filename); + free(item); + cnt++; + } + } + + return cnt == 0 ? LB_STATUS_ERROR_INVALID : LB_STATUS_SUCCESS; +} + +HAPI int update_monitor_trigger_delete_cb(const char *filename, int over) +{ + Eina_List *l; + Eina_List *n; + struct cb_item *item; + int cnt = 0; + + EINA_LIST_FOREACH_SAFE(s_info.delete_list, l, n, item) { + if (!strcmp(filename, item->filename) && item->cb(filename, item->data, over) == EXIT_FAILURE) { + s_info.delete_list = eina_list_remove_list(s_info.delete_list, l); + free(item->filename); + free(item); + cnt++; + } + } + + return cnt == 0 ? LB_STATUS_ERROR_INVALID : LB_STATUS_SUCCESS; +} + HAPI int update_monitor_add_update_cb(const char *filename, int (*cb)(const char *filename, void *data, int over), void *data) { diff --git a/src/util.c b/src/util.c index d8c9e4e..b3a53c3 100644 --- a/src/util.c +++ b/src/util.c @@ -68,6 +68,9 @@ HAPI int util_get_filesize(const char *filename) HAPI double util_timestamp(void) { +#if defined(_USE_ECORE_TIME_GET) + return ecore_time_get(); +#else struct timeval tv; if (gettimeofday(&tv, NULL) < 0) { @@ -79,6 +82,7 @@ HAPI double util_timestamp(void) } return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; +#endif } HAPI const char *util_basename(const char *name) @@ -86,8 +90,9 @@ HAPI const char *util_basename(const char *name) int length; length = name ? strlen(name) : 0; - if (!length) + if (!length) { return "."; + } while (--length > 0 && name[length] != '/'); @@ -111,15 +116,17 @@ HAPI char *util_get_current_module(char **symbol) register int i; if (!pthread_getattr_np(pthread_self(), &attr)) { - if (!pthread_attr_getstack(&attr, (void *)&stack_boundary, &stack_size)) + if (!pthread_attr_getstack(&attr, (void *)&stack_boundary, &stack_size)) { stack_boundary += stack_size; + } pthread_attr_destroy(&attr); } ret = NULL; for (i = 0, stack = (int *)&stack; (unsigned int)stack < stack_boundary ; stack++, i++) { - if (!dladdr((void *)*stack, &dinfo)) + if (!dladdr((void *)*stack, &dinfo)) { continue; + } ptr = util_basename(dinfo.dli_fname); if (strncmp(ptr, "liblive-", strlen("liblive-"))) { @@ -135,10 +142,11 @@ HAPI char *util_get_current_module(char **symbol) ret = strdup(ptr); if (symbol) { - if (dinfo.dli_sname) + if (dinfo.dli_sname) { *symbol = strdup(dinfo.dli_sname); - else + } else { *symbol = NULL; + } } break; } @@ -151,18 +159,19 @@ HAPI const char *util_uri_to_path(const char *uri) int len; len = strlen(SCHEMA_FILE); - if (strncasecmp(uri, SCHEMA_FILE, len)) + if (strncasecmp(uri, SCHEMA_FILE, len)) { return NULL; + } return uri + len; } HAPI double util_time_delay_for_compensation(double period) { - struct timeval tv; unsigned long long curtime; unsigned long long _period; unsigned long long remain; + struct timeval tv; double ret; if (period == 0.0f) { @@ -170,12 +179,13 @@ HAPI double util_time_delay_for_compensation(double period) return 0.0f; } - if (gettimeofday(&tv, NULL) < 0){ + if (gettimeofday(&tv, NULL) < 0) { ErrPrint("gettimeofday: %s\n", strerror(errno)); return period; } curtime = (unsigned long long)tv.tv_sec * 1000000llu + (unsigned long long)tv.tv_usec; + _period = (unsigned long long)(period * (double)1000000); if (_period == 0llu) { ErrPrint("%lf <> %llu\n", period, _period); @@ -185,7 +195,6 @@ HAPI double util_time_delay_for_compensation(double period) remain = curtime % _period; ret = (double)remain / (double)1000000; - DbgPrint("curtime: %llu, _period: %llu (%lf), remain: %llu, ret: %lf, result: %lf\n", curtime, _period, period, remain, ret, period - ret); return period - ret; } @@ -195,12 +204,12 @@ HAPI void *util_timer_add(double interval, Eina_Bool (*cb)(void *data), void *da double delay; timer = ecore_timer_add(interval, cb, data); - if (!timer) + if (!timer) { return NULL; + } delay = util_time_delay_for_compensation(interval) - interval; ecore_timer_delay(timer, delay); - DbgPrint("Compensate timer: %lf\n", delay); return timer; } diff --git a/stub/main.c b/stub/main.c new file mode 100644 index 0000000..3dd2d57 --- /dev/null +++ b/stub/main.c @@ -0,0 +1,73 @@ +#include +#include +#include +#include + +#include +#include + +#include "debug.h" +#if defined(LOG_TAG) +#undef LOG_TAG +#define LOG_TAG "DATA_PROVIDER_SLAVE_LOADER" +#endif + +int errno; + +/*! + * Defined for liblivebox + */ +const char *livebox_find_pkgname(const char *filename) +{ + return NULL; +} + +int livebox_request_update_by_id(const char *filename) +{ + return LB_STATUS_ERROR_NOT_EXIST; +} + +int livebox_trigger_update_monitor(const char *id, int is_pd) +{ + return LB_STATUS_ERROR_INVALID; +} + +int main(int argc, char *argv[]) +{ + int i; + char **_argv; + const char *option; + + if (argc < 4) { + return -EINVAL; + } + + _argv = malloc(sizeof(char *) * (argc+2)); + if (!_argv) { + ErrPrint("%s\n", strerror(errno)); + return -ENOMEM; + } + + for (i = 1; i < argc; i++) { + _argv[i] = strdup(argv[i]); + } + _argv[i] = NULL; + + _argv[0] = strdup("/usr/apps/org.tizen.data-provider-slave/bin/data-provider-slave.loader"); + DbgPrint("Replace argv[0] with %s\n", _argv[0]); + for (i = 0; i < argc; i++) { + DbgPrint("argv[%d]: %s\n", i, _argv[i]); + } + + option = getenv("PROVIDER_HEAP_MONITOR_START"); + if (option && !strcasecmp(option, "true")) { + DbgPrint("Heap monitor is enabled\n"); + setenv("LD_PRELOAD", "/usr/lib/libheap-monitor.so", 1); + } + + execvp(_argv[0], _argv); + ErrPrint("%s\n", strerror(errno)); + return 0; +} + +/* End of a file */