/pidgin/main: 6c217475a114: Clean merge.

Mark Doliner mark at kingant.net
Fri Aug 30 02:02:05 EDT 2013


Changeset: 6c217475a1147025db7ac0a78e8053e5a9ec9e4f
Author:	 Mark Doliner <mark at kingant.net>
Date:	 2013-08-29 23:01 -0700
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/6c217475a114

Description:

Clean merge.

diffstat:

 libpurple/Makefile.am                    |    2 +
 libpurple/Makefile.mingw                 |    1 +
 libpurple/connection.c                   |   20 +
 libpurple/connection.h                   |   12 +
 libpurple/http.c                         |  212 +++---------------
 libpurple/protocols/bonjour/bonjour.c    |   11 +-
 libpurple/protocols/gg/gg.c              |   10 +-
 libpurple/protocols/irc/irc.c            |   10 +-
 libpurple/protocols/jabber/libfacebook.c |    3 +-
 libpurple/protocols/jabber/libgtalk.c    |    3 +-
 libpurple/protocols/jabber/libxmpp.c     |    3 +-
 libpurple/protocols/msn/msn.c            |    9 +-
 libpurple/protocols/mxit/mxit.c          |    3 +-
 libpurple/protocols/myspace/myspace.c    |    3 +-
 libpurple/protocols/novell/novell.c      |   10 +-
 libpurple/protocols/null/nullprpl.c      |    3 +-
 libpurple/protocols/oscar/libaim.c       |    3 +-
 libpurple/protocols/oscar/libicq.c       |   10 +-
 libpurple/protocols/oscar/oscar.c        |    7 +
 libpurple/protocols/oscar/oscarcommon.h  |    1 +
 libpurple/protocols/sametime/sametime.c  |    1 +
 libpurple/protocols/silc/silc.c          |    3 +-
 libpurple/protocols/simple/simple.c      |    3 +-
 libpurple/protocols/yahoo/libyahoo.c     |    3 +-
 libpurple/protocols/yahoo/libyahoojp.c   |    3 +-
 libpurple/protocols/yahoo/libymsg.c      |    6 +
 libpurple/protocols/yahoo/libymsg.h      |    1 +
 libpurple/protocols/zephyr/zephyr.c      |    3 +-
 libpurple/prpl.h                         |   15 +
 libpurple/purple-socket.c                |  354 +++++++++++++++++++++++++++++++
 libpurple/purple-socket.h                |  200 +++++++++++++++++
 31 files changed, 735 insertions(+), 193 deletions(-)

diffs (truncated from 1409 to 300 lines):

diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -76,6 +76,7 @@ purple_coresources = \
 	privacy.c \
 	proxy.c \
 	prpl.c \
+	purple-socket.c \
 	request.c \
 	roomlist.c \
 	savedstatuses.c \
@@ -141,6 +142,7 @@ purple_coreheaders = \
 	privacy.h \
 	proxy.h \
 	prpl.h \
+	purple-socket.h \
 	request.h \
 	roomlist.h \
 	savedstatuses.h \
diff --git a/libpurple/Makefile.mingw b/libpurple/Makefile.mingw
--- a/libpurple/Makefile.mingw
+++ b/libpurple/Makefile.mingw
@@ -104,6 +104,7 @@ C_SRC =	\
 			privacy.c \
 			proxy.c \
 			prpl.c \
+			purple-socket.c \
 			request.c \
 			roomlist.c \
 			savedstatuses.c \
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -631,6 +631,26 @@ void purple_connection_update_last_recei
 	gc->last_received = time(NULL);
 }
 
