summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2019-02-24 03:46:51 +0100
committerSlávek Banko <slavek.banko@axis.cz>2019-02-24 03:48:23 +0100
commit89609911f85667e0e46b89e15023081cd6724677 (patch)
tree7ffcf2aa5491f3e37fafdb452f200b5fd6654f98
parent5649783834bfd68690b9037b05b4f75dba17adcc (diff)
downloadtdelibs-89609911f85667e0e46b89e15023081cd6724677.tar.gz
tdelibs-89609911f85667e0e46b89e15023081cd6724677.zip
Fixed support for logind power state calls.
This resolves bug 2661 and bug 2975. Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit c49ee53043b73fac7fe7e956360f1e3cdc342c6e)
-rw-r--r--tdecore/tdehw/tderootsystemdevice.cpp69
1 files changed, 34 insertions, 35 deletions
diff --git a/tdecore/tdehw/tderootsystemdevice.cpp b/tdecore/tdehw/tderootsystemdevice.cpp
index 92c95fcc2..a57a1c5d3 100644
--- a/tdecore/tdehw/tderootsystemdevice.cpp
+++ b/tdecore/tdehw/tderootsystemdevice.cpp
@@ -599,29 +599,26 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
#ifdef WITH_LOGINDPOWER
{
+ // No support for "freeze" and "standby" in org.freedesktop.login1
TQT_DBusConnection dbusConn;
dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
if ( dbusConn.isConnected() ) {
- if (ps == TDESystemPowerState::Suspend) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "Suspend");
- TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
- if (reply.type() == TQT_DBusMessage::ReplyMessage) {
- return true;
+ TQT_DBusProxy logindProxy("org.freedesktop.login1", "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager", dbusConn);
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromBool(true);
+ if (logindProxy.canSend()) {
+ if (ps == TDESystemPowerState::Suspend) {
+ TQT_DBusMessage reply = logindProxy.sendWithReply("Suspend", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage) {
+ return true;
+ }
}
- }
- else if (ps == TDESystemPowerState::Hibernate) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "Hibernate");
- TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
- if (reply.type() == TQT_DBusMessage::ReplyMessage) {
- return true;
+ else if (ps == TDESystemPowerState::Hibernate) {
+ TQT_DBusMessage reply = logindProxy.sendWithReply("Hibernate", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage) {
+ return true;
+ }
}
}
}
@@ -789,14 +786,15 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
TQT_DBusConnection dbusConn;
dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
if ( dbusConn.isConnected() ) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.trinitydesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "PowerOff");
- TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
- if (reply.type() == TQT_DBusMessage::ReplyMessage) {
- return true;
+ TQT_DBusProxy logindProxy("org.freedesktop.login1", "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager", dbusConn);
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromBool(true);
+ if (logindProxy.canSend()) {
+ TQT_DBusMessage reply = logindProxy.sendWithReply("PowerOff", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage) {
+ return true;
+ }
}
}
}
@@ -839,14 +837,15 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
TQT_DBusConnection dbusConn;
dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
if ( dbusConn.isConnected() ) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.trinitydesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "Reboot");
- TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
- if (reply.type() == TQT_DBusMessage::ReplyMessage) {
- return true;
+ TQT_DBusProxy logindProxy("org.freedesktop.login1", "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager", dbusConn);
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromBool(true);
+ if (logindProxy.canSend()) {
+ TQT_DBusMessage reply = logindProxy.sendWithReply("Reboot", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage) {
+ return true;
+ }
}
}
}