00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef SSHCONNECTION_H
00016 #define SSHCONNECTION_H
00017
00018 #ifdef ENABLE_SSH
00019
00020 #include <QtCore/QObject>
00021 #include <QtCore/QString>
00022
00023 namespace GlobalSearch {
00024 class OptBase;
00025 class SSHManager;
00026
00037 class SSHConnection : public QObject
00038 {
00039 Q_OBJECT
00040
00041 public:
00043 enum SSHConnectionException {
00045 SSH_CONNECTION_ERROR = 1,
00049 SSH_UNKNOWN_HOST_ERROR,
00051 SSH_BAD_PASSWORD_ERROR,
00053 SSH_UNKNOWN_ERROR
00054 };
00055
00061 explicit SSHConnection(SSHManager *parent = 0);
00062
00066 virtual ~SSHConnection();
00067
00069 QString getUser() {return m_user;};
00071 QString getHost() {return m_host;};
00073 int getPort() {return m_port;};
00074
00075 public slots:
00084 virtual void setLoginDetails(const QString &host,
00085 const QString &user = "",
00086 const QString &pass = "",
00087 int port = 22);
00088
00099 virtual bool execute(const QString &command,
00100 QString &stdout_str,
00101 QString &stderr_str,
00102 int &exitcode) = 0;
00103
00112 virtual bool copyFileToServer(const QString & localpath,
00113 const QString & remotepath) = 0;
00114
00123 virtual bool copyFileFromServer(const QString & remotepath,
00124 const QString & localpath) = 0;
00125
00135 virtual bool readRemoteFile(const QString &filename,
00136 QString &contents) = 0;
00137
00145 virtual bool removeRemoteFile(const QString &filename) = 0;
00146
00155 virtual bool copyDirectoryToServer(const QString & localpath,
00156 const QString & remotepath) = 0;
00157
00166 virtual bool copyDirectoryFromServer(const QString & remotepath,
00167 const QString & localpath) = 0;
00168
00177 virtual bool readRemoteDirectoryContents(const QString & remotepath,
00178 QStringList & contents) = 0;
00179
00189 virtual bool removeRemoteDirectory(const QString & remotepath,
00190 bool onlyDeleteContents = false) = 0;
00191
00192 protected:
00193 QString m_host;
00194 QString m_user;
00195 QString m_pass;
00196 int m_port;
00197 };
00198
00199 }
00200
00201
00202 #endif // ENABLE_SSH
00203 #endif // SSHCONNECTION_H