|
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: Implementation of CWsfWlanScanner |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // EXTERNAL INCLUDES |
|
21 #include <wlanmgmtclient.h> |
|
22 #include <centralrepository.h> |
|
23 #include <utf.h> |
|
24 #include <wlancontainer.h> |
|
25 #include <commsdattypeinfov1_1.h> |
|
26 #include <wlanscaninfo.h> |
|
27 #include <cmdestinationext.h> |
|
28 #include <commdb.h> |
|
29 |
|
30 #ifdef __WINS__ |
|
31 #include <e32math.h> |
|
32 #endif |
|
33 |
|
34 // CLASS HEADER |
|
35 #include "wsfwlanscanner.h" |
|
36 |
|
37 // INTERNAL INCLUDES |
|
38 #include "wsfwlaninfoarray.h" |
|
39 #include "wsfwlanscaninfodefines.h" |
|
40 #include "wsfwlanconnectiondetailsprovider.h" |
|
41 #include "wsfwlansettingsaccessor.h" |
|
42 |
|
43 #include "wsflogger.h" |
|
44 |
|
45 // LOCAL DEFINITIONS |
|
46 using namespace CMManager; |
|
47 |
|
48 |
|
49 /** |
|
50 * Microseconds in a second |
|
51 */ |
|
52 static const TInt KMicrosecPerSecond = 1000 * 1000; |
|
53 |
|
54 |
|
55 // CONSTRUCTION AND DESTRUCTION |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CWsfWlanScanner::NewL |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CWsfWlanScanner* CWsfWlanScanner::NewL( CommsDat::CMDBSession& aDbSession ) |
|
62 { |
|
63 CWsfWlanScanner* self = CWsfWlanScanner::NewLC( aDbSession ); |
|
64 CleanupStack::Pop( self ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CWsfWlanScanner::NewLC |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CWsfWlanScanner* CWsfWlanScanner::NewLC( CommsDat::CMDBSession& aDbSession ) |
|
74 { |
|
75 CWsfWlanScanner* self = new( ELeave ) CWsfWlanScanner( aDbSession ); |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL(); |
|
78 return self; |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CWsfWlanScanner::~CWsfWlanScanner |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CWsfWlanScanner::~CWsfWlanScanner() |
|
87 { |
|
88 LOG_ENTERFN( "CWsfWlanScanner::~CWsfWlanScanner" ); |
|
89 StopScanning(); |
|
90 Cancel(); |
|
91 iTimer.Close(); |
|
92 iCmManagerExt.Close(); |
|
93 delete iActiveConnectionName; |
|
94 delete iScanResults; |
|
95 delete iWlanMgmtClient; |
|
96 delete iWlanSettingsAccessor; |
|
97 delete iScanInfo; |
|
98 delete iScanArray; |
|
99 iDirectScanSsids.Close(); |
|
100 iDirectScanIapIDs.Close(); |
|
101 iDbSession = NULL; // not owning |
|
102 iConnectionDetailsProvider = NULL; |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CWsfWlanScanner::CWsfWlanScanner |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CWsfWlanScanner::CWsfWlanScanner( CommsDat::CMDBSession& aDbSession ): |
|
111 CActive( EPriorityStandard ), |
|
112 iDbSession( &aDbSession ), |
|
113 iScanState( EIdle ) |
|
114 { |
|
115 } |
|
116 |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CWsfWlanScanner::ConstructL |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CWsfWlanScanner::ConstructL() |
|
123 { |
|
124 LOG_ENTERFN( "CWsfWlanScanner::ConstructL" ); |
|
125 |
|
126 #ifndef __WINS__ // client is not available on wins |
|
127 iWlanMgmtClient = CWlanMgmtClient::NewL(); |
|
128 |
|
129 iScanInfo = CWlanScanInfo::NewL(); |
|
130 #endif |
|
131 |
|
132 iCmManagerExt.OpenL(); |
|
133 |
|
134 iScanArray = CWsfWlanInfoArray::NewL(); |
|
135 |
|
136 User::LeaveIfError( iTimer.CreateLocal() ); |
|
137 iScanResults = KNullDesC8().AllocL(); |
|
138 |
|
139 iWlanSettingsAccessor = CWsfWlanSettingsAccessor::NewL( *iDbSession ); |
|
140 iScanningInterval = iWlanSettingsAccessor->ScanInterval() * |
|
141 KMicrosecPerSecond; |
|
142 iShowAvailability = iWlanSettingsAccessor->ShowAvailability(); |
|
143 |
|
144 LOG_WRITEF( "initial bgScanInterval = %d sec", |
|
145 iWlanSettingsAccessor->ScanInterval() ); |
|
146 LOG_WRITEF( "initial showAvailability = %d", iShowAvailability ); |
|
147 |
|
148 CActiveScheduler::Add( this ); |
|
149 } |
|
150 |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CWsfWlanScanner::DoCancel |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CWsfWlanScanner::DoCancel() |
|
157 { |
|
158 LOG_ENTERFN( "CWsfWlanScanner::DoCancel" ); |
|
159 iTimer.Cancel(); |
|
160 #ifndef __WINS__ |
|
161 iWlanMgmtClient->CancelGetScanResults(); |
|
162 #endif |
|
163 iScanState = EIdle; |
|
164 } |
|
165 |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CWsfWlanScanner::RunL |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 void CWsfWlanScanner::RunL() |
|
172 { |
|
173 LOG_ENTERFN( "CWsfWlanScanner::RunL" ); |
|
174 |
|
175 /* |
|
176 * Scan logic |
|
177 * 1. Do broadcast scan - state = EIdle |
|
178 * 2. Get available IAPs - state = EBroadcastScan |
|
179 * 3. Process broadcast scan results state = EBroadcastScan |
|
180 * 4. Do direct scans for remaining known networks |
|
181 * from step 2. Get available IAPs - state = EDirectScan |
|
182 * 5. Add connected network - state = EFinished |
|
183 * 6. Set names and priorities for known networks - state = EFinished |
|
184 */ |
|
185 |
|
186 if ( iScanState == EIdle ) |
|
187 { |
|
188 LOG_WRITE( "broadcast scan phase" ); |
|
189 |
|
190 // prepare things for direct scans |
|
191 PrepareDirectScan(); |
|
192 |
|
193 // notify clients |
|
194 if ( iObserver ) |
|
195 { |
|
196 iObserver->WlanScanStarted(); |
|
197 } |
|
198 |
|
199 // do broadcast scan |
|
200 #ifndef __WINS__ |
|
201 iWlanMgmtClient->GetScanResults( iStatus, *iScanInfo ); |
|
202 SetActive(); |
|
203 #else |
|
204 // for testing |
|
205 SetActive(); |
|
206 TRequestStatus* status = &iStatus; |
|
207 User::RequestComplete( status, KErrNone ); |
|
208 #endif |
|
209 |
|
210 iScanState = EBroadcastScan; |
|
211 } |
|
212 |
|
213 else if ( iScanState == EBroadcastScan ) |
|
214 { |
|
215 // process broadcast scan results |
|
216 DoScanForNetworksL(); |
|
217 |
|
218 // now it's time to initiate direct scan |
|
219 // for remaining known networks |
|
220 if ( iDirectScanSsids.Count() ) |
|
221 { |
|
222 #ifdef _DEBUG |
|
223 HBufC* ssid = TWsfWlanInfo::GetSsidAsUnicodeLC( |
|
224 iDirectScanSsids[0] ); |
|
225 LOG_WRITEF( "requesting direct scan for [%S]", ssid ); |
|
226 CleanupStack::PopAndDestroy( ssid ); |
|
227 #endif |
|
228 |
|
229 #ifndef __WINS__ |
|
230 // run direct scan |
|
231 iWlanMgmtClient->GetScanResults( iDirectScanSsids[0], |
|
232 iStatus, *iScanInfo ); |
|
233 SetActive(); |
|
234 #else |
|
235 // for testing |
|
236 SetActive(); |
|
237 TRequestStatus* status = &iStatus; |
|
238 User::RequestComplete( status, KErrNone ); |
|
239 #endif |
|
240 |
|
241 iScanState = EDirectScan; |
|
242 } |
|
243 else |
|
244 { |
|
245 LOG_WRITE( "direct scan skipped" ); |
|
246 iScanState = EFinished; |
|
247 } |
|
248 } |
|
249 |
|
250 else if ( iScanState == EDirectScan ) |
|
251 { |
|
252 LOG_WRITE( "direct scan results" ); |
|
253 |
|
254 #ifndef __WINS__ |
|
255 ProcessDirectScanResultL(); |
|
256 #endif |
|
257 |
|
258 // delete the processed item (first) |
|
259 iDirectScanSsids.Remove( 0 ); |
|
260 iDirectScanIapIDs.Remove( 0 ); |
|
261 |
|
262 if ( iDirectScanSsids.Count() ) |
|
263 { |
|
264 // repeated direct scans for known networks |
|
265 #ifdef _DEBUG |
|
266 HBufC* ssid = TWsfWlanInfo::GetSsidAsUnicodeLC( |
|
267 iDirectScanSsids[0] ); |
|
268 LOG_WRITEF( "requesting direct scan for [%S]", ssid ); |
|
269 CleanupStack::PopAndDestroy( ssid ); |
|
270 #endif |
|
271 |
|
272 #ifndef __WINS__ |
|
273 // run direct scan |
|
274 iWlanMgmtClient->GetScanResults( iDirectScanSsids[0], |
|
275 iStatus, *iScanInfo ); |
|
276 SetActive(); |
|
277 #else |
|
278 // for testing |
|
279 SetActive(); |
|
280 TRequestStatus* status = &iStatus; |
|
281 User::RequestComplete( status, KErrNone ); |
|
282 #endif |
|
283 } |
|
284 else |
|
285 { |
|
286 // there is nothing more to do |
|
287 iScanState = EFinished; |
|
288 } |
|
289 } |
|
290 |
|
291 if ( iScanState == EFinished ) |
|
292 { |
|
293 LOG_WRITE( "scanning finished" ); |
|
294 #ifndef __WINS__ |
|
295 AddConnectedWLANInfoL(); |
|
296 |
|
297 TWsfWlanInfo* info(NULL); |
|
298 TInt scanArrayCount( iScanArray->Count() ); |
|
299 |
|
300 for ( TInt i(0) ; i < scanArrayCount ; i++ ) |
|
301 { |
|
302 info = (*iScanArray)[ i ]; |
|
303 |
|
304 if( info->iIapId ) |
|
305 { |
|
306 TRAPD( error, UpdatePriorityL( *info ) ); |
|
307 if ( error ) |
|
308 { |
|
309 // Ignore error and just continue |
|
310 LOG_WRITE( "Prio update failed" ); |
|
311 } |
|
312 } |
|
313 |
|
314 if( info->iIapId && info->iConnectionState != EConnected ) |
|
315 { |
|
316 ReplaceSsidsWithIapName( *info ); |
|
317 } |
|
318 } |
|
319 #endif //_WINS_ |
|
320 |
|
321 // sort the array |
|
322 iScanArray->SortArrayL(); |
|
323 |
|
324 HBufC8* results = iScanArray->SerializeContentLC(); |
|
325 CleanupStack::Pop( results ); |
|
326 delete iScanResults; |
|
327 iScanResults = results; |
|
328 |
|
329 // we may let go the scan array contents... |
|
330 iScanArray->Reset(); |
|
331 |
|
332 #ifdef _DEBUG |
|
333 DumpScanResultsL( iScanArray ); |
|
334 #endif |
|
335 // notify clients that data is ready |
|
336 if ( iObserver ) |
|
337 { |
|
338 iObserver->WlanScanCompleteL(); |
|
339 } |
|
340 |
|
341 if ( !iShowAvailability ) |
|
342 { |
|
343 // reset the timer if we are responsible for scheduling scans |
|
344 iTimer.Cancel(); |
|
345 iTimer.After( iStatus, |
|
346 TTimeIntervalMicroSeconds32( iScanningInterval ) ); |
|
347 Cancel(); |
|
348 SetActive(); |
|
349 } |
|
350 |
|
351 iScanState = EIdle; |
|
352 } |
|
353 } |
|
354 |
|
355 |
|
356 // --------------------------------------------------------------------------- |
|
357 // CWsfWlanScanner::AddConnectedWLANInfo |
|
358 // --------------------------------------------------------------------------- |
|
359 // |
|
360 void CWsfWlanScanner::AddConnectedWLANInfoL() |
|
361 { |
|
362 // Get the possible connection |
|
363 if ( iConnectionDetailsProvider ) |
|
364 { |
|
365 TWsfWlanInfo* connectedInfo = new (ELeave) TWsfWlanInfo(); |
|
366 CleanupStack::PushL( connectedInfo ); |
|
367 if ( iConnectionDetailsProvider->ConnectedWlanConnectionDetailsL( |
|
368 connectedInfo) ) |
|
369 { |
|
370 TBuf8<KWlanMaxAccessPointNameLength> connectedSsidOrIap; |
|
371 connectedSsidOrIap.Copy( connectedInfo->iSsid ); |
|
372 // ConnectedWlanConnectionDetailsL() may have returned an IAP name instead of SSID. |
|
373 // make sure that we really have SSID in connectedInfo->iSSID at this phase. |
|
374 TWlanSsid connectedSsid; |
|
375 iWlanMgmtClient->GetConnectionSsid( connectedSsid ); |
|
376 connectedInfo->iSsid.Copy( connectedSsid ); |
|
377 connectedInfo->iCoverage = 0; |
|
378 connectedInfo->iVisibility = 1; |
|
379 |
|
380 TBool connectedInfoAppended = EFalse; |
|
381 |
|
382 RPointerArray<TWsfWlanInfo> matchArray; |
|
383 CleanupClosePushL( matchArray ); |
|
384 |
|
385 if ( connectedInfo->iIapId ) |
|
386 { |
|
387 LOG_WRITEF( "Connected iap [%d]", connectedInfo->iIapId ); |
|
388 iScanArray->MatchWithIapIDL( connectedInfo->iIapId, |
|
389 iScanArray->Count(), matchArray ); |
|
390 |
|
391 if ( !matchArray.Count() ) |
|
392 { |
|
393 LOG_WRITE( "Not found with Iap id" ); |
|
394 iScanArray->MatchL( connectedInfo->iSsid, |
|
395 connectedInfo->iSecurityMode, |
|
396 connectedInfo->iNetMode, |
|
397 iScanArray->Count(), |
|
398 matchArray ); |
|
399 } |
|
400 |
|
401 } |
|
402 else |
|
403 { |
|
404 LOG_WRITE( "Easy WLAN connection" ); |
|
405 iScanArray->MatchL( connectedInfo->iSsid, |
|
406 connectedInfo->iSecurityMode, |
|
407 connectedInfo->iNetMode, iScanArray->Count(), |
|
408 matchArray ); |
|
409 } |
|
410 |
|
411 if ( matchArray.Count() ) |
|
412 { |
|
413 LOG_WRITE( "Info found" ); |
|
414 TWsfWlanInfo* temp = matchArray[0]; |
|
415 temp->iConnectionState = EConnected; |
|
416 temp->iSsid.Copy( connectedSsidOrIap ); |
|
417 temp->iNetworkName.Zero(); |
|
418 } |
|
419 else |
|
420 { |
|
421 LOG_WRITE( "Info not found - append" ); |
|
422 connectedInfo->iSsid.Copy( connectedSsidOrIap ); |
|
423 iScanArray->AppendL( connectedInfo ); |
|
424 connectedInfoAppended = ETrue; |
|
425 } |
|
426 |
|
427 CleanupStack::PopAndDestroy( &matchArray ); |
|
428 if ( connectedInfoAppended ) |
|
429 { |
|
430 CleanupStack::Pop( connectedInfo ); |
|
431 } |
|
432 else |
|
433 { |
|
434 CleanupStack::PopAndDestroy( connectedInfo ); |
|
435 } |
|
436 } |
|
437 else |
|
438 { |
|
439 CleanupStack::PopAndDestroy( connectedInfo ); |
|
440 } |
|
441 } |
|
442 else |
|
443 { |
|
444 LOG_WRITE( "No connection details provider" ); |
|
445 } |
|
446 } |
|
447 |
|
448 |
|
449 #ifdef _DEBUG |
|
450 // --------------------------------------------------------------------------- |
|
451 // CWsfWlanScanner::DumpScanResultsL |
|
452 // --------------------------------------------------------------------------- |
|
453 // |
|
454 void CWsfWlanScanner::DumpScanResultsL( CWsfWlanInfoArray* aArray ) |
|
455 { |
|
456 _LIT( Kopen, "open" ); |
|
457 _LIT( Kwep, "wep" ); |
|
458 _LIT( Kwpa, "wpa" ); |
|
459 _LIT( Kwpa2, "wpa2" ); |
|
460 _LIT( K802, "802.1x" ); |
|
461 const TDesC* secModes[4] = { &Kopen, &Kwep, &K802, &Kwpa }; |
|
462 _LIT( Kpsk, "psk" ); |
|
463 _LIT( Keap, "eap" ); |
|
464 _LIT( Khidden, "<hidden>" ); |
|
465 |
|
466 for ( TInt i( 0 ); i < aArray->Count(); ++i ) |
|
467 { |
|
468 TWsfWlanInfo* wi( (*aArray)[i] ); |
|
469 const TDesC* sm( 0 ); |
|
470 |
|
471 switch ( wi->iSecurityMode ) |
|
472 { |
|
473 case EWlanSecModeOpen: |
|
474 sm = &Kopen; |
|
475 break; |
|
476 case EWlanSecModeWep: |
|
477 sm = &Kwep; |
|
478 break; |
|
479 case EWlanSecModeWpa: |
|
480 sm = &Kwpa; |
|
481 break; |
|
482 case EWlanSecModeWpa2: |
|
483 sm = &Kwpa2; |
|
484 break; |
|
485 case EWlanSecMode802_1x: |
|
486 sm = &K802; |
|
487 } |
|
488 |
|
489 const TDesC* psk = wi->UsesPreSharedKey()? &Kpsk: |
|
490 ( ( wi->iSecurityMode == EWlanSecMode802_1x || |
|
491 wi->iSecurityMode == EWlanSecModeWpa || |
|
492 wi->iSecurityMode == EWlanSecModeWpa2 )? |
|
493 &Keap: &KNullDesC ); |
|
494 HBufC16 *ssid = TWsfWlanInfo::GetSsidAsUnicodeLC( wi->iSsid ); |
|
495 |
|
496 LOG_WRITEF( "[%S] %S %S %S", ssid, sm, psk, |
|
497 wi->iVisibility? &KNullDesC: &Khidden ); |
|
498 CleanupStack::PopAndDestroy( ssid ); |
|
499 } |
|
500 |
|
501 } |
|
502 #endif // _DEBUG |
|
503 |
|
504 |
|
505 // --------------------------------------------------------------------------- |
|
506 // CWsfWlanScanner::RunError |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 TInt CWsfWlanScanner::RunError( TInt aError ) |
|
510 { |
|
511 LOG_ENTERFN( "CWsfWlanScanner::RunError" ); |
|
512 LOG_WRITEF( "error = %d", aError ); |
|
513 |
|
514 iScanArray->Reset(); |
|
515 |
|
516 if ( iObserver && aError != KErrNotReady ) |
|
517 { |
|
518 // KErrNotReady is excluded as it indicates that the WLAN engine |
|
519 // has not yet set up itself, which we cannot help |
|
520 iObserver->NotifyError( aError ); |
|
521 } |
|
522 |
|
523 iScanState = EIdle; |
|
524 |
|
525 if ( !iShowAvailability ) |
|
526 { |
|
527 // the scanning has failed, re-issue the scan timer |
|
528 iTimer.Cancel(); |
|
529 iTimer.After( iStatus, |
|
530 TTimeIntervalMicroSeconds32( iScanningInterval ) ); |
|
531 SetActive(); |
|
532 } |
|
533 |
|
534 return KErrNone; |
|
535 } |
|
536 |
|
537 |
|
538 // --------------------------------------------------------------------------- |
|
539 // CWsfWlanScanner::SetObserver |
|
540 // --------------------------------------------------------------------------- |
|
541 // |
|
542 void CWsfWlanScanner::SetObserver( MWsfWlanScannerObserver& aObserver ) |
|
543 { |
|
544 iObserver = &aObserver; |
|
545 } |
|
546 |
|
547 |
|
548 // --------------------------------------------------------------------------- |
|
549 // CWsfWlanScanner::StartScanningL |
|
550 // --------------------------------------------------------------------------- |
|
551 // |
|
552 void CWsfWlanScanner::StartScanningL() |
|
553 { |
|
554 LOG_ENTERFN( "CWsfWlanScanner::StartScanningL" ); |
|
555 |
|
556 if ( iScanState == EIdle && !IsActive() ) |
|
557 { |
|
558 LOG_WRITE( "request notifications" ); |
|
559 #ifndef __WINS__ |
|
560 iWlanMgmtClient->CancelNotifications(); |
|
561 iWlanMgmtClient->ActivateNotificationsL( *this ); |
|
562 #endif |
|
563 iWlanSettingsAccessor->RequestNotificationL( *this ); |
|
564 |
|
565 iScanState = EIdle; |
|
566 |
|
567 if ( !iShowAvailability ) |
|
568 { |
|
569 // in case show wlan availability is off, carry out a scan now |
|
570 SetActive(); |
|
571 TRequestStatus* status = &iStatus; |
|
572 User::RequestComplete( status, KErrNone ); |
|
573 } |
|
574 } |
|
575 } |
|
576 |
|
577 |
|
578 // --------------------------------------------------------------------------- |
|
579 // CWsfWlanScanner::StartScanningL |
|
580 // --------------------------------------------------------------------------- |
|
581 // |
|
582 void CWsfWlanScanner::StopScanning() |
|
583 { |
|
584 LOG_ENTERFN( "CWsfWlanScanner::StopScanning" ); |
|
585 |
|
586 Cancel(); |
|
587 |
|
588 #ifndef __WINS__ |
|
589 if ( iWlanMgmtClient ) |
|
590 { |
|
591 iWlanMgmtClient->CancelNotifications(); |
|
592 } |
|
593 #endif |
|
594 |
|
595 if ( iWlanSettingsAccessor ) |
|
596 { |
|
597 iWlanSettingsAccessor->CancelNotifications(); |
|
598 } |
|
599 } |
|
600 |
|
601 |
|
602 // --------------------------------------------------------------------------- |
|
603 // CWsfWlanScanner::RestartScanning |
|
604 // --------------------------------------------------------------------------- |
|
605 // |
|
606 TBool CWsfWlanScanner::RestartScanning() |
|
607 { |
|
608 LOG_ENTERFN( "CWsfWlanScanner::RestartScanning" ); |
|
609 |
|
610 TBool restarted( EFalse ); |
|
611 |
|
612 if ( iScanState == EIdle && ( IsActive() || iShowAvailability ) ) |
|
613 { |
|
614 // we have been waiting for the timer to complete |
|
615 // cancel it manually |
|
616 Cancel(); |
|
617 |
|
618 // then complete ourselves |
|
619 SetActive(); |
|
620 TRequestStatus* status = &iStatus; |
|
621 User::RequestComplete( status, KErrNone ); |
|
622 restarted = ETrue; |
|
623 } |
|
624 |
|
625 return restarted; |
|
626 } |
|
627 |
|
628 |
|
629 // --------------------------------------------------------------------------- |
|
630 // CWsfWlanScanner::AbortScanning |
|
631 // --------------------------------------------------------------------------- |
|
632 // |
|
633 void CWsfWlanScanner::AbortScanning() |
|
634 { |
|
635 LOG_ENTERFN( "CWsfWlanScanner::AbortScanning" ); |
|
636 |
|
637 if ( iScanState != EIdle ) |
|
638 { |
|
639 // cancel the current scanning |
|
640 Cancel(); |
|
641 |
|
642 if ( !iShowAvailability ) |
|
643 { |
|
644 // still, life goes on |
|
645 iTimer.After( iStatus, TTimeIntervalMicroSeconds32( |
|
646 iScanningInterval ) ); |
|
647 SetActive(); |
|
648 } |
|
649 } |
|
650 } |
|
651 |
|
652 |
|
653 // --------------------------------------------------------------------------- |
|
654 // CWsfWlanScanner::ConnectionStateChanged |
|
655 // --------------------------------------------------------------------------- |
|
656 // |
|
657 void CWsfWlanScanner::ConnectionStateChanged( |
|
658 TWlanConnectionMode /*aNewState*/ ) |
|
659 { |
|
660 LOG_ENTERFN( "CWsfWlanScanner::ConnectionStateChanged" ); |
|
661 } |
|
662 |
|
663 |
|
664 // --------------------------------------------------------------------------- |
|
665 // CWsfWlanScanner::BssidChanged |
|
666 // --------------------------------------------------------------------------- |
|
667 // |
|
668 void CWsfWlanScanner::BssidChanged( TWlanBssid& /*aNewBSsid*/ ) |
|
669 { |
|
670 LOG_ENTERFN( "CWsfWlanScanner::BssidChanged" ); |
|
671 if ( iScanState == EIdle && !IsActive() ) |
|
672 { |
|
673 // complete ourselves |
|
674 SetActive(); |
|
675 TRequestStatus* status = &iStatus; |
|
676 User::RequestComplete( status, KErrNone ); |
|
677 } |
|
678 } |
|
679 |
|
680 |
|
681 // --------------------------------------------------------------------------- |
|
682 // CWsfWlanScanner::BssLost |
|
683 // --------------------------------------------------------------------------- |
|
684 // |
|
685 void CWsfWlanScanner::BssLost() |
|
686 { |
|
687 LOG_ENTERFN( "CWsfWlanScanner::BssLost" ); |
|
688 if ( iScanState == EIdle && !IsActive() ) |
|
689 { |
|
690 // complete ourselves |
|
691 SetActive(); |
|
692 TRequestStatus* status = &iStatus; |
|
693 User::RequestComplete( status, KErrNone ); |
|
694 } |
|
695 } |
|
696 |
|
697 |
|
698 // --------------------------------------------------------------------------- |
|
699 // CWsfWlanScanner::BssRegained |
|
700 // --------------------------------------------------------------------------- |
|
701 // |
|
702 void CWsfWlanScanner::BssRegained() |
|
703 { |
|
704 LOG_ENTERFN( "CWsfWlanScanner::BssRegained" ); |
|
705 if ( iScanState == EIdle && !IsActive() ) |
|
706 { |
|
707 // complete ourselves |
|
708 SetActive(); |
|
709 TRequestStatus* status = &iStatus; |
|
710 User::RequestComplete( status, KErrNone ); |
|
711 } |
|
712 } |
|
713 |
|
714 |
|
715 // --------------------------------------------------------------------------- |
|
716 // CWsfWlanScanner::NewNetworksDetected |
|
717 // --------------------------------------------------------------------------- |
|
718 // |
|
719 void CWsfWlanScanner::NewNetworksDetected() |
|
720 { |
|
721 LOG_ENTERFN( "CWsfWlanScanner::NewNetworksDetected" ); |
|
722 if ( iScanState == EIdle && !IsActive() ) |
|
723 { |
|
724 // complete ourselves |
|
725 SetActive(); |
|
726 TRequestStatus* status = &iStatus; |
|
727 User::RequestComplete( status, KErrNone ); |
|
728 } |
|
729 } |
|
730 |
|
731 |
|
732 // --------------------------------------------------------------------------- |
|
733 // CWsfWlanScanner::OldNetworksLost |
|
734 // --------------------------------------------------------------------------- |
|
735 // |
|
736 void CWsfWlanScanner::OldNetworksLost() |
|
737 { |
|
738 LOG_ENTERFN( "CWsfWlanScanner::OldNetworksLost" ); |
|
739 if ( iScanState == EIdle && !IsActive() ) |
|
740 { |
|
741 // complete ourselves |
|
742 SetActive(); |
|
743 TRequestStatus* status = &iStatus; |
|
744 User::RequestComplete( status, KErrNone ); |
|
745 } |
|
746 } |
|
747 |
|
748 |
|
749 // --------------------------------------------------------------------------- |
|
750 // CWsfWlanScanner::TransmitPowerChanged |
|
751 // --------------------------------------------------------------------------- |
|
752 // |
|
753 void CWsfWlanScanner::TransmitPowerChanged( TUint /*aPower*/ ) |
|
754 { |
|
755 LOG_ENTERFN( "CWsfWlanScanner::TransmitPowerChanged" ); |
|
756 if ( iScanState == EIdle && !IsActive() ) |
|
757 { |
|
758 // complete ourselves |
|
759 SetActive(); |
|
760 TRequestStatus* status = &iStatus; |
|
761 User::RequestComplete( status, KErrNone ); |
|
762 } |
|
763 } |
|
764 |
|
765 |
|
766 // --------------------------------------------------------------------------- |
|
767 // CWsfWlanScanner::RssChanged |
|
768 // --------------------------------------------------------------------------- |
|
769 // |
|
770 void CWsfWlanScanner::RssChanged( TWlanRssClass /*aRssClass*/, TUint /*aRss*/ ) |
|
771 { |
|
772 LOG_ENTERFN( "CWsfWlanScanner::RssChanged" ); |
|
773 if ( iScanState == EIdle && !IsActive() ) |
|
774 { |
|
775 // complete ourselves |
|
776 SetActive(); |
|
777 TRequestStatus* status = &iStatus; |
|
778 User::RequestComplete( status, KErrNone ); |
|
779 } |
|
780 } |
|
781 |
|
782 |
|
783 // --------------------------------------------------------------------------- |
|
784 // CWsfWlanScanner::PrepareDirectScan |
|
785 // --------------------------------------------------------------------------- |
|
786 // |
|
787 void CWsfWlanScanner::PrepareDirectScan() |
|
788 { |
|
789 LOG_ENTERFN( "CWsfWlanScanner::PrepareDirectScanL" ); |
|
790 |
|
791 // flush the arrays |
|
792 iDirectScanSsids.Reset(); |
|
793 iDirectScanIapIDs.Reset(); |
|
794 } |
|
795 |
|
796 |
|
797 // --------------------------------------------------------------------------- |
|
798 // CWsfWlanScanner::ProcessDirectScanResultL |
|
799 // --------------------------------------------------------------------------- |
|
800 // |
|
801 void CWsfWlanScanner::ProcessDirectScanResultL() |
|
802 { |
|
803 LOG_ENTERFN( "CWsfWlanScanner::ProcessDirectScanResultL" ); |
|
804 |
|
805 for ( iScanInfo->First(); !iScanInfo->IsDone(); iScanInfo->Next() ) |
|
806 { |
|
807 RPointerArray<TWsfWlanInfo> matchArray; |
|
808 CleanupClosePushL(matchArray); |
|
809 iScanArray->MatchWithIapIDL( iDirectScanIapIDs[0], iScanArray->Count(), matchArray ); |
|
810 |
|
811 TInt matchcount = matchArray.Count(); |
|
812 |
|
813 if ( matchcount == 0 ) |
|
814 { |
|
815 // not found yet |
|
816 #ifdef _DEBUG |
|
817 HBufC* ssid = TWsfWlanInfo::GetSsidAsUnicodeLC( iDirectScanSsids[0] ); |
|
818 LOG_WRITEF( "[%S] found in direct scan", ssid ); |
|
819 CleanupStack::PopAndDestroy( ssid ); |
|
820 #endif |
|
821 } |
|
822 else |
|
823 { |
|
824 LOG_WRITEF( "[%d] iap id is in scanarray", iDirectScanIapIDs[0] ); |
|
825 for( TInt i(0); i < matchcount; i++ ) |
|
826 { |
|
827 //if already found increase coverage |
|
828 TWsfWlanInfo* temp = matchArray[i]; |
|
829 ++temp->iCoverage; |
|
830 RefreshSignalStrength( *temp ); |
|
831 RefreshMaxRate( *temp ); |
|
832 } |
|
833 } |
|
834 // Close() for matchArray |
|
835 CleanupStack::PopAndDestroy( &matchArray ); |
|
836 } // for iScanInfo |
|
837 } |
|
838 |
|
839 |
|
840 // --------------------------------------------------------------------------- |
|
841 // CWsfWlanScanner::ReplaceSsidsWithIapName |
|
842 // --------------------------------------------------------------------------- |
|
843 // |
|
844 void CWsfWlanScanner::ReplaceSsidsWithIapName(TWsfWlanInfo& aWlanInfo) |
|
845 { |
|
846 LOG_ENTERFN( "CWsfWlanScanner::ReplaceSsidsWithIapName" ); |
|
847 if ( aWlanInfo.iNetworkName.Length() ) |
|
848 { |
|
849 LOG_WRITE( "Replace ssid" ); |
|
850 aWlanInfo.iSsid.Copy( aWlanInfo.iNetworkName ); |
|
851 aWlanInfo.iNetworkName.Zero(); |
|
852 } |
|
853 } |
|
854 |
|
855 |
|
856 // --------------------------------------------------------------------------- |
|
857 // CWsfWlanScanner::UpdatePriorityL |
|
858 // --------------------------------------------------------------------------- |
|
859 // |
|
860 void CWsfWlanScanner::UpdatePriorityL( TWsfWlanInfo& aWlanInfo ) |
|
861 { |
|
862 LOG_WRITE( "CWsfWlanScanner::updatePriority" ); |
|
863 |
|
864 TUint32 priority( 0 ); |
|
865 TInt exists( KErrNotFound ); |
|
866 TInt count( 0 ); |
|
867 |
|
868 // search for the destination of it |
|
869 RArray<TUint32> destinations; |
|
870 CleanupClosePushL( destinations ); |
|
871 |
|
872 LOG_WRITE( "CWsfWlanScanner::updatePriority get all destinations" ); |
|
873 iCmManagerExt.AllDestinationsL(destinations); |
|
874 |
|
875 count = destinations.Count(); |
|
876 LOG_WRITEF( "destination count %d", count); |
|
877 |
|
878 for( TInt i = 0; i < count && exists != KErrNone; i++ ) |
|
879 { |
|
880 RCmDestinationExt destination; |
|
881 destination = iCmManagerExt.DestinationL( destinations[ i ] ); |
|
882 CleanupClosePushL( destination ); |
|
883 |
|
884 LOG_WRITE( "check if connection method belongs to destination" ); |
|
885 |
|
886 RCmConnectionMethodExt connectionMethod; |
|
887 TRAP( exists, |
|
888 connectionMethod = destination.ConnectionMethodByIDL( |
|
889 aWlanInfo.iIapId ) ); |
|
890 |
|
891 LOG_WRITEF( "exists %d", exists ); |
|
892 if( exists == KErrNone ) |
|
893 { |
|
894 CleanupClosePushL( connectionMethod ); |
|
895 // correct destination found |
|
896 priority = destination.PriorityL( connectionMethod ); |
|
897 aWlanInfo.SetPriority( priority ); |
|
898 |
|
899 LOG_WRITEF( "priority %d", priority ); |
|
900 CleanupStack::PopAndDestroy( &connectionMethod ); |
|
901 } |
|
902 CleanupStack::PopAndDestroy( &destination ); |
|
903 } |
|
904 CleanupStack::PopAndDestroy( &destinations ); |
|
905 } |
|
906 |
|
907 |
|
908 #ifndef __WINS__ |
|
909 // --------------------------------------------------------------------------- |
|
910 // CWsfWlanScanner::DoScanForNetworksL |
|
911 // --------------------------------------------------------------------------- |
|
912 // |
|
913 void CWsfWlanScanner::DoScanForNetworksL() |
|
914 { |
|
915 LOG_ENTERFN( "CWsfWlanScanner::DoScanForNetworksL" ); |
|
916 |
|
917 // start by making sure the scan array is empty |
|
918 iScanArray->Reset(); |
|
919 |
|
920 LOG_WRITEF( "GetScanResults returned %d", iStatus.Int() ); |
|
921 |
|
922 if ( iStatus.Int() ) |
|
923 { |
|
924 // if the status is not KErrNone, we cannot be sure that iScanInfo |
|
925 // doesn't cause a crash, so it's better to leave |
|
926 User::Leave( iStatus.Int() ); |
|
927 } |
|
928 |
|
929 TInt nElem = 0; |
|
930 TBool isHidden( EFalse ); |
|
931 |
|
932 // get available iaps |
|
933 // (this only shows iaps with security mode matching to scan results |
|
934 // and also finds hidden wlans for which an iap has been configured) |
|
935 RArray<TUint> availableIaps; |
|
936 iWlanMgmtClient->GetAvailableIaps(availableIaps); |
|
937 TInt avIapCount = availableIaps.Count(); |
|
938 |
|
939 LOG_WRITEF( "Available iap count %d", avIapCount ); |
|
940 |
|
941 for( TInt i(0); i < avIapCount; i++ ) |
|
942 { |
|
943 TBool addToArray( ETrue ); |
|
944 TWsfWlanInfo* availableInfo = new ( ELeave ) TWsfWlanInfo(); |
|
945 CleanupStack::PushL( availableInfo ); |
|
946 availableInfo->iIapId = availableIaps[i]; |
|
947 TRAPD( error, GetWlanInfoFromIapL( *availableInfo ) ); |
|
948 |
|
949 if ( error == KErrNotFound ) |
|
950 { |
|
951 LOG_WRITEF( "Iap id = %d does not exist", availableInfo->iIapId ); |
|
952 addToArray = EFalse; |
|
953 } |
|
954 else if ( error ) |
|
955 { |
|
956 LOG_WRITEF( "GetWlanInfoFromIapL failed err = %d", error ); |
|
957 User::Leave( error ); |
|
958 } |
|
959 |
|
960 if( addToArray ) |
|
961 { |
|
962 LOG_WRITE( "Add to array" ); |
|
963 availableInfo->iCoverage = 0; |
|
964 availableInfo->iVisibility = 1; |
|
965 availableInfo->iStrengthLevel = EWlanSignalUnavailable; |
|
966 availableInfo->iTransferRate = 0; |
|
967 availableInfo->iConnectionState = ENotConnected; |
|
968 iScanArray->AppendL(availableInfo); |
|
969 nElem++; |
|
970 |
|
971 if ( availableInfo->iIapId ) |
|
972 { |
|
973 LOG_WRITEF( "Append available iap [%d] for direct scan", availableInfo->iIapId ); |
|
974 iDirectScanIapIDs.Append( availableInfo->iIapId ); |
|
975 iDirectScanSsids.Append( availableInfo->iSsid ); |
|
976 } |
|
977 |
|
978 CleanupStack::Pop( availableInfo ); |
|
979 } |
|
980 else |
|
981 { |
|
982 LOG_WRITE( "Info not added" ); |
|
983 CleanupStack::PopAndDestroy( availableInfo ); |
|
984 } |
|
985 } |
|
986 |
|
987 // Process the scanned results |
|
988 for( iScanInfo->First(); !iScanInfo->IsDone(); iScanInfo->Next() ) |
|
989 { |
|
990 TWsfWlanInfo* wlanInfo = iScanArray->At( nElem ); |
|
991 if ( !wlanInfo ) |
|
992 { |
|
993 wlanInfo = new ( ELeave ) TWsfWlanInfo(); |
|
994 CleanupStack::PushL( wlanInfo ); |
|
995 iScanArray->AppendL( wlanInfo ); |
|
996 CleanupStack::Pop( wlanInfo ); |
|
997 } |
|
998 isHidden = RefreshNetworkNameL( *wlanInfo ); |
|
999 wlanInfo->iVisibility = !isHidden; |
|
1000 wlanInfo->iStrengthLevel = EWlanSignalUnavailable; |
|
1001 wlanInfo->iTransferRate = 0; |
|
1002 wlanInfo->iConnectionState = ENotConnected; |
|
1003 |
|
1004 if( !isHidden ) |
|
1005 { |
|
1006 // not hidden |
|
1007 RefreshNetworkMode( *wlanInfo ); |
|
1008 RefreshSecurityMode( *wlanInfo ); |
|
1009 RefreshMaxRate( *wlanInfo ); |
|
1010 |
|
1011 // check if we already have an entry/entries corresponding to a scan result |
|
1012 // (multiple entries for one scan result possible if GetAvailableIaps() |
|
1013 // found several iaps configured for same wlan) |
|
1014 RPointerArray<TWsfWlanInfo> matchArray; |
|
1015 CleanupClosePushL(matchArray); |
|
1016 iScanArray->MatchL( wlanInfo->iSsid, wlanInfo->iSecurityMode, |
|
1017 wlanInfo->iNetMode, nElem, matchArray ); |
|
1018 |
|
1019 TInt matchcount = matchArray.Count(); |
|
1020 |
|
1021 // if not found |
|
1022 if( matchcount == 0 ) |
|
1023 { |
|
1024 wlanInfo->iCoverage = 1; |
|
1025 RefreshSignalStrength( *wlanInfo ); |
|
1026 RefreshMaxRate( *wlanInfo ); |
|
1027 ++nElem; // new entry, inc index in array |
|
1028 } |
|
1029 else // if found inc coverage and refresh signal strength and rate |
|
1030 { |
|
1031 for( TInt i(0); i < matchcount; i++ ) |
|
1032 { |
|
1033 TWsfWlanInfo* temp = matchArray[i]; |
|
1034 ++temp->iCoverage; |
|
1035 RefreshSignalStrength( *temp ); |
|
1036 RefreshMaxRate( *temp ); |
|
1037 |
|
1038 if ( temp->iIapId ) |
|
1039 { |
|
1040 TInt index( KErrNone ); |
|
1041 do { |
|
1042 LOG_WRITE( "Not hidden - Searching from direct scan list.." ); |
|
1043 // remove this item from the direct scan list, if found |
|
1044 index = iDirectScanIapIDs.Find( temp->iIapId ); |
|
1045 if ( index != KErrNotFound ) |
|
1046 { |
|
1047 LOG_WRITEF( "Found - removing iap id [%d]", iDirectScanIapIDs[index] ); |
|
1048 iDirectScanSsids.Remove( index ); |
|
1049 iDirectScanIapIDs.Remove( index ); |
|
1050 } |
|
1051 } while ( index != KErrNotFound ); |
|
1052 } |
|
1053 } |
|
1054 } |
|
1055 CleanupStack::PopAndDestroy(); // results in Close() being called on matchArray |
|
1056 } |
|
1057 } |
|
1058 //get rid of excess items |
|
1059 iScanArray->DeleteFromTail(iScanArray->Count() - nElem); |
|
1060 } |
|
1061 |
|
1062 #else // __WINS__ |
|
1063 |
|
1064 // --------------------------------------------------------------------------- |
|
1065 // CWsfWlanScanner::DoScanForNetworksL |
|
1066 // --------------------------------------------------------------------------- |
|
1067 // |
|
1068 void CWsfWlanScanner::DoScanForNetworksL() |
|
1069 { |
|
1070 LOG_ENTERFN( "CWsfWlanScanner::DoScanForNetworksL" ); |
|
1071 |
|
1072 // start by making sure the scan array is empty |
|
1073 iScanArray->Reset(); |
|
1074 |
|
1075 TWsfWlanInfo* wlan0 = new (ELeave) TWsfWlanInfo(); |
|
1076 CleanupStack::PushL( wlan0 ); |
|
1077 wlan0->iConnectionState = EConnected; |
|
1078 wlan0->iIapId = 666; |
|
1079 wlan0->iNetMode = EInfra; |
|
1080 wlan0->iSecurityMode = EWlanSecModeWep; |
|
1081 wlan0->iSsid = _L8("[C]Known WEP"); |
|
1082 wlan0->iStrengthLevel = EWlanSignalStrengthMax; |
|
1083 wlan0->iVisibility = ETrue; |
|
1084 wlan0->iCoverage = 1; |
|
1085 if ( Math::Random() % 2 == 0 ) |
|
1086 { |
|
1087 iScanArray->AppendL( wlan0 ); |
|
1088 } |
|
1089 else |
|
1090 { |
|
1091 delete wlan0; |
|
1092 } |
|
1093 |
|
1094 CleanupStack::Pop( wlan0 ); |
|
1095 |
|
1096 TWsfWlanInfo* wlan1 = new (ELeave) TWsfWlanInfo(); |
|
1097 CleanupStack::PushL( wlan1 ); |
|
1098 wlan1->iConnectionState = ENotConnected; |
|
1099 wlan1->iIapId = 666; |
|
1100 wlan1->iNetMode = EInfra; |
|
1101 wlan1->iSecurityMode = EWlanSecModeOpen; |
|
1102 wlan1->iSsid = _L8("Known open"); |
|
1103 wlan1->iStrengthLevel = EWlanSignalStrengthMin; |
|
1104 wlan1->iVisibility = ETrue; |
|
1105 wlan1->iCoverage = 3; |
|
1106 if ( Math::Random() % 2 == 0 ) |
|
1107 { |
|
1108 iScanArray->AppendL( wlan1 ); |
|
1109 } |
|
1110 else |
|
1111 { |
|
1112 delete wlan1; |
|
1113 } |
|
1114 |
|
1115 CleanupStack::Pop( wlan1 ); |
|
1116 |
|
1117 TWsfWlanInfo* wlan2 = new (ELeave) TWsfWlanInfo(); |
|
1118 CleanupStack::PushL( wlan2 ); |
|
1119 wlan2->iConnectionState = ENotConnected; |
|
1120 wlan2->iIapId = 0; |
|
1121 wlan2->iNetMode = EInfra; |
|
1122 wlan2->iSecurityMode = EWlanSecModeWpa2; |
|
1123 wlan2->iSsid = _L8("Known WPA2 PSK"); |
|
1124 wlan2->iStrengthLevel = EWlanSignalStrengthLow-7; |
|
1125 wlan2->iVisibility = ETrue; |
|
1126 wlan2->iCoverage = 1; |
|
1127 wlan2->SetUsesPreSharedKey( ETrue ); |
|
1128 if ( Math::Random() % 2 == 0 ) |
|
1129 { |
|
1130 iScanArray->AppendL( wlan2 ); |
|
1131 } |
|
1132 else |
|
1133 { |
|
1134 delete wlan2; |
|
1135 } |
|
1136 CleanupStack::Pop( wlan2 ); |
|
1137 |
|
1138 TWsfWlanInfo* wlan3 = new (ELeave) TWsfWlanInfo(); |
|
1139 CleanupStack::PushL( wlan3 ); |
|
1140 wlan3->iConnectionState = ENotConnected; |
|
1141 wlan3->iIapId = 0; |
|
1142 wlan3->iNetMode = EInfra; |
|
1143 wlan3->iSecurityMode = EWlanSecModeOpen; |
|
1144 wlan3->iSsid = _L8("Unknown open"); |
|
1145 wlan3->iStrengthLevel = EWlanSignalStrengthMax; |
|
1146 wlan3->iVisibility = 1; |
|
1147 wlan3->iCoverage = 1; |
|
1148 if ( Math::Random() % 2 == 0 ) |
|
1149 { |
|
1150 iScanArray->AppendL( wlan3 ); |
|
1151 } |
|
1152 else |
|
1153 { |
|
1154 delete wlan3; |
|
1155 } |
|
1156 CleanupStack::Pop( wlan3 ); |
|
1157 |
|
1158 TWsfWlanInfo* wlan4 = new (ELeave) TWsfWlanInfo(); |
|
1159 CleanupStack::PushL( wlan4 ); |
|
1160 wlan4->iConnectionState = ENotConnected; |
|
1161 wlan4->iIapId = 0; |
|
1162 wlan4->iNetMode = EAdhoc; |
|
1163 wlan4->iSecurityMode = EWlanSecModeWpa; |
|
1164 wlan4->iSsid = _L8("Unknown WPA"); |
|
1165 wlan4->iStrengthLevel = EWlanSignalStrengthMin; |
|
1166 wlan4->iVisibility = 1; |
|
1167 wlan4->iCoverage = 1; |
|
1168 wlan2->SetUsesPreSharedKey( ETrue ); |
|
1169 |
|
1170 if ( Math::Random() % 2 == 0 ) |
|
1171 { |
|
1172 iScanArray->AppendL( wlan4 ); |
|
1173 } |
|
1174 else |
|
1175 { |
|
1176 delete wlan4; |
|
1177 } |
|
1178 CleanupStack::Pop( wlan4 ); |
|
1179 |
|
1180 TWsfWlanInfo* wlan5 = new (ELeave) TWsfWlanInfo(); |
|
1181 CleanupStack::PushL( wlan5 ); |
|
1182 wlan5->iConnectionState = ENotConnected; |
|
1183 wlan5->iIapId = 12; |
|
1184 wlan5->iNetMode = EInfra; |
|
1185 wlan5->iSecurityMode = EWlanSecModeOpen; |
|
1186 wlan5->iSsid = _L8("SES"); |
|
1187 wlan5->iStrengthLevel = EWlanSignalStrengthLow-5; |
|
1188 wlan5->iVisibility = 0; |
|
1189 wlan5->iCoverage = 1; |
|
1190 if ( Math::Random() % 2 == 0 ) |
|
1191 { |
|
1192 iScanArray->AppendL( wlan5 ); |
|
1193 } |
|
1194 else |
|
1195 { |
|
1196 delete wlan5; |
|
1197 } |
|
1198 |
|
1199 CleanupStack::Pop( wlan5 ); |
|
1200 |
|
1201 TWsfWlanInfo* wlan6 = new (ELeave) TWsfWlanInfo(); |
|
1202 CleanupStack::PushL( wlan6 ); |
|
1203 wlan6->iConnectionState = ENotConnected; |
|
1204 wlan6->iIapId = 666; |
|
1205 wlan6->iNetMode = EInfra; |
|
1206 wlan6->iSecurityMode = EWlanSecModeWpa; |
|
1207 wlan6->iSsid = _L8("Sunny 22"); |
|
1208 wlan6->iStrengthLevel = EWlanSignalStrengthMin; |
|
1209 wlan6->iVisibility = 1; |
|
1210 wlan6->iCoverage = 2; |
|
1211 if ( Math::Random() % 2 == 0 ) |
|
1212 { |
|
1213 iScanArray->AppendL( wlan6 ); |
|
1214 } |
|
1215 else |
|
1216 { |
|
1217 delete wlan6; |
|
1218 } |
|
1219 CleanupStack::Pop( wlan6 ); |
|
1220 |
|
1221 |
|
1222 wlan5 = new (ELeave) TWsfWlanInfo(); |
|
1223 CleanupStack::PushL( wlan5 ); |
|
1224 wlan5->iConnectionState = ENotConnected; |
|
1225 wlan5->iIapId = 0; |
|
1226 wlan5->iNetMode = EInfra; |
|
1227 wlan5->iSecurityMode = EWlanSecModeOpen; |
|
1228 wlan5->iSsid = _L8("FON_accesspoint"); |
|
1229 wlan5->iStrengthLevel = EWlanSignalStrengthLow-8; |
|
1230 wlan5->iVisibility = 1; |
|
1231 wlan5->iCoverage = 1; |
|
1232 if ( Math::Random() % 2 == 0 ) |
|
1233 { |
|
1234 iScanArray->AppendL( wlan5 ); |
|
1235 } |
|
1236 else |
|
1237 { |
|
1238 delete wlan5; |
|
1239 } |
|
1240 CleanupStack::Pop( wlan5 ); |
|
1241 |
|
1242 |
|
1243 TWsfWlanInfo* wlan7 = new (ELeave) TWsfWlanInfo(); |
|
1244 CleanupStack::PushL( wlan7 ); |
|
1245 wlan7->iConnectionState = ENotConnected; |
|
1246 wlan7->iIapId = 667; |
|
1247 wlan7->iNetMode = EAdhoc; |
|
1248 wlan7->iSecurityMode = EWlanSecModeWpa; |
|
1249 wlan7->iSsid = _L8("Ad-hoc WPA"); |
|
1250 wlan7->iStrengthLevel = EWlanSignalStrengthMax; |
|
1251 wlan7->iVisibility = ETrue; |
|
1252 wlan7->iCoverage = 1; |
|
1253 if ( Math::Random() % 2 == 0 ) |
|
1254 { |
|
1255 iScanArray->AppendL( wlan7 ); |
|
1256 } |
|
1257 else |
|
1258 { |
|
1259 delete wlan7; |
|
1260 } |
|
1261 CleanupStack::Pop( wlan7 ); |
|
1262 |
|
1263 TWsfWlanInfo* wlan8 = new (ELeave) TWsfWlanInfo(); |
|
1264 CleanupStack::PushL( wlan8 ); |
|
1265 wlan8->iConnectionState = ENotConnected; |
|
1266 wlan8->iIapId = 667; |
|
1267 wlan8->iNetMode = EInfra; |
|
1268 wlan8->iSecurityMode = EWlanSecModeOpen; |
|
1269 wlan8->iSsid = _L8("Known pri 1"); |
|
1270 wlan8->iStrengthLevel = EWlanSignalStrengthMax; |
|
1271 wlan8->iVisibility = ETrue; |
|
1272 wlan8->iCoverage = 1; |
|
1273 wlan8->iPriority = 1; |
|
1274 if ( Math::Random() % 2 == 0 ) |
|
1275 { |
|
1276 iScanArray->AppendL( wlan8 ); |
|
1277 } |
|
1278 else |
|
1279 { |
|
1280 delete wlan8; |
|
1281 } |
|
1282 CleanupStack::Pop( wlan8 ); |
|
1283 |
|
1284 TWsfWlanInfo* wlan9 = new (ELeave) TWsfWlanInfo(); |
|
1285 CleanupStack::PushL( wlan9 ); |
|
1286 wlan9->iConnectionState = ENotConnected; |
|
1287 wlan9->iIapId = 668; |
|
1288 wlan9->iNetMode = EInfra; |
|
1289 wlan9->iSecurityMode = EWlanSecModeOpen; |
|
1290 wlan9->iSsid = _L8("Known pri 2"); |
|
1291 wlan9->iStrengthLevel = EWlanSignalStrengthMax; |
|
1292 wlan9->iVisibility = ETrue; |
|
1293 wlan9->iCoverage = 1; |
|
1294 wlan9->iPriority = 2; |
|
1295 if ( Math::Random() % 2 == 0 ) |
|
1296 { |
|
1297 iScanArray->AppendL( wlan9 ); |
|
1298 } |
|
1299 else |
|
1300 { |
|
1301 delete wlan9; |
|
1302 } |
|
1303 CleanupStack::Pop( wlan9 ); |
|
1304 |
|
1305 |
|
1306 } |
|
1307 |
|
1308 #endif // __WINS__ |
|
1309 |
|
1310 // --------------------------------------------------------------------------- |
|
1311 // CWsfWlanScanner::GetWlanInfoFromIapL() |
|
1312 // --------------------------------------------------------------------------- |
|
1313 // |
|
1314 void CWsfWlanScanner::GetWlanInfoFromIapL( TWsfWlanInfo& aWlanInfo ) |
|
1315 { |
|
1316 LOG_ENTERFN( "CWsfWlanScanner::GetWlanInfoFromIapL" ); |
|
1317 |
|
1318 CCommsDatabase* commsDb = CCommsDatabase::NewL(); |
|
1319 CleanupStack::PushL( commsDb ); |
|
1320 |
|
1321 CCommsDbTableView* commsDbIapTableView = commsDb->OpenViewMatchingUintLC( |
|
1322 TPtrC( IAP ), TPtrC( COMMDB_ID ), aWlanInfo.iIapId ); |
|
1323 User::LeaveIfError( commsDbIapTableView->GotoFirstRecord() ); |
|
1324 |
|
1325 // network name |
|
1326 TBuf<KCommsDbSvrMaxFieldLength> iapName; |
|
1327 commsDbIapTableView->ReadTextL( TPtrC( COMMDB_NAME ), iapName); |
|
1328 |
|
1329 TInt error = CnvUtfConverter::ConvertFromUnicodeToUtf8( |
|
1330 aWlanInfo.iNetworkName, |
|
1331 iapName ); |
|
1332 if ( error ) |
|
1333 { |
|
1334 LOG_WRITE( "ConvertFromUnicodeToUtf8 failed"); |
|
1335 aWlanInfo.iNetworkName.Copy( iapName ); |
|
1336 } |
|
1337 |
|
1338 // service Id |
|
1339 TUint32 serviceId(0); |
|
1340 commsDbIapTableView->ReadUintL(TPtrC( IAP_SERVICE), serviceId); |
|
1341 CCommsDbTableView* wlanTableView = commsDb->OpenViewMatchingUintLC( |
|
1342 TPtrC( WLAN_SERVICE), TPtrC( WLAN_SERVICE_ID), serviceId); |
|
1343 User::LeaveIfError(wlanTableView->GotoFirstRecord() ); |
|
1344 |
|
1345 // ssid |
|
1346 wlanTableView->ReadTextL( TPtrC( NU_WLAN_SSID ), aWlanInfo.iSsid ); |
|
1347 |
|
1348 // security mode |
|
1349 TUint32 secMode(0); |
|
1350 wlanTableView->ReadUintL(TPtrC( WLAN_SECURITY_MODE), secMode); |
|
1351 // Map Wpa2 to Wpa |
|
1352 secMode = ( secMode == EWlanSecModeWpa2 )? EWlanSecModeWpa : secMode; |
|
1353 aWlanInfo.iSecurityMode = static_cast<TWlanSecMode>(secMode); |
|
1354 |
|
1355 // net mode |
|
1356 TUint32 netMode(0); |
|
1357 wlanTableView->ReadUintL(TPtrC( WLAN_CONNECTION_MODE), netMode); |
|
1358 aWlanInfo.iNetMode = static_cast<TWlanNetMode>(netMode); |
|
1359 |
|
1360 CleanupStack::PopAndDestroy(wlanTableView); |
|
1361 CleanupStack::PopAndDestroy(commsDbIapTableView); |
|
1362 CleanupStack::PopAndDestroy(commsDb); |
|
1363 } |
|
1364 |
|
1365 |
|
1366 // --------------------------------------------------------------------------- |
|
1367 // CWsfWlanScanner::SsidIdentity |
|
1368 // --------------------------------------------------------------------------- |
|
1369 // |
|
1370 TBool CWsfWlanScanner::SsidIdentity( const TWlanSsid& aSsid1, |
|
1371 const TWlanSsid& aSsid2 ) |
|
1372 { |
|
1373 return !aSsid1.Compare( aSsid2 ); |
|
1374 } |
|
1375 |
|
1376 |
|
1377 // --------------------------------------------------------------------------- |
|
1378 // CWsfWlanScanner::RefreshNetworkNameL |
|
1379 // --------------------------------------------------------------------------- |
|
1380 // |
|
1381 TBool CWsfWlanScanner::RefreshNetworkNameL( TWsfWlanInfo& aWlanInfo ) |
|
1382 { |
|
1383 LOG_ENTERFN( "CWsfWlanScanner::RefreshNetworkNameL" ); |
|
1384 |
|
1385 TBool isHidden( EFalse ); |
|
1386 |
|
1387 TUint8 ieLen( 0 ); |
|
1388 const TUint8* ieData; |
|
1389 TBuf8<KWlanMaxSsidLength> ssid8; |
|
1390 |
|
1391 TInt ret = iScanInfo->InformationElement( E802Dot11SsidIE, ieLen, |
|
1392 &ieData ); |
|
1393 |
|
1394 if ( ret == KErrNone ) |
|
1395 { |
|
1396 isHidden = IsHiddenSsid( ieLen, ieData ); |
|
1397 |
|
1398 if ( ieLen ) |
|
1399 { |
|
1400 ssid8.Copy( ieData, ieLen ); |
|
1401 aWlanInfo.iSsid.Copy( ssid8 ); |
|
1402 TBuf<KWlanMaxSsidLength> ssid16; |
|
1403 ssid16.Copy( ssid8 ); |
|
1404 LOG_WRITEF( "SSID: [%S]", &ssid16 ); |
|
1405 } |
|
1406 else |
|
1407 { |
|
1408 LOG_WRITE( "SSID: <hidden>" ); |
|
1409 } |
|
1410 } |
|
1411 else |
|
1412 { |
|
1413 User::Leave( ret ); |
|
1414 } |
|
1415 |
|
1416 return isHidden; |
|
1417 } |
|
1418 |
|
1419 |
|
1420 // --------------------------------------------------------------------------- |
|
1421 // CWsfWlanScanner::IsHiddenSsid |
|
1422 // --------------------------------------------------------------------------- |
|
1423 // |
|
1424 TBool CWsfWlanScanner::IsHiddenSsid( TUint aSsidLength, const TUint8* aSsid ) |
|
1425 { |
|
1426 LOG_ENTERFN( "CWsfWlanScanner::IsHiddenSsid" ); |
|
1427 |
|
1428 |
|
1429 if ( !aSsidLength ) |
|
1430 { |
|
1431 LOG_WRITEF( "result: %d", ETrue ); |
|
1432 return ETrue; |
|
1433 } |
|
1434 |
|
1435 TInt count( 0 ); |
|
1436 for ( TUint i( 0 ); i < aSsidLength; ++i ) |
|
1437 { |
|
1438 count |= aSsid[i]; // in hidden networks characters are: 0x00 |
|
1439 } |
|
1440 |
|
1441 LOG_WRITEF( "result: %d", !count ); |
|
1442 |
|
1443 return !count; |
|
1444 } |
|
1445 |
|
1446 |
|
1447 // --------------------------------------------------------------------------- |
|
1448 // CWsfWlanScanner::RefreshSignalStrength |
|
1449 // --------------------------------------------------------------------------- |
|
1450 // |
|
1451 void CWsfWlanScanner::RefreshSignalStrength( TWsfWlanInfo& aWlanInfo ) |
|
1452 { |
|
1453 LOG_ENTERFN( "CWsfWlanScanner::RefreshSignalStrength" ); |
|
1454 |
|
1455 TInt rxLevel = iScanInfo->RXLevel(); |
|
1456 |
|
1457 LOG_WRITEF( "rxLevel = %d", rxLevel ); |
|
1458 |
|
1459 // yes, it is < and not >, because smaller value means stronger signal |
|
1460 |
|
1461 if ( rxLevel < aWlanInfo.iStrengthLevel ) |
|
1462 { |
|
1463 LOG_WRITEF( "updating %d to %d", aWlanInfo.iStrengthLevel, rxLevel ); |
|
1464 aWlanInfo.iStrengthLevel = rxLevel; |
|
1465 } |
|
1466 } |
|
1467 |
|
1468 |
|
1469 // --------------------------------------------------------------------------- |
|
1470 // CWsfWlanScanner::RefreshNetworkMode |
|
1471 // --------------------------------------------------------------------------- |
|
1472 // |
|
1473 void CWsfWlanScanner::RefreshNetworkMode( TWsfWlanInfo& aWlanInfo ) |
|
1474 { |
|
1475 LOG_ENTERFN( "CWsfWlanScanner::RefreshNetworkMode" ); |
|
1476 |
|
1477 aWlanInfo.iNetMode = ( iScanInfo->Capability() & |
|
1478 E802Dot11CapabilityEssMask ) ? |
|
1479 EInfra : EAdhoc ; |
|
1480 |
|
1481 LOG_WRITEF( "netmode = %d", TInt( aWlanInfo.iNetMode ) ); |
|
1482 } |
|
1483 |
|
1484 |
|
1485 // --------------------------------------------------------------------------- |
|
1486 // CWsfWlanScanner::RefreshSecurityMode |
|
1487 // --------------------------------------------------------------------------- |
|
1488 // |
|
1489 void CWsfWlanScanner::RefreshSecurityMode( TWsfWlanInfo& aWlanInfo ) |
|
1490 { |
|
1491 LOG_ENTERFN( "CWsfWlanScanner::RefreshSecurityMode" ); |
|
1492 |
|
1493 TWlanConnectionExtentedSecurityMode extSecMode = iScanInfo->ExtendedSecurityMode(); |
|
1494 |
|
1495 switch ( extSecMode ) |
|
1496 { |
|
1497 case EWlanConnectionExtentedSecurityModeWepOpen: |
|
1498 case EWlanConnectionExtentedSecurityModeWepShared: |
|
1499 { |
|
1500 aWlanInfo.iSecurityMode = EWlanSecModeWep; |
|
1501 break; |
|
1502 } |
|
1503 |
|
1504 case EWlanConnectionExtentedSecurityMode802d1x: |
|
1505 { |
|
1506 aWlanInfo.iSecurityMode = EWlanSecMode802_1x; |
|
1507 break; |
|
1508 } |
|
1509 |
|
1510 case EWlanConnectionExtentedSecurityModeWpa: |
|
1511 case EWlanConnectionExtentedSecurityModeWpa2: |
|
1512 { |
|
1513 aWlanInfo.iSecurityMode = EWlanSecModeWpa; |
|
1514 break; |
|
1515 } |
|
1516 |
|
1517 case EWlanConnectionExtentedSecurityModeWpaPsk: |
|
1518 case EWlanConnectionExtentedSecurityModeWpa2Psk: |
|
1519 { |
|
1520 aWlanInfo.iSecurityMode = EWlanSecModeWpa; |
|
1521 break; |
|
1522 } |
|
1523 |
|
1524 case EWlanConnectionExtentedSecurityModeWapi: |
|
1525 case EWlanConnectionExtentedSecurityModeWapiPsk: |
|
1526 { |
|
1527 aWlanInfo.iSecurityMode = EWlanSecModeWAPI; |
|
1528 break; |
|
1529 } |
|
1530 |
|
1531 case EWlanConnectionExtentedSecurityModeOpen: |
|
1532 default: |
|
1533 { |
|
1534 aWlanInfo.iSecurityMode = EWlanSecModeOpen; |
|
1535 } |
|
1536 } |
|
1537 |
|
1538 aWlanInfo.SetUsesPreSharedKey( |
|
1539 extSecMode == EWlanConnectionExtentedSecurityModeWpa2Psk || |
|
1540 extSecMode == EWlanConnectionExtentedSecurityModeWpaPsk ); |
|
1541 |
|
1542 LOG_WRITEF( "security mode %d (PSK: %d)", |
|
1543 (TInt)aWlanInfo.iSecurityMode, |
|
1544 (TInt)aWlanInfo.UsesPreSharedKey() ); |
|
1545 } |
|
1546 |
|
1547 |
|
1548 // --------------------------------------------------------------------------- |
|
1549 // CWsfWlanScanner::RefreshMaxRate |
|
1550 // --------------------------------------------------------------------------- |
|
1551 // |
|
1552 void CWsfWlanScanner::RefreshMaxRate( TWsfWlanInfo& aWlanInfo ) |
|
1553 { |
|
1554 LOG_ENTERFN( "CWsfWlanScanner::RefreshMaxRate" ); |
|
1555 |
|
1556 TUint8 ieLen( 0 ); |
|
1557 const TUint8* ieData; |
|
1558 TUint8 dataRates[KMaxNumberOfRates]; |
|
1559 TUint8 maxDataRate( aWlanInfo.iTransferRate * 2 ); |
|
1560 |
|
1561 Mem::FillZ( &dataRates[0], sizeof( dataRates ) ); |
|
1562 |
|
1563 // Supported Rates |
|
1564 iScanInfo->InformationElement( E802Dot11SupportedRatesIE, ieLen, &ieData ); |
|
1565 |
|
1566 Mem::Copy( dataRates, ieData, ieLen ); |
|
1567 |
|
1568 for ( TInt a = 0; a < ieLen; a++ ) |
|
1569 { |
|
1570 // ignore the highest bit |
|
1571 dataRates[a] &= 0x7f; |
|
1572 if ( maxDataRate < dataRates[a] ) |
|
1573 { |
|
1574 maxDataRate = dataRates[a]; |
|
1575 } |
|
1576 } |
|
1577 |
|
1578 // Extended Supported Rates |
|
1579 Mem::FillZ( &dataRates[0], sizeof( dataRates ) ); |
|
1580 |
|
1581 iScanInfo->InformationElement( E802Dot11ExtendedRatesIE, ieLen, &ieData ); |
|
1582 |
|
1583 Mem::Copy( dataRates, ieData, ieLen ); |
|
1584 |
|
1585 if ( ieData ) |
|
1586 { |
|
1587 for ( TInt a = 0; a < ieLen; a++ ) |
|
1588 { |
|
1589 dataRates[a] &= 0x7f; |
|
1590 if ( maxDataRate < dataRates[a] ) |
|
1591 { |
|
1592 maxDataRate = dataRates[a]; |
|
1593 } |
|
1594 } |
|
1595 } |
|
1596 aWlanInfo.iTransferRate = maxDataRate / 2; |
|
1597 LOG_WRITEF( "maxRate = %d", aWlanInfo.iTransferRate ); |
|
1598 } |
|
1599 |
|
1600 |
|
1601 // --------------------------------------------------------------------------- |
|
1602 // CWsfWlanScanner::ConnectionEstablishedL |
|
1603 // --------------------------------------------------------------------------- |
|
1604 // |
|
1605 void CWsfWlanScanner::ConnectionEstablishedL( const TDesC& aConnectionName ) |
|
1606 { |
|
1607 LOG_ENTERFN( "CWsfWlanScanner::ConnectionEstablishedL" ); |
|
1608 LOG_WRITEF( "aConnectionName: [%S]", &aConnectionName ); |
|
1609 |
|
1610 HBufC* temp = aConnectionName.AllocL(); |
|
1611 if ( iActiveConnectionName ) |
|
1612 { |
|
1613 delete iActiveConnectionName; |
|
1614 iActiveConnectionName = NULL; |
|
1615 } |
|
1616 iActiveConnectionName = temp; |
|
1617 } |
|
1618 |
|
1619 |
|
1620 // --------------------------------------------------------------------------- |
|
1621 // CWsfWlanScanner::ConnectionLostL |
|
1622 // --------------------------------------------------------------------------- |
|
1623 // |
|
1624 void CWsfWlanScanner::ConnectionLostL() |
|
1625 { |
|
1626 LOG_ENTERFN( "CWsfWlanScanner::ConnectionLostL" ); |
|
1627 if ( iActiveConnectionName ) |
|
1628 { |
|
1629 delete iActiveConnectionName; |
|
1630 iActiveConnectionName = NULL; |
|
1631 } |
|
1632 } |
|
1633 |
|
1634 |
|
1635 // --------------------------------------------------------------------------- |
|
1636 // CWsfWlanScanner::ConnectingFailedL |
|
1637 // --------------------------------------------------------------------------- |
|
1638 // |
|
1639 void CWsfWlanScanner::ConnectingFailedL( TInt /*aError*/ ) |
|
1640 { |
|
1641 // no implementation required |
|
1642 } |
|
1643 |
|
1644 |
|
1645 // --------------------------------------------------------------------------- |
|
1646 // CWsfWlanScanner::ConnectedIapReleasedL |
|
1647 // --------------------------------------------------------------------------- |
|
1648 // |
|
1649 void CWsfWlanScanner::ConnectedIapReleasedL() |
|
1650 { |
|
1651 // no implementation required |
|
1652 } |
|
1653 |
|
1654 |
|
1655 // --------------------------------------------------------------------------- |
|
1656 // CWsfWlanScanner::ScanResults |
|
1657 // --------------------------------------------------------------------------- |
|
1658 // |
|
1659 HBufC8* CWsfWlanScanner::ScanResults() |
|
1660 { |
|
1661 return iScanResults; |
|
1662 } |
|
1663 |
|
1664 |
|
1665 // --------------------------------------------------------------------------- |
|
1666 // CWsfWlanScanner::SetConnectionDetailProvider |
|
1667 // --------------------------------------------------------------------------- |
|
1668 // |
|
1669 void CWsfWlanScanner::SetConnectionDetailProvider( |
|
1670 MWsfWlanConnectionDetailsProvider& aProvider ) |
|
1671 { |
|
1672 iConnectionDetailsProvider = &aProvider; |
|
1673 } |
|
1674 |
|
1675 |
|
1676 // --------------------------------------------------------------------------- |
|
1677 // CWsfWlanScanner::WlanScanIntervalChangedL |
|
1678 // --------------------------------------------------------------------------- |
|
1679 // |
|
1680 void CWsfWlanScanner::WlanScanIntervalChangedL( TUint aNewScanInterval, |
|
1681 TBool aShowAvailability ) |
|
1682 { |
|
1683 LOG_ENTERFN( "CWsfWlanScanner::WlanScanIntervalChangedL" ); |
|
1684 LOG_WRITEF( "bgScanInterval = %d sec", aNewScanInterval ); |
|
1685 LOG_WRITEF( "showAvailability = %d", aShowAvailability ); |
|
1686 iScanningInterval = aNewScanInterval * KMicrosecPerSecond; |
|
1687 |
|
1688 if ( iShowAvailability != aShowAvailability ) |
|
1689 { |
|
1690 // background WLAN scanning status changed |
|
1691 iShowAvailability = aShowAvailability; |
|
1692 |
|
1693 if ( iShowAvailability ) |
|
1694 { |
|
1695 // bgscan is now enabled |
|
1696 // no reissuing, we rely on the WLAN engine callbacks |
|
1697 // from now on |
|
1698 LOG_WRITE( "background scan enabled" ); |
|
1699 |
|
1700 if ( iScanState == EIdle && IsActive() ) |
|
1701 { |
|
1702 // reset the timer only if we are not in the middle |
|
1703 // of another scanning |
|
1704 iTimer.Cancel(); |
|
1705 } |
|
1706 } |
|
1707 else |
|
1708 { |
|
1709 // bgscan is now disabled |
|
1710 // reset the timer with the new interval |
|
1711 LOG_WRITE( "background scan disabled" ); |
|
1712 |
|
1713 if ( iScanState == EIdle ) |
|
1714 { |
|
1715 LOG_WRITE( "reissuing timer request" ); |
|
1716 // reset the timer only if we are not in the middle |
|
1717 // of another scanning |
|
1718 // otherwise RunL will take care of the timer |
|
1719 // doCancel resets timer |
|
1720 if ( IsActive() ) |
|
1721 { |
|
1722 Cancel(); |
|
1723 } |
|
1724 iTimer.After( iStatus, TTimeIntervalMicroSeconds32( |
|
1725 iScanningInterval ) ); |
|
1726 SetActive(); |
|
1727 } |
|
1728 } |
|
1729 } |
|
1730 else if ( !iShowAvailability ) |
|
1731 { |
|
1732 // only the scan interval has changed |
|
1733 LOG_WRITE( "scan interval changed" ); |
|
1734 if ( iScanState == EIdle && IsActive() ) |
|
1735 { |
|
1736 // reset the timer only if we are not in the middle of |
|
1737 // another scanning |
|
1738 // doCancel resets timer |
|
1739 LOG_WRITE( "reissuing timer request" ); |
|
1740 Cancel(); |
|
1741 iTimer.After( iStatus, TTimeIntervalMicroSeconds32( |
|
1742 iScanningInterval ) ); |
|
1743 SetActive(); |
|
1744 } |
|
1745 } |
|
1746 } |
|
1747 |
|
1748 // End of file |
|
1749 |