Changeset 8105


Ignore:
Timestamp:
Mar 29, 2009, 6:45:35 PM (14 years ago)
Author:
charles
Message:

(trunk rpc) add "seed ratio" feature to RPC

Location:
trunk
Files:
4 edited

Legend:

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

    r8097 r8105  
    108108   "priority-low"                    | array      indices of low-priority file(s)
    109109   "priority-normal"                 | array      indices of normal-priority file(s)
     110   "seedRatioLimit"                  | 'double'   session seeding ratio
     111   "seedRatioLimited"                | 'boolean'  true if "seedRatioLimit" is honored
    110112   "uploadLimit"                     | number     maximum upload speed (in K/s)
    111113   "uploadLimited"                   | 'boolean'  true if "uploadLimit" is honored
     
    185187   scrapeURL                       | string                      | tr_stat
    186188   seeders                         | number                      | tr_stat
     189   seedRatioLimit                  | 'double'                    | tr_torrent
     190   seedRatioMode                   | number                      | tr_ratiolimit
    187191   sizeWhenDone                    | number                      | tr_stat
    188192   startDate                       | number                      | tr_stat
     
    439443         |         | yes       | torrent-set    | new arg "downloadLimited"
    440444         |         | yes       | torrent-set    | new arg "uploadLimited"
    441          |         | yes       | torrent-set    | new arg "honorsSessionLImits"
     445         |         | yes       | torrent-set    | new arg "honorsSessionLimits"
     446         |         | yes       | session-get    | new arg "seedRatioLimit"
     447         |         | yes       | session-get    | new arg "seedRatioLimited"
    442448         |         | yes       | session-get    | new arg "alt-speed-enabled"
    443449         |         | yes       | session-get    | new arg "alt-speed-time-enabled"
     
    449455         |         | yes       | session-get    | new arg "blocklist-size"
    450456         |         | yes       | session-get    | new arg "peer-limit-per-torrent"
     457         |         | yes       | torrent-get    | new arg "seedRatioLimit"
     458         |         | yes       | torrent-get    | new arg "seedRatioMode"
    451459         |         | yes       | torrent-get    | new ids option "recently-active"
    452460         |         | yes       |                | new method "torrent-reannounce"
  • trunk/libtransmission/bencode.c

    r8071 r8105  
    447447
    448448tr_bool
     449tr_bencDictFindBool( tr_benc * dict, const char * key, tr_bool * setme )
     450{
     451    int64_t i = 0;
     452    const tr_bool found = tr_bencDictFindInt( dict, key, &i );
     453    *setme = i!=0;
     454    return found;
     455}
     456
     457tr_bool
    449458tr_bencDictFindDouble( tr_benc * dict, const char * key, double * setme )
    450459{
     
    698707
    699708    return child;
     709}
     710
     711tr_benc*
     712tr_bencDictAddBool( tr_benc * dict, const char * key, tr_bool val )
     713{
     714    assert( tr_isBool( val ) );
     715
     716    return tr_bencDictAddInt( dict, key, val );
    700717}
    701718
  • trunk/libtransmission/bencode.h

    r8071 r8105  
    131131tr_benc * tr_bencDictAddInt( tr_benc *, const char * key, int64_t );
    132132
     133tr_benc * tr_bencDictAddBool( tr_benc *, const char * key, tr_bool );
     134
    133135tr_benc * tr_bencDictAddStr( tr_benc *, const char * key, const char * );
    134136
     
    149151
    150152tr_bool   tr_bencDictFindDouble( tr_benc *, const char * key, double * setme );
     153
     154tr_bool   tr_bencDictFindBool( tr_benc *, const char * key, tr_bool * setme );
    151155
    152156tr_bool   tr_bencDictFindStr( tr_benc *, const char * key, const char ** setme );
  • trunk/libtransmission/rpcimpl.c

    r8097 r8105  
    501501    else if( !strcmp( key, "seeders" ) )
    502502        tr_bencDictAddInt( d, key, st->seeders );
     503    else if( !strcmp( key, "seedRatioLimit" ) )
     504        tr_bencDictAddDouble( d, key, tr_torrentGetRatioLimit( tor ) );
     505    else if( !strcmp( key, "seedRatioMode" ) )
     506        tr_bencDictAddInt( d, key, tr_torrentGetRatioMode( tor ) );
    503507    else if( !strcmp( key, "sizeWhenDone" ) )
    504508        tr_bencDictAddInt( d, key, st->sizeWhenDone );
     
    700704        if( tr_bencDictFindInt( args_in, "ratio-limit-mode", &tmp ) )
    701705            tr_torrentSetRatioMode( tor, tmp );
     706        if( tr_bencDictFindDouble( args_in, "seedRatioLimit", &d ) )
     707            tr_torrentSetRatioLimit( tor, d );
     708        if( tr_bencDictFindInt( args_in, "seedRatioMode", &tmp ) )
     709            tr_torrentSetRatioMode( tor, tmp );
    702710        notify( session, TR_RPC_TORRENT_CHANGED, tor );
    703711    }
     
    855863            struct tr_rpc_idle_data  * idle_data )
    856864{
     865    tr_bool      b;
    857866    int64_t      i;
    858867    double       d;
     
    887896    if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_PORT_FORWARDING, &i ) )
    888897        tr_sessionSetPortForwardingEnabled( session, i );
     898    if( tr_bencDictFindDouble( args_in, "seedRatioLimit", &d ) )
     899        tr_sessionSetRatioLimit( session, d );
     900    if( tr_bencDictFindBool( args_in, "seedRatioLimited", &b ) )
     901        tr_sessionSetRatioLimited( session, b );
    889902    if( tr_bencDictFindInt( args_in, "speed-limit-down", &i ) )
    890903        tr_sessionSetSpeedLimit( session, TR_DOWN, i );
     
    9871000    tr_bencDictAddInt( d, "rpc-version", 4 );
    9881001    tr_bencDictAddInt( d, "rpc-version-minimum", 1 );
     1002    tr_bencDictAddDouble( d, "seedRatioLimit", tr_sessionGetRatioLimit( s ) );
     1003    tr_bencDictAddBool( d, "seedRatioLimited", tr_sessionIsRatioLimited( s ) );
    9891004    tr_bencDictAddInt( d, "speed-limit-up", tr_sessionGetSpeedLimit( s, TR_UP ) );
    9901005    tr_bencDictAddInt( d, "speed-limit-up-enabled", tr_sessionIsSpeedLimited( s, TR_UP ) );
Note: See TracChangeset for help on using the changeset viewer.