cpw.darkrain42.xmpp.bosh: 5019cf23: Allow the user to specify their own BOSH...

paul at darkrain42.org paul at darkrain42.org
Tue Feb 17 22:35:45 EST 2009


-----------------------------------------------------------------
Revision: 5019cf23f95130beae144e0f11c27820ed03b471
Ancestor: a2d22dce6d28c2996025c3f8edc2186e37a03c0d
Author: paul at darkrain42.org
Date: 2009-02-17T04:28:19
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/5019cf23f95130beae144e0f11c27820ed03b471

Modified files:
        libpurple/protocols/jabber/jabber.c
        libpurple/protocols/jabber/libxmpp.c

ChangeLog: 

Allow the user to specify their own BOSH url in the Connect Server option

If the Connect Server starts with "http(s?)://", use it as a BOSH connection
URL and go connect to it. The use case for this is someone who wants to 
connect to their Google Talk account from behind a firewall that blocks
everything but HTTP (and not just port 80), so the user runs a standalone
BOSH Connection Manager on their home computer and connects through that.

I'm not entirely happy with the how this leaves the advanced UI panel. The user
specifies a BOSH connection port as part of the URL, whereas the non-srv
connections use the separate 'port' account option.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c	6fbce92ecc315d32db08475b6064d0b67c17088a
+++ libpurple/protocols/jabber/jabber.c	b9c08f7fe2e2bcd3a0aa5127652f6db0459b0371
@@ -759,8 +759,6 @@ jabber_login(PurpleAccount *account)
 			"connect_server", "");
 	JabberStream *js;
 	JabberBuddy *my_jb = NULL;
-	/* XXX FORCE_BOSH */
-	gboolean force_bosh = purple_account_get_bool(account, "force_bosh", FALSE);
 
 	gc->flags |= PURPLE_CONNECTION_HTML |
 		PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY;
@@ -780,7 +778,6 @@ jabber_login(PurpleAccount *account)
 	js->write_buffer = purple_circ_buffer_new(512);
 	js->old_length = 0;
 	js->keepalive_timeout = -1;
-	js->certificate_CN = g_strdup(connect_server[0] ? connect_server : js->user ? js->user->domain : NULL);
 
 	if(!js->user) {
 		purple_connection_error_reason (gc,
@@ -801,10 +798,20 @@ jabber_login(PurpleAccount *account)
 
 	jabber_stream_set_state(js, JABBER_STREAM_CONNECTING);
 
-	/* XXX FORCE_BOSH: Remove this */
-	if (force_bosh) {
-		js->srv_query_data = purple_txt_resolve("_xmppconnect", js->user->domain, txt_resolved_cb, js);
+	/* TODO: Just use purple_url_parse? */
+	if (!g_ascii_strncasecmp(connect_server, "http://", 7) || !g_ascii_strncasecmp(connect_server, "https://", 8)) {
+		js->use_bosh = TRUE;
+		js->bosh = jabber_bosh_connection_init(js, connect_server);
+		if (!js->bosh) {
+			purple_connection_error_reason (js->gc,
+				PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
+				_("Malformed BOSH Connect Server"));
+			return;
+		}
+		jabber_bosh_connection_connect(js->bosh);
 		return;
+	} else {
+		js->certificate_CN = g_strdup(connect_server[0] ? connect_server : js->user->domain);
 	}
 
 	/* if they've got old-ssl mode going, we probably want to ignore SRV lookups */
============================================================
--- libpurple/protocols/jabber/libxmpp.c	cfd9a3a7598dccc7efa488996ddb49122c2d1011
+++ libpurple/protocols/jabber/libxmpp.c	c4ad2be1e8c9e9d3a45e20e70efc5e9527868abc
@@ -236,12 +236,6 @@ init_plugin(PurplePlugin *plugin)
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
 						   option);
 
-	/* XXX FORCE_BOSH: Remove this before re-merging branch */
-	option = purple_account_option_bool_new(_("Force BOSH (debugging)"),
-						"force_bosh", FALSE);
-	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
-							option);
-
 	option = purple_account_option_int_new(_("Connect port"), "port", 5222);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
 						   option);


More information about the Commits mailing list