Files
qt-creator/src/libs/utils/ssh/sshchannel_p.h

129 lines
4.0 KiB
C
Raw Normal View History

2010-07-12 09:33:22 +02:00
/**************************************************************************
**
** This file is part of Qt Creator
**
2011-01-11 16:28:15 +01:00
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
2010-07-12 09:33:22 +02:00
**
2011-04-13 08:42:33 +02:00
** Contact: Nokia Corporation (info@qt.nokia.com)
2010-07-12 09:33:22 +02:00
**
**
** GNU Lesser General Public License Usage
**
2011-04-13 08:42:33 +02:00
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
2010-07-12 09:33:22 +02:00
**
2010-12-17 16:01:08 +01:00
** In addition, as a special exception, Nokia gives you certain additional
2011-04-13 08:42:33 +02:00
** rights. These rights are described in the Nokia Qt LGPL Exception
2010-12-17 16:01:08 +01:00
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
2011-04-13 08:42:33 +02:00
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
2010-12-17 16:01:08 +01:00
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
2010-07-12 09:33:22 +02:00
**
**************************************************************************/
#ifndef SSHCHANNEL_P_H
#define SSHCHANNEL_P_H
#include <QtCore/QByteArray>
#include <QtCore/QObject>
2010-07-12 09:33:22 +02:00
#include <QtCore/QString>
QT_FORWARD_DECLARE_CLASS(QTimer)
2010-08-17 09:22:43 +02:00
namespace Utils {
2010-07-12 09:33:22 +02:00
namespace Internal {
2010-08-24 20:53:15 +02:00
struct SshChannelExitSignal;
struct SshChannelExitStatus;
2010-07-12 09:33:22 +02:00
class SshIncomingPacket;
class SshSendFacility;
class AbstractSshChannel : public QObject
2010-07-12 09:33:22 +02:00
{
Q_OBJECT
2010-07-12 09:33:22 +02:00
public:
enum ChannelState {
Inactive, SessionRequested, SessionEstablished, CloseRequested, Closed
};
ChannelState channelState() const { return m_state; }
void setChannelState(ChannelState state);
void setError(const QString &error) { m_errorString = error; }
QString errorString() const { return m_errorString; }
quint32 localChannelId() const { return m_localChannel; }
quint32 remoteChannel() const { return m_remoteChannel; }
virtual void handleChannelSuccess()=0;
virtual void handleChannelFailure()=0;
virtual void closeHook()=0;
void handleOpenSuccess(quint32 remoteChannelId, quint32 remoteWindowSize,
quint32 remoteMaxPacketSize);
void handleOpenFailure(const QString &reason);
void handleWindowAdjust(quint32 bytesToAdd);
void handleChannelEof();
void handleChannelClose();
void handleChannelData(const QByteArray &data);
void handleChannelExtendedData(quint32 type, const QByteArray &data);
void handleChannelRequest(const SshIncomingPacket &packet);
2010-07-12 09:33:22 +02:00
void requestSessionStart();
void sendData(const QByteArray &data);
void closeChannel();
virtual ~AbstractSshChannel();
2010-08-17 09:22:43 +02:00
static const int ReplyTimeout = 10000; // milli seconds
signals:
void timeout();
2010-07-12 09:33:22 +02:00
protected:
AbstractSshChannel(quint32 channelId, SshSendFacility &sendFacility);
quint32 maxDataSize() const;
void checkChannelActive();
SshSendFacility &m_sendFacility;
2010-08-17 09:22:43 +02:00
QTimer * const m_timeoutTimer;
2010-07-12 09:33:22 +02:00
private:
virtual void handleOpenSuccessInternal()=0;
virtual void handleOpenFailureInternal()=0;
virtual void handleChannelDataInternal(const QByteArray &data)=0;
virtual void handleChannelExtendedDataInternal(quint32 type,
const QByteArray &data)=0;
virtual void handleExitStatus(const SshChannelExitStatus &exitStatus)=0;
virtual void handleExitSignal(const SshChannelExitSignal &signal)=0;
2010-07-12 09:33:22 +02:00
void setState(ChannelState newState);
void flushSendBuffer();
int handleChannelOrExtendedChannelData(const QByteArray &data);
const quint32 m_localChannel;
quint32 m_remoteChannel;
quint32 m_localWindowSize;
quint32 m_remoteWindowSize;
quint32 m_remoteMaxPacketSize;
ChannelState m_state;
QByteArray m_sendBuffer;
QString m_errorString;
};
} // namespace Internal
} // namespace Utils
2010-07-12 09:33:22 +02:00
#endif // SSHCHANNEL_P_H