removed wrong contacts, added authors
[platform/core/location/lbs-location.git] / location / manager / location-ielement.c
1 /*
2  * libslp-location
3  *
4  * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22
23 #include "location-log.h"
24 #include "location-ielement.h"
25
26 static void
27 location_ielement_base_init(gpointer g_class)
28 {
29         static gboolean is_initialized = FALSE;
30
31         if (is_initialized) {
32                 /* add properties and signals to the interface here */
33
34                 is_initialized = TRUE;
35         }
36 }
37
38 GType
39 location_ielement_get_type(void)
40 {
41         static GType iface_type = 0;
42
43         if (iface_type == 0) {
44                 static const GTypeInfo info = {
45                         sizeof(LocationIElementInterface),
46                         location_ielement_base_init, /* base_init */
47                         NULL /* base_finalize */
48                 };
49
50                 iface_type = g_type_register_static(G_TYPE_INTERFACE, "LocationIElement", &info, 0);
51         }
52
53         return iface_type;
54 }
55
56 int
57 location_ielement_start(LocationIElement *self)
58 {
59         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
60         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
61         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->start, LOCATION_ERROR_NOT_AVAILABLE);
62         return LOCATION_IELEMENT_GET_INTERFACE(self)->start(self);
63 }
64
65 int
66 location_ielement_stop(LocationIElement *self)
67 {
68         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
69         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
70         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->stop, LOCATION_ERROR_NOT_AVAILABLE);
71         return LOCATION_IELEMENT_GET_INTERFACE(self)->stop(self);
72 }
73
74 int
75 location_ielement_start_batch(LocationIElement *self)
76 {
77         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
78         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
79         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->start_batch, LOCATION_ERROR_NOT_AVAILABLE);
80         return LOCATION_IELEMENT_GET_INTERFACE(self)->start_batch(self);
81 }
82
83 int
84 location_ielement_stop_batch(LocationIElement *self)
85 {
86         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
87         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
88         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->stop_batch, LOCATION_ERROR_NOT_AVAILABLE);
89         return LOCATION_IELEMENT_GET_INTERFACE(self)->stop_batch(self);
90 }
91
92 int
93 location_ielement_request_single_location(LocationIElement *self, int timeout)
94 {
95         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
96         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
97         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->request_single_location, LOCATION_ERROR_NOT_AVAILABLE);
98
99         return LOCATION_IELEMENT_GET_INTERFACE(self)->request_single_location(self, timeout);
100 }
101
102 int
103 location_ielement_cancel_single_location(LocationIElement *self)
104 {
105         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
106         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
107         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->cancel_single_location, LOCATION_ERROR_NOT_AVAILABLE);
108
109         return LOCATION_IELEMENT_GET_INTERFACE(self)->cancel_single_location(self);
110 }
111
112 int
113 location_ielement_get_position(LocationIElement *self, LocationPosition **position, LocationAccuracy **accuracy)
114 {
115         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
116         g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
117         g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
118         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
119         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_position, LOCATION_ERROR_NOT_AVAILABLE);
120
121         return LOCATION_IELEMENT_GET_INTERFACE(self)->get_position(self, position, accuracy);
122 }
123
124 int
125 location_ielement_get_position_ext(LocationIElement *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
126 {
127         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
128         g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
129         g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
130         g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
131         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
132         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_position_ext, LOCATION_ERROR_NOT_AVAILABLE);
133
134         return LOCATION_IELEMENT_GET_INTERFACE(self)->get_position_ext(self, position, velocity, accuracy);
135 }
136
137
138 int
139 location_ielement_get_last_position(LocationIElement *self, LocationPosition **position, LocationAccuracy **accuracy)
140 {
141         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
142         g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
143         g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
144         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
145         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
146
147         return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_position(self, position, accuracy);
148 }
149
150 int
151 location_ielement_get_last_position_ext(LocationIElement *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
152 {
153         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
154         g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
155         g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
156         g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
157         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
158         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_position_ext, LOCATION_ERROR_NOT_AVAILABLE);
159
160         return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_position_ext(self, position, velocity, accuracy);
161 }
162
163
164 int
165 location_ielement_get_batch(LocationIElement *self, LocationBatch **batch)
166 {
167         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
168         g_return_val_if_fail(batch, LOCATION_ERROR_PARAMETER);
169         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
170         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_batch, LOCATION_ERROR_NOT_AVAILABLE);
171
172         return LOCATION_IELEMENT_GET_INTERFACE(self)->get_batch(self, batch);
173 }
174
175 int
176 location_ielement_get_satellite(LocationIElement *self,
177                                                                 LocationSatellite **satellite)
178 {
179         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
180         g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
181         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
182         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_satellite, LOCATION_ERROR_NOT_AVAILABLE);
183
184         return LOCATION_IELEMENT_GET_INTERFACE(self)->get_satellite(self, satellite);
185 }
186
187 int
188 location_ielement_get_last_satellite(LocationIElement *self, LocationSatellite **satellite)
189 {
190         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
191         g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
192         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
193         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_satellite, LOCATION_ERROR_NOT_AVAILABLE);
194
195         return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_satellite(self, satellite);
196 }
197
198 int
199 location_ielement_get_velocity(LocationIElement *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
200 {
201         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
202         g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
203         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
204         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_velocity, LOCATION_ERROR_NOT_AVAILABLE);
205         return LOCATION_IELEMENT_GET_INTERFACE(self)->get_velocity(self, velocity, accuracy);
206 }
207
208 int
209 location_ielement_get_last_velocity(LocationIElement *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
210 {
211         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
212         g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
213         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
214         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_velocity, LOCATION_ERROR_NOT_AVAILABLE);
215         return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_velocity(self, velocity, accuracy);
216 }
217
218 int
219 location_ielement_set_option(LocationIElement *self, const char *option)
220 {
221         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
222         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
223         return LOCATION_IELEMENT_GET_INTERFACE(self)->set_option(self, option);
224 }
225
226 int
227 location_ielement_get_nmea(LocationIElement *self, char **nmea)
228 {
229         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
230         g_return_val_if_fail(nmea, LOCATION_ERROR_PARAMETER);
231         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
232         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_nmea, LOCATION_ERROR_NOT_AVAILABLE);
233
234         return LOCATION_IELEMENT_GET_INTERFACE(self)->get_nmea(self, nmea);
235 }
236
237
238 /* Tizen 3.0 */
239 int location_ielement_set_mock_location(LocationIElement *self, const LocationPosition *position, const LocationVelocity *velocity, const LocationAccuracy *accuracy)
240 {
241         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
242         g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
243         g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
244         g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
245         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
246         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->set_mock_location, LOCATION_ERROR_NOT_AVAILABLE);
247
248         return LOCATION_IELEMENT_GET_INTERFACE(self)->set_mock_location(self, position, velocity, accuracy);
249 }
250
251 int location_ielement_clear_mock_location(LocationIElement *self)
252 {
253         g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
254         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
255         g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->clear_mock_location, LOCATION_ERROR_NOT_AVAILABLE);
256
257         return LOCATION_IELEMENT_GET_INTERFACE(self)->clear_mock_location(self);
258 }
259