author | alwin <alwin> | 2004-02-24 13:25:40 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-02-24 13:25:40 (UTC) |
commit | 6b6ba7aa1bf21647a804c7e5e7e1654112c3ee38 (patch) (side-by-side diff) | |
tree | 6d202c80e470686ec72680e3371d15e0fb987c3b | |
parent | 911473db35a9fce5f3589f03c27210456faaba86 (diff) | |
download | opie-6b6ba7aa1bf21647a804c7e5e7e1654112c3ee38.zip opie-6b6ba7aa1bf21647a804c7e5e7e1654112c3ee38.tar.gz opie-6b6ba7aa1bf21647a804c7e5e7e1654112c3ee38.tar.bz2 |
use Config for checking if the medium should be checked
-rw-r--r-- | library/global.cpp | 246 |
1 files changed, 114 insertions, 132 deletions
diff --git a/library/global.cpp b/library/global.cpp index 4aca08b..a627348 100644 --- a/library/global.cpp +++ b/library/global.cpp @@ -52,22 +52,2 @@ -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("check = 0" ) ){ - return false; - }else if( (*it).startsWith("check = 1" ) ){ - return true; - } - } - return true; - } -} - //#include "quickexec_p.h" @@ -79,7 +59,7 @@ public: { - 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&))); + 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&))); } @@ -112,3 +92,3 @@ StartingAppList::StartingAppList( QObject *parent, const char* name ) connect( qwsServer, SIGNAL( newChannel(const QString&)), - this, SLOT( handleNewChannel(const QString&)) ); + this, SLOT( handleNewChannel(const QString&)) ); #endif @@ -121,3 +101,3 @@ void StartingAppList::add( const QString& name ) if ( !appl ) - appl = new StartingAppList; + appl = new StartingAppList; QTime *t = new QTime; @@ -132,11 +112,11 @@ bool StartingAppList::isStarting( const QString name ) if ( appl ) { - QTime *t = appl->dict.find( "QPE/Application/" + name ); - if ( !t ) - return FALSE; - if ( t->elapsed() > 10000 ) { - // timeout in case of crash or something - appl->dict.remove( "QPE/Application/" + name ); - return FALSE; - } - return TRUE; + QTime *t = appl->dict.find( "QPE/Application/" + name ); + if ( !t ) + return FALSE; + if ( t->elapsed() > 10000 ) { + // timeout in case of crash or something + appl->dict.remove( "QPE/Application/" + name ); + return FALSE; + } + return TRUE; } @@ -240,35 +220,35 @@ const QDawg& Global::fixedDawg() if ( !fixed_dawg ) { - if ( !docDirCreated ) - createDocDir(); - - fixed_dawg = new QDawg; - QString dawgfilename = dictDir() + "/dawg"; - QString words_lang; - QStringList langs = Global::languageList(); - for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { - QString lang = *it; - words_lang = dictDir() + "/words." + lang; - QString dawgfilename_lang = dawgfilename + "." + lang; - if ( QFile::exists(dawgfilename_lang) || - QFile::exists(words_lang) ) { - dawgfilename = dawgfilename_lang; - break; - } - } - QFile dawgfile(dawgfilename); - - if ( !dawgfile.exists() ) { - QString fn = dictDir() + "/words"; - if ( QFile::exists(words_lang) ) - fn = words_lang; - QFile in(fn); - if ( in.open(IO_ReadOnly) ) { - fixed_dawg->createFromWords(&in); - dawgfile.open(IO_WriteOnly); - fixed_dawg->write(&dawgfile); - dawgfile.close(); - } - } else { - fixed_dawg->readFile(dawgfilename); - } + if ( !docDirCreated ) + createDocDir(); + + fixed_dawg = new QDawg; + QString dawgfilename = dictDir() + "/dawg"; + QString words_lang; + QStringList langs = Global::languageList(); + for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { + QString lang = *it; + words_lang = dictDir() + "/words." + lang; + QString dawgfilename_lang = dawgfilename + "." + lang; + if ( QFile::exists(dawgfilename_lang) || + QFile::exists(words_lang) ) { + dawgfilename = dawgfilename_lang; + break; + } + } + QFile dawgfile(dawgfilename); + + if ( !dawgfile.exists() ) { + QString fn = dictDir() + "/words"; + if ( QFile::exists(words_lang) ) + fn = words_lang; + QFile in(fn); + if ( in.open(IO_ReadOnly) ) { + fixed_dawg->createFromWords(&in); + dawgfile.open(IO_WriteOnly); + fixed_dawg->write(&dawgfile); + dawgfile.close(); + } + } else { + fixed_dawg->readFile(dawgfilename); + } } @@ -299,11 +279,11 @@ const QDawg& Global::dawg(const QString& name) if ( !named_dawg ) - named_dawg = new QDict<QDawg>; + named_dawg = new QDict<QDawg>; QDawg* r = named_dawg->find(name); if ( !r ) { - r = new QDawg; - named_dawg->insert(name,r); - QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; - QFile dawgfile(dawgfilename); - if ( dawgfile.open(IO_ReadOnly) ) - r->readFile(dawgfilename); + r = new QDawg; + named_dawg->insert(name,r); + QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; + QFile dawgfile(dawgfilename); + if ( dawgfile.open(IO_ReadOnly) ) + r->readFile(dawgfilename); } @@ -342,4 +322,4 @@ void Global::addWords(const QString& dictname, const QStringList& wordlist) if ( dawgfile.open(IO_WriteOnly) ) { - d.write(&dawgfile); - dawgfile.close(); + d.write(&dawgfile); + dawgfile.close(); } @@ -365,8 +345,8 @@ QString Global::applicationFileName(const QString& appname, const QString& filen if ( !QFile::exists( r ) ) - if ( d.mkdir(r) == false ) - return QString::null; + if ( d.mkdir(r) == false ) + return QString::null; r += appname; if ( !QFile::exists( r ) ) - if ( d.mkdir(r) == false ) - return QString::null; + if ( d.mkdir(r) == false ) + return QString::null; r += "/"; r += filename; @@ -381,4 +361,4 @@ void Global::createDocDir() if ( !docDirCreated ) { - docDirCreated = TRUE; - mkdir( QPEApplication::documentDir().latin1(), 0755 ); + docDirCreated = TRUE; + mkdir( QPEApplication::documentDir().latin1(), 0755 ); } @@ -472,7 +452,7 @@ bool Global::isBuiltinCommand( const QString &name ) if(!builtin) - return FALSE; // yes, it can happen + return FALSE; // yes, it can happen for (int i = 0; builtin[i].file; i++) { - if ( builtin[i].file == name ) { - return TRUE; - } + if ( builtin[i].file == name ) { + return TRUE; + } } @@ -496,3 +476,3 @@ void Global::setBuiltinCommands( Command* list ) if ( running ) - delete [] running; + delete [] running; @@ -501,5 +481,5 @@ void Global::setBuiltinCommands( Command* list ) if (!builtin) - return; + return; while ( builtin[count].file ) - count++; + count++; @@ -522,8 +502,8 @@ bool Global::terminateBuiltin( const QString& n ) if (!builtin) - return FALSE; + return FALSE; for (int i = 0; builtin[i].file; i++) { - if ( builtin[i].file == n ) { - delete running[i]; - return TRUE; - } + if ( builtin[i].file == n ) { + delete running[i]; + return TRUE; + } } @@ -542,3 +522,3 @@ void Global::terminate( const AppLnk* app ) if ( QCopChannel::isRegistered(channel) ) { - QCopEnvelope e(channel, "quit()"); + QCopEnvelope e(channel, "quit()"); } @@ -564,8 +544,8 @@ void Global::invoke(const QString &c) if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { - // If the channel is already register, the app is already running, so show it. - { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } + // If the channel is already register, the app is already running, so show it. + { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } - //QCopEnvelope e("QPE/System", "notBusy(QString)" ); - //e << ap; - return; + //QCopEnvelope e("QPE/System", "notBusy(QString)" ); + //e << ap; + return; } @@ -579,5 +559,5 @@ void Global::invoke(const QString &c) // had the idea that an apploader belongs to the launcher ... - //QCopEnvelope e("QPE/System", "notBusy(QString)" ); - //e << ap; - return; + //QCopEnvelope e("QPE/System", "notBusy(QString)" ); + //e << ap; + return; } @@ -593,3 +573,3 @@ void Global::invoke(const QString &c) for ( j = 0; j < list.count(); j++ ) - slist.append( list[j].utf8() ); + slist.append( list[j].utf8() ); @@ -597,3 +577,3 @@ void Global::invoke(const QString &c) for ( j = 0; j < slist.count(); j++ ) - args[j] = slist.at(j); + args[j] = slist.at(j); args[j] = NULL; @@ -614,4 +594,4 @@ void Global::invoke(const QString &c) if ( QFile::exists( libexe ) ) { - qDebug("calling quickexec %s", libexe.latin1() ); - quickexecv( libexe.utf8().data(), (const char **)args ); + qDebug("calling quickexec %s", libexe.latin1() ); + quickexecv( libexe.utf8().data(), (const char **)args ); } else @@ -685,3 +665,3 @@ void Global::execute( const QString &c, const QString& document ) { - // ask the server to do the work + // ask the server to do the work #if !defined(QT_NO_COP) @@ -708,8 +688,8 @@ QString Global::shellQuote(const QString& s) for (int i=0; i<(int)s.length(); i++) { - char c = s[i].latin1(); - switch (c) { - case '\\': case '"': case '$': - r+="\\"; - } - r += s[i]; + char c = s[i].latin1(); + switch (c) { + case '\\': case '"': case '$': + r+="\\"; + } + r += s[i]; } @@ -729,8 +709,8 @@ QString Global::stringQuote(const QString& s) for (int i=0; i<(int)s.length(); i++) { - char c = s[i].latin1(); - switch (c) { - case '\\': case '"': - r+="\\"; - } - r += s[i]; + char c = s[i].latin1(); + switch (c) { + case '\\': case '"': + r+="\\"; + } + r += s[i]; } @@ -771,5 +751,7 @@ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) QString path = (*it)->path(); - if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) - continue; Config conf((*it)->path() + "/.opiestorage.cf", Config::File ); + conf.setGroup("main"); + if (!conf.readBoolEntry("check",true)) { + continue; + } conf.setGroup("subdirs"); @@ -789,5 +771,5 @@ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { - QString path = (*it)->path() + "/Documents"; - DocLnkSet ide( path, mimefilter ); - folder->appendFrom(ide); + QString path = (*it)->path() + "/Documents"; + DocLnkSet ide( path, mimefilter ); + folder->appendFrom(ide); } @@ -803,6 +785,6 @@ QStringList Global::languageList() if ( i > 0 ) - lang = lang.left( i ); + lang = lang.left( i ); i = lang.find( "_" ); if ( i > 0 ) - langs.append(lang.left(i)); + langs.append(lang.left(i)); return langs; @@ -816,5 +798,5 @@ QStringList Global::helpPath() for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { - QString lang = *it; - if ( !lang.isEmpty() ) - path += qpeDir + "/help/" + lang + "/html"; + QString lang = *it; + if ( !lang.isEmpty() ) + path += qpeDir + "/help/" + lang + "/html"; } |