1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
28 **************************************************************************/
30 #ifndef SSHCONNECTION_H
31 #define SSHCONNECTION_H
33 #include "ssherrors.h"
35 #include <coreplugin/core_global.h>
37 #include <QtCore/QByteArray>
38 #include <QtCore/QObject>
39 #include <QtCore/QSharedPointer>
40 #include <QtCore/QString>
44 class SshRemoteProcess;
47 class SshConnectionPrivate;
48 } // namespace Internal
50 struct CORE_EXPORT SshConnectionParameters
52 enum ProxyType { DefaultProxy, NoProxy };
53 SshConnectionParameters(ProxyType proxyType);
58 QString privateKeyFile;
60 enum AuthType { AuthByPwd, AuthByKey } authType;
65 CORE_EXPORT bool operator==(const SshConnectionParameters &p1, const SshConnectionParameters &p2);
66 CORE_EXPORT bool operator!=(const SshConnectionParameters &p1, const SshConnectionParameters &p2);
69 * This class provides an SSH connection, implementing protocol version 2.0
70 * It can spawn channels for remote execution and SFTP operations (version 3).
71 * It operates asynchronously (non-blocking) and is not thread-safe.
73 class CORE_EXPORT SshConnection : public QObject
76 Q_DISABLE_COPY(SshConnection)
78 enum State { Unconnected, Connecting, Connected };
79 typedef QSharedPointer<SshConnection> Ptr;
83 void connectToHost(const SshConnectionParameters &serverInfo);
84 void disconnectFromHost();
86 SshError errorState() const;
87 QString errorString() const;
88 SshConnectionParameters connectionParameters() const;
91 QSharedPointer<SshRemoteProcess> createRemoteProcess(const QByteArray &command);
92 QSharedPointer<SftpChannel> createSftpChannel();
97 void dataAvailable(const QString &message);
98 void error(Core::SshError);
103 Internal::SshConnectionPrivate *d;
106 } // namespace Internal
108 #endif // SSHCONNECTION_H