org.kde.koala

Class KProcIO

public class KProcIO extends KProcess

KProcIO This class provides a slightly simpler interface to the communication functions provided by KProcess. The simplifications are:
  • The buffer for a write is copied to an internal KProcIO 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, KProcIO 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 KProcess. See KProcIOSignals for signals emitted by KProcIO

    Author: David Sweet

    UNKNOWN: A slightly simpler interface to KProcess.

    Constructor Summary
    protected KProcIO(Class dummy)
    KProcIO(QTextCodec codec)
    Constructor
    KProcIO()
    Method Summary
    voidackRead()
    Call this after you have finished processing a readReady() signal.
    StringclassName()
    voidcloseWhenDone()
    Closes stdin after all data has been send.
    protected voidcontrolledEmission()
    voiddispose()
    Delete the wrapped C++ instance ahead of finalize()
    voidenableReadSignals(boolean enable)
    Turns readReady() signals on and off.
    protected voidfinalize()
    Deletes the wrapped C++ instance
    booleanisDisposed()
    Has the wrapped C++ instance been deleted?
    QMetaObjectmetaObject()
    intreadln(StringBuffer line, boolean autoAck, boolean[] partial)
    Reads a line of text (up to and including '\\n').
    intreadln(StringBuffer line, boolean autoAck)
    intreadln(StringBuffer line)
    protected voidreceived(KProcess proc, String buffer, int buflen)
    voidresetAll()
    Reset the class.
    protected voidsent(KProcess arg1)
    voidsetComm(int comm)
    Sets the communication mode to be passed to KProcess.start() by start().
    booleanstart(int runmode, boolean includeStderr)
    Starts the process.
    booleanstart(int runmode)
    booleanstart()
    booleanwriteStdin(String line, boolean appendnewline)
    Writes text to stdin of the process.
    booleanwriteStdin(String line)
    booleanwriteStdin(byte[] data)
    Writes data to stdin of the process.

    Constructor Detail

    KProcIO

    protected KProcIO(Class dummy)

    KProcIO

    public KProcIO(QTextCodec codec)
    Constructor

    UNKNOWN: Constructor

    KProcIO

    public KProcIO()

    Method Detail

    ackRead

    public void 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.

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

    className

    public String className()

    closeWhenDone

    public void closeWhenDone()
    Closes stdin after all data has been send.

    UNKNOWN: Closes stdin after all data has been send.

    controlledEmission

    protected void controlledEmission()

    dispose

    public void dispose()
    Delete the wrapped C++ instance ahead of finalize()

    enableReadSignals

    public void enableReadSignals(boolean 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: enable true to turn the signals on, false to turn them off

    UNKNOWN: Turns readReady() signals on and off.

    finalize

    protected void finalize()
    Deletes the wrapped C++ instance

    isDisposed

    public boolean isDisposed()
    Has the wrapped C++ instance been deleted?

    metaObject

    public QMetaObject metaObject()

    readln

    public int readln(StringBuffer line, boolean autoAck, boolean[] partial)
    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 KProcIO that you are ready for another readReady() signal. readln() never blocks. autoAck==true makes these functions call ackRead() for you.

    Parameters: line is used to store the line that was read. autoAck when true, ackRead() is called for you. partial when 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.

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

    readln

    public int readln(StringBuffer line, boolean autoAck)

    readln

    public int readln(StringBuffer line)

    received

    protected void received(KProcess proc, String buffer, int buflen)

    resetAll

    public void resetAll()
    Reset the class. Doesn't kill the process.

    UNKNOWN: Reset the class.

    sent

    protected void sent(KProcess arg1)

    setComm

    public void setComm(int comm)
    Sets the communication mode to be passed to KProcess.start() by start(). The default communication mode is KProcess.All. You probably want to use this function in conjunction with KProcess.setUsePty().

    Parameters: comm the communication mode

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

    start

    public boolean start(int runmode, boolean includeStderr)
    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: runmode For a detailed description of the various run modes, have a look at the general description of the KProcess class. includeStderr If true, data from both stdout and stderr is listened to. If false, only stdout is listened to.

    Returns: true on success, false on error.

    UNKNOWN: Starts the process.

    start

    public boolean start(int runmode)

    start

    public boolean start()

    writeStdin

    public boolean writeStdin(String line, boolean appendnewline)
    Writes text to stdin of the process.

    Parameters: line Text to write. appendnewline if true, a newline '\\n' is appended.

    Returns: true if successful, false otherwise

    UNKNOWN: Writes text to stdin of the process.

    writeStdin

    public boolean writeStdin(String line)

    writeStdin

    public boolean writeStdin(byte[] data)
    Writes data to stdin of the process.

    Parameters: data Data to write.

    Returns: true if successful, false otherwise

    UNKNOWN: Writes data to stdin of the process.