1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +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) isComplete;
- (BOOL) isError;
- (BOOL) isErrorOrWarning;
- (NSString *) errorMessage;
- (NSArray *) peers;

View file

@ -920,12 +920,17 @@ int trashDataFile(const char * filename)
- (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
{
if (![self isError])
if (![self isErrorOrWarning])
return @"";
NSString * error;
@ -1058,9 +1063,16 @@ int trashDataFile(const char * filename)
{
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];
if (errorString && ![errorString isEqualToString: @""])
string = [string stringByAppendingFormat: @": %@", errorString];

View file

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