bluetoothengine/bteng/btfeatures/btfeatures.cpp
changeset 0 f63038272f30
child 6 6a29d5ad0713
child 15 00f9ee97d895
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/bteng/btfeatures/btfeatures.cpp	Mon Jan 18 20:28:57 2010 +0200
@@ -0,0 +1,93 @@
+/*
+* 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;
+	}