author | zecke <zecke> | 2003-08-25 14:46:43 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-08-25 14:46:43 (UTC) |
commit | 292b097e7db25dd231381c5b09307a1fbe81a492 (patch) (unidiff) | |
tree | b103c6c5e15e784dc07af55539672a72559da821 /library/global.cpp | |
parent | 5f292b6e4fc0f4ee8e4bced9a916f6bdce864b6b (diff) | |
download | opie-292b097e7db25dd231381c5b09307a1fbe81a492.zip opie-292b097e7db25dd231381c5b09307a1fbe81a492.tar.gz opie-292b097e7db25dd231381c5b09307a1fbe81a492.tar.bz2 |
-instead of defining for an board we define now what this
boards need
QPE_NEED_CALIBRATE
-launcher is the only one executin application
-allow processing of QCOPfiles after start ( qpeapplication )
-qcopenvelope no longer calls Global::execute
-rw-r--r-- | library/global.cpp | 59 |
1 files changed, 7 insertions, 52 deletions
diff --git a/library/global.cpp b/library/global.cpp index 189b830..5c89430 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -631,152 +631,107 @@ void Global::invoke(const QString &c) | |||
631 | // Try bindir first, so that foo/bar works too | 631 | // Try bindir first, so that foo/bar works too |
632 | ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); | 632 | ::execv ( qpeDir ( ) + "/bin/" + args [0], (char * const *) args ); |
633 | ::execvp ( args [0], (char * const *) args ); | 633 | ::execvp ( args [0], (char * const *) args ); |
634 | 634 | ||
635 | char resultByte = 1; | 635 | char resultByte = 1; |
636 | if ( pfd [1] >= 0 ) | 636 | if ( pfd [1] >= 0 ) |
637 | ::write ( pfd [1], &resultByte, 1 ); | 637 | ::write ( pfd [1], &resultByte, 1 ); |
638 | ::_exit ( -1 ); | 638 | ::_exit ( -1 ); |
639 | } | 639 | } |
640 | else if ( pid > 0 ) { | 640 | else if ( pid > 0 ) { |
641 | success = true; | 641 | success = true; |
642 | 642 | ||
643 | if ( pfd [1] >= 0 ) | 643 | if ( pfd [1] >= 0 ) |
644 | ::close ( pfd [1] ); | 644 | ::close ( pfd [1] ); |
645 | if ( pfd [0] >= 0 ) { | 645 | if ( pfd [0] >= 0 ) { |
646 | while ( true ) { | 646 | while ( true ) { |
647 | char resultByte; | 647 | char resultByte; |
648 | int n = ::read ( pfd [0], &resultByte, 1 ); | 648 | int n = ::read ( pfd [0], &resultByte, 1 ); |
649 | if ( n == 1 ) { | 649 | if ( n == 1 ) { |
650 | success = false; | 650 | success = false; |
651 | break; | 651 | break; |
652 | } | 652 | } |
653 | if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) | 653 | if (( n == -1 ) && (( errno == ECHILD ) || ( errno == EINTR ))) |
654 | continue; | 654 | continue; |
655 | 655 | ||
656 | break; // success | 656 | break; // success |
657 | } | 657 | } |
658 | ::close ( pfd [0] ); | 658 | ::close ( pfd [0] ); |
659 | } | 659 | } |
660 | } | 660 | } |
661 | if ( success ) | 661 | if ( success ) |
662 | StartingAppList::add( list[0] ); | 662 | StartingAppList::add( list[0] ); |
663 | else | 663 | else |
664 | QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 ); | 664 | QMessageBox::warning( 0, "Error", "Could not start the application " + c, "Ok", 0, 0, 0, 1 ); |
665 | } | 665 | } |
666 | #endif //QT_NO_QWS_MULTIPROCESS | 666 | #endif //QT_NO_QWS_MULTIPROCESS |
667 | } | 667 | } |
668 | 668 | ||
669 | 669 | ||
670 | /*! | 670 | /*! |
671 | Executes the application identfied by \a c, passing \a | 671 | Executes the application identfied by \a c, passing \a |
672 | document if it isn't null. | 672 | document if it isn't null. |
673 | 673 | ||
674 | Note that a better approach might be to send a QCop message to the | 674 | Note that a better approach might be to send a QCop message to the |
675 | application's QPE/Application/\e{appname} channel. | 675 | application's QPE/Application/\e{appname} channel. |
676 | */ | 676 | */ |
677 | void Global::execute( const QString &c, const QString& document ) | 677 | void Global::execute( const QString &c, const QString& document ) |
678 | { | 678 | { |
679 | if ( qApp->type() != QApplication::GuiServer ) { | ||
680 | // ask the server to do the work | 679 | // ask the server to do the work |
681 | #if !defined(QT_NO_COP) | 680 | #if !defined(QT_NO_COP) |
682 | if ( document.isNull() ) { | 681 | if ( document.isNull() ) { |
683 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 682 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
684 | e << c; | 683 | e << c; |
685 | } else { | 684 | } else { |
686 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); | 685 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); |
687 | e << c << document; | 686 | e << c << document; |
688 | } | ||
689 | #endif | ||
690 | return; | ||
691 | } | ||
692 | |||
693 | // Attempt to execute the app using a builtin class for the app first | ||
694 | // else try and find it in the bin directory | ||
695 | if (builtin) { | ||
696 | for (int i = 0; builtin[i].file; i++) { | ||
697 | if ( builtin[i].file == c ) { | ||
698 | if ( running[i] ) { | ||
699 | if ( !document.isNull() && builtin[i].documentary ) | ||
700 | setDocument(running[i], document); | ||
701 | running[i]->raise(); | ||
702 | running[i]->show(); | ||
703 | running[i]->setActiveWindow(); | ||
704 | } else { | ||
705 | running[i] = builtin[i].func( builtin[i].maximized ); | ||
706 | } | ||
707 | #ifndef QT_NO_COP | ||
708 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | ||
709 | e << c; // that was quick ;-) | ||
710 | #endif | ||
711 | return; | ||
712 | } | ||
713 | } | ||
714 | } | ||
715 | |||
716 | //Global::invoke(c, document); | ||
717 | |||
718 | // Convert the command line in to a list of arguments | ||
719 | QStringList list = QStringList::split(QRegExp(" *"),c); | ||
720 | |||
721 | #if !defined(QT_NO_COP) | ||
722 | QString ap=list[0]; | ||
723 | |||
724 | qDebug("executing %s", ap.latin1() ); | ||
725 | |||
726 | /* if need be, sending a qcop message will result in an invoke, see | ||
727 | preceeding function */ | ||
728 | invoke( ap ); | ||
729 | //{ QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | ||
730 | if ( !document.isEmpty() ) { | ||
731 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); | ||
732 | env << document; | ||
733 | } | 687 | } |
734 | #endif | 688 | #endif |
689 | return; | ||
735 | } | 690 | } |
736 | 691 | ||
737 | /*! | 692 | /*! |
738 | Returns the string \a s with the characters '\', '"', and '$' quoted | 693 | Returns the string \a s with the characters '\', '"', and '$' quoted |
739 | by a preceeding '\'. | 694 | by a preceeding '\'. |
740 | 695 | ||
741 | \sa stringQuote() | 696 | \sa stringQuote() |
742 | */ | 697 | */ |
743 | QString Global::shellQuote(const QString& s) | 698 | QString Global::shellQuote(const QString& s) |
744 | { | 699 | { |
745 | QString r="\""; | 700 | QString r="\""; |
746 | for (int i=0; i<(int)s.length(); i++) { | 701 | for (int i=0; i<(int)s.length(); i++) { |
747 | char c = s[i].latin1(); | 702 | char c = s[i].latin1(); |
748 | switch (c) { | 703 | switch (c) { |
749 | case '\\': case '"': case '$': | 704 | case '\\': case '"': case '$': |
750 | r+="\\"; | 705 | r+="\\"; |
751 | } | 706 | } |
752 | r += s[i]; | 707 | r += s[i]; |
753 | } | 708 | } |
754 | r += "\""; | 709 | r += "\""; |
755 | return r; | 710 | return r; |
756 | } | 711 | } |
757 | 712 | ||
758 | /*! | 713 | /*! |
759 | Returns the string \a s with the characters '\' and '"' quoted by a | 714 | Returns the string \a s with the characters '\' and '"' quoted by a |
760 | preceeding '\'. | 715 | preceeding '\'. |
761 | 716 | ||
762 | \sa shellQuote() | 717 | \sa shellQuote() |
763 | */ | 718 | */ |
764 | QString Global::stringQuote(const QString& s) | 719 | QString Global::stringQuote(const QString& s) |
765 | { | 720 | { |
766 | QString r="\""; | 721 | QString r="\""; |
767 | for (int i=0; i<(int)s.length(); i++) { | 722 | for (int i=0; i<(int)s.length(); i++) { |
768 | char c = s[i].latin1(); | 723 | char c = s[i].latin1(); |
769 | switch (c) { | 724 | switch (c) { |
770 | case '\\': case '"': | 725 | case '\\': case '"': |
771 | r+="\\"; | 726 | r+="\\"; |
772 | } | 727 | } |
773 | r += s[i]; | 728 | r += s[i]; |
774 | } | 729 | } |
775 | r += "\""; | 730 | r += "\""; |
776 | return r; | 731 | return r; |
777 | } | 732 | } |
778 | 733 | ||
779 | /*! | 734 | /*! |
780 | Finds all documents on the system's document directories which | 735 | Finds all documents on the system's document directories which |
781 | match the filter \a mimefilter, and appends the resulting DocLnk | 736 | match the filter \a mimefilter, and appends the resulting DocLnk |
782 | objects to \a folder. | 737 | objects to \a folder. |