Ignore:
Timestamp:
Mar 23, 2007, 8:28:01 AM (15 years ago)
Author:
joshe
Message:

Merge PEX branch, I hope this works.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r1577 r1579  
    4040#define TAB_INFO_HEIGHT 284.0
    4141#define TAB_ACTIVITY_HEIGHT 170.0
    42 #define TAB_PEERS_HEIGHT 268.0
    43 #define TAB_FILES_HEIGHT 268.0
     42#define TAB_PEERS_HEIGHT 279.0
     43#define TAB_FILES_HEIGHT 279.0
    4444#define TAB_OPTIONS_HEIGHT 117.0
    4545
     
    196196        [fLeechersField setStringValue: @""];
    197197        [fCompletedFromTrackerField setStringValue: @""];
    198         [fConnectedPeersField setStringValue: @""];
     198        [fConnectedPeersField setStringValue: NSLocalizedString(@"info not available", "Inspector -> Peers tab -> peers")];
    199199        [fDownloadingFromField setStringValue: @""];
    200200        [fUploadingToField setStringValue: @""];
     
    237237        [fHashField setToolTip: hashString];
    238238        [fSecureField setStringValue: [torrent privateTorrent]
    239                         ? NSLocalizedString(@"Private Torrent", "Inspector -> is private torrent")
     239                        ? NSLocalizedString(@"Private Torrent, PEX disabled", "Inspector -> is private torrent")
    240240                        : NSLocalizedString(@"Public Torrent", "Inspector -> is not private torrent")];
    241241        [fCommentView setString: commentString];
     
    382382   
    383383    BOOL active = [torrent isActive];
    384     [fConnectedPeersField setStringValue: active ? [NSString stringWithFormat: NSLocalizedString(@"%d (%d incoming)",
    385                                                                                 "Inspector -> Peers tab -> connected"),
    386                                                     [torrent totalPeers], [torrent totalPeersIncoming]]: @""];
     384   
     385    if (active)
     386    {
     387        int total = [torrent totalPeers];
     388        NSString * connected = [NSString stringWithFormat:
     389                                NSLocalizedString(@"%d Connected", "Inspector -> Peers tab -> peers"), total];
     390       
     391        if (total > 0)
     392        {
     393            NSMutableArray * components = [NSMutableArray arrayWithCapacity: 4];
     394            int count;
     395            if ((count = [torrent totalPeersTracker]) > 0)
     396                [components addObject: [NSString stringWithFormat:
     397                                        NSLocalizedString(@"%d tracker", "Inspector -> Peers tab -> peers"), count]];
     398            if ((count = [torrent totalPeersIncoming]) > 0)
     399                [components addObject: [NSString stringWithFormat:
     400                                        NSLocalizedString(@"%d incoming", "Inspector -> Peers tab -> peers"), count]];
     401            if ((count = [torrent totalPeersPex]) > 0)
     402                [components addObject: [NSString stringWithFormat:
     403                                        NSLocalizedString(@"%d PEX", "Inspector -> Peers tab -> peers"), count]];
     404            if ((count = [torrent totalPeersCache]) > 0)
     405                [components addObject: [NSString stringWithFormat:
     406                                        NSLocalizedString(@"%d cache", "Inspector -> Peers tab -> peers"), count]];
     407           
     408            connected = [NSString stringWithFormat: @"%@: %@", connected, [components componentsJoinedByString: @", "]];
     409        }
     410       
     411        [fConnectedPeersField setStringValue: connected];
     412    }
     413    else
     414        [fConnectedPeersField setStringValue: NSLocalizedString(@"info not available", "Inspector -> Peers tab -> peers")];
     415   
    387416    [fDownloadingFromField setStringValue: active ? [NSString stringWithInt: [torrent peersUploading]] : @""];
    388417    [fUploadingToField setStringValue: active ? [NSString stringWithInt: [torrent peersDownloading]] : @""];
     
    666695    {
    667696        NSDictionary * peerDic = [fPeers objectAtIndex: row];
     697       
     698        NSString * fromString;
     699        int from = [[peerDic objectForKey: @"From"] intValue];
     700        if (from == TR_PEER_FROM_INCOMING)
     701            fromString = NSLocalizedString(@"incoming connection", "Inspector -> Peers tab -> table row tooltip");
     702        else if (from == TR_PEER_FROM_CACHE)
     703            fromString = NSLocalizedString(@"cache", "Inspector -> Peers tab -> table row tooltip");
     704        else if (from == TR_PEER_FROM_PEX)
     705            fromString = NSLocalizedString(@"peer exchange", "Inspector -> Peers tab -> table row tooltip");
     706        else
     707            fromString = NSLocalizedString(@"tracker", "Inspector -> Peers tab -> table row tooltip");
     708       
    668709        return [NSString stringWithFormat: NSLocalizedString(@"Progress: %.1f%%"
    669710                    "\nPort: %@"
    670                     "\nFrom %@ connection", "Inspector -> Peers tab -> table row tooltip"),
     711                    "\nFrom: %@", "Inspector -> Peers tab -> table row tooltip"),
    671712                    [[peerDic objectForKey: @"Progress"] floatValue] * 100.0,
    672                     [peerDic objectForKey: @"Port"],
    673                     [[peerDic objectForKey: @"Incoming"] boolValue]
    674                         ? NSLocalizedString(@"incoming", "Inspector -> Peers tab -> table row tooltip")
    675                         : NSLocalizedString(@"outgoing", "Inspector -> Peers tab -> table row tooltip")];
     713                    [peerDic objectForKey: @"Port"], fromString];
    676714    }
    677715    return nil;
Note: See TracChangeset for help on using the changeset viewer.