[empathy] Support address fields



commit b89200b47a145f288a35a81625a73bb76a054599
Author: Pierre-Luc Beaudoin <pierre-luc pierlux com>
Date:   Wed Dec 10 17:27:42 2008 -0500

    Support address fields
---
 libempathy-gtk/empathy-location-manager.c |   32 +++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c
index 7ad275d..a30b4a9 100644
--- a/libempathy-gtk/empathy-location-manager.c
+++ b/libempathy-gtk/empathy-location-manager.c
@@ -278,19 +278,43 @@ position_changed_cb (GeocluePosition *position,
   }
 }
 
+static void
+address_foreach_cb (gpointer key,
+                    gpointer value,
+                    gpointer location_manager)
+{
+  if (location_manager == NULL)
+    return;
+
+  EmpathyLocationManagerPriv *priv;
+  priv = GET_PRIV (location_manager);
+
+  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,
                     GHashTable *details,
                     GeoclueAccuracy *accuracy,
-                    gpointer user_data)
+                    gpointer location_manager)
 {
   GeoclueAccuracyLevel level;
   geoclue_accuracy_get_details (accuracy, &level, NULL, NULL);
-  DEBUG ("New address (accuracy level %d):\n", level);
-  // XXX todo
-  publish_location_to_all_accounts (EMPATHY_LOCATION_MANAGER (user_data));
+  EmpathyLocationManagerPriv *priv;
+
+  DEBUG ("New address (accuracy level %d):", level);
+
+  priv = GET_PRIV (location_manager);
+  g_hash_table_remove_all (priv->location);
+
+  g_hash_table_foreach (details, address_foreach_cb, (gpointer)location_manager);
+
+  publish_location_to_all_accounts (EMPATHY_LOCATION_MANAGER (location_manager));
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]