mirror of
https://github.com/transmission/transmission.git
synced 2026-05-08 09:39:08 +01:00
(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
This commit is contained in:
+80
-11
@@ -10,6 +10,7 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* strcmp */
|
||||
@@ -36,22 +37,38 @@ enum { TAG_LIST, TAG_DETAILS, TAG_FILES };
|
||||
static const char*
|
||||
getUsage( void )
|
||||
{
|
||||
return "Transmission "LONG_VERSION_STRING" http://www.transmissionbt.com/\n"
|
||||
"A fast and easy BitTorrent client\n"
|
||||
"\n"
|
||||
"Usage: "MY_NAME" [host] [options]\n"
|
||||
" "MY_NAME" [port] [options]\n"
|
||||
" "MY_NAME" [host:port] [options]";
|
||||
return
|
||||
"Transmission "LONG_VERSION_STRING" http://www.transmissionbt.com/\n"
|
||||
"A fast and easy BitTorrent client\n"
|
||||
"\n"
|
||||
"Usage: "MY_NAME" [host] [options]\n"
|
||||
" "MY_NAME" [port] [options]\n"
|
||||
" "MY_NAME" [host:port] [options]\n"
|
||||
"\n"
|
||||
"Notes:\n"
|
||||
" <files> can be 'all', a single index, or a comma-separated list.\n"
|
||||
" <torrents> can be 'all', a torrent id or hash string, or a comma-separated list of ids and hash strings.\n"
|
||||
"\n"
|
||||
"Examples:\n"
|
||||
" \""MY_NAME" -l\" (list all torrents)\n"
|
||||
" \""MY_NAME" -tall --start\" (start all torrents)\n"
|
||||
" \""MY_NAME" --add ~/Desktop/*torrent\" (add all the torrent files in $HOME/Desktop)\n"
|
||||
" \""MY_NAME" -t1 -i\" (get detailed information on the torrent whose id is '1')\n"
|
||||
" \""MY_NAME" -t1 -Gall -g2,4,6\" (same torrent; only download the second, fourth, and sixth files)\n"
|
||||
" \""MY_NAME" -tall -ph1,2\" (set all torrent's first two files' priorities to high)\n"
|
||||
" \""MY_NAME" -tall -pnall\" (set all torrent's files' priorities to normal)";
|
||||
}
|
||||
|
||||
static tr_option opts[] =
|
||||
{
|
||||
{ 'a', "add", "Add torrent files", "a", 0, NULL },
|
||||
{ 'b', "debug", "Print debugging information", "b", 0, NULL },
|
||||
{ 'd', "downlimit", "Set the maximum download speed in KB/s", "d", 1, "<number>" },
|
||||
{ 'D', "no-downlimit", "Don't limit the download speed", "D", 0, NULL },
|
||||
{ 'e', "encryption", "Set encryption mode [required, preferred, tolerated]", "e", 1, "<mode>" },
|
||||
{ 'f', "files", "Get a file list for the current torrent(s)", "f", 0, NULL },
|
||||
{ 'g', "debug", "Print debugging information", "g", 0, NULL },
|
||||
{ 'g', "get", "Mark files for download", "g", 1, "<files>" },
|
||||
{ 'G', "no-get", "Mark files for not downloading", "G", 1, "<files>" },
|
||||
{ 'h', "help", "Show this help page and exit", "h", 0, NULL },
|
||||
{ 'i', "info", "Show details of the current torrent(s)", "i", 0, NULL },
|
||||
{ 'l', "list", "List all torrents", "l", 0, NULL },
|
||||
@@ -59,10 +76,13 @@ static tr_option opts[] =
|
||||
{ 'M', "no-portmap", "Disable portmapping", "M", 0, NULL },
|
||||
{ 'n', "auth", "Set username for authentication", "n", 1, "<user>:<pass>" },
|
||||
{ 'p', "port", "Port to listen for incoming peers", "p", 1, "<port>" },
|
||||
{ 900, "priority-high", "Set one or more files' priority as high", "ph", 1, "<files>" },
|
||||
{ 901, "priority-normal", "Set one or more files' priority as normal", "pn", 1, "<files>" },
|
||||
{ 902, "priority-normal", "Set one or more files' priority as low", "pl", 1, "<files>" },
|
||||
{ 'r', "remove", "Remove the current torrent(s)", "r", 0, NULL },
|
||||
{ 's', "start", "Start the current torrent(s)", "s", 0, NULL },
|
||||
{ 'S', "stop", "Stop the current torrent(s)", "S", 0, NULL },
|
||||
{ 't', "torrent", "Set the current torrent(s)", "t", 1, "<id|hash|all>" },
|
||||
{ 't', "torrent", "Set the current torrent(s)", "t", 1, "<torrents>" },
|
||||
{ 'u', "uplimit", "Set the maximum upload speed in KB/s", "u", 1, "<number>" },
|
||||
{ 'U', "no-uplimit", "Don't limit the upload speed", "U", 0, NULL },
|
||||
{ 'v', "verify", "Verify the current torrent(s)", "v", 0, NULL },
|
||||
@@ -125,11 +145,40 @@ addIdArg( tr_benc * args, const char * id )
|
||||
if( !*id ) {
|
||||
fprintf( stderr, "No torrent specified! Please use the -t option first.\n" );
|
||||
id = "-1"; /* no torrent will have this ID, so should be a no-op */
|
||||
} else if( strcmp( id, "all" ) ) {
|
||||
}
|
||||
if( strcmp( id, "all" ) ) {
|
||||
tr_rpc_parse_list_str( tr_bencDictAdd( args, "ids" ), id, strlen(id) );
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
addFiles( tr_benc * args, const char * key, const char * arg )
|
||||
{
|
||||
tr_benc * files = tr_bencDictAddList( args, key, 100 );
|
||||
|
||||
if( !*arg )
|
||||
{
|
||||
fprintf( stderr, "No files specified!\n" );
|
||||
arg = "-1"; /* no file will have this index, so should be a no-op */
|
||||
}
|
||||
if( strcmp( arg, "all" ) )
|
||||
{
|
||||
const char * walk = arg;
|
||||
while( *walk ) {
|
||||
char * p;
|
||||
unsigned long l;
|
||||
errno = 0;
|
||||
l = strtol( walk, &p, 10 );
|
||||
if( errno )
|
||||
break;
|
||||
tr_bencListAddInt( files, l - 1 );
|
||||
if( *p != ',' )
|
||||
break;
|
||||
walk = p + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
readargs( int argc, const char ** argv )
|
||||
{
|
||||
@@ -165,6 +214,9 @@ readargs( int argc, const char ** argv )
|
||||
case 'a': addingTorrents = 1;
|
||||
addArg = FALSE;
|
||||
break;
|
||||
case 'b': debug = 1;
|
||||
addArg = FALSE;
|
||||
break;
|
||||
case 'd': tr_bencDictAddStr( &top, "method", "session-set" );
|
||||
tr_bencDictAddInt( args, "speed-limit-down", numarg( optarg ) );
|
||||
tr_bencDictAddInt( args, "speed-limit-down-enabled", 1 );
|
||||
@@ -183,8 +235,13 @@ readargs( int argc, const char ** argv )
|
||||
| TR_RPC_TORRENT_PRIORITIES;
|
||||
tr_bencDictAddInt( args, "fields", fields );
|
||||
break;
|
||||
case 'g': debug = 1;
|
||||
addArg = FALSE;
|
||||
case 'g': tr_bencDictAddStr( &top, "method", "torrent-set" );
|
||||
addIdArg( args, id );
|
||||
addFiles( args, "files-wanted", optarg );
|
||||
break;
|
||||
case 'G': tr_bencDictAddStr( &top, "method", "torrent-set" );
|
||||
addIdArg( args, id );
|
||||
addFiles( args, "files-unwanted", optarg );
|
||||
break;
|
||||
case 'i': tr_bencDictAddStr( &top, "method", "torrent-get" );
|
||||
tr_bencDictAddInt( &top, "tag", TAG_DETAILS );
|
||||
@@ -252,6 +309,18 @@ readargs( int argc, const char ** argv )
|
||||
case 'X': tr_bencDictAddStr( &top, "method", "session-set" );
|
||||
tr_bencDictAddInt( args, "pex-allowed", 0 );
|
||||
break;
|
||||
case 900: tr_bencDictAddStr( &top, "method", "torrent-set" );
|
||||
addIdArg( args, id );
|
||||
addFiles( args, "priority-high", optarg );
|
||||
break;
|
||||
case 901: tr_bencDictAddStr( &top, "method", "torrent-set" );
|
||||
addIdArg( args, id );
|
||||
addFiles( args, "priority-normal", optarg );
|
||||
break;
|
||||
case 902: tr_bencDictAddStr( &top, "method", "torrent-set" );
|
||||
addIdArg( args, id );
|
||||
addFiles( args, "priority-low", optarg );
|
||||
break;
|
||||
default: fprintf( stderr, "got opt [%d]\n", (int)c );
|
||||
showUsage( );
|
||||
break;
|
||||
|
||||
@@ -12,11 +12,13 @@ and
|
||||
.Nm
|
||||
.Op Ar host:port | host | port
|
||||
.Op Fl a Ar torrent-files
|
||||
.Op Fl b
|
||||
.Op Fl d Ar number
|
||||
.Op Fl D
|
||||
.Op Fl e Ar mode
|
||||
.Op Fl f
|
||||
.Op Fl g
|
||||
.Op Fl g Ar files
|
||||
.Op Fl G Ar files
|
||||
.Op Fl h
|
||||
.Op Fl i
|
||||
.Op Fl l
|
||||
@@ -24,6 +26,9 @@ and
|
||||
.Op Fl M
|
||||
.Op Fl n Ar user:pass
|
||||
.Op Fl p Ar port
|
||||
.Op Fl ph Ar files
|
||||
.Op Fl pl Ar files
|
||||
.Op Fl pn Ar files
|
||||
.Op Fl r
|
||||
.Op Fl s
|
||||
.Op Fl S
|
||||
@@ -53,6 +58,9 @@ The options are as follows:
|
||||
Add metainfo
|
||||
.Ar torrent-file(s) .
|
||||
|
||||
.It Fl b Fl -debug
|
||||
Enable debugging mode.
|
||||
|
||||
.It Fl d Fl -downlimit Ar limit
|
||||
Limit the download speed to
|
||||
.Ar limit
|
||||
@@ -71,6 +79,16 @@ Prefer unencrypted peer connections.
|
||||
.It Fl f Fl -files
|
||||
Get a file list for the current torrent(s)
|
||||
|
||||
.It Fl g Fl -get Ar files
|
||||
Mark file(s) for download.
|
||||
.Ar files
|
||||
can be a file index, or a comma-separated list of file indices, or the literal
|
||||
.Ar all
|
||||
for all files in the torrent.
|
||||
|
||||
.It Fl g Fl -no-get Ar files
|
||||
Mark file(s) for not downloading
|
||||
|
||||
.It Fl h Fl -help
|
||||
Print command-line option descriptions.
|
||||
|
||||
@@ -96,6 +114,25 @@ Set the
|
||||
.Ar port
|
||||
for use when listening for incoming peer connections
|
||||
|
||||
.It Fl ph Fl -priority-high Ar files
|
||||
Mark
|
||||
.Ar files
|
||||
as high priority.
|
||||
.Ar files
|
||||
can be a file index, or a comma-separated list of file indices, or the literal
|
||||
.Ar all
|
||||
for all files in the torrent.
|
||||
|
||||
.It Fl pl Fl -priority-low Ar files
|
||||
Mark
|
||||
.Ar files
|
||||
as low priority
|
||||
|
||||
.It Fl pn Fl -priority-normal Ar files
|
||||
Mark
|
||||
.Ar files
|
||||
as normal priority
|
||||
|
||||
.It Fl r Fl -remove
|
||||
Remove the current torrent(s). This does not delete the downloaded data.
|
||||
|
||||
@@ -135,28 +172,47 @@ Disable peer exchange (PEX).
|
||||
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
Show all torrents, their ID numbers, and their status:
|
||||
|
||||
List all torrents:
|
||||
.Pp
|
||||
.Dl transmission-remote -l
|
||||
.Pp
|
||||
Pause torrent #12:
|
||||
.Pp
|
||||
.Dl transmission-remote -t 12 -S
|
||||
.Dl transmission-remote --torrent=12 --stop
|
||||
.Dl $ transmission-remote -l
|
||||
.Pp
|
||||
|
||||
Start all torrents:
|
||||
.Pp
|
||||
.Dl transmission-remote -t all -s
|
||||
.Dl transmission-remote --torrent=all --start
|
||||
.Dl $ transmission-remote -tall --start
|
||||
.Pp
|
||||
|
||||
Get detailed information on the torrent whose ID is '1':
|
||||
.Pp
|
||||
.Dl $ transmission-remote -t1 -i
|
||||
.Pp
|
||||
|
||||
Only download the second, fourth, and sixth files of the torrent whose ID is '1':
|
||||
.Pp
|
||||
.Dl $ transmission-remote -t1 -Gall -g2,4,6
|
||||
.Pp
|
||||
|
||||
Set all torrents' first two files' priorities to high:
|
||||
.Pp
|
||||
.Dl $ transmission-remote -t1 -ph1,2
|
||||
.Pp
|
||||
|
||||
Set all torrents' files' priorities to normal:
|
||||
.Pp
|
||||
.Dl $ transmission-remote -tall -pnall
|
||||
.Pp
|
||||
|
||||
Set download and upload limits to 100 KiB/sec and 20 KiB/sec:
|
||||
.Pp
|
||||
.Dl transmission-remote -d 100 -u 20
|
||||
.Dl transmission-remote -d=100 -u=20
|
||||
.Dl $ transmission-remote -d 100 -u 20
|
||||
.Dl $ transmission-remote -d=100 -u=20
|
||||
.Pp
|
||||
|
||||
Add two torrents:
|
||||
.Pp
|
||||
.Dl transmission-remote -a one.torrent two.torrent
|
||||
.Dl $ transmission-remote -a one.torrent two.torrent
|
||||
.Pp
|
||||
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
|
||||
+1
-1
@@ -979,7 +979,7 @@ networkPage( GObject * core )
|
||||
t = hig_workarea_create( );
|
||||
hig_workarea_add_section_title (t, &row, _( "Router" ) );
|
||||
|
||||
s = _("Use port _forwarding from my router" );
|
||||
s = _("Use UPnP or NAT-PMP port _forwarding from my router" );
|
||||
w = new_check_button( s, PREF_KEY_PORT_FORWARDING, core );
|
||||
hig_workarea_add_wide_control( t, &row, w );
|
||||
|
||||
|
||||
+28
-8
@@ -338,11 +338,21 @@ setFilePriorities( tr_torrent * tor, int priority, tr_benc * list )
|
||||
int64_t tmp;
|
||||
int fileCount = 0;
|
||||
const int n = tr_bencListSize( list );
|
||||
tr_file_index_t * files = tr_new0( tr_file_index_t, n );
|
||||
tr_file_index_t * files = tr_new0( tr_file_index_t, tor->info.fileCount );
|
||||
|
||||
for( i=0; i<n; ++i )
|
||||
if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) )
|
||||
files[fileCount++] = tmp;
|
||||
if( n )
|
||||
{
|
||||
for( i=0; i<n; ++i )
|
||||
if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) )
|
||||
if( 0<=tmp && tmp<tor->info.fileCount )
|
||||
files[fileCount++] = tmp;
|
||||
}
|
||||
else // if empty set, apply to all
|
||||
{
|
||||
tr_file_index_t t;
|
||||
for( t=0; t<tor->info.fileCount; ++t )
|
||||
files[fileCount++] = t;
|
||||
}
|
||||
|
||||
if( fileCount )
|
||||
tr_torrentSetFilePriorities( tor, files, fileCount, priority );
|
||||
@@ -357,11 +367,21 @@ setFileDLs( tr_torrent * tor, int do_download, tr_benc * list )
|
||||
int64_t tmp;
|
||||
int fileCount = 0;
|
||||
const int n = tr_bencListSize( list );
|
||||
tr_file_index_t * files = tr_new0( tr_file_index_t, n );
|
||||
tr_file_index_t * files = tr_new0( tr_file_index_t, tor->info.fileCount );
|
||||
|
||||
for( i=0; i<n; ++i )
|
||||
if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) )
|
||||
files[fileCount++] = tmp;
|
||||
if( n ) // if argument list, process them
|
||||
{
|
||||
for( i=0; i<n; ++i )
|
||||
if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) )
|
||||
if( 0<=tmp && tmp<tor->info.fileCount )
|
||||
files[fileCount++] = tmp;
|
||||
}
|
||||
else // if empty set, apply to all
|
||||
{
|
||||
tr_file_index_t t;
|
||||
for( t=0; t<tor->info.fileCount; ++t )
|
||||
files[fileCount++] = t;
|
||||
}
|
||||
|
||||
if( fileCount )
|
||||
tr_torrentSetFileDLs( tor, files, fileCount, do_download );
|
||||
|
||||
@@ -56,7 +56,7 @@ getopts_usage_line( const tr_option * opt,
|
||||
const char * longName = opt->longName ? opt->longName : "";
|
||||
const char * shortName = opt->shortName ? opt->shortName : "";
|
||||
const char * arg = getArgName( opt );
|
||||
printf( " -%*s, --%-*s %-*s %s\n", shortWidth, shortName,
|
||||
printf( " -%-*s --%-*s %-*s %s\n", shortWidth, shortName,
|
||||
longWidth, longName,
|
||||
argWidth, arg,
|
||||
opt->description );
|
||||
|
||||
Reference in New Issue
Block a user