diff --git a/macosx/Controller.m b/macosx/Controller.m index 210ad6a0d..bc50fd482 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1842,12 +1842,13 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy { filtering = YES; + #warning check multiple trackers NSString * filterType = [fDefaults stringForKey: @"FilterSearchType"]; NSString * fullString; Torrent * torrent; int i; - for (i = [tempTorrents count] - 1; i >= 0; i--) + for (i = [tempTorrents count]-1; i >= 0; i--) { torrent = [tempTorrents objectAtIndex: i]; if ([filterType isEqualToString: FILTER_TYPE_TRACKER]) @@ -3034,7 +3035,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy { NSEnumerator * enumerator; Torrent * torrent; - BOOL active; + BOOL active, canSleep; switch (messageType) { @@ -3058,20 +3059,24 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy break; case kIOMessageCanSystemSleep: - //pevent idle sleep unless all paused - active = NO; - enumerator = [fTorrents objectEnumerator]; - while ((torrent = [enumerator nextObject])) - if ([torrent isActive] && ![torrent isStalled] && ![torrent isError]) - { - active = YES; - break; - } + + canSleep = YES; + if ([fDefaults boolForKey: @"SleepPrevent"]) + { + //prevent idle sleep unless all inactive + enumerator = [fTorrents objectEnumerator]; + while ((torrent = [enumerator nextObject])) + if ([torrent isActive] && ![torrent isStalled] && ![torrent isError]) + { + canSleep = NO; + break; + } + } - if (active) - IOCancelPowerChange(fRootPort, (long) messageArgument); - else + if (canSleep) IOAllowPowerChange(fRootPort, (long) messageArgument); + else + IOCancelPowerChange(fRootPort, (long) messageArgument); break; case kIOMessageSystemHasPoweredOn: diff --git a/macosx/Defaults.plist b/macosx/Defaults.plist index 0f17a9145..16dfe3632 100644 --- a/macosx/Defaults.plist +++ b/macosx/Defaults.plist @@ -84,6 +84,8 @@ Submarine ShowInspector + SleepPrevent + SmallStatusRegular SmallView diff --git a/macosx/English.lproj/PrefsWindow.nib/info.nib b/macosx/English.lproj/PrefsWindow.nib/info.nib index c8ca51ff1..d5545df91 100644 --- a/macosx/English.lproj/PrefsWindow.nib/info.nib +++ b/macosx/English.lproj/PrefsWindow.nib/info.nib @@ -3,17 +3,17 @@ IBDocumentLocation - 19 79 356 240 0 0 1152 842 + 32 103 356 240 0 0 1680 1028 IBEditorPositions 153 - 294 444 563 268 0 0 1152 842 + 558 568 583 268 0 0 1680 1028 28 - 138 430 563 313 0 0 1152 842 + 558 511 583 348 0 0 1680 1028 41 - 294 426 563 305 0 0 1152 842 + 548 550 583 305 0 0 1680 1028 66 - 294 506 563 144 0 0 1152 842 + 334 527 583 144 0 0 1680 1028 IBFramework Version 446.1 @@ -23,9 +23,9 @@ IBOpenObjects - 28 + 153 IBSystem Version - 8R218 + 8R4031 diff --git a/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib b/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib index 00d7a1734..2c4717afd 100644 Binary files a/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib and b/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib differ