1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the Qt 3 compatibility classes of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
33
#include "QtCore/qobject.h"
34
#include "QtCore/qstringlist.h"
35
#include "QtCore/qdir.h"
40
class Q3ProcessPrivate;
43
class Q_COMPAT_EXPORT Q3Process : public QObject
47
Q3Process( QObject *parent=0, const char *name=0 );
48
Q3Process( const QString& arg0, QObject *parent=0, const char *name=0 );
49
Q3Process( const QStringList& args, QObject *parent=0, const char *name=0 );
52
// set and get the arguments and working directory
53
QStringList arguments() const;
54
void clearArguments();
55
virtual void setArguments( const QStringList& args );
56
virtual void addArgument( const QString& arg );
58
QDir workingDirectory() const;
59
virtual void setWorkingDirectory( const QDir& dir );
62
// set and get the comms wanted
63
enum Communication { Stdin=0x01, Stdout=0x02, Stderr=0x04, DupStderr=0x08 };
64
void setCommunication( int c );
65
int communication() const;
67
// start the execution
68
virtual bool start( QStringList *env=0 );
69
virtual bool launch( const QString& buf, QStringList *env=0 );
70
virtual bool launch( const QByteArray& buf, QStringList *env=0 );
73
bool isRunning() const;
74
bool normalExit() const;
75
int exitStatus() const;
78
virtual QByteArray readStdout();
79
virtual QByteArray readStderr();
80
bool canReadLineStdout() const;
81
bool canReadLineStderr() const;
82
virtual QString readLineStdout();
83
virtual QString readLineStderr();
85
// get platform dependent process information
86
#if defined(Q_OS_WIN32)
91
PID processIdentifier();
96
void readyReadStdout();
97
void readyReadStderr();
100
void launchFinished();
104
void tryTerminate() const;
108
virtual void writeToStdin( const QByteArray& buf );
109
virtual void writeToStdin( const QString& buf );
110
virtual void closeStdin();
112
protected: // ### or private?
113
void connectNotify( const char * signal );
114
void disconnectNotify( const char * signal );
116
void setIoRedirection( bool value );
117
void setNotifyOnExit( bool value );
118
void setWroteStdinConnected( bool value );
122
#if defined(Q_OS_WIN32)
123
uint readStddev( Qt::HANDLE dev, char *buf, uint bytes );
125
Q3Membuf* membufStdout();
126
Q3Membuf* membufStderr();
129
void socketRead( int fd );
130
void socketWrite( int fd );
132
void closeStdinLaunch();
139
QStringList _arguments;
141
int exitStat; // exit status
142
bool exitNormal; // normal exit?
143
bool ioRedirection; // automatically set be (dis)connectNotify
144
bool notifyOnExit; // automatically set be (dis)connectNotify
145
bool wroteToStdinConnected; // automatically set be (dis)connectNotify
147
bool readStdoutCalled;
148
bool readStderrCalled;
151
friend class Q3ProcessPrivate;
152
#if defined(Q_OS_UNIX)
153
friend class Q3ProcessManager;
157
#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
158
Q3Process( const Q3Process & );
159
Q3Process &operator=( const Q3Process & );
163
#endif // QT_NO_PROCESS
165
#endif // Q3PROCESS_H