summaryrefslogtreecommitdiffstats
path: root/src/hardware.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hardware.cpp')
-rw-r--r--src/hardware.cpp50
1 files changed, 41 insertions, 9 deletions
diff --git a/src/hardware.cpp b/src/hardware.cpp
index 7b1c215..54d5027 100644
--- a/src/hardware.cpp
+++ b/src/hardware.cpp
@@ -390,6 +390,9 @@ void HardwareInfo::checkSuspend() {
suspend_states.standby = false;
suspend_states.standby_can = false;
suspend_states.standby_allowed = -1;
+ suspend_states.suspend_hybrid = false;
+ suspend_states.suspend_hybrid_can = false;
+ suspend_states.suspend_hybrid_allowed = -1;
TDERootSystemDevice* rdevice = m_hwdevices->rootSystemDevice();
TDESystemPowerStateList powerStates = rdevice->powerStates();
@@ -399,27 +402,32 @@ void HardwareInfo::checkSuspend() {
if ((*it) == TDESystemPowerState::Active) {
//
}
- if ((*it) == TDESystemPowerState::Standby) {
+ else if ((*it) == TDESystemPowerState::Standby) {
suspend_states.standby = true;
suspend_states.standby_allowed = rdevice->canStandby();
- suspend_states.standby_can = suspend_states.standby_allowed & suspend_states.standby;
+ suspend_states.standby_can = suspend_states.standby_allowed && suspend_states.standby;
}
- if ((*it) == TDESystemPowerState::Freeze) {
+ else if ((*it) == TDESystemPowerState::Freeze) {
suspend_states.freeze = true;
suspend_states.freeze_allowed = rdevice->canFreeze();
- suspend_states.freeze_can = suspend_states.freeze_allowed & suspend_states.freeze;
+ suspend_states.freeze_can = suspend_states.freeze_allowed && suspend_states.freeze;
}
- if ((*it) == TDESystemPowerState::Suspend) {
+ else if ((*it) == TDESystemPowerState::Suspend) {
suspend_states.suspend2ram = true;
suspend_states.suspend2ram_allowed = rdevice->canSuspend();
- suspend_states.suspend2ram_can = suspend_states.suspend2ram_allowed & suspend_states.suspend2ram;
+ suspend_states.suspend2ram_can = suspend_states.suspend2ram_allowed && suspend_states.suspend2ram;
}
- if ((*it) == TDESystemPowerState::Hibernate) {
+ else if ((*it) == TDESystemPowerState::Hibernate) {
suspend_states.suspend2disk = true;
suspend_states.suspend2disk_allowed = rdevice->canHibernate();
- suspend_states.suspend2disk_can = suspend_states.suspend2disk_allowed & suspend_states.suspend2disk;
+ suspend_states.suspend2disk_can = suspend_states.suspend2disk_allowed && suspend_states.suspend2disk;
}
- if ((*it) == TDESystemPowerState::PowerOff) {
+ else if ((*it) == TDESystemPowerState::HybridSuspend) {
+ suspend_states.suspend_hybrid = true;
+ suspend_states.suspend_hybrid_allowed = rdevice->canHybridSuspend();
+ suspend_states.suspend_hybrid_can = suspend_states.suspend_hybrid_allowed && suspend_states.suspend_hybrid;
+ }
+ else if ((*it) == TDESystemPowerState::PowerOff) {
//
}
}
@@ -801,6 +809,27 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false;
}
break;
+
+ case SUSPEND_HYBRID:
+ if (suspend_states.suspend_hybrid && (suspend_states.suspend_hybrid_allowed != 0)) {
+ if (rdevice->setPowerState(TDESystemPowerState::HybridSuspend)) {
+ calledSuspend.start();
+ handleResumeSignal(0);
+ return true;
+ } else {
+ handleResumeSignal(-1);
+ return false;
+ }
+ } else {
+ if ( !suspend_states.suspend_hybrid )
+ kdDebug() << "The machine does not support hybrid suspension." << endl;
+ else
+ kdWarning() << "Policy forbid user to trigger hybrid suspension" << endl;
+
+ return false;
+ }
+ break;
+
case SUSPEND2RAM:
if (suspend_states.suspend2ram && (suspend_states.suspend2ram_allowed != 0)) {
if (rdevice->setPowerState(TDESystemPowerState::Suspend)) {
@@ -820,6 +849,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false;
}
break;
+
case FREEZE:
if (suspend_states.freeze && (suspend_states.freeze_allowed != 0)) {
if (rdevice->setPowerState(TDESystemPowerState::Freeze)) {
@@ -839,6 +869,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false;
}
break;
+
case STANDBY:
if (suspend_states.standby && (suspend_states.standby_allowed != 0)) {
if (rdevice->setPowerState(TDESystemPowerState::Standby)) {
@@ -858,6 +889,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false;
}
break;
+
default:
return false;
}