[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / powermanagement / PowerManager.h
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #ifndef _POWER_MANAGER_H_
22 #define _POWER_MANAGER_H_
23 #include "IPowerSyscall.h"
24
25 // For systems without PowerSyscalls we have a NullObject
26 class CNullPowerSyscall : public IPowerSyscall
27 {
28 public:
29   virtual bool Powerdown()    { return false; }
30   virtual bool Suspend()      { return false; }
31   virtual bool Hibernate()    { return false; }
32   virtual bool Reboot()       { return false; }
33
34   virtual bool CanPowerdown() { return true; }
35   virtual bool CanSuspend()   { return true; }
36   virtual bool CanHibernate() { return true; }
37   virtual bool CanReboot()    { return true; }
38
39   virtual int  BatteryLevel() { return 0; }
40
41
42   virtual bool PumpPowerEvents(IPowerEventsCallback *callback) { return false; }
43 };
44
45 // This class will wrap and handle PowerSyscalls.
46 // It will handle and decide if syscalls are needed.
47 class CPowerManager : public IPowerEventsCallback
48 {
49 public:
50   CPowerManager();
51   ~CPowerManager();
52
53   void Initialize();
54   void SetDefaults();
55
56   bool Powerdown();
57   bool Suspend();
58   bool Hibernate();
59   bool Reboot();
60
61   bool CanPowerdown();
62   bool CanSuspend();
63   bool CanHibernate();
64   bool CanReboot();
65   
66   int  BatteryLevel();
67
68   void ProcessEvents();
69 private:
70   void OnSleep();
71   void OnWake();
72
73   void OnLowBattery();
74
75   IPowerSyscall *m_instance;
76 };
77
78 extern CPowerManager g_powerManager;
79 #endif