datacommsserver/esockserver/ssock/ss_sapshim.cpp
branchRCL_3
changeset 84 486e9e9c45a7
parent 73 5ebd530e523b
--- a/datacommsserver/esockserver/ssock/ss_sapshim.cpp	Wed Sep 15 13:33:11 2010 +0300
+++ b/datacommsserver/esockserver/ssock/ss_sapshim.cpp	Wed Oct 13 15:54:14 2010 +0300
@@ -104,7 +104,7 @@
 
 MLowerDataSender::TSendResult CTransportFlowShim::Send(RMBufChain& /*aData*/)
     {
-    __ASSERT_DEBUG(IsHostResolver(), User::Panic(KSpecAssert_ESockSSocksspshm, 3));
+    __ASSERT_DEBUG(iHostResolverNotify, User::Panic(KSpecAssert_ESockSSocksspshm, 3));
 
     TBuf8<sizeof(TConnectionInfo)> buf;
     if (Control(KSOLProvider, static_cast<TUint>(KSoConnectionInfo), buf) == KErrNone)
@@ -270,7 +270,9 @@
 
 void CTransportFlowShim::HostResolverSpecificUnbind()
 	{
+	// Can't have both HR & SAP
 	__ASSERT_DEBUG(!iProvider, User::Panic(KSpecAssert_ESockSSocksspshm, 9));
+
 	if(iSubConnectionProvider.IsOpen())
 		{
 		iSessionControlNotify = NULL;
@@ -287,6 +289,7 @@
 		DeleteThisFlow();
 		}
 	}
+
 void CTransportFlowShim::Unbind()
     {
 	LOG( ESockLog::Printf(_L8("CTransportFlowShim %08x:\tUnbind()"), this) );
@@ -298,32 +301,29 @@
 		return;
 		}
 
-	// Legacy support for host resolvers
-	if(IsHostResolver())
+	// Legacy support for host resolvers involves a separate north bound MUpperControl interface
+	if(iHostResolverNotify)
 		{
 		HostResolverSpecificUnbind();
-
-			}
-		else
-			{
-
-	if (iProvider)
+		}
+	else
 		{
-		iProvider->SetNotify(NULL);
-
-		if (!Detaching())
+		if (iProvider)
 			{
-			delete iProvider;
-			iProvider = NULL;
+			iProvider->SetNotify(NULL);
+
+			if (!Detaching())
+				{
+				delete iProvider;
+				iProvider = NULL;
+				}
 			}
-		}
 
 #ifdef SYMBIAN_NETWORKING_UPS
-	// Hook for derived classes to do cleanup before unbind occurs
-	PreUnbind();
+		// Hook for derived classes to do cleanup before unbind occurs
+		PreUnbind();
 #endif
-
-	CNetworkFlow::Unbind();
+		CNetworkFlow::Unbind();
 		}
     }
 
@@ -1336,7 +1336,7 @@
 		LOG( ESockLog::Printf(_L("CTransportFlowShim %08x:\tSubConnectionError() - calling Error() function"), this) );
     	Error(errorMsg.iValue, anOperationMask);
 	    }
-	else if (IsHostResolver())
+	else if (iHostResolverNotify)
 	    {
 		LOG( ESockLog::Printf(_L("CTransportFlowShim %08x:\tSubConnectionError() - passing to host resolver's Error() function"), this) );
 	    iHostResolverNotify->Error(errorMsg.iValue);
@@ -1374,7 +1374,7 @@
 		
 		__ASSERT_DEBUG(iSubConnectionProvider.IsOpen(), User::Panic(KSpecAssert_ESockSSocksspshm, 48));	// legacy flows have no control side; should never get here
 		}
-	else if (IsHostResolver())
+	else if (iHostResolverNotify)
 	    {//workaroud to indicate to CHostResolver we've got connection info
 	    if (!aBindTo.iNodeId.Ptr())
 	        {
@@ -1433,7 +1433,7 @@
 
         // A held-over implicit resolution request will now work (if it ever will).
 		// Explicit host resolver requests have already been re-issued in BindToL().
-        if (IsHostResolver() && (iFlowParams.iFlowRequestType != TFlowParams::EExplicitConnection))
+        if (iHostResolverNotify && (iFlowParams.iFlowRequestType != TFlowParams::EExplicitConnection))
 	        {
     	    iHostResolverNotify->StartSending();
 	        }
@@ -1461,16 +1461,13 @@
 	// 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.
 
-	TInt err = (aMessage.iValue == KErrForceDisconnected) ? KErrDisconnected : aMessage.iValue;
-	if (IsBoundToSession() && (aMessage.iValue == KErrForceDisconnected || !UseBearerErrors()))
+	if (IsBoundToSession() && aMessage.iValue == KErrForceDisconnected)
 		{
-		Error(err, EErrorAllOperations);
+		Error(KErrDisconnected, EErrorAllOperations);
 		}
-	else if (IsHostResolver())
+	else if (IsBoundToSession() && !UseBearerErrors())
 	    {
-        __ASSERT_DEBUG(err != KErrNone, User::Panic(KSpecAssert_ESockSSocksspshm, 67));
-        LOG( ESockLog::Printf(_L("CTransportFlowShim %08x:\tStopFlow() - passing to host resolver's Error() function"), this) );
-        iHostResolverNotify->Error(err);
+    	Error(aMessage.iValue, EErrorAllOperations);
 	    }
 
 	if (iLowerFlow)