os/security/securityanddataprivacytools/securitytools/certapp/encdec/swicertstore.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2008-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 "swicertstore.h"
sl@0
    20
static const EnumEntry enumDetailsForTBool[] =
sl@0
    21
{
sl@0
    22
    { "false", false},
sl@0
    23
    { "true", true},
sl@0
    24
    { "EFalse", false},
sl@0
    25
    { "ETrue", true},
sl@0
    26
	{ 0,0 }
sl@0
    27
};
sl@0
    28
sl@0
    29
EncDecContainerItem *SwiCertStoreEntry::Factory()
sl@0
    30
{
sl@0
    31
	return new SwiCertStoreEntry;
sl@0
    32
}
sl@0
    33
sl@0
    34
SwiCertStoreEntry::SwiCertStoreEntry()
sl@0
    35
	: CertStoreEntry(true),
sl@0
    36
	  iCapabilitySet("CapabilitySet"), 
sl@0
    37
	  iTmpFlags("Mandatory/SystemUpgrade"),
sl@0
    38
	  iMandatory("Mandatory", enumDetailsForTBool),
sl@0
    39
	  iSystemUpgrade("SystemUpgrade", enumDetailsForTBool)
sl@0
    40
{
sl@0
    41
	// We only need to initialise EncDecObject members which wrap non-class types
sl@0
    42
	iTmpFlags.Value() = 0;
sl@0
    43
}
sl@0
    44
sl@0
    45
SwiCertStoreEntry::~SwiCertStoreEntry()
sl@0
    46
{
sl@0
    47
}
sl@0
    48
sl@0
    49
const int KMandatoryMask = 0x01;
sl@0
    50
const int KSystemUpgradeMask = 0x02;
sl@0
    51
sl@0
    52
void SwiCertStoreEntry::Encode(REncodeWriteStream &aWriteStream)
sl@0
    53
{
sl@0
    54
	CertStoreEntry::Encode(aWriteStream);
sl@0
    55
	aWriteStream << iCapabilitySet;
sl@0
    56
	if(aWriteStream.HumanReadable())
sl@0
    57
		{
sl@0
    58
		// Write the Mandatory and SystemUpgrade fields
sl@0
    59
		aWriteStream << iMandatory;
sl@0
    60
		aWriteStream << iSystemUpgrade;
sl@0
    61
		}
sl@0
    62
	else
sl@0
    63
		{
sl@0
    64
		// Encode the Mandatory and SystemUpgrade values and write the binary field
sl@0
    65
		TUint8 tmp = 0;
sl@0
    66
		if(iMandatory.Value())
sl@0
    67
			{
sl@0
    68
			tmp |= KMandatoryMask;
sl@0
    69
			}
sl@0
    70
		
sl@0
    71
		if(iSystemUpgrade.Value())
sl@0
    72
			{
sl@0
    73
			tmp |= KSystemUpgradeMask;
sl@0
    74
			}
sl@0
    75
		
sl@0
    76
		iTmpFlags.Value() = tmp;
sl@0
    77
		aWriteStream << iTmpFlags;
sl@0
    78
		}
sl@0
    79
sl@0
    80
}
sl@0
    81
sl@0
    82
void SwiCertStoreEntry::Decode(RDecodeReadStream &aReadStream)
sl@0
    83
{
sl@0
    84
	CertStoreEntry::Decode(aReadStream);
sl@0
    85
	aReadStream >> iCapabilitySet;
sl@0
    86
sl@0
    87
	if(aReadStream.HumanReadable())
sl@0
    88
		{
sl@0
    89
		// Read the Mandatory and SystemUpgrade fields
sl@0
    90
		if(aReadStream.PeakToken() == iMandatory.Name())
sl@0
    91
			{
sl@0
    92
			aReadStream >> iMandatory;
sl@0
    93
			}
sl@0
    94
		else
sl@0
    95
			{
sl@0
    96
			iMandatory.SetValue("false");
sl@0
    97
			}
sl@0
    98
			if(aReadStream.PeakToken() == iSystemUpgrade.Name())
sl@0
    99
			{
sl@0
   100
			aReadStream >> iSystemUpgrade;
sl@0
   101
			}
sl@0
   102
		else
sl@0
   103
			{
sl@0
   104
			iSystemUpgrade.SetValue("false");
sl@0
   105
			}
sl@0
   106
		}
sl@0
   107
	else
sl@0
   108
		{
sl@0
   109
		// Read the binary field and decode the Mandatory and SystemUpgrade values
sl@0
   110
		aReadStream >> iTmpFlags;
sl@0
   111
		iMandatory.SetValue((iTmpFlags.Value() & KMandatoryMask) != 0);
sl@0
   112
		iSystemUpgrade.SetValue((iTmpFlags.Value() & KSystemUpgradeMask) != 0);
sl@0
   113
		}
sl@0
   114
}
sl@0
   115
sl@0
   116
SwiCertStoreEntry& SwiCertStoreEntry::operator= (const SwiCertStoreEntry& aRhs)
sl@0
   117
{
sl@0
   118
	if(this == &aRhs) return *this; // handle self assignment
sl@0
   119
sl@0
   120
	// Copy base class members
sl@0
   121
	CertStoreEntry::operator=(*static_cast<const CertStoreEntry *>(&aRhs));
sl@0
   122
sl@0
   123
	// Copy our additional members
sl@0
   124
	iCapabilitySet = aRhs.iCapabilitySet;
sl@0
   125
	// iTmpFlags does not need copying
sl@0
   126
	iMandatory = aRhs.iMandatory;
sl@0
   127
	iSystemUpgrade = aRhs.iSystemUpgrade;
sl@0
   128
sl@0
   129
	return *this;
sl@0
   130
}
sl@0
   131
sl@0
   132
sl@0
   133
// End of file