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 CWsfWlanIapWizard
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// EXTERNAL INCLUDES
|
|
21 |
#include <e32std.h>
|
|
22 |
#include <utf.h>
|
|
23 |
#include <wlanmgmtcommon.h>
|
|
24 |
#include <StringLoader.h>
|
|
25 |
#include <cmpluginwlandef.h>
|
|
26 |
#include <cmsettingsui.h>
|
|
27 |
#include <ConnectionUiUtilities.h>
|
|
28 |
#include <data_caging_path_literals.hrh>
|
|
29 |
#include <bautils.h>
|
|
30 |
#include <AknQueryDialog.h>
|
|
31 |
#include <aknnotewrappers.h>
|
|
32 |
#include <wsfapwizard.rsg>
|
|
33 |
|
|
34 |
// CLASS HEADER
|
|
35 |
#include "wsfwlaniapwizard.h"
|
|
36 |
|
|
37 |
// INTERNAL INCLUDES
|
|
38 |
#include "wsfwlaniapcreator.h"
|
|
39 |
#include "wsfwlanssiddiscovery.h"
|
|
40 |
#include "wsflogger.h"
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
using namespace CMManager;
|
|
45 |
|
|
46 |
|
|
47 |
/**
|
|
48 |
* ROM folder
|
|
49 |
*/
|
|
50 |
_LIT( KDriveZ, "z:" );
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Resource file name
|
|
54 |
*/
|
|
55 |
_LIT( KResourceFileName, "wsfapwizard.rsc" );
|
|
56 |
|
|
57 |
/**
|
|
58 |
* the longest possible key is the 64 character long hex WPA key
|
|
59 |
*/
|
|
60 |
static const TInt KMaxSecureKeyLength = 64;
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
#ifdef _DEBUG
|
|
65 |
_LIT( KApWizardPanic, "wsfapwizard" );
|
|
66 |
#define __ASSERTD( v ) __ASSERT_DEBUG( (v), \
|
|
67 |
User::Panic( KApWizardPanic, 0 ) )
|
|
68 |
#else
|
|
69 |
#define __ASSERTD( v )
|
|
70 |
#endif
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
// ----------------------------------------------------------------------------
|
|
75 |
// CWsfWlanIapWizard::NewL
|
|
76 |
// ----------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
EXPORT_C CWsfWlanIapWizard* CWsfWlanIapWizard::NewL()
|
|
79 |
{
|
|
80 |
CWsfWlanIapWizard* thisPtr = NewLC();
|
|
81 |
CleanupStack::Pop( thisPtr );
|
|
82 |
return thisPtr;
|
|
83 |
}
|
|
84 |
|
|
85 |
|
|
86 |
// ----------------------------------------------------------------------------
|
|
87 |
// CWsfWlanIapWizard::NewLC
|
|
88 |
// ----------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
EXPORT_C CWsfWlanIapWizard* CWsfWlanIapWizard::NewLC()
|
|
91 |
{
|
|
92 |
CWsfWlanIapWizard* thisPtr = new (ELeave) CWsfWlanIapWizard();
|
|
93 |
CleanupStack::PushL( thisPtr );
|
|
94 |
thisPtr->ConstructL();
|
|
95 |
return thisPtr;
|
|
96 |
}
|
|
97 |
|
|
98 |
|
|
99 |
// ----------------------------------------------------------------------------
|
|
100 |
// CWsfWlanIapWizard::CWsfWlanIapWizard
|
|
101 |
// ----------------------------------------------------------------------------
|
|
102 |
//
|
|
103 |
CWsfWlanIapWizard::CWsfWlanIapWizard():
|
|
104 |
iEnv( *CEikonEnv::Static() ),
|
|
105 |
iResourceFileOffset( -1 ),
|
|
106 |
iWlanInfo( NULL )
|
|
107 |
{
|
|
108 |
}
|
|
109 |
|
|
110 |
|
|
111 |
// ----------------------------------------------------------------------------
|
|
112 |
// CWsfWlanIapWizard::ConstructL
|
|
113 |
// ----------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
void CWsfWlanIapWizard::ConstructL()
|
|
116 |
{
|
|
117 |
iResourceFileOffset = InitResourcesL( iEnv );
|
|
118 |
|
|
119 |
iCreator = CWsfWlanIapCreator::NewL();
|
|
120 |
iSsidDiscovery = CWsfWlanSsidDiscovery::NewL();
|
|
121 |
}
|
|
122 |
|
|
123 |
|
|
124 |
// ----------------------------------------------------------------------------
|
|
125 |
// CWsfWlanIapWizard::~CWsfWlanIapWizard
|
|
126 |
// ----------------------------------------------------------------------------
|
|
127 |
//
|
|
128 |
EXPORT_C CWsfWlanIapWizard::~CWsfWlanIapWizard()
|
|
129 |
{
|
|
130 |
delete iCreator;
|
|
131 |
|
|
132 |
ReleaseResources( iEnv, iResourceFileOffset );
|
|
133 |
|
|
134 |
delete iUsedPassword;
|
|
135 |
delete iWaitDialog;
|
|
136 |
delete iSsidDiscovery;
|
|
137 |
}
|
|
138 |
|
|
139 |
|
|
140 |
// ---------------------------------------------------------------------------
|
|
141 |
// CWsfWlanIapWizard::InitResourcesL
|
|
142 |
// ---------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
TInt CWsfWlanIapWizard::InitResourcesL( CEikonEnv& aEnv )
|
|
145 |
{
|
|
146 |
// The resource has to be loaded manually since it is not an application.
|
|
147 |
TFileName resourceFileName;
|
|
148 |
|
|
149 |
resourceFileName.Append( KDriveZ );
|
|
150 |
resourceFileName.Append( KDC_RESOURCE_FILES_DIR );
|
|
151 |
resourceFileName.Append( KResourceFileName );
|
|
152 |
|
|
153 |
BaflUtils::NearestLanguageFile( aEnv.FsSession(), resourceFileName );
|
|
154 |
|
|
155 |
return aEnv.AddResourceFileL( resourceFileName );
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
// ---------------------------------------------------------------------------
|
|
160 |
// CWsfWlanIapWizard::ReleaseResources
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
void CWsfWlanIapWizard::ReleaseResources( CEikonEnv& aEnv, TInt aResOffset )
|
|
164 |
{
|
|
165 |
if ( aResOffset != -1 )
|
|
166 |
{
|
|
167 |
aEnv.DeleteResourceFile( aResOffset );
|
|
168 |
}
|
|
169 |
}
|
|
170 |
|
|
171 |
|
|
172 |
// ----------------------------------------------------------------------------
|
|
173 |
// CWsfWlanIapWizard::LaunchWizardL
|
|
174 |
// ----------------------------------------------------------------------------
|
|
175 |
//
|
|
176 |
EXPORT_C TBool CWsfWlanIapWizard::LaunchWizardL( TWsfWlanInfo& aWlanInfo,
|
|
177 |
TBool aDefineNewAccessPoint )
|
|
178 |
{
|
|
179 |
LOG_ENTERFN( "CWsfWlanIapWizard::LaunchWizardL" );
|
|
180 |
LOG_WRITEF( "defineAp = %d", aDefineNewAccessPoint );
|
|
181 |
|
|
182 |
if ( aDefineNewAccessPoint &&
|
|
183 |
!( aWlanInfo.Hidden() && !aWlanInfo.Known() ) )
|
|
184 |
{
|
|
185 |
HBufC* ssid16 = aWlanInfo.GetSsidAsUnicodeLC();
|
|
186 |
LOG_WRITEF( "ssid = %S", ssid16 );
|
|
187 |
HBufC* infoText = StringLoader::LoadLC(
|
|
188 |
R_QTN_CMON_QUEST_CREATE_WLAN_IAP,
|
|
189 |
*ssid16 );
|
|
190 |
|
|
191 |
CAknQueryDialog* confirmQuery = CAknQueryDialog::NewL();
|
|
192 |
TBool result = confirmQuery->ExecuteLD(
|
|
193 |
R_QTN_WIZARD_CONFIRMATION_QUERY,
|
|
194 |
*infoText );
|
|
195 |
|
|
196 |
CleanupStack::PopAndDestroy( infoText );
|
|
197 |
CleanupStack::PopAndDestroy( ssid16 );
|
|
198 |
|
|
199 |
if ( !result )
|
|
200 |
{
|
|
201 |
return result;
|
|
202 |
}
|
|
203 |
}
|
|
204 |
|
|
205 |
iWlanInfo = &aWlanInfo;
|
|
206 |
iDefineNewAccessPoint = aDefineNewAccessPoint;
|
|
207 |
|
|
208 |
TRAPD( err, AskNetworkDetailsL() );
|
|
209 |
if ( err )
|
|
210 |
{
|
|
211 |
// We are here also if selection of
|
|
212 |
// the hidden network AP leaves or is
|
|
213 |
// cancelled by the end-user
|
|
214 |
LOG_WRITE( "AskNetworkDetailsL failed" );
|
|
215 |
}
|
|
216 |
|
|
217 |
return ( !err );
|
|
218 |
}
|
|
219 |
|
|
220 |
|
|
221 |
// ----------------------------------------------------------------------------
|
|
222 |
// CWsfWlanIapWizard::CreateAccessPointL
|
|
223 |
// ----------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
EXPORT_C TBool CWsfWlanIapWizard::CreateAccessPointL()
|
|
226 |
{
|
|
227 |
LOG_ENTERFN( "CWsfWlanIapWizard::CreateAccessPointL" );
|
|
228 |
__ASSERTD( iWlanInfo );
|
|
229 |
|
|
230 |
|
|
231 |
if ( iWlanInfo->iIapId != 0 )
|
|
232 |
{
|
|
233 |
// Access Point already exists
|
|
234 |
User::Leave( KErrAlreadyExists );
|
|
235 |
}
|
|
236 |
|
|
237 |
|
|
238 |
// otherwise new Access Point will be created
|
|
239 |
if ( !iWlanInfo->iSsid.Length() )
|
|
240 |
{
|
|
241 |
User::Leave( KErrGeneral );
|
|
242 |
}
|
|
243 |
|
|
244 |
TPtrC sharedKey = iUsedPassword ? *iUsedPassword : KNullDesC();
|
|
245 |
|
|
246 |
TUint32 destId( 0 );
|
|
247 |
|
|
248 |
if ( iDefineNewAccessPoint )
|
|
249 |
{
|
|
250 |
// define access point was selected, select destination query follows
|
|
251 |
LOG_WRITE( "defineAp = ETrue, opening select destination dialog..." );
|
|
252 |
|
|
253 |
CCmSettingsUi* settings = CCmSettingsUi::NewL();
|
|
254 |
CleanupStack::PushL( settings );
|
|
255 |
|
|
256 |
TBool result( EFalse );
|
|
257 |
result = settings->SelectDestinationDlgL( destId );
|
|
258 |
|
|
259 |
CleanupStack::PopAndDestroy( settings ); //settings
|
|
260 |
|
|
261 |
if ( !result )
|
|
262 |
{
|
|
263 |
LOG_WRITE( "dialog cancelled" );
|
|
264 |
// cancel was pressed, abort creation
|
|
265 |
return EFalse;
|
|
266 |
}
|
|
267 |
LOG_WRITEF( "target destination = %d", destId );
|
|
268 |
}
|
|
269 |
|
|
270 |
iCreator->SetDefaultDestination( destId );
|
|
271 |
|
|
272 |
iCreator->CreateAccessPointL( *iWlanInfo, sharedKey, iIsHexWep );
|
|
273 |
|
|
274 |
return ETrue;
|
|
275 |
}
|
|
276 |
|
|
277 |
|
|
278 |
// ----------------------------------------------------------------------------
|
|
279 |
// CWsfWlanIapWizard::QueryTextL
|
|
280 |
// ----------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
TInt CWsfWlanIapWizard::QueryTextL( TInt aQueryStringResource,
|
|
283 |
TDes& aVariable,
|
|
284 |
const TInt &aMaxLength )
|
|
285 |
{
|
|
286 |
LOG_ENTERFN( "CWsfWlanIapWizard::QueryTextL" );
|
|
287 |
HBufC* queryText = StringLoader::LoadLC( aQueryStringResource );
|
|
288 |
CAknTextQueryDialog* textQuery = CAknTextQueryDialog::NewL( aVariable );
|
|
289 |
CleanupStack::PushL( textQuery );
|
|
290 |
textQuery->SetPromptL( *queryText );
|
|
291 |
textQuery->SetMaxLength( aMaxLength );
|
|
292 |
CleanupStack::Pop( textQuery );
|
|
293 |
TInt result = textQuery->ExecuteLD( R_QTN_WIZARD_QUERY_GENERAL );
|
|
294 |
CleanupStack::PopAndDestroy( queryText );
|
|
295 |
return result;
|
|
296 |
}
|
|
297 |
|
|
298 |
|
|
299 |
// ----------------------------------------------------------------------------
|
|
300 |
// CWsfWlanIapWizard::QuerySecureKeyL
|
|
301 |
// ----------------------------------------------------------------------------
|
|
302 |
//
|
|
303 |
TBool CWsfWlanIapWizard::QuerySecureKeyL()
|
|
304 |
{
|
|
305 |
LOG_ENTERFN( "CWsfWlanIapWizard::QuerySecureKeyL" );
|
|
306 |
TBool okPressed( ETrue );
|
|
307 |
|
|
308 |
switch ( iWlanInfo->iSecurityMode )
|
|
309 |
{
|
|
310 |
case EWlanSecModeWep:
|
|
311 |
{
|
|
312 |
LOG_WRITE( "secmode WEP" );
|
|
313 |
CConnectionUiUtilities* connUiUtils =
|
|
314 |
CConnectionUiUtilities::NewL();
|
|
315 |
CleanupStack::PushL( connUiUtils );
|
|
316 |
iUsedPassword = HBufC::NewL( KMaxSecureKeyLength );
|
|
317 |
TPtr ptr( iUsedPassword->Des() );
|
|
318 |
okPressed = connUiUtils->EasyWepDlg( &ptr, iIsHexWep );
|
|
319 |
CleanupStack::PopAndDestroy( connUiUtils );
|
|
320 |
break;
|
|
321 |
}
|
|
322 |
|
|
323 |
case EWlanSecModeWpa:
|
|
324 |
case EWlanSecModeWpa2:
|
|
325 |
case EWlanSecMode802_1x:
|
|
326 |
{
|
|
327 |
if ( iWlanInfo->UsesPreSharedKey() )
|
|
328 |
{
|
|
329 |
// WPA-PSK
|
|
330 |
LOG_WRITE( "secmode WPA-PSK" );
|
|
331 |
|
|
332 |
CConnectionUiUtilities* connUiUtils =
|
|
333 |
CConnectionUiUtilities::NewL();
|
|
334 |
CleanupStack::PushL( connUiUtils );
|
|
335 |
iUsedPassword = HBufC::NewL( KMaxSecureKeyLength );
|
|
336 |
TPtr ptr( iUsedPassword->Des() );
|
|
337 |
okPressed = connUiUtils->EasyWpaDlg( &ptr );
|
|
338 |
CleanupStack::PopAndDestroy( connUiUtils );
|
|
339 |
}
|
|
340 |
else
|
|
341 |
{
|
|
342 |
// no key prompt in EAP mode, but the usual note is shown
|
|
343 |
LOG_WRITE( "secmode WPA-EAP" );
|
|
344 |
|
|
345 |
HBufC* eapText = StringLoader::LoadLC(
|
|
346 |
R_QTN_NETW_CONSET_INFO_EAP_SETTINGS_DEFAULT );
|
|
347 |
CAknInformationNote* informationNote =
|
|
348 |
new (ELeave) CAknInformationNote( ETrue );
|
|
349 |
informationNote->ExecuteLD( *eapText );
|
|
350 |
|
|
351 |
CleanupStack::PopAndDestroy( eapText );
|
|
352 |
}
|
|
353 |
|
|
354 |
break;
|
|
355 |
}
|
|
356 |
|
|
357 |
case EWlanSecModeOpen:
|
|
358 |
default:
|
|
359 |
{
|
|
360 |
LOG_WRITE( "secmode Open" );
|
|
361 |
|
|
362 |
delete iUsedPassword;
|
|
363 |
iUsedPassword = NULL;
|
|
364 |
}
|
|
365 |
}
|
|
366 |
|
|
367 |
return okPressed;
|
|
368 |
}
|
|
369 |
|
|
370 |
|
|
371 |
// ----------------------------------------------------------------------------
|
|
372 |
// CWsfWlanIapWizard::DismissWaitNote
|
|
373 |
// ----------------------------------------------------------------------------
|
|
374 |
//
|
|
375 |
void CWsfWlanIapWizard::DismissWaitNote( TAny* aPtr )
|
|
376 |
{
|
|
377 |
LOG_ENTERFN( "CWsfWlanIapWizard::DismissWaitNote" );
|
|
378 |
CWsfWlanIapWizard* self = static_cast<CWsfWlanIapWizard*>( aPtr );
|
|
379 |
|
|
380 |
if ( self->iWaitDialog )
|
|
381 |
{
|
|
382 |
// close waitnote
|
|
383 |
LOG_WRITE( "closing waitnote..." );
|
|
384 |
TRAP_IGNORE( self->iWaitDialog->ProcessFinishedL() );
|
|
385 |
|
|
386 |
// cleanup
|
|
387 |
delete self->iWaitDialog;
|
|
388 |
self->iWaitDialog = NULL;
|
|
389 |
}
|
|
390 |
}
|
|
391 |
|
|
392 |
|
|
393 |
// ----------------------------------------------------------------------------
|
|
394 |
// CWsfWlanIapWizard::AskNetworkDetailsL
|
|
395 |
// ----------------------------------------------------------------------------
|
|
396 |
//
|
|
397 |
void CWsfWlanIapWizard::AskNetworkDetailsL()
|
|
398 |
{
|
|
399 |
LOG_ENTERFN( "CWsfWlanIapWizard::AskNetworkDetailsL" );
|
|
400 |
|
|
401 |
|
|
402 |
// check the wlan info, and make proper questions....
|
|
403 |
if ( iWlanInfo->Hidden() && !iWlanInfo->Known() )
|
|
404 |
{
|
|
405 |
LOG_WRITE( "unlisted network" );
|
|
406 |
|
|
407 |
// query network SSID
|
|
408 |
HBufC* ssid16 = AskSsidL();
|
|
409 |
LOG_WRITEF( "SSID: [%S]", ssid16 );
|
|
410 |
|
|
411 |
// update SSID
|
|
412 |
CnvUtfConverter::ConvertFromUnicodeToUtf8( iWlanInfo->iSsid, *ssid16 );
|
|
413 |
delete ssid16;
|
|
414 |
|
|
415 |
// pop up waitnote
|
|
416 |
iWaitDialog = new ( ELeave ) CAknWaitDialog(
|
|
417 |
reinterpret_cast<CEikDialog**>( &iWaitDialog ), ETrue );
|
|
418 |
iWaitDialog->SetCallback( this );
|
|
419 |
iWaitDialog->ExecuteLD( R_SEARCHING_WLAN_WAIT_NOTE );
|
|
420 |
|
|
421 |
CleanupStack::PushL( TCleanupItem( DismissWaitNote, this ) );
|
|
422 |
|
|
423 |
// start to scan for surrounding WLAN networks
|
|
424 |
TBool foundSsid( EFalse );
|
|
425 |
TBool usePsk( EFalse );
|
|
426 |
TWlanSsid ssid( iWlanInfo->iSsid );
|
|
427 |
|
|
428 |
// make a broadcast scan
|
|
429 |
LOG_WRITE( "broadcast scanning for SSID" );
|
|
430 |
foundSsid = iSsidDiscovery->ScanForSsidL( ssid, ETrue,
|
|
431 |
iWlanInfo->iNetMode,
|
|
432 |
iWlanInfo->iSecurityMode,
|
|
433 |
usePsk );
|
|
434 |
|
|
435 |
// SSID found?
|
|
436 |
if ( !foundSsid )
|
|
437 |
{
|
|
438 |
// must be really hidden, direct scan for SSID
|
|
439 |
LOG_WRITE( "broadcast scan failed, direct scanning for SSID" );
|
|
440 |
foundSsid = iSsidDiscovery->ScanForSsidL( ssid, EFalse,
|
|
441 |
iWlanInfo->iNetMode,
|
|
442 |
iWlanInfo->iSecurityMode,
|
|
443 |
usePsk );
|
|
444 |
|
|
445 |
// it can only be found as hidden
|
|
446 |
iWlanInfo->iVisibility = EFalse;
|
|
447 |
|
|
448 |
CleanupStack::PopAndDestroy( 1 ); // DismissWaitNote
|
|
449 |
|
|
450 |
if ( !foundSsid )
|
|
451 |
{
|
|
452 |
LOG_WRITE( "direct scan failed, entering fully manual mode" );
|
|
453 |
|
|
454 |
// pop up discreet popup: No WLANs found
|
|
455 |
CConnectionUiUtilities* connUiUtils = CConnectionUiUtilities::NewL();
|
|
456 |
connUiUtils->NoWLANNetworksAvailableNote();
|
|
457 |
delete connUiUtils;
|
|
458 |
|
|
459 |
// now entering fully manual mode
|
|
460 |
|
|
461 |
// query network mode
|
|
462 |
TInt mode( 0 );
|
|
463 |
CAknListQueryDialog* listQuery =
|
|
464 |
new (ELeave) CAknListQueryDialog( &mode );
|
|
465 |
listQuery->PrepareLC( R_QTN_WIZARD_NETWORK_MODE );
|
|
466 |
TInt retval = listQuery->RunLD();
|
|
467 |
if ( !retval )
|
|
468 |
{
|
|
469 |
User::Leave( KErrCancel );
|
|
470 |
}
|
|
471 |
|
|
472 |
const TInt KModeInfraPublic = 0;
|
|
473 |
const TInt KModeInfraHidden = 1;
|
|
474 |
const TInt KModeAdhocPublic = 2;
|
|
475 |
|
|
476 |
TBool adhoc( EFalse );
|
|
477 |
|
|
478 |
switch ( mode )
|
|
479 |
{
|
|
480 |
case KModeInfraPublic:
|
|
481 |
{
|
|
482 |
LOG_WRITE( "infra public mode" );
|
|
483 |
iWlanInfo->iNetMode = EInfra;
|
|
484 |
iWlanInfo->iVisibility = ETrue;
|
|
485 |
break;
|
|
486 |
}
|
|
487 |
|
|
488 |
case KModeInfraHidden:
|
|
489 |
{
|
|
490 |
LOG_WRITE( "infra hidden mode" );
|
|
491 |
iWlanInfo->iNetMode = EInfra;
|
|
492 |
iWlanInfo->iVisibility = EFalse;
|
|
493 |
break;
|
|
494 |
}
|
|
495 |
|
|
496 |
case KModeAdhocPublic:
|
|
497 |
{
|
|
498 |
LOG_WRITE( "adhoc public mode" );
|
|
499 |
adhoc = ETrue;
|
|
500 |
iWlanInfo->iNetMode = EAdhoc;
|
|
501 |
iWlanInfo->iVisibility = ETrue;
|
|
502 |
break;
|
|
503 |
}
|
|
504 |
}
|
|
505 |
|
|
506 |
|
|
507 |
// query security mode
|
|
508 |
const TInt KSecModeOpen = 0;
|
|
509 |
const TInt KSecModeWep = 1;
|
|
510 |
const TInt KSecMode8021x = 2;
|
|
511 |
const TInt KSecModeWpa = 3;
|
|
512 |
|
|
513 |
mode = KSecModeOpen;
|
|
514 |
listQuery = new (ELeave) CAknListQueryDialog( &mode );
|
|
515 |
|
|
516 |
if ( adhoc )
|
|
517 |
{
|
|
518 |
listQuery->PrepareLC( R_QTN_WIZARD_AUTH_MODE_AD_HOC );
|
|
519 |
}
|
|
520 |
else
|
|
521 |
{
|
|
522 |
listQuery->PrepareLC( R_QTN_WIZARD_AUTH_MODE );
|
|
523 |
}
|
|
524 |
|
|
525 |
retval = listQuery->RunLD();
|
|
526 |
|
|
527 |
if ( !retval )
|
|
528 |
{
|
|
529 |
User::Leave( KErrCancel );
|
|
530 |
}
|
|
531 |
|
|
532 |
// map the security mode
|
|
533 |
|
|
534 |
switch ( mode )
|
|
535 |
{
|
|
536 |
case KSecModeWep:
|
|
537 |
{
|
|
538 |
LOG_WRITE( "security: WEP" );
|
|
539 |
iWlanInfo->iSecurityMode = EWlanSecModeWep;
|
|
540 |
break;
|
|
541 |
}
|
|
542 |
case KSecMode8021x:
|
|
543 |
{
|
|
544 |
LOG_WRITE( "security: 802.1x" );
|
|
545 |
iWlanInfo->iSecurityMode = EWlanSecMode802_1x;
|
|
546 |
break;
|
|
547 |
}
|
|
548 |
case KSecModeWpa:
|
|
549 |
{
|
|
550 |
LOG_WRITE( "security: WPA" );
|
|
551 |
iWlanInfo->iSecurityMode = EWlanSecModeWpa;
|
|
552 |
break;
|
|
553 |
}
|
|
554 |
|
|
555 |
case KSecModeOpen:
|
|
556 |
default:
|
|
557 |
{
|
|
558 |
LOG_WRITE( "security: Open" );
|
|
559 |
iWlanInfo->iSecurityMode = EWlanSecModeOpen;
|
|
560 |
}
|
|
561 |
}
|
|
562 |
|
|
563 |
// if WPA, query WPA mode
|
|
564 |
if ( iWlanInfo->iSecurityMode == EWlanSecModeWpa )
|
|
565 |
{
|
|
566 |
const TInt KWpaModeEap = 0;
|
|
567 |
const TInt KWpaModePsk = 1;
|
|
568 |
|
|
569 |
mode = KWpaModeEap;
|
|
570 |
listQuery = new (ELeave) CAknListQueryDialog( &mode );
|
|
571 |
listQuery->PrepareLC( R_QTN_WIZARD_WPA_MODE );
|
|
572 |
retval = listQuery->RunLD();
|
|
573 |
if ( !retval )
|
|
574 |
{
|
|
575 |
User::Leave( KErrCancel );
|
|
576 |
}
|
|
577 |
|
|
578 |
// 0 - EAP, 1 - PSK
|
|
579 |
|
|
580 |
usePsk = ( mode == KWpaModePsk );
|
|
581 |
if ( usePsk )
|
|
582 |
{
|
|
583 |
LOG_WRITE( "WPA-PSK" );
|
|
584 |
}
|
|
585 |
else
|
|
586 |
{
|
|
587 |
LOG_WRITE( "WPA-EAP" );
|
|
588 |
}
|
|
589 |
}
|
|
590 |
|
|
591 |
} // if !foundssid (direct)
|
|
592 |
|
|
593 |
|
|
594 |
} // if !foundssid (broadcast)
|
|
595 |
else
|
|
596 |
{
|
|
597 |
// it was thought to be hidden but actually it isn't
|
|
598 |
LOG_WRITE( "broadcast scan succeeded, "
|
|
599 |
L"network isn't hidden as it was thought" );
|
|
600 |
LOG_WRITEF( "netmode: %d, secmode: %d, usepsk: %d",
|
|
601 |
iWlanInfo->iNetMode,
|
|
602 |
iWlanInfo->iSecurityMode,
|
|
603 |
usePsk );
|
|
604 |
|
|
605 |
CleanupStack::PopAndDestroy( 1 ); // DismissWaitNote
|
|
606 |
|
|
607 |
// set WLAN to public
|
|
608 |
iWlanInfo->iVisibility = ETrue;
|
|
609 |
}
|
|
610 |
|
|
611 |
// convey PSK settings to iwlaninfo
|
|
612 |
// (netmode and secmode are already updated)
|
|
613 |
iWlanInfo->SetUsesPreSharedKey( usePsk );
|
|
614 |
|
|
615 |
}
|
|
616 |
else
|
|
617 |
{
|
|
618 |
// if NOT hidden
|
|
619 |
LOG_WRITE( "visible network" );
|
|
620 |
LOG_WRITEF( "netmode: %d, secmode: %d, usepsk: %d",
|
|
621 |
iWlanInfo->iNetMode,
|
|
622 |
iWlanInfo->iSecurityMode,
|
|
623 |
iWlanInfo->UsesPreSharedKey() );
|
|
624 |
}
|
|
625 |
|
|
626 |
// query the key and leave if cancelled
|
|
627 |
if ( !QuerySecureKeyL() )
|
|
628 |
{
|
|
629 |
User::Leave( KErrCancel );
|
|
630 |
}
|
|
631 |
|
|
632 |
}
|
|
633 |
|
|
634 |
|
|
635 |
// ----------------------------------------------------------------------------
|
|
636 |
// CWsfWlanIapWizard::AskSsidL
|
|
637 |
// ----------------------------------------------------------------------------
|
|
638 |
//
|
|
639 |
HBufC* CWsfWlanIapWizard::AskSsidL()
|
|
640 |
{
|
|
641 |
LOG_ENTERFN( "CWsfWlanIapWizard::AskSsidL" );
|
|
642 |
|
|
643 |
HBufC* apName = HBufC::NewLC( KWlanMaxSsidLength );
|
|
644 |
TPtr namePtr( apName->Des() );
|
|
645 |
if ( iWlanInfo->iSsid.Length() )
|
|
646 |
{
|
|
647 |
CnvUtfConverter::ConvertToUnicodeFromUtf8( namePtr, iWlanInfo->iSsid );
|
|
648 |
}
|
|
649 |
TInt response = QueryTextL( R_QTN_ENTER_NETWORK_SSID,
|
|
650 |
namePtr,
|
|
651 |
KWlanMaxSsidLength );
|
|
652 |
if ( response != EEikBidOk )
|
|
653 |
{
|
|
654 |
User::Leave( KErrCancel );
|
|
655 |
}
|
|
656 |
|
|
657 |
CleanupStack::Pop( apName );
|
|
658 |
return apName;
|
|
659 |
}
|
|
660 |
|
|
661 |
|
|
662 |
// ----------------------------------------------------------------------------
|
|
663 |
// CWsfWlanIapWizard::DialogDismissedL
|
|
664 |
// ----------------------------------------------------------------------------
|
|
665 |
//
|
|
666 |
void CWsfWlanIapWizard::DialogDismissedL( TInt aButtonId )
|
|
667 |
{
|
|
668 |
LOG_ENTERFN( "CWsfWlanIapWizard::DialogDismissedL" );
|
|
669 |
iWaitDialog = NULL;
|
|
670 |
|
|
671 |
if ( aButtonId == EEikBidCancel )
|
|
672 |
{
|
|
673 |
// dialog was cancelled by the user
|
|
674 |
LOG_WRITE( "dialog was cancelled" );
|
|
675 |
iSsidDiscovery->AbortScanning();
|
|
676 |
}
|
|
677 |
}
|
|
678 |
|
|
679 |
|