qtmobility/src/bearer/qnetworkconfigmanager_s60_p.h
branchRCL_3
changeset 10 cd2778e5acfe
equal deleted inserted replaced
9:5d007b20cfd0 10:cd2778e5acfe
       
     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 Qt Mobility Components.
       
     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 #ifndef QNETWORKCONFIGURATIONMANAGERPRIVATE_H
       
    43 #define QNETWORKCONFIGURATIONMANAGERPRIVATE_H
       
    44 
       
    45 //
       
    46 //  W A R N I N G
       
    47 //  -------------
       
    48 //
       
    49 // This file is not part of the Qt API.  It exists purely as an
       
    50 // implementation detail.  This header file may change from version to
       
    51 // version without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 //
       
    55 
       
    56 #include <qnetworkconfigmanager.h>
       
    57 #include <qnetworkconfiguration_s60_p.h>
       
    58 #include <qnetworksession.h>
       
    59 
       
    60 #include <QHash>
       
    61 #include <rconnmon.h>
       
    62 #ifdef SNAP_FUNCTIONALITY_AVAILABLE
       
    63     #include <cmmanager.h>
       
    64 #endif
       
    65 
       
    66 // Uncomment and compile QtBearer to gain detailed state tracing
       
    67 // #define QT_BEARERMGMT_SYMBIAN_DEBUG
       
    68 
       
    69 #define QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX "S_"
       
    70 #define QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX  "I_"
       
    71 
       
    72 class CCommsDatabase;
       
    73 class QEventLoop;
       
    74 
       
    75 QT_BEGIN_NAMESPACE
       
    76 class QTimer;
       
    77 QT_END_NAMESPACE
       
    78 
       
    79 QTM_BEGIN_NAMESPACE
       
    80 
       
    81 class QNetworkSessionPrivate;
       
    82 class AccessPointsAvailabilityScanner;
       
    83 
       
    84 class QNetworkConfigurationManagerPrivate : public QObject, public CActive, public MConnectionMonitorObserver
       
    85 {
       
    86     Q_OBJECT
       
    87 
       
    88 public:
       
    89     QNetworkConfigurationManagerPrivate();
       
    90     virtual ~QNetworkConfigurationManagerPrivate(); 
       
    91 
       
    92     QNetworkConfiguration defaultConfiguration();
       
    93     void performAsyncConfigurationUpdate();
       
    94 
       
    95 Q_SIGNALS:
       
    96     void configurationAdded(const QNetworkConfiguration& config);
       
    97     void configurationRemoved(const QNetworkConfiguration& config);
       
    98     void configurationUpdateComplete();
       
    99     void configurationChanged(const QNetworkConfiguration& config);
       
   100     void onlineStateChanged(bool isOnline);
       
   101     
       
   102     void configurationStateChanged(TUint32 accessPointId, TUint32 connMonId,
       
   103                                    QNetworkSession::State newState);
       
   104     
       
   105 public Q_SLOTS:
       
   106     void updateConfigurations();
       
   107     void delayedConfigurationUpdate();
       
   108 
       
   109 private:
       
   110     void registerPlatformCapabilities();
       
   111     void updateStatesToSnaps();
       
   112     bool changeConfigurationStateTo(QExplicitlySharedDataPointer<QNetworkConfigurationPrivate>& sharedData,
       
   113                                     QNetworkConfiguration::StateFlags newState);
       
   114     bool changeConfigurationStateAtMinTo(QExplicitlySharedDataPointer<QNetworkConfigurationPrivate>& sharedData,
       
   115                                          QNetworkConfiguration::StateFlags newState);
       
   116     bool changeConfigurationStateAtMaxTo(QExplicitlySharedDataPointer<QNetworkConfigurationPrivate>& sharedData,
       
   117                                           QNetworkConfiguration::StateFlags newState);
       
   118 #ifdef SNAP_FUNCTIONALITY_AVAILABLE
       
   119     void updateMobileBearerToConfigs(TConnMonBearerInfo bearerInfo);
       
   120     QNetworkConfigurationPrivate* configFromConnectionMethodL(RCmConnectionMethod& connectionMethod);
       
   121 #else
       
   122     bool readNetworkConfigurationValuesFromCommsDb(
       
   123             TUint32 aApId, QNetworkConfigurationPrivate* apNetworkConfiguration);
       
   124     void readNetworkConfigurationValuesFromCommsDbL(
       
   125             TUint32 aApId, QNetworkConfigurationPrivate* apNetworkConfiguration);
       
   126 #endif    
       
   127     
       
   128     void updateConfigurationsL();
       
   129     void updateActiveAccessPoints();
       
   130     void updateAvailableAccessPoints();
       
   131     void accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo);
       
   132     void startCommsDatabaseNotifications();
       
   133     void stopCommsDatabaseNotifications();
       
   134     void updateConfigurationsAfterRandomTime();
       
   135 
       
   136     QNetworkConfiguration defaultConfigurationL();
       
   137     TBool GetS60PlatformVersion(TUint& aMajor, TUint& aMinor) const;
       
   138     void startMonitoringIAPData(TUint32 aIapId);
       
   139     QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> dataByConnectionId(TUint aConnectionId);
       
   140 
       
   141 protected:
       
   142     // From CActive
       
   143     void RunL();
       
   144     void DoCancel();
       
   145     
       
   146 private:
       
   147     // MConnectionMonitorObserver
       
   148     void EventL(const CConnMonEventBase& aEvent);
       
   149     // For QNetworkSessionPrivate to indicate about state changes
       
   150     void configurationStateChangeReport(TUint32 accessPointId,
       
   151                                    QNetworkSession::State newState);
       
   152 #ifdef OCC_FUNCTIONALITY_AVAILABLE
       
   153     QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> configurationFromEasyWlan(TUint32 apId, TUint connectionId);
       
   154     bool easyWlanTrueIapId(TUint32& trueIapId);
       
   155 #endif
       
   156 
       
   157 public: // Data
       
   158     //this table contains an up to date list of all configs at any time.
       
   159     //it must be updated if configurations change, are added/removed or
       
   160     //the members of ServiceNetworks change
       
   161     QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > accessPointConfigurations;
       
   162     QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > snapConfigurations;
       
   163     QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > userChoiceConfigurations;
       
   164     QNetworkConfigurationManager::Capabilities capFlags;
       
   165     
       
   166 private: // Data
       
   167     bool               iFirstUpdate; 
       
   168     CCommsDatabase*    ipCommsDB;
       
   169     RConnectionMonitor iConnectionMonitor;
       
   170 
       
   171     TBool              iWaitingCommsDatabaseNotifications;
       
   172     TBool              iOnline;
       
   173     TBool              iInitOk;
       
   174     TBool              iUpdateGoingOn;
       
   175     TBool              iUpdatePending;
       
   176     TUint              iTimeToWait;
       
   177 
       
   178     AccessPointsAvailabilityScanner* ipAccessPointsAvailabilityScanner;
       
   179     
       
   180     friend class QNetworkSessionPrivate;
       
   181     friend class AccessPointsAvailabilityScanner;
       
   182 
       
   183 #ifdef SNAP_FUNCTIONALITY_AVAILABLE
       
   184     RCmManager iCmManager;
       
   185 #endif
       
   186 };
       
   187 
       
   188 class AccessPointsAvailabilityScanner : public CActive
       
   189 {
       
   190 public:
       
   191     AccessPointsAvailabilityScanner(QNetworkConfigurationManagerPrivate& owner,
       
   192                                    RConnectionMonitor& connectionMonitor); 
       
   193     ~AccessPointsAvailabilityScanner();
       
   194 
       
   195     void StartScanning();
       
   196     
       
   197 protected: // From CActive
       
   198     void RunL();
       
   199     void DoCancel();
       
   200 
       
   201 private: // Data
       
   202     QNetworkConfigurationManagerPrivate& iOwner;
       
   203     RConnectionMonitor& iConnectionMonitor;
       
   204     TConnMonIapInfoBuf iIapBuf;
       
   205 };
       
   206 
       
   207 QTM_END_NAMESPACE
       
   208 
       
   209 #endif //QNETWORKCONFIGURATIONMANAGERPRIVATE_H