Separate appcore-ui package from appcore-efl package
[platform/core/appfw/app-core.git] / src / legacy / appcore-efl.c
1 /*
2  * Copyright (c) 2000 - 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
22 #include "appcore-internal.h"
23 #include "appcore-efl.h"
24 #include "appcore_efl_base.h"
25
26 struct appcore_efl_context {
27         struct appcore_ops ops;
28 };
29
30 static struct appcore_efl_context __context;
31
32 static int __ui_app_create(void *data)
33 {
34         appcore_efl_base_on_create();
35
36         if (__context.ops.create) {
37                 if (__context.ops.create(__context.ops.data) < 0)
38                         return -1;
39         }
40
41         return 0;
42 }
43
44 static int __ui_app_terminate(void *data)
45 {
46         appcore_efl_base_on_terminate();
47
48         if (__context.ops.terminate)
49                 __context.ops.terminate(__context.ops.data);
50
51         return 0;
52 }
53
54 static int __ui_app_control(bundle *b, void *data)
55 {
56         appcore_efl_base_on_control(b);
57
58         if (__context.ops.reset)
59                 __context.ops.reset(b, __context.ops.data);
60
61         return 0;
62 }
63
64 static int __ui_app_pause(void *data)
65 {
66         appcore_efl_base_on_pause();
67
68         if (__context.ops.pause)
69                 __context.ops.pause(__context.ops.data);
70         return 0;
71 }
72
73 static int __ui_app_resume(void *data)
74 {
75         appcore_efl_base_on_resume();
76
77         if (__context.ops.resume)
78                 __context.ops.resume(__context.ops.data);
79         return 0;
80 }
81
82 EXPORT_API int appcore_efl_init(const char *name, int *argc, char ***argv,
83                      struct appcore_ops *ops)
84 {
85         int ret;
86         appcore_efl_base_ops efl_ops = appcore_efl_base_get_default_ops();
87
88         /* override methods */
89         efl_ops.ui_base.base.create = __ui_app_create;
90         efl_ops.ui_base.base.control = __ui_app_control;
91         efl_ops.ui_base.base.terminate = __ui_app_terminate;
92         efl_ops.ui_base.pause = __ui_app_pause;
93         efl_ops.ui_base.resume = __ui_app_resume;
94
95         __context.ops = *ops;
96
97         ret = appcore_efl_base_init(efl_ops, *argc, *argv, NULL,
98                         APPCORE_EFL_BASE_HINT_WINDOW_GROUP_CONTROL |
99                         APPCORE_EFL_BASE_HINT_WINDOW_STACK_CONTROL |
100                         APPCORE_EFL_BASE_HINT_BG_LAUNCH_CONTROL |
101                         APPCORE_EFL_BASE_HINT_HW_ACC_CONTROL |
102                         APPCORE_EFL_BASE_HINT_WINDOW_AUTO_CONTROL);
103
104         return ret;
105 }
106
107 EXPORT_API void appcore_efl_fini(void)
108 {
109         appcore_efl_base_fini();
110 }
111
112 EXPORT_API int appcore_efl_main(const char *name, int *argc, char ***argv,
113                                 struct appcore_ops *ops)
114 {
115         int r;
116
117         r = appcore_efl_init(name, argc, argv, ops);
118         if (r < 0)
119                 return r;
120
121         appcore_efl_fini();
122
123         return 0;
124 }
125
126 EXPORT_API void appcore_group_attach()
127 {
128         appcore_efl_base_group_add();
129 }
130
131 EXPORT_API void appcore_group_lower()
132 {
133         appcore_efl_base_group_remove();
134 }
135
136 EXPORT_API unsigned int appcore_get_main_window(void)
137 {
138         return appcore_efl_base_get_main_window();
139 }
140
141 EXPORT_API unsigned int appcore_get_main_surface(void)
142 {
143         return appcore_get_main_surface();
144 }
145
146 EXPORT_API int appcore_set_system_resource_reclaiming(bool enable)
147 {
148         return 0;
149 }