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 EAP Mschapv2 UI settings dialog |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 29 % |
|
20 */ |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <eikdialg.h> |
|
24 #include <AknDialog.h> |
|
25 #include <aknlists.h> |
|
26 #include "EapMschapv2UiView.h" |
|
27 #include "EapMschapv2Ui.hrh" |
|
28 #include <eapmschapv2ui.rsg> |
|
29 #include <akntextsettingpage.h> |
|
30 #include <aknsettingitemlist.h> |
|
31 #include "EapMschapv2UiSettingArray.h" |
|
32 #include <aknnavide.h> |
|
33 #include <aknnotewrappers.h> |
|
34 #include <EapMsChapV2UiConnection.h> |
|
35 #include <EapMsChapV2UiDataConnection.h> |
|
36 #include <EapMsChapV2UiMsChapV2Data.h> |
|
37 |
|
38 #include <featmgr.h> |
|
39 #include <hlplch.h> |
|
40 #include <csxhelp/cp.hlp.hrh> |
|
41 |
|
42 |
|
43 // CONSTANTS |
|
44 // UID of general settings app, in which help texts are included |
|
45 const TUid KHelpUidPlugin = { 0x100058EC }; |
|
46 |
|
47 _LIT( KEmptyString, "" ); |
|
48 |
|
49 static const TInt KEapMsChapv2Id = 26; |
|
50 |
|
51 // MODULE DATA STRUCTURES |
|
52 enum |
|
53 { |
|
54 EUsernameItem=0, |
|
55 EPasswordPromptItem, |
|
56 EPasswordItem |
|
57 }; |
|
58 |
|
59 |
|
60 // ============================ MEMBER FUNCTIONS =============================== |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CEapMsChapV2UiDialog::CEapMsChapV2UiDialog |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CEapMsChapV2UiDialog::CEapMsChapV2UiDialog( |
|
67 CEapMsChapV2UiConnection* aConnection, |
|
68 TInt& aButtonId ) |
|
69 : CAknDialog(), |
|
70 iConnection( aConnection ), |
|
71 iUiData( 0 ), |
|
72 iDataConnection( 0 ), |
|
73 iSettingArray( 0 ), |
|
74 iSettingListBox( 0 ), |
|
75 iSettingListItemDrawer( 0 ), |
|
76 iPassPrompt( EFalse ), |
|
77 iNaviPane( 0 ), |
|
78 iNaviDecorator( 0 ), |
|
79 iPreviousText( 0 ), |
|
80 iButtonId( &aButtonId ), |
|
81 iIsUIConstructionCompleted( EFalse ) |
|
82 { |
|
83 } |
|
84 |
|
85 |
|
86 // --------------------------------------------------z------- |
|
87 // CEapMsChapV2UiDialog::ConstructAndRunLD |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 TInt CEapMsChapV2UiDialog::ConstructAndRunLD( TInt aResourceId ) |
|
91 { |
|
92 CleanupStack::PushL( this ); |
|
93 |
|
94 iSettingArray = CEapMsChapV2SettingItemArray::NewL(); |
|
95 |
|
96 User::LeaveIfError( iConnection->Connect() ); |
|
97 |
|
98 iDataConnection = iConnection->GetDataConnection(); |
|
99 if ( iDataConnection == 0 ) |
|
100 { |
|
101 User::Leave( KErrNoMemory ); |
|
102 } |
|
103 |
|
104 User::LeaveIfError( iDataConnection->Open() ); |
|
105 User::LeaveIfError( iDataConnection->GetData( &iUiData ) ); |
|
106 |
|
107 FeatureManager::InitializeLibL(); |
|
108 |
|
109 ConstructL( R_MSCHAPV2_MENUBAR ); |
|
110 |
|
111 // ExecuteLD will PushL( this ), so we have to Pop it... |
|
112 CleanupStack::Pop( this ); // this |
|
113 |
|
114 return CAknDialog::ExecuteLD( aResourceId ); |
|
115 } |
|
116 |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CEapMsChapV2UiDialog::~CEapMsChapV2UiDialog |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 CEapMsChapV2UiDialog::~CEapMsChapV2UiDialog() |
|
123 { |
|
124 if ( iNaviDecorator ) |
|
125 { |
|
126 delete iNaviDecorator; |
|
127 iNaviDecorator = NULL; |
|
128 } |
|
129 |
|
130 if ( iSettingArray ) |
|
131 { |
|
132 iSettingArray->Array()->ResetAndDestroy(); |
|
133 delete iSettingArray; |
|
134 } |
|
135 |
|
136 if ( iSettingListBox ) |
|
137 { |
|
138 iSettingListBox = 0; |
|
139 } |
|
140 |
|
141 if ( iSettingListItemDrawer ) |
|
142 { |
|
143 iSettingListItemDrawer = 0; |
|
144 } |
|
145 |
|
146 if ( iDataConnection ) |
|
147 { |
|
148 iDataConnection->Close(); |
|
149 delete iDataConnection; |
|
150 } |
|
151 |
|
152 if ( iConnection ) |
|
153 { |
|
154 iConnection->Close(); |
|
155 } |
|
156 |
|
157 delete iPreviousText; |
|
158 |
|
159 FeatureManager::UnInitializeLib(); |
|
160 } |
|
161 |
|
162 |
|
163 // --------------------------------------------------------- |
|
164 // CEapMsChapV2UiDialog::HandleListBoxEventL |
|
165 // --------------------------------------------------------- |
|
166 // |
|
167 void CEapMsChapV2UiDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
168 TListBoxEvent aEventType ) |
|
169 { |
|
170 switch ( aEventType ) |
|
171 { |
|
172 case EEventEnterKeyPressed: |
|
173 case EEventItemSingleClicked: |
|
174 { |
|
175 OkToExitL( EMschapv2UiCmdChange ); |
|
176 break; |
|
177 } |
|
178 |
|
179 case EEventItemActioned: |
|
180 case EEventEditingStarted: |
|
181 case EEventEditingStopped: |
|
182 case EEventPenDownOnItem: |
|
183 case EEventItemDraggingActioned: |
|
184 { |
|
185 break; |
|
186 } |
|
187 |
|
188 default: |
|
189 { |
|
190 break; |
|
191 }; |
|
192 }; |
|
193 } |
|
194 |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CEapMsChapV2UiDialog::PreLayoutDynInitL |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CEapMsChapV2UiDialog::PreLayoutDynInitL() |
|
201 { |
|
202 ChangeTitleL( ETrue ); |
|
203 |
|
204 TUid naviPaneUid; |
|
205 naviPaneUid.iUid = EEikStatusPaneUidNavi; |
|
206 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
207 CEikStatusPaneBase::TPaneCapabilities subPane = |
|
208 statusPane->PaneCapabilities( naviPaneUid ); |
|
209 if ( subPane.IsPresent() && subPane.IsAppOwned() ) |
|
210 { |
|
211 iNaviPane = static_cast<CAknNavigationControlContainer*>( |
|
212 statusPane->ControlL(naviPaneUid) ); |
|
213 // Set empty text to hide tabs. |
|
214 iNaviDecorator = iNaviPane->CreateNavigationLabelL( KEmptyString ); |
|
215 iNaviPane->PushL( *iNaviDecorator ); |
|
216 } |
|
217 |
|
218 iSettingListBox = static_cast<CAknSettingStyleListBox*>( |
|
219 ControlOrNull( EMschapv2SettingsListBox) ); |
|
220 iSettingListItemDrawer = static_cast<CSettingsListBoxItemDrawer*>( |
|
221 iSettingListBox->ItemDrawer() ); |
|
222 |
|
223 iSettingListBox->SetMopParent( this ); |
|
224 iSettingListBox->CreateScrollBarFrameL( ETrue ); |
|
225 iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
226 CEikScrollBarFrame::EOff, |
|
227 CEikScrollBarFrame::EAuto ); |
|
228 iSettingListBox->SetListBoxObserver( this ); |
|
229 DrawSettingsListL(); |
|
230 |
|
231 iIsUIConstructionCompleted = ETrue; |
|
232 } |
|
233 |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CEapMsChapV2UiDialog::ShowSettingPageL |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 void CEapMsChapV2UiDialog::ShowSettingPageL( TInt aCalledFromMenu ) |
|
240 { |
|
241 TInt index = iSettingListBox->CurrentItemIndex(); |
|
242 |
|
243 CAknSettingItem* item = iSettingArray->Array()->At( index ); |
|
244 item->EditItemL( aCalledFromMenu ); |
|
245 item->StoreL(); |
|
246 |
|
247 if ( index == EPasswordPromptItem ) |
|
248 { |
|
249 if ( !iPassPrompt ) |
|
250 *iUiData->GetPasswordPrompt() = EFalse; |
|
251 else |
|
252 *iUiData->GetPasswordPrompt() = ETrue; |
|
253 } |
|
254 |
|
255 DrawNow(); |
|
256 } |
|
257 |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CEapMsChapV2UiDialog::OkToExitL |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 TBool CEapMsChapV2UiDialog::OkToExitL( TInt aButtonId ) |
|
264 { |
|
265 TBool ret( EFalse ); |
|
266 switch ( aButtonId ) |
|
267 { |
|
268 case EEikBidOk: |
|
269 { |
|
270 if( iIsUIConstructionCompleted ) |
|
271 { |
|
272 if ( iSettingListBox->IsFocused() ) |
|
273 { |
|
274 ShowSettingPageL( EFalse ); |
|
275 } |
|
276 } |
|
277 else |
|
278 { |
|
279 #if defined(_DEBUG) || defined(DEBUG) |
|
280 RDebug::Print(_L("CEapMsChapV2UiDialog::OkToExitL - UI not ready - Ignoring key press.\n") ); |
|
281 #endif |
|
282 } |
|
283 break; |
|
284 } |
|
285 |
|
286 case EAknSoftkeyOptions: |
|
287 { |
|
288 DisplayMenuL(); |
|
289 break; |
|
290 } |
|
291 |
|
292 case EAknSoftkeyBack: |
|
293 case EAknCmdExit: |
|
294 { |
|
295 if( iIsUIConstructionCompleted ) |
|
296 { |
|
297 iDataConnection->Update(); |
|
298 ChangeTitleL( EFalse ); |
|
299 ret = ETrue; |
|
300 } |
|
301 break; |
|
302 } |
|
303 |
|
304 case EMschapv2UiCmdChange: |
|
305 { |
|
306 if( iIsUIConstructionCompleted ) |
|
307 { |
|
308 ShowSettingPageL( EFalse ); |
|
309 } |
|
310 else |
|
311 { |
|
312 #if defined(_DEBUG) || defined(DEBUG) |
|
313 RDebug::Print(_L("CEapMsChapV2UiDialog::ProcessCommandL - UI not ready - Ignoring key press.\n") ); |
|
314 #endif |
|
315 } |
|
316 break; |
|
317 } |
|
318 |
|
319 default: |
|
320 { |
|
321 break; |
|
322 } |
|
323 } |
|
324 |
|
325 if ( ret ) |
|
326 { |
|
327 *iButtonId = aButtonId; |
|
328 } |
|
329 |
|
330 return ret; |
|
331 } |
|
332 |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // CEapMsChapV2UiDialog::DrawSettingsListL |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 void CEapMsChapV2UiDialog::DrawSettingsListL() |
|
339 { |
|
340 iSettingArray->Array()->ResetAndDestroy(); |
|
341 |
|
342 TInt ordinal = 0; |
|
343 iSettingArray->AddTextItemL( iUiData->GetUsername(), |
|
344 EMschapv2SettingPageUserName, |
|
345 R_MSCHAPV2_USERNAME_STRING, |
|
346 R_MSCHAPV2_USERNAME_PAGE, |
|
347 NULL, |
|
348 ordinal++ ); |
|
349 |
|
350 if ( *iUiData->GetPasswordPrompt() ) |
|
351 { |
|
352 iPassPrompt = ETrue; |
|
353 } |
|
354 else{ |
|
355 iPassPrompt = EFalse; |
|
356 } |
|
357 |
|
358 iSettingArray->AddBinarySettingItemL( R_MSCHAPV2_DISPLAY_YESNO_PAGE, |
|
359 R_MSCHAPV2_PASSPROMPT_STRING, |
|
360 R_MSCHAPV2_YESNO_TEXTS, |
|
361 ordinal++, |
|
362 iPassPrompt ); |
|
363 |
|
364 iSettingArray->AddPasswordItemL( iUiData->GetPassword(), |
|
365 EMschapv2SettingPagePassword, |
|
366 R_MSCHAPV2_PASSWORD_STRING, |
|
367 R_MSCHAPV2_PASSWORD_PAGE, |
|
368 NULL, |
|
369 ordinal++ ); |
|
370 |
|
371 |
|
372 iSettingListBox->Model()->SetItemTextArray( iSettingArray->Array() ); |
|
373 iSettingListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
374 iSettingArray->Array()->RecalculateVisibleIndicesL(); |
|
375 iSettingListBox->HandleItemAdditionL(); |
|
376 iSettingListBox->UpdateScrollBarsL(); |
|
377 } |
|
378 |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CEapMsChapV2UiDialog::ChangeTitleL |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 void CEapMsChapV2UiDialog::ChangeTitleL( TBool aIsStarted ) |
|
385 { |
|
386 TUid titlePaneUid; |
|
387 titlePaneUid.iUid = EEikStatusPaneUidTitle; |
|
388 |
|
389 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
390 CEikStatusPaneBase::TPaneCapabilities subPane = |
|
391 statusPane->PaneCapabilities( titlePaneUid ); |
|
392 |
|
393 if ( subPane.IsPresent() && subPane.IsAppOwned()) |
|
394 { |
|
395 CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( |
|
396 statusPane->ControlL( titlePaneUid ) ); |
|
397 if ( aIsStarted ) |
|
398 { |
|
399 // Store previous application title text |
|
400 const TDesC* prevText = titlePane->Text(); |
|
401 |
|
402 iPreviousText = HBufC::NewL( prevText->Length() ); |
|
403 iPreviousText->Des().Append( *prevText ); |
|
404 |
|
405 // EAGN-6QZD6U |
|
406 // Loadd different titles for plain MSCHAPv2 and EAP-MSCHAPv2 |
|
407 TDesC* titleText; |
|
408 if( iConnection->GetBearerEAPType() == KEapMsChapv2Id ) |
|
409 { |
|
410 titleText = iEikonEnv->AllocReadResourceLC( |
|
411 R_MSCHAPV2_SETTINGS_TITLE ); |
|
412 } |
|
413 else |
|
414 { |
|
415 titleText = iEikonEnv->AllocReadResourceLC( |
|
416 R_PLAIN_MSCHAPV2_SETTINGS_TITLE ); |
|
417 } |
|
418 titlePane->SetTextL( *titleText ); |
|
419 CleanupStack::PopAndDestroy( titleText ); |
|
420 } |
|
421 else |
|
422 { |
|
423 // Set calling application title text back |
|
424 titlePane->SetTextL( *iPreviousText ); |
|
425 // pop navidecorator when exiting |
|
426 iNaviPane->Pop( iNaviDecorator ); |
|
427 } |
|
428 } |
|
429 } |
|
430 |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // CEapMsChapV2UiDialog::DynInitMenuPaneL |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 void CEapMsChapV2UiDialog::DynInitMenuPaneL( TInt aResourceId, |
|
437 CEikMenuPane* aMenuPane ) |
|
438 { |
|
439 CAknDialog::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
440 |
|
441 if ( aResourceId == R_MSCHAPV2_MENU_PANE ) |
|
442 { |
|
443 if ( aMenuPane && !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
444 { |
|
445 aMenuPane->DeleteMenuItem( EAknCmdHelp ); |
|
446 } |
|
447 } |
|
448 } |
|
449 |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // CEapMsChapV2UiDialog::ProcessCommandL |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 void CEapMsChapV2UiDialog::ProcessCommandL( TInt aCommand ) |
|
456 { |
|
457 if ( MenuShowing() ) |
|
458 { |
|
459 HideMenu(); |
|
460 } |
|
461 |
|
462 switch( aCommand ) |
|
463 { |
|
464 case EAknCmdExit: |
|
465 { |
|
466 TryExitL( aCommand ); |
|
467 break; |
|
468 } |
|
469 |
|
470 case EAknCmdHelp: |
|
471 { |
|
472 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
473 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
474 break; |
|
475 } |
|
476 |
|
477 case EMschapv2UiCmdChange: |
|
478 { |
|
479 if( iIsUIConstructionCompleted ) |
|
480 { |
|
481 ShowSettingPageL( ETrue ); |
|
482 } |
|
483 else |
|
484 { |
|
485 #if defined(_DEBUG) || defined(DEBUG) |
|
486 RDebug::Print(_L("CEapMsChapV2UiDialog::ProcessCommandL - UI not ready - Ignoring key press.\n") ); |
|
487 #endif |
|
488 } |
|
489 break; |
|
490 } |
|
491 |
|
492 default: |
|
493 { |
|
494 break; |
|
495 } |
|
496 } |
|
497 } |
|
498 |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // CEapMsChapV2UiDialog::GetHelpContext |
|
502 // ----------------------------------------------------------------------------- |
|
503 // |
|
504 void CEapMsChapV2UiDialog::GetHelpContext( TCoeHelpContext& aContext ) const |
|
505 { |
|
506 aContext.iMajor = KHelpUidPlugin; |
|
507 if( iConnection->GetBearerEAPType() == KEapMsChapv2Id ) |
|
508 { |
|
509 aContext.iContext = KSET_HLP_WLAN_EAP_MSCHAPV2; |
|
510 } |
|
511 else |
|
512 { |
|
513 aContext.iContext = KSET_HLP_WLAN_EAP_PLAIN_MSCHAP; |
|
514 } |
|
515 } |
|
516 |
|
517 |
|
518 // End of File |
|