changeset 8400:0383e55cd658

[gaim-migrate @ 9129] the ietf docs say we SHOULD do this, so we will. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 05 Mar 2004 19:09:59 +0000
parents 681b1661ee8b
children c13a4913a071
files src/protocols/jabber/buddy.c src/protocols/jabber/buddy.h src/protocols/jabber/chat.c src/protocols/jabber/chat.h src/protocols/jabber/jabber.c src/protocols/jabber/message.c src/protocols/jabber/message.h
diffstat 7 files changed, 45 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/jabber/buddy.c	Fri Mar 05 16:37:37 2004 +0000
+++ b/src/protocols/jabber/buddy.c	Fri Mar 05 19:09:59 2004 +0000
@@ -122,6 +122,8 @@
 	g_free(jbr->name);
 	if(jbr->status)
 		g_free(jbr->status);
+	if(jbr->thread_id)
+		g_free(jbr->thread_id);
 	g_free(jbr);
 }
 
--- a/src/protocols/jabber/buddy.h	Fri Mar 05 16:37:37 2004 +0000
+++ b/src/protocols/jabber/buddy.h	Fri Mar 05 19:09:59 2004 +0000
@@ -49,6 +49,7 @@
 	int state;
 	char *status;
 	JabberCapabilities capabilities;
+	char *thread_id;
 } JabberBuddyResource;
 
 void jabber_buddy_free(JabberBuddy *jb);
--- a/src/protocols/jabber/chat.c	Fri Mar 05 16:37:37 2004 +0000
+++ b/src/protocols/jabber/chat.c	Fri Mar 05 19:09:59 2004 +0000
@@ -190,6 +190,7 @@
 
 	chat->room = g_strdup(room);
 	chat->server = g_strdup(server);
+	chat->handle = g_strdup(handle);
 
 	g_hash_table_insert(js->chats, room_jid, chat);
 
--- a/src/protocols/jabber/chat.h	Fri Mar 05 16:37:37 2004 +0000
+++ b/src/protocols/jabber/chat.h	Fri Mar 05 19:09:59 2004 +0000
@@ -35,6 +35,7 @@
 	JabberStream *js;
 	char *room;
 	char *server;
+	char *handle;
 	int id;
 	GaimConversation *conv;
 	gboolean muc;
--- a/src/protocols/jabber/jabber.c	Fri Mar 05 16:37:37 2004 +0000
+++ b/src/protocols/jabber/jabber.c	Fri Mar 05 19:09:59 2004 +0000
@@ -1169,6 +1169,27 @@
 	return NULL;
 }
 
+static void jabber_convo_closed(GaimConnection *gc, const char *who)
+{
+	JabberStream *js = gc->proto_data;
+	JabberID *jid;
+	JabberBuddy *jb;
+	JabberBuddyResource *jbr;
+
+	if(!(jid = jabber_id_new(who)))
+		return;
+
+	if((jb = jabber_buddy_find(js, who, TRUE)) &&
+			(jbr = jabber_buddy_find_resource(jb, jid->resource))) {
+		if(jbr->thread_id) {
+			g_free(jbr->thread_id);
+			jbr->thread_id = NULL;
+		}
+	}
+
+	jabber_id_free(jid);
+}
+
 static GaimPluginProtocolInfo prpl_info =
 {
 	OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME,
@@ -1219,7 +1240,7 @@
 	jabber_roster_group_change,
 	jabber_roster_group_rename,
 	NULL,
-	NULL, /* convo_closed */
+	jabber_convo_closed,
 	jabber_normalize,
 	NULL, /* set_buddy_icon */
 	NULL, /* remove_group */
--- a/src/protocols/jabber/message.c	Fri Mar 05 16:37:37 2004 +0000
+++ b/src/protocols/jabber/message.c	Fri Mar 05 19:09:59 2004 +0000
@@ -87,8 +87,13 @@
 		else
 			serv_got_typing_stopped(jm->js->gc, from);
 	} else {
-		if(jbr && jm->events & JABBER_MESSAGE_EVENT_COMPOSING)
-			jbr->capabilities |= JABBER_CAP_COMPOSING;
+		if(jbr) {
+			if(jm->events & JABBER_MESSAGE_EVENT_COMPOSING)
+				jbr->capabilities |= JABBER_CAP_COMPOSING;
+			if(jbr->thread_id)
+				g_free(jbr->thread_id);
+			jbr->thread_id = g_strdup(jbr->thread_id);
+		}
 		serv_got_im(jm->js->gc, from, jm->xhtml ? jm->xhtml : jm->body, 0,
 				jm->sent);
 	}
@@ -265,6 +270,9 @@
 		if(!strcmp(child->name, "subject")) {
 			if(!jm->subject)
 				jm->subject = xmlnode_get_data(child);
+		} else if(!strcmp(child->name, "thread")) {
+			if(!jm->thread_id)
+				jm->thread_id = xmlnode_get_data(child);
 		} else if(!strcmp(child->name, "body")) {
 			if(!jm->body)
 				jm->body = xmlnode_to_str(child, NULL);
@@ -385,6 +393,11 @@
 
 	xmlnode_set_attrib(message, "to", jm->to);
 
+	if(jm->thread_id) {
+		child = xmlnode_new_child(message, "thread");
+		xmlnode_insert_data(child, jm->thread_id, -1);
+	}
+
 	if(jm->events || (!jm->body && !jm->xhtml && !jm->subject)) {
 		child = xmlnode_new_child(message, "x");
 		xmlnode_set_attrib(child, "xmlns", "jabber:x:event");
@@ -443,6 +456,8 @@
 	jm->type = JABBER_MESSAGE_CHAT;
 	jm->events = JABBER_MESSAGE_EVENT_COMPOSING;
 	jm->to = g_strdup(who);
+	if(jbr && jbr->thread_id)
+		jm->thread_id = jbr->thread_id;
 
 	buf = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>%s</body></html>", msg);
 
--- a/src/protocols/jabber/message.h	Fri Mar 05 16:37:37 2004 +0000
+++ b/src/protocols/jabber/message.h	Fri Mar 05 19:09:59 2004 +0000
@@ -44,6 +44,7 @@
 	char *xhtml;
 	char *password;
 	char *error;
+	char *thread_id;
 	enum {
 		JABBER_MESSAGE_EVENT_COMPOSING = 1 << 1
 	} events;