Changeset 707


Ignore:
Timestamp:
Jul 30, 2006, 6:37:29 PM (15 years ago)
Author:
livings124
Message:

Check for completed download in Torrent class.

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r706 r707  
    132132
    133133- (void) updateUI: (NSTimer *) timer;
     134- (void) torrentFinishedDownloading: (NSNotification *) notification;
    134135- (void) updateTorrentHistory;
    135136
  • trunk/macosx/Controller.m

    r706 r707  
    285285    //observe notifications
    286286    NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
     287   
     288    [nc addObserver: self selector: @selector(torrentFinishedDownloading:)
     289                    name: @"TorrentFinishedDownloading" object: nil];
    287290   
    288291    [nc addObserver: self selector: @selector(updateControlTint:)
     
    840843- (void) updateUI: (NSTimer *) t
    841844{
    842     NSEnumerator * enumerator = [fTorrents objectEnumerator];
    843     Torrent * torrent;
    844     while ((torrent = [enumerator nextObject]))
    845     {
    846         [torrent update];
    847 
    848         if ([torrent justFinished])
    849         {
    850             [self applyFilter: nil];
    851             [self checkToStartWaiting: torrent];
    852        
    853             [GrowlApplicationBridge notifyWithTitle: @"Download Complete"
    854                 description: [torrent name] notificationName: GROWL_DOWNLOAD_COMPLETE iconData: nil
    855                 priority: 0 isSticky: NO clickContext: nil];
    856 
    857             if (![fWindow isKeyWindow])
    858                 fCompleted++;
    859         }
    860     }
     845    [fTorrents makeObjectsPerformSelector: @selector(update)];
    861846
    862847    if ([fSortType isEqualToString: @"Progress"] || [fSortType isEqualToString: @"State"])
     
    879864    //badge dock
    880865    [fBadger updateBadgeWithCompleted: fCompleted uploadRate: uploadRate downloadRate: downloadRate];
     866}
     867
     868- (void) torrentFinishedDownloading: (NSNotification *) notification
     869{
     870    Torrent * torrent = [notification object];
     871
     872    [self applyFilter: nil];
     873    [self checkToStartWaiting: torrent];
     874
     875    [GrowlApplicationBridge notifyWithTitle: @"Download Complete" description: [torrent name]
     876        notificationName: GROWL_DOWNLOAD_COMPLETE iconData: nil priority: 0 isSticky: NO clickContext: nil];
     877
     878    if (![fWindow isKeyWindow])
     879        fCompleted++;
    881880}
    882881
     
    13121311    [fInfoController updateInfoStatsAndSettings];
    13131312   
    1314     [GrowlApplicationBridge notifyWithTitle: @"Seeding Complete"
    1315                 description: [[notification object] name] notificationName: GROWL_SEEDING_COMPLETE
    1316                 iconData: nil priority: 0 isSticky: NO clickContext: nil];
     1313    [GrowlApplicationBridge notifyWithTitle: @"Seeding Complete" description: [[notification object] name]
     1314        notificationName: GROWL_SEEDING_COMPLETE iconData: nil priority: 0 isSticky: NO clickContext: nil];
    13171315}
    13181316
     
    14211419            //import only actually happened if the torrent array is larger
    14221420            if (oldCount < [fTorrents count])
    1423                 [GrowlApplicationBridge notifyWithTitle: @"Torrent File Auto Added"
    1424                     description: file notificationName: GROWL_AUTO_ADD iconData: nil
    1425                     priority: 0 isSticky: NO clickContext: nil];
     1421                [GrowlApplicationBridge notifyWithTitle: @"Torrent File Auto Added" description: file
     1422                    notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO clickContext: nil];
    14261423        }
    14271424}
  • trunk/macosx/Torrent.m

    r700 r707  
    144144    fStat = tr_torrentStat(fHandle);
    145145   
     146    //notification when downloading finished
     147    if ([self justFinished])
     148        [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
     149   
    146150    //check to stop for ratio
    147151    if ([self isSeeding] && ((fStopRatioSetting == RATIO_CHECK && [self ratio] >= fRatioLimit)
Note: See TracChangeset for help on using the changeset viewer.