cpw.darkrain42.xmpp.bosh: 5dc57aea: Reorder functions to remove prototypes

paul at darkrain42.org paul at darkrain42.org
Sat Apr 4 01:30:52 EDT 2009


-----------------------------------------------------------------
Revision: 5dc57aeace93ed1e1a09fdc459155844dfc7597e
Ancestor: 09737bf7e29cc82c8fce8466b74467fb6ee398a2
Author: paul at darkrain42.org
Date: 2009-04-04T05:15:18
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/5dc57aeace93ed1e1a09fdc459155844dfc7597e

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

ChangeLog: 

Reorder functions to remove prototypes

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/bosh.c	0ce515befeae9777f8d91d9186ddfa7b93a937d0
+++ libpurple/protocols/jabber/bosh.c	55a20f44165d05093e77f1647da6b95c3eb5d1e6
@@ -91,11 +91,6 @@ struct _PurpleHTTPConnection {
 
 };
 
-static void jabber_bosh_connection_stream_restart(PurpleBOSHConnection *conn);
-static gboolean jabber_bosh_connection_error_check(PurpleBOSHConnection *conn, xmlnode *node);
-static void jabber_bosh_connection_received(PurpleBOSHConnection *conn, xmlnode *node);
-static void jabber_bosh_connection_send(PurpleBOSHConnection *conn, PurpleBOSHPacketType type, const char *data);
-
 static void http_connection_connect(PurpleHTTPConnection *conn);
 static void http_connection_send_request(PurpleHTTPConnection *conn, const GString *req);
 
@@ -223,6 +218,107 @@ gboolean jabber_bosh_connection_is_ssl(P
 	return conn->ssl;
 }
 
