|
1 /* |
|
2 * Copyright (c) 2001-2010 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 the License "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 dialog. |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: tr1cfwln#33 % |
|
20 */ |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "WPASecuritySettingsDlg.h" |
|
24 #include "WPASecuritySettingsUiPanic.h" |
|
25 |
|
26 #include "WPASecuritySettingsUI.hrh" |
|
27 |
|
28 #include "WPASecuritySettingsDefs.h" |
|
29 |
|
30 #include <csxhelp/cp.hlp.hrh> |
|
31 #include <hlplch.h> |
|
32 |
|
33 #include <featmgr.h> |
|
34 |
|
35 #include <akntitle.h> |
|
36 #include <aknradiobuttonsettingpage.h> |
|
37 #include <StringLoader.h> |
|
38 #include <aknnotewrappers.h> |
|
39 #include <akntextsettingpage.h> |
|
40 #include <EAPPluginConfigurationIf.h> |
|
41 |
|
42 #include <WPASecuritySettingsUI.rsg> |
|
43 |
|
44 |
|
45 // CONSTANT DECLARATIONS |
|
46 |
|
47 // Number of fields of main view |
|
48 LOCAL_D const TInt KNumOfFieldsMain = 3; |
|
49 |
|
50 // Menu List item format |
|
51 _LIT( KTxtMenuListItemFormat, " \t%S\t\t" ); |
|
52 |
|
53 // Number of spaces and tabs in KTxtMenuListItemFormat string |
|
54 LOCAL_D const TInt KSpaceAndTabsLength = 4; |
|
55 |
|
56 |
|
57 |
|
58 // ================= MEMBER FUNCTIONS ======================= |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // CWPASecuritySettingsDlg::CWPASecuritySettingsDlg |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 CWPASecuritySettingsDlg::CWPASecuritySettingsDlg( TInt& aEventStore, |
|
65 const TUint32 aIapId, |
|
66 CEAPPluginConfigurationIf* aPlugin ) |
|
67 : iEventStore( &aEventStore ), |
|
68 iIapId( aIapId ), |
|
69 iPlugin( aPlugin ) |
|
70 { |
|
71 } |
|
72 |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CWPASecuritySettingsDlg::~CWPASecuritySettingsDlg |
|
76 // --------------------------------------------------------- |
|
77 // |
|
78 CWPASecuritySettingsDlg::~CWPASecuritySettingsDlg() |
|
79 { |
|
80 if ( iTitlePane ) |
|
81 { |
|
82 // set old text back, if we have it... |
|
83 if ( iOldTitleText ) |
|
84 { |
|
85 TRAP_IGNORE( iTitlePane->SetTextL( *iOldTitleText ) ); |
|
86 delete iOldTitleText; |
|
87 } |
|
88 } |
|
89 |
|
90 FeatureManager::UnInitializeLib(); |
|
91 } |
|
92 |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // CWPASecuritySettingsDlg::NewL |
|
96 // --------------------------------------------------------- |
|
97 // |
|
98 CWPASecuritySettingsDlg* CWPASecuritySettingsDlg::NewL( TInt& aEventStore, |
|
99 const TUint32 aIapId, |
|
100 CEAPPluginConfigurationIf* aPlugin ) |
|
101 { |
|
102 CWPASecuritySettingsDlg* secSett = new ( ELeave )CWPASecuritySettingsDlg( |
|
103 aEventStore, aIapId, aPlugin ); |
|
104 return secSett; |
|
105 } |
|
106 |
|
107 |
|
108 // --------------------------------------------------------- |
|
109 // CWPASecuritySettingsDlg::ConstructAndRunLD |
|
110 // --------------------------------------------------------- |
|
111 // |
|
112 TInt CWPASecuritySettingsDlg::ConstructAndRunLD( |
|
113 CWPASecuritySettingsImpl* aSecuritySettings, |
|
114 const TDesC& aTitle ) |
|
115 { |
|
116 CleanupStack::PushL( this ); |
|
117 |
|
118 const TInt Titles_Wpa_Main[KNumOfFieldsMain+2] = |
|
119 { |
|
120 R_WPA_MODE, |
|
121 R_WPA_EAP_CONFIG, |
|
122 R_WPA_MODE_PRESHARED_KEY, |
|
123 R_WPA_TKIP_CIPHER, |
|
124 R_WPA_UNENCRYPTED_CONN |
|
125 }; |
|
126 |
|
127 const TInt Fields_Wpa_Main[KNumOfFieldsMain+2] = |
|
128 { |
|
129 EWpaMode, |
|
130 EWpaEapConfig, |
|
131 EWpaPreSharedKey, |
|
132 EWpaWpa2Only, |
|
133 EWpaUnencryptedConn |
|
134 }; |
|
135 |
|
136 iSecuritySettings = aSecuritySettings; |
|
137 iConnectionName = aTitle; |
|
138 |
|
139 iFieldsMain = ( TWpaMember* ) Fields_Wpa_Main; |
|
140 iTitlesMain = MUTABLE_CAST( TInt*, Titles_Wpa_Main ); |
|
141 |
|
142 if ( !iSecuritySettings->WPAMode() && !iPlugin ) |
|
143 { |
|
144 iSecuritySettings->SetWPAMode( ETrue ); |
|
145 *iEventStore |= CWPASecuritySettings::EModified; |
|
146 } |
|
147 |
|
148 FeatureManager::InitializeLibL(); |
|
149 |
|
150 ConstructL( R_WPA_SECURITY_SETTINGS_MENUBAR ); |
|
151 |
|
152 // ExecuteLD will PushL( this ), so we have to Pop it... |
|
153 CleanupStack::Pop( this ); // this |
|
154 |
|
155 return ExecuteLD( R_WPASETTINGS_DIALOG ); |
|
156 } |
|
157 |
|
158 |
|
159 |
|
160 // --------------------------------------------------------- |
|
161 // CWPASecuritySettingsDlg::OkToExitL |
|
162 // --------------------------------------------------------- |
|
163 // |
|
164 TBool CWPASecuritySettingsDlg::OkToExitL( TInt aButtonId ) |
|
165 { |
|
166 // Translate the button presses into commands for the appui & current |
|
167 // view to handle |
|
168 TBool retval( EFalse ); |
|
169 if ( aButtonId == EAknSoftkeyOptions ) |
|
170 { |
|
171 DisplayMenuL(); |
|
172 } |
|
173 else if ( aButtonId == EEikCmdExit ) // ShutDown requested |
|
174 { |
|
175 *iEventStore |= CWPASecuritySettings::EShutDownReq; |
|
176 retval = ETrue; |
|
177 } |
|
178 else if ( aButtonId == EAknSoftkeyBack || aButtonId == EAknCmdExit ) |
|
179 { |
|
180 if ( iSecuritySettings->WPAMode() ) |
|
181 { |
|
182 if ( iSecuritySettings->IsValid() ) |
|
183 { |
|
184 *iEventStore |= CWPASecuritySettings::EValid; |
|
185 retval = ETrue; |
|
186 } |
|
187 else if ( aButtonId == EAknSoftkeyBack ) |
|
188 { |
|
189 HBufC* stringHolder = StringLoader::LoadL( |
|
190 R_WPA_PRESHARED_KEYDATA_MISSING, iEikonEnv ); |
|
191 CleanupStack::PushL( stringHolder ); |
|
192 |
|
193 CAknQueryDialog *queryDialog = new (ELeave) CAknQueryDialog(); |
|
194 |
|
195 queryDialog->PrepareLC( R_WPA_SEC_SETT_CONF_QUERY ); |
|
196 queryDialog->SetPromptL( stringHolder->Des() ); |
|
197 retval = queryDialog->RunLD(); |
|
198 |
|
199 CleanupStack::PopAndDestroy( stringHolder ); // stringHolder |
|
200 } |
|
201 else |
|
202 { |
|
203 retval = ETrue; |
|
204 } |
|
205 } |
|
206 else |
|
207 { |
|
208 *iEventStore |= CWPASecuritySettings::EValid; |
|
209 retval = ETrue; |
|
210 } |
|
211 |
|
212 if ( aButtonId == EAknCmdExit ) |
|
213 { |
|
214 *iEventStore |= CWPASecuritySettings::EExitReq; |
|
215 } |
|
216 } |
|
217 |
|
218 else if( aButtonId == EWpaSelCmdChange ) |
|
219 { |
|
220 ChangeSettingsL( ETrue ); |
|
221 retval = EFalse; // don't exit the dialog |
|
222 } |
|
223 |
|
224 return retval; |
|
225 } |
|
226 |
|
227 |
|
228 // --------------------------------------------------------- |
|
229 // CWPASecuritySettingsDlg::OfferKeyEventL |
|
230 // --------------------------------------------------------- |
|
231 // |
|
232 TKeyResponse CWPASecuritySettingsDlg::OfferKeyEventL( |
|
233 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
234 { |
|
235 TKeyResponse retval( EKeyWasNotConsumed ); |
|
236 |
|
237 // Only interested in standard key events |
|
238 if ( aType == EEventKey ) |
|
239 { |
|
240 // If a menu is showing offer key events to it. |
|
241 if ( CAknDialog::MenuShowing() ) |
|
242 { |
|
243 retval = CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
244 } |
|
245 else |
|
246 { |
|
247 if ( iList ) |
|
248 { |
|
249 // as list IS consuming, must handle because it IS the SHUTDOWN... |
|
250 // or, a view switch is shutting us down... |
|
251 if ( aKeyEvent.iCode == EKeyEscape ) |
|
252 { |
|
253 ProcessCommandL( EEikCmdExit ); |
|
254 retval = EKeyWasConsumed; |
|
255 } |
|
256 else |
|
257 { |
|
258 retval = iList->OfferKeyEventL( aKeyEvent, aType ); |
|
259 if ( *iEventStore & CWPASecuritySettings::EShutDownReq ) |
|
260 { |
|
261 ProcessCommandL( EEikCmdExit ); |
|
262 } |
|
263 else if ( *iEventStore & CWPASecuritySettings::EExitReq ) |
|
264 { |
|
265 ProcessCommandL( EAknCmdExit ); |
|
266 } |
|
267 } |
|
268 } |
|
269 else |
|
270 { |
|
271 if ( aKeyEvent.iCode == EKeyOK ) |
|
272 { |
|
273 ProcessCommandL( EWpaSelCmdChange ); |
|
274 retval = EKeyWasConsumed; |
|
275 } |
|
276 } |
|
277 } |
|
278 } |
|
279 |
|
280 return retval; |
|
281 } |
|
282 |
|
283 // --------------------------------------------------------- |
|
284 // CWPASecuritySettingsDlg::HandleDialogPageEventL |
|
285 // --------------------------------------------------------- |
|
286 // |
|
287 void CWPASecuritySettingsDlg::HandleDialogPageEventL( TInt aEventID ) |
|
288 { |
|
289 CAknDialog::HandleDialogPageEventL( aEventID ); |
|
290 if( *iEventStore & CWPASecuritySettings::EExitReq ) |
|
291 { |
|
292 // Exit requested, exit with EAknCmdExit. |
|
293 TryExitL( EAknCmdExit ); |
|
294 } |
|
295 |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------- |
|
299 // CWPASecuritySettingsDlg::HandleListboxDataChangeL |
|
300 // --------------------------------------------------------- |
|
301 // |
|
302 void CWPASecuritySettingsDlg::HandleListboxDataChangeL() |
|
303 { |
|
304 // fill up our new list with data |
|
305 CDesCArrayFlat* itemArray = new ( ELeave ) CDesCArrayFlat( 4 ); |
|
306 CleanupStack::PushL( itemArray ); |
|
307 |
|
308 FillListWithDataL( *itemArray, *iFieldsMain, iTitlesMain ); |
|
309 |
|
310 iList->Model()->SetItemTextArray( itemArray ); |
|
311 |
|
312 CleanupStack::Pop( itemArray ); // now it is owned by the LB, so pop it |
|
313 iItemArray = itemArray; |
|
314 |
|
315 iList->HandleItemAdditionL(); |
|
316 } |
|
317 |
|
318 |
|
319 // --------------------------------------------------------- |
|
320 // CWPASecuritySettingsDlg::ProcessCommandL |
|
321 // --------------------------------------------------------- |
|
322 // |
|
323 void CWPASecuritySettingsDlg::ProcessCommandL( TInt aCommandId ) |
|
324 { |
|
325 if ( MenuShowing() ) |
|
326 { |
|
327 HideMenu(); |
|
328 } |
|
329 |
|
330 switch ( aCommandId ) |
|
331 { |
|
332 case EWpaSelCmdChange: |
|
333 { |
|
334 ChangeSettingsL( EFalse ); |
|
335 break; |
|
336 } |
|
337 |
|
338 case EAknCmdHelp: |
|
339 { |
|
340 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
341 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
342 break; |
|
343 } |
|
344 |
|
345 case EAknSoftkeyBack: |
|
346 case EAknCmdExit: |
|
347 case EEikCmdExit: |
|
348 { |
|
349 TryExitL( aCommandId ); |
|
350 break; |
|
351 } |
|
352 |
|
353 default: |
|
354 { |
|
355 // silently ignore it |
|
356 break; |
|
357 } |
|
358 } |
|
359 } |
|
360 |
|
361 |
|
362 // --------------------------------------------------------- |
|
363 // CWPASecuritySettingsDlg::HandleListBoxEventL |
|
364 // --------------------------------------------------------- |
|
365 // |
|
366 void CWPASecuritySettingsDlg::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
367 TListBoxEvent aEventType ) |
|
368 { |
|
369 switch ( aEventType ) |
|
370 { |
|
371 case EEventEnterKeyPressed: |
|
372 case EEventItemSingleClicked: |
|
373 { |
|
374 ChangeSettingsL( ETrue ); |
|
375 break; |
|
376 } |
|
377 |
|
378 case EEventEditingStarted: |
|
379 case EEventEditingStopped: |
|
380 case EEventPenDownOnItem: |
|
381 case EEventItemDraggingActioned: |
|
382 { |
|
383 break; |
|
384 } |
|
385 |
|
386 default: |
|
387 { |
|
388 // New events like |
|
389 // EEventPanningStarted |
|
390 // EEventPanningStopped |
|
391 // EEventFlickStarted |
|
392 // EEventFlickStopped |
|
393 // EEventEmptyListClicked |
|
394 // EEventEmptyAreaClicked |
|
395 break; |
|
396 }; |
|
397 }; |
|
398 } |
|
399 |
|
400 |
|
401 // --------------------------------------------------------- |
|
402 // CWPASecuritySettingsDlg::PreLayoutDynInitL() |
|
403 // --------------------------------------------------------- |
|
404 // |
|
405 void CWPASecuritySettingsDlg::PreLayoutDynInitL() |
|
406 { |
|
407 // first get StatusPane |
|
408 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
409 |
|
410 // then get TitlePane |
|
411 iTitlePane = ( CAknTitlePane* ) statusPane->ControlL( TUid::Uid( |
|
412 EEikStatusPaneUidTitle ) ); |
|
413 // if not already stored, store it for restoring |
|
414 if ( !iOldTitleText ) |
|
415 { |
|
416 iOldTitleText = iTitlePane->Text()->AllocL(); |
|
417 } |
|
418 |
|
419 // set new titlepane text |
|
420 iTitlePane->SetTextL( iConnectionName ); |
|
421 |
|
422 iList = STATIC_CAST( CAknSettingStyleListBox*, |
|
423 Control( KWpaMainSettingsListboxId ) ); |
|
424 |
|
425 iList->CreateScrollBarFrameL( ETrue ); |
|
426 iList->ScrollBarFrame()->SetScrollBarVisibilityL |
|
427 ( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
428 |
|
429 HandleListboxDataChangeL(); |
|
430 |
|
431 iList->SetCurrentItemIndex( 0 ); |
|
432 iList->SetListBoxObserver( this ); |
|
433 } |
|
434 |
|
435 |
|
436 |
|
437 // --------------------------------------------------------- |
|
438 // CWPASecuritySettingsDlg::DynInitMenuPaneL |
|
439 // --------------------------------------------------------- |
|
440 // |
|
441 void CWPASecuritySettingsDlg::DynInitMenuPaneL( TInt aResourceId, |
|
442 CEikMenuPane* aMenuPane ) |
|
443 { |
|
444 CAknDialog::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
445 if ( aResourceId == R_WPA_SECURITY_SETTINGS_MENU ) |
|
446 { |
|
447 if ( aMenuPane && !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
448 { |
|
449 aMenuPane->DeleteMenuItem( EAknCmdHelp ); |
|
450 } |
|
451 } |
|
452 } |
|
453 |
|
454 |
|
455 //---------------------------------------------------------- |
|
456 // CWPASecuritySettingsDlg::FillListWithDataL |
|
457 //---------------------------------------------------------- |
|
458 // |
|
459 void CWPASecuritySettingsDlg::FillListWithDataL( CDesCArrayFlat& aItemArray, |
|
460 const TWpaMember& arr, |
|
461 const TInt* aRes ) |
|
462 { |
|
463 TWpaMember* wpaMember = MUTABLE_CAST( TWpaMember*, &arr ); |
|
464 |
|
465 TInt numOfFields = iSecuritySettings->SecurityMode() == ESecurityModeWpa ? |
|
466 KNumOfFieldsMain : KNumOfFieldsMain-1; |
|
467 |
|
468 for( TInt i = 0; i < numOfFields; i++ ) |
|
469 { |
|
470 // 802.1x has no WpaMode (PSK not supported) and no Wpa2Only selection |
|
471 if ( iSecuritySettings->SecurityMode() == ESecurityMode8021x && |
|
472 (*wpaMember == EWpaMode ||*wpaMember == EWpaWpa2Only ) ) |
|
473 { |
|
474 wpaMember++; |
|
475 aRes++; |
|
476 } |
|
477 // If PSK in use, EAP plug-in configuration is not shown |
|
478 if ( *wpaMember == EWpaEapConfig && iSecuritySettings->WPAMode() ) |
|
479 { |
|
480 wpaMember++; |
|
481 aRes++; |
|
482 } |
|
483 |
|
484 if ( *wpaMember == EWpaEapConfig ) |
|
485 { |
|
486 // Define a heap descriptor to hold all the item text |
|
487 // HBufC is non-modifiable |
|
488 HBufC* title = iEikonEnv->AllocReadResourceLC( *aRes ); |
|
489 |
|
490 // Define a heap descriptor to hold all the item text |
|
491 HBufC* itemText = HBufC::NewLC( title->Length() + |
|
492 KSpaceAndTabsLength ); |
|
493 |
|
494 // Define a modifiable pointer descriptor to be able to append |
|
495 // text to the non-modifiable heap descriptor itemText |
|
496 TPtr itemTextPtr = itemText->Des(); |
|
497 itemTextPtr.Format( KTxtMenuListItemFormat, title ); |
|
498 |
|
499 aItemArray.AppendL( *itemText ); |
|
500 |
|
501 CleanupStack::PopAndDestroy( 2, title ); // itemText, title |
|
502 |
|
503 // If Eap in use, PreSharedKey is not shown |
|
504 wpaMember++; |
|
505 aRes++; |
|
506 } |
|
507 else // EWpaMode, EWpaPreSharedKey, EWpaWpa2Only, EWpaUnencryptedConn: |
|
508 { |
|
509 if (( *wpaMember != EWpaUnencryptedConn ) || |
|
510 (FeatureManager::FeatureSupported( KFeatureIdFfWlanAuthenticationOnlySupport ) ) ) |
|
511 { |
|
512 HBufC* itemText = CreateTextualListBoxItemL( *wpaMember, *aRes ); |
|
513 CleanupStack::PushL( itemText ); |
|
514 aItemArray.AppendL( itemText->Des() ); |
|
515 CleanupStack::PopAndDestroy( itemText ); |
|
516 } |
|
517 } |
|
518 |
|
519 wpaMember++; |
|
520 aRes++; |
|
521 } |
|
522 } |
|
523 |
|
524 |
|
525 //---------------------------------------------------------- |
|
526 // CWPASecuritySettingsDlg::UpdateTextualListBoxItemL |
|
527 //---------------------------------------------------------- |
|
528 // |
|
529 void CWPASecuritySettingsDlg::UpdateTextualListBoxItemL( TWpaMember aMember, |
|
530 TInt aRes, TInt aPos ) |
|
531 { |
|
532 HBufC* itemText; |
|
533 HBufC* title; |
|
534 |
|
535 if ( aMember == EWpaEapConfig ) |
|
536 { |
|
537 title = iEikonEnv->AllocReadResourceLC( aRes ); |
|
538 |
|
539 // Define a heap descriptor to hold all the item text |
|
540 itemText = HBufC::NewLC( title->Length() + KSpaceAndTabsLength ); |
|
541 |
|
542 // Define a modifiable pointer descriptor to be able to append |
|
543 // text to the non-modifiable heap descriptor itemText |
|
544 TPtr itemTextPtr = itemText->Des(); |
|
545 itemTextPtr.Format( KTxtMenuListItemFormat, title ); |
|
546 } |
|
547 else |
|
548 { |
|
549 itemText = CreateTextualListBoxItemL( aMember, aRes ); |
|
550 CleanupStack::PushL( itemText ); |
|
551 } |
|
552 |
|
553 // first try to add, if Leaves, list will be untouched |
|
554 iItemArray->InsertL( aPos, itemText->Des() ); |
|
555 // if successful, previous item is scrolled up with one, |
|
556 // so delete that one... |
|
557 if ( ++aPos < iItemArray->MdcaCount() ) |
|
558 { |
|
559 iItemArray->Delete( aPos ); |
|
560 } |
|
561 |
|
562 CleanupStack::PopAndDestroy( itemText ); |
|
563 |
|
564 if ( aMember == EWpaEapConfig ) |
|
565 { |
|
566 CleanupStack::PopAndDestroy( title ); // title |
|
567 } |
|
568 } |
|
569 |
|
570 |
|
571 //---------------------------------------------------------- |
|
572 // CWPASecuritySettingsDlg::CreateTextualListBoxItemL |
|
573 //---------------------------------------------------------- |
|
574 // |
|
575 HBufC* CWPASecuritySettingsDlg::CreateTextualListBoxItemL( TWpaMember aMember, |
|
576 TInt aRes ) |
|
577 { |
|
578 // Define a heap descriptor to hold all the item text |
|
579 // HBufC is non-modifiable |
|
580 HBufC* title = iEikonEnv->AllocReadResourceLC( aRes ); |
|
581 |
|
582 // both variables needed independently of the following conditions so I |
|
583 // must declare them here... |
|
584 HBufC16* value; |
|
585 TUint32 valueResourceID; |
|
586 |
|
587 switch ( aMember ) |
|
588 { |
|
589 case EWpaMode: |
|
590 { |
|
591 valueResourceID = iSecuritySettings->WPAMode() ? |
|
592 R_WPA_MODE_PRESHARED_KEY : R_WPA_MODE_EAP; |
|
593 break; |
|
594 } |
|
595 |
|
596 case EWpaWpa2Only: |
|
597 { |
|
598 valueResourceID = iSecuritySettings->Wpa2Only() ? |
|
599 R_WPA_CIPHER_NOT_ALLOWED : R_WPA_CIPHER_ALLOWED; |
|
600 break; |
|
601 } |
|
602 |
|
603 case EWpaUnencryptedConn: |
|
604 { |
|
605 valueResourceID = iSecuritySettings->WPAUnencryptedConn() ? |
|
606 R_WPA_UNENCRYPTED_CONN_ALLOW : R_WPA_UNENCRYPTED_CONN_NOT_ALLOW; |
|
607 break; |
|
608 } |
|
609 |
|
610 case EWpaPreSharedKey: |
|
611 { |
|
612 valueResourceID = |
|
613 iSecuritySettings->WPAPreSharedKey()->Length() == 0 ? |
|
614 R_WPA_PRESHARED_KEY_MUST_BE_DEFINED : 0; |
|
615 |
|
616 break; |
|
617 } |
|
618 |
|
619 default: |
|
620 { |
|
621 valueResourceID = 0; |
|
622 break; |
|
623 } |
|
624 } |
|
625 |
|
626 _LIT( KStars, "****" ); |
|
627 _LIT( KTxtListItemFormat, " \t%S\t\t%S" ); |
|
628 _LIT( KTxtCompulsory, "\t*" ); |
|
629 |
|
630 if ( valueResourceID ) |
|
631 { |
|
632 // Read up value text from resource |
|
633 value = iEikonEnv->AllocReadResourceLC( valueResourceID ); |
|
634 } |
|
635 else |
|
636 { |
|
637 value = HBufC::NewLC( KStars().Length() ); |
|
638 value->Des().Copy( KStars ); |
|
639 } |
|
640 |
|
641 // Define a heap descriptor to hold all the item text |
|
642 // +4 for space and tab characters |
|
643 TInt length = title->Length() + value->Length() + KSpaceAndTabsLength; |
|
644 if ( aMember == EWpaPreSharedKey ) // Compulsory |
|
645 { |
|
646 length += KTxtCompulsory().Length(); |
|
647 } |
|
648 |
|
649 HBufC* itemText = HBufC::NewLC( length ); |
|
650 |
|
651 // Define a modifiable pointer descriptor to be able to append text to the |
|
652 // non-modifiable heap descriptor itemText |
|
653 TPtr itemTextPtr = itemText->Des(); |
|
654 itemTextPtr.Format( KTxtListItemFormat, title, value ); |
|
655 if ( aMember == EWpaPreSharedKey ) // Compulsory |
|
656 { |
|
657 itemTextPtr.Append( KTxtCompulsory ); |
|
658 } |
|
659 CleanupStack::Pop( itemText ); // itemtext, |
|
660 |
|
661 CleanupStack::PopAndDestroy( 2 ); // title, value |
|
662 |
|
663 return itemText; |
|
664 } |
|
665 |
|
666 |
|
667 |
|
668 //---------------------------------------------------------- |
|
669 // CWPASecuritySettingsDlg::ShowPopupSettingPageL |
|
670 //---------------------------------------------------------- |
|
671 // |
|
672 TBool CWPASecuritySettingsDlg::ShowPopupSettingPageL( TWpaMember aData ) |
|
673 { |
|
674 TInt currvalue( 0 ); |
|
675 TBool retval( EFalse ); |
|
676 TInt attr_resid( 0 ); |
|
677 |
|
678 CDesCArrayFlat* items = FillPopupSettingPageLC( aData, currvalue ); |
|
679 |
|
680 |
|
681 if ( aData == EWpaUnencryptedConn) |
|
682 { |
|
683 attr_resid = R_WPA_UNENCRYPTED_CONN; |
|
684 } |
|
685 else |
|
686 { |
|
687 attr_resid = aData == EWpaMode ? R_WPA_MODE : R_WPA_TKIP_CIPHER; |
|
688 } |
|
689 |
|
690 HBufC* titlebuf = iEikonEnv->AllocReadResourceLC( attr_resid ); |
|
691 CAknRadioButtonSettingPage* dlg = new ( ELeave )CAknRadioButtonSettingPage( |
|
692 R_RADIO_BUTTON_SETTING_PAGE, currvalue, items ); |
|
693 CleanupStack::PushL( dlg ); |
|
694 TPtrC ptr( titlebuf->Des() ); |
|
695 dlg->SetSettingTextL( ptr ); |
|
696 CleanupStack::Pop( dlg ); // dlg |
|
697 |
|
698 if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) ) |
|
699 { |
|
700 retval = UpdateFromPopupSettingPage( aData, ( TBool )currvalue ); |
|
701 } |
|
702 |
|
703 CleanupStack::PopAndDestroy( titlebuf ); |
|
704 CleanupStack::PopAndDestroy( items ); // items. It deletes also all |
|
705 // elements in the array. |
|
706 return retval; |
|
707 } |
|
708 |
|
709 |
|
710 |
|
711 //---------------------------------------------------------- |
|
712 // CWPASecuritySettingsDlg::ShowPopupTextSettingPageL |
|
713 //---------------------------------------------------------- |
|
714 // |
|
715 TBool CWPASecuritySettingsDlg::ShowPopupTextSettingPageL() |
|
716 { |
|
717 TBool retval( EFalse ); |
|
718 |
|
719 HBufC16* bufKeyData = HBufC16::NewLC( EMaxLengthOfPreSharedKey ); |
|
720 TPtr16 ptrKeyData( bufKeyData->Des() ); |
|
721 |
|
722 TBool showPage( ETrue ); |
|
723 while ( showPage ) |
|
724 { |
|
725 CAknTextSettingPage* settingPage = |
|
726 new( ELeave )CAknTextSettingPage( R_TEXT_SETTING_PAGE_KEY_DATA, |
|
727 ptrKeyData, EAknSettingPageNoOrdinalDisplayed ); |
|
728 |
|
729 if ( settingPage->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ) ) |
|
730 { |
|
731 HBufC8* buf8 = HBufC8::NewLC( bufKeyData->Des().Length() ); |
|
732 buf8->Des().Copy( bufKeyData->Des() ); |
|
733 |
|
734 if ( bufKeyData->Des().Length() < EMinLengthOfPreSharedKeyAscii ) |
|
735 { |
|
736 HBufC* stringLabel; |
|
737 |
|
738 stringLabel = StringLoader::LoadL( |
|
739 R_INFO_PRESHARED_KEY_TOO_SHORT, |
|
740 iEikonEnv ); |
|
741 |
|
742 CleanupStack::PushL( stringLabel ); |
|
743 |
|
744 CAknInformationNote* dialog = new ( ELeave ) |
|
745 CAknInformationNote( ETrue ); |
|
746 dialog->ExecuteLD( *stringLabel ); |
|
747 |
|
748 CleanupStack::PopAndDestroy( stringLabel ); // stringLabel |
|
749 |
|
750 ptrKeyData.Zero(); |
|
751 } |
|
752 else |
|
753 { |
|
754 if ( iSecuritySettings->SetWPAPreSharedKey( ptrKeyData ) != |
|
755 KErrNone ) |
|
756 { |
|
757 HBufC* stringLabel; |
|
758 stringLabel = StringLoader::LoadL( |
|
759 R_INFO_PRESHARED_KEY_NOT_HEX ); |
|
760 CleanupStack::PushL( stringLabel ); |
|
761 |
|
762 CAknInformationNote* dialog = new ( ELeave ) |
|
763 CAknInformationNote( ETrue ); |
|
764 CleanupStack::Pop( stringLabel ); |
|
765 |
|
766 dialog->ExecuteLD( *stringLabel ); |
|
767 |
|
768 delete stringLabel; |
|
769 } |
|
770 else |
|
771 { |
|
772 retval = ETrue; |
|
773 showPage = EFalse; |
|
774 } |
|
775 |
|
776 } |
|
777 |
|
778 CleanupStack::PopAndDestroy( buf8 ); // buf8 |
|
779 } |
|
780 else |
|
781 { |
|
782 showPage = EFalse; |
|
783 } |
|
784 } |
|
785 |
|
786 CleanupStack::PopAndDestroy( bufKeyData ); // bufKeyData |
|
787 |
|
788 return retval; |
|
789 } |
|
790 |
|
791 |
|
792 |
|
793 // --------------------------------------------------------- |
|
794 // CWPASecuritySettingsDlg::FillPopupSettingPageLC |
|
795 // --------------------------------------------------------- |
|
796 // |
|
797 CDesCArrayFlat* CWPASecuritySettingsDlg::FillPopupSettingPageLC( |
|
798 TWpaMember aData, |
|
799 TInt& aCurrvalue ) |
|
800 { |
|
801 CDesCArrayFlat* items = new( ELeave)CDesCArrayFlat( 1 ); |
|
802 CleanupStack::PushL( items ); |
|
803 |
|
804 if ( aData == EWpaMode ) |
|
805 { |
|
806 if ( iPlugin ) |
|
807 { |
|
808 aCurrvalue = iSecuritySettings->WPAMode(); |
|
809 |
|
810 items->AppendL( *iEikonEnv->AllocReadResourceLC( R_WPA_MODE_EAP ) ); |
|
811 CleanupStack::PopAndDestroy(); |
|
812 } |
|
813 else |
|
814 { |
|
815 aCurrvalue = 0; |
|
816 } |
|
817 |
|
818 items->AppendL( *iEikonEnv->AllocReadResourceLC( |
|
819 R_WPA_MODE_PRESHARED_KEY ) ); |
|
820 CleanupStack::PopAndDestroy(); |
|
821 } |
|
822 else if ( aData == EWpaWpa2Only ) |
|
823 { |
|
824 items->AppendL( *iEikonEnv->AllocReadResourceLC( |
|
825 R_WPA_CIPHER_ALLOWED ) ); |
|
826 CleanupStack::PopAndDestroy(); |
|
827 items->AppendL( *iEikonEnv->AllocReadResourceLC( |
|
828 R_WPA_CIPHER_NOT_ALLOWED ) ); |
|
829 CleanupStack::PopAndDestroy(); |
|
830 |
|
831 aCurrvalue = iSecuritySettings->Wpa2Only(); |
|
832 } |
|
833 else // EWpaUnencryptedConn |
|
834 { |
|
835 items->AppendL( *iEikonEnv->AllocReadResourceLC( |
|
836 R_WPA_UNENCRYPTED_CONN_NOT_ALLOW ) ); |
|
837 CleanupStack::PopAndDestroy(); |
|
838 items->AppendL( *iEikonEnv->AllocReadResourceLC( |
|
839 R_WPA_UNENCRYPTED_CONN_ALLOW ) ); |
|
840 CleanupStack::PopAndDestroy(); |
|
841 |
|
842 aCurrvalue = iSecuritySettings->WPAUnencryptedConn(); |
|
843 } |
|
844 |
|
845 return items; |
|
846 } |
|
847 |
|
848 |
|
849 // --------------------------------------------------------- |
|
850 // CWPASecuritySettingsDlg::UpdateFromPopupSettingPage |
|
851 // --------------------------------------------------------- |
|
852 // |
|
853 TBool CWPASecuritySettingsDlg::UpdateFromPopupSettingPage( TWpaMember aData, |
|
854 TBool aCurrvalue ) |
|
855 { |
|
856 TBool retVal( EFalse ); |
|
857 |
|
858 if ( aData == EWpaMode ) |
|
859 { |
|
860 if ( !iPlugin ) |
|
861 { |
|
862 aCurrvalue = ETrue; |
|
863 } |
|
864 |
|
865 if ( iSecuritySettings->WPAMode() != aCurrvalue ) |
|
866 { |
|
867 iSecuritySettings->SetWPAMode( aCurrvalue ); |
|
868 retVal = ETrue; |
|
869 } |
|
870 } |
|
871 else if ( aData == EWpaWpa2Only ) |
|
872 { |
|
873 if ( iSecuritySettings->Wpa2Only() != aCurrvalue ) |
|
874 { |
|
875 iSecuritySettings->SetWpa2Only( aCurrvalue ); |
|
876 retVal = ETrue; |
|
877 } |
|
878 } |
|
879 else // EWpaUnencryptedConn |
|
880 { |
|
881 if ( iSecuritySettings->WPAUnencryptedConn() != aCurrvalue ) |
|
882 { |
|
883 iSecuritySettings->SetWPAUnencryptedConn( aCurrvalue ); |
|
884 retVal = ETrue; |
|
885 } |
|
886 } |
|
887 |
|
888 return retVal; |
|
889 } |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 //---------------------------------------------------------- |
|
895 // CWPASecuritySettingsDlg::ChangeSettingsL |
|
896 //---------------------------------------------------------- |
|
897 // |
|
898 void CWPASecuritySettingsDlg::ResetEapConfigFlag( TAny* aPtr ) |
|
899 { |
|
900 CWPASecuritySettingsDlg* self = |
|
901 static_cast<CWPASecuritySettingsDlg*>( aPtr ); |
|
902 |
|
903 self->iEapConfigActive = EFalse; |
|
904 } |
|
905 |
|
906 |
|
907 //---------------------------------------------------------- |
|
908 // CWPASecuritySettingsDlg::ChangeSettingsL |
|
909 //---------------------------------------------------------- |
|
910 // |
|
911 void CWPASecuritySettingsDlg::ChangeSettingsL( TBool aQuick ) |
|
912 { |
|
913 TInt itemIndex; |
|
914 TInt shift; |
|
915 |
|
916 itemIndex = ( Max( iList->CurrentItemIndex(), 0 ) ); |
|
917 |
|
918 //In 802.1x the first item is EapConfig and second item is UncryptedConn |
|
919 if (iSecuritySettings->SecurityMode() == ESecurityMode8021x) |
|
920 { |
|
921 shift = ( itemIndex == EWpaMode ) ? 1 : 3; |
|
922 } |
|
923 else |
|
924 { |
|
925 shift = ( itemIndex >= EWpaWpa2Only || |
|
926 ( itemIndex == EWpaEapConfig && |
|
927 iSecuritySettings->WPAMode() ) ) ? 1 : 0; |
|
928 } |
|
929 |
|
930 TWpaMember* ptr = iFieldsMain + itemIndex + shift; |
|
931 TInt* titPtr = iTitlesMain + itemIndex + shift; |
|
932 |
|
933 switch ( *ptr ) |
|
934 { |
|
935 case EWpaMode: |
|
936 { // Pop-up setting item |
|
937 TBool changed( ETrue ); |
|
938 if ( aQuick ) |
|
939 { |
|
940 if ( iPlugin ) |
|
941 { |
|
942 iSecuritySettings->SetWPAMode( |
|
943 !iSecuritySettings->WPAMode() ); |
|
944 } |
|
945 else |
|
946 { |
|
947 changed = EFalse; |
|
948 } |
|
949 } |
|
950 else |
|
951 { |
|
952 changed = ShowPopupSettingPageL( EWpaMode ); |
|
953 } |
|
954 |
|
955 if ( changed ) |
|
956 { |
|
957 UpdateTextualListBoxItemL( *ptr, *titPtr, itemIndex ); |
|
958 *iEventStore |= CWPASecuritySettings::EModified; |
|
959 |
|
960 TInt shiftItem = iSecuritySettings->WPAMode() ? 2 : 1; |
|
961 |
|
962 ptr += shiftItem; |
|
963 titPtr += shiftItem; |
|
964 |
|
965 UpdateTextualListBoxItemL( *ptr, *titPtr, itemIndex+1 ); |
|
966 iList->SetCurrentItemIndexAndDraw( itemIndex+1 ); |
|
967 } |
|
968 break; |
|
969 } |
|
970 |
|
971 case EWpaWpa2Only: |
|
972 { // Setting item with two available values |
|
973 TBool changed( ETrue ); |
|
974 if ( aQuick ) |
|
975 { |
|
976 iSecuritySettings->SetWpa2Only( |
|
977 !iSecuritySettings->Wpa2Only() ); |
|
978 } |
|
979 else |
|
980 { |
|
981 changed = ShowPopupSettingPageL( EWpaWpa2Only ); |
|
982 } |
|
983 |
|
984 if ( changed ) |
|
985 { |
|
986 UpdateTextualListBoxItemL( *ptr, *titPtr, itemIndex ); |
|
987 *iEventStore |= CWPASecuritySettings::EModified; |
|
988 } |
|
989 break; |
|
990 } |
|
991 |
|
992 case EWpaUnencryptedConn: |
|
993 { // Setting item with two available values |
|
994 TBool changed( ETrue ); |
|
995 if ( aQuick ) |
|
996 { |
|
997 iSecuritySettings->SetWPAUnencryptedConn( |
|
998 !iSecuritySettings->WPAUnencryptedConn() ); |
|
999 } |
|
1000 else |
|
1001 { |
|
1002 changed = ShowPopupSettingPageL( EWpaUnencryptedConn ); |
|
1003 } |
|
1004 |
|
1005 if ( changed ) |
|
1006 { |
|
1007 UpdateTextualListBoxItemL( *ptr, *titPtr, itemIndex ); |
|
1008 *iEventStore |= CWPASecuritySettings::EModified; |
|
1009 } |
|
1010 break; |
|
1011 } |
|
1012 |
|
1013 case EWpaPreSharedKey: |
|
1014 { // Text setting item |
|
1015 if ( ShowPopupTextSettingPageL() ) |
|
1016 { |
|
1017 UpdateTextualListBoxItemL( *ptr, *titPtr, itemIndex ); |
|
1018 *iEventStore |= CWPASecuritySettings::EModified; |
|
1019 } |
|
1020 break; |
|
1021 } |
|
1022 |
|
1023 case EWpaEapConfig: |
|
1024 { |
|
1025 if ( iPlugin && !iEapConfigActive ) |
|
1026 { |
|
1027 iEapConfigActive = ETrue; |
|
1028 CleanupStack::PushL( TCleanupItem( ResetEapConfigFlag, this ) ); |
|
1029 |
|
1030 |
|
1031 // using expanded EAP types |
|
1032 iEnabledPluginList = ( |
|
1033 iSecuritySettings->WPAEnabledEAPPlugin()? |
|
1034 (TDesC8&)*iSecuritySettings->WPAEnabledEAPPlugin(): |
|
1035 KNullDesC8 ); |
|
1036 |
|
1037 iDisabledPluginList = ( |
|
1038 iSecuritySettings->WPADisabledEAPPlugin()? |
|
1039 (TDesC8&)*iSecuritySettings->WPADisabledEAPPlugin(): |
|
1040 KNullDesC8 ); |
|
1041 |
|
1042 TInt buttonId = iPlugin->EAPPluginConfigurationL( |
|
1043 iEnabledPluginList, |
|
1044 iDisabledPluginList, |
|
1045 iIapId, |
|
1046 iConnectionName ); |
|
1047 |
|
1048 CleanupStack::PopAndDestroy( 1 ); // ResetEapConfigFlag |
|
1049 |
|
1050 if ( buttonId == EEikCmdExit ) // ShutDown requested |
|
1051 { |
|
1052 *iEventStore |= CWPASecuritySettings::EShutDownReq; |
|
1053 } |
|
1054 else if ( buttonId == EAknCmdExit ) |
|
1055 { |
|
1056 *iEventStore |= CWPASecuritySettings::EExitReq; |
|
1057 } |
|
1058 |
|
1059 if ( !iSecuritySettings->WPAEnabledEAPPlugin() || |
|
1060 iEnabledPluginList != |
|
1061 *iSecuritySettings->WPAEnabledEAPPlugin() ) |
|
1062 { |
|
1063 User::LeaveIfError( |
|
1064 iSecuritySettings->SetWPAEnabledEAPPlugin( |
|
1065 iEnabledPluginList ) ); |
|
1066 *iEventStore |= CWPASecuritySettings::EModified; |
|
1067 } |
|
1068 |
|
1069 if ( !iSecuritySettings->WPADisabledEAPPlugin() || |
|
1070 iDisabledPluginList != |
|
1071 *iSecuritySettings->WPADisabledEAPPlugin() ) |
|
1072 { |
|
1073 User::LeaveIfError( |
|
1074 iSecuritySettings->SetWPADisabledEAPPlugin( |
|
1075 iDisabledPluginList ) ); |
|
1076 *iEventStore |= CWPASecuritySettings::EModified; |
|
1077 } |
|
1078 |
|
1079 // If exiting from the menu, pass it on |
|
1080 if( buttonId == EAknCmdExit ) |
|
1081 { |
|
1082 if (aQuick == EFalse) |
|
1083 { |
|
1084 TryExitL( buttonId ); |
|
1085 } |
|
1086 // Don't exit here if aQuick==ETrue. |
|
1087 // Framework command chain will |
|
1088 // cause a KERN-EXEC 3 panic. Handle the exit in |
|
1089 // HandleDialogPageEventL(). |
|
1090 } |
|
1091 } |
|
1092 |
|
1093 return; |
|
1094 } |
|
1095 |
|
1096 |
|
1097 default: |
|
1098 { |
|
1099 __ASSERT_DEBUG( EFalse, Panic( EUnknownCase ) ); |
|
1100 break; |
|
1101 } |
|
1102 } |
|
1103 |
|
1104 iList->ScrollToMakeItemVisible( itemIndex ); |
|
1105 iList->SetCurrentItemIndexAndDraw( itemIndex ); |
|
1106 } |
|
1107 |
|
1108 |
|
1109 |
|
1110 // --------------------------------------------------------- |
|
1111 // CWPASecuritySettingsDlg::GetHelpContext |
|
1112 // --------------------------------------------------------- |
|
1113 // |
|
1114 void CWPASecuritySettingsDlg::GetHelpContext( TCoeHelpContext& aContext ) const |
|
1115 { |
|
1116 aContext.iMajor = KWPASecuritySettingsUiHelpMajor; |
|
1117 if ( iSecuritySettings->SecurityMode() == ESecurityModeWpa ) |
|
1118 { |
|
1119 aContext.iContext = KSET_HLP_WLAN_WPA_MAIN; |
|
1120 } |
|
1121 else // iSecuritySettings->SecurityMode() == ESecurityMode8021x |
|
1122 { |
|
1123 aContext.iContext = KSET_HLP_WLAN_8021X_MAIN; |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 |
|
1128 // End of File |