[empathy] factor out add_contacts_to_favourites
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] factor out add_contacts_to_favourites
- Date: Mon, 15 Mar 2010 08:29:40 +0000 (UTC)
commit 01e4fe629f1861723d004daba9d190abe1e3ec00
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Mon Mar 8 16:32:03 2010 +0100
factor out add_contacts_to_favourites
libempathy/empathy-contact-manager.c | 61 ++++++++++++++++-----------------
1 files changed, 30 insertions(+), 31 deletions(-)
---
diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c
index 23794e0..6ccd089 100644
--- a/libempathy/empathy-contact-manager.c
+++ b/libempathy/empathy-contact-manager.c
@@ -290,19 +290,42 @@ contact_manager_remove_favourite (EmpathyContactList *manager,
}
static void
+add_contacts_to_favourites (EmpathyContactManager *self,
+ const gchar *account,
+ const gchar **contacts)
+{
+ EmpathyContactManagerPriv *priv = GET_PRIV (self);
+ guint j;
+ GHashTable *contact_hash;
+
+ contact_hash = g_hash_table_lookup (priv->favourites, account);
+ if (contact_hash == NULL) {
+ contact_hash = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free, NULL);
+ g_hash_table_insert (priv->favourites,
+ g_strdup (account),
+ g_hash_table_ref (contact_hash));
+ }
+
+ for (j = 0; contacts && contacts[j] != NULL; j++) {
+ g_hash_table_insert (contact_hash,
+ g_strdup (contacts[j]),
+ GINT_TO_POINTER (1));
+ }
+}
+
+static void
logger_favourite_contacts_add_from_value_array (GValueArray *va,
EmpathyContactManager *manager)
{
- EmpathyContactManagerPriv *priv = GET_PRIV (manager);
guint i;
for (i = 0; i < va->n_values; i++) {
GValue *account_value;
const gchar *account;
GValue *contacts_value;
- gchar **contacts;
- guint j;
- GHashTable *contact_hash;
+ const gchar **contacts;
account_value = g_value_array_get_nth (va, 0);
contacts_value = g_value_array_get_nth (va, 1);
@@ -310,21 +333,7 @@ logger_favourite_contacts_add_from_value_array (GValueArray *va,
account = g_value_get_boxed (account_value);
contacts = g_value_get_boxed (contacts_value);
- contact_hash = g_hash_table_lookup (priv->favourites, account);
- if (contact_hash == NULL) {
- contact_hash = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free, NULL);
- g_hash_table_insert (priv->favourites,
- g_strdup (account),
- g_hash_table_ref (contact_hash));
- }
-
- for (j = 0; contacts && contacts[j] != NULL; j++) {
- g_hash_table_insert (contact_hash,
- g_strdup (contacts[j]),
- GINT_TO_POINTER (1));
- }
+ add_contacts_to_favourites (manager, account, contacts);
}
}
@@ -522,19 +531,9 @@ logger_favourite_contacts_changed_cb (TpProxy *proxy,
* exactly one contact amongst added and removed, so the linear lookup
* of each contact isn't as painful as it appears */
- for (i = 0; added && added[i]; i++) {
- if (contact_hash == NULL) {
- contact_hash = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free, NULL);
- g_hash_table_insert (priv->favourites,
- g_strdup (account_name),
- g_hash_table_ref (contact_hash));
- }
-
- g_hash_table_insert (contact_hash, g_strdup (added[i]),
- GINT_TO_POINTER (1));
+ add_contacts_to_favourites (manager, account_name, added);
+ for (i = 0; added && added[i]; i++) {
contact = contact_manager_lookup_contact (manager, account_name,
added[i]);
if (contact != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]