about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/contact_list.c9
-rw-r--r--src/contact_list.h2
-rw-r--r--src/jabber.c6
3 files changed, 11 insertions, 6 deletions
diff --git a/src/contact_list.c b/src/contact_list.c
index 3f8ff2ee..d05d7412 100644
--- a/src/contact_list.c
+++ b/src/contact_list.c
@@ -54,21 +54,22 @@ contact_list_reset_search_attempts(void)
     p_autocomplete_reset(ac);
 }
 
-void
+gboolean
 contact_list_add(const char * const jid, const char * const name,
     const char * const presence, const char * const status,
     const char * const subscription)
 {
+    gboolean added = FALSE;
     PContact contact = g_hash_table_lookup(contacts, jid);
 
     if (contact == NULL) {
         contact = p_contact_new(jid, name, presence, status, subscription);
         g_hash_table_insert(contacts, strdup(jid), contact);
-    } else {
-        log_warning("Duplicate roster entry: %s", jid);
+        p_autocomplete_add(ac, strdup(jid));
+        added = TRUE;
     }
 
-    p_autocomplete_add(ac, strdup(jid));
+    return added;
 }
 
 gboolean
diff --git a/src/contact_list.h b/src/contact_list.h
index 9f6bbe4c..90ae947b 100644
--- a/src/contact_list.h
+++ b/src/contact_list.h
@@ -30,7 +30,7 @@
 void contact_list_init(void);
 void contact_list_clear(void);
 void contact_list_reset_search_attempts(void);
-void contact_list_add(const char * const jid, const char * const name,
+gboolean contact_list_add(const char * const jid, const char * const name,
     const char * const presence, const char * const status,
     const char * const subscription);
 gboolean contact_list_update_contact(const char * const jid, const char * const presence,
diff --git a/src/jabber.c b/src/jabber.c
index e2e146e8..8c9c9ba0 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -386,7 +386,11 @@ _roster_handler(xmpp_conn_t * const conn,
             const char *jid = xmpp_stanza_get_attribute(item, "jid");
             const char *name = xmpp_stanza_get_attribute(item, "name");
             const char *sub = xmpp_stanza_get_attribute(item, "subscription");
-            contact_list_add(jid, name, "offline", NULL, sub);
+            gboolean added = contact_list_add(jid, name, "offline", NULL, sub);
+
+            if (!added) {
+                log_warning("Attempt to add contact twice: %s", jid);
+            }
 
             item = xmpp_stanza_get_next(item);
         }