summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2019-02-24 03:46:51 +0100
committerSlávek Banko <[email protected]>2019-02-24 03:46:51 +0100
commitc49ee53043b73fac7fe7e956360f1e3cdc342c6e (patch)
tree734b3c688ad41c5872d8910386648ab9bd5987e7
parent43609c8a21144b56a53d53757639fc6c6298c10d (diff)
downloadtdelibs-c49ee53043b73fac7fe7e956360f1e3cdc342c6e.tar.gz
tdelibs-c49ee53043b73fac7fe7e956360f1e3cdc342c6e.zip
Fixed support for logind power state calls.
This resolves bug 2661 and bug 2975. Signed-off-by: Michele Calgaro <[email protected]>
-rw-r--r--tdecore/tdehw/tderootsystemdevice.cpp85
1 files changed, 39 insertions, 46 deletions
diff --git a/tdecore/tdehw/tderootsystemdevice.cpp b/tdecore/tdehw/tderootsystemdevice.cpp
index b9a0bef9c..09613778b 100644
--- a/tdecore/tdehw/tderootsystemdevice.cpp
+++ b/tdecore/tdehw/tderootsystemdevice.cpp
@@ -698,41 +698,32 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
#ifdef WITH_LOGINDPOWER
{
- // No support for "freeze" in org.freedesktop.login1
+ // 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;
+ }
}
- }
- else if (ps == TDESystemPowerState::HybridSuspend) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.login1",
- "/org/freedesktop/login1",
- "org.freedesktop.login1.Manager",
- "HybridSleep");
- TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
- if (reply.type() == TQT_DBusMessage::ReplyMessage) {
- return true;
+ else if (ps == TDESystemPowerState::HybridSuspend) {
+ TQT_DBusMessage reply = logindProxy.sendWithReply("HybridSleep", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage) {
+ return true;
+ }
}
}
}
@@ -927,14 +918,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;
+ }
}
}
}
@@ -994,14 +986,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;
+ }
}
}
}