summaryrefslogtreecommitdiff
path: root/library/global.cpp
Unidiff
Diffstat (limited to 'library/global.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp59
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
@@ -667,80 +667,35 @@ void Global::invoke(const QString &c)
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*/
677void Global::execute( const QString &c, const QString& document ) 677void 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*/
743QString Global::shellQuote(const QString& s) 698QString 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++) {