summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/applauncher.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp
index 08a3cb4..efbf426 100644
--- a/core/launcher/applauncher.cpp
+++ b/core/launcher/applauncher.cpp
@@ -390,194 +390,195 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus)
390 case SIGTRAP: sig = "SIGTRAP"; break; 390 case SIGTRAP: sig = "SIGTRAP"; break;
391 default: sig = QString("Unkown %1").arg(exitStatus); 391 default: sig = QString("Unkown %1").arg(exitStatus);
392 } 392 }
393 if ( preloadDisabled ) 393 if ( preloadDisabled )
394 sig += tr("<qt><p>Fast loading has been disabled for this application. Tap and hold the application icon to reenable it.</qt>"); 394 sig += tr("<qt><p>Fast loading has been disabled for this application. Tap and hold the application icon to reenable it.</qt>");
395 395
396 QString str = tr("<qt><b>%1</b> was terminated due to signal code %2</qt>").arg( app->name() ).arg( sig ); 396 QString str = tr("<qt><b>%1</b> was terminated due to signal code %2</qt>").arg( app->name() ).arg( sig );
397 QMessageBox::information(0, tr("Application terminated"), str ); 397 QMessageBox::information(0, tr("Application terminated"), str );
398 } else { 398 } else {
399 if ( exitStatus == 255 ) { //could not find app (because global returns -1) 399 if ( exitStatus == 255 ) { //could not find app (because global returns -1)
400 QMessageBox::information(0, tr("Application not found"), tr("<qt>Could not locate application <b>%1</b></qt>").arg( app->exec() ) ); 400 QMessageBox::information(0, tr("Application not found"), tr("<qt>Could not locate application <b>%1</b></qt>").arg( app->exec() ) );
401 } else { 401 } else {
402 QFileInfo fi(QString::fromLatin1("/tmp/qcop-msg-") + appName); 402 QFileInfo fi(QString::fromLatin1("/tmp/qcop-msg-") + appName);
403 if ( fi.exists() && fi.size() ) { 403 if ( fi.exists() && fi.size() ) {
404 emit terminated(sigPid, appName); 404 emit terminated(sigPid, appName);
405 qWarning("Re executing obmitted for %s", appName.latin1() ); 405 qWarning("Re executing obmitted for %s", appName.latin1() );
406 // execute( appName, QString::null ); 406 // execute( appName, QString::null );
407 return; 407 return;
408 } 408 }
409 } 409 }
410 } 410 }
411 411
412#endif 412#endif
413 413
414 emit terminated(sigPid, appName); 414 emit terminated(sigPid, appName);
415} 415}
416#else 416#else
417void AppLauncher::sigStopped(int sigPid, int sigStatus) 417void AppLauncher::sigStopped(int sigPid, int sigStatus)
418{ 418{
419 qDebug("Unhandled signal : AppLauncher::sigStopped(int sigPid, int sigStatus)"); 419 qDebug("Unhandled signal : AppLauncher::sigStopped(int sigPid, int sigStatus)");
420} 420}
421#endif // Q_OS_WIN32 421#endif // Q_OS_WIN32
422 422
423bool AppLauncher::isRunning(const QString &app) 423bool AppLauncher::isRunning(const QString &app)
424{ 424{
425 for (QMap<int,QString>::ConstIterator it = runningApps.begin(); it != runningApps.end(); ++it) { 425 for (QMap<int,QString>::ConstIterator it = runningApps.begin(); it != runningApps.end(); ++it) {
426 if ( *it == app ) { 426 if ( *it == app ) {
427#ifdef Q_OS_UNIX 427#ifdef Q_OS_UNIX
428 pid_t t = ::__getpgid( it.key() ); 428 pid_t t = ::__getpgid( it.key() );
429 if ( t == -1 ) { 429 if ( t == -1 ) {
430 qDebug("appLauncher bug, %s believed running, but pid %d is not existing", app.data(), it.key() ); 430 qDebug("appLauncher bug, %s believed running, but pid %d is not existing", app.data(), it.key() );
431 runningApps.remove( it.key() ); 431 runningApps.remove( it.key() );
432 return FALSE; 432 return FALSE;
433 } 433 }
434#endif 434#endif
435 return TRUE; 435 return TRUE;
436 } 436 }
437 } 437 }
438 438
439 return FALSE; 439 return FALSE;
440} 440}
441 441
442bool AppLauncher::executeBuiltin(const QString &c, const QString &document) 442bool AppLauncher::executeBuiltin(const QString &c, const QString &document)
443{ 443{
444 Global::Command* builtin = OGlobal::builtinCommands(); 444 Global::Command* builtin = OGlobal::builtinCommands();
445 QGuardedPtr<QWidget> *running = OGlobal::builtinRunning(); 445 QGuardedPtr<QWidget> *running = OGlobal::builtinRunning();
446 446
447 // Attempt to execute the app using a builtin class for the app 447 // Attempt to execute the app using a builtin class for the app
448 if (builtin) { 448 if (builtin) {
449 for (int i = 0; builtin[i].file; i++) { 449 for (int i = 0; builtin[i].file; i++) {
450 if ( builtin[i].file == c ) { 450 if ( builtin[i].file == c ) {
451 if ( running[i] ) { 451 if ( running[i] ) {
452 if ( !document.isNull() && builtin[i].documentary ) 452 if ( !document.isNull() && builtin[i].documentary )
453 Global::setDocument(running[i], document); 453 Global::setDocument(running[i], document);
454 running[i]->raise(); 454 running[i]->raise();
455 running[i]->show(); 455 running[i]->show();
456 running[i]->setActiveWindow(); 456 running[i]->setActiveWindow();
457 } else { 457 } else {
458 running[i] = builtin[i].func( builtin[i].maximized ); 458 running[i] = builtin[i].func( builtin[i].maximized );
459 } 459 }
460#ifndef QT_NO_COP 460#ifndef QT_NO_COP
461 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 461 QCopEnvelope e("QPE/System", "notBusy(QString)" );
462 e << c; // that was quick ;-) 462 e << c; // that was quick ;-)
463#endif 463#endif
464 return TRUE; 464 return TRUE;
465 } 465 }
466 } 466 }
467 } 467 }
468 468
469 // Convert the command line in to a list of arguments 469 // Convert the command line in to a list of arguments
470 QStringList list = QStringList::split(QRegExp(" *"),c); 470 QStringList list = QStringList::split(QRegExp(" *"),c);
471 QString ap=list[0]; 471 QString ap=list[0];
472 472
473 if ( ap == "suspend" ) { // No tr 473 if ( ap == "suspend" ) { // No tr
474 QWSServer::processKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 474 QWSServer::processKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
475 return TRUE; 475 return TRUE;
476 } 476 }
477 477
478 return FALSE; 478 return FALSE;
479} 479}
480 480
481bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRaise) 481bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRaise)
482{ 482{
483 qWarning("AppLauncher::execute '%s' '%s'", (const char*) c, (const char*) docParam ); 483 qWarning("AppLauncher::execute '%s' '%s'", (const char*) c, (const char*) docParam );
484 // Convert the command line in to a list of arguments 484 // Convert the command line in to a list of arguments
485 QStringList list = QStringList::split(QRegExp(" *"),c); 485 QStringList list = QStringList::split(QRegExp(" *"),c);
486 if ( !docParam.isEmpty() ) 486 QStringList arglist = QStringList::split(QRegExp(" *"),docParam);
487 list.append( docParam ); 487 for ( QStringList::Iterator it = arglist.begin(); it != arglist.end(); ++it )
488 list.append( *it );
488 489
489 QString appName = list[0]; 490 QString appName = list[0];
490 if ( isRunning(appName) ) { 491 if ( isRunning(appName) ) {
491 QCString channel = "QPE/Application/"; 492 QCString channel = "QPE/Application/";
492 channel += appName.latin1(); 493 channel += appName.latin1();
493 494
494 // Need to lock it to avoid race conditions with QPEApplication::processQCopFile 495 // Need to lock it to avoid race conditions with QPEApplication::processQCopFile
495 QFile f(QString::fromLatin1("/tmp/qcop-msg-") + appName); 496 QFile f(QString::fromLatin1("/tmp/qcop-msg-") + appName);
496 if ( !noRaise && f.open(IO_WriteOnly | IO_Append) ) { 497 if ( !noRaise && f.open(IO_WriteOnly | IO_Append) ) {
497#ifndef Q_OS_WIN32 498#ifndef Q_OS_WIN32
498 flock(f.handle(), LOCK_EX); 499 flock(f.handle(), LOCK_EX);
499#endif 500#endif
500 501
501 QDataStream ds(&f); 502 QDataStream ds(&f);
502 QByteArray b; 503 QByteArray b;
503 QDataStream bstream(b, IO_WriteOnly); 504 QDataStream bstream(b, IO_WriteOnly);
504 if ( !f.size() ) { 505 if ( !f.size() ) {
505 ds << channel << QCString("raise()") << b; 506 ds << channel << QCString("raise()") << b;
506 if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) { 507 if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) {
507 int id = startTimer(RAISE_TIMEOUT_MS); 508 int id = startTimer(RAISE_TIMEOUT_MS);
508 waitingHeartbeat.insert( appName, id ); 509 waitingHeartbeat.insert( appName, id );
509 } 510 }
510 } 511 }
511 if ( !docParam.isEmpty() ) { 512 if ( !docParam.isEmpty() ) {
512 bstream << docParam; 513 bstream << docParam;
513 ds << channel << QCString("setDocument(QString)") << b; 514 ds << channel << QCString("setDocument(QString)") << b;
514 } 515 }
515 516
516 f.flush(); 517 f.flush();
517#ifndef Q_OS_WIN32 518#ifndef Q_OS_WIN32
518 flock(f.handle(), LOCK_UN); 519 flock(f.handle(), LOCK_UN);
519#endif 520#endif
520 f.close(); 521 f.close();
521 } 522 }
522 if ( QCopChannel::isRegistered(channel) ) // avoid unnecessary warnings 523 if ( QCopChannel::isRegistered(channel) ) // avoid unnecessary warnings
523 QCopChannel::send(channel,"QPEProcessQCop()"); 524 QCopChannel::send(channel,"QPEProcessQCop()");
524 525
525 return TRUE; 526 return TRUE;
526 } 527 }
527 528
528#ifdef QT_NO_QWS_MULTIPROCESS 529#ifdef QT_NO_QWS_MULTIPROCESS
529 QMessageBox::warning( 0, tr("Error"), tr("<qt>Could not find the application %1</qt>").arg(c), 530 QMessageBox::warning( 0, tr("Error"), tr("<qt>Could not find the application %1</qt>").arg(c),
530 tr("OK"), 0, 0, 0, 1 ); 531 tr("OK"), 0, 0, 0, 1 );
531#else 532#else
532 533
533 QStrList slist; 534 QStrList slist;
534 unsigned j; 535 unsigned j;
535 for ( j = 0; j < list.count(); j++ ) 536 for ( j = 0; j < list.count(); j++ )
536 slist.append( list[j].utf8() ); 537 slist.append( list[j].utf8() );
537 538
538 const char **args = new const char *[slist.count() + 1]; 539 const char **args = new const char *[slist.count() + 1];
539 for ( j = 0; j < slist.count(); j++ ) 540 for ( j = 0; j < slist.count(); j++ )
540 args[j] = slist.at(j); 541 args[j] = slist.at(j);
541 args[j] = NULL; 542 args[j] = NULL;
542 543
543#ifndef Q_OS_WIN32 544#ifndef Q_OS_WIN32
544#ifdef Q_OS_MACX 545#ifdef Q_OS_MACX
545 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) { 546 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) {
546#else 547#else
547 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) { 548 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) {
548#endif /* Q_OS_MACX */ 549#endif /* Q_OS_MACX */
549 qDebug( "Quick launching: %s", args[0] ); 550 qDebug( "Quick launching: %s", args[0] );
550 if ( getuid() == 0 ) 551 if ( getuid() == 0 )
551 setpriority( PRIO_PROCESS, qlPid, 0 ); 552 setpriority( PRIO_PROCESS, qlPid, 0 );
552 QCString qlch("QPE/QuickLauncher-"); 553 QCString qlch("QPE/QuickLauncher-");
553 qlch += QString::number(qlPid); 554 qlch += QString::number(qlPid);
554 QCopEnvelope env( qlch, "execute(QStrList)" ); 555 QCopEnvelope env( qlch, "execute(QStrList)" );
555 env << slist; 556 env << slist;
556 runningApps[qlPid] = QString(args[0]); 557 runningApps[qlPid] = QString(args[0]);
557 emit launched(qlPid, QString(args[0])); 558 emit launched(qlPid, QString(args[0]));
558 QCopEnvelope e("QPE/System", "busy()"); 559 QCopEnvelope e("QPE/System", "busy()");
559 qlPid = 0; 560 qlPid = 0;
560 qlReady = FALSE; 561 qlReady = FALSE;
561 QTimer::singleShot( getuid() == 0 ? 800 : 1500, this, SLOT(createQuickLauncher()) ); 562 QTimer::singleShot( getuid() == 0 ? 800 : 1500, this, SLOT(createQuickLauncher()) );
562 } else { 563 } else {
563 int pid = ::vfork(); 564 int pid = ::vfork();
564 if ( !pid ) { 565 if ( !pid ) {
565 for ( int fd = 3; fd < 100; fd++ ) 566 for ( int fd = 3; fd < 100; fd++ )
566 ::close( fd ); 567 ::close( fd );
567 ::setpgid( ::getpid(), ::getppid() ); 568 ::setpgid( ::getpid(), ::getppid() );
568 // Try bindir first, so that foo/bar works too 569 // Try bindir first, so that foo/bar works too
569 ::execv( QPEApplication::qpeDir()+"bin/"+args[0], (char * const *)args ); 570 ::execv( QPEApplication::qpeDir()+"bin/"+args[0], (char * const *)args );
570 ::execvp( args[0], (char * const *)args ); 571 ::execvp( args[0], (char * const *)args );
571 _exit( -1 ); 572 _exit( -1 );
572 } 573 }
573 574
574 runningApps[pid] = QString(args[0]); 575 runningApps[pid] = QString(args[0]);
575 emit launched(pid, QString(args[0])); 576 emit launched(pid, QString(args[0]));
576 QCopEnvelope e("QPE/System", "busy()"); 577 QCopEnvelope e("QPE/System", "busy()");
577 } 578 }
578#else 579#else
579 QProcess *proc = new QProcess(this); 580 QProcess *proc = new QProcess(this);
580 if (proc){ 581 if (proc){
581 for (int i=0; i < slist.count(); i++) 582 for (int i=0; i < slist.count(); i++)
582 proc->addArgument(args[i]); 583 proc->addArgument(args[i]);
583 connect(proc, SIGNAL(processExited()), this, SLOT(processExited())); 584 connect(proc, SIGNAL(processExited()), this, SLOT(processExited()));