summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2013-04-25 16:08:46 +0000
committerTimothy Pearson <[email protected]>2013-04-25 16:08:46 +0000
commit55a0cc423fbf014b8f016d4b0128ce2924bba6ce (patch)
tree9cd21a9be467d25b01cbb80d26cb8d478d84164b
parent704eedf364cefe87cf5c63cb61a3c6051a37a585 (diff)
downloadtdebase-55a0cc423fbf014b8f016d4b0128ce2924bba6ce.tar.gz
tdebase-55a0cc423fbf014b8f016d4b0128ce2924bba6ce.zip
Use TDE hardware library to authorize and control shutdown related session options
This resolves Bug 1071
-rw-r--r--ksmserver/server.cpp24
-rw-r--r--ksmserver/server.h8
-rw-r--r--ksmserver/shutdown.cpp106
-rw-r--r--ksmserver/shutdowndlg.cpp245
-rw-r--r--ksmserver/shutdowndlg.h4
5 files changed, 199 insertions, 188 deletions
diff --git a/ksmserver/server.cpp b/ksmserver/server.cpp
index 780213897..1c9c18cec 100644
--- a/ksmserver/server.cpp
+++ b/ksmserver/server.cpp
@@ -579,7 +579,7 @@ extern "C" int _IceTransNoListen(const char * protocol);
#endif
KSMServer::KSMServer( const TQString& windowManager, const TQString& windowManagerAddArgs, bool _only_local )
- : DCOPObject("ksmserver"), sessionGroup( "" ), startupNotifierIPDlg(0), shutdownNotifierIPDlg(0)
+ : DCOPObject("ksmserver"), startupNotifierIPDlg(0), shutdownNotifierIPDlg(0), sessionGroup( "" )
{
the_server = this;
clean = false;
@@ -596,7 +596,9 @@ KSMServer::KSMServer( const TQString& windowManager, const TQString& windowManag
config->setGroup("General" );
clientInteracting = 0;
xonCommand = config->readEntry( "xonCommand", "xon" );
-
+
+ hwDevices = TDEGlobal::hardwareDevices();
+
connect( &knotifyTimeoutTimer, TQT_SIGNAL( timeout()), TQT_SLOT( knotifyTimeout()));
connect( &startupSuspendTimeoutTimer, TQT_SIGNAL( timeout()), TQT_SLOT( startupSuspendTimeout()));
connect( &pendingShutdown, TQT_SIGNAL( timeout()), TQT_SLOT( pendingShutdownTimeout()));
@@ -700,8 +702,9 @@ void KSMServer::cleanUp()
// strip the screen number from the display
display.replace(TQRegExp("\\.[0-9]+$"), "");
int i;
- while( (i = display.find(':')) >= 0)
+ while( (i = display.find(':')) >= 0) {
display[i] = '_';
+ }
fName += "_"+display;
::unlink(fName.data());
@@ -710,7 +713,20 @@ void KSMServer::cleanUp()
signal(SIGTERM, SIG_DFL);
signal(SIGINT, SIG_DFL);
- DM().shutdown( shutdownType, shutdownMode, bootOption );
+ if (DM().canShutdown()) {
+ DM().shutdown( shutdownType, shutdownMode, bootOption );
+ }
+ else {
+ TDERootSystemDevice* rootDevice = hwDevices->rootSystemDevice();
+ if (rootDevice) {
+ if (shutdownType == TDEApplication::ShutdownTypeHalt) {
+ rootDevice->setPowerState(TDESystemPowerState::PowerOff);
+ }
+ if (shutdownType == TDEApplication::ShutdownTypeReboot) {
+ rootDevice->setPowerState(TDESystemPowerState::Reboot);
+ }
+ }
+ }
}
diff --git a/ksmserver/server.h b/ksmserver/server.h
index a59e708c6..d3c7099f9 100644
--- a/ksmserver/server.h
+++ b/ksmserver/server.h
@@ -23,6 +23,8 @@ Copyright (C) 2000 Matthias Ettrich <[email protected]>
#include <tqtimer.h>
#include <dcopobject.h>
+#include <tdehardwaredevices.h>
+
#include "server2.h"
#include "KSMServerInterface.h"
@@ -93,7 +95,7 @@ public:
virtual void suspendStartup( TQCString app );
virtual void resumeStartup( TQCString app );
- bool checkStatus( bool &logoutConfirmed, bool &maysd,
+ bool checkStatus( bool &logoutConfirmed, bool &maysd, bool &mayrb,
TDEApplication::ShutdownConfirm confirm,
TDEApplication::ShutdownType sdtype,
TDEApplication::ShutdownMode sdmode );
@@ -230,10 +232,12 @@ private:
int appsToStart;
int lastAppStarted;
TQString lastIdStarted;
-
+
TQStringList excludeApps;
WindowMap legacyWindows;
+
+ TDEHardwareDevices* hwDevices;
};
#endif
diff --git a/ksmserver/shutdown.cpp b/ksmserver/shutdown.cpp
index 05bfd0af2..a13e7e3b1 100644
--- a/ksmserver/shutdown.cpp
+++ b/ksmserver/shutdown.cpp
@@ -83,13 +83,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <libtdersync/tdersync.h>
-#ifdef WITH_UPOWER
- #include <tqdbusdata.h>
- #include <tqdbusmessage.h>
- #include <tqdbusproxy.h>
- #include <tqdbusvariant.h>
-#endif
-
#include "server.h"
#include "global.h"
#include "shutdowndlg.h"
@@ -110,21 +103,21 @@ void KSMServer::logout( int confirm, int sdtype, int sdmode )
(TDEApplication::ShutdownMode)sdmode );
}
-bool KSMServer::checkStatus( bool &logoutConfirmed, bool &maysd,
+bool KSMServer::checkStatus( bool &logoutConfirmed, bool &maysd, bool &mayrb,
TDEApplication::ShutdownConfirm confirm,
TDEApplication::ShutdownType sdtype,
TDEApplication::ShutdownMode sdmode )
{
pendingShutdown.stop();
- if( dialogActive )
+ if( dialogActive ) {
return false;
- if( state >= Shutdown ) // already performing shutdown
+ }
+ if( state >= Shutdown ) { // already performing shutdown
return false;
- if( state != Idle ) // performing startup
- {
+ }
+ if( state != Idle ) { // performing startup
// perform shutdown as soon as startup is finished, in order to avoid saving partial session
- if( !pendingShutdown.isActive())
- {
+ if( !pendingShutdown.isActive()) {
pendingShutdown.start( 1000 );
pendingShutdown_confirm = confirm;
pendingShutdown_sdtype = sdtype;
@@ -142,11 +135,35 @@ bool KSMServer::checkStatus( bool &logoutConfirmed, bool &maysd,
(confirm == TDEApplication::ShutdownConfirmNo) ? true :
!config->readBoolEntry( "confirmLogout", true );
maysd = false;
- if (config->readBoolEntry( "offerShutdown", true ) && DM().canShutdown())
- maysd = true;
+ mayrb = false;
+ if (config->readBoolEntry( "offerShutdown", true )) {
+ if (DM().canShutdown()) {
+ maysd = true;
+ mayrb = true;
+ }
+ else {
+ TDERootSystemDevice* rootDevice = hwDevices->rootSystemDevice();
+ if (rootDevice) {
+ if (rootDevice->canPowerOff()) {
+ maysd = true;
+ }
+ if (rootDevice->canReboot()) {
+ mayrb = true;
+ }
+ }
+ }
+ }
if (!maysd) {
if (sdtype != TDEApplication::ShutdownTypeNone &&
sdtype != TDEApplication::ShutdownTypeDefault &&
+ sdtype != TDEApplication::ShutdownTypeReboot &&
+ logoutConfirmed)
+ return false; /* unsupported fast shutdown */
+ }
+ if (!mayrb) {
+ if (sdtype != TDEApplication::ShutdownTypeNone &&
+ sdtype != TDEApplication::ShutdownTypeDefault &&
+ sdtype != TDEApplication::ShutdownTypeHalt &&
logoutConfirmed)
return false; /* unsupported fast shutdown */
}
@@ -160,20 +177,27 @@ void KSMServer::shutdownInternal( TDEApplication::ShutdownConfirm confirm,
TQString bopt )
{
bool maysd = false;
+ bool mayrb = false;
bool logoutConfirmed = false;
- if ( !checkStatus( logoutConfirmed, maysd, confirm, sdtype, sdmode ) )
+ if ( !checkStatus( logoutConfirmed, maysd, mayrb, confirm, sdtype, sdmode ) ) {
return;
+ }
TDEConfig *config = TDEGlobal::config();
config->setGroup("General" );
- if (!maysd) {
+ if ((!maysd) && (sdtype != TDEApplication::ShutdownTypeReboot)) {
+ sdtype = TDEApplication::ShutdownTypeNone;
+ }
+ if ((!mayrb) && (sdtype != TDEApplication::ShutdownTypeHalt)) {
sdtype = TDEApplication::ShutdownTypeNone;
- } else if (sdtype == TDEApplication::ShutdownTypeDefault)
- sdtype = (TDEApplication::ShutdownType)
- config->readNumEntry( "shutdownType", (int)TDEApplication::ShutdownTypeNone );
- if (sdmode == TDEApplication::ShutdownModeDefault)
+ }
+ if (sdtype == TDEApplication::ShutdownTypeDefault) {
+ sdtype = (TDEApplication::ShutdownType) config->readNumEntry( "shutdownType", (int)TDEApplication::ShutdownTypeNone );
+ }
+ if (sdmode == TDEApplication::ShutdownModeDefault) {
sdmode = TDEApplication::ShutdownModeInteractive;
+ }
// shall we show a logout status dialog box?
bool showLogoutStatusDlg = TDEConfigGroup(TDEGlobal::config(), "Logout").readBoolEntry("showLogoutStatusDlg", true);
@@ -187,7 +211,7 @@ void KSMServer::shutdownInternal( TDEApplication::ShutdownConfirm confirm,
int selection;
KSMShutdownFeedback::start(); // make the screen gray
logoutConfirmed =
- KSMShutdownDlg::confirmShutdown( maysd, sdtype, bopt, &selection );
+ KSMShutdownDlg::confirmShutdown( maysd, mayrb, sdtype, bopt, &selection );
// ###### We can't make the screen remain gray while talking to the apps,
// because this prevents interaction ("do you want to save", etc.)
// TODO: turn the feedback widget into a list of apps to be closed,
@@ -201,30 +225,15 @@ void KSMServer::shutdownInternal( TDEApplication::ShutdownConfirm confirm,
if (lockOnResume) {
DCOPRef("kdesktop", "KScreensaverIface").send("lock");
}
-#ifdef WITH_UPOWER
- TQT_DBusConnection dbusConn;
- dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
- if (selection == 1) { // Suspend
- if ( dbusConn.isConnected() ) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.UPower",
- "/org/freedesktop/UPower",
- "org.freedesktop.UPower",
- "Suspend");
- dbusConn.sendWithReply(msg);
+ TDERootSystemDevice* rootDevice = hwDevices->rootSystemDevice();
+ if (rootDevice) {
+ if (selection == 1) { // Suspend
+ rootDevice->setPowerState(TDESystemPowerState::Suspend);
}
- }
- if (selection == 2) { // Hibernate
- if( dbusConn.isConnected() ) {
- TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
- "org.freedesktop.UPower",
- "/org/freedesktop/UPower",
- "org.freedesktop.UPower",
- "Hibernate");
- dbusConn.sendWithReply(msg);
+ if (selection == 2) { // Hibernate
+ rootDevice->setPowerState(TDESystemPowerState::Hibernate);
}
}
-#endif // WITH_UPOWER
}
}
@@ -308,12 +317,15 @@ void KSMServer::logoutTimed( int sdtype, int sdmode, TQString bootOption )
TDEConfig* config = TDEGlobal::config();
config->setGroup( "General" );
- if ( sdtype == TDEApplication::ShutdownTypeHalt )
+ if ( sdtype == TDEApplication::ShutdownTypeHalt ) {
confirmDelay = config->readNumEntry( "confirmShutdownDelay", 31 );
- else if ( sdtype == TDEApplication::ShutdownTypeReboot )
+ }
+ else if ( sdtype == TDEApplication::ShutdownTypeReboot ) {
confirmDelay = config->readNumEntry( "confirmRebootDelay", 31 );
- else
+ }
+ else {
confirmDelay = config->readNumEntry( "confirmLogoutDelay", 31 );
+ }
bool result = true;
if (confirmDelay) {
diff --git a/ksmserver/shutdowndlg.cpp b/ksmserver/shutdowndlg.cpp
index 13a0bb5f7..ad2d9113f 100644
--- a/ksmserver/shutdowndlg.cpp
+++ b/ksmserver/shutdowndlg.cpp
@@ -8,13 +8,6 @@ Copyright (C) 2000 Matthias Ettrich <[email protected]>
#include "shutdowndlg.h"
-#ifdef WITH_UPOWER
- #include <tqdbusdata.h>
- #include <tqdbusmessage.h>
- #include <tqdbusproxy.h>
- #include <tqdbusvariant.h>
-#endif
-
#include <tqapplication.h>
#include <tqlayout.h>
#include <tqgroupbox.h>
@@ -40,6 +33,7 @@ Copyright (C) 2000 Matthias Ettrich <[email protected]>
#include <tdelocale.h>
#include <tdeconfig.h>
#include <tdeapplication.h>
+#include <tdehardwaredevices.h>
#include <kdebug.h>
#include <kpushbutton.h>
#include <kstdguiitem.h>
@@ -674,7 +668,7 @@ void KSMShutdownIPFeedback::slotPaintEffect()
//////
KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
- bool maysd, TDEApplication::ShutdownType sdtype, int* selection )
+ bool maysd, bool mayrb, TDEApplication::ShutdownType sdtype, int* selection )
: TQDialog( parent, 0, TRUE, (WFlags)WType_Popup ), targets(0), m_selection(selection)
// this is a WType_Popup on purpose. Do not change that! Not
// having a popup here has severe side effects.
@@ -770,13 +764,11 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
connect(btnLogout, TQT_SIGNAL(clicked()), TQT_SLOT(slotLogout()));
}
-#ifndef WITH_UPOWER
#ifdef COMPILE_HALBACKEND
m_halCtx = NULL;
#endif
-#endif // WITH_UPOWER
- if (maysd) {
+ if ((maysd) || (mayrb)) {
// respect lock on resume & disable suspend/hibernate settings
// from power-manager
@@ -788,27 +780,6 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
bool canSuspend = false;
bool canHibernate = false;
-#ifdef WITH_UPOWER
- m_dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
-
- TQT_DBusProxy upowerProperties("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", m_dbusConn);
-
- // can suspend?
- TQValueList<TQT_DBusData> params;
- params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanSuspend");
- TQT_DBusMessage reply = upowerProperties.sendWithReply("Get", params);
- if(reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
- canSuspend = reply[0].toVariant().value.toBool();
- }
-
- // can hibernate?
- params.clear();
- params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanHibernate");
- reply = upowerProperties.sendWithReply("Get", params);
- if(reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
- canHibernate = reply[0].toVariant().value.toBool();
- }
-#else
#ifdef COMPILE_HALBACKEND
// Query HAL for suspend/resume support
m_halCtx = libhal_ctx_new();
@@ -864,8 +835,17 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
canHibernate = true;
}
}
-#endif
-#endif // WITH_UPOWER
+#else // COMPILE_HALBACKEND
+ TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice();
+ if (rootDevice) {
+ canSuspend = rootDevice->canSuspend();
+ canHibernate = rootDevice->canHibernate();
+ }
+ else {
+ canSuspend = false;
+ canHibernate = false;
+ }
+#endif // COMPILE_HALBACKEND
if(doUbuntuLogout) {
@@ -900,51 +880,59 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
TQHBoxLayout* hbuttonbox2 = new TQHBoxLayout( vbox, factor * KDialog::spacingHint() );
hbuttonbox2->setAlignment( Qt::AlignHCenter );
- // Reboot
- FlatButton* btnReboot = new FlatButton( frame );
- btnReboot->setTextLabel( i18n("&Restart"), false );
- btnReboot->setPixmap( DesktopIcon( "reload") );
- int i = btnReboot->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
- btnReboot->setAccel( "ALT+" + btnReboot->textLabel().lower()[i+1] ) ;
- hbuttonbox2->addWidget ( btnReboot);
- connect(btnReboot, TQT_SIGNAL(clicked()), TQT_SLOT(slotReboot()));
- if ( sdtype == TDEApplication::ShutdownTypeReboot )
- btnReboot->setFocus();
-
- // BAD CARMA .. this code is copied line by line from standard konqy dialog
- int def, cur;
- if ( DM().bootOptions( rebootOptions, def, cur ) ) {
- btnReboot->setPopupDelay(300); // visually add dropdown
- targets = new TQPopupMenu( frame );
- if ( cur == -1 )
- cur = def;
-
- int index = 0;
- for (TQStringList::ConstIterator it = rebootOptions.begin(); it != rebootOptions.end(); ++it, ++index)
- {
- TQString label = (*it);
- label=label.replace('&',"&&");
- if (index == cur)
- targets->insertItem( label + i18n("current option in boot loader", " (current)"), index);
- else
- targets->insertItem( label, index );
+ if (mayrb) {
+ // Reboot
+ FlatButton* btnReboot = new FlatButton( frame );
+ btnReboot->setTextLabel( i18n("&Restart"), false );
+ btnReboot->setPixmap( DesktopIcon( "reload") );
+ int i = btnReboot->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
+ btnReboot->setAccel( "ALT+" + btnReboot->textLabel().lower()[i+1] ) ;
+ hbuttonbox2->addWidget ( btnReboot);
+ connect(btnReboot, TQT_SIGNAL(clicked()), TQT_SLOT(slotReboot()));
+ if ( sdtype == TDEApplication::ShutdownTypeReboot ) {
+ btnReboot->setFocus();
}
-
- btnReboot->setPopup(targets);
- connect( targets, TQT_SIGNAL(activated(int)), TQT_SLOT(slotReboot(int)) );
+
+ // BAD KARMA .. this code is copied line by line from standard konqy dialog
+ int def, cur;
+ if ( DM().bootOptions( rebootOptions, def, cur ) ) {
+ btnReboot->setPopupDelay(300); // visually add dropdown
+ targets = new TQPopupMenu( frame );
+ if ( cur == -1 ) {
+ cur = def;
+ }
+
+ int index = 0;
+ for (TQStringList::ConstIterator it = rebootOptions.begin(); it != rebootOptions.end(); ++it, ++index) {
+ TQString label = (*it);
+ label=label.replace('&',"&&");
+ if (index == cur) {
+ targets->insertItem( label + i18n("current option in boot loader", " (current)"), index);
+ }
+ else {
+ targets->insertItem( label, index );
+ }
+ }
+
+ btnReboot->setPopup(targets);
+ connect( targets, TQT_SIGNAL(activated(int)), TQT_SLOT(slotReboot(int)) );
+ }
+ // BAD KARMA .. this code is copied line by line from standard konqy dialog [EOF]
}
- // BAD CARMA .. this code is copied line by line from standard konqy dialog [EOF]
-
- // Shutdown
- FlatButton* btnHalt = new FlatButton( frame );
- btnHalt->setTextLabel( i18n("&Turn Off"), false );
- btnHalt->setPixmap( DesktopIcon( "exit") );
- i = btnHalt->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
- btnHalt->setAccel( "ALT+" + btnHalt->textLabel().lower()[i+1] ) ;
- hbuttonbox2->addWidget ( btnHalt );
- connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt()));
- if ( sdtype == TDEApplication::ShutdownTypeHalt )
+
+ if (maysd) {
+ // Shutdown
+ FlatButton* btnHalt = new FlatButton( frame );
+ btnHalt->setTextLabel( i18n("&Turn Off"), false );
+ btnHalt->setPixmap( DesktopIcon( "exit") );
+ int i = btnHalt->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
+ btnHalt->setAccel( "ALT+" + btnHalt->textLabel().lower()[i+1] ) ;
+ hbuttonbox2->addWidget ( btnHalt );
+ connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt()));
+ if ( sdtype == TDEApplication::ShutdownTypeHalt ) {
btnHalt->setFocus();
+ }
+ }
// cancel buttonbox
TQHBoxLayout* hbuttonbox3 = new TQHBoxLayout( vbox, factor * KDialog::spacingHint() );
@@ -958,47 +946,54 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
}
else
{
- // Shutdown
- KPushButton* btnHalt = new KPushButton( KGuiItem( i18n("&Turn Off Computer"), "exit"), frame );
- TQToolTip::add( btnHalt, i18n( "<qt><h3>Turn Off Computer</h3><p>Log out of the current session and turn off the computer</p></qt>" ) );
- btnHalt->setFont( btnFont );
- buttonlay->addWidget( btnHalt );
- connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt()));
- if ( sdtype == TDEApplication::ShutdownTypeHalt || getenv("TDM_AUTOLOGIN") )
- btnHalt->setFocus();
-
- // Reboot
- KSMDelayedPushButton* btnReboot = new KSMDelayedPushButton( KGuiItem( i18n("&Restart Computer"), "reload"), frame );
- TQToolTip::add( btnReboot, i18n( "<qt><h3>Restart Computer</h3><p>Log out of the current session and restart the computer</p><p>Hold the mouse button or the space bar for a short while to get a list of options what to boot</p></qt>" ) );
- btnReboot->setFont( btnFont );
- buttonlay->addWidget( btnReboot );
-
- connect(btnReboot, TQT_SIGNAL(clicked()), TQT_SLOT(slotReboot()));
- if ( sdtype == TDEApplication::ShutdownTypeReboot )
- btnReboot->setFocus();
-
- // this section is copied as-is into ubuntulogout as well
- int def, cur;
- if ( DM().bootOptions( rebootOptions, def, cur ) ) {
- targets = new TQPopupMenu( frame );
- if ( cur == -1 )
- cur = def;
-
- int index = 0;
- for (TQStringList::ConstIterator it = rebootOptions.begin(); it != rebootOptions.end(); ++it, ++index)
- {
- TQString label = (*it);
- label=label.replace('&',"&&");
- if (index == cur)
- targets->insertItem( label + i18n("current option in boot loader", " (current)"), index);
- else
- targets->insertItem( label, index );
+ if (maysd) {
+ // Shutdown
+ KPushButton* btnHalt = new KPushButton( KGuiItem( i18n("&Turn Off Computer"), "exit"), frame );
+ TQToolTip::add( btnHalt, i18n( "<qt><h3>Turn Off Computer</h3><p>Log out of the current session and turn off the computer</p></qt>" ) );
+ btnHalt->setFont( btnFont );
+ buttonlay->addWidget( btnHalt );
+ connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt()));
+ if ( sdtype == TDEApplication::ShutdownTypeHalt || getenv("TDM_AUTOLOGIN") ) {
+ btnHalt->setFocus();
}
-
- btnReboot->setPopup(targets);
- connect( targets, TQT_SIGNAL(activated(int)), TQT_SLOT(slotReboot(int)) );
}
+ if (mayrb) {
+ // Reboot
+ KSMDelayedPushButton* btnReboot = new KSMDelayedPushButton( KGuiItem( i18n("&Restart Computer"), "reload"), frame );
+ TQToolTip::add( btnReboot, i18n( "<qt><h3>Restart Computer</h3><p>Log out of the current session and restart the computer</p><p>Hold the mouse button or the space bar for a short while to get a list of options what to boot</p></qt>" ) );
+ btnReboot->setFont( btnFont );
+ buttonlay->addWidget( btnReboot );
+
+ connect(btnReboot, TQT_SIGNAL(clicked()), TQT_SLOT(slotReboot()));
+ if ( sdtype == TDEApplication::ShutdownTypeReboot ) {
+ btnReboot->setFocus();
+ }
+
+ // this section is copied as-is into ubuntulogout as well
+ int def, cur;
+ if ( DM().bootOptions( rebootOptions, def, cur ) ) {
+ targets = new TQPopupMenu( frame );
+ if ( cur == -1 ) {
+ cur = def;
+ }
+
+ int index = 0;
+ for (TQStringList::ConstIterator it = rebootOptions.begin(); it != rebootOptions.end(); ++it, ++index) {
+ TQString label = (*it);
+ label=label.replace('&',"&&");
+ if (index == cur) {
+ targets->insertItem( label + i18n("current option in boot loader", " (current)"), index);
+ }
+ else {
+ targets->insertItem( label, index );
+ }
+ }
+
+ btnReboot->setPopup(targets);
+ connect( targets, TQT_SIGNAL(activated(int)), TQT_SLOT(slotReboot(int)) );
+ }
+ }
if (canSuspend && !disableSuspend)
{
@@ -1064,9 +1059,6 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
KSMShutdownDlg::~KSMShutdownDlg()
{
-#ifdef WITH_UPOWER
-#else // WITH_UPOWER
-
#ifdef COMPILE_HALBACKEND
if (m_halCtx)
{
@@ -1076,8 +1068,6 @@ KSMShutdownDlg::~KSMShutdownDlg()
libhal_ctx_free(m_halCtx);
}
#endif
-
-#endif // WITH_UPOWER
}
@@ -1116,9 +1106,6 @@ void KSMShutdownDlg::slotSuspend()
{
*m_selection = 1; // Suspend
-#ifdef WITH_UPOWER
- // Handled in shutdown.cpp
-#else
#ifdef COMPILE_HALBACKEND
if (m_dbusConn)
{
@@ -1136,7 +1123,6 @@ void KSMShutdownDlg::slotSuspend()
dbus_message_unref(msg);
}
#endif
-#endif // WITH_UPOWER
reject(); // continue on resume
}
@@ -1144,9 +1130,6 @@ void KSMShutdownDlg::slotHibernate()
{
*m_selection = 2; // Hibernate
-#ifdef WITH_UPOWER
- // Handled in shutdown.cpp
-#else
#ifdef COMPILE_HALBACKEND
if (m_dbusConn)
{
@@ -1161,23 +1144,19 @@ void KSMShutdownDlg::slotHibernate()
dbus_message_unref(msg);
}
#endif
-#endif // WITH_UPOWER
reject(); // continue on resume
}
-bool KSMShutdownDlg::confirmShutdown( bool maysd, TDEApplication::ShutdownType& sdtype, TQString& bootOption, int* selection )
+bool KSMShutdownDlg::confirmShutdown( bool maysd, bool mayrb, TDEApplication::ShutdownType& sdtype, TQString& bootOption, int* selection )
{
kapp->enableStyles();
- KSMShutdownDlg* l = new KSMShutdownDlg( 0,
- //KSMShutdownFeedback::self(),
- maysd, sdtype, selection );
+ KSMShutdownDlg* l = new KSMShutdownDlg( 0 /*KSMShutdownFeedback::self()*/, maysd, mayrb, sdtype, selection );
// Show dialog (will save the background in showEvent)
TQSize sh = l->sizeHint();
TQRect rect = TDEGlobalSettings::desktopGeometry(TQCursor::pos());
- l->move(rect.x() + (rect.width() - sh.width())/2,
- rect.y() + (rect.height() - sh.height())/2);
+ l->move(rect.x() + (rect.width() - sh.width())/2, rect.y() + (rect.height() - sh.height())/2);
bool result = l->exec();
sdtype = l->m_shutdownType;
bootOption = l->m_bootOption;
diff --git a/ksmserver/shutdowndlg.h b/ksmserver/shutdowndlg.h
index 9f030f1e3..e9f2271e3 100644
--- a/ksmserver/shutdowndlg.h
+++ b/ksmserver/shutdowndlg.h
@@ -129,7 +129,7 @@ class KSMShutdownDlg : public TQDialog
Q_OBJECT
public:
- static bool confirmShutdown( bool maysd, TDEApplication::ShutdownType& sdtype, TQString& bopt, int* selection=0 );
+ static bool confirmShutdown( bool maysd, bool mayrb, TDEApplication::ShutdownType& sdtype, TQString& bopt, int* selection=0 );
public slots:
void slotLogout();
@@ -143,7 +143,7 @@ protected:
~KSMShutdownDlg();
private:
- KSMShutdownDlg( TQWidget* parent, bool maysd, TDEApplication::ShutdownType sdtype, int* selection=0 );
+ KSMShutdownDlg( TQWidget* parent, bool maysd, bool mayrb, TDEApplication::ShutdownType sdtype, int* selection=0 );
TDEApplication::ShutdownType m_shutdownType;
TQString m_bootOption;
TQPopupMenu *targets;