kprocio.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1997 David Sweet <dsweet@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 #ifndef KPROCIO_H_ 00019 #define KPROCIO_H_ 00020 00021 #include <tqstring.h> 00022 #include <kprocess.h> 00023 #include <tqstrlist.h> 00024 #include "kdelibs_export.h" 00025 00026 class KProcIOPrivate; 00027 class TQTextCodec; 00028 00050 class KDECORE_EXPORT KProcIO : public KProcess 00051 { 00052 Q_OBJECT 00053 00054 public: 00058 KProcIO ( TQTextCodec *codec = 0 ); 00059 00063 ~KProcIO(); 00064 00072 void setComm (Communication comm); 00073 00088 bool start (RunMode runmode = NotifyOnExit, bool includeStderr = false); 00089 00096 bool writeStdin(const TQString &line, bool appendnewline=true); 00097 00104 bool writeStdin(const TQCString &line, bool appendnewline); 00105 00111 bool writeStdin(const TQByteArray &data); 00112 00113 //I like fputs better -- it's the same as writeStdin 00114 //inline 00123 KDE_DEPRECATED bool fputs (const TQString &line, bool AppendNewLine=true) 00124 { return writeStdin(line, AppendNewLine); } 00125 00129 void closeWhenDone(); 00130 00152 int readln (TQString &line, bool autoAck=true, bool *partial=0); 00153 00162 KDE_DEPRECATED int fgets (TQString &line, bool autoAck=false) 00163 { return readln (line, autoAck); } 00164 00168 void resetAll (); 00169 00179 void ackRead (); 00180 00187 void enableReadSignals (bool enable); 00188 00189 signals: 00195 void readReady(KProcIO *pio); 00196 00197 protected: 00198 TQPtrList<TQByteArray> outbuffer; 00199 TQCString recvbuffer; 00200 TQTextCodec *codec; 00201 int rbi; 00202 bool needreadsignal, readsignalon, writeready; 00203 00204 void controlledEmission (); 00205 00206 protected slots: 00207 void received (KProcess *proc, char *buffer, int buflen); 00208 void sent (KProcess *); 00209 00210 protected: 00211 virtual void virtual_hook( int id, void* data ); 00212 private: 00213 KProcIOPrivate *d; 00214 }; 00215 00216 #endif // KPROCIO_H_ 00217