From 33cbe2a5c488ba179d1defef87a4bb959c95bd32 Mon Sep 17 00:00:00 2001 From: Michal Pawluk Date: Mon, 10 Aug 2015 13:44:29 +0200 Subject: [PATCH] [SAMPLE APP][APP-COMMON] Application initialization section added Change-Id: I9012f89d900635a25b8e019f9359878af3441814 Signed-off-by: Michal Pawluk --- .../html/mobile_n/appcommon_sd_mn.htm | 144 +++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/org.tizen.sampledescriptions/html/mobile_n/appcommon_sd_mn.htm b/org.tizen.sampledescriptions/html/mobile_n/appcommon_sd_mn.htm index ae5d4ac..ed635a4 100644 --- a/org.tizen.sampledescriptions/html/mobile_n/appcommon_sd_mn.htm +++ b/org.tizen.sampledescriptions/html/mobile_n/appcommon_sd_mn.htm @@ -171,7 +171,151 @@ typedef enum { } path_item_type; +

Application initialization

+

+ The entire application life-cycle is implemented in the main source file, using a common Tizen application structure: +

+ +
+int main(int argc, char *argv[])
+{
+   appdata_s ad = {{0,},};
+   int ret = 0;
+   ui_app_lifecycle_callback_s event_callback;
+
+   event_callback.create = __create_app;
+   event_callback.terminate = __terminate_app;
+   event_callback.pause = __pause_app;
+   event_callback.resume = __resume_app;
+   event_callback.app_control = __control_app;
+
+   ret = ui_app_main(argc, argv, &event_callback, &ad);
+   if (ret != APP_ERROR_NONE)
+      controller_log(DLOG_ERROR, "Function ui_app_main() failed with error = %d", ret);
+
+   return ret;
+}
+
+ +

+ The application's initilization procedure is executed in __create_app() callback function, which is invoked on application's startup. +

+ +
+static bool __create_app(void *data)
+{
+   appdata_s *ad = (appdata_s *)data;
+
+   return controller_init(&ad->view, &ad->model);
+}
+
+ +

+ Finally, the controller_init() function is invoked, which controls the entire initialization process + (see the code snippet below for details). +

+ +
+bool controller_init(viewdata_s *vd, modeldata_s *md)
+{
+   if (!model_init(md))
+      return false;
+
+   if (!__add_event_handlers())
+      return false;
+
+   if (!view_create_base_gui(vd, __paths_popup_opened))
+      return false;
+
+   __init_view_app();
+
+   return true;
+}
+
+ +

+ The following functions, listed within the code snippet above, are responsible for: +

+ If any of the above functions (except __init_view_app()) fails, then application is terminated and the + __terminate_app() callback function is called. For details, see the Application termination section. +

+ +

Application termination

+ +

Model

-- 2.7.4