Changeset 1256


Ignore:
Timestamp:
Dec 18, 2006, 6:25:40 AM (15 years ago)
Author:
livings124
Message:

display actual upload/download rate in inspector for individual peers

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.h

    r1242 r1256  
    3232    NSArray * fTorrents;
    3333    NSMutableArray * fPeers, * fFiles;
    34     NSImage * fAppIcon, * fDotGreen, * fDotRed, * fCheckImage;
     34    NSImage * fAppIcon, * fDotGreen, * fDotRed;
    3535   
    3636    IBOutlet NSTabView * fTabView;
  • trunk/macosx/InfoWindowController.m

    r1250 r1256  
    6868        fDotGreen = [NSImage imageNamed: @"GreenDot.tiff"];
    6969        fDotRed = [NSImage imageNamed: @"RedDot.tiff"];
    70         fCheckImage = [NSImage imageNamed: @"NSMenuCheckmark"];   
    7170    }
    7271    return self;
     
    541540            return [peer objectForKey: @"Progress"];
    542541        else if ([ident isEqualToString: @"UL To"])
    543             return [[peer objectForKey: @"UL To"] boolValue] ? fCheckImage : nil;
     542            return [[peer objectForKey: @"UL To"] boolValue]
     543                    ? [NSString stringForSpeedAbbrev: [[peer objectForKey: @"UL To Rate"] floatValue]] : @"";
    544544        else if ([ident isEqualToString: @"DL From"])
    545             return [[peer objectForKey: @"DL From"] boolValue] ? fCheckImage : nil;
     545            return [[peer objectForKey: @"DL From"] boolValue]
     546                    ? [NSString stringForSpeedAbbrev: [[peer objectForKey: @"DL From Rate"] floatValue]] : @"";
    546547        else
    547548            return [peer objectForKey: @"IP"];
  • trunk/macosx/Torrent.m

    r1250 r1256  
    840840   
    841841    NSMutableArray * peerDics = [NSMutableArray arrayWithCapacity: totalPeers];
    842     tr_peer_stat_t peer;
     842    NSMutableDictionary * dic;
     843   
     844    tr_peer_stat_t * peer;
    843845    NSString * client;
    844846    for (i = 0; i < totalPeers; i++)
    845847    {
    846         peer = peers[i];
    847         [peerDics addObject: [NSDictionary dictionaryWithObjectsAndKeys:
    848             [NSNumber numberWithBool: peer.isConnected], @"Connected",
    849             [NSNumber numberWithBool: peer.isIncoming], @"Incoming",
    850             [NSString stringWithCString: (char *) peer.addr encoding: NSUTF8StringEncoding], @"IP",
    851             [NSString stringWithCString: (char *) peer.client encoding: NSUTF8StringEncoding], @"Client",
    852             [NSNumber numberWithFloat: peer.progress], @"Progress",
    853             [NSNumber numberWithBool: peer.isDownloading], @"UL To",
    854             [NSNumber numberWithBool: peer.isUploading], @"DL From",
    855             [NSNumber numberWithInt: peer.port], @"Port", nil]];
     848        peer = &peers[i];
     849       
     850        dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:
     851            [NSNumber numberWithBool: peer->isConnected], @"Connected",
     852            [NSNumber numberWithBool: peer->isIncoming], @"Incoming",
     853            [NSString stringWithCString: (char *) peer->addr encoding: NSUTF8StringEncoding], @"IP",
     854            [NSString stringWithCString: (char *) peer->client encoding: NSUTF8StringEncoding], @"Client",
     855            [NSNumber numberWithFloat: peer->progress], @"Progress",
     856            [NSNumber numberWithBool: peer->isDownloading], @"UL To",
     857            [NSNumber numberWithBool: peer->isUploading], @"DL From",
     858            [NSNumber numberWithInt: peer->port], @"Port", nil];
     859       
     860        if (peer->isDownloading)
     861            [dic setObject: [NSNumber numberWithFloat: peer->uploadToRate] forKey: @"UL To Rate"];
     862        if (peer->isUploading)
     863            [dic setObject: [NSNumber numberWithFloat: peer->downloadFromRate] forKey: @"DL From Rate"];
     864       
     865        [peerDics addObject: dic];
    856866    }
    857867   
Note: See TracChangeset for help on using the changeset viewer.