Changeset 140


Ignore:
Timestamp:
Mar 9, 2006, 2:32:16 AM (17 years ago)
Author:
titer
Message:

Adds tr_torrentAvailability for the advanced progress bar (also, now
supports any width for it)

Location:
branches/new_api/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/new_api/libtransmission/transmission.c

    r139 r140  
    348348    tr_stat_t * s;
    349349    tr_info_t * inf = &tor->info;
    350     int i, j, piece;
     350    int i;
    351351
    352352    tor->statCur = ( tor->statCur + 1 ) % 2;
     
    415415    }
    416416
    417     for( i = 0; i < 120; i++ )
    418     {
    419         piece = i * inf->pieceCount / 120;
     417    s->downloaded = tor->downloaded;
     418    s->uploaded   = tor->uploaded;
     419
     420    tr_lockUnlock( &tor->lock );
     421
     422    return s;
     423}
     424
     425void tr_torrentAvailability( tr_torrent_t * tor, uint8_t * tab, int size )
     426{
     427    int i, j, piece;
     428
     429    tr_lockLock( &tor->lock );
     430    for( i = 0; i < size; i++ )
     431    {
     432        piece = i * tor->info.pieceCount / size;
    420433
    421434        if( tr_cpPieceIsComplete( tor->completion, piece ) )
    422435        {
    423             s->pieces[i] = -1;
     436            tab[i] = -1;
    424437            continue;
    425438        }
    426439
    427         s->pieces[i] = 0;
    428        
     440        tab[i] = 0;
    429441        for( j = 0; j < tor->peerCount; j++ )
    430442        {
     
    432444                tr_bitfieldHas( tr_peerBitfield( tor->peers[j] ), piece ) )
    433445            {
    434                 (s->pieces[i])++;
     446                (tab[i])++;
    435447            }
    436448        }
    437449    }
    438 
    439     s->downloaded = tor->downloaded;
    440     s->uploaded   = tor->uploaded;
    441 
    442450    tr_lockUnlock( &tor->lock );
    443 
    444     return s;
    445451}
    446452
  • branches/new_api/libtransmission/transmission.h

    r139 r140  
    170170
    171171/***********************************************************************
     172 * tr_torrentAvailability
     173 ***********************************************************************
     174 * Use this to draw an advanced progress bar which is 'size' pixels
     175 * wide. Fills 'tab' which you must have allocated: each byte is set
     176 * to either -1 if we have the piece, otherwise it is set to the number
     177 * of connected peers who have the piece.
     178 **********************************************************************/
     179void tr_torrentAvailability( tr_torrent_t *, uint8_t * tab, int size );
     180
     181/***********************************************************************
    172182 * tr_torrentClose
    173183 ***********************************************************************
     
    240250    int         peersUploading;
    241251    int         peersDownloading;
    242     char        pieces[120];
    243252    int         seeders;
    244253    int         leechers;
Note: See TracChangeset for help on using the changeset viewer.