89 // --------------------------------------------------------------------------- |
91 // --------------------------------------------------------------------------- |
90 |
92 |
91 CMmPhoneBookOperationWrite* CMmPhoneBookOperationWrite::NewL( |
93 CMmPhoneBookOperationWrite* CMmPhoneBookOperationWrite::NewL( |
92 CMmPhoneBookStoreMessHandler* aMmPhoneBookStoreMessHandler, |
94 CMmPhoneBookStoreMessHandler* aMmPhoneBookStoreMessHandler, |
93 CMmUiccMessHandler* aUiccMessHandler, |
95 CMmUiccMessHandler* aUiccMessHandler, |
94 const CMmDataPackage* aDataPackage ) // Data |
96 const CMmDataPackage* aDataPackage, |
|
97 TInt aIpc ) // Data |
95 { |
98 { |
96 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::NewL"); |
99 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::NewL"); |
97 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_NEWL, "CMmPhoneBookOperationWrite::NewL" ); |
100 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_NEWL, "CMmPhoneBookOperationWrite::NewL" ); |
98 |
101 |
99 TName phonebookTypeName; |
102 TName phonebookTypeName; |
100 |
103 |
101 CMmPhoneBookOperationWrite* mmPhoneBookOperationWrite = |
104 CMmPhoneBookOperationWrite* mmPhoneBookOperationWrite = |
102 new( ELeave ) CMmPhoneBookOperationWrite(); |
105 new( ELeave ) CMmPhoneBookOperationWrite(); |
103 |
106 |
104 const CPhoneBookDataPackage* phoneBookData = |
107 if( ( EMmTsyONStoreWriteIPC != aIpc )&& |
105 static_cast<const CPhoneBookDataPackage*>( aDataPackage ); |
108 ( EMmTsyONStoreWriteEntryIPC != aIpc ) ) |
106 |
109 { |
107 phoneBookData->GetPhoneBookName( phonebookTypeName ); |
110 TName phonebookTypeName; |
108 // Store phonebook name |
111 |
109 mmPhoneBookOperationWrite->iPhoneBookTypeName = phonebookTypeName; |
112 const CPhoneBookDataPackage* phoneBookData = |
|
113 static_cast<const CPhoneBookDataPackage*>( aDataPackage ); |
|
114 |
|
115 phoneBookData->GetPhoneBookName( phonebookTypeName ); |
|
116 // Store phonebook name |
|
117 mmPhoneBookOperationWrite->iPhoneBookTypeName = phonebookTypeName; |
|
118 } |
|
119 |
110 |
120 |
111 mmPhoneBookOperationWrite->iMmPhoneBookStoreMessHandler = |
121 mmPhoneBookOperationWrite->iMmPhoneBookStoreMessHandler = |
112 aMmPhoneBookStoreMessHandler; |
122 aMmPhoneBookStoreMessHandler; |
113 |
123 |
114 mmPhoneBookOperationWrite->iMmUiccMessHandler = aUiccMessHandler; |
124 mmPhoneBookOperationWrite->iMmUiccMessHandler = aUiccMessHandler; |
141 { |
151 { |
142 TFLOGSTRING2("TSY: CMmPhoneBookOperationWrite::UICCCreateReq Ipc: %d", aIpc); |
152 TFLOGSTRING2("TSY: CMmPhoneBookOperationWrite::UICCCreateReq Ipc: %d", aIpc); |
143 OstTraceExt1( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONWRITE_UICCCREATEREQ, "CMmPhoneBookOperationWrite::UICCCreateReq;aIpc=%hd", aIpc ); |
153 OstTraceExt1( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONWRITE_UICCCREATEREQ, "CMmPhoneBookOperationWrite::UICCCreateReq;aIpc=%hd", aIpc ); |
144 |
154 |
145 TInt ret (KErrNotSupported); |
155 TInt ret (KErrNotSupported); |
|
156 iSavedIpc = aIpc; |
|
157 |
146 const CPhoneBookDataPackage* phoneBookData = |
158 const CPhoneBookDataPackage* phoneBookData = |
147 static_cast<const CPhoneBookDataPackage*>( aDataPackage ); |
159 static_cast<const CPhoneBookDataPackage*>( aDataPackage ); |
148 |
160 |
149 if( aIpc == EMmTsyPhoneBookStoreWriteIPC ) |
161 switch( aIpc ) |
150 { |
162 { |
|
163 case EMmTsyPhoneBookStoreWriteIPC: |
|
164 { |
151 TInt16 index( 0 ); |
165 TInt16 index( 0 ); |
152 // Store Entry to the operation which needs to be write in SIM |
166 // Store Entry to the operation which needs to be write in SIM |
153 phoneBookData->UnPackData( index, iPhoneBookEntry ); |
167 phoneBookData->UnPackData( index, iPhoneBookEntry ); |
154 |
168 |
155 if ( iPhoneBookEntry ) |
169 if ( iPhoneBookEntry ) |
156 { |
170 { |
157 // get the index Number needs to be write |
171 // get the index Number needs to be write |
158 iPhoneBookEntry->iLocation = static_cast<TUint16>( index ); |
172 iPhoneBookEntry->iLocation = static_cast<TUint16>( index ); |
159 |
173 |
160 // Convert Phone Book name to file id |
174 // Convert Phone Book name to file id |
161 TUint16 fileIdExt ( UICC_ILLEGAL_FILE_ID ); |
175 iFileId = ConvertToPBfileId( |
162 TUint16 pbFileId = ConvertToPBfileId( |
|
163 iPhoneBookTypeName, |
176 iPhoneBookTypeName, |
164 fileIdExt, |
177 iExtFileId, |
165 iMmUiccMessHandler->GetCardType() ); |
178 iMmUiccMessHandler->GetCardType() ); |
166 |
179 |
167 TUint8 pbArrayIndex ( ConvertToConfArrayIndex( pbFileId ) ); |
180 iArrayIndex = ConvertToConfArrayIndex( iFileId ); |
168 |
181 ret = UiccPbReqWriteL( aTransId, index, *iPhoneBookEntry ); |
169 if( PB_MBDN_FID == pbFileId ) |
182 } |
170 { |
183 break; |
171 // For MBDN PhoneBook first read MBI file |
184 } |
172 // Check if the mailbox inidcation type is correct |
185 case EMmTsyONStoreWriteEntryIPC: |
173 if( index <= iMmPhoneBookStoreMessHandler-> |
186 { |
174 iPBStoreConf[pbArrayIndex].iMbiRecLen ) |
187 iFileId = PB_MSISDN_FID; |
175 { |
188 iExtFileId = PB_EXT1_FID; |
176 iCurrentWritePhase = EPBWritePhase_Read_MBI_profile; |
189 iArrayIndex = EPhonebookTypeMSISDN; |
177 // read MBDN record number from MBI first record |
190 |
178 //Profile number |
191 RMobileONStore::TMobileONEntryV1 entry; |
179 ret = UiccPbReqReadMBI( index, aTransId ); |
192 aDataPackage->UnPackData( entry ); |
180 } |
193 |
181 else |
194 iPhoneBookEntry = new( ELeave ) CPhoneBookStoreEntry; |
182 { |
195 CleanupStack::PushL( iPhoneBookEntry ); |
183 ret = KErrArgument; |
196 iPhoneBookEntry->ConstructL(); |
184 } |
197 |
185 } |
198 // Copy index number |
186 else |
199 iPhoneBookEntry->iLocation = entry.iIndex; |
187 { |
200 |
188 ret = UiccPbReqWriteL( aTransId, index, *iPhoneBookEntry ); |
201 iPhoneBookEntry->iText = HBufC::NewL( KOwnNumberTextSize ); |
189 } |
202 // Copy name |
190 } |
203 TPtr ptrToName ( iPhoneBookEntry->iText->Des() ); |
191 } |
204 CopyData( entry.iText, ptrToName ); |
192 else |
205 |
193 { |
206 iPhoneBookEntry->iNumber = HBufC::NewL( KMaxMobileTelNumberSize ); |
|
207 // Copy Number |
|
208 TPtr ptrToNumber( iPhoneBookEntry->iNumber->Des() ); |
|
209 CopyData( entry.iNumber.iTelNumber, ptrToNumber ); |
|
210 |
|
211 CleanupStack::Pop( iPhoneBookEntry ); |
|
212 |
|
213 // Send Request |
|
214 ret = UiccPbReqWriteL( aTransId, entry.iIndex, *iPhoneBookEntry ); |
|
215 |
|
216 break; |
|
217 } |
|
218 case EMmTsyONStoreWriteIPC: |
|
219 { |
|
220 iFileId = PB_MSISDN_FID; |
|
221 iExtFileId = PB_EXT1_FID; |
|
222 |
|
223 iArrayIndex = EPhonebookTypeMSISDN; |
|
224 |
|
225 TDesC8* entry = NULL; |
|
226 aDataPackage->UnPackData( entry ); |
|
227 |
|
228 // Unpack entry param to get the location |
|
229 RMobileONStore::TMobileONEntryV1Pckg* entryPckg = |
|
230 reinterpret_cast<RMobileONStore::TMobileONEntryV1Pckg*>( entry ); |
|
231 RMobileONStore::TMobileONEntryV1& onEntry = ( *entryPckg )(); |
|
232 |
|
233 iPhoneBookEntry = new( ELeave ) CPhoneBookStoreEntry; |
|
234 CleanupStack::PushL( iPhoneBookEntry ); |
|
235 iPhoneBookEntry->ConstructL(); |
|
236 |
|
237 // Copy index number |
|
238 iPhoneBookEntry->iLocation = onEntry.iIndex; |
|
239 |
|
240 iPhoneBookEntry->iText = HBufC::NewL( KOwnNumberTextSize ); |
|
241 // Copy name |
|
242 TPtr ptrToName ( iPhoneBookEntry->iText->Des() ); |
|
243 CopyData( onEntry.iText, ptrToName ); |
|
244 |
|
245 iPhoneBookEntry->iNumber = HBufC::NewL( KMaxMobileTelNumberSize ); |
|
246 // Copy Number |
|
247 TPtr ptrToNumber( iPhoneBookEntry->iNumber->Des() ); |
|
248 CopyData( onEntry.iNumber.iTelNumber, ptrToNumber ); |
|
249 |
|
250 CleanupStack::Pop( iPhoneBookEntry ); |
|
251 |
|
252 // Send Request |
|
253 ret = UiccPbReqWriteL( aTransId, onEntry.iIndex, *iPhoneBookEntry ); |
|
254 |
|
255 break; |
|
256 } |
|
257 default: |
|
258 { |
194 TFLOGSTRING2("TSY: CMmPhoneBookOperationWrite::UICCCreateReq Unknown Ipc: %d", aIpc); |
259 TFLOGSTRING2("TSY: CMmPhoneBookOperationWrite::UICCCreateReq Unknown Ipc: %d", aIpc); |
195 OstTraceExt1( TRACE_NORMAL, DUP2_CMMPHONEBOOKOPERATIONWRITE_UICCCREATEREQ, "CMmPhoneBookOperationWrite::UICCCreateReq;Unknown aIpc =%hd", aIpc ); |
260 OstTraceExt1( TRACE_NORMAL, DUP2_CMMPHONEBOOKOPERATIONWRITE_UICCCREATEREQ, "CMmPhoneBookOperationWrite::UICCCreateReq;Unknown aIpc =%hd", aIpc ); |
|
261 |
|
262 break; |
|
263 } |
196 } |
264 } |
197 return ret; |
265 return ret; |
198 } |
266 } |
199 |
267 |
200 |
268 |
210 { |
278 { |
211 TFLOGSTRING3("TSY: CMmPhoneBookOperationWrite::SimPbReqWriteL, aTransId:%d,index:%d", aTransId, aIndex); |
279 TFLOGSTRING3("TSY: CMmPhoneBookOperationWrite::SimPbReqWriteL, aTransId:%d,index:%d", aTransId, aIndex); |
212 OstTraceExt2( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_UICCPBREQWRITEL, "CMmPhoneBookOperationWrite::UiccPbReqWriteL;aTransId=%hhu;aIndex=%hd", aTransId, aIndex ); |
280 OstTraceExt2( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_UICCPBREQWRITEL, "CMmPhoneBookOperationWrite::UiccPbReqWriteL;aTransId=%hhu;aIndex=%hd", aTransId, aIndex ); |
213 |
281 |
214 TInt ret( KErrNone ); |
282 TInt ret( KErrNone ); |
215 // Check for no of EXT records required for Writing this Entry |
283 |
216 TUint8 extRecordNo ( 0 ); |
284 if( ( PB_MBDN_FID == iFileId )&& |
217 |
285 ( 0 == iCurrentWritePhase ) ) |
218 if( UICC_EF_FDN_NO_EXT_NUM_LEN < iPhoneBookEntry->iNumber->Length() ) |
286 { |
219 { |
287 iCurrentWritePhase = EPBWritePhase_Read_MBI_profile; |
220 extRecordNo++; |
288 // read MBDN record number from MBI first record |
221 TInt extDataLength = iPhoneBookEntry->iNumber->Length() - |
289 //Profile number |
222 UICC_EF_FDN_NO_EXT_NUM_LEN; |
290 ret = UiccPbReqReadMBI( aIndex, aTransId ); |
223 while ( extDataLength > UICC_EF_EXT_REC_NUM_LEN) |
291 } |
224 { |
292 else |
225 extRecordNo++; |
293 { |
226 extDataLength = extDataLength - UICC_EF_EXT_REC_NUM_LEN; |
294 // Check for no of EXT records required for Writing this Entry |
227 } |
295 TUint8 extRecordNo ( 0 ); |
228 } |
296 GetExtRecNum( extRecordNo ); |
229 |
|
230 // reserve Space for ext record no |
|
231 iExtRecordArrayToBeWrite.ReserveL( extRecordNo ); |
|
232 // File reserved memory with 0 |
|
233 for( TInt count = 0; count < extRecordNo; count++ ) |
|
234 { |
|
235 iExtRecordArrayToBeWrite.Insert( 0 , count ); |
|
236 } |
|
237 |
|
238 // Convert Phone Book name to file id |
|
239 TUint16 fileIdExt ( UICC_ILLEGAL_FILE_ID ); |
|
240 TUint16 pbFileId = ConvertToPBfileId( |
|
241 iPhoneBookTypeName, |
|
242 fileIdExt, |
|
243 iMmUiccMessHandler->GetCardType() ); |
|
244 |
|
245 if( UICC_ILLEGAL_FILE_ID != pbFileId ) |
|
246 { |
|
247 TUint8 pbArrayIndex ( ConvertToConfArrayIndex( pbFileId ) ); |
|
248 |
297 |
249 // Check if the index To read is valid |
298 // Check if the index To read is valid |
250 if( aIndex <= iMmPhoneBookStoreMessHandler-> |
299 if( ( UICC_ILLEGAL_FILE_ID != iFileId ) && |
251 iPBStoreConf[pbArrayIndex].iNoOfRecords ) |
300 ( aIndex <= iMmPhoneBookStoreMessHandler-> |
252 { |
301 iPBStoreConf[iArrayIndex].iNoOfRecords ) ) |
253 // if Entry present in list Store it locally |
302 { |
254 TPBEntry entry; |
|
255 if( 0 < aIndex ) |
303 if( 0 < aIndex ) |
256 { |
304 { |
257 // Check for index present the store list |
305 ret = StartWriteEntryIndex( |
258 if( iMmPhoneBookStoreMessHandler->IndexCheckInPBList( |
|
259 aIndex, |
306 aIndex, |
260 pbArrayIndex, |
307 extRecordNo, |
261 entry ) ) |
308 aTransId, |
262 { |
309 aDataToWrite ); |
263 // Check if Entry is present or not |
|
264 if( entry.iEntryPresent ) |
|
265 { |
|
266 // Check if no if ext records are sufficient from |
|
267 //previous Entry |
|
268 if( extRecordNo > entry.PBEntryExtRecord.Count() ) |
|
269 { |
|
270 // Update old record number which needs to be |
|
271 //updated by new entry |
|
272 if( entry.PBEntryExtRecord.Count() > 0 ) |
|
273 { |
|
274 for( TInt i=0; |
|
275 i < entry.PBEntryExtRecord.Count(); |
|
276 i++ ) |
|
277 { |
|
278 // Append record number to be write from |
|
279 //old Entry |
|
280 iExtRecordArrayToBeWrite.Append( |
|
281 entry.PBEntryExtRecord[i] ); |
|
282 iExtRecordArrayToBeDelete.Append( |
|
283 entry.PBEntryExtRecord[i] ); |
|
284 } |
|
285 } |
|
286 // Search for more free records |
|
287 iCurrentWritePhase = EPBWritePhase_Search_Ext_Entry; |
|
288 |
|
289 // Send request to read first entry in Ext |
|
290 iExtRecordNo = 1 ; |
|
291 ret = UiccPbReqWriteReadExt( |
|
292 pbFileId, |
|
293 fileIdExt, |
|
294 iExtRecordNo, |
|
295 aTransId); |
|
296 } |
|
297 else // when reocrds to be delete and write are 0 or to |
|
298 // be write record less |
|
299 { |
|
300 // Check of both records are 0 |
|
301 if( ( extRecordNo == 0 ) && |
|
302 ( entry.PBEntryExtRecord.Count() == 0 )) |
|
303 { |
|
304 // Start Writing Entry |
|
305 iCurrentWritePhase = EPBWritePhase_Write_Entry; |
|
306 ret = UiccPBReqWriteEntry( |
|
307 pbFileId, |
|
308 aIndex, |
|
309 aTransId, |
|
310 aDataToWrite ); |
|
311 } |
|
312 else |
|
313 { |
|
314 // Start copy Ext record number to be write array |
|
315 for( TInt i=0; i < extRecordNo; i++ ) |
|
316 { |
|
317 // Append record number to be write from old |
|
318 //Entry |
|
319 iExtRecordArrayToBeWrite.Append( |
|
320 entry.PBEntryExtRecord[i]); |
|
321 iExtRecordArrayToBeDelete.Append( |
|
322 entry.PBEntryExtRecord[i]); |
|
323 } |
|
324 // Update records needs to be deleted |
|
325 // From old Entry |
|
326 for( TInt i=extRecordNo; |
|
327 i < entry.PBEntryExtRecord.Count(); |
|
328 i++ ) |
|
329 { |
|
330 // Append record number to be deleted from |
|
331 //old Entry |
|
332 iExtRecordArrayToBeDelete.Append( |
|
333 entry.PBEntryExtRecord[i]); |
|
334 } |
|
335 // Start Deleting the EXT Records |
|
336 iCurrentWritePhase = EPBWritePhase_Write_Ext_Entry; |
|
337 iExtDeleteOperation = ETrue; |
|
338 TUint8 index ( iExtRecordArrayToBeDelete[0] ); |
|
339 // Send request to Write main Entry |
|
340 ret = UiccPbReqWriteExtDelete( |
|
341 pbFileId, |
|
342 fileIdExt, |
|
343 index, |
|
344 aTransId ); |
|
345 } |
|
346 } |
|
347 } |
|
348 else |
|
349 { |
|
350 // If entry not present |
|
351 // Check if EXT Records are needed for Entry to be written |
|
352 if( 0 < extRecordNo ) |
|
353 { |
|
354 // Search for free ext records |
|
355 iCurrentWritePhase = EPBWritePhase_Search_Ext_Entry; |
|
356 |
|
357 // Send request To read First EXT record |
|
358 iExtRecordNo = 1; |
|
359 ret = UiccPbReqWriteReadExt( |
|
360 pbFileId, |
|
361 fileIdExt, |
|
362 iExtRecordNo, |
|
363 aTransId ); |
|
364 } |
|
365 else |
|
366 { |
|
367 // Start Writting Entry |
|
368 iCurrentWritePhase = EPBWritePhase_Write_Entry; |
|
369 TUint8 indexToWrite = iPhoneBookEntry->iLocation; |
|
370 ret = UiccPBReqWriteEntry( |
|
371 pbFileId, |
|
372 indexToWrite, |
|
373 aTransId, |
|
374 aDataToWrite ); |
|
375 } |
|
376 } |
|
377 } // end of if Entry is present in the list |
|
378 else |
|
379 { |
|
380 // First Read that Entry from SIM and then delete that entry |
|
381 // with EXT records if there are Any |
|
382 iCurrentWritePhase = EPBWritePhase_Read_Entry; |
|
383 ret = UiccPbReqWriteRead( pbFileId, aIndex, aTransId ); |
|
384 |
|
385 // read Main entry with given index number |
|
386 } |
|
387 } |
310 } |
388 else |
311 else |
389 { |
312 { |
390 // Start Serching For first free Entry in the Stored list |
313 // Start Serching For first free Entry in the Stored list |
391 TInt index = iMmPhoneBookStoreMessHandler-> |
314 iEntryToWrite = iMmPhoneBookStoreMessHandler-> |
392 EmptyEntryCheckInPBList( pbArrayIndex ); |
315 EmptyEntryCheckInPBList( iArrayIndex ); |
393 if( 0 < index ) |
316 if( 0 < iEntryToWrite ) |
394 { |
317 { |
395 //Check if EXT records Are needed or not |
318 //Check if EXT records Are needed or not |
396 if( 0 < extRecordNo ) |
319 if( 0 < extRecordNo ) |
397 { |
320 { |
398 // Start Serching for EXT records |
321 // Start Serching for EXT records |
399 // Search for free ext records |
322 // Search for free ext records |
400 iCurrentWritePhase = EPBWritePhase_Search_Ext_Entry; |
323 iCurrentWritePhase = EPBWritePhase_Search_Ext_Entry; |
401 |
324 |
402 // Send request To read First EXT record |
325 // Send request To read First EXT record |
403 iExtRecordNo = 1; |
326 iExtRecordNo = 1; |
404 ret = UiccPbReqWriteReadExt( |
327 ret = UiccPbReqWriteReadExt( |
405 pbFileId, |
|
406 fileIdExt, |
|
407 iExtRecordNo, |
328 iExtRecordNo, |
408 aTransId ); |
329 aTransId ); |
409 } |
330 } |
410 else |
331 else |
411 { |
332 { |
412 // Start Writing Entry on given Index |
333 // Start Writing Entry on given Index |
413 // Start Writting Entry |
334 // Start Writting Entry |
414 iCurrentWritePhase = EPBWritePhase_Write_Entry; |
335 iCurrentWritePhase = EPBWritePhase_Write_Entry; |
415 ret = UiccPBReqWriteEntry( |
336 ret = UiccPBReqWriteEntry( |
416 pbFileId, |
337 iEntryToWrite, |
417 index, |
|
418 aTransId, |
338 aTransId, |
419 aDataToWrite ); |
339 aDataToWrite ); |
420 } |
340 } |
421 } |
341 } |
422 else |
342 else |
496 |
409 |
497 TPtr16 ptrToName = aDataToWrite.iText->Des(); |
410 TPtr16 ptrToName = aDataToWrite.iText->Des(); |
498 // Convert the Entry Name from ASCII format to UCS2 |
411 // Convert the Entry Name from ASCII format to UCS2 |
499 CMmStaticUtility::ConvertUcs2ToGsmUcs2Data( ptrToName, nameBuf ); |
412 CMmStaticUtility::ConvertUcs2ToGsmUcs2Data( ptrToName, nameBuf ); |
500 if( nameBuf.Length() < iMmPhoneBookStoreMessHandler-> |
413 if( nameBuf.Length() < iMmPhoneBookStoreMessHandler-> |
501 iPBStoreConf[ arrayIndex ].iAlphaStringlength ) |
414 iPBStoreConf[iArrayIndex].iAlphaStringlength ) |
502 { |
415 { |
503 // Fill rest of the Bytes |
416 // Fill rest of the Bytes |
504 for( TInt count = nameBuf.Length(); count < ( iMmPhoneBookStoreMessHandler-> |
417 for( TInt count = nameBuf.Length(); count < ( iMmPhoneBookStoreMessHandler-> |
505 iPBStoreConf[ arrayIndex ].iAlphaStringlength ); count++ ) |
418 iPBStoreConf[ iArrayIndex ].iAlphaStringlength ); count++ ) |
506 { |
419 { |
507 nameBuf.Append( KTagUnusedbyte ); |
420 nameBuf.Append( KTagUnusedbyte ); |
508 } |
421 } |
509 } |
422 } |
510 TBuf8<300>numberBuf; |
423 TBuf8<300>numberBuf; |
511 TPtr16 ptrToNumber = aDataToWrite.iNumber->Des(); |
424 TPtr16 ptrToNumber = aDataToWrite.iNumber->Des(); |
512 iMmPhoneBookStoreMessHandler->ConvertToBCDFromUCS2( |
425 if( ptrToNumber.Length() > 0 ) |
513 ptrToNumber, |
426 { |
514 numberBuf, |
427 iMmPhoneBookStoreMessHandler->ConvertToBCDFromUCS2( |
515 aFileId ); |
428 ptrToNumber, |
|
429 numberBuf, |
|
430 iFileId ); |
|
431 } |
516 |
432 |
517 // Store number length |
433 // Store number length |
518 TUint8 numLength ( numberBuf.Length() ); |
434 TUint8 numLength ( numberBuf.Length() ); |
519 |
435 |
520 if( numberBuf.Length() < UICC_EF_EXT_REC_NUM_LEN ) |
436 if( numberBuf.Length() < UICC_EF_EXT_REC_NUM_LEN ) |
867 |
770 |
868 return ret ; |
771 return ret ; |
869 } |
772 } |
870 |
773 |
871 |
774 |
|
775 |
872 // --------------------------------------------------------------------------- |
776 // --------------------------------------------------------------------------- |
873 // CMmPhoneBookOperationWrite::UiccPbReqReadMBI |
777 // CMmPhoneBookOperationWrite::UiccPbReqReadMBI |
874 // Constructs an ISI-message to Read MBI profile from first record |
778 // Constructs an ISI-message to Read MBI profile from first record |
875 // --------------------------------------------------------------------------- |
779 // --------------------------------------------------------------------------- |
876 // |
780 // |
877 TInt CMmPhoneBookOperationWrite::UiccPbReqReadMBI( TUint8 aIndex, TUint8 aTransId ) |
781 TInt CMmPhoneBookOperationWrite::StartWriteEntryIndex( |
|
782 TUint16 aIndex, |
|
783 TUint8 aExtRecNo, |
|
784 TUint8 aTransId, |
|
785 CPhoneBookStoreEntry& aDataToWrite ) |
|
786 { |
|
787 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::StartWriteForEntryPresentInList"); |
|
788 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_STARTWRITEFORENTRYPRESENTINLIST, "CMmPhoneBookOperationWrite::StartWriteForEntryPresentInList" ); |
|
789 |
|
790 TInt ret( KErrNone ); |
|
791 // if Entry present in list Store it locally |
|
792 TPBEntry entry; |
|
793 // Check for index present the store list |
|
794 if( iMmPhoneBookStoreMessHandler->IndexCheckInPBList( |
|
795 aIndex, |
|
796 iArrayIndex, |
|
797 entry ) ) |
|
798 { |
|
799 // Check if Entry is present or not |
|
800 if( entry.iEntryPresent ) |
|
801 { |
|
802 // Check if no if ext records are sufficient from |
|
803 //previous Entry |
|
804 if( aExtRecNo > entry.PBEntryExtRecord.Count() ) |
|
805 { |
|
806 ret = CheckForExtRecordNum( entry, aTransId ); |
|
807 } |
|
808 else |
|
809 { |
|
810 // check for reocrds to be delete |
|
811 ret = ContinueWriteEntry( aExtRecNo, |
|
812 entry, |
|
813 aTransId, |
|
814 aDataToWrite ); |
|
815 } |
|
816 } |
|
817 else |
|
818 { |
|
819 // If entry not present |
|
820 // Check if EXT Records are needed for Entry to be written |
|
821 if( 0 < aExtRecNo ) |
|
822 { |
|
823 // Search for free ext records |
|
824 iCurrentWritePhase = EPBWritePhase_Search_Ext_Entry; |
|
825 // Send request To read First EXT record |
|
826 iExtRecordNo = 1; |
|
827 ret = UiccPbReqWriteReadExt( |
|
828 iExtRecordNo, |
|
829 aTransId ); |
|
830 } |
|
831 else |
|
832 { |
|
833 // Start Writting Entry |
|
834 iCurrentWritePhase = EPBWritePhase_Write_Entry; |
|
835 TUint8 indexToWrite = iPhoneBookEntry->iLocation; |
|
836 ret = UiccPBReqWriteEntry( |
|
837 indexToWrite, |
|
838 aTransId, |
|
839 aDataToWrite ); |
|
840 } |
|
841 } |
|
842 } // end of if Entry is present in the list |
|
843 else |
|
844 { |
|
845 // First Read that Entry from SIM and then delete that entry |
|
846 // with EXT records if there are Any |
|
847 iCurrentWritePhase = EPBWritePhase_Read_Entry; |
|
848 ret = UiccPbReqWriteRead( aIndex, aTransId ); |
|
849 } |
|
850 |
|
851 return ret; |
|
852 } |
|
853 |
|
854 |
|
855 // --------------------------------------------------------------------------- |
|
856 // CMmPhoneBookOperationWrite::UiccPbReqReadMBI |
|
857 // Constructs an ISI-message to Read MBI profile from first record |
|
858 // --------------------------------------------------------------------------- |
|
859 // |
|
860 TInt CMmPhoneBookOperationWrite::UiccPbReqReadMBI( TUint8 aOffset, TUint8 aTransId ) |
878 { |
861 { |
879 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::UiccPbReqReadMBI"); |
862 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::UiccPbReqReadMBI"); |
880 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONWRITE_UICCPBREQREADMBI, "CMmPhoneBookOperationWrite::UiccPbReqReadMBI" ); |
863 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONWRITE_UICCPBREQREADMBI, "CMmPhoneBookOperationWrite::UiccPbReqReadMBI" ); |
881 |
864 |
882 TInt ret ( KErrNone ); |
865 TInt ret ( KErrNone ); |
982 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_HANDLEUICCPBRESPL, "CMmPhoneBookOperationWrite::HandleUICCPbRespL" ); |
975 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_HANDLEUICCPBRESPL, "CMmPhoneBookOperationWrite::HandleUICCPbRespL" ); |
983 |
976 |
984 TBool complete ( EFalse ); |
977 TBool complete ( EFalse ); |
985 TInt ret ( KErrNone ); |
978 TInt ret ( KErrNone ); |
986 |
979 |
987 TUint16 fileIdExt ( 0x0000 ); |
|
988 TUint16 fileId = ConvertToPBfileId( iPhoneBookTypeName, fileIdExt, iMmUiccMessHandler->GetCardType() ); |
|
989 //// Check for PhoenBook Index for which needs to checked |
|
990 TUint8 pbArrayIndex = ConvertToConfArrayIndex( fileId ); |
|
991 |
|
992 switch( iCurrentWritePhase ) |
980 switch( iCurrentWritePhase ) |
993 { |
981 { |
994 case EPBWritePhase_Read_Entry: |
982 case EPBWritePhase_Read_Entry: |
995 { |
983 { |
996 ret = HandleWriteReadEntryResp( |
984 ret = HandleWriteReadEntryResp( |
997 aStatus, |
985 aStatus, |
998 aFileData, |
986 aFileData, |
999 aTransId, |
987 aTransId ); |
1000 fileId, |
|
1001 fileIdExt, |
|
1002 pbArrayIndex ); |
|
1003 break; |
988 break; |
1004 } |
989 } |
1005 case EPBWritePhase_Read_Ext_Entry: |
990 case EPBWritePhase_Read_Ext_Entry: |
1006 { |
991 { |
1007 ret = HandleWriteReadExtEntryResp( |
992 ret = HandleWriteReadExtEntryResp( |
1008 aStatus, |
993 aStatus, |
1009 aFileData, |
994 aFileData, |
1010 aTransId, |
995 aTransId ); |
1011 fileId, |
|
1012 fileIdExt ); |
|
1013 break; |
996 break; |
1014 } |
997 } |
1015 case EPBWritePhase_Search_Ext_Entry: |
998 case EPBWritePhase_Search_Ext_Entry: |
1016 { |
999 { |
1017 ret = HandleWriteSearchExtEntryResp( |
1000 ret = HandleWriteSearchExtEntryResp( |
1018 aStatus, |
1001 aStatus, |
1019 aFileData, |
1002 aFileData, |
1020 aTransId, |
1003 aTransId ); |
1021 fileId, |
|
1022 fileIdExt ); |
|
1023 break; |
1004 break; |
1024 } |
1005 } |
1025 case EPBWritePhase_Write_Entry: |
1006 case EPBWritePhase_Write_Entry: |
1026 { |
1007 { |
1027 ret = HandleWriteEntryResp( |
1008 ret = HandleWriteEntryResp( |
1028 aStatus, |
1009 aStatus, |
1029 aTransId, |
1010 aTransId ); |
1030 fileId, |
|
1031 fileIdExt ); |
|
1032 break; |
1011 break; |
1033 } |
1012 } |
1034 case EPBWritePhase_Write_Ext_Entry: |
1013 case EPBWritePhase_Write_Ext_Entry: |
1035 { |
1014 { |
1036 ret = HandleWriteExtEntryResp( |
1015 ret = HandleWriteExtEntryResp( |
1037 aStatus, |
1016 aStatus, |
1038 aTransId, |
1017 aTransId ); |
1039 fileId, |
|
1040 fileIdExt ); |
|
1041 break; |
1018 break; |
1042 } |
1019 } |
1043 case EPBWritePhase_Read_MBI_profile: |
1020 case EPBWritePhase_Read_MBI_profile: |
1044 { |
1021 { |
1045 ret = HandleWriteMBIReadResp( |
1022 ret = HandleWriteMBIReadResp( |
1064 } |
1041 } |
1065 } |
1042 } |
1066 |
1043 |
1067 if( ( KErrNone != ret ) || ( iCurrentWritePhase == EPBWritePhase_complete )) |
1044 if( ( KErrNone != ret ) || ( iCurrentWritePhase == EPBWritePhase_complete )) |
1068 { |
1045 { |
1069 // Complete the to common TSY |
1046 switch( iSavedIpc ) |
1070 CPhoneBookDataPackage phoneBookData; |
1047 { |
1071 |
1048 case EMmTsyONStoreWriteIPC: |
1072 //create a struct |
1049 { |
1073 TPBEntryInfo pbEntryInfo; |
1050 // Reset SavedIpc IPC. |
1074 // Set the structure as it has failed, we don't care of following |
1051 iSavedIpc = 0; |
1075 // information so set to 0 |
1052 if( KErrNone != ret ) |
1076 pbEntryInfo.iMaxNumLength = 0; |
1053 { |
1077 pbEntryInfo.iLocation = 0; |
1054 // Complete failed request |
1078 if( KErrNone == ret ) |
1055 iMmPhoneBookStoreMessHandler->MessageRouter()->Complete( |
1079 { |
1056 EMmTsyONStoreWriteIPC, |
1080 pbEntryInfo.iLocation = iPhoneBookEntry->iLocation; |
1057 NULL, |
1081 } |
1058 ret ); |
1082 // For EXT file Errors need not to pass to commontsy |
1059 } |
1083 if( KErrGeneral == ret ) |
1060 else |
1084 { |
1061 { |
1085 ret = KErrNone; |
1062 // Create data package |
1086 } |
1063 CMmDataPackage numberData; |
1087 phoneBookData.SetPhoneBookName( iPhoneBookTypeName ); |
1064 numberData.PackData( &iPhoneBookEntry->iLocation ); |
1088 |
1065 |
1089 //Pack Data and complete |
1066 // Complete request |
1090 phoneBookData.PackData( &pbEntryInfo ); |
1067 iMmPhoneBookStoreMessHandler->MessageRouter()->Complete( |
1091 iMmPhoneBookStoreMessHandler->MessageRouter()->Complete( |
1068 EMmTsyONStoreWriteIPC, |
1092 EMmTsyPhoneBookStoreWriteIPC, |
1069 &numberData, |
1093 &phoneBookData, |
1070 ret ); |
1094 ret ); |
1071 } |
1095 |
1072 |
|
1073 // delete PhoneBook Entry |
|
1074 delete iPhoneBookEntry; |
|
1075 break; |
|
1076 } |
|
1077 case EMmTsyONStoreWriteEntryIPC: |
|
1078 { |
|
1079 // Reset saved IPC. |
|
1080 iSavedIpc = 0; |
|
1081 // Complete request |
|
1082 iMmPhoneBookStoreMessHandler->MessageRouter()->Complete( |
|
1083 EMmTsyONStoreWriteEntryIPC, |
|
1084 ret ); |
|
1085 |
|
1086 // Delete Phone Book Entry |
|
1087 delete iPhoneBookEntry; |
|
1088 break; |
|
1089 } |
|
1090 case EMmTsyPhoneBookStoreWriteIPC: |
|
1091 { |
|
1092 // Complete the to common TSY |
|
1093 CPhoneBookDataPackage phoneBookData; |
|
1094 |
|
1095 //create a struct |
|
1096 TPBEntryInfo pbEntryInfo; |
|
1097 // Set the structure as it has failed, we don't care of following |
|
1098 // information so set to 0 |
|
1099 pbEntryInfo.iMaxNumLength = 0; |
|
1100 pbEntryInfo.iLocation = 0; |
|
1101 if( KErrNone == ret ) |
|
1102 { |
|
1103 // Convert Phone Book name to file id |
|
1104 pbEntryInfo.iMaxNumLength = iMmPhoneBookStoreMessHandler-> |
|
1105 iPBStoreConf[iArrayIndex].iNumlength; |
|
1106 if( 0 != iPhoneBookEntry->iLocation ) |
|
1107 { |
|
1108 pbEntryInfo.iLocation = iPhoneBookEntry->iLocation; |
|
1109 } |
|
1110 else |
|
1111 { |
|
1112 pbEntryInfo.iLocation = iEntryToWrite; |
|
1113 } |
|
1114 } |
|
1115 // For EXT file Errors need not to pass to commontsy |
|
1116 if( KErrGeneral == ret ) |
|
1117 { |
|
1118 ret = KErrNone; |
|
1119 } |
|
1120 phoneBookData.SetPhoneBookName( iPhoneBookTypeName ); |
|
1121 |
|
1122 //Pack Data and complete |
|
1123 phoneBookData.PackData( &pbEntryInfo ); |
|
1124 iMmPhoneBookStoreMessHandler->MessageRouter()->Complete( |
|
1125 EMmTsyPhoneBookStoreWriteIPC, |
|
1126 &phoneBookData, |
|
1127 ret ); |
|
1128 break; |
|
1129 } |
|
1130 default: |
|
1131 { |
|
1132 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::HandleSimPbRespL - unknown Ipc "); |
|
1133 OstTrace0( TRACE_NORMAL, DUP2_CMMPHONEBOOKOPERATIONWRITE_HANDLEUICCPBRESPL, "CMmPhoneBookOperationWrite::HandleUICCPbRespL - unknown Ipc" ); |
|
1134 break; |
|
1135 } |
|
1136 } |
1096 // set flag to indicate that we can remove this operation from array |
1137 // set flag to indicate that we can remove this operation from array |
1097 complete = ETrue; |
1138 complete = ETrue; |
1098 } |
1139 } |
1099 return complete; |
1140 return complete; |
1100 } |
1141 } |
1140 iCurrentWritePhase = EPBWritePhase_Search_Ext_Entry; |
1178 iCurrentWritePhase = EPBWritePhase_Search_Ext_Entry; |
1141 |
1179 |
1142 // Send request to read first entry in Ext |
1180 // Send request to read first entry in Ext |
1143 iExtRecordNo = 1; |
1181 iExtRecordNo = 1; |
1144 ret = UiccPbReqWriteReadExt( |
1182 ret = UiccPbReqWriteReadExt( |
1145 aFileId, |
|
1146 aFileIdExt, |
|
1147 iExtRecordNo, |
1183 iExtRecordNo, |
1148 aTransId ); |
1184 aTransId ); |
1149 } |
1185 } |
1150 else |
1186 else |
1151 { |
1187 { |
1152 // Start Write main Entry |
1188 // Start Write main Entry |
1153 iCurrentWritePhase = EPBWritePhase_Write_Entry; |
1189 iCurrentWritePhase = EPBWritePhase_Write_Entry; |
1154 TUint8 indexToWrite ( 0 ); |
1190 TUint8 indexToWrite ( 0 ); |
1155 if( PB_MBDN_FID == aFileId ) |
1191 if( PB_MBDN_FID == iFileId ) |
1156 { |
1192 { |
1157 indexToWrite = iEntryToWrite; |
1193 indexToWrite = iEntryToWrite; |
1158 } |
1194 } |
1159 else |
1195 else |
1160 { |
1196 { |
1161 indexToWrite = iPhoneBookEntry->iLocation; |
1197 indexToWrite = iPhoneBookEntry->iLocation; |
1162 } |
1198 } |
1163 ret = UiccPBReqWriteEntry( |
1199 ret = UiccPBReqWriteEntry( |
1164 aFileId, |
|
1165 indexToWrite, |
1200 indexToWrite, |
1166 aTransId, |
1201 aTransId, |
1167 *iPhoneBookEntry ); |
1202 *iPhoneBookEntry ); |
1168 } |
1203 } |
1169 } |
1204 } |
1170 else |
1205 else |
1171 { |
1206 { |
1172 // Append this Record number to be Delete record Array |
1207 // Append this Record number to be Delete record Array |
1173 iExtRecordArrayToBeDelete.Append( |
1208 iExtRecordArrayToBeDelete.Append( |
1174 iMmPhoneBookStoreMessHandler-> |
1209 iMmPhoneBookStoreMessHandler-> |
1175 iPBStoreConf[aArrayIndex].iAlphaStringlength+ 13 ); |
1210 iPBStoreConf[iArrayIndex].iAlphaStringlength+ 13 ); |
1176 |
1211 |
1177 // Start Reading EXT Record |
1212 // Start Reading EXT Record |
1178 iCurrentWritePhase = EPBWritePhase_Read_Ext_Entry; |
1213 iCurrentWritePhase = EPBWritePhase_Read_Ext_Entry; |
1179 TUint8 indexToRead = iMmPhoneBookStoreMessHandler-> |
1214 TUint8 indexToRead = iMmPhoneBookStoreMessHandler-> |
1180 iPBStoreConf[aArrayIndex].iAlphaStringlength+ 13; |
1215 iPBStoreConf[iArrayIndex].iAlphaStringlength+ 13; |
1181 ret = UiccPbReqWriteReadExt( |
1216 ret = UiccPbReqWriteReadExt( |
1182 aFileId, |
|
1183 aFileIdExt, |
|
1184 indexToRead, |
1217 indexToRead, |
1185 aTransId ); |
1218 aTransId ); |
1186 } |
1219 } |
1187 } |
1220 } |
1188 else |
1221 else |
1505 // Handle write response for EXT part of Entry |
1513 // Handle write response for EXT part of Entry |
1506 // --------------------------------------------------------------------------- |
1514 // --------------------------------------------------------------------------- |
1507 // |
1515 // |
1508 TInt CMmPhoneBookOperationWrite::HandleWriteEntryResp( |
1516 TInt CMmPhoneBookOperationWrite::HandleWriteEntryResp( |
1509 TInt aStatus, |
1517 TInt aStatus, |
1510 TUint8 aTransId, |
1518 TUint8 aTransId ) |
1511 TUint16 aFileId, |
|
1512 TUint16 aFileIdExt) |
|
1513 { |
1519 { |
1514 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::HandleWriteEntryResp"); |
1520 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::HandleWriteEntryResp"); |
1515 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_HANDLEWRITEENTRYRESP, "CMmPhoneBookOperationWrite::HandleWriteEntryResp" ); |
1521 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_HANDLEWRITEENTRYRESP, "CMmPhoneBookOperationWrite::HandleWriteEntryResp" ); |
1516 TInt ret ( KErrNone ); |
1522 TInt ret ( KErrNone ); |
1517 TUint8 arrayIndex ( ConvertToConfArrayIndex( aFileId )); |
1523 |
1518 |
|
1519 if( UICC_STATUS_OK == aStatus ) |
1524 if( UICC_STATUS_OK == aStatus ) |
1520 { |
1525 { |
1521 iEntryToUpdateInList = new ( ELeave ) TPBEntry(); |
1526 iEntryToUpdateInList = new ( ELeave ) TPBEntry(); |
1522 |
1527 |
1523 // Update the Entry needs to be Stored |
1528 // Update the Entry needs to be Stored |
1524 if( ( 0 == iPhoneBookEntry->iLocation )|| ( PB_MBDN_FID == aFileId ) ) |
1529 if( ( 0 == iPhoneBookEntry->iLocation )|| ( PB_MBDN_FID == iFileId ) ) |
1525 { |
1530 { |
1526 iEntryToUpdateInList->iEntryIndex = iEntryToWrite; |
1531 iEntryToUpdateInList->iEntryIndex = iEntryToWrite; |
1527 iEntryToUpdateInList->iEntryPresent = ETrue; |
1532 iEntryToUpdateInList->iEntryPresent = ETrue; |
1528 } |
1533 } |
1529 else |
1534 else |
1541 // Start Writing to EXT records |
1546 // Start Writing to EXT records |
1542 TUint8 index = iExtRecordArrayToBeWrite[0]; |
1547 TUint8 index = iExtRecordArrayToBeWrite[0]; |
1543 ret = UiccPbReqWriteExt( |
1548 ret = UiccPbReqWriteExt( |
1544 aTransId, |
1549 aTransId, |
1545 index, |
1550 index, |
1546 aFileId, |
|
1547 aFileIdExt, |
|
1548 *iPhoneBookEntry ); |
1551 *iPhoneBookEntry ); |
1549 } |
1552 } |
1550 else |
1553 else |
1551 { |
1554 { |
1552 // Remove old Entry from the list |
1555 // Remove old Entry from the list |
1553 TInt index = iMmPhoneBookStoreMessHandler-> |
1556 TInt index = iMmPhoneBookStoreMessHandler-> |
1554 GetIndexForPresentEntry( iPhoneBookEntry->iLocation, arrayIndex ); |
1557 GetIndexForPresentEntry( iPhoneBookEntry->iLocation, iArrayIndex ); |
1555 if( 0 <= index ) |
1558 if( 0 <= index ) |
1556 { |
1559 { |
1557 iMmPhoneBookStoreMessHandler->UpdateEntryFromList( |
1560 iMmPhoneBookStoreMessHandler->UpdateEntryFromList( |
1558 iEntryToUpdateInList, |
1561 iEntryToUpdateInList, |
1559 index, |
1562 index, |
1560 arrayIndex ); |
1563 iArrayIndex ); |
1561 } |
1564 } |
1562 else |
1565 else |
1563 { |
1566 { |
1564 // Append the Entry to the List |
1567 // Append the Entry to the List |
1565 iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList( |
1568 iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList( |
1566 iEntryToUpdateInList, |
1569 iEntryToUpdateInList, |
1567 arrayIndex ); |
1570 iArrayIndex ); |
1568 } |
1571 } |
1569 // If it is MBDN Phone Book then update MBI File also |
1572 // If it is MBDN Phone Book then update MBI File also |
1570 if( PB_MBDN_FID == aFileId) |
1573 if( PB_MBDN_FID == iFileId) |
1571 { |
1574 { |
1572 // Start Writing MBI file |
1575 // Start Writing MBI file |
1573 iCurrentWritePhase = EPBWritePhase_Write_MBI_profile; |
1576 iCurrentWritePhase = EPBWritePhase_Write_MBI_profile; |
1574 ret = UiccPBReqWriteMBIProfile( |
1577 ret = UiccPBReqWriteMBIProfile( |
1575 aTransId, |
1578 aTransId, |
1635 iExtRecordArrayToBeDelete.Compress(); |
1635 iExtRecordArrayToBeDelete.Compress(); |
1636 } |
1636 } |
1637 // Remove old Entry from the list |
1637 // Remove old Entry from the list |
1638 TInt index = iMmPhoneBookStoreMessHandler->GetIndexForPresentEntry( |
1638 TInt index = iMmPhoneBookStoreMessHandler->GetIndexForPresentEntry( |
1639 iPhoneBookEntry->iLocation, |
1639 iPhoneBookEntry->iLocation, |
1640 arrayIndex ); |
1640 iArrayIndex ); |
1641 if( 0 <= index ) |
1641 if( 0 <= index ) |
1642 { |
1642 { |
1643 iMmPhoneBookStoreMessHandler->RemoveExtEntryFromList( |
1643 iMmPhoneBookStoreMessHandler->RemoveExtEntryFromList( |
1644 index, |
1644 index, |
1645 arrayIndex); |
1645 iArrayIndex); |
1646 } |
1646 } |
1647 |
1647 |
1648 if( iExtRecordArrayToBeDelete.Count() > 0 ) |
1648 if( iExtRecordArrayToBeDelete.Count() > 0 ) |
1649 { |
1649 { |
1650 iCurrentWritePhase = EPBWritePhase_Write_Ext_Entry; |
1650 iCurrentWritePhase = EPBWritePhase_Write_Ext_Entry; |
1651 iExtDeleteOperation = ETrue; |
1651 iExtDeleteOperation = ETrue; |
1652 TUint8 index = iExtRecordArrayToBeDelete[ |
1652 TUint8 index = iExtRecordArrayToBeDelete[ |
1653 iExtRecordArrayToBeDelete.Count() -1 ]; |
1653 iExtRecordArrayToBeDelete.Count() -1 ]; |
1654 ret = UiccPbReqWriteExtDelete( |
1654 ret = UiccPbReqWriteExtDelete( |
1655 aFileId, |
|
1656 aFileIdExt, |
|
1657 index, |
1655 index, |
1658 aTransId ); |
1656 aTransId ); |
1659 } |
1657 } |
1660 else |
1658 else |
1661 { |
1659 { |
1662 // Start Writing the Entry |
1660 // Start Writing the Entry |
1663 iCurrentWritePhase = EPBWritePhase_Write_Entry; |
1661 iCurrentWritePhase = EPBWritePhase_Write_Entry; |
1664 TUint8 index ( 0 ); |
1662 TUint8 index ( 0 ); |
1665 // Start writing main Entry |
1663 // Start writing main Entry |
1666 if( ( iPhoneBookEntry->iLocation == 0 )|| |
1664 if( ( iPhoneBookEntry->iLocation == 0 )|| |
1667 ( PB_MBDN_FID == aFileId ) ) |
1665 ( PB_MBDN_FID == iFileId ) ) |
1668 { |
1666 { |
1669 index = iEntryToWrite; |
1667 index = iEntryToWrite; |
1670 } |
1668 } |
1671 else |
1669 else |
1672 { |
1670 { |
1673 index = iPhoneBookEntry->iLocation; |
1671 index = iPhoneBookEntry->iLocation; |
1674 } |
1672 } |
1675 if( 0 < index ) |
1673 if( 0 < index ) |
1676 { |
1674 { |
1677 ret = UiccPBReqWriteEntry( |
1675 ret = UiccPBReqWriteEntry( |
1678 aFileId, |
|
1679 index, |
1676 index, |
1680 aTransId, |
1677 aTransId, |
1681 *iPhoneBookEntry ); |
1678 *iPhoneBookEntry ); |
1682 } |
1679 } |
1683 else |
1680 else |
1703 iEntryToUpdateInList->PBEntryExtRecord.Append( iExtRecordArrayToBeWrite[0] ); |
1700 iEntryToUpdateInList->PBEntryExtRecord.Append( iExtRecordArrayToBeWrite[0] ); |
1704 TUint8 index = iExtRecordArrayToBeWrite[0]; |
1701 TUint8 index = iExtRecordArrayToBeWrite[0]; |
1705 ret = UiccPbReqWriteExt( |
1702 ret = UiccPbReqWriteExt( |
1706 aTransId, |
1703 aTransId, |
1707 index, |
1704 index, |
1708 aFileId, |
|
1709 aFileIdExt, |
|
1710 *iPhoneBookEntry ); |
1705 *iPhoneBookEntry ); |
1711 } |
1706 } |
1712 else |
1707 else |
1713 { |
1708 { |
1714 // Overwrite old Entry from the list |
1709 // Overwrite old Entry from the list |
1715 TInt index = iMmPhoneBookStoreMessHandler-> |
1710 TInt index = iMmPhoneBookStoreMessHandler-> |
1716 GetIndexForPresentEntry( |
1711 GetIndexForPresentEntry( |
1717 iPhoneBookEntry->iLocation, |
1712 iPhoneBookEntry->iLocation, |
1718 arrayIndex ); |
1713 iArrayIndex ); |
1719 if( 0 <= index ) |
1714 if( 0 <= index ) |
1720 { |
1715 { |
1721 iMmPhoneBookStoreMessHandler->UpdateEntryFromList( |
1716 iMmPhoneBookStoreMessHandler->UpdateEntryFromList( |
1722 iEntryToUpdateInList, |
1717 iEntryToUpdateInList, |
1723 index, |
1718 index, |
1724 arrayIndex ); |
1719 iArrayIndex ); |
1725 } |
1720 } |
1726 else |
1721 else |
1727 { |
1722 { |
1728 // Append the Entry to the List |
1723 // Append the Entry to the List |
1729 iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList( |
1724 iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList( |
1730 iEntryToUpdateInList, |
1725 iEntryToUpdateInList, |
1731 arrayIndex ); |
1726 iArrayIndex ); |
1732 } |
1727 } |
1733 // If it is MBDN PhoenBook then update MBI Profile also |
1728 // If it is MBDN PhoenBook then update MBI Profile also |
1734 if( PB_MBDN_FID == aFileId) |
1729 if( PB_MBDN_FID == iFileId) |
1735 { |
1730 { |
1736 // Start Writing MBI file |
1731 // Start Writing MBI file |
1737 iCurrentWritePhase = EPBWritePhase_Write_MBI_profile; |
1732 iCurrentWritePhase = EPBWritePhase_Write_MBI_profile; |
1738 ret = UiccPBReqWriteMBIProfile( |
1733 ret = UiccPBReqWriteMBIProfile( |
1739 aTransId, |
1734 aTransId, |
1840 else |
1835 else |
1841 { |
1836 { |
1842 ret = KErrArgument; |
1837 ret = KErrArgument; |
1843 } |
1838 } |
1844 } |
1839 } |
1845 |
|
1846 |
|
1847 return ret; |
1840 return ret; |
1848 } |
1841 } |
1849 |
1842 |
|
1843 |
|
1844 |
|
1845 |
|
1846 // --------------------------------------------------------------------------- |
|
1847 // void CMmPhoneBookOperationWrite::GetExtRecNum |
|
1848 // Get the total number of Ext records needed for new entry |
|
1849 // --------------------------------------------------------------------------- |
|
1850 // |
|
1851 void CMmPhoneBookOperationWrite::GetExtRecNum( TUint8 &aExtRecordNo ) |
|
1852 { |
|
1853 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::GetExtRecNum"); |
|
1854 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONWRITE_UICCPBREQWRITEMSISDN, "CMmPhoneBookOperationWrite::UiccPbReqWriteMsisdn" ); |
|
1855 |
|
1856 |
|
1857 if( UICC_EF_FDN_NO_EXT_NUM_LEN < iPhoneBookEntry->iNumber->Length() ) |
|
1858 { |
|
1859 aExtRecordNo++; |
|
1860 TInt extDataLength = iPhoneBookEntry->iNumber->Length() - |
|
1861 UICC_EF_FDN_NO_EXT_NUM_LEN; |
|
1862 while ( extDataLength > UICC_EF_EXT_REC_NUM_LEN) |
|
1863 { |
|
1864 aExtRecordNo++; |
|
1865 extDataLength = extDataLength - UICC_EF_EXT_REC_NUM_LEN; |
|
1866 } |
|
1867 } |
|
1868 |
|
1869 // reserve Space for ext record no |
|
1870 iExtRecordArrayToBeWrite.ReserveL( aExtRecordNo ); |
|
1871 // File reserved memory with 0 |
|
1872 for( TInt count = 0; count < aExtRecordNo; count++ ) |
|
1873 { |
|
1874 iExtRecordArrayToBeWrite.Insert( 0, count ); |
|
1875 } |
|
1876 } |
|
1877 |
|
1878 |
|
1879 |
|
1880 // --------------------------------------------------------------------------- |
|
1881 // void CMmPhoneBookOperationWrite::CheckForExtRecordNum |
|
1882 // Check for EXT number of records for new Entry is sufficiet or not |
|
1883 // --------------------------------------------------------------------------- |
|
1884 // |
|
1885 TInt CMmPhoneBookOperationWrite::CheckForExtRecordNum( |
|
1886 TPBEntry entry, |
|
1887 TUint8 aTransId ) |
|
1888 { |
|
1889 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::CheckForExtRecordNum"); |
|
1890 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_CHECKFOREXTRECORDNUM, "CMmPhoneBookOperationWrite::CheckForExtRecordNum" ); |
|
1891 |
|
1892 TInt ret( KErrNone ); |
|
1893 |
|
1894 // Update old record number which needs to be |
|
1895 //updated by new entry |
|
1896 if( entry.PBEntryExtRecord.Count() > 0 ) |
|
1897 { |
|
1898 for( TInt i=0; |
|
1899 i < entry.PBEntryExtRecord.Count(); |
|
1900 i++ ) |
|
1901 { |
|
1902 // Append record number to be write from |
|
1903 //old Entry |
|
1904 iExtRecordArrayToBeWrite.Append( |
|
1905 entry.PBEntryExtRecord[i] ); |
|
1906 iExtRecordArrayToBeDelete.Append( |
|
1907 entry.PBEntryExtRecord[i] ); |
|
1908 } |
|
1909 } |
|
1910 // Search for more free records |
|
1911 iCurrentWritePhase = EPBWritePhase_Search_Ext_Entry; |
|
1912 |
|
1913 // Send request to read first entry in Ext |
|
1914 iExtRecordNo = 1 ; |
|
1915 ret = UiccPbReqWriteReadExt( |
|
1916 iExtRecordNo, |
|
1917 aTransId); |
|
1918 |
|
1919 return ret; |
|
1920 } |
|
1921 |
|
1922 |
|
1923 |
|
1924 // --------------------------------------------------------------------------- |
|
1925 // void CMmPhoneBookOperationWrite::ContinueWriteEntry |
|
1926 // Check for records to deleted else start writing new entry |
|
1927 // --------------------------------------------------------------------------- |
|
1928 // |
|
1929 TInt CMmPhoneBookOperationWrite::ContinueWriteEntry( |
|
1930 TUint8 aExtRecNo, |
|
1931 TPBEntry entry, |
|
1932 TUint8 aTransId, |
|
1933 CPhoneBookStoreEntry& aDataToWrite ) |
|
1934 { |
|
1935 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::ContinueWriteEntry"); |
|
1936 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_CONTINUEWRITEENTRY, "CMmPhoneBookOperationWrite::ContinueWriteEntry" ); |
|
1937 |
|
1938 TInt ret( KErrNone ); |
|
1939 |
|
1940 // Check of both records are 0 |
|
1941 if( ( aExtRecNo == 0 ) && |
|
1942 ( entry.PBEntryExtRecord.Count() == 0 )) |
|
1943 { |
|
1944 // Start Writing Entry |
|
1945 iCurrentWritePhase = EPBWritePhase_Write_Entry; |
|
1946 ret = UiccPBReqWriteEntry( |
|
1947 iPhoneBookEntry->iLocation, |
|
1948 aTransId, |
|
1949 aDataToWrite ); |
|
1950 } |
|
1951 else |
|
1952 { |
|
1953 // Start copy Ext record number to be write array |
|
1954 for( TInt i=0; i < aExtRecNo; i++ ) |
|
1955 { |
|
1956 // Append record number to be write from old |
|
1957 //Entry |
|
1958 iExtRecordArrayToBeWrite.Append( |
|
1959 entry.PBEntryExtRecord[i]); |
|
1960 iExtRecordArrayToBeDelete.Append( |
|
1961 entry.PBEntryExtRecord[i]); |
|
1962 } |
|
1963 // Update records needs to be deleted |
|
1964 // From old Entry |
|
1965 for( TInt i=aExtRecNo; |
|
1966 i < entry.PBEntryExtRecord.Count(); |
|
1967 i++ ) |
|
1968 { |
|
1969 // Append record number to be deleted from |
|
1970 //old Entry |
|
1971 iExtRecordArrayToBeDelete.Append( |
|
1972 entry.PBEntryExtRecord[i]); |
|
1973 } |
|
1974 // Start Deleting the EXT Records |
|
1975 iCurrentWritePhase = EPBWritePhase_Write_Ext_Entry; |
|
1976 iExtDeleteOperation = ETrue; |
|
1977 TUint8 index ( iExtRecordArrayToBeDelete[0] ); |
|
1978 // Send request to Write main Entry |
|
1979 ret = UiccPbReqWriteExtDelete( |
|
1980 index, |
|
1981 aTransId ); |
|
1982 } |
|
1983 |
|
1984 return ret; |
|
1985 } |
|
1986 |
|
1987 // --------------------------------------------------------------------------- |
|
1988 // void CMmPhoneBookOperationWrite::GetExtRecNum |
|
1989 // Get the total number of Ext records needed for new entry |
|
1990 // --------------------------------------------------------------------------- |
|
1991 // |
|
1992 void CMmPhoneBookOperationWrite::CopyData( const TDesC16& aSource, TDes16& aTarget ) |
|
1993 { |
|
1994 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::CopyData"); |
|
1995 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_COPYDATA, "CMmPhoneBookOperationWrite::CopyData" ); |
|
1996 |
|
1997 TInt temp ( aSource.Length() ); |
|
1998 TInt temp1( aTarget.MaxLength() ); |
|
1999 if( aSource.Length() <= aTarget.MaxLength() ) |
|
2000 { |
|
2001 // Start Copy Data |
|
2002 for( TInt count(0); count < aSource.Length(); count++ ) |
|
2003 { |
|
2004 aTarget.Append( aSource[count] ); |
|
2005 } |
|
2006 } |
|
2007 } |
|
2008 |
1850 // End of file |
2009 // End of file |