|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtNetwork module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
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 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
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 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QFTP_H |
|
43 #define QFTP_H |
|
44 |
|
45 #include <QtCore/qstring.h> |
|
46 #include <QtNetwork/qurlinfo.h> |
|
47 #include <QtCore/qobject.h> |
|
48 |
|
49 QT_BEGIN_HEADER |
|
50 |
|
51 QT_BEGIN_NAMESPACE |
|
52 |
|
53 QT_MODULE(Network) |
|
54 |
|
55 #ifndef QT_NO_FTP |
|
56 |
|
57 class QFtpPrivate; |
|
58 |
|
59 class Q_NETWORK_EXPORT QFtp : public QObject |
|
60 { |
|
61 Q_OBJECT |
|
62 |
|
63 public: |
|
64 explicit QFtp(QObject *parent = 0); |
|
65 virtual ~QFtp(); |
|
66 |
|
67 enum State { |
|
68 Unconnected, |
|
69 HostLookup, |
|
70 Connecting, |
|
71 Connected, |
|
72 LoggedIn, |
|
73 Closing |
|
74 }; |
|
75 enum Error { |
|
76 NoError, |
|
77 UnknownError, |
|
78 HostNotFound, |
|
79 ConnectionRefused, |
|
80 NotConnected |
|
81 }; |
|
82 enum Command { |
|
83 None, |
|
84 SetTransferMode, |
|
85 SetProxy, |
|
86 ConnectToHost, |
|
87 Login, |
|
88 Close, |
|
89 List, |
|
90 Cd, |
|
91 Get, |
|
92 Put, |
|
93 Remove, |
|
94 Mkdir, |
|
95 Rmdir, |
|
96 Rename, |
|
97 RawCommand |
|
98 }; |
|
99 enum TransferMode { |
|
100 Active, |
|
101 Passive |
|
102 }; |
|
103 enum TransferType { |
|
104 Binary, |
|
105 Ascii |
|
106 }; |
|
107 |
|
108 int setProxy(const QString &host, quint16 port); |
|
109 int connectToHost(const QString &host, quint16 port=21); |
|
110 int login(const QString &user = QString(), const QString &password = QString()); |
|
111 int close(); |
|
112 int setTransferMode(TransferMode mode); |
|
113 int list(const QString &dir = QString()); |
|
114 int cd(const QString &dir); |
|
115 int get(const QString &file, QIODevice *dev=0, TransferType type = Binary); |
|
116 int put(const QByteArray &data, const QString &file, TransferType type = Binary); |
|
117 int put(QIODevice *dev, const QString &file, TransferType type = Binary); |
|
118 int remove(const QString &file); |
|
119 int mkdir(const QString &dir); |
|
120 int rmdir(const QString &dir); |
|
121 int rename(const QString &oldname, const QString &newname); |
|
122 |
|
123 int rawCommand(const QString &command); |
|
124 |
|
125 qint64 bytesAvailable() const; |
|
126 qint64 read(char *data, qint64 maxlen); |
|
127 #ifdef QT3_SUPPORT |
|
128 inline QT3_SUPPORT qint64 readBlock(char *data, quint64 maxlen) |
|
129 { return read(data, qint64(maxlen)); } |
|
130 #endif |
|
131 QByteArray readAll(); |
|
132 |
|
133 int currentId() const; |
|
134 QIODevice* currentDevice() const; |
|
135 Command currentCommand() const; |
|
136 bool hasPendingCommands() const; |
|
137 void clearPendingCommands(); |
|
138 |
|
139 State state() const; |
|
140 |
|
141 Error error() const; |
|
142 QString errorString() const; |
|
143 |
|
144 public Q_SLOTS: |
|
145 void abort(); |
|
146 |
|
147 Q_SIGNALS: |
|
148 void stateChanged(int); |
|
149 void listInfo(const QUrlInfo&); |
|
150 void readyRead(); |
|
151 void dataTransferProgress(qint64, qint64); |
|
152 void rawCommandReply(int, const QString&); |
|
153 |
|
154 void commandStarted(int); |
|
155 void commandFinished(int, bool); |
|
156 void done(bool); |
|
157 |
|
158 #ifdef QT3_SUPPORT |
|
159 public: |
|
160 QT3_SUPPORT_CONSTRUCTOR QFtp(QObject *parent, const char *name); |
|
161 #endif |
|
162 |
|
163 private: |
|
164 Q_DISABLE_COPY(QFtp) |
|
165 Q_DECLARE_PRIVATE(QFtp) |
|
166 |
|
167 Q_PRIVATE_SLOT(d_func(), void _q_startNextCommand()) |
|
168 Q_PRIVATE_SLOT(d_func(), void _q_piFinished(const QString&)) |
|
169 Q_PRIVATE_SLOT(d_func(), void _q_piError(int, const QString&)) |
|
170 Q_PRIVATE_SLOT(d_func(), void _q_piConnectState(int)) |
|
171 Q_PRIVATE_SLOT(d_func(), void _q_piFtpReply(int, const QString&)) |
|
172 }; |
|
173 |
|
174 #endif // QT_NO_FTP |
|
175 |
|
176 QT_END_NAMESPACE |
|
177 |
|
178 QT_END_HEADER |
|
179 |
|
180 #endif // QFTP_H |