aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-contact.c
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-04-08 19:51:41 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-04-08 21:51:50 +0800
commit093c7b7b64293adb9e8e31d08e557320a47dc757 (patch)
tree3da8421dce55f953c4bf71200388e7e9ee225c9a /libempathy/empathy-contact.c
parentee8b4ad4f89343de7e965a2414e1f746bd018b5a (diff)
downloadgsoc2013-empathy-093c7b7b64293adb9e8e31d08e557320a47dc757.tar
gsoc2013-empathy-093c7b7b64293adb9e8e31d08e557320a47dc757.tar.gz
gsoc2013-empathy-093c7b7b64293adb9e8e31d08e557320a47dc757.tar.bz2
gsoc2013-empathy-093c7b7b64293adb9e8e31d08e557320a47dc757.tar.lz
gsoc2013-empathy-093c7b7b64293adb9e8e31d08e557320a47dc757.tar.xz
gsoc2013-empathy-093c7b7b64293adb9e8e31d08e557320a47dc757.tar.zst
gsoc2013-empathy-093c7b7b64293adb9e8e31d08e557320a47dc757.zip
geocode_cb: don't update location if we didn't get the full position
Diffstat (limited to 'libempathy/empathy-contact.c')
-rw-r--r--libempathy/empathy-contact.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 4f554419c..387370097 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -1239,26 +1239,23 @@ geocode_cb (GeoclueGeocode *geocode,
if (error != NULL)
{
DEBUG ("Error geocoding location : %s", error->message);
- g_object_unref (geocode);
- g_object_unref (contact);
- return;
+ goto out;
}
- if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE)
- {
- new_value = tp_g_value_slice_new_double (latitude);
- g_hash_table_replace (location, g_strdup (EMPATHY_LOCATION_LAT),
- new_value);
- DEBUG ("\t - Latitude: %f", latitude);
- }
+ /* No need to change location if we didn't find the position */
+ if (!(fields & GEOCLUE_POSITION_FIELDS_LATITUDE))
+ goto out;
- if (fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)
- {
- new_value = tp_g_value_slice_new_double (longitude);
- g_hash_table_replace (location, g_strdup (EMPATHY_LOCATION_LON),
- new_value);
- DEBUG ("\t - Longitude: %f", longitude);
- }
+ if (!(fields & GEOCLUE_POSITION_FIELDS_LONGITUDE))
+ goto out;
+
+ g_hash_table_insert (location, g_strdup (EMPATHY_LOCATION_LAT),
+ tp_g_value_slice_new_double (latitude));
+ DEBUG ("\t - Latitude: %f", latitude);
+
+ g_hash_table_insert (location, g_strdup (EMPATHY_LOCATION_LON),
+ tp_g_value_slice_new_double (longitude));
+ DEBUG ("\t - Longitude: %f", longitude);
if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE)
{
@@ -1270,6 +1267,7 @@ geocode_cb (GeoclueGeocode *geocode,
/* Don't change the accuracy as we used an address to get this position */
g_object_notify (contact, "location");
+out:
g_object_unref (geocode);
g_object_unref (contact);
}