OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / coreplugin / ssh / sftppacket_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 SFTPPACKET_P_H
35 #define SFTPPACKET_P_H
36
37 #include <QtCore/QByteArray>
38 #include <QtCore/QList>
39 #include <QtCore/QString>
40
41 namespace Core {
42 namespace Internal {
43
44 enum SftpPacketType {
45     SSH_FXP_INIT = 1,
46     SSH_FXP_VERSION = 2,
47     SSH_FXP_OPEN = 3,
48     SSH_FXP_CLOSE = 4,
49     SSH_FXP_READ = 5,
50     SSH_FXP_WRITE = 6,
51     SSH_FXP_LSTAT = 7,
52     SSH_FXP_FSTAT = 8,
53     SSH_FXP_SETSTAT = 9,
54     SSH_FXP_FSETSTAT = 10,
55     SSH_FXP_OPENDIR = 11,
56     SSH_FXP_READDIR = 12,
57     SSH_FXP_REMOVE = 13,
58     SSH_FXP_MKDIR = 14,
59     SSH_FXP_RMDIR = 15,
60     SSH_FXP_REALPATH = 16,
61     SSH_FXP_STAT = 17,
62     SSH_FXP_RENAME = 18,
63     SSH_FXP_READLINK = 19,
64     SSH_FXP_SYMLINK = 20, // Removed from later protocol versions. Try not to use.
65
66     SSH_FXP_STATUS = 101,
67     SSH_FXP_HANDLE = 102,
68     SSH_FXP_DATA = 103,
69     SSH_FXP_NAME = 104,
70     SSH_FXP_ATTRS = 105,
71
72     SSH_FXP_EXTENDED = 200,
73     SSH_FXP_EXTENDED_REPLY = 201
74 };
75
76 enum SftpStatusCode {
77     SSH_FX_OK = 0,
78     SSH_FX_EOF = 1,
79     SSH_FX_NO_SUCH_FILE = 2,
80     SSH_FX_PERMISSION_DENIED = 3,
81     SSH_FX_FAILURE = 4,
82     SSH_FX_BAD_MESSAGE = 5,
83     SSH_FX_NO_CONNECTION = 6,
84     SSH_FX_CONNECTION_LOST = 7,
85     SSH_FX_OP_UNSUPPORTED = 8
86 };
87
88 class AbstractSftpPacket
89 {
90 public:
91     AbstractSftpPacket();
92     quint32 requestId() const;
93     const QByteArray &rawData() const { return m_data; }
94     SftpPacketType type() const { return static_cast<SftpPacketType>(m_data.at(TypeOffset)); }
95
96     static const quint32 MaxDataSize; // "Pure" data size per read/writepacket.
97     static const quint32 MaxPacketSize;
98
99 protected:
100     quint32 dataSize() const { return static_cast<quint32>(m_data.size()); }
101
102     static const int TypeOffset;
103     static const int RequestIdOffset;
104     static const int PayloadOffset;
105
106     QByteArray m_data;
107 };
108
109 } // namespace Internal
110 } // namespace Core
111
112 #endif // SFTPPACKET_P_H