changeset 7974:415df6fa0395

[gaim-migrate @ 8651] jabber /part support (with /part messages!) the list of the cool jabber chat stuff I can do w/o certain extras from people who know who they are is getting shorter and shorter committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 02 Jan 2004 15:34:04 +0000
parents aa99b8390092
children 2311532f9036
files src/protocols/jabber/chat.c src/protocols/jabber/chat.h src/protocols/jabber/message.c src/protocols/jabber/presence.c
diffstat 4 files changed, 27 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/jabber/chat.c	Fri Jan 02 08:15:52 2004 +0000
+++ b/src/protocols/jabber/chat.c	Fri Jan 02 15:34:04 2004 +0000
@@ -212,20 +212,12 @@
 {
 	JabberStream *js = gc->proto_data;
 	JabberChat *chat = jabber_chat_find_by_id(js, id);
-	char *room_jid;
-	xmlnode *presence;
+
 
 	if(!chat)
 		return;
 
-	room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
-	gaim_debug(GAIM_DEBUG_INFO, "jabber", "%s is leaving chat %s\n",
-			chat->nick, room_jid);
-	presence = xmlnode_new("presence");
-	xmlnode_set_attrib(presence, "to", room_jid);
-	xmlnode_set_attrib(presence, "type", "unavailable");
-	jabber_send(js, presence);
-	xmlnode_free(presence);
+	jabber_chat_part(chat, NULL);
 }
 
 void jabber_chat_destroy(JabberChat *chat)
@@ -592,4 +584,24 @@
 	xmlnode_free(presence);
 }
 
+void jabber_chat_part(JabberChat *chat, const char *msg)
+{
+	char *room_jid;
+	xmlnode *presence;
 
+	room_jid = g_strdup_printf("%s@%s", chat->room, chat->server);
+	gaim_debug(GAIM_DEBUG_INFO, "jabber", "%s is leaving chat %s\n",
+			chat->nick, room_jid);
+	presence = xmlnode_new("presence");
+	xmlnode_set_attrib(presence, "to", room_jid);
+	xmlnode_set_attrib(presence, "type", "unavailable");
+	if(msg) {
+		xmlnode *status = xmlnode_new_child(presence, "status");
+		xmlnode_insert_data(status, msg, -1);
+	}
+	jabber_send(chat->js, presence);
+	xmlnode_free(presence);
+	g_free(room_jid);
+}
+
+
--- a/src/protocols/jabber/chat.h	Fri Jan 02 08:15:52 2004 +0000
+++ b/src/protocols/jabber/chat.h	Fri Jan 02 15:34:04 2004 +0000
@@ -57,6 +57,7 @@
 void jabber_chat_change_topic(JabberChat *chat, const char *topic);
 void jabber_chat_set_topic(GaimConnection *gc, int id, const char *topic);
 void jabber_chat_change_nick(JabberChat *chat, const char *nick);
+void jabber_chat_part(JabberChat *chat, const char *msg);
 
 
 #endif /* _GAIM_JABBER_CHAT_H_ */
--- a/src/protocols/jabber/message.c	Fri Jan 02 08:15:52 2004 +0000
+++ b/src/protocols/jabber/message.c	Fri Jan 02 15:34:04 2004 +0000
@@ -503,6 +503,9 @@
 		if(strlen(msg) > 6)
 			jabber_chat_change_nick(chat, msg+6);
 		return 1;
+	} else if(!strncmp(msg, "/part", 5)) {
+		jabber_chat_part(chat, strlen(msg) > 6 ? msg+6 : NULL);
+		return 1;
 	}
 
 	jm = g_new0(JabberMessage, 1);
--- a/src/protocols/jabber/presence.c	Fri Jan 02 08:15:52 2004 +0000
+++ b/src/protocols/jabber/presence.c	Fri Jan 02 15:34:04 2004 +0000
@@ -344,7 +344,7 @@
 					jabber_chat_destroy(chat);
 				} else {
 					gaim_conv_chat_remove_user(GAIM_CONV_CHAT(chat->conv), jid->resource,
-							NULL);
+							status);
 				}
 			}
 		} else {