# HG changeset patch # User Paul Aurich # Date 1299451995 0 # Node ID 9d8a47ca14a1e92f407f63786fec116479d24d1b # Parent b44e3c2e83e184fc06b877d27daf0cb083302dd1 jabber: Add support for joining a room based not on the current server. An extension of a patch from Solarius, mcepl, and wyuka; I added in jabber_id_new parsing. Fixes #4526. I'll tweak the context help after the string freeze. diff -r b44e3c2e83e1 -r 9d8a47ca14a1 ChangeLog --- a/ChangeLog Sun Mar 06 22:38:45 2011 +0000 +++ b/ChangeLog Sun Mar 06 22:53:15 2011 +0000 @@ -28,6 +28,8 @@ 2.7.10). (#13329) * Don't treat the on-join status storms as 'new arrivals'. (Thijs Alkemade) (#a14527) + * Extend the /join command to support room JIDs, enabling you to join + a room on any server. (Solarius, Matěj Cepl, wyuka) (#4526) version 2.7.10 (02/06/2011): General: diff -r b44e3c2e83e1 -r 9d8a47ca14a1 libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Sun Mar 06 22:38:45 2011 +0000 +++ b/libpurple/protocols/jabber/jabber.c Sun Mar 06 22:53:15 2011 +0000 @@ -3008,21 +3008,44 @@ { JabberChat *chat = jabber_chat_find_by_conv(conv); GHashTable *components; - - if(!chat || !args || !args[0]) + JabberID *jid; + const char *room = NULL, *server = NULL, *handle = NULL; + + if (!chat || !args || !args[0]) return PURPLE_CMD_RET_FAILED; components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); - g_hash_table_replace(components, "room", args[0]); - g_hash_table_replace(components, "server", chat->server); - g_hash_table_replace(components, "handle", chat->handle); - if(args[1]) - g_hash_table_replace(components, "password", args[1]); + jid = jabber_id_new(args[0]); + if (jid) { + room = jid->node; + server = jid->domain; + handle = jid->resource ? jid->resource : chat->handle; + } else { + /* If jabber_id_new failed, the user may have just passed in + * a room name. For backward compatibility, handle that here. + */ + if (strchr(args[0], '@')) { + *error = g_strdup(_("Invalid XMPP ID")); + return PURPLE_CMD_RET_FAILED; + } + + room = args[0]; + server = chat->server; + handle = chat->handle; + } + + g_hash_table_insert(components, "room", (gpointer)room); + g_hash_table_insert(components, "server", (gpointer)server); + g_hash_table_insert(components, "handle", (gpointer)handle); + + if (args[1]) + g_hash_table_insert(components, "password", args[1]); jabber_chat_join(purple_conversation_get_gc(conv), components); g_hash_table_destroy(components); + jabber_id_free(jid); return PURPLE_CMD_RET_OK; } @@ -3650,6 +3673,7 @@ PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", jabber_cmd_chat_join, _("join: <room> [password]: Join a chat on this server."), + /* _("join: <room[@server]> [password]: Join a chat."), */ NULL); commands = g_slist_prepend(commands, GUINT_TO_POINTER(id));