qprocess.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef QPROCESS_H
00039 #define QPROCESS_H
00040
00041 #ifndef QT_H
00042 #include "qobject.h"
00043 #include "qstringlist.h"
00044 #include "qdir.h"
00045 #endif // QT_H
00046
00047 #ifndef QT_NO_PROCESS
00048
00049 class QProcessPrivate;
00050
00051
00052 class Q_EXPORT QProcess : public QObject
00053 {
00054 Q_OBJECT
00055 public:
00056 QProcess( QObject *parent=0, const char *name=0 );
00057 QProcess( const QString& arg0, QObject *parent=0, const char *name=0 );
00058 QProcess( const QStringList& args, QObject *parent=0, const char *name=0 );
00059 ~QProcess();
00060
00061
00062 QStringList arguments() const;
00063 void clearArguments();
00064 virtual void setArguments( const QStringList& args );
00065 virtual void addArgument( const QString& arg );
00066 #ifndef QT_NO_DIR
00067 QDir workingDirectory() const;
00068 virtual void setWorkingDirectory( const QDir& dir );
00069 #endif
00070
00071
00072 enum Communication { Stdin=0x01, Stdout=0x02, Stderr=0x04, DupStderr=0x08 };
00073 void setCommunication( int c );
00074 int communication() const;
00075
00076
00077 virtual bool start( QStringList *env=0 );
00078 virtual bool launch( const QString& buf, QStringList *env=0 );
00079 virtual bool launch( const QByteArray& buf, QStringList *env=0 );
00080
00081
00082 bool isRunning() const;
00083 bool normalExit() const;
00084 int exitStatus() const;
00085
00086
00087 virtual QByteArray readStdout();
00088 virtual QByteArray readStderr();
00089 bool canReadLineStdout() const;
00090 bool canReadLineStderr() const;
00091 virtual QString readLineStdout();
00092 virtual QString readLineStderr();
00093
00094
00095 #if defined(Q_OS_WIN32)
00096 typedef void* PID;
00097 #else
00098 typedef long Q_LONG;
00099 typedef Q_LONG PID;
00100 #endif
00101 PID processIdentifier();
00102
00103 void flushStdin();
00104
00105 signals:
00106 void readyReadStdout();
00107 void readyReadStderr();
00108 void processExited();
00109 void wroteToStdin();
00110 void launchFinished();
00111
00112 public slots:
00113
00114 void tryTerminate() const;
00115 void kill() const;
00116
00117
00118 virtual void writeToStdin( const QByteArray& buf );
00119 virtual void writeToStdin( const QString& buf );
00120 virtual void closeStdin();
00121
00122 protected:
00123 void connectNotify( const char * signal );
00124 void disconnectNotify( const char * signal );
00125 private:
00126 void setIoRedirection( bool value );
00127 void setNotifyOnExit( bool value );
00128 void setWroteStdinConnected( bool value );
00129
00130 void init();
00131 void reset();
00132 #if defined(Q_OS_WIN32)
00133 uint readStddev( HANDLE dev, char *buf, uint bytes );
00134 #endif
00135 bool scanNewline( bool stdOut, QByteArray *store );
00136
00137 QByteArray* bufStdout();
00138 QByteArray* bufStderr();
00139 void consumeBufStdout( int consume );
00140 void consumeBufStderr( int consume );
00141
00142 private slots:
00143 void socketRead( int fd );
00144 void socketWrite( int fd );
00145 void timeout();
00146 void closeStdinLaunch();
00147
00148 private:
00149 QProcessPrivate *d;
00150 #ifndef QT_NO_DIR
00151 QDir workingDir;
00152 #endif
00153 QStringList _arguments;
00154
00155 int exitStat;
00156 bool exitNormal;
00157 bool ioRedirection;
00158 bool notifyOnExit;
00159 bool wroteToStdinConnected;
00160
00161 bool readStdoutCalled;
00162 bool readStderrCalled;
00163 int comms;
00164
00165 friend class QProcessPrivate;
00166 #if defined(Q_OS_UNIX) || defined(_OS_UNIX) || defined(UNIX)
00167 friend class QProcessManager;
00168 friend class QProc;
00169 #endif
00170 };
00171
00172 #endif // QT_NO_PROCESS
00173
00174 #endif // QPROCESS_H
This file is part of the documentation for OPIE Version 1.5.5.