Changeset 8961


Ignore:
Timestamp:
Aug 17, 2009, 8:41:06 PM (13 years ago)
Author:
charles
Message:

(trunk daemon) #2158: transmission-remote should support "turtle mode"

Location:
trunk/daemon
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/remote.c

    r8959 r8961  
    6464{
    6565    { 'a', "add",                  "Add torrent files by filename or URL", "a",  0, NULL },
     66    { 970, "alt-speed",            "Use the alternate Limits", "as",  0, NULL },
     67    { 971, "no-alt-speed",         "Don't use the alternate Limits", "AS",  0, NULL },
     68    { 972, "alt-speed-downlimit",  "max alternate download speed (in KB/s)", "asd",  1, "<speed>" },
     69    { 973, "alt-speed-uplimit",    "max alternate upload speed (in KB/s)", "asu",  1, "<speed>" },
     70    { 974, "alt-speed-scheduler",  "Use the scheduled on/off times", "asc",  0, NULL },
     71    { 975, "no-alt-speed-scheduler","Don't use the scheduled on/off times", "ASC",  0, NULL },
     72    { 976, "alt-speed-time-begin", "Time to start using the alt speed limits (in hhmm)", NULL,  1, "<time>" },
     73    { 977, "alt-speed-time-end",   "Time to stop using the alt speed limits (in hhmm)", NULL,  1, "<time>" },
     74    { 978, "alt-speed-days",       "Numbers for any/all days of the week - eg. \"1-7\"", NULL,  1, "<days>" },
    6675    { 'b', "debug",                "Print debugging information", "b",  0, NULL },
    6776    { 'd', "downlimit",            "Set the maximum global download speed in KB/s", "d",  1, "<speed>" },
     
    212221
    213222static void
     223addTime( tr_benc * args, const char * key, const char * arg )
     224{
     225    int time;
     226    tr_bool success = FALSE;
     227
     228    if( arg && ( strlen( arg ) == 4 ) )
     229    {
     230        const char hh[3] = { arg[0], arg[1], '\0' };
     231        const char mm[3] = { arg[2], arg[3], '\0' };
     232        const int hour = atoi( hh );
     233        const int min = atoi( mm );
     234
     235        if( 0<=hour && hour<24 && 0<=min && min<60 )
     236        {
     237            time = min + ( hour * 60 );
     238            success = TRUE;
     239        }
     240    }
     241
     242    if( success )
     243        tr_bencDictAddInt( args, key, time );
     244    else
     245        fprintf( stderr, "Please specify the time of day in 'hhmm' format.\n" );
     246}
     247
     248static void
     249addDays( tr_benc * args, const char * key, const char * arg )
     250{
     251    int days = 0;
     252
     253    if( arg )
     254    {
     255        int i;
     256        int valueCount;
     257        int * values = tr_parseNumberRange( arg, -1, &valueCount );
     258        for( i=0; i<valueCount; ++i )
     259        {
     260            if ( values[i] < 0 || values[i] > 7 ) continue;
     261            if ( values[i] == 7 ) values[i] = 0;
     262
     263            days |= 1 << values[i];
     264        }
     265        tr_free( values );
     266    }
     267
     268    if ( days )
     269        tr_bencDictAddInt( args, key, days );
     270    else
     271        fprintf( stderr, "Please specify the days of the week in '1-3,4,7' format.\n" );
     272}
     273
     274static void
    214275addFiles( tr_benc *    args,
    215276          const char * key,
     
    374435                break;
    375436
     437            case 970:
     438                tr_bencDictAddStr( &top, "method", "session-set" );
     439                tr_bencDictAddBool( args, TR_PREFS_KEY_ALT_SPEED_ENABLED, TRUE );
     440                break;
     441
     442            case 971:
     443                tr_bencDictAddStr( &top, "method", "session-set" );
     444                tr_bencDictAddBool( args, TR_PREFS_KEY_ALT_SPEED_ENABLED, FALSE );
     445                break;
     446
     447            case 972:
     448                tr_bencDictAddStr( &top, "method", "session-set" );
     449                tr_bencDictAddInt( args, TR_PREFS_KEY_ALT_SPEED_DOWN, numarg( optarg ) );
     450                break;
     451
     452            case 973:
     453                tr_bencDictAddStr( &top, "method", "session-set" );
     454                tr_bencDictAddInt( args, TR_PREFS_KEY_ALT_SPEED_UP, numarg( optarg ) );
     455                break;
     456
     457            case 974:
     458                tr_bencDictAddStr( &top, "method", "session-set" );
     459                tr_bencDictAddBool( args, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, TRUE );
     460                break;
     461
     462            case 975:
     463                tr_bencDictAddStr( &top, "method", "session-set" );
     464                tr_bencDictAddBool( args, TR_PREFS_KEY_ALT_SPEED_TIME_ENABLED, FALSE );
     465                break;
     466
     467            case 976:
     468                tr_bencDictAddStr( &top, "method", "session-set" );
     469                addTime( args, TR_PREFS_KEY_ALT_SPEED_TIME_BEGIN, optarg);
     470                break;
     471
     472            case 977:
     473                tr_bencDictAddStr( &top, "method", "session-set" );
     474                addTime( args, TR_PREFS_KEY_ALT_SPEED_TIME_END, optarg);
     475                break;
     476
     477            case 978:
     478                tr_bencDictAddStr( &top, "method", "session-set" );
     479                addDays( args, TR_PREFS_KEY_ALT_SPEED_TIME_DAY, optarg );
     480                break;
     481
    376482            case 'f':
    377483                tr_bencDictAddStr( &top, "method", "torrent-get" );
  • trunk/daemon/transmission-remote.1

    r8951 r8961  
    1313.Op Ar host:port | host | port
    1414.Op Fl a Ar filenames-or-URLs
     15.Op Fl as
     16.Op Fl AS
     17.Op Fl asd Ar number
     18.Op Fl asu Ar number
     19.Op Fl asc
     20.Op Fl ASC
    1521.Op Fl b
    1622.Op Fl d Ar number | Fl D
     
    4147.Op Fl srd
    4248.Op Fl si
     49.Op Fl st
    4350.Op Fl t Ar all | Ar id | Ar hash
    4451.Op Fl u Ar number | Fl U
     
    6976Enable debugging mode.
    7077
     78.It Fl as Fl -alt-speed
     79Use the alternate Limits.
     80
     81.It Fl AS Fl -no-alt-speed
     82Don't use the alternate Limits.
     83
     84.It Fl asd Fl -alt-speed-downlimit Ar limit
     85Limit the alternate download speed to
     86.Ar limit
     87kilobytes per second.
     88
     89.It Fl asu Fl -alt-speed-uplimit Ar limit
     90Limit the alternate upload speed to
     91.Ar limit
     92kilobytes per second.
     93
     94.It Fl asc Fl -alt-speed-scheduler
     95Use the scheduled on/off times.
     96
     97.It Fl ASC Fl -no-alt-speed-scheduler
     98Don't use the scheduled on/off days and times.
     99
     100.It Fl -alt-speed-time-begin Ar time
     101.Ar Time
     102to start using the alt speed limits (in hhmm).
     103
     104.It Fl -alt-speed-time-end Ar time
     105.Ar Time
     106to stop using the alt speed limits (in hhmm).
     107
     108.It Fl -alt-speed-days Ar days
     109Set the number of
     110.Ar days
     111on which to enable the speed scheduler, using a list such as "2,4-6".
     112
    71113.It Fl d Fl -downlimit Ar limit
    72114Limit the global download speed to
     
    249291.Sh EXAMPLES
    250292
    251 Set download and upload limits to 100 KiB/sec and 20 KiB/sec:
    252 .Bd -literal -offset indent
    253 $ transmission-remote -d100 -u20
    254 $ transmission-remote --downlimit=100 --uplimit=20
     293Set download and upload limits to 400 KiB/sec and 60 KiB/sec:
     294.Bd -literal -offset indent
     295$ transmission-remote -d400 -u60
     296$ transmission-remote --downlimit=400 --uplimit=60
     297.Ed
     298
     299Set alternate download and upload limits to 100 KiB/sec and 20 KiB/sec:
     300.Bd -literal -offset indent
     301$ transmission-remote -asd100 -asu20
     302$ transmission-remote --alt-speed-downlimit=100 --alt-speed-uplimit=20
     303.Ed
     304
     305Set the scheduler to use the alternate speed limits on weekdays between 10AM and 11PM
     306.Bd -literal -offset indent
     307$ transmission-remote --alt-speed-time-begin=1000
     308$ transmission-remote --alt-speed-time-end=2300
     309$ transmission-remote --alt-speed-days=1-5
     310$ transmission-remote --alt-speed-scheduler
    255311.Ed
    256312
Note: See TracChangeset for help on using the changeset viewer.