kodi
CocoaPowerSyscall.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "powermanagement/IPowerSyscall.h"
12 
13 #include <IOKit/IOMessage.h>
14 #include <IOKit/pwr_mgt/IOPMLib.h>
15 
17 {
18 public:
20  ~CCocoaPowerSyscall() override;
21 
22  static IPowerSyscall* CreateInstance();
23  static void Register();
24 
25  bool Powerdown() override;
26  bool Suspend() override;
27  bool Hibernate() override;
28  bool Reboot() override;
29 
30  bool CanPowerdown() override;
31  bool CanSuspend() override;
32  bool CanHibernate() override;
33  bool CanReboot() override;
34  bool HasBattery();
35  int BatteryLevel() override;
36 
37  bool PumpPowerEvents(IPowerEventsCallback* callback) override;
38 
39 private:
40  void CreateOSPowerCallBacks(void);
41  void DeleteOSPowerCallBacks(void);
42  static void OSPowerCallBack(void *refcon, io_service_t service, natural_t msg_type, void *msg_arg);
43  static void OSPowerSourceCallBack(void *refcon);
44 
45  // OS Power
46  bool m_OnResume;
47  bool m_OnSuspend;
48  // OS Power Source
49  bool m_OnBattery;
50  int m_HasBattery;
51  int m_BatteryPercent;
52  bool m_SentBatteryMessage;
53 
54  io_connect_t m_root_port; // a reference to the Root Power Domain IOService
55  io_object_t m_notifier_object; // notifier object, used to deregister later
56  IONotificationPortRef m_notify_port; // notification port allocated by IORegisterForSystemPower
57  CFRunLoopSourceRef m_power_source = NULL;
58 };
Definition: CocoaPowerSyscall.h:16
bool PumpPowerEvents(IPowerEventsCallback *callback) override
Pump power related events back to xbmc.
Definition: CocoaPowerSyscall.cpp:210
Definition: IPowerSyscall.h:11
Definition: IPowerSyscall.h:25
Definition: IPowerSyscall.h:82