adaptationlayer/tsy/nokiatsy_dll/src/cmmphonebookoperationwrite.cpp
changeset 7 fa67e03b87df
parent 5 8ccc39f9d787
child 8 6295dc2169f3
equal deleted inserted replaced
6:942573423a60 7:fa67e03b87df
    64 // might leave.
    64 // might leave.
    65 // ---------------------------------------------------------------------------
    65 // ---------------------------------------------------------------------------
    66 //
    66 //
    67 CMmPhoneBookOperationWrite::CMmPhoneBookOperationWrite()
    67 CMmPhoneBookOperationWrite::CMmPhoneBookOperationWrite()
    68     {
    68     {
    69 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::\
    69 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::CMmPhoneBookOperationWrite");
    70         CMmPhoneBookOperationWrite");
       
    71 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_CMMPHONEBOOKOPERATIONWRITE, "CMmPhoneBookOperationWrite::CMmPhoneBookOperationWrite" );
    70 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_CMMPHONEBOOKOPERATIONWRITE, "CMmPhoneBookOperationWrite::CMmPhoneBookOperationWrite" );
    72     iPhoneBookEntry = NULL;
    71     iPhoneBookEntry = NULL;
    73     }
    72     }
    74 
    73 
    75 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    77 // C++ destructor.
    76 // C++ destructor.
    78 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
    79 //
    78 //
    80 CMmPhoneBookOperationWrite::~CMmPhoneBookOperationWrite()
    79 CMmPhoneBookOperationWrite::~CMmPhoneBookOperationWrite()
    81     {
    80     {
    82 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::\
    81 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::~CMmPhoneBookOperationWrite");
    83         ~CMmPhoneBookOperationWrite");
       
    84 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONWRITE_CMMPHONEBOOKOPERATIONWRITE, "CMmPhoneBookOperationWrite::~CMmPhoneBookOperationWrite" );
    82 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONWRITE_CMMPHONEBOOKOPERATIONWRITE, "CMmPhoneBookOperationWrite::~CMmPhoneBookOperationWrite" );
    85     }
    83     }
    86 
    84 
    87 // ---------------------------------------------------------------------------
    85 // ---------------------------------------------------------------------------
    88 // CMmPhoneBookOperationWrite::NewL
    86 // CMmPhoneBookOperationWrite::NewL
    90 // Two-phased constructor.
    88 // Two-phased constructor.
    91 // ---------------------------------------------------------------------------
    89 // ---------------------------------------------------------------------------
    92 
    90 
    93 CMmPhoneBookOperationWrite* CMmPhoneBookOperationWrite::NewL(
    91 CMmPhoneBookOperationWrite* CMmPhoneBookOperationWrite::NewL(
    94     CMmPhoneBookStoreMessHandler* aMmPhoneBookStoreMessHandler,
    92     CMmPhoneBookStoreMessHandler* aMmPhoneBookStoreMessHandler,
       
    93     CMmUiccMessHandler* aUiccMessHandler,
    95     const CMmDataPackage* aDataPackage ) // Data
    94     const CMmDataPackage* aDataPackage ) // Data
    96     {
    95     {
    97 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::NewL");
    96 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::NewL");
    98 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_NEWL, "CMmPhoneBookOperationWrite::NewL" );
    97 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_NEWL, "CMmPhoneBookOperationWrite::NewL" );
    99 
    98 
   110     mmPhoneBookOperationWrite->iPhoneBookTypeName = phonebookTypeName;
   109     mmPhoneBookOperationWrite->iPhoneBookTypeName = phonebookTypeName;
   111 
   110 
   112     mmPhoneBookOperationWrite->iMmPhoneBookStoreMessHandler =
   111     mmPhoneBookOperationWrite->iMmPhoneBookStoreMessHandler =
   113         aMmPhoneBookStoreMessHandler;
   112         aMmPhoneBookStoreMessHandler;
   114 
   113 
       
   114     mmPhoneBookOperationWrite->iMmUiccMessHandler = aUiccMessHandler;
   115     return mmPhoneBookOperationWrite;
   115     return mmPhoneBookOperationWrite;
   116     }
   116     }
   117 
   117 
   118 // ---------------------------------------------------------------------------
   118 // ---------------------------------------------------------------------------
   119 // CMmPhoneBookOperationWrite::ConstructL
   119 // CMmPhoneBookOperationWrite::ConstructL
   140         )
   140         )
   141     {
   141     {
   142 TFLOGSTRING2("TSY: CMmPhoneBookOperationWrite::UICCCreateReq Ipc: %d", aIpc);
   142 TFLOGSTRING2("TSY: CMmPhoneBookOperationWrite::UICCCreateReq Ipc: %d", aIpc);
   143 OstTraceExt1( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONWRITE_UICCCREATEREQ, "CMmPhoneBookOperationWrite::UICCCreateReq;aIpc=%hd", aIpc );
   143 OstTraceExt1( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONWRITE_UICCCREATEREQ, "CMmPhoneBookOperationWrite::UICCCreateReq;aIpc=%hd", aIpc );
   144     
   144     
   145     TInt ret (KErrNone);
   145     TInt ret (KErrNotSupported);
   146     const CPhoneBookDataPackage* phoneBookData =
   146     const CPhoneBookDataPackage* phoneBookData =
   147         static_cast<const CPhoneBookDataPackage*>( aDataPackage );
   147         static_cast<const CPhoneBookDataPackage*>( aDataPackage );
   148 
   148 
   149         if( aIpc == EMmTsyPhoneBookStoreWriteIPC )
   149         if( aIpc == EMmTsyPhoneBookStoreWriteIPC )
   150             {
   150             {
   157                     // get the index Number needs to be write
   157                     // get the index Number needs to be write
   158                     iPhoneBookEntry->iLocation = static_cast<TUint16>( index );
   158                     iPhoneBookEntry->iLocation = static_cast<TUint16>( index );
   159                     
   159                     
   160                     // Convert Phone Book name to file id
   160                     // Convert Phone Book name to file id
   161                     TUint16 fileIdExt ( UICC_ILLEGAL_FILE_ID );
   161                     TUint16 fileIdExt ( UICC_ILLEGAL_FILE_ID );
   162                     TUint16 pbFileId = ConvertToPBfileId( iPhoneBookTypeName, fileIdExt );
   162                     TUint16 pbFileId = ConvertToPBfileId( 
       
   163                                          iPhoneBookTypeName,
       
   164                                          fileIdExt,
       
   165                                          iMmUiccMessHandler->GetCardType() );
       
   166                                          
   163                     TUint8 pbArrayIndex ( ConvertToConfArrayIndex( pbFileId ) );
   167                     TUint8 pbArrayIndex ( ConvertToConfArrayIndex( pbFileId ) );
   164 
   168 
   165                     if( PB_MBDN_FID == pbFileId )
   169                     if( PB_MBDN_FID == pbFileId )
   166                         {
   170                         {
   167                         // For MBDN PhoneBook first read MBI file 
   171                         // For MBDN PhoneBook first read MBI file 
   168                         // Check if the mailbox inidcation type is correct
   172                         // Check if the mailbox inidcation type is correct
   169                         if( index <= iMmPhoneBookStoreMessHandler->
   173                         if( index <= iMmPhoneBookStoreMessHandler->
   170                                 iPBStoreConf[pbArrayIndex].iMbiRecLen )
   174                                 iPBStoreConf[pbArrayIndex].iMbiRecLen )
   171                             {
   175                             {
   172                             iCurrentWritePhase = EPBWritePhase_Read_MBI_profile;
   176                             iCurrentWritePhase = EPBWritePhase_Read_MBI_profile;
   173                             // read MBDN record number from MBI first record Profile number
   177                             // read MBDN record number from MBI first record 
       
   178                             //Profile number
   174                             ret = UiccPbReqReadMBI( index, aTransId );
   179                             ret = UiccPbReqReadMBI( index, aTransId );
   175                             }
   180                             }
   176                         else
   181                         else
   177                             {
   182                             {
   178                             ret = KErrArgument;
   183                             ret = KErrArgument;
   230         iExtRecordArrayToBeWrite.Insert( 0 , count );
   235         iExtRecordArrayToBeWrite.Insert( 0 , count );
   231         }
   236         }
   232 
   237 
   233     // Convert Phone Book name to file id
   238     // Convert Phone Book name to file id
   234     TUint16 fileIdExt ( UICC_ILLEGAL_FILE_ID );
   239     TUint16 fileIdExt ( UICC_ILLEGAL_FILE_ID );
   235     TUint16 pbFileId = ConvertToPBfileId( iPhoneBookTypeName, fileIdExt );
   240     TUint16 pbFileId = ConvertToPBfileId( 
       
   241                           iPhoneBookTypeName,
       
   242                           fileIdExt,
       
   243                           iMmUiccMessHandler->GetCardType() );
   236 
   244 
   237     if( UICC_ILLEGAL_FILE_ID != pbFileId )
   245     if( UICC_ILLEGAL_FILE_ID != pbFileId )
   238         {
   246         {
   239         TUint8 pbArrayIndex ( ConvertToConfArrayIndex( pbFileId ) );
   247         TUint8 pbArrayIndex ( ConvertToConfArrayIndex( pbFileId ) );
   240 
   248 
   253                         entry ) )
   261                         entry ) )
   254                     {
   262                     {
   255                     // Check if Entry is present or not 
   263                     // Check if Entry is present or not 
   256                     if( entry.iEntryPresent )
   264                     if( entry.iEntryPresent )
   257                         {
   265                         {
   258                         // Check if no if ext records are sufficient from previous Entry
   266                         // Check if no if ext records are sufficient from 
       
   267                         //previous Entry
   259                         if( extRecordNo  > entry.PBEntryExtRecord.Count() )
   268                         if( extRecordNo  > entry.PBEntryExtRecord.Count() )
   260                             {
   269                             {
   261                             // Update old record number which needs to be updated by new entry
   270                             // Update old record number which needs to be 
       
   271                             //updated by new entry
   262                             if( entry.PBEntryExtRecord.Count() > 0 )
   272                             if( entry.PBEntryExtRecord.Count() > 0 )
   263                                 {
   273                                 {
   264                                 for( TInt i=0; i <  entry.PBEntryExtRecord.Count(); i++ )
   274                                 for( TInt i=0; 
       
   275                                       i < entry.PBEntryExtRecord.Count();
       
   276                                       i++ )
   265                                     {
   277                                     {
   266                                     // Append record number to be write from old Entry
   278                                     // Append record number to be write from 
       
   279                                     //old Entry
   267                                     iExtRecordArrayToBeWrite.Append( 
   280                                     iExtRecordArrayToBeWrite.Append( 
   268                                             entry.PBEntryExtRecord[i] );
   281                                             entry.PBEntryExtRecord[i] );
   269                                     iExtRecordArrayToBeDelete.Append( 
   282                                     iExtRecordArrayToBeDelete.Append( 
   270                                             entry.PBEntryExtRecord[i] );
   283                                             entry.PBEntryExtRecord[i] );
   271                                     }
   284                                     }
   279                                     pbFileId,
   292                                     pbFileId,
   280                                     fileIdExt,
   293                                     fileIdExt,
   281                                     iExtRecordNo,
   294                                     iExtRecordNo,
   282                                     aTransId);
   295                                     aTransId);
   283                             }
   296                             }
   284                         else  // when reocrds to be delete and write are 0 or to be write record less
   297                         else  // when reocrds to be delete and write are 0 or to
       
   298                               // be write record less
   285                             {
   299                             {
   286                             // Check of both records are 0
   300                             // Check of both records are 0
   287                             if( ( extRecordNo == 0 ) && 
   301                             if( ( extRecordNo == 0 ) && 
   288                                     ( entry.PBEntryExtRecord.Count() == 0 ))
   302                                     ( entry.PBEntryExtRecord.Count() == 0 ))
   289                                 {
   303                                 {
   298                             else
   312                             else
   299                                 {
   313                                 {
   300                                 // Start copy Ext record number to be write array
   314                                 // Start copy Ext record number to be write array
   301                                 for( TInt i=0; i <  extRecordNo; i++ )
   315                                 for( TInt i=0; i <  extRecordNo; i++ )
   302                                     {
   316                                     {
   303                                     // Append record number to be write from old Entry
   317                                     // Append record number to be write from old
       
   318                                     //Entry
   304                                     iExtRecordArrayToBeWrite.Append(
   319                                     iExtRecordArrayToBeWrite.Append(
   305                                             entry.PBEntryExtRecord[i]);
   320                                             entry.PBEntryExtRecord[i]);
   306                                     iExtRecordArrayToBeDelete.Append(
   321                                     iExtRecordArrayToBeDelete.Append(
   307                                             entry.PBEntryExtRecord[i]);
   322                                             entry.PBEntryExtRecord[i]);
   308                                     }
   323                                     }
   309                                 // Update records needs to be deleted
   324                                 // Update records needs to be deleted
   310                                 // From old Entry
   325                                 // From old Entry
   311                                 for( TInt i=extRecordNo; i <  entry.PBEntryExtRecord.Count(); i++ )
   326                                 for( TInt i=extRecordNo;
       
   327                                        i < entry.PBEntryExtRecord.Count();
       
   328                                        i++ )
   312                                     {
   329                                     {
   313                                     // Append record number to be deleted from old Entry
   330                                     // Append record number to be deleted from 
       
   331                                     //old Entry
   314                                     iExtRecordArrayToBeDelete.Append( 
   332                                     iExtRecordArrayToBeDelete.Append( 
   315                                             entry.PBEntryExtRecord[i]);
   333                                             entry.PBEntryExtRecord[i]);
   316                                     }
   334                                     }
   317                                 // Start Deleting the EXT Records
   335                                 // Start Deleting the EXT Records
   318                                 iCurrentWritePhase = EPBWritePhase_Write_Ext_Entry;
   336                                 iCurrentWritePhase = EPBWritePhase_Write_Ext_Entry;
   357                             }
   375                             }
   358                         }
   376                         }
   359                     }   // end of if Entry is present in the list
   377                     }   // end of if Entry is present in the list
   360                 else
   378                 else
   361                     {
   379                     {
   362                     // First Read that Entry from SIM and then delete that entry with EXT records if there are Any
   380                     // First Read that Entry from SIM and then delete that entry
       
   381                     // with EXT records if there are Any
   363                     iCurrentWritePhase = EPBWritePhase_Read_Entry;
   382                     iCurrentWritePhase = EPBWritePhase_Read_Entry;
   364                     ret = UiccPbReqWriteRead( pbFileId, aIndex, aTransId );
   383                     ret = UiccPbReqWriteRead( pbFileId, aIndex, aTransId );
   365                     
   384                     
   366                     // read Main entry with given index number
   385                     // read Main entry with given index number
   367                     }
   386                     }
   430 // ---------------------------------------------------------------------------
   449 // ---------------------------------------------------------------------------
   431 // CMmPhoneBookOperationWrite::UiccPBReqWriteEntry
   450 // CMmPhoneBookOperationWrite::UiccPBReqWriteEntry
   432 // Constructs an ISI-message to Write main Entry data
   451 // Constructs an ISI-message to Write main Entry data
   433 // ---------------------------------------------------------------------------
   452 // ---------------------------------------------------------------------------
   434 //
   453 //
   435 TInt CMmPhoneBookOperationWrite::UiccPBReqWriteEntry( TUint16 aFileId, TUint8 aIndex, TUint8 aTransId, CPhoneBookStoreEntry& aDataToWrite )
   454 TInt CMmPhoneBookOperationWrite::UiccPBReqWriteEntry( 
       
   455              TUint16 aFileId,
       
   456              TUint8 aIndex,
       
   457              TUint8 aTransId,
       
   458              CPhoneBookStoreEntry& aDataToWrite )
   436     {
   459     {
   437 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::UiccPBReqWriteEntry");
   460 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite::UiccPBReqWriteEntry");
   438 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_UICCPBREQWRITEENTRY, "CMmPhoneBookOperationWrite::UiccPBReqWriteEntry" );
   461 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONWRITE_UICCPBREQWRITEENTRY, "CMmPhoneBookOperationWrite::UiccPBReqWriteEntry" );
   439 
   462 
   440     TInt ret( KErrNone );
   463     TInt ret( KErrNone );
   444                                ( iMmPhoneBookStoreMessHandler );
   467                                ( iMmPhoneBookStoreMessHandler );
   445     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   468     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   446     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   469     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   447     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   470     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   448     cmdParams.filePath.Append( APPL_FILE_ID);
   471     cmdParams.filePath.Append( APPL_FILE_ID);
   449     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   472     
   450     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   473     if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
       
   474         {
       
   475         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
       
   476         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
       
   477         }
       
   478     
   451     cmdParams.serviceType = UICC_APPL_UPDATE_LINEAR_FIXED;
   479     cmdParams.serviceType = UICC_APPL_UPDATE_LINEAR_FIXED;
   452     cmdParams.fileId = aFileId;
   480     cmdParams.fileId = aFileId;
   453     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   481     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   454     // Check for valid record number
   482     // Check for valid record number
   455     TUint8 arrayIndex ( ConvertToConfArrayIndex( aFileId ) );
   483     TUint8 arrayIndex ( ConvertToConfArrayIndex( aFileId ) );
   456     if( aIndex <= iMmPhoneBookStoreMessHandler->iPBStoreConf[arrayIndex].iNoOfRecords )
   484     if( aIndex <= iMmPhoneBookStoreMessHandler->
       
   485                      iPBStoreConf[arrayIndex].iNoOfRecords )
   457         {
   486         {
   458         cmdParams.record = aIndex;
   487         cmdParams.record = aIndex;
   459         }
   488         }
   460     else
   489     else
   461         {
   490         {
   489     TUint8 numLength ( numberBuf.Length() );
   518     TUint8 numLength ( numberBuf.Length() );
   490     
   519     
   491     if( numberBuf.Length() < UICC_EF_EXT_REC_NUM_LEN )
   520     if( numberBuf.Length() < UICC_EF_EXT_REC_NUM_LEN )
   492         {
   521         {
   493         // fill  rest of the bytes
   522         // fill  rest of the bytes
   494         for( TInt count = numberBuf.Length(); count < UICC_EF_EXT_REC_NUM_LEN; count++)
   523         for( TInt count = numberBuf.Length();
       
   524                count < UICC_EF_EXT_REC_NUM_LEN;
       
   525                count++)
   495             {
   526             {
   496             numberBuf.Append( KTagUnusedbyte );
   527             numberBuf.Append( KTagUnusedbyte );
   497             }
   528             }
   498         }
   529         }
   499     
   530     
   556                                 ( iMmPhoneBookStoreMessHandler );
   587                                 ( iMmPhoneBookStoreMessHandler );
   557     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   588     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   558     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   589     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   559     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   590     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   560     cmdParams.filePath.Append( APPL_FILE_ID);
   591     cmdParams.filePath.Append( APPL_FILE_ID);
   561     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   592     
   562     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   593     if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
       
   594         {
       
   595         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
       
   596         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
       
   597         }
       
   598     
   563     cmdParams.fileId = aFileIdExt;
   599     cmdParams.fileId = aFileIdExt;
   564     cmdParams.serviceType = UICC_APPL_UPDATE_LINEAR_FIXED;
   600     cmdParams.serviceType = UICC_APPL_UPDATE_LINEAR_FIXED;
   565     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   601     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   566     
   602     
   567     // File Data
   603     // File Data
   665                                ( iMmPhoneBookStoreMessHandler );
   701                                ( iMmPhoneBookStoreMessHandler );
   666     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   702     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   667     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   703     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   668     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   704     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   669     cmdParams.filePath.Append( APPL_FILE_ID);
   705     cmdParams.filePath.Append( APPL_FILE_ID);
   670     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   706     
   671     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   707     if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
       
   708         {
       
   709         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
       
   710         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
       
   711         }
   672     
   712     
   673     // Append transaction id 
   713     // Append transaction id 
   674     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   714     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   675     
   715     
   676     // Append File id
   716     // Append File id
   680     cmdParams.serviceType = UICC_APPL_READ_LINEAR_FIXED;
   720     cmdParams.serviceType = UICC_APPL_READ_LINEAR_FIXED;
   681     
   721     
   682     
   722     
   683     TUint8 arrayIndex( ConvertToConfArrayIndex( aFileId ) );
   723     TUint8 arrayIndex( ConvertToConfArrayIndex( aFileId ) );
   684     // Check for the valid index neds to be read
   724     // Check for the valid index neds to be read
   685     if( aIndex <= iMmPhoneBookStoreMessHandler->iPBStoreConf[arrayIndex].iExtNoOfRec )
   725     if( aIndex <= iMmPhoneBookStoreMessHandler->
       
   726                    iPBStoreConf[arrayIndex].iExtNoOfRec )
   686         {
   727         {
   687         // Append recor number
   728         // Append recor number
   688         cmdParams.record = aIndex;
   729         cmdParams.record = aIndex;
   689         }
   730         }
   690     else
   731     else
   724                                ( iMmPhoneBookStoreMessHandler );
   765                                ( iMmPhoneBookStoreMessHandler );
   725     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   766     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   726     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   767     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   727     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   768     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   728     cmdParams.filePath.Append( APPL_FILE_ID);
   769     cmdParams.filePath.Append( APPL_FILE_ID);
   729     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   770     
   730     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   771     if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
       
   772         {
       
   773         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
       
   774         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
       
   775         }
       
   776     
   731     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   777     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   732     cmdParams.fileId = aFileId;
   778     cmdParams.fileId = aFileId;
   733     cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   779     cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   734     TUint8 arrayIndex ( ConvertToConfArrayIndex( aFileId ) );
   780     TUint8 arrayIndex ( ConvertToConfArrayIndex( aFileId ) );
   735     if( aIndex <= iMmPhoneBookStoreMessHandler->iPBStoreConf[arrayIndex].iNoOfRecords )
   781     if( aIndex <= iMmPhoneBookStoreMessHandler->
       
   782                     iPBStoreConf[arrayIndex].iNoOfRecords )
   736         {
   783         {
   737         cmdParams.record = aIndex;
   784         cmdParams.record = aIndex;
   738         }
   785         }
   739     else
   786     else
   740         {
   787         {
   774                                ( iMmPhoneBookStoreMessHandler );
   821                                ( iMmPhoneBookStoreMessHandler );
   775     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   822     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   776     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   823     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   777     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   824     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   778     cmdParams.filePath.Append( APPL_FILE_ID);
   825     cmdParams.filePath.Append( APPL_FILE_ID);
   779     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   826     
   780     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   827     if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
       
   828         {
       
   829         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
       
   830         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
       
   831         }
       
   832     
   781     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   833     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   782     cmdParams.fileId = aFileIdExt;
   834     cmdParams.fileId = aFileIdExt;
   783     cmdParams.serviceType =  UICC_APPL_UPDATE_LINEAR_FIXED ;
   835     cmdParams.serviceType =  UICC_APPL_UPDATE_LINEAR_FIXED ;
   784     
   836     
   785     TUint8 arrayIndex ( ConvertToConfArrayIndex( aFileId ) );
   837     TUint8 arrayIndex ( ConvertToConfArrayIndex( aFileId ) );
   786 
   838 
   787     
   839     
   788     if( aIndex <= iMmPhoneBookStoreMessHandler->iPBStoreConf[arrayIndex].iExtNoOfRec)
   840     if( aIndex <= iMmPhoneBookStoreMessHandler->
       
   841                    iPBStoreConf[arrayIndex].iExtNoOfRec)
   789         {
   842         {
   790         cmdParams.record = aIndex;
   843         cmdParams.record = aIndex;
   791         }
   844         }
   792     else
   845     else
   793         {
   846         {
   832                                    ( iMmPhoneBookStoreMessHandler );
   885                                    ( iMmPhoneBookStoreMessHandler );
   833         cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   886         cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   834         cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   887         cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   835         cmdParams.filePath.Append( APPL_FILE_ID>>8);
   888         cmdParams.filePath.Append( APPL_FILE_ID>>8);
   836         cmdParams.filePath.Append( APPL_FILE_ID);
   889         cmdParams.filePath.Append( APPL_FILE_ID);
   837         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   890         
   838         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   891         if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
       
   892             {
       
   893             cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
       
   894             cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
       
   895             }
       
   896         
   839         cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   897         cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   840         cmdParams.fileId = PB_MBI_FID;
   898         cmdParams.fileId = PB_MBI_FID;
   841         cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   899         cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   842         cmdParams.dataAmount = 1;
   900         cmdParams.dataAmount = 1;
   843         cmdParams.dataOffset = aIndex;
   901         cmdParams.dataOffset = aIndex;
   874                                ( iMmPhoneBookStoreMessHandler );
   932                                ( iMmPhoneBookStoreMessHandler );
   875     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   933     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
   876     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   934     cmdParams.filePath.Append( static_cast<TUint8>( MF_FILE ));
   877     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   935     cmdParams.filePath.Append( APPL_FILE_ID>>8);
   878     cmdParams.filePath.Append( APPL_FILE_ID);
   936     cmdParams.filePath.Append( APPL_FILE_ID);
   879     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   937     
   880     cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
   938     if( UICC_CARD_TYPE_UICC == iMmUiccMessHandler->GetCardType() )
       
   939         {
       
   940         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
       
   941         cmdParams.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
       
   942         }
       
   943     
   881     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   944     cmdParams.trId = static_cast<TUiccTrId>( aTransId );
   882     cmdParams.fileId = PB_MBI_FID;
   945     cmdParams.fileId = PB_MBI_FID;
   883     cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   946     cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   884     cmdParams.dataAmount = 1;
   947     cmdParams.dataAmount = 1;
   885     cmdParams.dataOffset = aIndex;
   948     cmdParams.dataOffset = aIndex;
   920     
   983     
   921     TBool complete ( EFalse );
   984     TBool complete ( EFalse );
   922     TInt ret ( KErrNone );
   985     TInt ret ( KErrNone );
   923     
   986     
   924     TUint16 fileIdExt ( 0x0000 );
   987     TUint16 fileIdExt ( 0x0000 );
   925     TUint16 fileId = ConvertToPBfileId( iPhoneBookTypeName, fileIdExt );
   988     TUint16 fileId = ConvertToPBfileId( iPhoneBookTypeName, fileIdExt, iMmUiccMessHandler->GetCardType() );
   926     //// Check for PhoenBook Index for which needs to checked
   989     //// Check for PhoenBook Index for which needs to checked
   927     TUint8 pbArrayIndex = ConvertToConfArrayIndex( fileId );
   990     TUint8 pbArrayIndex = ConvertToConfArrayIndex( fileId );
   928 
   991 
   929     switch( iCurrentWritePhase )
   992     switch( iCurrentWritePhase )
   930         {
   993         {
  1224                         }
  1287                         }
  1225                     // Start Deleting Ext data
  1288                     // Start Deleting Ext data
  1226                     iCurrentWritePhase = EPBWritePhase_Write_Ext_Entry;
  1289                     iCurrentWritePhase = EPBWritePhase_Write_Ext_Entry;
  1227                     iExtDeleteOperation= ETrue;
  1290                     iExtDeleteOperation= ETrue;
  1228                     //last index
  1291                     //last index
  1229                     TUint8 index = iExtRecordArrayToBeDelete[ iExtRecordArrayToBeDelete.Count() -1 ];
  1292                     TUint8 index = iExtRecordArrayToBeDelete[
       
  1293                                         iExtRecordArrayToBeDelete.Count() -1 ];
  1230                     ret = UiccPbReqWriteExtDelete(
  1294                     ret = UiccPbReqWriteExtDelete(
  1231                           aFileId,
  1295                           aFileId,
  1232                           aFileIdExt,
  1296                           aFileIdExt,
  1233                           index,
  1297                           index,
  1234                           aTransId );
  1298                           aTransId );
  1361                     {
  1425                     {
  1362                     // Start Writing the Entry
  1426                     // Start Writing the Entry
  1363                     iCurrentWritePhase = EPBWritePhase_Write_Entry;
  1427                     iCurrentWritePhase = EPBWritePhase_Write_Entry;
  1364                     TUint8 index ( 0 );
  1428                     TUint8 index ( 0 );
  1365                         // Start writing main Entry
  1429                         // Start writing main Entry
  1366                     if( ( iPhoneBookEntry->iLocation == 0 )||( PB_MBDN_FID == aFileId ) )
  1430                     if( ( iPhoneBookEntry->iLocation == 0 )||
       
  1431                         ( PB_MBDN_FID == aFileId ) )
  1367                         {
  1432                         {
  1368                         index = iEntryToWrite;
  1433                         index = iEntryToWrite;
  1369                         }
  1434                         }
  1370                     else
  1435                     else
  1371                         {
  1436                         {
  1487             // Remove old Entry from the list 
  1552             // Remove old Entry from the list 
  1488             TInt index = iMmPhoneBookStoreMessHandler->
  1553             TInt index = iMmPhoneBookStoreMessHandler->
  1489                          GetIndexForPresentEntry( iPhoneBookEntry->iLocation, arrayIndex );
  1554                          GetIndexForPresentEntry( iPhoneBookEntry->iLocation, arrayIndex );
  1490             if( 0 <= index )
  1555             if( 0 <= index )
  1491                 {
  1556                 {
  1492                 iMmPhoneBookStoreMessHandler->UpdateEntryFromList( iEntryToUpdateInList, index, arrayIndex );
  1557                 iMmPhoneBookStoreMessHandler->UpdateEntryFromList( 
       
  1558                                                 iEntryToUpdateInList,
       
  1559                                                 index,
       
  1560                                                 arrayIndex );
  1493                 }
  1561                 }
  1494             else
  1562             else
  1495                 {
  1563                 {
  1496                 // Append the Entry to the List
  1564                 // Append the Entry to the List
  1497                 iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList( iEntryToUpdateInList, arrayIndex );
  1565                 iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList(
       
  1566                                                 iEntryToUpdateInList,
       
  1567                                                 arrayIndex );
  1498                 }
  1568                 }
  1499             // If it is MBDN Phone Book then update MBI File also
  1569             // If it is MBDN Phone Book then update MBI File also
  1500             if( PB_MBDN_FID == aFileId)
  1570             if( PB_MBDN_FID == aFileId)
  1501                 {
  1571                 {
  1502                 // Start Writing MBI file
  1572                 // Start Writing MBI file
  1563                 iExtRecordArrayToBeDelete.Remove(
  1633                 iExtRecordArrayToBeDelete.Remove(
  1564                                           iExtRecordArrayToBeDelete.Count() - 1 );
  1634                                           iExtRecordArrayToBeDelete.Count() - 1 );
  1565                 iExtRecordArrayToBeDelete.Compress();
  1635                 iExtRecordArrayToBeDelete.Compress();
  1566                 }
  1636                 }
  1567             // Remove old Entry from the list 
  1637             // Remove old Entry from the list 
  1568             TInt index = iMmPhoneBookStoreMessHandler->GetIndexForPresentEntry( iPhoneBookEntry->iLocation, arrayIndex );
  1638             TInt index = iMmPhoneBookStoreMessHandler->GetIndexForPresentEntry(
       
  1639                                                         iPhoneBookEntry->iLocation,
       
  1640                                                         arrayIndex );
  1569             if( 0 <= index )
  1641             if( 0 <= index )
  1570                 {
  1642                 {
  1571                 iMmPhoneBookStoreMessHandler->RemoveExtEntryFromList( index, arrayIndex);
  1643                 iMmPhoneBookStoreMessHandler->RemoveExtEntryFromList(
       
  1644                                                 index,
       
  1645                                                 arrayIndex);
  1572                 }
  1646                 }
  1573             
  1647             
  1574             if( iExtRecordArrayToBeDelete.Count() > 0 )
  1648             if( iExtRecordArrayToBeDelete.Count() > 0 )
  1575                 {
  1649                 {
  1576                 iCurrentWritePhase = EPBWritePhase_Write_Ext_Entry;
  1650                 iCurrentWritePhase = EPBWritePhase_Write_Ext_Entry;
  1577                 iExtDeleteOperation = ETrue;
  1651                 iExtDeleteOperation = ETrue;
  1578                 TUint8 index = iExtRecordArrayToBeDelete[
  1652                 TUint8 index = iExtRecordArrayToBeDelete[
  1579                                iExtRecordArrayToBeDelete.Count() -1 ];
  1653                                iExtRecordArrayToBeDelete.Count() -1 ];
  1580                 ret = UiccPbReqWriteExtDelete( aFileId, aFileIdExt, index, aTransId );
  1654                 ret = UiccPbReqWriteExtDelete(
       
  1655                               aFileId,
       
  1656                               aFileIdExt,
       
  1657                               index,
       
  1658                               aTransId );
  1581                 }
  1659                 }
  1582             else
  1660             else
  1583                 {
  1661                 {
  1584                 // Start Writing the Entry
  1662                 // Start Writing the Entry
  1585                 iCurrentWritePhase = EPBWritePhase_Write_Entry;
  1663                 iCurrentWritePhase = EPBWritePhase_Write_Entry;
  1586                 TUint8 index ( 0 );
  1664                 TUint8 index ( 0 );
  1587                 // Start writing main Entry
  1665                 // Start writing main Entry
  1588                 if( ( iPhoneBookEntry->iLocation == 0 )||( PB_MBDN_FID == aFileId ) )
  1666                 if( ( iPhoneBookEntry->iLocation == 0 )||
       
  1667                       ( PB_MBDN_FID == aFileId ) )
  1589                     {
  1668                     {
  1590                     index = iEntryToWrite;
  1669                     index = iEntryToWrite;
  1591                     }
  1670                     }
  1592                 else
  1671                 else
  1593                     {
  1672                     {
  1617             
  1696             
  1618             // Start Writing to EXT records
  1697             // Start Writing to EXT records
  1619             // first do the delete records
  1698             // first do the delete records
  1620             if( iExtRecordArrayToBeWrite.Count() > 0 )
  1699             if( iExtRecordArrayToBeWrite.Count() > 0 )
  1621                 {
  1700                 {
       
  1701                 // increment Ext record written
       
  1702                 iExtRecordWritten++;
  1622                 iEntryToUpdateInList->PBEntryExtRecord.Append( iExtRecordArrayToBeWrite[0] );
  1703                 iEntryToUpdateInList->PBEntryExtRecord.Append( iExtRecordArrayToBeWrite[0] );
  1623                 TUint8 index = iExtRecordArrayToBeWrite[0];
  1704                 TUint8 index = iExtRecordArrayToBeWrite[0];
  1624                 ret = UiccPbReqWriteExt(
  1705                 ret = UiccPbReqWriteExt(
  1625                       aTransId,
  1706                       aTransId,
  1626                       index,
  1707                       index,
  1630                 }
  1711                 }
  1631             else
  1712             else
  1632                 {
  1713                 {
  1633                 // Overwrite old Entry from the list 
  1714                 // Overwrite old Entry from the list 
  1634                 TInt index = iMmPhoneBookStoreMessHandler->
  1715                 TInt index = iMmPhoneBookStoreMessHandler->
  1635                              GetIndexForPresentEntry( iPhoneBookEntry->iLocation, arrayIndex );
  1716                                 GetIndexForPresentEntry( 
       
  1717                                   iPhoneBookEntry->iLocation,
       
  1718                                   arrayIndex );
  1636                 if( 0 <= index )
  1719                 if( 0 <= index )
  1637                     {
  1720                     {
  1638                     iMmPhoneBookStoreMessHandler->UpdateEntryFromList( iEntryToUpdateInList, index, arrayIndex );
  1721                     iMmPhoneBookStoreMessHandler->UpdateEntryFromList(
       
  1722                                                    iEntryToUpdateInList,
       
  1723                                                    index,
       
  1724                                                    arrayIndex );
  1639                     }
  1725                     }
  1640                 else
  1726                 else
  1641                     {
  1727                     {
  1642                     // Append the Entry to the List
  1728                     // Append the Entry to the List
  1643                     iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList( iEntryToUpdateInList, arrayIndex );
  1729                     iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList(
       
  1730                                                     iEntryToUpdateInList,
       
  1731                                                     arrayIndex );
  1644                     }
  1732                     }
  1645                 // If it is MBDN PhoenBook then update MBI Profile also
  1733                 // If it is MBDN PhoenBook then update MBI Profile also
  1646                 if( PB_MBDN_FID == aFileId)
  1734                 if( PB_MBDN_FID == aFileId)
  1647                     {
  1735                     {
  1648                     // Start Writing MBI file
  1736                     // Start Writing MBI file