Integrate appcore to reduce initialize time 18/109918/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 12 Jan 2017 07:52:38 +0000 (16:52 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 12 Jan 2017 09:01:52 +0000 (01:01 -0800)
IME application did not use appcore, AMD does not detect whether it's launched normally or not.
Therefore it was launched after 5 seconds timeout.

Change-Id: Idb0785bdbf80a52cf23b086a6b77c5e5bc6d2d58
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
CMakeLists.txt
packaging/libscl-core.spec
src/sclcoreui-efl.cpp
src/sclcoreui-efl.h

index 3bd64d6..64613c5 100644 (file)
@@ -34,6 +34,7 @@ SET(PKGS_CHECK_MODULES
         vconf
         libscl-common
         capi-appfw-application
+        appcore-efl
         )
 
 IF (with_wayland)
index f0f05d2..2deabe5 100644 (file)
@@ -28,6 +28,7 @@ BuildRequires:  pkgconfig(ecore-x)
 BuildRequires:  pkgconfig(x11)
 %endif
 BuildRequires:  pkgconfig(libscl-common)
+BuildRequires:  pkgconfig(appcore-efl)
 BuildRequires:  pkgconfig(capi-appfw-application)
 %if "%{WITH_WEBSOCKET}" == "TRUE"
 BuildRequires:  pkgconfig(libwebsockets)
index 93de8c0..da8ae2c 100644 (file)
@@ -19,6 +19,7 @@
 #include "sclcoreimpl.h"
 #include <Elementary.h>
 #include <dlog.h>
+#include <appcore-efl.h>
 
 #include <vconf.h>
 #include <vconf-keys.h>
@@ -38,6 +39,8 @@
 CWebHelperAgentWebSocket g_websocket;
 #endif
 
+static struct appcore_ops ops;
+
 #ifdef WAYLAND
 struct WaylandKeyboard
 {
@@ -74,6 +77,8 @@ CSCLCoreUIEFL::CSCLCoreUIEFL()
 
     m_rotation_degree = 0;
     m_main_window = SCLWINDOW_INVALID;
+    m_uuid = NULL;
+    m_display = NULL;
 }
 
 CSCLCoreUIEFL::~CSCLCoreUIEFL()
@@ -400,110 +405,154 @@ err:
 }
 #endif
 
-void CSCLCoreUIEFL::run(const sclchar *display)
+int CSCLCoreUIEFL::create(void *data)
 {
-    char *argv[4];
-    int argc = 3;
-
-    CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
-    if (impl) {
-        const sclchar *uuid = impl->get_uuid();
-        if (!uuid)
-            uuid = "";
-
-        argv[0] = const_cast<char *> (uuid);
-        argv[1] = (char *)"--display";
-        argv[2] = const_cast<char *> (display);
-        argv[3] = 0;
-
-        elm_init(argc, argv);
-
 #ifdef WAYLAND
-        if (!check_evas_engine(&wlkb)) {
-            LOGW("_wlkb_check_evas_engine error!\n");
-            elm_shutdown();
-            return;
-        }
-        LOGD("Selected engine: '%s'\n", wlkb.ee_engine);
+    if (!check_evas_engine(&wlkb)) {
+        LOGW("_wlkb_check_evas_engine error!\n");
+        elm_shutdown();
+        return -1;
+    }
+    LOGD("Selected engine: '%s'\n", wlkb.ee_engine);
 #endif
 
-        elm_config_accel_preference_set("3d");
-        elm_policy_set(ELM_POLICY_THROTTLE, ELM_POLICY_THROTTLE_NEVER);
+    elm_config_accel_preference_set("3d");
+    elm_policy_set(ELM_POLICY_THROTTLE, ELM_POLICY_THROTTLE_NEVER);
 
-        Evas_Object *main_window = elm_win_add(NULL, uuid, ELM_WIN_UTILITY);
-        if (!main_window) {
-            LOGE("Failed to create main window\n");
-            return;
-        }
+    Evas_Object *main_window = elm_win_add(NULL, m_uuid, ELM_WIN_UTILITY);
+    if (!main_window) {
+        LOGE("Failed to create main window\n");
+        return -1;
+    }
 
-        m_main_window = SCL_WINDOW_CAST(main_window);
+    m_main_window = SCL_WINDOW_CAST(main_window);
 
 #ifdef WAYLAND
-        if (!_wayland_setup(&wlkb, main_window)) {
-            LOGW("ERROR: Unable to setup input panel.\n");
-            elm_shutdown();
-            return;
-        }
+    if (!_wayland_setup(&wlkb, main_window)) {
+        LOGW("ERROR: Unable to setup input panel.\n");
+        appcore_efl_fini();
+        return -1;
+    }
 #endif
 
-        elm_win_borderless_set(main_window, EINA_TRUE);
-        elm_win_keyboard_win_set(main_window, EINA_TRUE);
-        elm_win_autodel_set(main_window, EINA_TRUE);
-        elm_win_title_set(main_window, uuid);
-        elm_win_prop_focus_skip_set(main_window, EINA_TRUE);
-        int rots[] = { 0, 90, 180, 270 };
-        elm_win_wm_rotation_available_rotations_set(main_window, rots, (sizeof(rots) / sizeof(int)));
+    elm_win_borderless_set(main_window, EINA_TRUE);
+    elm_win_keyboard_win_set(main_window, EINA_TRUE);
+    elm_win_autodel_set(main_window, EINA_TRUE);
+    elm_win_title_set(main_window, m_uuid);
+    elm_win_prop_focus_skip_set(main_window, EINA_TRUE);
+    int rots[] = { 0, 90, 180, 270 };
+    elm_win_wm_rotation_available_rotations_set(main_window, rots, (sizeof(rots) / sizeof(int)));
 
 #ifndef WAYLAND
-        unsigned int set = 1;
-        ecore_x_window_prop_card32_set(elm_win_xwindow_get(main_window),
-            ECORE_X_ATOM_E_WINDOW_ROTATION_SUPPORTED,
-            &set, 1);
+    unsigned int set = 1;
+    ecore_x_window_prop_card32_set(elm_win_xwindow_get(main_window),
+        ECORE_X_ATOM_E_WINDOW_ROTATION_SUPPORTED,
+        &set, 1);
 
-        ecore_x_icccm_name_class_set(elm_win_xwindow_get(main_window), "Virtual Keyboard", "ISF");
+    ecore_x_icccm_name_class_set(elm_win_xwindow_get(main_window), "Virtual Keyboard", "ISF");
 #endif
 
-        vconf_notify_key_changed(VCONFKEY_LANGSET, language_changed_cb, NULL);
-        vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb, NULL);
+    vconf_notify_key_changed(VCONFKEY_LANGSET, language_changed_cb, NULL);
+    vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb, NULL);
 
-        /* Should we call these callback functions here? */
-        language_changed_cb(NULL, NULL);
-        accessibility_changed_cb(NULL, NULL);
+    /* Should we call these callback functions here? */
+    language_changed_cb(NULL, NULL);
+    accessibility_changed_cb(NULL, NULL);
 
-        impl->init(display);
+    CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
+    if (impl)
+        impl->init(m_display);
 
 #ifdef WAYLAND
-        evas_object_smart_callback_add(main_window, "wm,rotation,changed", win_rotation_changed_cb, this);
+    evas_object_smart_callback_add(main_window, "wm,rotation,changed", win_rotation_changed_cb, NULL);
 #else
-        Ecore_Event_Handler *XClientMsgHandler =
-            ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _client_message_cb, this);
+    Ecore_Event_Handler *XClientMsgHandler =
+        ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _client_message_cb, this);
 #endif
 
-        signal(SIGQUIT, signal_handler);
-        signal(SIGTERM, signal_handler);
-        signal(SIGINT,  signal_handler);
-        signal(SIGHUP,  signal_handler);
+    signal(SIGQUIT, signal_handler);
+    signal(SIGTERM, signal_handler);
+    signal(SIGINT,  signal_handler);
+    signal(SIGHUP,  signal_handler);
 
 #ifdef WAYLAND
-        evas_object_show(main_window);
+    evas_object_show(main_window);
 #endif
 
-        elm_run();
+    return 0;
+}
 
+int CSCLCoreUIEFL::terminate(void *data)
+{
+    CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
+    if (impl)
         impl->fini();
 
-        vconf_ignore_key_changed(VCONFKEY_LANGSET, language_changed_cb);
-        vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb);
+    vconf_ignore_key_changed(VCONFKEY_LANGSET, language_changed_cb);
+    vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb);
 
 #ifndef WAYLAND
-        if (XClientMsgHandler) {
-            ecore_event_handler_del(XClientMsgHandler);
-            XClientMsgHandler = NULL;
-        }
+    if (XClientMsgHandler) {
+        ecore_event_handler_del(XClientMsgHandler);
+        XClientMsgHandler = NULL;
+    }
 #endif
 
-        elm_shutdown();
+    return 0;
+}
+
+static int app_create_cb(void *data)
+{
+    CSCLCoreUIEFL *sclui = static_cast<CSCLCoreUIEFL *>(data);
+    if (sclui)
+        return sclui->create(data);
+
+    return -1;
+}
+
+static int app_terminate_cb(void *data)
+{
+    CSCLCoreUIEFL *sclui = static_cast<CSCLCoreUIEFL *>(data);
+    if (sclui)
+        return sclui->terminate(data);
+
+    return -1;
+}
+
+void CSCLCoreUIEFL::run(const sclchar *display)
+{
+    char **argv = new char*[4];
+    int argc = 3;
+    const sclchar *uuid = NULL;
+
+    ops.create = app_create_cb;
+    ops.terminate = app_terminate_cb;
+    ops.resume = NULL;
+    ops.pause = NULL;
+    ops.reset = NULL;
+    ops.data = this;
+
+    CSCLCoreImpl *impl = CSCLCoreImpl::get_instance();
+    if (impl) {
+        uuid = impl->get_uuid();
     }
+
+    if (!uuid)
+        uuid = "";
+
+    m_uuid = uuid;
+    m_display = display;
+
+    argv[0] = const_cast<char *> (uuid);
+    argv[1] = (char *)"--display";
+    argv[2] = const_cast<char *> (display);
+    argv[3] = 0;
+
+    LOGD("name : %s\n", uuid);
+
+    int ret = appcore_efl_main(uuid, &argc, (char ***)&argv, &ops);
+
+    delete [] argv;
 }
 
 static void focus_out_cb(void *data, Evas *e, void *event)
index 30d0331..3cd50c6 100644 (file)
@@ -41,6 +41,9 @@ public:
     CSCLCoreUIEFL();
     ~CSCLCoreUIEFL();
 
+    int create(void *data);
+    int terminate(void *data);
+
     virtual sclboolean init();
     virtual void fini();
 
@@ -61,6 +64,8 @@ private:
 
     sclint m_rotation_degree;
     sclwindow m_main_window;
+    const sclchar *m_uuid;
+    const sclchar *m_display;
 
     OptionWindowInfo m_option_window_info[OPTION_WINDOW_TYPE_MAX];
 };