Changeset 8079


Ignore:
Timestamp:
Mar 23, 2009, 12:16:37 AM (13 years ago)
Author:
charles
Message:

(trunk rpc) added "recently-active" as a valid "ids" argument in torrent-get, etc.

Location:
trunk
Files:
2 edited

Legend:

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

    r8021 r8079  
    8080   "torrent-verify"    | tr_torrentVerify
    8181
    82    Request arguments: "ids", a list of torrent id numbers, sha1 hash strings,
    83                       or both.  These are the torrents that the request will
    84                       be applied to.  If "ids" is ommitted, the request is
    85                       applied to all torrents.
     82   Request arguments: "ids", which specifies which torrents to use.
     83                      All torrents are used if the "ids" argument is omitted.
     84                      "ids" should be one of the following:
     85                      (1) an integer referring to a torrent id
     86                      (2) a list of torrent id numbers, sha1 hash strings, or both
     87                      (3) a string, "recently-active", for recently-active torrents
    8688
    8789   Response arguments: none
     
    433435         |         | yes       | torrent-get    | new arg "speed-limit-up-enabled"
    434436         |         | yes       | torrent-get    | new arg "speed-limit-up-global-enabled"
     437         |         | yes       | torrent-get    | new ids option "recently-active"
    435438         |         |        NO | torrent-get    | removed arg "downloadLimit"
    436439         |         |        NO | torrent-get    | removed arg "downloadLimitMode"
  • trunk/libtransmission/rpcimpl.c

    r8021 r8079  
    112112    tr_torrent ** torrents = NULL;
    113113    tr_benc *     ids;
     114    const char * str;
    114115
    115116    if( tr_bencDictFindList( args, "ids", &ids ) )
     
    140141        if( ( tor = tr_torrentFindFromId( session, id ) ) )
    141142            torrents[torrentCount++] = tor;
     143    }
     144    else if( tr_bencDictFindStr( args, "ids", &str ) )
     145    {
     146        if( !strcmp( str, "recently-active" ) )
     147        {
     148            tr_torrent * tor = NULL;
     149            const time_t now = time( NULL );
     150            const time_t window = 120;
     151            const int n = tr_sessionCountTorrents( session );
     152            torrents = tr_new0( tr_torrent *, n );
     153            while( ( tor = tr_torrentNext( session, tor ) ) ) {
     154                time_t a = tor->activityDate;
     155                a = MAX( a, tor->addedDate );
     156                a = MAX( a, tor->doneDate );
     157                a = MAX( a, tor->startDate );
     158                if( a >= now - window )
     159                    torrents[torrentCount++] = tor;
     160            }
     161        }
    142162    }
    143163    else /* all of them */
Note: See TracChangeset for help on using the changeset viewer.