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 <app_manager.h>
28 #include "location-setting.h"
29 #include "location-log.h"
31 #include "module-internal.h"
33 #include "location-gps.h"
34 #include "location-marshal.h"
35 #include "location-ielement.h"
36 #include "location-signaling-util.h"
37 #include "location-common-util.h"
38 #include "location-privacy.h"
40 #include <vconf-internal-location-keys.h>
42 typedef struct _LocationGpsPrivate {
46 gboolean is_batch_invoked;
52 guint pos_updated_timestamp;
54 guint vel_updated_timestamp;
56 guint sat_updated_timestamp;
58 guint loc_updated_timestamp;
63 guint dist_updated_timestamp;
66 LocationPosition *pos;
68 LocationVelocity *vel;
69 LocationAccuracy *acc;
70 LocationSatellite *sat;
72 #if defined(TIZEN_DEVICE) && !defined(TIZEN_PROFILE_TV)
74 sensor_listener_h sensor_listener;
90 PROP_REMOVAL_BOUNDARY,
99 static guint32 signals[LAST_SIGNAL] = {0, };
100 static GParamSpec *properties[PROP_MAX] = {NULL, };
102 #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), LOCATION_TYPE_GPS, LocationGpsPrivate))
104 static void location_ielement_interface_init(LocationIElementInterface *iface);
106 G_DEFINE_TYPE_WITH_CODE(LocationGps, location_gps, G_TYPE_OBJECT,
107 G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, location_ielement_interface_init));
109 static void __reset_pos_data_from_priv(LocationGpsPrivate *priv)
112 g_return_if_fail(priv);
115 location_position_free(priv->pos);
120 location_batch_free(priv->batch);
125 location_velocity_free(priv->vel);
130 location_satellite_free(priv->sat);
135 location_accuracy_free(priv->acc);
138 priv->pos_updated_timestamp = 0;
139 priv->vel_updated_timestamp = 0;
140 priv->sat_updated_timestamp = 0;
141 priv->loc_updated_timestamp = 0;
143 priv->signal_type = 0;
146 static gboolean __get_started(gpointer self)
148 g_return_val_if_fail(self, FALSE);
150 LocationGpsPrivate *priv = GET_PRIVATE(self);
151 g_return_val_if_fail(priv, FALSE);
153 return priv->is_started;
156 static int __set_started(gpointer self, gboolean started)
158 g_return_val_if_fail(self, -1);
160 LocationGpsPrivate *priv = GET_PRIVATE(self);
161 g_return_val_if_fail(priv, -1);
163 if (priv->is_started != started) {
164 g_mutex_lock(&priv->mutex);
165 priv->is_started = started;
166 g_mutex_unlock(&priv->mutex);
172 static void gps_status_cb(gboolean enabled, LocationStatus status, gpointer self)
175 g_return_if_fail(self);
176 LocationGpsPrivate *priv = GET_PRIVATE(self);
177 g_return_if_fail(priv);
178 if (!priv->enabled && enabled) { /* Update satellite at searching status. */
179 return; /* Ignored: Support to get position at enabled callback */
180 } else if (priv->enabled == TRUE && enabled == FALSE) {
181 __set_started(self, FALSE);
182 enable_signaling(self, signals, &(priv->enabled), enabled, status);
186 static void gps_location_cb(gboolean enabled, LocationPosition *pos, LocationVelocity *vel, LocationAccuracy *acc, gpointer self)
188 g_return_if_fail(self);
189 g_return_if_fail(pos);
190 g_return_if_fail(vel);
191 g_return_if_fail(acc);
193 LocationGpsPrivate *priv = GET_PRIVATE(self);
194 g_return_if_fail(priv);
196 if (priv->min_interval != LOCATION_UPDATE_INTERVAL_NONE) {
197 distance_based_position_signaling(self, signals, enabled, pos, vel, acc,
198 priv->min_interval, priv->min_distance, &(priv->enabled),
199 &(priv->dist_updated_timestamp), &(priv->pos), &(priv->vel), &(priv->acc));
201 location_signaling(self, signals, enabled, priv->boundary_list, pos, vel, acc,
202 priv->pos_interval, priv->vel_interval, priv->loc_interval, &(priv->enabled),
203 &(priv->pos_updated_timestamp), &(priv->vel_updated_timestamp),
204 &(priv->loc_updated_timestamp), &(priv->pos), &(priv->vel), &(priv->acc));
208 static void gps_batch_cb(gboolean enabled, guint num_of_location, gpointer self)
210 g_return_if_fail(self);
211 LocationGpsPrivate *priv = GET_PRIVATE(self);
212 g_return_if_fail(priv);
214 if (priv->batch != NULL)
215 location_batch_free(priv->batch);
217 priv->batch = location_get_batch_file(num_of_location);
219 g_signal_emit(self, signals[BATCH_UPDATED], 0, num_of_location);
223 static void gps_satellite_cb(gboolean enabled, LocationSatellite *sat, gpointer self)
225 g_return_if_fail(self);
226 LocationGpsPrivate *priv = GET_PRIVATE(self);
227 g_return_if_fail(priv);
229 satellite_signaling(self, signals, &(priv->enabled), priv->sat_interval, TRUE, &(priv->sat_updated_timestamp), &(priv->sat), sat);
232 static void location_setting_search_cb(keynode_t *key, gpointer self)
235 g_return_if_fail(key);
236 g_return_if_fail(self);
237 LocationGpsPrivate *priv = GET_PRIVATE(self);
238 g_return_if_fail(priv);
240 if (location_setting_get_key_val(key) == VCONFKEY_LOCATION_GPS_SEARCHING) {
241 if (!location_setting_get_int(VCONFKEY_LOCATION_MOCK_ENABLED)) {
242 LOCATION_LOGD("enable_signaling : SERVICE_DISABLED");
243 enable_signaling(self, signals, &(priv->enabled), FALSE, LOCATION_STATUS_NO_FIX);
248 static void location_setting_gps_cb(keynode_t *key, gpointer self)
251 g_return_if_fail(key);
252 g_return_if_fail(self);
253 LocationGpsPrivate *priv = GET_PRIVATE(self);
254 g_return_if_fail(priv);
255 g_return_if_fail(priv->mod);
256 g_return_if_fail(priv->mod->handler);
258 int ret = LOCATION_ERROR_NONE;
260 if (0 == location_setting_get_key_val(key) && priv->mod->ops.stop && __get_started(self)) {
261 LOCATION_LOGD("location stopped by setting");
262 __set_started(self, FALSE);
263 ret = priv->mod->ops.stop(priv->mod->handler);
264 if (ret == LOCATION_ERROR_NONE)
265 __reset_pos_data_from_priv(priv);
267 LOCATION_LOGI("Fail to stop[%d]", ret);
269 } else if (1 == location_setting_get_key_val(key) && priv->mod->ops.start && !__get_started(self)) {
270 LOCATION_LOGD("location resumed by setting");
271 __set_started(self, TRUE);
272 ret = priv->mod->ops.start(priv->mod->handler, priv->pos_interval, gps_status_cb, gps_location_cb, gps_satellite_cb, self);
273 if (ret != LOCATION_ERROR_NONE) {
274 __set_started(self, FALSE);
275 LOCATION_LOGI("Fail to start[%d]", ret);
280 static int location_gps_start(LocationGps *self)
283 LocationGpsPrivate *priv = GET_PRIVATE(self);
284 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
285 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
286 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
287 g_return_val_if_fail(priv->mod->ops.start, LOCATION_ERROR_NOT_AVAILABLE);
289 if (__get_started(self) == TRUE) return LOCATION_ERROR_NONE;
291 int ret = LOCATION_ERROR_NONE;
293 if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
294 ret = LOCATION_ERROR_SETTING_OFF;
295 } else if (location_setting_get_int(VCONFKEY_SETAPPL_PSMODE) == SETTING_PSMODE_WEARABLE_ENHANCED) {
296 return LOCATION_ACCESS_DENIED;
298 __set_started(self, TRUE);
299 ret = priv->mod->ops.start(priv->mod->handler, priv->pos_interval, gps_status_cb, gps_location_cb, gps_satellite_cb, self);
300 if (ret != LOCATION_ERROR_NONE) {
301 LOCATION_LOGE("Fail to start gps. Error[%d]", ret);
302 __set_started(self, FALSE);
307 if (priv->app_type != CPPAPP && priv->set_noti == FALSE) {
308 location_setting_add_notify(VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb, self);
310 location_state_add_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb, self);
311 priv->set_noti = TRUE;
314 LOCATION_LOGD("EXIT <<<");
318 static int location_gps_stop(LocationGps *self)
321 LocationGpsPrivate *priv = GET_PRIVATE(self);
322 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
323 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
324 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
325 g_return_val_if_fail(priv->mod->ops.stop, LOCATION_ERROR_NOT_AVAILABLE);
327 int ret = LOCATION_ERROR_NONE;
329 if (__get_started(self) == TRUE) {
330 __set_started(self, FALSE);
331 ret = priv->mod->ops.stop(priv->mod->handler);
332 LOC_IF_FAIL_LOG(ret, _E, "Failed to stop [%s]", err_msg(ret));
334 return LOCATION_ERROR_NONE;
337 if (priv->app_type != CPPAPP && priv->set_noti == TRUE) {
338 location_setting_ignore_notify(VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb);
339 location_state_ignore_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb);
340 priv->set_noti = FALSE;
343 __reset_pos_data_from_priv(priv);
348 #if defined(TIZEN_DEVICE) && !defined(TIZEN_PROFILE_TV)
349 static void __sensor_event_cb(sensor_h s, sensor_event_s *event, void *data)
351 LocationGpsPrivate *priv = GET_PRIVATE(data);
352 g_return_if_fail(priv);
353 g_return_if_fail(event);
355 int remain_idx = (int)(event->values[4]);
357 if (priv->is_batch_invoked) {
358 location_batch_free(priv->batch);
359 priv->is_batch_invoked = FALSE;
363 if (priv->batch == NULL) {
364 g_return_if_fail(event->value_count <= 5);
365 priv->batch = location_batch_new(remain_idx + 1);
366 g_return_if_fail(priv->batch);
367 priv->batch->num_of_location = remain_idx + 1;
370 priv->batch->start_time = start + (time_t)((event->timestamp / 1001000) % 100000);
373 location_set_sensor_batch(priv->batch, event);
375 if (remain_idx == 0) {
376 g_signal_emit(data, signals[BATCH_UPDATED], 0, priv->batch->num_of_location);
377 priv->is_batch_invoked = TRUE;
381 static int __set_sensor_batch(LocationGps *self, int batch_interval)
384 LocationGpsPrivate *priv = GET_PRIVATE(self);
385 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
387 if (priv->batch != NULL) {
388 location_batch_free(priv->batch);
392 int update_interval = batch_interval * 1000; /* in ms */
394 bool supported = false;
396 ret = sensor_is_supported((sensor_type_e)0x1A02, &supported);
397 LOC_IF_FAIL(ret, _E, "Fail to sensor_is_supported [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
398 LOC_COND_RET(!supported, LOCATION_ERROR_NOT_SUPPORTED, _E, "Batch sensor is not supported [%s]", err_msg(LOCATION_ERROR_NOT_SUPPORTED));
400 ret = sensor_get_default_sensor((sensor_type_e)0x1A02, &priv->sensor);
401 LOC_IF_FAIL(ret, _E, "Fail to sensor_get_default_sensor [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
403 ret = sensor_create_listener(priv->sensor, &priv->sensor_listener);
404 LOC_IF_FAIL(ret, _E, "Fail to sensor_create_listener [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
406 ret = sensor_listener_set_event_cb(priv->sensor_listener, update_interval, __sensor_event_cb, self);
407 if (ret != SENSOR_ERROR_NONE) {
408 LOCATION_LOGE("sensor_listener_set_event_cb() failed");
409 sensor_destroy_listener(priv->sensor_listener);
410 return LOCATION_ERROR_NOT_AVAILABLE;
413 ret = sensor_listener_set_option(priv->sensor_listener, SENSOR_OPTION_ALWAYS_ON);
414 if (ret != SENSOR_ERROR_NONE) {
415 LOCATION_LOGE("sensor_listener_set_option() failed");
416 sensor_destroy_listener(priv->sensor_listener);
417 return LOCATION_ERROR_NOT_AVAILABLE;
419 ret = sensor_listener_start(priv->sensor_listener);
420 if (ret != SENSOR_ERROR_NONE) {
421 LOCATION_LOGE("sensor_listener_set_event_cb() failed");
422 sensor_destroy_listener(priv->sensor_listener);
423 return LOCATION_ERROR_NOT_AVAILABLE;
426 return LOCATION_ERROR_NONE;
430 static int location_gps_start_batch(LocationGps *self)
433 LocationGpsPrivate *priv = GET_PRIVATE(self);
434 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
435 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
436 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
437 g_return_val_if_fail(priv->mod->ops.start_batch, LOCATION_ERROR_NOT_AVAILABLE);
439 if (__get_started(self) == TRUE) return LOCATION_ERROR_NONE;
441 int ret = LOCATION_ERROR_NONE;
443 if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
444 ret = LOCATION_ERROR_SETTING_OFF;
447 __set_started(self, TRUE);
448 ret = priv->mod->ops.start_batch(priv->mod->handler, gps_batch_cb, priv->batch_interval, priv->batch_period, self);
449 if (ret != LOCATION_ERROR_NONE) {
450 LOCATION_LOGE("Fail to start_batch [%s]", err_msg(ret));
451 __set_started(self, FALSE);
456 #if defined(TIZEN_DEVICE) && !defined(TIZEN_PROFILE_TV)
457 return __set_sensor_batch(self, priv->batch_interval);
464 static int location_gps_stop_batch(LocationGps *self)
467 LocationGpsPrivate *priv = GET_PRIVATE(self);
468 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
469 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
470 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
471 g_return_val_if_fail(priv->mod->ops.stop_batch, LOCATION_ERROR_NOT_AVAILABLE);
473 int ret = LOCATION_ERROR_NONE;
475 #if defined(TIZEN_DEVICE) && !defined(TIZEN_PROFILE_TV)
476 ret = sensor_listener_stop(priv->sensor_listener);
477 LOC_IF_FAIL(ret, _E, "Fail to listener_stop [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
479 ret = sensor_listener_unset_event_cb(priv->sensor_listener);
480 LOC_IF_FAIL_LOG(ret, _E, "Fail to listener_unset_event_cb [%s]", err_msg(ret));
482 ret = sensor_destroy_listener(priv->sensor_listener);
483 LOC_IF_FAIL_LOG(ret, _E, "Fail to destroy_listener [%s]", err_msg(ret));
485 if (__get_started(self) == TRUE) {
486 __set_started(self, FALSE);
487 ret = priv->mod->ops.stop_batch(priv->mod->handler);
488 LOC_IF_FAIL_LOG(ret, _E, "Failed to stop_batch [%s]", err_msg(ret));
490 return LOCATION_ERROR_NONE;
494 __reset_pos_data_from_priv(priv);
499 static void location_gps_dispose(GObject *gobject)
502 LocationGpsPrivate *priv = GET_PRIVATE(gobject);
503 g_return_if_fail(priv);
504 g_mutex_clear(&priv->mutex);
506 if (priv->loc_timeout) g_source_remove(priv->loc_timeout);
507 priv->loc_timeout = 0;
510 priv->mod->ops.clear_mock_location(priv->mod->handler, NULL, gobject);
511 priv->is_mock = FALSE;
514 if (priv->app_type != CPPAPP && priv->set_noti == TRUE) {
515 location_setting_ignore_notify(VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb);
516 location_state_ignore_notify(VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb);
517 priv->set_noti = FALSE;
520 G_OBJECT_CLASS(location_gps_parent_class)->dispose(gobject);
523 static void location_gps_finalize(GObject *gobject)
526 LocationGpsPrivate *priv = GET_PRIVATE(gobject);
527 g_return_if_fail(priv);
529 module_free(priv->mod, "gps");
532 if (priv->boundary_list) {
533 g_list_free_full(priv->boundary_list, free_boundary_list);
534 priv->boundary_list = NULL;
538 location_position_free(priv->pos);
543 location_batch_free(priv->batch);
548 location_velocity_free(priv->vel);
553 location_accuracy_free(priv->acc);
558 location_satellite_free(priv->sat);
561 G_OBJECT_CLASS(location_gps_parent_class)->finalize(gobject);
564 static void location_gps_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
566 LocationGpsPrivate *priv = GET_PRIVATE(object);
567 g_return_if_fail(priv);
568 g_return_if_fail(priv->mod);
569 g_return_if_fail(priv->mod->handler);
572 switch (property_id) {
573 case PROP_BOUNDARY: {
574 GList *boundary_list = g_list_copy(g_value_get_pointer(value));
575 ret = set_prop_boundary(&priv->boundary_list, boundary_list);
576 LOC_IF_FAIL_LOG(ret, _E, "Set boundary. Error[%s]", err_msg(ret));
577 if (boundary_list) g_list_free(boundary_list);
580 case PROP_REMOVAL_BOUNDARY: {
581 LocationBoundary *req_boundary = (LocationBoundary *) g_value_dup_boxed(value);
582 ret = set_prop_removal_boundary(&priv->boundary_list, req_boundary);
583 LOC_IF_FAIL_LOG(ret, _E, "Removal boundary. Error[%s]", err_msg(ret));
586 case PROP_POS_INTERVAL: {
587 guint interval = g_value_get_uint(value);
588 LOCATION_LOGD("Set prop>> PROP_POS_INTERVAL: %u", interval);
589 /* We don't need to set interval when new one is same as the previous one */
590 if (interval == priv->pos_interval) break;
593 if (interval < LOCATION_UPDATE_INTERVAL_MAX)
594 priv->pos_interval = interval;
596 priv->pos_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
598 priv->pos_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
601 if (__get_started(object) == TRUE) {
602 LOCATION_LOGD("[update_pos_interval]: update pos-interval while pos-tracking");
603 g_return_if_fail(priv->mod->ops.set_position_update_interval);
604 priv->mod->ops.set_position_update_interval(priv->mod->handler, priv->pos_interval);
608 case PROP_VEL_INTERVAL: {
609 guint interval = g_value_get_uint(value);
610 LOCATION_LOGD("Set prop>> PROP_VEL_INTERVAL: %u", interval);
611 if (interval == priv->vel_interval) break;
614 if (interval < LOCATION_UPDATE_INTERVAL_MAX)
615 priv->vel_interval = interval;
617 priv->vel_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
619 priv->vel_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
623 case PROP_SAT_INTERVAL: {
624 guint interval = g_value_get_uint(value);
625 LOCATION_LOGD("Set prop>> PROP_SAT_INTERVAL: %u", interval);
627 if (interval < LOCATION_UPDATE_INTERVAL_MAX)
628 priv->sat_interval = interval;
630 priv->sat_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
632 priv->sat_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
636 case PROP_LOC_INTERVAL: {
637 guint interval = g_value_get_uint(value);
638 LOCATION_LOGD("Set prop>> PROP_LOC_INTERVAL: %u", interval);
640 if (interval < LOCATION_UPDATE_INTERVAL_MAX)
641 priv->loc_interval = interval;
643 priv->loc_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
645 priv->loc_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
649 case PROP_BATCH_INTERVAL: {
650 guint interval = g_value_get_uint(value);
651 LOCATION_LOGD("Set prop>> PROP_BATCH_INTERVAL: %u", interval);
653 if (interval < LOCATION_BATCH_INTERVAL_MAX)
654 priv->batch_interval = interval;
656 priv->batch_interval = (guint)LOCATION_BATCH_INTERVAL_MAX;
658 priv->batch_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
661 if (__get_started(object) == TRUE) {
662 LOCATION_LOGD("[update_batch_interval]: update batch-interval while pos-tracking");
663 g_return_if_fail(priv->mod->ops.set_position_update_interval);
664 priv->mod->ops.set_position_update_interval(priv->mod->handler, priv->batch_interval);
668 case PROP_BATCH_PERIOD: {
669 guint interval = g_value_get_uint(value);
670 LOCATION_LOGD("Set prop>> PROP_BATCH_PERIOD: %u", interval);
672 if (interval < LOCATION_BATCH_PERIOD_MAX)
673 priv->batch_period = interval;
675 priv->batch_period = (guint)LOCATION_BATCH_PERIOD_MAX;
677 priv->batch_period = (guint)LOCATION_BATCH_PERIOD_DEFAULT;
681 case PROP_MIN_INTERVAL: {
682 guint interval = g_value_get_uint(value);
683 LOCATION_LOGD("Set prop>> PROP_MIN_INTERVAL: %u", interval);
685 if (interval < LOCATION_MIN_INTERVAL_MAX)
686 priv->min_interval = interval;
688 priv->min_interval = (guint)LOCATION_MIN_INTERVAL_MAX;
690 priv->min_interval = (guint)LOCATION_MIN_INTERVAL_DEFAULT;
694 case PROP_MIN_DISTANCE: {
695 gdouble distance = g_value_get_double(value);
696 LOCATION_LOGD("Set prop>> PROP_MIN_DISTANCE: %u", distance);
698 if (distance < LOCATION_MIN_DISTANCE_MAX)
699 priv->min_distance = distance;
701 priv->min_distance = (gdouble)LOCATION_MIN_DISTANCE_MAX;
703 priv->min_distance = (gdouble)LOCATION_MIN_DISTANCE_DEFAULT;
708 case PROP_SERVICE_STATUS: {
709 gint enabled = g_value_get_int(value);
710 LOCATION_LOGD("Set prop>> PROP_SERVICE_STATUS: %u", enabled);
711 priv->enabled = enabled;
715 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
720 static void location_gps_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
722 LocationGpsPrivate *priv = GET_PRIVATE(object);
723 g_return_if_fail(priv);
724 g_return_if_fail(priv->mod);
725 g_return_if_fail(priv->mod->handler);
726 LocModGpsOps ops = priv->mod->ops;
727 switch (property_id) {
728 case PROP_METHOD_TYPE:
729 g_value_set_int(value, LOCATION_METHOD_GPS);
731 case PROP_IS_STARTED:
732 g_value_set_boolean(value, __get_started(object));
734 case PROP_LAST_POSITION:
735 g_value_set_boxed(value, priv->pos);
737 case PROP_POS_INTERVAL:
738 g_value_set_uint(value, priv->pos_interval);
740 case PROP_VEL_INTERVAL:
741 g_value_set_uint(value, priv->vel_interval);
743 case PROP_SAT_INTERVAL:
744 g_value_set_uint(value, priv->sat_interval);
746 case PROP_LOC_INTERVAL:
747 g_value_set_uint(value, priv->loc_interval);
749 case PROP_BATCH_INTERVAL:
750 g_value_set_uint(value, priv->batch_interval);
752 case PROP_BATCH_PERIOD:
753 g_value_set_uint(value, priv->batch_period);
755 case PROP_MIN_INTERVAL:
756 g_value_set_uint(value, priv->min_interval);
758 case PROP_MIN_DISTANCE:
759 g_value_set_double(value, priv->min_distance);
762 g_value_set_pointer(value, g_list_first(priv->boundary_list));
765 char *nmea_data = NULL;
766 if (ops.get_nmea && LOCATION_ERROR_NONE == ops.get_nmea(priv->mod->handler, &nmea_data) && nmea_data) {
767 LOCATION_SECLOG("Get prop>> Lastest nmea: \n%s", nmea_data);
768 g_value_set_string(value, nmea_data);
771 LOCATION_LOGW("Get prop>> Lastest nmea: failed");
772 g_value_set_string(value, NULL);
776 case PROP_SATELLITE: {
777 LocationSatellite *satellite = NULL;
778 if (ops.get_satellite && priv->mod->handler && LOCATION_ERROR_NONE == ops.get_satellite(priv->mod->handler, &satellite) && satellite) {
779 LOCATION_LOGD("Get prop>> Last sat: num_used(%d) num_view(%d)", satellite->num_of_sat_used, satellite->num_of_sat_inview);
780 g_value_set_boxed(value, satellite);
781 location_satellite_free(satellite);
783 LOCATION_LOGW("Get prop>> Last sat: failed");
784 g_value_set_boxed(value, NULL);
788 case PROP_SERVICE_STATUS:
789 g_value_set_int(value, priv->enabled);
792 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
797 static int location_gps_get_position(LocationGps *self, LocationPosition **position, LocationAccuracy **accuracy)
799 int ret = LOCATION_ERROR_NOT_AVAILABLE;
800 LocationGpsPrivate *priv = GET_PRIVATE(self);
801 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
802 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
804 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
805 LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_GPS_STATE);
808 *position = location_position_copy(priv->pos);
809 if (priv->acc) *accuracy = location_accuracy_copy(priv->acc);
810 else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
811 ret = LOCATION_ERROR_NONE;
818 location_gps_get_position_ext(LocationGps *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
820 int ret = LOCATION_ERROR_NOT_AVAILABLE;
821 LocationGpsPrivate *priv = GET_PRIVATE(self);
822 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
823 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
825 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
826 LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_GPS_STATE);
828 if (priv->pos && priv->vel) {
829 *position = location_position_copy(priv->pos);
830 *velocity = location_velocity_copy(priv->vel);
831 if (priv->acc) *accuracy = location_accuracy_copy(priv->acc);
832 else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
833 ret = LOCATION_ERROR_NONE;
840 location_gps_get_last_position(LocationGps *self, LocationPosition **position, LocationAccuracy **accuracy)
842 LocationGpsPrivate *priv = GET_PRIVATE(self);
843 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
844 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
845 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
847 int ret = LOCATION_ERROR_NONE;
848 LocationVelocity *_velocity = NULL;
850 LocModGpsOps ops = priv->mod->ops;
851 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
852 g_return_val_if_fail(ops.get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
853 ret = ops.get_last_position(priv->mod->handler, position, &_velocity, accuracy);
854 if (_velocity) location_velocity_free(_velocity);
860 location_gps_get_last_position_ext(LocationGps *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
862 LocationGpsPrivate *priv = GET_PRIVATE(self);
863 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
864 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
865 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
867 LocModGpsOps ops = priv->mod->ops;
868 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
869 g_return_val_if_fail(ops.get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
870 return ops.get_last_position(priv->mod->handler, position, velocity, accuracy);
875 location_gps_get_velocity(LocationGps *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
877 int ret = LOCATION_ERROR_NOT_AVAILABLE;
879 LocationGpsPrivate *priv = GET_PRIVATE(self);
880 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
881 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
883 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
884 LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_GPS_STATE);
887 *velocity = location_velocity_copy(priv->vel);
888 if (priv->acc) *accuracy = location_accuracy_copy(priv->acc);
889 else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
890 ret = LOCATION_ERROR_NONE;
897 location_gps_get_last_velocity(LocationGps *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
899 LocationGpsPrivate *priv = GET_PRIVATE(self);
900 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
901 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
902 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
904 int ret = LOCATION_ERROR_NONE;
905 LocationPosition *_position = NULL;
907 LocModGpsOps ops = priv->mod->ops;
908 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
909 g_return_val_if_fail(ops.get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
910 ret = ops.get_last_position(priv->mod->handler, &_position, velocity, accuracy);
911 if (_position) location_position_free(_position);
916 static gboolean __single_location_timeout_cb(void *data)
919 LocationGps *self = (LocationGps *)data;
920 LocationGpsPrivate *priv = GET_PRIVATE(self);
921 g_return_val_if_fail(priv, FALSE);
923 LocationPosition *pos = location_position_new(0, 0.0, 0.0, 0.0, LOCATION_STATUS_NO_FIX);
924 LocationVelocity *vel = location_velocity_new(0, 0.0, 0.0, 0.0);
925 LocationAccuracy *acc = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
927 if (priv->loc_timeout) g_source_remove(priv->loc_timeout);
928 priv->loc_timeout = 0;
930 g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NOT_AVAILABLE, pos, vel, acc);
931 location_gps_stop(self);
937 gps_single_location_cb(gboolean enabled, LocationPosition *pos, LocationVelocity *vel, LocationAccuracy *acc, gpointer self)
940 g_return_if_fail(self);
941 g_return_if_fail(pos);
942 g_return_if_fail(vel);
943 g_return_if_fail(acc);
945 LocationGps *obj = (LocationGps *)self;
946 LocationGpsPrivate *priv = GET_PRIVATE(obj);
947 g_return_if_fail(priv);
949 g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NONE, pos, vel, acc);
950 if (priv->loc_timeout) {
951 g_source_remove(priv->loc_timeout);
952 priv->loc_timeout = 0;
954 location_gps_stop(self);
958 location_gps_request_single_location(LocationGps *self, int timeout)
961 LocationGpsPrivate *priv = GET_PRIVATE(self);
962 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
963 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
964 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
965 g_return_val_if_fail(priv->mod->ops.start, LOCATION_ERROR_NOT_AVAILABLE);
967 if (__get_started(self) == TRUE) return LOCATION_ERROR_NONE;
969 int ret = LOCATION_ERROR_NONE;
971 __set_started(self, TRUE);
972 ret = priv->mod->ops.start(priv->mod->handler, priv->pos_interval, gps_status_cb, gps_single_location_cb, NULL, self);
973 if (ret != LOCATION_ERROR_NONE) {
974 LOCATION_LOGE("Fail to start request single. Error[%d]", ret);
975 __set_started(self, FALSE);
978 if (priv->loc_timeout != 0)
979 g_source_remove(priv->loc_timeout);
981 priv->loc_timeout = g_timeout_add_seconds(timeout, __single_location_timeout_cb, self);
987 static int location_gps_get_nmea(LocationGps *self, char **nmea_data)
989 int ret = LOCATION_ERROR_NOT_AVAILABLE;
991 LocationGpsPrivate *priv = GET_PRIVATE(self);
992 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
993 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
994 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
995 g_return_val_if_fail(priv->mod->ops.get_nmea, LOCATION_ERROR_NOT_AVAILABLE);
996 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
998 ret = priv->mod->ops.get_nmea(priv->mod->handler, nmea_data);
999 LOC_IF_FAIL_LOG(ret, _E, "Failed to get_nmea [%s]", err_msg(ret));
1004 static int location_gps_get_batch(LocationGps *self, LocationBatch **batch)
1006 int ret = LOCATION_ERROR_NOT_AVAILABLE;
1008 LocationGpsPrivate *priv = GET_PRIVATE(self);
1009 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
1010 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
1011 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
1013 #ifndef TIZEN_DEVICE
1014 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
1018 *batch = location_batch_copy(priv->batch);
1019 ret = LOCATION_ERROR_NONE;
1021 LOCATION_LOGE("priv->batch is null");
1022 ret = LOCATION_ERROR_NOT_AVAILABLE;
1028 static int location_gps_get_satellite(LocationGps *self, LocationSatellite **satellite)
1030 int ret = LOCATION_ERROR_NOT_AVAILABLE;
1032 LocationGpsPrivate *priv = GET_PRIVATE(self);
1033 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
1034 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
1036 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
1039 *satellite = location_satellite_copy(priv->sat);
1040 ret = LOCATION_ERROR_NONE;
1046 static int location_gps_get_last_satellite(LocationGps *self, LocationSatellite **satellite)
1048 return location_gps_get_satellite(self, satellite);
1051 static int location_gps_set_option(LocationGps *self, const char *option)
1053 LocationGpsPrivate *priv = GET_PRIVATE(self);
1054 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
1055 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
1056 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
1057 g_return_val_if_fail(priv->mod->ops.set_option, LOCATION_ERROR_NOT_AVAILABLE);
1059 int ret = LOCATION_ERROR_NONE;
1060 ret = priv->mod->ops.set_option(priv->mod->handler, option);
1061 LOC_IF_FAIL_LOG(ret, _E, "Failed to set_option [%s]", err_msg(ret));
1067 location_gps_set_mock_location(LocationGps *self, LocationPosition *position, LocationVelocity *velocity, LocationAccuracy *accuracy)
1070 LocationGpsPrivate *priv = GET_PRIVATE(self);
1071 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
1072 g_return_val_if_fail(priv->mod->ops.set_mock_location, LOCATION_ERROR_NOT_AVAILABLE);
1074 int ret = LOCATION_ERROR_NONE;
1075 if (!location_setting_get_int(VCONFKEY_LOCATION_MOCK_ENABLED)) {
1076 ret = LOCATION_ERROR_SETTING_OFF;
1078 ret = priv->mod->ops.set_mock_location(priv->mod->handler, position, velocity, accuracy, NULL, self);
1079 LOC_IF_FAIL_LOG(ret, _E, "Failed to set_mock_location [%s]", err_msg(ret));
1080 priv->is_mock = TRUE;
1087 location_gps_clear_mock_location(LocationGps *self)
1090 LocationGpsPrivate *priv = GET_PRIVATE(self);
1091 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
1092 g_return_val_if_fail(priv->mod->ops.clear_mock_location, LOCATION_ERROR_NOT_AVAILABLE);
1094 int ret = LOCATION_ERROR_NONE;
1095 if (!location_setting_get_int(VCONFKEY_LOCATION_MOCK_ENABLED)) {
1096 ret = LOCATION_ERROR_SETTING_OFF;
1098 ret = priv->mod->ops.clear_mock_location(priv->mod->handler, NULL, self);
1099 LOC_IF_FAIL_LOG(ret, _E, "Failed to clear_mock_location [%s]", err_msg(ret));
1100 priv->is_mock = FALSE;
1106 static void location_ielement_interface_init(LocationIElementInterface *iface)
1108 iface->start = (TYPE_START_FUNC)location_gps_start;
1109 iface->stop = (TYPE_STOP_FUNC)location_gps_stop;
1110 iface->get_position = (TYPE_GET_POSITION)location_gps_get_position;
1111 iface->get_position_ext = (TYPE_GET_POSITION_EXT)location_gps_get_position_ext;
1112 iface->get_last_position = (TYPE_GET_POSITION)location_gps_get_last_position;
1113 iface->get_last_position_ext = (TYPE_GET_POSITION_EXT)location_gps_get_last_position_ext;
1114 iface->get_velocity = (TYPE_GET_VELOCITY)location_gps_get_velocity;
1115 iface->get_last_velocity = (TYPE_GET_VELOCITY)location_gps_get_last_velocity;
1116 iface->get_satellite = (TYPE_GET_SATELLITE)location_gps_get_satellite;
1117 iface->get_last_satellite = (TYPE_GET_SATELLITE)location_gps_get_last_satellite;
1118 iface->set_option = (TYPE_SET_OPTION)location_gps_set_option;
1119 iface->get_batch = (TYPE_GET_BATCH)location_gps_get_batch;
1120 iface->start_batch = (TYPE_START_BATCH)location_gps_start_batch;
1121 iface->stop_batch = (TYPE_STOP_BATCH)location_gps_stop_batch;
1122 iface->request_single_location = (TYPE_REQUEST_SINGLE_LOCATION)location_gps_request_single_location;
1123 iface->get_nmea = (TYPE_GET_NMEA)location_gps_get_nmea;
1124 iface->set_mock_location = (TYPE_SET_MOCK_LOCATION) location_gps_set_mock_location;
1125 iface->clear_mock_location = (TYPE_CLEAR_MOCK_LOCATION) location_gps_clear_mock_location;
1128 static void location_gps_init(LocationGps *self)
1131 LocationGpsPrivate *priv = GET_PRIVATE(self);
1132 g_return_if_fail(priv);
1134 priv->mod = (LocationGpsMod *)module_new("gps");
1135 LOC_COND_LOG(!priv->mod, _E, "Module loading failed");
1137 g_mutex_init(&priv->mutex);
1138 priv->is_started = FALSE;
1139 priv->is_batch_invoked = FALSE;
1140 priv->is_mock = FALSE;
1141 priv->set_noti = FALSE;
1142 priv->enabled = FALSE;
1143 priv->signal_type = 0;
1145 priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1146 priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1147 priv->sat_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1148 priv->loc_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1149 priv->batch_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
1150 priv->batch_period = LOCATION_BATCH_PERIOD_DEFAULT;
1151 priv->min_interval = LOCATION_UPDATE_INTERVAL_NONE;
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) && !defined(TIZEN_PROFILE_TV)
1167 priv->sensor = NULL;
1168 priv->sensor_listener = NULL;
1171 priv->app_type = location_get_app_type(NULL);
1172 LOC_COND_LOG(priv->app_type == 0, _W, "Fail to get app_type");
1175 static void location_gps_class_init(LocationGpsClass *klass)
1178 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
1180 gobject_class->set_property = location_gps_set_property;
1181 gobject_class->get_property = location_gps_get_property;
1183 gobject_class->dispose = location_gps_dispose;
1184 gobject_class->finalize = location_gps_finalize;
1186 g_type_class_add_private(klass, sizeof(LocationGpsPrivate));
1188 signals[SERVICE_ENABLED] =
1189 g_signal_new("service-enabled", G_TYPE_FROM_CLASS(klass),
1190 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1191 G_STRUCT_OFFSET(LocationGpsClass, enabled),
1192 NULL, NULL, location_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
1194 signals[SERVICE_DISABLED] =
1195 g_signal_new("service-disabled", G_TYPE_FROM_CLASS(klass),
1196 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1197 G_STRUCT_OFFSET(LocationGpsClass, disabled),
1198 NULL, NULL, location_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
1200 #if 0 /* TODO: STATUS_CHANGED will aggregate SERVICE_ENABLED and SERVICE_DISABLED */
1201 signals[STATUS_CHANGED] =
1202 g_signal_new("status-changed", G_TYPE_FROM_CLASS(klass),
1203 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1204 G_STRUCT_OFFSET(LocationGpsClass, status_changed),
1205 NULL, NULL, location_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
1208 signals[SERVICE_UPDATED] =
1209 g_signal_new("service-updated", G_TYPE_FROM_CLASS(klass),
1210 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1211 G_STRUCT_OFFSET(LocationGpsClass, service_updated),
1212 NULL, NULL, location_VOID__INT_POINTER_POINTER_POINTER,
1213 G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
1215 signals[LOCATION_UPDATED] =
1216 g_signal_new("location-updated", G_TYPE_FROM_CLASS(klass),
1217 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1218 G_STRUCT_OFFSET(LocationGpsClass, location_updated),
1219 NULL, NULL, location_VOID__INT_POINTER_POINTER_POINTER,
1220 G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
1222 signals[BATCH_UPDATED] =
1223 g_signal_new("batch-updated", G_TYPE_FROM_CLASS(klass),
1224 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1225 G_STRUCT_OFFSET(LocationGpsClass, batch_updated),
1226 NULL, NULL, location_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
1229 g_signal_new("zone-in", G_TYPE_FROM_CLASS(klass),
1230 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1231 G_STRUCT_OFFSET(LocationGpsClass, zone_in),
1232 NULL, NULL, location_VOID__POINTER_POINTER_POINTER,
1233 G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
1236 g_signal_new("zone-out", G_TYPE_FROM_CLASS(klass),
1237 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
1238 G_STRUCT_OFFSET(LocationGpsClass, zone_out),
1239 NULL, NULL, location_VOID__POINTER_POINTER_POINTER,
1240 G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
1242 properties[PROP_METHOD_TYPE] =
1243 g_param_spec_int("method", "method type", "location method type name",
1244 LOCATION_METHOD_GPS, LOCATION_METHOD_GPS, LOCATION_METHOD_GPS, G_PARAM_READABLE);
1246 properties[PROP_IS_STARTED] =
1247 g_param_spec_boolean("is_started", "gps is started prop",
1248 "gps is started status", FALSE, G_PARAM_READWRITE);
1250 properties[PROP_LAST_POSITION] =
1251 g_param_spec_boxed("last-position", "gps last position prop",
1252 "gps last position data", LOCATION_TYPE_POSITION, G_PARAM_READABLE);
1254 properties[PROP_POS_INTERVAL] =
1255 g_param_spec_uint("pos-interval", "gps position interval prop",
1256 "gps position interval data", LOCATION_UPDATE_INTERVAL_MIN,
1257 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1259 properties[PROP_VEL_INTERVAL] =
1260 g_param_spec_uint("vel-interval", "gps velocity interval prop",
1261 "gps velocity interval data", LOCATION_UPDATE_INTERVAL_MIN,
1262 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1264 properties[PROP_SAT_INTERVAL] =
1265 g_param_spec_uint("sat-interval", "gps satellite interval prop",
1266 "gps satellite interval data", LOCATION_UPDATE_INTERVAL_MIN,
1267 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1269 properties[PROP_LOC_INTERVAL] =
1270 g_param_spec_uint("loc-interval", "gps location interval prop",
1271 "gps location interval data", LOCATION_UPDATE_INTERVAL_MIN,
1272 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1274 properties[PROP_BATCH_INTERVAL] =
1275 g_param_spec_uint("batch-interval", "gps batch interval interval prop",
1276 "gps batch interval interval data", LOCATION_UPDATE_INTERVAL_MIN,
1277 LOCATION_BATCH_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1279 properties[PROP_BATCH_PERIOD] =
1280 g_param_spec_uint("batch-period", "gps batch period prop",
1281 "gps batch period data", LOCATION_BATCH_PERIOD_MIN,
1282 LOCATION_BATCH_PERIOD_MAX, LOCATION_BATCH_PERIOD_DEFAULT, G_PARAM_READWRITE);
1284 properties[PROP_MIN_INTERVAL] =
1285 g_param_spec_uint("min-interval", "gps distance-based interval prop",
1286 "gps distance-based interval data", LOCATION_MIN_INTERVAL_MIN,
1287 LOCATION_MIN_INTERVAL_MAX, LOCATION_MIN_INTERVAL_DEFAULT, G_PARAM_READWRITE);
1289 properties[PROP_MIN_DISTANCE] =
1290 g_param_spec_double("min-distance", "gps distance-based distance prop",
1291 "gps distance-based distance data", LOCATION_MIN_DISTANCE_MIN,
1292 LOCATION_MIN_DISTANCE_MAX, LOCATION_MIN_DISTANCE_DEFAULT, G_PARAM_READWRITE);
1294 properties[PROP_BOUNDARY] =
1295 g_param_spec_pointer("boundary", "gps boundary prop",
1296 "gps boundary data", G_PARAM_READWRITE);
1298 properties[PROP_REMOVAL_BOUNDARY] =
1299 g_param_spec_boxed("removal-boundary", "gps removal boundary prop",
1300 "gps removal boundary data", LOCATION_TYPE_BOUNDARY, G_PARAM_READWRITE);
1302 properties[PROP_NMEA] =
1303 g_param_spec_string("nmea", "gps NMEA name prop", "gps NMEA",
1304 NULL, G_PARAM_READABLE);
1306 properties[PROP_SATELLITE] =
1307 g_param_spec_boxed("satellite", "gps satellite prop",
1308 "gps satellite data", LOCATION_TYPE_SATELLITE, G_PARAM_READABLE);
1310 properties[PROP_SERVICE_STATUS] =
1311 g_param_spec_int("service-status", "location service status prop",
1312 "location service status data", LOCATION_STATUS_NO_FIX,
1313 LOCATION_STATUS_3D_FIX, LOCATION_STATUS_NO_FIX, G_PARAM_READABLE);
1315 g_object_class_install_properties(gobject_class, PROP_MAX, properties);