summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp246
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
@@ -51,24 +51,4 @@
51#include <qfile.h> 51#include <qfile.h>
52 52
53namespace {
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"
74 54
@@ -78,9 +58,9 @@ public:
78 Emitter( QWidget* receiver, const QString& document ) 58 Emitter( QWidget* receiver, const QString& document )
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 }
86 66
@@ -111,5 +91,5 @@ StartingAppList::StartingAppList( QObject *parent, const char* name )
111#if QT_VERSION >= 232 && defined(QWS) 91#if QT_VERSION >= 232 && defined(QWS)
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
115 dict.setAutoDelete( TRUE ); 95 dict.setAutoDelete( TRUE );
@@ -120,5 +100,5 @@ void StartingAppList::add( const QString& name )
120#if QT_VERSION >= 232 && !defined(QT_NO_COP) 100#if QT_VERSION >= 232 && !defined(QT_NO_COP)
121 if ( !appl ) 101 if ( !appl )
122 appl = new StartingAppList; 102 appl = new StartingAppList;
123 QTime *t = new QTime; 103 QTime *t = new QTime;
124 t->start(); 104 t->start();
@@ -131,13 +111,13 @@ bool StartingAppList::isStarting( const QString name )
131#if QT_VERSION >= 232 && !defined(QT_NO_COP) 111#if QT_VERSION >= 232 && !defined(QT_NO_COP)
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 }
143#endif 123#endif
@@ -239,37 +219,37 @@ const QDawg& Global::fixedDawg()
239{ 219{
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 }
275 255
@@ -298,13 +278,13 @@ const QDawg& Global::dawg(const QString& name)
298 createDocDir(); 278 createDocDir();
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 }
310 return *r; 290 return *r;
@@ -341,6 +321,6 @@ void Global::addWords(const QString& dictname, const QStringList& wordlist)
341 QFile dawgfile(dawgfilename); 321 QFile dawgfile(dawgfilename);
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 }
346 326
@@ -364,10 +344,10 @@ QString Global::applicationFileName(const QString& appname, const QString& filen
364 r += "/Applications/"; 344 r += "/Applications/";
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;
373 return r; 353 return r;
@@ -380,6 +360,6 @@ void Global::createDocDir()
380{ 360{
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 }
385} 365}
@@ -471,9 +451,9 @@ bool Global::isBuiltinCommand( const QString &name )
471{ 451{
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 }
479 return FALSE; 459 return FALSE;
@@ -495,12 +475,12 @@ void Global::setBuiltinCommands( Command* list )
495{ 475{
496 if ( running ) 476 if ( running )
497 delete [] running; 477 delete [] running;
498 478
499 builtin = list; 479 builtin = list;
500 int count = 0; 480 int count = 0;
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
506 running = new QGuardedPtr<QWidget> [ count ]; 486 running = new QGuardedPtr<QWidget> [ count ];
@@ -521,10 +501,10 @@ bool Global::terminateBuiltin( const QString& n )
521{ 501{
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 }
530 return FALSE; 510 return FALSE;
@@ -541,5 +521,5 @@ void Global::terminate( const AppLnk* app )
541 QCString channel = "QPE/Application/" + app->exec().utf8(); 521 QCString channel = "QPE/Application/" + app->exec().utf8();
542 if ( QCopChannel::isRegistered(channel) ) { 522 if ( QCopChannel::isRegistered(channel) ) {
543 QCopEnvelope e(channel, "quit()"); 523 QCopEnvelope e(channel, "quit()");
544 } 524 }
545#endif 525#endif
@@ -563,10 +543,10 @@ void Global::invoke(const QString &c)
563 // XXX should lock file /tmp/qcop-msg-ap 543 // XXX should lock file /tmp/qcop-msg-ap
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 }
572 // XXX should unlock file /tmp/qcop-msg-ap 552 // XXX should unlock file /tmp/qcop-msg-ap
@@ -578,7 +558,7 @@ void Global::invoke(const QString &c)
578 // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there 558 // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there
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 }
584 564
@@ -592,9 +572,9 @@ void Global::invoke(const QString &c)
592 unsigned int j; 572 unsigned int j;
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
596 const char **args = new (const char *)[slist.count() + 1]; 576 const char **args = new (const char *)[slist.count() + 1];
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;
600 580
@@ -613,6 +593,6 @@ void Global::invoke(const QString &c)
613 qDebug("libfile = %s", libexe.latin1() ); 593 qDebug("libfile = %s", libexe.latin1() );
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
618#endif 598#endif
@@ -684,5 +664,5 @@ void Global::invoke(const QString &c)
684void Global::execute( const QString &c, const QString& document ) 664void 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)
688 if ( document.isNull() ) { 668 if ( document.isNull() ) {
@@ -707,10 +687,10 @@ QString Global::shellQuote(const QString& s)
707 QString r="\""; 687 QString r="\"";
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 }
716 r += "\""; 696 r += "\"";
@@ -728,10 +708,10 @@ QString Global::stringQuote(const QString& s)
728 QString r="\""; 708 QString r="\"";
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 }
737 r += "\""; 717 r += "\"";
@@ -770,7 +750,9 @@ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter)
770 // this is a candidate look at the cf and see if we should search on it 750 // this is a candidate look at the cf and see if we should search on it
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");
776 if (conf.readBoolEntry("wholemedia",true)) { 758 if (conf.readBoolEntry("wholemedia",true)) {
@@ -788,7 +770,7 @@ void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter)
788 } 770 }
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 }
794 } 776 }
@@ -802,8 +784,8 @@ QStringList Global::languageList()
802 int i = lang.find("."); 784 int i = lang.find(".");
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;
809} 791}
@@ -815,7 +797,7 @@ QStringList Global::helpPath()
815 QStringList langs = Global::languageList(); 797 QStringList langs = Global::languageList();
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 }
821 path += qpeDir + "/pics"; 803 path += qpeDir + "/pics";