Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/socket/qabstractsocketengine.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count |
---|---|---|
1 | - | |
2 | - | |
3 | - | |
4 | - | |
5 | - | |
6 | - | |
7 | - | |
8 | - | |
9 | - | |
10 | class QSocketEngineHandlerList : public QList<QSocketEngineHandler*> | - |
11 | { | - |
12 | public: | - |
13 | QMutex mutex; | - |
14 | }; | - |
15 | - | |
16 | namespace { namespace Q_QGS_socketHandlers { typedef QSocketEngineHandlerList Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QSocketEngineHandlerList, Q_QGS_socketHandlers::innerFunction, Q_QGS_socketHandlers::guard> socketHandlers; | - |
17 | - | |
18 | QSocketEngineHandler::QSocketEngineHandler() | - |
19 | { | - |
20 | if (!socketHandlers()) | - |
21 | return; | - |
22 | QMutexLocker locker(&socketHandlers()->mutex); | - |
23 | socketHandlers()->prepend(this); | - |
24 | } | - |
25 | - | |
26 | QSocketEngineHandler::~QSocketEngineHandler() | - |
27 | { | - |
28 | if (!socketHandlers()) | - |
29 | return; | - |
30 | QMutexLocker locker(&socketHandlers()->mutex); | - |
31 | socketHandlers()->removeAll(this); | - |
32 | } | - |
33 | - | |
34 | QAbstractSocketEnginePrivate::QAbstractSocketEnginePrivate() | - |
35 | : socketError(QAbstractSocket::UnknownSocketError) | - |
36 | , hasSetSocketError(false) | - |
37 | , socketErrorString(QLatin1String("Unknown error")) | - |
38 | , socketState(QAbstractSocket::UnconnectedState) | - |
39 | , socketType(QAbstractSocket::UnknownSocketType) | - |
40 | , socketProtocol(QAbstractSocket::UnknownNetworkLayerProtocol) | - |
41 | , localPort(0) | - |
42 | , peerPort(0) | - |
43 | , inboundStreamCount(0) | - |
44 | , outboundStreamCount(0) | - |
45 | , receiver(0) | - |
46 | { | - |
47 | } executed 72401 times by 31 tests: end of block Executed by:
| 72401 |
48 | - | |
49 | QAbstractSocketEngine::QAbstractSocketEngine(QObject *parent) | - |
50 | : QObject(*new QAbstractSocketEnginePrivate(), parent) | - |
51 | { | - |
52 | } | - |
53 | - | |
54 | QAbstractSocketEngine::QAbstractSocketEngine(QAbstractSocketEnginePrivate &dd, QObject* parent) | - |
55 | : QObject(dd, parent) | - |
56 | { | - |
57 | } | - |
58 | - | |
59 | QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(QAbstractSocket::SocketType socketType, const QNetworkProxy &proxy, QObject *parent) | - |
60 | { | - |
61 | - | |
62 | - | |
63 | if (proxy.type() == QNetworkProxy::DefaultProxy) | - |
64 | return 0; | - |
65 | - | |
66 | - | |
67 | QMutexLocker locker(&socketHandlers()->mutex); | - |
68 | for (int i = 0; i < socketHandlers()->size(); i++) { | - |
69 | if (QAbstractSocketEngine *ret = socketHandlers()->at(i)->createSocketEngine(socketType, proxy, parent)) | - |
70 | return ret; | - |
71 | } | - |
72 | - | |
73 | - | |
74 | - | |
75 | if (proxy.type() != QNetworkProxy::NoProxy) | - |
76 | return 0; | - |
77 | - | |
78 | - | |
79 | return new QNativeSocketEngine(parent); | - |
80 | } | - |
81 | - | |
82 | QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(qintptr socketDescripter, QObject *parent) | - |
83 | { | - |
84 | QMutexLocker locker(&socketHandlers()->mutex); | - |
85 | for (int i = 0; i < socketHandlers()->size(); i++) { | - |
86 | if (QAbstractSocketEngine *ret = socketHandlers()->at(i)->createSocketEngine(socketDescripter, parent)) | - |
87 | return ret; | - |
88 | } | - |
89 | return new QNativeSocketEngine(parent); | - |
90 | } | - |
91 | - | |
92 | QAbstractSocket::SocketError QAbstractSocketEngine::error() const | - |
93 | { | - |
94 | return d_func()->socketError; | - |
95 | } | - |
96 | - | |
97 | QString QAbstractSocketEngine::errorString() const | - |
98 | { | - |
99 | return d_func()->socketErrorString; | - |
100 | } | - |
101 | - | |
102 | void QAbstractSocketEngine::setError(QAbstractSocket::SocketError error, const QString &errorString) const | - |
103 | { | - |
104 | const QAbstractSocketEnginePrivate * const d = d_func(); | - |
105 | d->socketError = error; | - |
106 | d->socketErrorString = errorString; | - |
107 | } | - |
108 | - | |
109 | void QAbstractSocketEngine::setReceiver(QAbstractSocketEngineReceiver *receiver) | - |
110 | { | - |
111 | d_func()->receiver = receiver; | - |
112 | } | - |
113 | - | |
114 | void QAbstractSocketEngine::readNotification() | - |
115 | { | - |
116 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) | - |
117 | receiver->readNotification(); | - |
118 | } | - |
119 | - | |
120 | void QAbstractSocketEngine::writeNotification() | - |
121 | { | - |
122 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) | - |
123 | receiver->writeNotification(); | - |
124 | } | - |
125 | - | |
126 | void QAbstractSocketEngine::exceptionNotification() | - |
127 | { | - |
128 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) | - |
129 | receiver->exceptionNotification(); | - |
130 | } | - |
131 | - | |
132 | void QAbstractSocketEngine::closeNotification() | - |
133 | { | - |
134 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) | - |
135 | receiver->closeNotification(); | - |
136 | } | - |
137 | - | |
138 | void QAbstractSocketEngine::connectionNotification() | - |
139 | { | - |
140 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) | - |
141 | receiver->connectionNotification(); | - |
142 | } | - |
143 | - | |
144 | - | |
145 | void QAbstractSocketEngine::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator) | - |
146 | { | - |
147 | if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver) | - |
148 | receiver->proxyAuthenticationRequired(proxy, authenticator); | - |
149 | } | - |
150 | - | |
151 | - | |
152 | - | |
153 | QAbstractSocket::SocketState QAbstractSocketEngine::state() const | - |
154 | { | - |
155 | return d_func()->socketState; | - |
156 | } | - |
157 | - | |
158 | void QAbstractSocketEngine::setState(QAbstractSocket::SocketState state) | - |
159 | { | - |
160 | d_func()->socketState = state; | - |
161 | } | - |
162 | - | |
163 | QAbstractSocket::SocketType QAbstractSocketEngine::socketType() const | - |
164 | { | - |
165 | return d_func()->socketType; | - |
166 | } | - |
167 | - | |
168 | void QAbstractSocketEngine::setSocketType(QAbstractSocket::SocketType socketType) | - |
169 | { | - |
170 | d_func()->socketType = socketType; | - |
171 | } | - |
172 | - | |
173 | QAbstractSocket::NetworkLayerProtocol QAbstractSocketEngine::protocol() const | - |
174 | { | - |
175 | return d_func()->socketProtocol; | - |
176 | } | - |
177 | - | |
178 | void QAbstractSocketEngine::setProtocol(QAbstractSocket::NetworkLayerProtocol protocol) | - |
179 | { | - |
180 | d_func()->socketProtocol = protocol; | - |
181 | } | - |
182 | - | |
183 | QHostAddress QAbstractSocketEngine::localAddress() const | - |
184 | { | - |
185 | return d_func()->localAddress; | - |
186 | } | - |
187 | - | |
188 | void QAbstractSocketEngine::setLocalAddress(const QHostAddress &address) | - |
189 | { | - |
190 | d_func()->localAddress = address; | - |
191 | } | - |
192 | - | |
193 | quint16 QAbstractSocketEngine::localPort() const | - |
194 | { | - |
195 | return d_func()->localPort; | - |
196 | } | - |
197 | - | |
198 | void QAbstractSocketEngine::setLocalPort(quint16 port) | - |
199 | { | - |
200 | d_func()->localPort = port; | - |
201 | } | - |
202 | - | |
203 | QHostAddress QAbstractSocketEngine::peerAddress() const | - |
204 | { | - |
205 | return d_func()->peerAddress; | - |
206 | } | - |
207 | - | |
208 | void QAbstractSocketEngine::setPeerAddress(const QHostAddress &address) | - |
209 | { | - |
210 | d_func()->peerAddress = address; | - |
211 | } | - |
212 | - | |
213 | quint16 QAbstractSocketEngine::peerPort() const | - |
214 | { | - |
215 | return d_func()->peerPort; | - |
216 | } | - |
217 | - | |
218 | void QAbstractSocketEngine::setPeerPort(quint16 port) | - |
219 | { | - |
220 | d_func()->peerPort = port; | - |
221 | } | - |
222 | - | |
223 | int QAbstractSocketEngine::inboundStreamCount() const | - |
224 | { | - |
225 | return executed 5201 times by 29 tests: d_func()->inboundStreamCount;return d_func()->inboundStreamCount; Executed by:
executed 5201 times by 29 tests: return d_func()->inboundStreamCount; Executed by:
| 5201 |
226 | } | - |
227 | - | |
228 | int QAbstractSocketEngine::outboundStreamCount() const | - |
229 | { | - |
230 | return executed 5204 times by 29 tests: d_func()->outboundStreamCountreturn d_func()->outboundStreamCount; Executed by:
executed 5204 times by 29 tests: return d_func()->outboundStreamCount; Executed by:
executed 5204 times by 29 tests: ;return d_func()->outboundStreamCount; Executed by:
executed 5204 times by 29 tests: return d_func()->outboundStreamCount; Executed by:
| 5204 |
231 | } | - |
232 | - | |
233 | - | |
Switch to Source code | Preprocessed file |