author | zecke <zecke> | 2002-03-24 19:31:32 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-24 19:31:32 (UTC) |
commit | eb813af4c1e301c8ba015627a1da04f8199a3be2 (patch) (side-by-side diff) | |
tree | 7f23f61c2d8c58655fc98798b7f1b4aec75b5ff3 | |
parent | 4802684dd785274be50b472c87e315da0e325449 (diff) | |
download | opie-eb813af4c1e301c8ba015627a1da04f8199a3be2.zip opie-eb813af4c1e301c8ba015627a1da04f8199a3be2.tar.gz opie-eb813af4c1e301c8ba015627a1da04f8199a3be2.tar.bz2 |
Here is the second chunk of bits to make things a bit more fast
-rw-r--r-- | library/global.cpp | 27 | ||||
-rw-r--r-- | library/global.h | 8 | ||||
-rw-r--r-- | library/storage.cpp | 5 |
3 files changed, 38 insertions, 2 deletions
diff --git a/library/global.cpp b/library/global.cpp index dd15eb7..5a28595 100644 --- a/library/global.cpp +++ b/library/global.cpp @@ -27,48 +27,70 @@ #include <qpe/applnk.h> #if defined(Q_WS_QWS) && !defined(QT_NO_COP) #include "qpe/qcopenvelope_qws.h" #endif #include <qfile.h> #include <qlabel.h> #include <qtimer.h> #include <qmap.h> #include <qdict.h> #include <qdir.h> #include <qmessagebox.h> #include <qregexp.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/wait.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <qwindowsystem_qws.h> // for qwsServer #include <qdatetime.h> +#include <qfile.h> + +namespace { + // checks if the storage should be searched + bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke + QFile file(path ); + if(!file.open(IO_ReadOnly ) ) + return true; + + QByteArray array = file.readAll(); + QStringList list = QStringList::split('\n', QString( array ) ); + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ + if( (*it).startsWith("autocheck = 0" ) ){ + return true; + }else if( (*it).startsWith("autocheck = 1" ) ){ + return false; + } + } + return true; + } +} + //#include "quickexec_p.h" class Emitter : public QObject { Q_OBJECT public: Emitter( QWidget* receiver, const QString& document ) { connect(this, SIGNAL(setDocument(const QString&)), receiver, SLOT(setDocument(const QString&))); emit setDocument(document); disconnect(this, SIGNAL(setDocument(const QString&)), receiver, SLOT(setDocument(const QString&))); } signals: void setDocument(const QString&); }; class StartingAppList : public QObject { Q_OBJECT public: static void add( const QString& name ); static bool isStarting( const QString name ); @@ -617,50 +639,53 @@ QString Global::stringQuote(const QString& s) switch (c) { case '\\': case '"': r+="\\"; } r += s[i]; } 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); StorageInfo storage; const QList<FileSystem> &fs = storage.fileSystems(); QListIterator<FileSystem> it ( fs ); for ( ; it.current(); ++it ) { - if ( (*it)->isRemovable() ) { + 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(); + if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) + continue; 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() { QStringList path; QStringList langs = Global::languageList(); diff --git a/library/global.h b/library/global.h index d9ff8f8..fdf8754 100644 --- a/library/global.h +++ b/library/global.h @@ -1,85 +1,93 @@ /********************************************************************** +** Copyright (C) 2002 Holger 'zecke' Freyther <freyther@kde.org> ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** 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. ** **********************************************************************/ #ifndef GLOBAL_H #define GLOBAL_H #include <qstringlist.h> #include <qguardedptr.h> class QDawg; class QLabel; class QWidget; class AppLnk; class DocLnkSet; class Global { public: Global(); // Dictionaries static const QDawg& fixedDawg(); static const QDawg& addedDawg(); static const QDawg& dawg(const QString& name); static void addWords(const QStringList& word); static void addWords(const QString& dictname, const QStringList& word); // static void removeWords(const QStringList& word); -- if someone wants it static void createDocDir(); static void findDocuments(DocLnkSet* folder, const QString &mimefilter=QString::null); + // we don't need a mimefilter. Same as above but this is fast as light speed or not ;) + //static void findNewDocuments( DocLnkSet* folder ); static QString applicationFileName(const QString& appname, const QString& filename); struct Command { const char *file; QWidget *(*func)( bool ); bool maximized; bool documentary; }; static void setBuiltinCommands( Command* ); static void invoke( const QString &exec); static void execute( const QString &exec, const QString &document=QString::null ); static void setDocument( QWidget* receiver, const QString& document ); static bool terminateBuiltin( const QString& ); static void terminate( const AppLnk* ); static bool isBuiltinCommand( const QString &name ); // system messaging static void applyStyle(); static void statusMessage(const QString&); static QWidget *shutdown( bool = FALSE ); static QWidget *restart( bool = FALSE ); static void hideInputMethod(); static void showInputMethod(); static void writeHWClock(); static QString shellQuote(const QString& s); static QString stringQuote(const QString& s); +#ifdef QTOPIA_INTERNAL_LANGLIST + static QStringList languageList(); + static QStringList helpPath(); +#endif + private: static Command* builtin; static QGuardedPtr<QWidget> *running; }; #endif diff --git a/library/storage.cpp b/library/storage.cpp index bd34a5f..a4c96be 100644 --- a/library/storage.cpp +++ b/library/storage.cpp @@ -1,49 +1,51 @@ /********************************************************************** +** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** 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. ** **********************************************************************/ #include <qpe/storage.h> #ifdef QT_QWS_CUSTOM #include <qpe/custom.h> #endif +#include <qfile.h> #include <qtimer.h> #include <qcopchannel_qws.h> #include <stdio.h> #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <sys/vfs.h> #include <mntent.h> #endif #include <qstringlist.h> static bool isCF(const QString& m) { FILE* f = fopen("/var/run/stab", "r"); if (!f) f = fopen("/var/state/pcmcia/stab", "r"); if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); if ( f ) { char line[1024]; char devtype[80]; char devname[80]; while ( fgets( line, 1024, f ) ) { // 0 ide ide-cs 0 hda 3 0 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) @@ -63,49 +65,50 @@ StorageInfo::StorageInfo( QObject *parent ) : QObject( parent ) { mFileSystems.setAutoDelete( TRUE ); channel = new QCopChannel( "QPE/Card", this ); connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); update(); } const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) { for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { if ( filename.startsWith( (*i)->path() ) ) return (*i); } return 0; } void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) { if ( msg == "mtabChanged()" ) update(); } - +// cause of the lack of a d pointer we need +// to store informations in a config file :( void StorageInfo::update() { //qDebug("StorageInfo::updating"); #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) struct mntent *me; FILE *mntfp = setmntent( "/etc/mtab", "r" ); QStringList curdisks; QStringList curopts; QStringList curfs; bool rebuild = FALSE; int n=0; if ( mntfp ) { while ( (me = getmntent( mntfp )) != 0 ) { QString fs = me->mnt_fsname; if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" ) { n++; curdisks.append(fs); curopts.append( me->mnt_opts ); //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); curfs.append( me->mnt_dir ); bool found = FALSE; |