-rw-r--r-- | core/launcher/desktop.cpp | 2 | ||||
-rw-r--r-- | core/launcher/main.cpp | 132 |
2 files changed, 7 insertions, 127 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index bf19280..dee5535 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -528,192 +528,194 @@ void Desktop::raiseMenu() | |||
528 | Config cfg( "qpe" ); //F11, 'Menu | 528 | Config cfg( "qpe" ); //F11, 'Menu |
529 | cfg.setGroup( "AppsKey" ); | 529 | cfg.setGroup( "AppsKey" ); |
530 | QString tempItem; | 530 | QString tempItem; |
531 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); | 531 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); |
532 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { | 532 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { |
533 | Global::terminateBuiltin( "calibrate" ); | 533 | Global::terminateBuiltin( "calibrate" ); |
534 | tb->startMenu()->launch(); | 534 | tb->startMenu()->launch(); |
535 | } else { | 535 | } else { |
536 | QCopEnvelope e("QPE/System","execute(QString)"); | 536 | QCopEnvelope e("QPE/System","execute(QString)"); |
537 | e << tempItem; | 537 | e << tempItem; |
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | void Desktop::raiseEmail() | 541 | void Desktop::raiseEmail() |
542 | { | 542 | { |
543 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 | 543 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 |
544 | cfg.setGroup( "AppsKey" ); | 544 | cfg.setGroup( "AppsKey" ); |
545 | QString tempItem; | 545 | QString tempItem; |
546 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); | 546 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); |
547 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { | 547 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { |
548 | tempItem = "mail"; | 548 | tempItem = "mail"; |
549 | } | 549 | } |
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 | // autoStarts apps on resume and start | 554 | // autoStarts apps on resume and start |
555 | void Desktop::execAutoStart() | 555 | void Desktop::execAutoStart() |
556 | { | 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() |
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 (sandman: why ????) | 619 | // qpe_setBacklight ( 0 ); // force LCD off (sandman: why ????) |
620 | 620 | ||
621 | if ( wasloggedin ) | 621 | if ( wasloggedin ) |
622 | blankScreen(); | 622 | blankScreen(); |
623 | 623 | ||
624 | qDebug ( "OPIE suspending\n" ); | ||
625 | |||
624 | ODevice::inst ( )-> suspend ( ); | 626 | ODevice::inst ( )-> suspend ( ); |
625 | 627 | ||
626 | QWSServer::screenSaverActivate ( false ); | 628 | QWSServer::screenSaverActivate ( false ); |
627 | 629 | ||
628 | qpe_setBacklight ( -3 ); // force LCD on | 630 | qpe_setBacklight ( -3 ); // force LCD on |
629 | 631 | ||
630 | { | 632 | { |
631 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 633 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
632 | } | 634 | } |
633 | 635 | ||
634 | if ( wasloggedin ) | 636 | if ( wasloggedin ) |
635 | login(TRUE); | 637 | login(TRUE); |
636 | 638 | ||
637 | execAutoStart(); | 639 | execAutoStart(); |
638 | //qcopBridge->closeOpenConnections(); | 640 | //qcopBridge->closeOpenConnections(); |
639 | 641 | ||
640 | excllock = false; | 642 | excllock = false; |
641 | } | 643 | } |
642 | 644 | ||
643 | void Desktop::toggleLight() | 645 | void Desktop::toggleLight() |
644 | { | 646 | { |
645 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 647 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
646 | e << -2; // toggle | 648 | e << -2; // toggle |
647 | } | 649 | } |
648 | 650 | ||
649 | void Desktop::toggleSymbolInput() | 651 | void Desktop::toggleSymbolInput() |
650 | { | 652 | { |
651 | tb->toggleSymbolInput(); | 653 | tb->toggleSymbolInput(); |
652 | } | 654 | } |
653 | 655 | ||
654 | void Desktop::toggleNumLockState() | 656 | void Desktop::toggleNumLockState() |
655 | { | 657 | { |
656 | tb->toggleNumLockState(); | 658 | tb->toggleNumLockState(); |
657 | } | 659 | } |
658 | 660 | ||
659 | void Desktop::toggleCapsLockState() | 661 | void Desktop::toggleCapsLockState() |
660 | { | 662 | { |
661 | tb->toggleCapsLockState(); | 663 | tb->toggleCapsLockState(); |
662 | } | 664 | } |
663 | 665 | ||
664 | void Desktop::styleChange( QStyle &s ) | 666 | void Desktop::styleChange( QStyle &s ) |
665 | { | 667 | { |
666 | QWidget::styleChange( s ); | 668 | QWidget::styleChange( s ); |
667 | int displayw = qApp->desktop()->width(); | 669 | int displayw = qApp->desktop()->width(); |
668 | int displayh = qApp->desktop()->height(); | 670 | int displayh = qApp->desktop()->height(); |
669 | 671 | ||
670 | QSize sz = tb->sizeHint(); | 672 | QSize sz = tb->sizeHint(); |
671 | 673 | ||
672 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 674 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
673 | } | 675 | } |
674 | 676 | ||
675 | void DesktopApplication::shutdown() | 677 | void DesktopApplication::shutdown() |
676 | { | 678 | { |
677 | if ( type() != GuiServer ) | 679 | if ( type() != GuiServer ) |
678 | return; | 680 | return; |
679 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 681 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
680 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), | 682 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), |
681 | this, SLOT(shutdown(ShutdownImpl::Type)) ); | 683 | this, SLOT(shutdown(ShutdownImpl::Type)) ); |
682 | sd->showMaximized(); | 684 | sd->showMaximized(); |
683 | } | 685 | } |
684 | 686 | ||
685 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 687 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
686 | { | 688 | { |
687 | switch ( t ) { | 689 | switch ( t ) { |
688 | case ShutdownImpl::ShutdownSystem: | 690 | case ShutdownImpl::ShutdownSystem: |
689 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); | 691 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); |
690 | break; | 692 | break; |
691 | case ShutdownImpl::RebootSystem: | 693 | case ShutdownImpl::RebootSystem: |
692 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); | 694 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); |
693 | break; | 695 | break; |
694 | case ShutdownImpl::RestartDesktop: | 696 | case ShutdownImpl::RestartDesktop: |
695 | restart(); | 697 | restart(); |
696 | break; | 698 | break; |
697 | case ShutdownImpl::TerminateDesktop: | 699 | case ShutdownImpl::TerminateDesktop: |
698 | prepareForTermination(FALSE); | 700 | prepareForTermination(FALSE); |
699 | 701 | ||
700 | // This is a workaround for a Qt bug | 702 | // This is a workaround for a Qt bug |
701 | // clipboard applet has to stop its poll timer, or Qt/E | 703 | // clipboard applet has to stop its poll timer, or Qt/E |
702 | // will hang on quit() right before it emits aboutToQuit() | 704 | // will hang on quit() right before it emits aboutToQuit() |
703 | emit aboutToQuit ( ); | 705 | emit aboutToQuit ( ); |
704 | 706 | ||
705 | quit(); | 707 | quit(); |
706 | break; | 708 | break; |
707 | } | 709 | } |
708 | } | 710 | } |
709 | 711 | ||
710 | void DesktopApplication::restart() | 712 | void DesktopApplication::restart() |
711 | { | 713 | { |
712 | prepareForTermination(TRUE); | 714 | prepareForTermination(TRUE); |
713 | 715 | ||
714 | #ifdef Q_WS_QWS | 716 | #ifdef Q_WS_QWS |
715 | for ( int fd = 3; fd < 100; fd++ ) | 717 | for ( int fd = 3; fd < 100; fd++ ) |
716 | close( fd ); | 718 | close( fd ); |
717 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 719 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
718 | execl( "/sbin/init", "qpe", 0 ); | 720 | execl( "/sbin/init", "qpe", 0 ); |
719 | #elif defined(QT_QWS_CASSIOPEIA) | 721 | #elif defined(QT_QWS_CASSIOPEIA) |
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 5cf624b..ca0bbe4 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -1,387 +1,265 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "desktop.h" | 21 | #include "desktop.h" |
22 | #include "taskbar.h" | 22 | #include "taskbar.h" |
23 | #include "stabmon.h" | 23 | #include "stabmon.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/network.h> | 26 | #include <qpe/network.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 28 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
29 | #include <qpe/custom.h> | 29 | #include <qpe/custom.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #include <opie/odevice.h> | 32 | #include <opie/odevice.h> |
33 | 33 | ||
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qwindowsystem_qws.h> | 35 | #include <qwindowsystem_qws.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | #include <qpe/alarmserver.h> | 37 | #include <qpe/alarmserver.h> |
38 | 38 | ||
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include <stdio.h> | 40 | #include <stdio.h> |
41 | #include <signal.h> | 41 | #include <signal.h> |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | 43 | ||
44 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 44 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
45 | #include "../calibrate/calibrate.h" | 45 | #include "../calibrate/calibrate.h" |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | #ifdef QT_QWS_CASSIOPEIA | ||
49 | static void ignoreMessage( QtMsgType, const char * ) | ||
50 | { | ||
51 | } | ||
52 | #include <sys/mount.h> | ||
53 | #include <sys/types.h> | ||
54 | #include <sys/stat.h> | ||
55 | #include <sys/time.h> | ||
56 | #include <fcntl.h> | ||
57 | #include <qdatetime.h> | ||
58 | |||
59 | void initCassiopeia() | ||
60 | { | ||
61 | // MIPSEL-specific init - make sure /proc exists for shm | ||
62 | /* | ||
63 | if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) { | ||
64 | perror("Remounting - / read/write"); | ||
65 | } | ||
66 | */ | ||
67 | if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) { | ||
68 | perror("mounting ramfs /tmp"); | ||
69 | } else { | ||
70 | fprintf( stderr, "mounted /tmp\n" ); | ||
71 | } | ||
72 | if ( mount("none", "/home", "ramfs", 0, 0 ) ) { | ||
73 | perror("mounting ramfs /home"); | ||
74 | } else { | ||
75 | fprintf( stderr, "mounted /home\n" ); | ||
76 | } | ||
77 | if ( mount("none","/proc","proc",0,0) ) { | ||
78 | perror("Mounting - /proc"); | ||
79 | } else { | ||
80 | fprintf( stderr, "mounted /proc\n" ); | ||
81 | } | ||
82 | if ( mount("none","/mnt","shm",0,0) ) { | ||
83 | perror("Mounting - shm"); | ||
84 | } | ||
85 | setenv( "QTDIR", "/", 1 ); | ||
86 | setenv( "OPIEDIR", "/", 1 ); | ||
87 | setenv( "HOME", "/home", 1 ); | ||
88 | mkdir( "/home/Documents", 0755 ); | ||
89 | |||
90 | // set a reasonable starting date | ||
91 | QDateTime dt( QDate( 2001, 3, 15 ) ); | ||
92 | QDateTime now = QDateTime::currentDateTime(); | ||
93 | int change = now.secsTo( dt ); | ||
94 | |||
95 | time_t t = ::time(0); | ||
96 | t += change; | ||
97 | stime(&t); | ||
98 | |||
99 | qInstallMsgHandler(ignoreMessage); | ||
100 | } | ||
101 | #endif | ||
102 | |||
103 | #ifdef QPE_OWNAPM | ||
104 | #include <sys/ioctl.h> | ||
105 | #include <sys/types.h> | ||
106 | #include <fcntl.h> | ||
107 | #include <unistd.h> | ||
108 | #include <errno.h> | ||
109 | #include <linux/ioctl.h> | ||
110 | #include <qpe/global.h> | ||
111 | |||
112 | static void disableAPM() | ||
113 | { | ||
114 | |||
115 | int fd, cur_val, ret; | ||
116 | char *device = "/dev/apm_bios"; | ||
117 | |||
118 | fd = open (device, O_WRONLY); | ||
119 | |||
120 | if (fd == -1) { | ||
121 | perror(device); | ||
122 | return; | ||
123 | } | ||
124 | |||
125 | cur_val = ioctl(fd, APM_IOCGEVTSRC, 0); | ||
126 | if (cur_val == -1) { | ||
127 | perror("ioctl"); | ||
128 | exit(errno); | ||
129 | } | ||
130 | |||
131 | ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON); | ||
132 | if (ret == -1) { | ||
133 | perror("ioctl"); | ||
134 | return; | ||
135 | } | ||
136 | close(fd); | ||
137 | } | ||
138 | |||
139 | static void initAPM() | ||
140 | { | ||
141 | // So that we have to do it ourself, but better. | ||
142 | disableAPM(); | ||
143 | } | ||
144 | #endif | ||
145 | |||
146 | #ifdef QT_DEMO_SINGLE_FLOPPY | ||
147 | #include <sys/mount.h> | ||
148 | |||
149 | void initFloppy() | ||
150 | { | ||
151 | mount("none","/proc","proc",0,0); | ||
152 | setenv( "QTDIR", "/", 0 ); | ||
153 | setenv( "HOME", "/root", 0 ); | ||
154 | setenv( "QWS_SIZE", "240x320", 0 ); | ||
155 | } | ||
156 | #endif | ||
157 | |||
158 | 48 | ||
159 | void initEnvironment() | 49 | void initEnvironment() |
160 | { | 50 | { |
161 | Config config("locale"); | 51 | Config config("locale"); |
162 | config.setGroup( "Location" ); | 52 | config.setGroup( "Location" ); |
163 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); | 53 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); |
164 | 54 | ||
165 | // if not timezone set, pick New York | 55 | // if not timezone set, pick New York |
166 | if (tz.isNull()) | 56 | if (tz.isNull()) |
167 | tz = "America/New_York"; | 57 | tz = "America/New_York"; |
168 | 58 | ||
169 | setenv( "TZ", tz, 1 ); | 59 | setenv( "TZ", tz, 1 ); |
170 | config.writeEntry( "Timezone", tz); | 60 | config.writeEntry( "Timezone", tz); |
171 | 61 | ||
172 | config.setGroup( "Language" ); | 62 | config.setGroup( "Language" ); |
173 | QString lang = config.readEntry( "Language", getenv("LANG") ); | 63 | QString lang = config.readEntry( "Language", getenv("LANG") ); |
174 | if ( !lang.isNull() ) | 64 | if ( !lang.isNull() ) |
175 | setenv( "LANG", lang, 1 ); | 65 | setenv( "LANG", lang, 1 ); |
176 | } | 66 | } |
177 | 67 | ||
178 | static void initBacklight() | 68 | static void initBacklight() |
179 | { | 69 | { |
180 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | 70 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); |
181 | e << -3; // Forced on | 71 | e << -3; // Forced on |
182 | } | 72 | } |
183 | 73 | ||
184 | 74 | ||
185 | class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter | 75 | class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter |
186 | { | 76 | { |
187 | public: | 77 | public: |
188 | ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) | 78 | ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) |
189 | { | 79 | { |
190 | bool doinst = false; | 80 | bool doinst = false; |
191 | 81 | ||
192 | m_model = ODevice::inst ( )-> model ( ); | 82 | m_model = ODevice::inst ( )-> model ( ); |
193 | m_power_timer = 0; | 83 | m_power_timer = 0; |
194 | 84 | ||
195 | switch ( m_model ) { | 85 | switch ( m_model ) { |
196 | case OMODEL_iPAQ_H31xx: | 86 | case OMODEL_iPAQ_H31xx: |
197 | case OMODEL_iPAQ_H36xx: | 87 | case OMODEL_iPAQ_H36xx: |
198 | case OMODEL_iPAQ_H37xx: | 88 | case OMODEL_iPAQ_H37xx: |
199 | case OMODEL_iPAQ_H38xx: doinst = true; | 89 | case OMODEL_iPAQ_H38xx: doinst = true; |
200 | break; | 90 | break; |
201 | default : break; | 91 | default : break; |
202 | } | 92 | } |
203 | if ( doinst ) | 93 | if ( doinst ) |
204 | QWSServer::setKeyboardFilter ( this ); | 94 | QWSServer::setKeyboardFilter ( this ); |
205 | } | 95 | } |
206 | 96 | ||
207 | virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 97 | virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
208 | { | 98 | { |
209 | bool kill = false; | 99 | bool kill = false; |
210 | 100 | ||
211 | // Rotate cursor keys 180° | 101 | // Rotate cursor keys 180° |
212 | switch ( m_model ) { | 102 | switch ( m_model ) { |
213 | case OMODEL_iPAQ_H31xx: | 103 | case OMODEL_iPAQ_H31xx: |
214 | case OMODEL_iPAQ_H38xx: { | 104 | case OMODEL_iPAQ_H38xx: { |
215 | int newkeycode = keycode; | 105 | int newkeycode = keycode; |
216 | 106 | ||
217 | switch ( keycode ) { | 107 | switch ( keycode ) { |
218 | case Key_Left : newkeycode = Key_Right; break; | 108 | case Key_Left : newkeycode = Key_Right; break; |
219 | case Key_Right: newkeycode = Key_Left; break; | 109 | case Key_Right: newkeycode = Key_Left; break; |
220 | case Key_Up : newkeycode = Key_Down; break; | 110 | case Key_Up : newkeycode = Key_Down; break; |
221 | case Key_Down : newkeycode = Key_Up; break; | 111 | case Key_Down : newkeycode = Key_Up; break; |
222 | } | 112 | } |
223 | if ( newkeycode != keycode ) { | 113 | if ( newkeycode != keycode ) { |
224 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 114 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
225 | kill = true; | 115 | kill = true; |
226 | } | 116 | } |
227 | break; | 117 | break; |
228 | } | 118 | } |
229 | default: break; | 119 | default: break; |
230 | } | 120 | } |
231 | 121 | ||
232 | // map Power Button short/long press to F34/F35 | 122 | // map Power Button short/long press to F34/F35 |
233 | switch ( m_model ) { | 123 | switch ( m_model ) { |
234 | case OMODEL_iPAQ_H31xx: | 124 | case OMODEL_iPAQ_H31xx: |
235 | case OMODEL_iPAQ_H36xx: | 125 | case OMODEL_iPAQ_H36xx: |
236 | case OMODEL_iPAQ_H37xx: | 126 | case OMODEL_iPAQ_H37xx: |
237 | case OMODEL_iPAQ_H38xx: { | 127 | case OMODEL_iPAQ_H38xx: { |
238 | if ( keycode == Key_SysReq ) { | 128 | if ( keycode == Key_SysReq ) { |
239 | if ( isPress ) { | 129 | if ( isPress ) { |
240 | if ( m_power_timer ) | 130 | if ( m_power_timer ) |
241 | killTimer ( m_power_timer ); | 131 | killTimer ( m_power_timer ); |
242 | m_power_timer = startTimer ( 500 ); | 132 | m_power_timer = startTimer ( 500 ); |
243 | } | 133 | } |
244 | else if ( m_power_timer ) { | 134 | else if ( m_power_timer ) { |
245 | killTimer ( m_power_timer ); | 135 | killTimer ( m_power_timer ); |
246 | m_power_timer = 0; | 136 | m_power_timer = 0; |
247 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); | 137 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); |
248 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); | 138 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); |
249 | } | 139 | } |
250 | kill = true; | 140 | kill = true; |
251 | } | 141 | } |
252 | break; | 142 | break; |
253 | } | 143 | } |
254 | default: break; | 144 | default: break; |
255 | } | 145 | } |
256 | return kill; | 146 | return kill; |
257 | } | 147 | } |
258 | 148 | ||
259 | virtual void timerEvent ( QTimerEvent * ) | 149 | virtual void timerEvent ( QTimerEvent * ) |
260 | { | 150 | { |
261 | killTimer ( m_power_timer ); | 151 | killTimer ( m_power_timer ); |
262 | m_power_timer = 0; | 152 | m_power_timer = 0; |
263 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); | 153 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); |
264 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); | 154 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); |
265 | } | 155 | } |
266 | 156 | ||
267 | private: | 157 | private: |
268 | OModel m_model; | 158 | OModel m_model; |
269 | int m_power_timer; | 159 | int m_power_timer; |
270 | }; | 160 | }; |
271 | 161 | ||
272 | 162 | ||
273 | 163 | ||
274 | int initApplication( int argc, char ** argv ) | 164 | int initApplication( int argc, char ** argv ) |
275 | { | 165 | { |
276 | #ifdef QT_QWS_CASSIOPEIA | 166 | ODevice::inst ( )-> setPowerButtonHandler ( ODevice::OPIE ); |
277 | initCassiopeia(); | ||
278 | #endif | ||
279 | |||
280 | #ifdef QPE_OWNAPM | ||
281 | initAPM(); | ||
282 | #endif | ||
283 | |||
284 | #ifdef QT_DEMO_SINGLE_FLOPPY | ||
285 | initFloppy(); | ||
286 | #endif | ||
287 | 167 | ||
288 | initEnvironment(); | 168 | initEnvironment(); |
289 | 169 | ||
290 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) | 170 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) |
291 | setenv( "QWS_SIZE", "240x320", 0 ); | 171 | setenv( "QWS_SIZE", "240x320", 0 ); |
292 | #endif | 172 | #endif |
293 | 173 | ||
294 | //Don't flicker at startup: | 174 | //Don't flicker at startup: |
295 | QWSServer::setDesktopBackground( QImage() ); | 175 | QWSServer::setDesktopBackground( QImage() ); |
296 | DesktopApplication a( argc, argv, QApplication::GuiServer ); | 176 | DesktopApplication a( argc, argv, QApplication::GuiServer ); |
297 | 177 | ||
298 | (void) new ModelKeyFilter ( ); | 178 | (void) new ModelKeyFilter ( ); |
299 | 179 | ||
300 | initBacklight(); | 180 | initBacklight(); |
301 | 181 | ||
302 | AlarmServer::initialize(); | 182 | AlarmServer::initialize(); |
303 | 183 | ||
304 | Desktop *d = new Desktop(); | 184 | Desktop *d = new Desktop(); |
305 | 185 | ||
306 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); | 186 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); |
307 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); | 187 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); |
308 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); | 188 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); |
309 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); | 189 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); |
310 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); | 190 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); |
311 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); | 191 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); |
312 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); | 192 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); |
313 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); | 193 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); |
314 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); | 194 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); |
315 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); | 195 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); |
316 | 196 | ||
317 | (void)new SysFileMonitor(d); | 197 | (void)new SysFileMonitor(d); |
318 | Network::createServer(d); | 198 | Network::createServer(d); |
319 | 199 | ||
320 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 200 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
321 | if ( !QFile::exists( "/etc/pointercal" ) ) { | 201 | if ( !QFile::exists( "/etc/pointercal" ) ) { |
322 | // Make sure calibration widget starts on top. | 202 | // Make sure calibration widget starts on top. |
323 | Calibrate *cal = new Calibrate; | 203 | Calibrate *cal = new Calibrate; |
324 | cal->exec(); | 204 | cal->exec(); |
325 | delete cal; | 205 | delete cal; |
326 | } | 206 | } |
327 | #endif | 207 | #endif |
328 | 208 | ||
329 | d->show(); | 209 | d->show(); |
330 | 210 | ||
331 | int rv = a.exec(); | 211 | int rv = a.exec(); |
332 | 212 | ||
333 | delete d; | 213 | delete d; |
334 | 214 | ||
215 | ODevice::inst ( )-> setPowerButtonHandler ( ODevice::KERNEL ); | ||
216 | |||
335 | return rv; | 217 | return rv; |
336 | } | 218 | } |
337 | 219 | ||
338 | static const char *pidfile_path = "/var/run/opie.pid"; | 220 | static const char *pidfile_path = "/var/run/opie.pid"; |
339 | 221 | ||
340 | void create_pidfile ( ) | 222 | void create_pidfile ( ) |
341 | { | 223 | { |
342 | FILE *f; | 224 | FILE *f; |
343 | 225 | ||
344 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 226 | if (( f = ::fopen ( pidfile_path, "w" ))) { |
345 | ::fprintf ( f, "%d", getpid ( )); | 227 | ::fprintf ( f, "%d", getpid ( )); |
346 | ::fclose ( f ); | 228 | ::fclose ( f ); |
347 | } | 229 | } |
348 | } | 230 | } |
349 | 231 | ||
350 | void remove_pidfile ( ) | 232 | void remove_pidfile ( ) |
351 | { | 233 | { |
352 | ::unlink ( pidfile_path ); | 234 | ::unlink ( pidfile_path ); |
353 | } | 235 | } |
354 | 236 | ||
355 | void handle_sigterm ( int /* sig */ ) | 237 | void handle_sigterm ( int /* sig */ ) |
356 | { | 238 | { |
357 | if ( qApp ) | 239 | if ( qApp ) |
358 | qApp-> quit ( ); | 240 | qApp-> quit ( ); |
359 | } | 241 | } |
360 | 242 | ||
361 | int main( int argc, char ** argv ) | 243 | int main( int argc, char ** argv ) |
362 | { | 244 | { |
363 | #ifndef SINGLE_APP | ||
364 | ::signal( SIGCHLD, SIG_IGN ); | 245 | ::signal( SIGCHLD, SIG_IGN ); |
365 | 246 | ||
366 | ::signal ( SIGTERM, handle_sigterm ); | 247 | ::signal ( SIGTERM, handle_sigterm ); |
367 | ::signal ( SIGINT, handle_sigterm ); | 248 | ::signal ( SIGINT, handle_sigterm ); |
368 | 249 | ||
369 | ::setsid ( ); | 250 | ::setsid ( ); |
370 | ::setpgid ( 0, 0 ); | 251 | ::setpgid ( 0, 0 ); |
371 | 252 | ||
372 | ::atexit ( remove_pidfile ); | 253 | ::atexit ( remove_pidfile ); |
373 | create_pidfile ( ); | 254 | create_pidfile ( ); |
374 | #endif | ||
375 | 255 | ||
376 | int retVal = initApplication ( argc, argv ); | 256 | int retVal = initApplication ( argc, argv ); |
377 | 257 | ||
378 | #ifndef SINGLE_APP | ||
379 | // Kill them. Kill them all. | 258 | // Kill them. Kill them all. |
380 | ::kill ( 0, SIGTERM ); | 259 | ::kill ( 0, SIGTERM ); |
381 | ::sleep( 1 ); | 260 | ::sleep ( 1 ); |
382 | ::kill ( 0, SIGKILL ); | 261 | ::kill ( 0, SIGKILL ); |
383 | #endif | ||
384 | 262 | ||
385 | return retVal; | 263 | return retVal; |
386 | } | 264 | } |
387 | 265 | ||