diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2013-09-29 01:39:40 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2013-09-29 01:42:48 +0200 |
commit | d8d925203ed90f3c1ca93145e9364cfb854d2789 (patch) | |
tree | 4bab0e8460093a626d3f28b50cb9c53560249950 /tdecore/tdehw/tderootsystemdevice.cpp | |
parent | ea75e7f6173f214c197abd580b53b5ef09e49856 (diff) | |
download | tdelibs-d8d925203ed90f3c1ca93145e9364cfb854d2789.tar.gz tdelibs-d8d925203ed90f3c1ca93145e9364cfb854d2789.zip |
Add SetHibernationMethod to tdehwlib-daemon
Diffstat (limited to 'tdecore/tdehw/tderootsystemdevice.cpp')
-rw-r--r-- | tdecore/tdehw/tderootsystemdevice.cpp | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/tdecore/tdehw/tderootsystemdevice.cpp b/tdecore/tdehw/tderootsystemdevice.cpp index 488c60e2b..b62f07ddd 100644 --- a/tdecore/tdehw/tderootsystemdevice.cpp +++ b/tdecore/tdehw/tderootsystemdevice.cpp @@ -103,9 +103,26 @@ bool TDERootSystemDevice::canSetHibernationMethod() { if (rval == 0) { return TRUE; } - else { - return FALSE; + +#ifdef WITH_TDEHWLIB_DAEMONS + { + TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); + if (dbusConn.isConnected()) { + // can set hibernation method? + TQT_DBusMessage msg = TQT_DBusMessage::methodCall( + "org.trinitydesktop.hardwarecontrol", + "/org/trinitydesktop/hardwarecontrol", + "org.trinitydesktop.hardwarecontrol.Power", + "CanSetHibernationMethod"); + 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; } bool TDERootSystemDevice::canStandby() { @@ -495,7 +512,43 @@ void TDERootSystemDevice::setHibernationMethod(TDESystemHibernationMethod::TDESy TQTextStream stream( &file ); stream << hibernationCommand; file.close(); + return; } + +#ifdef WITH_TDEHWLIB_DAEMONS + { + TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus); + if (dbusConn.isConnected()) { + TQT_DBusProxy hardwareControl("org.trinitydesktop.hardwarecontrol", "/org/trinitydesktop/hardwarecontrol", "org.trinitydesktop.hardwarecontrol.Power", dbusConn); + if (hardwareControl.canSend()) { + // set hibernation method + TQValueList<TQT_DBusData> params; + TQString hibernationCommand; + if (hm == TDESystemHibernationMethod::Platform) { + hibernationCommand = "platform"; + } + if (hm == TDESystemHibernationMethod::Shutdown) { + hibernationCommand = "shutdown"; + } + if (hm == TDESystemHibernationMethod::Reboot) { + hibernationCommand = "reboot"; + } + if (hm == TDESystemHibernationMethod::TestProc) { + hibernationCommand = "testproc"; + } + if (hm == TDESystemHibernationMethod::Test) { + hibernationCommand = "test"; + } + params << TQT_DBusData::fromString(hibernationCommand); + TQT_DBusMessage reply = hardwareControl.sendWithReply("SetHibernationMethod", params); + if (reply.type() == TQT_DBusMessage::ReplyMessage) { + return; + } + } + } + } +#endif // WITH_TDEHWLIB_DAEMONS + } bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState ps) { |