OpenCoverage

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

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