-rw-r--r-- | core/launcher/desktop.cpp | 41 | ||||
-rw-r--r-- | core/launcher/desktop.h | 2 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 82 |
3 files changed, 75 insertions, 50 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index cf33011..43006f1 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -32,12 +32,13 @@ | |||
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/timeconversion.h> | ||
38 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
39 | #include <qpe/global.h> | 40 | #include <qpe/global.h> |
40 | #ifdef QT_QWS_CUSTOM | 41 | #ifdef QT_QWS_CUSTOM |
41 | #include "qpe/custom.h" | 42 | #include "qpe/custom.h" |
42 | #endif | 43 | #endif |
43 | 44 | ||
@@ -53,13 +54,13 @@ | |||
53 | #include <unistd.h> | 54 | #include <unistd.h> |
54 | 55 | ||
55 | class QCopKeyRegister | 56 | class QCopKeyRegister |
56 | { | 57 | { |
57 | public: | 58 | public: |
58 | QCopKeyRegister() : keyCode(0) { } | 59 | QCopKeyRegister() : keyCode(0) { } |
59 | QCopKeyRegister(int k, const QString &c, const QString &m) | 60 | QCopKeyRegister(int k, const QString &c, const QString &m) |
60 | : keyCode(k), channel(c), message(m) { } | 61 | : keyCode(k), channel(c), message(m) { } |
61 | 62 | ||
62 | int getKeyCode() const { return keyCode; } | 63 | int getKeyCode() const { return keyCode; } |
63 | QString getChannel() const { return channel; } | 64 | QString getChannel() const { return channel; } |
64 | QString getMessage() const { return message; } | 65 | QString getMessage() const { return message; } |
65 | 66 | ||
@@ -165,20 +166,20 @@ void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | |||
165 | int k; | 166 | int k; |
166 | QString c, m; | 167 | QString c, m; |
167 | 168 | ||
168 | stream >> k; | 169 | stream >> k; |
169 | stream >> c; | 170 | stream >> c; |
170 | stream >> m; | 171 | stream >> m; |
171 | 172 | ||
172 | qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); | 173 | qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); |
173 | keyRegisterList.append(QCopKeyRegister(k,c,m)); | 174 | keyRegisterList.append(QCopKeyRegister(k,c,m)); |
174 | } | 175 | } |
175 | else if (msg == "suspend()"){ | 176 | else if (msg == "suspend()"){ |
176 | emit power(); | 177 | emit power(); |
177 | } | 178 | } |
178 | 179 | ||
179 | } | 180 | } |
180 | 181 | ||
181 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; | 182 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; |
182 | 183 | ||
183 | #ifdef Q_WS_QWS | 184 | #ifdef Q_WS_QWS |
184 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 185 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
@@ -274,13 +275,13 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
274 | } | 275 | } |
275 | } else { | 276 | } else { |
276 | up = TRUE; | 277 | up = TRUE; |
277 | } | 278 | } |
278 | } | 279 | } |
279 | } | 280 | } |
280 | 281 | ||
281 | return QPEApplication::qwsEventFilter( e ); | 282 | return QPEApplication::qwsEventFilter( e ); |
282 | } | 283 | } |
283 | #endif | 284 | #endif |
284 | 285 | ||
285 | void DesktopApplication::psTimeout() | 286 | void DesktopApplication::psTimeout() |
286 | { | 287 | { |
@@ -544,20 +545,27 @@ void Desktop::raiseEmail() | |||
544 | QCopEnvelope e("QPE/System","execute(QString)"); | 545 | QCopEnvelope e("QPE/System","execute(QString)"); |
545 | e << tempItem; | 546 | e << tempItem; |
546 | } | 547 | } |
547 | } | 548 | } |
548 | 549 | ||
549 | // autoStarts apps on resume and start | 550 | // autoStarts apps on resume and start |
550 | void Desktop::execAutoStart() | 551 | void Desktop::execAutoStart() { |
551 | { | 552 | QString appName; |
552 | QString appName; | 553 | int delay; |
553 | Config cfg( "autostart" ); | 554 | QDateTime now = QDateTime::currentDateTime(); |
554 | cfg.setGroup( "AutoStart" ); | 555 | Config cfg( "autostart" ); |
555 | appName = cfg.readEntry("Apps", ""); | 556 | cfg.setGroup( "AutoStart" ); |
556 | QCopEnvelope e("QPE/System", "execute(QString)"); | 557 | appName = cfg.readEntry("Apps", ""); |
557 | e << QString(appName); | 558 | delay = (cfg.readEntry("Delay", "0" )).toInt(); |
559 | // If the time between suspend and resume was longer then the | ||
560 | // value saved as delay, start the app | ||
561 | if ( suspendTime.secsTo(now) >= (delay*60) ) { | ||
562 | QCopEnvelope e("QPE/System", "execute(QString)"); | ||
563 | e << QString(appName); | ||
564 | } else { | ||
565 | } | ||
558 | } | 566 | } |
559 | 567 | ||
560 | #if defined(QPE_HAVE_TOGGLELIGHT) | 568 | #if defined(QPE_HAVE_TOGGLELIGHT) |
561 | #include <qpe/config.h> | 569 | #include <qpe/config.h> |
562 | 570 | ||
563 | #include <sys/ioctl.h> | 571 | #include <sys/ioctl.h> |
@@ -590,19 +598,20 @@ static void darkScreen() | |||
590 | 598 | ||
591 | 599 | ||
592 | void Desktop::togglePower() | 600 | void Desktop::togglePower() |
593 | { | 601 | { |
594 | bool wasloggedin = loggedin; | 602 | bool wasloggedin = loggedin; |
595 | loggedin=0; | 603 | loggedin=0; |
604 | suspendTime = QDateTime::currentDateTime(); | ||
596 | darkScreen(); | 605 | darkScreen(); |
597 | if ( wasloggedin ) | 606 | if ( wasloggedin ) |
598 | blankScreen(); | 607 | blankScreen(); |
599 | 608 | ||
600 | system("apm --suspend"); | 609 | system("apm --suspend"); |
601 | 610 | ||
602 | 611 | ||
603 | 612 | ||
604 | QWSServer::screenSaverActivate( FALSE ); | 613 | QWSServer::screenSaverActivate( FALSE ); |
605 | { | 614 | { |
606 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 615 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
607 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 616 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
608 | e << -3; // Force on | 617 | e << -3; // Force on |
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index de0dbf0..e094dc0 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h | |||
@@ -24,12 +24,13 @@ | |||
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 | #include <qdatetime.h> | ||
30 | 31 | ||
31 | class Background; | 32 | class Background; |
32 | class Launcher; | 33 | class Launcher; |
33 | class TaskBar; | 34 | class TaskBar; |
34 | class PowerStatus; | 35 | class PowerStatus; |
35 | class QCopBridge; | 36 | class QCopBridge; |
@@ -123,12 +124,13 @@ private: | |||
123 | bool recoverMemory(); | 124 | bool recoverMemory(); |
124 | 125 | ||
125 | QCopBridge *qcopBridge; | 126 | QCopBridge *qcopBridge; |
126 | TransferServer *transferServer; | 127 | TransferServer *transferServer; |
127 | PackageSlave *packageSlave; | 128 | PackageSlave *packageSlave; |
128 | 129 | ||
130 | QDateTime suspendTime; | ||
129 | bool keyclick,touchclick; | 131 | bool keyclick,touchclick; |
130 | }; | 132 | }; |
131 | 133 | ||
132 | 134 | ||
133 | #endif // __DESKTOP_H__ | 135 | #endif // __DESKTOP_H__ |
134 | 136 | ||
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 1449269..979eee6 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -94,13 +94,13 @@ namespace { | |||
94 | if(tmpMime ) | 94 | if(tmpMime ) |
95 | mimes.append("image//*" ); | 95 | mimes.append("image//*" ); |
96 | 96 | ||
97 | tmpMime = cfg->readBoolEntry("text", true ); | 97 | tmpMime = cfg->readBoolEntry("text", true ); |
98 | if(tmpMime ) | 98 | if(tmpMime ) |
99 | mimes.append("text//*"); | 99 | mimes.append("text//*"); |
100 | 100 | ||
101 | tmpMime = cfg->readBoolEntry("video", true ); | 101 | tmpMime = cfg->readBoolEntry("video", true ); |
102 | if(tmpMime ) | 102 | if(tmpMime ) |
103 | mimes.append("video//*" ); | 103 | mimes.append("video//*" ); |
104 | } | 104 | } |
105 | return mimes; | 105 | return mimes; |
106 | } | 106 | } |
@@ -546,16 +546,16 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | |||
546 | QString home = QString(getenv("HOME")) + "/Documents"; | 546 | QString home = QString(getenv("HOME")) + "/Documents"; |
547 | tmp = new DocLnkSet( home , QString::null); | 547 | tmp = new DocLnkSet( home , QString::null); |
548 | docsFolder->appendFrom( *tmp ); | 548 | docsFolder->appendFrom( *tmp ); |
549 | delete tmp; | 549 | delete tmp; |
550 | // find out wich filesystems are new in this round | 550 | // find out wich filesystems are new in this round |
551 | // We will do this by having a timestamp inside each mountpoint | 551 | // We will do this by having a timestamp inside each mountpoint |
552 | // if the current timestamp doesn't match this is a new file system and | 552 | // if the current timestamp doesn't match this is a new file system and |
553 | // come up with our MediumMountGui :) let the hacking begin | 553 | // come up with our MediumMountGui :) let the hacking begin |
554 | int stamp = uidgen.generate(); | 554 | int stamp = uidgen.generate(); |
555 | 555 | ||
556 | QString newStamp = QString::number( stamp ); // generates newtime Stamp | 556 | QString newStamp = QString::number( stamp ); // generates newtime Stamp |
557 | StorageInfo storage; | 557 | StorageInfo storage; |
558 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 558 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
559 | QListIterator<FileSystem> it ( fileSystems ); | 559 | QListIterator<FileSystem> it ( fileSystems ); |
560 | for ( ; it.current(); ++it ) { | 560 | for ( ; it.current(); ++it ) { |
561 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 561 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
@@ -588,13 +588,13 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | |||
588 | if( check ){ // find the documents | 588 | if( check ){ // find the documents |
589 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); | 589 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); |
590 | docsFolder->appendFrom( *tmp ); | 590 | docsFolder->appendFrom( *tmp ); |
591 | delete tmp; | 591 | delete tmp; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | } | 594 | } |
595 | } | 595 | } |
596 | } | 596 | } |
597 | m_timeStamp = newStamp; | 597 | m_timeStamp = newStamp; |
598 | } | 598 | } |
599 | 599 | ||
600 | void Launcher::updateTabs() | 600 | void Launcher::updateTabs() |
@@ -684,13 +684,13 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | |||
684 | QString app; | 684 | QString app; |
685 | stream >> app; | 685 | stream >> app; |
686 | qWarning("app closed %s", app.latin1() ); | 686 | qWarning("app closed %s", app.latin1() ); |
687 | MRUList::removeTask( app ); | 687 | MRUList::removeTask( app ); |
688 | }else if ( msg == "linkChanged(QString)" ) { | 688 | }else if ( msg == "linkChanged(QString)" ) { |
689 | QString link; | 689 | QString link; |
690 | stream >> link; | 690 | stream >> link; |
691 | if ( in_lnk_props ) { | 691 | if ( in_lnk_props ) { |
692 | got_lnk_change = TRUE; | 692 | got_lnk_change = TRUE; |
693 | lnk_change = link; | 693 | lnk_change = link; |
694 | } else { | 694 | } else { |
695 | updateLink(link); | 695 | updateLink(link); |
696 | } | 696 | } |
@@ -738,40 +738,54 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | |||
738 | e << home; | 738 | e << home; |
739 | int locked = (int) Desktop::screenLocked(); | 739 | int locked = (int) Desktop::screenLocked(); |
740 | e << locked; | 740 | e << locked; |
741 | // register an app for autostart | 741 | // register an app for autostart |
742 | // if clear is send the list is cleared. | 742 | // if clear is send the list is cleared. |
743 | } else if ( msg == "autoStart(QString)" ) { | 743 | } else if ( msg == "autoStart(QString)" ) { |
744 | QString appName; | 744 | QString appName; |
745 | stream >> appName; | 745 | stream >> appName; |
746 | Config cfg( "autostart" ); | 746 | Config cfg( "autostart" ); |
747 | cfg.setGroup( "AutoStart" ); | 747 | cfg.setGroup( "AutoStart" ); |
748 | if ( appName.compare("clear") == 0){ | 748 | if ( appName.compare("clear") == 0){ |
749 | cfg.writeEntry("Apps", ""); | 749 | cfg.writeEntry("Apps", ""); |
750 | } | 750 | } |
751 | } else if ( msg == "autoStart(QString,QString)" ) { | 751 | } else if ( msg == "autoStart(QString,QString)" ) { |
752 | QString modifier, appName; | 752 | QString modifier, appName; |
753 | stream >> modifier >> appName; | 753 | stream >> modifier >> appName; |
754 | Config cfg( "autostart" ); | 754 | Config cfg( "autostart" ); |
755 | cfg.setGroup( "AutoStart" ); | 755 | cfg.setGroup( "AutoStart" ); |
756 | if ( modifier.compare("add") == 0 ){ | 756 | if ( modifier.compare("add") == 0 ){ |
757 | // only add it appname is entered | 757 | // only add if appname is entered |
758 | if (!appName.isEmpty()) { | 758 | if (!appName.isEmpty()) { |
759 | cfg.writeEntry("Apps", appName); | 759 | cfg.writeEntry("Apps", appName); |
760 | } | 760 | } |
761 | } else if (modifier.compare("remove") == 0 ) { | 761 | } else if (modifier.compare("remove") == 0 ) { |
762 | // need to change for multiple entries | 762 | // need to change for multiple entries |
763 | // actually remove is right now simular to clear, but in future there | 763 | // actually remove is right now simular to clear, but in future there |
764 | // should be multiple apps in autostart possible. | 764 | // should be multiple apps in autostart possible. |
765 | QString checkName; | 765 | QString checkName; |
766 | checkName = cfg.readEntry("Apps", ""); | 766 | checkName = cfg.readEntry("Apps", ""); |
767 | if (checkName == appName) { | 767 | if (checkName == appName) { |
768 | cfg.writeEntry("Apps", ""); | 768 | cfg.writeEntry("Apps", ""); |
769 | } | 769 | } |
770 | } | 770 | } |
771 | } else if ( msg == "sendCardInfo()" ) { | 771 | // case the autostart feature should be delayed |
772 | } else if ( msg == "autoStart(QString, QString, QString)") { | ||
773 | QString modifier, appName, delay; | ||
774 | stream >> modifier >> appName >> delay; | ||
775 | Config cfg( "autostart" ); | ||
776 | cfg.setGroup( "AutoStart" ); | ||
777 | if ( modifier.compare("add") == 0 ){ | ||
778 | // only add it appname is entered | ||
779 | if (!appName.isEmpty()) { | ||
780 | cfg.writeEntry("Apps", appName); | ||
781 | cfg.writeEntry("Delay", delay); | ||
782 | } | ||
783 | } else { | ||
784 | } | ||
785 | } else if ( msg == "sendCardInfo()" ) { | ||
772 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 786 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
773 | const QList<FileSystem> &fs = storage->fileSystems(); | 787 | const QList<FileSystem> &fs = storage->fileSystems(); |
774 | QListIterator<FileSystem> it ( fs ); | 788 | QListIterator<FileSystem> it ( fs ); |
775 | QString s; | 789 | QString s; |
776 | QString homeDir = getenv("HOME"); | 790 | QString homeDir = getenv("HOME"); |
777 | QString hardDiskHome; | 791 | QString hardDiskHome; |
@@ -820,13 +834,13 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | |||
820 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 834 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
821 | WStyle_Tool | WStyle_Customize | | 835 | WStyle_Tool | WStyle_Customize | |
822 | Qt::WStyle_StaysOnTop ); | 836 | Qt::WStyle_StaysOnTop ); |
823 | syncDialog->showMaximized(); | 837 | syncDialog->showMaximized(); |
824 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 838 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
825 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 839 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
826 | SLOT( cancelSync() ) ); | 840 | SLOT( cancelSync() ) ); |
827 | } | 841 | } |
828 | else if ( msg == "stopSync()") { | 842 | else if ( msg == "stopSync()") { |
829 | delete syncDialog; syncDialog = 0; | 843 | delete syncDialog; syncDialog = 0; |
830 | } else if ( msg == "getAllDocLinks()" ) { | 844 | } else if ( msg == "getAllDocLinks()" ) { |
831 | loadDocs(); | 845 | loadDocs(); |
832 | 846 | ||
@@ -859,13 +873,13 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | |||
859 | contents += QString("Size = %1\n").arg( fi.size() ); | 873 | contents += QString("Size = %1\n").arg( fi.size() ); |
860 | } | 874 | } |
861 | 875 | ||
862 | //qDebug( "sending length %d", contents.length() ); | 876 | //qDebug( "sending length %d", contents.length() ); |
863 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 877 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
864 | e << contents; | 878 | e << contents; |
865 | 879 | ||
866 | qDebug( "================ \n\n%s\n\n===============", | 880 | qDebug( "================ \n\n%s\n\n===============", |
867 | contents.latin1() ); | 881 | contents.latin1() ); |
868 | 882 | ||
869 | delete docsFolder; | 883 | delete docsFolder; |
870 | docsFolder = 0; | 884 | docsFolder = 0; |
871 | } | 885 | } |