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