• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
TDEProcIO Class Reference

#include <tdeprocio.h>

Inheritance diagram for TDEProcIO:
TDEProcess

Signals

void readReady (TDEProcIO *pio)
 
- Signals inherited from TDEProcess
void processExited (TDEProcess *proc)
 
void receivedStdout (TDEProcess *proc, char *buffer, int buflen)
 
void receivedStdout (int fd, int &len)
 
void receivedStderr (TDEProcess *proc, char *buffer, int buflen)
 
void wroteStdin (TDEProcess *proc)
 

Public Member Functions

 TDEProcIO (TQTextCodec *codec=0)
 
 ~TDEProcIO ()
 
void setComm (Communication comm)
 
bool start (RunMode runmode=NotifyOnExit, bool includeStderr=false)
 
bool writeStdin (const TQString &line, bool appendnewline=true)
 
bool writeStdin (const TQCString &line, bool appendnewline)
 
bool writeStdin (const TQByteArray &data)
 
TDE_DEPRECATED bool fputs (const TQString &line, bool AppendNewLine=true)
 
void closeWhenDone ()
 
int readln (TQString &line, bool autoAck=true, bool *partial=0)
 
TDE_DEPRECATED int fgets (TQString &line, bool autoAck=false)
 
void resetAll ()
 
void ackRead ()
 
void enableReadSignals (bool enable)
 
- Public Member Functions inherited from TDEProcess
 TDEProcess (TQObject *parent, const char *name=0)
 
 TDEProcess ()
 
virtual ~TDEProcess ()
 
bool setExecutable (const TQString &proc) TDE_DEPRECATED
 
TDEProcess & operator<< (const TQString &arg)
 
TDEProcess & operator<< (const char *arg)
 
TDEProcess & operator<< (const TQCString &arg)
 
TDEProcess & operator<< (const TQStringList &args)
 
void clearArguments ()
 
