qftp.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qftp.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//#define QFTPPI_DEBUG-
35//#define QFTPDTP_DEBUG-
36-
37#include "private/qftp_p.h"-
38#include "qabstractsocket.h"-
39-
40#ifndef QT_NO_FTP-
41-
42#include "qcoreapplication.h"-
43#include "qtcpsocket.h"-
44#include "qurlinfo_p.h"-
45#include "qstringlist.h"-
46#include "qregexp.h"-
47#include "qtimer.h"-
48#include "qfileinfo.h"-
49#include "qtcpserver.h"-
50#include "qlocale.h"-
51-
52QT_BEGIN_NAMESPACE-
53-
54class QFtpPI;-
55-
56/*-
57 The QFtpDTP (DTP = Data Transfer Process) controls all client side-
58 data transfer between the client and server.-
59*/-
60class QFtpDTP : public QObject-
61{-
62 Q_OBJECT-
63-
64public:-
65 enum ConnectState {-
66 CsHostFound,-
67 CsConnected,-
68 CsClosed,-
69 CsHostNotFound,-
70 CsConnectionRefused-
71 };-
72-
73 QFtpDTP(QFtpPI *p, QObject *parent = 0);-
74-
75 void setData(QByteArray *);-
76 void setDevice(QIODevice *);-
77 void writeData();-
78 void setBytesTotal(qint64 bytes);-
79-
80 bool hasError() const;-
81 QString errorMessage() const;-
82 void clearError();-
83-
84 void connectToHost(const QString & host, quint16 port);-
85 int setupListener(const QHostAddress &address);-
86 void waitForConnection();-
87-
88 QTcpSocket::SocketState state() const;-
89 qint64 bytesAvailable() const;-
90 qint64 read(char *data, qint64 maxlen);-
91 QByteArray readAll();-
92-
93 void abortConnection();-
94-
95 static bool parseDir(const QByteArray &buffer, const QString &userName, QUrlInfo *info);-
96-
97signals:-
98 void listInfo(const QUrlInfo&);-
99 void readyRead();-
100 void dataTransferProgress(qint64, qint64);-
101-
102 void connectState(int);-
103-
104private slots:-
105 void socketConnected();-
106 void socketReadyRead();-
107 void socketError(QAbstractSocket::SocketError);-
108 void socketConnectionClosed();-
109 void socketBytesWritten(qint64);-
110 void setupSocket();-
111-
112 void dataReadyRead();-
113-
114private:-
115 void clearData();-
116-
117 QTcpSocket *socket;-
118 QTcpServer listener;-
119-
120 QFtpPI *pi;-
121 QString err;-
122 qint64 bytesDone;-
123 qint64 bytesTotal;-
124 bool callWriteData;-
125-
126 // If is_ba is true, ba is used; ba is never 0.-
127 // Otherwise dev is used; dev can be 0 or not.-
128 union {-
129 QByteArray *ba;-
130 QIODevice *dev;-
131 } data;-
132 bool is_ba;-
133-
134 QByteArray bytesFromSocket;-
135};-
136-
137/**********************************************************************-
138 *-
139 * QFtpPI - Protocol Interpreter-
140 *-
141 *********************************************************************/-
142-
143class QFtpPI : public QObject-
144{-
145 Q_OBJECT-
146-
147public:-
148 QFtpPI(QObject *parent = 0);-
149-
150 void connectToHost(const QString &host, quint16 port);-
151-
152 bool sendCommands(const QStringList &cmds);-
153 bool sendCommand(const QString &cmd)-
154 { return sendCommands(QStringList(cmd)); }
never executed: return sendCommands(QStringList(cmd));
0
155-
156 void clearPendingCommands();-
157 void abort();-
158-
159 QString currentCommand() const-
160 { return currentCmd; }
executed 3604 times by 2 tests: return currentCmd;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
3604
161-
162 bool rawCommand;-
163 bool transferConnectionExtended;-
164-
165 QFtpDTP dtp; // the PI has a DTP which is not the design of RFC 959, but it-
166 // makes the design simpler this way-
167signals:-
168 void connectState(int);-
169 void finished(const QString&);-
170 void error(int, const QString&);-
171 void rawFtpReply(int, const QString&);-
172-
173private slots:-
174 void hostFound();-
175 void connected();-
176 void connectionClosed();-
177 void delayedCloseFinished();-
178 void readyRead();-
179 void error(QAbstractSocket::SocketError);-
180-
181 void dtpConnectState(int);-
182-
183private:-
184 // the states are modelled after the generalized state diagram of RFC 959,-
185 // page 58-
186 enum State {-
187 Begin,-
188 Idle,-
189 Waiting,-
190 Success,-
191 Failure-
192 };-
193-
194 enum AbortState {-
195 None,-
196 AbortStarted,-
197 WaitForAbortToFinish-
198 };-
199-
200 bool processReply();-
201 bool startNextCmd();-
202-
203 QTcpSocket commandSocket;-
204 QString replyText;-
205 char replyCode[3];-
206 State state;-
207 AbortState abortState;-
208 QStringList pendingCommands;-
209 QString currentCmd;-
210-
211 bool waitForDtpToConnect;-
212 bool waitForDtpToClose;-
213-
214 QByteArray bytesFromSocket;-
215-
216 friend class QFtpDTP;-
217};-
218-
219/**********************************************************************-
220 *-
221 * QFtpCommand implemenatation-
222 *-
223 *********************************************************************/-
224class QFtpCommand-
225{-
226public:-
227 QFtpCommand(QFtp::Command cmd, const QStringList &raw, const QByteArray &ba);-
228 QFtpCommand(QFtp::Command cmd, const QStringList &raw, QIODevice *dev = 0);-
229 ~QFtpCommand();-
230-
231 int id;-
232 QFtp::Command command;-
233 QStringList rawCmds;-
234-
235 // If is_ba is true, ba is used; ba is never 0.-
236 // Otherwise dev is used; dev can be 0 or not.-
237 union {-
238 QByteArray *ba;-
239 QIODevice *dev;-
240 } data;-
241 bool is_ba;-
242-
243 static QBasicAtomicInt idCounter;-
244};-
245-
246QBasicAtomicInt QFtpCommand::idCounter = Q_BASIC_ATOMIC_INITIALIZER(1);-
247-
248QFtpCommand::QFtpCommand(QFtp::Command cmd, const QStringList &raw, const QByteArray &ba)-
249 : command(cmd), rawCmds(raw), is_ba(true)-
250{-
251 id = idCounter.fetchAndAddRelaxed(1);-
252 data.ba = new QByteArray(ba);-
253}
executed 28 times by 1 test: end of block
Executed by:
  • tst_QFtp
28
254-
255QFtpCommand::QFtpCommand(QFtp::Command cmd, const QStringList &raw, QIODevice *dev)-
256 : command(cmd), rawCmds(raw), is_ba(false)-
257{-
258 id = idCounter.fetchAndAddRelaxed(1);-
259 data.dev = dev;-
260}
executed 3395 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
3395
261-
262QFtpCommand::~QFtpCommand()-
263{-
264 if (is_ba)
is_baDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 3391 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
28-3391
265 delete data.ba;
executed 28 times by 1 test: delete data.ba;
Executed by:
  • tst_QFtp
28
266}
executed 3419 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
3419
267-
268/**********************************************************************-
269 *-
270 * QFtpDTP implemenatation-
271 *-
272 *********************************************************************/-
273QFtpDTP::QFtpDTP(QFtpPI *p, QObject *parent) :-
274 QObject(parent),-
275 socket(0),-
276 listener(this),-
277 pi(p),-
278 callWriteData(false)-
279{-
280 clearData();-
281 listener.setObjectName(QLatin1String("QFtpDTP active state server"));-
282 connect(&listener, SIGNAL(newConnection()), SLOT(setupSocket()));-
283}
executed 661 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
661
284-
285void QFtpDTP::setData(QByteArray *ba)-
286{-
287 is_ba = true;-
288 data.ba = ba;-
289}
executed 28 times by 1 test: end of block
Executed by:
  • tst_QFtp
