#2488 when sorting by tracker, first use the tracker that comes first alphabetically
This commit is contained in:
parent
0fd678acd0
commit
2af26e1d7c
|
@ -1270,7 +1270,7 @@ typedef struct
|
|||
/* whether or not we've ever scraped to this tracker */
|
||||
tr_bool hasScraped;
|
||||
|
||||
/* ex: legaltorrents.com */
|
||||
/* ex: http://www.legaltorrents.com:7070 */
|
||||
char host[1024];
|
||||
|
||||
/* the full announce URL */
|
||||
|
|
|
@ -1941,10 +1941,9 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
descriptors = [[NSArray alloc] initWithObjects: progressDescriptor, ratioProgressDescriptor, ratioDescriptor,
|
||||
nameDescriptor, nil];
|
||||
}
|
||||
#warning broken
|
||||
else if ([sortType isEqualToString: SORT_TRACKER])
|
||||
{
|
||||
NSSortDescriptor * trackerDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"trackerAddressAnnounce" ascending: asc
|
||||
NSSortDescriptor * trackerDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"trackerSortKey" ascending: asc
|
||||
selector: @selector(localizedCaseInsensitiveCompare:)] autorelease];
|
||||
|
||||
descriptors = [[NSArray alloc] initWithObjects: trackerDescriptor, nameDescriptor, nil];
|
||||
|
@ -3472,8 +3471,10 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
break;
|
||||
case SORT_ACTIVITY_TAG:
|
||||
sortType = SORT_ACTIVITY;
|
||||
break;
|
||||
default:
|
||||
NSAssert1(NO, @"Unknown sort tag received: %d", [menuItem tag]);
|
||||
return;
|
||||
}
|
||||
|
||||
[menuItem setState: [sortType isEqualToString: [fDefaults stringForKey: @"Sort"]] ? NSOnState : NSOffState];
|
||||
|
@ -4110,7 +4111,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
if (!torrent)
|
||||
{
|
||||
[pool release];
|
||||
[pool drain];
|
||||
|
||||
NSLog(@"No torrent found matching the given torrent struct from the RPC callback!");
|
||||
return;
|
||||
|
|
|
@ -226,6 +226,7 @@
|
|||
- (BOOL) isStalled;
|
||||
|
||||
- (NSInteger) stateSortKey;
|
||||
- (NSString *) trackerSortKey;
|
||||
|
||||
- (tr_torrent *) torrentStruct;
|
||||
|
||||
|
|
|
@ -1478,6 +1478,24 @@ int trashDataFile(const char * filename)
|
|||
return 2;
|
||||
}
|
||||
|
||||
- (NSString *) trackerSortKey
|
||||
{
|
||||
int count;
|
||||
tr_tracker_stat * stats = tr_torrentTrackers(fHandle, &count);
|
||||
|
||||
NSString * best = nil;
|
||||
|
||||
for (int i=0; i < count; ++i)
|
||||
{
|
||||
NSString * tracker = [NSString stringWithUTF8String: stats[i].host];
|
||||
if (!best || [tracker localizedCaseInsensitiveCompare: best] == NSOrderedAscending)
|
||||
best = tracker;
|
||||
}
|
||||
|
||||
tr_torrentTrackersFree(stats, count);
|
||||
return best;
|
||||
}
|
||||
|
||||
- (tr_torrent *) torrentStruct
|
||||
{
|
||||
return fHandle;
|
||||
|
|
Loading…
Reference in New Issue