12#ifndef OPENVPN_APPLE_MACSLEEP_H
13#define OPENVPN_APPLE_MACSLEEP_H
15#include <mach/mach_port.h>
16#include <mach/mach_interface.h>
17#include <mach/mach_init.h>
19#include <IOKit/pwr_mgt/IOPMLib.h>
20#include <IOKit/IOMessage.h>
50 CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(
notifyPortRef), kCFRunLoopCommonModes);
60 CFRunLoopRemoveSource(CFRunLoopGetCurrent(),
62 kCFRunLoopCommonModes);
85 static void callback_static(
void *arg, io_service_t service, natural_t messageType,
void *messageArgument)
88 self->
callback(service, messageType, messageArgument);
91 void callback(io_service_t service, natural_t messageType,
void *messageArgument)
95 case kIOMessageCanSystemSleep:
96 IOAllowPowerChange(
root_port, (
long)messageArgument);
98 case kIOMessageSystemWillSleep:
100 IOAllowPowerChange(
root_port, (
long)messageArgument);
102 case kIOMessageSystemHasPoweredOn:
MacSleep(const MacSleep &)=delete
virtual void notify_wakeup()=0
io_object_t notifierObject
MacSleep & operator=(const MacSleep &)=delete
static void callback_static(void *arg, io_service_t service, natural_t messageType, void *messageArgument)
virtual void notify_sleep()=0
void callback(io_service_t service, natural_t messageType, void *messageArgument)
IONotificationPortRef notifyPortRef