if a download finishes downloading and finishes seeding at the same time, do all the "finished download" activities (dock badging, growl notification, sound); if one sound is playing for finished downloading/seeding, don't play another one

This commit is contained in:
Mitchell Livingston 2008-04-10 16:37:07 +00:00
parent 6ca3f6516b
commit afb5738b98
2 changed files with 36 additions and 18 deletions

View File

@ -114,7 +114,9 @@ typedef enum
NSMutableDictionary * fPendingTorrentDownloads;
NSMutableArray * fTempTorrentFiles;
BOOL fSoundPlaying;
BOOL fRemoteQuit;
}

View File

@ -221,6 +221,8 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
fBadger = [[Badger alloc] initWithLib: fLib];
fSoundPlaying = NO;
fIPCController = [[IPCController alloc] init];
[fIPCController setDelegate: self];
[fIPCController setPrefsController: fPrefsController];
@ -1593,24 +1595,29 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
- (void) torrentFinishedDownloading: (NSNotification *) notification
{
Torrent * torrent = [notification object];
if (!fSoundPlaying && [fDefaults boolForKey: @"PlayDownloadSound"])
{
NSSound * sound;
if ((sound = [NSSound soundNamed: [fDefaults stringForKey: @"DownloadSound"]]))
{
[sound setDelegate: self];
fSoundPlaying = YES;
[sound play];
}
}
NSDictionary * clickContext = [NSDictionary dictionaryWithObjectsAndKeys: GROWL_DOWNLOAD_COMPLETE, @"Type",
[torrent dataLocation] , @"Location", nil];
[GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Download Complete", "Growl notification title")
description: [torrent name] notificationName: GROWL_DOWNLOAD_COMPLETE
iconData: nil priority: 0 isSticky: NO clickContext: clickContext];
if (![fWindow isMainWindow])
[fBadger incrementCompleted];
if ([torrent isActive])
{
if ([fDefaults boolForKey: @"PlayDownloadSound"])
{
NSSound * sound;
if ((sound = [NSSound soundNamed: [fDefaults stringForKey: @"DownloadSound"]]))
[sound play];
}
NSDictionary * clickContext = [NSDictionary dictionaryWithObjectsAndKeys: GROWL_DOWNLOAD_COMPLETE, @"Type",
[torrent dataLocation] , @"Location", nil];
[GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Download Complete", "Growl notification title")
description: [torrent name] notificationName: GROWL_DOWNLOAD_COMPLETE
iconData: nil priority: 0 isSticky: NO clickContext: clickContext];
if (![fWindow isMainWindow])
[fBadger incrementCompleted];
if ([fDefaults boolForKey: @"QueueSeed"] && [self numToStartFromQueue: NO] <= 0)
{
[torrent stopTransfer];
@ -2341,11 +2348,15 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[fInfoController updateInfoStats];
[fInfoController updateOptions];
if ([fDefaults boolForKey: @"PlaySeedingSound"])
if (!fSoundPlaying && [fDefaults boolForKey: @"PlaySeedingSound"])
{
NSSound * sound;
if ((sound = [NSSound soundNamed: [fDefaults stringForKey: @"SeedingSound"]]))
{
[sound setDelegate: self];
fSoundPlaying = YES;
[sound play];
}
}
NSDictionary * clickContext = [NSDictionary dictionaryWithObjectsAndKeys: GROWL_SEEDING_COMPLETE, @"Type",
@ -2355,6 +2366,11 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
iconData: nil priority: 0 isSticky: NO clickContext: clickContext];
}
- (void) sound: (NSSound *) sound didFinishPlaying: (BOOL) finishedPlaying
{
fSoundPlaying = NO;
}
-(void) watcher: (id<UKFileWatcher>) watcher receivedNotification: (NSString *) notification forPath: (NSString *) path
{
if ([notification isEqualToString: UKFileWatcherWriteNotification])