Changeset 5813


Ignore:
Timestamp:
May 12, 2008, 12:41:55 AM (14 years ago)
Author:
charles
Message:

partial implementation of json-ipc backend: torrent start/stop/close/verify/stat/info, as are getting & setting per-torrent peer limits, upload speeds, and download speeds. this is a work in progress.

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/ipc-json-spec.txt

    r5807 r5813  
    13132.  Message Format
    1414
    15    The entire protocol is formatted in a subset of JSON that understands
     15   Messages are formatted in a subset of JSON that understands
    1616   arrays, maps, strings, and whole numbers with no exponentials --
    1717   in short, the subset of JSON easily represented in benc.
     
    2121   There are only two message types: request and response.  Both
    2222   are JSON objects with two members:  "headers" (described in 2.1)
    23    and "body" (described in 2.2-2.3).
     23   and "body" (described in 2.2 - 2.3).
    2424
    25252.1.  Headers
     
    46463.  Torrent Requests
    4747
    48 3.1.  Common Arguments
    49 
    50    Most torrent requests support an "ids" argument, which is a list
    51    containing unique torrent ids, or torrent sha1 hash strings, or both.
    52    These are the torrents that the request will be applied to.
    53    If "ids" is omitted, the request is applied to all torrents.
    54 
    55 3.2.  Torrent Action Requests
     483.1.  Torrent Action Requests
    5649
    5750   Request names: "torrent-start", "torrent-stop",
    5851                  "torrent-remove", "torrent-verify"
    59    Request arguments: 3.1's optional "ids" argument.
     52   Request arguments: "ids", a list of unique torrent ids, sha1 hash strings,
     53                      or both.  These are the torrents that the request will
     54                      be applied to.  If "ids" is ommitted, the request is
     55                      applied to all torrents.
    6056   Response arguments: none.
    6157
    62 3.3.  Torrent Info Requests
     583.2.  Torrent Info Requests
    6359
    6460   Request name: "torrent-info".
     
    119115      }
    120116
    121 3.4.  Torrent Status Requests
     1173.3.  Torrent Status Requests
    122118
    123119   Request name is "torrent-status".
     
    131127   (3) a new string, "scrape-url", is added
    132128
    133 3.5.  Adding a Torrent
     1293.4.  Adding a Torrent
    134130
    135131   Request name: "torrent-add"
     
    147143   The "filename" argument is required; all others are optional.
    148144
    149    Response arguments: 3.1's "error" if the request failed.
    150 
    151 3.6.  Other torrent settings
     145   Response arguments: none.
     146
     1473.5.  Other torrent settings
    152148
    153149   Common arguments:
     
    155151   string             | value type & description
    156152   -------------------+-------------------------------------------------
    157    "id"               | int or string  torrent id or hash string
    158153   "max-peers"        | int            maximum number of peers
    159154   "speed-limit-down" | int            maximum download speed (in KiB/s)
    160155   "speed-limit-up"   | int            maximum upload speed (in KiB/s)
    161156
    162 3.6.1.  Mutators
     1573.5.1.  Mutators
    163158
    164159   Request name: "torrent-set"
    165    Request arguments: "id" from 3.6, plus one or more of 3.6's other arguments
     160   Request arguments: 3.1's "ids", plus one or more of 3.5's arguments
    166161   Response arguments: none
    167162
    168 3.6.2.  Accessors
     1633.5.2.  Accessors
    169164
    170165   Request name: "torrent-get"
    171166   Request arguments: none
    172    Response arguments: all of 3.6's arguments
    173 
    174 3.7  File Priorities
     167   Response arguments: "torrents", a list of torrent objects containing
     168                       all of 3.5's arguments plus the id passed in
     169                       by "torrent-set".
     170                     
     171
     1723.6  File Priorities
    175173
    176174   Common arguments:
     
    178176   string             | value type & description
    179177   -------------------+-------------------------------------------------
    180    "id"               | int or string  torrent id or hash string
    181178   "priority-high"    | array          indices of one or more high-priority files
    182179   "priority-low"     | array          indices of one or more low-priority files
     
    185182   "no-download"      | array          indices of one or more file to not download
    186183
    187 3.7.1.  Mutators
     1843.6.1.  Mutators
    188185
    189186    Request name: "torrent-set-file"
    190     Request arguments: "id" from 3.7, plus one or more of 3.7's other arguments
     187    Request arguments: 3.1's "ids", plus one or more of 3.6's arguments
    191188    Response arguments: none
    192189
    193 3.7.2.  Accessors
     1903.6.2.  Accessors
    194191
    195192    Request name: "torrent-get-file"
    196193    Request arguments: none
    197     Response arguments: all of 3.7's arguments
     194   Response arguments: list of objects, one per torrent, containing
     195                       all of 3.6's arguments plus the id passed in
     196                       by "torrent-set".
    198197   
    1991984.   Session Status Requests
  • trunk/libtransmission/Makefile.am

    r5812 r5813  
    1717    handshake.c \
    1818    inout.c \
     19    ipc.c \
    1920    ipcparse.c \
    2021    json.c \
     
    5758    handshake.h \
    5859    inout.h \
     60    ipc.h \
    5961    ipcparse.h \
    6062    list.h \
  • trunk/libtransmission/torrent.c

    r5796 r5813  
    5454***/
    5555
     56tr_torrent*
     57tr_torrentFindFromId( tr_handle * handle, int id )
     58{
     59    tr_torrent * tor = NULL;
     60
     61    while(( tor = tr_torrentNext( handle, tor )))
     62        if( tor->uniqueId == id )
     63            return tor;
     64
     65    return NULL;
     66}
     67
     68tr_torrent*
     69tr_torrentFindFromHashString( tr_handle * handle, const char * str )
     70{
     71    tr_torrent * tor = NULL;
     72
     73    while(( tor = tr_torrentNext( handle, tor )))
     74        if( !strcmp( str, tor->info.hashString ) )
     75            return tor;
     76
     77    return NULL;
     78}
     79
    5680int
    5781tr_torrentExists( const tr_handle * handle,
     
    369393    uint64_t t;
    370394    tr_info * info = &tor->info;
     395    static int nextUniqueId = 1;
    371396   
    372397    tr_globalLock( h );
    373398
    374399    tor->handle   = h;
     400    tor->uniqueId = nextUniqueId++;
    375401
    376402    randomizeTiers( info );
  • trunk/libtransmission/torrent.h

    r5796 r5813  
    5050
    5151int tr_torrentExists( const tr_handle *, const uint8_t * );
     52tr_torrent* tr_torrentFindFromId( tr_handle *, int id );
    5253tr_torrent* tr_torrentFindFromHash( tr_handle *, const uint8_t * );
     54tr_torrent* tr_torrentFindFromHashString( tr_handle *, const char * );
    5355tr_torrent* tr_torrentFindFromObfuscatedHash( tr_handle *, const uint8_t* );
    5456
     
    179181
    180182    tr_torrent               * next;
     183
     184    int                        uniqueId;
    181185};
    182186
Note: See TracChangeset for help on using the changeset viewer.