2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2009-2022 Transmission authors and contributors.
|
|
|
|
// It may be used under the MIT (SPDX: MIT) license.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2009-09-28 01:57:35 +00:00
|
|
|
|
2018-09-30 10:37:30 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
2021-11-09 03:30:03 +00:00
|
|
|
#include <libtransmission/web-utils.h> //tr_addressIsIP()
|
2018-09-30 10:37:30 +00:00
|
|
|
|
2022-04-24 20:34:30 +00:00
|
|
|
#import "CocoaCompatibility.h"
|
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
#import "TrackerCell.h"
|
|
|
|
#import "TrackerNode.h"
|
2010-04-23 16:59:14 +00:00
|
|
|
|
2022-04-21 14:28:38 +00:00
|
|
|
#define PADDING_HORIZONTAL 3.0
|
|
|
|
#define PADDING_STATUS_HORIZONTAL 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
|
2022-07-17 23:04:32 +00:00
|
|
|
#define COUNT_WIDTH 60.0
|
2009-09-28 01:57:35 +00:00
|
|
|
|
2022-01-24 01:32:45 +00:00
|
|
|
@interface TrackerCell ()
|
2009-09-28 01:57:35 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
@property(nonatomic, readonly) NSImage* favIcon;
|
2022-02-22 16:04:20 +00:00
|
|
|
@property(nonatomic, readonly) NSAttributedString* attributedName;
|
|
|
|
@property(nonatomic, readonly) NSMutableDictionary* fNameAttributes;
|
|
|
|
@property(nonatomic, readonly) NSMutableDictionary* fStatusAttributes;
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)loadTrackerIcon:(NSString*)baseAddress;
|
|
|
|
|
|
|
|
- (NSRect)imageRectForBounds:(NSRect)bounds;
|
|
|
|
- (NSRect)rectForNameWithString:(NSAttributedString*)string inBounds:(NSRect)bounds;
|
|
|
|
- (NSRect)rectForCountWithString:(NSAttributedString*)string withAboveRect:(NSRect)aboveRect inBounds:(NSRect)bounds;
|
|
|
|
- (NSRect)rectForCountLabelWithString:(NSAttributedString*)string withRightRect:(NSRect)rightRect inBounds:(NSRect)bounds;
|
|
|
|
- (NSRect)rectForStatusWithString:(NSAttributedString*)string
|
|
|
|
withAboveRect:(NSRect)aboveRect
|
|
|
|
withRightRect:(NSRect)rightRect
|
|
|
|
inBounds:(NSRect)bounds;
|
|
|
|
|
|
|
|
- (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
|
2021-08-15 09:41:48 +00:00
|
|
|
NSCache* fTrackerIconCache;
|
|
|
|
NSMutableSet* fTrackerIconLoading;
|
2009-09-28 03:42:35 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (void)initialize
|
2009-09-28 03:42:35 +00:00
|
|
|
{
|
2011-10-18 02:30:22 +00:00
|
|
|
fTrackerIconCache = [[NSCache alloc] init];
|
2009-09-28 03:42:35 +00:00
|
|
|
fTrackerIconLoading = [[NSMutableSet alloc] init];
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (instancetype)init
|
2009-09-28 01:57:35 +00:00
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSMutableParagraphStyle* paragraphStyle = [NSParagraphStyle.defaultParagraphStyle mutableCopy];
|
2021-08-07 07:27:56 +00:00
|
|
|
paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
_fNameAttributes = [[NSMutableDictionary alloc]
|
2021-08-15 09:41:48 +00:00
|
|
|
initWithObjectsAndKeys:[NSFont messageFontOfSize:12.0], NSFontAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
_fStatusAttributes = [[NSMutableDictionary alloc]
|
2022-08-09 13:15:52 +00:00
|
|
|
initWithObjectsAndKeys:[NSFont messageFontOfSize:9.5], NSFontAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (id)copyWithZone:(NSZone*)zone
|
2012-03-13 02:52:11 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
TrackerCell* copy = [super copyWithZone:zone];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +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;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
|
2009-09-28 01:57:35 +00:00
|
|
|
{
|
|
|
|
//icon
|
2021-10-31 15:18:27 +00:00
|
|
|
[self.favIcon drawInRect:[self imageRectForBounds:cellFrame] fromRect:NSZeroRect operation:NSCompositingOperationSourceOver
|
2021-08-15 09:41:48 +00:00
|
|
|
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
|
2021-08-15 09:41:48 +00:00
|
|
|
NSColor *nameColor, *statusColor;
|
2021-10-31 15:18:27 +00:00
|
|
|
if (self.backgroundStyle == NSBackgroundStyleEmphasized)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
nameColor = statusColor = NSColor.whiteColor;
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2009-09-28 01:57:35 +00:00
|
|
|
else
|
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
nameColor = NSColor.labelColor;
|
|
|
|
statusColor = NSColor.secondaryLabelColor;
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fNameAttributes[NSForegroundColorAttributeName] = nameColor;
|
|
|
|
self.fStatusAttributes[NSForegroundColorAttributeName] = statusColor;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
TrackerNode* node = (TrackerNode*)self.objectValue;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
//name
|
2021-08-15 09:41:48 +00:00
|
|
|
NSAttributedString* nameString = self.attributedName;
|
|
|
|
NSRect const nameRect = [self rectForNameWithString:nameString inBounds:cellFrame];
|
|
|
|
[nameString drawInRect:nameRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 14:42:00 +00:00
|
|
|
//count strings
|
2021-08-15 09:41:48 +00:00
|
|
|
NSAttributedString* seederString = [self attributedCount:node.totalSeeders];
|
|
|
|
NSRect const seederRect = [self rectForCountWithString:seederString withAboveRect:nameRect inBounds:cellFrame];
|
|
|
|
[seederString drawInRect:seederRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSAttributedString* leecherString = [self attributedCount:node.totalLeechers];
|
|
|
|
NSRect const leecherRect = [self rectForCountWithString:leecherString withAboveRect:seederRect inBounds:cellFrame];
|
|
|
|
[leecherString drawInRect:leecherRect];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
NSAttributedString* downloadedString = [self attributedCount:node.totalDownloaded];
|
|
|
|
NSRect const 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
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* seederLabelBaseString = [NSLocalizedString(@"Seeders", "tracker peer stat") stringByAppendingFormat:@": "];
|
|
|
|
NSAttributedString* seederLabelString = [self attributedStatusWithString:seederLabelBaseString];
|
|
|
|
NSRect const seederLabelRect = [self rectForCountLabelWithString:seederLabelString withRightRect:seederRect inBounds:cellFrame];
|
|
|
|
[seederLabelString drawInRect:seederLabelRect];
|
|
|
|
|
|
|
|
NSString* leecherLabelBaseString = [NSLocalizedString(@"Leechers", "tracker peer stat") stringByAppendingFormat:@": "];
|
|
|
|
NSAttributedString* leecherLabelString = [self attributedStatusWithString:leecherLabelBaseString];
|
|
|
|
NSRect const leecherLabelRect = [self rectForCountLabelWithString:leecherLabelString withRightRect:leecherRect
|
|
|
|
inBounds:cellFrame];
|
|
|
|
[leecherLabelString drawInRect:leecherLabelRect];
|
|
|
|
|
|
|
|
NSString* downloadedLabelBaseString = [NSLocalizedString(@"Downloaded", "tracker peer stat") stringByAppendingFormat:@": "];
|
|
|
|
NSAttributedString* downloadedLabelString = [self attributedStatusWithString:downloadedLabelBaseString];
|
|
|
|
NSRect const 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
|
2021-08-15 09:41:48 +00:00
|
|
|
NSAttributedString* lastAnnounceString = [self attributedStatusWithString:node.lastAnnounceStatusString];
|
|
|
|
NSRect const lastAnnounceRect = [self rectForStatusWithString:lastAnnounceString withAboveRect:nameRect
|
|
|
|
withRightRect:seederLabelRect
|
|
|
|
inBounds:cellFrame];
|
|
|
|
[lastAnnounceString drawInRect:lastAnnounceRect];
|
|
|
|
|
|
|
|
NSAttributedString* nextAnnounceString = [self attributedStatusWithString:node.nextAnnounceStatusString];
|
|
|
|
NSRect const nextAnnounceRect = [self rectForStatusWithString:nextAnnounceString withAboveRect:lastAnnounceRect
|
|
|
|
withRightRect:leecherLabelRect
|
|
|
|
inBounds:cellFrame];
|
|
|
|
[nextAnnounceString drawInRect:nextAnnounceRect];
|
|
|
|
|
|
|
|
NSAttributedString* lastScrapeString = [self attributedStatusWithString:node.lastScrapeStatusString];
|
|
|
|
NSRect const lastScrapeRect = [self rectForStatusWithString:lastScrapeString withAboveRect:nextAnnounceRect
|
|
|
|
withRightRect:downloadedLabelRect
|
|
|
|
inBounds:cellFrame];
|
|
|
|
[lastScrapeString drawInRect:lastScrapeRect];
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
#pragma mark - Private
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (NSImage*)favIcon
|
2009-09-28 01:57:35 +00:00
|
|
|
{
|
2011-04-07 23:29:05 +00:00
|
|
|
id icon = nil;
|
2021-08-15 09:41:48 +00:00
|
|
|
NSURL* address = [NSURL URLWithString:((TrackerNode*)self.objectValue).fullAnnounceAddress];
|
|
|
|
NSString* host;
|
2021-08-07 07:27:56 +00:00
|
|
|
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
|
2022-06-12 20:29:00 +00:00
|
|
|
BOOL const isIP = tr_addressIsIP(host.UTF8String);
|
|
|
|
NSArray* hostComponents = !isIP ? [host componentsSeparatedByString:@"."] : nil;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-06-12 20:29:00 +00:00
|
|
|
if (!isIP && hostComponents.count >= 2)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-06-12 20:29:00 +00:00
|
|
|
NSString* domain = hostComponents[hostComponents.count - 2];
|
|
|
|
NSString* tld = hostComponents[hostComponents.count - 1];
|
|
|
|
NSString* baseAddress = [NSString stringWithFormat:@"%@.%@", domain, tld];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-06-12 20:29:00 +00:00
|
|
|
icon = [fTrackerIconCache objectForKey:baseAddress];
|
|
|
|
if (!icon)
|
|
|
|
{
|
|
|
|
[self loadTrackerIcon:baseAddress];
|
|
|
|
}
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2009-09-28 03:42:35 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2021-12-05 23:42:54 +00:00
|
|
|
if ((icon && icon != [NSNull null]))
|
|
|
|
{
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
2022-03-30 21:52:23 +00:00
|
|
|
if (@available(macOS 11.0, *))
|
|
|
|
{
|
2021-12-05 23:42:54 +00:00
|
|
|
NSImage* result = [NSImage imageWithSystemSymbolName:@"globe" accessibilityDescription:nil];
|
|
|
|
[result lockFocus];
|
|
|
|
[NSColor.textColor set];
|
2022-06-29 04:20:42 +00:00
|
|
|
NSRect imageRect = { NSZeroPoint, result.size };
|
2021-12-05 23:42:54 +00:00
|
|
|
NSRectFillUsingOperation(imageRect, NSCompositingOperationSourceIn);
|
|
|
|
[result unlockFocus];
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [NSImage imageNamed:@"FavIcon"];
|
2009-09-28 03:42:35 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)loadTrackerIcon:(NSString*)baseAddress
|
2009-09-28 03:42:35 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
if ([fTrackerIconLoading containsObject:baseAddress])
|
|
|
|
{
|
2020-01-03 05:12:59 +00:00
|
|
|
return;
|
2009-09-28 03:42:35 +00:00
|
|
|
}
|
2021-08-15 09:41:48 +00:00
|
|
|
[fTrackerIconLoading addObject:baseAddress];
|
|
|
|
|
2022-06-12 20:29:00 +00:00
|
|
|
NSString* favIconUrl = [NSString stringWithFormat:@"https://icons.duckduckgo.com/ip3/%@.ico", baseAddress];
|
2021-08-15 09:41:48 +00:00
|
|
|
|
2022-06-12 20:29:00 +00:00
|
|
|
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:favIconUrl] cachePolicy:NSURLRequestUseProtocolCachePolicy
|
|
|
|
timeoutInterval:30.0];
|
2021-08-15 09:41:48 +00:00
|
|
|
|
2022-06-12 20:29:00 +00:00
|
|
|
NSURLSessionDataTask* task = [NSURLSession.sharedSession
|
|
|
|
dataTaskWithRequest:request completionHandler:^(NSData* iconData, NSURLResponse* response, NSError* error) {
|
|
|
|
BOOL ok = ((NSHTTPURLResponse*)response).statusCode == 200 ? YES : NO;
|
|
|
|
if (!ok)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
2022-06-12 20:29:00 +00:00
|
|
|
return;
|
2020-01-03 05:12:59 +00:00
|
|
|
}
|
2021-08-15 09:41:48 +00:00
|
|
|
|
2022-06-12 20:29:00 +00:00
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
NSImage* icon = [[NSImage alloc] initWithData:iconData];
|
|
|
|
if (icon)
|
|
|
|
{
|
|
|
|
[fTrackerIconCache setObject:icon forKey:baseAddress];
|
2021-08-15 09:41:48 +00:00
|
|
|
|
2022-06-29 04:20:42 +00:00
|
|
|
[self.controlView setNeedsDisplay:YES];
|
2022-06-12 20:29:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[fTrackerIconCache setObject:[NSNull null] forKey:baseAddress];
|
|
|
|
}
|
2021-08-15 09:41:48 +00:00
|
|
|
|
2022-06-12 20:29:00 +00:00
|
|
|
[fTrackerIconLoading removeObject:baseAddress];
|
|
|
|
});
|
|
|
|
}];
|
|
|
|
[task resume];
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (NSRect)imageRectForBounds:(NSRect)bounds
|
2009-09-28 01:57:35 +00:00
|
|
|
{
|
2022-04-21 14:28:38 +00:00
|
|
|
return NSMakeRect(NSMinX(bounds) + PADDING_HORIZONTAL, NSMinY(bounds) + PADDING_ABOVE_ICON, ICON_SIZE, ICON_SIZE);
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (NSRect)rectForNameWithString:(NSAttributedString*)string inBounds:(NSRect)bounds
|
2009-09-28 01:57:35 +00:00
|
|
|
{
|
2009-12-28 20:05:33 +00:00
|
|
|
NSRect result;
|
2022-04-21 14:28:38 +00:00
|
|
|
result.origin.x = NSMinX(bounds) + PADDING_HORIZONTAL + ICON_SIZE + PADDING_BETWEEN_ICON_AND_NAME;
|
2009-12-28 20:05:33 +00:00
|
|
|
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;
|
2022-04-21 14:28:38 +00:00
|
|
|
result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (NSRect)rectForCountWithString:(NSAttributedString*)string withAboveRect:(NSRect)aboveRect inBounds:(NSRect)bounds
|
2009-09-28 14:42:00 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
return NSMakeRect(
|
2022-04-21 14:28:38 +00:00
|
|
|
NSMaxX(bounds) - PADDING_HORIZONTAL - COUNT_WIDTH,
|
2021-08-15 09:41:48 +00:00
|
|
|
NSMaxY(aboveRect) + PADDING_BETWEEN_LINES,
|
|
|
|
COUNT_WIDTH,
|
|
|
|
[string size].height);
|
2009-09-28 14:42:00 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (NSRect)rectForCountLabelWithString:(NSAttributedString*)string withRightRect:(NSRect)rightRect inBounds:(NSRect)bounds
|
2009-09-28 15:49:02 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +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;
|
2022-04-21 14:28:38 +00:00
|
|
|
result.origin.x = NSMinX(bounds) + PADDING_STATUS_HORIZONTAL;
|
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;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (NSAttributedString*)attributedName
|
2009-09-28 01:57:35 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* name = ((TrackerNode*)self.objectValue).host;
|
2022-02-22 16:04:20 +00:00
|
|
|
return [[NSAttributedString alloc] initWithString:name attributes:self.fNameAttributes];
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (NSAttributedString*)attributedStatusWithString:(NSString*)statusString
|
2009-09-28 01:57:35 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
return [[NSAttributedString alloc] initWithString:statusString attributes:self.fStatusAttributes];
|
2009-09-28 01:57:35 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (NSAttributedString*)attributedCount:(NSInteger)count
|
2009-09-28 15:59:17 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* countString = count != -1 ? [NSString stringWithFormat:@"%ld", count] : NSLocalizedString(@"N/A", "tracker peer stat");
|
2022-02-22 16:04:20 +00:00
|
|
|
return [[NSAttributedString alloc] initWithString:countString attributes:self.fStatusAttributes];
|
2009-09-28 15:59:17 +00:00
|
|
|
}
|
|
|
|
|
2009-09-28 01:57:35 +00:00
|
|
|
@end
|