4 * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
7 * Genie Kim <daejins.kim@samsung.com>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include "location-log.h"
27 #include "location-ielement.h"
30 location_ielement_base_init(gpointer g_class)
32 static gboolean is_initialized = FALSE;
35 /* add properties and signals to the interface here */
37 is_initialized = TRUE;
42 location_ielement_get_type(void)
44 static GType iface_type = 0;
46 if (iface_type == 0) {
47 static const GTypeInfo info = {
48 sizeof(LocationIElementInterface),
49 location_ielement_base_init, /* base_init */
50 NULL /* base_finalize */
53 iface_type = g_type_register_static(G_TYPE_INTERFACE, "LocationIElement", &info, 0);
60 location_ielement_start(LocationIElement *self)
62 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
63 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
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);
69 location_ielement_stop(LocationIElement *self)
71 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
72 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
73 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->stop, LOCATION_ERROR_NOT_AVAILABLE);
74 return LOCATION_IELEMENT_GET_INTERFACE(self)->stop(self);
78 location_ielement_start_batch(LocationIElement *self)
80 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
81 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
82 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->start_batch, LOCATION_ERROR_NOT_AVAILABLE);
83 return LOCATION_IELEMENT_GET_INTERFACE(self)->start_batch(self);
87 location_ielement_stop_batch(LocationIElement *self)
89 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
90 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
91 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->stop_batch, LOCATION_ERROR_NOT_AVAILABLE);
92 return LOCATION_IELEMENT_GET_INTERFACE(self)->stop_batch(self);
96 location_ielement_request_single_location(LocationIElement *self, int timeout)
98 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
99 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
100 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->request_single_location, LOCATION_ERROR_NOT_AVAILABLE);
102 return LOCATION_IELEMENT_GET_INTERFACE(self)->request_single_location(self, timeout);
106 location_ielement_cancel_single_location(LocationIElement *self)
108 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
109 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
110 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->cancel_single_location, LOCATION_ERROR_NOT_AVAILABLE);
112 return LOCATION_IELEMENT_GET_INTERFACE(self)->cancel_single_location(self);
116 location_ielement_get_position(LocationIElement *self, LocationPosition **position, LocationAccuracy **accuracy)
118 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
119 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
120 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
121 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
122 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_position, LOCATION_ERROR_NOT_AVAILABLE);
124 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_position(self, position, accuracy);
128 location_ielement_get_position_ext(LocationIElement *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
130 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
131 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
132 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
133 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
134 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
135 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_position_ext, LOCATION_ERROR_NOT_AVAILABLE);
137 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_position_ext(self, position, velocity, accuracy);
142 location_ielement_get_last_position(LocationIElement *self, LocationPosition **position, LocationAccuracy **accuracy)
144 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
145 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
146 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
147 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
148 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
150 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_position(self, position, accuracy);
154 location_ielement_get_last_position_ext(LocationIElement *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
156 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
157 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
158 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
159 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
160 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
161 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_position_ext, LOCATION_ERROR_NOT_AVAILABLE);
163 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_position_ext(self, position, velocity, accuracy);
168 location_ielement_get_batch(LocationIElement *self, LocationBatch **batch)
170 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
171 g_return_val_if_fail(batch, LOCATION_ERROR_PARAMETER);
172 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
173 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_batch, LOCATION_ERROR_NOT_AVAILABLE);
175 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_batch(self, batch);
179 location_ielement_get_satellite(LocationIElement *self,
180 LocationSatellite **satellite)
182 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
183 g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
184 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
185 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_satellite, LOCATION_ERROR_NOT_AVAILABLE);
187 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_satellite(self, satellite);
191 location_ielement_get_last_satellite(LocationIElement *self, LocationSatellite **satellite)
193 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
194 g_return_val_if_fail(satellite, LOCATION_ERROR_PARAMETER);
195 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
196 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_satellite, LOCATION_ERROR_NOT_AVAILABLE);
198 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_satellite(self, satellite);
202 location_ielement_get_velocity(LocationIElement *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
204 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
205 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
206 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
207 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_velocity, LOCATION_ERROR_NOT_AVAILABLE);
208 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_velocity(self, velocity, accuracy);
212 location_ielement_get_last_velocity(LocationIElement *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
214 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
215 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
216 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
217 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_velocity, LOCATION_ERROR_NOT_AVAILABLE);
218 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_velocity(self, velocity, accuracy);
222 location_ielement_set_option(LocationIElement *self, const char *option)
224 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
225 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
226 return LOCATION_IELEMENT_GET_INTERFACE(self)->set_option(self, option);
230 location_ielement_get_nmea(LocationIElement *self, char **nmea)
232 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
233 g_return_val_if_fail(nmea, LOCATION_ERROR_PARAMETER);
234 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
235 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->get_nmea, LOCATION_ERROR_NOT_AVAILABLE);
237 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_nmea(self, nmea);
242 int location_ielement_set_mock_location(LocationIElement *self, const LocationPosition *position, const LocationVelocity *velocity, const LocationAccuracy *accuracy)
244 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
245 g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
246 g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
247 g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
248 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
249 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->set_mock_location, LOCATION_ERROR_NOT_AVAILABLE);
251 return LOCATION_IELEMENT_GET_INTERFACE(self)->set_mock_location(self, position, velocity, accuracy);
254 int location_ielement_clear_mock_location(LocationIElement *self)
256 g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
257 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
258 g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->clear_mock_location, LOCATION_ERROR_NOT_AVAILABLE);
260 return LOCATION_IELEMENT_GET_INTERFACE(self)->clear_mock_location(self);