summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-03-07 11:05:40 (UTC)
committer harlekin <harlekin>2002-03-07 11:05:40 (UTC)
commita2f42b6df21b2e5d52b49376542d0f4c7443a897 (patch) (side-by-side diff)
treebfbacf25dd213cdb2b7a86a007e4598a1634bb18
parent09444065297662fca1396abf8c0c9dd00380699f (diff)
downloadopie-a2f42b6df21b2e5d52b49376542d0f4c7443a897.zip
opie-a2f42b6df21b2e5d52b49376542d0f4c7443a897.tar.gz
opie-a2f42b6df21b2e5d52b49376542d0f4c7443a897.tar.bz2
beginning support for autostart
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp48
-rw-r--r--core/launcher/desktop.h1
-rw-r--r--core/launcher/launcher.cpp60
3 files changed, 80 insertions, 29 deletions
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
@@ -43,25 +43,24 @@
#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)
: keyCode(k), channel(c), message(m) { }
int getKeyCode() const { return keyCode; }
QString getChannel() const { return channel; }
QString getMessage() const { return message; }
private:
@@ -488,24 +487,35 @@ void Desktop::raiseContacts()
void Desktop::raiseMenu()
{
Global::terminateBuiltin("calibrate");
tb->startMenu()->launch();
}
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 <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>
#endif
@@ -522,40 +532,44 @@ static void blankScreen()
blanked = TRUE;
}
static void darkScreen()
{
extern void qpe_setBacklight(int);
qpe_setBacklight(0); // force off
}
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()
{
QCopEnvelope e("QPE/System", "setBacklight(int)");
e << -2; // toggle
}
void Desktop::toggleSymbolInput()
{
tb->toggleSymbolInput();
}
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
@@ -90,24 +90,25 @@ public:
void checkMemory();
void keyClick();
void screenClick();
static void soundAlarm();
public slots:
void raiseDatebook();
void raiseContacts();
void raiseMenu();
void raiseLauncher();
void raiseEmail();
+ void execAutoStart();
void togglePower();
void toggleLight();
void toggleNumLockState();
void toggleCapsLockState();
void toggleSymbolInput();
void terminateServers();
void rereadVolumes();
protected:
void executeOrModify(const QString& appLnkFile);
void styleChange( QStyle & );
void timerEvent( QTimerEvent *e );
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
@@ -9,24 +9,28 @@
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
+// have this class.
+#define QTOPIA_INTERNAL_FSLP
+
#include <qpe/qcopenvelope_qws.h>
#include <qpe/resource.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/qpeapplication.h>
#include <qpe/mimetype.h>
#include <qpe/storage.h>
#include <qpe/palmtoprecord.h>
#include <qdir.h>
#include <qwindowsystem_qws.h>
@@ -622,27 +626,57 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
mkdir( "/tmp/rdiff" );
QDir dir;
dir.setPath( "/tmp/rdiff" );
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", "");
+ }
+ } 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<FileSystem> &fs = storage->fileSystems();
+ 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" ||
(*it)->disk() == "/dev/mtdblock/1" )
s += (*it)->name() + "=" + homeDir + "/Documents "
@@ -688,38 +722,40 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
connect( syncDialog->buttonCancel, SIGNAL( clicked() ),
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();
- 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";
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;