summaryrefslogtreecommitdiff
authorsandman <sandman>2002-06-16 01:31:36 (UTC)
committer sandman <sandman>2002-06-16 01:31:36 (UTC)
commitac7ddc479efedd5cbfb0f4a8a3e4fa304abfaa91 (patch) (unidiff)
tree9f21f116a4b7057c6a2f1bae45a0dfedc5bcae6b
parenteb414eb5d393f0f727e833fc8901aef096558997 (diff)
downloadopie-ac7ddc479efedd5cbfb0f4a8a3e4fa304abfaa91.zip
opie-ac7ddc479efedd5cbfb0f4a8a3e4fa304abfaa91.tar.gz
opie-ac7ddc479efedd5cbfb0f4a8a3e4fa304abfaa91.tar.bz2
Keyboard filter restructuring based on model detection:
1) Added a KeyboardFilter to main.cpp !! Please use this class for low-level/model-based filtering !! 2) Cursor keys are rotated for H31xx and H38xx 3) Power button long-press toggles backlight on iPAQs now (Mapped to F34/F35 - just like Z's)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp11
-rw-r--r--core/launcher/launcher.pro2
-rw-r--r--core/launcher/main.cpp91
3 files changed, 99 insertions, 5 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index aa51898..ab4f14a 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -149,196 +149,199 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
149 149
150 channel = new QCopChannel( "QPE/Desktop", this ); 150 channel = new QCopChannel( "QPE/Desktop", this );
151 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 151 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
152 this, SLOT(receive(const QCString&, const QByteArray&)) ); 152 this, SLOT(receive(const QCString&, const QByteArray&)) );
153} 153}
154 154
155 155
156DesktopApplication::~DesktopApplication() 156DesktopApplication::~DesktopApplication()
157{ 157{
158 delete ps; 158 delete ps;
159 delete pa; 159 delete pa;
160} 160}
161 161
162void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) 162void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
163{ 163{
164 QDataStream stream( data, IO_ReadOnly ); 164 QDataStream stream( data, IO_ReadOnly );
165 if (msg == "keyRegister(int key, QString channel, QString message)") 165 if (msg == "keyRegister(int key, QString channel, QString message)")
166 { 166 {
167 int k; 167 int k;
168 QString c, m; 168 QString c, m;
169 stream >> k; 169 stream >> k;
170 stream >> c; 170 stream >> c;
171 stream >> m; 171 stream >> m;
172 172
173 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); 173 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m );
174 keyRegisterList.append(QCopKeyRegister(k,c,m)); 174 keyRegisterList.append(QCopKeyRegister(k,c,m));
175 } 175 }
176 else if (msg == "suspend()"){ 176 else if (msg == "suspend()"){
177 emit power(); 177 emit power();
178 } 178 }
179 179
180} 180}
181 181
182enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 182enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
183 183
184#ifdef Q_WS_QWS 184#ifdef Q_WS_QWS
185bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 185bool DesktopApplication::qwsEventFilter( QWSEvent *e )
186{ 186{
187 qpedesktop->checkMemory(); 187 qpedesktop->checkMemory();
188 188
189 if ( e->type == QWSEvent::Key ) { 189 if ( e->type == QWSEvent::Key ) {
190 QWSKeyEvent *ke = (QWSKeyEvent *)e; 190 QWSKeyEvent *ke = (QWSKeyEvent *)e;
191 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 191 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
192 return TRUE; 192 return TRUE;
193 bool press = ke->simpleData.is_press; 193 bool press = ke->simpleData.is_press;
194 bool autoRepeat= ke->simpleData.is_auto_repeat; 194 bool autoRepeat= ke->simpleData.is_auto_repeat;
195 if (!keyRegisterList.isEmpty()) 195 if (!keyRegisterList.isEmpty())
196 { 196 {
197 KeyRegisterList::Iterator it; 197 KeyRegisterList::Iterator it;
198 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) 198 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
199 { 199 {
200 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) { 200 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) {
201 if(press) qDebug("press"); else qDebug("release"); 201 if(press) qDebug("press"); else qDebug("release");
202 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 202 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
203 } 203 }
204 } 204 }
205 } 205 }
206 206
207 if ( !keyboardGrabbed() ) { 207 if ( !keyboardGrabbed() ) {
208 if ( ke->simpleData.keycode == Key_F9 ) { 208 if ( ke->simpleData.keycode == Key_F9 ) {
209 if ( press ) emit datebook(); 209 if ( press ) emit datebook();
210 return TRUE; 210 return TRUE;
211 } 211 }
212 if ( ke->simpleData.keycode == Key_F10 ) { 212 if ( ke->simpleData.keycode == Key_F10 ) {
213 if ( !press && cardSendTimer ) { 213 if ( !press && cardSendTimer ) {
214 emit contacts(); 214 emit contacts();
215 delete cardSendTimer; 215 delete cardSendTimer;
216 } else if ( press ) { 216 } else if ( press ) {
217 cardSendTimer = new QTimer(); 217 cardSendTimer = new QTimer();
218 cardSendTimer->start( 2000, TRUE ); 218 cardSendTimer->start( 2000, TRUE );
219 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 219 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
220 } 220 }
221 return TRUE; 221 return TRUE;
222 } 222 }
223 /* menu key now opens application menu/toolbar 223 /* menu key now opens application menu/toolbar
224 if ( ke->simpleData.keycode == Key_F11 ) { 224 if ( ke->simpleData.keycode == Key_F11 ) {
225 if ( press ) emit menu(); 225 if ( press ) emit menu();
226 return TRUE; 226 return TRUE;
227 } 227 }
228 */ 228 */
229 if ( ke->simpleData.keycode == Key_F12 ) { 229 if ( ke->simpleData.keycode == Key_F12 ) {
230 while( activePopupWidget() ) 230 while( activePopupWidget() )
231 activePopupWidget()->close(); 231 activePopupWidget()->close();
232 if ( press ) emit launch(); 232 if ( press ) emit launch();
233 return TRUE; 233 return TRUE;
234 } 234 }
235 if ( ke->simpleData.keycode == Key_F13 ) { 235 if ( ke->simpleData.keycode == Key_F13 ) {
236 if ( press ) emit email(); 236 if ( press ) emit email();
237 return TRUE; 237 return TRUE;
238 } 238 }
239 } 239 }
240 240
241 if ( ke->simpleData.keycode == Key_F34 ) { 241 if ( ke->simpleData.keycode == Key_F34 ) {
242 if ( press ) emit power(); 242 if ( press ) emit power();
243 return TRUE; 243 return TRUE;
244 } 244 }
245 if ( ke->simpleData.keycode == Key_SysReq ) { 245// This was used for the iPAQ PowerButton
246 if ( press ) emit power(); 246// See main.cpp for new KeyboardFilter
247 return TRUE; 247//
248 } 248// if ( ke->simpleData.keycode == Key_SysReq ) {
249// if ( press ) emit power();
250// return TRUE;
251// }
249 if ( ke->simpleData.keycode == Key_F35 ) { 252 if ( ke->simpleData.keycode == Key_F35 ) {
250 if ( press ) emit backlight(); 253 if ( press ) emit backlight();
251 return TRUE; 254 return TRUE;
252 } 255 }
253 if ( ke->simpleData.keycode == Key_F32 ) { 256 if ( ke->simpleData.keycode == Key_F32 ) {
254 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 257 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
255 return TRUE; 258 return TRUE;
256 } 259 }
257 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 260 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
258 if ( press ) emit symbol(); 261 if ( press ) emit symbol();
259 return TRUE; 262 return TRUE;
260 } 263 }
261 if ( ke->simpleData.keycode == Key_NumLock ) { 264 if ( ke->simpleData.keycode == Key_NumLock ) {
262 if ( press ) emit numLockStateToggle(); 265 if ( press ) emit numLockStateToggle();
263 } 266 }
264 if ( ke->simpleData.keycode == Key_CapsLock ) { 267 if ( ke->simpleData.keycode == Key_CapsLock ) {
265 if ( press ) emit capsLockStateToggle(); 268 if ( press ) emit capsLockStateToggle();
266 } 269 }
267 if ( press ) 270 if ( press )
268 qpedesktop->keyClick(); 271 qpedesktop->keyClick();
269 } else { 272 } else {
270 if ( e->type == QWSEvent::Mouse ) { 273 if ( e->type == QWSEvent::Mouse ) {
271 QWSMouseEvent *me = (QWSMouseEvent *)e; 274 QWSMouseEvent *me = (QWSMouseEvent *)e;
272 static bool up = TRUE; 275 static bool up = TRUE;
273 if ( me->simpleData.state&LeftButton ) { 276 if ( me->simpleData.state&LeftButton ) {
274 if ( up ) { 277 if ( up ) {
275 up = FALSE; 278 up = FALSE;
276 qpedesktop->screenClick(); 279 qpedesktop->screenClick();
277 } 280 }
278 } else { 281 } else {
279 up = TRUE; 282 up = TRUE;
280 } 283 }
281 } 284 }
282 } 285 }
283 286
284 return QPEApplication::qwsEventFilter( e ); 287 return QPEApplication::qwsEventFilter( e );
285} 288}
286#endif 289#endif
287 290
288void DesktopApplication::psTimeout() 291void DesktopApplication::psTimeout()
289{ 292{
290 qpedesktop->checkMemory(); // in case no events are being generated 293 qpedesktop->checkMemory(); // in case no events are being generated
291 294
292 *ps = PowerStatusManager::readStatus(); 295 *ps = PowerStatusManager::readStatus();
293 296
294 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 297 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
295 pa->alert( tr( "Battery is running very low." ), 6 ); 298 pa->alert( tr( "Battery is running very low." ), 6 );
296 } 299 }
297 300
298 if ( ps->batteryStatus() == PowerStatus::Critical ) { 301 if ( ps->batteryStatus() == PowerStatus::Critical ) {
299 pa->alert( tr( "Battery level is critical!\n" 302 pa->alert( tr( "Battery level is critical!\n"
300 "Keep power off until power restored!" ), 1 ); 303 "Keep power off until power restored!" ), 1 );
301 } 304 }
302 305
303 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 306 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
304 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 307 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
305 } 308 }
306} 309}
307 310
308 311
309void DesktopApplication::sendCard() 312void DesktopApplication::sendCard()
310{ 313{
311 delete cardSendTimer; 314 delete cardSendTimer;
312 cardSendTimer = 0; 315 cardSendTimer = 0;
313 QString card = getenv("HOME"); 316 QString card = getenv("HOME");
314 card += "/Applications/addressbook/businesscard.vcf"; 317 card += "/Applications/addressbook/businesscard.vcf";
315 318
316 if ( QFile::exists( card ) ) { 319 if ( QFile::exists( card ) ) {
317 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 320 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
318 QString mimetype = "text/x-vCard"; 321 QString mimetype = "text/x-vCard";
319 e << tr("business card") << card << mimetype; 322 e << tr("business card") << card << mimetype;
320 } 323 }
321} 324}
322 325
323#if defined(QPE_HAVE_MEMALERTER) 326#if defined(QPE_HAVE_MEMALERTER)
324QPE_MEMALERTER_IMPL 327QPE_MEMALERTER_IMPL
325#endif 328#endif
326 329
327#if defined(CUSTOM_SOUND_IMPL) 330#if defined(CUSTOM_SOUND_IMPL)
328CUSTOM_SOUND_IMPL 331CUSTOM_SOUND_IMPL
329#endif 332#endif
330 333
331//=========================================================================== 334//===========================================================================
332 335
333Desktop::Desktop() : 336Desktop::Desktop() :
334 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 337 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
335 qcopBridge( 0 ), 338 qcopBridge( 0 ),
336 transferServer( 0 ), 339 transferServer( 0 ),
337 packageSlave( 0 ) 340 packageSlave( 0 )
338{ 341{
339#ifdef CUSTOM_SOUND_INIT 342#ifdef CUSTOM_SOUND_INIT
340 CUSTOM_SOUND_INIT; 343 CUSTOM_SOUND_INIT;
341#endif 344#endif
342 345
343 qpedesktop = this; 346 qpedesktop = this;
344 347
diff --git a/core/launcher/launcher.pro b/core/launcher/launcher.pro
index c77da50..f94f338 100644
--- a/core/launcher/launcher.pro
+++ b/core/launcher/launcher.pro
@@ -16,108 +16,108 @@ HEADERS = background.h \
16 stabmon.h \ 16 stabmon.h \
17 inputmethods.h \ 17 inputmethods.h \
18 systray.h \ 18 systray.h \
19 wait.h \ 19 wait.h \
20 shutdownimpl.h \ 20 shutdownimpl.h \
21 launcher.h \ 21 launcher.h \
22 launcherview.h \ 22 launcherview.h \
23 ../calibrate/calibrate.h \ 23 ../calibrate/calibrate.h \
24 startmenu.h \ 24 startmenu.h \
25 transferserver.h \ 25 transferserver.h \
26 qcopbridge.h \ 26 qcopbridge.h \
27 packageslave.h \ 27 packageslave.h \
28 irserver.h \ 28 irserver.h \
29 $(OPIEDIR)/rsync/buf.h \ 29 $(OPIEDIR)/rsync/buf.h \
30 $(OPIEDIR)/rsync/checksum.h \ 30 $(OPIEDIR)/rsync/checksum.h \
31 $(OPIEDIR)/rsync/command.h \ 31 $(OPIEDIR)/rsync/command.h \
32 $(OPIEDIR)/rsync/emit.h \ 32 $(OPIEDIR)/rsync/emit.h \
33 $(OPIEDIR)/rsync/job.h \ 33 $(OPIEDIR)/rsync/job.h \
34 $(OPIEDIR)/rsync/netint.h \ 34 $(OPIEDIR)/rsync/netint.h \
35 $(OPIEDIR)/rsync/protocol.h \ 35 $(OPIEDIR)/rsync/protocol.h \
36 $(OPIEDIR)/rsync/prototab.h \ 36 $(OPIEDIR)/rsync/prototab.h \
37 $(OPIEDIR)/rsync/rsync.h \ 37 $(OPIEDIR)/rsync/rsync.h \
38 $(OPIEDIR)/rsync/search.h \ 38 $(OPIEDIR)/rsync/search.h \
39 $(OPIEDIR)/rsync/stream.h \ 39 $(OPIEDIR)/rsync/stream.h \
40 $(OPIEDIR)/rsync/sumset.h \ 40 $(OPIEDIR)/rsync/sumset.h \
41 $(OPIEDIR)/rsync/trace.h \ 41 $(OPIEDIR)/rsync/trace.h \
42 $(OPIEDIR)/rsync/types.h \ 42 $(OPIEDIR)/rsync/types.h \
43 $(OPIEDIR)/rsync/util.h \ 43 $(OPIEDIR)/rsync/util.h \
44 $(OPIEDIR)/rsync/whole.h \ 44 $(OPIEDIR)/rsync/whole.h \
45 $(OPIEDIR)/rsync/config_rsync.h \ 45 $(OPIEDIR)/rsync/config_rsync.h \
46 $(OPIEDIR)/rsync/qrsync.h 46 $(OPIEDIR)/rsync/qrsync.h
47 # quicklauncher.h \ 47 # quicklauncher.h \
48 48
49 SOURCES = background.cpp \ 49 SOURCES = background.cpp \
50 desktop.cpp \ 50 desktop.cpp \
51 mediummountgui.cpp \ 51 mediummountgui.cpp \
52 qprocess.cpp qprocess_unix.cpp \ 52 qprocess.cpp qprocess_unix.cpp \
53 info.cpp \ 53 info.cpp \
54 appicons.cpp \ 54 appicons.cpp \
55 taskbar.cpp \ 55 taskbar.cpp \
56 sidething.cpp \ 56 sidething.cpp \
57 mrulist.cpp \ 57 mrulist.cpp \
58 stabmon.cpp \ 58 stabmon.cpp \
59 inputmethods.cpp \ 59 inputmethods.cpp \
60 systray.cpp \ 60 systray.cpp \
61 wait.cpp \ 61 wait.cpp \
62 shutdownimpl.cpp \ 62 shutdownimpl.cpp \
63 launcher.cpp \ 63 launcher.cpp \
64 launcherview.cpp \ 64 launcherview.cpp \
65 $(OPIEDIR)/calibrate/calibrate.cpp \ 65 $(OPIEDIR)/calibrate/calibrate.cpp \
66 transferserver.cpp \ 66 transferserver.cpp \
67 packageslave.cpp \ 67 packageslave.cpp \
68 irserver.cpp \ 68 irserver.cpp \
69 qcopbridge.cpp \ 69 qcopbridge.cpp \
70 startmenu.cpp \ 70 startmenu.cpp \
71 main.cpp \ 71 main.cpp \
72 $(OPIEDIR)/rsync/base64.c \ 72 $(OPIEDIR)/rsync/base64.c \
73 $(OPIEDIR)/rsync/buf.c \ 73 $(OPIEDIR)/rsync/buf.c \
74 $(OPIEDIR)/rsync/checksum.c \ 74 $(OPIEDIR)/rsync/checksum.c \
75 $(OPIEDIR)/rsync/command.c \ 75 $(OPIEDIR)/rsync/command.c \
76 $(OPIEDIR)/rsync/delta.c \ 76 $(OPIEDIR)/rsync/delta.c \
77 $(OPIEDIR)/rsync/emit.c \ 77 $(OPIEDIR)/rsync/emit.c \
78 $(OPIEDIR)/rsync/hex.c \ 78 $(OPIEDIR)/rsync/hex.c \
79 $(OPIEDIR)/rsync/job.c \ 79 $(OPIEDIR)/rsync/job.c \
80 $(OPIEDIR)/rsync/mdfour.c \ 80 $(OPIEDIR)/rsync/mdfour.c \
81 $(OPIEDIR)/rsync/mksum.c \ 81 $(OPIEDIR)/rsync/mksum.c \
82 $(OPIEDIR)/rsync/msg.c \ 82 $(OPIEDIR)/rsync/msg.c \
83 $(OPIEDIR)/rsync/netint.c \ 83 $(OPIEDIR)/rsync/netint.c \
84 $(OPIEDIR)/rsync/patch.c \ 84 $(OPIEDIR)/rsync/patch.c \
85 $(OPIEDIR)/rsync/prototab.c \ 85 $(OPIEDIR)/rsync/prototab.c \
86 $(OPIEDIR)/rsync/readsums.c \ 86 $(OPIEDIR)/rsync/readsums.c \
87 $(OPIEDIR)/rsync/scoop.c \ 87 $(OPIEDIR)/rsync/scoop.c \
88 $(OPIEDIR)/rsync/search.c \ 88 $(OPIEDIR)/rsync/search.c \
89 $(OPIEDIR)/rsync/stats.c \ 89 $(OPIEDIR)/rsync/stats.c \
90 $(OPIEDIR)/rsync/stream.c \ 90 $(OPIEDIR)/rsync/stream.c \
91 $(OPIEDIR)/rsync/sumset.c \ 91 $(OPIEDIR)/rsync/sumset.c \
92 $(OPIEDIR)/rsync/trace.c \ 92 $(OPIEDIR)/rsync/trace.c \
93 $(OPIEDIR)/rsync/tube.c \ 93 $(OPIEDIR)/rsync/tube.c \
94 $(OPIEDIR)/rsync/util.c \ 94 $(OPIEDIR)/rsync/util.c \
95 $(OPIEDIR)/rsync/version.c \ 95 $(OPIEDIR)/rsync/version.c \
96 $(OPIEDIR)/rsync/whole.c \ 96 $(OPIEDIR)/rsync/whole.c \
97 $(OPIEDIR)/rsync/qrsync.cpp 97 $(OPIEDIR)/rsync/qrsync.cpp
98 98
99 INTERFACES= shutdown.ui syncdialog.ui 99 INTERFACES= shutdown.ui syncdialog.ui
100 100
101INCLUDEPATH += $(OPIEDIR)/include 101INCLUDEPATH += $(OPIEDIR)/include
102 DEPENDPATH+= $(OPIEDIR)/include . 102 DEPENDPATH+= $(OPIEDIR)/include .
103 103
104INCLUDEPATH += $(OPIEDIR)/calibrate 104INCLUDEPATH += $(OPIEDIR)/calibrate
105 DEPENDPATH+= $(OPIEDIR)/calibrate 105 DEPENDPATH+= $(OPIEDIR)/calibrate
106 106
107INCLUDEPATH += $(OPIEDIR)/rsync 107INCLUDEPATH += $(OPIEDIR)/rsync
108 DEPENDPATH+= $(OPIEDIR)/rsync 108 DEPENDPATH+= $(OPIEDIR)/rsync
109 109
110 TARGET = qpe 110 TARGET = qpe
111 111
112 LIBS += -lqpe -lcrypt 112 LIBS += -lqpe -lcrypt -lopie
113 113
114TRANSLATIONS = ../i18n/de/qpe.ts 114TRANSLATIONS = ../i18n/de/qpe.ts
115TRANSLATIONS += ../i18n/pt_BR/qpe.ts 115TRANSLATIONS += ../i18n/pt_BR/qpe.ts
116TRANSLATIONS += ../i18n/en/qpe.ts 116TRANSLATIONS += ../i18n/en/qpe.ts
117TRANSLATIONS += ../i18n/hu/qpe.ts 117TRANSLATIONS += ../i18n/hu/qpe.ts
118TRANSLATIONS += ../i18n/ja/qpe.ts 118TRANSLATIONS += ../i18n/ja/qpe.ts
119TRANSLATIONS += ../i18n/fr/qpe.ts 119TRANSLATIONS += ../i18n/fr/qpe.ts
120TRANSLATIONS += ../i18n/ko/qpe.ts 120TRANSLATIONS += ../i18n/ko/qpe.ts
121TRANSLATIONS += ../i18n/no/qpe.ts 121TRANSLATIONS += ../i18n/no/qpe.ts
122TRANSLATIONS += ../i18n/zh_CN/qpe.ts 122TRANSLATIONS += ../i18n/zh_CN/qpe.ts
123TRANSLATIONS += ../i18n/zh_TW/qpe.ts 123TRANSLATIONS += ../i18n/zh_TW/qpe.ts
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index fc6d829..347eee9 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -1,276 +1,367 @@
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 <qfile.h> 32#include <qfile.h>
33#include <qwindowsystem_qws.h> 33#include <qwindowsystem_qws.h>
34#include <qpe/qcopenvelope_qws.h> 34#include <qpe/qcopenvelope_qws.h>
35#include <qpe/alarmserver.h> 35#include <qpe/alarmserver.h>
36 36
37#include <opie/ohwinfo.h>
38
37#include <stdlib.h> 39#include <stdlib.h>
38#include <stdio.h> 40#include <stdio.h>
39#include <signal.h> 41#include <signal.h>
40#include <unistd.h> 42#include <unistd.h>
41 43
42#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 44#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
43#include "../calibrate/calibrate.h" 45#include "../calibrate/calibrate.h"
44#endif 46#endif
45 47
46#ifdef QT_QWS_LOGIN 48#ifdef QT_QWS_LOGIN
47#include "../login/qdmdialogimpl.h" 49#include "../login/qdmdialogimpl.h"
48#endif 50#endif
49 51
50#ifdef QT_QWS_CASSIOPEIA 52#ifdef QT_QWS_CASSIOPEIA
51static void ignoreMessage( QtMsgType, const char * ) 53static void ignoreMessage( QtMsgType, const char * )
52{ 54{
53} 55}
54#include <sys/mount.h> 56#include <sys/mount.h>
55#include <sys/types.h> 57#include <sys/types.h>
56#include <sys/stat.h> 58#include <sys/stat.h>
57#include <sys/time.h> 59#include <sys/time.h>
58#include <fcntl.h> 60#include <fcntl.h>
59#include <qdatetime.h> 61#include <qdatetime.h>
60 62
61void initCassiopeia() 63void initCassiopeia()
62{ 64{
63 // MIPSEL-specific init - make sure /proc exists for shm 65 // MIPSEL-specific init - make sure /proc exists for shm
64/* 66/*
65 if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) { 67 if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) {
66 perror("Remounting - / read/write"); 68 perror("Remounting - / read/write");
67 } 69 }
68*/ 70*/
69 if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) { 71 if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) {
70 perror("mounting ramfs /tmp"); 72 perror("mounting ramfs /tmp");
71 } else { 73 } else {
72 fprintf( stderr, "mounted /tmp\n" ); 74 fprintf( stderr, "mounted /tmp\n" );
73 } 75 }
74 if ( mount("none", "/home", "ramfs", 0, 0 ) ) { 76 if ( mount("none", "/home", "ramfs", 0, 0 ) ) {
75 perror("mounting ramfs /home"); 77 perror("mounting ramfs /home");
76 } else { 78 } else {
77 fprintf( stderr, "mounted /home\n" ); 79 fprintf( stderr, "mounted /home\n" );
78 } 80 }
79 if ( mount("none","/proc","proc",0,0) ) { 81 if ( mount("none","/proc","proc",0,0) ) {
80 perror("Mounting - /proc"); 82 perror("Mounting - /proc");
81 } else { 83 } else {
82 fprintf( stderr, "mounted /proc\n" ); 84 fprintf( stderr, "mounted /proc\n" );
83 } 85 }
84 if ( mount("none","/mnt","shm",0,0) ) { 86 if ( mount("none","/mnt","shm",0,0) ) {
85 perror("Mounting - shm"); 87 perror("Mounting - shm");
86 } 88 }
87 setenv( "QTDIR", "/", 1 ); 89 setenv( "QTDIR", "/", 1 );
88 setenv( "OPIEDIR", "/", 1 ); 90 setenv( "OPIEDIR", "/", 1 );
89 setenv( "HOME", "/home", 1 ); 91 setenv( "HOME", "/home", 1 );
90 mkdir( "/home/Documents", 0755 ); 92 mkdir( "/home/Documents", 0755 );
91 93
92 // set a reasonable starting date 94 // set a reasonable starting date
93 QDateTime dt( QDate( 2001, 3, 15 ) ); 95 QDateTime dt( QDate( 2001, 3, 15 ) );
94 QDateTime now = QDateTime::currentDateTime(); 96 QDateTime now = QDateTime::currentDateTime();
95 int change = now.secsTo( dt ); 97 int change = now.secsTo( dt );
96 98
97 time_t t = ::time(0); 99 time_t t = ::time(0);
98 t += change; 100 t += change;
99 stime(&t); 101 stime(&t);
100 102
101 qInstallMsgHandler(ignoreMessage); 103 qInstallMsgHandler(ignoreMessage);
102} 104}
103#endif 105#endif
104 106
105#ifdef QPE_OWNAPM 107#ifdef QPE_OWNAPM
106#include <sys/ioctl.h> 108#include <sys/ioctl.h>
107#include <sys/types.h> 109#include <sys/types.h>
108#include <fcntl.h> 110#include <fcntl.h>
109#include <unistd.h> 111#include <unistd.h>
110#include <errno.h> 112#include <errno.h>
111#include <linux/ioctl.h> 113#include <linux/ioctl.h>
112#include <qpe/global.h> 114#include <qpe/global.h>
113 115
114static void disableAPM() 116static void disableAPM()
115{ 117{
116 118
117 int fd, cur_val, ret; 119 int fd, cur_val, ret;
118 char *device = "/dev/apm_bios"; 120 char *device = "/dev/apm_bios";
119 121
120 fd = open (device, O_WRONLY); 122 fd = open (device, O_WRONLY);
121 123
122 if (fd == -1) { 124 if (fd == -1) {
123 perror(device); 125 perror(device);
124 return; 126 return;
125 } 127 }
126 128
127 cur_val = ioctl(fd, APM_IOCGEVTSRC, 0); 129 cur_val = ioctl(fd, APM_IOCGEVTSRC, 0);
128 if (cur_val == -1) { 130 if (cur_val == -1) {
129 perror("ioctl"); 131 perror("ioctl");
130 exit(errno); 132 exit(errno);
131 } 133 }
132 134
133 ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON); 135 ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON);
134 if (ret == -1) { 136 if (ret == -1) {
135 perror("ioctl"); 137 perror("ioctl");
136 return; 138 return;
137 } 139 }
138 close(fd); 140 close(fd);
139} 141}
140 142
141static void initAPM() 143static void initAPM()
142{ 144{
143 // So that we have to do it ourself, but better. 145 // So that we have to do it ourself, but better.
144 disableAPM(); 146 disableAPM();
145} 147}
146#endif 148#endif
147 149
148#ifdef QT_DEMO_SINGLE_FLOPPY 150#ifdef QT_DEMO_SINGLE_FLOPPY
149#include <sys/mount.h> 151#include <sys/mount.h>
150 152
151void initFloppy() 153void initFloppy()
152{ 154{
153 mount("none","/proc","proc",0,0); 155 mount("none","/proc","proc",0,0);
154 setenv( "QTDIR", "/", 0 ); 156 setenv( "QTDIR", "/", 0 );
155 setenv( "HOME", "/root", 0 ); 157 setenv( "HOME", "/root", 0 );
156 setenv( "QWS_SIZE", "240x320", 0 ); 158 setenv( "QWS_SIZE", "240x320", 0 );
157} 159}
158#endif 160#endif
159 161
160 162
161void initEnvironment() 163void initEnvironment()
162{ 164{
163 Config config("locale"); 165 Config config("locale");
164 config.setGroup( "Location" ); 166 config.setGroup( "Location" );
165 QString tz = config.readEntry( "Timezone", getenv("TZ") ); 167 QString tz = config.readEntry( "Timezone", getenv("TZ") );
166 168
167 // if not timezone set, pick New York 169 // if not timezone set, pick New York
168 if (tz.isNull()) 170 if (tz.isNull())
169 tz = "America/New_York"; 171 tz = "America/New_York";
170 172
171 setenv( "TZ", tz, 1 ); 173 setenv( "TZ", tz, 1 );
172 config.writeEntry( "Timezone", tz); 174 config.writeEntry( "Timezone", tz);
173 175
174 config.setGroup( "Language" ); 176 config.setGroup( "Language" );
175 QString lang = config.readEntry( "Language", getenv("LANG") ); 177 QString lang = config.readEntry( "Language", getenv("LANG") );
176 if ( !lang.isNull() ) 178 if ( !lang.isNull() )
177 setenv( "LANG", lang, 1 ); 179 setenv( "LANG", lang, 1 );
178} 180}
179 181
180static void initBacklight() 182static void initBacklight()
181{ 183{
182 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 184 QCopEnvelope e("QPE/System", "setBacklight(int)" );
183 e << -3; // Forced on 185 e << -3; // Forced on
184} 186}
185 187
186 188
189class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter
190{
191public:
192 ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" )
193 {
194 bool doinst = false;
195
196 m_model = OHwInfo::inst ( )-> model ( );
197 m_power_timer = 0;
198
199 switch ( m_model ) {
200 case OMODEL_iPAQ_H31xx:
201 case OMODEL_iPAQ_H36xx:
202 case OMODEL_iPAQ_H37xx:
203 case OMODEL_iPAQ_H38xx: doinst = true;
204 break;
205 default : break;
206 }
207 if ( doinst )
208 QWSServer::setKeyboardFilter ( this );
209 }
210
211 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat )
212 {
213 bool kill = false;
214
215 // Rotate cursor keys 180°
216 switch ( m_model ) {
217 case OMODEL_iPAQ_H31xx:
218 case OMODEL_iPAQ_H38xx: {
219 int newkeycode = keycode;
220
221 switch ( keycode ) {
222 case Key_Left : newkeycode = Key_Right; break;
223 case Key_Right: newkeycode = Key_Left; break;
224 case Key_Up : newkeycode = Key_Down; break;
225 case Key_Down : newkeycode = Key_Up; break;
226 }
227 if ( newkeycode != keycode ) {
228 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
229 kill = true;
230 }
231 break;
232 }
233 default: break;
234 }
235
236 // map Power Button short/long press to F34/F35
237 switch ( m_model ) {
238 case OMODEL_iPAQ_H31xx:
239 case OMODEL_iPAQ_H36xx:
240 case OMODEL_iPAQ_H37xx:
241 case OMODEL_iPAQ_H38xx: {
242 if ( keycode == Key_SysReq ) {
243 if ( isPress ) {
244 m_power_timer = startTimer ( 500 );
245 }
246 else if ( m_power_timer ) {
247 killTimer ( m_power_timer );
248 m_power_timer = 0;
249 QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false );
250 QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false );
251 }
252 kill = true;
253 }
254 break;
255 }
256 default: break;
257 }
258 return kill;
259 }
260
261 virtual void timerEvent ( QTimerEvent * )
262 {
263 killTimer ( m_power_timer );
264 m_power_timer = 0;
265 QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false );
266 QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false );
267 }
268
269private:
270 OHwModel m_model;
271 bool m_power_press;
272 int m_power_timer;
273};
274
275
187 276
188int initApplication( int argc, char ** argv ) 277int initApplication( int argc, char ** argv )
189{ 278{
190#ifdef QT_QWS_CASSIOPEIA 279#ifdef QT_QWS_CASSIOPEIA
191 initCassiopeia(); 280 initCassiopeia();
192#endif 281#endif
193 282
194#ifdef QPE_OWNAPM 283#ifdef QPE_OWNAPM
195 initAPM(); 284 initAPM();
196#endif 285#endif
197 286
198#ifdef QT_DEMO_SINGLE_FLOPPY 287#ifdef QT_DEMO_SINGLE_FLOPPY
199 initFloppy(); 288 initFloppy();
200#endif 289#endif
201 290
202 initEnvironment(); 291 initEnvironment();
203 292
204#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) 293#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX)
205 setenv( "QWS_SIZE", "240x320", 0 ); 294 setenv( "QWS_SIZE", "240x320", 0 );
206#endif 295#endif
207 296
208 //Don't flicker at startup: 297 //Don't flicker at startup:
209 QWSServer::setDesktopBackground( QImage() ); 298 QWSServer::setDesktopBackground( QImage() );
210 DesktopApplication a( argc, argv, QApplication::GuiServer ); 299 DesktopApplication a( argc, argv, QApplication::GuiServer );
211 300
301 (void) new ModelKeyFilter ( );
302
212 initBacklight(); 303 initBacklight();
213 304
214 AlarmServer::initialize(); 305 AlarmServer::initialize();
215 306
216#if defined(QT_QWS_LOGIN) 307#if defined(QT_QWS_LOGIN)
217 for( int i=0; i<a.argc(); i++ ) 308 for( int i=0; i<a.argc(); i++ )
218 if( strcmp( a.argv()[i], "-login" ) == 0 ) { 309 if( strcmp( a.argv()[i], "-login" ) == 0 ) {
219 QDMDialogImpl::login( ); 310 QDMDialogImpl::login( );
220 return 0; 311 return 0;
221 } 312 }
222#endif 313#endif
223 314
224 Desktop *d = new Desktop(); 315 Desktop *d = new Desktop();
225 316
226 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); 317 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) );
227 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); 318 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) );
228 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); 319 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) );
229 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); 320 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) );
230 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); 321 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) );
231 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); 322 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) );
232 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); 323 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) );
233 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); 324 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) );
234 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); 325 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) );
235 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); 326 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) );
236 327
237 (void)new SysFileMonitor(d); 328 (void)new SysFileMonitor(d);
238 Network::createServer(d); 329 Network::createServer(d);
239 330
240#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 331#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
241 if ( !QFile::exists( "/etc/pointercal" ) ) { 332 if ( !QFile::exists( "/etc/pointercal" ) ) {
242 // Make sure calibration widget starts on top. 333 // Make sure calibration widget starts on top.
243 Calibrate *cal = new Calibrate; 334 Calibrate *cal = new Calibrate;
244 cal->exec(); 335 cal->exec();
245 delete cal; 336 delete cal;
246 } 337 }
247#endif 338#endif
248 339
249 d->show(); 340 d->show();
250 341
251 int rv = a.exec(); 342 int rv = a.exec();
252 343
253 delete d; 344 delete d;
254 345
255 return rv; 346 return rv;
256} 347}
257 348
258int main( int argc, char ** argv ) 349int main( int argc, char ** argv )
259{ 350{
260#ifndef SINGLE_APP 351#ifndef SINGLE_APP
261 signal( SIGCHLD, SIG_IGN ); 352 signal( SIGCHLD, SIG_IGN );
262#endif 353#endif
263 354
264 int retVal = initApplication( argc, argv ); 355 int retVal = initApplication( argc, argv );
265 356
266#ifndef SINGLE_APP 357#ifndef SINGLE_APP
267 // Kill them. Kill them all. 358 // Kill them. Kill them all.
268 setpgid( getpid(), getppid() ); 359 setpgid( getpid(), getppid() );
269 killpg( getpid(), SIGTERM ); 360 killpg( getpid(), SIGTERM );
270 sleep( 1 ); 361 sleep( 1 );
271 killpg( getpid(), SIGKILL ); 362 killpg( getpid(), SIGKILL );
272#endif 363#endif
273 364
274 return retVal; 365 return retVal;
275} 366}
276 367