MythTV
master
|
#include <libmythbase/platforms/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) |
Public Slots inherited from MythPower | |
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 Public Member Functions inherited from MythPower | |
static MythPower * | AcquireRelease (void *Reference, bool Acquire, std::chrono::seconds MinimumDelay=0s) |
Static Public Member Functions inherited from ReferenceCounter | |
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... | |
Protected Slots inherited from MythPower | |
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, std::chrono::seconds Delay) override |
Schedule a MythTV initiated power feature. More... | |
Protected Member Functions inherited from MythPower | |
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 (std::chrono::seconds Delay) |
void | PowerLevelChanged (int Level) |
Protected Member Functions inherited from ReferenceCounter | |
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 | |
Public Types inherited from MythPower | |
enum | PowerLevel : std::int8_t { UPS = -2, ACPower = -1, BatteryEmpty = 0, BatteryLow = 10, BatteryFull = 100, UnknownPower = 101, Unset = 102 } |
enum | Feature : std::uint8_t { FeatureNone = 0x00, FeatureShutdown = 0x01, FeatureSuspend = 0x02, FeatureHibernate = 0x04, FeatureRestart = 0x08, FeatureHybridSleep = 0x10 } |
Signals inherited from MythPower | |
void | ShuttingDown (void) |
void | Suspending (void) |
void | Hibernating (void) |
void | Restarting (void) |
void | HybridSleeping (void) |
void | WillShutDown (std::chrono::milliseconds MilliSeconds=0ms) |
void | WillSuspend (std::chrono::milliseconds MilliSeconds=0ms) |
void | WillHibernate (std::chrono::milliseconds MilliSeconds=0ms) |
void | WillRestart (std::chrono::milliseconds MilliSeconds=0ms) |
void | WillHybridSleep (std::chrono::milliseconds MilliSeconds=0ms) |
void | WokeUp (std::chrono::seconds SecondsAsleep) |
void | LowBattery (void) |
Public Member Functions inherited from MythPower | |
virtual bool | RequestFeature (Feature Request, bool Delay=true) |
Features | GetFeatures (void) |
bool | IsFeatureSupported (Feature Supported) |
int | GetPowerLevel (void) const |
QStringList | GetFeatureList (void) |
Public Member Functions inherited from ReferenceCounter | |
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 Protected Member Functions inherited from MythPower | |
static QString | FeatureToString (enum Feature Type) |
static bool | FeatureIsEquivalent (Feature First, Feature Second) |
Protected Attributes inherited from MythPower | |
Features | m_features { FeatureNone } |
Feature | m_scheduledFeature { FeatureNone } |
bool | m_isSpontaneous { false } |
std::chrono::seconds | m_maxRequestedDelay { 0s } |
std::chrono::seconds | m_maxSupportedDelay { MAXIMUM_SHUTDOWN_WAIT } |
QTimer | m_featureTimer |
QDateTime | m_sleepTime |
int | m_powerLevel { Unset } |
bool | m_warnForLowBattery { false } |
Protected Attributes inherited from ReferenceCounter | |
bool | m_logDebug |
This is used to suppress creating LoggingItem classes for LoggingItem reference count changes. More... | |
QAtomicInt | m_referenceCount {1} |
Static Protected Attributes inherited from MythPower | |
static QRecursiveMutex | s_lock |
Definition at line 12 of file mythpowerdbus.h.
|
protected |
Definition at line 65 of file mythpowerdbus.cpp.
|
overrideprotected |
Definition at line 72 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 46 of file mythpowerdbus.cpp.
Referenced by MythPower::AcquireRelease().
|
overrideslot |
This is untested.
Definition at line 348 of file mythpowerdbus.cpp.
|
slot |
Definition at line 357 of file mythpowerdbus.cpp.
Referenced by Init().
|
slot |
Definition at line 364 of file mythpowerdbus.cpp.
Referenced by Init().
|
slot |
Definition at line 376 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 393 of file mythpowerdbus.cpp.
Referenced by Init().
|
slot |
Definition at line 190 of file mythpowerdbus.cpp.
Referenced by Init().
|
slot |
Definition at line 206 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 559 of file mythpowerdbus.cpp.
Referenced by AcquireLock(), DoFeature(), MythPowerDBus(), and ~MythPowerDBus().
|
overrideprotectedvirtual |
Reimplemented from MythPower.
Definition at line 82 of file mythpowerdbus.cpp.
Referenced by MythPowerDBus().
Reimplemented from MythPower.
Definition at line 169 of file mythpowerdbus.cpp.
Referenced by ScheduleFeature().
|
overrideprotectedvirtual |
Reimplemented from MythPower.
Definition at line 269 of file mythpowerdbus.cpp.
Referenced by DBusShuttingDown(), and DBusSuspending().
|
overrideprotectedvirtual |
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 290 of file mythpowerdbus.cpp.
|
private |
Definition at line 222 of file mythpowerdbus.cpp.
Referenced by DBusShuttingDown(), and DBusSuspending().
|
private |
Definition at line 473 of file mythpowerdbus.cpp.
Referenced by DeviceAdded(), and DeviceChanged().
|
private |
Definition at line 438 of file mythpowerdbus.cpp.
Referenced by Changed(), DeviceAdded(), DeviceChanged(), and DeviceRemoved().
|
private |
Definition at line 404 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 520 of file mythpowerdbus.cpp.
Referenced by DidWakeUp(), and Init().
|
friend |
Definition at line 16 of file mythpowerdbus.h.
Definition at line 49 of file mythpowerdbus.h.
Referenced by RetrieveBatteryLevel(), UpdateBattery(), and UpdateProperties().
|
private |
Definition at line 50 of file mythpowerdbus.h.
Referenced by DeviceAdded(), DeviceChanged(), DeviceRemoved(), and UpdateBattery().
|
private |
Definition at line 51 of file mythpowerdbus.h.
Referenced by Init(), and RetrieveBatteryLevel().
|
private |
Definition at line 52 of file mythpowerdbus.h.
Referenced by Init(), and ~MythPowerDBus().
|
private |
Definition at line 53 of file mythpowerdbus.h.
Referenced by AcquireLock(), DoFeature(), Init(), ScheduleFeature(), UpdateBattery(), UpdateProperties(), UpdateStatus(), and ~MythPowerDBus().
|
private |
Definition at line 54 of file mythpowerdbus.h.
Referenced by AcquireLock(), and ReleaseLock().
|
private |
Definition at line 55 of file mythpowerdbus.h.
Referenced by CancelFeature(), DidWakeUp(), MythPowerDBus(), ScheduleFeature(), and UpdateStatus().