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