Changeset 5578


Ignore:
Timestamp:
Apr 10, 2008, 4:37:07 PM (14 years ago)
Author:
livings124
Message:

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

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r5404 r5578  
    115115    NSMutableDictionary             * fPendingTorrentDownloads;
    116116    NSMutableArray                  * fTempTorrentFiles;
    117 
     117   
     118    BOOL                            fSoundPlaying;
     119   
    118120    BOOL                            fRemoteQuit;
    119121}
  • trunk/macosx/Controller.m

    r5535 r5578  
    221221       
    222222        fBadger = [[Badger alloc] initWithLib: fLib];
     223       
     224        fSoundPlaying = NO;
    223225       
    224226        fIPCController = [[IPCController alloc] init];
     
    15941596{
    15951597    Torrent * torrent = [notification object];
     1598   
     1599    if (!fSoundPlaying && [fDefaults boolForKey: @"PlayDownloadSound"])
     1600    {
     1601        NSSound * sound;
     1602        if ((sound = [NSSound soundNamed: [fDefaults stringForKey: @"DownloadSound"]]))
     1603        {
     1604            [sound setDelegate: self];
     1605            fSoundPlaying = YES;
     1606            [sound play];
     1607        }
     1608    }
     1609   
     1610    NSDictionary * clickContext = [NSDictionary dictionaryWithObjectsAndKeys: GROWL_DOWNLOAD_COMPLETE, @"Type",
     1611                                    [torrent dataLocation] , @"Location", nil];
     1612    [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Download Complete", "Growl notification title")
     1613                                description: [torrent name] notificationName: GROWL_DOWNLOAD_COMPLETE
     1614                                iconData: nil priority: 0 isSticky: NO clickContext: clickContext];
     1615   
     1616    if (![fWindow isMainWindow])
     1617        [fBadger incrementCompleted];
     1618   
    15961619    if ([torrent isActive])
    15971620    {
    1598         if ([fDefaults boolForKey: @"PlayDownloadSound"])
    1599         {
    1600             NSSound * sound;
    1601             if ((sound = [NSSound soundNamed: [fDefaults stringForKey: @"DownloadSound"]]))
    1602                 [sound play];
    1603         }
    1604        
    1605         NSDictionary * clickContext = [NSDictionary dictionaryWithObjectsAndKeys: GROWL_DOWNLOAD_COMPLETE, @"Type",
    1606                                         [torrent dataLocation] , @"Location", nil];
    1607         [GrowlApplicationBridge notifyWithTitle: NSLocalizedString(@"Download Complete", "Growl notification title")
    1608                                     description: [torrent name] notificationName: GROWL_DOWNLOAD_COMPLETE
    1609                                     iconData: nil priority: 0 isSticky: NO clickContext: clickContext];
    1610        
    1611         if (![fWindow isMainWindow])
    1612             [fBadger incrementCompleted];
    1613        
    16141621        if ([fDefaults boolForKey: @"QueueSeed"] && [self numToStartFromQueue: NO] <= 0)
    16151622        {
     
    23422349    [fInfoController updateOptions];
    23432350   
    2344     if ([fDefaults boolForKey: @"PlaySeedingSound"])
     2351    if (!fSoundPlaying && [fDefaults boolForKey: @"PlaySeedingSound"])
    23452352    {
    23462353        NSSound * sound;
    23472354        if ((sound = [NSSound soundNamed: [fDefaults stringForKey: @"SeedingSound"]]))
     2355        {
     2356            [sound setDelegate: self];
     2357            fSoundPlaying = YES;
    23482358            [sound play];
     2359        }
    23492360    }
    23502361   
     
    23542365                        description: [torrent name] notificationName: GROWL_SEEDING_COMPLETE
    23552366                        iconData: nil priority: 0 isSticky: NO clickContext: clickContext];
     2367}
     2368
     2369- (void) sound: (NSSound *) sound didFinishPlaying: (BOOL) finishedPlaying
     2370{
     2371    fSoundPlaying = NO;
    23562372}
    23572373
Note: See TracChangeset for help on using the changeset viewer.