#define KEY_SPEED_Bps "speed-Bps"
#define KEY_USE_GLOBAL_SPEED_LIMIT "use-global-speed-limit"
#define KEY_USE_SPEED_LIMIT "use-speed-limit"
+#define KEY_TIME_SEEDING "seeding-time-seconds"
+#define KEY_TIME_DOWNLOADING "downloading-time-seconds"
#define KEY_SPEEDLIMIT_DOWN_SPEED "down-speed"
#define KEY_SPEEDLIMIT_DOWN_MODE "down-mode"
#define KEY_SPEEDLIMIT_UP_SPEED "up-speed"
return;
tr_bencInitDict( &top, 50 ); /* arbitrary "big enough" number */
+ tr_bencDictAddInt( &top, KEY_TIME_SEEDING, tor->secondsSeeding );
+ tr_bencDictAddInt( &top, KEY_TIME_DOWNLOADING, tor->secondsDownloading );
tr_bencDictAddInt( &top, KEY_ACTIVITY_DATE, tor->activityDate );
tr_bencDictAddInt( &top, KEY_ADDED_DATE, tor->addedDate );
tr_bencDictAddInt( &top, KEY_CORRUPT, tor->corruptPrev + tor->corruptCur );
fieldsLoaded |= TR_FR_ACTIVITY_DATE;
}
+ if( ( fieldsToLoad & TR_FR_TIME_SEEDING )
+ && tr_bencDictFindInt( &top, KEY_TIME_SEEDING, &i ) )
+ {
+ tor->secondsSeeding = i;
+ fieldsLoaded |= TR_FR_TIME_SEEDING;
+ }
+
+ if( ( fieldsToLoad & TR_FR_TIME_DOWNLOADING )
+ && tr_bencDictFindInt( &top, KEY_TIME_DOWNLOADING, &i ) )
+ {
+ tor->secondsDownloading = i;
+ fieldsLoaded |= TR_FR_TIME_DOWNLOADING;
+ }
+
if( ( fieldsToLoad & TR_FR_BANDWIDTH_PRIORITY )
&& tr_bencDictFindInt( &top, KEY_BANDWIDTH_PRIORITY, &i )
&& tr_isPriority( i ) )
TR_FR_DONE_DATE = ( 1 << 14 ),
TR_FR_ACTIVITY_DATE = ( 1 << 15 ),
TR_FR_RATIOLIMIT = ( 1 << 16 ),
- TR_FR_IDLELIMIT = ( 1 << 17 )
+ TR_FR_IDLELIMIT = ( 1 << 17 ),
+ TR_FR_TIME_SEEDING = ( 1 << 18 ),
+ TR_FR_TIME_DOWNLOADING = ( 1 << 19 )
};
/**
tr_bencDictAddInt( d, key, st->startDate );
else if( tr_streq( key, keylen, "status" ) )
tr_bencDictAddInt( d, key, st->activity );
+ else if( tr_streq( key, keylen, "secondsDownloading" ) )
+ tr_bencDictAddInt( d, key, st->secondsDownloading );
+ else if( tr_streq( key, keylen, "secondsSeeding" ) )
+ tr_bencDictAddInt( d, key, st->secondsSeeding );
else if( tr_streq( key, keylen, "trackers" ) )
addTrackers( inf, tr_bencDictAddList( d, key, inf->trackerCount ) );
else if( tr_streq( key, keylen, "trackerStats" ) ) {
const int min = 100;
const int max = 999999;
struct timeval tv;
+ tr_torrent * tor = NULL;
tr_session * session = vsession;
assert( tr_isSession( session ) );
assert( session->nowTimer != NULL );
+ /**
+ *** tr_session things to do once per second
+ **/
+
+ tr_timeUpdate( time( NULL ) );
+
+ if( session->turtle.isClockEnabled )
+ turtleCheckClock( session, &session->turtle );
+
+ while(( tor = tr_torrentNext( session, tor ))) {
+ if( tor->isRunning ) {
+ if( tr_torrentIsSeed( tor ) )
+ ++tor->secondsSeeding;
+ else
+ ++tor->secondsDownloading;
+ }
+ }
+
+ /**
+ *** Set the timer
+ **/
+
/* schedule the next timer for right after the next second begins */
gettimeofday( &tv, NULL );
usec = 1000000 - tv.tv_usec;
if( usec < min ) usec = min;
tr_timerAdd( session->nowTimer, 0, usec );
/* fprintf( stderr, "time %zu sec, %zu microsec\n", (size_t)tr_time(), (size_t)tv.tv_usec ); */
-
- /* tr_session things to do once per second */
- tr_timeUpdate( tv.tv_sec );
- if( session->turtle.isClockEnabled )
- turtleCheckClock( session, &session->turtle );
}
static void loadBlocklists( tr_session * session );
s->percentComplete = tr_cpPercentComplete ( &tor->completion );
s->metadataPercentComplete = tr_torrentGetMetadataPercent( tor );
- s->percentDone = tr_cpPercentDone ( &tor->completion );
- s->leftUntilDone = tr_cpLeftUntilDone( &tor->completion );
- s->sizeWhenDone = tr_cpSizeWhenDone ( &tor->completion );
- s->recheckProgress = s->activity == TR_STATUS_CHECK ? getVerifyProgress( tor ) : 0;
- s->activityDate = tor->activityDate;
- s->addedDate = tor->addedDate;
- s->doneDate = tor->doneDate;
- s->startDate = tor->startDate;
+ s->percentDone = tr_cpPercentDone ( &tor->completion );
+ s->leftUntilDone = tr_cpLeftUntilDone( &tor->completion );
+ s->sizeWhenDone = tr_cpSizeWhenDone ( &tor->completion );
+ s->recheckProgress = s->activity == TR_STATUS_CHECK ? getVerifyProgress( tor ) : 0;
+ s->activityDate = tor->activityDate;
+ s->addedDate = tor->addedDate;
+ s->doneDate = tor->doneDate;
+ s->startDate = tor->startDate;
+ s->secondsSeeding = tor->secondsSeeding;
+ s->secondsDownloading = tor->secondsDownloading;
if ((s->activity == TR_STATUS_DOWNLOAD || s->activity == TR_STATUS_SEED) && s->startDate != 0)
s->idleSecs = difftime(tr_time(), MAX(s->startDate, s->activityDate));
time_t startDate;
time_t anyDate;
+ time_t secondsDownloading;
+ time_t secondsSeeding;
+
tr_torrent_metadata_func * metadata_func;
void * metadata_func_user_data;
-1 if activity is not seeding or downloading. */
int idleSecs;
+ /** Cumulative seconds the torrent's ever spent downloading */
+ int secondsDownloading;
+
+ /** Cumulative seconds the torrent's ever spent seeding */
+ int secondsSeeding;
+
/** A torrent is considered finished if it has met its seed ratio.
As a result, only paused torrents can be finished. */
tr_bool finished;