diff -r 02103bf20ee5 -r 90dbfc0435e3 bluetoothengine/headsetsimulator/profiles/hspprofile/src/hspsdp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/headsetsimulator/profiles/hspprofile/src/hspsdp.cpp Wed Sep 15 15:59:44 2010 +0200 @@ -0,0 +1,148 @@ +/* + * + * Copyright (c) <2010> Comarch S.A. 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". + * + * Original Contributors: + * Comarch S.A. - original contribution. + * + * Contributors: + * + * Description: + * + */ + +#include "hspsdp.h" +#include "debug.h" + +CHsHSPSDP* CHsHSPSDP::NewL() + { + + CHsHSPSDP *self = CHsHSPSDP::NewLC(); + CleanupStack::Pop( self ); + + return self; + } + +CHsHSPSDP* CHsHSPSDP::NewLC() + { + CHsHSPSDP *self = new ( ELeave ) CHsHSPSDP; + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +CHsHSPSDP::CHsHSPSDP() + { + } + +CHsHSPSDP::~CHsHSPSDP() + { + iSdpDatabase.Close(); + iSdp.Close(); + } + +void CHsHSPSDP::CreateSdpRecordL() + { + TRACE_FUNC_ENTRY + + if ( iSdpRecordHandle ) + { + User::Leave( KErrAlreadyExists ); + } + + // create service class id list + CSdpAttrValueDES* serviceClassIdList = CSdpAttrValueDES::NewDESL( NULL ); + CleanupStack::PushL( serviceClassIdList ); + + // add Headset UID (0x1131) and Generic Audio UID (0x1203) + serviceClassIdList->StartListL()->BuildDESL()->StartListL() + ->BuildUUIDL( TUUID( KHsHeadsetUid ) )->EndListL()->BuildDESL() + ->StartListL()->BuildUUIDL( TUUID( KHsGenericAudioUid ) ) + ->EndListL()->EndListL(); + + // register record in database + iSdpDatabase.CreateServiceRecordL( *serviceClassIdList, iSdpRecordHandle ); + CleanupStack::PopAndDestroy( serviceClassIdList ); + + CSdpAttrValueDES* protocolDescList = CSdpAttrValueDES::NewDESL( NULL ); + CleanupStack::PushL( protocolDescList ); + + // add protocol descriptor list to inform clients about listening channel + protocolDescList->StartListL()->BuildDESL()->StartListL()->BuildUUIDL( + TUUID( KL2CAPUUID ) )->EndListL()->BuildDESL()->StartListL() + ->BuildUUIDL( TUUID( KRFCommUUID ) )->BuildUintL( + TSdpIntBuf ( iServicePort ) )->EndListL()->EndListL(); + + // update record in database + iSdpDatabase.UpdateAttributeL( iSdpRecordHandle, + KSdpAttrIdProtocolDescriptorList, *protocolDescList ); + CleanupStack::PopAndDestroy( protocolDescList ); + + CSdpAttrValueDES* bluetoothProfileDescList = CSdpAttrValueDES::NewDESL( + NULL ); + CleanupStack::PushL( bluetoothProfileDescList ); + + /** + * add info of bluetooth profile - headset profile (0x1108) version 1.2 + * (0x0102) + */ + bluetoothProfileDescList->StartListL()->BuildDESL()->StartListL() + ->BuildUUIDL( TUUID( KHsHeadsetProfileUid ) ) + ->BuildUintL( TSdpIntBuf ( KHsHeadsetProfileVersion ) ) + ->EndListL()->EndListL(); + + // update record in database + iSdpDatabase.UpdateAttributeL( iSdpRecordHandle, + KSdpAttrIdBluetoothProfileDescriptorList, + *bluetoothProfileDescList ); + CleanupStack::PopAndDestroy( bluetoothProfileDescList ); + + // set service name and update record + iSdpDatabase.UpdateAttributeL( iSdpRecordHandle, + KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName, + KHsServiceNameHeadset ); + + // set remote audio volume control to false + CSdpAttrValueBoolean* remoteAudioVolumeControl = + CSdpAttrValueBoolean::NewBoolL( ETrue ); + CleanupStack::PushL( remoteAudioVolumeControl ); + iSdpDatabase.UpdateAttributeL( iSdpRecordHandle, + KHsRemoteAudioVolumeControl, *remoteAudioVolumeControl ); + CleanupStack::PopAndDestroy( remoteAudioVolumeControl ); + + // set availability to true + iSdpDatabase.UpdateAttributeL( iSdpRecordHandle, + KSdpAttrIdServiceAvailability, 0xFF ); + iSdpDatabase.UpdateAttributeL( iSdpRecordHandle, + KSdpAttrIdServiceRecordState, 1 ); + + TRACE_FUNC_EXIT + } + +void CHsHSPSDP::DeleteSdpRecordL() + { + TRACE_FUNC_ENTRY + + if ( iSdpRecordHandle ) + { + iSdpDatabase.DeleteRecordL( iSdpRecordHandle ); + iSdpRecordHandle = 0; + } + + TRACE_FUNC_EXIT + } + +void CHsHSPSDP::ConstructL() + { + TRACE_FUNC_ENTRY + + User::LeaveIfError( iSdp.Connect() ); + User::LeaveIfError( iSdpDatabase.Open( iSdp ) ); + + TRACE_FUNC_EXIT + }