aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>2008-12-12 05:07:55 +0800
committerPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-06-01 23:35:29 +0800
commit82e42143ae2ad688045554abaa686ed5a19f454d (patch)
tree2eaae7d398b870d74400de7eb58cd317e3c9fa21
parentb89200b47a145f288a35a81625a73bb76a054599 (diff)
downloadgsoc2013-empathy-82e42143ae2ad688045554abaa686ed5a19f454d.tar
gsoc2013-empathy-82e42143ae2ad688045554abaa686ed5a19f454d.tar.gz
gsoc2013-empathy-82e42143ae2ad688045554abaa686ed5a19f454d.tar.bz2
gsoc2013-empathy-82e42143ae2ad688045554abaa686ed5a19f454d.tar.lz
gsoc2013-empathy-82e42143ae2ad688045554abaa686ed5a19f454d.tar.xz
gsoc2013-empathy-82e42143ae2ad688045554abaa686ed5a19f454d.tar.zst
gsoc2013-empathy-82e42143ae2ad688045554abaa686ed5a19f454d.zip
Support all position fields
-rw-r--r--libempathy-gtk/empathy-location-manager.c51
-rw-r--r--libempathy/empathy-location.h1
2 files changed, 43 insertions, 9 deletions
diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c
index a30b4a97c..b48278baa 100644
--- a/libempathy-gtk/empathy-location-manager.c
+++ b/libempathy-gtk/empathy-location-manager.c
@@ -259,25 +259,57 @@ position_changed_cb (GeocluePosition *position,
double longitude,
double altitude,
GeoclueAccuracy *accuracy,
- gpointer user_data)
+ gpointer location_manager)
{
+ EmpathyLocationManagerPriv *priv;
+ priv = GET_PRIV (location_manager);
GeoclueAccuracyLevel level;
+ GValue *new_value;
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
DEBUG ("New position (accuracy level %d)", level);
if (level == GEOCLUE_ACCURACY_LEVEL_NONE)
return;
- if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
- fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
- DEBUG ("\t%f, %f", latitude, longitude);
+ if (fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)
+ {
+ new_value = tp_g_value_slice_new (G_TYPE_DOUBLE);
+ g_value_set_double (new_value, latitude);
+ g_hash_table_insert (priv->location, EMPATHY_LOCATION_LON, new_value);
+ DEBUG ("\t - Longitude: %f", longitude);
+ }
+ else if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE)
+ {
+ new_value = tp_g_value_slice_new (G_TYPE_DOUBLE);
+ g_value_set_double (new_value, latitude);
+ g_hash_table_insert (priv->location, EMPATHY_LOCATION_LAT, new_value);
+ DEBUG ("\t - Latitude: %f", latitude);
+ }
+ else if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE)
+ {
+ new_value = tp_g_value_slice_new (G_TYPE_DOUBLE);
+ g_value_set_double (new_value, altitude);
+ g_hash_table_insert (priv->location, EMPATHY_LOCATION_ALT, new_value);
+ DEBUG ("\t - Altitude: %f", altitude);
+ }
+
+ if (level == GEOCLUE_ACCURACY_LEVEL_DETAILED)
+ {
+ gdouble mean, horizontal, vertical;
+
+ geoclue_accuracy_get_details (accuracy, &level, &horizontal, &vertical);
+ mean = (horizontal + vertical) / 2.0;
+
+ new_value = tp_g_value_slice_new (G_TYPE_DOUBLE);
+ g_value_set_double (new_value, mean);
+ g_hash_table_insert (priv->location, EMPATHY_LOCATION_ACCURACY, new_value);
+ DEBUG ("\t - Accuracy: %f", mean);
+ }
- publish_location_to_all_accounts (EMPATHY_LOCATION_MANAGER (user_data));
- } else {
- DEBUG ("- latitude and longitude not valid.");
- }
+ publish_location_to_all_accounts (EMPATHY_LOCATION_MANAGER (location_manager));
}
+
static void
address_foreach_cb (gpointer key,
gpointer value,
@@ -289,13 +321,14 @@ address_foreach_cb (gpointer key,
EmpathyLocationManagerPriv *priv;
priv = GET_PRIV (location_manager);
- GValue *new_value = tp_g_value_slice_new (G_TYPE_STRING);
+ GValue *new_value = tp_g_value_slice_new (G_TYPE_STRING);
g_value_set_string (new_value, value);
g_hash_table_insert (priv->location, g_strdup (key), new_value);
DEBUG ("\t - %s: %s", (char*) key, (char*) value);
}
+
static void
address_changed_cb (GeoclueAddress *address,
int timestamp,
diff --git a/libempathy/empathy-location.h b/libempathy/empathy-location.h
index a5d62d3a6..0feb0e527 100644
--- a/libempathy/empathy-location.h
+++ b/libempathy/empathy-location.h
@@ -42,6 +42,7 @@ G_BEGIN_DECLS
#define EMPATHY_LOCATION_LAT "lat"
#define EMPATHY_LOCATION_LON "lon"
#define EMPATHY_LOCATION_ALT "alt"
+#define EMPATHY_LOCATION_ACCURACY "accuracy"
#define EMPATHY_LOCATION_ACCURACY_LEVEL "accuracy-level"
#define EMPATHY_LOCATION_ERROR "error"
#define EMPATHY_LOCATION_VERTICAL_ERROR_M "vertical-error-m"