os/security/contentmgmt/contentaccessfwfordrm/source/caf/attribute.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/contentmgmt/contentaccessfwfordrm/source/caf/attribute.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,156 @@
     1.4 +/*
     1.5 +* Copyright (c) 2003-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 +#ifndef REMOVE_CAF1
    1.23 +
    1.24 +#include <e32std.h>
    1.25 +#include <caf/caftypes.h>
    1.26 +#include <caf/attribute.h>
    1.27 +#include <caf/agentinterface.h>
    1.28 +#include <caf/agentfactory.h>
    1.29 +#include "agentinfo.h"
    1.30 +#include <caf/bitset.h>
    1.31 +#include <caf/attributeset.h>
    1.32 +
    1.33 +using namespace ContentAccess;
    1.34 +
    1.35 +// Maximum number of attributes in CAF 1.0
    1.36 +const TInt KAttrTop = 10;
    1.37 +
    1.38 +CAttribute* CAttribute::NewLC(TUid aAgentUid, RFile &aFile)
    1.39 +	{
    1.40 +	CAttribute* self = new(ELeave) CAttribute();
    1.41 +	CleanupStack::PushL(self);
    1.42 +	self->ConstructL(aAgentUid, aFile);
    1.43 +	return self;
    1.44 +	}
    1.45 +
    1.46 +CAttribute* CAttribute::NewLC(TUid aAgentUid, const TDesC& aURI, TContentShareMode aShareMode)
    1.47 +	{
    1.48 +	CAttribute* self = new(ELeave) CAttribute();
    1.49 +	CleanupStack::PushL(self);
    1.50 +	self->ConstructL(aAgentUid, aURI, aShareMode);
    1.51 +	return self;
    1.52 +	}
    1.53 +	
    1.54 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
    1.55 +CAttribute* CAttribute::NewLC(TUid aAgentUid, const TDesC8& aHeaderData)
    1.56 +	{
    1.57 +	CAttribute* self = new(ELeave) CAttribute();
    1.58 +	CleanupStack::PushL(self);
    1.59 +	self->ConstructL(aAgentUid, aHeaderData);
    1.60 +	return self;
    1.61 +	}
    1.62 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
    1.63 +
    1.64 +CAttribute::CAttribute()
    1.65 +	{
    1.66 +	}
    1.67 +
    1.68 +CAttribute::~CAttribute() 
    1.69 +	{ 
    1.70 +	// delete the attribute sets
    1.71 +	delete iQuerySet;
    1.72 +	delete iResponseSet;
    1.73 +
    1.74 +	// Terminate the agent implementation
    1.75 +	delete iAgentContent;
    1.76 +	delete iAgentFactory;
    1.77 +	REComSession::FinalClose();
    1.78 +	}
    1.79 +
    1.80 +void CAttribute::ConstructL(TUid aAgentUid, const TDesC& aURI, TContentShareMode aShareMode)
    1.81 +	{
    1.82 +	// create a agent factory implementation (pseudo ECOM handle)
    1.83 +	iAgentFactory = CAgentFactory::NewL(aAgentUid);
    1.84 +	iAgentContent = iAgentFactory->CreateContentBrowserL(aURI, aShareMode);
    1.85 +
    1.86 +	iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop));
    1.87 +	iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop));
    1.88 +    }
    1.89 +
    1.90 +void CAttribute::ConstructL(TUid aAgentUid, RFile& aFile)
    1.91 +	{
    1.92 +	// create a agent factory implementation (pseudo ECOM handle)
    1.93 +	iAgentFactory = CAgentFactory::NewL(aAgentUid);
    1.94 +	iAgentContent = iAgentFactory->CreateContentBrowserL(aFile);
    1.95 +
    1.96 +	iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop));
    1.97 +	iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop));
    1.98 +    }
    1.99 +
   1.100 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   1.101 +void CAttribute::ConstructL(TUid aAgentUid, const TDesC8& aHeaderData)
   1.102 +	{
   1.103 +	// create a agent factory implementation (pseudo ECOM handle)
   1.104 +	iAgentFactory = CAgentFactory::NewL(aAgentUid);
   1.105 +	iAgentContent = iAgentFactory->CreateContentBrowserL(aHeaderData);
   1.106 +
   1.107 +	iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop));
   1.108 +	iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop));
   1.109 +    }
   1.110 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   1.111 +
   1.112 +EXPORT_C void CAttribute::Reset()
   1.113 +	{
   1.114 +	iQuerySet->Reset();
   1.115 +	iResponseSet->Reset();
   1.116 +	}
   1.117 +
   1.118 +EXPORT_C CBitset& CAttribute::QuerySet()
   1.119 +	{
   1.120 +	ASSERT(iQuerySet);
   1.121 +	return *iQuerySet;
   1.122 +	}
   1.123 +
   1.124 +EXPORT_C const CBitset& CAttribute::ResponseSet() const
   1.125 +	{
   1.126 +	ASSERT(iResponseSet);
   1.127 +	return *iResponseSet;
   1.128 +	}
   1.129 +
   1.130 +EXPORT_C void CAttribute::GetL()
   1.131 +	{
   1.132 +	TInt i = 0;
   1.133 +	TInt value = 0;
   1.134 +	TInt err = KErrNone;
   1.135 +
   1.136 +	RAttributeSet aAttributeSet;
   1.137 +	CleanupClosePushL(aAttributeSet);
   1.138 +	
   1.139 +	for(i=0 ;i < KAttrTop ;i++ )
   1.140 +		{
   1.141 +		if(iQuerySet->IsSet(i))
   1.142 +			{
   1.143 +			aAttributeSet.AddL(i);
   1.144 +			}
   1.145 +		}
   1.146 +	iAgentContent ->GetAttributeSet(aAttributeSet, KDefaultContentObject());
   1.147 +	
   1.148 +	for( i = 0; i < KAttrTop; i++)
   1.149 +		{
   1.150 +		err = aAttributeSet.GetValue(i, value);
   1.151 +		if(err == KErrNone && value == (TInt) ETrue)
   1.152 +			{
   1.153 +			iResponseSet->Set(i);
   1.154 +			}
   1.155 +		}
   1.156 +	CleanupStack::PopAndDestroy(&aAttributeSet);
   1.157 +	}
   1.158 +
   1.159 +#endif // REMOVE_CAF1