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