diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2014-11-14 15:30:22 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2014-11-14 15:30:22 +1300 |
commit | 9b4b12edc4d4844480b2717cbfa7eefe62198ecc (patch) | |
tree | 3369735dc397f72ebb57ddf8d34e940fd807e491 /liblightdm-qt | |
parent | cfceaf69929cacde5e31be21e93cf44866997bbe (diff) | |
download | lightdm-9b4b12edc4d4844480b2717cbfa7eefe62198ecc.tar.gz |
Revert removal of ConsoleKit support.
ConsoleKit has recently been forked for XFCE and Illumos is using ConsoleKit + LightDM.
http://lists.freedesktop.org/archives/lightdm/2014-November/000731.html
Diffstat (limited to 'liblightdm-qt')
-rw-r--r-- | liblightdm-qt/power.cpp | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/liblightdm-qt/power.cpp b/liblightdm-qt/power.cpp index fa366a1f..a8cb4fae 100644 --- a/liblightdm-qt/power.cpp +++ b/liblightdm-qt/power.cpp @@ -26,11 +26,13 @@ class PowerInterface::PowerInterfacePrivate public: PowerInterfacePrivate(); QScopedPointer<QDBusInterface> powerManagementInterface; + QScopedPointer<QDBusInterface> consoleKitInterface; QScopedPointer<QDBusInterface> login1Interface; }; PowerInterface::PowerInterfacePrivate::PowerInterfacePrivate() : powerManagementInterface(new QDBusInterface("org.freedesktop.UPower","/org/freedesktop/UPower", "org.freedesktop.UPower", QDBusConnection::systemBus())), + consoleKitInterface(new QDBusInterface("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus())), login1Interface(new QDBusInterface("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus())) { } @@ -115,9 +117,17 @@ bool PowerInterface::hibernate() bool PowerInterface::canShutdown() { - QDBusReply<QString> reply1 = d->login1Interface->call("CanPowerOff"); - if (reply1.isValid()) { - return reply1.value() == "yes"; + if (d->login1Interface->isValid()) { + QDBusReply<QString> reply1 = d->login1Interface->call("CanPowerOff"); + if (reply1.isValid()) { + return reply1.value() == "yes"; + } + } + qWarning() << d->login1Interface->lastError(); + + QDBusReply<bool> reply = d->consoleKitInterface->call("CanStop"); + if (reply.isValid()) { + return reply.value(); } return false; @@ -126,15 +136,26 @@ bool PowerInterface::canShutdown() bool PowerInterface::shutdown() { QDBusReply<void> reply; - reply = d->login1Interface->call("PowerOff", false); + if (d->login1Interface->isValid()) + reply = d->login1Interface->call("PowerOff", false); + else + reply = d->consoleKitInterface->call("Stop"); return reply.isValid(); } bool PowerInterface::canRestart() { - QDBusReply<QString> reply1 = d->login1Interface->call("CanReboot"); - if (reply1.isValid()) { - return reply1.value() == "yes"; + if (d->login1Interface->isValid()) { + QDBusReply<QString> reply1 = d->login1Interface->call("CanReboot"); + if (reply1.isValid()) { + return reply1.value() == "yes"; + } + } + qWarning() << d->login1Interface->lastError(); + + QDBusReply<bool> reply = d->consoleKitInterface->call("CanRestart"); + if (reply.isValid()) { + return reply.value(); } return false; @@ -143,7 +164,10 @@ bool PowerInterface::canRestart() bool PowerInterface::restart() { QDBusReply<void> reply; - reply = d->login1Interface->call("Reboot", false); + if (d->login1Interface->isValid()) + reply = d->login1Interface->call("Reboot", false); + else + reply = d->consoleKitInterface->call("Restart"); return reply.isValid(); } |