summaryrefslogtreecommitdiff
path: root/core/launcher/applauncher.cpp
Unidiff
Diffstat (limited to 'core/launcher/applauncher.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/applauncher.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp
index 0db99dd..f161e98 100644
--- a/core/launcher/applauncher.cpp
+++ b/core/launcher/applauncher.cpp
@@ -18,25 +18,25 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef QTOPIA_INTERNAL_PRELOADACCESS 21#ifndef QTOPIA_INTERNAL_PRELOADACCESS
22#define QTOPIA_INTERNAL_PRELOADACCESS 22#define QTOPIA_INTERNAL_PRELOADACCESS
23#endif 23#endif
24#ifndef QTOPIA_INTERNAL_FILEOPERATIONS 24#ifndef QTOPIA_INTERNAL_FILEOPERATIONS
25#define QTOPIA_INTERNAL_FILEOPERATIONS 25#define QTOPIA_INTERNAL_FILEOPERATIONS
26#endif 26#endif
27#ifndef QTOPIA_PROGRAM_MONITOR 27#ifndef QTOPIA_PROGRAM_MONITOR
28#define QTOPIA_PROGRAM_MONITOR 28#define QTOPIA_PROGRAM_MONITOR
29#endif 29#endif
30#include <qtopia/global.h> 30#include <opie2/oglobal.h>
31 31
32#ifndef Q_OS_WIN32 32#ifndef Q_OS_WIN32
33#include <sys/stat.h> 33#include <sys/stat.h>
34#include <sys/wait.h> 34#include <sys/wait.h>
35#include <sys/file.h> 35#include <sys/file.h>
36#include <unistd.h> 36#include <unistd.h>
37#include <sys/time.h> 37#include <sys/time.h>
38#include <sys/resource.h> 38#include <sys/resource.h>
39#include <errno.h> 39#include <errno.h>
40#else 40#else
41#include <process.h> 41#include <process.h>
42#include <windows.h> 42#include <windows.h>
@@ -52,25 +52,24 @@
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qfile.h> 53#include <qfile.h>
54#include <qfileinfo.h> 54#include <qfileinfo.h>
55 55
56#include <qtopia/qcopenvelope_qws.h> 56#include <qtopia/qcopenvelope_qws.h>
57#include <qtopia/applnk.h> 57#include <qtopia/applnk.h>
58#include <qtopia/qpeapplication.h> 58#include <qtopia/qpeapplication.h>
59#include <qtopia/config.h> 59#include <qtopia/config.h>
60#include <qtopia/global.h> 60#include <qtopia/global.h>
61 61
62#include "applauncher.h" 62#include "applauncher.h"
63#include "documentlist.h" 63#include "documentlist.h"
64#include "launcherglobal.h"
65 64
66const int AppLauncher::RAISE_TIMEOUT_MS = 5000; 65const int AppLauncher::RAISE_TIMEOUT_MS = 5000;
67 66
68//--------------------------------------------------------------------------- 67//---------------------------------------------------------------------------
69 68
70static AppLauncher* appLauncherPtr; 69static AppLauncher* appLauncherPtr;
71 70
72const int appStopEventID = 1290; 71const int appStopEventID = 1290;
73 72
74class AppStoppedEvent : public QCustomEvent 73class AppStoppedEvent : public QCustomEvent
75{ 74{
76public: 75public:
@@ -395,25 +394,25 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus)
395 case SIGTRAP: sig = "SIGTRAP"; break; 394 case SIGTRAP: sig = "SIGTRAP"; break;
396 default: sig = QString("Unkown %1").arg(exitStatus); 395 default: sig = QString("Unkown %1").arg(exitStatus);
397 } 396 }
398 if ( preloadDisabled ) 397 if ( preloadDisabled )
399 sig += tr("<qt><p>Fast loading has been disabled for this application. Tap and hold the application icon to reenable it.</qt>"); 398 sig += tr("<qt><p>Fast loading has been disabled for this application. Tap and hold the application icon to reenable it.</qt>");
400 399
401 QString str = tr("<qt><b>%1</b> was terminated due to signal code %2</qt>").arg( app->name() ).arg( sig ); 400 QString str = tr("<qt><b>%1</b> was terminated due to signal code %2</qt>").arg( app->name() ).arg( sig );
402 QMessageBox::information(0, tr("Application terminated"), str ); 401 QMessageBox::information(0, tr("Application terminated"), str );
403 } else { 402 } else {
404 if ( exitStatus == 255 ) { //could not find app (because global returns -1) 403 if ( exitStatus == 255 ) { //could not find app (because global returns -1)
405 QMessageBox::information(0, tr("Application not found"), tr("<qt>Could not locate application <b>%1</b></qt>").arg( app->exec() ) ); 404 QMessageBox::information(0, tr("Application not found"), tr("<qt>Could not locate application <b>%1</b></qt>").arg( app->exec() ) );
406 } else { 405 } else {
407 QFileInfo fi(Opie::Global::tempDir() + "qcop-msg-" + appName); 406 QFileInfo fi(OGlobal::tempDirPath() + "qcop-msg-" + appName);
408 if ( fi.exists() && fi.size() ) { 407 if ( fi.exists() && fi.size() ) {
409 emit terminated(sigPid, appName); 408 emit terminated(sigPid, appName);
410 qWarning("Re executing obmitted for %s", appName.latin1() ); 409 qWarning("Re executing obmitted for %s", appName.latin1() );
411 // execute( appName, QString::null ); 410 // execute( appName, QString::null );
412 return; 411 return;
413 } 412 }
414 } 413 }
415 } 414 }
416 415
417#endif 416#endif
418 417
419 emit terminated(sigPid, appName); 418 emit terminated(sigPid, appName);
@@ -437,26 +436,26 @@ bool AppLauncher::isRunning(const QString &app)
437 return FALSE; 436 return FALSE;
438 } 437 }
439#endif 438#endif
440 return TRUE; 439 return TRUE;
441 } 440 }
442 } 441 }
443 442
444 return FALSE; 443 return FALSE;
445} 444}
446 445
447bool AppLauncher::executeBuiltin(const QString &c, const QString &document) 446bool AppLauncher::executeBuiltin(const QString &c, const QString &document)
448{ 447{
449 Global::Command* builtin = Opie::Global::builtinCommands(); 448 Global::Command* builtin = OGlobal::builtinCommands();
450 QGuardedPtr<QWidget> *running = Opie::Global::builtinRunning(); 449 QGuardedPtr<QWidget> *running = OGlobal::builtinRunning();
451 450
452 // Attempt to execute the app using a builtin class for the app 451 // Attempt to execute the app using a builtin class for the app
453 if (builtin) { 452 if (builtin) {
454 for (int i = 0; builtin[i].file; i++) { 453 for (int i = 0; builtin[i].file; i++) {
455 if ( builtin[i].file == c ) { 454 if ( builtin[i].file == c ) {
456 if ( running[i] ) { 455 if ( running[i] ) {
457 if ( !document.isNull() && builtin[i].documentary ) 456 if ( !document.isNull() && builtin[i].documentary )
458 Global::setDocument(running[i], document); 457 Global::setDocument(running[i], document);
459 running[i]->raise(); 458 running[i]->raise();
460 running[i]->show(); 459 running[i]->show();
461 running[i]->setActiveWindow(); 460 running[i]->setActiveWindow();
462 } else { 461 } else {
@@ -488,25 +487,25 @@ bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRais
488 qWarning("AppLauncher::execute"); 487 qWarning("AppLauncher::execute");
489 // Convert the command line in to a list of arguments 488 // Convert the command line in to a list of arguments
490 QStringList list = QStringList::split(QRegExp(" *"),c); 489 QStringList list = QStringList::split(QRegExp(" *"),c);
491 if ( !docParam.isEmpty() ) 490 if ( !docParam.isEmpty() )
492 list.append( docParam ); 491 list.append( docParam );
493 492
494 QString appName = list[0]; 493 QString appName = list[0];
495 if ( isRunning(appName) ) { 494 if ( isRunning(appName) ) {
496 QCString channel = "QPE/Application/"; 495 QCString channel = "QPE/Application/";
497 channel += appName.latin1(); 496 channel += appName.latin1();
498 497
499 // Need to lock it to avoid race conditions with QPEApplication::processQCopFile 498 // Need to lock it to avoid race conditions with QPEApplication::processQCopFile
500 QFile f(Opie::Global::tempDir() + "qcop-msg-" + appName); 499 QFile f(OGlobal::tempDirPath() + "qcop-msg-" + appName);
501 if ( !noRaise && f.open(IO_WriteOnly | IO_Append) ) { 500 if ( !noRaise && f.open(IO_WriteOnly | IO_Append) ) {
502#ifndef Q_OS_WIN32 501#ifndef Q_OS_WIN32
503 flock(f.handle(), LOCK_EX); 502 flock(f.handle(), LOCK_EX);
504#endif 503#endif
505 504
506 QDataStream ds(&f); 505 QDataStream ds(&f);
507 QByteArray b; 506 QByteArray b;
508 QDataStream bstream(b, IO_WriteOnly); 507 QDataStream bstream(b, IO_WriteOnly);
509 if ( !f.size() ) { 508 if ( !f.size() ) {
510 ds << channel << QCString("raise()") << b; 509 ds << channel << QCString("raise()") << b;
511 if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) { 510 if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) {
512 int id = startTimer(RAISE_TIMEOUT_MS); 511 int id = startTimer(RAISE_TIMEOUT_MS);