]> granicus.if.org Git - transmission/commitdiff
initial separation of blocklist downloader and the corresponding view
authorMitchell Livingston <livings124@transmissionbt.com>
Sun, 31 Aug 2008 19:47:11 +0000 (19:47 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sun, 31 Aug 2008 19:47:11 +0000 (19:47 +0000)
Transmission.xcodeproj/project.pbxproj
macosx/BlocklistDownloader.h
macosx/BlocklistDownloader.m
macosx/BlocklistDownloaderViewController.h [new file with mode: 0644]
macosx/BlocklistDownloaderViewController.m [new file with mode: 0644]
macosx/Controller.m
macosx/PrefsController.m

index fccd3a58bbf375a7a159f983d462bdab83f3ac0a..b8700fe6cdef6ea9e4ba61185ec9a60216239f37 100644 (file)
@@ -83,6 +83,7 @@
                A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; };
                A22180980D148A71007D09ED /* GroupsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A22180970D148A71007D09ED /* GroupsWindowController.m */; };
                A22180B60D148F0F007D09ED /* GroupsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A22180B50D148F0F007D09ED /* GroupsWindow.xib */; };
+               A222E9870E6B21D9009FB003 /* BlocklistDownloaderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A222E9860E6B21D9009FB003 /* BlocklistDownloaderViewController.m */; };
                A224D2640DAAC55F000954EA /* Peers.png in Resources */ = {isa = PBXBuildFile; fileRef = A224D2630DAAC55F000954EA /* Peers.png */; };
                A2265F420B5EF5F40093DDA5 /* FileNameCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A2265F400B5EF5F40093DDA5 /* FileNameCell.m */; };
                A226FDAC0D0CDF20005A7F71 /* libnatpmp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C7A118D0D0B2EB800B5701F /* libnatpmp.a */; };
                A22180960D148A71007D09ED /* GroupsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GroupsWindowController.h; path = macosx/GroupsWindowController.h; sourceTree = "<group>"; };
                A22180970D148A71007D09ED /* GroupsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GroupsWindowController.m; path = macosx/GroupsWindowController.m; sourceTree = "<group>"; };
                A22180B50D148F0F007D09ED /* GroupsWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = GroupsWindow.xib; path = macosx/GroupsWindow.xib; sourceTree = "<group>"; };
+               A222E9850E6B21D9009FB003 /* BlocklistDownloaderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlocklistDownloaderViewController.h; path = macosx/BlocklistDownloaderViewController.h; sourceTree = "<group>"; };
+               A222E9860E6B21D9009FB003 /* BlocklistDownloaderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BlocklistDownloaderViewController.m; path = macosx/BlocklistDownloaderViewController.m; sourceTree = "<group>"; };
                A223AA7D0D220CEB00840069 /* nl */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nl; path = macosx/nl.lproj/Creator.xib; sourceTree = "<group>"; };
                A223AA7E0D220CEB00840069 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = macosx/nl.lproj/InfoPlist.strings; sourceTree = "<group>"; };
                A223AA7F0D220CEB00840069 /* nl */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nl; path = macosx/nl.lproj/InfoWindow.xib; sourceTree = "<group>"; };
                                A2FB701B0D95CAEA0001F331 /* GroupsController.m */,
                                A2D307A20D9EC6870051FD27 /* BlocklistDownloader.h */,
                                A2D307A30D9EC6870051FD27 /* BlocklistDownloader.m */,
+                               A222E9850E6B21D9009FB003 /* BlocklistDownloaderViewController.h */,
+                               A222E9860E6B21D9009FB003 /* BlocklistDownloaderViewController.m */,
                                A2DF567C0DE323D3000795D5 /* QuickLook.h */,
                                A2DF57720DE46A6A000795D5 /* QuickLookController.h */,
                                A2DF57730DE46A6A000795D5 /* QuickLookController.m */,
                                A2725D5D0DE7507C003445E7 /* TrackerTableView.m in Sources */,
                                A28F4F770E085BDC003A3882 /* ColorTextField.m in Sources */,
                                A27F0F330E19AD9800B2DB97 /* TorrentGroup.m in Sources */,
