source: trunk/include/qprocess.h@ 41

Last change on this file since 41 was 41, checked in by dmik, 20 years ago

Implemented the OS/2 version of the QProcess class.

  • Property svn:keywords set to Id
File size: 5.1 KB
Line 
1/****************************************************************************
2** $Id: qprocess.h 41 2005-12-19 12:25:49Z dmik $
3**
4** Implementation of QProcess class
5**
6** Created : 20000905
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the kernel module of the Qt GUI Toolkit.
11**
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.
15**
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.
20**
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.
24**
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.
27**
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.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef QPROCESS_H
39#define QPROCESS_H
40
41#ifndef QT_H
42#include "qobject.h"
43#include "qstringlist.h"
44#include "qdir.h"
45#endif // QT_H
46
47#ifndef QT_NO_PROCESS
48
49class QProcessPrivate;
50class QMembuf;
51
52
53class Q_EXPORT QProcess : public QObject
54{
55 Q_OBJECT
56public:
57 QProcess( QObject *parent=0, const char *name=0 );
58 QProcess( const QString& arg0, QObject *parent=0, const char *name=0 );
59 QProcess( const QStringList& args, QObject *parent=0, const char *name=0 );
60 ~QProcess();
61
62 // set and get the arguments and working directory
63 QStringList arguments() const;
64 void clearArguments();
65 virtual void setArguments( const QStringList& args );
66 virtual void addArgument( const QString& arg );
67#ifndef QT_NO_DIR
68 QDir workingDirectory() const;
69 virtual void setWorkingDirectory( const QDir& dir );
70#endif
71
72 // set and get the comms wanted
73 enum Communication { Stdin=0x01, Stdout=0x02, Stderr=0x04, DupStderr=0x08 };
74 void setCommunication( int c );
75 int communication() const;
76
77 // start the execution
78 virtual bool start( QStringList *env=0 );
79 virtual bool launch( const QString& buf, QStringList *env=0 );
80 virtual bool launch( const QByteArray& buf, QStringList *env=0 );
81
82 // inquire the status
83 bool isRunning() const;
84 bool normalExit() const;
85 int exitStatus() const;
86
87 // reading
88 virtual QByteArray readStdout();
89 virtual QByteArray readStderr();
90 bool canReadLineStdout() const;
91 bool canReadLineStderr() const;
92 virtual QString readLineStdout();
93 virtual QString readLineStderr();
94
95 // get platform dependent process information
96#if defined(Q_OS_WIN32)
97 typedef void* PID;
98#elif defined(Q_OS_OS2)
99 typedef ::PID PID;
100#else
101 typedef Q_LONG PID;
102#endif
103 PID processIdentifier();
104
105 void flushStdin();
106
107signals:
108 void readyReadStdout();
109 void readyReadStderr();
110 void processExited();
111 void wroteToStdin();
112 void launchFinished();
113
114public slots:
115 // end the execution
116 void tryTerminate() const;
117 void kill() const;
118
119 // input
120 virtual void writeToStdin( const QByteArray& buf );
121 virtual void writeToStdin( const QString& buf );
122 virtual void closeStdin();
123
124protected: // ### or private?
125 void connectNotify( const char * signal );
126 void disconnectNotify( const char * signal );
127private:
128 void setIoRedirection( bool value );
129 void setNotifyOnExit( bool value );
130 void setWroteStdinConnected( bool value );
131
132 void init();
133 void reset();
134#if defined(Q_OS_WIN32)
135 uint readStddev( HANDLE dev, char *buf, uint bytes );
136#endif
137 QMembuf* membufStdout();
138 QMembuf* membufStderr();
139
140private slots:
141 void socketRead( int fd );
142 void socketWrite( int fd );
143 void timeout();
144 void closeStdinLaunch();
145
146private:
147 QProcessPrivate *d;
148#ifndef QT_NO_DIR
149 QDir workingDir;
150#endif
151 QStringList _arguments;
152
153 int exitStat; // exit status
154 bool exitNormal; // normal exit?
155 bool ioRedirection; // automatically set be (dis)connectNotify
156 bool notifyOnExit; // automatically set be (dis)connectNotify
157 bool wroteToStdinConnected; // automatically set be (dis)connectNotify
158
159 bool readStdoutCalled;
160 bool readStderrCalled;
161 int comms;
162
163 friend class QProcessPrivate;
164#if defined(Q_OS_UNIX)
165 friend class QProcessManager;
166 friend class QProc;
167#endif
168
169#if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
170 QProcess( const QProcess & );
171 QProcess &operator=( const QProcess & );
172#endif
173};
174
175#endif // QT_NO_PROCESS
176
177#endif // QPROCESS_H
Note: See TracBrowser for help on using the repository browser.