Qt 4.8
Public Types | Public Slots | Public Functions | Properties | Friends | List of all members
QNetworkAccessFtpBackend Class Reference

#include <qnetworkaccessftpbackend_p.h>

Inheritance diagram for QNetworkAccessFtpBackend:
QNetworkAccessBackend QObject

Public Types

enum  State {
  Idle, LoggingIn, CheckingFeatures, Statting,
  Transferring, Disconnecting
}
 

Public Slots

void ftpConnectionReady (QNetworkAccessCache::CacheableObject *object)
 
void ftpDone ()
 
void ftpRawCommandReply (int code, const QString &text)
 
void ftpReadyRead ()
 
- Public Slots inherited from QNetworkAccessBackend
void writeDownstreamData (QIODevice *data)
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Public Functions

virtual void closeDownstreamChannel ()
 
void disconnectFromFtp ()
 
virtual void downstreamReadyWrite ()
 
virtual void open ()
 
 QNetworkAccessFtpBackend ()
 
virtual ~QNetworkAccessFtpBackend ()
 
- Public Functions inherited from QNetworkAccessBackend
QVariant attribute (QNetworkRequest::Attribute code) const
 
virtual bool canResume () const
 
virtual void copyFinished (QIODevice *)
 
virtual void emitReadBufferFreed (qint64 size)
 
virtual QNetworkCacheMetaData fetchCacheMetaData (const QNetworkCacheMetaData &metaData) const
 
virtual void fetchSslConfiguration (QSslConfiguration &configuration) const
 
bool hasRawHeader (const QByteArray &headerName) const
 
QVariant header (QNetworkRequest::KnownHeaders header) const
 
virtual void ignoreSslErrors ()
 
virtual void ignoreSslErrors (const QList< QSslError > &errors)
 
bool isCachingEnabled () const
 
bool isSynchronous ()
 
virtual bool needsResetableUploadData ()
 
QAbstractNetworkCachenetworkCache () const
 
QNetworkAccessManager::Operation operation () const
 
virtual bool processRequestSynchronously ()
 
QList< QNetworkProxyproxyList () const
 
 QNetworkAccessBackend ()
 
QByteArray rawHeader (const QByteArray &headerName) const
 
QList< QByteArrayrawHeaderList () const
 
QNetworkRequest request () const
 
void setAttribute (QNetworkRequest::Attribute code, const QVariant &value)
 
void setCachingEnabled (bool enable)
 
virtual void setDownstreamLimited (bool b)
 
void setHeader (QNetworkRequest::KnownHeaders header, const QVariant &value)
 
void setRawHeader (const QByteArray &headerName, const QByteArray &value)
 
virtual void setReadBufferSize (qint64 size)
 
virtual void setResumeOffset (quint64 offset)
 
virtual void setSslConfiguration (const QSslConfiguration &configuration)
 
void setSynchronous (bool sync)
 
void setUrl (const QUrl &url)
 
virtual bool start ()
 Starts the backend. More...
 
QUrl url () const
 
virtual ~QNetworkAccessBackend ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Properties

QPointer< QNetworkAccessCachedFtpConnectionftp
 
int helpId
 
int mdtmId
 
int sizeId
 
State state
 
bool supportsMdtm
 
bool supportsSize
 
qint64 totalBytes
 
QIODeviceuploadDevice
 

Friends

class QNetworkAccessFtpIODevice
 

Additional Inherited Members

- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QNetworkAccessBackend
void authenticationRequired (QAuthenticator *auth)
 
void emitReplyUploadProgress (qint64 bytesSent, qint64 bytesTotal)
 
void error (QNetworkReply::NetworkError code, const QString &errorString)
 
void finished ()
 
void metaDataChanged ()
 
void proxyAuthenticationRequired (const QNetworkProxy &proxy, QAuthenticator *auth)
 
void redirectionRequested (const QUrl &destination)
 
void sslErrors (const QList< QSslError > &errors)
 
- Protected Functions inherited from QNetworkAccessBackend
QNonContiguousByteDevicecreateUploadByteDevice ()
 
char * getDownloadBuffer (qint64)
 
qint64 nextDownstreamBlockSize () const
 
void writeDownstreamData (QByteDataBuffer &list)
 
void writeDownstreamDataDownloadBuffer (qint64, qint64)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QNetworkAccessBackend
QNetworkAccessManagerPrivatemanager
 
QNetworkReplyImplPrivatereply
 
