summaryrefslogtreecommitdiff
path: root/core/opie-login/loginwindowimpl.cpp
Side-by-side diff
Diffstat (limited to 'core/opie-login/loginwindowimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/opie-login/loginwindowimpl.cpp54
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
@@ -20,6 +20,7 @@
#include <grp.h>
#include <unistd.h>
#include <stdlib.h>
+#include <signal.h>
#ifdef USEPAM
extern "C" {
@@ -37,6 +38,7 @@ LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_C
{
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 );
@@ -57,7 +59,7 @@ 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 ( )
@@ -67,9 +69,9 @@ 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;
@@ -88,12 +90,12 @@ 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;
}
@@ -108,23 +110,25 @@ 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
@@ -258,36 +262,26 @@ bool LoginWindowImpl::changeIdentity ( const char *user )
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] )
@@ -303,12 +297,18 @@ void LoginWindowImpl::login ( )
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 {