1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00

recognize tracker errors and warnings

This commit is contained in:
Mitchell Livingston 2009-08-05 01:55:37 +00:00
parent a4767894e7
commit 360f5c49ae
3 changed files with 18 additions and 5 deletions

View file

@ -177,6 +177,7 @@
- (BOOL) allDownloaded; - (BOOL) allDownloaded;
- (BOOL) isComplete; - (BOOL) isComplete;
- (BOOL) isError; - (BOOL) isError;
- (BOOL) isErrorOrWarning;
- (NSString *) errorMessage; - (NSString *) errorMessage;
- (NSArray *) peers; - (NSArray *) peers;

View file

@ -920,12 +920,17 @@ int trashDataFile(const char * filename)
- (BOOL) isError - (BOOL) isError
{ {
return fStat->error != TR_OK; return fStat->error == TR_STAT_LOCAL_ERROR || fStat->error == TR_STAT_TRACKER_ERROR;
}
- (BOOL) isErrorOrWarning
{
return fStat->error != TR_STAT_OK;
} }
- (NSString *) errorMessage - (NSString *) errorMessage
{ {
if (![self isError]) if (![self isErrorOrWarning])
return @""; return @"";
NSString * error; NSString * error;
@ -1058,9 +1063,16 @@ int trashDataFile(const char * filename)
{ {
NSString * string; NSString * string;
if ([self isError]) if ([self isErrorOrWarning])
{ {
string = NSLocalizedString(@"Error", "Torrent -> status string"); switch (fStat->error)
{
case TR_STAT_LOCAL_ERROR: string = NSLocalizedString(@"Error", "Torrent -> status string"); break;
case TR_STAT_TRACKER_ERROR: string = NSLocalizedString(@"Tracker returned an error", "Torrent -> status string"); break;
case TR_STAT_TRACKER_WARNING: string = NSLocalizedString(@"Tracker returned a warning", "Torrent -> status string"); break;
default: NSAssert(NO, @"unknown error state");
}
NSString * errorString = [self errorMessage]; NSString * errorString = [self errorMessage];
if (errorString && ![errorString isEqualToString: @""]) if (errorString && ![errorString isEqualToString: @""])
string = [string stringByAppendingFormat: @": %@", errorString]; string = [string stringByAppendingFormat: @": %@", errorString];

View file

@ -419,7 +419,7 @@
} }
//error image //error image
const BOOL error = [torrent isError]; const BOOL error = [torrent isErrorOrWarning];
if (error && !fErrorImage) if (error && !fErrorImage)
{ {
fErrorImage = [NSImage imageNamed: @"Error.png"]; fErrorImage = [NSImage imageNamed: @"Error.png"];