(trunk) #2560: rename "inactive limit" to "idle limit". Add support in GTK+ client and preliminary support to Qt client
This commit is contained in:
parent
e5ed55808e
commit
3655047e85
|
@ -100,8 +100,8 @@
|
|||
"priority-high" | array indices of high-priority file(s)
|
||||
"priority-low" | array indices of low-priority file(s)
|
||||
"priority-normal" | array indices of normal-priority file(s)
|
||||
"seedInactiveLimit" | number torrent-level number of minutes of seeding inactivity
|
||||
"seedInactiveMode" | number which seeding inactivity to use. See tr_inactvelimit
|
||||
"seedIdleLimit" | number torrent-level number of minutes of seeding inactivity
|
||||
"seedIdleMode" | number which seeding inactivity to use. See tr_inactvelimit
|
||||
"seedRatioLimit" | double torrent-level seeding ratio
|
||||
"seedRatioMode" | number which ratio to use. See tr_ratiolimit
|
||||
"trackerAdd" | object (see below)
|
||||
|
@ -205,8 +205,8 @@
|
|||
rateDownload (KBps) | double | tr_stat
|
||||
rateUpload (KBps) | double | tr_stat
|
||||
recheckProgress | double | tr_stat
|
||||
seedInactiveLimit | number | tr_torrent
|
||||
seedInactiveMode | number | tr_inactvelimit
|
||||
seedIdleLimit | number | tr_torrent
|
||||
seedIdleMode | number | tr_inactvelimit
|
||||
seedRatioLimit | double | tr_torrent
|
||||
seedRatioMode | number | tr_ratiolimit
|
||||
sizeWhenDone | number | tr_stat
|
||||
|
@ -645,7 +645,5 @@
|
|||
| | yes | session-set | new arg "inactive-seeding-limit-enabled"
|
||||
| | yes | session-get | new arg "inactive-seeding-limit"
|
||||
| | yes | session-get | new arg "inactive-seeding-limit-enabled"
|
||||
| | yes | torrent-set | new arg "seedInactiveLimit"
|
||||
| | yes | torrent-set | new arg "seedInactiveMode"
|
||||
| | yes | torrent-get | new arg "seedInactiveLimit"
|
||||
| | yes | torrent-get | new arg "seedInactiveMode"
|
||||
| | yes | torrent-set | new arg "seedIdleLimit"
|
||||
| | yes | torrent-set | new arg "seedIdleMode"
|
||||
|
|
|
@ -125,7 +125,7 @@ addResponseCB( GtkDialog * dialog,
|
|||
{
|
||||
tr_torrent * tor = tr_torrent_handle( data->gtor );
|
||||
|
||||
tr_torrentSetPriority( tor, gtr_priority_combo_get_value( data->priority_combo ) );
|
||||
tr_torrentSetPriority( tor, gtr_priority_combo_get_value( GTK_COMBO_BOX( data->priority_combo ) ) );
|
||||
|
||||
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( data->run_check ) ) )
|
||||
tr_torrentStart( tor );
|
||||
|
@ -297,8 +297,8 @@ addSingleTorrentDialog( GtkWindow * parent, TrCore * core, tr_ctor * ctor )
|
|||
str = _( "_Start when added" );
|
||||
data->run_check = gtk_check_button_new_with_mnemonic( str );
|
||||
|
||||
data->priority_combo = gtr_priority_combo_new( );
|
||||
gtr_priority_combo_set_value( data->priority_combo, TR_PRI_NORMAL );
|
||||
w = data->priority_combo = gtr_priority_combo_new( );
|
||||
gtr_priority_combo_set_value( GTK_COMBO_BOX( w ), TR_PRI_NORMAL );
|
||||
|
||||
g_signal_connect( G_OBJECT( d ), "response",
|
||||
G_CALLBACK( addResponseCB ), data );
|
||||
|
|
276
gtk/details.c
276
gtk/details.c
|
@ -34,33 +34,30 @@ struct DetailsImpl
|
|||
{
|
||||
GtkWidget * dialog;
|
||||
|
||||
GtkWidget * peersPage;
|
||||
GtkWidget * trackerPage;
|
||||
GtkWidget * activityPage;
|
||||
GtkWidget * honor_limits_check;
|
||||
GtkWidget * up_limited_check;
|
||||
GtkWidget * up_limit_sping;
|
||||
GtkWidget * down_limited_check;
|
||||
GtkWidget * down_limit_spin;
|
||||
GtkWidget * bandwidth_combo;
|
||||
|
||||
GtkWidget * honorLimitsCheck;
|
||||
GtkWidget * upLimitedCheck;
|
||||
GtkWidget * upLimitSpin;
|
||||
GtkWidget * downLimitedCheck;
|
||||
GtkWidget * downLimitSpin;
|
||||
GtkWidget * bandwidthCombo;
|
||||
GtkWidget * seedGlobalRadio;
|
||||
GtkWidget * seedForeverRadio;
|
||||
GtkWidget * seedCustomRadio;
|
||||
GtkWidget * seedCustomSpin;
|
||||
GtkWidget * maxPeersSpin;
|
||||
GtkWidget * ratio_combo;
|
||||
GtkWidget * ratio_spin;
|
||||
GtkWidget * idle_combo;
|
||||
GtkWidget * idle_spin;
|
||||
GtkWidget * max_peers_spin;
|
||||
|
||||
guint honorLimitsCheckTag;
|
||||
guint upLimitedCheckTag;
|
||||
guint downLimitedCheckTag;
|
||||
guint downLimitSpinTag;
|
||||
guint upLimitSpinTag;
|
||||
guint bandwidthComboTag;
|
||||
guint seedForeverRadioTag;
|
||||
guint seedGlobalRadioTag;
|
||||
guint seedCustomRadioTag;
|
||||
guint seedCustomSpinTag;
|
||||
guint maxPeersSpinTag;
|
||||
guint honor_limits_check_tag;
|
||||
guint up_limited_check_tag;
|
||||
guint down_limited_check_tag;
|
||||
guint down_limit_spin_tag;
|
||||
guint up_limit_spin_tag;
|
||||
guint bandwidth_combo_tag;
|
||||
guint ratio_combo_tag;
|
||||
guint ratio_spin_tag;
|
||||
guint idle_combo_tag;
|
||||
guint idle_spin_tag;
|
||||
guint max_peers_spin_tag;
|
||||
|
||||
GtkWidget * size_lb;
|
||||
GtkWidget * state_lb;
|
||||
|
@ -192,7 +189,7 @@ refreshOptions( struct DetailsImpl * di, tr_torrent ** torrents, int n )
|
|||
**** Options Page
|
||||
***/
|
||||
|
||||
/* honorLimitsCheck */
|
||||
/* honor_limits_check */
|
||||
if( n ) {
|
||||
const tr_bool baseline = tr_torrentUsesSessionLimits( torrents[0] );
|
||||
int i;
|
||||
|
@ -200,11 +197,11 @@ refreshOptions( struct DetailsImpl * di, tr_torrent ** torrents, int n )
|
|||
if( baseline != tr_torrentUsesSessionLimits( torrents[i] ) )
|
||||
break;
|
||||
if( i == n )
|
||||
set_togglebutton_if_different( di->honorLimitsCheck,
|
||||
di->honorLimitsCheckTag, baseline );
|
||||
set_togglebutton_if_different( di->honor_limits_check,
|
||||
di->honor_limits_check_tag, baseline );
|
||||
}
|
||||
|
||||
/* downLimitedCheck */
|
||||
/* down_limited_check */
|
||||
if( n ) {
|
||||
const tr_bool baseline = tr_torrentUsesSpeedLimit( torrents[0], TR_DOWN );
|
||||
int i;
|
||||
|
@ -212,11 +209,11 @@ refreshOptions( struct DetailsImpl * di, tr_torrent ** torrents, int n )
|
|||
if( baseline != tr_torrentUsesSpeedLimit( torrents[i], TR_DOWN ) )
|
||||
break;
|
||||
if( i == n )
|
||||
set_togglebutton_if_different( di->downLimitedCheck,
|
||||
di->downLimitedCheckTag, baseline );
|
||||
set_togglebutton_if_different( di->down_limited_check,
|
||||
di->down_limited_check_tag, baseline );
|
||||
}
|
||||
|
||||
/* downLimitSpin */
|
||||
/* down_limit_spin */
|
||||
if( n ) {
|
||||
const int baseline = tr_torrentGetSpeedLimit_KBps( torrents[0], TR_DOWN );
|
||||
int i;
|
||||
|
@ -224,11 +221,11 @@ refreshOptions( struct DetailsImpl * di, tr_torrent ** torrents, int n )
|
|||
if( baseline != ( tr_torrentGetSpeedLimit_KBps( torrents[i], TR_DOWN ) ) )
|
||||
break;
|
||||
if( i == n )
|
||||
set_int_spin_if_different( di->downLimitSpin,
|
||||
di->downLimitSpinTag, baseline );
|
||||
set_int_spin_if_different( di->down_limit_spin,
|
||||
di->down_limit_spin_tag, baseline );
|
||||
}
|
||||
|
||||
/* upLimitedCheck */
|
||||
/* up_limited_check */
|
||||
if( n ) {
|
||||
const tr_bool baseline = tr_torrentUsesSpeedLimit( torrents[0], TR_UP );
|
||||
int i;
|
||||
|
@ -236,11 +233,11 @@ refreshOptions( struct DetailsImpl * di, tr_torrent ** torrents, int n )
|
|||
if( baseline != tr_torrentUsesSpeedLimit( torrents[i], TR_UP ) )
|
||||
break;
|
||||
if( i == n )
|
||||
set_togglebutton_if_different( di->upLimitedCheck,
|
||||
di->upLimitedCheckTag, baseline );
|
||||
set_togglebutton_if_different( di->up_limited_check,
|
||||
di->up_limited_check_tag, baseline );
|
||||
}
|
||||
|
||||
/* upLimitSpin */
|
||||
/* up_limit_sping */
|
||||
if( n ) {
|
||||
const int baseline = tr_torrentGetSpeedLimit_KBps( torrents[0], TR_UP );
|
||||
int i;
|
||||
|
@ -248,11 +245,11 @@ refreshOptions( struct DetailsImpl * di, tr_torrent ** torrents, int n )
|
|||
if( baseline != ( tr_torrentGetSpeedLimit_KBps( torrents[i], TR_UP ) ) )
|
||||
break;
|
||||
if( i == n )
|
||||
set_int_spin_if_different( di->upLimitSpin,
|
||||
di->upLimitSpinTag, baseline );
|
||||
set_int_spin_if_different( di->up_limit_sping,
|
||||
di->up_limit_spin_tag, baseline );
|
||||
}
|
||||
|
||||
/* bandwidthCombo */
|
||||
/* bandwidth_combo */
|
||||
if( n ) {
|
||||
const int baseline = tr_torrentGetPriority( torrents[0] );
|
||||
int i;
|
||||
|
@ -260,50 +257,64 @@ refreshOptions( struct DetailsImpl * di, tr_torrent ** torrents, int n )
|
|||
if( baseline != tr_torrentGetPriority( torrents[i] ) )
|
||||
break;
|
||||
if( i == n ) {
|
||||
g_signal_handler_block( di->bandwidthCombo, di->bandwidthComboTag );
|
||||
gtr_priority_combo_set_value( GTK_COMBO_BOX( di->bandwidthCombo ), baseline );
|
||||
g_signal_handler_unblock( di->bandwidthCombo, di->bandwidthComboTag );
|
||||
GtkWidget * w = di->bandwidth_combo;
|
||||
g_signal_handler_block( w, di->bandwidth_combo_tag );
|
||||
gtr_priority_combo_set_value( GTK_COMBO_BOX( w ), baseline );
|
||||
g_signal_handler_unblock( w, di->bandwidth_combo_tag );
|
||||
}
|
||||
else
|
||||
unset_combo( di->bandwidthCombo, di->bandwidthComboTag );
|
||||
unset_combo( di->bandwidth_combo, di->bandwidth_combo_tag );
|
||||
}
|
||||
|
||||
/* seedGlobalRadio */
|
||||
/* seedForeverRadio */
|
||||
/* seedCustomRadio */
|
||||
/* ratio_combo */
|
||||
/* ratio_spin */
|
||||
if( n ) {
|
||||
guint t;
|
||||
const int baseline = tr_torrentGetRatioMode( torrents[0] );
|
||||
int i;
|
||||
const int baseline = tr_torrentGetRatioMode( torrents[0] );
|
||||
for( i=1; i<n; ++i )
|
||||
if( baseline != (int)tr_torrentGetRatioMode( torrents[i] ) )
|
||||
break;
|
||||
if( i == n ) {
|
||||
GtkWidget * w;
|
||||
switch( baseline ) {
|
||||
case TR_RATIOLIMIT_SINGLE: w = di->seedCustomRadio;
|
||||
t = di->seedCustomRadioTag; break;
|
||||
case TR_RATIOLIMIT_UNLIMITED: w = di->seedForeverRadio;
|
||||
t = di->seedForeverRadioTag; break;
|
||||
default /*TR_RATIOLIMIT_GLOBAL*/: w = di->seedGlobalRadio;
|
||||
t = di->seedGlobalRadioTag; break;
|
||||
}
|
||||
set_togglebutton_if_different( w, t, TRUE );
|
||||
GtkWidget * w = di->ratio_combo;
|
||||
g_signal_handler_block( w, di->ratio_combo_tag );
|
||||
gtr_combo_box_set_active_enum( GTK_COMBO_BOX( w ), baseline );
|
||||
gtk_widget_set_visible( di->ratio_spin, baseline == TR_RATIOLIMIT_SINGLE );
|
||||
g_signal_handler_unblock( w, di->ratio_combo_tag );
|
||||
}
|
||||
}
|
||||
|
||||
/* seedCustomSpin */
|
||||
if( n ) {
|
||||
const double baseline = tr_torrentGetRatioLimit( torrents[0] );
|
||||
set_double_spin_if_different( di->seedCustomSpin,
|
||||
di->seedCustomSpinTag, baseline );
|
||||
set_double_spin_if_different( di->ratio_spin,
|
||||
di->ratio_spin_tag, baseline );
|
||||
}
|
||||
|
||||
/* maxPeersSpin */
|
||||
/* idle_combo */
|
||||
/* idle_spin */
|
||||
if( n ) {
|
||||
int i;
|
||||
const int baseline = tr_torrentGetIdleMode( torrents[0] );
|
||||
for( i=1; i<n; ++i )
|
||||
if( baseline != (int)tr_torrentGetIdleMode( torrents[i] ) )
|
||||
break;
|
||||
if( i == n ) {
|
||||
GtkWidget * w = di->idle_combo;
|
||||
g_signal_handler_block( w, di->idle_combo_tag );
|
||||
gtr_combo_box_set_active_enum( GTK_COMBO_BOX( w ), baseline );
|
||||
gtk_widget_set_visible( di->idle_spin, baseline == TR_IDLELIMIT_SINGLE );
|
||||
g_signal_handler_unblock( w, di->idle_combo_tag );
|
||||
}
|
||||
}
|
||||
if( n ) {
|
||||
const int baseline = tr_torrentGetIdleLimit( torrents[0] );
|
||||
set_int_spin_if_different( di->idle_spin,
|
||||
di->idle_spin_tag, baseline );
|
||||
}
|
||||
|
||||
/* max_peers_spin */
|
||||
if( n ) {
|
||||
const int baseline = tr_torrentGetPeerLimit( torrents[0] );
|
||||
set_int_spin_if_different( di->maxPeersSpin,
|
||||
di->maxPeersSpinTag, baseline );
|
||||
set_int_spin_if_different( di->max_peers_spin,
|
||||
di->max_peers_spin_tag, baseline );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,19 +390,6 @@ global_speed_toggled_cb( GtkToggleButton * tb, gpointer d )
|
|||
torrent_set_bool( d, "honorsSessionLimits", gtk_toggle_button_get_active( tb ) );
|
||||
}
|
||||
|
||||
#define RATIO_KEY "ratio-mode"
|
||||
|
||||
static void
|
||||
ratio_mode_changed_cb( GtkToggleButton * tb, struct DetailsImpl * d )
|
||||
{
|
||||
if( gtk_toggle_button_get_active( tb ) )
|
||||
{
|
||||
GObject * o = G_OBJECT( tb );
|
||||
const int mode = GPOINTER_TO_INT( g_object_get_data( o, RATIO_KEY ) );
|
||||
torrent_set_int( d, "seedRatioMode", mode );
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
up_speed_spun_cb( GtkSpinButton * s, struct DetailsImpl * di )
|
||||
{
|
||||
|
@ -404,11 +402,16 @@ down_speed_spun_cb( GtkSpinButton * s, struct DetailsImpl * di )
|
|||
torrent_set_int( di, "downloadLimit", gtk_spin_button_get_value_as_int( s ) );
|
||||
}
|
||||
|
||||
static void
|
||||
idle_spun_cb( GtkSpinButton * s, struct DetailsImpl * di )
|
||||
{
|
||||
torrent_set_int( di, "seedInactiveLimit", gtk_spin_button_get_value_as_int( s ) );
|
||||
}
|
||||
|
||||
static void
|
||||
ratio_spun_cb( GtkSpinButton * s, struct DetailsImpl * di )
|
||||
{
|
||||
torrent_set_real( di, "seedRatioLimit", gtk_spin_button_get_value( s ) );
|
||||
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( di->seedCustomRadio ), TRUE );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -428,10 +431,43 @@ static GtkWidget*
|
|||
new_priority_combo( struct DetailsImpl * di )
|
||||
{
|
||||
GtkWidget * w = gtr_priority_combo_new( );
|
||||
di->bandwidthComboTag = g_signal_connect( w, "changed", G_CALLBACK( onPriorityChanged ), di );
|
||||
di->bandwidth_combo_tag = g_signal_connect( w, "changed", G_CALLBACK( onPriorityChanged ), di );
|
||||
return w;
|
||||
}
|
||||
|
||||
static void refresh( struct DetailsImpl * di );
|
||||
|
||||
#define ARG_KEY "arg-key"
|
||||
|
||||
static void
|
||||
onComboEnumChanged( GtkComboBox * combo_box, struct DetailsImpl * di )
|
||||
{
|
||||
const char * key = g_object_get_data( G_OBJECT( combo_box ), ARG_KEY );
|
||||
torrent_set_int( di, key, gtr_combo_box_get_active_enum( combo_box ) );
|
||||
refresh( di );
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
ratio_combo_new( void )
|
||||
{
|
||||
GtkWidget * w = gtr_combo_box_new_enum( _( "Use global settings" ), TR_RATIOLIMIT_GLOBAL,
|
||||
_( "Seed regardless of ratio" ), TR_RATIOLIMIT_UNLIMITED,
|
||||
_( "Stop seeding at ratio:" ), TR_RATIOLIMIT_SINGLE,
|
||||
NULL );
|
||||
g_object_set_data_full( G_OBJECT( w ), ARG_KEY, g_strdup( "seedRatioMode" ), g_free );
|
||||
return w;
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
idle_combo_new( void )
|
||||
{
|
||||
GtkWidget * w = gtr_combo_box_new_enum ( _( "Use global settings" ), TR_IDLELIMIT_GLOBAL,
|
||||
_( "Seed regardless of activity" ), TR_IDLELIMIT_UNLIMITED,
|
||||
_( "Stop seeding if idle for N minutes:" ), TR_IDLELIMIT_SINGLE,
|
||||
NULL );
|
||||
g_object_set_data_full( G_OBJECT( w ), ARG_KEY, g_strdup( "seedIdleMode" ), g_free );
|
||||
return w;
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
options_page_new( struct DetailsImpl * d )
|
||||
|
@ -439,7 +475,6 @@ options_page_new( struct DetailsImpl * d )
|
|||
guint tag;
|
||||
int row;
|
||||
char buf[128];
|
||||
const char *s;
|
||||
GtkWidget *t, *w, *tb, *h;
|
||||
|
||||
row = 0;
|
||||
|
@ -447,73 +482,60 @@ options_page_new( struct DetailsImpl * d )
|
|||
hig_workarea_add_section_title( t, &row, _( "Speed" ) );
|
||||
|
||||
tb = hig_workarea_add_wide_checkbutton( t, &row, _( "Honor global _limits" ), 0 );
|
||||
d->honorLimitsCheck = tb;
|
||||
d->honor_limits_check = tb;
|
||||
tag = g_signal_connect( tb, "toggled", G_CALLBACK( global_speed_toggled_cb ), d );
|
||||
d->honorLimitsCheckTag = tag;
|
||||
d->honor_limits_check_tag = tag;
|
||||
|
||||
g_snprintf( buf, sizeof( buf ), _( "Limit _download speed (%s):" ), _(speed_K_str) );
|
||||
tb = gtk_check_button_new_with_mnemonic( buf );
|
||||
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( tb ), FALSE );
|
||||
d->downLimitedCheck = tb;
|
||||
d->down_limited_check = tb;
|
||||
tag = g_signal_connect( tb, "toggled", G_CALLBACK( down_speed_toggled_cb ), d );
|
||||
d->downLimitedCheckTag = tag;
|
||||
d->down_limited_check_tag = tag;
|
||||
|
||||
w = gtk_spin_button_new_with_range( 0, INT_MAX, 5 );
|
||||
tag = g_signal_connect( w, "value-changed", G_CALLBACK( down_speed_spun_cb ), d );
|
||||
d->downLimitSpinTag = tag;
|
||||
d->down_limit_spin_tag = tag;
|
||||
hig_workarea_add_row_w( t, &row, tb, w, NULL );
|
||||
d->downLimitSpin = w;
|
||||
d->down_limit_spin = w;
|
||||
|
||||
g_snprintf( buf, sizeof( buf ), _( "Limit _upload speed (%s):" ), _(speed_K_str) );
|
||||
tb = gtk_check_button_new_with_mnemonic( buf );
|
||||
d->upLimitedCheck = tb;
|
||||
d->up_limited_check = tb;
|
||||
tag = g_signal_connect( tb, "toggled", G_CALLBACK( up_speed_toggled_cb ), d );
|
||||
d->upLimitedCheckTag = tag;
|
||||
d->up_limited_check_tag = tag;
|
||||
|
||||
w = gtk_spin_button_new_with_range( 0, INT_MAX, 5 );
|
||||
tag = g_signal_connect( w, "value-changed", G_CALLBACK( up_speed_spun_cb ), d );
|
||||
d->upLimitSpinTag = tag;
|
||||
d->up_limit_spin_tag = tag;
|
||||
hig_workarea_add_row_w( t, &row, tb, w, NULL );
|
||||
d->upLimitSpin = w;
|
||||
d->up_limit_sping = w;
|
||||
|
||||
w = new_priority_combo( d );
|
||||
hig_workarea_add_row( t, &row, _( "Torrent _priority:" ), w, NULL );
|
||||
d->bandwidthCombo = w;
|
||||
d->bandwidth_combo = w;
|
||||
|
||||
hig_workarea_add_section_divider( t, &row );
|
||||
hig_workarea_add_section_title( t, &row, _( "Seed-Until Ratio" ) );
|
||||
|
||||
s = _( "Use _global settings" );
|
||||
w = gtk_radio_button_new_with_mnemonic( NULL, s );
|
||||
hig_workarea_add_wide_control( t, &row, w );
|
||||
g_object_set_data( G_OBJECT( w ), RATIO_KEY, GINT_TO_POINTER( TR_RATIOLIMIT_GLOBAL ) );
|
||||
tag = g_signal_connect( w, "toggled", G_CALLBACK( ratio_mode_changed_cb ), d );
|
||||
d->seedGlobalRadio = w;
|
||||
d->seedGlobalRadioTag = tag;
|
||||
|
||||
s = _( "Seed _regardless of ratio" );
|
||||
w = gtk_radio_button_new_with_mnemonic_from_widget( GTK_RADIO_BUTTON( w ), s );
|
||||
hig_workarea_add_wide_control( t, &row, w );
|
||||
g_object_set_data( G_OBJECT( w ), RATIO_KEY, GINT_TO_POINTER( TR_RATIOLIMIT_UNLIMITED ) );
|
||||
tag = g_signal_connect( w, "toggled", G_CALLBACK( ratio_mode_changed_cb ), d );
|
||||
d->seedForeverRadio = w;
|
||||
d->seedForeverRadioTag = tag;
|
||||
hig_workarea_add_section_title( t, &row, _( "Seeding Limits" ) );
|
||||
|
||||
h = gtk_hbox_new( FALSE, GUI_PAD );
|
||||
s = _( "_Seed torrent until its ratio reaches:" );
|
||||
w = gtk_radio_button_new_with_mnemonic_from_widget( GTK_RADIO_BUTTON( w ), s );
|
||||
d->seedCustomRadio = w;
|
||||
g_object_set_data( G_OBJECT( w ), RATIO_KEY, GINT_TO_POINTER( TR_RATIOLIMIT_SINGLE ) );
|
||||
tag = g_signal_connect( w, "toggled", G_CALLBACK( ratio_mode_changed_cb ), d );
|
||||
d->seedCustomRadioTag = tag;
|
||||
w = d->ratio_combo = ratio_combo_new( );
|
||||
d->ratio_combo_tag = g_signal_connect( w, "changed", G_CALLBACK( onComboEnumChanged ), d );
|
||||
gtk_box_pack_start( GTK_BOX( h ), w, TRUE, TRUE, 0 );
|
||||
w = d->ratio_spin = gtk_spin_button_new_with_range( 0, 1000, .05 );
|
||||
gtk_entry_set_width_chars( GTK_ENTRY( w ), 7 );
|
||||
d->ratio_spin_tag = g_signal_connect( w, "value-changed", G_CALLBACK( ratio_spun_cb ), d );
|
||||
gtk_box_pack_start( GTK_BOX( h ), w, FALSE, FALSE, 0 );
|
||||
w = gtk_spin_button_new_with_range( 0, INT_MAX, .05 );
|
||||
gtk_spin_button_set_digits( GTK_SPIN_BUTTON( w ), 2 );
|
||||
tag = g_signal_connect( w, "value-changed", G_CALLBACK( ratio_spun_cb ), d );
|
||||
hig_workarea_add_row( t, &row, _( "Ratio:" ), h, NULL );
|
||||
|
||||
h = gtk_hbox_new( FALSE, GUI_PAD );
|
||||
w = d->idle_combo = idle_combo_new( );
|
||||
d->idle_combo_tag = g_signal_connect( w, "changed", G_CALLBACK( onComboEnumChanged ), d );
|
||||
gtk_box_pack_start( GTK_BOX( h ), w, TRUE, TRUE, 0 );
|
||||
w = d->idle_spin = gtk_spin_button_new_with_range( 1, INT_MAX, 5 );
|
||||
d->idle_spin_tag = g_signal_connect( w, "value-changed", G_CALLBACK( idle_spun_cb ), d );
|
||||
gtk_box_pack_start( GTK_BOX( h ), w, FALSE, FALSE, 0 );
|
||||
hig_workarea_add_wide_control( t, &row, h );
|
||||
d->seedCustomSpin = w;
|
||||
d->seedCustomSpinTag = tag;
|
||||
hig_workarea_add_row( t, &row, _( "_Idle:" ), h, NULL );
|
||||
|
||||
hig_workarea_add_section_divider( t, &row );
|
||||
hig_workarea_add_section_title( t, &row, _( "Peer Connections" ) );
|
||||
|
@ -521,8 +543,8 @@ options_page_new( struct DetailsImpl * d )
|
|||
w = gtk_spin_button_new_with_range( 1, 3000, 5 );
|
||||
hig_workarea_add_row( t, &row, _( "_Maximum peers:" ), w, w );
|
||||
tag = g_signal_connect( w, "value-changed", G_CALLBACK( max_peers_spun_cb ), d );
|
||||
d->maxPeersSpin = w;
|
||||
d->maxPeersSpinTag = tag;
|
||||
d->max_peers_spin = w;
|
||||
d->max_peers_spin_tag = tag;
|
||||
|
||||
hig_workarea_finish( t, &row );
|
||||
return t;
|
||||
|
@ -1067,7 +1089,7 @@ webseed_model_new( void )
|
|||
G_TYPE_STRING, /* key */
|
||||
G_TYPE_BOOLEAN, /* was-updated */
|
||||
G_TYPE_STRING, /* url */
|
||||
G_TYPE_INT, /* download rate int */
|
||||
G_TYPE_DOUBLE, /* download rate double */
|
||||
G_TYPE_STRING ); /* download rate string */
|
||||
}
|
||||
|
||||
|
@ -2069,8 +2091,6 @@ refreshTracker( struct DetailsImpl * di, tr_torrent ** torrents, int n )
|
|||
g_free( statCount );
|
||||
}
|
||||
|
||||
static void refresh( struct DetailsImpl * di );
|
||||
|
||||
static void
|
||||
onScrapeToggled( GtkToggleButton * button, struct DetailsImpl * di )
|
||||
{
|
||||
|
|
|
@ -1257,6 +1257,14 @@ prefschanged( TrCore * core UNUSED, const char * key, gpointer data )
|
|||
{
|
||||
tr_sessionSetRatioLimit( tr, pref_double_get( key ) );
|
||||
}
|
||||
else if( !strcmp( key, TR_PREFS_KEY_IDLE_LIMIT ) )
|
||||
{
|
||||
tr_sessionSetIdleLimit( tr, pref_int_get( key ) );
|
||||
}
|
||||
else if( !strcmp( key, TR_PREFS_KEY_IDLE_LIMIT_ENABLED ) )
|
||||
{
|
||||
tr_sessionSetIdleLimited( tr, pref_flag_get( key ) );
|
||||
}
|
||||
else if( !strcmp( key, TR_PREFS_KEY_PORT_FORWARDING ) )
|
||||
{
|
||||
tr_sessionSetPortForwardingEnabled( tr, pref_flag_get( key ) );
|
||||
|
|
|
@ -319,7 +319,7 @@ torrentPage( GObject * core )
|
|||
hig_workarea_add_row_w( t, &row, l, w, NULL );
|
||||
|
||||
hig_workarea_add_section_divider( t, &row );
|
||||
hig_workarea_add_section_title( t, &row, _( "Seeding" ) );
|
||||
hig_workarea_add_section_title( t, &row, _( "Seeding Limits" ) );
|
||||
|
||||
s = _( "Stop seeding at _ratio:" );
|
||||
w = new_check_button( s, TR_PREFS_KEY_RATIO_ENABLED, core );
|
||||
|
@ -328,6 +328,13 @@ torrentPage( GObject * core )
|
|||
g_signal_connect( w, "toggled", G_CALLBACK( target_cb ), w2 );
|
||||
hig_workarea_add_row_w( t, &row, w, w2, NULL );
|
||||
|
||||
s = _( "Stop seeding if idle for _N minutes:" );
|
||||
w = new_check_button( s, TR_PREFS_KEY_IDLE_LIMIT_ENABLED, core );
|
||||
w2 = new_spin_button( TR_PREFS_KEY_IDLE_LIMIT, core, 1, 9999, 5 );
|
||||
gtk_widget_set_sensitive( GTK_WIDGET( w2 ), pref_flag_get( TR_PREFS_KEY_IDLE_LIMIT_ENABLED ) );
|
||||
g_signal_connect( w, "toggled", G_CALLBACK( target_cb ), w2 );
|
||||
hig_workarea_add_row_w( t, &row, w, w2, NULL );
|
||||
|
||||
hig_workarea_finish( t, &row );
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#define KEY_SPEEDLIMIT_UP "speed-limit-up"
|
||||
#define KEY_SPEEDLIMIT_DOWN "speed-limit-down"
|
||||
#define KEY_RATIOLIMIT "ratio-limit"
|
||||
#define KEY_INACTIVELIMIT "inactivity-limit"
|
||||
#define KEY_IDLELIMIT "idle-limit"
|
||||
#define KEY_UPLOADED "uploaded"
|
||||
|
||||
#define KEY_SPEED_KiBps "speed"
|
||||
|
@ -57,8 +57,8 @@
|
|||
#define KEY_SPEEDLIMIT_UP_MODE "up-mode"
|
||||
#define KEY_RATIOLIMIT_RATIO "ratio-limit"
|
||||
#define KEY_RATIOLIMIT_MODE "ratio-mode"
|
||||
#define KEY_INACTIVELIMIT_MINS "inactivity-limit"
|
||||
#define KEY_INACTIVELIMIT_MODE "inactivity-mode"
|
||||
#define KEY_IDLELIMIT_MINS "idle-limit"
|
||||
#define KEY_IDLELIMIT_MODE "idle-mode"
|
||||
|
||||
#define KEY_PROGRESS_MTIMES "mtimes"
|
||||
#define KEY_PROGRESS_BITFIELD "bitfield"
|
||||
|
@ -294,11 +294,11 @@ saveRatioLimits( tr_benc * dict, const tr_torrent * tor )
|
|||
}
|
||||
|
||||
static void
|
||||
saveInactivityLimits( tr_benc * dict, const tr_torrent * tor )
|
||||
saveIdleLimits( tr_benc * dict, const tr_torrent * tor )
|
||||
{
|
||||
tr_benc * d = tr_bencDictAddDict( dict, KEY_INACTIVELIMIT, 2 );
|
||||
tr_bencDictAddInt( d, KEY_INACTIVELIMIT_MINS, tr_torrentGetInactiveLimit( tor ) );
|
||||
tr_bencDictAddInt( d, KEY_INACTIVELIMIT_MODE, tr_torrentGetInactiveMode( tor ) );
|
||||
tr_benc * d = tr_bencDictAddDict( dict, KEY_IDLELIMIT, 2 );
|
||||
tr_bencDictAddInt( d, KEY_IDLELIMIT_MINS, tr_torrentGetIdleLimit( tor ) );
|
||||
tr_bencDictAddInt( d, KEY_IDLELIMIT_MODE, tr_torrentGetIdleMode( tor ) );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -387,21 +387,21 @@ loadRatioLimits( tr_benc * dict,
|
|||
}
|
||||
|
||||
static uint64_t
|
||||
loadInactivityLimits( tr_benc * dict,
|
||||
loadIdleLimits( tr_benc * dict,
|
||||
tr_torrent * tor )
|
||||
{
|
||||
uint64_t ret = 0;
|
||||
tr_benc * d;
|
||||
|
||||
if( tr_bencDictFindDict( dict, KEY_INACTIVELIMIT, &d ) )
|
||||
if( tr_bencDictFindDict( dict, KEY_IDLELIMIT, &d ) )
|
||||
{
|
||||
int64_t i;
|
||||
int64_t imin;
|
||||
if( tr_bencDictFindInt( d, KEY_INACTIVELIMIT_MINS, &imin ) )
|
||||
tr_torrentSetInactiveLimit( tor, imin );
|
||||
if( tr_bencDictFindInt( d, KEY_INACTIVELIMIT_MODE, &i ) )
|
||||
tr_torrentSetInactiveMode( tor, i );
|
||||
ret = TR_FR_INACTIVELIMIT;
|
||||
if( tr_bencDictFindInt( d, KEY_IDLELIMIT_MINS, &imin ) )
|
||||
tr_torrentSetIdleLimit( tor, imin );
|
||||
if( tr_bencDictFindInt( d, KEY_IDLELIMIT_MODE, &i ) )
|
||||
tr_torrentSetIdleMode( tor, i );
|
||||
ret = TR_FR_IDLELIMIT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -570,7 +570,7 @@ tr_torrentSaveResume( tr_torrent * tor )
|
|||
}
|
||||
saveSpeedLimits( &top, tor );
|
||||
saveRatioLimits( &top, tor );
|
||||
saveInactivityLimits( &top, tor );
|
||||
saveIdleLimits( &top, tor );
|
||||
|
||||
filename = getResumeFilename( tor );
|
||||
if(( err = tr_bencToFile( &top, TR_FMT_BENC, filename )))
|
||||
|
@ -706,8 +706,8 @@ loadFromFile( tr_torrent * tor,
|
|||
if( fieldsToLoad & TR_FR_RATIOLIMIT )
|
||||
fieldsLoaded |= loadRatioLimits( &top, tor );
|
||||
|
||||
if( fieldsToLoad & TR_FR_INACTIVELIMIT )
|
||||
fieldsLoaded |= loadInactivityLimits( &top, tor );
|
||||
if( fieldsToLoad & TR_FR_IDLELIMIT )
|
||||
fieldsLoaded |= loadIdleLimits( &top, tor );
|
||||
|
||||
/* loading the resume file triggers of a lot of changes,
|
||||
* but none of them needs to trigger a re-saving of the
|
||||
|
|
|
@ -36,7 +36,7 @@ enum
|
|||
TR_FR_DONE_DATE = ( 1 << 14 ),
|
||||
TR_FR_ACTIVITY_DATE = ( 1 << 15 ),
|
||||
TR_FR_RATIOLIMIT = ( 1 << 16 ),
|
||||
TR_FR_INACTIVELIMIT = ( 1 << 17 )
|
||||
TR_FR_IDLELIMIT = ( 1 << 17 )
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -574,10 +574,10 @@ addField( const tr_torrent * tor, tr_benc * d, const char * key )
|
|||
tr_bencDictAddReal( d, key, st->pieceUploadSpeed_KBps );
|
||||
else if( tr_streq( key, keylen, "recheckProgress" ) )
|
||||
tr_bencDictAddReal( d, key, st->recheckProgress );
|
||||
else if( tr_streq( key, keylen, "seedInactiveLimit" ) )
|
||||
tr_bencDictAddInt( d, key, tr_torrentGetInactiveLimit( tor ) );
|
||||
else if( tr_streq( key, keylen, "seedInactiveMode" ) )
|
||||
tr_bencDictAddInt( d, key, tr_torrentGetInactiveMode( tor ) );
|
||||
else if( tr_streq( key, keylen, "seedIdleLimit" ) )
|
||||
tr_bencDictAddInt( d, key, tr_torrentGetIdleLimit( tor ) );
|
||||
else if( tr_streq( key, keylen, "seedIdleMode" ) )
|
||||
tr_bencDictAddInt( d, key, tr_torrentGetIdleMode( tor ) );
|
||||
else if( tr_streq( key, keylen, "seedRatioLimit" ) )
|
||||
tr_bencDictAddReal( d, key, tr_torrentGetRatioLimit( tor ) );
|
||||
else if( tr_streq( key, keylen, "seedRatioMode" ) )
|
||||
|
@ -1017,10 +1017,10 @@ torrentSet( tr_session * session,
|
|||
tr_torrentSetSpeedLimit_KBps( tor, TR_UP, tmp );
|
||||
if( tr_bencDictFindBool( args_in, "uploadLimited", &boolVal ) )
|
||||
tr_torrentUseSpeedLimit( tor, TR_UP, boolVal );
|
||||
if( tr_bencDictFindInt( args_in, "seedInactiveLimit", &tmp ) )
|
||||
tr_torrentSetInactiveLimit( tor, tmp );
|
||||
if( tr_bencDictFindInt( args_in, "seedInactiveMode", &tmp ) )
|
||||
tr_torrentSetInactiveMode( tor, tmp );
|
||||
if( tr_bencDictFindInt( args_in, "seedIdleLimit", &tmp ) )
|
||||
tr_torrentSetIdleLimit( tor, tmp );
|
||||
if( tr_bencDictFindInt( args_in, "seedIdleMode", &tmp ) )
|
||||
tr_torrentSetIdleMode( tor, tmp );
|
||||
if( tr_bencDictFindReal( args_in, "seedRatioLimit", &d ) )
|
||||
tr_torrentSetRatioLimit( tor, d );
|
||||
if( tr_bencDictFindInt( args_in, "seedRatioMode", &tmp ) )
|
||||
|
@ -1461,10 +1461,10 @@ sessionSet( tr_session * session,
|
|||
tr_sessionSetRatioLimit( session, d );
|
||||
if( tr_bencDictFindBool( args_in, "seedRatioLimited", &boolVal ) )
|
||||
tr_sessionSetRatioLimited( session, boolVal );
|
||||
if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_INACTIVE_LIMIT, &i ) )
|
||||
tr_sessionSetInactiveLimit( session, i );
|
||||
if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_INACTIVE_LIMIT_ENABLED, &boolVal ) )
|
||||
tr_sessionSetInactivityLimited( session, boolVal );
|
||||
if( tr_bencDictFindInt( args_in, TR_PREFS_KEY_IDLE_LIMIT, &i ) )
|
||||
tr_sessionSetIdleLimit( session, i );
|
||||
if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_IDLE_LIMIT_ENABLED, &boolVal ) )
|
||||
tr_sessionSetIdleLimited( session, boolVal );
|
||||
if( tr_bencDictFindBool( args_in, TR_PREFS_KEY_START, &boolVal ) )
|
||||
tr_sessionSetPaused( session, !boolVal );
|
||||
if( tr_bencDictFindStr( args_in, TR_PREFS_KEY_SCRIPT_TORRENT_DONE_FILENAME, &str ) )
|
||||
|
@ -1579,8 +1579,8 @@ sessionGet( tr_session * s,
|
|||
tr_bencDictAddInt ( d, "rpc-version-minimum", RPC_VERSION_MIN );
|
||||
tr_bencDictAddReal( d, "seedRatioLimit", tr_sessionGetRatioLimit( s ) );
|
||||
tr_bencDictAddBool( d, "seedRatioLimited", tr_sessionIsRatioLimited( s ) );
|
||||
tr_bencDictAddInt ( d, TR_PREFS_KEY_INACTIVE_LIMIT, tr_sessionGetInactiveLimit( s ) );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_INACTIVE_LIMIT_ENABLED, tr_sessionIsInactivityLimited( s ) );
|
||||
tr_bencDictAddInt ( d, TR_PREFS_KEY_IDLE_LIMIT, tr_sessionGetIdleLimit( s ) );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_IDLE_LIMIT_ENABLED, tr_sessionIsIdleLimited( s ) );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_START, !tr_sessionGetPaused( s ) );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_TRASH_ORIGINAL, tr_sessionGetDeleteSource( s ) );
|
||||
tr_bencDictAddInt ( d, TR_PREFS_KEY_USPEED_KBps, tr_sessionGetSpeedLimit_KBps( s, TR_UP ) );
|
||||
|
|
|
@ -255,8 +255,8 @@ tr_sessionGetDefaultSettings( const char * configDir UNUSED, tr_benc * d )
|
|||
tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED_KBps, 100 );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, FALSE );
|
||||
tr_bencDictAddInt ( d, TR_PREFS_KEY_ENCRYPTION, TR_DEFAULT_ENCRYPTION );
|
||||
tr_bencDictAddReal( d, TR_PREFS_KEY_INACTIVE_LIMIT, 30 );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_INACTIVE_LIMIT_ENABLED, FALSE );
|
||||
tr_bencDictAddInt ( d, TR_PREFS_KEY_IDLE_LIMIT, 30 );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_IDLE_LIMIT_ENABLED, FALSE );
|
||||
tr_bencDictAddStr ( d, TR_PREFS_KEY_INCOMPLETE_DIR, tr_getDefaultDownloadDir( ) );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, FALSE );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_LAZY_BITFIELD, TRUE );
|
||||
|
@ -323,8 +323,8 @@ tr_sessionGetSettings( tr_session * s, struct tr_benc * d )
|
|||
tr_bencDictAddInt ( d, TR_PREFS_KEY_DSPEED_KBps, tr_sessionGetSpeedLimit_KBps( s, TR_DOWN ) );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_DSPEED_ENABLED, tr_sessionIsSpeedLimited( s, TR_DOWN ) );
|
||||
tr_bencDictAddInt ( d, TR_PREFS_KEY_ENCRYPTION, s->encryptionMode );
|
||||
tr_bencDictAddInt( d, TR_PREFS_KEY_INACTIVE_LIMIT, s->inactiveLimitMinutes );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_INACTIVE_LIMIT_ENABLED, s->isInactivityLimited );
|
||||
tr_bencDictAddInt ( d, TR_PREFS_KEY_IDLE_LIMIT, tr_sessionGetIdleLimit( s ) );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_IDLE_LIMIT_ENABLED, tr_sessionIsIdleLimited( s ) );
|
||||
tr_bencDictAddStr ( d, TR_PREFS_KEY_INCOMPLETE_DIR, tr_sessionGetIncompleteDir( s ) );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, tr_sessionIsIncompleteDirEnabled( s ) );
|
||||
tr_bencDictAddBool( d, TR_PREFS_KEY_LAZY_BITFIELD, s->useLazyBitfield );
|
||||
|
@ -801,10 +801,10 @@ sessionSetImpl( void * vdata )
|
|||
if( tr_bencDictFindBool( settings, TR_PREFS_KEY_RATIO_ENABLED, &boolVal ) )
|
||||
tr_sessionSetRatioLimited( session, boolVal );
|
||||
|
||||
if( tr_bencDictFindInt( settings, TR_PREFS_KEY_INACTIVE_LIMIT, &i ) )
|
||||
tr_sessionSetInactiveLimit( session, i );
|
||||
if( tr_bencDictFindBool( settings, TR_PREFS_KEY_INACTIVE_LIMIT_ENABLED, &boolVal ) )
|
||||
tr_sessionSetInactivityLimited( session, boolVal );
|
||||
if( tr_bencDictFindInt( settings, TR_PREFS_KEY_IDLE_LIMIT, &i ) )
|
||||
tr_sessionSetIdleLimit( session, i );
|
||||
if( tr_bencDictFindBool( settings, TR_PREFS_KEY_IDLE_LIMIT_ENABLED, &boolVal ) )
|
||||
tr_sessionSetIdleLimited( session, boolVal );
|
||||
|
||||
/**
|
||||
*** Turtle Mode
|
||||
|
@ -1108,35 +1108,35 @@ tr_sessionGetRatioLimit( const tr_session * session )
|
|||
***/
|
||||
|
||||
void
|
||||
tr_sessionSetInactivityLimited( tr_session * session, tr_bool isLimited )
|
||||
tr_sessionSetIdleLimited( tr_session * session, tr_bool isLimited )
|
||||
{
|
||||
assert( tr_isSession( session ) );
|
||||
|
||||
session->isInactivityLimited = isLimited;
|
||||
session->isIdleLimited = isLimited;
|
||||
}
|
||||
|
||||
void
|
||||
tr_sessionSetInactiveLimit( tr_session * session, uint64_t inactivityMinutes )
|
||||
tr_sessionSetIdleLimit( tr_session * session, uint16_t inactivityMinutes )
|
||||
{
|
||||
assert( tr_isSession( session ) );
|
||||
|
||||
session->inactiveLimitMinutes = inactivityMinutes;
|
||||
session->idleLimitMinutes = inactivityMinutes;
|
||||
}
|
||||
|
||||
tr_bool
|
||||
tr_sessionIsInactivityLimited( const tr_session * session )
|
||||
tr_sessionIsIdleLimited( const tr_session * session )
|
||||
{
|
||||
assert( tr_isSession( session ) );
|
||||
|
||||
return session->isInactivityLimited;
|
||||
return session->isIdleLimited;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
tr_sessionGetInactiveLimit( const tr_session * session )
|
||||
uint16_t
|
||||
tr_sessionGetIdleLimit( const tr_session * session )
|
||||
{
|
||||
assert( tr_isSession( session ) );
|
||||
|
||||
return session->inactiveLimitMinutes;
|
||||
return session->idleLimitMinutes;
|
||||
}
|
||||
|
||||
/***
|
||||
|
|
|
@ -95,7 +95,7 @@ struct tr_session
|
|||
tr_bool useLazyBitfield;
|
||||
tr_bool isIncompleteFileNamingEnabled;
|
||||
tr_bool isRatioLimited;
|
||||
tr_bool isInactivityLimited;
|
||||
tr_bool isIdleLimited;
|
||||
tr_bool isIncompleteDirEnabled;
|
||||
tr_bool pauseAddedTorrent;
|
||||
tr_bool deleteSourceTorrent;
|
||||
|
@ -186,7 +186,7 @@ struct tr_session
|
|||
|
||||
double desiredRatio;
|
||||
|
||||
uint64_t inactiveLimitMinutes;
|
||||
uint16_t idleLimitMinutes;
|
||||
|
||||
struct tr_bindinfo * public_ipv4;
|
||||
struct tr_bindinfo * public_ipv6;
|
||||
|
|
|
@ -328,68 +328,68 @@ tr_torrentIsSeedRatioDone( tr_torrent * tor )
|
|||
***/
|
||||
|
||||
void
|
||||
tr_torrentSetInactiveMode( tr_torrent * tor, tr_inactivelimit mode )
|
||||
tr_torrentSetIdleMode( tr_torrent * tor, tr_idlelimit mode )
|
||||
{
|
||||
assert( tr_isTorrent( tor ) );
|
||||
assert( mode==TR_INACTIVELIMIT_GLOBAL || mode==TR_INACTIVELIMIT_SINGLE || mode==TR_INACTIVELIMIT_UNLIMITED );
|
||||
assert( mode==TR_IDLELIMIT_GLOBAL || mode==TR_IDLELIMIT_SINGLE || mode==TR_IDLELIMIT_UNLIMITED );
|
||||
|
||||
if( mode != tor->inactiveLimitMode )
|
||||
if( mode != tor->idleLimitMode )
|
||||
{
|
||||
tor->inactiveLimitMode = mode;
|
||||
tor->idleLimitMode = mode;
|
||||
|
||||
tr_torrentSetDirty( tor );
|
||||
}
|
||||
}
|
||||
|
||||
tr_inactivelimit
|
||||
tr_torrentGetInactiveMode( const tr_torrent * tor )
|
||||
tr_idlelimit
|
||||
tr_torrentGetIdleMode( const tr_torrent * tor )
|
||||
{
|
||||
assert( tr_isTorrent( tor ) );
|
||||
|
||||
return tor->inactiveLimitMode;
|
||||
return tor->idleLimitMode;
|
||||
}
|
||||
|
||||
void
|
||||
tr_torrentSetInactiveLimit( tr_torrent * tor, uint64_t inactiveMinutes)
|
||||
tr_torrentSetIdleLimit( tr_torrent * tor, uint16_t idleMinutes )
|
||||
{
|
||||
assert( tr_isTorrent( tor ) );
|
||||
|
||||
if( inactiveMinutes > 0 )
|
||||
if( idleMinutes > 0 )
|
||||
{
|
||||
tor->inactiveLimitMinutes = inactiveMinutes;
|
||||
tor->idleLimitMinutes = idleMinutes;
|
||||
|
||||
tr_torrentSetDirty( tor );
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t
|
||||
tr_torrentGetInactiveLimit( const tr_torrent * tor )
|
||||
uint16_t
|
||||
tr_torrentGetIdleLimit( const tr_torrent * tor )
|
||||
{
|
||||
assert( tr_isTorrent( tor ) );
|
||||
|
||||
return tor->inactiveLimitMinutes;
|
||||
return tor->idleLimitMinutes;
|
||||
}
|
||||
|
||||
tr_bool
|
||||
tr_torrentGetSeedInactive( const tr_torrent * tor, uint64_t * inactiveMinutes )
|
||||
tr_torrentGetSeedIdle( const tr_torrent * tor, uint16_t * idleMinutes )
|
||||
{
|
||||
tr_bool isLimited;
|
||||
|
||||
switch( tr_torrentGetInactiveMode( tor ) )
|
||||
switch( tr_torrentGetIdleMode( tor ) )
|
||||
{
|
||||
case TR_INACTIVELIMIT_SINGLE:
|
||||
case TR_IDLELIMIT_SINGLE:
|
||||
isLimited = TRUE;
|
||||
if( inactiveMinutes )
|
||||
*inactiveMinutes = tr_torrentGetInactiveLimit( tor );
|
||||
if( idleMinutes )
|
||||
*idleMinutes = tr_torrentGetIdleLimit( tor );
|
||||
break;
|
||||
|
||||
case TR_INACTIVELIMIT_GLOBAL:
|
||||
isLimited = tr_sessionIsInactivityLimited( tor->session );
|
||||
if( isLimited && inactiveMinutes )
|
||||
*inactiveMinutes = tr_sessionGetInactiveLimit( tor->session );
|
||||
case TR_IDLELIMIT_GLOBAL:
|
||||
isLimited = tr_sessionIsIdleLimited( tor->session );
|
||||
if( isLimited && idleMinutes )
|
||||
*idleMinutes = tr_sessionGetIdleLimit( tor->session );
|
||||
break;
|
||||
|
||||
default: /* TR_INACTIVELIMIT_UNLIMITED */
|
||||
default: /* TR_IDLELIMIT_UNLIMITED */
|
||||
isLimited = FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -398,12 +398,12 @@ tr_torrentGetSeedInactive( const tr_torrent * tor, uint64_t * inactiveMinutes )
|
|||
}
|
||||
|
||||
static tr_bool
|
||||
tr_torrentIsSeedInactiveLimitDone( tr_torrent * tor )
|
||||
tr_torrentIsSeedIdleLimitDone( tr_torrent * tor )
|
||||
{
|
||||
uint64_t inactiveMinutes;
|
||||
uint16_t idleMinutes;
|
||||
#warning can this use the idleSecs from tr_stat?
|
||||
return tr_torrentGetSeedInactive( tor, &inactiveMinutes )
|
||||
&& difftime(tr_time(), MAX(tor->startDate, tor->activityDate)) >= inactiveMinutes * 60;
|
||||
return tr_torrentGetSeedIdle( tor, &idleMinutes )
|
||||
&& difftime(tr_time(), MAX(tor->startDate, tor->activityDate)) >= idleMinutes * 60u;
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -430,15 +430,15 @@ tr_torrentCheckSeedLimit( tr_torrent * tor )
|
|||
tor->ratio_limit_hit_func( tor, tor->ratio_limit_hit_func_user_data );
|
||||
}
|
||||
/* if we're seeding and reach our inactiviy limit, stop the torrent */
|
||||
else if( tr_torrentIsSeedInactiveLimitDone( tor ) )
|
||||
else if( tr_torrentIsSeedIdleLimitDone( tor ) )
|
||||
{
|
||||
tr_torinf( tor, "Seeding inactivity limit reached; pausing torrent" );
|
||||
|
||||
tor->isStopping = TRUE;
|
||||
|
||||
/* maybe notify the client */
|
||||
if( tor->inactive_limit_hit_func != NULL )
|
||||
tor->inactive_limit_hit_func( tor, tor->inactive_limit_hit_func_user_data );
|
||||
if( tor->idle_limit_hit_func != NULL )
|
||||
tor->idle_limit_hit_func( tor, tor->idle_limit_hit_func_user_data );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -808,10 +808,10 @@ torrentInit( tr_torrent * tor, const tr_ctor * ctor )
|
|||
tr_torrentSetRatioLimit( tor, tr_sessionGetRatioLimit( tor->session ) );
|
||||
}
|
||||
|
||||
if( !( loaded & TR_FR_INACTIVELIMIT ) )
|
||||
if( !( loaded & TR_FR_IDLELIMIT ) )
|
||||
{
|
||||
tr_torrentSetInactiveMode( tor, TR_INACTIVELIMIT_GLOBAL );
|
||||
tr_torrentSetInactiveLimit( tor, tr_sessionGetInactiveLimit( tor->session ) );
|
||||
tr_torrentSetIdleMode( tor, TR_IDLELIMIT_GLOBAL );
|
||||
tr_torrentSetIdleLimit( tor, tr_sessionGetIdleLimit( tor->session ) );
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1782,21 +1782,21 @@ tr_torrentClearRatioLimitHitCallback( tr_torrent * torrent )
|
|||
tr_torrentSetRatioLimitHitCallback( torrent, NULL, NULL );
|
||||
}
|
||||
|
||||
void
|
||||
tr_torrentSetInactiveLimitHitCallback( tr_torrent * tor,
|
||||
tr_torrent_inactive_limit_hit_func func,
|
||||
void * user_data )
|
||||
static void
|
||||
tr_torrentSetIdleLimitHitCallback( tr_torrent * tor,
|
||||
tr_torrent_idle_limit_hit_func func,
|
||||
void * user_data )
|
||||
{
|
||||
assert( tr_isTorrent( tor ) );
|
||||
|
||||
tor->inactive_limit_hit_func = func;
|
||||
tor->inactive_limit_hit_func_user_data = user_data;
|
||||
tor->idle_limit_hit_func = func;
|
||||
tor->idle_limit_hit_func_user_data = user_data;
|
||||
}
|
||||
|
||||
void
|
||||
tr_torrentClearInactiveLimitHitCallback( tr_torrent * torrent )
|
||||
tr_torrentClearIdleLimitHitCallback( tr_torrent * torrent )
|
||||
{
|
||||
tr_torrentSetInactiveLimitHitCallback( torrent, NULL, NULL );
|
||||
tr_torrentSetIdleLimitHitCallback( torrent, NULL, NULL );
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -229,8 +229,8 @@ struct tr_torrent
|
|||
tr_torrent_ratio_limit_hit_func * ratio_limit_hit_func;
|
||||
void * ratio_limit_hit_func_user_data;
|
||||
|
||||
tr_torrent_inactive_limit_hit_func * inactive_limit_hit_func;
|
||||
void * inactive_limit_hit_func_user_data;
|
||||
tr_torrent_idle_limit_hit_func * idle_limit_hit_func;
|
||||
void * idle_limit_hit_func_user_data;
|
||||
|
||||
tr_bool isRunning;
|
||||
tr_bool isStopping;
|
||||
|
@ -258,8 +258,8 @@ struct tr_torrent
|
|||
double desiredRatio;
|
||||
tr_ratiolimit ratioLimitMode;
|
||||
|
||||
uint64_t inactiveLimitMinutes;
|
||||
tr_inactivelimit inactiveLimitMode;
|
||||
uint16_t idleLimitMinutes;
|
||||
tr_idlelimit idleLimitMode;
|
||||
|
||||
uint64_t preVerifyTotal;
|
||||
};
|
||||
|
|
|
@ -170,8 +170,8 @@ const char* tr_getDefaultDownloadDir( void );
|
|||
#define TR_PREFS_KEY_LPD_ENABLED "lpd-enabled"
|
||||
#define TR_PREFS_KEY_DOWNLOAD_DIR "download-dir"
|
||||
#define TR_PREFS_KEY_ENCRYPTION "encryption"
|
||||
#define TR_PREFS_KEY_INACTIVE_LIMIT "inactive-seeding-limit"
|
||||
#define TR_PREFS_KEY_INACTIVE_LIMIT_ENABLED "inactive-seeding-limit-enabled"
|
||||
#define TR_PREFS_KEY_IDLE_LIMIT "idle-seeding-limit"
|
||||
#define TR_PREFS_KEY_IDLE_LIMIT_ENABLED "idle-seeding-limit-enabled"
|
||||
#define TR_PREFS_KEY_INCOMPLETE_DIR "incomplete-dir"
|
||||
#define TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED "incomplete-dir-enabled"
|
||||
#define TR_PREFS_KEY_LAZY_BITFIELD "lazy-bitfield-enabled"
|
||||
|
@ -725,11 +725,11 @@ tr_bool tr_sessionIsRatioLimited ( const tr_session * );
|
|||
void tr_sessionSetRatioLimit ( tr_session *, double desiredRatio );
|
||||
double tr_sessionGetRatioLimit ( const tr_session * );
|
||||
|
||||
void tr_sessionSetInactivityLimited ( tr_session *, tr_bool isLimited );
|
||||
tr_bool tr_sessionIsInactivityLimited ( const tr_session * );
|
||||
void tr_sessionSetIdleLimited ( tr_session *, tr_bool isLimited );
|
||||
tr_bool tr_sessionIsIdleLimited ( const tr_session * );
|
||||
|
||||
void tr_sessionSetInactiveLimit ( tr_session *, uint64_t inactivityMinutes );
|
||||
uint64_t tr_sessionGetInactiveLimit ( const tr_session * );
|
||||
void tr_sessionSetIdleLimit ( tr_session *, uint16_t idleMinutes );
|
||||
uint16_t tr_sessionGetIdleLimit ( const tr_session * );
|
||||
|
||||
void tr_sessionSetPeerLimit( tr_session *, uint16_t maxGlobalPeers );
|
||||
uint16_t tr_sessionGetPeerLimit( const tr_session * );
|
||||
|
@ -1169,29 +1169,29 @@ tr_bool tr_torrentGetSeedRatio( const tr_torrent *, double * ratio );
|
|||
|
||||
|
||||
/****
|
||||
***** Inactive Time Limits
|
||||
***** Idle Time Limits
|
||||
****/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TR_INACTIVELIMIT_GLOBAL = 0, /* follow the global settings */
|
||||
TR_INACTIVELIMIT_SINGLE = 1, /* override the global settings, seeding until a certain inactive time */
|
||||
TR_INACTIVELIMIT_UNLIMITED = 2 /* override the global settings, seeding regardless of activity */
|
||||
TR_IDLELIMIT_GLOBAL = 0, /* follow the global settings */
|
||||
TR_IDLELIMIT_SINGLE = 1, /* override the global settings, seeding until a certain idle time */
|
||||
TR_IDLELIMIT_UNLIMITED = 2 /* override the global settings, seeding regardless of activity */
|
||||
}
|
||||
tr_inactivelimit;
|
||||
tr_idlelimit;
|
||||
|
||||
void tr_torrentSetInactiveMode( tr_torrent * tor,
|
||||
tr_inactivelimit mode );
|
||||
void tr_torrentSetIdleMode ( tr_torrent * tor,
|
||||
tr_idlelimit mode );
|
||||
|
||||
tr_inactivelimit tr_torrentGetInactiveMode( const tr_torrent * tor );
|
||||
tr_idlelimit tr_torrentGetIdleMode ( const tr_torrent * tor );
|
||||
|
||||
void tr_torrentSetInactiveLimit( tr_torrent * tor,
|
||||
uint64_t inactiveMinutes );
|
||||
void tr_torrentSetIdleLimit( tr_torrent * tor,
|
||||
uint16_t idleMinutes );
|
||||
|
||||
uint64_t tr_torrentGetInactiveLimit( const tr_torrent * tor );
|
||||
uint16_t tr_torrentGetIdleLimit( const tr_torrent * tor );
|
||||
|
||||
|
||||
tr_bool tr_torrentGetSeedInactive( const tr_torrent *, uint64_t * inactiveMinutes );
|
||||
tr_bool tr_torrentGetSeedIdle( const tr_torrent *, uint16_t * idleMinutes );
|
||||
|
||||
/****
|
||||
***** Peer Limits
|
||||
|
@ -1322,8 +1322,8 @@ typedef void ( tr_torrent_completeness_func )( tr_torrent * torrent,
|
|||
typedef void ( tr_torrent_ratio_limit_hit_func )( tr_torrent * torrent,
|
||||
void * user_data );
|
||||
|
||||
typedef void ( tr_torrent_inactive_limit_hit_func )( tr_torrent * torrent,
|
||||
void * user_data );
|
||||
typedef void ( tr_torrent_idle_limit_hit_func )( tr_torrent * torrent,
|
||||
void * user_data );
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1384,10 +1384,10 @@ void tr_torrentClearRatioLimitHitCallback( tr_torrent * torrent );
|
|||
*/
|
||||
void tr_torrentSetInactivityLimitHitCallback(
|
||||
tr_torrent * torrent,
|
||||
tr_torrent_inactive_limit_hit_func func,
|
||||
tr_torrent_idle_limit_hit_func func,
|
||||
void * user_data );
|
||||
|
||||
void tr_torrentClearInactiveLimitHitCallback( tr_torrent * torrent );
|
||||
void tr_torrentClearIdleLimitHitCallback( tr_torrent * torrent );
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1229,7 +1229,7 @@ Details :: createOptionsTab( )
|
|||
myBandwidthPriorityCombo = m;
|
||||
|
||||
hig->addSectionDivider( );
|
||||
hig->addSectionTitle( tr( "Seed-Until Ratio" ) );
|
||||
hig->addSectionTitle( tr( "Seeding Limits" ) );
|
||||
|
||||
r = new QRadioButton( tr( "Use &global settings" ) );
|
||||
r->setProperty( RATIO_KEY, TR_RATIOLIMIT_GLOBAL );
|
||||
|
|
|
@ -595,13 +595,18 @@ PrefsDialog :: createTorrentsTab( )
|
|||
hig->addRow( tr( "Save to &Location:" ), b );
|
||||
|
||||
hig->addSectionDivider( );
|
||||
hig->addSectionTitle( tr( "Seeding" ) );
|
||||
hig->addSectionTitle( tr( "Seeding Limits" ) );
|
||||
|
||||
l = checkBoxNew( tr( "&Seed torrent until its ratio reaches:" ), Prefs::RATIO_ENABLED );
|
||||
l = checkBoxNew( tr( "Stop seeding at &ratio:" ), Prefs::RATIO_ENABLED );
|
||||
r = doubleSpinBoxNew( Prefs::RATIO, 0, INT_MAX, 0.5, 2 );
|
||||
hig->addRow( l, r );
|
||||
enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), r );
|
||||
|
||||
l = checkBoxNew( tr( "Stop seeding if idle for &N minutes:" ), Prefs::IDLE_LIMIT_ENABLED );
|
||||
r = spinBoxNew( Prefs::IDLE_LIMIT, 1, INT_MAX, 5 );
|
||||
hig->addRow( l, r );
|
||||
enableBuddyWhenChecked( qobject_cast<QCheckBox*>(l), r );
|
||||
|
||||
hig->finish( );
|
||||
return hig;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,8 @@ Prefs::PrefItem Prefs::myItems[] =
|
|||
{ DSPEED_ENABLED, TR_PREFS_KEY_DSPEED_ENABLED, QVariant::Bool },
|
||||
{ DOWNLOAD_DIR, TR_PREFS_KEY_DOWNLOAD_DIR, QVariant::String },
|
||||
{ ENCRYPTION, TR_PREFS_KEY_ENCRYPTION, QVariant::Int },
|
||||
{ IDLE_LIMIT, TR_PREFS_KEY_IDLE_LIMIT, QVariant::Int },
|
||||
{ IDLE_LIMIT_ENABLED, TR_PREFS_KEY_IDLE_LIMIT_ENABLED, QVariant::Bool },
|
||||
{ INCOMPLETE_DIR, TR_PREFS_KEY_INCOMPLETE_DIR, QVariant::String },
|
||||
{ INCOMPLETE_DIR_ENABLED, TR_PREFS_KEY_INCOMPLETE_DIR_ENABLED, QVariant::Bool },
|
||||
{ LAZY_BITFIELD, TR_PREFS_KEY_LAZY_BITFIELD, QVariant::Bool },
|
||||
|
|
|
@ -80,6 +80,8 @@ class Prefs: public QObject
|
|||
DSPEED_ENABLED,
|
||||
DOWNLOAD_DIR,
|
||||
ENCRYPTION,
|
||||
IDLE_LIMIT,
|
||||
IDLE_LIMIT_ENABLED,
|
||||
INCOMPLETE_DIR,
|
||||
INCOMPLETE_DIR_ENABLED,
|
||||
LAZY_BITFIELD,
|
||||
|
|
|
@ -144,6 +144,8 @@ Session :: updatePref( int key )
|
|||
case Prefs :: DOWNLOAD_DIR:
|
||||
case Prefs :: DSPEED:
|
||||
case Prefs :: DSPEED_ENABLED:
|
||||
case Prefs :: IDLE_LIMIT:
|
||||
case Prefs :: IDLE_LIMIT_ENABLED:
|
||||
case Prefs :: INCOMPLETE_DIR:
|
||||
case Prefs :: INCOMPLETE_DIR_ENABLED:
|
||||
case Prefs :: LPD_ENABLED:
|
||||
|
|
Loading…
Reference in New Issue