Mercurial > pidgin.yaz
changeset 27568:ff099a916d6b
Use jabber_is_own_account and perform way fewer normalizations per iteration
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 06 Jun 2009 22:38:15 +0000 |
parents | c96a7d9361bb |
children | 65b5bc543214 |
files | libpurple/protocols/jabber/roster.c |
diffstat | 1 files changed, 11 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/roster.c Sat Jun 06 20:52:02 2009 +0000 +++ b/libpurple/protocols/jabber/roster.c Sat Jun 06 22:38:15 2009 +0000 @@ -149,28 +149,18 @@ JabberIqType type, const char *id, xmlnode *query) { xmlnode *item, *group; - - if(from) { - char *from_norm; - gboolean invalid; - - from_norm = g_strdup(jabber_normalize(js->gc->account, from)); + gchar *own_jid; - if(!from_norm) - return; - - invalid = g_utf8_collate(from_norm, - jabber_normalize(js->gc->account, - purple_account_get_username(js->gc->account))); - - g_free(from_norm); - - if(invalid) - return; + if (!jabber_is_own_account(js, from)) { + purple_debug_warning("jabber", "Received bogon roster push from %s\n", + from); + return; } js->currently_parsing_roster_push = TRUE; + own_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); + for(item = xmlnode_get_child(query, "item"); item; item = xmlnode_get_next_twin(item)) { const char *jid, *name, *subscription, *ask; @@ -188,18 +178,11 @@ continue; if(subscription) { - gint me = -1; - char *jid_norm; - const char *username; + gboolean me = FALSE; - jid_norm = g_strdup(jabber_normalize(js->gc->account, jid)); - username = purple_account_get_username(js->gc->account); - me = g_utf8_collate(jid_norm, - jabber_normalize(js->gc->account, - username)); - g_free(jid_norm); + me = g_str_equal(own_jid, jabber_normalize(js->gc->account, jid)); - if(me == 0) + if(me) jb->subscription = JABBER_SUB_BOTH; else if(!strcmp(subscription, "none")) jb->subscription = JABBER_SUB_NONE; @@ -253,6 +236,7 @@ } } + g_free(own_jid); js->currently_parsing_roster_push = FALSE; /* if we're just now parsing the roster for the first time,