]>
Commit | Line | Data |
---|---|---|
bac41a7b A |
1 | /* |
2 | * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved. | |
3 | * | |
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 | |
8 | * using this file. | |
9 | * | |
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. | |
16 | */ | |
17 | ||
18 | ||
19 | // | |
20 | // powerwatch - hook into system notifications of power events | |
21 | // | |
22 | #ifndef _H_POWERWATCH | |
23 | #define _H_POWERWATCH | |
24 | ||
25 | #include <Security/machserver.h> | |
26 | #include <IOKit/pwr_mgt/IOPMLib.h> | |
27 | ||
28 | ||
29 | namespace Security { | |
30 | namespace MachPlusPlus { | |
31 | ||
32 | ||
33 | // | |
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. | |
38 | // | |
39 | class PowerWatcher { | |
40 | public: | |
41 | PowerWatcher(); | |
42 | virtual ~PowerWatcher(); | |
43 | ||
44 | protected: | |
45 | virtual void systemWillSleep(); | |
46 | virtual void systemIsWaking(); | |
47 | virtual void systemWillPowerDown(); | |
48 | ||
49 | protected: | |
50 | io_connect_t mKernelPort; | |
51 | IONotificationPortRef mPortRef; | |
52 | io_object_t mHandle; | |
53 | ||
54 | static void ioCallback(void *refCon, io_service_t service, | |
55 | natural_t messageType, void *argument); | |
56 | }; | |
57 | ||
58 | ||
59 | // | |
60 | // Hook into a "raw" MachServer object for event delivery | |
61 | // | |
62 | class PortPowerWatcher : public PowerWatcher, public MachServer::NoReplyHandler { | |
63 | public: | |
64 | PortPowerWatcher(); | |
65 | ~PortPowerWatcher(); | |
66 | ||
67 | boolean_t handle(mach_msg_header_t *in); | |
68 | }; | |
69 | ||
70 | ||
71 | // | |
72 | // Someone should add a RunLoopPowerWatcher class here, I suppose. | |
73 | // Well, if you need one: Tag, You're It! | |
74 | // | |
75 | ||
76 | ||
77 | } // end namespace MachPlusPlus | |
78 | ||
79 | } // end namespace Security | |
80 | ||
81 | #endif //_H_POWERWATCH |