site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer; bh=wO7RV0Lq4IOJy4jpi4A2NuWm4Ih7gYBAVabErR/J9xo=; b=OVs16CpiXYGrfvWRREXV5bec5qian8hQoBbG20C90+y12hfIb0wDrivjqvx10iCjYnRKFCcv5Zo0mTonxxqkff2SgO7uM4ugK3NbLVnyW16HFwhh7As8CKQsLtRvIiy+a5OJluennd3QSYYXpTJtGBITOSxehL0NNX/VfmqjFV4= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer; b=yFQ6cO4yzUOdPPD4loZDdBxBXYG5MFFK3SPTzbussc53ufYmiActdYkwXLwDfJXkvKPoDo3gzmqK8ua9byGTKzqWCVhGQjSlF8BbQAqL80ij0oZfcbdarDcvniDHJtie6/RMJgkeP0blBiT0ecaliXSldsekZYuWMgGSonfd5PA= On 30/12/2007, at 12:44 AM, Brian Bergstrand wrote: On Dec 29, 2007, at 1:35 PM, Andrew James wrote: Hi, #import <IOKit/IOMessage.h> #import <IOKit/pwr_mgt/IOPMLib.h> static io_connect_t powerPort = (io_connect_t)0; static void iokpm_callback (void *, io_service_t, natural_t, void*); case kIOMessageCanSystemPowerOff: if (dontIdleSleep) { IOCancelPowerChange(powerPort, (long)arg); } else IOAllowPowerChange(powerPort, (long)arg); break; default: break; } } Brian Bergstrand <http://www.bergstrand.org/brian/> PGP Key ID: 0xB6C7B6A2 _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Sorry i forgot to mention i am working from within a kext here, will i still be able to use that code or is there another way that will let me fulfill my original request since i am coding in a kext How do i cancel a sleep event from happening, along with things like the lid closing and causing a sleep. _______________________________________________ You can only cancel idle sleep, not user initiated sleep (via the power button, the Sleep menu, or closing the lid. int main(int argc, char* argv[]) { IONotificationPortRef portRef; io_object_t notifier; CFRunLoopSourceRef source; powerPort = IORegisterForSystemPower (NULL, &portRef, iokpm_callback, ¬ifier); if (powerPort) { source = IONotificationPortGetRunLoopSource(portRef); CFRunLoopAddSource([[NSRunLoop currentRunLoop] getCFRunLoop], source, kCFRunLoopCommonModes); } [[NSRunLoop currentRunLoop] run]; } static void iokpm_callback (void *myData, io_service_t service, natural_t message, void *arg) { switch(message) { // must always respond to the power state change messages case kIOMessageSystemWillSleep: case kIOMessageCanSystemSleep: // we can't prevent user initiated power off, only idle power off case kIOMessageSystemWillPowerOff: case kIOMessageSystemWillRestart: IOAllowPowerChange(powerPort, (long)arg); break; This email sent to site_archiver@lists.apple.com
participants (1)
-
Andrew James