-rw-r--r-- | core/launcher/desktop.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index fbcce7c..86527f6 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -257,223 +257,228 @@ void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & | |||
257 | int t1, t2, t3; | 257 | int t1, t2, t3; |
258 | stream >> t1 >> t2 >> t3; | 258 | stream >> t1 >> t2 >> t3; |
259 | m_screensaver-> setIntervals( t1, t2, t3 ); | 259 | m_screensaver-> setIntervals( t1, t2, t3 ); |
260 | } | 260 | } |
261 | else if ( msg == "setBacklight(int)" ) { | 261 | else if ( msg == "setBacklight(int)" ) { |
262 | int bright; | 262 | int bright; |
263 | stream >> bright; | 263 | stream >> bright; |
264 | m_screensaver-> setBacklight( bright ); | 264 | m_screensaver-> setBacklight( bright ); |
265 | } | 265 | } |
266 | else if ( msg == "setScreenSaverMode(int)" ) { | 266 | else if ( msg == "setScreenSaverMode(int)" ) { |
267 | int mode; | 267 | int mode; |
268 | stream >> mode; | 268 | stream >> mode; |
269 | m_screensaver-> setMode ( mode ); | 269 | m_screensaver-> setMode ( mode ); |
270 | } | 270 | } |
271 | else if ( msg == "reloadPowerWarnSettings()" ) { | 271 | else if ( msg == "reloadPowerWarnSettings()" ) { |
272 | reloadPowerWarnSettings(); | 272 | reloadPowerWarnSettings(); |
273 | } | 273 | } |
274 | else if ( msg == "setDisplayState(int)" ) { | 274 | else if ( msg == "setDisplayState(int)" ) { |
275 | int state; | 275 | int state; |
276 | stream >> state; | 276 | stream >> state; |
277 | m_screensaver-> setDisplayState ( state != 0 ); | 277 | m_screensaver-> setDisplayState ( state != 0 ); |
278 | } | 278 | } |
279 | else if ( msg == "suspend()" ) { | 279 | else if ( msg == "suspend()" ) { |
280 | emit power(); | 280 | emit power(); |
281 | } | 281 | } |
282 | else if ( msg == "sendBusinessCard()" ) { | 282 | else if ( msg == "sendBusinessCard()" ) { |
283 | QString card = ::getenv ( "HOME" ); | 283 | QString card = ::getenv ( "HOME" ); |
284 | card += "/Applications/addressbook/businesscard.vcf"; | 284 | card += "/Applications/addressbook/businesscard.vcf"; |
285 | 285 | ||
286 | if ( QFile::exists( card ) ) { | 286 | if ( QFile::exists( card ) ) { |
287 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | 287 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); |
288 | QString mimetype = "text/x-vCard"; | 288 | QString mimetype = "text/x-vCard"; |
289 | e << tr( "business card" ) << card << mimetype; | 289 | e << tr( "business card" ) << card << mimetype; |
290 | } | 290 | } |
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | void DesktopApplication::reloadPowerWarnSettings ( ) | 294 | void DesktopApplication::reloadPowerWarnSettings ( ) |
295 | { | 295 | { |
296 | Config cfg ( "apm" ); | 296 | Config cfg ( "apm" ); |
297 | cfg. setGroup ( "Warnings" ); | 297 | cfg. setGroup ( "Warnings" ); |
298 | 298 | ||
299 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); | 299 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); |
300 | 300 | ||
301 | m_apm_timer-> stop ( ); | 301 | m_apm_timer-> stop ( ); |
302 | if ( iv ) | 302 | if ( iv ) |
303 | m_apm_timer-> start ( iv ); | 303 | m_apm_timer-> start ( iv ); |
304 | 304 | ||
305 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); | 305 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); |
306 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); | 306 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); |
307 | } | 307 | } |
308 | 308 | ||
309 | 309 | ||
310 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 310 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
311 | 311 | ||
312 | 312 | ||
313 | void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data ) | 313 | void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data ) |
314 | { | 314 | { |
315 | QDataStream stream ( data, IO_ReadOnly ); | 315 | QDataStream stream ( data, IO_ReadOnly ); |
316 | 316 | ||
317 | if ( msg == "deviceButton(int,int,int)" ) { | 317 | if ( msg == "deviceButton(int,int,int)" ) { |
318 | int keycode, press, autoRepeat; | 318 | int keycode, press, autoRepeat; |
319 | stream >> keycode >> press >> autoRepeat; | 319 | stream >> keycode >> press >> autoRepeat; |
320 | 320 | ||
321 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode ); | 321 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode ); |
322 | 322 | ||
323 | if ( db ) | 323 | if ( db ) |
324 | checkButtonAction ( db, keycode, press, autoRepeat ); | 324 | checkButtonAction ( db, keycode, press, autoRepeat ); |
325 | } | 325 | } |
326 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { | 326 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { |
327 | int k; | 327 | int k; |
328 | QCString c, m; | 328 | QCString c, m; |
329 | stream >> k >> c >> m; | 329 | stream >> k >> c >> m; |
330 | 330 | ||
331 | keyRegisterList.append ( QCopKeyRegister ( k, c, m )); | 331 | keyRegisterList.append ( QCopKeyRegister ( k, c, m )); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | void DesktopApplication::sendHeldAction ( ) | 335 | void DesktopApplication::sendHeldAction ( ) |
336 | { | 336 | { |
337 | if ( m_last_button ) { | 337 | if ( m_last_button ) { |
338 | m_last_button-> heldAction ( ). send ( ); | 338 | m_last_button-> heldAction ( ). send ( ); |
339 | m_last_button = 0; | 339 | m_last_button = 0; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | 344 | ||
345 | bool DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat ) | 345 | bool DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat ) |
346 | { | 346 | { |
347 | if ( db ) { | 347 | if ( db ) { |
348 | if ( !press && !autoRepeat && m_button_timer-> isActive ( )) { | 348 | if ( !press && !autoRepeat && m_button_timer-> isActive ( )) { |
349 | m_button_timer-> stop ( ); | 349 | m_button_timer-> stop ( ); |
350 | 350 | ||
351 | if (!db-> pressedAction ( ). channel ( ) .isEmpty()) | 351 | if (!db-> pressedAction ( ). channel ( ) .isEmpty()) |
352 | { | 352 | { |
353 | |||
353 | if ( db-> pressedAction ( ). channel ( )!="ignore") { | 354 | if ( db-> pressedAction ( ). channel ( )!="ignore") { |
355 | |||
354 | db-> pressedAction ( ). send ( ); | 356 | db-> pressedAction ( ). send ( ); |
355 | } | 357 | } |
356 | else return false; | 358 | else |
359 | return false; | ||
357 | } | 360 | } |
358 | } | 361 | } |
359 | else if ( press && !autoRepeat ) { | 362 | else if ( press && !autoRepeat ) { |
360 | m_button_timer-> stop ( ); | 363 | m_button_timer-> stop ( ); |
361 | if (!db-> pressedAction ( ). channel ( ) .isEmpty()) | 364 | if (!db-> pressedAction ( ). channel ( ) .isEmpty()) |
362 | { | 365 | { |
363 | 366 | ||
364 | if ( db-> heldAction ( ). channel ( )!="ignore") { | 367 | if ( db-> heldAction ( ). channel ( )!="ignore") { |
365 | m_last_button = db; | 368 | m_last_button = db; |
366 | m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); | 369 | m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); |
367 | } | 370 | } |
368 | else return false; | 371 | else return false; |
369 | } | 372 | } |
370 | } | 373 | } |
371 | } | 374 | } |
372 | return true; | 375 | return true; |
373 | } | 376 | } |
374 | 377 | ||
375 | bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) | 378 | bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) |
376 | { | 379 | { |
380 | |||
377 | if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { | 381 | if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { |
378 | QKeyEvent *ke = (QKeyEvent *) e; | 382 | QKeyEvent *ke = (QKeyEvent *) e; |
379 | 383 | ||
380 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); | 384 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); |
381 | 385 | ||
382 | if ( db ) { | 386 | if ( db ) { |
383 | return checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )); | 387 | if (checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( ))) |
388 | return true; //checkButtonAction retrune false if events should be routed through | ||
384 | } | 389 | } |
385 | } | 390 | } |
386 | return QPEApplication::eventFilter ( o, e ); | 391 | return QPEApplication::eventFilter ( o, e ); |
387 | } | 392 | } |
388 | 393 | ||
389 | #ifdef Q_WS_QWS | 394 | #ifdef Q_WS_QWS |
390 | 395 | ||
391 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 396 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
392 | { | 397 | { |
393 | qpedesktop->checkMemory(); | 398 | qpedesktop->checkMemory(); |
394 | 399 | ||
395 | if ( e->type == QWSEvent::Key ) { | 400 | if ( e->type == QWSEvent::Key ) { |
396 | QWSKeyEvent * ke = (QWSKeyEvent *) e; | 401 | QWSKeyEvent * ke = (QWSKeyEvent *) e; |
397 | ushort keycode = ke-> simpleData. keycode; | 402 | ushort keycode = ke-> simpleData. keycode; |
398 | 403 | ||
399 | if ( !loggedin && keycode != Key_F34 ) | 404 | if ( !loggedin && keycode != Key_F34 ) |
400 | return true; | 405 | return true; |
401 | 406 | ||
402 | bool press = ke-> simpleData. is_press; | 407 | bool press = ke-> simpleData. is_press; |
403 | bool autoRepeat = ke-> simpleData. is_auto_repeat; | 408 | bool autoRepeat = ke-> simpleData. is_auto_repeat; |
404 | 409 | ||
405 | if ( !keyboardGrabbed ( )) { | 410 | if ( !keyboardGrabbed ( )) { |
406 | // app that registers key/message to be sent back to the app, when it doesn't have focus, | 411 | // app that registers key/message to be sent back to the app, when it doesn't have focus, |
407 | // when user presses key, unless keyboard has been requested from app. | 412 | // when user presses key, unless keyboard has been requested from app. |
408 | // will not send multiple repeats if user holds key | 413 | // will not send multiple repeats if user holds key |
409 | // i.e. one shot | 414 | // i.e. one shot |
410 | 415 | ||
411 | if ( keycode != 0 && press && !autoRepeat ) { | 416 | if ( keycode != 0 && press && !autoRepeat ) { |
412 | for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 417 | for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
413 | if (( *it ). getKeyCode ( ) == keycode ) { | 418 | if (( *it ). getKeyCode ( ) == keycode ) { |
414 | QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); | 419 | QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); |
415 | return true; | 420 | return true; |
416 | } | 421 | } |
417 | } | 422 | } |
418 | } | 423 | } |
419 | } | 424 | } |
420 | 425 | ||
421 | if ( keycode == HardKey_Suspend ) { | 426 | if ( keycode == HardKey_Suspend ) { |
422 | if ( press ) | 427 | if ( press ) |
423 | emit power ( ); | 428 | emit power ( ); |
424 | return true; | 429 | return true; |
425 | } | 430 | } |
426 | else if ( keycode == HardKey_Backlight ) { | 431 | else if ( keycode == HardKey_Backlight ) { |
427 | if ( press ) | 432 | if ( press ) |
428 | emit backlight ( ); | 433 | emit backlight ( ); |
429 | return true; | 434 | return true; |
430 | } | 435 | } |
431 | else if ( keycode == Key_F32 ) { | 436 | else if ( keycode == Key_F32 ) { |
432 | if ( press ) | 437 | if ( press ) |
433 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 438 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
434 | return true; | 439 | return true; |
435 | } | 440 | } |
436 | else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM | 441 | else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM |
437 | if ( press ) | 442 | if ( press ) |
438 | emit symbol ( ); | 443 | emit symbol ( ); |
439 | return true; | 444 | return true; |
440 | } | 445 | } |
441 | else if ( keycode == Key_NumLock ) { | 446 | else if ( keycode == Key_NumLock ) { |
442 | if ( press ) | 447 | if ( press ) |
443 | emit numLockStateToggle ( ); | 448 | emit numLockStateToggle ( ); |
444 | } | 449 | } |
445 | else if ( keycode == Key_CapsLock ) { | 450 | else if ( keycode == Key_CapsLock ) { |
446 | if ( press ) | 451 | if ( press ) |
447 | emit capsLockStateToggle(); | 452 | emit capsLockStateToggle(); |
448 | } | 453 | } |
449 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) { | 454 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) { |
450 | if ( m_keyclick_sound ) | 455 | if ( m_keyclick_sound ) |
451 | ODevice::inst ( )-> keySound ( ); | 456 | ODevice::inst ( )-> keySound ( ); |
452 | } | 457 | } |
453 | } | 458 | } |
454 | else if ( e-> type == QWSEvent::Mouse ) { | 459 | else if ( e-> type == QWSEvent::Mouse ) { |
455 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 460 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
456 | static bool up = true; | 461 | static bool up = true; |
457 | 462 | ||
458 | if ( me-> simpleData. state & LeftButton ) { | 463 | if ( me-> simpleData. state & LeftButton ) { |
459 | if ( up ) { | 464 | if ( up ) { |
460 | up = false; | 465 | up = false; |
461 | if ( m_screentap_sound ) | 466 | if ( m_screentap_sound ) |
462 | ODevice::inst ( ) -> touchSound ( ); | 467 | ODevice::inst ( ) -> touchSound ( ); |
463 | } | 468 | } |
464 | } | 469 | } |
465 | else { | 470 | else { |
466 | up = true; | 471 | up = true; |
467 | } | 472 | } |
468 | } | 473 | } |
469 | 474 | ||
470 | return QPEApplication::qwsEventFilter ( e ); | 475 | return QPEApplication::qwsEventFilter ( e ); |
471 | } | 476 | } |
472 | #endif | 477 | #endif |
473 | 478 | ||
474 | 479 | ||
475 | 480 | ||
476 | #if defined(QPE_HAVE_MEMALERTER) | 481 | #if defined(QPE_HAVE_MEMALERTER) |
477 | QPE_MEMALERTER_IMPL | 482 | QPE_MEMALERTER_IMPL |
478 | #endif | 483 | #endif |
479 | 484 | ||
@@ -572,194 +577,192 @@ void Desktop::checkMemory() | |||
572 | // QMessageBox::information ( 0 , "Memory Status", | 577 | // QMessageBox::information ( 0 , "Memory Status", |
573 | // "There is enough memory again." ); | 578 | // "There is enough memory again." ); |
574 | break; | 579 | break; |
575 | case VeryLow: | 580 | case VeryLow: |
576 | memstate = Unknown; | 581 | memstate = Unknown; |
577 | QMessageBox::critical( 0 , "Memory Status", | 582 | QMessageBox::critical( 0 , "Memory Status", |
578 | "The memory is very low. \n" | 583 | "The memory is very low. \n" |
579 | "Please end this application \n" | 584 | "Please end this application \n" |
580 | "immediately." ); | 585 | "immediately." ); |
581 | recoverMemory(); | 586 | recoverMemory(); |
582 | } | 587 | } |
583 | existingMessage = FALSE; | 588 | existingMessage = FALSE; |
584 | #endif | 589 | #endif |
585 | } | 590 | } |
586 | 591 | ||
587 | static bool isVisibleWindow( int wid ) | 592 | static bool isVisibleWindow( int wid ) |
588 | { | 593 | { |
589 | #ifdef QWS | 594 | #ifdef QWS |
590 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 595 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
591 | QWSWindow* w; | 596 | QWSWindow* w; |
592 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 597 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
593 | if ( w->winId() == wid ) | 598 | if ( w->winId() == wid ) |
594 | return !w->isFullyObscured(); | 599 | return !w->isFullyObscured(); |
595 | } | 600 | } |
596 | #endif | 601 | #endif |
597 | return FALSE; | 602 | return FALSE; |
598 | } | 603 | } |
599 | 604 | ||
600 | static bool hasVisibleWindow( const QString& clientname ) | 605 | static bool hasVisibleWindow( const QString& clientname ) |
601 | { | 606 | { |
602 | #ifdef QWS | 607 | #ifdef QWS |
603 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 608 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
604 | QWSWindow* w; | 609 | QWSWindow* w; |
605 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 610 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
606 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) | 611 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) |
607 | return TRUE; | 612 | return TRUE; |
608 | } | 613 | } |
609 | #endif | 614 | #endif |
610 | return FALSE; | 615 | return FALSE; |
611 | } | 616 | } |
612 | 617 | ||
613 | 618 | ||
614 | void Desktop::executeOrModify( const QString& appLnkFile ) | 619 | void Desktop::executeOrModify( const QString& appLnkFile ) |
615 | { | 620 | { |
616 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); | 621 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); |
617 | if ( lnk.isValid() ) { | 622 | if ( lnk.isValid() ) { |
618 | QCString app = lnk.exec().utf8(); | 623 | QCString app = lnk.exec().utf8(); |
619 | Global::terminateBuiltin( "calibrate" ); | 624 | Global::terminateBuiltin( "calibrate" ); |
620 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { | 625 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { |
621 | // MRUList::addTask( &lnk ); | 626 | // MRUList::addTask( &lnk ); |
622 | if ( hasVisibleWindow( app ) ) | 627 | if ( hasVisibleWindow( app ) ) |
623 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); | 628 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); |
624 | else | 629 | else |
625 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); | 630 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); |
626 | } | 631 | } |
627 | else { | 632 | else { |
628 | lnk.execute(); | 633 | lnk.execute(); |
629 | } | 634 | } |
630 | } | 635 | } |
631 | } | 636 | } |
632 | 637 | ||
633 | // autoStarts apps on resume and start | 638 | // autoStarts apps on resume and start |
634 | void Desktop::execAutoStart() | 639 | void Desktop::execAutoStart() |
635 | { | 640 | { |
636 | QString appName; | 641 | QString appName; |
637 | int delay; | 642 | int delay; |
638 | QDateTime now = QDateTime::currentDateTime(); | 643 | QDateTime now = QDateTime::currentDateTime(); |
639 | Config cfg( "autostart" ); | 644 | Config cfg( "autostart" ); |
640 | cfg.setGroup( "AutoStart" ); | 645 | cfg.setGroup( "AutoStart" ); |
641 | appName = cfg.readEntry( "Apps", "" ); | 646 | appName = cfg.readEntry( "Apps", "" ); |
642 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 647 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
643 | // If the time between suspend and resume was longer then the | 648 | // If the time between suspend and resume was longer then the |
644 | // value saved as delay, start the app | 649 | // value saved as delay, start the app |
645 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 650 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
646 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 651 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
647 | e << QString( appName ); | 652 | e << QString( appName ); |
648 | } | 653 | } |
649 | } | 654 | } |
650 | 655 | ||
651 | #if defined(QPE_HAVE_TOGGLELIGHT) | 656 | #if defined(QPE_HAVE_TOGGLELIGHT) |
652 | #include <qpe/config.h> | 657 | #include <qpe/config.h> |
653 | 658 | ||
654 | #include <sys/ioctl.h> | 659 | #include <sys/ioctl.h> |
655 | #include <sys/types.h> | 660 | #include <sys/types.h> |
656 | #include <fcntl.h> | 661 | #include <fcntl.h> |
657 | #include <unistd.h> | 662 | #include <unistd.h> |
658 | #include <errno.h> | 663 | #include <errno.h> |
659 | #include <linux/ioctl.h> | 664 | #include <linux/ioctl.h> |
660 | #include <time.h> | 665 | #include <time.h> |
661 | #endif | 666 | #endif |
662 | 667 | ||
663 | 668 | ||
664 | void Desktop::togglePower() | 669 | void Desktop::togglePower() |
665 | { | 670 | { |
666 | static bool excllock = false; | 671 | static bool excllock = false; |
667 | 672 | ||
668 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); | ||
669 | |||
670 | if ( excllock ) | 673 | if ( excllock ) |
671 | return ; | 674 | return ; |
672 | 675 | ||
673 | excllock = true; | 676 | excllock = true; |
674 | 677 | ||
675 | bool wasloggedin = loggedin; | 678 | bool wasloggedin = loggedin; |
676 | loggedin = 0; | 679 | loggedin = 0; |
677 | suspendTime = QDateTime::currentDateTime(); | 680 | suspendTime = QDateTime::currentDateTime(); |
678 | 681 | ||
679 | #ifdef QWS | 682 | #ifdef QWS |
680 | 683 | ||
681 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | 684 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
682 | // Should use a big black window instead. | 685 | // Should use a big black window instead. |
683 | // But this would not show up fast enough | 686 | // But this would not show up fast enough |
684 | QGfx *g = qt_screen-> screenGfx ( ); | 687 | QGfx *g = qt_screen-> screenGfx ( ); |
685 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 688 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
686 | delete g; | 689 | delete g; |
687 | } | 690 | } |
688 | #endif | 691 | #endif |
689 | 692 | ||
690 | ODevice::inst ( )-> suspend ( ); | 693 | ODevice::inst ( )-> suspend ( ); |
691 | 694 | ||
692 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | 695 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call |
693 | QWSServer::screenSaverActivate ( false ); | 696 | QWSServer::screenSaverActivate ( false ); |
694 | 697 | ||
695 | { | 698 | { |
696 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 699 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
697 | } | 700 | } |
698 | 701 | ||
699 | if ( wasloggedin ) | 702 | if ( wasloggedin ) |
700 | login ( true ); | 703 | login ( true ); |
701 | 704 | ||
702 | execAutoStart(); | 705 | execAutoStart(); |
703 | //qcopBridge->closeOpenConnections(); | 706 | //qcopBridge->closeOpenConnections(); |
704 | 707 | ||
705 | excllock = false; | 708 | excllock = false; |
706 | } | 709 | } |
707 | 710 | ||
708 | void Desktop::toggleLight() | 711 | void Desktop::toggleLight() |
709 | { | 712 | { |
710 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); | 713 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); |
711 | e << -2; // toggle | 714 | e << -2; // toggle |
712 | } | 715 | } |
713 | 716 | ||
714 | void Desktop::toggleSymbolInput() | 717 | void Desktop::toggleSymbolInput() |
715 | { | 718 | { |
716 | tb->toggleSymbolInput(); | 719 | tb->toggleSymbolInput(); |
717 | } | 720 | } |
718 | 721 | ||
719 | void Desktop::toggleNumLockState() | 722 | void Desktop::toggleNumLockState() |
720 | { | 723 | { |
721 | tb->toggleNumLockState(); | 724 | tb->toggleNumLockState(); |
722 | } | 725 | } |
723 | 726 | ||
724 | void Desktop::toggleCapsLockState() | 727 | void Desktop::toggleCapsLockState() |
725 | { | 728 | { |
726 | tb->toggleCapsLockState(); | 729 | tb->toggleCapsLockState(); |
727 | } | 730 | } |
728 | 731 | ||
729 | void Desktop::styleChange( QStyle &s ) | 732 | void Desktop::styleChange( QStyle &s ) |
730 | { | 733 | { |
731 | QWidget::styleChange( s ); | 734 | QWidget::styleChange( s ); |
732 | int displayw = qApp->desktop() ->width(); | 735 | int displayw = qApp->desktop() ->width(); |
733 | int displayh = qApp->desktop() ->height(); | 736 | int displayh = qApp->desktop() ->height(); |
734 | 737 | ||
735 | QSize sz = tb->sizeHint(); | 738 | QSize sz = tb->sizeHint(); |
736 | 739 | ||
737 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 740 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
738 | } | 741 | } |
739 | 742 | ||
740 | void DesktopApplication::shutdown() | 743 | void DesktopApplication::shutdown() |
741 | { | 744 | { |
742 | if ( type() != GuiServer ) | 745 | if ( type() != GuiServer ) |
743 | return ; | 746 | return ; |
744 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 747 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
745 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), | 748 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), |
746 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); | 749 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); |
747 | sd->showMaximized(); | 750 | sd->showMaximized(); |
748 | } | 751 | } |
749 | 752 | ||
750 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 753 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
751 | { | 754 | { |
752 | char *opt = 0; | 755 | char *opt = 0; |
753 | 756 | ||
754 | switch ( t ) { | 757 | switch ( t ) { |
755 | case ShutdownImpl::ShutdownSystem: | 758 | case ShutdownImpl::ShutdownSystem: |
756 | opt = "-h"; | 759 | opt = "-h"; |
757 | // fall through | 760 | // fall through |
758 | case ShutdownImpl::RebootSystem: | 761 | case ShutdownImpl::RebootSystem: |
759 | if ( opt == 0 ) | 762 | if ( opt == 0 ) |
760 | opt = "-r"; | 763 | opt = "-r"; |
761 | 764 | ||
762 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) | 765 | if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) |
763 | perror("shutdown"); | 766 | perror("shutdown"); |
764 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); | 767 | // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); |
765 | 768 | ||