201029_01
authorhgs
Wed, 21 Jul 2010 15:42:05 +0300
changeset 35 14e279d2bbb7
parent 34 9d84592f5036
child 48 22de2e391156
201029_01
bluetooth/btstack/l2cap/L2CapFecNegotiator.cpp
bluetooth/btstack/l2cap/L2CapFecNegotiator.h
bluetooth/btstack/linkmgr/physicallinks.cpp
bluetooth/gavdp/inc/gavdpInternal.h
bluetooth/gavdp/source/gavdpHelpers.cpp
bluetooth/gavdp/source/gavdpImp.cpp
bluetoothmgmt/bluetoothclientlib/btlib/btsynclink.cpp
bluetoothmgmt/bluetoothclientlib/btlib/btsynclinkhelpers.h
bluetoothmgmt/bluetoothclientlib/inc/bt_sock.h
package_definition.xml
--- a/bluetooth/btstack/l2cap/L2CapFecNegotiator.cpp	Mon Jul 12 07:06:31 2010 +0300
+++ b/bluetooth/btstack/l2cap/L2CapFecNegotiator.cpp	Wed Jul 21 15:42:05 2010 +0300
@@ -558,6 +558,14 @@
 	ProcessPeerValue(response, EFalse);
 	}
 
+void TL2CapIncomingFecNegotiator::DowngradeToBasic()
+	{
+	LOG_FUNC
+	iPreferred = TRetransmissionAndFlowControlOption();
+	iConfigStatus = EOptionConfigComplete;
+	}
+
+
 void TL2CapIncomingFecNegotiator::BuildRequest(TL2CapChannelMode aMode, TRetransmissionAndFlowControlOption& aFecOption)
     {
     LOG_FUNC
@@ -761,9 +769,7 @@
 		iIncomingNegotiator.Preferred().LinkMode() != EL2CAPBasicMode)
 		{
 		LOG(_L("\tReceived Basic mode Config Request, downgrading incoming channel mode to Basic"));
-		// Downgrade incoming FEC to be basic mode.
-  		TRetransmissionAndFlowControlOption basicFec;
-  		iIncomingNegotiator.SetPreferred(basicFec);
+		iIncomingNegotiator.DowngradeToBasic();
 		}
 	}
 
--- a/bluetooth/btstack/l2cap/L2CapFecNegotiator.h	Mon Jul 12 07:06:31 2010 +0300
+++ b/bluetooth/btstack/l2cap/L2CapFecNegotiator.h	Wed Jul 21 15:42:05 2010 +0300
@@ -207,6 +207,7 @@
 	void ProcessPeerValue(const TRetransmissionAndFlowControlOption& aFecOption,
 						  TBool aIsUnacceptableParameters);
 	void ProcessImplicitPeerValue();
+	void DowngradeToBasic();
     void Setup();
 protected:
     void BuildRequest(TL2CapChannelMode aMode, TRetransmissionAndFlowControlOption& aFecOption);
--- a/bluetooth/btstack/linkmgr/physicallinks.cpp	Mon Jul 12 07:06:31 2010 +0300
+++ b/bluetooth/btstack/linkmgr/physicallinks.cpp	Wed Jul 21 15:42:05 2010 +0300
@@ -58,7 +58,7 @@
 static const THCIErrorCode KDefaultRejectReason = EHostSecurityRejection; // see spec Error Codes
 
 #ifdef _DEBUG
-#define __CHECK_CONNECTION_HANDLE(aHandle) __ASSERT_DEBUG(aHandle==iHandle, Panic(EBTLinkMgrConnectionEventInWrongSAP));
+#define __CHECK_CONNECTION_HANDLE(aHandle) __ASSERT_DEBUG(HasHandle(aHandle), Panic(EBTLinkMgrConnectionEventInWrongSAP));
 #else
 #define __CHECK_CONNECTION_HANDLE(aHandle) aHandle=aHandle; // to suppress warnings
 #endif
--- a/bluetooth/gavdp/inc/gavdpInternal.h	Mon Jul 12 07:06:31 2010 +0300
+++ b/bluetooth/gavdp/inc/gavdpInternal.h	Wed Jul 21 15:42:05 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 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"
@@ -301,16 +301,17 @@
 NONSHARABLE_CLASS(CGavdpConnector) : public CGavdpHelper
 	{
 public:
-	static CGavdpConnector* NewL(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr);
+	static CGavdpConnector* NewL(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr, TBool aPassive = EFalse);
 	
 	virtual void Begin();
 	~CGavdpConnector();
 private:
-	CGavdpConnector(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr);
+	CGavdpConnector(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr, TBool aPassive);
 	void RunL();
 	void DoCancel();
 private:
 	TAvdtpSockAddr	iSocketAddress;
+	TBool			iIsPassiveConnector;	//true when listening
 	};
 
 class CGavdpUPlaneConnector;
--- a/bluetooth/gavdp/source/gavdpHelpers.cpp	Mon Jul 12 07:06:31 2010 +0300
+++ b/bluetooth/gavdp/source/gavdpHelpers.cpp	Wed Jul 21 15:42:05 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 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"
@@ -473,16 +473,17 @@
 
 	
 
-CGavdpConnector* CGavdpConnector::NewL(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr)
+CGavdpConnector* CGavdpConnector::NewL(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr, TBool aPassive)
 	{
-	return new (ELeave) CGavdpConnector(aGavdp, aUser, aAddr);
+	return new (ELeave) CGavdpConnector(aGavdp, aUser, aAddr, aPassive);
 	}
-	
-CGavdpConnector::CGavdpConnector(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr)
+
+CGavdpConnector::CGavdpConnector(CGavdp& aGavdp, MGavdpUser& aUser, const TBTDevAddr& aAddr, TBool aPassive)
 : CGavdpHelper(aGavdp, aUser)
 	{
 	iSocketAddress.SetBTAddr(aAddr);
 	iSocketAddress.SetSession(ESignalling);
+	iIsPassiveConnector = aPassive;
 	}
 
 CGavdpConnector::~CGavdpConnector()
