Symbian3/PDK/Source/GUID-96D9B512-5F6C-51D8-9780-BB38643CD967.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 5 f345bda72bc4
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-96D9B512-5F6C-51D8-9780-BB38643CD967" xml:lang="en"><title>Enabling
and Disabling a Feature</title><shortdesc>How to enable and disable a feature using <codeph>RFeatureControl</codeph>. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<context id="GUID-2C404C2C-76C0-578F-9B24-5178821E5769"><p>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 <xref href="GUID-F6AAAC24-4A62-383A-86C6-2E46335C3FD4.dita"><apiname>RFeatureControl</apiname></xref>,
take the following steps. </p> </context>
<steps id="GUID-12648023-51F4-5ED4-8BFD-8407D0C083CB">
<step id="GUID-0D74F298-7CBF-52F0-B3AB-986A5A22EE77"><cmd/>
<info>Create an instance of <xref href="GUID-F6AAAC24-4A62-383A-86C6-2E46335C3FD4.dita"><apiname>RFeatureControl</apiname></xref>, </info>
<stepxmp><codeblock id="GUID-833F18E8-5204-57B5-8FEA-9CD8EEA0B026" xml:space="preserve">
// replace &lt;featureUID&gt; with a real Uid ) 
#include &lt;featurecontrol.h&gt;
#include &lt;featureinfo.h&gt; // 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;
</codeblock> </stepxmp>
</step>
<step id="GUID-A456493D-836A-5A64-BC0B-E5DF80B4873A"><cmd/>
<info>call its <xref href="GUID-20D0D10F-3401-3F72-8AF6-DC35F6025DC2.dita"><apiname>Open()</apiname></xref> function, </info>
<stepxmp><codeblock id="GUID-F9BBB9E7-E297-5E64-B38C-55343E392523" xml:space="preserve">
     TInt err = featureControl.Open();
</codeblock> </stepxmp>
</step>
<step id="GUID-AE5E8A68-CDB6-5EC5-99B8-B6A93DCD606A"><cmd/>
<info>determine the Uid of the feature you wish to enable or disable, </info>
</step>
<step id="GUID-CB265CB7-2A0C-52D9-B4E0-864C6006C499"><cmd/>
<info>call the <xref href="GUID-7A7E7EF1-BF0B-32E7-B278-2E0D32B51629.dita"><apiname>EnableFeature()</apiname></xref> or <xref href="GUID-E5481858-1D95-3870-B0E9-66DFA521E873.dita"><apiname>DisableFeature()</apiname></xref> function
of the <xref href="GUID-F6AAAC24-4A62-383A-86C6-2E46335C3FD4.dita"><apiname>RFeatureControl</apiname></xref> object with the Uid of the feature
as argument, and </info>
<stepxmp><codeblock id="GUID-12BBCAB4-ACD9-5DCF-829A-819B583835D3" xml:space="preserve">
      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( &lt;featureUID&gt; ); 
</codeblock> </stepxmp>
</step>
<step id="GUID-5825BD2A-62EA-5F87-8CBB-254559E00EE6"><cmd/>
<info>call the <xref href="GUID-01D2AF56-21E1-3FF3-BF86-0C356A1658EF.dita"><apiname>Close()</apiname></xref> function of the <xref href="GUID-F6AAAC24-4A62-383A-86C6-2E46335C3FD4.dita"><apiname>RFeatureControl</apiname></xref> object. </info>
<stepxmp><codeblock id="GUID-DB78792D-4DA3-5221-89E6-F269A55AF836" xml:space="preserve">
         // Remember to call CloseL after using RFeatureControl.
         // It disconnects the Feature Manager server.
         featureControl.Close();  
         }
     }
</codeblock> </stepxmp>
</step>
</steps>
<result id="GUID-D7702C5C-357A-5245-B9BA-33CDF4A3C0D5"><p>The calls to <xref href="GUID-7A7E7EF1-BF0B-32E7-B278-2E0D32B51629.dita"><apiname>EnableFeature()</apiname></xref> or <xref href="GUID-E5481858-1D95-3870-B0E9-66DFA521E873.dita"><apiname>DisableFeature()</apiname></xref> require <xref href="GUID-7BA52F1C-159D-3F72-91A3-1A2B5870C48B.dita"><apiname>WriteDeviceData</apiname></xref> capability. They both return: </p> <ul>
<li id="GUID-081B2503-4FC5-5BA1-A5F6-6324A0A36A42"><p> <xref href="GUID-6CA4F1ED-7947-3087-B618-D35858FAA3BC.dita"><apiname>KErrNone</apiname></xref> on
success, </p> </li>
<li id="GUID-0FA20683-3E0D-5D4F-BC44-3672DED44730"><p> <xref href="GUID-298F3C28-48F5-34EA-8843-C75E2ECF0480.dita"><apiname>KErrAccessDenied</apiname></xref> if
the feature is not modifiable, </p> </li>
<li id="GUID-3217F280-3AF6-53D0-A71C-0145E0D48BC8"><p> <xref href="GUID-213DE05E-24F7-3E94-9B35-F4A72B3EBFD8.dita"><apiname>KErrPermissionDenied</apiname></xref> if
a capability check fails, </p> </li>
<li id="GUID-AF3E4251-CCC5-5944-A68E-B3C6EE9D3EC2"><p> <xref href="GUID-5E653C17-372C-32E1-A1B2-9E69A9991C40.dita"><apiname>KErrNotFound</apiname></xref> if
the feature does not exist, and </p> </li>
<li id="GUID-84497CA1-D1AA-5052-886D-20BB7A7EEF18"><p>otherwise return an
error code. </p> </li>
</ul> </result>
</taskbody><related-links>
<link href="GUID-418388CE-88DC-5300-ADF4-400337FE975B.dita"><linktext>Setting and
updating a                 feature</linktext></link>
<link href="GUID-5589AAB6-3801-5B3D-98D8-459508B4F836.dita"><linktext>Adding a
feature</linktext></link>
<link href="GUID-B71AC5E3-8AA8-55AD-916F-9E873926011B.dita"><linktext>Feature Manager
Collection Overview</linktext></link>
<link href="GUID-D01C4682-619E-501E-8992-9F7FA35D7682.dita"><linktext>Feature Manager
Modification Tutorials</linktext></link>
</related-links></task>