OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / utils / ssh / sftpchannel_p.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef SFTCHANNEL_P_H
34 #define SFTCHANNEL_P_H
35
36 #include "sftpdefs.h"
37 #include "sftpincomingpacket_p.h"
38 #include "sftpoperation_p.h"
39 #include "sftpoutgoingpacket_p.h"
40 #include "sshchannel_p.h"
41
42 #include <QtCore/QByteArray>
43 #include <QtCore/QMap>
44
45 namespace Utils {
46 class SftpChannel;
47 namespace Internal {
48
49 class SftpChannelPrivate : public AbstractSshChannel
50 {
51     Q_OBJECT
52     friend class Utils::SftpChannel;
53 public:
54
55     enum SftpState { Inactive, SubsystemRequested, InitSent, Initialized };
56
57     virtual void handleChannelSuccess();
58     virtual void handleChannelFailure();
59
60     virtual void closeHook();
61
62 signals:
63     void initialized();
64     void initializationFailed(const QString &reason);
65     void closed();
66     void finished(Utils::SftpJobId job, const QString &error = QString());
67     void dataAvailable(Utils::SftpJobId job, const QString &data);
68
69 private:
70     typedef QMap<SftpJobId, AbstractSftpOperation::Ptr> JobMap;
71
72     SftpChannelPrivate(quint32 channelId, SshSendFacility &sendFacility,
73         SftpChannel *sftp);
74     SftpJobId createJob(const AbstractSftpOperation::Ptr &job);
75
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);
83
84     void handleCurrentPacket();
85     void handleServerVersion();
86     void handleHandle();
87     void handleStatus();
88     void handleName();
89     void handleReadData();
90     void handleAttrs();
91
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);
102
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);
107
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,
117         quint32 requestId);
118
119     JobMap::Iterator lookupJob(SftpJobId id);
120     JobMap m_jobs;
121     SftpOutgoingPacket m_outgoingPacket;
122     SftpIncomingPacket m_incomingPacket;
123     QByteArray m_incomingData;
124     SftpJobId m_nextJobId;
125     SftpState m_sftpState;
126     SftpChannel *m_sftp;
127 };
128
129 } // namespace Internal
130 } // namespace Utils
131
132 #endif // SFTPCHANNEL_P_H