Qt 4.8
qftp.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtNetwork module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** 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.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 
50 
52 
53 QT_MODULE(Network)
54 
55 #ifndef QT_NO_FTP
56 
57 class QFtpPrivate;
58 
60 {
61  Q_OBJECT
62 
63 public:
64  explicit QFtp(QObject *parent = 0);
65  virtual ~QFtp();
66 
67  enum State {
73  Closing
74  };
75  enum Error {
80  NotConnected
81  };
82  enum Command {
90  Cd,
91  Get,
92  Put,
97  RawCommand
98  };
99  enum TransferMode {
101  Passive
102  };
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 public:
159 #ifdef QT3_SUPPORT
160  QT3_SUPPORT_CONSTRUCTOR QFtp(QObject *parent, const char *name);
161 #endif
162 
163 private:
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 
177 
179 
180 #endif // QFTP_H
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define error(msg)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
Command
This enum is used as the return value for the currentCommand() function.
Definition: qftp.h:82
Definition: qftp.h:90
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QFtp class provides an implementation of the client side of FTP protocol.
Definition: qftp.h:59
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
Definition: qegl.cpp:743
The QUrlInfo class stores information about URLs.
Definition: qurlinfo.h:60
TransferMode
FTP works with two socket connections; one for commands and another for transmitting data...
Definition: qftp.h:99
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Error
This enum identifies the error that occurred.
Definition: qftp.h:75
unsigned __int64 quint64
Definition: qglobal.h:943
const char * name
unsigned short quint16
Definition: qglobal.h:936
static const char * data(const QByteArray &arr)
__int64 qint64
Definition: qglobal.h:942
The State element defines configurations of objects and properties.
#define Q_OBJECT
Definition: qobjectdefs.h:157
Definition: qftp.h:91
#define Q_NETWORK_EXPORT
Definition: qglobal.h:1452
TransferType
This enum identifies the data transfer type used with get and put commands.
Definition: qftp.h:103
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
#define QT_END_HEADER
Definition: qglobal.h:137
Definition: qftp.h:92