2 * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <Elementary.h>
26 #include "appcore_efl_base_private.h"
27 #include "appcore_efl_base.h"
29 #define PATH_LIB_VC_ELM "/usr/lib/libvc-elm.so.0"
31 static bool __vc_elm_initialized;
32 static void *__vc_elm_handle;
33 static int (*__vc_elm_initialize)(void);
34 static int (*__vc_elm_deinitialize)(void);
35 static int (*__vc_elm_set_auto_register_mode)(int, int);
37 static void __unload_vc_elm(void)
42 __vc_elm_initialize = NULL;
43 __vc_elm_deinitialize = NULL;
44 __vc_elm_set_auto_register_mode = NULL;
46 dlclose(__vc_elm_handle);
47 __vc_elm_handle = NULL;
50 static int __load_vc_elm(void)
55 if (access(PATH_LIB_VC_ELM, F_OK) != 0) {
56 _ERR("Failed to access %s", PATH_LIB_VC_ELM);
60 __vc_elm_handle = dlopen(PATH_LIB_VC_ELM, RTLD_LAZY | RTLD_GLOBAL);
61 if (!__vc_elm_handle) {
62 _ERR("Failed to open %s", PATH_LIB_VC_ELM);
66 __vc_elm_initialize = dlsym(__vc_elm_handle, "vc_elm_initialize");
67 if (!__vc_elm_initialize) {
68 _ERR("Failed to load vc_elm_initialize");
73 __vc_elm_deinitialize = dlsym(__vc_elm_handle, "vc_elm_deinitialize");
74 if (!__vc_elm_deinitialize) {
75 _ERR("Failed to load vc_elm_deinitialize");
80 __vc_elm_set_auto_register_mode = dlsym(__vc_elm_handle,
81 "vc_elm_set_auto_register_mode");
82 if (!__vc_elm_set_auto_register_mode) {
83 _ERR("Failed to load vc_elm_set_auto_register_mode");
91 static void __vc_vtauto_changed_cb(keynode_t *key, void *data)
96 name = vconf_keynode_get_name(key);
97 if (!name || strcmp(name, VCONFKEY_VC_VOICE_TOUCH_AUTOMODE) != 0)
100 vt_automode = vconf_keynode_get_bool(key);
102 if (!__vc_elm_initialized) {
103 __vc_elm_initialize();
104 __vc_elm_initialized = true;
106 __vc_elm_set_auto_register_mode(2, 0);
108 __vc_elm_deinitialize();
109 __vc_elm_initialized = false;
113 static void __vc_elm_init(void)
122 vconf_notify_key_changed(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE,
123 __vc_vtauto_changed_cb, NULL);
124 vconf_get_bool(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE, &vt_automode);
126 if (!__vc_elm_initialized) {
127 __vc_elm_initialize();
128 __vc_elm_initialized = true;
130 __vc_elm_set_auto_register_mode(2, 0);
134 static void __vc_elm_finish(void)
136 vconf_ignore_key_changed(VCONFKEY_VC_VOICE_TOUCH_AUTOMODE,
137 __vc_vtauto_changed_cb);
138 if (__vc_elm_initialized) {
139 __vc_elm_deinitialize();
140 __vc_elm_initialized = false;
144 static void __efl_app_init(int argc, char **argv, void *data)
149 elm_init(argc, argv);
151 hint = appcore_efl_base_get_hint();
152 if (hint & APPCORE_EFL_BASE_HINT_HW_ACC_CONTROL) {
153 hwacc = getenv("HWACC");
155 _DBG("elm_config_accel_preference_set is not called");
156 } else if (strcmp(hwacc, "USE") == 0) {
157 elm_config_accel_preference_set("hw");
158 _DBG("elm_config_accel_preference_set : hw");
159 } else if (strcmp(hwacc, "NOT_USE") == 0) {
160 elm_config_accel_preference_set("none");
161 _DBG("elm_config_accel_preference_set : none");
163 _DBG("elm_config_accel_preference_set is not called");
167 /* VC voice touch setting */
171 static void __efl_app_finish(void)
177 /* Check loader case */
178 if (getenv("AUL_LOADER_INIT")) {
179 unsetenv("AUL_LOADER_INIT");
184 static void __efl_app_run(void *data)
189 static void __efl_app_exit(void *data)
194 EXPORT_API int appcore_efl_base_init(appcore_efl_base_ops ops, int argc,
195 char **argv, void *data, unsigned int hint)
197 return appcore_ui_base_init(ops.ui_base, argc, argv, data, hint);
200 EXPORT_API void appcore_efl_base_fini(void)
202 appcore_ui_base_fini();
205 EXPORT_API appcore_efl_base_ops appcore_efl_base_get_default_ops(void)
207 appcore_efl_base_ops ops;
209 ops.ui_base = appcore_ui_base_get_default_ops();
211 /* override methods */
212 ops.ui_base.base.init = __efl_app_init;
213 ops.ui_base.base.finish = __efl_app_finish;
214 ops.ui_base.base.run = __efl_app_run;
215 ops.ui_base.base.exit = __efl_app_exit;
220 EXPORT_API int appcore_efl_base_on_receive(aul_type type, bundle *b)
222 return appcore_ui_base_on_receive(type, b);
225 EXPORT_API int appcore_efl_base_on_create(void)
227 return appcore_ui_base_on_create();
230 EXPORT_API int appcore_efl_base_on_terminate(void)
232 return appcore_ui_base_on_terminate();
235 EXPORT_API int appcore_efl_base_on_pause(void)
237 return appcore_ui_base_on_pause();
240 EXPORT_API int appcore_efl_base_on_resume(void)
242 return appcore_ui_base_on_resume();
245 EXPORT_API int appcore_efl_base_on_control(bundle *b)
247 return appcore_ui_base_on_control(b);
250 EXPORT_API void appcore_efl_base_window_on_show(int type, void *event)
252 appcore_ui_base_window_on_show(type, event);
255 EXPORT_API void appcore_efl_base_window_on_hide(int type, void *event)
257 appcore_ui_base_window_on_hide(type, event);
260 EXPORT_API void appcore_efl_base_window_on_lower(int type, void *event)
262 appcore_ui_base_window_on_lower(type, event);
265 EXPORT_API void appcore_efl_base_window_on_visibility(int type, void *event)
267 appcore_ui_base_window_on_visibility(type, event);
270 EXPORT_API void appcore_efl_base_pause(void)
272 appcore_ui_base_pause();
275 EXPORT_API void appcore_efl_base_resume(void)
277 appcore_ui_base_resume();
280 EXPORT_API bool appcore_efl_base_is_resumed(void)
282 return appcore_ui_base_is_resumed();
285 EXPORT_API void appcore_efl_base_exit(void)
287 appcore_ui_base_exit();
290 EXPORT_API void appcore_efl_base_group_add(void)
292 appcore_ui_base_group_add();
295 EXPORT_API void appcore_efl_base_group_remove(void)
297 appcore_ui_base_group_remove();
300 EXPORT_API unsigned int appcore_efl_base_get_main_window(void)
302 return appcore_ui_base_get_main_window();
305 EXPORT_API unsigned int appcore_efl_base_get_main_surface(void)
307 return appcore_ui_base_get_main_surface();
310 EXPORT_API int appcore_efl_base_get_hint(void)
312 return appcore_ui_base_get_hint();
315 EXPORT_API bool appcore_efl_base_get_bg_state(void)
317 return appcore_ui_base_get_bg_state();
320 EXPORT_API void appcore_efl_base_set_bg_state(bool bg_state)
322 appcore_ui_base_set_bg_state(bg_state);