2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // powerwatch - hook into system notifications of power events
25 #include <Security/machserver.h>
26 #include <IOKit/pwr_mgt/IOPMLib.h>
30 namespace MachPlusPlus
{
34 // PowerWatcher embodies the ability to respond to power events.
35 // By itself, it is inert - nobody will call its virtual methods.
36 // Use one of it subclasses, which take care of "hooking" into an
37 // event delivery mechanism.
42 virtual ~PowerWatcher();
45 virtual void systemWillSleep();
46 virtual void systemIsWaking();
47 virtual void systemWillPowerDown();
50 io_connect_t mKernelPort
;
51 IONotificationPortRef mPortRef
;
54 static void ioCallback(void *refCon
, io_service_t service
,
55 natural_t messageType
, void *argument
);
60 // Hook into a "raw" MachServer object for event delivery
62 class PortPowerWatcher
: public PowerWatcher
, public MachServer::NoReplyHandler
{
67 boolean_t
handle(mach_msg_header_t
*in
);
72 // Someone should add a RunLoopPowerWatcher class here, I suppose.
73 // Well, if you need one: Tag, You're It!
77 } // end namespace MachPlusPlus
79 } // end namespace Security
81 #endif //_H_POWERWATCH