realtimenetprots/rtp/cfrtp/src/rtpscpr.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // RTP SubConnection Provider implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 
       
    24 #include <comms-infras/ss_log.h>
       
    25 #include <comms-infras/ss_nodemessages_factory.h>
       
    26 #include "rtp_cfmessages.h"
       
    27 #include "rtpscpr.h"
       
    28 #include "rtpscprstates.h"
       
    29 
       
    30 
       
    31 
       
    32 using namespace ESock;
       
    33 using namespace NetStateMachine;
       
    34 using namespace Messages;
       
    35 using namespace MeshMachine;
       
    36 
       
    37 namespace RTPSCprParamsRequest
       
    38 {
       
    39 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
       
    40 DECLARE_DEFINE_NODEACTIVITY(ECFActivityParamRequest, RTPSCprSetParams, TCFScpr::TSetParamsRequest)
       
    41 	FIRST_NODEACTIVITY_ENTRY(PRStates::TAwaitingParamRequest, CoreNetStates::TNoTagOrBearerPresent)
       
    42 	NODEACTIVITY_ENTRY(CoreNetStates::KBearerPresent, PRStates::TPassToServiceProvider, CoreNetStates::TAwaitingParamResponse, CoreNetStates::TBearerPresent)
       
    43 	LAST_NODEACTIVITY_ENTRY(CoreNetStates::KBearerPresent, PRStates::TStoreParamsAndPostToOriginators)
       
    44 	LAST_NODEACTIVITY_ENTRY(KNoTag, PRStates::TStoreAndRespondWithCurrentParams)
       
    45 NODEACTIVITY_END()
       
    46 #else
       
    47 DECLARE_DEFINE_NODEACTIVITY(ECFActivityParamRequest, RTPSCprSetParams, TCFScpr::TParamsRequest)
       
    48 	FIRST_NODEACTIVITY_ENTRY(SCprStates::TAwaitingParamRequest, CoreNetStates::TNoTagOrBearerPresent)
       
    49 	NODEACTIVITY_ENTRY(CoreNetStates::KBearerPresent, SCprStates::TPassToServiceProvider, CoreNetStates::TAwaitingParamResponse, CoreNetStates::TBearerPresent)
       
    50 	LAST_NODEACTIVITY_ENTRY(CoreNetStates::KBearerPresent, SCprStates::TStoreParamsAndPostToOriginators)
       
    51 	LAST_NODEACTIVITY_ENTRY(KNoTag, SCprStates::TStoreAndRespondWithCurrentParams)
       
    52 NODEACTIVITY_END()
       
    53 #endif //SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
       
    54 }
       
    55 
       
    56 
       
    57 //This will check if the scpr is of type RTP and then branch
       
    58 //If RTP, it will send commsbinder request to IPCPR to make the deftIP SCPR its service provider
       
    59 //If IPSCPR ( normal case ), it will send commsbinder to its servicwe provider
       
    60 namespace RTPSCprNoBearerActivity
       
    61 {
       
    62 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityNoBearer, RTPSCprNoBearer, TCFControlProvider::TNoBearer, PRActivities::CNoBearer::NewL)
       
    63 	FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingNoBearer, CoreNetStates::TNoTagOrBearerPresent)
       
    64 	
       
    65 	NODEACTIVITY_ENTRY(KNoTag, RtpSCprStates::TSendCommsBinderToCntrlProv, CoreNetStates::TAwaitingBinderResponse, MeshMachine::TNoTag)
       
    66 	NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendControlClientJoinRequest, CoreStates::TAwaitingJoinComplete, MeshMachine::TNoTag)
       
    67 	THROUGH_NODEACTIVITY_ENTRY(KNoTag, CoreActivities::ABindingActivity::TSendBindToComplete, MeshMachine::TNoTag)
       
    68 	
       
    69 	NODEACTIVITY_ENTRY(KNoTag, RtpSCprStates::TRequestCommsBinderRetry, CoreNetStates::TAwaitingBinderResponse, MeshMachine::TNoTag)
       
    70 	NODEACTIVITY_ENTRY(CoreNetStates::KBearerPresent, RtpSCprStates::TRequestCommsBinderRetry, CoreNetStates::TAwaitingBinderResponse, MeshMachine::TNoTag)
       
    71 	NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendBindTo, CoreNetStates::TAwaitingBindToComplete, MeshMachine::TNoTag)
       
    72 	THROUGH_NODEACTIVITY_ENTRY(KNoTag, CoreActivities::ABindingActivity::TSendBindToComplete, PRActivities::CNoBearer::TNoTagOrDataClientsToStart)
       
    73 
       
    74 	//Flow asking for a bearer needs to be started (provided KErrNone)
       
    75 	NODEACTIVITY_ENTRY(CoreNetStates::KDataClientsToStart, PRActivities::CNoBearer::TStartOriginatingDataClient, CoreNetStates::TAwaitingDataClientStarted, MeshMachine::TNoTag)
       
    76 		
       
    77 	LAST_NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing)
       
    78 		
       
    79 NODEACTIVITY_END()
       
    80 }
       
    81 
       
    82 
       
    83 // The activity will wait for ProvisionDone message from the flow. This will prevent the flow hanging in air with out a bearer while the 
       
    84 // socket is writing data to it. Now there is a case where in flow couldnot bind to the SP also the NoBearer which the flow sends maynot 
       
    85 // be completed. Unfortunately this activity has no way of knowing that the NoBearer sent by the flow has failed. The ProvisionDone message 
       
    86 // has a response code which will give an indication as to whether the flow is ready to accept a BindTo from above.
       
    87 namespace RTPSCprBinderRequestActivity
       
    88 {
       
    89 DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityBinderRequest, RTPSCprBinderRequest, ESock::TCFServiceProvider::TCommsBinderRequest, PRActivities::CCommsBinderActivity::NewL)
       
    90 	FIRST_NODEACTIVITY_ENTRY(RtpSCprStates::TAwaitingBinderRequest, PRActivities::CCommsBinderActivity::TNoTagOrUseExistingBlockedByBinderRequest)
       
    91 	NODEACTIVITY_ENTRY(KNoTag, RtpSCprStates::TCreateDataClient, CoreNetStates::TAwaitingDataClientJoin, MeshMachine::TNoTag)
       
    92 
       
    93 	THROUGH_NODEACTIVITY_ENTRY(KNoTag, PRActivities::CCommsBinderActivity::TProcessDataClientCreation, MeshMachine::TTag<CoreStates::KUseExisting>) 
       
    94 	NODEACTIVITY_ENTRY(CoreStates::KUseExisting, RtpSCprStates::TSetPostedToFlow, RtpSCprStates::TAwaitingReadyForBind, RtpSCprStates::TNoTagOrErrorTag)
       
    95 	LAST_NODEACTIVITY_ENTRY(KErrorTag, MeshMachine::TRaiseAndClearActivityError)
       
    96 	// Below this point we need to modify the error handling approach. If we're getting a TError on TBinderResponse,
       
    97 	// this means the client requesting the binder couldn't bind to it. As far as the client is concerned, this
       
    98 	// activity is finished (it has flagged an error). The standard error handling will result in erroring
       
    99 	// the originator. In this case we shouldn't error the originator, instead, wrap up quietly.
       
   100 	NODEACTIVITY_ENTRY(KNoTag, PRActivities::CCommsBinderActivity::TSendBinderResponse, PRActivities::CCommsBinderActivity::TAwaitingBindToComplete, MeshMachine::TNoTagOrErrorTag)
       
   101 	LAST_NODEACTIVITY_ENTRY(KNoTag, MeshMachine::TDoNothing)
       
   102 	LAST_NODEACTIVITY_ENTRY(KErrorTag, MeshMachine::TClearError)
       
   103 NODEACTIVITY_END()
       
   104 }
       
   105 
       
   106 
       
   107 namespace RTPSCprActivities
       
   108 {
       
   109 DECLARE_DEFINE_ACTIVITY_MAP(activityMap)
       
   110     ACTIVITY_MAP_ENTRY(RTPSCprParamsRequest, RTPSCprSetParams)
       
   111 	ACTIVITY_MAP_ENTRY(RTPSCprNoBearerActivity, RTPSCprNoBearer)
       
   112 	ACTIVITY_MAP_ENTRY(RTPSCprBinderRequestActivity, RTPSCprBinderRequest)
       
   113 ACTIVITY_MAP_END_BASE(SCprActivities, coreSCprActivities)
       
   114 }
       
   115 //-=========================================================
       
   116 //
       
   117 // CRtpSubConnectionProvider methods
       
   118 //
       
   119 //-=========================================================	
       
   120 CRtpSubConnectionProvider* CRtpSubConnectionProvider::NewL(ESock::CSubConnectionProviderFactoryBase& aFactory)
       
   121 /**
       
   122 Construct a new RTP SubConnection Provider Object
       
   123 
       
   124 @param aFactory factory that create this object
       
   125 */
       
   126 	{
       
   127 	CRtpSubConnectionProvider* self = new (ELeave) CRtpSubConnectionProvider(aFactory);
       
   128     CleanupStack::PushL(self);
       
   129     self->ConstructL();
       
   130     CleanupStack::Pop();
       
   131 	return self;
       
   132 	}
       
   133 
       
   134 
       
   135 CRtpSubConnectionProvider::~CRtpSubConnectionProvider()
       
   136     {
       
   137     LOG_NODE_DESTROY(KRTPSCprTag, CRtpSubConnectionProvider);
       
   138     iLocalParameterBundle.Close();
       
   139     }
       
   140 
       
   141 
       
   142 CRtpSubConnectionProvider::CRtpSubConnectionProvider(ESock::CSubConnectionProviderFactoryBase& aFactory)
       
   143 :CCoreSubConnectionProvider(aFactory, RTPSCprActivities::activityMap::Self())
       
   144     {
       
   145     LOG_NODE_CREATE(KRTPSCprTag, CRtpSubConnectionProvider);
       
   146     }
       
   147 
       
   148 void CRtpSubConnectionProvider::ConstructL()
       
   149 /**
       
   150 RTP SubConnection Provider Second Phase Constructor
       
   151 */
       
   152 	{
       
   153     CCoreSubConnectionProvider::ConstructL();
       
   154 	}
       
   155 
       
   156 void CRtpSubConnectionProvider::Received(MeshMachine::TNodeContextBase& aContext)
       
   157     {
       
   158   
       
   159 	 	Messages::TNodeSignal::TMessageId noPeerIds[] = {
       
   160         TCFFactory::TPeerFoundOrCreated::Id(),
       
   161         TCFPeer::TJoinRequest::Id(),
       
   162         Messages::TNodeSignal::TMessageId()
       
   163         };
       
   164 
       
   165     MeshMachine::AMMNodeBase::Received(noPeerIds, aContext);
       
   166 	MeshMachine::AMMNodeBase::PostReceived(aContext);
       
   167 	}
       
   168 
       
   169 void CRtpSubConnectionProvider::ReceivedL(const TRuntimeCtxId& aSender, const TNodeId& aRecipient, TSignatureBase& aCFMessage)
       
   170     {
       
   171     RtpSCprStates::TContext ctx(*this, aCFMessage, aSender, aRecipient);
       
   172     CRtpSubConnectionProvider::Received(ctx);
       
   173     User::LeaveIfError(ctx.iReturn);
       
   174 	}
       
   175 
       
   176 RCFParameterFamilyBundle& CRtpSubConnectionProvider::GetOrCreateLocalParameterBundleL()
       
   177 	{
       
   178 	if( ! iLocalParameterBundle.IsNull())
       
   179 		{
       
   180 		return iLocalParameterBundle;
       
   181 		}
       
   182 	iLocalParameterBundle.CreateL();
       
   183 	iLocalParameterBundle.Open();
       
   184 
       
   185 	return iLocalParameterBundle;	
       
   186 	}
       
   187