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