bluetoothengine/bteng/btfeatures/btfeatures.cpp
branchRCL_3
changeset 13 b6f55cd40afd
parent 6 6a29d5ad0713
equal deleted inserted replaced
11:a42ed326b458 13:b6f55cd40afd
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <btfeaturescfg.h> 
    19 #include <btfeaturescfg.h>
    20 #include <featmgr/featurecontrol.h>
       
    21 #include <featmgr/featmgr.h>
       
    22 
    20 
    23 /**
    21 #include <centralrepository.h> 
    24 	Device supports bluetooth data profiles disabled.
    22 
    25 */
    23 #include "btengprivatecrkeys.h"
    26 const TInt KFeatureIdTempFfBluetoothDataProfilesDisabled = 0x1000001;
       
    27 	
       
    28 /**
       
    29 	Device supports bluetooth disabled.
       
    30 */
       
    31 const TInt KFeatureIdTempFfBluetoothDisabled = 0x1000002;
       
    32 
    24 
    33 
    25 
    34 EXPORT_C void BluetoothFeatures::SetEnterpriseEnablementL(BluetoothFeatures::TEnterpriseEnablementMode aMode)
    26 EXPORT_C void BluetoothFeatures::SetEnterpriseEnablementL(BluetoothFeatures::TEnterpriseEnablementMode aMode)
    35 	{
    27 	{
    36 	// This method is only provided for use by the Bluetooth DCMO plugin. 
    28 	// This method is only provided for use by the Bluetooth DCMO plugin. 
    38 	_LIT_SECURE_ID(KDcmoServerSecureUid, 0x2001FE47);
    30 	_LIT_SECURE_ID(KDcmoServerSecureUid, 0x2001FE47);
    39 	RProcess proc;
    31 	RProcess proc;
    40 	if ( proc.SecureId() != KDcmoServerSecureUid )
    32 	if ( proc.SecureId() != KDcmoServerSecureUid )
    41 		{
    33 		{
    42 		User::Leave(KErrPermissionDenied);
    34 		User::Leave(KErrPermissionDenied);
    43 		}	
    35 		}
    44 
    36 	
    45 	const TUid KBtDisabledUid = {KFeatureIdTempFfBluetoothDisabled};
    37 	// get ready to use the central repository.
    46 	const TUid KBtDataProfilesDisabledUid = {KFeatureIdTempFfBluetoothDataProfilesDisabled};
    38 	CRepository* cenRep = CRepository::NewL(KCRUidBTEngPrivateSettings);
    47 
    39 	CleanupStack::PushL(cenRep);
    48 	RFeatureControl featureControl;
    40 	
    49 	User::LeaveIfError(featureControl.Connect());
    41 	switch(aMode)
    50 	CleanupClosePushL(featureControl);
       
    51 	switch ( aMode )
       
    52 		{
    42 		{
    53 	case EDisabled:
    43 	case EDisabled:
    54 		User::LeaveIfError(featureControl.EnableFeature(KBtDisabledUid));
    44 		User::LeaveIfError(cenRep->Set(KBluetoothEnterpriseState, EBluetoothEnterpriseDisabled));
    55 		User::LeaveIfError(featureControl.DisableFeature(KBtDataProfilesDisabledUid));
       
    56 		break;
    45 		break;
    57 	case EDataProfilesDisabled:
    46 	case EDataProfilesDisabled:
    58 		User::LeaveIfError(featureControl.DisableFeature(KBtDisabledUid));
    47 		User::LeaveIfError(cenRep->Set(KBluetoothEnterpriseState, EBluetoothEnterpriseDataProfilesDisabled));
    59 		User::LeaveIfError(featureControl.EnableFeature(KBtDataProfilesDisabledUid));
       
    60 		break;
    48 		break;
    61 	case EEnabled:
    49 	case EEnabled:
    62 		User::LeaveIfError(featureControl.DisableFeature(KBtDisabledUid));
    50 		User::LeaveIfError(cenRep->Set(KBluetoothEnterpriseState, EBluetoothEnterpriseEnabled));
    63 		User::LeaveIfError(featureControl.DisableFeature(KBtDataProfilesDisabledUid));
       
    64 		break;
    51 		break;
    65 	default:
    52 	default:
    66 		User::Leave(KErrArgument);
    53 		User::Leave(KErrArgument);
    67 		break;
    54 		break;
    68 		}
    55 		}
    69 	CleanupStack::PopAndDestroy(&featureControl);
    56 	
       
    57 	CleanupStack::PopAndDestroy(cenRep);
    70 	}
    58 	}
    71 
    59 
    72 EXPORT_C BluetoothFeatures::TEnterpriseEnablementMode BluetoothFeatures::EnterpriseEnablementL()
    60 EXPORT_C BluetoothFeatures::TEnterpriseEnablementMode BluetoothFeatures::EnterpriseEnablementL()
    73 	{
    61 	{
    74 	TEnterpriseEnablementMode mode = EDisabled;
    62 	TEnterpriseEnablementMode mode = EEnabled;
       
    63 	TInt setting = EBluetoothEnterpriseEnabled;
    75 	
    64 	
    76 	FeatureManager::InitializeLibL();
    65 	// get the value out of the repository.
    77     const TBool bluetoothDisabled = FeatureManager::FeatureSupported(KFeatureIdTempFfBluetoothDisabled);
    66 	CRepository* cenRep = CRepository::NewL(KCRUidBTEngPrivateSettings);
    78     if ( !bluetoothDisabled )
    67 	CleanupStack::PushL(cenRep);
       
    68 	
       
    69 	TInt err = cenRep->Get(KBluetoothEnterpriseState, setting);
       
    70 	if(err == KErrNotFound)
    79 		{
    71 		{
    80 		const TBool dataProfilesDisabled = FeatureManager::FeatureSupported(KFeatureIdTempFfBluetoothDataProfilesDisabled);
    72 		// not found in repository, so assume enabled by default
    81 		if ( dataProfilesDisabled )
    73 		mode = EEnabled;
       
    74 		}
       
    75 	else if(err == KErrNone)
       
    76 		{
       
    77 		// Got a value from repository, convert it as appropriate.
       
    78 		switch(setting)
    82 			{
    79 			{
       
    80 		case EBluetoothEnterpriseDisabled:
       
    81 			mode = EDisabled;
       
    82 			break;
       
    83 		case EBluetoothEnterpriseDataProfilesDisabled:
    83 			mode = EDataProfilesDisabled;
    84 			mode = EDataProfilesDisabled;
       
    85 			break;
       
    86 		case EBluetoothEnterpriseEnabled:
       
    87 			mode = EEnabled;
       
    88 			break;
       
    89 		default:
       
    90 			User::Leave(KErrUnknown);
       
    91 			break;
    84 			}
    92 			}
    85 		else
       
    86 			{
       
    87 			mode = EEnabled;
       
    88 			}	
       
    89 		}
    93 		}
    90     FeatureManager::UnInitializeLib();
    94 	else
    91     
    95 		{
       
    96 		// Some other error accessing the central repository.
       
    97 		User::Leave(err);
       
    98 		}
       
    99 	
       
   100 	CleanupStack::PopAndDestroy(cenRep);
       
   101 	
    92 	return mode;
   102 	return mode;
    93 	}
   103 	}