mirror of
https://github.com/transmission/transmission
synced 2024-12-26 01:27:28 +00:00
have the info controller format the peer status string, for efficiency sakes
This commit is contained in:
parent
243d4cfcba
commit
c83f25fed5
2 changed files with 20 additions and 30 deletions
|
@ -800,7 +800,25 @@ typedef enum
|
||||||
return (rate = [peer objectForKey: @"DL From Rate"]) ? [NSString stringForSpeedAbbrev: [rate floatValue]] : @"";
|
return (rate = [peer objectForKey: @"DL From Rate"]) ? [NSString stringForSpeedAbbrev: [rate floatValue]] : @"";
|
||||||
}
|
}
|
||||||
else if ([ident isEqualToString: @"Status"])
|
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
|
else
|
||||||
return [peer objectForKey: @"IP"];
|
return [peer objectForKey: @"IP"];
|
||||||
}
|
}
|
||||||
|
|
|
@ -808,34 +808,6 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
||||||
{
|
{
|
||||||
peer = &peers[i];
|
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:
|
dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithInt: peer->from], @"From",
|
[NSNumber numberWithInt: peer->from], @"From",
|
||||||
[NSString stringWithCString: (char *)peer->addr encoding: NSUTF8StringEncoding], @"IP",
|
[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 numberWithFloat: peer->progress], @"Progress",
|
||||||
[NSNumber numberWithBool: peer->isEncrypted], @"Encryption",
|
[NSNumber numberWithBool: peer->isEncrypted], @"Encryption",
|
||||||
[NSString stringWithCString: (char *)peer->client encoding: NSUTF8StringEncoding], @"Client",
|
[NSString stringWithCString: (char *)peer->client encoding: NSUTF8StringEncoding], @"Client",
|
||||||
statusString, @"Status", nil];
|
[NSNumber numberWithInt: peer->status], @"Status", nil];
|
||||||
|
|
||||||
if (peer->isDownloading)
|
if (peer->isDownloading)
|
||||||
[dic setObject: [NSNumber numberWithFloat: peer->uploadToRate] forKey: @"UL To Rate"];
|
[dic setObject: [NSNumber numberWithFloat: peer->uploadToRate] forKey: @"UL To Rate"];
|
||||||
|
|
Loading…
Reference in a new issue