1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef SFTCHANNEL_P_H
34 #define SFTCHANNEL_P_H
37 #include "sftpincomingpacket_p.h"
38 #include "sftpoperation_p.h"
39 #include "sftpoutgoingpacket_p.h"
40 #include "sshchannel_p.h"
42 #include <QtCore/QByteArray>
43 #include <QtCore/QMap>
49 class SftpChannelPrivate : public AbstractSshChannel
52 friend class Utils::SftpChannel;
55 enum SftpState { Inactive, SubsystemRequested, InitSent, Initialized };
57 virtual void handleChannelSuccess();
58 virtual void handleChannelFailure();
60 virtual void closeHook();
64 void initializationFailed(const QString &reason);
66 void finished(Utils::SftpJobId job, const QString &error = QString());
67 void dataAvailable(Utils::SftpJobId job, const QString &data);
70 typedef QMap<SftpJobId, AbstractSftpOperation::Ptr> JobMap;
72 SftpChannelPrivate(quint32 channelId, SshSendFacility &sendFacility,
74 SftpJobId createJob(const AbstractSftpOperation::Ptr &job);
76 virtual void handleOpenSuccessInternal();
77 virtual void handleOpenFailureInternal();
78 virtual void handleChannelDataInternal(const QByteArray &data);
79 virtual void handleChannelExtendedDataInternal(quint32 type,
80 const QByteArray &data);
81 virtual void handleExitStatus(const SshChannelExitStatus &exitStatus);
82 virtual void handleExitSignal(const SshChannelExitSignal &signal);
84 void handleCurrentPacket();
85 void handleServerVersion();
89 void handleReadData();
92 void handleStatusGeneric(const JobMap::Iterator &it,
93 const SftpStatusResponse &response);
94 void handleMkdirStatus(const JobMap::Iterator &it,
95 const SftpStatusResponse &response);
96 void handleLsStatus(const JobMap::Iterator &it,
97 const SftpStatusResponse &response);
98 void handleGetStatus(const JobMap::Iterator &it,
99 const SftpStatusResponse &response);
100 void handlePutStatus(const JobMap::Iterator &it,
101 const SftpStatusResponse &response);
103 void handleLsHandle(const JobMap::Iterator &it);
104 void handleCreateFileHandle(const JobMap::Iterator &it);
105 void handleGetHandle(const JobMap::Iterator &it);
106 void handlePutHandle(const JobMap::Iterator &it);
108 void spawnReadRequests(const SftpDownload::Ptr &job);
109 void spawnWriteRequests(const JobMap::Iterator &it);
110 void sendReadRequest(const SftpDownload::Ptr &job, quint32 requestId);
111 void sendWriteRequest(const JobMap::Iterator &it);
112 void finishTransferRequest(const JobMap::Iterator &it);
113 void removeTransferRequest(const JobMap::Iterator &it);
114 void reportRequestError(const AbstractSftpOperationWithHandle::Ptr &job,
115 const QString &error);
116 void sendTransferCloseHandle(const AbstractSftpTransfer::Ptr &job,
119 JobMap::Iterator lookupJob(SftpJobId id);
121 SftpOutgoingPacket m_outgoingPacket;
122 SftpIncomingPacket m_incomingPacket;
123 QByteArray m_incomingData;
124 SftpJobId m_nextJobId;
125 SftpState m_sftpState;
129 } // namespace Internal
132 #endif // SFTPCHANNEL_P_H