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