telephonyserverplugins/simtsy/src/CSimSmsStore.cpp
changeset 44 8b72faa1200f
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
39:2473f5e227f9 44:8b72faa1200f
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2003-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".
    17 
    17 
    18 /**
    18 /**
    19  @file
    19  @file
    20 */
    20 */
    21 
    21 
       
    22 
       
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "CSimSmsStoreTraces.h"
       
    27 #endif
       
    28 
    22 #include <mmlist.h>
    29 #include <mmlist.h>
    23 #include <mmretrieve.h>
    30 #include <mmretrieve.h>
    24 #include <testconfigfileparser.h>
    31 #include <testconfigfileparser.h>
    25 #include "CSimSmsStore.h"
    32 #include "CSimSmsStore.h"
    26 #include "csimsmsmess.h"
    33 #include "csimsmsmess.h"
    27 #include "Simlog.h"
       
    28 #include "CSimTsyMode.h"
    34 #include "CSimTsyMode.h"
    29 
    35 
    30 const TInt KSmsStoreGranularity=2;
    36 const TInt KSmsStoreGranularity=2;
    31 const TInt KCorruptPDU=9999;
    37 const TInt KCorruptPDU=9999;
    32 _LIT(KNullTelephoneNumber,"0");
    38 _LIT(KNullTelephoneNumber,"0");
   124 	{
   130 	{
   125 	iGsmSmsStoreEntries=new(ELeave) RMobileSmsStore::TMobileGsmSmsEntryV1[aMaxNumSlots+1];//index 0 is not used
   131 	iGsmSmsStoreEntries=new(ELeave) RMobileSmsStore::TMobileGsmSmsEntryV1[aMaxNumSlots+1];//index 0 is not used
   126 	iSmsMaxNumSlots=aMaxNumSlots;
   132 	iSmsMaxNumSlots=aMaxNumSlots;
   127 	iSmsStoreName.Copy(aName);
   133 	iSmsStoreName.Copy(aName);
   128 	iSmsReadAll=new(ELeave) CArrayPtrFlat<CListReadAllAttempt>(KSmsStoreGranularity);
   134 	iSmsReadAll=new(ELeave) CArrayPtrFlat<CListReadAllAttempt>(KSmsStoreGranularity);
   129 	LOGSMS1("Starting to parse SMS Store config parameters...");
   135 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_CONSTRUCTL_1, "Starting to parse SMS Store config parameters...");
   130 	iSmsIndividualPause=CfgFileSection()->ItemValue(KSmsStoreIndividualReqPause,KDefaultSmsStoreIndividualReqPause);
   136 	iSmsIndividualPause=CfgFileSection()->ItemValue(KSmsStoreIndividualReqPause,KDefaultSmsStoreIndividualReqPause);
   131 	iSmsBatchPause=CfgFileSection()->ItemValue(KSmsStoreBatchReqPause,KDefaultSmsStoreBatchReqPause);
   137 	iSmsBatchPause=CfgFileSection()->ItemValue(KSmsStoreBatchReqPause,KDefaultSmsStoreBatchReqPause);
   132 	
   138 	
   133 	const CTestConfigItem* item0=NULL;
   139 	const CTestConfigItem* item0=NULL;
   134 	item0=CfgFileSection()->Item(KSmsPhoneStoreCaps,0);
   140 	item0=CfgFileSection()->Item(KSmsPhoneStoreCaps,0);
   136 		{
   142 		{
   137 		TPtrC8 value0;
   143 		TPtrC8 value0;
   138 		TInt ret0=CTestConfig::GetElement(item0->Value(),KStdDelimiter,0,value0);
   144 		TInt ret0=CTestConfig::GetElement(item0->Value(),KStdDelimiter,0,value0);
   139 		if(ret0!=KErrNone)
   145 		if(ret0!=KErrNone)
   140 			{
   146 			{
   141 			LOGPARSERR("value0",ret0,0,&KSmsPhoneStoreCaps);
   147 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_CONSTRUCTL_2, "WARNING - CONFIGURATION FILE PARSING - Reading element VALUE0 returned %d (element no. %d) from tag %s.",ret0,0,KSmsPhoneStoreCaps);
   142 			iSmsStoreCaps=KDefaultSmsPhoneStoreCaps+KDefaultSmsOnlySmsCaps;
   148 			iSmsStoreCaps=KDefaultSmsPhoneStoreCaps+KDefaultSmsOnlySmsCaps;
   143 			}
   149 			}
   144 		else
   150 		else
   145 			{
   151 			{
   146 			TUint32 intValue;
   152 			TUint32 intValue;
   153 		}
   159 		}
   154 	else
   160 	else
   155 		iSmsStoreCaps=KDefaultSmsPhoneStoreCaps+KDefaultSmsOnlySmsCaps;
   161 		iSmsStoreCaps=KDefaultSmsPhoneStoreCaps+KDefaultSmsOnlySmsCaps;
   156 
   162 
   157 
   163 
   158 	LOGSMS1("...Finished parsing SMS Store config parameters");
   164 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_CONSTRUCTL_3, "...Finished parsing SMS Store config parameters");
   159 	iTimer=CSimTimer::NewL(iSmsMessaging->iPhone);
   165 	iTimer=CSimTimer::NewL(iSmsMessaging->iPhone);
   160 	iIncomingTimer=CSimTimer::NewL(iSmsMessaging->iPhone);
   166 	iIncomingTimer=CSimTimer::NewL(iSmsMessaging->iPhone);
   161 	}
   167 	}
   162 
   168 
   163 void CSimSmsStore::PopulateStoreFromConfigFile()
   169 void CSimSmsStore::PopulateStoreFromConfigFile()
   168  *
   174  *
   169  * The store entries comply to the following format:
   175  * The store entries comply to the following format:
   170  * "SmsStoreEntry = <store name>, <slot number>, <entry status>, <pdu>"
   176  * "SmsStoreEntry = <store name>, <slot number>, <entry status>, <pdu>"
   171  */
   177  */
   172 	{
   178 	{
   173 	LOGSMS1("Starting reading SMS Store entries...");
   179 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_POPULATESTOREFROMCONFIGFILE_1, "Starting reading SMS Store entries...");
   174 	TInt count=CfgFileSection()->ItemCount(KSmsStoreEntry);
   180 	TInt count=CfgFileSection()->ItemCount(KSmsStoreEntry);
   175 	const CTestConfigItem* item=NULL;
   181 	const CTestConfigItem* item=NULL;
   176 	TInt ret=KErrNone;
   182 	TInt ret=KErrNone;
   177 
   183 
   178 	for(TInt i=0;i<count;i++)
   184 	for(TInt i=0;i<count;i++)
   183 
   189 
   184 		TPtrC8 storeName;
   190 		TPtrC8 storeName;
   185 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,storeName);
   191 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,storeName);
   186 		if(ret!=KErrNone)
   192 		if(ret!=KErrNone)
   187 			{
   193 			{
   188 			LOGPARSERR("storeName",ret,0,&KSmsStoreEntry);
   194 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_POPULATESTOREFROMCONFIGFILE_2, "WARNING - CONFIGURATION FILE PARSING - Reading element STORENAME returned %d (element no. %d) from tag %s.",ret,0,KSmsStoreEntry);
   189 			continue;
   195 			continue;
   190 			}
   196 			}
   191 		if(storeName.MatchF(iSmsStoreName)!=0)
   197 		if(storeName.MatchF(iSmsStoreName)!=0)
   192 			continue;						// Not this store
   198 			continue;						// Not this store
   193 
   199 
   194 		TInt index,stat;
   200 		TInt index,stat;
   195 		TPtrC8 pdu;
   201 		TPtrC8 pdu;
   196 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,index);
   202 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,index);
   197 		if((ret!=KErrNone)||(index>=iSmsMaxNumSlots))
   203 		if((ret!=KErrNone)||(index>=iSmsMaxNumSlots))
   198 			{
   204 			{
   199 			LOGPARSERR("index",ret,1,&KSmsStoreEntry);
   205 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_POPULATESTOREFROMCONFIGFILE_3, "WARNING - CONFIGURATION FILE PARSING - Reading element INDEX returned %d (element no. %d) from tag %s.",ret,1,KSmsStoreEntry);
   200 			continue;
   206 			continue;
   201 			}
   207 			}
   202 	
   208 	
   203 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,stat);
   209 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,stat);
   204 		if(ret!=KErrNone)
   210 		if(ret!=KErrNone)
   205 			{
   211 			{
   206 			LOGPARSERR("stat",ret,2,&KSmsStoreEntry);
   212 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_POPULATESTOREFROMCONFIGFILE_4, "WARNING - CONFIGURATION FILE PARSING - Reading element STAT returned %d (element no. %d) from tag %s",ret,2,KSmsStoreEntry);
   207 			continue;
   213 			continue;
   208 			}
   214 			}
   209 
   215 
   210 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,pdu);
   216 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,pdu);
   211 		if(ret!=KErrNone)
   217 		if(ret!=KErrNone)
   212 			{
   218 			{
   213 			LOGPARSERR("pdu",ret,3,&KSmsStoreEntry);
   219 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_POPULATESTOREFROMCONFIGFILE_5, "WARNING - CONFIGURATION FILE PARSING - Reading element PDU returned %d (element no. %d) from tag %s.",ret,3,KSmsStoreEntry);
   214 			continue;
   220 			continue;
   215 			}
   221 			}
   216 
   222 
   217 		TPtrC8 sca;
   223 		TPtrC8 sca;
   218 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,sca);
   224 		ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,sca);
   219 		if(ret!=KErrNone)
   225 		if(ret!=KErrNone)
   220 			{
   226 			{
   221 			LOGPARSERR("sca",ret,4,&KSmsStoreEntry);
   227 			OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_POPULATESTOREFROMCONFIGFILE_6, "WARNING - CONFIGURATION FILE PARSING - Reading element SCA returned %d (element no. %d) from tag %s.",ret,4,KSmsStoreEntry);
   222 			continue;
   228 			continue;
   223 			}
   229 			}
   224 		iGsmSmsStoreEntries[index].iIndex=index;
   230 		iGsmSmsStoreEntries[index].iIndex=index;
   225 		iGsmSmsStoreEntries[index].iMsgStatus=(RMobileSmsStore::TMobileSmsStoreStatus)stat;
   231 		iGsmSmsStoreEntries[index].iMsgStatus=(RMobileSmsStore::TMobileSmsStoreStatus)stat;
   226 		ConvertAsciiSms(pdu,iGsmSmsStoreEntries[index].iMsgData);
   232 		ConvertAsciiSms(pdu,iGsmSmsStoreEntries[index].iMsgData);
   227 		RecordSca(sca, index);
   233 		RecordSca(sca, index);
   228 		}
   234 		}
   229 
   235 
   230 	LOGSMS1("...Finished reading SMS Store entries");
   236 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_POPULATESTOREFROMCONFIGFILE_7, "...Finished reading SMS Store entries");
   231 	}
   237 	}
   232 
   238 
   233 
   239 
   234 
   240 
   235 void CSimSmsStore::RecordSca(const TDesC8& aAsciiAddr, TInt aIndex)
   241 void CSimSmsStore::RecordSca(const TDesC8& aAsciiAddr, TInt aIndex)
   266 
   272 
   267 	delete iTimer;
   273 	delete iTimer;
   268 	delete iIncomingTimer;
   274 	delete iIncomingTimer;
   269 	}
   275 	}
   270 
   276 
   271 #ifdef _DEBUG
   277 #ifdef OST_TRACE_COMPILER_IN_USE
   272 void CSimSmsStore::LogRequest(TBool aEntering, TInt aIpc, TInt aError)
   278 void CSimSmsStore::LogRequest(TBool aEntering, TInt aIpc, TInt aError)
   273 #else
   279 #else
   274 void CSimSmsStore::LogRequest(TBool aEntering, TInt aIpc, TInt /*aError*/)
   280 void CSimSmsStore::LogRequest(TBool aEntering, TInt aIpc, TInt /*aError*/)
   275 #endif
   281 #endif
   276 /**
   282 /**
   322 			break;
   328 			break;
   323 		}
   329 		}
   324 
   330 
   325 	if (aEntering!=EFalse)
   331 	if (aEntering!=EFalse)
   326 		{
   332 		{
   327 		LOGSMS3(">>%d,CSimSmsStore::%S",aIpc, &ipcBuf );
   333 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_LOGREQUEST_1, ">>%d,CSimSmsStore::%s",aIpc, ipcBuf );
   328 		}
   334 		}
   329 	else
   335 	else
   330 		{
   336 		{	
   331 		LOGSMS4("<<%d,CSimSmsStore::%S with error %d",aIpc, &ipcBuf, aError);
   337 		OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_LOGREQUEST_2, "<<%d,CSimSmsStore::%s with error %d",aIpc, ipcBuf, aError);	
   332 		}
   338 		}
   333 	}
   339 	}
   334 
   340 
   335 
   341 
   336 
   342 
  1175 * Returns a pointer to the config file section
  1181 * Returns a pointer to the config file section
  1176 *
  1182 *
  1177 * @return CTestConfigSection a pointer to the configuration file data section
  1183 * @return CTestConfigSection a pointer to the configuration file data section
  1178 */
  1184 */
  1179 	{
  1185 	{
  1180 	LOGSMS1(">>CSimSmsStore::CfgFileSection");
  1186 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMSMSSTORE_CFGFILESECTION_1, ">>CSimSmsStore::CfgFileSection");
  1181 	return iSmsMessaging->CfgFileSection();
  1187 	return iSmsMessaging->CfgFileSection();
  1182 	}
  1188 	}
  1183 
  1189