|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Validation rules for some comms database elements |
|
15 // MAINTENANCE - Some rules may need adding or amending whenever the database schema changes |
|
16 // No need to validate every entry |
|
17 // Mostly rely on compliance from writers as they are well trusted |
|
18 // FILE CONTENTS : |
|
19 // 1/ CCDValidator Base class implementation |
|
20 // 2/ Validator classes for particular records |
|
21 // a) CCDValidatorProxyRecord |
|
22 // b) CCDValidatorLANServiceRecord |
|
23 // c) CCDValidatorTierRecord |
|
24 // d) CCDValidatorConnPref |
|
25 // e) CCDValidatorIAPRecord |
|
26 // All data in file |
|
27 // |
|
28 // |
|
29 |
|
30 /** |
|
31 @file CommsDatValidator.cpp |
|
32 @internalComponent |
|
33 */ |
|
34 |
|
35 |
|
36 #include "CommsDatInternalDefs.h" |
|
37 #include <commsdattypesv1_1.h> |
|
38 #include "CommsDatValidator.h" |
|
39 #include <comms-infras/commsdatschema.h> |
|
40 #include <commsdat.h> |
|
41 #include "CommsDatMapperAndValidatorUtils.h" |
|
42 |
|
43 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
44 #include <commsdattypesv1_1_partner.h> |
|
45 #include <commsdat_partner.h> |
|
46 #endif |
|
47 |
|
48 using namespace Meta; |
|
49 using namespace CommsDatInternal; |
|
50 using namespace CommsDat; |
|
51 |
|
52 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
53 //anonymous namespace |
|
54 namespace |
|
55 { |
|
56 const TInt KNumServiceType = 12; |
|
57 |
|
58 struct TMapBearerToServiceType |
|
59 { |
|
60 TCommDbBearer bearerMask; |
|
61 TCommDbConnectionDirection direction; |
|
62 const TText* serviceType; |
|
63 }; |
|
64 |
|
65 const TMapBearerToServiceType KMap[KNumServiceType] = |
|
66 { |
|
67 {KCommDbBearerCSD, ECommDbConnectionDirectionOutgoing, DIAL_OUT_ISP}, |
|
68 {KCommDbBearerCSD, ECommDbConnectionDirectionIncoming, DIAL_IN_ISP}, |
|
69 {KCommDbBearerWcdma, ECommDbConnectionDirectionOutgoing, OUTGOING_GPRS}, |
|
70 /** The following two mappings are only required for tornado */ |
|
71 {KCommDbBearerWcdma, ECommDbConnectionDirectionIncoming, INCOMING_GPRS}, |
|
72 {KCommDbBearerLAN, ECommDbConnectionDirectionIncoming, LAN_SERVICE}, |
|
73 {KCommDbBearerLAN, ECommDbConnectionDirectionOutgoing, LAN_SERVICE}, |
|
74 {KCommDbBearerVirtual, ECommDbConnectionDirectionIncoming, VPN_SERVICE}, |
|
75 {KCommDbBearerVirtual, ECommDbConnectionDirectionOutgoing, VPN_SERVICE}, |
|
76 /** PAN profile uses LAN service table, plus an extension service table */ |
|
77 {KCommDbBearerPAN, ECommDbConnectionDirectionIncoming, LAN_SERVICE}, |
|
78 {KCommDbBearerPAN, ECommDbConnectionDirectionOutgoing, LAN_SERVICE}, |
|
79 /** WLAN uses LAN service table, plus an extension service table */ |
|
80 {KCommDbBearerWLAN, ECommDbConnectionDirectionIncoming, LAN_SERVICE}, |
|
81 {KCommDbBearerWLAN, ECommDbConnectionDirectionOutgoing, LAN_SERVICE} |
|
82 }; |
|
83 |
|
84 //this function returns the index in the array of the service type which should be used based |
|
85 //on the received bearer and direction parameters. |
|
86 //it returns KErrNotFound if the service type cannot be found based on the received params. |
|
87 TInt GetIAPServiceType(TUint32& aServTypeArrayStartIndex, TCommDbBearer aBearerSet, TCommDbConnectionDirection aDirection) |
|
88 { |
|
89 for (int i = aServTypeArrayStartIndex; i < KNumServiceType; i++) |
|
90 { |
|
91 if ((aBearerSet & KMap[i].bearerMask) != 0 && |
|
92 (aDirection == KMap[i].direction || |
|
93 aDirection == ECommDbConnectionDirectionUnknown )) |
|
94 { |
|
95 aServTypeArrayStartIndex = i; |
|
96 return i; |
|
97 } |
|
98 } |
|
99 return KErrNotFound; |
|
100 } |
|
101 |
|
102 CMDBRecordLink<CCDAccessPointRecord>* GetTheAPxLinkFromAPPrioritySelPol(CCDAPPrioritySelectionPolicyRecord* aAPSelPolRec, |
|
103 TInt aRankingFromConnPref) |
|
104 { |
|
105 TMetaVTableIterator attribIter(aAPSelPolRec); |
|
106 SVDataTableEntry const* entry = 0; |
|
107 TInt fieldCounter(15); |
|
108 TInt linkNumber(aRankingFromConnPref); |
|
109 CMDBRecordLink<CCDAccessPointRecord>* apPrioritySelPolLink = NULL; |
|
110 |
|
111 while ( (entry = attribIter++) != NULL && |
|
112 linkNumber-- > 0 && |
|
113 fieldCounter-- > 0 ) |
|
114 { |
|
115 apPrioritySelPolLink = reinterpret_cast<CMDBRecordLink<CCDAccessPointRecord>*>(aAPSelPolRec->GetAttribPtr(entry->iOffset)); |
|
116 } |
|
117 |
|
118 return apPrioritySelPolLink; |
|
119 } |
|
120 } |
|
121 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
122 |
|
123 /**************************************************************************************** |
|
124 * 1/ CCDValidator Base class implementaion |
|
125 ****************************************************************************************/ |
|
126 |
|
127 CCDValidator::CCDValidator(CMDBElement* aElement,CMDBSessionImpl& aSession): |
|
128 iElement(aElement),iSession(aSession) |
|
129 /* |
|
130 @internalComponent |
|
131 */ |
|
132 { |
|
133 iSession.iMapping = ETrue; |
|
134 } |
|
135 |
|
136 CCDValidator::~CCDValidator() |
|
137 /* |
|
138 @internalComponent |
|
139 */ |
|
140 { |
|
141 iSession.iMapping = EFalse; |
|
142 } |
|
143 |
|
144 |
|
145 void CCDValidator::ValidateL(CMDBElement* aElement,CMDBSessionImpl& aSession |
|
146 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
147 ,TOperation aValidatorOperation |
|
148 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
149 ) |
|
150 /* |
|
151 Creates a validation object of the appropriate type |
|
152 if there are validation rules for aElement |
|
153 and calls validate |
|
154 |
|
155 @internalComponent |
|
156 */ |
|
157 { |
|
158 |
|
159 if( aSession.iMapping ) |
|
160 { |
|
161 return; |
|
162 } |
|
163 |
|
164 if( CommsDat::CommsDatSchema::IsTable(aElement->ElementId()) ) |
|
165 { |
|
166 return; |
|
167 } |
|
168 |
|
169 // then create a validator for the business data if there are any rules set |
|
170 CCDValidator* validator = NULL; |
|
171 |
|
172 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
173 if (EModify == aValidatorOperation || |
|
174 EStore == aValidatorOperation) |
|
175 //this is the original behaviour of this method |
|
176 { |
|
177 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
178 if (! CommsDat::CommsDatSchema::IsNode(aElement->ElementId())) |
|
179 { |
|
180 // First validate the field type (see CommsDatSchema) |
|
181 CommsDatSchema::ValidateFieldTypeL(aSession.iOwner, *aElement); |
|
182 |
|
183 /* Only compliant processes can write to the database |
|
184 |
|
185 don't see it is valuable to validate every field*/ |
|
186 |
|
187 //return; |
|
188 } |
|
189 |
|
190 switch(aElement->ElementId() & KCDMaskShowRecordType) |
|
191 { |
|
192 case KCDTIdConnectionPrefsRecord: |
|
193 { |
|
194 validator = new(ELeave)CCDValidatorConnPref(aElement,aSession |
|
195 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
196 , aValidatorOperation |
|
197 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
198 ); |
|
199 break; |
|
200 } |
|
201 |
|
202 case KCDTIdIAPRecord: |
|
203 { |
|
204 validator = new(ELeave)CCDValidatorIAPRecord(aElement,aSession |
|
205 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
206 , aValidatorOperation |
|
207 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
208 ); |
|
209 break; |
|
210 } |
|
211 |
|
212 case KCDTIdLANServiceRecord: |
|
213 { |
|
214 validator = new(ELeave)CCDValidatorLANServiceRecord(aElement,aSession); |
|
215 break; |
|
216 } |
|
217 |
|
218 case KCDTIdProxiesRecord: |
|
219 { |
|
220 validator = new(ELeave)CCDValidatorProxyRecord(aElement,aSession); |
|
221 break; |
|
222 } |
|
223 |
|
224 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
225 case KCDTIdTierRecord: |
|
226 { |
|
227 validator = new(ELeave)CCDValidatorTierRecord(aElement,aSession); |
|
228 break; |
|
229 } |
|
230 |
|
231 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
232 |
|
233 default : |
|
234 { |
|
235 return; // Exit quickly if there's no validator |
|
236 } |
|
237 } |
|
238 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
239 } |
|
240 else |
|
241 //the validator should be created for deleting some other data... |
|
242 { |
|
243 switch(aElement->ElementId() & KCDMaskShowRecordType) |
|
244 { |
|
245 case KCDTIdConnectionPrefsRecord: |
|
246 { |
|
247 validator = new(ELeave)CCDValidatorConnPref(aElement,aSession, aValidatorOperation); |
|
248 break; |
|
249 } |
|
250 case KCDTIdIAPRecord: |
|
251 { |
|
252 validator = new(ELeave)CCDValidatorIAPRecord(aElement,aSession, aValidatorOperation); |
|
253 break; |
|
254 } |
|
255 default : |
|
256 { |
|
257 return; // Exit quickly if there's no validator |
|
258 } |
|
259 } |
|
260 } |
|
261 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
262 |
|
263 CleanupStack::PushL(validator); |
|
264 |
|
265 validator->DoValidateL(); |
|
266 |
|
267 CleanupStack::PopAndDestroy(validator); |
|
268 } |
|
269 |
|
270 |
|
271 |
|
272 void CCDValidator::DoValidateL() |
|
273 /* |
|
274 Default is nothing to validate so return |
|
275 |
|
276 @internalComponent |
|
277 */ |
|
278 { |
|
279 User::LeaveIfError(1 == 1); |
|
280 } |
|
281 |
|
282 |
|
283 void CCDValidator::OnDeleteL() |
|
284 /* |
|
285 Default is nothing to delete; |
|
286 |
|
287 @internalTechnology |
|
288 */ |
|
289 { |
|
290 User::LeaveIfError(1 == 1); |
|
291 } |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 /*************************************************************************************** |
|
298 * 2/ VALIDATION CLASSES FOR INDIVIDUAL RECORDS |
|
299 **************************************************************************************/ |
|
300 |
|
301 |
|
302 |
|
303 /************************* 2a) Validate Proxy Record ************************************ |
|
304 Validate open link to service record |
|
305 */ |
|
306 void CCDValidatorProxyRecord::SetShadowElementL() |
|
307 { |
|
308 iShadowElement = CCDRecordBase::RecordFactoryL(KCDTIdProxiesRecord); |
|
309 iShadowElement->SetRecordId(iElement->RecordId()); |
|
310 iShadowElement->LoadL(iSession.iOwner); |
|
311 |
|
312 if ( KCDMaskShowFieldType != (KCDMaskShowFieldType & iElement->ElementId()) ) |
|
313 { |
|
314 //field validation |
|
315 CMDBElement* shadowFieldPtr = static_cast<CMDBRecordBase*>(iShadowElement)->GetFieldByIdL(iElement->ElementId()); |
|
316 |
|
317 if ( KCDTIdRecordName == (iElement->ElementId() & KCDMaskShowFieldType) || |
|
318 KCDTIdProxyServiceType == (iElement->ElementId() & KCDMaskShowType) || |
|
319 KCDTIdServerName == (iElement->ElementId() & KCDMaskShowType) || |
|
320 KCDTIdProtocolName == (iElement->ElementId() & KCDMaskShowType) || |
|
321 KCDTIdExceptions == (iElement->ElementId() & KCDMaskShowType) ) |
|
322 { |
|
323 CMDBField<TDesC>* nameField = static_cast<CMDBField<TDesC>*>(shadowFieldPtr); |
|
324 CMDBField<TDesC>* origField = static_cast<CMDBField<TDesC>*>(iElement); |
|
325 |
|
326 nameField->SetL(*origField); |
|
327 } |
|
328 else |
|
329 { |
|
330 CMDBField<TInt>* numField = static_cast<CMDBField<TInt>*>(shadowFieldPtr); |
|
331 CMDBField<TInt>* origField = static_cast<CMDBField<TInt>*>(iElement); |
|
332 |
|
333 numField->SetL(*origField); |
|
334 } |
|
335 } |
|
336 |
|
337 iElement = iShadowElement; |
|
338 } |
|
339 |
|
340 |
|
341 void CCDValidatorProxyRecord::DoValidateL() |
|
342 /* |
|
343 Just validate the linked field |
|
344 @internalComponent |
|
345 */ |
|
346 { |
|
347 if ( KCDMaskShowFieldType != (KCDMaskShowFieldType & iElement->ElementId())) |
|
348 { |
|
349 //field validation |
|
350 SetShadowElementL(); |
|
351 } |
|
352 |
|
353 #ifndef SYMBIAN_COMMSDAT_USE_INT_RECORD_LINKS |
|
354 CCDProxiesRecord* proxyRecord = static_cast<CCDProxiesRecord*>(iElement); |
|
355 |
|
356 if (! proxyRecord->iService.IsNull() && ! proxyRecord->iServiceType.IsNull()) |
|
357 { |
|
358 TMDBElementId serviceTypeId = CommsDatSchemaV1_1::LookupTableId(proxyRecord->iServiceType.GetL()); |
|
359 proxyRecord->iService = CommsDatSchema::GetLinkIdL(iSession.iOwner, proxyRecord->iService.ElementId(), proxyRecord->iService.GetL(), serviceTypeId/*, &proxyRecord*/); |
|
360 } |
|
361 #endif // SYMBIAN_COMMSDAT_USE_INT_RECORD_LINKS |
|
362 } |
|
363 |
|
364 |
|
365 /************************* 2b) Validate LANService Record *********************************** |
|
366 Validate open link to service extension record |
|
367 */ |
|
368 |
|
369 void CCDValidatorLANServiceRecord::SetShadowElementL() |
|
370 { |
|
371 iShadowElement = CCDRecordBase::RecordFactoryL(KCDTIdLANServiceRecord); |
|
372 iShadowElement->SetRecordId(iElement->RecordId()); |
|
373 iShadowElement->LoadL(iSession.iOwner); |
|
374 |
|
375 if ( KCDMaskShowFieldType != (KCDMaskShowFieldType & iElement->ElementId()) ) |
|
376 { |
|
377 //field validation |
|
378 CMDBElement* shadowFieldPtr = static_cast<CMDBRecordBase*>(iShadowElement)->GetFieldByIdL(iElement->ElementId()); |
|
379 |
|
380 if ( KCDTIdRecordTag == (iElement->ElementId() & KCDMaskShowFieldType) || |
|
381 KCDTIdLANIpAddrFromServer == (iElement->ElementId() & KCDMaskShowType) || |
|
382 KCDTIdLANIpDNSAddrFromServer == (iElement->ElementId() & KCDMaskShowType) || |
|
383 KCDTIdLANIp6DNSAddrFromServer == (iElement->ElementId() & KCDMaskShowType) || |
|
384 KCDTIdLANServiceExtensionTableRecordId == (iElement->ElementId() & KCDMaskShowType) ) |
|
385 { |
|
386 CMDBField<TInt>* numField = static_cast<CMDBField<TInt>*>(shadowFieldPtr); |
|
387 CMDBField<TInt>* origField = static_cast<CMDBField<TInt>*>(iElement); |
|
388 |
|
389 numField->SetL(*origField); |
|
390 } |
|
391 else |
|
392 { |
|
393 CMDBField<TDesC>* nameField = static_cast<CMDBField<TDesC>*>(shadowFieldPtr); |
|
394 CMDBField<TDesC>* origField = static_cast<CMDBField<TDesC>*>(iElement); |
|
395 |
|
396 nameField->SetL(*origField); |
|
397 } |
|
398 } |
|
399 |
|
400 iElement = iShadowElement; |
|
401 } |
|
402 |
|
403 void CCDValidatorLANServiceRecord::DoValidateL() |
|
404 /* |
|
405 Just validate the linked field |
|
406 @internalComponent |
|
407 */ |
|
408 { |
|
409 if ( KCDMaskShowFieldType != (KCDMaskShowFieldType & iElement->ElementId())) |
|
410 { |
|
411 //field validation |
|
412 SetShadowElementL(); |
|
413 } |
|
414 |
|
415 #ifndef SYMBIAN_COMMSDAT_USE_INT_RECORD_LINKS |
|
416 CCDLANServiceRecord* lanServiceRecord = static_cast<CCDLANServiceRecord*>(iElement); |
|
417 |
|
418 if (! lanServiceRecord->iServiceExtensionTableRecordId.IsNull() && ! lanServiceRecord->iServiceExtensionTableName.IsNull()) |
|
419 { |
|
420 //this was caught in testing but it is not valid to have a real record without these fields... |
|
421 TMDBElementId serviceExtTypeId = CommsDatSchemaV1_1::LookupTableId(lanServiceRecord->iServiceExtensionTableName.GetL()); |
|
422 |
|
423 lanServiceRecord->iServiceExtensionTableRecordId = |
|
424 CommsDatSchema::GetLinkIdL(iSession.iOwner, lanServiceRecord->iServiceExtensionTableRecordId.ElementId(), lanServiceRecord->iServiceExtensionTableRecordId.GetL(), serviceExtTypeId/*, &lanServiceRecord*/); |
|
425 } |
|
426 #endif |
|
427 } |
|
428 |
|
429 |
|
430 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
431 // because tier record doesn't exist before then |
|
432 |
|
433 /************************* 2c) Validate Tier Record ************************************* |
|
434 Tier thread name needs to be short name for Tier thread |
|
435 */ |
|
436 |
|
437 void CCDValidatorTierRecord::SetShadowElementL() |
|
438 { |
|
439 iShadowElement = CCDRecordBase::RecordFactoryL(KCDTIdTierRecord); |
|
440 iShadowElement->SetRecordId(iElement->RecordId()); |
|
441 iShadowElement->LoadL(iSession.iOwner); |
|
442 |
|
443 if ( KCDMaskShowFieldType != (KCDMaskShowFieldType & iElement->ElementId()) ) |
|
444 { |
|
445 //field validation |
|
446 CMDBElement* shadowFieldPtr = static_cast<CMDBRecordBase*>(iShadowElement)->GetFieldByIdL(iElement->ElementId()); |
|
447 |
|
448 if ( KCDTIdRecordTag == (iElement->ElementId() & KCDMaskShowFieldType) || |
|
449 KCDTIdDefaultAccessPoint == (iElement->ElementId() & KCDMaskShowType) ) |
|
450 { |
|
451 CMDBField<TInt>* numField = static_cast<CMDBField<TInt>*>(shadowFieldPtr); |
|
452 CMDBField<TInt>* origField = static_cast<CMDBField<TInt>*>(iElement); |
|
453 |
|
454 numField->SetL(*origField); |
|
455 } |
|
456 else |
|
457 { |
|
458 CMDBField<TDesC>* nameField = static_cast<CMDBField<TDesC>*>(shadowFieldPtr); |
|
459 CMDBField<TDesC>* origField = static_cast<CMDBField<TDesC>*>(iElement); |
|
460 |
|
461 nameField->SetL(*origField); |
|
462 } |
|
463 } |
|
464 |
|
465 iElement = iShadowElement; |
|
466 } |
|
467 |
|
468 void CCDValidatorTierRecord::DoValidateL() |
|
469 /* |
|
470 @internalComponent |
|
471 */ |
|
472 { |
|
473 if ( KCDMaskShowFieldType != (KCDMaskShowFieldType & iElement->ElementId()) ) |
|
474 { |
|
475 //field validation |
|
476 SetShadowElementL(); |
|
477 } |
|
478 |
|
479 CCDTierRecord* tierRec = static_cast<CCDTierRecord*>(iElement); |
|
480 if(static_cast<const TDesC16&>(tierRec->iTierThreadName).Length() > KShortTextLength) |
|
481 { |
|
482 __FLOG_STATIC(KLogComponent, KCDErrLog, |
|
483 _L("CCDValidatorTierRecord::DoValidateL() - TierThreadName > KShortTextLength chars")); |
|
484 User::Leave(KErrTooBig); |
|
485 } |
|
486 } |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 /***************** 2d) Validate Connection Preference Record ***************************** |
|
492 */ |
|
493 void CCDValidatorConnPref::SetShadowElementL() |
|
494 { |
|
495 iShadowElement = CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord); |
|
496 iShadowElement->SetRecordId(iElement->RecordId()); |
|
497 iShadowElement->LoadL(iSession.iOwner); |
|
498 |
|
499 if ( KCDMaskShowFieldType != (KCDMaskShowFieldType & iElement->ElementId()) ) |
|
500 { |
|
501 //field validation |
|
502 CMDBElement* shadowFieldPtr = static_cast<CMDBRecordBase*>(iShadowElement)->GetFieldByIdL(iElement->ElementId()); |
|
503 |
|
504 |
|
505 if (KCDTIdRecordName == (iElement->ElementId() & KCDMaskShowFieldType)) |
|
506 { |
|
507 CMDBField<TDesC>* nameField = static_cast<CMDBField<TDesC>*>(shadowFieldPtr); |
|
508 CMDBField<TDesC>* origField = static_cast<CMDBField<TDesC>*>(iElement); |
|
509 |
|
510 nameField->SetL(*origField); |
|
511 } |
|
512 else |
|
513 { |
|
514 //the only reason this cast can be done here is that the connPref record contains only |
|
515 //numerical based fields... (except the name field -> handled above...) |
|
516 CMDBField<TInt>* numField = static_cast<CMDBField<TInt>*>(shadowFieldPtr); |
|
517 CMDBField<TInt>* origField = static_cast<CMDBField<TInt>*>(iElement); |
|
518 |
|
519 if (EDelete == iOperation) |
|
520 { |
|
521 numField->SetL(0); |
|
522 } |
|
523 else |
|
524 { |
|
525 numField->SetL(*origField); |
|
526 } |
|
527 |
|
528 //in the case of the IAP link it has to be checked whether is it |
|
529 //given as a full link or only as a record number |
|
530 if (KCDTIdIAPLink == (iElement->ElementId() & KCDMaskShowType)) |
|
531 { |
|
532 if ((*origField & KCDMaskShowType) == KCDMaskShowType) |
|
533 { |
|
534 //the value is only a record id |
|
535 numField->SetL(*origField); |
|
536 } |
|
537 else |
|
538 { |
|
539 //the value is a TMDBElementId. Now only the reocrdId is important -> the |
|
540 //connprefValidator is working only with the recId |
|
541 numField->SetL((*origField & KCDMaskShowRecordId) >> 8); |
|
542 } |
|
543 } |
|
544 } |
|
545 } |
|
546 |
|
547 iElement = iShadowElement; |
|
548 } |
|
549 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
550 |
|
551 void CCDValidatorConnPref::DoValidateL() |
|
552 { |
|
553 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
554 if ( KCDMaskShowFieldType != (KCDMaskShowFieldType & iElement->ElementId()) || |
|
555 EDelete == iOperation ) |
|
556 { |
|
557 // a) field validation -> in this case the validator should load the whole record from the DB |
|
558 // mimicing record validation |
|
559 // b) this is a delete operation where only the record id is set on the record container |
|
560 // the validator should load the correct element in order to delete the 399 path |
|
561 SetShadowElementL(); |
|
562 } |
|
563 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
564 |
|
565 TBool clearHiddenFlag = EFalse; |
|
566 |
|
567 CCDConnectionPrefsRecord* ptrConnPref = static_cast<CCDConnectionPrefsRecord*>(iElement); |
|
568 |
|
569 TInt rank = ptrConnPref->iRanking; |
|
570 TCommDbConnectionDirection direction = ptrConnPref->iDirection; |
|
571 |
|
572 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
573 if (EDelete != iOperation) |
|
574 { |
|
575 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
576 //this kind of validation is needed if there is some other operation than delete... |
|
577 |
|
578 if(ptrConnPref->iDefaultIAP == 0) |
|
579 { |
|
580 /* |
|
581 Since phones get shipped without any predefined IAPs, when a connpref record |
|
582 is stored with the IAP(iDefaultIAP) not set, CED sets its value to 0. |
|
583 Such records hence should be exempted from validation. |
|
584 [Instead of a 0, the behaviour could have been a negative value to remove ambiguity and also |
|
585 could have been mandatory to set that value in the configuration file as well] |
|
586 */ |
|
587 // return; |
|
588 } |
|
589 /* This test is here returniong KErrNotFound for BC reasons. |
|
590 It used to assume that value of iDefaultIAP would always be a straight record id |
|
591 have now modified it to take account of different link values*/ |
|
592 if( ptrConnPref->iDefaultIAP != 0 && |
|
593 ptrConnPref->iDefaultIAP >= KCDMaxRecords ) |
|
594 { |
|
595 if( (ptrConnPref->iDefaultIAP & KLinkableTag) != 0 || |
|
596 (ptrConnPref->iDefaultIAP & KCDMaskShowRecordType ) != KCDTIdIAPRecord ) |
|
597 { |
|
598 // this can't be a valid IAP record |
|
599 User::Leave(KErrNotFound); |
|
600 } |
|
601 } |
|
602 |
|
603 if(rank > 2) |
|
604 { |
|
605 User::Leave(KErrOverflow); |
|
606 } |
|
607 |
|
608 if (direction == ECommDbConnectionDirectionIncoming && rank > 1) |
|
609 { |
|
610 User::Leave(KErrNotSupported); |
|
611 } |
|
612 //Re-setting the hidden flag in the case of a leave?????? |
|
613 clearHiddenFlag = ! iSession.IsSetAttributeMask(ECDHidden); |
|
614 if (clearHiddenFlag) |
|
615 { |
|
616 iSession.SetAttributeMask(ECDHidden); |
|
617 } |
|
618 |
|
619 //check if a record with the same rank already exists |
|
620 CCDConnectionPrefsRecord* ptrConnprefTestRecord = NULL; |
|
621 |
|
622 // secondly check records already in the db. |
|
623 |
|
624 ptrConnprefTestRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord)); |
|
625 CleanupStack::PushL(ptrConnprefTestRecord); |
|
626 |
|
627 ptrConnprefTestRecord->iRanking = rank; |
|
628 ptrConnprefTestRecord->iDirection = direction; |
|
629 |
|
630 // conditions does not apply for rank 0 |
|
631 if (rank > 0 && ptrConnprefTestRecord->FindL(iSession.iOwner)) |
|
632 { |
|
633 // Since Validation can occur from ModifyL as well, only leave if this isn't the same record |
|
634 if (ptrConnprefTestRecord->RecordId() != ptrConnPref->RecordId() && |
|
635 ptrConnprefTestRecord->RecordId() != KCDDefaultRecord) |
|
636 { |
|
637 User::Leave(KErrAlreadyExists); |
|
638 } |
|
639 } |
|
640 CleanupStack::PopAndDestroy(ptrConnprefTestRecord); |
|
641 |
|
642 // Check the IAP record id. look first in cache then in repository |
|
643 if (ptrConnPref->iDefaultIAP != 0) |
|
644 { |
|
645 TInt boo = ptrConnPref->iDialogPref; |
|
646 TCommDbDialogPref dialogpref = (TCommDbDialogPref)boo;//TODO change the templated type def of this field; |
|
647 |
|
648 |
|
649 if ( (*(ptrConnPref->iDefaultIAP.Data()) & KCDChangedFlag) == KCDChangedFlag || |
|
650 (*(ptrConnPref->iBearerSet.Data()) & KCDChangedFlag) == KCDChangedFlag ) |
|
651 { |
|
652 CMDBField<TDesC>* iapServiceType = new(ELeave) CMDBField<TDesC>(KCDTIdIAPServiceType); |
|
653 CleanupStack::PushL(iapServiceType); |
|
654 iapServiceType->SetMaxLengthL(KMaxTextLength); |
|
655 iapServiceType->SetRecordId(ptrConnPref->iDefaultIAP); |
|
656 iapServiceType->LoadL(iSession.iOwner); |
|
657 TPtrC serviceType(*iapServiceType); |
|
658 |
|
659 ValidateBearerAndDirectionL(serviceType, ptrConnPref->iDirection, ptrConnPref->iBearerSet, dialogpref); |
|
660 CleanupStack::PopAndDestroy(iapServiceType); |
|
661 } |
|
662 } |
|
663 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
664 } |
|
665 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
666 |
|
667 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
668 if ( (ECommDbConnectionDirectionIncoming != direction && // -| |
|
669 rank > 0 && // | -> related to sore, modify |
|
670 !iSession.UsingLatestVersion()) ) // | -> related to the latest session |
|
671 { |
|
672 IPProtoAPGenerationOrModificationL(); |
|
673 } |
|
674 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
675 |
|
676 if (clearHiddenFlag) |
|
677 { |
|
678 iSession.ClearAttributeMask(ECDHidden); |
|
679 } |
|
680 } |
|
681 |
|
682 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
683 CCDAPPrioritySelectionPolicyRecord* CCDValidatorConnPref::FindTheAPPrioritySelPolRecL(TInt aReferredIAPRecId) |
|
684 { |
|
685 //CCDConnectionPrefsRecord* ptrConnPref = static_cast<CCDConnectionPrefsRecord*>(&iElement); |
|
686 |
|
687 CCDAPPrioritySelectionPolicyRecord* defAPSelPolRec = NULL; |
|
688 |
|
689 //1st step - Search for the AP which has its tagID with the same value as the |
|
690 // recordNumber in the iDefaultIAP field in the ConnPref record or the calculated IAP number. |
|
691 // This AP will be the AP on the Link layer. |
|
692 |
|
693 // This is a checking too to be sure that the AP is existing. |
|
694 CMDBField<TInt>* linkLayerAPTagIDField = new(ELeave) CMDBField<TInt>(KCDTIdAccessPointRecord | KCDTIdRecordTag); |
|
695 *linkLayerAPTagIDField = aReferredIAPRecId; |
|
696 CleanupStack::PushL(linkLayerAPTagIDField); |
|
697 |
|
698 if (EDelete == iOperation || |
|
699 linkLayerAPTagIDField->FindL(iSession.iOwner)) |
|
700 { |
|
701 //2nd step - Search for the default Tier in the GlobalSettings Record |
|
702 // (The Global Settings record has to be stored before inserting |
|
703 // the ConnectionPreferences record!!!!). |
|
704 CMDBRecordLink<CCDTierRecord>* defaultTierField = new(ELeave) CMDBRecordLink<CCDTierRecord>(KCDTIdGlobalSettingsRecord | KCDTIdDefaultTier); |
|
705 defaultTierField->SetRecordId(1); |
|
706 CleanupStack::PushL(defaultTierField); |
|
707 |
|
708 //this field HAS to be in the GlobalSettings table as we are in 399 config... |
|
709 defaultTierField->LoadL(iSession.iOwner); |
|
710 |
|
711 //3rd step - Follow the defaultAccessPoint link in the defaultTier record which points to |
|
712 // the default AP record on the Network level. |
|
713 TInt recId = (*defaultTierField) << 8; |
|
714 CMDBRecordLink<CCDAccessPointRecord>* networkDefAPField = |
|
715 new(ELeave) CMDBRecordLink<CCDAccessPointRecord>(recId | |
|
716 KCDTIdDefaultAccessPoint); |
|
717 CleanupStack::PushL(networkDefAPField); |
|
718 |
|
719 networkDefAPField->LoadL(iSession.iOwner); |
|
720 |
|
721 //4th step - Follow the link from the default AP record to the linked APPrioritySelPol record. |
|
722 CMDBRecordLink<CCDAPPrioritySelectionPolicyRecord>* networkSelPolField = |
|
723 new(ELeave) CMDBRecordLink<CCDAPPrioritySelectionPolicyRecord>(((*networkDefAPField) & KCDMaskShowRecordId) | |
|
724 KCDTIdSelectionPolicy); |
|
725 CleanupStack::PushL(networkSelPolField); |
|
726 |
|
727 networkSelPolField->LoadL(iSession.iOwner); |
|
728 |
|
729 //at this point we already know the complete elementId of the default APPrioritySelPol record. |
|
730 //Read the whole record because it will be needed by the IPProto AP generation logic... |
|
731 |
|
732 defAPSelPolRec = static_cast<CCDAPPrioritySelectionPolicyRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdApPrioritySelectionPolicyRecord)); |
|
733 |
|
734 CleanupStack::PushL(defAPSelPolRec); |
|
735 |
|
736 defAPSelPolRec->SetElementId(*networkSelPolField); |
|
737 defAPSelPolRec->LoadL(iSession.iOwner); |
|
738 |
|
739 //we will transfer the ownership of this object to the IPProtoGenerator object |
|
740 CleanupStack::Pop(defAPSelPolRec); |
|
741 CleanupStack::PopAndDestroy(networkSelPolField); |
|
742 CleanupStack::PopAndDestroy(networkDefAPField); |
|
743 CleanupStack::PopAndDestroy(defaultTierField); |
|
744 } |
|
745 else |
|
746 //The link layer AP is not existing. Leaving... |
|
747 { |
|
748 User::Leave(KErrNotFound); |
|
749 } |
|
750 |
|
751 CleanupStack::PopAndDestroy(linkLayerAPTagIDField); |
|
752 |
|
753 return defAPSelPolRec; |
|
754 } |
|
755 |
|
756 |
|
757 void CCDValidatorConnPref::IPProtoAPGenerationOrModificationL() |
|
758 { |
|
759 CCDConnectionPrefsRecord* ptrConnPref = static_cast<CCDConnectionPrefsRecord*>(iElement); |
|
760 |
|
761 TInt referredIAPRecId = 0; |
|
762 |
|
763 if (EModify == iOperation || |
|
764 EStore == iOperation) |
|
765 { |
|
766 if (!(ptrConnPref->iDefaultIAP)) |
|
767 /* There is no default IAP in the ConnPref record so this means that |
|
768 * there is no default legacy path in the DB. |
|
769 * |
|
770 * - If the connpref record is prompting: |
|
771 * Insert an ipproto AP with a cprconfig field which contains the |
|
772 * full TMDBElementID of the given connpref record |
|
773 * |
|
774 * - If the connpref record is not prompting: |
|
775 * - If the rank1 record is the record which has the 0 as the IAP field |
|
776 * then: |
|
777 * - if there is IAP in the DB: |
|
778 * a default IAP has to be calculated |
|
779 * - if there isn't any IAP rec: |
|
780 * - if there is any default ipproto AP: |
|
781 * the Default ipproto AP should be used here as the 399 path. |
|
782 * - if there isn't any default ipproto AP: |
|
783 * one should be generated and linked |
|
784 * |
|
785 * - If the rank2 record is modified like this then: |
|
786 * - if there is IAP in the DB: |
|
787 * a default IAP has to calculated |
|
788 * - if there isn't any IAP rec: |
|
789 * nothing can be done... |
|
790 */ |
|
791 { |
|
792 if (1 == ptrConnPref->iRanking) |
|
793 { |
|
794 if (CommsDatMapperAndValidator::IsIAPRecInDB(iSession.iOwner)) |
|
795 { |
|
796 //there is IAP in the DB - > we can calculate a default one... |
|
797 referredIAPRecId = FindIAPWithoutDefIAPL(); |
|
798 } |
|
799 else |
|
800 { |
|
801 //there is no IAP in the DB |
|
802 CCDAPPrioritySelectionPolicyRecord* defAPSelPolRec = CommsDatMapperAndValidator::FindTheAPPrioritySelPolRecL(iSession.iOwner); |
|
803 |
|
804 CleanupStack::PushL(defAPSelPolRec); |
|
805 |
|
806 //Check whether the AP<ranking from the ConnPref rec> is already filled or not. |
|
807 |
|
808 // - If it's already filled this means that the IPProto level AP is already existing and |
|
809 // needs to be modified only. |
|
810 |
|
811 // - If it's not existing yet this means that a new one has to be generated and all the links |
|
812 // from or to the new record have to maintained. |
|
813 CMDBRecordLink<CCDAccessPointRecord>* apPrioritySelPolLink = |
|
814 GetTheAPxLinkFromAPPrioritySelPol(defAPSelPolRec, |
|
815 ptrConnPref->iRanking); |
|
816 |
|
817 __ASSERT_DEBUG(apPrioritySelPolLink, User::Panic(KCommsDatName,EWrongAPPrioritySelPolRecord)); |
|
818 if (!apPrioritySelPolLink) |
|
819 { |
|
820 User::Leave(KErrArgument); |
|
821 } |
|
822 |
|
823 CCDAccessPointRecord* defIPProtoAP = NULL; |
|
824 |
|
825 if (CommsDatMapperAndValidator::IsDefIPProtoAPInDB(iSession.iOwner)) |
|
826 { |
|
827 //there is an AP with the customSelPol field CCDAccessPointRecord::KNoPolicy. Use that record. |
|
828 defIPProtoAP = CommsDatMapperAndValidator::GetTheDefIPProtoAP(iSession.iOwner); |
|
829 CleanupStack::PushL(defIPProtoAP); |
|
830 } |
|
831 else |
|
832 { |
|
833 //there isn't any default ipproto AP -> have to generate one |
|
834 defIPProtoAP = CommsDatMapperAndValidator::GenerateIPProtoAPL(IPProtoBaseTagId, |
|
835 CCDAccessPointRecord::KNoPolicy, |
|
836 iSession.iOwner); |
|
837 |
|
838 CleanupStack::PushL(defIPProtoAP); |
|
839 |
|
840 defIPProtoAP->iRecordName.SetMaxLengthL(KDefaultIPProtoRecName().Length()); |
|
841 defIPProtoAP->iRecordName = KDefaultIPProtoRecName; |
|
842 |
|
843 //save the generated AP record |
|
844 defIPProtoAP->StoreL(iSession.iOwner); |
|
845 } |
|
846 |
|
847 TMDBElementId elemId = defIPProtoAP->ElementId(); |
|
848 elemId &= KCDMaskHideAttrAndRes; |
|
849 TMDBElementId tableAndRecordBitMask = KCDMaskShowRecordType | KCDMaskShowRecordId; |
|
850 elemId &= tableAndRecordBitMask; |
|
851 |
|
852 //update the APPrioritySelPol record to point to the default IPProto AP record |
|
853 CommsDatMapperAndValidator::ModifyAPPrioritySelPolRecL(apPrioritySelPolLink, |
|
854 defAPSelPolRec, |
|
855 elemId); |
|
856 |
|
857 defAPSelPolRec->ModifyL(iSession.iOwner); |
|
858 |
|
859 //modify the ipproto tier |
|
860 CMDBRecordLink<CCDAccessPointRecord>* ipProtoDefAccessPoint = new(ELeave)CMDBRecordLink<CCDAccessPointRecord>(KCDTIdDefaultAccessPoint); |
|
861 CleanupStack::PushL(ipProtoDefAccessPoint); |
|
862 |
|
863 TInt ipProtoRecId = CommsDatMapperAndValidator::GetIPProtoTierRecordIdL(iSession.iOwner); |
|
864 ipProtoDefAccessPoint->SetRecordId(ipProtoRecId); |
|
865 |
|
866 *ipProtoDefAccessPoint = elemId; |
|
867 ipProtoDefAccessPoint->ModifyL(iSession.iOwner); |
|
868 |
|
869 if (KCDChangedFlag == (ptrConnPref->iDialogPref.ElementId() & KCDChangedFlag)) |
|
870 { |
|
871 /* The dialogPref field has changed -> This means that: |
|
872 * a) we have to create a 'prompting AP' which means that the AP has to |
|
873 * contain the full TMDBElement ID of the given connpref record in its' |
|
874 * CprConfig field (prompting connpref rec). |
|
875 * b) the CprConfig field has to contain the IAP record number this |
|
876 * IPProto AP points to (not prompting connpref rec). |
|
877 */ |
|
878 TBool isPromptingAPNeeded; |
|
879 |
|
880 if (ECommDbDialogPrefUnknown == ptrConnPref->iDialogPref || |
|
881 ECommDbDialogPrefDoNotPrompt== ptrConnPref->iDialogPref) |
|
882 { |
|
883 isPromptingAPNeeded = EFalse; |
|
884 } |
|
885 else |
|
886 { |
|
887 isPromptingAPNeeded = ETrue; |
|
888 } |
|
889 |
|
890 if (isPromptingAPNeeded) |
|
891 { |
|
892 //the cprConfig has to contain the full TMDBElementId of the connpref record |
|
893 defIPProtoAP->iCprConfig = ptrConnPref->ElementId(); |
|
894 } |
|
895 else |
|
896 { |
|
897 /* the cprConfig field has to contain the IAP record id |
|
898 * Because this mapping/validation is done from a legacy configuration |
|
899 * commsdat can assume here that there will be only 3 layers. |
|
900 * |
|
901 * The following line says that the IAP pointed by the cprConfig and the |
|
902 * Link level AP pointed by the customSelectionPolicy field are the same. |
|
903 */ |
|
904 defIPProtoAP->iCprConfig.SetL(ptrConnPref->iDefaultIAP); |
|
905 } |
|
906 |
|
907 defIPProtoAP->ModifyL(iSession.iOwner); |
|
908 } |
|
909 |
|
910 CleanupStack::PopAndDestroy(ipProtoDefAccessPoint); |
|
911 CleanupStack::PopAndDestroy(defIPProtoAP); |
|
912 CleanupStack::PopAndDestroy(defAPSelPolRec); |
|
913 |
|
914 return; |
|
915 } |
|
916 } |
|
917 else |
|
918 { |
|
919 //rank2 record is modified |
|
920 if (CommsDatMapperAndValidator::IsIAPRecInDB(iSession.iOwner)) |
|
921 { |
|
922 //there is IAP in the DB - > we can calculate a default one... |
|
923 referredIAPRecId = FindIAPWithoutDefIAPL(); |
|
924 } |
|
925 else |
|
926 { |
|
927 /* - there is no IAP in the DB |
|
928 * - somebody is inserting a ranking2 connpref record |
|
929 * |
|
930 * Is this a normal case????? How should we handle it? |
|
931 */ |
|
932 return; |
|
933 } |
|
934 } |
|
935 } |
|
936 else |
|
937 //There is a default IAP in the record so just read it... |
|
938 //NOTE that this piece of code here assumes that the IAP in the ConnPref record is only a |
|
939 // number and _NOT_ a fully qualified link!!! |
|
940 { |
|
941 referredIAPRecId = ptrConnPref->iDefaultIAP.GetL(); |
|
942 } |
|
943 } |
|
944 |
|
945 //1st step - Search for the AP which has its tagID with the same value as the |
|
946 // recordNumber in the iDefaultIAP field in the ConnPref record or the calculated IAP number. |
|
947 // This AP will be the AP on the Link layer. |
|
948 |
|
949 // This is a checking too to be sure that the AP is existing. |
|
950 CMDBField<TInt>* linkLayerAPTagIDField = new(ELeave) CMDBField<TInt>(KCDTIdAccessPointRecord | KCDTIdRecordTag); |
|
951 *linkLayerAPTagIDField = referredIAPRecId; |
|
952 CleanupStack::PushL(linkLayerAPTagIDField); |
|
953 |
|
954 TBool foundLinkLayerAP = linkLayerAPTagIDField->FindL(iSession.iOwner); |
|
955 |
|
956 if (EDelete == iOperation || |
|
957 foundLinkLayerAP ) |
|
958 { |
|
959 //CCDAPPrioritySelectionPolicyRecord* defAPSelPolRec = FindTheAPPrioritySelPolRecL(referredIAPRecId); |
|
960 |
|
961 CCDAPPrioritySelectionPolicyRecord* defAPSelPolRec = CommsDatMapperAndValidator::FindTheAPPrioritySelPolRecL(iSession.iOwner); |
|
962 |
|
963 CleanupStack::PushL(defAPSelPolRec); |
|
964 |
|
965 //Check whether the AP<ranking from the ConnPref rec> is already filled or not. |
|
966 |
|
967 // - If it's already filled this means that the IPProto level AP is already existing and |
|
968 // needs to be modified only. |
|
969 |
|
970 // - If it's not existing yet this means that a new one has to be generated and all the links |
|
971 // from or to the new record have to maintained. |
|
972 CMDBRecordLink<CCDAccessPointRecord>* apPrioritySelPolLink = |
|
973 GetTheAPxLinkFromAPPrioritySelPol(defAPSelPolRec, |
|
974 ptrConnPref->iRanking); |
|
975 |
|
976 __ASSERT_DEBUG(apPrioritySelPolLink, User::Panic(KCommsDatName,EWrongAPPrioritySelPolRecord)); |
|
977 if (!apPrioritySelPolLink) |
|
978 { |
|
979 User::Leave(KErrArgument); |
|
980 } |
|
981 |
|
982 if (*apPrioritySelPolLink) |
|
983 //the AP<x> field has been already filled so the IPProto level AP is already existing. Only |
|
984 //modification is needed. |
|
985 { |
|
986 if (EModify == iOperation || |
|
987 EStore == iOperation) |
|
988 { |
|
989 iIPProtoGenerator = new(ELeave) CIPProtoAPModifier(defAPSelPolRec, |
|
990 *iElement, |
|
991 iSession, |
|
992 referredIAPRecId); |
|
993 |
|
994 //we transferred the ownership of this object to the IPProtoGenerator object |
|
995 CleanupStack::Pop(defAPSelPolRec); |
|
996 } |
|
997 else |
|
998 //The pointed AP should be deleted... |
|
999 { |
|
1000 iIPProtoGenerator = new(ELeave) CIPProtoAPRemover(defAPSelPolRec, |
|
1001 *iElement, |
|
1002 iSession); |
|
1003 |
|
1004 //we transferred the ownership of this object to the IPProtoGenerator object |
|
1005 CleanupStack::Pop(defAPSelPolRec); |
|
1006 } |
|
1007 } |
|
1008 else |
|
1009 //the AP<x> field has not been filled yet so creation is needed. |
|
1010 { |
|
1011 if (EModify == iOperation || |
|
1012 EStore == iOperation) |
|
1013 { |
|
1014 iIPProtoGenerator = new(ELeave) CIPProtoAPCreator(defAPSelPolRec, |
|
1015 *iElement, |
|
1016 iSession, |
|
1017 referredIAPRecId); |
|
1018 |
|
1019 //we transferred the ownership of this object to the IPProtoGenerator object |
|
1020 CleanupStack::Pop(defAPSelPolRec); |
|
1021 } |
|
1022 else |
|
1023 //hm... This is a delete operation and the AP<x> field is not filled in the |
|
1024 //APPrioritySelPol record. Database is inconsistent - would be better to leave?? |
|
1025 { |
|
1026 CleanupStack::PopAndDestroy(defAPSelPolRec); |
|
1027 CleanupStack::PopAndDestroy(linkLayerAPTagIDField); |
|
1028 return; |
|
1029 } |
|
1030 } |
|
1031 |
|
1032 //Modify or generate the IPProto level AP. |
|
1033 iIPProtoGenerator->DoTheWorkL(); |
|
1034 } |
|
1035 else |
|
1036 //The link layer AP is not existing. Leaving... |
|
1037 { |
|
1038 User::Leave(KErrNotFound); |
|
1039 } |
|
1040 |
|
1041 CleanupStack::PopAndDestroy(linkLayerAPTagIDField); |
|
1042 } |
|
1043 |
|
1044 |
|
1045 /** |
|
1046 NOTE: This function is a modified copy from the void CCommsDbTableView::ConstructL(TUint32 aBearerSet, TCommDbConnectionDirection aDirection) |
|
1047 function (in the commdb/commdbshim/scdb/cdbtable.cpp)!! |
|
1048 */ |
|
1049 TInt CCDValidatorConnPref::FindIAPWithoutDefIAPL() |
|
1050 { |
|
1051 CCDConnectionPrefsRecord* ptrConnPref = static_cast<CCDConnectionPrefsRecord*>(iElement); |
|
1052 |
|
1053 CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord)); |
|
1054 CleanupStack::PushL(iapRecord); |
|
1055 |
|
1056 CMDBField<TCommDbConnectionDirection>& direction = ptrConnPref->iDirection; |
|
1057 CMDBField<TUint32>& bearerSet = ptrConnPref->iBearerSet; |
|
1058 |
|
1059 TUint32 tempBearer = static_cast<TUint32>(bearerSet); |
|
1060 TCommDbConnectionDirection tempDirection = static_cast<TCommDbConnectionDirection>(direction); |
|
1061 |
|
1062 TBool defIAPFound = EFalse; |
|
1063 |
|
1064 TUint32 servTypeArrayStartIndex = 0; |
|
1065 |
|
1066 while ((!defIAPFound) && ((TInt)servTypeArrayStartIndex < KNumServiceType)) |
|
1067 { |
|
1068 TInt serviceTypeIndex = GetIAPServiceType( servTypeArrayStartIndex, (TCommDbBearer)tempBearer, tempDirection ); |
|
1069 __ASSERT_DEBUG(serviceTypeIndex!=KErrNotFound, User::Panic(KCommsDatName,EWrongIAPServiceType)); |
|
1070 if (KErrNotFound == serviceTypeIndex) |
|
1071 { |
|
1072 User::LeaveIfError(serviceTypeIndex); |
|
1073 } |
|
1074 |
|
1075 const TPtrC serviceType(KMap[serviceTypeIndex].serviceType); |
|
1076 |
|
1077 // prime the service type |
|
1078 iapRecord->iServiceType.SetMaxLengthL(serviceType.Length()); |
|
1079 iapRecord->iServiceType = serviceType; |
|
1080 |
|
1081 defIAPFound = iapRecord->FindL(iSession.iOwner); |
|
1082 if (!defIAPFound) |
|
1083 { |
|
1084 //No IAP record can be found with the given service |
|
1085 ++servTypeArrayStartIndex; |
|
1086 } |
|
1087 } |
|
1088 |
|
1089 if (!defIAPFound) |
|
1090 { |
|
1091 //No IAP record can be found with the given service(s) |
|
1092 User::Leave(KErrNotFound); |
|
1093 } |
|
1094 |
|
1095 |
|
1096 TInt tempRecId = iapRecord->RecordId(); |
|
1097 |
|
1098 CleanupStack::PopAndDestroy(iapRecord); |
|
1099 |
|
1100 return tempRecId; |
|
1101 } |
|
1102 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1103 |
|
1104 void CCDValidatorConnPref::ValidateBearerAndDirectionL(const TDesC& aServiceType, TCommDbConnectionDirection aDirection, TUint32 aBearerSet, TCommDbDialogPref aDlgPref) |
|
1105 { |
|
1106 TCommDbConnectionDirection expectedDirection = ECommDbConnectionDirectionUnknown; |
|
1107 TInt expectedBearer = KCommDbBearerUnknown; |
|
1108 |
|
1109 if (aServiceType == TPtrC(DIAL_OUT_ISP)) |
|
1110 { |
|
1111 expectedDirection = ECommDbConnectionDirectionOutgoing; |
|
1112 expectedBearer = KCommDbBearerCSD; |
|
1113 } |
|
1114 else if (aServiceType == TPtrC(DIAL_IN_ISP)) |
|
1115 { |
|
1116 expectedDirection = ECommDbConnectionDirectionIncoming; |
|
1117 expectedBearer = KCommDbBearerCSD; |
|
1118 } |
|
1119 else if (aServiceType == TPtrC(OUTGOING_GPRS)) |
|
1120 { |
|
1121 expectedDirection = ECommDbConnectionDirectionOutgoing; |
|
1122 expectedBearer = KCommDbBearerWcdma; |
|
1123 } |
|
1124 else if (aServiceType == TPtrC(INCOMING_GPRS)) |
|
1125 { |
|
1126 expectedDirection = ECommDbConnectionDirectionIncoming; |
|
1127 expectedBearer = KCommDbBearerWcdma; |
|
1128 } |
|
1129 else if (aServiceType == TPtrC(LAN_SERVICE)) |
|
1130 { |
|
1131 expectedBearer = KCommDbBearerLAN | KCommDbBearerPAN | KCommDbBearerWLAN; |
|
1132 } |
|
1133 else if (aServiceType == TPtrC(VPN_SERVICE)) |
|
1134 { |
|
1135 expectedBearer = KCommDbBearerVirtual; |
|
1136 } |
|
1137 |
|
1138 TBool valid; |
|
1139 if (aDlgPref == ECommDbDialogPrefPromptIfWrongMode) |
|
1140 { |
|
1141 // this pref should only be used for PSD bearers |
|
1142 // if expectedBearer == KCommDbBearerWcdma then bearer set should |
|
1143 // include something other than KCommDbBearerWcdma |
|
1144 valid = (~expectedBearer & aBearerSet) != 0 && (expectedBearer == KCommDbBearerWcdma); |
|
1145 } |
|
1146 else if (aDlgPref == ECommDbDialogPrefPrompt) |
|
1147 { |
|
1148 // the expected bearer should be included in the bearer set |
|
1149 // along with any other bearer |
|
1150 |
|
1151 if (aServiceType == TPtrC(VPN_SERVICE)) |
|
1152 valid = ETrue; |
|
1153 else |
|
1154 valid = (expectedBearer & aBearerSet) != 0; |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 // no restriction on the dialog preference |
|
1159 valid = ETrue; |
|
1160 } |
|
1161 |
|
1162 if (valid) |
|
1163 { |
|
1164 valid = aDirection == expectedDirection || |
|
1165 expectedDirection == ECommDbConnectionDirectionUnknown; |
|
1166 } |
|
1167 |
|
1168 if (!valid) |
|
1169 User::Leave(KErrArgument); |
|
1170 } |
|
1171 |
|
1172 |
|
1173 |
|
1174 /************************ 2e) Validate IAP Record ************************************ |
|
1175 */ |
|
1176 |
|
1177 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1178 |
|
1179 |
|
1180 // The relation of an IAP to its mapped AccessPoint records is as depicted below: |
|
1181 // |
|
1182 // IAP table (index == RecordId) AP table (index == Tag) |
|
1183 // --------- -------- |
|
1184 // |
|
1185 // |
|
1186 // ----- iCprConfig == 1 (a) ----- |
|
1187 // | 1|<------------------------------------| 1| |
|
1188 // | |- - - - - - - - - - - - - - - - - - >| |<----------- + |
|
1189 // ----- (inferred association) ----- | |
|
1190 // ^ | link AP | |
|
1191 // | | | |
|
1192 // | | | |
|
1193 // | | | |
|
1194 // | | | |
|
1195 // | | | |
|
1196 // | | iAccessPoint == 256 (b) ----- | |
|
1197 // | +-------------------------------------->| 256| iSelectionPolicy == 257 (c) |
|
1198 // | | |----+ | |
|
1199 // | ----- | | |
|
1200 // | net AP | | |
|
1201 // | | | |
|
1202 // | iCprConfig == 1 (a) ----- | | |
|
1203 // +-----------------------------------------| 257|<---+ | |
|
1204 // | |-------------+ |
|
1205 // ----- iSelectionPolicy == 1 (d) |
|
1206 // ipProto AP |
|
1207 // |
|
1208 // |
|
1209 // The following expressions are used to link the IAP and AP records: |
|
1210 // where: |
|
1211 // n = IAP record's recordId. |
|
1212 // B = the LinkBoundary (reserved Tags, currently 255) |
|
1213 // |
|
1214 // (a) = n |
|
1215 // (b) = B + 2n - 1 |
|
1216 // (c) = (b) + 1 |
|
1217 // (d) = n |
|
1218 // |
|
1219 |
|
1220 // The first 'KAPToIAPMappingThreshold' Tag Ids ('B' in the diagram above) are reserved for direct IAP to AP mapping, |
|
1221 // for those AP records where the index must match that of the RecordId of the corresponding IAP record. |
|
1222 // |
|
1223 // Note: |
|
1224 // We put the mapped AP's at the top of the permissible recordIds (being 254) and grows downwards. |
|
1225 // |
|
1226 // This should avoid colliding with any user created (either via input file, or dynamically). |
|
1227 // At time of writing, in the XML files, the RecordId cannot be specified (unlike in .cfg files) and a record's Id |
|
1228 // is calculated on the basis of its order of declaration in its table (in the markup). |
|
1229 // |
|
1230 // In .cfg files (where it is able and usual to specify the recordId - using the well known "# COMMDB_ID = x" |
|
1231 // statements) it is usual to start from 1 and count upwards. |
|
1232 // |
|
1233 // This might change, so is not included in the check at top of the function, when finding mapped AP records. |
|
1234 // |
|
1235 //static const TUint KAPToIAPTagMappingThreshold = 255; |
|
1236 static const TUint KAPToIAPRecordIdMappingConstant = 251; |
|
1237 |
|
1238 // TCleanupOperation function. |
|
1239 // |
|
1240 template <class T> |
|
1241 void DestroyRPointerArray(TAny* aPtr) |
|
1242 { |
|
1243 RPointerArray<T>* self = static_cast<RPointerArray<T>*>(aPtr); |
|
1244 self->ResetAndDestroy(); |
|
1245 } |
|
1246 |
|
1247 |
|
1248 static const TUint32 KZero = 0; |
|
1249 |
|
1250 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1251 |
|
1252 |
|
1253 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1254 void CCDValidatorIAPRecord::DeleteAssociatedLinkLevelAPL() |
|
1255 { |
|
1256 CCDAccessPointRecord* linkAPRecord = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
1257 CleanupStack::PushL(linkAPRecord); |
|
1258 |
|
1259 linkAPRecord->iRecordTag = iElement->RecordId(); |
|
1260 |
|
1261 if (linkAPRecord->FindL(iSession.iOwner)) |
|
1262 { |
|
1263 linkAPRecord->DeleteL(iSession.iOwner); |
|
1264 } |
|
1265 |
|
1266 CleanupStack::PopAndDestroy(linkAPRecord); |
|
1267 } |
|
1268 #endif |
|
1269 |
|
1270 void CCDValidatorIAPRecord::ServiceAndBearerValidationL() |
|
1271 { |
|
1272 #ifndef SYMBIAN_COMMSDAT_USE_INT_RECORD_LINKS |
|
1273 //at this point iElement has to be an IAP record!!! |
|
1274 CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(iElement); |
|
1275 |
|
1276 if (!iapRecord->iService.IsNull() && !iapRecord->iServiceType.IsNull()) |
|
1277 { |
|
1278 //this was caught in testing but actually it is not valid to have a real record without these fields... |
|
1279 |
|
1280 TMDBElementId tableTypeId = CommsDatSchemaV1_1::LookupTableId(iapRecord->iServiceType.GetL()); |
|
1281 iapRecord->iService = CommsDatSchema::GetLinkIdL(iSession.iOwner, iapRecord->iService.ElementId(), iapRecord->iService.GetL(), tableTypeId/*, &iapRecord*/); |
|
1282 } |
|
1283 |
|
1284 if (!iapRecord->iBearer.IsNull() && !iapRecord->iBearerType.IsNull()) |
|
1285 { |
|
1286 //this was caught in testing but actually it is not valid to have a real record without these fields... |
|
1287 |
|
1288 TMDBElementId tableTypeId = CommsDatSchemaV1_1::LookupTableId(iapRecord->iBearerType.GetL()); |
|
1289 iapRecord->iBearer = CommsDatSchema::GetLinkIdL(iSession.iOwner, iapRecord->iBearer.ElementId(), iapRecord->iBearer.GetL(), tableTypeId/*, &iapRecord*/); |
|
1290 } |
|
1291 #endif |
|
1292 } |
|
1293 |
|
1294 |
|
1295 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1296 void CCDValidatorIAPRecord::AssociatedLinkLevelAPGenerationL() |
|
1297 { |
|
1298 |
|
1299 // map to AP record |
|
1300 |
|
1301 //at this point iElement has to be an IAP record!!! |
|
1302 CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(iElement); |
|
1303 |
|
1304 /* |
|
1305 some of this work is a bit like mapping, but |
|
1306 the IAP record is still present in the database so doing this as validation |
|
1307 */ |
|
1308 TInt err = KErrNone; |
|
1309 |
|
1310 //typedef enum {ENetworkAP, EIPProtocolAP, ELinkAP, EAPRecordIndicesLast = ELinkAP, EAPRecordIndicesRange = EAPRecordIndicesLast + 1} TAPRecordIndices; |
|
1311 |
|
1312 // Calculate the 3 potential AP indices |
|
1313 // |
|
1314 const TInt KThisIAPRecordId = iapRecord->RecordId(); |
|
1315 const TInt KLinkAPTag = KThisIAPRecordId; |
|
1316 //const TInt KNetworkAPTag = KAPToIAPTagMappingThreshold + (2 * KThisIAPRecordId) - 1; |
|
1317 //const TInt KIPProtoAPTag = KNetworkAPTag + 1; |
|
1318 |
|
1319 __FLOG_STATIC1(KLogComponent, KCDInfoLog, |
|
1320 _L("CCDValidatorIAPRecord::DoValidateL() - Processing IAP record <%d>"), |
|
1321 KThisIAPRecordId); |
|
1322 |
|
1323 |
|
1324 // 666 |
|
1325 // Should tidy these variables up into a class, but the turgidness of it all is just |
|
1326 // distracting from getting immediate objective of getting over-night build tests going. |
|
1327 // |
|
1328 // Create copies of these recordIds, not so clever. |
|
1329 // |
|
1330 |
|
1331 //const TInt KAPRecordIdsTable[] = {KNetworkAPTag, KIPProtoAPTag, KLinkAPTag}; |
|
1332 TUint numberOfAPRecordsFound = 0; |
|
1333 |
|
1334 //RPointerArray<CCDAccessPointRecord> apRecords; |
|
1335 //CleanupStack::PushL(TCleanupItem(DestroyRPointerArray<CCDAccessPointRecord>, &apRecords)); |
|
1336 |
|
1337 TBuf<KCDMaxFieldNameLength> tempName; |
|
1338 _LIT(KMappedFrom, "MappedFromIAP"); |
|
1339 |
|
1340 // See which, if any of the records of interest exist already. |
|
1341 // |
|
1342 //for (TUint i = 0; i <= EAPRecordIndicesLast; i++) |
|
1343 // { |
|
1344 CCDAccessPointRecord* record = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
1345 CleanupStack::PushL(record); |
|
1346 //apRecords.InsertL(record, i); |
|
1347 |
|
1348 // Prime the search record and load it. |
|
1349 |
|
1350 TBool found = EFalse; |
|
1351 record->iRecordTag = KLinkAPTag; //KAPRecordIdsTable[i]; |
|
1352 TRAPD(loadErr, found = record->FindL(iSession.iOwner)); |
|
1353 |
|
1354 // Apply additional rules when validating, a mapped IAP must conform to. |
|
1355 // |
|
1356 if (loadErr == KErrNone && found) |
|
1357 { |
|
1358 _LIT(KAPNameCheckFormat, "%S%d"); |
|
1359 tempName.Format(KAPNameCheckFormat, &KMappedFrom, KThisIAPRecordId); |
|
1360 |
|
1361 // Its name should be that expected (ie which was applied by this function). |
|
1362 // |
|
1363 TPtrC tempPtr(static_cast<const TDesC&>(record->iRecordName)); |
|
1364 if (tempPtr.Find(tempName) != KErrNotFound |
|
1365 && record->iSelectionPolicy == 0) |
|
1366 |
|
1367 // And the selection policy and cpr config should conform to the diagram at the top of this function. |
|
1368 // |
|
1369 { |
|
1370 numberOfAPRecordsFound++; |
|
1371 } |
|
1372 } |
|
1373 if (loadErr != KErrNone && loadErr != KErrNotFound) |
|
1374 { |
|
1375 CleanupStack::PopAndDestroy(record); |
|
1376 record = NULL; |
|
1377 User::Leave(loadErr); |
|
1378 } |
|
1379 // } // for... |
|
1380 |
|
1381 |
|
1382 // Now let's evaluate what we've found. |
|
1383 // |
|
1384 if (numberOfAPRecordsFound == 0) |
|
1385 { |
|
1386 __FLOG_STATIC1(KLogComponent, KCDInfoLog, |
|
1387 _L("CCDValidatorIAPRecord::DoValidateL() - Creating AP record for IAP record <%d>"), |
|
1388 KThisIAPRecordId); |
|
1389 |
|
1390 // No AP records exist for this IAP, the IAP record therefore needs to be mapped. |
|
1391 |
|
1392 // Go on and create the 3 new AP records... neatly presented from top to bottom of stack. |
|
1393 |
|
1394 _LIT(KAPNameFormat, "%S%S%d"); |
|
1395 |
|
1396 |
|
1397 CCDAccessPointRecord *newAPRecord = |
|
1398 static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
1399 CleanupStack::PushL(newAPRecord); |
|
1400 |
|
1401 const TInt KBaseAPRecordId = KAPToIAPRecordIdMappingConstant - KThisIAPRecordId; |
|
1402 |
|
1403 // ... and finally the link record |
|
1404 |
|
1405 // The clean up stack handling of 'pBearerType' seems a bit contorted. |
|
1406 |
|
1407 CCDBearerTypeRecord* pBearerType = NULL; |
|
1408 TRAPD(ret, pBearerType = NewBearerTypeRecordL(iSession.iOwner, *iapRecord)); |
|
1409 if (ret != KErrNone || !pBearerType) |
|
1410 { |
|
1411 // Unfortunately, there are incorrect/unused IAPs in some of these configuration files (presumably they're dead). |
|
1412 // |
|
1413 __FLOG_STATIC1(KLogComponent, KCDInfoLog, |
|
1414 _L("CCDValidatorIAPRecord::DoValidateL() - error when mapping IAP record %d to its bearer"), |
|
1415 KThisIAPRecordId); |
|
1416 |
|
1417 if (pBearerType) |
|
1418 { |
|
1419 CleanupStack::PushL(pBearerType); |
|
1420 } |
|
1421 |
|
1422 // But since we're not aiming to validate their config files, don't flag error, otherwise we'll leave and |
|
1423 // the user will never get to create a (to them) usable database. |
|
1424 } |
|
1425 else if (ret == KErrNone && pBearerType) |
|
1426 { |
|
1427 CleanupStack::PushL(pBearerType); |
|
1428 |
|
1429 TPtrC name(pBearerType->iRecordName); |
|
1430 tempName.Format(KAPNameFormat, &name, &KMappedFrom, KThisIAPRecordId); |
|
1431 InitialiseAccessPointRecordL( |
|
1432 *newAPRecord, |
|
1433 tempName, |
|
1434 KBaseAPRecordId - KThisIAPRecordId, |
|
1435 KLinkAPTag, |
|
1436 pBearerType->iTier, |
|
1437 pBearerType->iMCpr, |
|
1438 KZero, |
|
1439 pBearerType->iCpr, |
|
1440 KZero, |
|
1441 pBearerType->iSCpr, |
|
1442 pBearerType->iProtocol); |
|
1443 newAPRecord->StoreL(iSession.iOwner); // 666 - TRAP |
|
1444 |
|
1445 TInt linkAPTagId = newAPRecord->iRecordTag; |
|
1446 |
|
1447 if (!CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(linkAPTagId, iSession.iOwner)) |
|
1448 { |
|
1449 //The IPProto AP is not existing yet. Generate one. |
|
1450 CCDAccessPointRecord* ipprotoAP = CommsDatMapperAndValidator::GenerateIPProtoAPL(IPProtoBaseTagId, linkAPTagId, iSession.iOwner); |
|
1451 CleanupStack::PushL(ipprotoAP); |
|
1452 |
|
1453 //save the generated AP record |
|
1454 ipprotoAP->StoreL(iSession.iOwner); |
|
1455 CleanupStack::PopAndDestroy(ipprotoAP); |
|
1456 } |
|
1457 |
|
1458 |
|
1459 __FLOG_STATIC1(KLogComponent, KCDInfoLog, |
|
1460 _L("CCDValidatorIAPRecord::DoValidateL() - Created AP records for IAP record <%d>"), |
|
1461 KThisIAPRecordId); |
|
1462 |
|
1463 // Update the IAP record itself to point to top-most AP tier record. |
|
1464 // |
|
1465 //thisIAPRecord->iAccessPoint = KNetworkAPTag; |
|
1466 } |
|
1467 else |
|
1468 { |
|
1469 // 666 All 1 expected AP records exist and the links between records make sense. |
|
1470 // So we assume that they have been correctly mapped already - perhaps have been called from ModifyL()? |
|
1471 // Do nothing |
|
1472 // |
|
1473 __FLOG_STATIC1(KLogComponent, KCDInfoLog, |
|
1474 _L("CCDValidatorIAPRecord::DoValidateL() - Found existing valid AP record for IAP record <%d>"), |
|
1475 KThisIAPRecordId); |
|
1476 } |
|
1477 |
|
1478 |
|
1479 if (pBearerType) |
|
1480 { |
|
1481 CleanupStack::PopAndDestroy(pBearerType); |
|
1482 } |
|
1483 CleanupStack::PopAndDestroy(newAPRecord); |
|
1484 } |
|
1485 |
|
1486 CleanupStack::PopAndDestroy(record); |
|
1487 |
|
1488 if (err != KErrNone) |
|
1489 { |
|
1490 //User::Leave(err); |
|
1491 __FLOG_STATIC2(KLogComponent, KCDErrLog, |
|
1492 _L("CCDValidatorIAPRecord::DoValidateL() - error <%d> when mapping IAP record <%d> to AP - indeterminate state"), |
|
1493 err, KThisIAPRecordId); |
|
1494 } |
|
1495 |
|
1496 } |
|
1497 #endif |
|
1498 |
|
1499 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1500 void CCDValidatorIAPRecord::SetShadowElementL() |
|
1501 { |
|
1502 iShadowElement = CCDRecordBase::RecordFactoryL(KCDTIdIAPRecord); |
|
1503 iShadowElement->SetRecordId(iElement->RecordId()); |
|
1504 iShadowElement->LoadL(iSession.iOwner); |
|
1505 |
|
1506 if ( KCDMaskShowFieldType != (KCDMaskShowFieldType & iElement->ElementId()) ) |
|
1507 { |
|
1508 //field validation |
|
1509 CMDBElement* shadowFieldPtr = static_cast<CMDBRecordBase*>(iShadowElement)->GetFieldByIdL(iElement->ElementId()); |
|
1510 |
|
1511 |
|
1512 if ( KCDTIdRecordName == (iElement->ElementId() & KCDMaskShowFieldType) || |
|
1513 KCDTIdIAPServiceType == (iElement->ElementId() & KCDMaskShowType) || |
|
1514 KCDTIdIAPBearerType == (iElement->ElementId() & KCDMaskShowType) ) |
|
1515 { |
|
1516 CMDBField<TDesC>* nameField = static_cast<CMDBField<TDesC>*>(shadowFieldPtr); |
|
1517 CMDBField<TDesC>* origField = static_cast<CMDBField<TDesC>*>(iElement); |
|
1518 |
|
1519 nameField->SetL(*origField); |
|
1520 } |
|
1521 else |
|
1522 { |
|
1523 //the only reason this cast can be done here is that the iap record contains only |
|
1524 //numerical based fields... (except the name, bearertype, servicetype fields -> handled above...) |
|
1525 CMDBField<TInt>* numField = static_cast<CMDBField<TInt>*>(shadowFieldPtr); |
|
1526 CMDBField<TInt>* origField = static_cast<CMDBField<TInt>*>(iElement); |
|
1527 |
|
1528 if (EDelete == iOperation) |
|
1529 { |
|
1530 numField->SetL(0); |
|
1531 } |
|
1532 else |
|
1533 { |
|
1534 numField->SetL(*origField); |
|
1535 } |
|
1536 } |
|
1537 } |
|
1538 |
|
1539 iElement = iShadowElement; |
|
1540 } |
|
1541 #endif |
|
1542 |
|
1543 void CCDValidatorIAPRecord::DoValidateL() |
|
1544 /* |
|
1545 1/ Validate the record links for service and bearer records |
|
1546 ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1547 2/ Create an AP record etc |
|
1548 endif SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1549 |
|
1550 @internalComponent |
|
1551 */ |
|
1552 { |
|
1553 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1554 if (EDelete == iOperation ) |
|
1555 { |
|
1556 if ( KCDMaskShowFieldType == (KCDMaskShowFieldType & iElement->ElementId()) ) |
|
1557 { |
|
1558 //deleting a whole IAP record -> the associated AP record should be deleted as well |
|
1559 DeleteAssociatedLinkLevelAPL(); |
|
1560 } |
|
1561 else |
|
1562 { |
|
1563 //deleting only a field from the record. Here the validator checks the inegrity of the IAP record. |
|
1564 //So if the client deleted one of the bearer or service fields the integrity check won't be successful |
|
1565 //we have to copy the origElemId because the SetShadowElementL will reset it... |
|
1566 TUint origElemId = iElement->ElementId(); |
|
1567 |
|
1568 SetShadowElementL(); |
|
1569 ServiceAndBearerValidationL(); |
|
1570 |
|
1571 if ( KCDTIdIAPAppSid == (origElemId & KCDMaskShowType) ) |
|
1572 { |
|
1573 //this field has to be mapped to the associated AP |
|
1574 CMDBField<TInt>* linkAPTagId = new(ELeave)CMDBField<TInt>(KCDTIdAccessPointRecord | KCDTIdRecordTag); |
|
1575 CleanupStack::PushL(linkAPTagId); |
|
1576 |
|
1577 *linkAPTagId = iElement->RecordId(); |
|
1578 if (linkAPTagId->FindL(iSession.iOwner)) |
|
1579 { |
|
1580 CMDBField<TInt>* appSidField = new(ELeave)CMDBField<TInt>(KCDTIdAppSID); |
|
1581 CleanupStack::PushL(appSidField); |
|
1582 |
|
1583 appSidField->SetRecordId(linkAPTagId->RecordId()); |
|
1584 appSidField->DeleteL(iSession.iOwner); |
|
1585 |
|
1586 CleanupStack::PopAndDestroy(appSidField); |
|
1587 } |
|
1588 CleanupStack::PopAndDestroy(linkAPTagId); |
|
1589 } |
|
1590 } |
|
1591 } |
|
1592 else if (EStore == iOperation || |
|
1593 EModify == iOperation ) |
|
1594 { |
|
1595 if ( KCDMaskShowFieldType == (KCDMaskShowFieldType & iElement->ElementId()) ) |
|
1596 { |
|
1597 //ModifyL or StoreL is called on a record container |
|
1598 ServiceAndBearerValidationL(); |
|
1599 } |
|
1600 else |
|
1601 { |
|
1602 //it's a field modification |
|
1603 SetShadowElementL(); |
|
1604 ServiceAndBearerValidationL(); |
|
1605 } |
|
1606 |
|
1607 if (EModify == iOperation) |
|
1608 { |
|
1609 DeleteAssociatedLinkLevelAPL(); |
|
1610 } |
|
1611 |
|
1612 AssociatedLinkLevelAPGenerationL(); |
|
1613 } |
|
1614 #else |
|
1615 ServiceAndBearerValidationL(); |
|
1616 #endif |
|
1617 } // CCDMapperIAPRecord::DoValidateL() |
|
1618 |
|
1619 |
|
1620 void CCDValidatorIAPRecord::OnDeleteL() |
|
1621 { |
|
1622 // TODO Cleanup on deletion of IAP record (cleanup matching AP?) |
|
1623 // meanwhile do nothing |
|
1624 User::LeaveIfError(ETrue); |
|
1625 } |
|
1626 |
|
1627 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1628 void CCDValidatorIAPRecord::InitialiseAccessPointRecordL( CCDAccessPointRecord& lhs, |
|
1629 const TDesC& aRecordName, |
|
1630 TInt aRecordId, |
|
1631 TInt aTag, |
|
1632 TUint32 aTier, |
|
1633 TUint32 aMCpr, |
|
1634 TUint32 aSelectionPolicy, |
|
1635 TUint32 aCpr, |
|
1636 TUint32 aCprConfig, |
|
1637 TUint32 aSCpr, |
|
1638 TUint32 aProtocol) |
|
1639 { |
|
1640 lhs.iRecordName.SetMaxLengthL(aRecordName.Length()); |
|
1641 lhs.iRecordName = aRecordName; |
|
1642 lhs.SetRecordId(aRecordId); |
|
1643 lhs.iRecordTag = aTag; |
|
1644 lhs.iTier = aTier; |
|
1645 lhs.iMCpr = aMCpr; |
|
1646 lhs.iSelectionPolicy = aSelectionPolicy; |
|
1647 lhs.iCpr = aCpr; |
|
1648 lhs.iCprConfig = aCprConfig; |
|
1649 lhs.iSCpr = aSCpr; |
|
1650 lhs.iProtocol = aProtocol; |
|
1651 |
|
1652 CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord*>(iElement); |
|
1653 |
|
1654 lhs.iAppSID.SetL(iapRecord->iAppSid); |
|
1655 lhs.iPriority = KMaxTUint; |
|
1656 } |
|
1657 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1658 |
|
1659 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1660 CCDBearerTypeRecord* CCDValidatorIAPRecord::NewBearerTypeRecordL(CMDBSession& aSessionOwner, CCDIAPRecord& aIAPRecord) |
|
1661 { |
|
1662 typedef enum {EModemBearer, ELANBearer, EVirtualBearer, TBearersLast = EVirtualBearer} TBearers; |
|
1663 |
|
1664 CCDBearerTypeRecord* pBearerType = NULL; |
|
1665 |
|
1666 __FLOG_STATIC1(KLogComponent, KCDInfoLog, |
|
1667 _L("CCDValidatorIAPRecord::NewBearerTypeRecordL() - Searching for bearer-type for IAP <%d>"), |
|
1668 aIAPRecord.RecordId()); |
|
1669 |
|
1670 // Note: |
|
1671 // These constants and tables are all grouped together at the top of the function. |
|
1672 // |
|
1673 // When intelligent links are added to CommsDat, much of this, and associated code, should become redundant. |
|
1674 |
|
1675 // Lookup table of the relevant bearer string identifiers. |
|
1676 // Keys for the IAP record's 'iBearerType' field. |
|
1677 // |
|
1678 const TText* const KBearerLookupTable[] = |
|
1679 { |
|
1680 KCDTypeNameModemBearer, |
|
1681 KCDTypeNameLANBearer, |
|
1682 KCDTypeNameVirtualBearer |
|
1683 }; |
|
1684 |
|
1685 // Lookup table of the relevant TMDBElementIds |
|
1686 // |
|
1687 const TMDBElementId KBearerIdLookupTable[] = |
|
1688 { |
|
1689 KCDTIdModemBearerRecord, |
|
1690 KCDTIdLANBearerRecord, |
|
1691 KCDTIdVirtualBearerRecord |
|
1692 }; |
|
1693 |
|
1694 _LIT(KSpudNif, "spud"); |
|
1695 _LIT(KSpudNifPrefix, "spud-%S"); |
|
1696 _LIT(KOutgoingGPRS, "outgoinggprs"); |
|
1697 _LIT(KLowerNifKey, "lowernif="); |
|
1698 |
|
1699 |
|
1700 TBearers thisBearer = EModemBearer; |
|
1701 TBool found = EFalse; |
|
1702 if (!aIAPRecord.iBearerType.IsNull()) |
|
1703 { |
|
1704 TPtrC bearerType(aIAPRecord.iBearerType); |
|
1705 |
|
1706 for (TInt i = 0; i <= TBearersLast; i++) |
|
1707 { |
|
1708 if (bearerType.CompareF(TPtrC(KBearerLookupTable[i])) == 0) |
|
1709 { |
|
1710 thisBearer = static_cast<TBearers>(i); |
|
1711 __FLOG_STATIC1(KLogComponent, KCDInfoLog, |
|
1712 _L("CCDMapperIAPRecord::NewBearerTypeRecordL() - Found bearer-type <%d>"), |
|
1713 thisBearer); |
|
1714 found = ETrue; |
|
1715 break; |
|
1716 } |
|
1717 } |
|
1718 } |
|
1719 |
|
1720 |
|
1721 if (!found) |
|
1722 { |
|
1723 return pBearerType; |
|
1724 } |
|
1725 |
|
1726 |
|
1727 CCDBearerRecordBase* pBearer = static_cast<CCDBearerRecordBase*>(CCDRecordBase::RecordFactoryL(KBearerIdLookupTable[thisBearer])); |
|
1728 CleanupStack::PushL(pBearer); |
|
1729 |
|
1730 __FLOG_STATIC2(KLogComponent, KCDInfoLog, |
|
1731 _L("CCDMapperIAPRecord::NewBearerTypeRecordL() - Loading bearer record <%d>, for bearer-type <%d>"), |
|
1732 static_cast<TInt>(aIAPRecord.iBearer), |
|
1733 thisBearer); |
|
1734 |
|
1735 pBearer->SetRecordId(aIAPRecord.iBearer); |
|
1736 pBearer->LoadL(aSessionOwner); |
|
1737 |
|
1738 |
|
1739 pBearerType = static_cast<CCDBearerTypeRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdBearerTypeRecord)); |
|
1740 CleanupStack::PushL(pBearerType); |
|
1741 |
|
1742 |
|
1743 TBool keepGoing = ETrue; |
|
1744 |
|
1745 TBuf<KMaxName> thisNifName; |
|
1746 |
|
1747 // Get the bearer's nif name (shouldn't the NifName be a member of the base class?, oh well, too late now). |
|
1748 // Requires horrible switch statement. |
|
1749 // |
|
1750 switch (thisBearer) |
|
1751 { |
|
1752 case EModemBearer: |
|
1753 { |
|
1754 // The usual modem bearer case is: |
|
1755 // |
|
1756 // ModemBearer[IAP.iBearer]->iNifName |
|
1757 // |
|
1758 // SPUD is an exception (if ModemBearer[IAP.iBearer]->iNifName == "SPUD"): |
|
1759 // |
|
1760 // OutgoingGPRS[IAP.Service]->iIfParame |
|
1761 // Extract the nif's name from the resultant string, of form "lowernif=xxxxx" |
|
1762 |
|
1763 |
|
1764 TPtrC nifName(static_cast<CCDModemBearerRecord*>(pBearer)->iNifName); |
|
1765 |
|
1766 if (nifName.CompareF(KSpudNif) == 0) |
|
1767 { |
|
1768 // Do "special" SPUD related processing to find the lowernif from the OutgoingGPRS table. |
|
1769 |
|
1770 TPtrC serviceType(aIAPRecord.iServiceType); |
|
1771 |
|
1772 // Check the expected service type |
|
1773 // |
|
1774 if (serviceType.CompareF(KOutgoingGPRS) == 0) |
|
1775 { |
|
1776 CCDOutgoingGprsRecord* pOutgoingGprs = |
|
1777 static_cast<CCDOutgoingGprsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdOutgoingGprsRecord)); |
|
1778 CleanupStack::PushL(pOutgoingGprs); |
|
1779 |
|
1780 // Load the associated OutgoingGPRS record. |
|
1781 |
|
1782 pOutgoingGprs->SetRecordId(aIAPRecord.iService); |
|
1783 pOutgoingGprs->LoadL(aSessionOwner); |
|
1784 |
|
1785 // Get the 'iGPRSIfParams' value. |
|
1786 |
|
1787 TPtrC gprsIfParams(static_cast<CCDOutgoingGprsRecord*>(pOutgoingGprs)->iGPRSIfParams); |
|
1788 |
|
1789 // And search for the key and its value (which should be the Nif we want) |
|
1790 // |
|
1791 TInt lowerNifIndex = gprsIfParams.FindF(KLowerNifKey); |
|
1792 if (lowerNifIndex >= 0) |
|
1793 { |
|
1794 TPtrC lowerNifName = gprsIfParams.Mid(lowerNifIndex + KLowerNifKey().Length()); |
|
1795 |
|
1796 // Cannot work out how to use the iRecordName member itself to call Format() on. |
|
1797 |
|
1798 thisNifName.Format(KSpudNifPrefix, &lowerNifName); |
|
1799 } |
|
1800 else |
|
1801 { |
|
1802 __FLOG_STATIC1(KLogComponent, KCDErrLog, |
|
1803 _L("CCDMapperIAPRecord::NewBearerTypeRecordL() - Failed to find \"lowernif=\" for IAP record <%d>"), |
|
1804 aIAPRecord.RecordId()); |
|
1805 keepGoing = EFalse; |
|
1806 } |
|
1807 |
|
1808 CleanupStack::PopAndDestroy(pOutgoingGprs); |
|
1809 } |
|
1810 else |
|
1811 { |
|
1812 __FLOG_STATIC1(KLogComponent, KCDErrLog, |
|
1813 _L("CCDMapperIAPRecord::NewBearerTypeRecordL() - unexpected SPUD bearer for IAP record <%d>"), |
|
1814 aIAPRecord.RecordId()); |
|
1815 keepGoing = EFalse; |
|
1816 } |
|
1817 } |
|
1818 else |
|
1819 { |
|
1820 // That's easy |
|
1821 thisNifName = nifName; |
|
1822 } |
|
1823 } |
|
1824 break; |
|
1825 |
|
1826 case ELANBearer: |
|
1827 { |
|
1828 TPtrC nifName(static_cast<CCDLANBearerRecord*>(pBearer)->iLanBearerNifName); |
|
1829 thisNifName = nifName; |
|
1830 } |
|
1831 break; |
|
1832 |
|
1833 case EVirtualBearer: |
|
1834 { |
|
1835 TPtrC nifName(static_cast<CCDVirtualBearerRecord*>(pBearer)->iVirtualBearerNifName); |
|
1836 thisNifName = nifName; |
|
1837 } |
|
1838 break; |
|
1839 |
|
1840 default: |
|
1841 keepGoing = EFalse; |
|
1842 break; |
|
1843 } |
|
1844 |
|
1845 |
|
1846 if (keepGoing) |
|
1847 { |
|
1848 __FLOG_STATIC2(KLogComponent, KCDInfoLog, |
|
1849 _L("CCDMapperIAPRecord::NewBearerTypeRecordL() - Looking up data for bearer-type <%S> for IAP <%d>"), |
|
1850 &thisNifName, |
|
1851 aIAPRecord.RecordId()); |
|
1852 |
|
1853 // The letters in the name of the bearer can appear in various cases. therefore |
|
1854 // convert the name of the bearer (however it was found) to lower-case letters. |
|
1855 // |
|
1856 // Note: |
|
1857 // Constraint is that the names of the bearer types in the preface file must also be lower-case. |
|
1858 // |
|
1859 thisNifName.LowerCase(); |
|
1860 pBearerType->iRecordName.SetMaxLengthL(thisNifName.Length()); |
|
1861 pBearerType->iRecordName = thisNifName; |
|
1862 |
|
1863 if (!pBearerType->FindL(aSessionOwner)) |
|
1864 { |
|
1865 __FLOG_STATIC2(KLogComponent, KCDErrLog, |
|
1866 _L("CCDMapperIAPRecord::NewBearerTypeRecordL() - Failed to find bearer-type <%S> for IAP <%d>"), |
|
1867 &thisNifName, |
|
1868 aIAPRecord.RecordId()); |
|
1869 |
|
1870 User::Leave(KErrNotFound); |
|
1871 } |
|
1872 } |
|
1873 |
|
1874 CleanupStack::Pop(pBearerType); |
|
1875 CleanupStack::PopAndDestroy(pBearer); |
|
1876 |
|
1877 return pBearerType; |
|
1878 } // NewBearerTypeRecordL() |
|
1879 |
|
1880 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1881 |
|
1882 |
|
1883 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
1884 |
|
1885 |
|
1886 |
|
1887 //---------- The IPProto AP handler classes ------------- |
|
1888 |
|
1889 /*virtual*/ void CIPProtoAPCreator::DoTheWorkL() |
|
1890 { |
|
1891 CCDConnectionPrefsRecord* ptrConnPref = static_cast<CCDConnectionPrefsRecord*>(&iElement); |
|
1892 |
|
1893 CMDBRecordLink<CCDAccessPointRecord>* apPrioritySelPolFieldToBeModified = |
|
1894 GetTheAPxLinkFromAPPrioritySelPol(iAPSelPolRec, |
|
1895 ptrConnPref->iRanking); |
|
1896 CCDAccessPointRecord* ipprotoAP = NULL; |
|
1897 |
|
1898 TBool modified = EFalse; |
|
1899 TBool isIPProtoAPExisting = EFalse; |
|
1900 |
|
1901 if (ECommDbDialogPrefUnknown == ptrConnPref->iDialogPref || |
|
1902 ECommDbDialogPrefDoNotPrompt== ptrConnPref->iDialogPref) |
|
1903 { |
|
1904 //this is a non prompting connpref rec |
|
1905 isIPProtoAPExisting = CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(iLinkAPTagId, |
|
1906 iSession.iOwner); |
|
1907 } |
|
1908 else |
|
1909 { |
|
1910 //this connpref rec is prompting so we need to consider the cprConfig field of the possibly |
|
1911 //existing IPProtoAP too |
|
1912 isIPProtoAPExisting = CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(iLinkAPTagId, |
|
1913 ptrConnPref->ElementId(), |
|
1914 iSession.iOwner); |
|
1915 } |
|
1916 |
|
1917 if (!isIPProtoAPExisting) |
|
1918 { |
|
1919 //The IPProto AP is not existing yet. Generate one. |
|
1920 ipprotoAP = CommsDatMapperAndValidator::GenerateIPProtoAPL(IPProtoBaseTagId, |
|
1921 iLinkAPTagId, |
|
1922 iSession.iOwner); |
|
1923 |
|
1924 CleanupStack::PushL(ipprotoAP); |
|
1925 |
|
1926 ipprotoAP->StoreL(iSession.iOwner); |
|
1927 |
|
1928 //modified = ETrue; |
|
1929 } |
|
1930 else |
|
1931 { |
|
1932 //The IPProto AP is already exsiting. Use that one. |
|
1933 ipprotoAP = CommsDatMapperAndValidator::LoadTheAPL(iLinkAPTagId, iSession.iOwner); |
|
1934 |
|
1935 CleanupStack::PushL(ipprotoAP); |
|
1936 } |
|
1937 |
|
1938 |
|
1939 if (KCDChangedFlag == (ptrConnPref->iDialogPref.ElementId() & KCDChangedFlag)) |
|
1940 { |
|
1941 /* The dialogPref field has changed -> This means that: |
|
1942 * a) we have to create a 'prompting AP' which means that the AP has to |
|
1943 * contain the full TMDBElement ID of the given connpref record in its' |
|
1944 * CprConfig field (prompting connpref rec). |
|
1945 * b) the CprConfig field has to contain the IAP record number this |
|
1946 * IPProto AP points to (not prompting connpref rec). |
|
1947 */ |
|
1948 TBool isPromptingAPNeeded; |
|
1949 |
|
1950 if (ECommDbDialogPrefUnknown == ptrConnPref->iDialogPref || |
|
1951 ECommDbDialogPrefDoNotPrompt== ptrConnPref->iDialogPref) |
|
1952 { |
|
1953 isPromptingAPNeeded = EFalse; |
|
1954 } |
|
1955 else |
|
1956 { |
|
1957 isPromptingAPNeeded = ETrue; |
|
1958 } |
|
1959 |
|
1960 if (isPromptingAPNeeded) |
|
1961 { |
|
1962 //the cprConfig has to contain the full TMDBElementId of the connpref record |
|
1963 ipprotoAP->iCprConfig = ptrConnPref->ElementId(); |
|
1964 } |
|
1965 else |
|
1966 { |
|
1967 /* the cprConfig field has to contain the IAP record id |
|
1968 * Because this mapping/validation is done from a legacy configuration |
|
1969 * commsdat can assume here that there will be only 3 layers. |
|
1970 * |
|
1971 * The fillowing line says that the IAP pointed by the cprConfig and the |
|
1972 * Link level AP pointed by the customSelectionPolicy field are the same. |
|
1973 */ |
|
1974 ipprotoAP->iCprConfig.SetL(ipprotoAP->iCustomSelectionPolicy); |
|
1975 } |
|
1976 |
|
1977 modified = ETrue; |
|
1978 } |
|
1979 |
|
1980 if (modified) |
|
1981 { |
|
1982 ipprotoAP->ModifyL(iSession.iOwner); |
|
1983 } |
|
1984 |
|
1985 TMDBElementId elemId = ipprotoAP->ElementId(); |
|
1986 elemId &= KCDMaskHideAttrAndRes; |
|
1987 TMDBElementId tableAndRecordBitMask = KCDMaskShowRecordType | KCDMaskShowRecordId; |
|
1988 elemId &= tableAndRecordBitMask; |
|
1989 |
|
1990 //a) update the APPrioritySelPol record to point to the newly creeated AP record |
|
1991 CommsDatMapperAndValidator::ModifyAPPrioritySelPolRecL(apPrioritySelPolFieldToBeModified, |
|
1992 iAPSelPolRec, |
|
1993 elemId); |
|
1994 |
|
1995 |
|
1996 iAPSelPolRec->ModifyL(iSession.iOwner); |
|
1997 |
|
1998 //maintain the link from the IPProto Tier record |
|
1999 if (1 == ptrConnPref->iRanking) |
|
2000 { |
|
2001 CommsDatMapperAndValidator::ModifyDefaultTierRecordL(elemId, iSession.iOwner); |
|
2002 } |
|
2003 |
|
2004 CleanupStack::PopAndDestroy(ipprotoAP); |
|
2005 } |
|
2006 |
|
2007 |
|
2008 |
|
2009 /*virtual*/ void CIPProtoAPModifier::DoTheWorkL() |
|
2010 { |
|
2011 TBool modified = EFalse; |
|
2012 CCDConnectionPrefsRecord* ptrConnPref = static_cast<CCDConnectionPrefsRecord*>(&iElement); |
|
2013 |
|
2014 CMDBRecordLink<CCDAccessPointRecord>* apPrioritySelPolFieldToBeModified = |
|
2015 GetTheAPxLinkFromAPPrioritySelPol(iAPSelPolRec, |
|
2016 ptrConnPref->iRanking); |
|
2017 |
|
2018 CCDAccessPointRecord* apRecordToBeModified = NULL; |
|
2019 |
|
2020 /* At this point we have to check: |
|
2021 * |
|
2022 * Is there any other link to this AP. |
|
2023 * If there is: |
|
2024 * ------------ |
|
2025 * a new AP should be generated and linked from the given |
|
2026 * APPrioritySelPol field |
|
2027 * |
|
2028 * If there isn't: |
|
2029 * --------------- |
|
2030 * Is there any other IPProto AP which contains the given link AP tagId |
|
2031 * in its' customSelPolField? |
|
2032 * If there is: |
|
2033 * No new AP should be generated but the already existing one |
|
2034 * should be used |
|
2035 * The AP which is not used anymore should be deleted |
|
2036 * |
|
2037 * If there isn't |
|
2038 * this means that the given AP can be modified. |
|
2039 */ |
|
2040 if (1 == CommsDatMapperAndValidator::CountReferenceToThisIPProtoAPL(*apPrioritySelPolFieldToBeModified, |
|
2041 iSession.iOwner)) |
|
2042 { |
|
2043 /* There is only 1 reference to this AP. Here the following should be considered: |
|
2044 * If there is already an IPProto AP whith the given link AP tagId value in the customselPol field |
|
2045 * no new AP should be generated but the one should be used, and the old one should be deleted!. |
|
2046 * If there is no AP with the given link AP tagId value in the customselPol field |
|
2047 * a new one should be generated. |
|
2048 */ |
|
2049 |
|
2050 if (!CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(iLinkAPTagId, iSession.iOwner)) |
|
2051 { |
|
2052 //ok, there is no AP with the given customSelPol field |
|
2053 apRecordToBeModified = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
2054 CleanupStack::PushL(apRecordToBeModified); |
|
2055 |
|
2056 apRecordToBeModified->SetElementId(*apPrioritySelPolFieldToBeModified); |
|
2057 |
|
2058 apRecordToBeModified->LoadL(iSession.iOwner); |
|
2059 } |
|
2060 else |
|
2061 { |
|
2062 //there is already an AP with the given customSelPol field |
|
2063 //delete the currently used IPProto AP |
|
2064 apRecordToBeModified = CommsDatMapperAndValidator::LoadTheAPL(iLinkAPTagId, iSession.iOwner); |
|
2065 |
|
2066 CleanupStack::PushL(apRecordToBeModified); |
|
2067 |
|
2068 CCDAccessPointRecord* apRecordToBeDeleted = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
2069 CleanupStack::PushL(apRecordToBeDeleted); |
|
2070 //DeleteL needs the '7F' in the FieldType... |
|
2071 apRecordToBeDeleted->SetElementId(*apPrioritySelPolFieldToBeModified | KCDMaskShowFieldType); |
|
2072 |
|
2073 if (apRecordToBeDeleted->RecordId() != apRecordToBeModified->RecordId()) |
|
2074 { |
|
2075 //we can delete the actual AP... |
|
2076 apRecordToBeDeleted->DeleteL(iSession.iOwner); |
|
2077 |
|
2078 TMDBElementId elemId = apRecordToBeModified->ElementId(); |
|
2079 elemId &= KCDMaskHideAttrAndRes; |
|
2080 TMDBElementId tableAndRecordBitMask = KCDMaskShowRecordType | KCDMaskShowRecordId; |
|
2081 elemId &= tableAndRecordBitMask; |
|
2082 |
|
2083 //update the APPrioritySelPol record to point to the newly creeated AP record |
|
2084 CommsDatMapperAndValidator::ModifyAPPrioritySelPolRecL(apPrioritySelPolFieldToBeModified, |
|
2085 iAPSelPolRec, |
|
2086 elemId); |
|
2087 } |
|
2088 |
|
2089 CleanupStack::PopAndDestroy(apRecordToBeDeleted); |
|
2090 |
|
2091 } |
|
2092 } |
|
2093 else |
|
2094 { |
|
2095 /* There is more than 1 link to the given AP record. |
|
2096 * If we would modify it with the same Link level TagId -> no necessary to do anything... |
|
2097 * This could happen if we processed already the IAPPrioritySelPol record and there |
|
2098 * is a ConnPref record too where the default IAP is the same as in the orig |
|
2099 * IAPPriorioritySelPol record. |
|
2100 * If it's a different Link level TagId -> Can't modify the AP instead create a new one. |
|
2101 */ |
|
2102 |
|
2103 TBool isIPProtoAPExisting = EFalse; |
|
2104 |
|
2105 if (ECommDbDialogPrefUnknown == ptrConnPref->iDialogPref || |
|
2106 ECommDbDialogPrefDoNotPrompt== ptrConnPref->iDialogPref) |
|
2107 { |
|
2108 //this is a non prompting connpref rec |
|
2109 isIPProtoAPExisting = CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(iLinkAPTagId, |
|
2110 iSession.iOwner); |
|
2111 } |
|
2112 else |
|
2113 { |
|
2114 //this connpref rec is prompting so we need to consider the cprConfig field of the possibly |
|
2115 //existing IPProtoAP too |
|
2116 isIPProtoAPExisting = CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(iLinkAPTagId, |
|
2117 ptrConnPref->ElementId(), |
|
2118 iSession.iOwner); |
|
2119 } |
|
2120 |
|
2121 if (isIPProtoAPExisting) |
|
2122 { |
|
2123 //the given IPProto is already existing with the received Link TagId (and cprConfig |
|
2124 //field if the connpref is prompting). Let's use that one |
|
2125 apRecordToBeModified = CommsDatMapperAndValidator::LoadTheAPL(iLinkAPTagId, iSession.iOwner); |
|
2126 |
|
2127 CleanupStack::PushL(apRecordToBeModified); |
|
2128 |
|
2129 } |
|
2130 else |
|
2131 { |
|
2132 apRecordToBeModified = CommsDatMapperAndValidator::GenerateIPProtoAPL(IPProtoBaseTagId, |
|
2133 iLinkAPTagId, |
|
2134 iSession.iOwner); |
|
2135 |
|
2136 CleanupStack::PushL(apRecordToBeModified); |
|
2137 |
|
2138 //save the generated AP record |
|
2139 apRecordToBeModified->StoreL(iSession.iOwner); |
|
2140 } |
|
2141 |
|
2142 TMDBElementId elemId = apRecordToBeModified->ElementId(); |
|
2143 elemId &= KCDMaskHideAttrAndRes; |
|
2144 TMDBElementId tableAndRecordBitMask = KCDMaskShowRecordType | KCDMaskShowRecordId; |
|
2145 elemId &= tableAndRecordBitMask; |
|
2146 |
|
2147 //update the APPrioritySelPol record to point to the newly creeated AP record |
|
2148 CommsDatMapperAndValidator::ModifyAPPrioritySelPolRecL(apPrioritySelPolFieldToBeModified, |
|
2149 iAPSelPolRec, |
|
2150 elemId); |
|
2151 } |
|
2152 |
|
2153 if (0 != apRecordToBeModified->iSelectionPolicy) |
|
2154 //it is possible from the cfg files that the iSelectionPolicy field is used to link to the |
|
2155 //link layer AP. If this is the case it should be 0ed. |
|
2156 { |
|
2157 apRecordToBeModified->iSelectionPolicy.SetL(0); |
|
2158 modified = ETrue; |
|
2159 } |
|
2160 |
|
2161 if (apRecordToBeModified->iCustomSelectionPolicy != iLinkAPTagId) |
|
2162 { |
|
2163 apRecordToBeModified->iCustomSelectionPolicy.SetL(iLinkAPTagId); |
|
2164 apRecordToBeModified->iCprConfig.SetL(iLinkAPTagId); |
|
2165 modified = ETrue; |
|
2166 } |
|
2167 |
|
2168 /* This is just cosmetics here. If we modify the default IPProto AP, which is |
|
2169 * coming from the meshpreface, then the name of the record should be modified. |
|
2170 */ |
|
2171 TPtrC recName(apRecordToBeModified->iRecordName); |
|
2172 if (0 == recName.Compare(KDefaultIPProtoRecName)) |
|
2173 { |
|
2174 //buffer for the record name |
|
2175 TBuf<KMaxName> recordName; |
|
2176 CommsDatMapperAndValidator::GenerateRecordName(recordName, apRecordToBeModified->iRecordTag); |
|
2177 apRecordToBeModified->iRecordName.SetMaxLengthL(recordName.Length()); |
|
2178 apRecordToBeModified->iRecordName = recordName; |
|
2179 modified = ETrue; |
|
2180 } |
|
2181 |
|
2182 if (KCDChangedFlag == (ptrConnPref->iDialogPref.ElementId() & KCDChangedFlag)) |
|
2183 { |
|
2184 /* The dialogPref field has changed -> This means that: |
|
2185 * a) we have to create a 'prompting AP' which means that the AP has to |
|
2186 * contain the full TMDBElement ID of the given connpref record in its' |
|
2187 * CprConfig field (prompting connpref rec). |
|
2188 * b) the CprConfig field has to contain the IAP record number this |
|
2189 * IPProto AP points to (not prompting connpref rec). |
|
2190 */ |
|
2191 TBool isPromptingAPNeeded; |
|
2192 |
|
2193 if (ECommDbDialogPrefUnknown == ptrConnPref->iDialogPref || |
|
2194 ECommDbDialogPrefDoNotPrompt== ptrConnPref->iDialogPref) |
|
2195 { |
|
2196 isPromptingAPNeeded = EFalse; |
|
2197 } |
|
2198 else |
|
2199 { |
|
2200 isPromptingAPNeeded = ETrue; |
|
2201 } |
|
2202 |
|
2203 if (isPromptingAPNeeded) |
|
2204 { |
|
2205 //the cprConfig has to contain the full TMDBElementId of the connpref record |
|
2206 apRecordToBeModified->iCprConfig = ptrConnPref->ElementId(); |
|
2207 } |
|
2208 else |
|
2209 { |
|
2210 /* the cprConfig field has to contain the IAP record id |
|
2211 * Because this mapping/validation is done from a legacy configuration |
|
2212 * commsdat can assume here that there will be only 3 layers. |
|
2213 * |
|
2214 * The following line says that the IAP pointed by the cprConfig and the |
|
2215 * Link level AP pointed by the customSelectionPolicy field are the same. |
|
2216 */ |
|
2217 apRecordToBeModified->iCprConfig.SetL(apRecordToBeModified->iCustomSelectionPolicy); |
|
2218 } |
|
2219 |
|
2220 modified = ETrue; |
|
2221 } |
|
2222 |
|
2223 iAPSelPolRec->ModifyL(iSession.iOwner); |
|
2224 |
|
2225 if (modified) |
|
2226 { |
|
2227 apRecordToBeModified->ModifyL(iSession.iOwner); |
|
2228 } |
|
2229 |
|
2230 //maintain the link from the IPProto Tier record |
|
2231 if (1 == ptrConnPref->iRanking) |
|
2232 { |
|
2233 TMDBElementId elemId = apRecordToBeModified->ElementId(); |
|
2234 elemId &= KCDMaskHideAttrAndRes; |
|
2235 TMDBElementId tableAndRecordBitMask = KCDMaskShowRecordType | KCDMaskShowRecordId; |
|
2236 elemId &= tableAndRecordBitMask; |
|
2237 |
|
2238 CommsDatMapperAndValidator::ModifyDefaultTierRecordL(elemId, iSession.iOwner); |
|
2239 } |
|
2240 |
|
2241 |
|
2242 |
|
2243 /* one last checking: if there is another IPProto AP with the same cusomtSelPol |
|
2244 * and CprConfig fields then only 1 can be in the database the other should be deleted. |
|
2245 */ |
|
2246 if (CommsDatMapperAndValidator::GetNumberOfThisIPProtoAPL(apRecordToBeModified, iSession.iOwner) > 1) |
|
2247 { |
|
2248 //this means that we have 2 IPProto AP with the same CustomSelPol and CprConfig |
|
2249 //fields |
|
2250 |
|
2251 //Correct the links from the defaultTier and APPriotySelPol links |
|
2252 //This is the elementId which will be deleted |
|
2253 CommsDatMapperAndValidator::CorrectLinksL(apRecordToBeModified->ElementId(), iSession.iOwner); |
|
2254 |
|
2255 //delete the AP |
|
2256 apRecordToBeModified->DeleteL(iSession.iOwner); |
|
2257 } |
|
2258 |
|
2259 CleanupStack::PopAndDestroy(apRecordToBeModified); |
|
2260 } |
|
2261 |
|
2262 /*virtual*/ void CIPProtoAPRemover::DoTheWorkL() |
|
2263 { |
|
2264 CCDConnectionPrefsRecord* ptrConnPref = static_cast<CCDConnectionPrefsRecord*>(&iElement); |
|
2265 |
|
2266 |
|
2267 CMDBRecordLink<CCDAccessPointRecord>* apPrioritySelPolFieldToBeModified = |
|
2268 GetTheAPxLinkFromAPPrioritySelPol(iAPSelPolRec, |
|
2269 ptrConnPref->iRanking); |
|
2270 |
|
2271 CCDAccessPointRecord* ipprotoAPRec = NULL; |
|
2272 |
|
2273 |
|
2274 |
|
2275 //if this was a ranking1 AP then the tier record has to be modified too... |
|
2276 if (1 == ptrConnPref->iRanking) |
|
2277 { |
|
2278 /** |
|
2279 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
2280 |
|
2281 The RANK1 connpref record is deleted which means that there is no default legacy path |
|
2282 in the database. In the 399 architecture in this case we create the default IPProto AP |
|
2283 which is in the meshpreface file by default (it's possible that it's overwritten) so |
|
2284 we modify the current AP by not deleting it but modifying it to contain the CCDAccessPointRecord::KNoPolicy value |
|
2285 in its' CustomSelectionPolicy field. |
|
2286 |
|
2287 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
2288 */ |
|
2289 if (1 == CommsDatMapperAndValidator::CountReferenceToThisIPProtoAPL(*apPrioritySelPolFieldToBeModified, |
|
2290 iSession.iOwner)) |
|
2291 { |
|
2292 //ok there is only 1 link to this AP -> we can modify it |
|
2293 |
|
2294 ipprotoAPRec = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
2295 CleanupStack::PushL(ipprotoAPRec); |
|
2296 |
|
2297 ipprotoAPRec->SetRecordId((*apPrioritySelPolFieldToBeModified & KCDMaskShowRecordId) >> 8); |
|
2298 |
|
2299 |
|
2300 ipprotoAPRec->LoadL(iSession.iOwner); |
|
2301 |
|
2302 ipprotoAPRec->iCustomSelectionPolicy = CCDAccessPointRecord::KNoPolicy; |
|
2303 |
|
2304 ipprotoAPRec->iRecordName.SetMaxLengthL(KDefaultIPProtoRecName().Length()); |
|
2305 ipprotoAPRec->iRecordName = KDefaultIPProtoRecName; |
|
2306 |
|
2307 ipprotoAPRec->iCprConfig = 0; |
|
2308 |
|
2309 ipprotoAPRec->ModifyL(iSession.iOwner); |
|
2310 } |
|
2311 else |
|
2312 { |
|
2313 //a new default AP should be generated |
|
2314 ipprotoAPRec = CommsDatMapperAndValidator::GenerateIPProtoAPL(IPProtoBaseTagId, |
|
2315 CCDAccessPointRecord::KNoPolicy, |
|
2316 iSession.iOwner); |
|
2317 |
|
2318 CleanupStack::PushL(ipprotoAPRec); |
|
2319 |
|
2320 ipprotoAPRec->iRecordName.SetMaxLengthL(KDefaultIPProtoRecName().Length()); |
|
2321 ipprotoAPRec->iRecordName = KDefaultIPProtoRecName; |
|
2322 |
|
2323 //save the generated AP record |
|
2324 ipprotoAPRec->StoreL(iSession.iOwner); |
|
2325 |
|
2326 |
|
2327 TMDBElementId elemId = ipprotoAPRec->ElementId(); |
|
2328 elemId &= KCDMaskHideAttrAndRes; |
|
2329 TMDBElementId tableAndRecordBitMask = KCDMaskShowRecordType | KCDMaskShowRecordId; |
|
2330 elemId &= tableAndRecordBitMask; |
|
2331 |
|
2332 //update the APPrioritySelPol record to point to the newly creeated AP record |
|
2333 CommsDatMapperAndValidator::ModifyAPPrioritySelPolRecL(apPrioritySelPolFieldToBeModified, |
|
2334 iAPSelPolRec, |
|
2335 elemId); |
|
2336 |
|
2337 iAPSelPolRec->ModifyL(iSession.iOwner); |
|
2338 |
|
2339 //modify the IPProto tier to point to this new default AP |
|
2340 CMDBRecordLink<CCDAccessPointRecord>* ipProtoDefAccessPoint = new(ELeave)CMDBRecordLink<CCDAccessPointRecord>(KCDTIdDefaultAccessPoint); |
|
2341 CleanupStack::PushL(ipProtoDefAccessPoint); |
|
2342 |
|
2343 TInt ipProtoRecId = CommsDatMapperAndValidator::GetIPProtoTierRecordIdL(iSession.iOwner); |
|
2344 ipProtoDefAccessPoint->SetRecordId(ipProtoRecId); |
|
2345 |
|
2346 *ipProtoDefAccessPoint = elemId; |
|
2347 ipProtoDefAccessPoint->ModifyL(iSession.iOwner); |
|
2348 |
|
2349 CleanupStack::PopAndDestroy(ipProtoDefAccessPoint); |
|
2350 } |
|
2351 //no further modification is needed here... |
|
2352 } |
|
2353 else |
|
2354 { |
|
2355 //RANK2 record is deleted |
|
2356 iAPSelPolRec->iApCount.SetL(1); |
|
2357 |
|
2358 if (1 == CommsDatMapperAndValidator::CountReferenceToThisIPProtoAPL(*apPrioritySelPolFieldToBeModified, |
|
2359 iSession.iOwner)) |
|
2360 { |
|
2361 //ok, there is only 1 link to this AP -> it can be deleted |
|
2362 ipprotoAPRec = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
2363 |
|
2364 CleanupStack::PushL(ipprotoAPRec); |
|
2365 |
|
2366 ipprotoAPRec->SetRecordId((*apPrioritySelPolFieldToBeModified & KCDMaskShowRecordId) >> 8); |
|
2367 |
|
2368 ipprotoAPRec->DeleteL(iSession.iOwner); |
|
2369 } |
|
2370 |
|
2371 //update the APPrioritySelPol record. |
|
2372 *apPrioritySelPolFieldToBeModified = 0; |
|
2373 iAPSelPolRec->ModifyL(iSession.iOwner); |
|
2374 } |
|
2375 |
|
2376 if (ipprotoAPRec) |
|
2377 { |
|
2378 CleanupStack::PopAndDestroy(ipprotoAPRec); |
|
2379 } |
|
2380 } |
|
2381 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
2382 //EOF |