src/network/bearer/qbearerengine.cpp
changeset 30 5dc02b23752f
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtNetwork module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qbearerengine_p.h"
       
    43 
       
    44 #ifndef QT_NO_BEARERMANAGEMENT
       
    45 
       
    46 QT_BEGIN_NAMESPACE
       
    47 
       
    48 QBearerEngine::QBearerEngine(QObject *parent)
       
    49 :   QObject(parent), mutex(QMutex::Recursive)
       
    50 {
       
    51 }
       
    52 
       
    53 QBearerEngine::~QBearerEngine()
       
    54 {
       
    55     QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
       
    56     QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
       
    57     for (it = snapConfigurations.begin(), end = snapConfigurations.end(); it != end; ++it) {
       
    58         it.value()->isValid = false;
       
    59         it.value()->id.clear();
       
    60     }
       
    61 
       
    62     for (it = accessPointConfigurations.begin(), end = accessPointConfigurations.end();
       
    63          it != end; ++it) {
       
    64         it.value()->isValid = false;
       
    65         it.value()->id.clear();
       
    66     }
       
    67 
       
    68     for (it = userChoiceConfigurations.begin(), end = userChoiceConfigurations.end();
       
    69          it != end; ++it) {
       
    70         it.value()->isValid = false;
       
    71         it.value()->id.clear();
       
    72     }
       
    73 }
       
    74 
       
    75 bool QBearerEngine::requiresPolling() const
       
    76 {
       
    77     return false;
       
    78 }
       
    79 
       
    80 /*
       
    81     Returns true if configurations are in use; otherwise returns false.
       
    82 
       
    83     If configurations are in use and requiresPolling() returns true, polling will be enabled for
       
    84     this engine.
       
    85 */
       
    86 bool QBearerEngine::configurationsInUse() const
       
    87 {
       
    88     QHash<QString, QNetworkConfigurationPrivatePointer>::ConstIterator it;
       
    89     QHash<QString, QNetworkConfigurationPrivatePointer>::ConstIterator end;
       
    90 
       
    91     QMutexLocker locker(&mutex);
       
    92 
       
    93     for (it = accessPointConfigurations.begin(),
       
    94          end = accessPointConfigurations.end(); it != end; ++it) {
       
    95         if (it.value()->ref > 1)
       
    96             return true;
       
    97     }
       
    98 
       
    99     for (it = snapConfigurations.begin(), end = snapConfigurations.end(); it != end; ++it) {
       
   100         if (it.value()->ref > 1)
       
   101             return true;
       
   102     }
       
   103 
       
   104     for (it = userChoiceConfigurations.begin(),
       
   105          end = userChoiceConfigurations.end(); it != end; ++it) {
       
   106         if (it.value()->ref > 1)
       
   107             return true;
       
   108     }
       
   109 
       
   110     return false;
       
   111 }
       
   112 
       
   113 #include "moc_qbearerengine_p.cpp"
       
   114 
       
   115 #endif // QT_NO_BEARERMANAGEMENT
       
   116 
       
   117 QT_END_NAMESPACE