adaptationlayer/tsy/nokiatsy_dll/src/cmmphonebookoperationdelete.cpp
changeset 6 942573423a60
parent 5 8ccc39f9d787
child 7 fa67e03b87df
equal deleted inserted replaced
5:8ccc39f9d787 6:942573423a60
   154             {
   154             {
   155             phoneBookData->UnPackData( iIndex );
   155             phoneBookData->UnPackData( iIndex );
   156 
   156 
   157             if( PB_MBDN_FID == iFileId )
   157             if( PB_MBDN_FID == iFileId )
   158                 {
   158                 {
       
   159                 // Store MBI Profile
       
   160                 iMBIProfileType = iIndex;
   159                 // For MBDN PhoneBook first read MBI file 
   161                 // For MBDN PhoneBook first read MBI file 
   160                 // Check if the mailbox inidcation type is correct
   162                 // Check if the mailbox inidcation type is correct
   161                 if( iIndex <= iMmPhoneBookStoreMessHandler->
   163                 if( iIndex < iMmPhoneBookStoreMessHandler->
   162                         iPBStoreConf[iArrayIndex].iMbiRecLen )
   164                         iPBStoreConf[iArrayIndex].iMbiRecLen )
   163                     {
   165                     {
   164                     iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
   166                     iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
   165                     // read MBDN record number from MBI first record Profile number
   167                     // read MBDN record number from MBI first record Profile number
   166                     ret = UiccPbReqReadMBI();
   168                     ret = UiccPbReqReadMBI();
   176                 }
   178                 }
   177             break;
   179             break;
   178             }
   180             }
   179         case EMmTsyPhoneBookStoreDeleteAllIPC:
   181         case EMmTsyPhoneBookStoreDeleteAllIPC:
   180             {
   182             {
   181             iNumOfEntries = iMmPhoneBookStoreMessHandler->
   183             if( PB_MBDN_FID != iFileId)
   182                 iPBStoreConf[iArrayIndex].iNoOfRecords;
   184                 {
   183             if ( iNumOfEntries )
   185                 iNumOfEntries = iMmPhoneBookStoreMessHandler->
   184                 {
   186                     iPBStoreConf[iArrayIndex].iNoOfRecords;
   185                 // Start to delete entries from the last one
   187                 if ( iNumOfEntries )
   186                 iIndex = iNumOfEntries;
   188                     {
   187                 ret = UiccPbReqDelete();
   189                     // Start to delete entries from the last one
   188                 iNumOfEntries--;
   190                     iIndex = iNumOfEntries;
   189                 }
   191                     ret = UiccPbReqDelete();
       
   192                     iNumOfEntries--;
       
   193                     }
       
   194                 }
       
   195             else
       
   196                 {
       
   197                 // For first Profile Type Read
       
   198                 iMBIProfileType = 0;
       
   199                 iIndex = iMBIProfileType;
       
   200                 // For MBDN PhoneBook first read MBI file 
       
   201                 // Check if the mailbox inidcation type is correct
       
   202                 if( iMBIProfileType < iMmPhoneBookStoreMessHandler->
       
   203                         iPBStoreConf[iArrayIndex].iMbiRecLen )
       
   204                     {
       
   205                     iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
       
   206                     // read MBDN record number from MBI first record Profile number
       
   207                     ret = UiccPbReqReadMBI();
       
   208                     }
       
   209                 else
       
   210                     {
       
   211                     ret = KErrArgument;
       
   212                     }
       
   213                 }
       
   214                 
   190             break;
   215             break;
   191             }
   216             }
   192 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
   217 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
   193         case ECustomDeleteAlphaStringIPC:
   218         case ECustomDeleteAlphaStringIPC:
   194             {
   219             {
   214 TInt CMmPhoneBookOperationDelete::UiccPbReqDelete()
   239 TInt CMmPhoneBookOperationDelete::UiccPbReqDelete()
   215     {
   240     {
   216 TFLOGSTRING3("TSY: CMmPhoneBookOperationDelete::UiccPbReqDelete, iTransId:%d,index:%d", iTransId, iIndex);
   241 TFLOGSTRING3("TSY: CMmPhoneBookOperationDelete::UiccPbReqDelete, iTransId:%d,index:%d", iTransId, iIndex);
   217 OstTraceExt2( TRACE_NORMAL, CMmPhoneBookOperationDelete_UICCPBREQWRITEL, "CMmPhoneBookOperationDelete::UiccPbReqDelete;iTransId=%hhu;iIndex=%hd", iTransId, iIndex );
   242 OstTraceExt2( TRACE_NORMAL, CMmPhoneBookOperationDelete_UICCPBREQWRITEL, "CMmPhoneBookOperationDelete::UiccPbReqDelete;iTransId=%hhu;iIndex=%hd", iTransId, iIndex );
   218 
   243 
   219     TInt ret( KErrNotSupported );
   244     TInt ret( KErrArgument );
   220 
   245 
   221     switch ( iFileId )
   246     switch ( iFileId )
   222         {
   247         {
   223         case PB_ADN_FID:
   248         case PB_ADN_FID:
   224         case PB_FDN_FID:
   249         case PB_FDN_FID:
   418 
   443 
   419         cmdParams.trId = static_cast<TUiccTrId>( iTransId );
   444         cmdParams.trId = static_cast<TUiccTrId>( iTransId );
   420         cmdParams.fileId = PB_MBI_FID;
   445         cmdParams.fileId = PB_MBI_FID;
   421         cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   446         cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   422         cmdParams.dataAmount = 1;
   447         cmdParams.dataAmount = 1;
   423         cmdParams.dataOffset = iIndex;
   448         cmdParams.dataOffset = iMBIProfileType;
   424         cmdParams.record = 1;   // only first profile number is supported
   449         cmdParams.record = 1;   // only first profile number is supported
   425         
   450         
   426         
   451         
   427         if( KErrNone == ret )
   452         if( KErrNone == ret )
   428             {
   453             {
   459         }
   484         }
   460     cmdParams.trId = static_cast<TUiccTrId>( iTransId );
   485     cmdParams.trId = static_cast<TUiccTrId>( iTransId );
   461     cmdParams.fileId = PB_MBI_FID;
   486     cmdParams.fileId = PB_MBI_FID;
   462     cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   487     cmdParams.serviceType =  UICC_APPL_READ_LINEAR_FIXED ;
   463     cmdParams.dataAmount = 1;
   488     cmdParams.dataAmount = 1;
   464     cmdParams.dataOffset = iIndex;
   489     cmdParams.dataOffset = iMBIProfileType;
   465     cmdParams.record = 1;   // only first profile number is supported
   490     cmdParams.record = 1;   // only first profile number is supported
   466 
   491 
   467     // Append FileData needs to be write
   492     // Append FileData needs to be write
   468     cmdParams.fileData.Append( 0 );
   493     cmdParams.fileData.Append( 0 );
   469     
   494     
   599 // ---------------------------------------------------------------------------
   624 // ---------------------------------------------------------------------------
   600 //
   625 //
   601 TInt CMmPhoneBookOperationDelete::HandleWriteMBIReadResp(
   626 TInt CMmPhoneBookOperationDelete::HandleWriteMBIReadResp(
   602         TInt aStatus,
   627         TInt aStatus,
   603         TUint8 aDetails,
   628         TUint8 aDetails,
       
   629         TBool &aComplete,
   604         const TDesC8 &aFileData ) 
   630         const TDesC8 &aFileData ) 
   605     {
   631     {
   606     TInt ret ( KErrNone );
   632     TInt ret ( KErrNone );
   607 TFLOGSTRING("TSY: CMmPhoneBookOperationDelete::HandleWriteMBIReadResp");
   633 TFLOGSTRING("TSY: CMmPhoneBookOperationDelete::HandleWriteMBIReadResp");
   608 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONDELETE_HANDLEWRITEMBIREADRESP, "CMmPhoneBookOperationDelete::HandleWriteMBIReadResp" );
   634 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONDELETE_HANDLEWRITEMBIREADRESP, "CMmPhoneBookOperationDelete::HandleWriteMBIReadResp" );
   609 
   635 
   610     // Store MBI Profile
       
   611     iMBIProfileType = iIndex;
       
   612     if( UICC_STATUS_OK  == aStatus )
   636     if( UICC_STATUS_OK  == aStatus )
   613         {
   637         {
   614         iIndex = aFileData[0];
   638         iIndex = aFileData[0];
   615         ret = UiccPbReqDelete();
   639         if( ( 0 != iIndex ) && ( iIndex <= iMmPhoneBookStoreMessHandler->
       
   640                 iPBStoreConf[iArrayIndex].iNoOfRecords ) )
       
   641             {
       
   642             ret = UiccPbReqDelete();
       
   643             }
       
   644         else
       
   645             {
       
   646             // Again read next MBI Profile type
       
   647             iMBIProfileType++;
       
   648             if ( EMmTsyPhoneBookStoreDeleteAllIPC == iIpc &&
       
   649                     ( iMBIProfileType < iMmPhoneBookStoreMessHandler->
       
   650                             iPBStoreConf[iArrayIndex].iMbiRecLen ) )
       
   651                 {
       
   652                 iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
       
   653                 // read MBDN record number from MBI first record Profile number
       
   654                 ret = UiccPbReqReadMBI();
       
   655                 }
       
   656             else
       
   657                 {
       
   658                 if( EMmTsyPhoneBookStoreDeleteIPC == iIpc )
       
   659                     {
       
   660                     ret = KErrArgument;
       
   661                     }
       
   662                 aComplete = ETrue;
       
   663                 }
       
   664             }
   616         }
   665         }
   617     else
   666     else
   618         {
   667         {
   619         if( UICC_SECURITY_CONDITIONS_NOT_SATISFIED == aDetails )
   668         if( UICC_SECURITY_CONDITIONS_NOT_SATISFIED == aDetails )
   620             {
   669             {
   645 OstTrace0( TRACE_NORMAL, CMmPhoneBookOperationDelete_HANDLEUICCPBRESPL, "CMmPhoneBookOperationDelete::HandleUICCPbRespL" );
   694 OstTrace0( TRACE_NORMAL, CMmPhoneBookOperationDelete_HANDLEUICCPBRESPL, "CMmPhoneBookOperationDelete::HandleUICCPbRespL" );
   646 
   695 
   647     TInt ret( KErrNone );
   696     TInt ret( KErrNone );
   648     TBool complete( EFalse );
   697     TBool complete( EFalse );
   649 
   698 
   650     TInt maxNumLength( 0 );
       
   651     TInt location( 0 );
   699     TInt location( 0 );
   652 
   700 
   653     if ( UICC_STATUS_OK == aStatus )
   701     if ( UICC_STATUS_OK == aStatus )
   654         {
   702         {
   655         switch ( iCurrentDeletePhase )
   703         switch ( iCurrentDeletePhase )
   733                     }
   781                     }
   734                 else
   782                 else
   735                     {
   783                     {
   736                         // Ready for complete
   784                         // Ready for complete
   737                         complete = ETrue;
   785                         complete = ETrue;
   738                         maxNumLength = iMmPhoneBookStoreMessHandler->
       
   739                             iPBStoreConf[iArrayIndex].iNumlength;
       
   740                     if ( EMmTsyPhoneBookStoreDeleteAllIPC == iIpc &&
   786                     if ( EMmTsyPhoneBookStoreDeleteAllIPC == iIpc &&
   741                         iNumOfEntries )
   787                         iNumOfEntries )
   742                         {
   788                         {
   743                         // Continue deleting entries
   789                         // Continue deleting entries
   744                         iIndex = iNumOfEntries;
   790                         iIndex = iNumOfEntries;
   747                         }
   793                         }
   748                     else
   794                     else
   749                         {
   795                         {
   750                         // Ready for complete
   796                         // Ready for complete
   751                         complete = ETrue;
   797                         complete = ETrue;
   752                         maxNumLength = iMmPhoneBookStoreMessHandler->
       
   753                             iPBStoreConf[iArrayIndex].iNumlength;
       
   754                         // In case of delete all location is 0
   798                         // In case of delete all location is 0
   755                         if ( EMmTsyPhoneBookStoreDeleteIPC == iIpc )
   799                         if ( EMmTsyPhoneBookStoreDeleteIPC == iIpc )
   756                             {
   800                             {
   757                             location = iIndex;
   801                             location = iIndex;
   758                             }
   802                             }
   760                     }
   804                     }
   761                 break;
   805                 break;
   762                 }
   806                 }
   763             case EPBDeletePhase_Read_MBI_profile:
   807             case EPBDeletePhase_Read_MBI_profile:
   764                 {
   808                 {
   765                 ret = HandleWriteMBIReadResp( aStatus, aDetails, aFileData );
   809                 ret = HandleWriteMBIReadResp( aStatus, aDetails, complete, aFileData );
   766                 break;
   810                 break;
   767                 }
   811                 }
   768             case EPBDeletePhase_delete_MBI_profile:
   812             case EPBDeletePhase_delete_MBI_profile:
   769                 {
   813                 {
   770                 if( UICC_STATUS_OK  != aStatus )
   814                 if( UICC_STATUS_OK  != aStatus )
   778                         ret = KErrArgument;
   822                         ret = KErrArgument;
   779                         }
   823                         }
   780                     }
   824                     }
   781                 else
   825                 else
   782                     {
   826                     {
   783                     // Ready for complete
   827                     // Continue deleting entries
   784                     complete = ETrue;
   828                     // increment iMBIProfileType to read next profile
   785                     maxNumLength = iMmPhoneBookStoreMessHandler->
   829                     iMBIProfileType++;
   786                         iPBStoreConf[iArrayIndex].iNumlength;
   830                     
   787                     location = iMBIProfileType;
   831                     if ( EMmTsyPhoneBookStoreDeleteAllIPC == iIpc &&
       
   832                         ( iMBIProfileType < iMmPhoneBookStoreMessHandler->
       
   833                                 iPBStoreConf[iArrayIndex].iMbiRecLen ) )
       
   834                         {
       
   835                         iCurrentDeletePhase = EPBDeletePhase_Read_MBI_profile;
       
   836                         // read MBDN record number from MBI first record Profile number
       
   837                         ret = UiccPbReqReadMBI();
       
   838                         }
       
   839                     else
       
   840                         {
       
   841                         // Ready for complete
       
   842                         complete = ETrue;
       
   843                         // In case of delete all location is 0
       
   844                         if ( EMmTsyPhoneBookStoreDeleteIPC == iIpc )
       
   845                             {
       
   846                             location = iMBIProfileType - 1 ;
       
   847                             }
       
   848                         }
   788                     }
   849                     }
   789                 break;
   850                 break;
   790                 }
   851                 }
   791             default:
   852             default:
   792                 {
   853                 {
   811         }
   872         }
   812 
   873 
   813     if ( complete )
   874     if ( complete )
   814         {
   875         {
   815         TPBEntryInfo pbEntryInfo;
   876         TPBEntryInfo pbEntryInfo;
   816         pbEntryInfo.iMaxNumLength = maxNumLength;
   877         pbEntryInfo.iMaxNumLength = iMmPhoneBookStoreMessHandler->
       
   878         iPBStoreConf[iArrayIndex].iNumlength;
   817         pbEntryInfo.iLocation = location;
   879         pbEntryInfo.iLocation = location;
   818 
   880 
   819         CPhoneBookDataPackage phoneBookData;
   881         CPhoneBookDataPackage phoneBookData;
   820         phoneBookData.SetPhoneBookName( iPhoneBookTypeName );
   882         phoneBookData.SetPhoneBookName( iPhoneBookTypeName );
   821         phoneBookData.PackData( &pbEntryInfo );
   883         phoneBookData.PackData( &pbEntryInfo );