ea62ae8da6e29c6ba097248e853ac4d5f7479938
[framework/location/libslp-location.git] / location / 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/location-log.h"
27 #include "location/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_velocity (LocationIElement *self,
91         LocationVelocity **velocity,
92         LocationAccuracy **accuracy)
93 {
94         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
95         g_return_val_if_fail (velocity, LOCATION_ERROR_PARAMETER);
96         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_velocity, LOCATION_ERROR_NOT_AVAILABLE);
97         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_velocity (self, velocity, accuracy);
98 }
99
100 int
101 location_ielement_get_geocode (LocationIElement *self,
102         const LocationAddress *address,
103         LocationPosition **position,
104         LocationAccuracy **accuracy)
105 {
106         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
107         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
108         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
109         g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
110         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode, LOCATION_ERROR_NOT_AVAILABLE);
111         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode (self, address, position, accuracy);
112 }
113
114 int
115 location_ielement_get_geocode_freeform (LocationIElement *self,
116         const gchar *address,
117         LocationPosition **position,
118         LocationAccuracy **accuracy)
119 {
120         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
121         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
122         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
123         g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
124         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform, LOCATION_ERROR_NOT_AVAILABLE);
125         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform (self, address, position, accuracy);
126 }
127
128 int
129 location_ielement_get_reversegeocode (LocationIElement *self,
130         const LocationPosition *position,
131         LocationAddress **address,
132         LocationAccuracy **accuracy)
133 {
134         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
135         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
136         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
137         g_return_val_if_fail (accuracy, LOCATION_ERROR_PARAMETER);
138         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode, LOCATION_ERROR_NOT_AVAILABLE);
139         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode (self, position, address, accuracy);
140 }
141
142 int
143 location_ielement_get_geocode_async (LocationIElement *self,
144         const LocationAddress *address,
145         LocationPositionCB callback,
146         gpointer userdata)
147 {
148         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
149         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
150         g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
151         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_async, LOCATION_ERROR_NOT_AVAILABLE);
152         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_async (self, address, callback, userdata);
153 }
154
155 int
156 location_ielement_get_geocode_freeform_async (LocationIElement *self,
157         const gchar *address,
158         LocationPositionCB callback,
159         gpointer userdata)
160 {
161         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
162         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
163         g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
164         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform_async, LOCATION_ERROR_NOT_AVAILABLE);
165         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_geocode_freeform_async (self, address, callback, userdata);
166 }
167
168 int
169 location_ielement_get_reversegeocode_async (LocationIElement *self,
170         const LocationPosition *position,
171         LocationAddressCB callback,
172         gpointer userdata)
173 {
174         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
175         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
176         g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
177         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode_async, LOCATION_ERROR_NOT_AVAILABLE);
178         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_reversegeocode_async (self, position, callback, userdata);
179 }
180
181 int
182 location_ielement_get_poi (LocationIElement *self,
183         gdouble radius,
184         const gchar* keyword,
185         LocationPOIInfo **poi_info)
186 {
187         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
188         g_return_val_if_fail (poi_info, LOCATION_ERROR_PARAMETER);
189         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi, LOCATION_ERROR_NOT_AVAILABLE);
190         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi(self, radius, keyword, poi_info);
191 }
192
193 int
194 location_ielement_get_poi_from_address (LocationIElement *self,
195         const LocationAddress* address,
196         gdouble radius,
197         const gchar *keyword,
198         LocationPOIInfo **poi_info)
199 {
200         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
201         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
202         g_return_val_if_fail (poi_info, LOCATION_ERROR_PARAMETER);
203         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_address, LOCATION_ERROR_NOT_AVAILABLE);
204         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_address(self, address, radius, keyword, poi_info);
205 }
206
207 int
208 location_ielement_get_poi_from_position (LocationIElement *self,
209         const LocationPosition *position,
210         gdouble radius,
211         const gchar *keyword,
212         LocationPOIInfo **poi_info)
213 {
214         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
215         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
216         g_return_val_if_fail (poi_info, LOCATION_ERROR_PARAMETER);
217         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_position, LOCATION_ERROR_NOT_AVAILABLE);
218         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_position(self, position, radius, keyword, poi_info);
219 }
220
221 int
222 location_ielement_get_poi_async (LocationIElement *self,
223         gdouble radius,
224         const gchar *keyword,
225         LocationPOICB callback,
226         gpointer userdata)
227 {
228         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
229         g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
230         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_async, LOCATION_ERROR_NOT_AVAILABLE);
231         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_async (self, radius, keyword, callback, userdata);
232 }
233
234 int
235 location_ielement_get_poi_from_address_async (LocationIElement *self,
236         const LocationAddress *address,
237         gdouble radius,
238         const gchar* keyword,
239         LocationPOICB callback,
240         gpointer userdata)
241 {
242         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
243         g_return_val_if_fail (address, LOCATION_ERROR_PARAMETER);
244         g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
245         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_address_async, LOCATION_ERROR_NOT_AVAILABLE);
246         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_address_async (self, address, radius, keyword, callback, userdata);
247 }
248
249
250
251 int location_ielement_get_poi_from_position_async (LocationIElement *self,
252         const LocationPosition* position,
253         gdouble radius,
254         const gchar* keyword,
255         LocationPOICB callback,
256         gpointer userdata)
257 {
258         g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER);
259         g_return_val_if_fail (position, LOCATION_ERROR_PARAMETER);
260         g_return_val_if_fail (callback, LOCATION_ERROR_PARAMETER);
261         g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_position_async, LOCATION_ERROR_NOT_AVAILABLE);
262         return LOCATION_IELEMENT_GET_INTERFACE (self)->get_poi_from_position_async (self, position, radius, keyword, callback, userdata);
263 }