summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/tderootsystemdevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdecore/tdehw/tderootsystemdevice.cpp')
-rw-r--r--tdecore/tdehw/tderootsystemdevice.cpp59
1 files changed, 56 insertions, 3 deletions
diff --git a/tdecore/tdehw/tderootsystemdevice.cpp b/tdecore/tdehw/tderootsystemdevice.cpp
index 774bc091a..488c60e2b 100644
--- a/tdecore/tdehw/tderootsystemdevice.cpp
+++ b/tdecore/tdehw/tderootsystemdevice.cpp
@@ -147,6 +147,45 @@ bool TDERootSystemDevice::canStandby() {
return FALSE;
}
+bool TDERootSystemDevice::canFreeze() {
+ // Network file systems mounted on $HOME typically cause nasty suspend/resume failures
+ // See Bug 1615 for details
+ if (isNetworkFileSystem(TDEStorageDevice::determineFileSystemType(TDEGlobal::dirs()->localtdedir()))) {
+ return FALSE;
+ }
+
+ TQString statenode = "/sys/power/state";
+ int rval = access (statenode.ascii(), W_OK);
+ if (rval == 0) {
+ if (powerStates().contains(TDESystemPowerState::Freeze)) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+ }
+
+#ifdef WITH_TDEHWLIB_DAEMONS
+ {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ // can freeze?
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.trinitydesktop.hardwarecontrol",
+ "/org/trinitydesktop/hardwarecontrol",
+ "org.trinitydesktop.hardwarecontrol.Power",
+ "CanFreeze");
+ 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::canSuspend() {
// Network file systems mounted on $HOME typically cause nasty suspend/resume failures
// See Bug 1615 for details
@@ -352,7 +391,7 @@ bool TDERootSystemDevice::canHibernate() {
bool TDERootSystemDevice::canPowerOff() {
TDEConfig *config = TDEGlobal::config();
config->reparseConfiguration(); // config may have changed in the KControl module
-
+
config->setGroup("General" );
bool maysd = false;
#ifdef WITH_CONSOLEKIT
@@ -394,7 +433,7 @@ bool TDERootSystemDevice::canPowerOff() {
bool TDERootSystemDevice::canReboot() {
TDEConfig *config = TDEGlobal::config();
config->reparseConfiguration(); // config may have changed in the KControl module
-
+
config->setGroup("General" );
bool mayrb = false;
#ifdef WITH_CONSOLEKIT
@@ -460,7 +499,7 @@ void TDERootSystemDevice::setHibernationMethod(TDESystemHibernationMethod::TDESy
}
bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState ps) {
- if ((ps == TDESystemPowerState::Standby) || (ps == TDESystemPowerState::Suspend) || (ps == TDESystemPowerState::Hibernate)) {
+ if ((ps == TDESystemPowerState::Standby) || (ps == TDESystemPowerState::Freeze) || (ps == TDESystemPowerState::Suspend) || (ps == TDESystemPowerState::Hibernate)) {
TQString statenode = "/sys/power/state";
TQFile file( statenode );
if ( file.open( IO_WriteOnly ) ) {
@@ -468,6 +507,9 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
if (ps == TDESystemPowerState::Standby) {
powerCommand = "standby";
}
+ if (ps == TDESystemPowerState::Freeze) {
+ powerCommand = "freeze";
+ }
if (ps == TDESystemPowerState::Suspend) {
powerCommand = "mem";
}
@@ -591,6 +633,17 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
return true;
}
}
+ else if (ps == TDESystemPowerState::Freeze) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.trinitydesktop.hardwarecontrol",
+ "/org/trinitydesktop/hardwarecontrol",
+ "org.trinitydesktop.hardwarecontrol.Power",
+ "Freeze");
+ 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",