28
290-
291void QFtpDTP::setDevice(QIODevice *dev)-
292{-
293 is_ba = false;-
294 data.dev = dev;-
295}
executed 55 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
55
296-
297void QFtpDTP::setBytesTotal(qint64 bytes)-
298{-
299 bytesTotal = bytes;-
300 bytesDone = 0;-
301 emit dataTransferProgress(bytesDone, bytesTotal);-
302}
executed 153 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
153
303-
304void QFtpDTP::connectToHost(const QString & host, quint16 port)-
305{-
306 bytesFromSocket.clear();-
307-
308 if (socket) {
socketDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 354 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
1-354
309 delete socket;-
310 socket = 0;-
311 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QNetworkReply
1
312 socket = new QTcpSocket(this);-
313#ifndef QT_NO_BEARERMANAGEMENT-
314 //copy network session down to the socket-
315 socket->setProperty("_q_networksession", property("_q_networksession"));-
316#endif-
317 socket->setObjectName(QLatin1String("QFtpDTP Passive state socket"));-
318 connect(socket, SIGNAL(connected()), SLOT(socketConnected()));-
319 connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead()));-
320 connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError)));-
321 connect(socket, SIGNAL(disconnected()), SLOT(socketConnectionClosed()));-
322 connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64)));-
323-
324 socket->connectToHost(host, port);-
325}
executed 355 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
355
326-
327int QFtpDTP::setupListener(const QHostAddress &address)-
328{-
329#ifndef QT_NO_BEARERMANAGEMENT-
330 //copy network session down to the socket-
331 listener.setProperty("_q_networksession", property("_q_networksession"));-
332#endif-
333 if (!listener.isListening() && !listener.listen(address, 0))
!listener.isListening()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
!listener.listen(address, 0)Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFtp
0-8
334 return -1;
never executed: return -1;
0
335 return listener.serverPort();
executed 8 times by 1 test: return listener.serverPort();
Executed by:
  • tst_QFtp
8
336}-
337-
338void QFtpDTP::waitForConnection()-
339{-
340 // This function is only interesting in Active transfer mode; it works-
341 // around a limitation in QFtp's design by blocking, waiting for an-
342 // incoming connection. For the default Passive mode, it does nothing.-
343 if (listener.isListening())
listener.isListening()Description
TRUEnever evaluated
FALSEevaluated 43 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-43
344 listener.waitForNewConnection();
never executed: listener.waitForNewConnection();
0
345}
executed 43 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
43
346-
347QTcpSocket::SocketState QFtpDTP::state() const-
348{-
349 return socket ? socket->state() : QTcpSocket::UnconnectedState;
executed 376 times by 2 tests: return socket ? socket->state() : QTcpSocket::UnconnectedState;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
socketDescription
TRUEevaluated 376 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
0-376
350}-
351-
352qint64 QFtpDTP::bytesAvailable() const-
353{-
354 if (!socket || socket->state() != QTcpSocket::ConnectedState)
!socketDescription
TRUEevaluated 4292 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 2013 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
socket->state(...ConnectedStateDescription
TRUEevaluated 1299 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 714 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
714-4292
355 return (qint64) bytesFromSocket.size();
executed 5591 times by 2 tests: return (qint64) bytesFromSocket.size();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
5591
356 return socket->bytesAvailable();
executed 714 times by 2 tests: return socket->bytesAvailable();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
714
357}-
358-
359qint64 QFtpDTP::read(char *data, qint64 maxlen)-
360{-
361 qint64 read;-
362 if (socket && socket->state() == QTcpSocket::ConnectedState) {
socketDescription
TRUEnever evaluated
FALSEnever evaluated
socket->state(...ConnectedStateDescription
TRUEnever evaluated
FALSEnever evaluated
0
363 read = socket->read(data, maxlen);-
364 } else {
never executed: end of block
0
365 read = qMin(maxlen, qint64(bytesFromSocket.size()));-
366 memcpy(data, bytesFromSocket.data(), read);-
367 bytesFromSocket.remove(0, read);-
368 }
never executed: end of block
0
369-
370 bytesDone += read;-
371 return read;
never executed: return read;
0
372}-
373-
374QByteArray QFtpDTP::readAll()-
375{-
376 QByteArray tmp;-
377 if (socket && socket->state() == QTcpSocket::ConnectedState) {
socketDescription
TRUEevaluated 744 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
socket->state(...ConnectedStateDescription
TRUEevaluated 720 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 24 times by 1 test
Evaluated by:
  • tst_QFtp
0-744
378 tmp = socket->readAll();-
379 bytesDone += tmp.size();-
380 } else {
executed 720 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
720
381 tmp = bytesFromSocket;-
382 bytesFromSocket.clear();-
383 }
executed 24 times by 1 test: end of block
Executed by:
  • tst_QFtp
24
384 return tmp;
executed 744 times by 2 tests: return tmp;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
744
385}-
386-
387void QFtpDTP::writeData()-
388{-
389 if (!socket)
!socketDescription
TRUEnever evaluated
FALSEevaluated 198 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-198
390 return;
never executed: return;
0
391-
392 if (is_ba) {
is_baDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 170 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
28-170
393#if defined(QFTPDTP_DEBUG)-
394 qDebug("QFtpDTP::writeData: write %d bytes", data.ba->size());-
395#endif-
396 if (data.ba->size() == 0)
data.ba->size() == 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFtp
8-20
397 emit dataTransferProgress(0, bytesTotal);
executed 20 times by 1 test: dataTransferProgress(0, bytesTotal);
Executed by:
  • tst_QFtp
20
398 else-
399 socket->write(data.ba->data(), data.ba->size());
executed 8 times by 1 test: socket->write(data.ba->data(), data.ba->size());
Executed by:
  • tst_QFtp
8
400-
401 socket->close();-
402-
403 clearData();-
404 } else if (data.dev) {
executed 28 times by 1 test: end of block
Executed by:
  • tst_QFtp
data.devDescription
TRUEevaluated 170 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
0-170
405 callWriteData = false;-
406 const qint64 blockSize = 16*1024;-
407 char buf[16*1024];-
408 qint64 read = data.dev->read(buf, blockSize);-
409#if defined(QFTPDTP_DEBUG)-
410 qDebug("QFtpDTP::writeData: write() of size %lli bytes", read);-
411#endif-
412 if (read > 0) {
read > 0Description
TRUEevaluated 155 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
15-155
413 socket->write(buf, read);-
414 } else if (read == -1 || (!data.dev->isSequential() && data.dev->atEnd())) {
executed 155 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
read == -1Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFtp
!data.dev->isSequential()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
data.dev->atEnd()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
0-155
415 // error or EOF-
416 if (bytesDone == 0 && socket->bytesToWrite() == 0)
bytesDone == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 13 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
socket->bytesToWrite() == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEnever evaluated
0-13
417 emit dataTransferProgress(0, bytesTotal);
executed 2 times by 1 test: dataTransferProgress(0, bytesTotal);
Executed by:
  • tst_QNetworkReply
2
418 socket->close();-
419 clearData();-
420 }
executed 15 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
15
421-
422 // do we continue uploading?-
423 callWriteData = data.dev != 0;-
424 }
executed 170 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
170
425}
executed 198 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
198
426-
427void QFtpDTP::dataReadyRead()-
428{-
429 writeData();-
430}
never executed: end of block
0
431-
432inline bool QFtpDTP::hasError() const-
433{-
434 return !err.isNull();
executed 3282 times by 2 tests: return !err.isNull();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
3282
435}-
436-
437inline QString QFtpDTP::errorMessage() const-
438{-
439 return err;
never executed: return err;
0
440}-
441-
442inline void QFtpDTP::clearError()-
443{-
444 err.clear();-
445}
never executed: end of block
0
446-
447void QFtpDTP::abortConnection()-
448{-
449#if defined(QFTPDTP_DEBUG)-
450 qDebug("QFtpDTP::abortConnection, bytesAvailable == %lli",-
451 socket ? socket->bytesAvailable() : (qint64) 0);-
452#endif-
453 callWriteData = false;-
454 clearData();-
455-
456 if (socket)
socketDescription
TRUEevaluated 19 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 144 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
19-144
457 socket->abort();
executed 19 times by 2 tests: socket->abort();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
19
458}
executed 163 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
163
459-
460static void _q_fixupDateTime(QDateTime *dateTime)-
461{-
462 // Adjust for future tolerance.-
463 const int futureTolerance = 86400;-
464 if (dateTime->secsTo(QDateTime::currentDateTime()) < -futureTolerance) {
dateTime->secs...utureToleranceDescription
TRUEnever evaluated
FALSEevaluated 116 times by 1 test
Evaluated by:
  • tst_QFtp
0-116
465 QDate d = dateTime->date();-
466 d.setDate(d.year() - 1, d.month(), d.day());-
467 dateTime->setDate(d);-
468 }
never executed: end of block
0
469}
executed 116 times by 1 test: end of block
Executed by:
  • tst_QFtp
116
470-
471static void _q_parseUnixDir(const QStringList &tokens, const QString &userName, QUrlInfo *info)-
472{-
473 // Unix style, 7 + 1 entries-
474 // -rw-r--r-- 1 ftp ftp 17358091 Aug 10 2004 qt-x11-free-3.3.3.tar.gz-
475 // drwxr-xr-x 3 ftp ftp 4096 Apr 14 2000 compiled-examples-
476 // lrwxrwxrwx 1 ftp ftp 9 Oct 29 2005 qtscape -> qtmozilla-
477 if (tokens.size() != 8)
tokens.size() != 8Description
TRUEnever evaluated
FALSEevaluated 372 times by 1 test
Evaluated by:
  • tst_QFtp
0-372
478 return;
never executed: return;
0
479-
480 char first = tokens.at(1).at(0).toLatin1();-
481 if (first == 'd') {
first == 'd'Description
TRUEevaluated 156 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 216 times by 1 test
Evaluated by:
  • tst_QFtp
156-216
482 info->setDir(true);-
483 info->setFile(false);-
484 info->setSymLink(false);-
485 } else if (first == '-') {
executed 156 times by 1 test: end of block
Executed by:
  • tst_QFtp
first == '-'Description
TRUEevaluated 216 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
0-216
486 info->setDir(false);-
487 info->setFile(true);-
488 info->setSymLink(false);-
489 } else if (first == 'l') {
executed 216 times by 1 test: end of block
Executed by:
  • tst_QFtp
first == 'l'Description
TRUEnever evaluated
FALSEnever evaluated
0-216
490 info->setDir(true);-
491 info->setFile(false);-
492 info->setSymLink(true);-
493 }
never executed: end of block
0
494-
495 // Resolve filename-
496 QString name = tokens.at(7);-
497 if (info->isSymLink()) {
info->isSymLink()Description
TRUEnever evaluated
FALSEevaluated 372 times by 1 test
Evaluated by:
  • tst_QFtp
0-372
498 int linkPos = name.indexOf(QLatin1String(" ->"));-
499 if (linkPos != -1)
linkPos != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
500 name.resize(linkPos);
never executed: name.resize(linkPos);
0
501 }
never executed: end of block
0
502 info->setName(name);-
503-
504 // Resolve owner & group-
505 info->setOwner(tokens.at(3));-
506 info->setGroup(tokens.at(4));-
507-
508 // Resolve size-
509 info->setSize(tokens.at(5).toLongLong());-
510-
511 QStringList formats;-
512 formats << QLatin1String("MMM dd yyyy") << QLatin1String("MMM dd hh:mm") << QLatin1String("MMM d yyyy")-
513 << QLatin1String("MMM d hh:mm") << QLatin1String("MMM d yyyy") << QLatin1String("MMM dd yyyy");-
514-
515 QString dateString = tokens.at(6);-
516 dateString[0] = dateString[0].toUpper();-
517-
518 // Resolve the modification date by parsing all possible formats-
519 QDateTime dateTime;-
520 int n = 0;-
521#ifndef QT_NO_DATESTRING-
522 do {-
523 dateTime = QLocale::c().toDateTime(dateString, formats.at(n++));-
524 } while (n < formats.size() && (!dateTime.isValid()));
executed 496 times by 1 test: end of block
Executed by:
  • tst_QFtp
n < formats.size()Description
TRUEevaluated 496 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
(!dateTime.isValid())Description
TRUEevaluated 124 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 372 times by 1 test
Evaluated by:
  • tst_QFtp
0-496
525#endif-
526-
527 if (n == 2 || n == 4) {
n == 2Description
TRUEevaluated 116 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 256 times by 1 test
Evaluated by:
  • tst_QFtp
n == 4Description
TRUEnever evaluated
FALSEevaluated 256 times by 1 test
Evaluated by:
  • tst_QFtp
0-256
528 // Guess the year.-
529 dateTime.setDate(QDate(QDate::currentDate().year(),-
530 dateTime.date().month(),-
531 dateTime.date().day()));-
532 _q_fixupDateTime(&dateTime);-
533 }
executed 116 times by 1 test: end of block
Executed by:
  • tst_QFtp
116
534 if (dateTime.isValid())
dateTime.isValid()Description
TRUEevaluated 372 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
0-372
535 info->setLastModified(dateTime);
executed 372 times by 1 test: info->setLastModified(dateTime);
Executed by:
  • tst_QFtp
372
536-
537 // Resolve permissions-
538 int permissions = 0;-
539 QString p = tokens.at(2);-
540 permissions |= (p[0] == QLatin1Char('r') ? QUrlInfo::ReadOwner : 0);
p[0] == QLatin1Char('r')Description
TRUEevaluated 372 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
0-372
541 permissions |= (p[1] == QLatin1Char('w') ? QUrlInfo::WriteOwner : 0);
p[1] == QLatin1Char('w')Description
TRUEevaluated 372 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
0-372
542 permissions |= (p[2] == QLatin1Char('x') ? QUrlInfo::ExeOwner : 0);
p[2] == QLatin1Char('x')Description
TRUEevaluated 156 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 216 times by 1 test
Evaluated by:
  • tst_QFtp
156-216
543 permissions |= (p[3] == QLatin1Char('r') ? QUrlInfo::ReadGroup : 0);
p[3] == QLatin1Char('r')Description
TRUEevaluated 372 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
0-372
544 permissions |= (p[4] == QLatin1Char('w') ? QUrlInfo::WriteGroup : 0);
p[4] == QLatin1Char('w')Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 324 times by 1 test
Evaluated by:
  • tst_QFtp
48-324
545 permissions |= (p[5] == QLatin1Char('x') ? QUrlInfo::ExeGroup : 0);
p[5] == QLatin1Char('x')Description
TRUEevaluated 156 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 216 times by 1 test
Evaluated by:
  • tst_QFtp
156-216
546 permissions |= (p[6] == QLatin1Char('r') ? QUrlInfo::ReadOther : 0);
p[6] == QLatin1Char('r')Description
TRUEevaluated 372 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
0-372
547 permissions |= (p[7] == QLatin1Char('w') ? QUrlInfo::WriteOther : 0);
p[7] == QLatin1Char('w')Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 324 times by 1 test
Evaluated by:
  • tst_QFtp
48-324
548 permissions |= (p[8] == QLatin1Char('x') ? QUrlInfo::ExeOther : 0);
p[8] == QLatin1Char('x')Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 264 times by 1 test
Evaluated by:
  • tst_QFtp
108-264
549 info->setPermissions(permissions);-
550-
551 bool isOwner = info->owner() == userName;-
552 info->setReadable((permissions & QUrlInfo::ReadOther) || ((permissions & QUrlInfo::ReadOwner) && isOwner));-
553 info->setWritable((permissions & QUrlInfo::WriteOther) || ((permissions & QUrlInfo::WriteOwner) && isOwner));-
554}
executed 372 times by 1 test: end of block
Executed by:
  • tst_QFtp
372
555-
556static void _q_parseDosDir(const QStringList &tokens, const QString &userName, QUrlInfo *info)-
557{-
558 // DOS style, 3 + 1 entries-
559 // 01-16-02 11:14AM <DIR> epsgroup-
560 // 06-05-03 03:19PM 1973 readme.txt-
561 if (tokens.size() != 4)
tokens.size() != 4Description
TRUEnever evaluated
FALSEnever evaluated
0
562 return;
never executed: return;
0
563-
564 Q_UNUSED(userName);-
565-
566 QString name = tokens.at(3);-
567 info->setName(name);-
568 info->setSymLink(name.toLower().endsWith(QLatin1String(".lnk")));-
569-
570 if (tokens.at(2) == QLatin1String("<DIR>")) {
tokens.at(2) =...tring("<DIR>")Description
TRUEnever evaluated
FALSEnever evaluated
0
571 info->setFile(false);-
572 info->setDir(true);-
573 } else {
never executed: end of block
0
574 info->setFile(true);-
575 info->setDir(false);-
576 info->setSize(tokens.at(2).toLongLong());-
577 }
never executed: end of block
0
578-
579 // Note: We cannot use QFileInfo; permissions are for the server-side-
580 // machine, and QFileInfo's behavior depends on the local platform.-
581 int permissions = QUrlInfo::ReadOwner | QUrlInfo::WriteOwner-
582 | QUrlInfo::ReadGroup | QUrlInfo::WriteGroup-
583 | QUrlInfo::ReadOther | QUrlInfo::WriteOther;-
584 QString ext;-
585 int extIndex = name.lastIndexOf(QLatin1Char('.'));-
586 if (extIndex != -1)
extIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
587 ext = name.mid(extIndex + 1);
never executed: ext = name.mid(extIndex + 1);
0
588 if (ext == QLatin1String("exe") || ext == QLatin1String("bat") || ext == QLatin1String("com"))
ext == QLatin1String("exe")Description
TRUEnever evaluated
FALSEnever evaluated
ext == QLatin1String("bat")Description
TRUEnever evaluated
FALSEnever evaluated
ext == QLatin1String("com")Description
TRUEnever evaluated
FALSEnever evaluated
0
589 permissions |= QUrlInfo::ExeOwner | QUrlInfo::ExeGroup | QUrlInfo::ExeOther;
never executed: permissions |= QUrlInfo::ExeOwner | QUrlInfo::ExeGroup | QUrlInfo::ExeOther;
0
590 info->setPermissions(permissions);-
591-
592 info->setReadable(true);-
593 info->setWritable(info->isFile());-
594-
595 QDateTime dateTime;-
596#ifndef QT_NO_DATESTRING-
597 dateTime = QLocale::c().toDateTime(tokens.at(1), QLatin1String("MM-dd-yy hh:mmAP"));-
598 if (dateTime.date().year() < 1971) {
dateTime.date().year() < 1971Description
TRUEnever evaluated
FALSEnever evaluated
0
599 dateTime.setDate(QDate(dateTime.date().year() + 100,-
600 dateTime.date().month(),-
601 dateTime.date().day()));-
602 }
never executed: end of block
0
603#endif-
604-
605 info->setLastModified(dateTime);-
606-
607}
never executed: end of block
0
608-
609bool QFtpDTP::parseDir(const QByteArray &buffer, const QString &userName, QUrlInfo *info)-
610{-
611 if (buffer.isEmpty())
buffer.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 374 times by 1 test
Evaluated by:
  • tst_QFtp
0-374
612 return false;
never executed: return false;
0
613-
614 QString bufferStr = QString::fromUtf8(buffer).trimmed();-
615-
616 // Unix style FTP servers-
617 QRegExp unixPattern(QLatin1String("^([\\-dl])([a-zA-Z\\-]{9,9})\\s+\\d+\\s+(\\S*)\\s+"-
618 "(\\S*)\\s+(\\d+)\\s+(\\S+\\s+\\S+\\s+\\S+)\\s+(\\S.*)"));-
619 if (unixPattern.indexIn(bufferStr) == 0) {
unixPattern.in...ufferStr) == 0Description
TRUEevaluated 372 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFtp
2-372
620 _q_parseUnixDir(unixPattern.capturedTexts(), userName, info);-
621 return true;
executed 372 times by 1 test: return true;
Executed by:
  • tst_QFtp
372
622 }-
623-
624 // DOS style FTP servers-
625 QRegExp dosPattern(QLatin1String("^(\\d\\d-\\d\\d-\\d\\d\\ \\ \\d\\d:\\d\\d[AP]M)\\s+"-
626 "(<DIR>|\\d+)\\s+(\\S.*)$"));-
627 if (dosPattern.indexIn(bufferStr) == 0) {
dosPattern.ind...ufferStr) == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFtp
0-2
628 _q_parseDosDir(dosPattern.capturedTexts(), userName, info);-
629 return true;
never executed: return true;
0
630 }-
631-
632 // Unsupported-
633 return false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_QFtp
2
634}-
635-
636void QFtpDTP::socketConnected()-
637{-
638 bytesDone = 0;-
639#if defined(QFTPDTP_DEBUG)-
640 qDebug("QFtpDTP::connectState(CsConnected)");-
641#endif-
642 emit connectState(QFtpDTP::CsConnected);-
643}
executed 355 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
355
644-
645void QFtpDTP::socketReadyRead()-
646{-
647 if (!socket)
!socketDescription
TRUEnever evaluated
FALSEevaluated 1764 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-1764
648 return;
never executed: return;
0
649-
650 if (pi->currentCommand().isEmpty()) {
pi->currentCommand().isEmpty()Description
TRUEnever evaluated
FALSEevaluated 1764 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-1764
651 socket->close();-
652#if defined(QFTPDTP_DEBUG)-
653 qDebug("QFtpDTP::connectState(CsClosed)");-
654#endif-
655 emit connectState(QFtpDTP::CsClosed);-
656 return;
never executed: return;
0
657 }-
658-
659 if (pi->abortState != QFtpPI::None) {
pi->abortState != QFtpPI::NoneDescription
TRUEnever evaluated
FALSEevaluated 1764 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-1764
660 // discard data-
661 socket->readAll();-
662 return;
never executed: return;
0
663 }-
664-
665 if (pi->currentCommand().startsWith(QLatin1String("LIST"))) {
pi->currentCom...tring("LIST"))Description
TRUEevaluated 142 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 1622 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
142-1622
666 while (socket->canReadLine()) {
socket->canReadLine()Description
TRUEevaluated 374 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 142 times by 1 test
Evaluated by:
  • tst_QFtp
142-374
667 QUrlInfo i;-
668 QByteArray line = socket->readLine();-
669#if defined(QFTPDTP_DEBUG)-
670 qDebug("QFtpDTP read (list): '%s'", line.constData());-
671#endif-
672 if (parseDir(line, QLatin1String(""), &i)) {
parseDir(line,...tring(""), &i)Description
TRUEevaluated 372 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFtp
2-372
673 emit listInfo(i);-
674 } else {
executed 372 times by 1 test: end of block
Executed by:
  • tst_QFtp
372
675 // some FTP servers don't return a 550 if the file or directory-
676 // does not exist, but rather write a text to the data socket-
677 // -- try to catch these cases-
678 if (line.endsWith("No such file or directory\r\n"))
line.endsWith(...irectory\r\n")Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFtp
0-2
679 err = QString::fromUtf8(line);
never executed: err = QString::fromUtf8(line);
0
680 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QFtp
2
681 }-
682 } else {
executed 142 times by 1 test: end of block
Executed by:
  • tst_QFtp
142
683 if (!is_ba && data.dev) {
!is_baDescription
TRUEevaluated 1622 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
data.devDescription
TRUEevaluated 269 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 1353 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-1622
684 do {-
685 QByteArray ba;-
686 ba.resize(socket->bytesAvailable());-
687 qint64 bytesRead = socket->read(ba.data(), ba.size());-
688 if (bytesRead < 0) {
bytesRead < 0Description
TRUEnever evaluated
FALSEevaluated 269 times by 1 test
Evaluated by:
  • tst_QFtp
0-269
689 // a read following a readyRead() signal will-
690 // never fail.-
691 return;
never executed: return;
0
692 }-
693 ba.resize(bytesRead);-
694 bytesDone += bytesRead;-
695#if defined(QFTPDTP_DEBUG)-
696 qDebug("QFtpDTP read: %lli bytes (total %lli bytes)", bytesRead, bytesDone);-
697#endif-
698 if (data.dev) // make sure it wasn't deleted in the slot
data.devDescription
TRUEevaluated 269 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
0-269
699 data.dev->write(ba);
executed 269 times by 1 test: data.dev->write(ba);
Executed by:
  • tst_QFtp
269
700 emit dataTransferProgress(bytesDone, bytesTotal);-
701-
702 // Need to loop; dataTransferProgress is often connected to-
703 // slots that update the GUI (e.g., progress bar values), and-
704 // if events are processed, more data may have arrived.-
705 } while (socket->bytesAvailable());
executed 269 times by 1 test: end of block
Executed by:
  • tst_QFtp
socket->bytesAvailable()Description
TRUEnever evaluated
FALSEevaluated 269 times by 1 test
Evaluated by:
  • tst_QFtp
0-269
706 } else {
executed 269 times by 1 test: end of block
Executed by:
  • tst_QFtp
269
707#if defined(QFTPDTP_DEBUG)-
708 qDebug("QFtpDTP readyRead: %lli bytes available (total %lli bytes read)",-
709 bytesAvailable(), bytesDone);-
710#endif-
711 emit dataTransferProgress(bytesDone+socket->bytesAvailable(), bytesTotal);-
712 emit readyRead();-
713 }
executed 1353 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
1353
714 }-
715}-
716-
717void QFtpDTP::socketError(QAbstractSocket::SocketError e)-
718{-
719 if (e == QTcpSocket::HostNotFoundError) {
e == QTcpSocke...tNotFoundErrorDescription
TRUEnever evaluated
FALSEevaluated 301 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-301
720#if defined(QFTPDTP_DEBUG)-
721 qDebug("QFtpDTP::connectState(CsHostNotFound)");-
722#endif-
723 emit connectState(QFtpDTP::CsHostNotFound);-
724 } else if (e == QTcpSocket::ConnectionRefusedError) {
never executed: end of block
e == QTcpSocke...onRefusedErrorDescription
TRUEnever evaluated
FALSEevaluated 301 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-301
725#if defined(QFTPDTP_DEBUG)-
726 qDebug("QFtpDTP::connectState(CsConnectionRefused)");-
727#endif-
728 emit connectState(QFtpDTP::CsConnectionRefused);-
729 }
never executed: end of block
0
730}
executed 301 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
301
731-
732void QFtpDTP::socketConnectionClosed()-
733{-
734 if (!is_ba && data.dev) {
!is_baDescription
TRUEevaluated 343 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 20 times by 1 test
Evaluated by:
  • tst_QFtp
data.devDescription
TRUEevaluated 47 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 296 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
20-343
735 clearData();-
736 }
executed 47 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
47
737-
738 if (socket->isOpen())
socket->isOpen()Description
TRUEevaluated 301 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 62 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
62-301
739 bytesFromSocket = socket->readAll();
executed 301 times by 2 tests: bytesFromSocket = socket->readAll();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
301
740 else-
741 bytesFromSocket.clear();
executed 62 times by 2 tests: bytesFromSocket.clear();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
62
742#if defined(QFTPDTP_DEBUG)-
743 qDebug("QFtpDTP::connectState(CsClosed)");-
744#endif-
745 emit connectState(QFtpDTP::CsClosed);-
746}
executed 363 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
363
747-
748void QFtpDTP::socketBytesWritten(qint64 bytes)-
749{-
750 bytesDone += bytes;-
751#if defined(QFTPDTP_DEBUG)-
752 qDebug("QFtpDTP::bytesWritten(%lli)", bytesDone);-
753#endif-
754 emit dataTransferProgress(bytesDone, bytesTotal);-
755 if (callWriteData)
callWriteDataDescription
TRUEevaluated 155 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFtp
8-155
756 writeData();
executed 155 times by 2 tests: writeData();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
155
757}
executed 163 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
163
758-
759void QFtpDTP::setupSocket()-
760{-
761 socket = listener.nextPendingConnection();-
762 socket->setObjectName(QLatin1String("QFtpDTP Active state socket"));-
763 connect(socket, SIGNAL(connected()), SLOT(socketConnected()));-
764 connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead()));-
765 connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError)));-
766 connect(socket, SIGNAL(disconnected()), SLOT(socketConnectionClosed()));-
767 connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64)));-
768-
769 listener.close();-
770}
executed 8 times by 1 test: end of block
Executed by:
  • tst_QFtp
8
771-
772void QFtpDTP::clearData()-
773{-
774 is_ba = false;-
775 data.dev = 0;-
776}
executed 914 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
914
777-
778/**********************************************************************-
779 *-
780 * QFtpPI implemenatation-
781 *-
782 *********************************************************************/-
783QFtpPI::QFtpPI(QObject *parent) :-
784 QObject(parent),-
785 rawCommand(false),-
786 transferConnectionExtended(true),-
787 dtp(this),-
788 commandSocket(0),-
789 state(Begin), abortState(None),-
790 currentCmd(QString()),-
791 waitForDtpToConnect(false),-
792 waitForDtpToClose(false)-
793{-
794 commandSocket.setObjectName(QLatin1String("QFtpPI_socket"));-
795 connect(&commandSocket, SIGNAL(hostFound()),-
796 SLOT(hostFound()));-
797 connect(&commandSocket, SIGNAL(connected()),-
798 SLOT(connected()));-
799 connect(&commandSocket, SIGNAL(disconnected()),-
800 SLOT(connectionClosed()));-
801 connect(&commandSocket, SIGNAL(readyRead()),-
802 SLOT(readyRead()));-
803 connect(&commandSocket, SIGNAL(error(QAbstractSocket::SocketError)),-
804 SLOT(error(QAbstractSocket::SocketError)));-
805-
806 connect(&dtp, SIGNAL(connectState(int)),-
807 SLOT(dtpConnectState(int)));-
808}
executed 661 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
661
809-
810void QFtpPI::connectToHost(const QString &host, quint16 port)-
811{-
812 emit connectState(QFtp::HostLookup);-
813#ifndef QT_NO_BEARERMANAGEMENT-
814 //copy network session down to the socket & DTP-
815 commandSocket.setProperty("_q_networksession", property("_q_networksession"));-
816 dtp.setProperty("_q_networksession", property("_q_networksession"));-
817#endif-
818 commandSocket.connectToHost(host, port);-
819}
executed 657 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
657
820-
821/*-
822 \internal-
823-
824 Sends the sequence of commands \a cmds to the FTP server. When the commands-
825 are all done the finished() signal is emitted. When an error occurs, the-
826 error() signal is emitted.-
827-
828 If there are pending commands in the queue this functions returns \c false and-
829 the \a cmds are not added to the queue; otherwise it returns \c true.-
830*/-
831bool QFtpPI::sendCommands(const QStringList &cmds)-
832{-
833 if (!pendingCommands.isEmpty())
!pendingCommands.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 1956 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-1956
834 return false;
never executed: return false;
0
835-
836 if (commandSocket.state() != QTcpSocket::ConnectedState || state!=Idle) {
commandSocket....ConnectedStateDescription
TRUEevaluated 21 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 1935 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
state!=IdleDescription
TRUEnever evaluated
FALSEevaluated 1935 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-1935
837 emit error(QFtp::NotConnected, QFtp::tr("Not connected"));-
838 return true; // there are no pending commands
executed 21 times by 2 tests: return true;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
21
839 }-
840-
841 pendingCommands = cmds;-
842 startNextCmd();-
843 return true;
executed 1935 times by 2 tests: return true;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
1935
844}-
845-
846void QFtpPI::clearPendingCommands()-
847{-
848 pendingCommands.clear();-
849 dtp.abortConnection();-
850 currentCmd.clear();-
851 state = Idle;-
852}
executed 161 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
161
853-
854void QFtpPI::abort()-
855{-
856 pendingCommands.clear();-
857-
858 if (abortState != None)
abortState != NoneDescription
TRUEnever evaluated
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-4
859 // ABOR already sent-
860 return;
never executed: return;
0
861-
862 if (currentCmd.isEmpty())
currentCmd.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
2
863 return; //no command in progress
executed 2 times by 1 test: return;
Executed by:
  • tst_QFtp
2
864-
865 if (currentCmd.startsWith(QLatin1String("STOR "))) {
currentCmd.sta...ring("STOR "))Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkReply
0-2
866 abortState = AbortStarted;-
867#if defined(QFTPPI_DEBUG)-
868 qDebug("QFtpPI send: ABOR");-
869#endif-
870 commandSocket.write("ABOR\r\n", 6);-
871-
872 dtp.abortConnection();-
873 } else {
never executed: end of block
0
874 //Deviation from RFC 959:-
875 //Most FTP servers do not support ABOR, or require the telnet-
876 //IP & synch sequence (TCP urgent data) which is not supported by QTcpSocket.-
877 //Following what most FTP clients do, just reset the data connection and wait for 426-
878 abortState = WaitForAbortToFinish;-
879 dtp.abortConnection();-
880 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
2
881}-
882-
883void QFtpPI::hostFound()-
884{-
885 emit connectState(QFtp::Connecting);-
886}
executed 354 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
354
887-
888void QFtpPI::connected()-
889{-
890 state = Begin;-
891#if defined(QFTPPI_DEBUG)-
892// qDebug("QFtpPI state: %d [connected()]", state);-
893#endif-
894 // try to improve performance by setting TCP_NODELAY-
895 commandSocket.setSocketOption(QAbstractSocket::LowDelayOption, 1);-
896-
897 emit connectState(QFtp::Connected);-
898}
executed 637 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
637
899-
900void QFtpPI::connectionClosed()-
901{-
902 commandSocket.close();-
903 emit connectState(QFtp::Unconnected);-
904}
executed 635 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
635
905-
906void QFtpPI::delayedCloseFinished()-
907{-
908 emit connectState(QFtp::Unconnected);-
909}
never executed: end of block
0
910-
911void QFtpPI::error(QAbstractSocket::SocketError e)-
912{-
913 if (e == QTcpSocket::HostNotFoundError) {
e == QTcpSocke...tNotFoundErrorDescription
TRUEevaluated 7 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 482 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
7-482
914 emit connectState(QFtp::Unconnected);-
915 emit error(QFtp::HostNotFound,-
916 QFtp::tr("Host %1 not found").arg(commandSocket.peerName()));-
917 } else if (e == QTcpSocket::ConnectionRefusedError) {
executed 7 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
e == QTcpSocke...onRefusedErrorDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 470 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
7-470
918 emit connectState(QFtp::Unconnected);-
919 emit error(QFtp::ConnectionRefused,-
920 QFtp::tr("Connection refused to host %1").arg(commandSocket.peerName()));-
921 } else if (e == QTcpSocket::SocketTimeoutError) {
executed 12 times by 1 test: end of block
Executed by:
  • tst_QFtp
e == QTcpSocke...etTimeoutErrorDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 469 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
1-469
922 emit connectState(QFtp::Unconnected);-
923 emit error(QFtp::ConnectionRefused,-
924 QFtp::tr("Connection timed out to host %1").arg(commandSocket.peerName()));-
925 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QFtp
1
926}
executed 489 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
489
927-
928void QFtpPI::readyRead()-
929{-
930 if (waitForDtpToClose)
waitForDtpToCloseDescription
TRUEnever evaluated
FALSEevaluated 4896 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-4896
931 return;
never executed: return;
0
932-
933 while (commandSocket.canReadLine()) {
commandSocket.canReadLine()Description
TRUEevaluated 4547 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 4787 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
4547-4787
934 // read line with respect to line continuation-
935 QString line = QString::fromUtf8(commandSocket.readLine());-
936 if (replyText.isEmpty()) {
replyText.isEmpty()Description
TRUEevaluated 4438 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 109 times by 1 test
Evaluated by:
  • tst_QNetworkReply
109-4438
937 if (line.length() < 3) {
line.length() < 3Description
TRUEnever evaluated
FALSEevaluated 4438 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-4438
938 // protocol error-
939 return;
never executed: return;
0
940 }-
941 const int lowerLimit[3] = {1,0,0};-
942 const int upperLimit[3] = {5,5,9};-
943 for (int i=0; i<3; i++) {
i<3Description
TRUEevaluated 13314 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 4438 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
4438-13314
944 replyCode[i] = line[i].digitValue();-
945 if (replyCode[i]<lowerLimit[i] || replyCode[i]>upperLimit[i]) {
replyCode[i]<lowerLimit[i]Description
TRUEnever evaluated
FALSEevaluated 13314 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
replyCode[i]>upperLimit[i]Description
TRUEnever evaluated
FALSEevaluated 13314 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-13314
946 // protocol error-
947 return;
never executed: return;
0
948 }-
949 }
executed 13314 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
13314
950 }
executed 4438 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
4438
951 QString endOfMultiLine;-
952 endOfMultiLine[0] = '0' + replyCode[0];-
953 endOfMultiLine[1] = '0' + replyCode[1];-
954 endOfMultiLine[2] = '0' + replyCode[2];-
955 endOfMultiLine[3] = QLatin1Char(' ');-
956 QString lineCont(endOfMultiLine);-
957 lineCont[3] = QLatin1Char('-');-
958 QString lineLeft4 = line.left(4);-
959-
960 while (lineLeft4 != endOfMultiLine) {
lineLeft4 != endOfMultiLineDescription
TRUEevaluated 242 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 4438 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
242-4438
961 if (lineLeft4 == lineCont)
lineLeft4 == lineContDescription
TRUEevaluated 106 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 136 times by 1 test
Evaluated by:
  • tst_QNetworkReply
106-136
962 replyText += line.mid(4); // strip 'xyz-'
executed 106 times by 2 tests: replyText += line.mid(4);
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
106
963 else-
964 replyText += line;
executed 136 times by 1 test: replyText += line;
Executed by:
  • tst_QNetworkReply
136
965 if (!commandSocket.canReadLine())
!commandSocket.canReadLine()Description
TRUEevaluated 109 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 133 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
109-133
966 return;
executed 109 times by 1 test: return;
Executed by:
  • tst_QNetworkReply
109
967 line = QString::fromUtf8(commandSocket.readLine());-
968 lineLeft4 = line.left(4);-
969 }
executed 133 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
133
970 replyText += line.mid(4); // strip reply code 'xyz '-
971 if (replyText.endsWith(QLatin1String("\r\n")))
replyText.ends...tring("\r\n"))Description
TRUEevaluated 4438 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
0-4438
972 replyText.chop(2);
executed 4438 times by 2 tests: replyText.chop(2);
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
4438
973-
974 if (processReply())
processReply()Description
TRUEevaluated 4406 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
32-4406
975 replyText = QLatin1String("");
executed 4406 times by 2 tests: replyText = QLatin1String("");
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
4406
976 }
executed 4438 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
4438
977}
executed 4787 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
4787
978-
979/*-
980 \internal-
981-
982 Process a reply from the FTP server.-
983-
984 Returns \c true if the reply was processed or false if the reply has to be-
985 processed at a later point.-
986*/-
987bool QFtpPI::processReply()-
988{-
989#if defined(QFTPPI_DEBUG)-
990// qDebug("QFtpPI state: %d [processReply() begin]", state);-
991 if (replyText.length() < 400)-
992 qDebug("QFtpPI recv: %d %s", 100*replyCode[0]+10*replyCode[1]+replyCode[2], replyText.toLatin1().constData());-
993 else-
994 qDebug("QFtpPI recv: %d (text skipped)", 100*replyCode[0]+10*replyCode[1]+replyCode[2]);-
995#endif-
996-
997 int replyCodeInt = 100*replyCode[0] + 10*replyCode[1] + replyCode[2];-
998-
999 // process 226 replies ("Closing Data Connection") only when the data-
1000 // connection is really closed to avoid short reads of the DTP-
1001 if (replyCodeInt == 226 || (replyCodeInt == 250 && currentCmd.startsWith(QLatin1String("RETR")))) {
replyCodeInt == 226Description
TRUEevaluated 376 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 4094 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
replyCodeInt == 250Description
TRUEevaluated 240 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 3854 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
currentCmd.sta...tring("RETR"))Description
TRUEnever evaluated
FALSEevaluated 240 times by 1 test
Evaluated by:
  • tst_QFtp
0-4094
1002 if (dtp.state() != QTcpSocket::UnconnectedState) {
dtp.state() !=...connectedStateDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 344 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
32-344
1003 waitForDtpToClose = true;-
1004 return false;
executed 32 times by 2 tests: return false;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
32
1005 }-
1006 }
executed 344 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
344
1007-
1008 switch (abortState) {-
1009 case AbortStarted:
never executed: case AbortStarted:
0
1010 abortState = WaitForAbortToFinish;-
1011 break;
never executed: break;
0
1012 case WaitForAbortToFinish:
executed 2 times by 1 test: case WaitForAbortToFinish:
Executed by:
  • tst_QNetworkReply
2
1013 abortState = None;-
1014 return true;
executed 2 times by 1 test: return true;
Executed by:
  • tst_QNetworkReply
2
1015 default:
executed 4436 times by 2 tests: default:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
4436
1016 break;
executed 4436 times by 2 tests: break;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
4436
1017 }-
1018-
1019 // get new state-
1020 static const State table[5] = {-
1021 /* 1yz 2yz 3yz 4yz 5yz */-
1022 Waiting, Success, Idle, Failure, Failure-
1023 };-
1024 switch (state) {-
1025 case Begin:
executed 637 times by 2 tests: case Begin:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
637
1026 if (replyCode[0] == 1) {
replyCode[0] == 1Description
TRUEnever evaluated
FALSEevaluated 637 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-637
1027 return true;
never executed: return true;
0
1028 } else if (replyCode[0] == 2) {
replyCode[0] == 2Description
TRUEevaluated 637 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
0-637
1029 state = Idle;-
1030 emit finished(QFtp::tr("Connected to host %1").arg(commandSocket.peerName()));-
1031 break;
executed 637 times by 2 tests: break;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
637
1032 }-
1033 // reply codes not starting with 1 or 2 are not handled.-
1034 return true;
never executed: return true;
0
1035 case Waiting:
executed 3799 times by 2 tests: case Waiting:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
3799
1036 if (static_cast<signed char>(replyCode[0]) < 0 || replyCode[0] > 5)
static_cast<si...lyCode[0]) < 0Description
TRUEnever evaluated
FALSEevaluated 3799 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
replyCode[0] > 5Description
TRUEnever evaluated
FALSEevaluated 3799 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-3799
1037 state = Failure;
never executed: state = Failure;
0
1038 else-
1039 if (replyCodeInt == 202)
replyCodeInt == 202Description
TRUEevaluated 43 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 3756 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
43-3756
1040 state = Failure;
executed 43 times by 2 tests: state = Failure;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
43
1041 else-
1042 state = table[replyCode[0] - 1];
executed 3756 times by 2 tests: state = table[replyCode[0] - 1];
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
3756
1043 break;
executed 3799 times by 2 tests: break;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
3799
1044 default:
never executed: default:
0
1045 // ignore unrequested message-
1046 return true;
never executed: return true;
0
1047 }-
1048#if defined(QFTPPI_DEBUG)-
1049// qDebug("QFtpPI state: %d [processReply() intermediate]", state);-
1050#endif-
1051-
1052 // special actions on certain replies-
1053 emit rawFtpReply(replyCodeInt, replyText);-
1054 if (rawCommand) {
rawCommandDescription
TRUEevaluated 132 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 4304 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
132-4304
1055 rawCommand = false;-
1056 } else if (replyCodeInt == 227) {
executed 132 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
replyCodeInt == 227Description
TRUEevaluated 355 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 3949 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
132-3949
1057 // 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2)-
1058 // rfc959 does not define this response precisely, and gives-
1059 // both examples where the parenthesis are used, and where-
1060 // they are missing. We need to scan for the address and host-
1061 // info.-
1062 QRegExp addrPortPattern(QLatin1String("(\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)"));-
1063 if (addrPortPattern.indexIn(replyText) == -1) {
addrPortPatter...plyText) == -1Description
TRUEnever evaluated
FALSEevaluated 355 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-355
1064#if defined(QFTPPI_DEBUG)-
1065 qDebug("QFtp: bad 227 response -- address and port information missing");-
1066#endif-
1067 // this error should be reported-
1068 } else {
never executed: end of block
0
1069 QStringList lst = addrPortPattern.capturedTexts();-
1070 QString host = lst[1] + QLatin1Char('.') + lst[2] + QLatin1Char('.') + lst[3] + QLatin1Char('.') + lst[4];-
1071 quint16 port = (lst[5].toUInt() << 8) + lst[6].toUInt();-
1072 waitForDtpToConnect = true;-
1073 dtp.connectToHost(host, port);-
1074 }
executed 355 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
355
1075 } else if (replyCodeInt == 229) {
replyCodeInt == 229Description
TRUEnever evaluated
FALSEevaluated 3949 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-3949
1076 // 229 Extended Passive mode OK (|||10982|)-
1077 int portPos = replyText.indexOf(QLatin1Char('('));-
1078 if (portPos == -1) {
portPos == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1079#if defined(QFTPPI_DEBUG)-
1080 qDebug("QFtp: bad 229 response -- port information missing");-
1081#endif-
1082 // this error should be reported-
1083 } else {
never executed: end of block
0
1084 ++portPos;-
1085 QChar delimiter = replyText.at(portPos);-
1086 QStringList epsvParameters = replyText.mid(portPos).split(delimiter);-
1087-
1088 waitForDtpToConnect = true;-
1089 dtp.connectToHost(commandSocket.peerAddress().toString(),-
1090 epsvParameters.at(3).toInt());-
1091 }
never executed: end of block
0
1092-
1093 } else if (replyCodeInt == 230) {
replyCodeInt == 230Description
TRUEevaluated 610 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 3339 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
610-3339
1094 if (currentCmd.startsWith(QLatin1String("USER ")) && pendingCommands.count()>0 &&
currentCmd.sta...ring("USER "))Description
TRUEnever evaluated
FALSEevaluated 610 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
pendingCommands.count()>0Description
TRUEnever evaluated
FALSEnever evaluated
0-610
1095 pendingCommands.first().startsWith(QLatin1String("PASS "))) {
pendingCommand...ring("PASS "))Description
TRUEnever evaluated
FALSEnever evaluated
0
1096 // no need to send the PASS -- we are already logged in-
1097 pendingCommands.pop_front();-
1098 }
never executed: end of block
0
1099 // 230 User logged in, proceed.-
1100 emit connectState(QFtp::LoggedIn);-
1101 } else if (replyCodeInt == 213) {
executed 610 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
replyCodeInt == 213Description
TRUEevaluated 94 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 3245 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
94-3245
1102 // 213 File status.-
1103 if (currentCmd.startsWith(QLatin1String("SIZE ")))
currentCmd.sta...ring("SIZE "))Description
TRUEevaluated 94 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
0-94
1104 dtp.setBytesTotal(replyText.simplified().toLongLong());
executed 94 times by 2 tests: dtp.setBytesTotal(replyText.simplified().toLongLong());
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
94
1105 } else if (replyCode[0]==1 && currentCmd.startsWith(QLatin1String("STOR "))) {
executed 94 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
replyCode[0]==1Description
TRUEevaluated 346 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 2899 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
currentCmd.sta...ring("STOR "))Description
TRUEevaluated 43 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 303 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
43-2899
1106 dtp.waitForConnection();-
1107 dtp.writeData();-
1108 }
executed 43 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
43
1109-
1110 // react on new state-
1111 switch (state) {-
1112 case Begin:
never executed: case Begin:
0
1113 // should never happen-
1114 break;
never executed: break;
0
1115 case Success:
executed 2633 times by 2 tests: case Success:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
2633
1116 // success handling-
1117 state = Idle;-
1118 // no break!-
1119 case Idle:
code before this statement executed 2633 times by 2 tests: case Idle:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
executed 649 times by 2 tests: case Idle:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
649-2633
1120 if (dtp.hasError()) {
dtp.hasError()Description
TRUEnever evaluated
FALSEevaluated 3282 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-3282
1121 emit error(QFtp::UnknownError, dtp.errorMessage());-
1122 dtp.clearError();-
1123 }
never executed: end of block
0
1124 startNextCmd();-
1125 break;
executed 3282 times by 2 tests: break;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
3282
1126 case Waiting:
executed 975 times by 2 tests: case Waiting:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
975
1127 // do nothing-
1128 break;
executed 975 times by 2 tests: break;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
975
1129 case Failure:
executed 179 times by 2 tests: case Failure:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
179
1130 // If the EPSV or EPRT commands fail, replace them with-
1131 // the old PASV and PORT instead and try again.-
1132 if (currentCmd.startsWith(QLatin1String("EPSV"))) {
currentCmd.sta...tring("EPSV"))Description
TRUEnever evaluated
FALSEevaluated 179 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-179
1133 transferConnectionExtended = false;-
1134 pendingCommands.prepend(QLatin1String("PASV\r\n"));-
1135 } else if (currentCmd.startsWith(QLatin1String("EPRT"))) {
never executed: end of block
currentCmd.sta...tring("EPRT"))Description
TRUEnever evaluated
FALSEevaluated 179 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-179
1136 transferConnectionExtended = false;-
1137 pendingCommands.prepend(QLatin1String("PORT\r\n"));-
1138 } else {
never executed: end of block
0
1139 emit error(QFtp::UnknownError, replyText);-
1140 }
executed 179 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
179
1141 if (state != Waiting) {
state != WaitingDescription
TRUEevaluated 175 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFtp
4-175
1142 state = Idle;-
1143 startNextCmd();-
1144 }
executed 175 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
175
1145 break;
executed 179 times by 2 tests: break;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
179
1146 }-
1147#if defined(QFTPPI_DEBUG)-
1148// qDebug("QFtpPI state: %d [processReply() end]", state);-
1149#endif-
1150 return true;
executed 4436 times by 2 tests: return true;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
4436
1151}-
1152-
1153/*-
1154 \internal-
1155-
1156 Starts next pending command. Returns \c false if there are no pending commands,-
1157 otherwise it returns \c true.-
1158*/-
1159bool QFtpPI::startNextCmd()-
1160{-
1161 if (waitForDtpToConnect)
waitForDtpToConnectDescription
TRUEevaluated 355 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 5392 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
355-5392
1162 // don't process any new commands until we are connected-
1163 return true;
executed 355 times by 2 tests: return true;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
355
1164-
1165#if defined(QFTPPI_DEBUG)-
1166 if (state != Idle)-
1167 qDebug("QFtpPI startNextCmd: Internal error! QFtpPI called in non-Idle state %d", state);-
1168#endif-
1169 if (pendingCommands.isEmpty()) {
pendingCommands.isEmpty()Description
TRUEevaluated 1937 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 3455 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
1937-3455
1170 currentCmd.clear();-
1171 emit finished(replyText);-
1172 return false;
executed 1937 times by 2 tests: return false;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
1937
1173 }-
1174 currentCmd = pendingCommands.first();-
1175-
1176 // PORT and PASV are edited in-place, depending on whether we-
1177 // should try the extended transfer connection commands EPRT and-
1178 // EPSV. The PORT command also triggers setting up a listener, and-
1179 // the address/port arguments are edited in.-
1180 QHostAddress address = commandSocket.localAddress();-
1181 if (currentCmd.startsWith(QLatin1String("PORT"))) {
currentCmd.sta...tring("PORT"))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 3447 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
8-3447
1182 if ((address.protocol() == QTcpSocket::IPv6Protocol) && transferConnectionExtended) {
(address.proto...:IPv6Protocol)Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFtp
transferConnectionExtendedDescription
TRUEnever evaluated
FALSEnever evaluated
0-8
1183 int port = dtp.setupListener(address);-
1184 currentCmd = QLatin1String("EPRT |");-
1185 currentCmd += (address.protocol() == QTcpSocket::IPv4Protocol) ? QLatin1Char('1') : QLatin1Char('2');
(address.proto...:IPv4Protocol)Description
TRUEnever evaluated
FALSEnever evaluated
0
1186 currentCmd += QLatin1Char('|') + address.toString() + QLatin1Char('|') + QString::number(port);-
1187 currentCmd += QLatin1Char('|');-
1188 } else if (address.protocol() == QTcpSocket::IPv4Protocol) {
never executed: end of block
address.protoc...::IPv4ProtocolDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEnever evaluated
0-8
1189 int port = dtp.setupListener(address);-
1190 QString portArg;-
1191 quint32 ip = address.toIPv4Address();-
1192 portArg += QString::number((ip & 0xff000000) >> 24);-
1193 portArg += QLatin1Char(',') + QString::number((ip & 0xff0000) >> 16);-
1194 portArg += QLatin1Char(',') + QString::number((ip & 0xff00) >> 8);-
1195 portArg += QLatin1Char(',') + QString::number(ip & 0xff);-
1196 portArg += QLatin1Char(',') + QString::number((port & 0xff00) >> 8);-
1197 portArg += QLatin1Char(',') + QString::number(port & 0xff);-
1198-
1199 currentCmd = QLatin1String("PORT ");-
1200 currentCmd += portArg;-
1201 } else {
executed 8 times by 1 test: end of block
Executed by:
  • tst_QFtp
8
1202 // No IPv6 connection can be set up with the PORT-
1203 // command.-
1204 return false;
never executed: return false;
0
1205 }-
1206-
1207 currentCmd += QLatin1String("\r\n");-
1208 } else if (currentCmd.startsWith(QLatin1String("PASV"))) {
executed 8 times by 1 test: end of block
Executed by:
  • tst_QFtp
currentCmd.sta...tring("PASV"))Description
TRUEevaluated 355 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 3092 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
8-3092
1209 if ((address.protocol() == QTcpSocket::IPv6Protocol) && transferConnectionExtended)
(address.proto...:IPv6Protocol)Description
TRUEnever evaluated
FALSEevaluated 355 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
transferConnectionExtendedDescription
TRUEnever evaluated
FALSEnever evaluated
0-355
1210 currentCmd = QLatin1String("EPSV\r\n");
never executed: currentCmd = QLatin1String("EPSV\r\n");
0
1211 }
executed 355 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
355
1212-
1213 pendingCommands.pop_front();-
1214#if defined(QFTPPI_DEBUG)-
1215 qDebug("QFtpPI send: %s", currentCmd.left(currentCmd.length()-2).toLatin1().constData());-
1216#endif-
1217 state = Waiting;-
1218 commandSocket.write(currentCmd.toUtf8());-
1219 return true;
executed 3455 times by 2 tests: return true;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
3455
1220}-
1221-
1222void QFtpPI::dtpConnectState(int s)-
1223{-
1224 switch (s) {-
1225 case QFtpDTP::CsClosed:
executed 363 times by 2 tests: case QFtpDTP::CsClosed:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
363
1226 if (waitForDtpToClose) {
waitForDtpToCloseDescription
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 331 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
32-331
1227 // there is an unprocessed reply-
1228 if (processReply())
processReply()Description
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
0-32
1229 replyText = QLatin1String("");
executed 32 times by 2 tests: replyText = QLatin1String("");
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
32
1230 else-
1231 return;
never executed: return;
0
1232 }-
1233 waitForDtpToClose = false;-
1234 readyRead();-
1235 return;
executed 363 times by 2 tests: return;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
363
1236 case QFtpDTP::CsConnected:
executed 355 times by 2 tests: case QFtpDTP::CsConnected:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
355
1237 waitForDtpToConnect = false;-
1238 startNextCmd();-
1239 return;
executed 355 times by 2 tests: return;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
355
1240 case QFtpDTP::CsHostNotFound:
never executed: case QFtpDTP::CsHostNotFound:
0
1241 case QFtpDTP::CsConnectionRefused:
never executed: case QFtpDTP::CsConnectionRefused:
0
1242 emit error(QFtp::ConnectionRefused,-
1243 QFtp::tr("Data Connection refused"));-
1244 startNextCmd();-
1245 return;
never executed: return;
0
1246 default:
never executed: default:
0
1247 return;
never executed: return;
0
1248 }-
1249}-
1250-
1251/**********************************************************************-
1252 *-
1253 * QFtpPrivate-
1254 *-
1255 *********************************************************************/-
1256-
1257QT_BEGIN_INCLUDE_NAMESPACE-
1258#include <private/qobject_p.h>-
1259QT_END_INCLUDE_NAMESPACE-
1260-
1261class QFtpPrivate : public QObjectPrivate-
1262{-
1263 Q_DECLARE_PUBLIC(QFtp)-
1264public:-
1265-
1266 inline QFtpPrivate() : close_waitForStateChange(false), state(QFtp::Unconnected),-
1267 transferMode(QFtp::Passive), error(QFtp::NoError)-
1268 { }
executed 661 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
661
1269-
1270 ~QFtpPrivate() { while (!pending.isEmpty()) delete pending.takeFirst(); }
executed 659 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
executed 661 times by 2 tests: delete pending.takeFirst();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
!pending.isEmpty()Description
TRUEevaluated 661 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 659 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
659-661
1271-
1272 // private slots-
1273 void _q_startNextCommand();-
1274 void _q_piFinished(const QString&);-
1275 void _q_piError(int, const QString&);-
1276 void _q_piConnectState(int);-
1277 void _q_piFtpReply(int, const QString&);-
1278-
1279 int addCommand(QFtpCommand *cmd);-
1280-
1281 QFtpPI pi;-
1282 QList<QFtpCommand *> pending;-
1283 bool close_waitForStateChange;-
1284 QFtp::State state;-
1285 QFtp::TransferMode transferMode;-
1286 QFtp::Error error;-
1287 QString errorString;-
1288-
1289 QString host;-
1290 quint16 port;-
1291 QString proxyHost;-
1292 quint16 proxyPort;-
1293};-
1294-
1295int QFtpPrivate::addCommand(QFtpCommand *cmd)-
1296{-
1297 pending.append(cmd);-
1298-
1299 if (pending.count() == 1) {
pending.count() == 1Description
TRUEevaluated 1481 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 1942 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
1481-1942
1300 // don't emit the commandStarted() signal before the ID is returned-
1301 QTimer::singleShot(0, q_func(), SLOT(_q_startNextCommand()));-
1302 }
executed 1481 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
1481
1303 return cmd->id;
executed 3423 times by 2 tests: return cmd->id;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
3423
1304}-
1305-
1306/**********************************************************************-
1307 *-
1308 * QFtp implementation-
1309 *-
1310 *********************************************************************/-
1311/*!-
1312 \internal-
1313 \class QFtp-
1314 \brief The QFtp class provides an implementation of the client side of FTP protocol.-
1315-
1316 \ingroup network-
1317 \inmodule QtNetwork-
1318-
1319-
1320 This class provides a direct interface to FTP that allows you to-
1321 have more control over the requests. However, for new-
1322 applications, it is recommended to use QNetworkAccessManager and-
1323 QNetworkReply, as those classes possess a simpler, yet more-
1324 powerful API.-
1325-
1326 The class works asynchronously, so there are no blocking-
1327 functions. If an operation cannot be executed immediately, the-
1328 function will still return straight away and the operation will be-
1329 scheduled for later execution. The results of scheduled operations-
1330 are reported via signals. This approach depends on the event loop-
1331 being in operation.-
1332-
1333 The operations that can be scheduled (they are called "commands"-
1334 in the rest of the documentation) are the following:-
1335 connectToHost(), login(), close(), list(), cd(), get(), put(),-
1336 remove(), mkdir(), rmdir(), rename() and rawCommand().-
1337-
1338 All of these commands return a unique identifier that allows you-
1339 to keep track of the command that is currently being executed.-
1340 When the execution of a command starts, the commandStarted()-
1341 signal with the command's identifier is emitted. When the command-
1342 is finished, the commandFinished() signal is emitted with the-
1343 command's identifier and a bool that indicates whether the command-
1344 finished with an error.-
1345-
1346 In some cases, you might want to execute a sequence of commands,-
1347 e.g. if you want to connect and login to a FTP server. This is-
1348 simply achieved:-
1349-
1350 \snippet code/src_network_access_qftp.cpp 0-
1351-
1352 In this case two FTP commands have been scheduled. When the last-
1353 scheduled command has finished, a done() signal is emitted with-
1354 a bool argument that tells you whether the sequence finished with-
1355 an error.-
1356-
1357 If an error occurs during the execution of one of the commands in-
1358 a sequence of commands, all the pending commands (i.e. scheduled,-
1359 but not yet executed commands) are cleared and no signals are-
1360 emitted for them.-
1361-
1362 Some commands, e.g. list(), emit additional signals to report-
1363 their results.-
1364-
1365 Example: If you want to download the INSTALL file from the Qt-
1366 FTP server, you would write this:-
1367-
1368 \snippet code/src_network_access_qftp.cpp 1-
1369-
1370 For this example the following sequence of signals is emitted-
1371 (with small variations, depending on network traffic, etc.):-
1372-
1373 \snippet code/src_network_access_qftp.cpp 2-
1374-
1375 The dataTransferProgress() signal in the above example is useful-
1376 if you want to show a \l{QProgressBar}{progress bar} to-
1377 inform the user about the progress of the download. The-
1378 readyRead() signal tells you that there is data ready to be read.-
1379 The amount of data can be queried then with the bytesAvailable()-
1380 function and it can be read with the read() or readAll()-
1381 function.-
1382-
1383 If the login fails for the above example, the signals would look-
1384 like this:-
1385-
1386 \snippet code/src_network_access_qftp.cpp 3-
1387-
1388 You can then get details about the error with the error() and-
1389 errorString() functions.-
1390-
1391 For file transfer, QFtp can use both active or passive mode, and-
1392 it uses passive file transfer mode by default; see the-
1393 documentation for setTransferMode() for more details about this.-
1394-
1395 Call setProxy() to make QFtp connect via an FTP proxy server.-
1396-
1397 The functions currentId() and currentCommand() provide more-
1398 information about the currently executing command.-
1399-
1400 The functions hasPendingCommands() and clearPendingCommands()-
1401 allow you to query and clear the list of pending commands.-
1402-
1403 If you are an experienced network programmer and want to have-
1404 complete control you can use rawCommand() to execute arbitrary FTP-
1405 commands.-
1406-
1407 \warning The current version of QFtp doesn't fully support-
1408 non-Unix FTP servers.-
1409-
1410 \sa QNetworkAccessManager, QNetworkRequest, QNetworkReply,-
1411 {FTP Example}-
1412*/-
1413-
1414-
1415/*!-
1416 \internal-
1417 Constructs a QFtp object with the given \a parent.-
1418*/-
1419QFtp::QFtp(QObject *parent)-
1420 : QObject(*new QFtpPrivate, parent)-
1421{-
1422 Q_D(QFtp);-
1423 d->errorString = tr("Unknown error");-
1424-
1425 connect(&d->pi, SIGNAL(connectState(int)),-
1426 SLOT(_q_piConnectState(int)));-
1427 connect(&d->pi, SIGNAL(finished(QString)),-
1428 SLOT(_q_piFinished(QString)));-
1429 connect(&d->pi, SIGNAL(error(int,QString)),-
1430 SLOT(_q_piError(int,QString)));-
1431 connect(&d->pi, SIGNAL(rawFtpReply(int,QString)),-
1432 SLOT(_q_piFtpReply(int,QString)));-
1433-
1434 connect(&d->pi.dtp, SIGNAL(readyRead()),-
1435 SIGNAL(readyRead()));-
1436 connect(&d->pi.dtp, SIGNAL(dataTransferProgress(qint64,qint64)),-
1437 SIGNAL(dataTransferProgress(qint64,qint64)));-
1438 connect(&d->pi.dtp, SIGNAL(listInfo(QUrlInfo)),-
1439 SIGNAL(listInfo(QUrlInfo)));-
1440}
executed 661 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
661
1441-
1442/*!-
1443 \internal-
1444 \enum QFtp::State-
1445-
1446 This enum defines the connection state:-
1447-
1448 \value Unconnected There is no connection to the host.-
1449 \value HostLookup A host name lookup is in progress.-
1450 \value Connecting An attempt to connect to the host is in progress.-
1451 \value Connected Connection to the host has been achieved.-
1452 \value LoggedIn Connection and user login have been achieved.-
1453 \value Closing The connection is closing down, but it is not yet-
1454 closed. (The state will be \c Unconnected when the connection is-
1455 closed.)-
1456-
1457 \sa stateChanged(), state()-
1458*/-
1459/*!-
1460 \internal-
1461 \enum QFtp::TransferMode-
1462-
1463 FTP works with two socket connections; one for commands and-
1464 another for transmitting data. While the command connection is-
1465 always initiated by the client, the second connection can be-
1466 initiated by either the client or the server.-
1467-
1468 This enum defines whether the client (Passive mode) or the server-
1469 (Active mode) should set up the data connection.-
1470-
1471 \value Passive The client connects to the server to transmit its-
1472 data.-
1473-
1474 \value Active The server connects to the client to transmit its-
1475 data.-
1476*/-
1477/*!-
1478 \internal-
1479 \enum QFtp::TransferType-
1480-
1481 This enum identifies the data transfer type used with get and-
1482 put commands.-
1483-
1484 \value Binary The data will be transferred in Binary mode.-
1485-
1486 \value Ascii The data will be transferred in Ascii mode and new line-
1487 characters will be converted to the local format.-
1488*/-
1489/*!-
1490 \internal-
1491 \enum QFtp::Error-
1492-
1493 This enum identifies the error that occurred.-
1494-
1495 \value NoError No error occurred.-
1496 \value HostNotFound The host name lookup failed.-
1497 \value ConnectionRefused The server refused the connection.-
1498 \value NotConnected Tried to send a command, but there is no connection to-
1499 a server.-
1500 \value UnknownError An error other than those specified above-
1501 occurred.-
1502-
1503 \sa error()-
1504*/-
1505-
1506/*!-
1507 \internal-
1508 \enum QFtp::Command-
1509-
1510 This enum is used as the return value for the currentCommand() function.-
1511 This allows you to perform specific actions for particular-
1512 commands, e.g. in a FTP client, you might want to clear the-
1513 directory view when a list() command is started; in this case you-
1514 can simply check in the slot connected to the start() signal if-
1515 the currentCommand() is \c List.-
1516-
1517 \value None No command is being executed.-
1518 \value SetTransferMode set the \l{TransferMode}{transfer} mode.-
1519 \value SetProxy switch proxying on or off.-
1520 \value ConnectToHost connectToHost() is being executed.-
1521 \value Login login() is being executed.-
1522 \value Close close() is being executed.-
1523 \value List list() is being executed.-
1524 \value Cd cd() is being executed.-
1525 \value Get get() is being executed.-
1526 \value Put put() is being executed.-
1527 \value Remove remove() is being executed.-
1528 \value Mkdir mkdir() is being executed.-
1529 \value Rmdir rmdir() is being executed.-
1530 \value Rename rename() is being executed.-
1531 \value RawCommand rawCommand() is being executed.-
1532-
1533 \sa currentCommand()-
1534*/-
1535-
1536/*!-
1537 \internal-
1538 \fn void QFtp::stateChanged(int state)-
1539-
1540 This signal is emitted when the state of the connection changes.-
1541 The argument \a state is the new state of the connection; it is-
1542 one of the \l State values.-
1543-
1544 It is usually emitted in response to a connectToHost() or close()-
1545 command, but it can also be emitted "spontaneously", e.g. when the-
1546 server closes the connection unexpectedly.-
1547-
1548 \sa connectToHost(), close(), state(), State-
1549*/-
1550-
1551/*!-
1552 \internal-
1553 \fn void QFtp::listInfo(const QUrlInfo &i);-
1554-
1555 This signal is emitted for each directory entry the list() command-
1556 finds. The details of the entry are stored in \a i.-
1557-
1558 \sa list()-
1559*/-
1560-
1561/*!-
1562 \internal-
1563 \fn void QFtp::commandStarted(int id)-
1564-
1565 This signal is emitted when processing the command identified by-
1566 \a id starts.-
1567-
1568 \sa commandFinished(), done()-
1569*/-
1570-
1571/*!-
1572 \internal-
1573 \fn void QFtp::commandFinished(int id, bool error)-
1574-
1575 This signal is emitted when processing the command identified by-
1576 \a id has finished. \a error is true if an error occurred during-
1577 the processing; otherwise \a error is false.-
1578-
1579 \sa commandStarted(), done(), error(), errorString()-
1580*/-
1581-
1582/*!-
1583 \internal-
1584 \fn void QFtp::done(bool error)-
1585-
1586 This signal is emitted when the last pending command has finished;-
1587 (it is emitted after the last command's commandFinished() signal).-
1588 \a error is true if an error occurred during the processing;-
1589 otherwise \a error is false.-
1590-
1591 \sa commandFinished(), error(), errorString()-
1592*/-
1593-
1594/*!-
1595 \internal-
1596 \fn void QFtp::readyRead()-
1597-
1598 This signal is emitted in response to a get() command when there-
1599 is new data to read.-
1600-
1601 If you specify a device as the second argument in the get()-
1602 command, this signal is \e not emitted; instead the data is-
1603 written directly to the device.-
1604-
1605 You can read the data with the readAll() or read() functions.-
1606-
1607 This signal is useful if you want to process the data in chunks as-
1608 soon as it becomes available. If you are only interested in the-
1609 complete data, just connect to the commandFinished() signal and-
1610 read the data then instead.-
1611-
1612 \sa get(), read(), readAll(), bytesAvailable()-
1613*/-
1614-
1615/*!-
1616 \internal-
1617 \fn void QFtp::dataTransferProgress(qint64 done, qint64 total)-
1618-
1619 This signal is emitted in response to a get() or put() request to-
1620 indicate the current progress of the download or upload.-
1621-
1622 \a done is the amount of data that has already been transferred-
1623 and \a total is the total amount of data to be read or written. It-
1624 is possible that the QFtp class is not able to determine the total-
1625 amount of data that should be transferred, in which case \a total-
1626 is 0. (If you connect this signal to a QProgressBar, the progress-
1627 bar shows a busy indicator if the total is 0).-
1628-
1629 \warning \a done and \a total are not necessarily the size in-
1630 bytes, since for large files these values might need to be-
1631 "scaled" to avoid overflow.-
1632-
1633 \sa get(), put(), QProgressBar-
1634*/-
1635-
1636/*!-
1637 \internal-
1638 \fn void QFtp::rawCommandReply(int replyCode, const QString &detail);-
1639-
1640 This signal is emitted in response to the rawCommand() function.-
1641 \a replyCode is the 3 digit reply code and \a detail is the text-
1642 that follows the reply code.-
1643-
1644 \sa rawCommand()-
1645*/-
1646-
1647/*!-
1648 \internal-
1649 Connects to the FTP server \a host using port \a port.-
1650-
1651 The stateChanged() signal is emitted when the state of the-
1652 connecting process changes, e.g. to \c HostLookup, then \c-
1653 Connecting, then \c Connected.-
1654-
1655 The function does not block and returns immediately. The command-
1656 is scheduled, and its execution is performed asynchronously. The-
1657 function returns a unique identifier which is passed by-
1658 commandStarted() and commandFinished().-
1659-
1660 When the command is started the commandStarted() signal is-
1661 emitted. When it is finished the commandFinished() signal is-
1662 emitted.-
1663-
1664 \sa stateChanged(), commandStarted(), commandFinished()-
1665*/-
1666int QFtp::connectToHost(const QString &host, quint16 port)-
1667{-
1668 QStringList cmds;-
1669 cmds << host;-
1670 cmds << QString::number((uint)port);-
1671 int id = d_func()->addCommand(new QFtpCommand(ConnectToHost, cmds));-
1672 d_func()->pi.transferConnectionExtended = true;-
1673 return id;
executed 657 times by 2 tests: return id;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
657
1674}-
1675-
1676/*!-
1677 \internal-
1678 Logs in to the FTP server with the username \a user and the-
1679 password \a password.-
1680-
1681 The stateChanged() signal is emitted when the state of the-
1682 connecting process changes, e.g. to \c LoggedIn.-
1683-
1684 The function does not block and returns immediately. The command-
1685 is scheduled, and its execution is performed asynchronously. The-
1686 function returns a unique identifier which is passed by-
1687 commandStarted() and commandFinished().-
1688-
1689 When the command is started the commandStarted() signal is-
1690 emitted. When it is finished the commandFinished() signal is-
1691 emitted.-
1692-
1693 \sa commandStarted(), commandFinished()-
1694*/-
1695int QFtp::login(const QString &user, const QString &password)-
1696{-
1697 QStringList cmds;-
1698 cmds << (QLatin1String("USER ") + (user.isNull() ? QLatin1String("anonymous") : user) + QLatin1String("\r\n"));-
1699 cmds << (QLatin1String("PASS ") + (password.isNull() ? QLatin1String("anonymous@") : password) + QLatin1String("\r\n"));-
1700 return d_func()->addCommand(new QFtpCommand(Login, cmds));
executed 636 times by 2 tests: return d_func()->addCommand(new QFtpCommand(Login, cmds));
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
636
1701}-
1702-
1703/*!-
1704 \internal-
1705 Closes the connection to the FTP server.-
1706-
1707 The stateChanged() signal is emitted when the state of the-
1708 connecting process changes, e.g. to \c Closing, then \c-
1709 Unconnected.-
1710-
1711 The function does not block and returns immediately. The command-
1712 is scheduled, and its execution is performed asynchronously. The-
1713 function returns a unique identifier which is passed by-
1714 commandStarted() and commandFinished().-
1715-
1716 When the command is started the commandStarted() signal is-
1717 emitted. When it is finished the commandFinished() signal is-
1718 emitted.-
1719-
1720 \sa stateChanged(), commandStarted(), commandFinished()-
1721*/-
1722int QFtp::close()-
1723{-
1724 return d_func()->addCommand(new QFtpCommand(Close, QStringList(QLatin1String("QUIT\r\n"))));
executed 1235 times by 2 tests: return d_func()->addCommand(new QFtpCommand(Close, QStringList(QLatin1String("QUIT\r\n"))));
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
1235
1725}-
1726-
1727/*!-
1728 \internal-
1729 Sets the current FTP transfer mode to \a mode. The default is QFtp::Passive.-
1730-
1731 \sa QFtp::TransferMode-
1732*/-
1733int QFtp::setTransferMode(TransferMode mode)-
1734{-
1735 int id = d_func()->addCommand(new QFtpCommand(SetTransferMode, QStringList()));-
1736 d_func()->pi.transferConnectionExtended = true;-
1737 d_func()->transferMode = mode;-
1738 return id;
executed 4 times by 1 test: return id;
Executed by:
  • tst_QFtp
4
1739}-
1740-
1741/*!-
1742 \internal-
1743 Enables use of the FTP proxy on host \a host and port \a-
1744 port. Calling this function with \a host empty disables proxying.-
1745-
1746 QFtp does not support FTP-over-HTTP proxy servers. Use-
1747 QNetworkAccessManager for this.-
1748*/-
1749int QFtp::setProxy(const QString &host, quint16 port)-
1750{-
1751 QStringList args;-
1752 args << host << QString::number(port);-
1753 return d_func()->addCommand(new QFtpCommand(SetProxy, args));
executed 26 times by 2 tests: return d_func()->addCommand(new QFtpCommand(SetProxy, args));
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
26
1754}-
1755-
1756/*!-
1757 \internal-
1758 Lists the contents of directory \a dir on the FTP server. If \a-
1759 dir is empty, it lists the contents of the current directory.-
1760-
1761 The listInfo() signal is emitted for each directory entry found.-
1762-
1763 The function does not block and returns immediately. The command-
1764 is scheduled, and its execution is performed asynchronously. The-
1765 function returns a unique identifier which is passed by-
1766 commandStarted() and commandFinished().-
1767-
1768 When the command is started the commandStarted() signal is-
1769 emitted. When it is finished the commandFinished() signal is-
1770 emitted.-
1771-
1772 \sa listInfo(), commandStarted(), commandFinished()-
1773*/-
1774int QFtp::list(const QString &dir)-
1775{-
1776 QStringList cmds;-
1777 cmds << QLatin1String("TYPE A\r\n");-
1778 cmds << QLatin1String(d_func()->transferMode == Passive ? "PASV\r\n" : "PORT\r\n");-
1779 if (dir.isEmpty())
dir.isEmpty()Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 156 times by 1 test
Evaluated by:
  • tst_QFtp
72-156
1780 cmds << QLatin1String("LIST\r\n");
executed 72 times by 1 test: cmds << QLatin1String("LIST\r\n");
Executed by:
  • tst_QFtp
72
1781 else-
1782 cmds << (QLatin1String("LIST ") + dir + QLatin1String("\r\n"));
executed 156 times by 1 test: cmds << (QLatin1String("LIST ") + dir + QLatin1String("\r\n"));
Executed by:
  • tst_QFtp
156
1783 return d_func()->addCommand(new QFtpCommand(List, cmds));
executed 228 times by 1 test: return d_func()->addCommand(new QFtpCommand(List, cmds));
Executed by:
  • tst_QFtp
228
1784}-
1785-
1786/*!-
1787 \internal-
1788 Changes the working directory of the server to \a dir.-
1789-
1790 The function does not block and returns immediately. The command-
1791 is scheduled, and its execution is performed asynchronously. The-
1792 function returns a unique identifier which is passed by-
1793 commandStarted() and commandFinished().-
1794-
1795 When the command is started the commandStarted() signal is-
1796 emitted. When it is finished the commandFinished() signal is-
1797 emitted.-
1798-
1799 \sa commandStarted(), commandFinished()-
1800*/-
1801int QFtp::cd(const QString &dir)-
1802{-
1803 return d_func()->addCommand(new QFtpCommand(Cd, QStringList(QLatin1String("CWD ") + dir + QLatin1String("\r\n"))));
executed 216 times by 1 test: return d_func()->addCommand(new QFtpCommand(Cd, QStringList(QLatin1String("CWD ") + dir + QLatin1String("\r\n"))));
Executed by:
  • tst_QFtp
216
1804}-
1805-
1806/*!-
1807 \internal-
1808 Downloads the file \a file from the server.-
1809-
1810 If \a dev is 0, then the readyRead() signal is emitted when there-
1811 is data available to read. You can then read the data with the-
1812 read() or readAll() functions.-
1813-
1814 If \a dev is not 0, the data is written directly to the device \a-
1815 dev. Make sure that the \a dev pointer is valid for the duration-
1816 of the operation (it is safe to delete it when the-
1817 commandFinished() signal is emitted). In this case the readyRead()-
1818 signal is \e not emitted and you cannot read data with the-
1819 read() or readAll() functions.-
1820-
1821 If you don't read the data immediately it becomes available, i.e.-
1822 when the readyRead() signal is emitted, it is still available-
1823 until the next command is started.-
1824-
1825 For example, if you want to present the data to the user as soon-
1826 as there is something available, connect to the readyRead() signal-
1827 and read the data immediately. On the other hand, if you only want-
1828 to work with the complete data, you can connect to the-
1829 commandFinished() signal and read the data when the get() command-
1830 is finished.-
1831-
1832 The data is transferred as Binary or Ascii depending on the value-
1833 of \a type.-
1834-
1835 The function does not block and returns immediately. The command-
1836 is scheduled, and its execution is performed asynchronously. The-
1837 function returns a unique identifier which is passed by-
1838 commandStarted() and commandFinished().-
1839-
1840 When the command is started the commandStarted() signal is-
1841 emitted. When it is finished the commandFinished() signal is-
1842 emitted.-
1843-
1844 \sa readyRead(), dataTransferProgress(), commandStarted(),-
1845 commandFinished()-
1846*/-
1847int QFtp::get(const QString &file, QIODevice *dev, TransferType type)-
1848{-
1849 QStringList cmds;-
1850 if (type == Binary)
type == BinaryDescription
TRUEevaluated 110 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
0-110
1851 cmds << QLatin1String("TYPE I\r\n");
executed 110 times by 2 tests: cmds << QLatin1String("TYPE I\r\n");
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
110
1852 else-
1853 cmds << QLatin1String("TYPE A\r\n");
never executed: cmds << QLatin1String("TYPE A\r\n");
0
1854 cmds << QLatin1String("SIZE ") + file + QLatin1String("\r\n");-
1855 cmds << QLatin1String(d_func()->transferMode == Passive ? "PASV\r\n" : "PORT\r\n");-
1856 cmds << QLatin1String("RETR ") + file + QLatin1String("\r\n");-
1857 return d_func()->addCommand(new QFtpCommand(Get, cmds, dev));
executed 110 times by 2 tests: return d_func()->addCommand(new QFtpCommand(Get, cmds, dev));
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
110
1858}-
1859-
1860/*!-
1861 \internal-
1862 \overload-
1863-
1864 Writes a copy of the given \a data to the file called \a file on-
1865 the server. The progress of the upload is reported by the-
1866 dataTransferProgress() signal.-
1867-
1868 The data is transferred as Binary or Ascii depending on the value-
1869 of \a type.-
1870-
1871 The function does not block and returns immediately. The command-
1872 is scheduled, and its execution is performed asynchronously. The-
1873 function returns a unique identifier which is passed by-
1874 commandStarted() and commandFinished().-
1875-
1876 When the command is started the commandStarted() signal is-
1877 emitted. When it is finished the commandFinished() signal is-
1878 emitted.-
1879-
1880 Since this function takes a copy of the \a data, you can discard-
1881 your own copy when this function returns.-
1882-
1883 \sa dataTransferProgress(), commandStarted(), commandFinished()-
1884*/-
1885int QFtp::put(const QByteArray &data, const QString &file, TransferType type)-
1886{-
1887 QStringList cmds;-
1888 if (type == Binary)
type == BinaryDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFtp
4-24
1889 cmds << QLatin1String("TYPE I\r\n");
executed 24 times by 1 test: cmds << QLatin1String("TYPE I\r\n");
Executed by:
  • tst_QFtp
24
1890 else-
1891 cmds << QLatin1String("TYPE A\r\n");
executed 4 times by 1 test: cmds << QLatin1String("TYPE A\r\n");
Executed by:
  • tst_QFtp
4
1892 cmds << QLatin1String(d_func()->transferMode == Passive ? "PASV\r\n" : "PORT\r\n");-
1893 cmds << QLatin1String("ALLO ") + QString::number(data.size()) + QLatin1String("\r\n");-
1894 cmds << QLatin1String("STOR ") + file + QLatin1String("\r\n");-
1895 return d_func()->addCommand(new QFtpCommand(Put, cmds, data));
executed 28 times by 1 test: return d_func()->addCommand(new QFtpCommand(Put, cmds, data));
Executed by:
  • tst_QFtp
28
1896}-
1897-
1898/*!-
1899 \internal-
1900 Reads the data from the IO device \a dev, and writes it to the-
1901 file called \a file on the server. The data is read in chunks from-
1902 the IO device, so this overload allows you to transmit large-
1903 amounts of data without the need to read all the data into memory-
1904 at once.-
1905-
1906 The data is transferred as Binary or Ascii depending on the value-
1907 of \a type.-
1908-
1909 Make sure that the \a dev pointer is valid for the duration of the-
1910 operation (it is safe to delete it when the commandFinished() is-
1911 emitted).-
1912*/-
1913int QFtp::put(QIODevice *dev, const QString &file, TransferType type)-
1914{-
1915 QStringList cmds;-
1916 if (type == Binary)
type == BinaryDescription
TRUEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
0-15
1917 cmds << QLatin1String("TYPE I\r\n");
executed 15 times by 2 tests: cmds << QLatin1String("TYPE I\r\n");
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
15
1918 else-
1919 cmds << QLatin1String("TYPE A\r\n");
never executed: cmds << QLatin1String("TYPE A\r\n");
0
1920 cmds << QLatin1String(d_func()->transferMode == Passive ? "PASV\r\n" : "PORT\r\n");-
1921 if (!dev->isSequential())
!dev->isSequential()Description
TRUEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
0-15
1922 cmds << QLatin1String("ALLO ") + QString::number(dev->size()) + QLatin1String("\r\n");
executed 15 times by 2 tests: cmds << QLatin1String("ALLO ") + QString::number(dev->size()) + QLatin1String("\r\n");
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
15
1923 cmds << QLatin1String("STOR ") + file + QLatin1String("\r\n");-
1924 return d_func()->addCommand(new QFtpCommand(Put, cmds, dev));
executed 15 times by 2 tests: return d_func()->addCommand(new QFtpCommand(Put, cmds, dev));
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
15
1925}-
1926-
1927/*!-
1928 \internal-
1929 Deletes the file called \a file from the server.-
1930-
1931 The function does not block and returns immediately. The command-
1932 is scheduled, and its execution is performed asynchronously. The-
1933 function returns a unique identifier which is passed by-
1934 commandStarted() and commandFinished().-
1935-
1936 When the command is started the commandStarted() signal is-
1937 emitted. When it is finished the commandFinished() signal is-
1938 emitted.-
1939-
1940 \sa commandStarted(), commandFinished()-
1941*/-
1942int QFtp::remove(const QString &file)-
1943{-
1944 return d_func()->addCommand(new QFtpCommand(Remove, QStringList(QLatin1String("DELE ") + file + QLatin1String("\r\n"))));
executed 32 times by 1 test: return d_func()->addCommand(new QFtpCommand(Remove, QStringList(QLatin1String("DELE ") + file + QLatin1String("\r\n"))));
Executed by:
  • tst_QFtp
32
1945}-
1946-
1947/*!-
1948 \internal-
1949 Creates a directory called \a dir on the server.-
1950-
1951 The function does not block and returns immediately. The command-
1952 is scheduled, and its execution is performed asynchronously. The-
1953 function returns a unique identifier which is passed by-
1954 commandStarted() and commandFinished().-
1955-
1956 When the command is started the commandStarted() signal is-
1957 emitted. When it is finished the commandFinished() signal is-
1958 emitted.-
1959-
1960 \sa commandStarted(), commandFinished()-
1961*/-
1962int QFtp::mkdir(const QString &dir)-
1963{-
1964 return d_func()->addCommand(new QFtpCommand(Mkdir, QStringList(QLatin1String("MKD ") + dir + QLatin1String("\r\n"))));
executed 52 times by 1 test: return d_func()->addCommand(new QFtpCommand(Mkdir, QStringList(QLatin1String("MKD ") + dir + QLatin1String("\r\n"))));
Executed by:
  • tst_QFtp
52
1965}-
1966-
1967/*!-
1968 \internal-
1969 Removes the directory called \a dir from the server.-
1970-
1971 The function does not block and returns immediately. The command-
1972 is scheduled, and its execution is performed asynchronously. The-
1973 function returns a unique identifier which is passed by-
1974 commandStarted() and commandFinished().-
1975-
1976 When the command is started the commandStarted() signal is-
1977 emitted. When it is finished the commandFinished() signal is-
1978 emitted.-
1979-
1980 \sa commandStarted(), commandFinished()-
1981*/-
1982int QFtp::rmdir(const QString &dir)-
1983{-
1984 return d_func()->addCommand(new QFtpCommand(Rmdir, QStringList(QLatin1String("RMD ") + dir + QLatin1String("\r\n"))));
executed 20 times by 1 test: return d_func()->addCommand(new QFtpCommand(Rmdir, QStringList(QLatin1String("RMD ") + dir + QLatin1String("\r\n"))));
Executed by:
  • tst_QFtp
20
1985}-
1986-
1987/*!-
1988 \internal-
1989 Renames the file called \a oldname to \a newname on the server.-
1990-
1991 The function does not block and returns immediately. The command-
1992 is scheduled, and its execution is performed asynchronously. The-
1993 function returns a unique identifier which is passed by-
1994 commandStarted() and commandFinished().-
1995-
1996 When the command is started the commandStarted() signal is-
1997 emitted. When it is finished the commandFinished() signal is-
1998 emitted.-
1999-
2000 \sa commandStarted(), commandFinished()-
2001*/-
2002int QFtp::rename(const QString &oldname, const QString &newname)-
2003{-
2004 QStringList cmds;-
2005 cmds << QLatin1String("RNFR ") + oldname + QLatin1String("\r\n");-
2006 cmds << QLatin1String("RNTO ") + newname + QLatin1String("\r\n");-
2007 return d_func()->addCommand(new QFtpCommand(Rename, cmds));
executed 28 times by 1 test: return d_func()->addCommand(new QFtpCommand(Rename, cmds));
Executed by:
  • tst_QFtp
28
2008}-
2009-
2010/*!-
2011 \internal-
2012 Sends the raw FTP command \a command to the FTP server. This is-
2013 useful for low-level FTP access. If the operation you wish to-
2014 perform has an equivalent QFtp function, we recommend using the-
2015 function instead of raw FTP commands since the functions are-
2016 easier and safer.-
2017-
2018 The function does not block and returns immediately. The command-
2019 is scheduled, and its execution is performed asynchronously. The-
2020 function returns a unique identifier which is passed by-
2021 commandStarted() and commandFinished().-
2022-
2023 When the command is started the commandStarted() signal is-
2024 emitted. When it is finished the commandFinished() signal is-
2025 emitted.-
2026-
2027 \sa rawCommandReply(), commandStarted(), commandFinished()-
2028*/-
2029int QFtp::rawCommand(const QString &command)-
2030{-
2031 QString cmd = command.trimmed() + QLatin1String("\r\n");-
2032 return d_func()->addCommand(new QFtpCommand(RawCommand, QStringList(cmd)));
executed 136 times by 1 test: return d_func()->addCommand(new QFtpCommand(RawCommand, QStringList(cmd)));
Executed by:
  • tst_QNetworkReply
136
2033}-
2034-
2035/*!-
2036 \internal-
2037 Returns the number of bytes that can be read from the data socket-
2038 at the moment.-
2039-
2040 \sa get(), readyRead(), read(), readAll()-
2041*/-
2042qint64 QFtp::bytesAvailable() const-
2043{-
2044 return d_func()->pi.dtp.bytesAvailable();
executed 6305 times by 2 tests: return d_func()->pi.dtp.bytesAvailable();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
6305
2045}-
2046-
2047/*!-
2048 \internal-
2049 Reads \a maxlen bytes from the data socket into \a data and-
2050 returns the number of bytes read. Returns -1 if an error occurred.-
2051-
2052 \sa get(), readyRead(), bytesAvailable(), readAll()-
2053*/-
2054qint64 QFtp::read(char *data, qint64 maxlen)-
2055{-
2056 return d_func()->pi.dtp.read(data, maxlen);
never executed: return d_func()->pi.dtp.read(data, maxlen);
0
2057}-
2058-
2059/*!-
2060 \internal-
2061 Reads all the bytes available from the data socket and returns-
2062 them.-
2063-
2064 \sa get(), readyRead(), bytesAvailable(), read()-
2065*/-
2066QByteArray QFtp::readAll()-
2067{-
2068 return d_func()->pi.dtp.readAll();
executed 744 times by 2 tests: return d_func()->pi.dtp.readAll();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
744
2069}-
2070-
2071/*!-
2072 \internal-
2073 Aborts the current command and deletes all scheduled commands.-
2074-
2075 If there is an unfinished command (i.e. a command for which the-
2076 commandStarted() signal has been emitted, but for which the-
2077 commandFinished() signal has not been emitted), this function-
2078 sends an \c ABORT command to the server. When the server replies-
2079 that the command is aborted, the commandFinished() signal with the-
2080 \c error argument set to \c true is emitted for the command. Due-
2081 to timing issues, it is possible that the command had already-
2082 finished before the abort request reached the server, in which-
2083 case, the commandFinished() signal is emitted with the \c error-
2084 argument set to \c false.-
2085-
2086 For all other commands that are affected by the abort(), no-
2087 signals are emitted.-
2088-
2089 If you don't start further FTP commands directly after the-
2090 abort(), there won't be any scheduled commands and the done()-
2091 signal is emitted.-
2092-
2093 \warning Some FTP servers, for example the BSD FTP daemon (version-
2094 0.3), wrongly return a positive reply even when an abort has-
2095 occurred. For these servers the commandFinished() signal has its-
2096 error flag set to \c false, even though the command did not-
2097 complete successfully.-
2098-
2099 \sa clearPendingCommands()-
2100*/-
2101void QFtp::abort()-
2102{-
2103 if (d_func()->pending.isEmpty())
d_func()->pending.isEmpty()Description
TRUEevaluated 657 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
4-657
2104 return;
executed 657 times by 2 tests: return;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
657
2105-
2106 clearPendingCommands();-
2107 d_func()->pi.abort();-
2108}
executed 4 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
4
2109-
2110/*!-
2111 \internal-
2112 Returns the identifier of the FTP command that is being executed-
2113 or 0 if there is no command being executed.-
2114-
2115 \sa currentCommand()-
2116*/-
2117int QFtp::currentId() const-
2118{-
2119 if (d_func()->pending.isEmpty())
d_func()->pending.isEmpty()Description
TRUEevaluated 731 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 48797 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
731-48797
2120 return 0;
executed 731 times by 1 test: return 0;
Executed by:
  • tst_QFtp
731
2121 return d_func()->pending.first()->id;
executed 48797 times by 2 tests: return d_func()->pending.first()->id;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
48797
2122}-
2123-
2124/*!-
2125 \internal-
2126 Returns the command type of the FTP command being executed or \c-
2127 None if there is no command being executed.-
2128-
2129 \sa currentId()-
2130*/-
2131QFtp::Command QFtp::currentCommand() const-
2132{-
2133 if (d_func()->pending.isEmpty())
d_func()->pending.isEmpty()Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 20839 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
24-20839
2134 return None;
executed 24 times by 1 test: return None;
Executed by:
  • tst_QFtp
24
2135 return d_func()->pending.first()->command;
executed 20839 times by 2 tests: return d_func()->pending.first()->command;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
20839
2136}-
2137-
2138/*!-
2139 \internal-
2140 Returns the QIODevice pointer that is used by the FTP command to read data-
2141 from or store data to. If there is no current FTP command being executed or-
2142 if the command does not use an IO device, this function returns 0.-
2143-
2144 This function can be used to delete the QIODevice in the slot connected to-
2145 the commandFinished() signal.-
2146-
2147 \sa get(), put()-
2148*/-
2149QIODevice* QFtp::currentDevice() const-
2150{-
2151 if (d_func()->pending.isEmpty())
d_func()->pending.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2152 return 0;
never executed: return 0;
0
2153 QFtpCommand *c = d_func()->pending.first();-
2154 if (c->is_ba)
c->is_baDescription
TRUEnever evaluated
FALSEnever evaluated
0
2155 return 0;
never executed: return 0;
0
2156 return c->data.dev;
never executed: return c->data.dev;
0
2157}-
2158-
2159/*!-
2160 \internal-
2161 Returns \c true if there are any commands scheduled that have not yet-
2162 been executed; otherwise returns \c false.-
2163-
2164 The command that is being executed is \e not considered as a-
2165 scheduled command.-
2166-
2167 \sa clearPendingCommands(), currentId(), currentCommand()-
2168*/-
2169bool QFtp::hasPendingCommands() const-
2170{-
2171 return d_func()->pending.count() > 1;
executed 7398 times by 1 test: return d_func()->pending.count() > 1;
Executed by:
  • tst_QFtp
7398
2172}-
2173-
2174/*!-
2175 \internal-
2176 Deletes all pending commands from the list of scheduled commands.-
2177 This does not affect the command that is being executed. If you-
2178 want to stop this as well, use abort().-
2179-
2180 \sa hasPendingCommands(), abort()-
2181*/-
2182void QFtp::clearPendingCommands()-
2183{-
2184 // delete all entires except the first one-
2185 while (d_func()->pending.count() > 1)
d_func()->pending.count() > 1Description
TRUEevaluated 119 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 165 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
119-165
2186 delete d_func()->pending.takeLast();
executed 119 times by 2 tests: delete d_func()->pending.takeLast();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
119
2187}
executed 165 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
165
2188-
2189/*!-
2190 \internal-
2191 Returns the current state of the object. When the state changes,-
2192 the stateChanged() signal is emitted.-
2193-
2194 \sa State, stateChanged()-
2195*/-
2196QFtp::State QFtp::state() const-
2197{-
2198 return d_func()->state;
executed 10508 times by 2 tests: return d_func()->state;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
10508
2199}-
2200-
2201/*!-
2202 \internal-
2203 Returns the last error that occurred. This is useful to find out-
2204 what went wrong when receiving a commandFinished() or a done()-
2205 signal with the \c error argument set to \c true.-
2206-
2207 If you start a new command, the error status is reset to \c NoError.-
2208*/-
2209QFtp::Error QFtp::error() const-
2210{-
2211 return d_func()->error;
executed 5556 times by 2 tests: return d_func()->error;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
5556
2212}-
2213-
2214/*!-
2215 \internal-
2216 Returns a human-readable description of the last error that-
2217 occurred. This is useful for presenting a error message to the-
2218 user when receiving a commandFinished() or a done() signal with-
2219 the \c error argument set to \c true.-
2220-
2221 The error string is often (but not always) the reply from the-
2222 server, so it is not always possible to translate the string. If-
2223 the message comes from Qt, the string has already passed through-
2224 tr().-
2225*/-
2226QString QFtp::errorString() const-
2227{-
2228 return d_func()->errorString;
executed 6 times by 1 test: return d_func()->errorString;
Executed by:
  • tst_QNetworkReply
6
2229}-
2230-
2231/*! \internal-
2232*/-
2233void QFtpPrivate::_q_startNextCommand()-
2234{-
2235 Q_Q(QFtp);-
2236 if (pending.isEmpty())
pending.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 2643 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-2643
2237 return;
never executed: return;
0
2238 QFtpCommand *c = pending.first();-
2239-
2240 error = QFtp::NoError;-
2241 errorString = QT_TRANSLATE_NOOP(QFtp, QLatin1String("Unknown error"));-
2242-
2243 if (q->bytesAvailable())
q->bytesAvailable()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 2635 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
8-2635
2244 q->readAll(); // clear the data
executed 8 times by 1 test: q->readAll();
Executed by:
  • tst_QFtp
8
2245 emit q->commandStarted(c->id);-
2246-
2247 // Proxy support, replace the Login argument in place, then fall-
2248 // through.-
2249 if (c->command == QFtp::Login && !proxyHost.isEmpty()) {
c->command == QFtp::LoginDescription
TRUEevaluated 633 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 2010 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
!proxyHost.isEmpty()Description
TRUEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 607 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
26-2010
2250 QString loginString = c->rawCmds.first().trimmed();-
2251 loginString += QLatin1Char('@') + host;-
2252 if (port && port != 21)
portDescription
TRUEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
port != 21Description
TRUEnever evaluated
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-26
2253 loginString += QLatin1Char(':') + QString::number(port);
never executed: loginString += QLatin1Char(':') + QString::number(port);
0
2254 loginString += QLatin1String("\r\n");-
2255 c->rawCmds[0] = loginString;-
2256 }
executed 26 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
26
2257-
2258 if (c->command == QFtp::SetTransferMode) {
c->command == ...etTransferModeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 2639 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
4-2639
2259 _q_piFinished(QLatin1String("Transfer mode set"));-
2260 } else if (c->command == QFtp::SetProxy) {
executed 4 times by 1 test: end of block
Executed by:
  • tst_QFtp
c->command == QFtp::SetProxyDescription
TRUEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 2613 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
4-2613
2261 proxyHost = c->rawCmds[0];-
2262 proxyPort = c->rawCmds[1].toUInt();-
2263 c->rawCmds.clear();-
2264 _q_piFinished(QLatin1String("Proxy set to ") + proxyHost + QLatin1Char(':') + QString::number(proxyPort));-
2265 } else if (c->command == QFtp::ConnectToHost) {
executed 26 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
c->command == ...:ConnectToHostDescription
TRUEevaluated 657 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 1956 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
26-1956
2266#ifndef QT_NO_BEARERMANAGEMENT-
2267 //copy network session down to the PI-
2268 pi.setProperty("_q_networksession", q->property("_q_networksession"));-
2269#endif-
2270 if (!proxyHost.isEmpty()) {
!proxyHost.isEmpty()Description
TRUEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 631 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
26-631
2271 host = c->rawCmds[0];-
2272 port = c->rawCmds[1].toUInt();-
2273 pi.connectToHost(proxyHost, proxyPort);-
2274 } else {
executed 26 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
26
2275 pi.connectToHost(c->rawCmds[0], c->rawCmds[1].toUInt());-
2276 }
executed 631 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
631
2277 } else {-
2278 if (c->command == QFtp::Put) {
c->command == QFtp::PutDescription
TRUEevaluated 43 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 1913 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
43-1913
2279 if (c->is_ba) {
c->is_baDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
15-28
2280 pi.dtp.setData(c->data.ba);-
2281 pi.dtp.setBytesTotal(c->data.ba->size());-
2282 } else if (c->data.dev && (c->data.dev->isOpen() || c->data.dev->open(QIODevice::ReadOnly))) {
executed 28 times by 1 test: end of block
Executed by:
  • tst_QFtp
c->data.devDescription
TRUEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
c->data.dev->isOpen()Description
TRUEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
c->data.dev->o...ice::ReadOnly)Description
TRUEnever evaluated
FALSEnever evaluated
0-28
2283 pi.dtp.setDevice(c->data.dev);-
2284 if (c->data.dev->isSequential()) {
c->data.dev->isSequential()Description
TRUEnever evaluated
FALSEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-15
2285 pi.dtp.setBytesTotal(0);-
2286 pi.dtp.connect(c->data.dev, SIGNAL(readyRead()), SLOT(dataReadyRead()));-
2287 pi.dtp.connect(c->data.dev, SIGNAL(readChannelFinished()), SLOT(dataReadyRead()));-
2288 } else {
never executed: end of block
0
2289 pi.dtp.setBytesTotal(c->data.dev->size());-
2290 }
executed 15 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
15
2291 }-
2292 } else if (c->command == QFtp::Get) {
executed 43 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
c->command == QFtp::GetDescription
TRUEevaluated 110 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 1803 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
43-1803
2293 if (!c->is_ba && c->data.dev) {
!c->is_baDescription
TRUEevaluated 110 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
c->data.devDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 70 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-110
2294 pi.dtp.setDevice(c->data.dev);-
2295 }
executed 40 times by 1 test: end of block
Executed by:
  • tst_QFtp
40
2296 } else if (c->command == QFtp::Close) {
executed 110 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
c->command == QFtp::CloseDescription
TRUEevaluated 480 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 1323 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
110-1323
2297 state = QFtp::Closing;-
2298 emit q->stateChanged(state);-
2299 }
executed 480 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
480
2300 pi.sendCommands(c->rawCmds);-
2301 }
executed 1956 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
1956
2302}-
2303-
2304/*! \internal-
2305*/-
2306void QFtpPrivate::_q_piFinished(const QString&)-
2307{-
2308 if (pending.isEmpty())
pending.isEmpty()Description
TRUEevaluated 116 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 2957 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
116-2957
2309 return;
executed 116 times by 1 test: return;
Executed by:
  • tst_QFtp
116
2310 QFtpCommand *c = pending.first();-
2311-
2312 if (c->command == QFtp::Close) {
c->command == QFtp::CloseDescription
TRUEevaluated 948 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 2009 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
948-2009
2313 // The order of in which the slots are called is arbitrary, so-
2314 // disconnect the SIGNAL-SIGNAL temporary to make sure that we-
2315 // don't get the commandFinished() signal before the stateChanged()-
2316 // signal.-
2317 if (state != QFtp::Unconnected) {
state != QFtp::UnconnectedDescription
TRUEevaluated 479 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 469 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
469-479
2318 close_waitForStateChange = true;-
2319 return;
executed 479 times by 2 tests: return;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
479
2320 }-
2321 }
executed 469 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
469
2322 emit q_func()->commandFinished(c->id, false);-
2323 pending.removeFirst();-
2324-
2325 delete c;-
2326-
2327 if (pending.isEmpty()) {
pending.isEmpty()Description
TRUEevaluated 663 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 1815 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
663-1815
2328 emit q_func()->done(false);-
2329 } else {
executed 663 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
663
2330 _q_startNextCommand();-
2331 }
executed 1815 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
1815
2332}-
2333-
2334/*! \internal-
2335*/-
2336void QFtpPrivate::_q_piError(int errorCode, const QString &text)-
2337{-
2338 Q_Q(QFtp);-
2339-
2340 if (pending.isEmpty()) {
pending.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 220 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
0-220
2341 qWarning("QFtpPrivate::_q_piError was called without pending command!");-
2342 return;
never executed: return;
0
2343 }-
2344-
2345 QFtpCommand *c = pending.first();-
2346-
2347 // non-fatal errors-
2348 if (c->command == QFtp::Get && pi.currentCommand().startsWith(QLatin1String("SIZE "))) {
c->command == QFtp::GetDescription
TRUEevaluated 33 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 187 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
pi.currentComm...ring("SIZE "))Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_QFtp
FALSEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
16-187
2349 pi.dtp.setBytesTotal(0);-
2350 return;
executed 16 times by 1 test: return;
Executed by:
  • tst_QFtp
16
2351 } else if (c->command==QFtp::Put && pi.currentCommand().startsWith(QLatin1String("ALLO "))) {
c->command==QFtp::PutDescription
TRUEevaluated 43 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 161 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
pi.currentComm...ring("ALLO "))Description
TRUEevaluated 43 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEnever evaluated
0-161
2352 return;
executed 43 times by 2 tests: return;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
43
2353 }-
2354-
2355 error = QFtp::Error(errorCode);-
2356 switch (q->currentCommand()) {-
2357 case QFtp::ConnectToHost:
executed 20 times by 2 tests: case QFtp::ConnectToHost:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
20
2358 errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Connecting to host failed:\n%1"))-
2359 .arg(text);-
2360 break;
executed 20 times by 2 tests: break;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
20
2361 case QFtp::Login:
executed 23 times by 2 tests: case QFtp::Login:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
23
2362 errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Login failed:\n%1"))-
2363 .arg(text);-
2364 break;
executed 23 times by 2 tests: break;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
23
2365 case QFtp::List:
never executed: case QFtp::List:
0
2366 errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Listing directory failed:\n%1"))-
2367 .arg(text);-
2368 break;
never executed: break;
0
2369 case QFtp::Cd:
executed 48 times by 1 test: case QFtp::Cd:
Executed by:
  • tst_QFtp
48
2370 errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Changing directory failed:\n%1"))-
2371 .arg(text);-
2372 break;
executed 48 times by 1 test: break;
Executed by:
  • tst_QFtp
48
2373 case QFtp::Get:
executed 17 times by 2 tests: case QFtp::Get:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
17
2374 errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Downloading file failed:\n%1"))-
2375 .arg(text);-
2376 break;
executed 17 times by 2 tests: break;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
17
2377 case QFtp::Put:
never executed: case QFtp::Put:
0
2378 errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Uploading file failed:\n%1"))-
2379 .arg(text);-
2380 break;
never executed: break;
0
2381 case QFtp::Remove:
never executed: case QFtp::Remove:
0
2382 errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Removing file failed:\n%1"))-
2383 .arg(text);-
2384 break;
never executed: break;
0
2385 case QFtp::Mkdir:
executed 32 times by 1 test: case QFtp::Mkdir:
Executed by:
  • tst_QFtp
32
2386 errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Creating directory failed:\n%1"))-
2387 .arg(text);-
2388 break;
executed 32 times by 1 test: break;
Executed by:
  • tst_QFtp
32
2389 case QFtp::Rmdir:
never executed: case QFtp::Rmdir:
0
2390 errorString = QString::fromLatin1(QT_TRANSLATE_NOOP("QFtp", "Removing directory failed:\n%1"))-
2391 .arg(text);-
2392 break;
never executed: break;
0
2393 default:
executed 21 times by 2 tests: default:
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
21
2394 errorString = text;-
2395 break;
executed 21 times by 2 tests: break;
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
21
2396 }-
2397-
2398 pi.clearPendingCommands();-
2399 q->clearPendingCommands();-
2400 emit q->commandFinished(c->id, true);-
2401-
2402 pending.removeFirst();-
2403 delete c;-
2404 if (pending.isEmpty())
pending.isEmpty()Description
TRUEevaluated 157 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QFtp
4-157
2405 emit q->done(true);
executed 157 times by 2 tests: q->done(true);
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
157
2406 else-
2407 _q_startNextCommand();
executed 4 times by 1 test: _q_startNextCommand();
Executed by:
  • tst_QFtp
4
2408}-
2409-
2410/*! \internal-
2411*/-
2412void QFtpPrivate::_q_piConnectState(int connectState)-
2413{-
2414 state = QFtp::State(connectState);-
2415 emit q_func()->stateChanged(state);-
2416 if (close_waitForStateChange) {
close_waitForStateChangeDescription
TRUEevaluated 469 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
FALSEevaluated 2278 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
469-2278
2417 close_waitForStateChange = false;-
2418 _q_piFinished(QLatin1String(QT_TRANSLATE_NOOP("QFtp", "Connection closed")));-
2419 }
executed 469 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
469
2420}
executed 2747 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
2747
2421-
2422/*! \internal-
2423*/-
2424void QFtpPrivate::_q_piFtpReply(int code, const QString &text)-
2425{-
2426 if (q_func()->currentCommand() == QFtp::RawCommand) {
q_func()->curr...tp::RawCommandDescription
TRUEevaluated 132 times by 1 test
Evaluated by:
  • tst_QNetworkReply
FALSEevaluated 4304 times by 2 tests
Evaluated by:
  • tst_QFtp
  • tst_QNetworkReply
132-4304
2427 pi.rawCommand = true;-
2428 emit q_func()->rawCommandReply(code, text);-
2429 }
executed 132 times by 1 test: end of block
Executed by:
  • tst_QNetworkReply
132
2430}
executed 4436 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
4436
2431-
2432/*!-
2433 \internal-
2434 Destructor.-
2435*/-
2436QFtp::~QFtp()-
2437{-
2438 abort();
executed 659 times by 2 tests: abort();
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
659
2439 close();-
2440}
executed 659 times by 2 tests: end of block
Executed by:
  • tst_QFtp
  • tst_QNetworkReply
659
2441-
2442QT_END_NAMESPACE-
2443-
2444#include "qftp.moc"-
2445-
2446#include "moc_qftp_p.cpp"-
2447-
2448#endif // QT_NO_FTP-
Source codeSwitch to Preprocessed file

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