source: trunk/src/plugins/bearer/symbian/symbianengine.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 8.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 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 plugins of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef SYMBIANENGINE_H
43#define SYMBIANENGINE_H
44
45#include <QtCore/qstringlist.h>
46#include <QtNetwork/private/qbearerengine_p.h>
47#include <QtNetwork/qnetworkconfigmanager.h>
48
49#include <QHash>
50#include <rconnmon.h>
51#ifdef SNAP_FUNCTIONALITY_AVAILABLE
52 #include <cmmanager.h>
53#endif
54
55// Uncomment and compile QtBearer to gain detailed state tracing
56// #define QT_BEARERMGMT_SYMBIAN_DEBUG
57
58#define QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX QLatin1String("S_")
59#define QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX QLatin1String("I_")
60
61class CCommsDatabase;
62class QEventLoop;
63
64QT_BEGIN_NAMESPACE
65class QTimer;
66QT_END_NAMESPACE
67
68QT_BEGIN_NAMESPACE
69
70class QNetworkSessionPrivate;
71class AccessPointsAvailabilityScanner;
72
73class SymbianNetworkConfigurationPrivate : public QNetworkConfigurationPrivate
74{
75public:
76 SymbianNetworkConfigurationPrivate();
77 ~SymbianNetworkConfigurationPrivate();
78
79 inline TUint32 numericIdentifier() const
80 {
81 QMutexLocker locker(&mutex);
82 return numericId;
83 }
84
85 inline TUint connectionIdentifier() const
86 {
87 QMutexLocker locker(&mutex);
88 return connectionId;
89 }
90
91 inline QString configMappingName() const
92 {
93 QMutexLocker locker(&mutex);
94 return mappingName;
95 }
96
97 QString mappingName;
98
99 // So called IAP id from the platform. Remains constant as long as the
100 // platform is aware of the configuration ie. it is stored in the databases
101 // --> does not depend on whether connections are currently open or not.
102 // In practice is the same for the lifetime of the QNetworkConfiguration.
103 TUint32 numericId;
104 // So called connection id, or connection monitor ID. A dynamic ID assigned
105 // by RConnectionMonitor whenever a new connection is opened. ConnectionID and
106 // numericId/IAP id have 1-to-1 mapping during the lifetime of the connection at
107 // connection monitor. Notably however it changes whenever a new connection to
108 // a given IAP is created. In a sense it is constant during the time the
109 // configuration remains between states Discovered..Active..Discovered, do not
110 // however relay on this.
111 TUint connectionId;
112};
113
114inline SymbianNetworkConfigurationPrivate *toSymbianConfig(QNetworkConfigurationPrivatePointer ptr)
115{
116 return static_cast<SymbianNetworkConfigurationPrivate *>(ptr.data());
117}
118
119class SymbianEngine : public QBearerEngine, public CActive,
120 public MConnectionMonitorObserver
121{
122 Q_OBJECT
123
124public:
125 SymbianEngine(QObject *parent = 0);
126 virtual ~SymbianEngine();
127
128 bool hasIdentifier(const QString &id);
129
130 Q_INVOKABLE void initialize();
131 Q_INVOKABLE void requestUpdate();
132
133 QNetworkConfigurationManager::Capabilities capabilities() const;
134
135 QNetworkSessionPrivate *createSessionBackend();
136
137 QNetworkConfigurationPrivatePointer defaultConfiguration();
138
139 QStringList accessPointConfigurationIdentifiers();
140
141 QNetworkConfigurationPrivatePointer configurationFromSsid(const QString &ssid);
142
143 // For QNetworkSessionPrivateImpl to indicate about state changes
144 void configurationStateChangeReport(TUint32 accessPointId, QNetworkSession::State newState);
145
146Q_SIGNALS:
147 void onlineStateChanged(bool isOnline);
148
149 void configurationStateChanged(quint32 accessPointId, quint32 connMonId,
150 QNetworkSession::State newState);
151
152public Q_SLOTS:
153 void updateConfigurations();
154 void delayedConfigurationUpdate();
155
156private:
157 void updateStatesToSnaps();
158 bool changeConfigurationStateTo(QNetworkConfigurationPrivatePointer ptr,
159 QNetworkConfiguration::StateFlags newState);
160 bool changeConfigurationStateAtMinTo(QNetworkConfigurationPrivatePointer ptr,
161 QNetworkConfiguration::StateFlags newState);
162 bool changeConfigurationStateAtMaxTo(QNetworkConfigurationPrivatePointer ptr,
163 QNetworkConfiguration::StateFlags newState);
164#ifdef SNAP_FUNCTIONALITY_AVAILABLE
165 void updateMobileBearerToConfigs(TConnMonBearerInfo bearerInfo);
166 SymbianNetworkConfigurationPrivate *configFromConnectionMethodL(RCmConnectionMethod& connectionMethod);
167#else
168 bool readNetworkConfigurationValuesFromCommsDb(
169 TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration);
170 void readNetworkConfigurationValuesFromCommsDbL(
171 TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration);
172#endif
173
174 void updateConfigurationsL();
175 void updateActiveAccessPoints();
176 void updateAvailableAccessPoints();
177 void accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo);
178 void startCommsDatabaseNotifications();
179 void stopCommsDatabaseNotifications();
180 void updateConfigurationsAfterRandomTime();
181
182 QNetworkConfigurationPrivatePointer defaultConfigurationL();
183 TBool GetS60PlatformVersion(TUint& aMajor, TUint& aMinor) const;
184 void startMonitoringIAPData(TUint32 aIapId);
185 QNetworkConfigurationPrivatePointer dataByConnectionId(TUint aConnectionId);
186
187protected:
188 // From CActive
189 void RunL();
190 void DoCancel();
191
192private:
193 // MConnectionMonitorObserver
194 void EventL(const CConnMonEventBase& aEvent);
195#ifdef SNAP_FUNCTIONALITY_AVAILABLE
196 QNetworkConfigurationPrivatePointer configurationFromEasyWlan(TUint32 apId,
197 TUint connectionId);
198#endif
199
200private: // Data
201 bool iFirstUpdate;
202 CCommsDatabase* ipCommsDB;
203 RConnectionMonitor iConnectionMonitor;
204
205 TBool iWaitingCommsDatabaseNotifications;
206 TBool iOnline;
207 TBool iInitOk;
208 TBool iUpdateGoingOn;
209 TBool iUpdatePending;
210 TBool iScanInQueue;
211
212 AccessPointsAvailabilityScanner* ipAccessPointsAvailabilityScanner;
213
214 QNetworkConfigurationPrivatePointer defaultConfig;
215
216 friend class QNetworkSessionPrivate;
217 friend class AccessPointsAvailabilityScanner;
218
219#ifdef SNAP_FUNCTIONALITY_AVAILABLE
220 RCmManager iCmManager;
221#endif
222};
223
224class AccessPointsAvailabilityScanner : public CActive
225{
226public:
227 AccessPointsAvailabilityScanner(SymbianEngine& owner,
228 RConnectionMonitor& connectionMonitor);
229 ~AccessPointsAvailabilityScanner();
230
231 void StartScanning();
232
233protected: // From CActive
234 void RunL();
235 void DoCancel();
236
237private: // Data
238 SymbianEngine& iOwner;
239 RConnectionMonitor& iConnectionMonitor;
240 TConnMonIapInfoBuf iIapBuf;
241 TBool iScanActive;
242};
243
244QT_END_NAMESPACE
245
246#endif
Note: See TracBrowser for help on using the repository browser.