summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-09-09 18:14:37 (UTC)
committer harlekin <harlekin>2002-09-09 18:14:37 (UTC)
commit3044db24e632adbcf5dbbf1874944d54cee7c8e3 (patch) (side-by-side diff)
tree9961a3531e7fd16709002f82faa7494dd3dafed3
parent2e56c4b88cfb1ebdbc0d952791af48c870f9f14b (diff)
downloadopie-3044db24e632adbcf5dbbf1874944d54cee7c8e3.zip
opie-3044db24e632adbcf5dbbf1874944d54cee7c8e3.tar.gz
opie-3044db24e632adbcf5dbbf1874944d54cee7c8e3.tar.bz2
add preloaded app control needed to runningappsbar
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/applnk.cpp29
-rw-r--r--library/applnk.h5
2 files changed, 31 insertions, 3 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp
index 778ccab..9498f84 100644
--- a/library/applnk.cpp
+++ b/library/applnk.cpp
@@ -309,100 +309,100 @@ QString AppLnk::file() const
if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { // a .desktop with the same name exists
int n=1;
qWarning("AppLnk::file() n=1 %s", that->mFile.latin1() );
QString nn;
while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext)
|| QFile::exists(nn+".desktop"))
n++;
that->mFile = nn;
qWarning("AppLnl::file() now mFile is %s", that->mFile.latin1() );
}
that->mLinkFile = that->mFile+".desktop";
that->mFile += ext;
}
prepareDirectories(that->mFile);
QFile f(that->mFile);
if ( !f.open(IO_WriteOnly) )
that->mFile = QString::null;
return that->mFile;
}
return mFile;
}
/*!
Returns the desktop file coresponding to this AppLnk.
\sa file(), exec()
*/
QString AppLnk::linkFile() const
{
if ( mLinkFile.isNull() ) {
AppLnk* that = (AppLnk*)this;
if ( type().contains('/') ) {
StorageInfo storage;
const FileSystem *fs = storage.fileSystemOf( that->mFile );
if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs" ) ) {
that->mLinkFile = fs->path();
} else
that->mLinkFile = getenv( "HOME" );
that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName);
if ( QFile::exists(that->mLinkFile+".desktop") ) { // ok the file exists lets check if we point to the same file
int n=1;
QString nn;
AppLnk lnk( that->mLinkFile+".desktop" );
if(that->file() != lnk.file() ){
qWarning("AppLnk::linkFile exists %s", that->mLinkFile.latin1() );
while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")){
n++;
AppLnk lnk(nn ); // just to be sure
- if(lnk.file() ==that->file() ){
+ if(lnk.file() ==that->file() ){
break;
- }
- }
+ }
+ }
that->mLinkFile = nn;
}
}
that->mLinkFile += ".desktop";
qWarning("AppLnk::linkFile is %s", that->mLinkFile.latin1() );
storeLink();
}
return that->mLinkFile;
}
return mLinkFile;
}
/*!
Copies \a copy.
*/
AppLnk::AppLnk( const AppLnk &copy )
{
mName = copy.mName;
mPixmap = copy.mPixmap;
mBigPixmap = copy.mBigPixmap;
mExec = copy.mExec;
mType = copy.mType;
mRotation = copy.mRotation;
mComment = copy.mComment;
mFile = copy.mFile;
mLinkFile = copy.mLinkFile;
mIconFile = copy.mIconFile;
mMimeTypes = copy.mMimeTypes;
mMimeTypeIcons = copy.mMimeTypeIcons;
mId = 0;
d = new AppLnkPrivate();
d->mCat = copy.d->mCat;
}
/*!
Destroys the AppLnk. Note that if the AppLnk is current a member of
an AppLnkSet, this will produce a run-time warning.
\sa AppLnkSet::add(), AppLnkSet::remove()
*/
AppLnk::~AppLnk()
{
if ( mId )
qWarning("Deleting AppLnk that is in an AppLnkSet");
if ( d )
delete d;
}
@@ -561,96 +561,119 @@ bool AppLnk::writeLink() const
return TRUE;
}
void AppLnk::storeLink() const
{
Config config( mLinkFile, Config::File );
config.setGroup("Desktop Entry");
config.writeEntry("Name",mName);
if ( !mIconFile.isNull() ) config.writeEntry("Icon",mIconFile);
config.writeEntry("Type",type());
if ( !mComment.isNull() ) config.writeEntry("Comment",mComment);
config.writeEntry("File",file());
// write out the id...
int i;
QStringList sl;
for ( i = 0; i < int(d->mCat.count()); i++ ) {
sl.append( QString::number( d->mCat[i] ) );
}
config.writeEntry( "Categories", sl, ';' );
QCopEnvelope e("QPE/System", "linkChanged(QString)");
e << mLinkFile;
}
/*!
Sets the property named \a key to \a value.
*/
void AppLnk::setProperty(const QString& key, const QString& value)
{
if ( ensureLinkExists() ) {
Config cfg(linkFile(), Config::File);
cfg.writeEntry(key,value);
}
}
/*!
Returns the property named \a key.
*/
QString AppLnk::property(const QString& key) const
{
QString lf = linkFile();
if ( !QFile::exists(lf) )
return QString::null;
Config cfg(lf, Config::File);
return cfg.readEntry(key);
}
+bool AppLnk::isPreloaded() const {
+ // Preload information is stored in the Launcher config in v1.5.
+ Config cfg("Launcher");
+ cfg.setGroup("Preload");
+ QStringList apps = cfg.readListEntry("Apps",',');
+ if (apps.contains(exec()))
+ return true;
+ return false;
+}
+
+void AppLnk::setPreloaded(bool yesNo) {
+ // Preload information is stored in the Launcher config in v1.5.
+ Config cfg("Launcher");
+ cfg.setGroup("Preload");
+ QStringList apps = cfg.readListEntry("Apps", ',');
+ if (apps.contains(exec()) && !yesNo)
+ apps.remove(exec());
+ else if (yesNo && !apps.contains(exec()))
+ apps.append(exec());
+ cfg.writeEntry("Apps", apps, ',');
+}
+
+
/*!
Deletes both the linkFile() and file() associated with this AppLnk.
*/
void AppLnk::removeFiles()
{
bool valid = isValid();
if ( !valid || !linkFileKnown() || QFile::remove(linkFile()) ) {
if ( QFile::remove(file()) ) {
QCopEnvelope e("QPE/System", "linkChanged(QString)");
if ( linkFileKnown() )
e << linkFile();
else
e << file();
} else if ( valid ) {
// restore link
writeLink();
}
}
}
/*!
Delete the linkFile(), leaving any file() untouched.
*/
void AppLnk::removeLinkFile()
{
if ( isValid() && linkFileKnown() && QFile::remove(linkFile()) ) {
QCopEnvelope e("QPE/System", "linkChanged(QString)");
e << linkFile();
}
}
class AppLnkSetPrivate {
public:
AppLnkSetPrivate()
{
typPix.setAutoDelete(TRUE);
typPixBig.setAutoDelete(TRUE);
typName.setAutoDelete(TRUE);
}
QDict<QPixmap> typPix;
QDict<QPixmap> typPixBig;
QDict<QString> typName;
};
/*!
\class AppLnkSet applnk.h
\brief The AppLnkSet class is a set of AppLnk objects.
diff --git a/library/applnk.h b/library/applnk.h
index 18e20b6..9b5523e 100644
--- a/library/applnk.h
+++ b/library/applnk.h
@@ -33,96 +33,101 @@ class AppLnk
{
public:
AppLnk();
AppLnk( const QString &file );
AppLnk( const AppLnk &copy ); // copy constructor
virtual ~AppLnk();
bool isValid() const { return !mLinkFile.isNull(); }
static void setSmallIconSize(int);
static void setBigIconSize(int);
static int smallIconSize();
static int bigIconSize();
QString name() const { return mName; }
const QPixmap& pixmap() const;
const QPixmap& bigPixmap() const;
virtual QString exec() const { return mExec; }
QString type() const;
QString rotation() const { return mRotation; }
QString comment() const { return mComment; }
QString file() const;
QString linkFile() const;
QStringList mimeTypes() const { return mMimeTypes; }
QStringList mimeTypeIcons() const { return mMimeTypeIcons; }
const QArray<int> &categories() const;
int id() const { return mId; }
bool linkFileKnown() const { return !mLinkFile.isNull(); }
void execute() const;
void execute(const QStringList& args) const;
void removeFiles();
void removeLinkFile();
void setName( const QString& docname );
void setExec( const QString& exec );
void setFile( const QString& filename );
void setLinkFile( const QString& filename );
void setComment( const QString& comment );
void setType( const QString& mimetype );
void setIcon( const QString& iconname );
void setCategories( const QArray<int> &v );
bool writeLink() const;
void setProperty(const QString& key, const QString& value);
QString property(const QString& key) const;
+//#ifdef QTOPIA_INTERNAL_PRELOADACCESS
+ bool isPreloaded() const;
+ void setPreloaded(bool yesNo);
+//#endif
+
protected:
QString mName;
QPixmap mPixmap;
QPixmap mBigPixmap;
QString mExec;
QString mType;
QString mRotation;
QString mComment;
QString mFile;
QString mLinkFile;
QString mIconFile;
QStringList mMimeTypes;
QStringList mMimeTypeIcons;
int mId;
static int lastId;
AppLnkPrivate *d;
friend class AppLnkSet;
virtual void invoke(const QStringList& args) const;
bool ensureLinkExists() const;
void storeLink() const;
};
class DocLnk : public AppLnk
{
public:
DocLnk();
DocLnk( const DocLnk &o ) : AppLnk(o) { }
DocLnk( const QString &file );
DocLnk( const QString &file, bool may_be_desktopfile );
virtual ~DocLnk();
QString exec() const;
protected:
void invoke(const QStringList& args) const;
private:
void init(const QString &file);
};
class AppLnkSet
{
public:
AppLnkSet();
AppLnkSet( const QString &dir );
~AppLnkSet();