1 /* |
|
2 * Copyright (c) 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: Dialog for setting packet data plugin advanced settings |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 |
|
20 #include <cmpacketdataui.rsg> |
|
21 #include <cmmanager.rsg> |
|
22 #include <StringLoader.h> |
|
23 #include <akntextsettingpage.h> |
|
24 #include <aknradiobuttonsettingpage.h> |
|
25 #include <aknmfnesettingpage.h> |
|
26 #include <csxhelp/cp.hlp.hrh> |
|
27 |
|
28 #include <cmpluginpacketdatadef.h> |
|
29 #include "cmppacketdatasettingsdlgadv.h" |
|
30 #include "cmpacketdatacommonconstants.h" |
|
31 #include "cmpluginmultilinedialog.h" |
|
32 #include <cmcommonui.h> |
|
33 #include "cmpluginmenucommands.hrh" |
|
34 #include "cmpluginpacketdata.h" |
|
35 #include <cmcommonconstants.h> |
|
36 #include <cmpsettingsconsts.h> |
|
37 #include "cmmanagerimpl.h" |
|
38 |
|
39 using namespace CMManager; |
|
40 |
|
41 const TUint32 KDNSSelectionItems[] = |
|
42 { |
|
43 R_QTN_SET_IP_ADDRESS_DYNAMIC, |
|
44 R_QTN_SET_IP_WELL_KNOWN, |
|
45 R_QTN_SET_IP_USER_DEFINED, |
|
46 0 |
|
47 }; |
|
48 |
|
49 const TUint32 KPDPSelectionItems[] = |
|
50 { |
|
51 R_GPRS_PLUGIN_VIEW_PDP_TYPE_IPV4, |
|
52 R_GPRS_PLUGIN_VIEW_PDP_TYPE_IPV6, |
|
53 0 |
|
54 }; |
|
55 |
|
56 // ================= MEMBER FUNCTIONS ======================================= |
|
57 |
|
58 // -------------------------------------------------------------------------- |
|
59 // CmPluginPacketDataSettingsDlgAdv::NewL() |
|
60 // Two-phase dconstructor, second phase is ConstructAndRunLD |
|
61 // -------------------------------------------------------------------------- |
|
62 // |
|
63 CmPluginPacketDataSettingsDlgAdv* CmPluginPacketDataSettingsDlgAdv::NewL( |
|
64 CCmPluginBaseEng& aCmPluginBase ) |
|
65 { |
|
66 CmPluginPacketDataSettingsDlgAdv* self = |
|
67 new ( ELeave ) CmPluginPacketDataSettingsDlgAdv( aCmPluginBase ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // -------------------------------------------------------------------------- |
|
72 // CmPluginPacketDataSettingsDlgAdv::CmPluginPacketDataSettingsDlgAdv() |
|
73 // -------------------------------------------------------------------------- |
|
74 // |
|
75 CmPluginPacketDataSettingsDlgAdv::CmPluginPacketDataSettingsDlgAdv( |
|
76 CCmPluginBaseEng& aCmPluginBase ) |
|
77 : CmPluginBaseSettingsDlgAdv( aCmPluginBase ) |
|
78 , iIpv6Supported( aCmPluginBase.FeatureSupported( KFeatureIdIPv6 ) ) |
|
79 , iParent( NULL ) |
|
80 { |
|
81 iHelpContext = KSET_HLP_AP_SETTING_GPRS_AS; |
|
82 } |
|
83 |
|
84 // -------------------------------------------------------------------------- |
|
85 // CmPluginPacketDataSettingsDlgAdv::~CmPluginPacketDataSettingsDlgAdv |
|
86 // Destructor |
|
87 // -------------------------------------------------------------------------- |
|
88 // |
|
89 CmPluginPacketDataSettingsDlgAdv::~CmPluginPacketDataSettingsDlgAdv() |
|
90 { |
|
91 } |
|
92 |
|
93 // -------------------------------------------------------------------------- |
|
94 // CmPluginPacketDataSettingsDlgAdv::ConstructAndRunLD |
|
95 // -------------------------------------------------------------------------- |
|
96 // |
|
97 TInt CmPluginPacketDataSettingsDlgAdv::ConstructAndRunLD() |
|
98 { |
|
99 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
100 cmMgr.WatcherRegisterL( this ); |
|
101 |
|
102 return CmPluginBaseSettingsDlgAdv::ConstructAndRunLD(); |
|
103 } |
|
104 |
|
105 // -------------------------------------------------------------------------- |
|
106 // CmPluginPacketDataSettingsDlgAdv::UpdateListBoxContentBearerSpecificL |
|
107 // -------------------------------------------------------------------------- |
|
108 // |
|
109 void CmPluginPacketDataSettingsDlgAdv::UpdateListBoxContentBearerSpecificL( |
|
110 CDesCArray& aItemArray ) |
|
111 { |
|
112 TInt valueResId = 0; |
|
113 TInt pdpType = RPacketContext::EPdpTypeIPv4; |
|
114 |
|
115 // Get the PDP type - EPdpTypeIPv4 by default |
|
116 if ( iIpv6Supported ) |
|
117 { |
|
118 pdpType = iCmPluginBaseEng.GetIntAttributeL( EPacketDataPDPType ); |
|
119 |
|
120 // NETWORK (PDP) TYPE |
|
121 AppendSettingTextsL( aItemArray, |
|
122 EPacketDataPDPType, |
|
123 pdpType == RPacketContext::EPdpTypeIPv6 ? |
|
124 R_GPRS_PLUGIN_VIEW_PDP_TYPE_IPV6 : |
|
125 R_GPRS_PLUGIN_VIEW_PDP_TYPE_IPV4 ); |
|
126 } |
|
127 |
|
128 if ( pdpType != RPacketContext::EPdpTypeIPv6 ) |
|
129 { |
|
130 // IP ADDRESS |
|
131 AppendSettingTextsL( aItemArray, EPacketDataIPAddr ); |
|
132 } |
|
133 |
|
134 if ( iIpv6Supported ) |
|
135 { |
|
136 // DNS SERVERS IP ADDRESS |
|
137 if ( pdpType == RPacketContext::EPdpTypeIPv6 ) |
|
138 { |
|
139 switch ( GetIPv6DNSTypeL( EPacketDataIPIP6NameServer1, |
|
140 EPacketDataIPIP6NameServer2 ) ) |
|
141 { |
|
142 case EIPv6Unspecified: |
|
143 { |
|
144 valueResId = R_QTN_SET_IP_ADDRESS_DYNAMIC; |
|
145 break; |
|
146 } |
|
147 case EIPv6WellKnown: |
|
148 { |
|
149 valueResId = R_QTN_SET_IP_WELL_KNOWN; |
|
150 break; |
|
151 } |
|
152 case EIPv6UserDefined: |
|
153 { |
|
154 valueResId = R_QTN_SET_IP_USER_DEFINED; |
|
155 break; |
|
156 } |
|
157 default: |
|
158 { |
|
159 User::Leave( KErrNotSupported ); |
|
160 break; |
|
161 } |
|
162 } |
|
163 } |
|
164 else |
|
165 { |
|
166 if ( !iCmPluginBaseEng.GetBoolAttributeL( |
|
167 EPacketDataIPDNSAddrFromServer ) ) |
|
168 { |
|
169 valueResId = R_QTN_SET_IP_USER_DEFINED; |
|
170 } |
|
171 else |
|
172 { |
|
173 valueResId = R_QTN_SET_DNS_SERVERS_AUTOMATIC; |
|
174 } |
|
175 } |
|
176 AppendSettingTextsL( aItemArray, |
|
177 EPacketDataIPIP6DNSAddrFromServer, |
|
178 valueResId ); |
|
179 } |
|
180 else |
|
181 { |
|
182 // PRIMARY NAME SERVER |
|
183 AppendSettingTextsL( aItemArray, EPacketDataIPNameServer1 ); |
|
184 AppendSettingTextsL( aItemArray, EPacketDataIPNameServer2 ); |
|
185 } |
|
186 |
|
187 // PROXY SETTINGS |
|
188 // PROXY SERVER ADDRESS |
|
189 AppendSettingTextsL( aItemArray, ECmProxyServerName ); |
|
190 // PROXY PORT NUMBER |
|
191 AppendSettingTextsL( aItemArray, ECmProxyPortNumber ); |
|
192 } |
|
193 |
|
194 // -------------------------------------------------------------------------- |
|
195 // CmPluginPacketDataSettingsDlgAdv::ShowPopupPacketDataIPDNSAddrFromServerL |
|
196 // -------------------------------------------------------------------------- |
|
197 // |
|
198 void CmPluginPacketDataSettingsDlgAdv:: |
|
199 ShowPopupPacketDataIPDNSAddrFromServerL() |
|
200 { |
|
201 TInt PDPType = iCmPluginBaseEng.GetIntAttributeL( EPacketDataPDPType ); |
|
202 |
|
203 if ( PDPType == RPacketContext::EPdpTypeIPv6 ) |
|
204 { |
|
205 ShowPopupIPv6DNSEditorL( KDNSSelectionItems, |
|
206 EPacketDataIPIP6DNSAddrFromServer, |
|
207 EPacketDataIPIP6NameServer1, |
|
208 EPacketDataIPIP6NameServer2 ); |
|
209 } |
|
210 else //ipv4 |
|
211 { |
|
212 ShowPopupIPv4DNSEditorL( EPacketDataIPDNSAddrFromServer, |
|
213 EPacketDataIPNameServer1, |
|
214 EPacketDataIPNameServer2 ); |
|
215 } |
|
216 } |
|
217 |
|
218 // -------------------------------------------------------------------------- |
|
219 // CmPluginPacketDataSettingsDlgAdv::ShowPopupSettingPageL |
|
220 // -------------------------------------------------------------------------- |
|
221 // |
|
222 TBool CmPluginPacketDataSettingsDlgAdv::ShowPopupSettingPageL( |
|
223 TUint32 aAttribute, TInt aCommandId ) |
|
224 { |
|
225 TBool retval = EFalse; |
|
226 |
|
227 switch ( aAttribute ) |
|
228 { |
|
229 // IPDNS Settings |
|
230 case EPacketDataIPDNSAddrFromServer: |
|
231 case EPacketDataIPIP6DNSAddrFromServer: |
|
232 { |
|
233 ShowPopupPacketDataIPDNSAddrFromServerL(); |
|
234 break; |
|
235 } |
|
236 case EPacketDataPDPType: |
|
237 { |
|
238 if ( aCommandId == EAknSoftkeyOk ) |
|
239 { |
|
240 TInt intFromCM = 0; |
|
241 TRAPD( err, intFromCM = iCmPluginBaseEng.GetIntAttributeL( |
|
242 aAttribute ) ); |
|
243 |
|
244 if ( !err ) |
|
245 { |
|
246 intFromCM == RPacketContext::EPdpTypeIPv6 ? |
|
247 intFromCM = RPacketContext::EPdpTypeIPv4 : |
|
248 intFromCM = RPacketContext::EPdpTypeIPv6; |
|
249 } |
|
250 else |
|
251 { |
|
252 User::Leave( KErrNotSupported ); |
|
253 } |
|
254 |
|
255 iCmPluginBaseEng.SetIntAttributeL( aAttribute, intFromCM ); |
|
256 UpdateListBoxContentL(); |
|
257 } |
|
258 else |
|
259 { |
|
260 if ( aCommandId == EPluginBaseCmdChange ) |
|
261 |
|
262 { |
|
263 ShowPDPTypeRBPageL( aAttribute ); |
|
264 } |
|
265 else |
|
266 { |
|
267 TInt pdpType = iCmPluginBaseEng.GetIntAttributeL( EPacketDataPDPType ); |
|
268 pdpType = pdpType == RPacketContext::EPdpTypeIPv4 ? |
|
269 RPacketContext::EPdpTypeIPv6 : |
|
270 RPacketContext::EPdpTypeIPv4; |
|
271 iCmPluginBaseEng.SetIntAttributeL( aAttribute, pdpType ); |
|
272 UpdateListBoxContentL(); |
|
273 } |
|
274 } |
|
275 break; |
|
276 } |
|
277 // IP Setting Page |
|
278 case EPacketDataIPNameServer1: |
|
279 case EPacketDataIPNameServer2: |
|
280 case EPacketDataIPAddr: |
|
281 { |
|
282 ShowPopupIpSettingPageL( aAttribute ); |
|
283 break; |
|
284 } |
|
285 // Text Settings |
|
286 case ECmProxyServerName: |
|
287 { |
|
288 retval = ShowPopupTextSettingPageL( aAttribute ); |
|
289 break; |
|
290 } |
|
291 // Numeric Settings |
|
292 case ECmProxyPortNumber: |
|
293 { |
|
294 if ( ShowPopupPortNumSettingPageL( aAttribute ) ) |
|
295 { |
|
296 retval = ETrue; |
|
297 } |
|
298 break; |
|
299 } |
|
300 default: |
|
301 { |
|
302 CmPluginBaseSettingsDlgAdv::ShowPopupSettingPageL( aAttribute, |
|
303 aCommandId ); |
|
304 break; |
|
305 } |
|
306 } |
|
307 return retval; |
|
308 } |
|
309 |
|
310 // -------------------------------------------------------------------------- |
|
311 // CmPluginPacketDataSettingsDlgAdv::ProcessCommandL |
|
312 // -------------------------------------------------------------------------- |
|
313 // |
|
314 void CmPluginPacketDataSettingsDlgAdv::ProcessCommandL( TInt aCommandId ) |
|
315 { |
|
316 if ( MenuShowing() ) |
|
317 { |
|
318 HideMenu(); |
|
319 } |
|
320 |
|
321 switch ( aCommandId ) |
|
322 { |
|
323 case EPluginBaseCmdExit: |
|
324 { |
|
325 iExitReason = KDialogUserExit; // flow to EAknSoftkeyBack |
|
326 } |
|
327 case EAknSoftkeyBack: |
|
328 { |
|
329 TryExitL( iExitReason ); |
|
330 break; |
|
331 } |
|
332 case EAknSoftkeyOk: |
|
333 case EPluginBaseCmdChange: |
|
334 { |
|
335 TInt attrib = iSettingIndex->At( iListbox->CurrentItemIndex() ); |
|
336 ShowPopupSettingPageL( attrib, aCommandId ); |
|
337 |
|
338 if ( iHasSettingChanged ) |
|
339 { |
|
340 iHasSettingChanged = EFalse; // Don't call UpdateL at this stage |
|
341 } |
|
342 break; |
|
343 } |
|
344 default: |
|
345 { |
|
346 CmPluginBaseSettingsDlgAdv::ProcessCommandL( aCommandId ); |
|
347 |
|
348 if ( iHasSettingChanged ) |
|
349 { |
|
350 iHasSettingChanged = EFalse; // Don't call UpdateL at this stage |
|
351 } |
|
352 break; |
|
353 } |
|
354 } |
|
355 } |
|
356 |
|
357 // -------------------------------------------------------------------------- |
|
358 // CmPluginPacketDataSettingsDlgAdv::OkToExitL |
|
359 // -------------------------------------------------------------------------- |
|
360 // |
|
361 TBool CmPluginPacketDataSettingsDlgAdv::OkToExitL( TInt aButtonId ) |
|
362 { |
|
363 TBool retval( EFalse ); |
|
364 switch ( aButtonId ) |
|
365 { |
|
366 case EPluginBaseCmdExit: |
|
367 case EAknSoftkeyBack: |
|
368 { |
|
369 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
370 cmMgr.WatcherUnRegister(); |
|
371 } |
|
372 default: |
|
373 { |
|
374 retval = CmPluginBaseSettingsDlgAdv::OkToExitL( aButtonId ); |
|
375 break; |
|
376 } |
|
377 } |
|
378 |
|
379 return retval; |
|
380 } |
|
381 |
|
382 // -------------------------------------------------------------------------- |
|
383 // CmPluginPacketDataSettingsDlgAdv::ShowPDPTypeRBPageL |
|
384 // -------------------------------------------------------------------------- |
|
385 // |
|
386 void CmPluginPacketDataSettingsDlgAdv::ShowPDPTypeRBPageL( TUint32 aAttribute ) |
|
387 { |
|
388 TInt selected = iCmPluginBaseEng.GetIntAttributeL( aAttribute ); |
|
389 |
|
390 TInt originalValue = selected; |
|
391 |
|
392 if ( ShowRadioButtonSettingPageL( KPDPSelectionItems, |
|
393 selected, |
|
394 R_GPRS_PLUGIN_VIEW_PDP_TYPE ) && |
|
395 originalValue != selected ) |
|
396 { |
|
397 iCmPluginBaseEng.SetIntAttributeL( aAttribute , selected ); |
|
398 UpdateListBoxContentL(); |
|
399 } |
|
400 } |
|
401 |
|
402 // -------------------------------------------------------------------------- |
|
403 // CmPluginPacketDataSettingsDlgAdv::RegisterParentView |
|
404 // -------------------------------------------------------------------------- |
|
405 // |
|
406 void CmPluginPacketDataSettingsDlgAdv::RegisterParentView( CCmParentViewNotifier* aParent ) |
|
407 { |
|
408 iParent = aParent; |
|
409 } |
|
410 |
|
411 // -------------------------------------------------------------------------- |
|
412 // CmPluginPacketDataSettingsDlgAdv::CommsDatChangesL |
|
413 // -------------------------------------------------------------------------- |
|
414 // |
|
415 void CmPluginPacketDataSettingsDlgAdv::CommsDatChangesL() |
|
416 { |
|
417 CCmManagerImpl& cmMgr = iCmPluginBaseEng.CmMgr(); |
|
418 CCmDestinationImpl* parentDest = iCmPluginBaseEng.ParentDestination(); |
|
419 |
|
420 if ( parentDest ) |
|
421 { |
|
422 if( !cmMgr.DestinationStillExistedL( parentDest ) ) |
|
423 { |
|
424 if( iParent ) |
|
425 { |
|
426 iParent->NotifyParentView( KCmNotifiedDestinationDisappear ); |
|
427 } |
|
428 |
|
429 cmMgr.WatcherUnRegister(); |
|
430 // If parent destination is deleted by somebody then the dialog must exit back to main view |
|
431 iExitReason = KDialogUserExit; |
|
432 TryExitL( iExitReason ); |
|
433 |
|
434 cmMgr.RemoveDestFromPool( parentDest ); |
|
435 delete parentDest; |
|
436 return; |
|
437 } |
|
438 |
|
439 if( !cmMgr.IsIapStillInDestL( parentDest, iCmPluginBaseEng ) ) |
|
440 { |
|
441 if( iParent ) |
|
442 { |
|
443 iParent->NotifyParentView( KCmNotifiedIapIsNotInThisDestination ); |
|
444 } |
|
445 |
|
446 cmMgr.WatcherUnRegister(); |
|
447 // In this case, the dialog can go back to the parent view |
|
448 TryExitL( iExitReason ); |
|
449 |
|
450 cmMgr.RemoveDestFromPool( parentDest ); |
|
451 delete parentDest; |
|
452 return; |
|
453 } |
|
454 |
|
455 // We may have to notify parent view to go back to its parent view even though this Iap is still in CommsDat |
|
456 // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more |
|
457 // after this call when some Iap is deleted. |
|
458 if( iParent ) |
|
459 { |
|
460 iParent->NotifyParentView( KCmNotifiedIapDisappear ); |
|
461 } |
|
462 cmMgr.WatcherUnRegister(); |
|
463 TryExitL( iExitReason ); |
|
464 |
|
465 cmMgr.RemoveDestFromPool( parentDest ); |
|
466 delete parentDest; |
|
467 } |
|
468 else |
|
469 { |
|
470 if( !cmMgr.IapStillExistedL(iCmPluginBaseEng) ) |
|
471 { |
|
472 if( iParent ) |
|
473 { |
|
474 iParent->NotifyParentView( KCmNotifiedIapDisappear ); |
|
475 } |
|
476 |
|
477 cmMgr.WatcherUnRegister(); |
|
478 // In this case, the dialog can go back to the parent view |
|
479 TryExitL( iExitReason ); |
|
480 return; |
|
481 } |
|
482 |
|
483 // We may have to notify parent view to go back to its parent view even though this Iap is still in CommsDat |
|
484 // for cmMgr ( = iCmPluginBaseEng.CmMgr() ) can not be accessed any more |
|
485 // after this call when some Iap is deleted. |
|
486 if( iParent ) |
|
487 { |
|
488 iParent->NotifyParentView( KCmNotifiedIapDisappear ); |
|
489 } |
|
490 cmMgr.WatcherUnRegister(); |
|
491 TryExitL( iExitReason ); |
|
492 } |
|
493 } |
|