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