summaryrefslogtreecommitdiff
path: root/library/global.cpp
Unidiff
Diffstat (limited to 'library/global.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/library/global.cpp b/library/global.cpp
index dd15eb7..5a28595 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -19,64 +19,86 @@
19**********************************************************************/ 19**********************************************************************/
20#define QTOPIA_INTERNAL_LANGLIST 20#define QTOPIA_INTERNAL_LANGLIST
21#include <qpe/qpedebug.h> 21#include <qpe/qpedebug.h>
22#include <qpe/global.h> 22#include <qpe/global.h>
23#include <qpe/qdawg.h> 23#include <qpe/qdawg.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/storage.h> 26#include <qpe/storage.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 28#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
29#include "qpe/qcopenvelope_qws.h" 29#include "qpe/qcopenvelope_qws.h"
30#endif 30#endif
31 31
32#include <qfile.h> 32#include <qfile.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qtimer.h> 34#include <qtimer.h>
35#include <qmap.h> 35#include <qmap.h>
36#include <qdict.h> 36#include <qdict.h>
37#include <qdir.h> 37#include <qdir.h>
38#include <qmessagebox.h> 38#include <qmessagebox.h>
39#include <qregexp.h> 39#include <qregexp.h>
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42#include <sys/stat.h> 42#include <sys/stat.h>
43#include <sys/wait.h> 43#include <sys/wait.h>
44#include <sys/types.h> 44#include <sys/types.h>
45#include <fcntl.h> 45#include <fcntl.h>
46#include <unistd.h> 46#include <unistd.h>
47 47
48#include <qwindowsystem_qws.h> // for qwsServer 48#include <qwindowsystem_qws.h> // for qwsServer
49#include <qdatetime.h> 49#include <qdatetime.h>
50 50
51#include <qfile.h>
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("autocheck = 0" ) ){
64 return true;
65 }else if( (*it).startsWith("autocheck = 1" ) ){
66 return false;
67 }
68 }
69 return true;
70 }
71}
72
51//#include "quickexec_p.h" 73//#include "quickexec_p.h"
52 74
53class Emitter : public QObject { 75class Emitter : public QObject {
54 Q_OBJECT 76 Q_OBJECT
55public: 77public:
56 Emitter( QWidget* receiver, const QString& document ) 78 Emitter( QWidget* receiver, const QString& document )
57 { 79 {
58 connect(this, SIGNAL(setDocument(const QString&)), 80 connect(this, SIGNAL(setDocument(const QString&)),
59 receiver, SLOT(setDocument(const QString&))); 81 receiver, SLOT(setDocument(const QString&)));
60 emit setDocument(document); 82 emit setDocument(document);
61 disconnect(this, SIGNAL(setDocument(const QString&)), 83 disconnect(this, SIGNAL(setDocument(const QString&)),
62 receiver, SLOT(setDocument(const QString&))); 84 receiver, SLOT(setDocument(const QString&)));
63 } 85 }
64 86
65signals: 87signals:
66 void setDocument(const QString&); 88 void setDocument(const QString&);
67}; 89};
68 90
69 91
70class StartingAppList : public QObject { 92class StartingAppList : public QObject {
71 Q_OBJECT 93 Q_OBJECT
72public: 94public:
73 static void add( const QString& name ); 95 static void add( const QString& name );
74 static bool isStarting( const QString name ); 96 static bool isStarting( const QString name );
75private slots: 97private slots:
76 void handleNewChannel( const QString &); 98 void handleNewChannel( const QString &);
77private: 99private:
78 StartingAppList( QObject *parent=0, const char* name=0 ) ; 100 StartingAppList( QObject *parent=0, const char* name=0 ) ;
79 101
80 QDict<QTime> dict; 102 QDict<QTime> dict;
81 static StartingAppList *appl; 103 static StartingAppList *appl;
82}; 104};
@@ -609,69 +631,72 @@ QString Global::shellQuote(const QString& s)
609 Returns the string \a s with the characters backslash and " 631 Returns the string \a s with the characters backslash and "
610 quoted by a preceeding backslash. 632 quoted by a preceeding backslash.
611*/ 633*/
612QString Global::stringQuote(const QString& s) 634QString Global::stringQuote(const QString& s)
613{ 635{
614 QString r="\""; 636 QString r="\"";
615 for (int i=0; i<(int)s.length(); i++) { 637 for (int i=0; i<(int)s.length(); i++) {
616 char c = s[i].latin1(); 638 char c = s[i].latin1();
617 switch (c) { 639 switch (c) {
618 case '\\': case '"': 640 case '\\': case '"':
619 r+="\\"; 641 r+="\\";
620 } 642 }
621 r += s[i]; 643 r += s[i];
622 } 644 }
623 r += "\""; 645 r += "\"";
624 return r; 646 return r;
625} 647}
626 648
627/*! 649/*!
628 Finds all documents on the system's document directories which 650 Finds all documents on the system's document directories which
629 match the filter \a mimefilter, and appends the resulting DocLnk 651 match the filter \a mimefilter, and appends the resulting DocLnk
630 objects to \a folder. 652 objects to \a folder.
631*/ 653*/
632void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) 654void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter)
633{ 655{
634 QString homedocs = QString(getenv("HOME")) + "/Documents"; 656 QString homedocs = QString(getenv("HOME")) + "/Documents";
635 DocLnkSet d(homedocs,mimefilter); 657 DocLnkSet d(homedocs,mimefilter);
636 folder->appendFrom(d); 658 folder->appendFrom(d);
637 StorageInfo storage; 659 StorageInfo storage;
638 const QList<FileSystem> &fs = storage.fileSystems(); 660 const QList<FileSystem> &fs = storage.fileSystems();
639 QListIterator<FileSystem> it ( fs ); 661 QListIterator<FileSystem> it ( fs );
640 for ( ; it.current(); ++it ) { 662 for ( ; it.current(); ++it ) {
641 if ( (*it)->isRemovable() ) { 663 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
642 QString path = (*it)->path(); 664 // this is a candidate look at the cf and see if we should search on it
643 DocLnkSet ide( path, mimefilter ); 665 QString path = (*it)->path();
644 folder->appendFrom(ide); 666 if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) )
645 } 667 continue;
668 DocLnkSet ide( path, mimefilter );
669 folder->appendFrom(ide);
670 }
646 } 671 }
647} 672}
648 673
649QStringList Global::languageList() 674QStringList Global::languageList()
650{ 675{
651 QString lang = getenv("LANG"); 676 QString lang = getenv("LANG");
652 QStringList langs; 677 QStringList langs;
653 langs.append(lang); 678 langs.append(lang);
654 int i = lang.find("."); 679 int i = lang.find(".");
655 if ( i > 0 ) 680 if ( i > 0 )
656 lang = lang.left( i ); 681 lang = lang.left( i );
657 i = lang.find( "_" ); 682 i = lang.find( "_" );
658 if ( i > 0 ) 683 if ( i > 0 )
659 langs.append(lang.left(i)); 684 langs.append(lang.left(i));
660 return langs; 685 return langs;
661} 686}
662 687
663QStringList Global::helpPath() 688QStringList Global::helpPath()
664{ 689{
665 QStringList path; 690 QStringList path;
666 QStringList langs = Global::languageList(); 691 QStringList langs = Global::languageList();
667 for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { 692 for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) {
668 QString lang = *it; 693 QString lang = *it;
669 if ( !lang.isEmpty() ) 694 if ( !lang.isEmpty() )
670 path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; 695 path += QPEApplication::qpeDir() + "/help/" + lang + "/html";
671 } 696 }
672 path += QPEApplication::qpeDir() + "/pics"; 697 path += QPEApplication::qpeDir() + "/pics";
673 path += QPEApplication::qpeDir() + "/help/en/html"; 698 path += QPEApplication::qpeDir() + "/help/en/html";
674 path += QPEApplication::qpeDir() + "/docs"; 699 path += QPEApplication::qpeDir() + "/docs";
675 QString dir = QDir::current().canonicalPath(); 700 QString dir = QDir::current().canonicalPath();
676 if ( dir == "/" ) 701 if ( dir == "/" )
677 dir += "/docs"; 702 dir += "/docs";