bearer/qnetworkconfigmanager_p.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtNetwork module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qnetworkconfigmanager_p.h" -
43#include "qbearerplugin_p.h" -
44 -
45#include <QtCore/private/qfactoryloader_p.h> -
46 -
47#include <QtCore/qdebug.h> -
48#include <QtCore/qtimer.h> -
49#include <QtCore/qstringlist.h> -
50#include <QtCore/qthread.h> -
51#include <QtCore/private/qcoreapplication_p.h> -
52 -
53#ifndef QT_NO_BEARERMANAGEMENT -
54 -
55QT_BEGIN_NAMESPACE -
56 -
57#ifndef QT_NO_LIBRARY -
58Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:14
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
partially evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
59 (QBearerEngineFactoryInterface_iid, QLatin1String("/bearer"))) -
60#endif -
61 -
62QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() -
63 : QObject(), pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) -
64{ -
65 qRegisterMetaType<QNetworkConfiguration>();
executed (the execution status of this line is deduced): qRegisterMetaType<QNetworkConfiguration>();
-
66 qRegisterMetaType<QNetworkConfigurationPrivatePointer>();
executed (the execution status of this line is deduced): qRegisterMetaType<QNetworkConfigurationPrivatePointer>();
-
67}
executed: }
Execution Count:14
14
68 -
69void QNetworkConfigurationManagerPrivate::initialize() -
70{ -
71 //Two stage construction, because we only want to do this heavyweight work for the winner of the Q_GLOBAL_STATIC race. -
72 bearerThread = new QThread();
executed (the execution status of this line is deduced): bearerThread = new QThread();
-
73 bearerThread->setObjectName(QStringLiteral("bearerThread"));
executed (the execution status of this line is deduced): bearerThread->setObjectName(QString::fromUtf8("" "bearerThread" "", sizeof("bearerThread") - 1));
-
74 -
75 bearerThread->moveToThread(QCoreApplicationPrivate::mainThread()); // because cleanup() is called in main thread context.
executed (the execution status of this line is deduced): bearerThread->moveToThread(QCoreApplicationPrivate::mainThread());
-
76 moveToThread(bearerThread);
executed (the execution status of this line is deduced): moveToThread(bearerThread);
-
77 bearerThread->start();
executed (the execution status of this line is deduced): bearerThread->start();
-
78 updateConfigurations();
executed (the execution status of this line is deduced): updateConfigurations();
-
79}
executed: }
Execution Count:14
14
80 -
81QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() -
82{ -
83 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
84 -
85 qDeleteAll(sessionEngines);
executed (the execution status of this line is deduced): qDeleteAll(sessionEngines);
-
86 if (bearerThread)
partially evaluated: bearerThread
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
87 bearerThread->quit();
executed: bearerThread->quit();
Execution Count:14
14
88}
executed: }
Execution Count:14
14
89 -
90void QNetworkConfigurationManagerPrivate::cleanup() -
91{ -
92 QThread* thread = bearerThread;
executed (the execution status of this line is deduced): QThread* thread = bearerThread;
-
93 deleteLater();
executed (the execution status of this line is deduced): deleteLater();
-
94 if (thread->wait(5000))
partially evaluated: thread->wait(5000)
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
95 delete thread;
executed: delete thread;
Execution Count:14
14
96}
executed: }
Execution Count:14
14
97 -
98QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() const -
99{ -
100 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
101 -
102 foreach (QBearerEngine *engine, sessionEngines) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sessionEngines)> _container_(sessionEngines); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QBearerEngine *engine = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
103 QNetworkConfigurationPrivatePointer ptr = engine->defaultConfiguration();
executed (the execution status of this line is deduced): QNetworkConfigurationPrivatePointer ptr = engine->defaultConfiguration();
-
104 if (ptr) {
partially evaluated: ptr
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
105 QNetworkConfiguration config;
never executed (the execution status of this line is deduced): QNetworkConfiguration config;
-
106 config.d = ptr;
never executed (the execution status of this line is deduced): config.d = ptr;
-
107 return config;
never executed: return config;
0
108 } -
109 }
executed: }
Execution Count:13
13
110 -
111 // Engines don't have a default configuration. -
112 -
113 // Return first active snap -
114 QNetworkConfigurationPrivatePointer defaultConfiguration;
executed (the execution status of this line is deduced): QNetworkConfigurationPrivatePointer defaultConfiguration;
-
115 -
116 foreach (QBearerEngine *engine, sessionEngines) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sessionEngines)> _container_(sessionEngines); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QBearerEngine *engine = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
117 QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
executed (the execution status of this line is deduced): QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
-
118 QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
executed (the execution status of this line is deduced): QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
-
119 -
120 QMutexLocker locker(&engine->mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&engine->mutex);
-
121 -
122 for (it = engine->snapConfigurations.begin(),
executed (the execution status of this line is deduced): for (it = engine->snapConfigurations.begin(),
-
123 end = engine->snapConfigurations.end(); it != end; ++it) {
partially evaluated: it != end
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
124 QNetworkConfigurationPrivatePointer ptr = it.value();
never executed (the execution status of this line is deduced): QNetworkConfigurationPrivatePointer ptr = it.value();
-
125 -
126 QMutexLocker configLocker(&ptr->mutex);
never executed (the execution status of this line is deduced): QMutexLocker configLocker(&ptr->mutex);
-
127 -
128 if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
never evaluated: (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active
0
129 QNetworkConfiguration config;
never executed (the execution status of this line is deduced): QNetworkConfiguration config;
-
130 config.d = ptr;
never executed (the execution status of this line is deduced): config.d = ptr;
-
131 return config;
never executed: return config;
0
132 } else if (!defaultConfiguration) {
never evaluated: !defaultConfiguration
0
133 if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered)
never evaluated: (ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered
0
134 defaultConfiguration = ptr;
never executed: defaultConfiguration = ptr;
0
135 }
never executed: }
0
136 } -
137 }
executed: }
Execution Count:13
13
138 -
139 // No Active SNAPs return first Discovered SNAP. -
140 if (defaultConfiguration) {
partially evaluated: defaultConfiguration
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
141 QNetworkConfiguration config;
never executed (the execution status of this line is deduced): QNetworkConfiguration config;
-
142 config.d = defaultConfiguration;
never executed (the execution status of this line is deduced): config.d = defaultConfiguration;
-
143 return config;
never executed: return config;
0
144 } -
145 -
146 /* -
147 No Active or Discovered SNAPs, find the perferred access point. -
148 The following priority order is used: -
149 -
150 1. Active Ethernet -
151 2. Active WLAN -
152 3. Active Other -
153 4. Discovered Ethernet -
154 5. Discovered WLAN -
155 6. Discovered Other -
156 */ -
157 -
158 foreach (QBearerEngine *engine, sessionEngines) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sessionEngines)> _container_(sessionEngines); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QBearerEngine *engine = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
159 QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
executed (the execution status of this line is deduced): QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
-
160 QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
executed (the execution status of this line is deduced): QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
-
161 -
162 QMutexLocker locker(&engine->mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&engine->mutex);
-
163 -
164 for (it = engine->accessPointConfigurations.begin(),
executed (the execution status of this line is deduced): for (it = engine->accessPointConfigurations.begin(),
-
165 end = engine->accessPointConfigurations.end(); it != end; ++it) {
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:13
13-52
166 QNetworkConfigurationPrivatePointer ptr = it.value();
executed (the execution status of this line is deduced): QNetworkConfigurationPrivatePointer ptr = it.value();
-
167 -
168 QMutexLocker configLocker(&ptr->mutex);
executed (the execution status of this line is deduced): QMutexLocker configLocker(&ptr->mutex);
-
169 QNetworkConfiguration::BearerType bearerType = ptr->bearerType;
executed (the execution status of this line is deduced): QNetworkConfiguration::BearerType bearerType = ptr->bearerType;
-
170 -
171 if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
evaluated: (ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:13
13-39
172 if (!defaultConfiguration) {
evaluated: !defaultConfiguration
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:26
13-26
173 defaultConfiguration = ptr;
executed (the execution status of this line is deduced): defaultConfiguration = ptr;
-
174 } else {
executed: }
Execution Count:13
13
175 QMutexLocker defaultConfigLocker(&defaultConfiguration->mutex);
executed (the execution status of this line is deduced): QMutexLocker defaultConfigLocker(&defaultConfiguration->mutex);
-
176 -
177 if (defaultConfiguration->state == ptr->state) {
partially evaluated: defaultConfiguration->state == ptr->state
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-26
178 switch (defaultConfiguration->bearerType) { -
179 case QNetworkConfiguration::BearerEthernet: -
180 // do nothing -
181 break;
executed: break;
Execution Count:26
26
182 case QNetworkConfiguration::BearerWLAN: -
183 // Ethernet beats WLAN -
184 defaultConfiguration = ptr;
never executed (the execution status of this line is deduced): defaultConfiguration = ptr;
-
185 break;
never executed: break;
0
186 default: -
187 // Ethernet and WLAN beats other -
188 if (bearerType == QNetworkConfiguration::BearerEthernet ||
never evaluated: bearerType == QNetworkConfiguration::BearerEthernet
0
189 bearerType == QNetworkConfiguration::BearerWLAN) {
never evaluated: bearerType == QNetworkConfiguration::BearerWLAN
0
190 defaultConfiguration = ptr;
never executed (the execution status of this line is deduced): defaultConfiguration = ptr;
-
191 }
never executed: }
0
192 }
never executed: }
0
193 } else {
executed: }
Execution Count:26
26
194 // active beats discovered -
195 if ((defaultConfiguration->state & QNetworkConfiguration::Active) !=
never evaluated: (defaultConfiguration->state & QNetworkConfiguration::Active) != QNetworkConfiguration::Active
0
196 QNetworkConfiguration::Active) {
never evaluated: (defaultConfiguration->state & QNetworkConfiguration::Active) != QNetworkConfiguration::Active
0
197 defaultConfiguration = ptr;
never executed (the execution status of this line is deduced): defaultConfiguration = ptr;
-
198 }
never executed: }
0
199 }
never executed: }
0
200 } -
201 } -
202 }
executed: }
Execution Count:52
52
203 }
executed: }
Execution Count:13
13
204 -
205 // No Active InternetAccessPoint return first Discovered InternetAccessPoint. -
206 if (defaultConfiguration) {
partially evaluated: defaultConfiguration
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
207 QNetworkConfiguration config;
executed (the execution status of this line is deduced): QNetworkConfiguration config;
-
208 config.d = defaultConfiguration;
executed (the execution status of this line is deduced): config.d = defaultConfiguration;
-
209 return config;
executed: return config;
Execution Count:13
13
210 } -
211 -
212 return QNetworkConfiguration();
never executed: return QNetworkConfiguration();
0
213} -
214 -
215QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurations(QNetworkConfiguration::StateFlags filter) const -
216{ -
217 QList<QNetworkConfiguration> result;
executed (the execution status of this line is deduced): QList<QNetworkConfiguration> result;
-
218 -
219 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
220 -
221 foreach (QBearerEngine *engine, sessionEngines) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sessionEngines)> _container_(sessionEngines); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QBearerEngine *engine = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
222 QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
executed (the execution status of this line is deduced): QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
-
223 QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
executed (the execution status of this line is deduced): QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
-
224 -
225 QMutexLocker locker(&engine->mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&engine->mutex);
-
226 -
227 //find all InternetAccessPoints -
228 for (it = engine->accessPointConfigurations.begin(),
executed (the execution status of this line is deduced): for (it = engine->accessPointConfigurations.begin(),
-
229 end = engine->accessPointConfigurations.end(); it != end; ++it) {
evaluated: it != end
TRUEFALSE
yes
Evaluation Count:108
yes
Evaluation Count:27
27-108
230 QNetworkConfigurationPrivatePointer ptr = it.value();
executed (the execution status of this line is deduced): QNetworkConfigurationPrivatePointer ptr = it.value();
-
231 -
232 QMutexLocker configLocker(&ptr->mutex);
executed (the execution status of this line is deduced): QMutexLocker configLocker(&ptr->mutex);
-
233 -
234 if ((ptr->state & filter) == filter) {
evaluated: (ptr->state & filter) == filter
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:13
13-95
235 QNetworkConfiguration pt;
executed (the execution status of this line is deduced): QNetworkConfiguration pt;
-
236 pt.d = ptr;
executed (the execution status of this line is deduced): pt.d = ptr;
-
237 result << pt;
executed (the execution status of this line is deduced): result << pt;
-
238 }
executed: }
Execution Count:95
95
239 }
executed: }
Execution Count:108
108
240 -
241 //find all service networks -
242 for (it = engine->snapConfigurations.begin(),
executed (the execution status of this line is deduced): for (it = engine->snapConfigurations.begin(),
-
243 end = engine->snapConfigurations.end(); it != end; ++it) {
partially evaluated: it != end
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:27
0-27
244 QNetworkConfigurationPrivatePointer ptr = it.value();
never executed (the execution status of this line is deduced): QNetworkConfigurationPrivatePointer ptr = it.value();
-
245 -
246 QMutexLocker configLocker(&ptr->mutex);
never executed (the execution status of this line is deduced): QMutexLocker configLocker(&ptr->mutex);
-
247 -
248 if ((ptr->state & filter) == filter) {
never evaluated: (ptr->state & filter) == filter
0
249 QNetworkConfiguration pt;
never executed (the execution status of this line is deduced): QNetworkConfiguration pt;
-
250 pt.d = ptr;
never executed (the execution status of this line is deduced): pt.d = ptr;
-
251 result << pt;
never executed (the execution status of this line is deduced): result << pt;
-
252 }
never executed: }
0
253 }
never executed: }
0
254 }
executed: }
Execution Count:27
27
255 -
256 return result;
executed: return result;
Execution Count:27
27
257} -
258 -
259QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier(const QString &identifier) const -
260{ -
261 QNetworkConfiguration item;
executed (the execution status of this line is deduced): QNetworkConfiguration item;
-
262 -
263 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
264 -
265 foreach (QBearerEngine *engine, sessionEngines) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sessionEngines)> _container_(sessionEngines); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QBearerEngine *engine = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
266 QMutexLocker locker(&engine->mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&engine->mutex);
-
267 -
268 if (engine->accessPointConfigurations.contains(identifier))
evaluated: engine->accessPointConfigurations.contains(identifier)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
269 item.d = engine->accessPointConfigurations[identifier];
executed: item.d = engine->accessPointConfigurations[identifier];
Execution Count:4
4
270 else if (engine->snapConfigurations.contains(identifier))
partially evaluated: engine->snapConfigurations.contains(identifier)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
271 item.d = engine->snapConfigurations[identifier];
never executed: item.d = engine->snapConfigurations[identifier];
0
272 else if (engine->userChoiceConfigurations.contains(identifier))
partially evaluated: engine->userChoiceConfigurations.contains(identifier)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
273 item.d = engine->userChoiceConfigurations[identifier];
never executed: item.d = engine->userChoiceConfigurations[identifier];
0
274 else -
275 continue;
executed: continue;
Execution Count:1
1
276 -
277 return item;
executed: return item;
Execution Count:4
4
278 } -
279 -
280 return item;
executed: return item;
Execution Count:1
1
281} -
282 -
283bool QNetworkConfigurationManagerPrivate::isOnline() const -
284{ -
285 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
286 -
287 return !onlineConfigurations.isEmpty();
executed: return !onlineConfigurations.isEmpty();
Execution Count:1
1
288} -
289 -
290QNetworkConfigurationManager::Capabilities QNetworkConfigurationManagerPrivate::capabilities() const -
291{ -
292 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
293 -
294 QNetworkConfigurationManager::Capabilities capFlags;
executed (the execution status of this line is deduced): QNetworkConfigurationManager::Capabilities capFlags;
-
295 -
296 foreach (QBearerEngine *engine, sessionEngines)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sessionEngines)> _container_(sessionEngines); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QBearerEngine *engine = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
297 capFlags |= engine->capabilities();
executed: capFlags |= engine->capabilities();
Execution Count:84
84
298 -
299 return capFlags;
executed: return capFlags;
Execution Count:84
84
300} -
301 -
302void QNetworkConfigurationManagerPrivate::configurationAdded(QNetworkConfigurationPrivatePointer ptr) -
303{ -
304 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
305 -
306 if (!firstUpdate) {
partially evaluated: !firstUpdate
TRUEFALSE
yes
Evaluation Count:56
no
Evaluation Count:0
0-56
307 QNetworkConfiguration item;
executed (the execution status of this line is deduced): QNetworkConfiguration item;
-
308 item.d = ptr;
executed (the execution status of this line is deduced): item.d = ptr;
-
309 emit configurationAdded(item);
executed (the execution status of this line is deduced): configurationAdded(item);
-
310 }
executed: }
Execution Count:56
56
311 -
312 ptr->mutex.lock();
executed (the execution status of this line is deduced): ptr->mutex.lock();
-
313 if (ptr->state == QNetworkConfiguration::Active) {
evaluated: ptr->state == QNetworkConfiguration::Active
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:14
14-42
314 ptr->mutex.unlock();
executed (the execution status of this line is deduced): ptr->mutex.unlock();
-
315 onlineConfigurations.insert(ptr->id);
executed (the execution status of this line is deduced): onlineConfigurations.insert(ptr->id);
-
316 if (!firstUpdate && onlineConfigurations.count() == 1)
partially evaluated: !firstUpdate
TRUEFALSE
yes
Evaluation Count:42
no
Evaluation Count:0
evaluated: onlineConfigurations.count() == 1
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:28
0-42
317 emit onlineStateChanged(true);
executed: onlineStateChanged(true);
Execution Count:14
14
318 } else {
executed: }
Execution Count:42
42
319 ptr->mutex.unlock();
executed (the execution status of this line is deduced): ptr->mutex.unlock();
-
320 }
executed: }
Execution Count:14
14
321} -
322 -
323void QNetworkConfigurationManagerPrivate::configurationRemoved(QNetworkConfigurationPrivatePointer ptr) -
324{ -
325 QMutexLocker locker(&mutex);
never executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
326 -
327 ptr->mutex.lock();
never executed (the execution status of this line is deduced): ptr->mutex.lock();
-
328 ptr->isValid = false;
never executed (the execution status of this line is deduced): ptr->isValid = false;
-
329 ptr->mutex.unlock();
never executed (the execution status of this line is deduced): ptr->mutex.unlock();
-
330 -
331 if (!firstUpdate) {
never evaluated: !firstUpdate
0
332 QNetworkConfiguration item;
never executed (the execution status of this line is deduced): QNetworkConfiguration item;
-
333 item.d = ptr;
never executed (the execution status of this line is deduced): item.d = ptr;
-
334 emit configurationRemoved(item);
never executed (the execution status of this line is deduced): configurationRemoved(item);
-
335 }
never executed: }
0
336 -
337 onlineConfigurations.remove(ptr->id);
never executed (the execution status of this line is deduced): onlineConfigurations.remove(ptr->id);
-
338 if (!firstUpdate && onlineConfigurations.isEmpty())
never evaluated: !firstUpdate
never evaluated: onlineConfigurations.isEmpty()
0
339 emit onlineStateChanged(false);
never executed: onlineStateChanged(false);
0
340}
never executed: }
0
341 -
342void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigurationPrivatePointer ptr) -
343{ -
344 QMutexLocker locker(&mutex);
never executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
345 -
346 if (!firstUpdate) {
never evaluated: !firstUpdate
0
347 QNetworkConfiguration item;
never executed (the execution status of this line is deduced): QNetworkConfiguration item;
-
348 item.d = ptr;
never executed (the execution status of this line is deduced): item.d = ptr;
-
349 emit configurationChanged(item);
never executed (the execution status of this line is deduced): configurationChanged(item);
-
350 }
never executed: }
0
351 -
352 bool previous = !onlineConfigurations.isEmpty();
never executed (the execution status of this line is deduced): bool previous = !onlineConfigurations.isEmpty();
-
353 -
354 ptr->mutex.lock();
never executed (the execution status of this line is deduced): ptr->mutex.lock();
-
355 if (ptr->state == QNetworkConfiguration::Active)
never evaluated: ptr->state == QNetworkConfiguration::Active
0
356 onlineConfigurations.insert(ptr->id);
never executed: onlineConfigurations.insert(ptr->id);
0
357 else -
358 onlineConfigurations.remove(ptr->id);
never executed: onlineConfigurations.remove(ptr->id);
0
359 ptr->mutex.unlock();
never executed (the execution status of this line is deduced): ptr->mutex.unlock();
-
360 -
361 bool online = !onlineConfigurations.isEmpty();
never executed (the execution status of this line is deduced): bool online = !onlineConfigurations.isEmpty();
-
362 -
363 if (!firstUpdate && online != previous)
never evaluated: !firstUpdate
never evaluated: online != previous
0
364 emit onlineStateChanged(online);
never executed: onlineStateChanged(online);
0
365}
never executed: }
0
366 -
367void QNetworkConfigurationManagerPrivate::updateConfigurations() -
368{ -
369#ifndef QT_NO_LIBRARY -
370 typedef QMultiMap<int, QString> PluginKeyMap;
executed (the execution status of this line is deduced): typedef QMultiMap<int, QString> PluginKeyMap;
-
371 typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
executed (the execution status of this line is deduced): typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
-
372#endif -
373 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
374 -
375 if (firstUpdate) {
evaluated: firstUpdate
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:68
14-68
376 if (qobject_cast<QBearerEngine *>(sender()))
partially evaluated: qobject_cast<QBearerEngine *>(sender())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
377 return;
never executed: return;
0
378 -
379 updating = false;
executed (the execution status of this line is deduced): updating = false;
-
380 -
381#ifndef QT_NO_LIBRARY -
382 QBearerEngine *generic = 0;
executed (the execution status of this line is deduced): QBearerEngine *generic = 0;
-
383 QFactoryLoader *l = loader();
executed (the execution status of this line is deduced): QFactoryLoader *l = loader();
-
384 const PluginKeyMap keyMap = l->keyMap();
executed (the execution status of this line is deduced): const PluginKeyMap keyMap = l->keyMap();
-
385 const PluginKeyMapConstIterator cend = keyMap.constEnd();
executed (the execution status of this line is deduced): const PluginKeyMapConstIterator cend = keyMap.constEnd();
-
386 QStringList addedEngines;
executed (the execution status of this line is deduced): QStringList addedEngines;
-
387 for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) {
evaluated: it != cend
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:14
14-42
388 const QString &key = it.value();
executed (the execution status of this line is deduced): const QString &key = it.value();
-
389 if (addedEngines.contains(key))
partially evaluated: addedEngines.contains(key)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
390 continue;
never executed: continue;
0
391 -
392 addedEngines.append(key);
executed (the execution status of this line is deduced): addedEngines.append(key);
-
393 if (QBearerEngine *engine = qLoadPlugin<QBearerEngine, QBearerEnginePlugin>(l, key)) {
evaluated: QBearerEngine *engine = qLoadPlugin<QBearerEngine, QBearerEnginePlugin>(l, key)
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:28
14-28
394 if (key == QLatin1String("generic"))
partially evaluated: key == QLatin1String("generic")
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
395 generic = engine;
executed: generic = engine;
Execution Count:14
14
396 else -
397 sessionEngines.append(engine);
never executed: sessionEngines.append(engine);
0
398 -
399 engine->moveToThread(bearerThread);
executed (the execution status of this line is deduced): engine->moveToThread(bearerThread);
-
400 -
401 connect(engine, SIGNAL(updateCompleted()),
executed (the execution status of this line is deduced): connect(engine, "2""updateCompleted()",
-
402 this, SLOT(updateConfigurations()),
executed (the execution status of this line is deduced): this, "1""updateConfigurations()",
-
403 Qt::QueuedConnection);
executed (the execution status of this line is deduced): Qt::QueuedConnection);
-
404 connect(engine, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)),
executed (the execution status of this line is deduced): connect(engine, "2""configurationAdded(QNetworkConfigurationPrivatePointer)",
-
405 this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer)),
executed (the execution status of this line is deduced): this, "1""configurationAdded(QNetworkConfigurationPrivatePointer)",
-
406 Qt::QueuedConnection);
executed (the execution status of this line is deduced): Qt::QueuedConnection);
-
407 connect(engine, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)),
executed (the execution status of this line is deduced): connect(engine, "2""configurationRemoved(QNetworkConfigurationPrivatePointer)",
-
408 this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer)),
executed (the execution status of this line is deduced): this, "1""configurationRemoved(QNetworkConfigurationPrivatePointer)",
-
409 Qt::QueuedConnection);
executed (the execution status of this line is deduced): Qt::QueuedConnection);
-
410 connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
executed (the execution status of this line is deduced): connect(engine, "2""configurationChanged(QNetworkConfigurationPrivatePointer)",
-
411 this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)),
executed (the execution status of this line is deduced): this, "1""configurationChanged(QNetworkConfigurationPrivatePointer)",
-
412 Qt::QueuedConnection);
executed (the execution status of this line is deduced): Qt::QueuedConnection);
-
413 }
executed: }
Execution Count:14
14
414 }
executed: }
Execution Count:42
42
415 -
416 if (generic)
partially evaluated: generic
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
417 sessionEngines.append(generic);
executed: sessionEngines.append(generic);
Execution Count:14
14
418#endif // QT_NO_LIBRARY -
419 }
executed: }
Execution Count:14
14
420 -
421 QBearerEngine *engine = qobject_cast<QBearerEngine *>(sender());
executed (the execution status of this line is deduced): QBearerEngine *engine = qobject_cast<QBearerEngine *>(sender());
-
422 if (engine && !updatingEngines.isEmpty())
evaluated: engine
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:14
evaluated: !updatingEngines.isEmpty()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:52
14-68
423 updatingEngines.remove(engine);
executed: updatingEngines.remove(engine);
Execution Count:16
16
424 -
425 if (updating && updatingEngines.isEmpty()) {
evaluated: updating
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:66
partially evaluated: updatingEngines.isEmpty()
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-66
426 updating = false;
executed (the execution status of this line is deduced): updating = false;
-
427 emit configurationUpdateComplete();
executed (the execution status of this line is deduced): configurationUpdateComplete();
-
428 }
executed: }
Execution Count:16
16
429 -
430 if (engine && !pollingEngines.isEmpty()) {
evaluated: engine
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:14
evaluated: !pollingEngines.isEmpty()
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:30
14-68
431 pollingEngines.remove(engine);
executed (the execution status of this line is deduced): pollingEngines.remove(engine);
-
432 if (pollingEngines.isEmpty())
partially evaluated: pollingEngines.isEmpty()
TRUEFALSE
yes
Evaluation Count:38
no
Evaluation Count:0
0-38
433 startPolling();
executed: startPolling();
Execution Count:38
38
434 }
executed: }
Execution Count:38
38
435 -
436 if (firstUpdate) {
evaluated: firstUpdate
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:68
14-68
437 firstUpdate = false;
executed (the execution status of this line is deduced): firstUpdate = false;
-
438 QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex
executed (the execution status of this line is deduced): QList<QBearerEngine*> enginesToInitialize = sessionEngines;
-
439 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
440 foreach (QBearerEngine* engine, enginesToInitialize) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(enginesToInitialize)> _container_(enginesToInitialize); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QBearerEngine* engine = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
441 QMetaObject::invokeMethod(engine, "initialize", Qt::BlockingQueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(engine, "initialize", Qt::BlockingQueuedConnection);
-
442 }
executed: }
Execution Count:14
14
443 }
executed: }
Execution Count:14
14
444}
executed: }
Execution Count:82
82
445 -
446void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate() -
447{ -
448 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
449 -
450 if (sessionEngines.isEmpty()) {
partially evaluated: sessionEngines.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
451 emit configurationUpdateComplete();
never executed (the execution status of this line is deduced): configurationUpdateComplete();
-
452 return;
never executed: return;
0
453 } -
454 -
455 updating = true;
executed (the execution status of this line is deduced): updating = true;
-
456 -
457 foreach (QBearerEngine *engine, sessionEngines) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sessionEngines)> _container_(sessionEngines); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QBearerEngine *engine = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
458 updatingEngines.insert(engine);
executed (the execution status of this line is deduced): updatingEngines.insert(engine);
-
459 QMetaObject::invokeMethod(engine, "requestUpdate");
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(engine, "requestUpdate");
-
460 }
executed: }
Execution Count:16
16
461}
executed: }
Execution Count:16
16
462 -
463QList<QBearerEngine *> QNetworkConfigurationManagerPrivate::engines() const -
464{ -
465 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
466 -
467 return sessionEngines;
executed: return sessionEngines;
Execution Count:76
76
468} -
469 -
470void QNetworkConfigurationManagerPrivate::startPolling() -
471{ -
472 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
473 -
474 if(!pollTimer) {
evaluated: !pollTimer
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:46
14-46
475 pollTimer = new QTimer(this);
executed (the execution status of this line is deduced): pollTimer = new QTimer(this);
-
476 pollTimer->setInterval(10000);
executed (the execution status of this line is deduced): pollTimer->setInterval(10000);
-
477 pollTimer->setSingleShot(true);
executed (the execution status of this line is deduced): pollTimer->setSingleShot(true);
-
478 connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines()));
executed (the execution status of this line is deduced): connect(pollTimer, "2""timeout()", this, "1""pollEngines()");
-
479 }
executed: }
Execution Count:14
14
480 -
481 if(pollTimer->isActive())
evaluated: pollTimer->isActive()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:53
7-53
482 return;
executed: return;
Execution Count:7
7
483 -
484 foreach (QBearerEngine *engine, sessionEngines) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sessionEngines)> _container_(sessionEngines); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QBearerEngine *engine = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
485 if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
partially evaluated: engine->requiresPolling()
TRUEFALSE
yes
Evaluation Count:53
no
Evaluation Count:0
evaluated: forcedPolling
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:6
evaluated: engine->configurationsInUse()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
0-53
486 pollTimer->start();
executed (the execution status of this line is deduced): pollTimer->start();
-
487 break;
executed: break;
Execution Count:49
49
488 } -
489 }
executed: }
Execution Count:4
4
490}
executed: }
Execution Count:53
53
491 -
492void QNetworkConfigurationManagerPrivate::pollEngines() -
493{ -
494 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
495 -
496 foreach (QBearerEngine *engine, sessionEngines) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sessionEngines)> _container_(sessionEngines); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QBearerEngine *engine = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
497 if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
partially evaluated: engine->requiresPolling()
TRUEFALSE
yes
Evaluation Count:38
no
Evaluation Count:0
evaluated: forcedPolling
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:2
partially evaluated: engine->configurationsInUse()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-38
498 pollingEngines.insert(engine);
executed (the execution status of this line is deduced): pollingEngines.insert(engine);
-
499 QMetaObject::invokeMethod(engine, "requestUpdate");
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(engine, "requestUpdate");
-
500 }
executed: }
Execution Count:38
38
501 }
executed: }
Execution Count:38
38
502}
executed: }
Execution Count:38
38
503 -
504void QNetworkConfigurationManagerPrivate::enablePolling() -
505{ -
506 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
507 -
508 ++forcedPolling;
executed (the execution status of this line is deduced): ++forcedPolling;
-
509 -
510 if (forcedPolling == 1)
evaluated: forcedPolling == 1
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:85
22-85
511 QMetaObject::invokeMethod(this, "startPolling");
executed: QMetaObject::invokeMethod(this, "startPolling");
Execution Count:22
22
512}
executed: }
Execution Count:107
107
513 -
514void QNetworkConfigurationManagerPrivate::disablePolling() -
515{ -
516 QMutexLocker locker(&mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&mutex);
-
517 -
518 --forcedPolling;
executed (the execution status of this line is deduced): --forcedPolling;
-
519}
executed: }
Execution Count:107
107
520 -
521QT_END_NAMESPACE -
522 -
523#endif // QT_NO_BEARERMANAGEMENT -
524 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial