epoc32/include/featdiscovery.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@4
     2
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@4
    14
* Description:
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@4
    19
williamr@4
    20
#ifndef FEATDISCOVERY_H
williamr@4
    21
#define FEATDISCOVERY_H
williamr@2
    22
williamr@2
    23
//  INCLUDES
williamr@4
    24
#include <e32base.h>
williamr@2
    25
williamr@4
    26
class CFeatureDiscoveryImpl;
williamr@2
    27
williamr@2
    28
/**
williamr@4
    29
Wrapper class used for multiple feature queries.
williamr@4
    30
@publishedAll
williamr@4
    31
@released
williamr@2
    32
*/
williamr@2
    33
williamr@4
    34
class TFeatureSet
williamr@4
    35
    {
williamr@4
    36
    public:
williamr@4
    37
williamr@4
    38
		/**
williamr@4
    39
		Constructor
williamr@4
    40
	    */
williamr@4
    41
        IMPORT_C TFeatureSet();
williamr@4
    42
williamr@4
    43
		/**
williamr@4
    44
		Destructor
williamr@4
    45
	    */
williamr@4
    46
        IMPORT_C ~TFeatureSet();
williamr@4
    47
williamr@4
    48
		/**
williamr@4
    49
		 Method to add features before querying support statuses. This
williamr@4
    50
		 method must be called to initialize feature array before querying
williamr@4
    51
		 support statuses from server with FeaturesSupported(L) and finally
williamr@4
    52
		 check the status with a call to IsFeatureSupported or AreAllFeaturesSupported.
williamr@4
    53
williamr@4
    54
	     @return KErrNone if feature addition succeded.
williamr@4
    55
	             Otherwise one of the Symbian OS error codes
williamr@4
    56
	    */
williamr@4
    57
	    IMPORT_C TInt Append( TUid aFeature );
williamr@4
    58
williamr@4
    59
		/**
williamr@4
    60
	     Method to check feature's support status.
williamr@4
    61
williamr@4
    62
	     @param aFeature is the feature UID of the feature that is queried.
williamr@4
    63
		 @return a TBool indicating whether the feature is supported (ETrue)
williamr@4
    64
		 or not (EFalse). If the feature does not exist, the return value is
williamr@4
    65
		 EFalse.
williamr@4
    66
	    */
williamr@4
    67
        IMPORT_C TBool IsFeatureSupported( TUid aFeature ) const;
williamr@4
    68
williamr@4
    69
		/**
williamr@4
    70
		 Method to check whether all features queried are supported.
williamr@4
    71
williamr@4
    72
	     @return ETrue if all features queried are supported or no features have been queried.
williamr@4
    73
	             Otherwise EFalse.
williamr@4
    74
	    */
williamr@4
    75
	    IMPORT_C TBool AreAllFeaturesSupported() const;
williamr@4
    76
williamr@4
    77
    public: // For CFeatureDiscoveryImpl internal use
williamr@4
    78
williamr@4
    79
        // Count number of features in TFeatureStat array.
williamr@4
    80
        TInt Count();
williamr@4
    81
williamr@4
    82
        // Return id of feature in requested index from TFeatureStat array.
williamr@4
    83
        TUid FeatureId( TInt aIndex ) const;
williamr@4
    84
williamr@4
    85
        // Reset TFeatureStat array.
williamr@4
    86
        void Reset();
williamr@4
    87
williamr@4
    88
        // Append feature and status object into TFeatureStat array
williamr@4
    89
        TInt Append( TUid aFeature, TBool aSupported );
williamr@4
    90
williamr@4
    91
    private:
williamr@4
    92
        struct TFeatureStat
williamr@4
    93
        {
williamr@4
    94
            TUid iFeatureID;
williamr@4
    95
            TBool iSupported;
williamr@4
    96
        };
williamr@4
    97
williamr@4
    98
    private:
williamr@4
    99
        // Feature id, status array
williamr@4
   100
        RArray<TFeatureStat> iStatus;
williamr@4
   101
williamr@4
   102
        // Counter for checking feature count before and after query
williamr@4
   103
        TInt iCount;
williamr@4
   104
williamr@4
   105
        // Reserved for future use.
williamr@4
   106
        TUint32 iReserved;
williamr@4
   107
    };
williamr@4
   108
williamr@4
   109
/**
williamr@4
   110
 The feature discovery API provides methods which are used to query which
williamr@4
   111
 features are supported in the environment.
williamr@4
   112
williamr@4
   113
@publishedAll
williamr@4
   114
@released
williamr@4
   115
*/
williamr@2
   116
class CFeatureDiscovery : public CBase
williamr@2
   117
    {
williamr@2
   118
    public:
williamr@2
   119
williamr@4
   120
	    /**
williamr@4
   121
	     This is a two-phase constructor method that is used to create
williamr@4
   122
	     a new instance of the CFeatureDiscovery class.
williamr@4
   123
williamr@4
   124
	     @return a pointer to a new instance of the CFeatureDiscovery class.
williamr@4
   125
williamr@4
   126
	     @leave Any One of the Symbian OS system-wide error codes
williamr@4
   127
	    */
williamr@2
   128
		IMPORT_C static CFeatureDiscovery* NewL();
williamr@2
   129
williamr@4
   130
	    /**
williamr@4
   131
	     This is a two-phase constructor method that is used to create
williamr@4
   132
	     a new instance of the CFeatureDiscovery class. This method leaves
williamr@4
   133
	     the instance of the object on the cleanup stack.
williamr@4
   134
williamr@4
   135
	     @return a pointer to a new instance of the CFeatureDiscovery class.
williamr@4
   136
williamr@4
   137
	      @leave Any One of the Symbian OS system-wide error codes
williamr@4
   138
	    */
williamr@2
   139
		IMPORT_C static CFeatureDiscovery* NewLC();
williamr@2
   140
williamr@4
   141
	    /**
williamr@4
   142
	     Destructor.
williamr@4
   143
	    */
williamr@2
   144
		virtual ~CFeatureDiscovery();
williamr@2
   145
williamr@2
   146
		/**
williamr@4
   147
		 Static method to query the supported status of a feature on the
williamr@4
   148
		 device.
williamr@4
   149
williamr@4
   150
		 @deprecated Use IsFeatureSupportedL(TUid aFeature) instead.
williamr@4
   151
williamr@4
   152
		 @param aFeature is the feature ID of the feature that is queried.
williamr@4
   153
		 @return a TBool indicating whether the feature is supported (ETrue)
williamr@4
   154
		 or not (EFalse). If the feature does not exist, the return value is
williamr@4
   155
		 EFalse.
williamr@4
   156
williamr@4
   157
		  @leave Any One of the Symbian OS system-wide error codes
williamr@4
   158
		*/
williamr@4
   159
		IMPORT_C static TBool IsFeatureSupportedL( TInt aFeature );
williamr@2
   160
williamr@2
   161
		/**
williamr@4
   162
	     Dynamic method to query the supported status of a feature on the
williamr@4
   163
	     device. Before calling the method an instance of the CFeatureDiscovery
williamr@4
   164
	     class must be created by using one of the factory methods,
williamr@4
   165
	     NewL() or NewLC(). The created instance must be deleted after use.
williamr@4
   166
williamr@4
   167
	     @deprecated Use IsSupported(TUid aFeature) instead.
williamr@4
   168
williamr@4
   169
	     @param aFeature is the feature ID of the feature that is queried.
williamr@4
   170
	     @return a TBool indicating whether the feature is supported (ETrue)
williamr@4
   171
	     or not (EFalse). If the feature does not exist, the return value is
williamr@4
   172
	     EFalse.
williamr@4
   173
	    */
williamr@4
   174
		IMPORT_C TBool IsSupported( TInt aFeature ) const ;
williamr@4
   175
williamr@4
   176
		/**
williamr@4
   177
	     Static method to query the supported status of a feature on the device.
williamr@4
   178
williamr@4
   179
	     @param aFeature is the feature UID of the feature that is queried.
williamr@4
   180
	     @return a TBool indicating whether the feature is supported (ETrue)
williamr@4
   181
	     or not (EFalse). If the feature does not exist, the return value is
williamr@4
   182
	     EFalse.
williamr@4
   183
williamr@4
   184
	     @leave Any One of the Symbian OS system-wide error codes
williamr@4
   185
	    */
williamr@4
   186
	    IMPORT_C static TBool IsFeatureSupportedL( TUid aFeature );
williamr@4
   187
williamr@4
   188
		/**
williamr@4
   189
	     Dynamic method to query the supported status of a feature on the device.
williamr@4
   190
williamr@4
   191
	     Before calling the method an instance of the CFeatureDiscovery class must
williamr@4
   192
	     be created by using one of the factory methods, NewL() or NewLC().
williamr@4
   193
	     The created instance must be deleted after use.
williamr@4
   194
williamr@4
   195
	     @param aFeature is the feature UID of the feature that is queried.
williamr@4
   196
	     @return a TBool indicating whether the feature is supported (ETrue)
williamr@4
   197
	     or not (EFalse). If the feature does not exist, the return value is
williamr@4
   198
	     EFalse.
williamr@4
   199
	    */
williamr@4
   200
		IMPORT_C TBool IsSupported( TUid aFeature ) const ;
williamr@4
   201
williamr@4
   202
		/**
williamr@4
   203
		 Static method to query the supported status of a set of features
williamr@4
   204
		 on the device.
williamr@4
   205
williamr@4
   206
		 @param aFeatures is the wrapper class for feature array queried.
williamr@4
   207
williamr@4
   208
		 @leave Any One of the Symbian OS system-wide error codes
williamr@4
   209
		*/
williamr@4
   210
		IMPORT_C static void FeaturesSupportedL( TFeatureSet& aFeatures );
williamr@4
   211
williamr@4
   212
		/**
williamr@4
   213
	     Dynamic method to query the supported status of a set of features
williamr@4
   214
	     on the device. Before calling the method an instance of the
williamr@4
   215
	     CFeatureDiscovery class need to be created by using one of the
williamr@4
   216
	     factory methods, NewL() or NewLC(). The created instance must be
williamr@4
   217
	     deleted after use.
williamr@4
   218
williamr@4
   219
	     @param aFeatures is the wrapper class for feature array queried.
williamr@4
   220
	     @return KErrNone if status query succeeded.
williamr@4
   221
	             Otherwise one of the Symbian OS error codes
williamr@4
   222
	    */
williamr@4
   223
		IMPORT_C TInt FeaturesSupported( TFeatureSet& aFeatures ) const;
williamr@2
   224
williamr@2
   225
    private:
williamr@2
   226
williamr@4
   227
	    /**
williamr@4
   228
	     C++ default constructor.
williamr@4
   229
	    */
williamr@2
   230
		CFeatureDiscovery();
williamr@2
   231
williamr@4
   232
	    /**
williamr@4
   233
	     By default Symbian OS constructor is private.
williamr@4
   234
	    */
williamr@4
   235
	    void ConstructL();
williamr@4
   236
williamr@4
   237
    private:
williamr@4
   238
williamr@4
   239
		// Feature discovery implementation class
williamr@4
   240
		CFeatureDiscoveryImpl* iImpl;
williamr@2
   241
    } ;
