diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2013-08-25 14:59:43 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2013-08-25 14:59:43 +0200 |
commit | 2280c7079b13ff8ddb64e9ecccac12d447bfbc2a (patch) | |
tree | effebec8a67aaa24505bdd3636ec2930dea34057 /tdecore/tdehw/tderootsystemdevice.cpp | |
parent | a5ba7ad71203a7ff1b3a716e7171e919a2e2e5bb (diff) | |
download | tdelibs-2280c7079b13ff8ddb64e9ecccac12d447bfbc2a.tar.gz tdelibs-2280c7079b13ff8ddb64e9ecccac12d447bfbc2a.zip |
Add tdehwlib-daemon power management backend to TDE hardware library
Diffstat (limited to 'tdecore/tdehw/tderootsystemdevice.cpp')
-rw-r--r-- | tdecore/tdehw/tderootsystemdevice.cpp | 101 |
1 files changed, 97 insertions, 4 deletions
diff --git a/tdecore/tdehw/tderootsystemdevice.cpp b/tdecore/tdehw/tderootsystemdevice.cpp index 422ff50de..86a92340c 100644 --- a/tdecore/tdehw/tderootsystemdevice.cpp +++ b/tdecore/tdehw/tderootsystemdevice.cpp @@ -30,13 +30,13 @@ #include "config.h" -#if defined(WITH_UPOWER) || defined(WITH_CONSOLEKIT) +#if defined(WITH_TDEHWLIB_DAEMONS) || defined(WITH_UPOWER) || defined(WITH_DEVKITPOWER) || defined(WITH_HAL) || defined(WITH_CONSOLEKIT) #include <tqdbusdata.h> #include <tqdbusmessage.h> #include <tqdbusproxy.h> #include <tqdbusvariant.h> #include <tqdbusconnection.h> -#endif // defined(WITH_UPOWER) || defined(WITH_CONSOLEKIT) +#endif // defined(WITH_TDEHWLIB_DAEMONS) || defined(WITH_UPOWER) || defined(WITH_DEVKITPOWER) || defined(WITH_HAL) || defined(WITH_CONSOLEKIT) TDERootSystemDevice::TDERootSystemDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) { m_hibernationSpace = -1; @@ -107,9 +107,24 @@ bool TDERootSystemDevice::canStandby() { return FALSE; } } - else { - return FALSE; + +#ifdef WITH_TDEHWLIB_DAEMONS + { + TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); + if (dbusConn.isConnected()) { + // can standby? + TQT_DBusMessage msg = TQT_DBusMessage::methodCall( + "org.trinitydesktop.hardwarecontrol", + "/org/trinitydesktop/hardwarecontrol", + "org.trinitydesktop.hardwarecontrol.Power", + "CanStandby"); + TQT_DBusMessage reply = dbusConn.sendWithReply(msg); + if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { + return reply[0].toBool(); + } + } } +#endif // WITH_TDEHWLIB_DAEMONS } bool TDERootSystemDevice::canSuspend() { @@ -186,6 +201,24 @@ bool TDERootSystemDevice::canSuspend() { } #endif // WITH_HAL +#ifdef WITH_TDEHWLIB_DAEMONS + { + TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); + if (dbusConn.isConnected()) { + // can suspend? + TQT_DBusMessage msg = TQT_DBusMessage::methodCall( + "org.trinitydesktop.hardwarecontrol", + "/org/trinitydesktop/hardwarecontrol", + "org.trinitydesktop.hardwarecontrol.Power", + "CanSuspend"); + TQT_DBusMessage reply = dbusConn.sendWithReply(msg); + if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { + return reply[0].toBool(); + } + } + } +#endif // WITH_TDEHWLIB_DAEMONS + return FALSE; } @@ -263,6 +296,24 @@ bool TDERootSystemDevice::canHibernate() { } #endif // WITH_HAL +#ifdef WITH_TDEHWLIB_DAEMONS + { + TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); + if (dbusConn.isConnected()) { + // can hibernate? + TQT_DBusMessage msg = TQT_DBusMessage::methodCall( + "org.trinitydesktop.hardwarecontrol", + "/org/trinitydesktop/hardwarecontrol", + "org.trinitydesktop.hardwarecontrol.Power", + "CanHibernate"); + TQT_DBusMessage reply = dbusConn.sendWithReply(msg); + if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { + return reply[0].toBool(); + } + } + } +#endif // WITH_TDEHWLIB_DAEMONS + return FALSE; } @@ -492,6 +543,48 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState } #endif // WITH_HAL +#ifdef WITH_TDEHWLIB_DAEMONS + { + TQT_DBusConnection dbusConn; + dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); + if ( dbusConn.isConnected() ) { + if (ps == TDESystemPowerState::Standby) { + TQT_DBusMessage msg = TQT_DBusMessage::methodCall( + "org.trinitydesktop.hardwarecontrol", + "/org/trinitydesktop/hardwarecontrol", + "org.trinitydesktop.hardwarecontrol.Power", + "Standby"); + TQT_DBusMessage reply = dbusConn.sendWithReply(msg); + if (reply.type() == TQT_DBusMessage::ReplyMessage) { + return true; + } + } + else if (ps == TDESystemPowerState::Suspend) { + TQT_DBusMessage msg = TQT_DBusMessage::methodCall( + "org.trinitydesktop.hardwarecontrol", + "/org/trinitydesktop/hardwarecontrol", + "org.trinitydesktop.hardwarecontrol.Power", + "Suspend"); + TQT_DBusMessage reply = dbusConn.sendWithReply(msg); + if (reply.type() == TQT_DBusMessage::ReplyMessage) { + return true; + } + } + else if (ps == TDESystemPowerState::Hibernate) { + TQT_DBusMessage msg = TQT_DBusMessage::methodCall( + "org.trinitydesktop.hardwarecontrol", + "/org/trinitydesktop/hardwarecontrol", + "org.trinitydesktop.hardwarecontrol.Power", + "Hibernate"); + TQT_DBusMessage reply = dbusConn.sendWithReply(msg); + if (reply.type() == TQT_DBusMessage::ReplyMessage) { + return true; + } + } + } + } +#endif // WITH_TDEHWLIB_DAEMONS + return false; } else if (ps == TDESystemPowerState::PowerOff) { |