| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/access/qftp.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | class QFtpPI; | - | ||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | class QFtpDTP : public QObject | - | ||||||||||||||||||
| 14 | { | - | ||||||||||||||||||
| 15 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - | ||||||||||||||||||
| 16 | #pragma GCC diagnostic push | - | ||||||||||||||||||
| 17 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||||||||
| 18 | #pragma GCC diagnostic pop | - | ||||||||||||||||||
| 19 | struct QPrivateSignal {}; | - | ||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | public: | - | ||||||||||||||||||
| 22 | enum ConnectState { | - | ||||||||||||||||||
| 23 | CsHostFound, | - | ||||||||||||||||||
| 24 | CsConnected, | - | ||||||||||||||||||
| 25 | CsClosed, | - | ||||||||||||||||||
| 26 | CsHostNotFound, | - | ||||||||||||||||||
| 27 | CsConnectionRefused | - | ||||||||||||||||||
| 28 | }; | - | ||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | QFtpDTP(QFtpPI *p, QObject *parent = 0); | - | ||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | void setData(QByteArray *); | - | ||||||||||||||||||
| 33 | void setDevice(QIODevice *); | - | ||||||||||||||||||
| 34 | void writeData(); | - | ||||||||||||||||||
| 35 | void setBytesTotal(qint64 bytes); | - | ||||||||||||||||||
| 36 | - | |||||||||||||||||||
| 37 | bool hasError() const; | - | ||||||||||||||||||
| 38 | QString errorMessage() const; | - | ||||||||||||||||||
| 39 | void clearError(); | - | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | void connectToHost(const QString & host, quint16 port); | - | ||||||||||||||||||
| 42 | int setupListener(const QHostAddress &address); | - | ||||||||||||||||||
| 43 | void waitForConnection(); | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | QTcpSocket::SocketState state() const; | - | ||||||||||||||||||
| 46 | qint64 bytesAvailable() const; | - | ||||||||||||||||||
| 47 | qint64 read(char *data, qint64 maxlen); | - | ||||||||||||||||||
| 48 | QByteArray readAll(); | - | ||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | void abortConnection(); | - | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | static bool parseDir(const QByteArray &buffer, const QString &userName, QUrlInfo *info); | - | ||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | public : | - | ||||||||||||||||||
| 55 | void listInfo(const QUrlInfo&); | - | ||||||||||||||||||
| 56 | void readyRead(); | - | ||||||||||||||||||
| 57 | void dataTransferProgress(qint64, qint64); | - | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | void connectState(int); | - | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | private : | - | ||||||||||||||||||
| 62 | void socketConnected(); | - | ||||||||||||||||||
| 63 | void socketReadyRead(); | - | ||||||||||||||||||
| 64 | void socketError(QAbstractSocket::SocketError); | - | ||||||||||||||||||
| 65 | void socketConnectionClosed(); | - | ||||||||||||||||||
| 66 | void socketBytesWritten(qint64); | - | ||||||||||||||||||
| 67 | void setupSocket(); | - | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | void dataReadyRead(); | - | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | private: | - | ||||||||||||||||||
| 72 | void clearData(); | - | ||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | QTcpSocket *socket; | - | ||||||||||||||||||
| 75 | QTcpServer listener; | - | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | QFtpPI *pi; | - | ||||||||||||||||||
| 78 | QString err; | - | ||||||||||||||||||
| 79 | qint64 bytesDone; | - | ||||||||||||||||||
| 80 | qint64 bytesTotal; | - | ||||||||||||||||||
| 81 | bool callWriteData; | - | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | union { | - | ||||||||||||||||||
| 86 | QByteArray *ba; | - | ||||||||||||||||||
| 87 | QIODevice *dev; | - | ||||||||||||||||||
| 88 | } data; | - | ||||||||||||||||||
| 89 | bool is_ba; | - | ||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | QByteArray bytesFromSocket; | - | ||||||||||||||||||
| 92 | }; | - | ||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | class QFtpPI : public QObject | - | ||||||||||||||||||
| 101 | { | - | ||||||||||||||||||
| 102 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - | ||||||||||||||||||
| 103 | #pragma GCC diagnostic push | - | ||||||||||||||||||
| 104 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||||||||
| 105 | #pragma GCC diagnostic pop | - | ||||||||||||||||||
| 106 | struct QPrivateSignal {}; | - | ||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | public: | - | ||||||||||||||||||
| 109 | QFtpPI(QObject *parent = 0); | - | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | void connectToHost(const QString &host, quint16 port); | - | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | bool sendCommands(const QStringList &cmds); | - | ||||||||||||||||||
| 114 | bool sendCommand(const QString &cmd) | - | ||||||||||||||||||
| 115 |         { return never executed:   sendCommands(QStringList(cmd));return sendCommands(QStringList(cmd));never executed:   }return sendCommands(QStringList(cmd)); | 0 | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | void clearPendingCommands(); | - | ||||||||||||||||||
| 118 | void abort(); | - | ||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | QString currentCommand() const | - | ||||||||||||||||||
| 121 |         { return executed 3234 times by 2 tests:   currentCmd;return currentCmd;Executed by: 
 executed 3234 times by 2 tests:   }return currentCmd;Executed by: 
  | 3234 | ||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | bool rawCommand; | - | ||||||||||||||||||
| 124 | bool transferConnectionExtended; | - | ||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | QFtpDTP dtp; | - | ||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | public : | - | ||||||||||||||||||
| 129 | void connectState(int); | - | ||||||||||||||||||
| 130 | void finished(const QString&); | - | ||||||||||||||||||
| 131 | void error(int, const QString&); | - | ||||||||||||||||||
| 132 | void rawFtpReply(int, const QString&); | - | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | private : | - | ||||||||||||||||||
| 135 | void hostFound(); | - | ||||||||||||||||||
| 136 | void connected(); | - | ||||||||||||||||||
| 137 | void connectionClosed(); | - | ||||||||||||||||||
| 138 | void delayedCloseFinished(); | - | ||||||||||||||||||
| 139 | void readyRead(); | - | ||||||||||||||||||
| 140 | void error(QAbstractSocket::SocketError); | - | ||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | void dtpConnectState(int); | - | ||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | private: | - | ||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | enum State { | - | ||||||||||||||||||
| 148 | Begin, | - | ||||||||||||||||||
| 149 | Idle, | - | ||||||||||||||||||
| 150 | Waiting, | - | ||||||||||||||||||
| 151 | Success, | - | ||||||||||||||||||
| 152 | Failure | - | ||||||||||||||||||
| 153 | }; | - | ||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | enum AbortState { | - | ||||||||||||||||||
| 156 | None, | - | ||||||||||||||||||
| 157 | AbortStarted, | - | ||||||||||||||||||
| 158 | WaitForAbortToFinish | - | ||||||||||||||||||
| 159 | }; | - | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | bool processReply(); | - | ||||||||||||||||||
| 162 | bool startNextCmd(); | - | ||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | QTcpSocket commandSocket; | - | ||||||||||||||||||
| 165 | QString replyText; | - | ||||||||||||||||||
| 166 | char replyCode[3]; | - | ||||||||||||||||||
| 167 | State state; | - | ||||||||||||||||||
| 168 | AbortState abortState; | - | ||||||||||||||||||
| 169 | QStringList pendingCommands; | - | ||||||||||||||||||
| 170 | QString currentCmd; | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | bool waitForDtpToConnect; | - | ||||||||||||||||||
| 173 | bool waitForDtpToClose; | - | ||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | QByteArray bytesFromSocket; | - | ||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | friend class QFtpDTP; | - | ||||||||||||||||||
| 178 | }; | - | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | class QFtpCommand | - | ||||||||||||||||||
| 186 | { | - | ||||||||||||||||||
| 187 | public: | - | ||||||||||||||||||
| 188 | QFtpCommand(QFtp::Command cmd, const QStringList &raw, const QByteArray &ba); | - | ||||||||||||||||||
| 189 | QFtpCommand(QFtp::Command cmd, const QStringList &raw, QIODevice *dev = 0); | - | ||||||||||||||||||
| 190 | ~QFtpCommand(); | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | int id; | - | ||||||||||||||||||
| 193 | QFtp::Command command; | - | ||||||||||||||||||
| 194 | QStringList rawCmds; | - | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | union { | - | ||||||||||||||||||
| 199 | QByteArray *ba; | - | ||||||||||||||||||
| 200 | QIODevice *dev; | - | ||||||||||||||||||
| 201 | } data; | - | ||||||||||||||||||
| 202 | bool is_ba; | - | ||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | static QBasicAtomicInt idCounter; | - | ||||||||||||||||||
| 205 | }; | - | ||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | QBasicAtomicInt QFtpCommand::idCounter = { 1 }; | - | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | QFtpCommand::QFtpCommand(QFtp::Command cmd, const QStringList &raw, const QByteArray &ba) | - | ||||||||||||||||||
| 210 | : command(cmd), rawCmds(raw), is_ba(true) | - | ||||||||||||||||||
| 211 | { | - | ||||||||||||||||||
| 212 | id = idCounter.fetchAndAddRelaxed(1); | - | ||||||||||||||||||
| 213 | data.ba = new QByteArray(ba); | - | ||||||||||||||||||
| 214 | } executed 28 times by 1 test:  end of blockExecuted by: 
  | 28 | ||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | QFtpCommand::QFtpCommand(QFtp::Command cmd, const QStringList &raw, QIODevice *dev) | - | ||||||||||||||||||
| 217 | : command(cmd), rawCmds(raw), is_ba(false) | - | ||||||||||||||||||
| 218 | { | - | ||||||||||||||||||
| 219 | id = idCounter.fetchAndAddRelaxed(1); | - | ||||||||||||||||||
| 220 | data.dev = dev; | - | ||||||||||||||||||
| 221 | } executed 3395 times by 2 tests:  end of blockExecuted by: 
  | 3395 | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | QFtpCommand::~QFtpCommand() | - | ||||||||||||||||||
| 224 | { | - | ||||||||||||||||||
| 225 |     if (is_ba
  | 28-3391 | ||||||||||||||||||
| 226 |         delete data.ba; executed 28 times by 1 test:  delete data.ba;Executed by: 
  | 28 | ||||||||||||||||||
| 227 | } executed 3419 times by 2 tests:  end of blockExecuted by: 
  | 3419 | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | - | |||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | QFtpDTP::QFtpDTP(QFtpPI *p, QObject *parent) : | - | ||||||||||||||||||
| 235 | QObject(parent), | - | ||||||||||||||||||
| 236 | socket(0), | - | ||||||||||||||||||
| 237 | listener(this), | - | ||||||||||||||||||
| 238 | pi(p), | - | ||||||||||||||||||
| 239 | callWriteData(false) | - | ||||||||||||||||||
| 240 | { | - | ||||||||||||||||||
| 241 | clearData(); | - | ||||||||||||||||||
| 242 | listener.setObjectName(QLatin1String("QFtpDTP active state server")); | - | ||||||||||||||||||
| 243 | connect(&listener, qFlagLocation("2""newConnection()" "\0" __FILE__ ":" "288"), qFlagLocation("1""setupSocket()" "\0" __FILE__ ":" "288")); | - | ||||||||||||||||||
| 244 | } executed 661 times by 2 tests:  end of blockExecuted by: 
  | 661 | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | void QFtpDTP::setData(QByteArray *ba) | - | ||||||||||||||||||
| 247 | { | - | ||||||||||||||||||
| 248 | is_ba = true; | - | ||||||||||||||||||
| 249 | data.ba = ba; | - | ||||||||||||||||||
| 250 | } executed 28 times by 1 test:  end of blockExecuted by: 
  | 28 | ||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | void QFtpDTP::setDevice(QIODevice *dev) | - | ||||||||||||||||||
| 253 | { | - | ||||||||||||||||||
| 254 | is_ba = false; | - | ||||||||||||||||||
| 255 | data.dev = dev; | - | ||||||||||||||||||
| 256 | } executed 55 times by 2 tests:  end of blockExecuted by: 
  | 55 | ||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | void QFtpDTP::setBytesTotal(qint64 bytes) | - | ||||||||||||||||||
| 259 | { | - | ||||||||||||||||||
| 260 | bytesTotal = bytes; | - | ||||||||||||||||||
| 261 | bytesDone = 0; | - | ||||||||||||||||||
| 262 | dataTransferProgress(bytesDone, bytesTotal); | - | ||||||||||||||||||
| 263 | } executed 153 times by 2 tests:  end of blockExecuted by: 
  | 153 | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | void QFtpDTP::connectToHost(const QString & host, quint16 port) | - | ||||||||||||||||||
| 266 | { | - | ||||||||||||||||||
| 267 | bytesFromSocket.clear(); | - | ||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 |     if (socket
  | 1-354 | ||||||||||||||||||
| 270 | delete socket; | - | ||||||||||||||||||
| 271 | socket = 0; | - | ||||||||||||||||||
| 272 |     } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 273 | socket = new QTcpSocket(this); | - | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | - | |||||||||||||||||||
| 276 | socket->setProperty("_q_networksession", property("_q_networksession")); | - | ||||||||||||||||||
| 277 | - | |||||||||||||||||||
| 278 | socket->setObjectName(QLatin1String("QFtpDTP Passive state socket")); | - | ||||||||||||||||||
| 279 | connect(socket, qFlagLocation("2""connected()" "\0" __FILE__ ":" "324"), qFlagLocation("1""socketConnected()" "\0" __FILE__ ":" "324")); | - | ||||||||||||||||||
| 280 | connect(socket, qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "325"), qFlagLocation("1""socketReadyRead()" "\0" __FILE__ ":" "325")); | - | ||||||||||||||||||
| 281 | connect(socket, qFlagLocation("2""error(QAbstractSocket::SocketError)" "\0" __FILE__ ":" "326"), qFlagLocation("1""socketError(QAbstractSocket::SocketError)" "\0" __FILE__ ":" "326")); | - | ||||||||||||||||||
| 282 | connect(socket, qFlagLocation("2""disconnected()" "\0" __FILE__ ":" "327"), qFlagLocation("1""socketConnectionClosed()" "\0" __FILE__ ":" "327")); | - | ||||||||||||||||||
| 283 | connect(socket, qFlagLocation("2""bytesWritten(qint64)" "\0" __FILE__ ":" "328"), qFlagLocation("1""socketBytesWritten(qint64)" "\0" __FILE__ ":" "328")); | - | ||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | socket->connectToHost(host, port); | - | ||||||||||||||||||
| 286 | } executed 355 times by 2 tests:  end of blockExecuted by: 
  | 355 | ||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | int QFtpDTP::setupListener(const QHostAddress &address) | - | ||||||||||||||||||
| 289 | { | - | ||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | listener.setProperty("_q_networksession", property("_q_networksession")); | - | ||||||||||||||||||
| 293 | - | |||||||||||||||||||
| 294 |     if (!listener.isListening()
 
  | 0-8 | ||||||||||||||||||
| 295 |         return never executed:   -1;return -1;never executed:  return -1; | 0 | ||||||||||||||||||
| 296 |     return executed 8 times by 1 test:   listener.serverPort();return listener.serverPort();Executed by: 
 executed 8 times by 1 test:  return listener.serverPort();Executed by: 
  | 8 | ||||||||||||||||||
| 297 | } | - | ||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | void QFtpDTP::waitForConnection() | - | ||||||||||||||||||
| 300 | { | - | ||||||||||||||||||
| 301 | - | |||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | - | |||||||||||||||||||
| 304 |     if (listener.isListening()
  | 0-43 | ||||||||||||||||||
| 305 |         listener.waitForNewConnection(); never executed:  listener.waitForNewConnection(); | 0 | ||||||||||||||||||
| 306 | } executed 43 times by 2 tests:  end of blockExecuted by: 
  | 43 | ||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | QTcpSocket::SocketState QFtpDTP::state() const | - | ||||||||||||||||||
| 309 | { | - | ||||||||||||||||||
| 310 |     return executed 346 times by 2 tests:   socket ? socket->state() : QTcpSocket::UnconnectedState;return socket ? socket->state() : QTcpSocket::UnconnectedState;Executed by: 
 executed 346 times by 2 tests:  return socket ? socket->state() : QTcpSocket::UnconnectedState;Executed by: 
  | 346 | ||||||||||||||||||
| 311 | } | - | ||||||||||||||||||
| 312 | - | |||||||||||||||||||
| 313 | qint64 QFtpDTP::bytesAvailable() const | - | ||||||||||||||||||
| 314 | { | - | ||||||||||||||||||
| 315 |     if (!socket
 
  | 580-4292 | ||||||||||||||||||
| 316 |         return executed 5591 times by 2 tests:   (qint64) bytesFromSocket.size();return (qint64) bytesFromSocket.size();Executed by: 
 executed 5591 times by 2 tests:  return (qint64) bytesFromSocket.size();Executed by: 
  | 5591 | ||||||||||||||||||
| 317 |     return executed 580 times by 2 tests:   socket->bytesAvailable();return socket->bytesAvailable();Executed by: 
 executed 580 times by 2 tests:  return socket->bytesAvailable();Executed by: 
  | 580 | ||||||||||||||||||
| 318 | } | - | ||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | qint64 QFtpDTP::read(char *data, qint64 maxlen) | - | ||||||||||||||||||
| 321 | { | - | ||||||||||||||||||
| 322 | qint64 read; | - | ||||||||||||||||||
| 323 |     if (socket
 
  | 0 | ||||||||||||||||||
| 324 | read = socket->read(data, maxlen); | - | ||||||||||||||||||
| 325 |     } never executed:   else {end of block | 0 | ||||||||||||||||||
| 326 | read = qMin(maxlen, qint64(bytesFromSocket.size())); | - | ||||||||||||||||||
| 327 | memcpy(data, bytesFromSocket.data(), read); | - | ||||||||||||||||||
| 328 | bytesFromSocket.remove(0, read); | - | ||||||||||||||||||
| 329 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | bytesDone += read; | - | ||||||||||||||||||
| 332 |     return never executed:   read;return read;never executed:  return read; | 0 | ||||||||||||||||||
| 333 | } | - | ||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | QByteArray QFtpDTP::readAll() | - | ||||||||||||||||||
| 336 | { | - | ||||||||||||||||||
| 337 | QByteArray tmp; | - | ||||||||||||||||||
| 338 |     if (socket
 
  | 0-611 | ||||||||||||||||||
| 339 | tmp = socket->readAll(); | - | ||||||||||||||||||
| 340 | bytesDone += tmp.size(); | - | ||||||||||||||||||
| 341 |     } executed 587 times by 2 tests:   else {end of blockExecuted by: 
  | 587 | ||||||||||||||||||
| 342 | tmp = bytesFromSocket; | - | ||||||||||||||||||
| 343 | bytesFromSocket.clear(); | - | ||||||||||||||||||
| 344 |     } executed 24 times by 1 test:  end of blockExecuted by: 
  | 24 | ||||||||||||||||||
| 345 |     return executed 611 times by 2 tests:   tmp;return tmp;Executed by: 
 executed 611 times by 2 tests:  return tmp;Executed by: 
  | 611 | ||||||||||||||||||
| 346 | } | - | ||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | void QFtpDTP::writeData() | - | ||||||||||||||||||
| 349 | { | - | ||||||||||||||||||
| 350 |     if (!socket
  | 0-198 | ||||||||||||||||||
| 351 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 352 | - | |||||||||||||||||||
| 353 |     if (is_ba
  | 28-170 | ||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | - | |||||||||||||||||||
| 356 | - | |||||||||||||||||||
| 357 |         if (data.ba->size() == 0
  | 8-20 | ||||||||||||||||||
| 358 |             dataTransferProgress(0, bytesTotal); executed 20 times by 1 test:  dataTransferProgress(0, bytesTotal);Executed by: 
  | 20 | ||||||||||||||||||
| 359 | else | - | ||||||||||||||||||
| 360 |             socket->write(data.ba->data(), data.ba->size()); executed 8 times by 1 test:  socket->write(data.ba->data(), data.ba->size());Executed by: 
  | 8 | ||||||||||||||||||
| 361 | - | |||||||||||||||||||
| 362 | socket->close(); | - | ||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | clearData(); | - | ||||||||||||||||||
| 365 |     } executed 28 times by 1 test:   else if (data.devend of blockExecuted by: 
 
  | 0-170 | ||||||||||||||||||
| 366 | callWriteData = false; | - | ||||||||||||||||||
| 367 | const qint64 blockSize = 16*1024; | - | ||||||||||||||||||
| 368 | char buf[16*1024]; | - | ||||||||||||||||||
| 369 | qint64 read = data.dev->read(buf, blockSize); | - | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | - | |||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 |         if (read > 0
  | 15-155 | ||||||||||||||||||
| 374 | socket->write(buf, read); | - | ||||||||||||||||||
| 375 |         } executed 155 times by 2 tests:   else if (read == -1end of blockExecuted by: 
 
 
 
  | 0-155 | ||||||||||||||||||
| 376 | - | |||||||||||||||||||
| 377 |             if (bytesDone == 0
 
  | 0-13 | ||||||||||||||||||
| 378 |                 dataTransferProgress(0, bytesTotal); executed 2 times by 1 test:  dataTransferProgress(0, bytesTotal);Executed by: 
  | 2 | ||||||||||||||||||
| 379 | socket->close(); | - | ||||||||||||||||||
| 380 | clearData(); | - | ||||||||||||||||||
| 381 |         } executed 15 times by 2 tests:  end of blockExecuted by: 
  | 15 | ||||||||||||||||||
| 382 | - | |||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | callWriteData = data.dev != 0; | - | ||||||||||||||||||
| 385 |     } executed 170 times by 2 tests:  end of blockExecuted by: 
  | 170 | ||||||||||||||||||
| 386 | } executed 198 times by 2 tests:  end of blockExecuted by: 
  | 198 | ||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | void QFtpDTP::dataReadyRead() | - | ||||||||||||||||||
| 389 | { | - | ||||||||||||||||||
| 390 | writeData(); | - | ||||||||||||||||||
| 391 | } never executed:  end of block | 0 | ||||||||||||||||||
| 392 | - | |||||||||||||||||||
| 393 | inline bool QFtpDTP::hasError() const | - | ||||||||||||||||||
| 394 | { | - | ||||||||||||||||||
| 395 |     return executed 3282 times by 2 tests:   !err.isNull();return !err.isNull();Executed by: 
 executed 3282 times by 2 tests:  return !err.isNull();Executed by: 
  | 3282 | ||||||||||||||||||
| 396 | } | - | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | inline QString QFtpDTP::errorMessage() const | - | ||||||||||||||||||
| 399 | { | - | ||||||||||||||||||
| 400 |     return never executed:   err;return err;never executed:  return err; | 0 | ||||||||||||||||||
| 401 | } | - | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | inline void QFtpDTP::clearError() | - | ||||||||||||||||||
| 404 | { | - | ||||||||||||||||||
| 405 | err.clear(); | - | ||||||||||||||||||
| 406 | } never executed:  end of block | 0 | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | void QFtpDTP::abortConnection() | - | ||||||||||||||||||
| 409 | { | - | ||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | - | |||||||||||||||||||
| 413 | - | |||||||||||||||||||
| 414 | callWriteData = false; | - | ||||||||||||||||||
| 415 | clearData(); | - | ||||||||||||||||||
| 416 | - | |||||||||||||||||||
| 417 |     if (socket
  | 19-144 | ||||||||||||||||||
| 418 |         socket->abort(); executed 19 times by 2 tests:  socket->abort();Executed by: 
  | 19 | ||||||||||||||||||
| 419 | } executed 163 times by 2 tests:  end of blockExecuted by: 
  | 163 | ||||||||||||||||||
| 420 | - | |||||||||||||||||||
| 421 | static void _q_fixupDateTime(QDateTime *dateTime) | - | ||||||||||||||||||
| 422 | { | - | ||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | const int futureTolerance = 86400; | - | ||||||||||||||||||
| 425 |     if (dateTime->secsTo(QDateTime::currentDateTime()) < -futureTolerance
  | 0-116 | ||||||||||||||||||
| 426 | QDate d = dateTime->date(); | - | ||||||||||||||||||
| 427 | d.setDate(d.year() - 1, d.month(), d.day()); | - | ||||||||||||||||||
| 428 | dateTime->setDate(d); | - | ||||||||||||||||||
| 429 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 430 | } executed 116 times by 1 test:  end of blockExecuted by: 
  | 116 | ||||||||||||||||||
| 431 | - | |||||||||||||||||||
| 432 | static void _q_parseUnixDir(const QStringList &tokens, const QString &userName, QUrlInfo *info) | - | ||||||||||||||||||
| 433 | { | - | ||||||||||||||||||
| 434 | - | |||||||||||||||||||
| 435 | - | |||||||||||||||||||
| 436 | - | |||||||||||||||||||
| 437 | - | |||||||||||||||||||
| 438 |     if (tokens.size() != 8
  | 0-372 | ||||||||||||||||||
| 439 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 440 | - | |||||||||||||||||||
| 441 | char first = tokens.at(1).at(0).toLatin1(); | - | ||||||||||||||||||
| 442 |     if (first == 'd'
  | 156-216 | ||||||||||||||||||
| 443 | info->setDir(true); | - | ||||||||||||||||||
| 444 | info->setFile(false); | - | ||||||||||||||||||
| 445 | info->setSymLink(false); | - | ||||||||||||||||||
| 446 |     } executed 156 times by 1 test:   else if (first == '-'end of blockExecuted by: 
 
  | 0-216 | ||||||||||||||||||
| 447 | info->setDir(false); | - | ||||||||||||||||||
| 448 | info->setFile(true); | - | ||||||||||||||||||
| 449 | info->setSymLink(false); | - | ||||||||||||||||||
| 450 |     } executed 216 times by 1 test:   else if (first == 'l'end of blockExecuted by: 
 
  | 0-216 | ||||||||||||||||||
| 451 | info->setDir(true); | - | ||||||||||||||||||
| 452 | info->setFile(false); | - | ||||||||||||||||||
| 453 | info->setSymLink(true); | - | ||||||||||||||||||
| 454 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 455 | - | |||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | QString name = tokens.at(7); | - | ||||||||||||||||||
| 458 |     if (info->isSymLink()
  | 0-372 | ||||||||||||||||||
| 459 | int linkPos = name.indexOf(QLatin1String(" ->")); | - | ||||||||||||||||||
| 460 |         if (linkPos != -1
  | 0 | ||||||||||||||||||
| 461 |             name.resize(linkPos); never executed:  name.resize(linkPos); | 0 | ||||||||||||||||||
| 462 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 463 | info->setName(name); | - | ||||||||||||||||||
| 464 | - | |||||||||||||||||||
| 465 | - | |||||||||||||||||||
| 466 | info->setOwner(tokens.at(3)); | - | ||||||||||||||||||
| 467 | info->setGroup(tokens.at(4)); | - | ||||||||||||||||||
| 468 | - | |||||||||||||||||||
| 469 | - | |||||||||||||||||||
| 470 | info->setSize(tokens.at(5).toLongLong()); | - | ||||||||||||||||||
| 471 | - | |||||||||||||||||||
| 472 | QStringList formats; | - | ||||||||||||||||||
| 473 | formats << QLatin1String("MMM dd yyyy") << QLatin1String("MMM dd hh:mm") << QLatin1String("MMM d yyyy") | - | ||||||||||||||||||
| 474 | << QLatin1String("MMM d hh:mm") << QLatin1String("MMM d yyyy") << QLatin1String("MMM dd yyyy"); | - | ||||||||||||||||||
| 475 | - | |||||||||||||||||||
| 476 | QString dateString = tokens.at(6); | - | ||||||||||||||||||
| 477 | dateString[0] = dateString[0].toUpper(); | - | ||||||||||||||||||
| 478 | - | |||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | QDateTime dateTime; | - | ||||||||||||||||||
| 481 | int n = 0; | - | ||||||||||||||||||
| 482 | - | |||||||||||||||||||
| 483 | do { | - | ||||||||||||||||||
| 484 | dateTime = QLocale::c().toDateTime(dateString, formats.at(n++)); | - | ||||||||||||||||||
| 485 |     } executed 496 times by 1 test:   while (n < formats.size()end of blockExecuted by: 
 
 
 
  | 0-496 | ||||||||||||||||||
| 486 | - | |||||||||||||||||||
| 487 | - | |||||||||||||||||||
| 488 |     if (n == 2
 
  | 0-256 | ||||||||||||||||||
| 489 | - | |||||||||||||||||||
| 490 | dateTime.setDate(QDate(QDate::currentDate().year(), | - | ||||||||||||||||||
| 491 | dateTime.date().month(), | - | ||||||||||||||||||
| 492 | dateTime.date().day())); | - | ||||||||||||||||||
| 493 | _q_fixupDateTime(&dateTime); | - | ||||||||||||||||||
| 494 |     } executed 116 times by 1 test:  end of blockExecuted by: 
  | 116 | ||||||||||||||||||
| 495 |     if (dateTime.isValid()
  | 0-372 | ||||||||||||||||||
| 496 |         info->setLastModified(dateTime); executed 372 times by 1 test:  info->setLastModified(dateTime);Executed by: 
  | 372 | ||||||||||||||||||
| 497 | - | |||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | int permissions = 0; | - | ||||||||||||||||||
| 500 | const QString &p = tokens.at(2); | - | ||||||||||||||||||
| 501 |     permissions |= (p[0] == QLatin1Char('r')
  | 0-372 | ||||||||||||||||||
| 502 |     permissions |= (p[1] == QLatin1Char('w')
  | 0-372 | ||||||||||||||||||
| 503 |     permissions |= (p[2] == QLatin1Char('x')
  | 156-216 | ||||||||||||||||||
| 504 |     permissions |= (p[3] == QLatin1Char('r')
  | 0-372 | ||||||||||||||||||
| 505 |     permissions |= (p[4] == QLatin1Char('w')
  | 48-324 | ||||||||||||||||||
| 506 |     permissions |= (p[5] == QLatin1Char('x')
  | 156-216 | ||||||||||||||||||
| 507 |     permissions |= (p[6] == QLatin1Char('r')
  | 0-372 | ||||||||||||||||||
| 508 |     permissions |= (p[7] == QLatin1Char('w')
  | 48-324 | ||||||||||||||||||
| 509 |     permissions |= (p[8] == QLatin1Char('x')
  | 108-264 | ||||||||||||||||||
| 510 | info->setPermissions(permissions); | - | ||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | bool isOwner = info->owner() == userName; | - | ||||||||||||||||||
| 513 | info->setReadable((permissions & QUrlInfo::ReadOther) || ((permissions & QUrlInfo::ReadOwner) && isOwner)); | - | ||||||||||||||||||
| 514 | info->setWritable((permissions & QUrlInfo::WriteOther) || ((permissions & QUrlInfo::WriteOwner) && isOwner)); | - | ||||||||||||||||||
| 515 | } executed 372 times by 1 test:  end of blockExecuted by: 
  | 372 | ||||||||||||||||||
| 516 | - | |||||||||||||||||||
| 517 | static void _q_parseDosDir(const QStringList &tokens, const QString &userName, QUrlInfo *info) | - | ||||||||||||||||||
| 518 | { | - | ||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | - | |||||||||||||||||||
| 521 | - | |||||||||||||||||||
| 522 |     if (tokens.size() != 4
  | 0 | ||||||||||||||||||
| 523 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 524 | - | |||||||||||||||||||
| 525 | (void)userName;; | - | ||||||||||||||||||
| 526 | - | |||||||||||||||||||
| 527 | QString name = tokens.at(3); | - | ||||||||||||||||||
| 528 | info->setName(name); | - | ||||||||||||||||||
| 529 | info->setSymLink(name.toLower().endsWith(QLatin1String(".lnk"))); | - | ||||||||||||||||||
| 530 | - | |||||||||||||||||||
| 531 |     if (tokens.at(2) == QLatin1String("<DIR>")
  | 0 | ||||||||||||||||||
| 532 | info->setFile(false); | - | ||||||||||||||||||
| 533 | info->setDir(true); | - | ||||||||||||||||||
| 534 |     } never executed:   else {end of block | 0 | ||||||||||||||||||
| 535 | info->setFile(true); | - | ||||||||||||||||||
| 536 | info->setDir(false); | - | ||||||||||||||||||
| 537 | info->setSize(tokens.at(2).toLongLong()); | - | ||||||||||||||||||
| 538 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 539 | - | |||||||||||||||||||
| 540 | - | |||||||||||||||||||
| 541 | - | |||||||||||||||||||
| 542 | int permissions = QUrlInfo::ReadOwner | QUrlInfo::WriteOwner | - | ||||||||||||||||||
| 543 | | QUrlInfo::ReadGroup | QUrlInfo::WriteGroup | - | ||||||||||||||||||
| 544 | | QUrlInfo::ReadOther | QUrlInfo::WriteOther; | - | ||||||||||||||||||
| 545 | QStringRef ext; | - | ||||||||||||||||||
| 546 | int extIndex = name.lastIndexOf(QLatin1Char('.')); | - | ||||||||||||||||||
| 547 |     if (extIndex != -1
  | 0 | ||||||||||||||||||
| 548 |         ext = name.midRef(extIndex + 1); never executed:  ext = name.midRef(extIndex + 1); | 0 | ||||||||||||||||||
| 549 |     if (ext == QLatin1String("exe")
 
 
  | 0 | ||||||||||||||||||
| 550 |         permissions |= QUrlInfo::ExeOwner | QUrlInfo::ExeGroup | QUrlInfo::ExeOther; never executed:  permissions |= QUrlInfo::ExeOwner | QUrlInfo::ExeGroup | QUrlInfo::ExeOther; | 0 | ||||||||||||||||||
| 551 | info->setPermissions(permissions); | - | ||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 | info->setReadable(true); | - | ||||||||||||||||||
| 554 | info->setWritable(info->isFile()); | - | ||||||||||||||||||
| 555 | - | |||||||||||||||||||
| 556 | QDateTime dateTime; | - | ||||||||||||||||||
| 557 | - | |||||||||||||||||||
| 558 | dateTime = QLocale::c().toDateTime(tokens.at(1), QLatin1String("MM-dd-yy hh:mmAP")); | - | ||||||||||||||||||
| 559 |     if (dateTime.date().year() < 1971
  | 0 | ||||||||||||||||||
| 560 | dateTime.setDate(QDate(dateTime.date().year() + 100, | - | ||||||||||||||||||
| 561 | dateTime.date().month(), | - | ||||||||||||||||||
| 562 | dateTime.date().day())); | - | ||||||||||||||||||
| 563 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 564 | - | |||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | info->setLastModified(dateTime); | - | ||||||||||||||||||
| 567 | - | |||||||||||||||||||
| 568 | } never executed:  end of block | 0 | ||||||||||||||||||
| 569 | - | |||||||||||||||||||
| 570 | bool QFtpDTP::parseDir(const QByteArray &buffer, const QString &userName, QUrlInfo *info) | - | ||||||||||||||||||
| 571 | { | - | ||||||||||||||||||
| 572 |     if (buffer.isEmpty()
  | 0-374 | ||||||||||||||||||
| 573 |         return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 574 | - | |||||||||||||||||||
| 575 | QString bufferStr = QString::fromUtf8(buffer).trimmed(); | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | - | |||||||||||||||||||
| 578 | QRegExp unixPattern(QLatin1String("^([\\-dl])([a-zA-Z\\-]{9,9})\\s+\\d+\\s+(\\S*)\\s+" | - | ||||||||||||||||||
| 579 | "(\\S*)\\s+(\\d+)\\s+(\\S+\\s+\\S+\\s+\\S+)\\s+(\\S.*)")); | - | ||||||||||||||||||
| 580 |     if (unixPattern.indexIn(bufferStr) == 0
  | 2-372 | ||||||||||||||||||
| 581 | _q_parseUnixDir(unixPattern.capturedTexts(), userName, info); | - | ||||||||||||||||||
| 582 |         return executed 372 times by 1 test:   true;return true;Executed by: 
 executed 372 times by 1 test:  return true;Executed by: 
  | 372 | ||||||||||||||||||
| 583 | } | - | ||||||||||||||||||
| 584 | - | |||||||||||||||||||
| 585 | - | |||||||||||||||||||
| 586 | QRegExp dosPattern(QLatin1String("^(\\d\\d-\\d\\d-\\d\\d\\ \\ \\d\\d:\\d\\d[AP]M)\\s+" | - | ||||||||||||||||||
| 587 | "(<DIR>|\\d+)\\s+(\\S.*)$")); | - | ||||||||||||||||||
| 588 |     if (dosPattern.indexIn(bufferStr) == 0
  | 0-2 | ||||||||||||||||||
| 589 | _q_parseDosDir(dosPattern.capturedTexts(), userName, info); | - | ||||||||||||||||||
| 590 |         return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||
| 591 | } | - | ||||||||||||||||||
| 592 | - | |||||||||||||||||||
| 593 | - | |||||||||||||||||||
| 594 |     return executed 2 times by 1 test:   false;return false;Executed by: 
 executed 2 times by 1 test:  return false;Executed by: 
  | 2 | ||||||||||||||||||
| 595 | } | - | ||||||||||||||||||
| 596 | - | |||||||||||||||||||
| 597 | void QFtpDTP::socketConnected() | - | ||||||||||||||||||
| 598 | { | - | ||||||||||||||||||
| 599 | bytesDone = 0; | - | ||||||||||||||||||
| 600 | - | |||||||||||||||||||
| 601 | - | |||||||||||||||||||
| 602 | - | |||||||||||||||||||
| 603 | connectState(QFtpDTP::CsConnected); | - | ||||||||||||||||||
| 604 | } executed 355 times by 2 tests:  end of blockExecuted by: 
  | 355 | ||||||||||||||||||
| 605 | - | |||||||||||||||||||
| 606 | void QFtpDTP::socketReadyRead() | - | ||||||||||||||||||
| 607 | { | - | ||||||||||||||||||
| 608 |     if (!socket
  | 0-1579 | ||||||||||||||||||
| 609 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 610 | - | |||||||||||||||||||
| 611 |     if (pi->currentCommand().isEmpty()
  | 0-1579 | ||||||||||||||||||
| 612 | socket->close(); | - | ||||||||||||||||||
| 613 | - | |||||||||||||||||||
| 614 | - | |||||||||||||||||||
| 615 | - | |||||||||||||||||||
| 616 | connectState(QFtpDTP::CsClosed); | - | ||||||||||||||||||
| 617 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 618 | } | - | ||||||||||||||||||
| 619 | - | |||||||||||||||||||
| 620 |     if (pi->abortState != QFtpPI::None
  | 0-1579 | ||||||||||||||||||
| 621 | - | |||||||||||||||||||
| 622 | socket->readAll(); | - | ||||||||||||||||||
| 623 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 624 | } | - | ||||||||||||||||||
| 625 | - | |||||||||||||||||||
| 626 |     if (pi->currentCommand().startsWith(QLatin1String("LIST"))
  | 142-1437 | ||||||||||||||||||
| 627 |         while (socket->canReadLine()
  | 142-374 | ||||||||||||||||||
| 628 | QUrlInfo i; | - | ||||||||||||||||||
| 629 | QByteArray line = socket->readLine(); | - | ||||||||||||||||||
| 630 | - | |||||||||||||||||||
| 631 | - | |||||||||||||||||||
| 632 | - | |||||||||||||||||||
| 633 |             if (parseDir(line, QLatin1String(""), &i)
  | 2-372 | ||||||||||||||||||
| 634 | listInfo(i); | - | ||||||||||||||||||
| 635 |             } executed 372 times by 1 test:   else {end of blockExecuted by: 
  | 372 | ||||||||||||||||||
| 636 | - | |||||||||||||||||||
| 637 | - | |||||||||||||||||||
| 638 | - | |||||||||||||||||||
| 639 |                 if (line.endsWith("No such file or directory\r\n")
  | 0-2 | ||||||||||||||||||
| 640 |                     err = QString::fromUtf8(line); never executed:  err = QString::fromUtf8(line); | 0 | ||||||||||||||||||
| 641 |             } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||
| 642 | } | - | ||||||||||||||||||
| 643 |     } executed 142 times by 1 test:   else {end of blockExecuted by: 
  | 142 | ||||||||||||||||||
| 644 |         if (!is_ba
 
  | 0-1437 | ||||||||||||||||||
| 645 | do { | - | ||||||||||||||||||
| 646 | QByteArray ba; | - | ||||||||||||||||||
| 647 | ba.resize(socket->bytesAvailable()); | - | ||||||||||||||||||
| 648 | qint64 bytesRead = socket->read(ba.data(), ba.size()); | - | ||||||||||||||||||
| 649 |                 if (bytesRead < 0
  | 0-236 | ||||||||||||||||||
| 650 | - | |||||||||||||||||||
| 651 | - | |||||||||||||||||||
| 652 |                     return; never executed:  return; | 0 | ||||||||||||||||||
| 653 | } | - | ||||||||||||||||||
| 654 | ba.resize(bytesRead); | - | ||||||||||||||||||
| 655 | bytesDone += bytesRead; | - | ||||||||||||||||||
| 656 | - | |||||||||||||||||||
| 657 | - | |||||||||||||||||||
| 658 | - | |||||||||||||||||||
| 659 |                 if (data.dev
  | 0-236 | ||||||||||||||||||
| 660 |                     data.dev->write(ba); executed 236 times by 1 test:  data.dev->write(ba);Executed by: 
  | 236 | ||||||||||||||||||
| 661 | dataTransferProgress(bytesDone, bytesTotal); | - | ||||||||||||||||||
| 662 | - | |||||||||||||||||||
| 663 | - | |||||||||||||||||||
| 664 | - | |||||||||||||||||||
| 665 | - | |||||||||||||||||||
| 666 |             } executed 236 times by 1 test:   while (socket->bytesAvailable()end of blockExecuted by: 
 
  | 0-236 | ||||||||||||||||||
| 667 |         } executed 236 times by 1 test:   else {end of blockExecuted by: 
  | 236 | ||||||||||||||||||
| 668 | - | |||||||||||||||||||
| 669 | - | |||||||||||||||||||
| 670 | - | |||||||||||||||||||
| 671 | - | |||||||||||||||||||
| 672 | dataTransferProgress(bytesDone+socket->bytesAvailable(), bytesTotal); | - | ||||||||||||||||||
| 673 | readyRead(); | - | ||||||||||||||||||
| 674 |         } executed 1201 times by 2 tests:  end of blockExecuted by: 
  | 1201 | ||||||||||||||||||
| 675 | } | - | ||||||||||||||||||
| 676 | } | - | ||||||||||||||||||
| 677 | - | |||||||||||||||||||
| 678 | void QFtpDTP::socketError(QAbstractSocket::SocketError e) | - | ||||||||||||||||||
| 679 | { | - | ||||||||||||||||||
| 680 |     if (e == QTcpSocket::HostNotFoundError
  | 0-301 | ||||||||||||||||||
| 681 | - | |||||||||||||||||||
| 682 | - | |||||||||||||||||||
| 683 | - | |||||||||||||||||||
| 684 | connectState(QFtpDTP::CsHostNotFound); | - | ||||||||||||||||||
| 685 |     } never executed:   else if (e == QTcpSocket::ConnectionRefusedErrorend of block
  | 0-301 | ||||||||||||||||||
| 686 | - | |||||||||||||||||||
| 687 | - | |||||||||||||||||||
| 688 | - | |||||||||||||||||||
| 689 | connectState(QFtpDTP::CsConnectionRefused); | - | ||||||||||||||||||
| 690 |     } never executed:  end of block | 0 | ||||||||||||||||||
| 691 | } executed 301 times by 2 tests:  end of blockExecuted by: 
  | 301 | ||||||||||||||||||
| 692 | - | |||||||||||||||||||
| 693 | void QFtpDTP::socketConnectionClosed() | - | ||||||||||||||||||
| 694 | { | - | ||||||||||||||||||
| 695 |     if (!is_ba
 
  | 20-343 | ||||||||||||||||||
| 696 | clearData(); | - | ||||||||||||||||||
| 697 |     } executed 47 times by 2 tests:  end of blockExecuted by: 
  | 47 | ||||||||||||||||||
| 698 | - | |||||||||||||||||||
| 699 |     if (socket->isOpen()
  | 62-301 | ||||||||||||||||||
| 700 |         bytesFromSocket = socket->readAll(); executed 301 times by 2 tests:  bytesFromSocket = socket->readAll();Executed by: 
  | 301 | ||||||||||||||||||
| 701 | else | - | ||||||||||||||||||
| 702 |         bytesFromSocket.clear(); executed 62 times by 2 tests:  bytesFromSocket.clear();Executed by: 
  | 62 | ||||||||||||||||||
| 703 | - | |||||||||||||||||||
| 704 | - | |||||||||||||||||||
| 705 | - | |||||||||||||||||||
| 706 | connectState(QFtpDTP::CsClosed); | - | ||||||||||||||||||
| 707 | } executed 363 times by 2 tests:  end of blockExecuted by: 
  | 363 | ||||||||||||||||||
| 708 | - | |||||||||||||||||||
| 709 | void QFtpDTP::socketBytesWritten(qint64 bytes) | - | ||||||||||||||||||
| 710 | { | - | ||||||||||||||||||
| 711 | bytesDone += bytes; | - | ||||||||||||||||||
| 712 | - | |||||||||||||||||||
| 713 | - | |||||||||||||||||||
| 714 | - | |||||||||||||||||||
| 715 | dataTransferProgress(bytesDone, bytesTotal); | - | ||||||||||||||||||
| 716 |     if (callWriteData
  | 8-155 | ||||||||||||||||||
| 717 |         writeData(); executed 155 times by 2 tests:  writeData();Executed by: 
  | 155 | ||||||||||||||||||
| 718 | } executed 163 times by 2 tests:  end of blockExecuted by: 
  | 163 | ||||||||||||||||||
| 719 | - | |||||||||||||||||||
| 720 | void QFtpDTP::setupSocket() | - | ||||||||||||||||||
| 721 | { | - | ||||||||||||||||||
| 722 | socket = listener.nextPendingConnection(); | - | ||||||||||||||||||
| 723 | socket->setObjectName(QLatin1String("QFtpDTP Active state socket")); | - | ||||||||||||||||||
| 724 | connect(socket, qFlagLocation("2""connected()" "\0" __FILE__ ":" "769"), qFlagLocation("1""socketConnected()" "\0" __FILE__ ":" "769")); | - | ||||||||||||||||||
| 725 | connect(socket, qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "770"), qFlagLocation("1""socketReadyRead()" "\0" __FILE__ ":" "770")); | - | ||||||||||||||||||
| 726 | connect(socket, qFlagLocation("2""error(QAbstractSocket::SocketError)" "\0" __FILE__ ":" "771"), qFlagLocation("1""socketError(QAbstractSocket::SocketError)" "\0" __FILE__ ":" "771")); | - | ||||||||||||||||||
| 727 | connect(socket, qFlagLocation("2""disconnected()" "\0" __FILE__ ":" "772"), qFlagLocation("1""socketConnectionClosed()" "\0" __FILE__ ":" "772")); | - | ||||||||||||||||||
| 728 | connect(socket, qFlagLocation("2""bytesWritten(qint64)" "\0" __FILE__ ":" "773"), qFlagLocation("1""socketBytesWritten(qint64)" "\0" __FILE__ ":" "773")); | - | ||||||||||||||||||
| 729 | - | |||||||||||||||||||
| 730 | listener.close(); | - | ||||||||||||||||||
| 731 | } executed 8 times by 1 test:  end of blockExecuted by: 
  | 8 | ||||||||||||||||||
| 732 | - | |||||||||||||||||||
| 733 | void QFtpDTP::clearData() | - | ||||||||||||||||||
| 734 | { | - | ||||||||||||||||||
| 735 | is_ba = false; | - | ||||||||||||||||||
| 736 | data.dev = 0; | - | ||||||||||||||||||
| 737 | } executed 914 times by 2 tests:  end of blockExecuted by: 
  | 914 | ||||||||||||||||||
| 738 | - | |||||||||||||||||||
| 739 | - | |||||||||||||||||||
| 740 | - | |||||||||||||||||||
| 741 | - | |||||||||||||||||||
| 742 | - | |||||||||||||||||||
| 743 | - | |||||||||||||||||||
| 744 | QFtpPI::QFtpPI(QObject *parent) : | - | ||||||||||||||||||
| 745 | QObject(parent), | - | ||||||||||||||||||
| 746 | rawCommand(false), | - | ||||||||||||||||||
| 747 | transferConnectionExtended(true), | - | ||||||||||||||||||
| 748 | dtp(this), | - | ||||||||||||||||||
| 749 | commandSocket(0), | - | ||||||||||||||||||
| 750 | state(Begin), abortState(None), | - | ||||||||||||||||||
| 751 | currentCmd(QString()), | - | ||||||||||||||||||
| 752 | waitForDtpToConnect(false), | - | ||||||||||||||||||
| 753 | waitForDtpToClose(false) | - | ||||||||||||||||||
| 754 | { | - | ||||||||||||||||||
| 755 | commandSocket.setObjectName(QLatin1String("QFtpPI_socket")); | - | ||||||||||||||||||
| 756 | connect(&commandSocket, qFlagLocation("2""hostFound()" "\0" __FILE__ ":" "801"), | - | ||||||||||||||||||
| 757 | qFlagLocation("1""hostFound()" "\0" __FILE__ ":" "802")); | - | ||||||||||||||||||
| 758 | connect(&commandSocket, qFlagLocation("2""connected()" "\0" __FILE__ ":" "803"), | - | ||||||||||||||||||
| 759 | qFlagLocation("1""connected()" "\0" __FILE__ ":" "804")); | - | ||||||||||||||||||
| 760 | connect(&commandSocket, qFlagLocation("2""disconnected()" "\0" __FILE__ ":" "805"), | - | ||||||||||||||||||
| 761 | qFlagLocation("1""connectionClosed()" "\0" __FILE__ ":" "806")); | - | ||||||||||||||||||
| 762 | connect(&commandSocket, qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "807"), | - | ||||||||||||||||||
| 763 | qFlagLocation("1""readyRead()" "\0" __FILE__ ":" "808")); | - | ||||||||||||||||||
| 764 | connect(&commandSocket, qFlagLocation("2""error(QAbstractSocket::SocketError)" "\0" __FILE__ ":" "809"), | - | ||||||||||||||||||
| 765 | qFlagLocation("1""error(QAbstractSocket::SocketError)" "\0" __FILE__ ":" "810")); | - | ||||||||||||||||||
| 766 | - | |||||||||||||||||||
| 767 | connect(&dtp, qFlagLocation("2""connectState(int)" "\0" __FILE__ ":" "812"), | - | ||||||||||||||||||
| 768 | qFlagLocation("1""dtpConnectState(int)" "\0" __FILE__ ":" "813")); | - | ||||||||||||||||||
| 769 | } executed 661 times by 2 tests:  end of blockExecuted by: 
  | 661 | ||||||||||||||||||
| 770 | - | |||||||||||||||||||
| 771 | void QFtpPI::connectToHost(const QString &host, quint16 port) | - | ||||||||||||||||||
| 772 | { | - | ||||||||||||||||||
| 773 | connectState(QFtp::HostLookup); | - | ||||||||||||||||||
| 774 | - | |||||||||||||||||||
| 775 | - | |||||||||||||||||||
| 776 | commandSocket.setProperty("_q_networksession", property("_q_networksession")); | - | ||||||||||||||||||
| 777 | dtp.setProperty("_q_networksession", property("_q_networksession")); | - | ||||||||||||||||||
| 778 | - | |||||||||||||||||||
| 779 | commandSocket.connectToHost(host, port); | - | ||||||||||||||||||
| 780 | } executed 657 times by 2 tests:  end of blockExecuted by: 
  | 657 | ||||||||||||||||||
| 781 | bool QFtpPI::sendCommands(const QStringList &cmds) | - | ||||||||||||||||||
| 782 | { | - | ||||||||||||||||||
| 783 |     if (!pendingCommands.isEmpty()
  | 0-1956 | ||||||||||||||||||
| 784 |         return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 785 | - | |||||||||||||||||||
| 786 |     if (commandSocket.state() != QTcpSocket::ConnectedState
 
  | 0-1935 | ||||||||||||||||||
| 787 | error(QFtp::NotConnected, QFtp::tr("Not connected")); | - | ||||||||||||||||||
| 788 |         return executed 21 times by 2 tests:   true;return true;Executed by: 
 executed 21 times by 2 tests:  return true;Executed by: 
  | 21 | ||||||||||||||||||
| 789 | } | - | ||||||||||||||||||
| 790 | - | |||||||||||||||||||
| 791 | pendingCommands = cmds; | - | ||||||||||||||||||
| 792 | startNextCmd(); | - | ||||||||||||||||||
| 793 |     return executed 1935 times by 2 tests:   true;return true;Executed by: 
 executed 1935 times by 2 tests:  return true;Executed by: 
  | 1935 | ||||||||||||||||||
| 794 | } | - | ||||||||||||||||||
| 795 | - | |||||||||||||||||||
| 796 | void QFtpPI::clearPendingCommands() | - | ||||||||||||||||||
| 797 | { | - | ||||||||||||||||||
| 798 | pendingCommands.clear(); | - | ||||||||||||||||||
| 799 | dtp.abortConnection(); | - | ||||||||||||||||||
| 800 | currentCmd.clear(); | - | ||||||||||||||||||
| 801 | state = Idle; | - | ||||||||||||||||||
| 802 | } executed 161 times by 2 tests:  end of blockExecuted by: 
  | 161 | ||||||||||||||||||
| 803 | - | |||||||||||||||||||
| 804 | void QFtpPI::abort() | - | ||||||||||||||||||
| 805 | { | - | ||||||||||||||||||
| 806 | pendingCommands.clear(); | - | ||||||||||||||||||
| 807 | - | |||||||||||||||||||
| 808 |     if (abortState != None
  | 0-4 | ||||||||||||||||||
| 809 | - | |||||||||||||||||||
| 810 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 811 | - | |||||||||||||||||||
| 812 |     if (currentCmd.isEmpty()
  | 2 | ||||||||||||||||||
| 813 |         return; executed 2 times by 1 test:  return;Executed by: 
  | 2 | ||||||||||||||||||
| 814 | - | |||||||||||||||||||
| 815 |     if (currentCmd.startsWith(QLatin1String("STOR "))
  | 0-2 | ||||||||||||||||||
| 816 | abortState = AbortStarted; | - | ||||||||||||||||||
| 817 | - | |||||||||||||||||||
| 818 | - | |||||||||||||||||||
| 819 | - | |||||||||||||||||||
| 820 | commandSocket.write("ABOR\r\n", 6); | - | ||||||||||||||||||
| 821 | - | |||||||||||||||||||
| 822 | dtp.abortConnection(); | - | ||||||||||||||||||
| 823 |     } never executed:   else {end of block | 0 | ||||||||||||||||||
| 824 | - | |||||||||||||||||||
| 825 | - | |||||||||||||||||||
| 826 | - | |||||||||||||||||||
| 827 | - | |||||||||||||||||||
| 828 | abortState = WaitForAbortToFinish; | - | ||||||||||||||||||
| 829 | dtp.abortConnection(); | - | ||||||||||||||||||
| 830 |     } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||||||||
| 831 | } | - | ||||||||||||||||||
| 832 | - | |||||||||||||||||||
| 833 | void QFtpPI::hostFound() | - | ||||||||||||||||||
| 834 | { | - | ||||||||||||||||||
| 835 | connectState(QFtp::Connecting); | - | ||||||||||||||||||
| 836 | } executed 354 times by 2 tests:  end of blockExecuted by: 
  | 354 | ||||||||||||||||||
| 837 | - | |||||||||||||||||||
| 838 | void QFtpPI::connected() | - | ||||||||||||||||||
| 839 | { | - | ||||||||||||||||||
| 840 | state = Begin; | - | ||||||||||||||||||
| 841 | - | |||||||||||||||||||
| 842 | - | |||||||||||||||||||
| 843 | - | |||||||||||||||||||
| 844 | - | |||||||||||||||||||
| 845 | commandSocket.setSocketOption(QAbstractSocket::LowDelayOption, 1); | - | ||||||||||||||||||
| 846 | - | |||||||||||||||||||
| 847 | connectState(QFtp::Connected); | - | ||||||||||||||||||
| 848 | } executed 637 times by 2 tests:  end of blockExecuted by: 
  | 637 | ||||||||||||||||||
| 849 | - | |||||||||||||||||||
| 850 | void QFtpPI::connectionClosed() | - | ||||||||||||||||||
| 851 | { | - | ||||||||||||||||||
| 852 | commandSocket.close(); | - | ||||||||||||||||||
| 853 | connectState(QFtp::Unconnected); | - | ||||||||||||||||||
| 854 | } executed 635 times by 2 tests:  end of blockExecuted by: 
  | 635 | ||||||||||||||||||
| 855 | - | |||||||||||||||||||
| 856 | void QFtpPI::delayedCloseFinished() | - | ||||||||||||||||||
| 857 | { | - | ||||||||||||||||||
| 858 | connectState(QFtp::Unconnected); | - | ||||||||||||||||||
| 859 | } never executed:  end of block | 0 | ||||||||||||||||||
| 860 | - | |||||||||||||||||||
| 861 | void QFtpPI::error(QAbstractSocket::SocketError e) | - | ||||||||||||||||||
| 862 | { | - | ||||||||||||||||||
| 863 |     if (e == QTcpSocket::HostNotFoundError
  | 7-482 | ||||||||||||||||||
| 864 | connectState(QFtp::Unconnected); | - | ||||||||||||||||||
| 865 | error(QFtp::HostNotFound, | - | ||||||||||||||||||
| 866 | QFtp::tr("Host %1 not found").arg(commandSocket.peerName())); | - | ||||||||||||||||||
| 867 |     } executed 7 times by 2 tests:   else if (e == QTcpSocket::ConnectionRefusedErrorend of blockExecuted by: 
 
  | 7-470 | ||||||||||||||||||
| 868 | connectState(QFtp::Unconnected); | - | ||||||||||||||||||
| 869 | error(QFtp::ConnectionRefused, | - | ||||||||||||||||||
| 870 | QFtp::tr("Connection refused to host %1").arg(commandSocket.peerName())); | - | ||||||||||||||||||
| 871 |     } executed 12 times by 1 test:   else if (e == QTcpSocket::SocketTimeoutErrorend of blockExecuted by: 
 
  | 1-469 | ||||||||||||||||||
| 872 | connectState(QFtp::Unconnected); | - | ||||||||||||||||||
| 873 | error(QFtp::ConnectionRefused, | - | ||||||||||||||||||
| 874 | QFtp::tr("Connection timed out to host %1").arg(commandSocket.peerName())); | - | ||||||||||||||||||
| 875 |     } executed 1 time by 1 test:  end of blockExecuted by: 
  | 1 | ||||||||||||||||||
| 876 | } executed 489 times by 2 tests:  end of blockExecuted by: 
  | 489 | ||||||||||||||||||
| 877 | - | |||||||||||||||||||
| 878 | void QFtpPI::readyRead() | - | ||||||||||||||||||
| 879 | { | - | ||||||||||||||||||
| 880 |     if (waitForDtpToClose
  | 0-4900 | ||||||||||||||||||
| 881 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 882 | - | |||||||||||||||||||
| 883 |     while (commandSocket.canReadLine()
  | 4537-4801 | ||||||||||||||||||
| 884 | - | |||||||||||||||||||
| 885 | QString line = QString::fromUtf8(commandSocket.readLine()); | - | ||||||||||||||||||
| 886 |         if (replyText.isEmpty()
  | 99-4438 | ||||||||||||||||||
| 887 |             if (line.length() < 3
  | 0-4438 | ||||||||||||||||||
| 888 | - | |||||||||||||||||||
| 889 |                 return; never executed:  return; | 0 | ||||||||||||||||||
| 890 | } | - | ||||||||||||||||||
| 891 | const int lowerLimit[3] = {1,0,0}; | - | ||||||||||||||||||
| 892 | const int upperLimit[3] = {5,5,9}; | - | ||||||||||||||||||
| 893 |             for (int i=0; i<3
  | 4438-13314 | ||||||||||||||||||
| 894 | replyCode[i] = line.at(i).digitValue(); | - | ||||||||||||||||||
| 895 |                 if (replyCode[i]<lowerLimit[i]
 
  | 0-13314 | ||||||||||||||||||
| 896 | - | |||||||||||||||||||
| 897 |                     return; never executed:  return; | 0 | ||||||||||||||||||
| 898 | } | - | ||||||||||||||||||
| 899 |             } executed 13314 times by 2 tests:  end of blockExecuted by: 
  | 13314 | ||||||||||||||||||
| 900 |         } executed 4438 times by 2 tests:  end of blockExecuted by: 
  | 4438 | ||||||||||||||||||
| 901 | QString endOfMultiLine; | - | ||||||||||||||||||
| 902 | endOfMultiLine[0] = '0' + replyCode[0]; | - | ||||||||||||||||||
| 903 | endOfMultiLine[1] = '0' + replyCode[1]; | - | ||||||||||||||||||
| 904 | endOfMultiLine[2] = '0' + replyCode[2]; | - | ||||||||||||||||||
| 905 | endOfMultiLine[3] = QLatin1Char(' '); | - | ||||||||||||||||||
| 906 | QString lineCont(endOfMultiLine); | - | ||||||||||||||||||
| 907 | lineCont[3] = QLatin1Char('-'); | - | ||||||||||||||||||
| 908 | QStringRef lineLeft4 = line.leftRef(4); | - | ||||||||||||||||||
| 909 | - | |||||||||||||||||||
| 910 |         while (lineLeft4 != endOfMultiLine
  | 242-4438 | ||||||||||||||||||
| 911 |             if (lineLeft4 == lineCont
  | 106-136 | ||||||||||||||||||
| 912 |                 replyText += line.midRef(4); executed 106 times by 2 tests:  replyText += line.midRef(4);Executed by: 
  | 106 | ||||||||||||||||||
| 913 | else | - | ||||||||||||||||||
| 914 |                 replyText += line; executed 136 times by 1 test:  replyText += line;Executed by: 
  | 136 | ||||||||||||||||||
| 915 |             if (!commandSocket.canReadLine()
  | 99-143 | ||||||||||||||||||
| 916 |                 return; executed 99 times by 1 test:  return;Executed by: 
  | 99 | ||||||||||||||||||
| 917 | line = QString::fromUtf8(commandSocket.readLine()); | - | ||||||||||||||||||
| 918 | lineLeft4 = line.leftRef(4); | - | ||||||||||||||||||
| 919 |         } executed 143 times by 2 tests:  end of blockExecuted by: 
  | 143 | ||||||||||||||||||
| 920 | replyText += line.midRef(4); | - | ||||||||||||||||||
| 921 |         if (replyText.endsWith(QLatin1String("\r\n"))
  | 0-4438 | ||||||||||||||||||
| 922 |             replyText.chop(2); executed 4438 times by 2 tests:  replyText.chop(2);Executed by: 
  | 4438 | ||||||||||||||||||
| 923 | - | |||||||||||||||||||
| 924 |         if (processReply()
  | 2-4436 | ||||||||||||||||||
| 925 |             replyText = QLatin1String(""); executed 4436 times by 2 tests:  replyText = QLatin1String("");Executed by: 
  | 4436 | ||||||||||||||||||
| 926 |     } executed 4438 times by 2 tests:  end of blockExecuted by: 
  | 4438 | ||||||||||||||||||
| 927 | } executed 4801 times by 2 tests:  end of blockExecuted by: 
  | 4801 | ||||||||||||||||||
| 928 | bool QFtpPI::processReply() | - | ||||||||||||||||||
| 929 | { | - | ||||||||||||||||||
| 930 | int replyCodeInt = 100*replyCode[0] + 10*replyCode[1] + replyCode[2]; | - | ||||||||||||||||||
| 931 | - | |||||||||||||||||||
| 932 | - | |||||||||||||||||||
| 933 | - | |||||||||||||||||||
| 934 |     if (replyCodeInt == 226
 
 
  | 0-4094 | ||||||||||||||||||
| 935 |         if (dtp.state() != QTcpSocket::UnconnectedState
  | 2-344 | ||||||||||||||||||
| 936 | waitForDtpToClose = true; | - | ||||||||||||||||||
| 937 |             return executed 2 times by 1 test:   false;return false;Executed by: 
 executed 2 times by 1 test:  return false;Executed by: 
  | 2 | ||||||||||||||||||
| 938 | } | - | ||||||||||||||||||
| 939 |     } executed 344 times by 2 tests:  end of blockExecuted by: 
  | 344 | ||||||||||||||||||
| 940 | - | |||||||||||||||||||
| 941 | switch (abortState) { | - | ||||||||||||||||||
| 942 |         case never executed:   AbortStarted:case AbortStarted:never executed:  case AbortStarted: | 0 | ||||||||||||||||||
| 943 | abortState = WaitForAbortToFinish; | - | ||||||||||||||||||
| 944 |             break; never executed:  break; | 0 | ||||||||||||||||||
| 945 |         case executed 2 times by 1 test:   WaitForAbortToFinish:case WaitForAbortToFinish:Executed by: 
 executed 2 times by 1 test:  case WaitForAbortToFinish:Executed by: 
  | 2 | ||||||||||||||||||
| 946 | abortState = None; | - | ||||||||||||||||||
| 947 |             return executed 2 times by 1 test:   true;return true;Executed by: 
 executed 2 times by 1 test:  return true;Executed by: 
  | 2 | ||||||||||||||||||
| 948 |         default executed 4436 times by 2 tests:  :default:Executed by: 
 executed 4436 times by 2 tests:  default:Executed by: 
  | 4436 | ||||||||||||||||||
| 949 |             break; executed 4436 times by 2 tests:  break;Executed by: 
  | 4436 | ||||||||||||||||||
| 950 | } | - | ||||||||||||||||||
| 951 | - | |||||||||||||||||||
| 952 | - | |||||||||||||||||||
| 953 | static const State table[5] = { | - | ||||||||||||||||||
| 954 | - | |||||||||||||||||||
| 955 | Waiting, Success, Idle, Failure, Failure | - | ||||||||||||||||||
| 956 | }; | - | ||||||||||||||||||
| 957 | switch (state) { | - | ||||||||||||||||||
| 958 |         case executed 637 times by 2 tests:   Begin:case Begin:Executed by: 
 executed 637 times by 2 tests:  case Begin:Executed by: 
  | 637 | ||||||||||||||||||
| 959 |             if (replyCode[0] == 1
  | 0-637 | ||||||||||||||||||
| 960 |                 return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||
| 961 |             } else if (replyCode[0] == 2
  | 0-637 | ||||||||||||||||||
| 962 | state = Idle; | - | ||||||||||||||||||
| 963 | finished(QFtp::tr("Connected to host %1").arg(commandSocket.peerName())); | - | ||||||||||||||||||
| 964 |                 break; executed 637 times by 2 tests:  break;Executed by: 
  | 637 | ||||||||||||||||||
| 965 | } | - | ||||||||||||||||||
| 966 | - | |||||||||||||||||||
| 967 |             return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||
| 968 |         case executed 3799 times by 2 tests:   Waiting:case Waiting:Executed by: 
 executed 3799 times by 2 tests:  case Waiting:Executed by: 
  | 3799 | ||||||||||||||||||
| 969 |             if (static_cast<
 
 
  | 0-3799 | ||||||||||||||||||
| 970 |                 state = Failure; never executed:  state = Failure; | 0 | ||||||||||||||||||
| 971 | else | - | ||||||||||||||||||
| 972 |             if (replyCodeInt == 202
  | 43-3756 | ||||||||||||||||||
| 973 |                 state = Failure; executed 43 times by 2 tests:  state = Failure;Executed by: 
  | 43 | ||||||||||||||||||
| 974 | else | - | ||||||||||||||||||
| 975 |                 state = table[replyCode[0] - 1]; executed 3756 times by 2 tests:  state = table[replyCode[0] - 1];Executed by: 
  | 3756 | ||||||||||||||||||
| 976 |             break; executed 3799 times by 2 tests:  break;Executed by: 
  | 3799 | ||||||||||||||||||
| 977 |         default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||
| 978 | - | |||||||||||||||||||
| 979 |             return never executed:   true;return true;never executed:  return true; | 0 | ||||||||||||||||||
| 980 | } | - | ||||||||||||||||||
| 981 | - | |||||||||||||||||||
| 982 | - | |||||||||||||||||||
| 983 | - | |||||||||||||||||||
| 984 | - | |||||||||||||||||||
| 985 | - | |||||||||||||||||||
| 986 | rawFtpReply(replyCodeInt, replyText); | - | ||||||||||||||||||
| 987 |     if (rawCommand
  | 132-4304 | ||||||||||||||||||
| 988 | rawCommand = false; | - | ||||||||||||||||||
| 989 |     } executed 132 times by 1 test:   else if (replyCodeInt == 227end of blockExecuted by: 
 
  | 132-3949 | ||||||||||||||||||
| 990 | - | |||||||||||||||||||
| 991 | - | |||||||||||||||||||
| 992 | - | |||||||||||||||||||
| 993 | - | |||||||||||||||||||
| 994 | - | |||||||||||||||||||
| 995 | QRegExp addrPortPattern(QLatin1String("(\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)")); | - | ||||||||||||||||||
| 996 |         if (addrPortPattern.indexIn(replyText) == -1
  | 0-355 | ||||||||||||||||||
| 997 | - | |||||||||||||||||||
| 998 | - | |||||||||||||||||||
| 999 | - | |||||||||||||||||||
| 1000 | - | |||||||||||||||||||
| 1001 |         } never executed:   else {end of block | 0 | ||||||||||||||||||
| 1002 | const QStringList lst = addrPortPattern.capturedTexts(); | - | ||||||||||||||||||
| 1003 | QString host = lst[1] + QLatin1Char('.') + lst[2] + QLatin1Char('.') + lst[3] + QLatin1Char('.') + lst[4]; | - | ||||||||||||||||||
| 1004 | quint16 port = (lst[5].toUInt() << 8) + lst[6].toUInt(); | - | ||||||||||||||||||
| 1005 | waitForDtpToConnect = true; | - | ||||||||||||||||||
| 1006 | dtp.connectToHost(host, port); | - | ||||||||||||||||||
| 1007 |         } executed 355 times by 2 tests:  end of blockExecuted by: 
  | 355 | ||||||||||||||||||
| 1008 |     } else if (replyCodeInt == 229
  | 0-3949 | ||||||||||||||||||
| 1009 | - | |||||||||||||||||||
| 1010 | int portPos = replyText.indexOf(QLatin1Char('(')); | - | ||||||||||||||||||
| 1011 |         if (portPos == -1
  | 0 | ||||||||||||||||||
| 1012 | - | |||||||||||||||||||
| 1013 | - | |||||||||||||||||||
| 1014 | - | |||||||||||||||||||
| 1015 | - | |||||||||||||||||||
| 1016 |         } never executed:   else {end of block | 0 | ||||||||||||||||||
| 1017 | ++portPos; | - | ||||||||||||||||||
| 1018 | QChar delimiter = replyText.at(portPos); | - | ||||||||||||||||||
| 1019 | const auto epsvParameters = replyText.midRef(portPos).split(delimiter); | - | ||||||||||||||||||
| 1020 | - | |||||||||||||||||||
| 1021 | waitForDtpToConnect = true; | - | ||||||||||||||||||
| 1022 | dtp.connectToHost(commandSocket.peerAddress().toString(), | - | ||||||||||||||||||
| 1023 | epsvParameters.at(3).toInt()); | - | ||||||||||||||||||
| 1024 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 1025 | - | |||||||||||||||||||
| 1026 |     } else if (replyCodeInt == 230
  | 610-3339 | ||||||||||||||||||
| 1027 |         if (currentCmd.startsWith(QLatin1String("USER "))
 
  | 0-610 | ||||||||||||||||||
| 1028 |             pendingCommands.constFirst().startsWith(QLatin1String("PASS "))
  | 0 | ||||||||||||||||||
| 1029 | - | |||||||||||||||||||
| 1030 | pendingCommands.pop_front(); | - | ||||||||||||||||||
| 1031 |         } never executed:  end of block | 0 | ||||||||||||||||||
| 1032 | - | |||||||||||||||||||
| 1033 | connectState(QFtp::LoggedIn); | - | ||||||||||||||||||
| 1034 |     } executed 610 times by 2 tests:   else if (replyCodeInt == 213end of blockExecuted by: 
 
  | 94-3245 | ||||||||||||||||||
| 1035 | - | |||||||||||||||||||
| 1036 |         if (currentCmd.startsWith(QLatin1String("SIZE "))
  | 0-94 | ||||||||||||||||||
| 1037 |             dtp.setBytesTotal(replyText.simplified().toLongLong()); executed 94 times by 2 tests:  dtp.setBytesTotal(replyText.simplified().toLongLong());Executed by: 
  | 94 | ||||||||||||||||||
| 1038 |     } executed 94 times by 2 tests:   else if (replyCode[0]==1end of blockExecuted by: 
 
 
  | 43-2899 | ||||||||||||||||||
| 1039 | dtp.waitForConnection(); | - | ||||||||||||||||||
| 1040 | dtp.writeData(); | - | ||||||||||||||||||
| 1041 |     } executed 43 times by 2 tests:  end of blockExecuted by: 
  | 43 | ||||||||||||||||||
| 1042 | - | |||||||||||||||||||
| 1043 | - | |||||||||||||||||||
| 1044 | switch (state) { | - | ||||||||||||||||||
| 1045 |         case never executed:   Begin:case Begin:never executed:  case Begin: | 0 | ||||||||||||||||||
| 1046 | - | |||||||||||||||||||
| 1047 |             break; never executed:  break; | 0 | ||||||||||||||||||
| 1048 |         case executed 2633 times by 2 tests:   Success:case Success:Executed by: 
 executed 2633 times by 2 tests:  case Success:Executed by: 
  | 2633 | ||||||||||||||||||
| 1049 | - | |||||||||||||||||||
| 1050 | state = Idle; | - | ||||||||||||||||||
| 1051 | - | |||||||||||||||||||
| 1052 |         case executed 649 times by 2 tests:   Idle:case Idle:Executed by: 
 executed 649 times by 2 tests:  case Idle:Executed by: 
 code before this statement executed 2633 times by 2 tests:  case Idle:Executed by: 
  | 649-2633 | ||||||||||||||||||
| 1053 |             if (dtp.hasError()
  | 0-3282 | ||||||||||||||||||
| 1054 | error(QFtp::UnknownError, dtp.errorMessage()); | - | ||||||||||||||||||
| 1055 | dtp.clearError(); | - | ||||||||||||||||||
| 1056 |             } never executed:  end of block | 0 | ||||||||||||||||||
| 1057 | startNextCmd(); | - | ||||||||||||||||||
| 1058 |             break; executed 3282 times by 2 tests:  break;Executed by: 
  | 3282 | ||||||||||||||||||
| 1059 |         case executed 975 times by 2 tests:   Waiting:case Waiting:Executed by: 
 executed 975 times by 2 tests:  case Waiting:Executed by: 
  | 975 | ||||||||||||||||||
| 1060 | - | |||||||||||||||||||
| 1061 |             break; executed 975 times by 2 tests:  break;Executed by: 
  | 975 | ||||||||||||||||||
| 1062 |         case executed 179 times by 2 tests:   Failure:case Failure:Executed by: 
 executed 179 times by 2 tests:  case Failure:Executed by: 
  | 179 | ||||||||||||||||||
| 1063 | - | |||||||||||||||||||
| 1064 | - | |||||||||||||||||||
| 1065 |             if (currentCmd.startsWith(QLatin1String("EPSV"))
  | 0-179 | ||||||||||||||||||
| 1066 | transferConnectionExtended = false; | - | ||||||||||||||||||
| 1067 | pendingCommands.prepend(QLatin1String("PASV\r\n")); | - | ||||||||||||||||||
| 1068 |             } never executed:   else if (currentCmd.startsWith(QLatin1String("EPRT"))end of block
  | 0-179 | ||||||||||||||||||
| 1069 | transferConnectionExtended = false; | - | ||||||||||||||||||
| 1070 | pendingCommands.prepend(QLatin1String("PORT\r\n")); | - | ||||||||||||||||||
| 1071 |             } never executed:   else {end of block | 0 | ||||||||||||||||||
| 1072 | error(QFtp::UnknownError, replyText); | - | ||||||||||||||||||
| 1073 |             } executed 179 times by 2 tests:  end of blockExecuted by: 
  | 179 | ||||||||||||||||||
| 1074 |             if (state != Waiting
  | 4-175 | ||||||||||||||||||
| 1075 | state = Idle; | - | ||||||||||||||||||
| 1076 | startNextCmd(); | - | ||||||||||||||||||
| 1077 |             } executed 175 times by 2 tests:  end of blockExecuted by: 
  | 175 | ||||||||||||||||||
| 1078 |             break; executed 179 times by 2 tests:  break;Executed by: 
  | 179 | ||||||||||||||||||
| 1079 | } | - | ||||||||||||||||||
| 1080 | - | |||||||||||||||||||
| 1081 | - | |||||||||||||||||||
| 1082 | - | |||||||||||||||||||
| 1083 |     return executed 4436 times by 2 tests:   true;return true;Executed by: 
 executed 4436 times by 2 tests:  return true;Executed by: 
  | 4436 | ||||||||||||||||||
| 1084 | } | - | ||||||||||||||||||
| 1085 | - | |||||||||||||||||||
| 1086 | - | |||||||||||||||||||
| 1087 | - | |||||||||||||||||||
| 1088 | - | |||||||||||||||||||
| 1089 | - | |||||||||||||||||||
| 1090 | - | |||||||||||||||||||
| 1091 | - | |||||||||||||||||||
| 1092 | bool QFtpPI::startNextCmd() | - | ||||||||||||||||||
| 1093 | { | - | ||||||||||||||||||
| 1094 |     if (waitForDtpToConnect
  | 355-5392 | ||||||||||||||||||
| 1095 | - | |||||||||||||||||||
| 1096 |         return executed 355 times by 2 tests:   true;return true;Executed by: 
 executed 355 times by 2 tests:  return true;Executed by: 
  | 355 | ||||||||||||||||||
| 1097 | - | |||||||||||||||||||
| 1098 | - | |||||||||||||||||||
| 1099 | - | |||||||||||||||||||
| 1100 | - | |||||||||||||||||||
| 1101 | - | |||||||||||||||||||
| 1102 |     if (pendingCommands.isEmpty()
  | 1937-3455 | ||||||||||||||||||
| 1103 | currentCmd.clear(); | - | ||||||||||||||||||
| 1104 | finished(replyText); | - | ||||||||||||||||||
| 1105 |         return executed 1937 times by 2 tests:   false;return false;Executed by: 
 executed 1937 times by 2 tests:  return false;Executed by: 
  | 1937 | ||||||||||||||||||
| 1106 | } | - | ||||||||||||||||||
| 1107 | currentCmd = pendingCommands.constFirst(); | - | ||||||||||||||||||
| 1108 | - | |||||||||||||||||||
| 1109 | - | |||||||||||||||||||
| 1110 | - | |||||||||||||||||||
| 1111 | - | |||||||||||||||||||
| 1112 | - | |||||||||||||||||||
| 1113 | QHostAddress address = commandSocket.localAddress(); | - | ||||||||||||||||||
| 1114 |     if (currentCmd.startsWith(QLatin1String("PORT"))
  | 8-3447 | ||||||||||||||||||
| 1115 |         if ((
 
 
  | 0-8 | ||||||||||||||||||
| 1116 | int port = dtp.setupListener(address); | - | ||||||||||||||||||
| 1117 | currentCmd = QLatin1String("EPRT |"); | - | ||||||||||||||||||
| 1118 |             currentCmd += (
 
  | 0 | ||||||||||||||||||
| 1119 | currentCmd += QLatin1Char('|') + address.toString() + QLatin1Char('|') + QString::number(port); | - | ||||||||||||||||||
| 1120 | currentCmd += QLatin1Char('|'); | - | ||||||||||||||||||
| 1121 |         } never executed:   else if (address.protocol() == QTcpSocket::IPv4Protocolend of block
  | 0-8 | ||||||||||||||||||
| 1122 | int port = dtp.setupListener(address); | - | ||||||||||||||||||
| 1123 | QString portArg; | - | ||||||||||||||||||
| 1124 | quint32 ip = address.toIPv4Address(); | - | ||||||||||||||||||
| 1125 | portArg += QString::number((ip & 0xff000000) >> 24); | - | ||||||||||||||||||
| 1126 | portArg += QLatin1Char(',') + QString::number((ip & 0xff0000) >> 16); | - | ||||||||||||||||||
| 1127 | portArg += QLatin1Char(',') + QString::number((ip & 0xff00) >> 8); | - | ||||||||||||||||||
| 1128 | portArg += QLatin1Char(',') + QString::number(ip & 0xff); | - | ||||||||||||||||||
| 1129 | portArg += QLatin1Char(',') + QString::number((port & 0xff00) >> 8); | - | ||||||||||||||||||
| 1130 | portArg += QLatin1Char(',') + QString::number(port & 0xff); | - | ||||||||||||||||||
| 1131 | - | |||||||||||||||||||
| 1132 | currentCmd = QLatin1String("PORT "); | - | ||||||||||||||||||
| 1133 | currentCmd += portArg; | - | ||||||||||||||||||
| 1134 |         } executed 8 times by 1 test:   else {end of blockExecuted by: 
  | 8 | ||||||||||||||||||
| 1135 | - | |||||||||||||||||||
| 1136 | - | |||||||||||||||||||
| 1137 |             return never executed:   false;return false;never executed:  return false; | 0 | ||||||||||||||||||
| 1138 | } | - | ||||||||||||||||||
| 1139 | - | |||||||||||||||||||
| 1140 | currentCmd += QLatin1String("\r\n"); | - | ||||||||||||||||||
| 1141 |     } executed 8 times by 1 test:   else if (currentCmd.startsWith(QLatin1String("PASV"))end of blockExecuted by: 
 
  | 8-3092 | ||||||||||||||||||
| 1142 |         if ((
 
 
  | 0-355 | ||||||||||||||||||
| 1143 |             currentCmd = QLatin1String("EPSV\r\n"); never executed:  currentCmd = QLatin1String("EPSV\r\n"); | 0 | ||||||||||||||||||
| 1144 |     } executed 355 times by 2 tests:  end of blockExecuted by: 
  | 355 | ||||||||||||||||||
| 1145 | - | |||||||||||||||||||
| 1146 | pendingCommands.pop_front(); | - | ||||||||||||||||||
| 1147 | - | |||||||||||||||||||
| 1148 | - | |||||||||||||||||||
| 1149 | - | |||||||||||||||||||
| 1150 | state = Waiting; | - | ||||||||||||||||||
| 1151 | commandSocket.write(currentCmd.toUtf8()); | - | ||||||||||||||||||
| 1152 |     return executed 3455 times by 2 tests:   true;return true;Executed by: 
 executed 3455 times by 2 tests:  return true;Executed by: 
  | 3455 | ||||||||||||||||||
| 1153 | } | - | ||||||||||||||||||
| 1154 | - | |||||||||||||||||||
| 1155 | void QFtpPI::dtpConnectState(int s) | - | ||||||||||||||||||
| 1156 | { | - | ||||||||||||||||||
| 1157 | switch (s) { | - | ||||||||||||||||||
| 1158 |         case executed 363 times by 2 tests:   QFtpDTP::CsClosed:case QFtpDTP::CsClosed:Executed by: 
 executed 363 times by 2 tests:  case QFtpDTP::CsClosed:Executed by: 
  | 363 | ||||||||||||||||||
| 1159 |             if (waitForDtpToClose
  | 2-361 | ||||||||||||||||||
| 1160 | - | |||||||||||||||||||
| 1161 |                 if (processReply()
  | 0-2 | ||||||||||||||||||
| 1162 |                     replyText = QLatin1String(""); executed 2 times by 1 test:  replyText = QLatin1String("");Executed by: 
  | 2 | ||||||||||||||||||
| 1163 | else | - | ||||||||||||||||||
| 1164 |                     return; never executed:  return; | 0 | ||||||||||||||||||
| 1165 | } | - | ||||||||||||||||||
| 1166 | waitForDtpToClose = false; | - | ||||||||||||||||||
| 1167 | readyRead(); | - | ||||||||||||||||||
| 1168 |             return; executed 363 times by 2 tests:  return;Executed by: 
  | 363 | ||||||||||||||||||
| 1169 |         case executed 355 times by 2 tests:   QFtpDTP::CsConnected:case QFtpDTP::CsConnected:Executed by: 
 executed 355 times by 2 tests:  case QFtpDTP::CsConnected:Executed by: 
  | 355 | ||||||||||||||||||
| 1170 | waitForDtpToConnect = false; | - | ||||||||||||||||||
| 1171 | startNextCmd(); | - | ||||||||||||||||||
| 1172 |             return; executed 355 times by 2 tests:  return;Executed by: 
  | 355 | ||||||||||||||||||
| 1173 |         case never executed:   QFtpDTP::CsHostNotFound:case QFtpDTP::CsHostNotFound:never executed:  case QFtpDTP::CsHostNotFound: | 0 | ||||||||||||||||||
| 1174 |         case never executed:   QFtpDTP::CsConnectionRefused:case QFtpDTP::CsConnectionRefused:never executed:  case QFtpDTP::CsConnectionRefused: | 0 | ||||||||||||||||||
| 1175 | error(QFtp::ConnectionRefused, | - | ||||||||||||||||||
| 1176 | QFtp::tr("Data Connection refused")); | - | ||||||||||||||||||
| 1177 | startNextCmd(); | - | ||||||||||||||||||
| 1178 |             return; never executed:  return; | 0 | ||||||||||||||||||
| 1179 |         default never executed:  :default:never executed:  default: | 0 | ||||||||||||||||||
| 1180 |             return; never executed:  return; | 0 | ||||||||||||||||||
| 1181 | } | - | ||||||||||||||||||
| 1182 | } | - | ||||||||||||||||||
| 1183 | - | |||||||||||||||||||
| 1184 | - | |||||||||||||||||||
| 1185 | - | |||||||||||||||||||
| 1186 | - | |||||||||||||||||||
| 1187 | - | |||||||||||||||||||
| 1188 | - | |||||||||||||||||||
| 1189 | - | |||||||||||||||||||
| 1190 | - | |||||||||||||||||||
| 1191 | - | |||||||||||||||||||
| 1192 | - | |||||||||||||||||||
| 1193 | class QFtpPrivate : public QObjectPrivate | - | ||||||||||||||||||
| 1194 | { | - | ||||||||||||||||||
| 1195 | inline QFtp* q_func() { return static_cast<QFtp *>(q_ptr); } inline const QFtp* q_func() const { return static_cast<const QFtp *>(q_ptr); } friend class QFtp; | - | ||||||||||||||||||
| 1196 | public: | - | ||||||||||||||||||
| 1197 | - | |||||||||||||||||||
| 1198 | inline QFtpPrivate() : close_waitForStateChange(false), state(QFtp::Unconnected), | - | ||||||||||||||||||
| 1199 | transferMode(QFtp::Passive), error(QFtp::NoError) | - | ||||||||||||||||||
| 1200 |     { } executed 661 times by 2 tests:  end of blockExecuted by: 
  | 661 | ||||||||||||||||||
| 1201 | - | |||||||||||||||||||
| 1202 |     ~QFtpPrivate() { while (!pending.isEmpty()
 executed 661 times by 2 tests:   }delete pending.takeFirst();Executed by: 
 executed 659 times by 2 tests:  end of blockExecuted by: 
  | 659-661 | ||||||||||||||||||
| 1203 | - | |||||||||||||||||||
| 1204 | - | |||||||||||||||||||
| 1205 | void _q_startNextCommand(); | - | ||||||||||||||||||
| 1206 | void _q_piFinished(const QString&); | - | ||||||||||||||||||
| 1207 | void _q_piError(int, const QString&); | - | ||||||||||||||||||
| 1208 | void _q_piConnectState(int); | - | ||||||||||||||||||
| 1209 | void _q_piFtpReply(int, const QString&); | - | ||||||||||||||||||
| 1210 | - | |||||||||||||||||||
| 1211 | int addCommand(QFtpCommand *cmd); | - | ||||||||||||||||||
| 1212 | - | |||||||||||||||||||
| 1213 | QFtpPI pi; | - | ||||||||||||||||||
| 1214 | QList<QFtpCommand *> pending; | - | ||||||||||||||||||
| 1215 | bool close_waitForStateChange; | - | ||||||||||||||||||
| 1216 | QFtp::State state; | - | ||||||||||||||||||
| 1217 | QFtp::TransferMode transferMode; | - | ||||||||||||||||||
| 1218 | QFtp::Error error; | - | ||||||||||||||||||
| 1219 | QString errorString; | - | ||||||||||||||||||
| 1220 | - | |||||||||||||||||||
| 1221 | QString host; | - | ||||||||||||||||||
| 1222 | quint16 port; | - | ||||||||||||||||||
| 1223 | QString proxyHost; | - | ||||||||||||||||||
| 1224 | quint16 proxyPort; | - | ||||||||||||||||||
| 1225 | }; | - | ||||||||||||||||||
| 1226 | - | |||||||||||||||||||
| 1227 | int QFtpPrivate::addCommand(QFtpCommand *cmd) | - | ||||||||||||||||||
| 1228 | { | - | ||||||||||||||||||
| 1229 | pending.append(cmd); | - | ||||||||||||||||||
| 1230 | - | |||||||||||||||||||
| 1231 |     if (pending.count() == 1
  | 1481-1942 | ||||||||||||||||||
| 1232 | - | |||||||||||||||||||
| 1233 | QTimer::singleShot(0, q_func(), qFlagLocation("1""_q_startNextCommand()" "\0" __FILE__ ":" "1307")); | - | ||||||||||||||||||
| 1234 |     } executed 1481 times by 2 tests:  end of blockExecuted by: 
  | 1481 | ||||||||||||||||||
| 1235 |     return executed 3423 times by 2 tests:   cmd->id;return cmd->id;Executed by: 
 executed 3423 times by 2 tests:  return cmd->id;Executed by: 
  | 3423 | ||||||||||||||||||
| 1236 | } | - | ||||||||||||||||||
| 1237 | QFtp::QFtp(QObject *parent) | - | ||||||||||||||||||
| 1238 | : QObject(*new QFtpPrivate, parent) | - | ||||||||||||||||||
| 1239 | { | - | ||||||||||||||||||
| 1240 | QFtpPrivate * const d = d_func(); | - | ||||||||||||||||||
| 1241 | d->errorString = tr("Unknown error"); | - | ||||||||||||||||||
| 1242 | - | |||||||||||||||||||
| 1243 | connect(&d->pi, qFlagLocation("2""connectState(int)" "\0" __FILE__ ":" "1431"), | - | ||||||||||||||||||
| 1244 | qFlagLocation("1""_q_piConnectState(int)" "\0" __FILE__ ":" "1432")); | - | ||||||||||||||||||
| 1245 | connect(&d->pi, qFlagLocation("2""finished(QString)" "\0" __FILE__ ":" "1433"), | - | ||||||||||||||||||
| 1246 | qFlagLocation("1""_q_piFinished(QString)" "\0" __FILE__ ":" "1434")); | - | ||||||||||||||||||
| 1247 | connect(&d->pi, qFlagLocation("2""error(int,QString)" "\0" __FILE__ ":" "1435"), | - | ||||||||||||||||||
| 1248 | qFlagLocation("1""_q_piError(int,QString)" "\0" __FILE__ ":" "1436")); | - | ||||||||||||||||||
| 1249 | connect(&d->pi, qFlagLocation("2""rawFtpReply(int,QString)" "\0" __FILE__ ":" "1437"), | - | ||||||||||||||||||
| 1250 | qFlagLocation("1""_q_piFtpReply(int,QString)" "\0" __FILE__ ":" "1438")); | - | ||||||||||||||||||
| 1251 | - | |||||||||||||||||||
| 1252 | connect(&d->pi.dtp, qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "1440"), | - | ||||||||||||||||||
| 1253 | qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "1441")); | - | ||||||||||||||||||
| 1254 | connect(&d->pi.dtp, qFlagLocation("2""dataTransferProgress(qint64,qint64)" "\0" __FILE__ ":" "1442"), | - | ||||||||||||||||||
| 1255 | qFlagLocation("2""dataTransferProgress(qint64,qint64)" "\0" __FILE__ ":" "1443")); | - | ||||||||||||||||||
| 1256 | connect(&d->pi.dtp, qFlagLocation("2""listInfo(QUrlInfo)" "\0" __FILE__ ":" "1444"), | - | ||||||||||||||||||
| 1257 | qFlagLocation("2""listInfo(QUrlInfo)" "\0" __FILE__ ":" "1445")); | - | ||||||||||||||||||
| 1258 | } executed 661 times by 2 tests:  end of blockExecuted by: 
  | 661 | ||||||||||||||||||
| 1259 | int QFtp::connectToHost(const QString &host, quint16 port) | - | ||||||||||||||||||
| 1260 | { | - | ||||||||||||||||||
| 1261 | QStringList cmds; | - | ||||||||||||||||||
| 1262 | cmds << host; | - | ||||||||||||||||||
| 1263 | cmds << QString::number((uint)port); | - | ||||||||||||||||||
| 1264 | int id = d_func()->addCommand(new QFtpCommand(ConnectToHost, cmds)); | - | ||||||||||||||||||
| 1265 | d_func()->pi.transferConnectionExtended = true; | - | ||||||||||||||||||
| 1266 |     return executed 657 times by 2 tests:   id;return id;Executed by: 
 executed 657 times by 2 tests:  return id;Executed by: 
  | 657 | ||||||||||||||||||
| 1267 | } | - | ||||||||||||||||||
| 1268 | int QFtp::login(const QString &user, const QString &password) | - | ||||||||||||||||||
| 1269 | { | - | ||||||||||||||||||
| 1270 | QStringList cmds; | - | ||||||||||||||||||
| 1271 | cmds << (QLatin1String("USER ") + (user.isNull() ? QLatin1String("anonymous") : user) + QLatin1String("\r\n")); | - | ||||||||||||||||||
| 1272 | cmds << (QLatin1String("PASS ") + (password.isNull() ? QLatin1String("anonymous@") : password) + QLatin1String("\r\n")); | - | ||||||||||||||||||
| 1273 |     return executed 636 times by 2 tests:   d_func()->addCommand(new QFtpCommand(Login, cmds));return d_func()->addCommand(new QFtpCommand(Login, cmds));Executed by: 
 executed 636 times by 2 tests:  return d_func()->addCommand(new QFtpCommand(Login, cmds));Executed by: 
  | 636 | ||||||||||||||||||
| 1274 | } | - | ||||||||||||||||||
| 1275 | int QFtp::close() | - | ||||||||||||||||||
| 1276 | { | - | ||||||||||||||||||
| 1277 |     return executed 1235 times by 2 tests:   d_func()->addCommand(new QFtpCommand(Close, QStringList(QLatin1String("QUIT\r\n"))));return d_func()->addCommand(new QFtpCommand(Close, QStringList(QLatin1String("QUIT\r\n"))));Executed by: 
 executed 1235 times by 2 tests:  return d_func()->addCommand(new QFtpCommand(Close, QStringList(QLatin1String("QUIT\r\n"))));Executed by: 
  | 1235 | ||||||||||||||||||
| 1278 | } | - | ||||||||||||||||||
| 1279 | - | |||||||||||||||||||
| 1280 | - | |||||||||||||||||||
| 1281 | - | |||||||||||||||||||
| 1282 | - | |||||||||||||||||||
| 1283 | - | |||||||||||||||||||
| 1284 | - | |||||||||||||||||||
| 1285 | - | |||||||||||||||||||
| 1286 | int QFtp::setTransferMode(TransferMode mode) | - | ||||||||||||||||||
| 1287 | { | - | ||||||||||||||||||
| 1288 | int id = d_func()->addCommand(new QFtpCommand(SetTransferMode, QStringList())); | - | ||||||||||||||||||
| 1289 | d_func()->pi.transferConnectionExtended = true; | - | ||||||||||||||||||
| 1290 | d_func()->transferMode = mode; | - | ||||||||||||||||||
| 1291 |     return executed 4 times by 1 test:   id;return id;Executed by: 
 executed 4 times by 1 test:  return id;Executed by: 
  | 4 | ||||||||||||||||||
| 1292 | } | - | ||||||||||||||||||
| 1293 | int QFtp::setProxy(const QString &host, quint16 port) | - | ||||||||||||||||||
| 1294 | { | - | ||||||||||||||||||
| 1295 | QStringList args; | - | ||||||||||||||||||
| 1296 | args << host << QString::number(port); | - | ||||||||||||||||||
| 1297 |     return executed 26 times by 2 tests:   d_func()->addCommand(new QFtpCommand(SetProxy, args));return d_func()->addCommand(new QFtpCommand(SetProxy, args));Executed by: 
 executed 26 times by 2 tests:  return d_func()->addCommand(new QFtpCommand(SetProxy, args));Executed by: 
  | 26 | ||||||||||||||||||
| 1298 | } | - | ||||||||||||||||||
| 1299 | int QFtp::list(const QString &dir) | - | ||||||||||||||||||
| 1300 | { | - | ||||||||||||||||||
| 1301 | QStringList cmds; | - | ||||||||||||||||||
| 1302 | cmds << QLatin1String("TYPE A\r\n"); | - | ||||||||||||||||||
| 1303 | cmds << QLatin1String(d_func()->transferMode == Passive ? "PASV\r\n" : "PORT\r\n"); | - | ||||||||||||||||||
| 1304 |     if (dir.isEmpty()
  | 72-156 | ||||||||||||||||||
| 1305 |         cmds << QLatin1String("LIST\r\n"); executed 72 times by 1 test:  cmds << QLatin1String("LIST\r\n");Executed by: 
  | 72 | ||||||||||||||||||
| 1306 | else | - | ||||||||||||||||||
| 1307 |         cmds << (QLatin1String("LIST ") + dir + QLatin1String("\r\n")); executed 156 times by 1 test:  cmds << (QLatin1String("LIST ") + dir + QLatin1String("\r\n"));Executed by: 
  | 156 | ||||||||||||||||||
| 1308 |     return executed 228 times by 1 test:   d_func()->addCommand(new QFtpCommand(List, cmds));return d_func()->addCommand(new QFtpCommand(List, cmds));Executed by: 
 executed 228 times by 1 test:  return d_func()->addCommand(new QFtpCommand(List, cmds));Executed by: 
  | 228 | ||||||||||||||||||
| 1309 | } | - | ||||||||||||||||||
| 1310 | int QFtp::cd(const QString &dir) | - | ||||||||||||||||||
| 1311 | { | - | ||||||||||||||||||
| 1312 |     return executed 216 times by 1 test:   d_func()->addCommand(new QFtpCommand(Cd, QStringList(QLatin1String("CWD ") + dir + QLatin1String("\r\n"))));return d_func()->addCommand(new QFtpCommand(Cd, QStringList(QLatin1String("CWD ") + dir + QLatin1String("\r\n"))));Executed by: 
 executed 216 times by 1 test:  return d_func()->addCommand(new QFtpCommand(Cd, QStringList(QLatin1String("CWD ") + dir + QLatin1String("\r\n"))));Executed by: 
  | 216 | ||||||||||||||||||
| 1313 | } | - | ||||||||||||||||||
| 1314 | int QFtp::get(const QString &file, QIODevice *dev, TransferType type) | - | ||||||||||||||||||
| 1315 | { | - | ||||||||||||||||||
| 1316 | QStringList cmds; | - | ||||||||||||||||||
| 1317 |     if (type == Binary
  | 0-110 | ||||||||||||||||||
| 1318 |         cmds << QLatin1String("TYPE I\r\n"); executed 110 times by 2 tests:  cmds << QLatin1String("TYPE I\r\n");Executed by: 
  | 110 | ||||||||||||||||||
| 1319 | else | - | ||||||||||||||||||
| 1320 |         cmds << QLatin1String("TYPE A\r\n"); never executed:  cmds << QLatin1String("TYPE A\r\n"); | 0 | ||||||||||||||||||
| 1321 | cmds << QLatin1String("SIZE ") + file + QLatin1String("\r\n"); | - | ||||||||||||||||||
| 1322 | cmds << QLatin1String(d_func()->transferMode == Passive ? "PASV\r\n" : "PORT\r\n"); | - | ||||||||||||||||||
| 1323 | cmds << QLatin1String("RETR ") + file + QLatin1String("\r\n"); | - | ||||||||||||||||||
| 1324 |     return executed 110 times by 2 tests:   d_func()->addCommand(new QFtpCommand(Get, cmds, dev));return d_func()->addCommand(new QFtpCommand(Get, cmds, dev));Executed by: 
 executed 110 times by 2 tests:  return d_func()->addCommand(new QFtpCommand(Get, cmds, dev));Executed by: 
  | 110 | ||||||||||||||||||
| 1325 | } | - | ||||||||||||||||||
| 1326 | int QFtp::put(const QByteArray &data, const QString &file, TransferType type) | - | ||||||||||||||||||
| 1327 | { | - | ||||||||||||||||||
| 1328 | QStringList cmds; | - | ||||||||||||||||||
| 1329 |     if (type == Binary
  | 4-24 | ||||||||||||||||||
| 1330 |         cmds << QLatin1String("TYPE I\r\n"); executed 24 times by 1 test:  cmds << QLatin1String("TYPE I\r\n");Executed by: 
  | 24 | ||||||||||||||||||
| 1331 | else | - | ||||||||||||||||||
| 1332 |         cmds << QLatin1String("TYPE A\r\n"); executed 4 times by 1 test:  cmds << QLatin1String("TYPE A\r\n");Executed by: 
  | 4 | ||||||||||||||||||
| 1333 | cmds << QLatin1String(d_func()->transferMode == Passive ? "PASV\r\n" : "PORT\r\n"); | - | ||||||||||||||||||
| 1334 | cmds << QLatin1String("ALLO ") + QString::number(data.size()) + QLatin1String("\r\n"); | - | ||||||||||||||||||
| 1335 | cmds << QLatin1String("STOR ") + file + QLatin1String("\r\n"); | - | ||||||||||||||||||
| 1336 |     return executed 28 times by 1 test:   d_func()->addCommand(new QFtpCommand(Put, cmds, data));return d_func()->addCommand(new QFtpCommand(Put, cmds, data));Executed by: 
 executed 28 times by 1 test:  return d_func()->addCommand(new QFtpCommand(Put, cmds, data));Executed by: 
  | 28 | ||||||||||||||||||
| 1337 | } | - | ||||||||||||||||||
| 1338 | int QFtp::put(QIODevice *dev, const QString &file, TransferType type) | - | ||||||||||||||||||
| 1339 | { | - | ||||||||||||||||||
| 1340 | QStringList cmds; | - | ||||||||||||||||||
| 1341 |     if (type == Binary
  | 0-15 | ||||||||||||||||||
| 1342 |         cmds << QLatin1String("TYPE I\r\n"); executed 15 times by 2 tests:  cmds << QLatin1String("TYPE I\r\n");Executed by: 
  | 15 | ||||||||||||||||||
| 1343 | else | - | ||||||||||||||||||
| 1344 |         cmds << QLatin1String("TYPE A\r\n"); never executed:  cmds << QLatin1String("TYPE A\r\n"); | 0 | ||||||||||||||||||
| 1345 | cmds << QLatin1String(d_func()->transferMode == Passive ? "PASV\r\n" : "PORT\r\n"); | - | ||||||||||||||||||
| 1346 |     if (!dev->isSequential()
  | 0-15 | ||||||||||||||||||
| 1347 |         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: 
  | 15 | ||||||||||||||||||
| 1348 | cmds << QLatin1String("STOR ") + file + QLatin1String("\r\n"); | - | ||||||||||||||||||
| 1349 |     return executed 15 times by 2 tests:   d_func()->addCommand(new QFtpCommand(Put, cmds, dev));return d_func()->addCommand(new QFtpCommand(Put, cmds, dev));Executed by: 
 executed 15 times by 2 tests:  return d_func()->addCommand(new QFtpCommand(Put, cmds, dev));Executed by: 
  | 15 | ||||||||||||||||||
| 1350 | } | - | ||||||||||||||||||
| 1351 | int QFtp::remove(const QString &file) | - | ||||||||||||||||||
| 1352 | { | - | ||||||||||||||||||
| 1353 |     return executed 32 times by 1 test:   d_func()->addCommand(new QFtpCommand(Remove, QStringList(QLatin1String("DELE ") + file + QLatin1String("\r\n"))));return d_func()->addCommand(new QFtpCommand(Remove, QStringList(QLatin1String("DELE ") + file + QLatin1String("\r\n"))));Executed by: 
 executed 32 times by 1 test:  return d_func()->addCommand(new QFtpCommand(Remove, QStringList(QLatin1String("DELE ") + file + QLatin1String("\r\n"))));Executed by: 
  | 32 | ||||||||||||||||||
| 1354 | } | - | ||||||||||||||||||
| 1355 | int QFtp::mkdir(const QString &dir) | - | ||||||||||||||||||
| 1356 | { | - | ||||||||||||||||||
| 1357 |     return executed 52 times by 1 test:   d_func()->addCommand(new QFtpCommand(Mkdir, QStringList(QLatin1String("MKD ") + dir + QLatin1String("\r\n"))));return d_func()->addCommand(new QFtpCommand(Mkdir, QStringList(QLatin1String("MKD ") + dir + QLatin1String("\r\n"))));Executed by: 
 executed 52 times by 1 test:  return d_func()->addCommand(new QFtpCommand(Mkdir, QStringList(QLatin1String("MKD ") + dir + QLatin1String("\r\n"))));Executed by: 
  | 52 | ||||||||||||||||||
| 1358 | } | - | ||||||||||||||||||
| 1359 | int QFtp::rmdir(const QString &dir) | - | ||||||||||||||||||
| 1360 | { | - | ||||||||||||||||||
| 1361 |     return executed 20 times by 1 test:   d_func()->addCommand(new QFtpCommand(Rmdir, QStringList(QLatin1String("RMD ") + dir + QLatin1String("\r\n"))));return d_func()->addCommand(new QFtpCommand(Rmdir, QStringList(QLatin1String("RMD ") + dir + QLatin1String("\r\n"))));Executed by: 
 executed 20 times by 1 test:  return d_func()->addCommand(new QFtpCommand(Rmdir, QStringList(QLatin1String("RMD ") + dir + QLatin1String("\r\n"))));Executed by: 
  | 20 | ||||||||||||||||||
| 1362 | } | - | ||||||||||||||||||
| 1363 | int QFtp::rename(const QString &oldname, const QString &newname) | - | ||||||||||||||||||
| 1364 | { | - | ||||||||||||||||||
| 1365 | QStringList cmds; | - | ||||||||||||||||||
| 1366 | cmds << QLatin1String("RNFR ") + oldname + QLatin1String("\r\n"); | - | ||||||||||||||||||
| 1367 | cmds << QLatin1String("RNTO ") + newname + QLatin1String("\r\n"); | - | ||||||||||||||||||
| 1368 |     return executed 28 times by 1 test:   d_func()->addCommand(new QFtpCommand(Rename, cmds));return d_func()->addCommand(new QFtpCommand(Rename, cmds));Executed by: 
 executed 28 times by 1 test:  return d_func()->addCommand(new QFtpCommand(Rename, cmds));Executed by: 
  | 28 | ||||||||||||||||||
| 1369 | } | - | ||||||||||||||||||
| 1370 | int QFtp::rawCommand(const QString &command) | - | ||||||||||||||||||
| 1371 | { | - | ||||||||||||||||||
| 1372 | const QString cmd = QStringRef(&command).trimmed() + QLatin1String("\r\n"); | - | ||||||||||||||||||
| 1373 |     return executed 136 times by 1 test:   d_func()->addCommand(new QFtpCommand(RawCommand, QStringList(cmd)));return d_func()->addCommand(new QFtpCommand(RawCommand, QStringList(cmd)));Executed by: 
 executed 136 times by 1 test:  return d_func()->addCommand(new QFtpCommand(RawCommand, QStringList(cmd)));Executed by: 
  | 136 | ||||||||||||||||||
| 1374 | } | - | ||||||||||||||||||
| 1375 | qint64 QFtp::bytesAvailable() const | - | ||||||||||||||||||
| 1376 | { | - | ||||||||||||||||||
| 1377 |     return executed 6171 times by 2 tests:   d_func()->pi.dtp.bytesAvailable();return d_func()->pi.dtp.bytesAvailable();Executed by: 
 executed 6171 times by 2 tests:  return d_func()->pi.dtp.bytesAvailable();Executed by: 
  | 6171 | ||||||||||||||||||
| 1378 | } | - | ||||||||||||||||||
| 1379 | qint64 QFtp::read(char *data, qint64 maxlen) | - | ||||||||||||||||||
| 1380 | { | - | ||||||||||||||||||
| 1381 |     return never executed:   d_func()->pi.dtp.read(data, maxlen);return d_func()->pi.dtp.read(data, maxlen);never executed:  return d_func()->pi.dtp.read(data, maxlen); | 0 | ||||||||||||||||||
| 1382 | } | - | ||||||||||||||||||
| 1383 | QByteArray QFtp::readAll() | - | ||||||||||||||||||
| 1384 | { | - | ||||||||||||||||||
| 1385 |     return executed 611 times by 2 tests:   d_func()->pi.dtp.readAll();return d_func()->pi.dtp.readAll();Executed by: 
 executed 611 times by 2 tests:  return d_func()->pi.dtp.readAll();Executed by: 
  | 611 | ||||||||||||||||||
| 1386 | } | - | ||||||||||||||||||
| 1387 | void QFtp::abort() | - | ||||||||||||||||||
| 1388 | { | - | ||||||||||||||||||
| 1389 |     if (d_func()->pending.isEmpty()
  | 4-657 | ||||||||||||||||||
| 1390 |         return; executed 657 times by 2 tests:  return;Executed by: 
  | 657 | ||||||||||||||||||
| 1391 | - | |||||||||||||||||||
| 1392 | clearPendingCommands(); | - | ||||||||||||||||||
| 1393 | d_func()->pi.abort(); | - | ||||||||||||||||||
| 1394 | } executed 4 times by 2 tests:  end of blockExecuted by: 
  | 4 | ||||||||||||||||||
| 1395 | int QFtp::currentId() const | - | ||||||||||||||||||
| 1396 | { | - | ||||||||||||||||||
| 1397 |     if (d_func()->pending.isEmpty()
  | 731-48388 | ||||||||||||||||||
| 1398 |         return executed 731 times by 1 test:   0;return 0;Executed by: 
 executed 731 times by 1 test:  return 0;Executed by: 
  | 731 | ||||||||||||||||||
| 1399 |     return executed 48388 times by 2 tests:   d_func()->pending.first()->id;return d_func()->pending.first()->id;Executed by: 
 executed 48388 times by 2 tests:  return d_func()->pending.first()->id;Executed by: 
  | 48388 | ||||||||||||||||||
| 1400 | } | - | ||||||||||||||||||
| 1401 | QFtp::Command QFtp::currentCommand() const | - | ||||||||||||||||||
| 1402 | { | - | ||||||||||||||||||
| 1403 |     if (d_func()->pending.isEmpty()
  | 24-20744 | ||||||||||||||||||
| 1404 |         return executed 24 times by 1 test:   None;return None;Executed by: 
 executed 24 times by 1 test:  return None;Executed by: 
  | 24 | ||||||||||||||||||
| 1405 |     return executed 20744 times by 2 tests:   d_func()->pending.first()->command;return d_func()->pending.first()->command;Executed by: 
 executed 20744 times by 2 tests:  return d_func()->pending.first()->command;Executed by: 
  | 20744 | ||||||||||||||||||
| 1406 | } | - | ||||||||||||||||||
| 1407 | QIODevice* QFtp::currentDevice() const | - | ||||||||||||||||||
| 1408 | { | - | ||||||||||||||||||
| 1409 |     if (d_func()->pending.isEmpty()
  | 0 | ||||||||||||||||||
| 1410 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 1411 | QFtpCommand *c = d_func()->pending.first(); | - | ||||||||||||||||||
| 1412 |     if (c->is_ba
  | 0 | ||||||||||||||||||
| 1413 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 1414 |     return never executed:   c->data.dev;return c->data.dev;never executed:  return c->data.dev; | 0 | ||||||||||||||||||
| 1415 | } | - | ||||||||||||||||||
| 1416 | bool QFtp::hasPendingCommands() const | - | ||||||||||||||||||
| 1417 | { | - | ||||||||||||||||||
| 1418 |     return executed 7303 times by 1 test:   d_func()->pending.count() > 1;return d_func()->pending.count() > 1;Executed by: 
 executed 7303 times by 1 test:  return d_func()->pending.count() > 1;Executed by: 
  | 7303 | ||||||||||||||||||
| 1419 | } | - | ||||||||||||||||||
| 1420 | void QFtp::clearPendingCommands() | - | ||||||||||||||||||
| 1421 | { | - | ||||||||||||||||||
| 1422 | - | |||||||||||||||||||
| 1423 |     while (d_func()->pending.count() > 1
  | 119-165 | ||||||||||||||||||
| 1424 |         delete d_func()->pending.takeLast(); executed 119 times by 2 tests:  delete d_func()->pending.takeLast();Executed by: 
  | 119 | ||||||||||||||||||
| 1425 | } executed 165 times by 2 tests:  end of blockExecuted by: 
  | 165 | ||||||||||||||||||
| 1426 | QFtp::State QFtp::state() const | - | ||||||||||||||||||
| 1427 | { | - | ||||||||||||||||||
| 1428 |     return executed 10413 times by 2 tests:   d_func()->state;return d_func()->state;Executed by: 
 executed 10413 times by 2 tests:  return d_func()->state;Executed by: 
  | 10413 | ||||||||||||||||||
| 1429 | } | - | ||||||||||||||||||
| 1430 | QFtp::Error QFtp::error() const | - | ||||||||||||||||||
| 1431 | { | - | ||||||||||||||||||
| 1432 |     return executed 5556 times by 2 tests:   d_func()->error;return d_func()->error;Executed by: 
 executed 5556 times by 2 tests:  return d_func()->error;Executed by: 
  | 5556 | ||||||||||||||||||
| 1433 | } | - | ||||||||||||||||||
| 1434 | QString QFtp::errorString() const | - | ||||||||||||||||||
| 1435 | { | - | ||||||||||||||||||
| 1436 |     return executed 6 times by 1 test:   d_func()->errorString;return d_func()->errorString;Executed by: 
 executed 6 times by 1 test:  return d_func()->errorString;Executed by: 
  | 6 | ||||||||||||||||||
| 1437 | } | - | ||||||||||||||||||
| 1438 | - | |||||||||||||||||||
| 1439 | - | |||||||||||||||||||
| 1440 | - | |||||||||||||||||||
| 1441 | void QFtpPrivate::_q_startNextCommand() | - | ||||||||||||||||||
| 1442 | { | - | ||||||||||||||||||
| 1443 | QFtp * const q = q_func(); | - | ||||||||||||||||||
| 1444 |     if (pending.isEmpty()
  | 0-2643 | ||||||||||||||||||
| 1445 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 1446 | QFtpCommand *c = pending.constFirst(); | - | ||||||||||||||||||
| 1447 | - | |||||||||||||||||||
| 1448 | error = QFtp::NoError; | - | ||||||||||||||||||
| 1449 | errorString = QLatin1String("Unknown error"); | - | ||||||||||||||||||
| 1450 | - | |||||||||||||||||||
| 1451 |     if (q->bytesAvailable()
  | 8-2635 | ||||||||||||||||||
| 1452 |         q->readAll(); executed 8 times by 1 test:  q->readAll();Executed by: 
  | 8 | ||||||||||||||||||
| 1453 | q->commandStarted(c->id); | - | ||||||||||||||||||
| 1454 | - | |||||||||||||||||||
| 1455 | - | |||||||||||||||||||
| 1456 | - | |||||||||||||||||||
| 1457 |     if (c->command == QFtp::Login
 
  | 26-2010 | ||||||||||||||||||
| 1458 | QString loginString; | - | ||||||||||||||||||
| 1459 | loginString += QStringRef(&c->rawCmds.constFirst()).trimmed() + QLatin1Char('@') + host; | - | ||||||||||||||||||
| 1460 |         if (port
 
  | 0-26 | ||||||||||||||||||
| 1461 |             loginString += QLatin1Char(':') + QString::number(port); never executed:  loginString += QLatin1Char(':') + QString::number(port); | 0 | ||||||||||||||||||
| 1462 | loginString += QLatin1String("\r\n"); | - | ||||||||||||||||||
| 1463 | c->rawCmds[0] = loginString; | - | ||||||||||||||||||
| 1464 |     } executed 26 times by 2 tests:  end of blockExecuted by: 
  | 26 | ||||||||||||||||||
| 1465 | - | |||||||||||||||||||
| 1466 |     if (c->command == QFtp::SetTransferMode
  | 4-2639 | ||||||||||||||||||
| 1467 | _q_piFinished(QLatin1String("Transfer mode set")); | - | ||||||||||||||||||
| 1468 |     } executed 4 times by 1 test:   else if (c->command == QFtp::SetProxyend of blockExecuted by: 
 
  | 4-2613 | ||||||||||||||||||
| 1469 | proxyHost = c->rawCmds.at(0); | - | ||||||||||||||||||
| 1470 | proxyPort = c->rawCmds.at(1).toUInt(); | - | ||||||||||||||||||
| 1471 | c->rawCmds.clear(); | - | ||||||||||||||||||
| 1472 | _q_piFinished(QLatin1String("Proxy set to ") + proxyHost + QLatin1Char(':') + QString::number(proxyPort)); | - | ||||||||||||||||||
| 1473 |     } executed 26 times by 2 tests:   else if (c->command == QFtp::ConnectToHostend of blockExecuted by: 
 
  | 26-1956 | ||||||||||||||||||
| 1474 | - | |||||||||||||||||||
| 1475 | - | |||||||||||||||||||
| 1476 | pi.setProperty("_q_networksession", q->property("_q_networksession")); | - | ||||||||||||||||||
| 1477 | - | |||||||||||||||||||
| 1478 |         if (!proxyHost.isEmpty()
  | 26-631 | ||||||||||||||||||
| 1479 | host = c->rawCmds.at(0); | - | ||||||||||||||||||
| 1480 | port = c->rawCmds.at(1).toUInt(); | - | ||||||||||||||||||
| 1481 | pi.connectToHost(proxyHost, proxyPort); | - | ||||||||||||||||||
| 1482 |         } executed 26 times by 2 tests:   else {end of blockExecuted by: 
  | 26 | ||||||||||||||||||
| 1483 | pi.connectToHost(c->rawCmds.at(0), c->rawCmds.at(1).toUInt()); | - | ||||||||||||||||||
| 1484 |         } executed 631 times by 2 tests:  end of blockExecuted by: 
  | 631 | ||||||||||||||||||
| 1485 | } else { | - | ||||||||||||||||||
| 1486 |         if (c->command == QFtp::Put
  | 43-1913 | ||||||||||||||||||
| 1487 |             if (c->is_ba
  | 15-28 | ||||||||||||||||||
| 1488 | pi.dtp.setData(c->data.ba); | - | ||||||||||||||||||
| 1489 | pi.dtp.setBytesTotal(c->data.ba->size()); | - | ||||||||||||||||||
| 1490 |             } executed 28 times by 1 test:   else if (c->data.devend of blockExecuted by: 
 
 
 
  | 0-28 | ||||||||||||||||||
| 1491 | pi.dtp.setDevice(c->data.dev); | - | ||||||||||||||||||
| 1492 |                 if (c->data.dev->isSequential()
  | 0-15 | ||||||||||||||||||
| 1493 | pi.dtp.setBytesTotal(0); | - | ||||||||||||||||||
| 1494 | pi.dtp.connect(c->data.dev, qFlagLocation("2""readyRead()" "\0" __FILE__ ":" "2292"), qFlagLocation("1""dataReadyRead()" "\0" __FILE__ ":" "2292")); | - | ||||||||||||||||||
| 1495 | pi.dtp.connect(c->data.dev, qFlagLocation("2""readChannelFinished()" "\0" __FILE__ ":" "2293"), qFlagLocation("1""dataReadyRead()" "\0" __FILE__ ":" "2293")); | - | ||||||||||||||||||
| 1496 |                 } never executed:   else {end of block | 0 | ||||||||||||||||||
| 1497 | pi.dtp.setBytesTotal(c->data.dev->size()); | - | ||||||||||||||||||
| 1498 |                 } executed 15 times by 2 tests:  end of blockExecuted by: 
  | 15 | ||||||||||||||||||
| 1499 | } | - | ||||||||||||||||||
| 1500 |         } executed 43 times by 2 tests:   else if (c->command == QFtp::Getend of blockExecuted by: 
 
  | 43-1803 | ||||||||||||||||||
| 1501 |             if (!c->is_ba
 
  | 0-110 | ||||||||||||||||||
| 1502 | pi.dtp.setDevice(c->data.dev); | - | ||||||||||||||||||
| 1503 |             } executed 40 times by 1 test:  end of blockExecuted by: 
  | 40 | ||||||||||||||||||
| 1504 |         } executed 110 times by 2 tests:   else if (c->command == QFtp::Closeend of blockExecuted by: 
 
  | 110-1323 | ||||||||||||||||||
| 1505 | state = QFtp::Closing; | - | ||||||||||||||||||
| 1506 | q->stateChanged(state); | - | ||||||||||||||||||
| 1507 |         } executed 480 times by 2 tests:  end of blockExecuted by: 
  | 480 | ||||||||||||||||||
| 1508 | pi.sendCommands(c->rawCmds); | - | ||||||||||||||||||
| 1509 |     } executed 1956 times by 2 tests:  end of blockExecuted by: 
  | 1956 | ||||||||||||||||||
| 1510 | } | - | ||||||||||||||||||
| 1511 | - | |||||||||||||||||||
| 1512 | - | |||||||||||||||||||
| 1513 | - | |||||||||||||||||||
| 1514 | void QFtpPrivate::_q_piFinished(const QString&) | - | ||||||||||||||||||
| 1515 | { | - | ||||||||||||||||||
| 1516 |     if (pending.isEmpty()
  | 116-2957 | ||||||||||||||||||
| 1517 |         return; executed 116 times by 1 test:  return;Executed by: 
  | 116 | ||||||||||||||||||
| 1518 | QFtpCommand *c = pending.constFirst(); | - | ||||||||||||||||||
| 1519 | - | |||||||||||||||||||
| 1520 |     if (c->command == QFtp::Close
  | 948-2009 | ||||||||||||||||||
| 1521 | - | |||||||||||||||||||
| 1522 | - | |||||||||||||||||||
| 1523 | - | |||||||||||||||||||
| 1524 | - | |||||||||||||||||||
| 1525 |         if (state != QFtp::Unconnected
  | 469-479 | ||||||||||||||||||
| 1526 | close_waitForStateChange = true; | - | ||||||||||||||||||
| 1527 |             return; executed 479 times by 2 tests:  return;Executed by: 
  | 479 | ||||||||||||||||||
| 1528 | } | - | ||||||||||||||||||
| 1529 |     } executed 469 times by 2 tests:  end of blockExecuted by: 
  | 469 | ||||||||||||||||||
| 1530 | q_func()->commandFinished(c->id, false); | - | ||||||||||||||||||
| 1531 | pending.removeFirst(); | - | ||||||||||||||||||
| 1532 | - | |||||||||||||||||||
| 1533 | delete c; | - | ||||||||||||||||||
| 1534 | - | |||||||||||||||||||
| 1535 |     if (pending.isEmpty()
  | 663-1815 | ||||||||||||||||||
| 1536 | q_func()->done(false); | - | ||||||||||||||||||
| 1537 |     } executed 663 times by 2 tests:   else {end of blockExecuted by: 
  | 663 | ||||||||||||||||||
| 1538 | _q_startNextCommand(); | - | ||||||||||||||||||
| 1539 |     } executed 1815 times by 2 tests:  end of blockExecuted by: 
  | 1815 | ||||||||||||||||||
| 1540 | } | - | ||||||||||||||||||
| 1541 | - | |||||||||||||||||||
| 1542 | - | |||||||||||||||||||
| 1543 | - | |||||||||||||||||||
| 1544 | void QFtpPrivate::_q_piError(int errorCode, const QString &text) | - | ||||||||||||||||||
| 1545 | { | - | ||||||||||||||||||
| 1546 | QFtp * const q = q_func(); | - | ||||||||||||||||||
| 1547 | - | |||||||||||||||||||
| 1548 |     if (pending.isEmpty()
  | 0-220 | ||||||||||||||||||
| 1549 | QMessageLogger(__FILE__, 2347, __PRETTY_FUNCTION__).warning("QFtpPrivate::_q_piError was called without pending command!"); | - | ||||||||||||||||||
| 1550 |         return; never executed:  return; | 0 | ||||||||||||||||||
| 1551 | } | - | ||||||||||||||||||
| 1552 | - | |||||||||||||||||||
| 1553 | QFtpCommand *c = pending.constFirst(); | - | ||||||||||||||||||
| 1554 | - | |||||||||||||||||||
| 1555 | - | |||||||||||||||||||
| 1556 |     if (c->command == QFtp::Get
 
  | 16-187 | ||||||||||||||||||
| 1557 | pi.dtp.setBytesTotal(0); | - | ||||||||||||||||||
| 1558 |         return; executed 16 times by 1 test:  return;Executed by: 
  | 16 | ||||||||||||||||||
| 1559 |     } else if (c->command==QFtp::Put
 
  | 0-161 | ||||||||||||||||||
| 1560 |         return; executed 43 times by 2 tests:  return;Executed by: 
  | 43 | ||||||||||||||||||
| 1561 | } | - | ||||||||||||||||||
| 1562 | - | |||||||||||||||||||
| 1563 | error = QFtp::Error(errorCode); | - | ||||||||||||||||||
| 1564 | switch (q->currentCommand()) { | - | ||||||||||||||||||
| 1565 |         case executed 20 times by 2 tests:   QFtp::ConnectToHost:case QFtp::ConnectToHost:Executed by: 
 executed 20 times by 2 tests:  case QFtp::ConnectToHost:Executed by: 
  | 20 | ||||||||||||||||||
| 1566 | errorString = QString::fromLatin1("Connecting to host failed:\n%1") | - | ||||||||||||||||||
| 1567 | .arg(text); | - | ||||||||||||||||||
| 1568 |             break; executed 20 times by 2 tests:  break;Executed by: 
  | 20 | ||||||||||||||||||
| 1569 |         case executed 23 times by 2 tests:   QFtp::Login:case QFtp::Login:Executed by: 
 executed 23 times by 2 tests:  case QFtp::Login:Executed by: 
  | 23 | ||||||||||||||||||
| 1570 | errorString = QString::fromLatin1("Login failed:\n%1") | - | ||||||||||||||||||
| 1571 | .arg(text); | - | ||||||||||||||||||
| 1572 |             break; executed 23 times by 2 tests:  break;Executed by: 
  | 23 | ||||||||||||||||||
| 1573 |         case never executed:   QFtp::List:case QFtp::List:never executed:  case QFtp::List: | 0 | ||||||||||||||||||
| 1574 | errorString = QString::fromLatin1("Listing directory failed:\n%1") | - | ||||||||||||||||||
| 1575 | .arg(text); | - | ||||||||||||||||||
| 1576 |             break; never executed:  break; | 0 | ||||||||||||||||||
| 1577 |         case executed 48 times by 1 test:   QFtp::Cd:case QFtp::Cd:Executed by: 
 executed 48 times by 1 test:  case QFtp::Cd:Executed by: 
  | 48 | ||||||||||||||||||
| 1578 | errorString = QString::fromLatin1("Changing directory failed:\n%1") | - | ||||||||||||||||||
| 1579 | .arg(text); | - | ||||||||||||||||||
| 1580 |             break; executed 48 times by 1 test:  break;Executed by: 
  | 48 | ||||||||||||||||||
| 1581 |         case executed 17 times by 2 tests:   QFtp::Get:case QFtp::Get:Executed by: 
 executed 17 times by 2 tests:  case QFtp::Get:Executed by: 
  | 17 | ||||||||||||||||||
| 1582 | errorString = QString::fromLatin1("Downloading file failed:\n%1") | - | ||||||||||||||||||
| 1583 | .arg(text); | - | ||||||||||||||||||
| 1584 |             break; executed 17 times by 2 tests:  break;Executed by: 
  | 17 | ||||||||||||||||||
| 1585 |         case never executed:   QFtp::Put:case QFtp::Put:never executed:  case QFtp::Put: | 0 | ||||||||||||||||||
| 1586 | errorString = QString::fromLatin1("Uploading file failed:\n%1") | - | ||||||||||||||||||
| 1587 | .arg(text); | - | ||||||||||||||||||
| 1588 |             break; never executed:  break; | 0 | ||||||||||||||||||
| 1589 |         case never executed:   QFtp::Remove:case QFtp::Remove:never executed:  case QFtp::Remove: | 0 | ||||||||||||||||||
| 1590 | errorString = QString::fromLatin1("Removing file failed:\n%1") | - | ||||||||||||||||||
| 1591 | .arg(text); | - | ||||||||||||||||||
| 1592 |             break; never executed:  break; | 0 | ||||||||||||||||||
| 1593 |         case executed 32 times by 1 test:   QFtp::Mkdir:case QFtp::Mkdir:Executed by: 
 executed 32 times by 1 test:  case QFtp::Mkdir:Executed by: 
  | 32 | ||||||||||||||||||
| 1594 | errorString = QString::fromLatin1("Creating directory failed:\n%1") | - | ||||||||||||||||||
| 1595 | .arg(text); | - | ||||||||||||||||||
| 1596 |             break; executed 32 times by 1 test:  break;Executed by: 
  | 32 | ||||||||||||||||||
| 1597 |         case never executed:   QFtp::Rmdir:case QFtp::Rmdir:never executed:  case QFtp::Rmdir: | 0 | ||||||||||||||||||
| 1598 | errorString = QString::fromLatin1("Removing directory failed:\n%1") | - | ||||||||||||||||||
| 1599 | .arg(text); | - | ||||||||||||||||||
| 1600 |             break; never executed:  break; | 0 | ||||||||||||||||||
| 1601 |         default executed 21 times by 2 tests:  :default:Executed by: 
 executed 21 times by 2 tests:  default:Executed by: 
  | 21 | ||||||||||||||||||
| 1602 | errorString = text; | - | ||||||||||||||||||
| 1603 |             break; executed 21 times by 2 tests:  break;Executed by: 
  | 21 | ||||||||||||||||||
| 1604 | } | - | ||||||||||||||||||
| 1605 | - | |||||||||||||||||||
| 1606 | pi.clearPendingCommands(); | - | ||||||||||||||||||
| 1607 | q->clearPendingCommands(); | - | ||||||||||||||||||
| 1608 | q->commandFinished(c->id, true); | - | ||||||||||||||||||
| 1609 | - | |||||||||||||||||||
| 1610 | pending.removeFirst(); | - | ||||||||||||||||||
| 1611 | delete c; | - | ||||||||||||||||||
| 1612 |     if (pending.isEmpty()
  | 4-157 | ||||||||||||||||||
| 1613 |         q->done(true); executed 157 times by 2 tests:  q->done(true);Executed by: 
  | 157 | ||||||||||||||||||
| 1614 | else | - | ||||||||||||||||||
| 1615 |         _q_startNextCommand(); executed 4 times by 1 test:  _q_startNextCommand();Executed by: 
  | 4 | ||||||||||||||||||
| 1616 | } | - | ||||||||||||||||||
| 1617 | - | |||||||||||||||||||
| 1618 | - | |||||||||||||||||||
| 1619 | - | |||||||||||||||||||
| 1620 | void QFtpPrivate::_q_piConnectState(int connectState) | - | ||||||||||||||||||
| 1621 | { | - | ||||||||||||||||||
| 1622 | state = QFtp::State(connectState); | - | ||||||||||||||||||
| 1623 | q_func()->stateChanged(state); | - | ||||||||||||||||||
| 1624 |     if (close_waitForStateChange
  | 469-2278 | ||||||||||||||||||
| 1625 | close_waitForStateChange = false; | - | ||||||||||||||||||
| 1626 | _q_piFinished(QLatin1String("Connection closed")); | - | ||||||||||||||||||
| 1627 |     } executed 469 times by 2 tests:  end of blockExecuted by: 
  | 469 | ||||||||||||||||||
| 1628 | } executed 2747 times by 2 tests:  end of blockExecuted by: 
  | 2747 | ||||||||||||||||||
| 1629 | - | |||||||||||||||||||
| 1630 | - | |||||||||||||||||||
| 1631 | - | |||||||||||||||||||
| 1632 | void QFtpPrivate::_q_piFtpReply(int code, const QString &text) | - | ||||||||||||||||||
| 1633 | { | - | ||||||||||||||||||
| 1634 |     if (q_func()->currentCommand() == QFtp::RawCommand
  | 132-4304 | ||||||||||||||||||
| 1635 | pi.rawCommand = true; | - | ||||||||||||||||||
| 1636 | q_func()->rawCommandReply(code, text); | - | ||||||||||||||||||
| 1637 |     } executed 132 times by 1 test:  end of blockExecuted by: 
  | 132 | ||||||||||||||||||
| 1638 | } executed 4436 times by 2 tests:  end of blockExecuted by: 
  | 4436 | ||||||||||||||||||
| 1639 | - | |||||||||||||||||||
| 1640 | - | |||||||||||||||||||
| 1641 | - | |||||||||||||||||||
| 1642 | - | |||||||||||||||||||
| 1643 | - | |||||||||||||||||||
| 1644 | QFtp::~QFtp() | - | ||||||||||||||||||
| 1645 | { | - | ||||||||||||||||||
| 1646 |     abort(); executed 659 times by 2 tests:  abort();Executed by: 
  | 659 | ||||||||||||||||||
| 1647 | close(); | - | ||||||||||||||||||
| 1648 | } executed 659 times by 2 tests:  end of blockExecuted by: 
  | 659 | ||||||||||||||||||
| 1649 | - | |||||||||||||||||||
| 1650 | - | |||||||||||||||||||
| 1651 | - | |||||||||||||||||||
| 1652 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |