Use TDE hardware library to authorize and control shutdown related session options

This resolves Bug 1071
pull/2/head
Timothy Pearson 11 years ago
parent 704eedf364
commit 55a0cc423f

@ -579,7 +579,7 @@ extern "C" int _IceTransNoListen(const char * protocol);
#endif #endif
KSMServer::KSMServer( const TQString& windowManager, const TQString& windowManagerAddArgs, bool _only_local ) 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; the_server = this;
clean = false; clean = false;
@ -597,6 +597,8 @@ KSMServer::KSMServer( const TQString& windowManager, const TQString& windowManag
clientInteracting = 0; clientInteracting = 0;
xonCommand = config->readEntry( "xonCommand", "xon" ); xonCommand = config->readEntry( "xonCommand", "xon" );
hwDevices = TDEGlobal::hardwareDevices();
connect( &knotifyTimeoutTimer, TQT_SIGNAL( timeout()), TQT_SLOT( knotifyTimeout())); connect( &knotifyTimeoutTimer, TQT_SIGNAL( timeout()), TQT_SLOT( knotifyTimeout()));
connect( &startupSuspendTimeoutTimer, TQT_SIGNAL( timeout()), TQT_SLOT( startupSuspendTimeout())); connect( &startupSuspendTimeoutTimer, TQT_SIGNAL( timeout()), TQT_SLOT( startupSuspendTimeout()));
connect( &pendingShutdown, TQT_SIGNAL( timeout()), TQT_SLOT( pendingShutdownTimeout())); connect( &pendingShutdown, TQT_SIGNAL( timeout()), TQT_SLOT( pendingShutdownTimeout()));
@ -700,8 +702,9 @@ void KSMServer::cleanUp()
// strip the screen number from the display // strip the screen number from the display
display.replace(TQRegExp("\\.[0-9]+$"), ""); display.replace(TQRegExp("\\.[0-9]+$"), "");
int i; int i;
while( (i = display.find(':')) >= 0) while( (i = display.find(':')) >= 0) {
display[i] = '_'; display[i] = '_';
}
fName += "_"+display; fName += "_"+display;
::unlink(fName.data()); ::unlink(fName.data());
@ -710,8 +713,21 @@ void KSMServer::cleanUp()
signal(SIGTERM, SIG_DFL); signal(SIGTERM, SIG_DFL);
signal(SIGINT, SIG_DFL); signal(SIGINT, SIG_DFL);
if (DM().canShutdown()) {
DM().shutdown( shutdownType, shutdownMode, bootOption ); 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);
}
}
}
}

@ -23,6 +23,8 @@ Copyright (C) 2000 Matthias Ettrich <ettrich@kde.org>
#include <tqtimer.h> #include <tqtimer.h>
#include <dcopobject.h> #include <dcopobject.h>
#include <tdehardwaredevices.h>
#include "server2.h" #include "server2.h"
#include "KSMServerInterface.h" #include "KSMServerInterface.h"
@ -93,7 +95,7 @@ public:
virtual void suspendStartup( TQCString app ); virtual void suspendStartup( TQCString app );
virtual void resumeStartup( 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::ShutdownConfirm confirm,
TDEApplication::ShutdownType sdtype, TDEApplication::ShutdownType sdtype,
TDEApplication::ShutdownMode sdmode ); TDEApplication::ShutdownMode sdmode );
@ -234,6 +236,8 @@ private:
TQStringList excludeApps; TQStringList excludeApps;
WindowMap legacyWindows; WindowMap legacyWindows;
TDEHardwareDevices* hwDevices;
}; };
#endif #endif

