4 * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include "location-log.h"
24 #include "location-ielement.h"
27 location_ielement_base_init(gpointer g_class)
29 static gboolean is_initialized = FALSE;
32 /* add properties and signals to the interface here */
34 is_initialized = TRUE;
39 location_ielement_get_type(void)
41 static GType iface_type = 0;
43 if (iface_type == 0) {
44 static const GTypeInfo info = {
45 sizeof(LocationIElementInterface),
46 location_ielement_base_init, /* base_init */
47 NULL /* base_finalize */
50 iface_type = g_type_register_static(G_TYPE_INTERFACE, "LocationIElement", &info, 0);
57 location_ielement_start(LocationIElement *self)
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);
66 location_ielement_stop(LocationIElement *self)
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);
75 location_ielement_start_batch(LocationIElement *self)
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);
84 location_ielement_stop_batch(LocationIElement *self)
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);
93 location_ielement_request_single_location(LocationIElement *self, int timeout)
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);
99 return LOCATION_IELEMENT_GET_INTERFACE(self)->request_single_location(self, timeout);
103 location_ielement_cancel_single_location(LocationIElement *self)
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);
109 return LOCATION_IELEMENT_GET_INTERFACE(self)->cancel_single_location(self);
113 location_ielement_get_position(LocationIElement *self, LocationPosition **position, LocationAccuracy **accuracy)
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);
121 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_position(self, position, accuracy);
125 location_ielement_get_position_ext(LocationIElement *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
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);
134 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_position_ext(self, position, velocity, accuracy);
139 location_ielement_get_last_position(LocationIElement *self, LocationPosition **position, LocationAccuracy **accuracy)
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);
147 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_position(self, position, accuracy);
151 location_ielement_get_last_position_ext(LocationIElement *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
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);
160 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_position_ext(self, position, velocity, accuracy);
165 location_ielement_get_batch(LocationIElement *self, LocationBatch **batch)
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);
172 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_batch(self, batch);
176 location_ielement_get_satellite(LocationIElement *self,
177 LocationSatellite **satellite)
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);
184 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_satellite(self, satellite);
188 location_ielement_get_last_satellite(LocationIElement *self, LocationSatellite **satellite)
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);
195 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_last_satellite(self, satellite);
199 location_ielement_get_velocity(LocationIElement *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
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);
209 location_ielement_get_last_velocity(LocationIElement *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
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);
219 location_ielement_set_option(LocationIElement *self, const char *option)
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);
227 location_ielement_get_nmea(LocationIElement *self, char **nmea)
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);
234 return LOCATION_IELEMENT_GET_INTERFACE(self)->get_nmea(self, nmea);
239 int location_ielement_set_mock_location(LocationIElement *self, const LocationPosition *position, const LocationVelocity *velocity, const LocationAccuracy *accuracy)
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);
248 return LOCATION_IELEMENT_GET_INTERFACE(self)->set_mock_location(self, position, velocity, accuracy);
251 int location_ielement_clear_mock_location(LocationIElement *self)
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);
257 return LOCATION_IELEMENT_GET_INTERFACE(self)->clear_mock_location(self);