comparison src/protocols/yahoo/yahoo_filexfer.c @ 7805:5f0bb52c0609

[gaim-migrate @ 8452] File transfer changes from marv. This fixes various ft related bugs, including: * Sometimes clicking cancel on a send would crash. * We seemed to leak the GaimXfer most of the time. * Choosing to not overwrite the file would cancel the receive altogether. This should fix all these issues. It would be nice if someone (SimGuy?) could test this for me, especially on windows, to make sure i didn't break anything. Jabber ft is untested, althoughi didn't make any changes in the jabber source. So, it should still work, i just can't comfirm it. Yahoo and OSCAR do still work. Amoung other things, this patch impliments some reference counting on the GaimXfer, so the ui can keep it around a while if it wants, without leaking it because we're afraid to destroy it. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 08 Dec 2003 04:58:07 +0000
parents 45fd907e1d48
children ee32e030c9be
comparison
equal deleted inserted replaced
7804:622c9149609c 7805:5f0bb52c0609
66 return; 66 return;
67 if (!(xd = xfer->data)) 67 if (!(xd = xfer->data))
68 return; 68 return;
69 if (source < 0) { 69 if (source < 0) {
70 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, _("Unable to connect.")); 70 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, _("Unable to connect."));
71 gaim_xfer_end(xfer); 71 gaim_xfer_cancel_remote(xfer);
72 return; 72 return;
73 } 73 }
74 74
75 xfer->fd = source; 75 xfer->fd = source;
76 gaim_xfer_start(xfer, source, NULL, 0); 76 gaim_xfer_start(xfer, source, NULL, 0);
120 gchar *size, *post, *buf; 120 gchar *size, *post, *buf;
121 int content_length; 121 int content_length;
122 GaimConnection *gc; 122 GaimConnection *gc;
123 GaimAccount *account; 123 GaimAccount *account;
124 struct yahoo_data *yd; 124 struct yahoo_data *yd;
125 char *filename;
125 126
126 gaim_debug(GAIM_DEBUG_INFO, "yahoo", 127 gaim_debug(GAIM_DEBUG_INFO, "yahoo",
127 "AAA - in yahoo_sendfile_connected\n"); 128 "AAA - in yahoo_sendfile_connected\n");
128 if (!(xfer = data)) 129 if (!(xfer = data))
129 return; 130 return;
136 137
137 138
138 139
139 if (source < 0) { 140 if (source < 0) {
140 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, _("Unable to connect.")); 141 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, _("Unable to connect."));
141 gaim_xfer_end(xfer); 142 gaim_xfer_cancel_remote(xfer);
142 return; 143 return;
143 } 144 }
144 145
145 xfer->fd = source; 146 xfer->fd = source;
146 gaim_xfer_start(xfer, source, NULL, 0); 147 gaim_xfer_start(xfer, source, NULL, 0);
151 size = g_strdup_printf("%d", gaim_xfer_get_size(xfer)); 152 size = g_strdup_printf("%d", gaim_xfer_get_size(xfer));
152 153
153 yahoo_packet_hash(pkt, 0, gaim_connection_get_display_name(gc)); 154 yahoo_packet_hash(pkt, 0, gaim_connection_get_display_name(gc));
154 yahoo_packet_hash(pkt, 5, xfer->who); 155 yahoo_packet_hash(pkt, 5, xfer->who);
155 yahoo_packet_hash(pkt, 14, ""); 156 yahoo_packet_hash(pkt, 14, "");
156 yahoo_packet_hash(pkt, 27, gaim_xfer_get_local_filename(xfer)); 157 filename = g_path_get_basename(gaim_xfer_get_local_filename(xfer));
158 yahoo_packet_hash(pkt, 27, filename);
157 yahoo_packet_hash(pkt, 28, size); 159 yahoo_packet_hash(pkt, 28, size);
158 160
159 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); 161 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);
160 162
161 buf = g_strdup_printf("Y=%s; T=%s", yd->cookie_y, yd->cookie_t); 163 buf = g_strdup_printf("Y=%s; T=%s", yd->cookie_y, yd->cookie_t);
177 write(xfer->fd, "29\xc0\x80", 4); 179 write(xfer->fd, "29\xc0\x80", 4);
178 180
179 g_free(size); 181 g_free(size);
180 g_free(post); 182 g_free(post);
181 g_free(buf); 183 g_free(buf);
184 g_free(filename);
182 } 185 }
183 186
184 static void yahoo_xfer_init(GaimXfer *xfer) 187 static void yahoo_xfer_init(GaimXfer *xfer)
185 { 188 {
186 struct yahoo_xfer_data *xfer_data; 189 struct yahoo_xfer_data *xfer_data;
515 gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv); 518 gaim_xfer_set_cancel_recv_fnc(xfer, yahoo_xfer_cancel_recv);
516 gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read); 519 gaim_xfer_set_read_fnc(xfer, yahoo_xfer_read);
517 gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write); 520 gaim_xfer_set_write_fnc(xfer, yahoo_xfer_write);
518 521
519 /* Now perform the request */ 522 /* Now perform the request */
520 gaim_xfer_request_accepted(xfer, g_strdup(file)); 523 gaim_xfer_request_accepted(xfer, file);
521 } 524 }