-rw-r--r-- | core/launcher/desktop.cpp | 41 |
1 files changed, 25 insertions, 16 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 |