sl@0: /* sl@0: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef REMOVE_CAF1 sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "agentinfo.h" sl@0: #include sl@0: #include sl@0: sl@0: using namespace ContentAccess; sl@0: sl@0: // Maximum number of attributes in CAF 1.0 sl@0: const TInt KAttrTop = 10; sl@0: sl@0: CAttribute* CAttribute::NewLC(TUid aAgentUid, RFile &aFile) sl@0: { sl@0: CAttribute* self = new(ELeave) CAttribute(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aAgentUid, aFile); sl@0: return self; sl@0: } sl@0: sl@0: CAttribute* CAttribute::NewLC(TUid aAgentUid, const TDesC& aURI, TContentShareMode aShareMode) sl@0: { sl@0: CAttribute* self = new(ELeave) CAttribute(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aAgentUid, aURI, aShareMode); sl@0: return self; sl@0: } sl@0: sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: CAttribute* CAttribute::NewLC(TUid aAgentUid, const TDesC8& aHeaderData) sl@0: { sl@0: CAttribute* self = new(ELeave) CAttribute(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aAgentUid, aHeaderData); sl@0: return self; sl@0: } sl@0: #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: CAttribute::CAttribute() sl@0: { sl@0: } sl@0: sl@0: CAttribute::~CAttribute() sl@0: { sl@0: // delete the attribute sets sl@0: delete iQuerySet; sl@0: delete iResponseSet; sl@0: sl@0: // Terminate the agent implementation sl@0: delete iAgentContent; sl@0: delete iAgentFactory; sl@0: REComSession::FinalClose(); sl@0: } sl@0: sl@0: void CAttribute::ConstructL(TUid aAgentUid, const TDesC& aURI, TContentShareMode aShareMode) sl@0: { sl@0: // create a agent factory implementation (pseudo ECOM handle) sl@0: iAgentFactory = CAgentFactory::NewL(aAgentUid); sl@0: iAgentContent = iAgentFactory->CreateContentBrowserL(aURI, aShareMode); sl@0: sl@0: iQuerySet = CBitset::NewL(static_cast(KAttrTop)); sl@0: iResponseSet = CBitset::NewL(static_cast(KAttrTop)); sl@0: } sl@0: sl@0: void CAttribute::ConstructL(TUid aAgentUid, RFile& aFile) sl@0: { sl@0: // create a agent factory implementation (pseudo ECOM handle) sl@0: iAgentFactory = CAgentFactory::NewL(aAgentUid); sl@0: iAgentContent = iAgentFactory->CreateContentBrowserL(aFile); sl@0: sl@0: iQuerySet = CBitset::NewL(static_cast(KAttrTop)); sl@0: iResponseSet = CBitset::NewL(static_cast(KAttrTop)); sl@0: } sl@0: sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: void CAttribute::ConstructL(TUid aAgentUid, const TDesC8& aHeaderData) sl@0: { sl@0: // create a agent factory implementation (pseudo ECOM handle) sl@0: iAgentFactory = CAgentFactory::NewL(aAgentUid); sl@0: iAgentContent = iAgentFactory->CreateContentBrowserL(aHeaderData); sl@0: sl@0: iQuerySet = CBitset::NewL(static_cast(KAttrTop)); sl@0: iResponseSet = CBitset::NewL(static_cast(KAttrTop)); sl@0: } sl@0: #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: EXPORT_C void CAttribute::Reset() sl@0: { sl@0: iQuerySet->Reset(); sl@0: iResponseSet->Reset(); sl@0: } sl@0: sl@0: EXPORT_C CBitset& CAttribute::QuerySet() sl@0: { sl@0: ASSERT(iQuerySet); sl@0: return *iQuerySet; sl@0: } sl@0: sl@0: EXPORT_C const CBitset& CAttribute::ResponseSet() const sl@0: { sl@0: ASSERT(iResponseSet); sl@0: return *iResponseSet; sl@0: } sl@0: sl@0: EXPORT_C void CAttribute::GetL() sl@0: { sl@0: TInt i = 0; sl@0: TInt value = 0; sl@0: TInt err = KErrNone; sl@0: sl@0: RAttributeSet aAttributeSet; sl@0: CleanupClosePushL(aAttributeSet); sl@0: sl@0: for(i=0 ;i < KAttrTop ;i++ ) sl@0: { sl@0: if(iQuerySet->IsSet(i)) sl@0: { sl@0: aAttributeSet.AddL(i); sl@0: } sl@0: } sl@0: iAgentContent ->GetAttributeSet(aAttributeSet, KDefaultContentObject()); sl@0: sl@0: for( i = 0; i < KAttrTop; i++) sl@0: { sl@0: err = aAttributeSet.GetValue(i, value); sl@0: if(err == KErrNone && value == (TInt) ETrue) sl@0: { sl@0: iResponseSet->Set(i); sl@0: } sl@0: } sl@0: CleanupStack::PopAndDestroy(&aAttributeSet); sl@0: } sl@0: sl@0: #endif // REMOVE_CAF1