datacommsserver/esockserver/ssock/ss_sapshim.cpp
branchRCL_3
changeset 9 77effd21b2c9
parent 2 dee179edb159
child 14 8b5d60ce1e94
--- a/datacommsserver/esockserver/ssock/ss_sapshim.cpp	Tue Feb 02 00:53:00 2010 +0200
+++ b/datacommsserver/esockserver/ssock/ss_sapshim.cpp	Sat Feb 20 00:01:55 2010 +0200
@@ -92,8 +92,9 @@
     {
     (void)aControl;
     __ASSERT_DEBUG(aControl == iHostResolverNotify, User::Panic(KSpecAssert_ESockSSocksspshm, 1));
-    __ASSERT_DEBUG(iDCIdle <= EClientsPresent, User::Panic(KSpecAssert_ESockSSocksspshm, 2));
-    iDCIdle = EIdle;
+    __ASSERT_DEBUG(!(Idle() || IdleSent()), User::Panic(KSpecAssert_ESockSSocksspshm, 2));
+    SetIdle();
+	
     iHostResolverNotify = NULL;
     if(iSubConnectionProvider.IsOpen())	// legacy flows have no control side
     	{
@@ -163,7 +164,7 @@
 		iListenerControlNotify->DisconnectFromListener(*this);
 		}
 
-	if(!iDetaching)
+	if(!Detaching())
 		{
 		delete iProvider;
 		iProvider = NULL;
@@ -283,14 +284,14 @@
 		{
 		__ASSERT_DEBUG(!iProvider, User::Panic(KSpecAssert_ESockSSocksspshm, 9));	// can't have both HR & SAP
 
-		LOG( ESockLog::Printf(_L8("CTransportFlowShim %08x:\tUnbind(): iBearerExpected %d"), this, iBearerExpected) );
-		if (!iBearerExpected)
+		LOG( ESockLog::Printf(_L8("CTransportFlowShim %08x:\tUnbind(): iBearerExpected %d"), this, BearerExpected()) );
+		if (!BearerExpected())
 			{
 			delete this;
 			}
 		else
 			{
-			iDeleteUponBearerReception = ETrue;
+			SetDeleteUponBearerReception();
 			iHostResolverNotify = NULL;
 			}
 		return;
@@ -300,7 +301,7 @@
 		{
 		iProvider->SetNotify(NULL);
 
-		if (!iDetaching)
+		if (!Detaching())
 			{
 			delete iProvider;
 			iProvider = NULL;
@@ -412,7 +413,7 @@
 */
 	{
 	TInt ret = EFalse;
-	if(!iIsStopped)
+	if(!Stopped())
 		{ // Prevent sending NoBearer if DataClientStop was received
 		if (LockToConnectionInfo() != KErrNone)
 		    {
@@ -420,7 +421,8 @@
 			PostNoBearer();
 			ret = ETrue;
 		    }
-		iUseBearerErrors = EFalse;
+		ClearUseBearerErrors();
+
 		ClearDataClientRoutedGuard();
 		}
 	return ret;
@@ -632,7 +634,7 @@
 	__ASSERT_DEBUG(iProvider, User::Panic(KSpecAssert_ESockSSocksspshm, 24));
 	if (aOption == MSessionControl::EImmediate)
 		{
-		iShuttingDown = ETrue;
+		SetShuttingDown();
 		}
 
 	// It is possible for the provider to be null if an error occurs immediatly
@@ -880,7 +882,8 @@
 
 	if(iSessionControlNotify)
 		{
-		iDetaching = aDelete == MSocketNotify::EDetach;
+		aDelete == MSocketNotify::EDetach ? SetDetaching() : ClearDetaching();
+		
 		iSessionControlNotify->CanClose(MSessionControlNotify::TDelete(aDelete));
         if(aDelete==MSocketNotify::EDetach)
             {
@@ -903,7 +906,7 @@
 
 	if(iSessionControlNotify)
 		{
-        iDetaching = aDelete == MSocketNotify::EDetach;
+		aDelete == MSocketNotify::EDetach ? SetDetaching() : ClearDetaching();
 		iSessionControlNotify->CanClose(aDisconnectData, MSessionControlNotify::TDelete(aDelete));
 		if(aDelete==MSocketNotify::EDetach)
 			{
@@ -945,7 +948,7 @@
 
 		// No control above us - likely cause is that we're the result of a passive open that
 		// hasn't yet been accepted.
-		iDetaching = MSocketNotify::EDetach;
+		SetDetaching();
 		Unbind();
 		}
 	}
@@ -964,7 +967,7 @@
 
 		// No control above us - likely cause is that we're the result of a passive open that
 		// hasn't yet been accepted.
-		iDetaching = MSocketNotify::EDetach;
+		SetDetaching();
 		Unbind();
 		}
 	}
@@ -983,7 +986,7 @@
 
 		// No control above us - likely cause is that we're the result of a passive open that
 		// hasn't yet been accepted.
-		iDetaching = MSocketNotify::EDetach;
+		SetDetaching();
 		Unbind();
 		}
 	}
@@ -1027,11 +1030,11 @@
 		return;
 		}
 
-	iUseBearerErrors = ETrue;
+	SetUseBearerErrors();
 	LocalName(iLocalAddress);
-	iLocalAddressSet = ETrue;
+	SetLocalAddressSet();
 	RemName(iRemoteAddress);
-	iRemoteAddressSet = ETrue;
+	SetRemoteAddressSet();
 	__ASSERT_DEBUG(iSubConnectionProvider.IsOpen(), User::Panic(KSpecAssert_ESockSSocksspshm, 41));	// legacy flows have no control side; should never get here
 
 	PostDataClientRouted();
@@ -1170,7 +1173,7 @@
 					{
 					CompleteStart(err);
 					}
-               iBearerExpected = ETrue;
+				SetBearerExpected();
 				}
 			else
 		    	{
@@ -1249,7 +1252,7 @@
 			{
 			CompleteStart(KErrNone);
 			}
-		LOG( ESockLog::Printf(_L8("CTransportFlowShim %08x:\tReceivedL(): TBearer: iDeleteUponBearerReception %d"), this, iDeleteUponBearerReception) );
+		LOG( ESockLog::Printf(_L8("CTransportFlowShim %08x:\tReceivedL(): TBearer: iDeleteUponBearerReception %d"), this, DeleteUponBearerReception()));
 
 		ClearNoBearerGuard();
 		ProcessDCIdleState();
@@ -1266,8 +1269,9 @@
 
 void CTransportFlowShim::NoBearerCompletion()
 	{
-	iBearerExpected = EFalse;
-	if (iDeleteUponBearerReception)
+	ClearBearerExpected();
+
+	if (DeleteUponBearerReception())
 		{
 		delete this;
 		}
@@ -1283,8 +1287,8 @@
 	if (aError==KErrNone)
 		{
 		iStartRequest.ReplyTo(Id(), TCFDataClient::TStarted().CRef());
-		iIsStarted = ETrue;
-		iIsStopped = EFalse;
+		SetStarted();
+		ClearStopped();
 		}
 	else
 		{
@@ -1333,7 +1337,7 @@
 	NM_LOG((KESockServerTag, _L8("CTransportFlowShim %08x:\tSynchronous call: From=%08x To=%08x Func=BindToL"),
 			this, static_cast<Messages::ANode*>(this), &aBindTo.iNodeId.Node()) )
 
-	if (iShuttingDown)
+	if (ShuttingDown())
 		{
 		User::Leave(KErrCancel);
 		return;
@@ -1344,9 +1348,10 @@
 		{
 		LockToConnectionInfo();
 		LocalName(iLocalAddress);
-		iLocalAddressSet = ETrue;
+		SetLocalAddressSet();
 		RemName(iRemoteAddress);
-		iRemoteAddressSet = ETrue;
+		SetRemoteAddressSet();
+		
 		__ASSERT_DEBUG(iSubConnectionProvider.IsOpen(), User::Panic(KSpecAssert_ESockSSocksspshm, 48));	// legacy flows have no control side; should never get here
 		}
 	else if (iHostResolverNotify)
@@ -1382,13 +1387,13 @@
 
 void CTransportFlowShim::StartFlowL(const TRuntimeCtxId& aSender)
 	{
-	__ASSERT_DEBUG(!iIsStarted, User::Panic(KSpecAssert_ESockSSocksspshm, 49));
+	__ASSERT_DEBUG(!Started(), User::Panic(KSpecAssert_ESockSSocksspshm, 49));
 	__ASSERT_DEBUG(iSubConnectionProvider.IsOpen(), User::Panic(KSpecAssert_ESockSSocksspshm, 50));	// legacy flows have no control side; should never get here
 
 	//We will wait for it and complete the start after we have received it
 	User::LeaveIfError(iStartRequest.Open(iSubConnectionProvider, aSender));
 
-	if (iDCIdle != EClientsPresent)
+	if (Idle())
 		{
 		iStartRequest.ReplyTo(Id(), TEBase::TError(TCFDataClient::TStart::Id(), KErrNotReady).CRef());
 		iStartRequest.Close();
@@ -1399,8 +1404,8 @@
 		{
 		iStartRequest.ReplyTo(Id(), TCFDataClient::TStarted().CRef());
 		iStartRequest.Close();
-		iIsStarted = ETrue;
-		iIsStopped = EFalse;
+		SetStarted();
+		ClearStopped();
 		return;
 		}
 
@@ -1411,7 +1416,6 @@
 
 void CTransportFlowShim::StopFlow(TCFDataClient::TStop& aMessage)
 	{
-	__ASSERT_DEBUG(iIsStarted, User::Panic(KSpecAssert_ESockSSocksspshm, 51)); //Must be started now
 	__ASSERT_DEBUG(iSubConnectionProvider.IsOpen(), User::Panic(KSpecAssert_ESockSSocksspshm, 52));	// legacy flows have no control side; should never get here
 
 	// We need to error the socket if the lower protocol stack is not going to do this.  Once a
@@ -1425,7 +1429,11 @@
 	// RConnection but not transferring any data will not cause the TCP/IP stack to attach the flow
 	// to the route and hence not call Error() if the interface comes down.
 
-	if (IsBoundToSession() && !iUseBearerErrors)
+	if (IsBoundToSession() && aMessage.iValue == KErrForceDisconnected)
+		{
+		Error(KErrDisconnected, EErrorAllOperations);
+		}
+	else if (IsBoundToSession() && !UseBearerErrors())
 	    {
     	Error(aMessage.iValue, EErrorAllOperations);
 	    }
@@ -1438,14 +1446,14 @@
 	iLowerControl = NULL;
 
 	iSubConnectionProvider.PostMessage(Id(), TCFDataClient::TStopped(aMessage.iValue).CRef());
-	iIsStarted = EFalse;
-	iIsStopped = ETrue;
+	ClearStarted();
+	SetStopped();
 	}
 
 void CTransportFlowShim::InitDestroy()
 	{
-    __ASSERT_DEBUG(iDCIdle <= EClientsPresent, User::Panic(KSpecAssert_ESockSSocksspshm, 53));
-    iDCIdle = EIdle;
+	__ASSERT_DEBUG(!(Idle() || IdleSent()), User::Panic(KSpecAssert_ESockSSocksspshm, 53));
+    SetIdle();
 
     if(iSubConnectionProvider.IsOpen())	// legacy flows have no control side
     	{
@@ -1473,8 +1481,8 @@
 
 void CTransportFlowShim::PostDataClientRouted()
 	{
- 	if (iLocalAddressSet && iRemoteAddressSet
-	&& iRemoteAddress.Family() != KAFUnspec && !iDataClientRoutedGuard)
+	if (LocalAddressSet() && RemoteAddressSet()
+		&& iRemoteAddress.Family() != KAFUnspec && !DataClientRoutedGuard())
 		{
 		iSubConnectionProvider.PostMessage(
 			Id(),
@@ -1486,16 +1494,10 @@
 					iIfInfo.iIAPId)
 				).CRef()
 			);
-		iDataClientRoutedGuard = ETrue;
+		SetDataClientRoutedGuard();
 		}
 	}
 
-void CTransportFlowShim::ClearDataClientRoutedGuard()
-	{
-	iDataClientRoutedGuard = EFalse;
-	}
-
-
 /*
 Store the provision information passed from the Control side.
 @param TProvisionConfig Message recd.
@@ -1770,7 +1772,7 @@
 			}
 		}
 
-	if(!IsStopped())
+	if(!Stopped())
 		{ // Prevent sending NoBearer if DataClientStop was received
 		ParseNoBearerParams(aConnectionParams);
 		if (iIsScoped)
@@ -1807,7 +1809,7 @@
 				}
 	        PostNoBearer();
 		    }
-		ClearUseBearerErrors();
+
 		ClearDataClientRoutedGuard();
 		}
 	else
@@ -1887,7 +1889,7 @@
 	{
 	SetPolicyCheckRequestPending(EFalse);
 
-	if (iDCIdle == EIdle)
+	if (Idle() && !IdleSent())
 		{
 		ProcessDCIdleState();
 		}