Eneboo - Documentación para desarrolladores
src/qt/include/qprocess.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qprocess.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Implementation of QProcess class
00005 **
00006 ** Created : 20000905
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the kernel module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
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 class QMembuf;
00051 
00052 
00053 class Q_EXPORT QProcess : public QObject
00054 {
00055     Q_OBJECT
00056 public:
00057     QProcess( QObject *parent=0, const char *name=0 );
00058     QProcess( const QString& arg0, QObject *parent=0, const char *name=0 );
00059     QProcess( const QStringList& args, QObject *parent=0, const char *name=0 );
00060     ~QProcess();
00061 
00062     // set and get the arguments and working directory
00063     QStringList arguments() const;
00064     void clearArguments();
00065     virtual void setArguments( const QStringList& args );
00066     virtual void addArgument( const QString& arg );
00067 #ifndef QT_NO_DIR
00068     QDir workingDirectory() const;
00069     virtual void setWorkingDirectory( const QDir& dir );
00070 #endif
00071 
00072     // set and get the comms wanted
00073     enum Communication { Stdin=0x01, Stdout=0x02, Stderr=0x04, DupStderr=0x08 };
00074     void setCommunication( int c );
00075     int communication() const;
00076 
00077     // start the execution
00078     virtual bool start( QStringList *env=0 );
00079     virtual bool launch( const QString& buf, QStringList *env=0  );
00080     virtual bool launch( const QByteArray& buf, QStringList *env=0  );
00081 
00082     // inquire the status
00083     bool isRunning() const;
00084     bool normalExit() const;
00085     int exitStatus() const;
00086 
00087     // reading
00088     virtual QByteArray readStdout();
00089     virtual QByteArray readStderr();
00090     bool canReadLineStdout() const;
00091     bool canReadLineStderr() const;
00092     virtual QString readLineStdout();
00093     virtual QString readLineStderr();
00094 
00095     // get platform dependent process information
00096 #if defined(Q_OS_WIN32)
00097     typedef void* PID;
00098 #else
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     // end the execution
00114     void tryTerminate() const;
00115     void kill() const;
00116 
00117     // input
00118     virtual void writeToStdin( const QByteArray& buf );
00119     virtual void writeToStdin( const QString& buf );
00120     virtual void closeStdin();
00121 
00122 protected: // ### or private?
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     QMembuf* membufStdout();
00136     QMembuf* membufStderr();
00137 
00138 private slots:
00139     void socketRead( int fd );
00140     void socketWrite( int fd );
00141     void timeout();
00142     void closeStdinLaunch();
00143 
00144 private:
00145     QProcessPrivate *d;
00146 #ifndef QT_NO_DIR
00147     QDir        workingDir;
00148 #endif
00149     QStringList _arguments;
00150 
00151     int  exitStat; // exit status
00152     bool exitNormal; // normal exit?
00153     bool ioRedirection; // automatically set be (dis)connectNotify
00154     bool notifyOnExit; // automatically set be (dis)connectNotify
00155     bool wroteToStdinConnected; // automatically set be (dis)connectNotify
00156 
00157     bool readStdoutCalled;
00158     bool readStderrCalled;
00159     int comms;
00160 
00161     friend class QProcessPrivate;
00162 #if defined(Q_OS_UNIX)
00163     friend class QProcessManager;
00164     friend class QProc;
00165 #endif
00166 
00167 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
00168     QProcess( const QProcess & );
00169     QProcess &operator=( const QProcess & );
00170 #endif
00171 };
00172 
00173 #endif // QT_NO_PROCESS
00174 
00175 #endif // QPROCESS_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'