From d8e9c10a3411c45e06e507608b2b1cef7e692316 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Wed, 24 Oct 2007 18:49:59 +0000 Subject: [PATCH] display all trackers in the announce list in the inspector's tooltip --- macosx/InfoWindowController.m | 8 +++++++- macosx/Torrent.h | 1 + macosx/Torrent.m | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 0fb49e31d..787e7a8c3 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -316,6 +316,13 @@ typedef enum [fNameField setToolTip: name]; [fSizeField setStringValue: [NSString stringForFileSize: [torrent size]]]; + NSArray * allTrackers = [torrent allTrackers], * subTrackers; + NSMutableArray * trackerStrings = [NSMutableArray arrayWithCapacity: [allTrackers count]]; + NSEnumerator * enumerator = [allTrackers objectEnumerator]; + while ((subTrackers = [enumerator nextObject])) + [trackerStrings addObject: [subTrackers componentsJoinedByString: @", "]]; + [fTrackerField setToolTip: [trackerStrings componentsJoinedByString: @"\n"]]; + NSString * hashString = [torrent hashString]; [fPiecesField setStringValue: [NSString stringWithFormat: @"%d, %@", [torrent pieceCount], [NSString stringForFileSize: [torrent pieceSize]]]]; @@ -1107,7 +1114,6 @@ typedef enum NSString * tracker = [[torrent trackerAddress] stringByAppendingString: [torrent trackerAddressAnnounce]]; [fTrackerField setStringValue: tracker]; - [fTrackerField setToolTip: tracker]; NSString * location = [torrent dataLocation]; [fDataLocationField setStringValue: [location stringByAbbreviatingWithTildeInPath]]; diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 483afc0aa..3fc01fd3c 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -132,6 +132,7 @@ typedef enum - (uint64_t) sizeLeft; - (NSString *) trackerAddress; - (NSString *) trackerAddressAnnounce; +- (NSArray *) allTrackers; - (NSString *) comment; - (NSString *) creator; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 3f3261c0a..e9701d863 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -617,6 +617,24 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * return [NSString stringWithUTF8String: fStat->tracker->announce]; } +- (NSArray *) allTrackers +{ + NSMutableArray * trackers = [NSMutableArray arrayWithCapacity: fInfo->trackerTiers], * subTrackers; + + int i, j; + for (i = 0; i < fInfo->trackerTiers; i++) + { + subTrackers = [NSMutableArray arrayWithCapacity: fInfo->trackerList[i].count]; + for (j = 0; j < fInfo->trackerList[i].count; j++) + [subTrackers addObject: [NSString stringWithFormat: @"http://%s:%d", + fInfo->trackerList[i].list[j].address, fInfo->trackerList[i].list[j].port]]; + + [trackers addObject: subTrackers]; + } + + return trackers; +} + - (NSString *) comment { return [NSString stringWithUTF8String: fInfo->comment];