-rw-r--r-- | core/launcher/serverapp.cpp | 278 |
1 files changed, 138 insertions, 140 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index 807942d..54cc313 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -98,10 +98,10 @@ public: | |||
98 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 98 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
99 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), | 99 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), |
100 | QMessageBox::Critical, | 100 | QMessageBox::Critical, |
101 | QMessageBox::Ok | QMessageBox::Default, | 101 | QMessageBox::Ok | QMessageBox::Default, |
102 | QMessageBox::NoButton, QMessageBox::NoButton, | 102 | QMessageBox::NoButton, QMessageBox::NoButton, |
103 | parent, name, FALSE ) | 103 | parent, name, FALSE ) |
104 | { | 104 | { |
105 | currentPriority = INT_MAX; | 105 | currentPriority = INT_MAX; |
106 | alertCount = 0; | 106 | alertCount = 0; |
107 | } | 107 | } |
@@ -119,5 +119,5 @@ void DesktopPowerAlerter::alert( const QString &text, int priority ) | |||
119 | if ( alertCount < priority ) | 119 | if ( alertCount < priority ) |
120 | return; | 120 | return; |
121 | if ( priority > currentPriority ) | 121 | if ( priority > currentPriority ) |
122 | return; | 122 | return; |
123 | currentPriority = priority; | 123 | currentPriority = priority; |
@@ -148,9 +148,9 @@ void KeyFilter::timerEvent(QTimerEvent* e) | |||
148 | if ( e->timerId() == held_tid ) { | 148 | if ( e->timerId() == held_tid ) { |
149 | killTimer(held_tid); | 149 | killTimer(held_tid); |
150 | // button held | 150 | // button held |
151 | if ( heldButton ) { | 151 | if ( heldButton ) { |
152 | emit activate(heldButton, TRUE); | 152 | emit activate(heldButton, TRUE); |
153 | heldButton = 0; | 153 | heldButton = 0; |
154 | } | 154 | } |
155 | held_tid = 0; | 155 | held_tid = 0; |
156 | } | 156 | } |
@@ -180,13 +180,13 @@ bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepe | |||
180 | if ( !loggedin | 180 | if ( !loggedin |
181 | // Permitted keys | 181 | // Permitted keys |
182 | && keycode != Key_F34 // power | 182 | && keycode != Key_F34 // power |
183 | && keycode != Key_F30 // select | 183 | && keycode != Key_F30 // select |
184 | && keycode != Key_Enter | 184 | && keycode != Key_Enter |
185 | && keycode != Key_Return | 185 | && keycode != Key_Return |
186 | && keycode != Key_Space | 186 | && keycode != Key_Space |
187 | && keycode != Key_Left | 187 | && keycode != Key_Left |
188 | && keycode != Key_Right | 188 | && keycode != Key_Right |
189 | && keycode != Key_Up | 189 | && keycode != Key_Up |
190 | && keycode != Key_Down ) | 190 | && keycode != Key_Down ) |
191 | return TRUE; | 191 | return TRUE; |
192 | 192 | ||
@@ -322,3 +322,3 @@ ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | |||
322 | if ( PluginLoader::inSafeMode() ) | 322 | if ( PluginLoader::inSafeMode() ) |
323 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); | 323 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); |
324 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); | 324 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); |
@@ -381,11 +381,11 @@ void ServerApplication::apmTimeout() { | |||
381 | if ( bat <= m_powerCritical ) { | 381 | if ( bat <= m_powerCritical ) { |
382 | QMessageBox battlow( | 382 | QMessageBox battlow( |
383 | tr("WARNING"), | 383 | tr("WARNING"), |
384 | tr("<p>The battery level is critical!" | 384 | tr("<p>The battery level is critical!" |
385 | "<p>Keep power off until AC is restored"), | 385 | "<p>Keep power off until AC is restored"), |
386 | QMessageBox::Warning, | 386 | QMessageBox::Warning, |
387 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 387 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
388 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 388 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
389 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); | 389 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); |
390 | battlow.exec(); | 390 | battlow.exec(); |
391 | } else if ( bat <= m_powerVeryLow ) | 391 | } else if ( bat <= m_powerVeryLow ) |
@@ -395,11 +395,11 @@ void ServerApplication::apmTimeout() { | |||
395 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { | 395 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { |
396 | QMessageBox battlow( | 396 | QMessageBox battlow( |
397 | tr("WARNING"), | 397 | tr("WARNING"), |
398 | tr("<p>The Back-up battery is very low" | 398 | tr("<p>The Back-up battery is very low" |
399 | "<p>Please charge the back-up battery"), | 399 | "<p>Please charge the back-up battery"), |
400 | QMessageBox::Warning, | 400 | QMessageBox::Warning, |
401 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 401 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
402 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 402 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
403 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); | 403 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); |
404 | battlow.exec(); | 404 | battlow.exec(); |
405 | } | 405 | } |
@@ -497,7 +497,7 @@ void ServerApplication::login(bool at_poweron) | |||
497 | if ( !loggedin ) { | 497 | if ( !loggedin ) { |
498 | Global::terminateBuiltin("calibrate"); // No tr | 498 | Global::terminateBuiltin("calibrate"); // No tr |
499 | Password::authenticate(at_poweron); | 499 | Password::authenticate(at_poweron); |
500 | loggedin=1; | 500 | loggedin=1; |
501 | #ifndef QT_NO_COP | 501 | #ifndef QT_NO_COP |
502 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 502 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
503 | #endif | 503 | #endif |
@@ -549,16 +549,16 @@ namespace { | |||
549 | QString appName; | 549 | QString appName; |
550 | int delay; | 550 | int delay; |
551 | QDateTime now = QDateTime::currentDateTime(); | 551 | QDateTime now = QDateTime::currentDateTime(); |
552 | 552 | ||
553 | Config cfg( "autostart" ); | 553 | Config cfg( "autostart" ); |
554 | cfg.setGroup( "AutoStart" ); | 554 | cfg.setGroup( "AutoStart" ); |
555 | appName = cfg.readEntry( "Apps", "" ); | 555 | appName = cfg.readEntry( "Apps", "" ); |
556 | delay = cfg.readNumEntry( "Delay", 0 ); | 556 | delay = cfg.readNumEntry( "Delay", 0 ); |
557 | 557 | ||
558 | // If the time between suspend and resume was longer then the | 558 | // If the time between suspend and resume was longer then the |
559 | // value saved as delay, start the app | 559 | // value saved as delay, start the app |
560 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 560 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
561 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 561 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
562 | e << QString( appName ); | 562 | e << QString( appName ); |
563 | } | 563 | } |
564 | } | 564 | } |
@@ -569,12 +569,12 @@ void ServerApplication::togglePower() | |||
569 | { | 569 | { |
570 | static bool excllock = false; | 570 | static bool excllock = false; |
571 | 571 | ||
572 | if ( excllock ) | 572 | if ( excllock ) |
573 | return ; | 573 | return ; |
574 | 574 | ||
575 | excllock = true; | 575 | excllock = true; |
576 | 576 | ||
577 | bool wasloggedin = loggedin; | 577 | bool wasloggedin = loggedin; |
578 | loggedin = 0; | 578 | loggedin = 0; |
579 | m_suspendTime = QDateTime::currentDateTime(); | 579 | m_suspendTime = QDateTime::currentDateTime(); |
580 | 580 | ||
@@ -582,27 +582,27 @@ void ServerApplication::togglePower() | |||
582 | 582 | ||
583 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | 583 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
584 | // Should use a big black window instead. | 584 | // Should use a big black window instead. |
585 | // But this would not show up fast enough | 585 | // But this would not show up fast enough |
586 | QGfx *g = qt_screen-> screenGfx ( ); | 586 | QGfx *g = qt_screen-> screenGfx ( ); |
587 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 587 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
588 | delete g; | 588 | delete g; |
589 | } | 589 | } |
590 | #endif | 590 | #endif |
591 | 591 | ||
592 | ODevice::inst ( )-> suspend ( ); | 592 | ODevice::inst ( )-> suspend ( ); |
593 | 593 | ||
594 | ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call | 594 | ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call |
595 | QWSServer::screenSaverActivate ( false ); | 595 | QWSServer::screenSaverActivate ( false ); |
596 | 596 | ||
597 | { | 597 | { |
598 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 598 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
599 | } | 599 | } |
600 | 600 | ||
601 | if ( wasloggedin ) | 601 | if ( wasloggedin ) |
602 | login ( true ); | 602 | login ( true ); |
603 | 603 | ||
604 | execAutoStart(m_suspendTime); | 604 | execAutoStart(m_suspendTime); |
605 | //qcopBridge->closeOpenConnections(); | 605 | //qcopBridge->closeOpenConnections(); |
606 | 606 | ||
607 | excllock = false; | 607 | excllock = false; |
608 | } | 608 | } |
@@ -644,13 +644,13 @@ bool ServerApplication::qwsEventFilter( QWSEvent *e ) | |||
644 | if ( e->type == QWSEvent::Mouse ) { | 644 | if ( e->type == QWSEvent::Mouse ) { |
645 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 645 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
646 | static bool up = TRUE; | 646 | static bool up = TRUE; |
647 | if ( me->simpleData.state&LeftButton ) { | 647 | if ( me->simpleData.state&LeftButton ) { |
648 | if ( up ) { | 648 | if ( up ) { |
649 | up = FALSE; | 649 | up = FALSE; |
650 | screenClick(TRUE); | 650 | screenClick(TRUE); |
651 | } | 651 | } |
652 | } else if ( !up ) { | 652 | } else if ( !up ) { |
653 | up = TRUE; | 653 | up = TRUE; |
654 | screenClick(FALSE); | 654 | screenClick(FALSE); |
655 | } | 655 | } |
656 | }else if ( e->type == QWSEvent::Key ) { | 656 | }else if ( e->type == QWSEvent::Key ) { |
@@ -675,7 +675,7 @@ void ServerApplication::showSafeMode() | |||
675 | if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " | 675 | if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " |
676 | "and the system is now in Safe Mode. " | 676 | "and the system is now in Safe Mode. " |
677 | "Plugins are not loaded in Safe Mode. " | 677 | "Plugins are not loaded in Safe Mode. " |
678 | "You can use the Plugin Manager to " | 678 | "You can use the Plugin Manager to " |
679 | "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) { | 679 | "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) { |
680 | Global::execute( "pluginmanager" ); | 680 | Global::execute( "pluginmanager" ); |
681 | } | 681 | } |
@@ -693,3 +693,3 @@ void ServerApplication::clearSafeMode() | |||
693 | if ( mode == "MaybeSafe" ) { | 693 | if ( mode == "MaybeSafe" ) { |
694 | cfg.writeEntry( "Mode", "Normal" ); | 694 | cfg.writeEntry( "Mode", "Normal" ); |
695 | } | 695 | } |
@@ -702,9 +702,7 @@ void ServerApplication::shutdown() | |||
702 | if ( type() != GuiServer ) | 702 | if ( type() != GuiServer ) |
703 | return; | 703 | return; |
704 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 704 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
705 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), | 705 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), |
706 | this, SLOT(shutdown(ShutdownImpl::Type)) ); | 706 | this, SLOT(shutdown(ShutdownImpl::Type)) ); |
707 | QPEApplication::showWidget( sd ); | 707 | QPEApplication::showWidget( sd ); |
708 | sd->move(0,0); | ||
709 | |||
710 | } | 708 | } |
@@ -725,3 +723,3 @@ void ServerApplication::shutdown( ShutdownImpl::Type t ) | |||
725 | perror("shutdown"); | 723 | perror("shutdown"); |
726 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); | 724 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); |
727 | 725 | ||
@@ -759,5 +757,5 @@ void ServerApplication::restart() | |||
759 | emit aboutToQuit(); | 757 | emit aboutToQuit(); |
760 | prepareForTermination(TRUE); | 758 | prepareForTermination(TRUE); |
761 | doRestart = TRUE; | 759 | doRestart = TRUE; |
762 | quit(); | 760 | quit(); |
763 | #else | 761 | #else |
@@ -765,3 +763,3 @@ void ServerApplication::restart() | |||
765 | for ( int fd = 3; fd < 100; fd++ ) | 763 | for ( int fd = 3; fd < 100; fd++ ) |
766 | close( fd ); | 764 | close( fd ); |
767 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); | 765 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); |
@@ -790,3 +788,3 @@ void ServerApplication::checkMemory() | |||
790 | if(existingMessage) | 788 | if(existingMessage) |
791 | return; // don't show a second message while still on first | 789 | return; // don't show a second message while still on first |
792 | 790 | ||
@@ -794,27 +792,27 @@ void ServerApplication::checkMemory() | |||
794 | switch ( memstate ) { | 792 | switch ( memstate ) { |
795 | case MemUnknown: | 793 | case MemUnknown: |
796 | break; | 794 | break; |
797 | case MemLow: | 795 | case MemLow: |
798 | memstate = MemUnknown; | 796 | memstate = MemUnknown; |
799 | if ( !recoverMemory() ) { | 797 | if ( !recoverMemory() ) { |
800 | QMessageBox::warning( 0 , tr("Memory Status"), | 798 | QMessageBox::warning( 0 , tr("Memory Status"), |
801 | tr("Memory Low\nPlease save data.") ); | 799 | tr("Memory Low\nPlease save data.") ); |
802 | ignoreNormal = FALSE; | 800 | ignoreNormal = FALSE; |
803 | } | 801 | } |
804 | break; | 802 | break; |
805 | case MemNormal: | 803 | case MemNormal: |
806 | memstate = MemUnknown; | 804 | memstate = MemUnknown; |
807 | if ( !ignoreNormal ) { | 805 | if ( !ignoreNormal ) { |
808 | ignoreNormal = TRUE; | 806 | ignoreNormal = TRUE; |
809 | QMessageBox::information ( 0 , tr("Memory Status"), | 807 | QMessageBox::information ( 0 , tr("Memory Status"), |
810 | "Memory OK" ); | 808 | "Memory OK" ); |
811 | } | 809 | } |
812 | break; | 810 | break; |
813 | case MemVeryLow: | 811 | case MemVeryLow: |
814 | memstate = MemUnknown; | 812 | memstate = MemUnknown; |
815 | QMessageBox::critical( 0 , tr("Memory Status"), | 813 | QMessageBox::critical( 0 , tr("Memory Status"), |
816 | tr("Critical Memory Shortage\n" | 814 | tr("Critical Memory Shortage\n" |
817 | "Please end this application\n" | 815 | "Please end this application\n" |
818 | "immediately.") ); | 816 | "immediately.") ); |
819 | recoverMemory(); | 817 | recoverMemory(); |
820 | } | 818 | } |
@@ -849,3 +847,3 @@ ServerApplication *ServerApplication::me ( ) | |||
849 | { | 847 | { |
850 | return static_cast<ServerApplication*>( qApp ); | 848 | return static_cast<ServerApplication*>( qApp ); |
851 | } | 849 | } |