Skip to content

Commit

Permalink
Adopting lightweight generics
Browse files Browse the repository at this point in the history
  • Loading branch information
Coeur committed Apr 24, 2022
1 parent 4f70baa commit 63eac83
Show file tree
Hide file tree
Showing 77 changed files with 189 additions and 183 deletions.
2 changes: 1 addition & 1 deletion macosx/AboutWindowController.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>

@interface AboutWindowController : NSWindowController

Expand Down
2 changes: 1 addition & 1 deletion macosx/AddMagnetWindowController.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>

@class Controller;
@class Torrent;
Expand Down
2 changes: 1 addition & 1 deletion macosx/AddWindowController.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>

@class Controller;
@class Torrent;
Expand Down
2 changes: 1 addition & 1 deletion macosx/BadgeView.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>

#include <libtransmission/transmission.h>

Expand Down
2 changes: 1 addition & 1 deletion macosx/BlocklistDownloader.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>

@class BlocklistDownloaderViewController;

Expand Down
12 changes: 6 additions & 6 deletions macosx/BlocklistDownloader.mm
Expand Up @@ -15,7 +15,7 @@ @interface BlocklistDownloader ()
@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

Expand Down Expand Up @@ -185,27 +185,27 @@ - (void)startDownload
[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];
}
}

Expand Down
2 changes: 1 addition & 1 deletion macosx/BlocklistDownloaderViewController.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>

#include <libtransmission/transmission.h>

Expand Down
2 changes: 1 addition & 1 deletion macosx/BonjourController.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>

@interface BonjourController : NSObject<NSNetServiceDelegate>

Expand Down
2 changes: 1 addition & 1 deletion macosx/ButtonToolbarItem.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>

@interface ButtonToolbarItem : NSToolbarItem

Expand Down
2 changes: 1 addition & 1 deletion macosx/ColorTextField.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>

@interface ColorTextField : NSTextField

Expand Down
16 changes: 8 additions & 8 deletions macosx/Controller.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>
#import <Quartz/Quartz.h>

#import <Sparkle/SUUpdaterDelegate.h>
Expand Down Expand Up @@ -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<Torrent*>*)torrents;

- (void)stopSelectedTorrents:(id)sender;
- (void)stopAllTorrents:(id)sender;
- (void)stopTorrents:(NSArray*)torrents;
- (void)stopTorrents:(NSArray<Torrent*>*)torrents;

- (void)removeTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData;
- (void)confirmRemoveTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData;
- (void)removeTorrents:(NSArray<Torrent*>*)torrents deleteData:(BOOL)deleteData;
- (void)confirmRemoveTorrents:(NSArray<Torrent*>*)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<Torrent*>*)torrents;

- (void)copyTorrentFiles:(id)sender;
- (void)copyTorrentFileForTorrents:(NSMutableArray*)torrents;
- (void)copyTorrentFileForTorrents:(NSMutableArray<Torrent*>*)torrents;

- (void)copyMagnetLinks:(id)sender;

Expand All @@ -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<Torrent*>* selectedTorrents;

@property(nonatomic, readonly) PrefsController* prefsController;
- (void)showPreferenceWindow:(id)sender;
Expand Down
64 changes: 33 additions & 31 deletions macosx/Controller.mm
Expand Up @@ -252,9 +252,9 @@ @interface Controller ()

@property(nonatomic, readonly) tr_session* fLib;

@property(nonatomic, readonly) NSMutableArray* fTorrents;
@property(nonatomic, readonly) NSMutableArray<Torrent*>* fTorrents;
@property(nonatomic, readonly) NSMutableArray* fDisplayedTorrents;
@property(nonatomic, readonly) NSMutableDictionary* fTorrentHashes;
@property(nonatomic, readonly) NSMutableDictionary<NSString*, Torrent*>* fTorrentHashes;

@property(nonatomic, readonly) InfoWindowController* fInfoController;
@property(nonatomic) MessageWindowController* fMessageController;
Expand All @@ -279,14 +279,14 @@ @interface Controller ()

@property(nonatomic) Badger* fBadger;

@property(nonatomic) NSMutableArray* fAutoImportedNames;
@property(nonatomic) NSMutableArray<NSString*>* fAutoImportedNames;
@property(nonatomic) NSTimer* fAutoImportTimer;

@property(nonatomic) NSMutableDictionary* fPendingTorrentDownloads;
@property(nonatomic) NSMutableDictionary<NSURL*, id>* fPendingTorrentDownloads;

@property(nonatomic) NSMutableSet* fAddingTransfers;
@property(nonatomic) NSMutableSet<Torrent*>* fAddingTransfers;

@property(nonatomic) NSMutableSet* fAddWindows;
@property(nonatomic) NSMutableSet<NSWindowController*>* fAddWindows;
@property(nonatomic) URLSheetWindowController* fUrlSheetController;

@property(nonatomic) BOOL fGlobalPopoverShown;
Expand Down Expand Up @@ -1609,7 +1609,7 @@ - (void)resumeWaitingTorrents:(id)sender
[self resumeTorrentsNoWait:torrents];
}

- (void)resumeTorrentsNoWait:(NSArray*)torrents
- (void)resumeTorrentsNoWait:(NSArray<Torrent*>*)torrents
{
//iterate through instead of all at once to ensure no conflicts
for (Torrent* torrent in torrents)
Expand All @@ -1630,7 +1630,7 @@ - (void)stopAllTorrents:(id)sender
[self stopTorrents:self.fTorrents];
}