@@ -492,10 +493,13 @@
 
 void CGavdpConnector::DoCancel()
 	{
-	AvdtpRequester().CancelAll(); // ESOCK has better semantics to SAP than CancelConnect.
+	//don't call cancel on the socket for passive connectors to prevent cancelling a listening socket
+	if (!iIsPassiveConnector)
+		{
+		AvdtpRequester().CancelAll(); // ESOCK has better semantics to SAP than CancelConnect.
+		}
 	}
 
-
 void CGavdpConnector::Begin()
 	{
 	// Ensure that once this is completed the RunL is scheduled
@@ -507,7 +511,6 @@
 
 void CGavdpConnector::RunL()
 	{
-		
 	// Do not call CGavdpHelper::CheckFailedL() here - avdtp will indicate a failure to connect, 
 	// and GAVDP is informed via CGavdpIndicator::RunL().
 	
@@ -751,14 +754,14 @@
 				}
 			};
 		}
+	
+	// This service is never complete, reissue ioctl.  We do this once we have finished using
+	// the iIndication data as once the ioctl has been issued the data may be overwritten.
+	// If AVDTP has an indication to pass to us and an ioctl has not been issued the
+	// indication will be queued within AVDTP until we have issued the ioctl again.
+	Begin();
+	}
 
-		// This service is never complete, reissue ioctl.  We do this once we have finished using
-		// the iIndication data as once the ioctl has been issued the data may be overwritten.
-		// If AVDTP has an indication to pass to us and an ioctl has not been issued the
-		// indication will be queued within AVDTP until we have issued the ioctl again.
-		Begin();
-	}
-	
 /**
 RunError overriden for CGavdpIndicator only. This GAVDP helper is used in its own right by GAVDP.
 It is not treated as a 'general' GAVDP helper, and, unlike a 'general' GAVDP helper,
--- a/bluetooth/gavdp/source/gavdpImp.cpp	Mon Jul 12 07:06:31 2010 +0300
+++ b/bluetooth/gavdp/source/gavdpImp.cpp	Wed Jul 21 15:42:05 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 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"
@@ -445,12 +445,37 @@
 	
 void CGavdp::Error(TInt aError)
 	{
-	// helper tells user - here we do whatever we need to tidy ourselves
+	//here we do whatever we need to tidy ourselves
 	delete iRequesterHelper;
 	iRequesterHelper = NULL;
-	iState = EIdle;
-	// and tell the user
-	iServiceUser.GAVDP_Error(aError, KNullDesC8);
+	
+	if (iState == EListening)
+		{
+		//if we're in the listening state and we get a KErrDisconnected error, this is
+		//because a connection completed and was disconnected straight away before we got
+		//the chance to pickup the connection indicator. We need to re-listen and throw
+		//away this error. Let's replace the error with the result of the re-listen.
+		if (aError == KErrDisconnected)
+			{
+			aError = Listen();
+			}
+		
+		//when listening, it doesn't make sense to pass this error to the user
+		if (aError == KErrCouldNotConnect)
+			{
+			aError = KErrNone;
+			}
+		}
+	
+	//the error might have been replaced due to the condition mentioned above so
+	//this needs to be checked.
+	if (aError != KErrNone)
+		{
+		iServiceUser.GAVDP_Error(aError, KNullDesC8);
+		
+		//update the state because an error did occur
+		iState = EIdle;
+		}
 	}
 
 void CGavdp::FatalError()
@@ -476,10 +501,12 @@
 		// eg Abort, Config
 		User::Leave(KErrInUse);
 		}
-	iRequesterHelper = CGavdpConnector::NewL(*this, iServiceUser, aRemoteAddress);
+	
+	//create a passive connector helper
+	iRequesterHelper = CGavdpConnector::NewL(*this, iServiceUser, aRemoteAddress, ETrue);
 	iRequesterHelper->Begin();
 	}
-	
+
 /*
 Forms the binding between passively created transport sessions and sockets
 */
--- a/bluetoothmgmt/bluetoothclientlib/btlib/btsynclink.cpp	Mon Jul 12 07:06:31 2010 +0300
+++ b/bluetoothmgmt/bluetoothclientlib/btlib/btsynclink.cpp	Wed Jul 21 15:42:05 2010 +0300
@@ -160,7 +160,6 @@
 
 // This needs to be a macro or the 'return' won't return properly
 #define CLOSE_RETURN_IF_ERROR(error) if (error) { LinkDown(); SCOSocket().Close(); ESCOSocket().Close(); return error; }
