author | sandman <sandman> | 2002-09-05 21:24:48 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-05 21:24:48 (UTC) |
commit | 70f3ed196a462eda3dd6554daddf210438aacc8a (patch) (unidiff) | |
tree | e19256fdc5ceaa5c0b4d1492e15fc42ee87d7692 | |
parent | baea6aaf4f0c9672a4383470a9389bca1a20bdba (diff) | |
download | opie-70f3ed196a462eda3dd6554daddf210438aacc8a.zip opie-70f3ed196a462eda3dd6554daddf210438aacc8a.tar.gz opie-70f3ed196a462eda3dd6554daddf210438aacc8a.tar.bz2 |
- remove obsolete cassiopeia and single-floppy code
- use the new ODevice setPowerButtonHandler() to set and reset power
button handling
-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 | |||
@@ -1,812 +1,814 @@ | |||
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 "info.h" | 22 | #include "info.h" |
23 | #include "launcher.h" | 23 | #include "launcher.h" |
24 | #include "mrulist.h" | 24 | #include "mrulist.h" |
25 | #include "qcopbridge.h" | 25 | #include "qcopbridge.h" |
26 | #include "shutdownimpl.h" | 26 | #include "shutdownimpl.h" |
27 | #include "startmenu.h" | 27 | #include "startmenu.h" |
28 | #include "taskbar.h" | 28 | #include "taskbar.h" |
29 | #include "transferserver.h" | 29 | #include "transferserver.h" |
30 | #include "irserver.h" | 30 | #include "irserver.h" |
31 | #include "packageslave.h" | 31 | #include "packageslave.h" |
32 | 32 | ||
33 | #include <qpe/applnk.h> | 33 | #include <qpe/applnk.h> |
34 | #include <qpe/mimetype.h> | 34 | #include <qpe/mimetype.h> |
35 | #include <qpe/password.h> | 35 | #include <qpe/password.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/power.h> | 37 | #include <qpe/power.h> |
38 | #include <qpe/timeconversion.h> | 38 | #include <qpe/timeconversion.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/global.h> | 40 | #include <qpe/global.h> |
41 | 41 | ||
42 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 42 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
43 | #include <qpe/custom.h> | 43 | #include <qpe/custom.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #include <opie/odevice.h> | 46 | #include <opie/odevice.h> |
47 | 47 | ||
48 | #include <qgfx_qws.h> | 48 | #include <qgfx_qws.h> |
49 | #include <qmainwindow.h> | 49 | #include <qmainwindow.h> |
50 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
51 | #include <qtimer.h> | 51 | #include <qtimer.h> |
52 | #include <qwindowsystem_qws.h> | 52 | #include <qwindowsystem_qws.h> |
53 | 53 | ||
54 | #include <qvaluelist.h> | 54 | #include <qvaluelist.h> |
55 | 55 | ||
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | #include <unistd.h> | 57 | #include <unistd.h> |
58 | 58 | ||
59 | class QCopKeyRegister | 59 | class QCopKeyRegister |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | QCopKeyRegister() : keyCode(0) { } | 62 | QCopKeyRegister() : keyCode(0) { } |
63 | QCopKeyRegister(int k, const QString &c, const QString &m) | 63 | QCopKeyRegister(int k, const QString &c, const QString &m) |
64 | : keyCode(k), channel(c), message(m) { } | 64 | : keyCode(k), channel(c), message(m) { } |
65 | 65 | ||
66 | int getKeyCode() const { return keyCode; } | 66 | int getKeyCode() const { return keyCode; } |
67 | QString getChannel() const { return channel; } | 67 | QString getChannel() const { return channel; } |
68 | QString getMessage() const { return message; } | 68 | QString getMessage() const { return message; } |
69 | 69 | ||
70 | private: | 70 | private: |
71 | int keyCode; | 71 | int keyCode; |
72 | QString channel, message; | 72 | QString channel, message; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 75 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
76 | KeyRegisterList keyRegisterList; | 76 | KeyRegisterList keyRegisterList; |
77 | 77 | ||
78 | static Desktop* qpedesktop = 0; | 78 | static Desktop* qpedesktop = 0; |
79 | static int loggedin=0; | 79 | static int loggedin=0; |
80 | static void login(bool at_poweron) | 80 | static void login(bool at_poweron) |
81 | { | 81 | { |
82 | if ( !loggedin ) { | 82 | if ( !loggedin ) { |
83 | Global::terminateBuiltin("calibrate"); | 83 | Global::terminateBuiltin("calibrate"); |
84 | Password::authenticate(at_poweron); | 84 | Password::authenticate(at_poweron); |
85 | loggedin=1; | 85 | loggedin=1; |
86 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 86 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | bool Desktop::screenLocked() | 90 | bool Desktop::screenLocked() |
91 | { | 91 | { |
92 | return loggedin == 0; | 92 | return loggedin == 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | /* | 95 | /* |
96 | Priority is number of alerts that are needed to pop up | 96 | Priority is number of alerts that are needed to pop up |
97 | alert. | 97 | alert. |
98 | */ | 98 | */ |
99 | class DesktopPowerAlerter : public QMessageBox | 99 | class DesktopPowerAlerter : public QMessageBox |
100 | { | 100 | { |
101 | public: | 101 | public: |
102 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 102 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
103 | : QMessageBox( tr("Battery Status"), "Low Battery", | 103 | : QMessageBox( tr("Battery Status"), "Low Battery", |
104 | QMessageBox::Critical, | 104 | QMessageBox::Critical, |
105 | QMessageBox::Ok | QMessageBox::Default, | 105 | QMessageBox::Ok | QMessageBox::Default, |
106 | QMessageBox::NoButton, QMessageBox::NoButton, | 106 | QMessageBox::NoButton, QMessageBox::NoButton, |
107 | parent, name, FALSE ) | 107 | parent, name, FALSE ) |
108 | { | 108 | { |
109 | currentPriority = INT_MAX; | 109 | currentPriority = INT_MAX; |
110 | alertCount = 0; | 110 | alertCount = 0; |
111 | } | 111 | } |
112 | 112 | ||
113 | void alert( const QString &text, int priority ); | 113 | void alert( const QString &text, int priority ); |
114 | void hideEvent( QHideEvent * ); | 114 | void hideEvent( QHideEvent * ); |
115 | private: | 115 | private: |
116 | int currentPriority; | 116 | int currentPriority; |
117 | int alertCount; | 117 | int alertCount; |
118 | }; | 118 | }; |
119 | 119 | ||
120 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 120 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
121 | { | 121 | { |
122 | alertCount++; | 122 | alertCount++; |
123 | if ( alertCount < priority ) | 123 | if ( alertCount < priority ) |
124 | return; | 124 | return; |
125 | if ( priority > currentPriority ) | 125 | if ( priority > currentPriority ) |
126 | return; | 126 | return; |
127 | currentPriority = priority; | 127 | currentPriority = priority; |
128 | setText( text ); | 128 | setText( text ); |
129 | show(); | 129 | show(); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 133 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
134 | { | 134 | { |
135 | QMessageBox::hideEvent( e ); | 135 | QMessageBox::hideEvent( e ); |
136 | alertCount = 0; | 136 | alertCount = 0; |
137 | currentPriority = INT_MAX; | 137 | currentPriority = INT_MAX; |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 142 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
143 | : QPEApplication( argc, argv, appType ) | 143 | : QPEApplication( argc, argv, appType ) |
144 | { | 144 | { |
145 | 145 | ||
146 | QTimer *t = new QTimer( this ); | 146 | QTimer *t = new QTimer( this ); |
147 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); | 147 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); |
148 | t->start( 10000 ); | 148 | t->start( 10000 ); |
149 | ps = new PowerStatus; | 149 | ps = new PowerStatus; |
150 | pa = new DesktopPowerAlerter( 0 ); | 150 | pa = new DesktopPowerAlerter( 0 ); |
151 | 151 | ||
152 | channel = new QCopChannel( "QPE/Desktop", this ); | 152 | channel = new QCopChannel( "QPE/Desktop", this ); |
153 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 153 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
154 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 154 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
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 | */ | 203 | */ |
204 | if (!keyRegisterList.isEmpty()) { | 204 | if (!keyRegisterList.isEmpty()) { |
205 | KeyRegisterList::Iterator it; | 205 | KeyRegisterList::Iterator it; |
206 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 206 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
207 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { | 207 | if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { |
208 | if(press) qDebug("press"); else qDebug("release"); | 208 | if(press) qDebug("press"); else qDebug("release"); |
209 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | 209 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | if ( !keyboardGrabbed() ) { | 214 | if ( !keyboardGrabbed() ) { |
215 | if ( ke->simpleData.keycode == Key_F9 ) { | 215 | if ( ke->simpleData.keycode == Key_F9 ) { |
216 | if ( press ) emit datebook(); | 216 | if ( press ) emit datebook(); |
217 | return TRUE; | 217 | return TRUE; |
218 | } | 218 | } |
219 | if ( ke->simpleData.keycode == Key_F10 ) { | 219 | if ( ke->simpleData.keycode == Key_F10 ) { |
220 | if ( !press && cardSendTimer ) { | 220 | if ( !press && cardSendTimer ) { |
221 | emit contacts(); | 221 | emit contacts(); |
222 | delete cardSendTimer; | 222 | delete cardSendTimer; |
223 | } else if ( press ) { | 223 | } else if ( press ) { |
224 | cardSendTimer = new QTimer(); | 224 | cardSendTimer = new QTimer(); |
225 | cardSendTimer->start( 2000, TRUE ); | 225 | cardSendTimer->start( 2000, TRUE ); |
226 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 226 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
227 | } | 227 | } |
228 | return TRUE; | 228 | return TRUE; |
229 | } | 229 | } |
230 | /* menu key now opens application menu/toolbar | 230 | /* menu key now opens application menu/toolbar |
231 | if ( ke->simpleData.keycode == Key_F11 ) { | 231 | if ( ke->simpleData.keycode == Key_F11 ) { |
232 | if ( press ) emit menu(); | 232 | if ( press ) emit menu(); |
233 | return TRUE; | 233 | return TRUE; |
234 | } | 234 | } |
235 | */ | 235 | */ |
236 | if ( ke->simpleData.keycode == Key_F12 ) { | 236 | if ( ke->simpleData.keycode == Key_F12 ) { |
237 | while( activePopupWidget() ) | 237 | while( activePopupWidget() ) |
238 | activePopupWidget()->close(); | 238 | activePopupWidget()->close(); |
239 | if ( press ) emit launch(); | 239 | if ( press ) emit launch(); |
240 | return TRUE; | 240 | return TRUE; |
241 | } | 241 | } |
242 | if ( ke->simpleData.keycode == Key_F13 ) { | 242 | if ( ke->simpleData.keycode == Key_F13 ) { |
243 | if ( press ) emit email(); | 243 | if ( press ) emit email(); |
244 | return TRUE; | 244 | return TRUE; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | if ( ke->simpleData.keycode == Key_F34 ) { | 248 | if ( ke->simpleData.keycode == Key_F34 ) { |
249 | if ( press ) emit power(); | 249 | if ( press ) emit power(); |
250 | return TRUE; | 250 | return TRUE; |
251 | } | 251 | } |
252 | // This was used for the iPAQ PowerButton | 252 | // This was used for the iPAQ PowerButton |
253 | // See main.cpp for new KeyboardFilter | 253 | // See main.cpp for new KeyboardFilter |
254 | // | 254 | // |
255 | // if ( ke->simpleData.keycode == Key_SysReq ) { | 255 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
256 | // if ( press ) emit power(); | 256 | // if ( press ) emit power(); |
257 | // return TRUE; | 257 | // return TRUE; |
258 | // } | 258 | // } |
259 | if ( ke->simpleData.keycode == Key_F35 ) { | 259 | if ( ke->simpleData.keycode == Key_F35 ) { |
260 | if ( press ) emit backlight(); | 260 | if ( press ) emit backlight(); |
261 | return TRUE; | 261 | return TRUE; |
262 | } | 262 | } |
263 | if ( ke->simpleData.keycode == Key_F32 ) { | 263 | if ( ke->simpleData.keycode == Key_F32 ) { |
264 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 264 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
265 | return TRUE; | 265 | return TRUE; |
266 | } | 266 | } |
267 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 267 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
268 | if ( press ) emit symbol(); | 268 | if ( press ) emit symbol(); |
269 | return TRUE; | 269 | return TRUE; |
270 | } | 270 | } |
271 | if ( ke->simpleData.keycode == Key_NumLock ) { | 271 | if ( ke->simpleData.keycode == Key_NumLock ) { |
272 | if ( press ) emit numLockStateToggle(); | 272 | if ( press ) emit numLockStateToggle(); |
273 | } | 273 | } |
274 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 274 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
275 | if ( press ) emit capsLockStateToggle(); | 275 | if ( press ) emit capsLockStateToggle(); |
276 | } | 276 | } |
277 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) | 277 | if (( press && !autoRepeat ) || ( !press && autoRepeat )) |
278 | qpedesktop->keyClick(); | 278 | qpedesktop->keyClick(); |
279 | } else { | 279 | } else { |
280 | if ( e->type == QWSEvent::Mouse ) { | 280 | if ( e->type == QWSEvent::Mouse ) { |
281 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 281 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
282 | static bool up = TRUE; | 282 | static bool up = TRUE; |
283 | if ( me->simpleData.state&LeftButton ) { | 283 | if ( me->simpleData.state&LeftButton ) { |
284 | if ( up ) { | 284 | if ( up ) { |
285 | up = FALSE; | 285 | up = FALSE; |
286 | qpedesktop->screenClick(); | 286 | qpedesktop->screenClick(); |
287 | } | 287 | } |
288 | } else { | 288 | } else { |
289 | up = TRUE; | 289 | up = TRUE; |
290 | } | 290 | } |
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | return QPEApplication::qwsEventFilter( e ); | 294 | return QPEApplication::qwsEventFilter( e ); |
295 | } | 295 | } |
296 | #endif | 296 | #endif |
297 | 297 | ||
298 | void DesktopApplication::psTimeout() | 298 | void DesktopApplication::psTimeout() |
299 | { | 299 | { |
300 | qpedesktop->checkMemory(); // in case no events are being generated | 300 | qpedesktop->checkMemory(); // in case no events are being generated |
301 | 301 | ||
302 | *ps = PowerStatusManager::readStatus(); | 302 | *ps = PowerStatusManager::readStatus(); |
303 | 303 | ||
304 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 304 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
305 | pa->alert( tr( "Battery is running very low." ), 6 ); | 305 | pa->alert( tr( "Battery is running very low." ), 6 ); |
306 | } | 306 | } |
307 | 307 | ||
308 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | 308 | if ( ps->batteryStatus() == PowerStatus::Critical ) { |
309 | pa->alert( tr( "Battery level is critical!\n" | 309 | pa->alert( tr( "Battery level is critical!\n" |
310 | "Keep power off until power restored!" ), 1 ); | 310 | "Keep power off until power restored!" ), 1 ); |
311 | } | 311 | } |
312 | 312 | ||
313 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 313 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
314 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 314 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
319 | void DesktopApplication::sendCard() | 319 | void DesktopApplication::sendCard() |
320 | { | 320 | { |
321 | delete cardSendTimer; | 321 | delete cardSendTimer; |
322 | cardSendTimer = 0; | 322 | cardSendTimer = 0; |
323 | QString card = getenv("HOME"); | 323 | QString card = getenv("HOME"); |
324 | card += "/Applications/addressbook/businesscard.vcf"; | 324 | card += "/Applications/addressbook/businesscard.vcf"; |
325 | 325 | ||
326 | if ( QFile::exists( card ) ) { | 326 | if ( QFile::exists( card ) ) { |
327 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); | 327 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); |
328 | QString mimetype = "text/x-vCard"; | 328 | QString mimetype = "text/x-vCard"; |
329 | e << tr("business card") << card << mimetype; | 329 | e << tr("business card") << card << mimetype; |
330 | } | 330 | } |
331 | } | 331 | } |
332 | 332 | ||
333 | #if defined(QPE_HAVE_MEMALERTER) | 333 | #if defined(QPE_HAVE_MEMALERTER) |
334 | QPE_MEMALERTER_IMPL | 334 | QPE_MEMALERTER_IMPL |
335 | #endif | 335 | #endif |
336 | 336 | ||
337 | //=========================================================================== | 337 | //=========================================================================== |
338 | 338 | ||
339 | Desktop::Desktop() : | 339 | Desktop::Desktop() : |
340 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 340 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
341 | qcopBridge( 0 ), | 341 | qcopBridge( 0 ), |
342 | transferServer( 0 ), | 342 | transferServer( 0 ), |
343 | packageSlave( 0 ) | 343 | packageSlave( 0 ) |
344 | { | 344 | { |
345 | qpedesktop = this; | 345 | qpedesktop = this; |
346 | 346 | ||
347 | // bg = new Info( this ); | 347 | // bg = new Info( this ); |
348 | tb = new TaskBar; | 348 | tb = new TaskBar; |
349 | 349 | ||
350 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 350 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
351 | 351 | ||
352 | connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); | 352 | connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); |
353 | connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); | 353 | connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); |
354 | 354 | ||
355 | int displayw = qApp->desktop()->width(); | 355 | int displayw = qApp->desktop()->width(); |
356 | int displayh = qApp->desktop()->height(); | 356 | int displayh = qApp->desktop()->height(); |
357 | 357 | ||
358 | 358 | ||
359 | QSize sz = tb->sizeHint(); | 359 | QSize sz = tb->sizeHint(); |
360 | 360 | ||
361 | setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 361 | setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
362 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 362 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
363 | 363 | ||
364 | tb->show(); | 364 | tb->show(); |
365 | launcher->showMaximized(); | 365 | launcher->showMaximized(); |
366 | launcher->show(); | 366 | launcher->show(); |
367 | launcher->raise(); | 367 | launcher->raise(); |
368 | #if defined(QPE_HAVE_MEMALERTER) | 368 | #if defined(QPE_HAVE_MEMALERTER) |
369 | initMemalerter(); | 369 | initMemalerter(); |
370 | #endif | 370 | #endif |
371 | // start services | 371 | // start services |
372 | startTransferServer(); | 372 | startTransferServer(); |
373 | (void) new IrServer( this ); | 373 | (void) new IrServer( this ); |
374 | rereadVolumes(); | 374 | rereadVolumes(); |
375 | 375 | ||
376 | packageSlave = new PackageSlave( this ); | 376 | packageSlave = new PackageSlave( this ); |
377 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); | 377 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); |
378 | 378 | ||
379 | qApp->installEventFilter( this ); | 379 | qApp->installEventFilter( this ); |
380 | } | 380 | } |
381 | 381 | ||
382 | void Desktop::show() | 382 | void Desktop::show() |
383 | { | 383 | { |
384 | login(TRUE); | 384 | login(TRUE); |
385 | QWidget::show(); | 385 | QWidget::show(); |
386 | } | 386 | } |
387 | 387 | ||
388 | Desktop::~Desktop() | 388 | Desktop::~Desktop() |
389 | { | 389 | { |
390 | delete launcher; | 390 | delete launcher; |
391 | delete tb; | 391 | delete tb; |
392 | delete qcopBridge; | 392 | delete qcopBridge; |
393 | delete transferServer; | 393 | delete transferServer; |
394 | } | 394 | } |
395 | 395 | ||
396 | bool Desktop::recoverMemory() | 396 | bool Desktop::recoverMemory() |
397 | { | 397 | { |
398 | return tb->recoverMemory(); | 398 | return tb->recoverMemory(); |
399 | } | 399 | } |
400 | 400 | ||
401 | void Desktop::checkMemory() | 401 | void Desktop::checkMemory() |
402 | { | 402 | { |
403 | #if defined(QPE_HAVE_MEMALERTER) | 403 | #if defined(QPE_HAVE_MEMALERTER) |
404 | static bool ignoreNormal=FALSE; | 404 | static bool ignoreNormal=FALSE; |
405 | static bool existingMessage=FALSE; | 405 | static bool existingMessage=FALSE; |
406 | 406 | ||
407 | if(existingMessage) | 407 | if(existingMessage) |
408 | return; // don't show a second message while still on first | 408 | return; // don't show a second message while still on first |
409 | 409 | ||
410 | existingMessage = TRUE; | 410 | existingMessage = TRUE; |
411 | switch ( memstate ) { | 411 | switch ( memstate ) { |
412 | case Unknown: | 412 | case Unknown: |
413 | break; | 413 | break; |
414 | case Low: | 414 | case Low: |
415 | memstate = Unknown; | 415 | memstate = Unknown; |
416 | if ( recoverMemory() ) | 416 | if ( recoverMemory() ) |
417 | ignoreNormal = TRUE; | 417 | ignoreNormal = TRUE; |
418 | else | 418 | else |
419 | QMessageBox::warning( 0 , "Memory Status", | 419 | QMessageBox::warning( 0 , "Memory Status", |
420 | "The memory smacks of shortage. \n" | 420 | "The memory smacks of shortage. \n" |
421 | "Please save data. " ); | 421 | "Please save data. " ); |
422 | break; | 422 | break; |
423 | case Normal: | 423 | case Normal: |
424 | memstate = Unknown; | 424 | memstate = Unknown; |
425 | if ( ignoreNormal ) | 425 | if ( ignoreNormal ) |
426 | ignoreNormal = FALSE; | 426 | ignoreNormal = FALSE; |
427 | else | 427 | else |
428 | QMessageBox::information ( 0 , "Memory Status", | 428 | QMessageBox::information ( 0 , "Memory Status", |
429 | "There is enough memory again." ); | 429 | "There is enough memory again." ); |
430 | break; | 430 | break; |
431 | case VeryLow: | 431 | case VeryLow: |
432 | memstate = Unknown; | 432 | memstate = Unknown; |
433 | QMessageBox::critical( 0 , "Memory Status", | 433 | QMessageBox::critical( 0 , "Memory Status", |
434 | "The memory is very low. \n" | 434 | "The memory is very low. \n" |
435 | "Please end this application \n" | 435 | "Please end this application \n" |
436 | "immediately." ); | 436 | "immediately." ); |
437 | recoverMemory(); | 437 | recoverMemory(); |
438 | } | 438 | } |
439 | existingMessage = FALSE; | 439 | existingMessage = FALSE; |
440 | #endif | 440 | #endif |
441 | } | 441 | } |
442 | 442 | ||
443 | static bool isVisibleWindow(int wid) | 443 | static bool isVisibleWindow(int wid) |
444 | { | 444 | { |
445 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 445 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
446 | QWSWindow* w; | 446 | QWSWindow* w; |
447 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 447 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
448 | if ( w->winId() == wid ) | 448 | if ( w->winId() == wid ) |
449 | return !w->isFullyObscured(); | 449 | return !w->isFullyObscured(); |
450 | } | 450 | } |
451 | return FALSE; | 451 | return FALSE; |
452 | } | 452 | } |
453 | 453 | ||
454 | static bool hasVisibleWindow(const QString& clientname) | 454 | static bool hasVisibleWindow(const QString& clientname) |
455 | { | 455 | { |
456 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 456 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
457 | QWSWindow* w; | 457 | QWSWindow* w; |
458 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 458 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
459 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) | 459 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) |
460 | return TRUE; | 460 | return TRUE; |
461 | } | 461 | } |
462 | return FALSE; | 462 | return FALSE; |
463 | } | 463 | } |
464 | 464 | ||
465 | void Desktop::raiseLauncher() | 465 | void Desktop::raiseLauncher() |
466 | { | 466 | { |
467 | Config cfg("qpe"); //F12 'Home' | 467 | Config cfg("qpe"); //F12 'Home' |
468 | cfg.setGroup("AppsKey"); | 468 | cfg.setGroup("AppsKey"); |
469 | QString tempItem; | 469 | QString tempItem; |
470 | tempItem = cfg.readEntry("Middle","Home"); | 470 | tempItem = cfg.readEntry("Middle","Home"); |
471 | if(tempItem == "Home" || tempItem.isEmpty()) { | 471 | if(tempItem == "Home" || tempItem.isEmpty()) { |
472 | if ( isVisibleWindow(launcher->winId()) ) | 472 | if ( isVisibleWindow(launcher->winId()) ) |
473 | launcher->nextView(); | 473 | launcher->nextView(); |
474 | else | 474 | else |
475 | launcher->raise(); | 475 | launcher->raise(); |
476 | } else { | 476 | } else { |
477 | QCopEnvelope e("QPE/System","execute(QString)"); | 477 | QCopEnvelope e("QPE/System","execute(QString)"); |
478 | e << tempItem; | 478 | e << tempItem; |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | void Desktop::executeOrModify(const QString& appLnkFile) | 482 | void Desktop::executeOrModify(const QString& appLnkFile) |
483 | { | 483 | { |
484 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); | 484 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); |
485 | if ( lnk.isValid() ) { | 485 | if ( lnk.isValid() ) { |
486 | QCString app = lnk.exec().utf8(); | 486 | QCString app = lnk.exec().utf8(); |
487 | Global::terminateBuiltin("calibrate"); | 487 | Global::terminateBuiltin("calibrate"); |
488 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { | 488 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { |
489 | MRUList::addTask(&lnk); | 489 | MRUList::addTask(&lnk); |
490 | if ( hasVisibleWindow(app) ) | 490 | if ( hasVisibleWindow(app) ) |
491 | QCopChannel::send("QPE/Application/" + app, "nextView()"); | 491 | QCopChannel::send("QPE/Application/" + app, "nextView()"); |
492 | else | 492 | else |
493 | QCopChannel::send("QPE/Application/" + app, "raise()"); | 493 | QCopChannel::send("QPE/Application/" + app, "raise()"); |
494 | } else { | 494 | } else { |
495 | lnk.execute(); | 495 | lnk.execute(); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | void Desktop::raiseDatebook() | 500 | void Desktop::raiseDatebook() |
501 | { | 501 | { |
502 | Config cfg( "qpe" ); //F9 'Activity' | 502 | Config cfg( "qpe" ); //F9 'Activity' |
503 | cfg.setGroup( "AppsKey" ); | 503 | cfg.setGroup( "AppsKey" ); |
504 | QString tempItem; | 504 | QString tempItem; |
505 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); | 505 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); |
506 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { | 506 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { |
507 | tempItem = "datebook"; | 507 | tempItem = "datebook"; |
508 | } | 508 | } |
509 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 509 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
510 | e << tempItem; | 510 | e << tempItem; |
511 | } | 511 | } |
512 | 512 | ||
513 | void Desktop::raiseContacts() | 513 | void Desktop::raiseContacts() |
514 | { | 514 | { |
515 | Config cfg( "qpe" ); //F10, 'Contacts' | 515 | Config cfg( "qpe" ); //F10, 'Contacts' |
516 | cfg.setGroup( "AppsKey" ); | 516 | cfg.setGroup( "AppsKey" ); |
517 | QString tempItem; | 517 | QString tempItem; |
518 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); | 518 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); |
519 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { | 519 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { |
520 | tempItem = "addressbook"; | 520 | tempItem = "addressbook"; |
521 | } | 521 | } |
522 | QCopEnvelope e("QPE/System","execute(QString)"); | 522 | QCopEnvelope e("QPE/System","execute(QString)"); |
523 | e << tempItem; | 523 | e << tempItem; |
524 | } | 524 | } |
525 | 525 | ||
526 | void Desktop::raiseMenu() | 526 | void Desktop::raiseMenu() |
527 | { | 527 | { |
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) |
720 | execl( "/bin/sh", "sh", 0 ); | 722 | execl( "/bin/sh", "sh", 0 ); |
721 | #else | 723 | #else |
722 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); | 724 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); |
723 | #endif | 725 | #endif |
724 | exit(1); | 726 | exit(1); |
725 | #endif | 727 | #endif |
726 | } | 728 | } |
727 | 729 | ||
728 | void Desktop::startTransferServer() | 730 | void Desktop::startTransferServer() |
729 | { | 731 | { |
730 | // start qcop bridge server | 732 | // start qcop bridge server |
731 | qcopBridge = new QCopBridge( 4243 ); | 733 | qcopBridge = new QCopBridge( 4243 ); |
732 | if ( !qcopBridge->ok() ) { | 734 | if ( !qcopBridge->ok() ) { |
733 | delete qcopBridge; | 735 | delete qcopBridge; |
734 | qcopBridge = 0; | 736 | qcopBridge = 0; |
735 | } | 737 | } |
736 | // start transfer server | 738 | // start transfer server |
737 | transferServer = new TransferServer( 4242 ); | 739 | transferServer = new TransferServer( 4242 ); |
738 | if ( !transferServer->ok() ) { | 740 | if ( !transferServer->ok() ) { |
739 | delete transferServer; | 741 | delete transferServer; |
740 | transferServer = 0; | 742 | transferServer = 0; |
741 | } | 743 | } |
742 | if ( !transferServer || !qcopBridge ) | 744 | if ( !transferServer || !qcopBridge ) |
743 | startTimer( 2000 ); | 745 | startTimer( 2000 ); |
744 | } | 746 | } |
745 | 747 | ||
746 | void Desktop::timerEvent( QTimerEvent *e ) | 748 | void Desktop::timerEvent( QTimerEvent *e ) |
747 | { | 749 | { |
748 | killTimer( e->timerId() ); | 750 | killTimer( e->timerId() ); |
749 | startTransferServer(); | 751 | startTransferServer(); |
750 | } | 752 | } |
751 | 753 | ||
752 | void Desktop::terminateServers() | 754 | void Desktop::terminateServers() |
753 | { | 755 | { |
754 | delete transferServer; | 756 | delete transferServer; |
755 | delete qcopBridge; | 757 | delete qcopBridge; |
756 | transferServer = 0; | 758 | transferServer = 0; |
757 | qcopBridge = 0; | 759 | qcopBridge = 0; |
758 | } | 760 | } |
759 | 761 | ||
760 | void Desktop::rereadVolumes() | 762 | void Desktop::rereadVolumes() |
761 | { | 763 | { |
762 | Config cfg("qpe"); | 764 | Config cfg("qpe"); |
763 | cfg.setGroup("Volume"); | 765 | cfg.setGroup("Volume"); |
764 | touchclick = cfg.readBoolEntry("TouchSound"); | 766 | touchclick = cfg.readBoolEntry("TouchSound"); |
765 | keyclick = cfg.readBoolEntry("KeySound"); | 767 | keyclick = cfg.readBoolEntry("KeySound"); |
766 | alarmsound = cfg.readBoolEntry("AlarmSound"); | 768 | alarmsound = cfg.readBoolEntry("AlarmSound"); |
767 | } | 769 | } |
768 | 770 | ||
769 | void Desktop::keyClick() | 771 | void Desktop::keyClick() |
770 | { | 772 | { |
771 | if ( keyclick ) | 773 | if ( keyclick ) |
772 | ODevice::inst ( )-> keySound ( ); | 774 | ODevice::inst ( )-> keySound ( ); |
773 | } | 775 | } |
774 | 776 | ||
775 | void Desktop::screenClick() | 777 | void Desktop::screenClick() |
776 | { | 778 | { |
777 | if ( touchclick ) | 779 | if ( touchclick ) |
778 | ODevice::inst ( )-> touchSound ( ); | 780 | ODevice::inst ( )-> touchSound ( ); |
779 | } | 781 | } |
780 | 782 | ||
781 | void Desktop::soundAlarm() | 783 | void Desktop::soundAlarm() |
782 | { | 784 | { |
783 | if ( qpedesktop-> alarmsound ) | 785 | if ( qpedesktop-> alarmsound ) |
784 | ODevice::inst ( )-> alarmSound ( ); | 786 | ODevice::inst ( )-> alarmSound ( ); |
785 | } | 787 | } |
786 | 788 | ||
787 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | 789 | bool Desktop::eventFilter( QObject *, QEvent *ev ) |
788 | { | 790 | { |
789 | if ( ev-> type ( ) == QEvent::KeyPress ) { | 791 | if ( ev-> type ( ) == QEvent::KeyPress ) { |
790 | QKeyEvent *ke = (QKeyEvent *) ev; | 792 | QKeyEvent *ke = (QKeyEvent *) ev; |
791 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key | 793 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key |
792 | QWidget *active = qApp-> activeWindow ( ); | 794 | QWidget *active = qApp-> activeWindow ( ); |
793 | 795 | ||
794 | if ( active && active-> isPopup ( )) | 796 | if ( active && active-> isPopup ( )) |
795 | active->close(); | 797 | active->close(); |
796 | 798 | ||
797 | /* | 799 | /* |
798 | * On iPAQ 38xx that key is not the "menu key" but the mail key | 800 | * 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 | 801 | * To not confuse the users, make it launch the mail app on 38xx |
800 | */ | 802 | */ |
801 | if (ODevice::inst()->model() == OMODEL_iPAQ_H38xx ) { | 803 | if (ODevice::inst()->model() == OMODEL_iPAQ_H38xx ) { |
802 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 804 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
803 | e << QString( "mail" ); | 805 | e << QString( "mail" ); |
804 | return true; | 806 | return true; |
805 | } else { | 807 | } else { |
806 | raiseMenu ( ); | 808 | raiseMenu ( ); |
807 | return true; | 809 | return true; |
808 | } | 810 | } |
809 | } | 811 | } |
810 | } | 812 | } |
811 | return false; | 813 | return false; |
812 | } | 814 | } |
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 | ||