Add support for freeze suspend state

pull/1/head
Slávek Banko 11 years ago
parent e113ed917c
commit 160e6f21b8

@ -7,7 +7,7 @@ ActionOnPowerButton=SHUTDOWN
ActionOnPowerButtonValue=
ActionOnSleepButton=SUSPEND2RAM
ActionOnS2DiskButton=SUSPEND2DISK
buttonsAllowedActions=SHUTDOWN,LOGOUT_DIALOG,SUSPEND2DISK,SUSPEND2RAM
buttonsAllowedActions=SHUTDOWN,LOGOUT_DIALOG,SUSPEND2DISK,SUSPEND2RAM,FREEZE
AutoSuspendCountdown=true
AutoSuspendCountdownTimeOut=30
Autostart=true
@ -32,7 +32,7 @@ batteryLowActionValue=1
batteryCritical=2
batteryCriticalAction=SHUTDOWN
batteryCriticalActionValue=
batteryAllowedActions=SHUTDOWN,SUSPEND2DISK,SUSPEND2RAM,CPUFREQ_POWERSAVE,CPUFREQ_PERFORMANCE,CPUFREQ_DYNAMIC,BRIGHTNESS
batteryAllowedActions=SHUTDOWN,SUSPEND2DISK,SUSPEND2RAM,FREEZE,CPUFREQ_POWERSAVE,CPUFREQ_PERFORMANCE,CPUFREQ_DYNAMIC,BRIGHTNESS
[default-scheme]
specSsSettings=false

@ -94,6 +94,9 @@ ConfigureDialog::ConfigureDialog( TDEConfig *_config, HardwareInfo *_hwinfo, Set
if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) {
actions.append("Suspend to Disk");
}
if ( suspend.freeze && (suspend.freeze_allowed || suspend.freeze_allowed == -1)) {
actions.append("Freeze");
}
if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
actions.append("Standby");
}
@ -249,6 +252,9 @@ void ConfigureDialog::setIcons(){
else if(actions[0] == "Suspend to RAM") {
tB_scheme->setItemIconSet( 2 ,SmallIcon("suspend_to_ram", TQIconSet::Automatic));
}
else if(actions[0] == "Freeze") {
tB_scheme->setItemIconSet( 2 ,SmallIcon("suspend_to_ram", TQIconSet::Automatic));
}
else if(actions[0] == "Standby") {
tB_scheme->setItemIconSet( 2 ,SmallIcon("stand_by", TQIconSet::Automatic));
}
@ -1797,6 +1803,9 @@ TQString ConfigureDialog::mapActionToDescription( TQString action ) {
} else if (action.startsWith("SUSPEND2RAM")) {
if (actions.contains("Suspend to RAM"))
ret = i18n("Suspend to RAM");
} else if (action.startsWith("FREEZE")) {
if (actions.contains("Freeze"))
ret = i18n("Freeze");
} else if (action.startsWith("CPUFRETQ_POWERSAVE")) {
if (hwinfo->supportCPUFreq())
ret = i18n("CPU Powersave policy");
@ -1836,6 +1845,9 @@ TQString ConfigureDialog::mapDescriptionToAction( TQString description ) {
} else if (description.startsWith("Suspend to RAM") ||
description.startsWith(i18n("Suspend to RAM"))) {
ret = "SUSPEND2RAM";
} else if (description.startsWith("Freeze") ||
description.startsWith(i18n("Freeze"))) {
ret = "FREEZE";
} else if (description.startsWith("CPU Powersave policy") ||
description.startsWith(i18n("CPU Powersave policy"))) {
ret = "CPUFRETQ_POWERSAVE";

@ -79,6 +79,8 @@ void countDownDialog::setPixmap( TQString type )
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("suspend2ram")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("freeze")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("standby")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("stand_by", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else {

@ -251,6 +251,12 @@ Comment[zh_CN]=启动暂挂到 RAM
Comment[zh_TW]=已啟動「暫停寫入到 RAM」
default_presentation=0
[freeze_event]
Name=FreezeEvent
Comment=Freeze is started
Comment[cs]=Přepínání do zmrazeného stavu
default_presentation=0
[standby_event]
Name=StandbyEvent
Comment=Standby is started
@ -302,6 +308,12 @@ Comment[zh_CN]=从“暂挂到 RAM”继续执行
Comment[zh_TW]=從「暫停寫入到 RAM」繼續執行
default_presentation=0
[resume_from_freeze_event]
Name=ResumeFromFreezeEvent
Comment=Resumed from Freeze
Comment[cs]=Probouzení ze zmrazeného stavu
default_presentation=0
[resume_from_standby_event]
Name=ResumeFromStandbyEvent
Comment=Resumed from Standby

@ -528,6 +528,9 @@ void HardwareInfo::checkSuspend() {
suspend_states.suspend2disk = false;
suspend_states.suspend2disk_can = false;
suspend_states.suspend2disk_allowed = -1;
suspend_states.freeze = false;
suspend_states.freeze_can = false;
suspend_states.freeze_allowed = -1;
suspend_states.standby = false;
suspend_states.standby_can = false;
suspend_states.standby_allowed = -1;
@ -545,6 +548,11 @@ void HardwareInfo::checkSuspend() {
suspend_states.standby_allowed = rdevice->canStandby();
suspend_states.standby_can = suspend_states.standby_allowed & suspend_states.standby;
}
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;
}
if ((*it) == TDESystemPowerState::Suspend) {
suspend_states.suspend2ram = true;
suspend_states.suspend2ram_allowed = rdevice->canSuspend();
@ -622,7 +630,7 @@ cpufreq_type HardwareInfo::checkCurrentCPUFreqPolicy() {
kdWarning() << "Could not get information about current governor" << endl;
}
} else {
kdWarning() << "CPU Frequency interface not supported by machine or HAL" << endl;
kdWarning() << "CPU Frequency interface not supported by machine or TDE hardware library" << endl;
}
if (_current != currentCPUFreqPolicy) {
@ -711,7 +719,7 @@ void HardwareInfo::checkCurrentBrightness() {
/*!
* The function initialise the hardware information and collect all
* initial information from HAL.
* initial information from TDE hardware library.
* \return boolean with result of the operation
* \retval true if successful
* \retval false else, if a error occurs
@ -899,10 +907,10 @@ void HardwareInfo::emitBatteryWARNState (int type, int state) {
}
// --> init HW information section -- END <---
// --> HAL method call (trigger actions) section -- START <---
// --> TDE hardware library method call (trigger actions) section -- START <---
/*!
* Function to trigger a suspend via HAL
* Function to trigger a suspend via TDE hardware library
* \param suspend enum of suspend_type with the requested suspend
* \return boolean with result of the operation
* \retval true if successful
@ -955,6 +963,25 @@ 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)) {
calledSuspend.start();
handleResumeSignal(0);
return true;
} else {
handleResumeSignal(-1);
return false;
}
} else {
if ( !suspend_states.freeze )
kdDebug() << "The machine does not support freeze." << endl;
else
kdWarning() << "Policy forbid user to trigger freeze" << endl;
return false;
}
break;
case STANDBY:
if (suspend_states.standby && (suspend_states.standby_allowed != 0)) {
if (rdevice->setPowerState(TDESystemPowerState::Standby)) {
@ -984,7 +1011,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
}
/*!
* Function to set brightness via HAL (if supported by hardware)
* Function to set brightness via TDE hardware library (if supported by hardware)
* \param level Integer with the level to set, (range: 0 - \ref availableBrightnessLevels )
* \param percent Integer with the brightness percentage to set
* \return boolean with result of the operation
@ -1040,7 +1067,7 @@ bool HardwareInfo::setBrightness ( int level, int percent ){
}
/*!
* Function to set the CPU frequency policy via HAL.
* Function to set the CPU frequency policy via TDE hardware library.
* \param cpufreq enum of cpufreq_type with the policy to set
* \param limit integer with range 0 - 100 (only if cpufreq == DYNAMIC)
* \return boolean with result of the operation
@ -1051,7 +1078,7 @@ bool HardwareInfo::setCPUFreq ( cpufreq_type cpufreq, int limit ) {
if (trace) kdDebug() << funcinfo << "IN: " << "cpufreq_type: " << cpufreq << " limit: " << limit << endl;
if (!cpuFreq) {
kdError() << "This machine does not support change the CPU Freq via HAL" << endl;
kdError() << "This machine does not support change the CPU Freq via TDE hardware library" << endl;
return false;
}
@ -1149,7 +1176,7 @@ bool HardwareInfo::setCPUFreq ( cpufreq_type cpufreq, int limit ) {
}
/*!
* Function to set the CPU governor via HAL.
* Function to set the CPU governor via TDE hardware library.
* \param governor char * with the name of the governor
* \return boolean with result of the operation
* \retval true if successful
@ -1179,7 +1206,7 @@ bool HardwareInfo::setCPUFreqGovernor( const char *governor ) {
/*!
* Function to set the powersave mode (incl. e.g. disk settings) via HAL.
* Function to set the powersave mode (incl. e.g. disk settings) via TDE hardware library.
* \param on boolean which tell if enable/disable powersave mode
* \return boolean with result of the operation
* \retval true if successful
@ -1192,14 +1219,14 @@ bool HardwareInfo::setPowerSave( bool on ) {
// FIXME
// Set up power saving to the best of our ability using "raw" functions
printf("[FIXME] HardwareInfo::setPowerSave unimplemented!\n\r"); fflush(stdout);
printf("[FIXME] HardwareInfo::setPowerSave unimplemented!\n"); fflush(stdout);
kdDebugFuncOut(trace);
return retval;
}
/*!
* Function to call GetSchedPowerSavings() via HAL.
* Function to call GetSchedPowerSavings() via TDE hardware library.
* \return boolean with result of the operation
* \retval true if successful
* \retval false else, if a error occurs
@ -1216,8 +1243,8 @@ bool HardwareInfo::getSchedPowerSavings() {
}
/*!
* Function to call SetSchedPowerSavings() via HAL. Note: this would only work on
* Multiprocessor/-core machines.
* Function to call SetSchedPowerSavings() via TDE hardware library.
* Note: this would only work on multiprocessor/-core machines.
* \return boolean with result of the operation
* \retval true if successful
* \retval false else, if a error occurs
@ -1234,7 +1261,7 @@ bool HardwareInfo::setSchedPowerSavings( bool enable ) {
}
// --> HAL method call (trigger actions) section -- END <---
// --> TDE hardware library method call (trigger actions) section -- END <---
// --> private helper functions/slots to forward/handle events -- START <--
// need this functions to make events from HAL/D-Bus independent
@ -1517,9 +1544,9 @@ bool HardwareInfo::isLaptop() const {
}
/*!
* The function return info if there is a working connection to D-Bus and HAL.
* The function return info if there is a working connection to TDE hardware library.
* This mean if we get hardwareinformation
* \return boolean with info if D-Bus and HAL work
* \return boolean with info if TDE hardware library work
* \retval true if connected
* \retval false if not connected
*/
@ -1561,7 +1588,7 @@ bool HardwareInfo::hasPMU() const {
/*!
* The function return the status of \ref brightness.
* \return boolean with info if machine support brightness changes via HAL
* \return boolean with info if machine support brightness changes via TDE hardware library
* \retval true if support brightness changes
* \retval false else
*/
@ -1571,7 +1598,7 @@ bool HardwareInfo::supportBrightness() const {
/*!
* The function return the status of \ref cpuFreq.
* \return boolean with info if machine support change the CPU frequency via HAL
* \return boolean with info if machine support change the CPU frequency via TDE hardware library
* \retval true if support brightness changes
* \retval false else
*/

@ -55,6 +55,7 @@
enum suspend_type {
SUSPEND2DISK,
SUSPEND2RAM,
FREEZE,
STANDBY
};
@ -84,7 +85,7 @@ enum ERROR_MSG {
//! hold information if suspend/standby/pm actions are supported and allowed
/*!
* This dictionary contains information about the available pm capabilities and
* the related interfaces in HAL.
* the related interfaces in TDE hardware library.
*/
typedef struct SuspendStates {
//! true if the machine support suspend2ram and the interface is available
@ -99,6 +100,12 @@ typedef struct SuspendStates {
bool suspend2disk_can;
//! true if the machine support suspend2disk and PolicyKit allow to call the interface
int suspend2disk_allowed;
//! true if the machine support freeze and the interface is available
bool freeze;
//! true if the machine support freeze, but no interface available
bool freeze_can;
//! true if the machine support freeze and PolicyKit allow to call the interface
int freeze_allowed;
//! true if the machine support standby and the interface is available
bool standby;
//! true if the machine support standby, but no interface available
@ -113,6 +120,9 @@ typedef struct SuspendStates {
suspend2disk = false;
suspend2disk_can = false;
suspend2disk_allowed = -1;
freeze = false;
freeze_can = false;
freeze_allowed = -1;
standby = false;
standby_can = false;
standby_allowed = -1;
@ -143,15 +153,15 @@ private:
//! hold the UDIs of all hardware we handle atm
/*!
* This TQStringList contains the list of UDIs we handle at the moment in this
* class. This should be used to handle device events from HAL for devices we
* want to monitor
* class. This should be used to handle device events from TDE hardware library
* for devices we want to monitor
*/
TQStringList allUDIs;
//! hold information if suspend/standby/pm actions are supported and allowed
/*!
* This dictionary contains information about the available pm capabilities and
* the related interfaces in HAL.
* the related interfaces in TDE hardware library.
*/
SuspendStates suspend_states;
@ -207,18 +217,18 @@ private:
* \li false: else
*/
bool has_PMU;
//! if the machine support change CPU Freq via HAL interface
//! if the machine support change CPU Freq via TDE hardware library
/*!
* This boolean represent information if the machine support change the
* CPU freqency via HAL.
* CPU freqency via TDE hardware library.
* \li true: if supported
* \li false: else
*/
bool cpuFreq;
//! if the machine support change *SchedPowerSavings methodes via HAL interface
//! if the machine support change *SchedPowerSavings methodes via TDE hardware library
/*!
* This boolean represent information if the machine support change the
* SchedPowerSavings methodes via HAL.
* SchedPowerSavings methodes via TDE hardware library.
* \li true: if supported
* \li false: else
*/
@ -258,7 +268,7 @@ private:
//! if the current user can use the CPU Freq interface
/*!
* This integer tell if the current user is allowed to change the
* CPU Frequency policy via the HAL interface
* CPU Frequency policy via the TDE hardware library
* \li 1: if allowed
* \li 0: if not allowed
* \li -1: if unknown (e.g. there is no policy/PolicyKit)
@ -267,7 +277,7 @@ private:
//! if the current user can use the brightness interface
/*!
* This integer tell if the current user is allowed to change the
* brightness via the HAL interface
* brightness via the TDE hardware library
* \li 1: if allowed
* \li 0: if not allowed
* \li -1: if unknown (e.g. there is no policy/PolicyKit)
@ -294,7 +304,7 @@ private:
void checkPowermanagement();
//! check the possible suspend/standby states
void checkSuspend();
//! check if the machine support change CPU Freq via HAL
//! check if the machine support change CPU Freq via TDE hardware library
void checkCPUFreq();
//! check the current brightness level
void checkCurrentBrightness();
@ -311,9 +321,9 @@ private:
bool checkIfHandleDevice ( TQString _udi, int *type );
//! to set the CPUFreq governor
bool setCPUFreqGovernor( const char *governor );
//! to get the state of SchedPowerSave setting of kernel/HAL
//! to get the state of SchedPowerSave setting of kernel/TDE hardware library
bool getSchedPowerSavings();
//! to set the state of SchedPowerSave setting of kernel/HAL
//! to set the state of SchedPowerSave setting of kernel/TDE hardware library
bool setSchedPowerSavings( bool enable );
//! find and update a battery information
@ -462,7 +472,7 @@ public:
bool getLidclose() const;
//! check if the machine is a latop
bool isLaptop() const;
//! check if there is a connection to D-Bus _and_ HAL
//! check if there is a connection to TDE hardware library
bool isOnline() const;
//! check if the machine support ACPI
bool hasACPI() const;
@ -477,10 +487,10 @@ public:
//! check if the current session is active
bool currentSessionIsActive() const;
// --> functions to call a HAL interface and trigger an action
//! execute/trigger a suspend via the HAL interface
// --> functions to call a TDE hardware library and trigger an action
//! execute/trigger a suspend via the TDE hardware library
bool suspend ( suspend_type suspend );
//! set the brightness via HAL interface
//! set the brightness via TDE hardware library
bool setBrightness ( int level, int percent = -1);
//! to set the brightness down
bool setBrightnessDown(int percentageStep = -1);
@ -488,7 +498,7 @@ public:
bool setBrightnessUp(int percentageStep = -1);
//! set the CPU frequency policy/speed
bool setCPUFreq ( cpufreq_type cpufreq, int limit = 51 );
//! call SetPowerSave method on HAL.
//! call SetPowerSave method on TDE hardware library.
bool setPowerSave( bool on );
//! function to set warning states for the primary battery collection

@ -300,12 +300,12 @@ bool Settings::load_general_settings(){
}
sleepButtonAction = mapActionToType(tdeconfig->readEntry("ActionOnSleepButton",""));
if ((sleepButtonAction != GO_SUSPEND2RAM) && (sleepButtonAction != GO_SUSPEND2DISK)) {
if ((sleepButtonAction != GO_SUSPEND2RAM) && (sleepButtonAction != GO_SUSPEND2DISK) && (sleepButtonAction != GO_FREEZE)) {
sleepButtonAction = NONE;
}
s2diskButtonAction = mapActionToType(tdeconfig->readEntry("ActionOnS2DiskButton",""));
if ((s2diskButtonAction != GO_SUSPEND2RAM) && (s2diskButtonAction != GO_SUSPEND2DISK)) {
if ((s2diskButtonAction != GO_SUSPEND2RAM) && (s2diskButtonAction != GO_SUSPEND2DISK) && (s2diskButtonAction != GO_FREEZE)) {
s2diskButtonAction = NONE;
}
@ -332,6 +332,8 @@ action Settings::mapActionToType (TQString _action) {
return GO_SUSPEND2DISK;
} else if (_action.startsWith("SUSPEND2RAM")) {
return GO_SUSPEND2RAM;
} else if (_action.startsWith("FREEZE")) {
return GO_FREEZE;
} else if (_action.startsWith("CPUFRETQ_POWERSAVE")) {
return CPUFRETQ_POWERSAVE;
} else if (_action.startsWith("CPUFRETQ_DYNAMIC")) {

@ -42,6 +42,7 @@ enum action{
LOGOUT_DIALOG,
GO_SUSPEND2RAM,
GO_SUSPEND2DISK,
GO_FREEZE,
SWITCH_SCHEME,
BRIGHTNESS,
CPUFRETQ_POWERSAVE,

@ -62,6 +62,8 @@ void suspendDialog::setPixmap( TQString type )
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("suspend2ram")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("freeze")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("standby")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("stand_by", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else {

@ -194,6 +194,8 @@ void tdepowersave::initMenu() {
TQIconSet::Automatic),
i18n("Suspend to RAM"), this,
TQT_SLOT(do_suspend2ram()));
FREEZE_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("suspend_to_ram", TQIconSet::Automatic),
i18n("Freeze"), this, TQT_SLOT(do_freeze()));
STANDBY_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("stand_by", TQIconSet::Automatic),
i18n("Standby"), this, TQT_SLOT(do_standby()));
@ -685,9 +687,9 @@ void tdepowersave::slotConfigProcessExited(TDEProcess *proc){
}
/*!
* \b TQT_SLOT to send the command for "suspend to disk" to HAL daemon.
* \b TQT_SLOT to send the command for "suspend to disk" to TDE hardware library.
* If there is a error while "suspend to disk" the user get e messagebox.
* This function need a running HAL daemon for "suspend to disk".
* This function need a power management backend in TDE hardware library for "suspend to disk".
* \return boolean with the result of the operation
* \retval true if successful
* \retval false if command not supported or if powersaved not running
@ -734,16 +736,16 @@ bool tdepowersave::do_suspend2disk(){
return false;
}
} else {
kdWarning() << "This machine does not provide suspend2disk via HAL" << endl;
kdWarning() << "This machine does not provide suspend to disk state" << endl;
kdDebugFuncOut(trace);
return false;
}
}
/*!
* \b TQT_SLOT to send the command for "suspend to RAM" to the HAL daemon.
* \b TQT_SLOT to send the command for "suspend to RAM" to the TDE hardware library.
* If there is a error while "suspend to RAM" the user get e messagebox.
* This function need a running HAL daemon for "suspend to RAM".
* This function need a power management backend in TDE hardware library for "suspend to RAM".
* \return boolean with the result of the operation
* \retval true if successful
* \retval false if command not supported or if powersaved not running
@ -790,16 +792,71 @@ bool tdepowersave::do_suspend2ram(){
return false;
}
} else {
kdWarning() << "This machine does not provide suspend2ram via HAL" << endl;
kdWarning() << "This machine does not provide suspend to ram state" << endl;
kdDebugFuncOut(trace);
return false;
}
}
/*!
* \b TQT_SLOT to send the command for "stand-by" to the HAL daemon.
* \b TQT_SLOT to send the command for "freeze" to the TDE hardware library.
* If there is a error while "freeze" the user get e messagebox.
* This function need a power management backend in TDE hardware library for "freeze".
* \return boolean with the result of the operation
* \retval true if successful
* \retval false if command not supported or if powersaved not running
*/
bool tdepowersave::do_freeze(){
kdDebugFuncIn(trace);
if (suspend.freeze) {
if (suspend.freeze_allowed || suspend.freeze_allowed == -1) {
calledSuspend = FREEZE;
if (!handleMounts(true)) {
kdWarning() << "Could not umount ..." << endl;
calledSuspend = -1;
kdDebugFuncOut(trace);
return false;
}
if(settings->lockOnSuspend) {
display->lockScreen( settings->lockmethod );
}
autoSuspend->stop();
autoDimm->stop();
notifySuspend(calledSuspend);
bool ret = hwinfo->suspend(FREEZE);
if (ret) {
kdDebugFuncOut(trace);
return true;
} else {
KPassivePopup::message( i18n("WARNING"),i18n("Freeze failed"),
SmallIcon("messagebox_warning", 20), this,
i18n("Warning").ascii(), 15000);
kdDebugFuncOut(trace);
return false;
}
} else {
KPassivePopup::message( i18n("WARNING"),i18n("Freeze disabled by administrator."),
SmallIcon("messagebox_warning", 20), this,
i18n("Warning").ascii(), 15000);
this->contextMenu()->setItemEnabled(FREEZE_MENU_ID, false);
kdDebugFuncOut(trace);
return false;
}
} else {
kdWarning() << "This machine does not provide freeze suspend state" << endl;
kdDebugFuncOut(trace);
return false;
}
}
/*!
* \b TQT_SLOT to send the command for "stand-by" to the TDE hardware library.
* If there is a error while "stand-by" the user get e messagebox.
* This function need a running HAL daemon for "stand-by".
* This function need a power management backend in TDE hardware library for "stand-by".
* \return boolean with the result of the operation
* \retval true if successful
* \retval false if command not supported or if powersaved not running
@ -845,7 +902,7 @@ bool tdepowersave::do_standby(){
return false;
}
} else {
kdWarning() << "This machine does not provide suspend2ram via HAL" << endl;
kdWarning() << "This machine does not provide standby suspend state" << endl;
kdDebugFuncOut(trace);
return false;
}
@ -872,6 +929,11 @@ void tdepowersave::do_autosuspendWarn() {
allowed = true;
}
}
else if (settings->autoInactiveAction == "Freeze") {
if ( suspend.freeze && (suspend.freeze_allowed || suspend.freeze_allowed == -1)) {
allowed = true;
}
}
else if (settings->autoInactiveAction == "Standby") {
if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
allowed = true;
@ -890,6 +952,8 @@ void tdepowersave::do_autosuspendWarn() {
countdown->setPixmap("suspend2disk");
} else if (settings->autoInactiveAction == "Suspend to RAM") {
countdown->setPixmap("suspend2ram");
} else if (settings->autoInactiveAction == "Freeze") {
countdown->setPixmap("suspend2ram");
} else if (settings->autoInactiveAction == "Standby") {
countdown->setPixmap("standby");
} else {
@ -943,6 +1007,8 @@ bool tdepowersave::do_autosuspend(bool chancel) {
return do_suspend2disk();
} else if (settings->autoInactiveAction == "Suspend to RAM") {
return do_suspend2ram();
} else if (settings->autoInactiveAction == "Freeze") {
return do_freeze();
} else if (settings->autoInactiveAction == "Standby") {
return do_standby();
} else {
@ -1389,6 +1455,7 @@ void tdepowersave::update(){
if (!hwinfo->isOnline()){
this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, false);
this->contextMenu()->setItemVisible(SUSPEND2RAM_MENU_ID, false);
this->contextMenu()->setItemVisible(FREEZE_MENU_ID, false);
this->contextMenu()->setItemVisible(STANDBY_MENU_ID, false);
this->contextMenu()->setItemVisible(SLEEP_SEPARATOR_MENU_ID, false);
this->contextMenu()->setItemVisible(SCHEME_SEPARATOR_MENU_ID, false);
@ -1411,6 +1478,7 @@ void tdepowersave::update(){
}
this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, true);
this->contextMenu()->setItemVisible(SUSPEND2RAM_MENU_ID, true);
this->contextMenu()->setItemVisible(FREEZE_MENU_ID, true);
this->contextMenu()->setItemVisible(STANDBY_MENU_ID, true);
this->contextMenu()->setItemVisible(SLEEP_SEPARATOR_MENU_ID, true);
this->contextMenu()->setItemVisible(SCHEME_SEPARATOR_MENU_ID, true);
@ -1439,6 +1507,15 @@ void tdepowersave::update(){
this->contextMenu()->setItemEnabled(SUSPEND2RAM_MENU_ID, false);
}
if (suspend.freeze && (suspend.freeze_allowed || suspend.freeze_allowed == -1)) {
this->contextMenu()->setItemEnabled(FREEZE_MENU_ID, true);
} else {
if (!suspend.freeze)
this->contextMenu()->setItemVisible(FREEZE_MENU_ID, false);
else
this->contextMenu()->setItemEnabled(FREEZE_MENU_ID, false);
}
if (suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
this->contextMenu()->setItemEnabled(STANDBY_MENU_ID, true);
} else {
@ -1840,6 +1917,11 @@ void tdepowersave::setAutoSuspend( bool resumed ){
allowed = true;
}
}
else if (settings->autoInactiveAction == "Freeze") {
if ( suspend.freeze && (suspend.freeze_allowed || suspend.freeze_allowed == -1)) {
allowed = true;
}
}
else if (settings->autoInactiveAction == "Standby") {
if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
allowed = true;
@ -2071,6 +2153,9 @@ void tdepowersave::handleActionCall ( action action, int value , bool checkAC, b
case GO_SUSPEND2DISK:
TQTimer::singleShot(100, this, TQT_SLOT(do_suspend2disk()));
break;
case GO_FREEZE:
TQTimer::singleShot(100, this, TQT_SLOT(do_freeze()));
break;
case BRIGHTNESS:
hwinfo->setBrightness( -1, value );
break;
@ -2192,6 +2277,11 @@ void tdepowersave::notifySuspend( int suspendType ) {
i18n("System is going into %1 now.").
arg(i18n("Suspend to RAM")));
break;
case FREEZE:
KNotifyClient::event( this->winId(), "freeze_event",
i18n("System is going into %1 now.").
arg(i18n("Freeze")));
break;
case STANDBY:
KNotifyClient::event( this->winId(), "standby_event",
i18n("System is going into %1 now.").
@ -2252,6 +2342,11 @@ void tdepowersave::handleResumeSignal() {
i18n("System is resumed from %1.").arg(
i18n("Suspend to RAM")));
break;
case FREEZE:
KNotifyClient::event( this->winId(), "resume_from_freeze_event",
i18n("System is resumed from %1.").arg(
i18n("Freeze")));
break;
case STANDBY:
KNotifyClient::event( this->winId(), "resume_from_standby_event",
i18n("System is resumed from %1.").arg(
@ -2301,6 +2396,10 @@ void tdepowersave::handleResumeSignal() {
logview = new LogViewer ("/var/log/suspend2ram.log");
logview->show();
break;
case FREEZE:
logview = new LogViewer ("/var/log/freeze.log");
logview->show();
break;
case STANDBY:
logview = new LogViewer ("/var/log/standby.log");
logview->show();
@ -2368,6 +2467,9 @@ TQString tdepowersave::getSuspendString (int type) {
case SUSPEND2RAM:
return i18n("Suspend to RAM");
break;
case FREEZE:
return i18n("Freeze");
break;
case STANDBY:
return i18n("Standby");
break;
@ -2517,6 +2619,9 @@ TQStringList tdepowersave::allowed_sleepingStates(){
suspend.suspend2ram_allowed == -1)){
sleepList.append("suspendToRAM");
}
if (suspend.freeze && (suspend.freeze_allowed || suspend.freeze_allowed == -1)){
sleepList.append("freeze");
}
if (suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)){
sleepList.append("standBy");
}
@ -2607,7 +2712,19 @@ bool tdepowersave::do_suspendToRAM(){
}
/*!
* DCOP Interface funtion to send the suspend to disk command to powersave.
* DCOP Interface funtion to send the freeze command to powersave.
* \return boolean with the result of calling do_freeze()
* \retval true if successful
* \retval false if not supported or powersaved not running
*/
bool tdepowersave::do_suspendFreeze(){
kdDebugFuncIn(trace);
kdDebugFuncOut(trace);
return do_freeze();
}
/*!
* DCOP Interface funtion to send the standby command to powersave.
* \return boolean with the result of calling do_standby()
* \retval true if successful
* \retval false if not supported or powersaved not running

@ -190,6 +190,9 @@ private:
/*! contains the ID of the menuentry for suspend-to-ram */
int SUSPEND2RAM_MENU_ID;
//! a menu entry ID
/*! contains the ID of the menuentry for freeze */
int FREEZE_MENU_ID;
//! a menu entry ID
/*! contains the ID of the menuentry for stand-by */
int STANDBY_MENU_ID;
//! a menu seperator ID
@ -312,6 +315,8 @@ private slots:
//! send command for stand-by to the TDE hardware library
bool do_standby();
//! send command for freeze to the TDE hardware library
bool do_freeze();
//! send command for suspend_to_disk to the TDE hardware library
bool do_suspend2disk();
//! send command for suspend_to_RAM to the TDE hardware library
@ -428,6 +433,8 @@ k_dcop:
bool do_suspendToDisk();
//! dcop function to send 'suspend to RAM' command to powersaved
bool do_suspendToRAM();
//! dcop function to send 'freeze' command to powersaved
bool do_suspendFreeze();
//! dcop function to send 'standby' command to powersaved
bool do_standBy();
//! dcop function to set the brightness down

Loading…
Cancel
Save