cpw.darkrain42.xmpp.bosh: 888c8575: Reorder some functions to eliminate prot...

paul at darkrain42.org paul at darkrain42.org
Sat Jan 17 23:56:23 EST 2009


-----------------------------------------------------------------
Revision: 888c8575006d8e143354d2cb7e3257b068eff828
Ancestor: 42b48d18527b01b2ce8d375b6a104fb81abef2aa
Author: paul at darkrain42.org
Date: 2008-12-05T00:08:19
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/888c8575006d8e143354d2cb7e3257b068eff828

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

ChangeLog: 

Reorder some functions to eliminate prototypes and
export jabber_bosh_connection_refresh()

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/bosh.c	3f62e7ff3c81d4a1b7c7bae85113ce0b17788f76
+++ libpurple/protocols/jabber/bosh.c	505371184c0f3227a69138174246d8e768606089
@@ -102,20 +102,11 @@ static void jabber_bosh_connection_send_
 static void jabber_bosh_connection_http_received_cb(PurpleHTTPRequest *req, PurpleHTTPResponse *res, void *userdata);
 static void jabber_bosh_connection_send_native(PurpleBOSHConnection *conn, xmlnode *node);
 
-static void jabber_bosh_http_connection_receive_parse_header(PurpleHTTPResponse *response, char **data, int *len);
-static PurpleHTTPConnection* jabber_bosh_http_connection_init(const char *host, int port);
 static void jabber_bosh_http_connection_connect(PurpleHTTPConnection *conn);
 static void jabber_bosh_http_connection_send_request(PurpleHTTPConnection *conn, PurpleHTTPRequest *req);
-static void jabber_bosh_http_connection_destroy(PurpleHTTPConnection *conn);
 
-static PurpleHTTPRequest* jabber_bosh_http_request_init(const char *method, const char *path, PurpleHTTPRequestCallback cb, void *userdata);
 static void jabber_bosh_http_request_add_to_header(PurpleHTTPRequest *req, const char *field, const char *value);
-static void jabber_bosh_http_request_set_data(PurpleHTTPRequest *req, char *data, int len);
-static void jabber_bosh_http_request_destroy(PurpleHTTPRequest *req);
 
-static PurpleHTTPResponse* jabber_bosh_http_response_init(void);
-static void jabber_bosh_http_response_destroy(PurpleHTTPResponse *res);
-
 void jabber_bosh_init(void)
 {
 	GHashTable *ui_info = purple_core_get_ui_info();
@@ -136,8 +127,82 @@ void jabber_bosh_uninit(void)
 	bosh_useragent = NULL;
 }
 
-PurpleBOSHConnection* jabber_bosh_connection_init(JabberStream *js, const char *url)
+static PurpleHTTPRequest*
+jabber_bosh_http_request_init(const char *method, const char *path,
+                         PurpleHTTPRequestCallback cb, void *userdata)
 {
+	PurpleHTTPRequest *req = g_new(PurpleHTTPRequest, 1);
+	req->method = g_strdup(method);
+	req->path = g_strdup(path);
+	req->cb = cb;
+	req->userdata = userdata;
+	req->header = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+	return req;
+}
+
+static void
+jabber_bosh_http_request_destroy(PurpleHTTPRequest *req)
+{
+	g_hash_table_destroy(req->header);
+	g_free(req->method);
+	g_free(req->path);
+	g_free(req->data);
+	g_free(req);
+}
+
+static PurpleHTTPResponse*
+jabber_bosh_http_response_init(void)
+{
+	PurpleHTTPResponse *res = g_new0(PurpleHTTPResponse, 1);
+	res->header = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+	return res;
+}
+
+static void
+jabber_bosh_http_response_destroy(PurpleHTTPResponse *res)
+{
+	g_hash_table_destroy(res->header);
+	g_free(res->data);
+	g_free(res);
+}
+
+static PurpleHTTPConnection*
+jabber_bosh_http_connection_init(const char *host, int port)
+{
+	PurpleHTTPConnection *conn = g_new0(PurpleHTTPConnection, 1);
+	conn->host = g_strdup(host);
+	conn->port = port;
+	conn->fd = -1;
+	conn->requests = g_queue_new();
+
+	return conn;
+}
+
+static void
+jabber_bosh_http_connection_destroy(PurpleHTTPConnection *conn)
+{
+	g_free(conn->current_data);
+	g_free(conn->host);
+
+	if (conn->requests) {
+		g_queue_foreach(conn->requests, (GFunc)jabber_bosh_http_request_destroy, NULL);
+		g_queue_free(conn->requests);
+	}
+
+	if (conn->current_response)
+		jabber_bosh_http_response_destroy(conn->current_response);
+
+	if (conn->ie_handle)
+		purple_input_remove(conn->ie_handle);
+	if (conn->fd > 0)
+		close(conn->fd);
+
+	g_free(conn);
+}
+
+PurpleBOSHConnection*
+jabber_bosh_connection_init(JabberStream *js, const char *url)
+{
 	PurpleBOSHConnection *conn;
 	char *host, *path, *user, *passwd;
 	int port;
@@ -171,7 +236,8 @@ PurpleBOSHConnection* jabber_bosh_connec
 	return conn;
 }
 
