telephonyserverplugins/simtsy/src/CSimIncomingContextManager.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-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".
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 
    15 
       
    16 
       
    17 
       
    18 #include "OstTraceDefinitions.h"
       
    19 #ifdef OST_TRACE_COMPILER_IN_USE
       
    20 #include "CSimIncomingContextManagerTraces.h"
       
    21 #endif
       
    22 
    16 #include "CSimIncomingContextManager.h"
    23 #include "CSimIncomingContextManager.h"
    17 
    24 
    18 #include <testconfigfileparser.h>
    25 #include <testconfigfileparser.h>
    19 
    26 
    20 #include "SimConstants.h"
    27 #include "SimConstants.h"
    21 #include "Simlog.h"
       
    22 #include "SimTsy.h"
    28 #include "SimTsy.h"
    23 #include "CSimPhone.h"
    29 #include "CSimPhone.h"
    24 #include "csimtimer.h"
    30 #include "csimtimer.h"
    25 #include "CSimPacketService.h"
    31 #include "CSimPacketService.h"
    26 
    32 
    75 * Constructs all the member data and retrieves all the data from the config file specific to this class.
    81 * Constructs all the member data and retrieves all the data from the config file specific to this class.
    76 *
    82 *
    77 * @leave Leaves no memory or any data member does not construct for any reason.
    83 * @leave Leaves no memory or any data member does not construct for any reason.
    78 */
    84 */
    79 	{	
    85 	{	
    80 	LOGPACKET1("CSimIncomingContextManager: Entered ConstructL()");
    86 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_CONSTRUCTL_1, "CSimIncomingContextManager: Entered ConstructL()");
    81 	
    87 	
    82 	iSimPacketService = aSimPacketService;
    88 	iSimPacketService = aSimPacketService;
    83 		
    89 		
    84 	iDelayIncomingContext=new(ELeave) CArrayFixFlat<TDelayIncomingContext>(KMaxNumberofConfigsChanges);
    90 	iDelayIncomingContext=new(ELeave) CArrayFixFlat<TDelayIncomingContext>(KMaxNumberofConfigsChanges);
    85 	iCurrentDelayIndex=0;
    91 	iCurrentDelayIndex=0;
   124 * Note only GPRS has been currently tested.
   130 * Note only GPRS has been currently tested.
   125 */
   131 */
   126 
   132 
   127 void CSimIncomingContextManager::LoadIncomingContextsL( TPtrC8 aTag )
   133 void CSimIncomingContextManager::LoadIncomingContextsL( TPtrC8 aTag )
   128 	{
   134 	{
   129 	LOGPACKET1("CSimIncomingContextManager: Entered LoadIncomingContextsL()");
   135 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_LOADINCOMINGCONTEXTSL_1, "CSimIncomingContextManager: Entered LoadIncomingContextsL()");
   130 		
   136 		
   131 	TDelayIncomingContext incomingContext;
   137 	TDelayIncomingContext incomingContext;
   132 	TInt error=KErrNone;
   138 	TInt error=KErrNone;
   133 	
   139 	
   134 	TInt count = CfgFile()->ItemCount(aTag);
   140 	TInt count = CfgFile()->ItemCount(aTag);
   137 		{
   143 		{
   138 		const CTestConfigItem* item = CfgFile()->Item(aTag,i);
   144 		const CTestConfigItem* item = CfgFile()->Item(aTag,i);
   139 		if(!item)
   145 		if(!item)
   140 			{
   146 			{
   141 			error = KErrArgument;	
   147 			error = KErrArgument;	
   142 			LOGPARSERR("DelayIncomingContext::No parameters in tag",error,0,&aTag);
   148 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_LOADINCOMINGCONTEXTSL_2, "WARNING - CONFIGURATION FILE PARSING - Reading element DELAYINCOMINGCONTEXT::NO PARAMETERS IN TAG returned %d (element no. %d) from tag %s.",error,0,aTag);
   143 			break;
   149 			break;
   144 			}
   150 			}
   145 		
   151 		
   146 		GetConfigType( (*item), 0, incomingContext.iExtensionId, error );
   152 		GetConfigType( (*item), 0, incomingContext.iExtensionId, error );
   147 		if (error)
   153 		if (error)
   148 			{
   154 			{
   149 			LOGPARSERR("DelayIncomingContext::ConfigType",error,0,&aTag);			
   155 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_LOADINCOMINGCONTEXTSL_3, "WARNING - CONFIGURATION FILE PARSING - Reading element DELAYINCOMINGCONTEXT::CONFIGTYPE returned %d (element no. %d) from tag %s.",error,0,aTag);
   150 			}
   156 			}
   151 		GetContextIndex( (*item), 1, incomingContext.iIndex, error );
   157 		GetContextIndex( (*item), 1, incomingContext.iIndex, error );
   152 		if (error)
   158 		if (error)
   153 			{
   159 			{
   154 			LOGPARSERR("DelayIncomingContext::Index",error,0,&aTag);			
   160 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_LOADINCOMINGCONTEXTSL_4, "WARNING - CONFIGURATION FILE PARSING - Reading element DELAYINCOMINGCONTEXT::INDEX returned %d (element no. %d) from tag %s.",error,0,aTag);
   155 			}
   161 			}
   156 		GetDelay( (*item),  2, incomingContext.iDelay, error );
   162 		GetDelay( (*item),  2, incomingContext.iDelay, error );
   157 		if (error)
   163 		if (error)
   158 			{
   164 			{
   159 			LOGPARSERR("DelayIncomingContext::Delay",error,0,&aTag);			
   165 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_LOADINCOMINGCONTEXTSL_5, "WARNING - CONFIGURATION FILE PARSING - Reading element DELAYINCOMINGCONTEXT::DELAY returned %d (element no. %d) from tag %s.",error,0,aTag);
   160 			}
   166 			}
   161 			
   167 			
   162 		iDelayIncomingContext->AppendL(incomingContext);
   168 		iDelayIncomingContext->AppendL(incomingContext);
   163 						
   169 						
   164 		}		
   170 		}		
   165 	
   171 	
   166 	LOGMISC2("Finished parsing DelayIncomingContext config parameters...%d items found",count);
   172 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_LOADINCOMINGCONTEXTSL_6, "Finished parsing DelayIncomingContext config parameters...%d items found",count);
   167 	}
   173 	}
   168 
   174 
   169 
   175 
   170 void CSimIncomingContextManager::StartFirstIncomingEvent( )
   176 void CSimIncomingContextManager::StartFirstIncomingEvent( )
   171 	{
   177 	{
   172 	LOGPACKET1("CSimIncomingContextManager: Entered StartFirstIncomingEvent()" );
   178 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_STARTFIRSTINCOMINGEVENT_1, "CSimIncomingContextManager: Entered StartFirstIncomingEvent()" );
   173 				
   179 				
   174 	if(iDelayIncomingContext->Count()!=0)
   180 	if(iDelayIncomingContext->Count()!=0)
   175 		{
   181 		{
   176 		iCurrentDelayIndex = 0;				
   182 		iCurrentDelayIndex = 0;				
   177 		const TDelayIncomingContext& delayIncomingContext = iDelayIncomingContext->At(0);
   183 		const TDelayIncomingContext& delayIncomingContext = iDelayIncomingContext->At(0);
   178 		LOGPACKET2("CSimIncomingContextManager: Entered StartFirstIncomingEvent() delay = %d", delayIncomingContext.iDelay);
   184 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_STARTFIRSTINCOMINGEVENT_2, "CSimIncomingContextManager: Entered StartFirstIncomingEvent() delay = %d", delayIncomingContext.iDelay);
   179 		iTimer->Start(delayIncomingContext.iDelay, iSimPacketService, ETimerIdContextActivationRequestedChange);
   185 		iTimer->Start(delayIncomingContext.iDelay, iSimPacketService, ETimerIdContextActivationRequestedChange);
   180 		}	
   186 		}	
   181 	}
   187 	}
   182 
   188 
   183 		
   189 		
   184 // This sets up the aPckg according to the current delay index.
   190 // This sets up the aPckg according to the current delay index.
   185 // And then sets the index	
   191 // And then sets the index	
   186 void CSimIncomingContextManager::NextIncomingEvent( TDes8* aPckg )
   192 void CSimIncomingContextManager::NextIncomingEvent( TDes8* aPckg )
   187 	{
   193 	{
   188 	LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent()" );
   194 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_NEXTINCOMINGEVENT_1, "CSimIncomingContextManager: Entered NextIncomingEvent()" );
   189 	
   195 	
   190 	if (iDelayIncomingContext->Count()==0)
   196 	if (iDelayIncomingContext->Count()==0)
   191 		{ // We have no incoming events. This is an error.
   197 		{ // We have no incoming events. This is an error.
   192 		LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent() No events at all!" );
   198 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_NEXTINCOMINGEVENT_2, "CSimIncomingContextManager: Entered NextIncomingEvent() No events at all!" );
   193 		SimPanic(EGeneral);		
   199 		SimPanic(EGeneral);		
   194 		return;
   200 		return;
   195 		}
   201 		}
   196 	if(iCurrentDelayIndex >= iDelayIncomingContext->Count())
   202 	if(iCurrentDelayIndex >= iDelayIncomingContext->Count())
   197 		{ // No more incoming contexts. .
   203 		{ // No more incoming contexts. .
   198 		LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent() No next event" );
   204 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_NEXTINCOMINGEVENT_3, "CSimIncomingContextManager: Entered NextIncomingEvent() No next event" );
   199 		return;		
   205 		return;		
   200 		}
   206 		}
   201 	// else we have an incoming context.
   207 	// else we have an incoming context.
   202 
   208 
   203 	const TDelayIncomingContext* delayIncomingContext = 
   209 	const TDelayIncomingContext* delayIncomingContext = 
   206 	// Lets deal with the incoming first.	
   212 	// Lets deal with the incoming first.	
   207 	const TContextConfigParam* context = FindContext( iIncomingContextConfigParams, 
   213 	const TContextConfigParam* context = FindContext( iIncomingContextConfigParams, 
   208 		delayIncomingContext->iExtensionId, delayIncomingContext->iIndex );
   214 		delayIncomingContext->iExtensionId, delayIncomingContext->iIndex );
   209 	if ( !context )
   215 	if ( !context )
   210 		{ // Unable to find a valid pre allocated context that we can use.
   216 		{ // Unable to find a valid pre allocated context that we can use.
   211 		LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent() failed unable to identify a valid context." );
   217 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_NEXTINCOMINGEVENT_4, "CSimIncomingContextManager: Entered NextIncomingEvent() failed unable to identify a valid context." );
   212 		SimPanic(EGeneral);		
   218 		SimPanic(EGeneral);		
   213 	  	return ;
   219 	  	return ;
   214 		}
   220 		}
   215 
   221 
   216 	if ( GetContextInCorrectFormatForEtel(context, aPckg) ) 
   222 	if ( GetContextInCorrectFormatForEtel(context, aPckg) ) 
   217 		{ // Okay got data. This will be sent to ETEL to activate the context.
   223 		{ // Okay got data. This will be sent to ETEL to activate the context.
   218 		LOGPACKET2("CSimIncomingContextManager: Entered NextIncomingEventt() delay = %d", delayIncomingContext->iDelay);
   224 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_NEXTINCOMINGEVENT_5, "CSimIncomingContextManager: Entered NextIncomingEventt() delay = %d", delayIncomingContext->iDelay);
   219 		}
   225 		}
   220 	else
   226 	else
   221 		{ // Error. Unable to format the data.
   227 		{ // Error. Unable to format the data.
   222 		LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent() failed unable format data for choosn context" );
   228 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_NEXTINCOMINGEVENT_6, "CSimIncomingContextManager: Entered NextIncomingEvent() failed unable format data for choosn context" );
   223 		SimPanic(EGeneral);		
   229 		SimPanic(EGeneral);		
   224 		return;
   230 		return;
   225 		}
   231 		}
   226 	
   232 	
   227 	// Set up for next event.	
   233 	// Set up for next event.	
   233 	}
   239 	}
   234 	
   240 	
   235 	
   241 	
   236 void CSimIncomingContextManager::Cancel( )
   242 void CSimIncomingContextManager::Cancel( )
   237 	{
   243 	{
   238 	LOGPACKET1("CSimIncomingContextManager::Cancel called");
   244 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_CANCEL_1, "CSimIncomingContextManager::Cancel called");
   239 	iTimer->Cancel();	
   245 	iTimer->Cancel();	
   240 	}
   246 	}
   241 	
   247 	
   242 	
   248 	
   243 void CSimIncomingContextManager::ForcedIncoming(TInt aIndex, TDes8* aPckg )
   249 void CSimIncomingContextManager::ForcedIncoming(TInt aIndex, TDes8* aPckg )
   244 	{
   250 	{
   245 	LOGPACKET1("CSimIncomingContextManager::ForcedIncoming called");
   251 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_FORCEDINCOMING_1, "CSimIncomingContextManager::ForcedIncoming called");
   246 
   252 
   247 	if(iDelayIncomingContext->Count()<=aIndex )
   253 	if(iDelayIncomingContext->Count()<=aIndex )
   248 		{ 
   254 		{ 
   249 		LOGPACKET1("CSimIncomingContextManager::ForcedIncoming invalid context");
   255 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_FORCEDINCOMING_2, "CSimIncomingContextManager::ForcedIncoming invalid context");
   250 		return;		
   256 		return;		
   251 		}
   257 		}
   252 	// else we have a valid incoming context.
   258 	// else we have a valid incoming context.
   253 
   259 
   254 	const TDelayIncomingContext* delayIncomingContext = 
   260 	const TDelayIncomingContext* delayIncomingContext = 
   260 	const TContextConfigParam* context = FindContext( iIncomingContextConfigParams, 
   266 	const TContextConfigParam* context = FindContext( iIncomingContextConfigParams, 
   261 		delayIncomingContext->iExtensionId, delayIncomingContext->iIndex );
   267 		delayIncomingContext->iExtensionId, delayIncomingContext->iIndex );
   262 
   268 
   263 	if ( !context )
   269 	if ( !context )
   264 		{ // Unable to find a valid pre allocated context that we can use.
   270 		{ // Unable to find a valid pre allocated context that we can use.
   265 		LOGPACKET1("CSimIncomingContextManager::ForcedIncoming invalid type, index leading to invalid context");
   271 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_FORCEDINCOMING_3, "CSimIncomingContextManager::ForcedIncoming invalid type, index leading to invalid context");
   266 		SimPanic(EGeneral);
   272 		SimPanic(EGeneral);
   267 	  	return ;
   273 	  	return ;
   268 		}
   274 		}
   269 
   275 
   270 	if ( GetContextInCorrectFormatForEtel(context, aPckg) ) 
   276 	if ( GetContextInCorrectFormatForEtel(context, aPckg) ) 
   271 		{ // Okay got data. This will be sent to ETEL to activate the context.
   277 		{ // Okay got data. This will be sent to ETEL to activate the context.
   272 		}
   278 		}
   273 	else
   279 	else
   274 		{ // Error. Unable to format the data.		
   280 		{ // Error. Unable to format the data.		
   275 		LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent() failed unable format data for choosn context" );
   281 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMINCOMINGCONTEXTMANAGER_FORCEDINCOMING_4, "CSimIncomingContextManager: Entered NextIncomingEvent() failed unable format data for choosn context" );
   276 		SimPanic(EGeneral);		
   282 		SimPanic(EGeneral);		
   277 		return;
   283 		return;
   278 		}
   284 		}
   279 
   285 
   280 	iTimer->Cancel();
   286 	iTimer->Cancel();