# HG changeset patch # User Paul Aurich # Date 1265778396 0 # Node ID db0762fbb60b0255fc373ebe118c0b6bd8fe0248 # Parent 4fb74d76c2dfb7735261d35699a77b494284799a jabber: Document jabber_find_unnormalized_im_conv (and my guess as to why it exists instead of using purple_find_conversation_with_account). diff -r 4fb74d76c2df -r db0762fbb60b libpurple/protocols/jabber/jutil.c --- a/libpurple/protocols/jabber/jutil.c Wed Feb 10 04:35:10 2010 +0000 +++ b/libpurple/protocols/jabber/jutil.c Wed Feb 10 05:06:36 2010 +0000 @@ -652,18 +652,17 @@ } PurpleConversation * -jabber_find_unnormalized_conv(const char *name, PurpleAccount *account) +jabber_find_unnormalized_im_conv(const char *name, PurpleAccount *account) { PurpleConversation *c = NULL; GList *cnv; g_return_val_if_fail(name != NULL, NULL); - for(cnv = purple_get_conversations(); cnv; cnv = cnv->next) { + for (cnv = purple_get_ims(); cnv; cnv = cnv->next) { c = (PurpleConversation*)cnv->data; - if(purple_conversation_get_type(c) == PURPLE_CONV_TYPE_IM && - !purple_utf8_strcasecmp(name, purple_conversation_get_name(c)) && - account == purple_conversation_get_account(c)) + if (account == purple_conversation_get_account(c) && + !purple_utf8_strcasecmp(name, purple_conversation_get_name(c))) return c; } diff -r 4fb74d76c2df -r db0762fbb60b libpurple/protocols/jabber/jutil.h --- a/libpurple/protocols/jabber/jutil.h Wed Feb 10 04:35:10 2010 +0000 +++ b/libpurple/protocols/jabber/jutil.h Wed Feb 10 05:06:36 2010 +0000 @@ -63,7 +63,17 @@ */ char *jabber_saslprep(const char *); -PurpleConversation *jabber_find_unnormalized_conv(const char *name, PurpleAccount *account); +/** + * Search for an IM conversation with this specific user (including resource). + * This is an alternative to purple_find_conversation_with_account(), which + * calls purple_normalize (so if a conversation was found, we'd need to compare + * the conversation name to see if the resources match). + * + * This function saves a call to purple_normalize(), at the expense of + * iterating over every open IM conversation. For most usages, I think + * this tradeoff is OK. + */ +PurpleConversation *jabber_find_unnormalized_im_conv(const char *name, PurpleAccount *account); char *jabber_calculate_data_sha1sum(gconstpointer data, size_t len); #endif /* PURPLE_JABBER_JUTIL_H_ */ diff -r 4fb74d76c2df -r db0762fbb60b libpurple/protocols/jabber/message.c --- a/libpurple/protocols/jabber/message.c Wed Feb 10 04:35:10 2010 +0000 +++ b/libpurple/protocols/jabber/message.c Wed Feb 10 05:06:36 2010 +0000 @@ -75,7 +75,7 @@ jb = jabber_buddy_find(jm->js, jm->from, TRUE); jbr = jabber_buddy_find_resource(jb, jid->resource); - if(jabber_find_unnormalized_conv(jm->from, account)) { + if(jabber_find_unnormalized_im_conv(jm->from, account)) { from = g_strdup(jm->from); } else if(jid->node) { if (jid->resource) { diff -r 4fb74d76c2df -r db0762fbb60b libpurple/protocols/jabber/presence.c --- a/libpurple/protocols/jabber/presence.c Wed Feb 10 04:35:10 2010 +0000 +++ b/libpurple/protocols/jabber/presence.c Wed Feb 10 05:06:36 2010 +0000 @@ -1004,7 +1004,7 @@ PurpleConversation *conv; jabber_buddy_remove_resource(jb, jid->resource); - if((conv = jabber_find_unnormalized_conv(from, js->gc->account))) + if((conv = jabber_find_unnormalized_im_conv(from, js->gc->account))) /* * If a resource went offline (or the buddy unsubscribed), * send further messages to the bare JID. (This is also