Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes
CAExternProgram Class Reference

Start a program as extern background process. More...

#include <externprogram.h>

Inheritance diagram for CAExternProgram:
Inheritance graph
[legend]

List of all members.

Signals

void nextOutput (const QByteArray &roData)
void programExited (int iExitCode)

Public Member Functions

 CAExternProgram (bool bRcvStdErr=true, bool bRcvStdOut=true)
 ~CAExternProgram ()
void setProgramName (const QString &roProgram)
void setProgramPath (const QString &roPath)
void setParameters (const QStringList &roParams)
void setParamDelimiter (QString oDelimiter=" ")
const QStringList & getParameters ()
bool getRunning ()
const QString & getParamDelimiter ()
int getExitState ()
void addParameter (const QString &roParam, bool bAddDelimiter=true)
void clearParameters ()
bool execProgram (const QString &roCwd=".")
bool waitForFinished (int iMSecs)

Protected Slots

void rcvProgramStdOut ()
void rcvProgramStdErr ()
void programError (QProcess::ProcessError)
void programFinished (int, QProcess::ExitStatus)

Protected Member Functions

void rcvProgramOutput (const QByteArray &roData)
void programExited ()

Protected Attributes

QProcess * _poExternProgram
QString _oProgramName
QString _oProgramPath
QStringList _oParameters
QString _oParamDelimiter
bool _bRcvStdErr

Detailed Description

Start a program as extern background process.

Copyright (c) 2006-2008, Reinhard Katzmann, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.

Copyright (c) 2006-2008, Reinhard Katzmann, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.

    This class is used to start an extern program as background process.
    Parameters are the program name and it's parameters
    The output of the program can be fetched via signal/slots
    Another signal is sent when the program finished including it's state

    Constructor: If the stderr output should not be shown, \a bRcvStdErr has
                 has to be set to false.

Constructor & Destructor Documentation

CAExternProgram::CAExternProgram ( bool  bRcvStdErr = true,
bool  bRcvStdOut = true 
)

References _poExternProgram.


Member Function Documentation

void CAExternProgram::addParameter ( const QString &  roParam,
bool  bAddDelimiter = true 
)

Adds a new parameter to the list of parameters

This method allows a fine grain control of the parameters being added to the program. Beside the oParam the delimiter is automatically add inserted if you don't set bAddDelimiter to false (the delimiter defaults to a single space character)

See also:
setParameters( QString oParams )
setParamDelimiter( QString oDelimiter )

References _oParamDelimiter, and _oParameters.

Referenced by CATypesetCtl::exportDocument(), CATypesetCtl::runTypesetter(), and CATypesetCtl::setTSetOption().

Here is the caller graph for this function:

References _oParameters.

Referenced by CATypesetCtl::exportDocument().

Here is the caller graph for this function:

bool CAExternProgram::execProgram ( const QString &  roCwd = ".")

Runs the program in the specified oCwd (working directory)

This method tries to start the specified program using the specified parameters. If a working directory is specified the it is applied to the process before the program starts. Errors on start are immediately reported to the error console.

See also:
setParameters( QString oParams )
setProgram( QString oProgram )

References _oParameters, _oProgramName, _oProgramPath, and _poExternProgram.

Referenced by CATypesetCtl::createPDF(), and CATypesetCtl::runTypesetter().

Here is the caller graph for this function:

Returns the exit status of the finished program

Returns "-1" if the program is still running, else the exist status of the process

See also:
setProgramName( QString oProgram )
QProcess::exitStatus()

References _poExternProgram, and getRunning().

Here is the call graph for this function:

References _oParamDelimiter.

const QStringList& CAExternProgram::getParameters ( ) [inline]

References _oParameters.

bool CAExternProgram::getRunning ( ) [inline]

References _poExternProgram.

Referenced by getExitState(), and programExited().

Here is the caller graph for this function:

void CAExternProgram::nextOutput ( const QByteArray &  roData) [signal]

