• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

KDE3Support

Signals | Public Member Functions | Protected Slots | Protected Member Functions
K3ProcIO Class Reference

#include <k3procio.h>

Inheritance diagram for K3ProcIO:
K3Process QObject

List of all members.

Signals

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

Public Member Functions

 K3ProcIO (QTextCodec *codec=0)
 ~K3ProcIO ()
void ackRead ()
void closeWhenDone ()
void enableReadSignals (bool enable)
int readln (QString &line, bool autoAck=true, bool *partial=0)
void resetAll ()
void setComm (Communication comm)
bool start (RunMode runmode=NotifyOnExit, bool includeStderr=false)
bool writeStdin (const QString &line, bool appendnewline=true)
bool writeStdin (const QByteArray &line, bool appendnewline)
bool writeStdin (const QByteArray &data)
- Public Member Functions inherited from K3Process
 K3Process (QObject *parent=0L)
virtual ~K3Process ()
const QList< QByteArray > & args ()
void clearArguments ()
void closeAll ()
bool closePty ()
bool closeStderr ()
bool closeStdin ()
bool closeStdout ()
bool coreDumped () const
void detach ()
int exitSignal () const
int exitStatus () const
bool isRunning () const
virtual bool kill (int signo=SIGTERM)
bool normalExit () const
K3Process & operator<< (const QString &arg)
K3Process & operator<< (const char *arg)
K3Process & operator<< (const QByteArray &arg)
K3Process & operator<< (const QStringList &args)
pid_t pid () const
KPty * pty () const
void resume ()
bool runPrivileged () const
void setEnvironment (const QString &name, const QString &value)
bool setPriority (int prio)
void setRunPrivileged (bool keepPrivileges)
void setUsePty (Communication comm, bool addUtmp)
void setUseShell (bool useShell, const char *shell=0)
void setWorkingDirectory (const QString &dir)
bool signalled () const
virtual bool start (RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
void suspend ()
bool wait (int timeout=-1)
bool writeStdin (const char *buffer, int buflen)

Protected Slots

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

Protected Member Functions

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

Additional Inherited Members

- Public Types inherited from K3Process
enum  {
  PrioLowest = 20, PrioLow = 10, PrioLower = 5, PrioNormal = 0,
  PrioHigher = -5, PrioHigh = -10, PrioHighest = -19
}
enum  CommunicationFlag {
  NoCommunication = 0, Stdin = 1, Stdout = 2, Stderr = 4,
  AllOutput = 6, All = 7, NoRead = 8, CTtyOnly = NoRead,
  MergedStderr = 16
}
enum  RunMode { DontCare, NotifyOnExit, Block, OwnGroup }
- Static Public Member Functions inherited from K3Process
static QString quote (const QString &arg)
- Protected Attributes inherited from K3Process
QList< QByteArray > arguments
Communication communication
int err [2]
QSocketNotifier * errnot
int in [2]
QSocketNotifier * innot
const char * input_data
int input_sent
int input_total
bool keepPrivs
int out [2]
QSocketNotifier * outnot
pid_t pid_
RunMode run_mode
bool runs
int status

Detailed Description

A slightly simpler interface to K3Process.

Deprecated:
Use KProcess and KPtyProcess instead.

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

  • The buffer for a write is copied to an internal K3ProcIO 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, K3ProcIO 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 K3Process.

Author:
David Sweet

Definition at line 50 of file k3procio.h.


Constructor & Destructor Documentation

K3ProcIO::K3ProcIO ( QTextCodec *  codec = 0)
explicit

Constructor.

Definition at line 49 of file k3procio.cpp.

K3ProcIO::~K3ProcIO ( )

Destructor.

Definition at line 60 of file k3procio.cpp.


Member Function Documentation

void K3ProcIO::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 197 of file k3procio.cpp.

void K3ProcIO::closeWhenDone ( )

Closes stdin after all data has been send.

Definition at line 163 of file k3procio.cpp.

void K3ProcIO::controlledEmission ( )
protected

Definition at line 205 of file k3procio.cpp.

void K3ProcIO::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 216 of file k3procio.cpp.

int K3ProcIO::readln ( QString &  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 K3ProcIO 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 k3procio.cpp.

void K3ProcIO::readReady ( K3ProcIO *  pio)
signal

Emitted when the process is ready for reading.

Parameters:
piothe process that emitted the signal
See also:
enableReadSignals()
void K3ProcIO::received ( K3Process *  proc,
char *  buffer,
int  buflen 
)
protectedslot

Definition at line 190 of file k3procio.cpp.

void K3ProcIO::resetAll ( )

Reset the class.

Doesn't kill the process.

Definition at line 67 of file k3procio.cpp.

void K3ProcIO::sent ( K3Process *  )
protectedslot

Definition at line 174 of file k3procio.cpp.

void K3ProcIO::setComm ( Communication  comm)

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

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

Parameters:
commthe communication mode

Definition at line 91 of file k3procio.cpp.

bool K3ProcIO::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 K3Process 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 96 of file k3procio.cpp.

bool K3ProcIO::writeStdin ( const QString &  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 113 of file k3procio.cpp.

bool K3ProcIO::writeStdin ( const QByteArray &  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 118 of file k3procio.cpp.

bool K3ProcIO::writeStdin ( const QByteArray &  data)

Writes data to stdin of the process.

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

Definition at line 147 of file k3procio.cpp.


The documentation for this class was generated from the following files:
  • k3procio.h
  • k3procio.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Jul 16 2013 17:53:31 by doxygen 1.8.1.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

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

kdelibs-4.10.5 API Reference

Skip menu "kdelibs-4.10.5 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal