access/qnetworkaccessftpbackend.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 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#include "qnetworkaccessftpbackend_p.h" -
43#include "qnetworkaccessmanager_p.h" -
44#include "QtNetwork/qauthenticator.h" -
45#include "private/qnoncontiguousbytedevice_p.h" -
46 -
47#ifndef QT_NO_FTP -
48 -
49QT_BEGIN_NAMESPACE -
50 -
51enum { -
52 DefaultFtpPort = 21 -
53}; -
54 -
55static QByteArray makeCacheKey(const QUrl &url) -
56{ -
57 QUrl copy = url;
executed (the execution status of this line is deduced): QUrl copy = url;
-
58 copy.setPort(url.port(DefaultFtpPort));
executed (the execution status of this line is deduced): copy.setPort(url.port(DefaultFtpPort));
-
59 return "ftp-connection:" +
executed: return "ftp-connection:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment);
Execution Count:76
76
60 copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery |
executed: return "ftp-connection:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment);
Execution Count:76
76
61 QUrl::RemoveFragment);
executed: return "ftp-connection:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment);
Execution Count:76
76
62} -
63 -
64QNetworkAccessBackend * -
65QNetworkAccessFtpBackendFactory::create(QNetworkAccessManager::Operation op, -
66 const QNetworkRequest &request) const -
67{ -
68 // is it an operation we know of? -
69 switch (op) { -
70 case QNetworkAccessManager::GetOperation: -
71 case QNetworkAccessManager::PutOperation: -
72 break;
executed: break;
Execution Count:89
89
73 -
74 default: -
75 // no, we can't handle this operation -
76 return 0;
never executed: return 0;
0
77 } -
78 -
79 QUrl url = request.url();
executed (the execution status of this line is deduced): QUrl url = request.url();
-
80 if (url.scheme().compare(QLatin1String("ftp"), Qt::CaseInsensitive) == 0)
evaluated: url.scheme().compare(QLatin1String("ftp"), Qt::CaseInsensitive) == 0
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:47
42-47
81 return new QNetworkAccessFtpBackend;
executed: return new QNetworkAccessFtpBackend;
Execution Count:42
42
82 return 0;
executed: return 0;
Execution Count:47
47
83} -
84 -
85class QNetworkAccessCachedFtpConnection: public QFtp, public QNetworkAccessCache::CacheableObject -
86{ -
87 // Q_OBJECT -
88public: -
89 QNetworkAccessCachedFtpConnection() -
90 { -
91 setExpires(true);
executed (the execution status of this line is deduced): setExpires(true);
-
92 setShareable(false);
executed (the execution status of this line is deduced): setShareable(false);
-
93 }
executed: }
Execution Count:37
37
94 -
95 void dispose() -
96 { -
97 connect(this, SIGNAL(done(bool)), this, SLOT(deleteLater()));
executed (the execution status of this line is deduced): connect(this, "2""done(bool)", this, "1""deleteLater()");
-
98 close();
executed (the execution status of this line is deduced): close();
-
99 }
executed: }
Execution Count:37
37
100}; -
101 -
102QNetworkAccessFtpBackend::QNetworkAccessFtpBackend() -
103 : ftp(0), uploadDevice(0), totalBytes(0), helpId(-1), sizeId(-1), mdtmId(-1), -
104 supportsSize(false), supportsMdtm(false), state(Idle) -
105{ -
106}
executed: }
Execution Count:42
42
107 -
108QNetworkAccessFtpBackend::~QNetworkAccessFtpBackend() -
109{ -
110 //if backend destroyed while in use, then abort (this is the code path from QNetworkReply::abort) -
111 if (ftp && state != Disconnecting)
evaluated: ftp
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:41
partially evaluated: state != Disconnecting
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-41
112 ftp->abort();
never executed: ftp->abort();
0
113 disconnectFromFtp();
executed (the execution status of this line is deduced): disconnectFromFtp();
-
114}
executed: }
Execution Count:42
42
115 -
116void QNetworkAccessFtpBackend::open() -
117{ -
118#ifndef QT_NO_NETWORKPROXY -
119 QNetworkProxy proxy;
executed (the execution status of this line is deduced): QNetworkProxy proxy;
-
120 foreach (const QNetworkProxy &p, proxyList()) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(proxyList())> _container_(proxyList()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QNetworkProxy &p = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
121 // use the first FTP proxy -
122 // or no proxy at all -
123 if (p.type() == QNetworkProxy::FtpCachingProxy
evaluated: p.type() == QNetworkProxy::FtpCachingProxy
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:42
2-42
124 || p.type() == QNetworkProxy::NoProxy) {
evaluated: p.type() == QNetworkProxy::NoProxy
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:5
5-37
125 proxy = p;
executed (the execution status of this line is deduced): proxy = p;
-
126 break;
executed: break;
Execution Count:39
39
127 } -
128 }
executed: }
Execution Count:5
5
129 -
130 // did we find an FTP proxy or a NoProxy? -
131 if (proxy.type() == QNetworkProxy::DefaultProxy) {
evaluated: proxy.type() == QNetworkProxy::DefaultProxy
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:39
3-39
132 // unsuitable proxies -
133 error(QNetworkReply::ProxyNotFoundError,
executed (the execution status of this line is deduced): error(QNetworkReply::ProxyNotFoundError,
-
134 tr("No suitable proxy found"));
executed (the execution status of this line is deduced): tr("No suitable proxy found"));
-
135 finished();
executed (the execution status of this line is deduced): finished();
-
136 return;
executed: return;
Execution Count:3
3
137 } -
138 -
139#endif -
140 -
141 QUrl url = this->url();
executed (the execution status of this line is deduced): QUrl url = this->url();
-
142 if (url.path().isEmpty()) {
evaluated: url.path().isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:38
1-38
143 url.setPath(QLatin1String("/"));
executed (the execution status of this line is deduced): url.setPath(QLatin1String("/"));
-
144 setUrl(url);
executed (the execution status of this line is deduced): setUrl(url);
-
145 }
executed: }
Execution Count:1
1
146 if (url.path().endsWith(QLatin1Char('/'))) {
evaluated: url.path().endsWith(QLatin1Char('/'))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:38
1-38
147 error(QNetworkReply::ContentOperationNotPermittedError,
executed (the execution status of this line is deduced): error(QNetworkReply::ContentOperationNotPermittedError,
-
148 tr("Cannot open %1: is a directory").arg(url.toString()));
executed (the execution status of this line is deduced): tr("Cannot open %1: is a directory").arg(url.toString()));
-
149 finished();
executed (the execution status of this line is deduced): finished();
-
150 return;
executed: return;
Execution Count:1
1
151 } -
152 state = LoggingIn;
executed (the execution status of this line is deduced): state = LoggingIn;
-
153 -
154 QNetworkAccessCache* objectCache = QNetworkAccessManagerPrivate::getObjectCache(this);
executed (the execution status of this line is deduced): QNetworkAccessCache* objectCache = QNetworkAccessManagerPrivate::getObjectCache(this);
-
155 QByteArray cacheKey = makeCacheKey(url);
executed (the execution status of this line is deduced): QByteArray cacheKey = makeCacheKey(url);
-
156 if (!objectCache->requestEntry(cacheKey, this,
evaluated: !objectCache->requestEntry(cacheKey, this, "1""ftpConnectionReady(QNetworkAccessCache::CacheableObject*)")
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:1
1-37
157 SLOT(ftpConnectionReady(QNetworkAccessCache::CacheableObject*)))) {
evaluated: !objectCache->requestEntry(cacheKey, this, "1""ftpConnectionReady(QNetworkAccessCache::CacheableObject*)")
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:1
1-37
158 ftp = new QNetworkAccessCachedFtpConnection;
executed (the execution status of this line is deduced): ftp = new QNetworkAccessCachedFtpConnection;
-
159#ifndef QT_NO_BEARERMANAGEMENT -
160 //copy network session down to the QFtp -
161 ftp->setProperty("_q_networksession", property("_q_networksession"));
executed (the execution status of this line is deduced): ftp->setProperty("_q_networksession", property("_q_networksession"));
-
162#endif -
163#ifndef QT_NO_NETWORKPROXY -
164 if (proxy.type() == QNetworkProxy::FtpCachingProxy)
evaluated: proxy.type() == QNetworkProxy::FtpCachingProxy
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:35
2-35
165 ftp->setProxy(proxy.hostName(), proxy.port());
executed: ftp->setProxy(proxy.hostName(), proxy.port());
Execution Count:2
2
166#endif -
167 ftp->connectToHost(url.host(), url.port(DefaultFtpPort));
executed (the execution status of this line is deduced): ftp->connectToHost(url.host(), url.port(DefaultFtpPort));
-
168 ftp->login(url.userName(), url.password());
executed (the execution status of this line is deduced): ftp->login(url.userName(), url.password());
-
169 -
170 objectCache->addEntry(cacheKey, ftp);
executed (the execution status of this line is deduced): objectCache->addEntry(cacheKey, ftp);
-
171 ftpConnectionReady(ftp);
executed (the execution status of this line is deduced): ftpConnectionReady(ftp);
-
172 }
executed: }
Execution Count:37
37
173 -
174 // Put operation -
175 if (operation() == QNetworkAccessManager::PutOperation) {
evaluated: operation() == QNetworkAccessManager::PutOperation
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:27
11-27
176 uploadDevice = QNonContiguousByteDeviceFactory::wrap(createUploadByteDevice());
executed (the execution status of this line is deduced): uploadDevice = QNonContiguousByteDeviceFactory::wrap(createUploadByteDevice());
-
177 uploadDevice->setParent(this);
executed (the execution status of this line is deduced): uploadDevice->setParent(this);
-
178 }
executed: }
Execution Count:11
11
179}
executed: }
Execution Count:38
38
180 -
181void QNetworkAccessFtpBackend::closeDownstreamChannel() -
182{ -
183 state = Disconnecting;
executed (the execution status of this line is deduced): state = Disconnecting;
-
184 if (operation() == QNetworkAccessManager::GetOperation)
partially evaluated: operation() == QNetworkAccessManager::GetOperation
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
185 ftp->abort();
executed: ftp->abort();
Execution Count:1
1
186}
executed: }
Execution Count:1
1
187 -
188void QNetworkAccessFtpBackend::downstreamReadyWrite() -
189{ -
190 if (state == Transferring && ftp && ftp->bytesAvailable())
evaluated: state == Transferring
TRUEFALSE
yes
Evaluation Count:787
yes
Evaluation Count:27
partially evaluated: ftp
TRUEFALSE
yes
Evaluation Count:787
no
Evaluation Count:0
partially evaluated: ftp->bytesAvailable()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:787
0-787
191 ftpReadyRead();
never executed: ftpReadyRead();
0
192}
executed: }
Execution Count:814
814
193 -
194void QNetworkAccessFtpBackend::ftpConnectionReady(QNetworkAccessCache::CacheableObject *o) -
195{ -
196 ftp = static_cast<QNetworkAccessCachedFtpConnection *>(o);
executed (the execution status of this line is deduced): ftp = static_cast<QNetworkAccessCachedFtpConnection *>(o);
-
197 connect(ftp, SIGNAL(done(bool)), SLOT(ftpDone()));
executed (the execution status of this line is deduced): connect(ftp, "2""done(bool)", "1""ftpDone()");
-
198 connect(ftp, SIGNAL(rawCommandReply(int,QString)), SLOT(ftpRawCommandReply(int,QString)));
executed (the execution status of this line is deduced): connect(ftp, "2""rawCommandReply(int,QString)", "1""ftpRawCommandReply(int,QString)");
-
199 connect(ftp, SIGNAL(readyRead()), SLOT(ftpReadyRead()));
executed (the execution status of this line is deduced): connect(ftp, "2""readyRead()", "1""ftpReadyRead()");
-
200 -
201 // is the login process done already? -
202 if (ftp->state() == QFtp::LoggedIn)
evaluated: ftp->state() == QFtp::LoggedIn
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:37
1-37
203 ftpDone();
executed: ftpDone();
Execution Count:1
1
204 -
205 // no, defer the actual operation until after we've logged in -
206}
executed: }
Execution Count:38
38
207 -
208void QNetworkAccessFtpBackend::disconnectFromFtp() -
209{ -
210 state = Disconnecting;
executed (the execution status of this line is deduced): state = Disconnecting;
-
211 -
212 if (ftp) {
evaluated: ftp
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:41
36-41
213 disconnect(ftp, 0, this, 0);
executed (the execution status of this line is deduced): disconnect(ftp, 0, this, 0);
-
214 -
215 QByteArray key = makeCacheKey(url());
executed (the execution status of this line is deduced): QByteArray key = makeCacheKey(url());
-
216 QNetworkAccessManagerPrivate::getObjectCache(this)->releaseEntry(key);
executed (the execution status of this line is deduced): QNetworkAccessManagerPrivate::getObjectCache(this)->releaseEntry(key);
-
217 -
218 ftp = 0;
executed (the execution status of this line is deduced): ftp = 0;
-
219 }
executed: }
Execution Count:36
36
220}
executed: }
Execution Count:77
77
221 -
222void QNetworkAccessFtpBackend::ftpDone() -
223{ -
224 // the last command we sent is done -
225 if (state == LoggingIn && ftp->state() != QFtp::LoggedIn) {
evaluated: state == LoggingIn
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:104
evaluated: ftp->state() != QFtp::LoggedIn
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:36
2-104
226 if (ftp->state() == QFtp::Connected) {
evaluated: ftp->state() == QFtp::Connected
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
227 // the login did not succeed -
228 QUrl newUrl = url();
executed (the execution status of this line is deduced): QUrl newUrl = url();
-
229 QString userInfo = newUrl.userInfo();
executed (the execution status of this line is deduced): QString userInfo = newUrl.userInfo();
-
230 newUrl.setUserInfo(QString());
executed (the execution status of this line is deduced): newUrl.setUserInfo(QString());
-
231 setUrl(newUrl);
executed (the execution status of this line is deduced): setUrl(newUrl);
-
232 -
233 QAuthenticator auth;
executed (the execution status of this line is deduced): QAuthenticator auth;
-
234 authenticationRequired(&auth);
executed (the execution status of this line is deduced): authenticationRequired(&auth);
-
235 -
236 if (!auth.isNull()) {
partially evaluated: !auth.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
237 // try again: -
238 newUrl.setUserName(auth.user());
never executed (the execution status of this line is deduced): newUrl.setUserName(auth.user());
-
239 ftp->login(auth.user(), auth.password());
never executed (the execution status of this line is deduced): ftp->login(auth.user(), auth.password());
-
240 return;
never executed: return;
0
241 } -
242 -
243 // Re insert the user info so that we can remove the cache entry. -
244 newUrl.setUserInfo(userInfo);
executed (the execution status of this line is deduced): newUrl.setUserInfo(userInfo);
-
245 setUrl(newUrl);
executed (the execution status of this line is deduced): setUrl(newUrl);
-
246 -
247 error(QNetworkReply::AuthenticationRequiredError,
executed (the execution status of this line is deduced): error(QNetworkReply::AuthenticationRequiredError,
-
248 tr("Logging in to %1 failed: authentication required")
executed (the execution status of this line is deduced): tr("Logging in to %1 failed: authentication required")
-
249 .arg(url().host()));
executed (the execution status of this line is deduced): .arg(url().host()));
-
250 } else {
executed: }
Execution Count:1
1
251 // we did not connect -
252 QNetworkReply::NetworkError code;
executed (the execution status of this line is deduced): QNetworkReply::NetworkError code;
-
253 switch (ftp->error()) { -
254 case QFtp::HostNotFound: -
255 code = QNetworkReply::HostNotFoundError;
executed (the execution status of this line is deduced): code = QNetworkReply::HostNotFoundError;
-
256 break;
executed: break;
Execution Count:1
1
257 -
258 case QFtp::ConnectionRefused: -
259 code = QNetworkReply::ConnectionRefusedError;
never executed (the execution status of this line is deduced): code = QNetworkReply::ConnectionRefusedError;
-
260 break;
never executed: break;
0
261 -
262 default: -
263 code = QNetworkReply::ProtocolFailure;
never executed (the execution status of this line is deduced): code = QNetworkReply::ProtocolFailure;
-
264 break;
never executed: break;
0
265 } -
266 -
267 error(code, ftp->errorString());
executed (the execution status of this line is deduced): error(code, ftp->errorString());
-
268 }
executed: }
Execution Count:1
1
269 -
270 // we're not connected, so remove the cache entry: -
271 QByteArray key = makeCacheKey(url());
executed (the execution status of this line is deduced): QByteArray key = makeCacheKey(url());
-
272 QNetworkAccessManagerPrivate::getObjectCache(this)->removeEntry(key);
executed (the execution status of this line is deduced): QNetworkAccessManagerPrivate::getObjectCache(this)->removeEntry(key);
-
273 -
274 disconnect(ftp, 0, this, 0);
executed (the execution status of this line is deduced): disconnect(ftp, 0, this, 0);
-
275 ftp->dispose();
executed (the execution status of this line is deduced): ftp->dispose();
-
276 ftp = 0;
executed (the execution status of this line is deduced): ftp = 0;
-
277 -
278 state = Disconnecting;
executed (the execution status of this line is deduced): state = Disconnecting;
-
279 finished();
executed (the execution status of this line is deduced): finished();
-
280 return;
executed: return;
Execution Count:2
2
281 } -
282 -
283 // check for errors: -
284 if (ftp->error() != QFtp::NoError) {
evaluated: ftp->error() != QFtp::NoError
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:136
4-136
285 QString msg;
executed (the execution status of this line is deduced): QString msg;
-
286 if (operation() == QNetworkAccessManager::GetOperation)
partially evaluated: operation() == QNetworkAccessManager::GetOperation
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
287 msg = tr("Error while downloading %1: %2");
executed: msg = tr("Error while downloading %1: %2");
Execution Count:4
4
288 else -
289 msg = tr("Error while uploading %1: %2");
never executed: msg = tr("Error while uploading %1: %2");
0
290 msg = msg.arg(url().toString(), ftp->errorString());
executed (the execution status of this line is deduced): msg = msg.arg(url().toString(), ftp->errorString());
-
291 -
292 if (state == Statting)
evaluated: state == Statting
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
293 // file probably doesn't exist -
294 error(QNetworkReply::ContentNotFoundError, msg);
executed: error(QNetworkReply::ContentNotFoundError, msg);
Execution Count:3
3
295 else -
296 error(QNetworkReply::ContentAccessDenied, msg);
executed: error(QNetworkReply::ContentAccessDenied, msg);
Execution Count:1
1
297 -
298 disconnectFromFtp();
executed (the execution status of this line is deduced): disconnectFromFtp();
-
299 finished();
executed (the execution status of this line is deduced): finished();
-
300 }
executed: }
Execution Count:4
4
301 -
302 if (state == LoggingIn) {
evaluated: state == LoggingIn
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:104
36-104
303 state = CheckingFeatures;
executed (the execution status of this line is deduced): state = CheckingFeatures;
-
304 if (operation() == QNetworkAccessManager::GetOperation) {
evaluated: operation() == QNetworkAccessManager::GetOperation
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:11
11-25
305 // send help command to find out if server supports "SIZE" and "MDTM" -
306 QString command = url().path();
executed (the execution status of this line is deduced): QString command = url().path();
-
307 command.prepend(QLatin1String("%1 "));
executed (the execution status of this line is deduced): command.prepend(QLatin1String("%1 "));
-
308 helpId = ftp->rawCommand(QLatin1String("HELP")); // get supported commands
executed (the execution status of this line is deduced): helpId = ftp->rawCommand(QLatin1String("HELP"));
-
309 } else {
executed: }
Execution Count:25
25
310 ftpDone();
executed (the execution status of this line is deduced): ftpDone();
-
311 }
executed: }
Execution Count:11
11
312 } else if (state == CheckingFeatures) {
evaluated: state == CheckingFeatures
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:68
36-68
313 state = Statting;
executed (the execution status of this line is deduced): state = Statting;
-
314 if (operation() == QNetworkAccessManager::GetOperation) {
evaluated: operation() == QNetworkAccessManager::GetOperation
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:11
11-25
315 // logged in successfully, send the stat requests (if supported) -
316 QString command = url().path();
executed (the execution status of this line is deduced): QString command = url().path();
-
317 command.prepend(QLatin1String("%1 "));
executed (the execution status of this line is deduced): command.prepend(QLatin1String("%1 "));
-
318 if (supportsSize) {
partially evaluated: supportsSize
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
319 ftp->rawCommand(QLatin1String("TYPE I"));
executed (the execution status of this line is deduced): ftp->rawCommand(QLatin1String("TYPE I"));
-
320 sizeId = ftp->rawCommand(command.arg(QLatin1String("SIZE"))); // get size
executed (the execution status of this line is deduced): sizeId = ftp->rawCommand(command.arg(QLatin1String("SIZE")));
-
321 }
executed: }
Execution Count:25
25
322 if (supportsMdtm)
partially evaluated: supportsMdtm
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
323 mdtmId = ftp->rawCommand(command.arg(QLatin1String("MDTM"))); // get modified time
executed: mdtmId = ftp->rawCommand(command.arg(QLatin1String("MDTM")));
Execution Count:25
25
324 if (!supportsSize && !supportsMdtm)
partially evaluated: !supportsSize
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
never evaluated: !supportsMdtm
0-25
325 ftpDone(); // no commands sent, move to the next state
never executed: ftpDone();
0
326 } else {
executed: }
Execution Count:25
25
327 ftpDone();
executed (the execution status of this line is deduced): ftpDone();
-
328 }
executed: }
Execution Count:11
11
329 } else if (state == Statting) {
evaluated: state == Statting
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:35
33-35
330 // statted successfully, send the actual request -
331 emit metaDataChanged();
executed (the execution status of this line is deduced): metaDataChanged();
-
332 state = Transferring;
executed (the execution status of this line is deduced): state = Transferring;
-
333 -
334 QFtp::TransferType type = QFtp::Binary;
executed (the execution status of this line is deduced): QFtp::TransferType type = QFtp::Binary;
-
335 if (operation() == QNetworkAccessManager::GetOperation) {
evaluated: operation() == QNetworkAccessManager::GetOperation
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:11
11-22
336 setCachingEnabled(true);
executed (the execution status of this line is deduced): setCachingEnabled(true);
-
337 ftp->get(url().path(), 0, type);
executed (the execution status of this line is deduced): ftp->get(url().path(), 0, type);
-
338 } else {
executed: }
Execution Count:22
22
339 ftp->put(uploadDevice, url().path(), type);
executed (the execution status of this line is deduced): ftp->put(uploadDevice, url().path(), type);
-
340 }
executed: }
Execution Count:11
11
341 -
342 } else if (state == Transferring) {
evaluated: state == Transferring
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:4
4-31
343 // upload or download finished -
344 disconnectFromFtp();
executed (the execution status of this line is deduced): disconnectFromFtp();
-
345 finished();
executed (the execution status of this line is deduced): finished();
-
346 }
executed: }
Execution Count:31
31
347} -
348 -
349void QNetworkAccessFtpBackend::ftpReadyRead() -
350{ -
351 QByteArray data = ftp->readAll();
executed (the execution status of this line is deduced): QByteArray data = ftp->readAll();
-
352 QByteDataBuffer list;
executed (the execution status of this line is deduced): QByteDataBuffer list;
-
353 list.append(data);
executed (the execution status of this line is deduced): list.append(data);
-
354 data.clear(); // important because of implicit sharing!
executed (the execution status of this line is deduced): data.clear();
-
355 writeDownstreamData(list);
executed (the execution status of this line is deduced): writeDownstreamData(list);
-
356}
executed: }
Execution Count:788
788
357 -
358void QNetworkAccessFtpBackend::ftpRawCommandReply(int code, const QString &text) -
359{ -
360 //qDebug() << "FTP reply:" << code << text; -
361 int id = ftp->currentId();
executed (the execution status of this line is deduced): int id = ftp->currentId();
-
362 -
363 if ((id == helpId) && ((code == 200) || (code == 214))) { // supported commands
evaluated: (id == helpId)
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:72
partially evaluated: (code == 200)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
partially evaluated: (code == 214)
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-72
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))
partially evaluated: text.contains(QLatin1String("SIZE"), Qt::CaseSensitive)
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
368 supportsSize = true;
executed: supportsSize = true;
Execution Count:25
25
369 if (text.contains(QLatin1String("MDTM"), Qt::CaseSensitive))
partially evaluated: text.contains(QLatin1String("MDTM"), Qt::CaseSensitive)
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
370 supportsMdtm = true;
executed: supportsMdtm = true;
Execution Count:25
25
371 } else if (code == 213) { // file status
executed: }
Execution Count:25
evaluated: code == 213
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:28
25-44
372 if (id == sizeId) {
evaluated: id == sizeId
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:22
22
373 // reply to the size command -
374 setHeader(QNetworkRequest::ContentLengthHeader, text.toLongLong());
executed (the execution status of this line is deduced): setHeader(QNetworkRequest::ContentLengthHeader, text.toLongLong());
-
375#ifndef QT_NO_DATESTRING -
376 } else if (id == mdtmId) {
executed: }
Execution Count:22
partially evaluated: id == mdtmId
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
0-22
377 QDateTime dt = QDateTime::fromString(text, QLatin1String("yyyyMMddHHmmss"));
executed (the execution status of this line is deduced): QDateTime dt = QDateTime::fromString(text, QLatin1String("yyyyMMddHHmmss"));
-
378 setHeader(QNetworkRequest::LastModifiedHeader, dt);
executed (the execution status of this line is deduced): setHeader(QNetworkRequest::LastModifiedHeader, dt);
-
379#endif -
380 }
executed: }
Execution Count:22
22
381 } -
382} -
383 -
384QT_END_NAMESPACE -
385 -
386#endif // QT_NO_FTP -
387 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial