QtNetwork/qftp.h Source File

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 
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 {
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  };
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 
177 
179 
180 #endif // QFTP_H
GLuint GLuint GLsizei GLenum type
Definition: GLee.h:872
GLint mode
Definition: GLee.h:4479
#define QT_END_NAMESPACE
Definition: qglobal.h:128
Command
Definition: qftp.h:82
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
State
The state the media producing object is in at the moment.
Definition: qftp.h:91
long long qint64
Definition: qglobal.h:947
State
Definition: qftp.h:67
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
#define Q_SLOTS
Definition: qobjectdefs.h:71
GLXDrawable GLXDrawable read
Definition: GLee.h:10243
#define Q_SIGNALS
Definition: qobjectdefs.h:72
unsigned long long quint64
Definition: qglobal.h:948
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:880
TransferType
Definition: qftp.h:103
unsigned short quint16
Definition: qglobal.h:936
#define Q_OBJECT
Definition: qobjectdefs.h:157
Definition: qftp.h:59
Definition: qftp.h:90
GLuint const GLchar * name
Definition: GLee.h:1704
Error
Definition: qftp.h:75
Definition: qftp.h:92
TransferMode
Definition: qftp.h:99
#define QT_END_HEADER
Definition: qglobal.h:142