#include <vconf-internal-location-keys.h>
-/*
- * forward definitions
- */
-
typedef struct _LocationPassivePrivate {
- LocationPassiveMod *mod;
+ LocationPassiveMod *mod;
GMutex mutex;
gboolean is_started;
guint app_type;
gboolean enabled;
guint pos_updated_timestamp;
guint vel_updated_timestamp;
+ guint sat_updated_timestamp;
guint loc_updated_timestamp;
guint dist_updated_timestamp;
guint pos_interval;
guint vel_interval;
+ guint sat_interval;
guint loc_interval;
guint loc_timeout;
guint min_interval;
LocationPosition *pos;
LocationVelocity *vel;
LocationAccuracy *acc;
+ LocationSatellite *sat;
GList *boundary_list;
} LocationPassivePrivate;
PROP_LAST_POSITION,
PROP_POS_INTERVAL,
PROP_VEL_INTERVAL,
+ PROP_SAT_INTERVAL,
PROP_LOC_INTERVAL,
PROP_BOUNDARY,
PROP_REMOVAL_BOUNDARY,
+ PROP_SATELLITE,
PROP_MIN_INTERVAL,
PROP_MIN_DISTANCE,
PROP_SERVICE_STATUS,
location_velocity_free(priv->vel);
priv->vel = NULL;
}
+ if (priv->sat) {
+ location_satellite_free(priv->sat);
+ priv->sat = NULL;
+ }
if (priv->acc) {
location_accuracy_free(priv->acc);
priv->acc = NULL;
}
priv->pos_updated_timestamp = 0;
priv->vel_updated_timestamp = 0;
+ priv->sat_updated_timestamp = 0;
+ priv->loc_updated_timestamp = 0;
}
static gboolean __get_started(gpointer self)
return 0;
}
-static void passive_gps_cb(keynode_t * key, gpointer self)
+static void passive_location_cb(gboolean enabled, LocationPosition *pos, LocationVelocity *vel, LocationAccuracy *acc, gpointer self)
{
- LOC_FUNC_LOG
- g_return_if_fail(key);
g_return_if_fail(self);
+ g_return_if_fail(pos);
+ g_return_if_fail(vel);
+ g_return_if_fail(acc);
+
LocationPassivePrivate *priv = GET_PRIVATE(self);
g_return_if_fail(priv);
- g_return_if_fail(priv->mod);
- g_return_if_fail(priv->mod->handler);
-
- LocationPosition *pos = NULL;
- LocationVelocity *vel = NULL;
- LocationAccuracy *acc = NULL;
-
- LocModPassiveOps ops = priv->mod->ops;
- int ret = ops.get_last_position(priv->mod->handler, &pos, &vel, &acc);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Fail to get position[%d]", ret);
- return ;
- }
- location_signaling(self, signals, TRUE, priv->boundary_list,
- pos, vel, acc, priv->pos_interval, priv->vel_interval, priv->loc_interval,
- &(priv->enabled), &(priv->pos_updated_timestamp),
- &(priv->vel_updated_timestamp), &(priv->loc_updated_timestamp),
- &(priv->pos), &(priv->vel), &(priv->acc));
+ location_signaling(self, signals, enabled, priv->boundary_list, pos, vel, acc,
+ priv->pos_interval, priv->vel_interval, priv->loc_interval, &(priv->enabled),
+ &(priv->pos_updated_timestamp), &(priv->vel_updated_timestamp),
+ &(priv->loc_updated_timestamp), &(priv->pos), &(priv->vel), &(priv->acc));
}
-static void passive_wps_cb(keynode_t *key, gpointer self)
+static void passive_satellite_cb(gboolean enabled, LocationSatellite *sat, gpointer self)
{
- LOC_FUNC_LOG
- g_return_if_fail(key);
g_return_if_fail(self);
LocationPassivePrivate *priv = GET_PRIVATE(self);
g_return_if_fail(priv);
- g_return_if_fail(priv->mod);
- g_return_if_fail(priv->mod->handler);
-
- LocationPosition *pos = NULL;
- LocationVelocity *vel = NULL;
- LocationAccuracy *acc = NULL;
- LocModPassiveOps ops = priv->mod->ops;
- int ret = ops.get_last_wps_position(priv->mod->handler, &pos, &vel, &acc);
- if (ret != LOCATION_ERROR_NONE) {
- LOCATION_LOGE("Fail to get position[%d]", ret);
- return ;
- }
-
- if (location_setting_get_int(VCONFKEY_LOCATION_GPS_STATE) == VCONFKEY_LOCATION_GPS_CONNECTED)
- return ;
-
- location_signaling(self, signals, TRUE, priv->boundary_list,
- pos, vel, acc, priv->pos_interval, priv->vel_interval, priv->loc_interval,
- &(priv->enabled), &(priv->pos_updated_timestamp),
- &(priv->vel_updated_timestamp), &(priv->loc_updated_timestamp),
- &(priv->pos), &(priv->vel), &(priv->acc));
+ satellite_signaling(self, signals, &(priv->enabled), priv->sat_interval, TRUE, &(priv->sat_updated_timestamp), &(priv->sat), sat);
}
static int location_passive_start(LocationPassive *self)
g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
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);
- LOC_COND_RET(__get_started(self) == TRUE, LOCATION_ERROR_NONE, _E, "__get_started. Error[%s]", err_msg(LOCATION_ERROR_NONE));
+ LOC_COND_RET(__get_started(self) == TRUE, LOCATION_ERROR_NONE, _E, "Passive already started. Error[%s]", err_msg(LOCATION_ERROR_NONE));
int ret = LOCATION_ERROR_NONE;
} else {
__set_started(self, TRUE);
- ret = location_setting_add_notify(VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP, passive_gps_cb, self);
- LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Add vconf notify. Error[%s]", err_msg(ret));
-
- ret = location_setting_add_notify(VCONFKEY_LOCATION_LAST_WPS_TIMESTAMP, passive_wps_cb, self);
- LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Add vconf notify. Error[%s]", err_msg(ret));
+ ret = priv->mod->ops.start(priv->mod->handler, 1, NULL, passive_location_cb, passive_satellite_cb, self);
+ if (ret != LOCATION_ERROR_NONE) {
+ LOCATION_LOGE("Fail to start gps. Error[%d]", ret);
+ __set_started(self, FALSE);
+ return ret;
+ }
}
if (priv->app_type != CPPAPP && priv->set_noti == FALSE)
g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
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 (__get_started(self) == TRUE) {
__set_started(self, FALSE);
+ ret = priv->mod->ops.stop(priv->mod->handler);
+ LOC_IF_FAIL_LOG(ret, _E, "Failed to stop [%s]", err_msg(ret));
g_signal_emit(self, signals[SERVICE_DISABLED], 0, LOCATION_STATUS_NO_FIX);
}
G_OBJECT_CLASS(location_passive_parent_class)->finalize(gobject);
}
+static guint get_valid_interval(guint interval, int max_interval, int min_interval)
+{
+ if (interval > max_interval)
+ return (guint)max_interval;
+ else if (interval < min_interval)
+ return (guint)min_interval;
+ else
+ return interval;
+}
+
static void location_passive_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
LocationPassivePrivate *priv = GET_PRIVATE(object);
}
break;
}
+ case PROP_SAT_INTERVAL: {
+ guint interval = g_value_get_uint(value);
+ LOCATION_LOGD("Set prop>> PROP_SAT_INTERVAL: %u", interval);
+ priv->sat_interval = get_valid_interval(interval, LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_MIN);
+ break;
+ }
case PROP_LOC_INTERVAL: {
guint interval = g_value_get_uint(value);
LOCATION_LOGD("Set prop>> PROP_LOC_INTERVAL: %u", interval);
{
LocationPassivePrivate *priv = GET_PRIVATE(object);
g_return_if_fail(priv);
+ g_return_if_fail(priv->mod);
+ g_return_if_fail(priv->mod->handler);
+ LocModPassiveOps ops = priv->mod->ops;
switch (property_id) {
case PROP_METHOD_TYPE:
case PROP_VEL_INTERVAL:
g_value_set_uint(value, priv->vel_interval);
break;
+ case PROP_SAT_INTERVAL:
+ g_value_set_uint(value, priv->sat_interval);
+ break;
case PROP_LOC_INTERVAL:
g_value_set_uint(value, priv->loc_interval);
break;
case PROP_MIN_DISTANCE:
g_value_set_double(value, priv->min_distance);
break;
+ case PROP_SATELLITE: {
+ LocationSatellite *satellite = NULL;
+ if (ops.get_satellite && priv->mod->handler && LOCATION_ERROR_NONE == ops.get_satellite(priv->mod->handler, &satellite) && satellite) {
+ LOCATION_LOGD("Get prop>> Last sat: num_used(%d) num_view(%d)", satellite->num_of_sat_used, satellite->num_of_sat_inview);
+ g_value_set_boxed(value, satellite);
+ location_satellite_free(satellite);
+ } else {
+ LOCATION_LOGW("Get prop>> Last sat: failed");
+ g_value_set_boxed(value, NULL);
+ }
+ break;
+ }
case PROP_SERVICE_STATUS:
g_value_set_int(value, priv->enabled);
break;
static int location_passive_get_position(LocationPassive *self, LocationPosition **position, LocationAccuracy **accuracy)
{
+ LOC_FUNC_LOG
int ret = LOCATION_ERROR_NOT_AVAILABLE;
LocationPassivePrivate *priv = GET_PRIVATE(self);
static int location_passive_get_position_ext(LocationPassive *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
{
+ LOC_FUNC_LOG
int ret = LOCATION_ERROR_NOT_AVAILABLE;
LocationPassivePrivate *priv = GET_PRIVATE(self);
static int location_passive_get_last_position(LocationPassive *self, LocationPosition **position, LocationAccuracy **accuracy)
{
+ LOC_FUNC_LOG
LocationPassivePrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
static int location_passive_get_last_position_ext(LocationPassive *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
{
+ LOC_FUNC_LOG
LocationPassivePrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
static int location_passive_get_last_velocity(LocationPassive *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
{
+ LOC_FUNC_LOG
LocationPassivePrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE);
return ret;
}
+static int location_passive_get_satellite(LocationPassive *self, LocationSatellite **satellite)
+{
+ LOC_FUNC_LOG
+ LocationPassivePrivate *priv = GET_PRIVATE(self);
+ g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
+ setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
+
+ LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Passive is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
+
+ int ret = LOCATION_ERROR_NOT_AVAILABLE;
+ if (priv->sat) {
+ *satellite = location_satellite_copy(priv->sat);
+ ret = LOCATION_ERROR_NONE;
+ }
+
+ return ret;
+}
+
+static int location_passive_get_last_satellite(LocationPassive *self, LocationSatellite **satellite)
+{
+ LOC_FUNC_LOG
+ return location_passive_get_satellite(self, satellite);
+}
+
+static int location_passive_set_option(LocationPassive *self, const char *option)
+{
+ LOC_FUNC_LOG
+ return LOCATION_ERROR_NONE;
+}
+
static int location_passive_request_single_location(LocationPassive *self, int timeout)
{
+ LOC_FUNC_LOG
return LOCATION_ERROR_NOT_SUPPORTED;
}
-static int location_passive_get_satellite(LocationPassive *self, LocationSatellite **satellite)
+static int location_passive_cancel_single_location(LocationPassive *self, int timeout)
{
+ LOC_FUNC_LOG
return LOCATION_ERROR_NOT_SUPPORTED;
}
-static int location_passive_get_last_satellite(LocationPassive *self, LocationSatellite **satellite)
+static int location_passive_get_nmea(LocationPassive *self, char **nmea_data)
{
+ LOC_FUNC_LOG
return LOCATION_ERROR_NOT_SUPPORTED;
}
-static int location_passive_set_option(LocationPassive *self, const char *option)
+static int location_passive_set_mock_location(LocationPassive *self, LocationPosition *position, LocationVelocity *velocity, LocationAccuracy *accuracy)
{
- LocationPassivePrivate *priv = GET_PRIVATE(self);
- g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
-
- return LOCATION_ERROR_NONE;
+ LOC_FUNC_LOG
+ return LOCATION_ERROR_NOT_SUPPORTED;
}
-static int location_passive_get_nmea(LocationPassive *self, char **nmea_data)
+static int location_passive_clear_mock_location(LocationPassive *self)
{
+ LOC_FUNC_LOG
return LOCATION_ERROR_NOT_SUPPORTED;
}
iface->get_last_satellite = (TYPE_GET_SATELLITE)location_passive_get_last_satellite;
iface->set_option = (TYPE_SET_OPTION)location_passive_set_option;
iface->request_single_location = (TYPE_REQUEST_SINGLE_LOCATION)location_passive_request_single_location;
+ iface->cancel_single_location = (TYPE_CANCEL_SINGLE_LOCATION)location_passive_cancel_single_location;
iface->get_nmea = (TYPE_GET_NMEA)location_passive_get_nmea;
+ iface->set_mock_location = (TYPE_SET_MOCK_LOCATION) location_passive_set_mock_location;
+ iface->clear_mock_location = (TYPE_CLEAR_MOCK_LOCATION) location_passive_clear_mock_location;
}
static void location_passive_init(LocationPassive *self)
priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+ priv->sat_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
priv->loc_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
priv->min_interval = LOCATION_UPDATE_INTERVAL_NONE;
priv->pos_updated_timestamp = 0;
priv->vel_updated_timestamp = 0;
+ priv->sat_updated_timestamp = 0;
priv->loc_updated_timestamp = 0;
priv->pos = NULL;
priv->vel = NULL;
priv->acc = NULL;
+ priv->sat = NULL;
priv->boundary_list = NULL;
priv->loc_timeout = 0;
priv->app_type = location_get_app_type(NULL);
- if (priv->app_type == 0)
- LOCATION_LOGW("Fail to get app_type");
+ LOC_COND_LOG(priv->app_type == 0, _W, "[Info] Fail to get app_type");
}
static void location_passive_class_init(LocationPassiveClass *klass)
"passive velocity interval data", LOCATION_UPDATE_INTERVAL_MIN,
LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
+ properties[PROP_SAT_INTERVAL] =
+ g_param_spec_uint("sat-interval", "passive satellite interval prop",
+ "passive satellite interval data", LOCATION_UPDATE_INTERVAL_MIN,
+ LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
+
properties[PROP_LOC_INTERVAL] =
g_param_spec_uint("loc-interval", "passive location interval prop",
"passive location interval data", LOCATION_UPDATE_INTERVAL_MIN,
g_param_spec_boxed("removal-boundary", "passive removal boundary prop",
"passive removal boundary data", LOCATION_TYPE_BOUNDARY, G_PARAM_READWRITE);
- /* Tizen 3.0 */
+ properties[PROP_SATELLITE] =
+ g_param_spec_boxed("satellite", "passive satellite prop",
+ "passive satellite data", LOCATION_TYPE_SATELLITE, G_PARAM_READABLE);
+
properties[PROP_SERVICE_STATUS] =
g_param_spec_int("service-status", "location service status prop",
"location service status data", LOCATION_STATUS_NO_FIX,