summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpurple/protocols/jabber/jutil.c9
-rw-r--r--libpurple/protocols/jabber/jutil.h12
-rw-r--r--libpurple/protocols/jabber/message.c2
-rw-r--r--libpurple/protocols/jabber/presence.c2
4 files changed, 17 insertions, 8 deletions
diff --git a/libpurple/protocols/jabber/jutil.c b/libpurple/protocols/jabber/jutil.c
index 3c6f58e44b..12527edcdb 100644
--- a/libpurple/protocols/jabber/jutil.c
+++ b/libpurple/protocols/jabber/jutil.c
@@ -652,18 +652,17 @@ jabber_is_own_account(JabberStream *js, const char *str)
}
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 --git a/libpurple/protocols/jabber/jutil.h b/libpurple/protocols/jabber/jutil.h
index ab7ea6e447..e7b31d9e0a 100644
--- a/libpurple/protocols/jabber/jutil.h
+++ b/libpurple/protocols/jabber/jutil.h
@@ -63,7 +63,17 @@ gboolean jabber_resourceprep_validate(const char *);
*/
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 --git a/libpurple/protocols/jabber/message.c b/libpurple/protocols/jabber/message.c
index 39f7b7c539..437f8f6ad5 100644
--- a/libpurple/protocols/jabber/message.c
+++ b/libpurple/protocols/jabber/message.c
@@ -75,7 +75,7 @@ static void handle_chat(JabberMessage *jm)
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 --git a/libpurple/protocols/jabber/presence.c b/libpurple/protocols/jabber/presence.c
index 077c4e3070..e19591a233 100644
--- a/libpurple/protocols/jabber/presence.c
+++ b/libpurple/protocols/jabber/presence.c
@@ -1004,7 +1004,7 @@ void jabber_presence_parse(JabberStream *js, xmlnode *packet)
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