Changeset 5906


Ignore:
Timestamp:
May 22, 2008, 7:24:11 PM (14 years ago)
Author:
charles
Message:

(rpc) remove TR_RPC_TORRENT_CLOSING. formalize "torrent-list"'s response in the rpc spec.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/daemon.c

    r5857 r5906  
    2525#include <libtransmission/bencode.h>
    2626#include <libtransmission/rpc.h>
    27 #include <libtransmission/utils.h> /* tr_strdup */
     27#include <libtransmission/utils.h>
    2828#include <libtransmission/version.h>
    2929
     
    3131
    3232static int closing = FALSE;
    33 static tr_handle * gl_session;
    34 static char gl_configfile[MAX_PATH_LENGTH];
     33static tr_handle * mySession;
     34static char myConfigFilename[MAX_PATH_LENGTH];
    3535
    3636static void
     
    4949    tr_bencDictAddStr( &d, "rpc-acl", tr_sessionGetRPCACL( h ) );
    5050    tr_bencDictAddInt( &d, "rpc-port", tr_sessionGetRPCPort( h ) );
     51    tr_bencDictAddInt( &d, "speed-limit-down",
     52                           tr_sessionGetSpeedLimit( h, TR_DOWN ) );
     53    tr_bencDictAddInt( &d, "speed-limit-down-enabled",
     54                           tr_sessionIsSpeedLimitEnabled( h, TR_DOWN ) );
    5155    tr_bencDictAddInt( &d, "speed-limit-up",
    5256                           tr_sessionGetSpeedLimit( h, TR_UP ) );
    5357    tr_bencDictAddInt( &d, "speed-limit-up-enabled",
    5458                           tr_sessionIsSpeedLimitEnabled( h, TR_UP ) );
    55     tr_bencDictAddInt( &d, "speed-limit-down",
    56                            tr_sessionGetSpeedLimit( h, TR_DOWN ) );
    57     tr_bencDictAddInt( &d, "speed-limit-down-enabled",
    58                            tr_sessionIsSpeedLimitEnabled( h, TR_DOWN ) );
    5959    switch( tr_sessionGetEncryption( h ) ) {
    6060        case TR_PLAINTEXT_PREFERRED: str = "tolerated"; break;
     
    6464    tr_bencDictAddStr( &d, "encryption", str );
    6565
    66     tr_ninf( MY_NAME, "saving \"%s\"", gl_configfile );
    67     tr_bencSaveFile( gl_configfile, &d );
     66    tr_ninf( MY_NAME, "saving \"%s\"", myConfigFilename );
     67    tr_bencSaveFile( myConfigFilename, &d );
    6868
    6969    tr_bencFree( &d );
    70 
    7170}
    7271
     
    9190    tr_torrent ** torrents;
    9291
    93     assert( !gl_session );
    94 
    95     if(( have_state = !tr_bencLoadFile( gl_configfile, &state )))
     92    if(( have_state = !tr_bencLoadFile( myConfigFilename, &state )))
    9693    {
    9794        const char * str;
    98         tr_ninf( MY_NAME, "loading settings from \"%s\"", gl_configfile );
     95        tr_ninf( MY_NAME, "loading settings from \"%s\"", myConfigFilename );
    9996
    10097        if( tr_bencDictFindStr( &state, "download-dir", &str ) )
    10198            tr_strlcpy( downloadDir, str, sizeof( downloadDir ) );
     99        tr_bencDictFindInt( &state, "peer-limit", &peers );
     100        tr_bencDictFindInt( &state, "pex-allowed", &pex_enabled );
    102101        tr_bencDictFindInt( &state, "port", &peer_port );
    103102        tr_bencDictFindInt( &state, "port-forwarding-enabled", &fwd_enabled );
    104         tr_bencDictFindInt( &state, "peer-limit", &peers );
    105         tr_bencDictFindInt( &state, "pex-allowed", &pex_enabled );
    106103        tr_bencDictFindStr( &state, "rpc-acl", &rpc_acl_fallback );
    107104        tr_bencDictFindInt( &state, "rpc-port", &rpc_port_fallback );
     
    127124
    128125    /* start the session */
    129     gl_session = tr_sessionInitFull( configDir, "daemon", downloadDir,
    130                                      pex_enabled, fwd_enabled, peer_port,
    131                                      encryption,
    132                                      up_limit, up_limited,
    133                                      down_limit, down_limited,
    134                                      peers,
    135                                      TR_MSG_INF, 0,
    136                                      FALSE, /* is the blocklist enabled? */
    137                                      TR_DEFAULT_PEER_SOCKET_TOS,
    138                                      TRUE, rpc_port, rpc_acl );
     126    mySession = tr_sessionInitFull( configDir, "daemon", downloadDir,
     127                                    pex_enabled, fwd_enabled, peer_port,
     128                                    encryption,
     129                                    up_limit, up_limited,
     130                                    down_limit, down_limited,
     131                                    peers,
     132                                    TR_MSG_INF, 0,
     133                                    FALSE, /* is the blocklist enabled? */
     134                                    TR_DEFAULT_PEER_SOCKET_TOS,
     135                                    TRUE, rpc_port, rpc_acl );
    139136
    140137    /* load the torrents */
    141     ctor = tr_ctorNew( gl_session );
    142     torrents = tr_sessionLoadTorrents( gl_session, ctor, NULL );
     138    ctor = tr_ctorNew( mySession );
     139    torrents = tr_sessionLoadTorrents( mySession, ctor, NULL );
    143140    tr_free( torrents );
    144141    tr_ctorFree( ctor );
     
    270267    if( configDir == NULL )
    271268        configDir = tr_strdup_printf( "%s-daemon", tr_getDefaultConfigDir() );
    272     tr_buildPath( gl_configfile, sizeof( gl_configfile ),
     269    tr_buildPath( myConfigFilename, sizeof( myConfigFilename ),
    273270                  configDir, "daemon-config.benc", NULL );
    274271
     
    285282        sleep( 1 );
    286283
    287     saveState( gl_session );
     284    saveState( mySession );
    288285    printf( "Closing transmission session..." );
    289     tr_sessionClose( gl_session );
     286    tr_sessionClose( mySession );
    290287    printf( " done.\n" );
    291288
  • trunk/doc/rpc-spec.txt

    r5902 r5906  
    3939   (3) An optional "tag" integer as described in 2.1.
    4040
    41 2.3.  Request URL Query Notation
    42 
    43    As a convenience, a casual notation is supported for requests via the
    44    query portion of a URL.  The advantage of this is that all current requests
    45    can be invoked via a very simple http GET request.  The possible future
    46    disadvantage is that it limits nesting and listing structured requests.
    47 
    48    The URI notation works as follows:
     412.3.  Transport Mechanism
     42
     43   POSTing a JSON-encoded request is the preferred way of communicating
     44   with the Transmission server; however, a simple notation also exists
     45   for sending requests in the query portion of a URL.
     46
     47   The URL notation works as follows:
    4948   (1) Any key not "tag" or "method" is assumed to be in "arguments".
    5049   (2) The "arguments" key isn't needed, since data isn't nested.
     
    79783.2.  Torrent List
    8079
     80   An overview list of torrents.
     81
    8182   Method name: "torrent-list".
    8283
    8384   Request arguments: none.
    8485
    85    Response arguments: "list", an array of objects that contain two keys:
    86    a torrent's name string, and its unique torrent id.
     86   Response arguments: "list", an array of objects that contain seven keys:
     87
     88   key                 | value type
     89   --------------------+-------------------------------------------------
     90   "hashString"        | string
     91   "id"                | number
     92   "name"              | string
     93   "rateDownload"      | double
     94   "rateUpload"        | double
     95   "ratio"             | double
    8796
    88973.3.  Torrent Info Requests
  • trunk/gtk/main.c

    r5903 r5906  
    303303            /* this should be automatic */
    304304            break;
    305         case TR_RPC_TORRENT_CLOSING:
     305        case TR_RPC_TORRENT_REMOVING:
    306306            /* FIXME */
    307307            break;
     
    327327    data->type = type;
    328328    data->torrentId = tor ? tr_torrentId( tor ) : -1;
    329     data->tor = type == TR_RPC_TORRENT_CLOSING ? NULL : tor;
     329    data->tor = type == TR_RPC_TORRENT_REMOVING ? NULL : tor;
    330330    data->cbdata = cbdata;
    331331    g_idle_add( onRPCIdle, data );
  • trunk/libtransmission/rpc.c

    r5902 r5906  
    302302        tr_torrent * tor = torrents[i];
    303303        const tr_stat * st = tr_torrentStat( tor );
    304         tr_benc * d = tr_bencListAddDict( list, 6 );
     304        tr_benc * d = tr_bencListAddDict( list, 7 );
     305        tr_bencDictAddStr( d, "hashString", tor->info.hashString );
    305306        tr_bencDictAddInt( d, "id", tr_torrentId( tor ) );
    306307        tr_bencDictAddStr( d, "name", tor->info.name );
  • trunk/libtransmission/transmission.h

    r5902 r5906  
    156156    TR_RPC_TORRENT_STARTED,
    157157    TR_RPC_TORRENT_STOPPED,
    158     TR_RPC_TORRENT_CLOSING,
    159158    TR_RPC_TORRENT_REMOVING,
    160159    TR_RPC_TORRENT_CHANGED,
  • trunk/macosx/Controller.m

    r5898 r5906  
    41724172        case TR_RPC_TORRENT_STOPPED:
    41734173            break;
    4174         case TR_RPC_TORRENT_CLOSING:
     4174        case TR_RPC_TORRENT_REMOVING:
    41754175            break;
    41764176        case TR_RPC_TORRENT_CHANGED:
Note: See TracChangeset for help on using the changeset viewer.