aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-06 20:14:54 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-05-18 21:40:09 +0800
commit9e46660b7f36e1274ca43a47b9a011c056c35746 (patch)
treeca4e68aff5e9483dafe41da8e087ddcfbc900939
parent3cceb20e7ded94d9a797f53704b53afde9e5176f (diff)
downloadgsoc2013-empathy-9e46660b7f36e1274ca43a47b9a011c056c35746.tar
gsoc2013-empathy-9e46660b7f36e1274ca43a47b9a011c056c35746.tar.gz
gsoc2013-empathy-9e46660b7f36e1274ca43a47b9a011c056c35746.tar.bz2
gsoc2013-empathy-9e46660b7f36e1274ca43a47b9a011c056c35746.tar.lz
gsoc2013-empathy-9e46660b7f36e1274ca43a47b9a011c056c35746.tar.xz
gsoc2013-empathy-9e46660b7f36e1274ca43a47b9a011c056c35746.tar.zst
gsoc2013-empathy-9e46660b7f36e1274ca43a47b9a011c056c35746.zip
invite-participant-dialog: display only contacts on the right Connection
-rw-r--r--src/empathy-invite-participant-dialog.c91
1 files changed, 68 insertions, 23 deletions
diff --git a/src/empathy-invite-participant-dialog.c b/src/empathy-invite-participant-dialog.c
index d88d7232d..30c168dc8 100644
--- a/src/empathy-invite-participant-dialog.c
+++ b/src/empathy-invite-participant-dialog.c
@@ -121,6 +121,69 @@ view_selection_changed_cb (GtkWidget *treeview,
g_object_unref (individual);
}
+/* Return the TpContact of @individual which is on the same connection as the
+ * EmpathyTpChat */
+static TpContact *
+get_tp_contact_for_chat (EmpathyInviteParticipantDialog *self,
+ FolksIndividual *individual)
+{
+ GList *personas, *l;
+ TpConnection *chat_conn;
+
+ chat_conn = empathy_tp_chat_get_connection (self->priv->tp_chat);
+
+ personas = folks_individual_get_personas (individual);
+
+ for (l = personas; l != NULL; l = g_list_next (l))
+ {
+ TpfPersona *persona = l->data;
+ TpContact *contact;
+ TpConnection *contact_conn;
+
+ if (!TPF_IS_PERSONA (persona))
+ continue;
+
+ contact = tpf_persona_get_contact (persona);
+ if (contact == NULL)
+ continue;
+
+ contact_conn = tp_contact_get_connection (contact);
+
+ if (!tp_strdiff (tp_proxy_get_object_path (contact_conn),
+ tp_proxy_get_object_path (chat_conn)))
+ return contact;
+ }
+
+ return NULL;
+}
+
+static gboolean
+filter_func (GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ EmpathyInviteParticipantDialog *self = user_data;
+ FolksIndividual *individual;
+ TpContact *contact;
+ gboolean is_online;
+
+ gtk_tree_model_get (model, iter,
+ EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual,
+ EMPATHY_INDIVIDUAL_STORE_COL_IS_ONLINE, &is_online,
+ -1);
+
+ if (individual == NULL || !is_online)
+ return FALSE;
+
+ /* Filter out individuals not having a persona on the same connection as the
+ * EmpathyTpChat. */
+ contact = get_tp_contact_for_chat (self, individual);
+ if (contact == NULL)
+ return FALSE;
+
+ return TRUE;
+}
+
static void
empathy_invite_participant_dialog_init (EmpathyInviteParticipantDialog *self)
{
@@ -161,6 +224,9 @@ empathy_invite_participant_dialog_init (EmpathyInviteParticipantDialog *self)
self->priv->view = empathy_individual_view_new (self->priv->store,
EMPATHY_INDIVIDUAL_VIEW_FEATURE_NONE , EMPATHY_INDIVIDUAL_FEATURE_NONE);
+ empathy_individual_view_set_custom_filter (self->priv->view,
+ filter_func, self);
+
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->view));
g_signal_connect (selection, "changed",
@@ -199,34 +265,13 @@ empathy_invite_participant_dialog_get_selected (
EmpathyInviteParticipantDialog *self)
{
FolksIndividual *individual;
- GList *personas, *l;
- TpContact *contact = NULL;
+ TpContact *contact;
individual = empathy_individual_view_dup_selected (self->priv->view);
if (individual == NULL)
return NULL;
- personas = folks_individual_get_personas (individual);
-
- for (l = personas; l != NULL; l = g_list_next (l))
- {
- TpfPersona *persona = l->data;
- TpConnection *contact_conn, *chat_conn;
-
- if (!TPF_IS_PERSONA (persona))
- continue;
-
- contact = tpf_persona_get_contact (persona);
- if (contact == NULL)
- continue;
-
- contact_conn = tp_contact_get_connection (contact);
- chat_conn = empathy_tp_chat_get_connection (self->priv->tp_chat);
-
- if (!tp_strdiff (tp_proxy_get_object_path (contact_conn),
- tp_proxy_get_object_path (chat_conn)))
- break;
- }
+ contact = get_tp_contact_for_chat (self, individual);
g_object_unref (individual);
return contact;