pidgin: e7e77ba5: jabber: Document jabber_find_unnormalize...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Wed Feb 10 01:08:24 EST 2010
-----------------------------------------------------------------
Revision: e7e77ba57572905d2ff67a531c24eb8334301f1a
Ancestor: 40443f948cfde18de2a53d8e2bc2cbfed3416e99
Author: darkrain42 at pidgin.im
Date: 2010-02-10T05:06:36
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e7e77ba57572905d2ff67a531c24eb8334301f1a
Modified files:
libpurple/protocols/jabber/jutil.c
libpurple/protocols/jabber/jutil.h
libpurple/protocols/jabber/message.c
libpurple/protocols/jabber/presence.c
ChangeLog:
jabber: Document jabber_find_unnormalized_im_conv (and my guess as to why
it exists instead of using purple_find_conversation_with_account).
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jutil.c 99af4534d0e0e24e6e0acd64e06d681311e59078
+++ libpurple/protocols/jabber/jutil.c 3d5230c2aa2ff69846c22334f68a6ba99c1b561f
@@ -652,18 +652,17 @@ PurpleConversation *
}
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;
}
============================================================
--- libpurple/protocols/jabber/jutil.h 868ace1b7d30296ddba8ba5b105198a5c97ddc12
+++ libpurple/protocols/jabber/jutil.h 827f484ada57bc4bd1c2dc161d761eb2254b01dd
@@ -63,7 +63,17 @@ char *jabber_saslprep(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_ */
============================================================
--- libpurple/protocols/jabber/message.c 53480c08b58f3ec961bdf83aa74e0300fb7c2a45
+++ libpurple/protocols/jabber/message.c 7b3878ec98bb0b7994a2f3236296e9967cf2894e
@@ -75,7 +75,7 @@ static void handle_chat(JabberMessage *j
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) {
============================================================
--- libpurple/protocols/jabber/presence.c 887df241d743700d4401973996e0049e0afdb027
+++ libpurple/protocols/jabber/presence.c c012fbbd799cc8b0cd45ed4c5ceae345097e26fe
@@ -1004,7 +1004,7 @@ void jabber_presence_parse(JabberStream
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
More information about the Commits
mailing list