Merge with release-2.x.y

Wed, 06 Mar 2013 10:34:45 -0500

author
Daniel Atallah <datallah@pidgin.im>
date
Wed, 06 Mar 2013 10:34:45 -0500
changeset 33817
5c8caea5bd66
parent 33814
4f41f47a9482 (current diff)
parent 33816
9eb08b587d95 (diff)
child 33818
75ff728af11c

Merge with release-2.x.y

libpurple/protocols/mxit/formcmds.c file | annotate | diff | comparison | revisions
libpurple/protocols/mxit/http.c file | annotate | diff | comparison | revisions
libpurple/protocols/mxit/login.c file | annotate | diff | comparison | revisions
libpurple/protocols/mxit/markup.c file | annotate | diff | comparison | revisions
libpurple/protocols/mxit/mxit.h file | annotate | diff | comparison | revisions
libpurple/protocols/mxit/protocol.c file | annotate | diff | comparison | revisions
libpurple/protocols/mxit/roster.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/mxit/formcmds.c	Sun Mar 03 20:01:23 2013 -0800
+++ b/libpurple/protocols/mxit/formcmds.c	Wed Mar 06 10:34:45 2013 -0500
@@ -413,6 +413,8 @@
 
 		/* 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);
--- a/libpurple/protocols/mxit/http.c	Sun Mar 03 20:01:23 2013 -0800
+++ b/libpurple/protocols/mxit/http.c	Wed Mar 06 10:34:45 2013 -0500
@@ -328,5 +328,8 @@
 
 	/* 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" ) );
+	}
 }
 
--- a/libpurple/protocols/mxit/login.c	Sun Mar 03 20:01:23 2013 -0800
+++ b/libpurple/protocols/mxit/login.c	Wed Mar 06 10:34:45 2013 -0500
@@ -393,6 +393,9 @@
 	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 @@
 			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 @@
 	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 @@
 
 	/* 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 );
--- a/libpurple/protocols/mxit/markup.c	Sun Mar 03 20:01:23 2013 -0800
+++ b/libpurple/protocols/mxit/markup.c	Wed Mar 06 10:34:45 2013 -0500
@@ -490,6 +490,9 @@
 	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 @@
 
 	/* 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 );
 }
 
--- a/libpurple/protocols/mxit/mxit.h	Sun Mar 03 20:01:23 2013 -0800
+++ b/libpurple/protocols/mxit/mxit.h	Wed Mar 06 10:34:45 2013 -0500
@@ -141,7 +141,6 @@
 	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 @@
 	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) */
--- a/libpurple/protocols/mxit/protocol.c	Sun Mar 03 20:01:23 2013 -0800
+++ b/libpurple/protocols/mxit/protocol.c	Wed Mar 06 10:34:45 2013 -0500
@@ -268,7 +268,7 @@
 	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_write_http_get( struct MXitSession* session, struct tx_packet* packet )
 {
+	PurpleUtilFetchUrlData*	url_data;
 	char*		part	= NULL;
 	char*		url		= NULL;
 
@@ -312,7 +313,9 @@
 #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 @@
 	}
 	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 */
--- a/libpurple/protocols/mxit/roster.c	Sun Mar 03 20:01:23 2013 -0800
+++ b/libpurple/protocols/mxit/roster.c	Wed Mar 06 10:34:45 2013 -0500
@@ -750,8 +750,10 @@
 
 		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 );

mercurial