summaryrefslogtreecommitdiff
path: root/core/launcher
authorharlekin <harlekin>2002-04-15 20:30:41 (UTC)
committer harlekin <harlekin>2002-04-15 20:30:41 (UTC)
commit15244683bb97d303d0d3b6104b46a9b429aaed85 (patch) (side-by-side diff)
treece57768177baec8b90146245a8cfad669addf647 /core/launcher
parent551eb586e6a19db69348b0bb38f06171201d89a0 (diff)
downloadopie-15244683bb97d303d0d3b6104b46a9b429aaed85.zip
opie-15244683bb97d303d0d3b6104b46a9b429aaed85.tar.gz
opie-15244683bb97d303d0d3b6104b46a9b429aaed85.tar.bz2
added a configurable delay, so for example if 5 min are set, and the suspend time is shorter, no app is autostarted
Diffstat (limited to 'core/launcher') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp41
-rw-r--r--core/launcher/desktop.h2
-rw-r--r--core/launcher/launcher.cpp82
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
@@ -35,6 +35,7 @@
#include <qpe/password.h>
#include <qpe/config.h>
#include <qpe/power.h>
+#include <qpe/timeconversion.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/global.h>
#ifdef QT_QWS_CUSTOM
@@ -56,7 +57,7 @@ class QCopKeyRegister
{
public:
QCopKeyRegister() : keyCode(0) { }
- QCopKeyRegister(int k, const QString &c, const QString &m)
+ QCopKeyRegister(int k, const QString &c, const QString &m)
: keyCode(k), channel(c), message(m) { }
int getKeyCode() const { return keyCode; }
@@ -168,14 +169,14 @@ void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
stream >> k;
stream >> c;
stream >> m;
-
+
qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m);
keyRegisterList.append(QCopKeyRegister(k,c,m));
- }
+ }
else if (msg == "suspend()"){
emit power();
}
-
+
}
enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
@@ -277,7 +278,7 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
}
}
}
-
+
return QPEApplication::qwsEventFilter( e );
}
#endif
@@ -547,14 +548,21 @@ void Desktop::raiseEmail()
}
// autoStarts apps on resume and start
-void Desktop::execAutoStart()
-{
- QString appName;
- Config cfg( "autostart" );
- cfg.setGroup( "AutoStart" );
- appName = cfg.readEntry("Apps", "");
- QCopEnvelope e("QPE/System", "execute(QString)");
- e << QString(appName);
+void Desktop::execAutoStart() {
+ QString appName;
+ int delay;
+ QDateTime now = QDateTime::currentDateTime();
+ Config cfg( "autostart" );
+ cfg.setGroup( "AutoStart" );
+ appName = cfg.readEntry("Apps", "");
+ delay = (cfg.readEntry("Delay", "0" )).toInt();
+ // If the time between suspend and resume was longer then the
+ // value saved as delay, start the app
+ if ( suspendTime.secsTo(now) >= (delay*60) ) {
+ QCopEnvelope e("QPE/System", "execute(QString)");
+ e << QString(appName);
+ } else {
+ }
}
#if defined(QPE_HAVE_TOGGLELIGHT)
@@ -593,13 +601,14 @@ void Desktop::togglePower()
{
bool wasloggedin = loggedin;
loggedin=0;
+ suspendTime = QDateTime::currentDateTime();
darkScreen();
if ( wasloggedin )
blankScreen();
-
+
system("apm --suspend");
-
-
+
+
QWSServer::screenSaverActivate( FALSE );
{
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
@@ -27,6 +27,7 @@
#include <qpe/qpeapplication.h>
#include <qwidget.h>
+#include <qdatetime.h>
class Background;
class Launcher;
@@ -126,6 +127,7 @@ private:
TransferServer *transferServer;
PackageSlave *packageSlave;
+ QDateTime suspendTime;
bool keyclick,touchclick;
};
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
@@ -97,7 +97,7 @@ namespace {
tmpMime = cfg->readBoolEntry("text", true );
if(tmpMime )
mimes.append("text//*");
-
+
tmpMime = cfg->readBoolEntry("video", true );
if(tmpMime )
mimes.append("video//*" );
@@ -549,10 +549,10 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global::
delete tmp;
// find out wich filesystems are new in this round
// We will do this by having a timestamp inside each mountpoint
- // if the current timestamp doesn't match this is a new file system and
+ // if the current timestamp doesn't match this is a new file system and
// come up with our MediumMountGui :) let the hacking begin
int stamp = uidgen.generate();
-
+
QString newStamp = QString::number( stamp ); // generates newtime Stamp
StorageInfo storage;
const QList<FileSystem> &fileSystems = storage.fileSystems();
@@ -591,7 +591,7 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global::
delete tmp;
}
}
- }
+ }
}
}
m_timeStamp = newStamp;
@@ -687,7 +687,7 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
MRUList::removeTask( app );
}else if ( msg == "linkChanged(QString)" ) {
QString link;
- stream >> link;
+ stream >> link;
if ( in_lnk_props ) {
got_lnk_change = TRUE;
lnk_change = link;
@@ -741,34 +741,48 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
// register an app for autostart
// if clear is send the list is cleared.
} else if ( msg == "autoStart(QString)" ) {
- QString appName;
- stream >> appName;
- Config cfg( "autostart" );
- cfg.setGroup( "AutoStart" );
- if ( appName.compare("clear") == 0){
- cfg.writeEntry("Apps", "");
- }
+ QString appName;
+ stream >> appName;
+ Config cfg( "autostart" );
+ cfg.setGroup( "AutoStart" );
+ if ( appName.compare("clear") == 0){
+ cfg.writeEntry("Apps", "");
+ }
} else if ( msg == "autoStart(QString,QString)" ) {
- QString modifier, appName;
- stream >> modifier >> appName;
- Config cfg( "autostart" );
- cfg.setGroup( "AutoStart" );
- if ( modifier.compare("add") == 0 ){
- // only add it appname is entered
- if (!appName.isEmpty()) {
- cfg.writeEntry("Apps", appName);
- }
- } else if (modifier.compare("remove") == 0 ) {
- // need to change for multiple entries
- // actually remove is right now simular to clear, but in future there
- // should be multiple apps in autostart possible.
- QString checkName;
- checkName = cfg.readEntry("Apps", "");
- if (checkName == appName) {
- cfg.writeEntry("Apps", "");
- }
- }
- } else if ( msg == "sendCardInfo()" ) {
+ QString modifier, appName;
+ stream >> modifier >> appName;
+ Config cfg( "autostart" );
+ cfg.setGroup( "AutoStart" );
+ if ( modifier.compare("add") == 0 ){
+ // only add if appname is entered
+ if (!appName.isEmpty()) {
+ cfg.writeEntry("Apps", appName);
+ }
+ } else if (modifier.compare("remove") == 0 ) {
+ // need to change for multiple entries
+ // actually remove is right now simular to clear, but in future there
+ // should be multiple apps in autostart possible.
+ QString checkName;
+ checkName = cfg.readEntry("Apps", "");
+ if (checkName == appName) {
+ cfg.writeEntry("Apps", "");
+ }
+ }
+ // case the autostart feature should be delayed
+ } else if ( msg == "autoStart(QString, QString, QString)") {
+ QString modifier, appName, delay;
+ stream >> modifier >> appName >> delay;
+ Config cfg( "autostart" );
+ cfg.setGroup( "AutoStart" );
+ if ( modifier.compare("add") == 0 ){
+ // only add it appname is entered
+ if (!appName.isEmpty()) {
+ cfg.writeEntry("Apps", appName);
+ cfg.writeEntry("Delay", delay);
+ }
+ } else {
+ }
+ } else if ( msg == "sendCardInfo()" ) {
QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
const QList<FileSystem> &fs = storage->fileSystems();
QListIterator<FileSystem> it ( fs );
@@ -823,7 +837,7 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
syncDialog->showMaximized();
syncDialog->whatLabel->setText( "<b>" + what + "</b>" );
connect( syncDialog->buttonCancel, SIGNAL( clicked() ),
- SLOT( cancelSync() ) );
+ SLOT( cancelSync() ) );
}
else if ( msg == "stopSync()") {
delete syncDialog; syncDialog = 0;
@@ -862,7 +876,7 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
//qDebug( "sending length %d", contents.length() );
QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
e << contents;
-
+
qDebug( "================ \n\n%s\n\n===============",
contents.latin1() );