Go to the documentation of this file.
13 #define LOC QString("Power: ")
15 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
78 static QHash<void*,std::chrono::seconds> s_delays;
80 QMutexLocker locker(&
s_lock);
93 #elif defined(USING_DBUS)
102 s_delays.insert(Reference, MinimumDelay);
107 s_delays.remove(Reference);
111 if (s_instance->
DecrRef() == 0)
112 s_instance =
nullptr;
118 std::chrono::seconds max = std::max_element(s_delays.cbegin(), s_delays.cend()).value();
134 if (supported.isEmpty())
136 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Supported actions: %1").arg(supported.join(
",")));
155 QStringList supported;
185 QMutexLocker locker(&
s_lock);
196 LOG(VB_GENERAL, LOG_DEBUG,
LOC + QString(
"Delay: %1 User: %2 Requested: %3 Supported: %4")
200 if (!Delay || delay < 1s)
225 QMutexLocker locker(&
s_lock);
228 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"No power request to cancel");
231 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Cancelling %1 request with %2 seconds remaining")
282 LOG(VB_GENERAL, LOG_ERR,
LOC +
283 QString(
"Ignoring %1 request: %2 pending in %3 seconds")
291 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Will %1 in %2 seconds")
314 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"About to: %1 %2")
331 QMutexLocker locker(&
s_lock);
336 static constexpr qint64 kSecsInDay { 24LL * 60 * 60 };
337 QDateTime now = QDateTime::currentDateTime();
339 qint64
days = secs / kSecsInDay;
340 QTime time = QTime(0, 0).addSecs(secs % kSecsInDay);
341 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Woke up after %1days %2hours %3minutes and %4seconds")
342 .arg(
days).arg(time.hour()).arg(time.minute()).arg(time.second()));
354 LOG(VB_GENERAL, LOG_INFO,
LOC +
"On AC power");
356 else if (Level ==
UPS)
359 LOG(VB_GENERAL, LOG_INFO,
LOC +
"On UPS");
363 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Battery at %1%").arg(Level));
369 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Low battery!");
380 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.
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.