change slightly which values are sent for display in the inspector (i.e. don't send values that won't be displayed), in peer table's tooltip show N/A instead of 0 for port when not available, and don't show progress for non-connected peers

This commit is contained in:
Mitchell Livingston 2007-05-04 18:42:26 +00:00
parent 91e4607c64
commit 2f82b2f4fa
2 changed files with 39 additions and 25 deletions

View File

@ -682,12 +682,12 @@
else if ([ident isEqualToString: @"Client"])
return [peer objectForKey: @"Client"];
else if ([ident isEqualToString: @"Progress"])
return [peer objectForKey: @"Progress"];
return [[peer objectForKey: @"Connected"] boolValue] ? [peer objectForKey: @"Progress"] : 0;
else if ([ident isEqualToString: @"UL To"])
return [[peer objectForKey: @"UL To"] boolValue]
return [[peer objectForKey: @"Connected"] boolValue] && [[peer objectForKey: @"UL To"] boolValue]
? [NSString stringForSpeedAbbrev: [[peer objectForKey: @"UL To Rate"] floatValue]] : @"";
else if ([ident isEqualToString: @"DL From"])
return [[peer objectForKey: @"DL From"] boolValue]
return [[peer objectForKey: @"Connected"] boolValue] && [[peer objectForKey: @"DL From"] boolValue]
? [NSString stringForSpeedAbbrev: [[peer objectForKey: @"DL From Rate"] floatValue]] : @"";
else
return [peer objectForKey: @"IP"];
@ -719,24 +719,33 @@
{
if (tableView == fPeerTable)
{
NSDictionary * peerDic = [fPeers objectAtIndex: row];
NSDictionary * peer = [fPeers objectAtIndex: row];
NSString * fromString;
int from = [[peerDic objectForKey: @"From"] intValue];
if (from == TR_PEER_FROM_INCOMING)
fromString = NSLocalizedString(@"incoming connection", "Inspector -> Peers tab -> table row tooltip");
else if (from == TR_PEER_FROM_CACHE)
fromString = NSLocalizedString(@"cache", "Inspector -> Peers tab -> table row tooltip");
else if (from == TR_PEER_FROM_PEX)
fromString = NSLocalizedString(@"peer exchange", "Inspector -> Peers tab -> table row tooltip");
NSMutableArray * components = [NSMutableArray arrayWithCapacity: 3];
if ([[peer objectForKey: @"Connected"] boolValue])
[components addObject: [NSString stringWithFormat:
NSLocalizedString(@"Progress: %.1f%%", "Inspector -> Peers tab -> table row tooltip"),
[[peer objectForKey: @"Progress"] floatValue] * 100.0]];
int port;
if ((port = [[peer objectForKey: @"Port"] intValue]) > 0)
[components addObject: [NSString stringWithFormat:
NSLocalizedString(@"Port: %d", "Inspector -> Peers tab -> table row tooltip"), port]];
else
fromString = NSLocalizedString(@"tracker", "Inspector -> Peers tab -> table row tooltip");
[components addObject: NSLocalizedString(@"Port: N/A", "Inspector -> Peers tab -> table row tooltip")];
return [NSString stringWithFormat: NSLocalizedString(@"Progress: %.1f%%"
"\nPort: %@"
"\nFrom: %@", "Inspector -> Peers tab -> table row tooltip"),
[[peerDic objectForKey: @"Progress"] floatValue] * 100.0,
[peerDic objectForKey: @"Port"], fromString];
int from = [[peer objectForKey: @"From"] intValue];
if (from == TR_PEER_FROM_INCOMING)
[components addObject: NSLocalizedString(@"From: incoming connection", "Inspector -> Peers tab -> table row tooltip")];
else if (from == TR_PEER_FROM_CACHE)
[components addObject: NSLocalizedString(@"From: cache", "Inspector -> Peers tab -> table row tooltip")];
else if (from == TR_PEER_FROM_PEX)
[components addObject: NSLocalizedString(@"From: peer exchange", "Inspector -> Peers tab -> table row tooltip")];
else
[components addObject: NSLocalizedString(@"From: tracker", "Inspector -> Peers tab -> table row tooltip")];
return [components componentsJoinedByString: @"\n"];
}
return nil;
}

View File

@ -996,15 +996,20 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[NSNumber numberWithInt: peer->from], @"From",
[NSString stringWithCString: (char *) peer->addr encoding: NSUTF8StringEncoding], @"IP",
[NSString stringWithCString: (char *) peer->client encoding: NSUTF8StringEncoding], @"Client",
[NSNumber numberWithFloat: peer->progress], @"Progress",
[NSNumber numberWithBool: peer->isDownloading], @"UL To",
[NSNumber numberWithBool: peer->isUploading], @"DL From",
[NSNumber numberWithInt: peer->port], @"Port", nil];
if (peer->isDownloading)
[dic setObject: [NSNumber numberWithFloat: peer->uploadToRate] forKey: @"UL To Rate"];
if (peer->isUploading)
[dic setObject: [NSNumber numberWithFloat: peer->downloadFromRate] forKey: @"DL From Rate"];
if (peer->isConnected)
{
[dic setObject: [NSNumber numberWithFloat: peer->progress] forKey: @"Progress"];
[dic setObject: [NSNumber numberWithBool: peer->isDownloading] forKey: @"UL To"];
if (peer->isDownloading)
[dic setObject: [NSNumber numberWithFloat: peer->uploadToRate] forKey: @"UL To Rate"];
[dic setObject: [NSNumber numberWithBool: peer->isUploading] forKey: @"DL From"];
if (peer->isUploading)
[dic setObject: [NSNumber numberWithFloat: peer->downloadFromRate] forKey: @"DL From Rate"];
}
[peerDics addObject: dic];
}