30#include <tqtextcodec.h>
32class TDEProcIOPrivate {
39 : codec(_codec), d(new TDEProcIOPrivate)
42 readsignalon=writeready=
true;
43 outbuffer.setAutoDelete(
true);
47 codec = TQTextCodec::codecForName(
"ISO 8859-1");
50 kdError(174) <<
"Can't create ISO 8859-1 codec!" <<
endl;
68 readsignalon=writeready=
true;
71 this, TQ_SLOT (received (
TDEProcess *,
char *,
int)));
74 this, TQ_SLOT (received (
TDEProcess *,
char *,
int)));
91 this, TQ_SLOT (received (
TDEProcess *,
char *,
int)));
96 this, TQ_SLOT (received (
TDEProcess *,
char *,
int)));
107 return writeStdin(TQCString(codec->fromUnicode(line)), appendnewline);
112 TQCString *qs =
new TQCString(line);
119 int l = qs->length();
126 TQByteArray *b = (TQByteArray *) qs;
143 TQByteArray *b =
new TQByteArray(data);
168 outbuffer.removeFirst();
170 if (outbuffer.count()==0)
176 TQByteArray *b = outbuffer.first();
189void TDEProcIO::received (
TDEProcess *,
char *buffer,
int buflen)
191 recvbuffer += TQCString(buffer, buflen+1);
193 controlledEmission();
199 if (needreadsignal || recvbuffer.length()!=0)
200 controlledEmission();
203void TDEProcIO::controlledEmission ()
207 needreadsignal=
false;
221 if (enable && needreadsignal)
234 len=recvbuffer.find (
'\n',rbi)-rbi;
240 ((
unsigned int)rbi<recvbuffer.length()))
242 recvbuffer=recvbuffer.mid (rbi);
246 len = recvbuffer.length();
257 line = codec->toUnicode(recvbuffer.mid(rbi,len), len);
272void TDEProcIO::virtual_hook(
int id,
void* data )
273{ TDEProcess::virtual_hook(
id, data ); }
275#include "tdeprocio.moc"
void closeWhenDone()
Closes stdin after all data has been send.
void resetAll()
Reset the class.
int readln(TQString &line, bool autoAck=true, bool *partial=0)
Reads a line of text (up to and including '\n').
void enableReadSignals(bool enable)
Turns readReady() signals on and off.
void setComm(Communication comm)
Sets the communication mode to be passed to TDEProcess::start() by start().
void readReady(TDEProcIO *pio)
Emitted when the process is ready for reading.
bool writeStdin(const TQString &line, bool appendnewline=true)
Writes text to stdin of the process.
TDEProcIO(TQTextCodec *codec=0)
Constructor.
bool start(RunMode runmode=NotifyOnExit, bool includeStderr=false)
Starts the process.
void ackRead()
Call this after you have finished processing a readReady() signal.
Child process invocation, monitoring and control.
bool isRunning() const
Checks whether the process is running.
virtual bool start(RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
Starts the process.
void clearArguments()
Clear a command line argument list that has been set by using operator<<.
virtual bool kill(int signo=SIGTERM)
Stop the process (by sending it a signal).
RunMode
Run-modes for a child process.
Communication
Modes in which the communication channel can be opened.
bool writeStdin(const char *buffer, int buflen)
void receivedStderr(TDEProcess *proc, char *buffer, int buflen)
Emitted, when output from the child process has been received on stderr.
void wroteStdin(TDEProcess *proc)
Emitted after all the data that has been specified by a prior call to writeStdin() has actually been ...
bool closeStdin()
Shuts down the Stdin communication link.
void receivedStdout(TDEProcess *proc, char *buffer, int buflen)
Emitted, when output from the child process has been received on stdout.
kndbgstream & endl(kndbgstream &s)
Does nothing.