|
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 "attribute.h" |
|
24 #include "agentinterface.h" |
|
25 #include "agentfactory.h" |
|
26 #include "agentinfo.h" |
|
27 #include "bitset.h" |
|
28 #include "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 CAttribute::CAttribute() |
|
52 { |
|
53 } |
|
54 |
|
55 CAttribute::~CAttribute() |
|
56 { |
|
57 // delete the attribute sets |
|
58 delete iQuerySet; |
|
59 delete iResponseSet; |
|
60 |
|
61 // Terminate the agent implementation |
|
62 delete iAgentContent; |
|
63 delete iAgentFactory; |
|
64 REComSession::FinalClose(); |
|
65 } |
|
66 |
|
67 void CAttribute::ConstructL(TUid aAgentUid, const TDesC& aURI, TContentShareMode aShareMode) |
|
68 { |
|
69 // create a agent factory implementation (pseudo ECOM handle) |
|
70 iAgentFactory = CAgentFactory::NewL(aAgentUid); |
|
71 iAgentContent = iAgentFactory->CreateContentBrowserL(aURI, aShareMode); |
|
72 |
|
73 iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop)); |
|
74 iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop)); |
|
75 } |
|
76 |
|
77 void CAttribute::ConstructL(TUid aAgentUid, RFile& aFile) |
|
78 { |
|
79 // create a agent factory implementation (pseudo ECOM handle) |
|
80 iAgentFactory = CAgentFactory::NewL(aAgentUid); |
|
81 iAgentContent = iAgentFactory->CreateContentBrowserL(aFile); |
|
82 |
|
83 iQuerySet = CBitset::NewL(static_cast<TInt>(KAttrTop)); |
|
84 iResponseSet = CBitset::NewL(static_cast<TInt>(KAttrTop)); |
|
85 } |
|
86 |
|
87 |
|
88 |
|
89 EXPORT_C void CAttribute::Reset() |
|
90 { |
|
91 iQuerySet->Reset(); |
|
92 iResponseSet->Reset(); |
|
93 } |
|
94 |
|
95 EXPORT_C CBitset& CAttribute::QuerySet() |
|
96 { |
|
97 ASSERT(iQuerySet); |
|
98 return *iQuerySet; |
|
99 } |
|
100 |
|
101 EXPORT_C const CBitset& CAttribute::ResponseSet() const |
|
102 { |
|
103 ASSERT(iResponseSet); |
|
104 return *iResponseSet; |
|
105 } |
|
106 |
|
107 EXPORT_C void CAttribute::GetL() |
|
108 { |
|
109 TInt i = 0; |
|
110 TInt value = 0; |
|
111 TInt err = KErrNone; |
|
112 |
|
113 RAttributeSet aAttributeSet; |
|
114 CleanupClosePushL(aAttributeSet); |
|
115 |
|
116 for(i=0 ;i < KAttrTop ;i++ ) |
|
117 { |
|
118 if(iQuerySet->IsSet(i)) |
|
119 { |
|
120 aAttributeSet.AddL(i); |
|
121 } |
|
122 } |
|
123 iAgentContent ->GetAttributeSet(aAttributeSet, KDefaultContentObject()); |
|
124 |
|
125 for( i = 0; i < KAttrTop; i++) |
|
126 { |
|
127 err = aAttributeSet.GetValue(i, value); |
|
128 if(err == KErrNone && value == (TInt) ETrue) |
|
129 { |
|
130 iResponseSet->Set(i); |
|
131 } |
|
132 } |
|
133 CleanupStack::PopAndDestroy(&aAttributeSet); |
|
134 } |
|
135 |
|
136 #endif // REMOVE_CAF1 |