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