Mercurial > pidgin.yaz
changeset 32398:307e851bc3a1
Use PurpleXfer accessor functions.
author | andrew.victor@mxit.com |
---|---|
date | Tue, 23 Aug 2011 21:39:07 +0000 |
parents | 404f8a1d98d7 |
children | 4ba344c46349 |
files | libpurple/protocols/mxit/filexfer.c |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/mxit/filexfer.c Tue Aug 23 21:06:12 2011 +0000 +++ b/libpurple/protocols/mxit/filexfer.c Tue Aug 23 21:39:07 2011 +0000 @@ -126,7 +126,7 @@ if ( purple_xfer_get_size( xfer ) > CP_MAX_FILESIZE ) { /* the file is too big */ - purple_xfer_error( xfer->type, xfer->account, xfer->who, _( "The file you are trying to send is too large!" ) ); + purple_xfer_error( purple_xfer_get_type( xfer ), purple_xfer_get_account( xfer ), purple_xfer_get_remote_user( xfer ), _( "The file you are trying to send is too large!" ) ); purple_xfer_cancel_local( xfer ); return; } @@ -151,6 +151,7 @@ */ static void mxit_xfer_start( PurpleXfer* xfer ) { + size_t filesize; unsigned char* buffer; int size; int wrote; @@ -163,10 +164,12 @@ * a buffer and copy the file data into memory and then we can send it to * the contact. we will send the whole file with one go. */ - buffer = g_malloc( xfer->bytes_remaining ); - size = fread( buffer, xfer->bytes_remaining, 1, xfer->dest_fp ); + filesize = purple_xfer_get_bytes_remaining( xfer ); + buffer = g_malloc( filesize ); + size = fread( buffer, filesize, 1, xfer->dest_fp ); + // TODO: If (size != 1) -> file read error - wrote = purple_xfer_write( xfer, buffer, xfer->bytes_remaining ); + wrote = purple_xfer_write( xfer, buffer, filesize ); if ( wrote > 0 ) purple_xfer_set_bytes_sent( xfer, wrote ); @@ -437,6 +440,7 @@ purple_xfer_ref( xfer ); purple_xfer_start( xfer, -1, NULL, 0 ); fwrite( data, datalen, 1, xfer->dest_fp ); + // TODO: Handle error from fwrite() purple_xfer_unref( xfer ); purple_xfer_set_completed( xfer, TRUE ); purple_xfer_end( xfer );