QSharedPointer< QNonContiguousByteDeviceuploadByteDevice
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 71 of file qnetworkaccessftpbackend_p.h.

Enumerations

◆ State

Constructors and Destructors

◆ QNetworkAccessFtpBackend()

QNetworkAccessFtpBackend::QNetworkAccessFtpBackend ( )

◆ ~QNetworkAccessFtpBackend()

QNetworkAccessFtpBackend::~QNetworkAccessFtpBackend ( )
virtual

Definition at line 108 of file qnetworkaccessftpbackend.cpp.

109 {
110  //if backend destroyed while in use, then abort (this is the code path from QNetworkReply::abort)
111  if (ftp && state != Disconnecting)
112  ftp->abort();
114 }
QPointer< QNetworkAccessCachedFtpConnection > ftp
void abort()
Aborts the current command and deletes all scheduled commands.
Definition: qftp.cpp:2188

Functions

◆ closeDownstreamChannel()

void QNetworkAccessFtpBackend::closeDownstreamChannel ( )
virtual

Implements QNetworkAccessBackend.

Definition at line 181 of file qnetworkaccessftpbackend.cpp.

182 {
185  ftp->abort();
186 }
QPointer< QNetworkAccessCachedFtpConnection > ftp
void abort()
Aborts the current command and deletes all scheduled commands.
Definition: qftp.cpp:2188
QNetworkAccessManager::Operation operation() const

◆ disconnectFromFtp()

void QNetworkAccessFtpBackend::disconnectFromFtp ( )

Definition at line 208 of file qnetworkaccessftpbackend.cpp.

Referenced by ftpDone(), and ~QNetworkAccessFtpBackend().

209 {
211 
212  if (ftp) {
213  disconnect(ftp, 0, this, 0);
214 
217 
218  ftp = 0;
219  }
220 }
static QByteArray makeCacheKey(const QUrl &url)
QPointer< QNetworkAccessCachedFtpConnection > ftp
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QNetworkAccessCache * getObjectCache(QNetworkAccessBackend *backend)
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
int key
void releaseEntry(const QByteArray &key)

◆ downstreamReadyWrite()

void QNetworkAccessFtpBackend::downstreamReadyWrite ( )
virtual

Reimplemented from QNetworkAccessBackend.

Definition at line 188 of file qnetworkaccessftpbackend.cpp.

189 {
190  if (state == Transferring && ftp && ftp->bytesAvailable())
191  ftpReadyRead();
192 }
QPointer< QNetworkAccessCachedFtpConnection > ftp
qint64 bytesAvailable() const
Returns the number of bytes that can be read from the data socket at the moment.
Definition: qftp.cpp:2127

◆ ftpConnectionReady

void QNetworkAccessFtpBackend::ftpConnectionReady ( QNetworkAccessCache::CacheableObject object)
slot

Definition at line 194 of file qnetworkaccessftpbackend.cpp.

Referenced by open().

195 {
196  ftp = static_cast<QNetworkAccessCachedFtpConnection *>(o);
197  connect(ftp, SIGNAL(done(bool)), SLOT(ftpDone()));
198  connect(ftp, SIGNAL(rawCommandReply(int,QString)), SLOT(ftpRawCommandReply(int,QString)));
199  connect(ftp, SIGNAL(readyRead()), SLOT(ftpReadyRead()));
200 
201  // is the login process done already?
202  if (ftp->state() == QFtp::LoggedIn)
203  ftpDone();
204 
205  // no, defer the actual operation until after we've logged in
206 }
void ftpRawCommandReply(int code, const QString &text)
QPointer< QNetworkAccessCachedFtpConnection > ftp
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
State state() const
Returns the current state of the object.
Definition: qftp.cpp:2277

◆ ftpDone

void QNetworkAccessFtpBackend::ftpDone ( )
slot

Definition at line 222 of file qnetworkaccessftpbackend.cpp.

Referenced by ftpConnectionReady().

