1
/****************************************************************************
2
** $Id: jprocess.h,v 1.5 2003/06/05 02:56:56 justin Exp $
4
** Implementation of QProcess class
8
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
10
** This file is part of the kernel module of the Qt GUI Toolkit.
12
** This file may be distributed under the terms of the Q Public License
13
** as defined by Trolltech AS of Norway and appearing in the file
14
** LICENSE.QPL included in the packaging of this file.
16
** This file may be distributed and/or modified under the terms of the
17
** GNU General Public License version 2 as published by the Free Software
18
** Foundation and appearing in the file LICENSE.GPL included in the
19
** packaging of this file.
21
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22
** licenses may use this file in accordance with the Qt Commercial License
23
** Agreement provided with the Software.
25
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
28
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29
** information about Qt Commercial License Agreements.
30
** See http://www.trolltech.com/qpl/ for QPL licensing information.
31
** See http://www.trolltech.com/gpl/ for GPL licensing information.
33
** Contact info@trolltech.com if any conditions of this licensing are
36
**********************************************************************/
43
#include "qstringlist.h"
49
class JProcessPrivate;
52
class Q_EXPORT JProcess : public QObject
56
JProcess( QObject *parent=0, const char *name=0 );
57
JProcess( const QString& arg0, QObject *parent=0, const char *name=0 );
58
JProcess( const QStringList& args, QObject *parent=0, const char *name=0 );
61
// set and get the arguments and working directory
62
QStringList arguments() const;
63
void clearArguments();
64
virtual void setArguments( const QStringList& args );
65
virtual void addArgument( const QString& arg );
67
QDir workingDirectory() const;
68
virtual void setWorkingDirectory( const QDir& dir );
71
// set and get the comms wanted
72
enum Communication { Stdin=0x01, Stdout=0x02, Stderr=0x04, DupStderr=0x08 };
73
void setCommunication( int c );
74
int communication() const;
76
// start the execution
77
virtual bool start( QStringList *env=0 );
78
virtual bool launch( const QString& buf, QStringList *env=0 );
79
virtual bool launch( const QByteArray& buf, QStringList *env=0 );
82
bool isRunning() const;
83
bool normalExit() const;
84
int exitStatus() const;
87
virtual QByteArray readStdout();
88
virtual QByteArray readStderr();
89
bool canReadLineStdout() const;
90
bool canReadLineStderr() const;
91
virtual QString readLineStdout();
92
virtual QString readLineStderr();
94
// get platform dependent process information
95
#if defined(Q_OS_WIN32)
99
void setChildStartingHandler(void (*childStarting)(JProcess *));
101
PID processIdentifier();
106
void readyReadStdout();
107
void readyReadStderr();
108
void processExited();
110
void launchFinished();
114
void tryTerminate() const;
118
virtual void writeToStdin( const QByteArray& buf );
119
virtual void writeToStdin( const QString& buf );
120
virtual void closeStdin();
122
protected: // ### or private?
123
void connectNotify( const char * signal );
124
void disconnectNotify( const char * signal );
126
void setIoRedirection( bool value );
127
void setNotifyOnExit( bool value );
128
void setWroteStdinConnected( bool value );
132
#if defined(Q_OS_WIN32)
133
uint readStddev( HANDLE dev, char *buf, uint bytes );
135
bool scanNewline( bool stdOut, QByteArray *store );
137
QByteArray* bufStdout();
138
QByteArray* bufStderr();
139
void consumeBufStdout( int consume );
140
void consumeBufStderr( int consume );
143
void socketRead( int fd );
144
void socketWrite( int fd );
146
void closeStdinLaunch();
153
QStringList _arguments;
155
int exitStat; // exit status
156
bool exitNormal; // normal exit?
157
bool ioRedirection; // automatically set be (dis)connectNotify
158
bool notifyOnExit; // automatically set be (dis)connectNotify
159
bool wroteToStdinConnected; // automatically set be (dis)connectNotify
161
bool readStdoutCalled;
162
bool readStderrCalled;
165
friend class JProcessPrivate;
166
#if defined(Q_OS_UNIX)
167
friend class JProcessManager;
171
#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
172
JProcess( const JProcess & );
173
JProcess &operator=( const JProcess & );
177
#endif // QT_NO_PROCESS