From dedfd1e8315b0af219293f9fd470525bed1b52c8 Mon Sep 17 00:00:00 2001 From: Pierre-Luc Beaudoin Date: Tue, 2 Dec 2008 17:29:38 -0500 Subject: Set/get location on telepathy --- libempathy/empathy-tp-contact-factory.c | 49 ++++++++++++++++++++++++++++++++- libempathy/empathy-tp-contact-factory.h | 3 +- 2 files changed, 50 insertions(+), 2 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c index 7735b0f1a..3c43f5254 100644 --- a/libempathy/empathy-tp-contact-factory.c +++ b/libempathy/empathy-tp-contact-factory.c @@ -121,6 +121,17 @@ tp_contact_factory_set_aliases_cb (TpConnection *connection, } } +static void +tp_contact_factory_set_location_cb (TpProxy *proxy, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + if (error) { + DEBUG ("Error setting location: %s", error->message); + } +} + static void tp_contact_factory_set_avatar_cb (TpConnection *connection, const gchar *token, @@ -409,6 +420,20 @@ tp_contact_factory_capabilities_changed_cb (TpConnection *connection, } } +static void +tp_contact_factory_location_updated_cb (TpProxy *proxy, + guint handle, + GHashTable *location, + gpointer user_data, + GObject *weak_object) +{ + EmpathyTpContactFactory *tp_factory = EMPATHY_TP_CONTACT_FACTORY (weak_object); + EmpathyContact *contact; + + contact = tp_contact_factory_find_by_handle (tp_factory, handle); + empathy_contact_set_location (contact, location); +} + static void get_requestable_channel_classes_cb (TpProxy *connection, const GValue *value, @@ -943,6 +968,24 @@ empathy_tp_contact_factory_set_avatar (EmpathyTpContactFactory *tp_factory, } } +void +empathy_tp_contact_factory_set_location (EmpathyTpContactFactory *tp_factory, + GHashTable *location) +{ + EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory); + + g_return_if_fail (EMPATHY_IS_TP_CONTACT_FACTORY (tp_factory)); + + DEBUG ("Setting location"); + + emp_cli_connection_interface_location_call_set_location (TP_PROXY (priv->connection), + -1, + location, + tp_contact_factory_set_location_cb, + NULL, NULL, + G_OBJECT (tp_factory)); +} + static void tp_contact_factory_get_property (GObject *object, guint param_id, @@ -1047,7 +1090,11 @@ tp_contact_factory_constructor (GType type, NULL, NULL, tp_factory, NULL); - + emp_cli_connection_interface_location_connect_to_location_updated (TP_PROXY (priv->connection), + tp_contact_factory_location_updated_cb, + NULL, NULL, + G_OBJECT (tp_factory), + NULL); /* FIXME: This should be moved to TpConnection */ tp_cli_connection_interface_avatars_call_get_avatar_requirements (priv->connection, diff --git a/libempathy/empathy-tp-contact-factory.h b/libempathy/empathy-tp-contact-factory.h index 91ff2f9e7..ed11bf7e4 100644 --- a/libempathy/empathy-tp-contact-factory.h +++ b/libempathy/empathy-tp-contact-factory.h @@ -108,7 +108,8 @@ void empathy_tp_contact_factory_set_avatar (EmpathyTpC const gchar *data, gsize size, const gchar *mime_type); - +void empathy_tp_contact_factory_set_location (EmpathyTpContactFactory *tp_factory, + GHashTable *location); G_END_DECLS #endif /* __EMPATHY_TP_CONTACT_FACTORY_H__ */ -- cgit v1.2.3