display all trackers in the announce list in the inspector's tooltip

This commit is contained in:
Mitchell Livingston 2007-10-24 18:49:59 +00:00
parent e38311e64e
commit d8e9c10a34
3 changed files with 26 additions and 1 deletions

View File

@ -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]];

View File

@ -132,6 +132,7 @@ typedef enum
- (uint64_t) sizeLeft;
- (NSString *) trackerAddress;
- (NSString *) trackerAddressAnnounce;
- (NSArray *) allTrackers;
- (NSString *) comment;
- (NSString *) creator;

View File

@ -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];