summaryrefslogtreecommitdiff
path: root/library/global.cpp
authorerik <erik>2007-01-19 01:18:01 (UTC)
committer erik <erik>2007-01-19 01:18:01 (UTC)
commit32343107b30904806d02672955c57ed53d39fe79 (patch) (unidiff)
tree9114a0ea170e3adc807a2445b49360f1bfde9626 /library/global.cpp
parentac0ce844e90a64247c0adb210e0a23021b011d57 (diff)
downloadopie-32343107b30904806d02672955c57ed53d39fe79.zip
opie-32343107b30904806d02672955c57ed53d39fe79.tar.gz
opie-32343107b30904806d02672955c57ed53d39fe79.tar.bz2
Every file in this commit has a change to check the return value of a call.
Diffstat (limited to 'library/global.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp63
1 files changed, 31 insertions, 32 deletions
diff --git a/library/global.cpp b/library/global.cpp
index f7a0767..7bdd0b1 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -1,507 +1,506 @@
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 <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#include <errno.h> 45#include <errno.h>
46 46
47#include <qwindowsystem_qws.h> // for qwsServer 47#include <qwindowsystem_qws.h> // for qwsServer
48#include <qdatetime.h> 48#include <qdatetime.h>
49 49
50 50
51//#include "quickexec_p.h" 51//#include "quickexec_p.h"
52 52
53class Emitter : public QObject { 53class Emitter : public QObject {
54 Q_OBJECT 54 Q_OBJECT
55public: 55public:
56 Emitter( QWidget* receiver, const QString& document ) 56 Emitter( QWidget* receiver, const QString& document )
57 { 57 {
58 connect(this, SIGNAL(setDocument(const QString&)), 58 connect(this, SIGNAL(setDocument(const QString&)),
59 receiver, SLOT(setDocument(const QString&))); 59 receiver, SLOT(setDocument(const QString&)));
60 emit setDocument(document); 60 emit setDocument(document);
61 disconnect(this, SIGNAL(setDocument(const QString&)), 61 disconnect(this, SIGNAL(setDocument(const QString&)),
62 receiver, SLOT(setDocument(const QString&))); 62 receiver, SLOT(setDocument(const QString&)));
63 } 63 }
64 64
65signals: 65signals:
66 void setDocument(const QString&); 66 void setDocument(const QString&);
67}; 67};
68 68
69 69
70class StartingAppList : public QObject { 70class StartingAppList : public QObject {
71 Q_OBJECT 71 Q_OBJECT
72public: 72public:
73 static void add( const QString& name ); 73 static void add( const QString& name );
74 static bool isStarting( const QString name ); 74 static bool isStarting( const QString name );
75private slots: 75private slots:
76 void handleNewChannel( const QString &); 76 void handleNewChannel( const QString &);
77private: 77private:
78 StartingAppList( QObject *parent=0, const char* name=0 ) ; 78 StartingAppList( QObject *parent=0, const char* name=0 ) ;
79 79
80 QDict<QTime> dict; 80 QDict<QTime> dict;
81 static StartingAppList *appl; 81 static StartingAppList *appl;
82}; 82};
83 83
84StartingAppList* StartingAppList::appl = 0; 84StartingAppList* StartingAppList::appl = 0;
85 85
86StartingAppList::StartingAppList( QObject *parent, const char* name ) 86StartingAppList::StartingAppList( QObject *parent, const char* name )
87 :QObject( parent, name ) 87 :QObject( parent, name )
88{ 88{
89#if QT_VERSION >= 232 && defined(QWS) 89#if QT_VERSION >= 232 && defined(QWS)
90 connect( qwsServer, SIGNAL( newChannel(const QString&)), 90 connect( qwsServer, SIGNAL( newChannel(const QString&)),
91 this, SLOT( handleNewChannel(const QString&)) ); 91 this, SLOT( handleNewChannel(const QString&)) );
92#endif 92#endif
93 dict.setAutoDelete( TRUE ); 93 dict.setAutoDelete( TRUE );
94} 94}
95 95
96void StartingAppList::add( const QString& name ) 96void StartingAppList::add( const QString& name )
97{ 97{
98#if QT_VERSION >= 232 && !defined(QT_NO_COP) 98#if QT_VERSION >= 232 && !defined(QT_NO_COP)
99 if ( !appl ) 99 if ( !appl )
100 appl = new StartingAppList; 100 appl = new StartingAppList;
101 QTime *t = new QTime; 101 QTime *t = new QTime;
102 t->start(); 102 t->start();
103 appl->dict.insert( "QPE/Application/" + name, t ); 103 appl->dict.insert( "QPE/Application/" + name, t );
104#endif 104#endif
105} 105}
106 106
107bool StartingAppList::isStarting( const QString name ) 107bool StartingAppList::isStarting( const QString name )
108{ 108{
109#if QT_VERSION >= 232 && !defined(QT_NO_COP) 109#if QT_VERSION >= 232 && !defined(QT_NO_COP)
110 if ( appl ) { 110 if ( appl ) {
111 QTime *t = appl->dict.find( "QPE/Application/" + name ); 111 QTime *t = appl->dict.find( "QPE/Application/" + name );
112 if ( !t ) 112 if ( !t )
113 return FALSE; 113 return FALSE;
114 if ( t->elapsed() > 10000 ) { 114 if ( t->elapsed() > 10000 ) {
115 // timeout in case of crash or something 115 // timeout in case of crash or something
116 appl->dict.remove( "QPE/Application/" + name ); 116 appl->dict.remove( "QPE/Application/" + name );
117 return FALSE; 117 return FALSE;
118 } 118 }
119 return TRUE; 119 return TRUE;
120 } 120 }
121#endif 121#endif
122 return FALSE; 122 return FALSE;
123} 123}
124 124
125void StartingAppList::handleNewChannel( const QString & name ) 125void StartingAppList::handleNewChannel( const QString & name )
126{ 126{
127#if QT_VERSION >= 232 && !defined(QT_NO_COP) 127#if QT_VERSION >= 232 && !defined(QT_NO_COP)
128 dict.remove( name ); 128 dict.remove( name );
129#endif 129#endif
130} 130}
131 131
132static bool docDirCreated = FALSE; 132static bool docDirCreated = FALSE;
133static QDawg* fixed_dawg = 0; 133static QDawg* fixed_dawg = 0;
134static QDict<QDawg> *named_dawg = 0; 134static QDict<QDawg> *named_dawg = 0;
135 135
136static QString qpeDir() 136static QString qpeDir()
137{ 137{
138 QString dir = getenv("OPIEDIR"); 138 QString dir = getenv("OPIEDIR");
139 if ( dir.isEmpty() ) dir = ".."; 139 if ( dir.isEmpty() ) dir = "..";
140 return dir; 140 return dir;
141} 141}
142 142
143static QString dictDir() 143static QString dictDir()
144{ 144{
145 return qpeDir() + "/etc/dict"; 145 return qpeDir() + "/etc/dict";
146} 146}
147 147
148/*! 148/*!
149 \class Global global.h 149 \class Global global.h
150 \brief The Global class provides application-wide global functions. 150 \brief The Global class provides application-wide global functions.
151 151
152 The Global functions are grouped as follows: 152 The Global functions are grouped as follows:
153 \tableofcontents 153 \tableofcontents
154 154
155 \section1 User Interface 155 \section1 User Interface
156 156
157 The statusMessage() function provides short-duration messages to the 157 The statusMessage() function provides short-duration messages to the
158 user. The showInputMethod() function shows the current input method, 158 user. The showInputMethod() function shows the current input method,
159 and hideInputMethod() hides the input method. 159 and hideInputMethod() hides the input method.
160 160
161 \section1 Document related 161 \section1 Document related
162 162
163 The findDocuments() function creates a set of \link doclnk.html 163 The findDocuments() function creates a set of \link doclnk.html
164 DocLnk\endlink objects in a particular folder. 164 DocLnk\endlink objects in a particular folder.
165 165
166 \section1 Filesystem related 166 \section1 Filesystem related
167 167
168 Global provides an applicationFileName() function that returns the 168 Global provides an applicationFileName() function that returns the
169 full path of an application-specific file. 169 full path of an application-specific file.
170 170
171 The execute() function runs an application. 171 The execute() function runs an application.
172 172
173 \section1 Word list related 173 \section1 Word list related
174 174
175 A list of words relevant to the current locale is maintained by the 175 A list of words relevant to the current locale is maintained by the
176 system. The list is held in a \link qdawg.html DAWG\endlink 176 system. The list is held in a \link qdawg.html DAWG\endlink
177 (implemented by the QDawg class). This list is used, for example, by 177 (implemented by the QDawg class). This list is used, for example, by
178 the pickboard input method. 178 the pickboard input method.
179 179
180 The global QDawg is returned by fixedDawg(); this cannot be updated. 180 The global QDawg is returned by fixedDawg(); this cannot be updated.
181 An updatable copy of the global QDawg is returned by addedDawg(). 181 An updatable copy of the global QDawg is returned by addedDawg().
182 Applications may have their own word lists stored in \l{QDawg}s 182 Applications may have their own word lists stored in \l{QDawg}s
183 which are returned by dawg(). Use addWords() to add words to the 183 which are returned by dawg(). Use addWords() to add words to the
184 updateable copy of the global QDawg or to named application 184 updateable copy of the global QDawg or to named application
185 \l{QDawg}s. 185 \l{QDawg}s.
186 186
187 \section1 Quoting 187 \section1 Quoting
188 188
189 The shellQuote() function quotes a string suitable for passing to a 189 The shellQuote() function quotes a string suitable for passing to a
190 shell. The stringQuote() function backslash escapes '\' and '"' 190 shell. The stringQuote() function backslash escapes '\' and '"'
191 characters. 191 characters.
192 192
193 \section1 Hardware 193 \section1 Hardware
194 194
195 The implementation of the writeHWClock() function depends on the AlarmServer 195 The implementation of the writeHWClock() function depends on the AlarmServer
196 implementation. If the AlarmServer is using atd the clock will be synced to 196 implementation. If the AlarmServer is using atd the clock will be synced to
197 hardware. If opie-alarm is used the hardware clock will be synced before 197 hardware. If opie-alarm is used the hardware clock will be synced before
198 suspending the device. opie-alarm is used by iPAQ and Zaurii implementation 198 suspending the device. opie-alarm is used by iPAQ and Zaurii implementation
199 199
200 \ingroup qtopiaemb 200 \ingroup qtopiaemb
201*/ 201*/
202 202
203/*! 203/*!
204 \internal 204 \internal
205*/ 205*/
206Global::Global() 206Global::Global()
207{ 207{
208} 208}
209 209
210/*! 210/*!
211 Returns the unchangeable QDawg that contains general 211 Returns the unchangeable QDawg that contains general
212 words for the current locale. 212 words for the current locale.
213 213
214 \sa addedDawg() 214 \sa addedDawg()
215*/ 215*/
216const QDawg& Global::fixedDawg() 216const QDawg& Global::fixedDawg()
217{ 217{
218 if ( !fixed_dawg ) { 218 if ( !fixed_dawg ) {
219 if ( !docDirCreated ) 219 if ( !docDirCreated )
220 createDocDir(); 220 createDocDir();
221 221
222 fixed_dawg = new QDawg; 222 fixed_dawg = new QDawg;
223 QString dawgfilename = dictDir() + "/dawg"; 223 QString dawgfilename = dictDir() + "/dawg";
224 QString words_lang; 224 QString words_lang;
225 QStringList langs = Global::languageList(); 225 QStringList langs = Global::languageList();
226 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 226 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
227 QString lang = *it; 227 QString lang = *it;
228 words_lang = dictDir() + "/words." + lang; 228 words_lang = dictDir() + "/words." + lang;
229 QString dawgfilename_lang = dawgfilename + "." + lang; 229 QString dawgfilename_lang = dawgfilename + "." + lang;
230 if ( QFile::exists(dawgfilename_lang) || 230 if ( QFile::exists(dawgfilename_lang) ||
231 QFile::exists(words_lang) ) { 231 QFile::exists(words_lang) ) {
232 dawgfilename = dawgfilename_lang; 232 dawgfilename = dawgfilename_lang;
233 break; 233 break;
234 } 234 }
235 }
236 QFile dawgfile(dawgfilename);
237
238 if ( !dawgfile.exists() ) {
239 QString fn = dictDir() + "/words";
240 if ( QFile::exists(words_lang) )
241 fn = words_lang;
242 QFile in(fn);
243 if ( in.open(IO_ReadOnly) ) {
244 fixed_dawg->createFromWords(&in);
245 dawgfile.open(IO_WriteOnly);
246 fixed_dawg->write(&dawgfile);
247 dawgfile.close();
248 } 235 }
249 } else { 236 QFile dawgfile(dawgfilename);
250 fixed_dawg->readFile(dawgfilename); 237
251 } 238 if ( !dawgfile.exists() ) {
239 QString fn = dictDir() + "/words";
240 if ( QFile::exists(words_lang) )
241 fn = words_lang;
242 QFile in(fn);
243 if ( in.open(IO_ReadOnly) ) {
244 fixed_dawg->createFromWords(&in);
245 if (dawgfile.open(IO_WriteOnly))
246 fixed_dawg->write(&dawgfile);
247 dawgfile.close();
248 }
249 } else
250 fixed_dawg->readFile(dawgfilename);
252 } 251 }
253 252
254 return *fixed_dawg; 253 return *fixed_dawg;
255} 254}
256 255
257/*! 256/*!
258 Returns the changeable QDawg that contains general 257 Returns the changeable QDawg that contains general
259 words for the current locale. 258 words for the current locale.
260 259
261 \sa fixedDawg() 260 \sa fixedDawg()
262*/ 261*/
263const QDawg& Global::addedDawg() 262const QDawg& Global::addedDawg()
264{ 263{
265 return dawg("local"); 264 return dawg("local");
266} 265}
267 266
268/*! 267/*!
269 Returns the QDawg with the given \a name. 268 Returns the QDawg with the given \a name.
270 This is an application-specific word list. 269 This is an application-specific word list.
271 270
272 \a name should not contain "/". 271 \a name should not contain "/".
273*/ 272*/
274const QDawg& Global::dawg(const QString& name) 273const QDawg& Global::dawg(const QString& name)
275{ 274{
276 createDocDir(); 275 createDocDir();
277 if ( !named_dawg ) 276 if ( !named_dawg )
278 named_dawg = new QDict<QDawg>; 277 named_dawg = new QDict<QDawg>;
279 QDawg* r = named_dawg->find(name); 278 QDawg* r = named_dawg->find(name);
280 if ( !r ) { 279 if ( !r ) {
281 r = new QDawg; 280 r = new QDawg;
282 named_dawg->insert(name,r); 281 named_dawg->insert(name,r);
283 QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; 282 QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg";
284 QFile dawgfile(dawgfilename); 283 QFile dawgfile(dawgfilename);
285 if ( dawgfile.open(IO_ReadOnly) ) 284 if ( dawgfile.open(IO_ReadOnly) )
286 r->readFile(dawgfilename); 285 r->readFile(dawgfilename);
287 } 286 }
288 return *r; 287 return *r;
289} 288}
290 289
291/*! 290/*!
292 \overload 291 \overload
293 Adds \a wordlist to the addedDawg(). 292 Adds \a wordlist to the addedDawg().
294 293
295 Note that the addition of words persists between program executions 294 Note that the addition of words persists between program executions
296 (they are saved in the dictionary files), so you should confirm the 295 (they are saved in the dictionary files), so you should confirm the
297 words with the user before adding them. 296 words with the user before adding them.
298*/ 297*/
299void Global::addWords(const QStringList& wordlist) 298void Global::addWords(const QStringList& wordlist)
300{ 299{
301 addWords("local",wordlist); 300 addWords("local",wordlist);
302} 301}
303 302
304/*! 303/*!
305 \overload 304 \overload
306 Adds \a wordlist to the addedDawg(). 305 Adds \a wordlist to the addedDawg().
307 306
308 Note that the addition of words persists between program executions 307 Note that the addition of words persists between program executions
309 (they are saved in the dictionary files), so you should confirm the 308 (they are saved in the dictionary files), so you should confirm the
310 words with the user before adding them. 309 words with the user before adding them.
311*/ 310*/
312void Global::addWords(const QString& dictname, const QStringList& wordlist) 311void Global::addWords(const QString& dictname, const QStringList& wordlist)
313{ 312{
314 QDawg& d = (QDawg&)dawg(dictname); 313 QDawg& d = (QDawg&)dawg(dictname);
315 QStringList all = d.allWords() + wordlist; 314 QStringList all = d.allWords() + wordlist;
316 d.createFromWords(all); 315 d.createFromWords(all);
317 316
318 QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg"; 317 QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg";
319 QFile dawgfile(dawgfilename); 318 QFile dawgfile(dawgfilename);
320 if ( dawgfile.open(IO_WriteOnly) ) { 319 if ( dawgfile.open(IO_WriteOnly) ) {
321 d.write(&dawgfile); 320 d.write(&dawgfile);
322 dawgfile.close(); 321 dawgfile.close();
323 } 322 }
324 323
325 // #### Re-read the dawg here if we use mmap(). 324 // #### Re-read the dawg here if we use mmap().
326 325
327 // #### Signal other processes to re-read. 326 // #### Signal other processes to re-read.
328} 327}
329 328
330 329
331/*! 330/*!
332 Returns the full path for the application called \a appname, with the 331 Returns the full path for the application called \a appname, with the
333 given \a filename. Returns QString::null if there was a problem creating 332 given \a filename. Returns QString::null if there was a problem creating
334 the directory tree for \a appname. 333 the directory tree for \a appname.
335 If \a filename contains "/", it is the caller's responsibility to 334 If \a filename contains "/", it is the caller's responsibility to
336 ensure that those directories exist. 335 ensure that those directories exist.
337*/ 336*/
338QString Global::applicationFileName(const QString& appname, const QString& filename) 337QString Global::applicationFileName(const QString& appname, const QString& filename)
339{ 338{
340 QDir d; 339 QDir d;
341 QString r = getenv("HOME"); 340 QString r = getenv("HOME");
342 r += "/Applications/"; 341 r += "/Applications/";
343 if ( !QFile::exists( r ) ) 342 if ( !QFile::exists( r ) )
344 if ( d.mkdir(r) == false ) 343 if ( d.mkdir(r) == false )
345 return QString::null; 344 return QString::null;
346 r += appname; 345 r += appname;
347 if ( !QFile::exists( r ) ) 346 if ( !QFile::exists( r ) )
348 if ( d.mkdir(r) == false ) 347 if ( d.mkdir(r) == false )
349 return QString::null; 348 return QString::null;
350 r += "/"; r += filename; 349 r += "/"; r += filename;
351 return r; 350 return r;
352} 351}
353 352
354/*! 353/*!
355 \internal 354 \internal
356*/ 355*/
357void Global::createDocDir() 356void Global::createDocDir()
358{ 357{
359 if ( !docDirCreated ) { 358 if ( !docDirCreated ) {
360 docDirCreated = TRUE; 359 docDirCreated = TRUE;
361 mkdir( QPEApplication::documentDir().latin1(), 0755 ); 360 mkdir( QPEApplication::documentDir().latin1(), 0755 );
362 } 361 }
363} 362}
364 363
365 364
366/*! 365/*!
367 Displays a status \a message to the user. This usually appears 366 Displays a status \a message to the user. This usually appears
368 in the taskbar for a short amount of time, then disappears. 367 in the taskbar for a short amount of time, then disappears.
369*/ 368*/
370void Global::statusMessage(const QString& message) 369void Global::statusMessage(const QString& message)
371{ 370{
372#if !defined(QT_NO_COP) 371#if !defined(QT_NO_COP)
373 QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); 372 QCopEnvelope e( "QPE/TaskBar", "message(QString)" );
374 e << message; 373 e << message;
375#endif 374#endif
376} 375}
377 376
378/*! 377/*!
379 \internal 378 \internal
380*/ 379*/
381void Global::applyStyle() 380void Global::applyStyle()
382{ 381{
383#if !defined(QT_NO_COP) 382#if !defined(QT_NO_COP)
384 QCopChannel::send( "QPE/System", "applyStyle()" ); 383 QCopChannel::send( "QPE/System", "applyStyle()" );
385#else 384#else
386 ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version 385 ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version
387#endif 386#endif
388} 387}
389 388
390/*! 389/*!
391 \internal 390 \internal
392*/ 391*/
393QWidget *Global::shutdown( bool ) 392QWidget *Global::shutdown( bool )
394{ 393{
395#if !defined(QT_NO_COP) 394#if !defined(QT_NO_COP)
396 QCopChannel::send( "QPE/System", "shutdown()" ); 395 QCopChannel::send( "QPE/System", "shutdown()" );
397#endif 396#endif
398 return 0; 397 return 0;
399} 398}
400 399
401/*! 400/*!
402 \internal 401 \internal
403*/ 402*/
404QWidget *Global::restart( bool ) 403QWidget *Global::restart( bool )
405{ 404{
406#if !defined(QT_NO_COP) 405#if !defined(QT_NO_COP)
407 QCopChannel::send( "QPE/System", "restart()" ); 406 QCopChannel::send( "QPE/System", "restart()" );
408#endif 407#endif
409 return 0; 408 return 0;
410} 409}
411 410
412/*! 411/*!
413 Explicitly show the current input method. 412 Explicitly show the current input method.
414 413
415 Input methods are indicated in the taskbar by a small icon. If the 414 Input methods are indicated in the taskbar by a small icon. If the
416 input method is activated (shown) then it takes up some proportion 415 input method is activated (shown) then it takes up some proportion
417 of the bottom of the screen, to allow the user to interact (input 416 of the bottom of the screen, to allow the user to interact (input
418 characters) with it. 417 characters) with it.
419 418
420 \sa hideInputMethod() 419 \sa hideInputMethod()
421*/ 420*/
422void Global::showInputMethod() 421void Global::showInputMethod()
423{ 422{
424#if !defined(QT_NO_COP) 423#if !defined(QT_NO_COP)
425 QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); 424 QCopChannel::send( "QPE/TaskBar", "showInputMethod()" );
426#endif 425#endif
427} 426}
428 427
429/*! 428/*!
430 Explicitly hide the current input method. 429 Explicitly hide the current input method.
431 430
432 The current input method is still indicated in the taskbar, but no 431 The current input method is still indicated in the taskbar, but no
433 longer takes up screen space, and can no longer be interacted with. 432 longer takes up screen space, and can no longer be interacted with.
434 433
435 \sa showInputMethod() 434 \sa showInputMethod()
436*/ 435*/
437void Global::hideInputMethod() 436void Global::hideInputMethod()
438{ 437{
439#if !defined(QT_NO_COP) 438#if !defined(QT_NO_COP)
440 QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); 439 QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" );
441#endif 440#endif
442} 441}
443 442
444 443
445/*! 444/*!
446 \internal 445 \internal
447*/ 446*/
448bool Global::isBuiltinCommand( const QString &name ) 447bool Global::isBuiltinCommand( const QString &name )
449{ 448{
450 if(!builtin) 449 if(!builtin)
451 return FALSE; // yes, it can happen 450 return FALSE; // yes, it can happen
452 for (int i = 0; builtin[i].file; i++) { 451 for (int i = 0; builtin[i].file; i++) {
453 if ( builtin[i].file == name ) { 452 if ( builtin[i].file == name ) {
454 return TRUE; 453 return TRUE;
455 } 454 }
456 } 455 }
457 return FALSE; 456 return FALSE;
458} 457}
459 458
460Global::Command* Global::builtin=0; 459Global::Command* Global::builtin=0;
461QGuardedPtr<QWidget> *Global::running=0; 460QGuardedPtr<QWidget> *Global::running=0;
462 461
463/*! 462/*!
464 \class Global::Command 463 \class Global::Command
465 \brief The Global::Command class is internal. 464 \brief The Global::Command class is internal.
466 \internal 465 \internal
467*/ 466*/
468 467
469/*! 468/*!
470 \internal 469 \internal
471*/ 470*/
472void Global::setBuiltinCommands( Command* list ) 471void Global::setBuiltinCommands( Command* list )
473{ 472{
474 if ( running ) 473 if ( running )
475 delete [] running; 474 delete [] running;
476 475
477 builtin = list; 476 builtin = list;
478 int count = 0; 477 int count = 0;
479 if (!builtin) 478 if (!builtin)
480 return; 479 return;
481 while ( builtin[count].file ) 480 while ( builtin[count].file )
482 count++; 481 count++;
483 482
484 running = new QGuardedPtr<QWidget> [ count ]; 483 running = new QGuardedPtr<QWidget> [ count ];
485} 484}
486 485
487/*! 486/*!
488 \internal 487 \internal
489*/ 488*/
490void Global::setDocument( QWidget* receiver, const QString& document ) 489void Global::setDocument( QWidget* receiver, const QString& document )
491{ 490{
492 Emitter emitter(receiver,document); 491 Emitter emitter(receiver,document);
493} 492}
494 493
495/*! 494/*!
496 \internal 495 \internal
497*/ 496*/
498bool Global::terminateBuiltin( const QString& n ) 497bool Global::terminateBuiltin( const QString& n )
499{ 498{
500 if (!builtin) 499 if (!builtin)
501 return FALSE; 500 return FALSE;
502 for (int i = 0; builtin[i].file; i++) { 501 for (int i = 0; builtin[i].file; i++) {
503 if ( builtin[i].file == n ) { 502 if ( builtin[i].file == n ) {
504 delete running[i]; 503 delete running[i];
505 return TRUE; 504 return TRUE;
506 } 505 }
507 } 506 }