datacommsserver/esockserver/ssock/ss_sapshim.cpp
branchRCL_3
changeset 27 5ebd530e523b
parent 26 b564fb5fd78b
equal deleted inserted replaced
26:b564fb5fd78b 27:5ebd530e523b
   102     	}
   102     	}
   103     }
   103     }
   104 
   104 
   105 MLowerDataSender::TSendResult CTransportFlowShim::Send(RMBufChain& /*aData*/)
   105 MLowerDataSender::TSendResult CTransportFlowShim::Send(RMBufChain& /*aData*/)
   106     {
   106     {
   107     __ASSERT_DEBUG(iHostResolverNotify, User::Panic(KSpecAssert_ESockSSocksspshm, 3));
   107     __ASSERT_DEBUG(IsHostResolver(), User::Panic(KSpecAssert_ESockSSocksspshm, 3));
   108 
   108 
   109     TBuf8<sizeof(TConnectionInfo)> buf;
   109     TBuf8<sizeof(TConnectionInfo)> buf;
   110     if (Control(KSOLProvider, static_cast<TUint>(KSoConnectionInfo), buf) == KErrNone)
   110     if (Control(KSOLProvider, static_cast<TUint>(KSoConnectionInfo), buf) == KErrNone)
   111         {
   111         {
   112         iHostResolverNotify->StartSending();
   112         iHostResolverNotify->StartSending();
   268 	return this;
   268 	return this;
   269     }
   269     }
   270 
   270 
   271 void CTransportFlowShim::HostResolverSpecificUnbind()
   271 void CTransportFlowShim::HostResolverSpecificUnbind()
   272 	{
   272 	{
   273 	// Can't have both HR & SAP
       
   274 	__ASSERT_DEBUG(!iProvider, User::Panic(KSpecAssert_ESockSSocksspshm, 9));
   273 	__ASSERT_DEBUG(!iProvider, User::Panic(KSpecAssert_ESockSSocksspshm, 9));
   275 
       
   276 	if(iSubConnectionProvider.IsOpen())
   274 	if(iSubConnectionProvider.IsOpen())
   277 		{
   275 		{
   278 		iSessionControlNotify = NULL;
   276 		iSessionControlNotify = NULL;
   279 		iSessionDataNotify = NULL;
   277 		iSessionDataNotify = NULL;
   280 		iHostResolverNotify = NULL;
   278 		iHostResolverNotify = NULL;
   287 	else
   285 	else
   288 		{
   286 		{
   289 		DeleteThisFlow();
   287 		DeleteThisFlow();
   290 		}
   288 		}
   291 	}
   289 	}
   292 
       
   293 void CTransportFlowShim::Unbind()
   290 void CTransportFlowShim::Unbind()
   294     {
   291     {
   295 	LOG( ESockLog::Printf(_L8("CTransportFlowShim %08x:\tUnbind()"), this) );
   292 	LOG( ESockLog::Printf(_L8("CTransportFlowShim %08x:\tUnbind()"), this) );
   296 
   293 
   297 	// Infant mortality case in which binding never completed,
   294 	// Infant mortality case in which binding never completed,
   299 		{
   296 		{
   300 		delete this;
   297 		delete this;
   301 		return;
   298 		return;
   302 		}
   299 		}
   303 
   300 
   304 	// Legacy support for host resolvers involves a separate north bound MUpperControl interface
   301 	// Legacy support for host resolvers
   305 	if(iHostResolverNotify)
   302 	if(IsHostResolver())
   306 		{
   303 		{
   307 		HostResolverSpecificUnbind();
   304 		HostResolverSpecificUnbind();
   308 		}
   305 
   309 	else
       
   310 		{
       
   311 		if (iProvider)
       
   312 			{
       
   313 			iProvider->SetNotify(NULL);
       
   314 
       
   315 			if (!Detaching())
       
   316 				{
       
   317 				delete iProvider;
       
   318 				iProvider = NULL;
       
   319 				}
       
   320 			}
   306 			}
       
   307 		else
       
   308 			{
       
   309 
       
   310 	if (iProvider)
       
   311 		{
       
   312 		iProvider->SetNotify(NULL);
       
   313 
       
   314 		if (!Detaching())
       
   315 			{
       
   316 			delete iProvider;
       
   317 			iProvider = NULL;
       
   318 			}
       
   319 		}
   321 
   320 
   322 #ifdef SYMBIAN_NETWORKING_UPS
   321 #ifdef SYMBIAN_NETWORKING_UPS
   323 		// Hook for derived classes to do cleanup before unbind occurs
   322 	// Hook for derived classes to do cleanup before unbind occurs
   324 		PreUnbind();
   323 	PreUnbind();
   325 #endif
   324 #endif
   326 		CNetworkFlow::Unbind();
   325 
       
   326 	CNetworkFlow::Unbind();
   327 		}
   327 		}
   328     }
   328     }
   329 
   329 
   330 ESock::CSubConnectionFlowBase& CTransportFlowShim::CloneFlowL()
   330 ESock::CSubConnectionFlowBase& CTransportFlowShim::CloneFlowL()
   331     {
   331     {
  1334 	if (IsBoundToSession())
  1334 	if (IsBoundToSession())
  1335 	    {
  1335 	    {
  1336 		LOG( ESockLog::Printf(_L("CTransportFlowShim %08x:\tSubConnectionError() - calling Error() function"), this) );
  1336 		LOG( ESockLog::Printf(_L("CTransportFlowShim %08x:\tSubConnectionError() - calling Error() function"), this) );
  1337     	Error(errorMsg.iValue, anOperationMask);
  1337     	Error(errorMsg.iValue, anOperationMask);
  1338 	    }
  1338 	    }
  1339 	else if (iHostResolverNotify)
  1339 	else if (IsHostResolver())
  1340 	    {
  1340 	    {
  1341 		LOG( ESockLog::Printf(_L("CTransportFlowShim %08x:\tSubConnectionError() - passing to host resolver's Error() function"), this) );
  1341 		LOG( ESockLog::Printf(_L("CTransportFlowShim %08x:\tSubConnectionError() - passing to host resolver's Error() function"), this) );
  1342 	    iHostResolverNotify->Error(errorMsg.iValue);
  1342 	    iHostResolverNotify->Error(errorMsg.iValue);
  1343 	    }
  1343 	    }
  1344 	}
  1344 	}
  1372 		RemName(iRemoteAddress);
  1372 		RemName(iRemoteAddress);
  1373 		SetRemoteAddressSet();
  1373 		SetRemoteAddressSet();
  1374 		
  1374 		
  1375 		__ASSERT_DEBUG(iSubConnectionProvider.IsOpen(), User::Panic(KSpecAssert_ESockSSocksspshm, 48));	// legacy flows have no control side; should never get here
  1375 		__ASSERT_DEBUG(iSubConnectionProvider.IsOpen(), User::Panic(KSpecAssert_ESockSSocksspshm, 48));	// legacy flows have no control side; should never get here
  1376 		}
  1376 		}
  1377 	else if (iHostResolverNotify)
  1377 	else if (IsHostResolver())
  1378 	    {//workaroud to indicate to CHostResolver we've got connection info
  1378 	    {//workaroud to indicate to CHostResolver we've got connection info
  1379 	    if (!aBindTo.iNodeId.Ptr())
  1379 	    if (!aBindTo.iNodeId.Ptr())
  1380 	        {
  1380 	        {
  1381             iHostResolverNotify->Error(KErrDisconnected);
  1381             iHostResolverNotify->Error(KErrDisconnected);
  1382 	        }
  1382 	        }
  1431 		SetStarted();
  1431 		SetStarted();
  1432 		ClearStopped();
  1432 		ClearStopped();
  1433 
  1433 
  1434         // A held-over implicit resolution request will now work (if it ever will).
  1434         // A held-over implicit resolution request will now work (if it ever will).
  1435 		// Explicit host resolver requests have already been re-issued in BindToL().
  1435 		// Explicit host resolver requests have already been re-issued in BindToL().
  1436         if (iHostResolverNotify && (iFlowParams.iFlowRequestType != TFlowParams::EExplicitConnection))
  1436         if (IsHostResolver() && (iFlowParams.iFlowRequestType != TFlowParams::EExplicitConnection))
  1437 	        {
  1437 	        {
  1438     	    iHostResolverNotify->StartSending();
  1438     	    iHostResolverNotify->StartSending();
  1439 	        }
  1439 	        }
  1440 
  1440 
  1441 		return;
  1441 		return;
  1459 	// has attached a flow to a route (and hence an interface) which, in turn, only occurs once the
  1459 	// has attached a flow to a route (and hence an interface) which, in turn, only occurs once the
  1460 	// interface is up and data has been sent over the socket.  Note that opening an RSocket on an
  1460 	// interface is up and data has been sent over the socket.  Note that opening an RSocket on an
  1461 	// RConnection but not transferring any data will not cause the TCP/IP stack to attach the flow
  1461 	// RConnection but not transferring any data will not cause the TCP/IP stack to attach the flow
  1462 	// to the route and hence not call Error() if the interface comes down.
  1462 	// to the route and hence not call Error() if the interface comes down.
  1463 
  1463 
  1464 	if (IsBoundToSession() && aMessage.iValue == KErrForceDisconnected)
  1464 	TInt err = (aMessage.iValue == KErrForceDisconnected) ? KErrDisconnected : aMessage.iValue;
  1465 		{
  1465 	if (IsBoundToSession() && (aMessage.iValue == KErrForceDisconnected || !UseBearerErrors()))
  1466 		Error(KErrDisconnected, EErrorAllOperations);
  1466 		{
  1467 		}
  1467 		Error(err, EErrorAllOperations);
  1468 	else if (IsBoundToSession() && !UseBearerErrors())
  1468 		}
       
  1469 	else if (IsHostResolver())
  1469 	    {
  1470 	    {
  1470     	Error(aMessage.iValue, EErrorAllOperations);
  1471         __ASSERT_DEBUG(err != KErrNone, User::Panic(KSpecAssert_ESockSSocksspshm, 67));
       
  1472         LOG( ESockLog::Printf(_L("CTransportFlowShim %08x:\tStopFlow() - passing to host resolver's Error() function"), this) );
       
  1473         iHostResolverNotify->Error(err);
  1471 	    }
  1474 	    }
  1472 
  1475 
  1473 	if (iLowerFlow)
  1476 	if (iLowerFlow)
  1474 		{
  1477 		{
  1475 		iLowerFlow->Unbind(NULL,NULL);
  1478 		iLowerFlow->Unbind(NULL,NULL);