comparison src/ft.c @ 4594:a2c95c0d7333

[gaim-migrate @ 4879] I need the ack thing so Gaim will be able to exchange files with MacAIM clizients. I think. The other changes makes gaim call gaim_xfer_end after reading in the # of bytes in the file. Previously it only called gaim_xfer_end when the other end closed the socket. I could write an oscar_xfer_read function that does this, but I would basically be duplicating all of gaim_xfer_read, and I thought this was a little clean. Chipster can lay the smack down on me if this is too ugly. I figured some of this will have to change if multiple files per transfer is ever supported. Gaim doesn't provide support for that [insert "support" related joke here]. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 20 Feb 2003 21:08:46 +0000
parents ff3b123aed43
children 63c022ca157c
comparison
equal deleted inserted replaced
4593:26992c8e8e21 4594:a2c95c0d7333
435 else { 435 else {
436 *buffer = g_malloc0(s); 436 *buffer = g_malloc0(s);
437 437
438 r = read(xfer->fd, *buffer, s); 438 r = read(xfer->fd, *buffer, s);
439 439
440 if (r == 0) 440 if ((r == 0) || ((gaim_xfer_get_size > 0) &&
441 ((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer))))
441 gaim_xfer_set_completed(xfer, TRUE); 442 gaim_xfer_set_completed(xfer, TRUE);
442 } 443 }
443 444
444 return r; 445 return r;
445 } 446 }
490 /* We have to seek back in the file now. */ 491 /* We have to seek back in the file now. */
491 fseek(xfer->dest_fp, r - s, SEEK_CUR); 492 fseek(xfer->dest_fp, r - s, SEEK_CUR);
492 } 493 }
493 } 494 }
494 495
495 g_free(buffer);
496
497 if (gaim_xfer_get_size(xfer) > 0) 496 if (gaim_xfer_get_size(xfer) > 0)
498 xfer->bytes_remaining -= r; 497 xfer->bytes_remaining -= r;
499 498
500 xfer->bytes_sent += r; 499 xfer->bytes_sent += r;
501 500
502 if (xfer->ops.ack != NULL) 501 if (xfer->ops.ack != NULL)
503 xfer->ops.ack(xfer); 502 xfer->ops.ack(xfer, buffer, r);
503
504 g_free(buffer);
504 505
505 ui_ops = gaim_xfer_get_ui_ops(xfer); 506 ui_ops = gaim_xfer_get_ui_ops(xfer);
506 507
507 if (ui_ops != NULL && ui_ops->update_progress != NULL) 508 if (ui_ops != NULL && ui_ops->update_progress != NULL)
508 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer)); 509 ui_ops->update_progress(xfer, gaim_xfer_get_progress(xfer));