MythTV  master
mythpowerdbus.h
Go to the documentation of this file.
1 #ifndef MYTHPOWERDBUS_H
2 #define MYTHPOWERDBUS_H
3 
4 // Qt
5 #include <QtDBus>
6 
7 // MythTV
8 #include "mythpower.h"
9 
10 class MythPowerDBus : public MythPower
11 {
12  Q_OBJECT
13 
14  friend class MythPower;
15 
16  public:
17  static bool IsAvailable(void);
18 
19  public slots:
20  void CancelFeature(void) override;
21  void Changed (void);
22  void DeviceAdded (const QDBusObjectPath& Device);
23  void DeviceRemoved (const QDBusObjectPath& Device);
24  void DeviceChanged (const QDBusObjectPath& Device);
25  void DBusSuspending (bool Stopping);
26  void DBusShuttingDown (bool Stopping);
27 
28  protected slots:
29  void ReleaseLock (void);
30 
31  protected:
32  MythPowerDBus();
33  ~MythPowerDBus() override;
34 
35  void Init (void) override;
36  bool DoFeature (bool Delayed = false) override;
37  void DidWakeUp (void) override;
38  bool ScheduleFeature (enum Feature Type, uint Delay) override;
39 
40  private:
41  bool UpdateStatus (void);
42  int RetrieveBatteryLevel(const QString &Path);
43  void UpdateBattery (void);
44  void UpdateProperties (void);
45  void AcquireLock (Features Types);
46 
47  bool m_onBattery { false };
48  QMap<QString,int> m_batteries { };
49  QDBusConnection m_bus { QDBusConnection::systemBus() };
50  QDBusInterface *m_upowerInterface { nullptr };
51  QDBusInterface *m_logindInterface { nullptr };
52  int m_lockHandle { -1 };
53  QTimer m_delayTimer { };
54 };
55 
56 #endif // MYTHPOWERDBUS_H
MythPower
Definition: mythpower.h:19
MythPowerDBus::UpdateBattery
void UpdateBattery(void)
Definition: mythpowerdbus.cpp:432
MythPowerDBus::DeviceChanged
void DeviceChanged(const QDBusObjectPath &Device)
Update power device state.
Definition: mythpowerdbus.cpp:389
MythPowerDBus::UpdateStatus
bool UpdateStatus(void)
Definition: mythpowerdbus.cpp:217
MythPowerDBus::DidWakeUp
void DidWakeUp(void) override
Definition: mythpowerdbus.cpp:265
MythPowerDBus::DBusShuttingDown
void DBusShuttingDown(bool Stopping)
Definition: mythpowerdbus.cpp:201
MythPowerDBus::m_delayTimer
QTimer m_delayTimer
Definition: mythpowerdbus.h:53
MythPowerDBus
Definition: mythpowerdbus.h:11
Device
A device containing images (ie. USB stick, CD, storage group etc)
Definition: imagemanager.cpp:34
MythPowerDBus::DeviceAdded
void DeviceAdded(const QDBusObjectPath &Device)
Definition: mythpowerdbus.cpp:360
MythPowerDBus::ReleaseLock
void ReleaseLock(void)
Release our inhibition lock.
Definition: mythpowerdbus.cpp:553
MythPowerDBus::DoFeature
bool DoFeature(bool Delayed=false) override
Definition: mythpowerdbus.cpp:164
MythPowerDBus::Init
void Init(void) override
Definition: mythpowerdbus.cpp:77
MythPowerDBus::m_onBattery
bool m_onBattery
Definition: mythpowerdbus.h:47
MythPowerDBus::m_bus
QDBusConnection m_bus
Definition: mythpowerdbus.h:49
MythPowerDBus::m_upowerInterface
QDBusInterface * m_upowerInterface
Definition: mythpowerdbus.h:50
MythPowerDBus::IsAvailable
static bool IsAvailable(void)
Static check for DBus interfaces that support some form of power management.
Definition: mythpowerdbus.cpp:41
MythPowerDBus::DBusSuspending
void DBusSuspending(bool Stopping)
Definition: mythpowerdbus.cpp:185
MythPowerDBus::CancelFeature
void CancelFeature(void) override
This is untested.
Definition: mythpowerdbus.cpp:344
MythPowerDBus::m_batteries
QMap< QString, int > m_batteries
Definition: mythpowerdbus.h:48
MythPowerDBus::AcquireLock
void AcquireLock(Features Types)
Acquire an inhibition lock for logind power events.
Definition: mythpowerdbus.cpp:514
MythPowerDBus::Changed
void Changed(void)
Definition: mythpowerdbus.cpp:353
MythPowerDBus::DeviceRemoved
void DeviceRemoved(const QDBusObjectPath &Device)
Definition: mythpowerdbus.cpp:372
uint
unsigned int uint
Definition: compat.h:141
MythPowerDBus::m_lockHandle
int m_lockHandle
Definition: mythpowerdbus.h:52
MythPower::Feature
Feature
Definition: mythpower.h:35
MythPowerDBus::UpdateProperties
void UpdateProperties(void)
Definition: mythpowerdbus.cpp:400
MythPowerDBus::RetrieveBatteryLevel
int RetrieveBatteryLevel(const QString &Path)
Definition: mythpowerdbus.cpp:467
MythPowerDBus::~MythPowerDBus
~MythPowerDBus() override
Definition: mythpowerdbus.cpp:67
MythPowerDBus::MythPowerDBus
MythPowerDBus()
Definition: mythpowerdbus.cpp:60
mythpower.h
MythPowerDBus::m_logindInterface
QDBusInterface * m_logindInterface
Definition: mythpowerdbus.h:51
MythPowerDBus::ScheduleFeature
bool ScheduleFeature(enum Feature Type, uint Delay) override
Schedule a MythTV initiated power feature.
Definition: mythpowerdbus.cpp:286