bluetooth/btstack/linkmgr/ACLSAP.cpp
branchRCL_3
changeset 8 2b6718f05bdb
parent 0 29b1cd4cb562
child 16 9f17f914e828
--- a/bluetooth/btstack/linkmgr/ACLSAP.cpp	Tue Feb 02 01:12:20 2010 +0200
+++ b/bluetooth/btstack/linkmgr/ACLSAP.cpp	Fri Feb 19 23:56:55 2010 +0200
@@ -60,6 +60,7 @@
 	iStates[EOpen]					=new (ELeave) TACLLinkStateOpen(*this);
 	iStates[EOpenParked]			=new (ELeave) TACLLinkStateOpenParked(*this);
 	iStates[EClosing]				=new (ELeave) TACLLinkStateClosing(*this);
+	iStates[EAcceptingClosing]		=new (ELeave) TACLLinkStateAcceptingClosing(*this);
 	}
 
 CACLLinkStateFactory::~CACLLinkStateFactory()
@@ -432,7 +433,7 @@
 	{
 	LOG_FUNC
 	// we're not wanted - close
-	ChangeState(aContext, CACLLinkStateFactory::EClosing);
+	ChangeState(aContext, CACLLinkStateFactory::EAcceptingClosing);
 	}
 
 //----------------------------------------------------------------------------------
@@ -497,7 +498,7 @@
 	{
 	LOG_FUNC
 	// just go
-	ChangeState(aContext, CACLLinkStateFactory::EClosing);
+	ChangeState(aContext, CACLLinkStateFactory::EAcceptingClosing);
 	}
 
 //----------------------------------------------------------------------------------
@@ -869,6 +870,38 @@
 
 //----------------------------------------------------------------------------------
 
+TACLLinkStateAcceptingClosing::TACLLinkStateAcceptingClosing(CACLLinkStateFactory& aFactory)
+: TACLLinkState(aFactory)
+	{
+	LOG_FUNC
+	STATENAME("AcceptingClosing");
+	}
+
+void TACLLinkStateAcceptingClosing::Shutdown(CACLLink& /*aContext*/, CServProviderBase::TCloseType /*aCloseType*/) const
+	{
+	LOG_FUNC
+	// we are!  just ignore and continue
+	}
+
+void TACLLinkStateAcceptingClosing::Deletion(CACLLink& aContext) const
+	{
+	LOG_FUNC
+	aContext.ListeningSAP()->RemoveChild(&aContext);
+	}
+
+void TACLLinkStateAcceptingClosing::Error(CACLLink& aContext, TInt /*aError*/) const
+	{
+	LOG_FUNC
+	// This method is reached by receiving a Disconnection Complete Event with Status field != EOk,
+	// in this case we don't want to error the socket - so instead it is just closed
+	aContext.ListeningSAP()->RemoveChild(&aContext);
+	ChangeState(aContext, CACLLinkStateFactory::EClosed);
+	aContext.Socket()->CanClose();
+	}
+
+
+//----------------------------------------------------------------------------------
+
 TACLLinkStateClosed::TACLLinkStateClosed(CACLLinkStateFactory& aFactory)
 : TACLLinkState(aFactory)
 	{