Changeset 4ac647d for dcc.c


Ignore:
Timestamp:
2008-08-04T14:21:49Z (14 years ago)
Author:
ulim <a.sporto+bee@…>
Branches:
master
Children:
8661caa
Parents:
8a90001
Message:

moved some stuff around in preperation for MSN merge.

  • both ends (proto&dcc) need to finish a transfer now for it to be finished
  • moved throughput calc. and some messages to dcc (no need to implement in protocols)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • dcc.c

    r8a90001 r4ac647d  
    114114}
    115115
     116/* As defined in ft.h */
     117void 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
    116127dcc_file_transfer_t *dcc_alloc_transfer( char *file_name, size_t file_size, struct im_connection *ic )
    117128{
     
    154165
    155166        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.");
    156171
    157172        return file;
     
    411426       
    412427                if( file->bytes_transferred >= file->file_size ) {
    413                         dcc_finish( file );
     428                        if( df->proto_finished )
     429                                dcc_finish( file );
    414430                        return FALSE;
    415431                }
     
    493509                        return dcc_abort( df, "Remote end closed connection" );
    494510
     511                if( !ft->write( df->ft, ft->buffer, ret ) )
     512                        return FALSE;
     513
    495514                df->bytes_sent += ret;
    496515
     
    509528                }
    510529               
    511                 if( !ft->write( df->ft, ft->buffer, ret ) )
    512                         return FALSE;
     530                if( df->bytes_sent == ret )
     531                        ft->started = time( NULL );
    513532
    514533                if( done )
    515534                {
    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 );
    518540
    519541                        df->watch_in = 0;
     
    572594                return dcc_abort( df, "send() sent %d instead of %d", ret, data_len );
    573595
     596        if( df->bytes_sent == 0 )
     597                file->started = time( NULL );
     598
    574599        df->bytes_sent += ret;
    575600
     
    610635void dcc_finish( file_transfer_t *file )
    611636{
     637        dcc_file_transfer_t *df = file->priv;
     638        time_t diff = time( NULL ) - file->started ? : 1;
     639
    612640        file->status |= FT_STATUS_FINISHED;
    613641       
     
    615643                file->finished( file );
    616644
     645        imcb_log( df->ic, "File %s transferred successfully at %d kb/s!" , file->file_name, (int) ( file->bytes_transferred / 1024 / diff ) );
    617646        dcc_close( file );
    618647}
Note: See TracChangeset for help on using the changeset viewer.