From 8957694686f44c0bad99b2fc4995f198795597ef Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 11 Dec 2009 16:09:09 +0100 Subject: factor out add_to_members --- libempathy/empathy-tp-contact-list.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-contact-list.c b/libempathy/empathy-tp-contact-list.c index d595745c7..8d88e00d5 100644 --- a/libempathy/empathy-tp-contact-list.c +++ b/libempathy/empathy-tp-contact-list.c @@ -372,6 +372,24 @@ tp_contact_list_group_add (EmpathyTpContactList *list, G_OBJECT (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, @@ -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}; -- cgit v1.2.3