re-add non-ARC-specific changes from r13248-50, mainly to make re-adding ARC support easier in the future
This commit is contained in:
parent
3d866c03e6
commit
4252d0ca02
|
@ -31,27 +31,26 @@
|
|||
|
||||
- (void) startDownload;
|
||||
- (void) decompressBlocklist;
|
||||
- (void) finishDownloadSuccess;
|
||||
|
||||
@end
|
||||
|
||||
@implementation BlocklistDownloader
|
||||
|
||||
BlocklistDownloader * fDownloader = nil;
|
||||
BlocklistDownloader * fBLDownloader = nil;
|
||||
+ (BlocklistDownloader *) downloader
|
||||
{
|
||||
if (!fDownloader)
|
||||
if (!fBLDownloader)
|
||||
{
|
||||
fDownloader = [[BlocklistDownloader alloc] init];
|
||||
[fDownloader startDownload];
|
||||
fBLDownloader = [[BlocklistDownloader alloc] init];
|
||||
[fBLDownloader startDownload];
|
||||
}
|
||||
|
||||
return fDownloader;
|
||||
return fBLDownloader;
|
||||
}
|
||||
|
||||
+ (BOOL) isRunning
|
||||
{
|
||||
return fDownloader != nil;
|
||||
return fBLDownloader != nil;
|
||||
}
|
||||
|
||||
- (void) setViewController: (BlocklistDownloaderViewController *) viewController
|
||||
|
@ -89,7 +88,7 @@ BlocklistDownloader * fDownloader = nil;
|
|||
|
||||
[[BlocklistScheduler scheduler] updateSchedule];
|
||||
|
||||
fDownloader = nil;
|
||||
fBLDownloader = nil;
|
||||
[self release];
|
||||
}
|
||||
|
||||
|
@ -128,14 +127,45 @@ BlocklistDownloader * fDownloader = nil;
|
|||
[[NSUserDefaults standardUserDefaults] setObject: [NSDate date] forKey: @"BlocklistNewLastUpdate"];
|
||||
[[BlocklistScheduler scheduler] updateSchedule];
|
||||
|
||||
fDownloader = nil;
|
||||
fBLDownloader = nil;
|
||||
[self release];
|
||||
}
|
||||
|
||||
- (void) downloadDidFinish: (NSURLDownload *) download
|
||||
{
|
||||
fState = BLOCKLIST_DL_PROCESSING;
|
||||
[self performSelectorInBackground: @selector(finishDownloadSuccess) withObject: nil];
|
||||
|
||||
[fViewController setStatusProcessing];
|
||||
|
||||
NSAssert(fDestination != nil, @"the blocklist file destination has not been specified");
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[self decompressBlocklist];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
const int count = tr_blocklistSetContent([PrefsController handle], [fDestination UTF8String]);
|
||||
|
||||
//delete downloaded file
|
||||
[[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
|
||||
|
||||
if (count > 0)
|
||||
[fViewController setFinished];
|
||||
else
|
||||
[fViewController setFailed: NSLocalizedString(@"The specified blocklist file did not contain any valid rules.",
|
||||
"blocklist fail message")];
|
||||
|
||||
//update last updated date for schedule
|
||||
NSDate * date = [NSDate date];
|
||||
[[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdate"];
|
||||
[[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdateSuccess"];
|
||||
[[BlocklistScheduler scheduler] updateSchedule];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"BlocklistUpdated" object: nil];
|
||||
|
||||
fBLDownloader = nil;
|
||||
[self release];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
- (BOOL) download: (NSURLDownload *) download shouldDecodeSourceDataOfMIMEType: (NSString *) encodingType
|
||||
|
@ -233,40 +263,4 @@ BlocklistDownloader * fDownloader = nil;
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) finishDownloadSuccess
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
[fViewController setStatusProcessing];
|
||||
|
||||
//process data
|
||||
NSAssert(fDestination != nil, @"the blocklist file destination has not been specified");
|
||||
|
||||
[self decompressBlocklist];
|
||||
|
||||
const int count = tr_blocklistSetContent([PrefsController handle], [fDestination UTF8String]);
|
||||
|
||||
//delete downloaded file
|
||||
[[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
|
||||
|
||||
if (count > 0)
|
||||
[fViewController setFinished];
|
||||
else
|
||||
[fViewController setFailed: NSLocalizedString(@"The specified blocklist file did not contain any valid rules.",
|
||||
"blocklist fail message")];
|
||||
|
||||
//update last updated date for schedule
|
||||
NSDate * date = [NSDate date];
|
||||
[[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdate"];
|
||||
[[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdateSuccess"];
|
||||
[[BlocklistScheduler scheduler] updateSchedule];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"BlocklistUpdated" object: nil];
|
||||
}
|
||||
|
||||
fDownloader = nil;
|
||||
[self release];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -37,10 +37,14 @@
|
|||
|
||||
@implementation BlocklistDownloaderViewController
|
||||
|
||||
BlocklistDownloaderViewController * fBLViewController = nil;
|
||||
+ (void) downloadWithPrefsController: (PrefsController *) prefsController
|
||||
{
|
||||
BlocklistDownloaderViewController * downloader = [[BlocklistDownloaderViewController alloc] initWithPrefsController: prefsController];
|
||||
[downloader startDownload];
|
||||
if (!fBLViewController)
|
||||
{
|
||||
fBLViewController = [[BlocklistDownloaderViewController alloc] initWithPrefsController: prefsController];
|
||||
[fBLViewController startDownload];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) awakeFromNib
|
||||
|
@ -101,6 +105,7 @@
|
|||
[NSApp endSheet: fStatusWindow];
|
||||
[fStatusWindow orderOut: self];
|
||||
|
||||
fBLViewController = nil;
|
||||
[self release];
|
||||
}
|
||||
|
||||
|
@ -148,6 +153,8 @@
|
|||
- (void) failureSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info
|
||||
{
|
||||
[[alert window] orderOut: self];
|
||||
|
||||
fBLViewController = nil;
|
||||
[self release];
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,11 @@
|
|||
BonjourController * fDefaultController = nil;
|
||||
+ (BonjourController *) defaultController
|
||||
{
|
||||
if (!fDefaultController)
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
fDefaultController = [[BonjourController alloc] init];
|
||||
});
|
||||
|
||||
return fDefaultController;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ typedef enum
|
|||
NSMutableDictionary * fPendingTorrentDownloads;
|
||||
|
||||
NSMutableSet * fAddingTransfers;
|
||||
NSMutableSet * fAddWindows;
|
||||
|
||||
BOOL fGlobalPopoverShown;
|
||||
BOOL fSoundPlaying;
|
||||
|
|
|
@ -714,6 +714,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
[fTorrents release];
|
||||
[fDisplayedTorrents release];
|
||||
|
||||
[fAddWindows release];
|
||||
[fAddingTransfers release];
|
||||
|
||||
[fOverlayWindow release];
|
||||
|
@ -901,6 +902,11 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
lockDestination: lockDestination controller: self torrentFile: torrentPath
|
||||
deleteTorrent: deleteTorrentFile canToggleDelete: canToggleDelete];
|
||||
[addController showWindow: self];
|
||||
|
||||
if (!fAddWindows)
|
||||
fAddWindows = [[NSMutableSet alloc] init];
|
||||
[fAddWindows addObject: addController];
|
||||
[addController release];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -923,7 +929,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
- (void) askOpenConfirmed: (AddWindowController *) addController add: (BOOL) add
|
||||
{
|
||||
Torrent * torrent = [addController torrent];
|
||||
[addController autorelease];
|
||||
|
||||
if (add)
|
||||
{
|
||||
|
@ -944,6 +949,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
[torrent closeRemoveTorrent: NO];
|
||||
[torrent release];
|
||||
}
|
||||
|
||||
[fAddWindows removeObject: addController];
|
||||
if ([fAddWindows count] == 0)
|
||||
{
|
||||
[fAddWindows release];
|
||||
fAddWindows = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) openMagnet: (NSString *) address
|
||||
|
@ -981,6 +993,11 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
AddMagnetWindowController * addController = [[AddMagnetWindowController alloc] initWithTorrent: torrent destination: location
|
||||
controller: self];
|
||||
[addController showWindow: self];
|
||||
|
||||
if (!fAddWindows)
|
||||
fAddWindows = [[NSMutableSet alloc] init];
|
||||
[fAddWindows addObject: addController];
|
||||
[addController release];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1002,7 +1019,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
- (void) askOpenMagnetConfirmed: (AddMagnetWindowController *) addController add: (BOOL) add
|
||||
{
|
||||
Torrent * torrent = [addController torrent];
|
||||
[addController autorelease];
|
||||
|
||||
if (add)
|
||||
{
|
||||
|
@ -1023,6 +1039,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||
[torrent closeRemoveTorrent: NO];
|
||||
[torrent release];
|
||||
}
|
||||
|
||||
[fAddWindows removeObject: addController];
|
||||
if ([fAddWindows count] == 0)
|
||||
{
|
||||
[fAddWindows release];
|
||||
fAddWindows = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) openCreatedFile: (NSNotification *) notification
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
#import "PeerProgressIndicatorCell.h"
|
||||
#import "NSStringAdditions.h"
|
||||
|
||||
#import "transmission.h" // required by utils.h
|
||||
#import "utils.h"
|
||||
|
||||
@implementation PeerProgressIndicatorCell
|
||||
|
||||
- (id) copyWithZone: (NSZone *) zone
|
||||
|
|
|
@ -38,9 +38,7 @@
|
|||
NSColor * color3 = [NSColor colorWithCalibratedRed: redComponent * 0.85 green: greenComponent * 0.85 blue: blueComponent * 0.85
|
||||
alpha: alpha];
|
||||
|
||||
NSGradient * progressGradient = [[NSGradient alloc] initWithColorsAndLocations: baseColor, 0.0, color2, 0.5, color3, 0.5,
|
||||
baseColor, 1.0, nil];
|
||||
return [progressGradient autorelease];
|
||||
return [[[NSGradient alloc] initWithColorsAndLocations: baseColor, 0.0, color2, 0.5, color3, 0.5, baseColor, 1.0, nil] autorelease];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue