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= ActionOnPowerButtonValue=
ActionOnSleepButton=SUSPEND2RAM ActionOnSleepButton=SUSPEND2RAM
ActionOnS2DiskButton=SUSPEND2DISK ActionOnS2DiskButton=SUSPEND2DISK
buttonsAllowedActions=SHUTDOWN,LOGOUT_DIALOG,SUSPEND2DISK,SUSPEND2RAM buttonsAllowedActions=SHUTDOWN,LOGOUT_DIALOG,SUSPEND2DISK,SUSPEND2RAM,FREEZE
AutoSuspendCountdown=true AutoSuspendCountdown=true
AutoSuspendCountdownTimeOut=30 AutoSuspendCountdownTimeOut=30
Autostart=true Autostart=true
@ -32,7 +32,7 @@ batteryLowActionValue=1
batteryCritical=2 batteryCritical=2
batteryCriticalAction=SHUTDOWN batteryCriticalAction=SHUTDOWN
batteryCriticalActionValue= 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] [default-scheme]
specSsSettings=false specSsSettings=false

@ -16,11 +16,11 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/ ***************************************************************************/
/*! \file configuredialog.cpp /*! \file configuredialog.cpp
* All here displayed file members of configureDialog.cpp are related to operations with the * All here displayed file members of configureDialog.cpp are related to operations with the
* configure dialog for tdepowersave * configure dialog for tdepowersave
* \brief In this file can be found all configure dialog related code. * \brief In this file can be found all configure dialog related code.
* \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de> * \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
* \date 2005 * \date 2005
*/ */
@ -78,7 +78,7 @@ ConfigureDialog::ConfigureDialog( TDEConfig *_config, HardwareInfo *_hwinfo, Set
if(hwinfo->supportBrightness()) { if(hwinfo->supportBrightness()) {
brightnessLevels = hwinfo->getMaxBrightnessLevel() -1; brightnessLevels = hwinfo->getMaxBrightnessLevel() -1;
brightness_last = hwinfo->getCurrentBrightnessLevel(); brightness_last = hwinfo->getCurrentBrightnessLevel();
} else { } else {
brightnessLevels = -1; brightnessLevels = -1;
brightness_last = -1; brightness_last = -1;
} }
@ -94,6 +94,9 @@ ConfigureDialog::ConfigureDialog( TDEConfig *_config, HardwareInfo *_hwinfo, Set
if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) { if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1)) {
actions.append("Suspend to Disk"); 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)) { if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
actions.append("Standby"); actions.append("Standby");
} }
@ -101,11 +104,11 @@ ConfigureDialog::ConfigureDialog( TDEConfig *_config, HardwareInfo *_hwinfo, Set
setIcons(); setIcons();
setTooltips(); setTooltips();
getSchemeList(); getSchemeList();
setSchemeList(); setSchemeList();
setGeneralSettings(); setGeneralSettings();
setInactivityBox(); setInactivityBox();
selectScheme(settings->currentScheme); selectScheme(settings->currentScheme);
tL_valueBrightness->setFrameStyle(TQFrame::Panel | TQFrame::Sunken); tL_valueBrightness->setFrameStyle(TQFrame::Panel | TQFrame::Sunken);
tL_valueBrightness->setBackgroundMode(TQt::PaletteBase); tL_valueBrightness->setBackgroundMode(TQt::PaletteBase);
tL_valueBrightness->setAlignment(TQt::AlignCenter); tL_valueBrightness->setAlignment(TQt::AlignCenter);
@ -137,7 +140,7 @@ ConfigureDialog::~ConfigureDialog(){
/* ---- START General setup SECTION ---- */ /* ---- START General setup SECTION ---- */
/*! /*!
* This used to fill the TQListBox listBox_schemes and the scheme related TQComboBoxes * This used to fill the TQListBox listBox_schemes and the scheme related TQComboBoxes
* with the existing schemes. * with the existing schemes.
*/ */
@ -170,7 +173,7 @@ void ConfigureDialog::setSchemeList(){
cB_acScheme->insertItem(i18n(_tmp)); cB_acScheme->insertItem(i18n(_tmp));
cB_batteryScheme->insertItem(i18n(_tmp)); cB_batteryScheme->insertItem(i18n(_tmp));
} else if((*it) == "AdvancedPowersave" || (*it) == i18n("Advanced Powersave")) { } else if((*it) == "AdvancedPowersave" || (*it) == i18n("Advanced Powersave")) {
listBox_schemes->insertItem(SmallIcon("scheme_advanced_powersave", listBox_schemes->insertItem(SmallIcon("scheme_advanced_powersave",
TQIconSet::Automatic), i18n("Advanced Powersave")); TQIconSet::Automatic), i18n("Advanced Powersave"));
cB_acScheme->insertItem(i18n("Advanced Powersave")); cB_acScheme->insertItem(i18n("Advanced Powersave"));
cB_batteryScheme->insertItem(i18n("Advanced Powersave")); cB_batteryScheme->insertItem(i18n("Advanced Powersave"));
@ -185,7 +188,7 @@ void ConfigureDialog::setSchemeList(){
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
/*! /*!
* This used to get the list of schemes in from the config * This used to get the list of schemes in from the config
*/ */
void ConfigureDialog::getSchemeList(){ void ConfigureDialog::getSchemeList(){
@ -199,7 +202,7 @@ void ConfigureDialog::getSchemeList(){
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
/*! /*!
* This used to set the current scheme based on the name of the scheme * This used to set the current scheme based on the name of the scheme
* \param _scheme TQString with the name of the scheme * \param _scheme TQString with the name of the scheme
*/ */
@ -218,11 +221,11 @@ void ConfigureDialog::selectScheme (TQString _scheme){
} else { } else {
listBox_schemes->setCurrentItem(0); listBox_schemes->setCurrentItem(0);
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
/*! /*!
* This used to set all needed Icons for the dialog. * This used to set all needed Icons for the dialog.
*/ */
void ConfigureDialog::setIcons(){ void ConfigureDialog::setIcons(){
@ -242,17 +245,20 @@ void ConfigureDialog::setIcons(){
tB_scheme->setItemIconSet( 0 ,SmallIcon("tdescreensaver", TQIconSet::Automatic)); tB_scheme->setItemIconSet( 0 ,SmallIcon("tdescreensaver", TQIconSet::Automatic));
tB_scheme->setItemIconSet( 1 ,SmallIcon("display", TQIconSet::Automatic)); tB_scheme->setItemIconSet( 1 ,SmallIcon("display", TQIconSet::Automatic));
if(actions[0] == "Suspend to Disk") { if(actions[0] == "Suspend to Disk") {
tB_scheme->setItemIconSet( 2 ,SmallIcon("suspend_to_disk", TQIconSet::Automatic)); tB_scheme->setItemIconSet( 2 ,SmallIcon("suspend_to_disk", TQIconSet::Automatic));
} }
else if(actions[0] == "Suspend to RAM") { else if(actions[0] == "Suspend to RAM") {
tB_scheme->setItemIconSet( 2 ,SmallIcon("suspend_to_ram", TQIconSet::Automatic)); 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") { else if(actions[0] == "Standby") {
tB_scheme->setItemIconSet( 2 ,SmallIcon("stand_by", TQIconSet::Automatic)); tB_scheme->setItemIconSet( 2 ,SmallIcon("stand_by", TQIconSet::Automatic));
} }
tB_scheme->setItemIconSet( 3 ,SmallIcon("autodimm", TQIconSet::Automatic)); tB_scheme->setItemIconSet( 3 ,SmallIcon("autodimm", TQIconSet::Automatic));
tB_scheme->setItemIconSet( 4 ,SmallIcon("processor", TQIconSet::Automatic)); tB_scheme->setItemIconSet( 4 ,SmallIcon("processor", TQIconSet::Automatic));
tB_scheme->setItemIconSet( 5 ,SmallIcon("misc", TQIconSet::Automatic)); tB_scheme->setItemIconSet( 5 ,SmallIcon("misc", TQIconSet::Automatic));
@ -267,7 +273,7 @@ void ConfigureDialog::setIcons(){
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
/*! /*!
* This used to set all needed Tooltips for the dialog. * This used to set all needed Tooltips for the dialog.
*/ */
void ConfigureDialog::setTooltips(){ void ConfigureDialog::setTooltips(){
@ -288,12 +294,12 @@ void ConfigureDialog::setTooltips(){
TQToolTip::add(cB_disablePM, i18n("This disables DPMS support.")); TQToolTip::add(cB_disablePM, i18n("This disables DPMS support."));
TQToolTip::add(cB_lockSuspend, i18n("If selected, the screen is locked on suspend or standby.")); TQToolTip::add(cB_lockSuspend, i18n("If selected, the screen is locked on suspend or standby."));
TQToolTip::add(cB_lockLid, i18n("If selected, the screen is locked if the lid close event is triggered.")); TQToolTip::add(cB_lockLid, i18n("If selected, the screen is locked if the lid close event is triggered."));
TQToolTip::add(cB_autoSuspend, i18n("Check this box to enable or disable automatic suspension of " TQToolTip::add(cB_autoSuspend, i18n("Check this box to enable or disable automatic suspension of "
"the computer.")); "the computer."));
TQToolTip::add(cB_autoInactivity, i18n("Activate this action if the user was inactive for the defined " TQToolTip::add(cB_autoInactivity, i18n("Activate this action if the user was inactive for the defined "
"time \n(greater than 0 minutes). If empty, nothing happens.")); "time \n(greater than 0 minutes). If empty, nothing happens."));
tB_scheme->setItemToolTip ( 0, i18n("All scheme-related screen saver and DPMS settings.")); tB_scheme->setItemToolTip ( 0, i18n("All scheme-related screen saver and DPMS settings."));
tB_scheme->setItemToolTip ( 1, i18n("All scheme-related display brightness settings.")); tB_scheme->setItemToolTip ( 1, i18n("All scheme-related display brightness settings."));
tB_scheme->setItemToolTip ( 2, i18n("All scheme-related automatic suspend settings.")); tB_scheme->setItemToolTip ( 2, i18n("All scheme-related automatic suspend settings."));
@ -310,11 +316,11 @@ void ConfigureDialog::setTooltips(){
/*! /*!
* This function is used to get the real name of the predefined schemes. * This function is used to get the real name of the predefined schemes.
* This is a workaround for the case if Yast translated the name of the * This is a workaround for the case if Yast translated the name of the
* scheme In this case is a new config section created and the old settings * scheme In this case is a new config section created and the old settings
* would be lost. * would be lost.
* \param s_scheme TQString with the 'current' name of the scheme * \param s_scheme TQString with the 'current' name of the scheme
* \return TQString with the english name of the scheme * \return TQString with the english name of the scheme
*/ */
TQString ConfigureDialog::getSchemeRealName(TQString s_scheme) { TQString ConfigureDialog::getSchemeRealName(TQString s_scheme) {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
@ -336,22 +342,22 @@ TQString ConfigureDialog::getSchemeRealName(TQString s_scheme) {
/*! /*!
* This function is used to read the settings from configfile and * This function is used to read the settings from configfile and
* set the values to the related dialog elements. * set the values to the related dialog elements.
* \param schemeID Integer value, represent the position of the * \param schemeID Integer value, represent the position of the
* scheme in the TQListBox and within the pdaemon-list. * scheme in the TQListBox and within the pdaemon-list.
*/ */
void ConfigureDialog::setConfigToDialog( int schemeID ){ void ConfigureDialog::setConfigToDialog( int schemeID ){
if (trace) kdDebug() << funcinfo << "IN , scheme: " << schemeID << endl; if (trace) kdDebug() << funcinfo << "IN , scheme: " << schemeID << endl;
initalised = false; initalised = false;
TQString s_scheme = getSchemeRealName(schemes[schemeID]); TQString s_scheme = getSchemeRealName(schemes[schemeID]);
if (tdeconfig->hasGroup(s_scheme)){ if (tdeconfig->hasGroup(s_scheme)){
settings->load_general_settings(); settings->load_general_settings();
// set the delete scheme button enabled if needed // set the delete scheme button enabled if needed
if (!s_scheme.startsWith("Performance") && !s_scheme.startsWith("Powersave") && if (!s_scheme.startsWith("Performance") && !s_scheme.startsWith("Powersave") &&
!s_scheme.startsWith("Presentation") && !s_scheme.startsWith("Acoustic")) { !s_scheme.startsWith("Presentation") && !s_scheme.startsWith("Acoustic")) {
if (!s_scheme.startsWith(settings->ac_scheme) || if (!s_scheme.startsWith(settings->ac_scheme) ||
!s_scheme.startsWith(settings->battery_scheme)) { !s_scheme.startsWith(settings->battery_scheme)) {
// enable delete button // enable delete button
pB_deleteScheme->setEnabled( true ); pB_deleteScheme->setEnabled( true );
@ -372,19 +378,19 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
tdeconfig->setGroup(s_scheme); tdeconfig->setGroup(s_scheme);
} }
// no configuration found, set to default values ?! // no configuration found, set to default values ?!
else { else {
if(tdeconfig->hasGroup("default-scheme")) if(tdeconfig->hasGroup("default-scheme"))
tdeconfig->setGroup("default-scheme"); tdeconfig->setGroup("default-scheme");
else { else {
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return; return;
} }
} }
cB_disable_Ss_toggled(tdeconfig->readBoolEntry("disableSs",false)); cB_disable_Ss_toggled(tdeconfig->readBoolEntry("disableSs",false));
cB_blankScreen->setChecked(tdeconfig->readBoolEntry("blankSs",false)); cB_blankScreen->setChecked(tdeconfig->readBoolEntry("blankSs",false));
cB_specificSettings_toggled(tdeconfig->readBoolEntry("specSsSettings",false)); cB_specificSettings_toggled(tdeconfig->readBoolEntry("specSsSettings",false));
int i_standby = tdeconfig->readNumEntry("standbyAfter", -1); int i_standby = tdeconfig->readNumEntry("standbyAfter", -1);
if(i_standby >= 0) { if(i_standby >= 0) {
sB_standby->setValue(i_standby); sB_standby->setValue(i_standby);
@ -406,7 +412,7 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme); if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme"); else tdeconfig->setGroup("default-scheme");
} }
int i_suspend = tdeconfig->readNumEntry("suspendAfter", -1); int i_suspend = tdeconfig->readNumEntry("suspendAfter", -1);
if(i_suspend >= 0) { if(i_suspend >= 0) {
sB_suspend->setValue(i_suspend); sB_suspend->setValue(i_suspend);
@ -428,7 +434,7 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme); if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme"); else tdeconfig->setGroup("default-scheme");
} }
int i_poweroff = tdeconfig->readNumEntry("powerOffAfter", -1); int i_poweroff = tdeconfig->readNumEntry("powerOffAfter", -1);
if(i_poweroff >= 0) { if(i_poweroff >= 0) {
sB_powerOff->setValue(i_poweroff); sB_powerOff->setValue(i_poweroff);
@ -450,15 +456,15 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme); if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme"); else tdeconfig->setGroup("default-scheme");
} }
cB_SpecificPM_toggled(tdeconfig->readBoolEntry("specPMSettings",false)); cB_SpecificPM_toggled(tdeconfig->readBoolEntry("specPMSettings",false));
cB_disablePM_toggled(tdeconfig->readBoolEntry("disableDPMS",false)); cB_disablePM_toggled(tdeconfig->readBoolEntry("disableDPMS",false));
// set autosuspend related settings // set autosuspend related settings
TQString _action = tdeconfig->readEntry("autoInactiveAction", "NULL"); TQString _action = tdeconfig->readEntry("autoInactiveAction", "NULL");
if( _action != "NULL") { if( _action != "NULL") {
int _index = actions.findIndex(_action); int _index = actions.findIndex(_action);
if( _index != -1) { if( _index != -1) {
cB_autoInactivity->setCurrentItem( _index ); cB_autoInactivity->setCurrentItem( _index );
cB_autoInactivity_activated( _index ); cB_autoInactivity_activated( _index );
cB_Blacklist->setEnabled(true); cB_Blacklist->setEnabled(true);
@ -474,13 +480,13 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
else { else {
// set to disabled (to reduce code), if a entry found set to enabled ! // set to disabled (to reduce code), if a entry found set to enabled !
cB_Blacklist->setEnabled(false); cB_Blacklist->setEnabled(false);
if(tdeconfig->hasGroup("default-scheme")){ if(tdeconfig->hasGroup("default-scheme")){
tdeconfig->setGroup("default-scheme"); tdeconfig->setGroup("default-scheme");
_action = tdeconfig->readEntry("autoInactiveAction", "NULL"); _action = tdeconfig->readEntry("autoInactiveAction", "NULL");
if(_action != "NULL") { if(_action != "NULL") {
int _index = actions.findIndex(_action); int _index = actions.findIndex(_action);
if( _index != -1) { if( _index != -1) {
cB_autoInactivity->setCurrentItem( _index ); cB_autoInactivity->setCurrentItem( _index );
tL_autoInactivity_After->setEnabled(true); tL_autoInactivity_After->setEnabled(true);
cB_Blacklist->setEnabled(true); cB_Blacklist->setEnabled(true);
@ -504,7 +510,7 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
sB_autoInactivity->setEnabled(false); sB_autoInactivity->setEnabled(false);
tL_autoInactivity_After->setEnabled(false); tL_autoInactivity_After->setEnabled(false);
} }
int i_autoInactivityAfter = tdeconfig->readNumEntry("autoInactiveActionAfter", -1); int i_autoInactivityAfter = tdeconfig->readNumEntry("autoInactiveActionAfter", -1);
if(i_autoInactivityAfter >= 0) { if(i_autoInactivityAfter >= 0) {
sB_autoInactivity->setValue(i_autoInactivityAfter); sB_autoInactivity->setValue(i_autoInactivityAfter);
@ -532,9 +538,9 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
cB_Brightness->setEnabled(true); cB_Brightness->setEnabled(true);
cB_Brightness_toggled(tdeconfig->readBoolEntry("enableBrightness",false)); cB_Brightness_toggled(tdeconfig->readBoolEntry("enableBrightness",false));
if (brightnessLevels > 33) if (brightnessLevels > 33)
brightnessSlider->setLineStep(3); brightnessSlider->setLineStep(3);
else else
brightnessSlider->setLineStep(100/brightnessLevels); brightnessSlider->setLineStep(100/brightnessLevels);
brightnessSlider->setPageStep(10); brightnessSlider->setPageStep(10);
@ -546,9 +552,9 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
} }
else { else {
brightnessSlider->setValue(100); brightnessSlider->setValue(100);
tL_valueBrightness->setText(TQString::number(100)+ " %"); tL_valueBrightness->setText(TQString::number(100)+ " %");
} }
tL_brightness->setText(i18n("Your hardware supports to change the brightness. The " tL_brightness->setText(i18n("Your hardware supports to change the brightness. The "
"values of the slider are in percent and mapped " "values of the slider are in percent and mapped "
"to the available brightness levels of your hardware.")); "to the available brightness levels of your hardware."));
@ -560,7 +566,7 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
"of your display.")); "of your display."));
} }
// no need to enable autodimm if not support change brightness // no need to enable autodimm if not support change brightness
if (hwinfo->supportBrightness()) { if (hwinfo->supportBrightness()) {
int i_autoDimmAfter = tdeconfig->readNumEntry("autoDimmAfter", -1); int i_autoDimmAfter = tdeconfig->readNumEntry("autoDimmAfter", -1);
if(i_autoDimmAfter >= 0) { if(i_autoDimmAfter >= 0) {
@ -609,13 +615,13 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
if (hwinfo->supportCPUFreq()) { if (hwinfo->supportCPUFreq()) {
TQString cpuFreqPolicy = tdeconfig->readEntry("cpuFreqPolicy"); TQString cpuFreqPolicy = tdeconfig->readEntry("cpuFreqPolicy");
if (cpuFreqPolicy.isEmpty()) { if (cpuFreqPolicy.isEmpty()) {
// load value from default-scheme // load value from default-scheme
if(tdeconfig->hasGroup("default-scheme")){ if(tdeconfig->hasGroup("default-scheme")){
tdeconfig->setGroup("default-scheme"); tdeconfig->setGroup("default-scheme");
cpuFreqPolicy = tdeconfig->readEntry("cpuFreqPolicy"); cpuFreqPolicy = tdeconfig->readEntry("cpuFreqPolicy");
} }
if (cpuFreqPolicy.isEmpty()) { if (cpuFreqPolicy.isEmpty()) {
cpuFreqPolicy = "DYNAMIC"; cpuFreqPolicy = "DYNAMIC";
} }
@ -657,35 +663,35 @@ void ConfigureDialog::setConfigToDialog( int schemeID ){
} }
/*! /*!
* This is used to set the values from the section general in configfile to the * This is used to set the values from the section general in configfile to the
* related items in the dialog. * related items in the dialog.
*/ */
void ConfigureDialog::setGeneralSettings() { void ConfigureDialog::setGeneralSettings() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
tdeconfig->setGroup("General"); tdeconfig->setGroup("General");
cB_lockSuspend->setChecked(tdeconfig->readBoolEntry("lockOnSuspend",false)); cB_lockSuspend->setChecked(tdeconfig->readBoolEntry("lockOnSuspend",false));
cB_lockLid->setChecked(tdeconfig->readBoolEntry("lockOnLidClose",false)); cB_lockLid->setChecked(tdeconfig->readBoolEntry("lockOnLidClose",false));
cB_autostart->setChecked(tdeconfig->readBoolEntry("Autostart",false)); cB_autostart->setChecked(tdeconfig->readBoolEntry("Autostart",false));
cB_autostart_neverAsk->setChecked(tdeconfig->readBoolEntry("AutostartNeverAsk",false)); cB_autostart_neverAsk->setChecked(tdeconfig->readBoolEntry("AutostartNeverAsk",false));
TQString lockmethod = tdeconfig->readEntry("lockMethod", "NULL"); TQString lockmethod = tdeconfig->readEntry("lockMethod", "NULL");
if(comboB_lock->count() == 0 ){ if(comboB_lock->count() == 0 ){
comboB_lock->insertItem(i18n("Select Automatically"),0); comboB_lock->insertItem(i18n("Select Automatically"),0);
comboB_lock->insertItem(i18n("TDEScreensaver"),1); comboB_lock->insertItem(i18n("TDEScreensaver"),1);
comboB_lock->insertItem(i18n("XScreensaver"),2); comboB_lock->insertItem(i18n("XScreensaver"),2);
comboB_lock->insertItem(i18n("xlock"),3); comboB_lock->insertItem(i18n("xlock"),3);
if (gnome_session) comboB_lock->insertItem(i18n("GNOME Screensaver"),4); if (gnome_session) comboB_lock->insertItem(i18n("GNOME Screensaver"),4);
} }
if (lockmethod == "automatic") comboB_lock->setCurrentItem(0); if (lockmethod == "automatic") comboB_lock->setCurrentItem(0);
else if (lockmethod == "tdescreensaver") comboB_lock->setCurrentItem(1); else if (lockmethod == "tdescreensaver") comboB_lock->setCurrentItem(1);
else if (lockmethod == "xscreensaver") comboB_lock->setCurrentItem(2); else if (lockmethod == "xscreensaver") comboB_lock->setCurrentItem(2);
else if (lockmethod == "xlock") comboB_lock->setCurrentItem(3); else if (lockmethod == "xlock") comboB_lock->setCurrentItem(3);
else if (gnome_session && (lockmethod == "gnomescreensaver")) comboB_lock->setCurrentItem(4); else if (gnome_session && (lockmethod == "gnomescreensaver")) comboB_lock->setCurrentItem(4);
else comboB_lock->setCurrentItem(0); else comboB_lock->setCurrentItem(0);
if(cB_lockSuspend->isOn() || cB_lockLid->isOn() ) { if(cB_lockSuspend->isOn() || cB_lockLid->isOn() ) {
tL_lockWith->setEnabled(true); tL_lockWith->setEnabled(true);
comboB_lock->setEnabled(true); comboB_lock->setEnabled(true);
@ -728,7 +734,7 @@ void ConfigureDialog::setGeneralSettings() {
sB_batCritAction_value->setValue(tdeconfig->readNumEntry("batteryCriticalActionValue",0)); sB_batCritAction_value->setValue(tdeconfig->readNumEntry("batteryCriticalActionValue",0));
} }
} else { } else {
// disable tab // disable tab
tB_general->setItemLabel( 0, tB_scheme->itemLabel(0) + i18n(" - not supported")); tB_general->setItemLabel( 0, tB_scheme->itemLabel(0) + i18n(" - not supported"));
tB_general->setItemEnabled( 0, false); tB_general->setItemEnabled( 0, false);
} }
@ -755,7 +761,7 @@ void ConfigureDialog::setGeneralSettings() {
/* ---- START store settings SECTION ---- */ /* ---- START store settings SECTION ---- */
/*! /*!
* This used to save changes in settings of the current scheme. * This used to save changes in settings of the current scheme.
*/ */
void ConfigureDialog::saveSchemeSettings() { void ConfigureDialog::saveSchemeSettings() {
@ -769,13 +775,13 @@ void ConfigureDialog::saveSchemeSettings() {
tdeconfig->writeEntry("blankSs",cB_blankScreen->isOn()); tdeconfig->writeEntry("blankSs",cB_blankScreen->isOn());
tdeconfig->writeEntry("specPMSettings",cB_SpecificPM->isOn()); tdeconfig->writeEntry("specPMSettings",cB_SpecificPM->isOn());
tdeconfig->writeEntry("disableDPMS",cB_disablePM->isOn()); tdeconfig->writeEntry("disableDPMS",cB_disablePM->isOn());
tdeconfig->writeEntry("standbyAfter",sB_standby->value()); tdeconfig->writeEntry("standbyAfter",sB_standby->value());
tdeconfig->writeEntry("suspendAfter",sB_suspend->value()); tdeconfig->writeEntry("suspendAfter",sB_suspend->value());
tdeconfig->writeEntry("powerOffAfter",sB_powerOff->value()); tdeconfig->writeEntry("powerOffAfter",sB_powerOff->value());
tdeconfig->writeEntry("disableNotifications",cB_disableNotifications->isOn()); tdeconfig->writeEntry("disableNotifications",cB_disableNotifications->isOn());
if(cB_autoInactivity->currentText() == " "){ if(cB_autoInactivity->currentText() == " "){
tdeconfig->writeEntry("autoInactiveAction", "_NONE_"); tdeconfig->writeEntry("autoInactiveAction", "_NONE_");
} }
@ -783,7 +789,7 @@ void ConfigureDialog::saveSchemeSettings() {
int _index = cB_autoInactivity->currentItem(); int _index = cB_autoInactivity->currentItem();
if(_index > 0) { if(_index > 0) {
/*if(_index == (cB_autoInactivity->count()-1)) { /*if(_index == (cB_autoInactivity->count()-1)) {
tdeconfig->writeEntry("autoInactiveAction","shutdown"); tdeconfig->writeEntry("autoInactiveAction","shutdown");
} }
else { else {
tdeconfig->writeEntry("autoInactiveAction",actions[(_index)]); tdeconfig->writeEntry("autoInactiveAction",actions[(_index)]);
@ -794,7 +800,7 @@ void ConfigureDialog::saveSchemeSettings() {
} }
tdeconfig->writeEntry("autoSuspend",cB_autoSuspend->isOn()); tdeconfig->writeEntry("autoSuspend",cB_autoSuspend->isOn());
tdeconfig->writeEntry("autoInactiveSchemeBlacklistEnabled",cB_Blacklist->isOn()); tdeconfig->writeEntry("autoInactiveSchemeBlacklistEnabled",cB_Blacklist->isOn());
tdeconfig->writeEntry("autoDimm",cB_autoDimm->isOn()); tdeconfig->writeEntry("autoDimm",cB_autoDimm->isOn());
tdeconfig->writeEntry("autoDimmAfter", sB_autoDimmTime->value()); tdeconfig->writeEntry("autoDimmAfter", sB_autoDimmTime->value());
tdeconfig->writeEntry("autoDimmTo", sB_autoDimmTo->value()); tdeconfig->writeEntry("autoDimmTo", sB_autoDimmTo->value());
@ -827,19 +833,19 @@ void ConfigureDialog::saveSchemeSettings() {
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
/*! /*!
* This used to save changes in settings of the current scheme. * This used to save changes in settings of the current scheme.
*/ */
void ConfigureDialog::saveGeneralSettings() { void ConfigureDialog::saveGeneralSettings() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
tdeconfig->setGroup("General"); tdeconfig->setGroup("General");
tdeconfig->writeEntry("lockOnSuspend",cB_lockSuspend->isOn()); tdeconfig->writeEntry("lockOnSuspend",cB_lockSuspend->isOn());
tdeconfig->writeEntry("lockOnLidClose",cB_lockLid->isOn()); tdeconfig->writeEntry("lockOnLidClose",cB_lockLid->isOn());
tdeconfig->writeEntry("Autostart",cB_autostart->isOn()); tdeconfig->writeEntry("Autostart",cB_autostart->isOn());
tdeconfig->writeEntry("AutostartNeverAsk",cB_autostart_neverAsk->isOn()); tdeconfig->writeEntry("AutostartNeverAsk",cB_autostart_neverAsk->isOn());
TQString selected_method = ""; TQString selected_method = "";
int _selected = comboB_lock->currentItem(); int _selected = comboB_lock->currentItem();
if(_selected == 0) selected_method = "automatic"; if(_selected == 0) selected_method = "automatic";
@ -848,7 +854,7 @@ void ConfigureDialog::saveGeneralSettings() {
else if(_selected == 3) selected_method = "xlock"; else if(_selected == 3) selected_method = "xlock";
else if(gnome_session && (_selected == 4)) selected_method = "gnomescreensaver"; else if(gnome_session && (_selected == 4)) selected_method = "gnomescreensaver";
tdeconfig->writeEntry( "lockMethod", selected_method ); tdeconfig->writeEntry( "lockMethod", selected_method );
tdeconfig->writeEntry("batteryWarning", sB_batWarning->value()); tdeconfig->writeEntry("batteryWarning", sB_batWarning->value());
tdeconfig->writeEntry("batteryLow", sB_batLow->value()); tdeconfig->writeEntry("batteryLow", sB_batLow->value());
tdeconfig->writeEntry("batteryCritical", sB_batCritical->value()); tdeconfig->writeEntry("batteryCritical", sB_batCritical->value());
@ -940,10 +946,10 @@ void ConfigureDialog::listBox_schemes_currentChanged(){
int res = KMessageBox::warningYesNo(this, int res = KMessageBox::warningYesNo(this,
i18n("There are unsaved changes in the active scheme.\n" i18n("There are unsaved changes in the active scheme.\n"
"Apply the changes before jumping to the next scheme " "Apply the changes before jumping to the next scheme "
"or discard the changes?"), "or discard the changes?"),
i18n("Unsaved Changes"), KStdGuiItem::apply(), i18n("Unsaved Changes"), KStdGuiItem::apply(),
KStdGuiItem::discard()); KStdGuiItem::discard());
if (res == KMessageBox::Yes) { if (res == KMessageBox::Yes) {
// Save changes // Save changes
saveSchemeSettings(); saveSchemeSettings();
@ -990,7 +996,7 @@ void ConfigureDialog::buttonCancel_clicked(){
if (scheme_changed || general_changed) { if (scheme_changed || general_changed) {
int res = KMessageBox::warningYesNoCancel(this, int res = KMessageBox::warningYesNoCancel(this,
i18n("There are unsaved changes.\nApply the changes " i18n("There are unsaved changes.\nApply the changes "
"before cancel or discard the changes?"), "before cancel or discard the changes?"),
i18n("Unsaved Changes"), KStdGuiItem::apply(), i18n("Unsaved Changes"), KStdGuiItem::apply(),
KStdGuiItem::discard()); KStdGuiItem::discard());
if (res == KMessageBox::Yes) { if (res == KMessageBox::Yes) {
@ -1011,7 +1017,7 @@ void ConfigureDialog::buttonOk_clicked(){
buttonApply_clicked(); buttonApply_clicked();
buttonApply->setEnabled(false); buttonApply->setEnabled(false);
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
close(); close();
} }
@ -1046,7 +1052,7 @@ void ConfigureDialog::pB_newScheme_clicked(){
getSchemeList(); getSchemeList();
while (!_end) { while (!_end) {
_new = KInputDialog::getText( i18n("TDEPowersave Configuration"), _new = KInputDialog::getText( i18n("TDEPowersave Configuration"),
_error + _text, TQString(), &_ok, this); _error + _text, TQString(), &_ok, this);
if (!_ok ) { if (!_ok ) {
_end = true; _end = true;
@ -1055,7 +1061,7 @@ void ConfigureDialog::pB_newScheme_clicked(){
if (!_new.isEmpty()) { if (!_new.isEmpty()) {
if ( schemes.contains(_new)) if ( schemes.contains(_new))
_error = i18n("Error: A scheme with this name already exist.\n"); _error = i18n("Error: A scheme with this name already exist.\n");
else else
_end = true; _end = true;
} }
} }
@ -1073,7 +1079,7 @@ void ConfigureDialog::pB_newScheme_clicked(){
selectScheme(_new); selectScheme(_new);
saveSchemeSettings(); saveSchemeSettings();
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
@ -1102,7 +1108,7 @@ void ConfigureDialog::pB_deleteScheme_clicked(){
selectScheme(settings->currentScheme); selectScheme(settings->currentScheme);
} else { } else {
// could not delete the scheme ... error case // could not delete the scheme ... error case
KMessageBox::queuedMessageBox(this, KMessageBox::Error, KMessageBox::queuedMessageBox(this, KMessageBox::Error,
i18n("Could not delete the selected scheme.")); i18n("Could not delete the selected scheme."));
} }
} }
@ -1124,7 +1130,7 @@ void ConfigureDialog::cB_specificSettings_toggled(bool state){
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if(!initalised) cB_specificSettings->setChecked(state); if(!initalised) cB_specificSettings->setChecked(state);
/* set widgets visible/disabled */ /* set widgets visible/disabled */
if(state){ if(state){
cB_disable_Ss->setEnabled(true); cB_disable_Ss->setEnabled(true);
@ -1154,7 +1160,7 @@ void ConfigureDialog::cB_disable_Ss_toggled(bool state){
/* set widgets visible/disabled */ /* set widgets visible/disabled */
if(!initalised) cB_disable_Ss->setChecked(state); if(!initalised) cB_disable_Ss->setChecked(state);
cB_blankScreen->setEnabled(!state); cB_blankScreen->setEnabled(!state);
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
@ -1172,7 +1178,7 @@ void ConfigureDialog::cB_SpecificPM_toggled(bool state){
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if(!initalised) cB_SpecificPM->setChecked(state); if(!initalised) cB_SpecificPM->setChecked(state);
/* set widgets visible/disabled */ /* set widgets visible/disabled */
cB_disablePM->setEnabled(state); cB_disablePM->setEnabled(state);
if(cB_disablePM->isOn()) { if(cB_disablePM->isOn()) {
@ -1216,7 +1222,7 @@ void ConfigureDialog::sB_standby_valueChanged() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if (initalised) { if (initalised) {
if (sB_standby->value() == 0 ) if (sB_standby->value() == 0 )
return; return;
if ( sB_standby->value() > sB_suspend->value()) { if ( sB_standby->value() > sB_suspend->value()) {
sB_suspend->setValue(sB_standby->value()); sB_suspend->setValue(sB_standby->value());
@ -1233,7 +1239,7 @@ void ConfigureDialog::sB_suspend_valueChanged() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if (initalised) { if (initalised) {
if (sB_suspend->value() == 0 ) if (sB_suspend->value() == 0 )
return; return;
if ( sB_suspend->value() < sB_standby->value()) { if ( sB_suspend->value() < sB_standby->value()) {
@ -1243,7 +1249,7 @@ void ConfigureDialog::sB_suspend_valueChanged() {
sB_powerOff->setValue(sB_suspend->value()); sB_powerOff->setValue(sB_suspend->value());
} }
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
@ -1254,7 +1260,7 @@ void ConfigureDialog::sB_powerOff_valueChanged() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if (initalised) { if (initalised) {
if (sB_powerOff->value() == 0 ) if (sB_powerOff->value() == 0 )
return; return;
if ( sB_powerOff->value() < sB_suspend->value()) { if ( sB_powerOff->value() < sB_suspend->value()) {
sB_suspend->setValue(sB_powerOff->value()); sB_suspend->setValue(sB_powerOff->value());
@ -1268,7 +1274,7 @@ void ConfigureDialog::sB_powerOff_valueChanged() {
/* ---- START Inactivity SECTION ---- */ /* ---- START Inactivity SECTION ---- */
/*! /*!
* This used to set the inactivity related combobox cB_autoInactivity . * This used to set the inactivity related combobox cB_autoInactivity .
*/ */
void ConfigureDialog::setInactivityBox(){ void ConfigureDialog::setInactivityBox(){
@ -1280,7 +1286,7 @@ void ConfigureDialog::setInactivityBox(){
// add "Turn Off Computer" at end of the list // add "Turn Off Computer" at end of the list
// TQString _to_i18n = i18n("Turn Off Computer"); // TQString _to_i18n = i18n("Turn Off Computer");
// actions.append("Turn Off Computer"); // actions.append("Turn Off Computer");
for ( TQStringList::Iterator it = actions.begin(); it != actions.end(); ++it ) { for ( TQStringList::Iterator it = actions.begin(); it != actions.end(); ++it ) {
cB_autoInactivity->insertItem( i18n( (*it).ascii() ) ); cB_autoInactivity->insertItem( i18n( (*it).ascii() ) );
} }
@ -1355,7 +1361,7 @@ void ConfigureDialog::cB_autoInactivity_activated( int selectedItem ) {
tL_autoInactivity_After->setEnabled(true); tL_autoInactivity_After->setEnabled(true);
cB_Blacklist->setEnabled(true); cB_Blacklist->setEnabled(true);
if(cB_Blacklist->isChecked()) pB_editBlacklist->setEnabled(true); if(cB_Blacklist->isChecked()) pB_editBlacklist->setEnabled(true);
} }
else { else {
sB_autoInactivity->setEnabled(false); sB_autoInactivity->setEnabled(false);
@ -1363,9 +1369,9 @@ void ConfigureDialog::cB_autoInactivity_activated( int selectedItem ) {
cB_Blacklist->setEnabled(false); cB_Blacklist->setEnabled(false);
pB_editBlacklist->setEnabled(false); pB_editBlacklist->setEnabled(false);
} }
cB_autoInactivity->setCurrentItem( selectedItem ); cB_autoInactivity->setCurrentItem( selectedItem );
if(initalised) { if(initalised) {
scheme_changed = true; scheme_changed = true;
buttonApply->setEnabled(true); buttonApply->setEnabled(true);
@ -1383,7 +1389,7 @@ void ConfigureDialog::cB_Blacklist_toggled( bool toggled ){
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
pB_editBlacklist->setEnabled(toggled); pB_editBlacklist->setEnabled(toggled);
if(initalised) { if(initalised) {
buttonApply->setEnabled(true); buttonApply->setEnabled(true);
scheme_changed = true; scheme_changed = true;
@ -1431,8 +1437,8 @@ void ConfigureDialog::pB_editBlacklistSuspend_clicked(){
} }
} }
blacklistEDlgAS = new blacklistEditDialog(blacklist, _top_text, initialiseImport, this); blacklistEDlgAS = new blacklistEditDialog(blacklist, _top_text, initialiseImport, this);
connect( blacklistEDlgAS, TQT_SIGNAL(config_finished(TQStringList)), this, connect( blacklistEDlgAS, TQT_SIGNAL(config_finished(TQStringList)), this,
TQT_SLOT(saveSchemeSuspendBlacklist(TQStringList))); TQT_SLOT(saveSchemeSuspendBlacklist(TQStringList)));
blacklistEDlgAS->exec(); blacklistEDlgAS->exec();
@ -1466,14 +1472,14 @@ void ConfigureDialog::saveSchemeSuspendBlacklist( TQStringList new_blacklist){
/* ---- START Autodimm SECTION ---- */ /* ---- START Autodimm SECTION ---- */
/*! /*!
* This used to set the autodimm related widgets. * This used to set the autodimm related widgets.
*/ */
void ConfigureDialog::cB_autoDimm_toggled( bool toggled ) { void ConfigureDialog::cB_autoDimm_toggled( bool toggled ) {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if(cB_autoDimm->isOn() != toggled) if(cB_autoDimm->isOn() != toggled)
cB_autoDimm->setChecked(toggled); cB_autoDimm->setChecked(toggled);
if (toggled) if (toggled)
tL_autoDimmExplain->setEnabled(toggled); tL_autoDimmExplain->setEnabled(toggled);
@ -1487,7 +1493,7 @@ void ConfigureDialog::cB_autoDimm_toggled( bool toggled ) {
if (cB_BlacklistDimm->isOn()) if (cB_BlacklistDimm->isOn())
pB_editBlacklistDimm->setEnabled(toggled); pB_editBlacklistDimm->setEnabled(toggled);
if (toggled) { if (toggled) {
if (sB_autoDimmTime->value() > 0) { if (sB_autoDimmTime->value() > 0) {
tL_autoDimmTo->setEnabled(true); tL_autoDimmTo->setEnabled(true);
@ -1513,7 +1519,7 @@ void ConfigureDialog::cB_BlacklistDimm_toggled( bool toggled ){
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
pB_editBlacklistDimm->setEnabled(toggled); pB_editBlacklistDimm->setEnabled(toggled);
if(initalised) { if(initalised) {
buttonApply->setEnabled(true); buttonApply->setEnabled(true);
scheme_changed = true; scheme_changed = true;
@ -1561,8 +1567,8 @@ void ConfigureDialog::pB_editBlacklistDimm_clicked(){
} }
} }
blacklistEDlgAD = new blacklistEditDialog(blacklist, _top_text, initialiseImport, this); blacklistEDlgAD = new blacklistEditDialog(blacklist, _top_text, initialiseImport, this);
connect( blacklistEDlgAD, TQT_SIGNAL(config_finished(TQStringList)), this, connect( blacklistEDlgAD, TQT_SIGNAL(config_finished(TQStringList)), this,
TQT_SLOT(saveSchemeDimmBlacklist(TQStringList))); TQT_SLOT(saveSchemeDimmBlacklist(TQStringList)));
blacklistEDlgAD->exec(); blacklistEDlgAD->exec();
@ -1667,9 +1673,9 @@ void ConfigureDialog::pB_resetBrightness_clicked( ) {
*/ */
void ConfigureDialog::sB_batWarning_valueChanged() { void ConfigureDialog::sB_batWarning_valueChanged() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if (initalised) { if (initalised) {
if (sB_batWarning->value() == 0 ) if (sB_batWarning->value() == 0 )
sB_batWarning->setValue(1); sB_batWarning->setValue(1);
if ( sB_batWarning->value() <= sB_batLow->value()) { if ( sB_batWarning->value() <= sB_batLow->value()) {
sB_batLow->setValue(sB_batWarning->value()-1); sB_batLow->setValue(sB_batWarning->value()-1);
@ -1686,7 +1692,7 @@ void ConfigureDialog::sB_batLow_valueChanged() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if (initalised) { if (initalised) {
if (sB_batLow->value() == 0 ) if (sB_batLow->value() == 0 )
sB_batLow->setValue(1); sB_batLow->setValue(1);
if ( sB_batLow->value() >= sB_batWarning->value()) { if ( sB_batLow->value() >= sB_batWarning->value()) {
@ -1707,7 +1713,7 @@ void ConfigureDialog::sB_batCritical_valueChanged() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if (initalised) { if (initalised) {
if (sB_batCritical->value() == 0 ) if (sB_batCritical->value() == 0 )
sB_batCritical->setValue(1); sB_batCritical->setValue(1);
if ( sB_batCritical->value() >= sB_batLow->value()) { if ( sB_batCritical->value() >= sB_batLow->value()) {
sB_batLow->setValue(sB_batCritical->value()+1); sB_batLow->setValue(sB_batCritical->value()+1);
@ -1797,6 +1803,9 @@ TQString ConfigureDialog::mapActionToDescription( TQString action ) {
} else if (action.startsWith("SUSPEND2RAM")) { } else if (action.startsWith("SUSPEND2RAM")) {
if (actions.contains("Suspend to RAM")) if (actions.contains("Suspend to RAM"))
ret = i18n("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")) { } else if (action.startsWith("CPUFRETQ_POWERSAVE")) {
if (hwinfo->supportCPUFreq()) if (hwinfo->supportCPUFreq())
ret = i18n("CPU Powersave policy"); ret = i18n("CPU Powersave policy");
@ -1809,7 +1818,7 @@ TQString ConfigureDialog::mapActionToDescription( TQString action ) {
} else if (action.startsWith("BRIGHTNESS")) { } else if (action.startsWith("BRIGHTNESS")) {
if (hwinfo->supportBrightness()) if (hwinfo->supportBrightness())
ret = i18n("Set Brightness to"); ret = i18n("Set Brightness to");
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return ret; return ret;
@ -1827,28 +1836,31 @@ TQString ConfigureDialog::mapDescriptionToAction( TQString description ) {
if (description.startsWith("Shutdown") || description.startsWith(i18n("Shutdown"))) { if (description.startsWith("Shutdown") || description.startsWith(i18n("Shutdown"))) {
ret = "SHUTDOWN"; ret = "SHUTDOWN";
} else if (description.startsWith("Logout Dialog") || } else if (description.startsWith("Logout Dialog") ||
description.startsWith(i18n("Logout Dialog"))) { description.startsWith(i18n("Logout Dialog"))) {
ret = "LOGOUT_DIALOG"; ret = "LOGOUT_DIALOG";
} else if (description.startsWith("Suspend to Disk") || } else if (description.startsWith("Suspend to Disk") ||
description.startsWith(i18n("Suspend to Disk"))) { description.startsWith(i18n("Suspend to Disk"))) {
ret = "SUSPEND2DISK"; ret = "SUSPEND2DISK";
} else if (description.startsWith("Suspend to RAM") || } else if (description.startsWith("Suspend to RAM") ||
description.startsWith(i18n("Suspend to RAM"))) { description.startsWith(i18n("Suspend to RAM"))) {
ret = "SUSPEND2RAM"; ret = "SUSPEND2RAM";
} else if (description.startsWith("CPU Powersave policy") || } else if (description.startsWith("Freeze") ||
description.startsWith(i18n("Freeze"))) {
ret = "FREEZE";
} else if (description.startsWith("CPU Powersave policy") ||
description.startsWith(i18n("CPU Powersave policy"))) { description.startsWith(i18n("CPU Powersave policy"))) {
ret = "CPUFRETQ_POWERSAVE"; ret = "CPUFRETQ_POWERSAVE";
} else if (description.startsWith("CPU Dynamic policy") || } else if (description.startsWith("CPU Dynamic policy") ||
description.startsWith(i18n("CPU Dynamic policy"))) { description.startsWith(i18n("CPU Dynamic policy"))) {
ret = "CPUFRETQ_DYNAMIC"; ret = "CPUFRETQ_DYNAMIC";
} else if (description.startsWith("CPU Performance policy") || } else if (description.startsWith("CPU Performance policy") ||
description.startsWith(i18n("CPU Performance policy"))) { description.startsWith(i18n("CPU Performance policy"))) {
ret = "CPUFRETQ_PERFORMANCE"; ret = "CPUFRETQ_PERFORMANCE";
} else if (description.startsWith("Set Brightness to") || } else if (description.startsWith("Set Brightness to") ||
description.startsWith(i18n("Set Brightness to"))) { description.startsWith(i18n("Set Brightness to"))) {
ret = "BRIGHTNESS"; ret = "BRIGHTNESS";
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return ret; return ret;

@ -18,7 +18,7 @@
***************************************************************************/ ***************************************************************************/
/*! \file countdowndialog.cpp /*! \file countdowndialog.cpp
* \brief In this file can be found the countdown dialog related code. * \brief In this file can be found the countdown dialog related code.
* \author Danny Kukawka, <dkukawka@suse.de, danny.kukawka@web.de> * \author Danny Kukawka, <dkukawka@suse.de, danny.kukawka@web.de>
* \date 2007 * \date 2007
*/ */
@ -34,7 +34,7 @@
// QT headers: // QT headers:
#include <tqdialog.h> #include <tqdialog.h>
#include <tqlabel.h> #include <tqlabel.h>
#include <tqprogressbar.h> #include <tqprogressbar.h>
#include <tqpushbutton.h> #include <tqpushbutton.h>
#include <tqstring.h> #include <tqstring.h>
@ -66,7 +66,7 @@ countDownDialog::~countDownDialog() {
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
/*! /*!
* This used to set Icon/pixmap for the dialog. * This used to set Icon/pixmap for the dialog.
* \param type TQString with the type of the current suspend * \param type TQString with the type of the current suspend
* to set the pixmap in the dialog * to set the pixmap in the dialog
@ -79,6 +79,8 @@ void countDownDialog::setPixmap( TQString type )
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge); pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("suspend2ram")) { } else if (type.startsWith("suspend2ram")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge); 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")) { } else if (type.startsWith("standby")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("stand_by", TDEIcon::NoGroup, TDEIcon::SizeLarge); pixmap = TDEGlobal::iconLoader()->loadIcon("stand_by", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else { } else {
@ -89,7 +91,7 @@ void countDownDialog::setPixmap( TQString type )
/*! /*!
* To set the message to the dialog, which should be shown to the user. * To set the message to the dialog, which should be shown to the user.
* \param text TQString with the message. * \param text TQString with the message.
*/ */
void countDownDialog::setMessageText(TQString text) { void countDownDialog::setMessageText(TQString text) {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
@ -153,12 +155,12 @@ void countDownDialog::updateProgress() {
if (remaining == 0 ) { if (remaining == 0 ) {
if (PROGRESS->isActive()) if (PROGRESS->isActive())
PROGRESS->stop(); PROGRESS->stop();
chancel = false; chancel = false;
close(); close();
} else if ( remaining > 0) { } else if ( remaining > 0) {
int setTo = (int)((100.0/(float)timeOut)*(float)remaining); int setTo = (int)((100.0/(float)timeOut)*(float)remaining);
// set the progressBar // set the progressBar
progressBar->setFormat(i18n("%1 seconds").arg(remaining)); progressBar->setFormat(i18n("%1 seconds").arg(remaining));
progressBar->setPercentageVisible(true); progressBar->setPercentageVisible(true);

@ -251,6 +251,12 @@ Comment[zh_CN]=启动暂挂到 RAM
Comment[zh_TW]=已啟動「暫停寫入到 RAM」 Comment[zh_TW]=已啟動「暫停寫入到 RAM」
default_presentation=0 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] [standby_event]
Name=StandbyEvent Name=StandbyEvent
Comment=Standby is started Comment=Standby is started
@ -302,6 +308,12 @@ Comment[zh_CN]=从“暂挂到 RAM”继续执行
Comment[zh_TW]=從「暫停寫入到 RAM」繼續執行 Comment[zh_TW]=從「暫停寫入到 RAM」繼續執行
default_presentation=0 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] [resume_from_standby_event]
Name=ResumeFromStandbyEvent Name=ResumeFromStandbyEvent
Comment=Resumed from Standby Comment=Resumed from Standby

@ -17,9 +17,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/ ***************************************************************************/
/*! /*!
* \file hardware.cpp * \file hardware.cpp
* \brief In this file can be found the hardware information related code. * \brief In this file can be found the hardware information related code.
* \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de> * \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
* \date 2006-2007 * \date 2006-2007
*/ */
@ -66,7 +66,7 @@ HardwareInfo::HardwareInfo() {
update_info_ac_changed = true; update_info_ac_changed = true;
update_info_cpufreq_policy_changed = true; update_info_cpufreq_policy_changed = true;
update_info_primBattery_changed = true; update_info_primBattery_changed = true;
currentCPUFreqPolicy = UNKNOWN_CPUFREQ; currentCPUFreqPolicy = UNKNOWN_CPUFREQ;
primaryBatteriesWarnLevel = 12; primaryBatteriesWarnLevel = 12;
primaryBatteriesLowLevel = 7; primaryBatteriesLowLevel = 7;
@ -75,7 +75,7 @@ HardwareInfo::HardwareInfo() {
allUDIs = TQStringList(); allUDIs = TQStringList();
consoleKitSession = TQString(); consoleKitSession = TQString();
BatteryList.setAutoDelete( true ); // the list owns the objects BatteryList.setAutoDelete( true ); // the list owns the objects
primaryBatteries = new BatteryCollection(BAT_PRIMARY); primaryBatteries = new BatteryCollection(BAT_PRIMARY);
setPrimaryBatteriesWarningLevel(); // force default settings setPrimaryBatteriesWarningLevel(); // force default settings
@ -92,7 +92,7 @@ HardwareInfo::HardwareInfo() {
checkIsLaptop(); checkIsLaptop();
checkBrightness(); checkBrightness();
checkCPUFreq(); checkCPUFreq();
// getSchedPowerSavings(); // getSchedPowerSavings();
checkSuspend(); checkSuspend();
intialiseHWInfo(); intialiseHWInfo();
@ -116,7 +116,7 @@ HardwareInfo::~HardwareInfo() {
*/ */
bool HardwareInfo::reinitHardwareInfos () { bool HardwareInfo::reinitHardwareInfos () {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
/* first cleanup */ /* first cleanup */
acadapter = true; acadapter = true;
lidclose = false; lidclose = false;
@ -128,7 +128,7 @@ bool HardwareInfo::reinitHardwareInfos () {
update_info_ac_changed = true; update_info_ac_changed = true;
update_info_cpufreq_policy_changed = true; update_info_cpufreq_policy_changed = true;
update_info_primBattery_changed = true; update_info_primBattery_changed = true;
allUDIs = TQStringList(); allUDIs = TQStringList();
BatteryList.clear(); BatteryList.clear();
@ -144,7 +144,7 @@ bool HardwareInfo::reinitHardwareInfos () {
// getSchedPowerSavings(); // getSchedPowerSavings();
updatePrimaryBatteries(); updatePrimaryBatteries();
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return true; return true;
} }
@ -189,7 +189,7 @@ void HardwareInfo::processKeyPressEvent(unsigned int keycode, TDEEventDevice* ed
// FIXME // FIXME
// How can I get specific button press/release information (instead of just "something happened to the button") from the TDE hardware library? // How can I get specific button press/release information (instead of just "something happened to the button") from the TDE hardware library?
// TODO: Check if we really need to monitor this events. We get maybe also // TODO: Check if we really need to monitor this events. We get maybe also
// HAL_PROPERTY_CHANGED event for the key // HAL_PROPERTY_CHANGED event for the key
// if (message.startsWith("ButtonPressed")) { // if (message.startsWith("ButtonPressed")) {
kdDebug() << "ButtonPressed event from TDE HW library " << endl; kdDebug() << "ButtonPressed event from TDE HW library " << endl;
@ -216,7 +216,7 @@ void HardwareInfo::processKeyPressEvent(unsigned int keycode, TDEEventDevice* ed
} }
/*! /*!
* This funtion is used to parse a message from D-Bus for the different * This funtion is used to parse a message from D-Bus for the different
* messagetypes and events. * messagetypes and events.
* \param type a \ref msg_type which should be parse/processed * \param type a \ref msg_type which should be parse/processed
* \param message the message * \param message the message
@ -241,7 +241,7 @@ void HardwareInfo::processMessage (msg_type type, TQString message, TQString val
case BUTTON_SLEEP: case BUTTON_SLEEP:
case BUTTON_POWER: case BUTTON_POWER:
case LID: case LID:
// TODO: handle code if needed actually not // TODO: handle code if needed actually not
break; break;
case LAPTOP_PANEL: case LAPTOP_PANEL:
checkBrightness(); checkBrightness();
@ -317,7 +317,7 @@ void HardwareInfo::handleResumeSignal (int result) {
if (trace) kdDebug() << funcinfo << "IN: " << "(int result: " << result << ")"<< endl; if (trace) kdDebug() << funcinfo << "IN: " << "(int result: " << result << ")"<< endl;
if (result == -1) { if (result == -1) {
// check if time since suspend is higher than 6 hours, // check if time since suspend is higher than 6 hours,
// the magic D-Bus timeout for pending calls // the magic D-Bus timeout for pending calls
if (calledSuspend.elapsed() > 21600000) { if (calledSuspend.elapsed() > 21600000) {
emit resumed(INT_MAX); emit resumed(INT_MAX);
@ -325,12 +325,12 @@ void HardwareInfo::handleResumeSignal (int result) {
} else { } else {
emit resumed(result); emit resumed(result);
} }
calledSuspend = TQTime(); calledSuspend = TQTime();
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
/*! /*!
* This function checks the session for the running TDEPowersave instance * This function checks the session for the running TDEPowersave instance
* \return Boolean with result of operation * \return Boolean with result of operation
* \retval true if the query/check could get finished * \retval true if the query/check could get finished
@ -349,30 +349,30 @@ bool HardwareInfo::checkConsoleKitSession () {
kdDebug() << "Could not get XDG_SESSION_COOKIE from environment" << endl; kdDebug() << "Could not get XDG_SESSION_COOKIE from environment" << endl;
sessionIsActive = true; sessionIsActive = true;
} else { } else {
if (dbus_HAL->dbusSystemMethodCall( CK_SERVICE, CK_MANAGER_OBJECT, if (dbus_HAL->dbusSystemMethodCall( CK_SERVICE, CK_MANAGER_OBJECT,
CK_MANAGER_IFACE, "GetSessionForCookie", CK_MANAGER_IFACE, "GetSessionForCookie",
&reply, DBUS_TYPE_OBJECT_PATH, &reply, DBUS_TYPE_OBJECT_PATH,
DBUS_TYPE_STRING, &cookie, DBUS_TYPE_STRING, &cookie,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
if (trace) if (trace)
kdDebug() << "GetSessionForCookie returned: " << reply << endl; kdDebug() << "GetSessionForCookie returned: " << reply << endl;
if (reply != NULL) { if (reply != NULL) {
dbus_bool_t i_reply; dbus_bool_t i_reply;
consoleKitSession = reply; consoleKitSession = reply;
if (dbus_HAL->dbusSystemMethodCall( CK_SERVICE, consoleKitSession, if (dbus_HAL->dbusSystemMethodCall( CK_SERVICE, consoleKitSession,
CK_SESSION_IFACE, "IsActive", CK_SESSION_IFACE, "IsActive",
&i_reply, DBUS_TYPE_BOOLEAN, &i_reply, DBUS_TYPE_BOOLEAN,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
sessionIsActive = ((i_reply != 0) ? true: false); sessionIsActive = ((i_reply != 0) ? true: false);
if (trace) if (trace)
kdDebug() << "IsActive returned: " << sessionIsActive << endl; kdDebug() << "IsActive returned: " << sessionIsActive << endl;
retval = true; retval = true;
} else { } else {
kdError() << "Could get session cookie and session name, but not " kdError() << "Could get session cookie and session name, but not "
<< "but not the status of the session. Assume for now " << "but not the status of the session. Assume for now "
<< "the Session is inactive!" << endl; << "the Session is inactive!" << endl;
sessionIsActive = false; sessionIsActive = false;
} }
@ -385,7 +385,7 @@ bool HardwareInfo::checkConsoleKitSession () {
return retval; return retval;
} }
/*! /*!
* This function check for a given UDI, if we should handle a device * This function check for a given UDI, if we should handle a device
* \param _udi TQString with the UDI of the device * \param _udi TQString with the UDI of the device
* \param *type pointer to a integer to return the type of the device, see \ref device_type * \param *type pointer to a integer to return the type of the device, see \ref device_type
@ -395,12 +395,12 @@ bool HardwareInfo::checkConsoleKitSession () {
*/ */
bool HardwareInfo::checkIfHandleDevice ( TQString _udi, int *type) { bool HardwareInfo::checkIfHandleDevice ( TQString _udi, int *type) {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
TQStringList _cap; TQStringList _cap;
bool ret = true; bool ret = true;
TDEGenericDevice* hwdevice = m_hwdevices->findByUniqueID(_udi); TDEGenericDevice* hwdevice = m_hwdevices->findByUniqueID(_udi);
if (hwdevice) { if (hwdevice) {
TDEGenericDeviceType::TDEGenericDeviceType devtype = hwdevice->type(); TDEGenericDeviceType::TDEGenericDeviceType devtype = hwdevice->type();
if (devtype == TDEGenericDeviceType::PowerSupply) { if (devtype == TDEGenericDeviceType::PowerSupply) {
@ -431,9 +431,9 @@ bool HardwareInfo::checkIfHandleDevice ( TQString _udi, int *type) {
} else { } else {
ret = false; ret = false;
} }
if (!ret) *type = UNKNOWN_DEVICE; if (!ret) *type = UNKNOWN_DEVICE;
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return ret; return ret;
} }
@ -441,7 +441,7 @@ bool HardwareInfo::checkIfHandleDevice ( TQString _udi, int *type) {
// --> set some values for devices // --> set some values for devices
/*! /*!
* This function set the warning level for the primary battery collection * This function set the warning level for the primary battery collection
* If all give param are -1 or not set this function force the current * If all give param are -1 or not set this function force the current
* settings to the primary battery collection. * settings to the primary battery collection.
* \param _warn value for the state BAT_WARN or -1 * \param _warn value for the state BAT_WARN or -1
* \param _low value for the state BAT_LOW or -1 * \param _low value for the state BAT_LOW or -1
@ -479,7 +479,7 @@ void HardwareInfo::checkIsLaptop () {
TQString ret; TQString ret;
TDERootSystemDevice* rdevice = m_hwdevices->rootSystemDevice(); TDERootSystemDevice* rdevice = m_hwdevices->rootSystemDevice();
if (rdevice->formFactor() == TDESystemFormFactor::Laptop) { if (rdevice->formFactor() == TDESystemFormFactor::Laptop) {
laptop = true; laptop = true;
} }
@ -495,7 +495,7 @@ void HardwareInfo::checkIsLaptop () {
*/ */
void HardwareInfo::checkPowermanagement() { void HardwareInfo::checkPowermanagement() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
TQString ret; TQString ret;
has_APM = false; has_APM = false;
@ -506,7 +506,7 @@ void HardwareInfo::checkPowermanagement() {
if (hwlist.count() > 0) { if (hwlist.count() > 0) {
has_ACPI = true; has_ACPI = true;
} }
// FIXME // FIXME
// Do we even need to detect APM and PMU devices in the year 2012?!? // Do we even need to detect APM and PMU devices in the year 2012?!?
@ -519,7 +519,7 @@ void HardwareInfo::checkPowermanagement() {
*/ */
void HardwareInfo::checkSuspend() { void HardwareInfo::checkSuspend() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
suspend_states = SuspendStates(); suspend_states = SuspendStates();
suspend_states.suspend2ram = false; suspend_states.suspend2ram = false;
@ -528,6 +528,9 @@ void HardwareInfo::checkSuspend() {
suspend_states.suspend2disk = false; suspend_states.suspend2disk = false;
suspend_states.suspend2disk_can = false; suspend_states.suspend2disk_can = false;
suspend_states.suspend2disk_allowed = -1; 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 = false;
suspend_states.standby_can = false; suspend_states.standby_can = false;
suspend_states.standby_allowed = -1; suspend_states.standby_allowed = -1;
@ -545,6 +548,11 @@ void HardwareInfo::checkSuspend() {
suspend_states.standby_allowed = rdevice->canStandby(); 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) {
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) { if ((*it) == TDESystemPowerState::Suspend) {
suspend_states.suspend2ram = true; suspend_states.suspend2ram = true;
suspend_states.suspend2ram_allowed = rdevice->canSuspend(); suspend_states.suspend2ram_allowed = rdevice->canSuspend();
@ -575,7 +583,7 @@ void HardwareInfo::checkCPUFreq() {
TDEGenericDevice *hwdevice; TDEGenericDevice *hwdevice;
hwdevice = hwlist.first(); hwdevice = hwlist.first();
TDECPUDevice *cpudevice = static_cast<TDECPUDevice*>(hwdevice); TDECPUDevice *cpudevice = static_cast<TDECPUDevice*>(hwdevice);
if (!cpudevice->scalingDriver().isNull()) { if (!cpudevice->scalingDriver().isNull()) {
cpuFreq = true; cpuFreq = true;
cpuFreqAllowed = cpudevice->canSetGovernor(); cpuFreqAllowed = cpudevice->canSetGovernor();
@ -600,7 +608,7 @@ cpufreq_type HardwareInfo::checkCurrentCPUFreqPolicy() {
TDEGenericDevice *hwdevice; TDEGenericDevice *hwdevice;
hwdevice = hwlist.first(); hwdevice = hwlist.first();
TDECPUDevice *cpudevice = static_cast<TDECPUDevice*>(hwdevice); TDECPUDevice *cpudevice = static_cast<TDECPUDevice*>(hwdevice);
TQString gov = cpudevice->governor(); TQString gov = cpudevice->governor();
cpufreq_type _current = UNKNOWN_CPUFREQ; cpufreq_type _current = UNKNOWN_CPUFREQ;
@ -622,7 +630,7 @@ cpufreq_type HardwareInfo::checkCurrentCPUFreqPolicy() {
kdWarning() << "Could not get information about current governor" << endl; kdWarning() << "Could not get information about current governor" << endl;
} }
} else { } 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) { if (_current != currentCPUFreqPolicy) {
@ -632,14 +640,14 @@ cpufreq_type HardwareInfo::checkCurrentCPUFreqPolicy() {
} else { } else {
update_info_cpufreq_policy_changed = false; update_info_cpufreq_policy_changed = false;
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return currentCPUFreqPolicy; return currentCPUFreqPolicy;
} }
/*! /*!
* The function checks whether the machine provide a brightness interface and init * The function checks whether the machine provide a brightness interface and init
* (if needed) brightness information. * (if needed) brightness information.
*/ */
void HardwareInfo::checkBrightness() { void HardwareInfo::checkBrightness() {
@ -682,7 +690,7 @@ void HardwareInfo::checkBrightness() {
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return; return;
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
@ -699,19 +707,19 @@ void HardwareInfo::checkCurrentBrightness() {
TDEGenericDevice *hwdevice; TDEGenericDevice *hwdevice;
hwdevice = hwlist.first(); hwdevice = hwlist.first();
TDEBacklightDevice *backlightdevice = static_cast<TDEBacklightDevice*>(hwdevice); TDEBacklightDevice *backlightdevice = static_cast<TDEBacklightDevice*>(hwdevice);
if (backlightdevice) { if (backlightdevice) {
currentBrightnessLevel = backlightdevice->rawBrightness(); currentBrightnessLevel = backlightdevice->rawBrightness();
} }
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
} }
/*! /*!
* The function initialise the hardware information and collect all * 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 * \return boolean with result of the operation
* \retval true if successful * \retval true if successful
* \retval false else, if a error occurs * \retval false else, if a error occurs
@ -817,7 +825,7 @@ void HardwareInfo::checkLidcloseState() {
} }
/*! /*!
* This funtion is used to call a update of a battery value for a given * This funtion is used to call a update of a battery value for a given
* UDI and the given changed property * UDI and the given changed property
* \param udi TQString with the UDI of the battery * \param udi TQString with the UDI of the battery
* \param property TQString with the changed property * \param property TQString with the changed property
@ -855,7 +863,7 @@ void HardwareInfo::updatePrimaryBatteries () {
if (primaryBatteries->getNumBatteries() < 1) { if (primaryBatteries->getNumBatteries() < 1) {
setPrimaryBatteriesWarningLevel(); setPrimaryBatteriesWarningLevel();
primaryBatteries->refreshInfo( BatteryList ); primaryBatteries->refreshInfo( BatteryList );
connect(primaryBatteries, TQT_SIGNAL(batteryChanged()), this, connect(primaryBatteries, TQT_SIGNAL(batteryChanged()), this,
TQT_SLOT(setPrimaryBatteriesChanges())); TQT_SLOT(setPrimaryBatteriesChanges()));
connect(primaryBatteries, TQT_SIGNAL(batteryWarnState(int,int)), this, connect(primaryBatteries, TQT_SIGNAL(batteryWarnState(int,int)), this,
TQT_SLOT(emitBatteryWARNState(int,int))); TQT_SLOT(emitBatteryWARNState(int,int)));
@ -888,7 +896,7 @@ void HardwareInfo::setPrimaryBatteriesChanges () {
void HardwareInfo::emitBatteryWARNState (int type, int state) { void HardwareInfo::emitBatteryWARNState (int type, int state) {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if (type == BAT_PRIMARY) if (type == BAT_PRIMARY)
emit primaryBatteryChanged(); emit primaryBatteryChanged();
else else
emit generalDataChanged(); emit generalDataChanged();
@ -899,10 +907,10 @@ void HardwareInfo::emitBatteryWARNState (int type, int state) {
} }
// --> init HW information section -- END <--- // --> 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 * \param suspend enum of suspend_type with the requested suspend
* \return boolean with result of the operation * \return boolean with result of the operation
* \retval true if successful * \retval true if successful
@ -928,7 +936,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false; return false;
} }
} else { } else {
if ( !suspend_states.suspend2disk ) if ( !suspend_states.suspend2disk )
kdDebug() << "The machine does not support suspend to disk." << endl; kdDebug() << "The machine does not support suspend to disk." << endl;
else else
kdWarning() << "Policy forbid user to trigger suspend to disk" << endl; kdWarning() << "Policy forbid user to trigger suspend to disk" << endl;
@ -947,11 +955,30 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false; return false;
} }
} else { } else {
if ( !suspend_states.suspend2ram ) if ( !suspend_states.suspend2ram )
kdDebug() << "The machine does not support suspend to ram." << endl; kdDebug() << "The machine does not support suspend to ram." << endl;
else else
kdWarning() << "Policy forbid user to trigger suspend to ram" << endl; kdWarning() << "Policy forbid user to trigger suspend to ram" << endl;
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; return false;
} }
break; break;
@ -966,7 +993,7 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false; return false;
} }
} else { } else {
if ( !suspend_states.standby ) if ( !suspend_states.standby )
kdDebug() << "The machine does not support standby." << endl; kdDebug() << "The machine does not support standby." << endl;
else else
kdWarning() << "Policy forbid user to trigger standby" << endl; kdWarning() << "Policy forbid user to trigger standby" << endl;
@ -978,13 +1005,13 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
return false; return false;
} }
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return false; return false;
} }
/*! /*!
* 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 level Integer with the level to set, (range: 0 - \ref availableBrightnessLevels )
* \param percent Integer with the brightness percentage to set * \param percent Integer with the brightness percentage to set
* \return boolean with result of the operation * \return boolean with result of the operation
@ -1037,10 +1064,10 @@ bool HardwareInfo::setBrightness ( int level, int percent ){
checkCurrentBrightness(); checkCurrentBrightness();
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return retval; return retval;
} }
/*! /*!
* 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 cpufreq enum of cpufreq_type with the policy to set
* \param limit integer with range 0 - 100 (only if cpufreq == DYNAMIC) * \param limit integer with range 0 - 100 (only if cpufreq == DYNAMIC)
* \return boolean with result of the operation * \return boolean with result of the operation
@ -1051,10 +1078,10 @@ bool HardwareInfo::setCPUFreq ( cpufreq_type cpufreq, int limit ) {
if (trace) kdDebug() << funcinfo << "IN: " << "cpufreq_type: " << cpufreq << " limit: " << limit << endl; if (trace) kdDebug() << funcinfo << "IN: " << "cpufreq_type: " << cpufreq << " limit: " << limit << endl;
if (!cpuFreq) { 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; return false;
} }
if (cpuFreqAllowed == 0) { if (cpuFreqAllowed == 0) {
kdError() << "Could not set CPU Freq, this not the needed privileges." << endl; kdError() << "Could not set CPU Freq, this not the needed privileges." << endl;
return false; return false;
@ -1088,7 +1115,7 @@ bool HardwareInfo::setCPUFreq ( cpufreq_type cpufreq, int limit ) {
for (TQStringList::Iterator it = dynamic.begin(); it != dynamic.end(); it++){ for (TQStringList::Iterator it = dynamic.begin(); it != dynamic.end(); it++){
kdDebug() << "Try to set dynamic CPUFreq to: " << *it << endl; kdDebug() << "Try to set dynamic CPUFreq to: " << *it << endl;
if (setCPUFreqGovernor((*it).latin1())) { if (setCPUFreqGovernor((*it).latin1())) {
kdDebug() << "Set dynamic successful to: " << *it << endl; kdDebug() << "Set dynamic successful to: " << *it << endl;
break; break;
@ -1120,7 +1147,7 @@ bool HardwareInfo::setCPUFreq ( cpufreq_type cpufreq, int limit ) {
cpuLimit = (cpuLimit * limit) / 100.0; cpuLimit = (cpuLimit * limit) / 100.0;
cpuLimit = cpudevice->maxFrequency() + cpuLimit; cpuLimit = cpudevice->maxFrequency() + cpuLimit;
cpudevice->setMaximumScalingFrequency(cpuLimit); cpudevice->setMaximumScalingFrequency(cpuLimit);
} }
break; break;
@ -1134,7 +1161,7 @@ bool HardwareInfo::setCPUFreq ( cpufreq_type cpufreq, int limit ) {
kdWarning() << "Unknown cpufreq_type: " << cpufreq << endl; kdWarning() << "Unknown cpufreq_type: " << cpufreq << endl;
return false; return false;
} }
// check if the policy was really set (and emit signal) // check if the policy was really set (and emit signal)
if (checkCurrentCPUFreqPolicy() == cpufreq) { if (checkCurrentCPUFreqPolicy() == cpufreq) {
// update_info_cpufreq_policy_changed = true; // update_info_cpufreq_policy_changed = true;
@ -1143,13 +1170,13 @@ bool HardwareInfo::setCPUFreq ( cpufreq_type cpufreq, int limit ) {
} else { } else {
return false; return false;
} }
} else { } else {
return false; return false;
} }
} }
/*! /*!
* 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 * \param governor char * with the name of the governor
* \return boolean with result of the operation * \return boolean with result of the operation
* \retval true if successful * \retval true if successful
@ -1172,14 +1199,14 @@ bool HardwareInfo::setCPUFreqGovernor( const char *governor ) {
ret = false; ret = false;
} }
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return ret; return ret;
} }
/*! /*!
* 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 * \param on boolean which tell if enable/disable powersave mode
* \return boolean with result of the operation * \return boolean with result of the operation
* \retval true if successful * \retval true if successful
@ -1192,14 +1219,14 @@ bool HardwareInfo::setPowerSave( bool on ) {
// FIXME // FIXME
// Set up power saving to the best of our ability using "raw" functions // 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); kdDebugFuncOut(trace);
return retval; return retval;
} }
/*! /*!
* Function to call GetSchedPowerSavings() via HAL. * Function to call GetSchedPowerSavings() via TDE hardware library.
* \return boolean with result of the operation * \return boolean with result of the operation
* \retval true if successful * \retval true if successful
* \retval false else, if a error occurs * \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 * Function to call SetSchedPowerSavings() via TDE hardware library.
* Multiprocessor/-core machines. * Note: this would only work on multiprocessor/-core machines.
* \return boolean with result of the operation * \return boolean with result of the operation
* \retval true if successful * \retval true if successful
* \retval false else, if a error occurs * \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 <-- // --> private helper functions/slots to forward/handle events -- START <--
// need this functions to make events from HAL/D-Bus independent // need this functions to make events from HAL/D-Bus independent
@ -1242,7 +1269,7 @@ bool HardwareInfo::setSchedPowerSavings( bool enable ) {
// blocked by normal KDE/QT (GUI) calls // blocked by normal KDE/QT (GUI) calls
/*! /*!
* Function to emit the signal for the Power button. * Function to emit the signal for the Power button.
*/ */
void HardwareInfo::emitPowerButtonPressed() { void HardwareInfo::emitPowerButtonPressed() {
if (sessionIsActive) { if (sessionIsActive) {
emit powerButtonPressed(); emit powerButtonPressed();
@ -1294,17 +1321,17 @@ void HardwareInfo::emitSessionActiveState() {
* Function to set the brightess a step up. * Function to set the brightess a step up.
* \param percentageStep Integer of next step should get set * \param percentageStep Integer of next step should get set
* \return result of the operation * \return result of the operation
* \retval true if could get set * \retval true if could get set
* \retval false else * \retval false else
*/ */
bool HardwareInfo::setBrightnessUp(int percentageStep) { bool HardwareInfo::setBrightnessUp(int percentageStep) {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
bool retval = false; bool retval = false;
checkCurrentBrightness(); checkCurrentBrightness();
if (supportBrightness() && (getCurrentBrightnessLevel() >= 0) && if (supportBrightness() && (getCurrentBrightnessLevel() >= 0) &&
(getCurrentBrightnessLevel() != (getMaxBrightnessLevel()-1))) { (getCurrentBrightnessLevel() != (getMaxBrightnessLevel()-1))) {
int setTo = 0; int setTo = 0;
int minPercStep = 10; int minPercStep = 10;
@ -1312,7 +1339,7 @@ bool HardwareInfo::setBrightnessUp(int percentageStep) {
if (percentageStep > 0 && (percentageStep <= (100-currentPerc))) { if (percentageStep > 0 && (percentageStep <= (100-currentPerc))) {
minPercStep = percentageStep; minPercStep = percentageStep;
} }
if ((currentPerc + minPercStep) > 100) { if ((currentPerc + minPercStep) > 100) {
// set to 100 % // set to 100 %
@ -1325,16 +1352,16 @@ bool HardwareInfo::setBrightnessUp(int percentageStep) {
} }
if (trace) { if (trace) {
kdDebug() << "Max: " << getMaxBrightnessLevel() kdDebug() << "Max: " << getMaxBrightnessLevel()
<< " Current: " << getCurrentBrightnessLevel() << " Current: " << getCurrentBrightnessLevel()
<< " minPercStep: " << minPercStep << " minPercStep: " << minPercStep
<< " currentPerc: " << currentPerc << " currentPerc: " << currentPerc
<< " setTo: " << setTo << endl; << " setTo: " << setTo << endl;
} }
retval = setBrightness(setTo, -1); retval = setBrightness(setTo, -1);
} }
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return retval; return retval;
} }
@ -1343,7 +1370,7 @@ bool HardwareInfo::setBrightnessUp(int percentageStep) {
* Function to set the brightess a step up. * Function to set the brightess a step up.
* \param percentageStep Integer of next step should get set * \param percentageStep Integer of next step should get set
* \return result of the operation * \return result of the operation
* \retval true if could get set * \retval true if could get set
* \retval false else * \retval false else
*/ */
bool HardwareInfo::setBrightnessDown(int percentageStep) { bool HardwareInfo::setBrightnessDown(int percentageStep) {
@ -1372,8 +1399,8 @@ bool HardwareInfo::setBrightnessDown(int percentageStep) {
} }
if (trace) { if (trace) {
kdDebug() << "Max: " << getMaxBrightnessLevel() kdDebug() << "Max: " << getMaxBrightnessLevel()
<< " Current: " << getCurrentBrightnessLevel() << " Current: " << getCurrentBrightnessLevel()
<< " minPercStep: " << minPercStep << " minPercStep: " << minPercStep
<< " currentPerc: " << currentPerc << " currentPerc: " << currentPerc
<< " setTo: " << setTo << endl; << " setTo: " << setTo << endl;
@ -1391,7 +1418,7 @@ bool HardwareInfo::setBrightnessDown(int percentageStep) {
*/ */
void HardwareInfo::brightnessUpPressed() { void HardwareInfo::brightnessUpPressed() {
kdDebugFuncIn(trace); kdDebugFuncIn(trace);
if (brightness) { if (brightness) {
if (!sessionIsActive) { if (!sessionIsActive) {
kdWarning() << "Session is not active, don't react on brightness up key event!" << endl; kdWarning() << "Session is not active, don't react on brightness up key event!" << endl;
@ -1431,9 +1458,9 @@ void HardwareInfo::brightnessDownPressed() {
/*! /*!
* The function return the current state of the ac adapter. * The function return the current state of the ac adapter.
* \return boolean with the current state * \return boolean with the current state
* \retval true if adapter is present/connected or unknown * \retval true if adapter is present/connected or unknown
* \retval false if not * \retval false if not
*/ */
bool HardwareInfo::getAcAdapter() const { bool HardwareInfo::getAcAdapter() const {
return acadapter; return acadapter;
@ -1441,7 +1468,7 @@ bool HardwareInfo::getAcAdapter() const {
/*! /*!
* The function return the current state of the lidclose button. * The function return the current state of the lidclose button.
* \return boolean with the current state * \return boolean with the current state
* \retval true if the lid is closed * \retval true if the lid is closed
* \retval false if the lid is opend * \retval false if the lid is opend
*/ */
@ -1508,7 +1535,7 @@ TQPtrList<Battery> HardwareInfo::getAllBatteries() const {
/*! /*!
* The function return the status of \ref laptop. * The function return the status of \ref laptop.
* \return boolean with info if machine is a laptop * \return boolean with info if machine is a laptop
* \retval true if a laptop * \retval true if a laptop
* \retval false else/if not a laptop * \retval false else/if not a laptop
*/ */
@ -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 * 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 true if connected
* \retval false if not connected * \retval false if not connected
*/ */
@ -1531,7 +1558,7 @@ bool HardwareInfo::isOnline() const {
/*! /*!
* The function return the status of \ref has_ACPI. * The function return the status of \ref has_ACPI.
* \return boolean with info if machine support ACPI * \return boolean with info if machine support ACPI
* \retval true if support ACPI * \retval true if support ACPI
* \retval false else * \retval false else
*/ */
@ -1551,7 +1578,7 @@ bool HardwareInfo::hasAPM() const {
/*! /*!
* The function return the status of \ref has_PMU. * The function return the status of \ref has_PMU.
* \return boolean with info if machine support PMU * \return boolean with info if machine support PMU
* \retval true if support PMU * \retval true if support PMU
* \retval false else * \retval false else
*/ */
@ -1561,7 +1588,7 @@ bool HardwareInfo::hasPMU() const {
/*! /*!
* The function return the status of \ref brightness. * 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 true if support brightness changes
* \retval false else * \retval false else
*/ */
@ -1571,7 +1598,7 @@ bool HardwareInfo::supportBrightness() const {
/*! /*!
* The function return the status of \ref cpuFreq. * 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 true if support brightness changes
* \retval false else * \retval false else
*/ */

@ -16,14 +16,14 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/ ***************************************************************************/
/*! /*!
* \file hardware.h * \file hardware.h
* \brief Headerfile for hardwareinfo.cpp. This file collect/hold all * \brief Headerfile for hardwareinfo.cpp. This file collect/hold all
* Hardware information as e.g. battery and ac state. * Hardware information as e.g. battery and ac state.
*/ */
/*! /*!
* \class HardwareInfo * \class HardwareInfo
* \brief class for hardware information related funtionality * \brief class for hardware information related funtionality
* \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de> * \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
@ -55,6 +55,7 @@
enum suspend_type { enum suspend_type {
SUSPEND2DISK, SUSPEND2DISK,
SUSPEND2RAM, SUSPEND2RAM,
FREEZE,
STANDBY STANDBY
}; };
@ -76,7 +77,7 @@ enum device_type {
}; };
enum ERROR_MSG { enum ERROR_MSG {
DBUS_NO_RIGHTS, DBUS_NO_RIGHTS,
DBUS_NOT_RUNNING, DBUS_NOT_RUNNING,
DBUS_RUNNING DBUS_RUNNING
}; };
@ -84,7 +85,7 @@ enum ERROR_MSG {
//! hold information if suspend/standby/pm actions are supported and allowed //! hold information if suspend/standby/pm actions are supported and allowed
/*! /*!
* This dictionary contains information about the available pm capabilities and * 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 { typedef struct SuspendStates {
//! true if the machine support suspend2ram and the interface is available //! true if the machine support suspend2ram and the interface is available
@ -99,6 +100,12 @@ typedef struct SuspendStates {
bool suspend2disk_can; bool suspend2disk_can;
//! true if the machine support suspend2disk and PolicyKit allow to call the interface //! true if the machine support suspend2disk and PolicyKit allow to call the interface
int suspend2disk_allowed; 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 //! true if the machine support standby and the interface is available
bool standby; bool standby;
//! true if the machine support standby, but no interface available //! true if the machine support standby, but no interface available
@ -106,13 +113,16 @@ typedef struct SuspendStates {
//! true if the machine support standby and PolicyKit allow to call the interface //! true if the machine support standby and PolicyKit allow to call the interface
int standby_allowed; int standby_allowed;
SuspendStates () { SuspendStates () {
suspend2ram = false; suspend2ram = false;
suspend2ram_can = false; suspend2ram_can = false;
suspend2ram_allowed = -1; suspend2ram_allowed = -1;
suspend2disk = false; suspend2disk = false;
suspend2disk_can = false; suspend2disk_can = false;
suspend2disk_allowed = -1; suspend2disk_allowed = -1;
freeze = false;
freeze_can = false;
freeze_allowed = -1;
standby = false; standby = false;
standby_can = false; standby_can = false;
standby_allowed = -1; standby_allowed = -1;
@ -122,9 +132,9 @@ typedef struct SuspendStates {
class HardwareInfo : public TQObject{ class HardwareInfo : public TQObject{
Q_OBJECT Q_OBJECT
private:
private:
TDEHardwareDevices *m_hwdevices; TDEHardwareDevices *m_hwdevices;
//! pointer to the dbusInterface connection class //! pointer to the dbusInterface connection class
@ -143,15 +153,15 @@ private:
//! hold the UDIs of all hardware we handle atm //! hold the UDIs of all hardware we handle atm
/*! /*!
* This TQStringList contains the list of UDIs we handle at the moment in this * 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 * class. This should be used to handle device events from TDE hardware library
* want to monitor * for devices we want to monitor
*/ */
TQStringList allUDIs; TQStringList allUDIs;
//! hold information if suspend/standby/pm actions are supported and allowed //! hold information if suspend/standby/pm actions are supported and allowed
/*! /*!
* This dictionary contains information about the available pm capabilities and * 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; SuspendStates suspend_states;
@ -173,65 +183,65 @@ private:
cpufreq_type currentCPUFreqPolicy; cpufreq_type currentCPUFreqPolicy;
//! the state of the ac adapter //! the state of the ac adapter
/*! /*!
* This boolean represent information about the AC adapter state. * This boolean represent information about the AC adapter state.
* \li true: if AC adapter is present * \li true: if AC adapter is present
* \li false: it AC adapter is not present * \li false: it AC adapter is not present
*/ */
bool acadapter; bool acadapter;
//! the state of the lidclose button //! the state of the lidclose button
/*! /*!
* This boolean represent information about the Lid button state. * This boolean represent information about the Lid button state.
* \li true: if lid is closed * \li true: if lid is closed
* \li false: else * \li false: else
*/ */
bool lidclose; bool lidclose;
//! if the machine support APM //! if the machine support APM
/*! /*!
* This boolean represent information if the machine support APM or not. * This boolean represent information if the machine support APM or not.
* \li true: if APM supported * \li true: if APM supported
* \li false: else * \li false: else
*/ */
bool has_APM; bool has_APM;
//! if the machine support ACPI //! if the machine support ACPI
/*! /*!
* This boolean represent information if the machine support ACPI or not. * This boolean represent information if the machine support ACPI or not.
* \li true: if ACPI supported * \li true: if ACPI supported
* \li false: else * \li false: else
*/ */
bool has_ACPI; bool has_ACPI;
//! if the machine support PMU (ppc power management) //! if the machine support PMU (ppc power management)
/*! /*!
* This boolean represent information if the machine support PMU or not. * This boolean represent information if the machine support PMU or not.
* \li true: if PMU supported * \li true: if PMU supported
* \li false: else * \li false: else
*/ */
bool has_PMU; 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 * 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 true: if supported
* \li false: else * \li false: else
*/ */
bool cpuFreq; 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 * 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 true: if supported
* \li false: else * \li false: else
*/ */
bool schedPowerSavings; bool schedPowerSavings;
//! if the machine support change brightness //! if the machine support change brightness
/*! /*!
* This boolean represent information if the machine support brightness changes. * This boolean represent information if the machine support brightness changes.
* \li true: if supported * \li true: if supported
* \li false: else * \li false: else
*/ */
bool brightness; bool brightness;
//! if brightness get controled via keyevents in hardware //! if brightness get controled via keyevents in hardware
/*! /*!
* This boolean represent information if the machine handle brightness button * This boolean represent information if the machine handle brightness button
* and keyevents in hardware. If so TDEPowersave should ignore key events. * and keyevents in hardware. If so TDEPowersave should ignore key events.
* \li true: if handled in hardware * \li true: if handled in hardware
@ -239,7 +249,7 @@ private:
*/ */
bool brightness_in_hardware; bool brightness_in_hardware;
//! if the machine is a laptop //! if the machine is a laptop
/*! /*!
* This boolean represent information if the machine is a laptop. * This boolean represent information if the machine is a laptop.
* \li true: if the machine is a laptop * \li true: if the machine is a laptop
* \li false: else * \li false: else
@ -247,7 +257,7 @@ private:
bool laptop; bool laptop;
//! if the current desktop session is active //! if the current desktop session is active
/*! /*!
* This boolean represent information if the current desktop session in * This boolean represent information if the current desktop session in
* Which TDEPowersave runs is marked in ConsoleKit as active or not. * Which TDEPowersave runs is marked in ConsoleKit as active or not.
* \li true: if active * \li true: if active
@ -256,18 +266,18 @@ private:
bool sessionIsActive; bool sessionIsActive;
//! if the current user can use the CPU Freq interface //! if the current user can use the CPU Freq interface
/*! /*!
* This integer tell if the current user is allowed to change the * 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 1: if allowed
* \li 0: if not allowed * \li 0: if not allowed
* \li -1: if unknown (e.g. there is no policy/PolicyKit) * \li -1: if unknown (e.g. there is no policy/PolicyKit)
*/ */
int cpuFreqAllowed; int cpuFreqAllowed;
//! if the current user can use the brightness interface //! if the current user can use the brightness interface
/*! /*!
* This integer tell if the current user is allowed to change the * 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 1: if allowed
* \li 0: if not allowed * \li 0: if not allowed
* \li -1: if unknown (e.g. there is no policy/PolicyKit) * \li -1: if unknown (e.g. there is no policy/PolicyKit)
@ -294,7 +304,7 @@ private:
void checkPowermanagement(); void checkPowermanagement();
//! check the possible suspend/standby states //! check the possible suspend/standby states
void checkSuspend(); 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(); void checkCPUFreq();
//! check the current brightness level //! check the current brightness level
void checkCurrentBrightness(); void checkCurrentBrightness();
@ -311,9 +321,9 @@ private:
bool checkIfHandleDevice ( TQString _udi, int *type ); bool checkIfHandleDevice ( TQString _udi, int *type );
//! to set the CPUFreq governor //! to set the CPUFreq governor
bool setCPUFreqGovernor( const char *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(); 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 ); bool setSchedPowerSavings( bool enable );
//! find and update a battery information //! find and update a battery information
@ -340,7 +350,7 @@ private slots:
//! TQT_SLOT to forward signal about changed battery warning state //! TQT_SLOT to forward signal about changed battery warning state
void emitBatteryWARNState (int type, int state); void emitBatteryWARNState (int type, int state);
//! TQT_SLOT to handle resume and forward a signal for resume //! TQT_SLOT to handle resume and forward a signal for resume
void handleResumeSignal (int result); void handleResumeSignal (int result);
@ -387,7 +397,7 @@ signals:
//! signal if the D-Bus daemon terminate and restart //! signal if the D-Bus daemon terminate and restart
void dbusRunning( int ); void dbusRunning( int );
//! signal if the IsActive state of //! signal if the IsActive state of
void desktopSessionIsActive (bool); void desktopSessionIsActive (bool);
//! signal if we are back from resume //! signal if we are back from resume
@ -397,21 +407,21 @@ public:
// update related info --> need to be reset if the data was read // update related info --> need to be reset if the data was read
//! tells if the CPUFreq Policy changed //! tells if the CPUFreq Policy changed
/*! /*!
* This boolean represent information about CPUFreq Policy changes. * This boolean represent information about CPUFreq Policy changes.
* \li true: if something changed * \li true: if something changed
* \li false: if nothing changed (or this is reset to false if the message was consumed) * \li false: if nothing changed (or this is reset to false if the message was consumed)
*/ */
bool update_info_cpufreq_policy_changed; bool update_info_cpufreq_policy_changed;
//! tells if the AC status changed //! tells if the AC status changed
/*! /*!
* This boolean represent information about AC status changes. * This boolean represent information about AC status changes.
* \li true: if something changed * \li true: if something changed
* \li false: if nothing changed (or this is reset to false if the message was consumed) * \li false: if nothing changed (or this is reset to false if the message was consumed)
*/ */
bool update_info_ac_changed; bool update_info_ac_changed;
//! tells if the primary battery collection changed some values //! tells if the primary battery collection changed some values
/*! /*!
* This boolean represent information about primary battery changes. * This boolean represent information about primary battery changes.
* \li true: if something changed * \li true: if something changed
* \li false: if nothing changed (or this is reset to false if the message was consumed) * \li false: if nothing changed (or this is reset to false if the message was consumed)
@ -433,14 +443,14 @@ public:
//! default destructor //! default destructor
~HardwareInfo(); ~HardwareInfo();
// to get private members // to get private members
//! get info about support of suspend/standby //! get info about support of suspend/standby
SuspendStates getSuspendSupport() const; SuspendStates getSuspendSupport() const;
//! get a pointer to the primary batteries //! get a pointer to the primary batteries
BatteryCollection* getPrimaryBatteries() const; BatteryCollection* getPrimaryBatteries() const;
//! get all batteries //! get all batteries
TQPtrList<Battery> getAllBatteries() const; TQPtrList<Battery> getAllBatteries() const;
//! check the currently set CPU Frequency Policy //! check the currently set CPU Frequency Policy
cpufreq_type checkCurrentCPUFreqPolicy(); cpufreq_type checkCurrentCPUFreqPolicy();
@ -462,7 +472,7 @@ public:
bool getLidclose() const; bool getLidclose() const;
//! check if the machine is a latop //! check if the machine is a latop
bool isLaptop() const; 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; bool isOnline() const;
//! check if the machine support ACPI //! check if the machine support ACPI
bool hasACPI() const; bool hasACPI() const;
@ -477,10 +487,10 @@ public:
//! check if the current session is active //! check if the current session is active
bool currentSessionIsActive() const; bool currentSessionIsActive() const;
// --> functions to call a HAL interface and trigger an action // --> functions to call a TDE hardware library and trigger an action
//! execute/trigger a suspend via the HAL interface //! execute/trigger a suspend via the TDE hardware library
bool suspend ( suspend_type suspend ); 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); bool setBrightness ( int level, int percent = -1);
//! to set the brightness down //! to set the brightness down
bool setBrightnessDown(int percentageStep = -1); bool setBrightnessDown(int percentageStep = -1);
@ -488,7 +498,7 @@ public:
bool setBrightnessUp(int percentageStep = -1); bool setBrightnessUp(int percentageStep = -1);
//! set the CPU frequency policy/speed //! set the CPU frequency policy/speed
bool setCPUFreq ( cpufreq_type cpufreq, int limit = 51 ); bool setCPUFreq ( cpufreq_type cpufreq, int limit = 51 );
//! call SetPowerSave method on HAL. //! call SetPowerSave method on TDE hardware library.
bool setPowerSave( bool on ); bool setPowerSave( bool on );
//! function to set warning states for the primary battery collection //! function to set warning states for the primary battery collection

@ -17,9 +17,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/ ***************************************************************************/
/*! /*!
* \file settings.cpp * \file settings.cpp
* \brief In this file can be found the settings ( read ) related code. * \brief In this file can be found the settings ( read ) related code.
* \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de> * \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
* \date 2005 * \date 2005
*/ */
@ -27,7 +27,7 @@
// KDE Header // KDE Header
#include <tdelocale.h> #include <tdelocale.h>
// QT Header // QT Header
// own headers // own headers
#include "settings.h" #include "settings.h"
@ -51,7 +51,7 @@ Settings::~Settings()
/*! /*!
* Loads the scheme settings from tdepowersaverc and fills the related variables. * Loads the scheme settings from tdepowersaverc and fills the related variables.
* \param schemeName TQString with the name (realname not i18n() version) of the * \param schemeName TQString with the name (realname not i18n() version) of the
* scheme which setting should be load. If the scheme could not * scheme which setting should be load. If the scheme could not
* be loaded, this function try to load "default-scheme" * be loaded, this function try to load "default-scheme"
* \return the result of the load * \return the result of the load
@ -59,7 +59,7 @@ Settings::~Settings()
* \retval false if there was no group named like schemeName or named "default-scheme" * \retval false if there was no group named like schemeName or named "default-scheme"
*/ */
bool Settings::load_scheme_settings(TQString schemeName){ bool Settings::load_scheme_settings(TQString schemeName){
tdeconfig->reparseConfiguration(); tdeconfig->reparseConfiguration();
bool setToDefault = false; bool setToDefault = false;
@ -71,7 +71,7 @@ bool Settings::load_scheme_settings(TQString schemeName){
schemeName = "Presentation"; schemeName = "Presentation";
else if( schemeName == "Acoustic" || schemeName == i18n("Acoustic")) else if( schemeName == "Acoustic" || schemeName == i18n("Acoustic"))
schemeName = "Acoustic"; schemeName = "Acoustic";
if(tdeconfig->hasGroup(schemeName) || tdeconfig->hasGroup("default-scheme") ){ if(tdeconfig->hasGroup(schemeName) || tdeconfig->hasGroup("default-scheme") ){
if(tdeconfig->hasGroup(schemeName)) tdeconfig->setGroup(schemeName); if(tdeconfig->hasGroup(schemeName)) tdeconfig->setGroup(schemeName);
else { else {
@ -81,13 +81,13 @@ bool Settings::load_scheme_settings(TQString schemeName){
setToDefault = true; setToDefault = true;
} }
currentScheme = schemeName; currentScheme = schemeName;
specSsSettings = tdeconfig->readBoolEntry("specSsSettings",false); specSsSettings = tdeconfig->readBoolEntry("specSsSettings",false);
disableSs = tdeconfig->readBoolEntry("disableSs",false); disableSs = tdeconfig->readBoolEntry("disableSs",false);
blankSs = tdeconfig->readBoolEntry("blankSs",false); blankSs = tdeconfig->readBoolEntry("blankSs",false);
specPMSettings = tdeconfig->readBoolEntry("specPMSettings",false); specPMSettings = tdeconfig->readBoolEntry("specPMSettings",false);
disableDPMS = tdeconfig->readBoolEntry("disableDPMS",false); disableDPMS = tdeconfig->readBoolEntry("disableDPMS",false);
int i_standby = tdeconfig->readNumEntry("standbyAfter", -1); int i_standby = tdeconfig->readNumEntry("standbyAfter", -1);
if (i_standby >= 0) standbyAfter = i_standby; if (i_standby >= 0) standbyAfter = i_standby;
else { else {
@ -100,7 +100,7 @@ bool Settings::load_scheme_settings(TQString schemeName){
// reset the group // reset the group
tdeconfig->setGroup(schemeName); tdeconfig->setGroup(schemeName);
} }
int i_suspend = tdeconfig->readNumEntry("suspendAfter", -1); int i_suspend = tdeconfig->readNumEntry("suspendAfter", -1);
if (i_suspend >= 0) suspendAfter = i_suspend; if (i_suspend >= 0) suspendAfter = i_suspend;
else { else {
@ -113,7 +113,7 @@ bool Settings::load_scheme_settings(TQString schemeName){
// reset the group // reset the group
tdeconfig->setGroup(schemeName); tdeconfig->setGroup(schemeName);
} }
int i_poweroff = tdeconfig->readNumEntry("powerOffAfter", -1); int i_poweroff = tdeconfig->readNumEntry("powerOffAfter", -1);
if (i_poweroff >= 0) powerOffAfter = i_poweroff; if (i_poweroff >= 0) powerOffAfter = i_poweroff;
else { else {
@ -126,7 +126,7 @@ bool Settings::load_scheme_settings(TQString schemeName){
// reset the group // reset the group
tdeconfig->setGroup(schemeName); tdeconfig->setGroup(schemeName);
} }
brightness = tdeconfig->readBoolEntry("enableBrightness",false); brightness = tdeconfig->readBoolEntry("enableBrightness",false);
brightnessValue = tdeconfig->readNumEntry("brightnessPercent", -1); brightnessValue = tdeconfig->readNumEntry("brightnessPercent", -1);
if (brightnessValue == -1) { if (brightnessValue == -1) {
@ -148,7 +148,7 @@ bool Settings::load_scheme_settings(TQString schemeName){
// reset the group // reset the group
tdeconfig->setGroup(schemeName); tdeconfig->setGroup(schemeName);
} }
TQString _autoInactiveAction = tdeconfig->readEntry("autoInactiveAction", "NULL"); TQString _autoInactiveAction = tdeconfig->readEntry("autoInactiveAction", "NULL");
if( _autoInactiveAction != "NULL") { if( _autoInactiveAction != "NULL") {
autoInactiveAction = _autoInactiveAction; autoInactiveAction = _autoInactiveAction;
@ -161,11 +161,11 @@ bool Settings::load_scheme_settings(TQString schemeName){
// reset the group // reset the group
tdeconfig->setGroup(schemeName); tdeconfig->setGroup(schemeName);
} }
autoSuspend = tdeconfig->readBoolEntry("autoSuspend",false); autoSuspend = tdeconfig->readBoolEntry("autoSuspend",false);
autoInactiveSBlistEnabled = tdeconfig->readBoolEntry("autoInactiveSchemeBlacklistEnabled",false); autoInactiveSBlistEnabled = tdeconfig->readBoolEntry("autoInactiveSchemeBlacklistEnabled",false);
autoInactiveSBlist = tdeconfig->readListEntry("autoInactiveSchemeBlacklist", ','); autoInactiveSBlist = tdeconfig->readListEntry("autoInactiveSchemeBlacklist", ',');
int i_autoDimmAfter = tdeconfig->readNumEntry("autoDimmAfter", -1); int i_autoDimmAfter = tdeconfig->readNumEntry("autoDimmAfter", -1);
if (i_autoDimmAfter >= 0) autoDimmAfter = i_autoDimmAfter; if (i_autoDimmAfter >= 0) autoDimmAfter = i_autoDimmAfter;
else { else {
@ -197,14 +197,14 @@ bool Settings::load_scheme_settings(TQString schemeName){
autoDimmSBlist = tdeconfig->readListEntry("autoDimmSchemeBlacklist", ','); autoDimmSBlist = tdeconfig->readListEntry("autoDimmSchemeBlacklist", ',');
disableNotifications = tdeconfig->readBoolEntry("disableNotifications",false); disableNotifications = tdeconfig->readBoolEntry("disableNotifications",false);
TQString _cpufreqpolicy = tdeconfig->readEntry("cpuFreqPolicy", "NULL"); TQString _cpufreqpolicy = tdeconfig->readEntry("cpuFreqPolicy", "NULL");
if( _cpufreqpolicy == "NULL") { if( _cpufreqpolicy == "NULL") {
tdeconfig->setGroup("default-scheme"); tdeconfig->setGroup("default-scheme");
_cpufreqpolicy = tdeconfig->readEntry("cpuFreqPolicy", "NULL"); _cpufreqpolicy = tdeconfig->readEntry("cpuFreqPolicy", "NULL");
// reset the group // reset the group
tdeconfig->setGroup(schemeName); tdeconfig->setGroup(schemeName);
} }
if (_cpufreqpolicy.startsWith("DYNAMIC")) { if (_cpufreqpolicy.startsWith("DYNAMIC")) {
cpuFreqPolicy = DYNAMIC; cpuFreqPolicy = DYNAMIC;
} else if (_cpufreqpolicy.startsWith("PERFORMANCE")) { } else if (_cpufreqpolicy.startsWith("PERFORMANCE")) {
@ -222,7 +222,7 @@ bool Settings::load_scheme_settings(TQString schemeName){
cpuFreqDynamicPerformance = tdeconfig->readNumEntry("cpuFreqDynamicPerformance", 51); cpuFreqDynamicPerformance = tdeconfig->readNumEntry("cpuFreqDynamicPerformance", 51);
// reset the group // reset the group
tdeconfig->setGroup(schemeName); tdeconfig->setGroup(schemeName);
} }
return true; return true;
} }
@ -237,12 +237,12 @@ bool Settings::load_scheme_settings(TQString schemeName){
* \retval false if there was no group named 'General' * \retval false if there was no group named 'General'
*/ */
bool Settings::load_general_settings(){ bool Settings::load_general_settings(){
tdeconfig->reparseConfiguration(); tdeconfig->reparseConfiguration();
if(tdeconfig->hasGroup("General")) { if(tdeconfig->hasGroup("General")) {
tdeconfig->setGroup("General"); tdeconfig->setGroup("General");
lockOnSuspend = tdeconfig->readBoolEntry("lockOnSuspend",true); lockOnSuspend = tdeconfig->readBoolEntry("lockOnSuspend",true);
lockOnLidClose = tdeconfig->readBoolEntry("lockOnLidClose",true); lockOnLidClose = tdeconfig->readBoolEntry("lockOnLidClose",true);
autostart = tdeconfig->readBoolEntry("Autostart",false); autostart = tdeconfig->readBoolEntry("Autostart",false);
@ -254,10 +254,10 @@ bool Settings::load_general_settings(){
lockmethod = tdeconfig->readEntry("lockMethod", "NULL"); lockmethod = tdeconfig->readEntry("lockMethod", "NULL");
if(lockmethod == "NULL") lockmethod = "automatic"; if(lockmethod == "NULL") lockmethod = "automatic";
autoInactiveGBlist = tdeconfig->readListEntry("autoInactiveBlacklist", ','); autoInactiveGBlist = tdeconfig->readListEntry("autoInactiveBlacklist", ',');
autoDimmGBlist = tdeconfig->readListEntry("autoDimmBlacklist", ','); autoDimmGBlist = tdeconfig->readListEntry("autoDimmBlacklist", ',');
autoSuspendCountdown = tdeconfig->readBoolEntry("AutoSuspendCountdown", false); autoSuspendCountdown = tdeconfig->readBoolEntry("AutoSuspendCountdown", false);
autoSuspendCountdownTimeout = tdeconfig->readNumEntry("AutoSuspendCountdownTimeOut", 30); autoSuspendCountdownTimeout = tdeconfig->readNumEntry("AutoSuspendCountdownTimeOut", 30);
@ -300,12 +300,12 @@ bool Settings::load_general_settings(){
} }
sleepButtonAction = mapActionToType(tdeconfig->readEntry("ActionOnSleepButton","")); sleepButtonAction = mapActionToType(tdeconfig->readEntry("ActionOnSleepButton",""));
if ((sleepButtonAction != GO_SUSPEND2RAM) && (sleepButtonAction != GO_SUSPEND2DISK)) { if ((sleepButtonAction != GO_SUSPEND2RAM) && (sleepButtonAction != GO_SUSPEND2DISK) && (sleepButtonAction != GO_FREEZE)) {
sleepButtonAction = NONE; sleepButtonAction = NONE;
} }
s2diskButtonAction = mapActionToType(tdeconfig->readEntry("ActionOnS2DiskButton","")); s2diskButtonAction = mapActionToType(tdeconfig->readEntry("ActionOnS2DiskButton",""));
if ((s2diskButtonAction != GO_SUSPEND2RAM) && (s2diskButtonAction != GO_SUSPEND2DISK)) { if ((s2diskButtonAction != GO_SUSPEND2RAM) && (s2diskButtonAction != GO_SUSPEND2DISK) && (s2diskButtonAction != GO_FREEZE)) {
s2diskButtonAction = NONE; s2diskButtonAction = NONE;
} }
@ -321,7 +321,7 @@ bool Settings::load_general_settings(){
* \return a integer value with the result of the mapping as \ref action * \return a integer value with the result of the mapping as \ref action
*/ */
action Settings::mapActionToType (TQString _action) { action Settings::mapActionToType (TQString _action) {
if (_action.isEmpty()) { if (_action.isEmpty()) {
return NONE; return NONE;
} else if (_action.startsWith("SHUTDOWN")) { } else if (_action.startsWith("SHUTDOWN")) {
@ -332,6 +332,8 @@ action Settings::mapActionToType (TQString _action) {
return GO_SUSPEND2DISK; return GO_SUSPEND2DISK;
} else if (_action.startsWith("SUSPEND2RAM")) { } else if (_action.startsWith("SUSPEND2RAM")) {
return GO_SUSPEND2RAM; return GO_SUSPEND2RAM;
} else if (_action.startsWith("FREEZE")) {
return GO_FREEZE;
} else if (_action.startsWith("CPUFRETQ_POWERSAVE")) { } else if (_action.startsWith("CPUFRETQ_POWERSAVE")) {
return CPUFRETQ_POWERSAVE; return CPUFRETQ_POWERSAVE;
} else if (_action.startsWith("CPUFRETQ_DYNAMIC")) { } else if (_action.startsWith("CPUFRETQ_DYNAMIC")) {
@ -341,7 +343,7 @@ action Settings::mapActionToType (TQString _action) {
} else if (_action.startsWith("BRIGHTNESS")) { } else if (_action.startsWith("BRIGHTNESS")) {
return BRIGHTNESS; return BRIGHTNESS;
} else { } else {
return UNKNOWN_ACTION; return UNKNOWN_ACTION;
} }
} }
@ -349,11 +351,11 @@ action Settings::mapActionToType (TQString _action) {
* Loads the default KDE Settings from the different configfiles and store * Loads the default KDE Settings from the different configfiles and store
* them to a \ref KDE_Settings 'object'. * them to a \ref KDE_Settings 'object'.
* \retval true if the settings could be loaded * \retval true if the settings could be loaded
* \retval false if there was a error/problem * \retval false if there was a error/problem
*/ */
void Settings::load_kde(){ void Settings::load_kde(){
TDEConfig *_tdeconfig = new TDEConfig("kcmdisplayrc", true ); TDEConfig *_tdeconfig = new TDEConfig("kcmdisplayrc", true );
/* KDE settings [DisplayEnergy] from kcmdisplayrc */ /* KDE settings [DisplayEnergy] from kcmdisplayrc */
if(_tdeconfig->hasGroup("DisplayEnergy")) { if(_tdeconfig->hasGroup("DisplayEnergy")) {
_tdeconfig->setGroup("DisplayEnergy"); _tdeconfig->setGroup("DisplayEnergy");
@ -362,7 +364,7 @@ void Settings::load_kde(){
kde->displaySuspend = _tdeconfig->readNumEntry("displaySuspend", 13); kde->displaySuspend = _tdeconfig->readNumEntry("displaySuspend", 13);
kde->displayPowerOff = _tdeconfig->readNumEntry("displayPowerOff", 19); kde->displayPowerOff = _tdeconfig->readNumEntry("displayPowerOff", 19);
} }
delete _tdeconfig; delete _tdeconfig;
_tdeconfig = new TDEConfig("kdesktoprc", true ); _tdeconfig = new TDEConfig("kdesktoprc", true );
/* KDE settings [ScreenSaver] from kdesktoprc */ /* KDE settings [ScreenSaver] from kdesktoprc */
if(_tdeconfig->hasGroup("ScreenSaver")) { if(_tdeconfig->hasGroup("ScreenSaver")) {
@ -373,7 +375,7 @@ void Settings::load_kde(){
TQString _savername = _tdeconfig->readEntry("Saver", "KBlankscreen.desktop"); TQString _savername = _tdeconfig->readEntry("Saver", "KBlankscreen.desktop");
if (_savername.startsWith("KBlankscreen.desktop")) if (_savername.startsWith("KBlankscreen.desktop"))
kde->blanked = true; kde->blanked = true;
else else
kde->blanked = false; kde->blanked = false;
} }
delete _tdeconfig; delete _tdeconfig;

@ -16,8 +16,8 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/ ***************************************************************************/
/*! /*!
* \file settings.h * \file settings.h
* \brief Headerfile for settings.cpp and the class \ref Settings. * \brief Headerfile for settings.cpp and the class \ref Settings.
*/ */
@ -42,6 +42,7 @@ enum action{
LOGOUT_DIALOG, LOGOUT_DIALOG,
GO_SUSPEND2RAM, GO_SUSPEND2RAM,
GO_SUSPEND2DISK, GO_SUSPEND2DISK,
GO_FREEZE,
SWITCH_SCHEME, SWITCH_SCHEME,
BRIGHTNESS, BRIGHTNESS,
CPUFRETQ_POWERSAVE, CPUFRETQ_POWERSAVE,
@ -49,7 +50,7 @@ enum action{
CPUFRETQ_PERFORMANCE CPUFRETQ_PERFORMANCE
}; };
/*! /*!
* \class KDE_Settings * \class KDE_Settings
* \brief class/object for the KDE default settings * \brief class/object for the KDE default settings
* \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de> * \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
@ -68,23 +69,23 @@ public:
bool displayEnergySaving; bool displayEnergySaving;
//! time for DPMS standby //! time for DPMS standby
/*! /*!
* This integer represent the time in minutes after which the * This integer represent the time in minutes after which the
* display should do to stand-by. * display should do to stand-by.
*/ */
int displayStandby; int displayStandby;
//! time for DPMS suspend //! time for DPMS suspend
/*! /*!
* This integer represent the time in minutes after which the * This integer represent the time in minutes after which the
* display should suspend. * display should suspend.
*/ */
int displaySuspend; int displaySuspend;
//! time for DPMS power-off //! time for DPMS power-off
/*! /*!
* This integer represent the time in minutes after which the * This integer represent the time in minutes after which the
* display should power off. * display should power off.
*/ */
int displayPowerOff; int displayPowerOff;
/* KDE settings [ScreenSaver] */ /* KDE settings [ScreenSaver] */
//! if the KDE screensaver is enabled //! if the KDE screensaver is enabled
/*! /*!
@ -108,10 +109,10 @@ public:
* \li false: if else * \li false: if else
*/ */
bool blanked; bool blanked;
}; };
/*! /*!
* \class Settings * \class Settings
* \brief class for the Settings ( read ) related funtionality * \brief class for the Settings ( read ) related funtionality
* \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de> * \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
@ -125,10 +126,10 @@ public:
Settings(); Settings();
//! default destructor //! default destructor
virtual ~Settings(); virtual ~Settings();
//! a instance of the KDE global settings. //! a instance of the KDE global settings.
KDE_Settings *kde; KDE_Settings *kde;
/* START ************************** General settings *******************************/ /* START ************************** General settings *******************************/
//! name of the default "onAC" scheme //! name of the default "onAC" scheme
TQString ac_scheme; TQString ac_scheme;
@ -136,7 +137,7 @@ public:
TQString battery_scheme; TQString battery_scheme;
//! a list with the names of the currently available schemes. //! a list with the names of the currently available schemes.
/*! /*!
* List with the names of the currently configured schemes. The name of the * List with the names of the currently configured schemes. The name of the
* schemes are the same as we use for the related selection in the configure file. * schemes are the same as we use for the related selection in the configure file.
* Note: Be sure that the name for the default schemes is not translated !!! * Note: Be sure that the name for the default schemes is not translated !!!
*/ */
@ -155,16 +156,16 @@ public:
//! if the messages from powersave should popup as Kpassivepopup //! if the messages from powersave should popup as Kpassivepopup
/*! /*!
* This boolean tells if the messages from powersave should be displayed * This boolean tells if the messages from powersave should be displayed
* as KPassivePopup or as KMessageBox::error * as KPassivePopup or as KMessageBox::error
* \li true: if use KPassivePopup * \li true: if use KPassivePopup
* \li false: if not * \li false: if not
*/ */
bool psMsgAsPassivePopup; bool psMsgAsPassivePopup;
//! if the screen should be locked on suspend //! if the screen should be locked on suspend
/*! /*!
* This boolean tells if the screen should be locked befor a suspend or standby. * This boolean tells if the screen should be locked befor a suspend or standby.
* \li true: if the screen should be locked * \li true: if the screen should be locked
* \li false: if not lock the screen * \li false: if not lock the screen
*/ */
bool lockOnSuspend; bool lockOnSuspend;
@ -178,7 +179,7 @@ public:
//! if tdepowersave starts on login //! if tdepowersave starts on login
/*! /*!
* This boolean tells if tdepowersave should be start automatically on userlogin. * This boolean tells if tdepowersave should be start automatically on userlogin.
* The value could be changed trough the configuration dialog and if the user * The value could be changed trough the configuration dialog and if the user
* stop tdepowersave. * stop tdepowersave.
* \li true: if autostart * \li true: if autostart
* \li false: if not start on login * \li false: if not start on login
@ -188,12 +189,12 @@ public:
/*! /*!
* This boolean tells if tdepowersave ask for autostart settings if user stop tdepowersave. * This boolean tells if tdepowersave ask for autostart settings if user stop tdepowersave.
* \li true: if ask on stop * \li true: if ask on stop
* \li false: if never ask * \li false: if never ask
*/ */
bool autostartNeverAsk; bool autostartNeverAsk;
//! if tdepowersave should force DPMS shutdown for display for lidclose //! if tdepowersave should force DPMS shutdown for display for lidclose
/*! /*!
* This boolean tells if tdepowersave should force dpms shutdown for the display if a * This boolean tells if tdepowersave should force dpms shutdown for the display if a
* lidclose event was recieved * lidclose event was recieved
* \li true: if shutdown display * \li true: if shutdown display
* \li false: if not * \li false: if not
@ -214,23 +215,23 @@ public:
* to show the login dialog if the desktop was locked on suspend. Value is in msec. * to show the login dialog if the desktop was locked on suspend. Value is in msec.
*/ */
int timeToFakeKeyAfterLock; int timeToFakeKeyAfterLock;
//! percentag value of battery level for warning state //! percentag value of battery level for warning state
/*! /*!
* This integer represent the remaining percentag of the battery * This integer represent the remaining percentag of the battery
* where we reach the battery warning level. This is a value between 0 and 100. * where we reach the battery warning level. This is a value between 0 and 100.
*/ */
int batteryWarningLevel; int batteryWarningLevel;
//! percentag value of battery level for low state //! percentag value of battery level for low state
/*! /*!
* This integer represent the remaining percentag of the battery * This integer represent the remaining percentag of the battery
* where we reach the battery low level. This is a value between 0 and 100 and * where we reach the battery low level. This is a value between 0 and 100 and
* should be lower than \ref batteryWarningLevel and higher than \ref batteryCriticalLevel * should be lower than \ref batteryWarningLevel and higher than \ref batteryCriticalLevel
*/ */
int batteryLowLevel; int batteryLowLevel;
//! percentag value of battery level for critical state //! percentag value of battery level for critical state
/*! /*!
* This integer represent the remaining percentag of the battery * This integer represent the remaining percentag of the battery
* where we reach the battery critical level. This is a value between 0 and 100 and * where we reach the battery critical level. This is a value between 0 and 100 and
* should be lower than \ref batteryLowLevel and higher than 0 * should be lower than \ref batteryLowLevel and higher than 0
*/ */
@ -268,7 +269,7 @@ public:
//! name of the scheme representing the current settings //! name of the scheme representing the current settings
TQString currentScheme; TQString currentScheme;
// ---------- Screensaver/DPMS section ------------ // // ---------- Screensaver/DPMS section ------------ //
//! if tdepowersave use own screensaver settings //! if tdepowersave use own screensaver settings
/*! /*!
@ -296,7 +297,7 @@ public:
//! if tdepowersave use own DPMS settings //! if tdepowersave use own DPMS settings
/*! /*!
* This boolean tells if tdepowersave should use own userspecific settings for * This boolean tells if tdepowersave should use own userspecific settings for
* Display PowerManagement Settings. If this value is true tdepowersave overwritte * Display PowerManagement Settings. If this value is true tdepowersave overwritte
* the KDE or GNOME global settings. * the KDE or GNOME global settings.
* \li true: if tdepowersave use own DPMS settings * \li true: if tdepowersave use own DPMS settings
* \li false: if tdepowersave don't change DPMS settings * \li false: if tdepowersave don't change DPMS settings
@ -312,19 +313,19 @@ public:
bool disableDPMS; bool disableDPMS;
//! time for DPMS standby //! time for DPMS standby
/*! /*!
* This integer represent the time in minutes after which the * This integer represent the time in minutes after which the
* display should do to stand-by. * display should do to stand-by.
*/ */
int standbyAfter; int standbyAfter;
//! time for DPMS suspend //! time for DPMS suspend
/*! /*!
* This integer represent the time in minutes after which the * This integer represent the time in minutes after which the
* display should suspend. * display should suspend.
*/ */
int suspendAfter; int suspendAfter;
//! time for DPMS power-off //! time for DPMS power-off
/*! /*!
* This integer represent the time in minutes after which the * This integer represent the time in minutes after which the
* display should power off. * display should power off.
*/ */
int powerOffAfter; int powerOffAfter;
@ -332,7 +333,7 @@ public:
// ------------ Brightness section ---------------- // // ------------ Brightness section ---------------- //
//! if brightness is enabled for the current scheme //! if brightness is enabled for the current scheme
/*! /*!
* This boolean tells if brightness is enabled for the * This boolean tells if brightness is enabled for the
* current scheme * current scheme
* \li true: if brightness is enabled * \li true: if brightness is enabled
* \li false: if not * \li false: if not
@ -340,15 +341,15 @@ public:
bool brightness; bool brightness;
//! the value for the brighness //! the value for the brighness
/*! /*!
* This integer represent the value to which the brigthness * This integer represent the value to which the brigthness
* should be set. This value is in percentage. * should be set. This value is in percentage.
*/ */
int brightnessValue; int brightnessValue;
// ------------ Autosuspend section ---------------- // // ------------ Autosuspend section ---------------- //
//! if autosuspend is enabled for the current scheme //! if autosuspend is enabled for the current scheme
/*! /*!
* This boolean tells if autosuspend is enabled for the * This boolean tells if autosuspend is enabled for the
* current scheme * current scheme
* \li true: if autosuspend is enabled * \li true: if autosuspend is enabled
* \li false: if not * \li false: if not
@ -357,7 +358,7 @@ public:
//! if scheme specific blacklist is enabled //! if scheme specific blacklist is enabled
/*! /*!
* This boolean tells if a scheme specific blacklist * This boolean tells if a scheme specific blacklist
* ( autoInactiveSchemeBlacklist ) should be used. * ( autoInactiveSchemeBlacklist ) should be used.
* \li true: if use scheme specific blacklist * \li true: if use scheme specific blacklist
* \li false: if not * \li false: if not
*/ */
@ -369,7 +370,7 @@ public:
* action. * action.
*/ */
int autoInactiveActionAfter; int autoInactiveActionAfter;
//! action which execute after a defined time of inactivity //! action which execute after a defined time of inactivity
/*! /*!
* This TQString contains the action/command which should be execute * This TQString contains the action/command which should be execute
* after a trough \ref autoInactiveActionAfter defined time. If nothing * after a trough \ref autoInactiveActionAfter defined time. If nothing
@ -379,14 +380,14 @@ public:
//! general list with running programs which prevent the autosuspend //! general list with running programs which prevent the autosuspend
/*! /*!
* This TQStringList contains names of programs which prevent, if one of * This TQStringList contains names of programs which prevent, if one of
* them is running/active the autossuspend. * them is running/active the autossuspend.
*/ */
TQStringList autoInactiveGBlist; TQStringList autoInactiveGBlist;
//! scheme list with running programs which prevent the autosuspend //! scheme list with running programs which prevent the autosuspend
/*! /*!
* This TQStringList contains names of programs which prevent, if one of * This TQStringList contains names of programs which prevent, if one of
* them is running/active the autossuspend. * them is running/active the autossuspend.
*/ */
TQStringList autoInactiveSBlist; TQStringList autoInactiveSBlist;
// ------ Autosuspend countdown dialog section -------- // // ------ Autosuspend countdown dialog section -------- //
@ -401,12 +402,12 @@ public:
//! how long the autosuspend warn dialog should be shown //! how long the autosuspend warn dialog should be shown
/*! /*!
* This integer represent the time in seconds how long the autosuspend * This integer represent the time in seconds how long the autosuspend
* warning dialog should be shown. This time get stripped from * warning dialog should be shown. This time get stripped from
* \ref autoInactiveActionAfter to be sure the suspend get called within * \ref autoInactiveActionAfter to be sure the suspend get called within
* the expected time. * the expected time.
*/ */
int autoSuspendCountdownTimeout; int autoSuspendCountdownTimeout;
// -------------- Autodimm section ------------------- // // -------------- Autodimm section ------------------- //
//! if autodimm is enabled for the current scheme //! if autodimm is enabled for the current scheme
/*! /*!
@ -418,7 +419,7 @@ public:
//! if a scheme specific autodimm blacklist is enabled //! if a scheme specific autodimm blacklist is enabled
/*! /*!
* This boolean tells if a scheme specific autdimm blacklist * This boolean tells if a scheme specific autdimm blacklist
* ( autoDimmSBlist ) should be used. * ( autoDimmSBlist ) should be used.
* \li true: if use scheme specific blacklist * \li true: if use scheme specific blacklist
* \li false: if not * \li false: if not
*/ */
@ -431,7 +432,7 @@ public:
int autoDimmAfter; int autoDimmAfter;
//! percentage to which the display should dimmed to //! percentage to which the display should dimmed to
/*! /*!
* This integer represent the brightness percentage to which the * This integer represent the brightness percentage to which the
* display should get dimmed if the user is the via \ref autoDimmAfter * display should get dimmed if the user is the via \ref autoDimmAfter
* defined time inactivit; * defined time inactivit;
*/ */
@ -439,17 +440,17 @@ public:
//! general list with running programs which prevent the autodimm //! general list with running programs which prevent the autodimm
/*! /*!
* This TQStringList contains names of programs which prevent, if one of * This TQStringList contains names of programs which prevent, if one of
* them is running/active the autodimm of the display panel. * them is running/active the autodimm of the display panel.
*/ */
TQStringList autoDimmGBlist; TQStringList autoDimmGBlist;
//! scheme specific list with running programs which prevent the autodimm //! scheme specific list with running programs which prevent the autodimm
/*! /*!
* This TQStringList contains names of programs which prevent, if one of * This TQStringList contains names of programs which prevent, if one of
* them is running/active the autodimm of the display panel. This list is * them is running/active the autodimm of the display panel. This list is
* scheme specific. * scheme specific.
*/ */
TQStringList autoDimmSBlist; TQStringList autoDimmSBlist;
// ------------ CPU Frequency section ---------------- // // ------------ CPU Frequency section ---------------- //
//! represent the CPU Frequency policy to set //! represent the CPU Frequency policy to set
@ -476,17 +477,17 @@ public:
bool unmountExternalOnSuspend; bool unmountExternalOnSuspend;
/* END ************************ Scheme settings and values ******************************/ /* END ************************ Scheme settings and values ******************************/
/******************* Functions ********************/ /******************* Functions ********************/
//! to load the general settings //! to load the general settings
bool load_general_settings(); bool load_general_settings();
//! to load the global KDE settings //! to load the global KDE settings
void load_kde(); void load_kde();
//! to load settings of a specific scheme //! to load settings of a specific scheme
bool load_scheme_settings(TQString); bool load_scheme_settings(TQString);
private: private:
//! configuration of tdepowersave //! configuration of tdepowersave
TDEConfig *tdeconfig; TDEConfig *tdeconfig;

@ -17,13 +17,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/ ***************************************************************************/
/*! /*!
* \file suspenddialog.cpp * \file suspenddialog.cpp
* \brief In this file can be found the suspend dialog related code. * \brief In this file can be found the suspend dialog related code.
* \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de> * \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
* \date 2005 * \date 2005
*/ */
// KDE - Headers // KDE - Headers
#include <tdelocale.h> #include <tdelocale.h>
#include <kiconloader.h> #include <kiconloader.h>
@ -45,12 +45,12 @@ suspendDialog::suspendDialog(TQWidget *parent, const char *name)
} }
/*! This is the default destructor of the class. */ /*! This is the default destructor of the class. */
suspendDialog::~suspendDialog() suspendDialog::~suspendDialog()
{ {
} }
/*! /*!
* This used to set Icon/pixmap for the dialog. * This used to set Icon/pixmap for the dialog.
* \param type TQString with the type of the current suspend * \param type TQString with the type of the current suspend
* to set the pixmap in the dialog * to set the pixmap in the dialog
@ -62,6 +62,8 @@ void suspendDialog::setPixmap( TQString type )
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge); pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_disk", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else if (type.startsWith("suspend2ram")) { } else if (type.startsWith("suspend2ram")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("suspend_to_ram", TDEIcon::NoGroup, TDEIcon::SizeLarge); 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")) { } else if (type.startsWith("standby")) {
pixmap = TDEGlobal::iconLoader()->loadIcon("stand_by", TDEIcon::NoGroup, TDEIcon::SizeLarge); pixmap = TDEGlobal::iconLoader()->loadIcon("stand_by", TDEIcon::NoGroup, TDEIcon::SizeLarge);
} else { } else {
@ -71,7 +73,7 @@ void suspendDialog::setPixmap( TQString type )
iconPixmap->setPixmap( pixmap ); iconPixmap->setPixmap( pixmap );
} }
/*! /*!
* This used to set the values of progressbar for the dialog. * This used to set the values of progressbar for the dialog.
* \param percent integer value with current progress stauts of suspend * \param percent integer value with current progress stauts of suspend
*/ */
@ -81,11 +83,11 @@ void suspendDialog::setProgressbar( int percent )
progressBar->setProgress(percent); progressBar->setProgress(percent);
} }
/*! /*!
* This used to set the message of current suspend action to the the dialog. * This used to set the message of current suspend action to the the dialog.
* \param messageText TQString with the message of the current running suspend * \param messageText TQString with the message of the current running suspend
* prepare action * prepare action
*/ */
void suspendDialog::setTextLabel( TQString messageText ) void suspendDialog::setTextLabel( TQString messageText )
{ {
message->show(); message->show();

@ -194,6 +194,8 @@ void tdepowersave::initMenu() {
TQIconSet::Automatic), TQIconSet::Automatic),
i18n("Suspend to RAM"), this, i18n("Suspend to RAM"), this,
TQT_SLOT(do_suspend2ram())); 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), STANDBY_MENU_ID = this->contextMenu()->insertItem( SmallIconSet("stand_by", TQIconSet::Automatic),
i18n("Standby"), this, TQT_SLOT(do_standby())); 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. * 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 * \return boolean with the result of the operation
* \retval true if successful * \retval true if successful
* \retval false if command not supported or if powersaved not running * \retval false if command not supported or if powersaved not running
@ -734,16 +736,16 @@ bool tdepowersave::do_suspend2disk(){
return false; return false;
} }
} else { } else {
kdWarning() << "This machine does not provide suspend2disk via HAL" << endl; kdWarning() << "This machine does not provide suspend to disk state" << endl;
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return false; 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. * 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 * \return boolean with the result of the operation
* \retval true if successful * \retval true if successful
* \retval false if command not supported or if powersaved not running * \retval false if command not supported or if powersaved not running
@ -790,16 +792,71 @@ bool tdepowersave::do_suspend2ram(){
return false; return false;
} }
} else { } else {
kdWarning() << "This machine does not provide suspend2ram via HAL" << endl; kdWarning() << "This machine does not provide suspend to ram state" << endl;
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return false; 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. * 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 * \return boolean with the result of the operation
* \retval true if successful * \retval true if successful
* \retval false if command not supported or if powersaved not running * \retval false if command not supported or if powersaved not running
@ -845,7 +902,7 @@ bool tdepowersave::do_standby(){
return false; return false;
} }
} else { } else {
kdWarning() << "This machine does not provide suspend2ram via HAL" << endl; kdWarning() << "This machine does not provide standby suspend state" << endl;
kdDebugFuncOut(trace); kdDebugFuncOut(trace);
return false; return false;
} }
@ -872,6 +929,11 @@ void tdepowersave::do_autosuspendWarn() {
allowed = true; allowed = true;
} }
} }
else if (settings->autoInactiveAction == "Freeze") {
if ( suspend.freeze && (suspend.freeze_allowed || suspend.freeze_allowed == -1)) {
allowed = true;
}
}
else if (settings->autoInactiveAction == "Standby") { else if (settings->autoInactiveAction == "Standby") {
if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) { if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
allowed = true; allowed = true;
@ -890,6 +952,8 @@ void tdepowersave::do_autosuspendWarn() {
countdown->setPixmap("suspend2disk"); countdown->setPixmap("suspend2disk");
} else if (settings->autoInactiveAction == "Suspend to RAM") { } else if (settings->autoInactiveAction == "Suspend to RAM") {
countdown->setPixmap("suspend2ram"); countdown->setPixmap("suspend2ram");
} else if (settings->autoInactiveAction == "Freeze") {
countdown->setPixmap("suspend2ram");
} else if (settings->autoInactiveAction == "Standby") { } else if (settings->autoInactiveAction == "Standby") {
countdown->setPixmap("standby"); countdown->setPixmap("standby");
} else { } else {
@ -943,6 +1007,8 @@ bool tdepowersave::do_autosuspend(bool chancel) {
return do_suspend2disk(); return do_suspend2disk();
} else if (settings->autoInactiveAction == "Suspend to RAM") { } else if (settings->autoInactiveAction == "Suspend to RAM") {
return do_suspend2ram(); return do_suspend2ram();
} else if (settings->autoInactiveAction == "Freeze") {
return do_freeze();
} else if (settings->autoInactiveAction == "Standby") { } else if (settings->autoInactiveAction == "Standby") {
return do_standby(); return do_standby();
} else { } else {
@ -1389,6 +1455,7 @@ void tdepowersave::update(){
if (!hwinfo->isOnline()){ if (!hwinfo->isOnline()){
this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, false); this->contextMenu()->setItemVisible(SUSPEND2DISK_MENU_ID, false);
this->contextMenu()->setItemVisible(SUSPEND2RAM_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(STANDBY_MENU_ID, false);
this->contextMenu()->setItemVisible(SLEEP_SEPARATOR_MENU_ID, false); this->contextMenu()->setItemVisible(SLEEP_SEPARATOR_MENU_ID, false);
this->contextMenu()->setItemVisible(SCHEME_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(SUSPEND2DISK_MENU_ID, true);
this->contextMenu()->setItemVisible(SUSPEND2RAM_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(STANDBY_MENU_ID, true);
this->contextMenu()->setItemVisible(SLEEP_SEPARATOR_MENU_ID, true); this->contextMenu()->setItemVisible(SLEEP_SEPARATOR_MENU_ID, true);
this->contextMenu()->setItemVisible(SCHEME_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); 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)) { if (suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
this->contextMenu()->setItemEnabled(STANDBY_MENU_ID, true); this->contextMenu()->setItemEnabled(STANDBY_MENU_ID, true);
} else { } else {
@ -1840,6 +1917,11 @@ void tdepowersave::setAutoSuspend( bool resumed ){
allowed = true; allowed = true;
} }
} }
else if (settings->autoInactiveAction == "Freeze") {
if ( suspend.freeze && (suspend.freeze_allowed || suspend.freeze_allowed == -1)) {
allowed = true;
}
}
else if (settings->autoInactiveAction == "Standby") { else if (settings->autoInactiveAction == "Standby") {
if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) { if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)) {
allowed = true; allowed = true;
@ -2071,6 +2153,9 @@ void tdepowersave::handleActionCall ( action action, int value , bool checkAC, b
case GO_SUSPEND2DISK: case GO_SUSPEND2DISK:
TQTimer::singleShot(100, this, TQT_SLOT(do_suspend2disk())); TQTimer::singleShot(100, this, TQT_SLOT(do_suspend2disk()));
break; break;
case GO_FREEZE:
TQTimer::singleShot(100, this, TQT_SLOT(do_freeze()));
break;
case BRIGHTNESS: case BRIGHTNESS:
hwinfo->setBrightness( -1, value ); hwinfo->setBrightness( -1, value );
break; break;
@ -2192,6 +2277,11 @@ void tdepowersave::notifySuspend( int suspendType ) {
i18n("System is going into %1 now."). i18n("System is going into %1 now.").
arg(i18n("Suspend to RAM"))); arg(i18n("Suspend to RAM")));
break; break;
case FREEZE:
KNotifyClient::event( this->winId(), "freeze_event",
i18n("System is going into %1 now.").
arg(i18n("Freeze")));
break;
case STANDBY: case STANDBY:
KNotifyClient::event( this->winId(), "standby_event", KNotifyClient::event( this->winId(), "standby_event",
i18n("System is going into %1 now."). i18n("System is going into %1 now.").
@ -2252,6 +2342,11 @@ void tdepowersave::handleResumeSignal() {
i18n("System is resumed from %1.").arg( i18n("System is resumed from %1.").arg(
i18n("Suspend to RAM"))); i18n("Suspend to RAM")));
break; break;
case FREEZE:
KNotifyClient::event( this->winId(), "resume_from_freeze_event",
i18n("System is resumed from %1.").arg(
i18n("Freeze")));
break;
case STANDBY: case STANDBY:
KNotifyClient::event( this->winId(), "resume_from_standby_event", KNotifyClient::event( this->winId(), "resume_from_standby_event",
i18n("System is resumed from %1.").arg( i18n("System is resumed from %1.").arg(
@ -2301,6 +2396,10 @@ void tdepowersave::handleResumeSignal() {
logview = new LogViewer ("/var/log/suspend2ram.log"); logview = new LogViewer ("/var/log/suspend2ram.log");
logview->show(); logview->show();
break; break;
case FREEZE:
logview = new LogViewer ("/var/log/freeze.log");
logview->show();
break;
case STANDBY: case STANDBY:
logview = new LogViewer ("/var/log/standby.log"); logview = new LogViewer ("/var/log/standby.log");
logview->show(); logview->show();
@ -2368,6 +2467,9 @@ TQString tdepowersave::getSuspendString (int type) {
case SUSPEND2RAM: case SUSPEND2RAM:
return i18n("Suspend to RAM"); return i18n("Suspend to RAM");
break; break;
case FREEZE:
return i18n("Freeze");
break;
case STANDBY: case STANDBY:
return i18n("Standby"); return i18n("Standby");
break; break;
@ -2517,6 +2619,9 @@ TQStringList tdepowersave::allowed_sleepingStates(){
suspend.suspend2ram_allowed == -1)){ suspend.suspend2ram_allowed == -1)){
sleepList.append("suspendToRAM"); 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)){ if (suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1)){
sleepList.append("standBy"); 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() * \return boolean with the result of calling do_standby()
* \retval true if successful * \retval true if successful
* \retval false if not supported or powersaved not running * \retval false if not supported or powersaved not running

@ -69,7 +69,7 @@ class TDEGlobalAccel;
class tdepowersave : public KSystemTray, public DCOPObject class tdepowersave : public KSystemTray, public DCOPObject
{ {
Q_OBJECT Q_OBJECT
// //
K_DCOP K_DCOP
private: private:
@ -190,6 +190,9 @@ private:
/*! contains the ID of the menuentry for suspend-to-ram */ /*! contains the ID of the menuentry for suspend-to-ram */
int SUSPEND2RAM_MENU_ID; int SUSPEND2RAM_MENU_ID;
//! a menu entry 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 */ /*! contains the ID of the menuentry for stand-by */
int STANDBY_MENU_ID; int STANDBY_MENU_ID;
//! a menu seperator ID //! a menu seperator ID
@ -312,6 +315,8 @@ private slots:
//! send command for stand-by to the TDE hardware library //! send command for stand-by to the TDE hardware library
bool do_standby(); 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 //! send command for suspend_to_disk to the TDE hardware library
bool do_suspend2disk(); bool do_suspend2disk();
//! send command for suspend_to_RAM to the TDE hardware library //! send command for suspend_to_RAM to the TDE hardware library
@ -428,6 +433,8 @@ k_dcop:
bool do_suspendToDisk(); bool do_suspendToDisk();
//! dcop function to send 'suspend to RAM' command to powersaved //! dcop function to send 'suspend to RAM' command to powersaved
bool do_suspendToRAM(); bool do_suspendToRAM();
//! dcop function to send 'freeze' command to powersaved
bool do_suspendFreeze();
//! dcop function to send 'standby' command to powersaved //! dcop function to send 'standby' command to powersaved
bool do_standBy(); bool do_standBy();
//! dcop function to set the brightness down //! dcop function to set the brightness down

Loading…
Cancel
Save