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