summaryrefslogtreecommitdiff
path: root/liblightdm-qt
diff options
context:
space:
mode:
authorIain Lane <iain.lane@canonical.com>2013-04-18 11:54:55 +0100
committerIain Lane <iain.lane@canonical.com>2013-04-18 11:54:55 +0100
commit28ceda9f1aee92c7e9379e07a051f81657e7b119 (patch)
tree468fbf32d5bbf69a09f786c670a723e427227d64 /liblightdm-qt
parentcf0cb47d745d47ba178c0e461c796a83785f58a0 (diff)
downloadlightdm-git-28ceda9f1aee92c7e9379e07a051f81657e7b119.tar.gz
Use logind for suspend/hibernate too, if available.
Diffstat (limited to 'liblightdm-qt')
-rw-r--r--liblightdm-qt/power.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/liblightdm-qt/power.cpp b/liblightdm-qt/power.cpp
index 47bd5a05..245e15c7 100644
--- a/liblightdm-qt/power.cpp
+++ b/liblightdm-qt/power.cpp
@@ -51,6 +51,17 @@ PowerInterface::~PowerInterface()
bool PowerInterface::canSuspend()
{
+ if (d->login1Interface->isValid())
+ {
+ QDBusReply<QString> reply = d->login1Interface->call("CanSuspend");
+ if (reply.isValid())
+ {
+ return reply.value() == "yes";
+ }
+ }
+
+ qWarning() << d->login1Interface->lastError();
+
QDBusReply<bool> reply = d->powerManagementInterface->call("SuspendAllowed");
if (reply.isValid()) {
return reply.value();
@@ -62,12 +73,28 @@ bool PowerInterface::canSuspend()
bool PowerInterface::suspend()
{
- QDBusReply<void> reply = d->powerManagementInterface->call("Suspend");
+ QDBusReply<void> reply;
+ if (d->login1Interface->isValid())
+ reply = d->login1Interface->call("Hibernate", false);
+ else
+ reply = d->powerManagementInterface->call("Hibernate");
+
return reply.isValid ();
}
bool PowerInterface::canHibernate()
{
+ if (d->login1Interface->isValid())
+ {
+ QDBusReply<QString> reply = d->login1Interface->call("CanHibernate");
+ if (reply.isValid())
+ {
+ return reply.value() == "yes";
+ }
+ }
+
+ qWarning() << d->login1Interface->lastError();
+
QDBusReply<bool> reply = d->powerManagementInterface->call("HibernateAllowed");
if (reply.isValid()) {
return reply.value();
@@ -79,7 +106,12 @@ bool PowerInterface::canHibernate()
bool PowerInterface::hibernate()
{
- QDBusReply<void> reply = d->powerManagementInterface->call("Hibernate");
+ QDBusReply<void> reply;
+ if (d->login1Interface->isValid())
+ reply = d->login1Interface->call("Hibernate", false);
+ else
+ reply = d->powerManagementInterface->call("Hibernate");
+
return reply.isValid ();
}