From a2f42b6df21b2e5d52b49376542d0f4c7443a897 Mon Sep 17 00:00:00 2001 From: harlekin Date: Thu, 07 Mar 2002 11:05:40 +0000 Subject: beginning support for autostart --- (limited to 'core') 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 @@ -52,7 +52,6 @@ #include #include - class QCopKeyRegister { public: @@ -497,6 +496,17 @@ void Desktop::raiseEmail() executeOrModify("Applications/qtmail.desktop"); } +// 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); +} + #if defined(QPE_HAVE_TOGGLELIGHT) #include @@ -531,22 +541,26 @@ static void darkScreen() void Desktop::togglePower() { - bool wasloggedin = loggedin; - loggedin=0; - 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); - //qcopBridge->closeOpenConnections(); - //qDebug("called togglePower()!!!!!!"); + bool wasloggedin = loggedin; + loggedin=0; + darkScreen(); + if ( wasloggedin ) + blankScreen(); + + system("apm --suspend"); + execAutoStart(); + 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); + } + + //qcopBridge->closeOpenConnections(); + //qDebug("called togglePower()!!!!!!"); } void Desktop::toggleLight() 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 @@ -99,6 +99,7 @@ public slots: void raiseMenu(); void raiseLauncher(); void raiseEmail(); + void execAutoStart(); void togglePower(); void toggleLight(); void toggleNumLockState(); 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 @@ -18,6 +18,10 @@ ** **********************************************************************/ +// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT +// have this class. +#define QTOPIA_INTERNAL_FSLP + #include #include #include @@ -631,9 +635,39 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 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", ""); + } + } 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()" ) { - QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); - const QList &fs = storage->fileSystems(); + QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); + const QList &fs = storage->fileSystems(); QListIterator it ( fs ); QString s; QString homeDir = getenv("HOME"); @@ -697,20 +731,22 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) for ( QListIterator it( docsFolder->children() ); it.current(); ++it ) { DocLnk *doc = it.current(); - QString lfn = doc->linkFile(); QFileInfo fi( doc->file() ); if ( !fi.exists() ) continue; - - - QFile f( lfn ); - if ( f.open( IO_ReadOnly ) ) { - QTextStream ts( &f ); - ts.setEncoding( QTextStream::UnicodeUTF8 ); - contents += ts.read(); - f.close(); - } else { + bool fake = !doc->linkFileKnown(); + if ( !fake ) { + QFile f( doc->linkFile() ); + if ( f.open( IO_ReadOnly ) ) { + QTextStream ts( &f ); + ts.setEncoding( QTextStream::UnicodeUTF8 ); + contents += ts.read(); + f.close(); + } else + fake = TRUE; + } + if (fake) { contents += "[Desktop Entry]\n"; contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; contents += "File = "+doc->file()+"\n"; -- cgit v0.9.0.2