networkcontrol/ipnetworklayer/src/IPProtoCprStates.cpp
branchRCL_3
changeset 7 db85996de7c4
parent 0 af10295192d8
child 8 e9cc36e353d4
equal deleted inserted replaced
6:c64cefac6e99 7:db85996de7c4
    35 #include <comms-infras/ss_nodemessages_internal.h>
    35 #include <comms-infras/ss_nodemessages_internal.h>
    36 #include <comms-infras/ss_legacyinterfaces.h>
    36 #include <comms-infras/ss_legacyinterfaces.h>
    37 #include <comms-infras/simpleselectorbase.h>
    37 #include <comms-infras/simpleselectorbase.h>
    38 #include <commsdattypesv1_1_partner.h>
    38 #include <commsdattypesv1_1_partner.h>
    39 #include <es_prot_internal.h>
    39 #include <es_prot_internal.h>
       
    40 #include <elements/nm_messages_errorrecovery.h>
    40 
    41 
    41 using namespace Messages;
    42 using namespace Messages;
    42 using namespace MeshMachine;
    43 using namespace MeshMachine;
    43 using namespace IpProtoCpr;
    44 using namespace IpProtoCpr;
    44 using namespace ESock;
    45 using namespace ESock;
       
    46 
       
    47 DEFINE_SMELEMENT(TProvisionActivation, NetStateMachine::MStateTransition, IpProtoCpr::TContext)
       
    48 void TProvisionActivation::DoL()
       
    49     {
       
    50     CIPProtoConnectionProvider& node = iContext.Node();
       
    51     
       
    52     //Trap if memory allocation fails
       
    53     TRAP( node.iProvisionError, node.iSubConnProvisioningInfo = new (ELeave) TDataMonitoringSubConnProvisioningInfo(NULL, NULL));
       
    54     }
       
    55 
       
    56 DEFINE_SMELEMENT(THandleProvisionError, NetStateMachine::MStateTransition, IpProtoCpr::TContext)
       
    57 void THandleProvisionError::DoL()
       
    58     {
       
    59     //Set node error
       
    60     iContext.iNodeActivity->SetError(iContext.Node().iProvisionError);
       
    61     }
    45 
    62 
    46 DEFINE_SMELEMENT(TStoreProvision, NetStateMachine::MStateTransition, IpProtoCpr::TContext)
    63 DEFINE_SMELEMENT(TStoreProvision, NetStateMachine::MStateTransition, IpProtoCpr::TContext)
    47 void TStoreProvision::DoL()
    64 void TStoreProvision::DoL()
    48 	{
    65 	{
    49 	PRStates::TStoreProvision storeProvision(iContext);
    66 	PRStates::TStoreProvision storeProvision(iContext);
    81     	// This used to be allocated in the SCPR, but it has been moved here to the CPR.  This is because there can be
    98     	// This used to be allocated in the SCPR, but it has been moved here to the CPR.  This is because there can be
    82     	// temporary circumstances where there is more than one SCPR present - one or more of these in a leaving
    99     	// temporary circumstances where there is more than one SCPR present - one or more of these in a leaving
    83     	// state and one in an active state.  The access point config cannot presently hold provisioning information
   100     	// state and one in an active state.  The access point config cannot presently hold provisioning information
    84     	// specific to an SCPR instance, so it is allocated and managed here in the CPR as a shared entity.  Only
   101     	// specific to an SCPR instance, so it is allocated and managed here in the CPR as a shared entity.  Only
    85     	// one SCPR instance should be using this at a time, however.
   102     	// one SCPR instance should be using this at a time, however.
    86     	TDataMonitoringSubConnProvisioningInfo* subConnProvisioningInfo = new (ELeave) TDataMonitoringSubConnProvisioningInfo(NULL, NULL);
   103     	
    87     	CleanupStack::PushL(subConnProvisioningInfo);
   104     	//this allocation taken care in previous activity entry
    88     	node.iNodeLocalExtensions.AppendExtensionL(subConnProvisioningInfo);
   105     	//just append here
    89     	CleanupStack::Pop(subConnProvisioningInfo);
   106     	//TDataMonitoringSubConnProvisioningInfo* subConnProvisioningInfo = new (ELeave) TDataMonitoringSubConnProvisioningInfo(NULL, NULL);
       
   107     	CleanupStack::PushL(node.iSubConnProvisioningInfo);
       
   108     	node.iNodeLocalExtensions.AppendExtensionL(node.iSubConnProvisioningInfo);
       
   109     	CleanupStack::Pop(node.iSubConnProvisioningInfo);
    90     	
   110     	
    91        	// The CLinkCprExtensionApi may have been added previously if this is a reconnect scenario
   111        	// The CLinkCprExtensionApi may have been added previously if this is a reconnect scenario
    92     	// We add it again in this new override of the extensions, if the old container is fully superceded
   112     	// We add it again in this new override of the extensions, if the old container is fully superceded
    93     	// it will be closed and destroyed.
   113     	// it will be closed and destroyed.
    94        	extension = CLinkCprExtensionApi::NewLC(iContext.Node());
   114        	extension = CLinkCprExtensionApi::NewLC(iContext.Node());
   120 			TCFDataClient::TProvisionConfig(iContext.Node().iAccessPointConfig).CRef()
   140 			TCFDataClient::TProvisionConfig(iContext.Node().iAccessPointConfig).CRef()
   121 			);
   141 			);
   122 		}
   142 		}
   123 	}
   143 	}
   124 
   144 
       
   145 DEFINE_SMELEMENT(TSendStoppedAndGoneDown, NetStateMachine::MStateTransition, IpProtoCpr::TContext)
       
   146 void TSendStoppedAndGoneDown::DoL()
       
   147 	{
       
   148 	ASSERT(iContext.iNodeActivity);
       
   149 
       
   150 	// stop has been caused by timer expiry, remove self from originators list, because we
       
   151 	// are not waiting for TStopped and in certain situations it would arrive after the node has been
       
   152 	// destroyed
       
   153 	if (iContext.Node().iTimerExpired)
       
   154 		{
       
   155 		TInt selfidx = iContext.iNodeActivity->FindOriginator(iContext.Node().SelfInterface());
       
   156 		ASSERT(selfidx != KErrNotFound);
       
   157 		iContext.iNodeActivity->RemoveOriginator(selfidx);
       
   158 		}
       
   159 		
       
   160 	TInt stopCode = KErrCancel;
       
   161     MeshMachine::CNodeActivityBase* activity = iContext.iNodeActivity;
       
   162     
       
   163     if (activity && activity->Error() != KErrNone)
       
   164         {
       
   165         stopCode = activity->Error();
       
   166         activity->SetError(KErrNone);
       
   167         }
       
   168 
       
   169 	// Could be TStop, TStopped or TDataClientStopped (usually TStopped)
       
   170 	if  ( (iContext.iMessage.IsMessage<TCFServiceProvider::TStopped>()) ||
       
   171 		(iContext.iMessage.IsMessage<TCFServiceProvider::TStop>()) ||
       
   172 		(iContext.iMessage.IsMessage<TCFDataClient::TStopped>()) ||
       
   173 		(iContext.iMessage.IsMessage<TCFDataClient::TStop>()) )
       
   174 		{
       
   175 		stopCode = static_cast<const Messages::TSigNumber&>(iContext.iMessage).iValue;
       
   176 		}
       
   177 	else if ( (iContext.iMessage.IsMessage<TCFControlClient::TGoneDown>()) ||
       
   178 		(iContext.iMessage.IsMessage<TCFControlProvider::TDataClientGoneDown>()) )
       
   179 		{
       
   180 		stopCode = static_cast<const Messages::TSigNumberNumber&>(iContext.iMessage).iValue1;
       
   181 		}
       
   182 	else if ( iContext.iMessage.IsMessage<TEErrorRecovery::TErrorRecoveryResponse>() )
       
   183 		{
       
   184 		// Action must be propagate or there is no error code (your activity flow is faulty)!
       
   185 		const Messages::TSigErrResponse& sig = static_cast<const Messages::TSigErrResponse&>(iContext.iMessage);
       
   186 		__ASSERT_DEBUG(sig.iErrResponse.iAction == Messages::TErrResponse::EPropagate, User::Invariant());
       
   187    		stopCode = sig.iErrResponse.iError;
       
   188 		}
       
   189 
       
   190 	TCFServiceProvider::TStopped msg(stopCode);
       
   191 	iContext.iNodeActivity->PostToOriginators(msg);
       
   192 
       
   193     const TProviderInfo& providerInfo = static_cast<const TProviderInfoExt&>(iContext.Node().AccessPointConfig().FindExtensionL(
       
   194             STypeId::CreateSTypeId(TProviderInfoExt::EUid, TProviderInfoExt::ETypeId))).iProviderInfo;
       
   195 
       
   196 	TCFControlClient::TGoneDown goneDown(stopCode, providerInfo.APId());
       
   197 	TClientIter<TDefaultClientMatchPolicy> iter = iContext.Node().GetClientIter<TDefaultClientMatchPolicy>(TClientType(TCFClientType::ECtrl));
       
   198     CNodeActivityBase* startActivity = iContext.Node().FindActivityById(ECFActivityStart);
       
   199 
       
   200     for (TInt i = 0; iter[i]; i++)
       
   201 		{
       
   202 		//Send TGoneDown to every Ctrl client except
       
   203 		// * the originator (who would be recieving TStopped)
       
   204 		// * originators of the start activity (these will be errored separately)
       
   205         if (iContext.iNodeActivity && iContext.iNodeActivity->FindOriginator(*iter[i]) >= 0)
       
   206             {
       
   207             continue; // ControlClient is a Stop originator
       
   208             }
       
   209 		
       
   210         // So far the control client is not a Stop originator
       
   211         if (startActivity == NULL || startActivity->FindOriginator(*iter[i]) == KErrNotFound)
       
   212 			{
       
   213             // ControlClient is not a Start originator
       
   214 			iter[i]->PostMessage(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), goneDown);
       
   215 			}
       
   216 		}
       
   217 
       
   218 	if (iContext.iNodeActivity)
       
   219     	{
       
   220         iContext.iNodeActivity->SetError(KErrNone);
       
   221     	}
       
   222 	}
       
   223 
   125 DEFINE_SMELEMENT(TAwaitingDataMonitoringNotification, NetStateMachine::MState, IpProtoCpr::TContext)
   224 DEFINE_SMELEMENT(TAwaitingDataMonitoringNotification, NetStateMachine::MState, IpProtoCpr::TContext)
   126 TBool TAwaitingDataMonitoringNotification::Accept()
   225 TBool TAwaitingDataMonitoringNotification::Accept()
   127 	{
   226 	{
   128 	return iContext.iMessage.IsMessage<TCFDataMonitoringNotification::TDataMonitoringNotification>();
   227 	return iContext.iMessage.IsMessage<TCFDataMonitoringNotification::TDataMonitoringNotification>();
   129 	}
   228 	}