|
1 /* |
|
2 * Copyright (c) 2006-2006 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 "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: Container class for the settings UI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aknnotewrappers.h> |
|
20 #include <e32property.h> |
|
21 #include <stringloader.h> |
|
22 #include <akntitle.h> |
|
23 #include <cmmanager.h> |
|
24 #include <cmdestination.h> |
|
25 #include "ircommonsettingscontainer.h" |
|
26 #include "ir.hrh" |
|
27 #include <internetradio.rsg> |
|
28 #include "irnetworkcontroller.h" |
|
29 #include "iraap.hlp.hrh" |
|
30 #include "irdebug.h" // PC-Lint comments :: SPP |
|
31 |
|
32 #define KUIDIRAPP 0x2000B499 |
|
33 const TUid KIRMCVUid = {KUIDIRAPP}; |
|
34 |
|
35 const TInt KBufSize = 256; |
|
36 |
|
37 // ======== LOCAL FUNCTIONS ======== |
|
38 |
|
39 // ======== MEMBER FUNCTIONS ======== |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // NewL() |
|
43 // Two-phased constructor. |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C CIRCommonSettingsContainer* CIRCommonSettingsContainer::NewL() |
|
47 { |
|
48 IRLOG_DEBUG( "CIRCommonSettingsContainer::NewL - Entering" ); |
|
49 CIRCommonSettingsContainer* self = new ( ELeave ) CIRCommonSettingsContainer(/*aAccessPointList, aDefaultAccessPoint*/); |
|
50 CleanupStack::PushL( self ); |
|
51 self->BaseConstructL(); |
|
52 CleanupStack::Pop( self ); |
|
53 IRLOG_DEBUG( "CIRCommonSettingsContainer::NewL - Exiting" ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Constructor. |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C CIRCommonSettingsContainer::CIRCommonSettingsContainer( ) |
|
62 { |
|
63 IRLOG_DEBUG( "CIRCommonSettingsContainer::CIRCommonSettingsContainer" ); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // BaseConstructL() |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 EXPORT_C void CIRCommonSettingsContainer::BaseConstructL() |
|
71 { |
|
72 IRLOG_DEBUG( "CIRCommonSettingsContainer::BaseConstructL - Entering" ); |
|
73 iNetworkController = CIRNetworkController::OpenL(); |
|
74 iIRSettings = CIRSettings::OpenL(); |
|
75 ConstructFromResourceL( R_IR_SETTING_LIST ); |
|
76 iDestinationSelected = EFalse; |
|
77 SetListBoxTextL() ; |
|
78 IRLOG_DEBUG( "CIRCommonSettingsContainer::BaseConstructL - Exiting" ); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Destructor. |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C CIRCommonSettingsContainer::~CIRCommonSettingsContainer() |
|
86 { |
|
87 IRLOG_DEBUG( "CIRCommonSettingsContainer::~CIRCommonSettingsContainer - Entering" ); |
|
88 if(iIRSettings) |
|
89 { |
|
90 iIRSettings->Close(); |
|
91 iIRSettings = NULL; |
|
92 } |
|
93 if(iNetworkController) |
|
94 { |
|
95 iNetworkController->Close(); |
|
96 iNetworkController = NULL; |
|
97 } |
|
98 IRLOG_DEBUG( "CIRCommonSettingsContainer::~CIRCommonSettingsContainer - Exiting" ); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // EditCurrentItemL() |
|
103 // Starts editing of the current item. |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CIRCommonSettingsContainer::EditCurrentItemL( TBool aCalledFromMenu ) |
|
107 { |
|
108 IRLOG_DEBUG( "CIRCommonSettingsContainer::EditCurrentItemL - Entering" ); |
|
109 EditItemL( ListBox()->CurrentItemIndex(), aCalledFromMenu ); |
|
110 DrawDeferred(); |
|
111 IRLOG_DEBUG( "CIRCommonSettingsContainer::EditCurrentItemL - Exiting" ); |
|
112 } |
|
113 |
|
114 TInt CIRCommonSettingsContainer::GetCurrentSelection() |
|
115 { |
|
116 IRLOG_DEBUG( "CIRCommonSettingsContainer::GetCurrentSelection - Entering" ); |
|
117 TInt current = ListBox()->CurrentItemIndex(); |
|
118 IRLOG_DEBUG( "CIRCommonSettingsContainer::GetCurrentSelection - Exiting" ); |
|
119 if((current >= 0) && (current < SettingItemArray()->Count())) |
|
120 { |
|
121 return SettingItemArray()->At( current )->Identifier(); |
|
122 } |
|
123 else |
|
124 { |
|
125 return 0; |
|
126 } |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // CreateSettingItemL() |
|
131 // From CAknSettingItemList. |
|
132 // Creates a setting item based upon the user id aSettingId |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C CAknSettingItem* CIRCommonSettingsContainer::CreateSettingItemL( TInt aSettingId ) |
|
136 { |
|
137 IRLOG_DEBUG( "CIRCommonSettingsContainer::CreateSettingItemL - Entering" ); |
|
138 CAknSettingItem* item = NULL; |
|
139 |
|
140 switch ( aSettingId ) |
|
141 { |
|
142 case EIRSettingItemSnapSelectionID: |
|
143 { |
|
144 iAccessPointIndex = 0; |
|
145 // Need to use this class later |
|
146 item = new (ELeave) CAknEnumeratedTextPopupSettingItem(aSettingId, |
|
147 iAccessPointIndex); |
|
148 } |
|
149 break; |
|
150 |
|
151 case EIRSettingItemGprsConnBitRateID: |
|
152 { |
|
153 iGprsBitRateIndex = 0; |
|
154 item = new (ELeave) CAknEnumeratedTextPopupSettingItem(aSettingId, |
|
155 iGprsBitRateIndex); |
|
156 iGprsBitRateIndex = iIRSettings->GetGPRSBitrateQuality(); |
|
157 } |
|
158 break; |
|
159 |
|
160 case EIRSettingItem3GConnBitRateID: |
|
161 { |
|
162 i3GBitRateIndex = 0; |
|
163 item = new (ELeave) CAknEnumeratedTextPopupSettingItem(aSettingId, |
|
164 i3GBitRateIndex); |
|
165 i3GBitRateIndex = iIRSettings->Get3GBitrateQuality(); |
|
166 } |
|
167 break; |
|
168 |
|
169 case EIRSettingItemWiFiConnBitRateID: |
|
170 { |
|
171 iWifiBitRateIndex = 0; |
|
172 item = new (ELeave) CAknEnumeratedTextPopupSettingItem(aSettingId, |
|
173 iWifiBitRateIndex); |
|
174 iWifiBitRateIndex = iIRSettings->GetWiFiBitrateQuality(); |
|
175 } |
|
176 break; |
|
177 |
|
178 default: |
|
179 break; |
|
180 } |
|
181 |
|
182 LoadSettingsL(); |
|
183 IRLOG_DEBUG( "CIRCommonSettingsContainer::CreateSettingItemL - Exiting" ); |
|
184 return item; |
|
185 |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // EditItemL() |
|
190 // Called when an item is being edited. |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 |
|
194 EXPORT_C void CIRCommonSettingsContainer::EditItemL( TInt aIndex, TBool aCalledFromMenu ) |
|
195 { |
|
196 IRLOG_DEBUG( "CIRCommonSettingsContainer::EditItemL - Entering" ); |
|
197 if((aIndex >= 0) && (aIndex < SettingItemArray()->Count())) |
|
198 { |
|
199 TInt settingId = SettingItemArray()->At( aIndex )->Identifier(); |
|
200 |
|
201 switch ( settingId ) |
|
202 { |
|
203 case EIRSettingItemGprsConnBitRateID: |
|
204 { |
|
205 CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); |
|
206 SettingItemArray()->At( aIndex )->StoreL(); |
|
207 iIRSettings->SetGPRSBitrateQualityL(iGprsBitRateIndex); |
|
208 break; |
|
209 } |
|
210 case EIRSettingItem3GConnBitRateID: |
|
211 { |
|
212 CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); |
|
213 SettingItemArray()->At( aIndex )->StoreL(); |
|
214 iIRSettings->Set3GBitrateQualityL(i3GBitRateIndex); |
|
215 break; |
|
216 } |
|
217 case EIRSettingItemWiFiConnBitRateID: |
|
218 { |
|
219 CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); |
|
220 SettingItemArray()->At( aIndex )->StoreL(); |
|
221 iIRSettings->SetWiFiBitrateQualityL(iWifiBitRateIndex); |
|
222 break; |
|
223 } |
|
224 case EIRSettingItemSnapSelectionID: |
|
225 { |
|
226 ShowConnectionSettingsUiL(); |
|
227 break; |
|
228 } |
|
229 default: |
|
230 break; |
|
231 } |
|
232 IRLOG_DEBUG( "CIRCommonSettingsContainer::EditItemL - Exiting" ); |
|
233 } |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // Gets the help context. |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 EXPORT_C void CIRCommonSettingsContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
241 { |
|
242 IRLOG_DEBUG( "CIRCommonSettingsContainer::GetHelpContext - Entering" ); |
|
243 aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_SETTINGS ); |
|
244 IRLOG_DEBUG( "CIRCommonSettingsContainer::GetHelpContext - Exiting" ); |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CIRCommonSettingsContainer::SizeChanged |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 EXPORT_C void CIRCommonSettingsContainer::SizeChanged() |
|
252 { |
|
253 IRLOG_DEBUG( "CIRCommonSettingsContainer::SizeChanged - Entering" ); |
|
254 CAknSettingItemList::SizeChanged(); |
|
255 CEikListBox* lb = ListBox(); |
|
256 if( lb ) |
|
257 { |
|
258 lb->SetRect( Rect() ); // Needed to update listbox after portrait-landscape change |
|
259 } |
|
260 IRLOG_DEBUG( "CIRCommonSettingsContainer::SizeChanged - Exiting" ); |
|
261 } |
|
262 |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // ShowConnectionSettingsUiL |
|
266 // Displays the connection settings ui |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 void CIRCommonSettingsContainer::ShowConnectionSettingsUiL() |
|
270 { |
|
271 IRLOG_DEBUG( "CIRCommonSettingsContainer::ShowConnectionSettingsUiL - Entering" ); |
|
272 TCmSettingSelection userSelection; |
|
273 userSelection.iResult = GetUserSelectionL() ; |
|
274 if(userSelection.iResult == EDestination) |
|
275 { |
|
276 userSelection.iId = iIRSettings->GetDestinationIdL(); |
|
277 } |
|
278 else if(userSelection.iResult == EConnectionMethod) |
|
279 { |
|
280 userSelection.iId = iIRSettings->GetApIdL(); |
|
281 } |
|
282 else |
|
283 { |
|
284 userSelection.iId =0; |
|
285 } |
|
286 |
|
287 CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL(); |
|
288 CleanupStack::PushL( settings ); |
|
289 |
|
290 TUint listedItems = EShowAlwaysAsk | EShowDefaultConnection | |
|
291 EShowDestinations | EShowConnectionMethods; |
|
292 |
|
293 TBearerFilterArray filter; |
|
294 TBool selected = EFalse; |
|
295 |
|
296 TRAPD( settingsErr, selected = settings->RunApplicationSettingsL( userSelection, |
|
297 listedItems, filter ) ); |
|
298 |
|
299 CleanupStack::PopAndDestroy( settings ); |
|
300 |
|
301 if((selected == EFalse) || (settingsErr != KErrNone) ) |
|
302 { |
|
303 return; |
|
304 } |
|
305 |
|
306 switch ( userSelection.iResult ) |
|
307 { |
|
308 case EAlwaysAsk: |
|
309 { |
|
310 iIRSettings->SetUserDefinedSelectionL(EUserSelectionAlwaysAsk); |
|
311 iIRSettings->SetDisplayAccessPointL(); |
|
312 break; |
|
313 } |
|
314 case EDefaultConnection: |
|
315 { |
|
316 iIRSettings->SetUserDefinedSelectionL(EUserSelectionDefaultConnection); |
|
317 break; |
|
318 } |
|
319 |
|
320 case EDestination: |
|
321 { |
|
322 iIRSettings->SetUserDefinedSelectionL(EUserSelectionDestination); |
|
323 iIRSettings->SetDestinationIdL(userSelection.iId); |
|
324 iDestinationSelected = ETrue; |
|
325 break; |
|
326 } |
|
327 |
|
328 case EConnectionMethod: |
|
329 { |
|
330 iIRSettings->SetUserDefinedSelectionL(EUserSelectionConnectionMethod); |
|
331 SetAccessPointDetailsL(userSelection.iId); |
|
332 iDestinationSelected = EFalse; |
|
333 break; |
|
334 } |
|
335 default: |
|
336 { |
|
337 break; |
|
338 } |
|
339 } |
|
340 SetListBoxTextL(); |
|
341 IRLOG_DEBUG( "CIRCommonSettingsContainer::ShowConnectionSettingsUiL - Exiting" ); |
|
342 } |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // UpdateStatusL() |
|
350 // Fetches the new settings values from iIRSettings and updates the list |
|
351 // --------------------------------------------------------------------------- |
|
352 // |
|
353 void CIRCommonSettingsContainer::UpdateStatusL() |
|
354 { |
|
355 IRLOG_DEBUG( "CIRCommonSettingsContainer::UpdateStatusL - Entering" ); |
|
356 iGprsBitRateIndex = iIRSettings->GetGPRSBitrateQuality(); |
|
357 i3GBitRateIndex = iIRSettings->Get3GBitrateQuality(); |
|
358 iWifiBitRateIndex = iIRSettings->GetWiFiBitrateQuality(); |
|
359 LoadSettingsL(); |
|
360 SetListBoxTextL(); |
|
361 IRLOG_DEBUG( "CIRCommonSettingsContainer::UpdateStatusL - Exiting" ); |
|
362 } |
|
363 |
|
364 |
|
365 // --------------------------------------------------------------------------- |
|
366 // GetUserSelectionL() |
|
367 // Queries the Settings and returns the user selected IAP/SNAP |
|
368 // --------------------------------------------------------------------------- |
|
369 // |
|
370 TCmSettingSelectionMode CIRCommonSettingsContainer::GetUserSelectionL() |
|
371 { |
|
372 IRLOG_DEBUG( "CIRCommonSettingsContainer::GetUserSelectionL - Entering" ); |
|
373 TUint32 userSelection; |
|
374 userSelection = iIRSettings->GetUserDefinedSelectionL(); |
|
375 TCmSettingSelectionMode ret = EAlwaysAsk; |
|
376 switch(userSelection) |
|
377 { |
|
378 case EUserSelectionAlwaysAsk: |
|
379 ret = EAlwaysAsk; |
|
380 break; |
|
381 |
|
382 case EUserSelectionDefaultConnection: |
|
383 ret = EDefaultConnection ; |
|
384 break; |
|
385 |
|
386 case EUserSelectionDestination: |
|
387 ret = EDestination; |
|
388 break; |
|
389 |
|
390 case EUserSelectionConnectionMethod: |
|
391 ret = EConnectionMethod; |
|
392 break; |
|
393 |
|
394 default: |
|
395 ret = EAlwaysAsk; |
|
396 break; |
|
397 |
|
398 } |
|
399 IRLOG_DEBUG( "CIRCommonSettingsContainer::GetUserSelectionL - Exiting" ); |
|
400 return ret; |
|
401 } |
|
402 |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // SetAccessPointDetailsL() |
|
406 // Sets the details of the chosen IAP in cenrep |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 void CIRCommonSettingsContainer::SetAccessPointDetailsL(TUint aId) |
|
410 { |
|
411 IRLOG_DEBUG( "CIRCommonSettingsContainer::SetAccessPointDetailsL - Entering" ); |
|
412 //Get All the bearer IDs(RArray) |
|
413 const RArray<TUint32>& bearerIDArray = iNetworkController->GetBearerList(); |
|
414 const RArray<TUint32>& networkIDArray = iNetworkController->GetNetworkList(); |
|
415 const RArray<TUint32>& accessPointIDArray = iNetworkController->GetApList(); |
|
416 |
|
417 TInt index =0; |
|
418 //Get access point index, that matches the access point stored in |
|
419 // settings previously |
|
420 for(TInt i=0; i<accessPointIDArray.Count(); i++ ) |
|
421 { |
|
422 if(accessPointIDArray[i] == aId ) |
|
423 { |
|
424 index = i; |
|
425 } |
|
426 } |
|
427 |
|
428 TUint32 bearerId = bearerIDArray[index]; |
|
429 TUint32 networkId = networkIDArray[index]; |
|
430 TUint32 accessPointId = accessPointIDArray[index]; |
|
431 |
|
432 //This stores the settings in Central Repository |
|
433 iIRSettings->SetUserSavedApSettingsL(bearerId, networkId,accessPointId); |
|
434 |
|
435 // Save the settings for use by IRNetworkContorller |
|
436 iIRSettings->SetBearerIdL(bearerId); |
|
437 iIRSettings->SetNetworkIdL(networkId); |
|
438 iIRSettings->SetApIdL(accessPointId); |
|
439 IRLOG_DEBUG( "CIRCommonSettingsContainer::SetAccessPointDetailsL - Exiting" ); |
|
440 } |
|
441 |
|
442 // --------------------------------------------------------------------------- |
|
443 // SetListBoxTextL() |
|
444 // Sets the text of the Network Selection in the Settings UI |
|
445 // --------------------------------------------------------------------------- |
|
446 // |
|
447 void CIRCommonSettingsContainer::SetListBoxTextL() |
|
448 { |
|
449 IRLOG_DEBUG( "CIRCommonSettingsContainer::SetListBoxTextL - Entering" ); |
|
450 if(SettingItemArray()->Count()>0) |
|
451 { |
|
452 switch(GetUserSelectionL()) |
|
453 { |
|
454 case EAlwaysAsk: |
|
455 { |
|
456 HBufC* stringholder = StringLoader::LoadLC( R_IR_ACCESS_ASK); |
|
457 SettingItemArray()->At( 0 )->SetEmptyItemTextL(*stringholder); |
|
458 CleanupStack::PopAndDestroy(stringholder); |
|
459 HandleChangeInItemArrayOrVisibilityL(); |
|
460 ActivateL(); |
|
461 break; |
|
462 } |
|
463 |
|
464 case EDefaultConnection: |
|
465 { |
|
466 HBufC* stringholder = StringLoader::LoadLC( R_IR_SETTINGS_SNAP_DEFAULT); |
|
467 SettingItemArray()->At( 0 )->SetEmptyItemTextL(*stringholder); |
|
468 CleanupStack::PopAndDestroy(stringholder); |
|
469 HandleChangeInItemArrayOrVisibilityL(); |
|
470 ActivateL(); |
|
471 break; |
|
472 } |
|
473 |
|
474 case EDestination: |
|
475 { |
|
476 RCmManager cmManager; |
|
477 cmManager.OpenL(); |
|
478 TRAPD(err, RCmDestination dest = cmManager.DestinationL( iIRSettings->GetDestinationIdL() )); |
|
479 if (err == KErrNone) |
|
480 { |
|
481 RCmDestination dest = cmManager.DestinationL(iIRSettings->GetDestinationIdL()); |
|
482 CleanupClosePushL( dest ); |
|
483 |
|
484 HBufC* destName = dest.NameLC(); |
|
485 TBuf<KBufSize> item; |
|
486 _LIT( KStringFormat, "%S" ); |
|
487 item.Format( KStringFormat,destName ); |
|
488 |
|
489 SettingItemArray()->At( 0 )->SetEmptyItemTextL(item); |
|
490 HandleChangeInItemArrayOrVisibilityL(); |
|
491 ActivateL(); |
|
492 CleanupStack::PopAndDestroy( destName ); // destName, dest |
|
493 CleanupStack::PopAndDestroy( &dest); |
|
494 } |
|
495 cmManager.Close(); |
|
496 break; |
|
497 } |
|
498 |
|
499 case EConnectionMethod: |
|
500 { |
|
501 if(!iDestinationSelected) |
|
502 { |
|
503 iIapArray = iNetworkController->GetAccessPointList(); |
|
504 const RArray<TUint32>& accessPointIDArray = iNetworkController->GetApList(); |
|
505 |
|
506 TInt index = 0; |
|
507 //Get access point index, that matches the access point stored in |
|
508 // settings previously |
|
509 for(TInt i=0; i<accessPointIDArray.Count(); i++ ) |
|
510 { |
|
511 if(accessPointIDArray[i] == iIRSettings->GetApIdL()) |
|
512 { |
|
513 index = i; |
|
514 } |
|
515 } |
|
516 TPtrC list; |
|
517 list.Set(iIapArray->MdcaPoint(index)); |
|
518 HBufC* itemText = HBufC::NewLC(list.Length()); |
|
519 itemText->Des().Copy(list); |
|
520 |
|
521 SettingItemArray()->At( 0 )->SetEmptyItemTextL(list); |
|
522 HandleChangeInItemArrayOrVisibilityL(); |
|
523 ActivateL(); |
|
524 CleanupStack::PopAndDestroy(itemText); |
|
525 } |
|
526 |
|
527 break; |
|
528 } |
|
529 default: |
|
530 break; |
|
531 |
|
532 } |
|
533 } |
|
534 IRLOG_DEBUG( "CIRCommonSettingsContainer::SetListBoxTextL - Exiting" ); |
|
535 } |
|
536 |
|
537 |
|
538 |
|
539 // ======== GLOBAL FUNCTIONS ======== |
|
540 |