sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "CSWICertStoreEntryList.h" sl@0: #include "CSWICertStoreEntry.h" sl@0: #include sl@0: sl@0: CSWICertStoreEntryList* CSWICertStoreEntryList::NewL(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex, TInt aStoreIndex) sl@0: { sl@0: CSWICertStoreEntryList* self = new(ELeave) CSWICertStoreEntryList(); sl@0: CleanupStack::PushL(self); sl@0: self->InternalizeL(aStream, aToken, aCertIndex, aStoreIndex); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CSWICertStoreEntryList* CSWICertStoreEntryList::NewL() sl@0: { sl@0: CSWICertStoreEntryList* self = new(ELeave) CSWICertStoreEntryList(); sl@0: return self; sl@0: } sl@0: sl@0: CSWICertStoreEntryList::CSWICertStoreEntryList() sl@0: { sl@0: } sl@0: sl@0: CSWICertStoreEntryList::~CSWICertStoreEntryList() sl@0: { sl@0: iEntries.ResetAndDestroy(); sl@0: iEntries.Close(); sl@0: } sl@0: sl@0: void CSWICertStoreEntryList::InternalizeL(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex, TInt aStoreIndex) sl@0: { sl@0: TInt count = aStream.ReadInt32L(); sl@0: sl@0: for (TInt i = 0 ; i < count ; ++i) sl@0: { sl@0: CSWICertStoreEntry* entry = CSWICertStoreEntry::NewLC(aStream, aToken, aCertIndex+i, aStoreIndex); sl@0: iEntries.AppendL(entry); sl@0: CleanupStack::Pop(entry); sl@0: } sl@0: } sl@0: sl@0: TInt CSWICertStoreEntryList::Count() const sl@0: { sl@0: return iEntries.Count(); sl@0: } sl@0: sl@0: TBool CSWICertStoreEntryList::LabelExists(const TDesC& aLabel) const sl@0: { sl@0: TInt count = iEntries.Count(); sl@0: for (TInt i = 0 ; i < count ; ++i) sl@0: { sl@0: CSWICertStoreEntry* entry = iEntries[i]; sl@0: if (entry->CertInfo().Label() == aLabel) sl@0: { sl@0: return ETrue; sl@0: } sl@0: } sl@0: return EFalse; sl@0: } sl@0: sl@0: TInt CSWICertStoreEntryList::AppendL(CSWICertStoreEntry* aCertInfo) sl@0: { sl@0: User::LeaveIfError(iEntries.Append(aCertInfo)); sl@0: return iEntries.Count() - 1; sl@0: } sl@0: sl@0: void CSWICertStoreEntryList::Remove(TInt aIndex) sl@0: { sl@0: CSWICertStoreEntry* entry = iEntries[aIndex]; sl@0: iEntries.Remove(aIndex); sl@0: delete entry; sl@0: } sl@0: sl@0: const CSWICertStoreEntry& CSWICertStoreEntryList::GetByIndex(TInt aIndex) const sl@0: { sl@0: return *iEntries[aIndex]; sl@0: } sl@0: sl@0: const CSWICertStoreEntry& CSWICertStoreEntryList::GetByHandleL(const TCTTokenObjectHandle& aHandle) const sl@0: { sl@0: TInt index = KErrNotFound; sl@0: sl@0: for (TInt i = 0 ; i < iEntries.Count() ; ++i) sl@0: { sl@0: CSWICertStoreEntry* entry = iEntries[i]; sl@0: if (aHandle == entry->CertInfo().Handle()) sl@0: { sl@0: index = i; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: User::LeaveIfError(index); sl@0: return GetByIndex(index); sl@0: }