Separate appcore-ui package from appcore-efl package
[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 #include <voice_control_elm.h>
23 #include <voice_control_elm_private.h>
24
25 #include "appcore_efl_base_private.h"
26 #include "appcore_efl_base.h"
27
28 static int __efl_app_init(int argc, char **argv, void *data)
29 {
30         int r;
31         int hint;
32         int is_vc_vt_automode = 0;
33         const char *hwacc;
34
35         elm_init(argc, argv);
36
37         r = vc_elm_is_supported_vt_auto(&is_vc_vt_automode);
38         if (r != 0) {
39                 _ERR("[VC] Failed to get vconfkey of vt_automode");
40         } else {
41                 if (is_vc_vt_automode) {
42                         vc_elm_initialize();
43                         vc_elm_set_auto_register_mode(2, 0);
44                 }
45         }
46
47         hint = appcore_efl_base_get_hint();
48         if (hint & APPCORE_EFL_BASE_HINT_HW_ACC_CONTROL) {
49                 hwacc = getenv("HWACC");
50                 if (hwacc == NULL) {
51                         _DBG("elm_config_accel_preference_set is not called");
52                 } else if (strcmp(hwacc, "USE") == 0) {
53                         elm_config_accel_preference_set("hw");
54                         _DBG("elm_config_accel_preference_set : hw");
55                 } else if (strcmp(hwacc, "NOT_USE") == 0) {
56                         elm_config_accel_preference_set("none");
57                         _DBG("elm_config_accel_preference_set : none");
58                 } else {
59                         _DBG("elm_config_accel_preference_set is not called");
60                 }
61         }
62
63         return 0;
64 }
65
66 static void __efl_app_finish(void)
67 {
68         int r;
69         int is_vc_vt_automode = 0;
70
71         r = vc_elm_is_supported_vt_auto(&is_vc_vt_automode);
72         if (r != 0) {
73                 _ERR("[VC] Failed to get vconfkey of vt_automode");
74         } else {
75                 if (is_vc_vt_automode)
76                         vc_elm_deinitialize();
77         }
78
79         elm_shutdown();
80
81         /* Check loader case */
82         if (getenv("AUL_LOADER_INIT")) {
83                 unsetenv("AUL_LOADER_INIT");
84                 elm_shutdown();
85         }
86 }
87
88 static void __efl_app_run(void *data)
89 {
90         elm_run();
91 }
92
93 static void __efl_app_exit(void *data)
94 {
95         elm_exit();
96 }
97
98 EXPORT_API int appcore_efl_base_init(appcore_efl_base_ops ops, int argc,
99                 char **argv, void *data, unsigned int hint)
100 {
101         return appcore_ui_base_init(ops.ui_base, argc, argv, data, hint);
102 }
103
104 EXPORT_API void appcore_efl_base_fini(void)
105 {
106         appcore_ui_base_fini();
107 }
108
109 EXPORT_API appcore_efl_base_ops appcore_efl_base_get_default_ops(void)
110 {
111         appcore_efl_base_ops ops;
112
113         ops.ui_base = appcore_ui_base_get_default_ops();
114
115         /* override methods */
116         ops.ui_base.base.init = __efl_app_init;
117         ops.ui_base.base.finish = __efl_app_finish;
118         ops.ui_base.base.run = __efl_app_run;
119         ops.ui_base.base.exit = __efl_app_exit;
120
121         return ops;
122 }
123
124 EXPORT_API int appcore_efl_base_on_receive(aul_type type, bundle *b)
125 {
126         return appcore_ui_base_on_receive(type, b);
127 }
128
129 EXPORT_API int appcore_efl_base_on_create(void)
130 {
131         return appcore_ui_base_on_create();
132 }
133
134 EXPORT_API int appcore_efl_base_on_terminate(void)
135 {
136         return appcore_ui_base_on_terminate();
137 }
138
139 EXPORT_API int appcore_efl_base_on_pause(void)
140 {
141         return appcore_ui_base_on_pause();
142 }
143
144 EXPORT_API int appcore_efl_base_on_resume(void)
145 {
146         return appcore_ui_base_on_resume();
147 }
148
149 EXPORT_API int appcore_efl_base_on_control(bundle *b)
150 {
151         return appcore_ui_base_on_control(b);
152 }
153
154 EXPORT_API void appcore_efl_base_window_on_show(int type, void *event)
155 {
156         appcore_ui_base_window_on_show(type, event);
157 }
158
159 EXPORT_API void appcore_efl_base_window_on_hide(int type, void *event)
160 {
161         appcore_ui_base_window_on_hide(type, event);
162 }
163
164 EXPORT_API void appcore_efl_base_window_on_lower(int type, void *event)
165 {
166         appcore_ui_base_window_on_lower(type, event);
167 }
168
169 EXPORT_API void appcore_efl_base_window_on_visibility(int type, void *event)
170 {
171         appcore_ui_base_window_on_visibility(type, event);
172 }
173
174 EXPORT_API void appcore_efl_base_pause(void)
175 {
176         appcore_ui_base_pause();
177 }
178
179 EXPORT_API void appcore_efl_base_resume(void)
180 {
181         appcore_ui_base_resume();
182 }
183
184 EXPORT_API bool appcore_efl_base_is_resumed(void)
185 {
186         return appcore_ui_base_is_resumed();
187 }
188
189 EXPORT_API void appcore_efl_base_exit(void)
190 {
191         appcore_ui_base_exit();
192 }
193
194 EXPORT_API void appcore_efl_base_group_add(void)
195 {
196         appcore_ui_base_group_add();
197 }
198
199 EXPORT_API void appcore_efl_base_group_remove(void)
200 {
201         appcore_ui_base_group_remove();
202 }
203
204 EXPORT_API unsigned int appcore_efl_base_get_main_window(void)
205 {
206         return appcore_ui_base_get_main_window();
207 }
208
209 EXPORT_API unsigned int appcore_efl_base_get_main_surface(void)
210 {
211         return appcore_ui_base_get_main_surface();
212 }
213
214 EXPORT_API int appcore_efl_base_get_hint(void)
215 {
216         return appcore_ui_base_get_hint();
217 }