author | clem <clem> | 2004-10-08 22:50:28 (UTC) |
---|---|---|
committer | clem <clem> | 2004-10-08 22:50:28 (UTC) |
commit | 2f29d0ec4bb2355f193d744c890add203bd6f2b2 (patch) (unidiff) | |
tree | a703b00b673b9be036415393b53d9c95a5bb87cd /core/launcher/serverapp.cpp | |
parent | dec031cc21181d70e0c806bcf6c228044f7df90b (diff) | |
download | opie-2f29d0ec4bb2355f193d744c890add203bd6f2b2.zip opie-2f29d0ec4bb2355f193d744c890add203bd6f2b2.tar.gz opie-2f29d0ec4bb2355f193d744c890add203bd6f2b2.tar.bz2 |
Big commit thanks to a little feature request :-) We now have an O-menu applet
to lock the PDA immediately, and the internal way to ask for an authentication
(on resume, on start up, on demand or for a simple test) is much cleaner:
it's through MultiauthPassword(int lockMode) (instead of the old bool at_poweron)
-rw-r--r-- | core/launcher/serverapp.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index dc1f2c7..e541d10 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -417,193 +417,194 @@ void ServerApplication::apmTimeout() | |||
417 | battlow.exec(); | 417 | battlow.exec(); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | 420 | ||
421 | void ServerApplication::systemMessage( const QCString& msg, | 421 | void ServerApplication::systemMessage( const QCString& msg, |
422 | const QByteArray& data ) | 422 | const QByteArray& data ) |
423 | { | 423 | { |
424 | QDataStream stream ( data, IO_ReadOnly ); | 424 | QDataStream stream ( data, IO_ReadOnly ); |
425 | 425 | ||
426 | if ( msg == "setScreenSaverInterval(int)" ) { | 426 | if ( msg == "setScreenSaverInterval(int)" ) { |
427 | int time; | 427 | int time; |
428 | stream >> time; | 428 | stream >> time; |
429 | m_screensaver-> setInterval( time ); | 429 | m_screensaver-> setInterval( time ); |
430 | } | 430 | } |
431 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 431 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
432 | int t1, t2, t3; | 432 | int t1, t2, t3; |
433 | stream >> t1 >> t2 >> t3; | 433 | stream >> t1 >> t2 >> t3; |
434 | m_screensaver-> setIntervals( t1, t2, t3 ); | 434 | m_screensaver-> setIntervals( t1, t2, t3 ); |
435 | } | 435 | } |
436 | else if ( msg == "setBacklight(int)" ) { | 436 | else if ( msg == "setBacklight(int)" ) { |
437 | int bright; | 437 | int bright; |
438 | stream >> bright; | 438 | stream >> bright; |
439 | m_screensaver-> setBacklight( bright ); | 439 | m_screensaver-> setBacklight( bright ); |
440 | } | 440 | } |
441 | else if ( msg == "setScreenSaverMode(int)" ) { | 441 | else if ( msg == "setScreenSaverMode(int)" ) { |
442 | int mode; | 442 | int mode; |
443 | stream >> mode; | 443 | stream >> mode; |
444 | m_screensaver-> setMode ( mode ); | 444 | m_screensaver-> setMode ( mode ); |
445 | } | 445 | } |
446 | else if ( msg == "reloadPowerWarnSettings()" ) { | 446 | else if ( msg == "reloadPowerWarnSettings()" ) { |
447 | reloadPowerWarnSettings(); | 447 | reloadPowerWarnSettings(); |
448 | } | 448 | } |
449 | else if ( msg == "setDisplayState(int)" ) { | 449 | else if ( msg == "setDisplayState(int)" ) { |
450 | int state; | 450 | int state; |
451 | stream >> state; | 451 | stream >> state; |
452 | m_screensaver-> setDisplayState ( state != 0 ); | 452 | m_screensaver-> setDisplayState ( state != 0 ); |
453 | } | 453 | } |
454 | else if ( msg == "suspend()" ) { | 454 | else if ( msg == "suspend()" ) { |
455 | emit power(); | 455 | emit power(); |
456 | } | 456 | } |
457 | else if ( msg == "sendBusinessCard()" ) { | 457 | else if ( msg == "sendBusinessCard()" ) { |
458 | QString card = ::getenv ( "HOME" ); | 458 | QString card = ::getenv ( "HOME" ); |
459 | card += "/Applications/addressbook/businesscard.vcf"; | 459 | card += "/Applications/addressbook/businesscard.vcf"; |
460 | 460 | ||
461 | if ( QFile::exists( card ) ) { | 461 | if ( QFile::exists( card ) ) { |
462 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | 462 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); |
463 | QString mimetype = "text/x-vCard"; | 463 | QString mimetype = "text/x-vCard"; |
464 | e << tr( "business card" ) << card << mimetype; | 464 | e << tr( "business card" ) << card << mimetype; |
465 | } | 465 | } |
466 | } | 466 | } |
467 | } | 467 | } |
468 | 468 | ||
469 | void ServerApplication::reloadPowerWarnSettings ( ) | 469 | void ServerApplication::reloadPowerWarnSettings ( ) |
470 | { | 470 | { |
471 | Config cfg ( "apm" ); | 471 | Config cfg ( "apm" ); |
472 | cfg. setGroup ( "Warnings" ); | 472 | cfg. setGroup ( "Warnings" ); |
473 | 473 | ||
474 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); | 474 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); |
475 | 475 | ||
476 | m_apm_timer-> stop ( ); | 476 | m_apm_timer-> stop ( ); |
477 | if ( iv ) | 477 | if ( iv ) |
478 | m_apm_timer-> start ( iv ); | 478 | m_apm_timer-> start ( iv ); |
479 | 479 | ||
480 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); | 480 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); |
481 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); | 481 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); |
482 | } | 482 | } |
483 | 483 | ||
484 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) | 484 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) |
485 | { | 485 | { |
486 | QDataStream stream ( data, IO_ReadOnly ); | 486 | QDataStream stream ( data, IO_ReadOnly ); |
487 | 487 | ||
488 | if ( msg == "deviceButton(int,int,int)" ) { | 488 | if ( msg == "deviceButton(int,int,int)" ) { |
489 | int keycode, press, autoRepeat; | 489 | int keycode, press, autoRepeat; |
490 | stream >> keycode >> press >> autoRepeat; | 490 | stream >> keycode >> press >> autoRepeat; |
491 | 491 | ||
492 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); | 492 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); |
493 | } | 493 | } |
494 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { | 494 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { |
495 | int k; | 495 | int k; |
496 | QCString c, m; | 496 | QCString c, m; |
497 | stream >> k >> c >> m; | 497 | stream >> k >> c >> m; |
498 | 498 | ||
499 | kf -> registerKey( QCopKeyRegister(k, c, m) ); | 499 | kf -> registerKey( QCopKeyRegister(k, c, m) ); |
500 | } | 500 | } |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | bool ServerApplication::screenLocked() | 504 | bool ServerApplication::screenLocked() |
505 | { | 505 | { |
506 | return loggedin == 0; | 506 | return loggedin == 0; |
507 | } | 507 | } |
508 | 508 | ||
509 | void ServerApplication::login(bool at_poweron) | 509 | void ServerApplication::login(bool at_poweron) |
510 | { | 510 | { |
511 | if ( !loggedin ) { | 511 | if ( !loggedin ) { |
512 | Global::terminateBuiltin("calibrate"); // No tr | 512 | Global::terminateBuiltin("calibrate"); // No tr |
513 | Opie::Security::MultiauthPassword::authenticate(at_poweron); | 513 | int lockMode = at_poweron ? Opie::Security::IfPowerOn : Opie::Security::IfResume; |
514 | Opie::Security::MultiauthPassword::authenticate(lockMode); | ||
514 | loggedin=1; | 515 | loggedin=1; |
515 | #ifndef QT_NO_COP | 516 | #ifndef QT_NO_COP |
516 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 517 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
517 | #endif | 518 | #endif |
518 | } | 519 | } |
519 | } | 520 | } |
520 | 521 | ||
521 | #if defined(QPE_HAVE_TOGGLELIGHT) | 522 | #if defined(QPE_HAVE_TOGGLELIGHT) |
522 | #include <qtopia/config.h> | 523 | #include <qtopia/config.h> |
523 | 524 | ||
524 | #include <sys/ioctl.h> | 525 | #include <sys/ioctl.h> |
525 | #include <sys/types.h> | 526 | #include <sys/types.h> |
526 | #include <fcntl.h> | 527 | #include <fcntl.h> |
527 | #include <unistd.h> | 528 | #include <unistd.h> |
528 | #include <errno.h> | 529 | #include <errno.h> |
529 | #include <linux/ioctl.h> | 530 | #include <linux/ioctl.h> |
530 | #include <time.h> | 531 | #include <time.h> |
531 | #endif | 532 | #endif |
532 | 533 | ||
533 | namespace { | 534 | namespace { |
534 | void execAutoStart(const QDateTime& suspendTime ) { | 535 | void execAutoStart(const QDateTime& suspendTime ) { |
535 | QString appName; | 536 | QString appName; |
536 | int delay; | 537 | int delay; |
537 | QDateTime now = QDateTime::currentDateTime(); | 538 | QDateTime now = QDateTime::currentDateTime(); |
538 | 539 | ||
539 | Config cfg( "autostart" ); | 540 | Config cfg( "autostart" ); |
540 | cfg.setGroup( "AutoStart" ); | 541 | cfg.setGroup( "AutoStart" ); |
541 | appName = cfg.readEntry( "Apps", "" ); | 542 | appName = cfg.readEntry( "Apps", "" ); |
542 | delay = cfg.readNumEntry( "Delay", 0 ); | 543 | delay = cfg.readNumEntry( "Delay", 0 ); |
543 | 544 | ||
544 | // If the time between suspend and resume was longer then the | 545 | // If the time between suspend and resume was longer then the |
545 | // value saved as delay, start the app | 546 | // value saved as delay, start the app |
546 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 547 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
547 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 548 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
548 | e << QString( appName ); | 549 | e << QString( appName ); |
549 | } | 550 | } |
550 | } | 551 | } |
551 | } | 552 | } |
552 | 553 | ||
553 | 554 | ||
554 | void ServerApplication::togglePower() | 555 | void ServerApplication::togglePower() |
555 | { | 556 | { |
556 | static bool excllock = false; | 557 | static bool excllock = false; |
557 | 558 | ||
558 | if ( excllock ) | 559 | if ( excllock ) |
559 | return ; | 560 | return ; |
560 | 561 | ||
561 | excllock = true; | 562 | excllock = true; |
562 | 563 | ||
563 | bool wasloggedin = loggedin; | 564 | bool wasloggedin = loggedin; |
564 | loggedin = 0; | 565 | loggedin = 0; |
565 | m_suspendTime = QDateTime::currentDateTime(); | 566 | m_suspendTime = QDateTime::currentDateTime(); |
566 | 567 | ||
567 | #ifdef QWS | 568 | #ifdef QWS |
568 | if ( Opie::Security::MultiauthPassword::needToAuthenticate ( true ) && qt_screen ) { | 569 | if ( Opie::Security::MultiauthPassword::needToAuthenticate ( true ) && qt_screen ) { |
569 | // Should use a big black window instead. | 570 | // Should use a big black window instead. |
570 | // But this would not show up fast enough | 571 | // But this would not show up fast enough |
571 | QGfx *g = qt_screen-> screenGfx ( ); | 572 | QGfx *g = qt_screen-> screenGfx ( ); |
572 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 573 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
573 | delete g; | 574 | delete g; |
574 | } | 575 | } |
575 | #endif | 576 | #endif |
576 | 577 | ||
577 | ODevice::inst ( )-> suspend ( ); | 578 | ODevice::inst ( )-> suspend ( ); |
578 | 579 | ||
579 | ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call | 580 | ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call |
580 | QWSServer::screenSaverActivate ( false ); | 581 | QWSServer::screenSaverActivate ( false ); |
581 | 582 | ||
582 | { | 583 | { |
583 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 584 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
584 | } | 585 | } |
585 | 586 | ||
586 | if ( wasloggedin ) | 587 | if ( wasloggedin ) |
587 | login ( true ); | 588 | login ( true ); |
588 | 589 | ||
589 | execAutoStart(m_suspendTime); | 590 | execAutoStart(m_suspendTime); |
590 | //qcopBridge->closeOpenConnections(); | 591 | //qcopBridge->closeOpenConnections(); |
591 | 592 | ||
592 | excllock = false; | 593 | excllock = false; |
593 | } | 594 | } |
594 | 595 | ||
595 | void ServerApplication::toggleLight() | 596 | void ServerApplication::toggleLight() |
596 | { | 597 | { |
597 | #ifndef QT_NO_COP | 598 | #ifndef QT_NO_COP |
598 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 599 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
599 | e << -2; // toggle | 600 | e << -2; // toggle |
600 | #endif | 601 | #endif |
601 | } | 602 | } |
602 | 603 | ||
603 | 604 | ||
604 | /* | 605 | /* |
605 | * We still listen to key events but handle them in | 606 | * We still listen to key events but handle them in |
606 | * a special class | 607 | * a special class |
607 | */ | 608 | */ |
608 | 609 | ||
609 | bool ServerApplication::eventFilter( QObject *o, QEvent *e) { | 610 | bool ServerApplication::eventFilter( QObject *o, QEvent *e) { |