adaptationlayer/tsy/nokiatsy_dll/src/cmmphonebookoperationread3g_adn.cpp
changeset 8 6295dc2169f3
parent 5 8ccc39f9d787
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".
    19 #include <etelmm.h>
    19 #include <etelmm.h>
    20 #include <tisi.h>
    20 #include <tisi.h>
    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 "cmmphonebookoperationread3g_adn.h"
    25 #include "cmmphonebookoperationread3g_adn.h"
    25 #include "OstTraceDefinitions.h"
    26 #include "OstTraceDefinitions.h"
    26 #ifdef OST_TRACE_COMPILER_IN_USE
    27 #ifdef OST_TRACE_COMPILER_IN_USE
    27 #include "cmmphonebookoperationreadTraces.h"
    28 #include "cmmphonebookoperationreadTraces.h"
    28 #include "OstTraceDefinitions.h"
    29 #include "OstTraceDefinitions.h"
    35 
    36 
    36 // EXTERNAL FUNCTION PROTOTYPES
    37 // EXTERNAL FUNCTION PROTOTYPES
    37     // None
    38     // None
    38 
    39 
    39 // CONSTANTS
    40 // CONSTANTS
    40 //const TUint16 KSimPbLocationMBDN = 0x0100;
    41 const TUint8 KAnrOffsetNumLength = 1;  // refer from 3GPP TS 31.102 document
       
    42 const TUint8 KAnrOffsetNumber = 2;
       
    43 const TUint8 KMinLengthEfAnr = 15;
       
    44 const TUint8 KMaxEmptyPatternBuf = 243;
    41 
    45 
    42 // MACROS
    46 // MACROS
    43     // None
    47     // None
    44 
    48 
    45 // LOCAL CONSTANTS AND MACROS
    49 // LOCAL CONSTANTS AND MACROS
    65 
    69 
    66 CMmPhoneBookOperationRead3g_adn::CMmPhoneBookOperationRead3g_adn()
    70 CMmPhoneBookOperationRead3g_adn::CMmPhoneBookOperationRead3g_adn()
    67     {
    71     {
    68     TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::CMmPhoneBookOperationRead3g_adn");
    72     TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::CMmPhoneBookOperationRead3g_adn");
    69     OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_CMMPHONEBOOKOPERATIONREAD3G_ADN, "CMmPhoneBookOperationRead3g_adn::CMmPhoneBookOperationRead3g_adn" );
    73     OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_CMMPHONEBOOKOPERATIONREAD3G_ADN, "CMmPhoneBookOperationRead3g_adn::CMmPhoneBookOperationRead3g_adn" );
    70 
       
    71 
       
    72     }
    74     }
    73 
    75 
    74 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    75 //CMmPhoneBookOperationRead3g_adn::CMmPhoneBookOperationRead3g_adn C++ destructor.
    77 //CMmPhoneBookOperationRead3g_adn::CMmPhoneBookOperationRead3g_adn C++ destructor.
    76 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    80     // None
    82     // None
    81     )
    83     )
    82     {
    84     {
    83     TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::~CMmPhoneBookOperationRead3g_adn");
    85     TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::~CMmPhoneBookOperationRead3g_adn");
    84     OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD3G_ADN_CMMPHONEBOOKOPERATIONREAD3G_ADN, "CMmPhoneBookOperationRead3g_adn::~CMmPhoneBookOperationRead3g_adn" );
    86     OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD3G_ADN_CMMPHONEBOOKOPERATIONREAD3G_ADN, "CMmPhoneBookOperationRead3g_adn::~CMmPhoneBookOperationRead3g_adn" );
    85 
       
    86     }
    87     }
    87 
    88 
    88 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
    89 // CMmPhoneBookOperationRead3g_adn::NewL
    90 // CMmPhoneBookOperationRead3g_adn::NewL
    90 // Creates a new CMmPhonebookOperationRead object instance.
    91 // Creates a new CMmPhonebookOperationRead object instance.
    91 // Two-phased constructor.
    92 // Two-phased constructor.
    92 // -----------------------------------------------------------------------------
    93 // -----------------------------------------------------------------------------
    93 //
    94 //
    94 CMmPhoneBookOperationRead3g_adn* CMmPhoneBookOperationRead3g_adn::NewL
    95 CMmPhoneBookOperationRead3g_adn* CMmPhoneBookOperationRead3g_adn::NewL
    95     (
    96     (
    96             CMmPhoneBookStoreMessHandler* /*aMmPhoneBookStoreMessHandler*/,
    97             CMmPhoneBookStoreMessHandler* aMmPhoneBookStoreMessHandler,
    97             CMmUiccMessHandler* /*aUiccMessHandler*/,
    98             CMmUiccMessHandler* aUiccMessHandler,
    98             const CMmDataPackage* /*aDataPackage*/ // Data
    99             const CMmDataPackage* aDataPackage,
       
   100             TInt aIpc
    99     )
   101     )
   100     {
   102     {
   101     TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::NewL");
   103     TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::NewL");
   102     OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_NEWL, "CMmPhoneBookOperationRead3g_adn::NewL" );
   104     OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_NEWL, "CMmPhoneBookOperationRead3g_adn::NewL" );
   103 
   105 
   104 
   106 
   105     TName phonebookTypeName;
       
   106 
       
   107     CMmPhoneBookOperationRead3g_adn* mmPhoneBookOperationRead3g_adn =
   107     CMmPhoneBookOperationRead3g_adn* mmPhoneBookOperationRead3g_adn =
   108         new( ELeave ) CMmPhoneBookOperationRead3g_adn();
   108         new( ELeave ) CMmPhoneBookOperationRead3g_adn();
   109 
   109 
       
   110     if( ( EMmTsyONStoreReadSizeIPC != aIpc )&&
       
   111         ( EMmTsyONStoreWriteSizeIPC != aIpc ) )
       
   112         {
       
   113         TName phonebookTypeName;
       
   114 
       
   115         const CPhoneBookDataPackage* phoneBookData =
       
   116             static_cast<const CPhoneBookDataPackage*>( aDataPackage );
       
   117 
       
   118         phoneBookData->GetPhoneBookName( phonebookTypeName );
       
   119         
       
   120         // Store phoneBook name 
       
   121         mmPhoneBookOperationRead3g_adn->iPhoneBookTypeName = phonebookTypeName;
       
   122         }
       
   123 
       
   124     mmPhoneBookOperationRead3g_adn->iMmPhoneBookStoreMessHandler =
       
   125         aMmPhoneBookStoreMessHandler;
       
   126     mmPhoneBookOperationRead3g_adn->iMmUiccMessHandler = aUiccMessHandler;
       
   127     
       
   128     mmPhoneBookOperationRead3g_adn->ConstructL();
       
   129     
   110     return mmPhoneBookOperationRead3g_adn;
   130     return mmPhoneBookOperationRead3g_adn;
   111     }
   131     }
   112 
   132 
   113 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
   114 // CMmPhoneBookOperationRead3g_adn::ConstructL
   134 // CMmPhoneBookOperationRead3g_adn::ConstructL
   120     // None
   140     // None
   121     )
   141     )
   122     {
   142     {
   123     TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::ConstructL");
   143     TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::ConstructL");
   124     OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_CONSTRUCTL, "CMmPhoneBookOperationRead3g_adn::ConstructL" );
   144     OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_CONSTRUCTL, "CMmPhoneBookOperationRead3g_adn::ConstructL" );
   125 
   145     
   126     }
   146     iLocationSearch = EFalse;
   127 
   147     iCurrentType1Ef = 0;
       
   148     iCurrentType2Ef = 0;
       
   149     iLocationSearch = EFalse;
       
   150     iNumOfEntriesFilled = 0;
       
   151     iNumOfEntriesToRead = 0;
       
   152     iIndexToRead = 0;
       
   153 
       
   154     }
       
   155 
       
   156 
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CMmPhoneBookOperationRead3g_adn::UICCCreateReq
       
   160 // Create request to read Entry
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 TInt CMmPhoneBookOperationRead3g_adn::UICCCreateReq
       
   164     (
       
   165     TInt aIpc,
       
   166     const CMmDataPackage* aDataPackage,
       
   167     TUint8 aTransId
       
   168     )
       
   169     {
       
   170 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UICCCreateReq");
       
   171 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCCREATEREQ, "CMmPhoneBookOperationRead3g_adn::UICCCreateReq" );
       
   172 
       
   173     TInt ret( KErrNotSupported );
       
   174     
       
   175     const CPhoneBookDataPackage* phoneBookData =
       
   176         static_cast<const CPhoneBookDataPackage*>( aDataPackage );
       
   177 
       
   178     iSavedIPCForComplete = aIpc;
       
   179 
       
   180     // Convert Phone Book name to file id
       
   181     iExtFileId = UICC_ILLEGAL_FILE_ID;
       
   182     iFileId = ConvertToPBfileId(
       
   183                             iPhoneBookTypeName,
       
   184                             iExtFileId,
       
   185                             iMmUiccMessHandler->GetCardType() );
       
   186     iArrayIndex = ConvertToConfArrayIndex( iFileId );
       
   187 
       
   188     
       
   189     switch( aIpc )
       
   190         {
       
   191         case EMmTsyONStoreReadIPC:
       
   192         case EMmTsyONStoreReadEntryIPC:
       
   193             {
       
   194             iFileId = PB_MSISDN_FID;
       
   195             iExtFileId = PB_EXT5_FID;
       
   196             iArrayIndex = EPhonebookTypeMSISDN;
       
   197             // Unpack index to be read
       
   198             aDataPackage->UnPackData( iIndexToRead );
       
   199             ret = USimPbReqRead( iIndexToRead, aTransId );
       
   200             break;
       
   201             }
       
   202         case EMmTsyPhoneBookStoreReadIPC:
       
   203             {
       
   204             CArrayPtrSeg<CPhoneBookStoreEntry>* prtToReadEntriesArray;
       
   205             RMobilePhoneBookStore::TPBIndexAndNumEntries* ptrToIndexAndEntries;
       
   206             phoneBookData->UnPackData(
       
   207                 ptrToIndexAndEntries,
       
   208                 prtToReadEntriesArray );
       
   209 
       
   210             if ( prtToReadEntriesArray && ptrToIndexAndEntries )
       
   211                 {
       
   212                 iPhoneBookStoreCacheArray = prtToReadEntriesArray;
       
   213                 iNumOfEntriesToRead = ptrToIndexAndEntries->iNumSlots;
       
   214                 iNumOfEntriesFilled = 0;
       
   215                 iIndexToRead = ptrToIndexAndEntries->iIndex;
       
   216 
       
   217                 if( PB_ADN_FID == iFileId )
       
   218                     {
       
   219                     // handle for ADN 3g phoneBook
       
   220                     ret = UICCHandleData3gADNReadReq( aDataPackage,
       
   221                                                       aTransId );
       
   222                     }
       
   223                 else
       
   224                     {
       
   225                     ret = USimPbReqRead( iIndexToRead, aTransId );
       
   226                     }
       
   227                 }
       
   228             break;
       
   229             }
       
   230         case EMmTsyONStoreReadSizeIPC:
       
   231         case EMmTsyONStoreWriteSizeIPC:
       
   232             {
       
   233             ret = USimReadWriteSizeReq( aTransId );
       
   234             break;
       
   235             }
       
   236         default:
       
   237             {
       
   238             // Nothing to do here
       
   239 TFLOGSTRING2("TSY: CMmPhoneBookOperationRead3g_adn::UICCCreateReq - Unknown IPC: %d", aIpc);
       
   240 OstTrace1( TRACE_NORMAL, DUP2_CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCCREATEREQ, "CMmPhoneBookOperationRead3g_adn::UICCCreateReq - UnKnown Ipc : %d", aIpc );
       
   241             break;
       
   242             }
       
   243         } // switch-case
       
   244 
       
   245     return ret;
       
   246     }
   128 
   247 
   129 // -----------------------------------------------------------------------------
   248 // -----------------------------------------------------------------------------
   130 // CMmPhoneBookOperationRead3g_adn::UICCHandleData3gADNReadReq
   249 // CMmPhoneBookOperationRead3g_adn::UICCHandleData3gADNReadReq
   131 // Handles Read Resp
   250 // Handles Read Resp
   132 // -----------------------------------------------------------------------------
   251 // -----------------------------------------------------------------------------
   133 //
   252 //
   134 TInt CMmPhoneBookOperationRead3g_adn::UICCHandleData3gADNReadReq
   253 TInt CMmPhoneBookOperationRead3g_adn::UICCHandleData3gADNReadReq
   135         (
   254         (
   136         TInt aFileId,
   255          const CMmDataPackage* aDataPackage,
   137         TInt aFileSFI
   256          TUint8 aTransId         
   138         )
   257         )
   139     {
   258     {
   140     TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UICCHandleData3gADNReadReq");
   259 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UICCHandleData3gADNReadReq");
   141     OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCHANDLEDATA3GADNREADREQ, "CMmPhoneBookOperationRead3g_adn::UICCHandleData3gADNReadReq" );
   260 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCHANDLEDATA3GADNREADREQ, "CMmPhoneBookOperationRead3g_adn::UICCHandleData3gADNReadReq" );
   142 
   261 
   143     TInt ret(KErrNone);
   262     TInt ret(KErrNone);
   144 
   263 
   145     // get the index to be read from phonebook
   264     const CPhoneBookDataPackage* phoneBookData =
   146     TInt index( iIndexToRead );
   265         static_cast<const CPhoneBookDataPackage*>( aDataPackage );
   147     TInt appFileId(APPL_FILE_ID);
   266 
   148 
   267     CArrayPtrSeg<CPhoneBookStoreEntry>* prtToReadEntriesArray;
   149     TUiccReadLinearFixed cmdParams;
   268     RMobilePhoneBookStore::TPBIndexAndNumEntries* ptrToIndexAndEntries;
   150     //cmdParams.messHandlerPtr  = static_cast<MUiccOperationBase*> iMmPhoneBookStoreMessHandler;
   269     phoneBookData->UnPackData(
   151 
   270         ptrToIndexAndEntries,
   152     cmdParams.filePath.Append(static_cast<TUint8>( MF_FILE >> 8 ));
   271         prtToReadEntriesArray );
   153     cmdParams.filePath.Append(static_cast<TUint8>( MF_FILE ));
   272 
   154     cmdParams.filePath.Append(appFileId >> 8);
   273     if ( prtToReadEntriesArray && ptrToIndexAndEntries )
   155     cmdParams.filePath.Append(appFileId);
   274         {
   156     cmdParams.filePath.Append(static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
   275         iPhoneBookStoreCacheArray = prtToReadEntriesArray;
   157     cmdParams.filePath.Append(static_cast<TUint8>( DF_PHONEBOOK ));
   276         iNumOfEntriesToRead = ptrToIndexAndEntries->iNumSlots;
   158 
   277         iNumOfEntriesFilled = 0;
   159     index = iIndexToRead && 0x00FF;
   278         iIndexToRead = ptrToIndexAndEntries->iIndex;
   160 
   279         
   161     if( PB_PBR_FID == aFileId )
   280         if( ( iIndexToRead <= iMmPhoneBookStoreMessHandler->
   162         {
   281                          iPBStoreConf[EPhonebookTypeAdn].iNoOfRecords ) &&
   163         // Find which record no should be read
   282             ( 0 < iIndexToRead ) )
   164         // get ADN file ID from PBR EF data according to which entry needs to be read
   283             {
   165         TUint8 pbrRecordNo(0);
   284             ret = iMmPhoneBookStoreMessHandler->GetPBRRecordNum( iIndexToRead, 
   166         do
   285                                                                  iCurrentPBRRecordNo);
   167             {
   286             }
   168             pbrRecordNo++;
   287         else
   169             index = index-255;
   288             {
   170             }while(index > 255);
   289             // Start Reading from first location , 1st PBR Record
   171 
   290             iCurrentPBRRecordNo = 1;
   172         cmdParams.fileId = PB_PBR_FID;
   291             }
   173         cmdParams.serviceType = UICC_APPL_READ_LINEAR_FIXED;
   292 
   174         cmdParams.record = pbrRecordNo;
   293         if( KErrNone == ret )
   175         }
   294             {
   176     else
   295             ret = UiccReadEfRecordReq(
   177         {
   296                          aTransId,
   178         cmdParams.fileId = aFileId;
   297                          PB_PBR_FID,
   179         cmdParams.serviceType = UICC_APPL_READ_LINEAR_FIXED;
   298                          UICC_SFI_NOT_PRESENT,
   180         cmdParams.record = index;
   299                          iCurrentPBRRecordNo );
   181         cmdParams.fileIdSfi = aFileSFI;
   300             }
   182         }
   301         }
   183     return ret;
   302     return ret;
   184     }
   303     }
   185 
   304 
   186 
   305 
   187 
   306 
       
   307 
       
   308 // -----------------------------------------------------------------------------
       
   309 // CMmPhoneBookOperationRead3g_adn::UiccReadEfRecordReq
       
   310 // Reads record from EFpbr
       
   311 // -----------------------------------------------------------------------------
       
   312 //
       
   313 TInt CMmPhoneBookOperationRead3g_adn::UiccReadEfRecordReq( 
       
   314     const TInt aTraId, 
       
   315     const TUint16 aFileId, 
       
   316     const TUint8 aFileIdSfi,
       
   317     const TUint8 aRecordNo )
       
   318     {
       
   319 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UiccReadEfRecordReq");
       
   320 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFRECORDREQ, "CMmPhoneBookOperationRead3g_adn::UiccReadEfRecordReq" );
       
   321 
       
   322     TUiccReadLinearFixed params;
       
   323     params.messHandlerPtr =
       
   324              static_cast<MUiccOperationBase*>( iMmPhoneBookStoreMessHandler );
       
   325     params.fileId = aFileId;
       
   326     params.fileIdSfi = aFileIdSfi;
       
   327     params.serviceType = UICC_APPL_READ_LINEAR_FIXED;
       
   328     params.record = aRecordNo;
       
   329     params.filePath.Append( static_cast<TUint8>( MF_FILE >> 8 ));
       
   330     params.filePath.Append( static_cast<TUint8>( MF_FILE ));
       
   331     params.filePath.Append( static_cast<TUint8>( APPL_FILE_ID >> 8 ));
       
   332     params.filePath.Append( static_cast<TUint8>( APPL_FILE_ID ));
       
   333     params.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK >> 8 ));
       
   334     params.filePath.Append( static_cast<TUint8>( DF_PHONEBOOK ));
       
   335     params.trId = static_cast<TUiccTrId>( aTraId );
       
   336 
       
   337     return iMmPhoneBookStoreMessHandler->UiccMessHandler()->
       
   338                                           CreateUiccApplCmdReq( params );
       
   339     }
       
   340 
       
   341 
       
   342 
       
   343 
       
   344 // -----------------------------------------------------------------------------
       
   345 // CMmPhoneBookOperationRead::HandleUICCPbRespL
       
   346 // Separate request
       
   347 // -----------------------------------------------------------------------------
       
   348 //
       
   349 TBool CMmPhoneBookOperationRead3g_adn::HandleUICCPbRespL
       
   350     (
       
   351     TInt aStatus,
       
   352     TUint8 /*aDetails*/,
       
   353     const TDesC8 &aFileData,
       
   354     TInt aTransId
       
   355     )
       
   356     {
       
   357 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::HandleUICCPbRespL");
       
   358 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_HANDLEUICCPBRESPL, "CMmPhoneBookOperationRead3g_adn::HandleUICCPbRespL" );
       
   359     
       
   360     TBool completed( EFalse );
       
   361     TInt ret( KErrNone );
       
   362     // Handle possible error case all PhoneBooks extcept Adn
       
   363     if ( UICC_STATUS_OK != aStatus )
       
   364         {
       
   365 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::HandleUICCPbRespL-Unsuccessfully completed by UICC");
       
   366 OstTrace0( TRACE_NORMAL, DUP2_CMMPHONEBOOKOPERATIONREAD3G_ADN_HANDLEUICCPBRESPL, "CMmPhoneBookOperationRead3g_adn::HandleUICCPbRespL - Unsuccessfully completed by UICC" );
       
   367         
       
   368         ret = CMmStaticUtility::UICCCSCauseToEpocError(aStatus );
       
   369         }
       
   370     switch( iSavedIPCForComplete )
       
   371         {
       
   372         case EMmTsyPhoneBookStoreReadIPC:
       
   373         case EMmTsyONStoreReadIPC:
       
   374         case EMmTsyONStoreReadEntryIPC:
       
   375             {
       
   376             if( PB_ADN_FID == iFileId )
       
   377                 {
       
   378                 completed = HandleUICC3gADNRespL( aStatus,
       
   379                                                   aFileData,
       
   380                                                   aTransId );
       
   381                 }
       
   382             else
       
   383                 {
       
   384                 completed = USimPbReadRespL( ret, 
       
   385                                     aTransId,
       
   386                                     aFileData );
       
   387                 }
       
   388             break;
       
   389             }
       
   390         case EMmTsyONStoreReadSizeIPC:
       
   391         case EMmTsyONStoreWriteSizeIPC:
       
   392             {
       
   393             completed = USimReadWriteSizeResp( aFileData, ret );
       
   394             break;
       
   395             }
       
   396         default:
       
   397             {
       
   398             // Nothing to do here
       
   399 TFLOGSTRING2("TSY: CMmPhoneBookOperationRead3g_adn::HandleUICCPbRespL - Unknown IPC: %d", iSavedIPCForComplete);
       
   400 OstTrace1( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD3G_ADN_HANDLEUICCPBRESPL, "CMmPhoneBookOperationRead3g_adn::HandleUICCPbRespL - UnKnown Ipc : =%d", iSavedIPCForComplete );
       
   401             break;
       
   402             }
       
   403         }
       
   404     return completed;
       
   405 
       
   406     }
   188 
   407 
   189 // -----------------------------------------------------------------------------
   408 // -----------------------------------------------------------------------------
   190 // CMmPhoneBookOperationRead3g_adn::HandleUICC3gADNRespL
   409 // CMmPhoneBookOperationRead3g_adn::HandleUICC3gADNRespL
   191 // HAndles Response for ADN phoneBook
   410 // HAndles Response for ADN phoneBook
   192 // -----------------------------------------------------------------------------
   411 // -----------------------------------------------------------------------------
   193 //
   412 //
   194 TInt CMmPhoneBookOperationRead3g_adn::HandleUICC3gADNRespL
   413 TBool CMmPhoneBookOperationRead3g_adn::HandleUICC3gADNRespL
   195     (
   414     (
   196     const TInt aStatus,
   415     const TInt aStatus,
   197     const TDes8 &/*aFileData*/,
   416     const TDesC8 &aFileData,
   198     const TInt /*aTransId*/
   417     const TInt aTransId
   199     )
   418     )
   200     {
   419     {
   201 
   420 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::HandleUICC3gADNRespL");
   202     TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::HandleUICC3gADNRespL");
   421 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCHANDLEDATA3GADNREADREQ, "CMmPhoneBookOperationRead3g_adn::UICCHandleData3gADNReadReq" );
   203     OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCHANDLEDATA3GADNREADREQ, "CMmPhoneBookOperationRead3g_adn::UICCHandleData3gADNReadReq" );
   422 
   204 
   423     TBool completed ( EFalse );
   205 
       
   206     TInt ret(KErrNone);
   424     TInt ret(KErrNone);
   207     // Initialize Application file ID to send in next request
   425     
   208 
   426     switch( iCurrentReadPhase )
   209     // Handle possible error case
   427         {
   210     if ( UICC_STATUS_OK != aStatus )
   428         case EPBReadPhase_PBR_Read_Entry:
   211         {
   429             {
   212         TFLOGSTRING("TSY: CMmPhoneBookOperationRead::HandleUICCPbRespRead-\
   430             ret = UiccReadEfPbrRecordResp( aStatus, 
   213             Unsuccessfully completed by SIMSON");
   431                                            aFileData, 
   214 //OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD_HANDLEUICCPBRESPL, "CMmPhoneBookOperationRead::HandleUICCPbRespL, Unsuccessfully completed by UICC Server" );
   432                                            aTransId );
   215         ret = CMmStaticUtility::UICCCSCauseToEpocError(aStatus );
   433 
   216         }
   434             break;
   217 
   435             }
   218 
   436         case EPBReadPhase_Read_Type1_Entry:
   219     if(UICC_STATUS_OK == aStatus)
   437             {
   220         {
   438             ret = UiccReadEfType1RespL( aStatus, 
   221 
   439                                        aTransId,
   222         // Case: <complete request>
   440                                        aFileData );
   223         if ( KErrNone != ret || 0 == iNumOfEntriesToRead )
   441 
   224             {
   442             break;
   225             // If no entries found
   443             }
   226             if ( 0 == iNumOfEntriesFilled )
   444         case EPBReadPhase_Read_Type2_Entry:
       
   445             {
       
   446             ret = UiccReadEfType2RespL( aStatus, 
       
   447                                        aTransId,
       
   448                                        aFileData );
       
   449 
       
   450             break;
       
   451             }
       
   452         case EPBReadPhase_Read_type3_Entry:
       
   453             {
       
   454             TUint8 fileTag;
       
   455             if( iType2OperationOngoing )
   227                 {
   456                 {
   228                 ret = KErrNotFound;
   457                 fileTag = iType2FileArray[iCurrentType2Ef].tagValue;
   229                 }
   458                 }
   230 
   459             else
   231             }
   460                 {
   232           }
   461                 fileTag = iType1FileArray[iCurrentType1Ef].tagValue;
       
   462                 }
       
   463             ret = UiccReadEfType3RespL( aStatus, 
       
   464                                        aTransId,
       
   465                                        fileTag,
       
   466                                        aFileData );
       
   467             break;
       
   468             }
       
   469         default:
       
   470             {
       
   471 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::HandleUICC3gADNRespL - default branch ");
       
   472 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_HANDLEUICC3GADNRESPL, "CMmPhoneBookOperationRead3g_adn::HandleUICC3gADNRespL - default branch " );
       
   473             break;
       
   474             }
       
   475         }
       
   476 
       
   477     if( ( EPB_3G_ADN_Read_Phase_complete == iCurrentReadPhase ) &&
       
   478         ( 0 != iNumOfEntriesToRead ) &&
       
   479         ( KErrNone == ret ) )
       
   480         {
       
   481         iIndexToRead++;
       
   482         iCurrentEfEntryIndex++;
       
   483         
       
   484         // Calculate The PBR Record Number needs to be read
       
   485         // get the Max no of Entries in one PBR record
       
   486         TInt maxNoOfEntry( iMmPhoneBookStoreMessHandler->
       
   487                 iPBStoreConf[EPhonebookTypeAdn].iNoOfRecords  );
       
   488 
       
   489         TInt maxNoOfPbrRec( iMmPhoneBookStoreMessHandler->
       
   490                 iPBStoreConf[EPhonebookTypeAdn].iPBRNoOfRecords );
       
   491 
       
   492         if( iIndexToRead > ( iCurrentPBRRecordNo * ( maxNoOfEntry/maxNoOfPbrRec ) ) )
       
   493             {
       
   494             // Read Next PBR Record 
       
   495             iCurrentPBRRecordNo++;
       
   496             if( iCurrentPBRRecordNo <= maxNoOfPbrRec )
       
   497                 {
       
   498                 // Reset all Buffers
       
   499                 iType1FileArray.Reset();
       
   500                 iType2FileArray.Reset();
       
   501                 iType3FileArray.Reset();
       
   502                 
       
   503                 iCurrentReadPhase = EPBReadPhase_PBR_Read_Entry;
       
   504                 ret = UiccReadEfRecordReq(
       
   505                              aTransId,
       
   506                              PB_PBR_FID,
       
   507                              UICC_SFI_NOT_PRESENT,
       
   508                              iCurrentPBRRecordNo );
       
   509                 }
       
   510             else
       
   511                 {
       
   512                 // complete with Error
       
   513                 ret = KErrArgument;
       
   514                 iNumOfEntriesToRead = 0;
       
   515                 }
       
   516             }
       
   517         else
       
   518             {
       
   519             // Start Reading next Entry
       
   520             ret = StartReadingEntry( aTransId );
       
   521             }
       
   522         }
       
   523     
       
   524     if( ( KErrNone != ret ) ||
       
   525         ( EPB_3G_ADN_Read_Phase_complete == iCurrentReadPhase ) )
       
   526         {
       
   527         // Check fo Any Entries Found
       
   528         if( ( UICC_STATUS_OK == aStatus )&& ( 0 == iNumOfEntriesFilled ) )
       
   529             {
       
   530             ret = KErrNotFound;
       
   531             }
       
   532         
       
   533         CPhoneBookDataPackage phoneBookData;
       
   534         phoneBookData.SetPhoneBookName( iPhoneBookTypeName );
       
   535         iNumOfEntriesFilled = 0;
       
   536         iPhoneBookStoreCacheArray = NULL;
       
   537         iMmPhoneBookStoreMessHandler->MessageRouter()->Complete(
       
   538                 EMmTsyPhoneBookStoreReadIPC,
       
   539                 &phoneBookData,
       
   540                 ret );
       
   541 
       
   542         // Set flag to indicate that we can remove this operation from array
       
   543         completed = ETrue;
       
   544         }
       
   545 
       
   546     return completed;
       
   547     }
       
   548 
       
   549 
       
   550 
       
   551 
       
   552 // -----------------------------------------------------------------------------
       
   553 // CMmPhoneBookOperationRead3g_adn::UiccReadEfPbrRecordResp
       
   554 // Handles response for EFpbr record reading
       
   555 // -----------------------------------------------------------------------------
       
   556 //
       
   557 TInt CMmPhoneBookOperationRead3g_adn::UiccReadEfPbrRecordResp( 
       
   558     TInt aStatus, 
       
   559     const TDesC8 &aFileData, 
       
   560     TInt aTraId )
       
   561     {
       
   562 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UiccReadEfPbrRecordResp");
       
   563 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFPBRRECORDRESP, "CMmPhoneBookOperationRead3g_adn::UiccReadEfPbrRecordResp" );
       
   564 
       
   565     TInt ret( KErrArgument );
       
   566     if( UICC_STATUS_OK == aStatus )
       
   567         {
       
   568         ret = FetchFileListFromPBR(
       
   569                            aFileData,
       
   570                            KTagConstructedTagA8,
       
   571                            iType1FileArray );
       
   572         ret = FetchFileListFromPBR(
       
   573                            aFileData,
       
   574                            KTagConstructedTagA9,
       
   575                            iType2FileArray );
       
   576         ret = FetchFileListFromPBR(
       
   577                            aFileData,
       
   578                            KTagConstructedTagAA,
       
   579                            iType3FileArray );
       
   580         
       
   581         ret = StartReadingEntry( aTraId );
       
   582         }
       
   583     else
       
   584         {
       
   585 TFLOGSTRING2("TSY: CMmPhoneBookOperationWrite3g_adn::UiccReadEfPbrRecordResp: file reading fails: 0x%x", aStatus );
       
   586 OstTrace1( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFPBRRECORDRESP, "CMmPhoneBookOperationRead3g_adn::UiccReadEfPbrRecordResp;file reading fails: =%d", aStatus );
       
   587         
       
   588         iNumOfEntriesToRead = 0;
       
   589         }
   233     return ret;
   590     return ret;
   234     }
   591     }
   235 
   592 
   236 
   593 
   237 
   594 
       
   595 
       
   596 // -----------------------------------------------------------------------------
       
   597 // CMmPhoneBookOperationRead3g_adn::UiccReadEfType1RespL
       
   598 // Handles response for Type1 File Array record reading
       
   599 // -----------------------------------------------------------------------------
       
   600 //
       
   601 TInt CMmPhoneBookOperationRead3g_adn::UiccReadEfType1RespL(
       
   602         TInt aStatus, 
       
   603         TInt aTraId,
       
   604         const TDesC8 &aFileData )
       
   605     {
       
   606 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UiccReadEfType1RespL");
       
   607 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFTYPE1RESPL, "CMmPhoneBookOperationRead3g_adn::UiccReadEfType1RespL" );
       
   608 
       
   609      TInt ret ( KErrNone );
       
   610      
       
   611      CPhoneBookStoreEntry* phoneBookStoreEntry( NULL );
       
   612      TBool entryAllocatedNow( EFalse ); // Cache entry allocated now or earlier
       
   613      TBool entryStored( EFalse ); // Is entry data stored in cache
       
   614      TBool notEmptyEntry( ETrue ); // If Entryis Empty
       
   615 
       
   616      if( UICC_STATUS_OK == aStatus )
       
   617          {
       
   618          CreateInternalPbEntryL( iIndexToRead );
       
   619          }
       
   620      
       
   621      notEmptyEntry = CheckForEmptyEntry( iType1FileArray[iCurrentType1Ef].tagValue,
       
   622              aFileData );
       
   623      if( notEmptyEntry )
       
   624          {
       
   625          phoneBookStoreEntry = CreateReadPbEntryL(
       
   626              iIndexToRead,
       
   627              entryAllocatedNow );
       
   628          }
       
   629      
       
   630      if( UICC_STATUS_OK == aStatus )
       
   631          {
       
   632          switch( iType1FileArray[iCurrentType1Ef].tagValue )
       
   633              {
       
   634              case UICC_EF_ADN_TAG: 
       
   635                  {
       
   636                  // Get name and number
       
   637                  iMmPhoneBookStoreMessHandler->iPBStoreConf[EPhonebookTypeAdn].
       
   638                  GetPBEntryFromUICCData( aFileData, iNumberBuf, iNameBuf );
       
   639 
       
   640                  // Check if there is Any Ext records
       
   641                  TInt index( iMmPhoneBookStoreMessHandler->
       
   642                          iPBStoreConf[EPhonebookTypeAdn].iAlphaStringlength
       
   643                          + KAdnMandatoryBytes );
       
   644 
       
   645                  TInt extFileTagIndex( KErrNotFound );
       
   646                  iType2OperationOngoing = EFalse;
       
   647                  ret = CheckForExtToContinueNextRead(
       
   648                          index,
       
   649                          aFileData,
       
   650                          aTraId,
       
   651                          extFileTagIndex );
       
   652 
       
   653                  if( KErrNotFound == extFileTagIndex )
       
   654                      {
       
   655                      entryStored = ETrue;
       
   656                      iCurrentType1Ef++;
       
   657 
       
   658                      ret = ContinueWithNextReading( aTraId );
       
   659                      } // no else
       
   660                      
       
   661                  if ( entryStored && notEmptyEntry ) // No extension record, store entry
       
   662                      {
       
   663                      iMmPhoneBookStoreMessHandler->StorePhonebookEntryL(
       
   664                              iNameBuf,
       
   665                              iNumberBuf,
       
   666                              *phoneBookStoreEntry,
       
   667                              PB_ADN_FID,
       
   668                              iIndexToRead );
       
   669 
       
   670                      // Set status in internal list
       
   671                      iStoreEntry->iEntryPresent = ETrue;
       
   672                      iNumberBuf.Zero(); // Reset buffers for next time
       
   673                      iNameBuf.Zero();
       
   674                      }
       
   675                  break;
       
   676                  }
       
   677              case UICC_EF_ANR_TAG:
       
   678                  {
       
   679                  if ( aFileData.Length() && KMinLengthEfAnr <= aFileData.Length() )
       
   680                      {
       
   681                      // Get and save ANR
       
   682                      TInt numLength( aFileData[KAnrOffsetNumLength] );
       
   683                      iNumberBuf.Copy( aFileData.Mid( KAnrOffsetNumber, numLength ) );
       
   684                      }
       
   685                  
       
   686                  TInt extFileTagIndex( KErrNotFound );
       
   687                  iType2OperationOngoing = EFalse;
       
   688                  ret = CheckForExtToContinueNextRead(
       
   689                          KAnrExtRecIdOffset,
       
   690                          aFileData,
       
   691                          aTraId,
       
   692                          extFileTagIndex );
       
   693                  
       
   694                  if( KErrNotFound == extFileTagIndex )
       
   695                      {
       
   696                      entryStored = ETrue;
       
   697                      iCurrentType1Ef++;
       
   698                      ret = ContinueWithNextReading( aTraId );
       
   699                      }  // no else
       
   700                  
       
   701                  
       
   702                  if( entryStored && notEmptyEntry )
       
   703                      {
       
   704                      iMmPhoneBookStoreMessHandler->StoreAnrToPhonebookEntryL(
       
   705                              iNumberBuf,
       
   706                              *phoneBookStoreEntry,
       
   707                              PB_ADN_FID ); // Coding is same as in ADN
       
   708 
       
   709                      // Set status in internal list
       
   710                      iStoreEntry->iEntryPresent = ETrue;
       
   711                      
       
   712                      // Reset buffer for next time
       
   713                      iNumberBuf.Zero();
       
   714                      }  // NO ELSE
       
   715                  break;
       
   716                  }
       
   717              case UICC_EF_EMAIL_TAG:
       
   718              case UICC_EF_SNE_TAG:
       
   719                  {
       
   720                  // In type 1 file, EF SNE contains only alpha string
       
   721                  iNameBuf.Copy( aFileData );
       
   722                  if( notEmptyEntry )
       
   723                      {
       
   724                      iMmPhoneBookStoreMessHandler->StoreSneEmailToPbEntryL(
       
   725                          iNameBuf,
       
   726                          *phoneBookStoreEntry,
       
   727                          iType1FileArray[iCurrentType1Ef].tagValue );
       
   728                      // Set status in internal list
       
   729                      iStoreEntry->iEntryPresent = ETrue;
       
   730                      }
       
   731 
       
   732                  // reset name buffer to reuse next time
       
   733                  iNameBuf.Zero();
       
   734 
       
   735                  iCurrentType1Ef++;
       
   736                  ret = ContinueWithNextReading( aTraId );
       
   737                  break;
       
   738                  }
       
   739              case UICC_EF_IAP_TAG:
       
   740                  {
       
   741                  if( ( aFileData.Length() == iType2FileArray.Count() ) &&
       
   742                      ( notEmptyEntry ) )
       
   743                      {
       
   744                      for ( TInt i( 0 ); i < aFileData.Length() ; i++ )
       
   745                          {
       
   746                          TIapInfo iapinfo;
       
   747                          iapinfo.recordNo = aFileData[i];
       
   748                          iapinfo.fileTag = iType2FileArray[i].tagValue;
       
   749                          iapinfo.fileSfi = iType2FileArray[i].tagSFI;
       
   750                          iapinfo.fileId = iType2FileArray[i].tagFID;
       
   751                          
       
   752                          iStoreEntry->iapInfo.Append( iapinfo );
       
   753                          }
       
   754                      } // no else
       
   755                  
       
   756                  iCurrentType1Ef++;
       
   757                  ret = ContinueWithNextReading( aTraId );
       
   758                  break;
       
   759                  }
       
   760              default:
       
   761                  {
       
   762 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UiccReadEfType1RespL - default branch ");
       
   763 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFTYPE1RESPL, "CMmPhoneBookOperationRead3g_adn::UiccReadEfType1RespL - default branch" );
       
   764 
       
   765                  break;
       
   766                  }
       
   767              }
       
   768          }
       
   769      else
       
   770          {
       
   771          // ADN Read failed for some reason so complete the
       
   772          // operation with error value
       
   773 TFLOGSTRING("TSY: CMmPhoneBookOperationWrite3g_adn::UiccReadEfType1RespL - Type1 File Read failed ");
       
   774 OstTrace0( TRACE_NORMAL, DUP2_CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFTYPE1RESPL, "CMmPhoneBookOperationRead3g_adn::UiccReadEfType1RespL - Type1 file read failed" );
       
   775 
       
   776          iCurrentReadPhase = EPB_3G_ADN_Read_Phase_complete;
       
   777          ret = KErrArgument;
       
   778          }
       
   779 
       
   780 
       
   781          if ( entryAllocatedNow )
       
   782              {
       
   783              TF_ASSERT( NULL != iPhoneBookStoreCacheArray );
       
   784              iPhoneBookStoreCacheArray->AppendL( phoneBookStoreEntry );
       
   785              CleanupStack::Pop( phoneBookStoreEntry );
       
   786              iNumOfEntriesFilled++;
       
   787              } // No else
       
   788 
       
   789          return ret;
       
   790     }
       
   791 
       
   792 
       
   793 
       
   794 // -----------------------------------------------------------------------------
       
   795 // CMmPhoneBookOperationRead3g_adn::UiccReadEfType2RespL
       
   796 // Handles response for Type2 File Array record reading
       
   797 // -----------------------------------------------------------------------------
       
   798 //
       
   799 TInt CMmPhoneBookOperationRead3g_adn::UiccReadEfType2RespL(
       
   800         TInt aStatus, 
       
   801         TInt aTraId,
       
   802         const TDesC8 &aFileData )
       
   803     {
       
   804 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UiccReadEfType2RespL");
       
   805 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFTYPE2RESPL, "CMmPhoneBookOperationRead3g_adn::UiccReadEfType2RespL" );
       
   806 
       
   807      TInt ret ( KErrNone );
       
   808      
       
   809      CPhoneBookStoreEntry* phoneBookStoreEntry( NULL );
       
   810      TBool entryAllocatedNow( EFalse ); // Cache entry allocated now or earlier
       
   811      TBool entryStored( EFalse ); // Is entry data stored in cache
       
   812      TBool notEmptyEntry( ETrue ); // Entry is Empty
       
   813 
       
   814      if( UICC_STATUS_OK == aStatus )
       
   815          {
       
   816          CreateInternalPbEntryL( iIndexToRead );
       
   817          }
       
   818 
       
   819      notEmptyEntry = CheckForEmptyEntry( iType2FileArray[iCurrentType2Ef].tagValue,
       
   820              aFileData );
       
   821      if( notEmptyEntry )
       
   822          {
       
   823          phoneBookStoreEntry = CreateReadPbEntryL(
       
   824              iIndexToRead,
       
   825              entryAllocatedNow );
       
   826          }
       
   827 
       
   828      if( UICC_STATUS_OK == aStatus )
       
   829          {
       
   830          // Check for Filetag 
       
   831          switch( iType2FileArray[iCurrentType2Ef].tagValue )
       
   832              {
       
   833              case UICC_EF_ANR_TAG:
       
   834                  {
       
   835                  if ( aFileData.Length() && KMinLengthEfAnr <= aFileData.Length() )
       
   836                      {
       
   837                      // Get and save ANR
       
   838                      TInt numLength( aFileData[KAnrOffsetNumLength] );
       
   839                      iNumberBuf.Copy( aFileData.Mid( KAnrOffsetNumber, numLength ) );
       
   840                      }
       
   841 
       
   842                  TInt extFileTagIndex( KErrNotFound );
       
   843                  // Check if there is Any Ext records
       
   844                  iType2OperationOngoing = ETrue;
       
   845                  ret = CheckForExtToContinueNextRead(
       
   846                            KAnrExtRecIdOffset,
       
   847                            aFileData,
       
   848                            aTraId,
       
   849                            extFileTagIndex );
       
   850                  
       
   851                  if( KErrNotFound == extFileTagIndex )
       
   852                      {
       
   853                      entryStored = ETrue;
       
   854                      iCurrentType2Ef++;
       
   855                      ret = CheckForNextType2Read( aTraId );
       
   856                      } // no else
       
   857                  
       
   858                  if( entryStored && notEmptyEntry )
       
   859                      {
       
   860                      iMmPhoneBookStoreMessHandler->StoreAnrToPhonebookEntryL(
       
   861                          iNumberBuf,
       
   862                          *phoneBookStoreEntry,
       
   863                          PB_ADN_FID ); // Coding is same as in ADN
       
   864 
       
   865                      // Set status in internal list
       
   866                      iStoreEntry->iEntryPresent = ETrue;
       
   867                      // Reset buffer for next time
       
   868                      iNumberBuf.Zero();
       
   869                      }
       
   870                  break;
       
   871                  }
       
   872              case UICC_EF_EMAIL_TAG:
       
   873              case UICC_EF_SNE_TAG:
       
   874                  {
       
   875                  // In type 1 file, EF SNE contains only alpha string
       
   876                  iNameBuf.Copy( aFileData );
       
   877                  if( notEmptyEntry )
       
   878                      {
       
   879                      iMmPhoneBookStoreMessHandler->StoreSneEmailToPbEntryL(
       
   880                          iNameBuf,
       
   881                          *phoneBookStoreEntry,
       
   882                          iType2FileArray[iCurrentType2Ef].tagValue );
       
   883                      // Set status in internal list
       
   884                      iStoreEntry->iEntryPresent = ETrue;
       
   885                      }
       
   886 
       
   887                  // Reset name buffe rto recuse next time
       
   888                  iNameBuf.Zero();
       
   889 
       
   890                  iCurrentType2Ef++;
       
   891                  ret = CheckForNextType2Read( aTraId );
       
   892                  break;
       
   893                  }
       
   894              default:
       
   895                  {
       
   896 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UiccReadEfType2RespL - default branch");
       
   897 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFTYPE2RESPL, "CMmPhoneBookOperationRead3g_adn::UiccReadEfType2RespL - default branch" );
       
   898                  break;
       
   899                  }
       
   900              }
       
   901          }
       
   902      else
       
   903          {
       
   904 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UiccReadEfType2RespL - Type2 File Read Failed");
       
   905 OstTrace0( TRACE_NORMAL, DUP2_CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFTYPE2RESPL, "CMmPhoneBookOperationRead3g_adn::UiccReadEfType2RespL - Type2 file read failed" );
       
   906 
       
   907          iCurrentReadPhase = EPB_3G_ADN_Read_Phase_complete;
       
   908          ret = KErrArgument;
       
   909          }
       
   910      
       
   911      if ( entryAllocatedNow )
       
   912          {
       
   913          TF_ASSERT( NULL != iPhoneBookStoreCacheArray );
       
   914          iPhoneBookStoreCacheArray->AppendL( phoneBookStoreEntry );
       
   915          CleanupStack::Pop( phoneBookStoreEntry );
       
   916          iNumOfEntriesFilled++;
       
   917          } // No else
       
   918 
       
   919      return ret;
       
   920     }
       
   921 
       
   922 
       
   923 // -----------------------------------------------------------------------------
       
   924 // CMmPhoneBookOperationRead3g_adn::UiccReadEfType3RespL
       
   925 // Handles response for Type3 File Array record reading
       
   926 // -----------------------------------------------------------------------------
       
   927 //
       
   928 TInt CMmPhoneBookOperationRead3g_adn::UiccReadEfType3RespL(
       
   929         TInt aStatus, 
       
   930         TInt aTraId,
       
   931         TUint8 aFileTag,
       
   932         const TDesC8 &aFileData )
       
   933     {
       
   934 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UiccReadEfType2RespL");
       
   935 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFTYPE3RESPL, "CMmPhoneBookOperationRead3g_adn::UiccReadEfType3RespL" );
       
   936     
       
   937      TInt ret ( KErrNone );
       
   938      
       
   939      CPhoneBookStoreEntry* phoneBookStoreEntry( NULL );
       
   940      TBool entryAllocatedNow( EFalse ); // Cache entry allocated now or earlier
       
   941 
       
   942      if( UICC_STATUS_OK == aStatus )
       
   943          {
       
   944          CreateInternalPbEntryL( iIndexToRead );
       
   945          phoneBookStoreEntry = CreateReadPbEntryL(
       
   946              iIndexToRead,
       
   947              entryAllocatedNow );
       
   948          }
       
   949 
       
   950      
       
   951      if( UICC_STATUS_OK == aStatus )
       
   952          {
       
   953          // Store number , if Data length valid and Data type is Additional Data Type
       
   954          if( ( KExtRecordSize == aFileData.Length() ) &&
       
   955              ( KAdditionalNoType == aFileData[0] ) )
       
   956              {
       
   957              // Check if EXT Data Furthe has any ext records
       
   958              if( KTagUnusedbyte != aFileData[UICC_EXT_REC_NO_OFFSET] )
       
   959                  {
       
   960                  // Store Number upto last byte
       
   961                  iNumberBuf.Append(aFileData.Mid(1,UICC_EF_EXT_REC_NUM_LEN));
       
   962 
       
   963                  // read that Entry
       
   964                  TInt index (SearchForFileTagIndex(
       
   965                                UICC_EF_EXT1_TAG,
       
   966                                iType3FileArray,
       
   967                                0 ) );
       
   968                                
       
   969                  ret = UiccReadEfRecordReq(
       
   970                          aTraId,
       
   971                          iType3FileArray[index].tagFID,
       
   972                          iType3FileArray[index].tagSFI,
       
   973                          aFileData[UICC_EXT_REC_NO_OFFSET] );
       
   974                  }
       
   975              else
       
   976                  {
       
   977                  // Check for length upto which no is stored
       
   978                  TInt offset = aFileData.Find( &KTagUnusedbyte,1 );
       
   979                  // store Data
       
   980                  iNumberBuf.Append(aFileData.Mid(1,( offset - 1 )));
       
   981 
       
   982                  // Save to cache
       
   983                  if ( UICC_ADN_PRIM_TAG == aFileTag )
       
   984                      {
       
   985                      iMmPhoneBookStoreMessHandler->StorePhonebookEntryL(
       
   986                          iNameBuf,
       
   987                          iNumberBuf,
       
   988                          *phoneBookStoreEntry,
       
   989                          PB_ADN_FID,
       
   990                          iIndexToRead );
       
   991                      
       
   992                      // Reset Number and name buffer to reuse next time
       
   993                      iNumberBuf.Zero(); // Reset buffers for next time
       
   994                      iNameBuf.Zero();
       
   995                      }
       
   996                  else if ( UICC_ANR_PRIM_TAG == aFileTag )
       
   997                      {
       
   998                      iMmPhoneBookStoreMessHandler->StoreAnrToPhonebookEntryL(
       
   999                          iNumberBuf,
       
  1000                          *phoneBookStoreEntry,
       
  1001                          PB_ADN_FID ); // Same coding as in ADN
       
  1002                      
       
  1003                      // Reset number buffer to reuse next time
       
  1004                      iNumberBuf.Zero();
       
  1005                      }
       
  1006 
       
  1007                  if( iType2OperationOngoing )
       
  1008                      {
       
  1009                      iCurrentType2Ef++;
       
  1010                      // Continue with Type2 File operations
       
  1011                      ret = CheckForNextType2Read( aTraId );
       
  1012                      }
       
  1013                  else
       
  1014                      {
       
  1015                      iCurrentType1Ef++;
       
  1016                      // Continue with next read phase
       
  1017                      ret = ContinueWithNextReading( aTraId );
       
  1018                      }
       
  1019                  }
       
  1020              } // no else
       
  1021          }
       
  1022      else
       
  1023          {
       
  1024          // EXT Reading fails for some reason complete the operation with
       
  1025          // error value
       
  1026 TFLOGSTRING("TSY: CMmPhoneBookOperationRead3g_adn::UiccReadEfType3RespL - EXT Read fail");
       
  1027 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD3G_ADN_UICCREADEFTYPE3RESPL, "CMmPhoneBookOperationRead3g_adn::UiccReadEfType3RespL - EXT Read fail" );
       
  1028          
       
  1029          iCurrentReadPhase = EPB_3G_ADN_Read_Phase_complete;
       
  1030          ret = KErrArgument;
       
  1031          }
       
  1032      
       
  1033      if ( entryAllocatedNow )
       
  1034          {
       
  1035          TF_ASSERT( NULL != iPhoneBookStoreCacheArray );
       
  1036          iPhoneBookStoreCacheArray->AppendL( phoneBookStoreEntry );
       
  1037          CleanupStack::Pop( phoneBookStoreEntry );
       
  1038          iNumOfEntriesFilled++;
       
  1039          } // No else
       
  1040 
       
  1041 
       
  1042      return ret;
       
  1043     }
       
  1044 
       
  1045 
       
  1046 
       
  1047 // -----------------------------------------------------------------------------
       
  1048 // CMmPhoneBookOperationReadg_adn::GetNextType1File
       
  1049 // Get next Type1 valid FileId to be read
       
  1050 // -----------------------------------------------------------------------------
       
  1051 //
       
  1052 TInt CMmPhoneBookOperationRead3g_adn::GetNextType1File()
       
  1053     {
       
  1054 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::GetNextType1File" );
       
  1055 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_GETNEXTTYPE1FILE, "CMmPhoneBookOperationRead3g_adn::GetNextType1File" );
       
  1056     
       
  1057     TInt ret ( KErrNotFound );
       
  1058 
       
  1059     for(; iCurrentType1Ef < iType1FileArray.Count(); )
       
  1060         {
       
  1061         if( ( iType1FileArray[iCurrentType1Ef].tagValue == UICC_EF_PBC_TAG ) ||
       
  1062                 ( iType1FileArray[iCurrentType1Ef].tagValue == UICC_EF_UID_TAG )||
       
  1063                 ( iType1FileArray[iCurrentType1Ef].tagValue == UICC_EF_GRP_TAG ) )
       
  1064             {
       
  1065             iCurrentType1Ef++;
       
  1066             }
       
  1067         else
       
  1068             {
       
  1069             ret = KErrNone;
       
  1070             break;
       
  1071             }
       
  1072         }
       
  1073     return ret ;
       
  1074     }
       
  1075 
       
  1076 
       
  1077 // -----------------------------------------------------------------------------
       
  1078 // CMmPhoneBookOperationRead3g_adn::CheckForExtToContinueNextRead(
       
  1079 // Start Delete Operation for present Entry
       
  1080 // -----------------------------------------------------------------------------
       
  1081 //
       
  1082 TInt CMmPhoneBookOperationRead3g_adn::CheckForExtToContinueNextRead( 
       
  1083         TUint8 aIndex, 
       
  1084         const TDesC8 &aFileData, 
       
  1085         TInt aTraId,
       
  1086         TInt &aExtFileTagIndex )
       
  1087     {
       
  1088 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::CheckForExtToContinueNextRead" );
       
  1089 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_CHECKFOREXTTOCONTINUENEXTREAD, "CMmPhoneBookOperationRead3g_adn::CheckForExtToContinueNextRead" );
       
  1090     
       
  1091     TInt ret ( KErrNone );
       
  1092 
       
  1093     if( KTagUnusedbyte != aFileData[aIndex] )
       
  1094         {
       
  1095         // Start reading Ext1 FileData
       
  1096         iStoreEntry->PBEntryExtRecord.Append( aFileData[aIndex] );
       
  1097         
       
  1098         // Search For Ext1 File tag in iType3FileArray
       
  1099         aExtFileTagIndex = SearchForFileTagIndex(
       
  1100                                UICC_EF_EXT1_TAG,
       
  1101                                iType3FileArray,
       
  1102                                0 ) ;
       
  1103                                
       
  1104         if( KErrNotFound != aExtFileTagIndex )
       
  1105             {
       
  1106             iCurrentReadPhase = EPBReadPhase_Read_type3_Entry;
       
  1107             // Send request to read Ext
       
  1108             ret = UiccReadEfRecordReq(
       
  1109                     aTraId,
       
  1110                     iType3FileArray[aExtFileTagIndex].tagFID,
       
  1111                     iType3FileArray[aExtFileTagIndex].tagSFI,
       
  1112                     aFileData[aIndex] );
       
  1113             } // no else
       
  1114         } // no else
       
  1115     return ret;
       
  1116     }
       
  1117 
       
  1118 
       
  1119 
       
  1120 // -----------------------------------------------------------------------------
       
  1121 // CMmPhoneBookOperationRead3g_adn::ContinueWithNextReading(
       
  1122 // Start Delete Operation for present Entry
       
  1123 // -----------------------------------------------------------------------------
       
  1124 //
       
  1125 TInt CMmPhoneBookOperationRead3g_adn::ContinueWithNextReading( TUint8 aTraId )
       
  1126     {
       
  1127 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::ContinueWithNextReading" );
       
  1128 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_CONTINUEWITHNEXTREADING, "CMmPhoneBookOperationRead3g_adn::ContinueWithNextReading" );
       
  1129     
       
  1130     TInt ret( KErrNone );
       
  1131     if( KErrNone == GetNextType1File() )
       
  1132         {
       
  1133         iType2OperationOngoing = EFalse;
       
  1134         iCurrentReadPhase = EPBReadPhase_Read_Type1_Entry;
       
  1135         ret =  UiccReadEfRecordReq( 
       
  1136                   aTraId, 
       
  1137                   iType1FileArray[iCurrentType1Ef].tagFID, 
       
  1138                   iType1FileArray[iCurrentType1Ef].tagSFI,
       
  1139                   iCurrentEfEntryIndex );
       
  1140         }
       
  1141     else
       
  1142         {
       
  1143         iCurrentType2Ef  = 0;
       
  1144         // Check if there is any type 2 File Data present
       
  1145         if( ( iCurrentType2Ef < iType2FileArray.Count() ) &&
       
  1146                 (  KErrNotFound != GetNextUsedType2FileRecord( iCurrentType2Ef ) ) )
       
  1147             {
       
  1148             iType2OperationOngoing = ETrue;
       
  1149             // Start reading Type2Files
       
  1150             // Continue with next Type 2 File reading
       
  1151             iCurrentReadPhase = EPBReadPhase_Read_Type2_Entry;
       
  1152             ret =  UiccReadEfRecordReq( 
       
  1153                     aTraId, 
       
  1154                     iType2FileArray[iCurrentType2Ef].tagFID, 
       
  1155                     iType2FileArray[iCurrentType2Ef].tagSFI,
       
  1156                     iStoreEntry->iapInfo[iCurrentType2Ef].recordNo );
       
  1157             }
       
  1158         else
       
  1159             {
       
  1160             if( !iLocationSearch )
       
  1161                 {
       
  1162                 iNumOfEntriesToRead--;
       
  1163                 }
       
  1164 
       
  1165             iCurrentReadPhase = EPB_3G_ADN_Read_Phase_complete;
       
  1166             }
       
  1167         }
       
  1168     return ret;
       
  1169     }
       
  1170 
       
  1171 
       
  1172 
       
  1173 // -----------------------------------------------------------------------------
       
  1174 // CMmPhoneBookOperationRead3g_adn::StartReadingEntry
       
  1175 // STart reading Entry
       
  1176 // -----------------------------------------------------------------------------
       
  1177 //
       
  1178 TInt CMmPhoneBookOperationRead3g_adn::StartReadingEntry( TUint8 aTransId )
       
  1179     {
       
  1180     TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::StartReadingEntry" );
       
  1181     OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_STARTREADINGENTRY, "CMmPhoneBookOperationRead3g_adn::StartReadingEntry" );
       
  1182 
       
  1183     TInt ret( KErrNone );
       
  1184     
       
  1185     // Check if index is valid index or Entry to Written on first free entry
       
  1186     if( iIndexToRead <= iMmPhoneBookStoreMessHandler->
       
  1187                               iPBStoreConf[EPhonebookTypeAdn].iNoOfRecords )
       
  1188         {
       
  1189         iType2OperationOngoing = EFalse;
       
  1190         // Start reading The present Entry
       
  1191         iCurrentReadPhase = EPBReadPhase_Read_Type1_Entry;
       
  1192         iCurrentType1Ef = 0;
       
  1193 
       
  1194         if( 0 < iIndexToRead )
       
  1195             {
       
  1196             ret = iMmPhoneBookStoreMessHandler->GetCurrentEfRecNum( 
       
  1197                                                      iCurrentPBRRecordNo, 
       
  1198                                                      iCurrentEfEntryIndex, 
       
  1199                                                      iIndexToRead );
       
  1200             
       
  1201             if( ( KErrNone == GetNextType1File() ) &&
       
  1202                 ( KErrNone == ret ) )
       
  1203                 {
       
  1204                 ret =  UiccReadEfRecordReq( 
       
  1205                         aTransId, 
       
  1206                         iType1FileArray[iCurrentType1Ef].tagFID, 
       
  1207                         iType1FileArray[iCurrentType1Ef].tagSFI,
       
  1208                         iCurrentEfEntryIndex );
       
  1209                 }  // no else
       
  1210             }
       
  1211         else
       
  1212             {
       
  1213             iLocationSearch = ETrue;
       
  1214             // Read First Entry
       
  1215             iIndexToRead  = 1;
       
  1216             iCurrentEfEntryIndex = 1;
       
  1217             
       
  1218             if( KErrNone == GetNextType1File() )
       
  1219                 {
       
  1220                 ret =  UiccReadEfRecordReq( 
       
  1221                           aTransId, 
       
  1222                           iType1FileArray[iCurrentType1Ef].tagFID, 
       
  1223                           iType1FileArray[iCurrentType1Ef].tagSFI,
       
  1224                           iCurrentEfEntryIndex );
       
  1225                 }  // no else
       
  1226             }
       
  1227         }
       
  1228 
       
  1229     return ret;
       
  1230     }
       
  1231 
       
  1232 
       
  1233 
       
  1234 // -----------------------------------------------------------------------------
       
  1235 // CMmPhoneBookOperationCache3G_adn::CreateInternalPbEntryL
       
  1236 //
       
  1237 // -----------------------------------------------------------------------------
       
  1238 //
       
  1239 void CMmPhoneBookOperationRead3g_adn::CreateInternalPbEntryL(
       
  1240     const TInt aLocation )
       
  1241     {
       
  1242 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3G_adn::CreateInternalPbEntryL" );
       
  1243 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_CREATEINTERNALPBENTRYL, "CMmPhoneBookOperationRead3g_adn::CreateInternalPbEntryL" );
       
  1244 
       
  1245     // Check if this entry was already stored in internal list
       
  1246     iStoreEntry = iMmPhoneBookStoreMessHandler->FindEntryFromPbList(
       
  1247         EPhonebookTypeAdn,
       
  1248         aLocation );
       
  1249     if( ! iStoreEntry )
       
  1250         {
       
  1251         // Add new entry to internal list
       
  1252         iStoreEntry = new ( ELeave ) TPBEntry();
       
  1253         iStoreEntry->iEntryIndex = iIndexToRead;
       
  1254         // Not present by default. if some data for this record is found,
       
  1255         // it is set as present
       
  1256         iStoreEntry->iEntryPresent = EFalse;
       
  1257         iMmPhoneBookStoreMessHandler->StoreEntryToPhoneBookList(
       
  1258             iStoreEntry,
       
  1259             EPhonebookTypeAdn );
       
  1260         } // No else
       
  1261     }
       
  1262 
       
  1263 
       
  1264 // -----------------------------------------------------------------------------
       
  1265 // CMmPhoneBookOperationCache3G_adn::CreateReadPbEntryL
       
  1266 //
       
  1267 // -----------------------------------------------------------------------------
       
  1268 //
       
  1269 CPhoneBookStoreEntry* CMmPhoneBookOperationRead3g_adn::CreateReadPbEntryL(
       
  1270     const TInt aLocation, TBool& aAllocatedNow )
       
  1271     {
       
  1272 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::CreateReadPbEntryL" );
       
  1273 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_CREATEREADPBENTRYL, "CMmPhoneBookOperationRead3g_adn::CreateReadPbEntryL" );
       
  1274 
       
  1275     aAllocatedNow = ETrue;
       
  1276     CPhoneBookStoreEntry* phoneBookStoreEntry( NULL );
       
  1277     // Check is there already created CPhoneBookStoreEntry in
       
  1278     // iPhoneBookStoreCacheArray.
       
  1279     for ( TInt i ( 0 ); i < iPhoneBookStoreCacheArray->Count(); i++ )
       
  1280         {
       
  1281         phoneBookStoreEntry = iPhoneBookStoreCacheArray->At( i );
       
  1282         if ( phoneBookStoreEntry &&
       
  1283             ( phoneBookStoreEntry->iLocation == aLocation ) )
       
  1284             {
       
  1285             aAllocatedNow = EFalse;
       
  1286             break;
       
  1287             }
       
  1288         // No else
       
  1289         }
       
  1290 
       
  1291     if ( aAllocatedNow ) // Need to create a new entry
       
  1292         {
       
  1293         phoneBookStoreEntry = new( ELeave ) CPhoneBookStoreEntry;
       
  1294         CleanupStack::PushL( phoneBookStoreEntry );
       
  1295         phoneBookStoreEntry->ConstructL();
       
  1296         phoneBookStoreEntry->iLocation = aLocation;
       
  1297         }
       
  1298     // No else
       
  1299 
       
  1300     return phoneBookStoreEntry;
       
  1301     }
       
  1302 
       
  1303 // -----------------------------------------------------------------------------
       
  1304 // CMmPhoneBookOperationRead3g_adn::SearchForFileTagIndex
       
  1305 // Get the index for ADN file Tag
       
  1306 // -----------------------------------------------------------------------------
       
  1307 //
       
  1308 TInt CMmPhoneBookOperationRead3g_adn::SearchForFileTagIndex(
       
  1309             TUint8 aFileTag,
       
  1310             RArray <TPrimitiveTag>& aFileList,
       
  1311             TUint8 aOffset )
       
  1312     {
       
  1313 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::SearchForFileTagIndex" );
       
  1314 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_SEARCHFORFILETAGINDEX, "CMmPhoneBookOperationRead3g_adn::SearchForFileTagIndex" );
       
  1315     
       
  1316     TInt index( KErrNotFound );
       
  1317     for( TInt count(0); count<aFileList.Count(); count++ )
       
  1318         {
       
  1319         if( ( aFileTag == aFileList[count].tagValue ) &&
       
  1320             ( aOffset <= count ) )
       
  1321             {
       
  1322             index = count;
       
  1323             break;
       
  1324             }  // no else
       
  1325         }
       
  1326     return( index );
       
  1327     }
       
  1328 
       
  1329 
       
  1330 
       
  1331 // -----------------------------------------------------------------------------
       
  1332 // CMmPhoneBookOperationRead3g_adn::CheckForNextType2Read(
       
  1333 // Check for next Type 1 Read
       
  1334 // -----------------------------------------------------------------------------
       
  1335 //
       
  1336 TInt CMmPhoneBookOperationRead3g_adn::CheckForNextType2Read( TInt aTraId )
       
  1337     {
       
  1338 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::CheckForNextType2Read" );
       
  1339 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_CHECKFORNEXTTYPE2READ, "CMmPhoneBookOperationRead3g_adn::CheckForNextType2Read" );
       
  1340     
       
  1341     TInt ret ( KErrNone );
       
  1342     // Check if there is any type 2 File Data present
       
  1343     if( ( iCurrentType2Ef < iType2FileArray.Count() ) &&
       
  1344         ( KErrNotFound != GetNextUsedType2FileRecord( iCurrentType2Ef ) ) )
       
  1345         {
       
  1346         iType2OperationOngoing = ETrue;
       
  1347         // Start reading Type2Files
       
  1348         // Continue with next Type 2 File reading
       
  1349         iCurrentReadPhase = EPBReadPhase_Read_Type2_Entry;
       
  1350         ret =  UiccReadEfRecordReq( 
       
  1351                 aTraId, 
       
  1352                 iType2FileArray[iCurrentType2Ef].tagFID, 
       
  1353                 iType2FileArray[iCurrentType2Ef].tagSFI,
       
  1354                 iStoreEntry->iapInfo[iCurrentType2Ef].recordNo );
       
  1355         }
       
  1356     else
       
  1357         {
       
  1358         if( !iLocationSearch )
       
  1359             {
       
  1360             iNumOfEntriesToRead--;
       
  1361             }
       
  1362 
       
  1363         iCurrentReadPhase = EPB_3G_ADN_Read_Phase_complete;
       
  1364         }
       
  1365     return ret;
       
  1366     }
       
  1367 
       
  1368 
       
  1369 
       
  1370 // -----------------------------------------------------------------------------
       
  1371 // CMmPhoneBookOperationRead3g_adn::GetNextUsedType2FileRecord
       
  1372 // Start Delete Operation for present Entry
       
  1373 // -----------------------------------------------------------------------------
       
  1374 //
       
  1375 TInt CMmPhoneBookOperationRead3g_adn::GetNextUsedType2FileRecord( TInt &aOffset )
       
  1376     {
       
  1377 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::GetNextUsedType2FileRecord" );
       
  1378 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_GETNEXTUSEDTYPE2FILERECORD, "CMmPhoneBookOperationRead3g_adn::GetNextUsedType2FileRecord" );
       
  1379     
       
  1380     TInt index( KErrNotFound );
       
  1381     if( iStoreEntry->iapInfo.Count() == iType2FileArray.Count() )
       
  1382         {
       
  1383         for( TInt count( aOffset ); count < iType2FileArray.Count(); count++ )
       
  1384             {
       
  1385             if( KTagUnusedbyte != iStoreEntry->iapInfo[count].recordNo )
       
  1386                 {
       
  1387                 aOffset = count;
       
  1388                 index = KErrNone;
       
  1389                 break;
       
  1390                 }  // no else
       
  1391             }
       
  1392         }
       
  1393     return index;
       
  1394     }
       
  1395 
       
  1396 
       
  1397 // -----------------------------------------------------------------------------
       
  1398 // CMmPhoneBookOperationRead3G_adn::UiccGetSearchPattern
       
  1399 // resolves P2 and search data for command SEARCH RECORD depending on file type
       
  1400 // -----------------------------------------------------------------------------
       
  1401 //
       
  1402 TBool CMmPhoneBookOperationRead3g_adn::CheckForEmptyEntry(
       
  1403     const TUint8 aFileType,
       
  1404     const TDesC8 &aFileData )
       
  1405     {
       
  1406 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::CheckForEmptyEntry" );
       
  1407 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_CHECKFOREMPTYENTRY, "CMmPhoneBookOperationRead3g_adn::CheckForEmptyEntry" );
       
  1408 
       
  1409     TBool notEmpty( ETrue );
       
  1410     TBuf8<KMaxEmptyPatternBuf> emptyData;
       
  1411     GetEmptyRecordPattern( aFileType,
       
  1412                            emptyData );
       
  1413     for( TInt count(0); count < emptyData.Length(); count++ )
       
  1414         {
       
  1415         if( aFileData[count] == emptyData[count] )
       
  1416             {
       
  1417             notEmpty = EFalse;
       
  1418             break;
       
  1419             }
       
  1420         }
       
  1421     return notEmpty;
       
  1422     }
       
  1423 
       
  1424 
       
  1425 // -----------------------------------------------------------------------------
       
  1426 // CMmPhoneBookOperationRead3G_adn::UiccGetSearchPattern
       
  1427 // resolves P2 and search data for command SEARCH RECORD depending on file type
       
  1428 // -----------------------------------------------------------------------------
       
  1429 //
       
  1430 void CMmPhoneBookOperationRead3g_adn::GetEmptyRecordPattern(
       
  1431     const TUint8 aFileType,
       
  1432     TDes8& aEmptyPattern )
       
  1433     {
       
  1434 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::GetEmptyRecordPattern" );
       
  1435 OstTrace0( TRACE_NORMAL, CMMPHONEBOOKOPERATIONREAD3G_ADN_GETEMPTYRECORDPATTERN, "CMmPhoneBookOperationRead3G_adn::GetEmptyRecordPattern" );
       
  1436 
       
  1437     switch( aFileType )
       
  1438         {
       
  1439         case UICC_ADN_PRIM_TAG:
       
  1440             {
       
  1441             TInt alphaStringLength( iMmPhoneBookStoreMessHandler->
       
  1442                 iPBStoreConf[EPhonebookTypeAdn].iAlphaStringlength );
       
  1443             // If aplha string field is included in entry, search pattern is
       
  1444             // all alpa bytes 'FF' and number length 0 and TON&NPI 'FF'
       
  1445             if ( alphaStringLength )
       
  1446                 {
       
  1447                 aEmptyPattern.AppendFill( KTagUnusedbyte, alphaStringLength );
       
  1448                 aEmptyPattern.Append( 0x00 ); // Search for number length zero
       
  1449                 aEmptyPattern.Append( KTagUnusedbyte ); // and TON&NPI 'FF'
       
  1450                 }
       
  1451             // Alpha string does not exists, search pattern is for empty number
       
  1452             else
       
  1453                 {
       
  1454                 aEmptyPattern.Append( 0x00 ); // Search for number length zero
       
  1455                 aEmptyPattern.Append( KTagUnusedbyte ); // and TON&NPI FF
       
  1456                 }
       
  1457             break;
       
  1458             }
       
  1459         case UICC_IAP_PRIM_TAG:
       
  1460             {
       
  1461             // Number of bytes in EFiap is same as file amount
       
  1462             // in EFpbr list with tag "A9". In other words, count
       
  1463             // of type 2 files
       
  1464             for( TInt i( 0 ); i < iType2FileArray.Count(); i++ )
       
  1465                 {
       
  1466                 aEmptyPattern.Append( 0x00 );
       
  1467                 }
       
  1468             break;
       
  1469             }
       
  1470         case UICC_ANR_PRIM_TAG:
       
  1471             {
       
  1472             aEmptyPattern.Append( KTagUnusedbyte ); // Check for AAS record there is none
       
  1473             aEmptyPattern.Append( 0x00 ); // For SSC/ BCD Number Length 0
       
  1474             aEmptyPattern.Append( KTagUnusedbyte ); //TON&NPI FF
       
  1475             aEmptyPattern.Append( KTagUnusedbyte ); // SSC/BCD forst Byte is FF
       
  1476             break;
       
  1477             }
       
  1478         case UICC_SNE_PRIM_TAG:
       
  1479         case UICC_EMAIL_PRIM_TAG:
       
  1480             {
       
  1481             // If first byte of the EF record is 0xFF, the record
       
  1482             // is empty
       
  1483             aEmptyPattern.Append( KTagUnusedbyte );
       
  1484             break;
       
  1485             }
       
  1486         default:
       
  1487             {
       
  1488 TFLOGSTRING( "TSY: CMmPhoneBookOperationRead3g_adn::GetEmptyRecordPattern: default" );
       
  1489 OstTrace0( TRACE_NORMAL, DUP1_CMMPHONEBOOKOPERATIONREAD3G_ADN_GETEMPTYRECORDPATTERN, "CMmPhoneBookOperationRead3g_adn::GetEmptyRecordPattern : default" );
       
  1490             break;
       
  1491             }
       
  1492         }
       
  1493     }
       
  1494