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-setting.h"
24 #include "location-log.h"
26 #include "module-internal.h"
28 #include "location-passive.h"
29 #include "location-marshal.h"
30 #include "location-ielement.h"
31 #include "location-signaling-util.h"
32 #include "location-common-util.h"
34 #include <vconf-internal-location-keys.h>
36 typedef struct _LocationPassivePrivate {
37 LocationPassiveMod *mod;
43 guint pos_updated_timestamp;
44 guint vel_updated_timestamp;
45 guint sat_updated_timestamp;
46 guint loc_updated_timestamp;
47 guint dist_updated_timestamp;
55 LocationPosition *pos;
56 LocationVelocity *vel;
57 LocationAccuracy *acc;
58 LocationSatellite *sat;
60 } LocationPassivePrivate;
72 PROP_REMOVAL_BOUNDARY,
80 static guint32 signals[LAST_SIGNAL] = {0, };
81 static GParamSpec *properties[PROP_MAX] = {NULL, };
83 #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), LOCATION_TYPE_PASSIVE, LocationPassivePrivate))
85 static void location_ielement_interface_init(LocationIElementInterface *iface);
87 G_DEFINE_TYPE_WITH_CODE(LocationPassive, location_passive, G_TYPE_OBJECT,
88 G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, location_ielement_interface_init));
90 static void __reset_pos_data_from_priv(LocationPassivePrivate *priv)
93 g_return_if_fail(priv);
96 location_position_free(priv->pos);
100 location_velocity_free(priv->vel);
104 location_satellite_free(priv->sat);
108 location_accuracy_free(priv->acc);
111 priv->pos_updated_timestamp = 0;
112 priv->vel_updated_timestamp = 0;
113 priv->sat_updated_timestamp = 0;
114 priv->loc_updated_timestamp = 0;
117 static gboolean __get_started(gpointer self)
119 LocationPassivePrivate *priv = GET_PRIVATE(self);
120 g_return_val_if_fail(priv, FALSE);
122 return priv->is_started;
125 static int __set_started(gpointer self, gboolean started)
127 LocationPassivePrivate *priv = GET_PRIVATE(self);
128 g_return_val_if_fail(priv, -1);
130 if (priv->is_started != started) {
131 g_mutex_lock(&priv->mutex);
132 priv->is_started = started;
133 g_mutex_unlock(&priv->mutex);
139 static void passive_location_cb(gboolean enabled, LocationPosition *pos, LocationVelocity *vel, LocationAccuracy *acc, gpointer self)
141 g_return_if_fail(self);
142 g_return_if_fail(pos);
143 g_return_if_fail(vel);
144 g_return_if_fail(acc);
146 LocationPassivePrivate *priv = GET_PRIVATE(self);
147 g_return_if_fail(priv);
149 if (priv->min_interval != LOCATION_UPDATE_INTERVAL_NONE) {
150 distance_based_position_signaling(self, signals, enabled, pos, vel, acc,
151 priv->min_interval, priv->min_distance, &(priv->enabled),
152 &(priv->dist_updated_timestamp), &(priv->pos), &(priv->vel), &(priv->acc));
154 location_signaling(self, signals, enabled, priv->boundary_list, pos, vel, acc,
155 priv->pos_interval, priv->vel_interval, priv->loc_interval, &(priv->enabled),
156 &(priv->pos_updated_timestamp), &(priv->vel_updated_timestamp),
157 &(priv->loc_updated_timestamp), &(priv->pos), &(priv->vel), &(priv->acc));
160 static void passive_satellite_cb(gboolean enabled, LocationSatellite *sat, gpointer self)
162 g_return_if_fail(self);
163 LocationPassivePrivate *priv = GET_PRIVATE(self);
164 g_return_if_fail(priv);
166 satellite_signaling(self, signals, &(priv->enabled), priv->sat_interval, TRUE, &(priv->sat_updated_timestamp), &(priv->sat), sat);
169 static int location_passive_start(LocationPassive *self)
172 LocationPassivePrivate *priv = GET_PRIVATE(self);
173 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
174 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
175 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
176 g_return_val_if_fail(priv->mod->ops.start, LOCATION_ERROR_NOT_AVAILABLE);
178 LOC_COND_RET(__get_started(self) == TRUE, LOCATION_ERROR_NONE, _E, "Passive already started. Error[%s]", err_msg(LOCATION_ERROR_NONE));
180 int ret = LOCATION_ERROR_NONE;
182 if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
183 ret = LOCATION_ERROR_SETTING_OFF;
185 __set_started(self, TRUE);
187 ret = priv->mod->ops.start(priv->mod->handler, 1, NULL, passive_location_cb, passive_satellite_cb, self);
188 if (ret != LOCATION_ERROR_NONE) {
189 LOCATION_LOGE("Fail to start gps. Error[%d]", ret);
190 __set_started(self, FALSE);
195 if (priv->app_type != CPPAPP && priv->set_noti == FALSE)
196 priv->set_noti = TRUE;
201 static int location_passive_stop(LocationPassive *self)
204 LocationPassivePrivate *priv = GET_PRIVATE(self);
205 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
206 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
207 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
208 g_return_val_if_fail(priv->mod->ops.stop, LOCATION_ERROR_NOT_AVAILABLE);
210 int ret = LOCATION_ERROR_NONE;
212 if (__get_started(self) == TRUE) {
213 __set_started(self, FALSE);
214 ret = priv->mod->ops.stop(priv->mod->handler);
215 LOC_IF_FAIL_LOG(ret, _E, "Failed to stop [%s]", err_msg(ret));
216 g_signal_emit(self, signals[SERVICE_DISABLED], 0, LOCATION_STATUS_NO_FIX);
219 if (priv->app_type != CPPAPP && priv->set_noti == TRUE)
220 priv->set_noti = FALSE;
222 __reset_pos_data_from_priv(priv);
227 static void location_passive_dispose(GObject *gobject)
230 LocationPassivePrivate *priv = GET_PRIVATE(gobject);
231 g_return_if_fail(priv);
233 g_mutex_clear(&priv->mutex);
235 if (priv->app_type != CPPAPP && priv->set_noti == TRUE)
236 priv->set_noti = FALSE;
238 G_OBJECT_CLASS(location_passive_parent_class)->dispose(gobject);
241 static void location_passive_finalize(GObject *gobject)
244 LocationPassivePrivate *priv = GET_PRIVATE(gobject);
245 g_return_if_fail(priv);
247 if (priv->boundary_list) {
248 g_list_free_full(priv->boundary_list, free_boundary_list);
249 priv->boundary_list = NULL;
253 location_position_free(priv->pos);
258 location_velocity_free(priv->vel);
263 location_accuracy_free(priv->acc);
266 G_OBJECT_CLASS(location_passive_parent_class)->finalize(gobject);
269 static guint get_valid_interval(guint interval, int max_interval, int min_interval)
271 if (interval > max_interval)
272 return (guint)max_interval;
273 else if (interval < min_interval)
274 return (guint)min_interval;
279 static void location_passive_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
281 LocationPassivePrivate *priv = GET_PRIVATE(object);
282 g_return_if_fail(priv);
285 switch (property_id) {
286 case PROP_BOUNDARY: {
287 GList *boundary_list = (GList *)g_list_copy(g_value_get_pointer(value));
288 ret = set_prop_boundary(&priv->boundary_list, boundary_list);
289 if (ret != LOCATION_ERROR_NONE)
290 LOCATION_LOGE("Set boundary. Error[%d]", ret);
292 g_list_free(boundary_list);
295 case PROP_REMOVAL_BOUNDARY: {
296 LocationBoundary *req_boundary = (LocationBoundary *) g_value_dup_boxed(value);
297 ret = set_prop_removal_boundary(&priv->boundary_list, req_boundary);
298 if (ret != 0) LOCATION_LOGD("Set removal boundary. Error[%d]", ret);
301 case PROP_POS_INTERVAL: {
302 guint interval = g_value_get_uint(value);
304 if (interval < LOCATION_UPDATE_INTERVAL_MAX)
305 priv->pos_interval = interval;
307 priv->pos_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
309 priv->pos_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
314 case PROP_VEL_INTERVAL: {
315 guint interval = g_value_get_uint(value);
317 if (interval < LOCATION_UPDATE_INTERVAL_MAX)
318 priv->vel_interval = interval;
320 priv->vel_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
322 priv->vel_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
326 case PROP_SAT_INTERVAL: {
327 guint interval = g_value_get_uint(value);
328 LOCATION_LOGD("Set prop>> PROP_SAT_INTERVAL: %u", interval);
329 priv->sat_interval = get_valid_interval(interval, LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_MIN);
332 case PROP_LOC_INTERVAL: {
333 guint interval = g_value_get_uint(value);
334 LOCATION_LOGD("Set prop>> PROP_LOC_INTERVAL: %u", interval);
336 if (interval < LOCATION_UPDATE_INTERVAL_MAX)
337 priv->loc_interval = interval;
339 priv->loc_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX;
341 priv->loc_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
346 case PROP_MIN_INTERVAL: {
347 guint interval = g_value_get_uint(value);
348 LOCATION_LOGD("Set prop>> update-min-interval: %u", interval);
350 if (interval < LOCATION_MIN_INTERVAL_MAX)
351 priv->min_interval = interval;
353 priv->min_interval = (guint)LOCATION_MIN_INTERVAL_MAX;
355 priv->min_interval = (guint)LOCATION_MIN_INTERVAL_DEFAULT;
360 case PROP_MIN_DISTANCE: {
361 gdouble distance = g_value_get_double(value);
362 LOCATION_LOGD("Set prop>> update-min-distance: %f", distance);
364 if (distance < LOCATION_MIN_DISTANCE_MAX)
365 priv->min_distance = distance;
367 priv->min_distance = (gdouble)LOCATION_MIN_DISTANCE_MAX;
369 priv->min_distance = (gdouble)LOCATION_MIN_DISTANCE_DEFAULT;
374 case PROP_SERVICE_STATUS: {
375 gint enabled = g_value_get_int(value);
376 LOCATION_LOGD("Set prop>> PROP_SERVICE_STATUS: %d", enabled);
377 priv->enabled = enabled;
381 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
386 static void location_passive_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
388 LocationPassivePrivate *priv = GET_PRIVATE(object);
389 g_return_if_fail(priv);
390 g_return_if_fail(priv->mod);
391 g_return_if_fail(priv->mod->handler);
392 LocModPassiveOps ops = priv->mod->ops;
394 switch (property_id) {
395 case PROP_METHOD_TYPE:
396 g_value_set_int(value, LOCATION_METHOD_PASSIVE);
398 case PROP_IS_STARTED:
399 g_value_set_boolean(value, __get_started(object));
401 case PROP_LAST_POSITION:
402 g_value_set_boxed(value, priv->pos);
405 g_value_set_pointer(value, g_list_first(priv->boundary_list));
407 case PROP_POS_INTERVAL:
408 g_value_set_uint(value, priv->pos_interval);
410 case PROP_VEL_INTERVAL:
411 g_value_set_uint(value, priv->vel_interval);
413 case PROP_SAT_INTERVAL:
414 g_value_set_uint(value, priv->sat_interval);
416 case PROP_LOC_INTERVAL:
417 g_value_set_uint(value, priv->loc_interval);
419 case PROP_MIN_INTERVAL:
420 g_value_set_uint(value, priv->min_interval);
422 case PROP_MIN_DISTANCE:
423 g_value_set_double(value, priv->min_distance);
425 case PROP_SATELLITE: {
426 LocationSatellite *satellite = NULL;
427 if (ops.get_satellite && priv->mod->handler && LOCATION_ERROR_NONE == ops.get_satellite(priv->mod->handler, &satellite) && satellite) {
428 LOCATION_LOGD("Get prop>> Last sat: num_used(%d) num_view(%d)", satellite->num_of_sat_used, satellite->num_of_sat_inview);
429 g_value_set_boxed(value, satellite);
430 location_satellite_free(satellite);
432 LOCATION_LOGW("Get prop>> Last sat: failed");
433 g_value_set_boxed(value, NULL);
437 case PROP_SERVICE_STATUS:
438 g_value_set_int(value, priv->enabled);
441 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
446 static int location_passive_get_position(LocationPassive *self, LocationPosition **position, LocationAccuracy **accuracy)
449 int ret = LOCATION_ERROR_NOT_AVAILABLE;
451 LocationPassivePrivate *priv = GET_PRIVATE(self);
452 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
453 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
454 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
456 if (__get_started(self) != TRUE) {
457 LOCATION_LOGE("location is not started");
458 return LOCATION_ERROR_NOT_AVAILABLE;
462 *position = location_position_copy(priv->pos);
463 if (priv->acc) *accuracy = location_accuracy_copy(priv->acc);
464 else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
465 ret = LOCATION_ERROR_NONE;
471 static int location_passive_get_position_ext(LocationPassive *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
474 int ret = LOCATION_ERROR_NOT_AVAILABLE;
476 LocationPassivePrivate *priv = GET_PRIVATE(self);
477 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
478 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
479 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
481 if (__get_started(self) != TRUE) {
482 LOCATION_LOGE("location is not started");
483 return LOCATION_ERROR_NOT_AVAILABLE;
486 if (priv->pos && priv->vel) {
487 *position = location_position_copy(priv->pos);
488 *velocity = location_velocity_copy(priv->vel);
489 if (priv->acc) *accuracy = location_accuracy_copy(priv->acc);
490 else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
491 ret = LOCATION_ERROR_NONE;
498 static int location_passive_get_last_position(LocationPassive *self, LocationPosition **position, LocationAccuracy **accuracy)
501 LocationPassivePrivate *priv = GET_PRIVATE(self);
502 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
503 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
504 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
506 int ret = LOCATION_ERROR_NONE;
507 LocationVelocity *_velocity = NULL;
509 LocModPassiveOps ops = priv->mod->ops;
510 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
511 g_return_val_if_fail(ops.get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
513 ret = ops.get_last_position(priv->mod->handler, position, &_velocity, accuracy);
514 if (_velocity) location_velocity_free(_velocity);
519 static int location_passive_get_last_position_ext(LocationPassive *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
522 LocationPassivePrivate *priv = GET_PRIVATE(self);
523 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
524 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
525 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
527 LocModPassiveOps ops = priv->mod->ops;
528 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
529 g_return_val_if_fail(ops.get_last_position, LOCATION_ERROR_NOT_AVAILABLE);
531 return ops.get_last_position(priv->mod->handler, position, velocity, accuracy);
534 static int location_passive_get_velocity(LocationPassive *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
536 int ret = LOCATION_ERROR_NOT_AVAILABLE;
538 LocationPassivePrivate *priv = GET_PRIVATE(self);
539 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
540 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
541 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
543 if (__get_started(self) != TRUE) {
544 LOCATION_LOGE("location is not started");
545 return LOCATION_ERROR_NOT_AVAILABLE;
549 *velocity = location_velocity_copy(priv->vel);
550 if (priv->acc) *accuracy = location_accuracy_copy(priv->acc);
551 else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
552 ret = LOCATION_ERROR_NONE;
558 static int location_passive_get_last_velocity(LocationPassive *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
561 LocationPassivePrivate *priv = GET_PRIVATE(self);
562 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
563 g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
564 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
566 int ret = LOCATION_ERROR_NONE;
567 LocationPosition *_position = NULL;
569 LocModPassiveOps ops = priv->mod->ops;
570 g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
571 ret = ops.get_last_position(priv->mod->handler, &_position, velocity, accuracy);
572 if (!_position) location_position_free(_position);
577 static int location_passive_get_satellite(LocationPassive *self, LocationSatellite **satellite)
580 LocationPassivePrivate *priv = GET_PRIVATE(self);
581 g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
582 setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
584 LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Passive is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
586 int ret = LOCATION_ERROR_NOT_AVAILABLE;
588 *satellite = location_satellite_copy(priv->sat);
589 ret = LOCATION_ERROR_NONE;
595 static int location_passive_get_last_satellite(LocationPassive *self, LocationSatellite **satellite)
598 return location_passive_get_satellite(self, satellite);
601 static int location_passive_set_option(LocationPassive *self, const char *option)
604 return LOCATION_ERROR_NONE;
607 static int location_passive_request_single_location(LocationPassive *self, int timeout)
610 return LOCATION_ERROR_NOT_SUPPORTED;
613 static int location_passive_cancel_single_location(LocationPassive *self, int timeout)
616 return LOCATION_ERROR_NOT_SUPPORTED;
619 static int location_passive_get_nmea(LocationPassive *self, char **nmea_data)
622 return LOCATION_ERROR_NOT_SUPPORTED;
625 static int location_passive_set_mock_location(LocationPassive *self, LocationPosition *position, LocationVelocity *velocity, LocationAccuracy *accuracy)
628 return LOCATION_ERROR_NOT_SUPPORTED;
631 static int location_passive_clear_mock_location(LocationPassive *self)
634 return LOCATION_ERROR_NOT_SUPPORTED;
637 static void location_ielement_interface_init(LocationIElementInterface *iface)
639 iface->start = (TYPE_START_FUNC)location_passive_start;
640 iface->stop = (TYPE_STOP_FUNC)location_passive_stop;
641 iface->get_position = (TYPE_GET_POSITION)location_passive_get_position;
642 iface->get_position_ext = (TYPE_GET_POSITION_EXT)location_passive_get_position_ext;
643 iface->get_last_position = (TYPE_GET_POSITION)location_passive_get_last_position;
644 iface->get_last_position_ext = (TYPE_GET_POSITION_EXT)location_passive_get_last_position_ext;
645 iface->get_velocity = (TYPE_GET_VELOCITY)location_passive_get_velocity;
646 iface->get_last_velocity = (TYPE_GET_VELOCITY)location_passive_get_last_velocity;
647 iface->get_satellite = (TYPE_GET_SATELLITE)location_passive_get_satellite;
648 iface->get_last_satellite = (TYPE_GET_SATELLITE)location_passive_get_last_satellite;
649 iface->set_option = (TYPE_SET_OPTION)location_passive_set_option;
650 iface->request_single_location = (TYPE_REQUEST_SINGLE_LOCATION)location_passive_request_single_location;
651 iface->cancel_single_location = (TYPE_CANCEL_SINGLE_LOCATION)location_passive_cancel_single_location;
652 iface->get_nmea = (TYPE_GET_NMEA)location_passive_get_nmea;
653 iface->set_mock_location = (TYPE_SET_MOCK_LOCATION) location_passive_set_mock_location;
654 iface->clear_mock_location = (TYPE_CLEAR_MOCK_LOCATION) location_passive_clear_mock_location;
657 static void location_passive_init(LocationPassive *self)
660 LocationPassivePrivate *priv = GET_PRIVATE(self);
661 g_return_if_fail(priv);
663 priv->mod = (LocationPassiveMod *)module_new("passive");
664 if (!priv->mod) LOCATION_LOGW("module loading failed");
666 g_mutex_init(&priv->mutex);
667 priv->is_started = FALSE;
668 priv->set_noti = FALSE;
669 priv->enabled = FALSE;
671 priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
672 priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
673 priv->sat_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
674 priv->loc_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
675 priv->min_interval = LOCATION_UPDATE_INTERVAL_NONE;
677 priv->pos_updated_timestamp = 0;
678 priv->vel_updated_timestamp = 0;
679 priv->sat_updated_timestamp = 0;
680 priv->loc_updated_timestamp = 0;
686 priv->boundary_list = NULL;
688 priv->loc_timeout = 0;
690 priv->app_type = location_get_app_type(NULL);
691 LOC_COND_LOG(priv->app_type == 0, _W, "[Info] Fail to get app_type");
694 static void location_passive_class_init(LocationPassiveClass *klass)
697 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
699 gobject_class->set_property = location_passive_set_property;
700 gobject_class->get_property = location_passive_get_property;
702 gobject_class->dispose = location_passive_dispose;
703 gobject_class->finalize = location_passive_finalize;
705 g_type_class_add_private(klass, sizeof(LocationPassivePrivate));
707 signals[SERVICE_ENABLED] =
708 g_signal_new("service-enabled", G_TYPE_FROM_CLASS(klass),
709 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
710 G_STRUCT_OFFSET(LocationPassiveClass, enabled),
711 NULL, NULL, location_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
713 signals[SERVICE_DISABLED] =
714 g_signal_new("service-disabled", G_TYPE_FROM_CLASS(klass),
715 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
716 G_STRUCT_OFFSET(LocationPassiveClass, disabled),
717 NULL, NULL, location_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
719 signals[SERVICE_UPDATED] =
720 g_signal_new("service-updated", G_TYPE_FROM_CLASS(klass),
721 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
722 G_STRUCT_OFFSET(LocationPassiveClass, service_updated),
723 NULL, NULL, location_VOID__INT_POINTER_POINTER_POINTER, G_TYPE_NONE, 4,
724 G_TYPE_INT, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
726 signals[LOCATION_UPDATED] =
727 g_signal_new("location-updated", G_TYPE_FROM_CLASS(klass),
728 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
729 G_STRUCT_OFFSET(LocationPassiveClass, location_updated),
730 NULL, NULL, location_VOID__INT_POINTER_POINTER_POINTER,
731 G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
734 g_signal_new("zone-in", G_TYPE_FROM_CLASS(klass),
735 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
736 G_STRUCT_OFFSET(LocationPassiveClass, zone_in),
737 NULL, NULL, location_VOID__POINTER_POINTER_POINTER,
738 G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
741 g_signal_new("zone-out", G_TYPE_FROM_CLASS(klass),
742 G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
743 G_STRUCT_OFFSET(LocationPassiveClass, zone_out),
744 NULL, NULL, location_VOID__POINTER_POINTER_POINTER,
745 G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER);
747 properties[PROP_METHOD_TYPE] =
748 g_param_spec_int("method", "method type", "location method type name",
749 LOCATION_METHOD_PASSIVE, LOCATION_METHOD_PASSIVE, LOCATION_METHOD_PASSIVE, G_PARAM_READABLE);
751 properties[PROP_IS_STARTED] =
752 g_param_spec_boolean("is_started", "passive is started prop",
753 "passive is started status", FALSE, G_PARAM_READWRITE);
755 properties[PROP_LAST_POSITION] =
756 g_param_spec_boxed("last-position", "passive last position prop",
757 "passive last position data", LOCATION_TYPE_POSITION, G_PARAM_READABLE);
759 properties[PROP_POS_INTERVAL] =
760 g_param_spec_uint("pos-interval", "passive position interval prop",
761 "passive position interval data", LOCATION_UPDATE_INTERVAL_MIN,
762 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
764 properties[PROP_VEL_INTERVAL] =
765 g_param_spec_uint("vel-interval", "passive velocity interval prop",
766 "passive velocity interval data", LOCATION_UPDATE_INTERVAL_MIN,
767 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
769 properties[PROP_SAT_INTERVAL] =
770 g_param_spec_uint("sat-interval", "passive satellite interval prop",
771 "passive satellite interval data", LOCATION_UPDATE_INTERVAL_MIN,
772 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
774 properties[PROP_LOC_INTERVAL] =
775 g_param_spec_uint("loc-interval", "passive location interval prop",
776 "passive location interval data", LOCATION_UPDATE_INTERVAL_MIN,
777 LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
779 properties[PROP_MIN_INTERVAL] =
780 g_param_spec_uint("min-interval", "passive distance-based interval prop",
781 "passive distance-based interval data", LOCATION_MIN_INTERVAL_MIN,
782 LOCATION_MIN_INTERVAL_MAX, LOCATION_MIN_INTERVAL_DEFAULT, G_PARAM_READWRITE);
784 properties[PROP_MIN_DISTANCE] =
785 g_param_spec_double("min-distance", "passive distance-based distance prop",
786 "passive distance-based distance data", LOCATION_MIN_DISTANCE_MIN,
787 LOCATION_MIN_DISTANCE_MAX, LOCATION_MIN_DISTANCE_DEFAULT, G_PARAM_READWRITE);
789 properties[PROP_BOUNDARY] =
790 g_param_spec_pointer("boundary", "passive boundary prop",
791 "passive boundary data", G_PARAM_READWRITE);
793 properties[PROP_REMOVAL_BOUNDARY] =
794 g_param_spec_boxed("removal-boundary", "passive removal boundary prop",
795 "passive removal boundary data", LOCATION_TYPE_BOUNDARY, G_PARAM_READWRITE);
797 properties[PROP_SATELLITE] =
798 g_param_spec_boxed("satellite", "passive satellite prop",
799 "passive satellite data", LOCATION_TYPE_SATELLITE, G_PARAM_READABLE);
801 properties[PROP_SERVICE_STATUS] =
802 g_param_spec_int("service-status", "location service status prop",
803 "location service status data", LOCATION_STATUS_NO_FIX,
804 LOCATION_STATUS_3D_FIX, LOCATION_STATUS_NO_FIX, G_PARAM_READABLE);
806 g_object_class_install_properties(gobject_class, PROP_MAX, properties);