sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <featdiscovery.h>
|
sl@0
|
19 |
#include <e32cmn.h>
|
sl@0
|
20 |
#include "featdiscoveryimpl.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
// -----------------------------------------------------------------------------
|
sl@0
|
23 |
// TFeatureSet::TFeatureSet()
|
sl@0
|
24 |
// -----------------------------------------------------------------------------
|
sl@0
|
25 |
//
|
sl@0
|
26 |
EXPORT_C TFeatureSet::TFeatureSet() :
|
sl@0
|
27 |
iCount( 0 )
|
sl@0
|
28 |
{
|
sl@0
|
29 |
}
|
sl@0
|
30 |
|
sl@0
|
31 |
// -----------------------------------------------------------------------------
|
sl@0
|
32 |
// TFeatureSet::~TFeatureSet()
|
sl@0
|
33 |
// -----------------------------------------------------------------------------
|
sl@0
|
34 |
//
|
sl@0
|
35 |
EXPORT_C TFeatureSet::~TFeatureSet()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
iStatus.Close();
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
// -----------------------------------------------------------------------------
|
sl@0
|
41 |
// TFeatureSet::Append(TUid)
|
sl@0
|
42 |
// -----------------------------------------------------------------------------
|
sl@0
|
43 |
//
|
sl@0
|
44 |
EXPORT_C TInt TFeatureSet::Append( TUid aFeature )
|
sl@0
|
45 |
{
|
sl@0
|
46 |
TInt err;
|
sl@0
|
47 |
TFeatureStat feature;
|
sl@0
|
48 |
feature.iFeatureID = aFeature;
|
sl@0
|
49 |
feature.iSupported=EFalse;
|
sl@0
|
50 |
|
sl@0
|
51 |
err = iStatus.Append( feature );
|
sl@0
|
52 |
if( err == KErrNone )
|
sl@0
|
53 |
{
|
sl@0
|
54 |
iCount++;
|
sl@0
|
55 |
}
|
sl@0
|
56 |
|
sl@0
|
57 |
return err;
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
// -----------------------------------------------------------------------------
|
sl@0
|
61 |
// TFeatureSet::IsFeatureSupported(TUid)
|
sl@0
|
62 |
// -----------------------------------------------------------------------------
|
sl@0
|
63 |
//
|
sl@0
|
64 |
EXPORT_C TBool TFeatureSet::IsFeatureSupported( TUid aFeature ) const
|
sl@0
|
65 |
{
|
sl@0
|
66 |
TBool featureSupported( EFalse );
|
sl@0
|
67 |
TFeatureStat feature;
|
sl@0
|
68 |
feature.iFeatureID = aFeature;
|
sl@0
|
69 |
TInt index = iStatus.Find( feature );
|
sl@0
|
70 |
if( index != KErrNotFound )
|
sl@0
|
71 |
{
|
sl@0
|
72 |
featureSupported = iStatus[index].iSupported;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
return featureSupported;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
// -----------------------------------------------------------------------------
|
sl@0
|
79 |
// TFeatureSet::AreAllFeaturesSupported()
|
sl@0
|
80 |
// -----------------------------------------------------------------------------
|
sl@0
|
81 |
//
|
sl@0
|
82 |
EXPORT_C TBool TFeatureSet::AreAllFeaturesSupported() const
|
sl@0
|
83 |
{
|
sl@0
|
84 |
//if the request array is empty return true
|
sl@0
|
85 |
if( !iCount ) return ETrue;
|
sl@0
|
86 |
|
sl@0
|
87 |
TBool allSupported( ETrue );
|
sl@0
|
88 |
TInt count( iStatus.Count() );
|
sl@0
|
89 |
|
sl@0
|
90 |
if( count != iCount )
|
sl@0
|
91 |
{
|
sl@0
|
92 |
// Features have been removed from array, because they don't exist.
|
sl@0
|
93 |
allSupported = EFalse;
|
sl@0
|
94 |
}
|
sl@0
|
95 |
else
|
sl@0
|
96 |
{
|
sl@0
|
97 |
for(TInt i(0); i < count; i++)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
if( !iStatus[i].iSupported )
|
sl@0
|
100 |
{
|
sl@0
|
101 |
allSupported = EFalse;
|
sl@0
|
102 |
break;
|
sl@0
|
103 |
}
|
sl@0
|
104 |
}
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
return allSupported;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
// -----------------------------------------------------------------------------
|
sl@0
|
111 |
// TFeatureSet::Count()
|
sl@0
|
112 |
// -----------------------------------------------------------------------------
|
sl@0
|
113 |
//
|
sl@0
|
114 |
TInt TFeatureSet::Count()
|
sl@0
|
115 |
{
|
sl@0
|
116 |
return iStatus.Count();
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
// -----------------------------------------------------------------------------
|
sl@0
|
120 |
// TFeatureSet::Reset()
|
sl@0
|
121 |
// -----------------------------------------------------------------------------
|
sl@0
|
122 |
//
|
sl@0
|
123 |
TUid TFeatureSet::FeatureId( TInt aIndex ) const
|
sl@0
|
124 |
{
|
sl@0
|
125 |
return iStatus[aIndex].iFeatureID;
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
// -----------------------------------------------------------------------------
|
sl@0
|
129 |
// TFeatureSet::Reset()
|
sl@0
|
130 |
// -----------------------------------------------------------------------------
|
sl@0
|
131 |
//
|
sl@0
|
132 |
void TFeatureSet::Reset()
|
sl@0
|
133 |
{
|
sl@0
|
134 |
iStatus.Reset();
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
// -----------------------------------------------------------------------------
|
sl@0
|
138 |
// TFeatureSet::Append()
|
sl@0
|
139 |
// -----------------------------------------------------------------------------
|
sl@0
|
140 |
//
|
sl@0
|
141 |
TInt TFeatureSet::Append( TUid aFeature, TBool aSupported )
|
sl@0
|
142 |
{
|
sl@0
|
143 |
TFeatureStat feature;
|
sl@0
|
144 |
feature.iFeatureID = aFeature;
|
sl@0
|
145 |
feature.iSupported = aSupported;
|
sl@0
|
146 |
|
sl@0
|
147 |
return iStatus.Append( feature );
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
// -----------------------------------------------------------------------------
|
sl@0
|
151 |
// CFeatureDiscovery::CFeatureDiscovery* NewL()
|
sl@0
|
152 |
// -----------------------------------------------------------------------------
|
sl@0
|
153 |
//
|
sl@0
|
154 |
EXPORT_C CFeatureDiscovery* CFeatureDiscovery::NewL()
|
sl@0
|
155 |
{
|
sl@0
|
156 |
CFeatureDiscovery* self = NewLC();
|
sl@0
|
157 |
CleanupStack::Pop( self);
|
sl@0
|
158 |
|
sl@0
|
159 |
return self;
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
|
sl@0
|
163 |
// -----------------------------------------------------------------------------
|
sl@0
|
164 |
// CFeatureDiscovery::CFeatureDiscovery* NewLC()
|
sl@0
|
165 |
// -----------------------------------------------------------------------------
|
sl@0
|
166 |
//
|
sl@0
|
167 |
EXPORT_C CFeatureDiscovery* CFeatureDiscovery::NewLC()
|
sl@0
|
168 |
{
|
sl@0
|
169 |
CFeatureDiscovery* self = new( ELeave ) CFeatureDiscovery();
|
sl@0
|
170 |
CleanupStack::PushL( self );
|
sl@0
|
171 |
self->ConstructL();
|
sl@0
|
172 |
|
sl@0
|
173 |
return self;
|
sl@0
|
174 |
}
|
sl@0
|
175 |
|
sl@0
|
176 |
// ---------------------------------------------------------
|
sl@0
|
177 |
// CFeatureDiscovery::ConstructL
|
sl@0
|
178 |
//
|
sl@0
|
179 |
// Symbian OS default constructor, initializes variables and cache
|
sl@0
|
180 |
// ---------------------------------------------------------
|
sl@0
|
181 |
//
|
sl@0
|
182 |
void CFeatureDiscovery::ConstructL()
|
sl@0
|
183 |
{
|
sl@0
|
184 |
iImpl = CFeatureDiscoveryImpl::NewL();
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
|
sl@0
|
188 |
// -----------------------------------------------------------------------------
|
sl@0
|
189 |
// CFeatureDiscovery::~CFeatureDiscovery()
|
sl@0
|
190 |
// -----------------------------------------------------------------------------
|
sl@0
|
191 |
//
|
sl@0
|
192 |
CFeatureDiscovery::~CFeatureDiscovery()
|
sl@0
|
193 |
{
|
sl@0
|
194 |
delete iImpl;
|
sl@0
|
195 |
}
|
sl@0
|
196 |
|
sl@0
|
197 |
|
sl@0
|
198 |
// -----------------------------------------------------------------------------
|
sl@0
|
199 |
// CFeatureDiscovery::CFeatureDiscovery()
|
sl@0
|
200 |
// -----------------------------------------------------------------------------
|
sl@0
|
201 |
//
|
sl@0
|
202 |
CFeatureDiscovery::CFeatureDiscovery()
|
sl@0
|
203 |
{
|
sl@0
|
204 |
}
|
sl@0
|
205 |
|
sl@0
|
206 |
|
sl@0
|
207 |
// -----------------------------------------------------------------------------
|
sl@0
|
208 |
// CFeatureDiscovery::IsFeatureSupportedL(TInt)
|
sl@0
|
209 |
// -----------------------------------------------------------------------------
|
sl@0
|
210 |
//
|
sl@0
|
211 |
EXPORT_C TBool CFeatureDiscovery::IsFeatureSupportedL(TInt aFeature)
|
sl@0
|
212 |
{
|
sl@0
|
213 |
return CFeatureDiscoveryImpl::IsFeatureSupportedL( TUid::Uid( aFeature ) );
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
// -----------------------------------------------------------------------------
|
sl@0
|
217 |
// CFeatureDiscovery::IsFeatureSupportedL(TUid)
|
sl@0
|
218 |
// -----------------------------------------------------------------------------
|
sl@0
|
219 |
//
|
sl@0
|
220 |
EXPORT_C TBool CFeatureDiscovery::IsFeatureSupportedL(TUid aFeature)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
return CFeatureDiscoveryImpl::IsFeatureSupportedL( aFeature );
|
sl@0
|
223 |
}
|
sl@0
|
224 |
|
sl@0
|
225 |
// -----------------------------------------------------------------------------
|
sl@0
|
226 |
// CFeatureDiscovery::IsSupported(TInt)
|
sl@0
|
227 |
// -----------------------------------------------------------------------------
|
sl@0
|
228 |
//
|
sl@0
|
229 |
EXPORT_C TBool CFeatureDiscovery::IsSupported(TInt aFeature) const
|
sl@0
|
230 |
{
|
sl@0
|
231 |
return iImpl->IsSupported( TUid::Uid( aFeature ) );
|
sl@0
|
232 |
}
|
sl@0
|
233 |
|
sl@0
|
234 |
// -----------------------------------------------------------------------------
|
sl@0
|
235 |
// CFeatureDiscovery::IsSupported(TUid)
|
sl@0
|
236 |
// -----------------------------------------------------------------------------
|
sl@0
|
237 |
//
|
sl@0
|
238 |
EXPORT_C TBool CFeatureDiscovery::IsSupported(TUid aFeature) const
|
sl@0
|
239 |
{
|
sl@0
|
240 |
return iImpl->IsSupported( aFeature );
|
sl@0
|
241 |
}
|
sl@0
|
242 |
|
sl@0
|
243 |
// -----------------------------------------------------------------------------
|
sl@0
|
244 |
// CFeatureDiscovery::FeaturesSupportedL(TFeatureSet&)
|
sl@0
|
245 |
// -----------------------------------------------------------------------------
|
sl@0
|
246 |
//
|
sl@0
|
247 |
EXPORT_C void CFeatureDiscovery::FeaturesSupportedL( TFeatureSet& aFeatures )
|
sl@0
|
248 |
{
|
sl@0
|
249 |
CFeatureDiscoveryImpl::FeaturesSupportedL( aFeatures );
|
sl@0
|
250 |
}
|
sl@0
|
251 |
|
sl@0
|
252 |
// -----------------------------------------------------------------------------
|
sl@0
|
253 |
// CFeatureDiscovery::FeaturesSupported(TFeatureSet&)
|
sl@0
|
254 |
// -----------------------------------------------------------------------------
|
sl@0
|
255 |
//
|
sl@0
|
256 |
EXPORT_C TInt CFeatureDiscovery::FeaturesSupported( TFeatureSet& aFeatures ) const
|
sl@0
|
257 |
{
|
sl@0
|
258 |
return iImpl->FeaturesSupported( aFeatures );
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
// EOF
|