telephonyserverplugins/simtsy/src/CSimCallBarring.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2001-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".
    18 
    18 
    19 /**
    19 /**
    20  @file
    20  @file
    21 */
    21 */
    22 
    22 
       
    23 
       
    24 
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "CSimCallBarringTraces.h"
       
    28 #endif
       
    29 
    23 #include <testconfigfileparser.h>
    30 #include <testconfigfileparser.h>
    24 #include "CSimCallBarring.h"
    31 #include "CSimCallBarring.h"
    25 #include "CSimPhone.h"
    32 #include "CSimPhone.h"
    26 #include "Simlog.h"
       
    27 
    33 
    28 // The Mobile Basic Service Groups used - originally were magic numbers from 1 to 6 incl;
    34 // The Mobile Basic Service Groups used - originally were magic numbers from 1 to 6 incl;
    29 const TInt KMobServiceIndxStart = 1;
    35 const TInt KMobServiceIndxStart = 1;
    30 const TInt KMobServiceIndxEnd   = 6;
    36 const TInt KMobServiceIndxEnd   = 6;
    31 
    37 
    57 /**
    63 /**
    58 	Second phase of 2-Phase Constructor
    64 	Second phase of 2-Phase Constructor
    59   	Retrieves all the Call Barring related tags from the config file
    65   	Retrieves all the Call Barring related tags from the config file
    60 */
    66 */
    61 	{
    67 	{
    62 	LOGCALL1("Starting to parse Call Barring config parameters...");
    68 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_CONSTRUCTL_1, "Starting to parse Call Barring config parameters...");
    63 
    69 
    64 	iPassword.Copy(CfgFile()->ItemValue(KCBPassword,KCBDefaultPassword));
    70 	iPassword.Copy(CfgFile()->ItemValue(KCBPassword,KCBDefaultPassword));
    65 
    71 
    66 	iGetCBStatus = new(ELeave) CArrayPtrFlat<CListReadAllAttempt>(1);
    72 	iGetCBStatus = new(ELeave) CArrayPtrFlat<CListReadAllAttempt>(1);
    67 	FindAndCreateCBListL();
    73 	FindAndCreateCBListL();
    68 	LOGCALL1("...Finished parsing Call Barring config parameters...");
    74 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_CONSTRUCTL_2, "...Finished parsing Call Barring config parameters...");
    69 	}
    75 	}
    70 	
    76 	
    71 void CSimCallBarring::FindAndCreateCBListL()
    77 void CSimCallBarring::FindAndCreateCBListL()
    72 {
    78 {
    73 /**
    79 /**
    74   	Retrieves all the Call barring tags that define the 
    80   	Retrieves all the Call barring tags that define the 
    75   	original status of Call barring from the config file
    81   	original status of Call barring from the config file
    76 */
    82 */
    77 	LOGCALL1("CSimPhone::FindAndCreateCBListL");
    83 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_FINDANDCREATECBLISTL_1, "CSimPhone::FindAndCreateCBListL");
    78 	RMobilePhone::TMobilePhoneCBInfoEntryV1 entry;
    84 	RMobilePhone::TMobilePhoneCBInfoEntryV1 entry;
    79 
    85 
    80 	iCBList = CMobilePhoneCBList::NewL();
    86 	iCBList = CMobilePhoneCBList::NewL();
    81 	TInt count=CfgFile()->ItemCount(KCBList);
    87 	TInt count=CfgFile()->ItemCount(KCBList);
    82 	const CTestConfigItem* item=NULL;
    88 	const CTestConfigItem* item=NULL;
    83 	TInt ret=KErrNone;
    89 	TInt ret=KErrNone;
    84 
    90 
    85 	LOGCALL1("Starting to Load and Parse CBList Config parameters");
    91 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_FINDANDCREATECBLISTL_2, "Starting to Load and Parse CBList Config parameters");
    86 	TInt i;
    92 	TInt i;
    87 	for(i=0;i<count;i++)
    93 	for(i=0;i<count;i++)
    88 		{
    94 		{
    89 		item=CfgFile()->Item(KCBList,i);
    95 		item=CfgFile()->Item(KCBList,i);
    90 		if(!item)
    96 		if(!item)
    92 		
    98 		
    93 		TInt condition, serviceGroup, status;
    99 		TInt condition, serviceGroup, status;
    94 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,condition);
   100 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,condition);
    95 		if(ret!=KErrNone)
   101 		if(ret!=KErrNone)
    96 			{
   102 			{
    97 			LOGPARSERR("condition",ret,0,&KCBList);
   103 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_FINDANDCREATECBLISTL_3, "WARNING - CONFIGURATION FILE PARSING - Reading element CONDITION returned %d (element no. %d) from tag %s.",ret,0,KCBList);
    98 			continue;
   104 			continue;
    99 			}
   105 			}
   100 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,serviceGroup);
   106 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,serviceGroup);
   101 		if(ret!=KErrNone)
   107 		if(ret!=KErrNone)
   102 			{
   108 			{
   103 			LOGPARSERR("serviceGroup",ret,1,&KCBList);
   109 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_FINDANDCREATECBLISTL_4, "WARNING - CONFIGURATION FILE PARSING - Reading element SERVICEGROUP returned %d (element no. %d) from tag %s.",ret,1,KCBList);
   104 			continue;
   110 			continue;
   105 			}
   111 			}
   106 
   112 
   107 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,status);
   113 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,status);
   108 		if(ret!=KErrNone)
   114 		if(ret!=KErrNone)
   109 			{
   115 			{
   110 			LOGPARSERR("status",ret,2,&KCBList);
   116 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_FINDANDCREATECBLISTL_5, "WARNING - CONFIGURATION FILE PARSING - Reading element STATUS returned %d (element no. %d) from tag %s.",ret,2,KCBList);
   111 			continue;
   117 			continue;
   112 			}
   118 			}
   113 		
   119 		
   114 		entry.iCondition=(RMobilePhone::TMobilePhoneCBCondition)condition;
   120 		entry.iCondition=(RMobilePhone::TMobilePhoneCBCondition)condition;
   115 		entry.iServiceGroup=(RMobilePhone::TMobileService)serviceGroup;
   121 		entry.iServiceGroup=(RMobilePhone::TMobileService)serviceGroup;
   192   	*/
   198   	*/
   193 	__ASSERT_ALWAYS(!iCBNotification.iCBChangeInfoNotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
   199 	__ASSERT_ALWAYS(!iCBNotification.iCBChangeInfoNotificationPending,SimPanic(ENotificationReqAlreadyOutstanding));
   194 	iCBNotification.iCBChangeInfoNotificationPending=ETrue;
   200 	iCBNotification.iCBChangeInfoNotificationPending=ETrue;
   195 	iCBNotification.iCBChangeInfoReqHandle=aReqHandle;
   201 	iCBNotification.iCBChangeInfoReqHandle=aReqHandle;
   196 	iCBNotification.iCurrentCBCondition=aCB;
   202 	iCBNotification.iCurrentCBCondition=aCB;
   197 	LOGCALL1("Finished CSimCallBarring::NotifyCallBarringStatusChange");
   203 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_NOTIFYCALLBARRINGSTATUSCHANGE_1, "Finished CSimCallBarring::NotifyCallBarringStatusChange");
   198 	return KErrNone;
   204 	return KErrNone;
   199 	}
   205 	}
   200 
   206 
   201 TInt CSimCallBarring::NotifyCallBarringStatusChangeCancel(const TTsyReqHandle aReqHandle)
   207 TInt CSimCallBarring::NotifyCallBarringStatusChangeCancel(const TTsyReqHandle aReqHandle)
   202 	{
   208 	{
   308 	1st phase retrieval of the the call barring status list
   314 	1st phase retrieval of the the call barring status list
   309 	@param aReqHandle Handle to the request
   315 	@param aReqHandle Handle to the request
   310 	@param aReqData information about the request
   316 	@param aReqData information about the request
   311 	@param aBufSize Size of the buffer the client has to allocate for the 2nd pahase
   317 	@param aBufSize Size of the buffer the client has to allocate for the 2nd pahase
   312   	*/
   318   	*/
   313 	LOGCALL1("CSimPhone::GetCallBarringStatusPhase1");
   319 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_GETCALLBARRINGSTATUSPHASE1_1, "CSimPhone::GetCallBarringStatusPhase1");
   314 	
   320 	
   315 	TInt ret=KErrNone;
   321 	TInt ret=KErrNone;
   316 	TInt leaveCode=KErrNone;
   322 	TInt leaveCode=KErrNone;
   317 	TRAP(leaveCode, ret=ProcessGetCallBarringStatusPhase1L(aTsyReqHandle, aReqData, aBufSize););
   323 	TRAP(leaveCode, ret=ProcessGetCallBarringStatusPhase1L(aTsyReqHandle, aReqData, aBufSize););
   318 	if (leaveCode != KErrNone)
   324 	if (leaveCode != KErrNone)
   319 			iPhone->ReqCompleted(aTsyReqHandle,leaveCode);
   325 			iPhone->ReqCompleted(aTsyReqHandle,leaveCode);
   320 
   326 
   321 	LOGCALL1("CSimPhone::GetCallBarringStatusPhase1");
   327 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_GETCALLBARRINGSTATUSPHASE1_2, "CSimPhone::GetCallBarringStatusPhase1");
   322 	return ret;
   328 	return ret;
   323 	}
   329 	}
   324 	
   330 	
   325 TInt CSimCallBarring::ProcessGetCallBarringStatusPhase1L(const TTsyReqHandle aTsyReqHandle, 
   331 TInt CSimCallBarring::ProcessGetCallBarringStatusPhase1L(const TTsyReqHandle aTsyReqHandle, 
   326 														 CRetrieveMobilePhoneCBList::TGetCallBarringRequest* aReqData, 
   332 														 CRetrieveMobilePhoneCBList::TGetCallBarringRequest* aReqData, 
   331 	stream the list and then return size of this buffer to client
   337 	stream the list and then return size of this buffer to client
   332 	@param aReqHandle Handle to the request
   338 	@param aReqHandle Handle to the request
   333 	@param aReqData information about the request
   339 	@param aReqData information about the request
   334 	@param aBufSize Size of the buffer the client has to allocate for the 2nd pahase
   340 	@param aBufSize Size of the buffer the client has to allocate for the 2nd pahase
   335 	*/
   341 	*/
   336 	LOGCALL1("CSimCallBarring::ProcessGetCallBarringStatusPhase1L");
   342 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_PROCESSGETCALLBARRINGSTATUSPHASE1L_1, "CSimCallBarring::ProcessGetCallBarringStatusPhase1L");
   337 
   343 
   338 	CMobilePhoneCBList* list=CMobilePhoneCBList::NewL();
   344 	CMobilePhoneCBList* list=CMobilePhoneCBList::NewL();
   339 	CleanupStack::PushL(list);
   345 	CleanupStack::PushL(list);
   340 		
   346 		
   341 
   347 
   393 	CleanupStack::PopAndDestroy(list); // pop&destroy list
   399 	CleanupStack::PopAndDestroy(list); // pop&destroy list
   394 	
   400 	
   395 	// Complete first phase of list retrieval
   401 	// Complete first phase of list retrieval
   396 	iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
   402 	iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
   397 	
   403 	
   398 	LOGCALL1("CSimCallBarring::ProcessGetCallBarringStatusPhase1L");
   404 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_PROCESSGETCALLBARRINGSTATUSPHASE1L_2, "CSimCallBarring::ProcessGetCallBarringStatusPhase1L");
   399 	return KErrNone;
   405 	return KErrNone;
   400 	}
   406 	}
   401 
   407 
   402 TInt CSimCallBarring::GetCallBarringStatusPhase2(const TTsyReqHandle aTsyReqHandle, 
   408 TInt CSimCallBarring::GetCallBarringStatusPhase2(const TTsyReqHandle aTsyReqHandle, 
   403 												 RMobilePhone::TClientId* aClient, TDes8* aBuf)
   409 												 RMobilePhone::TClientId* aClient, TDes8* aBuf)
   406 	2nd phase retrieval of the the call barring status list
   412 	2nd phase retrieval of the the call barring status list
   407 	@param aReqHandle Handle to the request
   413 	@param aReqHandle Handle to the request
   408 	@param aClient Ponter to the client
   414 	@param aClient Ponter to the client
   409 	@param aBuf Buffer containiong the call barring status list
   415 	@param aBuf Buffer containiong the call barring status list
   410 	*/
   416 	*/
   411 	LOGCALL1("CSimCallBarring::GetCallBarringStatusPhase2");
   417 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_GETCALLBARRINGSTATUSPHASE2_1, "CSimCallBarring::GetCallBarringStatusPhase2");
   412 	CListReadAllAttempt* read=NULL;
   418 	CListReadAllAttempt* read=NULL;
   413 	// Find the get detected network attempt from this client
   419 	// Find the get detected network attempt from this client
   414 	for (TInt i=0; i<iGetCBStatus->Count(); ++i)
   420 	for (TInt i=0; i<iGetCBStatus->Count(); ++i)
   415 		{
   421 		{
   416 		read = iGetCBStatus->At(i);
   422 		read = iGetCBStatus->At(i);
   425 			iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
   431 			iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
   426 			return KErrNone;
   432 			return KErrNone;
   427 			}
   433 			}
   428 		}
   434 		}
   429 	// Should handle error case of not finding the matching client from read all phase 1
   435 	// Should handle error case of not finding the matching client from read all phase 1
   430 	LOGCALL1("CSimCallBarring::GetCallBarringStatusPhase2");
   436 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_GETCALLBARRINGSTATUSPHASE2_2, "CSimCallBarring::GetCallBarringStatusPhase2");
   431 	return KErrNotFound;
   437 	return KErrNotFound;
   432 	}
   438 	}
   433 
   439 
   434 TInt CSimCallBarring::GetCallBarringStatusCancel(const TTsyReqHandle aTsyReqHandle)
   440 TInt CSimCallBarring::GetCallBarringStatusCancel(const TTsyReqHandle aTsyReqHandle)
   435 	{
   441 	{
   436 	/*
   442 	/*
   437 	Cancels a Request to retrieve the call barring status list
   443 	Cancels a Request to retrieve the call barring status list
   438 	@param aReqHandle Handle to the request
   444 	@param aReqHandle Handle to the request
   439 	*/
   445 	*/
   440 	LOGCALL1("CSimCallBarring::GetCallBarringStatusCancel");
   446 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_GETCALLBARRINGSTATUSCANCEL_1, "CSimCallBarring::GetCallBarringStatusCancel");
   441 	iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
   447 	iPhone->ReqCompleted(aTsyReqHandle,KErrNone);
   442 	// Remove the read all attempt from iGetCBStatus
   448 	// Remove the read all attempt from iGetCBStatus
   443 	CListReadAllAttempt* read=NULL;
   449 	CListReadAllAttempt* read=NULL;
   444 	for (TInt i=0; i<iGetCBStatus->Count(); ++i)
   450 	for (TInt i=0; i<iGetCBStatus->Count(); ++i)
   445 		{
   451 		{
   450 			iGetCBStatus->Delete(i);
   456 			iGetCBStatus->Delete(i);
   451 			break;
   457 			break;
   452 			}
   458 			}
   453 		}
   459 		}
   454 	iPhone->ReqCompleted(aTsyReqHandle,KErrCancel);
   460 	iPhone->ReqCompleted(aTsyReqHandle,KErrCancel);
   455 	LOGCALL1("CSimCallBarring::GetCallBarringStatusCancel");
   461 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMCALLBARRING_GETCALLBARRINGSTATUSCANCEL_2, "CSimCallBarring::GetCallBarringStatusCancel");
   456 	return KErrNone;
   462 	return KErrNone;
   457 	}
   463 	}
   458 
   464 
   459 // some useful functions for checking the type of conditions
   465 // some useful functions for checking the type of conditions
   460 inline TBool IsOutgoingCondition( RMobilePhone::TMobilePhoneCBCondition aCondition )
   466 inline TBool IsOutgoingCondition( RMobilePhone::TMobilePhoneCBCondition aCondition )