author | alwin <alwin> | 2004-02-24 13:25:40 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-02-24 13:25:40 (UTC) |
commit | 6b6ba7aa1bf21647a804c7e5e7e1654112c3ee38 (patch) (unidiff) | |
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 @@ | |||
52 | 52 | ||
53 | namespace { | ||
54 | // checks if the storage should be searched | ||
55 | bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke | ||
56 | QFile file(path ); | ||
57 | if(!file.open(IO_ReadOnly ) ) | ||
58 | return true; | ||
59 | |||
60 | QByteArray array = file.readAll(); | ||
61 | QStringList list = QStringList::split('\n', QString( array ) ); | ||
62 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ | ||
63 | if( (*it).startsWith("check = 0" ) ){ | ||
64 | return false; | ||
65 | }else if( (*it).startsWith("check = 1" ) ){ | ||
66 | return true; | ||
67 | } | ||
68 | } | ||
69 | return true; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | //#include "quickexec_p.h" | 53 | //#include "quickexec_p.h" |
@@ -79,7 +59,7 @@ public: | |||
79 | { | 59 | { |
80 | connect(this, SIGNAL(setDocument(const QString&)), | 60 | connect(this, SIGNAL(setDocument(const QString&)), |
81 | receiver, SLOT(setDocument(const QString&))); | 61 | receiver, SLOT(setDocument(const QString&))); |
82 | emit setDocument(document); | 62 | emit setDocument(document); |
83 | disconnect(this, SIGNAL(setDocument(const QString&)), | 63 | disconnect(this, SIGNAL(setDocument(const QString&)), |
84 | receiver, SLOT(setDocument(const QString&))); | 64 | receiver, SLOT(setDocument(const QString&))); |
85 | } | 65 | } |
@@ -112,3 +92,3 @@ StartingAppList::StartingAppList( QObject *parent, const char* name ) | |||
112 | connect( qwsServer, SIGNAL( newChannel(const QString&)), | 92 | connect( qwsServer, SIGNAL( newChannel(const QString&)), |
113 | this, SLOT( handleNewChannel(const QString&)) ); | 93 | this, SLOT( handleNewChannel(const QString&)) ); |
114 | #endif | 94 | #endif |
@@ -121,3 +101,3 @@ void StartingAppList::add( const QString& name ) | |||
121 | if ( !appl ) | 101 | if ( !appl ) |
122 | appl = new StartingAppList; | 102 | appl = new StartingAppList; |
123 | QTime *t = new QTime; | 103 | QTime *t = new QTime; |
@@ -132,11 +112,11 @@ bool StartingAppList::isStarting( const QString name ) | |||
132 | if ( appl ) { | 112 | if ( appl ) { |
133 | QTime *t = appl->dict.find( "QPE/Application/" + name ); | 113 | QTime *t = appl->dict.find( "QPE/Application/" + name ); |
134 | if ( !t ) | 114 | if ( !t ) |
135 | return FALSE; | 115 | return FALSE; |
136 | if ( t->elapsed() > 10000 ) { | 116 | if ( t->elapsed() > 10000 ) { |
137 | // timeout in case of crash or something | 117 | // timeout in case of crash or something |
138 | appl->dict.remove( "QPE/Application/" + name ); | 118 | appl->dict.remove( "QPE/Application/" + name ); |
139 | return FALSE; | 119 | return FALSE; |
140 | } | 120 | } |
141 | return TRUE; | 121 | return TRUE; |
142 | } | 122 | } |
@@ -240,35 +220,35 @@ const QDawg& Global::fixedDawg() | |||
240 | if ( !fixed_dawg ) { | 220 | if ( !fixed_dawg ) { |
241 | if ( !docDirCreated ) | 221 | if ( !docDirCreated ) |
242 | createDocDir(); | 222 | createDocDir(); |
243 | 223 | ||
244 | fixed_dawg = new QDawg; | 224 | fixed_dawg = new QDawg; |
245 | QString dawgfilename = dictDir() + "/dawg"; | 225 | QString dawgfilename = dictDir() + "/dawg"; |
246 | QString words_lang; | 226 | QString words_lang; |
247 | QStringList langs = Global::languageList(); | 227 | QStringList langs = Global::languageList(); |
248 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 228 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
249 | QString lang = *it; | 229 | QString lang = *it; |
250 | words_lang = dictDir() + "/words." + lang; | 230 | words_lang = dictDir() + "/words." + lang; |
251 | QString dawgfilename_lang = dawgfilename + "." + lang; | 231 | QString dawgfilename_lang = dawgfilename + "." + lang; |
252 | if ( QFile::exists(dawgfilename_lang) || | 232 | if ( QFile::exists(dawgfilename_lang) || |
253 | QFile::exists(words_lang) ) { | 233 | QFile::exists(words_lang) ) { |
254 | dawgfilename = dawgfilename_lang; | 234 | dawgfilename = dawgfilename_lang; |
255 | break; | 235 | break; |
256 | } | 236 | } |
257 | } | 237 | } |
258 | QFile dawgfile(dawgfilename); | 238 | QFile dawgfile(dawgfilename); |
259 | 239 | ||
260 | if ( !dawgfile.exists() ) { | 240 | if ( !dawgfile.exists() ) { |
261 | QString fn = dictDir() + "/words"; | 241 | QString fn = dictDir() + "/words"; |
262 | if ( QFile::exists(words_lang) ) | 242 | if ( QFile::exists(words_lang) ) |
263 | fn = words_lang; | 243 | fn = words_lang; |
264 | QFile in(fn); | 244 | QFile in(fn); |
265 | if ( in.open(IO_ReadOnly) ) { | 245 | if ( in.open(IO_ReadOnly) ) { |
266 | fixed_dawg->createFromWords(&in); | 246 | fixed_dawg->createFromWords(&in); |
267 | dawgfile.open(IO_WriteOnly); | 247 | dawgfile.open(IO_WriteOnly); |
268 | fixed_dawg->write(&dawgfile); | 248 | fixed_dawg->write(&dawgfile); |
269 | dawgfile.close(); | 249 | dawgfile.close(); |
270 | } | 250 | } |
271 | } else { | 251 | } else { |
272 | fixed_dawg->readFile(dawgfilename); | 252 | fixed_dawg->readFile(dawgfilename); |
273 | } | 253 | } |
274 | } | 254 | } |
@@ -299,11 +279,11 @@ const QDawg& Global::dawg(const QString& name) | |||
299 | if ( !named_dawg ) | 279 | if ( !named_dawg ) |
300 | named_dawg = new QDict<QDawg>; | 280 | named_dawg = new QDict<QDawg>; |
301 | QDawg* r = named_dawg->find(name); | 281 | QDawg* r = named_dawg->find(name); |
302 | if ( !r ) { | 282 | if ( !r ) { |
303 | r = new QDawg; | 283 | r = new QDawg; |
304 | named_dawg->insert(name,r); | 284 | named_dawg->insert(name,r); |
305 | QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; | 285 | QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; |
306 | QFile dawgfile(dawgfilename); | 286 | QFile dawgfile(dawgfilename); |
307 | if ( dawgfile.open(IO_ReadOnly) ) | 287 | if ( dawgfile.open(IO_ReadOnly) ) |
308 | r->readFile(dawgfilename); | 288 | r->readFile(dawgfilename); |
309 | } | 289 | } |
@@ -342,4 +322,4 @@ void Global::addWords(const QString& dictname, const QStringList& wordlist) | |||
342 | if ( dawgfile.open(IO_WriteOnly) ) { | 322 | if ( dawgfile.open(IO_WriteOnly) ) { |
343 | d.write(&dawgfile); | 323 | d.write(&dawgfile); |
344 | dawgfile.close(); | 324 | dawgfile.close(); |
345 | } | 325 | } |
@@ -365,8 +345,8 @@ QString Global::applicationFileName(const QString& appname, const QString& filen | |||
365 | if ( !QFile::exists( r ) ) | 345 | if ( !QFile::exists( r ) ) |
366 | if ( d.mkdir(r) == false ) | 346 | if ( d.mkdir(r) == false ) |
367 | return QString::null; | 347 | return QString::null; |
368 | r += appname; | 348 | r += appname; |
369 | if ( !QFile::exists( r ) ) | 349 | if ( !QFile::exists( r ) ) |
370 | if ( d.mkdir(r) == false ) | 350 | if ( d.mkdir(r) == false ) |
371 | return QString::null; | 351 | return QString::null; |
372 | r += "/"; r += filename; | 352 | r += "/"; r += filename; |
@@ -381,4 +361,4 @@ void Global::createDocDir() | |||
381 | if ( !docDirCreated ) { | 361 | if ( !docDirCreated ) { |
382 | docDirCreated = TRUE; | 362 | docDirCreated = TRUE; |
383 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); | 363 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); |
384 | } | 364 | } |
@@ -472,7 +452,7 @@ bool Global::isBuiltinCommand( const QString &name ) | |||
472 | if(!builtin) | 452 | if(!builtin) |
473 | return FALSE; // yes, it can happen | 453 | return FALSE; // yes, it can happen |
474 | for (int i = 0; builtin[i].file; i++) { | 454 | for (int i = 0; builtin[i].file; i++) { |
475 | if ( builtin[i].file == name ) { | 455 | if ( builtin[i].file == name ) { |
476 | return TRUE; | 456 | return TRUE; |
477 | } | 457 | } |
478 | } | 458 | } |
@@ -496,3 +476,3 @@ void Global::setBuiltinCommands( Command* list ) | |||
496 | if ( running ) | 476 | if ( running ) |
497 | delete [] running; | 477 | delete [] running; |
498 | 478 | ||
@@ -501,5 +481,5 @@ void Global::setBuiltinCommands( Command* list ) | |||
501 | if (!builtin) | 481 | if (!builtin) |
502 | return; | 482 | return; |
503 | while ( builtin[count].file ) | 483 | while ( builtin[count].file ) |
504 | count++; | 484 | count++; |
505 | 485 | ||
@@ -522,8 +502,8 @@ bool Global::terminateBuiltin( const QString& n ) | |||
522 | if (!builtin) | 502 | if (!builtin) |
523 | return FALSE; | 503 | return FALSE; |
524 | for (int i = 0; builtin[i].file; i++) { | 504 | for (int i = 0; builtin[i].file; i++) { |
525 | if ( builtin[i].file == n ) { | 505 | if ( builtin[i].file == n ) { |
526 | delete running[i]; | 506 | delete running[i]; |
527 | return TRUE; | 507 | return TRUE; |
528 | } | 508 | } |
529 | } | 509 | } |
@@ -542,3 +522,3 @@ void Global::terminate( const AppLnk* app ) | |||
542 | if ( QCopChannel::isRegistered(channel) ) { | 522 | if ( QCopChannel::isRegistered(channel) ) { |
543 | QCopEnvelope e(channel, "quit()"); | 523 | QCopEnvelope e(channel, "quit()"); |
544 | } | 524 | } |
@@ -564,8 +544,8 @@ void Global::invoke(const QString &c) | |||
564 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { | 544 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { |
565 | // If the channel is already register, the app is already running, so show it. | 545 | // If the channel is already register, the app is already running, so show it. |
566 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | 546 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } |
567 | 547 | ||
568 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 548 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
569 | //e << ap; | 549 | //e << ap; |
570 | return; | 550 | return; |
571 | } | 551 | } |
@@ -579,5 +559,5 @@ void Global::invoke(const QString &c) | |||
579 | // had the idea that an apploader belongs to the launcher ... | 559 | // had the idea that an apploader belongs to the launcher ... |
580 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 560 | //QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
581 | //e << ap; | 561 | //e << ap; |
582 | return; | 562 | return; |
583 | } | 563 | } |
@@ -593,3 +573,3 @@ void Global::invoke(const QString &c) | |||
593 | for ( j = 0; j < list.count(); j++ ) | 573 | for ( j = 0; j < list.count(); j++ ) |
594 | slist.append( list[j].utf8() ); | 574 | slist.append( list[j].utf8() ); |
595 | 575 | ||
@@ -597,3 +577,3 @@ void Global::invoke(const QString &c) | |||
597 | for ( j = 0; j < slist.count(); j++ ) | 577 | for ( j = 0; j < slist.count(); j++ ) |
598 | args[j] = slist.at(j); | 578 | args[j] = slist.at(j); |
599 | args[j] = NULL; | 579 | args[j] = NULL; |
@@ -614,4 +594,4 @@ void Global::invoke(const QString &c) | |||
614 | if ( QFile::exists( libexe ) ) { | 594 | if ( QFile::exists( libexe ) ) { |
615 | qDebug("calling quickexec %s", libexe.latin1() ); | 595 | qDebug("calling quickexec %s", libexe.latin1() ); |
616 | quickexecv( libexe.utf8().data(), (const char **)args ); | 596 | quickexecv( libexe.utf8().data(), (const char **)args ); |
617 | } else | 597 | } else |
@@ -685,3 +665,3 @@ void Global::execute( const QString &c, const QString& document ) | |||
685 | { | 665 | { |
686 | // ask the server to do the work | 666 | // ask the server to do the work |
687 | #if !defined(QT_NO_COP) | 667 | #if !defined(QT_NO_COP) |
@@ -708,8 +688,8 @@ QString Global::shellQuote(const QString& s) | |||
708 | for (int i=0; i<(int)s.length(); i++) { | 688 | for (int i=0; i<(int)s.length(); i++) { |
709 | char c = s[i].latin1(); | 689 | char c = s[i].latin1(); |
710 | switch (c) { | 690 | switch (c) { |
711 | case '\\': case '"': case '$': | 691 | case '\\': case '"': case '$': |
712 | r+="\\"; | 692 | r+="\\"; |
713 | } | 693 | } |
714 | r += s[i]; | 694 | r += s[i]; |
715 | } | 695 | } |
@@ -729,8 +709,8 @@ QString Global::stringQuote(const QString& s) | |||
729 | for (int i=0; i<(int)s.length(); i++) { | 709 | for (int i=0; i<(int)s.length(); i++) { |
730 | char c = s[i].latin1(); | 710 | char c = s[i].latin1(); |
731 | switch (c) { | 711 | switch (c) { |
732 | case '\\': case '"': | 712 | case '\\': case '"': |
733 | r+="\\"; | 713 | r+="\\"; |
734 | } | 714 | } |
735 | r += s[i]; | 715 | r += s[i]; |
736 | } | 716 | } |
@@ -771,5 +751,7 @@ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) | |||
771 | QString path = (*it)->path(); | 751 | QString path = (*it)->path(); |
772 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) | ||
773 | continue; | ||
774 | Config conf((*it)->path() + "/.opiestorage.cf", Config::File ); | 752 | Config conf((*it)->path() + "/.opiestorage.cf", Config::File ); |
753 | conf.setGroup("main"); | ||
754 | if (!conf.readBoolEntry("check",true)) { | ||
755 | continue; | ||
756 | } | ||
775 | conf.setGroup("subdirs"); | 757 | conf.setGroup("subdirs"); |
@@ -789,5 +771,5 @@ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) | |||
789 | } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | 771 | } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { |
790 | QString path = (*it)->path() + "/Documents"; | 772 | QString path = (*it)->path() + "/Documents"; |
791 | DocLnkSet ide( path, mimefilter ); | 773 | DocLnkSet ide( path, mimefilter ); |
792 | folder->appendFrom(ide); | 774 | folder->appendFrom(ide); |
793 | } | 775 | } |
@@ -803,6 +785,6 @@ QStringList Global::languageList() | |||
803 | if ( i > 0 ) | 785 | if ( i > 0 ) |
804 | lang = lang.left( i ); | 786 | lang = lang.left( i ); |
805 | i = lang.find( "_" ); | 787 | i = lang.find( "_" ); |
806 | if ( i > 0 ) | 788 | if ( i > 0 ) |
807 | langs.append(lang.left(i)); | 789 | langs.append(lang.left(i)); |
808 | return langs; | 790 | return langs; |
@@ -816,5 +798,5 @@ QStringList Global::helpPath() | |||
816 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { | 798 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { |
817 | QString lang = *it; | 799 | QString lang = *it; |
818 | if ( !lang.isEmpty() ) | 800 | if ( !lang.isEmpty() ) |
819 | path += qpeDir + "/help/" + lang + "/html"; | 801 | path += qpeDir + "/help/" + lang + "/html"; |
820 | } | 802 | } |