os/security/contentmgmt/contentaccessfwfordrm/source/cafutils/rightsinfo.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/contentmgmt/contentaccessfwfordrm/source/cafutils/rightsinfo.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,101 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include <s32strm.h>
    1.23 +
    1.24 +#include <caf/rightsinfo.h>
    1.25 +#include <caf/agent.h>
    1.26 +#include "cafutils.h"
    1.27 +
    1.28 +using namespace ContentAccess;
    1.29 +
    1.30 +EXPORT_C CRightsInfo* CRightsInfo::NewL(RReadStream& aStream)
    1.31 +	{
    1.32 +	CRightsInfo* self = new (ELeave) CRightsInfo;
    1.33 +	CleanupStack::PushL(self);
    1.34 +	self->InternalizeL(aStream);
    1.35 +	CleanupStack::Pop(self);
    1.36 +	return self;
    1.37 +	}
    1.38 +
    1.39 +EXPORT_C CRightsInfo* CRightsInfo::NewL(const TDesC& aDescription, const TDesC& aUniqueId, TInt aRightsType, TRightsStatus aRightsStatus)
    1.40 +	{
    1.41 +	CRightsInfo* self = new (ELeave) CRightsInfo(aRightsType, aRightsStatus);
    1.42 +	CleanupStack::PushL(self);
    1.43 +	self->ConstructL(aDescription, aUniqueId);
    1.44 +	CleanupStack::Pop(self);
    1.45 +	return self;
    1.46 +	}
    1.47 +
    1.48 +CRightsInfo::CRightsInfo()
    1.49 +	{
    1.50 +	}
    1.51 +
    1.52 +CRightsInfo::CRightsInfo(TInt aRightsType, TRightsStatus aRightsStatus) :
    1.53 +		iRightsType(aRightsType), iRightsStatus(aRightsStatus)
    1.54 +	{
    1.55 +	}
    1.56 +	
    1.57 +
    1.58 +CRightsInfo::~CRightsInfo()
    1.59 +	{
    1.60 +	delete iDescription;
    1.61 +	delete iUniqueId;
    1.62 +	}	
    1.63 +
    1.64 +void CRightsInfo::ConstructL(const TDesC& aDescription, const TDesC& aUniqueId)
    1.65 +	{
    1.66 +	iDescription = aDescription.AllocL();
    1.67 +	iUniqueId = aUniqueId.AllocL();
    1.68 +	}
    1.69 +	
    1.70 +EXPORT_C const TDesC& CRightsInfo::Description() const
    1.71 +	{
    1.72 +	return *iDescription;
    1.73 +	}
    1.74 +
    1.75 +EXPORT_C const TDesC& CRightsInfo::UniqueId() const
    1.76 +	{
    1.77 +	return *iUniqueId;
    1.78 +	}
    1.79 +
    1.80 +EXPORT_C TInt CRightsInfo::RightsType() const
    1.81 +	{
    1.82 +	return iRightsType;
    1.83 +	}
    1.84 +
    1.85 +EXPORT_C TRightsStatus CRightsInfo::RightsStatus() const
    1.86 +	{
    1.87 +	return iRightsStatus;
    1.88 +	}
    1.89 +
    1.90 +EXPORT_C void CRightsInfo::ExternalizeL(RWriteStream &aStream) const
    1.91 +	{
    1.92 +	TCafUtils::WriteDescriptor16L(aStream, *iDescription);
    1.93 +	TCafUtils::WriteDescriptor16L(aStream, *iUniqueId);
    1.94 +	aStream.WriteInt32L(iRightsType);
    1.95 +	aStream.WriteInt32L((TInt) iRightsStatus);
    1.96 +	}
    1.97 +
    1.98 +void CRightsInfo::InternalizeL(RReadStream& aStream)
    1.99 +	{
   1.100 +	iDescription = TCafUtils::ReadDescriptor16L(aStream);
   1.101 +	iUniqueId = TCafUtils::ReadDescriptor16L(aStream);
   1.102 +	iRightsType = aStream.ReadInt32L();
   1.103 +	iRightsStatus = (TRightsStatus) aStream.ReadInt32L();
   1.104 +	}