qnetworkaccessftpbackend.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkaccessftpbackend.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qnetworkaccessftpbackend_p.h"-
35#include "qnetworkaccessmanager_p.h"-
36#include "QtNetwork/qauthenticator.h"-
37#include "private/qnoncontiguousbytedevice_p.h"-
38#include <QStringList>-
39-
40#ifndef QT_NO_FTP-
41-
42QT_BEGIN_NAMESPACE-
43-
44enum {-
45 DefaultFtpPort = 21-
46};-
47-
48static QByteArray makeCacheKey(const QUrl &url)-
49{-
50 QUrl copy = url;-
51 copy.setPort(url.port(DefaultFtpPort));-
52 return "ftp-connection:" +
executed 98 times by 1 test: return "ftp-connection:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment);
Executed by:
  • tst_QNetworkReply
98
53 copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery |
executed 98 times by 1 test: return "ftp-connection:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment);
Executed by:
  • tst_QNetworkReply
98
54 QUrl::RemoveFragment);
executed 98 times by 1 test: return "ftp-connection:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment);
Executed by:
  • tst_QNetworkReply
98
55}-
56-
57QStringList QNetworkAccessFtpBackendFactory::supportedSchemes() const-
58{-
59 return QStringList(QStringLiteral("ftp"));
never executed: return QStringList(([]() -> QString { enum { Size = sizeof(u"" "ftp")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "ftp" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));
never executed: return qstring_literal_temp;
0
60}-
61-
62QNetworkAccessBackend *-
63QNetworkAccessFtpBackendFactory::create(QNetworkAccessManager::Operation op,-
64 const QNetworkRequest &request) const-
65{-
66 // is it an operation we know of?-
67 switch (op) {-
68 case QNetworkAccessManager::GetOperation:
executed 49 times by 1 test: case QNetworkAccessManager::GetOperation:
Executed by:
  • tst_QNetworkReply
49
69 case QNetworkAccessManager::PutOperation:
executed 59 times by 1 test: case QNetworkAccessManager::PutOperation:
Executed by:
  • tst_QNetworkReply
59
70 break;
executed 108 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
108
71-
72 default:
never executed: default:
0
73 // no, we can't handle this operation-
74 return 0;
never executed: return 0;
0
75 }-
76-
77 QUrl url = request.url();-
78 if (url.scheme().compare(QLatin1String("ftp"), Qt::CaseInsensitive) == 0)
url.scheme().c...ensitive) == 0Description
TRUEevaluated 54 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 54 times by 1 test
Evaluated by:
  • tst_QNetworkReply
54
79 return new QNetworkAccessFtpBackend;
executed 54 times by 1 test: return new QNetworkAccessFtpBackend;
Executed by:
  • tst_QNetworkReply
54
80 return 0;
executed 54 times by 1 test: return 0;
Executed by:
  • tst_QNetworkReply
54
81}-
82-
83class QNetworkAccessCachedFtpConnection: public QFtp, public QNetworkAccessCache::CacheableObject-
84{-
85 // Q_OBJECT-
86public:-
87 QNetworkAccessCachedFtpConnection()-
88 {-
89 setExpires(true);-
90 setShareable(false);-
91 }
executed 48 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
48
92-
93 void dispose() Q_DECL_OVERRIDE-
94 {-
95 connect(this, SIGNAL(done(bool)), this, SLOT(deleteLater()));-
96 close();-
97 }
executed 48 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
48
98};-
99-
100QNetworkAccessFtpBackend::QNetworkAccessFtpBackend()-
101 : ftp(0), uploadDevice(0), totalBytes(0), helpId(-1), sizeId(-1), mdtmId(-1),-
102 supportsSize(false), supportsMdtm(false), state(Idle)-
103{-
104}
executed 54 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
54
105-
106QNetworkAccessFtpBackend::~QNetworkAccessFtpBackend()-
107{-
108 //if backend destroyed while in use, then abort (this is the code path from QNetworkReply::abort)-
109 if (ftp && state != Disconnecting)
state != DisconnectingDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1
110 ftp->abort();
executed 1 time by 1 test: ftp->abort();
Executed by:
  • tst_QNetworkReply
1
111 disconnectFromFtp();-
112}
executed 54 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
54
113-
114void QNetworkAccessFtpBackend::open()-
115{-
116#ifndef QT_NO_NETWORKPROXY-
117 QNetworkProxy proxy;-
118 foreach (const QNetworkProxy &p, proxyList()) {-
119 // use the first FTP proxy-
120 // or no proxy at all-
121 if (p.type() == QNetworkProxy::FtpCachingProxy
p.type() == QN...tpCachingProxyDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 53 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2-53
122 || p.type() == QNetworkProxy::NoProxy) {
p.type() == QN...Proxy::NoProxyDescription
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
5-48
123 proxy = p;-
124 break;
executed 50 times by 1 test: break;
Executed by:
  • tst_QNetworkReply
50
125 }-
126 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
5
127-
128 // did we find an FTP proxy or a NoProxy?-
129 if (proxy.type() == QNetworkProxy::DefaultProxy) {
proxy.type() =...::DefaultProxyDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 50 times by 1 test
Evaluated by:
  • tst_QNetworkReply
3-50
130 // unsuitable proxies-
131 error(QNetworkReply::ProxyNotFoundError,-
132 tr("No suitable proxy found"));-
133 finished();-
134 return;
executed 3 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
3
135 }-
136-
137#endif-
138-
139 QUrl url = this->url();-
140 if (url.path().isEmpty()) {
url.path().isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 49 times by 1 test
Evaluated by:
  • tst_QNetworkReply
1-49
141 url.setPath(QLatin1String("/"));-
142 setUrl(url);-
143 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
144 if (url.path().endsWith(QLatin1Char('/'))) {
url.path().end...tin1Char('/'))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 49 times by 1 test
Evaluated by:
  • tst_QNetworkReply
1-49
145 error(QNetworkReply::ContentOperationNotPermittedError,-
146 tr("Cannot open %1: is a directory").arg(url.toString()));-
147 finished();-
148 return;
executed 1 time by 1 test: return;
Executed by:
  • tst_QNetworkReply
1
149 }-
150 state = LoggingIn;-
151-
152 QNetworkAccessCache* objectCache = QNetworkAccessManagerPrivate::getObjectCache(this);-
153 QByteArray cacheKey = makeCacheKey(url);-
154 if (!objectCache->requestEntry(cacheKey, this,
!objectCache->...__ ":" "155"))Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1-48
155 SLOT(ftpConnectionReady(QNetworkAccessCache::CacheableObject*)))) {
!objectCache->...__ ":" "155"))Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1-48
156 ftp = new QNetworkAccessCachedFtpConnection;-
157#ifndef QT_NO_BEARERMANAGEMENT-
158 //copy network session down to the QFtp-
159 ftp->setProperty("_q_networksession", property("_q_networksession"));-
160#endif-
161#ifndef QT_NO_NETWORKPROXY-
162 if (proxy.type() == QNetworkProxy::FtpCachingProxy)
proxy.type() =...tpCachingProxyDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 46 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2-46
163 ftp->setProxy(proxy.hostName(), proxy.port());
executed 2 times by 1 test: ftp->setProxy(proxy.hostName(), proxy.port());
Executed by:
  • tst_QNetworkReply
