kernel/qnetworkproxy.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10class QSocks5SocketEngineHandler; -
11class QHttpSocketEngineHandler; -
12 -
13class QGlobalNetworkProxy -
14{ -
15public: -
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
TRUEFALSE
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
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
64 return;
never executed: return;
0
65 if (applicationLevelProxy)
evaluated: applicationLevelProxy
TRUEFALSE
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 -
78private: -
79 QMutex mutex; -
80 QNetworkProxy *applicationLevelProxy; -
81 QNetworkProxyFactory *applicationLevelProxyFactory; -
82 -
83 QSocks5SocketEngineHandler *socks5SocketEngineHandler; -
84 -
85 -
86 QHttpSocketEngineHandler *httpSocketEngineHandler; -
87 -
88}; -
89 -
90QList<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")
TRUEFALSE
yes
Evaluation Count:1133
yes
Evaluation Count:2452
1133-2452
100 || hostname.startsWith(QLatin1String("localhost."))
partially evaluated: hostname.startsWith(QLatin1String("localhost."))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2452
0-2452
101 || (parsed.setAddress(hostname)
evaluated: parsed.setAddress(hostname)
TRUEFALSE
yes
Evaluation Count:371
yes
Evaluation Count:2081
371-2081
102 && (parsed.isLoopback()))) {
evaluated: (parsed.isLoopback())
TRUEFALSE
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
TRUEFALSE
yes
Evaluation Count:2126
yes
Evaluation Count:7
7-2126
108 if (applicationLevelProxy
evaluated: applicationLevelProxy
TRUEFALSE
yes
Evaluation Count:389
yes
Evaluation Count:1737
389-1737
109 && applicationLevelProxy->type() != QNetworkProxy::DefaultProxy)
partially evaluated: applicationLevelProxy->type() != QNetworkProxy::DefaultProxy
TRUEFALSE
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()
TRUEFALSE
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 }
never executed: }
0
123 return result;
executed: return result;
Execution Count:7
7
124} -
125 -
126static 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)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:30948
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:30971
0-30971
127 -
128namespace { -
129 template<bool> struct StaticAssertTest; -
130 template<> struct StaticAssertTest<true> { enum { Value = 1 }; }; -
131} -
132 -
133static inline void qt_noop_with_arg(int) {} -
134 -
135 -
136static 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
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5987
partially evaluated: int(type) > int(QNetworkProxy::FtpCachingProxy)
TRUEFALSE
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 -
173class QNetworkProxyPrivate: public QSharedData -
174{ -
175public: -
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 -
208template<> void QSharedDataPointer<QNetworkProxyPrivate>::detach() -
209{ -
210 if (d && d->ref.load() == 1)
evaluated: d
TRUEFALSE
yes
Evaluation Count:181
yes
Evaluation Count:1
evaluated: d->ref.load() == 1
TRUEFALSE
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
TRUEFALSE
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
TRUEFALSE
yes
Evaluation Count:83
yes
Evaluation Count:1
partially evaluated: !d->ref.deref()
TRUEFALSE
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 -
226QNetworkProxy::QNetworkProxy() -
227 : d(0) -
228{ -
229 -
230 -
231 -
232 globalNetworkProxy(); -
233}
executed: }
Execution Count:17052
17052
234QNetworkProxy::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 -
247QNetworkProxy::QNetworkProxy(const QNetworkProxy &other) -
248 : d(other.d) -
249{ -
250}
executed: }
Execution Count:10367
10367
251 -
252 -
253 -
254 -
255QNetworkProxy::~QNetworkProxy() -
256{ -
257 -
258} -
259 -
260 -
261 -
262 -
263 -
264 -
265 -
266bool 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} -
270QNetworkProxy &QNetworkProxy::operator=(const QNetworkProxy &other) -
271{ -
272 d = other.d; -
273 return *this;
executed: return *this;
Execution Count:14812
14812
274} -
275void QNetworkProxy::setType(QNetworkProxy::ProxyType type) -
276{ -
277 d->type = type; -
278 if (!d->capabilitiesSet)
evaluated: !d->capabilitiesSet
TRUEFALSE
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 -
287QNetworkProxy::ProxyType QNetworkProxy::type() const -
288{ -
289 return d ? d->type : DefaultProxy;
executed: return d ? d->type : DefaultProxy;
Execution Count:32038
32038
290} -
291void QNetworkProxy::setCapabilities(Capabilities capabilities) -
292{ -
293 d->capabilities = capabilities; -
294 d->capabilitiesSet = true; -
295}
executed: }
Execution Count:1
1
296QNetworkProxy::Capabilities QNetworkProxy::capabilities() const -
297{ -
298 return d ? d->capabilities : defaultCapabilitiesForType(DefaultProxy);
executed: return d ? d->capabilities : defaultCapabilitiesForType(DefaultProxy);
Execution Count:7082
7082
299} -
300bool QNetworkProxy::isCachingProxy() const -
301{ -
302 return capabilities() & CachingCapability;
never executed: return capabilities() & CachingCapability;
0
303} -
304bool QNetworkProxy::isTransparentProxy() const -
305{ -
306 return capabilities() & TunnelingCapability;
executed: return capabilities() & TunnelingCapability;
Execution Count:660
660
307} -
308 -
309 -
310 -
311 -
312 -
313 -
314void QNetworkProxy::setUser(const QString &user) -
315{ -
316 d->user = user; -
317}
executed: }
Execution Count:130
130
318 -
319 -
320 -
321 -
322 -
323 -
324QString 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 -
334void QNetworkProxy::setPassword(const QString &password) -
335{ -
336 d->password = password; -
337}
executed: }
Execution Count:21
21
338 -
339 -
340 -
341 -
342 -
343 -
344QString 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 -
354void QNetworkProxy::setHostName(const QString &hostName) -
355{ -
356 d->hostName = hostName; -
357}
never executed: }
0
358 -
359 -
360 -
361 -
362 -
363 -
364QString 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 -
374void QNetworkProxy::setPort(quint16 port) -
375{ -
376 d->port = port; -
377}
executed: }
Execution Count:2
2
378 -
379 -
380 -
381 -
382 -
383 -
384quint16 QNetworkProxy::port() const -
385{ -
386 return d ? d->port : 0;
executed: return d ? d->port : 0;
Execution Count:632
632
387} -
388void QNetworkProxy::setApplicationProxy(const QNetworkProxy &networkProxy) -
389{ -
390 if (globalNetworkProxy()) {
partially evaluated: globalNetworkProxy()
TRUEFALSE
yes
Evaluation Count:376
no
Evaluation Count:0
0-376
391 -
392 if (networkProxy.type() == DefaultProxy)
evaluated: networkProxy.type() == DefaultProxy
TRUEFALSE
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
398QNetworkProxy QNetworkProxy::applicationProxy() -
399{ -
400 if (globalNetworkProxy())
partially evaluated: globalNetworkProxy()
TRUEFALSE
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} -
404QVariant 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} -
410void 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}
never executed: }
0
415bool QNetworkProxy::hasRawHeader(const QByteArray &headerName) const -
416{ -
417 if (d->type != HttpProxy && d->type != HttpCachingProxy)
partially evaluated: d->type != HttpProxy
TRUEFALSE
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} -
421QByteArray QNetworkProxy::rawHeader(const QByteArray &headerName) const -
422{ -
423 if (d->type != HttpProxy && d->type != HttpCachingProxy)
partially evaluated: d->type != HttpProxy
TRUEFALSE
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()
TRUEFALSE
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} -
431QList<QByteArray> QNetworkProxy::rawHeaderList() const -
432{ -
433 if (d->type != HttpProxy && d->type != HttpCachingProxy)
partially evaluated: d->type != HttpProxy
TRUEFALSE
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} -
437void QNetworkProxy::setRawHeader(const QByteArray &headerName, const QByteArray &headerValue) -
438{ -
439 if (d->type == HttpProxy || d->type == HttpCachingProxy)
partially evaluated: d->type == HttpProxy
TRUEFALSE
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 -
443class QNetworkProxyQueryPrivate: public QSharedData -
444{ -
445public: -
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 -
465template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach() -
466{ -
467 if (d && d->ref.load() == 1)
evaluated: d
TRUEFALSE
yes
Evaluation Count:6813
yes
Evaluation Count:2951
partially evaluated: d->ref.load() == 1
TRUEFALSE
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
TRUEFALSE
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
TRUEFALSE
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
476QNetworkProxyQuery::QNetworkProxyQuery() -
477{ -
478} -
479 -
480 -
481 -
482 -
483 -
484 -
485 -
486QNetworkProxyQuery::QNetworkProxyQuery(const QUrl &requestUrl, QueryType queryType) -
487{ -
488 d->remote = requestUrl; -
489 d->type = queryType; -
490}
executed: }
Execution Count:746
746
491QNetworkProxyQuery::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
500QNetworkProxyQuery::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
507QNetworkProxyQuery::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
514QNetworkProxyQuery::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}
never executed: }
0
525QNetworkProxyQuery::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}
never executed: }
0
534 -
535 -
536 -
537 -
538 -
539QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkProxyQuery &other) -
540 : d(other.d) -
541{ -
542}
never executed: }
0
543 -
544 -
545 -
546 -
547QNetworkProxyQuery::~QNetworkProxyQuery() -
548{ -
549 -
550} -
551 -
552 -
553 -
554 -
555QNetworkProxyQuery &QNetworkProxyQuery::operator=(const QNetworkProxyQuery &other) -
556{ -
557 d = other.d; -
558 return *this;
executed: return *this;
Execution Count:80
80
559} -
560bool 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} -
564QNetworkProxyQuery::QueryType QNetworkProxyQuery::queryType() const -
565{ -
566 return d ? d->type : TcpSocket;
never executed: return d ? d->type : TcpSocket;
0
567} -
568 -
569 -
570 -
571 -
572void QNetworkProxyQuery::setQueryType(QueryType type) -
573{ -
574 d->type = type; -
575}
never executed: }
0
576int QNetworkProxyQuery::peerPort() const -
577{ -
578 return d ? d->remote.port() : -1;
never executed: return d ? d->remote.port() : -1;
0
579} -
580void QNetworkProxyQuery::setPeerPort(int port) -
581{ -
582 d->remote.setPort(port); -
583}
never executed: }
0
584QString QNetworkProxyQuery::peerHostName() const -
585{ -
586 return d ? d->remote.host() : QString();
executed: return d ? d->remote.host() : QString();
Execution Count:41
41
587} -
588void QNetworkProxyQuery::setPeerHostName(const QString &hostname) -
589{ -
590 d->remote.setHost(hostname); -
591}
never executed: }
0
592 -
593 -
594 -
595 -
596 -
597 -
598 -
599int QNetworkProxyQuery::localPort() const -
600{ -
601 return d ? d->localPort : -1;
never executed: return d ? d->localPort : -1;
0
602} -
603void QNetworkProxyQuery::setLocalPort(int port) -
604{ -
605 d->localPort = port; -
606}
never executed: }
0
607QString QNetworkProxyQuery::protocolTag() const -
608{ -
609 return d ? d->remote.scheme() : QString();
executed: return d ? d->remote.scheme() : QString();
Execution Count:32
32
610} -
611void QNetworkProxyQuery::setProtocolTag(const QString &protocolTag) -
612{ -
613 d->remote.setScheme(protocolTag); -
614}
never executed: }
0
615 -
616 -
617 -
618 -
619 -
620 -
621 -
622QUrl QNetworkProxyQuery::url() const -
623{ -
624 return d ? d->remote : QUrl();
executed: return d ? d->remote : QUrl();
Execution Count:3585
3585
625} -
626void QNetworkProxyQuery::setUrl(const QUrl &url) -
627{ -
628 d->remote = url; -
629}
never executed: }
0
630 -
631 -
632 -
633 -
634 -
635 -
636 -
637QNetworkConfiguration QNetworkProxyQuery::networkConfiguration() const -
638{ -
639 return d ? d->config : QNetworkConfiguration();
never executed: return d ? d->config : QNetworkConfiguration();
0
640} -
641void QNetworkProxyQuery::setNetworkConfiguration(const QNetworkConfiguration &networkConfiguration) -
642{ -
643 d->config = networkConfiguration; -
644}
never executed: }
0
645QNetworkProxyFactory::QNetworkProxyFactory() -
646{ -
647} -
648 -
649 -
650 -
651 -
652QNetworkProxyFactory::~QNetworkProxyFactory() -
653{ -
654} -
655void QNetworkProxyFactory::setUseSystemConfiguration(bool enable) -
656{ -
657 if (enable) {
never evaluated: enable
0
658 setApplicationProxyFactory(new QSystemConfigurationProxyFactory); -
659 } else {
never executed: }
0
660 setApplicationProxyFactory(0); -
661 }
never executed: }
0
662} -
663void QNetworkProxyFactory::setApplicationProxyFactory(QNetworkProxyFactory *factory) -
664{ -
665 if (globalNetworkProxy())
partially evaluated: globalNetworkProxy()
TRUEFALSE
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
668QList<QNetworkProxy> QNetworkProxyFactory::proxyForQuery(const QNetworkProxyQuery &query) -
669{ -
670 if (!globalNetworkProxy())
partially evaluated: !globalNetworkProxy()
TRUEFALSE
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 -
680QDebug 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;
never executed: break;
0
690 case QNetworkProxy::Socks5Proxy: -
691 debug << "Socks5Proxy "; -
692 break;
never executed: break;
0
693 case QNetworkProxy::HttpProxy: -
694 debug << "HttpProxy "; -
695 break;
never executed: break;
0
696 case QNetworkProxy::HttpCachingProxy: -
697 debug << "HttpCachingProxy "; -
698 break;
never executed: break;
0
699 case QNetworkProxy::FtpCachingProxy: -
700 debug << "FtpCachingProxy "; -
701 break;
never executed: break;
0
702 default: -
703 debug << "Unknown proxy " << int(type); -
704 break;
never executed: 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
TRUEFALSE
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
TRUEFALSE
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
TRUEFALSE
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
TRUEFALSE
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
TRUEFALSE
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 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial