|
1 /* |
|
2 * Copyright (c) 2002 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: Setting item list class for Network setting list view.* |
|
15 */ |
|
16 |
|
17 |
|
18 // Version : %version: 6 % |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <eikappui.h> |
|
25 #include <MediaSettings.rsg> |
|
26 #include <barsread.h> |
|
27 |
|
28 #include <cmmanagerext.h> |
|
29 #include <cmdestinationext.h> |
|
30 #include <cmapplicationsettingsui.h> |
|
31 |
|
32 #include "mediasettings.hrh" |
|
33 #include "MPSettingsNetworkSettingItemList.h" |
|
34 #include "MPSettingsSliderSettingItem.h" |
|
35 #include "MPSettingsUDPPortSettingItem.h" |
|
36 #include "MPSettingsModelForROP.h" |
|
37 #include "mpxlog.h" |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CMPSettingsNetworkSettingItemList::CMPSettingsNetworkSettingItemList |
|
43 // C++ default constructor can NOT contain any code, that |
|
44 // might leave. |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CMPSettingsNetworkSettingItemList::CMPSettingsNetworkSettingItemList(CMPSettingsModelForROP* aModel) |
|
48 : iModel( aModel) |
|
49 { |
|
50 MPX_FUNC("#MS# CMPSettingsNetworkSettingItemList::CMPSettingsNetworkSettingItemList()"); |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CMPSettingsNetworkSettingItemList::ConstructFromResourceL |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CMPSettingsNetworkSettingItemList::ConstructFromResourceL(TInt aResourceId) |
|
58 { |
|
59 MPX_DEBUG2(_L("#MS# CMPSettingsNetworkSettingItemList::ConstructFromResourceL(0x%X)"),aResourceId); |
|
60 TResourceReader reader; |
|
61 iCoeEnv->CreateResourceReaderLC(reader, aResourceId); |
|
62 ConstructFromResourceL(reader); |
|
63 CleanupStack::PopAndDestroy(); // reader |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CMPSettingsNetworkSettingItemList::ConstructFromResourceL |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CMPSettingsNetworkSettingItemList::ConstructFromResourceL(TResourceReader& aReader) |
|
71 { |
|
72 MPX_FUNC("#MS# CMPSettingsNetworkSettingItemList::ConstructFromResourceL()"); |
|
73 LoadAllL(); |
|
74 CAknSettingItemList::ConstructFromResourceL(aReader); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CMPSettingsNetworkSettingItemList::~CMPSettingsNetworkSettingItemList |
|
79 // Destructor |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CMPSettingsNetworkSettingItemList::~CMPSettingsNetworkSettingItemList() |
|
83 { |
|
84 MPX_FUNC("#MS# CMPSettingsNetworkSettingItemList::~CMPSettingsNetworkSettingItemList()"); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CMPSettingsNetworkSettingItemList::EditItemL |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CMPSettingsNetworkSettingItemList::EditItemL(TInt aIndex, TBool aCalledFromMenu) |
|
92 { |
|
93 MPX_DEBUG3(_L("#MS# CMPSettingsNetworkSettingItemList::EditItemL(%d,%d)"),aIndex,aCalledFromMenu); |
|
94 CAknSettingItem* settingItem = SettingItemArray()->At(aIndex); |
|
95 TInt identifier = settingItem->Identifier(); |
|
96 |
|
97 if ( identifier == EMPSettDefaultAPSettingId ) |
|
98 { |
|
99 LaunchConnectionSelectionL(); |
|
100 } |
|
101 else |
|
102 { |
|
103 // Call base call's method |
|
104 CAknSettingItemList::EditItemL(aIndex, aCalledFromMenu); |
|
105 } |
|
106 |
|
107 // Store setting value to settings model |
|
108 settingItem->StoreL(); |
|
109 StoreSettingL(identifier); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CMPSettingsNetworkSettingItemList::CreateSettingItemL |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 CAknSettingItem* CMPSettingsNetworkSettingItemList::CreateSettingItemL(TInt aSettingId) |
|
117 { |
|
118 MPX_DEBUG2(_L("#MS# CMPSettingsNetworkSettingItemList::CreateSettingItemL(%d)"),aSettingId); |
|
119 CAknSettingItem* settingItem = NULL; |
|
120 |
|
121 switch (aSettingId) |
|
122 { |
|
123 case EMPSettDefaultAPSettingId: |
|
124 iSettingConnectionItem = new (ELeave) CAknTextSettingItem( aSettingId, iSelectedApName); |
|
125 settingItem = iSettingConnectionItem; |
|
126 break; |
|
127 |
|
128 /*case EMPSettConnTimeoutSettingId: |
|
129 settingItem = new(ELeave) CMPSettingsSliderSettingItem(aSettingId, iConnTimeout, |
|
130 R_MPSETT_TIMEOUT_SLIDER); |
|
131 break; |
|
132 case EMPSettServerTimeoutSettingId: |
|
133 settingItem = new(ELeave) CMPSettingsSliderSettingItem(aSettingId, iSrvTimeout, |
|
134 R_MPSETT_TIMEOUT_SLIDER); |
|
135 break;*/ |
|
136 case EMPSettMinUDPPortSettingId: |
|
137 settingItem = new(ELeave) CMPSettingsUDPPortSettingItem(aSettingId, iMinUDPPort, iMaxUDPPort); |
|
138 break; |
|
139 case EMPSettMaxUDPPortSettingId: |
|
140 settingItem = new(ELeave) CMPSettingsUDPPortSettingItem(aSettingId, iMaxUDPPort, iMinUDPPort); |
|
141 break; |
|
142 default: |
|
143 break; |
|
144 } |
|
145 |
|
146 return settingItem; |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CMPSettingsNetworkSettingItemList::LoadAllL |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CMPSettingsNetworkSettingItemList::LoadAllL() |
|
154 { |
|
155 MPX_FUNC("#MS# CMPSettingsNetworkSettingItemList::LoadAllL()"); |
|
156 iModel->LoadSettingsL(EConfigUser); |
|
157 LoadSettingL(EMPSettDefaultAPSettingId); |
|
158 LoadSettingL(EMPSettConnTimeoutSettingId); |
|
159 LoadSettingL(EMPSettServerTimeoutSettingId); |
|
160 LoadSettingL(EMPSettMinUDPPortSettingId); |
|
161 LoadSettingL(EMPSettMaxUDPPortSettingId); |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CMPSettingsNetworkSettingItemList::LoadSettingL |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CMPSettingsNetworkSettingItemList::LoadSettingL(TInt aSettingId) |
|
169 { |
|
170 MPX_DEBUG2(_L("#MS# CMPSettingsNetworkSettingItemList::LoadSettingL(%d)"),aSettingId); |
|
171 switch (aSettingId) |
|
172 { |
|
173 case EMPSettDefaultAPSettingId: |
|
174 { |
|
175 iModel->GetDefaultAp( iDefaultAP ); |
|
176 |
|
177 if ( iDefaultAP != 0 ) |
|
178 { |
|
179 RCmManagerExt cmManager; |
|
180 CleanupClosePushL( cmManager ); |
|
181 cmManager.OpenL(); |
|
182 |
|
183 HBufC* tmpBuf = cmManager.GetConnectionMethodInfoStringL( iDefaultAP, CMManager::ECmName); |
|
184 if( tmpBuf && tmpBuf->Length() < KMaxApNameLength ) |
|
185 { |
|
186 iSelectedApName = *tmpBuf; |
|
187 } |
|
188 CleanupStack::PopAndDestroy( &cmManager ); |
|
189 } |
|
190 } |
|
191 break; |
|
192 case EMPSettConnTimeoutSettingId: |
|
193 iModel->GetConnectionTimeout(iConnTimeout); |
|
194 break; |
|
195 case EMPSettServerTimeoutSettingId: |
|
196 iModel->GetServerTimeout(iSrvTimeout); |
|
197 break; |
|
198 case EMPSettMinUDPPortSettingId: |
|
199 iModel->GetMinUDPPort(iMinUDPPort); |
|
200 break; |
|
201 case EMPSettMaxUDPPortSettingId: |
|
202 iModel->GetMaxUDPPort(iMaxUDPPort); |
|
203 break; |
|
204 default: |
|
205 break; |
|
206 } |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CMPSettingsNetworkSettingItemList::StoreSettingL |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void CMPSettingsNetworkSettingItemList::StoreSettingL(TInt aSettingId) |
|
214 { |
|
215 MPX_DEBUG2(_L("#MS# CMPSettingsNetworkSettingItemList::StoreSettingL(%d)"),aSettingId); |
|
216 switch (aSettingId) |
|
217 { |
|
218 case EMPSettDefaultAPSettingId: |
|
219 iModel->SetDefaultAp(iDefaultAP); |
|
220 break; |
|
221 case EMPSettConnTimeoutSettingId: |
|
222 iModel->SetConnectionTimeout(iConnTimeout); |
|
223 break; |
|
224 case EMPSettServerTimeoutSettingId: |
|
225 iModel->SetServerTimeout(iSrvTimeout); |
|
226 break; |
|
227 case EMPSettMinUDPPortSettingId: |
|
228 iModel->SetMinUDPPort(iMinUDPPort); |
|
229 break; |
|
230 case EMPSettMaxUDPPortSettingId: |
|
231 iModel->SetMaxUDPPort(iMaxUDPPort); |
|
232 break; |
|
233 default: |
|
234 break; |
|
235 } |
|
236 |
|
237 iModel->StoreSettingsL(); |
|
238 } |
|
239 |
|
240 // -------------------------------------------------------------------------- |
|
241 // CMPSettingsNetworkSettingItemList::HandleListBoxEventL() |
|
242 // -------------------------------------------------------------------------- |
|
243 // |
|
244 void CMPSettingsNetworkSettingItemList::HandleListBoxEventL( |
|
245 CEikListBox* aListBox, |
|
246 TListBoxEvent aListBoxEvent ) |
|
247 { |
|
248 if ( ( aListBoxEvent == EEventEnterKeyPressed ) || |
|
249 ( aListBoxEvent == EEventItemSingleClicked ) || |
|
250 ( aListBoxEvent == EEventItemDoubleClicked ) ) |
|
251 { |
|
252 CAknSettingItemList::HandleListBoxEventL( aListBox, aListBoxEvent ); |
|
253 } |
|
254 } |
|
255 |
|
256 // -------------------------------------------------------------------------- |
|
257 // CMPSettingsNetworkSettingItemList::LaunchConnectionSelectionL() |
|
258 // -------------------------------------------------------------------------- |
|
259 // |
|
260 void CMPSettingsNetworkSettingItemList::LaunchConnectionSelectionL() |
|
261 { |
|
262 MPX_FUNC("#MS# CMPSettingsNetworkSettingItemList::LaunchConnectionSelectionL()"); |
|
263 |
|
264 CCmApplicationSettingsUi* settingsUi = CCmApplicationSettingsUi::NewL(); |
|
265 CleanupStack::PushL ( settingsUi ); |
|
266 |
|
267 TCmSettingSelection selection; |
|
268 selection.iId = 0; // iSettingUsedSnapId; |
|
269 selection.iResult = CMManager::EDestination; |
|
270 |
|
271 TUint listItems = CMManager::EShowConnectionMethods; |
|
272 |
|
273 TBearerFilterArray filters; |
|
274 |
|
275 TBool retVal = settingsUi->RunApplicationSettingsL( selection, listItems, filters ); |
|
276 |
|
277 if ( retVal ) |
|
278 { |
|
279 switch ( selection.iResult ) |
|
280 { |
|
281 case CMManager::EDestination: |
|
282 case CMManager::EAlwaysAsk: |
|
283 break; |
|
284 |
|
285 case CMManager::EConnectionMethod: |
|
286 { |
|
287 iDefaultAP = selection.iId; |
|
288 } |
|
289 break; |
|
290 |
|
291 default: |
|
292 break; |
|
293 } |
|
294 |
|
295 UpdateSelectedConnectionNameL( ); |
|
296 |
|
297 if ( iSettingConnectionItem ) |
|
298 { |
|
299 iSettingConnectionItem->LoadL ( ); |
|
300 iSettingConnectionItem->UpdateListBoxTextL ( ); |
|
301 } |
|
302 DrawDeferred(); |
|
303 } |
|
304 |
|
305 CleanupStack::PopAndDestroy ( settingsUi ); |
|
306 } |
|
307 |
|
308 // -------------------------------------------------------------------------- |
|
309 // CMPSettingsNetworkSettingItemList::UpdateSelectedConnectionNameL |
|
310 // -------------------------------------------------------------------------- |
|
311 // |
|
312 void CMPSettingsNetworkSettingItemList::UpdateSelectedConnectionNameL() |
|
313 { |
|
314 MPX_FUNC("#MS# CMPSettingsNetworkSettingItemList::UpdateSelectedConnectionNameL()"); |
|
315 |
|
316 RCmManagerExt cmManager; |
|
317 RCmConnectionMethodExt connMethod; |
|
318 |
|
319 CleanupClosePushL( cmManager ); |
|
320 CleanupClosePushL( connMethod ); |
|
321 |
|
322 cmManager.OpenL(); |
|
323 |
|
324 // This leaves if conn method is not found. |
|
325 TRAPD( leave, connMethod = cmManager.ConnectionMethodL( iDefaultAP ) ); |
|
326 if ( KErrNone == leave ) |
|
327 { |
|
328 // HBufC* tmpBuf = destination.NameLC(); |
|
329 HBufC* tmpBuf = cmManager.GetConnectionMethodInfoStringL( iDefaultAP, CMManager::ECmName); |
|
330 |
|
331 if( tmpBuf && tmpBuf->Length() < KMaxApNameLength ) |
|
332 { |
|
333 iSelectedApName = *tmpBuf; |
|
334 } |
|
335 } |
|
336 |
|
337 CleanupStack::PopAndDestroy( &connMethod ); |
|
338 CleanupStack::PopAndDestroy( &cmManager ); |
|
339 } |
|
340 // End of File |