Changeset 13253


Ignore:
Timestamp:
Mar 13, 2012, 3:20:09 AM (9 years ago)
Author:
livings124
Message:

re-add non-ARC-specific changes from r13248-50, mainly to make re-adding ARC support easier in the future

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/BlocklistDownloader.m

    r13251 r13253  
    3232- (void) startDownload;
    3333- (void) decompressBlocklist;
    34 - (void) finishDownloadSuccess;
    3534
    3635@end
     
    3837@implementation BlocklistDownloader
    3938
    40 BlocklistDownloader * fDownloader = nil;
     39BlocklistDownloader * fBLDownloader = nil;
    4140+ (BlocklistDownloader *) downloader
    4241{
    43     if (!fDownloader)
     42    if (!fBLDownloader)
    4443    {
    45         fDownloader = [[BlocklistDownloader alloc] init];
    46         [fDownloader startDownload];
     44        fBLDownloader = [[BlocklistDownloader alloc] init];
     45        [fBLDownloader startDownload];
    4746    }
    4847   
    49     return fDownloader;
     48    return fBLDownloader;
    5049}
    5150
    5251+ (BOOL) isRunning
    5352{
    54     return fDownloader != nil;
     53    return fBLDownloader != nil;
    5554}
    5655
     
    9089    [[BlocklistScheduler scheduler] updateSchedule];
    9190   
    92     fDownloader = nil;
     91    fBLDownloader = nil;
    9392    [self release];
    9493}
     
    129128    [[BlocklistScheduler scheduler] updateSchedule];
    130129   
    131     fDownloader = nil;
     130    fBLDownloader = nil;
    132131    [self release];
    133132}
     
    136135{
    137136    fState = BLOCKLIST_DL_PROCESSING;
    138     [self performSelectorInBackground: @selector(finishDownloadSuccess) withObject: nil];
     137   
     138    [fViewController setStatusProcessing];
     139   
     140    NSAssert(fDestination != nil, @"the blocklist file destination has not been specified");
     141   
     142    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
     143        [self decompressBlocklist];
     144       
     145        dispatch_async(dispatch_get_main_queue(), ^{
     146            const int count = tr_blocklistSetContent([PrefsController handle], [fDestination UTF8String]);
     147           
     148            //delete downloaded file
     149            [[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
     150           
     151            if (count > 0)
     152                [fViewController setFinished];
     153            else
     154                [fViewController setFailed: NSLocalizedString(@"The specified blocklist file did not contain any valid rules.",
     155                                                              "blocklist fail message")];
     156           
     157            //update last updated date for schedule
     158            NSDate * date = [NSDate date];
     159            [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdate"];
     160            [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdateSuccess"];
     161            [[BlocklistScheduler scheduler] updateSchedule];
     162           
     163            [[NSNotificationCenter defaultCenter] postNotificationName: @"BlocklistUpdated" object: nil];
     164           
     165            fBLDownloader = nil;
     166            [self release];
     167        });
     168    });
    139169}
    140170
     
    234264}
    235265
    236 
    237 - (void) finishDownloadSuccess
    238 {
    239     @autoreleasepool
    240     {
    241         [fViewController setStatusProcessing];
    242        
    243         //process data
    244         NSAssert(fDestination != nil, @"the blocklist file destination has not been specified");
    245        
    246         [self decompressBlocklist];
    247        
    248         const int count = tr_blocklistSetContent([PrefsController handle], [fDestination UTF8String]);
    249        
    250         //delete downloaded file
    251         [[NSFileManager defaultManager] removeItemAtPath: fDestination error: NULL];
    252        
    253         if (count > 0)
    254             [fViewController setFinished];
    255         else
    256             [fViewController setFailed: NSLocalizedString(@"The specified blocklist file did not contain any valid rules.",
    257                                             "blocklist fail message")];
    258        
    259         //update last updated date for schedule
    260         NSDate * date = [NSDate date];
    261         [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdate"];
    262         [[NSUserDefaults standardUserDefaults] setObject: date forKey: @"BlocklistNewLastUpdateSuccess"];
    263         [[BlocklistScheduler scheduler] updateSchedule];
    264        
    265         [[NSNotificationCenter defaultCenter] postNotificationName: @"BlocklistUpdated" object: nil];
    266     }
    267    
    268     fDownloader = nil;
    269     [self release];
    270 }
    271 
    272266@end
  • trunk/macosx/BlocklistDownloaderViewController.m

    r13251 r13253  
    3838@implementation BlocklistDownloaderViewController
    3939
     40BlocklistDownloaderViewController * fBLViewController = nil;
    4041+ (void) downloadWithPrefsController: (PrefsController *) prefsController
    4142{
    42     BlocklistDownloaderViewController * downloader = [[BlocklistDownloaderViewController alloc] initWithPrefsController: prefsController];
    43     [downloader startDownload];
     43    if (!fBLViewController)
     44    {
     45        fBLViewController = [[BlocklistDownloaderViewController alloc] initWithPrefsController: prefsController];
     46        [fBLViewController startDownload];
     47    }
    4448}
    4549
     
    102106    [fStatusWindow orderOut: self];
    103107   
     108    fBLViewController = nil;
    104109    [self release];
    105110}
     
    149154{
    150155    [[alert window] orderOut: self];
     156   
     157    fBLViewController = nil;
    151158    [self release];
    152159}
  • trunk/macosx/BonjourController.m

    r13251 r13253  
    3030+ (BonjourController *) defaultController
    3131{
    32     if (!fDefaultController)
     32    static dispatch_once_t onceToken;
     33    dispatch_once(&onceToken, ^{
    3334        fDefaultController = [[BonjourController alloc] init];
     35    });
     36   
    3437    return fDefaultController;
    3538}
  • trunk/macosx/Controller.h

    r13251 r13253  
    106106   
    107107    NSMutableSet                    * fAddingTransfers;
     108    NSMutableSet                    * fAddWindows;
    108109   
    109110    BOOL                            fGlobalPopoverShown;
  • trunk/macosx/Controller.m

    r13251 r13253  
    715715    [fDisplayedTorrents release];
    716716   
     717    [fAddWindows release];
    717718    [fAddingTransfers release];
    718719   
     
    902903                                                    deleteTorrent: deleteTorrentFile canToggleDelete: canToggleDelete];
    903904            [addController showWindow: self];
     905           
     906            if (!fAddWindows)
     907                fAddWindows = [[NSMutableSet alloc] init];
     908            [fAddWindows addObject: addController];
     909            [addController release];
    904910        }
    905911        else
     
    924930{
    925931    Torrent * torrent = [addController torrent];
    926     [addController autorelease];
    927932   
    928933    if (add)
     
    944949        [torrent closeRemoveTorrent: NO];
    945950        [torrent release];
     951    }
     952   
     953    [fAddWindows removeObject: addController];
     954    if ([fAddWindows count] == 0)
     955    {
     956        [fAddWindows release];
     957        fAddWindows = nil;
    946958    }
    947959}
     
    982994                                                        controller: self];
    983995        [addController showWindow: self];
     996       
     997        if (!fAddWindows)
     998            fAddWindows = [[NSMutableSet alloc] init];
     999        [fAddWindows addObject: addController];
     1000        [addController release];
    9841001    }
    9851002    else
     
    10031020{
    10041021    Torrent * torrent = [addController torrent];
    1005     [addController autorelease];
    10061022   
    10071023    if (add)
     
    10231039        [torrent closeRemoveTorrent: NO];
    10241040        [torrent release];
     1041    }
     1042   
     1043    [fAddWindows removeObject: addController];
     1044    if ([fAddWindows count] == 0)
     1045    {
     1046        [fAddWindows release];
     1047        fAddWindows = nil;
    10251048    }
    10261049}
  • trunk/macosx/PeerProgressIndicatorCell.m

    r13251 r13253  
    2525#import "PeerProgressIndicatorCell.h"
    2626#import "NSStringAdditions.h"
    27 
    28 #import "transmission.h" // required by utils.h
    29 #import "utils.h"
    3027
    3128@implementation PeerProgressIndicatorCell
  • trunk/macosx/ProgressGradients.m

    r13251 r13253  
    3939                        alpha: alpha];
    4040   
    41     NSGradient * progressGradient = [[NSGradient alloc] initWithColorsAndLocations: baseColor, 0.0, color2, 0.5, color3, 0.5,
    42                                         baseColor, 1.0, nil];
    43     return [progressGradient autorelease];
     41    return [[[NSGradient alloc] initWithColorsAndLocations: baseColor, 0.0, color2, 0.5, color3, 0.5, baseColor, 1.0, nil] autorelease];
    4442}
    4543
Note: See TracChangeset for help on using the changeset viewer.