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