aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-03-08 23:32:03 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-03-15 16:28:41 +0800
commit01e4fe629f1861723d004daba9d190abe1e3ec00 (patch)
treef07f2eafc9e0aeddb78d87d24dae0ed4f45ebca9 /libempathy
parent0117b6e07afbe6b05add3baba61aae8d36093051 (diff)
downloadgsoc2013-empathy-01e4fe629f1861723d004daba9d190abe1e3ec00.tar
gsoc2013-empathy-01e4fe629f1861723d004daba9d190abe1e3ec00.tar.gz
gsoc2013-empathy-01e4fe629f1861723d004daba9d190abe1e3ec00.tar.bz2
gsoc2013-empathy-01e4fe629f1861723d004daba9d190abe1e3ec00.tar.lz
gsoc2013-empathy-01e4fe629f1861723d004daba9d190abe1e3ec00.tar.xz
gsoc2013-empathy-01e4fe629f1861723d004daba9d190abe1e3ec00.tar.zst
gsoc2013-empathy-01e4fe629f1861723d004daba9d190abe1e3ec00.zip
factor out add_contacts_to_favourites
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-contact-manager.c61
1 files changed, 30 insertions, 31 deletions
diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c
index 23794e001..6ccd08991 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)