author | sandman <sandman> | 2002-09-30 00:29:12 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-30 00:29:12 (UTC) |
commit | f6e9cebd79044b1ca54648ecdadd13db8c4673dc (patch) (unidiff) | |
tree | e29985455734329ee31e14d04b2d613eafabb6a0 /core/opie-login/loginwindowimpl.cpp | |
parent | b53db7a5a334fdd53bd86e8b50587f1dae41cfba (diff) | |
download | opie-f6e9cebd79044b1ca54648ecdadd13db8c4673dc.zip opie-f6e9cebd79044b1ca54648ecdadd13db8c4673dc.tar.gz opie-f6e9cebd79044b1ca54648ecdadd13db8c4673dc.tar.bz2 |
- added an option to quit to console
- launcher is now started via a login shell
- font is "hardcoded" to helvetica
- screen saver is "hardcoded" to 30/20/60 secs
(this should make opie-login usable, regardless of any
(miss)-configuration of the normal OPIE appearance)
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 | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <grp.h> | 20 | #include <grp.h> |
21 | #include <unistd.h> | 21 | #include <unistd.h> |
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <signal.h> | ||
23 | 24 | ||
24 | #ifdef USEPAM | 25 | #ifdef USEPAM |
25 | extern "C" { | 26 | extern "C" { |
@@ -37,6 +38,7 @@ LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_C | |||
37 | { | 38 | { |
38 | QPopupMenu *pop = new QPopupMenu ( this ); | 39 | QPopupMenu *pop = new QPopupMenu ( this ); |
39 | pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( ))); | 40 | pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( ))); |
41 | pop-> insertItem ( tr( "Quit" ), this, SLOT( quit ( ))); | ||
40 | m_menu-> setPopup ( pop ); | 42 | m_menu-> setPopup ( pop ); |
41 | 43 | ||
42 | QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); | 44 | QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); |
@@ -57,7 +59,7 @@ LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_C | |||
57 | if ( !bgpix. isNull ( )) | 59 | if ( !bgpix. isNull ( )) |
58 | setBackgroundPixmap ( bgpix ); | 60 | setBackgroundPixmap ( bgpix ); |
59 | 61 | ||
60 | m_caption-> setText ( m_caption-> text ( ) + tr( "<center><h1><u>%1 %2</u></h1></center>" ). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); | 62 | m_caption-> setText ( m_caption-> text ( ) + tr( "<center>%1 %2</center>" ). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); |
61 | } | 63 | } |
62 | 64 | ||
63 | LoginWindowImpl::~LoginWindowImpl ( ) | 65 | LoginWindowImpl::~LoginWindowImpl ( ) |
@@ -67,9 +69,9 @@ LoginWindowImpl::~LoginWindowImpl ( ) | |||
67 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) | 69 | void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) |
68 | { | 70 | { |
69 | switch ( e-> key ( )) { | 71 | switch ( e-> key ( )) { |
70 | case Key_F34: suspend ( ); | 72 | case HardKey_Suspend: suspend ( ); |
71 | break; | 73 | break; |
72 | case Key_F35: backlight ( ); | 74 | case HardKey_Backlight: backlight ( ); |
73 | break; | 75 | break; |
74 | default : e-> ignore ( ); | 76 | default : e-> ignore ( ); |
75 | break; | 77 | break; |
@@ -88,12 +90,12 @@ QStringList LoginWindowImpl::getAllUsers ( ) | |||
88 | struct passwd *pwd; | 90 | struct passwd *pwd; |
89 | QStringList sl; | 91 | QStringList sl; |
90 | 92 | ||
91 | while (( pwd = getpwent ( ))) { | 93 | while (( pwd = ::getpwent ( ))) { |
92 | if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) | 94 | if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) |
93 | sl << QString ( pwd-> pw_name ); | 95 | sl << QString ( pwd-> pw_name ); |
94 | } | 96 | } |
95 | 97 | ||
96 | endpwent ( ); | 98 | ::endpwent ( ); |
97 | 99 | ||
98 | return sl; | 100 | return sl; |
99 | } | 101 | } |
@@ -108,23 +110,25 @@ void LoginWindowImpl::restart ( ) | |||
108 | qApp-> quit ( ); | 110 | qApp-> quit ( ); |
109 | } | 111 | } |
110 | 112 | ||
111 | void LoginWindowImpl::suspend ( ) | 113 | void LoginWindowImpl::quit ( ) |
112 | { | 114 | { |
113 | system ( "apm -s" ); | 115 | qApp-> quit ( ); |
114 | usleep ( 1 * 1000 * 1000 ); | 116 | ::kill ( ::getppid ( ), SIGUSR1 ); |
117 | } | ||
118 | |||
119 | void LoginWindowImpl::suspend ( ) | ||
115 | { | 120 | { |
121 | ODevice::inst ( )-> suspend ( ); | ||
122 | |||
116 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 123 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
117 | e << -3; // Force on | 124 | e << -3; // Force on |
118 | } | 125 | } |
119 | } | ||
120 | 126 | ||
121 | void LoginWindowImpl::backlight ( ) | 127 | void LoginWindowImpl::backlight ( ) |
122 | { | 128 | { |
123 | { | ||
124 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 129 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
125 | e << -2; // toggle | 130 | e << -2; // toggle |
126 | } | 131 | } |
127 | } | ||
128 | 132 | ||
129 | #ifdef USEPAM | 133 | #ifdef USEPAM |
130 | 134 | ||
@@ -258,36 +262,26 @@ bool LoginWindowImpl::changeIdentity ( const char *user ) | |||
258 | struct passwd *pw = getpwnam ( user ); | 262 | struct passwd *pw = getpwnam ( user ); |
259 | 263 | ||
260 | fail |= ( pw == 0 ); | 264 | fail |= ( pw == 0 ); |
261 | printf ( "1 %d\n", fail ); | ||
262 | fail |= ( initgroups ( pw-> pw_name, pw-> pw_gid )); | 265 | fail |= ( initgroups ( pw-> pw_name, pw-> pw_gid )); |
263 | endgrent ( ); | 266 | endgrent ( ); |
264 | printf ( "2 %d\n", fail ); | ||
265 | fail |= ( setgid ( pw-> pw_gid )); | 267 | fail |= ( setgid ( pw-> pw_gid )); |
266 | printf ( "3 %d\n", fail ); | ||
267 | fail |= ( setuid ( pw-> pw_uid )); | 268 | fail |= ( setuid ( pw-> pw_uid )); |
268 | 269 | ||
269 | printf ( "4 %d\n", fail ); | ||
270 | fail |= ( chdir ( pw-> pw_dir ) && chdir ( "/" )); | 270 | fail |= ( chdir ( pw-> pw_dir ) && chdir ( "/" )); |
271 | 271 | ||
272 | printf ( "5 %d\n", fail ); | ||
273 | fail |= ( setenv ( "HOME", pw-> pw_dir, 1 )); | 272 | fail |= ( setenv ( "HOME", pw-> pw_dir, 1 )); |
274 | printf ( "6 %d\n", fail ); | ||
275 | fail |= ( setenv ( "SHELL", pw-> pw_shell, 1 )); | 273 | fail |= ( setenv ( "SHELL", pw-> pw_shell, 1 )); |
276 | printf ( "7 %d\n", fail ); | ||
277 | fail |= ( setenv ( "USER", pw-> pw_name, 1 )); | 274 | fail |= ( setenv ( "USER", pw-> pw_name, 1 )); |
278 | printf ( "8 %d\n", fail ); | ||
279 | fail |= ( setenv ( "LOGNAME", pw-> pw_name, 1 )); | 275 | fail |= ( setenv ( "LOGNAME", pw-> pw_name, 1 )); |
280 | printf ( "9 %d\n", fail ); | ||
281 | fail |= ( setenv ( "PATH", ( pw-> pw_uid ? DEFAULT_LOGIN_PATH : DEFAULT_ROOT_LOGIN_PATH ), 1 )); | 276 | fail |= ( setenv ( "PATH", ( pw-> pw_uid ? DEFAULT_LOGIN_PATH : DEFAULT_ROOT_LOGIN_PATH ), 1 )); |
282 | printf ( "10 %d\n", fail ); | ||
283 | 277 | ||
284 | return !fail; | 278 | return !fail; |
285 | } | 279 | } |
286 | 280 | ||
287 | void LoginWindowImpl::login ( ) | 281 | void LoginWindowImpl::login ( ) |
288 | { | 282 | { |
289 | const char *user = strdup ( m_user-> currentText ( ). local8Bit ( )); | 283 | const char *user = ::strdup ( m_user-> currentText ( ). local8Bit ( )); |
290 | const char *pass = strdup ( m_password-> text ( ). local8Bit ( )); | 284 | const char *pass = ::strdup ( m_password-> text ( ). local8Bit ( )); |
291 | bool ok; | 285 | bool ok; |
292 | 286 | ||
293 | if ( !user || !user [0] ) | 287 | if ( !user || !user [0] ) |
@@ -303,12 +297,18 @@ void LoginWindowImpl::login ( ) | |||
303 | 297 | ||
304 | if ( ok ) { | 298 | if ( ok ) { |
305 | if ( changeIdentity ( user )) { | 299 | if ( changeIdentity ( user )) { |
306 | QString opie = getenv ( "OPIEDIR" ); | 300 | char *opie = ::getenv ( "OPIEDIR" ); |
307 | opie += "/bin/qpe"; | 301 | char *arg = new char [::strlen ( opie ) + 8 + 1]; |
302 | |||
303 | ::strcpy ( arg, opie ); | ||
304 | ::strcat ( arg, "/bin/qpe" ); | ||
305 | |||
306 | // start qpe via a login shell | ||
307 | ::execl ( "/bin/sh", "-sh", "-c", arg, 0 ); | ||
308 | 308 | ||
309 | execl ( opie. latin1 ( ), "qpe", 0 ); | 309 | QMessageBox::critical ( this, tr( "Failure" ), tr( "Could not start OPIE\n(%1)." ). arg ( arg )); |
310 | delete [] arg; | ||
310 | 311 | ||
311 | QMessageBox::critical ( this, tr( "Failure" ), tr( "Could not start OPIE." )); | ||
312 | restart ( ); | 312 | restart ( ); |
313 | } | 313 | } |
314 | else { | 314 | else { |