sl@0: /* sl@0: * Copyright (c) 1998-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 "CSWICertStoreEntry.h" sl@0: #include sl@0: sl@0: CSWICertStoreEntry* CSWICertStoreEntry::NewLC(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex, TInt aStoreIndex) sl@0: { sl@0: CSWICertStoreEntry* self = new(ELeave) CSWICertStoreEntry(aStoreIndex); sl@0: CleanupStack::PushL(self); sl@0: sl@0: self->InternalizeL(aStream, aToken, aCertIndex); sl@0: return self; sl@0: } sl@0: sl@0: CSWICertStoreEntry* CSWICertStoreEntry::NewL(const CCTCertInfo& aCertInfo,const RArray& aCertificateApps,TBool aTrusted,TStreamId aDataStreamId,const TCertMetaInfo& aCertMetaInfo, TInt aStoreIndex) sl@0: { sl@0: CSWICertStoreEntry* self = new(ELeave) CSWICertStoreEntry(aStoreIndex); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aCertInfo, aCertificateApps, aTrusted, aDataStreamId, aCertMetaInfo); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CSWICertStoreEntry::ConstructL(const CCTCertInfo& aCertInfo,const RArray& aCertificateApps,TBool aTrusted,TStreamId aDataStreamId, const TCertMetaInfo& aCertMetaInfo) sl@0: { sl@0: iCertInfo = CCTCertInfo::NewL(aCertInfo); sl@0: sl@0: for (TInt i = 0 ; i < aCertificateApps.Count() ; ++i) sl@0: { sl@0: iCertificateApps.AppendL(aCertificateApps[i]); sl@0: } sl@0: sl@0: iTrusted = aTrusted; sl@0: iDataStreamId = aDataStreamId; sl@0: iCertMetaInfo = aCertMetaInfo; sl@0: } sl@0: sl@0: TInt CSWICertStoreEntry::StoreIndex() const sl@0: { sl@0: return iStoreIndex; sl@0: } sl@0: sl@0: CSWICertStoreEntry::CSWICertStoreEntry(TInt aStoreIndex):iStoreIndex(aStoreIndex) sl@0: { sl@0: } sl@0: sl@0: CSWICertStoreEntry::~CSWICertStoreEntry() sl@0: { sl@0: if (iCertInfo) sl@0: { sl@0: iCertInfo->Release(); sl@0: } sl@0: iCertificateApps.Close(); sl@0: } sl@0: sl@0: void CSWICertStoreEntry::InternalizeL(RReadStream& aStream, MCTToken& aToken, TInt aCertIndex) sl@0: { sl@0: ASSERT(!iCertInfo); sl@0: iCertInfo = CCTCertInfo::NewL(aStream, aToken); sl@0: iCertInfo->SetCertificateId(aCertIndex); sl@0: sl@0: TInt count = aStream.ReadInt32L(); sl@0: for (TInt i = 0 ; i < count ; ++i) sl@0: { sl@0: TUid id; sl@0: aStream >> id; sl@0: User::LeaveIfError(iCertificateApps.Append(id)); sl@0: } sl@0: sl@0: iTrusted = !!aStream.ReadUint8L(); // !! converts TUint8 to TBool sl@0: aStream >> iDataStreamId; sl@0: TPckg capsPckg(iCertMetaInfo.iCapabilities); sl@0: aStream >> capsPckg; sl@0: TUint8 value = aStream.ReadUint8L(); sl@0: iCertMetaInfo.iIsMandatory = !!(value & (1 << KMandatory)); // !! converts TUint8 to TBool sl@0: iCertMetaInfo.iIsSystemUpgrade = !!(value & (1 << KSystemUpgrade)); sl@0: } sl@0: sl@0: const CCTCertInfo& CSWICertStoreEntry::CertInfo() const sl@0: { sl@0: return *iCertInfo; sl@0: } sl@0: sl@0: const RArray& CSWICertStoreEntry::CertificateApps() const sl@0: { sl@0: return iCertificateApps; sl@0: } sl@0: sl@0: TBool CSWICertStoreEntry::IsApplicable(const TUid& aApplication) const sl@0: { sl@0: for (TInt i = 0 ; i < iCertificateApps.Count() ; ++i) sl@0: { sl@0: if (iCertificateApps[i] == aApplication) sl@0: { sl@0: return ETrue; sl@0: } sl@0: } sl@0: return EFalse; sl@0: } sl@0: sl@0: TBool CSWICertStoreEntry::Trusted() const sl@0: { sl@0: return iTrusted; sl@0: } sl@0: sl@0: TStreamId CSWICertStoreEntry::DataStreamId() const sl@0: { sl@0: return iDataStreamId; sl@0: } sl@0: sl@0: const TCertMetaInfo& CSWICertStoreEntry::CertMetaInfo() const sl@0: { sl@0: return iCertMetaInfo; sl@0: } sl@0: sl@0: