summaryrefslogtreecommitdiff
path: root/library/global.cpp
Unidiff
Diffstat (limited to 'library/global.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/library/global.cpp b/library/global.cpp
index 90954fe..05d23ac 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -543,129 +543,133 @@ void Global::terminate( const AppLnk* app )
543 } 543 }
544#endif 544#endif
545} 545}
546 546
547/*! 547/*!
548 Low-level function to run command \a c. 548 Low-level function to run command \a c.
549 549
550 \warning Do not use this function. Use execute instead. 550 \warning Do not use this function. Use execute instead.
551 551
552 \sa execute() 552 \sa execute()
553*/ 553*/
554void Global::invoke(const QString &c) 554void Global::invoke(const QString &c)
555{ 555{
556 // Convert the command line in to a list of arguments 556 // Convert the command line in to a list of arguments
557 QStringList list = QStringList::split(QRegExp(" *"),c); 557 QStringList list = QStringList::split(QRegExp(" *"),c);
558 558
559#if !defined(QT_NO_COP) 559#if !defined(QT_NO_COP)
560 QString ap=list[0]; 560 QString ap=list[0];
561 // see if the application is already running 561 // see if the application is already running
562 // XXX should lock file /tmp/qcop-msg-ap 562 // XXX should lock file /tmp/qcop-msg-ap
563 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { 563 if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) {
564 // If the channel is already register, the app is already running, so show it. 564 // If the channel is already register, the app is already running, so show it.
565 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } 565 { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); }
566 566
567 //QCopEnvelope e("QPE/System", "notBusy(QString)" ); 567 //QCopEnvelope e("QPE/System", "notBusy(QString)" );
568 //e << ap; 568 //e << ap;
569 return; 569 return;
570 } 570 }
571 // XXX should unlock file /tmp/qcop-msg-ap 571 // XXX should unlock file /tmp/qcop-msg-ap
572 //see if it is being started 572 //see if it is being started
573 if ( StartingAppList::isStarting( ap ) ) { 573 if ( StartingAppList::isStarting( ap ) ) {
574 // FIXME take it out for now, since it leads to a much to short showing of wait if 574 // FIXME take it out for now, since it leads to a much to short showing of wait if
575 // some entry is clicked. 575 // some entry is clicked.
576 // Real cause is that ::execute is called twice for document tab. But it would need some larger changes 576 // Real cause is that ::execute is called twice for document tab. But it would need some larger changes
577 // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there 577 // to fix that, and with future syncs with qtopia 1.6 it will change anyway big time since somebody there
578 // had the idea that an apploader belongs to the launcher ... 578 // had the idea that an apploader belongs to the launcher ...
579 //QCopEnvelope e("QPE/System", "notBusy(QString)" ); 579 //QCopEnvelope e("QPE/System", "notBusy(QString)" );
580 //e << ap; 580 //e << ap;
581 return; 581 return;
582 } 582 }
583 583
584#endif 584#endif
585 585
586#ifdef QT_NO_QWS_MULTIPROCESS 586#ifdef QT_NO_QWS_MULTIPROCESS
587 QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); 587 QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 );
588#else 588#else
589 589
590 QStrList slist; 590 QStrList slist;
591 unsigned int j; 591 unsigned int j;
592 for ( j = 0; j < list.count(); j++ ) 592 for ( j = 0; j < list.count(); j++ )
593 slist.append( list[j].utf8() ); 593 slist.append( list[j].utf8() );
594 594
595 const char **args = new (const char *)[slist.count() + 1]; 595 const char **args = new (const char *)[slist.count() + 1];
596 for ( j = 0; j < slist.count(); j++ ) 596 for ( j = 0; j < slist.count(); j++ )
597 args[j] = slist.at(j); 597 args[j] = slist.at(j);
598 args[j] = NULL; 598 args[j] = NULL;
599 599
600#if !defined(QT_NO_COP) 600#if !defined(QT_NO_COP)
601 // an attempt to show a wait... 601 // an attempt to show a wait...
602 // more logic should be used, but this will be fine for the moment... 602 // more logic should be used, but this will be fine for the moment...
603 QCopEnvelope ( "QPE/System", "busy()" ); 603 QCopEnvelope ( "QPE/System", "busy()" );
604#endif 604#endif
605 605
606#ifdef HAVE_QUICKEXEC 606#ifdef HAVE_QUICKEXEC
607#ifdef Q_OS_MACX
608 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".dylib";
609#else
607 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; 610 QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so";
611#endif
608 qDebug("libfile = %s", libexe.latin1() ); 612 qDebug("libfile = %s", libexe.latin1() );
609 if ( QFile::exists( libexe ) ) { 613 if ( QFile::exists( libexe ) ) {
610 qDebug("calling quickexec %s", libexe.latin1() ); 614 qDebug("calling quickexec %s", libexe.latin1() );
611 quickexecv( libexe.utf8().data(), (const char **)args ); 615 quickexecv( libexe.utf8().data(), (const char **)args );
612 } else 616 } else
613#endif 617#endif
614 { 618 {
615 bool success = false; 619 bool success = false;
616 int pfd [2]; 620 int pfd [2];
617 if ( ::pipe ( pfd ) < 0 ) 621 if ( ::pipe ( pfd ) < 0 )
618 pfd [0] = pfd [1] = -1; 622 pfd [0] = pfd [1] = -1;
619 623
620 pid_t pid = ::fork ( ); 624 pid_t pid = ::fork ( );
621 625
622 if ( pid == 0 ) { // child 626 if ( pid == 0 ) { // child
623 for ( int fd = 3; fd < 100; fd++ ) { 627 for ( int fd = 3; fd < 100; fd++ ) {
624 if ( fd != pfd [1] ) 628 if ( fd != pfd [1] )
625 ::close ( fd ); 629 ::close ( fd );
626 } 630 }
627 ::setpgid ( ::getpid ( ), ::getppid ( )); 631 ::setpgid ( ::getpid ( ), ::getppid ( ));
628 632
629 // Closing of fd[1] indicates that the execvp succeeded! 633 // Closing of fd[1] indicates that the execvp succeeded!
630 if ( pfd [1] >= 0 ) 634 if ( pfd [1] >= 0 )
631 ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC ); 635 ::fcntl ( pfd [1], F_SETFD, FD_CLOEXEC );
632 636
633 // Try bindir first, so that foo/bar works too 637 // Try bindir first, so that foo/bar works too
634 ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); 638 ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args );
635 ::execvp ( args [0], (char * const *) args ); 639 ::execvp ( args [0], (char * const *) args );
636 640
637 char resultByte = 1; 641 char resultByte = 1;
638 if ( pfd [1] >= 0 ) 642 if ( pfd [1] >= 0 )
639 ::write ( pfd [1], &resultByte, 1 ); 643 ::write ( pfd [1], &resultByte, 1 );
640 ::_exit ( -1 ); 644 ::_exit ( -1 );
641 } 645 }
642 else if ( pid > 0 ) { 646 else if ( pid > 0 ) {
643 success = true; 647 success = true;
644 648
645 if ( pfd [1] >= 0 ) 649 if ( pfd [1] >= 0 )
646 ::close ( pfd [1] ); 650 ::close ( pfd [1] );
647 if ( pfd [0] >= 0 ) { 651 if ( pfd [0] >= 0 ) {
648 while ( true ) { 652 while ( true ) {
649 char resultByte; 653 char resultByte;
650 int n = ::read ( pfd [0], &resultByte, 1 ); 654 int n = ::read ( pfd [0], &resultByte, 1 );
651 if ( n == 1 ) { 655 if ( n == 1 ) {
652 success = false; 656 success = false;
653 break; 657 break;
654 } 658 }
655 if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) 659 if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR )))
656 continue; 660 continue;
657 661
658 break; // success 662 break; // success
659 } 663 }
660 ::close ( pfd [0] ); 664 ::close ( pfd [0] );
661 } 665 }
662 } 666 }
663 if ( success ) 667 if ( success )
664 StartingAppList::add( list[0] ); 668 StartingAppList::add( list[0] );
665 else 669 else
666 QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 ); 670 QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 );
667 } 671 }
668#endif //QT_NO_QWS_MULTIPROCESS 672#endif //QT_NO_QWS_MULTIPROCESS
669} 673}
670 674
671 675