summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp58
-rw-r--r--core/launcher/main.cpp13
-rw-r--r--core/launcher/taskbar.cpp47
-rw-r--r--core/launcher/taskbar.h4
4 files changed, 53 insertions, 69 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index ab4f14a..7662e48 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,537 +1,531 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "desktop.h" 21#include "desktop.h"
22#include "info.h" 22#include "info.h"
23#include "launcher.h" 23#include "launcher.h"
24#include "mrulist.h" 24#include "mrulist.h"
25#include "qcopbridge.h" 25#include "qcopbridge.h"
26#include "shutdownimpl.h" 26#include "shutdownimpl.h"
27#include "startmenu.h" 27#include "startmenu.h"
28#include "taskbar.h" 28#include "taskbar.h"
29#include "transferserver.h" 29#include "transferserver.h"
30#include "irserver.h" 30#include "irserver.h"
31#include "packageslave.h" 31#include "packageslave.h"
32 32
33#include <qpe/applnk.h> 33#include <qpe/applnk.h>
34#include <qpe/mimetype.h> 34#include <qpe/mimetype.h>
35#include <qpe/password.h> 35#include <qpe/password.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/power.h> 37#include <qpe/power.h>
38#include <qpe/timeconversion.h> 38#include <qpe/timeconversion.h>
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/global.h> 40#include <qpe/global.h>
41 41
42#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 42#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
43#include <qpe/custom.h> 43#include <qpe/custom.h>
44#endif 44#endif
45 45
46#include <opie/odevice.h>
47
46#include <qgfx_qws.h> 48#include <qgfx_qws.h>
47#include <qmainwindow.h> 49#include <qmainwindow.h>
48#include <qmessagebox.h> 50#include <qmessagebox.h>
49#include <qtimer.h> 51#include <qtimer.h>
50#include <qwindowsystem_qws.h> 52#include <qwindowsystem_qws.h>
51 53
52#include <qvaluelist.h> 54#include <qvaluelist.h>
53 55
54#include <stdlib.h> 56#include <stdlib.h>
55#include <unistd.h> 57#include <unistd.h>
56 58
57class QCopKeyRegister 59class QCopKeyRegister
58{ 60{
59public: 61public:
60 QCopKeyRegister() : keyCode(0) { } 62 QCopKeyRegister() : keyCode(0) { }
61 QCopKeyRegister(int k, const QString &c, const QString &m) 63 QCopKeyRegister(int k, const QString &c, const QString &m)
62 : keyCode(k), channel(c), message(m) { } 64 : keyCode(k), channel(c), message(m) { }
63 65
64 int getKeyCode() const { return keyCode; } 66 int getKeyCode() const { return keyCode; }
65 QString getChannel() const { return channel; } 67 QString getChannel() const { return channel; }
66 QString getMessage() const { return message; } 68 QString getMessage() const { return message; }
67 69
68private: 70private:
69 int keyCode; 71 int keyCode;
70 QString channel, message; 72 QString channel, message;
71}; 73};
72 74
73typedef QValueList<QCopKeyRegister> KeyRegisterList; 75typedef QValueList<QCopKeyRegister> KeyRegisterList;
74KeyRegisterList keyRegisterList; 76KeyRegisterList keyRegisterList;
75 77
76static Desktop* qpedesktop = 0; 78static Desktop* qpedesktop = 0;
77static int loggedin=0; 79static int loggedin=0;
78static void login(bool at_poweron) 80static void login(bool at_poweron)
79{ 81{
80 if ( !loggedin ) { 82 if ( !loggedin ) {
81 Global::terminateBuiltin("calibrate"); 83 Global::terminateBuiltin("calibrate");
82 Password::authenticate(at_poweron); 84 Password::authenticate(at_poweron);
83 loggedin=1; 85 loggedin=1;
84 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 86 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
85 } 87 }
86} 88}
87 89
88bool Desktop::screenLocked() 90bool Desktop::screenLocked()
89{ 91{
90 return loggedin == 0; 92 return loggedin == 0;
91} 93}
92 94
93/* 95/*
94 Priority is number of alerts that are needed to pop up 96 Priority is number of alerts that are needed to pop up
95 alert. 97 alert.
96 */ 98 */
97class DesktopPowerAlerter : public QMessageBox 99class DesktopPowerAlerter : public QMessageBox
98{ 100{
99public: 101public:
100 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 102 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
101 : QMessageBox( tr("Battery Status"), "Low Battery", 103 : QMessageBox( tr("Battery Status"), "Low Battery",
102 QMessageBox::Critical, 104 QMessageBox::Critical,
103 QMessageBox::Ok | QMessageBox::Default, 105 QMessageBox::Ok | QMessageBox::Default,
104 QMessageBox::NoButton, QMessageBox::NoButton, 106 QMessageBox::NoButton, QMessageBox::NoButton,
105 parent, name, FALSE ) 107 parent, name, FALSE )
106 { 108 {
107 currentPriority = INT_MAX; 109 currentPriority = INT_MAX;
108 alertCount = 0; 110 alertCount = 0;
109 } 111 }
110 112
111 void alert( const QString &text, int priority ); 113 void alert( const QString &text, int priority );
112 void hideEvent( QHideEvent * ); 114 void hideEvent( QHideEvent * );
113private: 115private:
114 int currentPriority; 116 int currentPriority;
115 int alertCount; 117 int alertCount;
116}; 118};
117 119
118void DesktopPowerAlerter::alert( const QString &text, int priority ) 120void DesktopPowerAlerter::alert( const QString &text, int priority )
119{ 121{
120 alertCount++; 122 alertCount++;
121 if ( alertCount < priority ) 123 if ( alertCount < priority )
122 return; 124 return;
123 if ( priority > currentPriority ) 125 if ( priority > currentPriority )
124 return; 126 return;
125 currentPriority = priority; 127 currentPriority = priority;
126 setText( text ); 128 setText( text );
127 show(); 129 show();
128} 130}
129 131
130 132
131void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 133void DesktopPowerAlerter::hideEvent( QHideEvent *e )
132{ 134{
133 QMessageBox::hideEvent( e ); 135 QMessageBox::hideEvent( e );
134 alertCount = 0; 136 alertCount = 0;
135 currentPriority = INT_MAX; 137 currentPriority = INT_MAX;
136} 138}
137 139
138 140
139 141
140DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 142DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
141 : QPEApplication( argc, argv, appType ) 143 : QPEApplication( argc, argv, appType )
142{ 144{
143 145
144 QTimer *t = new QTimer( this ); 146 QTimer *t = new QTimer( this );
145 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 147 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
146 t->start( 10000 ); 148 t->start( 10000 );
147 ps = new PowerStatus; 149 ps = new PowerStatus;
148 pa = new DesktopPowerAlerter( 0 ); 150 pa = new DesktopPowerAlerter( 0 );
149 151
150 channel = new QCopChannel( "QPE/Desktop", this ); 152 channel = new QCopChannel( "QPE/Desktop", this );
151 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 153 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
152 this, SLOT(receive(const QCString&, const QByteArray&)) ); 154 this, SLOT(receive(const QCString&, const QByteArray&)) );
153} 155}
154 156
155 157
156DesktopApplication::~DesktopApplication() 158DesktopApplication::~DesktopApplication()
157{ 159{
158 delete ps; 160 delete ps;
159 delete pa; 161 delete pa;
160} 162}
161 163
162void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) 164void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
163{ 165{
164 QDataStream stream( data, IO_ReadOnly ); 166 QDataStream stream( data, IO_ReadOnly );
165 if (msg == "keyRegister(int key, QString channel, QString message)") 167 if (msg == "keyRegister(int key, QString channel, QString message)")
166 { 168 {
167 int k; 169 int k;
168 QString c, m; 170 QString c, m;
169 stream >> k; 171 stream >> k;
170 stream >> c; 172 stream >> c;
171 stream >> m; 173 stream >> m;
172 174
173 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); 175 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m );
174 keyRegisterList.append(QCopKeyRegister(k,c,m)); 176 keyRegisterList.append(QCopKeyRegister(k,c,m));
175 } 177 }
176 else if (msg == "suspend()"){ 178 else if (msg == "suspend()"){
177 emit power(); 179 emit power();
178 } 180 }
179 181
180} 182}
181 183
182enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 184enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
183 185
184#ifdef Q_WS_QWS 186#ifdef Q_WS_QWS
185bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 187bool DesktopApplication::qwsEventFilter( QWSEvent *e )
186{ 188{
187 qpedesktop->checkMemory(); 189 qpedesktop->checkMemory();
188 190
189 if ( e->type == QWSEvent::Key ) { 191 if ( e->type == QWSEvent::Key ) {
190 QWSKeyEvent *ke = (QWSKeyEvent *)e; 192 QWSKeyEvent *ke = (QWSKeyEvent *)e;
191 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 193 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
192 return TRUE; 194 return TRUE;
193 bool press = ke->simpleData.is_press; 195 bool press = ke->simpleData.is_press;
194 bool autoRepeat= ke->simpleData.is_auto_repeat; 196 bool autoRepeat= ke->simpleData.is_auto_repeat;
195 if (!keyRegisterList.isEmpty()) 197 if (!keyRegisterList.isEmpty())
196 { 198 {
197 KeyRegisterList::Iterator it; 199 KeyRegisterList::Iterator it;
198 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) 200 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
199 { 201 {
200 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) { 202 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) {
201 if(press) qDebug("press"); else qDebug("release"); 203 if(press) qDebug("press"); else qDebug("release");
202 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 204 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
203 } 205 }
204 } 206 }
205 } 207 }
206 208
207 if ( !keyboardGrabbed() ) { 209 if ( !keyboardGrabbed() ) {
208 if ( ke->simpleData.keycode == Key_F9 ) { 210 if ( ke->simpleData.keycode == Key_F9 ) {
209 if ( press ) emit datebook(); 211 if ( press ) emit datebook();
210 return TRUE; 212 return TRUE;
211 } 213 }
212 if ( ke->simpleData.keycode == Key_F10 ) { 214 if ( ke->simpleData.keycode == Key_F10 ) {
213 if ( !press && cardSendTimer ) { 215 if ( !press && cardSendTimer ) {
214 emit contacts(); 216 emit contacts();
215 delete cardSendTimer; 217 delete cardSendTimer;
216 } else if ( press ) { 218 } else if ( press ) {
217 cardSendTimer = new QTimer(); 219 cardSendTimer = new QTimer();
218 cardSendTimer->start( 2000, TRUE ); 220 cardSendTimer->start( 2000, TRUE );
219 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 221 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
220 } 222 }
221 return TRUE; 223 return TRUE;
222 } 224 }
223 /* menu key now opens application menu/toolbar 225 /* menu key now opens application menu/toolbar
224 if ( ke->simpleData.keycode == Key_F11 ) { 226 if ( ke->simpleData.keycode == Key_F11 ) {
225 if ( press ) emit menu(); 227 if ( press ) emit menu();
226 return TRUE; 228 return TRUE;
227 } 229 }
228 */ 230 */
229 if ( ke->simpleData.keycode == Key_F12 ) { 231 if ( ke->simpleData.keycode == Key_F12 ) {
230 while( activePopupWidget() ) 232 while( activePopupWidget() )
231 activePopupWidget()->close(); 233 activePopupWidget()->close();
232 if ( press ) emit launch(); 234 if ( press ) emit launch();
233 return TRUE; 235 return TRUE;
234 } 236 }
235 if ( ke->simpleData.keycode == Key_F13 ) { 237 if ( ke->simpleData.keycode == Key_F13 ) {
236 if ( press ) emit email(); 238 if ( press ) emit email();
237 return TRUE; 239 return TRUE;
238 } 240 }
239 } 241 }
240 242
241 if ( ke->simpleData.keycode == Key_F34 ) { 243 if ( ke->simpleData.keycode == Key_F34 ) {
242 if ( press ) emit power(); 244 if ( press ) emit power();
243 return TRUE; 245 return TRUE;
244 } 246 }
245// This was used for the iPAQ PowerButton 247// This was used for the iPAQ PowerButton
246// See main.cpp for new KeyboardFilter 248// See main.cpp for new KeyboardFilter
247// 249//
248// if ( ke->simpleData.keycode == Key_SysReq ) { 250// if ( ke->simpleData.keycode == Key_SysReq ) {
249// if ( press ) emit power(); 251// if ( press ) emit power();
250// return TRUE; 252// return TRUE;
251// } 253// }
252 if ( ke->simpleData.keycode == Key_F35 ) { 254 if ( ke->simpleData.keycode == Key_F35 ) {
253 if ( press ) emit backlight(); 255 if ( press ) emit backlight();
254 return TRUE; 256 return TRUE;
255 } 257 }
256 if ( ke->simpleData.keycode == Key_F32 ) { 258 if ( ke->simpleData.keycode == Key_F32 ) {
257 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 259 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
258 return TRUE; 260 return TRUE;
259 } 261 }
260 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 262 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
261 if ( press ) emit symbol(); 263 if ( press ) emit symbol();
262 return TRUE; 264 return TRUE;
263 } 265 }
264 if ( ke->simpleData.keycode == Key_NumLock ) { 266 if ( ke->simpleData.keycode == Key_NumLock ) {
265 if ( press ) emit numLockStateToggle(); 267 if ( press ) emit numLockStateToggle();
266 } 268 }
267 if ( ke->simpleData.keycode == Key_CapsLock ) { 269 if ( ke->simpleData.keycode == Key_CapsLock ) {
268 if ( press ) emit capsLockStateToggle(); 270 if ( press ) emit capsLockStateToggle();
269 } 271 }
270 if ( press ) 272 if (( press && !autoRepeat ) || ( !press && autoRepeat ))
271 qpedesktop->keyClick(); 273 qpedesktop->keyClick();
272 } else { 274 } else {
273 if ( e->type == QWSEvent::Mouse ) { 275 if ( e->type == QWSEvent::Mouse ) {
274 QWSMouseEvent *me = (QWSMouseEvent *)e; 276 QWSMouseEvent *me = (QWSMouseEvent *)e;
275 static bool up = TRUE; 277 static bool up = TRUE;
276 if ( me->simpleData.state&LeftButton ) { 278 if ( me->simpleData.state&LeftButton ) {
277 if ( up ) { 279 if ( up ) {
278 up = FALSE; 280 up = FALSE;
279 qpedesktop->screenClick(); 281 qpedesktop->screenClick();
280 } 282 }
281 } else { 283 } else {
282 up = TRUE; 284 up = TRUE;
283 } 285 }
284 } 286 }
285 } 287 }
286 288
287 return QPEApplication::qwsEventFilter( e ); 289 return QPEApplication::qwsEventFilter( e );
288} 290}
289#endif 291#endif
290 292
291void DesktopApplication::psTimeout() 293void DesktopApplication::psTimeout()
292{ 294{
293 qpedesktop->checkMemory(); // in case no events are being generated 295 qpedesktop->checkMemory(); // in case no events are being generated
294 296
295 *ps = PowerStatusManager::readStatus(); 297 *ps = PowerStatusManager::readStatus();
296 298
297 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 299 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
298 pa->alert( tr( "Battery is running very low." ), 6 ); 300 pa->alert( tr( "Battery is running very low." ), 6 );
299 } 301 }
300 302
301 if ( ps->batteryStatus() == PowerStatus::Critical ) { 303 if ( ps->batteryStatus() == PowerStatus::Critical ) {
302 pa->alert( tr( "Battery level is critical!\n" 304 pa->alert( tr( "Battery level is critical!\n"
303 "Keep power off until power restored!" ), 1 ); 305 "Keep power off until power restored!" ), 1 );
304 } 306 }
305 307
306 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 308 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
307 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 309 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
308 } 310 }
309} 311}
310 312
311 313
312void DesktopApplication::sendCard() 314void DesktopApplication::sendCard()
313{ 315{
314 delete cardSendTimer; 316 delete cardSendTimer;
315 cardSendTimer = 0; 317 cardSendTimer = 0;
316 QString card = getenv("HOME"); 318 QString card = getenv("HOME");
317 card += "/Applications/addressbook/businesscard.vcf"; 319 card += "/Applications/addressbook/businesscard.vcf";
318 320
319 if ( QFile::exists( card ) ) { 321 if ( QFile::exists( card ) ) {
320 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 322 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
321 QString mimetype = "text/x-vCard"; 323 QString mimetype = "text/x-vCard";
322 e << tr("business card") << card << mimetype; 324 e << tr("business card") << card << mimetype;
323 } 325 }
324} 326}
325 327
326#if defined(QPE_HAVE_MEMALERTER) 328#if defined(QPE_HAVE_MEMALERTER)
327QPE_MEMALERTER_IMPL 329QPE_MEMALERTER_IMPL
328#endif 330#endif
329 331
330#if defined(CUSTOM_SOUND_IMPL)
331CUSTOM_SOUND_IMPL
332#endif
333
334//=========================================================================== 332//===========================================================================
335 333
336Desktop::Desktop() : 334Desktop::Desktop() :
337 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 335 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
338 qcopBridge( 0 ), 336 qcopBridge( 0 ),
339 transferServer( 0 ), 337 transferServer( 0 ),
340 packageSlave( 0 ) 338 packageSlave( 0 )
341{ 339{
342#ifdef CUSTOM_SOUND_INIT
343 CUSTOM_SOUND_INIT;
344#endif
345
346 qpedesktop = this; 340 qpedesktop = this;
347 341
348// bg = new Info( this ); 342// bg = new Info( this );
349 tb = new TaskBar; 343 tb = new TaskBar;
350 344
351 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 345 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
352 346
353 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 347 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
354 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 348 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
355 349
356 int displayw = qApp->desktop()->width(); 350 int displayw = qApp->desktop()->width();
357 int displayh = qApp->desktop()->height(); 351 int displayh = qApp->desktop()->height();
358 352
359 353
360 QSize sz = tb->sizeHint(); 354 QSize sz = tb->sizeHint();
361 355
362 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 356 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
363 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 357 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
364 358
365 tb->show(); 359 tb->show();
366 launcher->showMaximized(); 360 launcher->showMaximized();
367 launcher->show(); 361 launcher->show();
368 launcher->raise(); 362 launcher->raise();
369#if defined(QPE_HAVE_MEMALERTER) 363#if defined(QPE_HAVE_MEMALERTER)
370 initMemalerter(); 364 initMemalerter();
371#endif 365#endif
372 // start services 366 // start services
373 startTransferServer(); 367 startTransferServer();
374 (void) new IrServer( this ); 368 (void) new IrServer( this );
375 rereadVolumes(); 369 rereadVolumes();
376 370
377 packageSlave = new PackageSlave( this ); 371 packageSlave = new PackageSlave( this );
378 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 372 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
379 373
380 qApp->installEventFilter( this ); 374 qApp->installEventFilter( this );
381} 375}
382 376
383void Desktop::show() 377void Desktop::show()
384{ 378{
385 login(TRUE); 379 login(TRUE);
386 QWidget::show(); 380 QWidget::show();
387} 381}
388 382
389Desktop::~Desktop() 383Desktop::~Desktop()
390{ 384{
391 delete launcher; 385 delete launcher;
392 delete tb; 386 delete tb;
393 delete qcopBridge; 387 delete qcopBridge;
394 delete transferServer; 388 delete transferServer;
395} 389}
396 390
397bool Desktop::recoverMemory() 391bool Desktop::recoverMemory()
398{ 392{
399 return tb->recoverMemory(); 393 return tb->recoverMemory();
400} 394}
401 395
402void Desktop::checkMemory() 396void Desktop::checkMemory()
403{ 397{
404#if defined(QPE_HAVE_MEMALERTER) 398#if defined(QPE_HAVE_MEMALERTER)
405 static bool ignoreNormal=FALSE; 399 static bool ignoreNormal=FALSE;
406 static bool existingMessage=FALSE; 400 static bool existingMessage=FALSE;
407 401
408 if(existingMessage) 402 if(existingMessage)
409 return; // don't show a second message while still on first 403 return; // don't show a second message while still on first
410 404
411 existingMessage = TRUE; 405 existingMessage = TRUE;
412 switch ( memstate ) { 406 switch ( memstate ) {
413 case Unknown: 407 case Unknown:
414 break; 408 break;
415 case Low: 409 case Low:
416 memstate = Unknown; 410 memstate = Unknown;
417 if ( recoverMemory() ) 411 if ( recoverMemory() )
418 ignoreNormal = TRUE; 412 ignoreNormal = TRUE;
419 else 413 else
420 QMessageBox::warning( 0 , "Memory Status", 414 QMessageBox::warning( 0 , "Memory Status",
421 "The memory smacks of shortage. \n" 415 "The memory smacks of shortage. \n"
422 "Please save data. " ); 416 "Please save data. " );
423 break; 417 break;
424 case Normal: 418 case Normal:
425 memstate = Unknown; 419 memstate = Unknown;
426 if ( ignoreNormal ) 420 if ( ignoreNormal )
427 ignoreNormal = FALSE; 421 ignoreNormal = FALSE;
428 else 422 else
429 QMessageBox::information ( 0 , "Memory Status", 423 QMessageBox::information ( 0 , "Memory Status",
430 "There is enough memory again." ); 424 "There is enough memory again." );
431 break; 425 break;
432 case VeryLow: 426 case VeryLow:
433 memstate = Unknown; 427 memstate = Unknown;
434 QMessageBox::critical( 0 , "Memory Status", 428 QMessageBox::critical( 0 , "Memory Status",
435 "The memory is very low. \n" 429 "The memory is very low. \n"
436 "Please end this application \n" 430 "Please end this application \n"
437 "immediately." ); 431 "immediately." );
438 recoverMemory(); 432 recoverMemory();
439 } 433 }
440 existingMessage = FALSE; 434 existingMessage = FALSE;
441#endif 435#endif
442} 436}
443 437
444static bool isVisibleWindow(int wid) 438static bool isVisibleWindow(int wid)
445{ 439{
446 const QList<QWSWindow> &list = qwsServer->clientWindows(); 440 const QList<QWSWindow> &list = qwsServer->clientWindows();
447 QWSWindow* w; 441 QWSWindow* w;
448 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 442 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
449 if ( w->winId() == wid ) 443 if ( w->winId() == wid )
450 return !w->isFullyObscured(); 444 return !w->isFullyObscured();
451 } 445 }
452 return FALSE; 446 return FALSE;
453} 447}
454 448
455static bool hasVisibleWindow(const QString& clientname) 449static bool hasVisibleWindow(const QString& clientname)
456{ 450{
457 const QList<QWSWindow> &list = qwsServer->clientWindows(); 451 const QList<QWSWindow> &list = qwsServer->clientWindows();
458 QWSWindow* w; 452 QWSWindow* w;
459 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 453 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
460 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 454 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
461 return TRUE; 455 return TRUE;
462 } 456 }
463 return FALSE; 457 return FALSE;
464} 458}
465 459
466void Desktop::raiseLauncher() 460void Desktop::raiseLauncher()
467{ 461{
468 Config cfg("qpe"); //F12 'Home' 462 Config cfg("qpe"); //F12 'Home'
469 cfg.setGroup("AppsKey"); 463 cfg.setGroup("AppsKey");
470 QString tempItem; 464 QString tempItem;
471 tempItem = cfg.readEntry("Middle","Home"); 465 tempItem = cfg.readEntry("Middle","Home");
472 if(tempItem == "Home" || tempItem.isEmpty()) { 466 if(tempItem == "Home" || tempItem.isEmpty()) {
473 if ( isVisibleWindow(launcher->winId()) ) 467 if ( isVisibleWindow(launcher->winId()) )
474 launcher->nextView(); 468 launcher->nextView();
475 else 469 else
476 launcher->raise(); 470 launcher->raise();
477 } else { 471 } else {
478 QCopEnvelope e("QPE/System","execute(QString)"); 472 QCopEnvelope e("QPE/System","execute(QString)");
479 e << tempItem; 473 e << tempItem;
480 } 474 }
481} 475}
482 476
483void Desktop::executeOrModify(const QString& appLnkFile) 477void Desktop::executeOrModify(const QString& appLnkFile)
484{ 478{
485 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 479 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
486 if ( lnk.isValid() ) { 480 if ( lnk.isValid() ) {
487 QCString app = lnk.exec().utf8(); 481 QCString app = lnk.exec().utf8();
488 Global::terminateBuiltin("calibrate"); 482 Global::terminateBuiltin("calibrate");
489 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 483 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
490 MRUList::addTask(&lnk); 484 MRUList::addTask(&lnk);
491 if ( hasVisibleWindow(app) ) 485 if ( hasVisibleWindow(app) )
492 QCopChannel::send("QPE/Application/" + app, "nextView()"); 486 QCopChannel::send("QPE/Application/" + app, "nextView()");
493 else 487 else
494 QCopChannel::send("QPE/Application/" + app, "raise()"); 488 QCopChannel::send("QPE/Application/" + app, "raise()");
495 } else { 489 } else {
496 lnk.execute(); 490 lnk.execute();
497 } 491 }
498 } 492 }
499} 493}
500 494
501void Desktop::raiseDatebook() 495void Desktop::raiseDatebook()
502{ 496{
503 Config cfg("qpe"); //F9 'Activity' 497 Config cfg("qpe"); //F9 'Activity'
504 cfg.setGroup("AppsKey"); 498 cfg.setGroup("AppsKey");
505 QString tempItem; 499 QString tempItem;
506 tempItem = cfg.readEntry("LeftEnd","Calender"); 500 tempItem = cfg.readEntry("LeftEnd","Calender");
507 if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); 501 if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop");
508 else { 502 else {
509 QCopEnvelope e("QPE/System","execute(QString)"); 503 QCopEnvelope e("QPE/System","execute(QString)");
510 e << tempItem; 504 e << tempItem;
511 } 505 }
512} 506}
513 507
514void Desktop::raiseContacts() 508void Desktop::raiseContacts()
515{ 509{
516 Config cfg("qpe"); //F10, 'Contacts' 510 Config cfg("qpe"); //F10, 'Contacts'
517 cfg.setGroup("AppsKey"); 511 cfg.setGroup("AppsKey");
518 QString tempItem; 512 QString tempItem;
519 tempItem = cfg.readEntry("Left2nd","Address Book"); 513 tempItem = cfg.readEntry("Left2nd","Address Book");
520 if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); 514 if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop");
521 else { 515 else {
522 QCopEnvelope e("QPE/System","execute(QString)"); 516 QCopEnvelope e("QPE/System","execute(QString)");
523 e << tempItem; 517 e << tempItem;
524 } 518 }
525} 519}
526 520
527void Desktop::raiseMenu() 521void Desktop::raiseMenu()
528{ 522{
529 Config cfg("qpe"); //F11, 'Menu' 523 Config cfg("qpe"); //F11, 'Menu'
530 cfg.setGroup("AppsKey"); 524 cfg.setGroup("AppsKey");
531 QString tempItem; 525 QString tempItem;
532 tempItem = cfg.readEntry("Right2nd","Popup Menu"); 526 tempItem = cfg.readEntry("Right2nd","Popup Menu");
533 if(tempItem == "Popup Menu" || tempItem.isEmpty()) { 527 if(tempItem == "Popup Menu" || tempItem.isEmpty()) {
534 Global::terminateBuiltin("calibrate"); 528 Global::terminateBuiltin("calibrate");
535 tb->startMenu()->launch(); 529 tb->startMenu()->launch();
536 } else { 530 } else {
537 QCopEnvelope e("QPE/System","execute(QString)"); 531 QCopEnvelope e("QPE/System","execute(QString)");
@@ -567,230 +561,224 @@ void Desktop::execAutoStart() {
567 QCopEnvelope e("QPE/System", "execute(QString)"); 561 QCopEnvelope e("QPE/System", "execute(QString)");
568 e << QString(appName); 562 e << QString(appName);
569 } else { 563 } else {
570 } 564 }
571} 565}
572 566
573#if defined(QPE_HAVE_TOGGLELIGHT) 567#if defined(QPE_HAVE_TOGGLELIGHT)
574#include <qpe/config.h> 568#include <qpe/config.h>
575 569
576#include <sys/ioctl.h> 570#include <sys/ioctl.h>
577#include <sys/types.h> 571#include <sys/types.h>
578#include <fcntl.h> 572#include <fcntl.h>
579#include <unistd.h> 573#include <unistd.h>
580#include <errno.h> 574#include <errno.h>
581#include <linux/ioctl.h> 575#include <linux/ioctl.h>
582#include <time.h> 576#include <time.h>
583#endif 577#endif
584 578
585static bool blanked=FALSE; 579static bool blanked=FALSE;
586 580
587static void blankScreen() 581static void blankScreen()
588{ 582{
589 if ( !qt_screen ) return; 583 if ( !qt_screen ) return;
590 /* Should use a big black window instead. 584 /* Should use a big black window instead.
591 QGfx* g = qt_screen->screenGfx(); 585 QGfx* g = qt_screen->screenGfx();
592 g->fillRect(0,0,qt_screen->width(),qt_screen->height()); 586 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
593 delete g; 587 delete g;
594 */ 588 */
595 blanked = TRUE; 589 blanked = TRUE;
596} 590}
597 591
598static void darkScreen() 592static void darkScreen()
599{ 593{
600 extern void qpe_setBacklight(int); 594 extern void qpe_setBacklight(int);
601 qpe_setBacklight(0); // force off 595 qpe_setBacklight(0); // force off
602} 596}
603 597
604 598
605void Desktop::togglePower() 599void Desktop::togglePower()
606{ 600{
607 bool wasloggedin = loggedin; 601 bool wasloggedin = loggedin;
608 loggedin=0; 602 loggedin=0;
609 suspendTime = QDateTime::currentDateTime(); 603 suspendTime = QDateTime::currentDateTime();
610 darkScreen(); 604 darkScreen();
611 if ( wasloggedin ) 605 if ( wasloggedin )
612 blankScreen(); 606 blankScreen();
613 607
614 system("apm --suspend"); 608 system("apm --suspend");
615 609
616 610
617 611
618 QWSServer::screenSaverActivate( FALSE ); 612 QWSServer::screenSaverActivate( FALSE );
619 { 613 {
620 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 614 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
621 QCopEnvelope e("QPE/System", "setBacklight(int)"); 615 QCopEnvelope e("QPE/System", "setBacklight(int)");
622 e << -3; // Force on 616 e << -3; // Force on
623 } 617 }
624 if ( wasloggedin ) { 618 if ( wasloggedin ) {
625 login(TRUE); 619 login(TRUE);
626 } 620 }
627 sleep(1); 621 sleep(1);
628 execAutoStart(); 622 execAutoStart();
629 //qcopBridge->closeOpenConnections(); 623 //qcopBridge->closeOpenConnections();
630 //qDebug("called togglePower()!!!!!!"); 624 //qDebug("called togglePower()!!!!!!");
631} 625}
632 626
633void Desktop::toggleLight() 627void Desktop::toggleLight()
634{ 628{
635 QCopEnvelope e("QPE/System", "setBacklight(int)"); 629 QCopEnvelope e("QPE/System", "setBacklight(int)");
636 e << -2; // toggle 630 e << -2; // toggle
637} 631}
638 632
639void Desktop::toggleSymbolInput() 633void Desktop::toggleSymbolInput()
640{ 634{
641 tb->toggleSymbolInput(); 635 tb->toggleSymbolInput();
642} 636}
643 637
644void Desktop::toggleNumLockState() 638void Desktop::toggleNumLockState()
645{ 639{
646 tb->toggleNumLockState(); 640 tb->toggleNumLockState();
647} 641}
648 642
649void Desktop::toggleCapsLockState() 643void Desktop::toggleCapsLockState()
650{ 644{
651 tb->toggleCapsLockState(); 645 tb->toggleCapsLockState();
652} 646}
653 647
654void Desktop::styleChange( QStyle &s ) 648void Desktop::styleChange( QStyle &s )
655{ 649{
656 QWidget::styleChange( s ); 650 QWidget::styleChange( s );
657 int displayw = qApp->desktop()->width(); 651 int displayw = qApp->desktop()->width();
658 int displayh = qApp->desktop()->height(); 652 int displayh = qApp->desktop()->height();
659 653
660 QSize sz = tb->sizeHint(); 654 QSize sz = tb->sizeHint();
661 655
662 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 656 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
663} 657}
664 658
665void DesktopApplication::shutdown() 659void DesktopApplication::shutdown()
666{ 660{
667 if ( type() != GuiServer ) 661 if ( type() != GuiServer )
668 return; 662 return;
669 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 663 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
670 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 664 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
671 this, SLOT(shutdown(ShutdownImpl::Type)) ); 665 this, SLOT(shutdown(ShutdownImpl::Type)) );
672 sd->showMaximized(); 666 sd->showMaximized();
673} 667}
674 668
675void DesktopApplication::shutdown( ShutdownImpl::Type t ) 669void DesktopApplication::shutdown( ShutdownImpl::Type t )
676{ 670{
677 switch ( t ) { 671 switch ( t ) {
678 case ShutdownImpl::ShutdownSystem: 672 case ShutdownImpl::ShutdownSystem:
679 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 673 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
680 break; 674 break;
681 case ShutdownImpl::RebootSystem: 675 case ShutdownImpl::RebootSystem:
682 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 676 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
683 break; 677 break;
684 case ShutdownImpl::RestartDesktop: 678 case ShutdownImpl::RestartDesktop:
685 restart(); 679 restart();
686 break; 680 break;
687 case ShutdownImpl::TerminateDesktop: 681 case ShutdownImpl::TerminateDesktop:
688 prepareForTermination(FALSE); 682 prepareForTermination(FALSE);
689 quit(); 683 quit();
690 break; 684 break;
691 } 685 }
692} 686}
693 687
694void DesktopApplication::restart() 688void DesktopApplication::restart()
695{ 689{
696 prepareForTermination(TRUE); 690 prepareForTermination(TRUE);
697 691
698#ifdef Q_WS_QWS 692#ifdef Q_WS_QWS
699 for ( int fd = 3; fd < 100; fd++ ) 693 for ( int fd = 3; fd < 100; fd++ )
700 close( fd ); 694 close( fd );
701#if defined(QT_DEMO_SINGLE_FLOPPY) 695#if defined(QT_DEMO_SINGLE_FLOPPY)
702 execl( "/sbin/init", "qpe", 0 ); 696 execl( "/sbin/init", "qpe", 0 );
703#elif defined(QT_QWS_CASSIOPEIA) 697#elif defined(QT_QWS_CASSIOPEIA)
704 execl( "/bin/sh", "sh", 0 ); 698 execl( "/bin/sh", "sh", 0 );
705#else 699#else
706 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 700 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
707#endif 701#endif
708 exit(1); 702 exit(1);
709#endif 703#endif
710} 704}
711 705
712void Desktop::startTransferServer() 706void Desktop::startTransferServer()
713{ 707{
714 // start qcop bridge server 708 // start qcop bridge server
715 qcopBridge = new QCopBridge( 4243 ); 709 qcopBridge = new QCopBridge( 4243 );
716 if ( !qcopBridge->ok() ) { 710 if ( !qcopBridge->ok() ) {
717 delete qcopBridge; 711 delete qcopBridge;
718 qcopBridge = 0; 712 qcopBridge = 0;
719 } 713 }
720 // start transfer server 714 // start transfer server
721 transferServer = new TransferServer( 4242 ); 715 transferServer = new TransferServer( 4242 );
722 if ( !transferServer->ok() ) { 716 if ( !transferServer->ok() ) {
723 delete transferServer; 717 delete transferServer;
724 transferServer = 0; 718 transferServer = 0;
725 } 719 }
726 if ( !transferServer || !qcopBridge ) 720 if ( !transferServer || !qcopBridge )
727 startTimer( 2000 ); 721 startTimer( 2000 );
728} 722}
729 723
730void Desktop::timerEvent( QTimerEvent *e ) 724void Desktop::timerEvent( QTimerEvent *e )
731{ 725{
732 killTimer( e->timerId() ); 726 killTimer( e->timerId() );
733 startTransferServer(); 727 startTransferServer();
734} 728}
735 729
736void Desktop::terminateServers() 730void Desktop::terminateServers()
737{ 731{
738 delete transferServer; 732 delete transferServer;
739 delete qcopBridge; 733 delete qcopBridge;
740 transferServer = 0; 734 transferServer = 0;
741 qcopBridge = 0; 735 qcopBridge = 0;
742} 736}
743 737
744void Desktop::rereadVolumes() 738void Desktop::rereadVolumes()
745{ 739{
746 Config cfg("qpe"); 740 Config cfg("qpe");
747 cfg.setGroup("Volume"); 741 cfg.setGroup("Volume");
748 touchclick = cfg.readBoolEntry("TouchSound"); 742 touchclick = cfg.readBoolEntry("TouchSound");
749 keyclick = cfg.readBoolEntry("KeySound"); 743 keyclick = cfg.readBoolEntry("KeySound");
750 alarmsound = cfg.readBoolEntry("AlarmSound"); 744 alarmsound = cfg.readBoolEntry("AlarmSound");
751// Config cfg("Sound"); 745// Config cfg("Sound");
752// cfg.setGroup("System"); 746// cfg.setGroup("System");
753// touchclick = cfg.readBoolEntry("Touch"); 747// touchclick = cfg.readBoolEntry("Touch");
754// keyclick = cfg.readBoolEntry("Key"); 748// keyclick = cfg.readBoolEntry("Key");
755} 749}
756 750
757void Desktop::keyClick() 751void Desktop::keyClick()
758{ 752{
759#ifdef CUSTOM_SOUND_KEYCLICK 753 if ( keyclick )
760 if ( keyclick ) 754 ODevice::inst ( )-> keySound ( );
761 CUSTOM_SOUND_KEYCLICK;
762#endif
763} 755}
764 756
765void Desktop::screenClick() 757void Desktop::screenClick()
766{ 758{
767#ifdef CUSTOM_SOUND_TOUCH 759 if ( touchclick )
768 if ( touchclick ) 760 ODevice::inst ( )-> touchSound ( );
769 CUSTOM_SOUND_TOUCH;
770#endif
771} 761}
772 762
773void Desktop::soundAlarm() 763void Desktop::soundAlarm()
774{ 764{
775#ifdef CUSTOM_SOUND_ALARM 765 if ( qpedesktop-> alarmsound )
776 if (qpedesktop->alarmsound) 766 ODevice::inst ( )-> alarmSound ( );
777 CUSTOM_SOUND_ALARM;
778#endif
779} 767}
780 768
781bool Desktop::eventFilter( QObject *w, QEvent *ev ) 769bool Desktop::eventFilter( QObject *, QEvent *ev )
782{ 770{
783 if ( ev->type() == QEvent::KeyPress ) { 771 if ( ev-> type ( ) == QEvent::KeyPress ) {
784 QKeyEvent *ke = (QKeyEvent *)ev; 772 QKeyEvent *ke = (QKeyEvent *) ev;
785 if ( ke->key() == Qt::Key_F11 ) { // menu key 773 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key
786 QWidget *active = qApp->activeWindow(); 774 QWidget *active = qApp-> activeWindow ( );
787 if ( active && active->isPopup() ) { 775
788 active->close(); 776 if ( active && active-> isPopup ( ))
789 } 777 active->close();
790 raiseMenu();
791 return TRUE;
792 }
793 }
794 return FALSE;
795}
796 778
779 raiseMenu ( );
780 return true;
781 }
782 }
783 return false;
784}
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 347eee9..b3c331b 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -1,367 +1,366 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "desktop.h" 21#include "desktop.h"
22#include "taskbar.h" 22#include "taskbar.h"
23#include "stabmon.h" 23#include "stabmon.h"
24 24
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/network.h> 26#include <qpe/network.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 28#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
29#include <qpe/custom.h> 29#include <qpe/custom.h>
30#endif 30#endif
31 31
32#include <opie/odevice.h>
33
32#include <qfile.h> 34#include <qfile.h>
33#include <qwindowsystem_qws.h> 35#include <qwindowsystem_qws.h>
34#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
35#include <qpe/alarmserver.h> 37#include <qpe/alarmserver.h>
36 38
37#include <opie/ohwinfo.h>
38
39#include <stdlib.h> 39#include <stdlib.h>
40#include <stdio.h> 40#include <stdio.h>
41#include <signal.h> 41#include <signal.h>
42#include <unistd.h> 42#include <unistd.h>
43 43
44#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 44#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
45#include "../calibrate/calibrate.h" 45#include "../calibrate/calibrate.h"
46#endif 46#endif
47 47
48#ifdef QT_QWS_LOGIN 48#ifdef QT_QWS_LOGIN
49#include "../login/qdmdialogimpl.h" 49#include "../login/qdmdialogimpl.h"
50#endif 50#endif
51 51
52#ifdef QT_QWS_CASSIOPEIA 52#ifdef QT_QWS_CASSIOPEIA
53static void ignoreMessage( QtMsgType, const char * ) 53static void ignoreMessage( QtMsgType, const char * )
54{ 54{
55} 55}
56#include <sys/mount.h> 56#include <sys/mount.h>
57#include <sys/types.h> 57#include <sys/types.h>
58#include <sys/stat.h> 58#include <sys/stat.h>
59#include <sys/time.h> 59#include <sys/time.h>
60#include <fcntl.h> 60#include <fcntl.h>
61#include <qdatetime.h> 61#include <qdatetime.h>
62 62
63void initCassiopeia() 63void initCassiopeia()
64{ 64{
65 // MIPSEL-specific init - make sure /proc exists for shm 65 // MIPSEL-specific init - make sure /proc exists for shm
66/* 66/*
67 if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) { 67 if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) {
68 perror("Remounting - / read/write"); 68 perror("Remounting - / read/write");
69 } 69 }
70*/ 70*/
71 if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) { 71 if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) {
72 perror("mounting ramfs /tmp"); 72 perror("mounting ramfs /tmp");
73 } else { 73 } else {
74 fprintf( stderr, "mounted /tmp\n" ); 74 fprintf( stderr, "mounted /tmp\n" );
75 } 75 }
76 if ( mount("none", "/home", "ramfs", 0, 0 ) ) { 76 if ( mount("none", "/home", "ramfs", 0, 0 ) ) {
77 perror("mounting ramfs /home"); 77 perror("mounting ramfs /home");
78 } else { 78 } else {
79 fprintf( stderr, "mounted /home\n" ); 79 fprintf( stderr, "mounted /home\n" );
80 } 80 }
81 if ( mount("none","/proc","proc",0,0) ) { 81 if ( mount("none","/proc","proc",0,0) ) {
82 perror("Mounting - /proc"); 82 perror("Mounting - /proc");
83 } else { 83 } else {
84 fprintf( stderr, "mounted /proc\n" ); 84 fprintf( stderr, "mounted /proc\n" );
85 } 85 }
86 if ( mount("none","/mnt","shm",0,0) ) { 86 if ( mount("none","/mnt","shm",0,0) ) {
87 perror("Mounting - shm"); 87 perror("Mounting - shm");
88 } 88 }
89 setenv( "QTDIR", "/", 1 ); 89 setenv( "QTDIR", "/", 1 );
90 setenv( "OPIEDIR", "/", 1 ); 90 setenv( "OPIEDIR", "/", 1 );
91 setenv( "HOME", "/home", 1 ); 91 setenv( "HOME", "/home", 1 );
92 mkdir( "/home/Documents", 0755 ); 92 mkdir( "/home/Documents", 0755 );
93 93
94 // set a reasonable starting date 94 // set a reasonable starting date
95 QDateTime dt( QDate( 2001, 3, 15 ) ); 95 QDateTime dt( QDate( 2001, 3, 15 ) );
96 QDateTime now = QDateTime::currentDateTime(); 96 QDateTime now = QDateTime::currentDateTime();
97 int change = now.secsTo( dt ); 97 int change = now.secsTo( dt );
98 98
99 time_t t = ::time(0); 99 time_t t = ::time(0);
100 t += change; 100 t += change;
101 stime(&t); 101 stime(&t);
102 102
103 qInstallMsgHandler(ignoreMessage); 103 qInstallMsgHandler(ignoreMessage);
104} 104}
105#endif 105#endif
106 106
107#ifdef QPE_OWNAPM 107#ifdef QPE_OWNAPM
108#include <sys/ioctl.h> 108#include <sys/ioctl.h>
109#include <sys/types.h> 109#include <sys/types.h>
110#include <fcntl.h> 110#include <fcntl.h>
111#include <unistd.h> 111#include <unistd.h>
112#include <errno.h> 112#include <errno.h>
113#include <linux/ioctl.h> 113#include <linux/ioctl.h>
114#include <qpe/global.h> 114#include <qpe/global.h>
115 115
116static void disableAPM() 116static void disableAPM()
117{ 117{
118 118
119 int fd, cur_val, ret; 119 int fd, cur_val, ret;
120 char *device = "/dev/apm_bios"; 120 char *device = "/dev/apm_bios";
121 121
122 fd = open (device, O_WRONLY); 122 fd = open (device, O_WRONLY);
123 123
124 if (fd == -1) { 124 if (fd == -1) {
125 perror(device); 125 perror(device);
126 return; 126 return;
127 } 127 }
128 128
129 cur_val = ioctl(fd, APM_IOCGEVTSRC, 0); 129 cur_val = ioctl(fd, APM_IOCGEVTSRC, 0);
130 if (cur_val == -1) { 130 if (cur_val == -1) {
131 perror("ioctl"); 131 perror("ioctl");
132 exit(errno); 132 exit(errno);
133 } 133 }
134 134
135 ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON); 135 ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON);
136 if (ret == -1) { 136 if (ret == -1) {
137 perror("ioctl"); 137 perror("ioctl");
138 return; 138 return;
139 } 139 }
140 close(fd); 140 close(fd);
141} 141}
142 142
143static void initAPM() 143static void initAPM()
144{ 144{
145 // So that we have to do it ourself, but better. 145 // So that we have to do it ourself, but better.
146 disableAPM(); 146 disableAPM();
147} 147}
148#endif 148#endif
149 149
150#ifdef QT_DEMO_SINGLE_FLOPPY 150#ifdef QT_DEMO_SINGLE_FLOPPY
151#include <sys/mount.h> 151#include <sys/mount.h>
152 152
153void initFloppy() 153void initFloppy()
154{ 154{
155 mount("none","/proc","proc",0,0); 155 mount("none","/proc","proc",0,0);
156 setenv( "QTDIR", "/", 0 ); 156 setenv( "QTDIR", "/", 0 );
157 setenv( "HOME", "/root", 0 ); 157 setenv( "HOME", "/root", 0 );
158 setenv( "QWS_SIZE", "240x320", 0 ); 158 setenv( "QWS_SIZE", "240x320", 0 );
159} 159}
160#endif 160#endif
161 161
162 162
163void initEnvironment() 163void initEnvironment()
164{ 164{
165 Config config("locale"); 165 Config config("locale");
166 config.setGroup( "Location" ); 166 config.setGroup( "Location" );
167 QString tz = config.readEntry( "Timezone", getenv("TZ") ); 167 QString tz = config.readEntry( "Timezone", getenv("TZ") );
168 168
169 // if not timezone set, pick New York 169 // if not timezone set, pick New York
170 if (tz.isNull()) 170 if (tz.isNull())
171 tz = "America/New_York"; 171 tz = "America/New_York";
172 172
173 setenv( "TZ", tz, 1 ); 173 setenv( "TZ", tz, 1 );
174 config.writeEntry( "Timezone", tz); 174 config.writeEntry( "Timezone", tz);
175 175
176 config.setGroup( "Language" ); 176 config.setGroup( "Language" );
177 QString lang = config.readEntry( "Language", getenv("LANG") ); 177 QString lang = config.readEntry( "Language", getenv("LANG") );
178 if ( !lang.isNull() ) 178 if ( !lang.isNull() )
179 setenv( "LANG", lang, 1 ); 179 setenv( "LANG", lang, 1 );
180} 180}
181 181
182static void initBacklight() 182static void initBacklight()
183{ 183{
184 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 184 QCopEnvelope e("QPE/System", "setBacklight(int)" );
185 e << -3; // Forced on 185 e << -3; // Forced on
186} 186}
187 187
188 188
189class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter 189class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter
190{ 190{
191public: 191public:
192 ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) 192 ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" )
193 { 193 {
194 bool doinst = false; 194 bool doinst = false;
195 195
196 m_model = OHwInfo::inst ( )-> model ( ); 196 m_model = ODevice::inst ( )-> model ( );
197 m_power_timer = 0; 197 m_power_timer = 0;
198 198
199 switch ( m_model ) { 199 switch ( m_model ) {
200 case OMODEL_iPAQ_H31xx: 200 case OMODEL_iPAQ_H31xx:
201 case OMODEL_iPAQ_H36xx: 201 case OMODEL_iPAQ_H36xx:
202 case OMODEL_iPAQ_H37xx: 202 case OMODEL_iPAQ_H37xx:
203 case OMODEL_iPAQ_H38xx: doinst = true; 203 case OMODEL_iPAQ_H38xx: doinst = true;
204 break; 204 break;
205 default : break; 205 default : break;
206 } 206 }
207 if ( doinst ) 207 if ( doinst )
208 QWSServer::setKeyboardFilter ( this ); 208 QWSServer::setKeyboardFilter ( this );
209 } 209 }
210 210
211 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) 211 virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
212 { 212 {
213 bool kill = false; 213 bool kill = false;
214 214
215 // Rotate cursor keys 180° 215 // Rotate cursor keys 180°
216 switch ( m_model ) { 216 switch ( m_model ) {
217 case OMODEL_iPAQ_H31xx: 217 case OMODEL_iPAQ_H31xx:
218 case OMODEL_iPAQ_H38xx: { 218 case OMODEL_iPAQ_H38xx: {
219 int newkeycode = keycode; 219 int newkeycode = keycode;
220 220
221 switch ( keycode ) { 221 switch ( keycode ) {
222 case Key_Left : newkeycode = Key_Right; break; 222 case Key_Left : newkeycode = Key_Right; break;
223 case Key_Right: newkeycode = Key_Left; break; 223 case Key_Right: newkeycode = Key_Left; break;
224 case Key_Up : newkeycode = Key_Down; break; 224 case Key_Up : newkeycode = Key_Down; break;
225 case Key_Down : newkeycode = Key_Up; break; 225 case Key_Down : newkeycode = Key_Up; break;
226 } 226 }
227 if ( newkeycode != keycode ) { 227 if ( newkeycode != keycode ) {
228 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 228 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
229 kill = true; 229 kill = true;
230 } 230 }
231 break; 231 break;
232 } 232 }
233 default: break; 233 default: break;
234 } 234 }
235 235
236 // map Power Button short/long press to F34/F35 236 // map Power Button short/long press to F34/F35
237 switch ( m_model ) { 237 switch ( m_model ) {
238 case OMODEL_iPAQ_H31xx: 238 case OMODEL_iPAQ_H31xx:
239 case OMODEL_iPAQ_H36xx: 239 case OMODEL_iPAQ_H36xx:
240 case OMODEL_iPAQ_H37xx: 240 case OMODEL_iPAQ_H37xx:
241 case OMODEL_iPAQ_H38xx: { 241 case OMODEL_iPAQ_H38xx: {
242 if ( keycode == Key_SysReq ) { 242 if ( keycode == Key_SysReq ) {
243 if ( isPress ) { 243 if ( isPress ) {
244 m_power_timer = startTimer ( 500 ); 244 m_power_timer = startTimer ( 500 );
245 } 245 }
246 else if ( m_power_timer ) { 246 else if ( m_power_timer ) {
247 killTimer ( m_power_timer ); 247 killTimer ( m_power_timer );
248 m_power_timer = 0; 248 m_power_timer = 0;
249 QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); 249 QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false );
250 QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); 250 QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false );
251 } 251 }
252 kill = true; 252 kill = true;
253 } 253 }
254 break; 254 break;
255 } 255 }
256 default: break; 256 default: break;
257 } 257 }
258 return kill; 258 return kill;
259 } 259 }
260 260
261 virtual void timerEvent ( QTimerEvent * ) 261 virtual void timerEvent ( QTimerEvent * )
262 { 262 {
263 killTimer ( m_power_timer ); 263 killTimer ( m_power_timer );
264 m_power_timer = 0; 264 m_power_timer = 0;
265 QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); 265 QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false );
266 QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); 266 QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false );
267 } 267 }
268 268
269private: 269private:
270 OHwModel m_model; 270 OModel m_model;
271 bool m_power_press; 271 int m_power_timer;
272 int m_power_timer;
273}; 272};
274 273
275 274
276 275
277int initApplication( int argc, char ** argv ) 276int initApplication( int argc, char ** argv )
278{ 277{
279#ifdef QT_QWS_CASSIOPEIA 278#ifdef QT_QWS_CASSIOPEIA
280 initCassiopeia(); 279 initCassiopeia();
281#endif 280#endif
282 281
283#ifdef QPE_OWNAPM 282#ifdef QPE_OWNAPM
284 initAPM(); 283 initAPM();
285#endif 284#endif
286 285
287#ifdef QT_DEMO_SINGLE_FLOPPY 286#ifdef QT_DEMO_SINGLE_FLOPPY
288 initFloppy(); 287 initFloppy();
289#endif 288#endif
290 289
291 initEnvironment(); 290 initEnvironment();
292 291
293#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) 292#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX)
294 setenv( "QWS_SIZE", "240x320", 0 ); 293 setenv( "QWS_SIZE", "240x320", 0 );
295#endif 294#endif
296 295
297 //Don't flicker at startup: 296 //Don't flicker at startup:
298 QWSServer::setDesktopBackground( QImage() ); 297 QWSServer::setDesktopBackground( QImage() );
299 DesktopApplication a( argc, argv, QApplication::GuiServer ); 298 DesktopApplication a( argc, argv, QApplication::GuiServer );
300 299
301 (void) new ModelKeyFilter ( ); 300 (void) new ModelKeyFilter ( );
302 301
303 initBacklight(); 302 initBacklight();
304 303
305 AlarmServer::initialize(); 304 AlarmServer::initialize();
306 305
307#if defined(QT_QWS_LOGIN) 306#if defined(QT_QWS_LOGIN)
308 for( int i=0; i<a.argc(); i++ ) 307 for( int i=0; i<a.argc(); i++ )
309 if( strcmp( a.argv()[i], "-login" ) == 0 ) { 308 if( strcmp( a.argv()[i], "-login" ) == 0 ) {
310 QDMDialogImpl::login( ); 309 QDMDialogImpl::login( );
311 return 0; 310 return 0;
312 } 311 }
313#endif 312#endif
314 313
315 Desktop *d = new Desktop(); 314 Desktop *d = new Desktop();
316 315
317 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); 316 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) );
318 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); 317 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) );
319 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); 318 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) );
320 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); 319 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) );
321 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); 320 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) );
322 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); 321 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) );
323 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); 322 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) );
324 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); 323 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) );
325 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); 324 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) );
326 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); 325 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) );
327 326
328 (void)new SysFileMonitor(d); 327 (void)new SysFileMonitor(d);
329 Network::createServer(d); 328 Network::createServer(d);
330 329
331#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 330#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
332 if ( !QFile::exists( "/etc/pointercal" ) ) { 331 if ( !QFile::exists( "/etc/pointercal" ) ) {
333 // Make sure calibration widget starts on top. 332 // Make sure calibration widget starts on top.
334 Calibrate *cal = new Calibrate; 333 Calibrate *cal = new Calibrate;
335 cal->exec(); 334 cal->exec();
336 delete cal; 335 delete cal;
337 } 336 }
338#endif 337#endif
339 338
340 d->show(); 339 d->show();
341 340
342 int rv = a.exec(); 341 int rv = a.exec();
343 342
344 delete d; 343 delete d;
345 344
346 return rv; 345 return rv;
347} 346}
348 347
349int main( int argc, char ** argv ) 348int main( int argc, char ** argv )
350{ 349{
351#ifndef SINGLE_APP 350#ifndef SINGLE_APP
352 signal( SIGCHLD, SIG_IGN ); 351 signal( SIGCHLD, SIG_IGN );
353#endif 352#endif
354 353
355 int retVal = initApplication( argc, argv ); 354 int retVal = initApplication( argc, argv );
356 355
357#ifndef SINGLE_APP 356#ifndef SINGLE_APP
358 // Kill them. Kill them all. 357 // Kill them. Kill them all.
359 setpgid( getpid(), getppid() ); 358 setpgid( getpid(), getppid() );
360 killpg( getpid(), SIGTERM ); 359 killpg( getpid(), SIGTERM );
361 sleep( 1 ); 360 sleep( 1 );
362 killpg( getpid(), SIGKILL ); 361 killpg( getpid(), SIGKILL );
363#endif 362#endif
364 363
365 return retVal; 364 return retVal;
366} 365}
367 366
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 5e95c99..e38b9fe 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -1,315 +1,316 @@
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 "startmenu.h" 21#include "startmenu.h"
22#include "inputmethods.h" 22#include "inputmethods.h"
23#include "mrulist.h" 23#include "mrulist.h"
24#include "systray.h" 24#include "systray.h"
25#include "calibrate.h" 25#include "calibrate.h"
26#include "wait.h" 26#include "wait.h"
27#include "appicons.h" 27#include "appicons.h"
28 28
29#include "taskbar.h" 29#include "taskbar.h"
30#include "desktop.h" 30#include "desktop.h"
31 31
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
34#include <qpe/global.h> 34#include <qpe/global.h>
35 35
36#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 36#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
37#include <qpe/custom.h> 37#include <qpe/custom.h>
38#endif 38#endif
39 39
40#include <opie/odevice.h>
41
40#include <qlabel.h> 42#include <qlabel.h>
41#include <qlayout.h> 43#include <qlayout.h>
42#include <qtimer.h> 44#include <qtimer.h>
43#include <qwindowsystem_qws.h> 45#include <qwindowsystem_qws.h>
44#include <qwidgetstack.h> 46#include <qwidgetstack.h>
45 47
46#if defined( Q_WS_QWS ) 48#if defined( Q_WS_QWS )
47#include <qwsdisplay_qws.h> 49#include <qwsdisplay_qws.h>
48#include <qgfx_qws.h> 50#include <qgfx_qws.h>
49#endif 51#endif
50 52
51 53
52#define FACTORY(T) \ 54#define FACTORY(T) \
53 static QWidget *new##T( bool maximized ) { \ 55 static QWidget *new##T( bool maximized ) { \
54 QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ 56 QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \
55 if ( maximized ) { \ 57 if ( maximized ) { \
56 if ( qApp->desktop()->width() <= 350 ) { \ 58 if ( qApp->desktop()->width() <= 350 ) { \
57 w->showMaximized(); \ 59 w->showMaximized(); \
58 } else { \ 60 } else { \
59 w->resize( QSize( 300, 300 ) ); \ 61 w->resize( QSize( 300, 300 ) ); \
60 } \ 62 } \
61 } \ 63 } \
62 w->show(); \ 64 w->show(); \
63 return w; \ 65 return w; \
64 } 66 }
65 67
66 68
67#ifdef SINGLE_APP 69#ifdef SINGLE_APP
68#define APP(a,b,c,d) FACTORY(b) 70#define APP(a,b,c,d) FACTORY(b)
69#include "../launcher/apps.h" 71#include "../launcher/apps.h"
70#undef APP 72#undef APP
71#endif // SINGLE_APP 73#endif // SINGLE_APP
72 74
73static Global::Command builtins[] = { 75static Global::Command builtins[] = {
74 76
75#ifdef SINGLE_APP 77#ifdef SINGLE_APP
76#define APP(a,b,c,d) { a, new##b, c }, 78#define APP(a,b,c,d) { a, new##b, c },
77#include "../launcher/apps.h" 79#include "../launcher/apps.h"
78#undef APP 80#undef APP
79#endif 81#endif
80 82
81#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX) 83#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX)
82 { "calibrate", TaskBar::calibrate, 1, 0 }, 84 { "calibrate", TaskBar::calibrate, 1, 0 },
83#endif 85#endif
84#if !defined(QT_QWS_CASSIOPEIA) 86#if !defined(QT_QWS_CASSIOPEIA)
85 { "shutdown", Global::shutdown, 1, 0 }, 87 { "shutdown", Global::shutdown, 1, 0 },
86// { "run", run, 1, 0 }, 88// { "run", run, 1, 0 },
87#endif 89#endif
88 90
89 { 0, TaskBar::calibrate, 0, 0 }, 91 { 0, TaskBar::calibrate, 0, 0 },
90}; 92};
91 93
92static bool initNumLock() 94static bool initNumLock()
93{ 95{
94#ifdef QPE_INITIAL_NUMLOCK_STATE 96#ifdef QPE_INITIAL_NUMLOCK_STATE
95 QPE_INITIAL_NUMLOCK_STATE 97 QPE_INITIAL_NUMLOCK_STATE
96#endif 98#endif
97 return FALSE; 99 return FALSE;
98} 100}
99 101
100class LockKeyState : public QWidget 102class LockKeyState : public QWidget
101{ 103{
102public: 104public:
103 LockKeyState( QWidget *parent ) : 105 LockKeyState( QWidget *parent ) :
104 QWidget(parent), 106 QWidget(parent),
105 nl(initNumLock()), cl(FALSE) 107 nl(initNumLock()), cl(FALSE)
106 { 108 {
107 nl_pm = Resource::loadPixmap("numlock"); 109 nl_pm = Resource::loadPixmap("numlock");
108 cl_pm = Resource::loadPixmap("capslock"); 110 cl_pm = Resource::loadPixmap("capslock");
109 } 111 }
110 QSize sizeHint() const 112 QSize sizeHint() const
111 { 113 {
112 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); 114 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
113 } 115 }
114 void toggleNumLockState() 116 void toggleNumLockState()
115 { 117 {
116 nl = !nl; repaint(); 118 nl = !nl; repaint();
117 } 119 }
118 void toggleCapsLockState() 120 void toggleCapsLockState()
119 { 121 {
120 cl = !cl; repaint(); 122 cl = !cl; repaint();
121 } 123 }
122 void paintEvent( QPaintEvent * ) 124 void paintEvent( QPaintEvent * )
123 { 125 {
124 int y = (height()-sizeHint().height())/2; 126 int y = (height()-sizeHint().height())/2;
125 QPainter p(this); 127 QPainter p(this);
126 if ( nl ) 128 if ( nl )
127 p.drawPixmap(1,y,nl_pm); 129 p.drawPixmap(1,y,nl_pm);
128 if ( cl ) 130 if ( cl )
129 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); 131 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
130 } 132 }
131private: 133private:
132 QPixmap nl_pm, cl_pm; 134 QPixmap nl_pm, cl_pm;
133 bool nl, cl; 135 bool nl, cl;
134}; 136};
135 137
136TaskBar::~TaskBar() 138TaskBar::~TaskBar()
137{ 139{
138} 140}
139 141
140 142
141TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) 143TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader)
142{ 144{
143 Global::setBuiltinCommands(builtins); 145 Global::setBuiltinCommands(builtins);
144 146
145 sm = new StartMenu( this ); 147 sm = new StartMenu( this );
146 148
147 inputMethods = new InputMethods( this ); 149 inputMethods = new InputMethods( this );
148 connect( inputMethods, SIGNAL(inputToggled(bool)), 150 connect( inputMethods, SIGNAL(inputToggled(bool)),
149 this, SLOT(calcMaxWindowRect()) ); 151 this, SLOT(calcMaxWindowRect()) );
150 //new QuickLauncher( this ); 152 //new QuickLauncher( this );
151 153
152 stack = new QWidgetStack( this ); 154 stack = new QWidgetStack( this );
153 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 155 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
154 label = new QLabel(stack); 156 label = new QLabel(stack);
155 157
156 mru = new MRUList( stack ); 158 mru = new MRUList( stack );
157 stack->raiseWidget( mru ); 159 stack->raiseWidget( mru );
158 160
159 waitIcon = new Wait( this ); 161 waitIcon = new Wait( this );
160 (void) new AppIcons( this ); 162 (void) new AppIcons( this );
161 163
162 sysTray = new SysTray( this ); 164 sysTray = new SysTray( this );
163 165
164 // ## make customizable in some way? 166 // ## make customizable in some way?
165#ifdef QT_QWS_CUSTOM 167#ifdef QT_QWS_CUSTOM
166 lockState = new LockKeyState( this ); 168 lockState = new LockKeyState( this );
167#else 169#else
168 lockState = 0; 170 lockState = 0;
169#endif 171#endif
170 172
171#if defined(Q_WS_QWS) 173#if defined(Q_WS_QWS)
172#if !defined(QT_NO_COP) 174#if !defined(QT_NO_COP)
173 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); 175 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this );
174 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 176 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
175 this, SLOT(receive(const QCString&, const QByteArray&)) ); 177 this, SLOT(receive(const QCString&, const QByteArray&)) );
176#endif 178#endif
177#endif 179#endif
178 waitTimer = new QTimer( this ); 180 waitTimer = new QTimer( this );
179 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); 181 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) );
180 clearer = new QTimer( this ); 182 clearer = new QTimer( this );
181 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); 183 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar()));
182 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); 184 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show()));
183} 185}
184 186
185void TaskBar::setStatusMessage( const QString &text ) 187void TaskBar::setStatusMessage( const QString &text )
186{ 188{
187 label->setText( text ); 189 label->setText( text );
188 stack->raiseWidget( label ); 190 stack->raiseWidget( label );
189 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) 191 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) )
190 sysTray->hide(); 192 sysTray->hide();
191 clearer->start( 3000 ); 193 clearer->start( 3000 );
192} 194}
193 195
194void TaskBar::clearStatusBar() 196void TaskBar::clearStatusBar()
195{ 197{
196 label->clear(); 198 label->clear();
197 stack->raiseWidget( mru ); 199 stack->raiseWidget( mru );
198} 200}
199 201
200void TaskBar::startWait() 202void TaskBar::startWait()
201{ 203{
202 waitIcon->setWaiting( true ); 204 waitIcon->setWaiting( true );
203 // a catchall stop after 10 seconds... 205 // a catchall stop after 10 seconds...
204 waitTimer->start( 10 * 1000, true ); 206 waitTimer->start( 10 * 1000, true );
205} 207}
206 208
207void TaskBar::stopWait(const QString& app) 209void TaskBar::stopWait(const QString& app)
208{ 210{
209 waitTimer->stop(); 211 waitTimer->stop();
210 mru->addTask(sm->execToLink(app)); 212 mru->addTask(sm->execToLink(app));
211 waitIcon->setWaiting( false ); 213 waitIcon->setWaiting( false );
212} 214}
213 215
214void TaskBar::stopWait() 216void TaskBar::stopWait()
215{ 217{
216 waitTimer->stop(); 218 waitTimer->stop();
217 waitIcon->setWaiting( false ); 219 waitIcon->setWaiting( false );
218} 220}
219 221
220void TaskBar::resizeEvent( QResizeEvent *e ) 222void TaskBar::resizeEvent( QResizeEvent *e )
221{ 223{
222 QHBox::resizeEvent( e ); 224 QHBox::resizeEvent( e );
223 calcMaxWindowRect(); 225 calcMaxWindowRect();
224} 226}
225 227
226void TaskBar::styleChange( QStyle &s ) 228void TaskBar::styleChange( QStyle &s )
227{ 229{
228 QHBox::styleChange( s ); 230 QHBox::styleChange( s );
229 calcMaxWindowRect(); 231 calcMaxWindowRect();
230} 232}
231 233
232void TaskBar::calcMaxWindowRect() 234void TaskBar::calcMaxWindowRect()
233{ 235{
234#ifdef Q_WS_QWS 236#ifdef Q_WS_QWS
235 QRect wr; 237 QRect wr;
236 int displayWidth = qApp->desktop()->width(); 238 int displayWidth = qApp->desktop()->width();
237 QRect ir = inputMethods->inputRect(); 239 QRect ir = inputMethods->inputRect();
238 if ( ir.isValid() ) { 240 if ( ir.isValid() ) {
239 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 241 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
240 } else { 242 } else {
241 wr.setCoords( 0, 0, displayWidth-1, y()-1 ); 243 wr.setCoords( 0, 0, displayWidth-1, y()-1 );
242 } 244 }
243 245
244#if QT_VERSION < 300 246#if QT_VERSION < 300
245 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, 247 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
246 QSize(qt_screen->width(),qt_screen->height())) 248 QSize(qt_screen->width(),qt_screen->height()))
247 ); 249 );
248#else 250#else
249 QWSServer::setMaxWindowRect( wr ); 251 QWSServer::setMaxWindowRect( wr );
250#endif 252#endif
251#endif 253#endif
252} 254}
253 255
254void TaskBar::receive( const QCString &msg, const QByteArray &data ) 256void TaskBar::receive( const QCString &msg, const QByteArray &data )
255{ 257{
256 QDataStream stream( data, IO_ReadOnly ); 258 QDataStream stream( data, IO_ReadOnly );
257 if ( msg == "message(QString)" ) { 259 if ( msg == "message(QString)" ) {
258 QString text; 260 QString text;
259 stream >> text; 261 stream >> text;
260 setStatusMessage( text ); 262 setStatusMessage( text );
261 } else if ( msg == "hideInputMethod()" ) { 263 } else if ( msg == "hideInputMethod()" ) {
262 inputMethods->hideInputMethod(); 264 inputMethods->hideInputMethod();
263 } else if ( msg == "showInputMethod()" ) { 265 } else if ( msg == "showInputMethod()" ) {
264 inputMethods->showInputMethod(); 266 inputMethods->showInputMethod();
265 } else if ( msg == "reloadInputMethods()" ) { 267 } else if ( msg == "reloadInputMethods()" ) {
266 inputMethods->loadInputMethods(); 268 inputMethods->loadInputMethods();
267 } else if ( msg == "reloadApplets()" ) { 269 } else if ( msg == "reloadApplets()" ) {
268 sysTray->loadApplets(); 270 sysTray->loadApplets();
269 } else if ( msg == "soundAlarm()" ) { 271 } else if ( msg == "soundAlarm()" ) {
270 Desktop::soundAlarm(); 272 Desktop::soundAlarm();
271 } 273 }
272#ifdef CUSTOM_LEDS 274 else if ( msg == "setLed(int,bool)" ) {
273 else if ( msg == "setLed(int,bool)" ) { 275 int led, status;
274 int led, status; 276 stream >> led >> status;
275 stream >> led >> status; 277
276 CUSTOM_LEDS( led, status ); 278 ODevice::inst ( )-> setLed ( led, status ? OLED_BlinkSlow : OLED_Off );
277 } 279 }
278#endif
279} 280}
280 281
281QWidget *TaskBar::calibrate(bool) 282QWidget *TaskBar::calibrate(bool)
282{ 283{
283#ifdef Q_WS_QWS 284#ifdef Q_WS_QWS
284 Calibrate *c = new Calibrate; 285 Calibrate *c = new Calibrate;
285 c->show(); 286 c->show();
286 return c; 287 return c;
287#else 288#else
288 return 0; 289 return 0;
289#endif 290#endif
290} 291}
291 292
292void TaskBar::toggleNumLockState() 293void TaskBar::toggleNumLockState()
293{ 294{
294 if ( lockState ) lockState->toggleNumLockState(); 295 if ( lockState ) lockState->toggleNumLockState();
295} 296}
296 297
297void TaskBar::toggleCapsLockState() 298void TaskBar::toggleCapsLockState()
298{ 299{
299 if ( lockState ) lockState->toggleCapsLockState(); 300 if ( lockState ) lockState->toggleCapsLockState();
300} 301}
301 302
302void TaskBar::toggleSymbolInput() 303void TaskBar::toggleSymbolInput()
303{ 304{
304 if ( inputMethods->currentShown() == "Unicode" ) { 305 if ( inputMethods->currentShown() == "Unicode" ) {
305 inputMethods->hideInputMethod(); 306 inputMethods->hideInputMethod();
306 } else { 307 } else {
307 inputMethods->showInputMethod("Unicode"); 308 inputMethods->showInputMethod("Unicode");
308 } 309 }
309} 310}
310 311
311bool TaskBar::recoverMemory() 312bool TaskBar::recoverMemory()
312{ 313{
313 return mru->quitOldApps(); 314 return mru->quitOldApps();
314} 315}
315 316
diff --git a/core/launcher/taskbar.h b/core/launcher/taskbar.h
index 78c4722..40983af 100644
--- a/core/launcher/taskbar.h
+++ b/core/launcher/taskbar.h
@@ -1,86 +1,82 @@
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#ifndef __TASKBAR_H__ 21#ifndef __TASKBAR_H__
22#define __TASKBAR_H__ 22#define __TASKBAR_H__
23 23
24#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
25#include <qpe/custom.h>
26#endif
27
28#include <qhbox.h> 24#include <qhbox.h>
29 25
30class QLabel; 26class QLabel;
31class QTimer; 27class QTimer;
32class InputMethods; 28class InputMethods;
33class Wait; 29class Wait;
34class SysTray; 30class SysTray;
35class MRUList; 31class MRUList;
36class QWidgetStack; 32class QWidgetStack;
37class QTimer; 33class QTimer;
38class QLabel; 34class QLabel;
39class StartMenu; 35class StartMenu;
40class LockKeyState; 36class LockKeyState;
41 37
42class TaskBar : public QHBox { 38class TaskBar : public QHBox {
43 Q_OBJECT 39 Q_OBJECT
44public: 40public:
45 TaskBar(); 41 TaskBar();
46 ~TaskBar(); 42 ~TaskBar();
47 43
48 static QWidget *calibrate( bool ); 44 static QWidget *calibrate( bool );
49 45
50 bool recoverMemory(); 46 bool recoverMemory();
51 47
52 StartMenu *startMenu() const { return sm; } 48 StartMenu *startMenu() const { return sm; }
53public slots: 49public slots:
54 void startWait(); 50 void startWait();
55 void stopWait(const QString&); 51 void stopWait(const QString&);
56 void stopWait(); 52 void stopWait();
57 void clearStatusBar(); 53 void clearStatusBar();
58 void toggleNumLockState(); 54 void toggleNumLockState();
59 void toggleCapsLockState(); 55 void toggleCapsLockState();
60 void toggleSymbolInput(); 56 void toggleSymbolInput();
61 57
62protected: 58protected:
63 void resizeEvent( QResizeEvent * ); 59 void resizeEvent( QResizeEvent * );
64 void styleChange( QStyle & ); 60 void styleChange( QStyle & );
65 void setStatusMessage( const QString &text ); 61 void setStatusMessage( const QString &text );
66 62
67private slots: 63private slots:
68 void calcMaxWindowRect(); 64 void calcMaxWindowRect();
69 void receive( const QCString &msg, const QByteArray &data ); 65 void receive( const QCString &msg, const QByteArray &data );
70 66
71private: 67private:
72 68
73 QTimer *waitTimer; 69 QTimer *waitTimer;
74 Wait *waitIcon; 70 Wait *waitIcon;
75 InputMethods *inputMethods; 71 InputMethods *inputMethods;
76 SysTray *sysTray; 72 SysTray *sysTray;
77 MRUList *mru; 73 MRUList *mru;
78 QWidgetStack *stack; 74 QWidgetStack *stack;
79 QTimer *clearer; 75 QTimer *clearer;
80 QLabel *label; 76 QLabel *label;
81 LockKeyState* lockState; 77 LockKeyState* lockState;
82 StartMenu *sm; 78 StartMenu *sm;
83}; 79};
84 80
85 81
86#endif // __TASKBAR_H__ 82#endif // __TASKBAR_H__