]> git.0d.be Git - empathy.git/commitdiff
Get location update from TpContact (#599162)
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 2 Apr 2010 14:21:23 +0000 (16:21 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 6 Apr 2010 15:59:10 +0000 (17:59 +0200)
libempathy/empathy-contact.c
libempathy/empathy-contact.h

index e5c406a6a470bd3a4680cdf13d33300cea9a4190..94d83b89d387a95010a7650159c8d3bb94a23e88 100644 (file)
@@ -60,6 +60,9 @@ typedef struct {
   /* Location is composed of string keys and GValues.
    * Example: a "city" key would have "Helsinki" as string GValue,
    *          a "latitude" would have 65.0 as double GValue.
+   *
+   * This is a super set of the location stored in TpContact as we can try add
+   * more fields by searching the address using geoclue.
    */
   GHashTable *location;
 } EmpathyContactPriv;
@@ -72,6 +75,9 @@ static void contact_set_property (GObject *object, guint param_id,
 
 static void update_geocode (EmpathyContact *contact);
 
+static void empathy_contact_set_location (EmpathyContact *contact,
+    GHashTable *location);
+
 G_DEFINE_TYPE (EmpathyContact, empathy_contact, G_TYPE_OBJECT);
 
 enum
@@ -122,6 +128,14 @@ tp_contact_notify_cb (TpContact *tp_contact,
     g_object_notify (contact, "id");
   else if (!tp_strdiff (param->name, "handle"))
     g_object_notify (contact, "handle");
+  else if (!tp_strdiff (param->name, "location"))
+    {
+      GHashTable *location;
+
+      location = tp_contact_get_location (tp_contact);
+      /* This will start a geoclue search to find the address if needed */
+      empathy_contact_set_location (EMPATHY_CONTACT (contact), location);
+    }
 }
 
 static void
@@ -302,6 +316,7 @@ set_tp_contact (EmpathyContact *contact,
                 TpContact *tp_contact)
 {
   EmpathyContactPriv *priv = GET_PRIV (contact);
+  GHashTable *location;
 
   if (tp_contact == NULL)
     return;
@@ -310,6 +325,10 @@ set_tp_contact (EmpathyContact *contact,
   priv->tp_contact = g_object_ref (tp_contact);
   priv->presence = empathy_contact_get_presence (contact);
 
+  location = tp_contact_get_location (tp_contact);
+  if (location != NULL)
+    empathy_contact_set_location (contact, location);
+
   g_signal_connect (priv->tp_contact, "notify",
     G_CALLBACK (tp_contact_notify_cb), contact);
 }
@@ -1128,9 +1147,9 @@ empathy_contact_get_location (EmpathyContact *contact)
  * Example: a "city" key would have "Helsinki" as string GValue,
  *          a "latitude" would have 65.0 as double GValue.
  */
-void
+static void
 empathy_contact_set_location (EmpathyContact *contact,
-                              GHashTable *location)
+    GHashTable *location)
 {
   EmpathyContactPriv *priv;
 
index 231f95b9d5e3d7f556eb801f332b09102b3f7240..002930bd56b9e73adfc97fff29a20b2328c690f2 100644 (file)
@@ -132,8 +132,6 @@ gboolean empathy_avatar_save_to_file (EmpathyAvatar *avatar,
     const gchar *filename, GError **error);
 
 GHashTable * empathy_contact_get_location (EmpathyContact *contact);
-void empathy_contact_set_location (EmpathyContact *contact,
-    GHashTable *location);
 gboolean empathy_contact_equal (gconstpointer contact1,
     gconstpointer contact2);