Changeset 6316


Ignore:
Timestamp:
Jul 10, 2008, 8:59:15 PM (13 years ago)
Author:
charles
Message:

(daemon) let file download flags and priorities be set by transmission-remote. Add examples to the man page and --help.
(libT) minor tweaks to tr-getopt
(gtk) tweak the preference dialog's "port forwarding" text for clarity as suggested in the forums

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/remote.c

    r6315 r6316  
    1111 */
    1212
     13#include <errno.h>
    1314#include <stdio.h>
    1415#include <stdlib.h>
     
    3738getUsage( void )
    3839{
    39     return "Transmission "LONG_VERSION_STRING"  http://www.transmissionbt.com/\n"
    40            "A fast and easy BitTorrent client\n"
    41            "\n"
    42            "Usage: "MY_NAME" [host] [options]\n"
    43            "       "MY_NAME" [port] [options]\n"
    44            "       "MY_NAME" [host:port] [options]";
     40    return
     41"Transmission "LONG_VERSION_STRING"  http://www.transmissionbt.com/\n"
     42"A fast and easy BitTorrent client\n"
     43"\n"
     44"Usage: "MY_NAME" [host] [options]\n"
     45"       "MY_NAME" [port] [options]\n"
     46"       "MY_NAME" [host:port] [options]\n"
     47"\n"
     48"Notes:\n"
     49"  <files> can be 'all', a single index, or a comma-separated list.\n"
     50"  <torrents> can be 'all', a torrent id or hash string, or a comma-separated list of ids and hash strings.\n"
     51"\n"
     52"Examples:\n"
     53"  \""MY_NAME" -l\" (list all torrents)\n"
     54"  \""MY_NAME" -tall --start\" (start all torrents)\n"
     55"  \""MY_NAME" --add ~/Desktop/*torrent\" (add all the torrent files in $HOME/Desktop)\n"
     56"  \""MY_NAME" -t1 -i\" (get detailed information on the torrent whose id is '1')\n"
     57"  \""MY_NAME" -t1 -Gall -g2,4,6\" (same torrent; only download the second, fourth, and sixth files)\n"
     58"  \""MY_NAME" -tall -ph1,2\" (set all torrent's first two files' priorities to high)\n"
     59"  \""MY_NAME" -tall -pnall\" (set all torrent's files' priorities to normal)";
    4560}
    4661
     
    4863{
    4964    { 'a', "add",          "Add torrent files", "a", 0, NULL },
     65    { 'b', "debug",        "Print debugging information", "b", 0, NULL },
    5066    { 'd', "downlimit",    "Set the maximum download speed in KB/s", "d", 1, "<number>" },
    5167    { 'D', "no-downlimit", "Don't limit the download speed", "D", 0, NULL },
    5268    { 'e', "encryption",   "Set encryption mode [required, preferred, tolerated]", "e", 1, "<mode>" },
    5369    { 'f', "files",        "Get a file list for the current torrent(s)", "f", 0, NULL },
    54     { 'g', "debug",        "Print debugging information", "g", 0, NULL },
     70    { 'g', "get",          "Mark files for download", "g", 1, "<files>" },
     71    { 'G', "no-get",       "Mark files for not downloading", "G", 1, "<files>" },
    5572    { 'h', "help",         "Show this help page and exit", "h", 0, NULL },
    5673    { 'i', "info",         "Show details of the current torrent(s)", "i", 0, NULL },
     
    6077    { 'n', "auth",         "Set username for authentication", "n", 1, "<user>:<pass>" },
    6178    { 'p', "port",         "Port to listen for incoming peers", "p", 1, "<port>" },
     79    { 900, "priority-high", "Set one or more files' priority as high", "ph", 1, "<files>" },
     80    { 901, "priority-normal", "Set one or more files' priority as normal", "pn", 1, "<files>" },
     81    { 902, "priority-normal", "Set one or more files' priority as low", "pl", 1, "<files>" },
    6282    { 'r', "remove",       "Remove the current torrent(s)", "r", 0, NULL },
    6383    { 's', "start",        "Start the current torrent(s)", "s", 0, NULL },
    6484    { 'S', "stop",         "Stop the current torrent(s)", "S", 0, NULL },
    65     { 't', "torrent",      "Set the current torrent(s)", "t", 1, "<id|hash|all>" },
     85    { 't', "torrent",      "Set the current torrent(s)", "t", 1, "<torrents>" },
    6686    { 'u', "uplimit",      "Set the maximum upload speed in KB/s", "u", 1, "<number>" },
    6787    { 'U', "no-uplimit",   "Don't limit the upload speed", "U", 0, NULL },
     
    126146        fprintf( stderr, "No torrent specified!  Please use the -t option first.\n" );
    127147        id = "-1"; /* no torrent will have this ID, so should be a no-op */
    128     } else if( strcmp( id, "all" ) ) {
     148    }
     149    if( strcmp( id, "all" ) ) {
    129150        tr_rpc_parse_list_str( tr_bencDictAdd( args, "ids" ), id, strlen(id) );
     151    }
     152}
     153
     154static void
     155addFiles( tr_benc * args, const char * key, const char * arg )
     156{
     157    tr_benc * files = tr_bencDictAddList( args, key, 100 );
     158
     159    if( !*arg )
     160    {
     161        fprintf( stderr, "No files specified!\n" );
     162        arg = "-1"; /* no file will have this index, so should be a no-op */
     163    }
     164    if( strcmp( arg, "all" ) )
     165    {
     166        const char * walk = arg;
     167        while( *walk ) {
     168            char * p;
     169            unsigned long l;
     170            errno = 0;
     171            l = strtol( walk, &p, 10 );
     172            if( errno )
     173                break;
     174            tr_bencListAddInt( files, l - 1 );
     175            if( *p != ',' )
     176                break;
     177            walk = p + 1;
     178        }
    130179    }
    131180}
     
    166215                      addArg = FALSE;
    167216                      break;
     217            case 'b': debug = 1;
     218                      addArg = FALSE;
     219                      break;
    168220            case 'd': tr_bencDictAddStr( &top, "method", "session-set" );
    169221                      tr_bencDictAddInt( args, "speed-limit-down", numarg( optarg ) );
     
    184236                      tr_bencDictAddInt( args, "fields", fields );
    185237                      break;
    186             case 'g': debug = 1;
    187                       addArg = FALSE;
     238            case 'g': tr_bencDictAddStr( &top, "method", "torrent-set" );
     239                      addIdArg( args, id );
     240                      addFiles( args, "files-wanted", optarg );
     241                      break;
     242            case 'G': tr_bencDictAddStr( &top, "method", "torrent-set" );
     243                      addIdArg( args, id );
     244                      addFiles( args, "files-unwanted", optarg );
    188245                      break;
    189246            case 'i': tr_bencDictAddStr( &top, "method", "torrent-get" );
     
    252309            case 'X': tr_bencDictAddStr( &top, "method", "session-set" );
    253310                      tr_bencDictAddInt( args, "pex-allowed", 0 );
     311                      break;
     312            case 900: tr_bencDictAddStr( &top, "method", "torrent-set" );
     313                      addIdArg( args, id );
     314                      addFiles( args, "priority-high", optarg );
     315                      break;
     316            case 901: tr_bencDictAddStr( &top, "method", "torrent-set" );
     317                      addIdArg( args, id );
     318                      addFiles( args, "priority-normal", optarg );
     319                      break;
     320            case 902: tr_bencDictAddStr( &top, "method", "torrent-set" );
     321                      addIdArg( args, id );
     322                      addFiles( args, "priority-low", optarg );
    254323                      break;
    255324            default:  fprintf( stderr, "got opt [%d]\n", (int)c );
  • trunk/daemon/transmission-remote.1

    r6295 r6316  
    1313.Op Ar host:port | host | port
    1414.Op Fl a Ar torrent-files
     15.Op Fl b
    1516.Op Fl d Ar number
    1617.Op Fl D
    1718.Op Fl e Ar mode
    1819.Op Fl f
    19 .Op Fl g
     20.Op Fl g Ar files
     21.Op Fl G Ar files
    2022.Op Fl h
    2123.Op Fl i
     
    2527.Op Fl n Ar user:pass
    2628.Op Fl p Ar port
     29.Op Fl ph Ar files
     30.Op Fl pl Ar files
     31.Op Fl pn Ar files
    2732.Op Fl r
    2833.Op Fl s
     
    5459.Ar torrent-file(s) .
    5560
     61.It Fl b Fl -debug
     62Enable debugging mode.
     63
    5664.It Fl d Fl -downlimit Ar limit
    5765Limit the download speed to
     
    7280Get a file list for the current torrent(s)
    7381
     82.It Fl g Fl -get Ar files
     83Mark file(s) for download.
     84.Ar files
     85can be a file index, or a comma-separated list of file indices, or the literal
     86.Ar all
     87for all files in the torrent.
     88
     89.It Fl g Fl -no-get Ar files
     90Mark file(s) for not downloading
     91
    7492.It Fl h Fl -help
    7593Print command-line option descriptions.
     
    96114.Ar port
    97115for use when listening for incoming peer connections
     116
     117.It Fl ph Fl -priority-high Ar files
     118Mark
     119.Ar files
     120as high priority.
     121.Ar files
     122can be a file index, or a comma-separated list of file indices, or the literal
     123.Ar all
     124for all files in the torrent.
     125
     126.It Fl pl Fl -priority-low Ar files
     127Mark
     128.Ar files
     129as low priority
     130
     131.It Fl pn Fl -priority-normal Ar files
     132Mark
     133.Ar files
     134as normal priority
    98135
    99136.It Fl r Fl -remove
     
    136173.El
    137174.Sh EXAMPLES
    138 Show all torrents, their ID numbers, and their status:
    139 .Pp
    140 .Dl transmission-remote -l
    141 .Pp
    142 Pause torrent #12:
    143 .Pp
    144 .Dl transmission-remote -t 12 -S
    145 .Dl transmission-remote --torrent=12 --stop
    146 .Pp
     175
     176List all torrents:
     177.Pp
     178.Dl $ transmission-remote -l
     179.Pp
     180
    147181Start all torrents:
    148182.Pp
    149 .Dl transmission-remote -t all -s
    150 .Dl transmission-remote --torrent=all --start
    151 .Pp
     183.Dl $ transmission-remote -tall --start
     184.Pp
     185
     186Get detailed information on the torrent whose ID is '1':
     187.Pp
     188.Dl $ transmission-remote -t1 -i
     189.Pp
     190
     191Only download the second, fourth, and sixth files of the torrent whose ID is '1':
     192.Pp
     193.Dl $ transmission-remote -t1 -Gall -g2,4,6
     194.Pp
     195
     196Set all torrents' first two files' priorities to high:
     197.Pp
     198.Dl $ transmission-remote -t1 -ph1,2
     199.Pp
     200
     201Set all torrents' files' priorities to normal:
     202.Pp
     203.Dl $ transmission-remote -tall -pnall
     204.Pp
     205
    152206Set download and upload limits to 100 KiB/sec and 20 KiB/sec:
    153207.Pp
    154 .Dl transmission-remote -d 100 -u 20
    155 .Dl transmission-remote -d=100 -u=20
    156 .Pp
     208.Dl $ transmission-remote -d 100 -u 20
     209.Dl $ transmission-remote -d=100 -u=20
     210.Pp
     211
    157212Add two torrents:
    158213.Pp
    159 .Dl transmission-remote -a one.torrent two.torrent
     214.Dl $ transmission-remote -a one.torrent two.torrent
     215.Pp
    160216
    161217.Sh AUTHORS
  • trunk/gtk/tr-prefs.c

    r6285 r6316  
    980980    hig_workarea_add_section_title (t, &row, _( "Router" ) );
    981981
    982         s = _("Use port _forwarding from my router" );
     982        s = _("Use UPnP or NAT-PMP port _forwarding from my router" );
    983983        w = new_check_button( s, PREF_KEY_PORT_FORWARDING, core );
    984984        hig_workarea_add_wide_control( t, &row, w );
  • trunk/libtransmission/rpc.c

    r6311 r6316  
    339339    int fileCount = 0;
    340340    const int n = tr_bencListSize( list );
    341     tr_file_index_t * files = tr_new0( tr_file_index_t, n );
    342 
    343     for( i=0; i<n; ++i )
    344         if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) )
    345             files[fileCount++] = tmp;
     341    tr_file_index_t * files = tr_new0( tr_file_index_t, tor->info.fileCount );
     342
     343    if( n )
     344    {
     345        for( i=0; i<n; ++i )
     346            if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) )
     347                if( 0<=tmp && tmp<tor->info.fileCount )
     348                    files[fileCount++] = tmp;
     349    }
     350    else // if empty set, apply to all
     351    {
     352        tr_file_index_t t;
     353        for( t=0; t<tor->info.fileCount; ++t )
     354            files[fileCount++] = t;
     355    }
    346356
    347357    if( fileCount )
     
    358368    int fileCount = 0;
    359369    const int n = tr_bencListSize( list );
    360     tr_file_index_t * files = tr_new0( tr_file_index_t, n );
    361 
    362     for( i=0; i<n; ++i )
    363         if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) )
    364             files[fileCount++] = tmp;
     370    tr_file_index_t * files = tr_new0( tr_file_index_t, tor->info.fileCount );
     371
     372    if( n ) // if argument list, process them
     373    {
     374        for( i=0; i<n; ++i )
     375            if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) )
     376                if( 0<=tmp && tmp<tor->info.fileCount )
     377                    files[fileCount++] = tmp;
     378    }
     379    else // if empty set, apply to all
     380    {
     381        tr_file_index_t t;
     382        for( t=0; t<tor->info.fileCount; ++t )
     383            files[fileCount++] = t;
     384    }
    365385
    366386    if( fileCount )
  • trunk/libtransmission/tr-getopt.c

    r6310 r6316  
    5757    const char * shortName  = opt->shortName ? opt->shortName : "";
    5858    const char * arg        = getArgName( opt );
    59     printf( "  -%*s, --%-*s %-*s  %s\n", shortWidth, shortName,
     59    printf( "  -%-*s --%-*s %-*s  %s\n", shortWidth, shortName,
    6060                                         longWidth, longName,
    6161                                         argWidth, arg,
Note: See TracChangeset for help on using the changeset viewer.