adaptationlayer/tsy/nokiatsy_dll/src/cmmphonebookoperationdelete.cpp
changeset 8 6295dc2169f3
parent 7 fa67e03b87df
child 9 8486d82aef45
equal deleted inserted replaced
7:fa67e03b87df 8:6295dc2169f3
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    21 #include <pn_const.h>
    21 #include <pn_const.h>
    22 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
    22 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
    23 #include "tsylogger.h"
    23 #include "tsylogger.h"
    24 #include "cmmmessagerouter.h"
    24 #include "cmmmessagerouter.h"
    25 #include "cmmphonebookoperationdelete.h"
    25 #include "cmmphonebookoperationdelete.h"
    26 #include "osttracedefinitions.h"
    26 #include "OstTraceDefinitions.h"
    27 #ifdef OST_TRACE_COMPILER_IN_USE
    27 #ifdef OST_TRACE_COMPILER_IN_USE
    28 #include "cmmphonebookoperationdeletetraces.h"
    28 #include "cmmphonebookoperationdeletetraces.h"
    29 #endif
    29 #endif
    30 
    30 
    31 // EXTERNAL DATA STRUCTURES
    31 // EXTERNAL DATA STRUCTURES
   139 
   139 
   140     TInt ret( KErrNotSupported );
   140     TInt ret( KErrNotSupported );
   141     iIpc = aIpc;
   141     iIpc = aIpc;
   142     iTransId = aTransId;
   142     iTransId = aTransId;
   143     // Convert phone book name to file id
   143     // Convert phone book name to file id
   144     iFileId = ConvertToPBfileId( iPhoneBookTypeName, iFileIdExt, iMmUiccMessHandler->GetCardType() );
   144     iFileId = ConvertToPBfileId(
       
   145         iPhoneBookTypeName,
       
   146         iFileIdExt,
       
   147         iMmUiccMessHandler->GetCardType() );
   145     // Find location from internal array
   148     // Find location from internal array
   146     iArrayIndex = ConvertToConfArrayIndex( iFileId );
   149     iArrayIndex = ConvertToConfArrayIndex( iFileId );
   147 
   150 
   148     const CPhoneBookDataPackage* phoneBookData(
   151     const CPhoneBookDataPackage* phoneBookData(
   149         static_cast<const CPhoneBookDataPackage*>( aDataPackage ) );
   152         static_cast<const CPhoneBookDataPackage*>( aDataPackage ) );
   150 
   153 
   151     switch( aIpc )
   154     switch( aIpc )
   152         {
   155         {
   153         case EMmTsyPhoneBookStoreDeleteIPC:
   156         case EMmTsyPhoneBookStoreDeleteIPC:
       
   157         case EMmTsyONStoreDeleteIPC:
   154             {
   158             {
   155             phoneBookData->UnPackData( iIndex );
   159             phoneBookData->UnPackData( iIndex );
   156 
   160 
   157             if( PB_MBDN_FID == iFileId )
   161             if( PB_MBDN_FID == iFileId )
   158                 {
   162                 {
   159                 // Store MBI Profile
   163                 // Store MBI Profile
   160                 iMBIProfileType = iIndex;
   164                 iMBIProfileType = iIndex;
   161                 // For MBDN PhoneBook first read MBI file 
   165                 // For MBDN PhoneBook first read MBI file
   162                 // Check if the mailbox inidcation type is correct
   166                 // Check if the mailbox inidcation type is correct
   163                 if( iIndex < iMmPhoneBookStoreMessHandler->
   167                 if( iIndex < iMmPhoneBookStoreMessHandler->
   164                         iPBStoreConf[iArrayIndex].iMbiRecLen )
   168                         iPBStoreConf[iArrayIndex].iMbiRecLen )
   165                     {
   169                     {
   166                     iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
   170                     iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
   177                 ret = UiccPbReqDelete();
   181                 ret = UiccPbReqDelete();
   178                 }
   182                 }
   179             break;
   183             break;
   180             }
   184             }
   181         case EMmTsyPhoneBookStoreDeleteAllIPC:
   185         case EMmTsyPhoneBookStoreDeleteAllIPC:
       
   186         case EMmTsyONStoreDeleteAllIPC:
   182             {
   187             {
   183             if( PB_MBDN_FID != iFileId)
   188             if( PB_MBDN_FID != iFileId)
   184                 {
   189                 {
   185                 iNumOfEntries = iMmPhoneBookStoreMessHandler->
   190                 iNumOfEntries = iMmPhoneBookStoreMessHandler->
   186                     iPBStoreConf[iArrayIndex].iNoOfRecords;
   191                     iPBStoreConf[iArrayIndex].iNoOfRecords;
   195             else
   200             else
   196                 {
   201                 {
   197                 // For first Profile Type Read
   202                 // For first Profile Type Read
   198                 iMBIProfileType = 0;
   203                 iMBIProfileType = 0;
   199                 iIndex = iMBIProfileType;
   204                 iIndex = iMBIProfileType;
   200                 // For MBDN PhoneBook first read MBI file 
   205                 // For MBDN PhoneBook first read MBI file
   201                 // Check if the mailbox inidcation type is correct
   206                 // Check if the mailbox inidcation type is correct
   202                 if( iMBIProfileType < iMmPhoneBookStoreMessHandler->
   207                 if( iMBIProfileType < iMmPhoneBookStoreMessHandler->
   203                         iPBStoreConf[iArrayIndex].iMbiRecLen )
   208                         iPBStoreConf[iArrayIndex].iMbiRecLen )
   204                     {
   209                     {
   205                     iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
   210                     iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
   209                 else
   214                 else
   210                     {
   215                     {
   211                     ret = KErrArgument;
   216                     ret = KErrArgument;
   212                     }
   217                     }
   213                 }
   218                 }
   214                 
       
   215             break;
   219             break;
   216             }
   220             }
   217 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   218         case ECustomDeleteAlphaStringIPC:
       
   219             {
       
   220             break;
       
   221             }
       
   222 #endif // INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   223         default:
   221         default:
   224             {
   222             {
   225 TFLOGSTRING2("TSY: CMmPhoneBookOperationDelete::CreateReq - Unknown IPC: %d", aIpc);
   223 TFLOGSTRING2("TSY: CMmPhoneBookOperationDelete::CreateReq - Unknown IPC: %d", aIpc);
   226 OstTrace1( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONDELETE_CREATEREQ, "CMmPhoneBookOperationDelete::CreateReq;aIpc=%d", aIpc );
   224 OstTrace1( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONDELETE_CREATEREQ, "CMmPhoneBookOperationDelete::CreateReq;aIpc=%d", aIpc );
   227             break;
   225             break;
   247         {
   245         {
   248         case PB_ADN_FID:
   246         case PB_ADN_FID:
   249         case PB_FDN_FID:
   247         case PB_FDN_FID:
   250         case PB_MBDN_FID:
   248         case PB_MBDN_FID:
   251         case PB_VMBX_FID:
   249         case PB_VMBX_FID:
       
   250         case PB_MSISDN_FID:
   252             {
   251             {
   253             // Check if the location to be deleted is valid
   252             // Check if the location to be deleted is valid
   254             if( iIndex <= iMmPhoneBookStoreMessHandler->
   253             if( ( iIndex <= iMmPhoneBookStoreMessHandler->
   255                 iPBStoreConf[iArrayIndex].iNoOfRecords )
   254                 iPBStoreConf[iArrayIndex].iNoOfRecords ) &&
       
   255                 ( 0 < iIndex ) )
   256                 {
   256                 {
   257                 // Check if entry can be found in list
   257                 // Check if entry can be found in list
   258                 if( iMmPhoneBookStoreMessHandler->IndexCheckInPBList(
   258                 if( iMmPhoneBookStoreMessHandler->IndexCheckInPBList(
   259                     iIndex,
   259                     iIndex,
   260                     iArrayIndex,
   260                     iArrayIndex,
   314         static_cast<MUiccOperationBase*>( iMmPhoneBookStoreMessHandler );
   314         static_cast<MUiccOperationBase*>( iMmPhoneBookStoreMessHandler );
   315     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ) );
   315     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ) );
   316     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ) );
   316     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ) );
   317     cmdParams.filePath.Append( APPL_FILE_ID >> 8 );
   317     cmdParams.filePath.Append( APPL_FILE_ID >> 8 );
   318     cmdParams.filePath.Append( APPL_FILE_ID );
   318     cmdParams.filePath.Append( APPL_FILE_ID );
   319     if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
   319     if( ( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() ) &&
       
   320         ( PB_MSISDN_FID != iFileId ) )
   320         {
   321         {
   321         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   322         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   322         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   323         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   323         }
   324         }
   324 
   325 
   373 
   374 
   374     // File Data
   375     // File Data
   375     TBuf8<KExtensionDataBytes>extFileData;
   376     TBuf8<KExtensionDataBytes>extFileData;
   376     extFileData.Append( 0x00 ); // Type of record ( 0x00 == unknown )
   377     extFileData.Append( 0x00 ); // Type of record ( 0x00 == unknown )
   377     // Rest of data is set by 'FF'
   378     // Rest of data is set by 'FF'
   378     extFileData.AppendFill( 0xFF, ( KExtensionDataBytes - 1 ) ); 
   379     extFileData.AppendFill( 0xFF, ( KExtensionDataBytes - 1 ) );
   379     cmdParams.fileData.Append( extFileData );
   380     cmdParams.fileData.Append( extFileData );
   380 
   381 
   381     return iMmPhoneBookStoreMessHandler->UiccMessHandler()->
   382     return iMmPhoneBookStoreMessHandler->UiccMessHandler()->
   382         CreateUiccApplCmdReq( cmdParams );
   383         CreateUiccApplCmdReq( cmdParams );
   383     }
   384     }
   403     if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
   404     if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
   404         {
   405         {
   405         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   406         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   406         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   407         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   407         }
   408         }
   408     
   409 
   409     cmdParams.serviceType = UICC_APPL_READ_LINEAR_FIXED;
   410     cmdParams.serviceType = UICC_APPL_READ_LINEAR_FIXED;
   410     cmdParams.fileId = iFileId;
   411     cmdParams.fileId = iFileId;
   411     cmdParams.trId = static_cast<TUiccTrId>( iTransId );
   412     cmdParams.trId = static_cast<TUiccTrId>( iTransId );
   412     cmdParams.record = iIndex;
   413     cmdParams.record = iIndex;
   413     
   414 
   414     return iMmPhoneBookStoreMessHandler->UiccMessHandler()->
   415     return iMmPhoneBookStoreMessHandler->UiccMessHandler()->
   415         CreateUiccApplCmdReq( cmdParams );
   416         CreateUiccApplCmdReq( cmdParams );
   416     }
   417     }
   417 
   418 
   418 
   419 
   419 // ---------------------------------------------------------------------------
   420 // ---------------------------------------------------------------------------
   420 // CMmPhoneBookOperationDelete::UiccPbReqReadMBI
   421 // CMmPhoneBookOperationDelete::UiccPbReqReadMBI
   421 // Constructs an ISI-message to Read MBI profile from first record 
   422 // Constructs an ISI-message to Read MBI profile from first record
   422 // ---------------------------------------------------------------------------
   423 // ---------------------------------------------------------------------------
   423 //
   424 //
   424 TInt CMmPhoneBookOperationDelete::UiccPbReqReadMBI( )
   425 TInt CMmPhoneBookOperationDelete::UiccPbReqReadMBI( )
   425     {
   426     {
   426 TFLOGSTRING("TSY: CMmPhoneBookOperationDelete::UiccPbReqReadMBI");
   427 TFLOGSTRING("TSY: CMmPhoneBookOperationDelete::UiccPbReqReadMBI");
   427 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONDELETE_UICCPBREQREADMBI, "CMmPhoneBookOperationDelete::UiccPbReqReadMBI" );
   428 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONDELETE_UICCPBREQREADMBI, "CMmPhoneBookOperationDelete::UiccPbReqReadMBI" );
   428         
   429 
   429         TInt ret ( KErrNone );
   430         TInt ret ( KErrNone );
   430         TUiccReadLinearFixed cmdParams;
   431         TUiccReadLinearFixed cmdParams;
   431         cmdParams.messHandlerPtr  = static_cast<MUiccOperationBase*> 
   432         cmdParams.messHandlerPtr  = static_cast<MUiccOperationBase*>
   432                                    ( iMmPhoneBookStoreMessHandler );
   433                                    ( iMmPhoneBookStoreMessHandler );
   433         cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   434         cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   434         cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   435         cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   435         cmdParams.filePath.Append( APPL_FILE_ID>>8);
   436         cmdParams.filePath.Append( APPL_FILE_ID>>8);
   436         cmdParams.filePath.Append( APPL_FILE_ID);
   437         cmdParams.filePath.Append( APPL_FILE_ID);
   437         
   438 
   438         if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
   439         if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
   439             {
   440             {
   440             cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   441             cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   441             cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   442             cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   442             }
   443             }
   445         cmdParams.fileId = PB_MBI_FID;
   446         cmdParams.fileId = PB_MBI_FID;
   446         cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   447         cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   447         cmdParams.dataAmount = 1;
   448         cmdParams.dataAmount = 1;
   448         cmdParams.dataOffset = iMBIProfileType;
   449         cmdParams.dataOffset = iMBIProfileType;
   449         cmdParams.record = 1;   // only first profile number is supported
   450         cmdParams.record = 1;   // only first profile number is supported
   450         
   451 
   451         
   452 
   452         if( KErrNone == ret )
   453         if( KErrNone == ret )
   453             {
   454             {
   454             ret = iMmPhoneBookStoreMessHandler->UiccMessHandler()->
   455             ret = iMmPhoneBookStoreMessHandler->UiccMessHandler()->
   455                 CreateUiccApplCmdReq( cmdParams );
   456                 CreateUiccApplCmdReq( cmdParams );
   456             }
   457             }
   467     {
   468     {
   468 TFLOGSTRING("TSY: CMmPhoneBookOperationDelete::UiccPBReqWriteMBIProfile");
   469 TFLOGSTRING("TSY: CMmPhoneBookOperationDelete::UiccPBReqWriteMBIProfile");
   469 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONDELETE_UICCPBREQDELETEMBIPROFILE, "CMmPhoneBookOperationDelete::UiccPBReqDeleteMBIProfile" );
   470 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONDELETE_UICCPBREQDELETEMBIPROFILE, "CMmPhoneBookOperationDelete::UiccPBReqDeleteMBIProfile" );
   470 
   471 
   471     TInt ret ( KErrNone );
   472     TInt ret ( KErrNone );
   472     
   473 
   473     TUiccWriteLinearFixed cmdParams;
   474     TUiccWriteLinearFixed cmdParams;
   474     cmdParams.messHandlerPtr  = static_cast<MUiccOperationBase*> 
   475     cmdParams.messHandlerPtr  = static_cast<MUiccOperationBase*>
   475                                ( iMmPhoneBookStoreMessHandler );
   476                                ( iMmPhoneBookStoreMessHandler );
   476     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   477     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   477     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   478     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   478     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   479     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   479     cmdParams.filePath.Append( APPL_FILE_ID);
   480     cmdParams.filePath.Append( APPL_FILE_ID);
   489     cmdParams.dataOffset = iMBIProfileType;
   490     cmdParams.dataOffset = iMBIProfileType;
   490     cmdParams.record = 1;   // only first profile number is supported
   491     cmdParams.record = 1;   // only first profile number is supported
   491 
   492 
   492     // Append FileData needs to be write
   493     // Append FileData needs to be write
   493     cmdParams.fileData.Append( 0 );
   494     cmdParams.fileData.Append( 0 );
   494     
   495 
   495     
   496 
   496     if( KErrNone == ret )
   497     if( KErrNone == ret )
   497         {
   498         {
   498         ret = iMmPhoneBookStoreMessHandler->UiccMessHandler()->
   499         ret = iMmPhoneBookStoreMessHandler->UiccMessHandler()->
   499             CreateUiccApplCmdReq( cmdParams );
   500             CreateUiccApplCmdReq( cmdParams );
   500         }
   501         }
   501 
   502 
   502     return ret;
   503     return ret;
   503     
   504 
   504     }
   505     }
   505 
   506 
   506 // ---------------------------------------------------------------------------
   507 // ---------------------------------------------------------------------------
   507 // CMmPhoneBookOperationDelete::HandleReadEntryResp
   508 // CMmPhoneBookOperationDelete::HandleReadEntryResp
   508 // Handles phonebook entry data
   509 // Handles phonebook entry data
   540             }
   541             }
   541         }
   542         }
   542     return ret;
   543     return ret;
   543     }
   544     }
   544 
   545 
       
   546 
       
   547 
       
   548 
       
   549 
       
   550 // ---------------------------------------------------------------------------
       
   551 // CMmPhoneBookOperationDelete::HandleDeleteEntryResp
       
   552 // Handles phonebook Entry Delete
       
   553 // ---------------------------------------------------------------------------
       
   554 //
       
   555 TInt CMmPhoneBookOperationDelete::HandleDeleteEntryResp(
       
   556     TBool &aComplete,
       
   557     TInt &aLocation )
       
   558     {
       
   559 TFLOGSTRING("TSY: CMmPhoneBookOperationDelete::HandleDeleteEntryResp");
       
   560 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONDELETE_HANDLEDELETEENTRYRESP, "CMmPhoneBookOperationDelete::HandleDeleteEntryResp" );
       
   561 
       
   562     TInt ret ( KErrNone );
       
   563 
       
   564     if ( iLocationFoundInPbList ) // Entry already in list, reset
       
   565         {
       
   566         iMmPhoneBookStoreMessHandler->ResetEntryInPhoneBookList(
       
   567             iArrayIndex,
       
   568             iIndex );
       
   569         }
       
   570     else
       
   571         {
       
   572         // This location has not been read earlier, add it to list
       
   573         TPBEntry* storeEntry = new ( ELeave ) TPBEntry();
       
   574         storeEntry->iEntryPresent = EFalse;
       
   575         storeEntry->iEntryIndex = iIndex;
       
   576         storeEntry->PBEntryExtRecord.Reset();
       
   577         iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList(
       
   578             storeEntry,
       
   579             iArrayIndex );
       
   580         }
       
   581 
       
   582     // If it is MBDN Phone Book then update MBI File also
       
   583     if( PB_MBDN_FID == iFileId)
       
   584         {
       
   585         // Start Writing MBI file
       
   586         iCurrentDeletePhase = EPBDeletePhase_delete_MBI_profile;
       
   587         ret = UiccPBReqDeleteMBIProfile();
       
   588         }
       
   589     else
       
   590         {
       
   591             // Ready for complete
       
   592             aComplete = ETrue;
       
   593         if ( EMmTsyPhoneBookStoreDeleteAllIPC == iIpc &&
       
   594             iNumOfEntries )
       
   595             {
       
   596             // Continue deleting entries
       
   597             iIndex = iNumOfEntries;
       
   598             ret = UiccPbReqDelete();
       
   599             iNumOfEntries--;
       
   600             }
       
   601         else
       
   602             {
       
   603             // Ready for complete
       
   604             aComplete = ETrue;
       
   605             // In case of delete all location is 0
       
   606             if ( EMmTsyPhoneBookStoreDeleteIPC == iIpc )
       
   607                 {
       
   608                 aLocation = iIndex;
       
   609                 }
       
   610             }
       
   611         }
       
   612 
       
   613     return ret;
       
   614     }
       
   615 
       
   616 
       
   617 // ---------------------------------------------------------------------------
       
   618 // CMmPhoneBookOperationDelete::HandleReadExtResp
       
   619 // Handles phonebook Ext data Read
       
   620 // ---------------------------------------------------------------------------
       
   621 //
       
   622 TInt CMmPhoneBookOperationDelete::HandleDeleteExtResp()
       
   623     {
       
   624 TFLOGSTRING("TSY: CMmPhoneBookOperationDelete::HandleDeleteExtResp");
       
   625 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONDELETE_HANDLEDELETEEXTRESP, "CMmPhoneBookOperationDelete::HandleDeleteExtResp" );
       
   626 
       
   627     TInt ret ( KErrNone );
       
   628 
       
   629     // Entry was read earlier and extension records saved
       
   630     if ( iLocationFoundInPbList )
       
   631         {
       
   632         // Check if there are extensions left, in that case
       
   633         // continue deleting extensions
       
   634         if ( iNumOfExtensions )
       
   635             {
       
   636             ret = UiccPbReqDeleteExt(
       
   637                 iEntry.PBEntryExtRecord[iNumOfExtensions-1] );
       
   638             iNumOfExtensions--;
       
   639             }
       
   640         // All extensions were deleted, next delete the main entry
       
   641         else
       
   642             {
       
   643             iCurrentDeletePhase = EPBDeletePhaseDeleteEntry;
       
   644             ret = UiccPbReqDeleteEntry();
       
   645             }
       
   646         }
       
   647     // Extensions were read from SIM and saved to internal buffer
       
   648     else
       
   649         {
       
   650         iNumOfExtensions = iExtRecordArrayToBeDelete.Count();
       
   651         if ( iNumOfExtensions )
       
   652             {
       
   653             ret = UiccPbReqDeleteExt(
       
   654                 iExtRecordArrayToBeDelete[iNumOfExtensions - 1] );
       
   655             iExtRecordArrayToBeDelete.Remove(
       
   656                 iNumOfExtensions - 1 );
       
   657             iExtRecordArrayToBeDelete.Compress();
       
   658             }
       
   659         else // It is time to delete the main entry
       
   660             {
       
   661             iCurrentDeletePhase = EPBDeletePhaseDeleteEntry;
       
   662             ret = UiccPbReqDeleteEntry();
       
   663             }
       
   664         }
       
   665 
       
   666     return ret;
       
   667     }
   545 
   668 
   546 // ---------------------------------------------------------------------------
   669 // ---------------------------------------------------------------------------
   547 // CMmPhoneBookOperationDelete::UiccPbReqDeleteExt
   670 // CMmPhoneBookOperationDelete::UiccPbReqDeleteExt
   548 // Constructs an ISI-message to delete extension record
   671 // Constructs an ISI-message to delete extension record
   549 // ---------------------------------------------------------------------------
   672 // ---------------------------------------------------------------------------
   618     }
   741     }
   619 
   742 
   620 
   743 
   621 // ---------------------------------------------------------------------------
   744 // ---------------------------------------------------------------------------
   622 // TBool CMmPhoneBookOperationDelete::HandleWriteMBIReadResp
   745 // TBool CMmPhoneBookOperationDelete::HandleWriteMBIReadResp
   623 // Handle write response for MBI profile read
   746 // Handle response for MBI profile read
   624 // ---------------------------------------------------------------------------
   747 // ---------------------------------------------------------------------------
   625 //
   748 //
   626 TInt CMmPhoneBookOperationDelete::HandleWriteMBIReadResp(
   749 TInt CMmPhoneBookOperationDelete::HandleMBIReadResp(
   627         TInt aStatus,
   750         TInt aStatus,
   628         TUint8 aDetails,
   751         TUint8 aDetails,
   629         TBool &aComplete,
   752         TBool &aComplete,
   630         const TDesC8 &aFileData ) 
   753         const TDesC8 &aFileData )
   631     {
   754     {
   632     TInt ret ( KErrNone );
   755     TInt ret ( KErrNone );
   633 TFLOGSTRING("TSY: CMmPhoneBookOperationDelete::HandleWriteMBIReadResp");
   756 TFLOGSTRING("TSY: CMmPhoneBookOperationDelete::HandleMBIReadResp");
   634 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONDELETE_HANDLEWRITEMBIREADRESP, "CMmPhoneBookOperationDelete::HandleWriteMBIReadResp" );
   757 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONDELETE_HANDLEMBIREADRESP, "CMmPhoneBookOperationDelete::HandleMBIReadResp" );
   635 
   758 
   636     if( UICC_STATUS_OK  == aStatus )
   759     if( UICC_STATUS_OK  == aStatus )
   637         {
   760         {
   638         iIndex = aFileData[0];
   761         iIndex = aFileData[0];
   639         if( ( 0 != iIndex ) && ( iIndex <= iMmPhoneBookStoreMessHandler->
   762         if( ( 0 != iIndex ) && ( iIndex <= iMmPhoneBookStoreMessHandler->
   712                 ret = HandleReadEntryResp( aFileData );
   835                 ret = HandleReadEntryResp( aFileData );
   713                 break;
   836                 break;
   714                 }
   837                 }
   715             case EPBDeletePhaseDeleteExtension:
   838             case EPBDeletePhaseDeleteExtension:
   716                 {
   839                 {
   717                 // Entry was read earlier and extension records saved
   840                 ret = HandleDeleteExtResp();
   718                 if ( iLocationFoundInPbList )
       
   719                     {
       
   720                     // Check if there are extensions left, in that case
       
   721                     // continue deleting extensions
       
   722                     if ( iNumOfExtensions )
       
   723                         {
       
   724                         ret = UiccPbReqDeleteExt(
       
   725                             iEntry.PBEntryExtRecord[iNumOfExtensions-1] );
       
   726                         iNumOfExtensions--;
       
   727                         }
       
   728                     // All extensions were deleted, next delete the main entry
       
   729                     else
       
   730                         {
       
   731                         iCurrentDeletePhase = EPBDeletePhaseDeleteEntry;
       
   732                         ret = UiccPbReqDeleteEntry();
       
   733                         }
       
   734                     }
       
   735                 // Extensions were read from SIM and saved to internal buffer
       
   736                 else
       
   737                     {
       
   738                     iNumOfExtensions = iExtRecordArrayToBeDelete.Count();
       
   739                     if ( iNumOfExtensions )
       
   740                         {
       
   741                         ret = UiccPbReqDeleteExt(
       
   742                             iExtRecordArrayToBeDelete[iNumOfExtensions - 1] );
       
   743                         iExtRecordArrayToBeDelete.Remove(
       
   744                             iNumOfExtensions - 1 );
       
   745                         iExtRecordArrayToBeDelete.Compress();
       
   746                         }
       
   747                     else // It is time to delete the main entry
       
   748                         {
       
   749                         iCurrentDeletePhase = EPBDeletePhaseDeleteEntry;
       
   750                         ret = UiccPbReqDeleteEntry();
       
   751                         }
       
   752                     }
       
   753                 break;
   841                 break;
   754                 }
   842                 }
   755             case EPBDeletePhaseDeleteEntry:
   843             case EPBDeletePhaseDeleteEntry:
   756                 {
   844                 {
   757                 if ( iLocationFoundInPbList ) // Entry already in list, reset
   845                 ret = HandleDeleteEntryResp( complete, location );
   758                     {
       
   759                     iMmPhoneBookStoreMessHandler->ResetEntryInPhoneBookList(
       
   760                         iArrayIndex,
       
   761                         iIndex );
       
   762                     }
       
   763                 else
       
   764                     {
       
   765                     // This location has not been read earlier, add it to list
       
   766                     TPBEntry* storeEntry = new ( ELeave ) TPBEntry();
       
   767                     storeEntry->iEntryPresent = EFalse;
       
   768                     storeEntry->iEntryIndex = iIndex;
       
   769                     storeEntry->PBEntryExtRecord.Reset();
       
   770                     iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList(
       
   771                         storeEntry,
       
   772                         iArrayIndex );
       
   773                     }
       
   774 
       
   775                 // If it is MBDN Phone Book then update MBI File also
       
   776                 if( PB_MBDN_FID == iFileId)
       
   777                     {
       
   778                     // Start Writing MBI file
       
   779                     iCurrentDeletePhase = EPBDeletePhase_delete_MBI_profile;
       
   780                     ret = UiccPBReqDeleteMBIProfile();
       
   781                     }
       
   782                 else
       
   783                     {
       
   784                         // Ready for complete
       
   785                         complete = ETrue;
       
   786                     if ( EMmTsyPhoneBookStoreDeleteAllIPC == iIpc &&
       
   787                         iNumOfEntries )
       
   788                         {
       
   789                         // Continue deleting entries
       
   790                         iIndex = iNumOfEntries;
       
   791                         ret = UiccPbReqDelete();
       
   792                         iNumOfEntries--;
       
   793                         }
       
   794                     else
       
   795                         {
       
   796                         // Ready for complete
       
   797                         complete = ETrue;
       
   798                         // In case of delete all location is 0
       
   799                         if ( EMmTsyPhoneBookStoreDeleteIPC == iIpc )
       
   800                             {
       
   801                             location = iIndex;
       
   802                             }
       
   803                         }
       
   804                     }
       
   805                 break;
   846                 break;
   806                 }
   847                 }
   807             case EPBDeletePhase_Read_MBI_profile:
   848             case EPBDeletePhase_Read_MBI_profile:
   808                 {
   849                 {
   809                 ret = HandleWriteMBIReadResp( aStatus, aDetails, complete, aFileData );
   850                 ret = HandleMBIReadResp( aStatus, aDetails, complete, aFileData );
   810                 break;
   851                 break;
   811                 }
   852                 }
   812             case EPBDeletePhase_delete_MBI_profile:
   853             case EPBDeletePhase_delete_MBI_profile:
   813                 {
   854                 {
   814                 if( UICC_STATUS_OK  != aStatus )
   855                 if( UICC_STATUS_OK  != aStatus )
   825                 else
   866                 else
   826                     {
   867                     {
   827                     // Continue deleting entries
   868                     // Continue deleting entries
   828                     // increment iMBIProfileType to read next profile
   869                     // increment iMBIProfileType to read next profile
   829                     iMBIProfileType++;
   870                     iMBIProfileType++;
   830                     
   871 
   831                     if ( EMmTsyPhoneBookStoreDeleteAllIPC == iIpc &&
   872                     if ( EMmTsyPhoneBookStoreDeleteAllIPC == iIpc &&
   832                         ( iMBIProfileType < iMmPhoneBookStoreMessHandler->
   873                         ( iMBIProfileType < iMmPhoneBookStoreMessHandler->
   833                                 iPBStoreConf[iArrayIndex].iMbiRecLen ) )
   874                                 iPBStoreConf[iArrayIndex].iMbiRecLen ) )
   834                         {
   875                         {
   835                         iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
   876                         iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
   872         }
   913         }
   873 
   914 
   874     if ( complete )
   915     if ( complete )
   875         {
   916         {
   876         TPBEntryInfo pbEntryInfo;
   917         TPBEntryInfo pbEntryInfo;
   877         pbEntryInfo.iMaxNumLength = iMmPhoneBookStoreMessHandler->
   918         pbEntryInfo.iLocation = 0;
   878         iPBStoreConf[iArrayIndex].iNumlength;
   919         pbEntryInfo.iMaxNumLength = 0;
   879         pbEntryInfo.iLocation = location;
   920 
       
   921         if( KErrNone == ret )
       
   922             {
       
   923             pbEntryInfo.iMaxNumLength = iMmPhoneBookStoreMessHandler->
       
   924             iPBStoreConf[iArrayIndex].iNumlength;
       
   925             if( iIpc == EMmTsyPhoneBookStoreDeleteIPC )
       
   926                 {
       
   927                 pbEntryInfo.iLocation = location;
       
   928                 }
       
   929             }
   880 
   930 
   881         CPhoneBookDataPackage phoneBookData;
   931         CPhoneBookDataPackage phoneBookData;
   882         phoneBookData.SetPhoneBookName( iPhoneBookTypeName );
   932         phoneBookData.SetPhoneBookName( iPhoneBookTypeName );
   883         phoneBookData.PackData( &pbEntryInfo );
   933         phoneBookData.PackData( &pbEntryInfo );
   884 
   934