From b286397338dbedaeaa3c27c5e3c68ebf7935a7ac Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 25 Oct 2007 20:14:24 +0000 Subject: [PATCH] filtering by a search string for tracker now checks all trackers in the announce-list --- macosx/Controller.m | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 42d2ee2d8..aa498180f 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1852,21 +1852,38 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi { filtering = YES; - #warning check multiple trackers NSString * filterType = [fDefaults stringForKey: @"FilterSearchType"]; - NSString * fullString; Torrent * torrent; + BOOL filterTracker = [filterType isEqualToString: FILTER_TYPE_TRACKER], remove; int i; for (i = [tempTorrents count]-1; i >= 0; i--) { torrent = [tempTorrents objectAtIndex: i]; - if ([filterType isEqualToString: FILTER_TYPE_TRACKER]) - fullString = [torrent trackerAddress]; - else - fullString = [torrent name]; + remove = NO; - if ([fullString rangeOfString: searchString options: NSCaseInsensitiveSearch].location == NSNotFound) + if (filterTracker) + { + NSEnumerator * trackerEnumerator = [[torrent allTrackers] objectEnumerator], * subTrackerEnumerator; + NSArray * subTrackers; + NSString * tracker; + while (!remove && (subTrackers = [trackerEnumerator nextObject])) + { + subTrackerEnumerator = [subTrackers objectEnumerator]; + while ((tracker = [subTrackerEnumerator nextObject])) + { + if ([tracker rangeOfString: searchString options: NSCaseInsensitiveSearch].location == NSNotFound) + { + remove = YES; + break; + } + } + } + } + else + remove = [[torrent name] rangeOfString: searchString options: NSCaseInsensitiveSearch].location == NSNotFound; + + if (remove) [tempTorrents removeObjectAtIndex: i]; } }