2
164#endif-
165 ftp->connectToHost(url.host(), url.port(DefaultFtpPort));-
166 ftp->login(url.userName(), url.password());-
167-
168 objectCache->addEntry(cacheKey, ftp);-
169 ftpConnectionReady(ftp);-
170 }
executed 48 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
48
171-
172 // Put operation-
173 if (operation() == QNetworkAccessManager::PutOperation) {
operation() ==...::PutOperationDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 36 times by 1 test
Evaluated by:
  • tst_QNetworkReply
13-36
174 uploadDevice = QNonContiguousByteDeviceFactory::wrap(createUploadByteDevice());-
175 uploadDevice->setParent(this);-
176 }
executed 13 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
13
177}
executed 49 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
49
178-
179void QNetworkAccessFtpBackend::closeDownstreamChannel()-
180{-
181 state = Disconnecting;-
182 if (operation() == QNetworkAccessManager::GetOperation)
operation() ==...::GetOperationDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-1
183 ftp->abort();
executed 1 time by 1 test: ftp->abort();
Executed by:
  • tst_QNetworkReply
1
184}
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
185-
186void QNetworkAccessFtpBackend::downstreamReadyWrite()-
187{-
188 if (state == Transferring && ftp && ftp->bytesAvailable())
state == TransferringDescription
TRUEevaluated 562 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_QNetworkReply
ftp->bytesAvailable()Description
TRUEnever evaluated
FALSEevaluated 562 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-562
189 ftpReadyRead();
never executed: ftpReadyRead();
0
190}
executed 600 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
600
191-
192void QNetworkAccessFtpBackend::ftpConnectionReady(QNetworkAccessCache::CacheableObject *o)-
193{-
194 ftp = static_cast<QNetworkAccessCachedFtpConnection *>(o);-
195 connect(ftp, SIGNAL(done(bool)), SLOT(ftpDone()));-
196 connect(ftp, SIGNAL(rawCommandReply(int,QString)), SLOT(ftpRawCommandReply(int,QString)));-
197 connect(ftp, SIGNAL(readyRead()), SLOT(ftpReadyRead()));-
198-
199 // is the login process done already?-
200 if (ftp->state() == QFtp::LoggedIn)
ftp->state() == QFtp::LoggedInDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 48 times by 1 test
Evaluated by:
  • tst_QNetworkReply
1-48
201 ftpDone();
executed 1 time by 1 test: ftpDone();
Executed by:
  • tst_QNetworkReply
1
202-
203 // no, defer the actual operation until after we've logged in-
204}
executed 49 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
49
205-
206void QNetworkAccessFtpBackend::disconnectFromFtp(CacheCleanupMode mode)-
207{-
208 state = Disconnecting;-
209-
210 if (ftp) {
ftpDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 52 times by 1 test
Evaluated by:
  • tst_QNetworkReply
49-52
211 disconnect(ftp, 0, this, 0);-
212-
213 QByteArray key = makeCacheKey(url());-
214 if (mode == RemoveCachedConnection) {
mode == RemoveCachedConnectionDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tst_QNetworkReply
9-40
215 QNetworkAccessManagerPrivate::getObjectCache(this)->removeEntry(key);-
216 ftp->dispose();-
217 } else {
executed 9 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
9
218 QNetworkAccessManagerPrivate::getObjectCache(this)->releaseEntry(key);-
219 }
executed 40 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
40
220-
221 ftp = 0;-
222 }
executed 49 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
49
223}
executed 101 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
101
224-
225void QNetworkAccessFtpBackend::ftpDone()-
226{-
227 // the last command we sent is done-
228 if (state == LoggingIn && ftp->state() != QFtp::LoggedIn) {
state == LoggingInDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 129 times by 1 test
Evaluated by:
  • tst_QNetworkReply
ftp->state() != QFtp::LoggedInDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 45 times by 1 test
Evaluated by:
  • tst_QNetworkReply
4-129
229 if (ftp->state() == QFtp::Connected) {
ftp->state() =...Ftp::ConnectedDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1-3
230 // the login did not succeed-
231 QUrl newUrl = url();-
232 QString userInfo = newUrl.userInfo();-
233 newUrl.setUserInfo(QString());-
234 setUrl(newUrl);-
235-
236 QAuthenticator auth;-
237 authenticationRequired(&auth);-
238-
239 if (!auth.isNull()) {
!auth.isNull()Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-3
240 // try again:-
241 newUrl.setUserName(auth.user());-
242 ftp->login(auth.user(), auth.password());-
243 return;
never executed: return;
0
244 }-
245-
246 // Re insert the user info so that we can remove the cache entry.-
247 newUrl.setUserInfo(userInfo);-
248 setUrl(newUrl);-
249-
250 error(QNetworkReply::AuthenticationRequiredError,-
251 tr("Logging in to %1 failed: authentication required")-
252 .arg(url().host()));-
253 } else {
executed 3 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
3
254 // we did not connect-
255 QNetworkReply::NetworkError code;-
256 switch (ftp->error()) {-
257 case QFtp::HostNotFound:
executed 1 time by 1 test: case QFtp::HostNotFound:
Executed by:
  • tst_QNetworkReply
1
258 code = QNetworkReply::HostNotFoundError;-
259 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QNetworkReply
1
260-
261 case QFtp::ConnectionRefused:
never executed: case QFtp::ConnectionRefused:
0
262 code = QNetworkReply::ConnectionRefusedError;-
263 break;
never executed: break;
0
264-
265 default:
never executed: default:
0
266 code = QNetworkReply::ProtocolFailure;-
267 break;
never executed: break;
0
268 }-
269-
270 error(code, ftp->errorString());-
271 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
272-
273 // we're not connected, so remove the cache entry:-
274 disconnectFromFtp(RemoveCachedConnection);-
275 finished();-
276 return;
executed 4 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
4
277 }-
278-
279 // check for errors:-
280 if (ftp->error() != QFtp::NoError) {
ftp->error() != QFtp::NoErrorDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 169 times by 1 test
Evaluated by:
  • tst_QNetworkReply
5-169
281 QString msg;-
282 if (operation() == QNetworkAccessManager::GetOperation)
operation() ==...::GetOperationDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-5
283 msg = tr("Error while downloading %1: %2");
executed 5 times by 1 test: msg = tr("Error while downloading %1: %2");
Executed by:
  • tst_QNetworkReply
5
284 else-
285 msg = tr("Error while uploading %1: %2");
never executed: msg = tr("Error while uploading %1: %2");
0
286 msg = msg.arg(url().toString(), ftp->errorString());-
287-
288 if (state == Statting)
state == StattingDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
1-4
289 // file probably doesn't exist-
290 error(QNetworkReply::ContentNotFoundError, msg);
executed 4 times by 1 test: error(QNetworkReply::ContentNotFoundError, msg);
Executed by:
  • tst_QNetworkReply
4
291 else-
292 error(QNetworkReply::ContentAccessDenied, msg);
executed 1 time by 1 test: error(QNetworkReply::ContentAccessDenied, msg);
Executed by:
  • tst_QNetworkReply
1
293-
294 disconnectFromFtp(RemoveCachedConnection);-
295 finished();-
296 }
executed 5 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
5
297-
298 if (state == LoggingIn) {
state == LoggingInDescription
TRUEevaluated 45 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 129 times by 1 test
Evaluated by:
  • tst_QNetworkReply
45-129
299 state = CheckingFeatures;-
300 if (operation() == QNetworkAccessManager::GetOperation) {
operation() ==...::GetOperationDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QNetworkReply
11-34
301 // send help command to find out if server supports "SIZE" and "MDTM"-
302 QString command = url().path();-
303 command.prepend(QLatin1String("%1 "));-
304 helpId = ftp->rawCommand(QLatin1String("HELP")); // get supported commands-
305 } else {
executed 34 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
34
306 ftpDone();-
307 }
executed 11 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
11
308 } else if (state == CheckingFeatures) {
state == CheckingFeaturesDescription
TRUEevaluated 45 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 84 times by 1 test
Evaluated by:
  • tst_QNetworkReply
45-84
309 state = Statting;-
310 if (operation() == QNetworkAccessManager::GetOperation) {
operation() ==...::GetOperationDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QNetworkReply
11-34
311 // logged in successfully, send the stat requests (if supported)-
312 QString command = url().path();-
313 command.prepend(QLatin1String("%1 "));-
314 if (supportsSize) {
supportsSizeDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-34
315 ftp->rawCommand(QLatin1String("TYPE I"));-
316 sizeId = ftp->rawCommand(command.arg(QLatin1String("SIZE"))); // get size-
317 }
executed 34 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
34
318 if (supportsMdtm)
supportsMdtmDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-34
319 mdtmId = ftp->rawCommand(command.arg(QLatin1String("MDTM"))); // get modified time
executed 34 times by 1 test: mdtmId = ftp->rawCommand(command.arg(QLatin1String("MDTM")));
Executed by:
  • tst_QNetworkReply
34
320 if (!supportsSize && !supportsMdtm)
!supportsSizeDescription
TRUEnever evaluated
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
!supportsMdtmDescription
TRUEnever evaluated
FALSEnever evaluated
0-34
321 ftpDone(); // no commands sent, move to the next state
never executed: ftpDone();
0
322 } else {
executed 34 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
34
323 ftpDone();-
324 }
executed 11 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
11
325 } else if (state == Statting) {
state == StattingDescription
TRUEevaluated 41 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 43 times by 1 test
Evaluated by:
  • tst_QNetworkReply
41-43
326 // statted successfully, send the actual request-
327 emit metaDataChanged();-
328 state = Transferring;-
329-
330 QFtp::TransferType type = QFtp::Binary;-
331 if (operation() == QNetworkAccessManager::GetOperation) {
operation() ==...::GetOperationDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 11 times by 1 test
Evaluated by:
  • tst_QNetworkReply
11-30
332 setCachingEnabled(true);-
333 ftp->get(url().path(), 0, type);-
334 } else {
executed 30 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
30
335 ftp->put(uploadDevice, url().path(), type);-
336 }
executed 11 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
11
337-
338 } else if (state == Transferring) {
state == TransferringDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_QNetworkReply
5-38
339 // upload or download finished-
340 disconnectFromFtp();-
341 finished();-
342 }
executed 38 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
38
343}
executed 174 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
174
344-
345void QNetworkAccessFtpBackend::ftpReadyRead()-
346{-
347 QByteArray data = ftp->readAll();-
348 QByteDataBuffer list;-
349 list.append(data);-
350 data.clear(); // important because of implicit sharing!-
351 writeDownstreamData(list);-
352}
executed 568 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
568
353-
354void QNetworkAccessFtpBackend::ftpRawCommandReply(int code, const QString &text)-
355{-
356 //qDebug() << "FTP reply:" << code << text;-
357 int id = ftp->currentId();-
358-
359 if ((id == helpId) && ((code == 200) || (code == 214))) { // supported commands
(id == helpId)Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 98 times by 1 test
Evaluated by:
  • tst_QNetworkReply
(code == 200)Description
TRUEnever evaluated
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
(code == 214)Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-98
360 // the "FEAT" ftp command would be nice here, but it is not part of the-
361 // initial FTP RFC 959, neither ar "SIZE" nor "MDTM" (they are all specified-
362 // in RFC 3659)-
363 if (text.contains(QLatin1String("SIZE"), Qt::CaseSensitive))
text.contains(...CaseSensitive)Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-34
364 supportsSize = true;
executed 34 times by 1 test: supportsSize = true;
Executed by:
  • tst_QNetworkReply
34
365 if (text.contains(QLatin1String("MDTM"), Qt::CaseSensitive))
text.contains(...CaseSensitive)Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-34
366 supportsMdtm = true;
executed 34 times by 1 test: supportsMdtm = true;
Executed by:
  • tst_QNetworkReply
34
367 } else if (code == 213) { // file status
executed 34 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
code == 213Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 38 times by 1 test
Evaluated by:
  • tst_QNetworkReply
34-60
368 if (id == sizeId) {
id == sizeIdDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
30
369 // reply to the size command-
370 setHeader(QNetworkRequest::ContentLengthHeader, text.toLongLong());-
371#ifndef QT_NO_DATESTRING-
372 } else if (id == mdtmId) {
executed 30 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
id == mdtmIdDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-30
373 QDateTime dt = QDateTime::fromString(text, QLatin1String("yyyyMMddHHmmss"));-
374 setHeader(QNetworkRequest::LastModifiedHeader, dt);-
375#endif-
376 }
executed 30 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
30
377 }
executed 60 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
60
378}
executed 132 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
132
379-
380QT_END_NAMESPACE-
381-
382#endif // QT_NO_FTP-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9