@ -83,13 +83,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <libtdersync/tdersync.h> #include <libtdersync/tdersync.h>
#ifdef WITH_UPOWER
#include <tqdbusdata.h>
#include <tqdbusmessage.h>
#include <tqdbusproxy.h>
#include <tqdbusvariant.h>
#endif
#include "server.h" #include "server.h"
#include "global.h" #include "global.h"
#include "shutdowndlg.h" #include "shutdowndlg.h"
@ -110,21 +103,21 @@ void KSMServer::logout( int confirm, int sdtype, int sdmode )
(TDEApplication::ShutdownMode)sdmode ); (TDEApplication::ShutdownMode)sdmode );
} }
bool KSMServer::checkStatus( bool &logoutConfirmed, bool &maysd, bool KSMServer::checkStatus( bool &logoutConfirmed, bool &maysd, bool &mayrb,
TDEApplication::ShutdownConfirm confirm, TDEApplication::ShutdownConfirm confirm,
TDEApplication::ShutdownType sdtype, TDEApplication::ShutdownType sdtype,
TDEApplication::ShutdownMode sdmode ) TDEApplication::ShutdownMode sdmode )
{ {
pendingShutdown.stop(); pendingShutdown.stop();
if( dialogActive ) if( dialogActive ) {
return false; return false;
if( state >= Shutdown ) // already performing shutdown }
if( state >= Shutdown ) { // already performing shutdown
return false; 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 // 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.start( 1000 );
pendingShutdown_confirm = confirm; pendingShutdown_confirm = confirm;
pendingShutdown_sdtype = sdtype; pendingShutdown_sdtype = sdtype;
@ -142,11 +135,35 @@ bool KSMServer::checkStatus( bool &logoutConfirmed, bool &maysd,
(confirm == TDEApplication::ShutdownConfirmNo) ? true : (confirm == TDEApplication::ShutdownConfirmNo) ? true :
!config->readBoolEntry( "confirmLogout", true ); !config->readBoolEntry( "confirmLogout", true );
maysd = false; maysd = false;
if (config->readBoolEntry( "offerShutdown", true ) && DM().canShutdown()) 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; maysd = true;
}
if (rootDevice->canReboot()) {
mayrb = true;
}
}
}
}
if (!maysd) { if (!maysd) {
if (sdtype != TDEApplication::ShutdownTypeNone && if (sdtype != TDEApplication::ShutdownTypeNone &&
sdtype != TDEApplication::ShutdownTypeDefault && 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) logoutConfirmed)
return false; /* unsupported fast shutdown */ return false; /* unsupported fast shutdown */
} }
@ -160,20 +177,27 @@ void KSMServer::shutdownInternal( TDEApplication::ShutdownConfirm confirm,
TQString bopt ) TQString bopt )
{ {
bool maysd = false; bool maysd = false;
bool mayrb = false;
bool logoutConfirmed = false; bool logoutConfirmed = false;
if ( !checkStatus( logoutConfirmed, maysd, confirm, sdtype, sdmode ) ) if ( !checkStatus( logoutConfirmed, maysd, mayrb, confirm, sdtype, sdmode ) ) {
return; return;
}
TDEConfig *config = TDEGlobal::config(); TDEConfig *config = TDEGlobal::config();
config->setGroup("General" ); config->setGroup("General" );
if (!maysd) { if ((!maysd) && (sdtype != TDEApplication::ShutdownTypeReboot)) {
sdtype = TDEApplication::ShutdownTypeNone;
}
if ((!mayrb) && (sdtype != TDEApplication::ShutdownTypeHalt)) {
sdtype = TDEApplication::ShutdownTypeNone; sdtype = TDEApplication::ShutdownTypeNone;
} else if (sdtype == TDEApplication::ShutdownTypeDefault) }
sdtype = (TDEApplication::ShutdownType) if (sdtype == TDEApplication::ShutdownTypeDefault) {
config->readNumEntry( "shutdownType", (int)TDEApplication::ShutdownTypeNone ); sdtype = (TDEApplication::ShutdownType) config->readNumEntry( "shutdownType", (int)TDEApplication::ShutdownTypeNone );
if (sdmode == TDEApplication::ShutdownModeDefault) }
if (sdmode == TDEApplication::ShutdownModeDefault) {
sdmode = TDEApplication::ShutdownModeInteractive; sdmode = TDEApplication::ShutdownModeInteractive;
}
// shall we show a logout status dialog box? // shall we show a logout status dialog box?
bool showLogoutStatusDlg = TDEConfigGroup(TDEGlobal::config(), "Logout").readBoolEntry("showLogoutStatusDlg", true); bool showLogoutStatusDlg = TDEConfigGroup(TDEGlobal::config(), "Logout").readBoolEntry("showLogoutStatusDlg", true);
@ -187,7 +211,7 @@ void KSMServer::shutdownInternal( TDEApplication::ShutdownConfirm confirm,
int selection; int selection;
KSMShutdownFeedback::start(); // make the screen gray KSMShutdownFeedback::start(); // make the screen gray
logoutConfirmed = 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, // ###### We can't make the screen remain gray while talking to the apps,
// because this prevents interaction ("do you want to save", etc.) // because this prevents interaction ("do you want to save", etc.)
// TODO: turn the feedback widget into a list of apps to be closed, // 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) { if (lockOnResume) {
DCOPRef("kdesktop", "KScreensaverIface").send("lock"); DCOPRef("kdesktop", "KScreensaverIface").send("lock");
} }
#ifdef WITH_UPOWER TDERootSystemDevice* rootDevice = hwDevices->rootSystemDevice();
TQT_DBusConnection dbusConn; if (rootDevice) {
dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
if (selection == 1) { // Suspend if (selection == 1) { // Suspend
if ( dbusConn.isConnected() ) { rootDevice->setPowerState(TDESystemPowerState::Suspend);
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
"org.freedesktop.UPower",
"/org/freedesktop/UPower",
"org.freedesktop.UPower",
"Suspend");
dbusConn.sendWithReply(msg);
}
} }
if (selection == 2) { // Hibernate if (selection == 2) { // Hibernate
if( dbusConn.isConnected() ) { rootDevice->setPowerState(TDESystemPowerState::Hibernate);
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
"org.freedesktop.UPower",
"/org/freedesktop/UPower",
"org.freedesktop.UPower",
"Hibernate");
dbusConn.sendWithReply(msg);
} }
} }
#endif // WITH_UPOWER
} }
} }
@ -308,12 +317,15 @@ void KSMServer::logoutTimed( int sdtype, int sdmode, TQString bootOption )
TDEConfig* config = TDEGlobal::config(); TDEConfig* config = TDEGlobal::config();
config->setGroup( "General" ); config->setGroup( "General" );
if ( sdtype == TDEApplication::ShutdownTypeHalt ) if ( sdtype == TDEApplication::ShutdownTypeHalt ) {
confirmDelay = config->readNumEntry( "confirmShutdownDelay", 31 ); confirmDelay = config->readNumEntry( "confirmShutdownDelay", 31 );
else if ( sdtype == TDEApplication::ShutdownTypeReboot ) }
else if ( sdtype == TDEApplication::ShutdownTypeReboot ) {
confirmDelay = config->readNumEntry( "confirmRebootDelay", 31 ); confirmDelay = config->readNumEntry( "confirmRebootDelay", 31 );
else }
else {
confirmDelay = config->readNumEntry( "confirmLogoutDelay", 31 ); confirmDelay = config->readNumEntry( "confirmLogoutDelay", 31 );
}
bool result = true; bool result = true;
if (confirmDelay) { if (confirmDelay) {

@ -8,13 +8,6 @@ Copyright (C) 2000 Matthias Ettrich <ettrich@kde.org>
#include "shutdowndlg.h" #include "shutdowndlg.h"
#ifdef WITH_UPOWER
#include <tqdbusdata.h>
#include <tqdbusmessage.h>
#include <tqdbusproxy.h>
#include <tqdbusvariant.h>
#endif
#include <tqapplication.h> #include <tqapplication.h>
#include <tqlayout.h> #include <tqlayout.h>
#include <tqgroupbox.h> #include <tqgroupbox.h>
@ -40,6 +33,7 @@ Copyright (C) 2000 Matthias Ettrich <ettrich@kde.org>
#include <tdelocale.h> #include <tdelocale.h>
#include <tdeconfig.h> #include <tdeconfig.h>
#include <tdeapplication.h> #include <tdeapplication.h>
#include <tdehardwaredevices.h>
#include <kdebug.h> #include <kdebug.h>
#include <kpushbutton.h> #include <kpushbutton.h>
#include <kstdguiitem.h> #include <kstdguiitem.h>
@ -674,7 +668,7 @@ void KSMShutdownIPFeedback::slotPaintEffect()
////// //////
KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, 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) : TQDialog( parent, 0, TRUE, (WFlags)WType_Popup ), targets(0), m_selection(selection)
// this is a WType_Popup on purpose. Do not change that! Not // this is a WType_Popup on purpose. Do not change that! Not
// having a popup here has severe side effects. // having a popup here has severe side effects.
@ -770,13 +764,11 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
connect(btnLogout, TQT_SIGNAL(clicked()), TQT_SLOT(slotLogout())); connect(btnLogout, TQT_SIGNAL(clicked()), TQT_SLOT(slotLogout()));
} }
#ifndef WITH_UPOWER
#ifdef COMPILE_HALBACKEND #ifdef COMPILE_HALBACKEND
m_halCtx = NULL; m_halCtx = NULL;
#endif #endif
#endif // WITH_UPOWER
if (maysd) { if ((maysd) || (mayrb)) {
// respect lock on resume & disable suspend/hibernate settings // respect lock on resume & disable suspend/hibernate settings
// from power-manager // from power-manager
@ -788,27 +780,6 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
bool canSuspend = false; bool canSuspend = false;
bool canHibernate = 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 #ifdef COMPILE_HALBACKEND
// Query HAL for suspend/resume support // Query HAL for suspend/resume support
m_halCtx = libhal_ctx_new(); m_halCtx = libhal_ctx_new();
@ -864,8 +835,17 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
canHibernate = true; canHibernate = true;
} }
} }
#endif #else // COMPILE_HALBACKEND
#endif // WITH_UPOWER TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice();
if (rootDevice) {
canSuspend = rootDevice->canSuspend();
canHibernate = rootDevice->canHibernate();
}
else {
canSuspend = false;
canHibernate = false;
}
#endif // COMPILE_HALBACKEND
if(doUbuntuLogout) { if(doUbuntuLogout) {
@ -900,6 +880,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
TQHBoxLayout* hbuttonbox2 = new TQHBoxLayout( vbox, factor * KDialog::spacingHint() ); TQHBoxLayout* hbuttonbox2 = new TQHBoxLayout( vbox, factor * KDialog::spacingHint() );
hbuttonbox2->setAlignment( Qt::AlignHCenter ); hbuttonbox2->setAlignment( Qt::AlignHCenter );
if (mayrb) {
// Reboot // Reboot
FlatButton* btnReboot = new FlatButton( frame ); FlatButton* btnReboot = new FlatButton( frame );
btnReboot->setTextLabel( i18n("&Restart"), false ); btnReboot->setTextLabel( i18n("&Restart"), false );
@ -908,43 +889,50 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
btnReboot->setAccel( "ALT+" + btnReboot->textLabel().lower()[i+1] ) ; btnReboot->setAccel( "ALT+" + btnReboot->textLabel().lower()[i+1] ) ;
hbuttonbox2->addWidget ( btnReboot); hbuttonbox2->addWidget ( btnReboot);
connect(btnReboot, TQT_SIGNAL(clicked()), TQT_SLOT(slotReboot())); connect(btnReboot, TQT_SIGNAL(clicked()), TQT_SLOT(slotReboot()));
if ( sdtype == TDEApplication::ShutdownTypeReboot ) if ( sdtype == TDEApplication::ShutdownTypeReboot ) {
btnReboot->setFocus(); btnReboot->setFocus();
}
// BAD CARMA .. this code is copied line by line from standard konqy dialog // BAD KARMA .. this code is copied line by line from standard konqy dialog
int def, cur; int def, cur;
if ( DM().bootOptions( rebootOptions, def, cur ) ) { if ( DM().bootOptions( rebootOptions, def, cur ) ) {
btnReboot->setPopupDelay(300); // visually add dropdown btnReboot->setPopupDelay(300); // visually add dropdown
targets = new TQPopupMenu( frame ); targets = new TQPopupMenu( frame );
if ( cur == -1 ) if ( cur == -1 ) {
cur = def; cur = def;
}
int index = 0; int index = 0;
for (TQStringList::ConstIterator it = rebootOptions.begin(); it != rebootOptions.end(); ++it, ++index) for (TQStringList::ConstIterator it = rebootOptions.begin(); it != rebootOptions.end(); ++it, ++index) {
{
TQString label = (*it); TQString label = (*it);
label=label.replace('&',"&&"); label=label.replace('&',"&&");
if (index == cur) if (index == cur) {
targets->insertItem( label + i18n("current option in boot loader", " (current)"), index); targets->insertItem( label + i18n("current option in boot loader", " (current)"), index);
else }
else {
targets->insertItem( label, index ); targets->insertItem( label, index );
} }
}
btnReboot->setPopup(targets); btnReboot->setPopup(targets);
connect( targets, TQT_SIGNAL(activated(int)), TQT_SLOT(slotReboot(int)) ); connect( targets, TQT_SIGNAL(activated(int)), TQT_SLOT(slotReboot(int)) );
} }
// BAD CARMA .. this code is copied line by line from standard konqy dialog [EOF] // BAD KARMA .. this code is copied line by line from standard konqy dialog [EOF]
}
if (maysd) {
// Shutdown // Shutdown
FlatButton* btnHalt = new FlatButton( frame ); FlatButton* btnHalt = new FlatButton( frame );
btnHalt->setTextLabel( i18n("&Turn Off"), false ); btnHalt->setTextLabel( i18n("&Turn Off"), false );
btnHalt->setPixmap( DesktopIcon( "exit") ); btnHalt->setPixmap( DesktopIcon( "exit") );
i = btnHalt->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1 int i = btnHalt->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
btnHalt->setAccel( "ALT+" + btnHalt->textLabel().lower()[i+1] ) ; btnHalt->setAccel( "ALT+" + btnHalt->textLabel().lower()[i+1] ) ;
hbuttonbox2->addWidget ( btnHalt ); hbuttonbox2->addWidget ( btnHalt );
connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt())); connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt()));
if ( sdtype == TDEApplication::ShutdownTypeHalt ) if ( sdtype == TDEApplication::ShutdownTypeHalt ) {
btnHalt->setFocus(); btnHalt->setFocus();
}
}
// cancel buttonbox // cancel buttonbox
TQHBoxLayout* hbuttonbox3 = new TQHBoxLayout( vbox, factor * KDialog::spacingHint() ); TQHBoxLayout* hbuttonbox3 = new TQHBoxLayout( vbox, factor * KDialog::spacingHint() );
@ -958,15 +946,19 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
} }
else else
{ {
if (maysd) {
// Shutdown // Shutdown
KPushButton* btnHalt = new KPushButton( KGuiItem( i18n("&Turn Off Computer"), "exit"), frame ); 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>" ) ); 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 ); btnHalt->setFont( btnFont );
buttonlay->addWidget( btnHalt ); buttonlay->addWidget( btnHalt );
connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt())); connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt()));
if ( sdtype == TDEApplication::ShutdownTypeHalt || getenv("TDM_AUTOLOGIN") ) if ( sdtype == TDEApplication::ShutdownTypeHalt || getenv("TDM_AUTOLOGIN") ) {
btnHalt->setFocus(); btnHalt->setFocus();
}
}
if (mayrb) {
// Reboot // Reboot
KSMDelayedPushButton* btnReboot = new KSMDelayedPushButton( KGuiItem( i18n("&Restart Computer"), "reload"), frame ); 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>" ) ); 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>" ) );
@ -974,31 +966,34 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
buttonlay->addWidget( btnReboot ); buttonlay->addWidget( btnReboot );
connect(btnReboot, TQT_SIGNAL(clicked()), TQT_SLOT(slotReboot())); connect(btnReboot, TQT_SIGNAL(clicked()), TQT_SLOT(slotReboot()));
if ( sdtype == TDEApplication::ShutdownTypeReboot ) if ( sdtype == TDEApplication::ShutdownTypeReboot ) {
btnReboot->setFocus(); btnReboot->setFocus();
}
// this section is copied as-is into ubuntulogout as well // this section is copied as-is into ubuntulogout as well
int def, cur; int def, cur;
if ( DM().bootOptions( rebootOptions, def, cur ) ) { if ( DM().bootOptions( rebootOptions, def, cur ) ) {
targets = new TQPopupMenu( frame ); targets = new TQPopupMenu( frame );
if ( cur == -1 ) if ( cur == -1 ) {
cur = def; cur = def;
}
int index = 0; int index = 0;
for (TQStringList::ConstIterator it = rebootOptions.begin(); it != rebootOptions.end(); ++it, ++index) for (TQStringList::ConstIterator it = rebootOptions.begin(); it != rebootOptions.end(); ++it, ++index) {
{
TQString label = (*it); TQString label = (*it);
label=label.replace('&',"&&"); label=label.replace('&',"&&");
if (index == cur) if (index == cur) {
targets->insertItem( label + i18n("current option in boot loader", " (current)"), index); targets->insertItem( label + i18n("current option in boot loader", " (current)"), index);
else }
else {
targets->insertItem( label, index ); targets->insertItem( label, index );
} }
}
btnReboot->setPopup(targets); btnReboot->setPopup(targets);
connect( targets, TQT_SIGNAL(activated(int)), TQT_SLOT(slotReboot(int)) ); connect( targets, TQT_SIGNAL(activated(int)), TQT_SLOT(slotReboot(int)) );
} }
}
if (canSuspend && !disableSuspend) if (canSuspend && !disableSuspend)
{ {
@ -1064,9 +1059,6 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
KSMShutdownDlg::~KSMShutdownDlg() KSMShutdownDlg::~KSMShutdownDlg()
{ {
#ifdef WITH_UPOWER
#else // WITH_UPOWER
#ifdef COMPILE_HALBACKEND #ifdef COMPILE_HALBACKEND
if (m_halCtx) if (m_halCtx)
{ {
@ -1076,8 +1068,6 @@ KSMShutdownDlg::~KSMShutdownDlg()
libhal_ctx_free(m_halCtx); libhal_ctx_free(m_halCtx);
} }
#endif #endif
#endif // WITH_UPOWER
} }
@ -1116,9 +1106,6 @@ void KSMShutdownDlg::slotSuspend()
{ {
*m_selection = 1; // Suspend *m_selection = 1; // Suspend
#ifdef WITH_UPOWER
// Handled in shutdown.cpp
#else
#ifdef COMPILE_HALBACKEND #ifdef COMPILE_HALBACKEND
if (m_dbusConn) if (m_dbusConn)
{ {
@ -1136,7 +1123,6 @@ void KSMShutdownDlg::slotSuspend()
dbus_message_unref(msg); dbus_message_unref(msg);
} }
#endif #endif
#endif // WITH_UPOWER
reject(); // continue on resume reject(); // continue on resume
} }
@ -1144,9 +1130,6 @@ void KSMShutdownDlg::slotHibernate()
{ {
*m_selection = 2; // Hibernate *m_selection = 2; // Hibernate
#ifdef WITH_UPOWER
// Handled in shutdown.cpp
#else
#ifdef COMPILE_HALBACKEND #ifdef COMPILE_HALBACKEND
if (m_dbusConn) if (m_dbusConn)
{ {
@ -1161,23 +1144,19 @@ void KSMShutdownDlg::slotHibernate()
dbus_message_unref(msg); dbus_message_unref(msg);
} }
#endif #endif
#endif // WITH_UPOWER
reject(); // continue on resume 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(); kapp->enableStyles();
KSMShutdownDlg* l = new KSMShutdownDlg( 0, KSMShutdownDlg* l = new KSMShutdownDlg( 0 /*KSMShutdownFeedback::self()*/, maysd, mayrb, sdtype, selection );
//KSMShutdownFeedback::self(),
maysd, sdtype, selection );
// Show dialog (will save the background in showEvent) // Show dialog (will save the background in showEvent)
TQSize sh = l->sizeHint(); TQSize sh = l->sizeHint();
TQRect rect = TDEGlobalSettings::desktopGeometry(TQCursor::pos()); TQRect rect = TDEGlobalSettings::desktopGeometry(TQCursor::pos());
l->move(rect.x() + (rect.width() - sh.width())/2, l->move(rect.x() + (rect.width() - sh.width())/2, rect.y() + (rect.height() - sh.height())/2);
rect.y() + (rect.height() - sh.height())/2);
bool result = l->exec(); bool result = l->exec();
sdtype = l->m_shutdownType; sdtype = l->m_shutdownType;
bootOption = l->m_bootOption; bootOption = l->m_bootOption;

@ -129,7 +129,7 @@ class KSMShutdownDlg : public TQDialog
Q_OBJECT Q_OBJECT
public: 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: public slots:
void slotLogout(); void slotLogout();
@ -143,7 +143,7 @@ protected:
~KSMShutdownDlg(); ~KSMShutdownDlg();
private: 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; TDEApplication::ShutdownType m_shutdownType;
TQString m_bootOption; TQString m_bootOption;
TQPopupMenu *targets; TQPopupMenu *targets;

Loading…
Cancel
Save