X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fbase%2Fappcore_base.c;h=c9a17cc69ebffdc30e16d2e82265f95c93eb4f45;hb=0fcfe3095409c931075c57faa7bd48809ab70b6f;hp=348f50043aac944a9e4fa09750e6ea943f985774;hpb=74b0d18b5b5e0df42f88ac87ea47470cd7b54a71;p=platform%2Fcore%2Fappfw%2Fapp-core.git diff --git a/src/base/appcore_base.c b/src/base/appcore_base.c index 348f500..c9a17cc 100644 --- a/src/base/appcore_base.c +++ b/src/base/appcore_base.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "appcore_base.h" #include "appcore_base_private.h" @@ -266,7 +267,7 @@ static void __on_low_memory(keynode_t *key, void *data) val = vconf_keynode_get_int(key); if (val >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING) { - __invoke_callback(key, APPCORE_BASE_EVENT_LOW_MEMORY); + __invoke_callback(&val, APPCORE_BASE_EVENT_LOW_MEMORY); malloc_trim(0); } } @@ -278,7 +279,7 @@ static void __on_low_battery(keynode_t *key, void *data) val = vconf_keynode_get_int(key); if (val <= VCONFKEY_SYSMAN_BAT_CRITICAL_LOW) - __invoke_callback(key, APPCORE_BASE_EVENT_LOW_BATTERY); + __invoke_callback(&val, APPCORE_BASE_EVENT_LOW_BATTERY); } static void __destroy_lang_info(gpointer data) @@ -622,7 +623,7 @@ static void __on_region_change(keynode_t *key, void *data) const char *name; name = vconf_keynode_get_name(key); - if (!strcmp(name, VCONFKEY_REGIONFORMAT)) + if (name && !strcmp(name, VCONFKEY_REGIONFORMAT)) val = vconf_keynode_get_str(key); __update_region(); @@ -849,9 +850,15 @@ EXPORT_API int appcore_base_on_set_i18n(void) return 0; } +EXPORT_API int appcore_base_set_i18n(const char *domain_name, const char *dir_name) +{ + return __set_i18n(domain_name, dir_name); +} + EXPORT_API int appcore_base_init(appcore_base_ops ops, int argc, char **argv, void *data) { int i; + int r; __context.ops = ops; __context.argc = argc; @@ -861,6 +868,9 @@ EXPORT_API int appcore_base_init(appcore_base_ops ops, int argc, char **argv, vo __context.suspended_state = false; __context.allowed_bg = false; + if (__context.ops.init) + __context.ops.init(argc, argv, data); + if (__context.ops.set_i18n) __context.ops.set_i18n(__context.data); @@ -877,9 +887,14 @@ EXPORT_API int appcore_base_init(appcore_base_ops ops, int argc, char **argv, vo } } - if (__context.ops.create && __context.ops.create(__context.data) < 0) { - aul_status_update(STATUS_DYING); - return 0; + if (__context.ops.create) { + traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:CREATE"); + r = __context.ops.create(__context.data); + traceEnd(TTRACE_TAG_APPLICATION_MANAGER); + if (r < 0) { + aul_status_update(STATUS_DYING); + return r; + } } if (__context.ops.run) @@ -893,8 +908,11 @@ EXPORT_API void appcore_base_fini(void) int i; aul_status_update(STATUS_DYING); - if (__context.ops.terminate) + if (__context.ops.terminate) { + traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:TERMINATE"); __context.ops.terminate(__context.data); + traceEnd(TTRACE_TAG_APPLICATION_MANAGER); + } for (i = APPCORE_BASE_EVENT_START + 1; i < APPCORE_BASE_EVENT_MAX; i++) { if (__exist_callback(i)) { @@ -913,6 +931,9 @@ EXPORT_API void appcore_base_fini(void) } __context.dirty = false; + + if (__context.ops.finish) + __context.ops.finish(); } EXPORT_API int appcore_base_flush_memory(void) @@ -951,8 +972,11 @@ EXPORT_API int appcore_base_on_receive(aul_type type, bundle *b) __remove_suspend_timer(); } - if (__context.ops.control) - __context.ops.control(b, __context.data); + if (__context.ops.control) { + traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:RESET"); + __context.ops.control(b, __context.data); + traceEnd(TTRACE_TAG_APPLICATION_MANAGER); + } break; case AUL_RESUME: _DBG("[APP %d] AUL event: AUL_RESUME", getpid()); @@ -1129,6 +1153,9 @@ EXPORT_API int appcore_base_remove_event(appcore_base_event_h handle) appcore_base_event_node *node = handle; enum appcore_base_event event; + if (!node || !g_list_find(__events, node)) + return -1; + event = node->type; __events = g_list_remove(__events, node); free(node); @@ -1148,6 +1175,13 @@ EXPORT_API int appcore_base_raise_event(void *event, enum appcore_base_event typ EXPORT_API int appcore_base_get_rotation_state(enum appcore_base_rm *curr) { + if (curr == NULL) + return -1; + + if (!__rotation.ref) + return -1; + + *curr = __rotation.rm; return 0; } @@ -1210,6 +1244,8 @@ EXPORT_API appcore_base_ops appcore_base_get_default_ops(void) ops.terminate = __on_terminate; ops.receive = __on_receive; ops.set_i18n = __on_set_i18n; + ops.init = NULL; + ops.finish = NULL; ops.run = NULL; ops.exit = NULL; ops.set_event = __on_set_event;