1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
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 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef SSHCHANNEL_P_H
35 #define SSHCHANNEL_P_H
37 #include <QtCore/QByteArray>
38 #include <QtCore/QObject>
39 #include <QtCore/QString>
41 QT_FORWARD_DECLARE_CLASS(QTimer)
46 struct SshChannelExitSignal;
47 struct SshChannelExitStatus;
48 class SshIncomingPacket;
49 class SshSendFacility;
51 class AbstractSshChannel : public QObject
56 Inactive, SessionRequested, SessionEstablished, CloseRequested, Closed
59 ChannelState channelState() const { return m_state; }
60 void setChannelState(ChannelState state);
62 void setError(const QString &error) { m_errorString = error; }
63 QString errorString() const { return m_errorString; }
65 quint32 localChannelId() const { return m_localChannel; }
66 quint32 remoteChannel() const { return m_remoteChannel; }
68 virtual void handleChannelSuccess()=0;
69 virtual void handleChannelFailure()=0;
71 virtual void closeHook()=0;
73 void handleOpenSuccess(quint32 remoteChannelId, quint32 remoteWindowSize,
74 quint32 remoteMaxPacketSize);
75 void handleOpenFailure(const QString &reason);
76 void handleWindowAdjust(quint32 bytesToAdd);
77 void handleChannelEof();
78 void handleChannelClose();
79 void handleChannelData(const QByteArray &data);
80 void handleChannelExtendedData(quint32 type, const QByteArray &data);
81 void handleChannelRequest(const SshIncomingPacket &packet);
83 void requestSessionStart();
84 void sendData(const QByteArray &data);
87 virtual ~AbstractSshChannel();
89 static const int ReplyTimeout = 10000; // milli seconds
95 AbstractSshChannel(quint32 channelId, SshSendFacility &sendFacility);
97 quint32 maxDataSize() const;
98 void checkChannelActive();
100 SshSendFacility &m_sendFacility;
101 QTimer * const m_timeoutTimer;
104 virtual void handleOpenSuccessInternal()=0;
105 virtual void handleOpenFailureInternal()=0;
106 virtual void handleChannelDataInternal(const QByteArray &data)=0;
107 virtual void handleChannelExtendedDataInternal(quint32 type,
108 const QByteArray &data)=0;
109 virtual void handleExitStatus(const SshChannelExitStatus &exitStatus)=0;
110 virtual void handleExitSignal(const SshChannelExitSignal &signal)=0;
112 void setState(ChannelState newState);
113 void flushSendBuffer();
114 int handleChannelOrExtendedChannelData(const QByteArray &data);
116 const quint32 m_localChannel;
117 quint32 m_remoteChannel;
118 quint32 m_localWindowSize;
119 quint32 m_remoteWindowSize;
120 quint32 m_remoteMaxPacketSize;
121 ChannelState m_state;
122 QByteArray m_sendBuffer;
123 QString m_errorString;
126 } // namespace Internal
129 #endif // SSHCHANNEL_P_H