From 6bcb612a956ee17677963708cf8bec01d5f0e232 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 8 Jul 2006 13:32:36 +0000 Subject: [PATCH] Post Growl notification when seeding complete. New name for notification for torrent auto added. --- macosx/Controller.h | 2 ++ macosx/Controller.m | 31 ++++++++++++++++++++----------- macosx/Torrent.m | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/macosx/Controller.h b/macosx/Controller.h index 7a0c8c651..001cf1d54 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -140,6 +140,8 @@ - (void) torrentStartSettingChange: (NSNotification *) notification; - (void) globalStartSettingChange: (NSNotification *) notification; +- (void) torrentStoppedForRatio: (NSNotification *) notification; + - (void) attemptToStartAuto: (Torrent *) torrent; - (void) attemptToStartMultipleAuto: (NSArray *) torrents; diff --git a/macosx/Controller.m b/macosx/Controller.m index d7ea747f9..fa2a4ff35 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -241,6 +241,10 @@ static void sleepCallBack(void * controller, io_service_t y, [nc addObserver: self selector: @selector(torrentStartSettingChange:) name: @"TorrentStartSettingChange" object: nil]; + //check if torrent should now start + [nc addObserver: self selector: @selector(torrentStoppedForRatio:) + name: @"TorrentStoppedForRatio" object: nil]; + //change that just impacts the inspector [nc addObserver: self selector: @selector(reloadInspectorSettings:) name: @"TorrentSettingChange" object: nil]; @@ -459,13 +463,12 @@ static void sleepCallBack(void * controller, io_service_t y, - (void) openShowSheet: (id) sender { NSOpenPanel * panel = [NSOpenPanel openPanel]; - NSArray * fileTypes = [NSArray arrayWithObject: @"torrent"]; [panel setAllowsMultipleSelection: YES]; [panel setCanChooseFiles: YES]; [panel setCanChooseDirectories: NO]; - [panel beginSheetForDirectory: nil file: nil types: fileTypes + [panel beginSheetForDirectory: nil file: nil types: [NSArray arrayWithObject: @"torrent"] modalForWindow: fWindow modalDelegate: self didEndSelector: @selector(openSheetClosed:returnCode:contextInfo:) contextInfo: nil]; } @@ -1050,6 +1053,15 @@ static void sleepCallBack(void * controller, io_service_t y, } } +- (void) torrentStartSettingChange: (NSNotification *) notification +{ + [self attemptToStartMultipleAuto: [notification object]]; + + [self updateUI: nil]; + [fInfoController updateInfoStatsAndSettings]; + [self updateTorrentHistory]; +} + - (void) globalStartSettingChange: (NSNotification *) notification { [self attemptToStartMultipleAuto: fTorrents]; @@ -1059,13 +1071,11 @@ static void sleepCallBack(void * controller, io_service_t y, [self updateTorrentHistory]; } -- (void) torrentStartSettingChange: (NSNotification *) notification +- (void) torrentStoppedForRatio: (NSNotification *) notification { - [self attemptToStartMultipleAuto: [notification object]]; - - [self updateUI: nil]; [fInfoController updateInfoStatsAndSettings]; - [self updateTorrentHistory]; + + [self notifyGrowl: @"Seeding Complete" message: [[notification object] name] identifier: @"Seeding Complete"]; } - (void) attemptToStartAuto: (Torrent *) torrent @@ -1173,8 +1183,7 @@ static void sleepCallBack(void * controller, io_service_t y, //import only actually happened if the torrent array is larger if (oldCount < [fTorrents count]) - [self notifyGrowl: [file stringByAppendingString: @" Auto Added"] message: @"Torrent file added" - identifier: @"Automatically Add Torrent"]; + [self notifyGrowl: @"Torrent File Auto Added" message: file identifier: @"Torrent Auto Added"]; } } @@ -1804,8 +1813,8 @@ static void sleepCallBack(void * controller, io_service_t y, " if exists application process \"GrowlHelperApp\" then\n" " tell application \"GrowlHelperApp\"\n" " register as application \"Transmission\" " - " all notifications {\"Download Complete\", \"Automatically Add Torrent\"}" - " default notifications {\"Download Complete\", \"Automatically Add Torrent\"}" + " all notifications {\"Download Complete\", \"Seeding Complete\", \"Torrent Auto Added\"}" + " default notifications {\"Download Complete\", \"Seeding Complete\", \"Torrent Auto Added\"}" " icon of application \"Transmission\"\n" " end tell\n" " end if\n" diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 73cc79515..14c45f626 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -152,7 +152,7 @@ fStat = tr_torrentStat(fHandle); - [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentSettingChange" object: self]; + [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentStoppedForRatio" object: self]; } [fProgressString setString: @""];