Enabling and Disabling a Feature

How to enable and disable a feature using RFeatureControl.

A feature is any item of functionality which can be included in a phone build or excluded from it. To enable and disable a feature using RFeatureControl, take the following steps.


  1. Create an instance of RFeatureControl,
    
    // replace <featureUID> with a real Uid ) 
    #include <featurecontrol.h>
    #include <featureinfo.h> // for feature definitions
    CMyClass::MyMethodL()
         {
         // Replace KFeatureUidx with real feature Uid.
         // Open() must be called before calling any other methods. 
         // Disconnect is done by calling the Close() method.
         RFeatureControl featureControl;
    

  2. call its Open() function,
    
         TInt err = featureControl.Open();
    

  3. determine the Uid of the feature you wish to enable or disable,

  4. call the EnableFeature() or DisableFeature() function of the RFeatureControl object with the Uid of the feature as argument, and
    
          if ( err == KErrNone )
             {
            // Enable some feature. 
    
             // EnableFeature() and DisableFeature() methods return 
             // KErrNone if the feature was succesfully enabled or disabled, 
             // KErrAccessDenied if the feature is not modifiable.
             // KErrPermissionDenied a capability check fails, 
             // KErrNotFound if the feature does not exist and 
             // otherwise one of the Symbian error codes.
             err = featureControl.EnableFeature( <featureUID> ); 
    

  5. call the Close() function of the RFeatureControl object.
    
             // Remember to call CloseL after using RFeatureControl.
             // It disconnects the Feature Manager server.
             featureControl.Close();  
             }
         }
    

The calls to EnableFeature() or DisableFeature() require WriteDeviceData capability. They both return: