aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-location-manager.c
diff options
context:
space:
mode:
authorPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-05-30 03:44:39 +0800
committerPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-06-01 23:35:33 +0800
commitb9f8f5f022fc95a59ae4a20f65b2272ecbdc84c1 (patch)
tree7445fa8c9e7d5f1581940e1882e1ce65aac9dde7 /libempathy-gtk/empathy-location-manager.c
parent07d6f0088b1428c6c64b4625c42f36e93cafa267 (diff)
downloadgsoc2013-empathy-b9f8f5f022fc95a59ae4a20f65b2272ecbdc84c1.tar
gsoc2013-empathy-b9f8f5f022fc95a59ae4a20f65b2272ecbdc84c1.tar.gz
gsoc2013-empathy-b9f8f5f022fc95a59ae4a20f65b2272ecbdc84c1.tar.bz2
gsoc2013-empathy-b9f8f5f022fc95a59ae4a20f65b2272ecbdc84c1.tar.lz
gsoc2013-empathy-b9f8f5f022fc95a59ae4a20f65b2272ecbdc84c1.tar.xz
gsoc2013-empathy-b9f8f5f022fc95a59ae4a20f65b2272ecbdc84c1.tar.zst
gsoc2013-empathy-b9f8f5f022fc95a59ae4a20f65b2272ecbdc84c1.zip
Don't use foreach to iter over a HashTable
Diffstat (limited to 'libempathy-gtk/empathy-location-manager.c')
-rw-r--r--libempathy-gtk/empathy-location-manager.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c
index ae234ee01..20ce3654a 100644
--- a/libempathy-gtk/empathy-location-manager.c
+++ b/libempathy-gtk/empathy-location-manager.c
@@ -431,29 +431,6 @@ position_changed_cb (GeocluePosition *position,
g_idle_add (publish_on_idle, location_manager);
}
-
-static void
-address_foreach_cb (gpointer key,
- gpointer value,
- gpointer location_manager)
-{
- if (location_manager == NULL)
- return;
-
- EmpathyLocationManagerPriv *priv;
- priv = GET_PRIV (location_manager);
-
- /* Discard street information if reduced accuracy is on */
- if (priv->reduce_accuracy && strcmp (key, EMPATHY_LOCATION_STREET) == 0)
- return;
-
- 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
initial_address_cb (GeoclueAddress *address,
int timestamp,
@@ -483,6 +460,8 @@ address_changed_cb (GeoclueAddress *address,
GeoclueAccuracyLevel level;
geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
EmpathyLocationManagerPriv *priv;
+ GHashTableIter iter;
+ gpointer key, value;
DEBUG ("New address (accuracy level %d):", level);
@@ -492,7 +471,21 @@ address_changed_cb (GeoclueAddress *address,
if (g_hash_table_size (details) == 0)
return;
- g_hash_table_foreach (details, address_foreach_cb, (gpointer)location_manager);
+ g_hash_table_iter_init (&iter, details);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ GValue *new_value;
+ /* do something with key and value */
+ /* Discard street information if reduced accuracy is on */
+ if (priv->reduce_accuracy && strcmp (key, EMPATHY_LOCATION_STREET) == 0)
+ continue;
+
+ new_value = tp_g_value_slice_new_string (value);
+ g_hash_table_insert (priv->location, g_strdup (key), new_value);
+
+ DEBUG ("\t - %s: %s", (char*) key, (char*) value);
+ }
+
update_timestamp (location_manager);
if (priv->idle_id == 0)