1 // Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2001-2009 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 "CSimPhBkStoreTraces.h" |
|
27 #endif |
|
28 |
|
29 #include "CSimPhBkStore.h" |
22 #include "CSimPhBkStore.h" |
30 #include "CSimPhone.h" |
23 #include "CSimPhone.h" |
|
24 #include "Simlog.h" |
31 #include <testconfigfileparser.h> |
25 #include <testconfigfileparser.h> |
32 |
26 |
33 const TUint16 KNpiTonInternational=145; // < The Number Plan Identifier and Type of Number for an international telephone number. |
27 const TUint16 KNpiTonInternational=145; // < The Number Plan Identifier and Type of Number for an international telephone number. |
34 const TUint16 KNpiTonNational=129; // < The Number Plan Identifier and Type of Number for a national telephone number. |
28 const TUint16 KNpiTonNational=129; // < The Number Plan Identifier and Type of Number for a national telephone number. |
35 const TInt KPhonebookErrorGranularity=3; // < Granularity of phonebook error list array. |
29 const TInt KPhonebookErrorGranularity=3; // < Granularity of phonebook error list array. |
78 * @param aName The name of the created phonebook. |
72 * @param aName The name of the created phonebook. |
79 * @param aMaxNumLen The maximum length of a telephone number. |
73 * @param aMaxNumLen The maximum length of a telephone number. |
80 * @param aMaxTextLen The maximum length of an alpha tag. |
74 * @param aMaxTextLen The maximum length of an alpha tag. |
81 */ |
75 */ |
82 { |
76 { |
83 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_CONSTRUCTL_1, "Starting to parse Phonebook store additional config parameters..."); |
77 LOGPHBK1("Starting to parse Phonebook store additional config parameters..."); |
84 __ASSERT_ALWAYS(aMaxNumLen<=KPhBkMaxTelNumSize,SimPanic(EPhonebookNameOrNumberTooLarge)); |
78 __ASSERT_ALWAYS(aMaxNumLen<=KPhBkMaxTelNumSize,SimPanic(EPhonebookNameOrNumberTooLarge)); |
85 __ASSERT_ALWAYS(aMaxTextLen<=KPhBkMaxAlphaTagSize,SimPanic(EPhonebookNameOrNumberTooLarge)); |
79 __ASSERT_ALWAYS(aMaxTextLen<=KPhBkMaxAlphaTagSize,SimPanic(EPhonebookNameOrNumberTooLarge)); |
86 |
80 |
87 iPhBkStoreEntries=new(ELeave) TPhBkStoreEntry[aMaxNumSlots+1]; //slot 0 is unused |
81 iPhBkStoreEntries=new(ELeave) TPhBkStoreEntry[aMaxNumSlots+1]; //slot 0 is unused |
88 iPhBkMaxNumSlots=aMaxNumSlots; |
82 iPhBkMaxNumSlots=aMaxNumSlots; |
104 TInt ipc, cnt, event; |
98 TInt ipc, cnt, event; |
105 |
99 |
106 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,ipc); |
100 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,ipc); |
107 if(ret!=KErrNone) |
101 if(ret!=KErrNone) |
108 { |
102 { |
109 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_CONSTRUCTL_2, "WARNING - CONFIGURATION FILE PARSING - Reading element IPC returned %d (element no. %d) from tag %s.",ret,0,KTriggerEventIPC); |
103 LOGPARSERR("ipc",ret,0,&KTriggerEventIPC); |
110 } |
104 } |
111 else |
105 else |
112 iTriggerEventIPC.iIPC=ipc; |
106 iTriggerEventIPC.iIPC=ipc; |
113 |
107 |
114 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,cnt); |
108 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,cnt); |
115 if(ret!=KErrNone) |
109 if(ret!=KErrNone) |
116 { |
110 { |
117 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_CONSTRUCTL_3, "WARNING - CONFIGURATION FILE PARSING - Reading element CNT returned %d (element no. %d) from tag %s.",ret,1,KTriggerEventIPC); |
111 LOGPARSERR("cnt",ret,1,&KTriggerEventIPC); |
118 } |
112 } |
119 else |
113 else |
120 iTriggerEventIPC.iIPCCnt=cnt; |
114 iTriggerEventIPC.iIPCCnt=cnt; |
121 |
115 |
122 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,event); |
116 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,event); |
123 if(ret!=KErrNone) |
117 if(ret!=KErrNone) |
124 { |
118 { |
125 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_CONSTRUCTL_4, "WARNING - CONFIGURATION FILE PARSING - Reading element EVENT returned %d (element no. %d) from tag %s.",ret,2,KTriggerEventIPC); |
119 LOGPARSERR("event",ret,2,&KTriggerEventIPC); |
126 } |
120 } |
127 else |
121 else |
128 iTriggerEventIPC.iEvent=RMobilePhone::TMobilePhoneSecurityEvent(event); |
122 iTriggerEventIPC.iEvent=RMobilePhone::TMobilePhoneSecurityEvent(event); |
129 |
123 |
130 |
124 |
137 TPtrC8 value0; |
131 TPtrC8 value0; |
138 TInt ret0=CTestConfig::GetElement(item0->Value(),KStdDelimiter,0,value0); |
132 TInt ret0=CTestConfig::GetElement(item0->Value(),KStdDelimiter,0,value0); |
139 if(ret0!=KErrNone) |
133 if(ret0!=KErrNone) |
140 { |
134 { |
141 iPhBkStoreCaps=KDefaultPhBkPhoneStoreCaps; |
135 iPhBkStoreCaps=KDefaultPhBkPhoneStoreCaps; |
142 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_CONSTRUCTL_5, "WARNING - CONFIGURATION FILE PARSING - Reading element VALUE0 returned %d (element no. %d) from tag %s.",ret0,0,KPhBkPhoneStoreCaps); |
136 LOGPARSERR("value0",ret0,0,&KPhBkPhoneStoreCaps); |
143 } |
137 } |
144 else |
138 else |
145 { |
139 { |
146 TUint32 intValue; |
140 TUint32 intValue; |
147 TInt ret = AsciiToNum(value0, intValue); |
141 TInt ret = AsciiToNum(value0, intValue); |
166 * |
160 * |
167 * The store entries comply to the following format: |
161 * The store entries comply to the following format: |
168 * "PhBkStoreEntry = <store name>, <slot number>, <telephone number>, <alphatag>" |
162 * "PhBkStoreEntry = <store name>, <slot number>, <telephone number>, <alphatag>" |
169 */ |
163 */ |
170 { |
164 { |
171 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATESTOREFROMCONFIGFILEL_1, "Starting to read Phonebook store entries..."); |
165 LOGPHBK1("Starting to read Phonebook store entries..."); |
172 iPhBkIndividualPause=CfgFile()->ItemValue(KPhBkStoreIndividualReqPause,KDefaultPhBkStoreIndividualReqPause); |
166 iPhBkIndividualPause=CfgFile()->ItemValue(KPhBkStoreIndividualReqPause,KDefaultPhBkStoreIndividualReqPause); |
173 iPhBkBatchPause=CfgFile()->ItemValue(KPhBkStoreBatchReqPause,KDefaultPhBkStoreBatchReqPause); |
167 iPhBkBatchPause=CfgFile()->ItemValue(KPhBkStoreBatchReqPause,KDefaultPhBkStoreBatchReqPause); |
174 |
168 |
175 TInt count=CfgFile()->ItemCount(KPhBkStoreEntry); |
169 TInt count=CfgFile()->ItemCount(KPhBkStoreEntry); |
176 const CTestConfigItem* item=NULL; |
170 const CTestConfigItem* item=NULL; |
187 TInt index; |
181 TInt index; |
188 TUint8 npiTon; |
182 TUint8 npiTon; |
189 ret=GetPhBkEntry(item,0,phonebookName,index,telNum,alphaTag,npiTon); |
183 ret=GetPhBkEntry(item,0,phonebookName,index,telNum,alphaTag,npiTon); |
190 if(ret!=KErrNone) |
184 if(ret!=KErrNone) |
191 { |
185 { |
192 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATESTOREFROMCONFIGFILEL_2, "WARNING - CONFIGURATION FILE PARSING - Reading element PHONEBOOK ENTRY returned %d (element no. %d) from tag %s.",ret,index,KPhBkStoreEntry); |
186 LOGPARSERR("Phonebook Entry",ret,index,&KPhBkStoreEntry); |
193 continue; |
187 continue; |
194 } |
188 } |
195 if(phonebookName.MatchF(iPhBkStoreName)!=0)// Not this phonebook |
189 if(phonebookName.MatchF(iPhBkStoreName)!=0)// Not this phonebook |
196 continue; |
190 continue; |
197 |
191 |
213 TPtrC8 phonebookName, phonebookStore; |
207 TPtrC8 phonebookName, phonebookStore; |
214 |
208 |
215 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,count); |
209 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,count); |
216 if(ret!=KErrNone) |
210 if(ret!=KErrNone) |
217 { |
211 { |
218 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATESTOREFROMCONFIGFILEL_3, "WARNING - CONFIGURATION FILE PARSING - Reading element COUNT returned %d (element no. %d) from tag %s.",ret,0,KPhBkError); |
212 LOGPARSERR("count",ret,0,&KPhBkError); |
219 continue; |
213 continue; |
220 } |
214 } |
221 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,error); |
215 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,error); |
222 if(ret!=KErrNone) |
216 if(ret!=KErrNone) |
223 { |
217 { |
224 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATESTOREFROMCONFIGFILEL_4, "WARNING - CONFIGURATION FILE PARSING - Reading element ERROR returned %d (element no. %d) from tag %s.",ret,1,KPhBkError); |
218 LOGPARSERR("error",ret,1,&KPhBkError); |
225 continue; |
219 continue; |
226 } |
220 } |
227 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,phonebookName); |
221 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,phonebookName); |
228 if(ret!=KErrNone) |
222 if(ret!=KErrNone) |
229 { |
223 { |
230 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATESTOREFROMCONFIGFILEL_5, "WARNING - CONFIGURATION FILE PARSING - Reading element PHONEBOOKNAME returned %d (element no. %d) from tag %s.",ret,2,KPhBkError); |
224 LOGPARSERR("phonebookName",ret,2,&KPhBkError); |
231 continue; |
225 continue; |
232 } |
226 } |
233 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,phonebookStore); |
227 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,phonebookStore); |
234 if(ret!=KErrNone) |
228 if(ret!=KErrNone) |
235 { |
229 { |
236 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATESTOREFROMCONFIGFILEL_6, "WARNING - CONFIGURATION FILE PARSING - Reading element PHONEBOOKSTORE returned %d (element no. %d) from tag %s.",ret,3,KPhBkError); |
230 LOGPARSERR("phonebookStore",ret,3,&KPhBkError); |
237 } |
231 } |
238 else //not for the global phonebook |
232 else //not for the global phonebook |
239 continue; |
233 continue; |
240 |
234 |
241 if(phonebookName.MatchF(iPhBkStoreName)!=0)// Not this phonebook |
235 if(phonebookName.MatchF(iPhBkStoreName)!=0)// Not this phonebook |
247 entry.iError=error; |
241 entry.iError=error; |
248 iPhBkError->AppendL(entry); |
242 iPhBkError->AppendL(entry); |
249 } |
243 } |
250 PopulateOOBWrite(); |
244 PopulateOOBWrite(); |
251 PopulateOOBDelete(); |
245 PopulateOOBDelete(); |
252 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATESTOREFROMCONFIGFILEL_7, "...Finished reading Phonebook store entries..."); |
246 LOGPHBK1("...Finished reading Phonebook store entries..."); |
253 |
247 |
254 if(iPhBkOOBWriteDuration!=-1) |
248 if(iPhBkOOBWriteDuration!=-1) |
255 iOOBWriteTimer->Start(iPhBkOOBWriteDuration,this,ETimerIdPhBkStorOOBWrite); |
249 iOOBWriteTimer->Start(iPhBkOOBWriteDuration,this,ETimerIdPhBkStorOOBWrite); |
256 if(iPhBkOOBDeleteDuration!=-1) |
250 if(iPhBkOOBDeleteDuration!=-1) |
257 iOOBDeleteTimer->Start(iPhBkOOBDeleteDuration,this,ETimerIdPhBkStorOOBDelete); |
251 iOOBDeleteTimer->Start(iPhBkOOBDeleteDuration,this,ETimerIdPhBkStorOOBDelete); |
272 |
266 |
273 TInt count; |
267 TInt count; |
274 TInt ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,count); |
268 TInt ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,count); |
275 if(ret!=KErrNone) |
269 if(ret!=KErrNone) |
276 { |
270 { |
277 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATEOOBWRITE_1, "WARNING - CONFIGURATION FILE PARSING - Reading element COUNT returned %d (element no. %d) from tag %s.",ret,0,KOOBPhBkWrite); |
271 LOGPARSERR("count",ret,0,&KOOBPhBkWrite); |
278 return; |
272 return; |
279 } |
273 } |
280 |
274 |
281 TPtrC8 phonebookName,alphaTag,telNum; |
275 TPtrC8 phonebookName,alphaTag,telNum; |
282 TInt index; |
276 TInt index; |
283 TUint8 npiTon; |
277 TUint8 npiTon; |
284 ret=GetPhBkEntry(item,1,phonebookName,index,telNum,alphaTag,npiTon); |
278 ret=GetPhBkEntry(item,1,phonebookName,index,telNum,alphaTag,npiTon); |
285 if(ret!=KErrNone) |
279 if(ret!=KErrNone) |
286 { |
280 { |
287 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATEOOBWRITE_2, "WARNING - CONFIGURATION FILE PARSING - Reading element NPITON returned %d (element no. %d) from tag %s.",ret,index,KOOBPhBkWrite); |
281 LOGPARSERR("npiTon",ret,index,&KOOBPhBkWrite); |
288 return; |
282 return; |
289 } |
283 } |
290 if(phonebookName.MatchF(iPhBkStoreName)!=0) |
284 if(phonebookName.MatchF(iPhBkStoreName)!=0) |
291 return; // Not this phonebook |
285 return; // Not this phonebook |
292 |
286 |
312 |
306 |
313 TInt count; |
307 TInt count; |
314 TInt ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,count); |
308 TInt ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,count); |
315 if(ret!=KErrNone) |
309 if(ret!=KErrNone) |
316 { |
310 { |
317 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATEOOBDELETE_1, "WARNING - CONFIGURATION FILE PARSING - Reading element COUNT returned %d (element no. %d) from tag %s.",ret,0,KOOBPhBkDelete); |
311 LOGPARSERR("count",ret,0,&KOOBPhBkDelete); |
318 return; |
312 return; |
319 } |
313 } |
320 |
314 |
321 TPtrC8 phonebookName; |
315 TPtrC8 phonebookName; |
322 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,phonebookName); |
316 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,phonebookName); |
323 if(ret!=KErrNone) |
317 if(ret!=KErrNone) |
324 { |
318 { |
325 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATEOOBDELETE_2, "WARNING - CONFIGURATION FILE PARSING - Reading element PHONEBOOKNAME returned %d (element no. %d) from tag %s.",ret,1,KOOBPhBkDelete); |
319 LOGPARSERR("phonebookName",ret,1,&KOOBPhBkDelete); |
326 return; |
320 return; |
327 } |
321 } |
328 if(phonebookName.MatchF(iPhBkStoreName)!=0) |
322 if(phonebookName.MatchF(iPhBkStoreName)!=0) |
329 return; // Not this phonebook |
323 return; // Not this phonebook |
330 |
324 |
331 TInt index; |
325 TInt index; |
332 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,index); |
326 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,index); |
333 if(ret!=KErrNone) |
327 if(ret!=KErrNone) |
334 { |
328 { |
335 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_POPULATEOOBDELETE_3, "WARNING - CONFIGURATION FILE PARSING - Reading element INDEX returned %d (element no. %d) from tag %s.",ret,2,KOOBPhBkDelete); |
329 LOGPARSERR("index",ret,2,&KOOBPhBkDelete); |
336 return; |
330 return; |
337 } |
331 } |
338 |
332 |
339 iPhBkOOBDeleteDuration=count; |
333 iPhBkOOBDeleteDuration=count; |
340 iPhBkOOBDeleteIndex=index; |
334 iPhBkOOBDeleteIndex=index; |
983 { |
977 { |
984 ReqCompleted(aReqHandle,ret); |
978 ReqCompleted(aReqHandle,ret); |
985 return KErrNone; |
979 return KErrNone; |
986 } |
980 } |
987 |
981 |
988 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_WRITE_1, "alphaTag Length = (%d)",alphaTag.Length()); |
982 LOGPHBK2("alphaTag Length = (%d)",alphaTag.Length()); |
989 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_WRITE_2, "Phonebook Max Text Length = (%d)",iPhBkMaxTextLen); |
983 LOGPHBK2("Phonebook Max Text Length = (%d)",iPhBkMaxTextLen); |
990 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_WRITE_3, "TelNum Length = (%d)",telNum.Length()); |
984 LOGPHBK2("TelNum Length = (%d)",telNum.Length()); |
991 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSIMPHBKSTORE_WRITE_4, "TelNum Max Length = (%d)",iPhBkMaxTelNumLen); |
985 LOGPHBK2("TelNum Max Length = (%d)",iPhBkMaxTelNumLen); |
992 |
986 |
993 if(alphaTag.Length()>iPhBkMaxTextLen) |
987 if(alphaTag.Length()>iPhBkMaxTextLen) |
994 { |
988 { |
995 ReqCompleted(aReqHandle, EXTENDEDERROR(KErrOverflow, KErrPhonebookTextOverflow)); |
989 ReqCompleted(aReqHandle, EXTENDEDERROR(KErrOverflow, KErrPhonebookTextOverflow)); |
996 return KErrNone; |
990 return KErrNone; |