pidgin: dfcd7327: jabber: Add support for joining a room b...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Mar 6 18:05:54 EST 2011


----------------------------------------------------------------------
Revision: dfcd7327f9dca20e01e193aa8ac416625e69c3d0
Parent:   ef76e324e615128214321c2c397788c3714c3e63
Author:   darkrain42 at pidgin.im
Date:     03/06/11 17:53:15
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/dfcd7327f9dca20e01e193aa8ac416625e69c3d0

Changelog: 

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.

Changes against parent ef76e324e615128214321c2c397788c3714c3e63

  patched  ChangeLog
  patched  libpurple/protocols/jabber/jabber.c

-------------- next part --------------
============================================================
--- ChangeLog	e56025ef13184aab3b02b0d12efd9696b58bb43a
+++ ChangeLog	0a07d2dd67ce31dea43478e94d49bf6c9dc8d68a
@@ -28,6 +28,8 @@ version 2.7.11 (??/??/????):
 	  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:
============================================================
--- libpurple/protocols/jabber/jabber.c	ad50987594a75a4e32625b8192cb0ab9412e310a
+++ libpurple/protocols/jabber/jabber.c	7140ac4d990310cc716507d05d29c1cc413712c2
@@ -3008,21 +3008,44 @@ static PurpleCmdRet jabber_cmd_chat_join
 {
 	JabberChat *chat = jabber_chat_find_by_conv(conv);
 	GHashTable *components;
+	JabberID *jid;
+	const char *room = NULL, *server = NULL, *handle = NULL;
 
-	if(!chat || !args || !args[0])
+	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 @@ static void jabber_register_commands(Pur
 	                  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));
 


More information about the Commits mailing list