|
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 // Mapping rules for deprecated elements in the comms database schema |
|
15 // All data in file |
|
16 // CONTENTS OF FILE |
|
17 // 1/ Utilities |
|
18 // 2/ CCDMapper Base class implementation |
|
19 // 3/ Mapper classes for individual elements in the database |
|
20 // a) CCDMapperGlobalSettingsRecord |
|
21 // b) CCDMapperIAPPrioritySelectionPolicyRecord |
|
22 // c) CCDMapperAccessPointRecord |
|
23 // MAINTENANCE - some rules may need adding or amending whenever the database schema changes |
|
24 // |
|
25 // |
|
26 |
|
27 /** |
|
28 @file CommsDatMapper.cpp |
|
29 @internalComponent |
|
30 */ |
|
31 |
|
32 |
|
33 #include "CommsDatInternalDefs.h" |
|
34 #include <commsdattypesv1_1.h> |
|
35 #include "CommsDatMapper.h" |
|
36 #include <comms-infras/commsdatschema.h> |
|
37 #include <commsdat.h> |
|
38 |
|
39 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
40 #include <commsdattypesv1_1_partner.h> |
|
41 #include <commsdat_partner.h> |
|
42 #endif |
|
43 |
|
44 using namespace Meta; |
|
45 using namespace CommsDatInternal; |
|
46 using namespace CommsDat; |
|
47 |
|
48 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
49 //anonymous namespace |
|
50 namespace |
|
51 { |
|
52 const TInt NetworkBaseTagId = 10000; |
|
53 } |
|
54 #endif //SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
55 /*************************************************************************************** |
|
56 * 1/ Utilities |
|
57 */ |
|
58 |
|
59 |
|
60 |
|
61 TBool Changed(const CMDBElement& aElement) |
|
62 /* |
|
63 Utility function to check if an element has been changed |
|
64 @internalComponent |
|
65 */ |
|
66 { |
|
67 if ( aElement.ElementId() & KCDChangedFlag ) |
|
68 { |
|
69 return ETrue; |
|
70 } |
|
71 |
|
72 return EFalse; |
|
73 } |
|
74 |
|
75 |
|
76 void Sync(CMDBElement& aElement) |
|
77 /* |
|
78 Utility function to mark an element in sync with Database |
|
79 @internalComponent |
|
80 */ |
|
81 { |
|
82 aElement.SetElementId(aElement.ElementId() & ~KCDChangedFlag); |
|
83 } |
|
84 |
|
85 |
|
86 |
|
87 TInt CCDMapper::FindLinkElementIdL(TInt aVal, TInt aTargetTable) |
|
88 /* |
|
89 utility for mapping link fields - when link fields fixed this will be unnecessary |
|
90 */ { |
|
91 TInt ret(KErrNone); |
|
92 |
|
93 if (KLinkableTag & aVal) |
|
94 { |
|
95 // this is a link by tag so need to do a find for the tag in the target field |
|
96 CMDBField<TUint32>* tagField = new (ELeave) CMDBField<TUint32>(aTargetTable |KCDTIdRecordTag); |
|
97 CleanupStack::PushL(tagField); |
|
98 |
|
99 *tagField = aVal; |
|
100 |
|
101 if (tagField->FindL(iSession.iOwner)) |
|
102 { |
|
103 ret = (tagField->ElementId() | KCDMaskShowRecordTypeAndId); |
|
104 } |
|
105 |
|
106 CleanupStack::PopAndDestroy(tagField); |
|
107 |
|
108 } |
|
109 |
|
110 // add a check for the record id too. |
|
111 |
|
112 // otherwise the value already gives the element id directly |
|
113 |
|
114 return ret; |
|
115 } |
|
116 |
|
117 |
|
118 /**************************************************************************************** |
|
119 * 2/ CCDMapper base class implementation |
|
120 ***************************************************************************************/ |
|
121 |
|
122 CCDMapper::CCDMapper(TMDBElementId aElementId, CMDBElement& aElement,CMDBSessionImpl& aSession |
|
123 ,const TOperation& aOperation) |
|
124 : CMDBRecordBase(aElementId) |
|
125 , iElement(aElement) |
|
126 , iSession(aSession) |
|
127 , iOperation(aOperation) |
|
128 { |
|
129 iSession.iMapping = ETrue; |
|
130 } |
|
131 |
|
132 |
|
133 CCDMapper::~CCDMapper() |
|
134 { |
|
135 iSession.iMapping = EFalse; |
|
136 } |
|
137 |
|
138 |
|
139 |
|
140 CCDMapper* CCDMapper::MaybeCreateMapperLC(CMDBElement& aElement,CMDBSessionImpl& aSession, const TOperation& aOperation) |
|
141 /* |
|
142 Static Factory function. |
|
143 |
|
144 Creates a mapping object of the appropriate type |
|
145 |
|
146 @internalComponent |
|
147 */ |
|
148 { |
|
149 if (aSession.UsingLatestVersion() || aSession.iMapping) |
|
150 { |
|
151 // only map if client has asked to manage deprecated fields |
|
152 // and if no mapping or validation going on already |
|
153 return NULL; |
|
154 } |
|
155 |
|
156 if(CommsDat::CommsDatSchema::IsTable(aElement.ElementId())) |
|
157 { |
|
158 // only need mapper for records and fields, not tables |
|
159 return NULL; |
|
160 } |
|
161 |
|
162 CCDMapper* mapper = NULL; |
|
163 |
|
164 switch((TUint32)aElement.TypeId() & KCDMaskShowRecordType) |
|
165 { |
|
166 |
|
167 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
168 |
|
169 case KCDTIdGlobalSettingsRecord: |
|
170 { |
|
171 mapper = new(ELeave)CCDMapperGlobalSettingsRecord(aElement,aSession, aOperation); |
|
172 break; |
|
173 } |
|
174 |
|
175 case KCDTIdIapPrioritySelectionPolicyRecord: |
|
176 { |
|
177 mapper = new(ELeave)CCDMapperIAPPrioritySelectionPolicyRecord(aElement,aSession, aOperation); |
|
178 break; |
|
179 } |
|
180 |
|
181 case KCDTIdAccessPointRecord: |
|
182 { |
|
183 mapper = new(ELeave)CCDMapperAccessPointRecord(aElement,aSession, aOperation); |
|
184 break; |
|
185 } |
|
186 |
|
187 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
188 |
|
189 default : |
|
190 { |
|
191 // Nothing to do so exit quickly |
|
192 mapper = NULL; |
|
193 } |
|
194 } |
|
195 |
|
196 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
197 |
|
198 if(! mapper) |
|
199 { |
|
200 return NULL; |
|
201 } |
|
202 |
|
203 if (mapper->NeedsMapping(aElement)) |
|
204 { |
|
205 |
|
206 CleanupStack::PushL(mapper); |
|
207 mapper->ConstructL(); |
|
208 } |
|
209 else |
|
210 { |
|
211 delete mapper; |
|
212 mapper = NULL; |
|
213 } |
|
214 |
|
215 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
216 |
|
217 return mapper; |
|
218 } |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 void CCDMapper::ConstructL() |
|
224 /* |
|
225 following a unique set of mapping rules implemented in derived classes and |
|
226 using information from both the input element and the database |
|
227 1/ Set up record id(s) for elements in the map |
|
228 2/ where deprecated elements in the input element (iElement) have values that |
|
229 have been changed by the user, populate the values of the corresponding map element(s) |
|
230 @internalTechnology |
|
231 */ |
|
232 { |
|
233 // Default is nothing to construct |
|
234 return; |
|
235 } |
|
236 |
|
237 void CCDMapper::PrepareToStoreL() |
|
238 { |
|
239 // Default is nothing to prepare |
|
240 return; |
|
241 } |
|
242 |
|
243 |
|
244 //TBool CCDMapper::Mapped(TMDBElementId aElementId) |
|
245 /* |
|
246 Return ETrue if the sub-element (always a field) is mapped. |
|
247 Otherwise return EFalse |
|
248 |
|
249 @internalTechnology |
|
250 */ |
|
251 // { |
|
252 // return aElementId != aElementId; |
|
253 // } |
|
254 |
|
255 |
|
256 void CCDMapper::MapResultsL() |
|
257 /* |
|
258 Set up record id(s) for the map and populate each entry in the map |
|
259 following a unique set of mapping rules (implemented in derived classes) |
|
260 using information from both the input element and the database |
|
261 |
|
262 @internalTechnology |
|
263 */ |
|
264 { |
|
265 // Default is nothing to map |
|
266 return; |
|
267 } |
|
268 |
|
269 /*virtual*/ void CCDMapper::PostMappingsL() |
|
270 /* |
|
271 @internalTechnology |
|
272 */ |
|
273 { |
|
274 // Default is nothing to process... |
|
275 (void)iOperation; //just to bypass the comp. warning |
|
276 return; |
|
277 } |
|
278 |
|
279 /*virtual*/ void CCDMapper::PreMappingsL() |
|
280 /* |
|
281 @internalTechnology |
|
282 */ |
|
283 { |
|
284 // Default is nothing to process... |
|
285 (void)iOperation; //just to bypass the comp. warning |
|
286 return; |
|
287 } |
|
288 |
|
289 /***************************************************************************************** |
|
290 * 3/ MAPPER CLASSES FOR INDIVIDUAL ELEMENTS |
|
291 *****************************************************************************************/ |
|
292 |
|
293 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
294 |
|
295 /************************* 3/ a) Mapper for GlobalSettings Table ************************************ |
|
296 * KCDTIdGlobalSettingsRecord |
|
297 * |
|
298 * These 2 fields are now stored against the Default Tier record in the Tier table |
|
299 * DefaultSnap KCDTIdDefaultSnap CCDGlobalSettingsRecord::iDefaultSnap |
|
300 * PromptUser KCDTIdPromptForSnap CCDGlobalSettingsRecord::iPromptForSnap |
|
301 * |
|
302 * Corresponding fields in the Tier table (KCDTIdTierRecord) are |
|
303 * DefaultSnap KCDTIdDefaultAccessPoint CCDTierRecord::iDefaultAccessPoint |
|
304 * PromptUser KCDTIdPromptUser CCDTierRecord::iPromptUser |
|
305 * |
|
306 * The mapping relies on the presence of the DefaultTier field in the GlobalSettings Table |
|
307 * DefaultTier KCDTIdDefaultTier CCDGlobalSettingsRecord::iDefaultTier |
|
308 * |
|
309 * The DefaultTier must always be present as a real or default value in the GlobalSettings |
|
310 * Table. A preface config file may be the best way to set this value. |
|
311 * |
|
312 * If KCDTIdDefaultTier field is not present in the GlobalSettings Table, |
|
313 * these fields cannot be mapped [They could be set as default values in Template of Tier Table?] |
|
314 */ |
|
315 #define KCDTIdGlobalSettingsRecordMapper 9879 |
|
316 START_ATTRIBUTE_TABLE( CCDMapperGlobalSettingsRecord, KCDTIdGlobalSettingsRecordMapper, KCDTIdGlobalSettingsRecordMapper) |
|
317 X_REGISTER_ATTRIBUTE( CCDMapperGlobalSettingsRecord, iPromptUser, TMDBNum) |
|
318 //X_REGISTER_ATTRIBUTE( CCDMapperGlobalSettingsRecord, iDefaultAccessPoint, TMDBNum) |
|
319 X_REGISTER_ATTRIBUTE( CCDMapperGlobalSettingsRecord, iDefaultAccessPoint, TMDBLinkNum) |
|
320 END_ATTRIBUTE_TABLE() |
|
321 |
|
322 CCDMapperGlobalSettingsRecord::CCDMapperGlobalSettingsRecord(CMDBElement& aElement,CMDBSessionImpl& aSession, const TOperation& aOperation) |
|
323 : CCDMapper(0, aElement,aSession,aOperation), |
|
324 iPromptUser(KCDTIdPromptUser), |
|
325 iDefaultAccessPoint(KCDTIdDefaultAccessPoint) |
|
326 {} |
|
327 |
|
328 |
|
329 void CCDMapperGlobalSettingsRecord::ConstructL() |
|
330 /* |
|
331 Set up record id(s) for elements in the map and populate the values of |
|
332 each each element in the map following a unique set of mapping rules |
|
333 (implemented in derived classes) using information from both the input |
|
334 element and the database |
|
335 |
|
336 * Rules |
|
337 a) find DefaultTier in GlobalSettings record (from inputElement or database) |
|
338 b) use the value to give the record id of the Tier record |
|
339 |
|
340 @internalComponent |
|
341 */ |
|
342 { |
|
343 CMDBRecordLink<CCDTierRecord> *defaultTier = new(ELeave) CMDBRecordLink<CCDTierRecord>(KCDTIdGlobalSettingsRecord | KCDTIdDefaultTier); |
|
344 CleanupStack::PushL(defaultTier); |
|
345 defaultTier->SetRecordId(1); |
|
346 |
|
347 defaultTier->LoadL(iSession.iOwner); |
|
348 |
|
349 if (CommsDat::CommsDatSchema::IsRecord(iElement.ElementId())) |
|
350 { |
|
351 CCDGlobalSettingsRecord& globalSettings = static_cast<CCDGlobalSettingsRecord&>(iElement); |
|
352 |
|
353 if (! globalSettings.iDefaultTier.IsNull()) |
|
354 { |
|
355 defaultTier->SetL(globalSettings.iDefaultTier); |
|
356 } |
|
357 } |
|
358 |
|
359 TMDBElementId targetId = CommsDatSchema::GetLinkIdL(iSession.iOwner, defaultTier->ElementId(), defaultTier->GetL(), KCDTIdTierRecord/*, NULL*/); |
|
360 |
|
361 CleanupStack::PopAndDestroy(defaultTier); |
|
362 |
|
363 SetRecordId(targetId); |
|
364 |
|
365 // Now populate the data from the input element |
|
366 CreateMapL(); |
|
367 } |
|
368 |
|
369 |
|
370 void CCDMapperGlobalSettingsRecord::CreateMapL() |
|
371 /* |
|
372 Populate the values of each each element in the map from data in the input element |
|
373 following a unique set of mapping rules. |
|
374 NB. Should only use data in the input element (iElement), not the database |
|
375 The record ids of the mapping elements have already been set in InitMapL |
|
376 |
|
377 @internalComponent |
|
378 */ |
|
379 { |
|
380 //switch (iElement.TypeId()) |
|
381 switch (iElement.ElementId() & KCDMaskShowType) |
|
382 { |
|
383 |
|
384 case KCDTIdGlobalSettingsRecord | KCDMaskShowFieldType: |
|
385 { |
|
386 CCDGlobalSettingsRecord* globalSettings = static_cast<CCDGlobalSettingsRecord*>(&iElement); |
|
387 |
|
388 if (Changed(globalSettings->iDefaultSnap)) |
|
389 { |
|
390 /* There are cases when the 'DefaultSnap' field in the GS record |
|
391 * is 0 (explicitly). In this case the GS mapper checks wheather |
|
392 * the given field is changed or not (it's changed) BUT during the |
|
393 * STORE operation we don't want to store and map the 0 value because |
|
394 * this would mean to overwrite the default AP field in the NetworkTier, |
|
395 * which is set to a default value form the meshpreface.cfg file. |
|
396 * So the check here checks: |
|
397 * if we are in a STORE operation and the DefualtSNAP field in the GS |
|
398 * record is 0 then we change the field back to the 'unchanged state'.*/ |
|
399 if (0 == globalSettings->iDefaultSnap.GetL() && |
|
400 EStore == iOperation) |
|
401 { |
|
402 //change back the field to the 'unchanged' state |
|
403 iDefaultAccessPoint.SetElementId(iDefaultAccessPoint.ElementId() & ~KCDChangedFlag); |
|
404 } |
|
405 else |
|
406 { |
|
407 //Assuming that the defaultSnap id the Snap config file is an AP record id |
|
408 iDefaultAccessPoint.SetL(KCDTIdAccessPointRecord | (globalSettings->iDefaultSnap << 8)); |
|
409 } |
|
410 } |
|
411 |
|
412 if (Changed(globalSettings->iPromptForSnap)) |
|
413 { |
|
414 iPromptUser.SetL(globalSettings->iPromptForSnap); |
|
415 } |
|
416 |
|
417 break; |
|
418 } |
|
419 //case KCDTIdDefaultAccessPoint : |
|
420 case KCDTIdDefaultSnap : |
|
421 { |
|
422 if (Changed(iElement)) |
|
423 { |
|
424 iDefaultAccessPoint.SetL(*static_cast<CMDBRecordLinkBase*>(&iElement)); |
|
425 } |
|
426 break; |
|
427 } |
|
428 case KCDTIdPromptForSnap : |
|
429 { |
|
430 if (Changed(iElement)) |
|
431 { |
|
432 iPromptUser.SetL(*static_cast<CMDBField<TBool>*>(&iElement)); |
|
433 } |
|
434 break; |
|
435 } |
|
436 default : |
|
437 { |
|
438 ASSERT(KErrNotFound); // hmmm... shouldn't get here. |
|
439 User::Leave(KErrNotFound); |
|
440 } |
|
441 } |
|
442 } |
|
443 |
|
444 /** |
|
445 if the mapped fields are already existing in the Tier record on the Network |
|
446 level, they should be deleted. |
|
447 */ |
|
448 /*virtual*/ void CCDMapperGlobalSettingsRecord::PrepareToStoreL() |
|
449 { |
|
450 //Create the storage for the original GlobalSettings record... |
|
451 iSession.MaybeCreateNodeL(iElement); |
|
452 |
|
453 if (Changed(iPromptUser)) |
|
454 { |
|
455 iPromptUser.SetRecordId(RecordId()); |
|
456 iPromptUser.DeleteL(iSession.iOwner); |
|
457 } |
|
458 |
|
459 if (Changed(iDefaultAccessPoint)) |
|
460 { |
|
461 iDefaultAccessPoint.SetRecordId(RecordId()); |
|
462 iDefaultAccessPoint.DeleteL(iSession.iOwner); |
|
463 } |
|
464 |
|
465 } |
|
466 |
|
467 TBool CCDMapperGlobalSettingsRecord::Mapped(TMDBElementId aElementId) |
|
468 /* |
|
469 Return ETrue for any element that is mapped. |
|
470 |
|
471 @internalComponent |
|
472 */ |
|
473 { |
|
474 //switch(aElementId & KCDMaskShowFieldType) |
|
475 switch(aElementId & KCDMaskShowType) |
|
476 { |
|
477 case KCDTIdDefaultSnap : |
|
478 case KCDTIdPromptForSnap : |
|
479 { |
|
480 return ETrue; |
|
481 } |
|
482 } |
|
483 return EFalse; |
|
484 } |
|
485 |
|
486 TBool CCDMapperGlobalSettingsRecord::NeedsMapping(CMDBElement& aElement) |
|
487 /* |
|
488 Return ETrue for any element that is mapped. |
|
489 |
|
490 @internalComponent |
|
491 */ |
|
492 { |
|
493 if(CommsDat::CommsDatSchema::IsRecord(iElement.ElementId())) |
|
494 { |
|
495 //this is a record mapping and the session used is not the latest. So let's have a mapper... |
|
496 /*CCDGlobalSettingsRecord& globalSettings = static_cast<CCDGlobalSettingsRecord&>(iElement); |
|
497 |
|
498 if (Changed(globalSettings.iDefaultSnap) || |
|
499 Changed(globalSettings.iPromptForSnap) ) |
|
500 { |
|
501 return ETrue; |
|
502 }*/ |
|
503 return ETrue; |
|
504 } |
|
505 |
|
506 return Mapped(aElement.ElementId()); |
|
507 } |
|
508 |
|
509 |
|
510 void CCDMapperGlobalSettingsRecord::MapResultsL() |
|
511 /* |
|
512 Map results to original element |
|
513 |
|
514 @internalComponent |
|
515 */ |
|
516 { |
|
517 //switch (iElement.TypeId()) |
|
518 switch (iElement.ElementId() & KCDMaskShowType) |
|
519 { |
|
520 |
|
521 case KCDTIdGlobalSettingsRecord | KCDMaskShowFieldType: |
|
522 { |
|
523 CCDGlobalSettingsRecord* globalSettings = static_cast<CCDGlobalSettingsRecord*>(&iElement); |
|
524 |
|
525 globalSettings->iDefaultSnap.SetL(iDefaultAccessPoint); |
|
526 //give back just the record number of the linked AP - as in the good old days... |
|
527 CMDBRecordLink<CCDAccessPointRecord>* defaultSnap = static_cast<CMDBRecordLink<CCDAccessPointRecord>*>(&(globalSettings->iDefaultSnap)); |
|
528 *defaultSnap = (*defaultSnap & KCDMaskShowRecordId) >> 8; |
|
529 Sync(globalSettings->iDefaultSnap); |
|
530 |
|
531 globalSettings->iPromptForSnap.SetL(iPromptUser); |
|
532 Sync(globalSettings->iPromptForSnap); |
|
533 |
|
534 break; |
|
535 } |
|
536 case KCDTIdDefaultSnap : |
|
537 |
|
538 { |
|
539 //CMDBField<TInt>* defaultSnap = static_cast<CMDBField<TInt>*>(&iElement); |
|
540 CMDBRecordLink<CCDAccessPointRecord>* defaultSnap = static_cast<CMDBRecordLink<CCDAccessPointRecord>*>(&iElement); |
|
541 defaultSnap->SetL(iDefaultAccessPoint); |
|
542 //give back just the record number of the linked AP - as in the good old days... |
|
543 *defaultSnap = (*defaultSnap & KCDMaskShowRecordId) >> 8; |
|
544 Sync(*defaultSnap); |
|
545 break; |
|
546 } |
|
547 case KCDTIdPromptForSnap : |
|
548 { |
|
549 CMDBField<TBool>* promptUser = static_cast<CMDBField<TBool>*>(&iElement); |
|
550 promptUser->SetL(iPromptUser); |
|
551 Sync(*promptUser); |
|
552 break; |
|
553 } |
|
554 default : |
|
555 { |
|
556 ASSERT(KErrNotFound); // hmmm... shouldn't get here. |
|
557 User::Leave(KErrNotFound); |
|
558 } |
|
559 } |
|
560 } |
|
561 |
|
562 |
|
563 /************************* Mapper for IAPSelection Table ************************************** |
|
564 * KCDTIdIapPrioritySelectionPolicyRecord CCDIAPPrioritySelectionPolicyRecord |
|
565 * |
|
566 * The IAP Selection table is deprecated and completely replaced by the APSelectionTable, |
|
567 * |
|
568 * KCDTIdApPrioritySelectionPolicyRecord CCDIAPPrioritySelectionPolicyRecord |
|
569 * |
|
570 * As IAPs map directly to APs, the IAP Selection Table that links to IAPs can map directly to |
|
571 * an AP selecton Table that points to APs that each map to a single IAP |
|
572 * |
|
573 * The mapping can be very simple because the record id, name, tag and so on can be identical |
|
574 */ |
|
575 |
|
576 #define KCDTIdIapPrioritySelectionPolicyRecordMapper 9880 |
|
577 START_ATTRIBUTE_TABLE( CCDMapperIAPPrioritySelectionPolicyRecord, KCDTIdIapPrioritySelectionPolicyRecordMapper, KCDTIdIapPrioritySelectionPolicyRecordMapper) |
|
578 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp1, TMDBLinkNum) |
|
579 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp2, TMDBLinkNum) |
|
580 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp3, TMDBLinkNum) |
|
581 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp4, TMDBLinkNum) |
|
582 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp5, TMDBLinkNum) |
|
583 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp6, TMDBLinkNum) |
|
584 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp7, TMDBLinkNum) |
|
585 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp8, TMDBLinkNum) |
|
586 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp9, TMDBLinkNum) |
|
587 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp10, TMDBLinkNum) |
|
588 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp11, TMDBLinkNum) |
|
589 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp12, TMDBLinkNum) |
|
590 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp13, TMDBLinkNum) |
|
591 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp14, TMDBLinkNum) |
|
592 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iAp15, TMDBLinkNum) |
|
593 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iApCount, TMDBNum) |
|
594 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iRecordTag, TMDBNum) |
|
595 X_REGISTER_ATTRIBUTE( CCDMapperIAPPrioritySelectionPolicyRecord, iRecordName, TMDBText) |
|
596 END_ATTRIBUTE_TABLE() |
|
597 |
|
598 CCDMapperIAPPrioritySelectionPolicyRecord::CCDMapperIAPPrioritySelectionPolicyRecord(CMDBElement& aElement,CMDBSessionImpl& aSession, const TOperation& aOperation) |
|
599 : CCDMapper(KCDTIdApPrioritySelectionPolicyRecord | (aElement.ElementId() & KCDMaskShowRecordId), aElement, aSession, aOperation), |
|
600 iAp1(KCDTIdAp1), |
|
601 iAp2(KCDTIdAp2), |
|
602 iAp3(KCDTIdAp3), |
|
603 iAp4(KCDTIdAp4), |
|
604 iAp5(KCDTIdAp5), |
|
605 iAp6(KCDTIdAp6), |
|
606 iAp7(KCDTIdAp7), |
|
607 iAp8(KCDTIdAp8), |
|
608 iAp9(KCDTIdAp9), |
|
609 iAp10(KCDTIdAp10), |
|
610 iAp11(KCDTIdAp11), |
|
611 iAp12(KCDTIdAp12), |
|
612 iAp13(KCDTIdAp13), |
|
613 iAp14(KCDTIdAp14), |
|
614 iAp15(KCDTIdAp15), |
|
615 iApCount(KCDTIdApCount), |
|
616 iRecordTag(KCDTIdRecordTag | KCDTIdApPrioritySelectionPolicyRecord), |
|
617 iRecordName(KCDTIdRecordName | KCDTIdApPrioritySelectionPolicyRecord) |
|
618 { |
|
619 //Check whether the original record is set as a 'KCDNewRecordRequest'... |
|
620 if (CommsDatSchema::IsNewRecordRequest(iElement.ElementId())) |
|
621 { |
|
622 SetRecordId(KCDNewRecordRequest); |
|
623 } |
|
624 } |
|
625 |
|
626 CCDMapperIAPPrioritySelectionPolicyRecord::~CCDMapperIAPPrioritySelectionPolicyRecord() |
|
627 { |
|
628 delete origMappedDataInDB; |
|
629 } |
|
630 |
|
631 void CCDMapperIAPPrioritySelectionPolicyRecord::ConstructL() |
|
632 /* |
|
633 Iterate through the mapper element and populate each entry |
|
634 following a unique set of mapping rules. |
|
635 The element is populated by information from both the input element and the database |
|
636 ConstructL is performed on data input and retrieval. Mustn't include calls specific to only one or the other |
|
637 @internalComponent |
|
638 */ |
|
639 { |
|
640 switch (iElement.TypeId()) |
|
641 { |
|
642 case KCDTIdRecordTag : |
|
643 { |
|
644 if (Changed(iElement)) |
|
645 { |
|
646 iRecordTag.SetL(*static_cast<CMDBField<TInt>*>(&iElement)); |
|
647 } |
|
648 break; |
|
649 } |
|
650 case KCDTIdRecordName : |
|
651 { |
|
652 if (Changed(iElement)) |
|
653 { |
|
654 iRecordName.SetL(*static_cast<CMDBField<TDesC>*>(&iElement)); |
|
655 } |
|
656 break; |
|
657 } |
|
658 case KCDTIdIapCount : |
|
659 { |
|
660 if (Changed(iElement)) |
|
661 { |
|
662 iApCount.SetL(*static_cast<CMDBField<TInt>*>(&iElement)); |
|
663 } |
|
664 break; |
|
665 } |
|
666 |
|
667 case KCDTIdIapPrioritySelectionPolicyRecord | KCDMaskShowFieldType: |
|
668 { |
|
669 |
|
670 // NB. This function relies on APs being already present |
|
671 |
|
672 //CMDBElement& thisElement = static_cast<CMDBElement&>(*this); |
|
673 |
|
674 CCDIAPPrioritySelectionPolicyRecord& inputElement = static_cast<CCDIAPPrioritySelectionPolicyRecord&>(iElement); |
|
675 |
|
676 if (Changed(inputElement.iRecordTag)) |
|
677 { |
|
678 iRecordTag.SetL(inputElement.iRecordTag); |
|
679 } |
|
680 if (Changed(inputElement.iRecordName)) |
|
681 { |
|
682 iRecordName.SetL(inputElement.iRecordName); |
|
683 } |
|
684 if (Changed(inputElement.iIapCount)) |
|
685 { |
|
686 iApCount.SetL(inputElement.iIapCount); |
|
687 } |
|
688 |
|
689 // as every other field is the same type and the mapping rule is identical for each |
|
690 // and mapping is 1:1, just iterate through the fields and map each one |
|
691 TInt fieldCounter(15); // only need to map this many fields |
|
692 |
|
693 TMetaVTableIterator mapperAttribIter(this); |
|
694 SVDataTableEntry const* mapperEntry = NULL; |
|
695 |
|
696 TMetaVTableIterator inputAttribIter(&iElement); |
|
697 SVDataTableEntry const* inputEntry = NULL; |
|
698 |
|
699 // NB this only works in this case because entries map exactly.... |
|
700 while ( (mapperEntry = mapperAttribIter++) != NULL && |
|
701 (inputEntry = inputAttribIter++) != NULL && |
|
702 fieldCounter-- > 0 ) |
|
703 { |
|
704 CMDBField<TUint32>* inputFieldPtr = reinterpret_cast<CMDBField<TUint32>*>(iElement.GetAttribPtr(inputEntry->iOffset)); |
|
705 //CMDBRecordLink<CCDIAPRecord>* inputFieldPtr = reinterpret_cast<CMDBRecordLink<CCDIAPRecord>*>(GetAttribPtr(mapperEntry->iOffset)); |
|
706 //if (inputFieldPtr && Changed(*inputFieldPtr) ) |
|
707 //we need to check the changed flag too -> somebody changes a link to 0... |
|
708 if (inputFieldPtr/* && ((*inputFieldPtr != NULL) || Changed(*inputFieldPtr)) */) |
|
709 { |
|
710 CMDBRecordLink<CCDAccessPointRecord>* mapperFieldPtr = reinterpret_cast<CMDBRecordLink<CCDAccessPointRecord>*>(GetAttribPtr(mapperEntry->iOffset)); |
|
711 if (mapperFieldPtr) |
|
712 { |
|
713 if ( ( (*inputFieldPtr) & KCDMaskShowType ) == 0 && |
|
714 ( (*inputFieldPtr) & KLinkableTag ) == 0 ) |
|
715 //there is only a number for the IAP link in the table... |
|
716 { |
|
717 if (*inputFieldPtr == 0) |
|
718 { |
|
719 //special case, the link is 0 |
|
720 mapperFieldPtr->SetL(*inputFieldPtr); |
|
721 |
|
722 if (!Changed(*inputFieldPtr)) |
|
723 { |
|
724 //this means that we have to remove the changed flag from our mapped field |
|
725 //because orginally no value was set for the input field that's why it's 0. |
|
726 mapperFieldPtr->SetElementId(mapperFieldPtr->ElementId() & ~KCDChangedFlag); |
|
727 } |
|
728 } |
|
729 else |
|
730 { |
|
731 mapperFieldPtr->SetL(*inputFieldPtr | KLinkableTag); |
|
732 } |
|
733 } |
|
734 else |
|
735 //the link is correctly set: |
|
736 //it's in Link.<TableName>.<TagId> OR |
|
737 // <TableName>.<RecordId> format. |
|
738 { |
|
739 /*IMPORTANT: this code will work ONLY if the linking in the original |
|
740 IAPPrioritySelectionPolicyTable is done by record ID. |
|
741 |
|
742 If the linking is by TagId then a FindL is needed here...*/ |
|
743 if (!Changed(*inputFieldPtr)) |
|
744 { |
|
745 //This means that there is a link field in the IAPPrioritySelPol record where |
|
746 //the link field is correctly set but is't not changed. This means that this field |
|
747 //is already stored in the DB. So we can try to read the already mapped element. |
|
748 mapperFieldPtr->SetRecordId(iElement.RecordId()); |
|
749 TRAPD(err, mapperFieldPtr->LoadL(iSession.iOwner)); |
|
750 if (KErrNone != err) |
|
751 { |
|
752 //the field is not in the database. Is the client playing with us?? |
|
753 TUint field = *inputFieldPtr & KCDMaskShowRecordId; |
|
754 |
|
755 mapperFieldPtr->SetL( (field >> 8) | KLinkableTag); |
|
756 } |
|
757 } |
|
758 else |
|
759 { |
|
760 //this is a modified field |
|
761 TUint field = *inputFieldPtr & KCDMaskShowRecordId; |
|
762 |
|
763 mapperFieldPtr->SetL( (field >> 8) | KLinkableTag); |
|
764 } |
|
765 } |
|
766 } |
|
767 } |
|
768 } |
|
769 break; |
|
770 } |
|
771 default: |
|
772 { |
|
773 //find out which field is used in the IAPPriorityselPol record |
|
774 CCDIAPPrioritySelectionPolicyRecord* iapPriorSelPol = static_cast<CCDIAPPrioritySelectionPolicyRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdIapPrioritySelectionPolicyRecord)); |
|
775 CleanupStack::PushL(iapPriorSelPol); |
|
776 |
|
777 TInt fieldCounter(15); // only need to map this many fields |
|
778 |
|
779 TMetaVTableIterator mapperAttribIter(this); |
|
780 SVDataTableEntry const* mapperEntry = NULL; |
|
781 |
|
782 TMetaVTableIterator inputAttribIter(iapPriorSelPol); |
|
783 SVDataTableEntry const* inputEntry = NULL; |
|
784 |
|
785 CMDBField<TUint32>* origInputFieldPtr = static_cast<CMDBField<TUint32>*>(&iElement); |
|
786 |
|
787 // NB this only works in this case because entries map exactly.... |
|
788 while ( (mapperEntry = mapperAttribIter++) != NULL && |
|
789 (inputEntry = inputAttribIter++) != NULL && |
|
790 fieldCounter-- > 0 ) |
|
791 { |
|
792 CMDBField<TUint32>* inputFieldPtr = reinterpret_cast<CMDBField<TUint32>*>(iapPriorSelPol->GetAttribPtr(inputEntry->iOffset)); |
|
793 |
|
794 TMDBElementId filteredOrigInputElemId = origInputFieldPtr->ElementId() & KCDMaskShowType; |
|
795 |
|
796 if ( inputFieldPtr && |
|
797 inputFieldPtr->ElementId() == filteredOrigInputElemId ) |
|
798 { |
|
799 CMDBRecordLink<CCDAccessPointRecord>* mapperFieldPtr = reinterpret_cast<CMDBRecordLink<CCDAccessPointRecord>*>(GetAttribPtr(mapperEntry->iOffset)); |
|
800 if (mapperFieldPtr) |
|
801 { |
|
802 if ( ( (*origInputFieldPtr) & KCDMaskShowType ) == 0 && |
|
803 ( (*origInputFieldPtr) & KLinkableTag ) == 0 ) |
|
804 //there is only a number for the IAP link in the table... |
|
805 { |
|
806 if (*origInputFieldPtr == 0) |
|
807 { |
|
808 //special case, the link is 0 |
|
809 mapperFieldPtr->SetL(*origInputFieldPtr); |
|
810 |
|
811 if (!Changed(*origInputFieldPtr)) |
|
812 { |
|
813 //this means that we have to remove the changed flag from our mapped field |
|
814 //because orginally no value was set for the input field that's why it's 0. |
|
815 mapperFieldPtr->SetElementId(mapperFieldPtr->ElementId() & ~KCDChangedFlag); |
|
816 } |
|
817 } |
|
818 else |
|
819 { |
|
820 mapperFieldPtr->SetL(*origInputFieldPtr | KLinkableTag); |
|
821 } |
|
822 } |
|
823 else |
|
824 //the link is correctly set: |
|
825 //it's in Link.<TableName>.<TagId> OR |
|
826 // <TableName>.<RecordId> format. |
|
827 { |
|
828 /*IMPORTANT: this code will work ONLY if the linking in the original |
|
829 IAPPrioritySelectionPolicyTable is done by record ID. |
|
830 |
|
831 If the linking is by TagId then a FindL is needed here...*/ |
|
832 if (!Changed(*origInputFieldPtr)) |
|
833 { |
|
834 //This means that there is a link field in the IAPPrioritySelPol record where |
|
835 //the link field is correctly set but is't not changed. This means that this field |
|
836 //is already stored in the DB. So we can try to read the already mapped element. |
|
837 mapperFieldPtr->SetRecordId(iElement.RecordId()); |
|
838 TRAPD(err, mapperFieldPtr->LoadL(iSession.iOwner)); |
|
839 if (KErrNone != err) |
|
840 { |
|
841 //the field is not in the database. Is the client playing with us?? |
|
842 TUint field = *origInputFieldPtr & KCDMaskShowRecordId; |
|
843 |
|
844 mapperFieldPtr->SetL( (field >> 8) | KLinkableTag); |
|
845 } |
|
846 } |
|
847 else |
|
848 { |
|
849 //this is a modified field |
|
850 TUint field = *origInputFieldPtr & KCDMaskShowRecordId; |
|
851 if (field) |
|
852 { |
|
853 mapperFieldPtr->SetL( (field >> 8) | KLinkableTag); |
|
854 } |
|
855 else |
|
856 { |
|
857 mapperFieldPtr->SetL(0); |
|
858 } |
|
859 } |
|
860 } |
|
861 } |
|
862 } |
|
863 } |
|
864 CleanupStack::PopAndDestroy(iapPriorSelPol); |
|
865 break; |
|
866 } |
|
867 } |
|
868 } |
|
869 |
|
870 void CCDMapperIAPPrioritySelectionPolicyRecord::PreMappingsL() |
|
871 { |
|
872 if ( KCDTIdRecordTag != iElement.TypeId() && |
|
873 KCDTIdRecordName != iElement.TypeId() && |
|
874 KCDTIdIapCount != iElement.TypeId() ) |
|
875 { |
|
876 if (EFind == iOperation) |
|
877 { |
|
878 //we don't know the elementId of the orig container so we can't call LoadL |
|
879 //from the input value we can find the link level AP. Following the link |
|
880 //backwards we can find the IPProto level AP. |
|
881 //1. find the already changed element in the mapper object |
|
882 CMDBRecordLink<CCDAccessPointRecord>* apXLink = &(this->iAp1); |
|
883 for (TInt i = 1; i<= MaxLinkCount; ++i) |
|
884 { |
|
885 if (Changed(*apXLink)) |
|
886 { |
|
887 //this is the changed element |
|
888 *apXLink = CommsDatSchema::GetLinkIdL(iSession.iOwner, apXLink->ElementId(), *apXLink, 0); |
|
889 |
|
890 //at this point we know that what is the link level AP which is the pair of the IAP given as |
|
891 //a value in the IAPPrioritySelPol link. Let's find the IPProto level AP which this link level |
|
892 //AP is linking from. |
|
893 CMDBField<TInt>* linkLevelAPTagId = new(ELeave) CMDBField<TInt>(*apXLink | KCDTIdRecordTag); |
|
894 CleanupStack::PushL(linkLevelAPTagId); |
|
895 |
|
896 linkLevelAPTagId->SetRecordId((*apXLink & KCDMaskShowRecordId) >> 8); |
|
897 linkLevelAPTagId->LoadL(iSession.iOwner); |
|
898 |
|
899 CMDBRecordSet<CCDAccessPointRecord>* apRecordSet = new(ELeave) CMDBRecordSet<CCDAccessPointRecord>(KCDTIdAccessPointRecord); |
|
900 CleanupStack::PushL(apRecordSet); |
|
901 |
|
902 CCDAccessPointRecord* apRecord = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord)); |
|
903 CleanupStack::PushL(apRecord); |
|
904 |
|
905 apRecord->iCustomSelectionPolicy.SetL(*linkLevelAPTagId); |
|
906 |
|
907 /* Find all of the AccessPoint records records in the database which have the given |
|
908 * customSelectionPolicy value. It's VERY VERY VERY expensive. However this is the only way we can |
|
909 * search back the links from the link level up to the APPrioritySelPol record. |
|
910 */ |
|
911 apRecordSet->iRecords.AppendL(apRecord); |
|
912 |
|
913 //the ownership is at the recordset already |
|
914 //CleanupStack::PopAndDestroy(apRecord); |
|
915 CleanupStack::Pop(apRecord); |
|
916 |
|
917 TInt recCount = 0; |
|
918 if(apRecordSet->FindL(iSession.iOwner)) |
|
919 { |
|
920 recCount = apRecordSet->iRecords.Count(); |
|
921 } |
|
922 if (recCount > 0) |
|
923 { |
|
924 //we have records with the given customSelectionPolicy value |
|
925 //now have to find that which accesspoint elementID ws set in the given position of the mapper object |
|
926 //originally. |
|
927 |
|
928 CCDAPPrioritySelectionPolicyRecord* probeApPrioritySelPol = static_cast<CCDAPPrioritySelectionPolicyRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdApPrioritySelectionPolicyRecord)); |
|
929 CleanupStack::PushL(probeApPrioritySelPol); |
|
930 |
|
931 //we know that which field was modified originally |
|
932 CMDBRecordLink<CCDAccessPointRecord>* probeField = &(probeApPrioritySelPol->iAp1); |
|
933 |
|
934 //position the field correctly |
|
935 for (TInt j = 1; j < i; ++j) |
|
936 { |
|
937 ++probeField; |
|
938 } |
|
939 |
|
940 TBool found = EFalse; |
|
941 for (TInt j = 0; (j < apRecordSet->iRecords.Count()) && !found; ++j) |
|
942 { |
|
943 probeField->SetL(apRecordSet->iRecords[j]->ElementId()); |
|
944 if (probeApPrioritySelPol->FindL(iSession.iOwner)) |
|
945 { |
|
946 found = ETrue; |
|
947 } |
|
948 } |
|
949 |
|
950 if (found) |
|
951 { |
|
952 //ok, got the correct record |
|
953 apXLink->SetL(*probeField); |
|
954 } |
|
955 else |
|
956 { |
|
957 // no apprioritySelPol record found with the given accesspoint link |
|
958 //User::Leave(KErrNotFound); |
|
959 return; |
|
960 } |
|
961 |
|
962 CleanupStack::PopAndDestroy(probeApPrioritySelPol); |
|
963 } |
|
964 else |
|
965 { |
|
966 //no records were found with the given customSelectionPolicy value |
|
967 //User::Leave(KErrNotFound); |
|
968 return; |
|
969 } |
|
970 |
|
971 CleanupStack::PopAndDestroy(apRecordSet); |
|
972 CleanupStack::PopAndDestroy(linkLevelAPTagId); |
|
973 } |
|
974 ++apXLink; |
|
975 } |
|
976 } |
|
977 else |
|
978 { |
|
979 //load the original mapped element. |
|
980 origMappedDataInDB = static_cast<CCDAPPrioritySelectionPolicyRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdApPrioritySelectionPolicyRecord)); |
|
981 origMappedDataInDB->SetRecordId(iElement.RecordId()); |
|
982 |
|
983 origMappedDataInDB->LoadL(iSession.iOwner); |
|
984 |
|
985 CCDAPPrioritySelectionPolicyRecord* origMappedRecord = static_cast<CCDAPPrioritySelectionPolicyRecord*>(origMappedDataInDB); |
|
986 if ( KCDMaskShowFieldType != (iElement.ElementId() & KCDMaskShowFieldType) ) |
|
987 { |
|
988 //this is a field. What happens here is we fill up the mapper with the mapped object |
|
989 //already stored in the db except that field which is currently changed and already set in the |
|
990 //ConstructL of the mapper. |
|
991 CMDBRecordLink<CCDAccessPointRecord>* origMappedFieldPtr = &(origMappedRecord->iAp1); |
|
992 CMDBRecordLink<CCDAccessPointRecord>* currentMappedFieldPtr = &(this->iAp1); |
|
993 |
|
994 for (TInt i = 1; i <= MaxLinkCount; ++i) |
|
995 { |
|
996 if (!Changed(*currentMappedFieldPtr) && currentMappedFieldPtr->IsNull()) |
|
997 { |
|
998 //it's not the field which has been changed so fill up from the DB |
|
999 currentMappedFieldPtr->SetL(*origMappedFieldPtr); |
|
1000 currentMappedFieldPtr->SetElementId(currentMappedFieldPtr->ElementId() & ~ KCDChangedFlag); |
|
1001 //it's possible that the field value is 0 -> so remove the not_null flag in this case |
|
1002 if (0 == *currentMappedFieldPtr) |
|
1003 { |
|
1004 currentMappedFieldPtr->SetElementId(currentMappedFieldPtr->ElementId() & ~ KCDNotNullFlag); |
|
1005 } |
|
1006 } |
|
1007 else |
|
1008 { |
|
1009 //there is a changed element |
|
1010 if (EDelete == iOperation) |
|
1011 { |
|
1012 //this is a tricky case here. There is a DeleteL call on a field in some IAPPrioritySelPol |
|
1013 //record. Since the mapping is record based we cannot delete the whole record (I mean the |
|
1014 //mapped APPrioritySelPol record) so we have to change the elementId of the mapper object |
|
1015 //because wwithout this the MaybeDeleteNodeL call would delete the whole record and this is |
|
1016 //not we would like to do here... |
|
1017 SetElementId(ElementId() & ~KCDMaskShowFieldType); |
|
1018 SetElementId(ElementId() | (currentMappedFieldPtr->ElementId() & KCDMaskShowFieldType)); |
|
1019 currentMappedFieldPtr->SetElementId(currentMappedFieldPtr->ElementId() | KCDChangedFlag); |
|
1020 } |
|
1021 } |
|
1022 ++origMappedFieldPtr; |
|
1023 ++currentMappedFieldPtr; |
|
1024 } |
|
1025 //ok all of the fields are now ready to handle. Set the count field too |
|
1026 this->iApCount.SetL(origMappedRecord->iApCount); |
|
1027 } |
|
1028 } |
|
1029 } |
|
1030 } |
|
1031 |
|
1032 |
|
1033 TBool CCDMapperIAPPrioritySelectionPolicyRecord::NeedsMapping(CMDBElement& /*aElement*/) |
|
1034 { |
|
1035 return ETrue; |
|
1036 } |
|
1037 |
|
1038 /*virtual*/ void CCDMapperIAPPrioritySelectionPolicyRecord::PrepareToStoreL() |
|
1039 { |
|
1040 CMDBElement& thisElement = static_cast<CMDBElement&>(*this); |
|
1041 |
|
1042 iSession.MaybeCreateNodeL(thisElement); |
|
1043 if (iElement.ElementId() & KCDNewRecordRequest == KCDNewRecordRequest) |
|
1044 { |
|
1045 iElement.SetRecordId(this->RecordId()); |
|
1046 } |
|
1047 } |
|
1048 |
|
1049 TBool CCDMapperIAPPrioritySelectionPolicyRecord::Mapped(TMDBElementId /*aElementId*/) |
|
1050 /* |
|
1051 Return ETrue for any element that is mapped. |
|
1052 |
|
1053 @internalComponent |
|
1054 */ |
|
1055 { |
|
1056 // Every element is mapped in this record so return true |
|
1057 return ETrue; |
|
1058 } |
|
1059 |
|
1060 |
|
1061 void CCDMapperIAPPrioritySelectionPolicyRecord::MapResultsL() |
|
1062 /* |
|
1063 Map results to original element |
|
1064 |
|
1065 @internalComponent |
|
1066 */ |
|
1067 { |
|
1068 switch (iElement.TypeId()) |
|
1069 { |
|
1070 case KCDTIdRecordTag : |
|
1071 { |
|
1072 CMDBField<TUint32>& recordTag = static_cast<CMDBField<TUint32>&>(iElement); |
|
1073 recordTag.SetL(iRecordTag); |
|
1074 Sync(recordTag); |
|
1075 break; |
|
1076 } |
|
1077 case KCDTIdRecordName : |
|
1078 { |
|
1079 CMDBField<TDesC>& recordName = static_cast<CMDBField<TDesC>&>(iElement); |
|
1080 recordName.SetL(iRecordName); |
|
1081 Sync(recordName); |
|
1082 break; |
|
1083 } |
|
1084 case KCDTIdIapCount : |
|
1085 { |
|
1086 CMDBField<TUint32>& iapCount = static_cast<CMDBField<TUint32>&>(iElement); |
|
1087 iapCount.SetL(iApCount); |
|
1088 Sync(iapCount); |
|
1089 break; |
|
1090 } |
|
1091 |
|
1092 case KCDTIdIapPrioritySelectionPolicyRecord | KCDMaskShowFieldType: |
|
1093 { |
|
1094 CCDIAPPrioritySelectionPolicyRecord& inputElement = static_cast<CCDIAPPrioritySelectionPolicyRecord&>(iElement); |
|
1095 |
|
1096 inputElement.iRecordTag.SetL(iRecordTag); |
|
1097 Sync(inputElement.iRecordTag); |
|
1098 |
|
1099 inputElement.iRecordName.SetL(iRecordName); |
|
1100 Sync(inputElement.iRecordName); |
|
1101 |
|
1102 inputElement.iIapCount.SetL(iApCount); |
|
1103 Sync(inputElement.iIapCount); |
|
1104 |
|
1105 //NO BREAK HERE - FALL THROUGH TO DEFAULT |
|
1106 } |
|
1107 default : |
|
1108 { |
|
1109 if ( KCDMaskShowFieldType != (iElement.ElementId() & KCDMaskShowFieldType ) ) |
|
1110 //Field mapping |
|
1111 { |
|
1112 const STableLookup* tableInfoPtr = CommsDatSchemaV1_1::iTableLookup; |
|
1113 TMDBElementId origTableId = iElement.ElementId() & KCDMaskShowRecordType; |
|
1114 TInt i = 0; |
|
1115 |
|
1116 while( tableInfoPtr && tableInfoPtr->iTableId != 0 && (tableInfoPtr->iTableId) != origTableId) |
|
1117 { |
|
1118 ++i; |
|
1119 ++tableInfoPtr; |
|
1120 } |
|
1121 |
|
1122 //At this point we know that what is the table of the mapped field. |
|
1123 //Now we should search for the field in the table and get the position of it. |
|
1124 //it is important because as the mapping here is 1:1 this position will be the |
|
1125 //position of the mapped field either. |
|
1126 const CommsDat::SRecordTypeInfo* fieldInfoPtr = CommsDatSchemaV1_1::iTableLookup[i].iFields; |
|
1127 TMDBElementId cleanOrigFieldId = iElement.ElementId() & KCDMaskShowType; |
|
1128 TInt fieldPosition = 0; |
|
1129 |
|
1130 //Skip the tagId and the name fields... |
|
1131 ++fieldInfoPtr; |
|
1132 ++fieldInfoPtr; |
|
1133 |
|
1134 while( fieldInfoPtr && fieldInfoPtr->iTypeId != 0 && (fieldInfoPtr->iTypeId) != cleanOrigFieldId) |
|
1135 { |
|
1136 ++fieldPosition; |
|
1137 ++fieldInfoPtr; |
|
1138 } |
|
1139 |
|
1140 TMetaVTableIterator mapperAttribIter(this); |
|
1141 SVDataTableEntry const* mapperEntry = NULL; |
|
1142 CMDBField<TUint32>* mapperFieldPtr = NULL; |
|
1143 |
|
1144 //just get into the right position with the attribute iterator for the mapper |
|
1145 while ( (mapperEntry = mapperAttribIter++) != NULL && |
|
1146 fieldPosition-- >= 0 ) |
|
1147 { |
|
1148 mapperFieldPtr = reinterpret_cast<CMDBField<TUint32>*>(GetAttribPtr(mapperEntry->iOffset)); |
|
1149 } |
|
1150 |
|
1151 CMDBField<TUint32>* custSelPolOfTheMappedRecord = new(ELeave) CMDBField<TUint32>((*mapperFieldPtr) | KCDTIdCustomSelectionPolicy); |
|
1152 CleanupStack::PushL(custSelPolOfTheMappedRecord); |
|
1153 custSelPolOfTheMappedRecord->LoadL(iSession.iOwner); |
|
1154 |
|
1155 TInt mappedIAPRecId = (*custSelPolOfTheMappedRecord) << 8; |
|
1156 |
|
1157 CleanupStack::PopAndDestroy(custSelPolOfTheMappedRecord); |
|
1158 |
|
1159 CMDBField<TUint32>& mappedField = reinterpret_cast<CMDBField<TUint32>& >(iElement); |
|
1160 mappedField.SetL(KCDTIdIAPRecord | mappedIAPRecId); |
|
1161 Sync(mappedField); |
|
1162 } |
|
1163 else |
|
1164 //Record mapping |
|
1165 { |
|
1166 // as every other field is the same type and the mapping rule is identical for each |
|
1167 // and mapping is 1:1, just iterate through the fields and map each one |
|
1168 TMetaVTableIterator inputAttribIter(&iElement); |
|
1169 SVDataTableEntry const* inputEntry = NULL; |
|
1170 |
|
1171 TMetaVTableIterator mapperAttribIter(this); |
|
1172 SVDataTableEntry const* mapperEntry = NULL; |
|
1173 |
|
1174 TInt fieldCounter(15); // only need to map this many fields (from start of record) |
|
1175 |
|
1176 while ( (mapperEntry = mapperAttribIter++) != NULL && |
|
1177 (inputEntry = inputAttribIter++) != NULL && |
|
1178 fieldCounter-- > 0 ) |
|
1179 { |
|
1180 CMDBField<TUint32>* mapperFieldPtr = reinterpret_cast<CMDBField<TUint32>*>(GetAttribPtr(mapperEntry->iOffset)); |
|
1181 if( mapperFieldPtr ) |
|
1182 /*At this point we already know that what is recordNumber of the MAPPED element. |
|
1183 So all we have to do is to load the mapped element and read its TagId.*/ |
|
1184 { |
|
1185 if ((mapperFieldPtr->ElementId() & KCDNotNullFlag) != 0) |
|
1186 { |
|
1187 if (0 != *mapperFieldPtr) |
|
1188 { |
|
1189 //it's possible that the link value is 0 because there can be holes |
|
1190 //in the record links... |
|
1191 CommsDatMapperAndValidator::TAPTypes apType = CheckLinkLevelAPL(*mapperFieldPtr); |
|
1192 TInt mappedIAPRecId = 0; |
|
1193 |
|
1194 if (CommsDatMapperAndValidator::ELinkLevel == apType) |
|
1195 //this is already a link level AP so the tagId of it can be used as record ID |
|
1196 //for the pointed IAP record |
|
1197 { |
|
1198 CMDBField<TUint32>* tagFieldOfTheMappedRecord = new(ELeave) CMDBField<TUint32>((*mapperFieldPtr) | KCDTIdRecordTag); |
|
1199 CleanupStack::PushL(tagFieldOfTheMappedRecord); |
|
1200 tagFieldOfTheMappedRecord->LoadL(iSession.iOwner); |
|
1201 |
|
1202 mappedIAPRecId = (*tagFieldOfTheMappedRecord) << 8; |
|
1203 |
|
1204 CleanupStack::PopAndDestroy(tagFieldOfTheMappedRecord); |
|
1205 } |
|
1206 else |
|
1207 //the other case is that this is an IPProto level AP (it cannot be network level |
|
1208 //because it is checked when storing the mapped APPrioritySelPol record). |
|
1209 //here we have to read the customSelectionPolicy field of the AP which gives us |
|
1210 //the TagId of the link level AP which the tag id of it is the same as the |
|
1211 //recordId of the mapped IAP recordId. :) |
|
1212 { |
|
1213 CMDBField<TUint32>* custSelPolOfTheMappedRecord = new(ELeave) CMDBField<TUint32>((*mapperFieldPtr) | KCDTIdCustomSelectionPolicy); |
|
1214 CleanupStack::PushL(custSelPolOfTheMappedRecord); |
|
1215 custSelPolOfTheMappedRecord->LoadL(iSession.iOwner); |
|
1216 |
|
1217 mappedIAPRecId = (*custSelPolOfTheMappedRecord) << 8; |
|
1218 |
|
1219 CleanupStack::PopAndDestroy(custSelPolOfTheMappedRecord); |
|
1220 } |
|
1221 |
|
1222 CMDBField<TUint32>* inputFieldPtr = reinterpret_cast<CMDBField<TUint32>*>(iElement.GetAttribPtr(inputEntry->iOffset)); |
|
1223 if (inputFieldPtr) |
|
1224 { |
|
1225 inputFieldPtr->SetL(KCDTIdIAPRecord | mappedIAPRecId); |
|
1226 Sync(*inputFieldPtr); |
|
1227 } |
|
1228 } |
|
1229 } |
|
1230 } |
|
1231 } |
|
1232 } |
|
1233 } |
|
1234 } |
|
1235 } |
|
1236 |
|
1237 //this method compared the current mapped APPrioritySelPol record with the one in the database which is the default |
|
1238 TBool CCDMapperIAPPrioritySelectionPolicyRecord::IsItTheDefaultAPPrioritySelPolRec(/*CCDAPPrioritySelectionPolicyRecord* aDefAPPrioritySelPolRec*/) |
|
1239 { |
|
1240 TInt defSelPolLinkValue = CommsDatMapperAndValidator::GetDefAPPrioritySelPolLinkValueL(iSession.iOwner); |
|
1241 |
|
1242 TInt myId = ElementId() & ~KCDMaskShowFieldType; |
|
1243 |
|
1244 if (defSelPolLinkValue == myId) |
|
1245 { |
|
1246 return ETrue; |
|
1247 } |
|
1248 return EFalse; |
|
1249 } |
|
1250 |
|
1251 /*virtual*/ void CCDMapperIAPPrioritySelectionPolicyRecord::PostMappingsL() |
|
1252 { |
|
1253 if ( KCDTIdRecordTag != iElement.TypeId() && |
|
1254 KCDTIdRecordName != iElement.TypeId() && |
|
1255 KCDTIdIapCount != iElement.TypeId() ) |
|
1256 { |
|
1257 TBool def = IsItTheDefaultAPPrioritySelPolRec(); |
|
1258 CMDBRecordLink<CCDAccessPointRecord>* apXField = &iAp1; |
|
1259 |
|
1260 CCDAPPrioritySelectionPolicyRecord* origMappedRecord = NULL; |
|
1261 CMDBRecordLink<CCDAccessPointRecord>* origApXField = NULL; |
|
1262 |
|
1263 if (origMappedDataInDB) |
|
1264 { |
|
1265 origMappedRecord = static_cast<CCDAPPrioritySelectionPolicyRecord*>(origMappedDataInDB); |
|
1266 origApXField = &(origMappedRecord->iAp1); |
|
1267 } |
|
1268 |
|
1269 TInt lastValidAPLinkNum = 0; |
|
1270 /* |
|
1271 * We have to go through the list because it's possible that the client modified an IAP link in |
|
1272 * the IAPPriorirytSelPol record and didn't update the IAPCount field. This loop here goes through the |
|
1273 * AP links in the mapped APPrioritySelPol table and counts the valid links and updates the APCount field. |
|
1274 * It's important since it's used during the selection. |
|
1275 * we have to go through all of the links because it's possible that there are 'holes' in the links. |
|
1276 * iap1 = valid link |
|
1277 * iap2 = 0 |
|
1278 * iap3 = valid link |
|
1279 * In this special case the apCount will be 3 meaning that there are valid links in the first 3 slots. |
|
1280 */ |
|
1281 for (TInt i = 1; /*(*apXField != NULL) &&*/ (i<=MaxLinkCount); ++i) |
|
1282 { |
|
1283 if ( (EDelete != iOperation) && |
|
1284 (0 != *apXField) ) |
|
1285 { |
|
1286 CommsDatMapperAndValidator::TAPTypes apType; |
|
1287 apType = CheckLinkLevelAPL(*apXField); |
|
1288 |
|
1289 if (CommsDatMapperAndValidator::ELinkLevel == apType) |
|
1290 //The IPProto AP has to be generated... |
|
1291 { |
|
1292 GenerateIPProtoAPL(apXField, i, def); |
|
1293 } |
|
1294 else if (CommsDatMapperAndValidator::EIPProtoLevel == apType) |
|
1295 //this link already points to an IPProto level AP check whether it has the correct linking |
|
1296 //to the link level AP |
|
1297 { |
|
1298 CheckIPProtoAPL(apXField, i, def); |
|
1299 } |
|
1300 else |
|
1301 //hm... Something is really bad here. Leaving... |
|
1302 { |
|
1303 User::Leave(KErrNotFound); |
|
1304 } |
|
1305 |
|
1306 lastValidAPLinkNum = i; |
|
1307 |
|
1308 } |
|
1309 else |
|
1310 { |
|
1311 if (KCDMaskShowFieldType == (ElementId() & KCDMaskShowFieldType)) |
|
1312 { |
|
1313 //the given field is NULL. Is this NULL a result of a modification or was it originally NULL? If it's |
|
1314 //NULL because of a modification (user set the field to 0) this means that we have to delete the IPProto |
|
1315 //level AP linked from the mapped APPrioritySelPol record. |
|
1316 |
|
1317 /* There is a little trick here. If there are 2 APPrioritySelPol records in the DB where |
|
1318 * 1 link in each record is linking against the same IPProto AP then the situation |
|
1319 * can be the following: |
|
1320 * APPrioritySelPolRec_1: |
|
1321 * AP1 = IPProto_link_record1 |
|
1322 * |
|
1323 * APPrioritySelPolRec_2: |
|
1324 * AP1 = IPProto_link_record1 |
|
1325 * |
|
1326 * One APPrioritySelPol record can be already deleted (by the MaybeDeleteNodeL call which was made |
|
1327 * previously to this postmappings call). |
|
1328 * So when the program logic tries to find that how many reference does a given |
|
1329 * IPProto AP have (IPProto_link_record1 in the example above) then it finds that it's only 1 because the |
|
1330 * other record from which it was linked the 2nd time is already deleted. That's why |
|
1331 * we give for the search algorithm the original (already deleted) APPrioritySelPol record. |
|
1332 */ |
|
1333 |
|
1334 if (origApXField && (*origApXField) && origMappedRecord ) |
|
1335 { |
|
1336 //originally this was not NULL. So we have to delete the linked IPProto level AP. |
|
1337 //do a deep copy from the original APPrioritySelPol record |
|
1338 CCDAPPrioritySelectionPolicyRecord* origSelPolRecCopy = static_cast<CCDAPPrioritySelectionPolicyRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdApPrioritySelectionPolicyRecord)); |
|
1339 CleanupStack::PushL(origSelPolRecCopy); |
|
1340 |
|
1341 TMetaVTableIterator inputAttribIter(origMappedRecord); |
|
1342 SVDataTableEntry const* inputEntry = NULL; |
|
1343 |
|
1344 TMetaVTableIterator copiedAttribIter(origSelPolRecCopy); |
|
1345 SVDataTableEntry const* copiedEntry = NULL; |
|
1346 |
|
1347 TInt fieldCounter = CCDAPPrioritySelectionPolicyRecord::EMaxNrOfAps; |
|
1348 |
|
1349 while ( (inputEntry = inputAttribIter++) != NULL && |
|
1350 (copiedEntry = copiedAttribIter++) != NULL && |
|
1351 fieldCounter-- > 0 ) |
|
1352 { |
|
1353 //loop for the fields |
|
1354 CMDBField<TUint32>* inputFieldPtr = reinterpret_cast<CMDBField<TUint32>*>(origMappedRecord->GetAttribPtr(inputEntry->iOffset)); |
|
1355 if ( inputFieldPtr ) |
|
1356 { |
|
1357 CMDBField<TUint32>* copyFieldPtr = reinterpret_cast<CMDBField<TUint32>*>(origSelPolRecCopy->GetAttribPtr(copiedEntry->iOffset)); |
|
1358 copyFieldPtr->SetL(*inputFieldPtr); |
|
1359 } |
|
1360 } |
|
1361 |
|
1362 origSelPolRecCopy->iApCount.SetL(origMappedRecord->iApCount); |
|
1363 |
|
1364 //we transfer the ownership of this pointer!!!!!! |
|
1365 |
|
1366 CleanupStack::Pop(origSelPolRecCopy); |
|
1367 |
|
1368 DeleteIPProtoAPL(origApXField, origSelPolRecCopy); |
|
1369 |
|
1370 lastValidAPLinkNum = ForcedCountAPLinks(); |
|
1371 } |
|
1372 } |
|
1373 else |
|
1374 { |
|
1375 //deleting a field |
|
1376 //in the PreMappings function the elementId of the field to be deleted was changed by turning on the |
|
1377 //changed flag on it. In this step we can exemine this flag. If found the corresponding IPProto level |
|
1378 //AP should be deleted. |
|
1379 if (Changed(*apXField)) |
|
1380 { |
|
1381 DeleteIPProtoAPL(origApXField); |
|
1382 |
|
1383 lastValidAPLinkNum = ForcedCountAPLinks(); |
|
1384 } |
|
1385 } |
|
1386 } |
|
1387 ++apXField; |
|
1388 |
|
1389 if (origMappedRecord) |
|
1390 { |
|
1391 ++origApXField; |
|
1392 } |
|
1393 } |
|
1394 |
|
1395 TBool countChanged = EFalse; |
|
1396 |
|
1397 if (iElement.TypeId() == (KCDTIdIapPrioritySelectionPolicyRecord | KCDMaskShowFieldType)) |
|
1398 { |
|
1399 CCDIAPPrioritySelectionPolicyRecord& inputElement = static_cast<CCDIAPPrioritySelectionPolicyRecord&>(iElement); |
|
1400 if (KCDChangedFlag == ((inputElement.iIapCount).ElementId() & KCDChangedFlag)) |
|
1401 { |
|
1402 //the client has changed the iap count field, don't overwrite it |
|
1403 countChanged = ETrue; |
|
1404 } |
|
1405 } |
|
1406 |
|
1407 if ( ( ( KCDMaskShowFieldType == (ElementId() & KCDMaskShowFieldType) && |
|
1408 EDelete != iOperation ) || |
|
1409 ( 0 != (ElementId() & KCDMaskShowFieldType) ) ) && |
|
1410 static_cast<TInt>(iApCount) != lastValidAPLinkNum && |
|
1411 !countChanged ) |
|
1412 { |
|
1413 // ( if it's not a record delete _OR_ |
|
1414 // it's a simple field operation) _AND_ |
|
1415 // the original link number is not the same as we counted _AND_ |
|
1416 // the user isn't modifying explicitly the link number |
|
1417 //then we update the record count field |
|
1418 iApCount.SetL(lastValidAPLinkNum); |
|
1419 this->ModifyL(iSession.iOwner); |
|
1420 } |
|
1421 |
|
1422 /* if (EDelete != aOperation && |
|
1423 !countChanged && |
|
1424 static_cast<TInt>(iApCount) != lastValidAPLinkNum) |
|
1425 { |
|
1426 //modify the APCount field. It's important since it's used during the selection process in ESock. |
|
1427 iApCount.SetL(lastValidAPLinkNum); |
|
1428 this->ModifyL(iSession.iOwner); |
|
1429 }*/ |
|
1430 |
|
1431 /* final check: |
|
1432 * if the default IAPPrioritySelPol (mapped APPrioritySelPol) OR |
|
1433 * the 1st link form the default IAPPrioritySelPol (mapped APPrioritySelPol) |
|
1434 * was deleted then the default IPProto AP (from the meshpreface file) |
|
1435 * should be linked from the APPrioritySelPol and the IPProto tier records. |
|
1436 */ |
|
1437 if ( (EDelete == iOperation || |
|
1438 0 == iApCount ) && |
|
1439 def && |
|
1440 ( KCDMaskShowFieldType == (ElementId() & KCDMaskShowFieldType) || |
|
1441 KCDTIdAp1 == (ElementId() & KCDMaskShowType) ) ) |
|
1442 { |
|
1443 //generate/link the def IPProto AP |
|
1444 //1. Is DefIPProto AP in the database |
|
1445 |
|
1446 CCDAccessPointRecord* defIpprotoAP = NULL; |
|
1447 |
|
1448 if (CommsDatMapperAndValidator::IsDefIPProtoAPInDB(iSession.iOwner)) |
|
1449 { |
|
1450 //yes, there is -> use it |
|
1451 defIpprotoAP = CommsDatMapperAndValidator::GetTheDefIPProtoAP(iSession.iOwner); |
|
1452 CleanupStack::PushL(defIpprotoAP); |
|
1453 } |
|
1454 else |
|
1455 { |
|
1456 //no there isn't -> generate one |
|
1457 defIpprotoAP = CommsDatMapperAndValidator::GenerateIPProtoAPL(IPProtoBaseTagId, |
|
1458 CCDAccessPointRecord::KNoPolicy, |
|
1459 iSession.iOwner); |
|
1460 CleanupStack::PushL(defIpprotoAP); |
|
1461 |
|
1462 defIpprotoAP->StoreL(iSession.iOwner); |
|
1463 } |
|
1464 |
|
1465 TPtrC recName(defIpprotoAP->iRecordName); |
|
1466 if (0 != recName.Compare(KDefaultIPProtoRecName)) |
|
1467 { |
|
1468 //the name of the selected default IPProto AP is not 'IPProtoDefault'. |
|
1469 defIpprotoAP->iRecordName.SetMaxLengthL(KDefaultIPProtoRecName().Length()); |
|
1470 defIpprotoAP->iRecordName.SetL(KDefaultIPProtoRecName); |
|
1471 |
|
1472 defIpprotoAP->ModifyL(iSession.iOwner); |
|
1473 } |
|
1474 |
|
1475 //2. correct the link in the ipproto Tier record to point to the default IPProto AP |
|
1476 TInt ipproroTierRecId = CommsDatMapperAndValidator::GetIPProtoTierRecordIdL(iSession.iOwner); |
|
1477 |
|
1478 //CMDBRecordLink<CCDAccessPointRecord>* defTierAP = new(ELeave)CMDBRecordLink<CCDAccessPointRecord>(KCDTIdDefaultAccessPoint); |
|
1479 CMDBField<TInt>* defTierAP = new(ELeave)CMDBField<TInt>(KCDTIdDefaultAccessPoint); |
|
1480 CleanupStack::PushL(defTierAP); |
|
1481 |
|
1482 defTierAP->SetRecordId(ipproroTierRecId); |
|
1483 defTierAP->LoadL(iSession.iOwner); |
|
1484 |
|
1485 TMDBElementId elemId = defIpprotoAP->ElementId(); |
|
1486 elemId &= KCDMaskHideAttrAndRes; |
|
1487 TMDBElementId tableAndRecordBitMask = KCDMaskShowRecordType | KCDMaskShowRecordId; |
|
1488 elemId &= tableAndRecordBitMask; |
|
1489 |
|
1490 *defTierAP = elemId; |
|
1491 |
|
1492 defTierAP->ModifyL(iSession.iOwner); |
|
1493 |
|
1494 CleanupStack::PopAndDestroy(defTierAP); |
|
1495 CleanupStack::PopAndDestroy(defIpprotoAP); |
|
1496 |
|
1497 } |
|
1498 } |
|
1499 } |
|
1500 |
|
1501 TInt CCDMapperIAPPrioritySelectionPolicyRecord::ForcedCountAPLinks() |
|
1502 { |
|
1503 TInt linkNum = 15; |
|
1504 |
|
1505 /* Walk backwards on the AP links and return the first valid AP link. |
|
1506 * This is the APCount number. |
|
1507 */ |
|
1508 CMDBRecordLink<CCDAccessPointRecord>* currAPLink = &(this->iAp15); |
|
1509 |
|
1510 for (; linkNum > 0; --linkNum) |
|
1511 { |
|
1512 if ( currAPLink && |
|
1513 *currAPLink ) |
|
1514 { |
|
1515 break; |
|
1516 } |
|
1517 --currAPLink; |
|
1518 } |
|
1519 |
|
1520 return linkNum; |
|
1521 } |
|
1522 |
|
1523 void CCDMapperIAPPrioritySelectionPolicyRecord::CheckIPProtoAPL(CMDBRecordLink<CCDAccessPointRecord>*& aAPPriorityField, |
|
1524 TInt aLinkNumber, |
|
1525 TBool aIsDefaultAP) |
|
1526 { |
|
1527 TInt linkAPTagId = 0; |
|
1528 |
|
1529 if ( KCDMaskShowFieldType == (iElement.ElementId() & KCDMaskShowFieldType) ) |
|
1530 { |
|
1531 //it's a record mapping |
|
1532 CCDIAPPrioritySelectionPolicyRecord* ptrIAPPrioritySelPol = static_cast<CCDIAPPrioritySelectionPolicyRecord*>(&iElement); |
|
1533 linkAPTagId = GetTheLinkAPTagIdL(ptrIAPPrioritySelPol, aLinkNumber); |
|
1534 } |
|
1535 else |
|
1536 { |
|
1537 //it's field mapping |
|
1538 if (Changed(*aAPPriorityField)) |
|
1539 { |
|
1540 CMDBRecordLink<CCDIAPRecord>* ptrIAPPrioritySelPol = static_cast<CMDBRecordLink<CCDIAPRecord>*>(&iElement); |
|
1541 linkAPTagId = GetTheLinkAPTagIdL(ptrIAPPrioritySelPol); |
|
1542 } |
|
1543 else |
|
1544 { |
|
1545 return; |
|
1546 } |
|
1547 } |
|
1548 |
|
1549 //got the original elementID of the linked IAP record |
|
1550 |
|
1551 //read the CustomSelectionPolicy field of the IPProto level AP |
|
1552 CMDBField<TInt>* custSelPolField = new(ELeave) CMDBField<TInt>(*aAPPriorityField | KCDTIdCustomSelectionPolicy); |
|
1553 CleanupStack::PushL(custSelPolField); |
|
1554 |
|
1555 custSelPolField->LoadL(iSession.iOwner); |
|
1556 |
|
1557 if (linkAPTagId != *custSelPolField) |
|
1558 //The IPProto AP has a wrong linking to the Link level AP. Modify it... |
|
1559 { |
|
1560 *custSelPolField = linkAPTagId; |
|
1561 |
|
1562 custSelPolField->ModifyL(iSession.iOwner); |
|
1563 } |
|
1564 |
|
1565 //if this is the default APPrioritySelPol record and the linkNumber is 1 then |
|
1566 //update the defaultAccessPoint link in the network Tier record |
|
1567 if (aIsDefaultAP/* && |
|
1568 1 == aLinkNumber*/) |
|
1569 { |
|
1570 CommsDatMapperAndValidator::ModifyDefaultTierRecordL((custSelPolField->ElementId() & ~KCDMaskShowFieldType) & ~KCDNotNullFlag, |
|
1571 iSession.iOwner); |
|
1572 } |
|
1573 |
|
1574 CleanupStack::PopAndDestroy(custSelPolField); |
|
1575 } |
|
1576 |
|
1577 void CCDMapperIAPPrioritySelectionPolicyRecord::GenerateIPProtoAPL(CMDBRecordLink<CCDAccessPointRecord>*& aAPPriorityFieldToModify, |
|
1578 TInt aLinkNumber, |
|
1579 TBool aIsDefaultAP) |
|
1580 |
|
1581 { |
|
1582 TInt linkAPTagId = 0; |
|
1583 |
|
1584 if ( KCDMaskShowFieldType == (iElement.ElementId() & KCDMaskShowFieldType) ) |
|
1585 { |
|
1586 //it's a record mapping |
|
1587 CCDIAPPrioritySelectionPolicyRecord* ptrIAPPrioritySelPol = static_cast<CCDIAPPrioritySelectionPolicyRecord*>(&iElement); |
|
1588 linkAPTagId = GetTheLinkAPTagIdL(ptrIAPPrioritySelPol, aLinkNumber); |
|
1589 } |
|
1590 else |
|
1591 { |
|
1592 //it's field mapping |
|
1593 if (Changed(*aAPPriorityFieldToModify)) |
|
1594 { |
|
1595 CMDBRecordLink<CCDIAPRecord>* ptrIAPPrioritySelPol = static_cast<CMDBRecordLink<CCDIAPRecord>*>(&iElement); |
|
1596 linkAPTagId = GetTheLinkAPTagIdL(ptrIAPPrioritySelPol); |
|
1597 } |
|
1598 else |
|
1599 { |
|
1600 //the given field is not changed -> don't touch anything... |
|
1601 return; |
|
1602 } |
|
1603 } |
|
1604 |
|
1605 CCDAccessPointRecord* ipprotoAP = NULL; |
|
1606 |
|
1607 if (!CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(linkAPTagId, iSession.iOwner)) |
|
1608 { |
|
1609 //The IPProto AP is not existing yet. Generate one. |
|
1610 ipprotoAP = CommsDatMapperAndValidator::GenerateIPProtoAPL(IPProtoBaseTagId, |
|
1611 linkAPTagId, |
|
1612 iSession.iOwner); |
|
1613 |
|
1614 CleanupStack::PushL(ipprotoAP); |
|
1615 |
|
1616 //save the generated AP record |
|
1617 ipprotoAP->StoreL(iSession.iOwner); |
|
1618 } |
|
1619 else |
|
1620 { |
|
1621 //The IPProto AP is already exsiting. Use that one. |
|
1622 ipprotoAP = CommsDatMapperAndValidator::LoadTheAPL(linkAPTagId, iSession.iOwner); |
|
1623 |
|
1624 CleanupStack::PushL(ipprotoAP); |
|
1625 } |
|
1626 |
|
1627 TMDBElementId elemId = ipprotoAP->ElementId(); |
|
1628 elemId &= KCDMaskHideAttrAndRes; |
|
1629 TMDBElementId tableAndRecordBitMask = KCDMaskShowRecordType | KCDMaskShowRecordId; |
|
1630 elemId &= tableAndRecordBitMask; |
|
1631 |
|
1632 //a) update the APPrioritySelPol record to point to the newly creeated AP record |
|
1633 *aAPPriorityFieldToModify = elemId; |
|
1634 |
|
1635 this->ModifyL(iSession.iOwner); |
|
1636 |
|
1637 //b) if this is the default APPrioritySelPol record and the linkNumber is 1 then |
|
1638 // update the defaultAccessPoint link in the network Tier record |
|
1639 if (aIsDefaultAP/* && |
|
1640 1 == aLinkNumber*/) |
|
1641 { |
|
1642 CommsDatMapperAndValidator::ModifyDefaultTierRecordL(elemId, iSession.iOwner); |
|
1643 } |
|
1644 |
|
1645 CleanupStack::PopAndDestroy(ipprotoAP); |
|
1646 } |
|
1647 |
|
1648 void CCDMapperIAPPrioritySelectionPolicyRecord::DeleteIPProtoAPL(CMDBRecordLink<CCDAccessPointRecord>*& aAPPriorityField) |
|
1649 { |
|
1650 TInt refCount = CommsDatMapperAndValidator::CountReferenceToThisIPProtoAPL(*aAPPriorityField, iSession.iOwner); |
|
1651 if (1 == refCount) |
|
1652 { |
|
1653 //ok, we have only 1 reference to the given IPProto AP -> it can be deleted |
|
1654 CCDAccessPointRecord* apRecordToBeDeleted = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(*aAPPriorityField)); |
|
1655 CleanupStack::PushL(apRecordToBeDeleted); |
|
1656 |
|
1657 apRecordToBeDeleted->DeleteL(iSession.iOwner); |
|
1658 |
|
1659 CleanupStack::PopAndDestroy(apRecordToBeDeleted); |
|
1660 } |
|
1661 } |
|
1662 |
|
1663 //Note - the ownership of the 'aTheAlreadyDeletedRecord' is transferred here!!!!!! |
|
1664 void CCDMapperIAPPrioritySelectionPolicyRecord::DeleteIPProtoAPL(CMDBRecordLink<CCDAccessPointRecord>*& aAPPriorityField, |
|
1665 CCDAPPrioritySelectionPolicyRecord* aTheAlreadyDeletedRecord) |
|
1666 { |
|
1667 //Note - the ownership of the 'aTheAlreadyDeletedRecord' is transferred to the CountReferenceToThisIPProtoAPL!!!!!! |
|
1668 TInt refCount = CommsDatMapperAndValidator::CountReferenceToThisIPProtoAPL(*aAPPriorityField, aTheAlreadyDeletedRecord, iSession.iOwner); |
|
1669 if (1 == refCount) |
|
1670 { |
|
1671 //ok, we have only 1 reference to the given IPProto AP -> it can be deleted |
|
1672 CCDAccessPointRecord* apRecordToBeDeleted = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(*aAPPriorityField)); |
|
1673 CleanupStack::PushL(apRecordToBeDeleted); |
|
1674 |
|
1675 apRecordToBeDeleted->DeleteL(iSession.iOwner); |
|
1676 |
|
1677 CleanupStack::PopAndDestroy(apRecordToBeDeleted); |
|
1678 } |
|
1679 } |
|
1680 |
|
1681 TInt CCDMapperIAPPrioritySelectionPolicyRecord::GetTheLinkAPTagIdL(CCDIAPPrioritySelectionPolicyRecord* aOrigIAPPrioritySelPolRec, |
|
1682 TInt aLinkNumber) |
|
1683 { |
|
1684 //TInt iapCount = aOrigIAPPrioritySelPolRec->iIapCount; |
|
1685 CMDBRecordLink<CCDIAPRecord>* iapXField = &aOrigIAPPrioritySelPolRec->iIap1; |
|
1686 CMDBField<TInt>* apTagId = NULL; |
|
1687 TInt tagId = 0; |
|
1688 |
|
1689 /*for (TInt i = 1; i!=aLinkNumber && i<=iapCount; ++i) |
|
1690 { |
|
1691 ++iapXField; |
|
1692 }*/ |
|
1693 |
|
1694 for (TInt i = 1; i!=aLinkNumber && i<=MaxLinkCount; ++i) |
|
1695 { |
|
1696 ++iapXField; |
|
1697 } |
|
1698 |
|
1699 //got the original elementID of the linked IAP record |
|
1700 |
|
1701 |
|
1702 //read the tagId of the generated Link level AP (if there is any)... |
|
1703 |
|
1704 apTagId = new(ELeave) CMDBField<TInt>(KCDTIdAccessPointRecord | KCDTIdRecordTag); |
|
1705 CleanupStack::PushL(apTagId); |
|
1706 |
|
1707 |
|
1708 if ( ( (*iapXField) & KCDMaskShowType ) == 0 && |
|
1709 ( (*iapXField) & KLinkableTag ) == 0 ) |
|
1710 { |
|
1711 //there is only a number for the IAP link in the table... |
|
1712 *apTagId = *iapXField; |
|
1713 } |
|
1714 else |
|
1715 { |
|
1716 //the IAP link is correctly set. Let's use the recordId from the value field. |
|
1717 *apTagId = (*iapXField & KCDMaskShowRecordId) >> 8; |
|
1718 } |
|
1719 |
|
1720 if ( !(apTagId->FindL(iSession.iOwner)) ) |
|
1721 //the link level AP cannot be found. Leaving... |
|
1722 { |
|
1723 User::Leave(KErrNotFound); |
|
1724 } |
|
1725 else |
|
1726 { |
|
1727 tagId = *apTagId; |
|
1728 } |
|
1729 |
|
1730 CleanupStack::PopAndDestroy(apTagId); |
|
1731 |
|
1732 return tagId; |
|
1733 } |
|
1734 |
|
1735 |
|
1736 TInt CCDMapperIAPPrioritySelectionPolicyRecord::GetTheLinkAPTagIdL(CMDBRecordLink<CCDIAPRecord>* aOrigIAPPrioritySelPolField/*, |
|
1737 TInt aLinkNumber*/) |
|
1738 { |
|
1739 CMDBField<TInt>* apTagId = NULL; |
|
1740 TInt tagId = 0; |
|
1741 //read the tagId of the generated Link level AP (if there is any)... |
|
1742 |
|
1743 apTagId = new(ELeave) CMDBField<TInt>(KCDTIdAccessPointRecord | KCDTIdRecordTag); |
|
1744 CleanupStack::PushL(apTagId); |
|
1745 |
|
1746 |
|
1747 if ( ( (*aOrigIAPPrioritySelPolField) & KCDMaskShowType ) == 0 && |
|
1748 ( (*aOrigIAPPrioritySelPolField) & KLinkableTag ) == 0 ) |
|
1749 { |
|
1750 //there is only a number for the IAP link in the table... |
|
1751 *apTagId = *aOrigIAPPrioritySelPolField; |
|
1752 } |
|
1753 else |
|
1754 { |
|
1755 //the IAP link is correctly set. Let's use the recordId from the value field. |
|
1756 *apTagId = (*aOrigIAPPrioritySelPolField & KCDMaskShowRecordId) >> 8; |
|
1757 } |
|
1758 |
|
1759 if ( !(apTagId->FindL(iSession.iOwner)) ) |
|
1760 //the link level AP cannot be found. Leaving... |
|
1761 { |
|
1762 User::Leave(KErrNotFound); |
|
1763 } |
|
1764 else |
|
1765 { |
|
1766 tagId = *apTagId; |
|
1767 } |
|
1768 |
|
1769 CleanupStack::PopAndDestroy(apTagId); |
|
1770 |
|
1771 return tagId; |
|
1772 } |
|
1773 |
|
1774 CommsDatMapperAndValidator::TAPTypes CCDMapperIAPPrioritySelectionPolicyRecord::CheckLinkLevelAPL(TMDBElementId aElementId) |
|
1775 //Assumption: an AP record always has a Tier field. |
|
1776 { |
|
1777 CommsDatMapperAndValidator::TAPTypes ret = CommsDatMapperAndValidator::EUndefined; |
|
1778 |
|
1779 CMDBRecordLink<CCDTierRecord>* tierField = new(ELeave) CMDBRecordLink<CCDTierRecord>(aElementId | KCDTIdTier); |
|
1780 CleanupStack::PushL(tierField); |
|
1781 |
|
1782 tierField->LoadL(iSession.iOwner); |
|
1783 |
|
1784 CMDBField<TInt>* tiertagId = new(ELeave) CMDBField<TInt>(*tierField | KCDTIdRecordTag); |
|
1785 CleanupStack::PushL(tiertagId); |
|
1786 |
|
1787 tiertagId->LoadL(iSession.iOwner); |
|
1788 |
|
1789 TInt tagId = *tiertagId; |
|
1790 |
|
1791 switch (tagId) |
|
1792 { |
|
1793 case CommsDatMapperAndValidator::ENetworkLevelTierId : |
|
1794 { |
|
1795 ret = CommsDatMapperAndValidator::ENetworkLevel; |
|
1796 break; |
|
1797 } |
|
1798 case CommsDatMapperAndValidator::EIPProtoTierId : |
|
1799 { |
|
1800 ret = CommsDatMapperAndValidator::EIPProtoLevel; |
|
1801 break; |
|
1802 } |
|
1803 case CommsDatMapperAndValidator::ELinkTierId : |
|
1804 { |
|
1805 ret = CommsDatMapperAndValidator::ELinkLevel; |
|
1806 break; |
|
1807 } |
|
1808 default: |
|
1809 { |
|
1810 User::Leave(KErrNotFound); |
|
1811 } |
|
1812 }; |
|
1813 |
|
1814 |
|
1815 CleanupStack::PopAndDestroy(tiertagId); |
|
1816 CleanupStack::PopAndDestroy(tierField); |
|
1817 |
|
1818 return ret; |
|
1819 } |
|
1820 |
|
1821 /************************* Mapper for AccessPoint Table *************************************** |
|
1822 * KCDTIdAccessPointRecord CCDAccessPointRecord |
|
1823 * |
|
1824 * The following fields are deprecated |
|
1825 * APGID CCDAccessPointRecord::iAccessPointGID |
|
1826 * |
|
1827 * They map to new fields within the AccessPointRecord |
|
1828 * APTier CCDAccessPointRecord::iTier |
|
1829 * |
|
1830 * The following fields have some deprecated usage which is mapped |
|
1831 * though the same field remains |
|
1832 * APSelectionPolicy CCDAccessPointRecord::iSelectionPolicy |
|
1833 * |
|
1834 * |
|
1835 */ |
|
1836 |
|
1837 #define KCDTIdMapperAccessPointRecord 9881 |
|
1838 START_ATTRIBUTE_TABLE( CCDMapperAccessPointRecord, KCDTIdMapperAccessPointRecord, KCDTIdMapperAccessPointRecord) |
|
1839 X_REGISTER_ATTRIBUTE( CCDMapperAccessPointRecord, iTier, TMDBLinkNum) |
|
1840 X_REGISTER_ATTRIBUTE( CCDMapperAccessPointRecord, iMCpr, TMDBLinkNum) |
|
1841 X_REGISTER_ATTRIBUTE( CCDMapperAccessPointRecord, iCpr, TMDBLinkNum) |
|
1842 X_REGISTER_ATTRIBUTE( CCDMapperAccessPointRecord, iSCpr, TMDBLinkNum) |
|
1843 X_REGISTER_ATTRIBUTE( CCDMapperAccessPointRecord, iProtocol, TMDBLinkNum) |
|
1844 X_REGISTER_ATTRIBUTE( CCDMapperAccessPointRecord, iCprConfig, TMDBNum) |
|
1845 X_REGISTER_ATTRIBUTE( CCDMapperAccessPointRecord, iAppSID, TMDBNum) |
|
1846 X_REGISTER_ATTRIBUTE( CCDMapperAccessPointRecord, iConfigAPIdList, TMDBText) |
|
1847 X_REGISTER_ATTRIBUTE( CCDMapperAccessPointRecord, iSelectionPolicy, TMDBNum) |
|
1848 X_REGISTER_ATTRIBUTE( CCDMapperAccessPointRecord, iRecordTag, TMDBNum) |
|
1849 END_ATTRIBUTE_TABLE() |
|
1850 |
|
1851 CCDMapperAccessPointRecord::CCDMapperAccessPointRecord(CMDBElement& aElement,CMDBSessionImpl& aSession, const TOperation& aOperation) |
|
1852 : CCDMapper(aElement.ElementId(), aElement, aSession, aOperation), |
|
1853 iTier(KCDTIdTier), |
|
1854 iMCpr(KCDTIdMCpr), |
|
1855 iCpr(KCDTIdCpr), |
|
1856 iSCpr(KCDTIdSCpr), |
|
1857 iProtocol(KCDTIdProtocol), |
|
1858 iCprConfig(KCDTIdCprConfig), |
|
1859 iAppSID(KCDTIdAppSID), |
|
1860 iConfigAPIdList(KCDTIdConfigAPIdList), |
|
1861 iSelectionPolicy(KCDTIdSelectionPolicy), |
|
1862 iRecordTag(KCDTIdRecordTag | KCDTIdAccessPointRecord) |
|
1863 {} |
|
1864 |
|
1865 void CCDMapperAccessPointRecord::ConstructL() |
|
1866 /* |
|
1867 Initialise the mapper element for any read or write operation |
|
1868 Only do the minimum work here as the call might be LoadL |
|
1869 |
|
1870 @internalTechnology |
|
1871 */ |
|
1872 { |
|
1873 // Will either be mappng the whole record or just the GID field |
|
1874 |
|
1875 CMDBField<TUint32>* theGIDField = NULL; |
|
1876 |
|
1877 SetRecordId(iElement.RecordId()); |
|
1878 |
|
1879 if(CommsDat::CommsDatSchema::IsRecord(iElement.ElementId())) |
|
1880 { |
|
1881 CCDAccessPointRecord& inputRecord = static_cast<CCDAccessPointRecord&>(iElement); |
|
1882 |
|
1883 theGIDField = static_cast<CMDBField<TUint32>*>(&inputRecord.iAccessPointGID); |
|
1884 |
|
1885 if (!inputRecord.iSelectionPolicy.IsNull()) |
|
1886 { |
|
1887 //create the link which will be valid at the time of the insertion of the IAPPrioritySelPol |
|
1888 //record |
|
1889 iSelectionPolicy.SetL(KCDTIdApPrioritySelectionPolicyRecord | inputRecord.iSelectionPolicy & KCDMaskShowRecordId); |
|
1890 } |
|
1891 |
|
1892 // These elements are quite likely to be NULL |
|
1893 if (!inputRecord.iTier.IsNull()) |
|
1894 { |
|
1895 iTier.SetL(inputRecord.iTier); |
|
1896 } |
|
1897 if (!inputRecord.iMCpr.IsNull()) |
|
1898 { |
|
1899 iMCpr.SetL(inputRecord.iMCpr); |
|
1900 } |
|
1901 if (!inputRecord.iCpr.IsNull()) |
|
1902 { |
|
1903 iCpr.SetL(inputRecord.iCpr); |
|
1904 } |
|
1905 if (!inputRecord.iSCpr.IsNull()) |
|
1906 { |
|
1907 iSCpr.SetL(inputRecord.iSCpr); |
|
1908 } |
|
1909 if (!inputRecord.iProtocol.IsNull()) |
|
1910 { |
|
1911 iProtocol.SetL(inputRecord.iProtocol); |
|
1912 } |
|
1913 if (!inputRecord.iCprConfig.IsNull()) |
|
1914 { |
|
1915 iCprConfig.SetL(inputRecord.iCprConfig); |
|
1916 } |
|
1917 if (!inputRecord.iAppSID.IsNull()) |
|
1918 { |
|
1919 iAppSID.SetL(inputRecord.iAppSID); |
|
1920 } |
|
1921 if (!inputRecord.iConfigAPIdList.IsNull()) |
|
1922 { |
|
1923 iConfigAPIdList.SetL(inputRecord.iConfigAPIdList); |
|
1924 } |
|
1925 } |
|
1926 else |
|
1927 { |
|
1928 if ( (iElement.ElementId() & KCDMaskShowType) == KCDTIdAccessPointGID ) |
|
1929 { |
|
1930 theGIDField = static_cast<CMDBField<TUint32>*>(&iElement); |
|
1931 } |
|
1932 else |
|
1933 { |
|
1934 //selectionPolicy field... |
|
1935 this->iSelectionPolicy.SetL(KCDTIdApPrioritySelectionPolicyRecord | static_cast<CMDBField<TUint32>&>(iElement) & KCDMaskShowRecordId); |
|
1936 this->iSelectionPolicy.SetRecordId(iElement.RecordId()); |
|
1937 } |
|
1938 } |
|
1939 |
|
1940 // Don't do validation - leave that til later. Just copy the fields |
|
1941 if (theGIDField && |
|
1942 0 != (*theGIDField) && |
|
1943 iTier.IsNull()) |
|
1944 { |
|
1945 if (Changed(*theGIDField)) |
|
1946 { |
|
1947 iTier.SetL(*theGIDField); |
|
1948 } |
|
1949 } |
|
1950 } |
|
1951 |
|
1952 void CCDMapperAccessPointRecord::PreMappingsL() |
|
1953 { |
|
1954 if (EStore == iOperation) |
|
1955 { |
|
1956 // 2. Map the fields |
|
1957 if ( iMCpr.IsNull() ) |
|
1958 { |
|
1959 // this would indicate the mapper was incomplete |
|
1960 // not trying to validate away completely pathological case where scattered fields are set |
|
1961 |
|
1962 //load the template AP for the Network layer form the BearerType table |
|
1963 _LIT(KTemplateRecName,"NetworkDefaultTemplate"); |
|
1964 |
|
1965 CCDBearerTypeRecord* templateForTheAPRec = static_cast<CCDBearerTypeRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdBearerTypeRecord)); |
|
1966 CleanupStack::PushL(templateForTheAPRec); |
|
1967 |
|
1968 templateForTheAPRec->iRecordName.SetMaxLengthL(KTemplateRecName().Length()); |
|
1969 templateForTheAPRec->iRecordName = KTemplateRecName(); |
|
1970 |
|
1971 if (!templateForTheAPRec->FindL(iSession.iOwner)) |
|
1972 { |
|
1973 User::Leave(KErrNotFound); |
|
1974 } |
|
1975 |
|
1976 // Copy the fields from the template record. The recordId will be the same as the one of the |
|
1977 //input record |
|
1978 iTier.SetL(templateForTheAPRec->iTier); |
|
1979 iMCpr.SetL(templateForTheAPRec->iMCpr); |
|
1980 iCpr.SetL(templateForTheAPRec->iCpr); |
|
1981 iSCpr.SetL(templateForTheAPRec->iSCpr); |
|
1982 iProtocol.SetL(templateForTheAPRec->iProtocol); |
|
1983 //the SelectionPolicy field was set in the ConstructL function... |
|
1984 |
|
1985 CCDAccessPointRecord& inputRecord = static_cast<CCDAccessPointRecord&>(iElement); |
|
1986 if (inputRecord.iRecordTag.IsNull() ) |
|
1987 //APs have to have tagIds.... |
|
1988 { |
|
1989 iRecordTag = CommsDatMapperAndValidator::GenerateTagIdL(NetworkBaseTagId, iSession.iOwner); |
|
1990 } |
|
1991 |
|
1992 CleanupStack::PopAndDestroy(templateForTheAPRec); |
|
1993 } |
|
1994 } |
|
1995 else if (EDelete == iOperation) |
|
1996 { |
|
1997 if (KCDMaskShowFieldType != (iElement.ElementId() & KCDMaskShowFieldType)) |
|
1998 { |
|
1999 //field mapping -> change the elementId of the whole mapper object so the MaybeDeleteNodeL will delete |
|
2000 //only the given field and not the whole mapper. |
|
2001 if (KCDTIdSelectionPolicy == (iElement.ElementId() & KCDMaskShowType)) |
|
2002 { |
|
2003 SetElementId(ElementId() & ~KCDMaskShowFieldType); |
|
2004 SetElementId(ElementId() | KCDTIdSelectionPolicy); |
|
2005 } |
|
2006 else |
|
2007 { |
|
2008 //the GID field is mapped into the Tier field |
|
2009 SetElementId(ElementId() | KCDTIdTier); |
|
2010 } |
|
2011 } |
|
2012 } |
|
2013 } |
|
2014 |
|
2015 |
|
2016 void CCDMapperAccessPointRecord::PrepareToStoreL() |
|
2017 /* |
|
2018 Prepare the mapper for a write operation |
|
2019 |
|
2020 Create any new node(s) that may be required. |
|
2021 Sometimes more than one mapper node might be needed for one input node. |
|
2022 |
|
2023 The mapper element will have been populated from the input element already, |
|
2024 but now complete the population where necessary following the unique set of |
|
2025 rules for this class |
|
2026 |
|
2027 validate the information (only where valid data is critical) |
|
2028 |
|
2029 The element can be populated by using information from both the input element and the database |
|
2030 |
|
2031 @internalTechnology |
|
2032 */ |
|
2033 { |
|
2034 // Create new node if necessary (only one new node in this case) and only when the input element is a record |
|
2035 iSession.MaybeCreateNodeL((CMDBElement&)*this); |
|
2036 if ( (iElement.ElementId() & KCDNewRecordRequest == KCDNewRecordRequest) && |
|
2037 (iElement.ElementId() & KCDMaskShowFieldType) == KCDMaskShowFieldType ) |
|
2038 { |
|
2039 iElement.SetRecordId(this->RecordId()); |
|
2040 } |
|
2041 |
|
2042 // Check that the tier matches the default tier (leave if it doesn't) |
|
2043 CMDBField<TUint32>* theGIDField = NULL; |
|
2044 |
|
2045 if(CommsDat::CommsDatSchema::IsRecord(iElement.ElementId())) |
|
2046 { |
|
2047 CCDAccessPointRecord& inputRecord = static_cast<CCDAccessPointRecord&>(iElement); |
|
2048 |
|
2049 theGIDField = static_cast<CMDBField<TUint32>*>(&inputRecord.iAccessPointGID); |
|
2050 } |
|
2051 else |
|
2052 { |
|
2053 if ( (iElement.ElementId() & KCDMaskShowType) == KCDTIdAccessPointGID ) |
|
2054 { |
|
2055 theGIDField = static_cast<CMDBField<TUint32>*>(&iElement); |
|
2056 } |
|
2057 } |
|
2058 |
|
2059 // 1. lookup defaultTier record from global settings and check it matches. |
|
2060 if (NULL == theGIDField || |
|
2061 0 == *theGIDField) |
|
2062 { |
|
2063 //GID field is not filled in the record so let's try to read the tier field in the mapped AP with the same |
|
2064 //recordId as the one from the client... |
|
2065 |
|
2066 //tier link in the AP record |
|
2067 CMDBRecordLink<CCDTierRecord>* apTierField = new(ELeave) CMDBRecordLink<CCDTierRecord>(KCDTIdTier); |
|
2068 CleanupStack::PushL(apTierField); |
|
2069 apTierField->SetRecordId(iElement.RecordId()); |
|
2070 |
|
2071 //tier link in the GS record |
|
2072 CMDBRecordLink<CCDTierRecord>* gsTierField = new(ELeave) CMDBRecordLink<CCDTierRecord>(KCDTIdDefaultTier); |
|
2073 CleanupStack::PushL(gsTierField); |
|
2074 gsTierField->SetRecordId(1); |
|
2075 |
|
2076 apTierField->LoadL(iSession.iOwner); |
|
2077 gsTierField->LoadL(iSession.iOwner); |
|
2078 |
|
2079 if ( *gsTierField != ((*apTierField & KCDMaskShowRecordId) >> 8) ) |
|
2080 { |
|
2081 //this is not a network level AP -> leaving |
|
2082 User::Leave(KErrArgument); |
|
2083 } |
|
2084 CleanupStack::PopAndDestroy(gsTierField); |
|
2085 CleanupStack::PopAndDestroy(apTierField); |
|
2086 } |
|
2087 else |
|
2088 { |
|
2089 CheckIsSnapL(*theGIDField); // returned default tier id is not used here |
|
2090 } |
|
2091 } |
|
2092 |
|
2093 |
|
2094 |
|
2095 TBool CCDMapperAccessPointRecord::NeedsMapping(CMDBElement& aElement) |
|
2096 // NB it is correct that the fields listed here are different from the fields in the Mapped() function |
|
2097 { |
|
2098 if( CommsDat::CommsDatSchema::IsRecord(aElement.ElementId()) ) |
|
2099 { |
|
2100 CCDAccessPointRecord& ap = static_cast<CCDAccessPointRecord&>(aElement); |
|
2101 if (ap.iTier.IsNull() ) |
|
2102 { |
|
2103 // either reading into an empty record or storing and haven't set the tier so map |
|
2104 return ETrue; |
|
2105 } |
|
2106 |
|
2107 return EFalse; |
|
2108 } |
|
2109 |
|
2110 |
|
2111 if( (aElement.ElementId() & KCDMaskShowType) == KCDTIdAccessPointGID || |
|
2112 (aElement.ElementId() & KCDMaskShowType) == KCDTIdSelectionPolicy ) |
|
2113 { |
|
2114 return ETrue; |
|
2115 } |
|
2116 |
|
2117 return EFalse; |
|
2118 } |
|
2119 |
|
2120 |
|
2121 TBool CCDMapperAccessPointRecord::Mapped(TMDBElementId aElementId) |
|
2122 // Lists the fields in this record that will be handled by the mapper not the caller |
|
2123 { |
|
2124 TInt fieldTypeId = aElementId & KCDMaskShowType; |
|
2125 |
|
2126 switch(fieldTypeId) |
|
2127 { |
|
2128 case KCDTIdAccessPointGID : |
|
2129 case KCDTIdTier : |
|
2130 case KCDTIdMCpr : |
|
2131 case KCDTIdCpr : |
|
2132 case KCDTIdSCpr : |
|
2133 case KCDTIdProtocol : |
|
2134 case KCDTIdCprConfig : |
|
2135 case KCDTIdAppSID : |
|
2136 case KCDTIdConfigAPIdList : |
|
2137 case KCDTIdSelectionPolicy : |
|
2138 { |
|
2139 return ETrue; |
|
2140 } |
|
2141 } |
|
2142 return EFalse; |
|
2143 } |
|
2144 |
|
2145 //Delete the previously stored selectionPolicy field... |
|
2146 /*virtual*/ void CCDMapperAccessPointRecord::FinalPreparationsL() |
|
2147 { |
|
2148 CMDBRecordLink<CCDSelectionPolicyRecordBase>* selectionPolicy = new(ELeave) CMDBRecordLink<CCDSelectionPolicyRecordBase>(KCDTIdSelectionPolicy); |
|
2149 selectionPolicy->SetRecordId(RecordId()); |
|
2150 |
|
2151 selectionPolicy->DeleteL(iSession.iOwner); |
|
2152 } |
|
2153 |
|
2154 |
|
2155 TMDBElementId CCDMapper::CheckIsSnapL(TMDBElementId aInputId) |
|
2156 { |
|
2157 // first find the default tier record |
|
2158 CMDBRecordLink<CCDTierRecord> *tierLinkField = new(ELeave) CMDBRecordLink<CCDTierRecord>(KCDTIdGlobalSettingsRecord | KCDTIdDefaultTier | KCDGlobalSettingsRecordId); |
|
2159 CleanupStack::PushL(tierLinkField); |
|
2160 |
|
2161 tierLinkField->LoadL(iSession.iOwner); |
|
2162 |
|
2163 TMDBElementId defaultTierId = (tierLinkField->iLinkedRecord->ElementId()) & KCDMaskShowRecordTypeAndId; |
|
2164 |
|
2165 // now prime the same container with aId and check we get to the same tier record id |
|
2166 tierLinkField->SetL(aInputId); |
|
2167 |
|
2168 TMDBElementId resolvedInputId = CommsDatSchema::GetLinkIdL(iSession.iOwner, tierLinkField->ElementId(), tierLinkField->GetL(), KCDTIdTierRecord/*, NULL*/); |
|
2169 |
|
2170 if (defaultTierId != resolvedInputId) |
|
2171 { |
|
2172 __FLOG_STATIC3(KLogComponent, KCDErrLog, |
|
2173 _L("CCDMapper::CheckIsSnapL() - iGID <%08x> resolves to <%08x> not to the default (SNAP) Tier <%08x>"), |
|
2174 aInputId, resolvedInputId, defaultTierId); |
|
2175 |
|
2176 User::Leave(KErrArgument); |
|
2177 } |
|
2178 |
|
2179 CleanupStack::PopAndDestroy(tierLinkField); |
|
2180 |
|
2181 return defaultTierId; |
|
2182 } |
|
2183 |
|
2184 |
|
2185 |
|
2186 void CCDMapperAccessPointRecord::MapResultsL() |
|
2187 /* |
|
2188 Map results to client element following mapping rules |
|
2189 |
|
2190 only the GID and SelPol field need mapping |
|
2191 |
|
2192 @internalComponent |
|
2193 */ |
|
2194 { |
|
2195 CMDBField<TUint32>* gidInputElement = NULL; |
|
2196 CMDBRecordLink<CCDSelectionPolicyRecordBase>* selectionPolicy; |
|
2197 |
|
2198 if(CommsDat::CommsDatSchema::IsRecord(iElement.ElementId())) |
|
2199 { |
|
2200 CCDAccessPointRecord& inputRecord = static_cast<CCDAccessPointRecord&>(iElement); |
|
2201 gidInputElement = static_cast<CMDBField<TUint32>*>(&inputRecord.iAccessPointGID); |
|
2202 selectionPolicy = static_cast<CMDBRecordLink<CCDSelectionPolicyRecordBase>*>(&inputRecord.iSelectionPolicy); |
|
2203 |
|
2204 TInt mappedLinkValue = static_cast<TInt>(iSelectionPolicy); |
|
2205 if (mappedLinkValue) |
|
2206 { |
|
2207 *selectionPolicy = KCDTIdIapPrioritySelectionPolicyRecord | (mappedLinkValue & KCDMaskShowRecordId); |
|
2208 } |
|
2209 } |
|
2210 else |
|
2211 { |
|
2212 if( (iElement.ElementId() & KCDMaskShowType) == KCDTIdAccessPointGID) |
|
2213 { |
|
2214 gidInputElement=static_cast<CMDBField<TUint32>*>(&iElement); |
|
2215 } |
|
2216 else |
|
2217 { |
|
2218 //selection policy field mapping |
|
2219 TInt selPolVal = static_cast<TInt>(iSelectionPolicy); |
|
2220 if (selPolVal) |
|
2221 { |
|
2222 CMDBField<TInt>* inputSelPolField = static_cast<CMDBField<TInt>*>(&iElement); |
|
2223 inputSelPolField->SetL(KCDTIdIapPrioritySelectionPolicyRecord | selPolVal & KCDMaskShowRecordId); |
|
2224 Sync(*inputSelPolField); |
|
2225 } |
|
2226 } |
|
2227 } |
|
2228 |
|
2229 // Tier may not be default, but it's still ok to copy tier id to GID |
|
2230 // Though remember only default tier can be stored via a mapped access point |
|
2231 if ( (CommsDat::CommsDatSchema::IsRecord(iElement.ElementId())) || |
|
2232 ((iElement.ElementId() & KCDMaskShowType) == KCDTIdAccessPointGID) && |
|
2233 !iTier.IsNull() ) |
|
2234 { |
|
2235 gidInputElement->SetL(iTier); |
|
2236 Sync(*gidInputElement); |
|
2237 } |
|
2238 } |
|
2239 |
|
2240 |
|
2241 #endif // SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY |
|
2242 |
|
2243 |
|
2244 |
|
2245 //EOF |
|
2246 |
|
2247 |
|
2248 |
|
2249 |
|
2250 |
|
2251 |
|
2252 |
|
2253 |
|
2254 |
|
2255 |
|
2256 |
|
2257 |
|
2258 |