|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // Version : %version: 3 % |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 // INCLUDE FILES |
|
25 #include <eikappui.h> |
|
26 #include <akntextsettingpage.h> |
|
27 #include <barsread.h> |
|
28 |
|
29 #include <cmmanagerext.h> |
|
30 #include <cmdestinationext.h> |
|
31 #include <cmapplicationsettingsui.h> |
|
32 |
|
33 #include "mediasettings.hrh" |
|
34 #include "MPSettingsStreamingSettingItemList.h" |
|
35 #include "MPSettingsUDPPortSettingItem.h" |
|
36 #include "MPSettingsModelForROP.h" |
|
37 #include "mpxlog.h" |
|
38 |
|
39 // CONSTANTS |
|
40 const TInt KMPSettProxyHostListItemId = 4; |
|
41 const TInt KMPSettProxyPortListItemId = 5; |
|
42 const TInt KMPSettProxyHostMaxLength = 1000; |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CMPSettingsStreamingSettingItemList::CMPSettingsStreamingSettingItemList |
|
48 // C++ default constructor can NOT contain any code, that |
|
49 // might leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CMPSettingsStreamingSettingItemList::CMPSettingsStreamingSettingItemList( |
|
53 CMPSettingsModelForROP* aModel ) |
|
54 : iModel( aModel), |
|
55 iProxyHostPtr(NULL, 0) |
|
56 { |
|
57 MPX_DEBUG1(_L("#MS# CMPSettingsStreamingSettingItemList::CMPSettingsStreamingSettingItemList()")); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CMPSettingsStreamingSettingItemList::ConstructFromResourceL |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CMPSettingsStreamingSettingItemList::ConstructFromResourceL(TInt aResourceId) |
|
65 { |
|
66 MPX_DEBUG2(_L("#MS# CMPSettingsStreamingSettingItemList::ConstructFromResourceL(0x%X)"),aResourceId); |
|
67 TResourceReader reader; |
|
68 iCoeEnv->CreateResourceReaderLC(reader, aResourceId); |
|
69 ConstructFromResourceL(reader); |
|
70 CleanupStack::PopAndDestroy(); // reader |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CMPSettingsStreamingSettingItemList::ConstructFromResourceL |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CMPSettingsStreamingSettingItemList::ConstructFromResourceL(TResourceReader& aReader) |
|
78 { |
|
79 MPX_DEBUG1(_L("#MS# CMPSettingsStreamingSettingItemList::ConstructFromResourceL()")); |
|
80 LoadAllL(); |
|
81 CAknSettingItemList::ConstructFromResourceL(aReader); |
|
82 SetItemVisibilityL(); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CMPSettingsStreamingSettingItemList::~CMPSettingsStreamingSettingItemList |
|
87 // Destructor |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CMPSettingsStreamingSettingItemList::~CMPSettingsStreamingSettingItemList() |
|
91 { |
|
92 MPX_DEBUG1(_L("#MS# CMPSettingsStreamingSettingItemList::~CMPSettingsStreamingSettingItemList()")); |
|
93 |
|
94 delete iProxyHost; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CMPSettingsStreamingSettingItemList::EditItemL |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CMPSettingsStreamingSettingItemList::EditItemL(TInt aIndex, TBool aCalledFromMenu) |
|
102 { |
|
103 MPX_DEBUG3(_L("#MS# CMPSettingsStreamingSettingItemList::EditItemL(%d,%d)"),aIndex,aCalledFromMenu); |
|
104 CAknSettingItem* settingItem = SettingItemArray()->At(aIndex); |
|
105 TInt identifier = settingItem->Identifier(); |
|
106 |
|
107 if ( identifier == EMPSettDefaultAPSettingId ) |
|
108 { |
|
109 LaunchConnectionSelectionL(); |
|
110 } |
|
111 else |
|
112 { |
|
113 // Call base call's method |
|
114 CAknSettingItemList::EditItemL(aIndex, aCalledFromMenu); |
|
115 } |
|
116 |
|
117 // Store setting value to settings model |
|
118 settingItem->StoreL(); |
|
119 StoreSettingL(identifier); |
|
120 |
|
121 // Hide/unhide Proxy port & Proxy host settings according to Proxy mode. |
|
122 if (identifier == EMPSettProxyModeSettingId || |
|
123 identifier == EMPSettDefaultAPSettingId ) |
|
124 { |
|
125 SetItemVisibilityL(); |
|
126 } |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CMPSettingsStreamingSettingItemList::CreateSettingItemL |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 CAknSettingItem* CMPSettingsStreamingSettingItemList::CreateSettingItemL(TInt aSettingId) |
|
134 { |
|
135 MPX_DEBUG2(_L("#MS# CMPSettingsStreamingSettingItemList::CreateSettingItemL(%d)"),aSettingId); |
|
136 __ASSERT_DEBUG(iProxyHost, User::Leave(KErrAbort)); |
|
137 |
|
138 CAknSettingItem* settingItem = NULL; |
|
139 |
|
140 switch ( aSettingId ) |
|
141 { |
|
142 case EMPSettProxyModeSettingId: |
|
143 iSettingProxyItem = new(ELeave) CAknBinaryPopupSettingItem( aSettingId, |
|
144 iProxyMode ); |
|
145 settingItem = iSettingProxyItem; |
|
146 break; |
|
147 |
|
148 case EMPSettProxyHostSettingId: |
|
149 { |
|
150 settingItem = new(ELeave) CAknTextSettingItem(aSettingId, iProxyHostPtr); |
|
151 settingItem->SetSettingPageFlags(CAknTextSettingPage::EZeroLengthAllowed); |
|
152 break; |
|
153 } |
|
154 |
|
155 case EMPSettProxyPortSettingId: |
|
156 settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aSettingId, iProxyPort); |
|
157 break; |
|
158 |
|
159 case EMPSettDefaultAPSettingId: |
|
160 iSettingConnectionItem = new (ELeave) CAknTextSettingItem( aSettingId, |
|
161 iSelectedApName ); |
|
162 settingItem = iSettingConnectionItem; |
|
163 break; |
|
164 |
|
165 case EMPSettMinUDPPortSettingId: |
|
166 settingItem = new(ELeave) CMPSettingsUDPPortSettingItem( aSettingId, |
|
167 iMinUDPPort, |
|
168 iMaxUDPPort); |
|
169 break; |
|
170 |
|
171 case EMPSettMaxUDPPortSettingId: |
|
172 settingItem = new(ELeave) CMPSettingsUDPPortSettingItem( aSettingId, |
|
173 iMaxUDPPort, |
|
174 iMinUDPPort); |
|
175 break; |
|
176 |
|
177 default: |
|
178 break; |
|
179 } |
|
180 |
|
181 return settingItem; |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CMPSettingsStreamingSettingItemList::SetItemVisibilityL |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 void CMPSettingsStreamingSettingItemList::SetItemVisibilityL() |
|
189 { |
|
190 MPX_DEBUG2(_L("#MS# CMPSettingsStreamingSettingItemList::SetItemVisibilityL() iProxyMode(%d)"),iProxyMode); |
|
191 SettingItemArray()->At(KMPSettProxyHostListItemId)->SetHidden( !iProxyMode ); |
|
192 SettingItemArray()->At(KMPSettProxyPortListItemId)->SetHidden( !iProxyMode ); |
|
193 |
|
194 HandleChangeInItemArrayOrVisibilityL(); |
|
195 |
|
196 if ( ListBox() ) |
|
197 { |
|
198 // Scrollbar update is required for the case when items are set hidden |
|
199 // while list is scrolled down. |
|
200 ListBox()->UpdateScrollBarsL(); |
|
201 } |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CMPSettingsStreamingSettingItemList::LoadAllL |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CMPSettingsStreamingSettingItemList::LoadAllL() |
|
209 { |
|
210 MPX_DEBUG1(_L("#MS# CMPSettingsStreamingSettingItemList::LoadAllL()")); |
|
211 iModel->LoadSettingsL(EConfigUser); |
|
212 LoadSettingL(EMPSettProxyModeSettingId); |
|
213 LoadSettingL(EMPSettProxyHostSettingId); |
|
214 LoadSettingL(EMPSettProxyPortSettingId); |
|
215 LoadSettingL(EMPSettDefaultAPSettingId); |
|
216 LoadSettingL(EMPSettMinUDPPortSettingId); |
|
217 LoadSettingL(EMPSettMaxUDPPortSettingId); |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // CMPSettingsStreamingSettingItemList::LoadSettingL |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 void CMPSettingsStreamingSettingItemList::LoadSettingL(TInt aSettingId) |
|
225 { |
|
226 MPX_DEBUG2(_L("#MS# CMPSettingsStreamingSettingItemList::LoadSettingL(%d)"),aSettingId); |
|
227 switch ( aSettingId ) |
|
228 { |
|
229 case EMPSettDefaultAPSettingId: |
|
230 { |
|
231 iModel->GetDefaultAp( iDefaultAP ); |
|
232 |
|
233 if ( iDefaultAP != 0 ) |
|
234 { |
|
235 UpdateSelectedConnectionNameL(); |
|
236 } |
|
237 } |
|
238 break; |
|
239 |
|
240 case EMPSettConnTimeoutSettingId: |
|
241 iModel->GetConnectionTimeout(iConnTimeout); |
|
242 break; |
|
243 |
|
244 case EMPSettServerTimeoutSettingId: |
|
245 iModel->GetServerTimeout(iSrvTimeout); |
|
246 break; |
|
247 |
|
248 case EMPSettMinUDPPortSettingId: |
|
249 iModel->GetMinUDPPort(iMinUDPPort); |
|
250 break; |
|
251 |
|
252 case EMPSettMaxUDPPortSettingId: |
|
253 iModel->GetMaxUDPPort(iMaxUDPPort); |
|
254 break; |
|
255 |
|
256 case EMPSettProxyModeSettingId: |
|
257 iModel->GetProxyMode(iProxyMode); |
|
258 break; |
|
259 |
|
260 case EMPSettProxyHostSettingId: |
|
261 { |
|
262 if (!iProxyHost) |
|
263 { |
|
264 iProxyHost = HBufC::NewL(KMPSettProxyHostMaxLength); |
|
265 iProxyHostPtr.Set(iProxyHost->Des()); |
|
266 } |
|
267 |
|
268 iModel->GetProxyHostName(iProxyHostPtr); |
|
269 break; |
|
270 } |
|
271 case EMPSettProxyPortSettingId: |
|
272 iModel->GetProxyPort(iProxyPort); |
|
273 break; |
|
274 |
|
275 default: |
|
276 break; |
|
277 } |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CMPSettingsStreamingSettingItemList::StoreSettingL |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void CMPSettingsStreamingSettingItemList::StoreSettingL(TInt aSettingId) |
|
285 { |
|
286 MPX_DEBUG2(_L("#MS# CMPSettingsStreamingSettingItemList::StoreSettingL(%d)"),aSettingId); |
|
287 switch (aSettingId) |
|
288 { |
|
289 case EMPSettDefaultAPSettingId: |
|
290 iModel->SetDefaultAp(iDefaultAP); |
|
291 break; |
|
292 case EMPSettConnTimeoutSettingId: |
|
293 iModel->SetConnectionTimeout(iConnTimeout); |
|
294 break; |
|
295 case EMPSettServerTimeoutSettingId: |
|
296 iModel->SetServerTimeout(iSrvTimeout); |
|
297 break; |
|
298 case EMPSettMinUDPPortSettingId: |
|
299 iModel->SetMinUDPPort(iMinUDPPort); |
|
300 break; |
|
301 case EMPSettMaxUDPPortSettingId: |
|
302 iModel->SetMaxUDPPort(iMaxUDPPort); |
|
303 break; |
|
304 case EMPSettProxyModeSettingId: |
|
305 iModel->SetProxyMode(iProxyMode); |
|
306 break; |
|
307 case EMPSettProxyHostSettingId: |
|
308 iModel->SetProxyHostNameL(*iProxyHost); |
|
309 break; |
|
310 case EMPSettProxyPortSettingId: |
|
311 iModel->SetProxyPort(iProxyPort); |
|
312 break; |
|
313 default: |
|
314 break; |
|
315 } |
|
316 |
|
317 iModel->StoreSettingsL(); |
|
318 } |
|
319 |
|
320 // -------------------------------------------------------------------------- |
|
321 // CMPSettingsStreamingSettingItemList::LaunchConnectionSelectionL() |
|
322 // -------------------------------------------------------------------------- |
|
323 // |
|
324 void CMPSettingsStreamingSettingItemList::LaunchConnectionSelectionL() |
|
325 { |
|
326 MPX_FUNC("#MS# CMPSettingsStreamingSettingItemList::LaunchConnectionSelectionL()"); |
|
327 |
|
328 CCmApplicationSettingsUi* settingsUi = CCmApplicationSettingsUi::NewL(); |
|
329 CleanupStack::PushL ( settingsUi ); |
|
330 |
|
331 TCmSettingSelection selection; |
|
332 selection.iId = iDefaultAP; |
|
333 selection.iResult = CMManager::EConnectionMethod; |
|
334 |
|
335 TUint listItems = CMManager::EShowConnectionMethods; |
|
336 TBearerFilterArray filters; |
|
337 |
|
338 TBool retVal = settingsUi->RunApplicationSettingsL( selection, listItems, filters ); |
|
339 if ( retVal ) |
|
340 { |
|
341 TBool iapChanged = EFalse; |
|
342 |
|
343 switch ( selection.iResult ) |
|
344 { |
|
345 case CMManager::EDestination: |
|
346 break; |
|
347 |
|
348 case CMManager::EAlwaysAsk: |
|
349 { |
|
350 iDefaultAP = 0; // Set AP to "None" |
|
351 } |
|
352 break; |
|
353 |
|
354 case CMManager::EConnectionMethod: |
|
355 { |
|
356 if ( selection.iId != iDefaultAP) |
|
357 { |
|
358 iDefaultAP = selection.iId; |
|
359 iapChanged = ETrue; |
|
360 } |
|
361 } |
|
362 break; |
|
363 |
|
364 default: |
|
365 break; |
|
366 } |
|
367 |
|
368 if ( iapChanged ) |
|
369 { |
|
370 UpdateSelectedConnectionNameL( ); |
|
371 |
|
372 if ( iSettingConnectionItem ) |
|
373 { |
|
374 iSettingConnectionItem->LoadL ( ); |
|
375 iSettingConnectionItem->UpdateListBoxTextL ( ); |
|
376 } |
|
377 |
|
378 CheckProxyDisableL(); |
|
379 |
|
380 DrawDeferred(); |
|
381 } |
|
382 } |
|
383 CleanupStack::PopAndDestroy ( settingsUi ); |
|
384 } |
|
385 |
|
386 // -------------------------------------------------------------------------- |
|
387 // CMPSettingsStreamingSettingItemList::CheckProxyDisableL() |
|
388 // -------------------------------------------------------------------------- |
|
389 // |
|
390 void CMPSettingsStreamingSettingItemList::CheckProxyDisableL() |
|
391 { |
|
392 if ( iProxyMode && iSettingProxyItem ) |
|
393 { |
|
394 iSettingProxyItem->EditItemL( EFalse ); |
|
395 |
|
396 iSettingProxyItem->StoreL(); |
|
397 StoreSettingL( EMPSettProxyModeSettingId ); |
|
398 |
|
399 iSettingProxyItem->LoadL(); |
|
400 iSettingProxyItem->UpdateListBoxTextL(); |
|
401 } |
|
402 } |
|
403 |
|
404 // -------------------------------------------------------------------------- |
|
405 // CMPSettingsStreamingSettingItemList::UpdateSelectedConnectionNameL |
|
406 // -------------------------------------------------------------------------- |
|
407 // |
|
408 void CMPSettingsStreamingSettingItemList::UpdateSelectedConnectionNameL() |
|
409 { |
|
410 MPX_FUNC("#MS# CMPSettingsStreamingSettingItemList::UpdateSelectedConnectionNameL()"); |
|
411 |
|
412 RCmManagerExt cmManager; |
|
413 RCmConnectionMethodExt connMethod; |
|
414 |
|
415 CleanupClosePushL( cmManager ); |
|
416 CleanupClosePushL( connMethod ); |
|
417 |
|
418 cmManager.OpenL(); |
|
419 |
|
420 // This leaves if conn method is not found. |
|
421 TRAPD( leave, connMethod = cmManager.ConnectionMethodL( iDefaultAP ) ); |
|
422 if ( KErrNone == leave ) |
|
423 { |
|
424 HBufC* tmpBuf = |
|
425 cmManager.GetConnectionMethodInfoStringL( iDefaultAP, CMManager::ECmName); |
|
426 |
|
427 if( tmpBuf ) |
|
428 { |
|
429 if ( tmpBuf->Length() < KMaxApNameLength ) |
|
430 { |
|
431 iSelectedApName = *tmpBuf; |
|
432 } |
|
433 delete tmpBuf; |
|
434 } |
|
435 } |
|
436 |
|
437 CleanupStack::PopAndDestroy( &connMethod ); |
|
438 CleanupStack::PopAndDestroy( &cmManager ); |
|
439 } |
|
440 |
|
441 // -------------------------------------------------------------------------- |
|
442 // CMPSettingsStreamingSettingItemList::HandleListBoxEventL() |
|
443 // -------------------------------------------------------------------------- |
|
444 // |
|
445 void CMPSettingsStreamingSettingItemList::HandleListBoxEventL( |
|
446 CEikListBox* aListBox, |
|
447 TListBoxEvent aListBoxEvent ) |
|
448 { |
|
449 if ( ( aListBoxEvent == EEventEnterKeyPressed ) || |
|
450 ( aListBoxEvent == EEventItemSingleClicked ) || |
|
451 ( aListBoxEvent == EEventItemDoubleClicked ) ) |
|
452 { |
|
453 CAknSettingItemList::HandleListBoxEventL( aListBox, aListBoxEvent ); |
|
454 } |
|
455 } |
|
456 |
|
457 // End of File |