williamr@2
   242
williamr@4
   243
/**
williamr@4
   244
 Usage:
williamr@2
   245
williamr@4
   246
 @code
williamr@4
   247
  #include <featdiscovery.h>
williamr@4
   248
  #include <featureinfo.h> // for feature definitions
williamr@2
   249
williamr@4
   250
  // replace <featureUIDx> with a real UID )
williamr@4
   251
williamr@4
   252
  // If querying only one feature, it is more efficient to use the class
williamr@4
   253
  // via the static method, IsFeatureSupportedL().
williamr@4
   254
  // When querying more than one feature, it is more efficient to use the
williamr@4
   255
  // class by creating an instance and calling the IsSupported() method.
williamr@4
   256
williamr@4
   257
  // Static way of using the class:
williamr@4
   258
  TBool isSupported = CFeatureDiscovery::IsFeatureSupportedL(<featureUIDx>);
williamr@4
   259
williamr@4
   260
  // Dynamic way of using the class using NewL():
williamr@4
   261
williamr@4
   262
  // Call NewL() to create an instance of CFeatureDiscovery.
williamr@4
   263
  CFeatureDiscovery* testA = CFeatureDiscovery::NewL();
williamr@4
   264
williamr@4
   265
  // Call the exported IsSupported() method to query whether features
williamr@4
   266
  // are supported in the current environment or not.
williamr@4
   267
  TBool usbSupported = testA->IsSupported(<featureUIDx>);
williamr@4
   268
  TBool mmcSupported = testA->IsSupported(<featureUIDx>);
williamr@4
   269
williamr@4
   270
  // Delete the created instance of CFeatureDiscovery.
williamr@4
   271
  delete testA;
williamr@4
   272
williamr@4
   273
  // Dynamic way of using the class using NewLC():
williamr@4
   274
williamr@4
   275
  // Call NewLC() to create an instance of CFeatureDiscovery.
williamr@4
   276
  // The method leaves the instance of the object on the cleanup stack.
williamr@4
   277
  CFeatureDiscovery* testB = CFeatureDiscovery::NewLC();
williamr@4
   278
williamr@4
   279
  // Call the exported IsSupported() method to query whether features
williamr@4
   280
  // are supported in the current environment or not.
williamr@4
   281
  TBool wcdmaSupported = testB->IsSupported(<featureUIDx>);
williamr@4
   282
  TBool gsmSupported = testB->IsSupported(<featureUIDx>);
williamr@4
   283
williamr@4
   284
  // Dynamic way of using multiple feature query. This is preferred
williamr@4
   285
  // way to fetch support statuses if there are several features to be
williamr@4
   286
  // queried, because it involves less inter-process communication.
williamr@4
   287
williamr@4
   288
  TFeatureSet featset;
williamr@4
   289
  User::LeaveIfError( featset.Append( <featureUIDx> ) );
williamr@4
   290
  User::LeaveIfError( featset.Append( <featureUIDx> ) );
williamr@4
   291
  TInt err = testB->FeaturesSupported( featset );
williamr@4
   292
	if(!err)
williamr@4
   293
		{
williamr@4
   294
			TBool uid1Supported = featset.IsFeatureSupported(<featureUIDx>);
williamr@4
   295
			TBool uid2Supported = featset.IsFeatureSupported(<featureUIDx>);
williamr@4
   296
			// ... or whether all QUERIED features are supported
williamr@4
   297
			TBool allSupported = featset.AreAllFeaturesSupported();
williamr@4
   298
		}
williamr@4
   299
  // featset cleans array up in destructor on scope exit
williamr@4
   300
williamr@4
   301
  // Pop and delete the created instance of CFeatureDiscovery.
williamr@4
   302
  CleanupStack::PopAndDestroy();
williamr@4
   303
 @endcode
williamr@4
   304
*/
williamr@4
   305
#endif  // FEATDISCOVERY_H
williamr@4
   306
williamr@4
   307
// End of File