223 {
224  // the last command we sent is done
225  if (state == LoggingIn && ftp->state() != QFtp::LoggedIn) {
226  if (ftp->state() == QFtp::Connected) {
227  // the login did not succeed
228  QUrl newUrl = url();
229  newUrl.setUserInfo(QString());
230  setUrl(newUrl);
231 
232  QAuthenticator auth;
233  authenticationRequired(&auth);
234 
235  if (!auth.isNull()) {
236  // try again:
237  newUrl.setUserName(auth.user());
238  ftp->login(auth.user(), auth.password());
239  return;
240  }
241 
243  tr("Logging in to %1 failed: authentication required")
244  .arg(url().host()));
245  } else {
246  // we did not connect
248  switch (ftp->error()) {
249  case QFtp::HostNotFound:
251  break;
252 
255  break;
256 
257  default:
259  break;
260  }
261 
262  error(code, ftp->errorString());
263  }
264 
265  // we're not connected, so remove the cache entry:
268 
269  disconnect(ftp, 0, this, 0);
270  ftp->dispose();
271  ftp = 0;
272 
274  finished();
275  return;
276  }
277 
278  // check for errors:
279  if (ftp->error() != QFtp::NoError) {
280  QString msg;
282  msg = tr("Error while downloading %1: %2");
283  else
284  msg = tr("Error while uploading %1: %2");
285  msg = msg.arg(url().toString(), ftp->errorString());
286 
287  if (state == Statting)
288  // file probably doesn't exist
290  else
292 
294  finished();
295  }
296 
297  if (state == LoggingIn) {
300  // send help command to find out if server supports "SIZE" and "MDTM"
301  QString command = url().path();
302  command.prepend(QLatin1String("%1 "));
303  helpId = ftp->rawCommand(QLatin1String("HELP")); // get supported commands
304  } else {
305  ftpDone();
306  }
307  } else if (state == CheckingFeatures) {
308  state = Statting;
310  // logged in successfully, send the stat requests (if supported)
311  QString command = url().path();
312  command.prepend(QLatin1String("%1 "));
313  if (supportsSize) {
314  ftp->rawCommand(QLatin1String("TYPE I"));
315  sizeId = ftp->rawCommand(command.arg(QLatin1String("SIZE"))); // get size
316  }
317  if (supportsMdtm)
318  mdtmId = ftp->rawCommand(command.arg(QLatin1String("MDTM"))); // get modified time
319  if (!supportsSize && !supportsMdtm)
320  ftpDone(); // no commands sent, move to the next state
321  } else {
322  ftpDone();
323  }
324  } else if (state == Statting) {
325  // statted successfully, send the actual request
328 
331  setCachingEnabled(true);
332  ftp->get(url().path(), 0, type);
333  } else {
334  ftp->put(uploadDevice, url().path(), type);
335  }
336 
337  } else if (state == Transferring) {
338  // upload or download finished
340  finished();
341  }
342 }
void setUserInfo(const QString &userInfo)
Sets the user info of the URL to userInfo.
Definition: qurl.cpp:4615
int type
Definition: qmetatype.cpp:239
static QByteArray makeCacheKey(const QUrl &url)
QPointer< QNetworkAccessCachedFtpConnection > ftp
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString & prepend(QChar c)
Definition: qstring.h:261
int rawCommand(const QString &command)
Sends the raw FTP command command to the FTP server.
Definition: qftp.cpp:2115
NetworkError
Indicates all possible error conditions found during the processing of the request.
Definition: qnetworkreply.h:70
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
int put(const QByteArray &data, const QString &file, TransferType type=Binary)
Writes a copy of the given data to the file called file on the server.
Definition: qftp.cpp:1977
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
static QString toString(Register *reg, int type, bool *ok=0)
int get(const QString &file, QIODevice *dev=0, TransferType type=Binary)
Downloads the file file from the server.
Definition: qftp.cpp:1937
static QNetworkAccessCache * getObjectCache(QNetworkAccessBackend *backend)
#define emit
Definition: qobjectdefs.h:76
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QNetworkAccessManager::Operation operation() const
The QAuthenticator class provides an authentication object.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
void authenticationRequired(QAuthenticator *auth)
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
void error(QNetworkReply::NetworkError code, const QString &errorString)
void setUrl(const QUrl &url)
bool isNull() const
Returns true if the authenticator is null.
QString user() const
returns the user used for authentication.
int key
QString errorString() const
Returns a human-readable description of the last error that occurred.
Definition: qftp.cpp:2305
TransferType
This enum identifies the data transfer type used with get and put commands.
Definition: qftp.h:103
void setCachingEnabled(bool enable)
int login(const QString &user=QString(), const QString &password=QString())
Logs in to the FTP server with the username user and the password password.
Definition: qftp.cpp:1791
QString password() const
returns the password used for authentication.
Error error() const
Returns the last error that occurred.
Definition: qftp.cpp:2289
void setUserName(const QString &userName)
Sets the URL&#39;s user name to userName.
Definition: qurl.cpp:4648
void removeEntry(const QByteArray &key)
State state() const
Returns the current state of the object.
Definition: qftp.cpp:2277

◆ ftpRawCommandReply

void QNetworkAccessFtpBackend::ftpRawCommandReply ( int  code,
const QString text 
)
slot

Definition at line 353 of file qnetworkaccessftpbackend.cpp.

Referenced by ftpConnectionReady().

354 {
355  //qDebug() << "FTP reply:" << code << text;
356  int id = ftp->currentId();
357 
358  if ((id == helpId) && ((code == 200) || (code == 214))) { // supported commands
359  // the "FEAT" ftp command would be nice here, but it is not part of the
360  // initial FTP RFC 959, neither ar "SIZE" nor "MDTM" (they are all specified
361  // in RFC 3659)
362  if (text.contains(QLatin1String("SIZE"), Qt::CaseSensitive))
363  supportsSize = true;
364  if (text.contains(QLatin1String("MDTM"), Qt::CaseSensitive))
365  supportsMdtm = true;
366  } else if (code == 213) { // file status
367  if (id == sizeId) {
368  // reply to the size command
370 #ifndef QT_NO_DATESTRING
371  } else if (id == mdtmId) {
372  QDateTime dt = QDateTime::fromString(text, QLatin1String("yyyyMMddHHmmss"));
374 #endif
375  }
376  }
377 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
qlonglong toLongLong(bool *ok=0, int base=10) const
Returns the string converted to a long long using base base, which is 10 by default and must be betwe...
Definition: qstring.cpp:5943
QPointer< QNetworkAccessCachedFtpConnection > ftp
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int currentId() const
Returns the identifier of the FTP command that is being executed or 0 if there is no command being ex...
Definition: qftp.cpp:2203
static QDateTime fromString(const QString &s, Qt::DateFormat f=Qt::TextDate)
Returns the QDateTime represented by the string, using the format given, or an invalid datetime if th...
Definition: qdatetime.cpp:3487
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
void setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value)
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ ftpReadyRead

void QNetworkAccessFtpBackend::ftpReadyRead ( )
slot

Definition at line 344 of file qnetworkaccessftpbackend.cpp.

Referenced by downstreamReadyWrite(), and ftpConnectionReady().

345 {
346  QByteArray data = ftp->readAll();
347  QByteDataBuffer list;
348  list.append(data);
349  data.clear(); // important because of implicit sharing!
350  writeDownstreamData(list);
351 }
QByteArray readAll()
Reads all the bytes available from the data socket and returns them.
Definition: qftp.cpp:2154
QPointer< QNetworkAccessCachedFtpConnection > ftp
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void append(QByteDataBuffer &other)
Definition: qbytedata_p.h:77
static const char * data(const QByteArray &arr)
void writeDownstreamData(QByteDataBuffer &list)
void clear()
Clears the contents of the byte array and makes it empty.

◆ open()

void QNetworkAccessFtpBackend::open ( )
virtual

Implements QNetworkAccessBackend.

Definition at line 116 of file qnetworkaccessftpbackend.cpp.

