diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-07-28 17:20:27 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-07-28 17:20:27 +0800 |
commit | 1d153c1cf91edce537bc64efb01b5a496b35518e (patch) | |
tree | de8ba4359a0341bd0c8c6e1a7495f4f39fb565f1 /libempathy/empathy-tp-chat.c | |
parent | b50b7039d3b52f33df94e5a3526d9f43a51401ad (diff) | |
parent | 6df1c4bdd81fbbb288b8e49c3bea9a1dd2e005a6 (diff) | |
download | gsoc2013-empathy-1d153c1cf91edce537bc64efb01b5a496b35518e.tar gsoc2013-empathy-1d153c1cf91edce537bc64efb01b5a496b35518e.tar.gz gsoc2013-empathy-1d153c1cf91edce537bc64efb01b5a496b35518e.tar.bz2 gsoc2013-empathy-1d153c1cf91edce537bc64efb01b5a496b35518e.tar.lz gsoc2013-empathy-1d153c1cf91edce537bc64efb01b5a496b35518e.tar.xz gsoc2013-empathy-1d153c1cf91edce537bc64efb01b5a496b35518e.tar.zst gsoc2013-empathy-1d153c1cf91edce537bc64efb01b5a496b35518e.zip |
Merge commit 'upstream/master' into mc5
Conflicts:
libempathy-gtk/empathy-account-widget.c
src/empathy.c
Diffstat (limited to 'libempathy/empathy-tp-chat.c')
-rw-r--r-- | libempathy/empathy-tp-chat.c | 65 |
1 files changed, 52 insertions, 13 deletions
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 091871034..51ce79bb6 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -876,6 +876,34 @@ tp_chat_got_added_contacts_cb (EmpathyTpContactFactory *factory, tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat)); } +static EmpathyContact * +chat_lookup_contact (EmpathyTpChat *chat, + TpHandle handle, + gboolean remove) +{ + EmpathyTpChatPriv *priv = GET_PRIV (chat); + GList *l; + + for (l = priv->members; l; l = l->next) { + EmpathyContact *c = l->data; + + if (empathy_contact_get_handle (c) != handle) { + continue; + } + + if (remove) { + /* Caller takes the reference. */ + priv->members = g_list_delete_link (priv->members, l); + } else { + g_object_ref (c); + } + + return c; + } + + return NULL; +} + static void tp_chat_group_members_changed_cb (TpChannel *self, gchar *message, @@ -889,23 +917,30 @@ tp_chat_group_members_changed_cb (TpChannel *self, { EmpathyTpChatPriv *priv = GET_PRIV (chat); EmpathyContact *contact; - TpHandle handle; + EmpathyContact *actor_contact = NULL; guint i; - GList *l; + + if (actor != 0) { + actor_contact = chat_lookup_contact (chat, actor, FALSE); + if (actor_contact == NULL) { + /* FIXME: handle this a tad more gracefully: perhaps + * the actor was a server op. We could use the + * contact-ids detail of MembersChangedDetailed. + */ + DEBUG ("actor %u not a channel member", actor); + } + } /* Remove contacts that are not members anymore */ for (i = 0; i < removed->len; i++) { - for (l = priv->members; l; l = l->next) { - contact = l->data; - handle = empathy_contact_get_handle (contact); - if (handle == g_array_index (removed, TpHandle, i)) { - priv->members = g_list_delete_link (priv->members, l); - g_signal_emit_by_name (chat, "members-changed", - contact, NULL, reason, - message, FALSE); - g_object_unref (contact); - break; - } + contact = chat_lookup_contact (chat, + g_array_index (removed, TpHandle, i), TRUE); + + if (contact != NULL) { + g_signal_emit_by_name (chat, "members-changed", contact, + actor_contact, reason, message, + FALSE); + g_object_unref (contact); } } @@ -918,6 +953,10 @@ tp_chat_group_members_changed_cb (TpChannel *self, } tp_chat_update_remote_contact (chat); + + if (actor_contact != NULL) { + g_object_unref (actor_contact); + } } static void |