changeset 29405:1d1e653c4315

jabber: Unbind/Unlock from a specific resource on presences. Closes #9874.
author Paul Aurich <paul@darkrain42.org>
date Wed, 10 Feb 2010 05:44:25 +0000
parents 9c9cfcd69181
children b676cb5b4595
files libpurple/protocols/jabber/presence.c
diffstat 1 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/presence.c	Wed Feb 10 05:25:12 2010 +0000
+++ b/libpurple/protocols/jabber/presence.c	Wed Feb 10 05:44:25 2010 +0000
@@ -959,8 +959,24 @@
 		/* End of DEALING WITH CHATS...about 5000 lines ago */
 	} else {
 		/* DEALING WITH CONTACT (i.e. not a chat) */
+		PurpleConversation *conv;
+
 		buddy_name = g_strdup_printf("%s%s%s", jid->node ? jid->node : "",
 									 jid->node ? "@" : "", jid->domain);
+
+		/*
+		 * Unbind/unlock from sending messages to a specific resource on
+		 * presence changes.  This is locked to a specific resource when
+		 * receiving a message (in message.c).
+		 */
+		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
+				buddy_name, account);
+		if (conv) {
+			purple_debug_warning("jabber", "Changed conversation binding from %s to %s\n",
+					purple_conversation_get_name(conv), buddy_name);
+			purple_conversation_set_name(conv, buddy_name);
+		}
+
 		if((b = purple_find_buddy(account, buddy_name)) == NULL) {
 			if (jb != js->user_jb) {
 				purple_debug_warning("jabber", "Got presence for unknown buddy %s on account %s (%p)\n",
@@ -1005,17 +1021,7 @@
 		if(state == JABBER_BUDDY_STATE_ERROR ||
 				(type && (g_str_equal(type, "unavailable") ||
 				          g_str_equal(type, "unsubscribed")))) {
-			PurpleConversation *conv;
-
 			jabber_buddy_remove_resource(jb, jid->resource);
-			if((conv = jabber_find_unnormalized_im_conv(from, account)))
-				/*
-				 * If a resource went offline (or the buddy unsubscribed),
-				 * send further messages to the bare JID.  (This is also
-				 * updated in message.c when receiving a message)
-				 */
-				purple_conversation_set_name(conv, buddy_name);
-
 		} else {
 			jbr = jabber_buddy_track_resource(jb, jid->resource, priority,
 					state, status);