From 7ab59f951f94f10d3c5b2b1ab7e18fe521335314 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 16 Feb 2008 19:32:22 +0000 Subject: [PATCH] in minimal mode, show eta for seeding --- macosx/Torrent.h | 2 +- macosx/Torrent.m | 29 ++++++++++++----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 78bcb7a88..7b6c13326 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -56,7 +56,7 @@ typedef enum NSImage * fIcon; - NSString * fHashString; + NSString * fNameString, * fHashString; tr_file_stat * fileStat; NSArray * fFileList; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 9fa20b110..4d6349c7e 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -175,6 +175,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * free(fPreviousFinishedPieces); [fFinishedPiecesDate release]; + [fNameString release]; [fHashString release]; [fDownloadFolder release]; @@ -660,7 +661,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * - (NSString *) name { - return [NSString stringWithUTF8String: fInfo->name]; + return fNameString; } - (BOOL) folder @@ -708,12 +709,12 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * - (NSString *) comment { - return fInfo->comment != NULL ? [NSString stringWithUTF8String: fInfo->comment] : @""; + return [NSString stringWithUTF8String: fInfo->comment]; } - (NSString *) creator { - return fInfo->creator != NULL ? [NSString stringWithUTF8String: fInfo->creator] : @""; + return [NSString stringWithUTF8String: fInfo->creator]; } - (NSDate *) dateCreated @@ -1085,19 +1086,12 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * - (NSString *) remainingTimeString { - switch (fStat->status) - { - case TR_STATUS_DOWNLOAD: - return [self eta] >= 0 ? [self etaString: [self eta]] : NSLocalizedString(@"Unknown", "Torrent -> remaining time"); - - case TR_STATUS_SEED: - case TR_STATUS_DONE: - return [NSLocalizedString(@"Ratio: ", "Torrent -> status string") stringByAppendingString: - [NSString stringForRatio: [self ratio]]]; - - default: - return [self shortStatusString]; - } + if (![self isActive] || ([self isSeeding] + && !(fRatioSetting == NSOnState || (fRatioSetting == NSMixedState && [fDefaults boolForKey: @"RatioCheck"])))) + return [self shortStatusString]; + + int eta = fStat->status == TR_STATUS_DOWNLOAD ? [self eta] : [self etaRatio]; + return eta >= 0 ? [self etaString: eta] : NSLocalizedString(@"Unknown", "Torrent -> remaining time"); } - (NSString *) stateString @@ -1574,6 +1568,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * fInfo = tr_torrentInfo(fHandle); + fNameString = [[NSString alloc] initWithUTF8String: fInfo->name]; fHashString = [[NSString alloc] initWithUTF8String: fInfo->hashString]; fDateAdded = dateAdded ? [dateAdded retain] : [[NSDate alloc] init]; @@ -1712,7 +1707,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * case TR_CP_DONE: case TR_CP_COMPLETE: canMove = YES; - + //move file from incomplete folder to download folder if (fUseIncompleteFolder && ![[self downloadFolder] isEqualToString: fDownloadFolder] && (canMove = [self alertForMoveFolderAvailable]))