pidgin: 42ef226b: jabber: Improved support for XEP-0249 (a...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Mon Oct 19 19:02:28 EDT 2009


-----------------------------------------------------------------
Revision: 42ef226b881103f4e4d31960abd46dd8cd60e179
Ancestor: 394d54bc7dec16320e66a9b13789967db3da21b0
Author: darkrain42 at pidgin.im
Date: 2009-10-17T00:37:04
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/42ef226b881103f4e4d31960abd46dd8cd60e179

Modified files:
        libpurple/protocols/jabber/chat.c
        libpurple/protocols/jabber/message.c

ChangeLog: 

jabber: Improved support for XEP-0249 (and document the legacy stuff).

Ironically, I don't think there's a way to invoke the code in chat.c as-is,
since it's specifically invoked if the server doesn't purport to be a MUC.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/chat.c	ed7efb85279890a982ef439aefe67d0b10594fde
+++ libpurple/protocols/jabber/chat.c	f7fc22e20ebc600fe5b0d4e41b27bcadc2e716ea
@@ -177,10 +177,21 @@ void jabber_chat_invite(PurpleConnection
 		xmlnode_insert_data(body, msg, -1);
 	} else {
 		xmlnode_set_attrib(message, "to", name);
+		/*
+		 * Putting the reason into the body was an 'undocumented protocol,
+		 * ...not part of "groupchat 1.0"'.
+		 * http://xmpp.org/extensions/attic/jep-0045-1.16.html#invite
+		 *
+		 * Left here for compatibility.
+		 */
 		body = xmlnode_new_child(message, "body");
 		xmlnode_insert_data(body, msg, -1);
+
 		x = xmlnode_new_child(message, "x");
 		xmlnode_set_attrib(x, "jid", room_jid);
+
+		/* The better place for it! XEP-0249 style. */
+		xmlnode_set_attrib(x, "reason", msg);
 		xmlnode_set_namespace(x, "jabber:x:conference");
 	}
 
============================================================
--- libpurple/protocols/jabber/message.c	ed5b1b3926522fb89b38f3093bf3c96c4b3e5089
+++ libpurple/protocols/jabber/message.c	7dcf7918d32cd1c64bf9f0c184a4f8dec8e78885
@@ -758,9 +758,22 @@ void jabber_message_parse(JabberStream *
 					jm->type != JABBER_MESSAGE_ERROR) {
 				const char *jid = xmlnode_get_attrib(child, "jid");
 				if(jid) {
+					const char *reason = xmlnode_get_attrib(child, "reason");
+					const char *password = xmlnode_get_attrib(child, "password");
+
 					jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE;
 					g_free(jm->to);
 					jm->to = g_strdup(jid);
+
+					if (reason) {
+						g_free(jm->body);
+						jm->body = g_strdup(reason);
+					}
+
+					if (password) {
+						g_free(jm->password);
+						jm->password = g_strdup(password);
+					}
 				}
 			} else if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user") &&
 					jm->type != JABBER_MESSAGE_ERROR) {
@@ -775,8 +788,10 @@ void jabber_message_parse(JabberStream *
 						g_free(jm->body);
 						jm->body = xmlnode_get_data(reason);
 					}
-					if((password = xmlnode_get_child(child, "password")))
+					if((password = xmlnode_get_child(child, "password"))) {
+						g_free(jm->password);
 						jm->password = xmlnode_get_data(password);
+					}
 
 					jm->type = JABBER_MESSAGE_GROUPCHAT_INVITE;
 				}


More information about the Commits mailing list