+                               A222E9870E6B21D9009FB003 /* BlocklistDownloaderViewController.m in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 32a25fe351046f0a8d190c015131b8bd9c834198..712a5b6787fffd2115e86ff3690237eb2688283a 100644 (file)
 #import <Cocoa/Cocoa.h>
 #import <transmission.h>
 
-@class PrefsController;
+@class BlocklistDownloaderViewController;
 
 @interface BlocklistDownloader : NSObject
-{    
-    PrefsController * fPrefsController;
+{
+    NSURLDownload * fDownload;
     
-    IBOutlet NSWindow * fStatusWindow;
-    IBOutlet NSProgressIndicator * fProgressBar;
-    IBOutlet NSTextField * fTextField;
-    IBOutlet NSButton * fButton;
+    #warning have to store???
+    tr_handle * fHandle;
     
-    NSURLDownload * fDownload;
+    BlocklistDownloaderViewController * fViewController;
     
     NSUInteger fCurrentSize;
     long long fExpectedSize;
 }
 
-+ (void) downloadWithPrefsController: (PrefsController *) prefsController; //only use when no other blocklist is downloading
++ (BlocklistDownloader *) downloader: (tr_handle *) handle;
+- (void) setViewController: (BlocklistDownloaderViewController *) viewController;
 
-- (void) cancelDownload: (id) sender;
+- (void) cancelDownload;
 
 @end
index 994e72577a4960234c2c6e560669889eaa4737a4..08e1b50124347882fab25adc67d43ceac917bbd7 100644 (file)
@@ -23,8 +23,7 @@
  *****************************************************************************/
 
 #import "BlocklistDownloader.h"
-#import "PrefsController.h"
-#import "NSStringAdditions.h"
+#import "BlocklistDownloaderViewController.h"
 #import "NSApplicationAdditions.h"
 
 #define LIST_URL @"http://download.m0k.org/transmission/files/level1.gz"
 
 @interface BlocklistDownloader (Private)
 
-- (id) initWithPrefsController: (PrefsController *) prefsController;
+- (id) initWithHandle: (tr_handle *) handle;
 - (void) startDownload;
 - (void) finishDownloadSuccess;
-- (void) updateProcessString;
-- (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info;
 
 @end
 
 @implementation BlocklistDownloader
 
-+ (void) downloadWithPrefsController: (PrefsController *) prefsController
+BlocklistDownloader * fDownloader = nil;
++ (BlocklistDownloader *) downloader: (tr_handle *) handle
 {
-    BlocklistDownloader * downloader = [[BlocklistDownloader alloc] initWithPrefsController: prefsController];
-    [downloader startDownload];
+    if (!fDownloader)
+    {
+        fDownloader = [[BlocklistDownloader alloc] initWithHandle: handle];
+        [fDownloader startDownload];
+    }
+    
+    return fDownloader;
 }
 
-- (void) awakeFromNib
+- (void) setViewController: (BlocklistDownloaderViewController *) viewController
 {
-    [fButton setTitle: NSLocalizedString(@"Cancel", "Blocklist -> cancel button")];
-    
-    float oldWidth = [fButton frame].size.width;
-    [fButton sizeToFit];
-    NSRect buttonFrame = [fButton frame];
-    buttonFrame.origin.x -= buttonFrame.size.width - oldWidth;
-    [fButton setFrame: buttonFrame];
-    
-    [fTextField setStringValue: [NSLocalizedString(@"Connecting to site", "Blocklist -> message") stringByAppendingEllipsis]];
-    
-    [fProgressBar setUsesThreadedAnimation: YES];
-    [fProgressBar startAnimation: self];
+    fViewController = viewController;
+    if (fViewController)
+    {
+        #warning set actual status
+        [fViewController setStatusStarting];
+    }
 }
 
 - (void) dealloc
     [super dealloc];
 }
 
-- (void) cancelDownload: (id) sender
+- (void) cancelDownload
 {
+    [fViewController setFinished];
+    
     [fDownload cancel];
     
-    [NSApp endSheet: fStatusWindow];
-    [fStatusWindow orderOut: self];
+    fDownloader = nil;
     [self release];
 }
 
     fCurrentSize = 0;
     fExpectedSize = [response expectedContentLength];
     
-    //change from indeterminate to progress
-    [fProgressBar setIndeterminate: fExpectedSize == NSURLResponseUnknownLength];
-    [self updateProcessString];
+    [fViewController setStatusProgressForCurrentSize: fCurrentSize expectedSize: fExpectedSize];
 }
 
 - (void) download: (NSURLDownload *) download didReceiveDataOfLength: (NSUInteger) length
 {
     fCurrentSize += length;
-    [self updateProcessString];
+    [fViewController setStatusProgressForCurrentSize: fCurrentSize expectedSize: fExpectedSize];
 }
 
+#warning release?
 - (void) download: (NSURLDownload *) download didFailWithError: (NSError *) error
 {
-    [fProgressBar setHidden: YES];
-    
-    [NSApp endSheet: fStatusWindow];
-    [fStatusWindow orderOut: self];
-    
-    NSAlert * alert = [[[NSAlert alloc] init] autorelease];
-    [alert addButtonWithTitle: NSLocalizedString(@"OK", "Blocklist -> button")];
-    [alert setMessageText: NSLocalizedString(@"Download of the blocklist failed.", "Blocklist -> message")];
-    [alert setAlertStyle: NSWarningAlertStyle];
-    
-    [alert setInformativeText: [NSString stringWithFormat: @"%@ - %@", NSLocalizedString(@"Error", "Blocklist -> message"),
-        [error localizedDescription]]];
+    [fViewController setFailed: [error localizedDescription]];
     
-    [alert beginSheetModalForWindow: [fPrefsController window] modalDelegate: self
-        didEndSelector: @selector(failureSheetClosed:returnCode:contextInfo:) contextInfo: nil];
+    fDownloader = nil;
+    [self release];
 }
 
 - (void) downloadDidFinish: (NSURLDownload *) download
 
 @implementation BlocklistDownloader (Private)
 
-- (id) initWithPrefsController: (PrefsController *) prefsController
+- (id) initWithHandle: (tr_handle *) handle
 {
     if ((self = [super init]))
     {
-        fPrefsController = prefsController;
+        fHandle = handle;
     }
     
     return self;
 
 - (void) startDownload
 {
-    //load window and show as sheet
-    [NSBundle loadNibNamed: @"BlocklistStatusWindow" owner: self];
-    [NSApp beginSheet: fStatusWindow modalForWindow: [fPrefsController window] modalDelegate: nil didEndSelector: nil contextInfo: nil];
-    
-    //start the download
     NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: LIST_URL]];
     
     fDownload = [[NSURLDownload alloc] initWithRequest: request delegate: self];
 {
     NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
     
-    //change to indeterminate while processing
-    [fProgressBar setIndeterminate: YES];
-    [fProgressBar startAnimation: self];
-    
-    [fTextField setStringValue: [NSLocalizedString(@"Processing blocklist", "Blocklist -> message") stringByAppendingEllipsis]];
-    [fButton setEnabled: NO];
-    [fStatusWindow display]; //force window to be updated
+    [fViewController setStatusProcessing];
     
     //process data
-    tr_blocklistSetContent([fPrefsController handle], [DESTINATION UTF8String]);
+    tr_blocklistSetContent(fHandle, [DESTINATION UTF8String]);
     
     //delete downloaded file
     if ([NSApp isOnLeopardOrBetter])
     else
         [[NSFileManager defaultManager] removeFileAtPath: DESTINATION handler: nil];
     
-    [fPrefsController updateBlocklistFields];
+    [fViewController setFinished];
     
-    [NSApp endSheet: fStatusWindow];
-    [fStatusWindow orderOut: self];
+    #warning update date
+    [[NSNotificationCenter defaultCenter] postNotificationName: @"BlocklistUpdated" object: nil];
     
     [pool release];
-    [self release];
-}
-
-- (void) updateProcessString
-{
-    NSString * string = NSLocalizedString(@"Downloading blocklist", "Blocklist -> message");
-    if (fExpectedSize != NSURLResponseUnknownLength)
-    {
-        NSString * substring = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@", "Blocklist -> message"),
-                                [NSString stringForFileSize: fCurrentSize], [NSString stringForFileSize: fExpectedSize]];
-        string = [string stringByAppendingFormat: @" (%@)",  substring];
-        [fProgressBar setDoubleValue: (double)fCurrentSize / fExpectedSize];
-    }
     
-    [fTextField setStringValue: string];
-}
-
-- (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info
-{
-    [[alert window] orderOut: nil];
+    fDownloader = nil;
     [self release];
 }
 
diff --git a/macosx/BlocklistDownloaderViewController.h b/macosx/BlocklistDownloaderViewController.h
new file mode 100644 (file)
index 0000000..b2657d1
--- /dev/null
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * $Id$
+ *
+ * Copyright (c) 2008 Transmission authors and contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+#import <transmission.h>
+
+@class PrefsController;
+@class BlocklistDownloader;
+
+@interface BlocklistDownloaderViewController : NSObject
+{    
+    PrefsController * fPrefsController;
+    BlocklistDownloader * fDownloader;
+    
+    IBOutlet NSWindow * fStatusWindow;
+    IBOutlet NSProgressIndicator * fProgressBar;
+    IBOutlet NSTextField * fTextField;
+    IBOutlet NSButton * fButton;
+}
+
++ (void) downloadWithPrefsController: (PrefsController *) prefsController;
+
+- (void) cancelDownload: (id) sender;
+
+- (void) setStatusStarting;
+- (void) setStatusProgressForCurrentSize: (NSUInteger) currentSize expectedSize: (long long) expectedSize;
+- (void) setStatusProcessing;
+
+- (void) setFinished;
+- (void) setFailed: (NSString *) error;
+
+@end
diff --git a/macosx/BlocklistDownloaderViewController.m b/macosx/BlocklistDownloaderViewController.m
new file mode 100644 (file)
index 0000000..3831e68
--- /dev/null
@@ -0,0 +1,159 @@
+/******************************************************************************
+ * $Id$
+ *
+ * Copyright (c) 2008 Transmission authors and contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *****************************************************************************/
+
+#import "BlocklistDownloaderViewController.h"
+#import "BlocklistDownloader.h"
+#import "PrefsController.h"
+#import "NSStringAdditions.h"
+#import "NSApplicationAdditions.h"
+
+@interface BlocklistDownloaderViewController (Private)
+
+- (id) initWithPrefsController: (PrefsController *) prefsController;
+- (void) startDownload;
+- (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info;
+
+@end
+
+@implementation BlocklistDownloaderViewController
+
++ (void) downloadWithPrefsController: (PrefsController *) prefsController
+{
+    BlocklistDownloaderViewController * downloader = [[BlocklistDownloaderViewController alloc] initWithPrefsController: prefsController];
+    [downloader startDownload];
+}
+
+- (void) awakeFromNib
+{
+    [fButton setTitle: NSLocalizedString(@"Cancel", "Blocklist -> cancel button")];
+    
+    float oldWidth = [fButton frame].size.width;
+    [fButton sizeToFit];
+    NSRect buttonFrame = [fButton frame];
+    buttonFrame.origin.x -= buttonFrame.size.width - oldWidth;
+    [fButton setFrame: buttonFrame];
+    
+    [fProgressBar setUsesThreadedAnimation: YES];
+    [fProgressBar startAnimation: self];
+}
+
+- (void) cancelDownload: (id) sender
+{
+    [fDownloader cancelDownload];
+}
+
+- (void) setStatusStarting
+{
+    [fTextField setStringValue: [NSLocalizedString(@"Connecting to site", "Blocklist -> message") stringByAppendingEllipsis]];
+    [fProgressBar setIndeterminate: YES];
+}
+
+- (void) setStatusProgressForCurrentSize: (NSUInteger) currentSize expectedSize: (long long) expectedSize
+{
+    NSString * string = NSLocalizedString(@"Downloading blocklist", "Blocklist -> message");
+    if (expectedSize != NSURLResponseUnknownLength)
+    {
+        [fProgressBar setIndeterminate: NO];
+        
+        NSString * substring = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@", "Blocklist -> message"),
+                                [NSString stringForFileSize: currentSize], [NSString stringForFileSize: expectedSize]];
+        string = [string stringByAppendingFormat: @" (%@)",  substring];
+        [fProgressBar setDoubleValue: (double)currentSize / expectedSize];
+    }
+    else
+        string = [string stringByAppendingFormat: @" (%@)",  [NSString stringForFileSize: expectedSize]];
+    
+    [fTextField setStringValue: string];
+}
+
+- (void) setStatusProcessing
+{
+    //change to indeterminate while processing
+    [fProgressBar setIndeterminate: YES];
+    [fProgressBar startAnimation: self];
+    
+    [fTextField setStringValue: [NSLocalizedString(@"Processing blocklist", "Blocklist -> message") stringByAppendingEllipsis]];
+    [fButton setEnabled: NO];
+    [fStatusWindow display]; //force window to be updated
+}
+
+- (void) setFinished
+{
+    [NSApp endSheet: fStatusWindow];
+    [fStatusWindow orderOut: self];
+    
+    [self release];
+}
+
+- (void) setFailed: (NSString *) error
+{
+    #warning remove?
+    //[fProgressBar setHidden: YES];
+    
+    [NSApp endSheet: fStatusWindow];
+    [fStatusWindow orderOut: self];
+    
+    NSAlert * alert = [[[NSAlert alloc] init] autorelease];
+    [alert addButtonWithTitle: NSLocalizedString(@"OK", "Blocklist -> button")];
+    [alert setMessageText: NSLocalizedString(@"Download of the blocklist failed.", "Blocklist -> message")];
+    [alert setAlertStyle: NSWarningAlertStyle];
+    
+    [alert setInformativeText: [NSString stringWithFormat: @"%@ - %@", NSLocalizedString(@"Error", "Blocklist -> message"),
+        error]];
+    
+    [alert beginSheetModalForWindow: [fPrefsController window] modalDelegate: self
+        didEndSelector: @selector(failureSheetClosed:returnCode:contextInfo:) contextInfo: nil];
+}
+
+@end
+
+@implementation BlocklistDownloaderViewController (Private)
+
+- (id) initWithPrefsController: (PrefsController *) prefsController
+{
+    if ((self = [super init]))
+    {
+        fPrefsController = prefsController;
+    }
+    
+    return self;
+}
+
+- (void) startDownload
+{
+    //load window and show as sheet
+    [NSBundle loadNibNamed: @"BlocklistStatusWindow" owner: self];
+    [NSApp beginSheet: fStatusWindow modalForWindow: [fPrefsController window] modalDelegate: nil didEndSelector: nil contextInfo: nil];
+    
+    fDownloader = [BlocklistDownloader downloader: [fPrefsController handle]];
+    [fDownloader setViewController: self];
+}
+
+- (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info
+{
+    [[alert window] orderOut: nil];
+    [self release];
+}
+
+@end
index 80ccac5b2136a3079c8e825507aadcc66739627c..52f4d08abdcf6f320538ca58c945fb666fb987a7 100644 (file)
@@ -559,6 +559,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 
 - (void) applicationWillTerminate: (NSNotification *) notification
 {
+    #warning stop blocklist download
+    
     //stop timers and notification checking
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     
index 59b9ea913943f3bd51bc48f268b216658f8a570d..8f5f98b9eb8119e521394db1e039e1bbfa496635 100644 (file)
@@ -23,7 +23,7 @@
  *****************************************************************************/
 
 #import "PrefsController.h"
-#import "BlocklistDownloader.h"
+#import "BlocklistDownloaderViewController.h"
 #import "NSApplicationAdditions.h"
 #import "NSStringAdditions.h"
 #import "UKKQueue.h"
     return self;
 }
 
+#warning still needed? make class method?
 - (tr_handle *) handle
 {
     return fHandle;
 
 - (void) dealloc
 {
+    [[NSNotificationCenter defaultCenter] removeObserver: self];
+    
     [fPortStatusTimer invalidate];
     if (fPortChecker)
     {
     
     //set blocklist
     [self updateBlocklistFields];
+    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateBlocklistFields)
+        name: @"BlocklistUpdated" object: nil];
     
     //set rpc port
     [fRPCPortField setIntValue: [fDefaults integerForKey: @"RPCPort"]];
 
 - (void) updateBlocklist: (id) sender
 {
-    [BlocklistDownloader downloadWithPrefsController: self];
+    [BlocklistDownloaderViewController downloadWithPrefsController: self];
 }
 
 - (void) updateBlocklistFields