MacOS suspend mode handler draft
This commit is contained in:
parent
f767171c06
commit
5ef8254cba
2 changed files with 110 additions and 0 deletions
|
|
@ -10,8 +10,28 @@
|
|||
#include "../ios/iosnetworkwatcher.h"
|
||||
#include "networkwatcherimpl.h"
|
||||
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#include <IOKit/IOMessage.h>
|
||||
|
||||
|
||||
class QString;
|
||||
|
||||
// Inspired by https://ladydebug.com/blog/2020/05/21/programmatically-capture-energy-saver-event-on-mac/
|
||||
class PowerNotificationsListener
|
||||
{
|
||||
public:
|
||||
void registerForNotifications();
|
||||
|
||||
private:
|
||||
static void sleepWakeupCallBack(void *refParam, io_service_t service, natural_t messageType, void *messageArgument);
|
||||
|
||||
private:
|
||||
IONotificationPortRef notifyPortRef = nullptr; // notification port allocated by IORegisterForSystemPower
|
||||
io_object_t notifierObj = IO_OBJECT_NULL; // notifier object, used to deregister later
|
||||
io_connect_t rootPowerDomain = IO_OBJECT_NULL; // a reference to the Root Power Domain IOService
|
||||
};
|
||||
|
||||
|
||||
class MacOSNetworkWatcher final : public IOSNetworkWatcher {
|
||||
public:
|
||||
MacOSNetworkWatcher(QObject* parent);
|
||||
|
|
@ -25,6 +45,7 @@ class MacOSNetworkWatcher final : public IOSNetworkWatcher {
|
|||
|
||||
private:
|
||||
void* m_delegate = nullptr;
|
||||
PowerNotificationsListener m_powerlistener;
|
||||
};
|
||||
|
||||
#endif // MACOSNETWORKWATCHER_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue