UrpoProcess Class Reference

Process running ssh/scp command. More...

#include <urpoprocess.h>

List of all members.

Public Types

enum  UrpoStatus { Ready = 0, Running = 1, Successed = 2, Failed = 3 }
enum  UrpoError {
  NoError = 0, ProcessError = 1, ConnectionError = 2, AuthError = 3,
  Timeout = 4, Cancelled = 5
}

Public Slots

void terminate ()
 Cancel process.
void processFinished (int exitCode, QProcess::ExitStatus exitStatus)
 SSH client has finished.
void timeout ()
 Timeout during connecting.

Signals

void finished (bool success)
 Process finished (successed of failed).
void debugMessage (QString message)

Public Member Functions

 UrpoProcess (QObject *parent=0)
QStringList getOutput ()
 Get output of command.
void start (const QString &command)
 Run command.
UrpoError getError () const
 Error of process.
QString getErrorString () const
 Error of process (in string).
UrpoStatus getStatus () const
 Process status.
void sendDebugMessage (QString message)
 Send debug message.
void setTimeout (int msecs)
 Set timeout.
int getTimeout ()
 Return timeout.

Detailed Description

Process running ssh/scp command.

Author:
Arto Hyv├Ąttinen
Version:
0
Date:
2010-06-11 - 2010-06-12

Run ssh/scp etc. command.

Read setting using UrpoConnect settings information object. Support debug monitoring using debugMessage-signals, monitor defined in settings object

First, connect finished()-signal. Then, run command. Command is run asynchronosly.

  ...
  // Get list of available printers

    QString command = "ssh ";
    command.append(getConnection()->getKeyOption());
    command.append(getConnection()->getHostString());
    command.append(" env LANG=en lpstat -p");

    process = new UrpoProcess( connect );

  connect( process, SIGNAL(finished(bool)), this, SLOT( readOutput(bool) ) );
  process.start(command);

  ...
  ::readOutput(bool success)
  {
    if( success )
    {
        foreach(QString line, process->getOutput() )
        cout << line << "\n";
    }
    else
        cout << "Error " << process->getError();
  }
See also:
UrpoConnect

Definition at line 76 of file urpoprocess.h.


Member Enumeration Documentation

Enumerator:
NoError 

No errors happends.

ProcessError 

Error running process.

ConnectionError 

Error connecting host.

AuthError 

Authentication failed.

Timeout 

Timed out.

Cancelled 

User cancelled operation.

Definition at line 93 of file urpoprocess.h.

Enumerator:
Ready 

Ready for connecting.

Running 

Command running.

Successed 

Command successed.

Failed 

Command failed.

Definition at line 86 of file urpoprocess.h.


Constructor & Destructor Documentation

UrpoProcess::UrpoProcess ( QObject *  parent = 0  )  [explicit]
Parameters:
connection Pointer to connection settings information

Definition at line 32 of file urpoprocess.cpp.


Member Function Documentation

void UrpoProcess::debugMessage ( QString  message  )  [signal]

Send debug messages

UrpoConnection can set up a debug monitor, a QObject receiving debugMsg signals. Debug messages contains information about process output, errors etc.

Parameters:
message Message send to debug monitor
void UrpoProcess::finished ( bool  success  )  [signal]

Process finished (successed of failed).

Parameters:
success True if process successed, false if failed

Emitted when process finished. Output of process can be reader throught getOutput()

UrpoError UrpoProcess::getError (  )  const [inline]

Error of process.

If process failed, get error code

Returns:
Error code

Definition at line 121 of file urpoprocess.h.

QString UrpoProcess::getErrorString (  )  const

Error of process (in string).

If process failed, return error string readable by user

Returns:
Error string

Definition at line 114 of file urpoprocess.cpp.

QStringList UrpoProcess::getOutput (  ) 

Get output of command.

Returns:
Output of command, list of QStrings

Definition at line 45 of file urpoprocess.cpp.

UrpoStatus UrpoProcess::getStatus (  )  const [inline]

Process status.

Returns:
Status (Ready, Running, Successed, Failed)

Definition at line 135 of file urpoprocess.h.

int UrpoProcess::getTimeout (  )  [inline]

Return timeout.

Returns:
Timeout in msecs

Definition at line 159 of file urpoprocess.h.

void UrpoProcess::sendDebugMessage ( QString  message  )  [inline]

Send debug message.

Parameters:
message Message to debug monitor

If debug monitor has been connected, send message to debug monitor

Definition at line 145 of file urpoprocess.h.

void UrpoProcess::setTimeout ( int  msecs  )  [inline]

Set timeout.

Process time out, if running command last more than timeout

Parameters:
msecs Timeout in msecs

Definition at line 154 of file urpoprocess.h.

void UrpoProcess::start ( const QString &  command  ) 

Run command.

Start process running command. When process finish (successed/failed), finished() signal will be emitted

Parameters:
command Command to execute

Definition at line 67 of file urpoprocess.cpp.

void UrpoProcess::terminate (  )  [slot]

Cancel process.

Terminate process. Emit finished(false) signal and set Cancelled error

Definition at line 40 of file urpoprocess.cpp.


The documentation for this class was generated from the following files:
Generated on Mon Sep 27 18:46:05 2010 for Urpo by  doxygen 1.6.3