-rw-r--r-- | core/launcher/serverapp.cpp | 514 |
1 files changed, 355 insertions, 159 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index 6edaa21..522ef07 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -22,2 +22,4 @@ | |||
22 | 22 | ||
23 | #include <opie/odevice.h> | ||
24 | |||
23 | #include <qtopia/password.h> | 25 | #include <qtopia/password.h> |
@@ -25,4 +27,2 @@ | |||
25 | #include <qtopia/power.h> | 27 | #include <qtopia/power.h> |
26 | #include <qtopia/devicebuttonmanager.h> | ||
27 | #include <qtopia/pluginloader.h> | ||
28 | 28 | ||
@@ -50,2 +50,3 @@ | |||
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include "screensaver.h" | ||
51 | 52 | ||
@@ -54,51 +55,31 @@ static int loggedin=0; | |||
54 | 55 | ||
56 | using namespace Opie; | ||
55 | 57 | ||
58 | QCopKeyRegister::QCopKeyRegister() | ||
59 | : m_keyCode( 0 ) { | ||
60 | } | ||
56 | 61 | ||
57 | /* Apply light/power settings for current power source */ | 62 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) |
58 | static void applyLightSettings(PowerStatus *p) | 63 | :m_keyCode( k ), m_channel( c ), m_message( m ) { |
59 | { | 64 | } |
60 | int initbright, intervalDim, intervalLightOff, intervalSuspend; | ||
61 | bool dim, lightoff, suspend; | ||
62 | 65 | ||
63 | { | 66 | int QCopKeyRegister::keyCode()const { |
64 | Config config("qpe"); | 67 | return m_keyCode; |
65 | bool defsus; | ||
66 | if ( p->acStatus() == PowerStatus::Online ) { | ||
67 | config.setGroup("ExternalPower"); | ||
68 | defsus = FALSE; | ||
69 | } else { | ||
70 | config.setGroup("BatteryPower"); | ||
71 | defsus = TRUE; | ||
72 | } | 68 | } |
73 | 69 | ||
74 | intervalDim = config.readNumEntry( "Interval_Dim", 20 ); | 70 | QCString QCopKeyRegister::channel()const { |
75 | intervalLightOff = config.readNumEntry("Interval_LightOff", 30); | 71 | return m_channel; |
76 | intervalSuspend = config.readNumEntry("Interval", 240); | 72 | } |
77 | initbright = config.readNumEntry("Brightness", 255); | ||
78 | dim = config.readBoolEntry("Dim", TRUE); | ||
79 | lightoff = config.readBoolEntry("LightOff", FALSE ); | ||
80 | suspend = config.readBoolEntry("Suspend", defsus ); | ||
81 | 73 | ||
82 | /* For compability*/ | 74 | QCString QCopKeyRegister::message()const { |
83 | config.setGroup("Screensaver"); | 75 | return m_message; |
84 | config.writeEntry( "Dim", dim ); | ||
85 | config.writeEntry( "LightOff", lightoff ); | ||
86 | config.writeEntry( "Suspend", suspend ); | ||
87 | config.writeEntry( "Interval_Dim", intervalDim ); | ||
88 | config.writeEntry( "Interval_LightOff", intervalLightOff ); | ||
89 | config.writeEntry( "Interval", intervalSuspend ); | ||
90 | config.writeEntry( "Brightness", initbright ); | ||
91 | } | 76 | } |
92 | 77 | ||
93 | int i_dim = (dim ? intervalDim : 0); | 78 | bool QCopKeyRegister::send() { |
94 | int i_lightoff = (lightoff ? intervalLightOff : 0); | 79 | if (m_channel.isNull() ) |
95 | int i_suspend = (suspend ? intervalSuspend : 0); | 80 | return false; |
96 | 81 | ||
97 | #ifndef QT_NO_COP | 82 | QCopEnvelope( m_channel, m_message ); |
98 | QCopEnvelope eB("QPE/System", "setBacklight(int)" ); | ||
99 | eB << initbright; | ||
100 | 83 | ||
101 | QCopEnvelope e("QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 84 | return true; |
102 | e << i_dim << i_lightoff << i_suspend; | ||
103 | #endif | ||
104 | } | 85 | } |
@@ -157,3 +138,6 @@ KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton | |||
157 | { | 138 | { |
139 | /* We don't do this cause it would interfere with ODevice */ | ||
140 | #if 0 | ||
158 | qwsServer->setKeyboardFilter(this); | 141 | qwsServer->setKeyboardFilter(this); |
142 | #endif | ||
159 | } | 143 | } |
@@ -173,4 +157,22 @@ void KeyFilter::timerEvent(QTimerEvent* e) | |||
173 | 157 | ||
174 | bool KeyFilter::filter(int /*unicode*/, int keycode, int modifiers, bool press, | 158 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { |
175 | bool autoRepeat) | 159 | m_keys.insert( key.keyCode(), key ); |
160 | } | ||
161 | |||
162 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { | ||
163 | m_keys.remove( key.keyCode() ); | ||
164 | } | ||
165 | |||
166 | bool KeyFilter::keyRegistered( int key ) { | ||
167 | /* | ||
168 | * Check if we've a key registered | ||
169 | */ | ||
170 | if ( !m_keys[key].send()) | ||
171 | return false; | ||
172 | else | ||
173 | return true; | ||
174 | |||
175 | } | ||
176 | |||
177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | ||
176 | { | 178 | { |
@@ -188,6 +190,12 @@ bool KeyFilter::filter(int /*unicode*/, int keycode, int modifiers, bool press, | |||
188 | return TRUE; | 190 | return TRUE; |
189 | if ( !modifiers ) { | 191 | |
190 | if ( !((ServerApplication*)qApp)->keyboardGrabbed() ) { | 192 | /* check if it was registered */ |
193 | if (!db ) { | ||
194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | ||
195 | return true; | ||
196 | }else { | ||
197 | |||
198 | |||
191 | // First check to see if DeviceButtonManager knows something about this button: | 199 | // First check to see if DeviceButtonManager knows something about this button: |
192 | const DeviceButton* button = DeviceButtonManager::instance().buttonForKeycode(keycode); | 200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); |
193 | if (button && !autoRepeat) { | 201 | if (button && !autoRepeat) { |
@@ -202,3 +210,3 @@ bool KeyFilter::filter(int /*unicode*/, int keycode, int modifiers, bool press, | |||
202 | heldButton = button; | 210 | heldButton = button; |
203 | held_tid = startTimer(500); | 211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); |
204 | } else if ( heldButton ) { | 212 | } else if ( heldButton ) { |
@@ -210,4 +218,5 @@ bool KeyFilter::filter(int /*unicode*/, int keycode, int modifiers, bool press, | |||
210 | } | 218 | } |
219 | return false; | ||
211 | } | 220 | } |
212 | if ( keycode == Key_F34 ) { | 221 | if ( keycode == HardKey_Suspend ) { |
213 | if ( press ) emit power(); | 222 | if ( press ) emit power(); |
@@ -215,3 +224,3 @@ bool KeyFilter::filter(int /*unicode*/, int keycode, int modifiers, bool press, | |||
215 | } | 224 | } |
216 | if ( keycode == Key_F35 ) { | 225 | if ( keycode == HardKey_Backlight ) { |
217 | if ( press ) emit backlight(); | 226 | if ( press ) emit backlight(); |
@@ -230,11 +239,12 @@ bool KeyFilter::filter(int /*unicode*/, int keycode, int modifiers, bool press, | |||
230 | } | 239 | } |
231 | } | 240 | |
232 | if ( keycode == Key_NumLock ) { | 241 | if ( keycode == Key_NumLock ) |
233 | if ( press ) emit numLockStateToggle(); | 242 | if ( press ) emit numLockStateToggle(); |
234 | } | 243 | |
235 | if ( keycode == Key_CapsLock ) { | 244 | if ( keycode == Key_CapsLock ) |
236 | if ( press ) emit capsLockStateToggle(); | 245 | if ( press ) emit capsLockStateToggle(); |
237 | } | 246 | |
238 | if ( serverApp ) | 247 | if ( serverApp ) |
239 | serverApp->keyClick(keycode,press,autoRepeat); | 248 | serverApp->keyClick(keycode,press,autoRepeat); |
249 | |||
240 | return FALSE; | 250 | return FALSE; |
@@ -248,5 +258,3 @@ QPE_MEMALERTER_IMPL | |||
248 | 258 | ||
249 | #if defined(CUSTOM_SOUND_IMPL) | 259 | |
250 | CUSTOM_SOUND_IMPL | ||
251 | #endif | ||
252 | 260 | ||
@@ -257,2 +265,20 @@ bool ServerApplication::allowRestart = TRUE; | |||
257 | 265 | ||
266 | void ServerApplication::switchLCD( bool on ) { | ||
267 | if ( !qApp ) | ||
268 | return; | ||
269 | |||
270 | ServerApplication *dapp = ServerApplication::me() ; | ||
271 | |||
272 | if ( !dapp-> m_screensaver ) | ||
273 | return; | ||
274 | |||
275 | if ( on ) { | ||
276 | dapp-> m_screensaver-> setDisplayState ( true ); | ||
277 | dapp-> m_screensaver-> setBacklight ( -3 ); | ||
278 | }else | ||
279 | dapp-> m_screensaver-> setDisplayState ( false ); | ||
280 | |||
281 | |||
282 | } | ||
283 | |||
258 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | 284 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) |
@@ -260,9 +286,3 @@ ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | |||
260 | { | 286 | { |
261 | #ifdef CUSTOM_SOUND_INIT | ||
262 | CUSTOM_SOUND_INIT; | ||
263 | #endif | ||
264 | 287 | ||
265 | #if defined(QPE_HAVE_MEMALERTER) | ||
266 | initMemalerter(); | ||
267 | #endif | ||
268 | 288 | ||
@@ -271,10 +291,30 @@ ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | |||
271 | 291 | ||
272 | QTimer *timer = new QTimer( this ); | 292 | m_ps = new PowerStatus; |
273 | connect( timer, SIGNAL(timeout()), this, SLOT(psTimeout()) ); | 293 | m_ps_last = new PowerStatus; |
274 | timer->start( 10000 ); | ||
275 | ps = new PowerStatus; | ||
276 | pa = new DesktopPowerAlerter( 0 ); | 294 | pa = new DesktopPowerAlerter( 0 ); |
277 | 295 | ||
278 | applyLightSettings(ps); | 296 | m_apm_timer = new QTimer( this ); |
297 | connect(m_apm_timer, SIGNAL( timeout() ), | ||
298 | this, SLOT( apmTimeout() ) ); | ||
299 | |||
300 | reloadPowerWarnSettings(); | ||
301 | |||
302 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | ||
303 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | ||
304 | this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); | ||
305 | |||
306 | channel = new QCopChannel("QPE/Launcher", this ); | ||
307 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | ||
308 | this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); | ||
309 | |||
310 | m_screensaver = new OpieScreenSaver(); | ||
311 | m_screensaver->setInterval( -1 ); | ||
312 | QWSServer::setScreenSaver( m_screensaver ); | ||
313 | |||
314 | connect( qApp, SIGNAL( volumeChanged( bool ) ), | ||
315 | this, SLOT( rereadVolumes() ) ); | ||
279 | 316 | ||
317 | |||
318 | /* ### PluginLoader libqtopia SafeMode */ | ||
319 | #if 0 | ||
280 | if ( PluginLoader::inSafeMode() ) | 320 | if ( PluginLoader::inSafeMode() ) |
@@ -282,4 +322,5 @@ ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | |||
282 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); | 322 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); |
323 | #endif | ||
283 | 324 | ||
284 | KeyFilter* kf = new KeyFilter(this); | 325 | kf = new KeyFilter(this); |
285 | 326 | ||
@@ -291,3 +332,4 @@ ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | |||
291 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); | 332 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); |
292 | connect( kf, SIGNAL(activate(const DeviceButton*,bool)), this,SIGNAL(activate(const DeviceButton*,bool))); | 333 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), |
334 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); | ||
293 | 335 | ||
@@ -296,3 +338,5 @@ ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | |||
296 | 338 | ||
297 | connect( this, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()) ); | 339 | connect( this, SIGNAL(power() ), |
340 | SLOT(togglePower() ) ); | ||
341 | |||
298 | rereadVolumes(); | 342 | rereadVolumes(); |
@@ -300,2 +344,8 @@ ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | |||
300 | serverApp = this; | 344 | serverApp = this; |
345 | |||
346 | apmTimeout(); | ||
347 | grabKeyboard(); | ||
348 | |||
349 | /* make sure the event filter is installed */ | ||
350 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); | ||
301 | } | 351 | } |
@@ -305,6 +355,116 @@ ServerApplication::~ServerApplication() | |||
305 | { | 355 | { |
306 | delete ps; | 356 | ungrabKeyboard(); |
357 | |||
358 | |||
307 | delete pa; | 359 | delete pa; |
360 | delete m_ps; | ||
361 | delete m_ps_last; | ||
362 | } | ||
363 | |||
364 | void ServerApplication::apmTimeout() { | ||
365 | serverApp-> checkMemory( ); // in case no events are generated | ||
366 | *m_ps_last = *m_ps; | ||
367 | *m_ps = PowerStatusManager::readStatus(); | ||
368 | |||
369 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) | ||
370 | m_screensaver-> powerStatusChanged( *m_ps ); | ||
371 | |||
372 | if ( m_ps->acStatus() == PowerStatus::Online ) | ||
373 | return; | ||
374 | |||
375 | int bat = m_ps-> batteryPercentRemaining(); | ||
376 | |||
377 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { | ||
378 | if ( bat <= m_powerCritical ) | ||
379 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); | ||
380 | else if ( bat <= m_powerVeryLow ) | ||
381 | pa->alert( tr( "Battery is running very low. "), 2 ); | ||
382 | } | ||
383 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) | ||
384 | pa->alert( tr("The Back-up battery is very low.\nPlease charge the back-up battery." ), 2); | ||
385 | |||
308 | } | 386 | } |
309 | 387 | ||
388 | void ServerApplication::systemMessage( const QCString& msg, | ||
389 | const QByteArray& data ) { | ||
390 | QDataStream stream ( data, IO_ReadOnly ); | ||
391 | |||
392 | if ( msg == "setScreenSaverInterval(int)" ) { | ||
393 | int time; | ||
394 | stream >> time; | ||
395 | m_screensaver-> setInterval( time ); | ||
396 | } | ||
397 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | ||
398 | int t1, t2, t3; | ||
399 | stream >> t1 >> t2 >> t3; | ||
400 | m_screensaver-> setIntervals( t1, t2, t3 ); | ||
401 | } | ||
402 | else if ( msg == "setBacklight(int)" ) { | ||
403 | int bright; | ||
404 | stream >> bright; | ||
405 | m_screensaver-> setBacklight( bright ); | ||
406 | } | ||
407 | else if ( msg == "setScreenSaverMode(int)" ) { | ||
408 | int mode; | ||
409 | stream >> mode; | ||
410 | m_screensaver-> setMode ( mode ); | ||
411 | } | ||
412 | else if ( msg == "reloadPowerWarnSettings()" ) { | ||
413 | reloadPowerWarnSettings(); | ||
414 | } | ||
415 | else if ( msg == "setDisplayState(int)" ) { | ||
416 | int state; | ||
417 | stream >> state; | ||
418 | m_screensaver-> setDisplayState ( state != 0 ); | ||
419 | } | ||
420 | else if ( msg == "suspend()" ) { | ||
421 | emit power(); | ||
422 | } | ||
423 | else if ( msg == "sendBusinessCard()" ) { | ||
424 | QString card = ::getenv ( "HOME" ); | ||
425 | card += "/Applications/addressbook/businesscard.vcf"; | ||
426 | |||
427 | if ( QFile::exists( card ) ) { | ||
428 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | ||
429 | QString mimetype = "text/x-vCard"; | ||
430 | e << tr( "business card" ) << card << mimetype; | ||
431 | } | ||
432 | } | ||
433 | } | ||
434 | |||
435 | void ServerApplication::reloadPowerWarnSettings ( ) | ||
436 | { | ||
437 | Config cfg ( "apm" ); | ||
438 | cfg. setGroup ( "Warnings" ); | ||
439 | |||
440 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); | ||
441 | |||
442 | m_apm_timer-> stop ( ); | ||
443 | if ( iv ) | ||
444 | m_apm_timer-> start ( iv ); | ||
445 | |||
446 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); | ||
447 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); | ||
448 | } | ||
449 | |||
450 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) | ||
451 | { | ||
452 | QDataStream stream ( data, IO_ReadOnly ); | ||
453 | |||
454 | if ( msg == "deviceButton(int,int,int)" ) { | ||
455 | int keycode, press, autoRepeat; | ||
456 | stream >> keycode >> press >> autoRepeat; | ||
457 | |||
458 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); | ||
459 | } | ||
460 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { | ||
461 | int k; | ||
462 | QCString c, m; | ||
463 | stream >> k >> c >> m; | ||
464 | |||
465 | kf -> registerKey( QCopKeyRegister(k, c, m) ); | ||
466 | } | ||
467 | } | ||
468 | |||
469 | |||
310 | bool ServerApplication::screenLocked() | 470 | bool ServerApplication::screenLocked() |
@@ -338,2 +498,3 @@ void ServerApplication::login(bool at_poweron) | |||
338 | 498 | ||
499 | #if 0 | ||
339 | static bool blanked=FALSE; | 500 | static bool blanked=FALSE; |
@@ -358,45 +519,70 @@ static void darkScreen() | |||
358 | { | 519 | { |
520 | /* ### Screen blanking ODevice */ | ||
521 | #if 0 | ||
359 | qpe_setBacklight(0); // force off | 522 | qpe_setBacklight(0); // force off |
523 | #endif | ||
360 | } | 524 | } |
525 | #endif | ||
361 | 526 | ||
527 | namespace { | ||
528 | void execAutoStart(const QDateTime& suspendTime ) { | ||
529 | QString appName; | ||
530 | int delay; | ||
531 | QDateTime now = QDateTime::currentDateTime(); | ||
362 | 532 | ||
363 | void ServerApplication::togglePower() | 533 | Config cfg( "autostart" ); |
364 | { | 534 | cfg.setGroup( "AutoStart" ); |
365 | static int haveAPM = -1; | 535 | appName = cfg.readEntry( "Apps", "" ); |
366 | if ( haveAPM < 0 ) { | 536 | delay = cfg.readNumEntry( "Delay", 0 ); |
367 | if ( QFile::exists( "/proc/apm" ) ) { | 537 | |
368 | haveAPM = 1; | 538 | // If the time between suspend and resume was longer then the |
369 | } else { | 539 | // value saved as delay, start the app |
370 | haveAPM = 0; | 540 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
371 | qWarning( "Cannot suspend - no APM support in kernel" ); | 541 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
542 | e << QString( appName ); | ||
372 | } | 543 | } |
373 | } | 544 | } |
545 | } | ||
546 | |||
547 | |||
548 | void ServerApplication::togglePower() | ||
549 | { | ||
550 | static bool excllock = false; | ||
551 | |||
552 | if ( excllock ) | ||
553 | return ; | ||
554 | |||
555 | excllock = true; | ||
374 | 556 | ||
375 | if ( haveAPM ) { | ||
376 | bool wasloggedin = loggedin; | 557 | bool wasloggedin = loggedin; |
377 | loggedin=0; | 558 | loggedin=0; |
378 | if ( wasloggedin ) { | 559 | m_suspendTime = QDateTime::currentDateTime(); |
379 | Config cfg( QPEApplication::qpeDir()+"/etc/Security.conf", Config::File); | 560 | |
380 | cfg.setGroup("Passcode"); | 561 | #ifdef QWS |
381 | QString passcode = cfg.readEntry("passcode"); | 562 | |
382 | if ( !passcode.isEmpty() && cfg.readNumEntry("passcode_poweron",0) ) | 563 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
383 | blankScreen(); | 564 | // Should use a big black window instead. |
565 | // But this would not show up fast enough | ||
566 | QGfx *g = qt_screen-> screenGfx ( ); | ||
567 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | ||
568 | delete g; | ||
384 | } | 569 | } |
570 | #endif | ||
385 | 571 | ||
386 | system("apm --suspend"); | 572 | ODevice::inst ( )-> suspend ( ); |
573 | |||
574 | ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call | ||
575 | QWSServer::screenSaverActivate ( false ); | ||
387 | 576 | ||
388 | #ifndef QT_NO_COP | ||
389 | QWSServer::screenSaverActivate( FALSE ); | ||
390 | { | 577 | { |
391 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 578 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
392 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | ||
393 | e << -3; // Force on | ||
394 | } | 579 | } |
395 | #endif | 580 | |
396 | if ( wasloggedin ) | 581 | if ( wasloggedin ) |
397 | login(TRUE); | 582 | login ( true ); |
398 | } | ||
399 | 583 | ||
584 | execAutoStart(m_suspendTime); | ||
400 | //qcopBridge->closeOpenConnections(); | 585 | //qcopBridge->closeOpenConnections(); |
401 | //qDebug("called togglePower()!!!!!!"); | 586 | |
587 | excllock = false; | ||
402 | } | 588 | } |
@@ -412,2 +598,22 @@ void ServerApplication::toggleLight() | |||
412 | 598 | ||
599 | /* | ||
600 | * We still listen to key events but handle them in | ||
601 | * a special class | ||
602 | */ | ||
603 | |||
604 | bool ServerApplication::eventFilter( QObject *o, QEvent *e) { | ||
605 | if ( e->type() != QEvent::KeyPress && | ||
606 | e->type() != QEvent::KeyRelease ) | ||
607 | return QPEApplication::eventFilter( o, e ); | ||
608 | |||
609 | QKeyEvent *ke = static_cast<QKeyEvent*>( e ); | ||
610 | if ( kf->checkButtonAction( true, ke->key(), | ||
611 | e->type() == QEvent::KeyPress, | ||
612 | ke-> isAutoRepeat() )) | ||
613 | return true; | ||
614 | |||
615 | return QPEApplication::eventFilter( o, e ); | ||
616 | |||
617 | } | ||
618 | |||
413 | #ifdef Q_WS_QWS | 619 | #ifdef Q_WS_QWS |
@@ -429,2 +635,9 @@ bool ServerApplication::qwsEventFilter( QWSEvent *e ) | |||
429 | } | 635 | } |
636 | }else if ( e->type == QWSEvent::Key ) { | ||
637 | QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); | ||
638 | if ( kf->checkButtonAction( false, | ||
639 | ke-> simpleData.keycode, | ||
640 | ke-> simpleData.is_press, | ||
641 | ke-> simpleData.is_auto_repeat ) ) | ||
642 | return true; | ||
430 | } | 643 | } |
@@ -435,29 +648,4 @@ bool ServerApplication::qwsEventFilter( QWSEvent *e ) | |||
435 | 648 | ||
436 | void ServerApplication::psTimeout() | ||
437 | { | ||
438 | checkMemory(); // in case no events are being generated | ||
439 | |||
440 | PowerStatus::ACStatus oldStatus = ps->acStatus(); | ||
441 | |||
442 | *ps = PowerStatusManager::readStatus(); | ||
443 | |||
444 | if ( oldStatus != ps->acStatus() ) { | ||
445 | // power source changed, read settings applying to current powersource | ||
446 | applyLightSettings(ps); | ||
447 | } | ||
448 | 649 | ||
449 | 650 | /* ### FIXME libqtopia Plugin Safe Mode */ | |
450 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { | ||
451 | pa->alert( tr( "Battery is running very low." ), 6 ); | ||
452 | } | ||
453 | |||
454 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | ||
455 | pa->alert( tr( "Battery level is critical!\n" | ||
456 | "Please recharge the main battery!" ), 1 ); | ||
457 | } | ||
458 | |||
459 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | ||
460 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | ||
461 | } | ||
462 | } | ||
463 | 651 | ||
@@ -465,2 +653,3 @@ void ServerApplication::showSafeMode() | |||
465 | { | 653 | { |
654 | #if 0 | ||
466 | if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " | 655 | if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " |
@@ -472,2 +661,3 @@ void ServerApplication::showSafeMode() | |||
472 | } | 661 | } |
662 | #endif | ||
473 | } | 663 | } |
@@ -476,2 +666,3 @@ void ServerApplication::clearSafeMode() | |||
476 | { | 666 | { |
667 | #if 0 | ||
477 | // If we've been running OK for a while then we won't bother going into | 668 | // If we've been running OK for a while then we won't bother going into |
@@ -484,4 +675,6 @@ void ServerApplication::clearSafeMode() | |||
484 | } | 675 | } |
676 | #endif | ||
485 | } | 677 | } |
486 | 678 | ||
679 | |||
487 | void ServerApplication::shutdown() | 680 | void ServerApplication::shutdown() |
@@ -498,22 +691,17 @@ void ServerApplication::shutdown( ShutdownImpl::Type t ) | |||
498 | { | 691 | { |
692 | char *opt = 0; | ||
693 | |||
499 | switch ( t ) { | 694 | switch ( t ) { |
500 | case ShutdownImpl::ShutdownSystem: | 695 | case ShutdownImpl::ShutdownSystem: |
501 | #ifndef Q_OS_WIN32 | 696 | opt = "-h"; |
502 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); // No tr | 697 | // fall through |
503 | #else | ||
504 | qDebug("ServerApplication::ShutdownSystem"); | ||
505 | prepareForTermination(FALSE); | ||
506 | quit(); | ||
507 | #endif | ||
508 | break; | ||
509 | |||
510 | case ShutdownImpl::RebootSystem: | 698 | case ShutdownImpl::RebootSystem: |
511 | #ifndef Q_OS_WIN32 | 699 | if ( opt == 0 ) |
512 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); // No tr | 700 | opt = "-r"; |
513 | #else | 701 | |
514 | qDebug("ServerApplication::RebootSystem"); | 702 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) |
515 | restart(); | 703 | perror("shutdown"); |
516 | #endif | 704 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); |
517 | break; | ||
518 | 705 | ||
706 | break; | ||
519 | case ShutdownImpl::RestartDesktop: | 707 | case ShutdownImpl::RestartDesktop: |
@@ -521,5 +709,10 @@ void ServerApplication::shutdown( ShutdownImpl::Type t ) | |||
521 | break; | 709 | break; |
522 | |||
523 | case ShutdownImpl::TerminateDesktop: | 710 | case ShutdownImpl::TerminateDesktop: |
524 | prepareForTermination(FALSE); | 711 | prepareForTermination(FALSE); |
712 | |||
713 | // This is a workaround for a Qt bug | ||
714 | // clipboard applet has to stop its poll timer, or Qt/E | ||
715 | // will hang on quit() right before it emits aboutToQuit() | ||
716 | emit aboutToQuit ( ); | ||
717 | |||
525 | quit(); | 718 | quit(); |
@@ -540,6 +733,8 @@ void ServerApplication::rereadVolumes() | |||
540 | { | 733 | { |
541 | Config cfg("Sound"); | 734 | Config cfg( "qpe" ); |
542 | cfg.setGroup("System"); | 735 | cfg. setGroup ( "Volume" ); |
543 | touchclick = cfg.readBoolEntry("Touch"); | 736 | |
544 | keyclick = cfg.readBoolEntry("Key"); | 737 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); |
738 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); | ||
739 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); | ||
545 | } | 740 | } |
@@ -593,12 +788,7 @@ bool ServerApplication::recoverMemory() | |||
593 | 788 | ||
594 | void ServerApplication::keyClick(int keycode, bool press, bool repeat) | 789 | void ServerApplication::keyClick(int , bool press, bool ) |
595 | { | 790 | { |
596 | #ifdef CUSTOM_SOUND_KEYCLICK | 791 | if ( press && m_keyclick_sound ) |
597 | if ( keyclick ) | 792 | ODevice::inst() -> keySound(); |
598 | CUSTOM_SOUND_KEYCLICK(keycode,press,repeat); | 793 | |
599 | #else | ||
600 | Q_UNUSED( keycode ); | ||
601 | Q_UNUSED( press ); | ||
602 | Q_UNUSED( repeat ); | ||
603 | #endif | ||
604 | } | 794 | } |
@@ -607,8 +797,14 @@ void ServerApplication::screenClick(bool press) | |||
607 | { | 797 | { |
608 | #ifdef CUSTOM_SOUND_TOUCH | 798 | if ( press && m_screentap_sound ) |
609 | if ( touchclick ) | 799 | ODevice::inst() -> touchSound(); |
610 | CUSTOM_SOUND_TOUCH(press); | 800 | } |
611 | #else | 801 | |
612 | Q_UNUSED( press ); | 802 | void ServerApplication::soundAlarm() { |
613 | #endif | 803 | if ( me ()->m_alarm_sound ) |
804 | ODevice::inst()->alarmSound(); | ||
805 | } | ||
806 | |||
807 | ServerApplication *ServerApplication::me ( ) | ||
808 | { | ||
809 | return static_cast<ServerApplication*>( qApp ); | ||
614 | } | 810 | } |