comparison src/ft.c @ 8316:cf84056fed27

[gaim-migrate @ 9040] this still needs a lot of work, but for the special case of perfect conditions and no errors, you can now send files via jabber. enjoy! committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 22 Feb 2004 22:10:47 +0000
parents b5dbd1839716
children ffa642240fc1
comparison
equal deleted inserted replaced
8315:52ea0ab31caa 8316:cf84056fed27
461 461
462 r = read(xfer->fd, *buffer, s); 462 r = read(xfer->fd, *buffer, s);
463 if ((gaim_xfer_get_size(xfer) > 0) && 463 if ((gaim_xfer_get_size(xfer) > 0) &&
464 ((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer))) 464 ((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer)))
465 gaim_xfer_set_completed(xfer, TRUE); 465 gaim_xfer_set_completed(xfer, TRUE);
466 else if(r <= 0)
467 r = -1;
466 } 468 }
467 469
468 return r; 470 return r;
469 } 471 }
470 472
494 transfer_cb(gpointer data, gint source, GaimInputCondition condition) 496 transfer_cb(gpointer data, gint source, GaimInputCondition condition)
495 { 497 {
496 GaimXferUiOps *ui_ops; 498 GaimXferUiOps *ui_ops;
497 GaimXfer *xfer = (GaimXfer *)data; 499 GaimXfer *xfer = (GaimXfer *)data;
498 char *buffer = NULL; 500 char *buffer = NULL;
499 size_t r; 501 ssize_t r;
500 502
501 if (condition & GAIM_INPUT_READ) { 503 if (condition & GAIM_INPUT_READ) {
502 r = gaim_xfer_read(xfer, &buffer); 504 r = gaim_xfer_read(xfer, &buffer);
503 if (r > 0) 505 if (r > 0) {
504 fwrite(buffer, 1, r, xfer->dest_fp); 506 fwrite(buffer, 1, r, xfer->dest_fp);
507 } else if(r < 0) {
508 gaim_xfer_cancel_remote(xfer);
509 return;
510 }
505 } 511 }
506 else { 512 else {
507 size_t s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096); 513 size_t s = MIN(gaim_xfer_get_bytes_remaining(xfer), 4096);
508 514
509 buffer = g_malloc0(s); 515 buffer = g_malloc0(s);