MythTV
master
|
#include <mythpowerdbus.h>
Public Slots | |
void | CancelFeature (void) override |
This is untested. More... | |
void | Changed (void) |
void | DeviceAdded (const QDBusObjectPath &Device) |
void | DeviceRemoved (const QDBusObjectPath &Device) |
void | DeviceChanged (const QDBusObjectPath &Device) |
Update power device state. More... | |
void | DBusSuspending (bool Stopping) |
void | DBusShuttingDown (bool Stopping) |
![]() | |
virtual void | CancelFeature (void) |
This is untested as it is currently not clear whether it is useful. More... | |
Static Public Member Functions | |
static bool | IsAvailable (void) |
Static check for DBus interfaces that support some form of power management. More... | |
![]() | |
static MythPower * | AcquireRelease (void *Reference, bool Acquire, uint MinimumDelay=0) |
![]() | |
static void | PrintDebug (void) |
Print out any leaks if that level of debugging is enabled. More... | |
Protected Slots | |
void | ReleaseLock (void) |
Release our inhibition lock. More... | |
![]() | |
void | FeatureTimeout (void) |
virtual void | Refresh (void) |
Protected Member Functions | |
MythPowerDBus () | |
~MythPowerDBus () override | |
void | Init (void) override |
bool | DoFeature (bool Delayed=false) override |
void | DidWakeUp (void) override |
bool | ScheduleFeature (enum Feature Type, uint Delay) override |
Schedule a MythTV initiated power feature. More... | |
![]() | |
MythPower () | |
~MythPower () override=default | |
virtual void | FeatureHappening (Feature Spontaneous=FeatureNone) |
Signal to the rest of MythTV that the given feature will happen now. More... | |
void | SetRequestedDelay (uint Delay) |
void | PowerLevelChanged (int Level) |
![]() | |
virtual | ~ReferenceCounter (void) |
Called on destruction, will warn if object deleted with references in place. More... | |
Private Member Functions | |
bool | UpdateStatus (void) |
int | RetrieveBatteryLevel (const QString &Path) |
void | UpdateBattery (void) |
void | UpdateProperties (void) |
void | AcquireLock (Features Types) |
Acquire an inhibition lock for logind power events. More... | |
Private Attributes | |
bool | m_onBattery { false } |
QMap< QString, int > | m_batteries { } |
QDBusConnection | m_bus { QDBusConnection::systemBus() } |
QDBusInterface * | m_upowerInterface { nullptr } |
QDBusInterface * | m_logindInterface { nullptr } |
int | m_lockHandle { -1 } |
QTimer | m_delayTimer { } |
Friends | |
class | MythPower |
Additional Inherited Members | |
![]() | |
enum | PowerLevel { UPS = -2, ACPower = -1, BatteryEmpty = 0, BatteryLow = 10, BatteryFull = 100, UnknownPower = 101, Unset } |
enum | Feature { FeatureNone = 0x00, FeatureShutdown = 0x01, FeatureSuspend = 0x02, FeatureHibernate = 0x04, FeatureRestart = 0x08, FeatureHybridSleep = 0x10 } |
![]() | |
void | ShuttingDown (void) |
void | Suspending (void) |
void | Hibernating (void) |
void | Restarting (void) |
void | HybridSleeping (void) |
void | WillShutDown (uint MilliSeconds=0) |
void | WillSuspend (uint MilliSeconds=0) |
void | WillHibernate (uint MilliSeconds=0) |
void | WillRestart (uint MilliSeconds=0) |
void | WillHybridSleep (uint MilliSeconds=0) |
void | WokeUp (qint64 SecondsAsleep) |
void | LowBattery (void) |
![]() | |
virtual bool | RequestFeature (Feature Request, bool Delay=true) |
Features | GetFeatures (void) |
bool | IsFeatureSupported (Feature Supported) |
int | GetPowerLevel (void) const |
QStringList | GetFeatureList (void) |
![]() | |
ReferenceCounter (const QString &debugName, bool logDebug=true) | |
Creates reference counter with an initial value of 1. More... | |
virtual int | IncrRef (void) |
Increments reference count. More... | |
virtual int | DecrRef (void) |
Decrements reference count and deletes on 0. More... | |
![]() | |
static QString | FeatureToString (enum Feature Type) |
static bool | FeatureIsEquivalent (Feature First, Feature Second) |
![]() | |
Features | m_features { FeatureNone } |
Feature | m_scheduledFeature { FeatureNone } |
bool | m_isSpontaneous { false } |
uint | m_maxRequestedDelay { 0 } |
uint | m_maxSupportedDelay { MAXIMUM_SHUTDOWN_WAIT } |
QTimer | m_featureTimer { } |
QDateTime | m_sleepTime { } |
int | m_powerLevel { Unset } |
bool | m_warnForLowBattery { false } |
![]() | |
bool | m_logDebug |
This is used to suppress creating LoggingItem classes for LoggingItem reference count changes. More... | |
QAtomicInt | m_referenceCount {1} |
![]() | |
static QMutex | s_lock |
Definition at line 10 of file mythpowerdbus.h.
|
protected |
Definition at line 60 of file mythpowerdbus.cpp.
|
overrideprotected |
Definition at line 67 of file mythpowerdbus.cpp.
|
static |
Static check for DBus interfaces that support some form of power management.
This currently looks for UPower and login1 (logind) interfaces.
UPower is used for battery status.
logind manages shutdown, suspend etc. We make use of ScheduleShutdown where possible to integrate better with other services and mimic ScheduleShutdown otherwise (e.g. for suspend). Two different MythTV services (e.g both frontend and backend) should integrate well with their behaviour as both can delay events independantly as needed (though this might lead to user confusion if an event is delayed longer than they expect).
Definition at line 41 of file mythpowerdbus.cpp.
Referenced by MythPower::AcquireRelease().
|
overrideslot |
This is untested.
Definition at line 344 of file mythpowerdbus.cpp.
|
slot |
Definition at line 353 of file mythpowerdbus.cpp.
Referenced by Init().
|
slot |
Definition at line 360 of file mythpowerdbus.cpp.
Referenced by Init().
|
slot |
Definition at line 372 of file mythpowerdbus.cpp.
Referenced by Init().
|
slot |
Update power device state.
This is typically called by the UPower service when the battery state has changed.
Definition at line 389 of file mythpowerdbus.cpp.
Referenced by Init().
|
slot |
Definition at line 185 of file mythpowerdbus.cpp.
Referenced by Init().
|
slot |
Definition at line 201 of file mythpowerdbus.cpp.
Referenced by Init().
|
protectedslot |
Release our inhibition lock.
This will be called when we exit (cleanup) or when we are ready implement or allow shutdown/resume events.
Definition at line 553 of file mythpowerdbus.cpp.
Referenced by AcquireLock(), DoFeature(), MythPowerDBus(), and ~MythPowerDBus().
|
overrideprotectedvirtual |
Reimplemented from MythPower.
Definition at line 77 of file mythpowerdbus.cpp.
Referenced by MythPowerDBus().
Reimplemented from MythPower.
Definition at line 164 of file mythpowerdbus.cpp.
Referenced by ScheduleFeature().
|
overrideprotectedvirtual |
Reimplemented from MythPower.
Definition at line 265 of file mythpowerdbus.cpp.
Referenced by DBusShuttingDown(), and DBusSuspending().
Schedule a MythTV initiated power feature.
The default MythPopwer implementation will schedule the feature at a point in the future. logind however allows us to schedule shutdown events (but not suspend/hibernate etc). This has the advantage that logind will send a PrepareForShutdown signal - which gives other services advanced warning of the pending shutdown and allows them to prepare properly.
For suspend type events, we mimic the delay by initiating the suspend straight away but retaining the inhibition lock until we are ready. This plays nicely with other services (which receive the PrepareForSleep signal immediately) but on some systems means the display is turned off too soon.
Reimplemented from MythPower.
Definition at line 286 of file mythpowerdbus.cpp.
|
private |
Definition at line 217 of file mythpowerdbus.cpp.
Referenced by DBusShuttingDown(), and DBusSuspending().
|
private |
Definition at line 467 of file mythpowerdbus.cpp.
Referenced by DeviceAdded(), and DeviceChanged().
|
private |
Definition at line 432 of file mythpowerdbus.cpp.
Referenced by Changed(), DeviceAdded(), DeviceChanged(), and DeviceRemoved().
|
private |
Definition at line 400 of file mythpowerdbus.cpp.
Referenced by Changed().
|
private |
Acquire an inhibition lock for logind power events.
We typically acquire a lock for both suspend and shutdown. We must hold this at all times (when we want to inhibit those events). Failure to hold a lock may lead to race conditions and other unpredictable behaviour. When we are ready, the lock is released (closed) and logind will proceed. On resume, we take a new lock immediately.
Definition at line 514 of file mythpowerdbus.cpp.
Referenced by DidWakeUp(), and Init().
|
friend |
Definition at line 14 of file mythpowerdbus.h.
Definition at line 47 of file mythpowerdbus.h.
Referenced by RetrieveBatteryLevel(), UpdateBattery(), and UpdateProperties().
|
private |
Definition at line 48 of file mythpowerdbus.h.
Referenced by DeviceAdded(), DeviceChanged(), DeviceRemoved(), and UpdateBattery().
|
private |
Definition at line 49 of file mythpowerdbus.h.
Referenced by Init(), and RetrieveBatteryLevel().
|
private |
Definition at line 50 of file mythpowerdbus.h.
Referenced by Init(), and ~MythPowerDBus().
|
private |
Definition at line 51 of file mythpowerdbus.h.
Referenced by AcquireLock(), DoFeature(), Init(), ScheduleFeature(), UpdateBattery(), UpdateProperties(), UpdateStatus(), and ~MythPowerDBus().
|
private |
Definition at line 52 of file mythpowerdbus.h.
Referenced by AcquireLock(), and ReleaseLock().
|
private |
Definition at line 53 of file mythpowerdbus.h.
Referenced by CancelFeature(), DidWakeUp(), MythPowerDBus(), ScheduleFeature(), and UpdateStatus().