comparison src/protocols/yahoo/yahoo_filexfer.c @ 14089:10e8eb6a4910

[gaim-migrate @ 16712] Pretty large commit here. Basically I got sick of having to verify that gc is still valid on all the callback functions for gaim_proxy_connect(). The fix for this for gaim_proxy_connect() to return something that allows the connection attempt to be canceled. It's not quite there yet, but this is a good first step. I changed gaim_proxy_connect() to return a reference to a new GaimProxyConnectInfo (this used to be called PHB). Eventually this can be passed to a function that'll cancel the connection attempt. I also decided to add an error_cb instead of using connect_cb and passing a file descriptor of -1. And proxy.c will also pass an error message to callers which should explain the reason that the connection attempt failed. Oh, and proxy.c now never calls gaim_connection_error() committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 12 Aug 2006 10:12:43 +0000
parents b7e4180af1db
children 7a205b430d19
comparison
equal deleted inserted replaced
14088:223570831b0b 14089:10e8eb6a4910
90 90
91 gaim_xfer_start(xfer, source, NULL, 0); 91 gaim_xfer_start(xfer, source, NULL, 0);
92 92
93 } 93 }
94 94
95 static void yahoo_receivefile_connected(gpointer data, gint source, GaimInputCondition condition) 95 static void yahoo_receivefile_connected(gpointer data, gint source)
96 { 96 {
97 GaimXfer *xfer; 97 GaimXfer *xfer;
98 struct yahoo_xfer_data *xd; 98 struct yahoo_xfer_data *xd;
99 99
100 gaim_debug(GAIM_DEBUG_INFO, "yahoo", 100 gaim_debug(GAIM_DEBUG_INFO, "yahoo",
160 xd->txbuflen = 0; 160 xd->txbuflen = 0;
161 161
162 gaim_xfer_start(xfer, source, NULL, 0); 162 gaim_xfer_start(xfer, source, NULL, 0);
163 } 163 }
164 164
165 static void yahoo_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) 165 static void yahoo_sendfile_connected(gpointer data, gint source)
166 { 166 {
167 GaimXfer *xfer; 167 GaimXfer *xfer;
168 struct yahoo_xfer_data *xd; 168 struct yahoo_xfer_data *xd;
169 struct yahoo_packet *pkt; 169 struct yahoo_packet *pkt;
170 gchar *size, *filename, *encoded_filename, *header; 170 gchar *size, *filename, *encoded_filename, *header;
261 261
262 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { 262 if (gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) {
263 if (yd->jp) { 263 if (yd->jp) {
264 if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), 264 if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST),
265 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), 265 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
266 yahoo_sendfile_connected, xfer) == -1) 266 yahoo_sendfile_connected, NULL, xfer) == NULL)
267 { 267 {
268 gaim_notify_error(gc, NULL, _("File Transfer Failed"), 268 gaim_notify_error(gc, NULL, _("File Transfer Failed"),
269 _("Unable to establish file descriptor.")); 269 _("Unable to establish file descriptor."));
270 gaim_xfer_cancel_remote(xfer); 270 gaim_xfer_cancel_remote(xfer);
271 } 271 }
272 } else { 272 } else {
273 if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), 273 if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST),
274 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), 274 gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
275 yahoo_sendfile_connected, xfer) == -1) 275 yahoo_sendfile_connected, NULL, xfer) == NULL)
276 { 276 {
277 gaim_notify_error(gc, NULL, _("File Transfer Failed"), 277 gaim_notify_error(gc, NULL, _("File Transfer Failed"),
278 _("Unable to establish file descriptor.")); 278 _("Unable to establish file descriptor."));
279 gaim_xfer_cancel_remote(xfer); 279 gaim_xfer_cancel_remote(xfer);
280 } 280 }
281 } 281 }
282 } else { 282 } else {
283 xfer->fd = gaim_proxy_connect(account, xfer_data->host, xfer_data->port, 283 /* TODO: Using xfer->fd like this is probably a bad thing... */
284 yahoo_receivefile_connected, xfer); 284 if (gaim_proxy_connect(account, xfer_data->host, xfer_data->port,
285 yahoo_receivefile_connected, NULL, xfer) == NULL)
286 xfer->fd = -1;
287 else
288 xfer->fd = 0;
285 if (xfer->fd == -1) { 289 if (xfer->fd == -1) {
286 gaim_notify_error(gc, NULL, _("File Transfer Failed"), 290 gaim_notify_error(gc, NULL, _("File Transfer Failed"),
287 _("Unable to establish file descriptor.")); 291 _("Unable to establish file descriptor."));
288 gaim_xfer_cancel_remote(xfer); 292 gaim_xfer_cancel_remote(xfer);
289 } 293 }