aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-04-02 22:21:23 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-04-06 23:59:10 +0800
commit3607fded92aa603e2f6135144e16b109bfb900f8 (patch)
tree739414a03cdc77cea3b3a237e83b6c9bf7f2ef66 /libempathy
parent76a5a6e1be3b8dd36421d95affc6516ca057b4dc (diff)
downloadgsoc2013-empathy-3607fded92aa603e2f6135144e16b109bfb900f8.tar
gsoc2013-empathy-3607fded92aa603e2f6135144e16b109bfb900f8.tar.gz
gsoc2013-empathy-3607fded92aa603e2f6135144e16b109bfb900f8.tar.bz2
gsoc2013-empathy-3607fded92aa603e2f6135144e16b109bfb900f8.tar.lz
gsoc2013-empathy-3607fded92aa603e2f6135144e16b109bfb900f8.tar.xz
gsoc2013-empathy-3607fded92aa603e2f6135144e16b109bfb900f8.tar.zst
gsoc2013-empathy-3607fded92aa603e2f6135144e16b109bfb900f8.zip
Get location update from TpContact (#599162)
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-contact.c23
-rw-r--r--libempathy/empathy-contact.h2
2 files changed, 21 insertions, 4 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index e5c406a6a..94d83b89d 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -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;
diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h
index 231f95b9d..002930bd5 100644
--- a/libempathy/empathy-contact.h
+++ b/libempathy/empathy-contact.h
@@ -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);