2009-09-28 01:57:35 +00:00
|
|
|
/******************************************************************************
|
2012-01-14 17:12:04 +00:00
|
|
|
* Copyright (c) 2009-2012 Transmission authors and contributors
|
2009-09-28 01:57:35 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-09-30 10:37:30 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
|
|
|
#include <libtransmission/utils.h> //tr_addressIsIP()
|
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
#import "TrackerCell.h"
|
|
|
|
#import "TrackerNode.h"
|
2010-04-23 16:59:14 +00:00
|
|
|
|
2009-09-28 03:42:35 +00:00
|
|
|
#define PADDING_HORIZONAL 3.0
|
|
|
|
#define PADDING_STATUS_HORIZONAL 3.0
|
2010-01-31 22:33:00 +00:00
|
|
|
#define ICON_SIZE 16.0
|
2009-09-28 03:42:35 +00:00
|
|
|
#define PADDING_BETWEEN_ICON_AND_NAME 4.0
|
|
|
|
#define PADDING_ABOVE_ICON 1.0
|
2010-01-31 22:33:00 +00:00
|
|
|
#define PADDING_ABOVE_NAME 1.0
|
2009-09-28 01:57:35 +00:00
|
|
|
#define PADDING_BETWEEN_LINES 1.0
|
2009-09-28 17:42:24 +00:00
|
|
|
#define PADDING_BETWEEN_LINES_ON_SAME_LINE 4.0
|
2009-09-28 15:49:02 +00:00
|
|
|
#define COUNT_WIDTH 40.0
|
2009-09-28 01:57:35 +00:00
|
|
|
|
|
|
|
@interface TrackerCell (Private)
|
|
|
|
|
|
|
|
- (NSImage *) favIcon;
|
2009-09-28 03:42:35 +00:00
|
|
|
- (void) loadTrackerIcon: (NSString *) baseAddress;
|
2009-09-28 01:57:35 +00:00
|
|
|
|
|
|
|
- (NSRect) imageRectForBounds: (NSRect) bounds;
|
|
|
|
- (NSRect) rectForNameWithString: (NSAttributedString *) string inBounds: (NSRect) bounds;
|
2009-09-28 15:49:02 +00:00
|
|
|
- (NSRect) rectForCountWithString: (NSAttributedString *) string withAboveRect: (NSRect) aboveRect inBounds: (NSRect) bounds;
|
|
|
|
- (NSRect) rectForCountLabelWithString: (NSAttributedString *) string withRightRect: (NSRect) rightRect inBounds: (NSRect) bounds;
|
2009-09-28 14:42:00 +00:00
|
|
|
- (NSRect) rectForStatusWithString: (NSAttributedString *) string withAboveRect: (NSRect) aboveRect withRightRect: (NSRect) rightRect
|
|
|
|
inBounds: (NSRect) bounds;
|
2009-09-28 01:57:35 +00:00
|
|
|
|
2009-09-28 17:42:24 +00:00
|
|
|
- (NSAttributedString *) attributedName;
|
|
|
|
- (NSAttributedString *) attributedStatusWithString: (NSString *) statusString;
|
|
|
|
- (NSAttributedString *) attributedCount: (NSInteger) count;
|
2009-09-28 01:57:35 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation TrackerCell
|
|
|
|
|
2009-09-28 03:42:35 +00:00
|
|
|
//make the favicons accessible to all tracker cells
|
2011-10-06 00:30:40 +00:00
|
|
|
NSCache * fTrackerIconCache;
|
2009-09-28 03:42:35 +00:00
|
|
|
NSMutableSet * fTrackerIconLoading;
|
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
2011-10-18 02:30:22 +00:00
|
|
|
fTrackerIconCache = [[NSCache alloc] init];
|
2009-09-28 03:42:35 +00:00
|
|
|
fTrackerIconLoading = [[NSMutableSet alloc] init];
|
|
|
|
}
|
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
|
|
|
[paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
fNameAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
2010-01-31 22:33:00 +00:00
|
|
|
[NSFont messageFontOfSize: 12.0], NSFontAttributeName,
|
2009-09-28 01:57:35 +00:00
|
|
|
paragraphStyle, NSParagraphStyleAttributeName, nil];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
fStatusAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
|
|
|
[NSFont messageFontOfSize: 9.0], NSFontAttributeName,
|
|
|
|
paragraphStyle, NSParagraphStyleAttributeName, nil];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2012-03-13 02:52:11 +00:00
|
|
|
|
|
|
|
- (id) copyWithZone: (NSZone *) zone
|
|
|
|
{
|
|
|
|
TrackerCell * copy = [super copyWithZone: zone];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2017-07-29 16:14:22 +00:00
|
|
|
copy->fNameAttributes = fNameAttributes;
|
|
|
|
copy->fStatusAttributes = fStatusAttributes;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-03-13 02:52:11 +00:00
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
|
|
|
|
{
|
|
|
|
//icon
|
2011-10-06 00:30:40 +00:00
|
|
|
[[self favIcon] drawInRect: [self imageRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0 respectFlipped: YES hints: nil];
|
2009-09-28 03:42:35 +00:00
|
|
|
|
2009-09-28 17:42:24 +00:00
|
|
|
//set table colors
|
2009-09-28 01:57:35 +00:00
|
|
|
NSColor * nameColor, * statusColor;
|
|
|
|
if ([self backgroundStyle] == NSBackgroundStyleDark)
|
|
|
|
nameColor = statusColor = [NSColor whiteColor];
|
|
|
|
else
|
|
|
|
{
|
2018-12-21 21:39:47 +00:00
|
|
|
nameColor = [NSColor labelColor];
|
|
|
|
statusColor = [NSColor secondaryLabelColor];
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2017-07-08 14:38:47 +00:00
|
|
|
fNameAttributes[NSForegroundColorAttributeName] = nameColor;
|
|
|
|
fStatusAttributes[NSForegroundColorAttributeName] = statusColor;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 14:42:00 +00:00
|
|
|
TrackerNode * node = (TrackerNode *)[self objectValue];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
//name
|
2009-09-28 17:42:24 +00:00
|
|
|
NSAttributedString * nameString = [self attributedName];
|
2009-09-28 13:53:17 +00:00
|
|
|
const NSRect nameRect = [self rectForNameWithString: nameString inBounds: cellFrame];
|
2009-09-28 01:57:35 +00:00
|
|
|
[nameString drawInRect: nameRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 14:42:00 +00:00
|
|
|
//count strings
|
2009-09-28 17:42:24 +00:00
|
|
|
NSAttributedString * seederString = [self attributedCount: [node totalSeeders]];
|
2009-09-28 14:42:00 +00:00
|
|
|
const NSRect seederRect = [self rectForCountWithString: seederString withAboveRect: nameRect inBounds: cellFrame];
|
|
|
|
[seederString drawInRect: seederRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 17:42:24 +00:00
|
|
|
NSAttributedString * leecherString = [self attributedCount: [node totalLeechers]];
|
2009-09-28 14:42:00 +00:00
|
|
|
const NSRect leecherRect = [self rectForCountWithString: leecherString withAboveRect: seederRect inBounds: cellFrame];
|
|
|
|
[leecherString drawInRect: leecherRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 17:42:24 +00:00
|
|
|
NSAttributedString * downloadedString = [self attributedCount: [node totalDownloaded]];
|
2009-09-28 14:42:00 +00:00
|
|
|
const NSRect downloadedRect = [self rectForCountWithString: downloadedString withAboveRect: leecherRect inBounds: cellFrame];
|
|
|
|
[downloadedString drawInRect: downloadedRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 15:49:02 +00:00
|
|
|
//count label strings
|
|
|
|
NSString * seederLabelBaseString = [NSLocalizedString(@"Seeders", "tracker peer stat") stringByAppendingFormat: @": "];
|
2009-09-28 17:42:24 +00:00
|
|
|
NSAttributedString * seederLabelString = [self attributedStatusWithString: seederLabelBaseString];
|
2009-09-28 15:49:02 +00:00
|
|
|
const NSRect seederLabelRect = [self rectForCountLabelWithString: seederLabelString withRightRect: seederRect
|
|
|
|
inBounds: cellFrame];
|
|
|
|
[seederLabelString drawInRect: seederLabelRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 15:49:02 +00:00
|
|
|
NSString * leecherLabelBaseString = [NSLocalizedString(@"Leechers", "tracker peer stat") stringByAppendingFormat: @": "];
|
2009-09-28 17:42:24 +00:00
|
|
|
NSAttributedString * leecherLabelString = [self attributedStatusWithString: leecherLabelBaseString];
|
2009-09-28 15:49:02 +00:00
|
|
|
const NSRect leecherLabelRect = [self rectForCountLabelWithString: leecherLabelString withRightRect: leecherRect
|
|
|
|
inBounds: cellFrame];
|
|
|
|
[leecherLabelString drawInRect: leecherLabelRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 15:49:02 +00:00
|
|
|
NSString * downloadedLabelBaseString = [NSLocalizedString(@"Downloaded", "tracker peer stat") stringByAppendingFormat: @": "];
|
2009-09-28 17:42:24 +00:00
|
|
|
NSAttributedString * downloadedLabelString = [self attributedStatusWithString: downloadedLabelBaseString];
|
2009-09-28 15:49:02 +00:00
|
|
|
const NSRect downloadedLabelRect = [self rectForCountLabelWithString: downloadedLabelString withRightRect: downloadedRect
|
|
|
|
inBounds: cellFrame];
|
|
|
|
[downloadedLabelString drawInRect: downloadedLabelRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 14:42:00 +00:00
|
|
|
//status strings
|
2009-09-28 17:42:24 +00:00
|
|
|
NSAttributedString * lastAnnounceString = [self attributedStatusWithString: [node lastAnnounceStatusString]];
|
2009-09-28 15:49:02 +00:00
|
|
|
const NSRect lastAnnounceRect = [self rectForStatusWithString: lastAnnounceString withAboveRect: nameRect
|
|
|
|
withRightRect: seederLabelRect inBounds: cellFrame];
|
2009-09-28 01:57:35 +00:00
|
|
|
[lastAnnounceString drawInRect: lastAnnounceRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 17:42:24 +00:00
|
|
|
NSAttributedString * nextAnnounceString = [self attributedStatusWithString: [node nextAnnounceStatusString]];
|
2009-09-28 13:53:17 +00:00
|
|
|
const NSRect nextAnnounceRect = [self rectForStatusWithString: nextAnnounceString withAboveRect: lastAnnounceRect
|
2009-09-28 15:49:02 +00:00
|
|
|
withRightRect: leecherLabelRect inBounds: cellFrame];
|
2009-09-28 01:57:35 +00:00
|
|
|
[nextAnnounceString drawInRect: nextAnnounceRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 17:42:24 +00:00
|
|
|
NSAttributedString * lastScrapeString = [self attributedStatusWithString: [node lastScrapeStatusString]];
|
2009-09-28 14:42:00 +00:00
|
|
|
const NSRect lastScrapeRect = [self rectForStatusWithString: lastScrapeString withAboveRect: nextAnnounceRect
|
2009-09-28 15:49:02 +00:00
|
|
|
withRightRect: downloadedLabelRect inBounds: cellFrame];
|
2009-09-28 01:57:35 +00:00
|
|
|
[lastScrapeString drawInRect: lastScrapeRect];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation TrackerCell (Private)
|
|
|
|
|
|
|
|
- (NSImage *) favIcon
|
|
|
|
{
|
2011-04-07 23:29:05 +00:00
|
|
|
id icon = nil;
|
2009-12-13 22:47:25 +00:00
|
|
|
NSURL * address = [NSURL URLWithString: [(TrackerNode *)[self objectValue] fullAnnounceAddress]];
|
2011-04-07 23:29:05 +00:00
|
|
|
NSString * host;
|
|
|
|
if ((host = [address host]))
|
2009-09-28 03:42:35 +00:00
|
|
|
{
|
2011-04-07 23:29:05 +00:00
|
|
|
//don't try to parse ip address
|
|
|
|
const BOOL separable = !tr_addressIsIP([host UTF8String]);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2011-04-07 23:29:05 +00:00
|
|
|
NSArray * hostComponents = separable ? [host componentsSeparatedByString: @"."] : nil;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2011-04-07 23:29:05 +00:00
|
|
|
//let's try getting the tracker address without using any subdomains
|
|
|
|
NSString * baseAddress;
|
|
|
|
if (separable && [hostComponents count] > 1)
|
|
|
|
baseAddress = [NSString stringWithFormat: @"http://%@.%@",
|
2017-07-08 09:16:01 +00:00
|
|
|
hostComponents[[hostComponents count]-2], [hostComponents lastObject]];
|
2011-04-07 23:29:05 +00:00
|
|
|
else
|
|
|
|
baseAddress = [NSString stringWithFormat: @"http://%@", host];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2011-04-07 23:29:05 +00:00
|
|
|
icon = [fTrackerIconCache objectForKey: baseAddress];
|
2020-01-03 05:12:59 +00:00
|
|
|
if (!icon)
|
|
|
|
[self loadTrackerIcon: baseAddress];
|
2009-09-28 03:42:35 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2012-06-10 02:35:58 +00:00
|
|
|
return (icon && icon != [NSNull null]) ? icon : [NSImage imageNamed: @"FavIcon"];
|
2009-09-28 03:42:35 +00:00
|
|
|
}
|
|
|
|
|
2011-04-17 20:01:46 +00:00
|
|
|
#warning better favicon detection
|
2009-09-28 03:42:35 +00:00
|
|
|
- (void) loadTrackerIcon: (NSString *) baseAddress
|
|
|
|
{
|
2020-01-03 05:12:59 +00:00
|
|
|
if ([fTrackerIconLoading containsObject: baseAddress]) {
|
|
|
|
return;
|
2009-09-28 03:42:35 +00:00
|
|
|
}
|
2020-01-03 05:12:59 +00:00
|
|
|
[fTrackerIconLoading addObject: baseAddress];
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
NSImage *icon = nil;
|
|
|
|
|
|
|
|
NSArray<NSString *> *filenamesToTry = @[ @"favicon.png", @"favicon.ico" ];
|
|
|
|
for (NSString *filename in filenamesToTry) {
|
|
|
|
NSURL * favIconUrl = [NSURL URLWithString: [baseAddress stringByAppendingPathComponent:filename]];
|
|
|
|
|
|
|
|
NSURLRequest * request = [NSURLRequest requestWithURL: favIconUrl cachePolicy: NSURLRequestUseProtocolCachePolicy
|
|
|
|
timeoutInterval: 30.0];
|
|
|
|
|
|
|
|
NSData * iconData = [NSURLConnection sendSynchronousRequest: request returningResponse: NULL error: NULL];
|
|
|
|
if (iconData) {
|
|
|
|
icon = [[NSImage alloc] initWithData: iconData];
|
|
|
|
if (icon) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
if (icon)
|
|
|
|
{
|
|
|
|
[fTrackerIconCache setObject: icon forKey: baseAddress];
|
|
|
|
|
|
|
|
[[self controlView] setNeedsDisplay: YES];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[fTrackerIconCache setObject: [NSNull null] forKey: baseAddress];
|
|
|
|
|
|
|
|
[fTrackerIconLoading removeObject: baseAddress];
|
|
|
|
});
|
|
|
|
});
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect) imageRectForBounds: (NSRect) bounds
|
|
|
|
{
|
2009-12-28 20:05:33 +00:00
|
|
|
return NSMakeRect(NSMinX(bounds) + PADDING_HORIZONAL, NSMinY(bounds) + PADDING_ABOVE_ICON, ICON_SIZE, ICON_SIZE);
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect) rectForNameWithString: (NSAttributedString *) string inBounds: (NSRect) bounds
|
|
|
|
{
|
2009-12-28 20:05:33 +00:00
|
|
|
NSRect result;
|
|
|
|
result.origin.x = NSMinX(bounds) + PADDING_HORIZONAL + ICON_SIZE + PADDING_BETWEEN_ICON_AND_NAME;
|
|
|
|
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_NAME;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-12-28 20:05:33 +00:00
|
|
|
result.size.height = [string size].height;
|
|
|
|
result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONAL;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-09-28 15:49:02 +00:00
|
|
|
- (NSRect) rectForCountWithString: (NSAttributedString *) string withAboveRect: (NSRect) aboveRect inBounds: (NSRect) bounds
|
2009-09-28 14:42:00 +00:00
|
|
|
{
|
|
|
|
return NSMakeRect(NSMaxX(bounds) - PADDING_HORIZONAL - COUNT_WIDTH,
|
2009-09-28 15:49:02 +00:00
|
|
|
NSMaxY(aboveRect) + PADDING_BETWEEN_LINES,
|
2009-09-28 14:42:00 +00:00
|
|
|
COUNT_WIDTH, [string size].height);
|
|
|
|
}
|
|
|
|
|
2009-09-28 15:49:02 +00:00
|
|
|
- (NSRect) rectForCountLabelWithString: (NSAttributedString *) string withRightRect: (NSRect) rightRect inBounds: (NSRect) bounds
|
|
|
|
{
|
|
|
|
NSRect result = rightRect;
|
|
|
|
result.size.width = [string size].width;
|
2009-12-28 20:05:33 +00:00
|
|
|
result.origin.x -= NSWidth(result);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 15:49:02 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-09-28 14:42:00 +00:00
|
|
|
- (NSRect) rectForStatusWithString: (NSAttributedString *) string withAboveRect: (NSRect) aboveRect withRightRect: (NSRect) rightRect
|
|
|
|
inBounds: (NSRect) bounds
|
2009-09-28 01:57:35 +00:00
|
|
|
{
|
2009-12-28 20:05:33 +00:00
|
|
|
NSRect result;
|
|
|
|
result.origin.x = NSMinX(bounds) + PADDING_STATUS_HORIZONAL;
|
2009-09-28 14:42:00 +00:00
|
|
|
result.origin.y = NSMaxY(aboveRect) + PADDING_BETWEEN_LINES;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-12-28 20:05:33 +00:00
|
|
|
result.size.height = [string size].height;
|
|
|
|
result.size.width = NSMinX(rightRect) - PADDING_BETWEEN_LINES_ON_SAME_LINE - NSMinX(result);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-09-28 17:42:24 +00:00
|
|
|
- (NSAttributedString *) attributedName
|
2009-09-28 01:57:35 +00:00
|
|
|
{
|
|
|
|
NSString * name = [(TrackerNode *)[self objectValue] host];
|
2017-07-29 16:14:22 +00:00
|
|
|
return [[NSAttributedString alloc] initWithString: name attributes: fNameAttributes];
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
2009-09-28 17:42:24 +00:00
|
|
|
- (NSAttributedString *) attributedStatusWithString: (NSString *) statusString
|
2009-09-28 01:57:35 +00:00
|
|
|
{
|
2017-07-29 16:14:22 +00:00
|
|
|
return [[NSAttributedString alloc] initWithString: statusString attributes: fStatusAttributes];
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
2009-09-28 17:42:24 +00:00
|
|
|
- (NSAttributedString *) attributedCount: (NSInteger) count
|
2009-09-28 15:59:17 +00:00
|
|
|
{
|
2012-08-13 00:52:04 +00:00
|
|
|
NSString * countString = count != -1 ? [NSString stringWithFormat: @"%ld", count] : NSLocalizedString(@"N/A", "tracker peer stat");
|
2017-07-29 16:14:22 +00:00
|
|
|
return [[NSAttributedString alloc] initWithString: countString attributes: fStatusAttributes];
|
2009-09-28 15:59:17 +00:00
|
|
|
}
|
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
@end
|