4 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
7 * Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
26 #include "location-setting.h"
27 #include "location-log.h"
29 #include "module-internal.h"
31 #include "location-hybrid.h"
32 #include "location-marshal.h"
33 #include "location-ielement.h"
34 #include "location-signaling-util.h"
35 #include "location-common-util.h"
37 #include "location-gps.h"
38 #include "location-wps.h"
39 #include "location-cps.h"
41 typedef struct _LocationHybridPrivate {
45 guint pos_updated_timestamp;
47 guint vel_updated_timestamp;
49 guint sat_updated_timestamp;
54 LocationMethod current_method;
55 LocationPosition *pos;
56 LocationVelocity *vel;
57 LocationAccuracy *acc;
58 LocationSatellite *sat;
60 ZoneStatus zone_status;
66 } LocationHybridPrivate;
76 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_HYBRID, LocationHybridPrivate))
85 static void location_ielement_interface_init (LocationIElementInterface *iface);
87 G_DEFINE_TYPE_WITH_CODE (LocationHybrid, location_hybrid, G_TYPE_OBJECT,
88 G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT,
89 location_ielement_interface_init));
92 hybrid_get_current_method(LocationHybridPrivate* priv)
94 g_return_val_if_fail (priv, LOCATION_METHOD_NONE);
95 LOCATION_LOGW("Current Method [%d]\n", priv->current_method);
96 return priv->current_method;
100 hybrid_set_current_method (LocationHybridPrivate* priv, GType g_type)
102 g_return_val_if_fail (priv, FALSE);
104 if (g_type == LOCATION_TYPE_GPS) {
105 priv->current_method = LOCATION_METHOD_GPS;
106 LOCATION_LOGW("Set current Method [%d]\n", priv->current_method);
107 } else if (g_type == LOCATION_TYPE_WPS) {
108 priv->current_method = LOCATION_METHOD_WPS;
109 LOCATION_LOGW("Set current Method [%d]\n", priv->current_method);
110 } else if (g_type == LOCATION_TYPE_HYBRID){
111 priv->current_method = LOCATION_METHOD_HYBRID;
112 LOCATION_LOGW("Set current Method [%d]\n", priv->current_method);
121 hybrid_get_update_method (LocationHybridPrivate* priv)
123 if(!priv->gps && !priv->wps) return -1;
125 if (priv->gps_enabled) {
126 hybrid_set_current_method (priv, LOCATION_TYPE_GPS);
127 } else if (priv->wps_enabled) {
128 hybrid_set_current_method (priv, LOCATION_TYPE_WPS);
130 hybrid_set_current_method (priv,LOCATION_TYPE_HYBRID);
136 static LocationObject *
137 hybrid_get_current_object (LocationHybridPrivate* priv)
139 LocationMethod method = hybrid_get_current_method (priv);
141 LocationObject *obj = NULL;
143 case LOCATION_METHOD_GPS:
146 case LOCATION_METHOD_WPS:
156 static gboolean /* True : Receive more accurate info. False : Receive less accurate info */
157 hybrid_compare_g_type_method(LocationHybridPrivate *priv, GType g_type)
159 if (g_type == LOCATION_TYPE_GPS) {
160 hybrid_set_current_method(priv, LOCATION_TYPE_GPS);
162 } else if (g_type == LOCATION_TYPE_WPS && hybrid_get_current_method(priv) == LOCATION_METHOD_WPS) {
163 hybrid_set_current_method(priv, LOCATION_TYPE_WPS);
171 _position_timeout_cb (gpointer data)
173 LOCATION_LOGD("_position_timeout_cb");
174 GObject *object = (GObject *)data;
175 if (!object) return FALSE;
176 LocationHybridPrivate *priv = GET_PRIVATE(object);
177 if (!priv) return FALSE;
179 LocationPosition *pos = NULL;
180 LocationAccuracy *acc = NULL;
183 pos = location_position_copy (priv->pos);
186 pos = location_position_new (0, 0.0, 0.0, 0.0, LOCATION_STATUS_NO_FIX);
190 acc = location_accuracy_copy (priv->acc);
193 acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
196 LOCATION_LOGD("POSITION SERVICE_UPDATED");
197 g_signal_emit(object, signals[SERVICE_UPDATED], 0, POSITION_UPDATED, pos, acc);
199 location_position_free (pos);
200 location_accuracy_free (acc);
206 _velocity_timeout_cb (gpointer data)
208 LOCATION_LOGD("_velocity_timeout_cb");
209 GObject *object = (GObject *)data;
210 LocationHybridPrivate *priv = GET_PRIVATE(object);
211 if (!priv) return FALSE;
213 LocationVelocity *vel = NULL;
214 LocationAccuracy *acc = NULL;
217 vel = location_velocity_copy(priv->vel);
220 vel = location_velocity_new (0, 0.0, 0.0, 0.0);
224 acc = location_accuracy_copy (priv->acc);
227 acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
230 LOCATION_LOGD("VELOCITY SERVICE_UPDATED");
231 g_signal_emit(object, signals[SERVICE_UPDATED], 0, VELOCITY_UPDATED, vel, acc);
233 location_velocity_free (vel);
234 location_accuracy_free (acc);
241 location_hybrid_state_cb (keynode_t *key, gpointer self)
243 LOCATION_LOGD("location_hybrid_state_cb");
244 g_return_if_fail (key);
245 g_return_if_fail (self);
246 LocationHybridPrivate *priv = GET_PRIVATE(self);
248 if (location_setting_get_key_val (key) == VCONFKEY_LOCATION_POSITION_SEARCHING) {
249 if (!priv->pos_timer) priv->pos_timer = g_timeout_add (priv->pos_interval * 1000, _position_timeout_cb, self);
250 if (!priv->vel_timer) priv->vel_timer = g_timeout_add (priv->vel_interval * 1000, _velocity_timeout_cb, self);
254 if (priv->pos_timer) g_source_remove (priv->pos_timer);
255 if (priv->vel_timer) g_source_remove (priv->vel_timer);
263 hybrid_service_updated (GObject *obj,
269 LocationPosition *pos = NULL;
270 LocationVelocity *vel = NULL;
271 LocationSatellite *sat = NULL;
272 LOCATION_LOGD ("hybrid_service_updated");
274 /* To discard invalid data in a hybrid */
276 case POSITION_UPDATED: {
277 pos = (LocationPosition *)data;
278 if (!pos->timestamp) return;
280 case VELOCITY_UPDATED: {
281 vel = (LocationVelocity *)data;
282 if (!vel->timestamp) return;
284 case SATELLITE_UPDATED: {
285 sat = (LocationSatellite *)data;
286 if (!sat->timestamp) return;
290 LocationHybridPrivate* priv = GET_PRIVATE((LocationHybrid*)self);
291 GType g_type = G_TYPE_FROM_INSTANCE(obj);
292 if (g_type == LOCATION_TYPE_GPS) {
293 if (type == SATELLITE_UPDATED) {
294 satellite_signaling(self, signals, &(priv->enabled), priv->sat_interval, TRUE, &(priv->sat_updated_timestamp), &(priv->sat), sat);
297 else if (location_setting_get_int (VCONFKEY_LOCATION_GPS_STATE) == VCONFKEY_LOCATION_GPS_SEARCHING) {
298 LOCATION_LOGD ("Searching GPS");
303 else if ((g_type == LOCATION_TYPE_WPS || g_type == LOCATION_TYPE_CPS) && location_setting_get_int (VCONFKEY_LOCATION_WPS_STATE) == VCONFKEY_LOCATION_WPS_SEARCHING) {
304 LOCATION_LOGD ("Searching WPS or CPS");
308 if (hybrid_compare_g_type_method(priv, g_type)) {
309 LocationAccuracy *acc = (LocationAccuracy*)accuracy;
310 if (type == POSITION_UPDATED) {
311 position_signaling(self, signals, &(priv->enabled), priv->pos_interval, TRUE, &(priv->pos_updated_timestamp), &(priv->pos), &(priv->acc), priv->boundary_list, &(priv->zone_status), pos, acc);
312 LOCATION_LOGW("Position updated. timestamp [%d]", priv->pos->timestamp);
313 } else if (type == VELOCITY_UPDATED) {
314 velocity_signaling(self, signals, &(priv->enabled), priv->vel_interval, TRUE, &(priv->vel_updated_timestamp), &(priv->vel), vel, acc);
315 LOCATION_LOGW("Velocity updated. timestamp [%d]", priv->vel->timestamp);
318 } else if (type == POSITION_UPDATED && priv->pos) {
319 if (pos->timestamp - priv->pos->timestamp > HYBRID_POSITION_EXPIRATION_TIME) {
320 hybrid_set_current_method(priv, g_type);
327 hybrid_service_enabled (GObject *obj,
331 LOCATION_LOGD ("hybrid_service_enabled");
332 LocationHybridPrivate* priv = GET_PRIVATE((LocationHybrid*)self);
333 GType g_type = G_TYPE_FROM_INSTANCE(obj);
334 if(g_type == LOCATION_TYPE_GPS) priv->gps_enabled = TRUE;
335 else if(g_type == LOCATION_TYPE_WPS) priv->wps_enabled = TRUE;
337 LOCATION_LOGW("Undefined GType enabled");
340 hybrid_get_update_method(priv);
341 if(priv->gps_enabled || priv->wps_enabled)
342 enable_signaling(self, signals, &(priv->enabled), TRUE, status);
347 hybrid_service_disabled (GObject *obj,
351 LOCATION_LOGD ("hybrid_service_disabled");
352 LocationHybridPrivate* priv = GET_PRIVATE((LocationHybrid*)self);
353 GType g_type = G_TYPE_FROM_INSTANCE(obj);
354 if(g_type == LOCATION_TYPE_GPS) priv->gps_enabled = FALSE;
355 else if(g_type == LOCATION_TYPE_WPS) priv->wps_enabled = FALSE;
357 LOCATION_LOGW("Undefined GType disabled");
360 hybrid_get_update_method(priv);
361 if(!priv->gps_enabled && !priv->wps_enabled)
362 enable_signaling(self, signals, &(priv->enabled), FALSE, status);
367 location_hybrid_start (LocationHybrid *self)
369 LOCATION_LOGD("location_hybrid_start");
371 int ret_gps = LOCATION_ERROR_NONE;
372 int ret_wps = LOCATION_ERROR_NONE;
374 LocationHybridPrivate* priv = GET_PRIVATE(self);
375 if (priv->is_started == TRUE)
376 return LOCATION_ERROR_NONE;
378 if(priv->gps) ret_gps = location_start(priv->gps);
379 if(priv->wps) ret_wps = location_start(priv->wps);
381 if (ret_gps != LOCATION_ERROR_NONE &&
382 ret_wps != LOCATION_ERROR_NONE) {
383 if (ret_gps == LOCATION_ERROR_NOT_ALLOWED ||
384 ret_wps == LOCATION_ERROR_NOT_ALLOWED) {
385 priv->is_started = TRUE;
386 return LOCATION_ERROR_NOT_ALLOWED;
389 return LOCATION_ERROR_NOT_AVAILABLE;
393 priv->is_started = TRUE;
395 if (priv->set_noti == FALSE) {
396 location_setting_add_notify (VCONFKEY_LOCATION_POSITION_STATE, location_hybrid_state_cb, self);
397 priv->set_noti = TRUE;
401 return LOCATION_ERROR_NONE;
405 location_hybrid_stop (LocationHybrid *self)
407 LOCATION_LOGD("location_hybrid_stop");
409 LocationHybridPrivate* priv = GET_PRIVATE(self);
410 if( priv->is_started == FALSE)
411 return LOCATION_ERROR_NONE;
413 int ret_gps = LOCATION_ERROR_NONE;
414 int ret_wps = LOCATION_ERROR_NONE;
416 if(priv->gps) ret_gps = location_stop(priv->gps);
417 if(priv->wps) ret_wps = location_stop(priv->wps);
419 priv->is_started = FALSE;
421 if (ret_gps != LOCATION_ERROR_NONE &&
422 ret_wps != LOCATION_ERROR_NONE)
423 return LOCATION_ERROR_NOT_AVAILABLE;
425 if (priv->pos_timer) g_source_remove (priv->pos_timer);
426 if (priv->vel_timer) g_source_remove (priv->vel_timer);
430 if (priv->set_noti == TRUE) {
431 location_setting_ignore_notify (VCONFKEY_LOCATION_POSITION_STATE, location_hybrid_state_cb);
432 priv->set_noti = FALSE;
435 return LOCATION_ERROR_NONE;
439 location_hybrid_dispose (GObject *gobject)
441 LOCATION_LOGD("location_hybrid_dispose");
442 LocationHybridPrivate *priv = GET_PRIVATE(gobject);
444 if (priv->pos_timer) g_source_remove (priv->pos_timer);
445 if (priv->vel_timer) g_source_remove (priv->vel_timer);
449 if (priv->set_noti == TRUE) {
450 location_setting_ignore_notify (VCONFKEY_LOCATION_POSITION_STATE, location_hybrid_state_cb);
451 priv->set_noti = FALSE;
454 G_OBJECT_CLASS (location_hybrid_parent_class)->dispose (gobject);
458 location_hybrid_finalize (GObject *gobject)
460 LOCATION_LOGD("location_hybrid_finalize");
461 LocationHybridPrivate* priv = GET_PRIVATE(gobject);
464 g_signal_handlers_disconnect_by_func(priv->gps, G_CALLBACK (hybrid_service_enabled), gobject);
465 g_signal_handlers_disconnect_by_func(priv->gps, G_CALLBACK (hybrid_service_disabled), gobject);
466 g_signal_handlers_disconnect_by_func(priv->gps, G_CALLBACK (hybrid_service_updated), gobject);
467 location_free(priv->gps);
470 g_signal_handlers_disconnect_by_func(priv->wps, G_CALLBACK (hybrid_service_enabled), gobject);
471 g_signal_handlers_disconnect_by_func(priv->wps, G_CALLBACK (hybrid_service_disabled), gobject);
472 g_signal_handlers_disconnect_by_func(priv->wps, G_CALLBACK (hybrid_service_updated), gobject);
473 location_free(priv->wps);
476 if (priv->boundary_list) {
477 g_list_free_full(priv->boundary_list, free_boundary_list);
478 priv->boundary_list = NULL;
482 location_position_free(priv->pos);
487 location_velocity_free(priv->vel);
492 location_accuracy_free(priv->acc);
497 location_satellite_free(priv->sat);
501 G_OBJECT_CLASS (location_hybrid_parent_class)->finalize (gobject);
505 location_hybrid_set_property (GObject *object,
510 LocationHybridPrivate* priv = GET_PRIVATE(object);
511 if (!priv->gps && !priv->wps) {
512 LOCATION_LOGW("Set property is not available now");
517 switch (property_id){
519 GList *boundary_list = (GList *)g_list_copy(g_value_get_pointer(value));
520 ret = set_prop_boundary(&priv->boundary_list, boundary_list);
521 if(ret != 0) LOCATION_LOGD("Set boundary. Error[%d]", ret);
524 case PROP_REMOVAL_BOUNDARY: {
525 LocationBoundary *req_boundary = (LocationBoundary*) g_value_dup_boxed(value);
526 ret = set_prop_removal_boundary(&priv->boundary_list, req_boundary);
527 if(ret != 0) LOCATION_LOGD("Removal boundary. Error[%d]", ret);
530 case PROP_POS_INTERVAL: {
531 guint interval = g_value_get_uint(value);
533 if(interval < LOCATION_UPDATE_INTERVAL_MAX)
534 priv->pos_interval = interval;
536 priv->pos_interval = (guint) LOCATION_UPDATE_INTERVAL_MAX;
540 priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
542 if (priv->pos_timer) {
543 g_source_remove (priv->pos_timer);
544 priv->pos_timer = g_timeout_add (priv->pos_interval * 1000, _position_timeout_cb, object);
549 case PROP_VEL_INTERVAL: {
550 guint interval = g_value_get_uint(value);
552 if(interval < LOCATION_UPDATE_INTERVAL_MAX)
553 priv->vel_interval = interval;
555 priv->vel_interval = (guint) LOCATION_UPDATE_INTERVAL_MAX;
559 priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
561 if (priv->vel_timer) {
562 g_source_remove (priv->vel_timer);
563 priv->vel_timer = g_timeout_add (priv->vel_interval * 1000, _velocity_timeout_cb, object);
568 case PROP_SAT_INTERVAL: {
569 guint interval = g_value_get_uint(value);
571 if(interval < LOCATION_UPDATE_INTERVAL_MAX)
572 priv->sat_interval = interval;
574 priv->sat_interval = (guint) LOCATION_UPDATE_INTERVAL_MAX;
578 priv->sat_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
583 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
589 location_hybrid_get_property (GObject *object,
594 LocationHybridPrivate *priv = GET_PRIVATE (object);
595 if(!priv->gps && !priv->wps){
596 LOCATION_LOGW("Get property is not available now");
600 LOCATION_LOGW("Get Propery ID[%d]", property_id);
602 switch (property_id){
603 case PROP_METHOD_TYPE:
604 g_value_set_int(value, hybrid_get_current_method (priv));
606 case PROP_LAST_POSITION:
607 g_value_set_boxed(value, priv->pos);
610 g_value_set_pointer(value, g_list_first(priv->boundary_list));
612 case PROP_POS_INTERVAL:
613 g_value_set_uint(value, priv->pos_interval);
615 case PROP_VEL_INTERVAL:
616 g_value_set_uint(value, priv->vel_interval);
618 case PROP_SAT_INTERVAL:
619 g_value_set_uint(value, priv->sat_interval);
622 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
628 location_hybrid_get_position (LocationHybrid *self,
629 LocationPosition **position,
630 LocationAccuracy **accuracy)
632 int ret = LOCATION_ERROR_NOT_AVAILABLE;
633 LOCATION_LOGD("location_hybrid_get_position");
634 if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED) && !location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED)) {
635 return LOCATION_ERROR_NOT_ALLOWED;
638 LocationHybridPrivate *priv = GET_PRIVATE (self);
641 *position = location_position_copy (priv->pos);
642 ret = LOCATION_ERROR_NONE;
646 *accuracy = location_accuracy_copy (priv->acc);
653 location_hybrid_get_last_position (LocationHybrid *self,
654 LocationPosition **position,
655 LocationAccuracy **accuracy)
657 LOCATION_LOGD("location_hybrid_get_last_position");
659 int ret = LOCATION_ERROR_NONE;
660 LocationPosition *gps_pos = NULL, *wps_pos = NULL;
661 LocationAccuracy *gps_acc = NULL, *wps_acc = NULL;
662 LocationHybridPrivate *priv = GET_PRIVATE (self);
664 if (priv->gps) location_get_last_position (priv->gps, &gps_pos, &gps_acc);
665 if (priv->wps) location_get_last_position (priv->wps, &wps_pos, &wps_acc);
667 if (gps_pos && wps_pos) {
668 if (wps_pos->timestamp > gps_pos->timestamp) {
671 location_position_free (gps_pos);
672 location_accuracy_free (gps_acc);
677 location_position_free (wps_pos);
678 location_accuracy_free (wps_acc);
680 } else if (gps_pos) {
683 } else if (wps_pos) {
687 ret = LOCATION_ERROR_NOT_AVAILABLE;
694 location_hybrid_get_velocity (LocationHybrid *self,
695 LocationVelocity **velocity,
696 LocationAccuracy **accuracy)
698 int ret = LOCATION_ERROR_NOT_AVAILABLE;
699 LOCATION_LOGD("location_hybrid_get_velocity");
700 if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED) && !location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED)) {
701 return LOCATION_ERROR_NOT_ALLOWED;
704 LocationHybridPrivate *priv = GET_PRIVATE (self);
707 *velocity = location_velocity_copy (priv->vel);
708 ret = LOCATION_ERROR_NONE;
712 *accuracy = location_accuracy_copy (priv->acc);
719 location_hybrid_get_last_velocity (LocationHybrid *self,
720 LocationVelocity **velocity,
721 LocationAccuracy **accuracy)
723 LOCATION_LOGD("location_hybrid_get_last_velocity");
725 int ret = LOCATION_ERROR_NONE;
726 LocationHybridPrivate *priv = GET_PRIVATE (self);
727 LocationVelocity *gps_vel = NULL, *wps_vel = NULL;
728 LocationAccuracy *gps_acc = NULL, *wps_acc = NULL;
730 if (priv->gps) location_get_last_velocity (priv->gps, &gps_vel, &gps_acc);
731 if (priv->wps) location_get_last_velocity (priv->wps, &wps_vel, &wps_acc);
733 if (gps_vel && wps_vel) {
734 if (wps_vel->timestamp > gps_vel->timestamp) {
737 location_velocity_free (gps_vel);
738 location_accuracy_free (gps_acc);
742 location_velocity_free (wps_vel);
743 location_accuracy_free (wps_acc);
749 } else if (wps_vel) {
755 ret = LOCATION_ERROR_NOT_AVAILABLE;
762 location_hybrid_get_satellite (LocationHybrid *self,
763 LocationSatellite **satellite)
765 int ret = LOCATION_ERROR_NOT_AVAILABLE;
766 LOCATION_LOGD("location_hybrid_get_satellite");
767 if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED) && !location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED)) {
768 return LOCATION_ERROR_NOT_ALLOWED;
771 LocationHybridPrivate *priv = GET_PRIVATE (self);
773 *satellite = location_satellite_copy (priv->sat);
774 ret = LOCATION_ERROR_NONE;
781 location_hybrid_get_last_satellite (LocationHybrid *self,
782 LocationSatellite **satellite)
784 LOCATION_LOGD("location_hybrid_get_last_satellite");
786 int ret = LOCATION_ERROR_NONE;
787 LocationHybridPrivate *priv = GET_PRIVATE (self);
789 if (priv->gps) ret = location_get_last_satellite (priv->gps, satellite);
792 ret = LOCATION_ERROR_NOT_AVAILABLE;
799 location_ielement_interface_init (LocationIElementInterface *iface)
801 iface->start = (TYPE_START_FUNC)location_hybrid_start;
802 iface->stop = (TYPE_STOP_FUNC)location_hybrid_stop;
803 iface->get_position = (TYPE_GET_POSITION)location_hybrid_get_position;
804 iface->get_last_position = (TYPE_GET_POSITION)location_hybrid_get_last_position;
805 iface->get_velocity = (TYPE_GET_VELOCITY)location_hybrid_get_velocity;
806 iface->get_last_velocity = (TYPE_GET_VELOCITY)location_hybrid_get_last_velocity;
807 iface->get_satellite = (TYPE_GET_SATELLITE)location_hybrid_get_satellite;
808 iface->get_last_satellite = (TYPE_GET_SATELLITE)location_hybrid_get_last_satellite;
812 location_hybrid_init (LocationHybrid *self)
814 LOCATION_LOGD("location_hybrid_init");
815 LocationHybridPrivate* priv = GET_PRIVATE(self);
817 priv->is_started = FALSE;
818 priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
819 priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
820 priv->sat_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
822 priv->pos_updated_timestamp = 0;
823 priv->vel_updated_timestamp = 0;
824 priv->sat_updated_timestamp = 0;
826 priv->gps_enabled = FALSE;
827 priv->wps_enabled = FALSE;
832 priv->set_noti = FALSE;
837 if(location_is_supported_method(LOCATION_METHOD_GPS)) priv->gps = location_new (LOCATION_METHOD_GPS);
838 if(location_is_supported_method(LOCATION_METHOD_WPS)) priv->wps = location_new (LOCATION_METHOD_WPS);
841 g_signal_connect (priv->gps, "service-enabled", G_CALLBACK(hybrid_service_enabled), self);
842 g_signal_connect (priv->gps, "service-disabled", G_CALLBACK(hybrid_service_disabled), self);
843 g_signal_connect (priv->gps, "service-updated", G_CALLBACK(hybrid_service_updated), self);
846 g_signal_connect (priv->wps, "service-enabled", G_CALLBACK(hybrid_service_enabled), self);
847 g_signal_connect (priv->wps, "service-disabled", G_CALLBACK(hybrid_service_disabled), self);
848 g_signal_connect (priv->wps, "service-updated", G_CALLBACK(hybrid_service_updated), self);
851 hybrid_set_current_method (priv, LOCATION_TYPE_HYBRID);
852 priv->enabled= FALSE;
859 priv->zone_status = ZONE_STATUS_NONE;
860 priv->boundary_list = NULL;
865 location_hybrid_class_init (LocationHybridClass *klass)
867 LOCATION_LOGD("location_hybrid_class_init");
868 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
870 gobject_class->set_property = location_hybrid_set_property;
871 gobject_class->get_property = location_hybrid_get_property;
873 gobject_class->dispose = location_hybrid_dispose;
874 gobject_class->finalize = location_hybrid_finalize;
876 g_type_class_add_private (klass, sizeof (LocationHybridPrivate));
878 signals[SERVICE_ENABLED] = g_signal_new ("service-enabled",
879 G_TYPE_FROM_CLASS (klass),
882 G_STRUCT_OFFSET (LocationHybridClass, enabled),
888 signals[SERVICE_DISABLED] = g_signal_new ("service-disabled",
889 G_TYPE_FROM_CLASS (klass),
892 G_STRUCT_OFFSET (LocationHybridClass, disabled),
898 signals[SERVICE_UPDATED] = g_signal_new ("service-updated",
899 G_TYPE_FROM_CLASS (klass),
902 G_STRUCT_OFFSET (LocationHybridClass, updated),
904 location_VOID__UINT_POINTER_POINTER,
910 signals[ZONE_IN] = g_signal_new ("zone-in",
911 G_TYPE_FROM_CLASS (klass),
914 G_STRUCT_OFFSET (LocationHybridClass, zone_in),
916 location_VOID__UINT_POINTER_POINTER,
922 signals[ZONE_OUT] = g_signal_new ("zone-out",
923 G_TYPE_FROM_CLASS (klass),
926 G_STRUCT_OFFSET (LocationHybridClass, zone_out),
928 location_VOID__UINT_POINTER_POINTER,
934 properties[PROP_METHOD_TYPE] = g_param_spec_int ("method",
936 "location method type name",
937 LOCATION_METHOD_HYBRID,
938 LOCATION_METHOD_HYBRID,
939 LOCATION_METHOD_HYBRID,
942 properties[PROP_LAST_POSITION] = g_param_spec_boxed ("last-position",
943 "hybrid last position prop",
944 "hybrid last position data",
945 LOCATION_TYPE_POSITION,
948 properties[PROP_POS_INTERVAL] = g_param_spec_uint ("pos-interval",
949 "position interval prop",
950 "position interval data",
951 LOCATION_UPDATE_INTERVAL_MIN,
952 LOCATION_UPDATE_INTERVAL_MAX,
953 LOCATION_UPDATE_INTERVAL_DEFAULT,
955 properties[PROP_VEL_INTERVAL] = g_param_spec_uint ("vel-interval",
956 "velocity interval prop",
957 "velocity interval data",
958 LOCATION_UPDATE_INTERVAL_MIN,
959 LOCATION_UPDATE_INTERVAL_MAX,
960 LOCATION_UPDATE_INTERVAL_DEFAULT,
962 properties[PROP_SAT_INTERVAL] = g_param_spec_uint ("sat-interval",
963 "satellite interval prop",
964 "satellite interval data",
965 LOCATION_UPDATE_INTERVAL_MIN,
966 LOCATION_UPDATE_INTERVAL_MAX,
967 LOCATION_UPDATE_INTERVAL_DEFAULT,
970 properties[PROP_BOUNDARY] = g_param_spec_pointer ("boundary",
971 "hybrid boundary prop",
972 "hybrid boundary data",
975 properties[PROP_REMOVAL_BOUNDARY] = g_param_spec_boxed("removal-boundary",
976 "hybrid removal boundary prop",
977 "hybrid removal boundary data",
978 LOCATION_TYPE_BOUNDARY,
981 g_object_class_install_properties (gobject_class,