diff options
author | Pierre-Luc Beaudoin <pierre-luc@pierlux.com> | 2008-12-12 05:07:55 +0800 |
---|---|---|
committer | Pierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk> | 2009-06-01 23:35:29 +0800 |
commit | 82e42143ae2ad688045554abaa686ed5a19f454d (patch) | |
tree | 2eaae7d398b870d74400de7eb58cd317e3c9fa21 /libempathy-gtk | |
parent | b89200b47a145f288a35a81625a73bb76a054599 (diff) | |
download | gsoc2013-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
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-location-manager.c | 51 |
1 files changed, 42 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, |