changeset 14631:622931ca5622

[gaim-migrate @ 17377] A pending yahoo_buddy_icon_upload() request is now cancelled when disconnecting or if a second upload request is made, which can happen if the user rapidly changes buddy icons. committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Tue, 26 Sep 2006 23:20:39 +0000
parents 275c84b1b2a4
children 108152f29f37
files libgaim/protocols/yahoo/yahoo.c libgaim/protocols/yahoo/yahoo.h libgaim/protocols/yahoo/yahoo_picture.c
diffstat 3 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/yahoo/yahoo.c	Tue Sep 26 23:02:40 2006 +0000
+++ b/libgaim/protocols/yahoo/yahoo.c	Tue Sep 26 23:20:39 2006 +0000
@@ -2778,6 +2778,8 @@
 	yd->rxlen = 0;
 	g_free(yd->picture_url);
 
+	if (yd->buddy_icon_connect_data)
+		gaim_proxy_connect_cancel(yd->buddy_icon_connect_data);
 	if (yd->picture_upload_todo)
 		yahoo_buddy_icon_upload_data_free(yd->picture_upload_todo);
 	if (yd->ycht)
--- a/libgaim/protocols/yahoo/yahoo.h	Tue Sep 26 23:02:40 2006 +0000
+++ b/libgaim/protocols/yahoo/yahoo.h	Tue Sep 26 23:20:39 2006 +0000
@@ -137,6 +137,7 @@
 	/* ew. we have to check the icon before we connect,
 	 * but can't upload it til we're connected. */
 	struct yahoo_buddy_icon_upload_data *picture_upload_todo;
+	GaimProxyConnectData *buddy_icon_connect_data;
 
 	struct _YchtConn *ycht;
 
--- a/libgaim/protocols/yahoo/yahoo_picture.c	Tue Sep 26 23:02:40 2006 +0000
+++ b/libgaim/protocols/yahoo/yahoo_picture.c	Tue Sep 26 23:20:39 2006 +0000
@@ -444,13 +444,15 @@
 	account = gaim_connection_get_account(gc);
 	yd = gc->proto_data;
 
+	/* Buddy icon connect is now complete; clear the GaimProxyConnectData */
+	yd->buddy_icon_connect_data = NULL;
+
 	if (source < 0) {
 		gaim_debug_error("yahoo", "Buddy icon upload failed, no file desc.\n");
 		yahoo_buddy_icon_upload_data_free(d);
 		return;
 	}
 
-
 	pkt = yahoo_packet_new(0xc2, YAHOO_STATUS_AVAILABLE, yd->session_id);
 
 	size = g_strdup_printf("%" G_GSIZE_FORMAT, d->str->len);
@@ -498,26 +500,37 @@
 {
 	GaimAccount *account = gaim_connection_get_account(gc);
 	struct yahoo_data *yd = gc->proto_data;
+	GaimProxyConnectData *connect_data = NULL;
 
 	g_return_if_fail(d != NULL);
 
+	if (yd->buddy_icon_connect_data) {
+		/* Cancel any in-progress buddy icon upload */
+		gaim_proxy_connect_cancel(yd->buddy_icon_connect_data);
+		yd->buddy_icon_connect_data = NULL;
+	}
+
 	if (yd->jp) {
-		if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host",  YAHOOJP_XFER_HOST),
-		                       gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
-		                       yahoo_buddy_icon_upload_connected, d) == NULL)
+		if ((connect_data = gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host",  YAHOOJP_XFER_HOST),
+											   gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
+											   yahoo_buddy_icon_upload_connected, d)) == NULL)
 		{
 			gaim_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n");
 			yahoo_buddy_icon_upload_data_free(d);
 		}
 	} else {
-		if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host",  YAHOO_XFER_HOST),
-		                       gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
-		                       yahoo_buddy_icon_upload_connected, d) == NULL)
+		if ((connect_data = gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host",  YAHOO_XFER_HOST),
+											   gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
+											   yahoo_buddy_icon_upload_connected, d)) == NULL)
 		{
 			gaim_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n");
 			yahoo_buddy_icon_upload_data_free(d);
 		}
 	}
+
+	if (connect_data) {
+		yd->buddy_icon_connect_data = connect_data;
+	}
 }
 
 void yahoo_set_buddy_icon(GaimConnection *gc, const char *iconfile)