-rw-r--r-- | core/launcher/desktop.cpp | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 5aba8dd..8756d37 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -155,97 +155,96 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | |||
155 | } | 155 | } |
156 | 156 | ||
157 | 157 | ||
158 | DesktopApplication::~DesktopApplication() | 158 | DesktopApplication::~DesktopApplication() |
159 | { | 159 | { |
160 | delete ps; | 160 | delete ps; |
161 | delete pa; | 161 | delete pa; |
162 | } | 162 | } |
163 | 163 | ||
164 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | 164 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) |
165 | { | 165 | { |
166 | QDataStream stream( data, IO_ReadOnly ); | 166 | QDataStream stream( data, IO_ReadOnly ); |
167 | if (msg == "keyRegister(int key, QString channel, QString message)") | 167 | if (msg == "keyRegister(int key, QString channel, QString message)") |
168 | { | 168 | { |
169 | int k; | 169 | int k; |
170 | QString c, m; | 170 | QString c, m; |
171 | stream >> k; | 171 | stream >> k; |
172 | stream >> c; | 172 | stream >> c; |
173 | stream >> m; | 173 | stream >> m; |
174 | 174 | ||
175 | qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); | 175 | qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); |
176 | keyRegisterList.append(QCopKeyRegister(k,c,m)); | 176 | keyRegisterList.append(QCopKeyRegister(k,c,m)); |
177 | } | 177 | } |
178 | else if (msg == "suspend()"){ | 178 | else if (msg == "suspend()"){ |
179 | emit power(); | 179 | emit power(); |
180 | } | 180 | } |
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; | 184 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; |
185 | 185 | ||
186 | #ifdef Q_WS_QWS | 186 | #ifdef Q_WS_QWS |
187 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 187 | bool 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 | |||
204 | */ | 203 | */ |
205 | if (!keyRegisterList.isEmpty()) { | 204 | if (!keyRegisterList.isEmpty()) { |
206 | KeyRegisterList::Iterator it; | 205 | KeyRegisterList::Iterator it; |
207 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 206 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
208 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { | 207 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { |
209 | if(press) qDebug("press"); else qDebug("release"); | 208 | if(press) qDebug("press"); else qDebug("release"); |
210 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | 209 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); |
211 | } | 210 | } |
212 | } | 211 | } |
213 | } | 212 | } |
214 | 213 | ||
215 | if ( !keyboardGrabbed() ) { | 214 | if ( !keyboardGrabbed() ) { |
216 | if ( ke->simpleData.keycode == Key_F9 ) { | 215 | if ( ke->simpleData.keycode == Key_F9 ) { |
217 | if ( press ) emit datebook(); | 216 | if ( press ) emit datebook(); |
218 | return TRUE; | 217 | return TRUE; |
219 | } | 218 | } |
220 | if ( ke->simpleData.keycode == Key_F10 ) { | 219 | if ( ke->simpleData.keycode == Key_F10 ) { |
221 | if ( !press && cardSendTimer ) { | 220 | if ( !press && cardSendTimer ) { |
222 | emit contacts(); | 221 | emit contacts(); |
223 | delete cardSendTimer; | 222 | delete cardSendTimer; |
224 | } else if ( press ) { | 223 | } else if ( press ) { |
225 | cardSendTimer = new QTimer(); | 224 | cardSendTimer = new QTimer(); |
226 | cardSendTimer->start( 2000, TRUE ); | 225 | cardSendTimer->start( 2000, TRUE ); |
227 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 226 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
228 | } | 227 | } |
229 | return TRUE; | 228 | return TRUE; |
230 | } | 229 | } |
231 | /* menu key now opens application menu/toolbar | 230 | /* menu key now opens application menu/toolbar |
232 | if ( ke->simpleData.keycode == Key_F11 ) { | 231 | if ( ke->simpleData.keycode == Key_F11 ) { |
233 | if ( press ) emit menu(); | 232 | if ( press ) emit menu(); |
234 | return TRUE; | 233 | return TRUE; |
235 | } | 234 | } |
236 | */ | 235 | */ |
237 | if ( ke->simpleData.keycode == Key_F12 ) { | 236 | if ( ke->simpleData.keycode == Key_F12 ) { |
238 | while( activePopupWidget() ) | 237 | while( activePopupWidget() ) |
239 | activePopupWidget()->close(); | 238 | activePopupWidget()->close(); |
240 | if ( press ) emit launch(); | 239 | if ( press ) emit launch(); |
241 | return TRUE; | 240 | return TRUE; |
242 | } | 241 | } |
243 | if ( ke->simpleData.keycode == Key_F13 ) { | 242 | if ( ke->simpleData.keycode == Key_F13 ) { |
244 | if ( press ) emit email(); | 243 | if ( press ) emit email(); |
245 | return TRUE; | 244 | return TRUE; |
246 | } | 245 | } |
247 | } | 246 | } |
248 | 247 | ||
249 | if ( ke->simpleData.keycode == Key_F34 ) { | 248 | if ( ke->simpleData.keycode == Key_F34 ) { |
250 | if ( press ) emit power(); | 249 | if ( press ) emit power(); |
251 | return TRUE; | 250 | return TRUE; |
@@ -486,119 +485,120 @@ void Desktop::executeOrModify(const QString& appLnkFile) | |||
486 | if ( lnk.isValid() ) { | 485 | if ( lnk.isValid() ) { |
487 | QCString app = lnk.exec().utf8(); | 486 | QCString app = lnk.exec().utf8(); |
488 | Global::terminateBuiltin("calibrate"); | 487 | Global::terminateBuiltin("calibrate"); |
489 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { | 488 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { |
490 | MRUList::addTask(&lnk); | 489 | MRUList::addTask(&lnk); |
491 | if ( hasVisibleWindow(app) ) | 490 | if ( hasVisibleWindow(app) ) |
492 | QCopChannel::send("QPE/Application/" + app, "nextView()"); | 491 | QCopChannel::send("QPE/Application/" + app, "nextView()"); |
493 | else | 492 | else |
494 | QCopChannel::send("QPE/Application/" + app, "raise()"); | 493 | QCopChannel::send("QPE/Application/" + app, "raise()"); |
495 | } else { | 494 | } else { |
496 | lnk.execute(); | 495 | lnk.execute(); |
497 | } | 496 | } |
498 | } | 497 | } |
499 | } | 498 | } |
500 | 499 | ||
501 | void Desktop::raiseDatebook() | 500 | void Desktop::raiseDatebook() |
502 | { | 501 | { |
503 | Config cfg( "qpe" ); //F9 'Activity' | 502 | Config cfg( "qpe" ); //F9 'Activity' |
504 | cfg.setGroup( "AppsKey" ); | 503 | cfg.setGroup( "AppsKey" ); |
505 | QString tempItem; | 504 | QString tempItem; |
506 | tempItem = cfg.readEntry( "LeftEnd" , "Calender" ); | 505 | tempItem = cfg.readEntry( "LeftEnd" , "Calender" ); |
507 | if ( tempItem == "Calender" || tempItem.isEmpty() ) { | 506 | if ( tempItem == "Calender" || tempItem.isEmpty() ) { |
508 | tempItem = "datebook"; | 507 | tempItem = "datebook"; |
509 | } | 508 | } |
510 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 509 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
511 | e << tempItem; | 510 | e << tempItem; |
512 | } | 511 | } |
513 | 512 | ||
514 | void Desktop::raiseContacts() | 513 | void Desktop::raiseContacts() |
515 | { | 514 | { |
516 | Config cfg( "qpe" ); //F10, 'Contacts' | 515 | Config cfg( "qpe" ); //F10, 'Contacts' |
517 | cfg.setGroup( "AppsKey" ); | 516 | cfg.setGroup( "AppsKey" ); |
518 | QString tempItem; | 517 | QString tempItem; |
519 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); | 518 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); |
520 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { | 519 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { |
521 | tempItem = "addressbook"; | 520 | tempItem = "addressbook"; |
522 | } | 521 | } |
523 | QCopEnvelope e("QPE/System","execute(QString)"); | 522 | QCopEnvelope e("QPE/System","execute(QString)"); |
524 | e << tempItem; | 523 | e << tempItem; |
525 | } | 524 | } |
526 | 525 | ||
527 | void Desktop::raiseMenu() | 526 | void Desktop::raiseMenu() |
528 | { | 527 | { |
529 | Config cfg( "qpe" ); //F11, 'Menu | 528 | Config cfg( "qpe" ); //F11, 'Menu |
530 | cfg.setGroup( "AppsKey" ); | 529 | cfg.setGroup( "AppsKey" ); |
531 | QString tempItem; | 530 | QString tempItem; |
532 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); | 531 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); |
533 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { | 532 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { |
534 | Global::terminateBuiltin("calibrate"); | 533 | Global::terminateBuiltin( "calibrate" ); |
535 | tb->startMenu()->launch(); | 534 | tb->startMenu()->launch(); |
536 | } else { | 535 | } else { |
537 | QCopEnvelope e("QPE/System","execute(QString)"); | 536 | QCopEnvelope e("QPE/System","execute(QString)"); |
538 | e << tempItem; | 537 | e << tempItem; |
539 | } | 538 | } |
540 | } | 539 | } |
541 | 540 | ||
542 | void Desktop::raiseEmail() | 541 | void Desktop::raiseEmail() |
543 | { | 542 | { |
544 | Config cfg( "qpe" ); //F13, 'Mail' | 543 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 |
545 | cfg.setGroup( "AppsKey" ); | 544 | cfg.setGroup( "AppsKey" ); |
546 | QString tempItem; | 545 | QString tempItem; |
547 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); | 546 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); |
548 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { | 547 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { |
549 | tempItem = "mail"; | 548 | tempItem = "mail"; |
550 | } | 549 | } |
551 | QCopEnvelope e("QPE/System","execute(QString)"); | 550 | QCopEnvelope e("QPE/System","execute(QString)"); |
552 | e << tempItem; | 551 | e << tempItem; |
553 | } | 552 | } |
554 | 553 | ||
555 | // autoStarts apps on resume and start | 554 | // autoStarts apps on resume and start |
556 | void Desktop::execAutoStart() { | 555 | void Desktop::execAutoStart() |
556 | { | ||
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() |
@@ -719,88 +719,94 @@ void DesktopApplication::restart() | |||
719 | #elif defined(QT_QWS_CASSIOPEIA) | 719 | #elif defined(QT_QWS_CASSIOPEIA) |
720 | execl( "/bin/sh", "sh", 0 ); | 720 | execl( "/bin/sh", "sh", 0 ); |
721 | #else | 721 | #else |
722 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); | 722 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); |
723 | #endif | 723 | #endif |
724 | exit(1); | 724 | exit(1); |
725 | #endif | 725 | #endif |
726 | } | 726 | } |
727 | 727 | ||
728 | void Desktop::startTransferServer() | 728 | void Desktop::startTransferServer() |
729 | { | 729 | { |
730 | // start qcop bridge server | 730 | // start qcop bridge server |
731 | qcopBridge = new QCopBridge( 4243 ); | 731 | qcopBridge = new QCopBridge( 4243 ); |
732 | if ( !qcopBridge->ok() ) { | 732 | if ( !qcopBridge->ok() ) { |
733 | delete qcopBridge; | 733 | delete qcopBridge; |
734 | qcopBridge = 0; | 734 | qcopBridge = 0; |
735 | } | 735 | } |
736 | // start transfer server | 736 | // start transfer server |
737 | transferServer = new TransferServer( 4242 ); | 737 | transferServer = new TransferServer( 4242 ); |
738 | if ( !transferServer->ok() ) { | 738 | if ( !transferServer->ok() ) { |
739 | delete transferServer; | 739 | delete transferServer; |
740 | transferServer = 0; | 740 | transferServer = 0; |
741 | } | 741 | } |
742 | if ( !transferServer || !qcopBridge ) | 742 | if ( !transferServer || !qcopBridge ) |
743 | startTimer( 2000 ); | 743 | startTimer( 2000 ); |
744 | } | 744 | } |
745 | 745 | ||
746 | void Desktop::timerEvent( QTimerEvent *e ) | 746 | void Desktop::timerEvent( QTimerEvent *e ) |
747 | { | 747 | { |
748 | killTimer( e->timerId() ); | 748 | killTimer( e->timerId() ); |
749 | startTransferServer(); | 749 | startTransferServer(); |
750 | } | 750 | } |
751 | 751 | ||
752 | void Desktop::terminateServers() | 752 | void Desktop::terminateServers() |
753 | { | 753 | { |
754 | delete transferServer; | 754 | delete transferServer; |
755 | delete qcopBridge; | 755 | delete qcopBridge; |
756 | transferServer = 0; | 756 | transferServer = 0; |
757 | qcopBridge = 0; | 757 | qcopBridge = 0; |
758 | } | 758 | } |
759 | 759 | ||
760 | void Desktop::rereadVolumes() | 760 | void Desktop::rereadVolumes() |
761 | { | 761 | { |
762 | Config cfg("qpe"); | 762 | Config cfg("qpe"); |
763 | cfg.setGroup("Volume"); | 763 | cfg.setGroup("Volume"); |
764 | touchclick = cfg.readBoolEntry("TouchSound"); | 764 | touchclick = cfg.readBoolEntry("TouchSound"); |
765 | keyclick = cfg.readBoolEntry("KeySound"); | 765 | keyclick = cfg.readBoolEntry("KeySound"); |
766 | alarmsound = cfg.readBoolEntry("AlarmSound"); | 766 | alarmsound = cfg.readBoolEntry("AlarmSound"); |
767 | // Config cfg("Sound"); | ||
768 | // cfg.setGroup("System"); | ||
769 | // touchclick = cfg.readBoolEntry("Touch"); | ||
770 | // keyclick = cfg.readBoolEntry("Key"); | ||
771 | } | 767 | } |
772 | 768 | ||
773 | void Desktop::keyClick() | 769 | void Desktop::keyClick() |
774 | { | 770 | { |
775 | if ( keyclick ) | 771 | if ( keyclick ) |
776 | ODevice::inst ( )-> keySound ( ); | 772 | ODevice::inst ( )-> keySound ( ); |
777 | } | 773 | } |
778 | 774 | ||
779 | void Desktop::screenClick() | 775 | void Desktop::screenClick() |
780 | { | 776 | { |
781 | if ( touchclick ) | 777 | if ( touchclick ) |
782 | ODevice::inst ( )-> touchSound ( ); | 778 | ODevice::inst ( )-> touchSound ( ); |
783 | } | 779 | } |
784 | 780 | ||
785 | void Desktop::soundAlarm() | 781 | void Desktop::soundAlarm() |
786 | { | 782 | { |
787 | if ( qpedesktop-> alarmsound ) | 783 | if ( qpedesktop-> alarmsound ) |
788 | ODevice::inst ( )-> alarmSound ( ); | 784 | ODevice::inst ( )-> alarmSound ( ); |
789 | } | 785 | } |
790 | 786 | ||
791 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | 787 | bool Desktop::eventFilter( QObject *, QEvent *ev ) |
792 | { | 788 | { |
793 | if ( ev-> type ( ) == QEvent::KeyPress ) { | 789 | if ( ev-> type ( ) == QEvent::KeyPress ) { |
794 | QKeyEvent *ke = (QKeyEvent *) ev; | 790 | QKeyEvent *ke = (QKeyEvent *) ev; |
795 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key | 791 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key |
796 | QWidget *active = qApp-> activeWindow ( ); | 792 | QWidget *active = qApp-> activeWindow ( ); |
797 | 793 | ||
798 | if ( active && active-> isPopup ( )) | 794 | if ( active && active-> isPopup ( )) |
799 | active->close(); | 795 | active->close(); |
800 | 796 | ||
801 | raiseMenu ( ); | 797 | /* |
802 | return true; | 798 | * On iPAQ 38xx that key is not the "menu key" but the mail key |
799 | * To not confuse the users, make it launch the mail app on 38xx | ||
800 | */ | ||
801 | if (ODevice::inst()->model() == OMODEL_iPAQ_H38xx ) { | ||
802 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | ||
803 | e << QString( "mail" ); | ||
804 | return true; | ||
805 | } else { | ||
806 | raiseMenu ( ); | ||
807 | return true; | ||
808 | } | ||
809 | } | ||
803 | } | 810 | } |
804 | } | 811 | return false; |
805 | return false; | ||
806 | } | 812 | } |