Referenced by rcvProgramOutput().

Here is the caller graph for this function:

void CAExternProgram::programError ( QProcess::ProcessError  ) [inline, protected, slot]

References programExited().

Referenced by CAExternProgram().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAExternProgram::programExited ( int  iExitCode) [signal]
void CAExternProgram::programExited ( ) [protected]

This slot sends a signal when the extern program is finished or reports an error

To get acknowledged by the program end and when an error occurs connect to the signal programExited. Only errors leading to a program crash are reported this way others are only put out to the console

See also:
QProcess::setProgram( QString oProgram )

References _oProgramName, _poExternProgram, and getRunning().

Referenced by programError(), and programFinished().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAExternProgram::programFinished ( int  ,
QProcess::ExitStatus   
) [inline, protected, slot]

References programExited().

Referenced by CAExternProgram().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAExternProgram::rcvProgramOutput ( const QByteArray &  roData) [protected]

This method sends a signal when data is received by the extern program

To receive data from the extern program create a signal/slot connection to the nextOutput signal. This class does not cache any data! The roData contains the data received by the process output to either stdout or stderr. Use the constructor to define if you don't wish to either receive standartd output or standard error.

See also:
QProcess::setProgram( QString oProgram )

References nextOutput().

Referenced by rcvProgramStdErr(), and rcvProgramStdOut().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAExternProgram::rcvProgramStdErr ( ) [inline, protected, slot]

References _poExternProgram, and rcvProgramOutput().

Referenced by CAExternProgram().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAExternProgram::rcvProgramStdOut ( ) [inline, protected, slot]

References _poExternProgram, and rcvProgramOutput().

Referenced by CAExternProgram().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAExternProgram::setParamDelimiter ( QString  oDelimiter = " ") [inline]

References _oParamDelimiter.

void CAExternProgram::setParameters ( const QStringList &  roParams)
  Defines the parameters of the program to be run

  This method let's you define all the \a oParams being added
  to the executable name at once. It removed all existant parameters.

If you need a finer parameter control you can use this method to just define the first parameter if you need to change them.

  \sa addParameter( QString oParam, bool bAddSpaces = true )
  \sa setProgramName( QString oProgram )

References _oParameters.

Referenced by CATypesetCtl::setPS2PDF().

Here is the caller graph for this function:

void CAExternProgram::setProgramName ( const QString &  roProgram)

Defines the program executable name to be run

This method let's you define the oProgramm executable name. If the program cannot be found in the PATH then you either need to add it to the program name or define it separately via setProgramPath

See also:
setParameters( QString oParams )
setProgramPath( QString oPath )
execProgram( QString oCwd )

References _oProgramName.

Referenced by CATypesetCtl::setPS2PDF(), and CATypesetCtl::setTypesetter().

Here is the caller graph for this function:

void CAExternProgram::setProgramPath ( const QString &  roPath)

Defines the program path of the program executable

This method let's you define the oPath name where the executable name can be found. You only need to set it if the program executable name cannot be found in the PATH.

See also:
setProgramName( QString oProgram )

References _oProgramPath.

Referenced by CATypesetCtl::setPS2PDF(), and CATypesetCtl::setTypesetter().

Here is the caller graph for this function:

bool CAExternProgram::waitForFinished ( int  iMSecs) [inline]

References _poExternProgram.

Referenced by CATypesetCtl::waitForFinished().

Here is the caller graph for this function:


Member Data Documentation

bool CAExternProgram::_bRcvStdErr [protected]

Referenced by CAExternProgram().

QString CAExternProgram::_oParamDelimiter [protected]
QStringList CAExternProgram::_oParameters [protected]
QString CAExternProgram::_oProgramName [protected]
QString CAExternProgram::_oProgramPath [protected]

Referenced by execProgram(), and setProgramPath().

QProcess* CAExternProgram::_poExternProgram [protected]

The documentation for this class was generated from the following files: