| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtNetwork module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | #include "qabstractsocketengine_p.h" | - |
| 43 | | - |
| 44 | #include "qnativesocketengine_p.h" | - |
| 45 | | - |
| 46 | #include "qmutex.h" | - |
| 47 | #include "qnetworkproxy.h" | - |
| 48 | | - |
| 49 | QT_BEGIN_NAMESPACE | - |
| 50 | | - |
| 51 | class QSocketEngineHandlerList : public QList<QSocketEngineHandler*> | - |
| 52 | { | - |
| 53 | public: | - |
| 54 | QMutex mutex; | - |
| 55 | }; | - |
| 56 | | - |
| 57 | Q_GLOBAL_STATIC(QSocketEngineHandlerList, socketHandlers) never executed: delete x; executed: return thisGlobalStatic.pointer.load();Execution Count:21227 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)| no Evaluation Count:0 | yes Evaluation Count:23 |
evaluated: !thisGlobalStatic.pointer.load()| yes Evaluation Count:23 | yes Evaluation Count:21204 |
partially evaluated: !thisGlobalStatic.destroyed| yes Evaluation Count:23 | no Evaluation Count:0 |
| 0-21227 |
| 58 | | - |
| 59 | QSocketEngineHandler::QSocketEngineHandler() | - |
| 60 | { | - |
| 61 | if (!socketHandlers()) partially evaluated: !socketHandlers()| no Evaluation Count:0 | yes Evaluation Count:46 |
| 0-46 |
| 62 | return; | 0 |
| 63 | QMutexLocker locker(&socketHandlers()->mutex); executed (the execution status of this line is deduced): QMutexLocker locker(&socketHandlers()->mutex); | - |
| 64 | socketHandlers()->prepend(this); executed (the execution status of this line is deduced): socketHandlers()->prepend(this); | - |
| 65 | } executed: }Execution Count:46 | 46 |
| 66 | | - |
| 67 | QSocketEngineHandler::~QSocketEngineHandler() | - |
| 68 | { | - |
| 69 | if (!socketHandlers()) partially evaluated: !socketHandlers()| no Evaluation Count:0 | yes Evaluation Count:46 |
| 0-46 |
| 70 | return; | 0 |
| 71 | QMutexLocker locker(&socketHandlers()->mutex); executed (the execution status of this line is deduced): QMutexLocker locker(&socketHandlers()->mutex); | - |
| 72 | socketHandlers()->removeAll(this); executed (the execution status of this line is deduced): socketHandlers()->removeAll(this); | - |
| 73 | } executed: }Execution Count:46 | 46 |
| 74 | | - |
| 75 | QAbstractSocketEnginePrivate::QAbstractSocketEnginePrivate() | - |
| 76 | : socketError(QAbstractSocket::UnknownSocketError) | - |
| 77 | , hasSetSocketError(false) | - |
| 78 | , socketErrorString(QLatin1String(QT_TRANSLATE_NOOP(QSocketLayer, "Unknown error"))) | - |
| 79 | , socketState(QAbstractSocket::UnconnectedState) | - |
| 80 | , socketType(QAbstractSocket::UnknownSocketType) | - |
| 81 | , socketProtocol(QAbstractSocket::UnknownNetworkLayerProtocol) | - |
| 82 | , localPort(0) | - |
| 83 | , peerPort(0) | - |
| 84 | , receiver(0) | - |
| 85 | { | - |
| 86 | } executed: }Execution Count:3522 | 3522 |
| 87 | | - |
| 88 | QAbstractSocketEngine::QAbstractSocketEngine(QObject *parent) | - |
| 89 | : QObject(*new QAbstractSocketEnginePrivate(), parent) | - |
| 90 | { | - |
| 91 | } | 0 |
| 92 | | - |
| 93 | QAbstractSocketEngine::QAbstractSocketEngine(QAbstractSocketEnginePrivate &dd, QObject* parent) | - |
| 94 | : QObject(dd, parent) | - |
| 95 | { | - |
| 96 | } executed: }Execution Count:3522 | 3522 |
| 97 | | - |
| 98 | QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(QAbstractSocket::SocketType socketType, const QNetworkProxy &proxy, QObject *parent) | - |
| 99 | { | - |
| 100 | #ifndef QT_NO_NETWORKPROXY | - |
| 101 | // proxy type must have been resolved by now | - |
| 102 | if (proxy.type() == QNetworkProxy::DefaultProxy) evaluated: proxy.type() == QNetworkProxy::DefaultProxy| yes Evaluation Count:6 | yes Evaluation Count:2906 |
| 6-2906 |
| 103 | return 0; executed: return 0;Execution Count:6 | 6 |
| 104 | #endif | - |
| 105 | | - |
| 106 | QMutexLocker locker(&socketHandlers()->mutex); executed (the execution status of this line is deduced): QMutexLocker locker(&socketHandlers()->mutex); | - |
| 107 | for (int i = 0; i < socketHandlers()->size(); i++) { evaluated: i < socketHandlers()->size()| yes Evaluation Count:5795 | yes Evaluation Count:2761 |
| 2761-5795 |
| 108 | if (QAbstractSocketEngine *ret = socketHandlers()->at(i)->createSocketEngine(socketType, proxy, parent)) evaluated: QAbstractSocketEngine *ret = socketHandlers()->at(i)->createSocketEngine(socketType, proxy, parent)| yes Evaluation Count:145 | yes Evaluation Count:5650 |
| 145-5650 |
| 109 | return ret; executed: return ret;Execution Count:145 | 145 |
| 110 | } executed: }Execution Count:5650 | 5650 |
| 111 | | - |
| 112 | #ifndef QT_NO_NETWORKPROXY | - |
| 113 | // only NoProxy can have reached here | - |
| 114 | if (proxy.type() != QNetworkProxy::NoProxy) partially evaluated: proxy.type() != QNetworkProxy::NoProxy| no Evaluation Count:0 | yes Evaluation Count:2761 |
| 0-2761 |
| 115 | return 0; never executed: return 0; | 0 |
| 116 | #endif | - |
| 117 | | - |
| 118 | return new QNativeSocketEngine(parent); executed: return new QNativeSocketEngine(parent);Execution Count:2761 | 2761 |
| 119 | } | - |
| 120 | | - |
| 121 | QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(qintptr socketDescripter, QObject *parent) | - |
| 122 | { | - |
| 123 | QMutexLocker locker(&socketHandlers()->mutex); executed (the execution status of this line is deduced): QMutexLocker locker(&socketHandlers()->mutex); | - |
| 124 | for (int i = 0; i < socketHandlers()->size(); i++) { evaluated: i < socketHandlers()->size()| yes Evaluation Count:1232 | yes Evaluation Count:615 |
| 615-1232 |
| 125 | if (QAbstractSocketEngine *ret = socketHandlers()->at(i)->createSocketEngine(socketDescripter, parent)) evaluated: QAbstractSocketEngine *ret = socketHandlers()->at(i)->createSocketEngine(socketDescripter, parent)| yes Evaluation Count:1 | yes Evaluation Count:1231 |
| 1-1231 |
| 126 | return ret; executed: return ret;Execution Count:1 | 1 |
| 127 | } executed: }Execution Count:1231 | 1231 |
| 128 | return new QNativeSocketEngine(parent); executed: return new QNativeSocketEngine(parent);Execution Count:615 | 615 |
| 129 | } | - |
| 130 | | - |
| 131 | QAbstractSocket::SocketError QAbstractSocketEngine::error() const | - |
| 132 | { | - |
| 133 | return d_func()->socketError; executed: return d_func()->socketError;Execution Count:942 | 942 |
| 134 | } | - |
| 135 | | - |
| 136 | QString QAbstractSocketEngine::errorString() const | - |
| 137 | { | - |
| 138 | return d_func()->socketErrorString; executed: return d_func()->socketErrorString;Execution Count:460 | 460 |
| 139 | } | - |
| 140 | | - |
| 141 | void QAbstractSocketEngine::setError(QAbstractSocket::SocketError error, const QString &errorString) const | - |
| 142 | { | - |
| 143 | Q_D(const QAbstractSocketEngine); executed (the execution status of this line is deduced): const QAbstractSocketEnginePrivate * const d = d_func(); | - |
| 144 | d->socketError = error; executed (the execution status of this line is deduced): d->socketError = error; | - |
| 145 | d->socketErrorString = errorString; executed (the execution status of this line is deduced): d->socketErrorString = errorString; | - |
| 146 | } executed: }Execution Count:44 | 44 |
| 147 | | - |
| 148 | void QAbstractSocketEngine::setReceiver(QAbstractSocketEngineReceiver *receiver) | - |
| 149 | { | - |
| 150 | d_func()->receiver = receiver; executed (the execution status of this line is deduced): d_func()->receiver = receiver; | - |
| 151 | } executed: }Execution Count:3508 | 3508 |
| 152 | | - |
| 153 | void QAbstractSocketEngine::readNotification() | - |
| 154 | { | - |
| 155 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) partially evaluated: QAbstractSocketEngineReceiver *receiver = d_func()->receiver| yes Evaluation Count:9772 | no Evaluation Count:0 |
| 0-9772 |
| 156 | receiver->readNotification(); executed: receiver->readNotification();Execution Count:9772 | 9772 |
| 157 | } executed: }Execution Count:9772 | 9772 |
| 158 | | - |
| 159 | void QAbstractSocketEngine::writeNotification() | - |
| 160 | { | - |
| 161 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) partially evaluated: QAbstractSocketEngineReceiver *receiver = d_func()->receiver| yes Evaluation Count:7469 | no Evaluation Count:0 |
| 0-7469 |
| 162 | receiver->writeNotification(); executed: receiver->writeNotification();Execution Count:7469 | 7469 |
| 163 | } executed: }Execution Count:7469 | 7469 |
| 164 | | - |
| 165 | void QAbstractSocketEngine::exceptionNotification() | - |
| 166 | { | - |
| 167 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) never evaluated: QAbstractSocketEngineReceiver *receiver = d_func()->receiver | 0 |
| 168 | receiver->exceptionNotification(); never executed: receiver->exceptionNotification(); | 0 |
| 169 | } | 0 |
| 170 | | - |
| 171 | void QAbstractSocketEngine::closeNotification() | - |
| 172 | { | - |
| 173 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) never evaluated: QAbstractSocketEngineReceiver *receiver = d_func()->receiver | 0 |
| 174 | receiver->closeNotification(); never executed: receiver->closeNotification(); | 0 |
| 175 | } | 0 |
| 176 | | - |
| 177 | void QAbstractSocketEngine::connectionNotification() | - |
| 178 | { | - |
| 179 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) partially evaluated: QAbstractSocketEngineReceiver *receiver = d_func()->receiver| yes Evaluation Count:839 | no Evaluation Count:0 |
| 0-839 |
| 180 | receiver->connectionNotification(); executed: receiver->connectionNotification();Execution Count:839 | 839 |
| 181 | } executed: }Execution Count:839 | 839 |
| 182 | | - |
| 183 | #ifndef QT_NO_NETWORKPROXY | - |
| 184 | void QAbstractSocketEngine::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator) | - |
| 185 | { | - |
| 186 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) partially evaluated: QAbstractSocketEngineReceiver *receiver = d_func()->receiver| yes Evaluation Count:33 | no Evaluation Count:0 |
| 0-33 |
| 187 | receiver->proxyAuthenticationRequired(proxy, authenticator); executed: receiver->proxyAuthenticationRequired(proxy, authenticator);Execution Count:33 | 33 |
| 188 | } executed: }Execution Count:33 | 33 |
| 189 | #endif | - |
| 190 | | - |
| 191 | | - |
| 192 | QAbstractSocket::SocketState QAbstractSocketEngine::state() const | - |
| 193 | { | - |
| 194 | return d_func()->socketState; executed: return d_func()->socketState;Execution Count:31640 | 31640 |
| 195 | } | - |
| 196 | | - |
| 197 | void QAbstractSocketEngine::setState(QAbstractSocket::SocketState state) | - |
| 198 | { | - |
| 199 | d_func()->socketState = state; executed (the execution status of this line is deduced): d_func()->socketState = state; | - |
| 200 | } executed: }Execution Count:217 | 217 |
| 201 | | - |
| 202 | QAbstractSocket::SocketType QAbstractSocketEngine::socketType() const | - |
| 203 | { | - |
| 204 | return d_func()->socketType; executed: return d_func()->socketType;Execution Count:199 | 199 |
| 205 | } | - |
| 206 | | - |
| 207 | void QAbstractSocketEngine::setSocketType(QAbstractSocket::SocketType socketType) | - |
| 208 | { | - |
| 209 | d_func()->socketType = socketType; executed (the execution status of this line is deduced): d_func()->socketType = socketType; | - |
| 210 | } executed: }Execution Count:17 | 17 |
| 211 | | - |
| 212 | QAbstractSocket::NetworkLayerProtocol QAbstractSocketEngine::protocol() const | - |
| 213 | { | - |
| 214 | return d_func()->socketProtocol; executed: return d_func()->socketProtocol;Execution Count:442 | 442 |
| 215 | } | - |
| 216 | | - |
| 217 | void QAbstractSocketEngine::setProtocol(QAbstractSocket::NetworkLayerProtocol protocol) | - |
| 218 | { | - |
| 219 | d_func()->socketProtocol = protocol; executed (the execution status of this line is deduced): d_func()->socketProtocol = protocol; | - |
| 220 | } executed: }Execution Count:17 | 17 |
| 221 | | - |
| 222 | QHostAddress QAbstractSocketEngine::localAddress() const | - |
| 223 | { | - |
| 224 | return d_func()->localAddress; executed: return d_func()->localAddress;Execution Count:2591 | 2591 |
| 225 | } | - |
| 226 | | - |
| 227 | void QAbstractSocketEngine::setLocalAddress(const QHostAddress &address) | - |
| 228 | { | - |
| 229 | d_func()->localAddress = address; executed (the execution status of this line is deduced): d_func()->localAddress = address; | - |
| 230 | } executed: }Execution Count:15 | 15 |
| 231 | | - |
| 232 | quint16 QAbstractSocketEngine::localPort() const | - |
| 233 | { | - |
| 234 | return d_func()->localPort; executed: return d_func()->localPort;Execution Count:3005 | 3005 |
| 235 | } | - |
| 236 | | - |
| 237 | void QAbstractSocketEngine::setLocalPort(quint16 port) | - |
| 238 | { | - |
| 239 | d_func()->localPort = port; executed (the execution status of this line is deduced): d_func()->localPort = port; | - |
| 240 | } executed: }Execution Count:15 | 15 |
| 241 | | - |
| 242 | QHostAddress QAbstractSocketEngine::peerAddress() const | - |
| 243 | { | - |
| 244 | return d_func()->peerAddress; executed: return d_func()->peerAddress;Execution Count:1863 | 1863 |
| 245 | } | - |
| 246 | | - |
| 247 | void QAbstractSocketEngine::setPeerAddress(const QHostAddress &address) | - |
| 248 | { | - |
| 249 | d_func()->peerAddress = address; executed (the execution status of this line is deduced): d_func()->peerAddress = address; | - |
| 250 | } executed: }Execution Count:68 | 68 |
| 251 | | - |
| 252 | quint16 QAbstractSocketEngine::peerPort() const | - |
| 253 | { | - |
| 254 | return d_func()->peerPort; executed: return d_func()->peerPort;Execution Count:1863 | 1863 |
| 255 | } | - |
| 256 | | - |
| 257 | void QAbstractSocketEngine::setPeerPort(quint16 port) | - |
| 258 | { | - |
| 259 | d_func()->peerPort = port; executed (the execution status of this line is deduced): d_func()->peerPort = port; | - |
| 260 | } executed: }Execution Count:68 | 68 |
| 261 | | - |
| 262 | QT_END_NAMESPACE | - |
| 263 | | - |
| | |