-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 | |||
@@ -83,125 +83,125 @@ bool QCopKeyRegister::send() { | |||
83 | QCopEnvelope( m_channel, m_message ); | 83 | QCopEnvelope( m_channel, m_message ); |
84 | 84 | ||
85 | return true; | 85 | return true; |
86 | } | 86 | } |
87 | 87 | ||
88 | //--------------------------------------------------------------------------- | 88 | //--------------------------------------------------------------------------- |
89 | 89 | ||
90 | /* | 90 | /* |
91 | Priority is number of alerts that are needed to pop up | 91 | Priority is number of alerts that are needed to pop up |
92 | alert. | 92 | alert. |
93 | */ | 93 | */ |
94 | class DesktopPowerAlerter : public QMessageBox | 94 | class DesktopPowerAlerter : public QMessageBox |
95 | { | 95 | { |
96 | Q_OBJECT | 96 | Q_OBJECT |
97 | public: | 97 | 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 | } |
108 | 108 | ||
109 | void alert( const QString &text, int priority ); | 109 | void alert( const QString &text, int priority ); |
110 | void hideEvent( QHideEvent * ); | 110 | void hideEvent( QHideEvent * ); |
111 | private: | 111 | private: |
112 | int currentPriority; | 112 | int currentPriority; |
113 | int alertCount; | 113 | int alertCount; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 116 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
117 | { | 117 | { |
118 | alertCount++; | 118 | alertCount++; |
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; |
124 | setText( text ); | 124 | setText( text ); |
125 | show(); | 125 | show(); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 129 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
130 | { | 130 | { |
131 | QMessageBox::hideEvent( e ); | 131 | QMessageBox::hideEvent( e ); |
132 | alertCount = 0; | 132 | alertCount = 0; |
133 | currentPriority = INT_MAX; | 133 | currentPriority = INT_MAX; |
134 | } | 134 | } |
135 | 135 | ||
136 | //--------------------------------------------------------------------------- | 136 | //--------------------------------------------------------------------------- |
137 | 137 | ||
138 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) | 138 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) |
139 | { | 139 | { |
140 | /* We don't do this cause it would interfere with ODevice */ | 140 | /* We don't do this cause it would interfere with ODevice */ |
141 | #if 0 | 141 | #if 0 |
142 | qwsServer->setKeyboardFilter(this); | 142 | qwsServer->setKeyboardFilter(this); |
143 | #endif | 143 | #endif |
144 | } | 144 | } |
145 | 145 | ||
146 | void KeyFilter::timerEvent(QTimerEvent* e) | 146 | void KeyFilter::timerEvent(QTimerEvent* e) |
147 | { | 147 | { |
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 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { | 159 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { |
160 | m_keys.insert( key.keyCode(), key ); | 160 | m_keys.insert( key.keyCode(), key ); |
161 | } | 161 | } |
162 | 162 | ||
163 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { | 163 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { |
164 | m_keys.remove( key.keyCode() ); | 164 | m_keys.remove( key.keyCode() ); |
165 | } | 165 | } |
166 | 166 | ||
167 | bool KeyFilter::keyRegistered( int key ) { | 167 | bool KeyFilter::keyRegistered( int key ) { |
168 | /* | 168 | /* |
169 | * Check if we've a key registered | 169 | * Check if we've a key registered |
170 | */ | 170 | */ |
171 | if ( !m_keys[key].send()) | 171 | if ( !m_keys[key].send()) |
172 | return false; | 172 | return false; |
173 | else | 173 | else |
174 | return true; | 174 | return true; |
175 | 175 | ||
176 | } | 176 | } |
177 | 177 | ||
178 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | 178 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) |
179 | { | 179 | { |
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 | ||
193 | /* check if it was registered */ | 193 | /* check if it was registered */ |
194 | if (!db ) { | 194 | if (!db ) { |
195 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | 195 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) |
196 | return true; | 196 | return true; |
197 | }else { | 197 | }else { |
198 | 198 | ||
199 | 199 | ||
200 | // First check to see if DeviceButtonManager knows something about this button: | 200 | // First check to see if DeviceButtonManager knows something about this button: |
201 | const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); | 201 | const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); |
202 | if (button && !autoRepeat) { | 202 | if (button && !autoRepeat) { |
203 | if ( held_tid ) { | 203 | if ( held_tid ) { |
204 | killTimer(held_tid); | 204 | killTimer(held_tid); |
205 | held_tid = 0; | 205 | held_tid = 0; |
206 | } | 206 | } |
207 | if ( button->heldAction().isNull() ) { | 207 | if ( button->heldAction().isNull() ) { |
@@ -307,33 +307,33 @@ ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | |||
307 | 307 | ||
308 | channel = new QCopChannel("QPE/Launcher", this ); | 308 | channel = new QCopChannel("QPE/Launcher", this ); |
309 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), | 309 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), |
310 | this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) ); | 310 | this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) ); |
311 | 311 | ||
312 | m_screensaver = new OpieScreenSaver(); | 312 | m_screensaver = new OpieScreenSaver(); |
313 | m_screensaver->setInterval( -1 ); | 313 | m_screensaver->setInterval( -1 ); |
314 | QWSServer::setScreenSaver( m_screensaver ); | 314 | QWSServer::setScreenSaver( m_screensaver ); |
315 | 315 | ||
316 | connect( qApp, SIGNAL( volumeChanged(bool) ), | 316 | connect( qApp, SIGNAL( volumeChanged(bool) ), |
317 | this, SLOT( rereadVolumes() ) ); | 317 | this, SLOT( rereadVolumes() ) ); |
318 | 318 | ||
319 | 319 | ||
320 | /* ### PluginLoader libqtopia SafeMode */ | 320 | /* ### PluginLoader libqtopia SafeMode */ |
321 | #if 0 | 321 | #if 0 |
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()) ); |
325 | #endif | 325 | #endif |
326 | 326 | ||
327 | kf = new KeyFilter(this); | 327 | kf = new KeyFilter(this); |
328 | 328 | ||
329 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); | 329 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); |
330 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); | 330 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); |
331 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); | 331 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); |
332 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); | 332 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); |
333 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); | 333 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); |
334 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); | 334 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); |
335 | connect( kf, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), | 335 | connect( kf, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), |
336 | this,SIGNAL(activate(const Opie::Core::ODeviceButton*,bool))); | 336 | this,SIGNAL(activate(const Opie::Core::ODeviceButton*,bool))); |
337 | 337 | ||
338 | 338 | ||
339 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); | 339 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); |
@@ -366,55 +366,55 @@ ServerApplication::~ServerApplication() | |||
366 | void ServerApplication::apmTimeout() { | 366 | void ServerApplication::apmTimeout() { |
367 | serverApp-> checkMemory( ); // in case no events are generated | 367 | serverApp-> checkMemory( ); // in case no events are generated |
368 | *m_ps_last = *m_ps; | 368 | *m_ps_last = *m_ps; |
369 | *m_ps = PowerStatusManager::readStatus(); | 369 | *m_ps = PowerStatusManager::readStatus(); |
370 | 370 | ||
371 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) | 371 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) |
372 | m_screensaver-> powerStatusChanged( *m_ps ); | 372 | m_screensaver-> powerStatusChanged( *m_ps ); |
373 | 373 | ||
374 | if ( m_ps->acStatus() == PowerStatus::Online ) { | 374 | if ( m_ps->acStatus() == PowerStatus::Online ) { |
375 | return; | 375 | return; |
376 | } | 376 | } |
377 | 377 | ||
378 | int bat = m_ps-> batteryPercentRemaining(); | 378 | int bat = m_ps-> batteryPercentRemaining(); |
379 | 379 | ||
380 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { | 380 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { |
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 ) |
392 | pa->alert( tr( "The battery is running very low. "), 2 ); | 392 | pa->alert( tr( "The battery is running very low. "), 2 ); |
393 | } | 393 | } |
394 | 394 | ||
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 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | void ServerApplication::systemMessage( const QCString& msg, | 408 | void ServerApplication::systemMessage( const QCString& msg, |
409 | const QByteArray& data ) { | 409 | const QByteArray& data ) { |
410 | QDataStream stream ( data, IO_ReadOnly ); | 410 | QDataStream stream ( data, IO_ReadOnly ); |
411 | 411 | ||
412 | if ( msg == "setScreenSaverInterval(int)" ) { | 412 | if ( msg == "setScreenSaverInterval(int)" ) { |
413 | int time; | 413 | int time; |
414 | stream >> time; | 414 | stream >> time; |
415 | m_screensaver-> setInterval( time ); | 415 | m_screensaver-> setInterval( time ); |
416 | } | 416 | } |
417 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 417 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
418 | int t1, t2, t3; | 418 | int t1, t2, t3; |
419 | stream >> t1 >> t2 >> t3; | 419 | stream >> t1 >> t2 >> t3; |
420 | m_screensaver-> setIntervals( t1, t2, t3 ); | 420 | m_screensaver-> setIntervals( t1, t2, t3 ); |
@@ -482,37 +482,37 @@ void ServerApplication::launcherMessage( const QCString & msg, const QByteArray | |||
482 | QCString c, m; | 482 | QCString c, m; |
483 | stream >> k >> c >> m; | 483 | stream >> k >> c >> m; |
484 | 484 | ||
485 | kf -> registerKey( QCopKeyRegister(k, c, m) ); | 485 | kf -> registerKey( QCopKeyRegister(k, c, m) ); |
486 | } | 486 | } |
487 | } | 487 | } |
488 | 488 | ||
489 | 489 | ||
490 | bool ServerApplication::screenLocked() | 490 | bool ServerApplication::screenLocked() |
491 | { | 491 | { |
492 | return loggedin == 0; | 492 | return loggedin == 0; |
493 | } | 493 | } |
494 | 494 | ||
495 | void ServerApplication::login(bool at_poweron) | 495 | void ServerApplication::login(bool at_poweron) |
496 | { | 496 | { |
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 |
504 | } | 504 | } |
505 | } | 505 | } |
506 | 506 | ||
507 | #if defined(QPE_HAVE_TOGGLELIGHT) | 507 | #if defined(QPE_HAVE_TOGGLELIGHT) |
508 | #include <qtopia/config.h> | 508 | #include <qtopia/config.h> |
509 | 509 | ||
510 | #include <sys/ioctl.h> | 510 | #include <sys/ioctl.h> |
511 | #include <sys/types.h> | 511 | #include <sys/types.h> |
512 | #include <fcntl.h> | 512 | #include <fcntl.h> |
513 | #include <unistd.h> | 513 | #include <unistd.h> |
514 | #include <errno.h> | 514 | #include <errno.h> |
515 | #include <linux/ioctl.h> | 515 | #include <linux/ioctl.h> |
516 | #include <time.h> | 516 | #include <time.h> |
517 | #endif | 517 | #endif |
518 | 518 | ||
@@ -534,90 +534,90 @@ static void blankScreen() | |||
534 | blanked = TRUE; | 534 | blanked = TRUE; |
535 | #endif | 535 | #endif |
536 | } | 536 | } |
537 | 537 | ||
538 | static void darkScreen() | 538 | static void darkScreen() |
539 | { | 539 | { |
540 | /* ### Screen blanking ODevice */ | 540 | /* ### Screen blanking ODevice */ |
541 | #if 0 | 541 | #if 0 |
542 | qpe_setBacklight(0); // force off | 542 | qpe_setBacklight(0); // force off |
543 | #endif | 543 | #endif |
544 | } | 544 | } |
545 | #endif | 545 | #endif |
546 | 546 | ||
547 | namespace { | 547 | namespace { |
548 | void execAutoStart(const QDateTime& suspendTime ) { | 548 | void execAutoStart(const QDateTime& suspendTime ) { |
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 | } |
565 | } | 565 | } |
566 | 566 | ||
567 | 567 | ||
568 | void ServerApplication::togglePower() | 568 | 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 | ||
581 | #ifdef QWS | 581 | #ifdef QWS |
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 | } |
609 | 609 | ||
610 | void ServerApplication::toggleLight() | 610 | void ServerApplication::toggleLight() |
611 | { | 611 | { |
612 | #ifndef QT_NO_COP | 612 | #ifndef QT_NO_COP |
613 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 613 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
614 | e << -2; // toggle | 614 | e << -2; // toggle |
615 | #endif | 615 | #endif |
616 | } | 616 | } |
617 | 617 | ||
618 | 618 | ||
619 | /* | 619 | /* |
620 | * We still listen to key events but handle them in | 620 | * We still listen to key events but handle them in |
621 | * a special class | 621 | * a special class |
622 | */ | 622 | */ |
623 | 623 | ||
@@ -629,114 +629,112 @@ bool ServerApplication::eventFilter( QObject *o, QEvent *e) { | |||
629 | QKeyEvent *ke = static_cast<QKeyEvent*>( e ); | 629 | QKeyEvent *ke = static_cast<QKeyEvent*>( e ); |
630 | if ( kf->checkButtonAction( true, ke->key(), | 630 | if ( kf->checkButtonAction( true, ke->key(), |
631 | e->type() == QEvent::KeyPress, | 631 | e->type() == QEvent::KeyPress, |
632 | ke-> isAutoRepeat() )) | 632 | ke-> isAutoRepeat() )) |
633 | return true; | 633 | return true; |
634 | 634 | ||
635 | return QPEApplication::eventFilter( o, e ); | 635 | return QPEApplication::eventFilter( o, e ); |
636 | 636 | ||
637 | } | 637 | } |
638 | 638 | ||
639 | #ifdef Q_WS_QWS | 639 | #ifdef Q_WS_QWS |
640 | bool ServerApplication::qwsEventFilter( QWSEvent *e ) | 640 | bool ServerApplication::qwsEventFilter( QWSEvent *e ) |
641 | { | 641 | { |
642 | checkMemory(); | 642 | checkMemory(); |
643 | 643 | ||
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 ) { |
657 | QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); | 657 | QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); |
658 | if ( kf->checkButtonAction( false, | 658 | if ( kf->checkButtonAction( false, |
659 | ke-> simpleData.keycode, | 659 | ke-> simpleData.keycode, |
660 | ke-> simpleData.is_press, | 660 | ke-> simpleData.is_press, |
661 | ke-> simpleData.is_auto_repeat ) ) | 661 | ke-> simpleData.is_auto_repeat ) ) |
662 | return true; | 662 | return true; |
663 | } | 663 | } |
664 | 664 | ||
665 | return QPEApplication::qwsEventFilter( e ); | 665 | return QPEApplication::qwsEventFilter( e ); |
666 | } | 666 | } |
667 | #endif | 667 | #endif |
668 | 668 | ||
669 | 669 | ||
670 | /* ### FIXME libqtopia Plugin Safe Mode */ | 670 | /* ### FIXME libqtopia Plugin Safe Mode */ |
671 | 671 | ||
672 | void ServerApplication::showSafeMode() | 672 | void ServerApplication::showSafeMode() |
673 | { | 673 | { |
674 | #if 0 | 674 | #if 0 |
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 | } |
682 | #endif | 682 | #endif |
683 | } | 683 | } |
684 | 684 | ||
685 | void ServerApplication::clearSafeMode() | 685 | void ServerApplication::clearSafeMode() |
686 | { | 686 | { |
687 | #if 0 | 687 | #if 0 |
688 | // If we've been running OK for a while then we won't bother going into | 688 | // If we've been running OK for a while then we won't bother going into |
689 | // safe mode immediately on the next crash. | 689 | // safe mode immediately on the next crash. |
690 | Config cfg( "PluginLoader" ); | 690 | Config cfg( "PluginLoader" ); |
691 | cfg.setGroup( "Global" ); | 691 | cfg.setGroup( "Global" ); |
692 | QString mode = cfg.readEntry( "Mode", "Normal" ); | 692 | QString mode = cfg.readEntry( "Mode", "Normal" ); |
693 | if ( mode == "MaybeSafe" ) { | 693 | if ( mode == "MaybeSafe" ) { |
694 | cfg.writeEntry( "Mode", "Normal" ); | 694 | cfg.writeEntry( "Mode", "Normal" ); |
695 | } | 695 | } |
696 | #endif | 696 | #endif |
697 | } | 697 | } |
698 | 698 | ||
699 | 699 | ||
700 | void ServerApplication::shutdown() | 700 | void ServerApplication::shutdown() |
701 | { | 701 | { |
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 | } |
711 | 709 | ||
712 | void ServerApplication::shutdown( ShutdownImpl::Type t ) | 710 | void ServerApplication::shutdown( ShutdownImpl::Type t ) |
713 | { | 711 | { |
714 | char *opt = 0; | 712 | char *opt = 0; |
715 | 713 | ||
716 | switch ( t ) { | 714 | switch ( t ) { |
717 | case ShutdownImpl::ShutdownSystem: | 715 | case ShutdownImpl::ShutdownSystem: |
718 | opt = "-h"; | 716 | opt = "-h"; |
719 | // fall through | 717 | // fall through |
720 | case ShutdownImpl::RebootSystem: | 718 | case ShutdownImpl::RebootSystem: |
721 | if ( opt == 0 ) | 719 | if ( opt == 0 ) |
722 | opt = "-r"; | 720 | opt = "-r"; |
723 | 721 | ||
724 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) | 722 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) |
725 | perror("shutdown"); | 723 | perror("shutdown"); |
726 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); | 724 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); |
727 | 725 | ||
728 | break; | 726 | break; |
729 | case ShutdownImpl::RestartDesktop: | 727 | case ShutdownImpl::RestartDesktop: |
730 | restart(); | 728 | restart(); |
731 | break; | 729 | break; |
732 | case ShutdownImpl::TerminateDesktop: | 730 | case ShutdownImpl::TerminateDesktop: |
733 | prepareForTermination( FALSE ); | 731 | prepareForTermination( FALSE ); |
734 | 732 | ||
735 | // This is a workaround for a Qt bug | 733 | // This is a workaround for a Qt bug |
736 | // clipboard applet has to stop its poll timer, or Qt/E | 734 | // clipboard applet has to stop its poll timer, or Qt/E |
737 | // will hang on quit() right before it emits aboutToQuit() | 735 | // will hang on quit() right before it emits aboutToQuit() |
738 | emit aboutToQuit ( ); | 736 | emit aboutToQuit ( ); |
739 | 737 | ||
740 | quit(); | 738 | quit(); |
741 | break; | 739 | break; |
742 | } | 740 | } |
@@ -744,122 +742,122 @@ void ServerApplication::shutdown( ShutdownImpl::Type t ) | |||
744 | 742 | ||
745 | void ServerApplication::restart() | 743 | void ServerApplication::restart() |
746 | { | 744 | { |
747 | if ( allowRestart ) { | 745 | if ( allowRestart ) { |
748 | 746 | ||
749 | /* | 747 | /* |
750 | * Applets and restart is a problem. Some applets delete | 748 | * Applets and restart is a problem. Some applets delete |
751 | * their widgets even if ownership gets transfered to the | 749 | * their widgets even if ownership gets transfered to the |
752 | * parent (Systray ) but deleting the applet may be unsafe | 750 | * parent (Systray ) but deleting the applet may be unsafe |
753 | * as well ( double deletion ). Some have topLevel widgets | 751 | * as well ( double deletion ). Some have topLevel widgets |
754 | * and when we dlclose and then delete the widget we will | 752 | * and when we dlclose and then delete the widget we will |
755 | * crash and an crash during restart is not nice | 753 | * crash and an crash during restart is not nice |
756 | */ | 754 | */ |
757 | #ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED | 755 | #ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED |
758 | /* same as above */ | 756 | /* same as above */ |
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 |
764 | prepareForTermination( true ); | 762 | prepareForTermination( true ); |
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 ); |
768 | exit( 1 ); | 766 | exit( 1 ); |
769 | #endif | 767 | #endif |
770 | } | 768 | } |
771 | } | 769 | } |
772 | 770 | ||
773 | void ServerApplication::rereadVolumes() | 771 | void ServerApplication::rereadVolumes() |
774 | { | 772 | { |
775 | Config cfg( "qpe" ); | 773 | Config cfg( "qpe" ); |
776 | cfg. setGroup ( "Volume" ); | 774 | cfg. setGroup ( "Volume" ); |
777 | 775 | ||
778 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); | 776 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); |
779 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); | 777 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); |
780 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); | 778 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); |
781 | } | 779 | } |
782 | 780 | ||
783 | 781 | ||
784 | void ServerApplication::checkMemory() | 782 | void ServerApplication::checkMemory() |
785 | { | 783 | { |
786 | #if defined(QPE_HAVE_MEMALERTER) | 784 | #if defined(QPE_HAVE_MEMALERTER) |
787 | static bool ignoreNormal=TRUE; | 785 | static bool ignoreNormal=TRUE; |
788 | static bool existingMessage=FALSE; | 786 | static bool existingMessage=FALSE; |
789 | 787 | ||
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 | ||
793 | existingMessage = TRUE; | 791 | existingMessage = TRUE; |
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 | } |
821 | existingMessage = FALSE; | 819 | existingMessage = FALSE; |
822 | #endif | 820 | #endif |
823 | } | 821 | } |
824 | 822 | ||
825 | bool ServerApplication::recoverMemory() | 823 | bool ServerApplication::recoverMemory() |
826 | { | 824 | { |
827 | return FALSE; | 825 | return FALSE; |
828 | } | 826 | } |
829 | 827 | ||
830 | void ServerApplication::keyClick(int , bool press, bool ) | 828 | void ServerApplication::keyClick(int , bool press, bool ) |
831 | { | 829 | { |
832 | if ( press && m_keyclick_sound ) | 830 | if ( press && m_keyclick_sound ) |
833 | ODevice::inst() -> playKeySound(); | 831 | ODevice::inst() -> playKeySound(); |
834 | 832 | ||
835 | } | 833 | } |
836 | 834 | ||
837 | void ServerApplication::screenClick(bool press) | 835 | void ServerApplication::screenClick(bool press) |
838 | { | 836 | { |
839 | if ( press && m_screentap_sound ) | 837 | if ( press && m_screentap_sound ) |
840 | ODevice::inst() -> playTouchSound(); | 838 | ODevice::inst() -> playTouchSound(); |
841 | } | 839 | } |
842 | 840 | ||
843 | void ServerApplication::soundAlarm() { | 841 | void ServerApplication::soundAlarm() { |
844 | if ( me ()->m_alarm_sound ) | 842 | if ( me ()->m_alarm_sound ) |
845 | ODevice::inst()->playAlarmSound(); | 843 | ODevice::inst()->playAlarmSound(); |
846 | } | 844 | } |
847 | 845 | ||
848 | ServerApplication *ServerApplication::me ( ) | 846 | ServerApplication *ServerApplication::me ( ) |
849 | { | 847 | { |
850 | return static_cast<ServerApplication*>( qApp ); | 848 | return static_cast<ServerApplication*>( qApp ); |
851 | } | 849 | } |
852 | 850 | ||
853 | bool ServerApplication::isStarting() | 851 | bool ServerApplication::isStarting() |
854 | { | 852 | { |
855 | return ms_is_starting; | 853 | return ms_is_starting; |
856 | } | 854 | } |
857 | 855 | ||
858 | int ServerApplication::exec() | 856 | int ServerApplication::exec() |
859 | { | 857 | { |
860 | ms_is_starting = true; | 858 | ms_is_starting = true; |
861 | odebug << "Serverapp - exec" << oendl; | 859 | odebug << "Serverapp - exec" << oendl; |
862 | return QPEApplication::exec(); | 860 | return QPEApplication::exec(); |
863 | } | 861 | } |
864 | 862 | ||
865 | #include "serverapp.moc" | 863 | #include "serverapp.moc" |