os/security/cryptoservices/certificateandkeymgmt/swicertstore/CSWICertStoreEntryList.cpp
First public contribution.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "CSWICertStoreEntryList.h"
20 #include "CSWICertStoreEntry.h"
21 #include <cctcertinfo.h>
23 CSWICertStoreEntryList* CSWICertStoreEntryList::NewL(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex, TInt aStoreIndex)
25 CSWICertStoreEntryList* self = new(ELeave) CSWICertStoreEntryList();
26 CleanupStack::PushL(self);
27 self->InternalizeL(aStream, aToken, aCertIndex, aStoreIndex);
28 CleanupStack::Pop(self);
32 CSWICertStoreEntryList* CSWICertStoreEntryList::NewL()
34 CSWICertStoreEntryList* self = new(ELeave) CSWICertStoreEntryList();
38 CSWICertStoreEntryList::CSWICertStoreEntryList()
42 CSWICertStoreEntryList::~CSWICertStoreEntryList()
44 iEntries.ResetAndDestroy();
48 void CSWICertStoreEntryList::InternalizeL(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex, TInt aStoreIndex)
50 TInt count = aStream.ReadInt32L();
52 for (TInt i = 0 ; i < count ; ++i)
54 CSWICertStoreEntry* entry = CSWICertStoreEntry::NewLC(aStream, aToken, aCertIndex+i, aStoreIndex);
55 iEntries.AppendL(entry);
56 CleanupStack::Pop(entry);
60 TInt CSWICertStoreEntryList::Count() const
62 return iEntries.Count();
65 TBool CSWICertStoreEntryList::LabelExists(const TDesC& aLabel) const
67 TInt count = iEntries.Count();
68 for (TInt i = 0 ; i < count ; ++i)
70 CSWICertStoreEntry* entry = iEntries[i];
71 if (entry->CertInfo().Label() == aLabel)
79 TInt CSWICertStoreEntryList::AppendL(CSWICertStoreEntry* aCertInfo)
81 User::LeaveIfError(iEntries.Append(aCertInfo));
82 return iEntries.Count() - 1;
85 void CSWICertStoreEntryList::Remove(TInt aIndex)
87 CSWICertStoreEntry* entry = iEntries[aIndex];
88 iEntries.Remove(aIndex);
92 const CSWICertStoreEntry& CSWICertStoreEntryList::GetByIndex(TInt aIndex) const
94 return *iEntries[aIndex];
97 const CSWICertStoreEntry& CSWICertStoreEntryList::GetByHandleL(const TCTTokenObjectHandle& aHandle) const
99 TInt index = KErrNotFound;
101 for (TInt i = 0 ; i < iEntries.Count() ; ++i)
103 CSWICertStoreEntry* entry = iEntries[i];
104 if (aHandle == entry->CertInfo().Handle())
111 User::LeaveIfError(index);
112 return GetByIndex(index);