pidgin: 8fe61955: jabber: Cleanup (and drop that unnormali...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Wed Feb 10 01:08:23 EST 2010
-----------------------------------------------------------------
Revision: 8fe6195539754a041b3f223b89bfef28eb1998c3
Ancestor: 080a4ba95022e5c7613fdab2833eee2085b65b46
Author: darkrain42 at pidgin.im
Date: 2010-02-10T05:56:53
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8fe6195539754a041b3f223b89bfef28eb1998c3
Modified files:
libpurple/protocols/jabber/jutil.c
libpurple/protocols/jabber/jutil.h
libpurple/protocols/jabber/message.c
ChangeLog:
jabber: Cleanup (and drop that unnormalized find function)!
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jutil.c 3d5230c2aa2ff69846c22334f68a6ba99c1b561f
+++ libpurple/protocols/jabber/jutil.c d0ecf1856c5cde6e1deb28492fcdbf624805d7f3
@@ -651,24 +651,6 @@ jabber_is_own_account(JabberStream *js,
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)
============================================================
--- libpurple/protocols/jabber/jutil.h 827f484ada57bc4bd1c2dc161d761eb2254b01dd
+++ libpurple/protocols/jabber/jutil.h e18a94f6754ab41d5272d85925d8115f29fcfba0
@@ -63,17 +63,5 @@ char *jabber_saslprep(const char *);
*/
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_ */
============================================================
--- libpurple/protocols/jabber/message.c 7b3878ec98bb0b7994a2f3236296e9967cf2894e
+++ libpurple/protocols/jabber/message.c 9b0d9a5596b4f3c99d856e3f2347199f6d6e4de0
@@ -59,7 +59,6 @@ static void handle_chat(JabberMessage *j
static void handle_chat(JabberMessage *jm)
{
JabberID *jid = jabber_id_new(jm->from);
- char *from;
PurpleConnection *gc;
PurpleAccount *account;
@@ -75,30 +74,20 @@ 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_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 @@ static void handle_chat(JabberMessage *j
}
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 @@ static void handle_chat(JabberMessage *j
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 @@ static void handle_chat(JabberMessage *j
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);
}
More information about the Commits
mailing list