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: VPN plug-in IF implementation class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AknsUtils.h> |
|
19 #include <cmpluginvpn.mbg> |
|
20 #include <cmpluginvpnui.rsg> |
|
21 #include <cmmanager.rsg> |
|
22 #include <StringLoader.h> |
|
23 #include <data_caging_path_literals.hrh> |
|
24 #include <cmpluginbaseeng.h> |
|
25 #include <cmpluginbase.h> |
|
26 #include <cmcommonui.h> |
|
27 #include <aknPopup.h> |
|
28 #include <aknlistquerydialog.h> |
|
29 #include <AknIconArray.h> |
|
30 #include <vpnapidefs.h> |
|
31 #include <cmpluginwlandef.h> |
|
32 // #include <vpnapi.h> |
|
33 #include <centralrepository.h> |
|
34 #include <settingsinternalcrkeys.h> |
|
35 #include <featmgr.h> |
|
36 #include <ConeResLoader.h> |
|
37 #include <bautils.h> |
|
38 |
|
39 #include <commsdattypesv1_1_partner.h> |
|
40 #include <commsdattypeinfov1_1_internal.h> |
|
41 |
|
42 #include "cmlogger.h" |
|
43 #include "cmmanagerimpl.h" |
|
44 #include "cmdestinationimpl.h" |
|
45 #include "cmvpncommonconstants.h" |
|
46 #include <cmcommonconstants.h> |
|
47 #include "cmpluginvpn.h" |
|
48 #include "cmpvpnsettingsdlg.h" |
|
49 #include "cmpvpnpolicyselectiondlg.h" |
|
50 #include "cmpvpnnextlayerselectdlg.h" |
|
51 |
|
52 using namespace CMManager; |
|
53 |
|
54 _LIT( KPluginVpnFileIcons, "z:cmpluginvpn.mbm" ); |
|
55 //_LIT(KListItemFormat, "%d\t%S\t%S"); |
|
56 |
|
57 static const TCmAttribConvTable SVpnConvTbl[] = |
|
58 { |
|
59 { EVpnServicePolicyName, EPluginVpnAttribRangeMax, NULL }, |
|
60 { EVpnServicePolicy, KCDTIdVPNPolicyName, NULL, |
|
61 R_QTN_VPN_SETT_VPN_IAP_POLICY_REFERENCE, |
|
62 0, EConvCompulsory, R_QTN_VPN_SETT_VPN_IAP_POLICY_REFERENCE_COMPULSORY, 0, NULL, NULL }, |
|
63 { EVpnServicePolicyName, 0, NULL, |
|
64 R_QTN_VPN_SETT_VPN_IAP_POLICY_REFERENCE, |
|
65 0, EConvCompulsory, R_QTN_VPN_SETT_VPN_IAP_POLICY_REFERENCE_COMPULSORY, 0, NULL, NULL }, |
|
66 { EVpnIapId, KCDTIdVPNIAPRecord, NULL }, |
|
67 { EVpnNetworkId, KCDTIdVPNNetwork, &ReadOnlyAttributeL }, |
|
68 { 0, 0, NULL } |
|
69 }; |
|
70 |
|
71 static const TCmAttribConvTable SVpnVirtualIAPNextLayerConvTbl[] = |
|
72 { |
|
73 { ECmNextLayerIapId, ECmNextLayerSNAPId+1, NULL }, |
|
74 { ECmNextLayerIapId, KCDTIdVirtualNextLayerIAP, NULL }, |
|
75 { ECmNextLayerSNAPId, KCDTIdVirtualNextLayerSNAP, NULL }, |
|
76 { 0, 0, NULL } |
|
77 }; |
|
78 |
|
79 _LIT( KVpnVirtualBearerName, "vpnbearer" ); |
|
80 _LIT( KVpnVirtualBearerAgent, "vpnconnagt.agt" ); |
|
81 _LIT( KVpnVirtualBearerNif, "tunnelnif" ); |
|
82 |
|
83 // constants needed for the virtualbearer table |
|
84 const TInt KNoTimeout = -1; |
|
85 const TUint32 KLastSessionTimeout = 3; |
|
86 |
|
87 |
|
88 const TUint32 KContainsVpn = 0x01; |
|
89 const TUint32 KLinksBackToParent = 0x02; |
|
90 const TUint32 KEmptyDest = 0x04; |
|
91 const TUint32 KNoNonVirtuals = 0x08; |
|
92 |
|
93 const TUint32 KBindDenied = KLinksBackToParent | KContainsVpn; |
|
94 |
|
95 // -------------------------------------------------------------------------- |
|
96 // CCmPluginVpn::NewL() |
|
97 // -------------------------------------------------------------------------- |
|
98 // |
|
99 CCmPluginVpn* CCmPluginVpn::NewL( TCmPluginInitParam* aInitParam ) |
|
100 { |
|
101 |
|
102 CRepository* repository = CRepository::NewLC(KCRUidCommunicationSettings); |
|
103 |
|
104 TInt vpnSupported; |
|
105 repository->Get(KSettingsVPNSupported, vpnSupported); |
|
106 |
|
107 CleanupStack::PopAndDestroy(repository); |
|
108 |
|
109 if( !vpnSupported ) |
|
110 { |
|
111 User::Leave( KErrNotSupported ); |
|
112 } |
|
113 |
|
114 CCmPluginVpn* self = new( ELeave ) CCmPluginVpn( aInitParam ); |
|
115 CleanupStack::PushL( self ); |
|
116 self->ConstructL(); |
|
117 CleanupStack::Pop( self ); |
|
118 return self; |
|
119 } |
|
120 |
|
121 // -------------------------------------------------------------------------- |
|
122 // CCmPluginVpn::~CCmPluginVpn() |
|
123 // -------------------------------------------------------------------------- |
|
124 // |
|
125 CCmPluginVpn::~CCmPluginVpn() |
|
126 { |
|
127 CCmPluginVpn::AdditionalReset(); |
|
128 |
|
129 RemoveResourceFile( KPluginVPNResDirAndFileName ); |
|
130 |
|
131 iBindableMethods.Reset(); |
|
132 iBindableMethods.Close(); |
|
133 delete iPolicyName; |
|
134 CLOG_CLOSE; |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------------- |
|
138 // CCmPluginVpn::CreateInstanceL |
|
139 // -------------------------------------------------------------------------- |
|
140 // |
|
141 CCmPluginBaseEng* CCmPluginVpn::CreateInstanceL( TCmPluginInitParam& aInitParam ) const |
|
142 { |
|
143 CCmPluginVpn* self = new( ELeave ) CCmPluginVpn( &aInitParam ); |
|
144 CleanupStack::PushL( self ); |
|
145 self->ConstructL(); |
|
146 CleanupStack::Pop( self ); |
|
147 |
|
148 return self; |
|
149 } |
|
150 |
|
151 // -------------------------------------------------------------------------- |
|
152 // CCmPluginVpn::CCmPluginVpn() |
|
153 // -------------------------------------------------------------------------- |
|
154 // |
|
155 CCmPluginVpn::CCmPluginVpn( TCmPluginInitParam* aInitParam ) |
|
156 : CCmPluginBaseEng( aInitParam ) |
|
157 , iBindableMethods( KCmArraySmallGranularity ) |
|
158 { |
|
159 CLOG_CREATE; |
|
160 iBearerType = KPluginVPNBearerTypeUid; |
|
161 } |
|
162 |
|
163 // -------------------------------------------------------------------------- |
|
164 // CCmPluginVpn::ConstructL() |
|
165 // -------------------------------------------------------------------------- |
|
166 // |
|
167 void CCmPluginVpn::ConstructL() |
|
168 { |
|
169 CCmPluginBaseEng::ConstructL(); |
|
170 |
|
171 TRAP_IGNORE( iVirtualTableId = |
|
172 CCDVirtualIAPNextLayerRecord::TableIdL( Session() ) ); |
|
173 if( !iVirtualTableId ) |
|
174 { |
|
175 iVirtualTableId = CCDVirtualIAPNextLayerRecord::CreateTableL( Session() ); |
|
176 } |
|
177 |
|
178 AddResourceFileL( KPluginVPNResDirAndFileName ); |
|
179 |
|
180 AddConverstionTableL( (CCDRecordBase**)&iServiceRecord, NULL, SVpnConvTbl ); |
|
181 |
|
182 iPolicyName = KNullDesC().AllocL(); |
|
183 } |
|
184 |
|
185 // -------------------------------------------------------------------------- |
|
186 // CCmPluginVpn::GetIntAttributeL() |
|
187 // -------------------------------------------------------------------------- |
|
188 // |
|
189 TUint32 CCmPluginVpn::GetIntAttributeL( const TUint32 aAttribute ) const |
|
190 { |
|
191 LOGGER_ENTERFN( "CCmPluginVpn::GetIntAttributeL" ); |
|
192 |
|
193 TUint32 retVal( 0 ); |
|
194 |
|
195 switch( aAttribute ) |
|
196 { |
|
197 case ECmBearerIcon: |
|
198 { |
|
199 TAknsItemID id; |
|
200 |
|
201 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
202 |
|
203 TParse mbmFile; |
|
204 User::LeaveIfError( mbmFile.Set( KPluginVpnFileIcons, |
|
205 &KDC_BITMAP_DIR, |
|
206 NULL ) ); |
|
207 |
|
208 retVal = (TUint32)AknsUtils::CreateGulIconL( |
|
209 skinInstance, |
|
210 id, |
|
211 mbmFile.FullName(), |
|
212 EMbmCmpluginvpnQgn_prop_vpn_access_point, |
|
213 EMbmCmpluginvpnQgn_prop_vpn_access_point_mask ); |
|
214 } |
|
215 break; |
|
216 |
|
217 case ECmCommsDBBearerType: |
|
218 { |
|
219 retVal = KCommDbBearerVirtual; |
|
220 } |
|
221 break; |
|
222 |
|
223 case ECmDefaultUiPriority: |
|
224 case ECmDefaultPriority: |
|
225 { |
|
226 retVal = aAttribute == ECmDefaultPriority ? |
|
227 GlobalBearerPriority( TPtrC(KCDTypeNameVPNService) ) : |
|
228 GlobalUiBearerPriority( TPtrC(KCDTypeNameVPNService) ); |
|
229 } |
|
230 break; |
|
231 |
|
232 case EVpnIapId: |
|
233 { |
|
234 if( !ServiceRecordExists() ) |
|
235 { |
|
236 User::Leave( KErrNotSupported ); |
|
237 } |
|
238 |
|
239 retVal = ServiceRecord().iServiceIAP; |
|
240 } |
|
241 break; |
|
242 case EVpnNetworkId: |
|
243 { |
|
244 if( !ServiceRecordExists() ) |
|
245 { |
|
246 User::Leave( KErrNotSupported ); |
|
247 } |
|
248 |
|
249 retVal = ServiceRecord().iServiceNetwork; |
|
250 } |
|
251 break; |
|
252 case ECmNextLayerIapId: |
|
253 { |
|
254 retVal = iVirtualRecord->iNextLayerIAP; |
|
255 } |
|
256 break; |
|
257 case ECmNextLayerSNAPId: |
|
258 { |
|
259 retVal = iVirtualRecord->iNextLayerSNAP; |
|
260 } |
|
261 break; |
|
262 case ECmIapId: |
|
263 case ECmId: |
|
264 case ECmWapId: |
|
265 case ECmIapServiceId: |
|
266 case ECmInvalidAttribute: |
|
267 case ECmLoadResult: |
|
268 case ECmBearerType: |
|
269 case ECmSeamlessnessLevel: |
|
270 case ECmElementID: |
|
271 case ECmNetworkId: |
|
272 case ECmProxyPortNumber: |
|
273 case ECmExtensionLevel: |
|
274 case ECmWapIPWSPOption: |
|
275 case ECmWapIPProxyPort: |
|
276 case ECmNamingMethod: |
|
277 { |
|
278 retVal = CCmPluginBaseEng::GetIntAttributeL( aAttribute ); |
|
279 } |
|
280 break; |
|
281 |
|
282 default: |
|
283 { |
|
284 User::Leave( KErrNotSupported ); |
|
285 } |
|
286 } |
|
287 |
|
288 return retVal; |
|
289 } |
|
290 |
|
291 // -------------------------------------------------------------------------- |
|
292 // CCmPluginVpn::GetBoolAttributeL() |
|
293 // -------------------------------------------------------------------------- |
|
294 // |
|
295 TBool CCmPluginVpn::GetBoolAttributeL( const TUint32 aAttribute ) const |
|
296 { |
|
297 LOGGER_ENTERFN( "CCmPluginVpn::GetBoolAttributeL" ); |
|
298 |
|
299 TBool retVal( EFalse ); |
|
300 |
|
301 switch( aAttribute ) |
|
302 { |
|
303 case ECmAddToAvailableList: |
|
304 { |
|
305 retVal = EFalse; |
|
306 } |
|
307 break; |
|
308 |
|
309 case ECmChargeCardUsageEnabled: |
|
310 { |
|
311 retVal = EFalse; |
|
312 } |
|
313 break; |
|
314 case ECmBearerHasUi: |
|
315 { |
|
316 retVal = ETrue; |
|
317 break; |
|
318 } |
|
319 case ECmCoverage: |
|
320 case ECmDestination: |
|
321 case ECmIPv6Supported: |
|
322 case ECmHidden: |
|
323 case ECmProtected: |
|
324 case ECmMetaHighlight: |
|
325 case ECmMetaHiddenAgent: |
|
326 case ECmProxyUsageEnabled: |
|
327 case ECmConnected: |
|
328 case ECmIsLinked: |
|
329 case ECmWapIPSecurity: |
|
330 { |
|
331 retVal = CCmPluginBaseEng::GetBoolAttributeL( aAttribute ); |
|
332 } |
|
333 break; |
|
334 case ECmVirtual: |
|
335 { |
|
336 return ETrue; |
|
337 } |
|
338 default: |
|
339 { |
|
340 User::Leave( KErrNotSupported ); |
|
341 |
|
342 } |
|
343 } |
|
344 |
|
345 return retVal; |
|
346 } |
|
347 |
|
348 // -------------------------------------------------------------------------- |
|
349 // CCmPluginVpn::GetStringAttributeL() |
|
350 // -------------------------------------------------------------------------- |
|
351 // |
|
352 HBufC* CCmPluginVpn::GetStringAttributeL( const TUint32 aAttribute ) const |
|
353 { |
|
354 LOGGER_ENTERFN( "CCmPluginVpn::GetStringAttributeL" ); |
|
355 |
|
356 HBufC* retVal = NULL; |
|
357 |
|
358 switch( aAttribute ) |
|
359 { |
|
360 case ECmBearerSupportedName: |
|
361 { |
|
362 retVal = AllocReadL( R_QTN_NETW_CONSET_BEARER_SUPPORTED_VPN ); |
|
363 } |
|
364 break; |
|
365 |
|
366 case EVpnServicePolicyName: |
|
367 { |
|
368 if( !ServiceRecordExists() ) |
|
369 { |
|
370 User::Leave( KErrNotSupported ); |
|
371 } |
|
372 else |
|
373 { |
|
374 CCmPluginVpn* tmp = const_cast< CCmPluginVpn * >( this ); |
|
375 tmp->UpdatePolicyNameL(); |
|
376 } |
|
377 retVal = iPolicyName->AllocL(); |
|
378 break; |
|
379 } |
|
380 case EVpnServicePolicy: |
|
381 { |
|
382 if( !ServiceRecordExists() ) |
|
383 { |
|
384 User::Leave( KErrNotSupported ); |
|
385 } |
|
386 |
|
387 if( !ServiceRecord().iServicePolicy.IsNull() ) |
|
388 { |
|
389 retVal = ServiceRecord().iServicePolicy.GetL().AllocL(); |
|
390 } |
|
391 else |
|
392 { |
|
393 retVal = KNullDesC().AllocL(); |
|
394 } |
|
395 } |
|
396 break; |
|
397 |
|
398 case ECmName: |
|
399 case ECmProxyServerName: |
|
400 case ECmProxyProtocolName: |
|
401 case ECmProxyExceptions: |
|
402 case ECmWapIPGatewayAddress: |
|
403 case ECmWapIPProxyLoginName: |
|
404 case ECmWapIPProxyLoginPass: |
|
405 case ECmStartPage: |
|
406 { |
|
407 retVal = CCmPluginBaseEng::GetStringAttributeL( aAttribute ); |
|
408 } |
|
409 break; |
|
410 |
|
411 default: |
|
412 { |
|
413 User::Leave( KErrNotSupported ); |
|
414 } |
|
415 break; |
|
416 } |
|
417 |
|
418 return retVal; |
|
419 } |
|
420 |
|
421 // -------------------------------------------------------------------------- |
|
422 // CCmPluginVpn::GetString8AttributeL() |
|
423 // -------------------------------------------------------------------------- |
|
424 // |
|
425 HBufC8* CCmPluginVpn::GetString8AttributeL( const TUint32 aAttribute ) const |
|
426 { |
|
427 LOGGER_ENTERFN( "CCmPluginVpn::GetString8AttributeL" ); |
|
428 |
|
429 HBufC8* retVal = NULL; |
|
430 |
|
431 switch( aAttribute ) |
|
432 { |
|
433 default: |
|
434 { |
|
435 User::Leave( KErrNotSupported ); |
|
436 } |
|
437 break; |
|
438 } |
|
439 |
|
440 return retVal; |
|
441 } |
|
442 |
|
443 // -------------------------------------------------------------------------- |
|
444 // CCmPluginVpn::SetIntAttributeL() |
|
445 // -------------------------------------------------------------------------- |
|
446 // |
|
447 void CCmPluginVpn::SetIntAttributeL( const TUint32 aAttribute, |
|
448 TUint32 aValue ) |
|
449 { |
|
450 LOGGER_ENTERFN( "CCmPluginVpn::SetIntAttributeL" ); |
|
451 |
|
452 switch( aAttribute ) |
|
453 { |
|
454 case ECmNextLayerIapId: |
|
455 case EVpnIapId: |
|
456 { |
|
457 CheckRecordIdValidityL( this, EVpnIapId, &aValue ); |
|
458 |
|
459 // ServiceRecord.iServiceIAP should be 0 according to |
|
460 // DM CommsDat Contents v1.4, but for now it is made |
|
461 // backward compatible |
|
462 if( !ServiceRecordExists() ) |
|
463 { |
|
464 User::Leave( KErrNotSupported ); |
|
465 } |
|
466 |
|
467 ServiceRecord().iServiceIAP = aValue; |
|
468 ServiceRecord().iServiceNetwork = 0; |
|
469 ServiceRecord().iServiceSNAP = 0; |
|
470 iVirtualRecord->iNextLayerIAP = aValue; |
|
471 iVirtualRecord->iNextLayerSNAP = 0; |
|
472 } |
|
473 break; |
|
474 |
|
475 case EVpnNetworkId: |
|
476 case ECmNextLayerSNAPId: |
|
477 { |
|
478 // To keep backwards compability, keep these 2 attributes |
|
479 // (EVpnNetworkId & ECmNextLayerSNAPId) together even though |
|
480 // network id and destination id are no longer exactly the same. |
|
481 if( !ServiceRecordExists() ) |
|
482 { |
|
483 User::Leave( KErrNotSupported ); |
|
484 } |
|
485 |
|
486 TInt destinationId( 0 ); |
|
487 destinationId = CheckValidityAndConvertDestinationIdL( aValue ); |
|
488 TMDBElementId defaultAP = DefaultAPRecordL(); |
|
489 |
|
490 ServiceRecord().iServiceIAP = 0; |
|
491 ServiceRecord().iServiceNetwork = 0; |
|
492 ServiceRecord().iServiceSNAP = defaultAP; |
|
493 iVirtualRecord->iNextLayerIAP = 0; |
|
494 iVirtualRecord->iNextLayerSNAP = destinationId; |
|
495 } |
|
496 break; |
|
497 |
|
498 case ECmSeamlessnessLevel: |
|
499 case ECmProxyPortNumber: |
|
500 case ECmNamingMethod: |
|
501 case ECmWapIPWSPOption: |
|
502 case ECmWapIPProxyPort: |
|
503 { |
|
504 CCmPluginBaseEng::SetIntAttributeL( aAttribute, aValue ); |
|
505 } |
|
506 break; |
|
507 |
|
508 default: |
|
509 { |
|
510 User::Leave( KErrNotSupported ); |
|
511 } |
|
512 break; |
|
513 } |
|
514 } |
|
515 |
|
516 // -------------------------------------------------------------------------- |
|
517 // CCmPluginVpn::SetBoolAttributeL() |
|
518 // -------------------------------------------------------------------------- |
|
519 // |
|
520 void CCmPluginVpn::SetBoolAttributeL( const TUint32 aAttribute, |
|
521 TBool aValue ) |
|
522 { |
|
523 LOGGER_ENTERFN( "CCmPluginVpn::SetBoolAttributeL" ); |
|
524 |
|
525 switch( aAttribute ) |
|
526 { |
|
527 case ECmChargeCardUsageEnabled: |
|
528 { |
|
529 User::Leave( KErrNotSupported ); |
|
530 } |
|
531 break; |
|
532 |
|
533 case ECmHidden: |
|
534 case ECmProtected: |
|
535 case ECmMetaHighlight: |
|
536 case ECmMetaHiddenAgent: |
|
537 case ECmProxyUsageEnabled: |
|
538 case ECmWapIPSecurity: |
|
539 { |
|
540 CCmPluginBaseEng::SetBoolAttributeL( aAttribute, aValue ); |
|
541 } |
|
542 break; |
|
543 |
|
544 default: |
|
545 { |
|
546 User::Leave( KErrNotSupported ); |
|
547 } |
|
548 break; |
|
549 } |
|
550 } |
|
551 |
|
552 // -------------------------------------------------------------------------- |
|
553 // CCmPluginVpn::SetStringAttributeL() |
|
554 // -------------------------------------------------------------------------- |
|
555 // |
|
556 void CCmPluginVpn::SetStringAttributeL( const TUint32 aAttribute, |
|
557 const TDesC16& aValue ) |
|
558 { |
|
559 LOGGER_ENTERFN( "CCmPluginVpn::SetStringAttributeL" ); |
|
560 |
|
561 switch( aAttribute ) |
|
562 { |
|
563 case EVpnServicePolicyName: |
|
564 { |
|
565 HBufC* tmp = aValue.AllocLC(); |
|
566 delete iPolicyName; |
|
567 iPolicyName = tmp; |
|
568 CleanupStack::Pop( tmp ); |
|
569 break; |
|
570 } |
|
571 case EVpnServicePolicy: |
|
572 { |
|
573 if( !ServiceRecordExists() ) |
|
574 { |
|
575 User::Leave( KErrNotSupported ); |
|
576 } |
|
577 |
|
578 CLOG_WRITE_1( "New policy set:[%S]", &aValue ); |
|
579 ServiceRecord().iServicePolicy.SetL( aValue ); |
|
580 } |
|
581 break; |
|
582 case ECmProxyServerName: |
|
583 { |
|
584 CCmPluginBaseEng::SetStringAttributeL( aAttribute, aValue ); |
|
585 if( !aValue.Length() || !iProxyRecord->iPortNumber ) |
|
586 { |
|
587 iProxyRecord->iPortNumber = KVpnProxyPortNumberDefault; |
|
588 } |
|
589 } |
|
590 break; |
|
591 |
|
592 case ECmName: |
|
593 case ECmProxyProtocolName: |
|
594 case ECmProxyExceptions: |
|
595 case ECmWapIPGatewayAddress: |
|
596 case ECmWapIPProxyLoginName: |
|
597 case ECmWapIPProxyLoginPass: |
|
598 case ECmStartPage: |
|
599 { |
|
600 CCmPluginBaseEng::SetStringAttributeL( aAttribute, aValue ); |
|
601 } |
|
602 break; |
|
603 |
|
604 default: |
|
605 { |
|
606 User::Leave( KErrNotSupported ); |
|
607 } |
|
608 break; |
|
609 } |
|
610 } |
|
611 |
|
612 // -------------------------------------------------------------------------- |
|
613 // CCmPluginVpn::SetString8AttributeL() |
|
614 // -------------------------------------------------------------------------- |
|
615 // |
|
616 void CCmPluginVpn::SetString8AttributeL( const TUint32 aAttribute, |
|
617 const TDesC8& /*aValue*/ ) |
|
618 { |
|
619 LOGGER_ENTERFN( "CCmPluginVpn::SetString8AttributeL" ); |
|
620 |
|
621 switch( aAttribute ) |
|
622 { |
|
623 default: |
|
624 { |
|
625 User::Leave( KErrNotSupported ); |
|
626 } |
|
627 break; |
|
628 } |
|
629 } |
|
630 |
|
631 // -------------------------------------------------------------------------- |
|
632 // CCmPluginVpn::CanHandleIapIdL() |
|
633 // -------------------------------------------------------------------------- |
|
634 // |
|
635 TBool CCmPluginVpn::CanHandleIapIdL( TUint32 aIapId ) const |
|
636 { |
|
637 LOGGER_ENTERFN( "CCmPluginVpn::CanHandleIapIdL1" ); |
|
638 TBool retVal( EFalse ); |
|
639 |
|
640 CCDIAPRecord *iapRecord = static_cast<CCDIAPRecord *> |
|
641 (CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord)); |
|
642 |
|
643 CleanupStack::PushL( iapRecord ); |
|
644 iapRecord->SetRecordId( aIapId ); |
|
645 |
|
646 TRAPD( err, iapRecord->LoadL( Session() )); |
|
647 |
|
648 if( !err ) |
|
649 { |
|
650 CanHandleIapIdL( iapRecord ); |
|
651 } |
|
652 |
|
653 CleanupStack::PopAndDestroy( iapRecord ); |
|
654 return retVal; |
|
655 } |
|
656 |
|
657 // -------------------------------------------------------------------------- |
|
658 // CCmPluginVpn::CanHandleIapIdL() |
|
659 // -------------------------------------------------------------------------- |
|
660 // |
|
661 TBool CCmPluginVpn::CanHandleIapIdL( CCDIAPRecord *aIapRecord ) const |
|
662 { |
|
663 LOGGER_ENTERFN( "CCmPluginVpn::CanHandleIapIdL" ); |
|
664 |
|
665 TBool retVal( EFalse ); |
|
666 |
|
667 if( TPtrC(aIapRecord->iServiceType) == TPtrC(KCDTypeNameVPNService) || |
|
668 TPtrC(aIapRecord->iBearerType) == TPtrC(KCDTypeNameVirtualBearer) ) |
|
669 { |
|
670 retVal = ETrue; |
|
671 } |
|
672 |
|
673 return retVal; |
|
674 } |
|
675 |
|
676 // -------------------------------------------------------------------------- |
|
677 // CCmPluginVpn::RunSettingsL() |
|
678 // -------------------------------------------------------------------------- |
|
679 // |
|
680 TInt CCmPluginVpn::RunSettingsL() |
|
681 { |
|
682 LOGGER_ENTERFN( "CCmPluginVpn::RunSettingsL" ); |
|
683 CmPluginVpnSettingsDlg* dlg = CmPluginVpnSettingsDlg::NewL( *this ); |
|
684 |
|
685 return dlg->ConstructAndRunLD(); |
|
686 } |
|
687 |
|
688 // -------------------------------------------------------------------------- |
|
689 // CCmPluginVpn::LoadServiceSettingL() |
|
690 // -------------------------------------------------------------------------- |
|
691 // |
|
692 void CCmPluginVpn::LoadServiceSettingL() |
|
693 { |
|
694 LOGGER_ENTERFN( "CCmPluginVpn::LoadServiceSettingL" ); |
|
695 |
|
696 if( TPtrC(KCDTypeNameVPNService) == iIapRecord->iServiceType ) |
|
697 { |
|
698 iServiceRecord = static_cast<CCDVPNServiceRecord *> |
|
699 (CCDRecordBase::RecordFactoryL(KCDTIdVPNServiceRecord)); |
|
700 } |
|
701 else |
|
702 // this IAP service is not supported by this plugin. |
|
703 { |
|
704 User::Leave( KErrNotSupported ); |
|
705 } |
|
706 |
|
707 |
|
708 CCmPluginBaseEng::LoadServiceSettingL(); |
|
709 } |
|
710 |
|
711 |
|
712 // -------------------------------------------------------------------------- |
|
713 // CCmPluginVpn::LoadAdditionalRecordsL() |
|
714 // -------------------------------------------------------------------------- |
|
715 // |
|
716 void CCmPluginVpn::LoadAdditionalRecordsL() |
|
717 { |
|
718 LOGGER_ENTERFN( "CCmPluginVpn::LoadAdditionalRecordsL" ); |
|
719 |
|
720 iVirtualRecord = new (ELeave) CCDVirtualIAPNextLayerRecord( iVirtualTableId ); |
|
721 |
|
722 CMDBRecordSet<CCDVirtualIAPNextLayerRecord>* virtualRS = |
|
723 new(ELeave) CMDBRecordSet<CCDVirtualIAPNextLayerRecord>( iVirtualTableId ); |
|
724 CleanupStack::PushL( virtualRS ); |
|
725 |
|
726 CCDVirtualIAPNextLayerRecord* record = |
|
727 new (ELeave) CCDVirtualIAPNextLayerRecord( iVirtualTableId ); |
|
728 |
|
729 record->iIAP = iIapId; |
|
730 CleanupStack::PushL( record ); |
|
731 virtualRS->iRecords.AppendL( record ); |
|
732 CleanupStack::Pop( record ); |
|
733 record = NULL; |
|
734 |
|
735 if( virtualRS->FindL( Session() ) ) |
|
736 { |
|
737 iVirtualRecord->SetRecordId( (*virtualRS)[0]->RecordId() ); |
|
738 |
|
739 iVirtualRecord->LoadL( Session() ); |
|
740 |
|
741 CLOG_WRITE_3( "Next layer: IAP[%d], NextSNAP[%d], NextIAP[%d]", |
|
742 TUint( iVirtualRecord->iIAP ), |
|
743 TUint( iVirtualRecord->iNextLayerSNAP ), |
|
744 TUint( iVirtualRecord->iNextLayerIAP ) ); |
|
745 } |
|
746 else |
|
747 { |
|
748 CLOG_WRITE( "Virtual records not found" ); |
|
749 } |
|
750 |
|
751 CleanupStack::PopAndDestroy( virtualRS ); |
|
752 AddConverstionTableL( (CCDRecordBase**)&iVirtualRecord, NULL, SVpnVirtualIAPNextLayerConvTbl ); |
|
753 |
|
754 if (iIapRecord->iRecordName.GetL() == KNullDesC) |
|
755 { |
|
756 //now we have next layer info, so generate default cm name if name is empty (new cm) |
|
757 GenerateDefaultCmNameL(); |
|
758 } |
|
759 |
|
760 if ( !iProxyRecord->iPortNumber ) |
|
761 { |
|
762 iProxyRecord->iPortNumber = KVpnProxyPortNumberDefault; |
|
763 } |
|
764 } |
|
765 |
|
766 // -------------------------------------------------------------------------- |
|
767 // CCmPluginVpn::InitializeWithUiL() |
|
768 // -------------------------------------------------------------------------- |
|
769 // |
|
770 TBool CCmPluginVpn::InitializeWithUiL( TBool /*aManuallyConfigure*/ ) |
|
771 { |
|
772 LOGGER_ENTERFN( "CCmPluginVpn::InitializeWithUiL" ); |
|
773 TInt retVal( EFalse ); |
|
774 |
|
775 // Compile a list of bindable methods, issue a warning if none found |
|
776 if ( BindableRealConnectionsExistL() ) |
|
777 { |
|
778 // check if the intended destination is not available for VPN, |
|
779 // or, if the destination has not been set yet, whether there is |
|
780 // at least one suitable destination to place it in |
|
781 TBool validParent = EFalse; |
|
782 |
|
783 if ( iParentDest ) |
|
784 { |
|
785 // parent destination is known |
|
786 // check if it is not linked by any other VPN |
|
787 validParent = !HasUpstreamVpnL( iParentDest, ETrue ); |
|
788 } |
|
789 else |
|
790 { |
|
791 // parent destination is not known yet |
|
792 // check if there is any destination into which this VPN could be put |
|
793 |
|
794 // trigger the recalculation |
|
795 RArray<TUint32> parents ( CmMgr().DestinationCountL() ); |
|
796 CleanupClosePushL( parents ); |
|
797 |
|
798 CmMgr().AllDestinationsL( parents ); |
|
799 |
|
800 FilterPossibleParentsL( parents ); |
|
801 |
|
802 // if there is only one such destination, we should filter out |
|
803 // that one from the underlying candidates |
|
804 if ( parents.Count() == 1 ) |
|
805 { |
|
806 TInt destIndex = iBindableMethods.Find( parents[0] ); |
|
807 if ( destIndex != KErrNotFound ) |
|
808 { |
|
809 // got it, now remove |
|
810 iBindableMethods.Remove( destIndex ); |
|
811 } |
|
812 |
|
813 if ( iBindableMethods.Count() ) |
|
814 { |
|
815 // if there are still some methods to bind to, |
|
816 // mark the destination as valid |
|
817 validParent = ETrue; |
|
818 } |
|
819 |
|
820 } |
|
821 else |
|
822 { |
|
823 validParent = ( parents.Count() > 0 ); |
|
824 } |
|
825 |
|
826 CleanupStack::PopAndDestroy( &parents ); |
|
827 } |
|
828 |
|
829 if ( !validParent ) |
|
830 { |
|
831 TCmCommonUi::ShowNoteL( R_CMWIZARD_NO_VPN_STACKING, |
|
832 TCmCommonUi::ECmErrorNote ); |
|
833 |
|
834 return retVal; |
|
835 } |
|
836 |
|
837 |
|
838 // Check VPN policies installed on the device |
|
839 if ( ShowPolicySelectionDlgL() ) |
|
840 { |
|
841 retVal = ShowRealConnectionSelectionDlgL(); |
|
842 |
|
843 if ( retVal ) |
|
844 { |
|
845 if ( iIapRecord->iRecordName.GetL() == KNullDesC ) |
|
846 { |
|
847 // now we have next layer info, so generate default cm name |
|
848 GenerateDefaultCmNameL(); |
|
849 } |
|
850 |
|
851 } |
|
852 } |
|
853 } |
|
854 else |
|
855 { |
|
856 HBufC* buf = AllocReadL( R_QTN_NETW_CONSET_INFO_NO_CM_TO_BIND_TO ); |
|
857 TPtr ptr ( buf->Des() ); |
|
858 CleanupStack::PushL( buf ); |
|
859 TCmCommonUi::ShowNoteL( ptr, TCmCommonUi::ECmErrorNote ); |
|
860 CleanupStack::PopAndDestroy( buf ); |
|
861 } |
|
862 |
|
863 return retVal; |
|
864 } |
|
865 |
|
866 |
|
867 // -------------------------------------------------------------------------- |
|
868 // CCmPluginVpn::ServiceRecord() |
|
869 // -------------------------------------------------------------------------- |
|
870 // |
|
871 CCDVPNServiceRecord& CCmPluginVpn::ServiceRecord() const |
|
872 { |
|
873 LOGGER_ENTERFN( "CCmPluginVpn::ServiceRecord" ); |
|
874 return *static_cast<CCDVPNServiceRecord*>( iServiceRecord ); |
|
875 } |
|
876 |
|
877 // -------------------------------------------------------------------------- |
|
878 // CCmPluginVpn::ServiceRecordExists() |
|
879 // -------------------------------------------------------------------------- |
|
880 // |
|
881 TBool CCmPluginVpn::ServiceRecordExists() const |
|
882 { |
|
883 if ( !iServiceRecord ) |
|
884 { |
|
885 return EFalse; |
|
886 } |
|
887 return ETrue; |
|
888 } |
|
889 |
|
890 // -------------------------------------------------------------------------- |
|
891 // CCmPluginVpn::CreateNewServiceRecordL() |
|
892 // -------------------------------------------------------------------------- |
|
893 // |
|
894 void CCmPluginVpn::CreateNewServiceRecordL() |
|
895 { |
|
896 LOGGER_ENTERFN( "CCmPluginVpn::CreateNewServiceRecordL" ); |
|
897 |
|
898 delete iServiceRecord; iServiceRecord = NULL; |
|
899 |
|
900 iServiceRecord = static_cast<CCDVPNServiceRecord *> |
|
901 (CCDRecordBase::RecordFactoryL( KCDTIdVPNServiceRecord )); |
|
902 |
|
903 CLOG_WRITE("New service record, policy emptied"); |
|
904 ServiceRecord().iServicePolicy.SetL( KNullDesC ); |
|
905 ServiceRecord().iServiceIAP = 0; |
|
906 ServiceRecord().iServiceNetwork = 0; |
|
907 ServiceRecord().iServiceSNAP = 0; |
|
908 |
|
909 |
|
910 iProxyRecord->iPortNumber = KVpnProxyPortNumberDefault; |
|
911 |
|
912 SetIntAttributeL( ECmSeamlessnessLevel, ESeamlessnessShowprogress ); |
|
913 } |
|
914 |
|
915 // --------------------------------------------------------------------------- |
|
916 // CCmPluginVpn::CreateAdditionalRecordsL |
|
917 // --------------------------------------------------------------------------- |
|
918 // |
|
919 void CCmPluginVpn::CreateAdditionalRecordsL() |
|
920 { |
|
921 LOGGER_ENTERFN( "CCmPluginVpn::CreateAdditionalRecordsL" ); |
|
922 |
|
923 delete iVirtualRecord; |
|
924 iVirtualRecord = NULL; |
|
925 |
|
926 iVirtualRecord = new (ELeave) CCDVirtualIAPNextLayerRecord( iVirtualTableId ); |
|
927 } |
|
928 |
|
929 // --------------------------------------------------------------------------- |
|
930 // CCmPluginVpn::UpdateServiceRecordL |
|
931 // --------------------------------------------------------------------------- |
|
932 // |
|
933 void CCmPluginVpn::UpdateServiceRecordL() |
|
934 { |
|
935 LOGGER_ENTERFN( "CCmPluginVpn::UpdateServiceRecordL" ); |
|
936 |
|
937 CCmPluginBaseEng::UpdateServiceRecordL(); |
|
938 } |
|
939 |
|
940 // --------------------------------------------------------------------------- |
|
941 // CCmPluginVpn::UpdateAdditionalRecordsL |
|
942 // --------------------------------------------------------------------------- |
|
943 // |
|
944 void CCmPluginVpn::UpdateAdditionalRecordsL() |
|
945 { |
|
946 LOGGER_ENTERFN( "CCmPluginVpn::UpdateAdditionalRecordsL" ); |
|
947 |
|
948 CheckIfNameModifiedL( iVirtualRecord ); |
|
949 |
|
950 if( !iVirtualRecord->RecordId() ) |
|
951 { |
|
952 iVirtualRecord->SetRecordId( KCDNewRecordRequest ); |
|
953 |
|
954 iVirtualRecord->iIAP = iIapId; |
|
955 iVirtualRecord->StoreL( Session() ); |
|
956 } |
|
957 else |
|
958 { |
|
959 iVirtualRecord->ModifyL( Session() ); |
|
960 } |
|
961 } |
|
962 |
|
963 // --------------------------------------------------------------------------- |
|
964 // CCmPluginVpn::ServiceRecordIdLC |
|
965 // --------------------------------------------------------------------------- |
|
966 // |
|
967 void CCmPluginVpn::ServiceRecordIdLC( HBufC* &aName, |
|
968 TUint32& aRecordId ) |
|
969 { |
|
970 LOGGER_ENTERFN( "CCmPluginVpn::ServiceRecordIdLC" ); |
|
971 |
|
972 aName = TPtrC( KCDTypeNameVPNService ).AllocLC(); |
|
973 aRecordId = iServiceRecord->RecordId(); |
|
974 } |
|
975 |
|
976 // -------------------------------------------------------------------------- |
|
977 // CCmPluginVpn::BearerRecordIdLC() |
|
978 // -------------------------------------------------------------------------- |
|
979 // |
|
980 void CCmPluginVpn::BearerRecordIdLC( HBufC* &aBearerName, |
|
981 TUint32& aRecordId ) |
|
982 { |
|
983 LOGGER_ENTERFN( "CCmPluginVpn::BearerRecordIdLC" ); |
|
984 |
|
985 CMDBRecordSet<CCDVirtualBearerRecord>* bearersRS = |
|
986 new(ELeave) CMDBRecordSet<CCDVirtualBearerRecord> |
|
987 (KCDTIdVirtualBearerRecord); |
|
988 CleanupStack::PushL( bearersRS ); |
|
989 |
|
990 // Now try to find the linked proxy record |
|
991 // create new record |
|
992 CCDVirtualBearerRecord* bearerRecord = |
|
993 static_cast<CCDVirtualBearerRecord *> |
|
994 (CCDRecordBase::RecordFactoryL(KCDTIdVirtualBearerRecord)); |
|
995 |
|
996 CleanupStack::PushL( bearerRecord ); |
|
997 |
|
998 bearerRecord->iBearerAgent.SetL( KVpnVirtualBearerAgent ); |
|
999 |
|
1000 bearersRS->iRecords.AppendL( bearerRecord ); |
|
1001 |
|
1002 CleanupStack::Pop( bearerRecord ); |
|
1003 bearerRecord = NULL; |
|
1004 |
|
1005 CLOG_WRITE_1( "Looking for bearer: [%d]", TUint32(iIapRecord->iService) ); |
|
1006 |
|
1007 if ( !bearersRS->FindL( Session() ) ) |
|
1008 // No bearer record found -> create a default one. |
|
1009 { |
|
1010 bearerRecord = static_cast<CCDVirtualBearerRecord *> |
|
1011 (CCDRecordBase::RecordFactoryL(KCDTIdVirtualBearerRecord)); |
|
1012 CleanupStack::PushL(bearerRecord); |
|
1013 |
|
1014 bearerRecord->iRecordName.SetL( KVpnVirtualBearerName ); |
|
1015 bearerRecord->iBearerAgent.SetL( KVpnVirtualBearerAgent ); |
|
1016 bearerRecord->iVirtualBearerNifName.SetL(KVpnVirtualBearerNif); |
|
1017 bearerRecord->iLastSocketActivityTimeout = (TUint32)KNoTimeout; |
|
1018 bearerRecord->iLastSessionClosedTimeout = KLastSessionTimeout; |
|
1019 bearerRecord->iLastSocketClosedTimeout = (TUint32)KNoTimeout; |
|
1020 |
|
1021 bearerRecord->SetRecordId( KCDNewRecordRequest ); |
|
1022 bearerRecord->StoreL( Session() ); |
|
1023 |
|
1024 aRecordId = bearerRecord->RecordId(); |
|
1025 |
|
1026 CleanupStack::PopAndDestroy(bearerRecord); |
|
1027 } |
|
1028 else |
|
1029 { |
|
1030 aRecordId = (*bearersRS)[0]->RecordId(); |
|
1031 } |
|
1032 |
|
1033 CleanupStack::PopAndDestroy( bearersRS ); |
|
1034 |
|
1035 aBearerName = TPtrC( KCDTypeNameVirtualBearer ).AllocLC(); |
|
1036 } |
|
1037 |
|
1038 // -------------------------------------------------------------------------- |
|
1039 // CCmPluginVpn::AdditionalReset() |
|
1040 // -------------------------------------------------------------------------- |
|
1041 // |
|
1042 void CCmPluginVpn::AdditionalReset() |
|
1043 { |
|
1044 LOGGER_ENTERFN( "CCmPluginVpn::AdditionalReset" ); |
|
1045 |
|
1046 delete iNetworkRecord; |
|
1047 iNetworkRecord = NULL; |
|
1048 |
|
1049 delete iVirtualRecord; |
|
1050 iVirtualRecord = NULL; |
|
1051 } |
|
1052 |
|
1053 // -------------------------------------------------------------------------- |
|
1054 // CCmPluginVpn::PrepareToUpdateRecordsL() |
|
1055 // -------------------------------------------------------------------------- |
|
1056 // |
|
1057 void CCmPluginVpn::PrepareToUpdateRecordsL() |
|
1058 { |
|
1059 LOGGER_ENTERFN( "CCmPluginVpn::PrepareToUpdateRecordsL" ); |
|
1060 // Check here if every data of the connection method is valid |
|
1061 // before records were saved to CommsDat. |
|
1062 // Set incorrect attribute id in iInvalidAttribute and leave |
|
1063 // with KErrArgument. |
|
1064 } |
|
1065 |
|
1066 // -------------------------------------------------------------------------- |
|
1067 // CCmPluginVpn::ShowPolicySelectionDlgL |
|
1068 // -------------------------------------------------------------------------- |
|
1069 // |
|
1070 TBool CCmPluginVpn::ShowPolicySelectionDlgL() |
|
1071 { |
|
1072 LOGGER_ENTERFN( "CCmPluginVpn::ShowPolicySelectionDlgL" ); |
|
1073 |
|
1074 TBool retVal ( EFalse ); |
|
1075 |
|
1076 CmPluginVpnPolicySelectionDlg* dlg = |
|
1077 CmPluginVpnPolicySelectionDlg::NewL( *this ); |
|
1078 CleanupStack::PushL( dlg ); |
|
1079 retVal = dlg->ShowPolicySelectionListL(); |
|
1080 CleanupStack::PopAndDestroy(); |
|
1081 |
|
1082 return retVal; |
|
1083 } |
|
1084 |
|
1085 |
|
1086 // -------------------------------------------------------------------------- |
|
1087 // CCmPluginVpn::BindableRealConnectionsExistL |
|
1088 // -------------------------------------------------------------------------- |
|
1089 // |
|
1090 TBool CCmPluginVpn::BindableRealConnectionsExistL() |
|
1091 { |
|
1092 LOGGER_ENTERFN( "CCmPluginVpn::BindableRealConnectionsExistL" ); |
|
1093 |
|
1094 TBool retVal ( EFalse ); |
|
1095 |
|
1096 iBindableMethods.Close(); |
|
1097 |
|
1098 // Compile and array of destination IDs which the VPN CM can be bound to |
|
1099 // includes Uncategorised destination and Easy WLAN if valid |
|
1100 CmMgr().AllDestinationsL( iBindableMethods ); |
|
1101 |
|
1102 // Filter out invalid methods |
|
1103 for ( TInt i = 0; i < iBindableMethods.Count(); i++ ) |
|
1104 { |
|
1105 TUint32 bindresult = |
|
1106 CanDestUsedAsUnderlyingConnectionL( iBindableMethods[i] ); |
|
1107 |
|
1108 if ( bindresult & (KBindDenied | KNoNonVirtuals | KEmptyDest ) ) |
|
1109 { |
|
1110 iBindableMethods.Remove( i ); |
|
1111 i--; |
|
1112 } |
|
1113 } |
|
1114 |
|
1115 // If there are destination IDs which the VPN CM can be bound to. |
|
1116 if( iBindableMethods.Count() ) |
|
1117 { |
|
1118 retVal = ETrue; |
|
1119 } |
|
1120 |
|
1121 // 2. Are there uncategorised connection methods which aren't virtual? |
|
1122 RArray<TUint32> cmArray ( KCmArrayMediumGranularity ); |
|
1123 CleanupClosePushL( cmArray ); |
|
1124 CmMgr().ConnectionMethodL( cmArray, EFalse ); |
|
1125 |
|
1126 for ( TInt k = 0; k < cmArray.Count(); k++ ) |
|
1127 { |
|
1128 TInt bearerType (0); |
|
1129 TRAPD( err, bearerType = CmMgr().GetConnectionMethodInfoIntL( |
|
1130 cmArray[k], ECmBearerType );); |
|
1131 |
|
1132 //if no plugin is found to handle the bearertype, GetConnectionMethodInfoIntL leaves with KErrNotSupported |
|
1133 if ( err == KErrNotSupported ) |
|
1134 { |
|
1135 //continue with the next element in the array |
|
1136 continue; |
|
1137 } |
|
1138 |
|
1139 // uncategorised contains a non-virtual connection method |
|
1140 if ( !CmMgr().GetBearerInfoBoolL( bearerType, ECmVirtual ) ) |
|
1141 { |
|
1142 retVal = ETrue; |
|
1143 iBindableMethods.Append( KDestItemUncategorized ); |
|
1144 break; |
|
1145 } |
|
1146 } |
|
1147 CleanupStack::PopAndDestroy( &cmArray ); |
|
1148 |
|
1149 // 3. Is Easy WLAN available? |
|
1150 if ( FeatureManager::FeatureSupported( KFeatureIdProtocolWlan ) ) |
|
1151 { |
|
1152 // easy wlan is available |
|
1153 if ( CmMgr().EasyWlanIdL() ) |
|
1154 { |
|
1155 iBindableMethods.Append( KDestItemEasyWlan ); |
|
1156 retVal = ETrue; |
|
1157 } |
|
1158 } |
|
1159 |
|
1160 return retVal; |
|
1161 } |
|
1162 |
|
1163 // -------------------------------------------------------------------------- |
|
1164 // CCmPluginVpn::ShowRealConnectionSelectionDlgL |
|
1165 // -------------------------------------------------------------------------- |
|
1166 // |
|
1167 TBool CCmPluginVpn::ShowRealConnectionSelectionDlgL() |
|
1168 { |
|
1169 LOGGER_ENTERFN( "CCmPluginVpn::ShowRealConnectionSelectionDlgL" ); |
|
1170 TBool retVal ( EFalse ); |
|
1171 |
|
1172 TBool snapSelected ( EFalse ); |
|
1173 TUint32 nextLayerId ( 0 ); |
|
1174 |
|
1175 CmPluginVpnNextLayerSelectDlg* dlg = |
|
1176 CmPluginVpnNextLayerSelectDlg::NewL( *this, |
|
1177 iBindableMethods, |
|
1178 snapSelected, |
|
1179 nextLayerId ); |
|
1180 if ( dlg->ExecuteLD( R_VPN_REAL_CM_SELECTION_LIST ) ) |
|
1181 { |
|
1182 // Handle results |
|
1183 retVal = ETrue; |
|
1184 } |
|
1185 |
|
1186 return retVal; |
|
1187 } |
|
1188 |
|
1189 // -------------------------------------------------------------------------- |
|
1190 // CCmPluginVpn::IsLinkedToIap |
|
1191 // -------------------------------------------------------------------------- |
|
1192 // |
|
1193 TBool CCmPluginVpn::IsLinkedToIap( TUint32 aIapId ) |
|
1194 { |
|
1195 LOGGER_ENTERFN( "CCmPluginVpn::IsLinkedToIap" ); |
|
1196 |
|
1197 return ( ServiceRecord().iServiceIAP == aIapId ); |
|
1198 } |
|
1199 |
|
1200 |
|
1201 // -------------------------------------------------------------------------- |
|
1202 // CCmPluginVpn::IsLinkedToSnap |
|
1203 // -------------------------------------------------------------------------- |
|
1204 // |
|
1205 TBool CCmPluginVpn::IsLinkedToSnap( TUint32 aSnapId ) |
|
1206 { |
|
1207 LOGGER_ENTERFN( "CCmPluginVpn::IsLinkedToSnap" ); |
|
1208 |
|
1209 return ( iVirtualRecord->iNextLayerSNAP == aSnapId ); |
|
1210 } |
|
1211 |
|
1212 |
|
1213 // --------------------------------------------------------------------------- |
|
1214 // CCmPluginVpn::RestoreAttributeL |
|
1215 // --------------------------------------------------------------------------- |
|
1216 // |
|
1217 void CCmPluginVpn::RestoreAttributeL( const TUint32 aAttribute ) |
|
1218 { |
|
1219 LOGGER_ENTERFN( "CCmPluginVpn::RestoreAttributeL" ); |
|
1220 |
|
1221 if ( aAttribute == EVpnServicePolicyName ) |
|
1222 { |
|
1223 // also restore policy name |
|
1224 RVpnServ ps; |
|
1225 CleanupClosePushL<RVpnServ>( ps ); |
|
1226 |
|
1227 TInt err = ps.Connect(); |
|
1228 |
|
1229 if ( !err ) |
|
1230 { |
|
1231 if( !ServiceRecordExists() ) |
|
1232 { |
|
1233 User::Leave( KErrNotSupported ); |
|
1234 } |
|
1235 |
|
1236 CCDVPNServiceRecord *r = &(ServiceRecord()); |
|
1237 TVpnPolicyName pId( r->iServicePolicy ); |
|
1238 |
|
1239 TInt policyCount(0); |
|
1240 err = ps.EnumeratePolicies(policyCount); |
|
1241 if ( !err && policyCount) |
|
1242 { |
|
1243 CArrayFixFlat<TVpnPolicyInfo>* policyList; |
|
1244 policyList = new (ELeave) CArrayFixFlat<TVpnPolicyInfo>(policyCount); |
|
1245 CleanupStack::PushL(policyList); |
|
1246 |
|
1247 err = ps.GetPolicyInfoList(policyList); |
|
1248 |
|
1249 TBool found(EFalse); |
|
1250 |
|
1251 if ( err == KErrNone ) |
|
1252 { |
|
1253 for (TInt i(0); i<policyList->Count(); ++i) |
|
1254 { |
|
1255 if (pId.Compare((*policyList)[i].iId) == 0 ) |
|
1256 { |
|
1257 SetStringAttributeL( EVpnServicePolicyName, |
|
1258 (*policyList)[i].iName ); |
|
1259 found = ETrue; |
|
1260 break; |
|
1261 } |
|
1262 } |
|
1263 } |
|
1264 |
|
1265 if ( err || (!found) ) |
|
1266 { |
|
1267 CLOG_WRITE_1("Error when restoring policy attribute, [%d]", err ); |
|
1268 // the set policies are not installed, |
|
1269 // or we can not access vpn client: |
|
1270 // Must be defined qtn_selec_setting_compulsory is displayed |
|
1271 // for the invalid settings. |
|
1272 // reset policy to compulsory |
|
1273 SetStringAttributeL( EVpnServicePolicyName, |
|
1274 KNullDesC() ); |
|
1275 SetStringAttributeL( EVpnServicePolicy, |
|
1276 KNullDesC() ); |
|
1277 } |
|
1278 CleanupStack::PopAndDestroy(policyList); |
|
1279 } |
|
1280 } |
|
1281 CleanupStack::PopAndDestroy(); // ps.Close |
|
1282 } |
|
1283 // Type of EVpnIapId is ELink. This is plugin specified type. |
|
1284 // So, it should be handled here. |
|
1285 else if( aAttribute == EVpnIapId ) |
|
1286 { |
|
1287 if( !ServiceRecordExists() ) |
|
1288 { |
|
1289 User::Leave( KErrNotSupported ); |
|
1290 } |
|
1291 |
|
1292 ServiceRecord().iServiceIAP = 0; |
|
1293 iVirtualRecord->iNextLayerIAP = 0; |
|
1294 iVirtualRecord->iNextLayerSNAP = 0; |
|
1295 } |
|
1296 else |
|
1297 { |
|
1298 CCmPluginBaseEng::RestoreAttributeL( aAttribute ); |
|
1299 } |
|
1300 } |
|
1301 |
|
1302 |
|
1303 |
|
1304 // -------------------------------------------------------------------------- |
|
1305 // CCmPluginVpn::GenerateDefaultCmNameL |
|
1306 // -------------------------------------------------------------------------- |
|
1307 // |
|
1308 void CCmPluginVpn::GenerateDefaultCmNameL() |
|
1309 { |
|
1310 LOGGER_ENTERFN( "CCmPluginVpn::GenerateDefaultCmNameL" ); |
|
1311 |
|
1312 //create default string |
|
1313 RFs fs; |
|
1314 CleanupClosePushL<RFs>( fs ); |
|
1315 User::LeaveIfError( fs.Connect() ); |
|
1316 |
|
1317 // There may not be a UI context yet.... |
|
1318 TFileName resourceFile; |
|
1319 _LIT( KDriveZ, "z:" ); |
|
1320 resourceFile.Append( KDriveZ ); |
|
1321 resourceFile.Append( KDC_RESOURCE_FILES_DIR ); |
|
1322 _LIT( KCmmResFileName, "cmpluginvpnui.rsc" ); |
|
1323 resourceFile.Append( KCmmResFileName ); |
|
1324 BaflUtils::NearestLanguageFile( fs, resourceFile ); |
|
1325 |
|
1326 RResourceFile rf; |
|
1327 CleanupClosePushL<RResourceFile>( rf ); |
|
1328 rf.OpenL( fs, resourceFile ); |
|
1329 rf.ConfirmSignatureL( 0 ); |
|
1330 HBufC8* readBuffer = rf.AllocReadLC( R_QTN_NETW_CONSET_METHOD_NAME_VPN ); |
|
1331 const TPtrC16 ptrReadBuffer( (TText16*) readBuffer->Ptr(), |
|
1332 ( readBuffer->Length() + 1 ) >> 1 ); |
|
1333 HBufC16* textBuffer=HBufC16::NewL( ptrReadBuffer.Length() ); |
|
1334 CleanupStack::PushL( textBuffer ); |
|
1335 *textBuffer=ptrReadBuffer; |
|
1336 |
|
1337 // Find %U and replace it with %S |
|
1338 TPtr sourceString = textBuffer->Des(); |
|
1339 _LIT(KPercentS,"%S"); |
|
1340 _LIT(KPercentU,"%U"); |
|
1341 TInt puPos = sourceString.Find(KPercentU); |
|
1342 if ( puPos >= 0 ) |
|
1343 { |
|
1344 sourceString.Replace( puPos, |
|
1345 static_cast<TDesC>(KPercentS).Length(), KPercentS ); |
|
1346 } |
|
1347 |
|
1348 // Check if there is a length defined in copy of the recourse string e.g. "VPN(%U[08])" |
|
1349 // If it's found convert it to integer and remove it from the string. |
|
1350 TInt maxDataLength( 0 ); |
|
1351 TInt perceLength = static_cast<TDesC>(KPercentS).Length(); |
|
1352 if ( sourceString[puPos+perceLength] == '[' ) |
|
1353 { |
|
1354 // Key includes max datalength |
|
1355 maxDataLength = 10*( sourceString[puPos+perceLength+1]-'0' ) |
|
1356 + ( sourceString[puPos+perceLength+2]-'0' ); |
|
1357 sourceString.Delete(puPos+perceLength,4); |
|
1358 } |
|
1359 |
|
1360 // Get the IAP name which the VPM Connection Method points to |
|
1361 HBufC* refName = NULL; |
|
1362 |
|
1363 if( !ServiceRecordExists() ) |
|
1364 { |
|
1365 User::Leave( KErrNotSupported ); |
|
1366 } |
|
1367 |
|
1368 if ( ServiceRecord().iServiceIAP ) |
|
1369 { |
|
1370 // ask for the bearer type |
|
1371 TUint32 bearerType = CmMgr().GetConnectionMethodInfoIntL( |
|
1372 ServiceRecord().iServiceIAP, ECmBearerType ); |
|
1373 |
|
1374 if ( iCmMgr.EasyWlanIdL() && bearerType == KUidWlanBearerType ) |
|
1375 { |
|
1376 refName = GenerateVPNPointToWLANNetworkLC(rf, refName); |
|
1377 } |
|
1378 else |
|
1379 { |
|
1380 refName = iCmMgr.GetConnectionMethodInfoStringL( |
|
1381 ServiceRecord().iServiceIAP, |
|
1382 ECmName ); |
|
1383 CleanupStack::PushL( refName ); |
|
1384 } |
|
1385 } |
|
1386 else |
|
1387 { |
|
1388 CCmDestinationImpl* dest = iCmMgr.DestinationL( |
|
1389 iVirtualRecord->iNextLayerSNAP ); |
|
1390 CleanupStack::PushL( dest ); |
|
1391 refName = dest->NameLC(); |
|
1392 CleanupStack::Pop( refName ); |
|
1393 CleanupStack::PopAndDestroy( dest ); |
|
1394 CleanupStack::PushL( refName ); |
|
1395 } |
|
1396 |
|
1397 TPtr16 refNamePtr = refName->Des(); |
|
1398 // If there was a length definition e.g. [08]--> length is 8 the CM or |
|
1399 // Destination name must be cut to length - 1 and copy the ellipsis(shown as |
|
1400 // "...") to the end. |
|
1401 if( maxDataLength > 0 && refName->Length() > maxDataLength ) |
|
1402 { |
|
1403 refNamePtr.Delete( maxDataLength-1, refName->Length()-maxDataLength+1); |
|
1404 TText ellipsis(KEllipsis); |
|
1405 refNamePtr.Insert( maxDataLength-1, TPtrC(&ellipsis,1) ); |
|
1406 } |
|
1407 |
|
1408 if ( maxDataLength == 0 ) |
|
1409 { |
|
1410 // Length not defined in resource string so set it to refName length |
|
1411 maxDataLength = refNamePtr.Length(); |
|
1412 } |
|
1413 |
|
1414 HBufC* cmName = HBufC::NewL( sourceString.Length() + maxDataLength ); |
|
1415 CleanupStack::PushL( cmName ); |
|
1416 cmName->Des().Format(sourceString, &refNamePtr); |
|
1417 SetStringAttributeL( ECmName, *cmName ); |
|
1418 CleanupStack::PopAndDestroy( cmName ); |
|
1419 CleanupStack::PopAndDestroy( refName ); |
|
1420 CleanupStack::PopAndDestroy( textBuffer ); |
|
1421 CleanupStack::PopAndDestroy( readBuffer ); |
|
1422 CleanupStack::PopAndDestroy( &rf ); |
|
1423 CleanupStack::PopAndDestroy( &fs ); |
|
1424 } |
|
1425 |
|
1426 // -------------------------------------------------------------------------- |
|
1427 // CCmPluginVpn::GenerateDefaultCmNameL |
|
1428 // -------------------------------------------------------------------------- |
|
1429 // |
|
1430 void CCmPluginVpn::CreateNewL() |
|
1431 { |
|
1432 CCmPluginBaseEng::CreateNewL(); |
|
1433 |
|
1434 iIapRecord->iRecordName.SetL( KNullDesC ); |
|
1435 } |
|
1436 |
|
1437 |
|
1438 |
|
1439 // -------------------------------------------------------------------------- |
|
1440 // CCmPluginVpn::LoadL |
|
1441 // -------------------------------------------------------------------------- |
|
1442 // |
|
1443 void CCmPluginVpn::LoadL( TUint32 aIapId ) |
|
1444 { |
|
1445 CCmPluginBaseEng::LoadL( aIapId ); |
|
1446 if ( iServiceRecord ) |
|
1447 { |
|
1448 // UpdatePolicyNameL(); |
|
1449 } |
|
1450 } |
|
1451 |
|
1452 |
|
1453 // -------------------------------------------------------------------------- |
|
1454 // CCmPluginVpn::UpdatePolicyNameL |
|
1455 // -------------------------------------------------------------------------- |
|
1456 // |
|
1457 void CCmPluginVpn::UpdatePolicyNameL() |
|
1458 { |
|
1459 LOGGER_ENTERFN( "CCmPluginVpn::UpdatePolicyNameL" ); |
|
1460 // now get policy name from ID |
|
1461 |
|
1462 RVpnServ ps; |
|
1463 CleanupClosePushL<RVpnServ>( ps ); |
|
1464 TInt err = ps.Connect(); |
|
1465 |
|
1466 CLOG_WRITE_1( "Connected to VPN server, err [%d]", err ); |
|
1467 |
|
1468 if (! err ) |
|
1469 { |
|
1470 if( !ServiceRecordExists() ) |
|
1471 { |
|
1472 User::Leave( KErrNotSupported ); |
|
1473 } |
|
1474 |
|
1475 CCDVPNServiceRecord *r = &(ServiceRecord()); |
|
1476 TVpnPolicyName pId( r->iServicePolicy ); |
|
1477 TInt policyCount(0); |
|
1478 err = ps.EnumeratePolicies(policyCount); |
|
1479 if ( !err && policyCount) |
|
1480 { |
|
1481 CArrayFixFlat<TVpnPolicyInfo>* policyList; |
|
1482 policyList = new (ELeave) CArrayFixFlat<TVpnPolicyInfo>(policyCount); |
|
1483 CleanupStack::PushL(policyList); |
|
1484 |
|
1485 err = ps.GetPolicyInfoList(policyList); |
|
1486 if ( err ) |
|
1487 { |
|
1488 // the set policies are not installed, |
|
1489 // Must be defined qtn_selec_setting_compulsory is displayed |
|
1490 // for the invalid settings. |
|
1491 // reset policy to compulsory |
|
1492 SetStringAttributeL( EVpnServicePolicyName, |
|
1493 KNullDesC() ); |
|
1494 SetStringAttributeL( EVpnServicePolicy, |
|
1495 KNullDesC() ); |
|
1496 } |
|
1497 else |
|
1498 { |
|
1499 for (TInt i(0); i<policyList->Count(); ++i) |
|
1500 { |
|
1501 if (pId.Compare((*policyList)[i].iId) == 0 ) |
|
1502 { |
|
1503 SetStringAttributeL( EVpnServicePolicyName, |
|
1504 (*policyList)[i].iName ); |
|
1505 break; |
|
1506 } |
|
1507 } |
|
1508 } |
|
1509 CleanupStack::PopAndDestroy(policyList); |
|
1510 } |
|
1511 } |
|
1512 CleanupStack::PopAndDestroy(); // ps.close |
|
1513 } |
|
1514 |
|
1515 |
|
1516 // -------------------------------------------------------------------------- |
|
1517 // CCmPluginVpn::CanDestUsedAsUnderlyingConnectionL |
|
1518 // -------------------------------------------------------------------------- |
|
1519 // |
|
1520 TUint32 CCmPluginVpn::CanDestUsedAsUnderlyingConnectionL( TUint32 aDestinationId ) |
|
1521 { |
|
1522 LOGGER_ENTERFN( "CCmPluginVpn::CanDestUsedAsUnderlyingConnectionL" ); |
|
1523 |
|
1524 TUint32 retval(KEmptyDest); |
|
1525 |
|
1526 TBool hasNonVirtualCm(EFalse); |
|
1527 |
|
1528 CCmDestinationImpl* dest = CmMgr().DestinationL( aDestinationId ); |
|
1529 CleanupStack::PushL( dest ); |
|
1530 |
|
1531 // is this our parent destination (if there is one) |
|
1532 CCmDestinationImpl* parentDest = ParentDestination(); |
|
1533 if ( parentDest ) |
|
1534 { |
|
1535 if ( dest->Id() == parentDest->Id() ) |
|
1536 { |
|
1537 retval |= KLinksBackToParent; |
|
1538 } |
|
1539 } |
|
1540 delete parentDest; |
|
1541 if ( !( retval & KBindDenied ) ) |
|
1542 { |
|
1543 // filter out: |
|
1544 // empty destinations |
|
1545 // destinations containing VPN in or linked in |
|
1546 // destinations containing emb. dest. if the linked dest is empty |
|
1547 |
|
1548 // so if we found a VPN inside, or a VPN linked through an amb. dest, |
|
1549 // than it should be filtered out. |
|
1550 // it also should be filtered out if it links back |
|
1551 // to our parent dest. in any way... |
|
1552 |
|
1553 TInt count = dest->ConnectionMethodCount(); |
|
1554 |
|
1555 if ( count ) |
|
1556 { |
|
1557 // has at least one CM |
|
1558 retval &= ~KEmptyDest; |
|
1559 for ( TInt j = 0; j < dest->ConnectionMethodCount(); j++ ) |
|
1560 { |
|
1561 CCmPluginBase* cm = dest->GetConnectionMethodL( j ); |
|
1562 CleanupStack::PushL( cm ); |
|
1563 TUint32 cmId = cm->GetIntAttributeL( ECmId ); |
|
1564 |
|
1565 TInt bearerType = CmMgr().GetConnectionMethodInfoIntL( |
|
1566 cmId, ECmBearerType ); |
|
1567 if ( !CmMgr().GetBearerInfoBoolL( bearerType, ECmVirtual ) ) |
|
1568 { |
|
1569 // found a non-virtual connection method |
|
1570 hasNonVirtualCm = ETrue; |
|
1571 } |
|
1572 else |
|
1573 { |
|
1574 // now we have to check if it is an emb.dest., if it is, |
|
1575 // check if the referenced destination is not empty, |
|
1576 // it has at least one, non-virtual CM, |
|
1577 // OR it has another emb.dest., then recurse it... |
|
1578 if ( CmMgr().GetBearerInfoBoolL( bearerType, ECmDestination ) ) |
|
1579 { // it is an emb. destination |
|
1580 // get the emb. destination |
|
1581 CCmDestinationImpl* embdest = cm->Destination(); |
|
1582 TUint32 emdestId = embdest->Id(); |
|
1583 // check if the embeded destination can be used |
|
1584 TUint32 res = CanDestUsedAsUnderlyingConnectionL( emdestId ); |
|
1585 if ( res & KBindDenied ) |
|
1586 { |
|
1587 // emb. dest. can not be used |
|
1588 retval |= (res & KBindDenied ); |
|
1589 } |
|
1590 else |
|
1591 { |
|
1592 // if binding is not denied, still what to do with |
|
1593 // KEmptyDest & KNoNonVirtuals? |
|
1594 // if it does not return KNoNonVirtuals, then it |
|
1595 // has at least one, non-virt. CM |
|
1596 if ( res & KNoNonVirtuals ) |
|
1597 { |
|
1598 // if we already have a non-virt, then it is no |
|
1599 // problem, no need to change hasNonVirtualCm |
|
1600 // as it starts from EFalse. |
|
1601 } |
|
1602 else |
|
1603 { |
|
1604 // if it is not empty, than |
|
1605 // it has at least one, non-virt. CM, so: |
|
1606 if ( !( res & KEmptyDest ) ) |
|
1607 { |
|
1608 hasNonVirtualCm = ETrue; |
|
1609 } |
|
1610 } |
|
1611 // if it is an empty dest., then: |
|
1612 // if we still have the base as empty, then |
|
1613 // there is nothing to do. |
|
1614 // if the base is non-empty, again, nothing to do |
|
1615 if ( !(res & KEmptyDest ) ) |
|
1616 { |
|
1617 // not empty dest, so set base |
|
1618 // value to reflect it |
|
1619 hasNonVirtualCm = ETrue; |
|
1620 } |
|
1621 } |
|
1622 } |
|
1623 else |
|
1624 { |
|
1625 // virtual, but not emb. dest |
|
1626 // check if it is VPN |
|
1627 // if it is VPN, |
|
1628 if ( bearerType == KPluginVPNBearerTypeUid ) |
|
1629 { |
|
1630 retval |= KContainsVpn; |
|
1631 } |
|
1632 } |
|
1633 } |
|
1634 CleanupStack::Pop( cm ); |
|
1635 cm = NULL; // not owned |
|
1636 if ( retval & KBindDenied ) |
|
1637 { // binding is already denied, we can break... |
|
1638 break; |
|
1639 } |
|
1640 } |
|
1641 if ( !hasNonVirtualCm ) |
|
1642 { |
|
1643 retval |= KNoNonVirtuals; |
|
1644 } |
|
1645 } |
|
1646 else |
|
1647 { |
|
1648 retval |= KEmptyDest; |
|
1649 } |
|
1650 } |
|
1651 CleanupStack::PopAndDestroy( dest ); |
|
1652 |
|
1653 return retval; |
|
1654 } |
|
1655 |
|
1656 |
|
1657 |
|
1658 // -------------------------------------------------------------------------- |
|
1659 // CCmPluginVpn::BindableDestinationsL |
|
1660 // -------------------------------------------------------------------------- |
|
1661 // |
|
1662 void CCmPluginVpn::BindableDestinationsL( RArray<TUint32>& aDestinationArray ) |
|
1663 { |
|
1664 LOGGER_ENTERFN( "CCmPluginVpn::BindableDestinationsL" ); |
|
1665 TUint32 upLimit = KCmDefaultDestinationAPTagId + 0xff; |
|
1666 |
|
1667 aDestinationArray.Close(); |
|
1668 if ( BindableRealConnectionsExistL() ) |
|
1669 { |
|
1670 for (TInt i=0; i<iBindableMethods.Count(); i++) |
|
1671 { |
|
1672 if ( iBindableMethods[i] <= KDestMaxId || |
|
1673 (iBindableMethods[i] > KCmDefaultDestinationAPTagId && iBindableMethods[i] <= upLimit) ) |
|
1674 { |
|
1675 aDestinationArray.AppendL( iBindableMethods[i] ); |
|
1676 } |
|
1677 } |
|
1678 } |
|
1679 } |
|
1680 |
|
1681 |
|
1682 // -------------------------------------------------------------------------- |
|
1683 // CCmPluginVpn::HasUpstreamVpnL |
|
1684 // -------------------------------------------------------------------------- |
|
1685 // |
|
1686 TBool CCmPluginVpn::HasUpstreamVpnL( TUint32 aId, TBool aIsDestination ) |
|
1687 { |
|
1688 LOGGER_ENTERFN( "CCmPluginVpn::HasUpstreamVpnL" ); |
|
1689 |
|
1690 // the function returns true if: |
|
1691 // - the destination given is referenced by a CM which is either VPN or |
|
1692 // has an upstream VPN |
|
1693 // - the CM given is linked by a VPN or the CM or its destination have |
|
1694 // an upstream VPN |
|
1695 TBool hasUpstreamVpn( EFalse ); |
|
1696 |
|
1697 // array of destinations |
|
1698 RArray<TUint32> destArray( CmMgr().DestinationCountL() ); |
|
1699 CleanupClosePushL( destArray ); |
|
1700 |
|
1701 // get all destinations |
|
1702 CmMgr().AllDestinationsL( destArray ); |
|
1703 |
|
1704 CLOG_WRITE( "CCmPluginVpn::HasUpstreamVpnL checking destinations..." ); |
|
1705 |
|
1706 for ( TInt i = 0; !hasUpstreamVpn && i < destArray.Count(); ++i ) |
|
1707 { |
|
1708 if ( aIsDestination && destArray[i] == aId ) |
|
1709 { |
|
1710 // connection methods cannot link to their parent destination |
|
1711 // so we can skip this round |
|
1712 continue; |
|
1713 } |
|
1714 |
|
1715 CCmDestinationImpl* dest = CmMgr().DestinationL( destArray[i] ); |
|
1716 CleanupStack::PushL( dest ); |
|
1717 |
|
1718 // check out all CM's from destinations |
|
1719 TInt cmCount = dest->ConnectionMethodCount(); |
|
1720 |
|
1721 for ( TInt j = 0; j < cmCount; ++j ) |
|
1722 { |
|
1723 // instantiate a connmethod |
|
1724 CCmPluginBase* cm = dest->GetConnectionMethodL( j ); |
|
1725 CleanupStack::PushL( cm ); |
|
1726 |
|
1727 TUint32 cmId = cm->GetIntAttributeL( ECmId ); |
|
1728 |
|
1729 // ask for the bearer type |
|
1730 TUint32 bearerType = CmMgr().GetConnectionMethodInfoIntL( |
|
1731 cmId, ECmBearerType ); |
|
1732 |
|
1733 // is it virtual? if not, there's nothing to do |
|
1734 if ( CmMgr().GetBearerInfoBoolL( bearerType, ECmVirtual ) ) |
|
1735 { |
|
1736 // it is virtual |
|
1737 |
|
1738 if ( CmMgr().GetBearerInfoBoolL( bearerType, ECmDestination ) ) |
|
1739 { |
|
1740 // what's more, it is an embedded destination |
|
1741 if ( aIsDestination && cm->IsLinkedToSnap( aId ) ) |
|
1742 { |
|
1743 hasUpstreamVpn = |
|
1744 HasUpstreamVpnL( cmId, EFalse ) || |
|
1745 HasUpstreamVpnL( dest->Id(), ETrue ); |
|
1746 } |
|
1747 } |
|
1748 else |
|
1749 { |
|
1750 // it is not an emb.dest. |
|
1751 if ( aIsDestination ) |
|
1752 { |
|
1753 // does it link to this destination? |
|
1754 if ( cm->IsLinkedToSnap( aId ) ) |
|
1755 { |
|
1756 hasUpstreamVpn = |
|
1757 ( bearerType == KPluginVPNBearerTypeUid ) || |
|
1758 HasUpstreamVpnL( cmId, EFalse ) || |
|
1759 HasUpstreamVpnL( dest->Id(), ETrue ); |
|
1760 } |
|
1761 } |
|
1762 else |
|
1763 { |
|
1764 CCmPluginBase* targetCm = |
|
1765 CmMgr().GetConnectionMethodL( aId ); |
|
1766 CleanupStack::PushL( targetCm ); |
|
1767 |
|
1768 // does it link to this CM or to its destination? |
|
1769 if ( cm->IsLinkedToIap( aId ) ) |
|
1770 { |
|
1771 hasUpstreamVpn = |
|
1772 ( bearerType == KPluginVPNBearerTypeUid ) || |
|
1773 HasUpstreamVpnL( cmId, EFalse ); |
|
1774 } |
|
1775 /************** after cmmanager fix ************** |
|
1776 CCmDestinationImpl* parentDest = targetCm->ParentDestination(); |
|
1777 else if ( parentDest && |
|
1778 cm->IsLinkedToSnap( |
|
1779 parentDest->Id() ) ) |
|
1780 { |
|
1781 hasUpstreamVpn = |
|
1782 ( bearerType == KPluginVPNBearerTypeUid ) || |
|
1783 HasUpstreamVpnL( cmId, EFalse ) || |
|
1784 HasUpstreamVpnL( dest->Id(), ETrue ); |
|
1785 } |
|
1786 delete parentDest; |
|
1787 ***************************************************/ |
|
1788 else |
|
1789 { |
|
1790 TUint32 parent( 0 ); |
|
1791 parent = FindParentDestinationL( aId ); |
|
1792 |
|
1793 if ( parent && cm->IsLinkedToSnap( parent ) ) |
|
1794 { |
|
1795 hasUpstreamVpn = |
|
1796 ( bearerType == KPluginVPNBearerTypeUid ) || |
|
1797 HasUpstreamVpnL( cmId, EFalse ) || |
|
1798 HasUpstreamVpnL( dest->Id(), ETrue ); |
|
1799 } |
|
1800 |
|
1801 } |
|
1802 |
|
1803 CleanupStack::PopAndDestroy( targetCm ); |
|
1804 } |
|
1805 |
|
1806 } // if !emb.dest. |
|
1807 |
|
1808 } // if virtual |
|
1809 |
|
1810 CleanupStack::Pop( cm ); |
|
1811 } // for j |
|
1812 |
|
1813 CleanupStack::PopAndDestroy( dest ); |
|
1814 } // for i |
|
1815 |
|
1816 CleanupStack::PopAndDestroy( &destArray ); |
|
1817 |
|
1818 |
|
1819 // if we already know the answer, jump out here |
|
1820 if (hasUpstreamVpn) |
|
1821 { |
|
1822 return hasUpstreamVpn; |
|
1823 } |
|
1824 |
|
1825 |
|
1826 CLOG_WRITE( "CCmPluginVpn::HasUpstreamVpnL checking uncategorized group..." ); |
|
1827 |
|
1828 // we have to check the uncategorized, too |
|
1829 |
|
1830 RArray<TUint32> cmArray ( KCmArrayMediumGranularity ); |
|
1831 CleanupClosePushL( cmArray ); |
|
1832 |
|
1833 CmMgr().ConnectionMethodL( cmArray ); |
|
1834 |
|
1835 // search for virtual CM's |
|
1836 for ( TInt k = 0; !hasUpstreamVpn && k < cmArray.Count(); ++k ) |
|
1837 { |
|
1838 TInt bearerType = CmMgr().GetConnectionMethodInfoIntL( cmArray[k], |
|
1839 ECmBearerType ); |
|
1840 |
|
1841 if ( CmMgr().GetBearerInfoBoolL( bearerType, ECmVirtual ) ) |
|
1842 { |
|
1843 // if virtual, does it link to this destination? |
|
1844 |
|
1845 CCmPluginBase* cm = CmMgr().GetConnectionMethodL( cmArray[k] ); |
|
1846 CleanupStack::PushL( cm ); |
|
1847 |
|
1848 TUint32 cmId = cm->GetIntAttributeL( ECmId ); |
|
1849 |
|
1850 if ( aIsDestination ) |
|
1851 { |
|
1852 // does it link to this destination? |
|
1853 if ( cm->IsLinkedToSnap( aId ) ) |
|
1854 { |
|
1855 hasUpstreamVpn = |
|
1856 ( bearerType == KPluginVPNBearerTypeUid ) || |
|
1857 HasUpstreamVpnL( cmId, EFalse ); |
|
1858 } |
|
1859 } |
|
1860 else |
|
1861 { |
|
1862 // does it link to this CM? |
|
1863 if ( cm->IsLinkedToIap( aId ) ) |
|
1864 { |
|
1865 hasUpstreamVpn = |
|
1866 ( bearerType == KPluginVPNBearerTypeUid ) || |
|
1867 HasUpstreamVpnL( cmId, EFalse ); |
|
1868 } |
|
1869 |
|
1870 } |
|
1871 |
|
1872 CleanupStack::PopAndDestroy( cm ); |
|
1873 } // if virtual |
|
1874 |
|
1875 } // for k |
|
1876 |
|
1877 |
|
1878 CleanupStack::PopAndDestroy( &cmArray ); |
|
1879 |
|
1880 return hasUpstreamVpn; |
|
1881 } |
|
1882 |
|
1883 |
|
1884 |
|
1885 // -------------------------------------------------------------------------- |
|
1886 // CCmPluginVpn::FilterPossibleParentsL |
|
1887 // -------------------------------------------------------------------------- |
|
1888 // |
|
1889 void CCmPluginVpn::FilterPossibleParentsL( RArray<TUint32>& aDests ) |
|
1890 { |
|
1891 LOGGER_ENTERFN( "CCmPluginVpn::FilterPossibleParentsL" ); |
|
1892 |
|
1893 // check if there is any destination into which this VPN could be put |
|
1894 |
|
1895 // Filter out invalid destinations |
|
1896 for ( TInt i = 0; i < aDests.Count(); ++i ) |
|
1897 { |
|
1898 if ( HasUpstreamVpnL( aDests[i], ETrue ) ) |
|
1899 { |
|
1900 aDests.Remove( i ); |
|
1901 --i; |
|
1902 } |
|
1903 } |
|
1904 |
|
1905 // also filter out the underlying connection's destination |
|
1906 if ( aDests.Count() ) |
|
1907 { |
|
1908 // still have work to do |
|
1909 TUint32 destId = 0; |
|
1910 |
|
1911 if ( iVirtualRecord->iNextLayerSNAP ) |
|
1912 { |
|
1913 // the VPN links to a destination |
|
1914 destId = iVirtualRecord->iNextLayerSNAP; |
|
1915 } |
|
1916 else if ( iVirtualRecord->iNextLayerIAP ) |
|
1917 { |
|
1918 // the VPN links to a connmethod, find out parent destination id |
|
1919 |
|
1920 /********** after CmManager fix *********************** |
|
1921 CCmPluginBase* cm = CmMgr().GetConnectionMethodL( |
|
1922 iVirtualRecord->iNextLayerIAP ); |
|
1923 |
|
1924 CCmDestinationImpl* parentDest = cm->ParentDestination(); |
|
1925 if ( parentDest ) |
|
1926 { |
|
1927 // take the id only if cm has a parent |
|
1928 destId = parentDest->Id(); |
|
1929 } |
|
1930 |
|
1931 delete cm; |
|
1932 delete parentDest; |
|
1933 *******************************************************/ |
|
1934 destId = FindParentDestinationL( iVirtualRecord->iNextLayerIAP ); |
|
1935 } |
|
1936 |
|
1937 |
|
1938 // now search for the id |
|
1939 if ( destId ) |
|
1940 { |
|
1941 TInt index = aDests.Find( destId ); |
|
1942 if ( index != KErrNotFound ) |
|
1943 { |
|
1944 // got it, remove |
|
1945 aDests.Remove( index ); |
|
1946 } |
|
1947 } |
|
1948 |
|
1949 } // if aDests.Count |
|
1950 |
|
1951 |
|
1952 } |
|
1953 |
|
1954 |
|
1955 TUint32 CCmPluginVpn::FindParentDestinationL( TUint32 aCmId ) |
|
1956 { |
|
1957 LOGGER_ENTERFN( "CCmPluginVpn::FindParentDestinationL" ); |
|
1958 |
|
1959 TBool found = EFalse; |
|
1960 TUint32 targetDestId( 0 ); |
|
1961 |
|
1962 RArray<TUint32> destinations( CmMgr().DestinationCountL() ); |
|
1963 |
|
1964 CmMgr().AllDestinationsL( destinations ); |
|
1965 CleanupClosePushL( destinations ); |
|
1966 |
|
1967 for ( TInt i = 0; i < destinations.Count() && !found; i++ ) |
|
1968 { |
|
1969 CCmDestinationImpl* dest = |
|
1970 CmMgr().DestinationL( destinations[i] ); |
|
1971 CleanupStack::PushL( dest ); |
|
1972 |
|
1973 TInt cmCount = dest->ConnectionMethodCount(); |
|
1974 |
|
1975 for ( TInt j = 0; j < cmCount && !found; j++ ) |
|
1976 { |
|
1977 // instantiate a connmethod |
|
1978 CCmPluginBase* cm = dest->GetConnectionMethodL( j ); |
|
1979 CleanupStack::PushL( cm ); |
|
1980 TUint32 cmId = cm->GetIntAttributeL( ECmId ); |
|
1981 |
|
1982 if ( cmId == aCmId) |
|
1983 { |
|
1984 targetDestId = destinations[i]; |
|
1985 found = ETrue; |
|
1986 } |
|
1987 |
|
1988 CleanupStack::Pop( cm ); |
|
1989 } |
|
1990 |
|
1991 CleanupStack::PopAndDestroy( dest ); |
|
1992 } |
|
1993 |
|
1994 CleanupStack::PopAndDestroy( &destinations ); |
|
1995 |
|
1996 return targetDestId; |
|
1997 } |
|
1998 |
|
1999 // -------------------------------------------------------------------------- |
|
2000 // CCmPluginVpn::DeleteAdditionalRecordsL |
|
2001 // -------------------------------------------------------------------------- |
|
2002 // |
|
2003 void CCmPluginVpn::DeleteAdditionalRecordsL() |
|
2004 { |
|
2005 LOGGER_ENTERFN( "CCmPluginVpn::DeleteAdditionalRecordsL" ); |
|
2006 |
|
2007 // Virtual record must be deleted |
|
2008 iVirtualRecord->DeleteL( Session() ); |
|
2009 } |
|
2010 |
|
2011 // -------------------------------------------------------------------------- |
|
2012 // CCmPluginVpn::GenerateVPNPointToEasyWLANLC |
|
2013 // -------------------------------------------------------------------------- |
|
2014 // |
|
2015 HBufC* CCmPluginVpn::GenerateVPNPointToWLANNetworkLC(RResourceFile& rf, HBufC*& aName) |
|
2016 { |
|
2017 LOGGER_ENTERFN( "CCmPluginVpn::GenerateVPNPointToWLANNetworkLC" ); |
|
2018 aName = NULL; |
|
2019 |
|
2020 HBufC8* readBuffer2 = rf.AllocReadLC( R_QTN_NETW_CONSET_VPN_EASY_WLAN ); |
|
2021 const TPtrC16 ptrReadBuffer2( (TText16*) readBuffer2->Ptr(), |
|
2022 ( readBuffer2->Length() + 1 ) >> 1 ); |
|
2023 aName = HBufC16::NewL( ptrReadBuffer2.Length() ); |
|
2024 *aName = ptrReadBuffer2; |
|
2025 |
|
2026 CleanupStack::PopAndDestroy( readBuffer2 ); |
|
2027 CleanupStack::PushL( aName ); |
|
2028 |
|
2029 return aName; |
|
2030 } |
|
2031 |
|
2032 // -------------------------------------------------------------------------- |
|
2033 // CCmPluginVpn::CheckValidityAndConvertDestinationIdL |
|
2034 // -------------------------------------------------------------------------- |
|
2035 // |
|
2036 TInt CCmPluginVpn::CheckValidityAndConvertDestinationIdL( TUint32 aDestId ) |
|
2037 { |
|
2038 TInt id( 0 ); |
|
2039 |
|
2040 if ( aDestId > 0 && aDestId < 255 ) |
|
2041 { |
|
2042 id = aDestId + KCmDefaultDestinationAPTagId; |
|
2043 } |
|
2044 else if ( aDestId > KCmDefaultDestinationAPTagId |
|
2045 && ( aDestId < ( KCmDefaultDestinationAPTagId+255 ) ) ) |
|
2046 { |
|
2047 id = aDestId; |
|
2048 } |
|
2049 else |
|
2050 { |
|
2051 User::Leave( KErrArgument ); |
|
2052 } |
|
2053 |
|
2054 return id; |
|
2055 } |
|
2056 |
|
2057 // -------------------------------------------------------------------------- |
|
2058 // CCmPluginVpn::DefaultAPRecordL |
|
2059 // -------------------------------------------------------------------------- |
|
2060 // |
|
2061 const TMDBElementId CCmPluginVpn::DefaultAPRecordL( const TInt aTierIdentifier ) |
|
2062 { |
|
2063 LOGGER_ENTERFN( "CCmPluginVpn::DefaultAPRecordL" ); |
|
2064 // Resolve the Default SNAP AP elementid |
|
2065 // |
|
2066 CCDTierRecord* tierRecord = static_cast<CCDTierRecord *>( |
|
2067 CCDRecordBase::RecordFactoryL( KCDTIdTierRecord ) ); |
|
2068 |
|
2069 CleanupStack::PushL( tierRecord ); |
|
2070 |
|
2071 // Find the correct tier table based on given identifier. |
|
2072 // |
|
2073 tierRecord->iRecordTag = aTierIdentifier; |
|
2074 if ( !tierRecord->FindL( Session() ) ) |
|
2075 { |
|
2076 User::Leave( KErrCorrupt ); |
|
2077 } |
|
2078 |
|
2079 // Find out the default AP for IP connections. |
|
2080 // |
|
2081 TMDBElementId defaultAP = tierRecord->iDefaultAccessPoint; |
|
2082 |
|
2083 // Cleanup tier record. |
|
2084 // |
|
2085 CleanupStack::PopAndDestroy( tierRecord ); |
|
2086 |
|
2087 return defaultAP; |
|
2088 } |
|
2089 |
|
2090 // eof |
|