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 <e32cmn.h>
|
sl@0
|
19 |
#include <featdiscovery.h>
|
sl@0
|
20 |
#include "featdiscoveryimpl.h"
|
sl@0
|
21 |
#include "featurecontrol.h"
|
sl@0
|
22 |
#include "featurecmn.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
// -----------------------------------------------------------------------------
|
sl@0
|
25 |
// CFeatureDiscoveryImpl::CFeatureDiscoveryImpl* NewL()
|
sl@0
|
26 |
// -----------------------------------------------------------------------------
|
sl@0
|
27 |
//
|
sl@0
|
28 |
CFeatureDiscoveryImpl* CFeatureDiscoveryImpl::NewL()
|
sl@0
|
29 |
{
|
sl@0
|
30 |
CFeatureDiscoveryImpl* self = new( ELeave ) CFeatureDiscoveryImpl();
|
sl@0
|
31 |
CleanupStack::PushL( self );
|
sl@0
|
32 |
self->ConstructL();
|
sl@0
|
33 |
CleanupStack::Pop( self );
|
sl@0
|
34 |
|
sl@0
|
35 |
return self;
|
sl@0
|
36 |
}
|
sl@0
|
37 |
|
sl@0
|
38 |
|
sl@0
|
39 |
|
sl@0
|
40 |
// ---------------------------------------------------------
|
sl@0
|
41 |
// CFeatureDiscoveryImpl::ConstructL
|
sl@0
|
42 |
//
|
sl@0
|
43 |
// Symbian OS default constructor, initializes variables and cache
|
sl@0
|
44 |
// ---------------------------------------------------------
|
sl@0
|
45 |
//
|
sl@0
|
46 |
void CFeatureDiscoveryImpl::ConstructL()
|
sl@0
|
47 |
{
|
sl@0
|
48 |
TInt err( iFeatControl.Connect() );
|
sl@0
|
49 |
User::LeaveIfError( err );
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
|
sl@0
|
53 |
// -----------------------------------------------------------------------------
|
sl@0
|
54 |
// CFeatureDiscoveryImpl::~CFeatureDiscoveryImpl()
|
sl@0
|
55 |
// -----------------------------------------------------------------------------
|
sl@0
|
56 |
//
|
sl@0
|
57 |
CFeatureDiscoveryImpl::~CFeatureDiscoveryImpl()
|
sl@0
|
58 |
{
|
sl@0
|
59 |
iFeatControl.Close();
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
|
sl@0
|
63 |
// -----------------------------------------------------------------------------
|
sl@0
|
64 |
// CFeatureDiscoveryImpl::CFeatureDiscoveryImpl()
|
sl@0
|
65 |
// -----------------------------------------------------------------------------
|
sl@0
|
66 |
//
|
sl@0
|
67 |
CFeatureDiscoveryImpl::CFeatureDiscoveryImpl()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
|
sl@0
|
72 |
// -----------------------------------------------------------------------------
|
sl@0
|
73 |
// CFeatureDiscoveryImpl::IsFeatureSupportedL(TUid)
|
sl@0
|
74 |
// -----------------------------------------------------------------------------
|
sl@0
|
75 |
//
|
sl@0
|
76 |
TBool CFeatureDiscoveryImpl::IsFeatureSupportedL(TUid aFeature)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
RFeatureControl featControl;
|
sl@0
|
79 |
TInt err( featControl.Connect() );
|
sl@0
|
80 |
User::LeaveIfError( err );
|
sl@0
|
81 |
TFeatureEntry feature( aFeature );
|
sl@0
|
82 |
err = featControl.FeatureSupported( feature );
|
sl@0
|
83 |
featControl.Close();
|
sl@0
|
84 |
|
sl@0
|
85 |
return (( err > 0 ) ? ETrue : EFalse );
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
// -----------------------------------------------------------------------------
|
sl@0
|
89 |
// CFeatureDiscoveryImpl::IsSupported(TUid)
|
sl@0
|
90 |
// -----------------------------------------------------------------------------
|
sl@0
|
91 |
//
|
sl@0
|
92 |
TBool CFeatureDiscoveryImpl::IsSupported(TUid aFeature)
|
sl@0
|
93 |
{
|
sl@0
|
94 |
TFeatureEntry feature( aFeature );
|
sl@0
|
95 |
|
sl@0
|
96 |
return (( iFeatControl.FeatureSupported( feature ) > 0 ) ? ETrue : EFalse );
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
// -----------------------------------------------------------------------------
|
sl@0
|
100 |
// CFeatureDiscoveryImpl::FeaturesSupportedL(TFeatureSet&)
|
sl@0
|
101 |
// -----------------------------------------------------------------------------
|
sl@0
|
102 |
//
|
sl@0
|
103 |
void CFeatureDiscoveryImpl::FeaturesSupportedL( TFeatureSet& aFeatures )
|
sl@0
|
104 |
{
|
sl@0
|
105 |
RFeatureControl featControl;
|
sl@0
|
106 |
CleanupClosePushL( featControl );
|
sl@0
|
107 |
TInt err( featControl.Connect() );
|
sl@0
|
108 |
User::LeaveIfError( err );
|
sl@0
|
109 |
|
sl@0
|
110 |
// Construct feature entry array used by feature control
|
sl@0
|
111 |
RFeatureArray features;
|
sl@0
|
112 |
CleanupClosePushL( features );
|
sl@0
|
113 |
TInt count( aFeatures.Count() );
|
sl@0
|
114 |
|
sl@0
|
115 |
for(TInt i(0); i < count; i++)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
TFeatureEntry feature( aFeatures.FeatureId( i ) );
|
sl@0
|
118 |
features.AppendL( feature );
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
// Fetch feature information from server
|
sl@0
|
122 |
err = featControl.FeaturesSupported( features );
|
sl@0
|
123 |
User::LeaveIfError( err );
|
sl@0
|
124 |
|
sl@0
|
125 |
// Refresh count of features after query, non existing features are removed
|
sl@0
|
126 |
count = features.Count();
|
sl@0
|
127 |
// Write information back to format feature discovery uses
|
sl@0
|
128 |
aFeatures.Reset();
|
sl@0
|
129 |
|
sl@0
|
130 |
for(TInt i(0); i < count; i++)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
const TUid uid( features[i].FeatureUid() );
|
sl@0
|
133 |
const TBool supported( features[i].FeatureFlags().IsSet( EFeatureSupported ) );
|
sl@0
|
134 |
err = aFeatures.Append( uid, supported );
|
sl@0
|
135 |
User::LeaveIfError( err );
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
CleanupStack::PopAndDestroy( &features );
|
sl@0
|
139 |
CleanupStack::PopAndDestroy( &featControl );
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
// -----------------------------------------------------------------------------
|
sl@0
|
143 |
// CFeatureDiscoveryImpl::FeaturesSupported(TFeatureSet&)
|
sl@0
|
144 |
// -----------------------------------------------------------------------------
|
sl@0
|
145 |
//
|
sl@0
|
146 |
TInt CFeatureDiscoveryImpl::FeaturesSupported( TFeatureSet& aFeatures )
|
sl@0
|
147 |
{
|
sl@0
|
148 |
// Construct feature entry array used by feature control
|
sl@0
|
149 |
TInt err( KErrNone );
|
sl@0
|
150 |
RFeatureArray features;
|
sl@0
|
151 |
TInt count( aFeatures.Count() );
|
sl@0
|
152 |
|
sl@0
|
153 |
for(TInt i(0); i < count; i++)
|
sl@0
|
154 |
{
|
sl@0
|
155 |
TFeatureEntry feature( aFeatures.FeatureId( i ) );
|
sl@0
|
156 |
err = features.Append( feature );
|
sl@0
|
157 |
if( err != KErrNone )
|
sl@0
|
158 |
{
|
sl@0
|
159 |
break;
|
sl@0
|
160 |
}
|
sl@0
|
161 |
}
|
sl@0
|
162 |
|
sl@0
|
163 |
if( err == KErrNone )
|
sl@0
|
164 |
{
|
sl@0
|
165 |
// Fetch feature information from server
|
sl@0
|
166 |
err = iFeatControl.FeaturesSupported( features );
|
sl@0
|
167 |
// Refresh count of features after query, non existing features are removed
|
sl@0
|
168 |
count = features.Count();
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
if( err == KErrNone )
|
sl@0
|
172 |
{
|
sl@0
|
173 |
// Write information back to format feature discovery uses
|
sl@0
|
174 |
aFeatures.Reset();
|
sl@0
|
175 |
|
sl@0
|
176 |
for(TInt i(0); i < count; i++)
|
sl@0
|
177 |
{
|
sl@0
|
178 |
const TUid uid( features[i].FeatureUid() );
|
sl@0
|
179 |
const TBool supported( features[i].FeatureFlags().IsSet( EFeatureSupported ) );
|
sl@0
|
180 |
err = aFeatures.Append( uid, supported );
|
sl@0
|
181 |
if( err != KErrNone )
|
sl@0
|
182 |
{
|
sl@0
|
183 |
break;
|
sl@0
|
184 |
}
|
sl@0
|
185 |
}
|
sl@0
|
186 |
}
|
sl@0
|
187 |
|
sl@0
|
188 |
features.Close();
|
sl@0
|
189 |
return err;
|
sl@0
|
190 |
}
|
sl@0
|
191 |
// EOF
|