add a stat for the eta of the seeding idle limit, and use it in the Mac eta display
This commit is contained in:
parent
dfed8e6d91
commit
c3715ca6ce
|
@ -1056,6 +1056,7 @@ tr_torrentStat( tr_torrent * tor )
|
|||
uint64_t seedRatioBytesLeft;
|
||||
uint64_t seedRatioBytesGoal;
|
||||
tr_bool seedRatioApplies;
|
||||
uint16_t seedIdleMinutes;
|
||||
|
||||
if( !tor )
|
||||
return NULL;
|
||||
|
@ -1141,7 +1142,6 @@ tr_torrentStat( tr_torrent * tor )
|
|||
s->ratio = tr_getRatio( s->uploadedEver,
|
||||
s->downloadedEver ? s->downloadedEver : s->haveValid );
|
||||
|
||||
#warning account for idle limit?
|
||||
seedRatioApplies = tr_torrentGetSeedRatioBytes( tor, &seedRatioBytesLeft,
|
||||
&seedRatioBytesGoal );
|
||||
|
||||
|
@ -1166,10 +1166,11 @@ tr_torrentStat( tr_torrent * tor )
|
|||
s->eta = TR_ETA_UNKNOWN;
|
||||
else
|
||||
s->eta = s->leftUntilDone / toSpeedBytes(tor->etaDLSpeed_KBps);
|
||||
|
||||
s->etaIdle = TR_ETA_NOT_AVAIL;
|
||||
break;
|
||||
|
||||
case TR_STATUS_SEED: {
|
||||
#warning do something for idle?
|
||||
if( !seedRatioApplies )
|
||||
s->eta = TR_ETA_NOT_AVAIL;
|
||||
else {
|
||||
|
@ -1184,11 +1185,17 @@ tr_torrentStat( tr_torrent * tor )
|
|||
else
|
||||
s->eta = seedRatioBytesLeft / toSpeedBytes(tor->etaULSpeed_KBps);
|
||||
}
|
||||
|
||||
if( tr_torrentGetSeedIdle( tor, &seedIdleMinutes ) )
|
||||
s->etaIdle = seedIdleMinutes * 60 - s->idleSecs;
|
||||
else
|
||||
s->etaIdle = TR_ETA_NOT_AVAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
s->eta = TR_ETA_NOT_AVAIL;
|
||||
s->etaIdle = TR_ETA_NOT_AVAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1817,6 +1817,8 @@ typedef struct tr_stat
|
|||
/** If downloading, estimated number of seconds left until the torrent is done.
|
||||
If seeding, estimated number of seconds left until seed ratio is reached. */
|
||||
int eta;
|
||||
/** If seeding, number of seconds left until the idle time limit is reached.. */
|
||||
int etaIdle;
|
||||
|
||||
/** Number of peers that the tracker says this torrent has */
|
||||
int peersKnown;
|
||||
|
|
|
@ -90,19 +90,19 @@
|
|||
- (BOOL) isMagnet;
|
||||
- (NSString *) magnetLink;
|
||||
|
||||
- (BOOL) seedLimitSet;
|
||||
|
||||
- (CGFloat) ratio;
|
||||
- (tr_ratiolimit) ratioSetting;
|
||||
- (void) setRatioSetting: (tr_ratiolimit) setting;
|
||||
- (CGFloat) ratioLimit;
|
||||
- (void) setRatioLimit: (CGFloat) limit;
|
||||
- (BOOL) seedRatioSet;
|
||||
- (CGFloat) progressStopRatio;
|
||||
|
||||
- (tr_idlelimit) idleSetting;
|
||||
- (void) setIdleSetting: (tr_idlelimit) setting;
|
||||
- (NSUInteger) idleLimitMinutes;
|
||||
- (void) setIdleLimitMinutes: (NSUInteger) limit;
|
||||
- (BOOL) seedIdleLimitSet;
|
||||
|
||||
- (BOOL) usesSpeedLimit: (BOOL) upload;
|
||||
- (void) setUseSpeedLimit: (BOOL) use upload: (BOOL) upload;
|
||||
|
@ -157,8 +157,6 @@
|
|||
- (CGFloat) progressLeft;
|
||||
- (CGFloat) checkingProgress;
|
||||
|
||||
- (NSInteger) eta;
|
||||
|
||||
- (CGFloat) availableDesired;
|
||||
|
||||
- (BOOL) isActive;
|
||||
|
|
|
@ -357,6 +357,11 @@ int trashDataFile(const char * filename)
|
|||
return [NSString stringWithUTF8String: tr_torrentGetMagnetLink(fHandle)];
|
||||
}
|
||||
|
||||
- (BOOL) seedLimitSet
|
||||
{
|
||||
return tr_torrentGetSeedRatio(fHandle, NULL) || tr_torrentGetSeedIdle(fHandle, NULL);
|
||||
}
|
||||
|
||||
- (CGFloat) ratio
|
||||
{
|
||||
return fStat->ratio;
|
||||
|
@ -383,11 +388,6 @@ int trashDataFile(const char * filename)
|
|||
tr_torrentSetRatioLimit(fHandle, limit);
|
||||
}
|
||||
|
||||
- (BOOL) seedRatioSet
|
||||
{
|
||||
return tr_torrentGetSeedRatio(fHandle, NULL);
|
||||
}
|
||||
|
||||
- (CGFloat) progressStopRatio
|
||||
{
|
||||
return fStat->seedRatioPercentDone;
|
||||
|
@ -414,11 +414,6 @@ int trashDataFile(const char * filename)
|
|||
tr_torrentSetIdleLimit(fHandle, limit);
|
||||
}
|
||||
|
||||
- (BOOL) seedIdleLimitSet
|
||||
{
|
||||
return tr_torrentGetSeedIdle(fHandle, NULL);
|
||||
}
|
||||
|
||||
- (BOOL) usesSpeedLimit: (BOOL) upload
|
||||
{
|
||||
return tr_torrentUsesSpeedLimit(fHandle, upload ? TR_UP : TR_DOWN);
|
||||
|
@ -821,11 +816,6 @@ int trashDataFile(const char * filename)
|
|||
return fStat->recheckProgress;
|
||||
}
|
||||
|
||||
- (NSInteger) eta
|
||||
{
|
||||
return fStat->eta;
|
||||
}
|
||||
|
||||
- (CGFloat) availableDesired
|
||||
{
|
||||
return (CGFloat)fStat->desiredAvailable / [self sizeLeft];
|
||||
|
@ -1013,7 +1003,7 @@ int trashDataFile(const char * filename)
|
|||
}
|
||||
|
||||
//add time when downloading or seed limit set
|
||||
if (fStat->activity == TR_STATUS_DOWNLOAD || ([self isSeeding] && [self seedRatioSet]))
|
||||
if (fStat->activity == TR_STATUS_DOWNLOAD || ([self isSeeding] && [self seedLimitSet]))
|
||||
string = [string stringByAppendingFormat: @" - %@", [self etaString]];
|
||||
|
||||
return string;
|
||||
|
@ -1161,8 +1151,7 @@ int trashDataFile(const char * filename)
|
|||
|
||||
- (NSString *) remainingTimeString
|
||||
{
|
||||
#warning update?
|
||||
if (fStat->activity == TR_STATUS_DOWNLOAD || ([self isSeeding] && [self seedRatioSet]))
|
||||
if (fStat->activity == TR_STATUS_DOWNLOAD || ([self isSeeding] && [self seedLimitSet]))
|
||||
return [self etaString];
|
||||
else
|
||||
return [self shortStatusString];
|
||||
|
@ -1819,18 +1808,24 @@ int trashDataFile(const char * filename)
|
|||
[[NSNotificationCenter defaultCenter] postNotificationName: @"ResetInspector" object: self];
|
||||
}
|
||||
|
||||
#warning don't show idle minutes when very large
|
||||
- (NSString *) etaString
|
||||
{
|
||||
const NSInteger eta = [self eta];
|
||||
switch (eta)
|
||||
{
|
||||
case TR_ETA_NOT_AVAIL:
|
||||
case TR_ETA_UNKNOWN:
|
||||
return NSLocalizedString(@"remaining time unknown", "Torrent -> eta string");
|
||||
default:
|
||||
return [NSString stringWithFormat: NSLocalizedString(@"%@ remaining", "Torrent -> eta string"),
|
||||
[NSString timeString: eta showSeconds: YES maxFields: 2]];
|
||||
}
|
||||
const BOOL etaReg = fStat->eta != TR_ETA_NOT_AVAIL && fStat->eta != TR_ETA_UNKNOWN;
|
||||
const BOOL etaIdelSeed = fStat->etaIdle != TR_ETA_NOT_AVAIL && fStat->etaIdle != TR_ETA_UNKNOWN;
|
||||
|
||||
NSInteger eta;
|
||||
if (etaReg && etaIdelSeed)
|
||||
eta = MIN(fStat->eta, fStat->etaIdle);
|
||||
else if (etaReg)
|
||||
eta = fStat->eta;
|
||||
else if (etaIdelSeed)
|
||||
eta = fStat->etaIdle;
|
||||
else
|
||||
return NSLocalizedString(@"remaining time unknown", "Torrent -> eta string");
|
||||
|
||||
return [NSString stringWithFormat: NSLocalizedString(@"%@ remaining", "Torrent -> eta string"),
|
||||
[NSString timeString: eta showSeconds: YES maxFields: 2]];
|
||||
}
|
||||
|
||||
- (void) setTimeMachineExclude: (BOOL) exclude forPath: (NSString *) path
|
||||
|
|
Loading…
Reference in New Issue