xbmc
PowerManager.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 "IPowerSyscall.h"
12 
13 #include <memory>
14 #include <string>
15 #include <utility>
16 #include <vector>
17 
18 class CFileItem;
19 class CSetting;
20 class CSettings;
21 
23 
24 // This class will wrap and handle PowerSyscalls.
25 // It will handle and decide if syscalls are needed.
27 {
28 public:
29  CPowerManager();
30  ~CPowerManager() override;
31 
32  void Initialize();
33  void SetDefaults();
34 
35  bool Powerdown();
36  bool Suspend();
37  bool Hibernate();
38  bool Reboot();
39 
40  bool CanPowerdown();
41  bool CanSuspend();
42  bool CanHibernate();
43  bool CanReboot();
44 
45  int BatteryLevel();
46 
47  void ProcessEvents();
48 
49  static void SettingOptionsShutdownStatesFiller(const std::shared_ptr<const CSetting>& setting,
50  std::vector<IntegerSettingOption>& list,
51  int& current,
52  void* data);
53 
54  IPowerSyscall* GetPowerSyscall() const { return m_instance.get(); }
55 
56 private:
57  void OnSleep() override;
58  void OnWake() override;
59  void OnLowBattery() override;
60  void RestorePlayerState();
61  void StorePlayerState();
62 
63  // Construction parameters
64  std::shared_ptr<CSettings> m_settings;
65 
66  std::unique_ptr<IPowerSyscall> m_instance;
67  std::unique_ptr<CFileItem> m_lastPlayedFileItem;
68  std::string m_lastUsedPlayer;
69 };
Wrapper around CSettingsManager responsible for properly setting up the settings manager and register...
Definition: Settings.h:27
Definition: IPowerSyscall.h:11
Setting base class containing all the properties which are common to all settings independent of the ...
Definition: Setting.h:46
Definition: PowerManager.h:26
Definition: IPowerSyscall.h:25
Definition: SettingDefinitions.h:66
Represents a file on a share.
Definition: FileItem.h:102