Go to the documentation of this file.
14 #define LOC QString("Power: ")
75 static QHash<void*,std::chrono::seconds> s_delays;
77 QMutexLocker locker(&
s_lock);
90 #elif defined(USING_DBUS)
99 s_delays.insert(Reference, MinimumDelay);
104 s_delays.remove(Reference);
108 if (s_instance->
DecrRef() == 0)
109 s_instance =
nullptr;
115 std::chrono::seconds max = std::max_element(s_delays.cbegin(), s_delays.cend()).value();
131 if (supported.isEmpty())
133 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Supported actions: %1").arg(supported.join(
",")));
152 QStringList supported;
182 QMutexLocker locker(&
s_lock);
193 LOG(VB_GENERAL, LOG_DEBUG,
LOC + QString(
"Delay: %1 User: %2 Requested: %3 Supported: %4")
197 if (!Delay || delay < 1s)
222 QMutexLocker locker(&
s_lock);
225 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"No power request to cancel");
228 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Cancelling %1 request with %2 seconds remaining")
279 LOG(VB_GENERAL, LOG_ERR,
LOC +
280 QString(
"Ignoring %1 request: %2 pending in %3 seconds")
288 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Will %1 in %2 seconds")
311 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"About to: %1 %2")
328 QMutexLocker locker(&
s_lock);
333 static constexpr qint64 kSecsInDay { 24LL * 60 * 60 };
334 QDateTime now = QDateTime::currentDateTime();
336 qint64
days = secs / kSecsInDay;
337 QTime time = QTime(0, 0).addSecs(secs % kSecsInDay);
338 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Woke up after %1days %2hours %3minutes and %4seconds")
339 .arg(
days).arg(time.hour()).arg(time.minute()).arg(time.second()));
351 LOG(VB_GENERAL, LOG_INFO,
LOC +
"On AC power");
353 else if (Level ==
UPS)
356 LOG(VB_GENERAL, LOG_INFO,
LOC +
"On UPS");
360 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Battery at %1%").arg(Level));
366 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Low battery!");
377 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.