sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "CSWICertStoreEntryList.h"
|
sl@0
|
20 |
#include "CSWICertStoreEntry.h"
|
sl@0
|
21 |
#include <cctcertinfo.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
CSWICertStoreEntryList* CSWICertStoreEntryList::NewL(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex, TInt aStoreIndex)
|
sl@0
|
24 |
{
|
sl@0
|
25 |
CSWICertStoreEntryList* self = new(ELeave) CSWICertStoreEntryList();
|
sl@0
|
26 |
CleanupStack::PushL(self);
|
sl@0
|
27 |
self->InternalizeL(aStream, aToken, aCertIndex, aStoreIndex);
|
sl@0
|
28 |
CleanupStack::Pop(self);
|
sl@0
|
29 |
return self;
|
sl@0
|
30 |
}
|
sl@0
|
31 |
|
sl@0
|
32 |
CSWICertStoreEntryList* CSWICertStoreEntryList::NewL()
|
sl@0
|
33 |
{
|
sl@0
|
34 |
CSWICertStoreEntryList* self = new(ELeave) CSWICertStoreEntryList();
|
sl@0
|
35 |
return self;
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
CSWICertStoreEntryList::CSWICertStoreEntryList()
|
sl@0
|
39 |
{
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
CSWICertStoreEntryList::~CSWICertStoreEntryList()
|
sl@0
|
43 |
{
|
sl@0
|
44 |
iEntries.ResetAndDestroy();
|
sl@0
|
45 |
iEntries.Close();
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
void CSWICertStoreEntryList::InternalizeL(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex, TInt aStoreIndex)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
TInt count = aStream.ReadInt32L();
|
sl@0
|
51 |
|
sl@0
|
52 |
for (TInt i = 0 ; i < count ; ++i)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
CSWICertStoreEntry* entry = CSWICertStoreEntry::NewLC(aStream, aToken, aCertIndex+i, aStoreIndex);
|
sl@0
|
55 |
iEntries.AppendL(entry);
|
sl@0
|
56 |
CleanupStack::Pop(entry);
|
sl@0
|
57 |
}
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
TInt CSWICertStoreEntryList::Count() const
|
sl@0
|
61 |
{
|
sl@0
|
62 |
return iEntries.Count();
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
TBool CSWICertStoreEntryList::LabelExists(const TDesC& aLabel) const
|
sl@0
|
66 |
{
|
sl@0
|
67 |
TInt count = iEntries.Count();
|
sl@0
|
68 |
for (TInt i = 0 ; i < count ; ++i)
|
sl@0
|
69 |
{
|
sl@0
|
70 |
CSWICertStoreEntry* entry = iEntries[i];
|
sl@0
|
71 |
if (entry->CertInfo().Label() == aLabel)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
return ETrue;
|
sl@0
|
74 |
}
|
sl@0
|
75 |
}
|
sl@0
|
76 |
return EFalse;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
TInt CSWICertStoreEntryList::AppendL(CSWICertStoreEntry* aCertInfo)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
User::LeaveIfError(iEntries.Append(aCertInfo));
|
sl@0
|
82 |
return iEntries.Count() - 1;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
void CSWICertStoreEntryList::Remove(TInt aIndex)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
CSWICertStoreEntry* entry = iEntries[aIndex];
|
sl@0
|
88 |
iEntries.Remove(aIndex);
|
sl@0
|
89 |
delete entry;
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
const CSWICertStoreEntry& CSWICertStoreEntryList::GetByIndex(TInt aIndex) const
|
sl@0
|
93 |
{
|
sl@0
|
94 |
return *iEntries[aIndex];
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
const CSWICertStoreEntry& CSWICertStoreEntryList::GetByHandleL(const TCTTokenObjectHandle& aHandle) const
|
sl@0
|
98 |
{
|
sl@0
|
99 |
TInt index = KErrNotFound;
|
sl@0
|
100 |
|
sl@0
|
101 |
for (TInt i = 0 ; i < iEntries.Count() ; ++i)
|
sl@0
|
102 |
{
|
sl@0
|
103 |
CSWICertStoreEntry* entry = iEntries[i];
|
sl@0
|
104 |
if (aHandle == entry->CertInfo().Handle())
|
sl@0
|
105 |
{
|
sl@0
|
106 |
index = i;
|
sl@0
|
107 |
break;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
User::LeaveIfError(index);
|
sl@0
|
112 |
return GetByIndex(index);
|
sl@0
|
113 |
}
|