Revert "Revert "Revert "Add codes for setting voice touch as auto mode"""
[platform/core/appfw/app-core.git] / src / efl_base / appcore_efl_base.c
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <stdio.h>
18 #include <string.h>
19 #include <stdlib.h>
20 #include <stdbool.h>
21 #include <Elementary.h>
22
23 #include "appcore_efl_base_private.h"
24 #include "appcore_efl_base.h"
25
26 static int __efl_app_init(int argc, char **argv, void *data)
27 {
28         int hint;
29         const char *hwacc;
30
31         elm_init(argc, argv);
32
33         hint = appcore_efl_base_get_hint();
34         if (hint & APPCORE_EFL_BASE_HINT_HW_ACC_CONTROL) {
35                 hwacc = getenv("HWACC");
36                 if (hwacc == NULL) {
37                         _DBG("elm_config_accel_preference_set is not called");
38                 } else if (strcmp(hwacc, "USE") == 0) {
39                         elm_config_accel_preference_set("hw");
40                         _DBG("elm_config_accel_preference_set : hw");
41                 } else if (strcmp(hwacc, "NOT_USE") == 0) {
42                         elm_config_accel_preference_set("none");
43                         _DBG("elm_config_accel_preference_set : none");
44                 } else {
45                         _DBG("elm_config_accel_preference_set is not called");
46                 }
47         }
48
49         return 0;
50 }
51
52 static void __efl_app_finish(void)
53 {
54         elm_shutdown();
55
56         /* Check loader case */
57         if (getenv("AUL_LOADER_INIT")) {
58                 unsetenv("AUL_LOADER_INIT");
59                 elm_shutdown();
60         }
61 }
62
63 static void __efl_app_run(void *data)
64 {
65         elm_run();
66 }
67
68 static void __efl_app_exit(void *data)
69 {
70         elm_exit();
71 }
72
73 EXPORT_API int appcore_efl_base_init(appcore_efl_base_ops ops, int argc,
74                 char **argv, void *data, unsigned int hint)
75 {
76         return appcore_ui_base_init(ops.ui_base, argc, argv, data, hint);
77 }
78
79 EXPORT_API void appcore_efl_base_fini(void)
80 {
81         appcore_ui_base_fini();
82 }
83
84 EXPORT_API appcore_efl_base_ops appcore_efl_base_get_default_ops(void)
85 {
86         appcore_efl_base_ops ops;
87
88         ops.ui_base = appcore_ui_base_get_default_ops();
89
90         /* override methods */
91         ops.ui_base.base.init = __efl_app_init;
92         ops.ui_base.base.finish = __efl_app_finish;
93         ops.ui_base.base.run = __efl_app_run;
94         ops.ui_base.base.exit = __efl_app_exit;
95
96         return ops;
97 }
98
99 EXPORT_API int appcore_efl_base_on_receive(aul_type type, bundle *b)
100 {
101         return appcore_ui_base_on_receive(type, b);
102 }
103
104 EXPORT_API int appcore_efl_base_on_create(void)
105 {
106         return appcore_ui_base_on_create();
107 }
108
109 EXPORT_API int appcore_efl_base_on_terminate(void)
110 {
111         return appcore_ui_base_on_terminate();
112 }
113
114 EXPORT_API int appcore_efl_base_on_pause(void)
115 {
116         return appcore_ui_base_on_pause();
117 }
118
119 EXPORT_API int appcore_efl_base_on_resume(void)
120 {
121         return appcore_ui_base_on_resume();
122 }
123
124 EXPORT_API int appcore_efl_base_on_control(bundle *b)
125 {
126         return appcore_ui_base_on_control(b);
127 }
128
129 EXPORT_API void appcore_efl_base_window_on_show(int type, void *event)
130 {
131         appcore_ui_base_window_on_show(type, event);
132 }
133
134 EXPORT_API void appcore_efl_base_window_on_hide(int type, void *event)
135 {
136         appcore_ui_base_window_on_hide(type, event);
137 }
138
139 EXPORT_API void appcore_efl_base_window_on_lower(int type, void *event)
140 {
141         appcore_ui_base_window_on_lower(type, event);
142 }
143
144 EXPORT_API void appcore_efl_base_window_on_visibility(int type, void *event)
145 {
146         appcore_ui_base_window_on_visibility(type, event);
147 }
148
149 EXPORT_API void appcore_efl_base_pause(void)
150 {
151         appcore_ui_base_pause();
152 }
153
154 EXPORT_API void appcore_efl_base_resume(void)
155 {
156         appcore_ui_base_resume();
157 }
158
159 EXPORT_API bool appcore_efl_base_is_resumed(void)
160 {
161         return appcore_ui_base_is_resumed();
162 }
163
164 EXPORT_API void appcore_efl_base_exit(void)
165 {
166         appcore_ui_base_exit();
167 }
168
169 EXPORT_API void appcore_efl_base_group_add(void)
170 {
171         appcore_ui_base_group_add();
172 }
173
174 EXPORT_API void appcore_efl_base_group_remove(void)
175 {
176         appcore_ui_base_group_remove();
177 }
178
179 EXPORT_API unsigned int appcore_efl_base_get_main_window(void)
180 {
181         return appcore_ui_base_get_main_window();
182 }
183
184 EXPORT_API unsigned int appcore_efl_base_get_main_surface(void)
185 {
186         return appcore_ui_base_get_main_surface();
187 }
188
189 EXPORT_API int appcore_efl_base_get_hint(void)
190 {
191         return appcore_ui_base_get_hint();
192 }