telephonyprotocols/umtsgprsscpr/spudtel/src/ceteldrivercontext.cpp
changeset 64 b34bb05ac869
parent 56 ab72d5c1d770
equal deleted inserted replaced
56:ab72d5c1d770 64:b34bb05ac869
     1 // Copyright (c) 2004-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 // implementation of etel driver context class
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file 
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 
       
    24 #include "ceteldrivercontext.h"
       
    25 #include "ceteldriverfactory.h"
       
    26 #include "spudteldebuglogger.h"
       
    27 
       
    28 
       
    29 using namespace EtelDriver;
       
    30 
       
    31 CEtelDriverContext::CEtelDriverContext (TContextId aId, CEtelDriverFactory& aFactory)
       
    32 : CActive(CActive::EPriorityStandard),
       
    33   iId(aId),
       
    34   iCompletionStatus(KErrNone),
       
    35   iStrategyStep(MEtelDriverStrategy::EFinishStep),
       
    36   iStrategyId(ESentinelStrategy),
       
    37   iFactory(aFactory),
       
    38   iQosRequestedPckg(iQosRequested),
       
    39   iQosNegotiatedPckg(iQosNegotiated),
       
    40  iContextConfigGPRS(),
       
    41  iContextConfigGPRSPckg(iContextConfigGPRS),
       
    42  iDataChannelV2(),
       
    43  iDataChannelV2Pckg(iDataChannelV2),
       
    44  iFilterV2(),
       
    45  iFilterV2Pckg(iFilterV2)
       
    46  	{
       
    47 	SPUDTEL_FNLOG("CEtelDriverContext::CEtelDriverContext");
       
    48 	CActiveScheduler::Add(this);
       
    49   	}
       
    50 
       
    51 
       
    52 
       
    53 CEtelDriverContext::~CEtelDriverContext()
       
    54 	{
       
    55 	SPUDTEL_FNLOG("CEtelDriverContext::~CEtelDriverContext()");
       
    56 	Cancel(); // N.B. This cancels all outstanding operations on the context, including deletion!
       
    57 	
       
    58 	// Guarantees proper release of all handles.
       
    59 	// If everything is closed already, this does no harm.
       
    60 	iPacketQoS.Close(); // Close QoS first, a buggy TSY may not handle it the other way.
       
    61 	iPacketContext.Close(); // At this point the reference count on the context is zero.
       
    62 	// TSY should cleanly dispose of the context, if it had not done so already.
       
    63 	
       
    64 	// This is necessary only in a situtation where Spudman is destroyed while a strategy
       
    65 	// on a context is outstanding: in this case deletion of SpudTel results in cancellation
       
    66 	// of all outstanding operations, which is likely to result in handle leak.
       
    67 	// Under other circumstances, the handles will be closed via an appropriate strategy.
       
    68 	}
       
    69 
       
    70 /** initiates a new request 
       
    71 
       
    72 @param aOperation - type of an etel driver request 
       
    73 
       
    74 @return KErrInUse if pdp context has active strategy
       
    75 */
       
    76 TInt CEtelDriverContext::Input (TEtelInput aOperation)
       
    77 	{
       
    78 	SPUDTEL_FNLOG("CEtelDriverContext::Input()");
       
    79 	SPUDTELVERBOSE_INFO_LOG1( _L("Operation %d"), aOperation );
       
    80 	
       
    81 	if (MEtelDriverStrategy::EFinishStep != iStrategyStep)
       
    82 		{
       
    83 		SPUDTEL_ERROR_LOG(_L("ERROR: Pdp context is in use, return %d"), KErrInUse);
       
    84 		// I'm still doing something
       
    85 		ASSERT(EFalse); // shouldn't happen
       
    86 		return KErrInUse;
       
    87 		}
       
    88 	
       
    89 	iStrategyId = iFactory.StrategyId(aOperation);
       
    90 	iStrategyStep = MEtelDriverStrategy::EStartStep;
       
    91 	iCompletionStatus = KErrNone;
       
    92 	
       
    93 	SetActive();
       
    94 	Strategy(iStrategyId).Next(*this, &iStatus);
       
    95 
       
    96 	return KErrNone;
       
    97 	}
       
    98 
       
    99 
       
   100 void CEtelDriverContext::RunL()
       
   101 	{
       
   102 	SPUDTEL_FNLOG("CEtelDriverContext::RunL()");
       
   103 	ASSERT(iStrategyId < ESentinelStrategy);
       
   104 	
       
   105 	if(iStatus != KErrNone)
       
   106 		{
       
   107 		if(iCompletionStatus == KErrNone)
       
   108 			{ 
       
   109 			iCompletionStatus = iStatus; 
       
   110 			SPUDTEL_ERROR_LOG(_L("Last async request completed with error %d"), iStatus.Int());
       
   111 			}
       
   112 		// Don't continue with the strategy for all cases except Delete
       
   113 		// N.B.: deletion of a context has to be done till the very last step
       
   114 		//	to ensure proper cleanup of resources.
       
   115 		if(EContextDeleteStrategy != iStrategyId)
       
   116 			{
       
   117 			iStrategyStep = MEtelDriverStrategy::EFinishStep;
       
   118 			}
       
   119 		SPUDTELVERBOSE_INFO_LOG(_L("Strategy is completed"));
       
   120 		}
       
   121 	
       
   122 	if(MEtelDriverStrategy::EFinishStep == iStrategyStep)
       
   123 		{
       
   124 		// we are done
       
   125 		SPUDTELVERBOSE_INFO_LOG(_L("Strategy is completed"));
       
   126 		Strategy(iStrategyId).NotifyFsm (*this, iCompletionStatus);
       
   127 		}
       
   128 	else
       
   129 		{
       
   130 		// continue with next step
       
   131 		SetActive();
       
   132 		Strategy(iStrategyId).Next(*this, &iStatus);
       
   133 		}
       
   134 	}
       
   135 
       
   136 /** cancels last async request */  	
       
   137 void CEtelDriverContext::DoCancel()
       
   138 	{
       
   139 	SPUDTEL_FNLOG("CEtelDriverContext::DoCancel()");
       
   140 
       
   141 	if(IsActive())
       
   142 		{
       
   143 		// delegate to strategy	
       
   144 		Strategy(iStrategyId).CancelAsyncRequest(*this);
       
   145 		}
       
   146 	iStrategyStep = MEtelDriverStrategy::EFinishStep;
       
   147 	SPUDTELVERBOSE_INFO_LOG(_L("Strategy is cancelled"));
       
   148 	}
       
   149 
       
   150 /** accessor */
       
   151 const TName& CEtelDriverContext::ExistingContextName() const 
       
   152 	{ 
       
   153    	SPUDTEL_FNLOG("CEtelDriverContext::ExistingContextName()");
       
   154 	for (TContextId i = 0; i < static_cast<TContextId>(iFactory.ContextCount()); i++)
       
   155 		{
       
   156         
       
   157 		if (iFactory.HasContext(i) && iFactory.Context(i).Name().Size())
       
   158 			{
       
   159 			return iFactory.Context(i).Name(); 
       
   160 			}
       
   161 		}
       
   162 		
       
   163 	// Unacceptable situation: we didn't create a single context yet
       
   164 	SPUDTEL_ERROR_LOG(_L("CEtelDriverContext::ExistingContextName - can't find existing context. return %S"), &iFactory.Context(0).Name());
       
   165 	ASSERT(EFalse);
       
   166 	return iFactory.Context(0).Name(); 
       
   167 	}
       
   168 
       
   169 /** accessor 
       
   170 
       
   171 @return reference to etel RPhone
       
   172 */
       
   173 RPhone& CEtelDriverContext::Phone() const
       
   174 	{ 
       
   175 	return iFactory.Phone(); 
       
   176 	}
       
   177 
       
   178 /** accessor 
       
   179 
       
   180 @return reference to etel RPacketService
       
   181 */
       
   182 RPacketService& CEtelDriverContext::PacketService() const
       
   183 	{ 
       
   184 	return iFactory.PacketService(); 
       
   185 	}
       
   186 
       
   187 /** accessor 
       
   188 
       
   189 @return reference to etel driver strategy
       
   190 */
       
   191 MEtelDriverStrategy& CEtelDriverContext::Strategy(TEtelDriverStrategy aId) const
       
   192 	{ 
       
   193 	return iFactory.Strategy(aId); 
       
   194 	}
       
   195 
       
   196 /** accessor 
       
   197 
       
   198 @return reference to pdp fsm interface
       
   199 */
       
   200 CPdpFsmInterface& CEtelDriverContext::PdpFsmInterface() const
       
   201 	{ 
       
   202 	return iFactory.PdpFsmInterface(); 
       
   203 	}
       
   204 
       
   205 /** start pdp notifications */
       
   206 void CEtelDriverContext::StartNotifications() const
       
   207 	{ 
       
   208 	iFactory.StartPdpNotifications(iId); 
       
   209 	}
       
   210 
       
   211 /** stops pdp notifications */
       
   212 void CEtelDriverContext::StopNotifications() const
       
   213 	{ 
       
   214 	iFactory.CancelPdpNotifications(iId); 
       
   215 	}
       
   216 
       
   217 void CEtelDriverContext::PdpStatusChangeNotifierCancel()
       
   218     {
       
   219     iFactory.PdpStatusChangeNotifierCancel(iId);
       
   220     }
       
   221 
       
   222 void CEtelDriverContext::QoSChangeNotifierCancel()
       
   223     {
       
   224     iFactory.QoSChangeNotifierCancel(iId);
       
   225     }
       
   226 
       
   227 void CEtelDriverContext::PdpConfigChangeNotifierCancel()
       
   228     {
       
   229     iFactory.PdpConfigChangeNotifierCancel(iId);
       
   230     }
       
   231 
       
   232 #ifdef _DEBUG
       
   233 void CEtelDriverContext::DumpReqProfileParameters ()
       
   234     {
       
   235     SPUDTEL_INFO_LOG1( _L("Requested Profile Parameters Dump - Context Id = %d"), Id());
       
   236     SPUDTEL_INFO_LOG( _L("==========================================================="));
       
   237     SPUDTEL_INFO_LOG1( _L("ExtensionId = %d"), iQosRequested.ExtensionId());
       
   238     
       
   239     if (iQosRequested.ExtensionId() != TPacketDataConfigBase::KConfigRel99Rel4
       
   240         && iQosRequested.ExtensionId() != TPacketDataConfigBase::KConfigRel5)
       
   241         {
       
   242         SPUDTEL_INFO_LOG( _L("Invalid/Unsupported ExtensionId"));
       
   243         return;
       
   244         }
       
   245 
       
   246     if (iQosRequested.ExtensionId() == TPacketDataConfigBase::KConfigRel99Rel4
       
   247         || iQosRequested.ExtensionId() == TPacketDataConfigBase::KConfigRel5)
       
   248         {
       
   249         SPUDTEL_INFO_LOG1( _L("[1]iReqTrafficClass = %d"), iQosRequested.RequestedQoSR99_R4().iReqTrafficClass);
       
   250         SPUDTEL_INFO_LOG1( _L("[2]iMinTrafficClass = %d"), iQosRequested.RequestedQoSR99_R4().iMinTrafficClass);
       
   251         SPUDTEL_INFO_LOG1( _L("[3]iReqDeliveryOrderReqd = %d"), iQosRequested.RequestedQoSR99_R4().iReqDeliveryOrderReqd);
       
   252         SPUDTEL_INFO_LOG1( _L("[4]iMinDeliveryOrderReqd = %d"), iQosRequested.RequestedQoSR99_R4().iMinDeliveryOrderReqd);
       
   253         SPUDTEL_INFO_LOG1( _L("[5]iReqDeliverErroneousSDU = %d"), iQosRequested.RequestedQoSR99_R4().iReqDeliverErroneousSDU);
       
   254         SPUDTEL_INFO_LOG1( _L("[6]iMinDeliverErroneousSDU = %d"), iQosRequested.RequestedQoSR99_R4().iMinDeliverErroneousSDU);
       
   255         SPUDTEL_INFO_LOG1( _L("[7]iReqMaxSDUSize = %d"), iQosRequested.RequestedQoSR99_R4().iReqMaxSDUSize);
       
   256         SPUDTEL_INFO_LOG1( _L("[8]iMinAcceptableMaxSDUSize = %d"), iQosRequested.RequestedQoSR99_R4().iMinAcceptableMaxSDUSize);
       
   257         SPUDTEL_INFO_LOG1( _L("[9]iReqMaxRate.iUplinkRate = %d"), iQosRequested.RequestedQoSR99_R4().iReqMaxRate.iUplinkRate);
       
   258         SPUDTEL_INFO_LOG1( _L("[10]iReqMaxRate.iDownlinkRate = %d"), iQosRequested.RequestedQoSR99_R4().iReqMaxRate.iDownlinkRate);
       
   259         SPUDTEL_INFO_LOG1( _L("[11]iMinAcceptableMaxRate.iUplinkRate = %d"), iQosRequested.RequestedQoSR99_R4().iMinAcceptableMaxRate.iUplinkRate);
       
   260         SPUDTEL_INFO_LOG1( _L("[12]iMinAcceptableMaxRate.iDownlinkRate = %d"), iQosRequested.RequestedQoSR99_R4().iMinAcceptableMaxRate.iDownlinkRate);
       
   261         SPUDTEL_INFO_LOG1( _L("[13]iReqBER = %d"), iQosRequested.RequestedQoSR99_R4().iReqBER);
       
   262         SPUDTEL_INFO_LOG1( _L("[14]iMaxBER = %d"), iQosRequested.RequestedQoSR99_R4().iMaxBER);
       
   263         SPUDTEL_INFO_LOG1( _L("[15]iReqSDUErrorRatio = %d"), iQosRequested.RequestedQoSR99_R4().iReqSDUErrorRatio);
       
   264         SPUDTEL_INFO_LOG1( _L("[16]iMaxSDUErrorRatio = %d"), iQosRequested.RequestedQoSR99_R4().iMaxSDUErrorRatio);
       
   265         SPUDTEL_INFO_LOG1( _L("[17]iReqTrafficHandlingPriority = %d"), iQosRequested.RequestedQoSR99_R4().iReqTrafficHandlingPriority);
       
   266         SPUDTEL_INFO_LOG1( _L("[18]iReqTrafficHandlingPriority = %d"), iQosRequested.RequestedQoSR99_R4().iMinTrafficHandlingPriority);
       
   267         SPUDTEL_INFO_LOG1( _L("[19]iReqTransferDelay = %d"), iQosRequested.RequestedQoSR99_R4().iReqTransferDelay);
       
   268         SPUDTEL_INFO_LOG1( _L("[20]iMaxTransferDelay = %d"), iQosRequested.RequestedQoSR99_R4().iMaxTransferDelay);
       
   269         SPUDTEL_INFO_LOG1( _L("[21]iReqGuaranteedRate.iUplinkRate = %d"), iQosRequested.RequestedQoSR99_R4().iReqGuaranteedRate.iUplinkRate);
       
   270         SPUDTEL_INFO_LOG1( _L("[22]iReqGuaranteedRate.iDownlinkRate = %d"), iQosRequested.RequestedQoSR99_R4().iReqGuaranteedRate.iDownlinkRate);
       
   271         SPUDTEL_INFO_LOG1( _L("[23]iMinGuaranteedRate.iUplinkRate = %d"), iQosRequested.RequestedQoSR99_R4().iMinGuaranteedRate.iUplinkRate);
       
   272         SPUDTEL_INFO_LOG1( _L("[24]iMinGuaranteedRate.iDownlinkRate = %d"), iQosRequested.RequestedQoSR99_R4().iMinGuaranteedRate.iDownlinkRate);
       
   273         }
       
   274     
       
   275 #ifdef SYMBIAN_NETWORKING_UMTSR5
       
   276     if (iQosRequested.ExtensionId() == TPacketDataConfigBase::KConfigRel5)
       
   277         {
       
   278         SPUDTEL_INFO_LOG1( _L("[25]iSignallingIndication = %d"), iQosRequested.RequestedQoSR5().iSignallingIndication);
       
   279         SPUDTEL_INFO_LOG1( _L("[26]iSourceStatisticsDescriptor = %d"), iQosRequested.RequestedQoSR5().iSourceStatisticsDescriptor);
       
   280         }
       
   281 #endif        
       
   282     }
       
   283 
       
   284 
       
   285 
       
   286 void CEtelDriverContext::DumpNegProfileParameters ()
       
   287     {
       
   288     SPUDTEL_INFO_LOG1( _L("Negotiated Profile Parameters Dump - Context Id = %d"), Id());
       
   289     SPUDTEL_INFO_LOG( _L("==========================================================="));
       
   290     SPUDTEL_INFO_LOG1( _L("ExtensionId = %d"), iQosNegotiated.ExtensionId());
       
   291     
       
   292     if (iQosNegotiated.ExtensionId() != TPacketDataConfigBase::KConfigRel99Rel4
       
   293         && iQosNegotiated.ExtensionId() != TPacketDataConfigBase::KConfigRel5)
       
   294         {
       
   295         SPUDTEL_INFO_LOG( _L("Invalid/Unsupported ExtensionId"));
       
   296         return;
       
   297         }
       
   298 
       
   299     if (iQosNegotiated.ExtensionId() == TPacketDataConfigBase::KConfigRel99Rel4
       
   300         || iQosNegotiated.ExtensionId() == TPacketDataConfigBase::KConfigRel5)
       
   301         {
       
   302         SPUDTEL_INFO_LOG1( _L("[2]iTrafficClass = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iTrafficClass);
       
   303         SPUDTEL_INFO_LOG1( _L("[3]iDeliveryOrderReqd = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iDeliveryOrderReqd);
       
   304         SPUDTEL_INFO_LOG1( _L("[4]iDeliverErroneousSDU = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iDeliverErroneousSDU);
       
   305         SPUDTEL_INFO_LOG1( _L("[5]iMaxSDUSize = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iMaxSDUSize);
       
   306         SPUDTEL_INFO_LOG1( _L("[6]iBER = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iBER);
       
   307         SPUDTEL_INFO_LOG1( _L("[7]iSDUErrorRatio = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iSDUErrorRatio);
       
   308         SPUDTEL_INFO_LOG1( _L("[8]iTrafficHandlingPriority = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iTrafficHandlingPriority);
       
   309         SPUDTEL_INFO_LOG1( _L("[9]iTransferDelay = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iTransferDelay);
       
   310         SPUDTEL_INFO_LOG1( _L("[10]iGuaranteedRate.iUplinkRate = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iGuaranteedRate.iUplinkRate);
       
   311         SPUDTEL_INFO_LOG1( _L("[11]iGuaranteedRate.iDownlinkRate = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iGuaranteedRate.iDownlinkRate);
       
   312         SPUDTEL_INFO_LOG1( _L("[12]iMaxRate.iUplinkRate = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iMaxRate.iUplinkRate);
       
   313         SPUDTEL_INFO_LOG1( _L("[13]iMaxRate.iDownlinkRate = %d"), iQosNegotiated.NegotiatedQoSR99_R4().iMaxRate.iDownlinkRate);
       
   314         }
       
   315 
       
   316     
       
   317 #ifdef SYMBIAN_NETWORKING_UMTSR5
       
   318     if (iQosNegotiated.ExtensionId() == TPacketDataConfigBase::KConfigRel5)
       
   319         {
       
   320         SPUDTEL_INFO_LOG1( _L("[14]iSignallingIndication = %d"), iQosNegotiated.NegotiatedQoSR5().iSignallingIndication);
       
   321         SPUDTEL_INFO_LOG1( _L("[15]iSourceStatisticsDescriptor = %d"), iQosNegotiated.NegotiatedQoSR5().iSourceStatisticsDescriptor);
       
   322         }
       
   323 #endif
       
   324     }
       
   325     
       
   326 #endif
       
   327 // _DEBUG