24
|
1 |
// Copyright (c) 2007-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 |
//
|
|
15 |
|
|
16 |
#include "CSimIncomingContextManager.h"
|
|
17 |
|
|
18 |
#include <testconfigfileparser.h>
|
|
19 |
|
|
20 |
#include "SimConstants.h"
|
|
21 |
#include "Simlog.h"
|
|
22 |
#include "SimTsy.h"
|
|
23 |
#include "CSimPhone.h"
|
|
24 |
#include "csimtimer.h"
|
|
25 |
#include "CSimPacketService.h"
|
|
26 |
|
|
27 |
|
|
28 |
#include "CSimContextHelper.h"
|
|
29 |
|
|
30 |
|
|
31 |
CSimIncomingContextManager::CSimIncomingContextManager(CSimPhone* aPhone) :
|
|
32 |
iPhone(aPhone)
|
|
33 |
{
|
|
34 |
|
|
35 |
}
|
|
36 |
|
|
37 |
CSimIncomingContextManager::~CSimIncomingContextManager()
|
|
38 |
{
|
|
39 |
|
|
40 |
delete iForceIncomingContextChange;
|
|
41 |
|
|
42 |
if (iTimer != NULL)
|
|
43 |
{
|
|
44 |
iTimer->Cancel();
|
|
45 |
delete iTimer;
|
|
46 |
}
|
|
47 |
|
|
48 |
if (iIncomingContextConfigParams != NULL)
|
|
49 |
{
|
|
50 |
iIncomingContextConfigParams->Delete(0, iIncomingContextConfigParams->Count());
|
|
51 |
delete iIncomingContextConfigParams;
|
|
52 |
}
|
|
53 |
|
|
54 |
if (iDelayIncomingContext != NULL)
|
|
55 |
{
|
|
56 |
iDelayIncomingContext->Delete(0, iDelayIncomingContext->Count());
|
|
57 |
delete iDelayIncomingContext;
|
|
58 |
}
|
|
59 |
}
|
|
60 |
|
|
61 |
CSimIncomingContextManager* CSimIncomingContextManager::NewL(CSimPhone* aPhone, CSimPacketService* aSimPacketService)
|
|
62 |
{
|
|
63 |
CSimIncomingContextManager* delayIncomingContextManager=new(ELeave) CSimIncomingContextManager(aPhone);
|
|
64 |
CleanupStack::PushL(delayIncomingContextManager);
|
|
65 |
delayIncomingContextManager->ConstructL(aSimPacketService);
|
|
66 |
CleanupStack::Pop();
|
|
67 |
return delayIncomingContextManager;
|
|
68 |
}
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
void CSimIncomingContextManager::ConstructL(CSimPacketService* aSimPacketService)
|
|
73 |
/**
|
|
74 |
* Second phase of the 2-phase constructor.
|
|
75 |
* Constructs all the member data and retrieves all the data from the config file specific to this class.
|
|
76 |
*
|
|
77 |
* @leave Leaves no memory or any data member does not construct for any reason.
|
|
78 |
*/
|
|
79 |
{
|
|
80 |
LOGPACKET1("CSimIncomingContextManager: Entered ConstructL()");
|
|
81 |
|
|
82 |
iSimPacketService = aSimPacketService;
|
|
83 |
|
|
84 |
iDelayIncomingContext=new(ELeave) CArrayFixFlat<TDelayIncomingContext>(KMaxNumberofConfigsChanges);
|
|
85 |
iCurrentDelayIndex=0;
|
|
86 |
|
|
87 |
iTimer=CSimTimer::NewL(iPhone);
|
|
88 |
|
|
89 |
iIncomingContextConfigParams = new (ELeave) CArrayFixFlat<TContextConfigParam>(KNumberofConfigs);
|
|
90 |
|
|
91 |
CSimContextHelper::GetContextConfigParamSettingsL( CfgFile(), KSetContextConfigGPRS(),
|
|
92 |
iIncomingContextConfigParams );
|
|
93 |
CSimContextHelper::GetContextConfigParamSettingsL( CfgFile(), KSetContextConfigRel99(),
|
|
94 |
iIncomingContextConfigParams );
|
|
95 |
CSimContextHelper::GetContextConfigParamSettingsL( CfgFile(), KSetContextConfigRel5(),
|
|
96 |
iIncomingContextConfigParams );
|
|
97 |
|
|
98 |
iForceIncomingContextChangeProperty=CSimPubSub::TPubSubProperty(KUidPSSimTsyCategory, KPSSimTsyForceIncomingContextActivation, KPSSimTsyForceIncomingContextActivationType);
|
|
99 |
iForceIncomingContextChange = CSimPubSub::NewL(iSimPacketService, iForceIncomingContextChangeProperty);
|
|
100 |
iForceIncomingContextChange->Start();
|
|
101 |
}
|
|
102 |
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Read in the incomming PDP delay contexts.
|
|
106 |
* The format of the command is
|
|
107 |
* DelayIncomingContext = Type , Index, Delay
|
|
108 |
* Type can be
|
|
109 |
* TPacketDataConfigBase::KConfigGPRS= 0x01
|
|
110 |
|
|
111 |
* TPacketDataConfigBase::KConfigRel99Rel4= 0x03
|
|
112 |
* TPacketDataConfigBase::KConfigRel5= 0x04
|
|
113 |
*
|
|
114 |
* Index
|
|
115 |
* This the index for the ContextPDP.
|
|
116 |
* All the ContextPDP are grouped by type (i.e. GPRS.)
|
|
117 |
* So
|
|
118 |
* DelayIncomingContext = 1 , 2, 20
|
|
119 |
* points to the PDP context which is GPRS (1), and 2 in the list.
|
|
120 |
* Delay
|
|
121 |
* How long before the simulated incoming PDP becomes active.
|
|
122 |
*
|
|
123 |
* Stick to general theme of error detection of just make a note and keep going.
|
|
124 |
* Note only GPRS has been currently tested.
|
|
125 |
*/
|
|
126 |
|
|
127 |
void CSimIncomingContextManager::LoadIncomingContextsL( TPtrC8 aTag )
|
|
128 |
{
|
|
129 |
LOGPACKET1("CSimIncomingContextManager: Entered LoadIncomingContextsL()");
|
|
130 |
|
|
131 |
TDelayIncomingContext incomingContext;
|
|
132 |
TInt error=KErrNone;
|
|
133 |
|
|
134 |
TInt count = CfgFile()->ItemCount(aTag);
|
|
135 |
|
|
136 |
for(TInt i=0;i<count;i++)
|
|
137 |
{
|
|
138 |
const CTestConfigItem* item = CfgFile()->Item(aTag,i);
|
|
139 |
if(!item)
|
|
140 |
{
|
|
141 |
error = KErrArgument;
|
|
142 |
LOGPARSERR("DelayIncomingContext::No parameters in tag",error,0,&aTag);
|
|
143 |
break;
|
|
144 |
}
|
|
145 |
|
|
146 |
GetConfigType( (*item), 0, incomingContext.iExtensionId, error );
|
|
147 |
if (error)
|
|
148 |
{
|
|
149 |
LOGPARSERR("DelayIncomingContext::ConfigType",error,0,&aTag);
|
|
150 |
}
|
|
151 |
GetContextIndex( (*item), 1, incomingContext.iIndex, error );
|
|
152 |
if (error)
|
|
153 |
{
|
|
154 |
LOGPARSERR("DelayIncomingContext::Index",error,0,&aTag);
|
|
155 |
}
|
|
156 |
GetDelay( (*item), 2, incomingContext.iDelay, error );
|
|
157 |
if (error)
|
|
158 |
{
|
|
159 |
LOGPARSERR("DelayIncomingContext::Delay",error,0,&aTag);
|
|
160 |
}
|
|
161 |
|
|
162 |
iDelayIncomingContext->AppendL(incomingContext);
|
|
163 |
|
|
164 |
}
|
|
165 |
|
|
166 |
LOGMISC2("Finished parsing DelayIncomingContext config parameters...%d items found",count);
|
|
167 |
}
|
|
168 |
|
|
169 |
|
|
170 |
void CSimIncomingContextManager::StartFirstIncomingEvent( )
|
|
171 |
{
|
|
172 |
LOGPACKET1("CSimIncomingContextManager: Entered StartFirstIncomingEvent()" );
|
|
173 |
|
|
174 |
if(iDelayIncomingContext->Count()!=0)
|
|
175 |
{
|
|
176 |
iCurrentDelayIndex = 0;
|
|
177 |
const TDelayIncomingContext& delayIncomingContext = iDelayIncomingContext->At(0);
|
|
178 |
LOGPACKET2("CSimIncomingContextManager: Entered StartFirstIncomingEvent() delay = %d", delayIncomingContext.iDelay);
|
|
179 |
iTimer->Start(delayIncomingContext.iDelay, iSimPacketService, ETimerIdContextActivationRequestedChange);
|
|
180 |
}
|
|
181 |
}
|
|
182 |
|
|
183 |
|
|
184 |
// This sets up the aPckg according to the current delay index.
|
|
185 |
// And then sets the index
|
|
186 |
void CSimIncomingContextManager::NextIncomingEvent( TDes8* aPckg )
|
|
187 |
{
|
|
188 |
LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent()" );
|
|
189 |
|
|
190 |
if (iDelayIncomingContext->Count()==0)
|
|
191 |
{ // We have no incoming events. This is an error.
|
|
192 |
LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent() No events at all!" );
|
|
193 |
SimPanic(EGeneral);
|
|
194 |
return;
|
|
195 |
}
|
|
196 |
if(iCurrentDelayIndex >= iDelayIncomingContext->Count())
|
|
197 |
{ // No more incoming contexts. .
|
|
198 |
LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent() No next event" );
|
|
199 |
return;
|
|
200 |
}
|
|
201 |
// else we have an incoming context.
|
|
202 |
|
|
203 |
const TDelayIncomingContext* delayIncomingContext =
|
|
204 |
&(iDelayIncomingContext->At(iCurrentDelayIndex));
|
|
205 |
|
|
206 |
// Lets deal with the incoming first.
|
|
207 |
const TContextConfigParam* context = FindContext( iIncomingContextConfigParams,
|
|
208 |
delayIncomingContext->iExtensionId, delayIncomingContext->iIndex );
|
|
209 |
if ( !context )
|
|
210 |
{ // Unable to find a valid pre allocated context that we can use.
|
|
211 |
LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent() failed unable to identify a valid context." );
|
|
212 |
SimPanic(EGeneral);
|
|
213 |
return ;
|
|
214 |
}
|
|
215 |
|
|
216 |
if ( GetContextInCorrectFormatForEtel(context, aPckg) )
|
|
217 |
{ // Okay got data. This will be sent to ETEL to activate the context.
|
|
218 |
LOGPACKET2("CSimIncomingContextManager: Entered NextIncomingEventt() delay = %d", delayIncomingContext->iDelay);
|
|
219 |
}
|
|
220 |
else
|
|
221 |
{ // Error. Unable to format the data.
|
|
222 |
LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent() failed unable format data for choosn context" );
|
|
223 |
SimPanic(EGeneral);
|
|
224 |
return;
|
|
225 |
}
|
|
226 |
|
|
227 |
// Set up for next event.
|
|
228 |
if(iCurrentDelayIndex < iDelayIncomingContext->Count())
|
|
229 |
{
|
|
230 |
iCurrentDelayIndex++;
|
|
231 |
}
|
|
232 |
|
|
233 |
}
|
|
234 |
|
|
235 |
|
|
236 |
void CSimIncomingContextManager::Cancel( )
|
|
237 |
{
|
|
238 |
LOGPACKET1("CSimIncomingContextManager::Cancel called");
|
|
239 |
iTimer->Cancel();
|
|
240 |
}
|
|
241 |
|
|
242 |
|
|
243 |
void CSimIncomingContextManager::ForcedIncoming(TInt aIndex, TDes8* aPckg )
|
|
244 |
{
|
|
245 |
LOGPACKET1("CSimIncomingContextManager::ForcedIncoming called");
|
|
246 |
|
|
247 |
if(iDelayIncomingContext->Count()<=aIndex )
|
|
248 |
{
|
|
249 |
LOGPACKET1("CSimIncomingContextManager::ForcedIncoming invalid context");
|
|
250 |
return;
|
|
251 |
}
|
|
252 |
// else we have a valid incoming context.
|
|
253 |
|
|
254 |
const TDelayIncomingContext* delayIncomingContext =
|
|
255 |
&(iDelayIncomingContext->At(aIndex));
|
|
256 |
// Note we will do use (type, index) to detmine which context to use.
|
|
257 |
// We would have difficultly with pdp context index, as they grouped by type.
|
|
258 |
// This is consistant with how we do it for timers.
|
|
259 |
|
|
260 |
const TContextConfigParam* context = FindContext( iIncomingContextConfigParams,
|
|
261 |
delayIncomingContext->iExtensionId, delayIncomingContext->iIndex );
|
|
262 |
|
|
263 |
if ( !context )
|
|
264 |
{ // Unable to find a valid pre allocated context that we can use.
|
|
265 |
LOGPACKET1("CSimIncomingContextManager::ForcedIncoming invalid type, index leading to invalid context");
|
|
266 |
SimPanic(EGeneral);
|
|
267 |
return ;
|
|
268 |
}
|
|
269 |
|
|
270 |
if ( GetContextInCorrectFormatForEtel(context, aPckg) )
|
|
271 |
{ // Okay got data. This will be sent to ETEL to activate the context.
|
|
272 |
}
|
|
273 |
else
|
|
274 |
{ // Error. Unable to format the data.
|
|
275 |
LOGPACKET1("CSimIncomingContextManager: Entered NextIncomingEvent() failed unable format data for choosn context" );
|
|
276 |
SimPanic(EGeneral);
|
|
277 |
return;
|
|
278 |
}
|
|
279 |
|
|
280 |
iTimer->Cancel();
|
|
281 |
// No more timer.
|
|
282 |
|
|
283 |
}
|
|
284 |
|
|
285 |
TBool CSimIncomingContextManager::IsForcedIncoming(const CSimPubSub::TPubSubProperty aProperty )
|
|
286 |
{
|
|
287 |
TBool ret = (aProperty == iForceIncomingContextChangeProperty);
|
|
288 |
return ret;
|
|
289 |
}
|
|
290 |
|
|
291 |
|
|
292 |
void CSimIncomingContextManager::GetConfigType( const CTestConfigItem& aItem ,
|
|
293 |
TInt aIndex, TInt& aType, TInt& aError )
|
|
294 |
{
|
|
295 |
|
|
296 |
aError = KErrNone;
|
|
297 |
aType = TPacketDataConfigBase::KConfigGPRS;
|
|
298 |
// Have a default value even if error.
|
|
299 |
|
|
300 |
|
|
301 |
TInt ret=CTestConfig::GetElement(aItem.Value(),KStdDelimiter,aIndex,aType);
|
|
302 |
if(ret!=KErrNone)
|
|
303 |
{
|
|
304 |
aError=KErrArgument;
|
|
305 |
}
|
|
306 |
else
|
|
307 |
{
|
|
308 |
if ( (1 <= aType) && ( aType <= TPacketDataConfigBase::KConfigRel5 ) )
|
|
309 |
{ //Okay we have a valid type.
|
|
310 |
}
|
|
311 |
else
|
|
312 |
{ // Else not one of the recognised types.
|
|
313 |
aError=KErrOverflow;
|
|
314 |
}
|
|
315 |
}
|
|
316 |
}
|
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
void CSimIncomingContextManager::GetContextIndex( const CTestConfigItem& aItem,
|
|
321 |
TInt aIndex, TInt& aContextIndex, TInt& aError )
|
|
322 |
{
|
|
323 |
|
|
324 |
aError = KErrNone;
|
|
325 |
aContextIndex = 0;
|
|
326 |
|
|
327 |
TInt ret=CTestConfig::GetElement(aItem.Value(),KStdDelimiter,aIndex,aContextIndex);
|
|
328 |
if(ret!=KErrNone)
|
|
329 |
{
|
|
330 |
aError=KErrArgument;
|
|
331 |
}
|
|
332 |
}
|
|
333 |
|
|
334 |
|
|
335 |
|
|
336 |
void CSimIncomingContextManager::GetDelay( const CTestConfigItem& aItem,
|
|
337 |
TInt aIndex, TInt& aDelay, TInt& aError )
|
|
338 |
{
|
|
339 |
|
|
340 |
aError = KErrNone;
|
|
341 |
aDelay = 1;
|
|
342 |
|
|
343 |
TInt ret=CTestConfig::GetElement(aItem.Value(),KStdDelimiter,aIndex,aDelay);
|
|
344 |
if(ret!=KErrNone)
|
|
345 |
{
|
|
346 |
aError=KErrArgument;
|
|
347 |
}
|
|
348 |
|
|
349 |
}
|
|
350 |
|
|
351 |
|
|
352 |
|
|
353 |
const TContextConfigParam* CSimIncomingContextManager::FindContext( const CArrayFixFlat<TContextConfigParam>* aIncomingContextConfigParams,
|
|
354 |
const TInt aExtensionId, const TInt aIndex )
|
|
355 |
{
|
|
356 |
__ASSERT_ALWAYS(aIncomingContextConfigParams, SimPanic(EIllegalNullPtrParameter));
|
|
357 |
|
|
358 |
const TContextConfigParam* ret=NULL;
|
|
359 |
TInt incomingConfigIndex=0;
|
|
360 |
|
|
361 |
for(TInt index=0; index < aIncomingContextConfigParams->Count(); index++)
|
|
362 |
{
|
|
363 |
const TContextConfigParam& thisConfig = aIncomingContextConfigParams->At(index);
|
|
364 |
|
|
365 |
if ( thisConfig.iProtocolType == aExtensionId )
|
|
366 |
{
|
|
367 |
if ( aIndex==incomingConfigIndex )
|
|
368 |
{ // We have found the context.
|
|
369 |
ret=&(thisConfig);
|
|
370 |
break;
|
|
371 |
}
|
|
372 |
|
|
373 |
incomingConfigIndex++;
|
|
374 |
// Only gets incremented for aExtensionId ids we are looking for.
|
|
375 |
}
|
|
376 |
}
|
|
377 |
// if ret = 0 then we could not find the context.
|
|
378 |
// This may or may not be an error, depending on usage.
|
|
379 |
|
|
380 |
return ret;
|
|
381 |
}
|
|
382 |
|
|
383 |
|
|
384 |
|
|
385 |
TBool CSimIncomingContextManager::GetContextInCorrectFormatForEtel(const TContextConfigParam* aContextConfig,
|
|
386 |
TDes8* aData)
|
|
387 |
{
|
|
388 |
|
|
389 |
if (!aContextConfig)
|
|
390 |
{ // Has no context.
|
|
391 |
return EFalse;
|
|
392 |
}
|
|
393 |
else if (aContextConfig->iProtocolType == TPacketDataConfigBase::KConfigGPRS)
|
|
394 |
{
|
|
395 |
TPckg<RPacketContext::TContextConfigGPRS>& contextConfigGPRSPckg = *( (TPckg<RPacketContext::TContextConfigGPRS>*)aData );
|
|
396 |
RPacketContext::TContextConfigGPRS& contextConfigGPRS = (contextConfigGPRSPckg)();
|
|
397 |
CSimContextHelper::ConvertConfigParams( (*aContextConfig), contextConfigGPRS );
|
|
398 |
return ETrue;
|
|
399 |
}
|
|
400 |
|
|
401 |
#if 0 // Note some may be in a totally different table.
|
|
402 |
else if (aContextConfig->iProtocolType == TPacketDataConfigBase::KConfigRel99Rel4)
|
|
403 |
{
|
|
404 |
|
|
405 |
//ConvertConfigParams(const TContextConfigParam& aInput, RPacketContext::TContextConfigGPRS& aOutput);
|
|
406 |
return ETrue;
|
|
407 |
}
|
|
408 |
else if (aContextConfig->iProtocolType == TPacketDataConfigBase::KConfigRel5)
|
|
409 |
{
|
|
410 |
|
|
411 |
//ConvertConfigParams(const TContextConfigParam& aInput, RPacketContext::TContextConfigGPRS& aOutput);
|
|
412 |
return ETrue;
|
|
413 |
}
|
|
414 |
#endif
|
|
415 |
|
|
416 |
return EFalse;
|
|
417 |
}
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
/**
|
|
423 |
* Returns a pointer to the current configuration file section.
|
|
424 |
*
|
|
425 |
* @return CTestConfigSection A pointer to the current configuration file section.
|
|
426 |
*/
|
|
427 |
const CTestConfigSection* CSimIncomingContextManager::CfgFile()
|
|
428 |
{
|
|
429 |
return iPhone->CfgFile();
|
|
430 |
}
|
|
431 |
|