-#define CLOSE_LISTENER_RETURN_IF_ERROR(error) if (error) { ListeningSCOSocket().Close(); ListeningESCOSocket().Close(); return error; }
 
 EXPORT_C TInt CBluetoothSynchronousLink::SetupConnection(const TBTDevAddr& aBDAddr, const TBTSyncPackets& aPacketTypes)
 	{
@@ -191,23 +190,17 @@
 	if (packetsESCO) 
 		{
 		iSCOTypes |= EeSCO;
-		openESCO = ETrue;	
+		openESCO = ETrue;
 		}
 		
 	// but must be one		
 	__ASSERT_ALWAYS(packetsSCO || packetsESCO, Panic(EBadSyncPacketTypes));
 
-	if (iBTSynchronousLinkAttacherSCO->IsActive())
+	if (iBTSynchronousLinkAttacherSCO->IsActive() || iBTSynchronousLinkAttacherESCO->IsActive())
 		{
 		FLOG(_L("Link attacher already active"));
 		return KErrInUse;
 		}
-	
-	if (iBTSynchronousLinkAttacherESCO->IsActive())
-		{
-		FLOG(_L("Link attacher already active"));
-		return KErrInUse;
-		}	
 		
 	TInt linkState = LinkUp(aBDAddr);
 	if (linkState != KErrNone)
@@ -337,16 +330,12 @@
 */
 EXPORT_C TInt CBluetoothSynchronousLink::Disconnect()
 	{
-	if (!SCOSocket().SubSessionHandle())
+	if (!SCOSocket().SubSessionHandle() && !ESCOSocket().SubSessionHandle())
 		{
-		if(!ESCOSocket().SubSessionHandle())
-			{
-			return KErrDisconnected;
-			}
+		return KErrDisconnected;
 		}
 
-	if (iBTSynchronousLinkDetacherSCO->IsActive() ||
-	    iBTSynchronousLinkDetacherESCO->IsActive())
+	if (iBTSynchronousLinkDetacherSCO->IsActive() || iBTSynchronousLinkDetacherESCO->IsActive())
 		{
 		return KErrInUse;
 		}
@@ -499,6 +488,12 @@
 */
 EXPORT_C TInt CBluetoothSynchronousLink::AcceptConnection(const TBTSyncPackets& aPacketTypes)
 	{
+	TRAPD(err, AcceptConnectionL(aPacketTypes));
+	return err;
+	}
+	
+void CBluetoothSynchronousLink::AcceptConnectionL(const TBTSyncPackets& aPacketTypes)
+	{
 	TBool listenForSCO = EFalse;
 	TBool listenForESCO = EFalse;
 
@@ -506,41 +501,30 @@
 	
 	TBTSyncPacketTypes packets = aPacketTypes();
 	
-	
 	__ASSERT_ALWAYS(packets, Panic(EBadSyncPacketTypes));
 	packets &= (TBTSyncPackets::ESyncAnySCOPacket | TBTSyncPackets::ESyncAnyESCOPacket);
 	if (!packets)
 		{
-		return KErrNotSupported;
+		User::Leave(KErrNotSupported);
 		}
 
-	if (iBTSynchronousLinkAccepterSCO->IsActive())
+	if (iBTSynchronousLinkAccepterSCO->IsActive() || iBTSynchronousLinkAccepterESCO->IsActive())
 		{
-		return KErrInUse;
-		}
-		
-	if (iBTSynchronousLinkAccepterESCO->IsActive())
-		{
-		return KErrInUse;
+		User::Leave(KErrInUse);
 		}
 	
-	TInt err = ListeningSCOSocket().Open(iSockServer, KBTAddrFamily, KSockBluetoothTypeSCO, KBTLinkManager);
-	if(err)
-		{
-		return err;
-		}
+	User::LeaveIfError(ListeningSCOSocket().Open(iSockServer, KBTAddrFamily, KSockBluetoothTypeSCO, KBTLinkManager));
+	CleanupClosePushL(ListeningSCOSocket());
 		
-	err = ListeningESCOSocket().Open(iSockServer, KBTAddrFamily, KSockBluetoothTypeESCO, KBTLinkManager);
-	if(err)
-		{
-		ListeningSCOSocket().Close();
-		return err;
-		}
+	User::LeaveIfError(ListeningESCOSocket().Open(iSockServer, KBTAddrFamily, KSockBluetoothTypeESCO, KBTLinkManager));
+	CleanupClosePushL(ListeningESCOSocket());
+	
+	CleanupStack::PushL(TCleanupItem(StaticResetScoTypes, this)); // we want to clear any setting of SCO types upon leaving
 	
 	TBTSyncPacketTypes packetsSCO = packets & TBTSyncPackets::ESyncAnySCOPacket;
 	if (packetsSCO)
 		{
-		err = ListeningSCOSocket().SetOpt(ESyncUserPacketTypes, KSolBtSCO, packetsSCO);
+		TInt err = ListeningSCOSocket().SetOpt(ESyncUserPacketTypes, KSolBtSCO, packetsSCO);
 		if(!err)
 			{
 			iSCOTypes |= ESCO;
@@ -551,17 +535,15 @@
 	TBTSyncPacketTypes packetsESCO = packets & TBTSyncPackets::ESyncAnyESCOPacket;
 	if (packetsESCO) 
 		{
-		err = ListeningESCOSocket().SetOpt(ESyncUserPacketTypes, KSolBtSCO, packetsESCO);
+		TInt err = ListeningESCOSocket().SetOpt(ESyncUserPacketTypes, KSolBtSCO, packetsESCO);
 		if (!err)
 			{
 			iSCOTypes |= EeSCO;
 			listenForESCO = ETrue;
+			
+			TPckgC<TBTeSCOLinkParams> options(iRequestedLink);
+			User::LeaveIfError(ListeningESCOSocket().SetOpt(EeSCOExtOptions, KSolBtESCO, options));
 			}
-			
-		TPckgBuf<TBTeSCOLinkParams> options;
-		options() = iRequestedLink;
-		err = ListeningESCOSocket().SetOpt(EeSCOExtOptions, KSolBtESCO, options);
-		CLOSE_LISTENER_RETURN_IF_ERROR(err);	
 		}
 
 	__ASSERT_ALWAYS(listenForSCO || listenForESCO, Panic(EBadSyncPacketTypes));
@@ -580,62 +562,57 @@
 	
 	if (listenForSCO)
 		{
-		err = ListeningSCOSocket().Bind(sa);
-		CLOSE_LISTENER_RETURN_IF_ERROR(err);
-		
-		err = ListeningSCOSocket().Listen(KSCOListenQueSize);
-		CLOSE_LISTENER_RETURN_IF_ERROR(err);
-		
-		err = SCOSocket().Open(SocketServer());							    
-		if(err)
-			{
-			return err;
-			}
+		User::LeaveIfError(ListeningSCOSocket().Bind(sa));
+		User::LeaveIfError(ListeningSCOSocket().Listen(KSCOListenQueSize));
+		User::LeaveIfError(SCOSocket().Open(SocketServer()));
+		CleanupClosePushL(SCOSocket());
 		}
 	
 	if(listenForESCO)
 		{
-		err = ListeningESCOSocket().Bind(sa);
-		CLOSE_LISTENER_RETURN_IF_ERROR(err);
-	
-		err = ListeningESCOSocket().Listen(KSCOListenQueSize);
-		CLOSE_LISTENER_RETURN_IF_ERROR(err);
+		User::LeaveIfError(ListeningESCOSocket().Bind(sa));
+		User::LeaveIfError(ListeningESCOSocket().Listen(KSCOListenQueSize));
+		User::LeaveIfError(ESCOSocket().Open(SocketServer()));
+		}
+
+	// Now we can't fail synchronously, so we're ready to begin the accept.
+	if(listenForESCO)
+		{
+		iBTSynchronousLinkAccepterESCO->Accept();
+		}
 		
-		err = ESCOSocket().Open(SocketServer());	
-		if(err)
-			{
-			return err;
-			}
-		}	
-
 	if (listenForSCO)
 		{
-		iBTSynchronousLinkAccepterSCO->Accept(ListeningSCOSocket());
+		CleanupStack::Pop(&SCOSocket());
+		iBTSynchronousLinkAccepterSCO->Accept();
 		}
 	
-	if(listenForESCO)
-		{
-		iBTSynchronousLinkAccepterESCO->Accept(ListeningESCOSocket());
-		}
+	CleanupStack::Pop(3); // StaticResetScoTypes, ListeningESCOSocket(), ListeningSCOSocket()
+	}
 	
-	return err;
+void CBluetoothSynchronousLink::StaticResetScoTypes(TAny* aThis)
+	{
+	static_cast<CBluetoothSynchronousLink*>(aThis)->iSCOTypes = 0;
 	}
 
 
 /**
 Cancel ability to respond to a remote request to set up a synchronous link.
-It is possible for a race condition to mean that a connection has been established,
-but as this call consumes the callback, for this fact not to reach the caller.
-For this reason, it may be desirable to follow a call to CancelAccept with a call
-to Disconnect.
-@see CBluetoothSynchronousLink::Disconnect
+
+It is possible for a race condition to mean that a connection has been established
+but the notifier has not yet received the call-back.  In this case no call-back will
+be received and the link (if established) will be immediately shutdown.
 */
 EXPORT_C void CBluetoothSynchronousLink::CancelAccept()
 	{
 	iBTSynchronousLinkAccepterSCO->Cancel();
 	iBTSynchronousLinkAccepterESCO->Cancel();
 	iBTSynchronousLinkBaseband->StopAll();
-
+	
+	iSCOTypes = 0;
+	
+	LinkDown();
+	
 	ListeningSCOSocket().Close();
 	ListeningESCOSocket().Close();
 	SCOSocket().Close();
@@ -896,36 +873,48 @@
 		if (aSCOType & ESCO)
 			{
 			iBTSynchronousLinkAccepterESCO->Cancel();
+			ListeningESCOSocket().Close();
+			ESCOSocket().Close();
+			
 			SCOSocket().RemoteName(sockAddr);
 			}
 		else
 			{
 			iBTSynchronousLinkAccepterSCO->Cancel();
+			ListeningSCOSocket().Close();
+			SCOSocket().Close();
+			
 			ESCOSocket().RemoteName(sockAddr);
 			}
 		
 		if(sockAddr.Family() == KBTAddrFamily)
 			{
-			TBTSockAddr& btSockAddr = static_cast<TBTSockAddr&>(sockAddr);	// subclasses of TSockAddr are forbidden to add members
+			TBTSockAddr& btSockAddr = static_cast<TBTSockAddr&>(sockAddr);
 			TBTDevAddr da = btSockAddr.BTAddr();
-			TInt linkState = LinkUp(da);
-				
-			__ASSERT_ALWAYS((linkState == KErrNone), Panic(EBasebandFailedConnect));
-			
-			iBTSynchronousLinkBaseband->PreventPark();
-			iBTSynchronousLinkBaseband->CatchEvents();
-			UpdateLinkParams(aSCOType);
+			aErr = LinkUp(da);
+			if(aErr == KErrNone)
+				{
+				iBTSynchronousLinkBaseband->PreventPark();
+				iBTSynchronousLinkBaseband->CatchEvents();
+				UpdateLinkParams(aSCOType);
+				}
+			else
+				{
+				FTRACE(FPrint(_L("Failed to \"LinkUp\" the synchronous link (aErr %d)"), aErr));
+				}
 			}
 		else
 			{
 			// reading RemoteName has failed, probably socket state is already closed
 			// for example after quick disconnection initiated from remote side
-			aErr = KErrDisconnected;			
+			aErr = KErrDisconnected;
 			}
 		}
-	else
+	
+	if(aErr != KErrNone)
 		{
 		iNegotiatedLink = TBTeSCOLinkParams(0, 0, 0, 0);
+		CancelAccept(); // makes sure everything is cleaned up.
 		}
 
 #ifdef __FLOGGING__
@@ -935,9 +924,6 @@
 #else
 	Notifier().HandleAcceptConnectionCompleteL(aErr);
 #endif
-	
-	ListeningSCOSocket().Close();
-	ListeningESCOSocket().Close();
 	}
 
 
@@ -1034,24 +1020,16 @@
 CBTSynchronousLinkBaseband* CBTSynchronousLinkBaseband::NewL(CBluetoothSynchronousLink& aParent)
 	{
 	CBTSynchronousLinkBaseband* self = new(ELeave) CBTSynchronousLinkBaseband(aParent);
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	CleanupStack::Pop(self);
 	return self;
 	}
 
 
 CBTSynchronousLinkBaseband::CBTSynchronousLinkBaseband(CBluetoothSynchronousLink& aParent)
 	: CActive(CActive::EPriorityStandard), iParent(aParent)
-	{}
-
-
-void CBTSynchronousLinkBaseband::ConstructL()
 	{
 	CActiveScheduler::Add(this);
 	}
 
-
 CBTSynchronousLinkBaseband::~CBTSynchronousLinkBaseband()
 	{
 	StopAll();
@@ -1093,7 +1071,7 @@
 	Cancel();
 	}
 
-
+	
 void CBTSynchronousLinkBaseband::DoCancel()
 	{
 	iParent.Baseband().CancelNextBasebandChangeEventNotifier();
@@ -1104,20 +1082,12 @@
 CBTSynchronousLinkAttacher* CBTSynchronousLinkAttacher::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType)
 	{
 	CBTSynchronousLinkAttacher* self = new (ELeave) CBTSynchronousLinkAttacher(aParent, aSCOType);
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	CleanupStack::Pop(self);
 	return self;
 	}
 
-
 CBTSynchronousLinkAttacher::CBTSynchronousLinkAttacher(CBluetoothSynchronousLink& aParent, TSCOType aSCOType)
 	: CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType)
 	{
-	}
-
-void CBTSynchronousLinkAttacher::ConstructL()
-	{
 	CActiveScheduler::Add(this);
 	}
 
@@ -1155,7 +1125,6 @@
 	return KErrNone;
 	}
 
