author | sandman <sandman> | 2002-08-28 23:01:58 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-08-28 23:01:58 (UTC) |
commit | 42e4592219600d6919c93dec82635e2b64382b37 (patch) (unidiff) | |
tree | 1201ccb206b2b4176c0886a85093e6ff40cc3cbf | |
parent | c46685713eb4ef4bfd0a9dcb7eb53b883704a759 (diff) | |
download | opie-42e4592219600d6919c93dec82635e2b64382b37.zip opie-42e4592219600d6919c93dec82635e2b64382b37.tar.gz opie-42e4592219600d6919c93dec82635e2b64382b37.tar.bz2 |
- speedup for suspend: don't switch off backlight
- don't call processEvents on resume since it is not really needed anymore
-rw-r--r-- | core/launcher/desktop.cpp | 5 | ||||
-rw-r--r-- | core/launcher/main.cpp | 3 |
2 files changed, 3 insertions, 5 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index fb10602..1ec477c 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -363,447 +363,444 @@ Desktop::Desktop() : | |||
363 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 363 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
364 | 364 | ||
365 | tb->show(); | 365 | tb->show(); |
366 | launcher->showMaximized(); | 366 | launcher->showMaximized(); |
367 | launcher->show(); | 367 | launcher->show(); |
368 | launcher->raise(); | 368 | launcher->raise(); |
369 | #if defined(QPE_HAVE_MEMALERTER) | 369 | #if defined(QPE_HAVE_MEMALERTER) |
370 | initMemalerter(); | 370 | initMemalerter(); |
371 | #endif | 371 | #endif |
372 | // start services | 372 | // start services |
373 | startTransferServer(); | 373 | startTransferServer(); |
374 | (void) new IrServer( this ); | 374 | (void) new IrServer( this ); |
375 | rereadVolumes(); | 375 | rereadVolumes(); |
376 | 376 | ||
377 | packageSlave = new PackageSlave( this ); | 377 | packageSlave = new PackageSlave( this ); |
378 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); | 378 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); |
379 | 379 | ||
380 | qApp->installEventFilter( this ); | 380 | qApp->installEventFilter( this ); |
381 | } | 381 | } |
382 | 382 | ||
383 | void Desktop::show() | 383 | void Desktop::show() |
384 | { | 384 | { |
385 | login(TRUE); | 385 | login(TRUE); |
386 | QWidget::show(); | 386 | QWidget::show(); |
387 | } | 387 | } |
388 | 388 | ||
389 | Desktop::~Desktop() | 389 | Desktop::~Desktop() |
390 | { | 390 | { |
391 | delete launcher; | 391 | delete launcher; |
392 | delete tb; | 392 | delete tb; |
393 | delete qcopBridge; | 393 | delete qcopBridge; |
394 | delete transferServer; | 394 | delete transferServer; |
395 | } | 395 | } |
396 | 396 | ||
397 | bool Desktop::recoverMemory() | 397 | bool Desktop::recoverMemory() |
398 | { | 398 | { |
399 | return tb->recoverMemory(); | 399 | return tb->recoverMemory(); |
400 | } | 400 | } |
401 | 401 | ||
402 | void Desktop::checkMemory() | 402 | void Desktop::checkMemory() |
403 | { | 403 | { |
404 | #if defined(QPE_HAVE_MEMALERTER) | 404 | #if defined(QPE_HAVE_MEMALERTER) |
405 | static bool ignoreNormal=FALSE; | 405 | static bool ignoreNormal=FALSE; |
406 | static bool existingMessage=FALSE; | 406 | static bool existingMessage=FALSE; |
407 | 407 | ||
408 | if(existingMessage) | 408 | if(existingMessage) |
409 | return; // don't show a second message while still on first | 409 | return; // don't show a second message while still on first |
410 | 410 | ||
411 | existingMessage = TRUE; | 411 | existingMessage = TRUE; |
412 | switch ( memstate ) { | 412 | switch ( memstate ) { |
413 | case Unknown: | 413 | case Unknown: |
414 | break; | 414 | break; |
415 | case Low: | 415 | case Low: |
416 | memstate = Unknown; | 416 | memstate = Unknown; |
417 | if ( recoverMemory() ) | 417 | if ( recoverMemory() ) |
418 | ignoreNormal = TRUE; | 418 | ignoreNormal = TRUE; |
419 | else | 419 | else |
420 | QMessageBox::warning( 0 , "Memory Status", | 420 | QMessageBox::warning( 0 , "Memory Status", |
421 | "The memory smacks of shortage. \n" | 421 | "The memory smacks of shortage. \n" |
422 | "Please save data. " ); | 422 | "Please save data. " ); |
423 | break; | 423 | break; |
424 | case Normal: | 424 | case Normal: |
425 | memstate = Unknown; | 425 | memstate = Unknown; |
426 | if ( ignoreNormal ) | 426 | if ( ignoreNormal ) |
427 | ignoreNormal = FALSE; | 427 | ignoreNormal = FALSE; |
428 | else | 428 | else |
429 | QMessageBox::information ( 0 , "Memory Status", | 429 | QMessageBox::information ( 0 , "Memory Status", |
430 | "There is enough memory again." ); | 430 | "There is enough memory again." ); |
431 | break; | 431 | break; |
432 | case VeryLow: | 432 | case VeryLow: |
433 | memstate = Unknown; | 433 | memstate = Unknown; |
434 | QMessageBox::critical( 0 , "Memory Status", | 434 | QMessageBox::critical( 0 , "Memory Status", |
435 | "The memory is very low. \n" | 435 | "The memory is very low. \n" |
436 | "Please end this application \n" | 436 | "Please end this application \n" |
437 | "immediately." ); | 437 | "immediately." ); |
438 | recoverMemory(); | 438 | recoverMemory(); |
439 | } | 439 | } |
440 | existingMessage = FALSE; | 440 | existingMessage = FALSE; |
441 | #endif | 441 | #endif |
442 | } | 442 | } |
443 | 443 | ||
444 | static bool isVisibleWindow(int wid) | 444 | static bool isVisibleWindow(int wid) |
445 | { | 445 | { |
446 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 446 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
447 | QWSWindow* w; | 447 | QWSWindow* w; |
448 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 448 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
449 | if ( w->winId() == wid ) | 449 | if ( w->winId() == wid ) |
450 | return !w->isFullyObscured(); | 450 | return !w->isFullyObscured(); |
451 | } | 451 | } |
452 | return FALSE; | 452 | return FALSE; |
453 | } | 453 | } |
454 | 454 | ||
455 | static bool hasVisibleWindow(const QString& clientname) | 455 | static bool hasVisibleWindow(const QString& clientname) |
456 | { | 456 | { |
457 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 457 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
458 | QWSWindow* w; | 458 | QWSWindow* w; |
459 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 459 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
460 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) | 460 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) |
461 | return TRUE; | 461 | return TRUE; |
462 | } | 462 | } |
463 | return FALSE; | 463 | return FALSE; |
464 | } | 464 | } |
465 | 465 | ||
466 | void Desktop::raiseLauncher() | 466 | void Desktop::raiseLauncher() |
467 | { | 467 | { |
468 | Config cfg("qpe"); //F12 'Home' | 468 | Config cfg("qpe"); //F12 'Home' |
469 | cfg.setGroup("AppsKey"); | 469 | cfg.setGroup("AppsKey"); |
470 | QString tempItem; | 470 | QString tempItem; |
471 | tempItem = cfg.readEntry("Middle","Home"); | 471 | tempItem = cfg.readEntry("Middle","Home"); |
472 | if(tempItem == "Home" || tempItem.isEmpty()) { | 472 | if(tempItem == "Home" || tempItem.isEmpty()) { |
473 | if ( isVisibleWindow(launcher->winId()) ) | 473 | if ( isVisibleWindow(launcher->winId()) ) |
474 | launcher->nextView(); | 474 | launcher->nextView(); |
475 | else | 475 | else |
476 | launcher->raise(); | 476 | launcher->raise(); |
477 | } else { | 477 | } else { |
478 | QCopEnvelope e("QPE/System","execute(QString)"); | 478 | QCopEnvelope e("QPE/System","execute(QString)"); |
479 | e << tempItem; | 479 | e << tempItem; |
480 | } | 480 | } |
481 | } | 481 | } |
482 | 482 | ||
483 | void Desktop::executeOrModify(const QString& appLnkFile) | 483 | void Desktop::executeOrModify(const QString& appLnkFile) |
484 | { | 484 | { |
485 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); | 485 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); |
486 | if ( lnk.isValid() ) { | 486 | if ( lnk.isValid() ) { |
487 | QCString app = lnk.exec().utf8(); | 487 | QCString app = lnk.exec().utf8(); |
488 | Global::terminateBuiltin("calibrate"); | 488 | Global::terminateBuiltin("calibrate"); |
489 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { | 489 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { |
490 | MRUList::addTask(&lnk); | 490 | MRUList::addTask(&lnk); |
491 | if ( hasVisibleWindow(app) ) | 491 | if ( hasVisibleWindow(app) ) |
492 | QCopChannel::send("QPE/Application/" + app, "nextView()"); | 492 | QCopChannel::send("QPE/Application/" + app, "nextView()"); |
493 | else | 493 | else |
494 | QCopChannel::send("QPE/Application/" + app, "raise()"); | 494 | QCopChannel::send("QPE/Application/" + app, "raise()"); |
495 | } else { | 495 | } else { |
496 | lnk.execute(); | 496 | lnk.execute(); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | void Desktop::raiseDatebook() | 501 | void Desktop::raiseDatebook() |
502 | { | 502 | { |
503 | Config cfg("qpe"); //F9 'Activity' | 503 | Config cfg("qpe"); //F9 'Activity' |
504 | cfg.setGroup("AppsKey"); | 504 | cfg.setGroup("AppsKey"); |
505 | QString tempItem; | 505 | QString tempItem; |
506 | tempItem = cfg.readEntry("LeftEnd","Calender"); | 506 | tempItem = cfg.readEntry("LeftEnd","Calender"); |
507 | if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); | 507 | if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); |
508 | else { | 508 | else { |
509 | QCopEnvelope e("QPE/System","execute(QString)"); | 509 | QCopEnvelope e("QPE/System","execute(QString)"); |
510 | e << tempItem; | 510 | e << tempItem; |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | void Desktop::raiseContacts() | 514 | void Desktop::raiseContacts() |
515 | { | 515 | { |
516 | Config cfg("qpe"); //F10, 'Contacts' | 516 | Config cfg("qpe"); //F10, 'Contacts' |
517 | cfg.setGroup("AppsKey"); | 517 | cfg.setGroup("AppsKey"); |
518 | QString tempItem; | 518 | QString tempItem; |
519 | tempItem = cfg.readEntry("Left2nd","Address Book"); | 519 | tempItem = cfg.readEntry("Left2nd","Address Book"); |
520 | if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); | 520 | if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); |
521 | else { | 521 | else { |
522 | QCopEnvelope e("QPE/System","execute(QString)"); | 522 | QCopEnvelope e("QPE/System","execute(QString)"); |
523 | e << tempItem; | 523 | e << tempItem; |
524 | } | 524 | } |
525 | } | 525 | } |
526 | 526 | ||
527 | void Desktop::raiseMenu() | 527 | void Desktop::raiseMenu() |
528 | { | 528 | { |
529 | Config cfg("qpe"); //F11, 'Menu' | 529 | Config cfg("qpe"); //F11, 'Menu' |
530 | cfg.setGroup("AppsKey"); | 530 | cfg.setGroup("AppsKey"); |
531 | QString tempItem; | 531 | QString tempItem; |
532 | tempItem = cfg.readEntry("Right2nd","Popup Menu"); | 532 | tempItem = cfg.readEntry("Right2nd","Popup Menu"); |
533 | if(tempItem == "Popup Menu" || tempItem.isEmpty()) { | 533 | if(tempItem == "Popup Menu" || tempItem.isEmpty()) { |
534 | Global::terminateBuiltin("calibrate"); | 534 | Global::terminateBuiltin("calibrate"); |
535 | tb->startMenu()->launch(); | 535 | tb->startMenu()->launch(); |
536 | } else { | 536 | } else { |
537 | QCopEnvelope e("QPE/System","execute(QString)"); | 537 | QCopEnvelope e("QPE/System","execute(QString)"); |
538 | e << tempItem; | 538 | e << tempItem; |
539 | } | 539 | } |
540 | } | 540 | } |
541 | 541 | ||
542 | void Desktop::raiseEmail() | 542 | void Desktop::raiseEmail() |
543 | { | 543 | { |
544 | Config cfg("qpe"); //F13, 'Mail' | 544 | Config cfg("qpe"); //F13, 'Mail' |
545 | cfg.setGroup("AppsKey"); | 545 | cfg.setGroup("AppsKey"); |
546 | QString tempItem; | 546 | QString tempItem; |
547 | tempItem = cfg.readEntry("RightEnd","Mail"); | 547 | tempItem = cfg.readEntry("RightEnd","Mail"); |
548 | if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); | 548 | if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); |
549 | else { | 549 | else { |
550 | QCopEnvelope e("QPE/System","execute(QString)"); | 550 | QCopEnvelope e("QPE/System","execute(QString)"); |
551 | e << tempItem; | 551 | e << tempItem; |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | // autoStarts apps on resume and start | 555 | // autoStarts apps on resume and start |
556 | void Desktop::execAutoStart() { | 556 | void Desktop::execAutoStart() { |
557 | QString appName; | 557 | QString appName; |
558 | int delay; | 558 | int delay; |
559 | QDateTime now = QDateTime::currentDateTime(); | 559 | QDateTime now = QDateTime::currentDateTime(); |
560 | Config cfg( "autostart" ); | 560 | Config cfg( "autostart" ); |
561 | cfg.setGroup( "AutoStart" ); | 561 | cfg.setGroup( "AutoStart" ); |
562 | appName = cfg.readEntry( "Apps", "" ); | 562 | appName = cfg.readEntry( "Apps", "" ); |
563 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 563 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
564 | // If the time between suspend and resume was longer then the | 564 | // If the time between suspend and resume was longer then the |
565 | // value saved as delay, start the app | 565 | // value saved as delay, start the app |
566 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 566 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
567 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 567 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
568 | e << QString( appName ); | 568 | e << QString( appName ); |
569 | } | 569 | } |
570 | } | 570 | } |
571 | 571 | ||
572 | #if defined(QPE_HAVE_TOGGLELIGHT) | 572 | #if defined(QPE_HAVE_TOGGLELIGHT) |
573 | #include <qpe/config.h> | 573 | #include <qpe/config.h> |
574 | 574 | ||
575 | #include <sys/ioctl.h> | 575 | #include <sys/ioctl.h> |
576 | #include <sys/types.h> | 576 | #include <sys/types.h> |
577 | #include <fcntl.h> | 577 | #include <fcntl.h> |
578 | #include <unistd.h> | 578 | #include <unistd.h> |
579 | #include <errno.h> | 579 | #include <errno.h> |
580 | #include <linux/ioctl.h> | 580 | #include <linux/ioctl.h> |
581 | #include <time.h> | 581 | #include <time.h> |
582 | #endif | 582 | #endif |
583 | 583 | ||
584 | static bool blanked=FALSE; | 584 | static bool blanked=FALSE; |
585 | 585 | ||
586 | static void blankScreen() | 586 | static void blankScreen() |
587 | { | 587 | { |
588 | if ( !qt_screen ) return; | 588 | if ( !qt_screen ) return; |
589 | /* Should use a big black window instead. | 589 | /* Should use a big black window instead. |
590 | QGfx* g = qt_screen->screenGfx(); | 590 | QGfx* g = qt_screen->screenGfx(); |
591 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); | 591 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); |
592 | delete g; | 592 | delete g; |
593 | */ | 593 | */ |
594 | blanked = TRUE; | 594 | blanked = TRUE; |
595 | } | 595 | } |
596 | 596 | ||
597 | static void darkScreen() | 597 | static void darkScreen() |
598 | { | 598 | { |
599 | extern void qpe_setBacklight(int); | 599 | extern void qpe_setBacklight(int); |
600 | qpe_setBacklight(0); // force off | 600 | qpe_setBacklight(0); // force off |
601 | } | 601 | } |
602 | 602 | ||
603 | 603 | ||
604 | void Desktop::togglePower() | 604 | void Desktop::togglePower() |
605 | { | 605 | { |
606 | extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop | 606 | extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop |
607 | 607 | ||
608 | static bool excllock = false; | 608 | static bool excllock = false; |
609 | 609 | ||
610 | if ( excllock ) | 610 | if ( excllock ) |
611 | return; | 611 | return; |
612 | 612 | ||
613 | excllock = true; | 613 | excllock = true; |
614 | 614 | ||
615 | bool wasloggedin = loggedin; | 615 | bool wasloggedin = loggedin; |
616 | loggedin=0; | 616 | loggedin=0; |
617 | suspendTime = QDateTime::currentDateTime(); | 617 | suspendTime = QDateTime::currentDateTime(); |
618 | 618 | ||
619 | qpe_setBacklight ( 0 ); // force LCD off | 619 | //qpe_setBacklight ( 0 ); // force LCD off (sandman: why ????) |
620 | 620 | ||
621 | if ( wasloggedin ) | 621 | if ( wasloggedin ) |
622 | blankScreen(); | 622 | blankScreen(); |
623 | 623 | ||
624 | ODevice::inst ( )-> suspend ( ); | 624 | ODevice::inst ( )-> suspend ( ); |
625 | 625 | ||
626 | QWSServer::screenSaverActivate ( false ); | 626 | QWSServer::screenSaverActivate ( false ); |
627 | 627 | ||
628 | qpe_setBacklight ( -3 ); // force LCD on | 628 | qpe_setBacklight ( -3 ); // force LCD on |
629 | 629 | ||
630 | { | 630 | { |
631 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 631 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
632 | } | 632 | } |
633 | 633 | ||
634 | if ( wasloggedin ) | 634 | if ( wasloggedin ) |
635 | login(TRUE); | 635 | login(TRUE); |
636 | 636 | ||
637 | execAutoStart(); | 637 | execAutoStart(); |
638 | //qcopBridge->closeOpenConnections(); | 638 | //qcopBridge->closeOpenConnections(); |
639 | //qDebug("called togglePower()!!!!!!"); | ||
640 | |||
641 | qApp-> processEvents ( ); | ||
642 | 639 | ||
643 | excllock = false; | 640 | excllock = false; |
644 | } | 641 | } |
645 | 642 | ||
646 | void Desktop::toggleLight() | 643 | void Desktop::toggleLight() |
647 | { | 644 | { |
648 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 645 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
649 | e << -2; // toggle | 646 | e << -2; // toggle |
650 | } | 647 | } |
651 | 648 | ||
652 | void Desktop::toggleSymbolInput() | 649 | void Desktop::toggleSymbolInput() |
653 | { | 650 | { |
654 | tb->toggleSymbolInput(); | 651 | tb->toggleSymbolInput(); |
655 | } | 652 | } |
656 | 653 | ||
657 | void Desktop::toggleNumLockState() | 654 | void Desktop::toggleNumLockState() |
658 | { | 655 | { |
659 | tb->toggleNumLockState(); | 656 | tb->toggleNumLockState(); |
660 | } | 657 | } |
661 | 658 | ||
662 | void Desktop::toggleCapsLockState() | 659 | void Desktop::toggleCapsLockState() |
663 | { | 660 | { |
664 | tb->toggleCapsLockState(); | 661 | tb->toggleCapsLockState(); |
665 | } | 662 | } |
666 | 663 | ||
667 | void Desktop::styleChange( QStyle &s ) | 664 | void Desktop::styleChange( QStyle &s ) |
668 | { | 665 | { |
669 | QWidget::styleChange( s ); | 666 | QWidget::styleChange( s ); |
670 | int displayw = qApp->desktop()->width(); | 667 | int displayw = qApp->desktop()->width(); |
671 | int displayh = qApp->desktop()->height(); | 668 | int displayh = qApp->desktop()->height(); |
672 | 669 | ||
673 | QSize sz = tb->sizeHint(); | 670 | QSize sz = tb->sizeHint(); |
674 | 671 | ||
675 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 672 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
676 | } | 673 | } |
677 | 674 | ||
678 | void DesktopApplication::shutdown() | 675 | void DesktopApplication::shutdown() |
679 | { | 676 | { |
680 | if ( type() != GuiServer ) | 677 | if ( type() != GuiServer ) |
681 | return; | 678 | return; |
682 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 679 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
683 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), | 680 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), |
684 | this, SLOT(shutdown(ShutdownImpl::Type)) ); | 681 | this, SLOT(shutdown(ShutdownImpl::Type)) ); |
685 | sd->showMaximized(); | 682 | sd->showMaximized(); |
686 | } | 683 | } |
687 | 684 | ||
688 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 685 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
689 | { | 686 | { |
690 | switch ( t ) { | 687 | switch ( t ) { |
691 | case ShutdownImpl::ShutdownSystem: | 688 | case ShutdownImpl::ShutdownSystem: |
692 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); | 689 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); |
693 | break; | 690 | break; |
694 | case ShutdownImpl::RebootSystem: | 691 | case ShutdownImpl::RebootSystem: |
695 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); | 692 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); |
696 | break; | 693 | break; |
697 | case ShutdownImpl::RestartDesktop: | 694 | case ShutdownImpl::RestartDesktop: |
698 | restart(); | 695 | restart(); |
699 | break; | 696 | break; |
700 | case ShutdownImpl::TerminateDesktop: | 697 | case ShutdownImpl::TerminateDesktop: |
701 | prepareForTermination(FALSE); | 698 | prepareForTermination(FALSE); |
702 | 699 | ||
703 | // This is a workaround for a Qt bug | 700 | // This is a workaround for a Qt bug |
704 | // clipboard applet has to stop its poll timer, or Qt/E | 701 | // clipboard applet has to stop its poll timer, or Qt/E |
705 | // will hang on quit() right before it emits aboutToQuit() | 702 | // will hang on quit() right before it emits aboutToQuit() |
706 | emit aboutToQuit ( ); | 703 | emit aboutToQuit ( ); |
707 | 704 | ||
708 | quit(); | 705 | quit(); |
709 | break; | 706 | break; |
710 | } | 707 | } |
711 | } | 708 | } |
712 | 709 | ||
713 | void DesktopApplication::restart() | 710 | void DesktopApplication::restart() |
714 | { | 711 | { |
715 | prepareForTermination(TRUE); | 712 | prepareForTermination(TRUE); |
716 | 713 | ||
717 | #ifdef Q_WS_QWS | 714 | #ifdef Q_WS_QWS |
718 | for ( int fd = 3; fd < 100; fd++ ) | 715 | for ( int fd = 3; fd < 100; fd++ ) |
719 | close( fd ); | 716 | close( fd ); |
720 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 717 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
721 | execl( "/sbin/init", "qpe", 0 ); | 718 | execl( "/sbin/init", "qpe", 0 ); |
722 | #elif defined(QT_QWS_CASSIOPEIA) | 719 | #elif defined(QT_QWS_CASSIOPEIA) |
723 | execl( "/bin/sh", "sh", 0 ); | 720 | execl( "/bin/sh", "sh", 0 ); |
724 | #else | 721 | #else |
725 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); | 722 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); |
726 | #endif | 723 | #endif |
727 | exit(1); | 724 | exit(1); |
728 | #endif | 725 | #endif |
729 | } | 726 | } |
730 | 727 | ||
731 | void Desktop::startTransferServer() | 728 | void Desktop::startTransferServer() |
732 | { | 729 | { |
733 | // start qcop bridge server | 730 | // start qcop bridge server |
734 | qcopBridge = new QCopBridge( 4243 ); | 731 | qcopBridge = new QCopBridge( 4243 ); |
735 | if ( !qcopBridge->ok() ) { | 732 | if ( !qcopBridge->ok() ) { |
736 | delete qcopBridge; | 733 | delete qcopBridge; |
737 | qcopBridge = 0; | 734 | qcopBridge = 0; |
738 | } | 735 | } |
739 | // start transfer server | 736 | // start transfer server |
740 | transferServer = new TransferServer( 4242 ); | 737 | transferServer = new TransferServer( 4242 ); |
741 | if ( !transferServer->ok() ) { | 738 | if ( !transferServer->ok() ) { |
742 | delete transferServer; | 739 | delete transferServer; |
743 | transferServer = 0; | 740 | transferServer = 0; |
744 | } | 741 | } |
745 | if ( !transferServer || !qcopBridge ) | 742 | if ( !transferServer || !qcopBridge ) |
746 | startTimer( 2000 ); | 743 | startTimer( 2000 ); |
747 | } | 744 | } |
748 | 745 | ||
749 | void Desktop::timerEvent( QTimerEvent *e ) | 746 | void Desktop::timerEvent( QTimerEvent *e ) |
750 | { | 747 | { |
751 | killTimer( e->timerId() ); | 748 | killTimer( e->timerId() ); |
752 | startTransferServer(); | 749 | startTransferServer(); |
753 | } | 750 | } |
754 | 751 | ||
755 | void Desktop::terminateServers() | 752 | void Desktop::terminateServers() |
756 | { | 753 | { |
757 | delete transferServer; | 754 | delete transferServer; |
758 | delete qcopBridge; | 755 | delete qcopBridge; |
759 | transferServer = 0; | 756 | transferServer = 0; |
760 | qcopBridge = 0; | 757 | qcopBridge = 0; |
761 | } | 758 | } |
762 | 759 | ||
763 | void Desktop::rereadVolumes() | 760 | void Desktop::rereadVolumes() |
764 | { | 761 | { |
765 | Config cfg("qpe"); | 762 | Config cfg("qpe"); |
766 | cfg.setGroup("Volume"); | 763 | cfg.setGroup("Volume"); |
767 | touchclick = cfg.readBoolEntry("TouchSound"); | 764 | touchclick = cfg.readBoolEntry("TouchSound"); |
768 | keyclick = cfg.readBoolEntry("KeySound"); | 765 | keyclick = cfg.readBoolEntry("KeySound"); |
769 | alarmsound = cfg.readBoolEntry("AlarmSound"); | 766 | alarmsound = cfg.readBoolEntry("AlarmSound"); |
770 | // Config cfg("Sound"); | 767 | // Config cfg("Sound"); |
771 | // cfg.setGroup("System"); | 768 | // cfg.setGroup("System"); |
772 | // touchclick = cfg.readBoolEntry("Touch"); | 769 | // touchclick = cfg.readBoolEntry("Touch"); |
773 | // keyclick = cfg.readBoolEntry("Key"); | 770 | // keyclick = cfg.readBoolEntry("Key"); |
774 | } | 771 | } |
775 | 772 | ||
776 | void Desktop::keyClick() | 773 | void Desktop::keyClick() |
777 | { | 774 | { |
778 | if ( keyclick ) | 775 | if ( keyclick ) |
779 | ODevice::inst ( )-> keySound ( ); | 776 | ODevice::inst ( )-> keySound ( ); |
780 | } | 777 | } |
781 | 778 | ||
782 | void Desktop::screenClick() | 779 | void Desktop::screenClick() |
783 | { | 780 | { |
784 | if ( touchclick ) | 781 | if ( touchclick ) |
785 | ODevice::inst ( )-> touchSound ( ); | 782 | ODevice::inst ( )-> touchSound ( ); |
786 | } | 783 | } |
787 | 784 | ||
788 | void Desktop::soundAlarm() | 785 | void Desktop::soundAlarm() |
789 | { | 786 | { |
790 | if ( qpedesktop-> alarmsound ) | 787 | if ( qpedesktop-> alarmsound ) |
791 | ODevice::inst ( )-> alarmSound ( ); | 788 | ODevice::inst ( )-> alarmSound ( ); |
792 | } | 789 | } |
793 | 790 | ||
794 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | 791 | bool Desktop::eventFilter( QObject *, QEvent *ev ) |
795 | { | 792 | { |
796 | if ( ev-> type ( ) == QEvent::KeyPress ) { | 793 | if ( ev-> type ( ) == QEvent::KeyPress ) { |
797 | QKeyEvent *ke = (QKeyEvent *) ev; | 794 | QKeyEvent *ke = (QKeyEvent *) ev; |
798 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key | 795 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key |
799 | QWidget *active = qApp-> activeWindow ( ); | 796 | QWidget *active = qApp-> activeWindow ( ); |
800 | 797 | ||
801 | if ( active && active-> isPopup ( )) | 798 | if ( active && active-> isPopup ( )) |
802 | active->close(); | 799 | active->close(); |
803 | 800 | ||
804 | raiseMenu ( ); | 801 | raiseMenu ( ); |
805 | return true; | 802 | return true; |
806 | } | 803 | } |
807 | } | 804 | } |
808 | return false; | 805 | return false; |
809 | } | 806 | } |
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 3ee5e26..5cf624b 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -99,288 +99,289 @@ void initCassiopeia() | |||
99 | qInstallMsgHandler(ignoreMessage); | 99 | qInstallMsgHandler(ignoreMessage); |
100 | } | 100 | } |
101 | #endif | 101 | #endif |
102 | 102 | ||
103 | #ifdef QPE_OWNAPM | 103 | #ifdef QPE_OWNAPM |
104 | #include <sys/ioctl.h> | 104 | #include <sys/ioctl.h> |
105 | #include <sys/types.h> | 105 | #include <sys/types.h> |
106 | #include <fcntl.h> | 106 | #include <fcntl.h> |
107 | #include <unistd.h> | 107 | #include <unistd.h> |
108 | #include <errno.h> | 108 | #include <errno.h> |
109 | #include <linux/ioctl.h> | 109 | #include <linux/ioctl.h> |
110 | #include <qpe/global.h> | 110 | #include <qpe/global.h> |
111 | 111 | ||
112 | static void disableAPM() | 112 | static void disableAPM() |
113 | { | 113 | { |
114 | 114 | ||
115 | int fd, cur_val, ret; | 115 | int fd, cur_val, ret; |
116 | char *device = "/dev/apm_bios"; | 116 | char *device = "/dev/apm_bios"; |
117 | 117 | ||
118 | fd = open (device, O_WRONLY); | 118 | fd = open (device, O_WRONLY); |
119 | 119 | ||
120 | if (fd == -1) { | 120 | if (fd == -1) { |
121 | perror(device); | 121 | perror(device); |
122 | return; | 122 | return; |
123 | } | 123 | } |
124 | 124 | ||
125 | cur_val = ioctl(fd, APM_IOCGEVTSRC, 0); | 125 | cur_val = ioctl(fd, APM_IOCGEVTSRC, 0); |
126 | if (cur_val == -1) { | 126 | if (cur_val == -1) { |
127 | perror("ioctl"); | 127 | perror("ioctl"); |
128 | exit(errno); | 128 | exit(errno); |
129 | } | 129 | } |
130 | 130 | ||
131 | ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON); | 131 | ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON); |
132 | if (ret == -1) { | 132 | if (ret == -1) { |
133 | perror("ioctl"); | 133 | perror("ioctl"); |
134 | return; | 134 | return; |
135 | } | 135 | } |
136 | close(fd); | 136 | close(fd); |
137 | } | 137 | } |
138 | 138 | ||
139 | static void initAPM() | 139 | static void initAPM() |
140 | { | 140 | { |
141 | // So that we have to do it ourself, but better. | 141 | // So that we have to do it ourself, but better. |
142 | disableAPM(); | 142 | disableAPM(); |
143 | } | 143 | } |
144 | #endif | 144 | #endif |
145 | 145 | ||
146 | #ifdef QT_DEMO_SINGLE_FLOPPY | 146 | #ifdef QT_DEMO_SINGLE_FLOPPY |
147 | #include <sys/mount.h> | 147 | #include <sys/mount.h> |
148 | 148 | ||
149 | void initFloppy() | 149 | void initFloppy() |
150 | { | 150 | { |
151 | mount("none","/proc","proc",0,0); | 151 | mount("none","/proc","proc",0,0); |
152 | setenv( "QTDIR", "/", 0 ); | 152 | setenv( "QTDIR", "/", 0 ); |
153 | setenv( "HOME", "/root", 0 ); | 153 | setenv( "HOME", "/root", 0 ); |
154 | setenv( "QWS_SIZE", "240x320", 0 ); | 154 | setenv( "QWS_SIZE", "240x320", 0 ); |
155 | } | 155 | } |
156 | #endif | 156 | #endif |
157 | 157 | ||
158 | 158 | ||
159 | void initEnvironment() | 159 | void initEnvironment() |
160 | { | 160 | { |
161 | Config config("locale"); | 161 | Config config("locale"); |
162 | config.setGroup( "Location" ); | 162 | config.setGroup( "Location" ); |
163 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); | 163 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); |
164 | 164 | ||
165 | // if not timezone set, pick New York | 165 | // if not timezone set, pick New York |
166 | if (tz.isNull()) | 166 | if (tz.isNull()) |
167 | tz = "America/New_York"; | 167 | tz = "America/New_York"; |
168 | 168 | ||
169 | setenv( "TZ", tz, 1 ); | 169 | setenv( "TZ", tz, 1 ); |
170 | config.writeEntry( "Timezone", tz); | 170 | config.writeEntry( "Timezone", tz); |
171 | 171 | ||
172 | config.setGroup( "Language" ); | 172 | config.setGroup( "Language" ); |
173 | QString lang = config.readEntry( "Language", getenv("LANG") ); | 173 | QString lang = config.readEntry( "Language", getenv("LANG") ); |
174 | if ( !lang.isNull() ) | 174 | if ( !lang.isNull() ) |
175 | setenv( "LANG", lang, 1 ); | 175 | setenv( "LANG", lang, 1 ); |
176 | } | 176 | } |
177 | 177 | ||
178 | static void initBacklight() | 178 | static void initBacklight() |
179 | { | 179 | { |
180 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | 180 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); |
181 | e << -3; // Forced on | 181 | e << -3; // Forced on |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter | 185 | class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter |
186 | { | 186 | { |
187 | public: | 187 | public: |
188 | ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) | 188 | ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) |
189 | { | 189 | { |
190 | bool doinst = false; | 190 | bool doinst = false; |
191 | 191 | ||
192 | m_model = ODevice::inst ( )-> model ( ); | 192 | m_model = ODevice::inst ( )-> model ( ); |
193 | m_power_timer = 0; | 193 | m_power_timer = 0; |
194 | 194 | ||
195 | switch ( m_model ) { | 195 | switch ( m_model ) { |
196 | case OMODEL_iPAQ_H31xx: | 196 | case OMODEL_iPAQ_H31xx: |
197 | case OMODEL_iPAQ_H36xx: | 197 | case OMODEL_iPAQ_H36xx: |
198 | case OMODEL_iPAQ_H37xx: | 198 | case OMODEL_iPAQ_H37xx: |
199 | case OMODEL_iPAQ_H38xx: doinst = true; | 199 | case OMODEL_iPAQ_H38xx: doinst = true; |
200 | break; | 200 | break; |
201 | default : break; | 201 | default : break; |
202 | } | 202 | } |
203 | if ( doinst ) | 203 | if ( doinst ) |
204 | QWSServer::setKeyboardFilter ( this ); | 204 | QWSServer::setKeyboardFilter ( this ); |
205 | } | 205 | } |
206 | 206 | ||
207 | virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 207 | virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
208 | { | 208 | { |
209 | bool kill = false; | 209 | bool kill = false; |
210 | 210 | ||
211 | // Rotate cursor keys 180° | 211 | // Rotate cursor keys 180° |
212 | switch ( m_model ) { | 212 | switch ( m_model ) { |
213 | case OMODEL_iPAQ_H31xx: | 213 | case OMODEL_iPAQ_H31xx: |
214 | case OMODEL_iPAQ_H38xx: { | 214 | case OMODEL_iPAQ_H38xx: { |
215 | int newkeycode = keycode; | 215 | int newkeycode = keycode; |
216 | 216 | ||
217 | switch ( keycode ) { | 217 | switch ( keycode ) { |
218 | case Key_Left : newkeycode = Key_Right; break; | 218 | case Key_Left : newkeycode = Key_Right; break; |
219 | case Key_Right: newkeycode = Key_Left; break; | 219 | case Key_Right: newkeycode = Key_Left; break; |
220 | case Key_Up : newkeycode = Key_Down; break; | 220 | case Key_Up : newkeycode = Key_Down; break; |
221 | case Key_Down : newkeycode = Key_Up; break; | 221 | case Key_Down : newkeycode = Key_Up; break; |
222 | } | 222 | } |
223 | if ( newkeycode != keycode ) { | 223 | if ( newkeycode != keycode ) { |
224 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 224 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
225 | kill = true; | 225 | kill = true; |
226 | } | 226 | } |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | default: break; | 229 | default: break; |
230 | } | 230 | } |
231 | 231 | ||
232 | // map Power Button short/long press to F34/F35 | 232 | // map Power Button short/long press to F34/F35 |
233 | switch ( m_model ) { | 233 | switch ( m_model ) { |
234 | case OMODEL_iPAQ_H31xx: | 234 | case OMODEL_iPAQ_H31xx: |
235 | case OMODEL_iPAQ_H36xx: | 235 | case OMODEL_iPAQ_H36xx: |
236 | case OMODEL_iPAQ_H37xx: | 236 | case OMODEL_iPAQ_H37xx: |
237 | case OMODEL_iPAQ_H38xx: { | 237 | case OMODEL_iPAQ_H38xx: { |
238 | if ( keycode == Key_SysReq ) { | 238 | if ( keycode == Key_SysReq ) { |
239 | if ( isPress ) { | 239 | if ( isPress ) { |
240 | if ( m_power_timer ) | 240 | if ( m_power_timer ) |
241 | killTimer ( m_power_timer ); | 241 | killTimer ( m_power_timer ); |
242 | m_power_timer = startTimer ( 500 ); | 242 | m_power_timer = startTimer ( 500 ); |
243 | } | 243 | } |
244 | else if ( m_power_timer ) { | 244 | else if ( m_power_timer ) { |
245 | killTimer ( m_power_timer ); | 245 | killTimer ( m_power_timer ); |
246 | m_power_timer = 0; | 246 | m_power_timer = 0; |
247 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); | 247 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); |
248 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); | 248 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); |
249 | } | 249 | } |
250 | kill = true; | 250 | kill = true; |
251 | } | 251 | } |
252 | break; | 252 | break; |
253 | } | 253 | } |
254 | default: break; | 254 | default: break; |
255 | } | 255 | } |
256 | return kill; | 256 | return kill; |
257 | } | 257 | } |
258 | 258 | ||
259 | virtual void timerEvent ( QTimerEvent * ) | 259 | virtual void timerEvent ( QTimerEvent * ) |
260 | { | 260 | { |
261 | killTimer ( m_power_timer ); | 261 | killTimer ( m_power_timer ); |
262 | m_power_timer = 0; | 262 | m_power_timer = 0; |
263 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); | 263 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); |
264 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); | 264 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); |
265 | } | 265 | } |
266 | 266 | ||
267 | private: | 267 | private: |
268 | OModel m_model; | 268 | OModel m_model; |
269 | int m_power_timer; | 269 | int m_power_timer; |
270 | }; | 270 | }; |
271 | 271 | ||
272 | 272 | ||
273 | 273 | ||
274 | int initApplication( int argc, char ** argv ) | 274 | int initApplication( int argc, char ** argv ) |
275 | { | 275 | { |
276 | #ifdef QT_QWS_CASSIOPEIA | 276 | #ifdef QT_QWS_CASSIOPEIA |
277 | initCassiopeia(); | 277 | initCassiopeia(); |
278 | #endif | 278 | #endif |
279 | 279 | ||
280 | #ifdef QPE_OWNAPM | 280 | #ifdef QPE_OWNAPM |
281 | initAPM(); | 281 | initAPM(); |
282 | #endif | 282 | #endif |
283 | 283 | ||
284 | #ifdef QT_DEMO_SINGLE_FLOPPY | 284 | #ifdef QT_DEMO_SINGLE_FLOPPY |
285 | initFloppy(); | 285 | initFloppy(); |
286 | #endif | 286 | #endif |
287 | 287 | ||
288 | initEnvironment(); | 288 | initEnvironment(); |
289 | 289 | ||
290 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) | 290 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) |
291 | setenv( "QWS_SIZE", "240x320", 0 ); | 291 | setenv( "QWS_SIZE", "240x320", 0 ); |
292 | #endif | 292 | #endif |
293 | 293 | ||
294 | //Don't flicker at startup: | 294 | //Don't flicker at startup: |
295 | QWSServer::setDesktopBackground( QImage() ); | 295 | QWSServer::setDesktopBackground( QImage() ); |
296 | DesktopApplication a( argc, argv, QApplication::GuiServer ); | 296 | DesktopApplication a( argc, argv, QApplication::GuiServer ); |
297 | 297 | ||
298 | (void) new ModelKeyFilter ( ); | 298 | (void) new ModelKeyFilter ( ); |
299 | 299 | ||
300 | initBacklight(); | 300 | initBacklight(); |
301 | 301 | ||
302 | AlarmServer::initialize(); | 302 | AlarmServer::initialize(); |
303 | 303 | ||
304 | Desktop *d = new Desktop(); | 304 | Desktop *d = new Desktop(); |
305 | 305 | ||
306 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); | 306 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); |
307 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); | 307 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); |
308 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); | 308 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); |
309 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); | 309 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); |
310 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); | 310 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); |
311 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); | 311 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); |
312 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); | 312 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); |
313 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); | 313 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); |
314 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); | 314 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); |
315 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); | 315 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); |
316 | 316 | ||
317 | (void)new SysFileMonitor(d); | 317 | (void)new SysFileMonitor(d); |
318 | Network::createServer(d); | 318 | Network::createServer(d); |
319 | 319 | ||
320 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 320 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
321 | if ( !QFile::exists( "/etc/pointercal" ) ) { | 321 | if ( !QFile::exists( "/etc/pointercal" ) ) { |
322 | // Make sure calibration widget starts on top. | 322 | // Make sure calibration widget starts on top. |
323 | Calibrate *cal = new Calibrate; | 323 | Calibrate *cal = new Calibrate; |
324 | cal->exec(); | 324 | cal->exec(); |
325 | delete cal; | 325 | delete cal; |
326 | } | 326 | } |
327 | #endif | 327 | #endif |
328 | 328 | ||
329 | d->show(); | 329 | d->show(); |
330 | 330 | ||
331 | int rv = a.exec(); | 331 | int rv = a.exec(); |
332 | 332 | ||
333 | delete d; | 333 | delete d; |
334 | 334 | ||
335 | return rv; | 335 | return rv; |
336 | } | 336 | } |
337 | 337 | ||
338 | static const char *pidfile_path = "/var/run/opie.pid"; | 338 | static const char *pidfile_path = "/var/run/opie.pid"; |
339 | 339 | ||
340 | void create_pidfile ( ) | 340 | void create_pidfile ( ) |
341 | { | 341 | { |
342 | FILE *f; | 342 | FILE *f; |
343 | 343 | ||
344 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 344 | if (( f = ::fopen ( pidfile_path, "w" ))) { |
345 | ::fprintf ( f, "%d", getpid ( )); | 345 | ::fprintf ( f, "%d", getpid ( )); |
346 | ::fclose ( f ); | 346 | ::fclose ( f ); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | void remove_pidfile ( ) | 350 | void remove_pidfile ( ) |
351 | { | 351 | { |
352 | ::unlink ( pidfile_path ); | 352 | ::unlink ( pidfile_path ); |
353 | } | 353 | } |
354 | 354 | ||
355 | void handle_sigterm ( int sig ) | 355 | void handle_sigterm ( int /* sig */ ) |
356 | { | 356 | { |
357 | if ( qApp ) | 357 | if ( qApp ) |
358 | qApp-> quit ( ); | 358 | qApp-> quit ( ); |
359 | } | 359 | } |
360 | 360 | ||
361 | int main( int argc, char ** argv ) | 361 | int main( int argc, char ** argv ) |
362 | { | 362 | { |
363 | #ifndef SINGLE_APP | 363 | #ifndef SINGLE_APP |
364 | ::signal( SIGCHLD, SIG_IGN ); | 364 | ::signal( SIGCHLD, SIG_IGN ); |
365 | 365 | ||
366 | ::signal ( SIGTERM, handle_sigterm ); | 366 | ::signal ( SIGTERM, handle_sigterm ); |
367 | ::signal ( SIGINT, handle_sigterm ); | ||
367 | 368 | ||
368 | ::setsid ( ); | 369 | ::setsid ( ); |
369 | ::setpgid ( 0, 0 ); | 370 | ::setpgid ( 0, 0 ); |
370 | 371 | ||
371 | ::atexit ( remove_pidfile ); | 372 | ::atexit ( remove_pidfile ); |
372 | create_pidfile ( ); | 373 | create_pidfile ( ); |
373 | #endif | 374 | #endif |
374 | 375 | ||
375 | int retVal = initApplication ( argc, argv ); | 376 | int retVal = initApplication ( argc, argv ); |
376 | 377 | ||
377 | #ifndef SINGLE_APP | 378 | #ifndef SINGLE_APP |
378 | // Kill them. Kill them all. | 379 | // Kill them. Kill them all. |
379 | ::kill ( 0, SIGTERM ); | 380 | ::kill ( 0, SIGTERM ); |
380 | ::sleep( 1 ); | 381 | ::sleep( 1 ); |
381 | ::kill ( 0, SIGKILL ); | 382 | ::kill ( 0, SIGKILL ); |
382 | #endif | 383 | #endif |
383 | 384 | ||
384 | return retVal; | 385 | return retVal; |
385 | } | 386 | } |
386 | 387 | ||