+static PurpleHTTPConnection *
+find_available_http_connection(PurpleBOSHConnection *conn)
+{
+	int i;
+
+	/* Easy solution: Does everyone involved support pipelining? Hooray! Just use
+	 * one TCP connection! */
+	if (conn->pipelining)
+		return conn->connections[0];
+
+	/* First loop, look for a connection that's ready */
+	for (i = 0; i < MAX_HTTP_CONNECTIONS; ++i) {
+		if (conn->connections[i] && conn->connections[i]->ready &&
+		                            conn->connections[i]->requests == 0)
+			return conn->connections[i];
+	}
+
+	/* Second loop, look for one that's NULL and create a new connection */
+	for (i = 0; i < MAX_HTTP_CONNECTIONS; ++i) {
+		if (!conn->connections[i]) {
+			conn->connections[i] = jabber_bosh_http_connection_init(conn);
+
+			http_connection_connect(conn->connections[i]);
+			return NULL;
+		}
+	}
+
+	/* None available. */
+	return NULL;
+}
+
+static void
+jabber_bosh_connection_send(PurpleBOSHConnection *conn, PurpleBOSHPacketType type,
+                            const char *data)
+{
+	PurpleHTTPConnection *chosen;
+	GString *packet = NULL;
+
+	chosen = find_available_http_connection(conn);
+
+	if (type != PACKET_NORMAL && !chosen) {
+		/*
+		 * For non-ordinary traffic, we don't want to 'buffer' it, so use the first
+		 * connection.
+		 */
+		chosen = conn->connections[0];
+	
+		if (!chosen->ready)
+			purple_debug_warning("jabber", "First BOSH connection wasn't ready. Bad "
+					"things may happen.\n");
+	}
+
+	if (type == PACKET_NORMAL && (!chosen ||
+	        (conn->max_requests > 0 && conn->requests == conn->max_requests))) {
+		/*
+		 * For normal data, send up to max_requests requests at a time or there is no
+		 * connection ready (likely, we're currently opening a second connection and
+		 * will send these packets when connected).
+		 */
+		if (data) {
+			int len = data ? strlen(data) : 0;
+			purple_circ_buffer_append(conn->pending, data, len); 
+		}
+		return;
+	}
+
+	packet = g_string_new("");
+
+	g_string_printf(packet, "<body "
+	                "rid='%" G_GUINT64_FORMAT "' "
+	                "sid='%s' "
+	                "to='%s' "
+	                "xml:lang='en' "
+	                "xmlns='http://jabber.org/protocol/httpbind' "
+	                "xmlns:xmpp='urn:xmpp:xbosh'",
+	                ++conn->rid,
+	                conn->sid,
+	                conn->js->user->domain);
+
+	if (type == PACKET_STREAM_RESTART)
+		packet = g_string_append(packet, " xmpp:restart='true'/>");
+	else {
+		gsize read_amt;
+		if (type == PACKET_TERMINATE)
+			packet = g_string_append(packet, " type='terminate'");
+
+		packet = g_string_append_c(packet, '>');
+
+		while ((read_amt = purple_circ_buffer_get_max_read(conn->pending)) > 0) {
+			packet = g_string_append_len(packet, conn->pending->outptr, read_amt);
+			purple_circ_buffer_mark_read(conn->pending, read_amt);
+		}
+
+		if (data)
+			packet = g_string_append(packet, data);
+		packet = g_string_append(packet, "</body>");
+	}
+
+	http_connection_send_request(chosen, packet);
+}
+
 void jabber_bosh_connection_close(PurpleBOSHConnection *conn)
 {
 	jabber_bosh_connection_send(conn, PACKET_TERMINATE, NULL);
@@ -374,37 +470,6 @@ static void boot_response_cb(PurpleBOSHC
 	jabber_stream_features_parse(conn->js, packet);		
 }
 
-static PurpleHTTPConnection *
-find_available_http_connection(PurpleBOSHConnection *conn)
-{
-	int i;
-
-	/* Easy solution: Does everyone involved support pipelining? Hooray! Just use
-	 * one TCP connection! */
-	if (conn->pipelining)
-		return conn->connections[0];
-
-	/* First loop, look for a connection that's ready */
-	for (i = 0; i < MAX_HTTP_CONNECTIONS; ++i) {
-		if (conn->connections[i] && conn->connections[i]->ready &&
-		                            conn->connections[i]->requests == 0)
-			return conn->connections[i];
-	}
-
-	/* Second loop, look for one that's NULL and create a new connection */
-	for (i = 0; i < MAX_HTTP_CONNECTIONS; ++i) {
-		if (!conn->connections[i]) {
-			conn->connections[i] = jabber_bosh_http_connection_init(conn);
-
-			http_connection_connect(conn->connections[i]);
-			return NULL;
-		}
-	}
-
-	/* None available. */
-	return NULL;
-}
-
 static void jabber_bosh_connection_boot(PurpleBOSHConnection *conn) {
 	GString *buf = g_string_new("");
 
@@ -460,76 +525,6 @@ static void
 }
 
 static void
-jabber_bosh_connection_send(PurpleBOSHConnection *conn, PurpleBOSHPacketType type,
-                            const char *data)
-{
-	PurpleHTTPConnection *chosen;
-	GString *packet = NULL;
-
-	chosen = find_available_http_connection(conn);
-
-	if (type != PACKET_NORMAL && !chosen) {
-		/*
-		 * For non-ordinary traffic, we don't want to 'buffer' it, so use the first
-		 * connection.
-		 */
-		chosen = conn->connections[0];
-	
-		if (!chosen->ready)
-			purple_debug_warning("jabber", "First BOSH connection wasn't ready. Bad "
-					"things may happen.\n");
-	}
-
-	if (type == PACKET_NORMAL && (!chosen ||
-	        (conn->max_requests > 0 && conn->requests == conn->max_requests))) {
-		/*
-		 * For normal data, send up to max_requests requests at a time or there is no
-		 * connection ready (likely, we're currently opening a second connection and
-		 * will send these packets when connected).
-		 */
-		if (data) {
-			int len = data ? strlen(data) : 0;
-			purple_circ_buffer_append(conn->pending, data, len); 
-		}
-		return;
-	}
-
-	packet = g_string_new("");
-
-	g_string_printf(packet, "<body "
-	                "rid='%" G_GUINT64_FORMAT "' "
-	                "sid='%s' "
-	                "to='%s' "
-	                "xml:lang='en' "
-	                "xmlns='http://jabber.org/protocol/httpbind' "
-	                "xmlns:xmpp='urn:xmpp:xbosh'",
-	                ++conn->rid,
-	                conn->sid,
-	                conn->js->user->domain);
-
-	if (type == PACKET_STREAM_RESTART)
-		packet = g_string_append(packet, " xmpp:restart='true'/>");
-	else {
-		gsize read_amt;
-		if (type == PACKET_TERMINATE)
-			packet = g_string_append(packet, " type='terminate'");
-
-		packet = g_string_append_c(packet, '>');
-
-		while ((read_amt = purple_circ_buffer_get_max_read(conn->pending)) > 0) {
-			packet = g_string_append_len(packet, conn->pending->outptr, read_amt);
-			purple_circ_buffer_mark_read(conn->pending, read_amt);
-		}
-
-		if (data)
-			packet = g_string_append(packet, data);
-		packet = g_string_append(packet, "</body>");
-	}
-
-	http_connection_send_request(chosen, packet);
-}
-
-static void
 connection_common_established_cb(PurpleHTTPConnection *conn)
 {
 	/* Indicate we're ready and reset some variables */


More information about the Commits mailing list