author | zecke <zecke> | 2003-04-16 10:57:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-04-16 10:57:59 (UTC) |
commit | eeb29547890a2d162de66d7d5b98d3840a7e2d79 (patch) (unidiff) | |
tree | 973c6de7aae2fd5ba368efb87fa24234f0e12aa3 /library/global.cpp | |
parent | dfa2d294b3af09bf3757a3c2294a925093e72fc6 (diff) | |
download | opie-eeb29547890a2d162de66d7d5b98d3840a7e2d79.zip opie-eeb29547890a2d162de66d7d5b98d3840a7e2d79.tar.gz opie-eeb29547890a2d162de66d7d5b98d3840a7e2d79.tar.bz2 |
Fix API docu
-rw-r--r-- | library/global.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/library/global.cpp b/library/global.cpp index 68a3a75..ce39751 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -49,129 +49,129 @@ | |||
49 | 49 | ||
50 | #include <qfile.h> | 50 | #include <qfile.h> |
51 | 51 | ||
52 | namespace { | 52 | namespace { |
53 | // checks if the storage should be searched | 53 | // checks if the storage should be searched |
54 | bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke | 54 | bool checkStorage(const QString &path ){ // this is a small Config replacement cause config is too limited -zecke |
55 | QFile file(path ); | 55 | QFile file(path ); |
56 | if(!file.open(IO_ReadOnly ) ) | 56 | if(!file.open(IO_ReadOnly ) ) |
57 | return true; | 57 | return true; |
58 | 58 | ||
59 | QByteArray array = file.readAll(); | 59 | QByteArray array = file.readAll(); |
60 | QStringList list = QStringList::split('\n', QString( array ) ); | 60 | QStringList list = QStringList::split('\n', QString( array ) ); |
61 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ | 61 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ |
62 | if( (*it).startsWith("autocheck = 0" ) ){ | 62 | if( (*it).startsWith("autocheck = 0" ) ){ |
63 | return false; | 63 | return false; |
64 | }else if( (*it).startsWith("autocheck = 1" ) ){ | 64 | }else if( (*it).startsWith("autocheck = 1" ) ){ |
65 | return true; | 65 | return true; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | return true; | 68 | return true; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | //#include "quickexec_p.h" | 72 | //#include "quickexec_p.h" |
73 | 73 | ||
74 | class Emitter : public QObject { | 74 | class Emitter : public QObject { |
75 | Q_OBJECT | 75 | Q_OBJECT |
76 | public: | 76 | public: |
77 | Emitter( QWidget* receiver, const QString& document ) | 77 | Emitter( QWidget* receiver, const QString& document ) |
78 | { | 78 | { |
79 | connect(this, SIGNAL(setDocument(const QString&)), | 79 | connect(this, SIGNAL(setDocument(const QString&)), |
80 | receiver, SLOT(setDocument(const QString&))); | 80 | receiver, SLOT(setDocument(const QString&))); |
81 | emit setDocument(document); | 81 | emit setDocument(document); |
82 | disconnect(this, SIGNAL(setDocument(const QString&)), | 82 | disconnect(this, SIGNAL(setDocument(const QString&)), |
83 | receiver, SLOT(setDocument(const QString&))); | 83 | receiver, SLOT(setDocument(const QString&))); |
84 | } | 84 | } |
85 | 85 | ||
86 | signals: | 86 | signals: |
87 | void setDocument(const QString&); | 87 | void setDocument(const QString&); |
88 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | class StartingAppList : public QObject { | 91 | class StartingAppList : public QObject { |
92 | Q_OBJECT | 92 | Q_OBJECT |
93 | public: | 93 | public: |
94 | static void add( const QString& name ); | 94 | static void add( const QString& name ); |
95 | static bool isStarting( const QString name ); | 95 | static bool isStarting( const QString name ); |
96 | private slots: | 96 | private slots: |
97 | void handleNewChannel( const QString &); | 97 | void handleNewChannel( const QString &); |
98 | private: | 98 | private: |
99 | StartingAppList( QObject *parent=0, const char* name=0 ) ; | 99 | StartingAppList( QObject *parent=0, const char* name=0 ) ; |
100 | 100 | ||
101 | QDict<QTime> dict; | 101 | QDict<QTime> dict; |
102 | static StartingAppList *appl; | 102 | static StartingAppList *appl; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | StartingAppList* StartingAppList::appl = 0; | 105 | StartingAppList* StartingAppList::appl = 0; |
106 | 106 | ||
107 | StartingAppList::StartingAppList( QObject *parent, const char* name ) | 107 | StartingAppList::StartingAppList( QObject *parent, const char* name ) |
108 | :QObject( parent, name ) | 108 | :QObject( parent, name ) |
109 | { | 109 | { |
110 | #if QT_VERSION >= 232 && defined(QWS) | 110 | #if QT_VERSION >= 232 && defined(QWS) |
111 | connect( qwsServer, SIGNAL( newChannel(const QString&)), | 111 | connect( qwsServer, SIGNAL( newChannel(const QString&)), |
112 | this, SLOT( handleNewChannel(const QString&)) ); | 112 | this, SLOT( handleNewChannel(const QString&)) ); |
113 | #endif | 113 | #endif |
114 | dict.setAutoDelete( TRUE ); | 114 | dict.setAutoDelete( TRUE ); |
115 | } | 115 | } |
116 | 116 | ||
117 | void StartingAppList::add( const QString& name ) | 117 | void StartingAppList::add( const QString& name ) |
118 | { | 118 | { |
119 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) | 119 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) |
120 | if ( !appl ) | 120 | if ( !appl ) |
121 | appl = new StartingAppList; | 121 | appl = new StartingAppList; |
122 | QTime *t = new QTime; | 122 | QTime *t = new QTime; |
123 | t->start(); | 123 | t->start(); |
124 | appl->dict.insert( "QPE/Application/" + name, t ); | 124 | appl->dict.insert( "QPE/Application/" + name, t ); |
125 | #endif | 125 | #endif |
126 | } | 126 | } |
127 | 127 | ||
128 | bool StartingAppList::isStarting( const QString name ) | 128 | bool StartingAppList::isStarting( const QString name ) |
129 | { | 129 | { |
130 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) | 130 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) |
131 | if ( appl ) { | 131 | if ( appl ) { |
132 | QTime *t = appl->dict.find( "QPE/Application/" + name ); | 132 | QTime *t = appl->dict.find( "QPE/Application/" + name ); |
133 | if ( !t ) | 133 | if ( !t ) |
134 | return FALSE; | 134 | return FALSE; |
135 | if ( t->elapsed() > 10000 ) { | 135 | if ( t->elapsed() > 10000 ) { |
136 | // timeout in case of crash or something | 136 | // timeout in case of crash or something |
137 | appl->dict.remove( "QPE/Application/" + name ); | 137 | appl->dict.remove( "QPE/Application/" + name ); |
138 | return FALSE; | 138 | return FALSE; |
139 | } | 139 | } |
140 | return TRUE; | 140 | return TRUE; |
141 | } | 141 | } |
142 | #endif | 142 | #endif |
143 | return FALSE; | 143 | return FALSE; |
144 | } | 144 | } |
145 | 145 | ||
146 | void StartingAppList::handleNewChannel( const QString & name ) | 146 | void StartingAppList::handleNewChannel( const QString & name ) |
147 | { | 147 | { |
148 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) | 148 | #if QT_VERSION >= 232 && !defined(QT_NO_COP) |
149 | dict.remove( name ); | 149 | dict.remove( name ); |
150 | #endif | 150 | #endif |
151 | } | 151 | } |
152 | 152 | ||
153 | static bool docDirCreated = FALSE; | 153 | static bool docDirCreated = FALSE; |
154 | static QDawg* fixed_dawg = 0; | 154 | static QDawg* fixed_dawg = 0; |
155 | static QDict<QDawg> *named_dawg = 0; | 155 | static QDict<QDawg> *named_dawg = 0; |
156 | 156 | ||
157 | static QString qpeDir() | 157 | static QString qpeDir() |
158 | { | 158 | { |
159 | QString dir = getenv("OPIEDIR"); | 159 | QString dir = getenv("OPIEDIR"); |
160 | if ( dir.isEmpty() ) dir = ".."; | 160 | if ( dir.isEmpty() ) dir = ".."; |
161 | return dir; | 161 | return dir; |
162 | } | 162 | } |
163 | 163 | ||
164 | static QString dictDir() | 164 | static QString dictDir() |
165 | { | 165 | { |
166 | return qpeDir() + "/etc/dict"; | 166 | return qpeDir() + "/etc/dict"; |
167 | } | 167 | } |
168 | 168 | ||
169 | /*! | 169 | /*! |
170 | \class Global global.h | 170 | \class Global global.h |
171 | \brief The Global class provides application-wide global functions. | 171 | \brief The Global class provides application-wide global functions. |
172 | 172 | ||
173 | The Global functions are grouped as follows: | 173 | The Global functions are grouped as follows: |
174 | \tableofcontents | 174 | \tableofcontents |
175 | 175 | ||
176 | \section1 User Interface | 176 | \section1 User Interface |
177 | 177 | ||
@@ -327,129 +327,129 @@ void Global::addWords(const QStringList& wordlist) | |||
327 | Note that the addition of words persists between program executions | 327 | Note that the addition of words persists between program executions |
328 | (they are saved in the dictionary files), so you should confirm the | 328 | (they are saved in the dictionary files), so you should confirm the |
329 | words with the user before adding them. | 329 | words with the user before adding them. |
330 | */ | 330 | */ |
331 | void Global::addWords(const QString& dictname, const QStringList& wordlist) | 331 | void Global::addWords(const QString& dictname, const QStringList& wordlist) |
332 | { | 332 | { |
333 | QDawg& d = (QDawg&)dawg(dictname); | 333 | QDawg& d = (QDawg&)dawg(dictname); |
334 | QStringList all = d.allWords() + wordlist; | 334 | QStringList all = d.allWords() + wordlist; |
335 | d.createFromWords(all); | 335 | d.createFromWords(all); |
336 | 336 | ||
337 | QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg"; | 337 | QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg"; |
338 | QFile dawgfile(dawgfilename); | 338 | QFile dawgfile(dawgfilename); |
339 | if ( dawgfile.open(IO_WriteOnly) ) { | 339 | if ( dawgfile.open(IO_WriteOnly) ) { |
340 | d.write(&dawgfile); | 340 | d.write(&dawgfile); |
341 | dawgfile.close(); | 341 | dawgfile.close(); |
342 | } | 342 | } |
343 | 343 | ||
344 | // #### Re-read the dawg here if we use mmap(). | 344 | // #### Re-read the dawg here if we use mmap(). |
345 | 345 | ||
346 | // #### Signal other processes to re-read. | 346 | // #### Signal other processes to re-read. |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | /*! | 350 | /*! |
351 | Returns the full path for the application called \a appname, with the | 351 | Returns the full path for the application called \a appname, with the |
352 | given \a filename. Returns QString::null if there was a problem creating | 352 | given \a filename. Returns QString::null if there was a problem creating |
353 | the directory tree for \a appname. | 353 | the directory tree for \a appname. |
354 | If \a filename contains "/", it is the caller's responsibility to | 354 | If \a filename contains "/", it is the caller's responsibility to |
355 | ensure that those directories exist. | 355 | ensure that those directories exist. |
356 | */ | 356 | */ |
357 | QString Global::applicationFileName(const QString& appname, const QString& filename) | 357 | QString Global::applicationFileName(const QString& appname, const QString& filename) |
358 | { | 358 | { |
359 | QDir d; | 359 | QDir d; |
360 | QString r = getenv("HOME"); | 360 | QString r = getenv("HOME"); |
361 | r += "/Applications/"; | 361 | r += "/Applications/"; |
362 | if ( !QFile::exists( r ) ) | 362 | if ( !QFile::exists( r ) ) |
363 | if ( d.mkdir(r) == false ) | 363 | if ( d.mkdir(r) == false ) |
364 | return QString::null; | 364 | return QString::null; |
365 | r += appname; | 365 | r += appname; |
366 | if ( !QFile::exists( r ) ) | 366 | if ( !QFile::exists( r ) ) |
367 | if ( d.mkdir(r) == false ) | 367 | if ( d.mkdir(r) == false ) |
368 | return QString::null; | 368 | return QString::null; |
369 | r += "/"; r += filename; | 369 | r += "/"; r += filename; |
370 | return r; | 370 | return r; |
371 | } | 371 | } |
372 | 372 | ||
373 | /*! | 373 | /*! |
374 | \internal | 374 | \internal |
375 | */ | 375 | */ |
376 | void Global::createDocDir() | 376 | void Global::createDocDir() |
377 | { | 377 | { |
378 | if ( !docDirCreated ) { | 378 | if ( !docDirCreated ) { |
379 | docDirCreated = TRUE; | 379 | docDirCreated = TRUE; |
380 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); | 380 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | 384 | ||
385 | /*! | 385 | /*! |
386 | Displays a status \a message to the user. This usually appears | 386 | Displays a status \a message to the user. This usually appears |
387 | in the taskbar for a short amount of time, then disappears. | 387 | in the taskbar for a short amount of time, then disappears. |
388 | */ | 388 | */ |
389 | void Global::statusMessage(const QString& message) | 389 | void Global::statusMessage(const QString& message) |
390 | { | 390 | { |
391 | #if!defined(QT_NO_COP) | 391 | #if !defined(QT_NO_COP) |
392 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); | 392 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); |
393 | e << message; | 393 | e << message; |
394 | #endif | 394 | #endif |
395 | } | 395 | } |
396 | 396 | ||
397 | /*! | 397 | /*! |
398 | \internal | 398 | \internal |
399 | */ | 399 | */ |
400 | void Global::applyStyle() | 400 | void Global::applyStyle() |
401 | { | 401 | { |
402 | #if !defined(QT_NO_COP) | 402 | #if !defined(QT_NO_COP) |
403 | QCopChannel::send( "QPE/System", "applyStyle()" ); | 403 | QCopChannel::send( "QPE/System", "applyStyle()" ); |
404 | #else | 404 | #else |
405 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version | 405 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version |
406 | #endif | 406 | #endif |
407 | } | 407 | } |
408 | 408 | ||
409 | /*! | 409 | /*! |
410 | \internal | 410 | \internal |
411 | */ | 411 | */ |
412 | QWidget *Global::shutdown( bool ) | 412 | QWidget *Global::shutdown( bool ) |
413 | { | 413 | { |
414 | #if !defined(QT_NO_COP) | 414 | #if !defined(QT_NO_COP) |
415 | QCopChannel::send( "QPE/System", "shutdown()" ); | 415 | QCopChannel::send( "QPE/System", "shutdown()" ); |
416 | #endif | 416 | #endif |
417 | return 0; | 417 | return 0; |
418 | } | 418 | } |
419 | 419 | ||
420 | /*! | 420 | /*! |
421 | \internal | 421 | \internal |
422 | */ | 422 | */ |
423 | QWidget *Global::restart( bool ) | 423 | QWidget *Global::restart( bool ) |
424 | { | 424 | { |
425 | #if !defined(QT_NO_COP) | 425 | #if !defined(QT_NO_COP) |
426 | QCopChannel::send( "QPE/System", "restart()" ); | 426 | QCopChannel::send( "QPE/System", "restart()" ); |
427 | #endif | 427 | #endif |
428 | return 0; | 428 | return 0; |
429 | } | 429 | } |
430 | 430 | ||
431 | /*! | 431 | /*! |
432 | Explicitly show the current input method. | 432 | Explicitly show the current input method. |
433 | 433 | ||
434 | Input methods are indicated in the taskbar by a small icon. If the | 434 | Input methods are indicated in the taskbar by a small icon. If the |
435 | input method is activated (shown) then it takes up some proportion | 435 | input method is activated (shown) then it takes up some proportion |
436 | of the bottom of the screen, to allow the user to interact (input | 436 | of the bottom of the screen, to allow the user to interact (input |
437 | characters) with it. | 437 | characters) with it. |
438 | 438 | ||
439 | \sa hideInputMethod() | 439 | \sa hideInputMethod() |
440 | */ | 440 | */ |
441 | void Global::showInputMethod() | 441 | void Global::showInputMethod() |
442 | { | 442 | { |
443 | #if !defined(QT_NO_COP) | 443 | #if !defined(QT_NO_COP) |
444 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); | 444 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); |
445 | #endif | 445 | #endif |
446 | } | 446 | } |
447 | 447 | ||
448 | /*! | 448 | /*! |
449 | Explicitly hide the current input method. | 449 | Explicitly hide the current input method. |
450 | 450 | ||
451 | The current input method is still indicated in the taskbar, but no | 451 | The current input method is still indicated in the taskbar, but no |
452 | longer takes up screen space, and can no longer be interacted with. | 452 | longer takes up screen space, and can no longer be interacted with. |
453 | 453 | ||
454 | \sa showInputMethod() | 454 | \sa showInputMethod() |
455 | */ | 455 | */ |
@@ -500,221 +500,221 @@ void Global::setBuiltinCommands( Command* list ) | |||
500 | while ( builtin[count].file ) | 500 | while ( builtin[count].file ) |
501 | count++; | 501 | count++; |
502 | 502 | ||
503 | running = new QGuardedPtr<QWidget> [ count ]; | 503 | running = new QGuardedPtr<QWidget> [ count ]; |
504 | } | 504 | } |
505 | 505 | ||
506 | /*! | 506 | /*! |
507 | \internal | 507 | \internal |
508 | */ | 508 | */ |
509 | void Global::setDocument( QWidget* receiver, const QString& document ) | 509 | void Global::setDocument( QWidget* receiver, const QString& document ) |
510 | { | 510 | { |
511 | Emitter emitter(receiver,document); | 511 | Emitter emitter(receiver,document); |
512 | } | 512 | } |
513 | 513 | ||
514 | /*! | 514 | /*! |
515 | \internal | 515 | \internal |
516 | */ | 516 | */ |
517 | bool Global::terminateBuiltin( const QString& n ) | 517 | bool Global::terminateBuiltin( const QString& n ) |
518 | { | 518 | { |
519 | if (!builtin) | 519 | if (!builtin) |
520 | return FALSE; | 520 | return FALSE; |
521 | for (int i = 0; builtin[i].file; i++) { | 521 | for (int i = 0; builtin[i].file; i++) { |
522 | if ( builtin[i].file == n ) { | 522 | if ( builtin[i].file == n ) { |
523 | delete running[i]; | 523 | delete running[i]; |
524 | return TRUE; | 524 | return TRUE; |
525 | } | 525 | } |
526 | } | 526 | } |
527 | return FALSE; | 527 | return FALSE; |
528 | } | 528 | } |
529 | 529 | ||
530 | /*! | 530 | /*! |
531 | \internal | 531 | \internal |
532 | */ | 532 | */ |
533 | void Global::terminate( const AppLnk* app ) | 533 | void Global::terminate( const AppLnk* app ) |
534 | { | 534 | { |
535 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this | 535 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this |
536 | 536 | ||
537 | #ifndef QT_NO_COP | 537 | #ifndef QT_NO_COP |
538 | QCString channel = "QPE/Application/" + app->exec().utf8(); | 538 | QCString channel = "QPE/Application/" + app->exec().utf8(); |
539 | if ( QCopChannel::isRegistered(channel) ) { | 539 | if ( QCopChannel::isRegistered(channel) ) { |
540 | QCopEnvelope e(channel, "quit()"); | 540 | QCopEnvelope e(channel, "quit()"); |
541 | } | 541 | } |
542 | #endif | 542 | #endif |
543 | } | 543 | } |
544 | 544 | ||
545 | /*! | 545 | /*! |
546 | Low-level function to run command \a c. | 546 | Low-level function to run command \a c. |
547 | 547 | ||
548 | \warning Do not use this function. Use execute instead. | 548 | \warning Do not use this function. Use execute instead. |
549 | 549 | ||
550 | \sa execute() | 550 | \sa execute() |
551 | */ | 551 | */ |
552 | void Global::invoke(const QString &c) | 552 | void Global::invoke(const QString &c) |
553 | { | 553 | { |
554 | // Convert the command line in to a list of arguments | 554 | // Convert the command line in to a list of arguments |
555 | QStringList list = QStringList::split(QRegExp(" *"),c); | 555 | QStringList list = QStringList::split(QRegExp(" *"),c); |
556 | 556 | ||
557 | #if !defined(QT_NO_COP) | 557 | #if !defined(QT_NO_COP) |
558 | QString ap=list[0]; | 558 | QString ap=list[0]; |
559 | // see if the application is already running | 559 | // see if the application is already running |
560 | // XXX should lock file /tmp/qcop-msg-ap | 560 | // XXX should lock file /tmp/qcop-msg-ap |
561 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { | 561 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { |
562 | // If the channel is already register, the app is already running, so show it. | 562 | // If the channel is already register, the app is already running, so show it. |
563 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | 563 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } |
564 | 564 | ||
565 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 565 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
566 | e << ap; | 566 | e << ap; |
567 | return; | 567 | return; |
568 | } | 568 | } |
569 | // XXX should unlock file /tmp/qcop-msg-ap | 569 | // XXX should unlock file /tmp/qcop-msg-ap |
570 | //see if it is being started | 570 | //see if it is being started |
571 | if ( StartingAppList::isStarting( ap ) ) { | 571 | if ( StartingAppList::isStarting( ap ) ) { |
572 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 572 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
573 | e << ap; | 573 | e << ap; |
574 | return; | 574 | return; |
575 | } | 575 | } |
576 | 576 | ||
577 | #endif | 577 | #endif |
578 | 578 | ||
579 | #ifdef QT_NO_QWS_MULTIPROCESS | 579 | #ifdef QT_NO_QWS_MULTIPROCESS |
580 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); | 580 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); |
581 | #else | 581 | #else |
582 | 582 | ||
583 | QStrList slist; | 583 | QStrList slist; |
584 | unsigned int j; | 584 | unsigned int j; |
585 | for ( j = 0; j < list.count(); j++ ) | 585 | for ( j = 0; j < list.count(); j++ ) |
586 | slist.append( list[j].utf8() ); | 586 | slist.append( list[j].utf8() ); |
587 | 587 | ||
588 | const char **args = new (const char *)[slist.count() + 1]; | 588 | const char **args = new (const char *)[slist.count() + 1]; |
589 | for ( j = 0; j < slist.count(); j++ ) | 589 | for ( j = 0; j < slist.count(); j++ ) |
590 | args[j] = slist.at(j); | 590 | args[j] = slist.at(j); |
591 | args[j] = NULL; | 591 | args[j] = NULL; |
592 | 592 | ||
593 | #if !defined(QT_NO_COP) | 593 | #if !defined(QT_NO_COP) |
594 | // an attempt to show a wait... | 594 | // an attempt to show a wait... |
595 | // more logic should be used, but this will be fine for the moment... | 595 | // more logic should be used, but this will be fine for the moment... |
596 | QCopEnvelope ( "QPE/System", "busy()" ); | 596 | QCopEnvelope ( "QPE/System", "busy()" ); |
597 | #endif | 597 | #endif |
598 | 598 | ||
599 | #ifdef HAVE_QUICKEXEC | 599 | #ifdef HAVE_QUICKEXEC |
600 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; | 600 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; |
601 | qDebug("libfile = %s", libexe.latin1() ); | 601 | qDebug("libfile = %s", libexe.latin1() ); |
602 | if ( QFile::exists( libexe ) ) { | 602 | if ( QFile::exists( libexe ) ) { |
603 | qDebug("calling quickexec %s", libexe.latin1() ); | 603 | qDebug("calling quickexec %s", libexe.latin1() ); |
604 | quickexecv( libexe.utf8().data(), (const char **)args ); | 604 | quickexecv( libexe.utf8().data(), (const char **)args ); |
605 | } else | 605 | } else |
606 | #endif | 606 | #endif |
607 | { | 607 | { |
608 | bool success = false; | 608 | bool success = false; |
609 | int pfd [2]; | 609 | int pfd [2]; |
610 | if ( ::pipe ( pfd ) < 0 ) | 610 | if ( ::pipe ( pfd ) < 0 ) |
611 | pfd [0] = pfd [1] = -1; | 611 | pfd [0] = pfd [1] = -1; |
612 | 612 | ||
613 | pid_t pid = ::fork ( ); | 613 | pid_t pid = ::fork ( ); |
614 | 614 | ||
615 | if ( pid == 0 ) { // child | 615 | if ( pid == 0 ) { // child |
616 | for ( int fd = 3; fd < 100; fd++ ) { | 616 | for ( int fd = 3; fd < 100; fd++ ) { |
617 | if ( fd != pfd [1] ) | 617 | if ( fd != pfd [1] ) |
618 | ::close ( fd ); | 618 | ::close ( fd ); |
619 | } | 619 | } |
620 | ::setpgid ( ::getpid ( ), ::getppid ( )); | 620 | ::setpgid ( ::getpid ( ), ::getppid ( )); |
621 | 621 | ||
622 | // Closing of fd[1] indicates that the execvp succeeded! | 622 | // Closing of fd[1] indicates that the execvp succeeded! |
623 | if ( pfd [1] >= 0 ) | 623 | if ( pfd [1] >= 0 ) |
624 | ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC ); | 624 | ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC ); |
625 | 625 | ||
626 | // Try bindir first, so that foo/bar works too | 626 | // Try bindir first, so that foo/bar works too |
627 | ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); | 627 | ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); |
628 | ::execvp ( args [0], (char * const *) args ); | 628 | ::execvp ( args [0], (char * const *) args ); |
629 | 629 | ||
630 | char resultByte = 1; | 630 | char resultByte = 1; |
631 | if ( pfd [1] >= 0 ) | 631 | if ( pfd [1] >= 0 ) |
632 | ::write ( pfd [1], &resultByte, 1 ); | 632 | ::write ( pfd [1], &resultByte, 1 ); |
633 | ::_exit ( -1 ); | 633 | ::_exit ( -1 ); |
634 | } | 634 | } |
635 | else if ( pid > 0 ) { | 635 | else if ( pid > 0 ) { |
636 | success = true; | 636 | success = true; |
637 | 637 | ||
638 | if ( pfd [1] >= 0 ) | 638 | if ( pfd [1] >= 0 ) |
639 | ::close ( pfd [1] ); | 639 | ::close ( pfd [1] ); |
640 | if ( pfd [0] >= 0 ) { | 640 | if ( pfd [0] >= 0 ) { |
641 | while ( true ) { | 641 | while ( true ) { |
642 | char resultByte; | 642 | char resultByte; |
643 | int n = ::read ( pfd [0], &resultByte, 1 ); | 643 | int n = ::read ( pfd [0], &resultByte, 1 ); |
644 | if ( n == 1 ) { | 644 | if ( n == 1 ) { |
645 | success = false; | 645 | success = false; |
646 | break; | 646 | break; |
647 | } | 647 | } |
648 | if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) | 648 | if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) |
649 | continue; | 649 | continue; |
650 | 650 | ||
651 | break; // success | 651 | break; // success |
652 | } | 652 | } |
653 | ::close ( pfd [0] ); | 653 | ::close ( pfd [0] ); |
654 | } | 654 | } |
655 | } | 655 | } |
656 | if ( success ) | 656 | if ( success ) |
657 | StartingAppList::add( list[0] ); | 657 | StartingAppList::add( list[0] ); |
658 | else | 658 | else |
659 | QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 ); | 659 | QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 ); |
660 | } | 660 | } |
661 | #endif //QT_NO_QWS_MULTIPROCESS | 661 | #endif //QT_NO_QWS_MULTIPROCESS |
662 | } | 662 | } |
663 | 663 | ||
664 | 664 | ||
665 | /*! | 665 | /*! |
666 | Executes the application identfied by \a c, passing \a | 666 | Executes the application identfied by \a c, passing \a |
667 | document if it isn't null. | 667 | document if it isn't null. |
668 | 668 | ||
669 | Note that a better approach might be to send a QCop message to the | 669 | Note that a better approach might be to send a QCop message to the |
670 | application's QPE/Application/\e{appname} channel. | 670 | application's QPE/Application/\e{appname} channel. |
671 | */ | 671 | */ |
672 | void Global::execute( const QString &c, const QString& document ) | 672 | void Global::execute( const QString &c, const QString& document ) |
673 | { | 673 | { |
674 | if ( qApp->type() != QApplication::GuiServer ) { | 674 | if ( qApp->type() != QApplication::GuiServer ) { |
675 | // ask the server to do the work | 675 | // ask the server to do the work |
676 | #if !defined(QT_NO_COP) | 676 | #if !defined(QT_NO_COP) |
677 | if ( document.isNull() ) { | 677 | if ( document.isNull() ) { |
678 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 678 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
679 | e << c; | 679 | e << c; |
680 | } else { | 680 | } else { |
681 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); | 681 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); |
682 | e << c << document; | 682 | e << c << document; |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | return; | 685 | return; |
686 | } | 686 | } |
687 | 687 | ||
688 | // Attempt to execute the app using a builtin class for the app first | 688 | // Attempt to execute the app using a builtin class for the app first |
689 | // else try and find it in the bin directory | 689 | // else try and find it in the bin directory |
690 | if (builtin) { | 690 | if (builtin) { |
691 | for (int i = 0; builtin[i].file; i++) { | 691 | for (int i = 0; builtin[i].file; i++) { |
692 | if ( builtin[i].file == c ) { | 692 | if ( builtin[i].file == c ) { |
693 | if ( running[i] ) { | 693 | if ( running[i] ) { |
694 | if ( !document.isNull() && builtin[i].documentary ) | 694 | if ( !document.isNull() && builtin[i].documentary ) |
695 | setDocument(running[i], document); | 695 | setDocument(running[i], document); |
696 | running[i]->raise(); | 696 | running[i]->raise(); |
697 | running[i]->show(); | 697 | running[i]->show(); |
698 | running[i]->setActiveWindow(); | 698 | running[i]->setActiveWindow(); |
699 | } else { | 699 | } else { |
700 | running[i] = builtin[i].func( builtin[i].maximized ); | 700 | running[i] = builtin[i].func( builtin[i].maximized ); |
701 | } | 701 | } |
702 | #ifndef QT_NO_COP | 702 | #ifndef QT_NO_COP |
703 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 703 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
704 | e << c; // that was quick ;-) | 704 | e << c; // that was quick ;-) |
705 | #endif | 705 | #endif |
706 | return; | 706 | return; |
707 | } | 707 | } |
708 | } | 708 | } |
709 | } | 709 | } |
710 | 710 | ||
711 | //Global::invoke(c, document); | 711 | //Global::invoke(c, document); |
712 | 712 | ||
713 | // Convert the command line in to a list of arguments | 713 | // Convert the command line in to a list of arguments |
714 | QStringList list = QStringList::split(QRegExp(" *"),c); | 714 | QStringList list = QStringList::split(QRegExp(" *"),c); |
715 | 715 | ||
716 | #if !defined(QT_NO_COP) | 716 | #if !defined(QT_NO_COP) |
717 | QString ap=list[0]; | 717 | QString ap=list[0]; |
718 | 718 | ||
719 | qDebug("executing %s", ap.latin1() ); | 719 | qDebug("executing %s", ap.latin1() ); |
720 | 720 | ||