bluetoothengine/bteng/btfeatures/btfeatures.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 22:59:18 +0200
branchRCL_3
changeset 6 6a29d5ad0713
parent 0 f63038272f30
child 13 b6f55cd40afd
permissions -rw-r--r--
Revision: 201003 Kit: 201007

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "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:
*
* Description: 
*
*/


#include <btfeaturescfg.h> 
#include <featmgr/featurecontrol.h>
#include <featmgr/featmgr.h>

/**
	Device supports bluetooth data profiles disabled.
*/
const TInt KFeatureIdTempFfBluetoothDataProfilesDisabled = 0x1000001;
	
/**
	Device supports bluetooth disabled.
*/
const TInt KFeatureIdTempFfBluetoothDisabled = 0x1000002;


EXPORT_C void BluetoothFeatures::SetEnterpriseEnablementL(BluetoothFeatures::TEnterpriseEnablementMode aMode)
	{
	// This method is only provided for use by the Bluetooth DCMO plugin. 
	// Hence we should be running in the DCMO server process.
	_LIT_SECURE_ID(KDcmoServerSecureUid, 0x2001FE47);
	RProcess proc;
	if ( proc.SecureId() != KDcmoServerSecureUid )
		{
		User::Leave(KErrPermissionDenied);
		}	

	const TUid KBtDisabledUid = {KFeatureIdTempFfBluetoothDisabled};
	const TUid KBtDataProfilesDisabledUid = {KFeatureIdTempFfBluetoothDataProfilesDisabled};

	RFeatureControl featureControl;
	User::LeaveIfError(featureControl.Connect());
	CleanupClosePushL(featureControl);
	switch ( aMode )
		{
	case EDisabled:
		User::LeaveIfError(featureControl.EnableFeature(KBtDisabledUid));
		User::LeaveIfError(featureControl.DisableFeature(KBtDataProfilesDisabledUid));
		break;
	case EDataProfilesDisabled:
		User::LeaveIfError(featureControl.DisableFeature(KBtDisabledUid));
		User::LeaveIfError(featureControl.EnableFeature(KBtDataProfilesDisabledUid));
		break;
	case EEnabled:
		User::LeaveIfError(featureControl.DisableFeature(KBtDisabledUid));
		User::LeaveIfError(featureControl.DisableFeature(KBtDataProfilesDisabledUid));
		break;
	default:
		User::Leave(KErrArgument);
		break;
		}
	CleanupStack::PopAndDestroy(&featureControl);
	}

EXPORT_C BluetoothFeatures::TEnterpriseEnablementMode BluetoothFeatures::EnterpriseEnablementL()
	{
	TEnterpriseEnablementMode mode = EDisabled;
	
	FeatureManager::InitializeLibL();
    const TBool bluetoothDisabled = FeatureManager::FeatureSupported(KFeatureIdTempFfBluetoothDisabled);
    if ( !bluetoothDisabled )
		{
		const TBool dataProfilesDisabled = FeatureManager::FeatureSupported(KFeatureIdTempFfBluetoothDataProfilesDisabled);
		if ( dataProfilesDisabled )
			{
			mode = EDataProfilesDisabled;
			}
		else
			{
			mode = EEnabled;
			}	
		}
    FeatureManager::UnInitializeLib();
    
	return mode;
	}