summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-02-08 23:40:04 (UTC)
committer mickeyl <mickeyl>2005-02-08 23:40:04 (UTC)
commitdf9f73f2505ac66e804aca3bf490b80e61d3f90d (patch) (unidiff)
treebcf38ecaaac77bf517c04c32649529beebf95900
parentb61772fe39346e724f560161d9885589ba86a23f (diff)
downloadopie-df9f73f2505ac66e804aca3bf490b80e61d3f90d.zip
opie-df9f73f2505ac66e804aca3bf490b80e61d3f90d.tar.gz
opie-df9f73f2505ac66e804aca3bf490b80e61d3f90d.tar.bz2
catch up w/ override changes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opie-login/main.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index 2de0180..711bedc 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -1,106 +1,106 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; version 2 of the License.
10     ._= =}       : or (at your option) any later version. 10     ._= =}       :
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc., 22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27 27
28#include "loginapplication.h" 28#include "loginapplication.h"
29#include "loginwindowimpl.h" 29#include "loginwindowimpl.h"
30#include "calibrate.h" 30#include "calibrate.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34#include <qpe/qpestyle.h> 34#include <qpe/qpestyle.h>
35#include <qpe/power.h> 35#include <qpe/power.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38/* QT */ 38/* QT */
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#include <qmessagebox.h> 40#include <qmessagebox.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qfile.h> 43#include <qfile.h>
44 44
45/* STD */ 45/* STD */
46#include <sys/types.h> 46#include <sys/types.h>
47#include <time.h> 47#include <time.h>
48#include <sys/time.h> 48#include <sys/time.h>
49#include <sys/resource.h> 49#include <sys/resource.h>
50#include <unistd.h> 50#include <unistd.h>
51#include <syslog.h> 51#include <syslog.h>
52#include <sys/wait.h> 52#include <sys/wait.h>
53#include <stdio.h> 53#include <stdio.h>
54#include <stdlib.h> 54#include <stdlib.h>
55#include <signal.h> 55#include <signal.h>
56#include <getopt.h> 56#include <getopt.h>
57#include <string.h> 57#include <string.h>
58 58
59using namespace Opie::Core; 59using namespace Opie::Core;
60 60
61int login_main ( int argc, char **argv, pid_t ppid ); 61int login_main ( int argc, char **argv, pid_t ppid );
62void sigterm ( int sig ); 62void sigterm ( int sig );
63void sigint ( int sig ); 63void sigint ( int sig );
64void exit_closelog ( ); 64void exit_closelog ( );
65 65
66static struct option long_options [] = { 66static struct option long_options [] = {
67 { "autologin", 1, 0, 'a' }, 67 { "autologin", 1, 0, 'a' },
68 { 0, 0, 0, 0 } 68 { 0, 0, 0, 0 }
69}; 69};
70 70
71 71
72int main ( int argc, char **argv ) 72int main ( int argc, char **argv )
73{ 73{
74 int userExited = 0; 74 int userExited = 0;
75 pid_t ppid = ::getpid ( ); 75 pid_t ppid = ::getpid ( );
76 76
77 if ( ::geteuid ( ) != 0 ) { 77 if ( ::geteuid ( ) != 0 ) {
78 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); 78 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] );
79 return 1; 79 return 1;
80 } 80 }
81 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and 81 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and
82 ::setuid ( 0 ); // messes up things like config files 82 ::setuid ( 0 ); // messes up things like config files
83 83
84 char *autolog = 0; 84 char *autolog = 0;
85 int c; 85 int c;
86 while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { 86 while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) {
87 switch ( c ) { 87 switch ( c ) {
88 case 'a': 88 case 'a':
89 autolog = optarg; 89 autolog = optarg;
90 break; 90 break;
91 default: 91 default:
92 ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); 92 ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] );
93 return 2; 93 return 2;
94 } 94 }
95 } 95 }
96 96
97 //struct rlimit rl; 97 //struct rlimit rl;
98 //::getrlimit ( RLIMIT_NOFILE, &rl ); 98 //::getrlimit ( RLIMIT_NOFILE, &rl );
99 99
100 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) 100 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ )
101 // ::close ( i ); 101 // ::close ( i );
102 102
103 ::setpgid ( 0, 0 ); 103 ::setpgid ( 0, 0 );
104 ::setsid ( ); 104 ::setsid ( );
105 105
106 ::signal ( SIGTERM, sigterm ); 106 ::signal ( SIGTERM, sigterm );
@@ -228,151 +228,146 @@ public:
228 LoginScreenSaver ( ) 228 LoginScreenSaver ( )
229 { 229 {
230 m_lcd_status = true; 230 m_lcd_status = true;
231 231
232 m_backlight_bright = -1; 232 m_backlight_bright = -1;
233 m_backlight_forcedoff = false; 233 m_backlight_forcedoff = false;
234 234
235 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 235 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
236 ODevice::inst ( )-> setDisplayStatus ( true ); 236 ODevice::inst ( )-> setDisplayStatus ( true );
237 } 237 }
238 void restore() 238 void restore()
239 { 239 {
240 if ( !m_lcd_status ) // We must have turned it off 240 if ( !m_lcd_status ) // We must have turned it off
241 ODevice::inst ( ) -> setDisplayStatus ( true ); 241 ODevice::inst ( ) -> setDisplayStatus ( true );
242 242
243 setBacklight ( -3 ); 243 setBacklight ( -3 );
244 } 244 }
245 bool save( int level ) 245 bool save( int level )
246 { 246 {
247 switch ( level ) { 247 switch ( level ) {
248 case 0: 248 case 0:
249 if ( backlight() > 1 ) 249 if ( backlight() > 1 )
250 setBacklight( 1 ); // lowest non-off 250 setBacklight( 1 ); // lowest non-off
251 return true; 251 return true;
252 break; 252 break;
253 case 1: 253 case 1:
254 setBacklight( 0 ); // off 254 setBacklight( 0 ); // off
255 return true; 255 return true;
256 break; 256 break;
257 case 2: 257 case 2:
258 // We're going to suspend the whole machine 258 // We're going to suspend the whole machine
259 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { 259 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) {
260 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 260 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
261 return true; 261 return true;
262 } 262 }
263 break; 263 break;
264 } 264 }
265 return false; 265 return false;
266 } 266 }
267 267
268private: 268private:
269public: 269public:
270 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) 270 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 )
271 { 271 {
272 int v [4]; 272 int v [4];
273 273
274 v [ 0 ] = QMAX( 1000 * i1, 100 ); 274 v [ 0 ] = QMAX( 1000 * i1, 100 );
275 v [ 1 ] = QMAX( 1000 * i2, 100 ); 275 v [ 1 ] = QMAX( 1000 * i2, 100 );
276 v [ 2 ] = QMAX( 1000 * i3, 100 ); 276 v [ 2 ] = QMAX( 1000 * i3, 100 );
277 v [ 3 ] = 0; 277 v [ 3 ] = 0;
278 278
279 if ( !i1 && !i2 && !i3 ) 279 if ( !i1 && !i2 && !i3 )
280 QWSServer::setScreenSaverInterval ( 0 ); 280 QWSServer::setScreenSaverInterval ( 0 );
281 else 281 else
282 QWSServer::setScreenSaverIntervals ( v ); 282 QWSServer::setScreenSaverIntervals ( v );
283 } 283 }
284 284
285 int backlight ( ) 285 int backlight ( )
286 { 286 {
287 if ( m_backlight_bright == -1 ) 287 if ( m_backlight_bright == -1 )
288 m_backlight_bright = 255; 288 m_backlight_bright = 255;
289 289
290 return m_backlight_bright; 290 return m_backlight_bright;
291 } 291 }
292 292
293 void setBacklight ( int bright ) 293 void setBacklight ( int bright )
294 { 294 {
295 if ( bright == -3 ) { 295 if ( bright == -3 ) {
296 // Forced on 296 // Forced on
297 m_backlight_forcedoff = false; 297 m_backlight_forcedoff = false;
298 bright = -1; 298 bright = -1;
299 } 299 }
300 if ( m_backlight_forcedoff && bright != -2 ) 300 if ( m_backlight_forcedoff && bright != -2 )
301 return ; 301 return ;
302 if ( bright == -2 ) { 302 if ( bright == -2 ) {
303 // Toggle between off and on 303 // Toggle between off and on
304 bright = m_backlight_bright ? 0 : -1; 304 bright = m_backlight_bright ? 0 : -1;
305 m_backlight_forcedoff = !bright; 305 m_backlight_forcedoff = !bright;
306 } 306 }
307 307
308 m_backlight_bright = bright; 308 m_backlight_bright = bright;
309 309
310 bright = backlight ( ); 310 bright = backlight ( );
311 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 311 ODevice::inst ( ) -> setDisplayBrightness ( bright );
312 312
313 m_backlight_bright = bright; 313 m_backlight_bright = bright;
314 } 314 }
315 315
316private: 316private:
317 bool m_lcd_status; 317 bool m_lcd_status;
318 318
319 int m_backlight_bright; 319 int m_backlight_bright;
320 bool m_backlight_forcedoff; 320 bool m_backlight_forcedoff;
321}; 321};
322 322
323 323
324namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting
325
326
327int login_main ( int argc, char **argv, pid_t ppid ) 324int login_main ( int argc, char **argv, pid_t ppid )
328{ 325{
329 QWSServer::setDesktopBackground( QImage() ); 326 QWSServer::setDesktopBackground( QImage() );
330 LoginApplication *app = new LoginApplication ( argc, argv, ppid ); 327 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
331 328
332 Opie::force_appearance = 0;
333
334 app-> setFont ( QFont ( "Helvetica", 10 )); 329 app-> setFont ( QFont ( "Helvetica", 10 ));
335 app-> setStyle ( new QPEStyle ( )); 330 app-> setStyle ( new QPEStyle ( ));
336 331
337 if ( QWSServer::mouseHandler() && 332 if ( QWSServer::mouseHandler() &&
338 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { 333 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
339 if ( !QFile::exists ( "/etc/pointercal" )) { 334 if ( !QFile::exists ( "/etc/pointercal" )) {
340 // Make sure calibration widget starts on top. 335 // Make sure calibration widget starts on top.
341 Calibrate *cal = new Calibrate; 336 Calibrate *cal = new Calibrate;
342 cal-> exec ( ); 337 cal-> exec ( );
343 delete cal; 338 delete cal;
344 } 339 }
345 } 340 }
346 341
347 LoginScreenSaver *saver = new LoginScreenSaver; 342 LoginScreenSaver *saver = new LoginScreenSaver;
348 343
349 saver-> setIntervals ( ); 344 saver-> setIntervals ( );
350 QWSServer::setScreenSaver ( saver ); 345 QWSServer::setScreenSaver ( saver );
351 saver-> restore ( ); 346 saver-> restore ( );
352 347
353 348
354 LoginWindowImpl *lw = new LoginWindowImpl ( ); 349 LoginWindowImpl *lw = new LoginWindowImpl ( );
355 app-> setMainWidget ( lw ); 350 app-> setMainWidget ( lw );
356 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 351 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
357 lw-> show ( ); 352 lw-> show ( );
358 353
359 int rc = app-> exec ( ); 354 int rc = app-> exec ( );
360 355
361 if ( app-> loginAs ( )) { 356 if ( app-> loginAs ( )) {
362 if ( app-> changeIdentity ( )) { 357 if ( app-> changeIdentity ( )) {
363 app-> login ( ); 358 app-> login ( );
364 359
365 // if login succeeds, it never comes back 360 // if login succeeds, it never comes back
366 361
367 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." )); 362 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start Opie." ));
368 rc = 1; 363 rc = 1;
369 } 364 }
370 else { 365 else {
371 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" )); 366 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" ));
372 rc = 2; 367 rc = 2;
373 } 368 }
374 369
375 } 370 }
376 return rc; 371 return rc;
377} 372}
378 373