Fix exception handling of appcore_ui_base API
[platform/core/appfw/app-core.git] / src / base / appcore_base.c
index 47527a0..c9a17cc 100644 (file)
@@ -36,6 +36,7 @@
 #include <aul.h>
 #include <bundle_internal.h>
 #include <sensor_internal.h>
+#include <ttrace.h>
 #include "appcore_base.h"
 #include "appcore_base_private.h"
 
@@ -857,6 +858,7 @@ EXPORT_API int appcore_base_set_i18n(const char *domain_name, const char *dir_na
 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;
@@ -866,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);
 
@@ -882,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)
@@ -898,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)) {
@@ -918,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)
@@ -956,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());
@@ -1225,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;