27 #include "tdeprocio.h" 30 #include <tqtextcodec.h> 32 class 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();
189 void TDEProcIO::received (
TDEProcess *,
char *buffer,
int buflen)
191 recvbuffer += TQCString(buffer, buflen+1);
193 controlledEmission();
199 if (needreadsignal || recvbuffer.length()!=0)
200 controlledEmission();
203 void 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);
272 void TDEProcIO::virtual_hook(
int id,
void* data )
273 { TDEProcess::virtual_hook(
id, data ); }
275 #include "tdeprocio.moc" bool start(RunMode runmode=NotifyOnExit, bool includeStderr=false)
Starts the process.
void setComm(Communication comm)
Sets the communication mode to be passed to TDEProcess::start() by start().
void wroteStdin(TDEProcess *proc)
Emitted after all the data that has been specified by a prior call to writeStdin() has actually been ...
void enableReadSignals(bool enable)
Turns readReady() signals on and off.
void receivedStderr(TDEProcess *proc, char *buffer, int buflen)
Emitted, when output from the child process has been received on stderr.
void receivedStdout(TDEProcess *proc, char *buffer, int buflen)
Emitted, when output from the child process has been received on stdout.
void resetAll()
Reset the class.
void readReady(TDEProcIO *pio)
Emitted when the process is ready for reading.
virtual bool kill(int signo=SIGTERM)
Stop the process (by sending it a signal).
virtual bool start(RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
Starts the process.
RunMode
Run-modes for a child process.
TDEProcIO(TQTextCodec *codec=0)
Constructor.
void clearArguments()
Clear a command line argument list that has been set by using operator<<.
bool writeStdin(const char *buffer, int buflen)
Transmit data to the child process' stdin.
int readln(TQString &line, bool autoAck=true, bool *partial=0)
Reads a line of text (up to and including '\n').
void ackRead()
Call this after you have finished processing a readReady() signal.
bool writeStdin(const TQString &line, bool appendnewline=true)
Writes text to stdin of the process.
void closeWhenDone()
Closes stdin after all data has been send.
bool isRunning() const
Checks whether the process is running.
Communication
Modes in which the communication channel can be opened.
Child process invocation, monitoring and control.
kndbgstream & endl(kndbgstream &s)
Does nothing.
bool closeStdin()
Shuts down the Stdin communication link.