os/security/contentmgmt/contentaccessfwfordrm/source/caf/attribute.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) 2003-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 #ifndef REMOVE_CAF1
    20 
    21 #include <e32std.h>
    22 #include <caf/caftypes.h>
    23 #include <caf/attribute.h>
    24 #include <caf/agentinterface.h>
    25 #include <caf/agentfactory.h>
    26 #include "agentinfo.h"
    27 #include <caf/bitset.h>
    28 #include <caf/attributeset.h>
    29 
    30 using namespace ContentAccess;
    31 
    32 // Maximum number of attributes in CAF 1.0
    33 const TInt KAttrTop = 10;
    34 
    35 CAttribute* CAttribute::NewLC(TUid aAgentUid, RFile &aFile)
    36 	{
    37 	CAttribute* self = new(ELeave) CAttribute();
    38 	CleanupStack::PushL(self);
    39 	self->ConstructL(aAgentUid, aFile);
    40 	return self;
    41 	}
    42 
    43 CAttribute* CAttribute::NewLC(TUid aAgentUid, const TDesC& aURI, TContentShareMode aShareMode)
    44 	{
    45 	CAttribute* self = new(ELeave) CAttribute();
    46 	CleanupStack::PushL(self);
    47 	self->ConstructL(aAgentUid, aURI, aShareMode);
    48 	return self;
    49 	}
    50 	
    51 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
    52 CAttribute* CAttribute::NewLC(TUid aAgentUid, const TDesC8& aHeaderData)
    53 	{
    54 	CAttribute* self = new(ELeave) CAttribute();
    55 	CleanupStack::PushL(self);
    56 	self->ConstructL(aAgentUid, aHeaderData);
    57 	return self;
    58 	}
    59 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
    60 
    61 CAttribute::CAttribute()
    62 	{
    63 	}
    64 
    65 CAttribute::~CAttribute() 
    66 	{ 
    67 	// delete the attribute sets
    68 	delete iQuerySet;
    69 	delete iResponseSet;
    70 
    71 	// Terminate the agent implementation
    72 	delete iAgentContent;
    73 	delete iAgentFactory;
    74 	REComSession::FinalClose();
    75 	}
    76 
    77 void CAttribute::ConstructL(TUid aAgentUid, const TDesC& aURI, TContentShareMode aShareMode)
    78 	{
    79 	// create a agent factory implementation (pseudo ECOM handle)
    80 	iAgentFactory = CAgentFactory::NewL(aAgentUid);
    81 	iAgentContent = iAgentFactory->CreateContentBrowserL(aURI, aShareMode);
    82 
    83 	iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop));
    84 	iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop));
    85     }
    86 
    87 void CAttribute::ConstructL(TUid aAgentUid, RFile& aFile)
    88 	{
    89 	// create a agent factory implementation (pseudo ECOM handle)
    90 	iAgentFactory = CAgentFactory::NewL(aAgentUid);
    91 	iAgentContent = iAgentFactory->CreateContentBrowserL(aFile);
    92 
    93 	iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop));
    94 	iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop));
    95     }
    96 
    97 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
    98 void CAttribute::ConstructL(TUid aAgentUid, const TDesC8& aHeaderData)
    99 	{
   100 	// create a agent factory implementation (pseudo ECOM handle)
   101 	iAgentFactory = CAgentFactory::NewL(aAgentUid);
   102 	iAgentContent = iAgentFactory->CreateContentBrowserL(aHeaderData);
   103 
   104 	iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop));
   105 	iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop));
   106     }
   107 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
   108 
   109 EXPORT_C void CAttribute::Reset()
   110 	{
   111 	iQuerySet->Reset();
   112 	iResponseSet->Reset();
   113 	}
   114 
   115 EXPORT_C CBitset& CAttribute::QuerySet()
   116 	{
   117 	ASSERT(iQuerySet);
   118 	return *iQuerySet;
   119 	}
   120 
   121 EXPORT_C const CBitset& CAttribute::ResponseSet() const
   122 	{
   123 	ASSERT(iResponseSet);
   124 	return *iResponseSet;
   125 	}
   126 
   127 EXPORT_C void CAttribute::GetL()
   128 	{
   129 	TInt i = 0;
   130 	TInt value = 0;
   131 	TInt err = KErrNone;
   132 
   133 	RAttributeSet aAttributeSet;
   134 	CleanupClosePushL(aAttributeSet);
   135 	
   136 	for(i=0 ;i < KAttrTop ;i++ )
   137 		{
   138 		if(iQuerySet->IsSet(i))
   139 			{
   140 			aAttributeSet.AddL(i);
   141 			}
   142 		}
   143 	iAgentContent ->GetAttributeSet(aAttributeSet, KDefaultContentObject());
   144 	
   145 	for( i = 0; i < KAttrTop; i++)
   146 		{
   147 		err = aAttributeSet.GetValue(i, value);
   148 		if(err == KErrNone && value == (TInt) ETrue)
   149 			{
   150 			iResponseSet->Set(i);
   151 			}
   152 		}
   153 	CleanupStack::PopAndDestroy(&aAttributeSet);
   154 	}
   155 
   156 #endif // REMOVE_CAF1