Check for completed download in Torrent class.
This commit is contained in:
parent
7329faccf7
commit
c251a5c5df
|
@ -131,6 +131,7 @@
|
||||||
- (void) updateControlTint: (NSNotification *) notification;
|
- (void) updateControlTint: (NSNotification *) notification;
|
||||||
|
|
||||||
- (void) updateUI: (NSTimer *) timer;
|
- (void) updateUI: (NSTimer *) timer;
|
||||||
|
- (void) torrentFinishedDownloading: (NSNotification *) notification;
|
||||||
- (void) updateTorrentHistory;
|
- (void) updateTorrentHistory;
|
||||||
|
|
||||||
- (void) sortTorrents;
|
- (void) sortTorrents;
|
||||||
|
|
|
@ -285,6 +285,9 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
//observe notifications
|
//observe notifications
|
||||||
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
|
[nc addObserver: self selector: @selector(torrentFinishedDownloading:)
|
||||||
|
name: @"TorrentFinishedDownloading" object: nil];
|
||||||
|
|
||||||
[nc addObserver: self selector: @selector(updateControlTint:)
|
[nc addObserver: self selector: @selector(updateControlTint:)
|
||||||
name: NSControlTintDidChangeNotification object: nil];
|
name: NSControlTintDidChangeNotification object: nil];
|
||||||
|
|
||||||
|
@ -839,25 +842,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
|
|
||||||
- (void) updateUI: (NSTimer *) t
|
- (void) updateUI: (NSTimer *) t
|
||||||
{
|
{
|
||||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
[fTorrents makeObjectsPerformSelector: @selector(update)];
|
||||||
Torrent * torrent;
|
|
||||||
while ((torrent = [enumerator nextObject]))
|
|
||||||
{
|
|
||||||
[torrent update];
|
|
||||||
|
|
||||||
if ([torrent justFinished])
|
|
||||||
{
|
|
||||||
[self applyFilter: nil];
|
|
||||||
[self checkToStartWaiting: torrent];
|
|
||||||
|
|
||||||
[GrowlApplicationBridge notifyWithTitle: @"Download Complete"
|
|
||||||
description: [torrent name] notificationName: GROWL_DOWNLOAD_COMPLETE iconData: nil
|
|
||||||
priority: 0 isSticky: NO clickContext: nil];
|
|
||||||
|
|
||||||
if (![fWindow isKeyWindow])
|
|
||||||
fCompleted++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([fSortType isEqualToString: @"Progress"] || [fSortType isEqualToString: @"State"])
|
if ([fSortType isEqualToString: @"Progress"] || [fSortType isEqualToString: @"State"])
|
||||||
[self sortTorrents];
|
[self sortTorrents];
|
||||||
|
@ -880,6 +865,20 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
[fBadger updateBadgeWithCompleted: fCompleted uploadRate: uploadRate downloadRate: downloadRate];
|
[fBadger updateBadgeWithCompleted: fCompleted uploadRate: uploadRate downloadRate: downloadRate];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) torrentFinishedDownloading: (NSNotification *) notification
|
||||||
|
{
|
||||||
|
Torrent * torrent = [notification object];
|
||||||
|
|
||||||
|
[self applyFilter: nil];
|
||||||
|
[self checkToStartWaiting: torrent];
|
||||||
|
|
||||||
|
[GrowlApplicationBridge notifyWithTitle: @"Download Complete" description: [torrent name]
|
||||||
|
notificationName: GROWL_DOWNLOAD_COMPLETE iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
||||||
|
|
||||||
|
if (![fWindow isKeyWindow])
|
||||||
|
fCompleted++;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) updateTorrentHistory
|
- (void) updateTorrentHistory
|
||||||
{
|
{
|
||||||
NSMutableArray * history = [NSMutableArray arrayWithCapacity: [fTorrents count]];
|
NSMutableArray * history = [NSMutableArray arrayWithCapacity: [fTorrents count]];
|
||||||
|
@ -1311,9 +1310,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
[self applyFilter: nil];
|
[self applyFilter: nil];
|
||||||
[fInfoController updateInfoStatsAndSettings];
|
[fInfoController updateInfoStatsAndSettings];
|
||||||
|
|
||||||
[GrowlApplicationBridge notifyWithTitle: @"Seeding Complete"
|
[GrowlApplicationBridge notifyWithTitle: @"Seeding Complete" description: [[notification object] name]
|
||||||
description: [[notification object] name] notificationName: GROWL_SEEDING_COMPLETE
|
notificationName: GROWL_SEEDING_COMPLETE iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
||||||
iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) attemptToStartAuto: (Torrent *) torrent
|
- (void) attemptToStartAuto: (Torrent *) torrent
|
||||||
|
@ -1420,9 +1418,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
|
|
||||||
//import only actually happened if the torrent array is larger
|
//import only actually happened if the torrent array is larger
|
||||||
if (oldCount < [fTorrents count])
|
if (oldCount < [fTorrents count])
|
||||||
[GrowlApplicationBridge notifyWithTitle: @"Torrent File Auto Added"
|
[GrowlApplicationBridge notifyWithTitle: @"Torrent File Auto Added" description: file
|
||||||
description: file notificationName: GROWL_AUTO_ADD iconData: nil
|
notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO clickContext: nil];
|
||||||
priority: 0 isSticky: NO clickContext: nil];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,10 @@
|
||||||
{
|
{
|
||||||
fStat = tr_torrentStat(fHandle);
|
fStat = tr_torrentStat(fHandle);
|
||||||
|
|
||||||
|
//notification when downloading finished
|
||||||
|
if ([self justFinished])
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
|
||||||
|
|
||||||
//check to stop for ratio
|
//check to stop for ratio
|
||||||
if ([self isSeeding] && ((fStopRatioSetting == RATIO_CHECK && [self ratio] >= fRatioLimit)
|
if ([self isSeeding] && ((fStopRatioSetting == RATIO_CHECK && [self ratio] >= fRatioLimit)
|
||||||
|| (fStopRatioSetting == RATIO_GLOBAL && [fDefaults boolForKey: @"RatioCheck"]
|
|| (fStopRatioSetting == RATIO_GLOBAL && [fDefaults boolForKey: @"RatioCheck"]
|
||||||
|
|
Loading…
Reference in New Issue