-
 void CBTSynchronousLinkAttacher::DoCancel()
 	{
 	FLOG(_L("CBTSynchronousLinkAttacher cancel attach sync link"));
@@ -1174,20 +1143,12 @@
 CBTSynchronousLinkDetacher* CBTSynchronousLinkDetacher::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType)
 	{
 	CBTSynchronousLinkDetacher* self = new (ELeave) CBTSynchronousLinkDetacher(aParent, aSCOType);
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	CleanupStack::Pop(self);
 	return self;
 	}
 
-
 CBTSynchronousLinkDetacher::CBTSynchronousLinkDetacher(CBluetoothSynchronousLink& aParent, TSCOType aSCOType)
 	: CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType)
 	{
-	}
-
-void CBTSynchronousLinkDetacher::ConstructL()
-	{
 	CActiveScheduler::Add(this);
 	}
 
@@ -1240,9 +1201,6 @@
 CBTSynchronousLinkAccepter* CBTSynchronousLinkAccepter::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType)
 	{
 	CBTSynchronousLinkAccepter* self = new (ELeave) CBTSynchronousLinkAccepter(aParent, aSCOType);
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	CleanupStack::Pop(self);
 	return self;
 	}
 
@@ -1250,10 +1208,6 @@
 CBTSynchronousLinkAccepter::CBTSynchronousLinkAccepter(CBluetoothSynchronousLink& aParent, TSCOType aSCOType)
 	: CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType)
 	{
-	}
-
-void CBTSynchronousLinkAccepter::ConstructL()
-	{
 	CActiveScheduler::Add(this);
 	}
 
@@ -1262,7 +1216,7 @@
 	Cancel();
 	}
 
-void CBTSynchronousLinkAccepter::Accept(RSocket& aSocket)
+void CBTSynchronousLinkAccepter::Accept()
 
 	{
 	__ASSERT_ALWAYS(!IsActive(), Panic(EUnfinishedBusiness));
@@ -1270,11 +1224,11 @@
 	FLOG(_L("CBTSynchronousLinkAccepter accept sync link"));
 	if (iSCOType == ESCO)
 		{
-		aSocket.Accept(iParent.SCOSocket(), iStatus);
+		iParent.ListeningSCOSocket().Accept(iParent.SCOSocket(), iStatus);
 		}
 	else
 		{
-		aSocket.Accept(iParent.ESCOSocket(), iStatus);
+		iParent.ListeningESCOSocket().Accept(iParent.ESCOSocket(), iStatus);
 		}
 	SetActive();
 	}
@@ -1315,9 +1269,6 @@
 CBTSynchronousLinkSender* CBTSynchronousLinkSender::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType)
 	{
 	CBTSynchronousLinkSender* self = new (ELeave) CBTSynchronousLinkSender(aParent, aSCOType);
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	CleanupStack::Pop(self);
 	return self;
 	}
 
@@ -1325,10 +1276,6 @@
 CBTSynchronousLinkSender::CBTSynchronousLinkSender(CBluetoothSynchronousLink& aParent, TSCOType aSCOType)
 	: CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType)
 	{
-	}
-
-void CBTSynchronousLinkSender::ConstructL()
-	{
 	CActiveScheduler::Add(this);
 	}
 
@@ -1403,9 +1350,6 @@
 CBTSynchronousLinkReceiver* CBTSynchronousLinkReceiver::NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType)
 	{
 	CBTSynchronousLinkReceiver* self = new (ELeave) CBTSynchronousLinkReceiver(aParent, aSCOType);
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	CleanupStack::Pop(self);
 	return self;
 	}
 
@@ -1413,10 +1357,6 @@
 CBTSynchronousLinkReceiver::CBTSynchronousLinkReceiver(CBluetoothSynchronousLink& aParent, TSCOType aSCOType)
 	: CActive(CActive::EPriorityStandard), iParent(aParent), iSCOType(aSCOType)
 	{
-	}
-
-void CBTSynchronousLinkReceiver::ConstructL()
-	{
 	CActiveScheduler::Add(this);
 	}
 
--- a/bluetoothmgmt/bluetoothclientlib/btlib/btsynclinkhelpers.h	Mon Jul 12 07:06:31 2010 +0300
+++ b/bluetoothmgmt/bluetoothclientlib/btlib/btsynclinkhelpers.h	Wed Jul 21 15:42:05 2010 +0300
@@ -32,7 +32,6 @@
 	
 private:
 	CBTSynchronousLinkBaseband(CBluetoothSynchronousLink& aParent);
-	void ConstructL();
 	void DoCancel();
 	void RunL();
 	TInt RunError(TInt aError);
@@ -41,7 +40,7 @@
 	TBTBasebandEvent			iEvent;
 	};
 
-//CBluetoothSynchronousLink Active Objects...
+
 NONSHARABLE_CLASS(CBTSynchronousLinkAttacher) : public CActive
 	{
 public:
@@ -53,7 +52,6 @@
 
 private:
 	CBTSynchronousLinkAttacher(CBluetoothSynchronousLink& aParent, TSCOType aSCOTypes);
-	void ConstructL();
 	void DoCancel();
 	void RunL();
 	TInt RunError(TInt aError);
@@ -75,7 +73,6 @@
 
 private:
 	CBTSynchronousLinkDetacher(CBluetoothSynchronousLink& aParent, TSCOType aSCOTypes);
-	void ConstructL();
 	void DoCancel();
 	void RunL();
 	TInt RunError(TInt aError);
@@ -93,12 +90,11 @@
 	static CBTSynchronousLinkAccepter* NewL(CBluetoothSynchronousLink& aParent, TSCOType aSCOType);
 	~CBTSynchronousLinkAccepter();
 
-	void Accept(RSocket& aSocket);
+	void Accept();
 
 
 private:
 	CBTSynchronousLinkAccepter(CBluetoothSynchronousLink& aParent, TSCOType aSCOType);
-	void ConstructL();
 	void DoCancel();
 	void RunL();
 	TInt RunError(TInt aError);
@@ -120,7 +116,6 @@
 
 private:
 	CBTSynchronousLinkSender(CBluetoothSynchronousLink& aParent, TSCOType aSCOType);
-	void ConstructL();
 	void DoCancel();
 	void RunL();
 	TInt RunError(TInt aError);
@@ -142,7 +137,6 @@
 
 private:
 	CBTSynchronousLinkReceiver(CBluetoothSynchronousLink& aParent, TSCOType aSCOTypes);
-	void ConstructL();
 	void DoCancel();
 	void RunL();
 	TInt RunError(TInt aError);
--- a/bluetoothmgmt/bluetoothclientlib/inc/bt_sock.h	Mon Jul 12 07:06:31 2010 +0300
+++ b/bluetoothmgmt/bluetoothclientlib/inc/bt_sock.h	Wed Jul 21 15:42:05 2010 +0300
@@ -1424,6 +1424,8 @@
 	void UpdateLinkParams(TSCOType aSCOType);
 	TInt LinkUp(TBTDevAddr aAddr);
 	void LinkDown();
+	void AcceptConnectionL(const TBTSyncPackets& aPacketTypes);
+	static void StaticResetScoTypes(TAny* aThis);
 
 private:
 	CBTSynchronousLinkSender*			iBTSynchronousLinkSenderSCO;
--- a/package_definition.xml	Mon Jul 12 07:06:31 2010 +0300
+++ b/package_definition.xml	Wed Jul 21 15:42:05 2010 +0300
@@ -1,103 +1,104 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <SystemDefinition schema="3.0.0">
-  <package id="bt" name="Bluetooth" levels="adaptation hw-if plugin framework server app-if">
+ <package id="bt" name="Bluetooth" levels="adaptation hw-if plugin framework server app-if">
   <collection id="bt_plat" name="Bluetooth Platform Interfaces" level="app-if">
-      <component id="bluetooth_audio_adaptation_api" name="Bluetooth Audio Adaptation API" class="api" filter="s60">
-        <meta rel="Api" href="bt_plat/bluetooth_audio_adaptation_api/bluetooth_audio_adaptation_api.metaxml"/>
-        <unit bldFile="bt_plat/bluetooth_audio_adaptation_api/group"/>
-      </component>
-      <component id="bluetooth_power_management_api" name="Bluetooth Power Management API" class="api" filter="s60">
-        <meta rel="Api" href="bt_plat/bluetooth_power_management_api/bluetooth_power_management_api.metaxml"/>
-        <unit bldFile="bt_plat/bluetooth_power_management_api/group"/>
-      </component>
-      <component id="at_command_handler_plugin_api" name="AT Command Handler Plugin API" class="api" filter="s60">
-        <meta rel="Api" href="bt_plat/at_command_handler_plugin_api/at_command_handler_plugin_api.metaxml"/>
-        <unit bldFile="bt_plat/at_command_handler_plugin_api/group"/>
-      </component>
+   <component id="bluetooth_audio_adaptation_api" name="Bluetooth Audio Adaptation API" class="api" filter="s60">
+    <meta rel="Api" href="bt_plat/bluetooth_audio_adaptation_api/bluetooth_audio_adaptation_api.metaxml"/>
+    <unit bldFile="bt_plat/bluetooth_audio_adaptation_api/group"/>
+   </component>
+   <component id="bluetooth_power_management_api" name="Bluetooth Power Management API" class="api" filter="s60">
+    <meta rel="Api" href="bt_plat/bluetooth_power_management_api/bluetooth_power_management_api.metaxml"/>
+    <unit bldFile="bt_plat/bluetooth_power_management_api/group"/>
+   </component>
+   <component id="at_command_handler_plugin_api" name="AT Command Handler Plugin API" class="api" filter="s60">
+    <meta rel="Api" href="bt_plat/at_command_handler_plugin_api/at_command_handler_plugin_api.metaxml"/>
+    <unit bldFile="bt_plat/at_command_handler_plugin_api/group"/>
+   </component>
+  </collection>
+  <collection id="bluetooth" name="Bluetooth Core" level="framework">
+   <component id="btstack" name="Bluetooth Stack" introduced="6.0" purpose="optional">
+    <unit bldFile="bluetooth/btstack" mrp="bluetooth/btstack/bluetooth_stack.mrp"/>
+   </component>
+   <component id="btcomm" name="Bluetooth CSY" introduced="6.0" purpose="optional" class="plugin">
+    <unit bldFile="bluetooth/btcomm" mrp="bluetooth/btcomm/bluetooth_btcomm.mrp"/>
+   </component>
+   <component id="btsdp" name="Bluetooth SDP" introduced="6.1" purpose="optional">
+    <unit bldFile="bluetooth/btsdp" mrp="bluetooth/btsdp/bluetooth_sdp.mrp"/>
+   </component>
+   <component id="btextnotifiers" name="Bluetooth Notifiers Support" introduced="6.1" purpose="optional">
+    <unit bldFile="bluetooth/btextnotifiers" mrp="bluetooth/btextnotifiers/bluetooth_btextnotifiers.mrp"/>
+   </component>
+   <component id="gavdp" name="Bluetooth GAVDP" introduced="8.1" purpose="optional">
+    <unit bldFile="bluetooth/gavdp/group" mrp="bluetooth/gavdp/group/bluetooth_gavdp.mrp"/>
+   </component>
+   <component id="btexample" name="Bluetooth Examples and Tests" introduced="6.1" purpose="development" filter="test">
+    <unit mrp="bluetooth/btexample/test/bluetooth_tests_examples.mrp" bldFile="bluetooth/btexample/test/group"/>
+   </component>
+   <component id="btlogger" name="Bluetooth Logging Engine" introduced="9.2" purpose="optional">
+    <unit bldFile="bluetooth/btlogger/group" mrp="bluetooth/btlogger/group/bluetooth_logger.mrp"/>
+   </component>
+   <component id="btdocs" name="Bluetooth Documentation" purpose="development" class="doc">
+    <unit mrp="bluetooth/btdocs/bluetooth_documentation.mrp"/>
+   </component>
   </collection>
-    <collection id="bluetooth" name="Bluetooth Core" level="framework">
-      <component id="btstack" name="Bluetooth Stack" introduced="6.0" purpose="optional">
-        <unit bldFile="bluetooth/btstack" mrp="bluetooth/btstack/bluetooth_stack.mrp"/>
-      </component>
-      <component id="btcomm" name="Bluetooth CSY" introduced="6.0" purpose="optional" class="plugin">
-        <unit bldFile="bluetooth/btcomm" mrp="bluetooth/btcomm/bluetooth_btcomm.mrp"/>
-      </component>
-      <component id="btsdp" name="Bluetooth SDP" introduced="6.1" purpose="optional">
-        <unit bldFile="bluetooth/btsdp" mrp="bluetooth/btsdp/bluetooth_sdp.mrp"/>
-      </component>
-      <component id="btextnotifiers" name="Bluetooth Notifiers Support" introduced="6.1" purpose="optional">
-        <unit bldFile="bluetooth/btextnotifiers" mrp="bluetooth/btextnotifiers/bluetooth_btextnotifiers.mrp"/>
-      </component>
-      <component id="gavdp" name="Bluetooth GAVDP" introduced="8.1" purpose="optional">
-        <unit bldFile="bluetooth/gavdp/group" mrp="bluetooth/gavdp/group/bluetooth_gavdp.mrp"/>
-      </component>
-      <component id="btexample" name="Bluetooth Examples and Tests" introduced="6.1" purpose="development" filter="test">
-        <unit mrp="bluetooth/btexample/test/bluetooth_tests_examples.mrp" bldFile="bluetooth/btexample/test/group"/>
-      </component>
-      <component id="btlogger" name="Bluetooth Logging Engine" introduced="9.2" purpose="optional">
-        <unit bldFile="bluetooth/btlogger/group" mrp="bluetooth/btlogger/group/bluetooth_logger.mrp"/>
-      </component>
-      <component id="btdocs" name="Bluetooth Documentation" purpose="development" class="doc">
-        <unit mrp="bluetooth/btdocs/bluetooth_documentation.mrp"/>
-      </component>
-    </collection>
-    <collection id="bluetoothmgmt" name="Bluetooth Management" level="plugin">
-      <component id="btmgr" name="Bluetooth Manager" introduced="6.0" purpose="optional">
-        <unit bldFile="bluetoothmgmt/btmgr" mrp="bluetoothmgmt/btmgr/bluetooth_manager.mrp"/>
-      </component>
-      <component id="btconfig" name="Bluetooth Config" purpose="optional" class="config">
-        <unit bldFile="bluetoothmgmt/btconfig" mrp="bluetoothmgmt/btconfig/bluetooth_config.mrp"/>
-      </component>
-      <component id="btrom" name="Bluetooth ROM" introduced="9.1" purpose="optional">
-        <unit bldFile="bluetoothmgmt/btrom" mrp="bluetoothmgmt/btrom/bluetooth_rom.mrp"/>
-      </component>
-      <component id="bluetoothclientlib" name="Bluetooth Client Library" introduced="6.0" purpose="optional">
-        <unit bldFile="bluetoothmgmt/bluetoothclientlib" mrp="bluetoothmgmt/bluetoothclientlib/bluetooth_user.mrp"/>
-      </component>
-      <component id="btcommon" name="Bluetooth Build Utilities" purpose="optional" filter="test">
-        <unit mrp="bluetoothmgmt/btcommon/bluetooth_common.mrp" bldFile="bluetoothmgmt/btcommon"/>
-      </component>
-    </collection>
-    <collection id="bluetoothcommsprofiles" name="Bluetooth Comms Profiles" level="app-if">
-      <component id="btpan" name="Bluetooth PAN Profile" introduced="8.1" purpose="optional" class="plugin">
-        <unit bldFile="bluetoothcommsprofiles/btpan/group" mrp="bluetoothcommsprofiles/btpan/group/bluetooth_pan.mrp"/>
-      </component>
-    </collection>
-    <collection id="bthci" name="Host Controller Interface" level="server">
-      <component id="bthci2" name="Bluetooth HCI Framework 2" introduced="9.2" purpose="optional">
-        <unit bldFile="bthci/bthci2/group" mrp="bthci/bthci2/group/bluetooth_hci_v2_framework.mrp"/>
-      </component>
-      <component id="hciextensioninterface" name="Bluetooth HCI Extension Interface" introduced="6.1" purpose="optional">
-        <unit bldFile="bthci/hciextensioninterface" mrp="bthci/hciextensioninterface/bluetooth_hciproxy.mrp"/>
-      </component>
-      <component id="hci2implementations" name="Bluetooth HCI 2 Reference Implementations" introduced="9.2" purpose="optional" class="plugin">
-        <unit bldFile="bthci/hci2implementations/group" mrp="bthci/hci2implementations/group/bluetooth_hci_v2_implementations.mrp"/>
-      </component>
-    </collection>
-    <collection id="irda" name="IrDA" level="plugin">
-      <component id="irdastack" name="IrDA Stack" purpose="optional">
-        <unit bldFile="irda/irdastack/group" mrp="irda/irdastack/group/infra-red_irda.mrp"/>
-      </component>
-    </collection>
-    <collection id="bluetoothapitest" name="Bluetooth API Tests" level="app-if">
-      <component id="bluetoothsvs" name="Bluetooth Verification Suite" introduced="^3" purpose="development" filter="test">
-        <unit mrp="bluetoothapitest/bluetoothsvs/group/bluetoothsvs.mrp" bldFile="bluetoothapitest/bluetoothsvs/group"/>
-      </component>
-    </collection>
-    <collection id="atext" name="AT Extensions" level="server">
-      <component id="atext_build" name="AT Extension Build" introduced="^3" purpose="optional" filter="s60">
-        <unit bldFile="atext/group"/>
-      </component>
-    </collection>
-    <collection id="bt_info" name="Bluetooth Info" level="app-if">
-      <component id="bt_metadata" name="Bluetooth Metadata" class="config" introduced="^3" purpose="development" target="desktop">
-        <unit mrp="bt_info/bt_metadata/bt_metadata.mrp"/>
-      </component>
-    </collection>
-    <collection id="btsimulator" name="Bluetooth Simulator" level="internal-utils">
-      <component id="btaudioadaptation_stub" name="Bluetooth Audio Adaption Stub" introduced="^3" purpose="optional" filter="s60">
-        <unit bldFile="btsimulator/btaudioadaptation_stub/group"/>
-      </component>
-    </collection>
-  </package>
+  <collection id="bluetoothmgmt" name="Bluetooth Management" level="plugin">
+   <component id="btmgr" name="Bluetooth Manager" introduced="6.0" purpose="optional">
+    <unit bldFile="bluetoothmgmt/btmgr" mrp="bluetoothmgmt/btmgr/bluetooth_manager.mrp"/>
+   </component>
+   <component id="btconfig" name="Bluetooth Config" purpose="optional" class="config">
+    <unit bldFile="bluetoothmgmt/btconfig" mrp="bluetoothmgmt/btconfig/bluetooth_config.mrp"/>
+   </component>
+   <component id="btrom" name="Bluetooth ROM" introduced="9.1" purpose="optional">
+    <unit bldFile="bluetoothmgmt/btrom" mrp="bluetoothmgmt/btrom/bluetooth_rom.mrp"/>
+   </component>
+   <component id="bluetoothclientlib" name="Bluetooth Client Library" introduced="6.0" purpose="optional">
+    <unit bldFile="bluetoothmgmt/bluetoothclientlib" mrp="bluetoothmgmt/bluetoothclientlib/bluetooth_user.mrp"/>
+   </component>
+   <component id="btcommon" name="Bluetooth Build Utilities" purpose="optional" filter="test">
+    <unit mrp="bluetoothmgmt/btcommon/bluetooth_common.mrp" bldFile="bluetoothmgmt/btcommon"/>
+   </component>
+  </collection>
+  <collection id="bluetoothcommsprofiles" name="Bluetooth Comms Profiles" level="app-if">
+   <component id="btpan" name="Bluetooth PAN Profile" introduced="8.1" purpose="optional" class="plugin">
+    <unit bldFile="bluetoothcommsprofiles/btpan/group" mrp="bluetoothcommsprofiles/btpan/group/bluetooth_pan.mrp"/>
+   </component>
+  </collection>
+  <collection id="bthci" name="Host Controller Interface" level="server">
+   <component id="bthci2" name="Bluetooth HCI Framework 2" introduced="9.2" purpose="optional">
+    <unit bldFile="bthci/bthci2/group" mrp="bthci/bthci2/group/bluetooth_hci_v2_framework.mrp"/>
+   </component>
+   <component id="hciextensioninterface" name="Bluetooth HCI Extension Interface" introduced="6.1" purpose="optional">
+    <unit bldFile="bthci/hciextensioninterface" mrp="bthci/hciextensioninterface/bluetooth_hciproxy.mrp"/>
+   </component>
+   <component id="hci2implementations" name="Bluetooth HCI 2 Reference Implementations" introduced="9.2" purpose="optional" class="plugin">
+    <unit bldFile="bthci/hci2implementations/group" mrp="bthci/hci2implementations/group/bluetooth_hci_v2_implementations.mrp"/>
+   </component>
+  </collection>
+  <collection id="irda" name="IrDA" level="plugin">
+   <component id="irdastack" name="IrDA Stack" purpose="optional">
+    <unit bldFile="irda/irdastack/group" mrp="irda/irdastack/group/infra-red_irda.mrp"/>
+   </component>
+  </collection>
+  <collection id="bluetoothapitest" name="Bluetooth API Tests" level="app-if">
+   <component id="bluetoothsvs" name="Bluetooth Verification Suite" introduced="^3" purpose="development" filter="test">
+    <unit mrp="bluetoothapitest/bluetoothsvs/group/bluetoothsvs.mrp" bldFile="bluetoothapitest/bluetoothsvs/group"/>
+   </component>
+  </collection>
+  <collection id="atext" name="AT Extensions" level="server">
+   <!-- collection is really a component. Need to move down a directory -->
+   <component id="atext_build" name="AT Extension Build" introduced="^3" purpose="optional" filter="s60">
+    <unit bldFile="atext/group"/>
+   </component>
+  </collection>
+  <collection id="bt_info" name="Bluetooth Info" level="app-if">
+   <component id="bt_metadata" name="Bluetooth Metadata" class="config" introduced="^3" purpose="development" target="desktop">
+    <unit mrp="bt_info/bt_metadata/bt_metadata.mrp"/>
+   </component>
+  </collection>
+  <collection id="btsimulator" name="Bluetooth Simulator" level="internal-utils">
+   <component id="btaudioadaptation_stub" name="Bluetooth Audio Adaption Stub" purpose="optional" filter="oem_build">
+    <unit bldFile="btsimulator/btaudioadaptation_stub/group"/>
+   </component>
+  </collection>
+ </package>
 </SystemDefinition>