Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | class QSocks5SocketEngineHandler; | - |
11 | class QHttpSocketEngineHandler; | - |
12 | | - |
13 | class QGlobalNetworkProxy | - |
14 | { | - |
15 | public: | - |
16 | QGlobalNetworkProxy() | - |
17 | : mutex(QMutex::Recursive) | - |
18 | , applicationLevelProxy(0) | - |
19 | , applicationLevelProxyFactory(0) | - |
20 | | - |
21 | , socks5SocketEngineHandler(0) | - |
22 | | - |
23 | | - |
24 | , httpSocketEngineHandler(0) | - |
25 | | - |
26 | { | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | socks5SocketEngineHandler = new QSocks5SocketEngineHandler(); | - |
32 | | - |
33 | | - |
34 | httpSocketEngineHandler = new QHttpSocketEngineHandler(); | - |
35 | | - |
36 | } executed: } Execution Count:23 | 23 |
37 | | - |
38 | ~QGlobalNetworkProxy() | - |
39 | { | - |
40 | delete applicationLevelProxy; | - |
41 | delete applicationLevelProxyFactory; | - |
42 | | - |
43 | delete socks5SocketEngineHandler; | - |
44 | | - |
45 | | - |
46 | delete httpSocketEngineHandler; | - |
47 | | - |
48 | } executed: } Execution Count:23 | 23 |
49 | | - |
50 | void setApplicationProxy(const QNetworkProxy &proxy) | - |
51 | { | - |
52 | QMutexLocker lock(&mutex); | - |
53 | if (!applicationLevelProxy) evaluated: !applicationLevelProxy yes Evaluation Count:3 | yes Evaluation Count:373 |
| 3-373 |
54 | applicationLevelProxy = new QNetworkProxy; executed: applicationLevelProxy = new QNetworkProxy; Execution Count:3 | 3 |
55 | *applicationLevelProxy = proxy; | - |
56 | delete applicationLevelProxyFactory; | - |
57 | applicationLevelProxyFactory = 0; | - |
58 | } executed: } Execution Count:376 | 376 |
59 | | - |
60 | void setApplicationProxyFactory(QNetworkProxyFactory *factory) | - |
61 | { | - |
62 | QMutexLocker lock(&mutex); | - |
63 | if (factory == applicationLevelProxyFactory) partially evaluated: factory == applicationLevelProxyFactory no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
64 | return; | 0 |
65 | if (applicationLevelProxy) evaluated: applicationLevelProxy yes Evaluation Count:7 | yes Evaluation Count:1 |
| 1-7 |
66 | *applicationLevelProxy = QNetworkProxy(); executed: *applicationLevelProxy = QNetworkProxy(); Execution Count:7 | 7 |
67 | delete applicationLevelProxyFactory; | - |
68 | applicationLevelProxyFactory = factory; | - |
69 | } executed: } Execution Count:8 | 8 |
70 | | - |
71 | QNetworkProxy applicationProxy() | - |
72 | { | - |
73 | return proxyForQuery(QNetworkProxyQuery()).first(); executed: return proxyForQuery(QNetworkProxyQuery()).first(); Execution Count:856 | 856 |
74 | } | - |
75 | | - |
76 | QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query); | - |
77 | | - |
78 | private: | - |
79 | QMutex mutex; | - |
80 | QNetworkProxy *applicationLevelProxy; | - |
81 | QNetworkProxyFactory *applicationLevelProxyFactory; | - |
82 | | - |
83 | QSocks5SocketEngineHandler *socks5SocketEngineHandler; | - |
84 | | - |
85 | | - |
86 | QHttpSocketEngineHandler *httpSocketEngineHandler; | - |
87 | | - |
88 | }; | - |
89 | | - |
90 | QList<QNetworkProxy> QGlobalNetworkProxy::proxyForQuery(const QNetworkProxyQuery &query) | - |
91 | { | - |
92 | QMutexLocker locker(&mutex); | - |
93 | | - |
94 | QList<QNetworkProxy> result; | - |
95 | | - |
96 | | - |
97 | QHostAddress parsed; | - |
98 | QString hostname = query.url().host(); | - |
99 | if (hostname == QLatin1String("localhost") evaluated: hostname == QLatin1String("localhost") yes Evaluation Count:1133 | yes Evaluation Count:2452 |
| 1133-2452 |
100 | || hostname.startsWith(QLatin1String("localhost.")) partially evaluated: hostname.startsWith(QLatin1String("localhost.")) no Evaluation Count:0 | yes Evaluation Count:2452 |
| 0-2452 |
101 | || (parsed.setAddress(hostname) evaluated: parsed.setAddress(hostname) yes Evaluation Count:371 | yes Evaluation Count:2081 |
| 371-2081 |
102 | && (parsed.isLoopback()))) { evaluated: (parsed.isLoopback()) yes Evaluation Count:319 | yes Evaluation Count:52 |
| 52-319 |
103 | result << QNetworkProxy(QNetworkProxy::NoProxy); | - |
104 | return result; executed: return result; Execution Count:1452 | 1452 |
105 | } | - |
106 | | - |
107 | if (!applicationLevelProxyFactory) { evaluated: !applicationLevelProxyFactory yes Evaluation Count:2126 | yes Evaluation Count:7 |
| 7-2126 |
108 | if (applicationLevelProxy evaluated: applicationLevelProxy yes Evaluation Count:389 | yes Evaluation Count:1737 |
| 389-1737 |
109 | && applicationLevelProxy->type() != QNetworkProxy::DefaultProxy) partially evaluated: applicationLevelProxy->type() != QNetworkProxy::DefaultProxy yes Evaluation Count:389 | no Evaluation Count:0 |
| 0-389 |
110 | result << *applicationLevelProxy; executed: result << *applicationLevelProxy; Execution Count:389 | 389 |
111 | else | - |
112 | result << QNetworkProxy(QNetworkProxy::NoProxy); executed: result << QNetworkProxy(QNetworkProxy::NoProxy); Execution Count:1737 | 1737 |
113 | return result; executed: return result; Execution Count:2126 | 2126 |
114 | } | - |
115 | | - |
116 | | - |
117 | result = applicationLevelProxyFactory->queryProxy(query); | - |
118 | if (result.isEmpty()) { partially evaluated: result.isEmpty() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
119 | QMessageLogger("kernel/qnetworkproxy.cpp", 349, __PRETTY_FUNCTION__).warning("QNetworkProxyFactory: factory %p has returned an empty result set", | - |
120 | applicationLevelProxyFactory); | - |
121 | result << QNetworkProxy(QNetworkProxy::NoProxy); | - |
122 | } | 0 |
123 | return result; executed: return result; Execution Count:7 | 7 |
124 | } | - |
125 | | - |
126 | static QGlobalNetworkProxy *globalNetworkProxy() { static QGlobalStatic<QGlobalNetworkProxy > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QGlobalNetworkProxy *x = new QGlobalNetworkProxy; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QGlobalNetworkProxy > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } 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:30948 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:23 | no Evaluation Count:0 |
never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:30971 | 0-30971 |
127 | | - |
128 | namespace { | - |
129 | template<bool> struct StaticAssertTest; | - |
130 | template<> struct StaticAssertTest<true> { enum { Value = 1 }; }; | - |
131 | } | - |
132 | | - |
133 | static inline void qt_noop_with_arg(int) {} | - |
134 | | - |
135 | | - |
136 | static QNetworkProxy::Capabilities defaultCapabilitiesForType(QNetworkProxy::ProxyType type) | - |
137 | { | - |
138 | qt_noop_with_arg(sizeof(StaticAssertTest< int(QNetworkProxy::DefaultProxy) == 0 >::Value)); | - |
139 | qt_noop_with_arg(sizeof(StaticAssertTest< int(QNetworkProxy::FtpCachingProxy) == 5 >::Value)); | - |
140 | static const int defaults[] = | - |
141 | { | - |
142 | | - |
143 | (int(QNetworkProxy::ListeningCapability) | | - |
144 | int(QNetworkProxy::TunnelingCapability) | | - |
145 | int(QNetworkProxy::UdpTunnelingCapability)), | - |
146 | | - |
147 | (int(QNetworkProxy::TunnelingCapability) | | - |
148 | int(QNetworkProxy::ListeningCapability) | | - |
149 | int(QNetworkProxy::UdpTunnelingCapability) | | - |
150 | int(QNetworkProxy::HostNameLookupCapability)), | - |
151 | | - |
152 | | - |
153 | (int(QNetworkProxy::ListeningCapability) | | - |
154 | int(QNetworkProxy::TunnelingCapability) | | - |
155 | int(QNetworkProxy::UdpTunnelingCapability)), | - |
156 | | - |
157 | (int(QNetworkProxy::TunnelingCapability) | | - |
158 | int(QNetworkProxy::CachingCapability) | | - |
159 | int(QNetworkProxy::HostNameLookupCapability)), | - |
160 | | - |
161 | (int(QNetworkProxy::CachingCapability) | | - |
162 | int(QNetworkProxy::HostNameLookupCapability)), | - |
163 | | - |
164 | (int(QNetworkProxy::CachingCapability) | | - |
165 | int(QNetworkProxy::HostNameLookupCapability)), | - |
166 | }; | - |
167 | | - |
168 | if (int(type) < 0 || int(type) > int(QNetworkProxy::FtpCachingProxy)) partially evaluated: int(type) < 0 no Evaluation Count:0 | yes Evaluation Count:5987 |
partially evaluated: int(type) > int(QNetworkProxy::FtpCachingProxy) no Evaluation Count:0 | yes Evaluation Count:5987 |
| 0-5987 |
169 | type = QNetworkProxy::DefaultProxy; never executed: type = QNetworkProxy::DefaultProxy; | 0 |
170 | return QNetworkProxy::Capabilities(defaults[int(type)]); executed: return QNetworkProxy::Capabilities(defaults[int(type)]); Execution Count:5987 | 5987 |
171 | } | - |
172 | | - |
173 | class QNetworkProxyPrivate: public QSharedData | - |
174 | { | - |
175 | public: | - |
176 | QString hostName; | - |
177 | QString user; | - |
178 | QString password; | - |
179 | QNetworkProxy::Capabilities capabilities; | - |
180 | quint16 port; | - |
181 | QNetworkProxy::ProxyType type; | - |
182 | bool capabilitiesSet; | - |
183 | QNetworkHeadersPrivate headers; | - |
184 | | - |
185 | inline QNetworkProxyPrivate(QNetworkProxy::ProxyType t = QNetworkProxy::DefaultProxy, | - |
186 | const QString &h = QString(), quint16 p = 0, | - |
187 | const QString &u = QString(), const QString &pw = QString()) | - |
188 | : hostName(h), | - |
189 | user(u), | - |
190 | password(pw), | - |
191 | capabilities(defaultCapabilitiesForType(t)), | - |
192 | port(p), | - |
193 | type(t), | - |
194 | capabilitiesSet(false) | - |
195 | { } executed: } Execution Count:5982 | 5982 |
196 | | - |
197 | inline bool operator==(const QNetworkProxyPrivate &other) const | - |
198 | { | - |
199 | return type == other.type && | 1 |
200 | port == other.port && | 1 |
201 | hostName == other.hostName && | 1 |
202 | user == other.user && | 1 |
203 | password == other.password && | 1 |
204 | capabilities == other.capabilities; executed: return type == other.type && port == other.port && hostName == other.hostName && user == other.user && password == other.password && capabilities == other.capabilities; Execution Count:1 | 1 |
205 | } | - |
206 | }; | - |
207 | | - |
208 | template<> void QSharedDataPointer<QNetworkProxyPrivate>::detach() | - |
209 | { | - |
210 | if (d && d->ref.load() == 1) evaluated: d yes Evaluation Count:181 | yes Evaluation Count:1 |
evaluated: d->ref.load() == 1 yes Evaluation Count:98 | yes Evaluation Count:83 |
| 1-181 |
211 | return; executed: return; Execution Count:98 | 98 |
212 | QNetworkProxyPrivate *x = (d ? new QNetworkProxyPrivate(*d) evaluated: d yes Evaluation Count:83 | yes Evaluation Count:1 |
| 1-83 |
213 | : new QNetworkProxyPrivate); | - |
214 | x->ref.ref(); | - |
215 | if (d && !d->ref.deref()) evaluated: d yes Evaluation Count:83 | yes Evaluation Count:1 |
partially evaluated: !d->ref.deref() no Evaluation Count:0 | yes Evaluation Count:83 |
| 0-83 |
216 | delete d; never executed: delete d; | 0 |
217 | d = x; | - |
218 | } executed: } Execution Count:84 | 84 |
219 | | - |
220 | | - |
221 | | - |
222 | | - |
223 | | - |
224 | | - |
225 | | - |
226 | QNetworkProxy::QNetworkProxy() | - |
227 | : d(0) | - |
228 | { | - |
229 | | - |
230 | | - |
231 | | - |
232 | globalNetworkProxy(); | - |
233 | } executed: } Execution Count:17052 | 17052 |
234 | QNetworkProxy::QNetworkProxy(ProxyType type, const QString &hostName, quint16 port, | - |
235 | const QString &user, const QString &password) | - |
236 | : d(new QNetworkProxyPrivate(type, hostName, port, user, password)) | - |
237 | { | - |
238 | | - |
239 | | - |
240 | | - |
241 | globalNetworkProxy(); | - |
242 | } executed: } Execution Count:5981 | 5981 |
243 | | - |
244 | | - |
245 | | - |
246 | | - |
247 | QNetworkProxy::QNetworkProxy(const QNetworkProxy &other) | - |
248 | : d(other.d) | - |
249 | { | - |
250 | } executed: } Execution Count:10367 | 10367 |
251 | | - |
252 | | - |
253 | | - |
254 | | - |
255 | QNetworkProxy::~QNetworkProxy() | - |
256 | { | - |
257 | | - |
258 | } | - |
259 | | - |
260 | | - |
261 | | - |
262 | | - |
263 | | - |
264 | | - |
265 | | - |
266 | bool QNetworkProxy::operator==(const QNetworkProxy &other) const | - |
267 | { | - |
268 | return d == other.d || (d && other.d && *d == *other.d); executed: return d == other.d || (d && other.d && *d == *other.d); Execution Count:72 | 72 |
269 | } | - |
270 | QNetworkProxy &QNetworkProxy::operator=(const QNetworkProxy &other) | - |
271 | { | - |
272 | d = other.d; | - |
273 | return *this; executed: return *this; Execution Count:14812 | 14812 |
274 | } | - |
275 | void QNetworkProxy::setType(QNetworkProxy::ProxyType type) | - |
276 | { | - |
277 | d->type = type; | - |
278 | if (!d->capabilitiesSet) evaluated: !d->capabilitiesSet yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-5 |
279 | d->capabilities = defaultCapabilitiesForType(type); executed: d->capabilities = defaultCapabilitiesForType(type); Execution Count:5 | 5 |
280 | } executed: } Execution Count:6 | 6 |
281 | | - |
282 | | - |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | QNetworkProxy::ProxyType QNetworkProxy::type() const | - |
288 | { | - |
289 | return d ? d->type : DefaultProxy; executed: return d ? d->type : DefaultProxy; Execution Count:32038 | 32038 |
290 | } | - |
291 | void QNetworkProxy::setCapabilities(Capabilities capabilities) | - |
292 | { | - |
293 | d->capabilities = capabilities; | - |
294 | d->capabilitiesSet = true; | - |
295 | } executed: } Execution Count:1 | 1 |
296 | QNetworkProxy::Capabilities QNetworkProxy::capabilities() const | - |
297 | { | - |
298 | return d ? d->capabilities : defaultCapabilitiesForType(DefaultProxy); executed: return d ? d->capabilities : defaultCapabilitiesForType(DefaultProxy); Execution Count:7082 | 7082 |
299 | } | - |
300 | bool QNetworkProxy::isCachingProxy() const | - |
301 | { | - |
302 | return capabilities() & CachingCapability; never executed: return capabilities() & CachingCapability; | 0 |
303 | } | - |
304 | bool QNetworkProxy::isTransparentProxy() const | - |
305 | { | - |
306 | return capabilities() & TunnelingCapability; executed: return capabilities() & TunnelingCapability; Execution Count:660 | 660 |
307 | } | - |
308 | | - |
309 | | - |
310 | | - |
311 | | - |
312 | | - |
313 | | - |
314 | void QNetworkProxy::setUser(const QString &user) | - |
315 | { | - |
316 | d->user = user; | - |
317 | } executed: } Execution Count:130 | 130 |
318 | | - |
319 | | - |
320 | | - |
321 | | - |
322 | | - |
323 | | - |
324 | QString QNetworkProxy::user() const | - |
325 | { | - |
326 | return d ? d->user : QString(); executed: return d ? d->user : QString(); Execution Count:1102 | 1102 |
327 | } | - |
328 | | - |
329 | | - |
330 | | - |
331 | | - |
332 | | - |
333 | | - |
334 | void QNetworkProxy::setPassword(const QString &password) | - |
335 | { | - |
336 | d->password = password; | - |
337 | } executed: } Execution Count:21 | 21 |
338 | | - |
339 | | - |
340 | | - |
341 | | - |
342 | | - |
343 | | - |
344 | QString QNetworkProxy::password() const | - |
345 | { | - |
346 | return d ? d->password : QString(); executed: return d ? d->password : QString(); Execution Count:224 | 224 |
347 | } | - |
348 | | - |
349 | | - |
350 | | - |
351 | | - |
352 | | - |
353 | | - |
354 | void QNetworkProxy::setHostName(const QString &hostName) | - |
355 | { | - |
356 | d->hostName = hostName; | - |
357 | } | 0 |
358 | | - |
359 | | - |
360 | | - |
361 | | - |
362 | | - |
363 | | - |
364 | QString QNetworkProxy::hostName() const | - |
365 | { | - |
366 | return d ? d->hostName : QString(); executed: return d ? d->hostName : QString(); Execution Count:723 | 723 |
367 | } | - |
368 | | - |
369 | | - |
370 | | - |
371 | | - |
372 | | - |
373 | | - |
374 | void QNetworkProxy::setPort(quint16 port) | - |
375 | { | - |
376 | d->port = port; | - |
377 | } executed: } Execution Count:2 | 2 |
378 | | - |
379 | | - |
380 | | - |
381 | | - |
382 | | - |
383 | | - |
384 | quint16 QNetworkProxy::port() const | - |
385 | { | - |
386 | return d ? d->port : 0; executed: return d ? d->port : 0; Execution Count:632 | 632 |
387 | } | - |
388 | void QNetworkProxy::setApplicationProxy(const QNetworkProxy &networkProxy) | - |
389 | { | - |
390 | if (globalNetworkProxy()) { partially evaluated: globalNetworkProxy() yes Evaluation Count:376 | no Evaluation Count:0 |
| 0-376 |
391 | | - |
392 | if (networkProxy.type() == DefaultProxy) evaluated: networkProxy.type() == DefaultProxy yes Evaluation Count:253 | yes Evaluation Count:123 |
| 123-253 |
393 | globalNetworkProxy()->setApplicationProxy(QNetworkProxy::NoProxy); executed: globalNetworkProxy()->setApplicationProxy(QNetworkProxy::NoProxy); Execution Count:253 | 253 |
394 | else | - |
395 | globalNetworkProxy()->setApplicationProxy(networkProxy); executed: globalNetworkProxy()->setApplicationProxy(networkProxy); Execution Count:123 | 123 |
396 | } | - |
397 | } executed: } Execution Count:376 | 376 |
398 | QNetworkProxy QNetworkProxy::applicationProxy() | - |
399 | { | - |
400 | if (globalNetworkProxy()) partially evaluated: globalNetworkProxy() yes Evaluation Count:856 | no Evaluation Count:0 |
| 0-856 |
401 | return globalNetworkProxy()->applicationProxy(); executed: return globalNetworkProxy()->applicationProxy(); Execution Count:856 | 856 |
402 | return QNetworkProxy(); never executed: return QNetworkProxy(); | 0 |
403 | } | - |
404 | QVariant QNetworkProxy::header(QNetworkRequest::KnownHeaders header) const | - |
405 | { | - |
406 | if (d->type != HttpProxy && d->type != HttpCachingProxy) never evaluated: d->type != HttpProxy never evaluated: d->type != HttpCachingProxy | 0 |
407 | return QVariant(); never executed: return QVariant(); | 0 |
408 | return d->headers.cookedHeaders.value(header); never executed: return d->headers.cookedHeaders.value(header); | 0 |
409 | } | - |
410 | void QNetworkProxy::setHeader(QNetworkRequest::KnownHeaders header, const QVariant &value) | - |
411 | { | - |
412 | if (d->type == HttpProxy || d->type == HttpCachingProxy) never evaluated: d->type == HttpProxy never evaluated: d->type == HttpCachingProxy | 0 |
413 | d->headers.setCookedHeader(header, value); never executed: d->headers.setCookedHeader(header, value); | 0 |
414 | } | 0 |
415 | bool QNetworkProxy::hasRawHeader(const QByteArray &headerName) const | - |
416 | { | - |
417 | if (d->type != HttpProxy && d->type != HttpCachingProxy) partially evaluated: d->type != HttpProxy no Evaluation Count:0 | yes Evaluation Count:25 |
never evaluated: d->type != HttpCachingProxy | 0-25 |
418 | return false; never executed: return false; | 0 |
419 | return d->headers.findRawHeader(headerName) != d->headers.rawHeaders.constEnd(); executed: return d->headers.findRawHeader(headerName) != d->headers.rawHeaders.constEnd(); Execution Count:25 | 25 |
420 | } | - |
421 | QByteArray QNetworkProxy::rawHeader(const QByteArray &headerName) const | - |
422 | { | - |
423 | if (d->type != HttpProxy && d->type != HttpCachingProxy) partially evaluated: d->type != HttpProxy no Evaluation Count:0 | yes Evaluation Count:12 |
never evaluated: d->type != HttpCachingProxy | 0-12 |
424 | return QByteArray(); never executed: return QByteArray(); | 0 |
425 | QNetworkHeadersPrivate::RawHeadersList::ConstIterator it = | - |
426 | d->headers.findRawHeader(headerName); | - |
427 | if (it != d->headers.rawHeaders.constEnd()) partially evaluated: it != d->headers.rawHeaders.constEnd() yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
428 | return it->second; executed: return it->second; Execution Count:12 | 12 |
429 | return QByteArray(); never executed: return QByteArray(); | 0 |
430 | } | - |
431 | QList<QByteArray> QNetworkProxy::rawHeaderList() const | - |
432 | { | - |
433 | if (d->type != HttpProxy && d->type != HttpCachingProxy) partially evaluated: d->type != HttpProxy no Evaluation Count:0 | yes Evaluation Count:25 |
never evaluated: d->type != HttpCachingProxy | 0-25 |
434 | return QList<QByteArray>(); never executed: return QList<QByteArray>(); | 0 |
435 | return d->headers.rawHeadersKeys(); executed: return d->headers.rawHeadersKeys(); Execution Count:25 | 25 |
436 | } | - |
437 | void QNetworkProxy::setRawHeader(const QByteArray &headerName, const QByteArray &headerValue) | - |
438 | { | - |
439 | if (d->type == HttpProxy || d->type == HttpCachingProxy) partially evaluated: d->type == HttpProxy yes Evaluation Count:5 | no Evaluation Count:0 |
never evaluated: d->type == HttpCachingProxy | 0-5 |
440 | d->headers.setRawHeader(headerName, headerValue); executed: d->headers.setRawHeader(headerName, headerValue); Execution Count:5 | 5 |
441 | } executed: } Execution Count:5 | 5 |
442 | | - |
443 | class QNetworkProxyQueryPrivate: public QSharedData | - |
444 | { | - |
445 | public: | - |
446 | inline QNetworkProxyQueryPrivate() | - |
447 | : localPort(-1), type(QNetworkProxyQuery::TcpSocket) | - |
448 | { } executed: } Execution Count:2951 | 2951 |
449 | | - |
450 | bool operator==(const QNetworkProxyQueryPrivate &other) const | - |
451 | { | - |
452 | return type == other.type && | 26 |
453 | localPort == other.localPort && | 26 |
454 | remote == other.remote; executed: return type == other.type && localPort == other.localPort && remote == other.remote; Execution Count:26 | 26 |
455 | } | - |
456 | | - |
457 | QUrl remote; | - |
458 | int localPort; | - |
459 | QNetworkProxyQuery::QueryType type; | - |
460 | | - |
461 | QNetworkConfiguration config; | - |
462 | | - |
463 | }; | - |
464 | | - |
465 | template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach() | - |
466 | { | - |
467 | if (d && d->ref.load() == 1) evaluated: d yes Evaluation Count:6813 | yes Evaluation Count:2951 |
partially evaluated: d->ref.load() == 1 yes Evaluation Count:6813 | no Evaluation Count:0 |
| 0-6813 |
468 | return; executed: return; Execution Count:6813 | 6813 |
469 | QNetworkProxyQueryPrivate *x = (d ? new QNetworkProxyQueryPrivate(*d) partially evaluated: d no Evaluation Count:0 | yes Evaluation Count:2951 |
| 0-2951 |
470 | : new QNetworkProxyQueryPrivate); | - |
471 | x->ref.ref(); | - |
472 | if (d && !d->ref.deref()) partially evaluated: d no Evaluation Count:0 | yes Evaluation Count:2951 |
never evaluated: !d->ref.deref() | 0-2951 |
473 | delete d; never executed: delete d; | 0 |
474 | d = x; | - |
475 | } executed: } Execution Count:2951 | 2951 |
476 | QNetworkProxyQuery::QNetworkProxyQuery() | - |
477 | { | - |
478 | } | - |
479 | | - |
480 | | - |
481 | | - |
482 | | - |
483 | | - |
484 | | - |
485 | | - |
486 | QNetworkProxyQuery::QNetworkProxyQuery(const QUrl &requestUrl, QueryType queryType) | - |
487 | { | - |
488 | d->remote = requestUrl; | - |
489 | d->type = queryType; | - |
490 | } executed: } Execution Count:746 | 746 |
491 | QNetworkProxyQuery::QNetworkProxyQuery(const QString &hostname, int port, | - |
492 | const QString &protocolTag, | - |
493 | QueryType queryType) | - |
494 | { | - |
495 | d->remote.setScheme(protocolTag); | - |
496 | d->remote.setHost(hostname); | - |
497 | d->remote.setPort(port); | - |
498 | d->type = queryType; | - |
499 | } executed: } Execution Count:1657 | 1657 |
500 | QNetworkProxyQuery::QNetworkProxyQuery(quint16 bindPort, const QString &protocolTag, | - |
501 | QueryType queryType) | - |
502 | { | - |
503 | d->remote.setScheme(protocolTag); | - |
504 | d->localPort = bindPort; | - |
505 | d->type = queryType; | - |
506 | } executed: } Execution Count:438 | 438 |
507 | QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration, | - |
508 | const QUrl &requestUrl, QueryType queryType) | - |
509 | { | - |
510 | d->config = networkConfiguration; | - |
511 | d->remote = requestUrl; | - |
512 | d->type = queryType; | - |
513 | } executed: } Execution Count:110 | 110 |
514 | QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration, | - |
515 | const QString &hostname, int port, | - |
516 | const QString &protocolTag, | - |
517 | QueryType queryType) | - |
518 | { | - |
519 | d->config = networkConfiguration; | - |
520 | d->remote.setScheme(protocolTag); | - |
521 | d->remote.setHost(hostname); | - |
522 | d->remote.setPort(port); | - |
523 | d->type = queryType; | - |
524 | } | 0 |
525 | QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration, | - |
526 | quint16 bindPort, const QString &protocolTag, | - |
527 | QueryType queryType) | - |
528 | { | - |
529 | d->config = networkConfiguration; | - |
530 | d->remote.setScheme(protocolTag); | - |
531 | d->localPort = bindPort; | - |
532 | d->type = queryType; | - |
533 | } | 0 |
534 | | - |
535 | | - |
536 | | - |
537 | | - |
538 | | - |
539 | QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkProxyQuery &other) | - |
540 | : d(other.d) | - |
541 | { | - |
542 | } | 0 |
543 | | - |
544 | | - |
545 | | - |
546 | | - |
547 | QNetworkProxyQuery::~QNetworkProxyQuery() | - |
548 | { | - |
549 | | - |
550 | } | - |
551 | | - |
552 | | - |
553 | | - |
554 | | - |
555 | QNetworkProxyQuery &QNetworkProxyQuery::operator=(const QNetworkProxyQuery &other) | - |
556 | { | - |
557 | d = other.d; | - |
558 | return *this; executed: return *this; Execution Count:80 | 80 |
559 | } | - |
560 | bool QNetworkProxyQuery::operator==(const QNetworkProxyQuery &other) const | - |
561 | { | - |
562 | return d == other.d || (d && other.d && *d == *other.d); executed: return d == other.d || (d && other.d && *d == *other.d); Execution Count:26 | 26 |
563 | } | - |
564 | QNetworkProxyQuery::QueryType QNetworkProxyQuery::queryType() const | - |
565 | { | - |
566 | return d ? d->type : TcpSocket; never executed: return d ? d->type : TcpSocket; | 0 |
567 | } | - |
568 | | - |
569 | | - |
570 | | - |
571 | | - |
572 | void QNetworkProxyQuery::setQueryType(QueryType type) | - |
573 | { | - |
574 | d->type = type; | - |
575 | } | 0 |
576 | int QNetworkProxyQuery::peerPort() const | - |
577 | { | - |
578 | return d ? d->remote.port() : -1; never executed: return d ? d->remote.port() : -1; | 0 |
579 | } | - |
580 | void QNetworkProxyQuery::setPeerPort(int port) | - |
581 | { | - |
582 | d->remote.setPort(port); | - |
583 | } | 0 |
584 | QString QNetworkProxyQuery::peerHostName() const | - |
585 | { | - |
586 | return d ? d->remote.host() : QString(); executed: return d ? d->remote.host() : QString(); Execution Count:41 | 41 |
587 | } | - |
588 | void QNetworkProxyQuery::setPeerHostName(const QString &hostname) | - |
589 | { | - |
590 | d->remote.setHost(hostname); | - |
591 | } | 0 |
592 | | - |
593 | | - |
594 | | - |
595 | | - |
596 | | - |
597 | | - |
598 | | - |
599 | int QNetworkProxyQuery::localPort() const | - |
600 | { | - |
601 | return d ? d->localPort : -1; never executed: return d ? d->localPort : -1; | 0 |
602 | } | - |
603 | void QNetworkProxyQuery::setLocalPort(int port) | - |
604 | { | - |
605 | d->localPort = port; | - |
606 | } | 0 |
607 | QString QNetworkProxyQuery::protocolTag() const | - |
608 | { | - |
609 | return d ? d->remote.scheme() : QString(); executed: return d ? d->remote.scheme() : QString(); Execution Count:32 | 32 |
610 | } | - |
611 | void QNetworkProxyQuery::setProtocolTag(const QString &protocolTag) | - |
612 | { | - |
613 | d->remote.setScheme(protocolTag); | - |
614 | } | 0 |
615 | | - |
616 | | - |
617 | | - |
618 | | - |
619 | | - |
620 | | - |
621 | | - |
622 | QUrl QNetworkProxyQuery::url() const | - |
623 | { | - |
624 | return d ? d->remote : QUrl(); executed: return d ? d->remote : QUrl(); Execution Count:3585 | 3585 |
625 | } | - |
626 | void QNetworkProxyQuery::setUrl(const QUrl &url) | - |
627 | { | - |
628 | d->remote = url; | - |
629 | } | 0 |
630 | | - |
631 | | - |
632 | | - |
633 | | - |
634 | | - |
635 | | - |
636 | | - |
637 | QNetworkConfiguration QNetworkProxyQuery::networkConfiguration() const | - |
638 | { | - |
639 | return d ? d->config : QNetworkConfiguration(); never executed: return d ? d->config : QNetworkConfiguration(); | 0 |
640 | } | - |
641 | void QNetworkProxyQuery::setNetworkConfiguration(const QNetworkConfiguration &networkConfiguration) | - |
642 | { | - |
643 | d->config = networkConfiguration; | - |
644 | } | 0 |
645 | QNetworkProxyFactory::QNetworkProxyFactory() | - |
646 | { | - |
647 | } | - |
648 | | - |
649 | | - |
650 | | - |
651 | | - |
652 | QNetworkProxyFactory::~QNetworkProxyFactory() | - |
653 | { | - |
654 | } | - |
655 | void QNetworkProxyFactory::setUseSystemConfiguration(bool enable) | - |
656 | { | - |
657 | if (enable) { | 0 |
658 | setApplicationProxyFactory(new QSystemConfigurationProxyFactory); | - |
659 | } else { | 0 |
660 | setApplicationProxyFactory(0); | - |
661 | } | 0 |
662 | } | - |
663 | void QNetworkProxyFactory::setApplicationProxyFactory(QNetworkProxyFactory *factory) | - |
664 | { | - |
665 | if (globalNetworkProxy()) partially evaluated: globalNetworkProxy() yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
666 | globalNetworkProxy()->setApplicationProxyFactory(factory); executed: globalNetworkProxy()->setApplicationProxyFactory(factory); Execution Count:8 | 8 |
667 | } executed: } Execution Count:8 | 8 |
668 | QList<QNetworkProxy> QNetworkProxyFactory::proxyForQuery(const QNetworkProxyQuery &query) | - |
669 | { | - |
670 | if (!globalNetworkProxy()) partially evaluated: !globalNetworkProxy() no Evaluation Count:0 | yes Evaluation Count:2729 |
| 0-2729 |
671 | return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); never executed: return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); | 0 |
672 | return globalNetworkProxy()->proxyForQuery(query); executed: return globalNetworkProxy()->proxyForQuery(query); Execution Count:2729 | 2729 |
673 | } | - |
674 | | - |
675 | | - |
676 | | - |
677 | | - |
678 | | - |
679 | | - |
680 | QDebug operator<<(QDebug debug, const QNetworkProxy &proxy) | - |
681 | { | - |
682 | QNetworkProxy::ProxyType type = proxy.type(); | - |
683 | switch (type) { | - |
684 | case QNetworkProxy::NoProxy: | - |
685 | debug << "NoProxy "; | - |
686 | break; executed: break; Execution Count:25 | 25 |
687 | case QNetworkProxy::DefaultProxy: | - |
688 | debug << "DefaultProxy "; | - |
689 | break; | 0 |
690 | case QNetworkProxy::Socks5Proxy: | - |
691 | debug << "Socks5Proxy "; | - |
692 | break; | 0 |
693 | case QNetworkProxy::HttpProxy: | - |
694 | debug << "HttpProxy "; | - |
695 | break; | 0 |
696 | case QNetworkProxy::HttpCachingProxy: | - |
697 | debug << "HttpCachingProxy "; | - |
698 | break; | 0 |
699 | case QNetworkProxy::FtpCachingProxy: | - |
700 | debug << "FtpCachingProxy "; | - |
701 | break; | 0 |
702 | default: | - |
703 | debug << "Unknown proxy " << int(type); | - |
704 | break; | 0 |
705 | } | - |
706 | debug << "\"" << proxy.hostName() << ":" << proxy.port() << "\" "; | - |
707 | QNetworkProxy::Capabilities caps = proxy.capabilities(); | - |
708 | QStringList scaps; | - |
709 | if (caps & QNetworkProxy::TunnelingCapability) partially evaluated: caps & QNetworkProxy::TunnelingCapability yes Evaluation Count:25 | no Evaluation Count:0 |
| 0-25 |
710 | scaps << QString::fromUtf8("" "Tunnel" "", sizeof("Tunnel") - 1); executed: scaps << QString::fromUtf8("" "Tunnel" "", sizeof("Tunnel") - 1); Execution Count:25 | 25 |
711 | if (caps & QNetworkProxy::ListeningCapability) partially evaluated: caps & QNetworkProxy::ListeningCapability yes Evaluation Count:25 | no Evaluation Count:0 |
| 0-25 |
712 | scaps << QString::fromUtf8("" "Listen" "", sizeof("Listen") - 1); executed: scaps << QString::fromUtf8("" "Listen" "", sizeof("Listen") - 1); Execution Count:25 | 25 |
713 | if (caps & QNetworkProxy::UdpTunnelingCapability) partially evaluated: caps & QNetworkProxy::UdpTunnelingCapability yes Evaluation Count:25 | no Evaluation Count:0 |
| 0-25 |
714 | scaps << QString::fromUtf8("" "UDP" "", sizeof("UDP") - 1); executed: scaps << QString::fromUtf8("" "UDP" "", sizeof("UDP") - 1); Execution Count:25 | 25 |
715 | if (caps & QNetworkProxy::CachingCapability) partially evaluated: caps & QNetworkProxy::CachingCapability no Evaluation Count:0 | yes Evaluation Count:25 |
| 0-25 |
716 | scaps << QString::fromUtf8("" "Caching" "", sizeof("Caching") - 1); never executed: scaps << QString::fromUtf8("" "Caching" "", sizeof("Caching") - 1); | 0 |
717 | if (caps & QNetworkProxy::HostNameLookupCapability) partially evaluated: caps & QNetworkProxy::HostNameLookupCapability no Evaluation Count:0 | yes Evaluation Count:25 |
| 0-25 |
718 | scaps << QString::fromUtf8("" "NameLookup" "", sizeof("NameLookup") - 1); never executed: scaps << QString::fromUtf8("" "NameLookup" "", sizeof("NameLookup") - 1); | 0 |
719 | debug << "[" << scaps.join(QLatin1Char(' ')) << "]"; | - |
720 | return debug; executed: return debug; Execution Count:25 | 25 |
721 | } | - |
722 | | - |
723 | | - |
724 | | - |
725 | | - |
| | |