Process running ssh/scp command. More...
#include <urpoprocess.h>
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. |
Process running ssh/scp command.
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(); }
Definition at line 76 of file urpoprocess.h.
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.
Ready |
Ready for connecting. |
Running |
Command running. |
Successed |
Command successed. |
Failed |
Command failed. |
Definition at line 86 of file urpoprocess.h.
UrpoProcess::UrpoProcess | ( | QObject * | parent = 0 |
) | [explicit] |
connection | Pointer to connection settings information |
Definition at line 32 of file urpoprocess.cpp.
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.
message | Message send to debug monitor |
void UrpoProcess::finished | ( | bool | success | ) | [signal] |
Process finished (successed of failed).
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
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
Definition at line 114 of file urpoprocess.cpp.
QStringList UrpoProcess::getOutput | ( | ) |
Get output of command.
Definition at line 45 of file urpoprocess.cpp.
UrpoStatus UrpoProcess::getStatus | ( | ) | const [inline] |
Process status.
Definition at line 135 of file urpoprocess.h.
int UrpoProcess::getTimeout | ( | ) | [inline] |
void UrpoProcess::sendDebugMessage | ( | QString | message | ) | [inline] |
Send debug message.
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
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
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.