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
@@ -1,793 +1,796 @@
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 <qgfx_qws.h> 46#include <qgfx_qws.h>
47#include <qmainwindow.h> 47#include <qmainwindow.h>
48#include <qmessagebox.h> 48#include <qmessagebox.h>
49#include <qtimer.h> 49#include <qtimer.h>
50#include <qwindowsystem_qws.h> 50#include <qwindowsystem_qws.h>
51 51
52#include <qvaluelist.h> 52#include <qvaluelist.h>
53 53
54#include <stdlib.h> 54#include <stdlib.h>
55#include <unistd.h> 55#include <unistd.h>
56 56
57class QCopKeyRegister 57class QCopKeyRegister
58{ 58{
59public: 59public:
60 QCopKeyRegister() : keyCode(0) { } 60 QCopKeyRegister() : keyCode(0) { }
61 QCopKeyRegister(int k, const QString &c, const QString &m) 61 QCopKeyRegister(int k, const QString &c, const QString &m)
62 : keyCode(k), channel(c), message(m) { } 62 : keyCode(k), channel(c), message(m) { }
63 63
64 int getKeyCode() const { return keyCode; } 64 int getKeyCode() const { return keyCode; }
65 QString getChannel() const { return channel; } 65 QString getChannel() const { return channel; }
66 QString getMessage() const { return message; } 66 QString getMessage() const { return message; }
67 67
68private: 68private:
69 int keyCode; 69 int keyCode;
70 QString channel, message; 70 QString channel, message;
71}; 71};
72 72
73typedef QValueList<QCopKeyRegister> KeyRegisterList; 73typedef QValueList<QCopKeyRegister> KeyRegisterList;
74KeyRegisterList keyRegisterList; 74KeyRegisterList keyRegisterList;
75 75
76static Desktop* qpedesktop = 0; 76static Desktop* qpedesktop = 0;
77static int loggedin=0; 77static int loggedin=0;
78static void login(bool at_poweron) 78static void login(bool at_poweron)
79{ 79{
80 if ( !loggedin ) { 80 if ( !loggedin ) {
81 Global::terminateBuiltin("calibrate"); 81 Global::terminateBuiltin("calibrate");
82 Password::authenticate(at_poweron); 82 Password::authenticate(at_poweron);
83 loggedin=1; 83 loggedin=1;
84 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 84 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
85 } 85 }
86} 86}
87 87
88bool Desktop::screenLocked() 88bool Desktop::screenLocked()
89{ 89{
90 return loggedin == 0; 90 return loggedin == 0;
91} 91}
92 92
93/* 93/*
94 Priority is number of alerts that are needed to pop up 94 Priority is number of alerts that are needed to pop up
95 alert. 95 alert.
96 */ 96 */
97class DesktopPowerAlerter : public QMessageBox 97class DesktopPowerAlerter : public QMessageBox
98{ 98{
99public: 99public:
100 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 100 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
101 : QMessageBox( tr("Battery Status"), "Low Battery", 101 : QMessageBox( tr("Battery Status"), "Low Battery",
102 QMessageBox::Critical, 102 QMessageBox::Critical,
103 QMessageBox::Ok | QMessageBox::Default, 103 QMessageBox::Ok | QMessageBox::Default,
104 QMessageBox::NoButton, QMessageBox::NoButton, 104 QMessageBox::NoButton, QMessageBox::NoButton,
105 parent, name, FALSE ) 105 parent, name, FALSE )
106 { 106 {
107 currentPriority = INT_MAX; 107 currentPriority = INT_MAX;
108 alertCount = 0; 108 alertCount = 0;
109 } 109 }
110 110
111 void alert( const QString &text, int priority ); 111 void alert( const QString &text, int priority );
112 void hideEvent( QHideEvent * ); 112 void hideEvent( QHideEvent * );
113private: 113private:
114 int currentPriority; 114 int currentPriority;
115 int alertCount; 115 int alertCount;
116}; 116};
117 117
118void DesktopPowerAlerter::alert( const QString &text, int priority ) 118void DesktopPowerAlerter::alert( const QString &text, int priority )
119{ 119{
120 alertCount++; 120 alertCount++;
121 if ( alertCount < priority ) 121 if ( alertCount < priority )
122 return; 122 return;
123 if ( priority > currentPriority ) 123 if ( priority > currentPriority )
124 return; 124 return;
125 currentPriority = priority; 125 currentPriority = priority;
126 setText( text ); 126 setText( text );
127 show(); 127 show();
128} 128}
129 129
130 130
131void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 131void DesktopPowerAlerter::hideEvent( QHideEvent *e )
132{ 132{
133 QMessageBox::hideEvent( e ); 133 QMessageBox::hideEvent( e );
134 alertCount = 0; 134 alertCount = 0;
135 currentPriority = INT_MAX; 135 currentPriority = INT_MAX;
136} 136}
137 137
138 138
139 139
140DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 140DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
141 : QPEApplication( argc, argv, appType ) 141 : QPEApplication( argc, argv, appType )
142{ 142{
143 143
144 QTimer *t = new QTimer( this ); 144 QTimer *t = new QTimer( this );
145 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 145 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
146 t->start( 10000 ); 146 t->start( 10000 );
147 ps = new PowerStatus; 147 ps = new PowerStatus;
148 pa = new DesktopPowerAlerter( 0 ); 148 pa = new DesktopPowerAlerter( 0 );
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
345// bg = new Info( this ); 348// bg = new Info( this );
346 tb = new TaskBar; 349 tb = new TaskBar;
347 350
348 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 351 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
349 352
350 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 353 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
351 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 354 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
352 355
353 int displayw = qApp->desktop()->width(); 356 int displayw = qApp->desktop()->width();
354 int displayh = qApp->desktop()->height(); 357 int displayh = qApp->desktop()->height();
355 358
356 359
357 QSize sz = tb->sizeHint(); 360 QSize sz = tb->sizeHint();
358 361
359 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 362 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
360 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 363 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
361 364
362 tb->show(); 365 tb->show();
363 launcher->showMaximized(); 366 launcher->showMaximized();
364 launcher->show(); 367 launcher->show();
365 launcher->raise(); 368 launcher->raise();
366#if defined(QPE_HAVE_MEMALERTER) 369#if defined(QPE_HAVE_MEMALERTER)
367 initMemalerter(); 370 initMemalerter();
368#endif 371#endif
369 // start services 372 // start services
370 startTransferServer(); 373 startTransferServer();
371 (void) new IrServer( this ); 374 (void) new IrServer( this );
372 rereadVolumes(); 375 rereadVolumes();
373 376
374 packageSlave = new PackageSlave( this ); 377 packageSlave = new PackageSlave( this );
375 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 378 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
376 379
377 qApp->installEventFilter( this ); 380 qApp->installEventFilter( this );
378} 381}
379 382
380void Desktop::show() 383void Desktop::show()
381{ 384{
382 login(TRUE); 385 login(TRUE);
383 QWidget::show(); 386 QWidget::show();
384} 387}
385 388
386Desktop::~Desktop() 389Desktop::~Desktop()
387{ 390{
388 delete launcher; 391 delete launcher;
389 delete tb; 392 delete tb;
390 delete qcopBridge; 393 delete qcopBridge;
391 delete transferServer; 394 delete transferServer;
392} 395}
393 396
394bool Desktop::recoverMemory() 397bool Desktop::recoverMemory()
395{ 398{
396 return tb->recoverMemory(); 399 return tb->recoverMemory();
397} 400}
398 401
399void Desktop::checkMemory() 402void Desktop::checkMemory()
400{ 403{
401#if defined(QPE_HAVE_MEMALERTER) 404#if defined(QPE_HAVE_MEMALERTER)
402 static bool ignoreNormal=FALSE; 405 static bool ignoreNormal=FALSE;
403 static bool existingMessage=FALSE; 406 static bool existingMessage=FALSE;
404 407
405 if(existingMessage) 408 if(existingMessage)
406 return; // don't show a second message while still on first 409 return; // don't show a second message while still on first
407 410
408 existingMessage = TRUE; 411 existingMessage = TRUE;
409 switch ( memstate ) { 412 switch ( memstate ) {
410 case Unknown: 413 case Unknown:
411 break; 414 break;
412 case Low: 415 case Low:
413 memstate = Unknown; 416 memstate = Unknown;
414 if ( recoverMemory() ) 417 if ( recoverMemory() )
415 ignoreNormal = TRUE; 418 ignoreNormal = TRUE;
416 else 419 else
417 QMessageBox::warning( 0 , "Memory Status", 420 QMessageBox::warning( 0 , "Memory Status",
418 "The memory smacks of shortage. \n" 421 "The memory smacks of shortage. \n"
419 "Please save data. " ); 422 "Please save data. " );
420 break; 423 break;
421 case Normal: 424 case Normal:
422 memstate = Unknown; 425 memstate = Unknown;
423 if ( ignoreNormal ) 426 if ( ignoreNormal )
424 ignoreNormal = FALSE; 427 ignoreNormal = FALSE;
425 else 428 else
426 QMessageBox::information ( 0 , "Memory Status", 429 QMessageBox::information ( 0 , "Memory Status",
427 "There is enough memory again." ); 430 "There is enough memory again." );
428 break; 431 break;
429 case VeryLow: 432 case VeryLow:
430 memstate = Unknown; 433 memstate = Unknown;
431 QMessageBox::critical( 0 , "Memory Status", 434 QMessageBox::critical( 0 , "Memory Status",
432 "The memory is very low. \n" 435 "The memory is very low. \n"
433 "Please end this application \n" 436 "Please end this application \n"
434 "immediately." ); 437 "immediately." );
435 recoverMemory(); 438 recoverMemory();
436 } 439 }
437 existingMessage = FALSE; 440 existingMessage = FALSE;
438#endif 441#endif
439} 442}
440 443
441static bool isVisibleWindow(int wid) 444static bool isVisibleWindow(int wid)
442{ 445{
443 const QList<QWSWindow> &list = qwsServer->clientWindows(); 446 const QList<QWSWindow> &list = qwsServer->clientWindows();
444 QWSWindow* w; 447 QWSWindow* w;
445 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 448 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
446 if ( w->winId() == wid ) 449 if ( w->winId() == wid )
447 return !w->isFullyObscured(); 450 return !w->isFullyObscured();
448 } 451 }
449 return FALSE; 452 return FALSE;
450} 453}
451 454
452static bool hasVisibleWindow(const QString& clientname) 455static bool hasVisibleWindow(const QString& clientname)
453{ 456{
454 const QList<QWSWindow> &list = qwsServer->clientWindows(); 457 const QList<QWSWindow> &list = qwsServer->clientWindows();
455 QWSWindow* w; 458 QWSWindow* w;
456 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 459 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
457 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 460 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
458 return TRUE; 461 return TRUE;
459 } 462 }
460 return FALSE; 463 return FALSE;
461} 464}
462 465
463void Desktop::raiseLauncher() 466void Desktop::raiseLauncher()
464{ 467{
465 Config cfg("qpe"); //F12 'Home' 468 Config cfg("qpe"); //F12 'Home'
466 cfg.setGroup("AppsKey"); 469 cfg.setGroup("AppsKey");
467 QString tempItem; 470 QString tempItem;
468 tempItem = cfg.readEntry("Middle","Home"); 471 tempItem = cfg.readEntry("Middle","Home");
469 if(tempItem == "Home" || tempItem.isEmpty()) { 472 if(tempItem == "Home" || tempItem.isEmpty()) {
470 if ( isVisibleWindow(launcher->winId()) ) 473 if ( isVisibleWindow(launcher->winId()) )
471 launcher->nextView(); 474 launcher->nextView();
472 else 475 else
473 launcher->raise(); 476 launcher->raise();
474 } else { 477 } else {
475 QCopEnvelope e("QPE/System","execute(QString)"); 478 QCopEnvelope e("QPE/System","execute(QString)");
476 e << tempItem; 479 e << tempItem;
477 } 480 }
478} 481}
479 482
480void Desktop::executeOrModify(const QString& appLnkFile) 483void Desktop::executeOrModify(const QString& appLnkFile)
481{ 484{
482 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 485 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
483 if ( lnk.isValid() ) { 486 if ( lnk.isValid() ) {
484 QCString app = lnk.exec().utf8(); 487 QCString app = lnk.exec().utf8();
485 Global::terminateBuiltin("calibrate"); 488 Global::terminateBuiltin("calibrate");
486 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 489 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
487 MRUList::addTask(&lnk); 490 MRUList::addTask(&lnk);
488 if ( hasVisibleWindow(app) ) 491 if ( hasVisibleWindow(app) )
489 QCopChannel::send("QPE/Application/" + app, "nextView()"); 492 QCopChannel::send("QPE/Application/" + app, "nextView()");
490 else 493 else
491 QCopChannel::send("QPE/Application/" + app, "raise()"); 494 QCopChannel::send("QPE/Application/" + app, "raise()");
492 } else { 495 } else {
493 lnk.execute(); 496 lnk.execute();
494 } 497 }
495 } 498 }
496} 499}
497 500
498void Desktop::raiseDatebook() 501void Desktop::raiseDatebook()
499{ 502{
500 Config cfg("qpe"); //F9 'Activity' 503 Config cfg("qpe"); //F9 'Activity'
501 cfg.setGroup("AppsKey"); 504 cfg.setGroup("AppsKey");
502 QString tempItem; 505 QString tempItem;
503 tempItem = cfg.readEntry("LeftEnd","Calender"); 506 tempItem = cfg.readEntry("LeftEnd","Calender");
504 if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); 507 if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop");
505 else { 508 else {
506 QCopEnvelope e("QPE/System","execute(QString)"); 509 QCopEnvelope e("QPE/System","execute(QString)");
507 e << tempItem; 510 e << tempItem;
508 } 511 }
509} 512}
510 513
511void Desktop::raiseContacts() 514void Desktop::raiseContacts()
512{ 515{
513 Config cfg("qpe"); //F10, 'Contacts' 516 Config cfg("qpe"); //F10, 'Contacts'
514 cfg.setGroup("AppsKey"); 517 cfg.setGroup("AppsKey");
515 QString tempItem; 518 QString tempItem;
516 tempItem = cfg.readEntry("Left2nd","Address Book"); 519 tempItem = cfg.readEntry("Left2nd","Address Book");
517 if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); 520 if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop");
518 else { 521 else {
519 QCopEnvelope e("QPE/System","execute(QString)"); 522 QCopEnvelope e("QPE/System","execute(QString)");
520 e << tempItem; 523 e << tempItem;
521 } 524 }
522} 525}
523 526
524void Desktop::raiseMenu() 527void Desktop::raiseMenu()
525{ 528{
526 Config cfg("qpe"); //F11, 'Menu' 529 Config cfg("qpe"); //F11, 'Menu'
527 cfg.setGroup("AppsKey"); 530 cfg.setGroup("AppsKey");
528 QString tempItem; 531 QString tempItem;
529 tempItem = cfg.readEntry("Right2nd","Popup Menu"); 532 tempItem = cfg.readEntry("Right2nd","Popup Menu");
530 if(tempItem == "Popup Menu" || tempItem.isEmpty()) { 533 if(tempItem == "Popup Menu" || tempItem.isEmpty()) {
531 Global::terminateBuiltin("calibrate"); 534 Global::terminateBuiltin("calibrate");
532 tb->startMenu()->launch(); 535 tb->startMenu()->launch();
533 } else { 536 } else {
534 QCopEnvelope e("QPE/System","execute(QString)"); 537 QCopEnvelope e("QPE/System","execute(QString)");
535 e << tempItem; 538 e << tempItem;
536 } 539 }
537} 540}
538 541
539void Desktop::raiseEmail() 542void Desktop::raiseEmail()
540{ 543{
541 Config cfg("qpe"); //F13, 'Mail' 544 Config cfg("qpe"); //F13, 'Mail'
542 cfg.setGroup("AppsKey"); 545 cfg.setGroup("AppsKey");
543 QString tempItem; 546 QString tempItem;
544 tempItem = cfg.readEntry("RightEnd","Mail"); 547 tempItem = cfg.readEntry("RightEnd","Mail");
545 if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); 548 if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop");
546 else { 549 else {
547 QCopEnvelope e("QPE/System","execute(QString)"); 550 QCopEnvelope e("QPE/System","execute(QString)");
548 e << tempItem; 551 e << tempItem;
549 } 552 }
550} 553}
551 554
552// autoStarts apps on resume and start 555// autoStarts apps on resume and start
553void Desktop::execAutoStart() { 556void Desktop::execAutoStart() {
554 QString appName; 557 QString appName;
555 int delay; 558 int delay;
556 QDateTime now = QDateTime::currentDateTime(); 559 QDateTime now = QDateTime::currentDateTime();
557 Config cfg( "autostart" ); 560 Config cfg( "autostart" );
558 cfg.setGroup( "AutoStart" ); 561 cfg.setGroup( "AutoStart" );
559 appName = cfg.readEntry("Apps", ""); 562 appName = cfg.readEntry("Apps", "");
560 delay = (cfg.readEntry("Delay", "0" )).toInt(); 563 delay = (cfg.readEntry("Delay", "0" )).toInt();
561 // If the time between suspend and resume was longer then the 564 // If the time between suspend and resume was longer then the
562 // value saved as delay, start the app 565 // value saved as delay, start the app
563 if ( suspendTime.secsTo(now) >= (delay*60) ) { 566 if ( suspendTime.secsTo(now) >= (delay*60) ) {
564 QCopEnvelope e("QPE/System", "execute(QString)"); 567 QCopEnvelope e("QPE/System", "execute(QString)");
565 e << QString(appName); 568 e << QString(appName);
566 } else { 569 } else {
567 } 570 }
568} 571}
569 572
570#if defined(QPE_HAVE_TOGGLELIGHT) 573#if defined(QPE_HAVE_TOGGLELIGHT)
571#include <qpe/config.h> 574#include <qpe/config.h>
572 575
573#include <sys/ioctl.h> 576#include <sys/ioctl.h>
574#include <sys/types.h> 577#include <sys/types.h>
575#include <fcntl.h> 578#include <fcntl.h>
576#include <unistd.h> 579#include <unistd.h>
577#include <errno.h> 580#include <errno.h>
578#include <linux/ioctl.h> 581#include <linux/ioctl.h>
579#include <time.h> 582#include <time.h>
580#endif 583#endif
581 584
582static bool blanked=FALSE; 585static bool blanked=FALSE;
583 586
584static void blankScreen() 587static void blankScreen()
585{ 588{
586 if ( !qt_screen ) return; 589 if ( !qt_screen ) return;
587 /* Should use a big black window instead. 590 /* Should use a big black window instead.
588 QGfx* g = qt_screen->screenGfx(); 591 QGfx* g = qt_screen->screenGfx();
589 g->fillRect(0,0,qt_screen->width(),qt_screen->height()); 592 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
590 delete g; 593 delete g;
591 */ 594 */
592 blanked = TRUE; 595 blanked = TRUE;
593} 596}
594 597
595static void darkScreen() 598static void darkScreen()
596{ 599{
597 extern void qpe_setBacklight(int); 600 extern void qpe_setBacklight(int);
598 qpe_setBacklight(0); // force off 601 qpe_setBacklight(0); // force off
599} 602}
600 603
601 604
602void Desktop::togglePower() 605void Desktop::togglePower()
603{ 606{
604 bool wasloggedin = loggedin; 607 bool wasloggedin = loggedin;
605 loggedin=0; 608 loggedin=0;
606 suspendTime = QDateTime::currentDateTime(); 609 suspendTime = QDateTime::currentDateTime();
607 darkScreen(); 610 darkScreen();
608 if ( wasloggedin ) 611 if ( wasloggedin )
609 blankScreen(); 612 blankScreen();
610 613
611 system("apm --suspend"); 614 system("apm --suspend");
612 615
613 616
614 617
615 QWSServer::screenSaverActivate( FALSE ); 618 QWSServer::screenSaverActivate( FALSE );
616 { 619 {
617 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 620 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
618 QCopEnvelope e("QPE/System", "setBacklight(int)"); 621 QCopEnvelope e("QPE/System", "setBacklight(int)");
619 e << -3; // Force on 622 e << -3; // Force on
620 } 623 }
621 if ( wasloggedin ) { 624 if ( wasloggedin ) {
622 login(TRUE); 625 login(TRUE);
623 } 626 }
624 sleep(1); 627 sleep(1);
625 execAutoStart(); 628 execAutoStart();
626 //qcopBridge->closeOpenConnections(); 629 //qcopBridge->closeOpenConnections();
627 //qDebug("called togglePower()!!!!!!"); 630 //qDebug("called togglePower()!!!!!!");
628} 631}
629 632
630void Desktop::toggleLight() 633void Desktop::toggleLight()
631{ 634{
632 QCopEnvelope e("QPE/System", "setBacklight(int)"); 635 QCopEnvelope e("QPE/System", "setBacklight(int)");
633 e << -2; // toggle 636 e << -2; // toggle
634} 637}
635 638
636void Desktop::toggleSymbolInput() 639void Desktop::toggleSymbolInput()
637{ 640{
638 tb->toggleSymbolInput(); 641 tb->toggleSymbolInput();
639} 642}
640 643
641void Desktop::toggleNumLockState() 644void Desktop::toggleNumLockState()
642{ 645{
643 tb->toggleNumLockState(); 646 tb->toggleNumLockState();
644} 647}
645 648
646void Desktop::toggleCapsLockState() 649void Desktop::toggleCapsLockState()
647{ 650{
648 tb->toggleCapsLockState(); 651 tb->toggleCapsLockState();
649} 652}
650 653
651void Desktop::styleChange( QStyle &s ) 654void Desktop::styleChange( QStyle &s )
652{ 655{
653 QWidget::styleChange( s ); 656 QWidget::styleChange( s );
654 int displayw = qApp->desktop()->width(); 657 int displayw = qApp->desktop()->width();
655 int displayh = qApp->desktop()->height(); 658 int displayh = qApp->desktop()->height();
656 659
657 QSize sz = tb->sizeHint(); 660 QSize sz = tb->sizeHint();
658 661
659 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 662 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
660} 663}
661 664
662void DesktopApplication::shutdown() 665void DesktopApplication::shutdown()
663{ 666{
664 if ( type() != GuiServer ) 667 if ( type() != GuiServer )
665 return; 668 return;
666 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 669 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
667 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 670 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
668 this, SLOT(shutdown(ShutdownImpl::Type)) ); 671 this, SLOT(shutdown(ShutdownImpl::Type)) );
669 sd->showMaximized(); 672 sd->showMaximized();
670} 673}
671 674
672void DesktopApplication::shutdown( ShutdownImpl::Type t ) 675void DesktopApplication::shutdown( ShutdownImpl::Type t )
673{ 676{
674 switch ( t ) { 677 switch ( t ) {
675 case ShutdownImpl::ShutdownSystem: 678 case ShutdownImpl::ShutdownSystem:
676 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 679 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
677 break; 680 break;
678 case ShutdownImpl::RebootSystem: 681 case ShutdownImpl::RebootSystem:
679 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 682 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
680 break; 683 break;
681 case ShutdownImpl::RestartDesktop: 684 case ShutdownImpl::RestartDesktop:
682 restart(); 685 restart();
683 break; 686 break;
684 case ShutdownImpl::TerminateDesktop: 687 case ShutdownImpl::TerminateDesktop:
685 prepareForTermination(FALSE); 688 prepareForTermination(FALSE);
686 quit(); 689 quit();
687 break; 690 break;
688 } 691 }
689} 692}
690 693
691void DesktopApplication::restart() 694void DesktopApplication::restart()
692{ 695{
693 prepareForTermination(TRUE); 696 prepareForTermination(TRUE);
694 697
695#ifdef Q_WS_QWS 698#ifdef Q_WS_QWS
696 for ( int fd = 3; fd < 100; fd++ ) 699 for ( int fd = 3; fd < 100; fd++ )
697 close( fd ); 700 close( fd );
698#if defined(QT_DEMO_SINGLE_FLOPPY) 701#if defined(QT_DEMO_SINGLE_FLOPPY)
699 execl( "/sbin/init", "qpe", 0 ); 702 execl( "/sbin/init", "qpe", 0 );
700#elif defined(QT_QWS_CASSIOPEIA) 703#elif defined(QT_QWS_CASSIOPEIA)
701 execl( "/bin/sh", "sh", 0 ); 704 execl( "/bin/sh", "sh", 0 );
702#else 705#else
703 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 706 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
704#endif 707#endif
705 exit(1); 708 exit(1);
706#endif 709#endif
707} 710}
708 711
709void Desktop::startTransferServer() 712void Desktop::startTransferServer()
710{ 713{
711 // start qcop bridge server 714 // start qcop bridge server
712 qcopBridge = new QCopBridge( 4243 ); 715 qcopBridge = new QCopBridge( 4243 );
713 if ( !qcopBridge->ok() ) { 716 if ( !qcopBridge->ok() ) {
714 delete qcopBridge; 717 delete qcopBridge;
715 qcopBridge = 0; 718 qcopBridge = 0;
716 } 719 }
717 // start transfer server 720 // start transfer server
718 transferServer = new TransferServer( 4242 ); 721 transferServer = new TransferServer( 4242 );
719 if ( !transferServer->ok() ) { 722 if ( !transferServer->ok() ) {
720 delete transferServer; 723 delete transferServer;
721 transferServer = 0; 724 transferServer = 0;
722 } 725 }
723 if ( !transferServer || !qcopBridge ) 726 if ( !transferServer || !qcopBridge )
724 startTimer( 2000 ); 727 startTimer( 2000 );
725} 728}
726 729
727void Desktop::timerEvent( QTimerEvent *e ) 730void Desktop::timerEvent( QTimerEvent *e )
728{ 731{
729 killTimer( e->timerId() ); 732 killTimer( e->timerId() );
730 startTransferServer(); 733 startTransferServer();
731} 734}
732 735
733void Desktop::terminateServers() 736void Desktop::terminateServers()
734{ 737{
735 delete transferServer; 738 delete transferServer;
736 delete qcopBridge; 739 delete qcopBridge;
737 transferServer = 0; 740 transferServer = 0;
738 qcopBridge = 0; 741 qcopBridge = 0;
739} 742}
740 743
741void Desktop::rereadVolumes() 744void Desktop::rereadVolumes()
742{ 745{
743 Config cfg("qpe"); 746 Config cfg("qpe");
744 cfg.setGroup("Volume"); 747 cfg.setGroup("Volume");
745 touchclick = cfg.readBoolEntry("TouchSound"); 748 touchclick = cfg.readBoolEntry("TouchSound");
746 keyclick = cfg.readBoolEntry("KeySound"); 749 keyclick = cfg.readBoolEntry("KeySound");
747 alarmsound = cfg.readBoolEntry("AlarmSound"); 750 alarmsound = cfg.readBoolEntry("AlarmSound");
748// Config cfg("Sound"); 751// Config cfg("Sound");
749// cfg.setGroup("System"); 752// cfg.setGroup("System");
750// touchclick = cfg.readBoolEntry("Touch"); 753// touchclick = cfg.readBoolEntry("Touch");
751// keyclick = cfg.readBoolEntry("Key"); 754// keyclick = cfg.readBoolEntry("Key");
752} 755}
753 756
754void Desktop::keyClick() 757void Desktop::keyClick()
755{ 758{
756#ifdef CUSTOM_SOUND_KEYCLICK 759#ifdef CUSTOM_SOUND_KEYCLICK
757 if ( keyclick ) 760 if ( keyclick )
758 CUSTOM_SOUND_KEYCLICK; 761 CUSTOM_SOUND_KEYCLICK;
759#endif 762#endif
760} 763}
761 764
762void Desktop::screenClick() 765void Desktop::screenClick()
763{ 766{
764#ifdef CUSTOM_SOUND_TOUCH 767#ifdef CUSTOM_SOUND_TOUCH
765 if ( touchclick ) 768 if ( touchclick )
766 CUSTOM_SOUND_TOUCH; 769 CUSTOM_SOUND_TOUCH;
767#endif 770#endif
768} 771}
769 772
770void Desktop::soundAlarm() 773void Desktop::soundAlarm()
771{ 774{
772#ifdef CUSTOM_SOUND_ALARM 775#ifdef CUSTOM_SOUND_ALARM
773 if (qpedesktop->alarmsound) 776 if (qpedesktop->alarmsound)
774 CUSTOM_SOUND_ALARM; 777 CUSTOM_SOUND_ALARM;
775#endif 778#endif
776} 779}
777 780
778bool Desktop::eventFilter( QObject *w, QEvent *ev ) 781bool Desktop::eventFilter( QObject *w, QEvent *ev )
779{ 782{
780 if ( ev->type() == QEvent::KeyPress ) { 783 if ( ev->type() == QEvent::KeyPress ) {
781 QKeyEvent *ke = (QKeyEvent *)ev; 784 QKeyEvent *ke = (QKeyEvent *)ev;
782 if ( ke->key() == Qt::Key_F11 ) { // menu key 785 if ( ke->key() == Qt::Key_F11 ) { // menu key
783 QWidget *active = qApp->activeWindow(); 786 QWidget *active = qApp->activeWindow();
784 if ( active && active->isPopup() ) { 787 if ( active && active->isPopup() ) {
785 active->close(); 788 active->close();
786 } 789 }
787 raiseMenu(); 790 raiseMenu();
788 return TRUE; 791 return TRUE;
789 } 792 }
790 } 793 }
791 return FALSE; 794 return FALSE;
792} 795}
793 796
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
@@ -1,123 +1,123 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 2
3 CONFIG = qt warn_on release 3 CONFIG = qt warn_on release
4 4
5 DESTDIR = $(OPIEDIR)/bin 5 DESTDIR = $(OPIEDIR)/bin
6 6
7 HEADERS = background.h \ 7 HEADERS = background.h \
8 desktop.h \ 8 desktop.h \
9 qprocess.h \ 9 qprocess.h \
10 mediummountgui.h \ 10 mediummountgui.h \
11 info.h \ 11 info.h \
12 appicons.h \ 12 appicons.h \
13 taskbar.h \ 13 taskbar.h \
14 sidething.h \ 14 sidething.h \
15 mrulist.h \ 15 mrulist.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