Changeset 3947


Ignore:
Timestamp:
Nov 23, 2007, 5:42:49 PM (14 years ago)
Author:
livings124
Message:

show remaining time for seeding torrents towards ratio

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Torrent.h

    r3946 r3947  
    154154- (float) progressDone;
    155155- (float) progressLeft;
     156
    156157- (int) eta;
    157 - (NSString * ) etaString;
     158- (int) etaRatio;
     159- (NSString * ) etaString: (int) eta;
    158160
    159161- (float) notAvailableDesired;
  • trunk/macosx/Torrent.m

    r3946 r3947  
    724724}
    725725
    726 - (NSString * ) etaString
    727 {
    728     int eta = [self eta];
     726- (int) etaRatio
     727{
     728    if (![self isSeeding])
     729        return -1;
     730   
     731    float uploadRate = [self uploadRate];
     732    if (uploadRate < 0.1)
     733        return -1;
     734   
     735    float stopRatio = [self actualStopRatio], ratio = [self ratio];
     736    if (stopRatio == INVALID || ratio >= stopRatio)
     737        return -1;
     738   
     739    return (float)MAX([self downloadedTotal], [self haveVerified]) * (stopRatio - ratio) / uploadRate / 1024.0;
     740}
     741
     742- (NSString * ) etaString: (int) eta
     743{
    729744    if (eta < 0)
    730745        return @"";
     
    869884    if (fStat->status == TR_STATUS_DOWNLOAD)
    870885    {
    871         string = [self eta] >= 0
    872             ? [string stringByAppendingFormat: NSLocalizedString(@" - %@ remaining", "Torrent -> progress string"), [self etaString]]
     886        int eta = [self eta];
     887        string = eta >= 0 ? [string stringByAppendingFormat: NSLocalizedString(@" - %@ remaining", "Torrent -> progress string"),
     888                                [self etaString: eta]]
    873889            : [string stringByAppendingString: NSLocalizedString(@" - remaining time unknown", "Torrent -> progress string")];
    874890    }
     891    else if ([self isSeeding] && fRatioSetting != NSOffState)
     892    {
     893        int eta = [self etaRatio];
     894        string = eta >= 0 ? [string stringByAppendingFormat: NSLocalizedString(@" - %@ remaining", "Torrent -> progress string"),
     895                                [self etaString: eta]]
     896            : [string stringByAppendingString: NSLocalizedString(@" - remaining time unknown", "Torrent -> progress string")];
     897    }
     898    else;
    875899   
    876900    return string;
     
    10071031    {
    10081032        case TR_STATUS_DOWNLOAD:
    1009             return [self eta] >= 0 ? [self etaString] : NSLocalizedString(@"Unknown", "Torrent -> remaining time");
     1033            return [self eta] >= 0 ? [self etaString: [self eta]] : NSLocalizedString(@"Unknown", "Torrent -> remaining time");
    10101034       
    10111035        case TR_STATUS_SEED:
Note: See TracChangeset for help on using the changeset viewer.