telephonyprotocols/pdplayer/src/PDPCPR.cpp
changeset 49 f50f4094acd7
parent 0 3553901f7fa8
child 64 b34bb05ac869
equal deleted inserted replaced
48:14460bf2a402 49:f50f4094acd7
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    29 #include <comms-infras/corescprstates.h>
    29 #include <comms-infras/corescprstates.h>
    30 #include <elements/mm_context.h>
    30 #include <elements/mm_context.h>
    31 #include <etelmm.h>
    31 #include <etelmm.h>
    32 #include <etelpckt.h>
    32 #include <etelpckt.h>
    33 #include <comms-infras/ss_metaconnprov.h>
    33 #include <comms-infras/ss_metaconnprov.h>
    34 #include "pdpprovision.h"
    34 #include "PDPProvision.h"
    35 #include <etel.h>
    35 #include <etel.h>
    36 #include <networking/cfbearers.h>
       
    37 #include "pdpcpravailabilitylistener.h"
    36 #include "pdpcpravailabilitylistener.h"
    38 #include <comms-infras/ss_nodemessages.h>
    37 #include <comms-infras/ss_nodemessages.h>
    39 #include <networking/ipcpr_states.h>
       
    40 #include <comms-infras/linkmessages.h>
    38 #include <comms-infras/linkmessages.h>
    41 #include <elements/nm_interfaces.h>
    39 #include <elements/nm_interfaces.h>
       
    40 
       
    41 
       
    42 
       
    43 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
       
    44 #include <networking/cfbearers.h>
       
    45 #include <networking/ipcpr_states.h>
    42 #include <cs_genevent.h>
    46 #include <cs_genevent.h>
    43 #include <networking/etelbearers.h>
    47 #include <networking/etelbearers.h>
       
    48 #endif
    44 
    49 
    45 using namespace ESock;
    50 using namespace ESock;
    46 
    51 
    47 
    52 
    48 //-=========================================================
    53 //-=========================================================
    55 //node: destroy and data client stop.
    60 //node: destroy and data client stop.
    56 static const TUint KDefaultMaxPreallocatedActivityCount = 2;
    61 static const TUint KDefaultMaxPreallocatedActivityCount = 2;
    57 static const TUint KMaxPreallocatedActivitySize = sizeof(MeshMachine::CNodeRetryParallelActivity) + sizeof(MeshMachine::APreallocatedOriginators<4>);
    62 static const TUint KMaxPreallocatedActivitySize = sizeof(MeshMachine::CNodeRetryParallelActivity) + sizeof(MeshMachine::APreallocatedOriginators<4>);
    58 static const TUint KPDPCPRPreallocatedActivityBufferSize = KDefaultMaxPreallocatedActivityCount * KMaxPreallocatedActivitySize;
    63 static const TUint KPDPCPRPreallocatedActivityBufferSize = KDefaultMaxPreallocatedActivityCount * KMaxPreallocatedActivitySize;
    59 
    64 
       
    65 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
    60 namespace PDPCprLinkCharacteristicActivity
    66 namespace PDPCprLinkCharacteristicActivity
    61 {
    67 {
    62 DECLARE_DEFINE_NODEACTIVITY(ECFActivityParamRequest, PDPCprLinkCharacteristic, TCFScpr::TGetParamsRequest)
    68 DECLARE_DEFINE_NODEACTIVITY(ECFActivityParamRequest, PDPCprLinkCharacteristic, TCFScpr::TGetParamsRequest)
    63     NODEACTIVITY_ENTRY(MeshMachine::KNoTag, PDPCprStates::TUpdateBundleAndRespondWithRetrievedParams, PRStates::TAwaitingParamRequest, MeshMachine::TNoTag)
    69     NODEACTIVITY_ENTRY(MeshMachine::KNoTag, PDPCprStates::TUpdateBundleAndRespondWithRetrievedParams, PRStates::TAwaitingParamRequest, MeshMachine::TNoTag)
    64 NODEACTIVITY_END()
    70 NODEACTIVITY_END()
    72     FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingDataClientGoneDown, CoreNetStates::TNoTagOrNonDefault)
    78     FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingDataClientGoneDown, CoreNetStates::TNoTagOrNonDefault)
    73     LAST_NODEACTIVITY_ENTRY(MeshMachine::KNoTag, PRStates::TSendGoneDown)
    79     LAST_NODEACTIVITY_ENTRY(MeshMachine::KNoTag, PRStates::TSendGoneDown)
    74     LAST_NODEACTIVITY_ENTRY(CoreNetStates::KNonDefault, MeshMachine::TDoNothing)    
    80     LAST_NODEACTIVITY_ENTRY(CoreNetStates::KNonDefault, MeshMachine::TDoNothing)    
    75 NODEACTIVITY_END()
    81 NODEACTIVITY_END()
    76 }
    82 }
       
    83 #endif
    77 
    84 
    78 namespace PDPCprActivities
    85 namespace PDPCprActivities
    79 {
    86 {
    80 DEFINE_ACTIVITY_MAP(activityMap)
    87 DEFINE_ACTIVITY_MAP(activityMap)
       
    88 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
    81     ACTIVITY_MAP_ENTRY(PDPDataClientGoneDownActivity, PDPScprGoneDown)
    89     ACTIVITY_MAP_ENTRY(PDPDataClientGoneDownActivity, PDPScprGoneDown)
    82 	ACTIVITY_MAP_ENTRY(PDPCprLinkCharacteristicActivity, PDPCprLinkCharacteristic)
    90 	ACTIVITY_MAP_ENTRY(PDPCprLinkCharacteristicActivity, PDPCprLinkCharacteristic)
       
    91 #endif
    83 ACTIVITY_MAP_END_BASE(CprActivities, coreCprActivities)
    92 ACTIVITY_MAP_END_BASE(CprActivities, coreCprActivities)
    84 }
    93 }
    85 
       
    86 
    94 
    87 CPDPConnectionProvider* CPDPConnectionProvider::NewL(ESock::CConnectionProviderFactoryBase& aFactory)
    95 CPDPConnectionProvider* CPDPConnectionProvider::NewL(ESock::CConnectionProviderFactoryBase& aFactory)
    88     {
    96     {
    89     CPDPConnectionProvider* provider = new (ELeave) CPDPConnectionProvider(aFactory);
    97     CPDPConnectionProvider* provider = new (ELeave) CPDPConnectionProvider(aFactory);
    90     CleanupStack::PushL(provider);
    98     CleanupStack::PushL(provider);
    91     provider->ConstructL();
    99     provider->ConstructL();
    92     CleanupStack::Pop(provider);
   100     CleanupStack::Pop(provider);
    93 	return provider;
   101 	return provider;
    94     }        
   102     }        
    95 
   103 
    96 
       
    97 void CPDPConnectionProvider::StartListener()
       
    98 /**
       
    99  * Start listening for dynamic caps or network mode changes.
       
   100  * @param None
       
   101  * @return void
       
   102  */
       
   103 	{
       
   104 	iDynamicCapsEventListener->NotifyDynamicCapsChange(this);
       
   105 	iNetworkModeEventListener->NotifyNetworkModeChange(this);
       
   106 	}
       
   107 
       
   108 void CPDPConnectionProvider::ConstructL()
   104 void CPDPConnectionProvider::ConstructL()
   109 /**
   105 /**
   110  * PDP Connection Provider Second Phase Constructor
   106  * PDP Connection Provider Second Phase Constructor
   111  * @param None
   107  * @param None
   112  * @return void
   108  * @return void
   113  */
   109  */
   114 	{
   110 	{
   115 	CCoreConnectionProvider::ConstructL(KPDPCPRPreallocatedActivityBufferSize);
   111 	CCoreConnectionProvider::ConstructL(KPDPCPRPreallocatedActivityBufferSize);
   116 	}
   112 	}
   117 
   113 
   118 void CPDPConnectionProvider::StopListener()
       
   119 /**
       
   120  * Start listening for dynamic caps or network mode changes.
       
   121  */
       
   122 	{
       
   123 	if(iDynamicCapsEventListener)
       
   124 		{
       
   125 		iDynamicCapsEventListener->Cancel();
       
   126 		}
       
   127 	if(iNetworkModeEventListener)
       
   128 		{
       
   129 		iNetworkModeEventListener->Cancel();
       
   130 		}
       
   131 	}
       
   132 
       
   133 CPDPConnectionProvider::CPDPConnectionProvider(ESock::CConnectionProviderFactoryBase& aFactory)
   114 CPDPConnectionProvider::CPDPConnectionProvider(ESock::CConnectionProviderFactoryBase& aFactory)
   134 	: CCoreConnectionProvider(aFactory, PDPCprActivities::activityMap::Self())
   115 	: CCoreConnectionProvider(aFactory, PDPCprActivities::activityMap::Self()),
       
   116 	  iDynamicCapsEventListener(NULL),
       
   117 	  iNetworkModeEventListener(NULL),
       
   118 	  iBearerType(0),
       
   119 	  iBearerSet(EFalse)
       
   120 	  
   135 /**
   121 /**
   136  * Construct PDP connection provider.
   122  * Construct PDP connection provider.
   137  */	
   123  */	
   138     {        
   124     {        
   139     LOG_NODE_CREATE(KESockConnectionTag, CPDPConnectionProvider);
   125     LOG_NODE_CREATE(KESockConnectionTag, CPDPConnectionProvider);
   143 /**
   129 /**
   144  * Destroy PDP connection provider.
   130  * Destroy PDP connection provider.
   145  */
   131  */
   146     {    
   132     {    
   147     LOG_NODE_DESTROY(KESockConnectionTag, CPDPConnectionProvider);
   133     LOG_NODE_DESTROY(KESockConnectionTag, CPDPConnectionProvider);
       
   134 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
   148     StopListener();
   135     StopListener();
       
   136 #endif
   149 	delete iDynamicCapsEventListener;
   137 	delete iDynamicCapsEventListener;
   150 	delete iNetworkModeEventListener;
   138 	delete iNetworkModeEventListener;
   151     }
   139     }
   152     
   140     
   153 void CPDPConnectionProvider::ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage)
   141 void CPDPConnectionProvider::ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage)
   163 /**
   151 /**
   164  * Update the parmeter set in case of modulation change and send TPlaneNotification message to
   152  * Update the parmeter set in case of modulation change and send TPlaneNotification message to
   165  * all the control client.
   153  * all the control client.
   166  */
   154  */
   167 	{
   155 	{
       
   156 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
   168 	//Update bearers.
   157 	//Update bearers.
   169 	UpdateBearer();
   158 	UpdateBearer();
   170 	
   159 	
   171 	//Send msg to all control clients
   160 	//Send msg to all control clients
   172 	CEventParamsChanged* eventChanged = CEventParamsChanged::NewL(KBearerInfo);
   161 	CEventParamsChanged* eventChanged = CEventParamsChanged::NewL(KBearerInfo);
   193 	while ((ctl = iter++) != NULL)
   182 	while ((ctl = iter++) != NULL)
   194 		{
   183 		{
   195 		msg.iRefCountOwnedNotification->Open();
   184 		msg.iRefCountOwnedNotification->Open();
   196 		ctl->PostMessage(this->NodeId(), msg);
   185 		ctl->PostMessage(this->NodeId(), msg);
   197 		}
   186 		}
   198 
   187 #endif
   199 	}
   188 	}
   200 
   189 
   201 
   190 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
       
   191 void CPDPConnectionProvider::StartListener()
       
   192 /**
       
   193  * Start listening for dynamic caps or network mode changes.
       
   194  * @param None
       
   195  * @return void
       
   196  */
       
   197     {
       
   198     iDynamicCapsEventListener->NotifyDynamicCapsChange(this);
       
   199     iNetworkModeEventListener->NotifyNetworkModeChange(this);
       
   200     }
       
   201 
       
   202 void CPDPConnectionProvider::StopListener()
       
   203 /**
       
   204  * Start listening for dynamic caps or network mode changes.
       
   205  */
       
   206     {
       
   207     if(iDynamicCapsEventListener)
       
   208         {
       
   209         iDynamicCapsEventListener->Cancel();
       
   210         }
       
   211     if(iNetworkModeEventListener)
       
   212         {
       
   213         iNetworkModeEventListener->Cancel();
       
   214         }
       
   215     }
   202 void CPDPConnectionProvider::UpdateBearer()
   216 void CPDPConnectionProvider::UpdateBearer()
   203 /**
   217 /**
   204  * Update bearer type based on the change of the dynamic caps or network mode.
   218  * Update bearer type based on the change of the dynamic caps or network mode.
   205  */
   219  */
   206 	{
   220 	{
   211 	
   225 	
   212 	//Resolve the bearer based on both dynamic caps and network mode
   226 	//Resolve the bearer based on both dynamic caps and network mode
   213 	iBearerType = Bearer(dynamicCaps, networkMode);
   227 	iBearerType = Bearer(dynamicCaps, networkMode);
   214 	iBearerSet = ETrue;
   228 	iBearerSet = ETrue;
   215 	}
   229 	}
   216 
       
   217 
   230 
   218 TUint32 CPDPConnectionProvider::Bearer(TUint aDynamicCaps, RMobilePhone::TMobilePhoneNetworkMode& aNetworkMode)
   231 TUint32 CPDPConnectionProvider::Bearer(TUint aDynamicCaps, RMobilePhone::TMobilePhoneNetworkMode& aNetworkMode)
   219 /**
   232 /**
   220  * Determine bearer based on dynamic caps and network mode.
   233  * Determine bearer based on dynamic caps and network mode.
   221  * @param aDynamicCaps a value of dynamic caps
   234  * @param aDynamicCaps a value of dynamic caps
   222  * @param aNetworkMode a value of network mode
   235  * @param aNetworkMode a value of network mode
   223  * @return Type of Bearer
   236  * @return Type of Bearer
   224  *
   237  *
   225  */
   238  */
   226 	{
   239 	{
   227 	
       
   228 	if ((aDynamicCaps & RPacketService::KCapsHSUPA) || (aDynamicCaps & RPacketService::KCapsHSDPA))
   240 	if ((aDynamicCaps & RPacketService::KCapsHSUPA) || (aDynamicCaps & RPacketService::KCapsHSDPA))
   229 		{
   241 		{
   230 		return KHsdpaBearer;
   242 		return KHsdpaBearer;
   231 		}
   243 		}
   232 	else if (aDynamicCaps & RPacketService::KCapsEGPRS)
   244 	else if (aDynamicCaps & RPacketService::KCapsEGPRS)
   248 		   	return KDefaultBearer;
   260 		   	return KDefaultBearer;
   249 			}
   261 			}
   250 		}
   262 		}
   251 	}
   263 	}
   252 
   264 
   253 
       
   254 DEFINE_SMELEMENT(PDPCprStates::TUpdateBundle, NetStateMachine::MStateTransition, PDPCprStates::TContext)
   265 DEFINE_SMELEMENT(PDPCprStates::TUpdateBundle, NetStateMachine::MStateTransition, PDPCprStates::TContext)
   255 void PDPCprStates::TUpdateBundle::DoL()
   266 void PDPCprStates::TUpdateBundle::DoL()
   256 /**
   267 /**
   257  * Process TGetParamsRequest
   268  * Process TGetParamsRequest
   258  */
   269  */
   297 		// if Dynamic Caps supported, start listener, which would Notify of Dynamic Caps change
   308 		// if Dynamic Caps supported, start listener, which would Notify of Dynamic Caps change
   298 		// no check required for network mode, since atleast one network mode is supported.
   309 		// no check required for network mode, since atleast one network mode is supported.
   299 		iContext.Node().StartListener();
   310 		iContext.Node().StartListener();
   300 		}
   311 		}
   301 	}
   312 	}
   302 
   313 #endif
   303 
   314 
       
   315