summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-27 21:11:47 (UTC)
committer harlekin <harlekin>2002-08-27 21:11:47 (UTC)
commita6432554a1e64d54c53c1400aa1dfa11ae83f11a (patch) (unidiff)
treebaae8b562962d952904e07a5b2317041a9e37ede
parent86352e32f449ecf00de254674b7dcac72bc34a14 (diff)
downloadopie-a6432554a1e64d54c53c1400aa1dfa11ae83f11a.zip
opie-a6432554a1e64d54c53c1400aa1dfa11ae83f11a.tar.gz
opie-a6432554a1e64d54c53c1400aa1dfa11ae83f11a.tar.bz2
small fix for autostart
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 552c7c3..fb10602 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -187,35 +187,35 @@ enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
187bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 187bool DesktopApplication::qwsEventFilter( QWSEvent *e )
188{ 188{
189 qpedesktop->checkMemory(); 189 qpedesktop->checkMemory();
190 190
191 if ( e->type == QWSEvent::Key ) { 191 if ( e->type == QWSEvent::Key ) {
192 QWSKeyEvent *ke = (QWSKeyEvent *)e; 192 QWSKeyEvent *ke = (QWSKeyEvent *)e;
193 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 193 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
194 return TRUE; 194 return TRUE;
195 bool press = ke->simpleData.is_press; 195 bool press = ke->simpleData.is_press;
196 bool autoRepeat= ke->simpleData.is_auto_repeat; 196 bool autoRepeat= ke->simpleData.is_auto_repeat;
197 197
198 /* 198 /*
199 app that registers key/message to be sent back to the app, when it doesn't have focus, 199 app that registers key/message to be sent back to the app, when it doesn't have focus,
200 when user presses key, unless keyboard has been requested from app. 200 when user presses key, unless keyboard has been requested from app.
201 will not send multiple repeats if user holds key 201 will not send multiple repeats if user holds key
202 i.e. one shot 202 i.e. one shot
203 203
204 */ 204 */
205 if (!keyRegisterList.isEmpty()) { 205 if (!keyRegisterList.isEmpty()) {
206 KeyRegisterList::Iterator it; 206 KeyRegisterList::Iterator it;
207 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 207 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
208 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { 208 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) {
209 if(press) qDebug("press"); else qDebug("release"); 209 if(press) qDebug("press"); else qDebug("release");
210 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 210 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
211 } 211 }
212 } 212 }
213 } 213 }
214 214
215 if ( !keyboardGrabbed() ) { 215 if ( !keyboardGrabbed() ) {
216 if ( ke->simpleData.keycode == Key_F9 ) { 216 if ( ke->simpleData.keycode == Key_F9 ) {
217 if ( press ) emit datebook(); 217 if ( press ) emit datebook();
218 return TRUE; 218 return TRUE;
219 } 219 }
220 if ( ke->simpleData.keycode == Key_F10 ) { 220 if ( ke->simpleData.keycode == Key_F10 ) {
221 if ( !press && cardSendTimer ) { 221 if ( !press && cardSendTimer ) {
@@ -237,33 +237,33 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
237 if ( ke->simpleData.keycode == Key_F12 ) { 237 if ( ke->simpleData.keycode == Key_F12 ) {
238 while( activePopupWidget() ) 238 while( activePopupWidget() )
239 activePopupWidget()->close(); 239 activePopupWidget()->close();
240 if ( press ) emit launch(); 240 if ( press ) emit launch();
241 return TRUE; 241 return TRUE;
242 } 242 }
243 if ( ke->simpleData.keycode == Key_F13 ) { 243 if ( ke->simpleData.keycode == Key_F13 ) {
244 if ( press ) emit email(); 244 if ( press ) emit email();
245 return TRUE; 245 return TRUE;
246 } 246 }
247 } 247 }
248 248
249 if ( ke->simpleData.keycode == Key_F34 ) { 249 if ( ke->simpleData.keycode == Key_F34 ) {
250 if ( press ) emit power(); 250 if ( press ) emit power();
251 return TRUE; 251 return TRUE;
252 } 252 }
253// This was used for the iPAQ PowerButton 253// This was used for the iPAQ PowerButton
254// See main.cpp for new KeyboardFilter 254// See main.cpp for new KeyboardFilter
255// 255//
256// if ( ke->simpleData.keycode == Key_SysReq ) { 256// if ( ke->simpleData.keycode == Key_SysReq ) {
257// if ( press ) emit power(); 257// if ( press ) emit power();
258// return TRUE; 258// return TRUE;
259// } 259// }
260 if ( ke->simpleData.keycode == Key_F35 ) { 260 if ( ke->simpleData.keycode == Key_F35 ) {
261 if ( press ) emit backlight(); 261 if ( press ) emit backlight();
262 return TRUE; 262 return TRUE;
263 } 263 }
264 if ( ke->simpleData.keycode == Key_F32 ) { 264 if ( ke->simpleData.keycode == Key_F32 ) {
265 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 265 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
266 return TRUE; 266 return TRUE;
267 } 267 }
268 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 268 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
269 if ( press ) emit symbol(); 269 if ( press ) emit symbol();
@@ -546,41 +546,40 @@ void Desktop::raiseEmail()
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
556void Desktop::execAutoStart() { 556void 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) ) { 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 } //else { 569 }
570 //}
571} 570}
572 571
573#if defined(QPE_HAVE_TOGGLELIGHT) 572#if defined(QPE_HAVE_TOGGLELIGHT)
574#include <qpe/config.h> 573#include <qpe/config.h>
575 574
576#include <sys/ioctl.h> 575#include <sys/ioctl.h>
577#include <sys/types.h> 576#include <sys/types.h>
578#include <fcntl.h> 577#include <fcntl.h>
579#include <unistd.h> 578#include <unistd.h>
580#include <errno.h> 579#include <errno.h>
581#include <linux/ioctl.h> 580#include <linux/ioctl.h>
582#include <time.h> 581#include <time.h>
583#endif 582#endif
584 583
585static bool blanked=FALSE; 584static bool blanked=FALSE;
586 585
@@ -594,66 +593,66 @@ static void blankScreen()
594 */ 593 */
595 blanked = TRUE; 594 blanked = TRUE;
596} 595}
597 596
598static void darkScreen() 597static void darkScreen()
599{ 598{
600 extern void qpe_setBacklight(int); 599 extern void qpe_setBacklight(int);
601 qpe_setBacklight(0); // force off 600 qpe_setBacklight(0); // force off
602} 601}
603 602
604 603
605void Desktop::togglePower() 604void Desktop::togglePower()
606{ 605{
607 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
608 607
609 static bool excllock = false; 608 static bool excllock = false;
610 609
611 if ( excllock ) 610 if ( excllock )
612 return; 611 return;
613 612
614 excllock = true; 613 excllock = true;
615 614
616 bool wasloggedin = loggedin; 615 bool wasloggedin = loggedin;
617 loggedin=0; 616 loggedin=0;
618 suspendTime = QDateTime::currentDateTime(); 617 suspendTime = QDateTime::currentDateTime();
619 618
620 qpe_setBacklight ( 0 ); // force LCD off 619 qpe_setBacklight ( 0 ); // force LCD off
621 620
622 if ( wasloggedin ) 621 if ( wasloggedin )
623 blankScreen(); 622 blankScreen();
624 623
625 ODevice::inst ( )-> suspend ( ); 624 ODevice::inst ( )-> suspend ( );
626 625
627 QWSServer::screenSaverActivate ( false ); 626 QWSServer::screenSaverActivate ( false );
628 627
629 qpe_setBacklight ( -3 ); // force LCD on 628 qpe_setBacklight ( -3 ); // force LCD on
630 629
631 { 630 {
632 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 631 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
633 } 632 }
634 633
635 if ( wasloggedin ) 634 if ( wasloggedin )
636 login(TRUE); 635 login(TRUE);
637 636
638 execAutoStart(); 637 execAutoStart();
639 //qcopBridge->closeOpenConnections(); 638 //qcopBridge->closeOpenConnections();
640 //qDebug("called togglePower()!!!!!!"); 639 //qDebug("called togglePower()!!!!!!");
641 640
642 qApp-> processEvents ( ); 641 qApp-> processEvents ( );
643 642
644 excllock = false; 643 excllock = false;
645} 644}
646 645
647void Desktop::toggleLight() 646void Desktop::toggleLight()
648{ 647{
649 QCopEnvelope e("QPE/System", "setBacklight(int)"); 648 QCopEnvelope e("QPE/System", "setBacklight(int)");
650 e << -2; // toggle 649 e << -2; // toggle
651} 650}
652 651
653void Desktop::toggleSymbolInput() 652void Desktop::toggleSymbolInput()
654{ 653{
655 tb->toggleSymbolInput(); 654 tb->toggleSymbolInput();
656} 655}
657 656
658void Desktop::toggleNumLockState() 657void Desktop::toggleNumLockState()
659{ 658{
@@ -687,38 +686,38 @@ void DesktopApplication::shutdown()
687} 686}
688 687
689void DesktopApplication::shutdown( ShutdownImpl::Type t ) 688void DesktopApplication::shutdown( ShutdownImpl::Type t )
690{ 689{
691 switch ( t ) { 690 switch ( t ) {
692 case ShutdownImpl::ShutdownSystem: 691 case ShutdownImpl::ShutdownSystem:
693 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 692 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
694 break; 693 break;
695 case ShutdownImpl::RebootSystem: 694 case ShutdownImpl::RebootSystem:
696 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 695 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
697 break; 696 break;
698 case ShutdownImpl::RestartDesktop: 697 case ShutdownImpl::RestartDesktop:
699 restart(); 698 restart();
700 break; 699 break;
701 case ShutdownImpl::TerminateDesktop: 700 case ShutdownImpl::TerminateDesktop:
702 prepareForTermination(FALSE); 701 prepareForTermination(FALSE);
703 702
704 // This is a workaround for a Qt bug 703 // This is a workaround for a Qt bug
705 // clipboard applet has to stop its poll timer, or Qt/E 704 // clipboard applet has to stop its poll timer, or Qt/E
706 // will hang on quit() right before it emits aboutToQuit() 705 // will hang on quit() right before it emits aboutToQuit()
707 emit aboutToQuit ( ); 706 emit aboutToQuit ( );
708 707
709 quit(); 708 quit();
710 break; 709 break;
711 } 710 }
712} 711}
713 712
714void DesktopApplication::restart() 713void DesktopApplication::restart()
715{ 714{
716 prepareForTermination(TRUE); 715 prepareForTermination(TRUE);
717 716
718#ifdef Q_WS_QWS 717#ifdef Q_WS_QWS
719 for ( int fd = 3; fd < 100; fd++ ) 718 for ( int fd = 3; fd < 100; fd++ )
720 close( fd ); 719 close( fd );
721#if defined(QT_DEMO_SINGLE_FLOPPY) 720#if defined(QT_DEMO_SINGLE_FLOPPY)
722 execl( "/sbin/init", "qpe", 0 ); 721 execl( "/sbin/init", "qpe", 0 );
723#elif defined(QT_QWS_CASSIOPEIA) 722#elif defined(QT_QWS_CASSIOPEIA)
724 execl( "/bin/sh", "sh", 0 ); 723 execl( "/bin/sh", "sh", 0 );
@@ -785,26 +784,26 @@ void Desktop::screenClick()
785 if ( touchclick ) 784 if ( touchclick )
786 ODevice::inst ( )-> touchSound ( ); 785 ODevice::inst ( )-> touchSound ( );
787} 786}
788 787
789void Desktop::soundAlarm() 788void Desktop::soundAlarm()
790{ 789{
791 if ( qpedesktop-> alarmsound ) 790 if ( qpedesktop-> alarmsound )
792 ODevice::inst ( )-> alarmSound ( ); 791 ODevice::inst ( )-> alarmSound ( );
793} 792}
794 793
795bool Desktop::eventFilter( QObject *, QEvent *ev ) 794bool Desktop::eventFilter( QObject *, QEvent *ev )
796{ 795{
797 if ( ev-> type ( ) == QEvent::KeyPress ) { 796 if ( ev-> type ( ) == QEvent::KeyPress ) {
798 QKeyEvent *ke = (QKeyEvent *) ev; 797 QKeyEvent *ke = (QKeyEvent *) ev;
799 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key 798 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key
800 QWidget *active = qApp-> activeWindow ( ); 799 QWidget *active = qApp-> activeWindow ( );
801 800
802 if ( active && active-> isPopup ( )) 801 if ( active && active-> isPopup ( ))
803 active->close(); 802 active->close();
804 803
805 raiseMenu ( ); 804 raiseMenu ( );
806 return true; 805 return true;
807 } 806 }
808 } 807 }
809 return false; 808 return false;
810} 809}