comparison src/protocols/irc/dcc_send.c @ 12143:cbebda5f019c

[gaim-migrate @ 14444] SF Patch #1360399 from Evan Schoenberg (evands) "I discussed this previously with Mark and he said it'd be fine. This factors out the part of the send_file function which creates a new GaimXfer into a separate prpl function, new_xfer. It's called in each of the existing send_file functions. This is needed so that another client (okay, Adium) can get a new outgoing GaimXfer from a prpl without depending upon the specific ft.c logic of send_file; previously I was adding a duplicate method to each prpl and then calling it directly." I fixed a couple small bugs in this. Otherwise, it looks good, and seems like a reasonable libgaim request. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sat, 19 Nov 2005 00:26:12 +0000
parents f9c5480ad0ce
children de798f2f4bf1
comparison
equal deleted inserted replaced
12142:0c672be21798 12143:cbebda5f019c
292 292
293 irc_cmd_privmsg(gc->proto_data, "msg", NULL, arg); 293 irc_cmd_privmsg(gc->proto_data, "msg", NULL, arg);
294 g_free(tmp); 294 g_free(tmp);
295 } 295 }
296 296
297 GaimXfer *irc_dccsend_new_xfer(GaimConnection *gc, const char *who) {
298 GaimXfer *xfer;
299 struct irc_xfer_send_data *xd;
300
301 /* Build the file transfer handle */
302 xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, who);
303
304 xd = g_new0(struct irc_xfer_send_data, 1);
305 xd->fd = -1;
306 xfer->data = xd;
307
308 /* Setup our I/O op functions */
309 gaim_xfer_set_init_fnc(xfer, irc_dccsend_send_init);
310 gaim_xfer_set_write_fnc(xfer, irc_dccsend_send_write);
311 gaim_xfer_set_end_fnc(xfer, irc_dccsend_send_destroy);
312 gaim_xfer_set_request_denied_fnc(xfer, irc_dccsend_send_destroy);
313 gaim_xfer_set_cancel_send_fnc(xfer, irc_dccsend_send_destroy);
314
315 return xfer;
316 }
317
297 /** 318 /**
298 * Gaim calls this function when the user selects Send File from the 319 * Gaim calls this function when the user selects Send File from the
299 * buddy menu 320 * buddy menu
300 * It sets up the GaimXfer struct and tells Gaim to go ahead 321 * It sets up the GaimXfer struct and tells Gaim to go ahead
301 */ 322 */
302 void irc_dccsend_send_file(GaimConnection *gc, const char *who, const char *file) { 323 void irc_dccsend_send_file(GaimConnection *gc, const char *who, const char *file) {
303 GaimXfer *xfer; 324 GaimXfer *xfer = irc_dccsend_new_xfer(gc, who);
304 struct irc_xfer_send_data *xd; 325
305 326 /* Perform the request */
306 /* Build the file transfer handle */
307 xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, who);
308
309
310 xd = g_new0(struct irc_xfer_send_data, 1);
311 xd->fd = -1;
312 xfer->data = xd;
313
314 /* Setup our I/O op functions */
315 gaim_xfer_set_init_fnc(xfer, irc_dccsend_send_init);
316 gaim_xfer_set_write_fnc(xfer, irc_dccsend_send_write);
317 gaim_xfer_set_end_fnc(xfer, irc_dccsend_send_destroy);
318 gaim_xfer_set_request_denied_fnc(xfer, irc_dccsend_send_destroy);
319 gaim_xfer_set_cancel_send_fnc(xfer, irc_dccsend_send_destroy);
320 /* Now perform the request */
321 if (file) 327 if (file)
322 gaim_xfer_request_accepted(xfer, file); 328 gaim_xfer_request_accepted(xfer, file);
323 else 329 else
324 gaim_xfer_request(xfer); 330 gaim_xfer_request(xfer);
325 } 331 }