summaryrefslogtreecommitdiff
path: root/library/global.cpp
Unidiff
Diffstat (limited to 'library/global.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/global.cpp b/library/global.cpp
index 6182de8..4aca08b 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -1,257 +1,257 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
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#include <qpe/qcopenvelope_qws.h> 28#include <qpe/qcopenvelope_qws.h>
29#include <qpe/config.h> 29#include <qpe/config.h>
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qdict.h> 35#include <qdict.h>
36#include <qdir.h> 36#include <qdir.h>
37#include <qmessagebox.h> 37#include <qmessagebox.h>
38#include <qregexp.h> 38#include <qregexp.h>
39 39
40#include <stdlib.h> 40#include <stdlib.h>
41#include <sys/stat.h> 41#include <sys/stat.h>
42#include <sys/wait.h> 42#include <sys/wait.h>
43#include <sys/types.h> 43#include <sys/types.h>
44#include <fcntl.h> 44#include <fcntl.h>
45#include <unistd.h> 45#include <unistd.h>
46#include <errno.h> 46#include <errno.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> 51#include <qfile.h>
52 52
53namespace { 53namespace {
54 // checks if the storage should be searched 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 55 bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke
56 QFile file(path ); 56 QFile file(path );
57 if(!file.open(IO_ReadOnly ) ) 57 if(!file.open(IO_ReadOnly ) )
58 return true; 58 return true;
59 59
60 QByteArray array = file.readAll(); 60 QByteArray array = file.readAll();
61 QStringList list = QStringList::split('\n', QString( array ) ); 61 QStringList list = QStringList::split('\n', QString( array ) );
62 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ 62 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){
63 if( (*it).startsWith("autocheck = 0" ) ){ 63 if( (*it).startsWith("check = 0" ) ){
64 return false; 64 return false;
65 }else if( (*it).startsWith("autocheck = 1" ) ){ 65 }else if( (*it).startsWith("check = 1" ) ){
66 return true; 66 return true;
67 } 67 }
68 } 68 }
69 return true; 69 return true;
70 } 70 }
71} 71}
72 72
73//#include "quickexec_p.h" 73//#include "quickexec_p.h"
74 74
75class Emitter : public QObject { 75class Emitter : public QObject {
76 Q_OBJECT 76 Q_OBJECT
77public: 77public:
78 Emitter( QWidget* receiver, const QString& document ) 78 Emitter( QWidget* receiver, const QString& document )
79 { 79 {
80 connect(this, SIGNAL(setDocument(const QString&)), 80 connect(this, SIGNAL(setDocument(const QString&)),
81 receiver, SLOT(setDocument(const QString&))); 81 receiver, SLOT(setDocument(const QString&)));
82 emit setDocument(document); 82 emit setDocument(document);
83 disconnect(this, SIGNAL(setDocument(const QString&)), 83 disconnect(this, SIGNAL(setDocument(const QString&)),
84 receiver, SLOT(setDocument(const QString&))); 84 receiver, SLOT(setDocument(const QString&)));
85 } 85 }
86 86
87signals: 87signals:
88 void setDocument(const QString&); 88 void setDocument(const QString&);
89}; 89};
90 90
91 91
92class StartingAppList : public QObject { 92class StartingAppList : public QObject {
93 Q_OBJECT 93 Q_OBJECT
94public: 94public:
95 static void add( const QString& name ); 95 static void add( const QString& name );
96 static bool isStarting( const QString name ); 96 static bool isStarting( const QString name );
97private slots: 97private slots:
98 void handleNewChannel( const QString &); 98 void handleNewChannel( const QString &);
99private: 99private:
100 StartingAppList( QObject *parent=0, const char* name=0 ) ; 100 StartingAppList( QObject *parent=0, const char* name=0 ) ;
101 101
102 QDict<QTime> dict; 102 QDict<QTime> dict;
103 static StartingAppList *appl; 103 static StartingAppList *appl;
104}; 104};
105 105
106StartingAppList* StartingAppList::appl = 0; 106StartingAppList* StartingAppList::appl = 0;
107 107
108StartingAppList::StartingAppList( QObject *parent, const char* name ) 108StartingAppList::StartingAppList( QObject *parent, const char* name )
109 :QObject( parent, name ) 109 :QObject( parent, name )
110{ 110{
111#if QT_VERSION >= 232 && defined(QWS) 111#if QT_VERSION >= 232 && defined(QWS)
112 connect( qwsServer, SIGNAL( newChannel(const QString&)), 112 connect( qwsServer, SIGNAL( newChannel(const QString&)),
113 this, SLOT( handleNewChannel(const QString&)) ); 113 this, SLOT( handleNewChannel(const QString&)) );
114#endif 114#endif
115 dict.setAutoDelete( TRUE ); 115 dict.setAutoDelete( TRUE );
116} 116}
117 117
118void StartingAppList::add( const QString& name ) 118void StartingAppList::add( const QString& name )
119{ 119{
120#if QT_VERSION >= 232 && !defined(QT_NO_COP) 120#if QT_VERSION >= 232 && !defined(QT_NO_COP)
121 if ( !appl ) 121 if ( !appl )
122 appl = new StartingAppList; 122 appl = new StartingAppList;
123 QTime *t = new QTime; 123 QTime *t = new QTime;
124 t->start(); 124 t->start();
125 appl->dict.insert( "QPE/Application/" + name, t ); 125 appl->dict.insert( "QPE/Application/" + name, t );
126#endif 126#endif
127} 127}
128 128
129bool StartingAppList::isStarting( const QString name ) 129bool StartingAppList::isStarting( const QString name )
130{ 130{
131#if QT_VERSION >= 232 && !defined(QT_NO_COP) 131#if QT_VERSION >= 232 && !defined(QT_NO_COP)
132 if ( appl ) { 132 if ( appl ) {
133 QTime *t = appl->dict.find( "QPE/Application/" + name ); 133 QTime *t = appl->dict.find( "QPE/Application/" + name );
134 if ( !t ) 134 if ( !t )
135 return FALSE; 135 return FALSE;
136 if ( t->elapsed() > 10000 ) { 136 if ( t->elapsed() > 10000 ) {
137 // timeout in case of crash or something 137 // timeout in case of crash or something
138 appl->dict.remove( "QPE/Application/" + name ); 138 appl->dict.remove( "QPE/Application/" + name );
139 return FALSE; 139 return FALSE;
140 } 140 }
141 return TRUE; 141 return TRUE;
142 } 142 }
143#endif 143#endif
144 return FALSE; 144 return FALSE;
145} 145}
146 146
147void StartingAppList::handleNewChannel( const QString & name ) 147void StartingAppList::handleNewChannel( const QString & name )
148{ 148{
149#if QT_VERSION >= 232 && !defined(QT_NO_COP) 149#if QT_VERSION >= 232 && !defined(QT_NO_COP)
150 dict.remove( name ); 150 dict.remove( name );
151#endif 151#endif
152} 152}
153 153
154static bool docDirCreated = FALSE; 154static bool docDirCreated = FALSE;
155static QDawg* fixed_dawg = 0; 155static QDawg* fixed_dawg = 0;
156static QDict<QDawg> *named_dawg = 0; 156static QDict<QDawg> *named_dawg = 0;
157 157
158static QString qpeDir() 158static QString qpeDir()
159{ 159{
160 QString dir = getenv("OPIEDIR"); 160 QString dir = getenv("OPIEDIR");
161 if ( dir.isEmpty() ) dir = ".."; 161 if ( dir.isEmpty() ) dir = "..";
162 return dir; 162 return dir;
163} 163}
164 164
165static QString dictDir() 165static QString dictDir()
166{ 166{
167 return qpeDir() + "/etc/dict"; 167 return qpeDir() + "/etc/dict";
168} 168}
169 169
170/*! 170/*!
171 \class Global global.h 171 \class Global global.h
172 \brief The Global class provides application-wide global functions. 172 \brief The Global class provides application-wide global functions.
173 173
174 The Global functions are grouped as follows: 174 The Global functions are grouped as follows:
175 \tableofcontents 175 \tableofcontents
176 176
177 \section1 User Interface 177 \section1 User Interface
178 178
179 The statusMessage() function provides short-duration messages to the 179 The statusMessage() function provides short-duration messages to the
180 user. The showInputMethod() function shows the current input method, 180 user. The showInputMethod() function shows the current input method,
181 and hideInputMethod() hides the input method. 181 and hideInputMethod() hides the input method.
182 182
183 \section1 Document related 183 \section1 Document related
184 184
185 The findDocuments() function creates a set of \link doclnk.html 185 The findDocuments() function creates a set of \link doclnk.html
186 DocLnk\endlink objects in a particular folder. 186 DocLnk\endlink objects in a particular folder.
187 187
188 \section1 Filesystem related 188 \section1 Filesystem related
189 189
190 Global provides an applicationFileName() function that returns the 190 Global provides an applicationFileName() function that returns the
191 full path of an application-specific file. 191 full path of an application-specific file.
192 192
193 The execute() function runs an application. 193 The execute() function runs an application.
194 194
195 \section1 Word list related 195 \section1 Word list related
196 196
197 A list of words relevant to the current locale is maintained by the 197 A list of words relevant to the current locale is maintained by the
198 system. The list is held in a \link qdawg.html DAWG\endlink 198 system. The list is held in a \link qdawg.html DAWG\endlink
199 (implemented by the QDawg class). This list is used, for example, by 199 (implemented by the QDawg class). This list is used, for example, by
200 the pickboard input method. 200 the pickboard input method.
201 201
202 The global QDawg is returned by fixedDawg(); this cannot be updated. 202 The global QDawg is returned by fixedDawg(); this cannot be updated.
203 An updatable copy of the global QDawg is returned by addedDawg(). 203 An updatable copy of the global QDawg is returned by addedDawg().
204 Applications may have their own word lists stored in \l{QDawg}s 204 Applications may have their own word lists stored in \l{QDawg}s
205 which are returned by dawg(). Use addWords() to add words to the 205 which are returned by dawg(). Use addWords() to add words to the
206 updateable copy of the global QDawg or to named application 206 updateable copy of the global QDawg or to named application
207 \l{QDawg}s. 207 \l{QDawg}s.
208 208
209 \section1 Quoting 209 \section1 Quoting
210 210
211 The shellQuote() function quotes a string suitable for passing to a 211 The shellQuote() function quotes a string suitable for passing to a
212 shell. The stringQuote() function backslash escapes '\' and '"' 212 shell. The stringQuote() function backslash escapes '\' and '"'
213 characters. 213 characters.
214 214
215 \section1 Hardware 215 \section1 Hardware
216 216
217 The implementation of the writeHWClock() function depends on the AlarmServer 217 The implementation of the writeHWClock() function depends on the AlarmServer
218 implementation. If the AlarmServer is using atd the clock will be synced to 218 implementation. If the AlarmServer is using atd the clock will be synced to
219 hardware. If opie-alarm is used the hardware clock will be synced before 219 hardware. If opie-alarm is used the hardware clock will be synced before
220 suspending the device. opie-alarm is used by iPAQ and Zaurii implementation 220 suspending the device. opie-alarm is used by iPAQ and Zaurii implementation
221 221
222 \ingroup qtopiaemb 222 \ingroup qtopiaemb
223*/ 223*/
224 224
225/*! 225/*!
226 \internal 226 \internal
227*/ 227*/
228Global::Global() 228Global::Global()
229{ 229{
230} 230}
231 231
232/*! 232/*!
233 Returns the unchangeable QDawg that contains general 233 Returns the unchangeable QDawg that contains general
234 words for the current locale. 234 words for the current locale.
235 235
236 \sa addedDawg() 236 \sa addedDawg()
237*/ 237*/
238const QDawg& Global::fixedDawg() 238const QDawg& Global::fixedDawg()
239{ 239{
240 if ( !fixed_dawg ) { 240 if ( !fixed_dawg ) {
241 if ( !docDirCreated ) 241 if ( !docDirCreated )
242 createDocDir(); 242 createDocDir();
243 243
244 fixed_dawg = new QDawg; 244 fixed_dawg = new QDawg;
245 QString dawgfilename = dictDir() + "/dawg"; 245 QString dawgfilename = dictDir() + "/dawg";
246 QString words_lang; 246 QString words_lang;
247 QStringList langs = Global::languageList(); 247 QStringList langs = Global::languageList();
248 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 248 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
249 QString lang = *it; 249 QString lang = *it;
250 words_lang = dictDir() + "/words." + lang; 250 words_lang = dictDir() + "/words." + lang;
251 QString dawgfilename_lang = dawgfilename + "." + lang; 251 QString dawgfilename_lang = dawgfilename + "." + lang;
252 if ( QFile::exists(dawgfilename_lang) || 252 if ( QFile::exists(dawgfilename_lang) ||
253 QFile::exists(words_lang) ) { 253 QFile::exists(words_lang) ) {
254 dawgfilename = dawgfilename_lang; 254 dawgfilename = dawgfilename_lang;
255 break; 255 break;
256 } 256 }
257 } 257 }