]> git.0d.be Git - empathy.git/commitdiff
Only remove the address fields and position fields instead of all
authorPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>
Mon, 1 Jun 2009 15:10:23 +0000 (11:10 -0400)
committerPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>
Mon, 1 Jun 2009 15:35:34 +0000 (11:35 -0400)
libempathy-gtk/empathy-location-manager.c

index 27cfb4ee619925c606b5b3aa3647169aed6609c7..1acdb3b9962a4f7a1f519bae3ae11035c8ed5c00 100644 (file)
@@ -293,7 +293,12 @@ address_changed_cb (GeoclueAddress *address,
   DEBUG ("New address (accuracy level %d):", level);
 
   geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
-  g_hash_table_remove_all (priv->location);
+  g_hash_table_remove (priv->location, EMPATHY_LOCATION_STREET);
+  g_hash_table_remove (priv->location, EMPATHY_LOCATION_AREA);
+  g_hash_table_remove (priv->location, EMPATHY_LOCATION_REGION);
+  g_hash_table_remove (priv->location, EMPATHY_LOCATION_COUNTRY);
+  g_hash_table_remove (priv->location, EMPATHY_LOCATION_COUNTRY_CODE);
+  g_hash_table_remove (priv->location, EMPATHY_LOCATION_POSTAL_CODE);
 
   if (g_hash_table_size (details) == 0)
     return;
@@ -351,6 +356,7 @@ position_changed_cb (GeocluePosition *position,
   gdouble mean, horizontal, vertical;
   GValue *new_value;
 
+
   geoclue_accuracy_get_details (accuracy, &level, &horizontal, &vertical);
   DEBUG ("New position (accuracy level %d)", level);
   if (level == GEOCLUE_ACCURACY_LEVEL_NONE)
@@ -364,30 +370,48 @@ position_changed_cb (GeocluePosition *position,
           new_value);
       DEBUG ("\t - Longitude: %f", longitude);
     }
+  else
+    {
+      g_hash_table_remove (priv->location, EMPATHY_LOCATION_LON);
+    }
+
   if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE)
     {
       latitude += priv->reduce_value;
       new_value = tp_g_value_slice_new_double (latitude);
-      g_hash_table_insert (priv->location, g_strdup (EMPATHY_LOCATION_LAT),
+      g_hash_table_replace (priv->location, g_strdup (EMPATHY_LOCATION_LAT),
           new_value);
       DEBUG ("\t - Latitude: %f", latitude);
     }
+  else
+    {
+      g_hash_table_remove (priv->location, EMPATHY_LOCATION_LAT);
+    }
+
   if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE)
     {
       new_value = tp_g_value_slice_new_double (altitude);
-      g_hash_table_insert (priv->location, g_strdup (EMPATHY_LOCATION_ALT),
+      g_hash_table_replace (priv->location, g_strdup (EMPATHY_LOCATION_ALT),
           new_value);
       DEBUG ("\t - Altitude: %f", altitude);
     }
+  else
+    {
+      g_hash_table_remove (priv->location, EMPATHY_LOCATION_ALT);
+    }
 
   if (level == GEOCLUE_ACCURACY_LEVEL_DETAILED)
     {
       mean = (horizontal + vertical) / 2.0;
       new_value = tp_g_value_slice_new_double (mean);
-      g_hash_table_insert (priv->location,
+      g_hash_table_replace (priv->location,
           g_strdup (EMPATHY_LOCATION_ACCURACY), new_value);
       DEBUG ("\t - Accuracy: %f", mean);
     }
+  else
+    {
+      g_hash_table_remove (priv->location, EMPATHY_LOCATION_ACCURACY);
+    }
 
   update_timestamp (location_manager);
   if (priv->timeout_id == 0)