summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-03-07 11:05:40 (UTC)
committer harlekin <harlekin>2002-03-07 11:05:40 (UTC)
commita2f42b6df21b2e5d52b49376542d0f4c7443a897 (patch) (unidiff)
treebfbacf25dd213cdb2b7a86a007e4598a1634bb18
parent09444065297662fca1396abf8c0c9dd00380699f (diff)
downloadopie-a2f42b6df21b2e5d52b49376542d0f4c7443a897.zip
opie-a2f42b6df21b2e5d52b49376542d0f4c7443a897.tar.gz
opie-a2f42b6df21b2e5d52b49376542d0f4c7443a897.tar.bz2
beginning support for autostart
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp48
-rw-r--r--core/launcher/desktop.h1
-rw-r--r--core/launcher/launcher.cpp60
3 files changed, 80 insertions, 29 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index a00fae2..4587ec6 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,151 +1,150 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "desktop.h" 21#include "desktop.h"
22#include "info.h" 22#include "info.h"
23#include "launcher.h" 23#include "launcher.h"
24#include "mrulist.h" 24#include "mrulist.h"
25#include "qcopbridge.h" 25#include "qcopbridge.h"
26#include "shutdownimpl.h" 26#include "shutdownimpl.h"
27#include "startmenu.h" 27#include "startmenu.h"
28#include "taskbar.h" 28#include "taskbar.h"
29#include "transferserver.h" 29#include "transferserver.h"
30#include "irserver.h" 30#include "irserver.h"
31#include "packageslave.h" 31#include "packageslave.h"
32 32
33#include <qpe/applnk.h> 33#include <qpe/applnk.h>
34#include <qpe/mimetype.h> 34#include <qpe/mimetype.h>
35#include <qpe/password.h> 35#include <qpe/password.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/power.h> 37#include <qpe/power.h>
38#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39#include <qpe/global.h> 39#include <qpe/global.h>
40#ifdef QT_QWS_CUSTOM 40#ifdef QT_QWS_CUSTOM
41#include "qpe/custom.h" 41#include "qpe/custom.h"
42#endif 42#endif
43 43
44#include <qgfx_qws.h> 44#include <qgfx_qws.h>
45#include <qmainwindow.h> 45#include <qmainwindow.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qtimer.h> 47#include <qtimer.h>
48#include <qwindowsystem_qws.h> 48#include <qwindowsystem_qws.h>
49 49
50#include <qvaluelist.h> 50#include <qvaluelist.h>
51 51
52#include <stdlib.h> 52#include <stdlib.h>
53#include <unistd.h> 53#include <unistd.h>
54 54
55
56class QCopKeyRegister 55class QCopKeyRegister
57{ 56{
58public: 57public:
59 QCopKeyRegister() : keyCode(0) { } 58 QCopKeyRegister() : keyCode(0) { }
60 QCopKeyRegister(int k, const QString &c, const QString &m) 59 QCopKeyRegister(int k, const QString &c, const QString &m)
61 : keyCode(k), channel(c), message(m) { } 60 : keyCode(k), channel(c), message(m) { }
62 61
63 int getKeyCode() const { return keyCode; } 62 int getKeyCode() const { return keyCode; }
64 QString getChannel() const { return channel; } 63 QString getChannel() const { return channel; }
65 QString getMessage() const { return message; } 64 QString getMessage() const { return message; }
66 65
67private: 66private:
68 int keyCode; 67 int keyCode;
69 QString channel, message; 68 QString channel, message;
70}; 69};
71 70
72typedef QValueList<QCopKeyRegister> KeyRegisterList; 71typedef QValueList<QCopKeyRegister> KeyRegisterList;
73KeyRegisterList keyRegisterList; 72KeyRegisterList keyRegisterList;
74 73
75static Desktop* qpedesktop = 0; 74static Desktop* qpedesktop = 0;
76static int loggedin=0; 75static int loggedin=0;
77static void login(bool at_poweron) 76static void login(bool at_poweron)
78{ 77{
79 if ( !loggedin ) { 78 if ( !loggedin ) {
80 Global::terminateBuiltin("calibrate"); 79 Global::terminateBuiltin("calibrate");
81 Password::authenticate(at_poweron); 80 Password::authenticate(at_poweron);
82 loggedin=1; 81 loggedin=1;
83 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 82 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
84 } 83 }
85} 84}
86 85
87bool Desktop::screenLocked() 86bool Desktop::screenLocked()
88{ 87{
89 return loggedin == 0; 88 return loggedin == 0;
90} 89}
91 90
92/* 91/*
93 Priority is number of alerts that are needed to pop up 92 Priority is number of alerts that are needed to pop up
94 alert. 93 alert.
95 */ 94 */
96class DesktopPowerAlerter : public QMessageBox 95class DesktopPowerAlerter : public QMessageBox
97{ 96{
98public: 97public:
99 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 98 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
100 : QMessageBox( tr("Battery Status"), "Low Battery", 99 : QMessageBox( tr("Battery Status"), "Low Battery",
101 QMessageBox::Critical, 100 QMessageBox::Critical,
102 QMessageBox::Ok | QMessageBox::Default, 101 QMessageBox::Ok | QMessageBox::Default,
103 QMessageBox::NoButton, QMessageBox::NoButton, 102 QMessageBox::NoButton, QMessageBox::NoButton,
104 parent, name, FALSE ) 103 parent, name, FALSE )
105 { 104 {
106 currentPriority = INT_MAX; 105 currentPriority = INT_MAX;
107 alertCount = 0; 106 alertCount = 0;
108 } 107 }
109 108
110 void alert( const QString &text, int priority ); 109 void alert( const QString &text, int priority );
111 void hideEvent( QHideEvent * ); 110 void hideEvent( QHideEvent * );
112private: 111private:
113 int currentPriority; 112 int currentPriority;
114 int alertCount; 113 int alertCount;
115}; 114};
116 115
117void DesktopPowerAlerter::alert( const QString &text, int priority ) 116void DesktopPowerAlerter::alert( const QString &text, int priority )
118{ 117{
119 alertCount++; 118 alertCount++;
120 if ( alertCount < priority ) 119 if ( alertCount < priority )
121 return; 120 return;
122 if ( priority > currentPriority ) 121 if ( priority > currentPriority )
123 return; 122 return;
124 currentPriority = priority; 123 currentPriority = priority;
125 setText( text ); 124 setText( text );
126 show(); 125 show();
127} 126}
128 127
129 128
130void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 129void DesktopPowerAlerter::hideEvent( QHideEvent *e )
131{ 130{
132 QMessageBox::hideEvent( e ); 131 QMessageBox::hideEvent( e );
133 alertCount = 0; 132 alertCount = 0;
134 currentPriority = INT_MAX; 133 currentPriority = INT_MAX;
135} 134}
136 135
137 136
138 137
139DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) 138DesktopApplication::DesktopApplication( int& argc, char **argv, Type t )
140 : QPEApplication( argc, argv, t ) 139 : QPEApplication( argc, argv, t )
141{ 140{
142 141
143 QTimer *t = new QTimer( this ); 142 QTimer *t = new QTimer( this );
144 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 143 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
145 t->start( 10000 ); 144 t->start( 10000 );
146 ps = new PowerStatus; 145 ps = new PowerStatus;
147 pa = new DesktopPowerAlerter( 0 ); 146 pa = new DesktopPowerAlerter( 0 );
148 147
149 channel = new QCopChannel( "QPE/Desktop", this ); 148 channel = new QCopChannel( "QPE/Desktop", this );
150 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 149 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
151 this, SLOT(receive(const QCString&, const QByteArray&)) ); 150 this, SLOT(receive(const QCString&, const QByteArray&)) );
@@ -404,242 +403,257 @@ void Desktop::checkMemory()
404 if ( recoverMemory() ) 403 if ( recoverMemory() )
405 ignoreNormal = TRUE; 404 ignoreNormal = TRUE;
406 else 405 else
407 QMessageBox::warning( 0 , "Memory Status", 406 QMessageBox::warning( 0 , "Memory Status",
408 "The memory smacks of shortage. \n" 407 "The memory smacks of shortage. \n"
409 "Please save data. " ); 408 "Please save data. " );
410 break; 409 break;
411 case Normal: 410 case Normal:
412 memstate = Unknown; 411 memstate = Unknown;
413 if ( ignoreNormal ) 412 if ( ignoreNormal )
414 ignoreNormal = FALSE; 413 ignoreNormal = FALSE;
415 else 414 else
416 QMessageBox::information ( 0 , "Memory Status", 415 QMessageBox::information ( 0 , "Memory Status",
417 "There is enough memory again." ); 416 "There is enough memory again." );
418 break; 417 break;
419 case VeryLow: 418 case VeryLow:
420 memstate = Unknown; 419 memstate = Unknown;
421 QMessageBox::critical( 0 , "Memory Status", 420 QMessageBox::critical( 0 , "Memory Status",
422 "The memory is very low. \n" 421 "The memory is very low. \n"
423 "Please end this application \n" 422 "Please end this application \n"
424 "immediately." ); 423 "immediately." );
425 recoverMemory(); 424 recoverMemory();
426 } 425 }
427 existingMessage = FALSE; 426 existingMessage = FALSE;
428#endif 427#endif
429} 428}
430 429
431static bool isVisibleWindow(int wid) 430static bool isVisibleWindow(int wid)
432{ 431{
433 const QList<QWSWindow> &list = qwsServer->clientWindows(); 432 const QList<QWSWindow> &list = qwsServer->clientWindows();
434 QWSWindow* w; 433 QWSWindow* w;
435 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 434 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
436 if ( w->winId() == wid ) 435 if ( w->winId() == wid )
437 return !w->isFullyObscured(); 436 return !w->isFullyObscured();
438 } 437 }
439 return FALSE; 438 return FALSE;
440} 439}
441 440
442static bool hasVisibleWindow(const QString& clientname) 441static bool hasVisibleWindow(const QString& clientname)
443{ 442{
444 const QList<QWSWindow> &list = qwsServer->clientWindows(); 443 const QList<QWSWindow> &list = qwsServer->clientWindows();
445 QWSWindow* w; 444 QWSWindow* w;
446 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 445 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
447 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 446 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
448 return TRUE; 447 return TRUE;
449 } 448 }
450 return FALSE; 449 return FALSE;
451} 450}
452 451
453void Desktop::raiseLauncher() 452void Desktop::raiseLauncher()
454{ 453{
455 if ( isVisibleWindow(launcher->winId()) ) 454 if ( isVisibleWindow(launcher->winId()) )
456 launcher->nextView(); 455 launcher->nextView();
457 else 456 else
458 launcher->raise(); 457 launcher->raise();
459} 458}
460 459
461void Desktop::executeOrModify(const QString& appLnkFile) 460void Desktop::executeOrModify(const QString& appLnkFile)
462{ 461{
463 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 462 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
464 if ( lnk.isValid() ) { 463 if ( lnk.isValid() ) {
465 QCString app = lnk.exec().utf8(); 464 QCString app = lnk.exec().utf8();
466 Global::terminateBuiltin("calibrate"); 465 Global::terminateBuiltin("calibrate");
467 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 466 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
468 MRUList::addTask(&lnk); 467 MRUList::addTask(&lnk);
469 if ( hasVisibleWindow(app) ) 468 if ( hasVisibleWindow(app) )
470 QCopChannel::send("QPE/Application/" + app, "nextView()"); 469 QCopChannel::send("QPE/Application/" + app, "nextView()");
471 else 470 else
472 QCopChannel::send("QPE/Application/" + app, "raise()"); 471 QCopChannel::send("QPE/Application/" + app, "raise()");
473 } else { 472 } else {
474 lnk.execute(); 473 lnk.execute();
475 } 474 }
476 } 475 }
477} 476}
478 477
479void Desktop::raiseDatebook() 478void Desktop::raiseDatebook()
480{ 479{
481 executeOrModify("Applications/datebook.desktop"); 480 executeOrModify("Applications/datebook.desktop");
482} 481}
483 482
484void Desktop::raiseContacts() 483void Desktop::raiseContacts()
485{ 484{
486 executeOrModify("Applications/addressbook.desktop"); 485 executeOrModify("Applications/addressbook.desktop");
487} 486}
488 487
489void Desktop::raiseMenu() 488void Desktop::raiseMenu()
490{ 489{
491 Global::terminateBuiltin("calibrate"); 490 Global::terminateBuiltin("calibrate");
492 tb->startMenu()->launch(); 491 tb->startMenu()->launch();
493} 492}
494 493
495void Desktop::raiseEmail() 494void Desktop::raiseEmail()
496{ 495{
497 executeOrModify("Applications/qtmail.desktop"); 496 executeOrModify("Applications/qtmail.desktop");
498} 497}
499 498
499// autoStarts apps on resume and start
500void Desktop::execAutoStart()
501{
502 QString appName;
503 Config cfg( "autostart" );
504 cfg.setGroup( "AutoStart" );
505 appName = cfg.readEntry("Apps", "");
506 QCopEnvelope e("QPE/System", "execute(QString)");
507 e << QString(appName);
508}
509
500#if defined(QPE_HAVE_TOGGLELIGHT) 510#if defined(QPE_HAVE_TOGGLELIGHT)
501#include <qpe/config.h> 511#include <qpe/config.h>
502 512
503#include <sys/ioctl.h> 513#include <sys/ioctl.h>
504#include <sys/types.h> 514#include <sys/types.h>
505#include <fcntl.h> 515#include <fcntl.h>
506#include <unistd.h> 516#include <unistd.h>
507#include <errno.h> 517#include <errno.h>
508#include <linux/ioctl.h> 518#include <linux/ioctl.h>
509#include <time.h> 519#include <time.h>
510#endif 520#endif
511 521
512static bool blanked=FALSE; 522static bool blanked=FALSE;
513 523
514static void blankScreen() 524static void blankScreen()
515{ 525{
516 if ( !qt_screen ) return; 526 if ( !qt_screen ) return;
517 /* Should use a big black window instead. 527 /* Should use a big black window instead.
518 QGfx* g = qt_screen->screenGfx(); 528 QGfx* g = qt_screen->screenGfx();
519 g->fillRect(0,0,qt_screen->width(),qt_screen->height()); 529 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
520 delete g; 530 delete g;
521 */ 531 */
522 blanked = TRUE; 532 blanked = TRUE;
523} 533}
524 534
525static void darkScreen() 535static void darkScreen()
526{ 536{
527 extern void qpe_setBacklight(int); 537 extern void qpe_setBacklight(int);
528 qpe_setBacklight(0); // force off 538 qpe_setBacklight(0); // force off
529} 539}
530 540
531 541
532void Desktop::togglePower() 542void Desktop::togglePower()
533{ 543{
534 bool wasloggedin = loggedin; 544 bool wasloggedin = loggedin;
535 loggedin=0; 545 loggedin=0;
536 darkScreen(); 546 darkScreen();
537 if ( wasloggedin ) 547 if ( wasloggedin )
538 blankScreen(); 548 blankScreen();
539 system("apm --suspend"); 549
540 QWSServer::screenSaverActivate( FALSE ); 550 system("apm --suspend");
541 { 551 execAutoStart();
542 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 552 QWSServer::screenSaverActivate( FALSE );
543 QCopEnvelope e("QPE/System", "setBacklight(int)"); 553 {
544 e << -3; // Force on 554 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
545 } 555 QCopEnvelope e("QPE/System", "setBacklight(int)");
546 if ( wasloggedin ) 556 e << -3; // Force on
547 login(TRUE); 557 }
548 //qcopBridge->closeOpenConnections(); 558 if ( wasloggedin ) {
549 //qDebug("called togglePower()!!!!!!"); 559 login(TRUE);
560 }
561
562 //qcopBridge->closeOpenConnections();
563 //qDebug("called togglePower()!!!!!!");
550} 564}
551 565
552void Desktop::toggleLight() 566void Desktop::toggleLight()
553{ 567{
554 QCopEnvelope e("QPE/System", "setBacklight(int)"); 568 QCopEnvelope e("QPE/System", "setBacklight(int)");
555 e << -2; // toggle 569 e << -2; // toggle
556} 570}
557 571
558void Desktop::toggleSymbolInput() 572void Desktop::toggleSymbolInput()
559{ 573{
560 tb->toggleSymbolInput(); 574 tb->toggleSymbolInput();
561} 575}
562 576
563void Desktop::toggleNumLockState() 577void Desktop::toggleNumLockState()
564{ 578{
565 tb->toggleNumLockState(); 579 tb->toggleNumLockState();
566} 580}
567 581
568void Desktop::toggleCapsLockState() 582void Desktop::toggleCapsLockState()
569{ 583{
570 tb->toggleCapsLockState(); 584 tb->toggleCapsLockState();
571} 585}
572 586
573void Desktop::styleChange( QStyle &s ) 587void Desktop::styleChange( QStyle &s )
574{ 588{
575 QWidget::styleChange( s ); 589 QWidget::styleChange( s );
576 int displayw = qApp->desktop()->width(); 590 int displayw = qApp->desktop()->width();
577 int displayh = qApp->desktop()->height(); 591 int displayh = qApp->desktop()->height();
578 592
579 QSize sz = tb->sizeHint(); 593 QSize sz = tb->sizeHint();
580 594
581 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 595 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
582} 596}
583 597
584void DesktopApplication::shutdown() 598void DesktopApplication::shutdown()
585{ 599{
586 if ( type() != GuiServer ) 600 if ( type() != GuiServer )
587 return; 601 return;
588 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 602 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
589 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 603 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
590 this, SLOT(shutdown(ShutdownImpl::Type)) ); 604 this, SLOT(shutdown(ShutdownImpl::Type)) );
591 sd->showMaximized(); 605 sd->showMaximized();
592} 606}
593 607
594void DesktopApplication::shutdown( ShutdownImpl::Type t ) 608void DesktopApplication::shutdown( ShutdownImpl::Type t )
595{ 609{
596 switch ( t ) { 610 switch ( t ) {
597 case ShutdownImpl::ShutdownSystem: 611 case ShutdownImpl::ShutdownSystem:
598 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 612 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
599 break; 613 break;
600 case ShutdownImpl::RebootSystem: 614 case ShutdownImpl::RebootSystem:
601 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 615 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
602 break; 616 break;
603 case ShutdownImpl::RestartDesktop: 617 case ShutdownImpl::RestartDesktop:
604 restart(); 618 restart();
605 break; 619 break;
606 case ShutdownImpl::TerminateDesktop: 620 case ShutdownImpl::TerminateDesktop:
607 prepareForTermination(FALSE); 621 prepareForTermination(FALSE);
608 quit(); 622 quit();
609 break; 623 break;
610 } 624 }
611} 625}
612 626
613void DesktopApplication::restart() 627void DesktopApplication::restart()
614{ 628{
615 prepareForTermination(TRUE); 629 prepareForTermination(TRUE);
616 630
617#ifdef Q_WS_QWS 631#ifdef Q_WS_QWS
618 for ( int fd = 3; fd < 100; fd++ ) 632 for ( int fd = 3; fd < 100; fd++ )
619 close( fd ); 633 close( fd );
620#if defined(QT_DEMO_SINGLE_FLOPPY) 634#if defined(QT_DEMO_SINGLE_FLOPPY)
621 execl( "/sbin/init", "qpe", 0 ); 635 execl( "/sbin/init", "qpe", 0 );
622#elif defined(QT_QWS_CASSIOPEIA) 636#elif defined(QT_QWS_CASSIOPEIA)
623 execl( "/bin/sh", "sh", 0 ); 637 execl( "/bin/sh", "sh", 0 );
624#else 638#else
625 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 639 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
626#endif 640#endif
627 exit(1); 641 exit(1);
628#endif 642#endif
629} 643}
630 644
631void Desktop::startTransferServer() 645void Desktop::startTransferServer()
632{ 646{
633 // start qcop bridge server 647 // start qcop bridge server
634 qcopBridge = new QCopBridge( 4243 ); 648 qcopBridge = new QCopBridge( 4243 );
635 if ( !qcopBridge->ok() ) { 649 if ( !qcopBridge->ok() ) {
636 delete qcopBridge; 650 delete qcopBridge;
637 qcopBridge = 0; 651 qcopBridge = 0;
638 } 652 }
639 // start transfer server 653 // start transfer server
640 transferServer = new TransferServer( 4242 ); 654 transferServer = new TransferServer( 4242 );
641 if ( !transferServer->ok() ) { 655 if ( !transferServer->ok() ) {
642 delete transferServer; 656 delete transferServer;
643 transferServer = 0; 657 transferServer = 0;
644 } 658 }
645 if ( !transferServer || !qcopBridge ) 659 if ( !transferServer || !qcopBridge )
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index f0a7cba..de0dbf0 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -6,128 +6,129 @@
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef __DESKTOP_H__ 21#ifndef __DESKTOP_H__
22#define __DESKTOP_H__ 22#define __DESKTOP_H__
23 23
24 24
25#include "shutdownimpl.h" 25#include "shutdownimpl.h"
26 26
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28 28
29#include <qwidget.h> 29#include <qwidget.h>
30 30
31class Background; 31class Background;
32class Launcher; 32class Launcher;
33class TaskBar; 33class TaskBar;
34class PowerStatus; 34class PowerStatus;
35class QCopBridge; 35class QCopBridge;
36class TransferServer; 36class TransferServer;
37class DesktopPowerAlerter; 37class DesktopPowerAlerter;
38class PackageSlave; 38class PackageSlave;
39 39
40class DesktopApplication : public QPEApplication 40class DesktopApplication : public QPEApplication
41{ 41{
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
44 DesktopApplication( int& argc, char **argv, Type t ); 44 DesktopApplication( int& argc, char **argv, Type t );
45 ~DesktopApplication(); 45 ~DesktopApplication();
46signals: 46signals:
47 void home(); 47 void home();
48 void datebook(); 48 void datebook();
49 void contacts(); 49 void contacts();
50 void launch(); 50 void launch();
51 void email(); 51 void email();
52 void backlight(); 52 void backlight();
53 void power(); 53 void power();
54 void symbol(); 54 void symbol();
55 void numLockStateToggle(); 55 void numLockStateToggle();
56 void capsLockStateToggle(); 56 void capsLockStateToggle();
57 void prepareForRestart(); 57 void prepareForRestart();
58 58
59protected: 59protected:
60#ifdef Q_WS_QWS 60#ifdef Q_WS_QWS
61 bool qwsEventFilter( QWSEvent * ); 61 bool qwsEventFilter( QWSEvent * );
62#endif 62#endif
63 void shutdown(); 63 void shutdown();
64 void restart(); 64 void restart();
65 65
66public slots: 66public slots:
67 void receive( const QCString &msg, const QByteArray &data ); 67 void receive( const QCString &msg, const QByteArray &data );
68 68
69protected slots: 69protected slots:
70 void shutdown(ShutdownImpl::Type); 70 void shutdown(ShutdownImpl::Type);
71 void psTimeout(); 71 void psTimeout();
72 void sendCard(); 72 void sendCard();
73private: 73private:
74 DesktopPowerAlerter *pa; 74 DesktopPowerAlerter *pa;
75 PowerStatus *ps; 75 PowerStatus *ps;
76 QTimer *cardSendTimer; 76 QTimer *cardSendTimer;
77 QCopChannel *channel; 77 QCopChannel *channel;
78}; 78};
79 79
80 80
81class Desktop : public QWidget { 81class Desktop : public QWidget {
82 Q_OBJECT 82 Q_OBJECT
83public: 83public:
84 Desktop(); 84 Desktop();
85 ~Desktop(); 85 ~Desktop();
86 86
87 static bool screenLocked(); 87 static bool screenLocked();
88 88
89 void show(); 89 void show();
90 void checkMemory(); 90 void checkMemory();
91 91
92 void keyClick(); 92 void keyClick();
93 void screenClick(); 93 void screenClick();
94 static void soundAlarm(); 94 static void soundAlarm();
95 95
96public slots: 96public slots:
97 void raiseDatebook(); 97 void raiseDatebook();
98 void raiseContacts(); 98 void raiseContacts();
99 void raiseMenu(); 99 void raiseMenu();
100 void raiseLauncher(); 100 void raiseLauncher();
101 void raiseEmail(); 101 void raiseEmail();
102 void execAutoStart();
102 void togglePower(); 103 void togglePower();
103 void toggleLight(); 104 void toggleLight();
104 void toggleNumLockState(); 105 void toggleNumLockState();
105 void toggleCapsLockState(); 106 void toggleCapsLockState();
106 void toggleSymbolInput(); 107 void toggleSymbolInput();
107 void terminateServers(); 108 void terminateServers();
108 void rereadVolumes(); 109 void rereadVolumes();
109 110
110protected: 111protected:
111 void executeOrModify(const QString& appLnkFile); 112 void executeOrModify(const QString& appLnkFile);
112 void styleChange( QStyle & ); 113 void styleChange( QStyle & );
113 void timerEvent( QTimerEvent *e ); 114 void timerEvent( QTimerEvent *e );
114 bool eventFilter( QObject *, QEvent * ); 115 bool eventFilter( QObject *, QEvent * );
115 116
116 QWidget *bg; 117 QWidget *bg;
117 Launcher *launcher; 118 Launcher *launcher;
118 TaskBar *tb; 119 TaskBar *tb;
119 120
120private: 121private:
121 void startTransferServer(); 122 void startTransferServer();
122 bool recoverMemory(); 123 bool recoverMemory();
123 124
124 QCopBridge *qcopBridge; 125 QCopBridge *qcopBridge;
125 TransferServer *transferServer; 126 TransferServer *transferServer;
126 PackageSlave *packageSlave; 127 PackageSlave *packageSlave;
127 128
128 bool keyclick,touchclick; 129 bool keyclick,touchclick;
129}; 130};
130 131
131 132
132#endif // __DESKTOP_H__ 133#endif // __DESKTOP_H__
133 134
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 66a2ce5..0573330 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,116 +1,120 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
22// have this class.
23#define QTOPIA_INTERNAL_FSLP
24
21#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
22#include <qpe/resource.h> 26#include <qpe/resource.h>
23#include <qpe/applnk.h> 27#include <qpe/applnk.h>
24#include <qpe/config.h> 28#include <qpe/config.h>
25#include <qpe/global.h> 29#include <qpe/global.h>
26#include <qpe/qpeapplication.h> 30#include <qpe/qpeapplication.h>
27#include <qpe/mimetype.h> 31#include <qpe/mimetype.h>
28#include <qpe/storage.h> 32#include <qpe/storage.h>
29#include <qpe/palmtoprecord.h> 33#include <qpe/palmtoprecord.h>
30 34
31#include <qdir.h> 35#include <qdir.h>
32#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
33#include <qtimer.h> 37#include <qtimer.h>
34#include <qcombobox.h> 38#include <qcombobox.h>
35#include <qvbox.h> 39#include <qvbox.h>
36#include <qlayout.h> 40#include <qlayout.h>
37#include <qstyle.h> 41#include <qstyle.h>
38#include <qpushbutton.h> 42#include <qpushbutton.h>
39#include <qtabbar.h> 43#include <qtabbar.h>
40#include <qwidgetstack.h> 44#include <qwidgetstack.h>
41#include <qlayout.h> 45#include <qlayout.h>
42#include <qregexp.h> 46#include <qregexp.h>
43#include <qmessagebox.h> 47#include <qmessagebox.h>
44#include <qframe.h> 48#include <qframe.h>
45#include <qpainter.h> 49#include <qpainter.h>
46#include <qlabel.h> 50#include <qlabel.h>
47#include <qtextstream.h> 51#include <qtextstream.h>
48 52
49#include "launcherview.h" 53#include "launcherview.h"
50#include "launcher.h" 54#include "launcher.h"
51#include "syncdialog.h" 55#include "syncdialog.h"
52#include "desktop.h" 56#include "desktop.h"
53#include <qpe/lnkproperties.h> 57#include <qpe/lnkproperties.h>
54#include "mrulist.h" 58#include "mrulist.h"
55#include "qrsync.h" 59#include "qrsync.h"
56#include <stdlib.h> 60#include <stdlib.h>
57#include <unistd.h> 61#include <unistd.h>
58 62
59#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 63#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
60#include <stdio.h> 64#include <stdio.h>
61#include <sys/vfs.h> 65#include <sys/vfs.h>
62#include <mntent.h> 66#include <mntent.h>
63#endif 67#endif
64 68
65//#define SHOW_ALL 69//#define SHOW_ALL
66 70
67CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : 71CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
68 QVBox( parent ) 72 QVBox( parent )
69{ 73{
70 categoryBar = 0; 74 categoryBar = 0;
71 stack = 0; 75 stack = 0;
72} 76}
73 77
74void CategoryTabWidget::prevTab() 78void CategoryTabWidget::prevTab()
75{ 79{
76 if ( categoryBar ) { 80 if ( categoryBar ) {
77 int n = categoryBar->count(); 81 int n = categoryBar->count();
78 int tab = categoryBar->currentTab(); 82 int tab = categoryBar->currentTab();
79 if ( tab >= 0 ) 83 if ( tab >= 0 )
80 categoryBar->setCurrentTab( (tab - 1 + n)%n ); 84 categoryBar->setCurrentTab( (tab - 1 + n)%n );
81 } 85 }
82} 86}
83 87
84void CategoryTabWidget::nextTab() 88void CategoryTabWidget::nextTab()
85{ 89{
86 if ( categoryBar ) { 90 if ( categoryBar ) {
87 int n = categoryBar->count(); 91 int n = categoryBar->count();
88 int tab = categoryBar->currentTab(); 92 int tab = categoryBar->currentTab();
89 categoryBar->setCurrentTab( (tab + 1)%n ); 93 categoryBar->setCurrentTab( (tab + 1)%n );
90 } 94 }
91} 95}
92 96
93void CategoryTabWidget::addItem( const QString& linkfile ) 97void CategoryTabWidget::addItem( const QString& linkfile )
94{ 98{
95 int i=0; 99 int i=0;
96 AppLnk *app = new AppLnk(linkfile); 100 AppLnk *app = new AppLnk(linkfile);
97 if ( !app->isValid() ) { 101 if ( !app->isValid() ) {
98 delete app; 102 delete app;
99 return; 103 return;
100 } 104 }
101 if ( !app->file().isEmpty() ) { 105 if ( !app->file().isEmpty() ) {
102 // A document 106 // A document
103 delete app; 107 delete app;
104 app = new DocLnk(linkfile); 108 app = new DocLnk(linkfile);
105 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); 109 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app);
106 return; 110 return;
107 } 111 }
108 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { 112 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) {
109 if ( !(*it).isEmpty() ) { 113 if ( !(*it).isEmpty() ) {
110 QRegExp tf(*it,FALSE,TRUE); 114 QRegExp tf(*it,FALSE,TRUE);
111 if ( tf.match(app->type()) >= 0 ) { 115 if ( tf.match(app->type()) >= 0 ) {
112 ((LauncherView*)stack->widget(i))->addItem(app); 116 ((LauncherView*)stack->widget(i))->addItem(app);
113 return; 117 return;
114 } 118 }
115 i++; 119 i++;
116 } 120 }
@@ -538,267 +542,299 @@ void Launcher::select( const AppLnk *appLnk )
538 tabs->setBusy(TRUE); 542 tabs->setBusy(TRUE);
539 emit executing( appLnk ); 543 emit executing( appLnk );
540 appLnk->execute(); 544 appLnk->execute();
541 } 545 }
542} 546}
543 547
544void Launcher::externalSelected(const AppLnk *appLnk) 548void Launcher::externalSelected(const AppLnk *appLnk)
545{ 549{
546 tabs->setBusy(TRUE); 550 tabs->setBusy(TRUE);
547 emit executing( appLnk ); 551 emit executing( appLnk );
548} 552}
549 553
550void Launcher::properties( AppLnk *appLnk ) 554void Launcher::properties( AppLnk *appLnk )
551{ 555{
552 if ( appLnk->type() == "Folder" ) { 556 if ( appLnk->type() == "Folder" ) {
553 // Not supported: flat is simpler for the user 557 // Not supported: flat is simpler for the user
554 } else { 558 } else {
555 in_lnk_props = TRUE; 559 in_lnk_props = TRUE;
556 got_lnk_change = FALSE; 560 got_lnk_change = FALSE;
557 LnkProperties prop(appLnk); 561 LnkProperties prop(appLnk);
558 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 562 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
559 prop.showMaximized(); 563 prop.showMaximized();
560 prop.exec(); 564 prop.exec();
561 in_lnk_props = FALSE; 565 in_lnk_props = FALSE;
562 if ( got_lnk_change ) { 566 if ( got_lnk_change ) {
563 updateLink(lnk_change); 567 updateLink(lnk_change);
564 } 568 }
565 } 569 }
566} 570}
567 571
568void Launcher::updateLink(const QString& link) 572void Launcher::updateLink(const QString& link)
569{ 573{
570 if (link.isNull()) 574 if (link.isNull())
571 updateTabs(); 575 updateTabs();
572 else if (link.isEmpty()) 576 else if (link.isEmpty())
573 updateDocs(); 577 updateDocs();
574 else 578 else
575 tabs->updateLink(link); 579 tabs->updateLink(link);
576} 580}
577 581
578void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 582void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
579{ 583{
580 QDataStream stream( data, IO_ReadOnly ); 584 QDataStream stream( data, IO_ReadOnly );
581 if ( msg == "linkChanged(QString)" ) { 585 if ( msg == "linkChanged(QString)" ) {
582 QString link; 586 QString link;
583 stream >> link; 587 stream >> link;
584 if ( in_lnk_props ) { 588 if ( in_lnk_props ) {
585 got_lnk_change = TRUE; 589 got_lnk_change = TRUE;
586 lnk_change = link; 590 lnk_change = link;
587 } else { 591 } else {
588 updateLink(link); 592 updateLink(link);
589 } 593 }
590 } else if ( msg == "busy()" ) { 594 } else if ( msg == "busy()" ) {
591 emit busy(); 595 emit busy();
592 } else if ( msg == "notBusy(QString)" ) { 596 } else if ( msg == "notBusy(QString)" ) {
593 QString app; 597 QString app;
594 stream >> app; 598 stream >> app;
595 tabs->setBusy(FALSE); 599 tabs->setBusy(FALSE);
596 emit notBusy(app); 600 emit notBusy(app);
597 } else if ( msg == "mkdir(QString)" ) { 601 } else if ( msg == "mkdir(QString)" ) {
598 QString dir; 602 QString dir;
599 stream >> dir; 603 stream >> dir;
600 if ( !dir.isEmpty() ) 604 if ( !dir.isEmpty() )
601 mkdir( dir ); 605 mkdir( dir );
602 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 606 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
603 QString baseFile, sigFile; 607 QString baseFile, sigFile;
604 stream >> baseFile >> sigFile; 608 stream >> baseFile >> sigFile;
605 QRsync::generateSignature( baseFile, sigFile ); 609 QRsync::generateSignature( baseFile, sigFile );
606 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 610 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
607 QString baseFile, sigFile, deltaFile; 611 QString baseFile, sigFile, deltaFile;
608 stream >> baseFile >> sigFile >> deltaFile; 612 stream >> baseFile >> sigFile >> deltaFile;
609 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 613 QRsync::generateDiff( baseFile, sigFile, deltaFile );
610 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 614 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
611 QString baseFile, deltaFile; 615 QString baseFile, deltaFile;
612 stream >> baseFile >> deltaFile; 616 stream >> baseFile >> deltaFile;
613 if ( !QFile::exists( baseFile ) ) { 617 if ( !QFile::exists( baseFile ) ) {
614 QFile f( baseFile ); 618 QFile f( baseFile );
615 f.open( IO_WriteOnly ); 619 f.open( IO_WriteOnly );
616 f.close(); 620 f.close();
617 } 621 }
618 QRsync::applyDiff( baseFile, deltaFile ); 622 QRsync::applyDiff( baseFile, deltaFile );
619 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 623 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
620 e << baseFile; 624 e << baseFile;
621 } else if ( msg == "rdiffCleanup()" ) { 625 } else if ( msg == "rdiffCleanup()" ) {
622 mkdir( "/tmp/rdiff" ); 626 mkdir( "/tmp/rdiff" );
623 QDir dir; 627 QDir dir;
624 dir.setPath( "/tmp/rdiff" ); 628 dir.setPath( "/tmp/rdiff" );
625 QStringList entries = dir.entryList(); 629 QStringList entries = dir.entryList();
626 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 630 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
627 dir.remove( *it ); 631 dir.remove( *it );
628 } else if ( msg == "sendHandshakeInfo()" ) { 632 } else if ( msg == "sendHandshakeInfo()" ) {
629 QString home = getenv( "HOME" ); 633 QString home = getenv( "HOME" );
630 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 634 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
631 e << home; 635 e << home;
632 int locked = (int) Desktop::screenLocked(); 636 int locked = (int) Desktop::screenLocked();
633 e << locked; 637 e << locked;
638 // register an app for autostart
639 // if clear is send the list is cleared.
640 } else if ( msg == "autoStart(QString)" ) {
641 QString appName;
642 stream >> appName;
643 Config cfg( "autostart" );
644 cfg.setGroup( "AutoStart" );
645 if ( appName.compare("clear") == 0){
646 cfg.writeEntry("Apps", "");
647 }
648 } else if ( msg == "autoStart(QString,QString)" ) {
649 QString modifier, appName;
650 stream >> modifier >> appName;
651 Config cfg( "autostart" );
652 cfg.setGroup( "AutoStart" );
653 if ( modifier.compare("add") == 0 ){
654 // only add it appname is entered
655 if (!appName.isEmpty()) {
656 cfg.writeEntry("Apps", appName);
657 }
658 } else if (modifier.compare("remove") == 0 ) {
659 // need to change for multiple entries
660 // actually remove is right now simular to clear, but in future there
661 // should be multiple apps in autostart possible.
662 QString checkName;
663 checkName = cfg.readEntry("Apps", "");
664 if (checkName == appName) {
665 cfg.writeEntry("Apps", "");
666 }
667 }
634 } else if ( msg == "sendCardInfo()" ) { 668 } else if ( msg == "sendCardInfo()" ) {
635 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 669 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
636 const QList<FileSystem> &fs = storage->fileSystems(); 670 const QList<FileSystem> &fs = storage->fileSystems();
637 QListIterator<FileSystem> it ( fs ); 671 QListIterator<FileSystem> it ( fs );
638 QString s; 672 QString s;
639 QString homeDir = getenv("HOME"); 673 QString homeDir = getenv("HOME");
640 QString hardDiskHome; 674 QString hardDiskHome;
641 for ( ; it.current(); ++it ) { 675 for ( ; it.current(); ++it ) {
642 if ( (*it)->isRemovable() ) 676 if ( (*it)->isRemovable() )
643 s += (*it)->name() + "=" + (*it)->path() + "/Documents " 677 s += (*it)->name() + "=" + (*it)->path() + "/Documents "
644 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 678 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
645 + " " + (*it)->options() + ";"; 679 + " " + (*it)->options() + ";";
646 else if ( (*it)->disk() == "/dev/mtdblock1" || 680 else if ( (*it)->disk() == "/dev/mtdblock1" ||
647 (*it)->disk() == "/dev/mtdblock/1" ) 681 (*it)->disk() == "/dev/mtdblock/1" )
648 s += (*it)->name() + "=" + homeDir + "/Documents " 682 s += (*it)->name() + "=" + homeDir + "/Documents "
649 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 683 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
650 + " " + (*it)->options() + ";"; 684 + " " + (*it)->options() + ";";
651 else if ( (*it)->name().contains( "Hard Disk") && 685 else if ( (*it)->name().contains( "Hard Disk") &&
652 homeDir.contains( (*it)->path() ) && 686 homeDir.contains( (*it)->path() ) &&
653 (*it)->path().length() > hardDiskHome.length() ) 687 (*it)->path().length() > hardDiskHome.length() )
654 hardDiskHome = 688 hardDiskHome =
655 (*it)->name() + "=" + homeDir + "/Documents " 689 (*it)->name() + "=" + homeDir + "/Documents "
656 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 690 + QString::number( (*it)->availBlocks() * (*it)->blockSize() )
657 + " " + (*it)->options() + ";"; 691 + " " + (*it)->options() + ";";
658 } 692 }
659 if ( !hardDiskHome.isEmpty() ) 693 if ( !hardDiskHome.isEmpty() )
660 s += hardDiskHome; 694 s += hardDiskHome;
661 695
662 e << s; 696 e << s;
663 } else if ( msg == "sendSyncDate(QString)" ) { 697 } else if ( msg == "sendSyncDate(QString)" ) {
664 QString app; 698 QString app;
665 stream >> app; 699 stream >> app;
666 Config cfg( "qpe" ); 700 Config cfg( "qpe" );
667 cfg.setGroup("SyncDate"); 701 cfg.setGroup("SyncDate");
668 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 702 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
669 e << app << cfg.readEntry( app ); 703 e << app << cfg.readEntry( app );
670 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 704 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
671 //cfg.readEntry( app ).latin1() ); 705 //cfg.readEntry( app ).latin1() );
672 } else if ( msg == "setSyncDate(QString,QString)" ) { 706 } else if ( msg == "setSyncDate(QString,QString)" ) {
673 QString app, date; 707 QString app, date;
674 stream >> app >> date; 708 stream >> app >> date;
675 Config cfg( "qpe" ); 709 Config cfg( "qpe" );
676 cfg.setGroup("SyncDate"); 710 cfg.setGroup("SyncDate");
677 cfg.writeEntry( app, date ); 711 cfg.writeEntry( app, date );
678 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 712 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
679 } else if ( msg == "startSync(QString)" ) { 713 } else if ( msg == "startSync(QString)" ) {
680 QString what; 714 QString what;
681 stream >> what; 715 stream >> what;
682 delete syncDialog; syncDialog = 0; 716 delete syncDialog; syncDialog = 0;
683 syncDialog = new SyncDialog( this, "syncProgress", FALSE, 717 syncDialog = new SyncDialog( this, "syncProgress", FALSE,
684 WStyle_Tool | WStyle_Customize | 718 WStyle_Tool | WStyle_Customize |
685 Qt::WStyle_StaysOnTop ); 719 Qt::WStyle_StaysOnTop );
686 syncDialog->showMaximized(); 720 syncDialog->showMaximized();
687 syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); 721 syncDialog->whatLabel->setText( "<b>" + what + "</b>" );
688 connect( syncDialog->buttonCancel, SIGNAL( clicked() ), 722 connect( syncDialog->buttonCancel, SIGNAL( clicked() ),
689 SLOT( cancelSync() ) ); 723 SLOT( cancelSync() ) );
690 } 724 }
691 else if ( msg == "stopSync()") { 725 else if ( msg == "stopSync()") {
692 delete syncDialog; syncDialog = 0; 726 delete syncDialog; syncDialog = 0;
693 } else if ( msg == "getAllDocLinks()" ) { 727 } else if ( msg == "getAllDocLinks()" ) {
694 loadDocs(); 728 loadDocs();
695 729
696 QString contents; 730 QString contents;
697 731
698 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { 732 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) {
699 DocLnk *doc = it.current(); 733 DocLnk *doc = it.current();
700 QString lfn = doc->linkFile();
701 QFileInfo fi( doc->file() ); 734 QFileInfo fi( doc->file() );
702 if ( !fi.exists() ) 735 if ( !fi.exists() )
703 continue; 736 continue;
704 737
705 738 bool fake = !doc->linkFileKnown();
706 739 if ( !fake ) {
707 QFile f( lfn ); 740 QFile f( doc->linkFile() );
708 if ( f.open( IO_ReadOnly ) ) { 741 if ( f.open( IO_ReadOnly ) ) {
709 QTextStream ts( &f ); 742 QTextStream ts( &f );
710 ts.setEncoding( QTextStream::UnicodeUTF8 ); 743 ts.setEncoding( QTextStream::UnicodeUTF8 );
711 contents += ts.read(); 744 contents += ts.read();
712 f.close(); 745 f.close();
713 } else { 746 } else
747 fake = TRUE;
748 }
749 if (fake) {
714 contents += "[Desktop Entry]\n"; 750 contents += "[Desktop Entry]\n";
715 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; 751 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n";
716 contents += "File = "+doc->file()+"\n"; 752 contents += "File = "+doc->file()+"\n";
717 contents += "Name = "+doc->name()+"\n"; 753 contents += "Name = "+doc->name()+"\n";
718 contents += "Type = "+doc->type()+"\n"; 754 contents += "Type = "+doc->type()+"\n";
719 } 755 }
720 contents += QString("Size = %1\n").arg( fi.size() ); 756 contents += QString("Size = %1\n").arg( fi.size() );
721 } 757 }
722 758
723 //qDebug( "sending length %d", contents.length() ); 759 //qDebug( "sending length %d", contents.length() );
724 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 760 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
725 e << contents; 761 e << contents;
726 762
727 //qDebug( "================ \n\n%s\n\n===============", 763 //qDebug( "================ \n\n%s\n\n===============",
728 //contents.latin1() ); 764 //contents.latin1() );
729 765
730 delete docsFolder; 766 delete docsFolder;
731 docsFolder = 0; 767 docsFolder = 0;
732 } 768 }
733} 769}
734 770
735void Launcher::cancelSync() 771void Launcher::cancelSync()
736{ 772{
737 QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); 773 QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
738} 774}
739 775
740void Launcher::storageChanged() 776void Launcher::storageChanged()
741{ 777{
742 if ( in_lnk_props ) { 778 if ( in_lnk_props ) {
743 got_lnk_change = TRUE; 779 got_lnk_change = TRUE;
744 lnk_change = ""; 780 lnk_change = "";
745 } else { 781 } else {
746 updateDocs(); 782 updateDocs();
747 } 783 }
748} 784}
749 785
750 786
751bool Launcher::mkdir(const QString &localPath) 787bool Launcher::mkdir(const QString &localPath)
752{ 788{
753 QDir fullDir(localPath); 789 QDir fullDir(localPath);
754 if (fullDir.exists()) 790 if (fullDir.exists())
755 return true; 791 return true;
756 792
757 // at this point the directory doesn't exist 793 // at this point the directory doesn't exist
758 // go through the directory tree and start creating the direcotories 794 // go through the directory tree and start creating the direcotories
759 // that don't exist; if we can't create the directories, return false 795 // that don't exist; if we can't create the directories, return false
760 796
761 QString dirSeps = "/"; 797 QString dirSeps = "/";
762 int dirIndex = localPath.find(dirSeps); 798 int dirIndex = localPath.find(dirSeps);
763 QString checkedPath; 799 QString checkedPath;
764 800
765 // didn't find any seps; weird, use the cur dir instead 801 // didn't find any seps; weird, use the cur dir instead
766 if (dirIndex == -1) { 802 if (dirIndex == -1) {
767 //qDebug("No seperators found in path %s", localPath.latin1()); 803 //qDebug("No seperators found in path %s", localPath.latin1());
768 checkedPath = QDir::currentDirPath(); 804 checkedPath = QDir::currentDirPath();
769 } 805 }
770 806
771 while (checkedPath != localPath) { 807 while (checkedPath != localPath) {
772 // no more seperators found, use the local path 808 // no more seperators found, use the local path
773 if (dirIndex == -1) 809 if (dirIndex == -1)
774 checkedPath = localPath; 810 checkedPath = localPath;
775 else { 811 else {
776 // the next directory to check 812 // the next directory to check
777 checkedPath = localPath.left(dirIndex) + "/"; 813 checkedPath = localPath.left(dirIndex) + "/";
778 // advance the iterator; the next dir seperator 814 // advance the iterator; the next dir seperator
779 dirIndex = localPath.find(dirSeps, dirIndex+1); 815 dirIndex = localPath.find(dirSeps, dirIndex+1);
780 } 816 }
781 817
782 QDir checkDir(checkedPath); 818 QDir checkDir(checkedPath);
783 if (!checkDir.exists()) { 819 if (!checkDir.exists()) {
784 //qDebug("mkdir making dir %s", checkedPath.latin1()); 820 //qDebug("mkdir making dir %s", checkedPath.latin1());
785 821
786 if (!checkDir.mkdir(checkedPath)) { 822 if (!checkDir.mkdir(checkedPath)) {
787 qDebug("Unable to make directory %s", checkedPath.latin1()); 823 qDebug("Unable to make directory %s", checkedPath.latin1());
788 return FALSE; 824 return FALSE;
789 } 825 }
790 } 826 }
791 827
792 } 828 }
793 return TRUE; 829 return TRUE;
794} 830}
795 831
796void Launcher::preloadApps() 832void Launcher::preloadApps()
797{ 833{
798 Config cfg("Launcher"); 834 Config cfg("Launcher");
799 cfg.setGroup("Preload"); 835 cfg.setGroup("Preload");
800 QStringList apps = cfg.readListEntry("Apps",','); 836 QStringList apps = cfg.readListEntry("Apps",',');
801 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 837 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
802 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 838 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
803 } 839 }
804} 840}