#include <glib.h>
#include <vconf.h>
+#include <vconf-internal-location-keys.h>
#include <location-module.h>
#include <geoclue/geoclue-position.h>
#include "log.h"
-#define VCONF_LOCATION_PATH "db/location"
-#define LOCATION_LAST_PATH VCONF_LOCATION_PATH"/last"
-#define GPS_LAST_PATH LOCATION_LAST_PATH"/gps"
-#define GPS_LAST_TIMESTAMP GPS_LAST_PATH"/Timestamp"
-#define GPS_LAST_LATITUDE GPS_LAST_PATH"/Latitude"
-#define GPS_LAST_LONGITUDE GPS_LAST_PATH"/Longitude"
-#define GPS_LAST_ALTITUDE GPS_LAST_PATH"/Altitude"
-#define GPS_LAST_HORACCURACY GPS_LAST_PATH"/HorAccuracy"
-#define GPS_LAST_VERACCURACY GPS_LAST_PATH"/VerAccuracy"
-#define GPS_LAST_SPEED GPS_LAST_PATH"/Speed"
-#define GPS_LAST_DIRECTION GPS_LAST_PATH"/Direction"
-
-
typedef struct {
char devname[256];
GeocluePosition *pos;
g_return_if_fail(gps_manager->sat_cb);
guint idx;
+ guint used_idx;
LocationSatellite *sat = NULL;
sat = location_satellite_new(satellite_visible);
sat->num_of_sat_inview = satellite_visible;
sat->num_of_sat_used = satellite_used;
for (idx = 0; idx < satellite_visible; idx++) {
- guint used_idx;
- gboolean used;
+ gboolean used = FALSE;
GValueArray *vals = (GValueArray *) g_ptr_array_index(sat_info, idx);
gint prn = g_value_get_int(g_value_array_get_nth(vals, 0));
gint elev = g_value_get_int(g_value_array_get_nth(vals, 1));
if (prn == g_array_index(used_prn, guint, idx)) {
used = TRUE;
break;
- } else {
- used = FALSE;
}
}
MOD_LOGD("prn[%d] : used %d elev %d azim %d snr %d", prn, used, elev, azim, snr);
ret =
g_signal_connect(G_OBJECT(GEOCLUE_PROVIDER(gps_manager->pos)),
"status-changed", G_CALLBACK(status_callback), gps_manager);
- g_debug("gsignal_connect status-changed %d", ret);
+ MOD_LOGD("gsignal_connect status-changed %d", ret);
ret =
g_signal_connect(G_OBJECT(GEOCLUE_PROVIDER(gps_manager->pos)),
"position-changed", G_CALLBACK(position_callback), gps_manager);
- g_debug("gsignal_connect position-changed %d", ret);
+ MOD_LOGD("gsignal_connect position-changed %d", ret);
ret =
g_signal_connect(G_OBJECT(GEOCLUE_PROVIDER(gps_manager->vel)),
"velocity-changed", G_CALLBACK(velocity_callback), gps_manager);
- g_debug("gsignal_connect velocity-changed %d", ret);
+ MOD_LOGD("gsignal_connect velocity-changed %d", ret);
ret =
g_signal_connect(G_OBJECT(GEOCLUE_PROVIDER(gps_manager->sat)),
"satellite-changed", G_CALLBACK(satellite_callback), gps_manager);
- g_debug("gsignal_connect satellite-changed %d", ret);
+ MOD_LOGD("gsignal_connect satellite-changed %d", ret);
ret =
g_signal_connect(G_OBJECT(GEOCLUE_PROVIDER(gps_manager->nmea)),
"nmea-changed", G_CALLBACK(nmea_callback), gps_manager);
- g_debug("gsignal_connect nmea-changed %d", ret);
+ MOD_LOGD("gsignal_connect nmea-changed %d", ret);
return TRUE;
}
if (!ref_gps_manager(gps_manager))
return LOCATION_ERROR_NOT_AVAILABLE;
+
+ GHashTable *options;
+ GError *error = NULL;
+
+ options = g_hash_table_new(g_str_hash, g_str_equal);
+ g_hash_table_insert(options, "CMD", "START");
+
+ if (!geoclue_provider_set_options(GEOCLUE_PROVIDER(gps_manager->pos), options, &error)) {
+ MOD_LOGE("Error geoclue_provider_set_options(START) : %s", error->message);
+ g_error_free(error);
+ error = NULL;
+ g_hash_table_destroy(options);
+ return LOCATION_ERROR_NOT_AVAILABLE;
+ } else {
+ MOD_LOGD("Success to geoclue_provider_set_options(START)");
+ }
+ g_hash_table_destroy(options);
+
return LOCATION_ERROR_NONE;
}
GpsManagerData *gps_manager = (GpsManagerData *) handle;
g_return_val_if_fail(gps_manager, LOCATION_ERROR_NOT_AVAILABLE);
g_return_val_if_fail(gps_manager->status_cb, LOCATION_ERROR_NOT_AVAILABLE);
+
+ GHashTable *options;
+ GError *error = NULL;
+
+ options = g_hash_table_new(g_str_hash, g_str_equal);
+ g_hash_table_insert(options, "CMD", "STOP");
+
+ if (!geoclue_provider_set_options(GEOCLUE_PROVIDER(gps_manager->pos), options, &error)) {
+ MOD_LOGE("Error geoclue_provider_set_options(STOP) : %s", error->message);
+ g_error_free(error);
+ error = NULL;
+ g_hash_table_destroy(options);
+ return LOCATION_ERROR_NOT_AVAILABLE;
+ } else {
+ MOD_LOGD("Success to geoclue_provider_set_options(STOP)");
+ }
+ g_hash_table_destroy(options);
+
unref_gps_manager(gps_manager);
gps_manager->status_cb(FALSE, LOCATION_STATUS_NO_FIX, gps_manager->userdata);
return LOCATION_ERROR_NONE;
g_return_val_if_fail(position, LOCATION_ERROR_PARAMETER);
g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
-#if 0 /* replaced by reading vconf directly */
- GeocluePositionFields fields;
- int timestamp;
- double lat, lon, alt;
- GeoclueAccuracy *_accuracy = NULL;
- GError *error = NULL;
-
- gchar *service = g_strdup_printf(GPS_MANAGER_SERVICE_NAME);
- gchar *path = g_strdup_printf(GPS_MANAGER_SERVICE_PATH);
-
- GeocluePosition *last_pos = geoclue_position_new(service, path);
-
- fields = geoclue_position_get_last_position(last_pos, ×tamp, &lat, &lon, &alt, &_accuracy, &error);
- if (error) {
- MOD_LOGD("Error getting last position: %s", error->message);
- g_error_free(error);
- g_object_unref(last_pos);
- g_free (service);
- g_free (path);
- return LOCATION_ERROR_NOT_AVAILABLE;
- }
-
- if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
- if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE)
- *position = location_position_new(timestamp, lat, lon, alt, LOCATION_STATUS_3D_FIX);
- else
- *position = location_position_new(timestamp, lat, lon, 0, LOCATION_STATUS_2D_FIX);
- } else
- *position = location_position_new(0, 0, 0, 0, LOCATION_STATUS_NO_FIX);
-
- if (_accuracy) {
- GeoclueAccuracyLevel level;
- double horiz_acc;
- double vert_acc;
- geoclue_accuracy_get_details(_accuracy, &level, &horiz_acc, &vert_acc);
- *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_DETAILED, horiz_acc, vert_acc);
- geoclue_accuracy_free(_accuracy);
- } else
- *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0, 0);
-
- g_object_unref(last_pos);
- g_free (service);
- g_free (path);
-
- return LOCATION_ERROR_NONE;
-#else
int timestamp = 0;
double longitude = 0.0, latitude = 0.0, altitude = 0.0;
double hor_accuracy = 0.0, ver_accuracy = 0.0;
LocationStatus status = LOCATION_STATUS_NO_FIX;
LocationAccuracyLevel level = LOCATION_ACCURACY_LEVEL_NONE;
- if (vconf_get_int(GPS_LAST_TIMESTAMP, ×tamp) ||
- vconf_get_dbl(GPS_LAST_LATITUDE, &latitude) ||
- vconf_get_dbl(GPS_LAST_LONGITUDE, &longitude) ||
- vconf_get_dbl(GPS_LAST_ALTITUDE, &altitude) ||
- vconf_get_dbl(GPS_LAST_HORACCURACY, &hor_accuracy) ||
- vconf_get_dbl(GPS_LAST_VERACCURACY, &ver_accuracy)) {
+ if (vconf_get_int(VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP, ×tamp) ||
+ vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_LATITUDE, &latitude) ||
+ vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_LONGITUDE, &longitude) ||
+ vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_ALTITUDE, &altitude) ||
+ vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_HOR_ACCURACY, &hor_accuracy) ||
+ vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_VER_ACCURACY, &ver_accuracy)) {
*position = NULL;
*accuracy = NULL;
return LOCATION_ERROR_NOT_AVAILABLE;
*accuracy = location_accuracy_new(level, hor_accuracy, ver_accuracy);
return LOCATION_ERROR_NONE;
-
-#endif
}
static int get_last_velocity(gpointer handle, LocationVelocity ** velocity, LocationAccuracy ** accuracy)
g_return_val_if_fail(velocity, LOCATION_ERROR_PARAMETER);
g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER);
-#if 0 /* replaced by reading vconf directly */
- GeoclueVelocityFields fields;
- int timestamp;
- double spd, dir, climb;
- GError *error = NULL;
-
- gchar *service = g_strdup_printf(GPS_MANAGER_SERVICE_NAME);
- gchar *path = g_strdup_printf(GPS_MANAGER_SERVICE_PATH);
-
- GeoclueVelocity *last_vel = geoclue_velocity_new(service, path);
-
- fields = geoclue_velocity_get_last_velocity(last_vel, ×tamp, &spd, &dir, &climb, &error);
- if (error) {
- MOD_LOGD("Error getting last velocity: %s", error->message);
- g_error_free(error);
- g_object_unref(last_vel);
- g_free (service);
- g_free (path);
- return LOCATION_ERROR_NOT_AVAILABLE;
- }
-
- if (fields & GEOCLUE_VELOCITY_FIELDS_SPEED && fields & GEOCLUE_VELOCITY_FIELDS_DIRECTION) {
- if (fields & GEOCLUE_VELOCITY_FIELDS_CLIMB)
- *velocity = location_velocity_new(timestamp, spd, dir, climb);
- else
- *velocity = location_velocity_new(timestamp, spd, dir, 0);
- *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_DETAILED, 0, 0);
- } else {
- *velocity = location_velocity_new(0, 0, 0, 0);
- *accuracy = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0, 0);
- }
-
- g_object_unref(last_vel);
- g_free (service);
- g_free (path);
-
- return LOCATION_ERROR_NONE;
-#else
gint timestamp = 0;
gdouble speed = 0.0, direction = 0.0;
gdouble hor_accuracy = 0.0, ver_accuracy = 0.0;
- if (vconf_get_int(GPS_LAST_TIMESTAMP, ×tamp) ||
- vconf_get_dbl(GPS_LAST_SPEED, &speed) ||
- vconf_get_dbl(GPS_LAST_DIRECTION, &direction) ||
- vconf_get_dbl(GPS_LAST_HORACCURACY, &hor_accuracy) ||
- vconf_get_dbl(GPS_LAST_VERACCURACY, &ver_accuracy)) {
+ if (vconf_get_int(VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP, ×tamp) ||
+ vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_SPEED, &speed) ||
+ vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_DIRECTION, &direction) ||
+ vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_HOR_ACCURACY, &hor_accuracy) ||
+ vconf_get_dbl(VCONFKEY_LOCATION_LAST_GPS_VER_ACCURACY, &ver_accuracy)) {
*velocity = NULL;
*accuracy = NULL;
return LOCATION_ERROR_NOT_AVAILABLE;;
*accuracy = location_accuracy_new (LOCATION_ACCURACY_LEVEL_DETAILED, hor_accuracy, ver_accuracy);
return LOCATION_ERROR_NONE;
-#endif
}
static int get_last_satellite(gpointer handle, LocationSatellite ** satellite)