os/security/securityanddataprivacytools/securitytools/certapp/encdec/swicertstore.cpp
Update contrib.
2 * Copyright (c) 2008-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 "swicertstore.h"
20 static const EnumEntry enumDetailsForTBool[] =
29 EncDecContainerItem *SwiCertStoreEntry::Factory()
31 return new SwiCertStoreEntry;
34 SwiCertStoreEntry::SwiCertStoreEntry()
35 : CertStoreEntry(true),
36 iCapabilitySet("CapabilitySet"),
37 iTmpFlags("Mandatory/SystemUpgrade"),
38 iMandatory("Mandatory", enumDetailsForTBool),
39 iSystemUpgrade("SystemUpgrade", enumDetailsForTBool)
41 // We only need to initialise EncDecObject members which wrap non-class types
42 iTmpFlags.Value() = 0;
45 SwiCertStoreEntry::~SwiCertStoreEntry()
49 const int KMandatoryMask = 0x01;
50 const int KSystemUpgradeMask = 0x02;
52 void SwiCertStoreEntry::Encode(REncodeWriteStream &aWriteStream)
54 CertStoreEntry::Encode(aWriteStream);
55 aWriteStream << iCapabilitySet;
56 if(aWriteStream.HumanReadable())
58 // Write the Mandatory and SystemUpgrade fields
59 aWriteStream << iMandatory;
60 aWriteStream << iSystemUpgrade;
64 // Encode the Mandatory and SystemUpgrade values and write the binary field
66 if(iMandatory.Value())
68 tmp |= KMandatoryMask;
71 if(iSystemUpgrade.Value())
73 tmp |= KSystemUpgradeMask;
76 iTmpFlags.Value() = tmp;
77 aWriteStream << iTmpFlags;
82 void SwiCertStoreEntry::Decode(RDecodeReadStream &aReadStream)
84 CertStoreEntry::Decode(aReadStream);
85 aReadStream >> iCapabilitySet;
87 if(aReadStream.HumanReadable())
89 // Read the Mandatory and SystemUpgrade fields
90 if(aReadStream.PeakToken() == iMandatory.Name())
92 aReadStream >> iMandatory;
96 iMandatory.SetValue("false");
98 if(aReadStream.PeakToken() == iSystemUpgrade.Name())
100 aReadStream >> iSystemUpgrade;
104 iSystemUpgrade.SetValue("false");
109 // Read the binary field and decode the Mandatory and SystemUpgrade values
110 aReadStream >> iTmpFlags;
111 iMandatory.SetValue((iTmpFlags.Value() & KMandatoryMask) != 0);
112 iSystemUpgrade.SetValue((iTmpFlags.Value() & KSystemUpgradeMask) != 0);
116 SwiCertStoreEntry& SwiCertStoreEntry::operator= (const SwiCertStoreEntry& aRhs)
118 if(this == &aRhs) return *this; // handle self assignment
120 // Copy base class members
121 CertStoreEntry::operator=(*static_cast<const CertStoreEntry *>(&aRhs));
123 // Copy our additional members
124 iCapabilitySet = aRhs.iCapabilitySet;
125 // iTmpFlags does not need copying
126 iMandatory = aRhs.iMandatory;
127 iSystemUpgrade = aRhs.iSystemUpgrade;