- (id) initWithPrefsController: (PrefsController *) prefsController;
- (void) startDownload;
+- (void) finishDownloadSuccess;
- (void) updateProcessString;
- (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info;
- (void) downloadDidFinish: (NSURLDownload *) download
{
- //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
-
- //process data
- tr_blocklistSetContent([fPrefsController handle], [DESTINATION UTF8String]);
-
- //delete downloaded file
if ([NSApp isOnLeopardOrBetter])
- [[NSFileManager defaultManager] removeItemAtPath: DESTINATION error: NULL];
+ [self performSelectorInBackground: @selector(finishDownloadSuccess) withObject: nil];
else
- [[NSFileManager defaultManager] removeFileAtPath: DESTINATION handler: nil];
-
- [fPrefsController updateBlocklistFields];
-
- [NSApp endSheet: fStatusWindow];
- [fStatusWindow orderOut: self];
- [self release];
+ [self finishDownloadSuccess];
}
@end
[fDownload setDestination: DESTINATION allowOverwrite: YES];
}
+- (void) finishDownloadSuccess
+{
+ //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
+
+ //process data
+ tr_blocklistSetContent([fPrefsController handle], [DESTINATION UTF8String]);
+
+ //delete downloaded file
+ if ([NSApp isOnLeopardOrBetter])
+ [[NSFileManager defaultManager] removeItemAtPath: DESTINATION error: NULL];
+ else
+ [[NSFileManager defaultManager] removeFileAtPath: DESTINATION handler: nil];
+
+ [fPrefsController updateBlocklistFields];
+
+ [NSApp endSheet: fStatusWindow];
+ [fStatusWindow orderOut: self];
+ [self release];
+}
+
- (void) updateProcessString
{
NSString * string = NSLocalizedString(@"Downloading blocklist", "Blocklist -> message");