summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-03-18 21:28:36 (UTC)
committer harlekin <harlekin>2002-03-18 21:28:36 (UTC)
commitd41e6d2ed4caeabf78ab08bde7d4f5866c9eeb04 (patch) (unidiff)
treeed3c5c8d2eea0001b954a34ecb4a496fa9a6a484
parente6d3c651634eee7ff54675cc060ae94bd3ef41bd (diff)
downloadopie-d41e6d2ed4caeabf78ab08bde7d4f5866c9eeb04.zip
opie-d41e6d2ed4caeabf78ab08bde7d4f5866c9eeb04.tar.gz
opie-d41e6d2ed4caeabf78ab08bde7d4f5866c9eeb04.tar.bz2
tweaked the suspend code a bit, maybe with a delay it works better
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 680cc06..547daa9 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -176,556 +176,559 @@ void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
176 emit power(); 176 emit power();
177 } 177 }
178 178
179} 179}
180 180
181enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 181enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
182 182
183#ifdef Q_WS_QWS 183#ifdef Q_WS_QWS
184bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 184bool DesktopApplication::qwsEventFilter( QWSEvent *e )
185{ 185{
186 qpedesktop->checkMemory(); 186 qpedesktop->checkMemory();
187 187
188 if ( e->type == QWSEvent::Key ) { 188 if ( e->type == QWSEvent::Key ) {
189 QWSKeyEvent *ke = (QWSKeyEvent *)e; 189 QWSKeyEvent *ke = (QWSKeyEvent *)e;
190 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 190 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
191 return TRUE; 191 return TRUE;
192 bool press = ke->simpleData.is_press; 192 bool press = ke->simpleData.is_press;
193 193
194 if (!keyRegisterList.isEmpty()) 194 if (!keyRegisterList.isEmpty())
195 { 195 {
196 KeyRegisterList::Iterator it; 196 KeyRegisterList::Iterator it;
197 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) 197 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
198 { 198 {
199 if ((*it).getKeyCode() == ke->simpleData.keycode) 199 if ((*it).getKeyCode() == ke->simpleData.keycode)
200 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 200 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
201 } 201 }
202 } 202 }
203 203
204 if ( !keyboardGrabbed() ) { 204 if ( !keyboardGrabbed() ) {
205 if ( ke->simpleData.keycode == Key_F9 ) { 205 if ( ke->simpleData.keycode == Key_F9 ) {
206 if ( press ) emit datebook(); 206 if ( press ) emit datebook();
207 return TRUE; 207 return TRUE;
208 } 208 }
209 if ( ke->simpleData.keycode == Key_F10 ) { 209 if ( ke->simpleData.keycode == Key_F10 ) {
210 if ( !press && cardSendTimer ) { 210 if ( !press && cardSendTimer ) {
211 emit contacts(); 211 emit contacts();
212 delete cardSendTimer; 212 delete cardSendTimer;
213 } else if ( press ) { 213 } else if ( press ) {
214 cardSendTimer = new QTimer(); 214 cardSendTimer = new QTimer();
215 cardSendTimer->start( 2000, TRUE ); 215 cardSendTimer->start( 2000, TRUE );
216 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 216 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
217 } 217 }
218 return TRUE; 218 return TRUE;
219 } 219 }
220 /* menu key now opens application menu/toolbar 220 /* menu key now opens application menu/toolbar
221 if ( ke->simpleData.keycode == Key_F11 ) { 221 if ( ke->simpleData.keycode == Key_F11 ) {
222 if ( press ) emit menu(); 222 if ( press ) emit menu();
223 return TRUE; 223 return TRUE;
224 } 224 }
225 */ 225 */
226 if ( ke->simpleData.keycode == Key_F12 ) { 226 if ( ke->simpleData.keycode == Key_F12 ) {
227 while( activePopupWidget() ) 227 while( activePopupWidget() )
228 activePopupWidget()->close(); 228 activePopupWidget()->close();
229 if ( press ) emit launch(); 229 if ( press ) emit launch();
230 return TRUE; 230 return TRUE;
231 } 231 }
232 if ( ke->simpleData.keycode == Key_F13 ) { 232 if ( ke->simpleData.keycode == Key_F13 ) {
233 if ( press ) emit email(); 233 if ( press ) emit email();
234 return TRUE; 234 return TRUE;
235 } 235 }
236 } 236 }
237 237
238 if ( ke->simpleData.keycode == Key_F34 ) { 238 if ( ke->simpleData.keycode == Key_F34 ) {
239 if ( press ) emit power(); 239 if ( press ) emit power();
240 return TRUE; 240 return TRUE;
241 } 241 }
242 if ( ke->simpleData.keycode == Key_SysReq ) { 242 if ( ke->simpleData.keycode == Key_SysReq ) {
243 if ( press ) emit power(); 243 if ( press ) emit power();
244 return TRUE; 244 return TRUE;
245 } 245 }
246 if ( ke->simpleData.keycode == Key_F35 ) { 246 if ( ke->simpleData.keycode == Key_F35 ) {
247 if ( press ) emit backlight(); 247 if ( press ) emit backlight();
248 return TRUE; 248 return TRUE;
249 } 249 }
250 if ( ke->simpleData.keycode == Key_F32 ) { 250 if ( ke->simpleData.keycode == Key_F32 ) {
251 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 251 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
252 return TRUE; 252 return TRUE;
253 } 253 }
254 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 254 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
255 if ( press ) emit symbol(); 255 if ( press ) emit symbol();
256 return TRUE; 256 return TRUE;
257 } 257 }
258 if ( ke->simpleData.keycode == Key_NumLock ) { 258 if ( ke->simpleData.keycode == Key_NumLock ) {
259 if ( press ) emit numLockStateToggle(); 259 if ( press ) emit numLockStateToggle();
260 } 260 }
261 if ( ke->simpleData.keycode == Key_CapsLock ) { 261 if ( ke->simpleData.keycode == Key_CapsLock ) {
262 if ( press ) emit capsLockStateToggle(); 262 if ( press ) emit capsLockStateToggle();
263 } 263 }
264 if ( press ) 264 if ( press )
265 qpedesktop->keyClick(); 265 qpedesktop->keyClick();
266 } else { 266 } else {
267 if ( e->type == QWSEvent::Mouse ) { 267 if ( e->type == QWSEvent::Mouse ) {
268 QWSMouseEvent *me = (QWSMouseEvent *)e; 268 QWSMouseEvent *me = (QWSMouseEvent *)e;
269 static bool up = TRUE; 269 static bool up = TRUE;
270 if ( me->simpleData.state&LeftButton ) { 270 if ( me->simpleData.state&LeftButton ) {
271 if ( up ) { 271 if ( up ) {
272 up = FALSE; 272 up = FALSE;
273 qpedesktop->screenClick(); 273 qpedesktop->screenClick();
274 } 274 }
275 } else { 275 } else {
276 up = TRUE; 276 up = TRUE;
277 } 277 }
278 } 278 }
279 } 279 }
280 280
281 return QPEApplication::qwsEventFilter( e ); 281 return QPEApplication::qwsEventFilter( e );
282} 282}
283#endif 283#endif
284 284
285void DesktopApplication::psTimeout() 285void DesktopApplication::psTimeout()
286{ 286{
287 qpedesktop->checkMemory(); // in case no events are being generated 287 qpedesktop->checkMemory(); // in case no events are being generated
288 288
289 *ps = PowerStatusManager::readStatus(); 289 *ps = PowerStatusManager::readStatus();
290 290
291 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 291 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
292 pa->alert( tr( "Battery is running very low." ), 6 ); 292 pa->alert( tr( "Battery is running very low." ), 6 );
293 } 293 }
294 294
295 if ( ps->batteryStatus() == PowerStatus::Critical ) { 295 if ( ps->batteryStatus() == PowerStatus::Critical ) {
296 pa->alert( tr( "Battery level is critical!\n" 296 pa->alert( tr( "Battery level is critical!\n"
297 "Keep power off until power restored!" ), 1 ); 297 "Keep power off until power restored!" ), 1 );
298 } 298 }
299 299
300 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 300 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
301 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 301 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
302 } 302 }
303} 303}
304 304
305 305
306void DesktopApplication::sendCard() 306void DesktopApplication::sendCard()
307{ 307{
308 delete cardSendTimer; 308 delete cardSendTimer;
309 cardSendTimer = 0; 309 cardSendTimer = 0;
310 QString card = getenv("HOME"); 310 QString card = getenv("HOME");
311 card += "/Applications/addressbook/businesscard.vcf"; 311 card += "/Applications/addressbook/businesscard.vcf";
312 312
313 if ( QFile::exists( card ) ) { 313 if ( QFile::exists( card ) ) {
314 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 314 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
315 QString mimetype = "text/x-vCard"; 315 QString mimetype = "text/x-vCard";
316 e << tr("business card") << card << mimetype; 316 e << tr("business card") << card << mimetype;
317 } 317 }
318} 318}
319 319
320#if defined(QPE_HAVE_MEMALERTER) 320#if defined(QPE_HAVE_MEMALERTER)
321QPE_MEMALERTER_IMPL 321QPE_MEMALERTER_IMPL
322#endif 322#endif
323 323
324#if defined(CUSTOM_SOUND_IMPL) 324#if defined(CUSTOM_SOUND_IMPL)
325CUSTOM_SOUND_IMPL 325CUSTOM_SOUND_IMPL
326#endif 326#endif
327 327
328//=========================================================================== 328//===========================================================================
329 329
330Desktop::Desktop() : 330Desktop::Desktop() :
331 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 331 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
332 qcopBridge( 0 ), 332 qcopBridge( 0 ),
333 transferServer( 0 ), 333 transferServer( 0 ),
334 packageSlave( 0 ) 334 packageSlave( 0 )
335{ 335{
336#ifdef CUSTOM_SOUND_INIT 336#ifdef CUSTOM_SOUND_INIT
337 CUSTOM_SOUND_INIT; 337 CUSTOM_SOUND_INIT;
338#endif 338#endif
339 339
340 qpedesktop = this; 340 qpedesktop = this;
341 341
342// bg = new Info( this ); 342// bg = new Info( this );
343 tb = new TaskBar; 343 tb = new TaskBar;
344 344
345 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 345 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
346 346
347 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 347 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
348 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 348 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
349 349
350 int displayw = qApp->desktop()->width(); 350 int displayw = qApp->desktop()->width();
351 int displayh = qApp->desktop()->height(); 351 int displayh = qApp->desktop()->height();
352 352
353 353
354 QSize sz = tb->sizeHint(); 354 QSize sz = tb->sizeHint();
355 355
356 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 356 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
357 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 357 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
358 358
359 tb->show(); 359 tb->show();
360 launcher->showMaximized(); 360 launcher->showMaximized();
361 launcher->show(); 361 launcher->show();
362 launcher->raise(); 362 launcher->raise();
363#if defined(QPE_HAVE_MEMALERTER) 363#if defined(QPE_HAVE_MEMALERTER)
364 initMemalerter(); 364 initMemalerter();
365#endif 365#endif
366 // start services 366 // start services
367 startTransferServer(); 367 startTransferServer();
368 (void) new IrServer( this ); 368 (void) new IrServer( this );
369 rereadVolumes(); 369 rereadVolumes();
370 370
371 packageSlave = new PackageSlave( this ); 371 packageSlave = new PackageSlave( this );
372 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 372 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
373 373
374 qApp->installEventFilter( this ); 374 qApp->installEventFilter( this );
375} 375}
376 376
377void Desktop::show() 377void Desktop::show()
378{ 378{
379 login(TRUE); 379 login(TRUE);
380 QWidget::show(); 380 QWidget::show();
381} 381}
382 382
383Desktop::~Desktop() 383Desktop::~Desktop()
384{ 384{
385 delete launcher; 385 delete launcher;
386 delete tb; 386 delete tb;
387 delete qcopBridge; 387 delete qcopBridge;
388 delete transferServer; 388 delete transferServer;
389} 389}
390 390
391bool Desktop::recoverMemory() 391bool Desktop::recoverMemory()
392{ 392{
393 return tb->recoverMemory(); 393 return tb->recoverMemory();
394} 394}
395 395
396void Desktop::checkMemory() 396void Desktop::checkMemory()
397{ 397{
398#if defined(QPE_HAVE_MEMALERTER) 398#if defined(QPE_HAVE_MEMALERTER)
399 static bool ignoreNormal=FALSE; 399 static bool ignoreNormal=FALSE;
400 static bool existingMessage=FALSE; 400 static bool existingMessage=FALSE;
401 401
402 if(existingMessage) 402 if(existingMessage)
403 return; // don't show a second message while still on first 403 return; // don't show a second message while still on first
404 404
405 existingMessage = TRUE; 405 existingMessage = TRUE;
406 switch ( memstate ) { 406 switch ( memstate ) {
407 case Unknown: 407 case Unknown:
408 break; 408 break;
409 case Low: 409 case Low:
410 memstate = Unknown; 410 memstate = Unknown;
411 if ( recoverMemory() ) 411 if ( recoverMemory() )
412 ignoreNormal = TRUE; 412 ignoreNormal = TRUE;
413 else 413 else
414 QMessageBox::warning( 0 , "Memory Status", 414 QMessageBox::warning( 0 , "Memory Status",
415 "The memory smacks of shortage. \n" 415 "The memory smacks of shortage. \n"
416 "Please save data. " ); 416 "Please save data. " );
417 break; 417 break;
418 case Normal: 418 case Normal:
419 memstate = Unknown; 419 memstate = Unknown;
420 if ( ignoreNormal ) 420 if ( ignoreNormal )
421 ignoreNormal = FALSE; 421 ignoreNormal = FALSE;
422 else 422 else
423 QMessageBox::information ( 0 , "Memory Status", 423 QMessageBox::information ( 0 , "Memory Status",
424 "There is enough memory again." ); 424 "There is enough memory again." );
425 break; 425 break;
426 case VeryLow: 426 case VeryLow:
427 memstate = Unknown; 427 memstate = Unknown;
428 QMessageBox::critical( 0 , "Memory Status", 428 QMessageBox::critical( 0 , "Memory Status",
429 "The memory is very low. \n" 429 "The memory is very low. \n"
430 "Please end this application \n" 430 "Please end this application \n"
431 "immediately." ); 431 "immediately." );
432 recoverMemory(); 432 recoverMemory();
433 } 433 }
434 existingMessage = FALSE; 434 existingMessage = FALSE;
435#endif 435#endif
436} 436}
437 437
438static bool isVisibleWindow(int wid) 438static bool isVisibleWindow(int wid)
439{ 439{
440 const QList<QWSWindow> &list = qwsServer->clientWindows(); 440 const QList<QWSWindow> &list = qwsServer->clientWindows();
441 QWSWindow* w; 441 QWSWindow* w;
442 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 442 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
443 if ( w->winId() == wid ) 443 if ( w->winId() == wid )
444 return !w->isFullyObscured(); 444 return !w->isFullyObscured();
445 } 445 }
446 return FALSE; 446 return FALSE;
447} 447}
448 448
449static bool hasVisibleWindow(const QString& clientname) 449static bool hasVisibleWindow(const QString& clientname)
450{ 450{
451 const QList<QWSWindow> &list = qwsServer->clientWindows(); 451 const QList<QWSWindow> &list = qwsServer->clientWindows();
452 QWSWindow* w; 452 QWSWindow* w;
453 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 453 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
454 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 454 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
455 return TRUE; 455 return TRUE;
456 } 456 }
457 return FALSE; 457 return FALSE;
458} 458}
459 459
460void Desktop::raiseLauncher() 460void Desktop::raiseLauncher()
461{ 461{
462 if ( isVisibleWindow(launcher->winId()) ) 462 if ( isVisibleWindow(launcher->winId()) )
463 launcher->nextView(); 463 launcher->nextView();
464 else 464 else
465 launcher->raise(); 465 launcher->raise();
466} 466}
467 467
468void Desktop::executeOrModify(const QString& appLnkFile) 468void Desktop::executeOrModify(const QString& appLnkFile)
469{ 469{
470 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 470 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
471 if ( lnk.isValid() ) { 471 if ( lnk.isValid() ) {
472 QCString app = lnk.exec().utf8(); 472 QCString app = lnk.exec().utf8();
473 Global::terminateBuiltin("calibrate"); 473 Global::terminateBuiltin("calibrate");
474 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 474 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
475 MRUList::addTask(&lnk); 475 MRUList::addTask(&lnk);
476 if ( hasVisibleWindow(app) ) 476 if ( hasVisibleWindow(app) )
477 QCopChannel::send("QPE/Application/" + app, "nextView()"); 477 QCopChannel::send("QPE/Application/" + app, "nextView()");
478 else 478 else
479 QCopChannel::send("QPE/Application/" + app, "raise()"); 479 QCopChannel::send("QPE/Application/" + app, "raise()");
480 } else { 480 } else {
481 lnk.execute(); 481 lnk.execute();
482 } 482 }
483 } 483 }
484} 484}
485 485
486void Desktop::raiseDatebook() 486void Desktop::raiseDatebook()
487{ 487{
488 executeOrModify("Applications/datebook.desktop"); 488 executeOrModify("Applications/datebook.desktop");
489} 489}
490 490
491void Desktop::raiseContacts() 491void Desktop::raiseContacts()
492{ 492{
493 executeOrModify("Applications/addressbook.desktop"); 493 executeOrModify("Applications/addressbook.desktop");
494} 494}
495 495
496void Desktop::raiseMenu() 496void Desktop::raiseMenu()
497{ 497{
498 Global::terminateBuiltin("calibrate"); 498 Global::terminateBuiltin("calibrate");
499 tb->startMenu()->launch(); 499 tb->startMenu()->launch();
500} 500}
501 501
502void Desktop::raiseEmail() 502void Desktop::raiseEmail()
503{ 503{
504 executeOrModify("Applications/qtmail.desktop"); 504 executeOrModify("Applications/qtmail.desktop");
505} 505}
506 506
507// autoStarts apps on resume and start 507// autoStarts apps on resume and start
508void Desktop::execAutoStart() 508void Desktop::execAutoStart()
509{ 509{
510 QString appName; 510 QString appName;
511 Config cfg( "autostart" ); 511 Config cfg( "autostart" );
512 cfg.setGroup( "AutoStart" ); 512 cfg.setGroup( "AutoStart" );
513 appName = cfg.readEntry("Apps", ""); 513 appName = cfg.readEntry("Apps", "");
514 QCopEnvelope e("QPE/System", "execute(QString)"); 514 QCopEnvelope e("QPE/System", "execute(QString)");
515 e << QString(appName); 515 e << QString(appName);
516} 516}
517 517
518#if defined(QPE_HAVE_TOGGLELIGHT) 518#if defined(QPE_HAVE_TOGGLELIGHT)
519#include <qpe/config.h> 519#include <qpe/config.h>
520 520
521#include <sys/ioctl.h> 521#include <sys/ioctl.h>
522#include <sys/types.h> 522#include <sys/types.h>
523#include <fcntl.h> 523#include <fcntl.h>
524#include <unistd.h> 524#include <unistd.h>
525#include <errno.h> 525#include <errno.h>
526#include <linux/ioctl.h> 526#include <linux/ioctl.h>
527#include <time.h> 527#include <time.h>
528#endif 528#endif
529 529
530static bool blanked=FALSE; 530static bool blanked=FALSE;
531 531
532static void blankScreen() 532static void blankScreen()
533{ 533{
534 if ( !qt_screen ) return; 534 if ( !qt_screen ) return;
535 /* Should use a big black window instead. 535 /* Should use a big black window instead.
536 QGfx* g = qt_screen->screenGfx(); 536 QGfx* g = qt_screen->screenGfx();
537 g->fillRect(0,0,qt_screen->width(),qt_screen->height()); 537 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
538 delete g; 538 delete g;
539 */ 539 */
540 blanked = TRUE; 540 blanked = TRUE;
541} 541}
542 542
543static void darkScreen() 543static void darkScreen()
544{ 544{
545 extern void qpe_setBacklight(int); 545 extern void qpe_setBacklight(int);
546 qpe_setBacklight(0); // force off 546 qpe_setBacklight(0); // force off
547} 547}
548 548
549 549
550void Desktop::togglePower() 550void Desktop::togglePower()
551{ 551{
552 bool wasloggedin = loggedin; 552 bool wasloggedin = loggedin;
553 loggedin=0; 553 loggedin=0;
554 darkScreen(); 554 darkScreen();
555 if ( wasloggedin ) 555 if ( wasloggedin )
556 blankScreen(); 556 blankScreen();
557 557
558 system("apm --suspend"); 558 system("apm --suspend");
559 559
560 sleep(2);
561
560 QWSServer::screenSaverActivate( FALSE ); 562 QWSServer::screenSaverActivate( FALSE );
561 { 563 {
562 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 564 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
563 QCopEnvelope e("QPE/System", "setBacklight(int)"); 565 QCopEnvelope e("QPE/System", "setBacklight(int)");
564 e << -3; // Force on 566 e << -3; // Force on
565 } 567 }
566 if ( wasloggedin ) { 568 if ( wasloggedin ) {
567 login(TRUE); 569 login(TRUE);
568 } 570 }
571
569 execAutoStart(); 572 execAutoStart();
570 //qcopBridge->closeOpenConnections(); 573 //qcopBridge->closeOpenConnections();
571 //qDebug("called togglePower()!!!!!!"); 574 //qDebug("called togglePower()!!!!!!");
572} 575}
573 576
574void Desktop::toggleLight() 577void Desktop::toggleLight()
575{ 578{
576 QCopEnvelope e("QPE/System", "setBacklight(int)"); 579 QCopEnvelope e("QPE/System", "setBacklight(int)");
577 e << -2; // toggle 580 e << -2; // toggle
578} 581}
579 582
580void Desktop::toggleSymbolInput() 583void Desktop::toggleSymbolInput()
581{ 584{
582 tb->toggleSymbolInput(); 585 tb->toggleSymbolInput();
583} 586}
584 587
585void Desktop::toggleNumLockState() 588void Desktop::toggleNumLockState()
586{ 589{
587 tb->toggleNumLockState(); 590 tb->toggleNumLockState();
588} 591}
589 592
590void Desktop::toggleCapsLockState() 593void Desktop::toggleCapsLockState()
591{ 594{
592 tb->toggleCapsLockState(); 595 tb->toggleCapsLockState();
593} 596}
594 597
595void Desktop::styleChange( QStyle &s ) 598void Desktop::styleChange( QStyle &s )
596{ 599{
597 QWidget::styleChange( s ); 600 QWidget::styleChange( s );
598 int displayw = qApp->desktop()->width(); 601 int displayw = qApp->desktop()->width();
599 int displayh = qApp->desktop()->height(); 602 int displayh = qApp->desktop()->height();
600 603
601 QSize sz = tb->sizeHint(); 604 QSize sz = tb->sizeHint();
602 605
603 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 606 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
604} 607}
605 608
606void DesktopApplication::shutdown() 609void DesktopApplication::shutdown()
607{ 610{
608 if ( type() != GuiServer ) 611 if ( type() != GuiServer )
609 return; 612 return;
610 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 613 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
611 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 614 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
612 this, SLOT(shutdown(ShutdownImpl::Type)) ); 615 this, SLOT(shutdown(ShutdownImpl::Type)) );
613 sd->showMaximized(); 616 sd->showMaximized();
614} 617}
615 618
616void DesktopApplication::shutdown( ShutdownImpl::Type t ) 619void DesktopApplication::shutdown( ShutdownImpl::Type t )
617{ 620{
618 switch ( t ) { 621 switch ( t ) {
619 case ShutdownImpl::ShutdownSystem: 622 case ShutdownImpl::ShutdownSystem:
620 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 623 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
621 break; 624 break;
622 case ShutdownImpl::RebootSystem: 625 case ShutdownImpl::RebootSystem:
623 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 626 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
624 break; 627 break;
625 case ShutdownImpl::RestartDesktop: 628 case ShutdownImpl::RestartDesktop:
626 restart(); 629 restart();
627 break; 630 break;
628 case ShutdownImpl::TerminateDesktop: 631 case ShutdownImpl::TerminateDesktop:
629 prepareForTermination(FALSE); 632 prepareForTermination(FALSE);
630 quit(); 633 quit();
631 break; 634 break;
632 } 635 }
633} 636}
634 637
635void DesktopApplication::restart() 638void DesktopApplication::restart()
636{ 639{
637 prepareForTermination(TRUE); 640 prepareForTermination(TRUE);
638 641
639#ifdef Q_WS_QWS 642#ifdef Q_WS_QWS
640 for ( int fd = 3; fd < 100; fd++ ) 643 for ( int fd = 3; fd < 100; fd++ )
641 close( fd ); 644 close( fd );
642#if defined(QT_DEMO_SINGLE_FLOPPY) 645#if defined(QT_DEMO_SINGLE_FLOPPY)
643 execl( "/sbin/init", "qpe", 0 ); 646 execl( "/sbin/init", "qpe", 0 );
644#elif defined(QT_QWS_CASSIOPEIA) 647#elif defined(QT_QWS_CASSIOPEIA)
645 execl( "/bin/sh", "sh", 0 ); 648 execl( "/bin/sh", "sh", 0 );
646#else 649#else
647 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 650 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
648#endif 651#endif
649 exit(1); 652 exit(1);
650#endif 653#endif
651} 654}
652 655
653void Desktop::startTransferServer() 656void Desktop::startTransferServer()
654{ 657{
655 // start qcop bridge server 658 // start qcop bridge server
656 qcopBridge = new QCopBridge( 4243 ); 659 qcopBridge = new QCopBridge( 4243 );
657 if ( !qcopBridge->ok() ) { 660 if ( !qcopBridge->ok() ) {
658 delete qcopBridge; 661 delete qcopBridge;
659 qcopBridge = 0; 662 qcopBridge = 0;
660 } 663 }
661 // start transfer server 664 // start transfer server
662 transferServer = new TransferServer( 4242 ); 665 transferServer = new TransferServer( 4242 );
663 if ( !transferServer->ok() ) { 666 if ( !transferServer->ok() ) {
664 delete transferServer; 667 delete transferServer;
665 transferServer = 0; 668 transferServer = 0;
666 } 669 }
667 if ( !transferServer || !qcopBridge ) 670 if ( !transferServer || !qcopBridge )
668 startTimer( 2000 ); 671 startTimer( 2000 );
669} 672}
670 673
671void Desktop::timerEvent( QTimerEvent *e ) 674void Desktop::timerEvent( QTimerEvent *e )
672{ 675{
673 killTimer( e->timerId() ); 676 killTimer( e->timerId() );
674 startTransferServer(); 677 startTransferServer();
675} 678}
676 679
677void Desktop::terminateServers() 680void Desktop::terminateServers()
678{ 681{
679 delete transferServer; 682 delete transferServer;
680 delete qcopBridge; 683 delete qcopBridge;
681 transferServer = 0; 684 transferServer = 0;
682 qcopBridge = 0; 685 qcopBridge = 0;
683} 686}
684 687
685void Desktop::rereadVolumes() 688void Desktop::rereadVolumes()
686{ 689{
687 Config cfg("Sound"); 690 Config cfg("Sound");
688 cfg.setGroup("System"); 691 cfg.setGroup("System");
689 touchclick = cfg.readBoolEntry("Touch"); 692 touchclick = cfg.readBoolEntry("Touch");
690 keyclick = cfg.readBoolEntry("Key"); 693 keyclick = cfg.readBoolEntry("Key");
691} 694}
692 695
693void Desktop::keyClick() 696void Desktop::keyClick()
694{ 697{
695#ifdef CUSTOM_SOUND_KEYCLICK 698#ifdef CUSTOM_SOUND_KEYCLICK
696 if ( keyclick ) 699 if ( keyclick )
697 CUSTOM_SOUND_KEYCLICK; 700 CUSTOM_SOUND_KEYCLICK;
698#endif 701#endif
699} 702}
700 703
701void Desktop::screenClick() 704void Desktop::screenClick()
702{ 705{
703#ifdef CUSTOM_SOUND_TOUCH 706#ifdef CUSTOM_SOUND_TOUCH
704 if ( touchclick ) 707 if ( touchclick )
705 CUSTOM_SOUND_TOUCH; 708 CUSTOM_SOUND_TOUCH;
706#endif 709#endif
707} 710}
708 711
709void Desktop::soundAlarm() 712void Desktop::soundAlarm()
710{ 713{
711#ifdef CUSTOM_SOUND_ALARM 714#ifdef CUSTOM_SOUND_ALARM
712 CUSTOM_SOUND_ALARM; 715 CUSTOM_SOUND_ALARM;
713#endif 716#endif
714} 717}
715 718
716bool Desktop::eventFilter( QObject *w, QEvent *ev ) 719bool Desktop::eventFilter( QObject *w, QEvent *ev )
717{ 720{
718 if ( ev->type() == QEvent::KeyPress ) { 721 if ( ev->type() == QEvent::KeyPress ) {
719 QKeyEvent *ke = (QKeyEvent *)ev; 722 QKeyEvent *ke = (QKeyEvent *)ev;
720 if ( ke->key() == Qt::Key_F11 ) { // menu key 723 if ( ke->key() == Qt::Key_F11 ) { // menu key
721 QWidget *active = qApp->activeWindow(); 724 QWidget *active = qApp->activeWindow();
722 if ( active && active->isPopup() ) { 725 if ( active && active->isPopup() ) {
723 active->close(); 726 active->close();
724 } 727 }
725 raiseMenu(); 728 raiseMenu();
726 return TRUE; 729 return TRUE;
727 } 730 }
728 } 731 }
729 return FALSE; 732 return FALSE;
730} 733}
731 734