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