Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkaccessftpbackend.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||||||||||||||
6 | enum { | - | ||||||||||||||||||||||||||||||||||||
7 | DefaultFtpPort = 21 | - | ||||||||||||||||||||||||||||||||||||
8 | }; | - | ||||||||||||||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||||||||||||||
10 | static QByteArray makeCacheKey(const QUrl &url) | - | ||||||||||||||||||||||||||||||||||||
11 | { | - | ||||||||||||||||||||||||||||||||||||
12 | QUrl copy = url; | - | ||||||||||||||||||||||||||||||||||||
13 | copy.setPort(url.port(DefaultFtpPort)); | - | ||||||||||||||||||||||||||||||||||||
14 | return executed 98 times by 1 test: "ftp-connection:" +return "ftp-connection:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment); Executed by:
executed 98 times by 1 test: return "ftp-connection:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment); Executed by:
| 98 | ||||||||||||||||||||||||||||||||||||
15 | 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:
| 98 | ||||||||||||||||||||||||||||||||||||
16 | QUrl::RemoveFragment); executed 98 times by 1 test: return "ftp-connection:" + copy.toEncoded(QUrl::RemovePassword | QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemoveFragment); Executed by:
| 98 | ||||||||||||||||||||||||||||||||||||
17 | } | - | ||||||||||||||||||||||||||||||||||||
18 | - | |||||||||||||||||||||||||||||||||||||
19 | QStringList QNetworkAccessFtpBackendFactory::supportedSchemes() const | - | ||||||||||||||||||||||||||||||||||||
20 | { | - | ||||||||||||||||||||||||||||||||||||
21 | return never executed: 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); returnreturn 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: qstring_literal_temp;return qstring_literal_temp; never executed: }()));return qstring_literal_temp; 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; }())); | 0 | ||||||||||||||||||||||||||||||||||||
22 | } | - | ||||||||||||||||||||||||||||||||||||
23 | - | |||||||||||||||||||||||||||||||||||||
24 | QNetworkAccessBackend * | - | ||||||||||||||||||||||||||||||||||||
25 | QNetworkAccessFtpBackendFactory::create(QNetworkAccessManager::Operation op, | - | ||||||||||||||||||||||||||||||||||||
26 | const QNetworkRequest &request) const | - | ||||||||||||||||||||||||||||||||||||
27 | { | - | ||||||||||||||||||||||||||||||||||||
28 | - | |||||||||||||||||||||||||||||||||||||
29 | switch (op) { | - | ||||||||||||||||||||||||||||||||||||
30 | case executed 49 times by 1 test: QNetworkAccessManager::GetOperation:case QNetworkAccessManager::GetOperation: Executed by:
executed 49 times by 1 test: case QNetworkAccessManager::GetOperation: Executed by:
| 49 | ||||||||||||||||||||||||||||||||||||
31 | case executed 59 times by 1 test: QNetworkAccessManager::PutOperation:case QNetworkAccessManager::PutOperation: Executed by:
executed 59 times by 1 test: case QNetworkAccessManager::PutOperation: Executed by:
| 59 | ||||||||||||||||||||||||||||||||||||
32 | break; executed 108 times by 1 test: break; Executed by:
| 108 | ||||||||||||||||||||||||||||||||||||
33 | - | |||||||||||||||||||||||||||||||||||||
34 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
35 | - | |||||||||||||||||||||||||||||||||||||
36 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||
37 | } | - | ||||||||||||||||||||||||||||||||||||
38 | - | |||||||||||||||||||||||||||||||||||||
39 | QUrl url = request.url(); | - | ||||||||||||||||||||||||||||||||||||
40 | if (url.scheme().compare(QLatin1String("ftp"), Qt::CaseInsensitive) == 0
| 54 | ||||||||||||||||||||||||||||||||||||
41 | return executed 54 times by 1 test: new QNetworkAccessFtpBackend;return new QNetworkAccessFtpBackend; Executed by:
executed 54 times by 1 test: return new QNetworkAccessFtpBackend; Executed by:
| 54 | ||||||||||||||||||||||||||||||||||||
42 | return executed 54 times by 1 test: 0;return 0; Executed by:
executed 54 times by 1 test: return 0; Executed by:
| 54 | ||||||||||||||||||||||||||||||||||||
43 | } | - | ||||||||||||||||||||||||||||||||||||
44 | - | |||||||||||||||||||||||||||||||||||||
45 | class QNetworkAccessCachedFtpConnection: public QFtp, public QNetworkAccessCache::CacheableObject | - | ||||||||||||||||||||||||||||||||||||
46 | { | - | ||||||||||||||||||||||||||||||||||||
47 | - | |||||||||||||||||||||||||||||||||||||
48 | public: | - | ||||||||||||||||||||||||||||||||||||
49 | QNetworkAccessCachedFtpConnection() | - | ||||||||||||||||||||||||||||||||||||
50 | { | - | ||||||||||||||||||||||||||||||||||||
51 | setExpires(true); | - | ||||||||||||||||||||||||||||||||||||
52 | setShareable(false); | - | ||||||||||||||||||||||||||||||||||||
53 | } executed 48 times by 1 test: end of block Executed by:
| 48 | ||||||||||||||||||||||||||||||||||||
54 | - | |||||||||||||||||||||||||||||||||||||
55 | void dispose() override | - | ||||||||||||||||||||||||||||||||||||
56 | { | - | ||||||||||||||||||||||||||||||||||||
57 | connect(this, qFlagLocation("2""done(bool)" "\0" __FILE__ ":" "95"), this, qFlagLocation("1""deleteLater()" "\0" __FILE__ ":" "95")); | - | ||||||||||||||||||||||||||||||||||||
58 | close(); | - | ||||||||||||||||||||||||||||||||||||
59 | } executed 48 times by 1 test: end of block Executed by:
| 48 | ||||||||||||||||||||||||||||||||||||
60 | }; | - | ||||||||||||||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||||||||||||||
62 | QNetworkAccessFtpBackend::QNetworkAccessFtpBackend() | - | ||||||||||||||||||||||||||||||||||||
63 | : ftp(0), uploadDevice(0), totalBytes(0), helpId(-1), sizeId(-1), mdtmId(-1), | - | ||||||||||||||||||||||||||||||||||||
64 | supportsSize(false), supportsMdtm(false), state(Idle) | - | ||||||||||||||||||||||||||||||||||||
65 | { | - | ||||||||||||||||||||||||||||||||||||
66 | } executed 54 times by 1 test: end of block Executed by:
| 54 | ||||||||||||||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||||||||||||||
68 | QNetworkAccessFtpBackend::~QNetworkAccessFtpBackend() | - | ||||||||||||||||||||||||||||||||||||
69 | { | - | ||||||||||||||||||||||||||||||||||||
70 | - | |||||||||||||||||||||||||||||||||||||
71 | if (ftp && state != Disconnecting
| 1 | ||||||||||||||||||||||||||||||||||||
72 | ftp->abort(); executed 1 time by 1 test: ftp->abort(); Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
73 | disconnectFromFtp(); | - | ||||||||||||||||||||||||||||||||||||
74 | } executed 54 times by 1 test: end of block Executed by:
| 54 | ||||||||||||||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||||||||||||||
76 | void QNetworkAccessFtpBackend::open() | - | ||||||||||||||||||||||||||||||||||||
77 | { | - | ||||||||||||||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||||||||||||||
79 | QNetworkProxy proxy; | - | ||||||||||||||||||||||||||||||||||||
80 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(proxyList())>::type> _container_((proxyList())); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QNetworkProxy &p = *_container_.i; _container_.control; _container_.control = 0) { | - | ||||||||||||||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||||||||||||||
82 | - | |||||||||||||||||||||||||||||||||||||
83 | if (p.type() == QNetworkProxy::FtpCachingProxy
| 2-53 | ||||||||||||||||||||||||||||||||||||
84 | || p.type() == QNetworkProxy::NoProxy
| 5-48 | ||||||||||||||||||||||||||||||||||||
85 | proxy = p; | - | ||||||||||||||||||||||||||||||||||||
86 | break; executed 50 times by 1 test: break; Executed by:
| 50 | ||||||||||||||||||||||||||||||||||||
87 | } | - | ||||||||||||||||||||||||||||||||||||
88 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||
89 | - | |||||||||||||||||||||||||||||||||||||
90 | - | |||||||||||||||||||||||||||||||||||||
91 | if (proxy.type() == QNetworkProxy::DefaultProxy
| 3-50 | ||||||||||||||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||||||||||||||
93 | error(QNetworkReply::ProxyNotFoundError, | - | ||||||||||||||||||||||||||||||||||||
94 | tr("No suitable proxy found")); | - | ||||||||||||||||||||||||||||||||||||
95 | finished(); | - | ||||||||||||||||||||||||||||||||||||
96 | return; executed 3 times by 1 test: return; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||
97 | } | - | ||||||||||||||||||||||||||||||||||||
98 | - | |||||||||||||||||||||||||||||||||||||
99 | - | |||||||||||||||||||||||||||||||||||||
100 | - | |||||||||||||||||||||||||||||||||||||
101 | QUrl url = this->url(); | - | ||||||||||||||||||||||||||||||||||||
102 | if (url.path().isEmpty()
| 1-49 | ||||||||||||||||||||||||||||||||||||
103 | url.setPath(QLatin1String("/")); | - | ||||||||||||||||||||||||||||||||||||
104 | setUrl(url); | - | ||||||||||||||||||||||||||||||||||||
105 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
106 | if (url.path().endsWith(QLatin1Char('/'))
| 1-49 | ||||||||||||||||||||||||||||||||||||
107 | error(QNetworkReply::ContentOperationNotPermittedError, | - | ||||||||||||||||||||||||||||||||||||
108 | tr("Cannot open %1: is a directory").arg(url.toString())); | - | ||||||||||||||||||||||||||||||||||||
109 | finished(); | - | ||||||||||||||||||||||||||||||||||||
110 | return; executed 1 time by 1 test: return; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
111 | } | - | ||||||||||||||||||||||||||||||||||||
112 | state = LoggingIn; | - | ||||||||||||||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||||||||||||||
114 | QNetworkAccessCache* objectCache = QNetworkAccessManagerPrivate::getObjectCache(this); | - | ||||||||||||||||||||||||||||||||||||
115 | QByteArray cacheKey = makeCacheKey(url); | - | ||||||||||||||||||||||||||||||||||||
116 | if (!objectCache->requestEntry(cacheKey, this,
| 1-48 | ||||||||||||||||||||||||||||||||||||
117 | qFlagLocation("1""ftpConnectionReady(QNetworkAccessCache::CacheableObject*)" "\0" __FILE__ ":" "155"))
| 1-48 | ||||||||||||||||||||||||||||||||||||
118 | ftp = new QNetworkAccessCachedFtpConnection; | - | ||||||||||||||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||||||||||||||
121 | ftp->setProperty("_q_networksession", property("_q_networksession")); | - | ||||||||||||||||||||||||||||||||||||
122 | - | |||||||||||||||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||||||||||||||
124 | if (proxy.type() == QNetworkProxy::FtpCachingProxy
| 2-46 | ||||||||||||||||||||||||||||||||||||
125 | ftp->setProxy(proxy.hostName(), proxy.port()); executed 2 times by 1 test: ftp->setProxy(proxy.hostName(), proxy.port()); Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||
126 | - | |||||||||||||||||||||||||||||||||||||
127 | ftp->connectToHost(url.host(), url.port(DefaultFtpPort)); | - | ||||||||||||||||||||||||||||||||||||
128 | ftp->login(url.userName(), url.password()); | - | ||||||||||||||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||||||||||||||
130 | objectCache->addEntry(cacheKey, ftp); | - | ||||||||||||||||||||||||||||||||||||
131 | ftpConnectionReady(ftp); | - | ||||||||||||||||||||||||||||||||||||
132 | } executed 48 times by 1 test: end of block Executed by:
| 48 | ||||||||||||||||||||||||||||||||||||
133 | - | |||||||||||||||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||||||||||||||
135 | if (operation() == QNetworkAccessManager::PutOperation
| 13-36 | ||||||||||||||||||||||||||||||||||||
136 | uploadDevice = QNonContiguousByteDeviceFactory::wrap(createUploadByteDevice()); | - | ||||||||||||||||||||||||||||||||||||
137 | uploadDevice->setParent(this); | - | ||||||||||||||||||||||||||||||||||||
138 | } executed 13 times by 1 test: end of block Executed by:
| 13 | ||||||||||||||||||||||||||||||||||||
139 | } executed 49 times by 1 test: end of block Executed by:
| 49 | ||||||||||||||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||||||||||||||
141 | void QNetworkAccessFtpBackend::closeDownstreamChannel() | - | ||||||||||||||||||||||||||||||||||||
142 | { | - | ||||||||||||||||||||||||||||||||||||
143 | state = Disconnecting; | - | ||||||||||||||||||||||||||||||||||||
144 | if (operation() == QNetworkAccessManager::GetOperation
| 0-1 | ||||||||||||||||||||||||||||||||||||
145 | ftp->abort(); executed 1 time by 1 test: ftp->abort(); Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
146 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
147 | - | |||||||||||||||||||||||||||||||||||||
148 | void QNetworkAccessFtpBackend::downstreamReadyWrite() | - | ||||||||||||||||||||||||||||||||||||
149 | { | - | ||||||||||||||||||||||||||||||||||||
150 | if (state == Transferring
| 0-562 | ||||||||||||||||||||||||||||||||||||
151 | ftpReadyRead(); never executed: ftpReadyRead(); | 0 | ||||||||||||||||||||||||||||||||||||
152 | } executed 600 times by 1 test: end of block Executed by:
| 600 | ||||||||||||||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||||||||||||||
154 | void QNetworkAccessFtpBackend::ftpConnectionReady(QNetworkAccessCache::CacheableObject *o) | - | ||||||||||||||||||||||||||||||||||||
155 | { | - | ||||||||||||||||||||||||||||||||||||
156 | ftp = static_cast<QNetworkAccessCachedFtpConnection *>(o); | - | ||||||||||||||||||||||||||||||||||||
157 | connect(ftp, qFlagLocation("2""done(bool)" "\0" __FILE__ ":" "195"), qFlagLocation("1""ftpDone()" "\0" __FILE__ ":" "195")); | - | ||||||||||||||||||||||||||||||||||||
158 | connect(ftp, qFlagLocation("2""rawCommandReply(int,QString)" "\0" __FILE__ ":" "196"), qFlagLocation("1""ftpRawCommandReply(int,QString)" "\0" __FILE__ ":" "196")); | - | ||||||||||||||||||||||||||||||||||||
159 | connect(ftp, qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "197"), qFlagLocation("1""ftpReadyRead()" "\0" __FILE__ ":" "197")); | - | ||||||||||||||||||||||||||||||||||||
160 | - | |||||||||||||||||||||||||||||||||||||
161 | - | |||||||||||||||||||||||||||||||||||||
162 | if (ftp->state() == QFtp::LoggedIn
| 1-48 | ||||||||||||||||||||||||||||||||||||
163 | ftpDone(); executed 1 time by 1 test: ftpDone(); Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
164 | - | |||||||||||||||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||||||||||||||
166 | } executed 49 times by 1 test: end of block Executed by:
| 49 | ||||||||||||||||||||||||||||||||||||
167 | - | |||||||||||||||||||||||||||||||||||||
168 | void QNetworkAccessFtpBackend::disconnectFromFtp(CacheCleanupMode mode) | - | ||||||||||||||||||||||||||||||||||||
169 | { | - | ||||||||||||||||||||||||||||||||||||
170 | state = Disconnecting; | - | ||||||||||||||||||||||||||||||||||||
171 | - | |||||||||||||||||||||||||||||||||||||
172 | if (ftp
| 49-52 | ||||||||||||||||||||||||||||||||||||
173 | disconnect(ftp, 0, this, 0); | - | ||||||||||||||||||||||||||||||||||||
174 | - | |||||||||||||||||||||||||||||||||||||
175 | QByteArray key = makeCacheKey(url()); | - | ||||||||||||||||||||||||||||||||||||
176 | if (mode == RemoveCachedConnection
| 9-40 | ||||||||||||||||||||||||||||||||||||
177 | QNetworkAccessManagerPrivate::getObjectCache(this)->removeEntry(key); | - | ||||||||||||||||||||||||||||||||||||
178 | ftp->dispose(); | - | ||||||||||||||||||||||||||||||||||||
179 | } executed 9 times by 1 test: else {end of block Executed by:
| 9 | ||||||||||||||||||||||||||||||||||||
180 | QNetworkAccessManagerPrivate::getObjectCache(this)->releaseEntry(key); | - | ||||||||||||||||||||||||||||||||||||
181 | } executed 40 times by 1 test: end of block Executed by:
| 40 | ||||||||||||||||||||||||||||||||||||
182 | - | |||||||||||||||||||||||||||||||||||||
183 | ftp = 0; | - | ||||||||||||||||||||||||||||||||||||
184 | } executed 49 times by 1 test: end of block Executed by:
| 49 | ||||||||||||||||||||||||||||||||||||
185 | } executed 101 times by 1 test: end of block Executed by:
| 101 | ||||||||||||||||||||||||||||||||||||
186 | - | |||||||||||||||||||||||||||||||||||||
187 | void QNetworkAccessFtpBackend::ftpDone() | - | ||||||||||||||||||||||||||||||||||||
188 | { | - | ||||||||||||||||||||||||||||||||||||
189 | - | |||||||||||||||||||||||||||||||||||||
190 | if (state == LoggingIn
| 4-129 | ||||||||||||||||||||||||||||||||||||
191 | if (ftp->state() == QFtp::Connected
| 1-3 | ||||||||||||||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||||||||||||||
193 | QUrl newUrl = url(); | - | ||||||||||||||||||||||||||||||||||||
194 | QString userInfo = newUrl.userInfo(); | - | ||||||||||||||||||||||||||||||||||||
195 | newUrl.setUserInfo(QString()); | - | ||||||||||||||||||||||||||||||||||||
196 | setUrl(newUrl); | - | ||||||||||||||||||||||||||||||||||||
197 | - | |||||||||||||||||||||||||||||||||||||
198 | QAuthenticator auth; | - | ||||||||||||||||||||||||||||||||||||
199 | authenticationRequired(&auth); | - | ||||||||||||||||||||||||||||||||||||
200 | - | |||||||||||||||||||||||||||||||||||||
201 | if (!auth.isNull()
| 0-3 | ||||||||||||||||||||||||||||||||||||
202 | - | |||||||||||||||||||||||||||||||||||||
203 | newUrl.setUserName(auth.user()); | - | ||||||||||||||||||||||||||||||||||||
204 | ftp->login(auth.user(), auth.password()); | - | ||||||||||||||||||||||||||||||||||||
205 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||||||||
206 | } | - | ||||||||||||||||||||||||||||||||||||
207 | - | |||||||||||||||||||||||||||||||||||||
208 | - | |||||||||||||||||||||||||||||||||||||
209 | newUrl.setUserInfo(userInfo); | - | ||||||||||||||||||||||||||||||||||||
210 | setUrl(newUrl); | - | ||||||||||||||||||||||||||||||||||||
211 | - | |||||||||||||||||||||||||||||||||||||
212 | error(QNetworkReply::AuthenticationRequiredError, | - | ||||||||||||||||||||||||||||||||||||
213 | tr("Logging in to %1 failed: authentication required") | - | ||||||||||||||||||||||||||||||||||||
214 | .arg(url().host())); | - | ||||||||||||||||||||||||||||||||||||
215 | } executed 3 times by 1 test: else {end of block Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||||||||||||||
217 | QNetworkReply::NetworkError code; | - | ||||||||||||||||||||||||||||||||||||
218 | switch (ftp->error()) { | - | ||||||||||||||||||||||||||||||||||||
219 | case executed 1 time by 1 test: QFtp::HostNotFound:case QFtp::HostNotFound: Executed by:
executed 1 time by 1 test: case QFtp::HostNotFound: Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
220 | code = QNetworkReply::HostNotFoundError; | - | ||||||||||||||||||||||||||||||||||||
221 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||||||||||||||
223 | case never executed: QFtp::ConnectionRefused:case QFtp::ConnectionRefused: never executed: case QFtp::ConnectionRefused: | 0 | ||||||||||||||||||||||||||||||||||||
224 | code = QNetworkReply::ConnectionRefusedError; | - | ||||||||||||||||||||||||||||||||||||
225 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
226 | - | |||||||||||||||||||||||||||||||||||||
227 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||
228 | code = QNetworkReply::ProtocolFailure; | - | ||||||||||||||||||||||||||||||||||||
229 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||||||||
230 | } | - | ||||||||||||||||||||||||||||||||||||
231 | - | |||||||||||||||||||||||||||||||||||||
232 | error(code, ftp->errorString()); | - | ||||||||||||||||||||||||||||||||||||
233 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
234 | - | |||||||||||||||||||||||||||||||||||||
235 | - | |||||||||||||||||||||||||||||||||||||
236 | disconnectFromFtp(RemoveCachedConnection); | - | ||||||||||||||||||||||||||||||||||||
237 | finished(); | - | ||||||||||||||||||||||||||||||||||||
238 | return; executed 4 times by 1 test: return; Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||
239 | } | - | ||||||||||||||||||||||||||||||||||||
240 | - | |||||||||||||||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||||||||||||||
242 | if (ftp->error() != QFtp::NoError
| 5-169 | ||||||||||||||||||||||||||||||||||||
243 | QString msg; | - | ||||||||||||||||||||||||||||||||||||
244 | if (operation() == QNetworkAccessManager::GetOperation
| 0-5 | ||||||||||||||||||||||||||||||||||||
245 | msg = tr("Error while downloading %1: %2"); executed 5 times by 1 test: msg = tr("Error while downloading %1: %2"); Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||
246 | else | - | ||||||||||||||||||||||||||||||||||||
247 | msg = tr("Error while uploading %1: %2"); never executed: msg = tr("Error while uploading %1: %2"); | 0 | ||||||||||||||||||||||||||||||||||||
248 | msg = msg.arg(url().toString(), ftp->errorString()); | - | ||||||||||||||||||||||||||||||||||||
249 | - | |||||||||||||||||||||||||||||||||||||
250 | if (state == Statting
| 1-4 | ||||||||||||||||||||||||||||||||||||
251 | - | |||||||||||||||||||||||||||||||||||||
252 | error(QNetworkReply::ContentNotFoundError, msg); executed 4 times by 1 test: error(QNetworkReply::ContentNotFoundError, msg); Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||
253 | else | - | ||||||||||||||||||||||||||||||||||||
254 | error(QNetworkReply::ContentAccessDenied, msg); executed 1 time by 1 test: error(QNetworkReply::ContentAccessDenied, msg); Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||
255 | - | |||||||||||||||||||||||||||||||||||||
256 | disconnectFromFtp(RemoveCachedConnection); | - | ||||||||||||||||||||||||||||||||||||
257 | finished(); | - | ||||||||||||||||||||||||||||||||||||
258 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||||||||||||||
259 | - | |||||||||||||||||||||||||||||||||||||
260 | if (state == LoggingIn
| 45-129 | ||||||||||||||||||||||||||||||||||||
261 | state = CheckingFeatures; | - | ||||||||||||||||||||||||||||||||||||
262 | if (operation() == QNetworkAccessManager::GetOperation
| 11-34 | ||||||||||||||||||||||||||||||||||||
263 | - | |||||||||||||||||||||||||||||||||||||
264 | QString command = url().path(); | - | ||||||||||||||||||||||||||||||||||||
265 | command.prepend(QLatin1String("%1 ")); | - | ||||||||||||||||||||||||||||||||||||
266 | helpId = ftp->rawCommand(QLatin1String("HELP")); | - | ||||||||||||||||||||||||||||||||||||
267 | } executed 34 times by 1 test: else {end of block Executed by:
| 34 | ||||||||||||||||||||||||||||||||||||
268 | ftpDone(); | - | ||||||||||||||||||||||||||||||||||||
269 | } executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||||||||||||||||||||
270 | } else if (state == CheckingFeatures
| 45-84 | ||||||||||||||||||||||||||||||||||||
271 | state = Statting; | - | ||||||||||||||||||||||||||||||||||||
272 | if (operation() == QNetworkAccessManager::GetOperation
| 11-34 | ||||||||||||||||||||||||||||||||||||
273 | - | |||||||||||||||||||||||||||||||||||||
274 | QString command = url().path(); | - | ||||||||||||||||||||||||||||||||||||
275 | command.prepend(QLatin1String("%1 ")); | - | ||||||||||||||||||||||||||||||||||||
276 | if (supportsSize
| 0-34 | ||||||||||||||||||||||||||||||||||||
277 | ftp->rawCommand(QLatin1String("TYPE I")); | - | ||||||||||||||||||||||||||||||||||||
278 | sizeId = ftp->rawCommand(command.arg(QLatin1String("SIZE"))); | - | ||||||||||||||||||||||||||||||||||||
279 | } executed 34 times by 1 test: end of block Executed by:
| 34 | ||||||||||||||||||||||||||||||||||||
280 | if (supportsMdtm
| 0-34 | ||||||||||||||||||||||||||||||||||||
281 | mdtmId = ftp->rawCommand(command.arg(QLatin1String("MDTM"))); executed 34 times by 1 test: mdtmId = ftp->rawCommand(command.arg(QLatin1String("MDTM"))); Executed by:
| 34 | ||||||||||||||||||||||||||||||||||||
282 | if (!supportsSize
| 0-34 | ||||||||||||||||||||||||||||||||||||
283 | ftpDone(); never executed: ftpDone(); | 0 | ||||||||||||||||||||||||||||||||||||
284 | } executed 34 times by 1 test: else {end of block Executed by:
| 34 | ||||||||||||||||||||||||||||||||||||
285 | ftpDone(); | - | ||||||||||||||||||||||||||||||||||||
286 | } executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||||||||||||||||||||
287 | } else if (state == Statting
| 41-43 | ||||||||||||||||||||||||||||||||||||
288 | - | |||||||||||||||||||||||||||||||||||||
289 | metaDataChanged(); | - | ||||||||||||||||||||||||||||||||||||
290 | state = Transferring; | - | ||||||||||||||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||||||||||||||
292 | QFtp::TransferType type = QFtp::Binary; | - | ||||||||||||||||||||||||||||||||||||
293 | if (operation() == QNetworkAccessManager::GetOperation
| 11-30 | ||||||||||||||||||||||||||||||||||||
294 | setCachingEnabled(true); | - | ||||||||||||||||||||||||||||||||||||
295 | ftp->get(url().path(), 0, type); | - | ||||||||||||||||||||||||||||||||||||
296 | } executed 30 times by 1 test: else {end of block Executed by:
| 30 | ||||||||||||||||||||||||||||||||||||
297 | ftp->put(uploadDevice, url().path(), type); | - | ||||||||||||||||||||||||||||||||||||
298 | } executed 11 times by 1 test: end of block Executed by:
| 11 | ||||||||||||||||||||||||||||||||||||
299 | - | |||||||||||||||||||||||||||||||||||||
300 | } else if (state == Transferring
| 5-38 | ||||||||||||||||||||||||||||||||||||
301 | - | |||||||||||||||||||||||||||||||||||||
302 | disconnectFromFtp(); | - | ||||||||||||||||||||||||||||||||||||
303 | finished(); | - | ||||||||||||||||||||||||||||||||||||
304 | } executed 38 times by 1 test: end of block Executed by:
| 38 | ||||||||||||||||||||||||||||||||||||
305 | } executed 174 times by 1 test: end of block Executed by:
| 174 | ||||||||||||||||||||||||||||||||||||
306 | - | |||||||||||||||||||||||||||||||||||||
307 | void QNetworkAccessFtpBackend::ftpReadyRead() | - | ||||||||||||||||||||||||||||||||||||
308 | { | - | ||||||||||||||||||||||||||||||||||||
309 | QByteArray data = ftp->readAll(); | - | ||||||||||||||||||||||||||||||||||||
310 | QByteDataBuffer list; | - | ||||||||||||||||||||||||||||||||||||
311 | list.append(data); | - | ||||||||||||||||||||||||||||||||||||
312 | data.clear(); | - | ||||||||||||||||||||||||||||||||||||
313 | writeDownstreamData(list); | - | ||||||||||||||||||||||||||||||||||||
314 | } executed 568 times by 1 test: end of block Executed by:
| 568 | ||||||||||||||||||||||||||||||||||||
315 | - | |||||||||||||||||||||||||||||||||||||
316 | void QNetworkAccessFtpBackend::ftpRawCommandReply(int code, const QString &text) | - | ||||||||||||||||||||||||||||||||||||
317 | { | - | ||||||||||||||||||||||||||||||||||||
318 | - | |||||||||||||||||||||||||||||||||||||
319 | int id = ftp->currentId(); | - | ||||||||||||||||||||||||||||||||||||
320 | - | |||||||||||||||||||||||||||||||||||||
321 | if ((
| 0-98 | ||||||||||||||||||||||||||||||||||||
322 | - | |||||||||||||||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||||||||||||||
325 | if (text.contains(QLatin1String("SIZE"), Qt::CaseSensitive)
| 0-34 | ||||||||||||||||||||||||||||||||||||
326 | supportsSize = true; executed 34 times by 1 test: supportsSize = true; Executed by:
| 34 | ||||||||||||||||||||||||||||||||||||
327 | if (text.contains(QLatin1String("MDTM"), Qt::CaseSensitive)
| 0-34 | ||||||||||||||||||||||||||||||||||||
328 | supportsMdtm = true; executed 34 times by 1 test: supportsMdtm = true; Executed by:
| 34 | ||||||||||||||||||||||||||||||||||||
329 | } executed 34 times by 1 test: else if (code == 213end of block Executed by:
| 34-60 | ||||||||||||||||||||||||||||||||||||
330 | if (id == sizeId
| 30 | ||||||||||||||||||||||||||||||||||||
331 | - | |||||||||||||||||||||||||||||||||||||
332 | setHeader(QNetworkRequest::ContentLengthHeader, text.toLongLong()); | - | ||||||||||||||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||||||||||||||
334 | } executed 30 times by 1 test: else if (id == mdtmIdend of block Executed by:
| 0-30 | ||||||||||||||||||||||||||||||||||||
335 | QDateTime dt = QDateTime::fromString(text, QLatin1String("yyyyMMddHHmmss")); | - | ||||||||||||||||||||||||||||||||||||
336 | setHeader(QNetworkRequest::LastModifiedHeader, dt); | - | ||||||||||||||||||||||||||||||||||||
337 | - | |||||||||||||||||||||||||||||||||||||
338 | } executed 30 times by 1 test: end of block Executed by:
| 30 | ||||||||||||||||||||||||||||||||||||
339 | } executed 60 times by 1 test: end of block Executed by:
| 60 | ||||||||||||||||||||||||||||||||||||
340 | } executed 132 times by 1 test: end of block Executed by:
| 132 | ||||||||||||||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||||||||||||||
342 | - | |||||||||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |