Changeset 4ac647d
- Timestamp:
- 2008-08-04T14:21:49Z (16 years ago)
- Branches:
- master
- Children:
- 8661caa
- Parents:
- 8a90001
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
dcc.c
r8a90001 r4ac647d 114 114 } 115 115 116 /* As defined in ft.h */ 117 void imcb_file_finished( file_transfer_t *file ) 118 { 119 dcc_file_transfer_t *df = file->priv; 120 121 if( file->bytes_transferred >= file->file_size ) 122 dcc_finish( file ); 123 else 124 df->proto_finished = TRUE; 125 } 126 116 127 dcc_file_transfer_t *dcc_alloc_transfer( char *file_name, size_t file_size, struct im_connection *ic ) 117 128 { … … 154 165 155 166 df->progress_timeout = b_timeout_add( DCC_MAX_STALL * 1000, dcc_progress, df ); 167 168 imcb_log( ic, "File transfer request from %s for %s (%zd kb). ", user_nick, file_name, file_size/1024 ); 169 170 imcb_log( ic, "Accept the file transfer if you'd like the file. If you don't, issue the 'transfers reject' command."); 156 171 157 172 return file; … … 411 426 412 427 if( file->bytes_transferred >= file->file_size ) { 413 dcc_finish( file ); 428 if( df->proto_finished ) 429 dcc_finish( file ); 414 430 return FALSE; 415 431 } … … 493 509 return dcc_abort( df, "Remote end closed connection" ); 494 510 511 if( !ft->write( df->ft, ft->buffer, ret ) ) 512 return FALSE; 513 495 514 df->bytes_sent += ret; 496 515 … … 509 528 } 510 529 511 if( !ft->write( df->ft, ft->buffer, ret ))512 return FALSE;530 if( df->bytes_sent == ret ) 531 ft->started = time( NULL ); 513 532 514 533 if( done ) 515 534 { 516 closesocket( fd ); 517 dcc_finish( ft ); 535 if( df->watch_out ) 536 b_event_remove( df->watch_out ); 537 538 if( df->proto_finished ) 539 dcc_finish( ft ); 518 540 519 541 df->watch_in = 0; … … 572 594 return dcc_abort( df, "send() sent %d instead of %d", ret, data_len ); 573 595 596 if( df->bytes_sent == 0 ) 597 file->started = time( NULL ); 598 574 599 df->bytes_sent += ret; 575 600 … … 610 635 void dcc_finish( file_transfer_t *file ) 611 636 { 637 dcc_file_transfer_t *df = file->priv; 638 time_t diff = time( NULL ) - file->started ? : 1; 639 612 640 file->status |= FT_STATUS_FINISHED; 613 641 … … 615 643 file->finished( file ); 616 644 645 imcb_log( df->ic, "File %s transferred successfully at %d kb/s!" , file->file_name, (int) ( file->bytes_transferred / 1024 / diff ) ); 617 646 dcc_close( file ); 618 647 } -
dcc.h
r8a90001 r4ac647d 83 83 struct sockaddr_storage saddr; 84 84 85 /* set to true if the protocol has finished 86 * (i.e. called imcb_file_finished) 87 */ 88 int proto_finished; 85 89 } dcc_file_transfer_t; 86 90 -
protocols/ft.h
r8a90001 r4ac647d 171 171 172 172 gboolean imcb_file_recv_start( file_transfer_t *ft ); 173 174 void imcb_file_finished( file_transfer_t *file ); 173 175 #endif -
protocols/jabber/jabber.c
r8a90001 r4ac647d 245 245 struct jabber_data *jd = ic->proto_data; 246 246 247 while( jd->filetransfers ) 248 imcb_file_canceled( ( ( struct jabber_transfer *) jd->filetransfers->data )->ft, "Logging out" ); 249 250 while( jd->streamhosts ) 251 { 252 jabber_streamhost_t *sh = jd->streamhosts->data; 253 jd->streamhosts = g_slist_remove( jd->streamhosts, sh ); 254 g_free( sh->jid ); 255 g_free( sh->host ); 256 g_free( sh ); 257 } 258 247 259 if( jd->fd >= 0 ) 248 260 jabber_end_stream( ic ); -
protocols/jabber/s5bytestream.c
r8a90001 r4ac647d 643 643 return jabber_bs_abort( bt, "Remote end closed connection" ); 644 644 645 if( tf->bytesread == 0 )646 tf->ft->started = time( NULL );647 648 645 tf->bytesread += ret; 646 647 if( tf->bytesread >= tf->ft->file_size ) 648 imcb_file_finished( tf->ft ); 649 649 650 650 tf->ft->write( tf->ft, tf->ft->buffer, ret ); … … 701 701 ASSERTSOCKOP( ret = send( tf->fd, buffer, len, 0 ), "Sending" ); 702 702 703 if( tf->byteswritten == 0 )704 tf->ft->started = time( NULL );705 706 703 tf->byteswritten += ret; 707 704 … … 710 707 return jabber_bs_abort( bt, "send() sent %d instead of %d (send buffer too big!)", ret, len ); 711 708 712 bt->tf->watch_out = b_input_add( tf->fd, GAIM_INPUT_WRITE, jabber_bs_send_can_write, bt ); 709 if( tf->byteswritten >= ft->file_size ) 710 imcb_file_finished( ft ); 711 else 712 bt->tf->watch_out = b_input_add( tf->fd, GAIM_INPUT_WRITE, jabber_bs_send_can_write, bt ); 713 713 714 714 return TRUE; -
protocols/jabber/si.c
r8a90001 r4ac647d 54 54 } 55 55 56 /* file_transfer finished() callback */57 void jabber_si_finished( file_transfer_t *ft )58 {59 struct jabber_transfer *tf = ft->data;60 time_t diff = time( NULL ) - ft->started ? : 1;61 62 imcb_log( tf->ic, "File %s transferred successfully at %d kb/s!" , ft->file_name, (int) ( ft->bytes_transferred / 1024 / diff ) );63 }64 65 56 /* file_transfer canceled() callback */ 66 57 void jabber_si_canceled( file_transfer_t *ft, char *reason ) … … 177 168 tf->ft->data = tf; 178 169 tf->ft->free = jabber_si_free_transfer; 179 tf->ft->finished = jabber_si_finished;180 170 tf->bud = bud; 181 171 ft->write = jabber_bs_send_write; … … 302 292 /* Request is fine. */ 303 293 304 imcb_log( ic, "File transfer request from %s for %s (%zd kb). ", xt_find_attr( node, "from" ), name, size/1024 );305 306 imcb_log( ic, "Accept the file transfer if you'd like the file. If you don't, issue the 'transfers reject' command.");307 308 294 tf = g_new0( struct jabber_transfer, 1 ); 309 295 … … 318 304 tf->ft->accept = jabber_si_answer_request; 319 305 tf->ft->free = jabber_si_free_transfer; 320 tf->ft->finished = jabber_si_finished;321 306 tf->ft->canceled = jabber_si_canceled; 322 307
Note: See TracChangeset
for help on using the changeset viewer.