virtual bool start (RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
 
virtual bool kill (int signo=SIGTERM)
 
bool isRunning () const
 
pid_t pid () const
 
TDE_DEPRECATED pid_t getPid () const
 
void suspend ()
 
void resume ()
 
bool wait (int timeout=-1)
 
bool normalExit () const
 
bool signalled () const
 
bool coreDumped () const
 
int exitStatus () const
 
int exitSignal () const
 
bool writeStdin (const char *buffer, int buflen)
 
bool closeStdin ()
 
bool closeStdout ()
 
bool closeStderr ()
 
bool closePty ()
 
void closeAll ()
 
const TQValueList< TQCString > & args ()
 
void setRunPrivileged (bool keepPrivileges)
 
bool runPrivileged () const
 
void setEnvironment (const TQString &name, const TQString &value)
 
void setWorkingDirectory (const TQString &dir)
 
void setUseShell (bool useShell, const char *shell=0)
 
void detach ()
 
void setUsePty (Communication comm, bool addUtmp)
 
KPty * pty () const
 
bool setPriority (int prio)
 

Protected Slots

void received (TDEProcess *proc, char *buffer, int buflen)
 
void sent (TDEProcess *)
 
- Protected Slots inherited from TDEProcess
void slotChildOutput (int fdno)
 
void slotChildError (int fdno)
 
void slotSendData (int dummy)
 

Protected Member Functions

void controlledEmission ()
 
virtual void virtual_hook (int id, void *data)
 
- Protected Member Functions inherited from TDEProcess
void setupEnvironment ()
 
virtual int setupCommunication (Communication comm)
 
virtual int commSetupDoneP ()
 
virtual int commSetupDoneC ()
 
virtual void processHasExited (int state)
 
virtual void commClose ()
 
void setBinaryExecutable (const char *filename)
 
int childOutput (int fdno)
 
int childError (int fdno)
 
virtual void virtual_hook (int id, void *data)
 

Protected Attributes

TQPtrList< TQByteArray > outbuffer
 
TQCString recvbuffer
 
TQTextCodec * codec
 
int rbi
 
bool needreadsignal
 
bool readsignalon
 
bool writeready
 
- Protected Attributes inherited from TDEProcess
TQValueList< TQCString > arguments
 
RunMode run_mode
 
bool runs
 
pid_t pid_
 
int status
 
bool keepPrivs
 
int out [2]
 
int in [2]
 
int err [2]
 
TQSocketNotifier * innot
 
TQSocketNotifier * outnot
 
TQSocketNotifier * errnot
 
Communication communication
 
const char * input_data
 
int input_sent
 
int input_total
 

Additional Inherited Members

- Public Types inherited from TDEProcess
enum  Communication {
  NoCommunication = 0 , Stdin = 1 , Stdout = 2 , Stderr = 4 ,
  AllOutput = 6 , All = 7 , NoRead = 8 , CTtyOnly = NoRead ,
  MergedStderr = 16
}
 
enum  RunMode { DontCare , NotifyOnExit , Block , OwnGroup }
 
enum  {
  PrioLowest = 20 , PrioLow = 10 , PrioLower = 5 , PrioNormal = 0 ,
  PrioHigher = -5 , PrioHigh = -10 , PrioHighest = -19
}
 
- Static Public Member Functions inherited from TDEProcess
static TQString quote (const TQString &arg)
 

Detailed Description

TDEProcIO.

This class provides a slightly simpler interface to the communication functions provided by TDEProcess. The simplifications are:

  • The buffer for a write is copied to an internal TDEProcIO buffer and maintained/freed appropriately. There is no need to be concerned with wroteStdin() signals at_all.
  • readln() reads a line of data and buffers any leftovers.
  • Conversion from/to unicode.

Basically, TDEProcIO gives you buffered I/O similar to fgets()/fputs().

Aside from these, and the fact that start() takes different parameters, use this class just like TDEProcess.

Author
David Sweet

A slightly simpler interface to TDEProcess

Definition at line 50 of file tdeprocio.h.

Constructor & Destructor Documentation

◆ TDEProcIO()

TDEProcIO::TDEProcIO ( TQTextCodec *  codec = 0)

Constructor.

Definition at line 38 of file tdeprocio.cpp.

◆ ~TDEProcIO()

TDEProcIO::~TDEProcIO ( )

Destructor.

Definition at line 55 of file tdeprocio.cpp.

Member Function Documentation

◆ ackRead()

void TDEProcIO::ackRead ( )

Call this after you have finished processing a readReady() signal.

This call need not be made in the slot that was signalled by readReady(). You won't receive any more readReady() signals until you acknowledge with ackRead(). This prevents your slot from being reentered while you are still processing the current data. If this doesn't matter, then call ackRead() right away in your readReady()-processing slot.

Definition at line 196 of file tdeprocio.cpp.

◆ closeWhenDone()

void TDEProcIO::closeWhenDone ( )

Closes stdin after all data has been send.

Definition at line 154 of file tdeprocio.cpp.

◆ controlledEmission()

void TDEProcIO::controlledEmission ( )
protected

Definition at line 203 of file tdeprocio.cpp.

◆ enableReadSignals()

void TDEProcIO::enableReadSignals ( bool  enable)

Turns readReady() signals on and off.

You can turn this off at will and not worry about losing any data. (as long as you turn it back on at some point...)

Parameters
enabletrue to turn the signals on, false to turn them off

Definition at line 217 of file tdeprocio.cpp.

◆ fgets()

TDE_DEPRECATED int TDEProcIO::fgets ( TQString &  line,
bool  autoAck = false 
)
inline

This function calls readln().

Parameters
lineis used to store the line that was read.
autoAckwhen true, ackRead() is called for you.
Returns
the number of characters read, or -1 if no data is available.
Deprecated:
use readln. Note that it has an inverted autoAck default, though.

Definition at line 162 of file tdeprocio.h.

◆ fputs()

TDE_DEPRECATED bool TDEProcIO::fputs ( const TQString &  line,
bool  AppendNewLine = true 
)
inline

This function just calls writeStdin().

Parameters
lineText to write.
AppendNewLineif true, a newline '\n' is appended.
Returns
true if successful, false otherwise
Deprecated:

Definition at line 123 of file tdeprocio.h.

◆ readln()

int TDEProcIO::readln ( TQString &  line,
bool  autoAck = true,
bool *  partial = 0 
)

Reads a line of text (up to and including '\n').

Use readln() in response to a readReady() signal. You may use it multiple times if more than one line of data is available. Be sure to use ackRead() when you have finished processing the readReady() signal. This informs TDEProcIO that you are ready for another readReady() signal.

readln() never blocks.

autoAck==true makes these functions call ackRead() for you.

Parameters
lineis used to store the line that was read.
autoAckwhen true, ackRead() is called for you.
partialwhen provided the line is returned even if it does not contain a '\n'. *partial will be set to false if the line contains a '\n' and false otherwise.
Returns
the number of characters read, or -1 if no data is available.

Definition at line 225 of file tdeprocio.cpp.

◆ readReady

void TDEProcIO::readReady ( TDEProcIO *  pio)
signal

Emitted when the process is ready for reading.

Parameters
piothe process that emitted the signal
See also
enableReadSignals()

◆ received

void TDEProcIO::received ( TDEProcess *  proc,
char *  buffer,
int  buflen 
)
protectedslot

Definition at line 189 of file tdeprocio.cpp.

◆ resetAll()

void TDEProcIO::resetAll ( )

Reset the class.

Doesn't kill the process.

Definition at line 61 of file tdeprocio.cpp.

◆ sent

void TDEProcIO::sent ( TDEProcess *  )
protectedslot

Definition at line 166 of file tdeprocio.cpp.

◆ setComm()

void TDEProcIO::setComm ( Communication  comm)

Sets the communication mode to be passed to TDEProcess::start() by start().

The default communication mode is TDEProcess::All. You probably want to use this function in conjunction with TDEProcess::setUsePty().

Parameters
commthe communication mode

Definition at line 83 of file tdeprocio.cpp.

◆ start()

bool TDEProcIO::start ( RunMode  runmode = NotifyOnExit,
bool  includeStderr = false 
)

Starts the process.

It will fail in the following cases:

  • The process is already running.
  • The command line argument list is empty.
  • The starting of the process failed (could not fork).
  • The executable was not found.
Parameters
runmodeFor a detailed description of the various run modes, have a look at the general description of the TDEProcess class.
includeStderrIf true, data from both stdout and stderr is listened to. If false, only stdout is listened to.
Returns
true on success, false on error.

Definition at line 88 of file tdeprocio.cpp.

◆ virtual_hook()

void TDEProcIO::virtual_hook ( int  id,
void *  data 
)
protectedvirtual

Reimplemented from TDEProcess.

Definition at line 272 of file tdeprocio.cpp.

◆ writeStdin() [1/3]

bool TDEProcIO::writeStdin ( const TQByteArray &  data)

Writes data to stdin of the process.

Parameters
dataData to write.
Returns
true if successful, false otherwise

Definition at line 139 of file tdeprocio.cpp.

◆ writeStdin() [2/3]

bool TDEProcIO::writeStdin ( const TQCString &  line,
bool  appendnewline 
)

Writes text to stdin of the process.

Parameters
lineText to write.
appendnewlineif true, a newline '\n' is appended.
Returns
true if successful, false otherwise

Definition at line 110 of file tdeprocio.cpp.

◆ writeStdin() [3/3]

bool TDEProcIO::writeStdin ( const TQString &  line,
bool  appendnewline = true 
)

Writes text to stdin of the process.

Parameters
lineText to write.
appendnewlineif true, a newline '\n' is appended.
Returns
true if successful, false otherwise

Definition at line 105 of file tdeprocio.cpp.

Member Data Documentation

◆ codec

TQTextCodec* TDEProcIO::codec
protected

Definition at line 200 of file tdeprocio.h.

◆ needreadsignal

bool TDEProcIO::needreadsignal
protected

Definition at line 202 of file tdeprocio.h.

◆ outbuffer

TQPtrList<TQByteArray> TDEProcIO::outbuffer
protected

Definition at line 198 of file tdeprocio.h.

◆ rbi

int TDEProcIO::rbi
protected

Definition at line 201 of file tdeprocio.h.

◆ readsignalon

bool TDEProcIO::readsignalon
protected

Definition at line 202 of file tdeprocio.h.

◆ recvbuffer

TQCString TDEProcIO::recvbuffer
protected

Definition at line 199 of file tdeprocio.h.

◆ writeready

bool TDEProcIO::writeready
protected

Definition at line 202 of file tdeprocio.h.


The documentation for this class was generated from the following files:
  • tdeprocio.h
  • tdeprocio.cpp

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.