Mercurial > pidgin.yaz
changeset 29406:b676cb5b4595
jabber: Cleanup (and drop that unnormalized find function)!
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 10 Feb 2010 05:56:53 +0000 |
parents | 1d1e653c4315 |
children | fbe2824286ce |
files | libpurple/protocols/jabber/jutil.c libpurple/protocols/jabber/jutil.h libpurple/protocols/jabber/message.c |
diffstat | 3 files changed, 19 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jutil.c Wed Feb 10 05:44:25 2010 +0000 +++ b/libpurple/protocols/jabber/jutil.c Wed Feb 10 05:56:53 2010 +0000 @@ -651,24 +651,6 @@ return equal; } -PurpleConversation * -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_ims(); cnv; cnv = cnv->next) { - c = (PurpleConversation*)cnv->data; - if (account == purple_conversation_get_account(c) && - !purple_utf8_strcasecmp(name, purple_conversation_get_name(c))) - return c; - } - - return NULL; -} - /* The same as purple_util_get_image_checksum, but guaranteed to remain SHA1 */ char * jabber_calculate_data_sha1sum(gconstpointer data, size_t len)
--- a/libpurple/protocols/jabber/jutil.h Wed Feb 10 05:44:25 2010 +0000 +++ b/libpurple/protocols/jabber/jutil.h Wed Feb 10 05:56:53 2010 +0000 @@ -63,17 +63,5 @@ */ char *jabber_saslprep(const char *); -/** - * 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_ */
--- a/libpurple/protocols/jabber/message.c Wed Feb 10 05:44:25 2010 +0000 +++ b/libpurple/protocols/jabber/message.c Wed Feb 10 05:56:53 2010 +0000 @@ -59,7 +59,6 @@ static void handle_chat(JabberMessage *jm) { JabberID *jid = jabber_id_new(jm->from); - char *from; PurpleConnection *gc; PurpleAccount *account; @@ -75,30 +74,20 @@ jb = jabber_buddy_find(jm->js, jm->from, TRUE); jbr = jabber_buddy_find_resource(jb, jid->resource); - if(jabber_find_unnormalized_im_conv(jm->from, account)) { - from = g_strdup(jm->from); - } else if(jid->node) { - if (jid->resource) { - /* - * We received a message from a specific resource, so we probably want a - * reply to go to this specific resource (i.e. bind the conversation to - * this resource). - * - * This works because purple_conv_im_send gets the name from - * purple_conversation_get_name() - */ - PurpleConversation *conv; + if (jid->resource) { + /* + * We received a message from a specific resource, so we probably want a + * reply to go to this specific resource (i.e. bind/lock the + * conversation to this resource). + * + * This works because purple_conv_im_send gets the name from + * purple_conversation_get_name() + */ + PurpleConversation *conv; - from = g_strdup_printf("%s@%s", jid->node, jid->domain); - conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, account); - if (conv) { - purple_conversation_set_name(conv, jm->from); - } - g_free(from); - } - from = g_strdup(jm->from); - } else { - from = g_strdup(jid->domain); + conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, jm->from, account); + if (conv) + purple_conversation_set_name(conv, jm->from); } if(!jm->xhtml && !jm->body) { @@ -110,12 +99,12 @@ } if(JM_STATE_COMPOSING == jm->chat_state) { - serv_got_typing(gc, from, 0, PURPLE_TYPING); + serv_got_typing(gc, jm->from, 0, PURPLE_TYPING); } else if(JM_STATE_PAUSED == jm->chat_state) { - serv_got_typing(gc, from, 0, PURPLE_TYPED); + serv_got_typing(gc, jm->from, 0, PURPLE_TYPED); } else if(JM_STATE_GONE == jm->chat_state) { PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, - from, account); + jm->from, account); if (conv && jid->node && jid->domain) { char buf[256]; PurpleBuddy *buddy; @@ -140,10 +129,10 @@ PURPLE_MESSAGE_SYSTEM, time(NULL)); } } - serv_got_typing_stopped(gc, from); + serv_got_typing_stopped(gc, jm->from); } else { - serv_got_typing_stopped(gc, from); + serv_got_typing_stopped(gc, jm->from); } } else { if(jbr) { @@ -162,11 +151,9 @@ jm->body = jabber_google_format_to_html(jm->body); g_free(tmp); } - serv_got_im(gc, from, jm->xhtml ? jm->xhtml : jm->body, 0, jm->sent); + serv_got_im(gc, jm->from, jm->xhtml ? jm->xhtml : jm->body, 0, jm->sent); } - - g_free(from); jabber_id_free(jid); }