+gsize
+purple_connection_get_max_message_size(PurpleConnection *gc)
+{
+	PurplePlugin *prpl;
+	PurplePluginProtocolInfo *prpl_info;
+
+	g_return_val_if_fail(gc != NULL, 0);
+
+	prpl = purple_connection_get_prpl(gc);
+	g_return_val_if_fail(prpl != NULL, 0);
+
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+	g_return_val_if_fail(prpl_info != NULL, 0);
+
+	if (!PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_max_message_size))
+		return 0;
+
+	return prpl_info->get_max_message_size(gc);
+}
+
 void
 purple_connections_disconnect_all(void)
 {
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -452,6 +452,18 @@ purple_connection_error_is_fatal (Purple
  */
 void purple_connection_update_last_received(PurpleConnection *gc);
 
+/**
+ * Gets the maximum message size in bytes for the protocol. It may depend on
+ * connection-specific variables (like protocol version).
+ *
+ * @see PurplePluginProtocolInfo#get_max_message_size
+ *
+ * @param gc The connection to query.
+ * @return   Maximum message size, or 0 if unspecified or infinite.
+ */
+gsize
+purple_connection_get_max_message_size(PurpleConnection *gc);
+
 /*@}*/
 
 /**************************************************************************/
diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -31,6 +31,7 @@
 
 #include "debug.h"
 #include "ntlm.h"
+#include "purple-socket.h"
 
 #include <zlib.h>
 
@@ -56,23 +57,13 @@ typedef struct _PurpleHttpKeepaliveReque
 
 typedef struct _PurpleHttpGzStream PurpleHttpGzStream;
 
-typedef void (*PurpleHttpSocketConnectCb)(PurpleHttpSocket *hs,
-	const gchar *error, gpointer user_data);
-
 struct _PurpleHttpSocket
 {
-	gboolean is_ssl;
+	PurpleSocket *ps;
+
 	gboolean is_busy;
 	guint use_count;
 	PurpleHttpKeepaliveHost *host;
-
-	PurpleSslConnection *ssl_connection;
-	PurpleProxyConnectData *raw_connection;
-	int fd;
-	guint inpa;
-	PurpleInputFunction watch_cb;
-	PurpleHttpSocketConnectCb connect_cb;
-	gpointer cb_data;
 };
 
 struct _PurpleHttpRequest
@@ -184,7 +175,7 @@ struct _PurpleHttpCookieJar
 struct _PurpleHttpKeepaliveRequest
 {
 	PurpleConnection *gc;
-	PurpleHttpSocketConnectCb cb;
+	PurpleSocketConnectCb cb;
 	gpointer user_data;
 
 	PurpleHttpKeepaliveHost *host;
@@ -256,7 +247,7 @@ gchar * purple_http_cookie_jar_dump(Purp
 static PurpleHttpKeepaliveRequest *
 purple_http_keepalive_pool_request(PurpleHttpKeepalivePool *pool,
 	PurpleConnection *gc, const gchar *host, int port, gboolean is_ssl,
-	PurpleHttpSocketConnectCb cb, gpointer user_data);
+	PurpleSocketConnectCb cb, gpointer user_data);
 static void
 purple_http_keepalive_pool_request_cancel(PurpleHttpKeepaliveRequest *req);
 static void
@@ -464,43 +455,6 @@ purple_http_gz_free(PurpleHttpGzStream *
 
 /*** HTTP Sockets *************************************************************/
 
-static void _purple_http_socket_connected_raw(gpointer _hs, gint fd,
-	const gchar *error_message)
-{
-	PurpleHttpSocket *hs = _hs;
-
-	hs->raw_connection = NULL;
-
-	if (fd == -1 || error_message != NULL) {
-		if (error_message == NULL)
-			error_message = _("Unknown error");
-		hs->connect_cb(hs, error_message, hs->cb_data);
-		return;
-	}
-
-	hs->fd = fd;
-	hs->connect_cb(hs, NULL, hs->cb_data);
-}
-
-static void _purple_http_socket_connected_ssl(gpointer _hs,
-	PurpleSslConnection *ssl_connection, PurpleInputCondition cond)
-{
-	PurpleHttpSocket *hs = _hs;
-
-	hs->fd = hs->ssl_connection->fd;
-	hs->connect_cb(hs, NULL, hs->cb_data);
-}
-
-static void _purple_http_socket_connected_ssl_error(
-	PurpleSslConnection *ssl_connection, PurpleSslErrorType error,
-	gpointer _hs)
-{
-	PurpleHttpSocket *hs = _hs;
-
-	hs->ssl_connection = NULL;
-	hs->connect_cb(hs, purple_ssl_strerror(error), hs->cb_data);
-}
-
 static gchar *
 purple_http_socket_hash(const gchar *host, int port, gboolean is_ssl)
 {
@@ -508,41 +462,18 @@ purple_http_socket_hash(const gchar *hos
 }
 
 static PurpleHttpSocket *
-purple_http_socket_connect_new(PurpleConnection *gc, const gchar *host, int port, gboolean is_ssl, PurpleHttpSocketConnectCb cb, gpointer user_data)
+purple_http_socket_connect_new(PurpleConnection *gc, const gchar *host,
+	int port, gboolean is_ssl, PurpleSocketConnectCb cb, gpointer user_data)
 {
 	PurpleHttpSocket *hs = g_new0(PurpleHttpSocket, 1);
-	PurpleAccount *account = NULL;
-
-	if (gc != NULL)
-		account = purple_connection_get_account(gc);
-
-	hs->is_ssl = is_ssl;
-	hs->connect_cb = cb;
-	hs->cb_data = user_data;
-	hs->fd = -1;
-
-	if (is_ssl) {
-		if (!purple_ssl_is_supported()) {
-			g_free(hs);
-			return NULL;
-		}
-
-		hs->ssl_connection = purple_ssl_connect(account,
-			host, port,
-			_purple_http_socket_connected_ssl,
-			_purple_http_socket_connected_ssl_error, hs);
-/* TODO
-		purple_ssl_set_compatibility_level(hs->ssl_connection,
-			PURPLE_SSL_COMPATIBILITY_SECURE);
-*/
-	} else {
-		hs->raw_connection = purple_proxy_connect(gc, account,
-			host, port,
-			_purple_http_socket_connected_raw, hs);
-	}
-
-	if (hs->ssl_connection == NULL &&
-		hs->raw_connection == NULL) {
+
+	hs->ps = purple_socket_new(gc);
+	purple_socket_set_data(hs->ps, "hs", hs);
+	purple_socket_set_tls(hs->ps, is_ssl);
+	purple_socket_set_host(hs->ps, host);
+	purple_socket_set_port(hs->ps, port);
+	if (!purple_socket_connect(hs->ps, cb, user_data)) {
+		purple_socket_destroy(hs->ps);
 		g_free(hs);
 		return NULL;
 	}
@@ -553,72 +484,6 @@ purple_http_socket_connect_new(PurpleCon
 	return hs;
 }
 
-static int
-purple_http_socket_read(PurpleHttpSocket *hs, gchar *buf, size_t len)
-{
-	g_return_val_if_fail(hs != NULL, -1);
-	g_return_val_if_fail(buf != NULL, -1);
-
-	if (hs->is_ssl)
-		return purple_ssl_read(hs->ssl_connection, buf, sizeof(buf));
-	else
-		return read(hs->fd, buf, sizeof(buf));
-}
-
-static int
-purple_http_socket_write(PurpleHttpSocket *hs, const gchar *buf, size_t len)
-{
-	g_return_val_if_fail(hs != NULL, -1);
-	g_return_val_if_fail(buf != NULL, -1);
-
-	if (hs->is_ssl)
-		return purple_ssl_write(hs->ssl_connection, buf, len);
-	else
-		return write(hs->fd, buf, len);
-}
-
-static void _purple_http_socket_watch_recv_ssl(gpointer _hs,
-	PurpleSslConnection *ssl_connection, PurpleInputCondition cond)
-{
-	PurpleHttpSocket *hs = _hs;
-
-	g_return_if_fail(hs != NULL);
-
-	hs->watch_cb(hs->cb_data, hs->fd, cond);
-}
-
-static void
-purple_http_socket_watch(PurpleHttpSocket *hs, PurpleInputCondition cond,
-	PurpleInputFunction func, gpointer user_data)
-{
-	g_return_if_fail(hs != NULL);
-
-	if (hs->inpa > 0)
-		purple_input_remove(hs->inpa);
-	hs->inpa = 0;
-
-	if (cond == PURPLE_INPUT_READ && hs->is_ssl) {
-		hs->watch_cb = func;
-		hs->cb_data = user_data;
-		purple_ssl_input_add(hs->ssl_connection,
-			_purple_http_socket_watch_recv_ssl, hs);
-	}
-	else
-		hs->inpa = purple_input_add(hs->fd, cond, func, user_data);
-}
-
-static void
-purple_http_socket_dontwatch(PurpleHttpSocket *hs)
-{
-	g_return_if_fail(hs != NULL);
-
-	if (hs->inpa > 0)
-		purple_input_remove(hs->inpa);
-	hs->inpa = 0;
-	if (hs->ssl_connection)



More information about the Commits mailing list