Go to the documentation of this file.
13 #define LOC QString("Power: ")
74 static QHash<void*,std::chrono::seconds> s_delays;
76 QMutexLocker locker(&
s_lock);
89 #elif defined(USING_DBUS)
98 s_delays.insert(Reference, MinimumDelay);
103 s_delays.remove(Reference);
107 if (s_instance->
DecrRef() == 0)
108 s_instance =
nullptr;
114 std::chrono::seconds max = std::max_element(s_delays.cbegin(), s_delays.cend()).value();
130 if (supported.isEmpty())
132 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Supported actions: %1").arg(supported.join(
",")));
151 QStringList supported;
181 QMutexLocker locker(&
s_lock);
192 LOG(VB_GENERAL, LOG_DEBUG,
LOC + QString(
"Delay: %1 User: %2 Requested: %3 Supported: %4")
196 if (!Delay || delay < 1s)
221 QMutexLocker locker(&
s_lock);
224 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"No power request to cancel");
227 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Cancelling %1 request with %2 seconds remaining")
278 LOG(VB_GENERAL, LOG_ERR,
LOC +
279 QString(
"Ignoring %1 request: %2 pending in %3 seconds")
287 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Will %1 in %2 seconds")
310 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"About to: %1 %2")
327 QMutexLocker locker(&
s_lock);
332 static constexpr qint64 kSecsInDay { 24LL * 60 * 60 };
333 QDateTime now = QDateTime::currentDateTime();
335 qint64
days = secs / kSecsInDay;
336 QTime time = QTime(0, 0).addSecs(secs % kSecsInDay);
337 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Woke up after %1days %2hours %3minutes and %4seconds")
338 .arg(
days).arg(time.hour()).arg(time.minute()).arg(time.second()));
350 LOG(VB_GENERAL, LOG_INFO,
LOC +
"On AC power");
352 else if (Level ==
UPS)
355 LOG(VB_GENERAL, LOG_INFO,
LOC +
"On UPS");
359 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Battery at %1%").arg(Level));
365 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Low battery!");
376 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Unknown power source");
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
static QString FeatureToString(enum Feature Type)
Feature m_scheduledFeature
virtual void FeatureHappening(Feature Spontaneous=FeatureNone)
Signal to the rest of MythTV that the given feature will happen now.
static bool FeatureIsEquivalent(Feature First, Feature Second)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
std::chrono::seconds m_maxRequestedDelay
void WillSuspend(std::chrono::milliseconds MilliSeconds=0ms)
std::chrono::seconds m_maxSupportedDelay
Features GetFeatures(void)
bool IsFeatureSupported(Feature Supported)
void WillRestart(std::chrono::milliseconds MilliSeconds=0ms)
virtual bool ScheduleFeature(enum Feature Type, std::chrono::seconds Delay)
static bool IsAvailable(void)
Static check for DBus interfaces that support some form of power management.
static MythPower * AcquireRelease(void *Reference, bool Acquire, std::chrono::seconds MinimumDelay=0s)
std::enable_if_t< std::chrono::__is_duration< T >::value, T > GetDurSetting(const QString &key, T defaultval=T::zero())
void PowerLevelChanged(int Level)
virtual bool RequestFeature(Feature Request, bool Delay=true)
void FeatureTimeout(void)
void WillHibernate(std::chrono::milliseconds MilliSeconds=0ms)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static eu8 clamp(eu8 value, eu8 low, eu8 high)
QStringList GetFeatureList(void)
virtual void CancelFeature(void)
This is untested as it is currently not clear whether it is useful.
static QRecursiveMutex s_lock
duration< CHRONO_TYPE, ratio< 86400 > > days
virtual bool DoFeature(bool=false)
void WillHybridSleep(std::chrono::milliseconds MilliSeconds=0ms)
void SetRequestedDelay(std::chrono::seconds Delay)
static constexpr std::chrono::seconds MAXIMUM_SHUTDOWN_WAIT
void WillShutDown(std::chrono::milliseconds MilliSeconds=0ms)
void HybridSleeping(void)
virtual void DidWakeUp(void)
int GetPowerLevel(void) const
virtual int IncrRef(void)
Increments reference count.
void WokeUp(std::chrono::seconds SecondsAsleep)
General purpose reference counter.