aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-tp-chat.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-03-04 18:41:28 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-04-22 18:21:13 +0800
commit9b9fcd3ce3b9c7fdc62836821d83377bec58d0a5 (patch)
tree78925c31878880bc82163cb02e9e38e7fe0679cf /libempathy/empathy-tp-chat.c
parentdcd115814f40de200c3cf4da6693de84489592ac (diff)
downloadgsoc2013-empathy-9b9fcd3ce3b9c7fdc62836821d83377bec58d0a5.tar
gsoc2013-empathy-9b9fcd3ce3b9c7fdc62836821d83377bec58d0a5.tar.gz
gsoc2013-empathy-9b9fcd3ce3b9c7fdc62836821d83377bec58d0a5.tar.bz2
gsoc2013-empathy-9b9fcd3ce3b9c7fdc62836821d83377bec58d0a5.tar.lz
gsoc2013-empathy-9b9fcd3ce3b9c7fdc62836821d83377bec58d0a5.tar.xz
gsoc2013-empathy-9b9fcd3ce3b9c7fdc62836821d83377bec58d0a5.tar.zst
gsoc2013-empathy-9b9fcd3ce3b9c7fdc62836821d83377bec58d0a5.zip
Change EmpathyTpContactFactory API to look more like TpConnection. Add function to get only one contact from
id/handle.
Diffstat (limited to 'libempathy/empathy-tp-chat.c')
-rw-r--r--libempathy/empathy-tp-chat.c86
1 files changed, 61 insertions, 25 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 8bb6567dc..bc99ba513 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -208,11 +208,21 @@ tp_chat_emit_queued_messages (EmpathyTpChat *chat)
static void
tp_chat_got_sender_cb (EmpathyTpContactFactory *factory,
- GList *contacts,
+ EmpathyContact *contact,
+ const GError *error,
gpointer message,
GObject *chat)
{
- empathy_message_set_sender (message, contacts->data);
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ /* Do not block the message queue, just drop this message */
+ g_queue_remove (priv->messages_queue, message);
+ } else {
+ empathy_message_set_sender (message, contact);
+ }
+
tp_chat_emit_queued_messages (EMPATHY_TP_CHAT (chat));
}
@@ -240,8 +250,8 @@ tp_chat_build_message (EmpathyTpChat *chat,
empathy_message_set_sender (message, priv->user);
tp_chat_emit_queued_messages (chat);
} else {
- empathy_tp_contact_factory_get_from_handles (priv->factory,
- 1, &from_handle,
+ empathy_tp_contact_factory_get_from_handle (priv->factory,
+ from_handle,
tp_chat_got_sender_cb,
message, NULL, G_OBJECT (chat));
}
@@ -362,13 +372,18 @@ typedef struct {
static void
tp_chat_state_changed_got_contact_cb (EmpathyTpContactFactory *factory,
- GList *contacts,
+ EmpathyContact *contact,
+ const GError *error,
gpointer user_data,
GObject *chat)
{
- EmpathyContact *contact = contacts->data;
TpChannelChatState state;
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ return;
+ }
+
state = GPOINTER_TO_UINT (user_data);
DEBUG ("Chat state changed for %s (%d): %d",
empathy_contact_get_name (contact),
@@ -386,7 +401,7 @@ tp_chat_state_changed_cb (TpChannel *channel,
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
- empathy_tp_contact_factory_get_from_handles (priv->factory, 1, &handle,
+ empathy_tp_contact_factory_get_from_handle (priv->factory, handle,
tp_chat_state_changed_got_contact_cb, GUINT_TO_POINTER (state),
NULL, chat);
}
@@ -825,19 +840,28 @@ tp_chat_update_remote_contact (EmpathyTpChat *chat)
static void
tp_chat_got_added_contacts_cb (EmpathyTpContactFactory *factory,
- GList *contacts,
+ guint n_contacts,
+ EmpathyContact * const * contacts,
+ guint n_failed,
+ const TpHandle *failed,
+ const GError *error,
gpointer user_data,
GObject *chat)
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
- GList *l;
+ guint i;
const TpIntSet *members;
TpHandle handle;
EmpathyContact *contact;
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ return;
+ }
+
members = tp_channel_group_get_members (priv->channel);
- for (l = contacts; l; l = l->next) {
- contact = l->data;
+ for (i = 0; i < n_contacts; i++) {
+ contact = contacts[i];
handle = empathy_contact_get_handle (contact);
/* Make sure the contact is still member */
@@ -899,13 +923,20 @@ tp_chat_group_members_changed_cb (TpChannel *self,
static void
tp_chat_got_remote_contact_cb (EmpathyTpContactFactory *factory,
- GList *contacts,
- gpointer user_data,
- GObject *chat)
+ EmpathyContact *contact,
+ const GError *error,
+ gpointer user_data,
+ GObject *chat)
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
- priv->remote_contact = g_object_ref (contacts->data);
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ empathy_tp_chat_close (EMPATHY_TP_CHAT (chat));
+ return;
+ }
+
+ priv->remote_contact = g_object_ref (contact);
g_object_notify (chat, "remote-contact");
tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
@@ -913,13 +944,20 @@ tp_chat_got_remote_contact_cb (EmpathyTpContactFactory *factory,
static void
tp_chat_got_self_contact_cb (EmpathyTpContactFactory *factory,
- GList *contacts,
+ EmpathyContact *contact,
+ const GError *error,
gpointer user_data,
GObject *chat)
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
- priv->user = g_object_ref (contacts->data);
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ empathy_tp_chat_close (EMPATHY_TP_CHAT (chat));
+ return;
+ }
+
+ priv->user = g_object_ref (contact);
empathy_contact_set_is_user (priv->user, TRUE);
tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
}
@@ -940,9 +978,8 @@ tp_chat_get_self_handle_cb (TpConnection *connection,
return;
}
- empathy_tp_contact_factory_get_from_handles (priv->factory,
- 1, &self_handle,
- tp_chat_got_self_contact_cb,
+ empathy_tp_contact_factory_get_from_handle (priv->factory,
+ self_handle, tp_chat_got_self_contact_cb,
NULL, NULL, chat);
}
@@ -973,9 +1010,8 @@ tp_chat_constructor (GType type,
/* Get self contact from the group's self handle */
handle = tp_channel_group_get_self_handle (priv->channel);
- empathy_tp_contact_factory_get_from_handles (priv->factory,
- 1, &handle,
- tp_chat_got_self_contact_cb,
+ empathy_tp_contact_factory_get_from_handle (priv->factory,
+ handle, tp_chat_got_self_contact_cb,
NULL, NULL, chat);
/* Get initial member contacts */
@@ -994,8 +1030,8 @@ tp_chat_constructor (GType type,
/* Get the remote contact */
handle = tp_channel_get_handle (priv->channel, NULL);
- empathy_tp_contact_factory_get_from_handles (priv->factory,
- 1, &handle, tp_chat_got_remote_contact_cb,
+ empathy_tp_contact_factory_get_from_handle (priv->factory,
+ handle, tp_chat_got_remote_contact_cb,
NULL, NULL, chat);
}