[empathy] invite-participant-dialog: filter out contacts already in the chat



commit 44162e3ac3604c3e4f14dd01b48fc32cd7fd1007
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri May 6 14:37:42 2011 +0200

    invite-participant-dialog: filter out contacts already in the chat

 src/empathy-invite-participant-dialog.c |   33 ++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/src/empathy-invite-participant-dialog.c b/src/empathy-invite-participant-dialog.c
index 30c168d..f0ce85e 100644
--- a/src/empathy-invite-participant-dialog.c
+++ b/src/empathy-invite-participant-dialog.c
@@ -166,6 +166,9 @@ filter_func (GtkTreeModel *model,
   FolksIndividual *individual;
   TpContact *contact;
   gboolean is_online;
+  GList *members, *l;
+  gboolean display;
+  TpChannel *channel;
 
   gtk_tree_model_get (model, iter,
       EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual,
@@ -181,7 +184,35 @@ filter_func (GtkTreeModel *model,
   if (contact == NULL)
     return FALSE;
 
-  return TRUE;
+  /* Filter out contacts which are already in the chat */
+  members = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (
+        self->priv->tp_chat));
+
+  display = TRUE;
+  channel = empathy_tp_chat_get_channel (self->priv->tp_chat);
+
+  for (l = members; l != NULL; l = g_list_next (l))
+    {
+      EmpathyContact *member = l->data;
+      TpHandle handle;
+
+      /* Try to get the non-channel specific handle. */
+      handle = tp_channel_group_get_handle_owner (channel,
+          empathy_contact_get_handle (member));
+      if (handle == 0)
+        handle = empathy_contact_get_handle (member);
+
+      if (handle ==  tp_contact_get_handle (contact))
+        {
+          display = FALSE;
+          break;
+        }
+    }
+
+  g_list_foreach (members, (GFunc) g_object_unref, NULL);
+  g_list_free (members);
+
+  return display;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]