author | llornkcor <llornkcor> | 2006-07-09 18:56:40 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2006-07-09 18:56:40 (UTC) |
commit | 36dece4760b1ac1799929221b49eb3bee98c2367 (patch) (side-by-side diff) | |
tree | a45f66d2d90bd9fbbff8e8903cd1cb9323c39f6e /library/global.cpp | |
parent | 604065c6e662cb3894acf03abadafacc3ab52913 (diff) | |
download | opie-36dece4760b1ac1799929221b49eb3bee98c2367.zip opie-36dece4760b1ac1799929221b49eb3bee98c2367.tar.gz opie-36dece4760b1ac1799929221b49eb3bee98c2367.tar.bz2 |
initial commit to add video4linux camera app from qtopia 2, needs more work
-rw-r--r-- | library/global.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/library/global.cpp b/library/global.cpp index ec87555..f7a0767 100644 --- a/library/global.cpp +++ b/library/global.cpp @@ -715,98 +715,147 @@ QString Global::stringQuote(const QString& s) r += "\""; return r; } /*! Finds all documents on the system's document directories which match the filter \a mimefilter, and appends the resulting DocLnk objects to \a folder. */ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) { QString homedocs = QString(getenv("HOME")) + "/Documents"; DocLnkSet d(homedocs,mimefilter); folder->appendFrom(d); /** let's do intellegint way of searching these files * a) the user don't want to check mediums global * b) the user wants to check but use the global options for it * c) the user wants to check it but not this medium * d) the user wants to check and this medium as well * * In all cases we need to apply a different mimefilter to * the medium. * a) mimefilter.isEmpty() we need to apply the responding filter * either the global or the one on the medium * * b) mimefilter is set to an application we need to find out if the * mimetypes are included in the mime mask of the medium */ StorageInfo storage; const QList<FileSystem> &fs = storage.fileSystems(); QListIterator<FileSystem> it ( fs ); for ( ; it.current(); ++it ) { if ( (*it)->isRemovable() ) { // let's find out if we should search on it // this is a candidate look at the cf and see if we should search on it QString path = (*it)->path(); Config conf((*it)->path() + "/.opiestorage.cf", Config::File ); conf.setGroup("main"); if (!conf.readBoolEntry("check",true)) { continue; } conf.setGroup("subdirs"); if (conf.readBoolEntry("wholemedia",true)) { DocLnkSet ide( path,mimefilter); folder->appendFrom(ide); } else { QStringList subDirs = conf.readListEntry("subdirs",':'); if (subDirs.isEmpty()) { subDirs.append("Documents"); } for (unsigned c = 0; c < subDirs.count();++c) { DocLnkSet ide( path+"/"+subDirs[c], mimefilter ); folder->appendFrom(ide); } } } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { QString path = (*it)->path() + "/Documents"; DocLnkSet ide( path, mimefilter ); folder->appendFrom(ide); } } } QStringList Global::languageList() { QString lang = getenv("LANG"); QStringList langs; langs.append(lang); int i = lang.find("."); if ( i > 0 ) lang = lang.left( i ); i = lang.find( "_" ); if ( i > 0 ) langs.append(lang.left(i)); return langs; } QStringList Global::helpPath() { QString qpeDir = QPEApplication::qpeDir(); QStringList path; QStringList langs = Global::languageList(); for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { QString lang = *it; if ( !lang.isEmpty() ) path += qpeDir + "/help/" + lang + "/html"; } path += qpeDir + "/pics"; path += qpeDir + "/help/html"; /* we even put english into the en dir so try it as fallback as well for opie */ path += qpeDir + "/help/en/html"; path += qpeDir + "/docs"; return path; } +/*! + \internal + Truncate file to size specified + \a f must be an open file + \a size must be a positive value + */ +bool Global::truncateFile(QFile &f, int size){ + if (!f.isOpen()) + return FALSE; + + return ::ftruncate(f.handle(), size) != -1; +} + + + + +// #if defined(Q_OS_UNIX) && defined(Q_WS_QWS) +// extern int qws_display_id; +// #endif + +/*! + /internal + Returns the default system path for storing temporary files. + Note: This does not it ensure that the provided directory exists +*/ +QString Global::tempDir() +{ + QString result; +#ifdef Q_OS_UNIX +#ifdef Q_WS_QWS + result = QString("/tmp/qtopia-%1/").arg(QString::number(qws_display_id)); +#else + result="/tmp/"; +#endif +#else + if (getenv("TEMP")) + result = getenv("TEMP"); + else + result = getenv("TMP"); + + if (result[(int)result.length() - 1] != QDir::separator()) + result.append(QDir::separator()); +#endif + + return result; +} + +//#endif + #include "global.moc" |