-rw-r--r-- | core/launcher/desktop.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 4c239a6..5ecc8bf 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -359,491 +359,491 @@ void DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keyc | |||
359 | m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); | 359 | m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); |
360 | } | 360 | } |
361 | } | 361 | } |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) | 365 | bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) |
366 | { | 366 | { |
367 | if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { | 367 | if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { |
368 | QKeyEvent *ke = (QKeyEvent *) e; | 368 | QKeyEvent *ke = (QKeyEvent *) e; |
369 | 369 | ||
370 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); | 370 | const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); |
371 | 371 | ||
372 | if ( db ) { | 372 | if ( db ) { |
373 | checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )); | 373 | checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )); |
374 | return true; | 374 | return true; |
375 | } | 375 | } |
376 | } | 376 | } |
377 | return QPEApplication::eventFilter ( o, e ); | 377 | return QPEApplication::eventFilter ( o, e ); |
378 | } | 378 | } |
379 | 379 | ||
380 | #ifdef Q_WS_QWS | 380 | #ifdef Q_WS_QWS |
381 | 381 | ||
382 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 382 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
383 | { | 383 | { |
384 | qpedesktop->checkMemory(); | 384 | qpedesktop->checkMemory(); |
385 | 385 | ||
386 | if ( e->type == QWSEvent::Key ) { | 386 | if ( e->type == QWSEvent::Key ) { |
387 | QWSKeyEvent * ke = (QWSKeyEvent *) e; | 387 | QWSKeyEvent * ke = (QWSKeyEvent *) e; |
388 | ushort keycode = ke-> simpleData. keycode; | 388 | ushort keycode = ke-> simpleData. keycode; |
389 | 389 | ||
390 | if ( !loggedin && keycode != Key_F34 ) | 390 | if ( !loggedin && keycode != Key_F34 ) |
391 | return true; | 391 | return true; |
392 | 392 | ||
393 | bool press = ke-> simpleData. is_press; | 393 | bool press = ke-> simpleData. is_press; |
394 | bool autoRepeat = ke-> simpleData. is_auto_repeat; | 394 | bool autoRepeat = ke-> simpleData. is_auto_repeat; |
395 | 395 | ||
396 | if ( !keyboardGrabbed ( )) { | 396 | if ( !keyboardGrabbed ( )) { |
397 | // app that registers key/message to be sent back to the app, when it doesn't have focus, | 397 | // app that registers key/message to be sent back to the app, when it doesn't have focus, |
398 | // when user presses key, unless keyboard has been requested from app. | 398 | // when user presses key, unless keyboard has been requested from app. |
399 | // will not send multiple repeats if user holds key | 399 | // will not send multiple repeats if user holds key |
400 | // i.e. one shot | 400 | // i.e. one shot |
401 | 401 | ||
402 | if ( keycode != 0 && press && !autoRepeat ) { | 402 | if ( keycode != 0 && press && !autoRepeat ) { |
403 | for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 403 | for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
404 | if (( *it ). getKeyCode ( ) == keycode ) { | 404 | if (( *it ). getKeyCode ( ) == keycode ) { |
405 | QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); | 405 | QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); |
406 | return true; | 406 | return true; |
407 | } | 407 | } |
408 | } | 408 | } |
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
412 | if ( keycode == HardKey_Suspend ) { | 412 | if ( keycode == HardKey_Suspend ) { |
413 | if ( press ) | 413 | if ( press ) |
414 | emit power ( ); | 414 | emit power ( ); |
415 | return true; | 415 | return true; |
416 | } | 416 | } |
417 | else if ( keycode == HardKey_Backlight ) { | 417 | else if ( keycode == HardKey_Backlight ) { |
418 | if ( press ) | 418 | if ( press ) |
419 | emit backlight ( ); | 419 | emit backlight ( ); |
420 | return true; | 420 | return true; |
421 | } | 421 | } |
422 | else if ( keycode == Key_F32 ) { | 422 | else if ( keycode == Key_F32 ) { |
423 | if ( press ) | 423 | if ( press ) |
424 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 424 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
425 | return true; | 425 | return true; |
426 | } | 426 | } |
427 | else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM | 427 | else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM |
428 | if ( press ) | 428 | if ( press ) |
429 | emit symbol ( ); | 429 | emit symbol ( ); |
430 | return true; | 430 | return true; |
431 | } | 431 | } |
432 | else if ( keycode == Key_NumLock ) { | 432 | else if ( keycode == Key_NumLock ) { |
433 | if ( press ) | 433 | if ( press ) |
434 | emit numLockStateToggle ( ); | 434 | emit numLockStateToggle ( ); |
435 | } | 435 | } |
436 | else if ( keycode == Key_CapsLock ) { | 436 | else if ( keycode == Key_CapsLock ) { |
437 | if ( press ) | 437 | if ( press ) |
438 | emit capsLockStateToggle(); | 438 | emit capsLockStateToggle(); |
439 | } | 439 | } |
440 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) { | 440 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) { |
441 | if ( m_keyclick_sound ) | 441 | if ( m_keyclick_sound ) |
442 | ODevice::inst ( )-> keySound ( ); | 442 | ODevice::inst ( )-> keySound ( ); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | else if ( e-> type == QWSEvent::Mouse ) { | 445 | else if ( e-> type == QWSEvent::Mouse ) { |
446 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 446 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
447 | static bool up = true; | 447 | static bool up = true; |
448 | 448 | ||
449 | if ( me-> simpleData. state & LeftButton ) { | 449 | if ( me-> simpleData. state & LeftButton ) { |
450 | if ( up ) { | 450 | if ( up ) { |
451 | up = false; | 451 | up = false; |
452 | if ( m_screentap_sound ) | 452 | if ( m_screentap_sound ) |
453 | ODevice::inst ( ) -> touchSound ( ); | 453 | ODevice::inst ( ) -> touchSound ( ); |
454 | } | 454 | } |
455 | } | 455 | } |
456 | else { | 456 | else { |
457 | up = true; | 457 | up = true; |
458 | } | 458 | } |
459 | } | 459 | } |
460 | 460 | ||
461 | return QPEApplication::qwsEventFilter ( e ); | 461 | return QPEApplication::qwsEventFilter ( e ); |
462 | } | 462 | } |
463 | #endif | 463 | #endif |
464 | 464 | ||
465 | 465 | ||
466 | 466 | ||
467 | #if defined(QPE_HAVE_MEMALERTER) | 467 | #if defined(QPE_HAVE_MEMALERTER) |
468 | QPE_MEMALERTER_IMPL | 468 | QPE_MEMALERTER_IMPL |
469 | #endif | 469 | #endif |
470 | 470 | ||
471 | //=========================================================================== | 471 | //=========================================================================== |
472 | 472 | ||
473 | Desktop::Desktop() : | 473 | Desktop::Desktop() : |
474 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 474 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
475 | qcopBridge( 0 ), | 475 | qcopBridge( 0 ), |
476 | transferServer( 0 ), | 476 | transferServer( 0 ), |
477 | packageSlave( 0 ) | 477 | packageSlave( 0 ) |
478 | { | 478 | { |
479 | qpedesktop = this; | 479 | qpedesktop = this; |
480 | 480 | ||
481 | // bg = new Info( this ); | 481 | // bg = new Info( this ); |
482 | tb = new TaskBar; | 482 | tb = new TaskBar; |
483 | 483 | ||
484 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 484 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
485 | 485 | ||
486 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); | 486 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); |
487 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); | 487 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); |
488 | 488 | ||
489 | int displayw = qApp->desktop() ->width(); | 489 | int displayw = qApp->desktop() ->width(); |
490 | int displayh = qApp->desktop() ->height(); | 490 | int displayh = qApp->desktop() ->height(); |
491 | 491 | ||
492 | 492 | ||
493 | QSize sz = tb->sizeHint(); | 493 | QSize sz = tb->sizeHint(); |
494 | 494 | ||
495 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 495 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
496 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 496 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
497 | 497 | ||
498 | tb->show(); | 498 | tb->show(); |
499 | launcher->showMaximized(); | 499 | launcher->showMaximized(); |
500 | launcher->show(); | 500 | launcher->show(); |
501 | launcher->raise(); | 501 | launcher->raise(); |
502 | #if defined(QPE_HAVE_MEMALERTER) | 502 | #if defined(QPE_HAVE_MEMALERTER) |
503 | 503 | ||
504 | initMemalerter(); | 504 | initMemalerter(); |
505 | #endif | 505 | #endif |
506 | // start services | 506 | // start services |
507 | startTransferServer(); | 507 | startTransferServer(); |
508 | ( void ) new IrServer( this ); | 508 | ( void ) new IrServer( this ); |
509 | 509 | ||
510 | packageSlave = new PackageSlave( this ); | 510 | packageSlave = new PackageSlave( this ); |
511 | 511 | ||
512 | qApp->installEventFilter( this ); | 512 | qApp->installEventFilter( this ); |
513 | 513 | ||
514 | qApp-> setMainWidget ( launcher ); | 514 | qApp-> setMainWidget ( launcher ); |
515 | } | 515 | } |
516 | 516 | ||
517 | void Desktop::show() | 517 | void Desktop::show() |
518 | { | 518 | { |
519 | login( TRUE ); | 519 | login( TRUE ); |
520 | QWidget::show(); | 520 | QWidget::show(); |
521 | } | 521 | } |
522 | 522 | ||
523 | Desktop::~Desktop() | 523 | Desktop::~Desktop() |
524 | { | 524 | { |
525 | delete launcher; | 525 | delete launcher; |
526 | delete tb; | 526 | delete tb; |
527 | delete qcopBridge; | 527 | delete qcopBridge; |
528 | delete transferServer; | 528 | delete transferServer; |
529 | } | 529 | } |
530 | 530 | ||
531 | bool Desktop::recoverMemory() | 531 | bool Desktop::recoverMemory() |
532 | { | 532 | { |
533 | return tb->recoverMemory(); | 533 | return tb->recoverMemory(); |
534 | } | 534 | } |
535 | 535 | ||
536 | void Desktop::checkMemory() | 536 | void Desktop::checkMemory() |
537 | { | 537 | { |
538 | #if defined(QPE_HAVE_MEMALERTER) | 538 | #if defined(QPE_HAVE_MEMALERTER) |
539 | static bool ignoreNormal = FALSE; | 539 | static bool ignoreNormal = FALSE; |
540 | static bool existingMessage = FALSE; | 540 | static bool existingMessage = FALSE; |
541 | 541 | ||
542 | if ( existingMessage ) | 542 | if ( existingMessage ) |
543 | return ; // don't show a second message while still on first | 543 | return ; // don't show a second message while still on first |
544 | 544 | ||
545 | existingMessage = TRUE; | 545 | existingMessage = TRUE; |
546 | switch ( memstate ) { | 546 | switch ( memstate ) { |
547 | case Unknown: | 547 | case Unknown: |
548 | break; | 548 | break; |
549 | case Low: | 549 | case Low: |
550 | memstate = Unknown; | 550 | memstate = Unknown; |
551 | if ( recoverMemory() ) | 551 | if ( recoverMemory() ) |
552 | ignoreNormal = TRUE; | 552 | ignoreNormal = TRUE; |
553 | else | 553 | else |
554 | QMessageBox::warning( 0 , "Memory Status", | 554 | QMessageBox::warning( 0 , "Memory Status", |
555 | "The memory smacks of shortage. \n" | 555 | "The memory smacks of shortage. \n" |
556 | "Please save data. " ); | 556 | "Please save data. " ); |
557 | break; | 557 | break; |
558 | case Normal: | 558 | case Normal: |
559 | memstate = Unknown; | 559 | memstate = Unknown; |
560 | if ( ignoreNormal ) | 560 | if ( ignoreNormal ) |
561 | ignoreNormal = FALSE; | 561 | ignoreNormal = FALSE; |
562 | // else | 562 | // else |
563 | // QMessageBox::information ( 0 , "Memory Status", | 563 | // QMessageBox::information ( 0 , "Memory Status", |
564 | // "There is enough memory again." ); | 564 | // "There is enough memory again." ); |
565 | break; | 565 | break; |
566 | case VeryLow: | 566 | case VeryLow: |
567 | memstate = Unknown; | 567 | memstate = Unknown; |
568 | QMessageBox::critical( 0 , "Memory Status", | 568 | QMessageBox::critical( 0 , "Memory Status", |
569 | "The memory is very low. \n" | 569 | "The memory is very low. \n" |
570 | "Please end this application \n" | 570 | "Please end this application \n" |
571 | "immediately." ); | 571 | "immediately." ); |
572 | recoverMemory(); | 572 | recoverMemory(); |
573 | } | 573 | } |
574 | existingMessage = FALSE; | 574 | existingMessage = FALSE; |
575 | #endif | 575 | #endif |
576 | } | 576 | } |
577 | 577 | ||
578 | static bool isVisibleWindow( int wid ) | 578 | static bool isVisibleWindow( int wid ) |
579 | { | 579 | { |
580 | #ifdef QWS | 580 | #ifdef QWS |
581 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 581 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
582 | QWSWindow* w; | 582 | QWSWindow* w; |
583 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 583 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
584 | if ( w->winId() == wid ) | 584 | if ( w->winId() == wid ) |
585 | return !w->isFullyObscured(); | 585 | return !w->isFullyObscured(); |
586 | } | 586 | } |
587 | #endif | 587 | #endif |
588 | return FALSE; | 588 | return FALSE; |
589 | } | 589 | } |
590 | 590 | ||
591 | static bool hasVisibleWindow( const QString& clientname ) | 591 | static bool hasVisibleWindow( const QString& clientname ) |
592 | { | 592 | { |
593 | #ifdef QWS | 593 | #ifdef QWS |
594 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 594 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
595 | QWSWindow* w; | 595 | QWSWindow* w; |
596 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 596 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
597 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) | 597 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) |
598 | return TRUE; | 598 | return TRUE; |
599 | } | 599 | } |
600 | #endif | 600 | #endif |
601 | return FALSE; | 601 | return FALSE; |
602 | } | 602 | } |
603 | 603 | ||
604 | 604 | ||
605 | void Desktop::executeOrModify( const QString& appLnkFile ) | 605 | void Desktop::executeOrModify( const QString& appLnkFile ) |
606 | { | 606 | { |
607 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); | 607 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); |
608 | if ( lnk.isValid() ) { | 608 | if ( lnk.isValid() ) { |
609 | QCString app = lnk.exec().utf8(); | 609 | QCString app = lnk.exec().utf8(); |
610 | Global::terminateBuiltin( "calibrate" ); | 610 | Global::terminateBuiltin( "calibrate" ); |
611 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { | 611 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { |
612 | // MRUList::addTask( &lnk ); | 612 | // MRUList::addTask( &lnk ); |
613 | if ( hasVisibleWindow( app ) ) | 613 | if ( hasVisibleWindow( app ) ) |
614 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); | 614 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); |
615 | else | 615 | else |
616 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); | 616 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); |
617 | } | 617 | } |
618 | else { | 618 | else { |
619 | lnk.execute(); | 619 | lnk.execute(); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | } | 622 | } |
623 | 623 | ||
624 | // autoStarts apps on resume and start | 624 | // autoStarts apps on resume and start |
625 | void Desktop::execAutoStart() | 625 | void Desktop::execAutoStart() |
626 | { | 626 | { |
627 | QString appName; | 627 | QString appName; |
628 | int delay; | 628 | int delay; |
629 | QDateTime now = QDateTime::currentDateTime(); | 629 | QDateTime now = QDateTime::currentDateTime(); |
630 | Config cfg( "autostart" ); | 630 | Config cfg( "autostart" ); |
631 | cfg.setGroup( "AutoStart" ); | 631 | cfg.setGroup( "AutoStart" ); |
632 | appName = cfg.readEntry( "Apps", "" ); | 632 | appName = cfg.readEntry( "Apps", "" ); |
633 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 633 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
634 | // If the time between suspend and resume was longer then the | 634 | // If the time between suspend and resume was longer then the |
635 | // value saved as delay, start the app | 635 | // value saved as delay, start the app |
636 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 636 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
637 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 637 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
638 | e << QString( appName ); | 638 | e << QString( appName ); |
639 | } | 639 | } |
640 | } | 640 | } |
641 | 641 | ||
642 | #if defined(QPE_HAVE_TOGGLELIGHT) | 642 | #if defined(QPE_HAVE_TOGGLELIGHT) |
643 | #include <qpe/config.h> | 643 | #include <qpe/config.h> |
644 | 644 | ||
645 | #include <sys/ioctl.h> | 645 | #include <sys/ioctl.h> |
646 | #include <sys/types.h> | 646 | #include <sys/types.h> |
647 | #include <fcntl.h> | 647 | #include <fcntl.h> |
648 | #include <unistd.h> | 648 | #include <unistd.h> |
649 | #include <errno.h> | 649 | #include <errno.h> |
650 | #include <linux/ioctl.h> | 650 | #include <linux/ioctl.h> |
651 | #include <time.h> | 651 | #include <time.h> |
652 | #endif | 652 | #endif |
653 | 653 | ||
654 | 654 | ||
655 | void Desktop::togglePower() | 655 | void Desktop::togglePower() |
656 | { | 656 | { |
657 | static bool excllock = false; | 657 | static bool excllock = false; |
658 | 658 | ||
659 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); | 659 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); |
660 | 660 | ||
661 | if ( excllock ) | 661 | if ( excllock ) |
662 | return ; | 662 | return ; |
663 | 663 | ||
664 | excllock = true; | 664 | excllock = true; |
665 | 665 | ||
666 | bool wasloggedin = loggedin; | 666 | bool wasloggedin = loggedin; |
667 | loggedin = 0; | 667 | loggedin = 0; |
668 | suspendTime = QDateTime::currentDateTime(); | 668 | suspendTime = QDateTime::currentDateTime(); |
669 | 669 | ||
670 | #ifdef QWS | 670 | #ifdef QWS |
671 | 671 | ||
672 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | 672 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
673 | // Should use a big black window instead. | 673 | // Should use a big black window instead. |
674 | // But this would not show up fast enough | 674 | // But this would not show up fast enough |
675 | QGfx *g = qt_screen-> screenGfx ( ); | 675 | QGfx *g = qt_screen-> screenGfx ( ); |
676 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 676 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
677 | delete g; | 677 | delete g; |
678 | } | 678 | } |
679 | #endif | 679 | #endif |
680 | 680 | ||
681 | ODevice::inst ( )-> suspend ( ); | 681 | ODevice::inst ( )-> suspend ( ); |
682 | 682 | ||
683 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | 683 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call |
684 | QWSServer::screenSaverActivate ( false ); | 684 | QWSServer::screenSaverActivate ( false ); |
685 | 685 | ||
686 | { | 686 | { |
687 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 687 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
688 | } | 688 | } |
689 | 689 | ||
690 | if ( wasloggedin ) | 690 | if ( wasloggedin ) |
691 | login ( true ); | 691 | login ( true ); |
692 | 692 | ||
693 | execAutoStart(); | 693 | execAutoStart(); |
694 | //qcopBridge->closeOpenConnections(); | 694 | //qcopBridge->closeOpenConnections(); |
695 | 695 | ||
696 | excllock = false; | 696 | excllock = false; |
697 | } | 697 | } |
698 | 698 | ||
699 | void Desktop::toggleLight() | 699 | void Desktop::toggleLight() |
700 | { | 700 | { |
701 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); | 701 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); |
702 | e << -2; // toggle | 702 | e << -2; // toggle |
703 | } | 703 | } |
704 | 704 | ||
705 | void Desktop::toggleSymbolInput() | 705 | void Desktop::toggleSymbolInput() |
706 | { | 706 | { |
707 | tb->toggleSymbolInput(); | 707 | tb->toggleSymbolInput(); |
708 | } | 708 | } |
709 | 709 | ||
710 | void Desktop::toggleNumLockState() | 710 | void Desktop::toggleNumLockState() |
711 | { | 711 | { |
712 | tb->toggleNumLockState(); | 712 | tb->toggleNumLockState(); |
713 | } | 713 | } |
714 | 714 | ||
715 | void Desktop::toggleCapsLockState() | 715 | void Desktop::toggleCapsLockState() |
716 | { | 716 | { |
717 | tb->toggleCapsLockState(); | 717 | tb->toggleCapsLockState(); |
718 | } | 718 | } |
719 | 719 | ||
720 | void Desktop::styleChange( QStyle &s ) | 720 | void Desktop::styleChange( QStyle &s ) |
721 | { | 721 | { |
722 | QWidget::styleChange( s ); | 722 | QWidget::styleChange( s ); |
723 | int displayw = qApp->desktop() ->width(); | 723 | int displayw = qApp->desktop() ->width(); |
724 | int displayh = qApp->desktop() ->height(); | 724 | int displayh = qApp->desktop() ->height(); |
725 | 725 | ||
726 | QSize sz = tb->sizeHint(); | 726 | QSize sz = tb->sizeHint(); |
727 | 727 | ||
728 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 728 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
729 | } | 729 | } |
730 | 730 | ||
731 | void DesktopApplication::shutdown() | 731 | void DesktopApplication::shutdown() |
732 | { | 732 | { |
733 | if ( type() != GuiServer ) | 733 | if ( type() != GuiServer ) |
734 | return ; | 734 | return ; |
735 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 735 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
736 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), | 736 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), |
737 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); | 737 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); |
738 | sd->showMaximized(); | 738 | sd->showMaximized(); |
739 | } | 739 | } |
740 | 740 | ||
741 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 741 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
742 | { | 742 | { |
743 | 743 | char *path[] = { "/sbin", "/usr/sbin", 0 }; | |
744 | char *opt = 0; | 744 | char *opt = 0; |
745 | 745 | ||
746 | switch ( t ) { | 746 | switch ( t ) { |
747 | case ShutdownImpl::ShutdownSystem: | 747 | case ShutdownImpl::ShutdownSystem: |
748 | opt = "-h"; | 748 | opt = "-h"; |
749 | // fall through | 749 | // fall through |
750 | case ShutdownImpl::RebootSystem: | 750 | case ShutdownImpl::RebootSystem: |
751 | if ( opt == 0 ) | 751 | if ( opt == 0 ) |
752 | opt = "-r"; | 752 | opt = "-r"; |
753 | 753 | ||
754 | if ( execle( "shutdown", "shutdown", opt, "now", ( void* ) 0, "/sbin", "/usr/sbin", ( void* ) 0 ) < 0 ) | 754 | if ( execle( "shutdown", "shutdown", opt, "now", ( void* ) 0, path ) < 0 ) |
755 | ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); | 755 | ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); |
756 | 756 | ||
757 | break; | 757 | break; |
758 | case ShutdownImpl::RestartDesktop: | 758 | case ShutdownImpl::RestartDesktop: |
759 | restart(); | 759 | restart(); |
760 | break; | 760 | break; |
761 | case ShutdownImpl::TerminateDesktop: | 761 | case ShutdownImpl::TerminateDesktop: |
762 | prepareForTermination( FALSE ); | 762 | prepareForTermination( FALSE ); |
763 | 763 | ||
764 | // This is a workaround for a Qt bug | 764 | // This is a workaround for a Qt bug |
765 | // clipboard applet has to stop its poll timer, or Qt/E | 765 | // clipboard applet has to stop its poll timer, or Qt/E |
766 | // will hang on quit() right before it emits aboutToQuit() | 766 | // will hang on quit() right before it emits aboutToQuit() |
767 | emit aboutToQuit ( ); | 767 | emit aboutToQuit ( ); |
768 | 768 | ||
769 | quit(); | 769 | quit(); |
770 | break; | 770 | break; |
771 | } | 771 | } |
772 | } | 772 | } |
773 | 773 | ||
774 | void DesktopApplication::restart() | 774 | void DesktopApplication::restart() |
775 | { | 775 | { |
776 | prepareForTermination( TRUE ); | 776 | prepareForTermination( TRUE ); |
777 | 777 | ||
778 | #ifdef Q_WS_QWS | 778 | #ifdef Q_WS_QWS |
779 | 779 | ||
780 | for ( int fd = 3; fd < 100; fd++ ) | 780 | for ( int fd = 3; fd < 100; fd++ ) |
781 | close( fd ); | 781 | close( fd ); |
782 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 782 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
783 | 783 | ||
784 | execl( "/sbin/init", "qpe", 0 ); | 784 | execl( "/sbin/init", "qpe", 0 ); |
785 | #elif defined(QT_QWS_CASSIOPEIA) | 785 | #elif defined(QT_QWS_CASSIOPEIA) |
786 | 786 | ||
787 | execl( "/bin/sh", "sh", 0 ); | 787 | execl( "/bin/sh", "sh", 0 ); |
788 | #else | 788 | #else |
789 | 789 | ||
790 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); | 790 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); |
791 | #endif | 791 | #endif |
792 | 792 | ||
793 | exit( 1 ); | 793 | exit( 1 ); |
794 | #endif | 794 | #endif |
795 | } | 795 | } |
796 | 796 | ||
797 | void Desktop::startTransferServer() | 797 | void Desktop::startTransferServer() |
798 | { | 798 | { |
799 | // start qcop bridge server | 799 | // start qcop bridge server |
800 | qcopBridge = new QCopBridge( 4243 ); | 800 | qcopBridge = new QCopBridge( 4243 ); |
801 | if ( !qcopBridge->ok() ) { | 801 | if ( !qcopBridge->ok() ) { |
802 | delete qcopBridge; | 802 | delete qcopBridge; |
803 | qcopBridge = 0; | 803 | qcopBridge = 0; |
804 | } | 804 | } |
805 | // start transfer server | 805 | // start transfer server |
806 | transferServer = new TransferServer( 4242 ); | 806 | transferServer = new TransferServer( 4242 ); |
807 | if ( !transferServer->ok() ) { | 807 | if ( !transferServer->ok() ) { |
808 | delete transferServer; | 808 | delete transferServer; |
809 | transferServer = 0; | 809 | transferServer = 0; |
810 | } | 810 | } |
811 | if ( !transferServer || !qcopBridge ) | 811 | if ( !transferServer || !qcopBridge ) |
812 | startTimer( 2000 ); | 812 | startTimer( 2000 ); |
813 | } | 813 | } |
814 | 814 | ||
815 | void Desktop::timerEvent( QTimerEvent *e ) | 815 | void Desktop::timerEvent( QTimerEvent *e ) |
816 | { | 816 | { |
817 | killTimer( e->timerId() ); | 817 | killTimer( e->timerId() ); |
818 | startTransferServer(); | 818 | startTransferServer(); |
819 | } | 819 | } |
820 | 820 | ||
821 | void Desktop::terminateServers() | 821 | void Desktop::terminateServers() |
822 | { | 822 | { |
823 | delete transferServer; | 823 | delete transferServer; |
824 | delete qcopBridge; | 824 | delete qcopBridge; |
825 | transferServer = 0; | 825 | transferServer = 0; |
826 | qcopBridge = 0; | 826 | qcopBridge = 0; |
827 | } | 827 | } |
828 | 828 | ||
829 | void DesktopApplication::rereadVolumes() | 829 | void DesktopApplication::rereadVolumes() |
830 | { | 830 | { |
831 | Config cfg( "qpe" ); | 831 | Config cfg( "qpe" ); |
832 | cfg. setGroup ( "Volume" ); | 832 | cfg. setGroup ( "Volume" ); |
833 | 833 | ||
834 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); | 834 | m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); |
835 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); | 835 | m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); |
836 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); | 836 | m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); |
837 | } | 837 | } |
838 | 838 | ||
839 | void DesktopApplication::soundAlarm() | 839 | void DesktopApplication::soundAlarm() |
840 | { | 840 | { |
841 | if ( me ( )-> m_alarm_sound ) | 841 | if ( me ( )-> m_alarm_sound ) |
842 | ODevice::inst ( )-> alarmSound ( ); | 842 | ODevice::inst ( )-> alarmSound ( ); |
843 | } | 843 | } |
844 | 844 | ||
845 | DesktopApplication *DesktopApplication::me ( ) | 845 | DesktopApplication *DesktopApplication::me ( ) |
846 | { | 846 | { |
847 | return (DesktopApplication *) qApp; | 847 | return (DesktopApplication *) qApp; |
848 | } | 848 | } |
849 | 849 | ||