qnetworkconfiguration.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/bearer/qnetworkconfiguration.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qnetworkconfiguration.h"-
41#include "qnetworkconfiguration_p.h"-
42#include <QDebug>-
43-
44QT_BEGIN_NAMESPACE-
45-
46/*!-
47 \class QNetworkConfiguration-
48-
49 \brief The QNetworkConfiguration class provides an abstraction of one or more access point configurations.-
50-
51 \since 4.7-
52-
53 \inmodule QtNetwork-
54 \ingroup network-
55 \ingroup shared-
56-
57 QNetworkConfiguration encapsulates a single access point or service network.-
58 In most cases a single access point configuration can be mapped to one network-
59 interface. However a single network interface may not always map to only one-
60 access point configuration. Multiple configurations for the same-
61 network device may enable multiple access points. An example-
62 device that could exhibit such a configuration might be a-
63 Smartphone which allows the user to manage multiple WLAN-
64 configurations while the device itself has only one WLAN network device.-
65-
66 The QNetworkConfiguration also supports the concept of service networks.-
67 This concept allows the grouping of multiple access point configurations-
68 into one entity. Such a group is called service network and can be-
69 beneficial in cases whereby a network session to a-
70 particular destination network is required (e.g. a company network).-
71 When using a service network the user doesn't usually care which one of the-
72 connectivity options is chosen (e.g. corporate WLAN or VPN via GPRS)-
73 as long as he can reach the company's target server. Depending-
74 on the current position and time some of the access points that make-
75 up the service network may not even be available. Furthermore-
76 automated access point roaming can be enabled which enables the device-
77 to change the network interface configuration dynamically while maintaining-
78 the applications connection to the target network. It allows adaption-
79 to the changing environment and may enable optimization with regards to-
80 cost, speed or other network parameters.-
81-
82 Special configurations of type UserChoice provide a placeholder configuration which is-
83 resolved to an actual network configuration by the platform when a-
84 \l {QNetworkSession}{session} is \l {QNetworkSession::open()}{opened}. Not all platforms-
85 support the concept of a user choice configuration.-
86-
87 \section1 Configuration States-
88-
89 The list of available configurations can be obtained via-
90 QNetworkConfigurationManager::allConfigurations(). A configuration can have-
91 multiple states. The \l Defined configuration state indicates that the configuration-
92 is stored on the device. However the configuration is not yet ready to be activated-
93 as e.g. a WLAN may not be available at the current time.-
94-
95 The \l Discovered state implies that the configuration is \l Defined and-
96 the outside conditions are such that the configuration can be used immediately-
97 to open a new network session. An example of such an outside condition may be-
98 that the Ethernet cable is actually connected to the device or that the WLAN-
99 with the specified SSID is in range.-
100-
101 The \l Active state implies that the configuration is \l Discovered. A configuration-
102 in this state is currently being used by an application. The underlying network-
103 interface has a valid IP configuration and can transfer IP packets between the-
104 device and the target network.-
105-
106 The \l Undefined state indicates that the system has knowledge of possible target-
107 networks but cannot actually use that knowledge to connect to it. An example-
108 for such a state could be an encrypted WLAN that has been discovered-
109 but the user hasn't actually saved a configuration including the required password-
110 which would allow the device to connect to it.-
111-
112 Depending on the type of configuration some states are transient in nature. A GPRS/UMTS-
113 connection may almost always be \l Discovered if the GSM/UMTS network is available.-
114 However if the GSM/UMTS network looses the connection the associated configuration may change its state-
115 from \l Discovered to \l Defined as well. A similar use case might be triggered by-
116 WLAN availability. QNetworkConfigurationManager::updateConfigurations() can be used to-
117 manually trigger updates of states. Note that some platforms do not require such updates-
118 as they implicitly change the state once it has been discovered. If the state of a-
119 configuration changes all related QNetworkConfiguration instances change their state automatically.-
120-
121 \sa QNetworkSession, QNetworkConfigurationManager-
122*/-
123-
124/*!-
125 \enum QNetworkConfiguration::Type-
126-
127 This enum describes the type of configuration.-
128-
129 \value InternetAccessPoint The configuration specifies the details for a single access point.-
130 Note that configurations of type InternetAccessPoint may be part-
131 of other QNetworkConfigurations of type ServiceNetwork.-
132 \value ServiceNetwork The configuration is based on a group of QNetworkConfigurations of-
133 type InternetAccessPoint. All group members can reach the same-
134 target network. This type of configuration is a mandatory-
135 requirement for roaming enabled network sessions. On some-
136 platforms this form of configuration may also be called Service-
137 Network Access Point (SNAP).-
138 \value UserChoice The configuration is a placeholder which will be resolved to an-
139 actual configuration by the platform when a session is opened. Depending-
140 on the platform the selection may generate a popup dialog asking the user-
141 for his preferred choice.-
142 \value Invalid The configuration is invalid.-
143*/-
144-
145/*!-
146 \enum QNetworkConfiguration::StateFlag-
147-
148 Specifies the configuration states.-
149-
150 \value Undefined This state is used for transient configurations such as newly discovered-
151 WLANs for which the user has not actually created a configuration yet.-
152 \value Defined Defined configurations are known to the system but are not immediately-
153 usable (e.g. a configured WLAN is not within range or the Ethernet cable-
154 is currently not plugged into the machine).-
155 \value Discovered A discovered configuration can be immediately used to create a new-
156 QNetworkSession. An example of a discovered configuration could be a WLAN-
157 which is within in range. If the device moves out of range the discovered-
158 flag is dropped. A second example is a GPRS configuration which generally-
159 remains discovered for as long as the device has network coverage. A-
160 configuration that has this state is also in state-
161 QNetworkConfiguration::Defined. If the configuration is a service network-
162 this flag is set if at least one of the underlying access points-
163 configurations has the Discovered state.-
164 \value Active The configuration is currently used by an open network session-
165 (see \l QNetworkSession::isOpen()). However this does not mean that the-
166 current process is the entity that created the open session. It merely-
167 indicates that if a new QNetworkSession were to be constructed based on-
168 this configuration \l QNetworkSession::state() would return-
169 \l QNetworkSession::Connected. This state implies the-
170 QNetworkConfiguration::Discovered state.-
171*/-
172-
173/*!-
174 \enum QNetworkConfiguration::Purpose-
175-
176 Specifies the purpose of the configuration.-
177-
178 \value UnknownPurpose The configuration doesn't specify any purpose. This is the default value.-
179 \value PublicPurpose The configuration can be used for general purpose internet access.-
180 \value PrivatePurpose The configuration is suitable to access a private network such as an office Intranet.-
181 \value ServiceSpecificPurpose The configuration can be used for operator specific services (e.g.-
182 receiving MMS messages or content streaming).-
183*/-
184-
185/*!-
186 \enum QNetworkConfiguration::BearerType-
187-
188 Specifies the type of bearer used by a configuration.-
189-
190 \value BearerUnknown The type of bearer is unknown or unspecified. The bearerTypeName()-
191 function may return additional information.-
192 \value BearerEthernet The configuration is for an Ethernet interfaces.-
193 \value BearerWLAN The configuration is for a Wireless LAN interface.-
194 \value Bearer2G The configuration is for a CSD, GPRS, HSCSD, EDGE or cdmaOne interface.-
195 \value Bearer3G The configuration is for a 3G interface.-
196 \value Bearer4G The configuration is for a 4G interface.-
197 \value BearerCDMA2000 The configuration is for CDMA interface.-
198 \value BearerWCDMA The configuration is for W-CDMA/UMTS interface.-
199 \value BearerHSPA The configuration is for High Speed Packet Access (HSPA) interface.-
200 \value BearerBluetooth The configuration is for a Bluetooth interface.-
201 \value BearerWiMAX The configuration is for a WiMAX interface.-
202 \value BearerEVDO The configuration is for an EVDO (3G) interface.-
203 \value BearerLTE The configuration is for a LTE (4G) interface.-
204*/-
205-
206/*!-
207 Constructs an invalid configuration object.-
208-
209 \sa isValid()-
210*/-
211QNetworkConfiguration::QNetworkConfiguration()-
212 : d(0)-
213{-
214}
executed 8172 times by 34 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
  • tst_lancelot - unknown status
  • tst_qeventloop - unknown status
  • tst_qguieventloop - unknown status
  • tst_qhttpsocketengine - unknown status
  • tst_qimagereader - unknown status
  • tst_qiodevice - unknown status
  • ...
