Changeset 8121


Ignore:
Timestamp:
Mar 31, 2009, 10:13:43 PM (14 years ago)
Author:
charles
Message:

(trunk rpc) added "fileStats" to rpc s.t. there's a simple interface for getting all the torrent's stat fields

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/rpc-spec.txt

    r8111 r8121  
    154154   eta                             | number                      | tr_stat
    155155   files                           | array (see below)           | n/a
     156   fileStats                       | array (see below)           | n/a
    156157   hashString                      | string                      | tr_info
    157158   haveUnchecked                   | number                      | tr_stat
     
    214215                          | name                    | string     | tr_info
    215216   -----------------------+--------------------------------------+
     217   fileStats              | a file's non-constant properties.    |
     218                          | array of tr_info.filecount objects,  |
     219                          | each containing:                     |
     220                          +-------------------------+------------+
     221                          | bytesCompleted          | number     | tr_torrent
     222                          | wanted                  | 'boolean'  | tr_info
     223                          | priority                | number     | tr_info
     224   -----------------------+--------------------------------------+
    216225   peers                  | array of objects, each containing:   |
    217226                          +-------------------------+------------+
     
    441450   ------+---------+-----------+----------------+-------------------------------
    442451   6     | 1.60    | yes       | torrent-get    | new arg "pieces"
     452         |         | yes       | torrent-get    | new arg "fileStats"
    443453         |         | yes       | torrent-set    | new arg "ratio"
    444454         |         | yes       | torrent-set    | new arg "downloadLimited"
  • trunk/libtransmission/rpcimpl.c

    r8111 r8121  
    288288****
    289289***/
     290
     291static void
     292addFileStats( const tr_torrent * tor, tr_benc * list )
     293{
     294    tr_file_index_t i;
     295    tr_file_index_t n;
     296    const tr_info * info = tr_torrentInfo( tor );
     297    tr_file_stat * files = tr_torrentFiles( tor, &n );
     298
     299    for( i = 0; i < info->fileCount; ++i )
     300    {
     301        const tr_file * file = &info->files[i];
     302        tr_benc * d = tr_bencListAddDict( list, 3 );
     303        tr_bencDictAddInt( d, "bytesCompleted", files[i].bytesCompleted );
     304        tr_bencDictAddInt( d, "priority", file->priority );
     305        tr_bencDictAddBool( d, "wanted", !file->dnd );
     306    }
     307
     308    tr_torrentFilesFree( files, n );
     309}
    290310
    291311static void
     
    416436    else if( !strcmp( key, "files" ) )
    417437        addFiles( tor, tr_bencDictAddList( d, key, inf->fileCount ) );
     438    else if( !strcmp( key, "fileStats" ) )
     439        addFileStats( tor, tr_bencDictAddList( d, key, inf->fileCount ) );
    418440    else if( !strcmp( key, "hashString" ) )
    419441        tr_bencDictAddStr( d, key, tor->info.hashString );
Note: See TracChangeset for help on using the changeset viewer.