aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>2009-01-01 04:16:38 +0800
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>2009-05-08 01:37:02 +0800
commitb5f052380c8c458dd54153840ab22b5733f14712 (patch)
tree00c89fdb6008191720ca45211824d558e2b8fff1 /libempathy
parente2cb83179f1d899c733e9d4ae07e7c9ab619ef8d (diff)
downloadgsoc2013-empathy-b5f052380c8c458dd54153840ab22b5733f14712.tar
gsoc2013-empathy-b5f052380c8c458dd54153840ab22b5733f14712.tar.gz
gsoc2013-empathy-b5f052380c8c458dd54153840ab22b5733f14712.tar.bz2
gsoc2013-empathy-b5f052380c8c458dd54153840ab22b5733f14712.tar.lz
gsoc2013-empathy-b5f052380c8c458dd54153840ab22b5733f14712.tar.xz
gsoc2013-empathy-b5f052380c8c458dd54153840ab22b5733f14712.tar.zst
gsoc2013-empathy-b5f052380c8c458dd54153840ab22b5733f14712.zip
Move get_location to the right place
This will make the location requested upon contact creation
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-tp-contact-factory.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c
index 5c861a716..fad4625d6 100644
--- a/libempathy/empathy-tp-contact-factory.c
+++ b/libempathy/empathy-tp-contact-factory.c
@@ -315,6 +315,21 @@ tp_contact_factory_avatar_updated_cb (TpConnection *connection,
}
static void
+tp_contact_factory_update_location (EmpathyTpContactFactory *tp_factory,
+ guint handle,
+ GHashTable *location)
+{
+ EmpathyContact *contact;
+
+ contact = tp_contact_factory_find_by_handle (tp_factory, handle);
+ if (!contact) {
+ return;
+ }
+
+ empathy_contact_set_location (contact, location);
+}
+
+static void
tp_contact_factory_update_capabilities (EmpathyTpContactFactory *tp_factory,
guint handle,
const gchar *channel_type,
@@ -391,6 +406,35 @@ tp_contact_factory_got_capabilities (EmpathyTpContactFactory *tp_factory,
}
static void
+tp_contact_factory_got_locations (EmpathyTpContactFactory *tp_factory,
+ GHashTable *locations,
+ const GError *error)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ /* FIXME Should set the capabilities of the contacts for which this request
+ * originated to NONE */
+ return;
+ }
+
+ g_hash_table_iter_init (&iter, locations);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ /* do something with key and value */
+ guint handle = GPOINTER_TO_INT (key);
+ GHashTable *location = value;
+
+ tp_contact_factory_update_location (tp_factory,
+ handle,
+ location);
+ }
+
+ g_hash_table_unref (locations);
+}
+
+static void
tp_contact_factory_capabilities_changed_cb (TpConnection *connection,
const GPtrArray *capabilities,
gpointer user_data,
@@ -548,6 +592,7 @@ tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory,
GArray handles = {(gchar*) &handle, 1};
GHashTable *tokens;
GPtrArray *capabilities;
+ GHashTable *locations;
GError *error = NULL;
/* Keep a weak ref to that contact */
@@ -595,6 +640,14 @@ tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory,
&error,
NULL);
tp_contact_factory_got_capabilities (tp_factory, capabilities, error);
+
+ emp_cli_connection_interface_location_run_get_locations (TP_PROXY (priv->connection),
+ -1,
+ &handles,
+ &locations,
+ &error,
+ NULL);
+ tp_contact_factory_got_locations (tp_factory, locations, error);
g_clear_error (&error);
DEBUG ("Contact added: %s (%d)",