cpw.darkrain42.roster: eed256df: Use jabber_is_own_account and perform wa...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Sat Jun 6 20:20:31 EDT 2009
-----------------------------------------------------------------
Revision: eed256df62cff36f40e4398c900667b920f46f82
Ancestor: 65354086b2158121a40a5e1b469992d2a2ee63d2
Author: darkrain42 at pidgin.im
Date: 2009-06-06T22:38:15
Branch: im.pidgin.cpw.darkrain42.roster
URL: http://d.pidgin.im/viewmtn/revision/info/eed256df62cff36f40e4398c900667b920f46f82
Modified files:
libpurple/protocols/jabber/roster.c
ChangeLog:
Use jabber_is_own_account and perform way fewer normalizations per iteration
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/roster.c 8f8c9bf266e6ebccf7ec893511335fb5baa7b692
+++ libpurple/protocols/jabber/roster.c e981c0685dccd483b8c0e347b3c22f2fa929d3b2
@@ -149,28 +149,18 @@ void jabber_roster_parse(JabberStream *j
JabberIqType type, const char *id, xmlnode *query)
{
xmlnode *item, *group;
+ gchar *own_jid;
- if(from) {
- char *from_norm;
- gboolean invalid;
-
- from_norm = g_strdup(jabber_normalize(js->gc->account, from));
-
- 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 @@ void jabber_roster_parse(JabberStream *j
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 @@ void jabber_roster_parse(JabberStream *j
}
}
+ g_free(own_jid);
js->currently_parsing_roster_push = FALSE;
/* if we're just now parsing the roster for the first time,
More information about the Commits
mailing list