OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / coreplugin / 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 (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
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
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
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.
24 **
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.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef SFTCHANNEL_P_H
35 #define SFTCHANNEL_P_H
36
37 #include "sftpdefs.h"
38 #include "sftpincomingpacket_p.h"
39 #include "sftpoperation_p.h"
40 #include "sftpoutgoingpacket_p.h"
41 #include "sshchannel_p.h"
42
43 #include <QtCore/QByteArray>
44 #include <QtCore/QMap>
45
46 namespace Core {
47 class SftpChannel;
48 namespace Internal {
49
50 class SftpChannelPrivate : public AbstractSshChannel
51 {
52     Q_OBJECT
53     friend class Core::SftpChannel;
54 public:
55
56     enum SftpState { Inactive, SubsystemRequested, InitSent, Initialized };
57
58     virtual void handleChannelSuccess();
59     virtual void handleChannelFailure();
60
61     virtual void closeHook();
62
63 signals:
64     void initialized();
65     void initializationFailed(const QString &reason);
66     void closed();
67     void finished(Core::SftpJobId job, const QString &error = QString());
68     void dataAvailable(Core::SftpJobId job, const QString &data);
69
70 private:
71     typedef QMap<SftpJobId, AbstractSftpOperation::Ptr> JobMap;
72
73     SftpChannelPrivate(quint32 channelId, SshSendFacility &sendFacility,
74         SftpChannel *sftp);
75     SftpJobId createJob(const AbstractSftpOperation::Ptr &job);
76
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);
84
85     void handleCurrentPacket();
86     void handleServerVersion();
87     void handleHandle();
88     void handleStatus();
89     void handleName();
90     void handleReadData();
91     void handleAttrs();
92
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);
103
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);
108
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,
118         quint32 requestId);
119
120     JobMap::Iterator lookupJob(SftpJobId id);
121     JobMap m_jobs;
122     SftpOutgoingPacket m_outgoingPacket;
123     SftpIncomingPacket m_incomingPacket;
124     QByteArray m_incomingData;
125     SftpJobId m_nextJobId;
126     SftpState m_sftpState;
127     SftpChannel *m_sftp;
128 };
129
130 } // namespace Internal
131 } // namespace Core
132
133 #endif // SFTPCHANNEL_P_H