# HG changeset patch # User Paul Aurich # Date 1255739824 0 # Node ID 41992511531f7336312d121b4e2c339913e378f8 # Parent 4a0d69b9d8a8fa1897225d8c698ca3bdf0bc1cdb 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. diff -r 4a0d69b9d8a8 -r 41992511531f libpurple/protocols/jabber/chat.c --- a/libpurple/protocols/jabber/chat.c Fri Oct 16 20:22:26 2009 +0000 +++ b/libpurple/protocols/jabber/chat.c Sat Oct 17 00:37:04 2009 +0000 @@ -177,10 +177,21 @@ 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"); } diff -r 4a0d69b9d8a8 -r 41992511531f libpurple/protocols/jabber/message.c --- a/libpurple/protocols/jabber/message.c Fri Oct 16 20:22:26 2009 +0000 +++ b/libpurple/protocols/jabber/message.c Sat Oct 17 00:37:04 2009 +0000 @@ -758,9 +758,22 @@ 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 @@ 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; }