Commit 0018b764 authored by Daniel Nicoletti's avatar Daniel Nicoletti
Browse files

Make sure appShouldConserveResources returns the cached value

BUG: 300786
parent cdf84286
......@@ -28,16 +28,16 @@
SOLID_GLOBAL_STATIC(Solid::PowerManagementPrivate, globalPowerManager)
Solid::PowerManagementPrivate::PowerManagementPrivate()
: managerIface("org.freedesktop.PowerManagement",
"/org/freedesktop/PowerManagement",
: managerIface(QLatin1String("org.freedesktop.PowerManagement"),
QLatin1String("/org/freedesktop/PowerManagement"),
QDBusConnection::sessionBus()),
policyAgentIface("org.kde.Solid.PowerManagement.PolicyAgent",
"/org/kde/Solid/PowerManagement/PolicyAgent",
policyAgentIface(QLatin1String("org.kde.Solid.PowerManagement.PolicyAgent"),
QLatin1String("/org/kde/Solid/PowerManagement/PolicyAgent"),
QDBusConnection::sessionBus()),
inhibitIface("org.freedesktop.PowerManagement.Inhibit",
"/org/freedesktop/PowerManagement/Inhibit",
inhibitIface(QLatin1String("org.freedesktop.PowerManagement.Inhibit"),
QLatin1String("/org/freedesktop/PowerManagement/Inhibit"),
QDBusConnection::sessionBus()),
serviceWatcher("org.kde.Solid.PowerManagement",
serviceWatcher(QLatin1String("org.kde.Solid.PowerManagement"),
QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration),
powerSaveStatus(false)
......@@ -56,8 +56,8 @@ Solid::PowerManagementPrivate::PowerManagementPrivate()
this, SLOT(slotServiceUnregistered(QString)));
// If the service is registered, trigger the connection immediately
if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.Solid.PowerManagement")) {
slotServiceRegistered("org.kde.Solid.PowerManagement");
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String("org.kde.Solid.PowerManagement"))) {
slotServiceRegistered(QLatin1String("org.kde.Solid.PowerManagement"));
}
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String("org.freedesktop.PowerManagement"))) {
slotServiceRegistered(QLatin1String("org.freedesktop.PowerManagement"));
......@@ -74,7 +74,7 @@ Solid::PowerManagement::Notifier::Notifier()
bool Solid::PowerManagement::appShouldConserveResources()
{
return globalPowerManager->managerIface.GetPowerSaveStatus();
return globalPowerManager->powerSaveStatus;
}
QSet<Solid::PowerManagement::SleepState> Solid::PowerManagement::supportedSleepStates()
......@@ -140,8 +140,10 @@ int Solid::PowerManagement::beginSuppressingScreenPowerManagement(const QString&
QCoreApplication::applicationName(), reason);
if (reply.isValid()) {
QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.ScreenSaver", "/ScreenSaver",
"org.freedesktop.ScreenSaver", "Inhibit");
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.ScreenSaver"),
QLatin1String("/ScreenSaver"),
QLatin1String("org.freedesktop.ScreenSaver"),
QLatin1String("Inhibit"));
message << QCoreApplication::applicationName();
message << reason;
......@@ -167,8 +169,10 @@ bool Solid::PowerManagement::stopSuppressingScreenPowerManagement(int cookie)
bool result = globalPowerManager->policyAgentIface.ReleaseInhibition(cookie).isValid();
if (globalPowerManager->screensaverCookiesForPowerDevilCookies.contains(cookie)) {
QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.ScreenSaver", "/ScreenSaver",
"org.freedesktop.ScreenSaver", "UnInhibit");
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.ScreenSaver"),
QLatin1String("/ScreenSaver"),
QLatin1String("org.freedesktop.ScreenSaver"),
QLatin1String("UnInhibit"));
message << globalPowerManager->screensaverCookiesForPowerDevilCookies.take(cookie);
QDBusConnection::sessionBus().asyncCall(message);
}
......@@ -238,19 +242,19 @@ void Solid::PowerManagementPrivate::slotServiceRegistered(const QString &service
slotPowerSaveStatusChanged(saveStatusReply.isValid() ? saveStatusReply.value() : false);
} else {
// Is the resume signal available?
QDBusMessage call = QDBusMessage::createMethodCall("org.kde.Solid.PowerManagement",
"/org/kde/Solid/PowerManagement",
"org.kde.Solid.PowerManagement",
"backendCapabilities");
QDBusMessage call = QDBusMessage::createMethodCall(QLatin1String("org.kde.Solid.PowerManagement"),
QLatin1String("/org/kde/Solid/PowerManagement"),
QLatin1String("org.kde.Solid.PowerManagement"),
QLatin1String("backendCapabilities"));
QDBusPendingReply< uint > reply = QDBusConnection::sessionBus().asyncCall(call);
reply.waitForFinished();
if (reply.isValid() && reply.value() > 0) {
// Connect the signal
QDBusConnection::sessionBus().connect("org.kde.Solid.PowerManagement",
"/org/kde/Solid/PowerManagement",
"org.kde.Solid.PowerManagement",
"resumingFromSuspend",
QDBusConnection::sessionBus().connect(QLatin1String("org.kde.Solid.PowerManagement"),
QLatin1String("/org/kde/Solid/PowerManagement"),
QLatin1String("org.kde.Solid.PowerManagement"),
QLatin1String("resumingFromSuspend"),
this,
SIGNAL(resumingFromSuspend()));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment