summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-10 11:42:53 (UTC)
committer zecke <zecke>2004-09-10 11:42:53 (UTC)
commit6adde94c6ee292de5bc87a0c651fef69e8847d7e (patch) (unidiff)
tree56ae2a840932bd50e16b59232a185e62d17c0843
parent854e3af27ee7208bbb3620733a24f0214c0b118a (diff)
downloadopie-6adde94c6ee292de5bc87a0c651fef69e8847d7e.zip
opie-6adde94c6ee292de5bc87a0c651fef69e8847d7e.tar.gz
opie-6adde94c6ee292de5bc87a0c651fef69e8847d7e.tar.bz2
Remove unused code and mark parameter as Q_UNUSED
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp2
-rw-r--r--core/launcher/server.cpp26
-rw-r--r--core/launcher/serverapp.cpp4
3 files changed, 6 insertions, 26 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 0d0f2cb..cd9c14b 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -320,256 +320,258 @@ protected:
320 cols = 2; 320 cols = 2;
321 else if ( viewerWidth >= 400 ) 321 else if ( viewerWidth >= 400 )
322 cols = viewerWidth/96; 322 cols = viewerWidth/96;
323 setSpacing( 4 ); 323 setSpacing( 4 );
324 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 324 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
325 setGridY( fontMetrics().height()*2+24 ); 325 setGridY( fontMetrics().height()*2+24 );
326 } else { 326 } else {
327 int cols = 2; 327 int cols = 2;
328 if ( viewerWidth < 150 ) 328 if ( viewerWidth < 150 )
329 cols = 1; 329 cols = 1;
330 else if ( viewerWidth >= 400 ) 330 else if ( viewerWidth >= 400 )
331 cols = viewerWidth/150; 331 cols = viewerWidth/150;
332 setSpacing( 2 ); 332 setSpacing( 2 );
333 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 333 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
334 setGridY( fontMetrics().height()+2 ); 334 setGridY( fontMetrics().height()+2 );
335 } 335 }
336 } 336 }
337 337
338 void focusInEvent( QFocusEvent * ) {} 338 void focusInEvent( QFocusEvent * ) {}
339 void focusOutEvent( QFocusEvent * ) {} 339 void focusOutEvent( QFocusEvent * ) {}
340 340
341private: 341private:
342 QList<AppLnk> hidden; 342 QList<AppLnk> hidden;
343 QDict<void> mimes; 343 QDict<void> mimes;
344 QDict<void> cats; 344 QDict<void> cats;
345 SortMethod sortmeth; 345 SortMethod sortmeth;
346 QRegExp tf; 346 QRegExp tf;
347 int cf; 347 int cf;
348 LauncherItem* bsy; 348 LauncherItem* bsy;
349 int busyTimer; 349 int busyTimer;
350 bool ike; 350 bool ike;
351 bool bigIcns; 351 bool bigIcns;
352 QPixmap bgPixmap; 352 QPixmap bgPixmap;
353 QColor bgColor; 353 QColor bgColor;
354#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 354#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
355 QPixmap busyPix; 355 QPixmap busyPix;
356#endif 356#endif
357 BusyIndicatorType busyType; 357 BusyIndicatorType busyType;
358}; 358};
359 359
360 360
361bool LauncherView::bsy=FALSE; 361bool LauncherView::bsy=FALSE;
362 362
363void LauncherView::setBusy(bool on) 363void LauncherView::setBusy(bool on)
364{ 364{
365 icons->setBusy(on); 365 icons->setBusy(on);
366} 366}
367 367
368void LauncherView::setBusyIndicatorType( const QString& type ) { 368void LauncherView::setBusyIndicatorType( const QString& type ) {
369 if ( type. lower ( ) == "animated" ) 369 if ( type. lower ( ) == "animated" )
370 icons->setBusyIndicatorType( BIT_Animated ) ; 370 icons->setBusyIndicatorType( BIT_Animated ) ;
371 else 371 else
372 icons->setBusyIndicatorType( BIT_Normal ) ; 372 icons->setBusyIndicatorType( BIT_Normal ) ;
373} 373}
374 374
375LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 375LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
376 : QIconViewItem( parent, applnk->name(), 376 : QIconViewItem( parent, applnk->name(),
377 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 377 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
378 isBigIcon( bigIcon ), 378 isBigIcon( bigIcon ),
379 iteration(0), 379 iteration(0),
380 app(applnk) // Takes ownership 380 app(applnk) // Takes ownership
381{ 381{
382} 382}
383 383
384LauncherItem::~LauncherItem() 384LauncherItem::~LauncherItem()
385{ 385{
386 LauncherIconView* liv = (LauncherIconView*)iconView(); 386 LauncherIconView* liv = (LauncherIconView*)iconView();
387 if ( liv->busyItem() == this ) 387 if ( liv->busyItem() == this )
388 liv->setBusy(FALSE); 388 liv->setBusy(FALSE);
389 delete app; 389 delete app;
390} 390}
391 391
392int LauncherItem::compare ( QIconViewItem * i ) const 392int LauncherItem::compare ( QIconViewItem * i ) const
393{ 393{
394 LauncherIconView* view = (LauncherIconView*)iconView(); 394 LauncherIconView* view = (LauncherIconView*)iconView();
395 return view->compare(app,((LauncherItem *)i)->appLnk()); 395 return view->compare(app,((LauncherItem *)i)->appLnk());
396} 396}
397 397
398void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) 398void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
399{ 399{
400 LauncherIconView* liv = (LauncherIconView*)iconView(); 400 LauncherIconView* liv = (LauncherIconView*)iconView();
401 QBrush oldBrush( liv->itemTextBackground() ); 401 QBrush oldBrush( liv->itemTextBackground() );
402 QColorGroup mycg( cg ); 402 QColorGroup mycg( cg );
403 if ( liv->currentItem() == this ) { 403 if ( liv->currentItem() == this ) {
404 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 404 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
405 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 405 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
406 } 406 }
407 407
408 QIconViewItem::paintItem(p,mycg); 408 QIconViewItem::paintItem(p,mycg);
409 409
410 // Paint animation overlay 410 // Paint animation overlay
411 if ( liv->busyItem() == this ) 411 if ( liv->busyItem() == this )
412 paintAnimatedIcon(p); 412 paintAnimatedIcon(p);
413 413
414 if ( liv->currentItem() == this ) 414 if ( liv->currentItem() == this )
415 liv->setItemTextBackground( oldBrush ); 415 liv->setItemTextBackground( oldBrush );
416} 416}
417 417
418 418
419 419
420void LauncherItem::paintAnimatedIcon( QPainter *p ) 420void LauncherItem::paintAnimatedIcon( QPainter *p )
421{ 421{
422 LauncherIconView* liv = (LauncherIconView*)iconView(); 422 LauncherIconView* liv = (LauncherIconView*)iconView();
423 int pic = iteration % 16; 423 int pic = iteration % 16;
424 int w = pixmap()->width(), h = pixmap()->height(); 424 int w = pixmap()->width(), h = pixmap()->height();
425 QPixmap dblBuf( w, h + 4 ); 425 QPixmap dblBuf( w, h + 4 );
426 QPainter p2( &dblBuf ); 426 QPainter p2( &dblBuf );
427 int x1, y1; 427 int x1, y1;
428 if ( liv->itemTextPos() == QIconView::Bottom ) { 428 if ( liv->itemTextPos() == QIconView::Bottom ) {
429 x1 = x() + (width() - w) / 2 - liv->contentsX(); 429 x1 = x() + (width() - w) / 2 - liv->contentsX();
430 y1 = y() - liv->contentsY(); 430 y1 = y() - liv->contentsY();
431 } else { 431 } else {
432 x1 = x() - liv->contentsX(); 432 x1 = x() - liv->contentsX();
433 y1 = y() + (height() - h) / 2 - liv->contentsY(); 433 y1 = y() + (height() - h) / 2 - liv->contentsY();
434 } 434 }
435 y1 -= 2; 435 y1 -= 2;
436 p2.translate(-x1,-y1); 436 p2.translate(-x1,-y1);
437 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); 437 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) );
438 int bounceY = 2; 438 int bounceY = 2;
439#ifdef BOUNCE_BUSY_ICON 439#ifdef BOUNCE_BUSY_ICON
440 if ( busyType == BIT_Animated ) { 440 if ( busyType == BIT_Animated ) {
441 bounceY = 4 - ((iteration+2)%8); 441 bounceY = 4 - ((iteration+2)%8);
442 bounceY = bounceY < 0 ? -bounceY : bounceY; 442 bounceY = bounceY < 0 ? -bounceY : bounceY;
443 } 443 }
444#endif 444#endif
445 p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); 445 p2.drawPixmap( x1, y1 + bounceY, *pixmap() );
446#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 446#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
447 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); 447 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h );
448#else
449 Q_UNUSED( pic )
448#endif 450#endif
449 p->drawPixmap( x1, y1, dblBuf ); 451 p->drawPixmap( x1, y1, dblBuf );
450} 452}
451 453
452void LauncherItem::animateIcon() 454void LauncherItem::animateIcon()
453{ 455{
454 LauncherIconView* liv = (LauncherIconView*)iconView(); 456 LauncherIconView* liv = (LauncherIconView*)iconView();
455 457
456 if ( liv->busyItem() != this || !app ) 458 if ( liv->busyItem() != this || !app )
457 return; 459 return;
458 460
459 // Highlight the icon 461 // Highlight the icon
460 if ( iteration == 0 ) { 462 if ( iteration == 0 ) {
461 QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap(); 463 QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap();
462 QImage img = src.convertToImage(); 464 QImage img = src.convertToImage();
463 QRgb *rgb; 465 QRgb *rgb;
464 int count; 466 int count;
465 if ( img.depth() == 32 ) { 467 if ( img.depth() == 32 ) {
466 rgb = (QRgb*)img.bits(); 468 rgb = (QRgb*)img.bits();
467 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 469 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
468 } else { 470 } else {
469 rgb = img.colorTable(); 471 rgb = img.colorTable();
470 count = img.numColors(); 472 count = img.numColors();
471 } 473 }
472 for ( int r = 0; r < count; r++, rgb++ ) { 474 for ( int r = 0; r < count; r++, rgb++ ) {
473#if defined(BRIGHTEN_BUSY_ICON) 475#if defined(BRIGHTEN_BUSY_ICON)
474 QColor c(*rgb); 476 QColor c(*rgb);
475 int h, s, v; 477 int h, s, v;
476 c.hsv(&h,&s,&v); 478 c.hsv(&h,&s,&v);
477 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); 479 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255));
478 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); 480 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb));
479#elif defined(ALPHA_FADE_BUSY_ICON) 481#elif defined(ALPHA_FADE_BUSY_ICON)
480 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); 482 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2);
481#endif 483#endif
482 } 484 }
483 src.convertFromImage( img ); 485 src.convertFromImage( img );
484 setPixmap( src ); 486 setPixmap( src );
485 } 487 }
486 488
487 iteration++; 489 iteration++;
488 490
489 // Paint animation overlay 491 // Paint animation overlay
490 QPainter p( liv->viewport() ); 492 QPainter p( liv->viewport() );
491 paintAnimatedIcon( &p ); 493 paintAnimatedIcon( &p );
492} 494}
493 495
494void LauncherItem::resetIcon() 496void LauncherItem::resetIcon()
495{ 497{
496 iteration = 0; 498 iteration = 0;
497 setPixmap( isBigIcon ? app->bigPixmap() : app->pixmap() ); 499 setPixmap( isBigIcon ? app->bigPixmap() : app->pixmap() );
498} 500}
499 501
500//=========================================================================== 502//===========================================================================
501 503
502QStringList LauncherIconView::mimeTypes() const 504QStringList LauncherIconView::mimeTypes() const
503{ 505{
504 QStringList r; 506 QStringList r;
505 QDictIterator<void> it(mimes); 507 QDictIterator<void> it(mimes);
506 while (it.current()) { 508 while (it.current()) {
507 r.append(it.currentKey()); 509 r.append(it.currentKey());
508 ++it; 510 ++it;
509 } 511 }
510 r.sort(); 512 r.sort();
511 return r; 513 return r;
512} 514}
513 515
514void LauncherIconView::addItem(AppLnk* app, bool resort) 516void LauncherIconView::addItem(AppLnk* app, bool resort)
515{ 517{
516 addCatsAndMimes(app); 518 addCatsAndMimes(app);
517 519
518 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 520 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
519 && (cf == 0 || app->categories().contains(cf) 521 && (cf == 0 || app->categories().contains(cf)
520 || cf == -1 && app->categories().count() == 0 ) ) 522 || cf == -1 && app->categories().count() == 0 ) )
521 (void) new LauncherItem( this, app, bigIcns ); 523 (void) new LauncherItem( this, app, bigIcns );
522 else 524 else
523 hidden.append(app); 525 hidden.append(app);
524 if ( resort ) 526 if ( resort )
525 sort(); 527 sort();
526} 528}
527 529
528void LauncherIconView::updateCategoriesAndMimeTypes() 530void LauncherIconView::updateCategoriesAndMimeTypes()
529{ 531{
530 mimes.clear(); 532 mimes.clear();
531 cats.clear(); 533 cats.clear();
532 LauncherItem* item = (LauncherItem*)firstItem(); 534 LauncherItem* item = (LauncherItem*)firstItem();
533 while (item) { 535 while (item) {
534 addCatsAndMimes(item->appLnk()); 536 addCatsAndMimes(item->appLnk());
535 item = (LauncherItem*)item->nextItem(); 537 item = (LauncherItem*)item->nextItem();
536 } 538 }
537 QListIterator<AppLnk> it(hidden); 539 QListIterator<AppLnk> it(hidden);
538 AppLnk* l; 540 AppLnk* l;
539 while ((l=it.current())) { 541 while ((l=it.current())) {
540 addCatsAndMimes(l); 542 addCatsAndMimes(l);
541 ++it; 543 ++it;
542 } 544 }
543} 545}
544 546
545void LauncherIconView::hideOrShowItems(bool resort) 547void LauncherIconView::hideOrShowItems(bool resort)
546{ 548{
547 viewport()->setUpdatesEnabled( FALSE ); 549 viewport()->setUpdatesEnabled( FALSE );
548 hidden.setAutoDelete(FALSE); 550 hidden.setAutoDelete(FALSE);
549 QList<AppLnk> links=hidden; 551 QList<AppLnk> links=hidden;
550 hidden.clear(); 552 hidden.clear();
551 hidden.setAutoDelete(TRUE); 553 hidden.setAutoDelete(TRUE);
552 LauncherItem* item = (LauncherItem*)firstItem(); 554 LauncherItem* item = (LauncherItem*)firstItem();
553 while (item) { 555 while (item) {
554 links.append(item->takeAppLnk()); 556 links.append(item->takeAppLnk());
555 item = (LauncherItem*)item->nextItem(); 557 item = (LauncherItem*)item->nextItem();
556 } 558 }
557 clear(); 559 clear();
558 QListIterator<AppLnk> it(links); 560 QListIterator<AppLnk> it(links);
559 AppLnk* l; 561 AppLnk* l;
560 while ((l=it.current())) { 562 while ((l=it.current())) {
561 addItem(l,FALSE); 563 addItem(l,FALSE);
562 ++it; 564 ++it;
563 } 565 }
564 if ( resort && !autoArrange() ) 566 if ( resort && !autoArrange() )
565 sort(); 567 sort();
566 viewport()->setUpdatesEnabled( TRUE ); 568 viewport()->setUpdatesEnabled( TRUE );
567} 569}
568 570
569bool LauncherIconView::removeLink(const QString& linkfile) 571bool LauncherIconView::removeLink(const QString& linkfile)
570{ 572{
571 LauncherItem* item = (LauncherItem*)firstItem(); 573 LauncherItem* item = (LauncherItem*)firstItem();
572 AppLnk* l; 574 AppLnk* l;
573 bool did = FALSE; 575 bool did = FALSE;
574 DocLnk dl(linkfile); 576 DocLnk dl(linkfile);
575 while (item) { 577 while (item) {
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp
index 950032d..5ae517b 100644
--- a/core/launcher/server.cpp
+++ b/core/launcher/server.cpp
@@ -71,280 +71,256 @@ static QWidget *calibrate(bool)
71 Calibrate *c = new Calibrate; 71 Calibrate *c = new Calibrate;
72 c->show(); 72 c->show();
73 return c; 73 return c;
74#else 74#else
75 return 0; 75 return 0;
76#endif 76#endif
77} 77}
78 78
79#define FACTORY(T) \ 79#define FACTORY(T) \
80 static QWidget *new##T( bool maximized ) { \ 80 static QWidget *new##T( bool maximized ) { \
81 QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ 81 QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \
82 if ( maximized ) { \ 82 if ( maximized ) { \
83 if ( qApp->desktop()->width() <= 350 ) { \ 83 if ( qApp->desktop()->width() <= 350 ) { \
84 w->showMaximized(); \ 84 w->showMaximized(); \
85 } else { \ 85 } else { \
86 w->resize( QSize( 300, 300 ) ); \ 86 w->resize( QSize( 300, 300 ) ); \
87 } \ 87 } \
88 } \ 88 } \
89 w->show(); \ 89 w->show(); \
90 return w; \ 90 return w; \
91 } 91 }
92 92
93 93
94#ifdef SINGLE_APP 94#ifdef SINGLE_APP
95#define APP(a,b,c,d) FACTORY(b) 95#define APP(a,b,c,d) FACTORY(b)
96#include "apps.h" 96#include "apps.h"
97#undef APP 97#undef APP
98#endif // SINGLE_APP 98#endif // SINGLE_APP
99 99
100static Global::Command builtins[] = { 100static Global::Command builtins[] = {
101 101
102#ifdef SINGLE_APP 102#ifdef SINGLE_APP
103#define APP(a,b,c,d) { a, new##b, c, d }, 103#define APP(a,b,c,d) { a, new##b, c, d },
104#include "apps.h" 104#include "apps.h"
105#undef APP 105#undef APP
106#endif 106#endif
107 107
108 /* FIXME defines need to be defined*/ 108 /* FIXME defines need to be defined*/
109#if !defined(OPIE_NO_BUILTIN_CALIBRATE) 109#if !defined(OPIE_NO_BUILTIN_CALIBRATE)
110 { "calibrate", calibrate, 1, 0 }, // No tr 110 { "calibrate", calibrate, 1, 0 }, // No tr
111#endif 111#endif
112#if !defined(OPIE_NO_BUILTIN_SHUTDOWN) 112#if !defined(OPIE_NO_BUILTIN_SHUTDOWN)
113 { "shutdown", Global::shutdown, 1, 0 }, // No tr 113 { "shutdown", Global::shutdown, 1, 0 }, // No tr
114// { "run", run, 1, 0 }, // No tr 114// { "run", run, 1, 0 }, // No tr
115#endif 115#endif
116 116
117 { 0, calibrate, 0, 0 }, 117 { 0, calibrate, 0, 0 },
118}; 118};
119 119
120 120
121//--------------------------------------------------------------------------- 121//---------------------------------------------------------------------------
122 122
123 123
124//=========================================================================== 124//===========================================================================
125 125
126Server::Server() : 126Server::Server() :
127 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 127 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
128 qcopBridge( 0 ), 128 qcopBridge( 0 ),
129 transferServer( 0 ), 129 transferServer( 0 ),
130 packageHandler( 0 ), 130 packageHandler( 0 ),
131 syncDialog( 0 ) 131 syncDialog( 0 )
132{ 132{
133 Global::setBuiltinCommands(builtins); 133 Global::setBuiltinCommands(builtins);
134 134
135 tid_xfer = 0; 135 tid_xfer = 0;
136 /* ### FIXME ### */ 136 /* ### FIXME ### */
137/* tid_today = startTimer(3600*2*1000);*/ 137/* tid_today = startTimer(3600*2*1000);*/
138 last_today_show = QDate::currentDate(); 138 last_today_show = QDate::currentDate();
139 139
140#if 0 140#if 0
141 tsmMonitor = new TempScreenSaverMode(); 141 tsmMonitor = new TempScreenSaverMode();
142 connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); 142 connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) );
143#endif 143#endif
144 144
145 serverGui = new Launcher; 145 serverGui = new Launcher;
146 serverGui->createGUI(); 146 serverGui->createGUI();
147 147
148 docList = new DocumentList( serverGui ); 148 docList = new DocumentList( serverGui );
149 appLauncher = new AppLauncher(this); 149 appLauncher = new AppLauncher(this);
150 connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); 150 connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) );
151 connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); 151 connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) );
152 connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); 152 connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) );
153 153
154 storage = new StorageInfo( this ); 154 storage = new StorageInfo( this );
155 connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); 155 connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) );
156 156
157 // start services 157 // start services
158 startTransferServer(); 158 startTransferServer();
159 (void) new IrServer( this ); 159 (void) new IrServer( this );
160 160
161 packageHandler = new PackageHandler( this ); 161 packageHandler = new PackageHandler( this );
162 connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), 162 connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)),
163 this,SLOT(activate(const Opie::Core::ODeviceButton*,bool))); 163 this,SLOT(activate(const Opie::Core::ODeviceButton*,bool)));
164 164
165 setGeometry( -10, -10, 9, 9 ); 165 setGeometry( -10, -10, 9, 9 );
166 166
167 QCopChannel *channel = new QCopChannel("QPE/System", this); 167 QCopChannel *channel = new QCopChannel("QPE/System", this);
168 connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), 168 connect(channel, SIGNAL(received(const QCString&,const QByteArray&)),
169 this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); 169 this, SLOT(systemMsg(const QCString&,const QByteArray&)) );
170 170
171 QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); 171 QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this );
172 connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), 172 connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)),
173 this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); 173 this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) );
174 174
175 connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); 175 connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) );
176 connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); 176 connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) );
177 177
178 preloadApps(); 178 preloadApps();
179} 179}
180 180
181void Server::show() 181void Server::show()
182{ 182{
183 ServerApplication::login(TRUE); 183 ServerApplication::login(TRUE);
184 QWidget::show(); 184 QWidget::show();
185} 185}
186 186
187Server::~Server() 187Server::~Server()
188{ 188{
189 serverGui->destroyGUI(); 189 serverGui->destroyGUI();
190 delete docList; 190 delete docList;
191 delete qcopBridge; 191 delete qcopBridge;
192 delete transferServer; 192 delete transferServer;
193 delete serverGui; 193 delete serverGui;
194#if 0 194#if 0
195 delete tsmMonitor; 195 delete tsmMonitor;
196#endif 196#endif
197} 197}
198 198
199static bool hasVisibleWindow(const QString& clientname, bool partial)
200{
201#ifdef QWS
202 const QList<QWSWindow> &list = qwsServer->clientWindows();
203 QWSWindow* w;
204 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
205 if ( w->client()->identity() == clientname ) {
206 if ( partial && !w->isFullyObscured() )
207 return TRUE;
208 if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) {
209# if QT_VERSION < 0x030000
210 QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect,
211 QSize(qt_screen->width(),qt_screen->height()) );
212# else
213 QRect mwr = qt_maxWindowRect;
214# endif
215 if ( mwr.contains(w->requested().boundingRect()) )
216 return TRUE;
217 }
218 }
219 }
220#endif
221 return FALSE;
222}
223 199
224void Server::activate(const ODeviceButton* button, bool held) 200void Server::activate(const ODeviceButton* button, bool held)
225{ 201{
226 Global::terminateBuiltin("calibrate"); // No tr 202 Global::terminateBuiltin("calibrate"); // No tr
227 OQCopMessage om; 203 OQCopMessage om;
228 if ( held ) { 204 if ( held ) {
229 om = button->heldAction(); 205 om = button->heldAction();
230 } else { 206 } else {
231 om = button->pressedAction(); 207 om = button->pressedAction();
232 } 208 }
233 209
234 if ( om.channel() != "ignore" ) 210 if ( om.channel() != "ignore" )
235 om.send(); 211 om.send();
236 212
237 // A button with no action defined, will return a null ServiceRequest. Don't attempt 213 // A button with no action defined, will return a null ServiceRequest. Don't attempt
238 // to send/do anything with this as it will crash 214 // to send/do anything with this as it will crash
239 /* ### FIXME */ 215 /* ### FIXME */
240#if 0 216#if 0
241 if ( !sr.isNull() ) { 217 if ( !sr.isNull() ) {
242 QString app = sr.app(); 218 QString app = sr.app();
243 bool vis = hasVisibleWindow(app, app != "qpe"); 219 bool vis = hasVisibleWindow(app, app != "qpe");
244 if ( sr.message() == "raise()" && vis ) { 220 if ( sr.message() == "raise()" && vis ) {
245 sr.setMessage("nextView()"); 221 sr.setMessage("nextView()");
246 } else { 222 } else {
247 // "back door" 223 // "back door"
248 sr << (int)vis; 224 sr << (int)vis;
249 } 225 }
250 226
251 sr.send(); 227 sr.send();
252 } 228 }
253#endif 229#endif
254} 230}
255 231
256 232
257#ifdef Q_WS_QWS 233#ifdef Q_WS_QWS
258 234
259 235
260typedef struct KeyOverride { 236typedef struct KeyOverride {
261 ushort scan_code; 237 ushort scan_code;
262 QWSServer::KeyMap map; 238 QWSServer::KeyMap map;
263}; 239};
264 240
265 241
266static const KeyOverride jp109keys[] = { 242static const KeyOverride jp109keys[] = {
267 { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, 243 { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } },
268 { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, 244 { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } },
269 { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, 245 { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } },
270 { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, 246 { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } },
271 { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, 247 { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } },
272 { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, 248 { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } },
273 { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, 249 { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } },
274 { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, 250 { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } },
275 { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, 251 { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } },
276 { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, 252 { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } },
277 { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, 253 { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } },
278 { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, 254 { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } },
279 { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, 255 { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } },
280 { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, 256 { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } },
281 { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, 257 { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } },
282 { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, 258 { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } },
283 { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, 259 { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } },
284 { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, 260 { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } },
285 { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, 261 { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } },
286 { 0x00, { 0, 0xffff , 0xffff , 0xffff } } 262 { 0x00, { 0, 0xffff , 0xffff , 0xffff } }
287}; 263};
288 264
289bool Server::setKeyboardLayout( const QString &kb ) 265bool Server::setKeyboardLayout( const QString &kb )
290{ 266{
291 //quick demo version that can be extended 267 //quick demo version that can be extended
292 268
293 QIntDict<QWSServer::KeyMap> *om = 0; 269 QIntDict<QWSServer::KeyMap> *om = 0;
294 if ( kb == "us101" ) { // No tr 270 if ( kb == "us101" ) { // No tr
295 om = 0; 271 om = 0;
296 } else if ( kb == "jp109" ) { 272 } else if ( kb == "jp109" ) {
297 om = new QIntDict<QWSServer::KeyMap>(37); 273 om = new QIntDict<QWSServer::KeyMap>(37);
298 const KeyOverride *k = jp109keys; 274 const KeyOverride *k = jp109keys;
299 while ( k->scan_code ) { 275 while ( k->scan_code ) {
300 om->insert( k->scan_code, &k->map ); 276 om->insert( k->scan_code, &k->map );
301 k++; 277 k++;
302 } 278 }
303 } 279 }
304 QWSServer::setOverrideKeys( om ); 280 QWSServer::setOverrideKeys( om );
305 281
306 return TRUE; 282 return TRUE;
307} 283}
308 284
309#endif 285#endif
310 286
311void Server::systemMsg(const QCString &msg, const QByteArray &data) 287void Server::systemMsg(const QCString &msg, const QByteArray &data)
312{ 288{
313 QDataStream stream( data, IO_ReadOnly ); 289 QDataStream stream( data, IO_ReadOnly );
314 290
315 if ( msg == "securityChanged()" ) { 291 if ( msg == "securityChanged()" ) {
316 if ( transferServer ) 292 if ( transferServer )
317 transferServer->authorizeConnections(); 293 transferServer->authorizeConnections();
318 if ( qcopBridge ) 294 if ( qcopBridge )
319 qcopBridge->authorizeConnections(); 295 qcopBridge->authorizeConnections();
320 } 296 }
321 /* ### FIXME support TempScreenSaverMode */ 297 /* ### FIXME support TempScreenSaverMode */
322#if 0 298#if 0
323 else if ( msg == "setTempScreenSaverMode(int,int)" ) { 299 else if ( msg == "setTempScreenSaverMode(int,int)" ) {
324 int mode, pid; 300 int mode, pid;
325 stream >> mode >> pid; 301 stream >> mode >> pid;
326 tsmMonitor->setTempMode(mode, pid); 302 tsmMonitor->setTempMode(mode, pid);
327 } 303 }
328#endif 304#endif
329 else if ( msg == "linkChanged(QString)" ) { 305 else if ( msg == "linkChanged(QString)" ) {
330 QString link; 306 QString link;
331 stream >> link; 307 stream >> link;
332 odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; 308 odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl;
333 docList->linkChanged(link); 309 docList->linkChanged(link);
334 } else if ( msg == "serviceChanged(QString)" ) { 310 } else if ( msg == "serviceChanged(QString)" ) {
335 MimeType::updateApplications(); 311 MimeType::updateApplications();
336 } else if ( msg == "mkdir(QString)" ) { 312 } else if ( msg == "mkdir(QString)" ) {
337 QString dir; 313 QString dir;
338 stream >> dir; 314 stream >> dir;
339 if ( !dir.isEmpty() ) 315 if ( !dir.isEmpty() )
340 mkdir( dir ); 316 mkdir( dir );
341 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 317 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
342 QString baseFile, sigFile; 318 QString baseFile, sigFile;
343 stream >> baseFile >> sigFile; 319 stream >> baseFile >> sigFile;
344 QRsync::generateSignature( baseFile, sigFile ); 320 QRsync::generateSignature( baseFile, sigFile );
345 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 321 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
346 QString baseFile, sigFile, deltaFile; 322 QString baseFile, sigFile, deltaFile;
347 stream >> baseFile >> sigFile >> deltaFile; 323 stream >> baseFile >> sigFile >> deltaFile;
348 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 324 QRsync::generateDiff( baseFile, sigFile, deltaFile );
349 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 325 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
350 QString baseFile, deltaFile; 326 QString baseFile, deltaFile;
@@ -573,157 +549,159 @@ bool Server::mkdir(const QString &localPath)
573 // didn't find any seps; weird, use the cur dir instead 549 // didn't find any seps; weird, use the cur dir instead
574 if (dirIndex == -1) { 550 if (dirIndex == -1) {
575 //odebug << "No seperators found in path " << localPath << "" << oendl; 551 //odebug << "No seperators found in path " << localPath << "" << oendl;
576 checkedPath = QDir::currentDirPath(); 552 checkedPath = QDir::currentDirPath();
577 } 553 }
578 554
579 while (checkedPath != localPath) { 555 while (checkedPath != localPath) {
580 // no more seperators found, use the local path 556 // no more seperators found, use the local path
581 if (dirIndex == -1) 557 if (dirIndex == -1)
582 checkedPath = localPath; 558 checkedPath = localPath;
583 else { 559 else {
584 // the next directory to check 560 // the next directory to check
585 checkedPath = localPath.left(dirIndex) + "/"; 561 checkedPath = localPath.left(dirIndex) + "/";
586 // advance the iterator; the next dir seperator 562 // advance the iterator; the next dir seperator
587 dirIndex = localPath.find(dirSeps, dirIndex+1); 563 dirIndex = localPath.find(dirSeps, dirIndex+1);
588 } 564 }
589 565
590 QDir checkDir(checkedPath); 566 QDir checkDir(checkedPath);
591 if (!checkDir.exists()) { 567 if (!checkDir.exists()) {
592 //odebug << "mkdir making dir " << checkedPath << "" << oendl; 568 //odebug << "mkdir making dir " << checkedPath << "" << oendl;
593 569
594 if (!checkDir.mkdir(checkedPath)) { 570 if (!checkDir.mkdir(checkedPath)) {
595 odebug << "Unable to make directory " << checkedPath << "" << oendl; 571 odebug << "Unable to make directory " << checkedPath << "" << oendl;
596 return FALSE; 572 return FALSE;
597 } 573 }
598 } 574 }
599 575
600 } 576 }
601 return TRUE; 577 return TRUE;
602} 578}
603 579
604void Server::styleChange( QStyle &s ) 580void Server::styleChange( QStyle &s )
605{ 581{
606 QWidget::styleChange( s ); 582 QWidget::styleChange( s );
607} 583}
608 584
609void Server::startTransferServer() 585void Server::startTransferServer()
610{ 586{
611 if ( !qcopBridge ) { 587 if ( !qcopBridge ) {
612 // start qcop bridge server 588 // start qcop bridge server
613 qcopBridge = new QCopBridge( 4243 ); 589 qcopBridge = new QCopBridge( 4243 );
614 if ( qcopBridge->ok() ) { 590 if ( qcopBridge->ok() ) {
615 // ... OK 591 // ... OK
616 connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), 592 connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)),
617 this, SLOT(syncConnectionClosed(const QHostAddress&)) ); 593 this, SLOT(syncConnectionClosed(const QHostAddress&)) );
618 } else { 594 } else {
619 delete qcopBridge; 595 delete qcopBridge;
620 qcopBridge = 0; 596 qcopBridge = 0;
621 } 597 }
622 } 598 }
623 if ( !transferServer ) { 599 if ( !transferServer ) {
624 // start transfer server 600 // start transfer server
625 transferServer = new TransferServer( 4242 ); 601 transferServer = new TransferServer( 4242 );
626 if ( transferServer->ok() ) { 602 if ( transferServer->ok() ) {
627 // ... OK 603 // ... OK
628 } else { 604 } else {
629 delete transferServer; 605 delete transferServer;
630 transferServer = 0; 606 transferServer = 0;
631 } 607 }
632 } 608 }
633 if ( !transferServer || !qcopBridge ) 609 if ( !transferServer || !qcopBridge )
634 tid_xfer = startTimer( 2000 ); 610 tid_xfer = startTimer( 2000 );
635} 611}
636 612
637void Server::timerEvent( QTimerEvent *e ) 613void Server::timerEvent( QTimerEvent *e )
638{ 614{
639 if ( e->timerId() == tid_xfer ) { 615 if ( e->timerId() == tid_xfer ) {
640 killTimer( tid_xfer ); 616 killTimer( tid_xfer );
641 tid_xfer = 0; 617 tid_xfer = 0;
642 startTransferServer(); 618 startTransferServer();
643 } 619 }
644 /* ### FIXME today startin */ 620 /* ### FIXME today startin */
645#if 0 621#if 0
646 else if ( e->timerId() == tid_today ) { 622 else if ( e->timerId() == tid_today ) {
647 QDate today = QDate::currentDate(); 623 QDate today = QDate::currentDate();
648 if ( today != last_today_show ) { 624 if ( today != last_today_show ) {
649 last_today_show = today; 625 last_today_show = today;
650 Config cfg("today"); 626 Config cfg("today");
651 cfg.setGroup("Start"); 627 cfg.setGroup("Start");
652#ifndef QPE_DEFAULT_TODAY_MODE 628#ifndef QPE_DEFAULT_TODAY_MODE
653#define QPE_DEFAULT_TODAY_MODE "Never" 629#define QPE_DEFAULT_TODAY_MODE "Never"
654#endif 630#endif
655 if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { 631 if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) {
656 QCopEnvelope env(Service::channel("today"),"raise()"); 632 QCopEnvelope env(Service::channel("today"),"raise()");
657 } 633 }
658 } 634 }
659 } 635 }
660#endif 636#endif
661} 637}
662 638
663void Server::terminateServers() 639void Server::terminateServers()
664{ 640{
665 delete transferServer; 641 delete transferServer;
666 delete qcopBridge; 642 delete qcopBridge;
667 transferServer = 0; 643 transferServer = 0;
668 qcopBridge = 0; 644 qcopBridge = 0;
669} 645}
670 646
671void Server::syncConnectionClosed( const QHostAddress & ) 647void Server::syncConnectionClosed( const QHostAddress & )
672{ 648{
673 odebug << "Lost sync connection" << oendl; 649 odebug << "Lost sync connection" << oendl;
674 delete syncDialog; 650 delete syncDialog;
675 syncDialog = 0; 651 syncDialog = 0;
676} 652}
677 653
678void Server::pokeTimeMonitors() 654void Server::pokeTimeMonitors()
679{ 655{
680#if 0 656#if 0
681 // inform all TimeMonitors 657 // inform all TimeMonitors
682 QStrList tms = Service::channels("TimeMonitor"); 658 QStrList tms = Service::channels("TimeMonitor");
683 for (const char* ch = tms.first(); ch; ch=tms.next()) { 659 for (const char* ch = tms.first(); ch; ch=tms.next()) {
684 QString t = getenv("TZ"); 660 QString t = getenv("TZ");
685 QCopEnvelope e(ch, "timeChange(QString)"); 661 QCopEnvelope e(ch, "timeChange(QString)");
686 e << t; 662 e << t;
687 } 663 }
688#endif 664#endif
689} 665}
690 666
691void Server::applicationLaunched(int, const QString &app) 667void Server::applicationLaunched(int, const QString &app)
692{ 668{
693 serverGui->applicationStateChanged( app, ServerInterface::Launching ); 669 serverGui->applicationStateChanged( app, ServerInterface::Launching );
694} 670}
695 671
696void Server::applicationTerminated(int pid, const QString &app) 672void Server::applicationTerminated(int pid, const QString &app)
697{ 673{
698 serverGui->applicationStateChanged( app, ServerInterface::Terminated ); 674 serverGui->applicationStateChanged( app, ServerInterface::Terminated );
699#if 0 675#if 0
700 tsmMonitor->applicationTerminated( pid ); 676 tsmMonitor->applicationTerminated( pid );
677#else
678 Q_UNUSED( pid )
701#endif 679#endif
702} 680}
703 681
704void Server::applicationConnected(const QString &app) 682void Server::applicationConnected(const QString &app)
705{ 683{
706 serverGui->applicationStateChanged( app, ServerInterface::Running ); 684 serverGui->applicationStateChanged( app, ServerInterface::Running );
707} 685}
708 686
709void Server::storageChanged() 687void Server::storageChanged()
710{ 688{
711 system( "opie-update-symlinks" ); 689 system( "opie-update-symlinks" );
712 serverGui->storageChanged( storage->fileSystems() ); 690 serverGui->storageChanged( storage->fileSystems() );
713 docList->storageChanged(); 691 docList->storageChanged();
714} 692}
715 693
716 694
717 695
718void Server::preloadApps() 696void Server::preloadApps()
719{ 697{
720 Config cfg("Launcher"); 698 Config cfg("Launcher");
721 cfg.setGroup("Preload"); 699 cfg.setGroup("Preload");
722 QStringList apps = cfg.readListEntry("Apps",','); 700 QStringList apps = cfg.readListEntry("Apps",',');
723 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 701 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
724#ifndef QT_NO_COP 702#ifndef QT_NO_COP
725 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 703 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
726#endif 704#endif
727 } 705 }
728} 706}
729 707
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp
index a2302d8..66cc788 100644
--- a/core/launcher/serverapp.cpp
+++ b/core/launcher/serverapp.cpp
@@ -232,258 +232,258 @@ bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepe
232 return TRUE; 232 return TRUE;
233 } 233 }
234 if ( keycode == HardKey_Backlight ) { 234 if ( keycode == HardKey_Backlight ) {
235 if ( press ) emit backlight(); 235 if ( press ) emit backlight();
236 return TRUE; 236 return TRUE;
237 } 237 }
238 if ( keycode == Key_F32 ) { 238 if ( keycode == Key_F32 ) {
239#ifndef QT_NO_COP 239#ifndef QT_NO_COP
240 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 240 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
241#endif 241#endif
242 return TRUE; 242 return TRUE;
243 } 243 }
244 if ( keycode == Key_F31 ) { 244 if ( keycode == Key_F31 ) {
245 if ( press ) emit symbol(); 245 if ( press ) emit symbol();
246 QWSServer::screenSaverActivate(FALSE); 246 QWSServer::screenSaverActivate(FALSE);
247 return TRUE; 247 return TRUE;
248 } 248 }
249 249
250 if ( keycode == Key_NumLock ) 250 if ( keycode == Key_NumLock )
251 if ( press ) emit numLockStateToggle(); 251 if ( press ) emit numLockStateToggle();
252 252
253 if ( keycode == Key_CapsLock ) 253 if ( keycode == Key_CapsLock )
254 if ( press ) emit capsLockStateToggle(); 254 if ( press ) emit capsLockStateToggle();
255 255
256 if ( serverApp ) 256 if ( serverApp )
257 serverApp->keyClick(keycode,press,autoRepeat); 257 serverApp->keyClick(keycode,press,autoRepeat);
258 258
259 return FALSE; 259 return FALSE;
260} 260}
261 261
262enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; 262enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown;
263 263
264#if defined(QPE_HAVE_MEMALERTER) 264#if defined(QPE_HAVE_MEMALERTER)
265QPE_MEMALERTER_IMPL 265QPE_MEMALERTER_IMPL
266#endif 266#endif
267 267
268 268
269 269
270//--------------------------------------------------------------------------- 270//---------------------------------------------------------------------------
271 271
272bool ServerApplication::doRestart = FALSE; 272bool ServerApplication::doRestart = FALSE;
273bool ServerApplication::allowRestart = TRUE; 273bool ServerApplication::allowRestart = TRUE;
274bool ServerApplication::ms_is_starting = TRUE; 274bool ServerApplication::ms_is_starting = TRUE;
275 275
276void ServerApplication::switchLCD( bool on ) 276void ServerApplication::switchLCD( bool on )
277{ 277{
278 if ( !qApp ) 278 if ( !qApp )
279 return; 279 return;
280 280
281 ServerApplication *dapp = ServerApplication::me() ; 281 ServerApplication *dapp = ServerApplication::me() ;
282 282
283 if ( !dapp-> m_screensaver ) 283 if ( !dapp-> m_screensaver )
284 return; 284 return;
285 285
286 if ( on ) { 286 if ( on ) {
287 dapp-> m_screensaver-> setDisplayState ( true ); 287 dapp-> m_screensaver-> setDisplayState ( true );
288 dapp-> m_screensaver-> setBacklight ( -3 ); 288 dapp-> m_screensaver-> setBacklight ( -3 );
289 } else 289 } else
290 dapp-> m_screensaver-> setDisplayState ( false ); 290 dapp-> m_screensaver-> setDisplayState ( false );
291 291
292 292
293} 293}
294 294
295ServerApplication::ServerApplication( int& argc, char **argv, Type t ) 295ServerApplication::ServerApplication( int& argc, char **argv, Type t )
296 : QPEApplication( argc, argv, t ) 296 : QPEApplication( argc, argv, t )
297{ 297{
298 ms_is_starting = true; 298 ms_is_starting = true;
299 299
300 // We know we'll have lots of cached pixmaps due to App/DocLnks 300 // We know we'll have lots of cached pixmaps due to App/DocLnks
301 QPixmapCache::setCacheLimit(512); 301 QPixmapCache::setCacheLimit(512);
302 302
303 m_ps = new PowerStatus; 303 m_ps = new PowerStatus;
304 m_ps_last = new PowerStatus; 304 m_ps_last = new PowerStatus;
305 pa = new DesktopPowerAlerter( 0 ); 305 pa = new DesktopPowerAlerter( 0 );
306 306
307 m_apm_timer = new QTimer( this ); 307 m_apm_timer = new QTimer( this );
308 connect(m_apm_timer, SIGNAL( timeout() ), 308 connect(m_apm_timer, SIGNAL( timeout() ),
309 this, SLOT( apmTimeout() ) ); 309 this, SLOT( apmTimeout() ) );
310 310
311 reloadPowerWarnSettings(); 311 reloadPowerWarnSettings();
312 312
313 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 313 QCopChannel *channel = new QCopChannel( "QPE/System", this );
314 connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), 314 connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ),
315 this, SLOT(systemMessage(const QCString&,const QByteArray&) ) ); 315 this, SLOT(systemMessage(const QCString&,const QByteArray&) ) );
316 316
317 channel = new QCopChannel("QPE/Launcher", this ); 317 channel = new QCopChannel("QPE/Launcher", this );
318 connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), 318 connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ),
319 this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) ); 319 this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) );
320 320
321 m_screensaver = new OpieScreenSaver(); 321 m_screensaver = new OpieScreenSaver();
322 m_screensaver->setInterval( -1 ); 322 m_screensaver->setInterval( -1 );
323 QWSServer::setScreenSaver( m_screensaver ); 323 QWSServer::setScreenSaver( m_screensaver );
324 324
325 connect( qApp, SIGNAL( volumeChanged(bool) ), 325 connect( qApp, SIGNAL( volumeChanged(bool) ),
326 this, SLOT( rereadVolumes() ) ); 326 this, SLOT( rereadVolumes() ) );
327 327
328 328
329 /* ### PluginLoader libqtopia SafeMode */ 329 /* ### PluginLoader libqtopia SafeMode */
330#if 0 330#if 0
331 if ( PluginLoader::inSafeMode() ) 331 if ( PluginLoader::inSafeMode() )
332 QTimer::singleShot(500, this, SLOT(showSafeMode()) ); 332 QTimer::singleShot(500, this, SLOT(showSafeMode()) );
333 QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); 333 QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) );
334#endif 334#endif
335 335
336 kf = new KeyFilter(this); 336 kf = new KeyFilter(this);
337 337
338 connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); 338 connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) );
339 connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); 339 connect( kf, SIGNAL(power()), this, SIGNAL(power()) );
340 connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); 340 connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) );
341 connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); 341 connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol()));
342 connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); 342 connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle()));
343 connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); 343 connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle()));
344 connect( kf, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), 344 connect( kf, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)),
345 this,SIGNAL(activate(const Opie::Core::ODeviceButton*,bool))); 345 this,SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)));
346 346
347 347
348 connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); 348 connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) );
349 349
350 connect( this, SIGNAL(power() ), 350 connect( this, SIGNAL(power() ),
351 SLOT(togglePower() ) ); 351 SLOT(togglePower() ) );
352 352
353 rereadVolumes(); 353 rereadVolumes();
354 354
355 serverApp = this; 355 serverApp = this;
356 356
357 apmTimeout(); 357 apmTimeout();
358 grabKeyboard(); 358 grabKeyboard();
359 359
360 /* make sure the event filter is installed */ 360 /* make sure the event filter is installed */ /* std::limits<short>::max() when you've stdc++ */
361 const ODeviceButton* but = ODevice::inst()->buttonForKeycode( -1 ); 361 const ODeviceButton* but = ODevice::inst()->buttonForKeycode( SHRT_MAX );
362 Q_CONST_UNUSED( but ) 362 Q_CONST_UNUSED( but )
363} 363}
364 364
365 365
366ServerApplication::~ServerApplication() 366ServerApplication::~ServerApplication()
367{ 367{
368 ungrabKeyboard(); 368 ungrabKeyboard();
369 369
370 delete pa; 370 delete pa;
371 delete m_ps; 371 delete m_ps;
372 delete m_ps_last; 372 delete m_ps_last;
373} 373}
374 374
375void ServerApplication::apmTimeout() 375void ServerApplication::apmTimeout()
376{ 376{
377 serverApp-> checkMemory( ); // in case no events are generated 377 serverApp-> checkMemory( ); // in case no events are generated
378 *m_ps_last = *m_ps; 378 *m_ps_last = *m_ps;
379 *m_ps = PowerStatusManager::readStatus(); 379 *m_ps = PowerStatusManager::readStatus();
380 380
381 if ( m_ps->acStatus() != m_ps_last-> acStatus() ) 381 if ( m_ps->acStatus() != m_ps_last-> acStatus() )
382 m_screensaver-> powerStatusChanged( *m_ps ); 382 m_screensaver-> powerStatusChanged( *m_ps );
383 383
384 if ( m_ps->acStatus() == PowerStatus::Online ) { 384 if ( m_ps->acStatus() == PowerStatus::Online ) {
385 return; 385 return;
386 } 386 }
387 387
388 int bat = m_ps-> batteryPercentRemaining(); 388 int bat = m_ps-> batteryPercentRemaining();
389 389
390 if ( bat < m_ps_last-> batteryPercentRemaining() ) { 390 if ( bat < m_ps_last-> batteryPercentRemaining() ) {
391 if ( bat <= m_powerCritical ) { 391 if ( bat <= m_powerCritical ) {
392 QMessageBox battlow( 392 QMessageBox battlow(
393 tr("WARNING"), 393 tr("WARNING"),
394 tr("<p>The battery level is critical!" 394 tr("<p>The battery level is critical!"
395 "<p>Keep power off until AC is restored"), 395 "<p>Keep power off until AC is restored"),
396 QMessageBox::Warning, 396 QMessageBox::Warning,
397 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, 397 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton,
398 0, QString::null, TRUE, WStyle_StaysOnTop); 398 0, QString::null, TRUE, WStyle_StaysOnTop);
399 battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); 399 battlow.setButtonText(QMessageBox::Cancel, tr("Ok"));
400 battlow.exec(); 400 battlow.exec();
401 } else if ( bat <= m_powerVeryLow ) 401 } else if ( bat <= m_powerVeryLow )
402 pa->alert( tr( "The battery is running very low. "), 2 ); 402 pa->alert( tr( "The battery is running very low. "), 2 );
403 } 403 }
404 404
405 if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { 405 if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) {
406 QMessageBox battlow( 406 QMessageBox battlow(
407 tr("WARNING"), 407 tr("WARNING"),
408 tr("<p>The Back-up battery is very low" 408 tr("<p>The Back-up battery is very low"
409 "<p>Please charge the back-up battery"), 409 "<p>Please charge the back-up battery"),
410 QMessageBox::Warning, 410 QMessageBox::Warning,
411 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, 411 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton,
412 0, QString::null, TRUE, WStyle_StaysOnTop); 412 0, QString::null, TRUE, WStyle_StaysOnTop);
413 battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); 413 battlow.setButtonText(QMessageBox::Cancel, tr("Ok"));
414 battlow.exec(); 414 battlow.exec();
415 } 415 }
416} 416}
417 417
418void ServerApplication::systemMessage( const QCString& msg, 418void ServerApplication::systemMessage( const QCString& msg,
419 const QByteArray& data ) 419 const QByteArray& data )
420{ 420{
421 QDataStream stream ( data, IO_ReadOnly ); 421 QDataStream stream ( data, IO_ReadOnly );
422 422
423 if ( msg == "setScreenSaverInterval(int)" ) { 423 if ( msg == "setScreenSaverInterval(int)" ) {
424 int time; 424 int time;
425 stream >> time; 425 stream >> time;
426 m_screensaver-> setInterval( time ); 426 m_screensaver-> setInterval( time );
427 } 427 }
428 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 428 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
429 int t1, t2, t3; 429 int t1, t2, t3;
430 stream >> t1 >> t2 >> t3; 430 stream >> t1 >> t2 >> t3;
431 m_screensaver-> setIntervals( t1, t2, t3 ); 431 m_screensaver-> setIntervals( t1, t2, t3 );
432 } 432 }
433 else if ( msg == "setBacklight(int)" ) { 433 else if ( msg == "setBacklight(int)" ) {
434 int bright; 434 int bright;
435 stream >> bright; 435 stream >> bright;
436 m_screensaver-> setBacklight( bright ); 436 m_screensaver-> setBacklight( bright );
437 } 437 }
438 else if ( msg == "setScreenSaverMode(int)" ) { 438 else if ( msg == "setScreenSaverMode(int)" ) {
439 int mode; 439 int mode;
440 stream >> mode; 440 stream >> mode;
441 m_screensaver-> setMode ( mode ); 441 m_screensaver-> setMode ( mode );
442 } 442 }
443 else if ( msg == "reloadPowerWarnSettings()" ) { 443 else if ( msg == "reloadPowerWarnSettings()" ) {
444 reloadPowerWarnSettings(); 444 reloadPowerWarnSettings();
445 } 445 }
446 else if ( msg == "setDisplayState(int)" ) { 446 else if ( msg == "setDisplayState(int)" ) {
447 int state; 447 int state;
448 stream >> state; 448 stream >> state;
449 m_screensaver-> setDisplayState ( state != 0 ); 449 m_screensaver-> setDisplayState ( state != 0 );
450 } 450 }
451 else if ( msg == "suspend()" ) { 451 else if ( msg == "suspend()" ) {
452 emit power(); 452 emit power();
453 } 453 }
454 else if ( msg == "sendBusinessCard()" ) { 454 else if ( msg == "sendBusinessCard()" ) {
455 QString card = ::getenv ( "HOME" ); 455 QString card = ::getenv ( "HOME" );
456 card += "/Applications/addressbook/businesscard.vcf"; 456 card += "/Applications/addressbook/businesscard.vcf";
457 457
458 if ( QFile::exists( card ) ) { 458 if ( QFile::exists( card ) ) {
459 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); 459 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" );
460 QString mimetype = "text/x-vCard"; 460 QString mimetype = "text/x-vCard";
461 e << tr( "business card" ) << card << mimetype; 461 e << tr( "business card" ) << card << mimetype;
462 } 462 }
463 } 463 }
464} 464}
465 465
466void ServerApplication::reloadPowerWarnSettings ( ) 466void ServerApplication::reloadPowerWarnSettings ( )
467{ 467{
468 Config cfg ( "apm" ); 468 Config cfg ( "apm" );
469 cfg. setGroup ( "Warnings" ); 469 cfg. setGroup ( "Warnings" );
470 470
471 int iv = cfg. readNumEntry ( "checkinterval", 10000 ); 471 int iv = cfg. readNumEntry ( "checkinterval", 10000 );
472 472
473 m_apm_timer-> stop ( ); 473 m_apm_timer-> stop ( );
474 if ( iv ) 474 if ( iv )
475 m_apm_timer-> start ( iv ); 475 m_apm_timer-> start ( iv );
476 476
477 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); 477 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 );
478 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); 478 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 );
479} 479}
480 480
481void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) 481void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data )
482{ 482{
483 QDataStream stream ( data, IO_ReadOnly ); 483 QDataStream stream ( data, IO_ReadOnly );
484 484
485 if ( msg == "deviceButton(int,int,int)" ) { 485 if ( msg == "deviceButton(int,int,int)" ) {
486 int keycode, press, autoRepeat; 486 int keycode, press, autoRepeat;
487 stream >> keycode >> press >> autoRepeat; 487 stream >> keycode >> press >> autoRepeat;
488 488
489 kf->checkButtonAction ( true, keycode, press, autoRepeat ); 489 kf->checkButtonAction ( true, keycode, press, autoRepeat );