os/security/cryptoservices/certificateandkeymgmt/tadditionalstores/tadditionalstoreentries.cpp
Update contrib.
2 * Copyright (c) 2005-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.
23 #include "tadditionalstoremapping.h"
25 ////////////////////////////////////////////////////////////////////////////////
26 //CFileCertStoreMapping
27 /////////////////////////////////////////////////////////////////////////////////
29 CFileCertStoreMapping* CFileCertStoreMapping::NewL()
31 CFileCertStoreMapping* self = CFileCertStoreMapping::NewLC();
32 CleanupStack::Pop(self);
36 CFileCertStoreMapping* CFileCertStoreMapping::NewLC()
38 CFileCertStoreMapping* self = new(ELeave) CFileCertStoreMapping();
39 CleanupStack::PushL(self);
44 void CFileCertStoreMapping::ConstructL()
46 iCertificateApps = new(ELeave) RArray<TUid>();
49 CFileCertStoreMapping::CFileCertStoreMapping()
53 CFileCertStoreMapping::~CFileCertStoreMapping()
61 iCertificateApps->Close();
62 delete iCertificateApps;
66 void CFileCertStoreMapping::SetEntry(CCTCertInfo* aCertInfo)
75 void CFileCertStoreMapping::SetCertificateApps(RArray<TUid>* aCertificateApps)
77 iCertificateApps->Close();
78 delete iCertificateApps;
79 iCertificateApps = aCertificateApps;
82 void CFileCertStoreMapping::SetId(TStreamId aId)
87 CCTCertInfo* CFileCertStoreMapping::Entry() const
92 const RArray<TUid>& CFileCertStoreMapping::CertificateApps() const
94 return *iCertificateApps;
97 TBool CFileCertStoreMapping::IsApplicable(const TUid& aApplication) const
99 TInt count = iCertificateApps->Count();
100 for (TInt i = 0; i < count; i++)
102 TUid app = (*iCertificateApps)[i];
103 if (app == aApplication)
111 TBool CFileCertStoreMapping::Trusted() const
116 void CFileCertStoreMapping::SetTrusted(TBool aTrusted)
121 TStreamId CFileCertStoreMapping::Id() const
126 void CFileCertStoreMapping::ExternalizeL(RWriteStream& aStream) const
131 TInt count = iCertificateApps->Count();
132 aStream.WriteInt32L(count);
133 for (TInt i = 0; i < count; i++)
135 aStream << (*iCertificateApps)[i];
137 aStream.WriteUint8L(iTrusted);
142 void CFileCertStoreMapping::SetTempRemoved(TBool aFlag)
147 TBool CFileCertStoreMapping::IsTempRemoved()
152 #include "tadditionalstoremappings.h"
154 /////////////////////////////////////////////////////////////////////////////////
155 //CFileCertStoreMappings
156 /////////////////////////////////////////////////////////////////////////////////
157 CFileCertStoreMappings::~CFileCertStoreMappings()
161 iMappings->ResetAndDestroy();
166 TInt CFileCertStoreMappings::Count()
168 return iMappings->Count();
171 void CFileCertStoreMappings::AddL(CFileCertStoreMapping* aEntry)
173 User::LeaveIfError(iMappings->Append(aEntry));
176 TInt CFileCertStoreMappings::Remove(const CCTCertInfo& aCertInfo)
178 TInt index = Index(aCertInfo);
179 if (index == KErrNotFound)
183 CFileCertStoreMapping* mapping = (*iMappings)[index];
184 iMappings->Remove(index);
189 TInt CFileCertStoreMappings::SetTempRemove(const CCTCertInfo& aCertInfo, TBool aFlag)
191 TInt index = Index(aCertInfo);
192 if (index == KErrNotFound)
196 (*iMappings)[index]->SetTempRemoved(aFlag);
201 void CFileCertStoreMappings::ExternalizeL(RWriteStream& aStream) const
203 TInt count = iMappings->Count();
204 TInt realCount=count;
206 for (i = 0; i < count; i++)
208 if ((*iMappings)[i]->IsTempRemoved())
213 aStream.WriteInt32L(realCount);
214 for (i = 0; i < count; i++)
216 aStream << *(*iMappings)[i];
220 void CFileCertStoreMappings::ReplaceL()
222 RStoreWriteStream stream;
223 stream.ReplaceLC(iStore, iStreamId);
224 ExternalizeL(stream);
226 CleanupStack::PopAndDestroy();
229 TInt CFileCertStoreMappings::Index(const CCTCertInfo& aCertInfo)
231 TInt count = iMappings->Count();
232 TInt ix = KErrNotFound;
233 for (TInt i = 0; i < count; i++)
235 CFileCertStoreMapping* mapping = (*iMappings)[i];
236 if (aCertInfo==*(mapping->Entry()))
245 CFileCertStoreMapping* CFileCertStoreMappings::Mapping(TInt aIndex)
247 return (*iMappings)[aIndex];
250 TStreamId CFileCertStoreMappings::StreamId() const
255 CFileCertStoreMappings::CFileCertStoreMappings(TStreamId aStreamId,
256 CPermanentFileStore& aStore)
257 :iStreamId(aStreamId), iStore(aStore)
261 /////////////////////////////////////////////////////////////////////////////////
262 //CFileCertStoreMappings
263 /////////////////////////////////////////////////////////////////////////////////
264 CFileCertStoreMappings* CFileCertStoreMappings::NewL(TStreamId aStreamId,
265 CPermanentFileStore& aStore)
267 CFileCertStoreMappings* self = new(ELeave) CFileCertStoreMappings(aStreamId, aStore);
268 CleanupStack::PushL(self);
274 const CCTCertInfo& CFileCertStoreMappings::Entry(TInt aIndex)
276 CFileCertStoreMapping* mapping = (*iMappings)[aIndex];
277 return *mapping->Entry();
280 const CCTCertInfo& CFileCertStoreMappings::EntryByHandleL(TInt aHandle) const
282 TInt count = iMappings->Count();
283 for (TInt i = 0; i < count; i++)
285 CFileCertStoreMapping* mapping = (*iMappings)[i];
286 if (aHandle==mapping->Entry()->Handle().iObjectId)
288 return *mapping->Entry();
291 User::Leave(KErrNotFound);
292 CCTCertInfo* info = NULL; // This is to shut up a compiler warning
296 TInt CFileCertStoreMappings::NextHandle() const
298 TInt count = iMappings->Count();
300 for (TInt i = 0; i < count; i++)
302 CFileCertStoreMapping* mapping = (*iMappings)[i];
303 if (mapping->Entry()->Handle().iObjectId > maxHandle)
305 maxHandle = mapping->Entry()->Handle().iObjectId;
311 void CFileCertStoreMappings::ConstructL()
313 iMappings = new(ELeave) RPointerArray<CFileCertStoreMapping>;