os/security/contentmgmt/contentaccessfwfordrm/source/cafutils/rightsinfo.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include <s32strm.h>
    20 
    21 #include <caf/rightsinfo.h>
    22 #include <caf/agent.h>
    23 #include "cafutils.h"
    24 
    25 using namespace ContentAccess;
    26 
    27 EXPORT_C CRightsInfo* CRightsInfo::NewL(RReadStream& aStream)
    28 	{
    29 	CRightsInfo* self = new (ELeave) CRightsInfo;
    30 	CleanupStack::PushL(self);
    31 	self->InternalizeL(aStream);
    32 	CleanupStack::Pop(self);
    33 	return self;
    34 	}
    35 
    36 EXPORT_C CRightsInfo* CRightsInfo::NewL(const TDesC& aDescription, const TDesC& aUniqueId, TInt aRightsType, TRightsStatus aRightsStatus)
    37 	{
    38 	CRightsInfo* self = new (ELeave) CRightsInfo(aRightsType, aRightsStatus);
    39 	CleanupStack::PushL(self);
    40 	self->ConstructL(aDescription, aUniqueId);
    41 	CleanupStack::Pop(self);
    42 	return self;
    43 	}
    44 
    45 CRightsInfo::CRightsInfo()
    46 	{
    47 	}
    48 
    49 CRightsInfo::CRightsInfo(TInt aRightsType, TRightsStatus aRightsStatus) :
    50 		iRightsType(aRightsType), iRightsStatus(aRightsStatus)
    51 	{
    52 	}
    53 	
    54 
    55 CRightsInfo::~CRightsInfo()
    56 	{
    57 	delete iDescription;
    58 	delete iUniqueId;
    59 	}	
    60 
    61 void CRightsInfo::ConstructL(const TDesC& aDescription, const TDesC& aUniqueId)
    62 	{
    63 	iDescription = aDescription.AllocL();
    64 	iUniqueId = aUniqueId.AllocL();
    65 	}
    66 	
    67 EXPORT_C const TDesC& CRightsInfo::Description() const
    68 	{
    69 	return *iDescription;
    70 	}
    71 
    72 EXPORT_C const TDesC& CRightsInfo::UniqueId() const
    73 	{
    74 	return *iUniqueId;
    75 	}
    76 
    77 EXPORT_C TInt CRightsInfo::RightsType() const
    78 	{
    79 	return iRightsType;
    80 	}
    81 
    82 EXPORT_C TRightsStatus CRightsInfo::RightsStatus() const
    83 	{
    84 	return iRightsStatus;
    85 	}
    86 
    87 EXPORT_C void CRightsInfo::ExternalizeL(RWriteStream &aStream) const
    88 	{
    89 	TCafUtils::WriteDescriptor16L(aStream, *iDescription);
    90 	TCafUtils::WriteDescriptor16L(aStream, *iUniqueId);
    91 	aStream.WriteInt32L(iRightsType);
    92 	aStream.WriteInt32L((TInt) iRightsStatus);
    93 	}
    94 
    95 void CRightsInfo::InternalizeL(RReadStream& aStream)
    96 	{
    97 	iDescription = TCafUtils::ReadDescriptor16L(aStream);
    98 	iUniqueId = TCafUtils::ReadDescriptor16L(aStream);
    99 	iRightsType = aStream.ReadInt32L();
   100 	iRightsStatus = (TRightsStatus) aStream.ReadInt32L();
   101 	}