117 {
118 #ifndef QT_NO_NETWORKPROXY
119  QNetworkProxy proxy;
120  foreach (const QNetworkProxy &p, proxyList()) {
121  // use the first FTP proxy
122  // or no proxy at all
124  || p.type() == QNetworkProxy::NoProxy) {
125  proxy = p;
126  break;
127  }
128  }
129 
130  // did we find an FTP proxy or a NoProxy?
131  if (proxy.type() == QNetworkProxy::DefaultProxy) {
132  // unsuitable proxies
134  tr("No suitable proxy found"));
135  finished();
136  return;
137  }
138 
139 #endif
140 
141  QUrl url = this->url();
142  if (url.path().isEmpty()) {
143  url.setPath(QLatin1String("/"));
144  setUrl(url);
145  }
146  if (url.path().endsWith(QLatin1Char('/'))) {
148  tr("Cannot open %1: is a directory").arg(url.toString()));
149  finished();
150  return;
151  }
152  state = LoggingIn;
153 
155  QByteArray cacheKey = makeCacheKey(url);
156  if (!objectCache->requestEntry(cacheKey, this,
159 #ifndef QT_NO_BEARERMANAGEMENT
160  //copy network session down to the QFtp
161  ftp->setProperty("_q_networksession", property("_q_networksession"));
162 #endif
163 #ifndef QT_NO_NETWORKPROXY
164  if (proxy.type() == QNetworkProxy::FtpCachingProxy)
165  ftp->setProxy(proxy.hostName(), proxy.port());
166 #endif
167  ftp->connectToHost(url.host(), url.port(DefaultFtpPort));
168  ftp->login(url.userName(), url.password());
169 
170  objectCache->addEntry(cacheKey, ftp);
172  }
173 
174  // Put operation
177  uploadDevice->setParent(this);
178  }
179 }
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
int connectToHost(const QString &host, quint16 port=21)
Connects to the FTP server host using port port.
Definition: qftp.cpp:1763
bool requestEntry(const QByteArray &key, QObject *target, const char *member)
static QByteArray makeCacheKey(const QUrl &url)
QPointer< QNetworkAccessCachedFtpConnection > ftp
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define SLOT(a)
Definition: qobjectdefs.h:226
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755
void setPath(const QString &path)
Sets the path of the URL to path.
Definition: qurl.cpp:4960
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
QString host() const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4837
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
int port() const
Returns the port of the URL, or -1 if the port is unspecified.
Definition: qurl.cpp:4916
The QNetworkProxy class provides a network layer proxy.
QNonContiguousByteDevice * createUploadByteDevice()
void addEntry(const QByteArray &key, CacheableObject *entry)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QNetworkAccessCache * getObjectCache(QNetworkAccessBackend *backend)
QList< QNetworkProxy > proxyList() const
QNetworkAccessManager::Operation operation() const
void ftpConnectionReady(QNetworkAccessCache::CacheableObject *object)
QString userName() const
Returns the user name of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4667
void error(QNetworkReply::NetworkError code, const QString &errorString)
void setUrl(const QUrl &url)
quint16 port() const
Returns the port of the proxy host.
static QIODevice * wrap(QNonContiguousByteDevice *byteDevice)
Wrap the byteDevice (possibly again) into a QIODevice.
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
int login(const QString &user=QString(), const QString &password=QString())
Logs in to the FTP server with the username user and the password password.
Definition: qftp.cpp:1791
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
int setProxy(const QString &host, quint16 port)
Enables use of the FTP proxy on host host and port port.
Definition: qftp.cpp:1842
QString password() const
Returns the password of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4754
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QString hostName() const
Returns the host name of the proxy host.

Friends and Related Functions

◆ QNetworkAccessFtpIODevice

friend class QNetworkAccessFtpIODevice
friend

Definition at line 102 of file qnetworkaccessftpbackend_p.h.

Properties

◆ ftp

QPointer<QNetworkAccessCachedFtpConnection> QNetworkAccessFtpBackend::ftp
private

◆ helpId

int QNetworkAccessFtpBackend::helpId
private

Definition at line 106 of file qnetworkaccessftpbackend_p.h.

Referenced by ftpDone(), and ftpRawCommandReply().

◆ mdtmId

int QNetworkAccessFtpBackend::mdtmId
private

Definition at line 106 of file qnetworkaccessftpbackend_p.h.

Referenced by ftpDone(), and ftpRawCommandReply().

◆ sizeId

int QNetworkAccessFtpBackend::sizeId
private

Definition at line 106 of file qnetworkaccessftpbackend_p.h.

Referenced by ftpDone(), and ftpRawCommandReply().

◆ state

State QNetworkAccessFtpBackend::state
private

◆ supportsMdtm

bool QNetworkAccessFtpBackend::supportsMdtm
private

Definition at line 107 of file qnetworkaccessftpbackend_p.h.

Referenced by ftpDone(), and ftpRawCommandReply().

◆ supportsSize

bool QNetworkAccessFtpBackend::supportsSize
private

Definition at line 107 of file qnetworkaccessftpbackend_p.h.

Referenced by ftpDone(), and ftpRawCommandReply().

◆ totalBytes

qint64 QNetworkAccessFtpBackend::totalBytes
private

Definition at line 105 of file qnetworkaccessftpbackend_p.h.

◆ uploadDevice

QIODevice* QNetworkAccessFtpBackend::uploadDevice
private

Definition at line 104 of file qnetworkaccessftpbackend_p.h.

Referenced by ftpDone(), and open().


The documentation for this class was generated from the following files: