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
@@ -43,25 +43,24 @@
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:
@@ -488,24 +487,35 @@ void Desktop::raiseContacts()
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
@@ -522,40 +532,44 @@ static void blankScreen()
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}
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
@@ -90,24 +90,25 @@ public:
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 );
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
@@ -9,24 +9,28 @@
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>
@@ -622,27 +626,57 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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 "
@@ -688,38 +722,40 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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;