From d581251a181ebb73777f9f6350e930e775b1efb1 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 17 Apr 2008 04:25:49 +0000 Subject: [PATCH] the blocklist downloader should get the tr_handle from the prefs controller instead of needing it passed separately --- macosx/BlocklistDownloader.h | 3 +-- macosx/BlocklistDownloader.m | 11 +++++------ macosx/PrefsController.h | 1 + macosx/PrefsController.m | 7 ++++++- macosx/Torrent.m | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/macosx/BlocklistDownloader.h b/macosx/BlocklistDownloader.h index 1802b8009..e33302bd9 100644 --- a/macosx/BlocklistDownloader.h +++ b/macosx/BlocklistDownloader.h @@ -30,7 +30,6 @@ @interface BlocklistDownloader : NSObject { PrefsController * fPrefsController; - tr_handle * fHandle; IBOutlet NSWindow * fStatusWindow; IBOutlet NSProgressIndicator * fProgressBar; @@ -43,7 +42,7 @@ long long fExpectedSize; } -+ (id) downloadWithPrefsController: (PrefsController *) prefsController withHandle: (tr_handle *) handle; ++ (id) downloadWithPrefsController: (PrefsController *) prefsController; - (void) cancelDownload: (id) sender; diff --git a/macosx/BlocklistDownloader.m b/macosx/BlocklistDownloader.m index e390ef8f0..0e1a93bd7 100644 --- a/macosx/BlocklistDownloader.m +++ b/macosx/BlocklistDownloader.m @@ -32,7 +32,7 @@ @interface BlocklistDownloader (Private) -- (id) initWithPrefsController: (PrefsController *) prefsController withHandle: (tr_handle *) handle; +- (id) initWithPrefsController: (PrefsController *) prefsController; - (void) startDownload; - (void) updateProcessString; - (void) failureSheetClosed: (NSAlert *) alert returnCode: (int) code contextInfo: (void *) info; @@ -41,9 +41,9 @@ @implementation BlocklistDownloader -+ (id) downloadWithPrefsController: (PrefsController *) prefsController withHandle: (tr_handle *) handle ++ (id) downloadWithPrefsController: (PrefsController *) prefsController { - BlocklistDownloader * downloader = [[BlocklistDownloader alloc] initWithPrefsController: prefsController withHandle: handle]; + BlocklistDownloader * downloader = [[BlocklistDownloader alloc] initWithPrefsController: prefsController]; [downloader startDownload]; } @@ -117,7 +117,7 @@ [fStatusWindow display]; //force window to be updated //process data - tr_blocklistSetContent(fHandle, [DESTINATION UTF8String]); + tr_blocklistSetContent([fPrefsController handle], [DESTINATION UTF8String]); //delete downloaded file if ([NSApp isOnLeopardOrBetter]) @@ -136,12 +136,11 @@ @implementation BlocklistDownloader (Private) -- (id) initWithPrefsController: (PrefsController *) prefsController withHandle: (tr_handle *) handle +- (id) initWithPrefsController: (PrefsController *) prefsController { if ((self = [super init])) { fPrefsController = prefsController; - fHandle = handle; } return self; diff --git a/macosx/PrefsController.h b/macosx/PrefsController.h index e36b78e8e..1fac6fd29 100644 --- a/macosx/PrefsController.h +++ b/macosx/PrefsController.h @@ -59,6 +59,7 @@ } - (id) initWithHandle: (tr_handle *) handle; +- (tr_handle *) handle; - (void) setUpdater: (SUUpdater *) updater; - (void) updatePortField; diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index c1b329154..2c5e3e1e3 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -98,6 +98,11 @@ return self; } +- (tr_handle *) handle +{ + return fHandle; +} + - (void) dealloc { if (fPortStatusTimer) @@ -374,7 +379,7 @@ - (void) updateBlocklist: (id) sender { - [BlocklistDownloader downloadWithPrefsController: self withHandle: fHandle]; + [BlocklistDownloader downloadWithPrefsController: self]; } - (void) updateBlocklistFields diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 423b4bb9c..58ae407d5 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -386,7 +386,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * float stopRatio, ratio; if ((stopRatio = [self actualStopRatio]) == INVALID || (ratio = [self ratio]) >= stopRatio) return 1.0; - else if (ratio > 0 && stopRatio > 0) + else if (stopRatio > 0) return ratio / stopRatio; else return 0;