/pidgin/main: 5c8caea5bd66: Merge with release-2.x.y

Daniel Atallah datallah at pidgin.im
Wed Mar 6 10:35:10 EST 2013


Changeset: 5c8caea5bd66e0a74639f8fea2ad80b688958a64
Author:	 Daniel Atallah <datallah at pidgin.im>
Date:	 2013-03-06 10:34 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/5c8caea5bd66

Description:

Merge with release-2.x.y

diffstat:

 libpurple/protocols/mxit/formcmds.c |   2 ++
 libpurple/protocols/mxit/http.c     |   3 +++
 libpurple/protocols/mxit/login.c    |  12 ++++++++++--
 libpurple/protocols/mxit/markup.c   |   7 ++++++-
 libpurple/protocols/mxit/mxit.h     |   2 +-
 libpurple/protocols/mxit/protocol.c |  15 +++++++++------
 libpurple/protocols/mxit/roster.c   |   6 ++++--
 7 files changed, 35 insertions(+), 12 deletions(-)

diffs (175 lines):

diff --git a/libpurple/protocols/mxit/formcmds.c b/libpurple/protocols/mxit/formcmds.c
--- a/libpurple/protocols/mxit/formcmds.c
+++ b/libpurple/protocols/mxit/formcmds.c
@@ -413,6 +413,8 @@ static void command_imagestrip(struct MX
 
 		/* base64 decode the image data */
 		rawimg = purple_base64_decode(tmp, &rawimglen);
+		if (!rawimg)
+			return;
 
 		/* save it to a file */
 		dir = g_build_filename(purple_user_dir(), "mxit", "imagestrips", NULL);
diff --git a/libpurple/protocols/mxit/http.c b/libpurple/protocols/mxit/http.c
--- a/libpurple/protocols/mxit/http.c
+++ b/libpurple/protocols/mxit/http.c
@@ -328,5 +328,8 @@ void mxit_http_send_request( struct MXit
 
 	/* open connection to the HTTP server */
 	con = purple_proxy_connect( NULL, session->acc, host, port, mxit_cb_http_connect, req );
+	if ( !con ) {
+		purple_connection_error_reason( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Unable to connect" ) );
+	}
 }
 
diff --git a/libpurple/protocols/mxit/login.c b/libpurple/protocols/mxit/login.c
--- a/libpurple/protocols/mxit/login.c
+++ b/libpurple/protocols/mxit/login.c
@@ -393,6 +393,9 @@ static void mxit_cb_clientinfo2( PurpleU
 	purple_debug_info( MXIT_PLUGIN_ID, "HTTP RESPONSE: '%s'\n", url_text );
 #endif
 
+	/* remove request from the async outstanding calls list */
+	session->async_calls = g_slist_remove( session->async_calls, url_data );
+
 	if ( !url_text ) {
 		/* no reply from the WAP site */
 		purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Error contacting the MXit WAP site. Please try again later." ) );
@@ -568,8 +571,9 @@ static void mxit_cb_captcha_ok( PurpleCo
 			MXIT_CAPTCHA_WIDTH,
 			time( NULL )
 	);
-	/* FIXME: This should be cancelled somewhere if not needed. */
 	url_data = purple_util_fetch_url_request( session->acc, url, TRUE, MXIT_HTTP_USERAGENT, TRUE, NULL, FALSE, -1, mxit_cb_clientinfo2, session );
+	if ( url_data )
+		session->async_calls = g_slist_prepend( session->async_calls, url_data );
 
 #ifdef	DEBUG_PROTOCOL
 	purple_debug_info( MXIT_PLUGIN_ID, "HTTP REQUEST: '%s'\n", url );
@@ -627,6 +631,9 @@ static void mxit_cb_clientinfo1( PurpleU
 	purple_debug_info( MXIT_PLUGIN_ID, "RESPONSE: %s\n", url_text );
 #endif
 
+	/* remove request from the async outstanding calls list */
+	session->async_calls = g_slist_remove( session->async_calls, url_data );
+
 	if ( !url_text ) {
 		/* no reply from the WAP site */
 		purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Error contacting the MXit WAP site. Please try again later." ) );
@@ -733,8 +740,9 @@ static void get_clientinfo( struct MXitS
 
 	/* reference: "libpurple/util.h" */
 	url = g_strdup_printf( "%s/res/?type=challenge&getcountries=true&getlanguage=true&getimage=true&h=%i&w=%i&ts=%li", wapserver, MXIT_CAPTCHA_HEIGHT, MXIT_CAPTCHA_WIDTH, time( NULL ) );
-	/* FIXME: This should be cancelled somewhere if not needed. */
 	url_data = purple_util_fetch_url_request( session->acc, url, TRUE, MXIT_HTTP_USERAGENT, TRUE, NULL, FALSE, -1, mxit_cb_clientinfo1, session );
+	if ( url_data )
+		session->async_calls = g_slist_prepend( session->async_calls, url_data );
 
 #ifdef	DEBUG_PROTOCOL
 	purple_debug_info( MXIT_PLUGIN_ID, "HTTP REQUEST: '%s'\n", url );
diff --git a/libpurple/protocols/mxit/markup.c b/libpurple/protocols/mxit/markup.c
--- a/libpurple/protocols/mxit/markup.c
+++ b/libpurple/protocols/mxit/markup.c
@@ -490,6 +490,9 @@ static void emoticon_returned( PurpleUti
 	purple_debug_info( MXIT_PLUGIN_ID, "emoticon_returned\n" );
 #endif
 
+	/* remove request from the async outstanding calls list */
+	mx->session->async_calls = g_slist_remove( mx->session->async_calls, url_data );
+
 	if ( !url_text ) {
 		/* no reply from the WAP site */
 		purple_debug_error( MXIT_PLUGIN_ID, "Error contacting the MXit WAP site. Please try again later (emoticon).\n" );
@@ -634,8 +637,10 @@ static void emoticon_request( struct RXM
 
 	/* reference: "libpurple/util.h" */
 	url = g_strdup_printf( "%s/res/?type=emo&mlh=%i&sc=%s&ts=%li", wapserver, MXIT_EMOTICON_SIZE, id, time( NULL ) );
-	/* FIXME: This should be cancelled somewhere if not needed. */
 	url_data = purple_util_fetch_url( url, TRUE, NULL, TRUE, -1, emoticon_returned, mx );
+	if ( url_data )
+		mx->session->async_calls = g_slist_prepend( mx->session->async_calls, url_data );
+
 	g_free( url );
 }
 
diff --git a/libpurple/protocols/mxit/mxit.h b/libpurple/protocols/mxit/mxit.h
--- a/libpurple/protocols/mxit/mxit.h
+++ b/libpurple/protocols/mxit/mxit.h
@@ -141,7 +141,6 @@ struct MXitSession {
 	int					http_interval;				/* poll inverval */
 	gint64				http_last_poll;				/* the last time a poll has been sent */
 	guint				http_handler;				/* HTTP connection handler */
-	void*				http_out_req;				/* HTTP outstanding request */
 
 	/* other servers */
 	char				voip_server[HOST_NAME_MAX];	/* voice/video server */
@@ -169,6 +168,7 @@ struct MXitSession {
 	int					outack;						/* outstanding ack packet */
 	guint				q_slow_timer_id;			/* timer handle for slow tx queue */
 	guint				q_fast_timer_id;			/* timer handle for fast tx queue */
+	GSList*				async_calls;				/* list of current outstanding async calls */
 
 	/* receive */
 	char				rx_lbuf[16];				/* receive byte buffer (socket packet length) */
diff --git a/libpurple/protocols/mxit/protocol.c b/libpurple/protocols/mxit/protocol.c
--- a/libpurple/protocols/mxit/protocol.c
+++ b/libpurple/protocols/mxit/protocol.c
@@ -268,7 +268,7 @@ static void mxit_cb_http_rx( PurpleUtilF
 	struct MXitSession*		session		= (struct MXitSession*) user_data;
 
 	/* clear outstanding request */
-	session->http_out_req = NULL;
+	session->async_calls = g_slist_remove( session->async_calls, url_data );
 
 	if ( ( !url_text ) || ( len == 0 ) ) {
 		/* error with request */
@@ -294,6 +294,7 @@ static void mxit_cb_http_rx( PurpleUtilF
  */
 static void mxit_write_http_get( struct MXitSession* session, struct tx_packet* packet )
 {
+	PurpleUtilFetchUrlData*	url_data;
 	char*		part	= NULL;
 	char*		url		= NULL;
 
@@ -312,7 +313,9 @@ static void mxit_write_http_get( struct 
 #endif
 
 	/* send the HTTP request */
-	session->http_out_req = purple_util_fetch_url_request( session->acc, url, TRUE, MXIT_HTTP_USERAGENT, TRUE, NULL, FALSE, -1, mxit_cb_http_rx, session );
+	url_data = purple_util_fetch_url_request( session->acc, url, TRUE, MXIT_HTTP_USERAGENT, TRUE, NULL, FALSE, -1, mxit_cb_http_rx, session );
+	if ( url_data )
+		session->async_calls = g_slist_prepend( session->async_calls, url_data );
 
 	g_free( url );
 	if ( part )
@@ -2874,10 +2877,10 @@ void mxit_close_connection( struct MXitS
 	}
 	session->flags &= ~MXIT_FLAG_CONNECTED;
 
-	/* cancel outstanding HTTP request */
-	if ( ( session->http ) && ( session->http_out_req ) ) {
-		purple_util_fetch_url_cancel( (PurpleUtilFetchUrlData*) session->http_out_req );
-		session->http_out_req = NULL;
+	/* cancel all outstanding async calls */
+	while ( session->async_calls ) {
+		purple_util_fetch_url_cancel( session->async_calls->data );
+		session->async_calls = g_slist_delete_link(session->async_calls, session->async_calls);
 	}
 
 	/* remove the input cb function */
diff --git a/libpurple/protocols/mxit/roster.c b/libpurple/protocols/mxit/roster.c
--- a/libpurple/protocols/mxit/roster.c
+++ b/libpurple/protocols/mxit/roster.c
@@ -750,8 +750,10 @@ void mxit_add_buddy( PurpleConnection* g
 
 		if ( buddy_name[0] == '#' ) {
 			gchar *tmp = (gchar*) purple_base64_decode( buddy_name + 1, NULL );
-			mxit_send_invite( session, tmp, FALSE, buddy_alias, group_name, message );
-			g_free( tmp );
+			if ( tmp ) {
+				mxit_send_invite( session, tmp, FALSE, buddy_alias, group_name, message );
+				g_free( tmp );
+			}
 		}
 		else
 			mxit_send_invite( session, buddy_name, TRUE, buddy_alias, group_name, message );



More information about the Commits mailing list