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

have the info controller format the peer status string, for efficiency sakes

This commit is contained in:
Mitchell Livingston 2007-11-18 00:28:37 +00:00
parent 243d4cfcba
commit c83f25fed5
2 changed files with 20 additions and 30 deletions

View file

@ -800,7 +800,25 @@ typedef enum
return (rate = [peer objectForKey: @"DL From Rate"]) ? [NSString stringForSpeedAbbrev: [rate floatValue]] : @"";
}
else if ([ident isEqualToString: @"Status"])
return [peer objectForKey: @"Status"];
{
switch ([[peer objectForKey: @"Status"] intValue])
{
case TR_PEER_STATUS_HANDSHAKE:
return NSLocalizedString(@"Handshaking", "peer -> status");
case TR_PEER_STATUS_PEER_IS_CHOKED:
return NSLocalizedString(@"Peer is Choked", "peer -> status");
case TR_PEER_STATUS_CLIENT_IS_CHOKED:
return NSLocalizedString(@"Choked", "peer -> status");
case TR_PEER_STATUS_CLIENT_IS_INTERESTED:
return NSLocalizedString(@"Choked and Interested", "peer -> status");
case TR_PEER_STATUS_READY:
return NSLocalizedString(@"Ready", "peer -> status");
case TR_PEER_STATUS_REQUEST_SENT:
return NSLocalizedString(@"Request Sent", "peer -> status");
case TR_PEER_STATUS_ACTIVE:
return NSLocalizedString(@"Active", "peer -> status");
}
}
else
return [peer objectForKey: @"IP"];
}

View file

@ -808,34 +808,6 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
{
peer = &peers[i];
NSString * statusString;
switch (peer->status)
{
case TR_PEER_STATUS_HANDSHAKE:
statusString = NSLocalizedString(@"Handshaking", "peer -> status");
break;
case TR_PEER_STATUS_PEER_IS_CHOKED:
statusString = NSLocalizedString(@"Peer is Choked", "peer -> status");
break;
case TR_PEER_STATUS_CLIENT_IS_CHOKED:
statusString = NSLocalizedString(@"Choked", "peer -> status");
break;
case TR_PEER_STATUS_CLIENT_IS_INTERESTED:
statusString = NSLocalizedString(@"Choked and Interested", "peer -> status");
break;
case TR_PEER_STATUS_READY:
statusString = NSLocalizedString(@"Ready", "peer -> status");
break;
case TR_PEER_STATUS_REQUEST_SENT:
statusString = NSLocalizedString(@"Request Sent", "peer -> status");
break;
case TR_PEER_STATUS_ACTIVE:
statusString = NSLocalizedString(@"Active", "peer -> status");
break;
default:
statusString = @"";
}
dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt: peer->from], @"From",
[NSString stringWithCString: (char *)peer->addr encoding: NSUTF8StringEncoding], @"IP",
@ -843,7 +815,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
[NSNumber numberWithFloat: peer->progress], @"Progress",
[NSNumber numberWithBool: peer->isEncrypted], @"Encryption",
[NSString stringWithCString: (char *)peer->client encoding: NSUTF8StringEncoding], @"Client",
statusString, @"Status", nil];
[NSNumber numberWithInt: peer->status], @"Status", nil];
if (peer->isDownloading)
[dic setObject: [NSNumber numberWithFloat: peer->uploadToRate] forKey: @"UL To Rate"];