-rw-r--r-- | core/launcher/desktop.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 03a23dc..4c239a6 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -5,32 +5,34 @@ ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#include <syslog.h> + #include "desktop.h" #include "info.h" #include "launcher.h" #include "qcopbridge.h" #include "shutdownimpl.h" #include "startmenu.h" #include "taskbar.h" #include "transferserver.h" #include "irserver.h" #include "packageslave.h" #include "screensaver.h" #include <qpe/applnk.h> #include <qpe/mimetype.h> #include <qpe/password.h> #include <qpe/config.h> @@ -725,38 +727,46 @@ void Desktop::styleChange( QStyle &s ) tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); } void DesktopApplication::shutdown() { if ( type() != GuiServer ) return ; ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), this, SLOT( shutdown( ShutdownImpl::Type ) ) ); sd->showMaximized(); } void DesktopApplication::shutdown( ShutdownImpl::Type t ) { + + char *opt = 0; + switch ( t ) { case ShutdownImpl::ShutdownSystem: - execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); - break; + opt = "-h"; + // fall through case ShutdownImpl::RebootSystem: - execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); + if ( opt == 0 ) + opt = "-r"; + + if ( execle( "shutdown", "shutdown", opt, "now", ( void* ) 0, "/sbin", "/usr/sbin", ( void* ) 0 ) < 0 ) + ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); + break; case ShutdownImpl::RestartDesktop: restart(); break; case ShutdownImpl::TerminateDesktop: prepareForTermination( FALSE ); // This is a workaround for a Qt bug // clipboard applet has to stop its poll timer, or Qt/E // will hang on quit() right before it emits aboutToQuit() emit aboutToQuit ( ); quit(); break; } } |