ffa63cbef4d9f358aaf7faca17fceb2b2cb98475
[framework/location/libslp-location.git] / location / manager / location-ielement.c
1 /*
2  * libslp-location
3  *
4  * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
7  *          Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include "location-log.h"
27 #include "location-ielement.h"
28
29 static void
30 location_ielement_base_init (gpointer g_class)
31 {
32         static gboolean is_initialized = FALSE;
33
34         if (is_initialized){
35                 /* add properties and signals to the interface here */
36
37                 is_initialized = TRUE;
38         }
39 }
40
41 GType
42 location_ielement_get_type (void)
43 {
44         static GType iface_type = 0;
45
46         if (iface_type == 0) {
47                 static const GTypeInfo info = {
48                         sizeof (LocationIElementInterface),
49                         location_ielement_base_init, /* base_init */
50                         NULL /* base_finalize */
51                 };
52
53                 iface_type = g_type_register_static (G_TYPE_INTERFACE, "LocationIElement",
54                                              &info, 0);
55         }
56
57         return iface_type;
58 }
59
60 int
61 location_ielement_start (LocationIElement *self)
62 {
63         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
64         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->start, LOCATION_ERROR_NOT_AVAILABLE);
65         return LOCATION_IELEMENT_GET_INTERFACE (self)->start (self);
66 }
67
68 int
69 location_ielement_stop (LocationIElement *self)
70 {
71         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
72         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->stop, LOCATION_ERROR_NOT_AVAILABLE);
73         return LOCATION_IELEMENT_GET_INTERFACE (self)->stop (self);
74 }
75
76 int
77 location_ielement_get_position (LocationIElement *self,
78         LocationPosition **position,
79         LocationAccuracy **accuracy)
80 {
81         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
82         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
83         g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
84         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_position, LOCATION_ERROR_NOT_AVAILABLE);
85
86         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_position (self, position, accuracy);
87 }
88
89 int
90 location_ielement_get_last_position (LocationIElement *self,
91         LocationPosition **position,
92         LocationAccuracy **accuracy)
93 {
94         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
95         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
96         g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
97         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
98
99         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_position (self, position, accuracy);
100 }
101
102 int
103 location_ielement_get_satellite (LocationIElement *self,
104         LocationSatellite **satellite)
105 {
106         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
107         g_return_val_if_fail (satellite, LOCATION_ERROR_PARAMETER);
108         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_satellite, LOCATION_ERROR_NOT_AVAILABLE);
109
110         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_satellite (self, satellite);
111 }
112
113 int
114 location_ielement_get_last_satellite (LocationIElement *self,
115         LocationSatellite **satellite)
116 {
117         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
118         g_return_val_if_fail (satellite, LOCATION_ERROR_PARAMETER);
119         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_satellite, LOCATION_ERROR_NOT_AVAILABLE);
120
121         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_satellite (self, satellite);
122 }
123
124
125 int
126 location_ielement_get_velocity (LocationIElement *self,
127         LocationVelocity **velocity,
128         LocationAccuracy **accuracy)
129 {
130         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
131         g_return_val_if_fail (velocity, LOCATION_ERROR_PARAMETER);
132         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_velocity, LOCATION_ERROR_NOT_AVAILABLE);
133         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_velocity (self, velocity, accuracy);
134 }
135
136 int
137 location_ielement_get_last_velocity (LocationIElement *self,
138         LocationVelocity **velocity,
139         LocationAccuracy **accuracy)
140 {
141         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
142         g_return_val_if_fail (velocity, LOCATION_ERROR_PARAMETER);
143         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_velocity, LOCATION_ERROR_NOT_AVAILABLE);
144         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_velocity (self, velocity, accuracy);
145 }
146
147 int
148 location_ielement_get_geocode (LocationIElement *self,
149         const LocationAddress *address,
150         GList **position_list,
151         GList **accuracy_list)
152 {
153         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
154         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
155         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode, LOCATION_ERROR_NOT_AVAILABLE);
156         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode (self, address, position_list, accuracy_list);
157 }
158
159 int
160 location_ielement_get_geocode_freeform (LocationIElement *self,
161         const gchar *address,
162         GList **position_list,
163         GList **accuracy_list)
164 {
165         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
166         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
167         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform, LOCATION_ERROR_NOT_AVAILABLE);
168         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform (self, address, position_list, accuracy_list);
169 }
170
171 int
172 location_ielement_get_reversegeocode (LocationIElement *self,
173         const LocationPosition *position,
174         LocationAddress **address,
175         LocationAccuracy **accuracy)
176 {
177         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
178         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
179         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
180         g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
181         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode, LOCATION_ERROR_NOT_AVAILABLE);
182         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode (self, position, address, accuracy);
183 }
184
185 int
186 location_ielement_get_geocode_async (LocationIElement *self,
187         const LocationAddress *address,
188         LocationPositionCB callback,
189         gpointer userdata)
190 {
191         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
192         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
193         g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
194         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_async, LOCATION_ERROR_NOT_AVAILABLE);
195         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_async (self, address, callback, userdata);
196 }
197
198 int
199 location_ielement_get_geocode_freeform_async (LocationIElement *self,
200         const gchar *address,
201         LocationPositionCB callback,
202         gpointer userdata)
203 {
204         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
205         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
206         g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
207         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform_async, LOCATION_ERROR_NOT_AVAILABLE);
208         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform_async (self, address, callback, userdata);
209 }
210
211 int
212 location_ielement_get_reversegeocode_async (LocationIElement *self,
213         const LocationPosition *position,
214         LocationAddressCB callback,
215         gpointer userdata)
216 {
217         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
218         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
219         g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
220         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode_async, LOCATION_ERROR_NOT_AVAILABLE);
221         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode_async (self, position, callback, userdata);
222 }
223
224 int
225 location_ielement_search_poi (LocationIElement *self,
226                 const LocationPOIFilter * filter, const LocationPosition *position,
227                 const LocationPreference *svc_pref, const LocationPOIPreference * pref,
228                 LocationPOICB cb, const gpointer user_data, guint * req_id)
229 {
230         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
231         g_return_val_if_fail (filter, LOCATION_ERROR_PARAMETER);
232         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
233         g_return_val_if_fail (pref, LOCATION_ERROR_PARAMETER);
234         g_return_val_if_fail (cb, LOCATION_ERROR_PARAMETER);
235         g_return_val_if_fail (req_id, LOCATION_ERROR_PARAMETER);
236         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->search_poi, LOCATION_ERROR_NOT_AVAILABLE);
237
238         return LOCATION_IELEMENT_GET_INTERFACE (self)->search_poi(self,
239                         filter, position, svc_pref, pref, cb, user_data, req_id);
240 }
241
242 int
243 location_ielement_search_poi_by_area (LocationIElement *self,
244                 const LocationPOIFilter * filter, const LocationBoundary * boundary,
245                 const LocationPreference *svc_pref, const LocationPOIPreference * pref,
246                 LocationPOICB cb, const gpointer user_data, guint * req_id)
247 {
248         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
249         g_return_val_if_fail (filter, LOCATION_ERROR_PARAMETER);
250         g_return_val_if_fail (boundary, LOCATION_ERROR_PARAMETER);
251         g_return_val_if_fail (pref, LOCATION_ERROR_PARAMETER);
252         g_return_val_if_fail (cb, LOCATION_ERROR_PARAMETER);
253         g_return_val_if_fail (req_id, LOCATION_ERROR_PARAMETER);
254         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->search_poi_by_area, LOCATION_ERROR_NOT_AVAILABLE);
255
256         return LOCATION_IELEMENT_GET_INTERFACE (self)->search_poi_by_area (self,
257                         filter, boundary, svc_pref, pref, cb, user_data, req_id);
258 }
259
260 int
261 location_ielement_search_poi_by_address (LocationIElement *self,
262                 const LocationPOIFilter * filter, const LocationAddress * address,
263                 const LocationPreference *svc_pref, const LocationPOIPreference * pref,
264                 LocationPOICB cb, const gpointer user_data, guint * req_id)
265 {
266         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
267         g_return_val_if_fail (filter, LOCATION_ERROR_PARAMETER);
268         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
269         g_return_val_if_fail (pref, LOCATION_ERROR_PARAMETER);
270         g_return_val_if_fail (cb, LOCATION_ERROR_PARAMETER);
271         g_return_val_if_fail (req_id, LOCATION_ERROR_PARAMETER);
272         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->search_poi_by_address, LOCATION_ERROR_NOT_AVAILABLE);
273
274         return LOCATION_IELEMENT_GET_INTERFACE (self)->search_poi_by_address (self,
275                         filter, address, svc_pref, pref, cb, user_data, req_id);
276 }
277
278 int
279 location_ielement_search_poi_by_freeform (LocationIElement *self, const LocationPOIFilter * filter,
280                 const gchar *freeform, const LocationPreference *svc_pref, const LocationPOIPreference *pref, LocationPOICB cb,
281                 const gpointer user_data, guint * req_id)
282 {
283         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
284         g_return_val_if_fail (filter, LOCATION_ERROR_PARAMETER);
285         g_return_val_if_fail (freeform, LOCATION_ERROR_PARAMETER);
286         g_return_val_if_fail (pref, LOCATION_ERROR_PARAMETER);
287         g_return_val_if_fail (cb, LOCATION_ERROR_PARAMETER);
288         g_return_val_if_fail (req_id, LOCATION_ERROR_PARAMETER);
289         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->search_poi_by_freeform, LOCATION_ERROR_NOT_AVAILABLE);
290
291         return LOCATION_IELEMENT_GET_INTERFACE (self)->search_poi_by_freeform (self,
292                         filter, freeform, svc_pref, pref, cb, user_data, req_id);
293 }
294
295 int
296 location_ielement_cancel_poi_request (LocationIElement *self, guint req_id)
297 {
298         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
299         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->cancel_poi_request, LOCATION_ERROR_NOT_AVAILABLE);
300
301         return LOCATION_IELEMENT_GET_INTERFACE (self)->cancel_poi_request (self, req_id);
302 }
303
304 int
305 location_ielement_request_route (LocationIElement *self, const LocationPosition *origin,
306                 const LocationPosition *destination, GList *waypoint,
307                 const LocationPreference *svc_pref, const LocationRoutePreference *pref, LocationRouteCB cb, const gpointer user_data, guint *req_id)
308 {
309         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
310         g_return_val_if_fail (origin, LOCATION_ERROR_PARAMETER);
311         g_return_val_if_fail (destination, LOCATION_ERROR_PARAMETER);
312         g_return_val_if_fail (pref, LOCATION_ERROR_PARAMETER);
313         g_return_val_if_fail (cb, LOCATION_ERROR_PARAMETER);
314         g_return_val_if_fail (req_id, LOCATION_ERROR_PARAMETER);
315         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->request_route, LOCATION_ERROR_NOT_AVAILABLE);
316
317         return LOCATION_IELEMENT_GET_INTERFACE (self)->request_route (self,
318                         origin, destination, waypoint, svc_pref, pref, cb, user_data, req_id);
319 }
320
321 int
322 location_ielement_cancel_route_request (LocationIElement *self, guint req_id)
323 {
324         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
325         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->cancel_route_request, LOCATION_ERROR_NOT_AVAILABLE);
326
327         return LOCATION_IELEMENT_GET_INTERFACE (self)->cancel_route_request (self, req_id);
328 }
329
330 gboolean
331 location_ielement_is_supported_map_provider_capability (LocationIElement *self, LocationMapServiceType type)
332 {
333         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
334         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->is_supported_map_provider_capability, LOCATION_ERROR_NOT_AVAILABLE);
335
336         return LOCATION_IELEMENT_GET_INTERFACE (self)->is_supported_map_provider_capability (self, type);
337 }
338
339 int
340 location_ielement_get_map_provider_capability_key (LocationIElement *self, LocationMapServiceType type, GList **key)
341 {
342         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
343         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_map_provider_capability_key, LOCATION_ERROR_NOT_AVAILABLE);
344
345         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_map_provider_capability_key (self, type, key);
346 }