telephonyprotocols/pdplayer/src/PDPSCPRStates.cpp
changeset 19 1f776524b15c
parent 0 3553901f7fa8
child 15 fc69e1e37771
child 23 6b1d113cdff3
equal deleted inserted replaced
0:3553901f7fa8 19:1f776524b15c
   175 //Provisioning
   175 //Provisioning
   176 //-=========================================================
   176 //-=========================================================
   177 DEFINE_SMELEMENT(TSelfInit, NetStateMachine::MStateTransition, PDPSCprStates::TContext)
   177 DEFINE_SMELEMENT(TSelfInit, NetStateMachine::MStateTransition, PDPSCprStates::TContext)
   178 void TSelfInit::DoL()
   178 void TSelfInit::DoL()
   179     {
   179     {
   180     if (iContext.Node().iPdpFsmInterface == NULL)
   180     CPDPSubConnectionProvider &tNode = static_cast<CPDPSubConnectionProvider&>(iContext.Node());
       
   181     
       
   182     // if the FSM interface is null, this means that we're initializing a secondary context
       
   183     // as this code is common for both
       
   184     
       
   185     if (tNode.iPdpFsmInterface == NULL)
   181         {
   186         {
   182         //Non-default SCPR running this code
   187         //Non-default SCPR running this code
   183         ASSERT(iContext.Node().ControlProvider());
   188         ASSERT(iContext.Node().ControlProvider());
   184         ESock::TDefaultSCPRFactoryQuery query(iContext.Node().ControlProvider()->RecipientId(), TSubConnOpen::EAttachToDefault );
   189         ESock::TDefaultSCPRFactoryQuery query(iContext.Node().ControlProvider()->RecipientId(), TSubConnOpen::EAttachToDefault );
   185         ESock::CSubConnectionProviderBase* defProvider = static_cast<ESock::CSubConnectionProviderBase*>(static_cast<ESock::CSubConnectionProviderFactoryBase&>(iContext.Node().Factory()).Find(query));
   190         ESock::CSubConnectionProviderBase* defProvider = static_cast<ESock::CSubConnectionProviderBase*>(static_cast<ESock::CSubConnectionProviderFactoryBase&>(iContext.Node().Factory()).Find(query));
   191         iContext.Node().iPdpFsmInterface = iContext.Node().iDefaultSCPR->iPdpFsmInterface;
   196         iContext.Node().iPdpFsmInterface = iContext.Node().iDefaultSCPR->iPdpFsmInterface;
   192         iContext.Node().iPdpFsmInterface->Open();
   197         iContext.Node().iPdpFsmInterface->Open();
   193         }
   198         }
   194     else
   199     else
   195         {
   200         {
   196         //default SCPR running this code
   201         //default SCPR running this code (i.e. primary context)
   197         const CTSYProvision* tsyProvision = static_cast<const CTSYProvision*>(
   202         const CTSYProvision* tsyProvision =\
   198 	        iContext.Node().AccessPointConfig().FindExtension(CTSYProvision::TypeId()));
   203                 static_cast<const CTSYProvision*>(tNode.AccessPointConfig().FindExtension(CTSYProvision::TypeId()));
       
   204         
   199         if (tsyProvision == NULL)
   205         if (tsyProvision == NULL)
   200         	{
   206         	{
       
   207             // we do not have to set provision failure here
       
   208             // as it was set in the base class constructor
       
   209             // svg will show the leave error code though
   201         	User::Leave(KErrCorrupt);
   210         	User::Leave(KErrCorrupt);
   202         	}
   211         	}
       
   212         
   203         CGPRSProvision* gprsProvision = const_cast<CGPRSProvision*>(static_cast<const CGPRSProvision*>(
   213         CGPRSProvision* gprsProvision = const_cast<CGPRSProvision*>(static_cast<const CGPRSProvision*>(
   204         	    iContext.Node().AccessPointConfig().FindExtension(STypeId::CreateSTypeId(CGPRSProvision::EUid,CGPRSProvision::ETypeId))));
   214         	    tNode.AccessPointConfig().FindExtension(STypeId::CreateSTypeId(CGPRSProvision::EUid,CGPRSProvision::ETypeId))));
       
   215         
   205         if (gprsProvision == NULL)
   216         if (gprsProvision == NULL)
   206                 	{
   217             {
   207                 	User::Leave(KErrCorrupt);
   218             tNode.iProvisionFailure = KErrCorrupt;
   208                 	}
   219             User::Leave(KErrCorrupt);
   209         switch(gprsProvision->UmtsGprsRelease())
   220             }
       
   221         
       
   222         TInt configType = TPacketDataConfigBase::KConfigGPRS;
       
   223         
       
   224         switch (gprsProvision->UmtsGprsRelease())
   210         	{
   225         	{
   211         	case TPacketDataConfigBase::KConfigGPRS:
   226         	case TPacketDataConfigBase::KConfigGPRS:
   212                 iContext.Node().iPdpFsmInterface->NewL(tsyProvision->iTsyName, TPacketDataConfigBase::KConfigGPRS);
   227         	    configType = TPacketDataConfigBase::KConfigGPRS;
   213         		break;
   228         		break;
   214         	case TPacketDataConfigBase::KConfigRel99Rel4:
   229         	case TPacketDataConfigBase::KConfigRel99Rel4:
   215                 iContext.Node().iPdpFsmInterface->NewL(tsyProvision->iTsyName, TPacketDataConfigBase::KConfigRel99Rel4);
   230         	    configType = TPacketDataConfigBase::KConfigRel99Rel4;
   216         		break;
   231         		break;
   217         	case TPacketDataConfigBase::KConfigRel5:
   232         	case TPacketDataConfigBase::KConfigRel5:
   218                 iContext.Node().iPdpFsmInterface->NewL(tsyProvision->iTsyName, TPacketDataConfigBase::KConfigRel5);
   233         	    configType = TPacketDataConfigBase::KConfigRel5;
   219         		break;
   234         		break;
   220         	default:
   235         	default:
       
   236         	    // we do not have to set provision failure here
       
   237         	    // as it was set in the base class constructor
       
   238         	    // svg will show the leave error code though
   221         		User::Leave(KErrNotSupported);
   239         		User::Leave(KErrNotSupported);
       
   240         		break;
   222         	}
   241         	}
   223 
   242         
   224         iContext.Node().iDefaultSCPR = static_cast<CPDPDefaultSubConnectionProvider*>(&iContext.Node());
   243         // a provisioning failure would be unrecoverable as this only happens
   225         }
   244         // we cannot create memory, access etel or there is a configuration
   226 
   245         // problem - however, leaving with an error here does not stop the
   227     //Replace the BCA provision - we'll be overriding the portname (the rest stays the same).
   246         // sequence of events because the handler for provision config is not
   228   
   247         // expecting a response. if there is a failure then it will be errored in 
   229     // BA: This doesn't make sense, the port name is copied too so just replaces one CBCAProvision
   248         // the next activity in the sequence, i.e. DataClientStart
   230     // with another identical one!!
   249         TRAP(tNode.iProvisionFailure,tNode.iPdpFsmInterface->NewL(tsyProvision->iTsyName,configType));
   231 //    const CBCAProvision* bcaExtension = static_cast<const CBCAProvision*>(
   250         
   232 //        iContext.Node().AccessPointConfig().FindExtensionL(CBCAProvision::TypeId()));
   251         tNode.iDefaultSCPR = static_cast<CPDPDefaultSubConnectionProvider*>(&tNode);
   233 
   252         }
   234 /*    
       
   235 	CBCAProvision* bcaExtension2 = new (ELeave) CBCAProvision;
       
   236 	CleanupStack::PushL(bcaExtension2);
       
   237 
       
   238 	//Could optimise it one day.
       
   239 	bcaExtension2->SetBCAStack(bcaExtension->GetBCAStack());
       
   240 	bcaExtension2->SetBCAName(bcaExtension->GetBCAName());
       
   241 	bcaExtension2->SetIAPid(bcaExtension->GetIAPid());
       
   242 	bcaExtension2->SetPortName(bcaExtension->GetPortName());
       
   243 	bcaExtension2->SetCommRole(bcaExtension->GetCommRole());
       
   244 	bcaExtension2->SetHandShaking(bcaExtension->GetHandShaking());
       
   245 
       
   246 	iContext.Node().iAccessPointConfig->RemoveAndDestroyExtension_INTERNALTECH(CBCAProvision::TypeId());
       
   247     iContext.Node().iAccessPointConfig->AppendExtensionL(bcaExtension2);
       
   248     CleanupStack::Pop(bcaExtension2); //Ownership with the list
       
   249 */ 
       
   250     }
   253     }
   251 
   254 
   252 
   255 
   253 //-=========================================================
   256 //-=========================================================
   254 //Creating context
   257 //Creating context
   445 	return (networkMode == RMobilePhone::ENetworkModeGsm);
   448 	return (networkMode == RMobilePhone::ENetworkModeGsm);
   446 	}
   449 	}
   447 
   450 
   448 void TCreatePrimaryPDPCtx::DoL()
   451 void TCreatePrimaryPDPCtx::DoL()
   449     {
   452     {
   450     ASSERT(iContext.Node().iPdpFsmInterface);
   453     // if the provisionconfig failed, there is no way to inform the CPR of the failure
       
   454     // as the framework doesn't expect a response from provisionconfig, so error here
       
   455     // if there was a problem so that the appropriate clean up can happen.
       
   456     
       
   457     CPDPDefaultSubConnectionProvider &tNode = static_cast<CPDPDefaultSubConnectionProvider&>(iContext.Node());
       
   458     
       
   459     User::LeaveIfError(tNode.iProvisionFailure);
       
   460     
       
   461     ASSERT(tNode.iPdpFsmInterface);
   451 
   462 
   452     iContext.Node().PostToClients<TDefaultClientMatchPolicy>(
   463     iContext.Node().PostToClients<TDefaultClientMatchPolicy>(
   453             iContext.NodeId(),
   464             iContext.NodeId(),
   454             TCFMessage::TStateChange(
   465             TCFMessage::TStateChange(
   455                     Elements::TStateChange(KPsdStartingConfiguration, KErrNone)).CRef(),
   466                     Elements::TStateChange(KPsdStartingConfiguration, KErrNone)).CRef(),