commsfwtools/preparedefaultcommsdatabase/src/CommsDatMapperAndValidatorUtils.cpp
branchRCL_3
changeset 12 8b5d60ce1e94
parent 0 dfb7c4ff071f
equal deleted inserted replaced
11:98a7181d2ce7 12:8b5d60ce1e94
   155 	apRecordToBeCreated->iTier.SetL(templateForTheAPRec->iTier);
   155 	apRecordToBeCreated->iTier.SetL(templateForTheAPRec->iTier);
   156 	apRecordToBeCreated->iMCpr.SetL(templateForTheAPRec->iMCpr);
   156 	apRecordToBeCreated->iMCpr.SetL(templateForTheAPRec->iMCpr);
   157 	apRecordToBeCreated->iCpr.SetL(templateForTheAPRec->iCpr);
   157 	apRecordToBeCreated->iCpr.SetL(templateForTheAPRec->iCpr);
   158 	apRecordToBeCreated->iSCpr.SetL(templateForTheAPRec->iSCpr);
   158 	apRecordToBeCreated->iSCpr.SetL(templateForTheAPRec->iSCpr);
   159 	apRecordToBeCreated->iProtocol.SetL(templateForTheAPRec->iProtocol);
   159 	apRecordToBeCreated->iProtocol.SetL(templateForTheAPRec->iProtocol);
   160     CMDBField<TInt>* custFiel = &(apRecordToBeCreated->iCustomSelectionPolicy);
   160 	apRecordToBeCreated->iCustomSelectionPolicy.SetL(aLinkLevelAPTagId);
   161     *custFiel = aLinkLevelAPTagId;
       
   162     apRecordToBeCreated->iCprConfig.SetL(aLinkLevelAPTagId);
   161     apRecordToBeCreated->iCprConfig.SetL(aLinkLevelAPTagId);
   163     
   162     
   164     CleanupStack::PopAndDestroy(templateForTheAPRec);
   163     CleanupStack::PopAndDestroy(templateForTheAPRec);
   165     
   164     
   166     //the ownership will be transferred
   165     //the ownership will be transferred
   307 	CleanupStack::PopAndDestroy(ipprotoTierTag);
   306 	CleanupStack::PopAndDestroy(ipprotoTierTag);
   308 	
   307 	
   309 	return recId;
   308 	return recId;
   310 	}
   309 	}
   311 
   310 
       
   311 
       
   312 /*
       
   313 Populates an access point record with the first matching IP Proto Access Point record.
       
   314 
       
   315 @param aAccessPoint An access point record that will be populated with data from the
       
   316                     first matching record. This can have fields primed in order to
       
   317                     make the match more specific
       
   318 @param aSession     The commsdat session to use  
       
   319 @return             ETrue if a matching IP Proto access point is found. EFalse if it is not.
       
   320 @exception          KErrCorrupt if the IP Proto Tier entry is missing from the database.
       
   321                     It can leave with other errors from other parts of commsdat/cenrep
       
   322 */
       
   323 TBool CommsDatMapperAndValidator::FindIPProtoAccessPointRecordL(CommsDat::CCDAccessPointRecord& aAccessPoint, CommsDat::CMDBSession& aSession)
       
   324     {
       
   325     // Find the IP Proto tier record - we can then use this information to more efficently find the ip proto access points
       
   326     CMDBField<TInt> tierRecord;
       
   327     tierRecord.SetElementId(KCDTIdTierRecord | KCDTIdRecordTag);
       
   328     tierRecord.SetL(EIPProtoTierId);
       
   329     TBool found = tierRecord.FindL(aSession);
       
   330     if (!found)
       
   331         {
       
   332         __FLOG_STATIC0(KLogComponent, KCDInfoLog, _L("CommsDatMapperAndValidator::FindIPProtoAccessPointRecordL - ERROR: IP Proto Tier entry missing!!"));
       
   333         User::Leave(KErrCorrupt);
       
   334         }
       
   335 
       
   336     TMDBElementId tierElement; // This is where the AP record will link if it is an IP Proto AP
       
   337     tierElement = tierRecord.ElementId() & (KCDMaskShowType | KCDMaskShowRecordId);
       
   338     
       
   339     aAccessPoint.iTier = tierElement;
       
   340     found = aAccessPoint.FindL(aSession);
       
   341     
       
   342     return found;
       
   343     }
       
   344 
   312 TBool CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(TInt aLinkLevelTagId,
   345 TBool CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(TInt aLinkLevelTagId,
   313 														  CommsDat::CMDBSession& aSession)
   346 														  CommsDat::CMDBSession& aSession)
   314 	{
   347 	{
   315 	TBool ret = EFalse;
   348     CCDAccessPointRecord* ap = (CCDAccessPointRecord*)CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord);
   316 	
   349     CleanupStack::PushL(ap);
   317 	CMDBField<TInt>* ipprotoCustSelPolField = new(ELeave)CMDBField<TInt>(KCDTIdCustomSelectionPolicy);
   350     
   318 	CleanupStack::PushL(ipprotoCustSelPolField);
   351     ap->iCustomSelectionPolicy = aLinkLevelTagId;
   319 	
   352     
   320 	*ipprotoCustSelPolField = aLinkLevelTagId;
   353     TBool found = FindIPProtoAccessPointRecordL(*ap, aSession);
   321 	
   354 	CleanupStack::PopAndDestroy(ap);
   322 	if (ipprotoCustSelPolField->FindL(aSession))
   355     
   323 		{
   356 	return found;
   324 		ret = ETrue;
       
   325 		}
       
   326 	
       
   327 	CleanupStack::PopAndDestroy(ipprotoCustSelPolField);
       
   328 	
       
   329 	return ret;
       
   330 	}
   357 	}
   331 
   358 
   332 TBool CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(TInt aLinkLevelTagId, 
   359 TBool CommsDatMapperAndValidator::IsIPProtoAPAlreadyExistL(TInt aLinkLevelTagId, 
   333 														   TInt aConnPrefElementId, 
   360 														   TInt aConnPrefElementId, 
   334 														   CommsDat::CMDBSession& aSession)
   361 														   CommsDat::CMDBSession& aSession)
   335 	{
   362 	{
   336 	TBool ret = EFalse;
   363     CCDAccessPointRecord* ap = (CCDAccessPointRecord*)CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord);
   337 	
   364     CleanupStack::PushL(ap);
   338 	CCDAccessPointRecord* apRec = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord));
   365     
   339 	CleanupStack::PushL(apRec);
   366     ap->iCprConfig = aConnPrefElementId;
   340 	
   367     ap->iCustomSelectionPolicy = aLinkLevelTagId;
   341 	apRec->iCprConfig = aConnPrefElementId;
   368 
   342 	apRec->iCustomSelectionPolicy = aLinkLevelTagId;
   369     TBool found = FindIPProtoAccessPointRecordL(*ap, aSession);
   343 	
   370     CleanupStack::PopAndDestroy(ap);
   344 	if (apRec->FindL(aSession))
   371     
   345 		{
   372     return found;
   346 		ret = ETrue;
   373 	}
   347 		}
   374 
   348 	
   375 
   349 	CleanupStack::PopAndDestroy(apRec);
   376 CommsDat::CCDAccessPointRecord* CommsDatMapperAndValidator::LoadIPProtoAccessPoint(TInt aLinkLevelTagId,
   350 	
       
   351 	return ret;
       
   352 	}
       
   353 
       
   354 CommsDat::CCDAccessPointRecord* CommsDatMapperAndValidator::LoadTheAPL(TInt aLinkLevelTagId,
       
   355 										   							   CommsDat::CMDBSession& aSession)
   377 										   							   CommsDat::CMDBSession& aSession)
   356 	{
   378 	{
   357     CCDAccessPointRecord* apRec = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord));
   379     CCDAccessPointRecord* apRec = static_cast<CCDAccessPointRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdAccessPointRecord));
   358     CleanupStack::PushL(apRec);
   380     CleanupStack::PushL(apRec);
   359     
   381     
   360     apRec->iCustomSelectionPolicy = aLinkLevelTagId;
   382     apRec->iCustomSelectionPolicy = aLinkLevelTagId;
   361     
   383     
   362     if(!apRec->FindL(aSession))
   384     if (!FindIPProtoAccessPointRecordL(*apRec, aSession))
   363     	{
   385         {
   364     	//no records were found with the given customSelectionPolicy value
   386         CleanupStack::PopAndDestroy(apRec);
   365     	User::Leave(KErrNotFound);
   387         return NULL;
   366     	}
   388         }
   367     
   389     
   368     CleanupStack::Pop(apRec);
   390     CleanupStack::Pop(apRec); // ownership of the AP record is given to the caller
   369     
       
   370     return apRec;
   391     return apRec;
   371 	}
   392 	}
       
   393 
   372 
   394 
   373 /* All of the APPrioritySelectionPolicy fields are exemined checking that how many
   395 /* All of the APPrioritySelectionPolicy fields are exemined checking that how many
   374  * fields, in different APPrioritySelPol records, are referencing the given AP
   396  * fields, in different APPrioritySelPol records, are referencing the given AP
   375  * record. The recordSet->FindL with a primed record is not suitable here because
   397  * record. The recordSet->FindL with a primed record is not suitable here because
   376  * the link can occur in any field of the APPrioritySelPol record.
   398  * the link can occur in any field of the APPrioritySelPol record.
   480 	CleanupStack::PopAndDestroy(apprioritySelPolRecSet);
   502 	CleanupStack::PopAndDestroy(apprioritySelPolRecSet);
   481 	
   503 	
   482 	return refCount;
   504 	return refCount;
   483 	}
   505 	}
   484 
   506 
       
   507 
   485 TBool CommsDatMapperAndValidator::IsIAPRecInDB(CommsDat::CMDBSession& aSession)
   508 TBool CommsDatMapperAndValidator::IsIAPRecInDB(CommsDat::CMDBSession& aSession)
   486 	{
   509 	{
   487 	TBool ret = EFalse;
   510 	TBool ret = EFalse;
   488 	
   511 	
   489 	CMDBRecordSet<CCDIAPRecord>* iapRecSet = new(ELeave)CMDBRecordSet<CCDIAPRecord>(KCDTIdIAPRecord);
   512 	CMDBRecordSet<CCDIAPRecord>* iapRecSet = new(ELeave)CMDBRecordSet<CCDIAPRecord>(KCDTIdIAPRecord);