pidgin: 6a3d408d: Use PurpleXfer accessor functions.

andrew.victor at mxit.com andrew.victor at mxit.com
Tue Aug 23 17:46:00 EDT 2011


----------------------------------------------------------------------
Revision: 6a3d408df0ce6d4a341eaf1bc512dcc35660ed0c
Parent:   6044eee442ed89464ba4e9026243e445d6dfaaff
Author:   andrew.victor at mxit.com
Date:     08/23/11 17:39:07
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6a3d408df0ce6d4a341eaf1bc512dcc35660ed0c

Changelog: 

Use PurpleXfer accessor functions.


Changes against parent 6044eee442ed89464ba4e9026243e445d6dfaaff

  patched  libpurple/protocols/mxit/filexfer.c

-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/filexfer.c	9576aed2352576d211e851812aaae35fa83d11a7
+++ libpurple/protocols/mxit/filexfer.c	61b9bf019d2bfa400cfe73d214710b9b52f680c5
@@ -126,7 +126,7 @@ static void mxit_xfer_init( PurpleXfer* 
 
 		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*
  */
 static void mxit_xfer_start( PurpleXfer* xfer )
 {
+	size_t			filesize;
 	unsigned char*	buffer;
 	int				size;
 	int				wrote;
@@ -163,10 +164,12 @@ static void mxit_xfer_start( PurpleXfer*
 		 * 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 @@ void mxit_xfer_rx_file( struct MXitSessi
 		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 );


More information about the Commits mailing list