]> git.0d.be Git - empathy.git/commitdiff
Implement TpContact selection in EmpathyInviteParticipantDialog
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 5 Aug 2011 10:00:31 +0000 (12:00 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 5 Aug 2011 13:03:43 +0000 (15:03 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=656020

libempathy-gtk/empathy-contact-chooser.c
libempathy-gtk/empathy-contact-chooser.h
src/empathy-invite-participant-dialog.c

index 9605855f2ccd96068c736dcac1939f66403fe8df..f6fa59d3b4497be2fc63d560c5016dbbc7d685b0 100644 (file)
@@ -192,47 +192,6 @@ view_selection_changed_cb (GtkWidget *treeview,
   tp_clear_object (&individual);
 }
 
-/* Return the TpContact of @individual which is on the same connection as the
- * EmpathyTpChat */
-static TpContact *
-get_tp_contact_for_chat (EmpathyContactChooser *self,
-    FolksIndividual *individual)
-{
-  TpContact *contact = NULL;
-  TpConnection *chat_conn;
-  GeeSet *personas;
-  GeeIterator *iter;
-
-  chat_conn = tp_channel_borrow_connection (TP_CHANNEL (self->priv->tp_chat));
-
-  personas = folks_individual_get_personas (individual);
-  iter = gee_iterable_iterator (GEE_ITERABLE (personas));
-  while (contact == FALSE && gee_iterator_next (iter))
-    {
-      TpfPersona *persona = gee_iterator_get (iter);
-      TpConnection *contact_conn;
-      TpContact *contact_cur = NULL;
-
-      if (TPF_IS_PERSONA (persona))
-        {
-          contact_cur = tpf_persona_get_contact (persona);
-          if (contact_cur != NULL)
-            {
-              contact_conn = tp_contact_get_connection (contact_cur);
-
-              if (!tp_strdiff (tp_proxy_get_object_path (contact_conn),
-                    tp_proxy_get_object_path (chat_conn)))
-                contact = contact_cur;
-            }
-        }
-
-      g_clear_object (&persona);
-    }
-  g_clear_object (&iter);
-
-  return contact;
-}
-
 static gboolean
 filter_func (GtkTreeModel *model,
     GtkTreeIter *iter,
@@ -446,20 +405,10 @@ empathy_contact_chooser_new (EmpathyTpChat *tp_chat)
       NULL);
 }
 
-TpContact *
-empathy_contact_chooser_get_selected (EmpathyContactChooser *self)
+FolksIndividual *
+empathy_contact_chooser_dup_selected (EmpathyContactChooser *self)
 {
-  FolksIndividual *individual;
-  TpContact *contact;
-
-  individual = empathy_individual_view_dup_selected (self->priv->view);
-  if (individual == NULL)
-    return NULL;
-
-  contact = get_tp_contact_for_chat (self, individual);
-
-  g_object_unref (individual);
-  return contact;
+  return empathy_individual_view_dup_selected (self->priv->view);
 }
 
 void
index 142660a6b7fc2f988a271951a03489bbaef52b38..b6e45c220d90db2c1b7977aadf98aca43588f651 100644 (file)
@@ -54,7 +54,7 @@ GType empathy_contact_chooser_get_type (void);
 
 GtkWidget * empathy_contact_chooser_new (EmpathyTpChat *tp_chat);
 
-TpContact * empathy_contact_chooser_get_selected (
+FolksIndividual * empathy_contact_chooser_dup_selected (
     EmpathyContactChooser *self);
 
 void empathy_contact_chooser_set_filter_func (EmpathyContactChooser *self,
index eedc6afabcf0c38afa4694f6e13643e507d184b0..4023ebacdbf4d6855c0e7bc0e9461c823dbda48f 100644 (file)
@@ -284,6 +284,16 @@ TpContact *
 empathy_invite_participant_dialog_get_selected (
     EmpathyInviteParticipantDialog *self)
 {
-  return empathy_contact_chooser_get_selected (
+  FolksIndividual *individual;
+  TpContact *contact;
+
+  individual = empathy_contact_chooser_dup_selected (
       EMPATHY_CONTACT_CHOOSER (self->priv->chooser));
+  if (individual == NULL)
+    return NULL;
+
+  contact = get_tp_contact_for_chat (self, individual);
+
+  g_object_unref (individual);
+  return contact;
 }