Re: Powerdown notification
Re: Powerdown notification
- Subject: Re: Powerdown notification
- From: Jean-Daniel Dupas <email@hidden>
- Date: Mon, 16 Mar 2009 15:15:50 +0100
Le 16 mars 09 à 14:54, Matthew Mashyna a écrit :
I'm sorry for having to ask a noob question. I posted this to the
Darwin user list last week but didn't get any replies. I have a
Cocoa daemon that needs to monitor system events and relay them to a
server. Using NSWorkspace notification I get sleep and wake messages
but I can't seem to get the power down notification. So, other cocoa
developers pointed me to using IOKit. I tried this from my daemon
void myPowerDownCallback(void *refcon,
io_service_t service,
uint32_t messageType,
void *messageArgument )
{
DLog(@"System shutdown message!");
[gDaemon systemWillPowerOff];
} // myPowerDownCallback
// from my initialization code
{
...
IONotificationPortRef thePortRef;
io_object_t notifier;
io_connect_t c = IORegisterForSystemPower(NULL,
&thePortRef,
myPowerDownCallback,
¬ifier );
}
I don't think the callback gets called. I suppose that it could be
interrupted before it can send its message but I really don't think
I'm getting the callback. I'm a complete noob with it comes to
IOKit. Can someone tell me where I'm going wrong ?
Thanks,
Matt
You have to create a runloop source using your IO port and add it to
the current run loop.
http://developer.apple.com/qa/qa2004/qa1340.html
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden