migrate appsvc to aul
[platform/core/appfw/app-svc.git] / src / appsvc.c
1 /*
2  * Copyright (c) 2015 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 <stdlib.h>
19 #include <glib.h>
20 #include <aul.h>
21 #include <aul_svc.h>
22 #include <Ecore.h>
23
24 #ifndef WAYLAND
25 #include <Ecore_X.h>
26 #endif
27
28 #include "appsvc.h"
29
30 #ifndef SLPAPI
31 #define SLPAPI __attribute__ ((visibility("default")))
32 #endif
33
34 SLPAPI int appsvc_set_operation(bundle *b, const char *operation)
35 {
36         return aul_svc_set_operation(b, operation);
37 }
38
39 SLPAPI int appsvc_set_uri(bundle *b, const char *uri)
40 {
41         return aul_svc_set_uri(b, uri);
42 }
43
44 SLPAPI int appsvc_set_mime(bundle *b, const char *mime)
45 {
46         return aul_svc_set_mime(b, mime);
47 }
48
49 SLPAPI int appsvc_add_data(bundle *b, const char *key, const char *val)
50 {
51         return aul_svc_add_data(b, key, val);
52 }
53
54 SLPAPI int appsvc_add_data_array(bundle *b, const char *key,  const char **val_array, int len)
55 {
56         return aul_svc_add_data_array(b, key, val_array, len);
57 }
58
59 SLPAPI int appsvc_set_pkgname(bundle *b, const char *pkg_name)
60 {
61         return aul_svc_set_pkgname(b, pkg_name);
62 }
63
64 SLPAPI int appsvc_set_appid(bundle *b, const char *appid)
65 {
66         return aul_svc_set_appid(b, appid);
67 }
68
69 SLPAPI int appsvc_set_category(bundle *b, const char *category)
70 {
71         return aul_svc_set_category(b, category);
72 }
73
74 SLPAPI int appsvc_set_launch_mode(bundle *b, const char *mode)
75 {
76         return aul_svc_set_launch_mode(b, mode);
77 }
78
79 SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, void *data)
80 {
81         return aul_svc_run_service(b, request_code, (aul_svc_res_fn)cbfunc, data);
82 }
83
84 SLPAPI int appsvc_usr_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, void *data, uid_t uid)
85 {
86         return aul_svc_run_service_with_uid(b, request_code, (aul_svc_res_fn)cbfunc, data, uid);
87 }
88
89 SLPAPI int appsvc_get_list(bundle *b, appsvc_info_iter_fn iter_fn, void *data)
90 {
91         return aul_svc_get_list(b, (aul_svc_info_iter_fn)iter_fn, data);
92 }
93
94 SLPAPI int appsvc_usr_get_list(bundle *b, appsvc_info_iter_fn iter_fn, void *data, uid_t uid)
95 {
96         return aul_svc_get_list_with_uid(b, (aul_svc_info_iter_fn)iter_fn, data, uid);
97 }
98
99 SLPAPI int appsvc_get_all_defapps(appsvc_info_iter_fn iter_fn, void *data)
100 {
101         return aul_svc_get_all_defapps((aul_svc_info_iter_fn)iter_fn, data);
102 }
103
104 SLPAPI const char *appsvc_get_operation(bundle *b)
105 {
106         return aul_svc_get_operation(b);
107 }
108
109 SLPAPI const char *appsvc_get_uri(bundle *b)
110 {
111         return aul_svc_get_uri(b);
112 }
113
114 SLPAPI const char *appsvc_get_mime(bundle *b)
115 {
116         return aul_svc_get_mime(b);
117 }
118
119 SLPAPI const char *appsvc_get_data(bundle *b, const char *key)
120 {
121         return aul_svc_get_data(b, key);
122 }
123
124 SLPAPI const char **appsvc_get_data_array(bundle *b, const char *key, int *len)
125 {
126         return aul_svc_get_data_array(b, key, len);
127 }
128
129 SLPAPI const char *appsvc_get_pkgname(bundle *b)
130 {
131         return aul_svc_get_pkgname(b);
132 }
133
134 SLPAPI const char *appsvc_get_appid(bundle *b)
135 {
136         return aul_svc_get_appid(b);
137 }
138
139 SLPAPI const char *appsvc_get_category(bundle *b)
140 {
141         return aul_svc_get_category(b);
142 }
143
144 SLPAPI const char *appsvc_get_launch_mode(bundle *b)
145 {
146         return aul_svc_get_launch_mode(b);
147 }
148
149 SLPAPI int appsvc_create_result_bundle(bundle *inb, bundle **outb)
150 {
151         return aul_svc_create_result_bundle(inb, outb);
152 }
153
154 SLPAPI int appsvc_send_result(bundle *b, appsvc_result_val result)
155 {
156         return aul_svc_send_result(b, (aul_svc_result_val)result);
157 }
158
159 SLPAPI int appsvc_set_defapp(const char *op, const char *mime_type, const char *uri,
160                                         const char *defapp, uid_t uid)
161 {
162         return aul_svc_set_defapp_with_uid(op, mime_type, uri, defapp, uid);
163 }
164
165 SLPAPI int appsvc_unset_defapp(const char *defapp, uid_t uid)
166 {
167         return aul_svc_unset_defapp_with_uid(defapp, uid);
168 }
169
170 SLPAPI int appsvc_unset_all_defapps()
171 {
172         return aul_svc_unset_all_defapps();
173 }
174
175 SLPAPI int appsvc_is_defapp(const char *pkg_name, uid_t uid)
176 {
177         return aul_svc_is_defapp_with_uid(pkg_name, uid);
178 }
179
180 SLPAPI int appsvc_data_is_array(bundle *b, const char *key)
181 {
182         return aul_svc_data_is_array(b, key);
183 }
184
185 #ifndef WAYLAND
186 SLPAPI int appsvc_allow_transient_app(bundle *b, Ecore_X_Window id)
187 {
188         return aul_svc_allow_transient_app(b, id);
189 }
190 #else
191 SLPAPI int appsvc_allow_transient_app(bundle *b, unsigned int id)
192 {
193         return aul_svc_allow_transient_app(b, id);
194 }
195 #endif
196
197 #ifndef WAYLAND
198 SLPAPI int appsvc_request_transient_app(bundle *b, Ecore_X_Window callee_id, appsvc_host_res_fn cbfunc, void *data)
199 {
200         return aul_svc_request_transient_app(b, callee_id, (aul_svc_host_res_fn)cbfunc, data);
201 }
202 #else
203 SLPAPI int appsvc_request_transient_app(bundle *b, unsigned int callee_id, appsvc_host_res_fn cbfunc, void *data)
204 {
205         return aul_svc_request_transient_app(b, callee_id, (aul_svc_host_res_fn)cbfunc, data);
206 }
207 #endif
208
209 SLPAPI int appsvc_subapp_terminate_request_pid(int pid)
210 {
211         return aul_svc_subapp_terminate_request_pid(pid);
212 }