-void jabber_bosh_connection_destroy(PurpleBOSHConnection *conn)
+void
+jabber_bosh_connection_destroy(PurpleBOSHConnection *conn)
 {
 	g_free(conn->host);
 	g_free(conn->path);
@@ -410,9 +476,9 @@ static void jabber_bosh_connection_conne
 	} else jabber_bosh_connection_boot(bosh_conn);
 }
 
-static void jabber_bosh_connection_refresh(PurpleHTTPConnection *conn) {
-	PurpleBOSHConnection *bosh_conn = conn->userdata;
-	jabber_bosh_connection_send(bosh_conn, NULL);
+void jabber_bosh_connection_refresh(PurpleBOSHConnection *conn)
+{
+	jabber_bosh_connection_send(conn, NULL);
 }
 
 static void jabber_bosh_http_connection_disconnected(PurpleHTTPConnection *conn) {
@@ -538,38 +604,6 @@ static void jabber_bosh_http_connection_
 	}
 }
 
-static PurpleHTTPConnection* jabber_bosh_http_connection_init(const char *host, int port)
-{
-	PurpleHTTPConnection *conn = g_new0(PurpleHTTPConnection, 1);
-	conn->host = g_strdup(host);
-	conn->port = port;
-	conn->fd = -1;
-	conn->requests = g_queue_new();
-
-	return conn;
-}
-
-static void jabber_bosh_http_connection_destroy(PurpleHTTPConnection *conn)
-{
-	g_free(conn->current_data);
-	g_free(conn->host);
-
-	if (conn->requests) {
-		g_queue_foreach(conn->requests, (GFunc)jabber_bosh_http_request_destroy, NULL);
-		g_queue_free(conn->requests);
-	}
-
-	if (conn->current_response)
-		jabber_bosh_http_response_destroy(conn->current_response);
-
-	if (conn->ie_handle)
-			purple_input_remove(conn->ie_handle);
-	if (conn->fd > 0)
-			close(conn->fd);
-
-	g_free(conn);
-}
-
 static void jabber_bosh_http_connection_callback(gpointer data, gint source, const gchar *error)
 {
 	PurpleHTTPConnection *conn = data;
@@ -632,48 +666,9 @@ void jabber_bosh_http_connection_send_re
 	g_queue_push_tail(conn->requests, req);
 }
 
-static PurpleHTTPRequest* jabber_bosh_http_request_init(const char *method,
-        const char *path, PurpleHTTPRequestCallback cb, void *userdata)
-{
-	PurpleHTTPRequest *req = g_new(PurpleHTTPRequest, 1);
-	req->method = g_strdup(method);
-	req->path = g_strdup(path);
-	req->cb = cb;
-	req->userdata = userdata;
-	req->header = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
-	return req;
-}
-
 static void jabber_bosh_http_request_add_to_header(PurpleHTTPRequest *req, const char *field, const char *value) {
 	char *f = g_strdup(field);
 	char *v = g_strdup(value);
 	g_hash_table_replace(req->header, f, v);
 }
 
-void jabber_bosh_http_request_set_data(PurpleHTTPRequest *req, char *data, int len) {
-	req->data = data;
-	req->data_len = len;
-}
-
-static void jabber_bosh_http_request_destroy(PurpleHTTPRequest *req)
-{
-	g_hash_table_destroy(req->header);
-	g_free(req->method);
-	g_free(req->path);
-	g_free(req->data);
-	g_free(req);
-}
-
-static PurpleHTTPResponse* jabber_bosh_http_response_init(void)
-{
-	PurpleHTTPResponse *res = g_new0(PurpleHTTPResponse, 1);
-	res->header = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
-	return res;
-}
-
-static void jabber_bosh_http_response_destroy(PurpleHTTPResponse *res)
-{
-	g_hash_table_destroy(res->header);
-	g_free(res->data);
-	g_free(res);
-}
============================================================
--- libpurple/protocols/jabber/bosh.h	8762bed96aa1807750ed885fa3a2d369c5ae0bd3
+++ libpurple/protocols/jabber/bosh.h	489c839ef35996d7c07df375f78f771639aea64f
@@ -36,4 +36,5 @@ void jabber_bosh_connection_send_raw(Pur
 void jabber_bosh_connection_close(PurpleBOSHConnection *conn);
 void jabber_bosh_connection_send(PurpleBOSHConnection *conn, xmlnode *node);
 void jabber_bosh_connection_send_raw(PurpleBOSHConnection *conn, const char *data, int len);
+void jabber_bosh_connection_refresh(PurpleBOSHConnection *conn);
 #endif /* _PURPLE_JABBER_BOSH_H_ */


More information about the Commits mailing list