diff libgaim/protocols/yahoo/yahoo_picture.c @ 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 776615acf309
children 118fd0dc5b6e
line wrap: on
line diff
--- 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)