MoleQueue  0.8.0
 All Classes Functions Variables Enumerations Enumerator Pages
Public Slots | Signals | Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
SshConnection Class Reference

#include <molequeue/sshconnection.h>

Inheritance diagram for SshConnection:
SshCommand OpenSshCommand PuttyCommand

Public Slots

void setPersistent (bool persist)
 
void setUserName (const QString &newUserName)
 
void setHostName (const QString &newHostName)
 
void setIdentityFile (const QString &newIdentityFile)
 
void setPortNumber (int newPortNumber)
 
virtual bool execute (const QString &command)
 
virtual bool copyTo (const QString &localFile, const QString &remoteFile)
 
virtual bool copyFrom (const QString &remoteFile, const QString &localFile)
 
virtual bool copyDirTo (const QString &localDir, const QString &remoteDir)
 
virtual bool copyDirFrom (const QString &remoteDir, const QString &localDir)
 

Signals

void requestSent ()
 
void requestComplete ()
 

Public Member Functions

 SshConnection (QObject *parentObject=0)
 
bool isPersistent () const
 
QString userName () const
 
QString hostName () const
 
QString identityFile () const
 
int portNumber () const
 
virtual bool isValid () const
 
virtual QString output () const
 
virtual int exitCode () const
 
virtual bool waitForCompletion (int msecs=30000)
 
virtual bool isComplete () const
 
QVariant & data ()
 
const QVariant & data () const
 
void setData (const QVariant &newData)
 

Static Protected Member Functions

static bool debug ()
 

Protected Attributes

bool m_persistent
 
QVariant m_data
 
QString m_userName
 
QString m_hostName
 
QString m_identityFile
 
int m_portNumber
 

Detailed Description

Abstract base class defining remote execution and file transfer operations over the ssh protocol.

Author
Marcus D. Hanwell, David C. Lonie

The SshConnection is the interface to use when writing code that requires interactions with a remote host. Subclasses provide concrete implementations of the interface, e.g. SshCommand, which calls the ssh and scp commands in a TerminalProcess.

Member Function Documentation

bool isPersistent ( ) const
Returns
If the SSH connection is set as persistent or not.
QString userName ( ) const
Returns
The user name that will be used.
QString hostName ( ) const
Returns
The host that will be used.
QString identityFile ( ) const
Returns
The path to the identity file that will be used.
int portNumber ( ) const
Returns
The port that will be used.
virtual bool isValid ( ) const
virtual
Returns
Whether the connection is valid, at a minimum need a host name.
virtual QString output ( ) const
virtual
Returns
The merged stdout and stderr of the remote command.

Reimplemented in SshCommand.

virtual int exitCode ( ) const
virtual
Returns
The exit code returned from a remote command.

Reimplemented in SshCommand.

virtual bool waitForCompletion ( int  msecs = 30000)
virtual

Wait until the request has been completed.

Parameters
msecsTimeout in milliseconds. Default is 30 seconds.
Returns
True if request finished, false on timeout.

Reimplemented in SshCommand.

virtual bool isComplete ( ) const
virtual
Returns
True if the request has completed. False otherwise.

Reimplemented in SshCommand.

QVariant& data ( )
Returns
A reference to arbitrary data stored in the command.
const QVariant& data ( ) const
Returns
A reference to arbitrary data stored in the command.
void setData ( const QVariant &  newData)
Parameters
newDataArbitrary data to store in the command.
void setPersistent ( bool  persist)
slot

Set whether the connection should be persistent, or each issuesd command uses a short-lived connection, e.g. on the command line a non-persistent connection would be the equivalent of,

ssh user ls

void setUserName ( const QString &  newUserName)
slot

Set the user name to use for the connection.

void setHostName ( const QString &  newHostName)
slot

Set the host name to use for the connection.

void setIdentityFile ( const QString &  newIdentityFile)
slot

Set the identity file to use for the connection. This is the path to the private key to be used when establishing the connection.

void setPortNumber ( int  newPortNumber)
slot

Set the host name to use for the connection.

virtual bool execute ( const QString &  command)
virtualslot

Execute the supplied command on the remote host.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See Also
requestSent() requestCompleted() waitForCompeletion()
Parameters
commandThe command to execute.
Returns
True on success, false on failure.
virtual bool copyTo ( const QString &  localFile,
const QString &  remoteFile 
)
virtualslot

Copy a local file to the remote system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See Also
requestSent() requestCompleted() waitForCompeletion()
Parameters
localFileThe path of the local file.
remoteFileThe path of the file on the remote system.
Returns
True on success, false on failure.
virtual bool copyFrom ( const QString &  remoteFile,
const QString &  localFile 
)
virtualslot

Copy a remote file to the local system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See Also
requestSent() requestCompleted() waitForCompeletion()
Parameters
remoteFileThe path of the file on the remote system.
localFileThe path of the local file.
Returns
True on success, false on failure.
virtual bool copyDirTo ( const QString &  localDir,
const QString &  remoteDir 
)
virtualslot

Copy a local directory recursively to the remote system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See Also
requestSent() requestCompleted() waitForCompeletion()
Parameters
localDirThe path of the local directory.
remoteDirThe path of the directory on the remote system.
Returns
True on success, false on failure.
virtual bool copyDirFrom ( const QString &  remoteDir,
const QString &  localDir 
)
virtualslot

Copy a remote directory recursively to the local system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See Also
requestSent() requestCompleted() waitForCompeletion()
Parameters
remoteDirThe path of the directory on the remote system.
localFileThe path of the local directory.
Returns
True on success, false on failure.
void requestSent ( )
signal

Emitted when the request has been sent to the server.

void requestComplete ( )
signal

Emitted when the request has been sent and the reply (if any) received.


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