1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +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
{
tr_handle_t * fLib;
int fCount, fSeeding, fDownloading, fCompleted;
int fCount, fCompleted;
NSMutableArray * fTorrents;
NSToolbar * fToolbar;

View file

@ -145,8 +145,6 @@ static void sleepCallBack( void * controller, io_service_t y,
fBadger = [[Badger alloc] init];
//update the interface every 500 ms
fDownloading = 0;
fSeeding = 0;
fCompleted = 0;
[self updateUI: nil];
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 *) messageArgument
{
NSEnumerator * enumerator;;
NSEnumerator * enumerator;
Torrent * torrent;
BOOL active;
switch( messageType )
{
@ -975,7 +974,13 @@ static void sleepCallBack( void * controller, io_service_t y,
case kIOMessageCanSystemSleep:
/* 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 );
else
IOAllowPowerChange( fRootPort, (long) messageArgument );