[empathy] factor out add_to_members



commit 8957694686f44c0bad99b2fc4995f198795597ef
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Dec 11 16:09:09 2009 +0100

    factor out add_to_members

 libempathy/empathy-tp-contact-list.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c
index d595745..8d88e00 100644
--- a/libempathy/empathy-tp-contact-list.c
+++ b/libempathy/empathy-tp-contact-list.c
@@ -373,6 +373,24 @@ tp_contact_list_group_add (EmpathyTpContactList *list,
 }
 
 static void
+add_to_members (EmpathyTpContactList *list,
+		EmpathyContact *contact)
+{
+	EmpathyTpContactListPriv *priv = GET_PRIV (list);
+	TpHandle handle;
+
+	handle = empathy_contact_get_handle (contact);
+	if (g_hash_table_lookup (priv->members, GUINT_TO_POINTER (handle)))
+		return;
+
+	/* Add to the list and emit signal */
+	g_hash_table_insert (priv->members, GUINT_TO_POINTER (handle),
+			     g_object_ref (contact));
+	g_signal_emit_by_name (list, "members-changed", contact,
+				       0, 0, NULL, TRUE);
+}
+
+static void
 tp_contact_list_got_added_members_cb (EmpathyTpContactFactory *factory,
 				      guint                    n_contacts,
 				      EmpathyContact * const * contacts,
@@ -394,16 +412,9 @@ tp_contact_list_got_added_members_cb (EmpathyTpContactFactory *factory,
 		EmpathyContact *contact = contacts[i];
 		TpHandle handle;
 
-		handle = empathy_contact_get_handle (contact);
-		if (g_hash_table_lookup (priv->members, GUINT_TO_POINTER (handle)))
-			continue;
-
-		/* Add to the list and emit signal */
-		g_hash_table_insert (priv->members, GUINT_TO_POINTER (handle),
-				     g_object_ref (contact));
-		g_signal_emit_by_name (list, "members-changed", contact,
-				       0, 0, NULL, TRUE);
+		add_to_members (EMPATHY_TP_CONTACT_LIST (list), contact);
 
+		handle = empathy_contact_get_handle (contact);
 		/* This contact is now member, implicitly accept pending. */
 		if (g_hash_table_lookup (priv->pendings, GUINT_TO_POINTER (handle))) {
 			GArray handles = {(gchar *) &handle, 1};



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