void CSrLvliRecord::UpdateListCount (void)
{
	dword Count = CountSubrecords(SR_NAME_LVLO);

	if (Count > SR_LVLO_MAXCOUNT)
	{
		SystemLog.Printf("WARNING: Exceeded maximum of %d LVLO subrecords!", SR_LVLO_MAXCOUNT);
		int Counter = 0;
		
		for (dword i = 0; i < m_Subrecords.GetSize(); ++i)
		{
			if (m_Subrecords[i]->GetRecordType() != SR_NAME_LVLO) continue;
			++Counter;

			if (Counter > SR_LVLO_MAXCOUNT) 
			{
				m_Subrecords.Delete(i);
				if (m_Subrecords[i] != NULL && m_Subrecords[i]->GetRecordType() == SR_NAME_COED) m_Subrecords.Delete(i);
				--i;
			}
		}

		SetListCount(SR_LVLO_MAXCOUNT);
	}

	SetListCount(Count);
}
void CListAllKeys::ConstructL(const TTestActionSpec& aTestActionSpec)
{
	CKeyStoreTestAction::ConstructL(aTestActionSpec);
	
	iFilter.iKeyAlgorithm = iAlgorithm;
	if (iUsage == 0)
		iUsage = EPKCS15UsageAll;
	iFilter.iUsage = iUsage;
	TInt pos = 0;
	TPtrC8 buf(0,0);

	iStore = 0;

	TInt err;
	buf.Set(Input::ParseElement(aTestActionSpec.iActionBody, KKeySizeStart, KKeySizeEnd, pos, err));
	if (err == KErrNone)
		SetKeySize(buf);

	buf.Set(Input::ParseElement(aTestActionSpec.iActionBody, KListCountStart, KListCountEnd, pos, err));
	if (err == KErrNone)
		SetListCount(buf);

	do
		{
		buf.Set(Input::ParseElement(aTestActionSpec.iActionBody, 
									KFoundKeyStart, KFoundKeyEnd,pos,err));
		if (err == KErrNone)
			AddFoundKeyL(buf);
		} 
	while (err == KErrNone);
}
bool CSrLvliRecord::DeleteItem (CSrLvloSubrecord* pItem)
{
	if (pItem == NULL) return false;
	bool Result = m_Subrecords.Delete(pItem);

	if (Result) 
	{
		if (GetListCount() > 0) 
			SetListCount(GetListCount() - 1);
		else
			UpdateListCount();
	}

	return true;
}
CSrLvloSubrecord* CSrLvliRecord::AddItem (const srformid_t FormID, const dword Level, const dword Count)
{
	if (GetListCount() > SR_LVLO_MAXCOUNT) return NULL;

	CSrSubrecord* pSubrecord = AddNewSubrecord(SR_NAME_LVLO);
	CSrLvloSubrecord* pNewLvlo = SrCastClassNull(CSrLvloSubrecord, pSubrecord);
	if (pNewLvlo == NULL) return NULL;
	pNewLvlo->InitializeNew();

	pNewLvlo->GetListData().Count  = Count;
	pNewLvlo->GetListData().Level  = Level;
	pNewLvlo->GetListData().FormID = FormID;

	SetListCount(GetListCount() + 1);
	return pNewLvlo;
}