From 34ec2f5aa4fd4076a94ad6bbea9058e8ef5977f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20C=C5=93ur?= Date: Sat, 30 Apr 2022 06:51:40 +0800 Subject: [PATCH] Adopting lightweight generics (#2974) --- macosx/BlocklistDownloader.mm | 12 ++-- macosx/BonjourController.h | 2 +- macosx/Controller.h | 14 ++-- macosx/Controller.mm | 64 ++++++++++--------- macosx/CreatorWindowController.mm | 2 +- macosx/FileListNode.h | 2 +- macosx/FileOutlineController.mm | 6 +- macosx/FileOutlineView.h | 2 +- macosx/FileOutlineView.mm | 2 +- macosx/FilterBarController.h | 2 +- macosx/FilterBarController.mm | 5 +- macosx/GroupsController.mm | 2 +- macosx/InfoActivityViewController.h | 2 +- macosx/InfoActivityViewController.mm | 4 +- macosx/InfoFileViewController.h | 4 +- macosx/InfoFileViewController.mm | 6 +- macosx/InfoGeneralViewController.h | 2 +- macosx/InfoGeneralViewController.mm | 4 +- macosx/InfoOptionsViewController.h | 2 +- macosx/InfoOptionsViewController.mm | 6 +- macosx/InfoPeersViewController.h | 2 +- macosx/InfoPeersViewController.mm | 12 ++-- macosx/InfoTrackersViewController.h | 2 +- macosx/InfoTrackersViewController.mm | 8 +-- macosx/InfoViewController.h | 4 +- macosx/InfoWindowController.h | 6 +- macosx/InfoWindowController.mm | 6 +- macosx/MessageWindowController.mm | 15 ++--- macosx/NSStringAdditions.h | 2 +- macosx/NSStringAdditions.mm | 2 +- macosx/PortChecker.h | 2 +- macosx/PrefsController.h | 2 +- macosx/PrefsController.mm | 10 +-- .../QuickLookPlugin/GeneratePreviewForURL.mm | 1 + macosx/ShareTorrentFileHelper.h | 6 +- macosx/ShareTorrentFileHelper.mm | 4 +- macosx/Torrent.h | 10 +-- macosx/Torrent.mm | 24 +++---- macosx/TorrentGroup.h | 4 +- macosx/TorrentTableView.h | 2 +- macosx/TorrentTableView.mm | 2 +- macosx/WebSeedTableView.h | 2 +- 42 files changed, 141 insertions(+), 132 deletions(-) diff --git a/macosx/BlocklistDownloader.mm b/macosx/BlocklistDownloader.mm index 78c93716b..a327ebb9f 100644 --- a/macosx/BlocklistDownloader.mm +++ b/macosx/BlocklistDownloader.mm @@ -15,7 +15,7 @@ @property(nonatomic) blocklistDownloadState fState; - (void)startDownload; -- (void)decompressFrom:(NSURL*)file to:(NSURL*)destination error:(NSError**)error; +- (BOOL)decompressFrom:(NSURL*)file to:(NSURL*)destination error:(NSError**)error; @end @@ -185,27 +185,27 @@ BlocklistDownloader* fBLDownloader = nil; [task resume]; } -- (void)decompressFrom:(NSURL*)file to:(NSURL*)destination error:(NSError**)error +- (BOOL)decompressFrom:(NSURL*)file to:(NSURL*)destination error:(NSError**)error { if ([self untarFrom:file to:destination]) { - return; + return YES; } if ([self unzipFrom:file to:destination]) { - return; + return YES; } if ([self gunzipFrom:file to:destination]) { - return; + return YES; } // If it doesn't look like archive just copy it to destination else { - [NSFileManager.defaultManager copyItemAtURL:file toURL:destination error:error]; + return [NSFileManager.defaultManager copyItemAtURL:file toURL:destination error:error]; } } diff --git a/macosx/BonjourController.h b/macosx/BonjourController.h index 9a209196a..5525b18fb 100644 --- a/macosx/BonjourController.h +++ b/macosx/BonjourController.h @@ -2,7 +2,7 @@ // It may be used under the MIT (SPDX: MIT) license. // License text can be found in the licenses/ folder. -#import +#import @interface BonjourController : NSObject diff --git a/macosx/Controller.h b/macosx/Controller.h index 32589e5e9..95f300503 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -62,24 +62,24 @@ typedef NS_ENUM(unsigned int, addType) { // - (void)resumeSelectedTorrentsNoWait:(id)sender; - (void)resumeWaitingTorrents:(id)sender; -- (void)resumeTorrentsNoWait:(NSArray*)torrents; +- (void)resumeTorrentsNoWait:(NSArray*)torrents; - (void)stopSelectedTorrents:(id)sender; - (void)stopAllTorrents:(id)sender; -- (void)stopTorrents:(NSArray*)torrents; +- (void)stopTorrents:(NSArray*)torrents; -- (void)removeTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData; -- (void)confirmRemoveTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData; +- (void)removeTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData; +- (void)confirmRemoveTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData; - (void)removeNoDelete:(id)sender; - (void)removeDeleteData:(id)sender; - (void)clearCompleted:(id)sender; - (void)moveDataFilesSelected:(id)sender; -- (void)moveDataFiles:(NSArray*)torrents; +- (void)moveDataFiles:(NSArray*)torrents; - (void)copyTorrentFiles:(id)sender; -- (void)copyTorrentFileForTorrents:(NSMutableArray*)torrents; +- (void)copyTorrentFileForTorrents:(NSMutableArray*)torrents; - (void)copyMagnetLinks:(id)sender; @@ -92,7 +92,7 @@ typedef NS_ENUM(unsigned int, addType) { // - (void)verifySelectedTorrents:(id)sender; - (void)verifyTorrents:(NSArray*)torrents; -@property(nonatomic, readonly) NSArray* selectedTorrents; +@property(nonatomic, readonly) NSArray* selectedTorrents; @property(nonatomic, readonly) PrefsController* prefsController; - (void)showPreferenceWindow:(id)sender; diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 4b24a7deb..885ba054e 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -255,9 +255,9 @@ static void removeKeRangerRansomware() @property(nonatomic, readonly) tr_session* fLib; -@property(nonatomic, readonly) NSMutableArray* fTorrents; +@property(nonatomic, readonly) NSMutableArray* fTorrents; @property(nonatomic, readonly) NSMutableArray* fDisplayedTorrents; -@property(nonatomic, readonly) NSMutableDictionary* fTorrentHashes; +@property(nonatomic, readonly) NSMutableDictionary* fTorrentHashes; @property(nonatomic, readonly) InfoWindowController* fInfoController; @property(nonatomic) MessageWindowController* fMessageController; @@ -282,14 +282,14 @@ static void removeKeRangerRansomware() @property(nonatomic) Badger* fBadger; -@property(nonatomic) NSMutableArray* fAutoImportedNames; +@property(nonatomic) NSMutableArray* fAutoImportedNames; @property(nonatomic) NSTimer* fAutoImportTimer; -@property(nonatomic) NSMutableDictionary* fPendingTorrentDownloads; +@property(nonatomic) NSMutableDictionary* fPendingTorrentDownloads; -@property(nonatomic) NSMutableSet* fAddingTransfers; +@property(nonatomic) NSMutableSet* fAddingTransfers; -@property(nonatomic) NSMutableSet* fAddWindows; +@property(nonatomic) NSMutableSet* fAddWindows; @property(nonatomic) URLSheetWindowController* fUrlSheetController; @property(nonatomic) BOOL fGlobalPopoverShown; @@ -1612,7 +1612,7 @@ static void removeKeRangerRansomware() [self resumeTorrentsNoWait:torrents]; } -- (void)resumeTorrentsNoWait:(NSArray*)torrents +- (void)resumeTorrentsNoWait:(NSArray*)torrents { //iterate through instead of all at once to ensure no conflicts for (Torrent* torrent in torrents) @@ -1633,7 +1633,7 @@ static void removeKeRangerRansomware() [self stopTorrents:self.fTorrents]; } -- (void)stopTorrents:(NSArray*)torrents +- (void)stopTorrents:(NSArray*)torrents { //don't want any of these starting then stopping for (Torrent* torrent in torrents) @@ -1652,7 +1652,7 @@ static void removeKeRangerRansomware() [self fullUpdateUI]; } -- (void)removeTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData +- (void)removeTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData { if ([self.fDefaults boolForKey:@"CheckRemove"]) { @@ -1676,7 +1676,7 @@ static void removeKeRangerRansomware() NSUInteger const selected = torrents.count; if (selected == 1) { - NSString* torrentName = ((Torrent*)torrents[0]).name; + NSString* torrentName = torrents[0].name; if (deleteData) { @@ -1753,7 +1753,7 @@ static void removeKeRangerRansomware() [self confirmRemoveTorrents:torrents deleteData:deleteData]; } -- (void)confirmRemoveTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData +- (void)confirmRemoveTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData { //miscellaneous for (Torrent* torrent in torrents) @@ -1872,7 +1872,7 @@ static void removeKeRangerRansomware() - (void)clearCompleted:(id)sender { - NSMutableArray* torrents = [NSMutableArray array]; + NSMutableArray* torrents = [NSMutableArray array]; for (Torrent* torrent in self.fTorrents) { @@ -1887,7 +1887,7 @@ static void removeKeRangerRansomware() NSString *message, *info; if (torrents.count == 1) { - NSString* torrentName = ((Torrent*)torrents[0]).name; + NSString* torrentName = torrents[0].name; message = [NSString stringWithFormat:NSLocalizedString(@"Are you sure you want to remove \"%@\" from the transfer list?", "Remove completed confirm panel -> title"), torrentName]; @@ -1936,7 +1936,7 @@ static void removeKeRangerRansomware() [self moveDataFiles:self.fTableView.selectedTorrents]; } -- (void)moveDataFiles:(NSArray*)torrents +- (void)moveDataFiles:(NSArray*)torrents { NSOpenPanel* panel = [NSOpenPanel openPanel]; panel.prompt = NSLocalizedString(@"Select", "Move torrent -> prompt"); @@ -1950,7 +1950,7 @@ static void removeKeRangerRansomware() { panel.message = [NSString stringWithFormat:NSLocalizedString(@"Select the new folder for \"%@\".", "Move torrent -> select destination folder"), - ((Torrent*)torrents[0]).name]; + torrents[0].name]; } else { @@ -1974,7 +1974,7 @@ static void removeKeRangerRansomware() [self copyTorrentFileForTorrents:[[NSMutableArray alloc] initWithArray:self.fTableView.selectedTorrents]]; } -- (void)copyTorrentFileForTorrents:(NSMutableArray*)torrents +- (void)copyTorrentFileForTorrents:(NSMutableArray*)torrents { if (torrents.count == 0) { @@ -2100,7 +2100,7 @@ static void removeKeRangerRansomware() [self verifyTorrents:self.fTableView.selectedTorrents]; } -- (void)verifyTorrents:(NSArray*)torrents +- (void)verifyTorrents:(NSArray*)torrents { for (Torrent* torrent in torrents) { @@ -2110,7 +2110,7 @@ static void removeKeRangerRansomware() [self applyFilter]; } -- (NSArray*)selectedTorrents +- (NSArray*)selectedTorrents { return self.fTableView.selectedTorrents; } @@ -2365,8 +2365,8 @@ static void removeKeRangerRansomware() NSParameterAssert(hash != nil); __block Torrent* torrent = nil; - [self.fTorrents enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id obj, NSUInteger idx, BOOL* stop) { - if ([((Torrent*)obj).hashString isEqualToString:hash]) + [self.fTorrents enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(Torrent* obj, NSUInteger idx, BOOL* stop) { + if ([obj.hashString isEqualToString:hash]) { torrent = obj; *stop = YES; @@ -2813,14 +2813,16 @@ static void removeKeRangerRansomware() //to count, we need each string in at least 1 tracker [searchStrings enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id searchString, NSUInteger idx, BOOL* stop) { __block BOOL found = NO; - [trackers enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id tracker, NSUInteger idx, BOOL* stopTracker) { - if ([tracker rangeOfString:searchString options:(NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)] - .location != NSNotFound) - { - found = YES; - *stopTracker = YES; - } - }]; + [trackers enumerateObjectsWithOptions:NSEnumerationConcurrent + usingBlock:^(NSString* tracker, NSUInteger idx, BOOL* stopTracker) { + if ([tracker rangeOfString:searchString + options:(NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch)] + .location != NSNotFound) + { + found = YES; + *stopTracker = YES; + } + }]; if (!found) { removeTextField = YES; @@ -2849,7 +2851,7 @@ static void removeKeRangerRansomware() return YES; }]; - NSArray* allTorrents = [self.fTorrents objectsAtIndexes:indexesOfNonFilteredTorrents]; + NSArray* allTorrents = [self.fTorrents objectsAtIndexes:indexesOfNonFilteredTorrents]; //set button tooltips if (self.fFilterBar) @@ -2944,7 +2946,7 @@ static void removeKeRangerRansomware() if (self.fAddingTransfers) { NSIndexSet* newAddIndexes = [allTorrents indexesOfObjectsAtIndexes:addIndexes options:NSEnumerationConcurrent - passingTest:^BOOL(id obj, NSUInteger idx, BOOL* stop) { + passingTest:^BOOL(Torrent* obj, NSUInteger idx, BOOL* stop) { return [self.fAddingTransfers containsObject:obj]; }]; @@ -3341,7 +3343,7 @@ static void removeKeRangerRansomware() path = path.stringByExpandingTildeInPath; - NSArray* importedNames; + NSArray* importedNames; if (!(importedNames = [NSFileManager.defaultManager contentsOfDirectoryAtPath:path error:NULL])) { return; diff --git a/macosx/CreatorWindowController.mm b/macosx/CreatorWindowController.mm index d5677691b..c8d5fda95 100644 --- a/macosx/CreatorWindowController.mm +++ b/macosx/CreatorWindowController.mm @@ -37,7 +37,7 @@ @property(nonatomic, readonly) tr_metainfo_builder* fInfo; @property(nonatomic, readonly) NSURL* fPath; @property(nonatomic) NSURL* fLocation; -@property(nonatomic) NSMutableArray* fTrackers; +@property(nonatomic) NSMutableArray* fTrackers; @property(nonatomic) NSTimer* fTimer; @property(nonatomic) BOOL fStarted; diff --git a/macosx/FileListNode.h b/macosx/FileListNode.h index 32741b401..97f953428 100644 --- a/macosx/FileListNode.h +++ b/macosx/FileListNode.h @@ -16,7 +16,7 @@ @property(nonatomic, readonly) uint64_t size; @property(nonatomic, readonly) NSImage* icon; @property(nonatomic, readonly) BOOL isFolder; -@property(nonatomic, readonly) NSMutableArray* children; +@property(nonatomic, readonly) NSMutableArray* children; @property(nonatomic, readonly) NSIndexSet* indexes; diff --git a/macosx/FileOutlineController.mm b/macosx/FileOutlineController.mm index ac7a83d05..c7ee19745 100644 --- a/macosx/FileOutlineController.mm +++ b/macosx/FileOutlineController.mm @@ -29,14 +29,14 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { // @interface FileOutlineController () -@property(nonatomic) NSMutableArray* fFileList; +@property(nonatomic) NSMutableArray* fFileList; @property(nonatomic) IBOutlet FileOutlineView* fOutline; @property(nonatomic, readonly) NSMenu* menu; - (NSUInteger)findFileNode:(FileListNode*)node - inList:(NSArray*)list + inList:(NSArray*)list atIndexes:(NSIndexSet*)range currentParent:(FileListNode*)currentParent finalParent:(FileListNode**)parent; @@ -683,7 +683,7 @@ typedef NS_ENUM(unsigned int, filePriorityMenuTag) { // } - (NSUInteger)findFileNode:(FileListNode*)node - inList:(NSArray*)list + inList:(NSArray*)list atIndexes:(NSIndexSet*)indexes currentParent:(FileListNode*)currentParent finalParent:(FileListNode* __autoreleasing*)parent diff --git a/macosx/FileOutlineView.h b/macosx/FileOutlineView.h index 7ca28959f..139377854 100644 --- a/macosx/FileOutlineView.h +++ b/macosx/FileOutlineView.h @@ -8,6 +8,6 @@ @property(nonatomic, readonly) NSInteger hoveredRow; -- (NSRect)iconRectForRow:(int)row; +- (NSRect)iconRectForRow:(NSInteger)row; @end diff --git a/macosx/FileOutlineView.mm b/macosx/FileOutlineView.mm index b583c2908..ec5da7911 100644 --- a/macosx/FileOutlineView.mm +++ b/macosx/FileOutlineView.mm @@ -56,7 +56,7 @@ return self.menu; } -- (NSRect)iconRectForRow:(int)row +- (NSRect)iconRectForRow:(NSInteger)row { FileNameCell* cell = (FileNameCell*)[self preparedCellAtColumn:[self columnWithIdentifier:@"Name"] row:row]; NSRect iconRect = [cell imageRectForBounds:[self rectOfRow:row]]; diff --git a/macosx/FilterBarController.h b/macosx/FilterBarController.h index 8a1b70993..c226bf209 100644 --- a/macosx/FilterBarController.h +++ b/macosx/FilterBarController.h @@ -18,7 +18,7 @@ @interface FilterBarController : NSViewController -@property(nonatomic, readonly) NSArray* searchStrings; +@property(nonatomic, readonly) NSArray* searchStrings; - (instancetype)init; diff --git a/macosx/FilterBarController.mm b/macosx/FilterBarController.mm index bbb0bd5d7..18172187d 100644 --- a/macosx/FilterBarController.mm +++ b/macosx/FilterBarController.mm @@ -36,7 +36,8 @@ - (instancetype)init { - return (self = [super initWithNibName:@"FilterBar" bundle:nil]); + self = [super initWithNibName:@"FilterBar" bundle:nil]; + return self; } - (void)awakeFromNib @@ -319,7 +320,7 @@ } } -- (NSArray*)searchStrings +- (NSArray*)searchStrings { return [self.fSearchField.stringValue betterComponentsSeparatedByCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet]; } diff --git a/macosx/GroupsController.mm b/macosx/GroupsController.mm index ef584cdf3..e564df9bf 100644 --- a/macosx/GroupsController.mm +++ b/macosx/GroupsController.mm @@ -10,7 +10,7 @@ @interface GroupsController () -@property(nonatomic, readonly) NSMutableArray* fGroups; +@property(nonatomic, readonly) NSMutableArray* fGroups; - (void)saveGroups; diff --git a/macosx/InfoActivityViewController.h b/macosx/InfoActivityViewController.h index 4939059e3..5ce92a71f 100644 --- a/macosx/InfoActivityViewController.h +++ b/macosx/InfoActivityViewController.h @@ -8,7 +8,7 @@ @interface InfoActivityViewController : NSViewController -- (void)setInfoForTorrents:(NSArray*)torrents; +- (void)setInfoForTorrents:(NSArray*)torrents; - (void)updateInfo; - (IBAction)setPiecesView:(id)sender; diff --git a/macosx/InfoActivityViewController.mm b/macosx/InfoActivityViewController.mm index f75208f53..5b32935be 100644 --- a/macosx/InfoActivityViewController.mm +++ b/macosx/InfoActivityViewController.mm @@ -16,7 +16,7 @@ @interface InfoActivityViewController () -@property(nonatomic, copy) NSArray* fTorrents; +@property(nonatomic, copy) NSArray* fTorrents; @property(nonatomic) BOOL fSet; @@ -155,7 +155,7 @@ [NSNotificationCenter.defaultCenter removeObserver:self]; } -- (void)setInfoForTorrents:(NSArray*)torrents +- (void)setInfoForTorrents:(NSArray*)torrents { //don't check if it's the same in case the metadata changed self.fTorrents = torrents; diff --git a/macosx/InfoFileViewController.h b/macosx/InfoFileViewController.h index 1ce67ce2b..0f5e60eb3 100644 --- a/macosx/InfoFileViewController.h +++ b/macosx/InfoFileViewController.h @@ -9,10 +9,10 @@ @interface InfoFileViewController : NSViewController -@property(nonatomic, readonly) NSArray* quickLookURLs; +@property(nonatomic, readonly) NSArray* quickLookURLs; @property(nonatomic, readonly) BOOL canQuickLook; -- (void)setInfoForTorrents:(NSArray*)torrents; +- (void)setInfoForTorrents:(NSArray*)torrents; - (void)updateInfo; - (void)saveViewSize; diff --git a/macosx/InfoFileViewController.mm b/macosx/InfoFileViewController.mm index ff2075d78..c5f7fbdbf 100644 --- a/macosx/InfoFileViewController.mm +++ b/macosx/InfoFileViewController.mm @@ -10,7 +10,7 @@ @interface InfoFileViewController () -@property(nonatomic, copy) NSArray* fTorrents; +@property(nonatomic, copy) NSArray* fTorrents; @property(nonatomic) BOOL fSet; @@ -74,7 +74,7 @@ self.fCheckAllButton.frame = checkAllFrame; } -- (void)setInfoForTorrents:(NSArray*)torrents +- (void)setInfoForTorrents:(NSArray*)torrents { //don't check if it's the same in case the metadata changed self.fTorrents = torrents; @@ -125,7 +125,7 @@ [self.fFileController uncheckAll]; } -- (NSArray*)quickLookURLs +- (NSArray*)quickLookURLs { FileOutlineView* fileOutlineView = self.fFileController.outlineView; Torrent* torrent = self.fTorrents[0]; diff --git a/macosx/InfoGeneralViewController.h b/macosx/InfoGeneralViewController.h index 8187cac70..e8ed1751d 100644 --- a/macosx/InfoGeneralViewController.h +++ b/macosx/InfoGeneralViewController.h @@ -8,7 +8,7 @@ @interface InfoGeneralViewController : NSViewController -- (void)setInfoForTorrents:(NSArray*)torrents; +- (void)setInfoForTorrents:(NSArray*)torrents; - (void)updateInfo; - (void)revealDataFile:(id)sender; diff --git a/macosx/InfoGeneralViewController.mm b/macosx/InfoGeneralViewController.mm index 7b03dc600..1821022a0 100644 --- a/macosx/InfoGeneralViewController.mm +++ b/macosx/InfoGeneralViewController.mm @@ -8,7 +8,7 @@ @interface InfoGeneralViewController () -@property(nonatomic, copy) NSArray* fTorrents; +@property(nonatomic, copy) NSArray* fTorrents; @property(nonatomic) BOOL fSet; @@ -112,7 +112,7 @@ } } -- (void)setInfoForTorrents:(NSArray*)torrents +- (void)setInfoForTorrents:(NSArray*)torrents { //don't check if it's the same in case the metadata changed self.fTorrents = torrents; diff --git a/macosx/InfoOptionsViewController.h b/macosx/InfoOptionsViewController.h index 821142fec..e9f70c1ce 100644 --- a/macosx/InfoOptionsViewController.h +++ b/macosx/InfoOptionsViewController.h @@ -8,7 +8,7 @@ @interface InfoOptionsViewController : NSViewController -- (void)setInfoForTorrents:(NSArray*)torrents; +- (void)setInfoForTorrents:(NSArray*)torrents; - (void)updateInfo; - (void)updateOptions; diff --git a/macosx/InfoOptionsViewController.mm b/macosx/InfoOptionsViewController.mm index 87e4b5378..20700c540 100644 --- a/macosx/InfoOptionsViewController.mm +++ b/macosx/InfoOptionsViewController.mm @@ -18,7 +18,7 @@ @interface InfoOptionsViewController () -@property(nonatomic, copy) NSArray* fTorrents; +@property(nonatomic, copy) NSArray* fTorrents; @property(nonatomic) BOOL fSet; @@ -86,7 +86,7 @@ [NSNotificationCenter.defaultCenter removeObserver:self]; } -- (void)setInfoForTorrents:(NSArray*)torrents +- (void)setInfoForTorrents:(NSArray*)torrents { //don't check if it's the same in case the metadata changed self.fTorrents = torrents; @@ -306,7 +306,7 @@ while ((torrent = [enumerator nextObject]) && priority != INVALID) { - if (priority != INVALID && priority != torrent.priority) + if (priority != torrent.priority) { priority = INVALID; } diff --git a/macosx/InfoPeersViewController.h b/macosx/InfoPeersViewController.h index 8093ffc11..864539f01 100644 --- a/macosx/InfoPeersViewController.h +++ b/macosx/InfoPeersViewController.h @@ -8,7 +8,7 @@ @interface InfoPeersViewController : NSViewController -- (void)setInfoForTorrents:(NSArray*)torrents; +- (void)setInfoForTorrents:(NSArray*)torrents; - (void)updateInfo; - (void)saveViewSize; diff --git a/macosx/InfoPeersViewController.mm b/macosx/InfoPeersViewController.mm index 2308f8227..27e6bf842 100644 --- a/macosx/InfoPeersViewController.mm +++ b/macosx/InfoPeersViewController.mm @@ -17,12 +17,12 @@ @interface InfoPeersViewController () -@property(nonatomic, copy) NSArray* fTorrents; +@property(nonatomic, copy) NSArray* fTorrents; @property(nonatomic) BOOL fSet; -@property(nonatomic) NSMutableArray* fPeers; -@property(nonatomic) NSMutableArray* fWebSeeds; +@property(nonatomic) NSMutableArray* fPeers; +@property(nonatomic) NSMutableArray* fWebSeeds; @property(nonatomic) IBOutlet NSTableView* fPeerTable; @property(nonatomic) IBOutlet WebSeedTableView* fWebSeedTable; @@ -31,7 +31,7 @@ @property(nonatomic) CGFloat fViewTopMargin; @property(nonatomic) IBOutlet NSLayoutConstraint* fWebSeedTableTopConstraint; -@property(nonatomic, readonly) NSArray* peerSortDescriptors; +@property(nonatomic, readonly) NSArray* peerSortDescriptors; - (void)setupInfo; @@ -96,7 +96,7 @@ } #warning subclass? -- (void)setInfoForTorrents:(NSArray*)torrents +- (void)setInfoForTorrents:(NSArray*)torrents { //don't check if it's the same in case the metadata changed self.fTorrents = torrents; @@ -573,7 +573,7 @@ (animate ? [self.fWebSeedTableTopConstraint animator] : self.fWebSeedTableTopConstraint).constant = webSeedTableTopMargin; } -- (NSArray*)peerSortDescriptors +- (NSArray*)peerSortDescriptors { NSMutableArray* descriptors = [NSMutableArray arrayWithCapacity:2]; diff --git a/macosx/InfoTrackersViewController.h b/macosx/InfoTrackersViewController.h index b5928ad0b..28142f2ed 100644 --- a/macosx/InfoTrackersViewController.h +++ b/macosx/InfoTrackersViewController.h @@ -8,7 +8,7 @@ @interface InfoTrackersViewController : NSViewController -- (void)setInfoForTorrents:(NSArray*)torrents; +- (void)setInfoForTorrents:(NSArray*)torrents; - (void)updateInfo; - (void)saveViewSize; diff --git a/macosx/InfoTrackersViewController.mm b/macosx/InfoTrackersViewController.mm index 28091dcda..869c7f531 100644 --- a/macosx/InfoTrackersViewController.mm +++ b/macosx/InfoTrackersViewController.mm @@ -16,7 +16,7 @@ @interface InfoTrackersViewController () -@property(nonatomic, copy) NSArray* fTorrents; +@property(nonatomic, copy) NSArray* fTorrents; @property(nonatomic) BOOL fSet; @@ -64,7 +64,7 @@ } } -- (void)setInfoForTorrents:(NSArray*)torrents +- (void)setInfoForTorrents:(NSArray*)torrents { //don't check if it's the same in case the metadata changed self.fTorrents = torrents; @@ -91,7 +91,7 @@ if (self.fTorrents.count == 1) { - self.fTrackers = ((Torrent*)self.fTorrents[0]).allTrackerStats; + self.fTrackers = self.fTorrents[0].allTrackerStats; } else { @@ -120,7 +120,7 @@ NSIndexSet* addedIndexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(self.fTrackers.count - 2, 2)]; NSArray* tierAndTrackerBeingAdded = [self.fTrackers objectsAtIndexes:addedIndexes]; - self.fTrackers = ((Torrent*)self.fTorrents[0]).allTrackerStats; + self.fTrackers = self.fTorrents[0].allTrackerStats; [self.fTrackers addObjectsFromArray:tierAndTrackerBeingAdded]; self.fTrackerTable.trackers = self.fTrackers; diff --git a/macosx/InfoViewController.h b/macosx/InfoViewController.h index 894a05eb8..27232f4c3 100644 --- a/macosx/InfoViewController.h +++ b/macosx/InfoViewController.h @@ -4,9 +4,11 @@ #import +@class Torrent; + @protocol InfoViewController -- (void)setInfoForTorrents:(NSArray*)torrents; +- (void)setInfoForTorrents:(NSArray*)torrents; - (void)updateInfo; @optional diff --git a/macosx/InfoWindowController.h b/macosx/InfoWindowController.h index 6d35b535f..e7dd4909f 100644 --- a/macosx/InfoWindowController.h +++ b/macosx/InfoWindowController.h @@ -5,12 +5,14 @@ #import #import +@class Torrent; + @interface InfoWindowController : NSWindowController -@property(nonatomic, readonly) NSArray* quickLookURLs; +@property(nonatomic, readonly) NSArray* quickLookURLs; @property(nonatomic, readonly) BOOL canQuickLook; -- (void)setInfoForTorrents:(NSArray*)torrents; +- (void)setInfoForTorrents:(NSArray*)torrents; - (void)updateInfoStats; - (void)updateOptions; diff --git a/macosx/InfoWindowController.mm b/macosx/InfoWindowController.mm index ebe4257db..3c803f55e 100644 --- a/macosx/InfoWindowController.mm +++ b/macosx/InfoWindowController.mm @@ -37,7 +37,7 @@ typedef NS_ENUM(unsigned int, tabTag) { @interface InfoWindowController () -@property(nonatomic, copy) NSArray* fTorrents; +@property(nonatomic, copy) NSArray* fTorrents; @property(nonatomic) CGFloat fMinWindowWidth; @@ -168,7 +168,7 @@ typedef NS_ENUM(unsigned int, tabTag) { } } -- (void)setInfoForTorrents:(NSArray*)torrents +- (void)setInfoForTorrents:(NSArray*)torrents { if (self.fTorrents && [self.fTorrents isEqualToArray:torrents]) { @@ -403,7 +403,7 @@ typedef NS_ENUM(unsigned int, tabTag) { [self.fOptionsViewController updateOptions]; } -- (NSArray*)quickLookURLs +- (NSArray*)quickLookURLs { return self.fFileViewController.quickLookURLs; } diff --git a/macosx/MessageWindowController.mm b/macosx/MessageWindowController.mm index 2b54edadd..5641f2411 100644 --- a/macosx/MessageWindowController.mm +++ b/macosx/MessageWindowController.mm @@ -28,10 +28,10 @@ @property(nonatomic) IBOutlet NSButton* fClearButton; @property(nonatomic) IBOutlet NSSearchField* fFilterField; -@property(nonatomic) NSMutableArray* fMessages; -@property(nonatomic) NSMutableArray* fDisplayedMessages; +@property(nonatomic) NSMutableArray* fMessages; +@property(nonatomic) NSMutableArray* fDisplayedMessages; -@property(nonatomic, copy) NSDictionary* fAttributes; +@property(nonatomic, copy) NSDictionary* fAttributes; @property(nonatomic) NSTimer* fTimer; @@ -487,11 +487,10 @@ NSInteger const level = [NSUserDefaults.standardUserDefaults integerForKey:@"MessageLevel"]; NSString* filterString = self.fFilterField.stringValue; - NSIndexSet* indexes = [self.fMessages indexesOfObjectsWithOptions:NSEnumerationConcurrent - passingTest:^BOOL(id message, NSUInteger idx, BOOL* stop) { - return [((NSDictionary*)message)[@"Level"] integerValue] <= level && - [self shouldIncludeMessageForFilter:filterString message:message]; - }]; + NSIndexSet* indexes = [self.fMessages + indexesOfObjectsWithOptions:NSEnumerationConcurrent passingTest:^BOOL(NSDictionary* message, NSUInteger idx, BOOL* stop) { + return [message[@"Level"] integerValue] <= level && [self shouldIncludeMessageForFilter:filterString message:message]; + }]; NSArray* tempMessages = [[self.fMessages objectsAtIndexes:indexes] sortedArrayUsingDescriptors:self.fMessageTable.sortDescriptors]; diff --git a/macosx/NSStringAdditions.h b/macosx/NSStringAdditions.h index 40c04ac9d..456fd516c 100644 --- a/macosx/NSStringAdditions.h +++ b/macosx/NSStringAdditions.h @@ -2,7 +2,7 @@ // It may be used under the MIT (SPDX: MIT) license. // License text can be found in the licenses/ folder. -#import +#import @interface NSString (NSStringAdditions) diff --git a/macosx/NSStringAdditions.mm b/macosx/NSStringAdditions.mm index 21bb3a7b5..80746d525 100644 --- a/macosx/NSStringAdditions.mm +++ b/macosx/NSStringAdditions.mm @@ -128,7 +128,7 @@ return [self compare:string options:comparisonOptions range:NSMakeRange(0, self.length) locale:NSLocale.currentLocale]; } -- (NSArray*)betterComponentsSeparatedByCharactersInSet:(NSCharacterSet*)separators +- (NSArray*)betterComponentsSeparatedByCharactersInSet:(NSCharacterSet*)separators { NSMutableArray* components = [NSMutableArray array]; diff --git a/macosx/PortChecker.h b/macosx/PortChecker.h index e05ed6a0d..46905ceb0 100644 --- a/macosx/PortChecker.h +++ b/macosx/PortChecker.h @@ -2,7 +2,7 @@ // It may be used under the MIT (SPDX: MIT) license. // License text can be found in the licenses/ folder. -#import +#import typedef NS_ENUM(unsigned int, port_status_t) { // PORT_STATUS_CHECKING, diff --git a/macosx/PrefsController.h b/macosx/PrefsController.h index 4f6470310..b52750c6e 100644 --- a/macosx/PrefsController.h +++ b/macosx/PrefsController.h @@ -8,7 +8,7 @@ @interface PrefsController : NSWindowController -@property(nonatomic, readonly) NSArray* sounds; +@property(nonatomic, readonly) NSArray* sounds; + (NSInteger)dateToTimeSum:(NSDate*)date; diff --git a/macosx/PrefsController.mm b/macosx/PrefsController.mm index 2f516a6db..e7ea9e6a2 100644 --- a/macosx/PrefsController.mm +++ b/macosx/PrefsController.mm @@ -97,7 +97,7 @@ @property(nonatomic) IBOutlet NSTextField* fRPCPortField; @property(nonatomic) IBOutlet NSTextField* fRPCPasswordField; @property(nonatomic) IBOutlet NSTableView* fRPCWhitelistTable; -@property(nonatomic, readonly) NSMutableArray* fRPCWhitelistArray; +@property(nonatomic, readonly) NSMutableArray* fRPCWhitelistArray; @property(nonatomic) IBOutlet NSSegmentedControl* fRPCAddRemoveControl; @property(nonatomic, copy) NSString* fRPCPassword; @@ -482,7 +482,7 @@ self.fPortChecker = nil; } -- (NSArray*)sounds +- (NSArray*)sounds { NSMutableArray* sounds = [NSMutableArray array]; @@ -843,7 +843,7 @@ - (void)setQueueNumber:(id)sender { - NSInteger const number = [sender intValue]; + int const number = [sender intValue]; BOOL const seed = sender == self.fQueueSeedField; [self.fDefaults setInteger:number forKey:seed ? @"QueueSeedNumber" : @"QueueDownloadNumber"]; @@ -861,7 +861,7 @@ - (void)setStalledMinutes:(id)sender { - NSInteger const min = [sender intValue]; + int const min = [sender intValue]; [self.fDefaults setInteger:min forKey:@"StalledMinutes"]; tr_sessionSetQueueStalledMinutes(self.fHandle, min); @@ -1183,7 +1183,7 @@ [self.fRPCWhitelistArray addObject:@""]; [self.fRPCWhitelistTable reloadData]; - int const row = self.fRPCWhitelistArray.count - 1; + NSUInteger const row = self.fRPCWhitelistArray.count - 1; [self.fRPCWhitelistTable selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO]; [self.fRPCWhitelistTable editColumn:0 row:row withEvent:nil select:YES]; } diff --git a/macosx/QuickLookPlugin/GeneratePreviewForURL.mm b/macosx/QuickLookPlugin/GeneratePreviewForURL.mm index 973ef22fc..bcd3aa581 100644 --- a/macosx/QuickLookPlugin/GeneratePreviewForURL.mm +++ b/macosx/QuickLookPlugin/GeneratePreviewForURL.mm @@ -1,3 +1,4 @@ +#import #import #include diff --git a/macosx/ShareTorrentFileHelper.h b/macosx/ShareTorrentFileHelper.h index 4f55c154f..8d63e8ca5 100644 --- a/macosx/ShareTorrentFileHelper.h +++ b/macosx/ShareTorrentFileHelper.h @@ -3,13 +3,13 @@ // License text can be found in the licenses/ folder. // Created by Mitchell Livingston on 1/10/14. -#import +#import @interface ShareTorrentFileHelper : NSObject @property(nonatomic, class, readonly) ShareTorrentFileHelper* sharedHelper; -@property(nonatomic, readonly) NSArray* shareTorrentURLs; -@property(nonatomic, readonly) NSArray* menuItems; +@property(nonatomic, readonly) NSArray* shareTorrentURLs; +@property(nonatomic, readonly) NSArray* menuItems; @end diff --git a/macosx/ShareTorrentFileHelper.mm b/macosx/ShareTorrentFileHelper.mm index 5795bab28..c8f4d12e9 100644 --- a/macosx/ShareTorrentFileHelper.mm +++ b/macosx/ShareTorrentFileHelper.mm @@ -19,7 +19,7 @@ return helper; } -- (NSArray*)shareTorrentURLs +- (NSArray*)shareTorrentURLs { NSArray* torrents = ((Controller*)NSApp.delegate).selectedTorrents; NSMutableArray* fileURLs = [NSMutableArray arrayWithCapacity:torrents.count]; @@ -34,7 +34,7 @@ return fileURLs; } -- (NSArray*)menuItems +- (NSArray*)menuItems { NSArray* services = [NSSharingService sharingServicesForItems:self.shareTorrentURLs]; NSMutableArray* items = [NSMutableArray arrayWithCapacity:services.count]; diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 58535a2f0..481f3f76e 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -93,7 +93,7 @@ typedef NS_ENUM(unsigned int, TorrentDeterminationType) { @property(nonatomic, readonly) uint64_t sizeLeft; @property(nonatomic, readonly) NSMutableArray* allTrackerStats; -@property(nonatomic, readonly) NSArray* allTrackersFlat; //used by GroupRules +@property(nonatomic, readonly) NSArray* allTrackersFlat; //used by GroupRules - (BOOL)addTrackerToNewTier:(NSString*)tracker; - (void)removeTrackers:(NSSet*)trackers; @@ -133,10 +133,10 @@ typedef NS_ENUM(unsigned int, TorrentDeterminationType) { @property(nonatomic, getter=isAnyErrorOrWarning, readonly) BOOL anyErrorOrWarning; @property(nonatomic, readonly) NSString* errorMessage; -@property(nonatomic, readonly) NSArray* peers; +@property(nonatomic, readonly) NSArray* peers; @property(nonatomic, readonly) NSUInteger webSeedCount; -@property(nonatomic, readonly) NSArray* webSeeds; +@property(nonatomic, readonly) NSArray* webSeeds; @property(nonatomic, readonly) NSString* progressString; @property(nonatomic, readonly) NSString* statusString; @@ -172,8 +172,8 @@ typedef NS_ENUM(unsigned int, TorrentDeterminationType) { @property(nonatomic, readonly) NSInteger groupOrderValue; - (void)checkGroupValueForRemoval:(NSNotification*)notification; -@property(nonatomic, readonly) NSArray* fileList; -@property(nonatomic, readonly) NSArray* flatFileList; +@property(nonatomic, readonly) NSArray* fileList; +@property(nonatomic, readonly) NSArray* flatFileList; @property(nonatomic, readonly) NSInteger fileCount; //methods require fileStats to have been updated recently to be accurate diff --git a/macosx/Torrent.mm b/macosx/Torrent.mm index 94cb45e65..ed922c15f 100644 --- a/macosx/Torrent.mm +++ b/macosx/Torrent.mm @@ -30,8 +30,8 @@ @property(nonatomic) NSImage* fIcon; -@property(nonatomic, copy) NSArray* fileList; -@property(nonatomic, copy) NSArray* flatFileList; +@property(nonatomic, copy) NSArray* fileList; +@property(nonatomic, copy) NSArray* flatFileList; @property(nonatomic, copy) NSIndexSet* fPreviousFinishedIndexes; @property(nonatomic) NSDate* fPreviousFinishedIndexesDate; @@ -61,8 +61,8 @@ forParent:(FileListNode*)parent fileSize:(uint64_t)size index:(NSInteger)index - flatList:(NSMutableArray*)flatFileList; -- (void)sortFileList:(NSMutableArray*)fileNodes; + flatList:(NSMutableArray*)flatFileList; +- (void)sortFileList:(NSMutableArray*)fileNodes; - (void)startQueue; - (void)completenessChange:(tr_completeness)status wasRunning:(BOOL)wasRunning; @@ -70,7 +70,7 @@ - (void)idleLimitHit; - (void)metadataRetrieved; - (void)renameFinished:(BOOL)success - nodes:(NSArray*)nodes + nodes:(NSArray*)nodes completionHandler:(void (^)(BOOL))completionHandler oldPath:(NSString*)oldPath newName:(NSString*)newName; @@ -697,7 +697,7 @@ bool trashDataFile(char const* filename, tr_error** error) return trackers; } -- (NSArray*)allTrackersFlat +- (NSArray*)allTrackersFlat { auto const n = tr_torrentTrackerCount(self.fHandle); NSMutableArray* allTrackers = [NSMutableArray arrayWithCapacity:n]; @@ -983,7 +983,7 @@ bool trashDataFile(char const* filename, tr_error** error) return error; } -- (NSArray*)peers +- (NSArray*)peers { int totalPeers; tr_peer_stat* peers = tr_torrentPeers(self.fHandle, &totalPeers); @@ -1028,7 +1028,7 @@ bool trashDataFile(char const* filename, tr_error** error) return tr_torrentWebseedCount(self.fHandle); } -- (NSArray*)webSeeds +- (NSArray*)webSeeds { NSUInteger n = tr_torrentWebseedCount(self.fHandle); NSMutableArray* webSeeds = [NSMutableArray arrayWithCapacity:n]; @@ -1897,12 +1897,12 @@ bool trashDataFile(char const* filename, tr_error** error) } } -- (void)insertPathForComponents:(NSArray*)components +- (void)insertPathForComponents:(NSArray*)components withComponentIndex:(NSUInteger)componentIndex forParent:(FileListNode*)parent fileSize:(uint64_t)size index:(NSInteger)index - flatList:(NSMutableArray*)flatFileList + flatList:(NSMutableArray*)flatFileList { NSParameterAssert(components.count > 0); NSParameterAssert(componentIndex < components.count); @@ -1951,7 +1951,7 @@ bool trashDataFile(char const* filename, tr_error** error) } } -- (void)sortFileList:(NSMutableArray*)fileNodes +- (void)sortFileList:(NSMutableArray*)fileNodes { NSSortDescriptor* descriptor = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES selector:@selector(localizedStandardCompare:)]; @@ -2042,7 +2042,7 @@ bool trashDataFile(char const* filename, tr_error** error) } - (void)renameFinished:(BOOL)success - nodes:(NSArray*)nodes + nodes:(NSArray*)nodes completionHandler:(void (^)(BOOL))completionHandler oldPath:(NSString*)oldPath newName:(NSString*)newName diff --git a/macosx/TorrentGroup.h b/macosx/TorrentGroup.h index 651557e11..7fdeecbff 100644 --- a/macosx/TorrentGroup.h +++ b/macosx/TorrentGroup.h @@ -4,13 +4,15 @@ #import +@class Torrent; + @interface TorrentGroup : NSObject - (instancetype)initWithGroup:(NSInteger)group; @property(nonatomic, readonly) NSInteger groupIndex; @property(nonatomic, readonly) NSInteger groupOrderValue; -@property(nonatomic, readonly) NSMutableArray* torrents; +@property(nonatomic, readonly) NSMutableArray* torrents; @property(nonatomic, readonly) CGFloat ratio; @property(nonatomic, readonly) CGFloat uploadRate; diff --git a/macosx/TorrentTableView.h b/macosx/TorrentTableView.h index 5fce2daa2..d15ac7aba 100644 --- a/macosx/TorrentTableView.h +++ b/macosx/TorrentTableView.h @@ -25,7 +25,7 @@ - (void)selectValues:(NSArray*)values; @property(nonatomic, readonly) NSArray* selectedValues; -@property(nonatomic, readonly) NSArray* selectedTorrents; +@property(nonatomic, readonly) NSArray* selectedTorrents; - (NSRect)iconRectForRow:(NSInteger)row; diff --git a/macosx/TorrentTableView.mm b/macosx/TorrentTableView.mm index 71edd97dd..f3d3b44aa 100644 --- a/macosx/TorrentTableView.mm +++ b/macosx/TorrentTableView.mm @@ -561,7 +561,7 @@ return values; } -- (NSArray*)selectedTorrents +- (NSArray*)selectedTorrents { NSIndexSet* selectedIndexes = self.selectedRowIndexes; NSMutableArray* torrents = [NSMutableArray arrayWithCapacity:selectedIndexes.count]; //take a shot at guessing capacity diff --git a/macosx/WebSeedTableView.h b/macosx/WebSeedTableView.h index 33c2dfcc5..9148ceebc 100644 --- a/macosx/WebSeedTableView.h +++ b/macosx/WebSeedTableView.h @@ -6,7 +6,7 @@ @interface WebSeedTableView : NSTableView -@property(nonatomic, weak) NSArray* webSeeds; +@property(nonatomic, weak) NSArray* webSeeds; - (void)copy:(id)sender;