diff options
author | James Booth <boothj5@gmail.com> | 2012-10-29 22:55:17 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-10-29 22:55:17 +0000 |
commit | 768b2aa4667a362ea1343f47c044d79b642c2497 (patch) | |
tree | 36c67b2b478069710712a28904dc1bf68487e088 /src | |
parent | a0eda4207cbc25329754944da2dedf9e19fa0150 (diff) | |
download | profani-tty-768b2aa4667a362ea1343f47c044d79b642c2497.tar.gz |
Fixed tests
Diffstat (limited to 'src')
-rw-r--r-- | src/contact_list.c | 9 | ||||
-rw-r--r-- | src/contact_list.h | 2 | ||||
-rw-r--r-- | src/jabber.c | 6 |
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); } |