Changeset 542


Ignore:
Timestamp:
Jul 7, 2006, 1:41:32 AM (16 years ago)
Author:
livings124
Message:

make sleep code match quit code for waiting for transfers to stop

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r539 r542  
    162162- (void) linkForums:        (id) sender;
    163163
    164 - (void) notifyGrowl: (NSString * ) title message: (NSString *) message notification: (NSString *) notification;
     164- (void) notifyGrowl: (NSString *) title message: (NSString *) message identifier: (NSString *) ident;
    165165- (void) growlRegister;
    166166
  • trunk/macosx/Controller.m

    r541 r542  
    786786       
    787787            //notifications
    788             [self notifyGrowl: @"Download Complete" message: [torrent name] notification: @"Download Complete"];
     788            [self notifyGrowl: @"Download Complete" message: [torrent name] identifier: @"Download Complete"];
    789789            if (![fWindow isKeyWindow])
    790790                fCompleted++;
     
    11741174            if (oldCount < [fTorrents count])
    11751175                [self notifyGrowl: [file stringByAppendingString: @" Auto Added"] message: @"Torrent file added"
    1176                                 notification: @"Automatically Add Torrent"];
     1176                                identifier: @"Automatically Add Torrent"];
    11771177        }
    11781178}
     
    16761676    BOOL active;
    16771677
    1678     switch( messageType )
     1678    switch (messageType)
    16791679    {
    16801680        case kIOMessageSystemWillSleep:
    1681             /* Close all connections before going to sleep and remember
    1682                we should resume when we wake up */
     1681            //close all connections before going to sleep and remember we should resume when we wake up
    16831682            [fTorrents makeObjectsPerformSelector: @selector(sleep)];
    16841683
    1685             /* Wait for torrents to stop (5 seconds timeout) */
     1684            //wait for running transfers to stop (5 second timeout)
    16861685            NSDate * start = [NSDate date];
    1687             enumerator = [fTorrents objectEnumerator];
    1688             while( ( torrent = [enumerator nextObject] ) )
    1689             {
    1690                 while( [[NSDate date] timeIntervalSinceDate: start] < 5 &&
    1691                         ![torrent isPaused] )
     1686            BOOL timeUp = NO;
     1687           
     1688            NSEnumerator * enumerator = [fTorrents objectEnumerator];
     1689            Torrent * torrent;
     1690            while (!timeUp && (torrent = [enumerator nextObject]))
     1691                while (![torrent isPaused] && !(timeUp = [start timeIntervalSinceNow] < -5.0))
    16921692                {
    1693                     usleep( 100000 );
     1693                    usleep(100000);
    16941694                    [torrent update];
    16951695                }
    1696             }
    1697 
    1698             IOAllowPowerChange( fRootPort, (long) messageArgument );
     1696
     1697            IOAllowPowerChange(fRootPort, (long) messageArgument);
    16991698            break;
    17001699
     
    17111710
    17121711            if (active)
    1713                 IOCancelPowerChange( fRootPort, (long) messageArgument );
     1712                IOCancelPowerChange(fRootPort, (long) messageArgument);
    17141713            else
    1715                 IOAllowPowerChange( fRootPort, (long) messageArgument );
     1714                IOAllowPowerChange(fRootPort, (long) messageArgument);
    17161715            break;
    17171716
    17181717        case kIOMessageSystemHasPoweredOn:
    1719             /* Resume download after we wake up */
     1718            //resume sleeping transfers after we wake up
    17201719            [fTorrents makeObjectsPerformSelector: @selector(wakeUp)];
    17211720            break;
     
    17591758}
    17601759
    1761 - (void) notifyGrowl: (NSString * ) title message: (NSString *) message notification: (NSString *) notification
     1760- (void) notifyGrowl: (NSString *) title message: (NSString *) message identifier: (NSString *) ident
    17621761{
    17631762    if (!fHasGrowl)
     
    17741773         "    end tell\n"
    17751774         "  end if\n"
    1776          "end tell", notification, title, message];
     1775         "end tell", ident, title, message];
    17771776   
    17781777    NSAppleScript * appleScript = [[NSAppleScript alloc] initWithSource: growlScript];
Note: See TracChangeset for help on using the changeset viewer.