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 "irnetworkcontroller.h" |
|
28 #include "iraap.hlp.hrh" |
|
29 #include "irdebug.h" // PC-Lint comments :: SPP |
|
30 |
|
31 #define KUIDIRAPP 0x2000B499 |
|
32 const TUid KIRMCVUid = {KUIDIRAPP}; |
|
33 |
|
34 |
|
35 // ======== LOCAL FUNCTIONS ======== |
|
36 |
|
37 // ======== MEMBER FUNCTIONS ======== |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // NewL() |
|
41 // Two-phased constructor. |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 EXPORT_C CIRCommonSettingsContainer* CIRCommonSettingsContainer::NewL() |
|
45 { |
|
46 IRLOG_DEBUG( "CIRCommonSettingsContainer::NewL - Entering" ); |
|
47 CIRCommonSettingsContainer* self = new ( ELeave ) CIRCommonSettingsContainer(/*aAccessPointList, aDefaultAccessPoint*/); |
|
48 CleanupStack::PushL( self ); |
|
49 self->BaseConstructL(); |
|
50 CleanupStack::Pop( self ); |
|
51 IRLOG_DEBUG( "CIRCommonSettingsContainer::NewL - Exiting" ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Constructor. |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CIRCommonSettingsContainer::CIRCommonSettingsContainer( ) |
|
60 { |
|
61 IRLOG_DEBUG( "CIRCommonSettingsContainer::CIRCommonSettingsContainer" ); |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // BaseConstructL() |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C void CIRCommonSettingsContainer::BaseConstructL() |
|
69 { |
|
70 IRLOG_DEBUG( "CIRCommonSettingsContainer::BaseConstructL - Entering" ); |
|
71 iNetworkController = CIRNetworkController::OpenL(); |
|
72 iIRSettings = CIRSettings::OpenL(); |
|
73 iDestinationSelected = EFalse; |
|
74 SetListBoxTextL() ; |
|
75 IRLOG_DEBUG( "CIRCommonSettingsContainer::BaseConstructL - Exiting" ); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // Destructor. |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C CIRCommonSettingsContainer::~CIRCommonSettingsContainer() |
|
83 { |
|
84 IRLOG_DEBUG( "CIRCommonSettingsContainer::~CIRCommonSettingsContainer - Entering" ); |
|
85 if(iIRSettings) |
|
86 { |
|
87 iIRSettings->Close(); |
|
88 iIRSettings = NULL; |
|
89 } |
|
90 if(iNetworkController) |
|
91 { |
|
92 iNetworkController->Close(); |
|
93 iNetworkController = NULL; |
|
94 } |
|
95 IRLOG_DEBUG( "CIRCommonSettingsContainer::~CIRCommonSettingsContainer - Exiting" ); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // EditCurrentItemL() |
|
100 // Starts editing of the current item. |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CIRCommonSettingsContainer::EditCurrentItemL( TBool aCalledFromMenu ) |
|
104 { |
|
105 IRLOG_DEBUG( "CIRCommonSettingsContainer::EditCurrentItemL - Entering" ); |
|
106 EditItemL( ListBox()->CurrentItemIndex(), aCalledFromMenu ); |
|
107 DrawDeferred(); |
|
108 IRLOG_DEBUG( "CIRCommonSettingsContainer::EditCurrentItemL - Exiting" ); |
|
109 } |
|
110 |
|
111 TInt CIRCommonSettingsContainer::GetCurrentSelection() |
|
112 { |
|
113 IRLOG_DEBUG( "CIRCommonSettingsContainer::GetCurrentSelection - Entering" ); |
|
114 TInt current = ListBox()->CurrentItemIndex(); |
|
115 IRLOG_DEBUG( "CIRCommonSettingsContainer::GetCurrentSelection - Exiting" ); |
|
116 if((current >= 0) && (current < SettingItemArray()->Count())) |
|
117 { |
|
118 return SettingItemArray()->At( current )->Identifier(); |
|
119 } |
|
120 else |
|
121 { |
|
122 return 0; |
|
123 } |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CreateSettingItemL() |
|
128 // From CAknSettingItemList. |
|
129 // Creates a setting item based upon the user id aSettingId |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C CAknSettingItem* CIRCommonSettingsContainer::CreateSettingItemL( TInt aSettingId ) |
|
133 { |
|
134 IRLOG_DEBUG( "CIRCommonSettingsContainer::CreateSettingItemL - Entering" ); |
|
135 CAknSettingItem* item = NULL; |
|
136 |
|
137 switch ( aSettingId ) |
|
138 { |
|
139 case EIRSettingItemSnapSelectionID: |
|
140 { |
|
141 iAccessPointIndex = 0; |
|
142 // Need to use this class later |
|
143 item = new (ELeave) CAknEnumeratedTextPopupSettingItem(aSettingId, |
|
144 iAccessPointIndex); |
|
145 } |
|
146 break; |
|
147 |
|
148 case EIRSettingItemGprsConnBitRateID: |
|
149 { |
|
150 iGprsBitRateIndex = 0; |
|
151 item = new (ELeave) CAknEnumeratedTextPopupSettingItem(aSettingId, |
|
152 iGprsBitRateIndex); |
|
153 iGprsBitRateIndex = iIRSettings->GetGPRSBitrateQuality(); |
|
154 } |
|
155 break; |
|
156 |
|
157 case EIRSettingItem3GConnBitRateID: |
|
158 { |
|
159 i3GBitRateIndex = 0; |
|
160 item = new (ELeave) CAknEnumeratedTextPopupSettingItem(aSettingId, |
|
161 i3GBitRateIndex); |
|
162 i3GBitRateIndex = iIRSettings->Get3GBitrateQuality(); |
|
163 } |
|
164 break; |
|
165 |
|
166 case EIRSettingItemWiFiConnBitRateID: |
|
167 { |
|
168 iWifiBitRateIndex = 0; |
|
169 item = new (ELeave) CAknEnumeratedTextPopupSettingItem(aSettingId, |
|
170 iWifiBitRateIndex); |
|
171 iWifiBitRateIndex = iIRSettings->GetWiFiBitrateQuality(); |
|
172 } |
|
173 break; |
|
174 |
|
175 default: |
|
176 break; |
|
177 } |
|
178 |
|
179 LoadSettingsL(); |
|
180 IRLOG_DEBUG( "CIRCommonSettingsContainer::CreateSettingItemL - Exiting" ); |
|
181 return item; |
|
182 |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // EditItemL() |
|
187 // Called when an item is being edited. |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 |
|
191 EXPORT_C void CIRCommonSettingsContainer::EditItemL( TInt aIndex, TBool aCalledFromMenu ) |
|
192 { |
|
193 IRLOG_DEBUG( "CIRCommonSettingsContainer::EditItemL - Entering" ); |
|
194 if((aIndex >= 0) && (aIndex < SettingItemArray()->Count())) |
|
195 { |
|
196 TInt settingId = SettingItemArray()->At( aIndex )->Identifier(); |
|
197 |
|
198 switch ( settingId ) |
|
199 { |
|
200 case EIRSettingItemGprsConnBitRateID: |
|
201 { |
|
202 CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); |
|
203 SettingItemArray()->At( aIndex )->StoreL(); |
|
204 iIRSettings->SetGPRSBitrateQualityL(iGprsBitRateIndex); |
|
205 break; |
|
206 } |
|
207 case EIRSettingItem3GConnBitRateID: |
|
208 { |
|
209 CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); |
|
210 SettingItemArray()->At( aIndex )->StoreL(); |
|
211 iIRSettings->Set3GBitrateQualityL(i3GBitRateIndex); |
|
212 break; |
|
213 } |
|
214 case EIRSettingItemWiFiConnBitRateID: |
|
215 { |
|
216 CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); |
|
217 SettingItemArray()->At( aIndex )->StoreL(); |
|
218 iIRSettings->SetWiFiBitrateQualityL(iWifiBitRateIndex); |
|
219 break; |
|
220 } |
|
221 case EIRSettingItemSnapSelectionID: |
|
222 { |
|
223 ShowConnectionSettingsUiL(); |
|
224 break; |
|
225 } |
|
226 default: |
|
227 break; |
|
228 } |
|
229 IRLOG_DEBUG( "CIRCommonSettingsContainer::EditItemL - Exiting" ); |
|
230 } |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // Gets the help context. |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 EXPORT_C void CIRCommonSettingsContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
238 { |
|
239 IRLOG_DEBUG( "CIRCommonSettingsContainer::GetHelpContext - Entering" ); |
|
240 aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_SETTINGS ); |
|
241 IRLOG_DEBUG( "CIRCommonSettingsContainer::GetHelpContext - Exiting" ); |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CIRCommonSettingsContainer::SizeChanged |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 EXPORT_C void CIRCommonSettingsContainer::SizeChanged() |
|
249 { |
|
250 IRLOG_DEBUG( "CIRCommonSettingsContainer::SizeChanged - Entering" ); |
|
251 CAknSettingItemList::SizeChanged(); |
|
252 CEikListBox* lb = ListBox(); |
|
253 if( lb ) |
|
254 { |
|
255 lb->SetRect( Rect() ); // Needed to update listbox after portrait-landscape change |
|
256 } |
|
257 IRLOG_DEBUG( "CIRCommonSettingsContainer::SizeChanged - Exiting" ); |
|
258 } |
|
259 |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // ShowConnectionSettingsUiL |
|
263 // Displays the connection settings ui |
|
264 // --------------------------------------------------------------------------- |
|
265 // |
|
266 void CIRCommonSettingsContainer::ShowConnectionSettingsUiL() |
|
267 { |
|
268 IRLOG_DEBUG( "CIRCommonSettingsContainer::ShowConnectionSettingsUiL - Entering" ); |
|
269 SetListBoxTextL(); |
|
270 IRLOG_DEBUG( "CIRCommonSettingsContainer::ShowConnectionSettingsUiL - Exiting" ); |
|
271 } |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // UpdateStatusL() |
|
279 // Fetches the new settings values from iIRSettings and updates the list |
|
280 // --------------------------------------------------------------------------- |
|
281 // |
|
282 void CIRCommonSettingsContainer::UpdateStatusL() |
|
283 { |
|
284 IRLOG_DEBUG( "CIRCommonSettingsContainer::UpdateStatusL - Entering" ); |
|
285 iGprsBitRateIndex = iIRSettings->GetGPRSBitrateQuality(); |
|
286 i3GBitRateIndex = iIRSettings->Get3GBitrateQuality(); |
|
287 iWifiBitRateIndex = iIRSettings->GetWiFiBitrateQuality(); |
|
288 LoadSettingsL(); |
|
289 SetListBoxTextL(); |
|
290 IRLOG_DEBUG( "CIRCommonSettingsContainer::UpdateStatusL - Exiting" ); |
|
291 } |
|
292 |
|
293 |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // SetAccessPointDetailsL() |
|
297 // Sets the details of the chosen IAP in cenrep |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 void CIRCommonSettingsContainer::SetAccessPointDetailsL(TUint aId) |
|
301 { |
|
302 IRLOG_DEBUG( "CIRCommonSettingsContainer::SetAccessPointDetailsL - Entering" ); |
|
303 //Get All the bearer IDs(RArray) |
|
304 const RArray<TUint32>& bearerIDArray = iNetworkController->GetBearerList(); |
|
305 const RArray<TUint32>& networkIDArray = iNetworkController->GetNetworkList(); |
|
306 const RArray<TUint32>& accessPointIDArray = iNetworkController->GetApList(); |
|
307 |
|
308 TInt index =0; |
|
309 //Get access point index, that matches the access point stored in |
|
310 // settings previously |
|
311 for(TInt i=0; i<accessPointIDArray.Count(); i++ ) |
|
312 { |
|
313 if(accessPointIDArray[i] == aId ) |
|
314 { |
|
315 index = i; |
|
316 } |
|
317 } |
|
318 |
|
319 TUint32 bearerId = bearerIDArray[index]; |
|
320 TUint32 networkId = networkIDArray[index]; |
|
321 TUint32 accessPointId = accessPointIDArray[index]; |
|
322 |
|
323 IRLOG_DEBUG( "CIRCommonSettingsContainer::SetAccessPointDetailsL - Exiting" ); |
|
324 } |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // SetListBoxTextL() |
|
328 // Sets the text of the Network Selection in the Settings UI |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 void CIRCommonSettingsContainer::SetListBoxTextL() |
|
332 { |
|
333 IRLOG_DEBUG( "CIRCommonSettingsContainer::SetListBoxTextL - Entering" ); |
|
334 |
|
335 IRLOG_DEBUG( "CIRCommonSettingsContainer::SetListBoxTextL - Exiting" ); |
|
336 } |
|
337 |
|
338 |
|
339 |
|
340 // ======== GLOBAL FUNCTIONS ======== |
|
341 |
|