8172
215-
216/*!-
217 Creates a copy of the QNetworkConfiguration object contained in \a other.-
218*/-
219QNetworkConfiguration::QNetworkConfiguration(const QNetworkConfiguration &other)-
220 : d(other.d)-
221{-
222}
executed 651 times by 19 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
651
223-
224/*!-
225 Frees the resources associated with the QNetworkConfiguration object.-
226*/-
227QNetworkConfiguration::~QNetworkConfiguration()-
228{-
229}-
230-
231/*!-
232 Copies the content of the QNetworkConfiguration object contained in \a other into this one.-
233*/-
234QNetworkConfiguration &QNetworkConfiguration::operator=(const QNetworkConfiguration &other)-
235{-
236 d = other.d;-
237 return *this;
executed 309 times by 16 tests: return *this;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_Spdy
309
238}-
239-
240/*!-
241 \fn void QNetworkConfiguration::swap(QNetworkConfiguration &other)-
242 \since 5.0-
243-
244 Swaps this network configuration with \a other. This function is-
245 very fast and never fails.-
246*/-
247-
248/*!-
249 Returns \c true, if this configuration is the same as the \a other-
250 configuration given; otherwise returns \c false.-
251*/-
252bool QNetworkConfiguration::operator==(const QNetworkConfiguration &other) const-
253{-
254 return (d == other.d);
executed 491 times by 11 tests: return (d == other.d);
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QXmlInputSource
  • tst_Spdy
491
255}-
256-
257/*!-
258 \fn bool QNetworkConfiguration::operator!=(const QNetworkConfiguration &other) const-
259-
260 Returns \c true if this configuration is not the same as the \a other-
261 configuration given; otherwise returns \c false.-
262*/-
263-
264/*!-
265 Returns the user visible name of this configuration.-
266-
267 The name may either be the name of the underlying access point or the-
268 name for service network that this configuration represents.-
269*/-
270QString QNetworkConfiguration::name() const-
271{-
272 if (!d)
!dDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_QNetworkConfiguration
FALSEevaluated 40 times by 4 tests
Evaluated by:
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkProxyFactory
  • tst_QNetworkSession
6-40
273 return QString();
executed 6 times by 1 test: return QString();
Executed by:
  • tst_QNetworkConfiguration
6
274-
275 QMutexLocker locker(&d->mutex);-
276 return d->name;
executed 40 times by 4 tests: return d->name;
Executed by:
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkProxyFactory
  • tst_QNetworkSession
40
277}-
278-
279/*!-
280 Returns the unique and platform specific identifier for this network configuration;-
281 otherwise an empty string.-
282*/-
283QString QNetworkConfiguration::identifier() const-
284{-
285 if (!d)
!dDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkSession
FALSEevaluated 851 times by 16 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_Spdy
2-851
286 return QString();
executed 2 times by 1 test: return QString();
Executed by:
  • tst_QNetworkSession
2
287-
288 QMutexLocker locker(&d->mutex);-
289 return d->id;
executed 851 times by 16 tests: return d->id;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_Spdy
851
290}-
291-
292/*!-
293 Returns the type of the configuration.-
294-
295 A configuration can represent a single access point configuration or-
296 a set of access point configurations. Such a set is called service network.-
297 A configuration that is based on a service network can potentially support-
298 roaming of network sessions.-
299*/-
300QNetworkConfiguration::Type QNetworkConfiguration::type() const-
301{-
302 if (!d)
!dDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QNetworkConfiguration
FALSEevaluated 401 times by 17 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_Spdy
7-401
303 return QNetworkConfiguration::Invalid;
executed 7 times by 1 test: return QNetworkConfiguration::Invalid;
Executed by:
  • tst_QNetworkConfiguration
7
304-
305 QMutexLocker locker(&d->mutex);-
306 return d->type;
executed 401 times by 17 tests: return d->type;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_Spdy
401
307}-
308-
309/*!-
310 Returns \c true if this QNetworkConfiguration object is valid.-
311 A configuration may become invalid if the user deletes the configuration or-
312 the configuration was default-constructed.-
313-
314 The addition and removal of configurations can be monitored via the-
315 QNetworkConfigurationManager.-
316-
317 \sa QNetworkConfigurationManager-
318*/-
319bool QNetworkConfiguration::isValid() const-
320{-
321 if (!d)
!dDescription
TRUEevaluated 171 times by 17 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_Spdy
FALSEevaluated 1030 times by 12 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QXmlInputSource
  • tst_Spdy
171-1030
322 return false;
executed 171 times by 17 tests: return false;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_Spdy
171
323-
324 QMutexLocker locker(&d->mutex);-
325 return d->isValid;
executed 1030 times by 12 tests: return d->isValid;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QXmlInputSource
  • tst_Spdy
1030
326}-
327-
328/*!-
329 Returns the current state of the configuration.-
330*/-
331QNetworkConfiguration::StateFlags QNetworkConfiguration::state() const-
332{-
333 if (!d)
!dDescription
TRUEevaluated 11 times by 2 tests
Evaluated by:
  • tst_QNetworkConfiguration
  • tst_QNetworkSession
FALSEevaluated 567 times by 18 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
11-567
334 return QNetworkConfiguration::Undefined;
executed 11 times by 2 tests: return QNetworkConfiguration::Undefined;
Executed by:
  • tst_QNetworkConfiguration
  • tst_QNetworkSession
11
335-
336 QMutexLocker locker(&d->mutex);-
337 return d->state;
executed 567 times by 18 tests: return d->state;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QFtp
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QNetworkSession
  • tst_QTcpServer
  • tst_QUdpSocket
  • tst_QXmlInputSource
  • tst_QXmlStream
  • tst_Spdy
567
338}-
339-
340/*!-
341 Returns the purpose of this configuration.-
342-
343 The purpose field may be used to programmatically determine the-
344 purpose of a configuration. Such information is usually part of the-
345 access point or service network meta data.-
346*/-
347QNetworkConfiguration::Purpose QNetworkConfiguration::purpose() const-
348{-
349 if (!d)
!dDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QNetworkConfiguration
FALSEevaluated 296 times by 11 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
4-296
350 return QNetworkConfiguration::UnknownPurpose;
executed 4 times by 1 test: return QNetworkConfiguration::UnknownPurpose;
Executed by:
  • tst_QNetworkConfiguration
4
351-
352 QMutexLocker locker(&d->mutex);-
353 return d->purpose;
executed 296 times by 11 tests: return d->purpose;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
296
354}-
355-
356/*!-
357 Returns \c true if this configuration supports roaming; otherwise false.-
358*/-
359bool QNetworkConfiguration::isRoamingAvailable() const-
360{-
361 if (!d)
!dDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QNetworkConfiguration
FALSEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
2-15
362 return false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_QNetworkConfiguration
2
363-
364 QMutexLocker locker(&d->mutex);-
365 return d->roamingSupported;
executed 15 times by 2 tests: return d->roamingSupported;
Executed by:
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
15
366}-
367-
368/*!-
369 Returns all sub configurations of this network configuration in priority order. The first sub-
370 configuration in the list has the highest priority.-
371-
372 Only network configurations of type \l ServiceNetwork can have children. Otherwise this-
373 function returns an empty list.-
374*/-
375QList<QNetworkConfiguration> QNetworkConfiguration::children() const-
376{-
377 QList<QNetworkConfiguration> results;-
378-
379 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
380 return results;
never executed: return results;
0
381-
382 QMutexLocker locker(&d->mutex);-
383-
384 if (d->type != QNetworkConfiguration::ServiceNetwork || !d->isValid)
d->type != QNe...ServiceNetworkDescription
TRUEnever evaluated
FALSEnever evaluated
!d->isValidDescription
TRUEnever evaluated
FALSEnever evaluated
0
385 return results;
never executed: return results;
0
386-
387 for (auto it = d->serviceNetworkMembers.begin(), end = d->serviceNetworkMembers.end(); it != end;) {
it != endDescription
TRUEnever evaluated
FALSEnever evaluated
0
388 QNetworkConfigurationPrivatePointer p = it.value();-
389 //if we have an invalid member get rid of it -> was deleted earlier on-
390 {-
391 QMutexLocker childLocker(&p->mutex);-
392-
393 if (!p->isValid) {
!p->isValidDescription
TRUEnever evaluated
FALSEnever evaluated
0
394 it = d->serviceNetworkMembers.erase(it);-
395 continue;
never executed: continue;
0
396 }-
397 }-
398 QNetworkConfiguration item;-
399 item.d = p;-
400 results << item;-
401 ++it;-
402 }
never executed: end of block
0
403-
404 return results;
never executed: return results;
0
405}-
406-
407/*!-
408 Returns the type of bearer used by this network configuration.-
409-
410 If the bearer type is \l {QNetworkConfiguration::BearerUnknown}{unknown} the bearerTypeName()-
411 function can be used to retrieve a textural type name for the bearer.-
412-
413 An invalid network configuration always returns the BearerUnknown value.-
414-
415 \sa bearerTypeName(), bearerTypeFamily()-
416*/-
417QNetworkConfiguration::BearerType QNetworkConfiguration::bearerType() const-
418{-
419 if (!isValid())
!isValid()Description
TRUEnever evaluated
FALSEevaluated 408 times by 9 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
0-408
420 return BearerUnknown;
never executed: return BearerUnknown;
0
421-
422 QMutexLocker locker(&d->mutex);-
423 return d->bearerType;
executed 408 times by 9 tests: return d->bearerType;
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QHttpNetworkConnection
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QNetworkProxyFactory
  • tst_QNetworkReply
  • tst_QXmlInputSource
  • tst_Spdy
408
424}-
425-
426/*!-
427 \since 5.2-
428-
429 Returns the bearer type family used by this network configuration.-
430 The following table lists how bearerType() values map to-
431 bearerTypeFamily() values:-
432-
433 \table-
434 \header-
435 \li bearer type-
436 \li bearer type family-
437 \row-
438 \li BearerUnknown, Bearer2G, BearerEthernet, BearerWLAN,-
439 BearerBluetooth-
440 \li (same type)-
441 \row-
442 \li BearerCDMA2000, BearerEVDO, BearerWCDMA, BearerHSPA, Bearer3G-
443 \li Bearer3G-
444 \row-
445 \li BearerWiMAX, BearerLTE, Bearer4G-
446 \li Bearer4G-
447 \endtable-
448-
449 An invalid network configuration always returns the BearerUnknown value.-
450-
451 \sa bearerType(), bearerTypeName()-
452*/-
453QNetworkConfiguration::BearerType QNetworkConfiguration::bearerTypeFamily() const-
454{-
455 QNetworkConfiguration::BearerType type = bearerType();-
456 switch (type) {-
457 case QNetworkConfiguration::BearerUnknown: // fallthrough
never executed: case QNetworkConfiguration::BearerUnknown:
0
458 case QNetworkConfiguration::Bearer2G: // fallthrough
never executed: case QNetworkConfiguration::Bearer2G:
0
459 case QNetworkConfiguration::BearerEthernet: // fallthrough
never executed: case QNetworkConfiguration::BearerEthernet:
0
460 case QNetworkConfiguration::BearerWLAN: // fallthrough
never executed: case QNetworkConfiguration::BearerWLAN:
0
461 case QNetworkConfiguration::BearerBluetooth:
never executed: case QNetworkConfiguration::BearerBluetooth:
0
462 return type;
never executed: return type;
0
463 case QNetworkConfiguration::BearerCDMA2000: // fallthrough
never executed: case QNetworkConfiguration::BearerCDMA2000:
0
464 case QNetworkConfiguration::BearerEVDO: // fallthrough
never executed: case QNetworkConfiguration::BearerEVDO:
0
465 case QNetworkConfiguration::BearerWCDMA: // fallthrough
never executed: case QNetworkConfiguration::BearerWCDMA:
0
466 case QNetworkConfiguration::BearerHSPA: // fallthrough
never executed: case QNetworkConfiguration::BearerHSPA:
0
467 case QNetworkConfiguration::Bearer3G:
never executed: case QNetworkConfiguration::Bearer3G:
0
468 return QNetworkConfiguration::Bearer3G;
never executed: return QNetworkConfiguration::Bearer3G;
0
469 case QNetworkConfiguration::BearerWiMAX: // fallthrough
never executed: case QNetworkConfiguration::BearerWiMAX:
0
470 case QNetworkConfiguration::BearerLTE: // fallthrough
never executed: case QNetworkConfiguration::BearerLTE:
0
471 case QNetworkConfiguration::Bearer4G:
never executed: case QNetworkConfiguration::Bearer4G:
0
472 return QNetworkConfiguration::Bearer4G;
never executed: return QNetworkConfiguration::Bearer4G;
0
473 default:
never executed: default:
0
474 qWarning() << "unknown bearer type" << type;-
475 return QNetworkConfiguration::BearerUnknown;
never executed: return QNetworkConfiguration::BearerUnknown;
0
476 }-
477}-
478/*!-
479 Returns the type of bearer used by this network configuration as a string.-
480-
481 The string is not translated and therefore can not be shown to the user. The subsequent table-
482 shows the fixed mappings between BearerType and the bearer type name for known types. If the-
483 BearerType is unknown this function may return additional information if it is available;-
484 otherwise an empty string will be returned.-
485-
486 \table-
487 \header-
488 \li BearerType-
489 \li Value-
490 \row-
491 \li BearerUnknown-
492 \li The session is based on an unknown or unspecified bearer type. The value of the-
493 string returned describes the bearer type.-
494 \row-
495 \li BearerEthernet-
496 \li Ethernet-
497 \row-
498 \li BearerWLAN-
499 \li WLAN-
500 \row-
501 \li Bearer2G-
502 \li 2G-
503 \row-
504 \li Bearer3G-
505 \li 3G-
506 \row-
507 \li Bearer4G-
508 \li 4G-
509 \row-
510 \li BearerCDMA2000-
511 \li CDMA2000-
512 \row-
513 \li BearerWCDMA-
514 \li WCDMA-
515 \row-
516 \li BearerHSPA-
517 \li HSPA-
518 \row-
519 \li BearerBluetooth-
520 \li Bluetooth-
521 \row-
522 \li BearerWiMAX-
523 \li WiMAX-
524 \row-
525 \li BearerEVDO-
526 \li EVDO-
527 \row-
528 \li BearerLTE-
529 \li LTE-
530 \endtable-
531-
532 This function returns an empty string if this is an invalid configuration, a network-
533 configuration of type \l QNetworkConfiguration::ServiceNetwork or-
534 \l QNetworkConfiguration::UserChoice.-
535-
536 \sa bearerType(), bearerTypeFamily()-
537*/-
538QString QNetworkConfiguration::bearerTypeName() const-
539{-
540 if (!isValid())
!isValid()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QNetworkSession
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkSession
1-3
541 return QString();
executed 1 time by 1 test: return QString();
Executed by:
  • tst_QNetworkSession
1
542-
543 QMutexLocker locker(&d->mutex);-
544-
545 if (d->type == QNetworkConfiguration::ServiceNetwork ||
d->type == QNe...ServiceNetworkDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkSession
0-3
546 d->type == QNetworkConfiguration::UserChoice)
d->type == QNe...on::UserChoiceDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QNetworkSession
0-3
547 return QString();
never executed: return QString();
0
548-
549 switch (d->bearerType) {-
550 case BearerEthernet:
executed 3 times by 1 test: case BearerEthernet:
Executed by:
  • tst_QNetworkSession
3
551 return QStringLiteral("Ethernet");
executed 3 times by 1 test: return ([]() -> QString { enum { Size = sizeof(u"" "Ethernet")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Ethernet" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
Executed by:
  • tst_QNetworkSession
executed 3 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QNetworkSession
3
552 case BearerWLAN:
never executed: case BearerWLAN:
0
553 return QStringLiteral("WLAN");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "WLAN")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "WLAN" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
554 case Bearer2G:
never executed: case Bearer2G:
0
555 return QStringLiteral("2G");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "2G")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "2G" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
556 case Bearer3G:
never executed: case Bearer3G:
0
557 return QStringLiteral("3G");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "3G")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "3G" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
558 case Bearer4G:
never executed: case Bearer4G:
0
559 return QStringLiteral("4G");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "4G")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "4G" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
560 case BearerCDMA2000:
never executed: case BearerCDMA2000:
0
561 return QStringLiteral("CDMA2000");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "CDMA2000")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "CDMA2000" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
562 case BearerWCDMA:
never executed: case BearerWCDMA:
0
563 return QStringLiteral("WCDMA");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "WCDMA")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "WCDMA" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
564 case BearerHSPA:
never executed: case BearerHSPA:
0
565 return QStringLiteral("HSPA");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "HSPA")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "HSPA" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
566 case BearerBluetooth:
never executed: case BearerBluetooth:
0
567 return QStringLiteral("Bluetooth");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "Bluetooth")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Bluetooth" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
568 case BearerWiMAX:
never executed: case BearerWiMAX:
0
569 return QStringLiteral("WiMAX");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "WiMAX")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "WiMAX" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
570 case BearerEVDO:
never executed: case BearerEVDO:
0
571 return QStringLiteral("EVDO");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "EVDO")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "EVDO" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
572 case BearerLTE:
never executed: case BearerLTE:
0
573 return QStringLiteral("LTE");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "LTE")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "LTE" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
574 case BearerUnknown:
never executed: case BearerUnknown:
0
575 break;
never executed: break;
0
576 }-
577 return QStringLiteral("Unknown");
never executed: return ([]() -> QString { enum { Size = sizeof(u"" "Unknown")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Unknown" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
never executed: return qstring_literal_temp;
0
578}-
579-
580QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9