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