+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <Elementary.h>
+#include <voice_control_elm.h>
+#include <voice_control_elm_private.h>
+
+#include "appcore_efl_base_private.h"
+#include "appcore_efl_base.h"
+
+static int __efl_app_init(int argc, char **argv, void *data)
+{
+ int r;
+ int hint;
+ int is_vc_vt_automode = 0;
+ const char *hwacc;
+
+ elm_init(argc, argv);
+
+ r = vc_elm_is_supported_vt_auto(&is_vc_vt_automode);
+ if (r != 0) {
+ _ERR("[VC] Failed to get vconfkey of vt_automode");
+ } else {
+ if (is_vc_vt_automode) {
+ vc_elm_initialize();
+ vc_elm_set_auto_register_mode(2, 0);
+ }
+ }
+
+ hint = appcore_efl_base_get_hint();
+ if (hint & APPCORE_EFL_BASE_HINT_HW_ACC_CONTROL) {
+ hwacc = getenv("HWACC");
+ if (hwacc == NULL) {
+ _DBG("elm_config_accel_preference_set is not called");
+ } else if (strcmp(hwacc, "USE") == 0) {
+ elm_config_accel_preference_set("hw");
+ _DBG("elm_config_accel_preference_set : hw");
+ } else if (strcmp(hwacc, "NOT_USE") == 0) {
+ elm_config_accel_preference_set("none");
+ _DBG("elm_config_accel_preference_set : none");
+ } else {
+ _DBG("elm_config_accel_preference_set is not called");
+ }
+ }
+
+ return 0;
+}
+
+static void __efl_app_finish(void)
+{
+ int r;
+ int is_vc_vt_automode = 0;
+
+ r = vc_elm_is_supported_vt_auto(&is_vc_vt_automode);
+ if (r != 0) {
+ _ERR("[VC] Failed to get vconfkey of vt_automode");
+ } else {
+ if (is_vc_vt_automode)
+ vc_elm_deinitialize();
+ }
+
+ elm_shutdown();
+
+ /* Check loader case */
+ if (getenv("AUL_LOADER_INIT")) {
+ unsetenv("AUL_LOADER_INIT");
+ elm_shutdown();
+ }
+}
+
+static void __efl_app_run(void *data)
+{
+ elm_run();
+}
+
+static void __efl_app_exit(void *data)
+{
+ elm_exit();
+}
+
+EXPORT_API int appcore_efl_base_init(appcore_efl_base_ops ops, int argc,
+ char **argv, void *data, unsigned int hint)
+{
+ return appcore_ui_base_init(ops.ui_base, argc, argv, data, hint);
+}
+
+EXPORT_API void appcore_efl_base_fini(void)
+{
+ appcore_ui_base_fini();
+}
+
+EXPORT_API appcore_efl_base_ops appcore_efl_base_get_default_ops(void)
+{
+ appcore_efl_base_ops ops;
+
+ ops.ui_base = appcore_ui_base_get_default_ops();
+
+ /* override methods */
+ ops.ui_base.base.init = __efl_app_init;
+ ops.ui_base.base.finish = __efl_app_finish;
+ ops.ui_base.base.run = __efl_app_run;
+ ops.ui_base.base.exit = __efl_app_exit;
+
+ return ops;
+}
+
+EXPORT_API int appcore_efl_base_on_receive(aul_type type, bundle *b)
+{
+ return appcore_ui_base_on_receive(type, b);
+}
+
+EXPORT_API int appcore_efl_base_on_create(void)
+{
+ return appcore_ui_base_on_create();
+}
+
+EXPORT_API int appcore_efl_base_on_terminate(void)
+{
+ return appcore_ui_base_on_terminate();
+}
+
+EXPORT_API int appcore_efl_base_on_pause(void)
+{
+ return appcore_ui_base_on_pause();
+}
+
+EXPORT_API int appcore_efl_base_on_resume(void)
+{
+ return appcore_ui_base_on_resume();
+}
+
+EXPORT_API int appcore_efl_base_on_control(bundle *b)
+{
+ return appcore_ui_base_on_control(b);
+}
+
+EXPORT_API void appcore_efl_base_window_on_show(int type, void *event)
+{
+ appcore_ui_base_window_on_show(type, event);
+}
+
+EXPORT_API void appcore_efl_base_window_on_hide(int type, void *event)
+{
+ appcore_ui_base_window_on_hide(type, event);
+}
+
+EXPORT_API void appcore_efl_base_window_on_lower(int type, void *event)
+{
+ appcore_ui_base_window_on_lower(type, event);
+}
+
+EXPORT_API void appcore_efl_base_window_on_visibility(int type, void *event)
+{
+ appcore_ui_base_window_on_visibility(type, event);
+}
+
+EXPORT_API void appcore_efl_base_pause(void)
+{
+ appcore_ui_base_pause();
+}
+
+EXPORT_API void appcore_efl_base_resume(void)
+{
+ appcore_ui_base_resume();
+}
+
+EXPORT_API bool appcore_efl_base_is_resumed(void)
+{
+ return appcore_ui_base_is_resumed();
+}
+
+EXPORT_API void appcore_efl_base_exit(void)
+{
+ appcore_ui_base_exit();
+}
+
+EXPORT_API void appcore_efl_base_group_add(void)
+{
+ appcore_ui_base_group_add();
+}
+
+EXPORT_API void appcore_efl_base_group_remove(void)
+{
+ appcore_ui_base_group_remove();
+}
+
+EXPORT_API unsigned int appcore_efl_base_get_main_window(void)
+{
+ return appcore_ui_base_get_main_window();
+}
+
+EXPORT_API unsigned int appcore_efl_base_get_main_surface(void)
+{
+ return appcore_ui_base_get_main_surface();
+}
+
+EXPORT_API int appcore_efl_base_get_hint(void)
+{
+ return appcore_ui_base_get_hint();
+}