summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-03-19 01:25:52 (UTC)
committer harlekin <harlekin>2002-03-19 01:25:52 (UTC)
commit7c64492d86e8ddc90e80c380d53e2744869397cf (patch) (unidiff)
tree430e49fa104ffdacdb56e817cb48ccf6002550f9
parent3698b59946936e76687850fde92c45989320e7b0 (diff)
downloadopie-7c64492d86e8ddc90e80c380d53e2744869397cf.zip
opie-7c64492d86e8ddc90e80c380d53e2744869397cf.tar.gz
opie-7c64492d86e8ddc90e80c380d53e2744869397cf.tar.bz2
again
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 547daa9..64043e7 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -368,367 +368,367 @@ Desktop::Desktop() :
368 (void) new IrServer( this ); 368 (void) new IrServer( this );
369 rereadVolumes(); 369 rereadVolumes();
370 370
371 packageSlave = new PackageSlave( this ); 371 packageSlave = new PackageSlave( this );
372 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 372 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
373 373
374 qApp->installEventFilter( this ); 374 qApp->installEventFilter( this );
375} 375}
376 376
377void Desktop::show() 377void Desktop::show()
378{ 378{
379 login(TRUE); 379 login(TRUE);
380 QWidget::show(); 380 QWidget::show();
381} 381}
382 382
383Desktop::~Desktop() 383Desktop::~Desktop()
384{ 384{
385 delete launcher; 385 delete launcher;
386 delete tb; 386 delete tb;
387 delete qcopBridge; 387 delete qcopBridge;
388 delete transferServer; 388 delete transferServer;
389} 389}
390 390
391bool Desktop::recoverMemory() 391bool Desktop::recoverMemory()
392{ 392{
393 return tb->recoverMemory(); 393 return tb->recoverMemory();
394} 394}
395 395
396void Desktop::checkMemory() 396void Desktop::checkMemory()
397{ 397{
398#if defined(QPE_HAVE_MEMALERTER) 398#if defined(QPE_HAVE_MEMALERTER)
399 static bool ignoreNormal=FALSE; 399 static bool ignoreNormal=FALSE;
400 static bool existingMessage=FALSE; 400 static bool existingMessage=FALSE;
401 401
402 if(existingMessage) 402 if(existingMessage)
403 return; // don't show a second message while still on first 403 return; // don't show a second message while still on first
404 404
405 existingMessage = TRUE; 405 existingMessage = TRUE;
406 switch ( memstate ) { 406 switch ( memstate ) {
407 case Unknown: 407 case Unknown:
408 break; 408 break;
409 case Low: 409 case Low:
410 memstate = Unknown; 410 memstate = Unknown;
411 if ( recoverMemory() ) 411 if ( recoverMemory() )
412 ignoreNormal = TRUE; 412 ignoreNormal = TRUE;
413 else 413 else
414 QMessageBox::warning( 0 , "Memory Status", 414 QMessageBox::warning( 0 , "Memory Status",
415 "The memory smacks of shortage. \n" 415 "The memory smacks of shortage. \n"
416 "Please save data. " ); 416 "Please save data. " );
417 break; 417 break;
418 case Normal: 418 case Normal:
419 memstate = Unknown; 419 memstate = Unknown;
420 if ( ignoreNormal ) 420 if ( ignoreNormal )
421 ignoreNormal = FALSE; 421 ignoreNormal = FALSE;
422 else 422 else
423 QMessageBox::information ( 0 , "Memory Status", 423 QMessageBox::information ( 0 , "Memory Status",
424 "There is enough memory again." ); 424 "There is enough memory again." );
425 break; 425 break;
426 case VeryLow: 426 case VeryLow:
427 memstate = Unknown; 427 memstate = Unknown;
428 QMessageBox::critical( 0 , "Memory Status", 428 QMessageBox::critical( 0 , "Memory Status",
429 "The memory is very low. \n" 429 "The memory is very low. \n"
430 "Please end this application \n" 430 "Please end this application \n"
431 "immediately." ); 431 "immediately." );
432 recoverMemory(); 432 recoverMemory();
433 } 433 }
434 existingMessage = FALSE; 434 existingMessage = FALSE;
435#endif 435#endif
436} 436}
437 437
438static bool isVisibleWindow(int wid) 438static bool isVisibleWindow(int wid)
439{ 439{
440 const QList<QWSWindow> &list = qwsServer->clientWindows(); 440 const QList<QWSWindow> &list = qwsServer->clientWindows();
441 QWSWindow* w; 441 QWSWindow* w;
442 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 442 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
443 if ( w->winId() == wid ) 443 if ( w->winId() == wid )
444 return !w->isFullyObscured(); 444 return !w->isFullyObscured();
445 } 445 }
446 return FALSE; 446 return FALSE;
447} 447}
448 448
449static bool hasVisibleWindow(const QString& clientname) 449static bool hasVisibleWindow(const QString& clientname)
450{ 450{
451 const QList<QWSWindow> &list = qwsServer->clientWindows(); 451 const QList<QWSWindow> &list = qwsServer->clientWindows();
452 QWSWindow* w; 452 QWSWindow* w;
453 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 453 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
454 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 454 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
455 return TRUE; 455 return TRUE;
456 } 456 }
457 return FALSE; 457 return FALSE;
458} 458}
459 459
460void Desktop::raiseLauncher() 460void Desktop::raiseLauncher()
461{ 461{
462 if ( isVisibleWindow(launcher->winId()) ) 462 if ( isVisibleWindow(launcher->winId()) )
463 launcher->nextView(); 463 launcher->nextView();
464 else 464 else
465 launcher->raise(); 465 launcher->raise();
466} 466}
467 467
468void Desktop::executeOrModify(const QString& appLnkFile) 468void Desktop::executeOrModify(const QString& appLnkFile)
469{ 469{
470 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 470 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
471 if ( lnk.isValid() ) { 471 if ( lnk.isValid() ) {
472 QCString app = lnk.exec().utf8(); 472 QCString app = lnk.exec().utf8();
473 Global::terminateBuiltin("calibrate"); 473 Global::terminateBuiltin("calibrate");
474 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 474 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
475 MRUList::addTask(&lnk); 475 MRUList::addTask(&lnk);
476 if ( hasVisibleWindow(app) ) 476 if ( hasVisibleWindow(app) )
477 QCopChannel::send("QPE/Application/" + app, "nextView()"); 477 QCopChannel::send("QPE/Application/" + app, "nextView()");
478 else 478 else
479 QCopChannel::send("QPE/Application/" + app, "raise()"); 479 QCopChannel::send("QPE/Application/" + app, "raise()");
480 } else { 480 } else {
481 lnk.execute(); 481 lnk.execute();
482 } 482 }
483 } 483 }
484} 484}
485 485
486void Desktop::raiseDatebook() 486void Desktop::raiseDatebook()
487{ 487{
488 executeOrModify("Applications/datebook.desktop"); 488 executeOrModify("Applications/datebook.desktop");
489} 489}
490 490
491void Desktop::raiseContacts() 491void Desktop::raiseContacts()
492{ 492{
493 executeOrModify("Applications/addressbook.desktop"); 493 executeOrModify("Applications/addressbook.desktop");
494} 494}
495 495
496void Desktop::raiseMenu() 496void Desktop::raiseMenu()
497{ 497{
498 Global::terminateBuiltin("calibrate"); 498 Global::terminateBuiltin("calibrate");
499 tb->startMenu()->launch(); 499 tb->startMenu()->launch();
500} 500}
501 501
502void Desktop::raiseEmail() 502void Desktop::raiseEmail()
503{ 503{
504 executeOrModify("Applications/qtmail.desktop"); 504 executeOrModify("Applications/qtmail.desktop");
505} 505}
506 506
507// autoStarts apps on resume and start 507// autoStarts apps on resume and start
508void Desktop::execAutoStart() 508void Desktop::execAutoStart()
509{ 509{
510 QString appName; 510 QString appName;
511 Config cfg( "autostart" ); 511 Config cfg( "autostart" );
512 cfg.setGroup( "AutoStart" ); 512 cfg.setGroup( "AutoStart" );
513 appName = cfg.readEntry("Apps", ""); 513 appName = cfg.readEntry("Apps", "");
514 QCopEnvelope e("QPE/System", "execute(QString)"); 514 QCopEnvelope e("QPE/System", "execute(QString)");
515 e << QString(appName); 515 e << QString(appName);
516} 516}
517 517
518#if defined(QPE_HAVE_TOGGLELIGHT) 518#if defined(QPE_HAVE_TOGGLELIGHT)
519#include <qpe/config.h> 519#include <qpe/config.h>
520 520
521#include <sys/ioctl.h> 521#include <sys/ioctl.h>
522#include <sys/types.h> 522#include <sys/types.h>
523#include <fcntl.h> 523#include <fcntl.h>
524#include <unistd.h> 524#include <unistd.h>
525#include <errno.h> 525#include <errno.h>
526#include <linux/ioctl.h> 526#include <linux/ioctl.h>
527#include <time.h> 527#include <time.h>
528#endif 528#endif
529 529
530static bool blanked=FALSE; 530static bool blanked=FALSE;
531 531
532static void blankScreen() 532static void blankScreen()
533{ 533{
534 if ( !qt_screen ) return; 534 if ( !qt_screen ) return;
535 /* Should use a big black window instead. 535 /* Should use a big black window instead.
536 QGfx* g = qt_screen->screenGfx(); 536 QGfx* g = qt_screen->screenGfx();
537 g->fillRect(0,0,qt_screen->width(),qt_screen->height()); 537 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
538 delete g; 538 delete g;
539 */ 539 */
540 blanked = TRUE; 540 blanked = TRUE;
541} 541}
542 542
543static void darkScreen() 543static void darkScreen()
544{ 544{
545 extern void qpe_setBacklight(int); 545 extern void qpe_setBacklight(int);
546 qpe_setBacklight(0); // force off 546 qpe_setBacklight(0); // force off
547} 547}
548 548
549 549
550void Desktop::togglePower() 550void Desktop::togglePower()
551{ 551{
552 bool wasloggedin = loggedin; 552 bool wasloggedin = loggedin;
553 loggedin=0; 553 loggedin=0;
554 darkScreen(); 554 darkScreen();
555 if ( wasloggedin ) 555 if ( wasloggedin )
556 blankScreen(); 556 blankScreen();
557 557
558 system("apm --suspend"); 558 system("apm --suspend");
559 559
560 sleep(2); 560
561 561
562 QWSServer::screenSaverActivate( FALSE ); 562 QWSServer::screenSaverActivate( FALSE );
563 { 563 {
564 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 564 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
565 QCopEnvelope e("QPE/System", "setBacklight(int)"); 565 QCopEnvelope e("QPE/System", "setBacklight(int)");
566 e << -3; // Force on 566 e << -3; // Force on
567 } 567 }
568 if ( wasloggedin ) { 568 if ( wasloggedin ) {
569 login(TRUE); 569 login(TRUE);
570 } 570 }
571 571 sleep(1);
572 execAutoStart(); 572 execAutoStart();
573 //qcopBridge->closeOpenConnections(); 573 //qcopBridge->closeOpenConnections();
574 //qDebug("called togglePower()!!!!!!"); 574 //qDebug("called togglePower()!!!!!!");
575} 575}
576 576
577void Desktop::toggleLight() 577void Desktop::toggleLight()
578{ 578{
579 QCopEnvelope e("QPE/System", "setBacklight(int)"); 579 QCopEnvelope e("QPE/System", "setBacklight(int)");
580 e << -2; // toggle 580 e << -2; // toggle
581} 581}
582 582
583void Desktop::toggleSymbolInput() 583void Desktop::toggleSymbolInput()
584{ 584{
585 tb->toggleSymbolInput(); 585 tb->toggleSymbolInput();
586} 586}
587 587
588void Desktop::toggleNumLockState() 588void Desktop::toggleNumLockState()
589{ 589{
590 tb->toggleNumLockState(); 590 tb->toggleNumLockState();
591} 591}
592 592
593void Desktop::toggleCapsLockState() 593void Desktop::toggleCapsLockState()
594{ 594{
595 tb->toggleCapsLockState(); 595 tb->toggleCapsLockState();
596} 596}
597 597
598void Desktop::styleChange( QStyle &s ) 598void Desktop::styleChange( QStyle &s )
599{ 599{
600 QWidget::styleChange( s ); 600 QWidget::styleChange( s );
601 int displayw = qApp->desktop()->width(); 601 int displayw = qApp->desktop()->width();
602 int displayh = qApp->desktop()->height(); 602 int displayh = qApp->desktop()->height();
603 603
604 QSize sz = tb->sizeHint(); 604 QSize sz = tb->sizeHint();
605 605
606 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 606 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
607} 607}
608 608
609void DesktopApplication::shutdown() 609void DesktopApplication::shutdown()
610{ 610{
611 if ( type() != GuiServer ) 611 if ( type() != GuiServer )
612 return; 612 return;
613 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 613 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
614 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 614 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
615 this, SLOT(shutdown(ShutdownImpl::Type)) ); 615 this, SLOT(shutdown(ShutdownImpl::Type)) );
616 sd->showMaximized(); 616 sd->showMaximized();
617} 617}
618 618
619void DesktopApplication::shutdown( ShutdownImpl::Type t ) 619void DesktopApplication::shutdown( ShutdownImpl::Type t )
620{ 620{
621 switch ( t ) { 621 switch ( t ) {
622 case ShutdownImpl::ShutdownSystem: 622 case ShutdownImpl::ShutdownSystem:
623 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 623 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
624 break; 624 break;
625 case ShutdownImpl::RebootSystem: 625 case ShutdownImpl::RebootSystem:
626 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 626 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
627 break; 627 break;
628 case ShutdownImpl::RestartDesktop: 628 case ShutdownImpl::RestartDesktop:
629 restart(); 629 restart();
630 break; 630 break;
631 case ShutdownImpl::TerminateDesktop: 631 case ShutdownImpl::TerminateDesktop:
632 prepareForTermination(FALSE); 632 prepareForTermination(FALSE);
633 quit(); 633 quit();
634 break; 634 break;
635 } 635 }
636} 636}
637 637
638void DesktopApplication::restart() 638void DesktopApplication::restart()
639{ 639{
640 prepareForTermination(TRUE); 640 prepareForTermination(TRUE);
641 641
642#ifdef Q_WS_QWS 642#ifdef Q_WS_QWS
643 for ( int fd = 3; fd < 100; fd++ ) 643 for ( int fd = 3; fd < 100; fd++ )
644 close( fd ); 644 close( fd );
645#if defined(QT_DEMO_SINGLE_FLOPPY) 645#if defined(QT_DEMO_SINGLE_FLOPPY)
646 execl( "/sbin/init", "qpe", 0 ); 646 execl( "/sbin/init", "qpe", 0 );
647#elif defined(QT_QWS_CASSIOPEIA) 647#elif defined(QT_QWS_CASSIOPEIA)
648 execl( "/bin/sh", "sh", 0 ); 648 execl( "/bin/sh", "sh", 0 );
649#else 649#else
650 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 650 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
651#endif 651#endif
652 exit(1); 652 exit(1);
653#endif 653#endif
654} 654}
655 655
656void Desktop::startTransferServer() 656void Desktop::startTransferServer()
657{ 657{
658 // start qcop bridge server 658 // start qcop bridge server
659 qcopBridge = new QCopBridge( 4243 ); 659 qcopBridge = new QCopBridge( 4243 );
660 if ( !qcopBridge->ok() ) { 660 if ( !qcopBridge->ok() ) {
661 delete qcopBridge; 661 delete qcopBridge;
662 qcopBridge = 0; 662 qcopBridge = 0;
663 } 663 }
664 // start transfer server 664 // start transfer server
665 transferServer = new TransferServer( 4242 ); 665 transferServer = new TransferServer( 4242 );
666 if ( !transferServer->ok() ) { 666 if ( !transferServer->ok() ) {
667 delete transferServer; 667 delete transferServer;
668 transferServer = 0; 668 transferServer = 0;
669 } 669 }
670 if ( !transferServer || !qcopBridge ) 670 if ( !transferServer || !qcopBridge )
671 startTimer( 2000 ); 671 startTimer( 2000 );
672} 672}
673 673
674void Desktop::timerEvent( QTimerEvent *e ) 674void Desktop::timerEvent( QTimerEvent *e )
675{ 675{
676 killTimer( e->timerId() ); 676 killTimer( e->timerId() );
677 startTransferServer(); 677 startTransferServer();
678} 678}
679 679
680void Desktop::terminateServers() 680void Desktop::terminateServers()
681{ 681{
682 delete transferServer; 682 delete transferServer;
683 delete qcopBridge; 683 delete qcopBridge;
684 transferServer = 0; 684 transferServer = 0;
685 qcopBridge = 0; 685 qcopBridge = 0;
686} 686}
687 687
688void Desktop::rereadVolumes() 688void Desktop::rereadVolumes()
689{ 689{
690 Config cfg("Sound"); 690 Config cfg("Sound");
691 cfg.setGroup("System"); 691 cfg.setGroup("System");
692 touchclick = cfg.readBoolEntry("Touch"); 692 touchclick = cfg.readBoolEntry("Touch");
693 keyclick = cfg.readBoolEntry("Key"); 693 keyclick = cfg.readBoolEntry("Key");
694} 694}
695 695
696void Desktop::keyClick() 696void Desktop::keyClick()
697{ 697{
698#ifdef CUSTOM_SOUND_KEYCLICK 698#ifdef CUSTOM_SOUND_KEYCLICK
699 if ( keyclick ) 699 if ( keyclick )
700 CUSTOM_SOUND_KEYCLICK; 700 CUSTOM_SOUND_KEYCLICK;
701#endif 701#endif
702} 702}
703 703
704void Desktop::screenClick() 704void Desktop::screenClick()
705{ 705{
706#ifdef CUSTOM_SOUND_TOUCH 706#ifdef CUSTOM_SOUND_TOUCH
707 if ( touchclick ) 707 if ( touchclick )
708 CUSTOM_SOUND_TOUCH; 708 CUSTOM_SOUND_TOUCH;
709#endif 709#endif
710} 710}
711 711
712void Desktop::soundAlarm() 712void Desktop::soundAlarm()
713{ 713{
714#ifdef CUSTOM_SOUND_ALARM 714#ifdef CUSTOM_SOUND_ALARM
715 CUSTOM_SOUND_ALARM; 715 CUSTOM_SOUND_ALARM;
716#endif 716#endif
717} 717}
718 718
719bool Desktop::eventFilter( QObject *w, QEvent *ev ) 719bool Desktop::eventFilter( QObject *w, QEvent *ev )
720{ 720{
721 if ( ev->type() == QEvent::KeyPress ) { 721 if ( ev->type() == QEvent::KeyPress ) {
722 QKeyEvent *ke = (QKeyEvent *)ev; 722 QKeyEvent *ke = (QKeyEvent *)ev;
723 if ( ke->key() == Qt::Key_F11 ) { // menu key 723 if ( ke->key() == Qt::Key_F11 ) { // menu key
724 QWidget *active = qApp->activeWindow(); 724 QWidget *active = qApp->activeWindow();
725 if ( active && active->isPopup() ) { 725 if ( active && active->isPopup() ) {
726 active->close(); 726 active->close();
727 } 727 }
728 raiseMenu(); 728 raiseMenu();
729 return TRUE; 729 return TRUE;
730 } 730 }
731 } 731 }
732 return FALSE; 732 return FALSE;
733} 733}
734 734