mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
solid: correct cookie type and remove obsolete standby sleep mode
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
f345af3c29
commit
3ab393c337
2 changed files with 19 additions and 20 deletions
|
@ -101,7 +101,6 @@ void Solid::PowerManagement::requestSleep(SleepState state, QObject *receiver, c
|
|||
|
||||
Q_ASSERT(managerIface);
|
||||
switch (state) {
|
||||
case StandbyState:
|
||||
case SuspendState: {
|
||||
globalPowerManager()->managerIface->asyncCall("Suspend");
|
||||
break;
|
||||
|
@ -117,26 +116,25 @@ void Solid::PowerManagement::requestSleep(SleepState state, QObject *receiver, c
|
|||
}
|
||||
}
|
||||
|
||||
int Solid::PowerManagement::beginSuppressingSleep(const QString &reason)
|
||||
uint Solid::PowerManagement::beginSuppressingSleep(const QString &reason)
|
||||
{
|
||||
QDBusReply<uint> reply = globalPowerManager()->inhibitIface.call("Inhibit", QCoreApplication::applicationName(), reason);
|
||||
if (reply.isValid())
|
||||
return reply;
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Solid::PowerManagement::stopSuppressingSleep(int cookie)
|
||||
bool Solid::PowerManagement::stopSuppressingSleep(uint cookie)
|
||||
{
|
||||
if (globalPowerManager()->inhibitIface.isValid()) {
|
||||
globalPowerManager()->inhibitIface.asyncCall("UnInhibit", uint(cookie));
|
||||
globalPowerManager()->inhibitIface.asyncCall("UnInhibit", cookie);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int Solid::PowerManagement::beginSuppressingScreenPowerManagement(const QString& reason)
|
||||
uint Solid::PowerManagement::beginSuppressingScreenPowerManagement(const QString& reason)
|
||||
{
|
||||
#warning TODO: the return type should be uint
|
||||
if (globalPowerManager()->saverIface.isValid()) {
|
||||
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.ScreenSaver"),
|
||||
QLatin1String("/ScreenSaver"),
|
||||
|
@ -152,20 +150,19 @@ int Solid::PowerManagement::beginSuppressingScreenPowerManagement(const QString&
|
|||
|
||||
return ssReply;
|
||||
}
|
||||
// No way to fallback on something, hence return failure
|
||||
return -1;
|
||||
// No way to fallback on something, hence return failure (0 is invalid cookie)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Solid::PowerManagement::stopSuppressingScreenPowerManagement(int cookie)
|
||||
bool Solid::PowerManagement::stopSuppressingScreenPowerManagement(uint cookie)
|
||||
{
|
||||
#warning TODO: the cookie type should be uint
|
||||
if (globalPowerManager()->saverIface.isValid()) {
|
||||
if (globalPowerManager()->screensaverCookies.contains(cookie)) {
|
||||
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.ScreenSaver"),
|
||||
QLatin1String("/ScreenSaver"),
|
||||
QLatin1String("org.freedesktop.ScreenSaver"),
|
||||
QLatin1String("UnInhibit"));
|
||||
message << uint(cookie);
|
||||
message << cookie;
|
||||
QDBusReply<void> ssReply = QDBusConnection::sessionBus().call(message);
|
||||
if (ssReply.isValid()) {
|
||||
globalPowerManager()->screensaverCookies.removeAll(cookie);
|
||||
|
|
|
@ -45,15 +45,17 @@ namespace Solid
|
|||
/**
|
||||
* This enum type defines the different suspend methods.
|
||||
*
|
||||
* - StandbyState: Processes are stopped, some hardware is deactivated (ACPI S1)
|
||||
* - SuspendState: Most devices are deactivated, only RAM is powered (ACPI S3)
|
||||
* - HibernateState: State of the machine is saved to disk, and the machine is powered down (ACPI S4)
|
||||
* - HybridSleepState: The contents of RAM are first copied to non-volatile storage like for regular hibernation,
|
||||
* but then, instead of powering down, the computer enters sleep mode
|
||||
*/
|
||||
enum SleepState { StandbyState = 1, SuspendState = 2, HibernateState = 4,
|
||||
/// @since 4.11
|
||||
HybridSuspendState = 8 };
|
||||
enum SleepState {
|
||||
SuspendState = 1,
|
||||
HibernateState = 2,
|
||||
/// @since 4.11
|
||||
HybridSuspendState = 4
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves a high level indication of how applications should behave according to the
|
||||
|
@ -92,7 +94,7 @@ namespace Solid
|
|||
* track the application's outstanding suppression requests. Returns -1 if the request was
|
||||
* denied.
|
||||
*/
|
||||
SOLID_EXPORT int beginSuppressingSleep(const QString &reason = QString());
|
||||
SOLID_EXPORT uint beginSuppressingSleep(const QString &reason = QString());
|
||||
|
||||
/**
|
||||
* Tell the power management that a particular sleep suppression is no longer needed. When
|
||||
|
@ -100,7 +102,7 @@ namespace Solid
|
|||
* @param cookie The cookie acquired when requesting sleep suppression
|
||||
* @return true if the suppression was stopped, false if an invalid cookie was given
|
||||
*/
|
||||
SOLID_EXPORT bool stopSuppressingSleep(int cookie);
|
||||
SOLID_EXPORT bool stopSuppressingSleep(uint cookie);
|
||||
|
||||
/**
|
||||
* Tell the power management subsystem to suppress automatic screen power management until
|
||||
|
@ -114,7 +116,7 @@ namespace Solid
|
|||
*
|
||||
* @since 4.6
|
||||
*/
|
||||
SOLID_EXPORT int beginSuppressingScreenPowerManagement(const QString &reason = QString());
|
||||
SOLID_EXPORT uint beginSuppressingScreenPowerManagement(const QString &reason = QString());
|
||||
|
||||
/**
|
||||
* Tell the power management that a particular screen power management suppression is no longer needed. When
|
||||
|
@ -126,7 +128,7 @@ namespace Solid
|
|||
*
|
||||
* @since 4.6
|
||||
*/
|
||||
SOLID_EXPORT bool stopSuppressingScreenPowerManagement(int cookie);
|
||||
SOLID_EXPORT bool stopSuppressingScreenPowerManagement(uint cookie);
|
||||
|
||||
class SOLID_EXPORT Notifier : public QObject
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue