Changeset 6671


Ignore:
Timestamp:
Aug 31, 2008, 8:48:10 PM (13 years ago)
Author:
livings124
Message:

some more streamlining of the blocklist code

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/BlocklistDownloader.h

    r6669 r6671  
    2424
    2525#import <Cocoa/Cocoa.h>
    26 #import <transmission.h>
    2726
    2827@class BlocklistDownloaderViewController;
     
    3231    NSURLDownload * fDownload;
    3332   
    34     #warning have to store???
    35     tr_handle * fHandle;
    36    
    3733    BlocklistDownloaderViewController * fViewController;
    3834   
     
    4137}
    4238
    43 + (BlocklistDownloader *) downloader: (tr_handle *) handle; //starts download if not already occuring
     39+ (BlocklistDownloader *) downloader; //starts download if not already occuring
    4440+ (BOOL) isRunning;
    4541
  • trunk/macosx/BlocklistDownloader.m

    r6669 r6671  
    2525#import "BlocklistDownloader.h"
    2626#import "BlocklistDownloaderViewController.h"
     27#import "PrefsController.h"
    2728#import "NSApplicationAdditions.h"
    2829
     
    3233@interface BlocklistDownloader (Private)
    3334
    34 - (id) initWithHandle: (tr_handle *) handle;
    3535- (void) startDownload;
    3636- (void) finishDownloadSuccess;
     
    4141
    4242BlocklistDownloader * fDownloader = nil;
    43 + (BlocklistDownloader *) downloader: (tr_handle *) handle
     43+ (BlocklistDownloader *) downloader
    4444{
    4545    if (!fDownloader)
    4646    {
    47         fDownloader = [[BlocklistDownloader alloc] initWithHandle: handle];
     47        fDownloader = [[BlocklistDownloader alloc] init];
    4848        [fDownloader startDownload];
    4949    }
     
    117117@implementation BlocklistDownloader (Private)
    118118
    119 - (id) initWithHandle: (tr_handle *) handle
    120 {
    121     if ((self = [super init]))
    122     {
    123         fHandle = handle;
    124     }
    125    
    126     return self;
    127 }
    128 
    129119- (void) startDownload
    130120{
     
    142132   
    143133    //process data
    144     tr_blocklistSetContent(fHandle, [DESTINATION UTF8String]);
     134    tr_blocklistSetContent([PrefsController handle], [DESTINATION UTF8String]);
    145135   
    146136    //delete downloaded file
  • trunk/macosx/BlocklistDownloaderViewController.h

    r6667 r6671  
    2727
    2828@class PrefsController;
    29 @class BlocklistDownloader;
    3029
    3130@interface BlocklistDownloaderViewController : NSObject
    3231{   
    3332    PrefsController * fPrefsController;
    34     BlocklistDownloader * fDownloader;
    3533   
    3634    IBOutlet NSWindow * fStatusWindow;
  • trunk/macosx/BlocklistDownloaderViewController.m

    r6668 r6671  
    6060- (void) cancelDownload: (id) sender
    6161{
    62     [fDownloader cancelDownload];
     62    [[BlocklistDownloader downloader] cancelDownload];
    6363}
    6464
     
    143143    [NSApp beginSheet: fStatusWindow modalForWindow: [fPrefsController window] modalDelegate: nil didEndSelector: nil contextInfo: nil];
    144144   
    145     fDownloader = [BlocklistDownloader downloader: [fPrefsController handle]];
    146     [fDownloader setViewController: self];
     145    BlocklistDownloader * downloader = [BlocklistDownloader downloader];
     146    [downloader setViewController: self];
    147147}
    148148
  • trunk/macosx/Controller.m

    r6669 r6671  
    242242        fMessageController = [[MessageWindowController alloc] init];
    243243        fInfoController = [[InfoWindowController alloc] init];
    244         fPrefsController = [[PrefsController alloc] initWithHandle: fLib];
     244       
     245        [PrefsController setHandle: fLib];
     246        fPrefsController = [[PrefsController alloc] init];
    245247       
    246248        fBadger = [[Badger alloc] initWithLib: fLib];
     
    563565    //stop blocklist download
    564566    if ([BlocklistDownloader isRunning])
    565         [[BlocklistDownloader downloader: fLib] cancelDownload];
     567        [[BlocklistDownloader downloader] cancelDownload];
    566568   
    567569    //stop timers and notification checking
  • trunk/macosx/PrefsController.h

    r6529 r6671  
    2929@interface PrefsController : NSWindowController
    3030{
    31     tr_handle * fHandle;
    32    
    3331    NSUserDefaults * fDefaults;
    3432    BOOL fHasLoaded;
     
    6462}
    6563
    66 - (id) initWithHandle: (tr_handle *) handle;
    67 - (tr_handle *) handle;
     64+ (void) setHandle: (tr_handle *) handle;
     65+ (tr_handle *) handle;
    6866
    6967- (void) updatePortField;
  • trunk/macosx/PrefsController.m

    r6667 r6671  
    7171@implementation PrefsController
    7272
    73 - (id) initWithHandle: (tr_handle *) handle
     73tr_handle * fHandle;
     74+ (void) setHandle: (tr_handle *) handle
     75{
     76    fHandle = handle;
     77}
     78
     79+ (tr_handle *) handle
     80{
     81    return fHandle;
     82}
     83
     84- (id) init
    7485{
    7586    if ((self = [super initWithWindowNibName: @"PrefsWindow"]))
    7687    {
    7788        fDefaults = [NSUserDefaults standardUserDefaults];
    78         fHandle = handle;
    7989       
    8090        //checks for old version speeds of -1
     
    126136   
    127137    return self;
    128 }
    129 
    130 #warning still needed? make class method?
    131 - (tr_handle *) handle
    132 {
    133     return fHandle;
    134138}
    135139
Note: See TracChangeset for help on using the changeset viewer.