summaryrefslogtreecommitdiff
path: root/library
authorzecke <zecke>2002-11-08 18:09:37 (UTC)
committer zecke <zecke>2002-11-08 18:09:37 (UTC)
commit028753a6a3857cdcf7476e537de1cd5c471424c4 (patch) (unidiff)
tree29ea6ac56b0a0310d74096101b37cce6ec9430ef /library
parent24da3ab5dd821dd552f13fa7b22f5b3c2986eecd (diff)
downloadopie-028753a6a3857cdcf7476e537de1cd5c471424c4.zip
opie-028753a6a3857cdcf7476e537de1cd5c471424c4.tar.gz
opie-028753a6a3857cdcf7476e537de1cd5c471424c4.tar.bz2
qwsServer belongs to QWS
and not to !QT_NO_COP
Diffstat (limited to 'library') (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 d02e711..9b3c51e 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -1,241 +1,241 @@
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 29
30#include <qfile.h> 30#include <qfile.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qmap.h> 33#include <qmap.h>
34#include <qdict.h> 34#include <qdict.h>
35#include <qdir.h> 35#include <qdir.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qregexp.h> 37#include <qregexp.h>
38 38
39#include <stdlib.h> 39#include <stdlib.h>
40#include <sys/stat.h> 40#include <sys/stat.h>
41#include <sys/wait.h> 41#include <sys/wait.h>
42#include <sys/types.h> 42#include <sys/types.h>
43#include <fcntl.h> 43#include <fcntl.h>
44#include <unistd.h> 44#include <unistd.h>
45 45
46#include <qwindowsystem_qws.h> // for qwsServer 46#include <qwindowsystem_qws.h> // for qwsServer
47#include <qdatetime.h> 47#include <qdatetime.h>
48 48
49#include <qfile.h> 49#include <qfile.h>
50 50
51namespace { 51namespace {
52 // checks if the storage should be searched 52 // checks if the storage should be searched
53 bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke 53 bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke
54 QFile file(path ); 54 QFile file(path );
55 if(!file.open(IO_ReadOnly ) ) 55 if(!file.open(IO_ReadOnly ) )
56 return true; 56 return true;
57 57
58 QByteArray array = file.readAll(); 58 QByteArray array = file.readAll();
59 QStringList list = QStringList::split('\n', QString( array ) ); 59 QStringList list = QStringList::split('\n', QString( array ) );
60 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ 60 for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){
61 if( (*it).startsWith("autocheck = 0" ) ){ 61 if( (*it).startsWith("autocheck = 0" ) ){
62 return false; 62 return false;
63 }else if( (*it).startsWith("autocheck = 1" ) ){ 63 }else if( (*it).startsWith("autocheck = 1" ) ){
64 return true; 64 return true;
65 } 65 }
66 } 66 }
67 return true; 67 return true;
68 } 68 }
69} 69}
70 70
71//#include "quickexec_p.h" 71//#include "quickexec_p.h"
72 72
73class Emitter : public QObject { 73class Emitter : public QObject {
74 Q_OBJECT 74 Q_OBJECT
75public: 75public:
76 Emitter( QWidget* receiver, const QString& document ) 76 Emitter( QWidget* receiver, const QString& document )
77 { 77 {
78 connect(this, SIGNAL(setDocument(const QString&)), 78 connect(this, SIGNAL(setDocument(const QString&)),
79 receiver, SLOT(setDocument(const QString&))); 79 receiver, SLOT(setDocument(const QString&)));
80 emit setDocument(document); 80 emit setDocument(document);
81 disconnect(this, SIGNAL(setDocument(const QString&)), 81 disconnect(this, SIGNAL(setDocument(const QString&)),
82 receiver, SLOT(setDocument(const QString&))); 82 receiver, SLOT(setDocument(const QString&)));
83 } 83 }
84 84
85signals: 85signals:
86 void setDocument(const QString&); 86 void setDocument(const QString&);
87}; 87};
88 88
89 89
90class StartingAppList : public QObject { 90class StartingAppList : public QObject {
91 Q_OBJECT 91 Q_OBJECT
92public: 92public:
93 static void add( const QString& name ); 93 static void add( const QString& name );
94 static bool isStarting( const QString name ); 94 static bool isStarting( const QString name );
95private slots: 95private slots:
96 void handleNewChannel( const QString &); 96 void handleNewChannel( const QString &);
97private: 97private:
98 StartingAppList( QObject *parent=0, const char* name=0 ) ; 98 StartingAppList( QObject *parent=0, const char* name=0 ) ;
99 99
100 QDict<QTime> dict; 100 QDict<QTime> dict;
101 static StartingAppList *appl; 101 static StartingAppList *appl;
102}; 102};
103 103
104StartingAppList* StartingAppList::appl = 0; 104StartingAppList* StartingAppList::appl = 0;
105 105
106StartingAppList::StartingAppList( QObject *parent, const char* name ) 106StartingAppList::StartingAppList( QObject *parent, const char* name )
107 :QObject( parent, name ) 107 :QObject( parent, name )
108{ 108{
109#if QT_VERSION >= 232 && !defined(QT_NO_COP) 109#if QT_VERSION >= 232 && defined(QWS)
110 connect( qwsServer, SIGNAL( newChannel(const QString&)), 110 connect( qwsServer, SIGNAL( newChannel(const QString&)),
111 this, SLOT( handleNewChannel(const QString&)) ); 111 this, SLOT( handleNewChannel(const QString&)) );
112 #endif
112 dict.setAutoDelete( TRUE ); 113 dict.setAutoDelete( TRUE );
113#endif
114} 114}
115 115
116void StartingAppList::add( const QString& name ) 116void StartingAppList::add( const QString& name )
117{ 117{
118#if QT_VERSION >= 232 && !defined(QT_NO_COP) 118#if QT_VERSION >= 232 && !defined(QT_NO_COP)
119 if ( !appl ) 119 if ( !appl )
120 appl = new StartingAppList; 120 appl = new StartingAppList;
121 QTime *t = new QTime; 121 QTime *t = new QTime;
122 t->start(); 122 t->start();
123 appl->dict.insert( "QPE/Application/" + name, t ); 123 appl->dict.insert( "QPE/Application/" + name, t );
124#endif 124#endif
125} 125}
126 126
127bool StartingAppList::isStarting( const QString name ) 127bool StartingAppList::isStarting( const QString name )
128{ 128{
129#if QT_VERSION >= 232 && !defined(QT_NO_COP) 129#if QT_VERSION >= 232 && !defined(QT_NO_COP)
130 if ( appl ) { 130 if ( appl ) {
131 QTime *t = appl->dict.find( "QPE/Application/" + name ); 131 QTime *t = appl->dict.find( "QPE/Application/" + name );
132 if ( !t ) 132 if ( !t )
133 return FALSE; 133 return FALSE;
134 if ( t->elapsed() > 10000 ) { 134 if ( t->elapsed() > 10000 ) {
135 // timeout in case of crash or something 135 // timeout in case of crash or something
136 appl->dict.remove( "QPE/Application/" + name ); 136 appl->dict.remove( "QPE/Application/" + name );
137 return FALSE; 137 return FALSE;
138 } 138 }
139 return TRUE; 139 return TRUE;
140 } 140 }
141#endif 141#endif
142 return FALSE; 142 return FALSE;
143} 143}
144 144
145void StartingAppList::handleNewChannel( const QString & name ) 145void StartingAppList::handleNewChannel( const QString & name )
146{ 146{
147#if QT_VERSION >= 232 && !defined(QT_NO_COP) 147#if QT_VERSION >= 232 && !defined(QT_NO_COP)
148 dict.remove( name ); 148 dict.remove( name );
149#endif 149#endif
150} 150}
151 151
152static bool docDirCreated = FALSE; 152static bool docDirCreated = FALSE;
153static QDawg* fixed_dawg = 0; 153static QDawg* fixed_dawg = 0;
154static QDict<QDawg> *named_dawg = 0; 154static QDict<QDawg> *named_dawg = 0;
155 155
156static QString qpeDir() 156static QString qpeDir()
157{ 157{
158 QString dir = getenv("OPIEDIR"); 158 QString dir = getenv("OPIEDIR");
159 if ( dir.isEmpty() ) dir = ".."; 159 if ( dir.isEmpty() ) dir = "..";
160 return dir; 160 return dir;
161} 161}
162 162
163static QString dictDir() 163static QString dictDir()
164{ 164{
165 return qpeDir() + "/etc/dict"; 165 return qpeDir() + "/etc/dict";
166} 166}
167 167
168/*! 168/*!
169 \class Global global.h 169 \class Global global.h
170 \brief The Global class provides application-wide global functions. 170 \brief The Global class provides application-wide global functions.
171 171
172 The Global functions are grouped as follows: 172 The Global functions are grouped as follows:
173 \tableofcontents 173 \tableofcontents
174 174
175 \section1 User Interface 175 \section1 User Interface
176 176
177 The statusMessage() function provides short-duration messages to the 177 The statusMessage() function provides short-duration messages to the
178 user. The showInputMethod() function shows the current input method, 178 user. The showInputMethod() function shows the current input method,
179 and hideInputMethod() hides the input method. 179 and hideInputMethod() hides the input method.
180 180
181 \section1 Document related 181 \section1 Document related
182 182
183 The findDocuments() function creates a set of \link doclnk.html 183 The findDocuments() function creates a set of \link doclnk.html
184 DocLnk\endlink objects in a particular folder. 184 DocLnk\endlink objects in a particular folder.
185 185
186 \section1 Filesystem related 186 \section1 Filesystem related
187 187
188 Global provides an applicationFileName() function that returns the 188 Global provides an applicationFileName() function that returns the
189 full path of an application-specific file. 189 full path of an application-specific file.
190 190
191 The execute() function runs an application. 191 The execute() function runs an application.
192 192
193 \section1 Word list related 193 \section1 Word list related
194 194
195 A list of words relevant to the current locale is maintained by the 195 A list of words relevant to the current locale is maintained by the
196 system. The list is held in a \link qdawg.html DAWG\endlink 196 system. The list is held in a \link qdawg.html DAWG\endlink
197 (implemented by the QDawg class). This list is used, for example, by 197 (implemented by the QDawg class). This list is used, for example, by
198 the pickboard input method. 198 the pickboard input method.
199 199
200 The global QDawg is returned by fixedDawg(); this cannot be updated. 200 The global QDawg is returned by fixedDawg(); this cannot be updated.
201 An updatable copy of the global QDawg is returned by addedDawg(). 201 An updatable copy of the global QDawg is returned by addedDawg().
202 Applications may have their own word lists stored in \l{QDawg}s 202 Applications may have their own word lists stored in \l{QDawg}s
203 which are returned by dawg(). Use addWords() to add words to the 203 which are returned by dawg(). Use addWords() to add words to the
204 updateable copy of the global QDawg or to named application 204 updateable copy of the global QDawg or to named application
205 \l{QDawg}s. 205 \l{QDawg}s.
206 206
207 \section1 Quoting 207 \section1 Quoting
208 208
209 The shellQuote() function quotes a string suitable for passing to a 209 The shellQuote() function quotes a string suitable for passing to a
210 shell. The stringQuote() function backslash escapes '\' and '"' 210 shell. The stringQuote() function backslash escapes '\' and '"'
211 characters. 211 characters.
212 212
213 \section1 Hardware 213 \section1 Hardware
214 214
215 The writeHWClock() function sets the hardware clock to the system 215 The writeHWClock() function sets the hardware clock to the system
216 clock's date and time. 216 clock's date and time.
217 217
218 \ingroup qtopiaemb 218 \ingroup qtopiaemb
219*/ 219*/
220 220
221/*! 221/*!
222 \internal 222 \internal
223*/ 223*/
224Global::Global() 224Global::Global()
225{ 225{
226} 226}
227 227
228/*! 228/*!
229 Returns the unchangeable QDawg that contains general 229 Returns the unchangeable QDawg that contains general
230 words for the current locale. 230 words for the current locale.
231 231
232 \sa addedDawg() 232 \sa addedDawg()
233*/ 233*/
234const QDawg& Global::fixedDawg() 234const QDawg& Global::fixedDawg()
235{ 235{
236 if ( !fixed_dawg ) { 236 if ( !fixed_dawg ) {
237 if ( !docDirCreated ) 237 if ( !docDirCreated )
238 createDocDir(); 238 createDocDir();
239 239
240 fixed_dawg = new QDawg; 240 fixed_dawg = new QDawg;
241 QString dawgfilename = dictDir() + "/dawg"; 241 QString dawgfilename = dictDir() + "/dawg";