diff options
Diffstat (limited to 'location/manager')
-rw-r--r-- | location/manager/Makefile.am | 1 | ||||
-rw-r--r-- | location/manager/location-accuracy.c | 2 | ||||
-rw-r--r-- | location/manager/location-cps.c | 708 | ||||
-rw-r--r-- | location/manager/location-cps.h | 64 | ||||
-rw-r--r-- | location/manager/location-gps.c | 124 | ||||
-rw-r--r-- | location/manager/location-hybrid.c | 66 | ||||
-rw-r--r-- | location/manager/location-ielement.c | 7 | ||||
-rw-r--r-- | location/manager/location-ielement.h | 3 | ||||
-rw-r--r-- | location/manager/location-position.c | 2 | ||||
-rw-r--r-- | location/manager/location-signaling-util.c | 71 | ||||
-rw-r--r-- | location/manager/location-signaling-util.h | 19 | ||||
-rw-r--r-- | location/manager/location-wps.c | 169 | ||||
-rw-r--r-- | location/manager/location.c | 39 | ||||
-rw-r--r-- | location/manager/location.h | 18 |
14 files changed, 266 insertions, 1027 deletions
diff --git a/location/manager/Makefile.am b/location/manager/Makefile.am index 9f8687a..7be44bf 100644 --- a/location/manager/Makefile.am +++ b/location/manager/Makefile.am @@ -19,7 +19,6 @@ liblocation_manager_la_SOURCES = \ location-common-util.c \
location-gps.c \
location-wps.c \
- location-cps.c \
location-hybrid.c
liblocation_manager_la_CFLAGS = \
diff --git a/location/manager/location-accuracy.c b/location/manager/location-accuracy.c index 8d04950..d519837 100644 --- a/location/manager/location-accuracy.c +++ b/location/manager/location-accuracy.c @@ -76,7 +76,7 @@ comp_double_reverse(double a, double b) return 1; } -int +EXPORT_API int location_accuracy_level_compare(const LocationAccuracy *accuracy1, const LocationAccuracy *accuracy2) { g_return_val_if_fail(accuracy1, -1); diff --git a/location/manager/location-cps.c b/location/manager/location-cps.c deleted file mode 100644 index 0da9c40..0000000 --- a/location/manager/location-cps.c +++ /dev/null @@ -1,708 +0,0 @@ -/* - * libslp-location - * - * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com> - * Genie Kim <daejins.kim@samsung.com> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "location-setting.h" -#include "location-log.h" - -#include "module-internal.h" - -#include "location-cps.h" -#include "location-marshal.h" -#include "location-ielement.h" -#include "location-signaling-util.h" -#include "location-common-util.h" - -typedef struct _LocationCpsPrivate { - LocationCpsMod *mod; - gboolean is_started; - gboolean set_noti; - gboolean enabled; - guint pos_updated_timestamp; - guint pos_interval; - guint vel_updated_timestamp; - guint vel_interval; - LocationPosition *pos; - LocationVelocity *vel; - LocationAccuracy *acc; - GList *boundary_list; - guint pos_timer; - guint vel_timer; -} LocationCpsPrivate; - -enum { - PROP_0, - PROP_METHOD_TYPE, - PROP_POS_INTERVAL, - PROP_VEL_INTERVAL, - PROP_BOUNDARY, - PROP_REMOVAL_BOUNDARY, - PROP_MAX -}; - -static guint32 signals[LAST_SIGNAL] = {0, }; -static GParamSpec *properties[PROP_MAX] = {NULL, }; - -#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LOCATION_TYPE_CPS, LocationCpsPrivate)) - -static void location_ielement_interface_init (LocationIElementInterface *iface); - -G_DEFINE_TYPE_WITH_CODE (LocationCps, location_cps, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT, - location_ielement_interface_init)); - -static gboolean -_position_timeout_cb (gpointer data) -{ - GObject *object = (GObject *)data; - LocationCpsPrivate *priv = GET_PRIVATE(object); - if (!priv) return FALSE; - - LocationPosition *pos = NULL; - LocationAccuracy *acc = NULL; - - if (priv->pos) { - pos = location_position_copy(priv->pos); - } else { - pos = location_position_new (0, 0.0, 0.0, 0.0, LOCATION_STATUS_NO_FIX); - } - - if (priv->acc) { - acc = location_accuracy_copy (priv->acc); - } else { - acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0); - } - - LOCATION_LOGD("VELOCITY SERVICE_UPDATED"); - g_signal_emit(object, signals[SERVICE_UPDATED], 0, POSITION_UPDATED, pos, acc); - - location_position_free (pos); - location_accuracy_free (acc); - - return TRUE; -} - -static gboolean -_velocity_timeout_cb (gpointer data) -{ - GObject *object = (GObject *)data; - LocationCpsPrivate *priv = GET_PRIVATE(object); - if (!priv) return FALSE; - - LocationVelocity *vel = NULL; - LocationAccuracy *acc = NULL; - - if (priv->vel) { - vel = location_velocity_copy(priv->vel); - } else { - vel = location_velocity_new (0, 0.0, 0.0, 0.0); - } - - if (priv->acc) { - acc = location_accuracy_copy (priv->acc); - } else { - acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0); - } - - LOCATION_LOGD("VELOCITY SERVICE_UPDATED"); - g_signal_emit(object, signals[SERVICE_UPDATED], 0, VELOCITY_UPDATED, vel, acc); - - location_velocity_free (vel); - location_accuracy_free (acc); - - return TRUE; -} - -static void -__reset_pos_data_from_priv(LocationCpsPrivate *priv) -{ - LOCATION_LOGD("__reset_pos_data_from_priv"); - g_return_if_fail(priv); - - if (priv->pos) { - location_position_free(priv->pos); - priv->pos = NULL; - } - - if (priv->vel) { - location_velocity_free(priv->vel); - priv->vel = NULL; - } - - if (priv->acc) { - location_accuracy_free(priv->acc); - priv->acc = NULL; - } -} - -static void -cps_status_cb (gboolean enabled, - LocationStatus status, - gpointer self) -{ - LOCATION_LOGD("cps_status_cb"); - g_return_if_fail(self); - LocationCpsPrivate* priv = GET_PRIVATE(self); - enable_signaling(self, signals, &(priv->enabled), enabled, status); - if (!priv->enabled) { - if (priv->pos_timer) { - g_source_remove(g_source_remove(priv->pos_timer)); - priv->pos_timer = 0; - } - if (priv->vel_timer) { - g_source_remove(g_source_remove(priv->vel_timer)); - priv->vel_timer = 0; - } - } -} - -static void -cps_position_ext_cb (gboolean enabled, - LocationPosition *pos, - LocationVelocity *vel, - LocationAccuracy *acc, - gpointer self) -{ - LOCATION_LOGD("cps_position_ext_cb"); - g_return_if_fail(self); - g_return_if_fail(pos); - g_return_if_fail(vel); - g_return_if_fail(acc); - LocationCpsPrivate* priv = GET_PRIVATE(self); - - if (enabled && !priv->enabled) { - if (!priv->pos_timer) priv->pos_timer = g_timeout_add_seconds (priv->pos_interval, _position_timeout_cb, self); - if (!priv->vel_timer) priv->vel_timer = g_timeout_add_seconds (priv->vel_interval, _velocity_timeout_cb, self); - } - - enable_signaling(self, signals, &(priv->enabled), enabled, pos->status); - position_signaling(self, signals, &(priv->enabled), priv->pos_interval, FALSE, &(priv->pos_updated_timestamp), &(priv->pos), &(priv->acc), priv->boundary_list, pos, acc); - velocity_signaling(self, signals, &(priv->enabled), priv->vel_interval, FALSE, &(priv->vel_updated_timestamp), &(priv->vel), vel, acc); -} - -static void -location_setting_cps_cb (keynode_t *key, - gpointer self) -{ - LOCATION_LOGD("location_setting_cps_cb"); - g_return_if_fail (key); - g_return_if_fail (self); - - LocationCpsPrivate *priv = GET_PRIVATE(self); - g_return_if_fail (priv->mod); - g_return_if_fail (priv->mod->handler); - - int ret = LOCATION_ERROR_NONE; - - if (location_setting_get_key_val (key) == 0) { - if (priv->mod->ops.stop && priv->is_started) { - ret = priv->mod->ops.stop (priv->mod->handler); - if (ret == LOCATION_ERROR_NONE) { - priv->is_started = FALSE; - __reset_pos_data_from_priv(priv); - } - } - } else { - if (1 == location_setting_get_int (VCONFKEY_LOCATION_NETWORK_ENABLED) && priv->mod->ops.start && !priv->is_started) { - LOCATION_LOGD("location resumed by setting"); - ret = priv->mod->ops.start (priv->mod->handler, cps_status_cb, cps_position_ext_cb, NULL, self); - if (ret == LOCATION_ERROR_NONE) { - priv->is_started = TRUE; - } - } - } -} - -static void -location_cps_dispose (GObject *gobject) -{ - LOCATION_LOGD("location_cps_dispose"); - - LocationCpsPrivate *priv = GET_PRIVATE(gobject); - if (priv->set_noti == TRUE) { - location_setting_ignore_notify (VCONFKEY_LOCATION_NETWORK_ENABLED, location_setting_cps_cb); - priv->set_noti = FALSE; - } - - if (priv->pos_timer) { - g_source_remove (priv->pos_timer); - priv->pos_timer = 0; - } - - if (priv->vel_timer) { - g_source_remove (priv->vel_timer); - priv->vel_timer = 0; - } - - G_OBJECT_CLASS (location_cps_parent_class)->dispose (gobject); -} - -static void -location_cps_finalize (GObject *gobject) -{ - LOCATION_LOGD("location_cps_finalize"); - LocationCpsPrivate* priv = GET_PRIVATE(gobject); - module_free(priv->mod, "cps"); - priv->mod = NULL; - - if (priv->boundary_list) { - g_list_free_full (priv->boundary_list, free_boundary_list); - priv->boundary_list = NULL; - } - - if (priv->pos) { - location_position_free(priv->pos); - priv->pos = NULL; - } - - if (priv->vel) { - location_velocity_free(priv->vel); - priv->vel = NULL; - } - - if (priv->acc) { - location_accuracy_free(priv->acc); - priv->acc = NULL; - } - - G_OBJECT_CLASS (location_cps_parent_class)->finalize (gobject); -} - -static void -location_cps_set_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - LocationCpsPrivate *priv = GET_PRIVATE(object); - - int ret = 0; - - switch (property_id) { - case PROP_BOUNDARY:{ - GList *boundary_list = (GList *)g_list_copy(g_value_get_pointer(value)); - ret = set_prop_boundary(&priv->boundary_list, boundary_list); - if(ret != 0) LOCATION_LOGD("Set boundary. Error[%d]", ret); - break; - } - case PROP_REMOVAL_BOUNDARY: { - LocationBoundary *req_boundary = (LocationBoundary*) g_value_dup_boxed(value); - ret = set_prop_removal_boundary(&priv->boundary_list, req_boundary); - if(ret != 0) LOCATION_LOGD("Set removal boundary. Error[%d]", ret); - break; - } - case PROP_POS_INTERVAL: { - guint interval = g_value_get_uint (value); - - if (interval > 0) { - if (interval < LOCATION_UPDATE_INTERVAL_MAX) - priv->pos_interval = interval; - else - priv->pos_interval = (guint) LOCATION_UPDATE_INTERVAL_MAX; - } else { - priv->pos_interval = (guint) LOCATION_UPDATE_INTERVAL_DEFAULT; - } - - if (priv->pos_timer) { - g_source_remove (priv->pos_timer); - priv->pos_timer = g_timeout_add_seconds (priv->pos_interval, _position_timeout_cb, object); - } - - break; - } - - case PROP_VEL_INTERVAL: { - guint interval = g_value_get_uint(value); - if(interval > 0) { - if(interval < LOCATION_UPDATE_INTERVAL_MAX) - priv->vel_interval = interval; - else - priv->vel_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX; - } else - priv->vel_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT; - - if (priv->vel_timer) { - g_source_remove (priv->vel_timer); - priv->vel_timer = g_timeout_add_seconds (priv->vel_interval, _velocity_timeout_cb, object); - } - - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -location_cps_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - LocationCpsPrivate *priv = GET_PRIVATE (object); - - switch (property_id){ - case PROP_METHOD_TYPE: - g_value_set_int(value, LOCATION_METHOD_CPS); - break; - case PROP_BOUNDARY: - g_value_set_pointer(value, g_list_first(priv->boundary_list)); - break; - case PROP_POS_INTERVAL: { - g_value_set_uint (value, priv->pos_interval); - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static int -location_cps_start (LocationCps *self) -{ - LOCATION_LOGD("location_cps_start"); - - LocationCpsPrivate* priv = GET_PRIVATE(self); - g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE); - g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE); - g_return_val_if_fail (priv->mod->ops.start, LOCATION_ERROR_NOT_AVAILABLE); - - if (priv->is_started == TRUE) return LOCATION_ERROR_NONE; - - int ret = LOCATION_ERROR_NOT_AVAILABLE; - - if (!location_setting_get_int (VCONFKEY_LOCATION_NETWORK_ENABLED)) { - ret = LOCATION_ERROR_SETTING_OFF; - } else { - ret = priv->mod->ops.start (priv->mod->handler, cps_status_cb, cps_position_ext_cb, NULL, self); - if (ret == LOCATION_ERROR_NONE) { - priv->is_started = TRUE; - } - else { - return ret; - } - } - - if (priv->set_noti == FALSE) { - location_setting_add_notify (VCONFKEY_LOCATION_NETWORK_ENABLED, location_setting_cps_cb, self); - priv->set_noti = TRUE; - } - - return ret; -} - -static int -location_cps_stop (LocationCps *self) -{ - LOCATION_LOGD("location_cps_stop"); - LocationCpsPrivate* priv = GET_PRIVATE(self); - g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE); - g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE); - g_return_val_if_fail (priv->mod->ops.stop, LOCATION_ERROR_NOT_AVAILABLE); - - int ret = LOCATION_ERROR_NONE; - - if (priv->is_started == TRUE) { - ret = priv->mod->ops.stop (priv->mod->handler); - if (ret == LOCATION_ERROR_NONE) { - priv->is_started = FALSE; - __reset_pos_data_from_priv(priv); - } - else { - LOCATION_LOGD("Failed to stop. Error[%d]", ret); - } - } - - if (priv->set_noti == TRUE) { - location_setting_ignore_notify (VCONFKEY_LOCATION_NETWORK_ENABLED, location_setting_cps_cb); - priv->set_noti = FALSE; - } - - return ret; -} - -static int -location_cps_get_position (LocationCps *self, - LocationPosition **position, - LocationAccuracy **accuracy) -{ - int ret = LOCATION_ERROR_NOT_AVAILABLE; - LOCATION_LOGD("location_cps_get_position"); - - LocationCpsPrivate *priv = GET_PRIVATE (self); - g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE); - - setting_retval_if_fail(VCONFKEY_LOCATION_NETWORK_ENABLED); - - if (priv->is_started != TRUE) { - LOCATION_LOGD("location is not started"); - return LOCATION_ERROR_NOT_AVAILABLE; - } - - if (priv->pos) { - *position = location_position_copy (priv->pos); - if (priv->acc) *accuracy = location_accuracy_copy(priv->acc); - else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0); - ret = LOCATION_ERROR_NONE; - } - - return ret; -} - -static int -location_cps_get_position_ext (LocationCps *self, - LocationPosition **position, - LocationVelocity **velocity, - LocationAccuracy **accuracy) -{ - int ret = LOCATION_ERROR_NOT_AVAILABLE; - LOCATION_LOGD("location_cps_get_position"); - - LocationCpsPrivate *priv = GET_PRIVATE (self); - g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE); - - setting_retval_if_fail(VCONFKEY_LOCATION_NETWORK_ENABLED); - - if (priv->is_started != TRUE) { - LOCATION_LOGD("location is not started"); - return LOCATION_ERROR_NOT_AVAILABLE; - } - - if (priv->pos && priv->vel) { - *position = location_position_copy (priv->pos); - *velocity = location_velocity_copy (priv->vel); - if (priv->acc) *accuracy = location_accuracy_copy(priv->acc); - else *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0); - ret = LOCATION_ERROR_NONE; - } - - return ret; -} - -static int -location_cps_get_last_position (LocationCps *self, - LocationPosition **position, - LocationAccuracy **accuracy) -{ - LOCATION_LOGD("location_cps_get_last_position"); - return LOCATION_ERROR_NOT_SUPPORTED; -} - -static int -location_cps_get_last_position_ext (LocationCps *self, - LocationPosition **position, - LocationVelocity **velocity, - LocationAccuracy **accuracy) -{ - LOCATION_LOGD("location_cps_get_last_position_ext"); - return LOCATION_ERROR_NOT_SUPPORTED; -} - -static int -location_cps_get_velocity (LocationCps *self, - LocationVelocity **velocity, - LocationAccuracy **accuracy) -{ - LOCATION_LOGD("location_cps_get_velocity"); - return LOCATION_ERROR_NOT_SUPPORTED; -} - -static int -location_cps_get_last_velocity (LocationCps *self, - LocationVelocity **velocity, - LocationAccuracy **accuracy) -{ - LOCATION_LOGD("location_cps_get_last_velocity"); - return LOCATION_ERROR_NOT_SUPPORTED; -} - -static int -location_cps_get_satellite (LocationCps *self, - LocationSatellite **satellite) -{ - LOCATION_LOGD("location_cps_get_satellite"); - return LOCATION_ERROR_NOT_SUPPORTED; -} - -static int -location_cps_get_last_satellite (LocationCps *self) -{ - LOCATION_LOGD("location_cps_get_last_satellite"); - return LOCATION_ERROR_NOT_SUPPORTED; -} - -static void -location_ielement_interface_init (LocationIElementInterface *iface) -{ - iface->start = (TYPE_START_FUNC) location_cps_start; - iface->stop = (TYPE_STOP_FUNC) location_cps_stop; - iface->get_position = (TYPE_GET_POSITION) location_cps_get_position; - iface->get_position_ext = (TYPE_GET_POSITION_EXT) location_cps_get_position_ext; - iface->get_last_position = (TYPE_GET_POSITION) location_cps_get_last_position; - iface->get_last_position_ext = (TYPE_GET_POSITION_EXT) location_cps_get_last_position_ext; - iface->get_velocity = (TYPE_GET_VELOCITY) location_cps_get_velocity; - iface->get_last_velocity = (TYPE_GET_VELOCITY)location_cps_get_last_velocity; - iface->get_satellite = (TYPE_GET_SATELLITE)location_cps_get_satellite; - iface->get_last_satellite = (TYPE_GET_SATELLITE)location_cps_get_last_satellite; -} - -static void -location_cps_init (LocationCps *self) -{ - LOCATION_LOGD("location_cps_init"); - LocationCpsPrivate* priv = GET_PRIVATE(self); - - priv->mod = (LocationCpsMod*)module_new("cps"); - if(!priv->mod) LOCATION_LOGW("module loading failed"); - - priv->is_started = FALSE; - priv->set_noti = FALSE; - priv->enabled = FALSE; - - priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT; - priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT; - - priv->pos_updated_timestamp = 0; - priv->vel_updated_timestamp = 0; - - priv->pos = NULL; - priv->acc = NULL; - priv->vel = NULL; - priv->boundary_list = NULL; - - priv->pos_timer = 0; - priv->vel_timer = 0; -} - -static void -location_cps_class_init (LocationCpsClass *klass) -{ - LOCATION_LOGD("location_cps_class_init"); - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->get_property = location_cps_get_property; - gobject_class->set_property = location_cps_set_property; - - gobject_class->dispose = location_cps_dispose; - gobject_class->finalize = location_cps_finalize; - - g_type_class_add_private (klass, sizeof (LocationCpsPrivate)); - - signals[SERVICE_ENABLED] = g_signal_new ("service-enabled", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | - G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (LocationCpsClass, enabled), - NULL, NULL, - location_VOID__UINT, - G_TYPE_NONE, 1, - G_TYPE_UINT); - - signals[SERVICE_DISABLED] = g_signal_new ("service-disabled", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | - G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (LocationCpsClass, disabled), - NULL, NULL, - location_VOID__UINT, - G_TYPE_NONE, 1, - G_TYPE_UINT); - - signals[SERVICE_UPDATED] = g_signal_new ("service-updated", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | - G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (LocationCpsClass, updated), - NULL, NULL, - location_VOID__UINT_POINTER_POINTER, - G_TYPE_NONE, 3, - G_TYPE_UINT, - G_TYPE_POINTER, - G_TYPE_POINTER); - - signals[ZONE_IN] = g_signal_new ("zone-in", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | - G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (LocationCpsClass, zone_in), - NULL, NULL, - location_VOID__POINTER_POINTER_POINTER, - G_TYPE_NONE, 3, - G_TYPE_POINTER, - G_TYPE_POINTER, - G_TYPE_POINTER); - - signals[ZONE_OUT] = g_signal_new ("zone-out", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | - G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (LocationCpsClass, zone_out), - NULL, NULL, - location_VOID__POINTER_POINTER_POINTER, - G_TYPE_NONE, 3, - G_TYPE_POINTER, - G_TYPE_POINTER, - G_TYPE_POINTER); - - properties[PROP_METHOD_TYPE] = g_param_spec_int ("method", - "method type", - "location method type name", - LOCATION_METHOD_CPS, - LOCATION_METHOD_CPS, - LOCATION_METHOD_CPS, - G_PARAM_READABLE); - - properties[PROP_POS_INTERVAL] = g_param_spec_uint ("pos-interval", - "cps position interval prop", - "cps position interval data", - LOCATION_UPDATE_INTERVAL_MIN, - LOCATION_UPDATE_INTERVAL_MAX, - LOCATION_UPDATE_INTERVAL_DEFAULT, - G_PARAM_READWRITE); - - properties[PROP_VEL_INTERVAL] = g_param_spec_uint ("vel-interval", - "cps velocity interval prop", - "cps velocity interval data", - LOCATION_UPDATE_INTERVAL_MIN, - LOCATION_UPDATE_INTERVAL_MAX, - LOCATION_UPDATE_INTERVAL_DEFAULT, - G_PARAM_READWRITE); - - properties[PROP_BOUNDARY] = g_param_spec_pointer ("boundary", - "cps boundary prop", - "cps boundary data", - G_PARAM_READWRITE); - - properties[PROP_REMOVAL_BOUNDARY] = g_param_spec_boxed("removal-boundary", - "cps removal boundary prop", - "cps removal boundary data", - LOCATION_TYPE_BOUNDARY, - G_PARAM_READWRITE); - - g_object_class_install_properties (gobject_class, - PROP_MAX, - properties); -} diff --git a/location/manager/location-cps.h b/location/manager/location-cps.h deleted file mode 100644 index 355586a..0000000 --- a/location/manager/location-cps.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * libslp-location - * - * Copyright (c) 2010-2013 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com> - * Genie Kim <daejins.kim@samsung.com> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __LOCATION_CPS_H__ -#define __LOCATION_CPS_H__ - -#include <glib-object.h> - -/** - * @file location-cps.h - * @brief This file contains the internal definitions and structures related to CPS. - */ - -G_BEGIN_DECLS - -#define LOCATION_TYPE_CPS (location_cps_get_type ()) -#define LOCATION_CPS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LOCATION_TYPE_CPS, LocationCps)) -#define LOCATION_IS_CPS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LOCATION_TYPE_CPS)) -#define LOCATION_CPS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LOCATION_TYPE_CPS, LocationCpsClass)) -#define LOCATION_IS_CPS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LOCATION_TYPE_CPS)) -#define LOCATION_CPS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LOCATION_TYPE_CPS, LocationCpsClass)) - -typedef struct _LocationCps LocationCps; -typedef struct _LocationCpsClass LocationCpsClass; - -struct _LocationCps -{ - GObject parent_instance; -}; - -struct _LocationCpsClass -{ - GObjectClass parent_class; - - void (* enabled) (guint type); - void (* disabled) (guint type); - void (* updated) (guint type, gpointer data, gpointer accuracy); - void (* zone_in) (gpointer boundary, gpointer position, gpointer accuracy); - void (* zone_out) (gpointer boundary, gpointer position, gpointer accuracy); -}; - -GType location_cps_get_type (void); - -G_END_DECLS - -#endif diff --git a/location/manager/location-gps.c b/location/manager/location-gps.c index 10eb252..495a16e 100644 --- a/location/manager/location-gps.c +++ b/location/manager/location-gps.c @@ -53,15 +53,15 @@ typedef struct _LocationGpsPrivate { LocationSatellite* sat; GList* boundary_list; - guint pos_timer; - guint vel_timer; - + guint pos_searching_timer; + guint vel_searching_timer; } LocationGpsPrivate; enum { PROP_0, PROP_DEV_NAME, PROP_METHOD_TYPE, + PROP_IS_STARTED, PROP_LAST_POSITION, PROP_POS_INTERVAL, PROP_VEL_INTERVAL, @@ -181,33 +181,46 @@ gps_status_cb (gboolean enabled, LOCATION_LOGD("gps_status_cb"); g_return_if_fail(self); LocationGpsPrivate* priv = GET_PRIVATE(self); - enable_signaling(self, signals, &(priv->enabled), enabled, status); - - if (!priv->enabled) { - if (priv->pos_timer) g_source_remove (priv->pos_timer); - if (priv->vel_timer) g_source_remove (priv->vel_timer); - priv->pos_timer = 0; - priv->vel_timer = 0; + if (!priv->enabled && enabled) { // Update satellite at searching status. + if (priv->pos_searching_timer) g_source_remove (priv->pos_searching_timer); + if (priv->vel_searching_timer) g_source_remove (priv->vel_searching_timer); + priv->pos_searching_timer = 0; + priv->vel_searching_timer = 0; + return; // Ignored: Support to get position at enabled callback + } else if (priv->enabled == TRUE && enabled == FALSE) { + enable_signaling(self, signals, &(priv->enabled), enabled, status); } } static void -gps_position_ext_cb (gboolean enabled, +gps_location_cb (gboolean enabled, LocationPosition *pos, LocationVelocity *vel, LocationAccuracy *acc, gpointer self) { - LOCATION_LOGD("gps_position_ext_cb"); + LOCATION_LOGD("gps_location_cb"); g_return_if_fail(self); g_return_if_fail(pos); g_return_if_fail(vel); g_return_if_fail(acc); - LocationGpsPrivate* priv = GET_PRIVATE(self); - enable_signaling(self, signals, &(priv->enabled), enabled, pos->status); - position_signaling(self, signals, &(priv->enabled), priv->pos_interval, TRUE, &(priv->pos_updated_timestamp), &(priv->pos), &(priv->acc), priv->boundary_list, pos, acc); - velocity_signaling(self, signals, &(priv->enabled), priv->vel_interval, TRUE, &(priv->vel_updated_timestamp), &(priv->vel), vel, acc); + LocationGpsPrivate* priv = GET_PRIVATE(self); + location_signaling(self, + signals, + enabled, // previous status + priv->boundary_list, + pos, + vel, + acc, + priv->pos_interval, + priv->vel_interval, + &(priv->enabled), + &(priv->pos_updated_timestamp), + &(priv->vel_updated_timestamp), + &(priv->pos), + &(priv->vel), + &(priv->acc)); } static void @@ -232,13 +245,13 @@ location_setting_search_cb (keynode_t *key, gpointer self) g_return_if_fail (priv->mod->handler); if (location_setting_get_key_val(key) == VCONFKEY_LOCATION_GPS_SEARCHING) { - if (!priv->pos_timer) priv->pos_timer = g_timeout_add (priv->pos_interval * 1000, _position_timeout_cb, self); - if (!priv->vel_timer) priv->vel_timer = g_timeout_add (priv->vel_interval * 1000, _velocity_timeout_cb, self); + if (!priv->pos_searching_timer) priv->pos_searching_timer = g_timeout_add (priv->pos_interval * 1000, _position_timeout_cb, self); + if (!priv->vel_searching_timer) priv->vel_searching_timer = g_timeout_add (priv->vel_interval * 1000, _velocity_timeout_cb, self); } else { - if (priv->pos_timer) g_source_remove (priv->pos_timer); - if (priv->vel_timer) g_source_remove (priv->vel_timer); - priv->pos_timer = 0; - priv->vel_timer = 0; + if (priv->pos_searching_timer) g_source_remove (priv->pos_searching_timer); + if (priv->vel_searching_timer) g_source_remove (priv->vel_searching_timer); + priv->pos_searching_timer = 0; + priv->vel_searching_timer = 0; } } @@ -264,7 +277,7 @@ location_setting_gps_cb (keynode_t *key, } } else if (1 == location_setting_get_key_val(key) && priv->mod->ops.start && !priv->is_started) { LOCATION_LOGD("location resumed by setting"); - ret = priv->mod->ops.start (priv->mod->handler, gps_status_cb, gps_position_ext_cb, gps_satellite_cb, self); + ret = priv->mod->ops.start (priv->mod->handler, gps_status_cb, gps_location_cb, gps_satellite_cb, self); if (ret == LOCATION_ERROR_NONE) { priv->is_started = TRUE; } @@ -287,7 +300,7 @@ location_gps_start (LocationGps *self) if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) { ret = LOCATION_ERROR_SETTING_OFF; } else { - ret = priv->mod->ops.start (priv->mod->handler, gps_status_cb, gps_position_ext_cb, gps_satellite_cb, self); + ret = priv->mod->ops.start (priv->mod->handler, gps_status_cb, gps_location_cb, gps_satellite_cb, self); if (ret == LOCATION_ERROR_NONE) { priv->is_started = TRUE; } else { @@ -324,16 +337,17 @@ location_gps_stop (LocationGps *self) } } - if (priv->pos_timer ) g_source_remove (priv->pos_timer); - if (priv->vel_timer ) g_source_remove (priv->vel_timer); - priv->pos_timer = 0; - priv->vel_timer = 0; + if (priv->pos_searching_timer ) g_source_remove (priv->pos_searching_timer); + if (priv->vel_searching_timer ) g_source_remove (priv->vel_searching_timer); + priv->pos_searching_timer = 0; + priv->vel_searching_timer = 0; if(priv->set_noti == TRUE) { location_setting_ignore_notify (VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb); location_setting_ignore_notify (VCONFKEY_LOCATION_GPS_STATE, location_setting_search_cb); priv->set_noti = FALSE; } + __reset_pos_data_from_priv(priv); return ret; @@ -346,10 +360,10 @@ location_gps_dispose (GObject *gobject) LocationGpsPrivate* priv = GET_PRIVATE(gobject); - if (priv->pos_timer) g_source_remove (priv->pos_timer); - if (priv->vel_timer) g_source_remove (priv->vel_timer); - priv->pos_timer = 0; - priv->vel_timer = 0; + if (priv->pos_searching_timer) g_source_remove (priv->pos_searching_timer); + if (priv->vel_searching_timer) g_source_remove (priv->vel_searching_timer); + priv->pos_searching_timer = 0; + priv->vel_searching_timer = 0; if(priv->set_noti == TRUE) { location_setting_ignore_notify (VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb); @@ -440,9 +454,9 @@ location_gps_set_property (GObject *object, else priv->pos_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT; - if (priv->pos_timer) { - g_source_remove (priv->pos_timer); - priv->pos_timer = g_timeout_add (priv->pos_interval * 1000, _position_timeout_cb, object); + if (priv->pos_searching_timer) { + g_source_remove (priv->pos_searching_timer); + priv->pos_searching_timer = g_timeout_add (priv->pos_interval * 1000, _position_timeout_cb, object); } break; @@ -459,9 +473,9 @@ location_gps_set_property (GObject *object, else priv->vel_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT; - if (priv->vel_timer) { - g_source_remove (priv->vel_timer); - priv->vel_timer = g_timeout_add (priv->vel_interval * 1000, _velocity_timeout_cb, object); + if (priv->vel_searching_timer) { + g_source_remove (priv->vel_searching_timer); + priv->vel_searching_timer = g_timeout_add (priv->vel_interval * 1000, _velocity_timeout_cb, object); } break; @@ -510,6 +524,9 @@ location_gps_get_property (GObject *object, case PROP_METHOD_TYPE: g_value_set_int(value, LOCATION_METHOD_GPS); break; + case PROP_IS_STARTED: + g_value_set_boolean(value, priv->is_started); + break; case PROP_LAST_POSITION: g_value_set_boxed (value, priv->pos); break; @@ -567,9 +584,7 @@ location_gps_get_position (LocationGps *self, g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE); setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED); - LocModGpsOps ops = priv->mod->ops; g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE); - g_return_val_if_fail (ops.get_position, LOCATION_ERROR_NOT_AVAILABLE); if (priv->is_started != TRUE) { LOCATION_LOGD("location is not started"); @@ -735,16 +750,18 @@ static int location_gps_get_last_satellite (LocationGps *self, LocationSatellite **satellite) { - LOCATION_LOGD("location_gps_get_last_satellite"); + return location_gps_get_satellite(self, satellite); +} - LocationGpsPrivate *priv = GET_PRIVATE (self); +static int +location_gps_set_option (LocationGps *self, const char *option) +{ + LOCATION_LOGD("location_gps_set_option"); + LocationGpsPrivate* priv = GET_PRIVATE(self); g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE); - setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED); - - LocModGpsOps ops = priv->mod->ops; g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE); - g_return_val_if_fail (ops.get_last_satellite, LOCATION_ERROR_NOT_AVAILABLE); - return ops.get_last_satellite(priv->mod->handler, satellite); + //g_return_val_if_fail (priv->mod->ops.set_option, LOCATION_ERROR_NOT_AVAILABLE); + return LOCATION_ERROR_NONE; } static void @@ -760,6 +777,7 @@ location_ielement_interface_init (LocationIElementInterface *iface) iface->get_last_velocity = (TYPE_GET_VELOCITY)location_gps_get_last_velocity; iface->get_satellite = (TYPE_GET_SATELLITE)location_gps_get_satellite; iface->get_last_satellite = (TYPE_GET_SATELLITE)location_gps_get_last_satellite; + iface->set_option = (TYPE_SET_OPTION)location_gps_set_option; } static void @@ -789,8 +807,8 @@ location_gps_init (LocationGps *self) priv->sat = NULL; priv->boundary_list = NULL; - priv->pos_timer = 0; - priv->vel_timer = 0; + priv->pos_searching_timer = 0; + priv->vel_searching_timer = 0; } static void @@ -877,6 +895,12 @@ location_gps_class_init (LocationGpsClass *klass) LOCATION_METHOD_GPS, G_PARAM_READABLE); + properties[PROP_IS_STARTED] = g_param_spec_boolean ("is_started", + "gps is started prop", + "gps is started status", + FALSE, + G_PARAM_READWRITE); + properties[PROP_LAST_POSITION] = g_param_spec_boxed ("last-position", "gps last position prop", "gps last position data", @@ -906,7 +930,7 @@ location_gps_class_init (LocationGpsClass *klass) LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE); - ; + properties[PROP_BOUNDARY] = g_param_spec_pointer ("boundary", "gps boundary prop", "gps boundary data", diff --git a/location/manager/location-hybrid.c b/location/manager/location-hybrid.c index fab9bbd..9fae291 100644 --- a/location/manager/location-hybrid.c +++ b/location/manager/location-hybrid.c @@ -36,10 +36,8 @@ #include "location-gps.h" #include "location-wps.h" -#include "location-cps.h" typedef struct _LocationHybridPrivate { - gboolean is_started; gboolean gps_enabled; gboolean wps_enabled; guint pos_updated_timestamp; @@ -233,7 +231,6 @@ _velocity_timeout_cb (gpointer data) return TRUE; } - static void location_hybrid_state_cb (keynode_t *key, gpointer self) { @@ -300,18 +297,27 @@ hybrid_service_updated (GObject *obj, } } - else if ((g_type == LOCATION_TYPE_WPS || g_type == LOCATION_TYPE_CPS) && location_setting_get_int (VCONFKEY_LOCATION_WPS_STATE) == VCONFKEY_LOCATION_WPS_SEARCHING) { - LOCATION_LOGD ("Searching WPS or CPS"); + else if (g_type == LOCATION_TYPE_WPS && location_setting_get_int (VCONFKEY_LOCATION_WPS_STATE) == VCONFKEY_LOCATION_WPS_SEARCHING) { + LOCATION_LOGD ("Searching WPS"); return; } if (hybrid_compare_g_type_method(priv, g_type)) { LocationAccuracy *acc = (LocationAccuracy*)accuracy; if (type == POSITION_UPDATED) { - position_signaling(self, signals, &(priv->enabled), priv->pos_interval, TRUE, &(priv->pos_updated_timestamp), &(priv->pos), &(priv->acc), priv->boundary_list, pos, acc); + if (priv->pos) location_position_free(priv->pos); + if (priv->acc) location_accuracy_free(priv->acc); + priv->pos = location_position_copy(pos); + priv->acc = location_accuracy_copy(acc); + if (!priv->enabled) { + enable_signaling(self, signals, &(priv->enabled), TRUE, pos->status); + } + position_signaling(self, signals, priv->pos_interval, &(priv->pos_updated_timestamp), priv->boundary_list, pos, acc); LOCATION_LOGW("Position updated. timestamp [%d]", priv->pos->timestamp); } else if (type == VELOCITY_UPDATED) { - velocity_signaling(self, signals, &(priv->enabled), priv->vel_interval, TRUE, &(priv->vel_updated_timestamp), &(priv->vel), vel, acc); + if (priv->vel) location_velocity_free(priv->vel); + priv->vel = location_velocity_copy(vel); + velocity_signaling(self, signals, priv->vel_interval, &(priv->vel_updated_timestamp), vel, acc); LOCATION_LOGW("Velocity updated. timestamp [%d]", priv->vel->timestamp); } @@ -337,9 +343,6 @@ hybrid_service_enabled (GObject *obj, return; } hybrid_get_update_method(priv); - if(priv->gps_enabled || priv->wps_enabled) - enable_signaling(self, signals, &(priv->enabled), TRUE, status); - } static void @@ -369,9 +372,15 @@ location_hybrid_start (LocationHybrid *self) int ret_gps = LOCATION_ERROR_NOT_AVAILABLE; int ret_wps = LOCATION_ERROR_NOT_AVAILABLE; + gboolean gps_started = FALSE; + gboolean wps_started = FALSE; LocationHybridPrivate* priv = GET_PRIVATE(self); - if (priv->is_started == TRUE) + + g_object_get(priv->gps, "is_started", &gps_started, NULL); + g_object_get(priv->wps, "is_started", &wps_started, NULL); + + if ((gps_started == TRUE) || (wps_started == TRUE)) return LOCATION_ERROR_NONE; if (priv->gps) ret_gps = location_start(priv->gps); @@ -387,8 +396,6 @@ location_hybrid_start (LocationHybrid *self) } } - priv->is_started = TRUE; - if (priv->set_noti == FALSE) { location_setting_add_notify (VCONFKEY_LOCATION_POSITION_STATE, location_hybrid_state_cb, self); priv->set_noti = TRUE; @@ -403,17 +410,22 @@ location_hybrid_stop (LocationHybrid *self) LOCATION_LOGD("location_hybrid_stop"); LocationHybridPrivate* priv = GET_PRIVATE(self); - if (priv->is_started == FALSE) - return LOCATION_ERROR_NONE; int ret_gps = LOCATION_ERROR_NOT_AVAILABLE; int ret_wps = LOCATION_ERROR_NOT_AVAILABLE; + gboolean gps_started = FALSE; + gboolean wps_started = FALSE; + + g_object_get(priv->gps, "is_started", &gps_started, NULL); + g_object_get(priv->wps, "is_started", &wps_started, NULL); + + if ((gps_started == FALSE) && (wps_started == FALSE)) { + return LOCATION_ERROR_NONE; + } if (priv->gps) ret_gps = location_stop(priv->gps); if (priv->wps) ret_wps = location_stop(priv->wps); - priv->is_started = FALSE; - if (ret_gps != LOCATION_ERROR_NONE && ret_wps != LOCATION_ERROR_NONE) return LOCATION_ERROR_NOT_AVAILABLE; @@ -873,6 +885,24 @@ location_hybrid_get_last_satellite (LocationHybrid *self, return ret; } +static int +location_hybrid_set_option (LocationHybrid *self, const char *option) +{ + LOCATION_LOGD("location_hybrid_set_option"); + LocationHybridPrivate *priv = GET_PRIVATE (self); + + int ret_gps = LOCATION_ERROR_NOT_AVAILABLE; + int ret_wps = LOCATION_ERROR_NOT_AVAILABLE; + + if (priv->gps) ret_gps = location_set_option(priv->gps, option); + if (priv->wps) ret_wps = location_set_option(priv->wps, option); + + if (ret_gps != LOCATION_ERROR_NONE && ret_wps != LOCATION_ERROR_NONE) + return LOCATION_ERROR_NOT_AVAILABLE; + + return LOCATION_ERROR_NONE; +} + static void location_ielement_interface_init (LocationIElementInterface *iface) { @@ -886,6 +916,7 @@ location_ielement_interface_init (LocationIElementInterface *iface) iface->get_last_velocity = (TYPE_GET_VELOCITY)location_hybrid_get_last_velocity; iface->get_satellite = (TYPE_GET_SATELLITE)location_hybrid_get_satellite; iface->get_last_satellite = (TYPE_GET_SATELLITE)location_hybrid_get_last_satellite; + iface->set_option = (TYPE_SET_OPTION)location_hybrid_set_option; } static void @@ -894,7 +925,6 @@ location_hybrid_init (LocationHybrid *self) LOCATION_LOGD("location_hybrid_init"); LocationHybridPrivate* priv = GET_PRIVATE(self); - priv->is_started = FALSE; priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT; priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT; priv->sat_interval = LOCATION_UPDATE_INTERVAL_DEFAULT; diff --git a/location/manager/location-ielement.c b/location/manager/location-ielement.c index 3be96bd..2d101c0 100644 --- a/location/manager/location-ielement.c +++ b/location/manager/location-ielement.c @@ -175,3 +175,10 @@ location_ielement_get_last_velocity (LocationIElement *self, g_return_val_if_fail (LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_velocity, LOCATION_ERROR_NOT_AVAILABLE); return LOCATION_IELEMENT_GET_INTERFACE (self)->get_last_velocity (self, velocity, accuracy); } + +int +location_ielement_set_option (LocationIElement *self, const char *option) +{ + g_return_val_if_fail (LOCATION_IS_IELEMENT (self), LOCATION_ERROR_PARAMETER); + return LOCATION_IELEMENT_GET_INTERFACE (self)->set_option (self, option); +}
\ No newline at end of file diff --git a/location/manager/location-ielement.h b/location/manager/location-ielement.h index c9a95b8..53d95a7 100644 --- a/location/manager/location-ielement.h +++ b/location/manager/location-ielement.h @@ -61,6 +61,7 @@ typedef int (*TYPE_GET_POSITION)(LocationIElement *self, LocationPosition **posi typedef int (*TYPE_GET_POSITION_EXT)(LocationIElement *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy); typedef int (*TYPE_GET_VELOCITY)(LocationIElement *self, LocationVelocity **velocity, LocationAccuracy **accuracy); typedef int (*TYPE_GET_SATELLITE)(LocationIElement *self, LocationSatellite **satellite); +typedef int (*TYPE_SET_OPTION)(LocationIElement *self, const char *option); struct _LocationIElementInterface { @@ -76,6 +77,7 @@ struct _LocationIElementInterface TYPE_GET_VELOCITY get_last_velocity; TYPE_GET_SATELLITE get_satellite; TYPE_GET_SATELLITE get_last_satellite; + TYPE_SET_OPTION set_option; }; GType location_ielement_get_type (void); @@ -88,6 +90,7 @@ int location_ielement_get_velocity (LocationIElement *self, LocationVelocity **v int location_ielement_get_last_velocity (LocationIElement *self, LocationVelocity **velocity, LocationAccuracy **accuracy); int location_ielement_get_satellite (LocationIElement *self, LocationSatellite **satellite); int location_ielement_get_last_satellite (LocationIElement *self, LocationSatellite **satellite); +int location_ielement_set_option (LocationIElement *self, const char *option); G_END_DECLS diff --git a/location/manager/location-position.c b/location/manager/location-position.c index 1bf57e0..b57542c 100644 --- a/location/manager/location-position.c +++ b/location/manager/location-position.c @@ -104,7 +104,7 @@ location_position_copy (const LocationPosition *position) } /* Vincenty formula. WGS-84 */ -EXPORT_API int +EXPORT_API int location_get_distance(const LocationPosition *pos1, const LocationPosition *pos2, gulong *distance) { g_return_val_if_fail(pos1, LOCATION_ERROR_PARAMETER); diff --git a/location/manager/location-signaling-util.c b/location/manager/location-signaling-util.c index 33ded5e..24e7813 100644 --- a/location/manager/location-signaling-util.c +++ b/location/manager/location-signaling-util.c @@ -51,15 +51,11 @@ enable_signaling (LocationObject *obj, void position_signaling (LocationObject *obj, guint32 signals[LAST_SIGNAL], - gboolean *prev_enabled, int interval, - gboolean emit, guint *updated_timestamp, - LocationPosition **prev_pos, - LocationAccuracy **prev_acc, GList *prev_bound, - const LocationPosition *pos, - const LocationAccuracy *acc) + LocationPosition *pos, + LocationAccuracy *acc) { g_return_if_fail(pos); g_return_if_fail(acc); @@ -73,14 +69,7 @@ position_signaling (LocationObject *obj, if (!pos->timestamp) return; - if (*prev_pos) location_position_free (*prev_pos); - if (*prev_acc) location_accuracy_free (*prev_acc); - - *prev_pos = location_position_copy(pos); - *prev_acc = location_accuracy_copy (acc); - LOCATION_LOGD("timestamp[%d], lat [%f], lon [%f]", (*prev_pos)->timestamp, (*prev_pos)->latitude, (*prev_pos)->longitude); - - if (emit && pos->timestamp - *updated_timestamp >= interval) { + if (pos->timestamp - *updated_timestamp >= interval) { LOCATION_LOGD("POSITION SERVICE_UPDATED"); g_signal_emit(obj, signals[SERVICE_UPDATED], 0, POSITION_UPDATED, pos, acc); *updated_timestamp = pos->timestamp; @@ -110,13 +99,10 @@ position_signaling (LocationObject *obj, void velocity_signaling (LocationObject *obj, guint32 signals[LAST_SIGNAL], - gboolean *prev_enabled, int interval, - gboolean emit, guint *updated_timestamp, - LocationVelocity **prev_vel, - const LocationVelocity *vel, - const LocationAccuracy *acc) + LocationVelocity *vel, + LocationAccuracy *acc) { g_return_if_fail(obj); g_return_if_fail(signals); @@ -124,12 +110,7 @@ velocity_signaling (LocationObject *obj, if (!vel->timestamp) return; - if (*prev_vel) location_velocity_free (*prev_vel); - - *prev_vel = location_velocity_copy (vel); - LOCATION_LOGD("timestamp[%d]", (*prev_vel)->timestamp); - - if (emit && vel->timestamp - *updated_timestamp >= interval) { + if (vel->timestamp - *updated_timestamp >= interval) { LOCATION_LOGD("VELOCITY SERVICE_UPDATED"); g_signal_emit(obj, signals[SERVICE_UPDATED], 0, VELOCITY_UPDATED, vel, acc); *updated_timestamp = vel->timestamp; @@ -137,6 +118,41 @@ velocity_signaling (LocationObject *obj, } void +location_signaling (LocationObject *obj, + guint32 signals[LAST_SIGNAL], + gboolean enabled, + GList *boundary_list, + LocationPosition *cur_pos, + LocationVelocity *cur_vel, + LocationAccuracy *cur_acc, + guint pos_interval, // interval : support an update interval + guint vel_interval, + gboolean *prev_enabled, + guint *prev_pos_timestamp, + guint *prev_vel_timestamp, + LocationPosition **prev_pos, // prev : keeping lastest info. + LocationVelocity **prev_vel, + LocationAccuracy **prev_acc) +{ + if (!cur_pos->timestamp) { + LOCATION_LOGD("Invalid location with timestamp, 0"); + return; + } + + if (*prev_pos) location_position_free(*prev_pos); + if (*prev_vel) location_velocity_free(*prev_vel); + if (*prev_acc) location_accuracy_free(*prev_acc); + + *prev_pos = location_position_copy (cur_pos); + *prev_vel = location_velocity_copy (cur_vel); + *prev_acc = location_accuracy_copy (cur_acc); + + enable_signaling (obj, signals, prev_enabled, enabled, cur_pos->status); + position_signaling (obj, signals, pos_interval, prev_pos_timestamp, boundary_list, cur_pos, cur_acc); + velocity_signaling (obj, signals, vel_interval, prev_vel_timestamp, cur_vel, cur_acc); +} + +void satellite_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean *prev_enabled, @@ -144,7 +160,7 @@ satellite_signaling(LocationObject *obj, gboolean emit, guint *updated_timestamp, LocationSatellite **prev_sat, - const LocationSatellite *sat) + LocationSatellite *sat) { g_return_if_fail(obj); g_return_if_fail(signals); @@ -160,5 +176,4 @@ satellite_signaling(LocationObject *obj, g_signal_emit(obj, signals[SERVICE_UPDATED], 0, SATELLITE_UPDATED, sat, NULL); *updated_timestamp = sat->timestamp; } - -} +}
\ No newline at end of file diff --git a/location/manager/location-signaling-util.h b/location/manager/location-signaling-util.h index b1f0231..51eaa57 100644 --- a/location/manager/location-signaling-util.h +++ b/location/manager/location-signaling-util.h @@ -35,19 +35,24 @@ G_BEGIN_DECLS void enable_signaling (LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean *prev_enabled, gboolean enabled, LocationStatus status); void position_signaling (LocationObject *obj, guint32 signals[LAST_SIGNAL], - gboolean *prev_enabled, int interval, gboolean emit, - guint *updated_interval, LocationPosition **prev_pos, LocationAccuracy **prev_acc, - GList *prev_bound, const LocationPosition *pos, const LocationAccuracy *acc); + int interval, guint *updated_interval, + GList *prev_bound, LocationPosition *pos, LocationAccuracy *acc); void velocity_signaling (LocationObject* obj, guint32 signals[LAST_SIGNAL], - gboolean *prev_enabled, int interval, gboolean emit, - guint *updated_timestamp, LocationVelocity **prev_vel, - const LocationVelocity *vel, const LocationAccuracy *acc); + int interval, guint *updated_timestamp, + LocationVelocity *vel, LocationAccuracy *acc); void satellite_signaling(LocationObject *obj, guint32 signals[LAST_SIGNAL], gboolean *prev_enabled, int interval, gboolean emit, guint *updated_timestamp, LocationSatellite **pre_sat, - const LocationSatellite *sat); + LocationSatellite *sat); + +void location_signaling (LocationObject *obj, guint32 signals[LAST_SIGNAL], + gboolean enabled, GList *boundary_list, + LocationPosition *cur_pos, LocationVelocity *cur_vel, LocationAccuracy *cur_acc, + guint pos_interval, guint vel_interval, + gboolean *prev_enabled, guint *prev_pos_timestamp, guint *prev_vel_timestamp, + LocationPosition **prev_pos, LocationVelocity **prev_vel, LocationAccuracy **prev_acc); G_END_DECLS diff --git a/location/manager/location-wps.c b/location/manager/location-wps.c index 511102c..affd355 100644 --- a/location/manager/location-wps.c +++ b/location/manager/location-wps.c @@ -50,13 +50,12 @@ typedef struct _LocationWpsPrivate { LocationVelocity *vel; LocationAccuracy *acc; GList *boundary_list; - guint pos_timer; - guint vel_timer; } LocationWpsPrivate; enum { PROP_0, PROP_METHOD_TYPE, + PROP_IS_STARTED, PROP_LAST_POSITION, PROP_POS_INTERVAL, PROP_VEL_INTERVAL, @@ -76,68 +75,6 @@ G_DEFINE_TYPE_WITH_CODE (LocationWps, location_wps, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (LOCATION_TYPE_IELEMENT, location_ielement_interface_init)); -static gboolean -_position_timeout_cb (gpointer data) -{ - GObject *object = (GObject *)data; - LocationWpsPrivate *priv = GET_PRIVATE(object); - if (!priv) return FALSE; - - LocationPosition *pos = NULL; - LocationAccuracy *acc = NULL; - - if (priv->pos) { - pos = location_position_copy(priv->pos); - } else { - pos = location_position_new (0, 0.0, 0.0, 0.0, LOCATION_STATUS_NO_FIX); - } - - if (priv->acc) { - acc = location_accuracy_copy (priv->acc); - } else { - acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0); - } - - LOCATION_LOGD("POSITION SERVICE_UPDATED"); - g_signal_emit(object, signals[SERVICE_UPDATED], 0, POSITION_UPDATED, pos, acc); - - location_position_free (pos); - location_accuracy_free (acc); - - return TRUE; -} - -static gboolean -_velocity_timeout_cb (gpointer data) -{ - GObject *object = (GObject *)data; - LocationWpsPrivate *priv = GET_PRIVATE(object); - if (!priv) return FALSE; - - LocationVelocity *vel = NULL; - LocationAccuracy *acc = NULL; - - if (priv->vel) { - vel = location_velocity_copy(priv->vel); - } else { - vel = location_velocity_new (0, 0.0, 0.0, 0.0); - } - - if (priv->acc) { - acc = location_accuracy_copy (priv->acc); - } else { - acc = location_accuracy_new (LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0); - } - - LOCATION_LOGD("POSITION SERVICE_UPDATED"); - g_signal_emit(object, signals[SERVICE_UPDATED], 0, VELOCITY_UPDATED, vel, acc); - - location_velocity_free (vel); - location_accuracy_free (acc); - - return TRUE; -} - static void __reset_pos_data_from_priv(LocationWpsPrivate *priv) { @@ -166,41 +103,40 @@ wps_status_cb (gboolean enabled, LOCATION_LOGD("wps_status_cb"); g_return_if_fail(self); LocationWpsPrivate* priv = GET_PRIVATE(self); - enable_signaling(self, signals, &(priv->enabled), enabled, status); - if (!priv->enabled) { - if (priv->pos_timer) { - g_source_remove (priv->pos_timer); - priv->pos_timer = 0; - } - if (priv->vel_timer) { - g_source_remove (priv->vel_timer); - priv->vel_timer = 0; - } + if (priv->enabled == TRUE && enabled == FALSE) { + enable_signaling(self, signals, &(priv->enabled), enabled, status); } } static void -wps_position_ext_cb (gboolean enabled, +wps_location_cb (gboolean enabled, LocationPosition *pos, LocationVelocity *vel, LocationAccuracy *acc, gpointer self) { - LOCATION_LOGD("wps_position_ext_cb"); + LOCATION_LOGD("wps_location_cb"); g_return_if_fail(self); g_return_if_fail(pos); g_return_if_fail(vel); g_return_if_fail(acc); LocationWpsPrivate* priv = GET_PRIVATE(self); - if (!priv->enabled && enabled) { - if (!priv->pos_timer) priv->pos_timer = g_timeout_add_seconds (priv->pos_interval, _position_timeout_cb, self); - if (!priv->vel_timer) priv->vel_timer = g_timeout_add_seconds (priv->vel_interval, _velocity_timeout_cb, self); - } - - enable_signaling(self, signals, &(priv->enabled), enabled, pos->status); - position_signaling(self, signals, &(priv->enabled), priv->pos_interval, FALSE, &(priv->pos_updated_timestamp), &(priv->pos), &(priv->acc), priv->boundary_list, pos, acc); - velocity_signaling(self, signals, &(priv->enabled), priv->vel_interval, FALSE, &(priv->vel_updated_timestamp), &(priv->vel), vel, acc); + location_signaling(self, + signals, + enabled, + priv->boundary_list, + pos, + vel, + acc, + priv->pos_interval, + priv->vel_interval, + &(priv->enabled), + &(priv->pos_updated_timestamp), + &(priv->vel_updated_timestamp), + &(priv->pos), + &(priv->vel), + &(priv->acc)); } static void @@ -228,7 +164,7 @@ location_setting_wps_cb(keynode_t *key, else { if (1 == location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED) && priv->mod->ops.start && !priv->is_started) { LOCATION_LOGD("location resumed by setting"); - ret = priv->mod->ops.start (priv->mod->handler, wps_status_cb, wps_position_ext_cb, NULL, self); + ret = priv->mod->ops.start (priv->mod->handler, wps_status_cb, wps_location_cb, NULL, self); if (ret == LOCATION_ERROR_NONE) { priv->is_started = TRUE; } @@ -253,7 +189,7 @@ location_wps_start (LocationWps *self) if (!location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED)) { ret = LOCATION_ERROR_SETTING_OFF; } else { - ret = priv->mod->ops.start (priv->mod->handler, wps_status_cb, wps_position_ext_cb, NULL, self); + ret = priv->mod->ops.start (priv->mod->handler, wps_status_cb, wps_location_cb, NULL, self); if (ret == LOCATION_ERROR_NONE) { priv->is_started = TRUE; } @@ -295,6 +231,7 @@ location_wps_stop (LocationWps *self) location_setting_ignore_notify (VCONFKEY_LOCATION_NETWORK_ENABLED, location_setting_wps_cb); priv->set_noti = FALSE; } + __reset_pos_data_from_priv(priv); return ret; @@ -310,15 +247,6 @@ location_wps_dispose (GObject *gobject) location_setting_ignore_notify (VCONFKEY_LOCATION_NETWORK_ENABLED, location_setting_wps_cb); priv->set_noti = FALSE; - if (priv->pos_timer) { - g_source_remove (priv->pos_timer); - priv->pos_timer = 0; - } - if (priv->vel_timer) { - g_source_remove (priv->vel_timer); - priv->vel_timer = 0; - } - } G_OBJECT_CLASS (location_wps_parent_class)->dispose (gobject); @@ -355,9 +283,9 @@ location_wps_finalize (GObject *gobject) static void location_wps_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) + guint property_id, + const GValue *value, + GParamSpec *pspec) { LocationWpsPrivate* priv = GET_PRIVATE(object); int ret = 0; @@ -367,13 +295,13 @@ location_wps_set_property (GObject *object, GList *boundary_list = (GList *)g_list_copy(g_value_get_pointer(value)); ret = set_prop_boundary(&priv->boundary_list, boundary_list); if(ret != 0) LOCATION_LOGD("Set boundary. Error[%d]", ret); - break; + break; } case PROP_REMOVAL_BOUNDARY: { LocationBoundary *req_boundary = (LocationBoundary*) g_value_dup_boxed(value); ret = set_prop_removal_boundary(&priv->boundary_list, req_boundary); if(ret != 0) LOCATION_LOGD("Set removal boundary. Error[%d]", ret); - break; + break; } case PROP_POS_INTERVAL: { guint interval = g_value_get_uint(value); @@ -386,11 +314,6 @@ location_wps_set_property (GObject *object, else priv->pos_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT; - if (priv->pos_timer) { - g_source_remove (priv->pos_timer); - priv->pos_timer = g_timeout_add_seconds (priv->pos_interval, _position_timeout_cb, object); - } - break; } case PROP_VEL_INTERVAL: { @@ -401,14 +324,9 @@ location_wps_set_property (GObject *object, else priv->vel_interval = (guint)LOCATION_UPDATE_INTERVAL_MAX; } - else + else { priv->vel_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT; - - if (priv->vel_timer) { - g_source_remove (priv->vel_timer); - priv->vel_timer = g_timeout_add_seconds (priv->vel_interval, _velocity_timeout_cb, object); } - break; } default: @@ -419,9 +337,9 @@ location_wps_set_property (GObject *object, static void location_wps_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) + guint property_id, + GValue *value, + GParamSpec *pspec) { LocationWpsPrivate *priv = GET_PRIVATE (object); @@ -429,6 +347,9 @@ location_wps_get_property (GObject *object, case PROP_METHOD_TYPE: g_value_set_int(value, LOCATION_METHOD_WPS); break; + case PROP_IS_STARTED: + g_value_set_boolean(value, priv->is_started); + break; case PROP_LAST_POSITION: g_value_set_boxed (value, priv->pos); break; @@ -610,6 +531,17 @@ location_wps_get_last_satellite (LocationWps *self, return LOCATION_ERROR_NOT_SUPPORTED; } +static int +location_wps_set_option (LocationWps *self, const char *option) +{ + LOCATION_LOGD("location_wps_set_option"); + LocationWpsPrivate* priv = GET_PRIVATE(self); + g_return_val_if_fail (priv->mod, LOCATION_ERROR_NOT_AVAILABLE); + g_return_val_if_fail (priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE); + //g_return_val_if_fail (priv->mod->ops.set_option, LOCATION_ERROR_NOT_AVAILABLE); + return LOCATION_ERROR_NONE; +} + static void location_ielement_interface_init (LocationIElementInterface *iface) { @@ -623,6 +555,7 @@ location_ielement_interface_init (LocationIElementInterface *iface) iface->get_last_velocity = (TYPE_GET_VELOCITY)location_wps_get_last_velocity; iface->get_satellite = (TYPE_GET_SATELLITE)location_wps_get_satellite; iface->get_last_satellite = (TYPE_GET_SATELLITE)location_wps_get_last_satellite; + iface->set_option = (TYPE_SET_OPTION)location_wps_set_option; } static void @@ -649,8 +582,6 @@ location_wps_init (LocationWps *self) priv->acc = NULL; priv->boundary_list = NULL; - priv->pos_timer = 0; - priv->vel_timer = 0; } static void @@ -731,6 +662,12 @@ location_wps_class_init (LocationWpsClass *klass) LOCATION_METHOD_WPS, G_PARAM_READABLE); + properties[PROP_IS_STARTED] = g_param_spec_boolean ("is_started", + "wps is started prop", + "wps is started status", + FALSE, + G_PARAM_READWRITE); + properties[PROP_LAST_POSITION] = g_param_spec_boxed ("last-position", "wps last position prop", "wps last position data", diff --git a/location/manager/location.c b/location/manager/location.c index 958a137..ca6a2e2 100644 --- a/location/manager/location.c +++ b/location/manager/location.c @@ -35,7 +35,6 @@ #include "location-hybrid.h" #include "location-gps.h" #include "location-wps.h" -#include "location-cps.h" #include "location-position.h" #include "map-service.h" #include "module-internal.h" @@ -73,8 +72,6 @@ location_new (LocationMethod method) self = g_object_new (LOCATION_TYPE_WPS, NULL); break; case LOCATION_METHOD_CPS: - self = g_object_new (LOCATION_TYPE_CPS, NULL); - break; default: break; } @@ -99,10 +96,6 @@ location_start (LocationObject *obj) g_return_val_if_fail (G_OBJECT_TYPE(obj) != MAP_TYPE_SERVICE, LOCATION_ERROR_PARAMETER); int ret = LOCATION_ERROR_NONE; - if (location_application_enabled() == FALSE) { - LOCATION_LOGD("Application does not have permission"); - return LOCATION_ERROR_NOT_ALLOWED; - } ret = location_ielement_start (LOCATION_IELEMENT(obj)); if (ret != LOCATION_ERROR_NONE) LOCATION_LOGD("Fail to start. Error [%d]", ret); @@ -138,8 +131,6 @@ location_is_supported_method(LocationMethod method) is_supported = module_is_supported("wps"); break; case LOCATION_METHOD_CPS: - is_supported = module_is_supported("cps"); - break; default: break; } @@ -335,33 +326,17 @@ location_set_accessibility_state (LocationAccessState state) return ret; } - EXPORT_API int location_send_command(const char *cmd) { g_return_val_if_fail (cmd, LOCATION_ERROR_PARAMETER); - int ret = LOCATION_ERROR_NOT_AVAILABLE; - - if (0 == g_strcmp0(cmd, "ADD_APPLIST")) { - if (location_application_add_app_to_applist () == FALSE) { - LOCATION_LOGD("Fail to add to applist"); - ret = LOCATION_ERROR_UNKNOWN; - } else { - ret = LOCATION_ERROR_NONE; - } - } else if (0 == g_strcmp0(cmd, "ACCESSIBILITY:1")) { - ret = location_set_accessibility_state(LOCATION_ACCESS_ALLOWED); - if (ret != LOCATION_ERROR_NONE) { - LOCATION_LOGD("Fail to set ACCESSIBILITY:1 [ret = %d]", ret); - } - } else if (0 == g_strcmp0(cmd, "ACCESSIBILITY:0")) { - ret = location_set_accessibility_state(LOCATION_ACCESS_DENIED); - if (ret != LOCATION_ERROR_NONE) { - LOCATION_LOGD("Fail to set ACCESSIBILITY:0 [ret = %d]", ret); - } - } else { - LOCATION_LOGD("Invalid CMD[%s]", cmd); - } + return LOCATION_ACCESS_NONE; +} +EXPORT_API int +location_set_option (LocationObject *obj, const char *option) +{ + g_return_val_if_fail (obj, LOCATION_ERROR_PARAMETER); + int ret = LOCATION_ERROR_NONE; return ret; } diff --git a/location/manager/location.h b/location/manager/location.h index 2a0c947..d42ae19 100644 --- a/location/manager/location.h +++ b/location/manager/location.h @@ -856,7 +856,6 @@ int location_get_accessibility_state (LocationAccessState *state); /** * @brief * Send command to the server. - * @remarks This functions is not implemneted yet. * @pre * #location_init should be called before.\n * Calling application must have glib or ecore main loop.\n @@ -871,6 +870,23 @@ int location_get_accessibility_state (LocationAccessState *state); int location_send_command(const char *cmd); /** + * @brief + * Set option of server. + * @pre + * #location_init should be called before.\n + * Calling application must have glib or ecore main loop.\n + * Calling application must have an active data connection. + * @post None. + * @param [in] obj - a #LocationObject created by #location_new + * @param [in] option - a #char + * @return int + * @retval 0 Success + * + * Please refer #LocationError for more information. + */ +int location_set_option(LocationObject *obj, const char *option); + +/** * @} @} */ |