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 SFTCHANNEL_P_H
35 #define SFTCHANNEL_P_H
38 #include "sftpincomingpacket_p.h"
39 #include "sftpoperation_p.h"
40 #include "sftpoutgoingpacket_p.h"
41 #include "sshchannel_p.h"
43 #include <QtCore/QByteArray>
44 #include <QtCore/QMap>
50 class SftpChannelPrivate : public AbstractSshChannel
53 friend class Core::SftpChannel;
56 enum SftpState { Inactive, SubsystemRequested, InitSent, Initialized };
58 virtual void handleChannelSuccess();
59 virtual void handleChannelFailure();
61 virtual void closeHook();
65 void initializationFailed(const QString &reason);
67 void finished(Core::SftpJobId job, const QString &error = QString());
68 void dataAvailable(Core::SftpJobId job, const QString &data);
71 typedef QMap<SftpJobId, AbstractSftpOperation::Ptr> JobMap;
73 SftpChannelPrivate(quint32 channelId, SshSendFacility &sendFacility,
75 SftpJobId createJob(const AbstractSftpOperation::Ptr &job);
77 virtual void handleOpenSuccessInternal();
78 virtual void handleOpenFailureInternal();
79 virtual void handleChannelDataInternal(const QByteArray &data);
80 virtual void handleChannelExtendedDataInternal(quint32 type,
81 const QByteArray &data);
82 virtual void handleExitStatus(const SshChannelExitStatus &exitStatus);
83 virtual void handleExitSignal(const SshChannelExitSignal &signal);
85 void handleCurrentPacket();
86 void handleServerVersion();
90 void handleReadData();
93 void handleStatusGeneric(const JobMap::Iterator &it,
94 const SftpStatusResponse &response);
95 void handleMkdirStatus(const JobMap::Iterator &it,
96 const SftpStatusResponse &response);
97 void handleLsStatus(const JobMap::Iterator &it,
98 const SftpStatusResponse &response);
99 void handleGetStatus(const JobMap::Iterator &it,
100 const SftpStatusResponse &response);
101 void handlePutStatus(const JobMap::Iterator &it,
102 const SftpStatusResponse &response);
104 void handleLsHandle(const JobMap::Iterator &it);
105 void handleCreateFileHandle(const JobMap::Iterator &it);
106 void handleGetHandle(const JobMap::Iterator &it);
107 void handlePutHandle(const JobMap::Iterator &it);
109 void spawnReadRequests(const SftpDownload::Ptr &job);
110 void spawnWriteRequests(const JobMap::Iterator &it);
111 void sendReadRequest(const SftpDownload::Ptr &job, quint32 requestId);
112 void sendWriteRequest(const JobMap::Iterator &it);
113 void finishTransferRequest(const JobMap::Iterator &it);
114 void removeTransferRequest(const JobMap::Iterator &it);
115 void reportRequestError(const AbstractSftpOperationWithHandle::Ptr &job,
116 const QString &error);
117 void sendTransferCloseHandle(const AbstractSftpTransfer::Ptr &job,
120 JobMap::Iterator lookupJob(SftpJobId id);
122 SftpOutgoingPacket m_outgoingPacket;
123 SftpIncomingPacket m_incomingPacket;
124 QByteArray m_incomingData;
125 SftpJobId m_nextJobId;
126 SftpState m_sftpState;
130 } // namespace Internal
133 #endif // SFTPCHANNEL_P_H