comparison libgaim/protocols/irc/dcc_send.c @ 14267:645598a4ec04

[gaim-migrate @ 16949] Change gaim_network_listen() and gaim_network_listen_range() to be cancelable. This doesn't actually help anything yet, since the gaim_upnp_functions() are not yet cancelable. But the framework is there, and the PRPLs shouldn't need any additional changes. Still to go: gaim_upnp_everything() gaim_url_fetch() gaim_srv_resolve() Let me know if there are others committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 21 Aug 2006 07:47:03 +0000
parents 60b1bc8dbf37
children c2f15e2117dc
comparison
equal deleted inserted replaced
14266:63ef6342db05 14267:645598a4ec04
140 /******************************************************************* 140 /*******************************************************************
141 * Functions related to sending files via DCC SEND 141 * Functions related to sending files via DCC SEND
142 *******************************************************************/ 142 *******************************************************************/
143 143
144 struct irc_xfer_send_data { 144 struct irc_xfer_send_data {
145 GaimNetworkListenData *listen_data;
145 gint inpa; 146 gint inpa;
146 int fd; 147 int fd;
147 guchar *rxqueue; 148 guchar *rxqueue;
148 guint rxlen; 149 guint rxlen;
149 }; 150 };
153 struct irc_xfer_send_data *xd = xfer->data; 154 struct irc_xfer_send_data *xd = xfer->data;
154 155
155 if (xd == NULL) 156 if (xd == NULL)
156 return; 157 return;
157 158
159 if (xd->listen_data != NULL)
160 gaim_network_listen_cancel(xd->listen_data);
158 if (xd->inpa > 0) 161 if (xd->inpa > 0)
159 gaim_input_remove(xd->inpa); 162 gaim_input_remove(xd->inpa);
160 if (xd->fd != -1) 163 if (xd->fd != -1)
161 close(xd->fd); 164 close(xd->fd);
162 165
269 const char *arg[2]; 272 const char *arg[2];
270 char *tmp; 273 char *tmp;
271 struct in_addr addr; 274 struct in_addr addr;
272 unsigned short int port; 275 unsigned short int port;
273 276
277 xd = xfer->data;
278 xd->listen_data = NULL;
279
274 if (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL 280 if (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL
275 || gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_REMOTE) { 281 || gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_REMOTE) {
276 gaim_xfer_unref(xfer); 282 gaim_xfer_unref(xfer);
277 return; 283 return;
278 } 284 }
312 /* 318 /*
313 * This function is called after the user has selected a file to send. 319 * This function is called after the user has selected a file to send.
314 */ 320 */
315 static void irc_dccsend_send_init(GaimXfer *xfer) { 321 static void irc_dccsend_send_init(GaimXfer *xfer) {
316 GaimConnection *gc = gaim_account_get_connection(gaim_xfer_get_account(xfer)); 322 GaimConnection *gc = gaim_account_get_connection(gaim_xfer_get_account(xfer));
323 struct irc_xfer_send_data *xd = xfer->data;
317 324
318 xfer->filename = g_path_get_basename(xfer->local_filename); 325 xfer->filename = g_path_get_basename(xfer->local_filename);
319 326
320 gaim_xfer_ref(xfer); 327 gaim_xfer_ref(xfer);
321 328
322 /* Create a listening socket */ 329 /* Create a listening socket */
323 if (!gaim_network_listen_range(0, 0, SOCK_STREAM, 330 xd->listen_data = gaim_network_listen_range(0, 0, SOCK_STREAM,
324 irc_dccsend_network_listen_cb, xfer)) { 331 irc_dccsend_network_listen_cb, xfer);
332 if (xd->listen_data == NULL) {
325 gaim_xfer_unref(xfer); 333 gaim_xfer_unref(xfer);
326 gaim_notify_error(gc, NULL, _("File Transfer Failed"), 334 gaim_notify_error(gc, NULL, _("File Transfer Failed"),
327 _("Gaim could not open a listening port.")); 335 _("Gaim could not open a listening port."));
328 gaim_xfer_cancel_local(xfer); 336 gaim_xfer_cancel_local(xfer);
329 } 337 }