Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <featdiscovery.h>
20 #include "featdiscoveryimpl.h"
21 #include "featurecontrol.h"
22 #include "featurecmn.h"
24 // -----------------------------------------------------------------------------
25 // CFeatureDiscoveryImpl::CFeatureDiscoveryImpl* NewL()
26 // -----------------------------------------------------------------------------
28 CFeatureDiscoveryImpl* CFeatureDiscoveryImpl::NewL()
30 CFeatureDiscoveryImpl* self = new( ELeave ) CFeatureDiscoveryImpl();
31 CleanupStack::PushL( self );
33 CleanupStack::Pop( self );
40 // ---------------------------------------------------------
41 // CFeatureDiscoveryImpl::ConstructL
43 // Symbian OS default constructor, initializes variables and cache
44 // ---------------------------------------------------------
46 void CFeatureDiscoveryImpl::ConstructL()
48 TInt err( iFeatControl.Connect() );
49 User::LeaveIfError( err );
53 // -----------------------------------------------------------------------------
54 // CFeatureDiscoveryImpl::~CFeatureDiscoveryImpl()
55 // -----------------------------------------------------------------------------
57 CFeatureDiscoveryImpl::~CFeatureDiscoveryImpl()
63 // -----------------------------------------------------------------------------
64 // CFeatureDiscoveryImpl::CFeatureDiscoveryImpl()
65 // -----------------------------------------------------------------------------
67 CFeatureDiscoveryImpl::CFeatureDiscoveryImpl()
72 // -----------------------------------------------------------------------------
73 // CFeatureDiscoveryImpl::IsFeatureSupportedL(TUid)
74 // -----------------------------------------------------------------------------
76 TBool CFeatureDiscoveryImpl::IsFeatureSupportedL(TUid aFeature)
78 RFeatureControl featControl;
79 TInt err( featControl.Connect() );
80 User::LeaveIfError( err );
81 TFeatureEntry feature( aFeature );
82 err = featControl.FeatureSupported( feature );
85 return (( err > 0 ) ? ETrue : EFalse );
88 // -----------------------------------------------------------------------------
89 // CFeatureDiscoveryImpl::IsSupported(TUid)
90 // -----------------------------------------------------------------------------
92 TBool CFeatureDiscoveryImpl::IsSupported(TUid aFeature)
94 TFeatureEntry feature( aFeature );
96 return (( iFeatControl.FeatureSupported( feature ) > 0 ) ? ETrue : EFalse );
99 // -----------------------------------------------------------------------------
100 // CFeatureDiscoveryImpl::FeaturesSupportedL(TFeatureSet&)
101 // -----------------------------------------------------------------------------
103 void CFeatureDiscoveryImpl::FeaturesSupportedL( TFeatureSet& aFeatures )
105 RFeatureControl featControl;
106 CleanupClosePushL( featControl );
107 TInt err( featControl.Connect() );
108 User::LeaveIfError( err );
110 // Construct feature entry array used by feature control
111 RFeatureArray features;
112 CleanupClosePushL( features );
113 TInt count( aFeatures.Count() );
115 for(TInt i(0); i < count; i++)
117 TFeatureEntry feature( aFeatures.FeatureId( i ) );
118 features.AppendL( feature );
121 // Fetch feature information from server
122 err = featControl.FeaturesSupported( features );
123 User::LeaveIfError( err );
125 // Refresh count of features after query, non existing features are removed
126 count = features.Count();
127 // Write information back to format feature discovery uses
130 for(TInt i(0); i < count; i++)
132 const TUid uid( features[i].FeatureUid() );
133 const TBool supported( features[i].FeatureFlags().IsSet( EFeatureSupported ) );
134 err = aFeatures.Append( uid, supported );
135 User::LeaveIfError( err );
138 CleanupStack::PopAndDestroy( &features );
139 CleanupStack::PopAndDestroy( &featControl );
142 // -----------------------------------------------------------------------------
143 // CFeatureDiscoveryImpl::FeaturesSupported(TFeatureSet&)
144 // -----------------------------------------------------------------------------
146 TInt CFeatureDiscoveryImpl::FeaturesSupported( TFeatureSet& aFeatures )
148 // Construct feature entry array used by feature control
149 TInt err( KErrNone );
150 RFeatureArray features;
151 TInt count( aFeatures.Count() );
153 for(TInt i(0); i < count; i++)
155 TFeatureEntry feature( aFeatures.FeatureId( i ) );
156 err = features.Append( feature );
157 if( err != KErrNone )
163 if( err == KErrNone )
165 // Fetch feature information from server
166 err = iFeatControl.FeaturesSupported( features );
167 // Refresh count of features after query, non existing features are removed
168 count = features.Count();
171 if( err == KErrNone )
173 // Write information back to format feature discovery uses
176 for(TInt i(0); i < count; i++)
178 const TUid uid( features[i].FeatureUid() );
179 const TBool supported( features[i].FeatureFlags().IsSet( EFeatureSupported ) );
180 err = aFeatures.Append( uid, supported );
181 if( err != KErrNone )