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 <app_manager.h>
25 #include "location-setting.h"
26 #include "location-log.h"
28 #include "module-internal.h"
30 #include "location-gps.h"
31 #include "location-marshal.h"
32 #include "location-ielement.h"
33 #include "location-signaling-util.h"
34 #include "location-common-util.h"
36 #include <vconf-internal-location-keys.h>
38 typedef struct _LocationGpsPrivate {
42 gboolean is_batch_invoked;
48 guint pos_updated_timestamp;
49 guint vel_updated_timestamp;
50 guint sat_updated_timestamp;
51 guint loc_updated_timestamp;
52 guint dist_updated_timestamp;
57 guint optimized_interval;
63 LocationPosition *pos;
65 LocationVelocity *vel;
66 LocationAccuracy *acc;
67 LocationSatellite *sat;
69 #if defined(TIZEN_DEVICE)
71 sensor_listener_h sensor_listener;
87 PROP_REMOVAL_BOUNDARY,
96 static guint32 signals[LAST_SIGNAL] = {0, };
97 static GParamSpec *properties[PROP_MAX] = {NULL, };
99 #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), LOCATION_TYPE_GPS, LocationGpsPrivate))
101 static void location_ielement_interface_init(LocationIElementInterface *iface);
102 static int location_gps_cancel_single_location(LocationGps *self);
104 G_DEFINE_TYPE_WITH_CODE(LocationGps, location_gps, G_TYPE_OBJECT,
105 G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, location_ielement_interface_init));
107 static void __reset_pos_data_from_priv(LocationGpsPrivate *priv)
110 g_return_if_fail(priv);
113 location_position_free(priv->pos);
118 location_batch_free(priv->batch);
123 location_velocity_free(priv->vel);
128 location_satellite_free(priv->sat);
133 location_accuracy_free(priv->acc);
136 priv->pos_updated_timestamp = 0;
137 priv->vel_updated_timestamp = 0;
138 priv->sat_updated_timestamp = 0;
139 priv->loc_updated_timestamp = 0;
141 priv->signal_type = 0;
144 static gboolean __get_started(gpointer self)
146 g_return_val_if_fail(self, FALSE);
148 LocationGpsPrivate *priv = GET_PRIVATE(self);
149 g_return_val_if_fail(priv, FALSE);
151 return priv->is_started;
154 static int __set_started(gpointer self, gboolean started)
156 g_return_val_if_fail(self, -1);
158 LocationGpsPrivate *priv = GET_PRIVATE(self);
159 g_return_val_if_fail(priv, -1);
161 if (priv->is_started != started) {
162 g_mutex_lock(&priv->mutex);
163 priv->is_started = started;
164 g_mutex_unlock(&priv->mutex);
170 static void gps_status_cb(gboolean enabled, LocationStatus status, gpointer self)
173 g_return_if_fail(self);
174 LocationGpsPrivate *priv = GET_PRIVATE(self);
175 g_return_if_fail(priv);
176 if (!priv->enabled && enabled) { /* Update satellite at searching status. */
177 return; /* Ignored: Support to get position at enabled callback */
178 } else if (priv->enabled == TRUE && enabled == FALSE) {
179 __set_started(self, FALSE);
180 enable_signaling(self, signals, &(priv->enabled), enabled, status);
184 static void gps_location_cb(gboolean enabled, LocationPosition *pos, LocationVelocity *vel, LocationAccuracy *acc, gpointer self)
186 g_return_if_fail(self);
187 g_return_if_fail(pos);
188 g_return_if_fail(vel);
189 g_return_if_fail(acc);
191 LocationGpsPrivate *priv = GET_PRIVATE(self);
192 g_return_if_fail(priv);
194 if (priv->min_interval != LOCATION_UPDATE_INTERVAL_NONE) {
195 distance_based_position_signaling(self, signals, enabled, pos, vel, acc,
196 priv->min_interval, priv->min_distance, &(priv->enabled),
197 &(priv->dist_updated_timestamp), &(priv->pos), &(priv->vel), &(priv->acc));
199 location_signaling(self, signals, enabled, priv->boundary_list, pos, vel, acc,
200 priv->pos_interval, priv->vel_interval, priv->loc_interval, &(priv->enabled),
201 &(priv->pos_updated_timestamp), &(priv->vel_updated_timestamp),
202 &(priv->loc_updated_timestamp), &(priv->pos), &(priv->vel), &(priv->acc));
206 static void gps_batch_cb(gboolean enabled, guint num_of_location, gpointer self)
208 g_return_if_fail(self);
209 LocationGpsPrivate *priv = GET_PRIVATE(self);
210 g_return_if_fail(priv);
212 if (priv->batch != NULL)
213 location_batch_free(priv->batch);
215 priv->batch = location_get_batch_file(num_of_location);
217 g_signal_emit(self, signals[BATCH_UPDATED], 0, num_of_location);
221 static void gps_satellite_cb(gboolean enabled, LocationSatellite *sat, gpointer self)
223 g_return_if_fail(self);
224 LocationGpsPrivate *priv = GET_PRIVATE(self);
225 g_return_if_fail(priv);
227 satellite_signaling(self, signals, &(priv->enabled), priv->sat_interval, TRUE, &(priv->sat_updated_timestamp), &(priv->sat), sat);
230 static void location_setting_search_cb(keynode_t *key, gpointer self)
233 g_return_if_fail(key);
234 g_return_if_fail(self);
235 LocationGpsPrivate *priv = GET_PRIVATE(self);
236 g_return_if_fail(priv);
238 if (location_setting_get_key_val(key) == VCONFKEY_LOCATION_GPS_SEARCHING) {
239 if (!location_setting_get_int(VCONFKEY_LOCATION_MOCK_ENABLED)) {
240 LOCATION_LOGD("enable_signaling : SERVICE_DISABLED");
241 enable_signaling(self, signals, &(priv->enabled), FALSE, LOCATION_STATUS_NO_FIX);
246 static void location_setting_gps_cb(keynode_t *key, gpointer self)
249 g_return_if_fail(key);
250 g_return_if_fail(self);
251 LocationGpsPrivate *priv = GET_PRIVATE(self);
252 g_return_if_fail(priv);
253 g_return_if_fail(priv->mod);
254 g_return_if_fail(priv->mod->handler);
256 int ret = LOCATION_ERROR_NONE;
258 if (0 == location_setting_get_key_val(key) && priv->mod->ops.stop && __get_started(self)) {
259 LOCATION_LOGD("location stopped by setting");
260 __set_started(self, FALSE);
261 ret = priv->mod->ops.stop(priv->mod->handler);
262 if (ret == LOCATION_ERROR_NONE)
263 __reset_pos_data_from_priv(priv);
265 LOCATION_LOGI("Fail to stop[%d]", ret);
267 } else if (1 == location_setting_get_key_val(key) && priv->mod->ops.start && !__get_started(self)) {
268 LOCATION_LOGD("location resumed by setting");
269 __set_started(self, TRUE);
270 ret = priv->mod->ops.start(priv->mod->handler, priv->optimized_interval, gps_status_cb, gps_location_cb, gps_satellite_cb, self);
271 if (ret != LOCATION_ERROR_NONE) {
272 __set_started(self, FALSE);
273 LOCATION_LOGI("Fail to start[%d]", ret);
278 static int location_gps_start(LocationGps *self)
281 LocationGpsPrivate *priv = GET_PRIVATE(self);
282 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
283 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
284 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
285 g_return_val_if_fail(priv->mod->ops.start, LOCATION_ERROR_NOT_AVAILABLE);
287 LOC_COND_RET(__get_started(self) == TRUE, LOCATION_ERROR_NONE, _E, "gps already started. Error[%s]", err_msg(LOCATION_ERROR_NONE));
289 int ret = LOCATION_ERROR_NONE;
291 if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
292 ret = LOCATION_ERROR_SETTING_OFF;
293 } else if (location_setting_get_int(VCONFKEY_SETAPPL_PSMODE) == SETTING_PSMODE_WEARABLE_ENHANCED) {
294 return LOCATION_ACCESS_DENIED;
296 __set_started(self, TRUE);
297 ret = priv->mod->ops.start(priv->mod->handler, priv->optimized_interval, gps_status_cb, gps_location_cb, gps_satellite_cb, self);
298 if (ret != LOCATION_ERROR_NONE) {
299 LOCATION_LOGE("Fail to start gps. Error[%d]", ret);
300 __set_started(self, FALSE);
305 if (priv->app_type != CPPAPP && priv->set_noti == FALSE) {
306 location_setting_add_notify(VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb, self);
307 location_state_add_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb, self);
308 priv->set_noti = TRUE;
311 LOCATION_LOGD("EXIT <<<");
315 static int location_gps_stop(LocationGps *self)
318 LocationGpsPrivate *priv = GET_PRIVATE(self);
319 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
320 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
321 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
322 g_return_val_if_fail(priv->mod->ops.stop, LOCATION_ERROR_NOT_AVAILABLE);
324 int ret = LOCATION_ERROR_NONE;
326 if (__get_started(self) == TRUE) {
327 __set_started(self, FALSE);
328 ret = priv->mod->ops.stop(priv->mod->handler);
329 LOC_IF_FAIL_LOG(ret, _E, "Failed to stop [%s]", err_msg(ret));
331 return LOCATION_ERROR_NONE;
334 if (priv->app_type != CPPAPP && priv->set_noti == TRUE) {
335 location_setting_ignore_notify(VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb);
336 location_state_ignore_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb);
337 priv->set_noti = FALSE;
340 __reset_pos_data_from_priv(priv);
345 #if defined(TIZEN_DEVICE)
346 static void __sensor_event_cb(sensor_h s, sensor_event_s *event, void *data)
348 LocationGpsPrivate *priv = GET_PRIVATE(data);
349 g_return_if_fail(priv);
350 g_return_if_fail(event);
352 int remain_idx = (int)(event->values[4]);
354 if (priv->is_batch_invoked) {
355 location_batch_free(priv->batch);
356 priv->is_batch_invoked = FALSE;
360 if (priv->batch == NULL) {
361 g_return_if_fail(event->value_count <= 5);
362 priv->batch = location_batch_new(remain_idx + 1);
363 g_return_if_fail(priv->batch);
364 priv->batch->num_of_location = remain_idx + 1;
367 priv->batch->start_time = start + (time_t)((event->timestamp / 1001000) % 100000);
370 location_set_sensor_batch(priv->batch, event);
372 if (remain_idx == 0) {
373 g_signal_emit(data, signals[BATCH_UPDATED], 0, priv->batch->num_of_location);
374 priv->is_batch_invoked = TRUE;
378 static int __set_sensor_batch(LocationGps *self, int batch_interval)
381 LocationGpsPrivate *priv = GET_PRIVATE(self);
382 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
384 if (priv->batch != NULL) {
385 location_batch_free(priv->batch);
389 int update_interval = batch_interval * 1000; /* in ms */
391 bool supported = false;
393 ret = sensor_is_supported((sensor_type_e)0x1A02, &supported);
394 LOC_IF_FAIL(ret, _E, "Fail to sensor_is_supported [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
395 LOC_COND_RET(!supported, LOCATION_ERROR_NOT_SUPPORTED, _E, "Batch sensor is not supported [%s]", err_msg(LOCATION_ERROR_NOT_SUPPORTED));
397 ret = sensor_get_default_sensor((sensor_type_e)0x1A02, &priv->sensor);
398 LOC_IF_FAIL(ret, _E, "Fail to sensor_get_default_sensor [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
400 ret = sensor_create_listener(priv->sensor, &priv->sensor_listener);
401 LOC_IF_FAIL(ret, _E, "Fail to sensor_create_listener [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
403 ret = sensor_listener_set_event_cb(priv->sensor_listener, update_interval, __sensor_event_cb, self);
404 if (ret != SENSOR_ERROR_NONE) {
405 LOCATION_LOGE("sensor_listener_set_event_cb() failed");
406 sensor_destroy_listener(priv->sensor_listener);
407 return LOCATION_ERROR_NOT_AVAILABLE;
410 ret = sensor_listener_set_option(priv->sensor_listener, SENSOR_OPTION_ALWAYS_ON);
411 if (ret != SENSOR_ERROR_NONE) {
412 LOCATION_LOGE("sensor_listener_set_option() failed");
413 sensor_destroy_listener(priv->sensor_listener);
414 return LOCATION_ERROR_NOT_AVAILABLE;
416 ret = sensor_listener_start(priv->sensor_listener);
417 if (ret != SENSOR_ERROR_NONE) {
418 LOCATION_LOGE("sensor_listener_set_event_cb() failed");
419 sensor_destroy_listener(priv->sensor_listener);
420 return LOCATION_ERROR_NOT_AVAILABLE;
423 return LOCATION_ERROR_NONE;
427 static int location_gps_start_batch(LocationGps *self)
430 LocationGpsPrivate *priv = GET_PRIVATE(self);
431 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
432 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
433 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
434 g_return_val_if_fail(priv->mod->ops.start_batch, LOCATION_ERROR_NOT_AVAILABLE);
436 if (__get_started(self) == TRUE) return LOCATION_ERROR_NONE;
438 int ret = LOCATION_ERROR_NONE;
440 if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
441 ret = LOCATION_ERROR_SETTING_OFF;
444 __set_started(self, TRUE);
445 ret = priv->mod->ops.start_batch(priv->mod->handler, gps_batch_cb, priv->batch_interval, priv->batch_period, self);
446 if (ret != LOCATION_ERROR_NONE) {
447 LOCATION_LOGE("Fail to start_batch [%s]", err_msg(ret));
448 __set_started(self, FALSE);
453 #if defined(TIZEN_DEVICE)
454 if (_get_tizen_profile() != TIZEN_PROFILE_TV)
455 return __set_sensor_batch(self, priv->batch_interval);
462 static int location_gps_stop_batch(LocationGps *self)
465 LocationGpsPrivate *priv = GET_PRIVATE(self);
466 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
467 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
468 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
469 g_return_val_if_fail(priv->mod->ops.stop_batch, LOCATION_ERROR_NOT_AVAILABLE);
471 int ret = LOCATION_ERROR_NONE;
473 #if defined(TIZEN_DEVICE)
474 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
475 ret = sensor_listener_stop(priv->sensor_listener);
476 LOC_IF_FAIL(ret, _E, "Fail to listener_stop [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
478 ret = sensor_listener_unset_event_cb(priv->sensor_listener);
479 LOC_IF_FAIL_LOG(ret, _E, "Fail to listener_unset_event_cb [%s]", err_msg(ret));
481 ret = sensor_destroy_listener(priv->sensor_listener);
482 LOC_IF_FAIL_LOG(ret, _E, "Fail to destroy_listener [%s]", err_msg(ret));
487 if (__get_started(self) == TRUE) {
488 __set_started(self, FALSE);
489 ret = priv->mod->ops.stop_batch(priv->mod->handler);
490 LOC_IF_FAIL_LOG(ret, _E, "Failed to stop_batch [%s]", err_msg(ret));
492 return LOCATION_ERROR_NONE;
496 __reset_pos_data_from_priv(priv);
501 static void location_gps_dispose(GObject *gobject)
504 LocationGpsPrivate *priv = GET_PRIVATE(gobject);
505 g_return_if_fail(priv);
506 g_return_if_fail(priv->mod);
507 g_mutex_clear(&priv->mutex);
509 if (priv->loc_timeout) g_source_remove(priv->loc_timeout);
510 priv->loc_timeout = 0;
513 g_return_if_fail(priv->mod->ops.clear_mock_location);
514 priv->mod->ops.clear_mock_location(priv->mod->handler, NULL, gobject);
515 priv->is_mock = FALSE;
518 if (priv->app_type != CPPAPP && priv->set_noti == TRUE) {
519 location_setting_ignore_notify(VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb);
520 location_state_ignore_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb);
521 priv->set_noti = FALSE;
524 G_OBJECT_CLASS(location_gps_parent_class)->dispose(gobject);
527 static void location_gps_finalize(GObject *gobject)
530 LocationGpsPrivate *priv = GET_PRIVATE(gobject);
531 g_return_if_fail(priv);
533 module_free(priv->mod, "gps");
536 if (priv->boundary_list) {
537 g_list_free_full(priv->boundary_list, free_boundary_list);
538 priv->boundary_list = NULL;
542 location_position_free(priv->pos);
547 location_batch_free(priv->batch);
552 location_velocity_free(priv->vel);
557 location_accuracy_free(priv->acc);
562 location_satellite_free(priv->sat);
565 G_OBJECT_CLASS(location_gps_parent_class)->finalize(gobject);
568 static guint get_valid_interval(guint interval, int max_interval, int min_interval)
570 if (interval > max_interval)
571 return (guint)max_interval;
572 else if (interval < min_interval)
573 return (guint)min_interval;
578 static void location_gps_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
580 LocationGpsPrivate *priv = GET_PRIVATE(object);
581 g_return_if_fail(priv);
582 g_return_if_fail(priv->mod);
583 g_return_if_fail(priv->mod->handler);
586 switch (property_id) {
587 case PROP_BOUNDARY: {
588 GList *boundary_list = g_list_copy(g_value_get_pointer(value));
589 ret = set_prop_boundary(&priv->boundary_list, boundary_list);
590 LOC_IF_FAIL_LOG(ret, _E, "Set boundary. Error[%s]", err_msg(ret));
591 if (boundary_list) g_list_free(boundary_list);
594 case PROP_REMOVAL_BOUNDARY: {
595 LocationBoundary *req_boundary = (LocationBoundary *) g_value_dup_boxed(value);
596 ret = set_prop_removal_boundary(&priv->boundary_list, req_boundary);
597 LOC_IF_FAIL_LOG(ret, _E, "Removal boundary. Error[%s]", err_msg(ret));
600 case PROP_POS_INTERVAL: {
601 guint interval = g_value_get_uint(value);
602 LOCATION_LOGD("Set prop>> PROP_POS_INTERVAL: %u", interval);
603 if (interval == priv->pos_interval) break;
605 priv->pos_interval = get_valid_interval(interval, LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_MIN);
606 priv->optimized_interval = priv->pos_interval;
608 if (__get_started(object) == TRUE) {
609 LOCATION_LOGD("[update_pos_interval]: update pos-interval while pos-tracking");
610 g_return_if_fail(priv->mod->ops.set_position_update_interval);
611 priv->mod->ops.set_position_update_interval(priv->mod->handler, priv->pos_interval);
615 case PROP_VEL_INTERVAL: {
616 guint interval = g_value_get_uint(value);
617 LOCATION_LOGD("Set prop>> PROP_VEL_INTERVAL: %u", interval);
618 if (interval == priv->vel_interval) break;
619 priv->vel_interval = get_valid_interval(interval, LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_MIN);
622 case PROP_SAT_INTERVAL: {
623 guint interval = g_value_get_uint(value);
624 LOCATION_LOGD("Set prop>> PROP_SAT_INTERVAL: %u", interval);
625 priv->sat_interval = get_valid_interval(interval, LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_MIN);
628 case PROP_LOC_INTERVAL: {
629 guint interval = g_value_get_uint(value);
630 LOCATION_LOGD("Set prop>> PROP_LOC_INTERVAL: %u", interval);
631 if (interval == priv->loc_interval) break;
633 priv->loc_interval = get_valid_interval(interval, LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_MIN);
634 priv->optimized_interval = priv->loc_interval;
636 if (__get_started(object) == TRUE) {
637 LOCATION_LOGD("[update_pos_interval]: update loc-interval while loc-tracking");
638 g_return_if_fail(priv->mod->ops.set_position_update_interval);
639 priv->mod->ops.set_position_update_interval(priv->mod->handler, priv->loc_interval);
643 case PROP_BATCH_INTERVAL: {
644 guint interval = g_value_get_uint(value);
645 LOCATION_LOGD("Set prop>> PROP_BATCH_INTERVAL: %u", interval);
647 priv->batch_interval = interval;
649 if (__get_started(object) == TRUE) {
650 LOCATION_LOGD("[update_batch_interval]: update batch-interval while pos-tracking");
651 g_return_if_fail(priv->mod->ops.set_position_update_interval);
652 priv->mod->ops.set_position_update_interval(priv->mod->handler, priv->batch_interval);
656 case PROP_BATCH_PERIOD: {
657 guint interval = g_value_get_uint(value);
658 LOCATION_LOGD("Set prop>> PROP_BATCH_PERIOD: %u", interval);
659 priv->batch_period = interval;
662 case PROP_MIN_INTERVAL: {
663 guint interval = g_value_get_uint(value);
664 LOCATION_LOGD("Set prop>> PROP_MIN_INTERVAL: %u", interval);
665 priv->min_interval = interval;
668 case PROP_MIN_DISTANCE: {
669 gdouble distance = g_value_get_double(value);
670 LOCATION_LOGD("Set prop>> PROP_MIN_DISTANCE: %f", distance);
671 priv->min_distance = distance;
674 case PROP_SERVICE_STATUS: {
675 gint enabled = g_value_get_int(value);
676 LOCATION_LOGD("Set prop>> PROP_SERVICE_STATUS: %d", enabled);
677 priv->enabled = enabled;
681 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
686 static void location_gps_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
688 LocationGpsPrivate *priv = GET_PRIVATE(object);
689 g_return_if_fail(priv);
690 g_return_if_fail(priv->mod);
691 g_return_if_fail(priv->mod->handler);
692 LocModGpsOps ops = priv->mod->ops;
693 switch (property_id) {
694 case PROP_METHOD_TYPE:
695 g_value_set_int(value, LOCATION_METHOD_GPS);
697 case PROP_IS_STARTED:
698 g_value_set_boolean(value, __get_started(object));
700 case PROP_LAST_POSITION:
701 g_value_set_boxed(value, priv->pos);
703 case PROP_POS_INTERVAL:
704 g_value_set_uint(value, priv->pos_interval);
706 case PROP_VEL_INTERVAL:
707 g_value_set_uint(value, priv->vel_interval);
709 case PROP_SAT_INTERVAL:
710 g_value_set_uint(value, priv->sat_interval);
712 case PROP_LOC_INTERVAL:
713 g_value_set_uint(value, priv->loc_interval);
715 case PROP_BATCH_INTERVAL:
716 g_value_set_uint(value, priv->batch_interval);
718 case PROP_BATCH_PERIOD:
719 g_value_set_uint(value, priv->batch_period);
721 case PROP_MIN_INTERVAL:
722 g_value_set_uint(value, priv->min_interval);
724 case PROP_MIN_DISTANCE:
725 g_value_set_double(value, priv->min_distance);
728 g_value_set_pointer(value, g_list_first(priv->boundary_list));
731 char *nmea_data = NULL;
732 if (ops.get_nmea && LOCATION_ERROR_NONE == ops.get_nmea(priv->mod->handler, &nmea_data) && nmea_data) {
733 LOCATION_SECLOG("Get prop>> Lastest nmea: \n%s", nmea_data);
734 g_value_set_string(value, nmea_data);
737 LOCATION_LOGW("Get prop>> Lastest nmea: failed");
738 g_value_set_string(value, NULL);
742 case PROP_SATELLITE: {
743 LocationSatellite *satellite = NULL;
744 if (ops.get_satellite && priv->mod->handler && LOCATION_ERROR_NONE == ops.get_satellite(priv->mod->handler, &satellite) && satellite) {
745 LOCATION_LOGD("Get prop>> Last sat: num_used(%d) num_view(%d)", satellite->num_of_sat_used, satellite->num_of_sat_inview);
746 g_value_set_boxed(value, satellite);
747 location_satellite_free(satellite);
749 LOCATION_LOGW("Get prop>> Last sat: failed");
750 g_value_set_boxed(value, NULL);
754 case PROP_SERVICE_STATUS:
755 g_value_set_int(value, priv->enabled);
758 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
763 static int location_gps_get_position(LocationGps *self, LocationPosition **position, LocationAccuracy **accuracy)
765 int ret = LOCATION_ERROR_NOT_AVAILABLE;
766 LocationGpsPrivate *priv = GET_PRIVATE(self);
767 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
768 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
770 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
771 LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_GPS_STATE);
774 *position = location_position_copy(priv->pos);
775 if (priv->acc) *accuracy = location_accuracy_copy(priv->acc);
776 else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
777 ret = LOCATION_ERROR_NONE;
784 location_gps_get_position_ext(LocationGps *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
786 int ret = LOCATION_ERROR_NOT_AVAILABLE;
787 LocationGpsPrivate *priv = GET_PRIVATE(self);
788 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
789 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
791 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
792 LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_GPS_STATE);
794 if (priv->pos && priv->vel) {
795 *position = location_position_copy(priv->pos);
796 *velocity = location_velocity_copy(priv->vel);
797 if (priv->acc) *accuracy = location_accuracy_copy(priv->acc);
798 else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
799 ret = LOCATION_ERROR_NONE;
806 location_gps_get_last_position(LocationGps *self, LocationPosition **position, LocationAccuracy **accuracy)
808 LocationGpsPrivate *priv = GET_PRIVATE(self);
809 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
810 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
811 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
813 int ret = LOCATION_ERROR_NONE;
814 LocationVelocity *_velocity = NULL;
816 LocModGpsOps ops = priv->mod->ops;
817 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
818 g_return_val_if_fail(ops.get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
819 ret = ops.get_last_position(priv->mod->handler, position, &_velocity, accuracy);
820 if (_velocity) location_velocity_free(_velocity);
826 location_gps_get_last_position_ext(LocationGps *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
828 LocationGpsPrivate *priv = GET_PRIVATE(self);
829 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
830 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
831 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
833 LocModGpsOps ops = priv->mod->ops;
834 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
835 g_return_val_if_fail(ops.get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
836 return ops.get_last_position(priv->mod->handler, position, velocity, accuracy);
841 location_gps_get_velocity(LocationGps *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
843 int ret = LOCATION_ERROR_NOT_AVAILABLE;
845 LocationGpsPrivate *priv = GET_PRIVATE(self);
846 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
847 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
849 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
850 LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_GPS_STATE);
853 *velocity = location_velocity_copy(priv->vel);
854 if (priv->acc) *accuracy = location_accuracy_copy(priv->acc);
855 else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
856 ret = LOCATION_ERROR_NONE;
863 location_gps_get_last_velocity(LocationGps *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
865 LocationGpsPrivate *priv = GET_PRIVATE(self);
866 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
867 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
868 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
870 int ret = LOCATION_ERROR_NONE;
871 LocationPosition *_position = NULL;
873 LocModGpsOps ops = priv->mod->ops;
874 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
875 g_return_val_if_fail(ops.get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
876 ret = ops.get_last_position(priv->mod->handler, &_position, velocity, accuracy);
877 if (_position) location_position_free(_position);
882 static gboolean __single_location_timeout_cb(void *data)
885 LocationGps *self = (LocationGps *)data;
886 LocationGpsPrivate *priv = GET_PRIVATE(self);
887 g_return_val_if_fail(priv, FALSE);
889 LocationPosition *pos = location_position_new(0, 0.0, 0.0, 0.0, LOCATION_STATUS_NO_FIX);
890 LocationVelocity *vel = location_velocity_new(0, 0.0, 0.0, 0.0);
892 if (priv->loc_timeout) g_source_remove(priv->loc_timeout);
893 priv->loc_timeout = 0;
895 g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NOT_AVAILABLE, pos, vel, NULL);
896 location_gps_stop(self);
902 gps_single_location_cb(gboolean enabled, LocationPosition *pos, LocationVelocity *vel, LocationAccuracy *acc, gpointer self)
905 g_return_if_fail(self);
906 g_return_if_fail(pos);
907 g_return_if_fail(vel);
908 g_return_if_fail(acc);
910 LocationGps *obj = (LocationGps *)self;
911 LocationGpsPrivate *priv = GET_PRIVATE(obj);
912 g_return_if_fail(priv);
914 g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NONE, pos, vel, acc);
915 if (priv->loc_timeout) {
916 g_source_remove(priv->loc_timeout);
917 priv->loc_timeout = 0;
919 location_gps_stop(self);
923 location_gps_request_single_location(LocationGps *self, int timeout)
926 LocationGpsPrivate *priv = GET_PRIVATE(self);
927 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
928 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
929 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
930 g_return_val_if_fail(priv->mod->ops.start, LOCATION_ERROR_NOT_AVAILABLE);
932 if (__get_started(self) == TRUE) return LOCATION_ERROR_NONE;
934 int ret = LOCATION_ERROR_NONE;
935 if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
936 ret = LOCATION_ERROR_SETTING_OFF;
938 __set_started(self, TRUE);
939 ret = priv->mod->ops.start(priv->mod->handler, LOCATION_UPDATE_INTERVAL_DEFAULT, gps_status_cb, gps_single_location_cb, NULL, self);
940 if (ret != LOCATION_ERROR_NONE) {
941 LOCATION_LOGE("Fail to start request single. Error[%d]", ret);
942 __set_started(self, FALSE);
945 if (priv->loc_timeout != 0)
946 g_source_remove(priv->loc_timeout);
948 priv->loc_timeout = g_timeout_add_seconds(timeout, __single_location_timeout_cb, self);
956 location_gps_cancel_single_location(LocationGps *self)
959 LocationGpsPrivate* priv = GET_PRIVATE(self);
960 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
961 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
962 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
963 g_return_val_if_fail(priv->mod->ops.stop, LOCATION_ERROR_NOT_AVAILABLE);
965 int ret = LOCATION_ERROR_NONE;
967 if (priv->loc_timeout)
968 g_source_remove(priv->loc_timeout);
969 priv->loc_timeout = 0;
971 if (__get_started(self) == TRUE) {
972 __set_started(self, FALSE);
973 __reset_pos_data_from_priv(priv);
974 ret = priv->mod->ops.stop(priv->mod->handler);
975 LOC_IF_FAIL_LOG(ret, _E, "Failed to stop [%s]", err_msg(ret));
981 static int location_gps_get_nmea(LocationGps *self, char **nmea_data)
983 int ret = LOCATION_ERROR_NOT_AVAILABLE;
985 LocationGpsPrivate *priv = GET_PRIVATE(self);
986 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
987 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
988 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
989 g_return_val_if_fail(priv->mod->ops.get_nmea, LOCATION_ERROR_NOT_AVAILABLE);
990 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
992 ret = priv->mod->ops.get_nmea(priv->mod->handler, nmea_data);
993 LOC_IF_FAIL_LOG(ret, _E, "Failed to get_nmea [%s]", err_msg(ret));
998 static int location_gps_get_batch(LocationGps *self, LocationBatch **batch)
1000 int ret = LOCATION_ERROR_NOT_AVAILABLE;
1002 LocationGpsPrivate *priv = GET_PRIVATE(self);
1003 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
1004 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
1005 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
1007 #ifndef TIZEN_DEVICE
1008 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
1012 *batch = location_batch_copy(priv->batch);
1013 ret = LOCATION_ERROR_NONE;
1015 LOCATION_LOGE("priv->batch is null");
1016 ret = LOCATION_ERROR_NOT_AVAILABLE;
1022 static int location_gps_get_satellite(LocationGps *self, LocationSatellite **satellite)
1024 int ret = LOCATION_ERROR_NOT_AVAILABLE;
1026 LocationGpsPrivate *priv = GET_PRIVATE(self);
1027 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
1028 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
1030 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
1033 *satellite = location_satellite_copy(priv->sat);
1034 ret = LOCATION_ERROR_NONE;
1040 static int location_gps_get_last_satellite(LocationGps *self, LocationSatellite **satellite)
1042 return location_gps_get_satellite(self, satellite);
1045 static int location_gps_set_option(LocationGps *self, const char *option)
1047 LocationGpsPrivate *priv = GET_PRIVATE(self);
1048 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
1049 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
1050 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
1051 g_return_val_if_fail(priv->mod->ops.set_option, LOCATION_ERROR_NOT_AVAILABLE);
1053 int ret = LOCATION_ERROR_NONE;
1054 ret = priv->mod->ops.set_option(priv->mod->handler, option);
1055 LOC_IF_FAIL_LOG(ret, _E, "Failed to set_option [%s]", err_msg(ret));
1061 location_gps_set_mock_location(LocationGps *self, LocationPosition *position, LocationVelocity *velocity, LocationAccuracy *accuracy)
1064 LocationGpsPrivate *priv = GET_PRIVATE(self);
1065 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
1066 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
1067 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
1068 g_return_val_if_fail(priv->mod->ops.set_mock_location, LOCATION_ERROR_NOT_AVAILABLE);
1070 int ret = LOCATION_ERROR_NONE;
1071 if (!location_setting_get_int(VCONFKEY_LOCATION_MOCK_ENABLED)) {
1072 ret = LOCATION_ERROR_SETTING_OFF;
1074 ret = priv->mod->ops.set_mock_location(priv->mod->handler, position, velocity, accuracy, NULL, self);
1075 LOC_IF_FAIL_LOG(ret, _E, "Failed to set_mock_location [%s]", err_msg(ret));
1076 priv->is_mock = TRUE;
1083 location_gps_clear_mock_location(LocationGps *self)
1086 LocationGpsPrivate *priv = GET_PRIVATE(self);
1087 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
1088 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
1089 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
1090 g_return_val_if_fail(priv->mod->ops.clear_mock_location, LOCATION_ERROR_NOT_AVAILABLE);
1092 int ret = LOCATION_ERROR_NONE;
1093 if (!location_setting_get_int(VCONFKEY_LOCATION_MOCK_ENABLED)) {
1094 ret = LOCATION_ERROR_SETTING_OFF;
1096 ret = priv->mod->ops.clear_mock_location(priv->mod->handler, NULL, self);
1097 LOC_IF_FAIL_LOG(ret, _E, "Failed to clear_mock_location [%s]", err_msg(ret));
1098 priv->is_mock = FALSE;
1104 static void location_ielement_interface_init(LocationIElementInterface *iface)
1106 iface->start = (TYPE_START_FUNC)location_gps_start;
1107 iface->stop = (TYPE_STOP_FUNC)location_gps_stop;
1108 iface->get_position = (TYPE_GET_POSITION)location_gps_get_position;
1109 iface->get_position_ext = (TYPE_GET_POSITION_EXT)location_gps_get_position_ext;
1110 iface->get_last_position = (TYPE_GET_POSITION)location_gps_get_last_position;
1111 iface->get_last_position_ext = (TYPE_GET_POSITION_EXT)location_gps_get_last_position_ext;
1112 iface->get_velocity = (TYPE_GET_VELOCITY)location_gps_get_velocity;
1113 iface->get_last_velocity = (TYPE_GET_VELOCITY)location_gps_get_last_velocity;
1114 iface->get_satellite = (TYPE_GET_SATELLITE)location_gps_get_satellite;
1115 iface->get_last_satellite = (TYPE_GET_SATELLITE)location_gps_get_last_satellite;
1116 iface->set_option = (TYPE_SET_OPTION)location_gps_set_option;
1117 iface->get_batch = (TYPE_GET_BATCH)location_gps_get_batch;
1118 iface->start_batch = (TYPE_START_BATCH)location_gps_start_batch;
1119 iface->stop_batch = (TYPE_STOP_BATCH)location_gps_stop_batch;
1120 iface->request_single_location = (TYPE_REQUEST_SINGLE_LOCATION)location_gps_request_single_location;
1121 iface->cancel_single_location = (TYPE_CANCEL_SINGLE_LOCATION)location_gps_cancel_single_location;
1122 iface->get_nmea = (TYPE_GET_NMEA)location_gps_get_nmea;
1123 iface->set_mock_location = (TYPE_SET_MOCK_LOCATION) location_gps_set_mock_location;
1124 iface->clear_mock_location = (TYPE_CLEAR_MOCK_LOCATION) location_gps_clear_mock_location;
1127 static void location_gps_init(LocationGps *self)
1130 LocationGpsPrivate *priv = GET_PRIVATE(self);
1131 g_return_if_fail(priv);
1133 priv->mod = (LocationGpsMod *)module_new("gps");
1134 LOC_COND_LOG(!priv->mod, _E, "Module loading failed");
1136 g_mutex_init(&priv->mutex);
1137 priv->is_started = FALSE;
1138 priv->is_batch_invoked = FALSE;
1139 priv->is_mock = FALSE;
1140 priv->set_noti = FALSE;
1141 priv->enabled = FALSE;
1142 priv->signal_type = 0;
1144 priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1145 priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1146 priv->sat_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1147 priv->loc_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1148 priv->batch_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1149 priv->batch_period = LOCATION_BATCH_PERIOD_DEFAULT;
1150 priv->min_interval = LOCATION_UPDATE_INTERVAL_NONE;
1151 priv->optimized_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1153 priv->pos_updated_timestamp = 0;
1154 priv->vel_updated_timestamp = 0;
1155 priv->sat_updated_timestamp = 0;
1156 priv->loc_updated_timestamp = 0;
1163 priv->boundary_list = NULL;
1164 priv->loc_timeout = 0;
1166 #if defined(TIZEN_DEVICE)
1167 if (_get_tizen_profile() != TIZEN_PROFILE_TV) {
1168 priv->sensor = NULL;
1169 priv->sensor_listener = NULL;
1173 priv->app_type = location_get_app_type(NULL);
1174 LOC_COND_LOG(priv->app_type == 0, _W, "Fail to get app_type");
1177 static void location_gps_class_init(LocationGpsClass *klass)
1180 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
1182 gobject_class->set_property = location_gps_set_property;
1183 gobject_class->get_property = location_gps_get_property;
1185 gobject_class->dispose = location_gps_dispose;
1186 gobject_class->finalize = location_gps_finalize;
1188 g_type_class_add_private(klass, sizeof(LocationGpsPrivate));
1190 signals[SERVICE_ENABLED] =
1191 g_signal_new("service-enabled", G_TYPE_FROM_CLASS(klass),
1192 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1193 G_STRUCT_OFFSET(LocationGpsClass, enabled),
1194 NULL, NULL, location_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
1196 signals[SERVICE_DISABLED] =
1197 g_signal_new("service-disabled", G_TYPE_FROM_CLASS(klass),
1198 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1199 G_STRUCT_OFFSET(LocationGpsClass, disabled),
1200 NULL, NULL, location_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
1202 signals[SERVICE_UPDATED] =
1203 g_signal_new("service-updated", G_TYPE_FROM_CLASS(klass),
1204 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1205 G_STRUCT_OFFSET(LocationGpsClass, service_updated),
1206 NULL, NULL, location_VOID__INT_POINTER_POINTER_POINTER,
1207 G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
1209 signals[LOCATION_UPDATED] =
1210 g_signal_new("location-updated", G_TYPE_FROM_CLASS(klass),
1211 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1212 G_STRUCT_OFFSET(LocationGpsClass, location_updated),
1213 NULL, NULL, location_VOID__INT_POINTER_POINTER_POINTER,
1214 G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
1216 signals[BATCH_UPDATED] =
1217 g_signal_new("batch-updated", G_TYPE_FROM_CLASS(klass),
1218 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1219 G_STRUCT_OFFSET(LocationGpsClass, batch_updated),
1220 NULL, NULL, location_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
1223 g_signal_new("zone-in", G_TYPE_FROM_CLASS(klass),
1224 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1225 G_STRUCT_OFFSET(LocationGpsClass, zone_in),
1226 NULL, NULL, location_VOID__POINTER_POINTER_POINTER,
1227 G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
1230 g_signal_new("zone-out", G_TYPE_FROM_CLASS(klass),
1231 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1232 G_STRUCT_OFFSET(LocationGpsClass, zone_out),
1233 NULL, NULL, location_VOID__POINTER_POINTER_POINTER,
1234 G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
1236 properties[PROP_METHOD_TYPE] =
1237 g_param_spec_int("method", "method type", "location method type name",
1238 LOCATION_METHOD_GPS, LOCATION_METHOD_GPS, LOCATION_METHOD_GPS, G_PARAM_READABLE);
1240 properties[PROP_IS_STARTED] =
1241 g_param_spec_boolean("is_started", "gps is started prop",
1242 "gps is started status", FALSE, G_PARAM_READWRITE);
1244 properties[PROP_LAST_POSITION] =
1245 g_param_spec_boxed("last-position", "gps last position prop",
1246 "gps last position data", LOCATION_TYPE_POSITION, G_PARAM_READABLE);
1248 properties[PROP_POS_INTERVAL] =
1249 g_param_spec_uint("pos-interval", "gps position interval prop",
1250 "gps position interval data", LOCATION_UPDATE_INTERVAL_MIN,
1251 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1253 properties[PROP_VEL_INTERVAL] =
1254 g_param_spec_uint("vel-interval", "gps velocity interval prop",
1255 "gps velocity interval data", LOCATION_UPDATE_INTERVAL_MIN,
1256 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1258 properties[PROP_SAT_INTERVAL] =
1259 g_param_spec_uint("sat-interval", "gps satellite interval prop",
1260 "gps satellite interval data", LOCATION_UPDATE_INTERVAL_MIN,
1261 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1263 properties[PROP_LOC_INTERVAL] =
1264 g_param_spec_uint("loc-interval", "gps location interval prop",
1265 "gps location interval data", LOCATION_UPDATE_INTERVAL_MIN,
1266 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1268 properties[PROP_BATCH_INTERVAL] =
1269 g_param_spec_uint("batch-interval", "gps batch interval interval prop",
1270 "gps batch interval interval data", LOCATION_UPDATE_INTERVAL_MIN,
1271 LOCATION_BATCH_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1273 properties[PROP_BATCH_PERIOD] =
1274 g_param_spec_uint("batch-period", "gps batch period prop",
1275 "gps batch period data", LOCATION_BATCH_PERIOD_MIN,
1276 LOCATION_BATCH_PERIOD_MAX, LOCATION_BATCH_PERIOD_DEFAULT, G_PARAM_READWRITE);
1278 properties[PROP_MIN_INTERVAL] =
1279 g_param_spec_uint("min-interval", "gps distance-based interval prop",
1280 "gps distance-based interval data", LOCATION_MIN_INTERVAL_MIN,
1281 LOCATION_MIN_INTERVAL_MAX, LOCATION_MIN_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1283 properties[PROP_MIN_DISTANCE] =
1284 g_param_spec_double("min-distance", "gps distance-based distance prop",
1285 "gps distance-based distance data", LOCATION_MIN_DISTANCE_MIN,
1286 LOCATION_MIN_DISTANCE_MAX, LOCATION_MIN_DISTANCE_DEFAULT, G_PARAM_READWRITE);
1288 properties[PROP_BOUNDARY] =
1289 g_param_spec_pointer("boundary", "gps boundary prop",
1290 "gps boundary data", G_PARAM_READWRITE);
1292 properties[PROP_REMOVAL_BOUNDARY] =
1293 g_param_spec_boxed("removal-boundary", "gps removal boundary prop",
1294 "gps removal boundary data", LOCATION_TYPE_BOUNDARY, G_PARAM_READWRITE);
1296 properties[PROP_NMEA] =
1297 g_param_spec_string("nmea", "gps NMEA name prop", "gps NMEA",
1298 NULL, G_PARAM_READABLE);
1300 properties[PROP_SATELLITE] =
1301 g_param_spec_boxed("satellite", "gps satellite prop",
1302 "gps satellite data", LOCATION_TYPE_SATELLITE, G_PARAM_READABLE);
1304 properties[PROP_SERVICE_STATUS] =
1305 g_param_spec_int("service-status", "location service status prop",
1306 "location service status data", LOCATION_STATUS_NO_FIX,
1307 LOCATION_STATUS_3D_FIX, LOCATION_STATUS_NO_FIX, G_PARAM_READABLE);
1309 g_object_class_install_properties(gobject_class, PROP_MAX, properties);