Diffstat (limited to 'core/opie-login/loginwindowimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/opie-login/loginwindowimpl.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp index 3265b46..f24ebb3 100644 --- a/core/opie-login/loginwindowimpl.cpp +++ b/core/opie-login/loginwindowimpl.cpp @@ -19,8 +19,9 @@ #include <pwd.h> #include <grp.h> #include <unistd.h> #include <stdlib.h> +#include <signal.h> #ifdef USEPAM extern "C" { #include <security/pam_appl.h> @@ -36,8 +37,9 @@ extern "C" { LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) { QPopupMenu *pop = new QPopupMenu ( this ); pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( ))); + pop-> insertItem ( tr( "Quit" ), this, SLOT( quit ( ))); m_menu-> setPopup ( pop ); QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); m_input = new InputMethods ( m_taskbar ); @@ -56,9 +58,9 @@ LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_C if ( !bgpix. isNull ( )) setBackgroundPixmap ( bgpix ); - m_caption-> setText ( m_caption-> text ( ) + tr( "<center><h1><u>%1 %2</u></h1></center>" ). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); + m_caption-> setText ( m_caption-> text ( ) + tr( "<center>%1 %2</center>" ). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); } LoginWindowImpl::~LoginWindowImpl ( ) { @@ -66,11 +68,11 @@ LoginWindowImpl::~LoginWindowImpl ( ) void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) { switch ( e-> key ( )) { - case Key_F34: suspend ( ); + case HardKey_Suspend: suspend ( ); break; - case Key_F35: backlight ( ); + case HardKey_Backlight: backlight ( ); break; default : e-> ignore ( ); break; } @@ -87,14 +89,14 @@ QStringList LoginWindowImpl::getAllUsers ( ) { struct passwd *pwd; QStringList sl; - while (( pwd = getpwent ( ))) { + while (( pwd = ::getpwent ( ))) { if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) sl << QString ( pwd-> pw_name ); } - endpwent ( ); + ::endpwent ( ); return sl; } @@ -107,25 +109,27 @@ void LoginWindowImpl::restart ( ) { qApp-> quit ( ); } -void LoginWindowImpl::suspend ( ) +void LoginWindowImpl::quit ( ) { - system ( "apm -s" ); - usleep ( 1 * 1000 * 1000 ); + qApp-> quit ( ); + ::kill ( ::getppid ( ), SIGUSR1 ); +} + +void LoginWindowImpl::suspend ( ) { + ODevice::inst ( )-> suspend ( ); + QCopEnvelope e("QPE/System", "setBacklight(int)"); e << -3; // Force on } -} void LoginWindowImpl::backlight ( ) { - { QCopEnvelope e("QPE/System", "setBacklight(int)"); e << -2; // toggle } -} #ifdef USEPAM static const char *_PAM_SERVICE = "xdm"; @@ -257,38 +261,28 @@ bool LoginWindowImpl::changeIdentity ( const char *user ) bool fail = false; struct passwd *pw = getpwnam ( user ); fail |= ( pw == 0 ); - printf ( "1 %d\n", fail ); fail |= ( initgroups ( pw-> pw_name, pw-> pw_gid )); endgrent ( ); - printf ( "2 %d\n", fail ); fail |= ( setgid ( pw-> pw_gid )); - printf ( "3 %d\n", fail ); fail |= ( setuid ( pw-> pw_uid )); - printf ( "4 %d\n", fail ); fail |= ( chdir ( pw-> pw_dir ) && chdir ( "/" )); - printf ( "5 %d\n", fail ); fail |= ( setenv ( "HOME", pw-> pw_dir, 1 )); - printf ( "6 %d\n", fail ); fail |= ( setenv ( "SHELL", pw-> pw_shell, 1 )); - printf ( "7 %d\n", fail ); fail |= ( setenv ( "USER", pw-> pw_name, 1 )); - printf ( "8 %d\n", fail ); fail |= ( setenv ( "LOGNAME", pw-> pw_name, 1 )); - printf ( "9 %d\n", fail ); fail |= ( setenv ( "PATH", ( pw-> pw_uid ? DEFAULT_LOGIN_PATH : DEFAULT_ROOT_LOGIN_PATH ), 1 )); - printf ( "10 %d\n", fail ); return !fail; } void LoginWindowImpl::login ( ) { - const char *user = strdup ( m_user-> currentText ( ). local8Bit ( )); - const char *pass = strdup ( m_password-> text ( ). local8Bit ( )); + const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); + const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); bool ok; if ( !user || !user [0] ) return; @@ -302,14 +296,20 @@ void LoginWindowImpl::login ( ) #endif if ( ok ) { if ( changeIdentity ( user )) { - QString opie = getenv ( "OPIEDIR" ); - opie += "/bin/qpe"; + char *opie = ::getenv ( "OPIEDIR" ); + char *arg = new char [::strlen ( opie ) + 8 + 1]; + + ::strcpy ( arg, opie ); + ::strcat ( arg, "/bin/qpe" ); + + // start qpe via a login shell + ::execl ( "/bin/sh", "-sh", "-c", arg, 0 ); - execl ( opie. latin1 ( ), "qpe", 0 ); + QMessageBox::critical ( this, tr( "Failure" ), tr( "Could not start OPIE\n(%1)." ). arg ( arg )); + delete [] arg; - QMessageBox::critical ( this, tr( "Failure" ), tr( "Could not start OPIE." )); restart ( ); } else { QMessageBox::critical ( this, tr( "Failure" ), tr( "Could not switch to new user identity" )); |