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