summaryrefslogtreecommitdiff
path: root/core/launcher
Side-by-side diff
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
@@ -26,46 +26,47 @@
#include "shutdownimpl.h"
#include "startmenu.h"
#include "taskbar.h"
#include "transferserver.h"
#include "irserver.h"
#include "packageslave.h"
#include <qpe/applnk.h>
#include <qpe/mimetype.h>
#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
#include "qpe/custom.h"
#endif
#include <qgfx_qws.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qtimer.h>
#include <qwindowsystem_qws.h>
#include <qvaluelist.h>
#include <stdlib.h>
#include <unistd.h>
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; }
QString getChannel() const { return channel; }
QString getMessage() const { return message; }
private:
int keyCode;
QString channel, message;
};
typedef QValueList<QCopKeyRegister> KeyRegisterList;
@@ -159,32 +160,32 @@ DesktopApplication::~DesktopApplication()
void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
{
QDataStream stream( data, IO_ReadOnly );
if (msg == "keyRegister(int key, QString channel, QString message)")
{
int k;
QString c, m;
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;
#ifdef Q_WS_QWS
bool DesktopApplication::qwsEventFilter( QWSEvent *e )
{
qpedesktop->checkMemory();
if ( e->type == QWSEvent::Key ) {
QWSKeyEvent *ke = (QWSKeyEvent *)e;
if ( !loggedin && ke->simpleData.keycode != Key_F34 )
@@ -268,25 +269,25 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
QWSMouseEvent *me = (QWSMouseEvent *)e;
static bool up = TRUE;
if ( me->simpleData.state&LeftButton ) {
if ( up ) {
up = FALSE;
qpedesktop->screenClick();
}
} else {
up = TRUE;
}
}
}
-
+
return QPEApplication::qwsEventFilter( e );
}
#endif
void DesktopApplication::psTimeout()
{
qpedesktop->checkMemory(); // in case no events are being generated
*ps = PowerStatusManager::readStatus();
if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
pa->alert( tr( "Battery is running very low." ), 6 );
@@ -538,32 +539,39 @@ void Desktop::raiseEmail()
Config cfg("qpe"); //F13, 'Mail'
cfg.setGroup("AppsKey");
QString tempItem;
tempItem = cfg.readEntry("RightEnd","Mail");
if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop");
else {
QCopEnvelope e("QPE/System","execute(QString)");
e << tempItem;
}
}
// 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)
#include <qpe/config.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <linux/ioctl.h>
#include <time.h>
@@ -584,31 +592,32 @@ static void blankScreen()
static void darkScreen()
{
extern void qpe_setBacklight(int);
qpe_setBacklight(0); // force off
}
void Desktop::togglePower()
{
bool wasloggedin = loggedin;
loggedin=0;
+ suspendTime = QDateTime::currentDateTime();
darkScreen();
if ( wasloggedin )
blankScreen();
-
+
system("apm --suspend");
-
-
+
+
QWSServer::screenSaverActivate( FALSE );
{
QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
QCopEnvelope e("QPE/System", "setBacklight(int)");
e << -3; // Force on
}
if ( wasloggedin ) {
login(TRUE);
}
sleep(1);
execAutoStart();
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
@@ -18,24 +18,25 @@
**
**********************************************************************/
#ifndef __DESKTOP_H__
#define __DESKTOP_H__
#include "shutdownimpl.h"
#include <qpe/qpeapplication.h>
#include <qwidget.h>
+#include <qdatetime.h>
class Background;
class Launcher;
class TaskBar;
class PowerStatus;
class QCopBridge;
class TransferServer;
class DesktopPowerAlerter;
class PackageSlave;
class DesktopApplication : public QPEApplication
{
@@ -117,18 +118,19 @@ protected:
QWidget *bg;
Launcher *launcher;
TaskBar *tb;
private:
void startTransferServer();
bool recoverMemory();
QCopBridge *qcopBridge;
TransferServer *transferServer;
PackageSlave *packageSlave;
+ QDateTime suspendTime;
bool keyclick,touchclick;
};
#endif // __DESKTOP_H__
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
@@ -88,25 +88,25 @@ namespace {
}else{
tmpMime = cfg->readBoolEntry("audio", true );
if(tmpMime )
mimes.append("audio//*" );
tmpMime = cfg->readBoolEntry("image", true );
if(tmpMime )
mimes.append("image//*" );
tmpMime = cfg->readBoolEntry("text", true );
if(tmpMime )
mimes.append("text//*");
-
+
tmpMime = cfg->readBoolEntry("video", true );
if(tmpMime )
mimes.append("video//*" );
}
return mimes;
}
}
CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
QVBox( parent )
@@ -540,28 +540,28 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global::
qWarning("loading Documents" );
qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() );
delete docsFolder;
docsFolder = new DocLnkSet;
qWarning("new DocLnkSet" );
DocLnkSet *tmp = 0;
QString home = QString(getenv("HOME")) + "/Documents";
tmp = new DocLnkSet( home , QString::null);
docsFolder->appendFrom( *tmp );
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();
QListIterator<FileSystem> it ( fileSystems );
for ( ; it.current(); ++it ) {
if ( (*it)->isRemovable() ) { // let's find out if we should search on it
qWarning("%s is removeable", (*it)->path().latin1() );
OConfig cfg( (*it)->path() + "/.opiestorage.cf");
cfg.setGroup("main");
QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
if( stamp == m_timeStamp ){ // ok we know this card
cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
@@ -582,25 +582,25 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global::
}// no else
}else{ // we checked
// do something different see what we need to do
// let's see if we should check the device
cfg.setGroup("main" );
bool check = cfg.readBoolEntry("autocheck", true );
if( check ){ // find the documents
tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
docsFolder->appendFrom( *tmp );
delete tmp;
}
}
- }
+ }
}
}
m_timeStamp = newStamp;
}
void Launcher::updateTabs()
{
MimeType::updateApplications(); // ### reads all applnks twice
delete rootFolder;
rootFolder = new AppLnkSet( MimeType::appsFolderName() );
@@ -678,25 +678,25 @@ void Launcher::updateLink(const QString& link)
}
void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
{
QDataStream stream( data, IO_ReadOnly );
if ( msg == "closing(QString)" ){
QString app;
stream >> app;
qWarning("app closed %s", app.latin1() );
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;
} else {
updateLink(link);
}
} else if ( msg == "busy()" ) {
emit busy();
} else if ( msg == "notBusy(QString)" ) {
QString app;
stream >> app;
tabs->setBusy(FALSE);
@@ -732,52 +732,66 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
QStringList entries = dir.entryList();
for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
dir.remove( *it );
} else if ( msg == "sendHandshakeInfo()" ) {
QString home = getenv( "HOME" );
QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
e << home;
int locked = (int) Desktop::screenLocked();
e << locked;
// 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 );
QString s;
QString homeDir = getenv("HOME");
QString hardDiskHome;
for ( ; it.current(); ++it ) {
if ( (*it)->isRemovable() )
s += (*it)->name() + "=" + (*it)->path() + "/Documents "
+ QString::number( (*it)->availBlocks() * (*it)->blockSize() )
+ " " + (*it)->options() + ";";
else if ( (*it)->disk() == "/dev/mtdblock1" ||
@@ -814,25 +828,25 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
cfg.writeEntry( app, date );
//qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
} else if ( msg == "startSync(QString)" ) {
QString what;
stream >> what;
delete syncDialog; syncDialog = 0;
syncDialog = new SyncDialog( this, "syncProgress", FALSE,
WStyle_Tool | WStyle_Customize |
Qt::WStyle_StaysOnTop );
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;
} else if ( msg == "getAllDocLinks()" ) {
loadDocs();
QString contents;
for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) {
DocLnk *doc = it.current();
QFileInfo fi( doc->file() );
if ( !fi.exists() )
@@ -853,25 +867,25 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
contents += "[Desktop Entry]\n";
contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n";
contents += "File = "+doc->file()+"\n";
contents += "Name = "+doc->name()+"\n";
contents += "Type = "+doc->type()+"\n";
}
contents += QString("Size = %1\n").arg( fi.size() );
}
//qDebug( "sending length %d", contents.length() );
QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
e << contents;
-
+
qDebug( "================ \n\n%s\n\n===============",
contents.latin1() );
delete docsFolder;
docsFolder = 0;
}
}
void Launcher::cancelSync()
{
QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
}