1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

Cleaning, also fixes disabling idle sleep when torrents are active

This commit is contained in:
Eric Petit 2006-04-05 12:21:16 +00:00
parent 94fd8c9cf6
commit b7a28dd9a1
2 changed files with 10 additions and 5 deletions

View file

@ -33,7 +33,7 @@
@interface Controller : NSObject @interface Controller : NSObject
{ {
tr_handle_t * fLib; tr_handle_t * fLib;
int fCount, fSeeding, fDownloading, fCompleted; int fCount, fCompleted;
NSMutableArray * fTorrents; NSMutableArray * fTorrents;
NSToolbar * fToolbar; NSToolbar * fToolbar;

View file

@ -145,8 +145,6 @@ static void sleepCallBack( void * controller, io_service_t y,
fBadger = [[Badger alloc] init]; fBadger = [[Badger alloc] init];
//update the interface every 500 ms //update the interface every 500 ms
fDownloading = 0;
fSeeding = 0;
fCompleted = 0; fCompleted = 0;
[self updateUI: nil]; [self updateUI: nil];
fTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self fTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self
@ -943,8 +941,9 @@ static void sleepCallBack( void * controller, io_service_t y,
- (void) sleepCallBack: (natural_t) messageType argument: - (void) sleepCallBack: (natural_t) messageType argument:
(void *) messageArgument (void *) messageArgument
{ {
NSEnumerator * enumerator;; NSEnumerator * enumerator;
Torrent * torrent; Torrent * torrent;
BOOL active;
switch( messageType ) switch( messageType )
{ {
@ -975,7 +974,13 @@ static void sleepCallBack( void * controller, io_service_t y,
case kIOMessageCanSystemSleep: case kIOMessageCanSystemSleep:
/* Prevent idle sleep unless all paused */ /* Prevent idle sleep unless all paused */
if (fDownloading > 0 || fSeeding > 0) active = NO;
enumerator = [fTorrents objectEnumerator];
while( !active && ( torrent = [enumerator nextObject] ) )
if( [torrent isActive] )
active = YES;
if (active)
IOCancelPowerChange( fRootPort, (long) messageArgument ); IOCancelPowerChange( fRootPort, (long) messageArgument );
else else
IOAllowPowerChange( fRootPort, (long) messageArgument ); IOAllowPowerChange( fRootPort, (long) messageArgument );