datacommsserver/esockserver/ssock/ss_connstates.cpp
branchRCL_3
changeset 67 00c6709d25aa
parent 66 cbb19216b74d
child 69 9d7ce34704c8
equal deleted inserted replaced
66:cbb19216b74d 67:00c6709d25aa
    54 
    54 
    55 #ifdef SYMBIAN_NETWORKING_UPS
    55 #ifdef SYMBIAN_NETWORKING_UPS
    56 #include <comms-infras/ss_upsaccesspointconfigext.h>
    56 #include <comms-infras/ss_upsaccesspointconfigext.h>
    57 #include <comms-infras/upsmessages.h>
    57 #include <comms-infras/upsmessages.h>
    58 #endif
    58 #endif
    59 
    59 #include <comms-infras/ss_roles.h>
    60 #ifdef _DEBUG
    60 #ifdef _DEBUG
    61 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module
    61 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module
    62 // (if it could happen through user error then you should give it an explicit, documented, category + code)
    62 // (if it could happen through user error then you should give it an explicit, documented, category + code)
    63 _LIT(KSpecAssert_ESockSSockscnsts, "ESockSSockscnsts");
    63 _LIT(KSpecAssert_ESockSSockscnsts, "ESockSSockscnsts");
    64 #endif
    64 #endif
   248 void ConnStates::TSendFinishedSelectionStateChange::DoL()
   248 void ConnStates::TSendFinishedSelectionStateChange::DoL()
   249 	{
   249 	{
   250 	//Send the relevant progress (don't use ReceivedL or you will warp), also use Null Activity id.
   250 	//Send the relevant progress (don't use ReceivedL or you will warp), also use Null Activity id.
   251 	RNodeInterface::OpenPostMessageClose(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.NodeId(),
   251 	RNodeInterface::OpenPostMessageClose(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.NodeId(),
   252 		TCFMessage::TStateChange(TStateChange(KFinishedSelection,KErrNone)).CRef());
   252 		TCFMessage::TStateChange(TStateChange(KFinishedSelection,KErrNone)).CRef());
   253 	}
       
   254 
       
   255 DEFINE_SMELEMENT(ConnStates::TJoinReceivedCpr, NetStateMachine::MStateTransition, ConnStates::TContext)
       
   256 void ConnStates::TJoinReceivedCpr::DoL()
       
   257 	{
       
   258 	__ASSERT_DEBUG(iContext.iNodeActivity, ConnPanic(KPanicNoActivity));
       
   259 	__ASSERT_DEBUG(iContext.Node().ServiceProvider()==NULL, ConnPanic(KPanicExpectedNoServiceProvider));
       
   260 
       
   261 	TCFDataClient::TBindTo& bt = message_cast<TCFDataClient::TBindTo>(iContext.iMessage);
       
   262     RNodeInterface* newSP = iContext.Node().AddClientL(bt.iNodeId, TClientType(TCFClientType::EServProvider, TCFClientType::EActive));
       
   263     __ASSERT_DEBUG(iContext.Node().ServiceProvider()==newSP, ConnPanic(KPanicNoServiceProvider)); //[RZ] revise this, possibly overdefensive
       
   264 
       
   265     //If this is attach, we need to see if we are a monitor or not
       
   266     TClientType clientType(TCFClientType::ECtrl);
       
   267 
       
   268     TUint selPrefs = static_cast<ConnActivities::CStartAttachActivity&>(*iContext.iNodeActivity).SelectionPrefs().Flags();
       
   269     if (selPrefs & TSelectionPrefs::EMonitor)
       
   270     	{
       
   271 		clientType.SetFlags(TCFClientType::EMonitor);
       
   272     	iContext.Node().iIsMonitor = ETrue;
       
   273     	}
       
   274 
       
   275 	// If it is an attach set the flag cause it is used by NetUPS to check if a JoinRequest comes from an RConnection::Attach
       
   276 	if (selPrefs & TSelectionPrefs::EAttach)
       
   277     	{
       
   278 		clientType.SetFlags(TCFClientType::EAttach);
       
   279     	}
       
   280     iContext.iNodeActivity->PostRequestTo(*newSP,
       
   281     	TCFServiceProvider::TJoinRequest(iContext.NodeId(), clientType).CRef());
       
   282 	}
   253 	}
   283 
   254 
   284 DEFINE_SMELEMENT(ConnStates::TJoinReceivedSCpr, NetStateMachine::MStateTransition, ConnStates::TContext)
   255 DEFINE_SMELEMENT(ConnStates::TJoinReceivedSCpr, NetStateMachine::MStateTransition, ConnStates::TContext)
   285 void ConnStates::TJoinReceivedSCpr::DoL()
   256 void ConnStates::TJoinReceivedSCpr::DoL()
   286 	{
   257 	{
  1301 	RNodeInterface* aux = iNode.GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EAux));
  1272 	RNodeInterface* aux = iNode.GetFirstClient<TDefaultClientMatchPolicy>(TClientType(TCFClientType::EAux));
  1302 	if (aux)
  1273 	if (aux)
  1303 		{
  1274 		{
  1304 		iNode.RemoveClient(aux->RecipientId());
  1275 		iNode.RemoveClient(aux->RecipientId());
  1305 		}
  1276 		}
       
  1277 
       
  1278     if (iRegisteredForInterfaceStateChanges)
       
  1279         {
       
  1280         CCommsFactoryBase* ipProtoCprFactory = IpProtoCprFactory();
       
  1281         if (ipProtoCprFactory)
       
  1282             {
       
  1283             Factories::IFactoryNotify itf(this, GetVTable());
       
  1284             ipProtoCprFactory->DeRegisterNotifier(itf);
       
  1285             }
       
  1286         }
       
  1287 
  1306 	delete iAllInterfaceNotificationWorker; //delete this node (why via iAllInterfaceNotificationWorker??)
  1288 	delete iAllInterfaceNotificationWorker; //delete this node (why via iAllInterfaceNotificationWorker??)
  1307 	}
  1289 	}
       
  1290 
       
  1291 /**
       
  1292 Called by the IpProtoCpr factory to propagate an interface state change from IpProtoCpr to registered
       
  1293 observers (suc as ourself).  If the interface is restarting, then we need to insert an EInterfaceDown,
       
  1294 EInterfaceUp "toggle" sequence into the AllInterfaceNotification queue.  This is because, ordinarily,
       
  1295 EInterfaceUp and EInterfaceDown are generated when the IpProtoCpr itself is created and destroyed,
       
  1296 but not if it is restarted before being destroyed. 
       
  1297 */
       
  1298 void CAllInterfaceNotificationActivity::InterfaceStateChangeNotification(const TDesC8& aInfo)
       
  1299     {
       
  1300     if (aInfo.Length() == sizeof(TInterfaceNotification))
       
  1301         {
       
  1302         const TInterfaceNotification* const info = reinterpret_cast<const TInterfaceNotification*>(aInfo.Ptr());
       
  1303         if (info && info->iState == EInterfaceRestarting)
       
  1304             {
       
  1305             LOG( ESockLog::Printf(KESockConnectionTag, _L("CAllInterfaceNotificationActivity %08x:\tInterfaceStateChangeNotification(): CConnection %08x, IapId %d, NetId %d"),
       
  1306                 this, &iAllInterfaceNotificationWorker->iConnection, info->iConnectionInfo.iIapId, info->iConnectionInfo.iNetId  ));
       
  1307 
       
  1308             AConnectionLegacy& legacy = iAllInterfaceNotificationWorker->iConnection.iLegacyConnection;
       
  1309             TInterfaceNotification notification(*info);
       
  1310             notification.iState = EInterfaceDown;
       
  1311             legacy.iNotificationQueue.Enque(notification);
       
  1312             notification.iState = EInterfaceUp;
       
  1313             legacy.iNotificationQueue.Enque(notification);
       
  1314             legacy.CompleteAllInterfaceNotificationL(KErrNone);
       
  1315             }
       
  1316         }
       
  1317     }
       
  1318 
       
  1319 CCommsFactoryBase* CAllInterfaceNotificationActivity::IpProtoCprFactory() const
       
  1320     {
       
  1321     CConnectionFactoryContainer& container = *static_cast<CPlayer&>(iAllInterfaceNotificationWorker->iConnection.Player()).SockManGlobals()->iConnectionFactories;
       
  1322     return static_cast<CCommsFactoryBase*>(container.FindFactory(TUid::Uid(AConnectionLegacy::KIPProtoConnectionProviderFactoryUid)));
       
  1323     }
       
  1324 
       
  1325 // Registration table for receiving InterfaceStateChangeNotification() events.
       
  1326 const Factories::TAnyFn CAllInterfaceNotificationActivity::iInterfaceVTableF[] =
       
  1327     {
       
  1328     (Factories::TAnyFn)1, // number of methods. the following entries must be in this order!
       
  1329     (Factories::TAnyFn)(Factories::TFactoryNotify<CAllInterfaceNotificationActivity>::Notification)
       
  1330     };
  1308 
  1331 
  1309 // States
  1332 // States
  1310 
  1333 
  1311 DEFINE_SMELEMENT(AllInterfaceNotificationActivity::TAwaitingStart, NetStateMachine::MState, TContext)
  1334 DEFINE_SMELEMENT(AllInterfaceNotificationActivity::TAwaitingStart, NetStateMachine::MState, TContext)
  1312 TInt AllInterfaceNotificationActivity::TAwaitingStart::Accept()
  1335 TInt AllInterfaceNotificationActivity::TAwaitingStart::Accept()
  1459 	__ASSERT_DEBUG(iContext.Activity(), ConnPanic(KPanicNoActivity));
  1482 	__ASSERT_DEBUG(iContext.Activity(), ConnPanic(KPanicNoActivity));
  1460 
  1483 
  1461 	TCFTierStatusProvider::TTierNotification& msg = message_cast<TCFTierStatusProvider::TTierNotification>(iContext.iMessage);
  1484 	TCFTierStatusProvider::TTierNotification& msg = message_cast<TCFTierStatusProvider::TTierNotification>(iContext.iMessage);
  1462 
  1485 
  1463 	__ASSERT_DEBUG(msg.iBundle, User::Panic(KSpecAssert_ESockSSockscnsts, 14));
  1486 	__ASSERT_DEBUG(msg.iBundle, User::Panic(KSpecAssert_ESockSSockscnsts, 14));
       
  1487 	
       
  1488     CAllInterfaceNotificationActivity& act = *iContext.Activity();
       
  1489     
       
  1490     // Register with the IpProtoCpr factory for interface state changes if we haven't already done so.
       
  1491     // We can only do this if the IpProtoCpr is active, and the assumption here is that it must be active
       
  1492     // if an interface event has been generated.
       
  1493     if (!act.iRegisteredForInterfaceStateChanges)
       
  1494         {
       
  1495         CCommsFactoryBase* ipProtoCprFactory = act.IpProtoCprFactory();
       
  1496         if (ipProtoCprFactory)
       
  1497             {
       
  1498             Factories::IFactoryNotify itf(&act, act.GetVTable());
       
  1499             ipProtoCprFactory->RegisterNotifierL(itf);
       
  1500             act.iRegisteredForInterfaceStateChanges = ETrue;
       
  1501             }
       
  1502         }
       
  1503 
  1464 	if(msg.iBundle->PtrL()->CountParamSetContainers() > 0)
  1504 	if(msg.iBundle->PtrL()->CountParamSetContainers() > 0)
  1465 		{
  1505 		{
  1466 		TInt i = 0;
  1506 		TInt i = 0;
  1467 		TBool found = EFalse;
  1507 		TBool found = EFalse;
  1468 		while(const CConnectionServParameterSetContainer* container = static_cast<const CConnectionServParameterSetContainer*>(msg.iBundle->Ptr()->GetParamSetContainer(i++)))
  1508 		while(const CConnectionServParameterSetContainer* container = static_cast<const CConnectionServParameterSetContainer*>(msg.iBundle->Ptr()->GetParamSetContainer(i++)))