Mercurial > pidgin
changeset 13207:8facf33a528a
[gaim-migrate @ 15571]
quiet some debugging. fixes in outgoing file transfers so that they'll show as complete (this is actualy a bug in Meanwhile, but I'm in the middle of a large rewrite right now). hopefully this will speed up sametime ft for some people, too. Or it could just consume more server resources and make everyone hate me, I dunno.
committer: Tailor Script <tailor@pidgin.im>
author | Christopher O'Brien <siege@pidgin.im> |
---|---|
date | Thu, 09 Feb 2006 19:04:36 +0000 |
parents | 0c4db52c6a3d |
children | de4f1fb08088 |
files | src/protocols/sametime/sametime.c |
diffstat | 1 files changed, 26 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/sametime/sametime.c Thu Feb 09 14:06:10 2006 +0000 +++ b/src/protocols/sametime/sametime.c Thu Feb 09 19:04:36 2006 +0000 @@ -393,7 +393,6 @@ while(len) { ret = write(pd->socket, buf, (len > BUF_LEN)? BUF_LEN: len); - DEBUG_INFO("wrote %i bytes in one turn\n", ret); if(ret <= 0) break; @@ -2025,6 +2024,10 @@ } +/** size of an outgoing file transfer chunk */ +#define MW_FT_LEN (BUF_LONG * 2) + + static void ft_incoming_cancel(GaimXfer *xfer) { /* incoming transfer rejected or canceled in-progress */ struct mwFileTransfer *ft = xfer->data; @@ -2104,28 +2107,28 @@ static void ft_send(struct mwFileTransfer *ft, FILE *fp) { - guchar buf[BUF_LONG]; - struct mwOpaque o = { .data = buf, .len = BUF_LONG }; + guchar buf[MW_FT_LEN]; + struct mwOpaque o = { .data = buf, .len = MW_FT_LEN }; guint32 rem; GaimXfer *xfer; xfer = mwFileTransfer_getClientData(ft); rem = mwFileTransfer_getRemaining(ft); - if(rem < BUF_LONG) o.len = rem; + if(rem < MW_FT_LEN) o.len = rem; if(fread(buf, (size_t) o.len, 1, fp)) { - /* calculate progress first. update is displayed upon ack */ + /* calculate progress and display it */ xfer->bytes_sent += o.len; xfer->bytes_remaining -= o.len; - - /* ... send data second */ + gaim_xfer_update_progress(xfer); + mwFileTransfer_send(ft, &o); } else { int err = errno; - DEBUG_WARN("problem reading from file %s: %s", + DEBUG_WARN("problem reading from file %s: %s\n", NSTR(mwFileTransfer_getFileName(ft)), strerror(err)); mwFileTransfer_cancel(ft); @@ -2133,17 +2136,6 @@ } -static gboolean ft_idle_cb(struct mwFileTransfer *ft) { - GaimXfer *xfer = mwFileTransfer_getClientData(ft); - g_return_val_if_fail(xfer != NULL, FALSE); - - xfer->watcher = 0; - ft_send(ft, xfer->dest_fp); - - return FALSE; -} - - static void mw_ft_opened(struct mwFileTransfer *ft) { /* - get gaim ft from client data in ft @@ -2160,11 +2152,9 @@ g_return_if_reached(); } - gaim_xfer_update_progress(xfer); - if(gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { - xfer->watcher = g_idle_add((GSourceFunc)ft_idle_cb, ft); xfer->dest_fp = g_fopen(xfer->local_filename, "rb"); + ft_send(ft, xfer->dest_fp); } } @@ -2182,7 +2172,7 @@ if(xfer) { xfer->data = NULL; - if(mwFileTransfer_isDone(ft)) { + if(! mwFileTransfer_getRemaining(ft)) { gaim_xfer_set_completed(xfer, TRUE); gaim_xfer_end(xfer); @@ -2243,10 +2233,13 @@ g_return_if_fail(xfer != NULL); g_return_if_fail(xfer->watcher == 0); - gaim_xfer_update_progress(xfer); - - if(mwFileTransfer_isOpen(ft)) - xfer->watcher = g_idle_add((GSourceFunc)ft_idle_cb, ft); + if(! mwFileTransfer_getRemaining(ft)) { + gaim_xfer_set_completed(xfer, TRUE); + gaim_xfer_end(xfer); + + } else if(mwFileTransfer_isOpen(ft)) { + ft_send(ft, xfer->dest_fp); + } } @@ -4943,6 +4936,8 @@ filesize = gaim_xfer_get_size(xfer); idb.user = xfer->who; + gaim_xfer_update_progress(xfer); + /* test that we can actually send the file */ fp = g_fopen(filename, "rb"); if(! fp) { @@ -4971,6 +4966,9 @@ static void ft_outgoing_cancel(GaimXfer *xfer) { struct mwFileTransfer *ft = xfer->data; + + DEBUG_INFO("ft_outgoing_cancel called\n"); + if(ft) mwFileTransfer_cancel(ft); } @@ -4984,7 +4982,7 @@ xfer = gaim_xfer_new(acct, GAIM_XFER_SEND, who); gaim_xfer_set_init_fnc(xfer, ft_outgoing_init); gaim_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); - + return xfer; }