Modify logic to set Home screen wallpaper.
[apps/native/menu-screen.git] / src / menu_screen.c
index f139d06..66765d8 100644 (file)
@@ -1,48 +1,51 @@
- /*
-  * Copyright 2012  Samsung Electronics Co., Ltd
-  *
-  * Licensed under the Flora License, Version 1.0 (the "License");
-  * you may not use this file except in compliance with the License.
-  * You may obtain a copy of the License at
-  *
-  *     http://www.tizenopensource.org/license
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * distributed under the License is distributed on an "AS IS" BASIS,
-  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  * See the License for the specific language governing permissions and
-  * limitations under the License.
-  */
-
-
-
-#include <ail.h>
+/*
+ * MENU-SCREEN
+ *
+ * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jin Yoon <jinny.yoon@samsung.com>
+ *          Junkyu Han <junkyu.han@samsung.com>
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
 #include <app.h>
 #include <aul.h>
-#include <Ecore_X.h>
 #include <Elementary.h>
 #include <stdbool.h>
 #include <system_info.h>
-#include <utilX.h>
 #include <vconf.h>
+#include <app_preference.h>
+#include <system_settings.h>
+#include <app_manager.h>
 
 #include "conf.h"
 #include "item.h"
+#include "key.h"
 #include "layout.h"
 #include "mapbuf.h"
 #include "menu_screen.h"
 #include "mouse.h"
 #include "page.h"
 #include "page_scroller.h"
+#include "pkgmgr.h"
 #include "util.h"
 
 #define MENU_SCREEN_ENGINE "file/private/org.tizen.menu-screen/engine"
-
-#define LAYOUT_EDJE_PORTRAIT EDJEDIR"/layout_portrait.edj"
 #define LAYOUT_GROUP_NAME "layout"
 
 
-
 // Define prototype of the "hidden API of AUL"
 extern int aul_listen_app_dead_signal(int (*func)(int signal, void *data), void *data);
 static struct {
@@ -114,25 +117,72 @@ HAPI void menu_screen_set_done(bool is_done)
 
 
 
+HAPI int menu_screen_get_state(void)
+{
+       return menu_screen_info.state;
+}
+
+
+
+static bool _is_emulator_on(void)
+{
+       int ret;
+       char *model = NULL;
+
+       ret = system_info_get_platform_string("tizen.org/system/model_name", &model);
+       if (SYSTEM_INFO_ERROR_NONE != ret) {
+               if (model) {
+                       free(model);
+               }
+               return false;
+       }
+
+       if (!strncmp(model, "Emulator", strlen(model))) {
+               _D("This model is on Emulator");
+               free(model);
+               return true;
+       }
+
+       _D("This model is NOT on Emulator");
+       free(model);
+       return false;
+}
+
+
+
 static menu_screen_error_e _create_canvas(char *name, char *title)
 {
-       Ecore_X_Atom ATOM_WM_WINDOW_ROLE;
+       char *buf;
+
+       if (_is_emulator_on()) {
+               _D("ELM_ENGINE is set as [software_x11]");
+               elm_config_accel_preference_set("opengl");
+       } else {
+               buf = vconf_get_str(MENU_SCREEN_ENGINE);
+               if (buf) {
+                       _D("ELM_ENGINE is set as [%s]", buf);
+                       elm_config_accel_preference_set(buf);
+                       free(buf);
+               } else {
+                       _D("ELM_ENGINE is set as [gl]");
+                       elm_config_accel_preference_set("gl");
+               }
+       }
 
-       menu_screen_info.win = elm_win_add(NULL, name, ELM_WIN_BASIC);
+       menu_screen_info.win = elm_win_util_standard_add(name, name);
        retv_if(NULL == menu_screen_info.win, MENU_SCREEN_ERROR_FAIL);
 
        if (title) {
                elm_win_title_set(menu_screen_info.win, title);
        }
+       _D("elm_scale: %f", elm_app_base_scale_get());
+       _D("config_scale: %f", elm_config_scale_get());
+
        elm_win_borderless_set(menu_screen_info.win, EINA_TRUE);
+       elm_win_screen_size_get(menu_screen_info.win, NULL, NULL, &menu_screen_info.root_width, &menu_screen_info.root_height);
+       _D("menu-screen window size:: width: %d, height: %d", menu_screen_info.root_width, menu_screen_info.root_height);
 
-       ecore_x_icccm_name_class_set(elm_win_xwindow_get(menu_screen_info.win), "MENU_SCREEN", "MENU_SCREEN");
-       ATOM_WM_WINDOW_ROLE = ecore_x_atom_get("WM_WINDOW_ROLE");
-       if (ATOM_WM_WINDOW_ROLE) {
-               ecore_x_window_prop_string_set(elm_win_xwindow_get(menu_screen_info.win), ATOM_WM_WINDOW_ROLE, "MENU_SCREEN");
-       } else {
-               _D("Failed to set the window role as MENU_SCREEN");
-       }
+       elm_win_role_set(menu_screen_info.win, "MENU_SCREEN");
 
        menu_screen_info.evas = evas_object_evas_get(menu_screen_info.win);
        if (!menu_screen_info.evas) {
@@ -144,9 +194,6 @@ static menu_screen_error_e _create_canvas(char *name, char *title)
                _E("[%s] Failed to get ecore_evas object", __func__);
        }
 
-       evas_object_size_hint_min_set(menu_screen_info.win, menu_screen_info.root_width, menu_screen_info.root_height);
-       evas_object_size_hint_max_set(menu_screen_info.win, menu_screen_info.root_width, menu_screen_info.root_height);
-       evas_object_resize(menu_screen_info.win, menu_screen_info.root_width, menu_screen_info.root_height);
        evas_object_show(menu_screen_info.win);
 
        return MENU_SCREEN_ERROR_OK;
@@ -163,94 +210,70 @@ static void _destroy_canvas(void)
 
 static int _dead_cb(int pid, void *data)
 {
-       utilx_hide_fake_effect(
-               ecore_x_display_get(),
-               ecore_x_window_root_get(ecore_evas_window_get(menu_screen_info.ee))
-       );
-
        return EXIT_SUCCESS;
 }
 
 
 
-static void _get_window_size(void)
-{
-       Ecore_X_Window focus_win;
-       Ecore_X_Window root_win;
-
-       focus_win = ecore_x_window_focus_get();
-       root_win = ecore_x_window_root_get(focus_win);
-       ecore_x_window_size_get(root_win, &menu_screen_info.root_width, &menu_screen_info.root_height);
-
-       _D("width:%d, height:%d", menu_screen_info.root_width, menu_screen_info.root_height);
-}
-
-
-
 static void _create_bg(void)
 {
-       char *buf;
-       Evas_Coord w;
-       Evas_Coord h;
+       _D("Create BG");
+       char *buf = NULL;
        Evas_Object *bg;
-       double f, wf, hf;
-       static int trigger = 0;
-       const char *key;
        int width;
        int height;
 
-       buf = vconf_get_str(VCONFKEY_BGSET);
-       ret_if(NULL == buf);
+       if (system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, &buf) < 0) {
+               _E("Failed to get a wallpaper: %d\n", SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN);
+       }
+       _D("Menu-screen bg's image : %s", buf);
 
        width = menu_screen_get_root_width();
        height = menu_screen_get_root_height();
+       _D("width : %d, height : %d FOR BG", width, height);
 
        bg = evas_object_data_get(menu_screen_get_win(), "bg");
-       if (NULL == bg) {
+       if (!bg) {
+               _D("BG is NULL, Create!!");
                Evas_Object *rect;
 
                rect = evas_object_rectangle_add(menu_screen_get_evas());
-               ret_if(NULL == rect);
+               if (NULL == rect) {
+                       free(buf);
+                       return;
+               }
                evas_object_data_set(menu_screen_get_win(), "rect", rect);
                evas_object_color_set(rect, 0, 0, 0, 255);
+               evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
                evas_object_size_hint_min_set(rect, width, height);
                evas_object_size_hint_max_set(rect, width, height);
-               evas_object_resize(rect, width, height);
+               elm_win_resize_object_add(menu_screen_get_win(), rect);
                evas_object_show(rect);
 
-               bg = evas_object_image_add(menu_screen_get_evas());
+               bg = elm_image_add(menu_screen_get_win());
                if (NULL == bg) {
                        free(buf);
                        return;
                }
-               evas_object_image_load_orientation_set(bg, EINA_TRUE);
                evas_object_data_set(menu_screen_get_win(), "bg", bg);
        }
 
-       if (trigger == 0) {
-               key = "/";
-               trigger = 1;
-       } else {
-               key = NULL;
-               trigger = 0;
+       elm_image_aspect_fixed_set(bg, EINA_TRUE);
+       elm_image_fill_outside_set(bg, EINA_TRUE);
+       elm_image_preload_disabled_set(bg, EINA_FALSE);
+
+       evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_min_set(bg, width, height);
+       evas_object_size_hint_max_set(bg, width, height);
+       if (buf == NULL || !elm_image_file_set(bg, buf, NULL)) {
+               _E("Failed to set image file : %s", buf);
+               if (!elm_image_file_set(bg, util_get_file_path(IMAGE_DIR"/home_001.png"), NULL)) {
+                       _E("Failed to set default image file: %s", util_get_file_path(IMAGE_DIR"/home_001.png"));
+                       return;
+               }
        }
 
-       evas_object_image_file_set(bg, buf, key);
-       evas_object_image_size_get(bg, &w, &h);
-       evas_object_image_filled_set(bg, 1);
-
-       wf = (double) width / (double) w;
-       hf = (double) height / (double) h;
-
-       f = wf < hf ? hf : wf;
-
-       w = (int) ((double) f * (double) w);
-       h = (int) ((double) f * (double) h);
-
-       evas_object_image_load_size_set(bg, w, h);
-       evas_object_image_fill_set(bg, 0, 0, w, h);
-       evas_object_move(bg, (width - w) / 2, (height - h) / 2);
-       evas_object_resize(bg, w, h);
+       elm_win_resize_object_add(menu_screen_get_win(), bg);
        evas_object_show(bg);
 
        free(buf);
@@ -273,7 +296,7 @@ static void _destroy_bg()
 
 
 
-static void _change_bg_cb(keynode_t *node, void *data)
+static void _change_bg_cb(system_settings_key_e key, void *data)
 {
        _D("Background image is changed.");
        _create_bg();
@@ -285,14 +308,14 @@ static void _init_theme(void)
 {
        menu_screen_info.theme = elm_theme_new();
        elm_theme_ref_set(menu_screen_info.theme, NULL);
-       elm_theme_extension_add(menu_screen_info.theme, EDJEDIR"/index.edj");
+       elm_theme_extension_add(menu_screen_info.theme, util_get_file_path(EDJE_DIR"/index.edj"));
 }
 
 
 
 static void _fini_theme(void)
 {
-       elm_theme_extension_del(menu_screen_info.theme, EDJEDIR"/index.edj");
+       elm_theme_extension_del(menu_screen_info.theme, util_get_file_path(EDJE_DIR"/index.edj"));
        elm_theme_free(menu_screen_info.theme);
        menu_screen_info.theme = NULL;
 
@@ -303,18 +326,29 @@ static void _fini_theme(void)
 static Evas_Object *_create_conformant(Evas_Object *win)
 {
        Evas_Object *conformant;
+       char *device_profile;
 
        conformant = elm_conformant_add(win);
        retv_if(NULL == conformant, NULL);
 
-       elm_object_style_set(conformant, "nokeypad");
        evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       device_profile = util_get_device_profile();
+       if (device_profile) {
+               if (!strcmp(device_profile, "mobile")) {
+                       elm_win_indicator_mode_set(menu_screen_info.win, ELM_WIN_INDICATOR_SHOW);
+                       elm_win_indicator_opacity_set(menu_screen_info.win, ELM_WIN_INDICATOR_TRANSLUCENT);
+               }
+       }
+       elm_object_signal_emit(conformant, "elm,state,indicator,overlap", "elm");
        evas_object_data_set(conformant, "win", win);
        evas_object_show(conformant);
 
        elm_win_resize_object_add(win, conformant);
        elm_win_conformant_set(win, EINA_TRUE);
 
+       if (device_profile)
+               free(device_profile);
+
        return conformant;
 }
 
@@ -331,15 +365,12 @@ static void _destroy_conformant(Evas_Object *conformant)
 static bool _create_cb(void *data)
 {
        Evas_Object *conformant;
-       Evas_Object *layout;
 
-       _get_window_size();
        _init_theme();
        retv_if(MENU_SCREEN_ERROR_FAIL == _create_canvas(PACKAGE, PACKAGE), false);
-       elm_win_indicator_mode_set(menu_screen_info.win, ELM_WIN_INDICATOR_SHOW);
 
-       if (vconf_notify_key_changed(VCONFKEY_BGSET, _change_bg_cb, NULL) < 0) {
-               _E("Failed to register a vconf cb for %s\n", VCONFKEY_BGSET);
+       if (system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, _change_bg_cb, NULL) < 0) {
+               _E("Failed to register a settings change cb for %d\n", SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN);
        }
        _create_bg();
 
@@ -347,8 +378,8 @@ static bool _create_cb(void *data)
        retv_if(NULL == conformant, false);
        evas_object_data_set(menu_screen_info.win, "conformant", conformant);
 
-       layout = layout_create(conformant, LAYOUT_EDJE_PORTRAIT,
-                               LAYOUT_GROUP_NAME, MENU_SCREEN_ROTATE_PORTRAIT);
+       Evas_Object *layout;
+       layout = layout_create(conformant, util_get_file_path(EDJE_DIR"/layout_portrait.edj"), LAYOUT_GROUP_NAME, MENU_SCREEN_ROTATE_PORTRAIT);
        if (NULL == layout) {
                _E("Failed to load an edje object");
                evas_object_del(menu_screen_info.win);
@@ -357,8 +388,13 @@ static bool _create_cb(void *data)
        evas_object_data_set(menu_screen_info.win, "layout", layout);
 
        elm_object_content_set(conformant, layout);
+
        mouse_register();
        aul_listen_app_dead_signal(_dead_cb, NULL);
+       key_register();
+
+       // FIXME : This will be enabled after rebuilding the routine for appid <-> pkgid.
+       pkgmgr_init();
 
        return true;
 }
@@ -370,12 +406,15 @@ static void _terminate_cb(void *data)
        Evas_Object *conformant;
        Evas_Object *layout;
 
-       if (vconf_ignore_key_changed(VCONFKEY_BGSET, _change_bg_cb) < 0) {
-               _E("Failed to remove bgset %s\n", VCONFKEY_BGSET);
+       // FIXME : This will be enabled after rebuilding the routine for appid <-> pkgid.
+
+       if (system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN) < 0) {
+               _E("Failed to remove bgset [%s]\n", SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN);
        }
 
        evas_object_hide(menu_screen_info.win);
 
+       key_unregister();
        mouse_unregister();
 
        layout = evas_object_data_del(menu_screen_info.win, "layout");
@@ -396,10 +435,6 @@ static void _pause_cb(void *data)
 {
        _D("Pause start");
 
-       if (vconf_set_int(VCONFKEY_IDLE_SCREEN_TOP, VCONFKEY_IDLE_SCREEN_TOP_FALSE) < 0) {
-               _E("Failed to set %s to 0", VCONFKEY_IDLE_SCREEN_TOP);
-       }
-
        menu_screen_info.state = APP_STATE_PAUSE;
 }
 
@@ -409,37 +444,45 @@ static void _resume_cb(void *data)
 {
        _D("START RESUME");
 
-       if (vconf_set_int(VCONFKEY_IDLE_SCREEN_TOP, VCONFKEY_IDLE_SCREEN_TOP_TRUE) < 0) {
-               _E("Failed to set %s to 1", VCONFKEY_IDLE_SCREEN_TOP);
-       }
+       do { // Focus
+               Evas_Object *layout = evas_object_data_get(menu_screen_info.win, "layout");
+               break_if(NULL == layout);
 
-       utilx_hide_fake_effect(
-               ecore_x_display_get(),
-               ecore_x_window_root_get(ecore_evas_window_get(menu_screen_info.ee))
-       );
+               Evas_Object *all_apps = evas_object_data_get(layout, "all_apps");
+               break_if(NULL == all_apps);
+
+               Evas_Object *scroller = elm_object_part_content_get(all_apps, "content");
+               break_if(NULL == scroller);
+
+               page_scroller_focus(scroller);
+       } while (0);
 
        menu_screen_info.state = APP_STATE_RESUME;
 }
 
 
 
-static void _service_cb(service_h service, void *data)
+static void _app_control_cb(app_control_h service, void *data)
 {
        _D("START RESET : %d", menu_screen_info.state);
 
-       if (vconf_set_int(VCONFKEY_IDLE_SCREEN_TOP, VCONFKEY_IDLE_SCREEN_TOP_TRUE) < 0) {
-               _E("Failed to set %s to 1", VCONFKEY_IDLE_SCREEN_TOP);
-       }
+       do { // Focus
+               Evas_Object *layout = evas_object_data_get(menu_screen_info.win, "layout");
+               break_if(NULL == layout);
 
-       utilx_hide_fake_effect(
-               ecore_x_display_get(),
-               ecore_x_window_root_get(ecore_evas_window_get(menu_screen_info.ee))
-       );
+               Evas_Object *all_apps = evas_object_data_get(layout, "all_apps");
+               break_if(NULL == all_apps);
+
+               Evas_Object *scroller = elm_object_part_content_get(all_apps, "content");
+               break_if(NULL == scroller);
+
+               page_scroller_focus(scroller);
+       } while (0);
 }
 
 
 
-static void _language_changed_cb(void *data)
+static void _language_changed_cb(app_event_info_h event_info, void *data)
 {
        register unsigned int i;
        register unsigned int j;
@@ -466,34 +509,39 @@ static void _language_changed_cb(void *data)
 
        count = page_scroller_count_page(scroller);
        page_max_app = (unsigned int) evas_object_data_get(scroller, "page_max_app");
-       for (i = 0; i < count; i ++) {
+       for (i = 0; i < count; i++) {
                page = page_scroller_get_page_at(scroller, i);
                if (!page) continue;
                if (mapbuf_is_enabled(page)) {
                        mapbuf_disable(page, 1);
                }
 
-               for (j = 0; j < page_max_app; j ++) {
-                       ail_appinfo_h ai;
+               for (j = 0; j < page_max_app; j++) {
+                       app_info_h app_info = NULL;
                        char *name;
+                       int ret;
+                       char *package;
 
                        item = page_get_item_at(page, j);
                        if (!item) continue;
 
-                       if (ail_get_appinfo(item_get_package(item), &ai) < 0) continue;
-                       if (ail_appinfo_get_str(ai, AIL_PROP_NAME_STR, &name) < 0) {
-                               ail_destroy_appinfo(ai);
+                       package = item_get_package(item);
+                       if (!package) continue;
+
+                       ret = app_manager_get_app_info(package, &app_info);
+                       if (ret != APP_MANAGER_ERROR_NONE || !app_info) {
+                               _E("Failed to get app info");
                                continue;
                        }
-
-                       if (!name) {
-                               _D("Failed to get name for %s", item_get_package(item));
-                               ail_destroy_appinfo(ai);
+                       ret = app_info_get_label(app_info, &name);
+                       if (APP_MANAGER_ERROR_NONE != ret) {
+                               _E("Failed to get label from : %s", item_get_package(item));
                                continue;
                        }
+                       _D("Changed Language name: %s", name);
+                       
 
                        item_set_name(item, name, 0);
-                       ail_destroy_appinfo(ai);
                }
 
                mapbuf_enable(page, 1);
@@ -502,74 +550,48 @@ static void _language_changed_cb(void *data)
 
 
 
-static void _init(app_event_callback_s *event_callback)
+static void _init(ui_app_lifecycle_callback_s *lifecycle_callback, app_event_handler_h *event_handlers)
 {
-       event_callback->create = _create_cb;
-       event_callback->terminate = _terminate_cb;
-       event_callback->pause = _pause_cb;
-       event_callback->resume = _resume_cb;
-       event_callback->service = _service_cb;
-       event_callback->low_memory = NULL;
-       event_callback->low_battery = NULL;
-       event_callback->device_orientation = NULL;
-       event_callback->language_changed = _language_changed_cb;
-       event_callback->region_format_changed = NULL;
-}
-
-
+       lifecycle_callback->create = _create_cb;
+       lifecycle_callback->terminate = _terminate_cb;
+       lifecycle_callback->pause = _pause_cb;
+       lifecycle_callback->resume = _resume_cb;
+       lifecycle_callback->app_control = _app_control_cb;
+
+       ui_app_add_event_handler(&event_handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, NULL);
+       ui_app_add_event_handler(&event_handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, NULL);
+       ui_app_add_event_handler(&event_handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL);
+       ui_app_add_event_handler(&event_handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _language_changed_cb, NULL);
+       ui_app_add_event_handler(&event_handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL);
 
-static void _fini(void)
-{
 }
 
 
 
-#define QP_EMUL_STR            "Emulator"
-static bool _is_emulator_on(void)
+static void _fini(app_event_handler_h *event_handlers)
 {
-       char *info;
+       ui_app_remove_event_handler(event_handlers[APP_EVENT_LOW_BATTERY]);
+       ui_app_remove_event_handler(event_handlers[APP_EVENT_LOW_MEMORY]);
+       ui_app_remove_event_handler(event_handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED]);
+       ui_app_remove_event_handler(event_handlers[APP_EVENT_LANGUAGE_CHANGED]);
+       ui_app_remove_event_handler(event_handlers[APP_EVENT_REGION_FORMAT_CHANGED]);
 
-       if (system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &info) == 0) {
-               if (info == NULL) return false;
-               if (!strncmp(QP_EMUL_STR, info, strlen(info))) {
-                       return true;
-               }
-       }
-
-       return false;
 }
 
 
 
 int main(int argc, char *argv[])
 {
-       char *buf;
-       app_event_callback_s event_callback;
+       ui_app_lifecycle_callback_s lifecycle_callback = {0, };
+       app_event_handler_h event_handlers[5] = {NULL, };
 
-       if (_is_emulator_on()) {
-               _D("ELM_ENGINE is set as [software_x11]");
-               setenv("ELM_ENGINE", "software_x11", 1);
-       } else {
-               buf = vconf_get_str(MENU_SCREEN_ENGINE);
-               if (buf) {
-                       _D("ELM_ENGINE is set as [%s]", buf);
-                       setenv("ELM_ENGINE", buf, 1);
-                       free(buf);
-               } else {
-                       _D("ELM_ENGINE is set as [gl]");
-                       setenv("ELM_ENGINE", "gl", 1);
-               }
-       }
-
-       _init(&event_callback);
-       app_efl_main(&argc, &argv, &event_callback, NULL);
-       _fini();
+       _init(&lifecycle_callback, event_handlers);
+       ui_app_main(argc, argv, &lifecycle_callback, NULL);
+       _fini(event_handlers);
 
        return EXIT_SUCCESS;
 }
 
 
 
-
-
 // End of a file