Changeset 8101


Ignore:
Timestamp:
Mar 28, 2009, 8:07:38 PM (13 years ago)
Author:
livings124
Message:

ensure alt speed limit is set on launch when using the scheduler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/session.c

    r8100 r8101  
    205205
    206206    tr_free( dirname );
     207}
     208
     209static tr_bool
     210isAltTime( const tr_session * s )
     211{
     212    tr_bool is;
     213    int minutes;
     214    struct tm tm;
     215    const time_t now = time( NULL );
     216    const int begin = s->altSpeedTimeBegin;
     217    const int end = s->altSpeedTimeEnd;
     218
     219    tr_localtime_r( &now, &tm );
     220    minutes = tm.tm_hour*60 + tm.tm_min;
     221
     222    if( begin <= end )
     223        is = ( begin <= minutes ) && ( minutes < end );
     224    else /* goes past midnight */
     225        is = ( begin <= minutes ) || ( minutes < end );
     226
     227    return is;
    207228}
    208229
     
    640661        tr_sessionUseAltSpeed( session, i!=0 );
    641662    }
     663    else
     664        tr_sessionUseAltSpeed( session, isAltTime( session ) );
    642665
    643666    /**
     
    864887
    865888    return isLimited;
    866 }
    867 
    868 static tr_bool
    869 isAltTime( const tr_session * s )
    870 {
    871     tr_bool is;
    872     int minutes;
    873     struct tm tm;
    874     const time_t now = time( NULL );
    875     const int begin = s->altSpeedTimeBegin;
    876     const int end = s->altSpeedTimeEnd;
    877 
    878     tr_localtime_r( &now, &tm );
    879     minutes = tm.tm_hour*60 + tm.tm_min;
    880 
    881     if( begin <= end )
    882         is = ( begin <= minutes ) && ( minutes < end );
    883     else /* goes past midnight */
    884         is = ( begin <= minutes ) || ( minutes < end );
    885 
    886     return is;
    887889}
    888890
Note: See TracChangeset for help on using the changeset viewer.