First public contribution.
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
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>
30 using namespace ContentAccess;
32 // Maximum number of attributes in CAF 1.0
33 const TInt KAttrTop = 10;
35 CAttribute* CAttribute::NewLC(TUid aAgentUid, RFile &aFile)
37 CAttribute* self = new(ELeave) CAttribute();
38 CleanupStack::PushL(self);
39 self->ConstructL(aAgentUid, aFile);
43 CAttribute* CAttribute::NewLC(TUid aAgentUid, const TDesC& aURI, TContentShareMode aShareMode)
45 CAttribute* self = new(ELeave) CAttribute();
46 CleanupStack::PushL(self);
47 self->ConstructL(aAgentUid, aURI, aShareMode);
51 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
52 CAttribute* CAttribute::NewLC(TUid aAgentUid, const TDesC8& aHeaderData)
54 CAttribute* self = new(ELeave) CAttribute();
55 CleanupStack::PushL(self);
56 self->ConstructL(aAgentUid, aHeaderData);
59 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
61 CAttribute::CAttribute()
65 CAttribute::~CAttribute()
67 // delete the attribute sets
71 // Terminate the agent implementation
74 REComSession::FinalClose();
77 void CAttribute::ConstructL(TUid aAgentUid, const TDesC& aURI, TContentShareMode aShareMode)
79 // create a agent factory implementation (pseudo ECOM handle)
80 iAgentFactory = CAgentFactory::NewL(aAgentUid);
81 iAgentContent = iAgentFactory->CreateContentBrowserL(aURI, aShareMode);
83 iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop));
84 iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop));
87 void CAttribute::ConstructL(TUid aAgentUid, RFile& aFile)
89 // create a agent factory implementation (pseudo ECOM handle)
90 iAgentFactory = CAgentFactory::NewL(aAgentUid);
91 iAgentContent = iAgentFactory->CreateContentBrowserL(aFile);
93 iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop));
94 iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop));
97 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
98 void CAttribute::ConstructL(TUid aAgentUid, const TDesC8& aHeaderData)
100 // create a agent factory implementation (pseudo ECOM handle)
101 iAgentFactory = CAgentFactory::NewL(aAgentUid);
102 iAgentContent = iAgentFactory->CreateContentBrowserL(aHeaderData);
104 iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop));
105 iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop));
107 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
109 EXPORT_C void CAttribute::Reset()
112 iResponseSet->Reset();
115 EXPORT_C CBitset& CAttribute::QuerySet()
121 EXPORT_C const CBitset& CAttribute::ResponseSet() const
123 ASSERT(iResponseSet);
124 return *iResponseSet;
127 EXPORT_C void CAttribute::GetL()
133 RAttributeSet aAttributeSet;
134 CleanupClosePushL(aAttributeSet);
136 for(i=0 ;i < KAttrTop ;i++ )
138 if(iQuerySet->IsSet(i))
140 aAttributeSet.AddL(i);
143 iAgentContent ->GetAttributeSet(aAttributeSet, KDefaultContentObject());
145 for( i = 0; i < KAttrTop; i++)
147 err = aAttributeSet.GetValue(i, value);
148 if(err == KErrNone && value == (TInt) ETrue)
150 iResponseSet->Set(i);
153 CleanupStack::PopAndDestroy(&aAttributeSet);
156 #endif // REMOVE_CAF1