changeset 29400:7cf5e442bbc8

Document the resource<>conversation binding (and how it works).
author Paul Aurich <paul@darkrain42.org>
date Wed, 10 Feb 2010 04:32:51 +0000
parents a8e19b69e6b4
children 4fb74d76c2df
files libpurple/protocols/jabber/message.c libpurple/protocols/jabber/presence.c
diffstat 2 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/message.c	Wed Feb 10 04:01:08 2010 +0000
+++ b/libpurple/protocols/jabber/message.c	Wed Feb 10 04:32:51 2010 +0000
@@ -73,14 +73,22 @@
 	if(jabber_find_unnormalized_conv(jm->from, jm->js->gc->account)) {
 		from = g_strdup(jm->from);
 	} else  if(jid->node) {
-		if(jid->resource) {
+		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;
 
 			from = g_strdup_printf("%s@%s", jid->node, jid->domain);
 			conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, jm->js->gc->account);
-			if(conv) {
+			if (conv) {
 				purple_conversation_set_name(conv, jm->from);
-				}
+			}
 			g_free(from);
 		}
 		from = g_strdup(jm->from);
--- a/libpurple/protocols/jabber/presence.c	Wed Feb 10 04:01:08 2010 +0000
+++ b/libpurple/protocols/jabber/presence.c	Wed Feb 10 04:32:51 2010 +0000
@@ -1005,6 +1005,11 @@
 
 			jabber_buddy_remove_resource(jb, jid->resource);
 			if((conv = jabber_find_unnormalized_conv(from, js->gc->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 {