author | sandman <sandman> | 2002-12-17 19:12:05 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-12-17 19:12:05 (UTC) |
commit | b6a03145553d7f536b04fc3355718cfdd72c590d (patch) (unidiff) | |
tree | cfadab49e69801a2000001f80d57ec081b2c5ea4 /libopie | |
parent | 6bbe59222c6b439f2016d0a36a111f17d338d120 (diff) | |
download | opie-b6a03145553d7f536b04fc3355718cfdd72c590d.zip opie-b6a03145553d7f536b04fc3355718cfdd72c590d.tar.gz opie-b6a03145553d7f536b04fc3355718cfdd72c590d.tar.bz2 |
- removed a the obsolete KShellProcess class
- added a few methods to OProcess to make it easier to port programs using
QProcess
-rw-r--r-- | libopie/oprocess.cpp | 94 | ||||
-rw-r--r-- | libopie/oprocess.h | 72 |
2 files changed, 56 insertions, 110 deletions
diff --git a/libopie/oprocess.cpp b/libopie/oprocess.cpp index f3e52bd..5db2b6c 100644 --- a/libopie/oprocess.cpp +++ b/libopie/oprocess.cpp | |||
@@ -94,22 +94,42 @@ public: | |||
94 | }; | 94 | }; |
95 | 95 | ||
96 | 96 | ||
97 | OProcess::OProcess() | 97 | OProcess::OProcess(QObject *parent, const char *name) |
98 | : QObject(), | 98 | : QObject(parent, name) |
99 | run_mode(NotifyOnExit), | ||
100 | runs(false), | ||
101 | pid_(0), | ||
102 | status(0), | ||
103 | keepPrivs(false), | ||
104 | innot(0), | ||
105 | outnot(0), | ||
106 | errnot(0), | ||
107 | communication(NoCommunication), | ||
108 | input_data(0), | ||
109 | input_sent(0), | ||
110 | input_total(0), | ||
111 | d(0) | ||
112 | { | 99 | { |
100 | init ( ); | ||
101 | } | ||
102 | |||
103 | OProcess::OProcess(const QString &arg0, QObject *parent, const char *name) | ||
104 | : QObject(parent, name) | ||
105 | { | ||
106 | init ( ); | ||
107 | *this << arg0; | ||
108 | } | ||
109 | |||
110 | OProcess::OProcess(const QStringList &args, QObject *parent, const char *name) | ||
111 | : QObject(parent, name) | ||
112 | { | ||
113 | init ( ); | ||
114 | *this << args; | ||
115 | } | ||
116 | |||
117 | void OProcess::init ( ) | ||
118 | { | ||
119 | run_mode = NotifyOnExit; | ||
120 | runs = false; | ||
121 | pid_ = 0; | ||
122 | status = 0; | ||
123 | keepPrivs = false; | ||
124 | innot = 0; | ||
125 | outnot = 0; | ||
126 | errnot = 0; | ||
127 | communication = NoCommunication; | ||
128 | input_data = 0; | ||
129 | input_sent = 0; | ||
130 | input_total = 0; | ||
131 | d = 0; | ||
132 | |||
113 | if (0 == OProcessController::theOProcessController) { | 133 | if (0 == OProcessController::theOProcessController) { |
114 | (void) new OProcessController(); | 134 | (void) new OProcessController(); |
115 | CHECK_PTR(OProcessController::theOProcessController); | 135 | CHECK_PTR(OProcessController::theOProcessController); |
@@ -472,6 +492,20 @@ bool OProcess::writeStdin(const char *buffer, int buflen) | |||
472 | return rv; | 492 | return rv; |
473 | } | 493 | } |
474 | 494 | ||
495 | void OProcess::flushStdin ( ) | ||
496 | { | ||
497 | if ( !input_data || ( input_sent == input_total )) | ||
498 | return; | ||
499 | |||
500 | int d1, d2; | ||
501 | |||
502 | do { | ||
503 | d1 = input_total - input_sent; | ||
504 | slotSendData ( 0 ); | ||
505 | d2 = input_total - input_sent; | ||
506 | } while ( d2 <= d1 ); | ||
507 | } | ||
508 | |||
475 | void OProcess::suspend() | 509 | void OProcess::suspend() |
476 | { | 510 | { |
477 | if ((communication & Stdout) && outnot) | 511 | if ((communication & Stdout) && outnot) |
@@ -888,35 +922,5 @@ bool OProcess::isExecutable(const QCString &filename) | |||
888 | return true; | 922 | return true; |
889 | } | 923 | } |
890 | 924 | ||
891 | void OProcess::virtual_hook( int, void* ) | ||
892 | { /*BASE::virtual_hook( id, data );*/ } | ||
893 | |||
894 | |||
895 | /////////////////////////// | ||
896 | // CC: Class KShellProcess | ||
897 | /////////////////////////// | ||
898 | |||
899 | KShellProcess::KShellProcess(const char *shellname): | ||
900 | OProcess() | ||
901 | { | ||
902 | setUseShell(true, shellname); | ||
903 | } | ||
904 | |||
905 | |||
906 | KShellProcess::~KShellProcess() { | ||
907 | } | ||
908 | |||
909 | QString KShellProcess::quote(const QString &arg) | ||
910 | { | ||
911 | return OProcess::quote(arg); | ||
912 | } | ||
913 | |||
914 | bool KShellProcess::start(RunMode runmode, Communication comm) | ||
915 | { | ||
916 | return OProcess::start(runmode, comm); | ||
917 | } | ||
918 | 925 | ||
919 | void KShellProcess::virtual_hook( int id, void* data ) | ||
920 | { OProcess::virtual_hook( id, data ); } | ||
921 | 926 | ||
922 | //#include "kprocess.moc" | ||
diff --git a/libopie/oprocess.h b/libopie/oprocess.h index fd726b4..bf5fe0e 100644 --- a/libopie/oprocess.h +++ b/libopie/oprocess.h | |||
@@ -187,7 +187,9 @@ public: | |||
187 | /** | 187 | /** |
188 | * Constructor | 188 | * Constructor |
189 | */ | 189 | */ |
190 | OProcess(); | 190 | OProcess(QObject *parent = 0, const char *name = 0); |
191 | OProcess(const QString &arg0, QObject *parent = 0, const char *name = 0); | ||
192 | OProcess(const QStringList &args, QObject *parent = 0, const char *name = 0); | ||
191 | 193 | ||
192 | /** | 194 | /** |
193 | *Destructor: | 195 | *Destructor: |
@@ -360,6 +362,8 @@ public: | |||
360 | **/ | 362 | **/ |
361 | bool writeStdin(const char *buffer, int buflen); | 363 | bool writeStdin(const char *buffer, int buflen); |
362 | 364 | ||
365 | void flushStdin(); | ||
366 | |||
363 | /** | 367 | /** |
364 | * This causes the stdin file descriptor of the child process to be | 368 | * This causes the stdin file descriptor of the child process to be |
365 | * closed indicating an "EOF" to the child. | 369 | * closed indicating an "EOF" to the child. |
@@ -731,72 +735,10 @@ private: | |||
731 | OProcess( const OProcess& ); | 735 | OProcess( const OProcess& ); |
732 | OProcess& operator= ( const OProcess& ); | 736 | OProcess& operator= ( const OProcess& ); |
733 | 737 | ||
734 | protected: | ||
735 | virtual void virtual_hook( int id, void* data ); | ||
736 | private: | ||
737 | OProcessPrivate *d; | ||
738 | }; | ||
739 | |||
740 | class KShellProcessPrivate; | ||
741 | |||
742 | /** | ||
743 | * @obsolete | ||
744 | * | ||
745 | * This class is obsolete. Use OProcess and OProcess::setUseShell(true) | ||
746 | * instead. | ||
747 | * | ||
748 | * @short A class derived from @ref OProcess to start child | ||
749 | * processes through a shell. | ||
750 | * @author Christian Czezakte <e9025461@student.tuwien.ac.at> | ||
751 | * @version $Id$ | ||
752 | */ | ||
753 | class KShellProcess: public OProcess | ||
754 | { | ||
755 | Q_OBJECT | ||
756 | |||
757 | public: | ||
758 | |||
759 | /** | ||
760 | * Constructor | ||
761 | * | ||
762 | * By specifying the name of a shell (like "/bin/bash") you can override | ||
763 | * the mechanism for finding a valid shell as described in OProcess::searchShell() | ||
764 | */ | ||
765 | KShellProcess(const char *shellname=0); | ||
766 | |||
767 | /** | ||
768 | * Destructor. | ||
769 | */ | ||
770 | ~KShellProcess(); | ||
771 | |||
772 | /** | ||
773 | * Starts up the process. -- For a detailed description | ||
774 | * have a look at the "start" member function and the detailed | ||
775 | * description of @ref OProcess . | ||
776 | */ | ||
777 | virtual bool start(RunMode runmode = NotifyOnExit, | ||
778 | Communication comm = NoCommunication); | ||
779 | |||
780 | /** | ||
781 | * This function can be used to quote an argument string such that | ||
782 | * the shell processes it properly. This is e. g. necessary for | ||
783 | * user-provided file names which may contain spaces or quotes. | ||
784 | * It also prevents expansion of wild cards and environment variables. | ||
785 | */ | ||
786 | static QString quote(const QString &arg); | ||
787 | |||
788 | private: | 738 | private: |
739 | void init ( ); | ||
789 | 740 | ||
790 | QCString shell; | 741 | OProcessPrivate *d; |
791 | |||
792 | // Disallow assignment and copy-construction | ||
793 | KShellProcess( const KShellProcess& ); | ||
794 | KShellProcess& operator= ( const KShellProcess& ); | ||
795 | |||
796 | protected: | ||
797 | virtual void virtual_hook( int id, void* data ); | ||
798 | private: | ||
799 | KShellProcessPrivate *d; | ||
800 | }; | 742 | }; |
801 | 743 | ||
802 | 744 | ||