1 /* |
|
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class header for CWsfWlanScanner |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_WSFWLANSCANNER_H |
|
21 #define C_WSFWLANSCANNER_H |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <wlanmgmtcommon.h> |
|
26 #include <commsdattypesv1_1.h> |
|
27 #include <cmmanagerext.h> |
|
28 |
|
29 |
|
30 |
|
31 // INTERNAL INCLUDES |
|
32 #include "wsfwlanscannerobserver.h" |
|
33 #include "wsfwlanmonitorobserver.h" |
|
34 #include "wsfwlanscanintervalchangeobserver.h" |
|
35 #include "wsfwlaninfo.h" |
|
36 |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 class CWlanMgmtClient; |
|
40 class CWlanScanInfo; |
|
41 class CWsfWlanSettingsAccessor; |
|
42 class CWsfWlanInfoArray; |
|
43 class TWsfWlanInfo; |
|
44 class MWsfWlanConnectionDetailsProvider; |
|
45 class MWsfKnownIapRecognizer; |
|
46 |
|
47 |
|
48 // CLASS DEFINITION |
|
49 /** |
|
50 * Class to schedule WLAN scanning and process the resultant data |
|
51 * |
|
52 * @since S60 5.0 |
|
53 * @lib wsfserver.exe |
|
54 */ |
|
55 NONSHARABLE_CLASS( CWsfWlanScanner ): public CActive, |
|
56 public MWlanMgmtNotifications, |
|
57 public MWsfWlanMonitorObserver, |
|
58 public MWsfWlanScanIntervalChangeObserver |
|
59 { |
|
60 private: // Type definitions |
|
61 |
|
62 /** |
|
63 * States of the scanning process |
|
64 */ |
|
65 enum TWsfScanState |
|
66 { |
|
67 /** |
|
68 * Not scanning but scheduled |
|
69 */ |
|
70 EIdle, |
|
71 |
|
72 /** |
|
73 * Processing broadcast scan results |
|
74 */ |
|
75 EBroadcastScan, |
|
76 |
|
77 /** |
|
78 * Processing direct scan results |
|
79 */ |
|
80 EDirectScan, |
|
81 |
|
82 /** |
|
83 * Scanning finished, cleanup and notification |
|
84 */ |
|
85 EFinished |
|
86 }; |
|
87 |
|
88 public: // Constructors and destructor |
|
89 |
|
90 /** |
|
91 * Factory function. |
|
92 * @since S60 5.0 |
|
93 * @param aDbSession Reference to the database session to use |
|
94 * @return Class instance |
|
95 */ |
|
96 static CWsfWlanScanner* NewL( CommsDat::CMDBSession& aDbSession ); |
|
97 |
|
98 /** |
|
99 * Factory function. |
|
100 * @since S60 5.0 |
|
101 * @param aDbSession Reference to the database session to use |
|
102 * @return Class instance |
|
103 */ |
|
104 static CWsfWlanScanner* NewLC( CommsDat::CMDBSession& aDbSession ); |
|
105 |
|
106 /** |
|
107 * Destructor. |
|
108 */ |
|
109 ~CWsfWlanScanner(); |
|
110 |
|
111 |
|
112 private: // Constructors |
|
113 |
|
114 /** |
|
115 * Constructor |
|
116 * @since S60 5.0 |
|
117 * @param aDbSession Reference to the database session to use |
|
118 */ |
|
119 CWsfWlanScanner( CommsDat::CMDBSession& aSession ); |
|
120 |
|
121 /** |
|
122 * Second-phase constructor. |
|
123 * @since S60 5.0 |
|
124 */ |
|
125 void ConstructL(); |
|
126 |
|
127 |
|
128 public: // New methods |
|
129 /** |
|
130 * Sets the observer of this class |
|
131 * @since S60 5.0 |
|
132 * @param aObserver The observer to be notified of scanning events |
|
133 */ |
|
134 void SetObserver( MWsfWlanScannerObserver& aObserver ); |
|
135 |
|
136 /** |
|
137 * Enables scanning for wlans |
|
138 * @since S60 5.0 |
|
139 */ |
|
140 void StartScanningL(); |
|
141 |
|
142 /** |
|
143 * Stops the activation timer and cancels the mgmt client to |
|
144 * give notifications |
|
145 * @since S60 5.0 |
|
146 */ |
|
147 void StopScanning(); |
|
148 |
|
149 /** |
|
150 * Initiates a new scanning if it was already enabled but was idle. |
|
151 * @since S60 5.0 |
|
152 * @return ETrue if scanning was in fact restarted |
|
153 */ |
|
154 TBool RestartScanning(); |
|
155 |
|
156 /** |
|
157 * Aborts the scanning process if it was active. However, it does not |
|
158 * disable scanning |
|
159 * @since S60 5.0 |
|
160 */ |
|
161 void AbortScanning(); |
|
162 |
|
163 /** |
|
164 * Returns the serialized contents of scan results |
|
165 * @since S60 5.0 |
|
166 * @return A serialized array of wlaninfo items |
|
167 */ |
|
168 HBufC8* ScanResults(); |
|
169 |
|
170 /** |
|
171 * Sets ConnectionDetails provider handle to get data about |
|
172 * connected wlans |
|
173 * @since S60 5.0 |
|
174 * @param aProvider The object to be asked for connection details |
|
175 */ |
|
176 void SetConnectionDetailProvider( |
|
177 MWsfWlanConnectionDetailsProvider& aProvider ); |
|
178 |
|
179 |
|
180 public: // From MWlanMgmtNotifications |
|
181 /** |
|
182 * Connection status has changed. |
|
183 * @since S60 5.0 |
|
184 * @param aNewState The new connection state |
|
185 */ |
|
186 void ConnectionStateChanged( TWlanConnectionMode aNewState ); |
|
187 |
|
188 /** |
|
189 * BSSID has changed (i.e. AP handover). |
|
190 * @since S60 5.0 |
|
191 * @param aNewBssid The new BSSID |
|
192 */ |
|
193 void BssidChanged( TWlanBssid& aNewBssid ); |
|
194 |
|
195 /** |
|
196 * Connection has been lost. |
|
197 * @since S60 5.0 |
|
198 */ |
|
199 void BssLost(); |
|
200 |
|
201 /** |
|
202 * Connection has been regained. |
|
203 * @since S60 5.0 |
|
204 */ |
|
205 void BssRegained(); |
|
206 |
|
207 /** |
|
208 * New networks have been detected during scan. |
|
209 * @since S60 5.0 |
|
210 */ |
|
211 void NewNetworksDetected(); |
|
212 |
|
213 /** |
|
214 * One or more networks have been lost since the last scan. |
|
215 * @since S60 5.0 |
|
216 */ |
|
217 void OldNetworksLost(); |
|
218 |
|
219 /** |
|
220 * The used transmit power has been changed. |
|
221 * @since S60 5.0 |
|
222 * @param aPower The transmit power in mW. |
|
223 */ |
|
224 void TransmitPowerChanged( TUint aPower ); |
|
225 |
|
226 /** |
|
227 * Received signal strength level has been changed. |
|
228 * @since S60 5.0 |
|
229 * @param aRssClass specifies the current class of the received signal |
|
230 * @param aRss RSS level in absolute dBm values. |
|
231 */ |
|
232 void RssChanged( TWlanRssClass aRssClass, TUint aRss ); |
|
233 |
|
234 |
|
235 private: // New methods |
|
236 /** |
|
237 * Processes the results of the broadcast scan |
|
238 * @since S60 5.0 |
|
239 */ |
|
240 void DoScanForNetworksL(); |
|
241 |
|
242 /** |
|
243 * Compares two SSIDs |
|
244 * @since S60 5.0 |
|
245 * @param aSsid1 First SSID |
|
246 * @param aSsid2 Second SSID |
|
247 * @return ETrue if the SSIDs are the same, EFalse otherwise |
|
248 */ |
|
249 static TBool SsidIdentity( const TWlanSsid& aSsid1, |
|
250 const TWlanSsid& aSsid2 ); |
|
251 |
|
252 #ifdef _DEBUG |
|
253 /** |
|
254 * Dumps the scan results to the log |
|
255 * @since S60 5.0 |
|
256 * @param aArray Array of wlaninfo items added during scanning |
|
257 */ |
|
258 static void DumpScanResultsL( CWsfWlanInfoArray* aArray ); |
|
259 #endif |
|
260 |
|
261 /** |
|
262 * Check if the given SSID implies a hidden WLAN |
|
263 * @since S60 5.0 |
|
264 * @param aSsidLength Length of the SSID passed |
|
265 * @param aSsid SSID as array of bytes |
|
266 * @return ETrue if the network in question is hidden, EFalse otherwise |
|
267 */ |
|
268 TBool IsHiddenSsid( TUint aSsidLength, const TUint8* aSsid ); |
|
269 |
|
270 /** |
|
271 * Parses the scan results for the network name |
|
272 * @since S60 5.0 |
|
273 * @param aWlanInfo The wlaninfo to put the results in |
|
274 * @return ETrue if the network is a hidden one |
|
275 */ |
|
276 TBool RefreshNetworkNameL( TWsfWlanInfo& aWlanInfo ); |
|
277 |
|
278 /** |
|
279 * Parses the scan results for the wlan signal stregth |
|
280 * @since S60 5.0 |
|
281 * @param aWlanInfo The wlaninfo to put the results in |
|
282 */ |
|
283 void RefreshSignalStrength( TWsfWlanInfo& aWlanInfo ); |
|
284 |
|
285 /** |
|
286 * Parses the scan results for the network mode |
|
287 * @since S60 5.0 |
|
288 * @param aWlanInfo The wlaninfo to put the results in |
|
289 */ |
|
290 void RefreshNetworkMode( TWsfWlanInfo& aWlanInfo ); |
|
291 |
|
292 /** |
|
293 * Parses the scan results for the security mode |
|
294 * @since S60 5.0 |
|
295 * @param aWlanInfo The wlaninfo to put the results in |
|
296 */ |
|
297 void RefreshSecurityMode( TWsfWlanInfo& aWlanInfo ); |
|
298 |
|
299 /** |
|
300 * Parses the scan results for the transfer rate |
|
301 * @since S60 5.0 |
|
302 * @param aWlanInfo The wlaninfo to put the results in |
|
303 */ |
|
304 void RefreshMaxRate( TWsfWlanInfo& aWlanInfo ); |
|
305 |
|
306 /** |
|
307 * Prepares for direct scanning |
|
308 * @since S60 5.0 |
|
309 */ |
|
310 void PrepareDirectScan(); |
|
311 |
|
312 /** |
|
313 * Processes the result of the last direct scan |
|
314 * @since S60 5.0 |
|
315 */ |
|
316 void ProcessDirectScanResultL(); |
|
317 |
|
318 /** |
|
319 * Checks iScanArray and replaces SSIDs of known networks |
|
320 * with their IAP names. |
|
321 * @param aWlanInfo The wlaninfo to put the results in |
|
322 * @since S60 5.0 |
|
323 */ |
|
324 void ReplaceSsidsWithIapName(TWsfWlanInfo& aWlanInfo); |
|
325 |
|
326 /** |
|
327 * Updates IAPs priority |
|
328 * @since S60 5.0 |
|
329 * @param aWlanInfo The wlaninfo to put the results in |
|
330 */ |
|
331 void UpdatePriorityL( TWsfWlanInfo& aWlanInfo ); |
|
332 |
|
333 /** |
|
334 * Finds the security mode, network mode from WLAN table |
|
335 * with their IAP names. |
|
336 * @param aWlanInfo The wlaninfo to put the results in |
|
337 * @since S60 5.0 |
|
338 */ |
|
339 void GetWlanInfoFromIapL( TWsfWlanInfo& aWlanInfo ); |
|
340 |
|
341 /** |
|
342 * Add connected wlan info to scan results |
|
343 * @since S60 5.0 |
|
344 */ |
|
345 void AddConnectedWLANInfoL(); |
|
346 |
|
347 private: // From CActive |
|
348 /** |
|
349 * Implements cancellation of an outstanding request. |
|
350 * @since S60 5.0 |
|
351 */ |
|
352 void DoCancel(); |
|
353 |
|
354 /** |
|
355 * Handles an active object's request completion event. |
|
356 * @since S60 5.0 |
|
357 */ |
|
358 void RunL(); |
|
359 |
|
360 /** |
|
361 * Handles a leave occurring in RunL(). |
|
362 * @since S60 5.0 |
|
363 * @param aError Leave code |
|
364 * @return aError |
|
365 */ |
|
366 TInt RunError( TInt aError ); |
|
367 |
|
368 |
|
369 public: // from MWsfWlanMonitorObserver |
|
370 |
|
371 /** |
|
372 * Called when a wlan connection is established |
|
373 * @since S60 5.0 |
|
374 * @param aConnectionName WLAN connection name (SSID) |
|
375 */ |
|
376 void ConnectionEstablishedL( const TDesC& aConnectionName ); |
|
377 |
|
378 /** |
|
379 * Called when wlan connection has been lost |
|
380 * @since S60 5.0 |
|
381 */ |
|
382 void ConnectionLostL(); |
|
383 |
|
384 /** |
|
385 * Called when the connection process failed for some reason |
|
386 * @since S60 5.0 |
|
387 * @param aError System wide error code |
|
388 */ |
|
389 void ConnectingFailedL( TInt aError ); |
|
390 |
|
391 /** |
|
392 * Called when the connection no longer needs the IAP it was using |
|
393 * @since S60 5.0 |
|
394 */ |
|
395 void ConnectedIapReleasedL(); |
|
396 |
|
397 |
|
398 public: // from MWsfWlanScanIntervalChangeObserver |
|
399 /** |
|
400 * Called when the value of the background scan interval or the |
|
401 * show availability flag has been changed |
|
402 * @since S60 5.0 |
|
403 * @param aNewScanInterval The new value for the scan interval |
|
404 * @param aShowAvailability The new value for the |
|
405 * Show WLAN availability flag |
|
406 */ |
|
407 void WlanScanIntervalChangedL( TUint aNewScanInterval, |
|
408 TBool aShowAvailability ); |
|
409 |
|
410 private: // Data |
|
411 /** |
|
412 * Reference to the observer of this class (not owned) |
|
413 */ |
|
414 MWsfWlanScannerObserver* iObserver; |
|
415 |
|
416 /** |
|
417 * Reference to the database session to use (not owned) |
|
418 */ |
|
419 CommsDat::CMDBSession* iDbSession; |
|
420 |
|
421 /** |
|
422 * Reference to the connection details providing object (not owned) |
|
423 */ |
|
424 MWsfWlanConnectionDetailsProvider* iConnectionDetailsProvider; |
|
425 |
|
426 /** |
|
427 * Handle to the WLAN management client (owned) |
|
428 */ |
|
429 CWlanMgmtClient* iWlanMgmtClient; |
|
430 |
|
431 /** |
|
432 * Scan info object (owned) |
|
433 */ |
|
434 CWlanScanInfo* iScanInfo; |
|
435 |
|
436 /** |
|
437 * WLAN settings monitoring object (owned) |
|
438 */ |
|
439 CWsfWlanSettingsAccessor* iWlanSettingsAccessor; |
|
440 |
|
441 /** |
|
442 * The array containing the wlaninfo items found during scanning |
|
443 * (owned) |
|
444 */ |
|
445 CWsfWlanInfoArray* iScanArray; |
|
446 |
|
447 /** |
|
448 * Name of the active connection (owned) |
|
449 */ |
|
450 HBufC* iActiveConnectionName; |
|
451 |
|
452 /** |
|
453 * Timer for scheduling WLAN scans |
|
454 */ |
|
455 RTimer iTimer; |
|
456 |
|
457 /** |
|
458 * Handle to the CmManager |
|
459 */ |
|
460 RCmManagerExt iCmManagerExt; |
|
461 |
|
462 /** |
|
463 * Buffer to store the serialized array of wlaninfo items (owned) |
|
464 */ |
|
465 HBufC8* iScanResults; |
|
466 |
|
467 /** |
|
468 * The background scan interval in microseconds |
|
469 */ |
|
470 TUint iScanningInterval; |
|
471 |
|
472 /** |
|
473 * Value of Show WLAN availability flag |
|
474 */ |
|
475 TBool iShowAvailability; |
|
476 |
|
477 /** |
|
478 * Array of SSIDs that are in CommsDat but have not been found |
|
479 * by broadcast scan |
|
480 */ |
|
481 RArray<TWlanSsid> iDirectScanSsids; |
|
482 |
|
483 /** |
|
484 * Array of IapIDs that are in CommsDat but have not been found |
|
485 * by broadcast scan |
|
486 */ |
|
487 RArray<TUint> iDirectScanIapIDs; |
|
488 |
|
489 /** |
|
490 * Indicates the scanning state |
|
491 */ |
|
492 TWsfScanState iScanState; |
|
493 |
|
494 /** |
|
495 * Connected SSID or IAP name |
|
496 */ |
|
497 TBuf8<KWlanMaxAccessPointNameLength> iConnectedSsidOrIap; |
|
498 |
|
499 }; |
|
500 |
|
501 |
|
502 #endif // C_WSFWLANSCANNER_H |
|
503 |
|
504 // End of file |
|