Qt 4.8
qnetworkconfiguration.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 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 "qnetworkconfiguration.h"
44 
46 
223  : d(0)
224 {
225 }
226 
231  : d(other.d)
232 {
233 }
234 
239 {
240 }
241 
246 {
247  d = other.d;
248  return *this;
249 }
250 
256 {
257  return (d == other.d);
258 }
259 
277 {
278  if (!d)
279  return QString();
280 
281  QMutexLocker locker(&d->mutex);
282  return d->name;
283 }
284 
290 {
291  if (!d)
292  return QString();
293 
294  QMutexLocker locker(&d->mutex);
295  return d->id;
296 }
297 
307 {
308  if (!d)
310 
311  QMutexLocker locker(&d->mutex);
312  return d->type;
313 }
314 
326 {
327  if (!d)
328  return false;
329 
330  QMutexLocker locker(&d->mutex);
331  return d->isValid;
332 }
333 
337 QNetworkConfiguration::StateFlags QNetworkConfiguration::state() const
338 {
339  if (!d)
341 
342  QMutexLocker locker(&d->mutex);
343  return d->state;
344 }
345 
354 {
355  if (!d)
357 
358  QMutexLocker locker(&d->mutex);
359  return d->purpose;
360 }
361 
366 {
367  if (!d)
368  return false;
369 
370  QMutexLocker locker(&d->mutex);
371  return d->roamingSupported;
372 }
373 
382 {
384 
385  if (!d)
386  return results;
387 
388  QMutexLocker locker(&d->mutex);
389 
391  return results;
392 
393  QMutableMapIterator<unsigned int, QNetworkConfigurationPrivatePointer> i(d->serviceNetworkMembers);
394  while (i.hasNext()) {
395  i.next();
396 
398 
399  //if we have an invalid member get rid of it -> was deleted earlier on
400  {
401  QMutexLocker childLocker(&p->mutex);
402 
403  if (!p->isValid) {
404  i.remove();
405  continue;
406  }
407  }
408 
410  item.d = p;
411  results << item;
412  }
413 
414  return results;
415 }
416 
437 {
438  if (!isValid())
439  return BearerUnknown;
440 
441  QMutexLocker locker(&d->mutex);
442 
443  return d->bearerType;
444 }
445 
495 {
496  if (!isValid())
497  return QString();
498 
499  QMutexLocker locker(&d->mutex);
500 
503  return QString();
504 
505  switch (d->bearerType) {
506  case BearerUnknown:
507  return d->bearerTypeName();
508  case BearerEthernet:
509  return QLatin1String("Ethernet");
510  case BearerWLAN:
511  return QLatin1String("WLAN");
512  case Bearer2G:
513  return QLatin1String("2G");
514  case BearerCDMA2000:
515  return QLatin1String("CDMA2000");
516  case BearerWCDMA:
517  return QLatin1String("WCDMA");
518  case BearerHSPA:
519  return QLatin1String("HSPA");
520  case BearerBluetooth:
521  return QLatin1String("Bluetooth");
522  case BearerWiMAX:
523  return QLatin1String("WiMAX");
524  }
525 
526  return QLatin1String("Unknown");
527 }
528 
BearerType
Specifies the type of bearer used by a configuration.
double d
Definition: qnumeric_p.h:62
BearerType bearerType() const
Returns the type of bearer used by this network configuration.
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > d
Purpose
Specifies the purpose of the configuration.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QNetworkConfiguration & operator=(const QNetworkConfiguration &other)
Copies the content of the QNetworkConfiguration object contained in other into this one...
QNetworkConfiguration::StateFlags state
QMap< unsigned int, QNetworkConfigurationPrivatePointer > serviceNetworkMembers
Purpose purpose() const
Returns the purpose of this configuration.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QList< QNetworkConfiguration > children() const
Returns all sub configurations of this network configuration in priority order.
The QString class provides a Unicode character string.
Definition: qstring.h:83
QNetworkConfiguration()
Constructs an invalid configuration object.
QNetworkConfiguration::BearerType bearerType
bool isValid() const
Returns true if this QNetworkConfiguration object is valid.
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
~QNetworkConfiguration()
Frees the resources associated with the QNetworkConfiguration object.
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QString identifier() const
Returns the unique and platform specific identifier for this network configuration; otherwise an empt...
QNetworkConfiguration::Purpose purpose
QString bearerTypeName() const
Returns the type of bearer used by this network configuration as a string.
bool operator==(const QNetworkConfiguration &other) const
Returns true, if this configuration is the same as the other configuration given; otherwise returns f...
QNetworkConfiguration::Type type
QString name() const
Returns the user visible name of this configuration.
StateFlags state() const
Returns the current state of the configuration.
Type
This enum describes the type of configuration.
virtual QString bearerTypeName() const
bool isRoamingAvailable() const
Returns true if this configuration supports roaming; otherwise false.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
Type type() const
Returns the type of the configuration.