-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 | |||
@@ -576,96 +576,98 @@ void Desktop::execAutoStart() | |||
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 | ||
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,205 +1,95 @@ | |||
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 | } |
@@ -228,160 +118,148 @@ public: | |||
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 | ||