changeset 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 26992c8e8e21
children 63c022ca157c
files src/ft.c src/ft.h src/protocols/irc/irc.c
diffstat 3 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/ft.c	Thu Feb 20 12:03:08 2003 +0000
+++ b/src/ft.c	Thu Feb 20 21:08:46 2003 +0000
@@ -437,7 +437,8 @@
 
 		r = read(xfer->fd, *buffer, s);
 
-		if (r == 0)
+		if ((r == 0) || ((gaim_xfer_get_size > 0) &&
+			((gaim_xfer_get_bytes_sent(xfer)+r) >= gaim_xfer_get_size(xfer))))
 			gaim_xfer_set_completed(xfer, TRUE);
 	}
 
@@ -492,15 +493,15 @@
 		}
 	}
 
-	g_free(buffer);
-
 	if (gaim_xfer_get_size(xfer) > 0)
 		xfer->bytes_remaining -= r;
 
 	xfer->bytes_sent += r;
 
 	if (xfer->ops.ack != NULL)
-		xfer->ops.ack(xfer);
+		xfer->ops.ack(xfer, buffer, r);
+
+	g_free(buffer);
 
 	ui_ops = gaim_xfer_get_ui_ops(xfer);
 
--- a/src/ft.h	Thu Feb 20 12:03:08 2003 +0000
+++ b/src/ft.h	Thu Feb 20 21:08:46 2003 +0000
@@ -96,7 +96,8 @@
 		size_t (*read)(char **buffer, struct gaim_xfer *xfer);
 		size_t (*write)(const char *buffer, size_t size,
 						struct gaim_xfer *xfer);
-		void (*ack)(struct gaim_xfer *xfer);
+		void (*ack)(struct gaim_xfer *xfer, const char *buffer, 
+						size_t size);
 
 	} ops;
 
--- a/src/protocols/irc/irc.c	Thu Feb 20 12:03:08 2003 +0000
+++ b/src/protocols/irc/irc.c	Thu Feb 20 21:08:46 2003 +0000
@@ -1257,7 +1257,7 @@
 }
 
 static void
-irc_xfer_ack(struct gaim_xfer *xfer)
+irc_xfer_ack(struct gaim_xfer *xfer, const char *buffer, size_t size)
 {
 	guint32 pos;