os/persistentdata/featuremgmt/featuremgr/src/featdiscovery/featdiscovery.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/featuremgmt/featuremgr/src/featdiscovery/featdiscovery.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,261 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +
    1.21 +#include <featdiscovery.h>
    1.22 +#include <e32cmn.h>
    1.23 +#include "featdiscoveryimpl.h"
    1.24 +
    1.25 +// -----------------------------------------------------------------------------
    1.26 +// TFeatureSet::TFeatureSet()
    1.27 +// -----------------------------------------------------------------------------
    1.28 +//
    1.29 +EXPORT_C TFeatureSet::TFeatureSet() :
    1.30 +    iCount( 0 )
    1.31 +    {
    1.32 +    }
    1.33 +
    1.34 +// -----------------------------------------------------------------------------
    1.35 +// TFeatureSet::~TFeatureSet()
    1.36 +// -----------------------------------------------------------------------------
    1.37 +//
    1.38 +EXPORT_C TFeatureSet::~TFeatureSet()
    1.39 +    {
    1.40 +    iStatus.Close();
    1.41 +    }
    1.42 +
    1.43 +// -----------------------------------------------------------------------------
    1.44 +// TFeatureSet::Append(TUid)
    1.45 +// -----------------------------------------------------------------------------
    1.46 +//
    1.47 +EXPORT_C TInt TFeatureSet::Append( TUid aFeature )
    1.48 +    {
    1.49 +    TInt err;
    1.50 +    TFeatureStat feature;
    1.51 +    feature.iFeatureID = aFeature;
    1.52 +    feature.iSupported=EFalse;
    1.53 +    
    1.54 +    err = iStatus.Append( feature );
    1.55 +    if( err == KErrNone )
    1.56 +        {
    1.57 +        iCount++;
    1.58 +        }
    1.59 +    
    1.60 +    return err;
    1.61 +    }
    1.62 +
    1.63 +// -----------------------------------------------------------------------------
    1.64 +// TFeatureSet::IsFeatureSupported(TUid)
    1.65 +// -----------------------------------------------------------------------------
    1.66 +//
    1.67 +EXPORT_C TBool TFeatureSet::IsFeatureSupported( TUid aFeature ) const
    1.68 +    {
    1.69 +    TBool featureSupported( EFalse );
    1.70 +    TFeatureStat feature;
    1.71 +    feature.iFeatureID = aFeature;
    1.72 +    TInt index = iStatus.Find( feature );
    1.73 +    if( index != KErrNotFound )
    1.74 +        {
    1.75 +        featureSupported = iStatus[index].iSupported;
    1.76 +        }
    1.77 +    
    1.78 +    return featureSupported;
    1.79 +    }
    1.80 +
    1.81 +// -----------------------------------------------------------------------------
    1.82 +// TFeatureSet::AreAllFeaturesSupported()
    1.83 +// -----------------------------------------------------------------------------
    1.84 +//
    1.85 +EXPORT_C TBool TFeatureSet::AreAllFeaturesSupported() const
    1.86 +    {
    1.87 +    //if the request array is empty return true 
    1.88 +    if( !iCount ) return ETrue;
    1.89 +    
    1.90 +    TBool allSupported( ETrue );
    1.91 +    TInt count( iStatus.Count() );
    1.92 +    
    1.93 +    if( count != iCount )
    1.94 +        {
    1.95 +        // Features have been removed from array, because they don't exist.
    1.96 +        allSupported = EFalse;
    1.97 +        }
    1.98 +    else
    1.99 +        {
   1.100 +        for(TInt i(0); i < count; i++)
   1.101 +            {
   1.102 +            if( !iStatus[i].iSupported )
   1.103 +                {
   1.104 +                allSupported = EFalse;
   1.105 +                break;
   1.106 +                }
   1.107 +            }
   1.108 +        }
   1.109 +    
   1.110 +    return allSupported;
   1.111 +    }
   1.112 +
   1.113 +// -----------------------------------------------------------------------------
   1.114 +// TFeatureSet::Count()
   1.115 +// -----------------------------------------------------------------------------
   1.116 +//
   1.117 +TInt TFeatureSet::Count()
   1.118 +    {
   1.119 +    return iStatus.Count();
   1.120 +    }
   1.121 +
   1.122 +// -----------------------------------------------------------------------------
   1.123 +// TFeatureSet::Reset()
   1.124 +// -----------------------------------------------------------------------------
   1.125 +//
   1.126 +TUid TFeatureSet::FeatureId( TInt aIndex ) const
   1.127 +    {
   1.128 +    return iStatus[aIndex].iFeatureID;
   1.129 +    }
   1.130 +
   1.131 +// -----------------------------------------------------------------------------
   1.132 +// TFeatureSet::Reset()
   1.133 +// -----------------------------------------------------------------------------
   1.134 +//
   1.135 +void TFeatureSet::Reset()
   1.136 +    {
   1.137 +    iStatus.Reset();
   1.138 +    }
   1.139 +
   1.140 +// -----------------------------------------------------------------------------
   1.141 +// TFeatureSet::Append()
   1.142 +// -----------------------------------------------------------------------------
   1.143 +//
   1.144 +TInt TFeatureSet::Append( TUid aFeature, TBool aSupported )
   1.145 +    {
   1.146 +    TFeatureStat feature;
   1.147 +    feature.iFeatureID = aFeature;
   1.148 +    feature.iSupported = aSupported;
   1.149 +    
   1.150 +    return iStatus.Append( feature );
   1.151 +    }
   1.152 +
   1.153 +// -----------------------------------------------------------------------------
   1.154 +// CFeatureDiscovery::CFeatureDiscovery* NewL()
   1.155 +// -----------------------------------------------------------------------------
   1.156 +//
   1.157 +EXPORT_C CFeatureDiscovery* CFeatureDiscovery::NewL()
   1.158 +    {
   1.159 +    CFeatureDiscovery* self = NewLC();
   1.160 +    CleanupStack::Pop( self);
   1.161 +
   1.162 +    return self;
   1.163 +    }
   1.164 +
   1.165 +
   1.166 +// -----------------------------------------------------------------------------
   1.167 +// CFeatureDiscovery::CFeatureDiscovery* NewLC()
   1.168 +// -----------------------------------------------------------------------------
   1.169 +//
   1.170 +EXPORT_C CFeatureDiscovery* CFeatureDiscovery::NewLC()
   1.171 +    {
   1.172 +    CFeatureDiscovery* self = new( ELeave ) CFeatureDiscovery();
   1.173 +    CleanupStack::PushL( self );
   1.174 +    self->ConstructL();
   1.175 +
   1.176 +    return self;
   1.177 +    }
   1.178 +
   1.179 +// ---------------------------------------------------------
   1.180 +// CFeatureDiscovery::ConstructL
   1.181 +//
   1.182 +// Symbian OS default constructor, initializes variables and cache 
   1.183 +// ---------------------------------------------------------
   1.184 +//
   1.185 +void CFeatureDiscovery::ConstructL()
   1.186 +    {
   1.187 +    iImpl = CFeatureDiscoveryImpl::NewL();
   1.188 +    }
   1.189 +
   1.190 +
   1.191 +// -----------------------------------------------------------------------------
   1.192 +// CFeatureDiscovery::~CFeatureDiscovery()
   1.193 +// -----------------------------------------------------------------------------
   1.194 +//
   1.195 +CFeatureDiscovery::~CFeatureDiscovery()
   1.196 +    {
   1.197 +    delete iImpl;
   1.198 +    }
   1.199 +
   1.200 +
   1.201 +// -----------------------------------------------------------------------------
   1.202 +// CFeatureDiscovery::CFeatureDiscovery()
   1.203 +// -----------------------------------------------------------------------------
   1.204 +//
   1.205 +CFeatureDiscovery::CFeatureDiscovery()
   1.206 +    {
   1.207 +    }
   1.208 +
   1.209 +
   1.210 +// -----------------------------------------------------------------------------
   1.211 +// CFeatureDiscovery::IsFeatureSupportedL(TInt)
   1.212 +// -----------------------------------------------------------------------------
   1.213 +//
   1.214 +EXPORT_C TBool CFeatureDiscovery::IsFeatureSupportedL(TInt aFeature)
   1.215 +    {
   1.216 +    return CFeatureDiscoveryImpl::IsFeatureSupportedL( TUid::Uid( aFeature ) );
   1.217 +    }
   1.218 +
   1.219 +// -----------------------------------------------------------------------------
   1.220 +// CFeatureDiscovery::IsFeatureSupportedL(TUid)
   1.221 +// -----------------------------------------------------------------------------
   1.222 +//
   1.223 +EXPORT_C TBool CFeatureDiscovery::IsFeatureSupportedL(TUid aFeature)
   1.224 +    {
   1.225 +    return CFeatureDiscoveryImpl::IsFeatureSupportedL( aFeature );
   1.226 +    }
   1.227 +
   1.228 +// -----------------------------------------------------------------------------
   1.229 +// CFeatureDiscovery::IsSupported(TInt)
   1.230 +// -----------------------------------------------------------------------------
   1.231 +//
   1.232 +EXPORT_C TBool CFeatureDiscovery::IsSupported(TInt aFeature) const
   1.233 +    {
   1.234 +    return iImpl->IsSupported( TUid::Uid( aFeature ) );
   1.235 +    }
   1.236 +
   1.237 +// -----------------------------------------------------------------------------
   1.238 +// CFeatureDiscovery::IsSupported(TUid)
   1.239 +// -----------------------------------------------------------------------------
   1.240 +//
   1.241 +EXPORT_C TBool CFeatureDiscovery::IsSupported(TUid aFeature) const
   1.242 +    {
   1.243 +    return iImpl->IsSupported( aFeature );
   1.244 +    }
   1.245 +
   1.246 +// -----------------------------------------------------------------------------
   1.247 +// CFeatureDiscovery::FeaturesSupportedL(TFeatureSet&)
   1.248 +// -----------------------------------------------------------------------------
   1.249 +//
   1.250 +EXPORT_C void CFeatureDiscovery::FeaturesSupportedL( TFeatureSet& aFeatures )
   1.251 +    {
   1.252 +    CFeatureDiscoveryImpl::FeaturesSupportedL( aFeatures );
   1.253 +    }
   1.254 +    
   1.255 +// -----------------------------------------------------------------------------
   1.256 +// CFeatureDiscovery::FeaturesSupported(TFeatureSet&)
   1.257 +// -----------------------------------------------------------------------------
   1.258 +//
   1.259 +EXPORT_C TInt CFeatureDiscovery::FeaturesSupported( TFeatureSet& aFeatures ) const
   1.260 +    {
   1.261 +    return iImpl->FeaturesSupported( aFeatures );
   1.262 +    }
   1.263 +
   1.264 +// EOF