- (void)stopTorrents:(NSArray*)torrents
- (void)stopTorrents:(NSArray<Torrent*>*)torrents
{
//don't want any of these starting then stopping
for (Torrent* torrent in torrents)
Expand All @@ -1649,7 +1649,7 @@ - (void)stopTorrents:(NSArray*)torrents
[self fullUpdateUI];
}

- (void)removeTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData
- (void)removeTorrents:(NSArray<Torrent*>*)torrents deleteData:(BOOL)deleteData
{
if ([self.fDefaults boolForKey:@"CheckRemove"])
{
Expand All @@ -1673,7 +1673,7 @@ - (void)removeTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData
NSUInteger const selected = torrents.count;
if (selected == 1)
{
NSString* torrentName = ((Torrent*)torrents[0]).name;
NSString* torrentName = torrents[0].name;

if (deleteData)
{
Expand Down Expand Up @@ -1750,7 +1750,7 @@ - (void)removeTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData
[self confirmRemoveTorrents:torrents deleteData:deleteData];
}

- (void)confirmRemoveTorrents:(NSArray*)torrents deleteData:(BOOL)deleteData
- (void)confirmRemoveTorrents:(NSArray<Torrent*>*)torrents deleteData:(BOOL)deleteData
{
//miscellaneous
for (Torrent* torrent in torrents)
Expand Down Expand Up @@ -1869,7 +1869,7 @@ - (void)removeDeleteData:(id)sender

- (void)clearCompleted:(id)sender
{
NSMutableArray* torrents = [NSMutableArray array];
NSMutableArray<Torrent*>* torrents = [NSMutableArray array];

for (Torrent* torrent in self.fTorrents)
{
Expand All @@ -1884,7 +1884,7 @@ - (void)clearCompleted:(id)sender
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];
Expand Down Expand Up @@ -1933,7 +1933,7 @@ - (void)moveDataFilesSelected:(id)sender
[self moveDataFiles:self.fTableView.selectedTorrents];
}

- (void)moveDataFiles:(NSArray*)torrents
- (void)moveDataFiles:(NSArray<Torrent*>*)torrents
{
NSOpenPanel* panel = [NSOpenPanel openPanel];
panel.prompt = NSLocalizedString(@"Select", "Move torrent -> prompt");
Expand All @@ -1947,7 +1947,7 @@ - (void)moveDataFiles:(NSArray*)torrents
{
panel.message = [NSString
stringWithFormat:NSLocalizedString(@"Select the new folder for \"%@\".", "Move torrent -> select destination folder"),
((Torrent*)torrents[0]).name];
torrents[0].name];
}
else
{
Expand All @@ -1971,7 +1971,7 @@ - (void)copyTorrentFiles:(id)sender
[self copyTorrentFileForTorrents:[[NSMutableArray alloc] initWithArray:self.fTableView.selectedTorrents]];
}

- (void)copyTorrentFileForTorrents:(NSMutableArray*)torrents
- (void)copyTorrentFileForTorrents:(NSMutableArray<Torrent*>*)torrents
{
if (torrents.count == 0)
{
Expand Down Expand Up @@ -2097,7 +2097,7 @@ - (void)verifySelectedTorrents:(id)sender
[self verifyTorrents:self.fTableView.selectedTorrents];
}

- (void)verifyTorrents:(NSArray*)torrents
- (void)verifyTorrents:(NSArray<Torrent*>*)torrents
{
for (Torrent* torrent in torrents)
{
Expand All @@ -2107,7 +2107,7 @@ - (void)verifyTorrents:(NSArray*)torrents
[self applyFilter];
}

- (NSArray*)selectedTorrents
- (NSArray<Torrent*>*)selectedTorrents
{
return self.fTableView.selectedTorrents;
}
Expand Down Expand Up @@ -2362,8 +2362,8 @@ - (Torrent*)torrentForHash:(NSString*)hash
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;
Expand Down Expand Up @@ -2810,14 +2810,16 @@ - (void)applyFilter
//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;
Expand Down Expand Up @@ -2846,7 +2848,7 @@ - (void)applyFilter
return YES;
}];

NSArray* allTorrents = [self.fTorrents objectsAtIndexes:indexesOfNonFilteredTorrents];
NSArray<Torrent*>* allTorrents = [self.fTorrents objectsAtIndexes:indexesOfNonFilteredTorrents];

//set button tooltips
if (self.fFilterBar)
Expand Down Expand Up @@ -2941,7 +2943,7 @@ - (void)applyFilter
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];
}];

Expand Down Expand Up @@ -3338,7 +3340,7 @@ - (void)checkAutoImportDirectory

path = path.stringByExpandingTildeInPath;

NSArray* importedNames;
NSArray<NSString*>* importedNames;
if (!(importedNames = [NSFileManager.defaultManager contentsOfDirectoryAtPath:path error:NULL]))
{
return;
Expand Down
2 changes: 1 addition & 1 deletion macosx/CreatorWindowController.h
Expand Up @@ -2,7 +2,7 @@
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.

#import <Cocoa/Cocoa.h>
#import <AppKit/AppKit.h>

#include <libtransmission/transmission.h>

Expand Down
2 changes: 1 addition & 1 deletion macosx/CreatorWindowController.mm
Expand Up @@ -37,7 +37,7 @@ @interface CreatorWindowController ()
@property(nonatomic, readonly) tr_metainfo_builder* fInfo;
@property(nonatomic, readonly) NSURL* fPath;
@property(nonatomic) NSURL* fLocation;
@property(nonatomic) NSMutableArray* fTrackers;
@property(nonatomic) NSMutableArray<NSString*>* fTrackers;

@property(nonatomic) NSTimer* fTimer;
@property(nonatomic) BOOL fStarted;
Expand Down

0 comments on commit 63eac83

Please sign in to comment.