Showing the changes to interface/src/MacHelper.cpp (1 of 2 files). Show all
Unified · Split
| @@ -11,32 +11,34 @@ · 10 unmodified lines | |||
| 11 | 11 | ||
| 12 | #include "InterfaceLogging.h" | 12 | #include "InterfaceLogging.h" |
| 13 | #include "MacHelper.h" | 13 | #include "MacHelper.h" |
| 14 | #include <NodeList.h> | ||
| 14 | 15 | ||
| 15 | #ifdef Q_OS_MAC | 16 | #ifdef Q_OS_MAC |
| 16 | #include <IOKit/pwr_mgt/IOPMLib.h> | ||
| 17 | #include <IOKit/IOMessage.h> | 17 | #include <IOKit/IOMessage.h> |
| 18 | 18 | #include <IOKit/pwr_mgt/IOPMLib.h> | |
| 19 | io_connect_t root_port; | 19 | |
| 20 | IONotificationPortRef notifyPortRef; | 20 | // These type definitions come from IOKit, which includes a definition of Duration that conflicts with ours. |
| 21 | io_object_t notifierObject; | 21 | // So... we include these definitions here rather than in the .h, as the .h is included in Application.cpp which |
| 22 | void* refCon; | 22 | // uses Duration. |
| 23 | static io_connect_t root_port; | ||
| 24 | static IONotificationPortRef notifyPortRef; | ||
| 25 | static io_object_t notifierObject; | ||
| 26 | static void* refCon; | ||
| 23 | 27 | ||
| 24 | void sleepHandler(void* refCon, io_service_t service, natural_t messageType, void* messageArgument) { | 28 | static void sleepHandler(void* refCon, io_service_t service, natural_t messageType, void* messageArgument) { |
| 25 | qCInfo(interfaceapp) << "HRS FIXME sleepHandler."; | ||
| 26 | if (messageType == kIOMessageSystemHasPoweredOn) { | 29 | if (messageType == kIOMessageSystemHasPoweredOn) { |
| 27 | qCInfo(interfaceapp) << "HRS FIXME Waking up from sleep or hybernation."; | 30 | qCInfo(interfaceapp) << "Waking up from sleep or hybernation."; |
| 31 | QMetaObject::invokeMethod(DependencyManager::get<NodeList>().data(), "noteAwakening", Qt::QueuedConnection); | ||
| 28 | } | 32 | } |
| 29 | } | 33 | } |
| 30 | #endif | 34 | #endif |
| 31 | 35 | ||
| 32 | MacHelper::MacHelper() { | 36 | MacHelper::MacHelper() { |
| 33 | qCInfo(interfaceapp) << "HRS FIXME Start MacHelper."; | ||
| 34 | #ifdef Q_OS_MAC | 37 | #ifdef Q_OS_MAC |
| 35 | root_port = IORegisterForSystemPower(refCon, ¬ifyPortRef, sleepHandler, ¬ifierObject); | 38 | root_port = IORegisterForSystemPower(refCon, ¬ifyPortRef, sleepHandler, ¬ifierObject); |
| 36 | if (root_port == 0) { | 39 | if (root_port == 0) { |
| 37 | qCWarning(interfaceapp) << "IORegisterForSystemPower failed"; | 40 | qCWarning(interfaceapp) << "IORegisterForSystemPower failed"; |
| 38 | } else { | 41 | return; |
| 39 | qCDebug(interfaceapp) << "HRS FIXME IORegisterForSystemPower OK"; | ||
| 40 | } | 42 | } |
| 41 | CFRunLoopAddSource(CFRunLoopGetCurrent(), | 43 | CFRunLoopAddSource(CFRunLoopGetCurrent(), |
| 42 | IONotificationPortGetRunLoopSource(notifyPortRef), | 44 | IONotificationPortGetRunLoopSource(notifyPortRef), |
| @@ -45,7 +47,6 @@ MacHelper::MacHelper() { · 2 unmodified lines | |||
| 45 | } | 47 | } |
| 46 | 48 | ||
| 47 | MacHelper::~MacHelper() { | 49 | MacHelper::~MacHelper() { |
| 48 | qCInfo(interfaceapp) << "HRS FIXME End MacHelper."; | ||
| 49 | #ifdef Q_OS_MAC | 50 | #ifdef Q_OS_MAC |
| 50 | CFRunLoopRemoveSource(CFRunLoopGetCurrent(), | 51 | CFRunLoopRemoveSource(CFRunLoopGetCurrent(), |
| 51 | IONotificationPortGetRunLoopSource(notifyPortRef), | 52 | IONotificationPortGetRunLoopSource(notifyPortRef), |