summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp1244
-rw-r--r--core/launcher/desktop.h133
2 files changed, 803 insertions, 574 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index dee5535..a19e4c6 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -37,6 +37,7 @@
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/network.h>
40#include <qpe/global.h> 41#include <qpe/global.h>
41 42
42#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 43#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
@@ -55,41 +56,53 @@
55 56
56#include <stdlib.h> 57#include <stdlib.h>
57#include <unistd.h> 58#include <unistd.h>
59#include <fcntl.h>
58 60
59class QCopKeyRegister 61class QCopKeyRegister
60{ 62{
61public: 63public:
62 QCopKeyRegister() : keyCode(0) { } 64 QCopKeyRegister() : keyCode( 0 )
63 QCopKeyRegister(int k, const QString &c, const QString &m) 65 { }
64 : keyCode(k), channel(c), message(m) { } 66 QCopKeyRegister( int k, const QString &c, const QString &m )
65 67 : keyCode( k ), channel( c ), message( m )
66 int getKeyCode() const { return keyCode; } 68 { }
67 QString getChannel() const { return channel; } 69
68 QString getMessage() const { return message; } 70 int getKeyCode() const
71 {
72 return keyCode;
73 }
74 QString getChannel() const
75 {
76 return channel;
77 }
78 QString getMessage() const
79 {
80 return message;
81 }
69 82
70private: 83private:
71 int keyCode; 84 int keyCode;
72 QString channel, message; 85 QString channel, message;
73}; 86};
74 87
75typedef QValueList<QCopKeyRegister> KeyRegisterList; 88typedef QValueList<QCopKeyRegister> KeyRegisterList;
76KeyRegisterList keyRegisterList; 89KeyRegisterList keyRegisterList;
77 90
78static Desktop* qpedesktop = 0; 91static Desktop* qpedesktop = 0;
79static int loggedin=0; 92static int loggedin = 0;
80static void login(bool at_poweron) 93static void login( bool at_poweron )
81{ 94{
82 if ( !loggedin ) { 95 if ( !loggedin ) {
83 Global::terminateBuiltin("calibrate"); 96 Global::terminateBuiltin( "calibrate" );
84 Password::authenticate(at_poweron); 97 Password::authenticate( at_poweron );
85 loggedin=1; 98 loggedin = 1;
86 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 99 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
87 } 100 }
88} 101}
89 102
90bool Desktop::screenLocked() 103bool Desktop::screenLocked()
91{ 104{
92 return loggedin == 0; 105 return loggedin == 0;
93} 106}
94 107
95/* 108/*
@@ -99,235 +112,461 @@ bool Desktop::screenLocked()
99class DesktopPowerAlerter : public QMessageBox 112class DesktopPowerAlerter : public QMessageBox
100{ 113{
101public: 114public:
102 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 115 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
103 : QMessageBox( tr("Battery Status"), "Low Battery", 116 : QMessageBox( tr( "Battery Status" ), "Low Battery",
104 QMessageBox::Critical, 117 QMessageBox::Critical,
105 QMessageBox::Ok | QMessageBox::Default, 118 QMessageBox::Ok | QMessageBox::Default,
106 QMessageBox::NoButton, QMessageBox::NoButton, 119 QMessageBox::NoButton, QMessageBox::NoButton,
107 parent, name, FALSE ) 120 parent, name, FALSE )
108 { 121 {
109 currentPriority = INT_MAX; 122 currentPriority = INT_MAX;
110 alertCount = 0; 123 alertCount = 0;
111 } 124 }
112 125
113 void alert( const QString &text, int priority ); 126 void alert( const QString &text, int priority );
114 void hideEvent( QHideEvent * ); 127 void hideEvent( QHideEvent * );
115private: 128private:
116 int currentPriority; 129 int currentPriority;
117 int alertCount; 130 int alertCount;
118}; 131};
119 132
120void DesktopPowerAlerter::alert( const QString &text, int priority ) 133void DesktopPowerAlerter::alert( const QString &text, int priority )
121{ 134{
122 alertCount++; 135 alertCount++;
123 if ( alertCount < priority ) 136 if ( alertCount < priority )
124 return; 137 return ;
125 if ( priority > currentPriority ) 138 if ( priority > currentPriority )
126 return; 139 return ;
127 currentPriority = priority; 140 currentPriority = priority;
128 setText( text ); 141 setText( text );
129 show(); 142 show();
130} 143}
131 144
132 145
133void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 146void DesktopPowerAlerter::hideEvent( QHideEvent *e )
134{ 147{
135 QMessageBox::hideEvent( e ); 148 QMessageBox::hideEvent( e );
136 alertCount = 0; 149 alertCount = 0;
137 currentPriority = INT_MAX; 150 currentPriority = INT_MAX;
138} 151}
139 152
140 153
154class QPEScreenSaver : public QWSScreenSaver
155{
156private:
157 int LcdOn;
158
159public:
160 QPEScreenSaver()
161 {
162 m_disable_suspend = 100;
163 m_enable_dim = false;
164 m_enable_lightoff = false;
165 m_enable_onlylcdoff = false;
166
167 m_lcd_status = true;
168
169 m_backlight_bright = -1;
170 m_backlight_forcedoff = false;
171
172 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
173 ODevice::inst ( ) -> setDisplayStatus ( true );
174 }
175 void restore()
176 {
177 if ( !m_lcd_status ) // We must have turned it off
178 ODevice::inst ( ) -> setDisplayStatus ( true );
179
180 setBacklight ( -1 );
181 }
182 bool save( int level )
183 {
184 switch ( level ) {
185 case 0:
186 if ( m_disable_suspend > 0 && m_enable_dim ) {
187 if ( backlight() > 1 )
188 setBacklight( 1 ); // lowest non-off
189 }
190 return true;
191 break;
192 case 1:
193 if ( m_disable_suspend > 1 && m_enable_lightoff ) {
194 setBacklight( 0 ); // off
195 }
196 return true;
197 break;
198 case 2:
199 if ( m_enable_onlylcdoff ) {
200 ODevice::inst ( ) -> setDisplayStatus ( false );
201 m_lcd_status = false;
202 return true;
203 }
204 else // We're going to suspend the whole machine
205 {
206 if ( ( m_disable_suspend > 2 ) &&
207 ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) &&
208 ( !Network::networkOnline ( ) ) ) {
209 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
210 return true;
211 }
212 }
213 break;
214 }
215 return false;
216 }
217
218private:
219 static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def )
220 {
221 if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 )
222 return 0;
223
224 if ( interval < 0 ) {
225 // Restore screen blanking and power saving state
226 interval = config.readNumEntry( value, def );
227 }
228 return interval;
229 }
230
231public:
232 void setIntervals( int i1, int i2, int i3 )
233 {
234 Config config( "qpe" );
235 config.setGroup( "Screensaver" );
236
237 int v[ 4 ];
238 i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 );
239 i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 );
240 i3 = ssi( i3, config, "", "Interval", 60 );
241
242 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
243
244 v [ 0 ] = QMAX( 1000 * i1, 100 );
245 v [ 1 ] = QMAX( 1000 * i2, 100 );
246 v [ 2 ] = QMAX( 1000 * i3, 100 );
247 v [ 3 ] = 0;
248 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false );
249 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false );
250 m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 );
251
252 if ( !i1 && !i2 && !i3 )
253 QWSServer::setScreenSaverInterval( 0 );
254 else
255 QWSServer::setScreenSaverIntervals( v );
256 }
257
258 void setInterval ( int interval )
259 {
260 setIntervals ( -1, -1, interval );
261 }
262
263 void setMode ( int mode )
264 {
265 if ( mode > m_disable_suspend )
266 setInterval( -1 );
267 m_disable_suspend = mode;
268 }
269
270 int backlight ( )
271 {
272 if ( m_backlight_bright == -1 ) {
273 // Read from config
274 Config config ( "qpe" );
275 config. setGroup ( "Screensaver" );
276 m_backlight_bright = config. readNumEntry ( "Brightness", 255 );
277 }
278 return m_backlight_bright;
279 }
280
281 void setBacklight ( int bright )
282 {
283 if ( bright == -3 ) {
284 // Forced on
285 m_backlight_forcedoff = false;
286 bright = -1;
287 }
288 if ( m_backlight_forcedoff && bright != -2 )
289 return ;
290 if ( bright == -2 ) {
291 // Toggle between off and on
292 bright = m_backlight_bright ? 0 : -1;
293 m_backlight_forcedoff = !bright;
294 }
295
296 m_backlight_bright = bright;
297
298 bright = backlight ( );
299 ODevice::inst ( ) -> setDisplayBrightness ( bright );
300
301 m_backlight_bright = bright;
302 }
303
304private:
305 int m_disable_suspend;
306 bool m_enable_dim;
307 bool m_enable_lightoff;
308 bool m_enable_onlylcdoff;
309
310 bool m_lcd_status;
311
312 int m_backlight_bright;
313 bool m_backlight_forcedoff;
314};
315
316
317void DesktopApplication::switchLCD ( bool on )
318{
319 if ( qApp ) {
320 DesktopApplication *dapp = (DesktopApplication *) qApp;
321
322 if ( dapp-> m_screensaver )
323 dapp-> m_screensaver-> setBacklight ( on ? -3 : -1 );
324 }
325}
326
141 327
142DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 328DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
143 : QPEApplication( argc, argv, appType ) 329 : QPEApplication( argc, argv, appType )
144{ 330{
145 331
146 QTimer *t = new QTimer( this ); 332 QTimer * t = new QTimer( this );
147 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 333 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) );
148 t->start( 10000 ); 334 t->start( 10000 );
149 ps = new PowerStatus; 335 ps = new PowerStatus;
150 pa = new DesktopPowerAlerter( 0 ); 336 pa = new DesktopPowerAlerter( 0 );
151 337
152 channel = new QCopChannel( "QPE/Desktop", this ); 338 channel = new QCopChannel( "QPE/Desktop", this );
153 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 339 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
154 this, SLOT(receive(const QCString&, const QByteArray&)) ); 340 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) );
341
342 channel = new QCopChannel( "QPE/System", this );
343 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
344 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
345
346 m_screensaver = new QPEScreenSaver;
347
348 m_screensaver-> setInterval ( -1 );
349 QWSServer::setScreenSaver( m_screensaver );
155} 350}
156 351
157 352
158DesktopApplication::~DesktopApplication() 353DesktopApplication::~DesktopApplication()
159{ 354{
160 delete ps; 355 delete ps;
161 delete pa; 356 delete pa;
162} 357}
163 358
164void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) 359void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data )
165{ 360{
166 QDataStream stream( data, IO_ReadOnly ); 361#ifdef Q_WS_QWS
167 if (msg == "keyRegister(int key, QString channel, QString message)") 362 QDataStream stream( data, IO_ReadOnly );
168 { 363 if ( msg == "keyRegister(int key, QString channel, QString message)" ) {
169 int k; 364 int k;
170 QString c, m; 365 QString c, m;
171 stream >> k; 366 stream >> k;
172 stream >> c; 367 stream >> c;
173 stream >> m; 368 stream >> m;
369
370 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m );
371 keyRegisterList.append( QCopKeyRegister( k, c, m ) );
372 }
373 else if ( msg == "suspend()" ) {
374 emit power();
375 }
376#endif
377}
174 378
175 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m );
176 keyRegisterList.append(QCopKeyRegister(k,c,m));
177 }
178 else if (msg == "suspend()"){
179 emit power();
180 }
181 379
380void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
381{
382#ifdef Q_WS_QWS
383 QDataStream stream ( data, IO_ReadOnly );
384
385 if ( msg == "setScreenSaverInterval(int)" ) {
386 int time;
387 stream >> time;
388 m_screensaver-> setInterval( time );
389 }
390 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
391 int t1, t2, t3;
392 stream >> t1 >> t2 >> t3;
393 m_screensaver-> setIntervals( t1, t2, t3 );
394 }
395 else if ( msg == "setBacklight(int)" ) {
396 int bright;
397 stream >> bright;
398 m_screensaver-> setBacklight( bright );
399 }
400 else if ( msg == "setScreenSaverMode(int)" ) {
401 int mode;
402 stream >> mode;
403 m_screensaver-> setMode ( mode );
404 }
405#endif
182} 406}
183 407
184enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 408enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
185 409
186#ifdef Q_WS_QWS 410#ifdef Q_WS_QWS
187bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 411bool DesktopApplication::qwsEventFilter( QWSEvent *e )
188{ 412{
189 qpedesktop->checkMemory(); 413 qpedesktop->checkMemory();
190 414
191 if ( e->type == QWSEvent::Key ) { 415 if ( e->type == QWSEvent::Key ) {
192 QWSKeyEvent *ke = (QWSKeyEvent *)e; 416 QWSKeyEvent * ke = ( QWSKeyEvent * ) e;
193 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 417 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
194 return TRUE; 418 return TRUE;
195 bool press = ke->simpleData.is_press; 419 bool press = ke->simpleData.is_press;
196 bool autoRepeat= ke->simpleData.is_auto_repeat; 420 bool autoRepeat = ke->simpleData.is_auto_repeat;
197 421
198 /* 422 /*
199 app that registers key/message to be sent back to the app, when it doesn't have focus, 423 app that registers key/message to be sent back to the app, when it doesn't have focus,
200 when user presses key, unless keyboard has been requested from app. 424 when user presses key, unless keyboard has been requested from app.
201 will not send multiple repeats if user holds key 425 will not send multiple repeats if user holds key
202 i.e. one shot 426 i.e. one shot
203 */ 427 */
204 if (!keyRegisterList.isEmpty()) { 428 if ( !keyRegisterList.isEmpty() ) {
205 KeyRegisterList::Iterator it; 429 KeyRegisterList::Iterator it;
206 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 430 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
207 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { 431 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press ) {
208 if(press) qDebug("press"); else qDebug("release"); 432 if ( press )
209 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 433 qDebug( "press" );
210 } 434 else
211 } 435 qDebug( "release" );
212 } 436 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() );
213 437 }
214 if ( !keyboardGrabbed() ) { 438 }
215 if ( ke->simpleData.keycode == Key_F9 ) { 439 }
216 if ( press ) emit datebook(); 440
217 return TRUE; 441 if ( !keyboardGrabbed() ) {
218 } 442 if ( ke->simpleData.keycode == Key_F9 ) {
219 if ( ke->simpleData.keycode == Key_F10 ) { 443 if ( press )
220 if ( !press && cardSendTimer ) { 444 emit datebook();
221 emit contacts(); 445 return TRUE;
222 delete cardSendTimer; 446 }
223 } else if ( press ) { 447 if ( ke->simpleData.keycode == Key_F10 ) {
224 cardSendTimer = new QTimer(); 448 if ( !press && cardSendTimer ) {
225 cardSendTimer->start( 2000, TRUE ); 449 emit contacts();
226 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 450 delete cardSendTimer;
227 } 451 }
228 return TRUE; 452 else if ( press ) {
229 } 453 cardSendTimer = new QTimer();
230 /* menu key now opens application menu/toolbar 454 cardSendTimer->start( 2000, TRUE );
231 if ( ke->simpleData.keycode == Key_F11 ) { 455 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
232 if ( press ) emit menu(); 456 }
233 return TRUE; 457 return TRUE;
234 } 458 }
235 */ 459 /* menu key now opens application menu/toolbar
236 if ( ke->simpleData.keycode == Key_F12 ) { 460 if ( ke->simpleData.keycode == Key_F11 ) {
237 while( activePopupWidget() ) 461 if ( press ) emit menu();
238 activePopupWidget()->close(); 462 return TRUE;
239 if ( press ) emit launch(); 463 }
240 return TRUE; 464 */
241 } 465 if ( ke->simpleData.keycode == Key_F12 ) {
242 if ( ke->simpleData.keycode == Key_F13 ) { 466 while ( activePopupWidget() )
243 if ( press ) emit email(); 467 activePopupWidget() ->close();
244 return TRUE; 468 if ( press )
245 } 469 emit launch();
246 } 470 return TRUE;
247 471 }
248 if ( ke->simpleData.keycode == Key_F34 ) { 472 if ( ke->simpleData.keycode == Key_F13 ) {
249 if ( press ) emit power(); 473 if ( press )
250 return TRUE; 474 emit email();
251 } 475 return TRUE;
252// This was used for the iPAQ PowerButton 476 }
253// See main.cpp for new KeyboardFilter 477 }
254// 478
255// if ( ke->simpleData.keycode == Key_SysReq ) { 479 if ( ke->simpleData.keycode == Key_F34 ) {
256// if ( press ) emit power(); 480 if ( press )
257// return TRUE; 481 emit power();
258// } 482 return TRUE;
259 if ( ke->simpleData.keycode == Key_F35 ) { 483 }
260 if ( press ) emit backlight(); 484 // This was used for the iPAQ PowerButton
261 return TRUE; 485 // See main.cpp for new KeyboardFilter
262 } 486 //
263 if ( ke->simpleData.keycode == Key_F32 ) { 487 // if ( ke->simpleData.keycode == Key_SysReq ) {
264 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 488 // if ( press ) emit power();
265 return TRUE; 489 // return TRUE;
266 } 490 // }
267 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 491 if ( ke->simpleData.keycode == Key_F35 ) {
268 if ( press ) emit symbol(); 492 if ( press )
269 return TRUE; 493 emit backlight();
270 } 494 return TRUE;
271 if ( ke->simpleData.keycode == Key_NumLock ) { 495 }
272 if ( press ) emit numLockStateToggle(); 496 if ( ke->simpleData.keycode == Key_F32 ) {
273 } 497 if ( press )
274 if ( ke->simpleData.keycode == Key_CapsLock ) { 498 QCopEnvelope e( "QPE/Desktop", "startSync()" );
275 if ( press ) emit capsLockStateToggle(); 499 return TRUE;
276 } 500 }
277 if (( press && !autoRepeat ) || ( !press && autoRepeat )) 501 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
278 qpedesktop->keyClick(); 502 if ( press )
279 } else { 503 emit symbol();
280 if ( e->type == QWSEvent::Mouse ) { 504 return TRUE;
281 QWSMouseEvent *me = (QWSMouseEvent *)e; 505 }
282 static bool up = TRUE; 506 if ( ke->simpleData.keycode == Key_NumLock ) {
283 if ( me->simpleData.state&LeftButton ) { 507 if ( press )
284 if ( up ) { 508 emit numLockStateToggle();
285 up = FALSE; 509 }
286 qpedesktop->screenClick(); 510 if ( ke->simpleData.keycode == Key_CapsLock ) {
287 } 511 if ( press )
288 } else { 512 emit capsLockStateToggle();
289 up = TRUE; 513 }
290 } 514 if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) )
291 } 515 qpedesktop->keyClick();
292 } 516 }
293 517 else {
294 return QPEApplication::qwsEventFilter( e ); 518 if ( e->type == QWSEvent::Mouse ) {
519 QWSMouseEvent * me = ( QWSMouseEvent * ) e;
520 static bool up = TRUE;
521 if ( me->simpleData.state & LeftButton ) {
522 if ( up ) {
523 up = FALSE;
524 qpedesktop->screenClick();
525 }
526 }
527 else {
528 up = TRUE;
529 }
530 }
531 }
532
533 return QPEApplication::qwsEventFilter( e );
295} 534}
296#endif 535#endif
297 536
298void DesktopApplication::psTimeout() 537void DesktopApplication::psTimeout()
299{ 538{
300 qpedesktop->checkMemory(); // in case no events are being generated 539 qpedesktop->checkMemory(); // in case no events are being generated
301 540
302 *ps = PowerStatusManager::readStatus(); 541 *ps = PowerStatusManager::readStatus();
303 542
304 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 543 if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) {
305 pa->alert( tr( "Battery is running very low." ), 6 ); 544 pa->alert( tr( "Battery is running very low." ), 6 );
306 } 545 }
307 546
308 if ( ps->batteryStatus() == PowerStatus::Critical ) { 547 if ( ps->batteryStatus() == PowerStatus::Critical ) {
309 pa->alert( tr( "Battery level is critical!\n" 548 pa->alert( tr( "Battery level is critical!\n"
310 "Keep power off until power restored!" ), 1 ); 549 "Keep power off until power restored!" ), 1 );
311 } 550 }
312 551
313 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 552 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
314 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 553 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
315 } 554 }
316} 555}
317 556
318 557
319void DesktopApplication::sendCard() 558void DesktopApplication::sendCard()
320{ 559{
321 delete cardSendTimer; 560 delete cardSendTimer;
322 cardSendTimer = 0; 561 cardSendTimer = 0;
323 QString card = getenv("HOME"); 562 QString card = getenv( "HOME" );
324 card += "/Applications/addressbook/businesscard.vcf"; 563 card += "/Applications/addressbook/businesscard.vcf";
325 564
326 if ( QFile::exists( card ) ) { 565 if ( QFile::exists( card ) ) {
327 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 566 QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" );
328 QString mimetype = "text/x-vCard"; 567 QString mimetype = "text/x-vCard";
329 e << tr("business card") << card << mimetype; 568 e << tr( "business card" ) << card << mimetype;
330 } 569 }
331} 570}
332 571
333#if defined(QPE_HAVE_MEMALERTER) 572#if defined(QPE_HAVE_MEMALERTER)
@@ -337,236 +576,240 @@ QPE_MEMALERTER_IMPL
337//=========================================================================== 576//===========================================================================
338 577
339Desktop::Desktop() : 578Desktop::Desktop() :
340 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 579 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
341 qcopBridge( 0 ), 580 qcopBridge( 0 ),
342 transferServer( 0 ), 581 transferServer( 0 ),
343 packageSlave( 0 ) 582 packageSlave( 0 )
344{ 583{
345 qpedesktop = this; 584 qpedesktop = this;
346 585
347// bg = new Info( this ); 586 // bg = new Info( this );
348 tb = new TaskBar; 587 tb = new TaskBar;
349 588
350 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 589 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
351 590
352 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 591 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) );
353 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 592 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) );
354 593
355 int displayw = qApp->desktop()->width(); 594 int displayw = qApp->desktop() ->width();
356 int displayh = qApp->desktop()->height(); 595 int displayh = qApp->desktop() ->height();
357 596
358 597
359 QSize sz = tb->sizeHint(); 598 QSize sz = tb->sizeHint();
360 599
361 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 600 setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
362 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 601 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
363 602
364 tb->show(); 603 tb->show();
365 launcher->showMaximized(); 604 launcher->showMaximized();
366 launcher->show(); 605 launcher->show();
367 launcher->raise(); 606 launcher->raise();
368#if defined(QPE_HAVE_MEMALERTER) 607#if defined(QPE_HAVE_MEMALERTER)
369 initMemalerter(); 608
609 initMemalerter();
370#endif 610#endif
371 // start services 611 // start services
372 startTransferServer(); 612 startTransferServer();
373 (void) new IrServer( this ); 613 ( void ) new IrServer( this );
374 rereadVolumes(); 614 rereadVolumes();
375 615
376 packageSlave = new PackageSlave( this ); 616 packageSlave = new PackageSlave( this );
377 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 617 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) );
378 618
379 qApp->installEventFilter( this ); 619 qApp->installEventFilter( this );
380} 620}
381 621
382void Desktop::show() 622void Desktop::show()
383{ 623{
384 login(TRUE); 624 login( TRUE );
385 QWidget::show(); 625 QWidget::show();
386} 626}
387 627
388Desktop::~Desktop() 628Desktop::~Desktop()
389{ 629{
390 delete launcher; 630 delete launcher;
391 delete tb; 631 delete tb;
392 delete qcopBridge; 632 delete qcopBridge;
393 delete transferServer; 633 delete transferServer;
394} 634}
395 635
396bool Desktop::recoverMemory() 636bool Desktop::recoverMemory()
397{ 637{
398 return tb->recoverMemory(); 638 return tb->recoverMemory();
399} 639}
400 640
401void Desktop::checkMemory() 641void Desktop::checkMemory()
402{ 642{
403#if defined(QPE_HAVE_MEMALERTER) 643#if defined(QPE_HAVE_MEMALERTER)
404 static bool ignoreNormal=FALSE; 644 static bool ignoreNormal = FALSE;
405 static bool existingMessage=FALSE; 645 static bool existingMessage = FALSE;
406 646
407 if(existingMessage) 647 if ( existingMessage )
408 return; // don't show a second message while still on first 648 return ; // don't show a second message while still on first
409 649
410 existingMessage = TRUE; 650 existingMessage = TRUE;
411 switch ( memstate ) { 651 switch ( memstate ) {
412 case Unknown: 652 case Unknown:
413 break; 653 break;
414 case Low: 654 case Low:
415 memstate = Unknown; 655 memstate = Unknown;
416 if ( recoverMemory() ) 656 if ( recoverMemory() )
417 ignoreNormal = TRUE; 657 ignoreNormal = TRUE;
418 else 658 else
419 QMessageBox::warning( 0 , "Memory Status", 659 QMessageBox::warning( 0 , "Memory Status",
420 "The memory smacks of shortage. \n" 660 "The memory smacks of shortage. \n"
421 "Please save data. " ); 661 "Please save data. " );
422 break; 662 break;
423 case Normal: 663 case Normal:
424 memstate = Unknown; 664 memstate = Unknown;
425 if ( ignoreNormal ) 665 if ( ignoreNormal )
426 ignoreNormal = FALSE; 666 ignoreNormal = FALSE;
427 else 667 else
428 QMessageBox::information ( 0 , "Memory Status", 668 QMessageBox::information ( 0 , "Memory Status",
429 "There is enough memory again." ); 669 "There is enough memory again." );
430 break; 670 break;
431 case VeryLow: 671 case VeryLow:
432 memstate = Unknown; 672 memstate = Unknown;
433 QMessageBox::critical( 0 , "Memory Status", 673 QMessageBox::critical( 0 , "Memory Status",
434 "The memory is very low. \n" 674 "The memory is very low. \n"
435 "Please end this application \n" 675 "Please end this application \n"
436 "immediately." ); 676 "immediately." );
437 recoverMemory(); 677 recoverMemory();
438 } 678 }
439 existingMessage = FALSE; 679 existingMessage = FALSE;
440#endif 680#endif
441} 681}
442 682
443static bool isVisibleWindow(int wid) 683static bool isVisibleWindow( int wid )
444{ 684{
445 const QList<QWSWindow> &list = qwsServer->clientWindows(); 685 const QList<QWSWindow> &list = qwsServer->clientWindows();
446 QWSWindow* w; 686 QWSWindow* w;
447 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 687 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
448 if ( w->winId() == wid ) 688 if ( w->winId() == wid )
449 return !w->isFullyObscured(); 689 return !w->isFullyObscured();
450 } 690 }
451 return FALSE; 691 return FALSE;
452} 692}
453 693
454static bool hasVisibleWindow(const QString& clientname) 694static bool hasVisibleWindow( const QString& clientname )
455{ 695{
456 const QList<QWSWindow> &list = qwsServer->clientWindows(); 696 const QList<QWSWindow> &list = qwsServer->clientWindows();
457 QWSWindow* w; 697 QWSWindow* w;
458 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 698 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
459 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 699 if ( w->client() ->identity() == clientname && !w->isFullyObscured() )
460 return TRUE; 700 return TRUE;
461 } 701 }
462 return FALSE; 702 return FALSE;
463} 703}
464 704
465void Desktop::raiseLauncher() 705void Desktop::raiseLauncher()
466{ 706{
467 Config cfg("qpe"); //F12 'Home' 707 Config cfg( "qpe" ); //F12 'Home'
468 cfg.setGroup("AppsKey"); 708 cfg.setGroup( "AppsKey" );
469 QString tempItem; 709 QString tempItem;
470 tempItem = cfg.readEntry("Middle","Home"); 710 tempItem = cfg.readEntry( "Middle", "Home" );
471 if(tempItem == "Home" || tempItem.isEmpty()) { 711 if ( tempItem == "Home" || tempItem.isEmpty() ) {
472 if ( isVisibleWindow(launcher->winId()) ) 712 if ( isVisibleWindow( launcher->winId() ) )
473 launcher->nextView(); 713 launcher->nextView();
474 else 714 else
475 launcher->raise(); 715 launcher->raise();
476 } else { 716 }
477 QCopEnvelope e("QPE/System","execute(QString)"); 717 else {
478 e << tempItem; 718 QCopEnvelope e( "QPE/System", "execute(QString)" );
479 } 719 e << tempItem;
480} 720 }
481 721}
482void Desktop::executeOrModify(const QString& appLnkFile) 722
483{ 723void Desktop::executeOrModify( const QString& appLnkFile )
484 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 724{
485 if ( lnk.isValid() ) { 725 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile );
486 QCString app = lnk.exec().utf8(); 726 if ( lnk.isValid() ) {
487 Global::terminateBuiltin("calibrate"); 727 QCString app = lnk.exec().utf8();
488 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 728 Global::terminateBuiltin( "calibrate" );
489 MRUList::addTask(&lnk); 729 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) {
490 if ( hasVisibleWindow(app) ) 730 MRUList::addTask( &lnk );
491 QCopChannel::send("QPE/Application/" + app, "nextView()"); 731 if ( hasVisibleWindow( app ) )
492 else 732 QCopChannel::send( "QPE/Application/" + app, "nextView()" );
493 QCopChannel::send("QPE/Application/" + app, "raise()"); 733 else
494 } else { 734 QCopChannel::send( "QPE/Application/" + app, "raise()" );
495 lnk.execute(); 735 }
496 } 736 else {
497 } 737 lnk.execute();
738 }
739 }
498} 740}
499 741
500void Desktop::raiseDatebook() 742void Desktop::raiseDatebook()
501{ 743{
502 Config cfg( "qpe" ); //F9 'Activity' 744 Config cfg( "qpe" ); //F9 'Activity'
503 cfg.setGroup( "AppsKey" ); 745 cfg.setGroup( "AppsKey" );
504 QString tempItem; 746 QString tempItem;
505 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); 747 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" );
506 if ( tempItem == "Calendar" || tempItem.isEmpty() ) { 748 if ( tempItem == "Calendar" || tempItem.isEmpty() ) {
507 tempItem = "datebook"; 749 tempItem = "datebook";
508 } 750 }
509 QCopEnvelope e( "QPE/System", "execute(QString)" ); 751 QCopEnvelope e( "QPE/System", "execute(QString)" );
510 e << tempItem; 752 e << tempItem;
511} 753}
512 754
513void Desktop::raiseContacts() 755void Desktop::raiseContacts()
514{ 756{
515 Config cfg( "qpe" ); //F10, 'Contacts' 757 Config cfg( "qpe" ); //F10, 'Contacts'
516 cfg.setGroup( "AppsKey" ); 758 cfg.setGroup( "AppsKey" );
517 QString tempItem; 759 QString tempItem;
518 tempItem = cfg.readEntry( "Left2nd", "Address Book" ); 760 tempItem = cfg.readEntry( "Left2nd", "Address Book" );
519 if ( tempItem == "Address Book" || tempItem.isEmpty() ) { 761 if ( tempItem == "Address Book" || tempItem.isEmpty() ) {
520 tempItem = "addressbook"; 762 tempItem = "addressbook";
521 } 763 }
522 QCopEnvelope e("QPE/System","execute(QString)"); 764 QCopEnvelope e( "QPE/System", "execute(QString)" );
523 e << tempItem; 765 e << tempItem;
524} 766}
525 767
526void Desktop::raiseMenu() 768void Desktop::raiseMenu()
527{ 769{
528 Config cfg( "qpe" ); //F11, 'Menu 770 Config cfg( "qpe" ); //F11, 'Menu
529 cfg.setGroup( "AppsKey" ); 771 cfg.setGroup( "AppsKey" );
530 QString tempItem; 772 QString tempItem;
531 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); 773 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" );
532 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { 774 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) {
533 Global::terminateBuiltin( "calibrate" ); 775 Global::terminateBuiltin( "calibrate" );
534 tb->startMenu()->launch(); 776 tb->startMenu() ->launch();
535 } else { 777 }
536 QCopEnvelope e("QPE/System","execute(QString)"); 778 else {
537 e << tempItem; 779 QCopEnvelope e( "QPE/System", "execute(QString)" );
538 } 780 e << tempItem;
781 }
539} 782}
540 783
541void Desktop::raiseEmail() 784void Desktop::raiseEmail()
542{ 785{
543 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 786 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11
544 cfg.setGroup( "AppsKey" ); 787 cfg.setGroup( "AppsKey" );
545 QString tempItem; 788 QString tempItem;
546 tempItem = cfg.readEntry( "RightEnd", "Mail" ); 789 tempItem = cfg.readEntry( "RightEnd", "Mail" );
547 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { 790 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) {
548 tempItem = "mail"; 791 tempItem = "mail";
549 } 792 }
550 QCopEnvelope e("QPE/System","execute(QString)"); 793 QCopEnvelope e( "QPE/System", "execute(QString)" );
551 e << tempItem; 794 e << tempItem;
552} 795}
553 796
554// autoStarts apps on resume and start 797// autoStarts apps on resume and start
555void Desktop::execAutoStart() 798void Desktop::execAutoStart()
556{ 799{
557 QString appName; 800 QString appName;
558 int delay; 801 int delay;
559 QDateTime now = QDateTime::currentDateTime(); 802 QDateTime now = QDateTime::currentDateTime();
560 Config cfg( "autostart" ); 803 Config cfg( "autostart" );
561 cfg.setGroup( "AutoStart" ); 804 cfg.setGroup( "AutoStart" );
562 appName = cfg.readEntry( "Apps", "" ); 805 appName = cfg.readEntry( "Apps", "" );
563 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); 806 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt();
564 // If the time between suspend and resume was longer then the 807 // If the time between suspend and resume was longer then the
565 // value saved as delay, start the app 808 // value saved as delay, start the app
566 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 809 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
567 QCopEnvelope e( "QPE/System", "execute(QString)" ); 810 QCopEnvelope e( "QPE/System", "execute(QString)" );
568 e << QString( appName ); 811 e << QString( appName );
569 } 812 }
570} 813}
571 814
572#if defined(QPE_HAVE_TOGGLELIGHT) 815#if defined(QPE_HAVE_TOGGLELIGHT)
@@ -581,234 +824,211 @@ void Desktop::execAutoStart()
581#include <time.h> 824#include <time.h>
582#endif 825#endif
583 826
584static bool blanked=FALSE;
585
586static void blankScreen()
587{
588 if ( !qt_screen ) return;
589 /* Should use a big black window instead.
590 QGfx* g = qt_screen->screenGfx();
591 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
592 delete g;
593 */
594 blanked = TRUE;
595}
596
597static void darkScreen()
598{
599 extern void qpe_setBacklight(int);
600 qpe_setBacklight(0); // force off
601}
602
603 827
604void Desktop::togglePower() 828void Desktop::togglePower()
605{ 829{
606 extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop 830 static bool excllock = false;
607
608 static bool excllock = false;
609
610 if ( excllock )
611 return;
612
613 excllock = true;
614
615 bool wasloggedin = loggedin;
616 loggedin=0;
617 suspendTime = QDateTime::currentDateTime();
618 831
619// qpe_setBacklight ( 0 ); // force LCD off (sandman: why ????) 832 if ( excllock )
833 return ;
620 834
621 if ( wasloggedin ) 835 excllock = true;
622 blankScreen();
623 836
624 qDebug ( "OPIE suspending\n" ); 837 bool wasloggedin = loggedin;
838 loggedin = 0;
839 suspendTime = QDateTime::currentDateTime();
625 840
626 ODevice::inst ( )-> suspend ( ); 841 ODevice::inst ( ) -> suspend ( );
627 842
628 QWSServer::screenSaverActivate ( false ); 843 QWSServer::screenSaverActivate ( false );
844 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
629 845
630 qpe_setBacklight ( -3 ); // force LCD on 846 {
847 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
848 }
631 849
632 { 850 if ( wasloggedin )
633 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 851 login( TRUE );
634 }
635 852
636 if ( wasloggedin ) 853 execAutoStart();
637 login(TRUE); 854 //qcopBridge->closeOpenConnections();
638 855
639 execAutoStart(); 856 excllock = false;
640 //qcopBridge->closeOpenConnections();
641
642 excllock = false;
643} 857}
644 858
645void Desktop::toggleLight() 859void Desktop::toggleLight()
646{ 860{
647 QCopEnvelope e("QPE/System", "setBacklight(int)"); 861 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
648 e << -2; // toggle 862 e << -2; // toggle
649} 863}
650 864
651void Desktop::toggleSymbolInput() 865void Desktop::toggleSymbolInput()
652{ 866{
653 tb->toggleSymbolInput(); 867 tb->toggleSymbolInput();
654} 868}
655 869
656void Desktop::toggleNumLockState() 870void Desktop::toggleNumLockState()
657{ 871{
658 tb->toggleNumLockState(); 872 tb->toggleNumLockState();
659} 873}
660 874
661void Desktop::toggleCapsLockState() 875void Desktop::toggleCapsLockState()
662{ 876{
663 tb->toggleCapsLockState(); 877 tb->toggleCapsLockState();
664} 878}
665 879
666void Desktop::styleChange( QStyle &s ) 880void Desktop::styleChange( QStyle &s )
667{ 881{
668 QWidget::styleChange( s ); 882 QWidget::styleChange( s );
669 int displayw = qApp->desktop()->width(); 883 int displayw = qApp->desktop() ->width();
670 int displayh = qApp->desktop()->height(); 884 int displayh = qApp->desktop() ->height();
671 885
672 QSize sz = tb->sizeHint(); 886 QSize sz = tb->sizeHint();
673 887
674 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 888 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
675} 889}
676 890
677void DesktopApplication::shutdown() 891void DesktopApplication::shutdown()
678{ 892{
679 if ( type() != GuiServer ) 893 if ( type() != GuiServer )
680 return; 894 return ;
681 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 895 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
682 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 896 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
683 this, SLOT(shutdown(ShutdownImpl::Type)) ); 897 this, SLOT( shutdown( ShutdownImpl::Type ) ) );
684 sd->showMaximized(); 898 sd->showMaximized();
685} 899}
686 900
687void DesktopApplication::shutdown( ShutdownImpl::Type t ) 901void DesktopApplication::shutdown( ShutdownImpl::Type t )
688{ 902{
689 switch ( t ) { 903 switch ( t ) {
690 case ShutdownImpl::ShutdownSystem: 904 case ShutdownImpl::ShutdownSystem:
691 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 905 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 );
692 break; 906 break;
693 case ShutdownImpl::RebootSystem: 907 case ShutdownImpl::RebootSystem:
694 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 908 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 );
695 break; 909 break;
696 case ShutdownImpl::RestartDesktop: 910 case ShutdownImpl::RestartDesktop:
697 restart(); 911 restart();
698 break; 912 break;
699 case ShutdownImpl::TerminateDesktop: 913 case ShutdownImpl::TerminateDesktop:
700 prepareForTermination(FALSE); 914 prepareForTermination( FALSE );
701 915
702 // This is a workaround for a Qt bug 916 // This is a workaround for a Qt bug
703 // clipboard applet has to stop its poll timer, or Qt/E 917 // clipboard applet has to stop its poll timer, or Qt/E
704 // will hang on quit() right before it emits aboutToQuit() 918 // will hang on quit() right before it emits aboutToQuit()
705 emit aboutToQuit ( ); 919 emit aboutToQuit ( );
706 920
707 quit(); 921 quit();
708 break; 922 break;
709 } 923 }
710} 924}
711 925
712void DesktopApplication::restart() 926void DesktopApplication::restart()
713{ 927{
714 prepareForTermination(TRUE); 928 prepareForTermination( TRUE );
715 929
716#ifdef Q_WS_QWS 930#ifdef Q_WS_QWS
717 for ( int fd = 3; fd < 100; fd++ ) 931
718 close( fd ); 932 for ( int fd = 3; fd < 100; fd++ )
933 close( fd );
719#if defined(QT_DEMO_SINGLE_FLOPPY) 934#if defined(QT_DEMO_SINGLE_FLOPPY)
720 execl( "/sbin/init", "qpe", 0 ); 935
936 execl( "/sbin/init", "qpe", 0 );
721#elif defined(QT_QWS_CASSIOPEIA) 937#elif defined(QT_QWS_CASSIOPEIA)
722 execl( "/bin/sh", "sh", 0 ); 938
939 execl( "/bin/sh", "sh", 0 );
723#else 940#else
724 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 941
942 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
725#endif 943#endif
726 exit(1); 944
945 exit( 1 );
727#endif 946#endif
728} 947}
729 948
730void Desktop::startTransferServer() 949void Desktop::startTransferServer()
731{ 950{
732 // start qcop bridge server 951 // start qcop bridge server
733 qcopBridge = new QCopBridge( 4243 ); 952 qcopBridge = new QCopBridge( 4243 );
734 if ( !qcopBridge->ok() ) { 953 if ( !qcopBridge->ok() ) {
735 delete qcopBridge; 954 delete qcopBridge;
736 qcopBridge = 0; 955 qcopBridge = 0;
737 } 956 }
738 // start transfer server 957 // start transfer server
739 transferServer = new TransferServer( 4242 ); 958 transferServer = new TransferServer( 4242 );
740 if ( !transferServer->ok() ) { 959 if ( !transferServer->ok() ) {
741 delete transferServer; 960 delete transferServer;
742 transferServer = 0; 961 transferServer = 0;
743 } 962 }
744 if ( !transferServer || !qcopBridge ) 963 if ( !transferServer || !qcopBridge )
745 startTimer( 2000 ); 964 startTimer( 2000 );
746} 965}
747 966
748void Desktop::timerEvent( QTimerEvent *e ) 967void Desktop::timerEvent( QTimerEvent *e )
749{ 968{
750 killTimer( e->timerId() ); 969 killTimer( e->timerId() );
751 startTransferServer(); 970 startTransferServer();
752} 971}
753 972
754void Desktop::terminateServers() 973void Desktop::terminateServers()
755{ 974{
756 delete transferServer; 975 delete transferServer;
757 delete qcopBridge; 976 delete qcopBridge;
758 transferServer = 0; 977 transferServer = 0;
759 qcopBridge = 0; 978 qcopBridge = 0;
760} 979}
761 980
762void Desktop::rereadVolumes() 981void Desktop::rereadVolumes()
763{ 982{
764 Config cfg("qpe"); 983 Config cfg( "qpe" );
765 cfg.setGroup("Volume"); 984 cfg.setGroup( "Volume" );
766 touchclick = cfg.readBoolEntry("TouchSound"); 985 touchclick = cfg.readBoolEntry( "TouchSound" );
767 keyclick = cfg.readBoolEntry("KeySound"); 986 keyclick = cfg.readBoolEntry( "KeySound" );
768 alarmsound = cfg.readBoolEntry("AlarmSound"); 987 alarmsound = cfg.readBoolEntry( "AlarmSound" );
769} 988}
770 989
771void Desktop::keyClick() 990void Desktop::keyClick()
772{ 991{
773 if ( keyclick ) 992 if ( keyclick )
774 ODevice::inst ( )-> keySound ( ); 993 ODevice::inst ( ) -> keySound ( );
775} 994}
776 995
777void Desktop::screenClick() 996void Desktop::screenClick()
778{ 997{
779 if ( touchclick ) 998 if ( touchclick )
780 ODevice::inst ( )-> touchSound ( ); 999 ODevice::inst ( ) -> touchSound ( );
781} 1000}
782 1001
783void Desktop::soundAlarm() 1002void Desktop::soundAlarm()
784{ 1003{
785 if ( qpedesktop-> alarmsound ) 1004 if ( qpedesktop-> alarmsound )
786 ODevice::inst ( )-> alarmSound ( ); 1005 ODevice::inst ( ) -> alarmSound ( );
787} 1006}
788 1007
789bool Desktop::eventFilter( QObject *, QEvent *ev ) 1008bool Desktop::eventFilter( QObject *, QEvent *ev )
790{ 1009{
791 if ( ev-> type ( ) == QEvent::KeyPress ) { 1010 if ( ev-> type ( ) == QEvent::KeyPress ) {
792 QKeyEvent *ke = (QKeyEvent *) ev; 1011 QKeyEvent * ke = ( QKeyEvent * ) ev;
793 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key 1012 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key
794 QWidget *active = qApp-> activeWindow ( ); 1013 QWidget * active = qApp-> activeWindow ( );
795 1014
796 if ( active && active-> isPopup ( )) 1015 if ( active && active-> isPopup ( ) )
797 active->close(); 1016 active->close();
798 1017
799 /* 1018 /*
800 * On iPAQ 38xx that key is not the "menu key" but the mail key 1019 * On iPAQ 38xx that key is not the "menu key" but the mail key
801 * To not confuse the users, make it launch the mail app on 38xx 1020 * To not confuse the users, make it launch the mail app on 38xx
802 */ 1021 */
803 if (ODevice::inst()->model() == OMODEL_iPAQ_H38xx ) { 1022 if ( ODevice::inst() ->model() == OMODEL_iPAQ_H38xx ) {
804 QCopEnvelope e( "QPE/System", "execute(QString)" ); 1023 QCopEnvelope e( "QPE/System", "execute(QString)" );
805 e << QString( "mail" ); 1024 e << QString( "mail" );
806 return true; 1025 return true;
807 } else { 1026 }
808 raiseMenu ( ); 1027 else {
809 return true; 1028 raiseMenu ( );
810 } 1029 return true;
811 } 1030 }
812 } 1031 }
813 return false; 1032 }
1033 return false;
814} 1034}
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index 9bc4be9..b9ff39f 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -37,98 +37,107 @@ class QCopBridge;
37class TransferServer; 37class TransferServer;
38class DesktopPowerAlerter; 38class DesktopPowerAlerter;
39class PackageSlave; 39class PackageSlave;
40class QPEScreenSaver;
40 41
41class DesktopApplication : public QPEApplication 42class DesktopApplication : public QPEApplication
42{ 43{
43 Q_OBJECT 44 Q_OBJECT
44public: 45public:
45 DesktopApplication( int& argc, char **argv, Type t ); 46 DesktopApplication( int& argc, char **argv, Type t );
46 ~DesktopApplication(); 47 ~DesktopApplication();
48
49 static void switchLCD ( bool on ); // only for togglePower in Desktop
50
47signals: 51signals:
48 void home(); 52 void home();
49 void datebook(); 53 void datebook();
50 void contacts(); 54 void contacts();
51 void launch(); 55 void launch();
52 void email(); 56 void email();
53 void backlight(); 57 void backlight();
54 void power(); 58 void power();
55 void symbol(); 59 void symbol();
56 void numLockStateToggle(); 60 void numLockStateToggle();
57 void capsLockStateToggle(); 61 void capsLockStateToggle();
58 void prepareForRestart(); 62 void prepareForRestart();
59 63
60protected: 64protected:
61#ifdef Q_WS_QWS 65#ifdef Q_WS_QWS
62 bool qwsEventFilter( QWSEvent * ); 66
67 bool qwsEventFilter( QWSEvent * );
63#endif 68#endif
64 void shutdown(); 69
65 void restart(); 70 void shutdown();
71 void restart();
66 72
67public slots: 73public slots:
68 void receive( const QCString &msg, const QByteArray &data ); 74 virtual void desktopMessage ( const QCString &msg, const QByteArray &data );
75 virtual void systemMessage ( const QCString &msg, const QByteArray &data );
69 76
70protected slots: 77protected slots:
71 void shutdown(ShutdownImpl::Type); 78 void shutdown( ShutdownImpl::Type );
72 void psTimeout(); 79 void psTimeout();
73 void sendCard(); 80 void sendCard();
74private: 81private:
75 DesktopPowerAlerter *pa; 82 DesktopPowerAlerter *pa;
76 PowerStatus *ps; 83 PowerStatus *ps;
77 QTimer *cardSendTimer; 84 QTimer *cardSendTimer;
78 QCopChannel *channel; 85 QCopChannel *channel;
86 QPEScreenSaver *m_screensaver;
79}; 87};
80 88
81 89
82class Desktop : public QWidget { 90class Desktop : public QWidget
83 Q_OBJECT 91{
92 Q_OBJECT
84public: 93public:
85 Desktop(); 94 Desktop();
86 ~Desktop(); 95 ~Desktop();
87 96
88 static bool screenLocked(); 97 static bool screenLocked();
89 98
90 void show(); 99 void show();
91 void checkMemory(); 100 void checkMemory();
92 101
93 void keyClick(); 102 void keyClick();
94 void screenClick(); 103 void screenClick();
95 static void soundAlarm(); 104 static void soundAlarm();
96 105
97public slots: 106public slots:
98 void raiseDatebook(); 107 void raiseDatebook();
99 void raiseContacts(); 108 void raiseContacts();
100 void raiseMenu(); 109 void raiseMenu();
101 void raiseLauncher(); 110 void raiseLauncher();
102 void raiseEmail(); 111 void raiseEmail();
103 void execAutoStart(); 112 void execAutoStart();
104 void togglePower(); 113 void togglePower();
105 void toggleLight(); 114 void toggleLight();
106 void toggleNumLockState(); 115 void toggleNumLockState();
107 void toggleCapsLockState(); 116 void toggleCapsLockState();
108 void toggleSymbolInput(); 117 void toggleSymbolInput();
109 void terminateServers(); 118 void terminateServers();
110 void rereadVolumes(); 119 void rereadVolumes();
111 120
112protected: 121protected:
113 void executeOrModify(const QString& appLnkFile); 122 void executeOrModify( const QString& appLnkFile );
114 void styleChange( QStyle & ); 123 void styleChange( QStyle & );
115 void timerEvent( QTimerEvent *e ); 124 void timerEvent( QTimerEvent *e );
116 bool eventFilter( QObject *, QEvent * ); 125 bool eventFilter( QObject *, QEvent * );
117 126
118 QWidget *bg; 127 QWidget *bg;
119 Launcher *launcher; 128 Launcher *launcher;
120 TaskBar *tb; 129 TaskBar *tb;
121 130
122private: 131private:
123 void startTransferServer(); 132 void startTransferServer();
124 bool recoverMemory(); 133 bool recoverMemory();
125 134
126 QCopBridge *qcopBridge; 135 QCopBridge *qcopBridge;
127 TransferServer *transferServer; 136 TransferServer *transferServer;
128 PackageSlave *packageSlave; 137 PackageSlave *packageSlave;
129 138
130 QDateTime suspendTime; 139 QDateTime suspendTime;
131 bool keyclick,touchclick,alarmsound; 140 bool keyclick, touchclick, alarmsound;
132}; 141};
133 142
134 143