telephonyserverplugins/common_tsy/commontsy/src/mmstorage/cmmphonebookstoretsy.cpp
branchRCL_3
changeset 66 07a122eea281
parent 65 630d2f34d719
child 74 9200f38b1324
equal deleted inserted replaced
65:630d2f34d719 66:07a122eea281
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 //
    14 //
    15 
    15 
    16 
    16 
    17 
    17 
    18 //  INCLUDE FILES
    18 //  INCLUDE FILES
    19 
       
    20 #include "OstTraceDefinitions.h"
       
    21 #ifdef OST_TRACE_COMPILER_IN_USE
       
    22 #include "cmmphonebookstoretsyTraces.h"
       
    23 #endif
       
    24 
       
    25 #include "cmmphonebookstoretsy.h"
    19 #include "cmmphonebookstoretsy.h"
    26 #include "cmmpblist.h"
    20 #include "cmmpblist.h"
    27 #include "cmmphonebookstoregsmext.h"
    21 #include "cmmphonebookstoregsmext.h"
    28 #include "CMmCustomTsy.h"
    22 #include "CMmCustomTsy.h"
       
    23 #include <ctsy/tflogger.h>
    29 #include <ctsy/rmmcustomapi.h>
    24 #include <ctsy/rmmcustomapi.h>
    30 #include "cmmmessagemanagerbase.h"
    25 #include "cmmmessagemanagerbase.h"
    31 #include "cmmtsyreqhandlestore.h"
    26 #include "cmmtsyreqhandlestore.h"
    32 #include <ctsy/pluginapi/cmmdatapackage.h>
    27 #include <ctsy/pluginapi/cmmdatapackage.h>
    33 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
    28 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
    42     {
    37     {
    43     }
    38     }
    44 
    39 
    45 void CMmPhoneBookStoreTsy::ConstructL( const TDesC& aName )
    40 void CMmPhoneBookStoreTsy::ConstructL( const TDesC& aName )
    46     {
    41     {
    47 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CONSTRUCTL_1, "TSY: CMmPhoneBookStoreTsy::ConstructL - entered");
    42 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ConstructL - entered");
    48 #ifdef REQHANDLE_TIMER
    43 #ifdef REQHANDLE_TIMER
    49     // Create req handle store
    44     // Create req handle store
    50     iTsyReqHandleStore = CMmTsyReqHandleStore::NewL( this,
    45     iTsyReqHandleStore = CMmTsyReqHandleStore::NewL( this,
    51         iMmPhoneTsy,
    46         iMmPhoneTsy,
    52         EMmTsyNumOfStorageRequests,
    47         EMmTsyNumOfStorageRequests,
    77     // Set extension mode
    72     // Set extension mode
    78     SetActivePBExtension( iMmPhoneBookStoreExtInterface );
    73     SetActivePBExtension( iMmPhoneBookStoreExtInterface );
    79     // Set phonebookrelated name and number max values
    74     // Set phonebookrelated name and number max values
    80     SetMaxNameAndNumLenght();
    75     SetMaxNameAndNumLenght();
    81 
    76 
    82 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CONSTRUCTL_2, "TSY: CMmPhoneBookStoreTsy::ConstructL - PB %S", iPhoneBookName);
    77 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ConstructL - PB %S", &iPhoneBookName);
    83 
    78 
    84     // Used entries is zero in the start
    79     // Used entries is zero in the start
    85     iUsedEntries = 0;
    80     iUsedEntries = 0;
    86 
    81 
    87     // Create bootState
    82     // Create bootState
    93     iRetFillBufferedDes = KErrNone;
    88     iRetFillBufferedDes = KErrNone;
    94     iReadReqStore->iCaching = EFalse;
    89     iReadReqStore->iCaching = EFalse;
    95     iRequestedOnPBRead = EFalse;
    90     iRequestedOnPBRead = EFalse;
    96     iIsPBInitCompleted = EFalse;
    91     iIsPBInitCompleted = EFalse;
    97 
    92 
    98 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CONSTRUCTL_3, "TSY: CMmPhoneBookStoreTsy::ConstructL - iIsPhonebookInitialized: %u", (TUint)iStoreInfoData->iIsPhonebookInitialized);
    93 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ConstructL - iIsPhonebookInitialized: %i", iStoreInfoData->iIsPhonebookInitialized);
    99 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CONSTRUCTL_4, "TSY: CMmPhoneBookStoreTsy::ConstructL - iSIMReady: %u", (TUint)bootState->iSIMReady);
    94 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ConstructL - iSIMReady: %i", bootState->iSIMReady);
   100 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CONSTRUCTL_5, "TSY: CMmPhoneBookStoreTsy::ConstructL - before initialization");
    95 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ConstructL - before initialization");
   101     if(bootState->iSIMReady)
    96     if(bootState->iSIMReady)
   102         {
    97         {
   103         SimIsReady();
    98         SimIsReady();
   104         }
    99         }
   105     else
   100     else
   110 
   105 
   111 CMmPhoneBookStoreTsy* CMmPhoneBookStoreTsy::NewL(
   106 CMmPhoneBookStoreTsy* CMmPhoneBookStoreTsy::NewL(
   112     CMmPhoneTsy* aMmPhone,
   107     CMmPhoneTsy* aMmPhone,
   113     const TDesC& aName )
   108     const TDesC& aName )
   114     {
   109     {
   115 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_NEWL_1, "TSY: CMmPhoneBookStoreTsy::NewL - entered");
   110 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::NewL - entered");
   116     
   111     
   117     CMmPhoneBookStoreTsy* mmPhoneBookStoreTsy =
   112     CMmPhoneBookStoreTsy* mmPhoneBookStoreTsy =
   118         new ( ELeave ) CMmPhoneBookStoreTsy();
   113         new ( ELeave ) CMmPhoneBookStoreTsy();
   119 
   114 
   120     CleanupClosePushL( *mmPhoneBookStoreTsy );
   115     CleanupClosePushL( *mmPhoneBookStoreTsy );
   129     }
   124     }
   130 
   125 
   131 
   126 
   132 CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy()
   127 CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy()
   133     {
   128     {
   134 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DTOR_1, "TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - PB %S", iPhoneBookName);
   129 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - PB %S", &iPhoneBookName);
   135 
   130 
   136     if ( iMmPhoneTsy )
   131     if ( iMmPhoneTsy )
   137         {
   132         {
   138         CMmPhoneTsy::TNosBootState* bootState = iMmPhoneTsy->NosBootState();
   133         CMmPhoneTsy::TNosBootState* bootState = iMmPhoneTsy->NosBootState();
   139         
   134         
   140         if ( iMmPhoneTsy->GetCustomTsy() )
   135         if ( iMmPhoneTsy->GetCustomTsy() )
   141             {
   136             {
   142             RMmCustomAPI::TPndCacheStatus fdnCacheStatus = 
   137             RMmCustomAPI::TPndCacheStatus fdnCacheStatus = 
   143             iMmPhoneTsy->GetCustomTsy()->GetPhonebookCacheStatus( KFDNPhoneBook );
   138             iMmPhoneTsy->GetCustomTsy()->GetPhonebookCacheStatus( KFDNPhoneBook );
   144 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DTOR_2, "TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - FDN cachestatus %d", fdnCacheStatus);
   139 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - FDN cachestatus %d", fdnCacheStatus);
   145 
   140 
   146             RMmCustomAPI::TPndCacheStatus adnCacheStatus =
   141             RMmCustomAPI::TPndCacheStatus adnCacheStatus =
   147             iMmPhoneTsy->GetCustomTsy()->GetPhonebookCacheStatus( KADNPhoneBook );
   142             iMmPhoneTsy->GetCustomTsy()->GetPhonebookCacheStatus( KADNPhoneBook );
   148 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DTOR_3, "TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - ADN cachestatus %d", adnCacheStatus);
   143 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - ADN cachestatus %d", adnCacheStatus);
   149 
   144 
   150             // Check if the caching is active
   145             // Check if the caching is active
   151             if ( bootState->iCachingActive )
   146             if ( bootState->iCachingActive )
   152                 {
   147                 {
   153                 // Check if the phonebook type is either ADN or FDN
   148                 // Check if the phonebook type is either ADN or FDN
   164                         CPhoneBookDataPackage package;
   159                         CPhoneBookDataPackage package;
   165                         // Set package data
   160                         // Set package data
   166                         package.SetPhoneBookName( iPhoneBookName );
   161                         package.SetPhoneBookName( iPhoneBookName );
   167                         TRAP_IGNORE( iMmPhoneTsy->MessageManager()->HandleRequestL( 
   162                         TRAP_IGNORE( iMmPhoneTsy->MessageManager()->HandleRequestL( 
   168                                 EMmTsyPhoneBookStoreCacheCancelIPC, &package ); );
   163                                 EMmTsyPhoneBookStoreCacheCancelIPC, &package ); );
   169                         OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DTOR_4, "TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - CacheCancel for %d", iPhoneBookType);
   164                         TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - CacheCancel for %d", iPhoneBookType);
   170                         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DTOR_5, "TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - CachingActive = EFalse");
   165                         TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - CachingActive = EFalse");
   171 
   166 
   172                         bootState->iCachingActive = EFalse;
   167                         bootState->iCachingActive = EFalse;
   173                         }
   168                         }
   174                     }
   169                     }
   175 
   170 
   177                         || RMmCustomAPI::ECacheFailed == fdnCacheStatus ) && (KADNPhoneBook == iPhoneBookType) )
   172                         || RMmCustomAPI::ECacheFailed == fdnCacheStatus ) && (KADNPhoneBook == iPhoneBookType) )
   178                         || (( RMmCustomAPI::ECacheNotReady == adnCacheStatus
   173                         || (( RMmCustomAPI::ECacheNotReady == adnCacheStatus
   179                                 || RMmCustomAPI::ECacheFailed == adnCacheStatus )) && (KFDNPhoneBook == iPhoneBookType) )  
   174                                 || RMmCustomAPI::ECacheFailed == adnCacheStatus )) && (KFDNPhoneBook == iPhoneBookType) )  
   180 
   175 
   181                     {
   176                     {
   182                     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DTOR_6, "TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - CachingActive = ETrue");
   177                     TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::~CMmPhoneBookStoreTsy - CachingActive = ETrue");
   183                     // Set the caching back to active
   178                     // Set the caching back to active
   184                     bootState->iCachingActive = ETrue;                 
   179                     bootState->iCachingActive = ETrue;                 
   185                     }
   180                     }
   186                 }
   181                 }
   187             }
   182             }
   302 // ---------------------------------------------------------------------------
   297 // ---------------------------------------------------------------------------
   303 //
   298 //
   304 CTelObject::TReqMode CMmPhoneBookStoreTsy::ReqModeL(
   299 CTelObject::TReqMode CMmPhoneBookStoreTsy::ReqModeL(
   305     const TInt aIpc )
   300     const TInt aIpc )
   306     {
   301     {
   307 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_REQMODEL_1, "TSY: CMmPhoneBookStoreTsy::ReqModeL IPC:%d", aIpc);
   302 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ReqModeL IPC:%d", aIpc);
   308 
   303 
   309     CTelObject::TReqMode ret = 0;
   304     CTelObject::TReqMode ret = 0;
   310     switch ( aIpc )
   305     switch ( aIpc )
   311         {
   306         {
   312         // Flow Controlled Services
   307         // Flow Controlled Services
   441 //
   436 //
   442 TInt CMmPhoneBookStoreTsy::CancelService(
   437 TInt CMmPhoneBookStoreTsy::CancelService(
   443     const TInt aIpc,
   438     const TInt aIpc,
   444     const TTsyReqHandle aTsyReqHandle )
   439     const TTsyReqHandle aTsyReqHandle )
   445     {
   440     {
   446 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CANCELSERVICE_1, "TSY: CMmPhoneBookStoreTsy::CancelService IPC:%d Handle:%d", aIpc, aTsyReqHandle);
   441 TFLOGSTRING3("TSY: CMmPhoneBookStoreTsy::CancelService IPC:%d Handle:%d", aIpc, aTsyReqHandle);
   447 
   442 
   448     TInt ret( KErrNone );
   443     TInt ret( KErrNone );
   449 
   444 
   450     switch ( aIpc )
   445     switch ( aIpc )
   451         {
   446         {
   467             ret =  NotifyStoreEventCancel( aTsyReqHandle );
   462             ret =  NotifyStoreEventCancel( aTsyReqHandle );
   468             break;
   463             break;
   469         default:
   464         default:
   470             break;
   465             break;
   471         }
   466         }
   472 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CANCELSERVICE_2, "TSY: CMmPhoneBookStoreTsy::CancelService return: %d", ret);
   467 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CancelService return: %d", ret);
   473 
   468 
   474     return ret;
   469     return ret;
   475     }
   470     }
   476 
   471 
   477 // ---------------------------------------------------------------------------
   472 // ---------------------------------------------------------------------------
   486 TInt CMmPhoneBookStoreTsy::ExtFunc(
   481 TInt CMmPhoneBookStoreTsy::ExtFunc(
   487     const TTsyReqHandle aTsyReqHandle,
   482     const TTsyReqHandle aTsyReqHandle,
   488     const TInt aIpc,
   483     const TInt aIpc,
   489     const TDataPackage& aPackage )
   484     const TDataPackage& aPackage )
   490     {
   485     {
   491 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_EXTFUNC_1, "TSY: CMmPhoneBookStoreTsy::ExtFunc IPC:%d Handle:%d", aIpc, aTsyReqHandle);
   486 TFLOGSTRING3("TSY: CMmPhoneBookStoreTsy::ExtFunc IPC:%d Handle:%d", aIpc, aTsyReqHandle);
   492 
   487 
   493     TInt ret = KErrNone;
   488     TInt ret = KErrNone;
   494     TInt trapError = KErrNone;
   489     TInt trapError = KErrNone;
   495 
   490 
   496     // Ensure the ReqHandleType is unset.
   491     // Ensure the ReqHandleType is unset.
   540 TInt CMmPhoneBookStoreTsy::DoExtFuncL(
   535 TInt CMmPhoneBookStoreTsy::DoExtFuncL(
   541     const TTsyReqHandle aTsyReqHandle,
   536     const TTsyReqHandle aTsyReqHandle,
   542     const TInt aIpc,
   537     const TInt aIpc,
   543     const TDataPackage& aPackage )
   538     const TDataPackage& aPackage )
   544     {
   539     {
   545 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DOEXTFUNCL_1, "TSY: CMmPhoneBookStoreTsy::DoExtFuncL IPC:%d Handle:%d", aIpc, aTsyReqHandle);
   540 TFLOGSTRING3("TSY: CMmPhoneBookStoreTsy::DoExtFuncL IPC:%d Handle:%d", aIpc, aTsyReqHandle);
   546 
   541 
   547     TAny* dataPtr=aPackage.Ptr1();
   542     TAny* dataPtr=aPackage.Ptr1();
   548     TAny* dataPtr2=aPackage.Ptr2();
   543     TAny* dataPtr2=aPackage.Ptr2();
   549     TInt result(KErrNotSupported);
   544     TInt result(KErrNotSupported);
   550 
   545 
   633         }
   628         }
   634     else if ( !aName.CompareF( KETelIccMbdnPhoneBook ) )
   629     else if ( !aName.CompareF( KETelIccMbdnPhoneBook ) )
   635         {
   630         {
   636         iPhoneBookType = KMBDNPhoneBook; //MBDN
   631         iPhoneBookType = KMBDNPhoneBook; //MBDN
   637         }
   632         }
   638 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SETPHONEBOOKTYPE_1,  "TSY: CMmPhoneBookStoreTsy::SetPhoneBookType - Type: %d", iPhoneBookType);
   633 TFLOGSTRING2( "TSY: CMmPhoneBookStoreTsy::SetPhoneBookType - Type: %d", iPhoneBookType);
   639     }
   634     }
   640 
   635 
   641 // ---------------------------------------------------------------------------
   636 // ---------------------------------------------------------------------------
   642 // CMmPhoneBookStoreTsy::CompletePBStoreInitializationL
   637 // CMmPhoneBookStoreTsy::CompletePBStoreInitializationL
   643 // Completes Phonebook initialization
   638 // Completes Phonebook initialization
   646 //
   641 //
   647 void CMmPhoneBookStoreTsy::CompletePBStoreInitializationL(
   642 void CMmPhoneBookStoreTsy::CompletePBStoreInitializationL(
   648     TInt aResult,
   643     TInt aResult,
   649     CMmDataPackage* aDataPackage )
   644     CMmDataPackage* aDataPackage )
   650     {
   645     {
   651 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEPBSTOREINITIALIZATIONL_1, "TSY: CMmPhoneBookStoreTsy::CompletePBStoreInitializationL - Result: %d",aResult );
   646 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompletePBStoreInitializationL - Result: %i",aResult );
   652 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEPBSTOREINITIALIZATIONL_2, "TSY: CMmPhoneBookStoreTsy::CompletePBStoreInitializationL - PhoneBookType: %u",iPhoneBookType );
   647 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompletePBStoreInitializationL - PhoneBookType: %u",iPhoneBookType );
   653 
   648 
   654     // If initialization made successfully
   649     // If initialization made successfully
   655     // fill phonebook related static data
   650     // fill phonebook related static data
   656     if ( KErrNone == aResult )
   651     if ( KErrNone == aResult )
   657         {
   652         {
   674        }
   669        }
   675     else
   670     else
   676     //Initialisation has failed
   671     //Initialisation has failed
   677         {
   672         {
   678         CMmCustomTsy* mmCustom = iMmPhoneTsy->GetCustomTsy();
   673         CMmCustomTsy* mmCustom = iMmPhoneTsy->GetCustomTsy();
   679 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEPBSTOREINITIALIZATIONL_3, "TSY: CMmPhoneBookStoreTsy::CompletePBStoreInitializationL has failed" );
   674 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::CompletePBStoreInitializationL has failed" );
   680 
   675 
   681         if ( NULL != mmCustom )
   676         if ( NULL != mmCustom )
   682             {
   677             {
   683             //complete
   678             //complete
   684             mmCustom->CompleteNotifyPhoneBookCacheReady
   679             mmCustom->CompleteNotifyPhoneBookCacheReady
   735 // (other items were commented in a header).
   730 // (other items were commented in a header).
   736 // ---------------------------------------------------------------------------
   731 // ---------------------------------------------------------------------------
   737 //
   732 //
   738 void CMmPhoneBookStoreTsy::SetMaxNameAndNumLenght()
   733 void CMmPhoneBookStoreTsy::SetMaxNameAndNumLenght()
   739     {
   734     {
   740 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SETMAXNAMEANDNUMLENGHT_1, "TSY: CMmPhoneBookStoreTsy::SetMaxNameAndNumLenght");
   735 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SetMaxNameAndNumLenght");
   741     switch ( iPhoneBookType )
   736     switch ( iPhoneBookType )
   742         {
   737         {
   743         case KADNPhoneBook:
   738         case KADNPhoneBook:
   744             iMaxNumLen = iStoreInfoData->iADNNumberLengthMax;
   739             iMaxNumLen = iStoreInfoData->iADNNumberLengthMax;
   745             iMaxTextLen = iStoreInfoData->iADNTextLengthMax;
   740             iMaxTextLen = iStoreInfoData->iADNTextLengthMax;
   784 TInt CMmPhoneBookStoreTsy::ReadL(
   779 TInt CMmPhoneBookStoreTsy::ReadL(
   785     const TTsyReqHandle aTsyReqHandle,
   780     const TTsyReqHandle aTsyReqHandle,
   786     RMobilePhoneBookStore::TPBIndexAndNumEntries* aIndexAndEntries,
   781     RMobilePhoneBookStore::TPBIndexAndNumEntries* aIndexAndEntries,
   787     TDes8* aPBData, TBool aContinuedRead )
   782     TDes8* aPBData, TBool aContinuedRead )
   788     {
   783     {
   789 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_1, "TSY: CMmPhoneBookStoreTsy::ReadL");
   784 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadL");
   790 
   785 
   791     // Initialise ret to KErrServerBusy
   786     // Initialise ret to KErrServerBusy
   792     TInt ret = KErrServerBusy;
   787     TInt ret = KErrServerBusy;
   793 
   788 
   794     // Check if request handle already exists
   789     // Check if request handle already exists
   802     // since the handle will already be set. This is done by checking the value of aContinuedRead which
   797     // since the handle will already be set. This is done by checking the value of aContinuedRead which
   803     // is set ETrue when ReadL is invoked from ContinueReadL.
   798     // is set ETrue when ReadL is invoked from ContinueReadL.
   804     if ( !aContinuedRead && EMultimodePhoneBookStoreReqHandleUnknown != phoneBookStoreReadHandle )
   799     if ( !aContinuedRead && EMultimodePhoneBookStoreReqHandleUnknown != phoneBookStoreReadHandle )
   805         {
   800         {
   806         // If request handle already exists return KErrServerBusy
   801         // If request handle already exists return KErrServerBusy
   807         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_2, "TSY: CMmPhoneBookStoreTsy::ReadL - Handle already exists");
   802         TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadL - Handle already exists");
   808         ReqCompleted( aTsyReqHandle, ret );
   803         ReqCompleted( aTsyReqHandle, ret );
   809         }
   804         }
   810     // check the buffer size
   805     // check the buffer size
   811     else if ( sizeof(CPhoneBookStoreEntry) > aPBData->MaxLength() )
   806     else if ( sizeof(CPhoneBookStoreEntry) > aPBData->MaxLength() )
   812         {
   807         {
   815     //Caching needs to be done only in case of ADN or FDN phonebook.
   810     //Caching needs to be done only in case of ADN or FDN phonebook.
   816     else if( !iMmPhoneTsy->GetSimRefreshRegister() &&
   811     else if( !iMmPhoneTsy->GetSimRefreshRegister() &&
   817         !( iReadReqStore->iCaching ) &&
   812         !( iReadReqStore->iCaching ) &&
   818         (KADNPhoneBook == iPhoneBookType || KFDNPhoneBook == iPhoneBookType))
   813         (KADNPhoneBook == iPhoneBookType || KFDNPhoneBook == iPhoneBookType))
   819         {
   814         {
   820 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_3, "TSY: CMmPhoneBookStoreTsy::ReadL - SIM refresh registration failed Cache info can be corrupted - ");
   815 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadL - SIM refresh registration failed Cache info can be corrupted - ");
   821 
   816 
   822         //Store Read req params for new request
   817         //Store Read req params for new request
   823         iReadReqStore->iReqHandle = aTsyReqHandle;
   818         iReadReqStore->iReqHandle = aTsyReqHandle;
   824         iReadReqStore->iIndexAndEntries = aIndexAndEntries;
   819         iReadReqStore->iIndexAndEntries = aIndexAndEntries;
   825         iReadReqStore->iPBData = aPBData;
   820         iReadReqStore->iPBData = aPBData;
   837         {
   832         {
   838         if ( ( KADNPhoneBook == iPhoneBookType ||
   833         if ( ( KADNPhoneBook == iPhoneBookType ||
   839                 KFDNPhoneBook == iPhoneBookType ) &&
   834                 KFDNPhoneBook == iPhoneBookType ) &&
   840              ( !iStoreInfoData->iIsPhonebookInitialized || !iCacheReady ) )
   835              ( !iStoreInfoData->iIsPhonebookInitialized || !iCacheReady ) )
   841             {
   836             {
   842 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_4, "TSY: CMmPhoneBookStoreTsy::ReadL - Initiliszation ongoing -> Read not possible");
   837 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadL - Initiliszation ongoing -> Read not possible");
   843             // If phonebook initialisation is not ready for AND and FDN phonebooks,
   838             // If phonebook initialisation is not ready for AND and FDN phonebooks,
   844             // complete with KErrInUse. This is done becauce TSY can not handle
   839             // complete with KErrInUse. This is done becauce TSY can not handle
   845             // multible simultaneously request to certain phonebook.
   840             // multible simultaneously request to certain phonebook.
   846             // (No dynamic transaktion Ids)
   841             // (No dynamic transaktion Ids)
   847             ret = KErrInUse;
   842             ret = KErrInUse;
   860         // If user supplies index which is less than 0, complete with
   855         // If user supplies index which is less than 0, complete with
   861         // KErrArgument each record are numbered from 0 to maximum
   856         // KErrArgument each record are numbered from 0 to maximum
   862         // number of records.
   857         // number of records.
   863         if ( ( 1 > iIndexToRead ) || ( 1 > aIndexAndEntries->iNumSlots ) )
   858         if ( ( 1 > iIndexToRead ) || ( 1 > aIndexAndEntries->iNumSlots ) )
   864             {
   859             {
   865 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_5, "TSY: CMmPhoneBookStoreTsy::ReadL - Index is less than 1 or aIndexAndEntries->iNumSlots is less then 1" );
   860 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadL - Index is less than 1 or aIndexAndEntries->iNumSlots is less then 1" );
   866 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_6, "TSY: CMmPhoneBookStoreTsy::ReadL - Index %d ", iIndexToRead);
   861 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ReadL - Index %i ", iIndexToRead);
   867             iIndexAndEntries = NULL;
   862             iIndexAndEntries = NULL;
   868             iIndexToRead = 0;
   863             iIndexToRead = 0;
   869             ReqCompleted( aTsyReqHandle, KErrArgument );
   864             ReqCompleted( aTsyReqHandle, KErrArgument );
   870             }
   865             }
   871         else if ( KBDNPhoneBook != iPhoneBookType && 
   866         else if ( KBDNPhoneBook != iPhoneBookType && 
   872                   aIndexAndEntries->iNumSlots > iMultipleReadPosTo  )
   867                   aIndexAndEntries->iNumSlots > iMultipleReadPosTo  )
   873             {
   868             {
   874 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_7, "TSY: CMmPhoneBookStoreTsy::ReadL - iPhoneBookType %u: ", iPhoneBookType);
   869 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ReadL - iPhoneBookType %i: ", iPhoneBookType);
   875 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_8, "TSY: CMmPhoneBookStoreTsy::ReadL - iNumSlots: %d > iMultipleReadPosTo: %d", aIndexAndEntries->iNumSlots, iMultipleReadPosTo );
   870 TFLOGSTRING3("TSY: CMmPhoneBookStoreTsy::ReadL - iNumSlots: %i > iMultipleReadPosTo: %i", aIndexAndEntries->iNumSlots, iMultipleReadPosTo );
   876             iIndexAndEntries = NULL;
   871             iIndexAndEntries = NULL;
   877             iIndexToRead = 0;
   872             iIndexToRead = 0;
   878             ReqCompleted( aTsyReqHandle, KErrNotFound );
   873             ReqCompleted( aTsyReqHandle, KErrNotFound );
   879             }
   874             }
   880         else
   875         else
   899                 aIndexAndEntries);
   894                 aIndexAndEntries);
   900                 }
   895                 }
   901             // If cache request, but cache is not yet ready
   896             // If cache request, but cache is not yet ready
   902             else if ( ( NULL == iPBStoreCache ) || !iCacheReady )
   897             else if ( ( NULL == iPBStoreCache ) || !iCacheReady )
   903                 {
   898                 {
   904 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_9, "TSY: CMmPhoneBookStoreTsy::ReadL - Cache is not yet ready" );
   899 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadL - Cache is not yet ready" );
   905                 ret = KErrNotReady;
   900                 ret = KErrNotReady;
   906                 }
   901                 }
   907             // Set cache request for completion handling
   902             // Set cache request for completion handling
   908             else
   903             else
   909                 {
   904                 {
   910                 cacheRequest = ETrue;
   905                 cacheRequest = ETrue;
   911 
   906 
   912                 if ( ( iNumEntriesToRead ) > iMultipleReadPosTo )
   907                 if ( ( iNumEntriesToRead ) > iMultipleReadPosTo )
   913                     {
   908                     {
   914                     ret = KErrArgument;
   909                     ret = KErrArgument;
   915 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_10, "TSY: CMmPhoneBookStoreTsy::ReadL - KErrArgument" );
   910 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadL - KErrArgument" );
   916                     }
   911                     }
   917                 }
   912                 }
   918 
   913 
   919             // Error when doing Read -request or error in parameters
   914             // Error when doing Read -request or error in parameters
   920             if ( KErrNone != ret )
   915             if ( KErrNone != ret )
   935                     }
   930                     }
   936                 }
   931                 }
   937             // Handle cached request
   932             // Handle cached request
   938             else
   933             else
   939                 {
   934                 {
   940 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_11, "TSY: CMmPhoneBookStoreTsy::ReadL - iIndexToRead %d ", iIndexToRead);
   935 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ReadL - iIndexToRead %i ", iIndexToRead);
   941 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_12, "TSY: CMmPhoneBookStoreTsy::ReadL - iNumSlots %d ", iNumEntriesToRead);
   936 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ReadL - iNumSlots %i ", iNumEntriesToRead);
   942                 ReadEntriesFromArrayL( EPBStoreCacheArray );
   937                 ReadEntriesFromArrayL( EPBStoreCacheArray );
   943                 aIndexAndEntries->iNumSlots = iNumEntriesFilled;
   938                 aIndexAndEntries->iNumSlots = iNumEntriesFilled;
   944                 //This condition will arise when client has sent a buffer insufficient to
   939                 //This condition will arise when client has sent a buffer insufficient to
   945                 //hold even one entry. KErrArgument has to be returned in this case.
   940                 //hold even one entry. KErrArgument has to be returned in this case.
   946                 if ( ( iRetFillBufferedDes == KErrOverflow ) && ( iNumEntriesFilled == 0 ) )
   941                 if ( ( iRetFillBufferedDes == KErrOverflow ) && ( iNumEntriesFilled == 0 ) )
   947                     {
   942                     {
   948                     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_13, "TSY: CMmPhoneBookStoreTsy::ReadL - Insufficient buffer to hold even 1 entry." );
   943                     TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadL - Insufficient buffer to hold even 1 entry." );
   949                     ret = KErrArgument;
   944                     ret = KErrArgument;
   950                     }
   945                     }
   951                 else if ( 0 == iNumEntriesFilled )
   946                 else if ( 0 == iNumEntriesFilled )
   952                     {
   947                     {
   953 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READL_14, "TSY: CMmPhoneBookStoreTsy::ReadL - iNumEntriesFilled is 0 " );
   948 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadL - iNumEntriesFilled is 0 " );
   954                     ret = KErrNotFound;
   949                     ret = KErrNotFound;
   955                     }
   950                     }
   956                 ReqCompleted( aTsyReqHandle, ret );
   951                 ReqCompleted( aTsyReqHandle, ret );
   957                 }
   952                 }
   958             }
   953             }
   982 //
   977 //
   983 void CMmPhoneBookStoreTsy::CompleteReadL(
   978 void CMmPhoneBookStoreTsy::CompleteReadL(
   984     TInt aResult,
   979     TInt aResult,
   985     CMmDataPackage* aDataPackage )
   980     CMmDataPackage* aDataPackage )
   986     {
   981     {
   987 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEREADL_1, "TSY: CMmPhoneBookStoreTsy::CompleteReadL - aResult: %d",aResult );
   982 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteReadL - aResult: %i",aResult );
   988 
   983 
   989     TInt errCode = aResult;
   984     TInt errCode = aResult;
   990     // Reset req handle. Returns the deleted req handle
   985     // Reset req handle. Returns the deleted req handle
   991     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
   986     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
   992         EMultimodePhoneBookStoreRead ); 
   987         EMultimodePhoneBookStoreRead ); 
  1000             ReadEntriesFromArrayL( EPBStoreReadEntriesArray );
   995             ReadEntriesFromArrayL( EPBStoreReadEntriesArray );
  1001             //This condition will arise when client has sent a buffer insufficient to
   996             //This condition will arise when client has sent a buffer insufficient to
  1002             //hold even one entry. KErrArgument has to be returned in this case.
   997             //hold even one entry. KErrArgument has to be returned in this case.
  1003             if ( ( iRetFillBufferedDes == KErrOverflow ) && ( iNumEntriesFilled == 0 ) )
   998             if ( ( iRetFillBufferedDes == KErrOverflow ) && ( iNumEntriesFilled == 0 ) )
  1004                 {
   999                 {
  1005                 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEREADL_2, "TSY: CMmPhoneBookStoreTsy::CompleteReadL - Insufficient buffer to hold even 1 entry." );
  1000                 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::CompleteReadL - Insufficient buffer to hold even 1 entry." );
  1006                 errCode = KErrArgument;
  1001                 errCode = KErrArgument;
  1007                 }
  1002                 }
  1008             }
  1003             }
  1009         iIndexAndEntries->iNumSlots = iNumEntriesFilled;
  1004         iIndexAndEntries->iNumSlots = iNumEntriesFilled;
  1010         }
  1005         }
  1030 // (other items were commented in a header).
  1025 // (other items were commented in a header).
  1031 // ---------------------------------------------------------------------------
  1026 // ---------------------------------------------------------------------------
  1032 //
  1027 //
  1033 TInt CMmPhoneBookStoreTsy::CountEntriesL()
  1028 TInt CMmPhoneBookStoreTsy::CountEntriesL()
  1034     {
  1029     {
  1035 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COUNTENTRIESL_1, "TSY: CMmPhoneBookStoreTsy::CountEntriesL called");
  1030 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::CountEntriesL called");
  1036 
  1031 
  1037     // before phonebook requests, phonebook must be initialized
  1032     // before phonebook requests, phonebook must be initialized
  1038     TInt returnValue( KErrNone );
  1033     TInt returnValue( KErrNone );
  1039     returnValue = iMmPhoneBookStoreExtInterface->
  1034     returnValue = iMmPhoneBookStoreExtInterface->
  1040         CountPhonebookEntriesL( EMmTsyPhoneBookStoreGetInfoIPC,
  1035         CountPhonebookEntriesL( EMmTsyPhoneBookStoreGetInfoIPC,
  1052 //
  1047 //
  1053 void CMmPhoneBookStoreTsy::CompleteCountEntries(
  1048 void CMmPhoneBookStoreTsy::CompleteCountEntries(
  1054     TInt aResult,
  1049     TInt aResult,
  1055     CMmDataPackage* aDataPackage )
  1050     CMmDataPackage* aDataPackage )
  1056     {
  1051     {
  1057 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETECOUNTENTRIES_1, "TSY: CMmPhoneBookStoreTsy::CompleteCountEntries - Result: %d", aResult );
  1052 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteCountEntries - Result: %i", aResult );
  1058     TInt numOfEntries( 0 );
  1053     TInt numOfEntries( 0 );
  1059 
  1054 
  1060     //reset request handle. Returns the deleted req handle.
  1055     //reset request handle. Returns the deleted req handle.
  1061     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  1056     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  1062         EMultimodePhoneStoreGetInfo );
  1057         EMultimodePhoneStoreGetInfo );
  1089 #ifndef USING_CTSY_DISPATCHER 
  1084 #ifndef USING_CTSY_DISPATCHER 
  1090 
  1085 
  1091 
  1086 
  1092 void CMmPhoneBookStoreTsy::CacheEntriesL()
  1087 void CMmPhoneBookStoreTsy::CacheEntriesL()
  1093     {
  1088     {
  1094 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CACHEENTRIESL_1, "TSY: CMmPhoneBookStoreTsy::CacheEntriesL - entered");
  1089 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::CacheEntriesL - entered");
  1095     // Get Phonebook related DLL -static data
  1090     // Get Phonebook related DLL -static data
  1096 
  1091 
  1097     // Check if phonebook has been initialized successfully. Caching of ADN
  1092     // Check if phonebook has been initialized successfully. Caching of ADN
  1098     // entries does not work if phonebook initialize have been failed.
  1093     // entries does not work if phonebook initialize have been failed.
  1099     if ( iStoreInfoData->iIsPhonebookInitialized &&
  1094     if ( iStoreInfoData->iIsPhonebookInitialized &&
  1100          ( EFalse == iStoreInfoData->iIsPhonebookInitializeFailed ||
  1095          ( EFalse == iStoreInfoData->iIsPhonebookInitializeFailed ||
  1101            KADNPhoneBook != iPhoneBookType ) )
  1096            KADNPhoneBook != iPhoneBookType ) )
  1102         {
  1097         {
  1103 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CACHEENTRIESL_2, "TSY: CMmPhoneBookStoreTsy::CacheEntriesL - Cache PB %S ", iPhoneBookName);
  1098 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CacheEntriesL - Cache PB %S ", &iPhoneBookName);
  1104 
  1099 
  1105 		TInt ret = KErrNone;
  1100 		TInt ret = KErrNone;
  1106 		CMmPhoneTsy::TNosBootState* bootState = iMmPhoneTsy->NosBootState();
  1101 		CMmPhoneTsy::TNosBootState* bootState = iMmPhoneTsy->NosBootState();
  1107 		
  1102 		
  1108               if ( !iCacheReady )
  1103               if ( !iCacheReady )
  1116                     if ( NULL != iPBStoreCache )
  1111                     if ( NULL != iPBStoreCache )
  1117                         {
  1112                         {
  1118                         iPBStoreCache->ResetAndDestroy();
  1113                         iPBStoreCache->ResetAndDestroy();
  1119                         delete iPBStoreCache;
  1114                         delete iPBStoreCache;
  1120                         iPBStoreCache = NULL;
  1115                         iPBStoreCache = NULL;
  1121 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CACHEENTRIESL_3, "TSY: CMmPhoneBookStoreTsy::CacheEntriesL - Old cache deleted");
  1116 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::CacheEntriesL - Old cache deleted");
  1122                         }
  1117                         }
  1123                     
  1118                     
  1124                     //Inform phonebook that the cache is not ready for refresh
  1119                     //Inform phonebook that the cache is not ready for refresh
  1125                     ResetCacheReady();
  1120                     ResetCacheReady();
  1126 
  1121 
  1128                     TRAP( ret, ReadToCacheL();)
  1123                     TRAP( ret, ReadToCacheL();)
  1129                     }
  1124                     }
  1130                 }
  1125                 }
  1131             else if ( iCacheReady )
  1126             else if ( iCacheReady )
  1132                 {
  1127                 {
  1133 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CACHEENTRIESL_4, "TSY: CMmPhoneBookStoreTsy::CacheEntriesL - PB %S cache entries ready", iPhoneBookName);
  1128 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CacheEntriesL - PB %S cache entries ready", &iPhoneBookName);
  1134                 }
  1129                 }
  1135         if ( KErrNone != ret)
  1130         if ( KErrNone != ret)
  1136             {
  1131             {
  1137 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CACHEENTRIESL_5, "TSY: CMmPhoneBookStoreTsy::CacheEntriesL - PB %S caching failed!", iPhoneBookName);
  1132 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CacheEntriesL - PB %S caching failed!", &iPhoneBookName);
  1138             }
  1133             }
  1139         }
  1134         }
  1140     // Phonebook not initialized -> let's do it before caching
  1135     // Phonebook not initialized -> let's do it before caching
  1141     else if ( ( !iStoreInfoData->iIsPhonebookInitialized
  1136     else if ( ( !iStoreInfoData->iIsPhonebookInitialized
  1142         || iStoreInfoData->iIsPhonebookInitializeFailed )
  1137         || iStoreInfoData->iIsPhonebookInitializeFailed )
  1143         && !iMmPhoneTsy->IsPBInitActive() )
  1138         && !iMmPhoneTsy->IsPBInitActive() )
  1144         {
  1139         {
  1145 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CACHEENTRIESL_6, "TSY: CMmPhoneBookStoreTsy::CacheEntriesL - Starting initialization PB: %S", iPhoneBookName);
  1140 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CacheEntriesL - Starting initialization PB: %S", &iPhoneBookName);
  1146         // before phonebook requests, phonebook must be initialized
  1141         // before phonebook requests, phonebook must be initialized
  1147         iMmPhoneBookStoreExtInterface->InitPhonebook(
  1142         iMmPhoneBookStoreExtInterface->InitPhonebook(
  1148             EMmTsyPhoneBookStoreInitIPC, iPhoneBookName );
  1143             EMmTsyPhoneBookStoreInitIPC, iPhoneBookName );
  1149         iMmPhoneTsy->SetPBInitActiveStatus( ETrue );
  1144         iMmPhoneTsy->SetPBInitActiveStatus( ETrue );
  1150         }
  1145         }
  1162 // ---------------------------------------------------------------------------
  1157 // ---------------------------------------------------------------------------
  1163 //
  1158 //
  1164 void CMmPhoneBookStoreTsy::CompleteCachingL(
  1159 void CMmPhoneBookStoreTsy::CompleteCachingL(
  1165     TInt aResult, CMmDataPackage* aDataPackage )
  1160     TInt aResult, CMmDataPackage* aDataPackage )
  1166     {
  1161     {
  1167 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETECACHINGL_1, "TSY: CMmPhoneBookStoreTsy::CompleteCachingL - PB %S Caching completed", iPhoneBookName);
  1162 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteCachingL - PB %S Caching completed", &iPhoneBookName);
  1168 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETECACHINGL_2, "TSY: CMmPhoneBookStoreTsy::CompleteCachingL - Result: %d",aResult );
  1163 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteCachingL - Result: %i",aResult );
  1169 	
  1164 	
  1170 #ifdef USING_CTSY_DISPATCHER 		
  1165 #ifdef USING_CTSY_DISPATCHER 		
  1171 	aDataPackage->UnPackData(iPBStoreCache);
  1166 	aDataPackage->UnPackData(iPBStoreCache);
  1172 #else
  1167 #else
  1173 	CArrayPtrSeg<CPhoneBookStoreEntry>* entryData;
  1168 	CArrayPtrSeg<CPhoneBookStoreEntry>* entryData;
  1179 
  1174 
  1180     // If cache were successfully generated, update
  1175     // If cache were successfully generated, update
  1181     // the number of used entries
  1176     // the number of used entries
  1182     if ( KErrNone == aResult )
  1177     if ( KErrNone == aResult )
  1183         {
  1178         {
  1184 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETECACHINGL_3, "TSY: CMmPhoneBookStoreTsy::CompleteCachingL - iPBStoreCache->Count: %d",iPBStoreCache->Count() );
  1179 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteCachingL - iPBStoreCache->Count: %i",iPBStoreCache->Count() );
  1185         iUsedEntries = iPBStoreCache->Count();
  1180         iUsedEntries = iPBStoreCache->Count();
  1186         //Set the caching ready only if request is successfull.
  1181         //Set the caching ready only if request is successfull.
  1187         //when FDN is on, the ADN caching is not successful. Meanwhile the FDN
  1182         //when FDN is on, the ADN caching is not successful. Meanwhile the FDN
  1188         //is on, the ADN list is not available, so this is not a problem.
  1183         //is on, the ADN list is not available, so this is not a problem.
  1189         //When the user turns the FDN back to off the tsy will
  1184         //When the user turns the FDN back to off the tsy will
  1190         //cache the FDN list
  1185         //cache the FDN list
  1191         //again
  1186         //again
  1192         iCacheReady = ETrue;
  1187         iCacheReady = ETrue;
  1193         }
  1188         }
  1194 
  1189 
  1195 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETECACHINGL_4, "TSY: CMmPhoneBookStoreTsy::CompleteCachingL - iUsedEntries: %d",iUsedEntries );
  1190 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteCachingL - iUsedEntries: %i",iUsedEntries );
  1196 
  1191 
  1197     bootState->iCachingActive = EFalse;
  1192     bootState->iCachingActive = EFalse;
  1198 
  1193 
  1199     CMmCustomTsy* mmCustom = iMmPhoneTsy->GetCustomTsy();
  1194     CMmCustomTsy* mmCustom = iMmPhoneTsy->GetCustomTsy();
  1200 
  1195 
  1201     // Check if client has requested caching before completing
  1196     // Check if client has requested caching before completing
  1202     if ( NULL != mmCustom && !iMmPhoneTsy->IsRefreshOngoing() )
  1197     if ( NULL != mmCustom && !iMmPhoneTsy->IsRefreshOngoing() )
  1203         {
  1198         {
  1204 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETECACHINGL_5, "TSY: CMmPhoneBookStoreTsy::CompleteCachingL - Client refresh req complete" );
  1199 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::CompleteCachingL - Client refresh req complete" );
  1205         if ( KErrNone == aResult )
  1200         if ( KErrNone == aResult )
  1206             {
  1201             {
  1207             mmCustom->UpdateCacheStatus( RMmCustomAPI::ECacheReady,
  1202             mmCustom->UpdateCacheStatus( RMmCustomAPI::ECacheReady,
  1208                 iPhoneBookName );
  1203                 iPhoneBookName );
  1209 
  1204 
  1227         }
  1222         }
  1228     // Otherwise caching has been originated from SIM and completion goes
  1223     // Otherwise caching has been originated from SIM and completion goes
  1229     // through refresh
  1224     // through refresh
  1230     else
  1225     else
  1231         {
  1226         {
  1232 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETECACHINGL_6, "TSY: CMmPhoneBookStoreTsy::CompleteCachingL - SIM refresh req complete" );
  1227 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::CompleteCachingL - SIM refresh req complete" );
  1233 
  1228 
  1234         // Check for which phonebook the caching must be completed
  1229         // Check for which phonebook the caching must be completed
  1235         if ( !iPhoneBookName.CompareF( KETelIccAdnPhoneBook ) )
  1230         if ( !iPhoneBookName.CompareF( KETelIccAdnPhoneBook ) )
  1236             {
  1231             {
  1237             iMmPhoneTsy->CompleteCacheSimL( KCacheAdn, aResult );
  1232             iMmPhoneTsy->CompleteCacheSimL( KCacheAdn, aResult );
  1241             iMmPhoneTsy->CompleteCacheSimL( KCacheFdn, aResult );
  1236             iMmPhoneTsy->CompleteCacheSimL( KCacheFdn, aResult );
  1242             }
  1237             }
  1243         //NOTIFY THE PHONEBOOK that the cache is ready
  1238         //NOTIFY THE PHONEBOOK that the cache is ready
  1244         if ( NULL != mmCustom )
  1239         if ( NULL != mmCustom )
  1245             {
  1240             {
  1246 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETECACHINGL_7, "TSY: CMmPhoneBookStoreTsy::CompleteCachingL, mmCustom->UpdateCacheStatus" );
  1241 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::CompleteCachingL, mmCustom->UpdateCacheStatus" );
  1247             if ( KErrNone == aResult )
  1242             if ( KErrNone == aResult )
  1248                 {
  1243                 {
  1249                 mmCustom->UpdateCacheStatus(
  1244                 mmCustom->UpdateCacheStatus(
  1250                     RMmCustomAPI::ECacheReady, iPhoneBookName );
  1245                     RMmCustomAPI::ECacheReady, iPhoneBookName );
  1251                 }
  1246                 }
  1263         {
  1258         {
  1264         RMmCustomAPI::TPndCacheStatus fdnCacheStatus =
  1259         RMmCustomAPI::TPndCacheStatus fdnCacheStatus =
  1265             mmCustom->GetPhonebookCacheStatus( KFDNPhoneBook );
  1260             mmCustom->GetPhonebookCacheStatus( KFDNPhoneBook );
  1266         RMmCustomAPI::TPndCacheStatus adnCacheStatus =
  1261         RMmCustomAPI::TPndCacheStatus adnCacheStatus =
  1267             mmCustom->GetPhonebookCacheStatus( KADNPhoneBook );
  1262             mmCustom->GetPhonebookCacheStatus( KADNPhoneBook );
  1268 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETECACHINGL_8, "TSY: CMmPhoneBookStoreTsy::CompleteCachingL - FDN cachestatus %d", fdnCacheStatus);
  1263 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteCachingL - FDN cachestatus %d", fdnCacheStatus);
  1269 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETECACHINGL_9, "TSY: CMmPhoneBookStoreTsy::CompleteCachingL - ADN cachestatus %d", adnCacheStatus);
  1264 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteCachingL - ADN cachestatus %d", adnCacheStatus);
  1270 
  1265 
  1271 	    // Set caching back to active if either FDN or ADN is caching
  1266 	    // Set caching back to active if either FDN or ADN is caching
  1272         if ( RMmCustomAPI::ECacheNotReady == fdnCacheStatus 
  1267         if ( RMmCustomAPI::ECacheNotReady == fdnCacheStatus 
  1273     		|| RMmCustomAPI::ECacheNotReady == adnCacheStatus ) 
  1268     		|| RMmCustomAPI::ECacheNotReady == adnCacheStatus ) 
  1274     	    {
  1269     	    {
  1288     {
  1283     {
  1289     CArrayPtrSeg<CPhoneBookStoreEntry>* ptrToArray = NULL;
  1284     CArrayPtrSeg<CPhoneBookStoreEntry>* ptrToArray = NULL;
  1290 
  1285 
  1291     if ( EPBStoreCacheArray == aArrayType )
  1286     if ( EPBStoreCacheArray == aArrayType )
  1292         {
  1287         {
  1293 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READENTRIESFROMARRAYL_1, "TSY: CMmPhoneBookStoreTsy::ReadEntriesFromCache %S, iPBStoreCache", iPhoneBookName);
  1288 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ReadEntriesFromCache %S, iPBStoreCache", &iPhoneBookName);
  1294         ptrToArray = iPBStoreCache;
  1289         ptrToArray = iPBStoreCache;
  1295         }
  1290         }
  1296     else if ( EPBStoreReadEntriesArray == aArrayType )
  1291     else if ( EPBStoreReadEntriesArray == aArrayType )
  1297         {
  1292         {
  1298 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READENTRIESFROMARRAYL_2, "TSY: CMmPhoneBookStoreTsy::ReadEntriesFromEntryArray %S, iPBStoreReadEntries", iPhoneBookName);
  1293 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ReadEntriesFromEntryArray %S, iPBStoreReadEntries", &iPhoneBookName);
  1299         ptrToArray = iPBStoreReadEntries;
  1294         ptrToArray = iPBStoreReadEntries;
  1300         }
  1295         }
  1301     else
  1296     else
  1302         {
  1297         {
  1303 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READENTRIESFROMARRAYL_3, "TSY: CMmPhoneBookStoreTsy::ReadEntriesFromEntryArray invalid aArrayType");
  1298 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadEntriesFromEntryArray invalid aArrayType");
  1304         User::Leave(KErrNotSupported);
  1299         User::Leave(KErrNotSupported);
  1305         }
  1300         }
  1306 
  1301 
  1307     CPhoneBookStoreEntry* cacheEntry = NULL;
  1302     CPhoneBookStoreEntry* cacheEntry = NULL;
  1308 
  1303 
  1335 // (other items were commented in a header).
  1330 // (other items were commented in a header).
  1336 // ---------------------------------------------------------------------------
  1331 // ---------------------------------------------------------------------------
  1337 //
  1332 //
  1338 void CMmPhoneBookStoreTsy::ReadToCacheL()
  1333 void CMmPhoneBookStoreTsy::ReadToCacheL()
  1339     {
  1334     {
  1340 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READTOCACHEL_1, "TSY: CMmPhoneBookStoreTsy::ReadToCacheL");
  1335 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadToCacheL");
  1341 
  1336 
  1342     // Call ReadL from GSM extension
  1337     // Call ReadL from GSM extension
  1343     iMmPhoneBookStoreExtInterface->ReadToCacheL(
  1338     iMmPhoneBookStoreExtInterface->ReadToCacheL(
  1344           EMmTsyPhoneBookStoreCacheIPC,
  1339           EMmTsyPhoneBookStoreCacheIPC,
  1345           iPhoneBookName);
  1340           iPhoneBookName);
  1354 //
  1349 //
  1355 void CMmPhoneBookStoreTsy::UpdateCacheL(
  1350 void CMmPhoneBookStoreTsy::UpdateCacheL(
  1356     CPhoneBookStoreEntry* aEntry,
  1351     CPhoneBookStoreEntry* aEntry,
  1357     TBool aDeleteEntry )
  1352     TBool aDeleteEntry )
  1358     {
  1353     {
  1359 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_1, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL");
  1354 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::UpdateCacheL");
  1360 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_2, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - iPBStoreCache->Count(): %d ", iPBStoreCache->Count() );
  1355 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - iPBStoreCache->Count(): %i ", iPBStoreCache->Count() );
  1361 
  1356 
  1362     if(aEntry == NULL)
  1357     if(aEntry == NULL)
  1363         {
  1358         {
  1364         if(aDeleteEntry == EFalse)
  1359         if(aDeleteEntry == EFalse)
  1365 		   {
  1360 		   {
  1368 		   }
  1363 		   }
  1369 		
  1364 		
  1370 		User::Leave(KErrArgument);
  1365 		User::Leave(KErrArgument);
  1371         }
  1366         }
  1372     
  1367     
  1373 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_3, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - aEntry->Location(): %u ", aEntry->iLocation );
  1368 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - aEntry->Location(): %i ", aEntry->iLocation );
  1374 
  1369 
  1375     TInt result( KErrNotFound );
  1370     TInt result( KErrNotFound );
  1376     TInt updateIndex( 0 );
  1371     TInt updateIndex( 0 );
  1377 
  1372 
  1378     for ( TInt index = 0; index < iPBStoreCache->Count() &&
  1373     for ( TInt index = 0; index < iPBStoreCache->Count() &&
  1379           result == KErrNotFound; index++ )
  1374           result == KErrNotFound; index++ )
  1380         {
  1375         {
  1381         if ( ( iPBStoreCache->At( index ) )->iLocation == aEntry->iLocation )
  1376         if ( ( iPBStoreCache->At( index ) )->iLocation == aEntry->iLocation )
  1382             {
  1377             {
  1383 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_4, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - iPBStoreCache->iLocation:  %u ", aEntry->iLocation);
  1378 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - iPBStoreCache->iLocation:  %i ", aEntry->iLocation);
  1384             updateIndex =  index;
  1379             updateIndex =  index;
  1385             result = KErrNone;
  1380             result = KErrNone;
  1386             }
  1381             }
  1387         }
  1382         }
  1388 
  1383 
  1405             // Reset pointer to PB object. It is stored in iPBStoreCache array
  1400             // Reset pointer to PB object. It is stored in iPBStoreCache array
  1406             iWriteEntry = NULL;
  1401             iWriteEntry = NULL;
  1407             }     
  1402             }     
  1408         else
  1403         else
  1409             {
  1404             {
  1410 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_5, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL, Deleted entry is not in cache! ");
  1405 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::UpdateCacheL, Deleted entry is not in cache! ");                
  1411             }          
  1406             }          
  1412         }
  1407         }
  1413     // Entry found
  1408     // Entry found
  1414     else
  1409     else
  1415         {
  1410         {
  1417         if ( aEntry->iText || aEntry->iNumber ||
  1412         if ( aEntry->iText || aEntry->iNumber ||
  1418             ( aEntry->iAnr && aEntry->iAnr->MdcaCount() > 0 ) ||
  1413             ( aEntry->iAnr && aEntry->iAnr->MdcaCount() > 0 ) ||
  1419             ( aEntry->iEmail && aEntry->iEmail->MdcaCount() > 0 ) ||
  1414             ( aEntry->iEmail && aEntry->iEmail->MdcaCount() > 0 ) ||
  1420             ( aEntry->iSne && aEntry->iSne->MdcaCount() > 0 ) )
  1415             ( aEntry->iSne && aEntry->iSne->MdcaCount() > 0 ) )
  1421             {
  1416             {
  1422 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_6, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - Change existing entry");
  1417 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - Change existing entry");
  1423             // Every update/deletion of an existing phonebook entry or the
  1418             // Every update/deletion of an existing phonebook entry or the
  1424             // addition of a new phone book entry, incremements the
  1419             // addition of a new phone book entry, incremements the
  1425             // iChangeCounter.
  1420             // iChangeCounter.
  1426             iPhoneBookInfo.iChangeCounter++;
  1421             iPhoneBookInfo.iChangeCounter++;
  1427             // Append updated entry to cache
  1422             // Append updated entry to cache
  1429             // Delete current entry
  1424             // Delete current entry
  1430             CPhoneBookStoreEntry* entryToDelete =
  1425             CPhoneBookStoreEntry* entryToDelete =
  1431                 iPBStoreCache->At( updateIndex );
  1426                 iPBStoreCache->At( updateIndex );
  1432             if ( entryToDelete == iDeleteEntry )
  1427             if ( entryToDelete == iDeleteEntry )
  1433                 {
  1428                 {
  1434 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_7, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - entryToDelete == iDeleteEntry");
  1429 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - entryToDelete == iDeleteEntry");
  1435                 // reset iDeleteEntry member
  1430                 // reset iDeleteEntry member
  1436                 iDeleteEntry = NULL;
  1431                 iDeleteEntry = NULL;
  1437                 }
  1432                 }
  1438             if ( entryToDelete == iWriteEntry )
  1433             if ( entryToDelete == iWriteEntry )
  1439                 {
  1434                 {
  1440 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_8, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - entryToDelete == iWriteEntry");
  1435 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - entryToDelete == iWriteEntry");
  1441                 // reset iWriteEntry member
  1436                 // reset iWriteEntry member
  1442                 iWriteEntry = NULL;
  1437                 iWriteEntry = NULL;
  1443                 }
  1438                 }
  1444             delete entryToDelete;
  1439             delete entryToDelete;
  1445             entryToDelete = NULL;
  1440             entryToDelete = NULL;
  1446             iPBStoreCache->Delete( updateIndex );
  1441             iPBStoreCache->Delete( updateIndex );
  1447             iPBStoreCache->InsertL( updateIndex, aEntry );
  1442             iPBStoreCache->InsertL( updateIndex, aEntry );
  1448 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_9, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - updateIndex: %d", updateIndex);
  1443 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - updateIndex: %i", updateIndex);
  1449             if ( aEntry == iWriteEntry )
  1444             if ( aEntry == iWriteEntry )
  1450                 {
  1445                 {
  1451 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_10, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - aEntry == iWriteEntry");
  1446 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - aEntry == iWriteEntry");
  1452                 // reset iWriteEntry member
  1447                 // reset iWriteEntry member
  1453                 iWriteEntry = NULL;
  1448                 iWriteEntry = NULL;
  1454                 }
  1449                 }
  1455             // Compress cache
  1450             // Compress cache
  1456             iPBStoreCache->Compress();
  1451             iPBStoreCache->Compress();
  1459                 RMobilePhoneStore::KStoreEntryChanged );
  1454                 RMobilePhoneStore::KStoreEntryChanged );
  1460             }
  1455             }
  1461         // Case: <Delete entry from cache>
  1456         // Case: <Delete entry from cache>
  1462         else
  1457         else
  1463             {
  1458             {
  1464 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_11, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - Delete entry");
  1459 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - Delete entry");
  1465             // decrease iUsedEntries
  1460             // decrease iUsedEntries
  1466             iUsedEntries--;
  1461             iUsedEntries--;
  1467 
  1462 
  1468             // Every update/deletion of an existing phonebook entry or the
  1463             // Every update/deletion of an existing phonebook entry or the
  1469             // addition of a new phone book entry incremements the
  1464             // addition of a new phone book entry incremements the
  1471             iPhoneBookInfo.iChangeCounter++;
  1466             iPhoneBookInfo.iChangeCounter++;
  1472             CPhoneBookStoreEntry* entryToDelete =
  1467             CPhoneBookStoreEntry* entryToDelete =
  1473                 iPBStoreCache->At( updateIndex );
  1468                 iPBStoreCache->At( updateIndex );
  1474             if ( entryToDelete == iDeleteEntry )
  1469             if ( entryToDelete == iDeleteEntry )
  1475                 {
  1470                 {
  1476 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_12, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - entryToDelete == iDeleteEntry");
  1471 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - entryToDelete == iDeleteEntry");
  1477                 // reset iDeleteEntry member
  1472                 // reset iDeleteEntry member
  1478                 iDeleteEntry = NULL;
  1473                 iDeleteEntry = NULL;
  1479                 }
  1474                 }
  1480             else
  1475             else
  1481                 {
  1476                 {
  1482 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_UPDATECACHEL_13, "TSY: CMmPhoneBookStoreTsy::UpdateCacheL - iWriteEntry = NULL");
  1477 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::UpdateCacheL - iWriteEntry = NULL");
  1483                 // reset iWriteEntry member
  1478                 // reset iWriteEntry member
  1484                 iWriteEntry = NULL;
  1479                 iWriteEntry = NULL;
  1485                 }
  1480                 }
  1486 
  1481 
  1487             delete entryToDelete;
  1482             delete entryToDelete;
  1534         {
  1529         {
  1535         // Append new entry
  1530         // Append new entry
  1536         if ( 0 == marked )
  1531         if ( 0 == marked )
  1537             {
  1532             {
  1538             ret = pbBuffer->AddNewEntryTag();
  1533             ret = pbBuffer->AddNewEntryTag();
  1539 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_FILLBUFFEREDDESL_1, "TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 0, ret: %d ", ret);
  1534 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 0, ret: %i ", ret);
  1540             }
  1535             }
  1541         // Append Index
  1536         // Append Index
  1542         else if ( 1 == marked )
  1537         else if ( 1 == marked )
  1543             {
  1538             {
  1544             ret = pbBuffer->PutTagAndValue(
  1539             ret = pbBuffer->PutTagAndValue(
  1545                 RMobilePhoneBookStore::ETagPBAdnIndex, (TUint16)(
  1540                 RMobilePhoneBookStore::ETagPBAdnIndex, (TUint16)(
  1546                 aPhoneBookStoreResp->iLocation ) );
  1541                 aPhoneBookStoreResp->iLocation ) );
  1547 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_FILLBUFFEREDDESL_2, "TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 1, ret: %d ", ret);
  1542 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 1, ret: %i ", ret);
  1548             }
  1543             }
  1549         // Append Name
  1544         // Append Name
  1550         else if ( 2 == marked )
  1545         else if ( 2 == marked )
  1551             {
  1546             {
  1552             if ( aPhoneBookStoreResp->iText &&
  1547             if ( aPhoneBookStoreResp->iText &&
  1554                 {
  1549                 {
  1555                 ret = pbBuffer->PutTagAndValue(
  1550                 ret = pbBuffer->PutTagAndValue(
  1556                     RMobilePhoneBookStore::ETagPBText,
  1551                     RMobilePhoneBookStore::ETagPBText,
  1557                     aPhoneBookStoreResp->iText->Des() );
  1552                     aPhoneBookStoreResp->iText->Des() );
  1558                 }
  1553                 }
  1559 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_FILLBUFFEREDDESL_3, "TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 2, ret: %d ", ret);
  1554 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 2, ret: %i ", ret);
  1560             }
  1555             }
  1561         // Append Number
  1556         // Append Number
  1562         else if ( 3 == marked )
  1557         else if ( 3 == marked )
  1563             {
  1558             {
  1564             if ( aPhoneBookStoreResp->iNumber &&
  1559             if ( aPhoneBookStoreResp->iNumber &&
  1566                 {
  1561                 {
  1567                 ret = pbBuffer->PutTagAndValue(
  1562                 ret = pbBuffer->PutTagAndValue(
  1568                     RMobilePhoneBookStore::ETagPBNumber,
  1563                     RMobilePhoneBookStore::ETagPBNumber,
  1569                     aPhoneBookStoreResp->iNumber->Des() );
  1564                     aPhoneBookStoreResp->iNumber->Des() );
  1570                 }
  1565                 }
  1571 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_FILLBUFFEREDDESL_4, "TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 3, ret: %d ", ret);
  1566 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 3, ret: %i ", ret);
  1572             }
  1567             }
  1573         // Append Email
  1568         // Append Email
  1574         else if ( 4 == marked )
  1569         else if ( 4 == marked )
  1575             {
  1570             {
  1576             for ( TInt numEmails = 0;
  1571             for ( TInt numEmails = 0;
  1579                 {
  1574                 {
  1580                 ret = pbBuffer->PutTagAndValue(
  1575                 ret = pbBuffer->PutTagAndValue(
  1581                     RMobilePhoneBookStore::ETagPBEmailAddress,
  1576                     RMobilePhoneBookStore::ETagPBEmailAddress,
  1582                     aPhoneBookStoreResp->iEmail->MdcaPoint( numEmails ) );
  1577                     aPhoneBookStoreResp->iEmail->MdcaPoint( numEmails ) );
  1583                 }
  1578                 }
  1584 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_FILLBUFFEREDDESL_5, "TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 4, ret: %d ", ret);
  1579 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 4, ret: %i ", ret);
  1585             }
  1580             }
  1586         // Append Sne
  1581         // Append Sne
  1587         else if ( 5 == marked )
  1582         else if ( 5 == marked )
  1588             {
  1583             {
  1589             for ( TInt numSnes = 0;
  1584             for ( TInt numSnes = 0;
  1592                 {
  1587                 {
  1593                 ret = pbBuffer->PutTagAndValue(
  1588                 ret = pbBuffer->PutTagAndValue(
  1594                     RMobilePhoneBookStore::ETagPBSecondName,
  1589                     RMobilePhoneBookStore::ETagPBSecondName,
  1595                     aPhoneBookStoreResp->iSne->MdcaPoint( numSnes ) );
  1590                     aPhoneBookStoreResp->iSne->MdcaPoint( numSnes ) );
  1596                 }
  1591                 }
  1597 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_FILLBUFFEREDDESL_6, "TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 5, ret: %d ", ret);
  1592 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 5, ret: %i ", ret);
  1598             }
  1593             }
  1599         // Append Anr
  1594         // Append Anr
  1600         else if ( 6 == marked )
  1595         else if ( 6 == marked )
  1601             {
  1596             {
  1602             for ( TInt numAnrs = 0;
  1597             for ( TInt numAnrs = 0;
  1606                 pbBuffer->AddNewNumberTag();
  1601                 pbBuffer->AddNewNumberTag();
  1607                 ret = pbBuffer->PutTagAndValue(
  1602                 ret = pbBuffer->PutTagAndValue(
  1608                     RMobilePhoneBookStore::ETagPBNumber,
  1603                     RMobilePhoneBookStore::ETagPBNumber,
  1609                     aPhoneBookStoreResp->iAnr->MdcaPoint( numAnrs ) );
  1604                     aPhoneBookStoreResp->iAnr->MdcaPoint( numAnrs ) );
  1610                 }
  1605                 }
  1611 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_FILLBUFFEREDDESL_7, "TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 6, ret: %d ", ret);
  1606 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - 6, ret: %i ", ret);
  1612             }
  1607             }
  1613 
  1608 
  1614         marked++;
  1609         marked++;
  1615         }
  1610         }
  1616 
  1611 
  1630         iNumEntriesFilled++;
  1625         iNumEntriesFilled++;
  1631         }
  1626         }
  1632     
  1627     
  1633     CleanupStack::PopAndDestroy(pbBuffer);
  1628     CleanupStack::PopAndDestroy(pbBuffer);
  1634 
  1629 
  1635 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_FILLBUFFEREDDESL_8, "TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - returnvalue: %d ", ret);
  1630 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::FillBufferedDesL - returnvalue: %i ", ret);
  1636 
  1631 
  1637     //If simrefresh registration is failed prevent new cache
  1632     //If simrefresh registration is failed prevent new cache
  1638     if( KErrOverflow == ret && !( iMmPhoneTsy->GetSimRefreshRegister() ) )
  1633     if( KErrOverflow == ret && !( iMmPhoneTsy->GetSimRefreshRegister() ) )
  1639         {
  1634         {
  1640 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_FILLBUFFEREDDESL_9, "TSY: CMmPhoneBookStoreTsy::ReadL - Prevent new cache" );
  1635 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ReadL - Prevent new cache" );
  1641         iReadReqStore->iCaching = ETrue;
  1636         iReadReqStore->iCaching = ETrue;
  1642         }
  1637         }
  1643 
  1638 
  1644     iRetFillBufferedDes = ret;
  1639     iRetFillBufferedDes = ret;
  1645 
  1640 
  1654 // ---------------------------------------------------------------------------
  1649 // ---------------------------------------------------------------------------
  1655 //
  1650 //
  1656 TInt CMmPhoneBookStoreTsy::ReadCancel(
  1651 TInt CMmPhoneBookStoreTsy::ReadCancel(
  1657     const TTsyReqHandle aTsyReqHandle )
  1652     const TTsyReqHandle aTsyReqHandle )
  1658     {
  1653     {
  1659 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_READCANCEL_1, "TSY: CMmPhoneBookStoreTsy::ReadCancel - Handle:%d", aTsyReqHandle );
  1654 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::ReadCancel - Handle:%d", aTsyReqHandle );
  1660 
  1655 
  1661     // Reset req handle. Returns the deleted req handle
  1656     // Reset req handle. Returns the deleted req handle
  1662     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  1657     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  1663         EMultimodePhoneBookStoreRead );
  1658         EMultimodePhoneBookStoreRead );
  1664 
  1659 
  1690 TInt CMmPhoneBookStoreTsy::WriteL(
  1685 TInt CMmPhoneBookStoreTsy::WriteL(
  1691     const TTsyReqHandle aTsyReqHandle,
  1686     const TTsyReqHandle aTsyReqHandle,
  1692     TDesC8* aPBData,
  1687     TDesC8* aPBData,
  1693     TInt* aIndex )
  1688     TInt* aIndex )
  1694     {
  1689     {
  1695 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_WRITEL_1, "TSY: CMmPhoneBookStoreTsy::WriteL - EtelIndex: %d",*aIndex );
  1690 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::WriteL - EtelIndex: %i",*aIndex );
  1696 
  1691 
  1697     //SDN phonebook can't be updated by user.
  1692     //SDN phonebook can't be updated by user.
  1698     if (iPhoneBookType == KSDNPhoneBook)
  1693     if (iPhoneBookType == KSDNPhoneBook)
  1699         {
  1694         {
  1700         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_WRITEL_2, "TSY: CMmPhoneBookStoreTsy::WriteL - SDN phonebook entry can't be updated");
  1695         TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::WriteL - SDN phonebook entry can't be updated");
  1701         ReqCompleted( aTsyReqHandle, KErrAccessDenied );
  1696         ReqCompleted( aTsyReqHandle, KErrAccessDenied );
  1702         }
  1697         }
  1703     else
  1698     else
  1704         {
  1699         {
  1705         // Check if request handle already exists
  1700         // Check if request handle already exists
  1732             else
  1727             else
  1733                 {
  1728                 {
  1734                 // Straight write-forwarding to SIM server,
  1729                 // Straight write-forwarding to SIM server,
  1735                 TInt index = *aIndex;
  1730                 TInt index = *aIndex;
  1736     
  1731     
  1737     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_WRITEL_3, "TSY: CMmPhoneBookStoreTsy::WriteL - Straight write-forwarding to SIM");
  1732     TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::WriteL - Straight write-forwarding to SIM");
  1738                 ret = WriteByIndexL( index );
  1733                 ret = WriteByIndexL( index );
  1739                 }
  1734                 }
  1740     
  1735     
  1741             // Check error while processing write
  1736             // Check error while processing write
  1742             if ( KErrNone != ret )
  1737             if ( KErrNone != ret )
  1816 //
  1811 //
  1817 void CMmPhoneBookStoreTsy::CompleteWriteL(
  1812 void CMmPhoneBookStoreTsy::CompleteWriteL(
  1818     TInt aResult,
  1813     TInt aResult,
  1819     CMmDataPackage* aDataPackage )
  1814     CMmDataPackage* aDataPackage )
  1820     {
  1815     {
  1821 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEWRITEL_1, "TSY: CMmPhoneBookStoreTsy::CompleteWriteL - Result: %d",aResult );
  1816 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteWriteL - Result: %i",aResult );
  1822     // Reset req handle. Returns the deleted req handle
  1817     // Reset req handle. Returns the deleted req handle
  1823     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  1818     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  1824         EMultimodePhoneBookStoreWrite );
  1819         EMultimodePhoneBookStoreWrite );
  1825 
  1820 
  1826     if ( EMultimodePhoneBookStoreReqHandleUnknown != reqHandle )
  1821     if ( EMultimodePhoneBookStoreReqHandleUnknown != reqHandle )
  1865             if ( KADNPhoneBook == iPhoneBookType )
  1860             if ( KADNPhoneBook == iPhoneBookType )
  1866                 {
  1861                 {
  1867                 //Update Adn Max Num Length
  1862                 //Update Adn Max Num Length
  1868                 iStoreInfoData->iADNNumberLengthMax =
  1863                 iStoreInfoData->iADNNumberLengthMax =
  1869                     pbEntryInfo.iMaxNumLength;
  1864                     pbEntryInfo.iMaxNumLength;
  1870 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEWRITEL_2, "TSY: CMmPhoneBookStoreTsy::CompleteWriteL: pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  1865 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteWriteL: pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  1871                 }
  1866                 }
  1872             else if ( KFDNPhoneBook == iPhoneBookType )
  1867             else if ( KFDNPhoneBook == iPhoneBookType )
  1873                 {
  1868                 {
  1874                 //Update Fdn Max Num Length
  1869                 //Update Fdn Max Num Length
  1875                 iStoreInfoData->iFDNNumberLengthMax =
  1870                 iStoreInfoData->iFDNNumberLengthMax =
  1876                     pbEntryInfo.iMaxNumLength;
  1871                     pbEntryInfo.iMaxNumLength;
  1877 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEWRITEL_3, "TSY: CMmPhoneBookStoreTsy::CompleteWriteL:FDN pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  1872 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteWriteL:FDN pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  1878                 }
  1873                 }
  1879             else if ( KVMBXPhoneBook == iPhoneBookType )
  1874             else if ( KVMBXPhoneBook == iPhoneBookType )
  1880                 {
  1875                 {
  1881                 //Update VMBX Max Num Length
  1876                 //Update VMBX Max Num Length
  1882                 if ( 0 < pbEntryInfo.iMaxNumLength )
  1877                 if ( 0 < pbEntryInfo.iMaxNumLength )
  1883                     {
  1878                     {
  1884                     iStoreInfoData->iVMBXNumberLengthMax =
  1879                     iStoreInfoData->iVMBXNumberLengthMax =
  1885                         pbEntryInfo.iMaxNumLength;
  1880                         pbEntryInfo.iMaxNumLength;
  1886                     }
  1881                     }
  1887 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEWRITEL_4, "TSY: CMmPhoneBookStoreTsy::CompleteWriteL:VMBX pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  1882 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteWriteL:VMBX pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  1888                 }
  1883                 }
  1889             else if ( KMBDNPhoneBook == iPhoneBookType )
  1884             else if ( KMBDNPhoneBook == iPhoneBookType )
  1890                 {
  1885                 {
  1891                 //Update MBDN Max Num Length
  1886                 //Update MBDN Max Num Length
  1892                 if ( 0 < pbEntryInfo.iMaxNumLength )
  1887                 if ( 0 < pbEntryInfo.iMaxNumLength )
  1893                     {
  1888                     {
  1894                     iStoreInfoData->iMBDNNumberLengthMax =
  1889                     iStoreInfoData->iMBDNNumberLengthMax =
  1895                         pbEntryInfo.iMaxNumLength;
  1890                         pbEntryInfo.iMaxNumLength;
  1896                     }
  1891                     }
  1897 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEWRITEL_5, "TSY: CMmPhoneBookStoreTsy::CompleteWriteL:MBDN pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  1892 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteWriteL:MBDN pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  1898                 }
  1893                 }
  1899             CompleteNotifyStoreEvent( pbEntryInfo.iLocation );
  1894             CompleteNotifyStoreEvent( pbEntryInfo.iLocation );
  1900             }
  1895             }
  1901         if ( ( KErrNone == aResult ) || 
  1896         if ( ( KErrNone == aResult ) || 
  1902             ( KErrGsmSimServSneFull == aResult ) ||
  1897             ( KErrGsmSimServSneFull == aResult ) ||
  1981                 // Get name
  1976                 // Get name
  1982                 case RMobilePhoneBookStore::ETagPBText:
  1977                 case RMobilePhoneBookStore::ETagPBText:
  1983                     ret = pbBuffer->GetValue( textPtr );
  1978                     ret = pbBuffer->GetValue( textPtr );
  1984                     if ( iMaxTextLen < textPtr.Length() )
  1979                     if ( iMaxTextLen < textPtr.Length() )
  1985                         {
  1980                         {
  1986 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SEPARATEPBDATAL_1, "TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - Text length is more than KPBStoreTextSize " );
  1981 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - Text length is more than KPBStoreTextSize " );
  1987                         ret = CMmCommonStaticUtility::EpocErrorCode(
  1982                         ret = CMmCommonStaticUtility::EpocErrorCode(
  1988                             KErrTooBig, KErrGsm0707TextStringTooLong );
  1983                             KErrTooBig, KErrGsm0707TextStringTooLong );
  1989                         }
  1984                         }
  1990                     else
  1985                     else
  1991                         {
  1986                         {
  2057                             {
  2052                             {
  2058                             aWriteData->iAnr->AppendL( anrPtr );
  2053                             aWriteData->iAnr->AppendL( anrPtr );
  2059                             }
  2054                             }
  2060                         break;
  2055                         break;
  2061                     case RMobilePhoneBookStore::ETagPBText:
  2056                     case RMobilePhoneBookStore::ETagPBText:
  2062 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SEPARATEPBDATAL_2, "TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - RMobilePhoneBookStore::ETagPBAnrStart ETagPBText" );
  2057 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - RMobilePhoneBookStore::ETagPBAnrStart ETagPBText" );
  2063                         break;
  2058                         break;
  2064                     case RMobilePhoneBookStore::ETagPBTonNpi:
  2059                     case RMobilePhoneBookStore::ETagPBTonNpi:
  2065 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SEPARATEPBDATAL_3, "TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - RMobilePhoneBookStore::ETagPBAnrStart ETagPBTonNpi" );
  2060 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - RMobilePhoneBookStore::ETagPBAnrStart ETagPBTonNpi" );
  2066                         break;
  2061                         break;
  2067                     default:
  2062                     default:
  2068 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SEPARATEPBDATAL_4, "TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - RMobilePhoneBookStore::ETagPBAnrStart KErrArgument" );
  2063 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - RMobilePhoneBookStore::ETagPBAnrStart KErrArgument" );
  2069                         ret = KErrArgument;
  2064                         ret = KErrArgument;
  2070                         break;
  2065                         break;
  2071                     }
  2066                     }
  2072                 }
  2067                 }
  2073                 break;
  2068                 break;
  2074                 // Unknown Tag, complete with KErrArgument
  2069                 // Unknown Tag, complete with KErrArgument
  2075                 default:
  2070                 default:
  2076 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SEPARATEPBDATAL_5, "TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - Unknown Tag " );
  2071 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - Unknown Tag " );
  2077                     ret = KErrArgument;
  2072                     ret = KErrArgument;
  2078                     break;
  2073                     break;
  2079                 }
  2074                 }
  2080             // Get the new field if no errors
  2075             // Get the new field if no errors
  2081 
  2076 
  2082             if ( KErrNone == ret )
  2077             if ( KErrNone == ret )
  2083                 {
  2078                 {
  2084                 ret = pbBuffer->GetTagAndType( tagValue, tagType );
  2079                 ret = pbBuffer->GetTagAndType( tagValue, tagType );
  2085 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SEPARATEPBDATAL_6, "TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - RMobilePhoneBookStore::GetNewField tagValue: %d ", tagValue);
  2080 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - RMobilePhoneBookStore::GetNewField tagValue: %d ", tagValue);
  2086                 }         
  2081                 }         
  2087             }
  2082             }
  2088         if ( KErrNotFound != ret )
  2083         if ( KErrNotFound != ret )
  2089             {
  2084             {
  2090             returnValue = ret;
  2085             returnValue = ret;
  2091             }
  2086             }
  2092         }
  2087         }
  2093     // Bad descriptor, no new entry found
  2088     // Bad descriptor, no new entry found
  2094     else
  2089     else
  2095         {
  2090         {
  2096 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SEPARATEPBDATAL_7, "TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - Bad descriptor " );
  2091 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SeparatePBDataL - Bad descriptor " );
  2097         returnValue = KErrArgument;
  2092         returnValue = KErrArgument;
  2098         }
  2093         }
  2099 
  2094 
  2100     CleanupStack::PopAndDestroy(pbBuffer);
  2095     CleanupStack::PopAndDestroy(pbBuffer);
  2101     
  2096     
  2111 //
  2106 //
  2112 TInt CMmPhoneBookStoreTsy::DeleteL(
  2107 TInt CMmPhoneBookStoreTsy::DeleteL(
  2113     const TTsyReqHandle aTsyReqHandle,
  2108     const TTsyReqHandle aTsyReqHandle,
  2114     TInt* aIndex )
  2109     TInt* aIndex )
  2115     {
  2110     {
  2116 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DELETEL_1, "TSY: CMmPhoneBookStoreTsy::DeleteL - aIndex: %d",*aIndex );
  2111 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::DeleteL - aIndex: %i",*aIndex );
  2117 
  2112 
  2118     //SDN phonebook can't be updated by user.
  2113     //SDN phonebook can't be updated by user.
  2119     if (iPhoneBookType == KSDNPhoneBook)
  2114     if (iPhoneBookType == KSDNPhoneBook)
  2120         {
  2115         {
  2121         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DELETEL_2, "TSY: CMmPhoneBookStoreTsy::DeleteL - SDN phonebook entry can't be updated");
  2116         TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::DeleteL - SDN phonebook entry can't be updated");
  2122         ReqCompleted( aTsyReqHandle, KErrAccessDenied );
  2117         ReqCompleted( aTsyReqHandle, KErrAccessDenied );
  2123         }
  2118         }
  2124     else
  2119     else
  2125         {
  2120         {
  2126         TInt ret( KErrNone );
  2121         TInt ret( KErrNone );
  2180 //
  2175 //
  2181 void CMmPhoneBookStoreTsy::CompleteDeleteL(
  2176 void CMmPhoneBookStoreTsy::CompleteDeleteL(
  2182     TInt aResult,
  2177     TInt aResult,
  2183     CMmDataPackage* aDataPackage )
  2178     CMmDataPackage* aDataPackage )
  2184     {
  2179     {
  2185 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEDELETEL_1, "TSY: CMmPhoneBookStoreTsy::CompleteDeleteL - Result: %d",aResult );
  2180 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteDeleteL - Result: %i",aResult );
  2186     // Reset req handle. Returns the deleted req handle
  2181     // Reset req handle. Returns the deleted req handle
  2187     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2182     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2188         EMultimodePhoneStoreDelete );
  2183         EMultimodePhoneStoreDelete );
  2189 
  2184 
  2190     if ( EMultimodePhoneBookStoreReqHandleUnknown != reqHandle )
  2185     if ( EMultimodePhoneBookStoreReqHandleUnknown != reqHandle )
  2223             if ( KADNPhoneBook == iPhoneBookType )
  2218             if ( KADNPhoneBook == iPhoneBookType )
  2224                 {
  2219                 {
  2225                 //Update Adn Max Num Length
  2220                 //Update Adn Max Num Length
  2226                 iStoreInfoData->iADNNumberLengthMax =
  2221                 iStoreInfoData->iADNNumberLengthMax =
  2227                     pbEntryInfo.iMaxNumLength;
  2222                     pbEntryInfo.iMaxNumLength;
  2228 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEDELETEL_2, "TSY: CMmPhoneBookStoreTsy::CompleteDeleteL: pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2223 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteDeleteL: pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2229                 }
  2224                 }
  2230             else if ( KFDNPhoneBook == iPhoneBookType )
  2225             else if ( KFDNPhoneBook == iPhoneBookType )
  2231                 {
  2226                 {
  2232                 //Update Fdn Max Num Length
  2227                 //Update Fdn Max Num Length
  2233                 iStoreInfoData->iFDNNumberLengthMax =
  2228                 iStoreInfoData->iFDNNumberLengthMax =
  2234                     pbEntryInfo.iMaxNumLength;
  2229                     pbEntryInfo.iMaxNumLength;
  2235 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEDELETEL_3, "TSY: CMmPhoneBookStoreTsy::CompleteDeleteL:FDN pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2230 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteDeleteL:FDN pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2236                 }
  2231                 }
  2237             else if ( KVMBXPhoneBook == iPhoneBookType )
  2232             else if ( KVMBXPhoneBook == iPhoneBookType )
  2238                 {
  2233                 {
  2239                 //Update VMBX Max Num Length
  2234                 //Update VMBX Max Num Length
  2240                 if ( 0 < pbEntryInfo.iMaxNumLength )
  2235                 if ( 0 < pbEntryInfo.iMaxNumLength )
  2241                     {
  2236                     {
  2242                     iStoreInfoData->iVMBXNumberLengthMax =
  2237                     iStoreInfoData->iVMBXNumberLengthMax =
  2243                         pbEntryInfo.iMaxNumLength;
  2238                         pbEntryInfo.iMaxNumLength;
  2244                     }
  2239                     }
  2245 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEDELETEL_4, "TSY: CMmPhoneBookStoreTsy::CompleteDeleteL:VMBX pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2240 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteDeleteL:VMBX pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2246                 }
  2241                 }
  2247             }
  2242             }
  2248         
  2243         
  2249 #ifdef USING_CTSY_DISPATCHER
  2244 #ifdef USING_CTSY_DISPATCHER
  2250            
  2245            
  2288 // ---------------------------------------------------------------------------
  2283 // ---------------------------------------------------------------------------
  2289 //
  2284 //
  2290 TInt CMmPhoneBookStoreTsy::DeleteAllL(
  2285 TInt CMmPhoneBookStoreTsy::DeleteAllL(
  2291     const TTsyReqHandle aTsyReqHandle )
  2286     const TTsyReqHandle aTsyReqHandle )
  2292     {
  2287     {
  2293 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DELETEALLL_1, "TSY: CMmPhoneBookStoreTsy::DeleteAllL - Handle:%d", aTsyReqHandle );
  2288 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::DeleteAllL - Handle:%d", aTsyReqHandle );
  2294 
  2289 
  2295     //SDN phonebook can't be updated by user.
  2290     //SDN phonebook can't be updated by user.
  2296     if (iPhoneBookType == KSDNPhoneBook)
  2291     if (iPhoneBookType == KSDNPhoneBook)
  2297         {
  2292         {
  2298         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_DELETEALLL_2, "TSY: CMmPhoneBookStoreTsy::DeleteAllL - SDN phonebook entry can't be updated");
  2293         TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::DeleteAllL - SDN phonebook entry can't be updated");
  2299         ReqCompleted( aTsyReqHandle, KErrAccessDenied );
  2294         ReqCompleted( aTsyReqHandle, KErrAccessDenied );
  2300         }
  2295         }
  2301     else
  2296     else
  2302         {
  2297         {
  2303         TInt ret( KErrNone );
  2298         TInt ret( KErrNone );
  2329 //
  2324 //
  2330 void CMmPhoneBookStoreTsy::CompleteDeleteAll(
  2325 void CMmPhoneBookStoreTsy::CompleteDeleteAll(
  2331     TInt aResult,
  2326     TInt aResult,
  2332     CMmDataPackage* aDataPackage )
  2327     CMmDataPackage* aDataPackage )
  2333     {
  2328     {
  2334 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEDELETEALL_1, "TSY: CMmPhoneBookStoreTsy::CompleteDeleteAll - Result: %d",aResult );
  2329 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteDeleteAll - Result: %i",aResult );
  2335     // Reset req handle. Returns the deleted req handle
  2330     // Reset req handle. Returns the deleted req handle
  2336     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2331     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2337         EMultimodePhoneStoreDeleteAll );
  2332         EMultimodePhoneStoreDeleteAll );
  2338 
  2333 
  2339     if ( EMultimodePhoneBookStoreReqHandleUnknown != reqHandle )
  2334     if ( EMultimodePhoneBookStoreReqHandleUnknown != reqHandle )
  2361             if ( KADNPhoneBook == iPhoneBookType )
  2356             if ( KADNPhoneBook == iPhoneBookType )
  2362                 {
  2357                 {
  2363                 //Update Adn Max Num Length
  2358                 //Update Adn Max Num Length
  2364                 iStoreInfoData->iADNNumberLengthMax =
  2359                 iStoreInfoData->iADNNumberLengthMax =
  2365                     pbEntryInfo.iMaxNumLength;
  2360                     pbEntryInfo.iMaxNumLength;
  2366 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEDELETEALL_2, "TSY: CMmPhoneBookStoreTsy::CompleteDeleteAll: pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2361 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteDeleteAll: pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2367                 }
  2362                 }
  2368             else if ( KFDNPhoneBook == iPhoneBookType )
  2363             else if ( KFDNPhoneBook == iPhoneBookType )
  2369                 {
  2364                 {
  2370                 //Update Fdn Max Num Length
  2365                 //Update Fdn Max Num Length
  2371                 iStoreInfoData->iFDNNumberLengthMax =
  2366                 iStoreInfoData->iFDNNumberLengthMax =
  2372                     pbEntryInfo.iMaxNumLength;
  2367                     pbEntryInfo.iMaxNumLength;
  2373 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEDELETEALL_3, "TSY: CMmPhoneBookStoreTsy::CompleteDeleteAll:FDN pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2368 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteDeleteAll:FDN pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2374                 }
  2369                 }
  2375             else if ( KVMBXPhoneBook == iPhoneBookType )
  2370             else if ( KVMBXPhoneBook == iPhoneBookType )
  2376                 {
  2371                 {
  2377                 //Update VMBX Max Num Length
  2372                 //Update VMBX Max Num Length
  2378                 if ( 0 < pbEntryInfo.iMaxNumLength )
  2373                 if ( 0 < pbEntryInfo.iMaxNumLength )
  2379                     {
  2374                     {
  2380                     iStoreInfoData->iVMBXNumberLengthMax =
  2375                     iStoreInfoData->iVMBXNumberLengthMax =
  2381                         pbEntryInfo.iMaxNumLength;
  2376                         pbEntryInfo.iMaxNumLength;
  2382                     }
  2377                     }
  2383 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEDELETEALL_4, "TSY: CMmPhoneBookStoreTsy::CompleteDeleteAll:VMBX pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2378 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteDeleteAll:VMBX pbEntryInfo.iMaxNumLength:%d", pbEntryInfo.iMaxNumLength);
  2384                 }
  2379                 }
  2385 
  2380 
  2386             // Complete notify store event
  2381             // Complete notify store event
  2387             iMobilePhoneBookStoreEvent = RMobilePhoneStore::KStoreEmpty;
  2382             iMobilePhoneBookStoreEvent = RMobilePhoneStore::KStoreEmpty;
  2388             CompleteNotifyStoreEvent( -1 ); // DeleteAll->index -1
  2383             CompleteNotifyStoreEvent( -1 ); // DeleteAll->index -1
  2405 TInt CMmPhoneBookStoreTsy::GetInfoL(
  2400 TInt CMmPhoneBookStoreTsy::GetInfoL(
  2406     const TTsyReqHandle aTsyReqHandle,
  2401     const TTsyReqHandle aTsyReqHandle,
  2407     TDes8* aInfo )
  2402     TDes8* aInfo )
  2408     {
  2403     {
  2409 
  2404 
  2410 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_1, "TSY: CMmPhoneBookStoreTsy::GetInfoL Handle:%d", aTsyReqHandle);
  2405 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL Handle:%d", aTsyReqHandle);
  2411 
  2406 
  2412     TInt ret( KErrNone );
  2407     TInt ret( KErrNone );
  2413     TTsyReqHandle getInfoHandle =
  2408     TTsyReqHandle getInfoHandle =
  2414         iTsyReqHandleStore->GetTsyReqHandle( EMultimodePhoneStoreGetInfo );
  2409         iTsyReqHandleStore->GetTsyReqHandle( EMultimodePhoneStoreGetInfo );
  2415 
  2410 
  2456         // BDN is not supported feature. Request will be completed later on 
  2451         // BDN is not supported feature. Request will be completed later on 
  2457         // this method with KErrNone and hard coded BDN storage information 
  2452         // this method with KErrNone and hard coded BDN storage information 
  2458         // will be delivered to the client.
  2453         // will be delivered to the client.
  2459         if ( KBDNPhoneBook == iPhoneBookType )
  2454         if ( KBDNPhoneBook == iPhoneBookType )
  2460             {
  2455             {
  2461 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_2, "TSY: CMmPhoneBookStoreTsy::GetInfoL - BDN" );
  2456 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL - BDN" );
  2462             }
  2457             }
  2463         // If PB type is ADN, total entries and used entries already read
  2458         // If PB type is ADN, total entries and used entries already read
  2464         else if ( KADNPhoneBook == iPhoneBookType )
  2459         else if ( KADNPhoneBook == iPhoneBookType )
  2465             {
  2460             {
  2466 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_3, "TSY: CMmPhoneBookStoreTsy::GetInfoL - ADN" );
  2461 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL - ADN" );
  2467             ret = KErrNotReady;
  2462             ret = KErrNotReady;
  2468 
  2463 
  2469             //if cache is ready, set information and get name length
  2464             //if cache is ready, set information and get name length
  2470             if ( EFalse != iCacheReady )
  2465             if ( EFalse != iCacheReady )
  2471                 {
  2466                 {
  2480                     iStoreInfoData->iADNTextLengthMax;
  2475                     iStoreInfoData->iADNTextLengthMax;
  2481 
  2476 
  2482                 // The total number of entries
  2477                 // The total number of entries
  2483                 iPhoneBookInfoChanged->iTotalEntries =
  2478                 iPhoneBookInfoChanged->iTotalEntries =
  2484                     iStoreInfoData->iADNNumOfEntries;
  2479                     iStoreInfoData->iADNNumOfEntries;
  2485 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_4, "TSY: CMmPhoneBookStoreTsy::GetInfoL - total entries: %d",iStoreInfoData->iADNNumOfEntries );
  2480 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - total entries: %i",iStoreInfoData->iADNNumOfEntries );
  2486 
  2481 
  2487                 // Check if Email, SNE & ANR Caps are supported + GRP
  2482                 // Check if Email, SNE & ANR Caps are supported + GRP
  2488 
  2483 
  2489                 if ( iStoreInfoData->iEmailNumOfEntriesPerEntry > 0 )
  2484                 if ( iStoreInfoData->iEmailNumOfEntriesPerEntry > 0 )
  2490                     {
  2485                     {
  2491                     iPhoneBookInfoChanged->iCaps =
  2486                     iPhoneBookInfoChanged->iCaps =
  2492                         iPhoneBookInfoChanged->iCaps |
  2487                         iPhoneBookInfoChanged->iCaps |
  2493                         RMobilePhoneBookStore::KCapsEmailAddressUsed;
  2488                         RMobilePhoneBookStore::KCapsEmailAddressUsed;
  2494 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_5, "TSY: CMmPhoneBookStoreTsy::GetInfoL ADN -> Email supported" );
  2489 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL ADN -> Email supported" );
  2495                     }
  2490                     }
  2496                 if ( iStoreInfoData->iSNENumOfEntriesPerEntry > 0 )
  2491                 if ( iStoreInfoData->iSNENumOfEntriesPerEntry > 0 )
  2497                     {
  2492                     {
  2498                     iPhoneBookInfoChanged->iCaps =
  2493                     iPhoneBookInfoChanged->iCaps =
  2499                         iPhoneBookInfoChanged->iCaps |
  2494                         iPhoneBookInfoChanged->iCaps |
  2500                         RMobilePhoneBookStore::KCapsSecondNameUsed;
  2495                         RMobilePhoneBookStore::KCapsSecondNameUsed;
  2501 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_6, "TSY: CMmPhoneBookStoreTsy::GetInfoL ADN -> SNE supported" );
  2496 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL ADN -> SNE supported" );
  2502                     }
  2497                     }
  2503                 if ( iStoreInfoData->iANRNumOfEntriesPerEntry > 0 )
  2498                 if ( iStoreInfoData->iANRNumOfEntriesPerEntry > 0 )
  2504                     {
  2499                     {
  2505                     iPhoneBookInfoChanged->iCaps =
  2500                     iPhoneBookInfoChanged->iCaps =
  2506                         iPhoneBookInfoChanged->iCaps |
  2501                         iPhoneBookInfoChanged->iCaps |
  2507                         RMobilePhoneBookStore::KCapsAdditionalNumUsed;
  2502                         RMobilePhoneBookStore::KCapsAdditionalNumUsed;
  2508 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_7, "TSY: CMmPhoneBookStoreTsy::GetInfoL ADN -> ANR supported" );
  2503 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL ADN -> ANR supported" );
  2509                     }
  2504                     }
  2510                 }
  2505                 }
  2511             }
  2506             }
  2512         // If PB type is FDN, total entries and used entries already read
  2507         // If PB type is FDN, total entries and used entries already read
  2513         else if ( KFDNPhoneBook == iPhoneBookType )
  2508         else if ( KFDNPhoneBook == iPhoneBookType )
  2514             {
  2509             {
  2515 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_8, "TSY: CMmPhoneBookStoreTsy::GetInfoL - FDN" );
  2510 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL - FDN" );
  2516             ret = KErrNotReady;
  2511             ret = KErrNotReady;
  2517 
  2512 
  2518             //if cache is ready, set information and get name length
  2513             //if cache is ready, set information and get name length
  2519             if ( EFalse != iCacheReady )
  2514             if ( EFalse != iCacheReady )
  2520                 {
  2515                 {
  2529                     iStoreInfoData->iFDNTextLengthMax;
  2524                     iStoreInfoData->iFDNTextLengthMax;
  2530 
  2525 
  2531                 // The total number of entries
  2526                 // The total number of entries
  2532                 iPhoneBookInfoChanged->iTotalEntries =
  2527                 iPhoneBookInfoChanged->iTotalEntries =
  2533                     iStoreInfoData->iFDNNumOfEntries;
  2528                     iStoreInfoData->iFDNNumOfEntries;
  2534 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_9, "TSY: CMmPhoneBookStoreTsy::GetInfoL - total entries: %d",iStoreInfoData->iFDNNumOfEntries );
  2529 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - total entries: %i",iStoreInfoData->iFDNNumOfEntries );
  2535 
  2530 
  2536                 // Set caps by phonebook name
  2531                 // Set caps by phonebook name
  2537                 iPhoneBookInfoChanged->iCaps = KPBTypeFDNCaps;
  2532                 iPhoneBookInfoChanged->iCaps = KPBTypeFDNCaps;
  2538                 }
  2533                 }
  2539 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_10, "TSY: CMmPhoneBookStoreTsy::GetInfoL - iMaxNumLength: %d",iPhoneBookInfoChanged->iMaxNumLength );
  2534 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - iMaxNumLength: %i",iPhoneBookInfoChanged->iMaxNumLength );
  2540 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_11, "TSY: CMmPhoneBookStoreTsy::GetInfoL - iMaxTextLength: %d",iPhoneBookInfoChanged->iMaxTextLength );
  2535 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - iMaxTextLength: %i",iPhoneBookInfoChanged->iMaxTextLength );
  2541 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_12, "TSY: CMmPhoneBookStoreTsy::GetInfoL - iTotalEntries: %d",iPhoneBookInfoChanged->iTotalEntries );
  2536 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - iTotalEntries: %i",iPhoneBookInfoChanged->iTotalEntries );
  2542 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_13, "TSY: CMmPhoneBookStoreTsy::GetInfoL - iUsedEntries: %d",iPhoneBookInfoChanged->iUsedEntries );
  2537 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - iUsedEntries: %i",iPhoneBookInfoChanged->iUsedEntries );
  2543             }
  2538             }
  2544         else if ( KSDNPhoneBook == iPhoneBookType )
  2539         else if ( KSDNPhoneBook == iPhoneBookType )
  2545             {
  2540             {
  2546 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_14, "TSY: CMmPhoneBookStoreTsy::GetInfoL - SDN" );
  2541 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL - SDN" );
  2547             ret = KErrNone;
  2542             ret = KErrNone;
  2548 
  2543 
  2549             // The maximum length for the number in a phonebook entry
  2544             // The maximum length for the number in a phonebook entry
  2550             iPhoneBookInfoChanged->iMaxNumLength =
  2545             iPhoneBookInfoChanged->iMaxNumLength =
  2551                 iStoreInfoData->iSDNNumberLengthMax;
  2546                 iStoreInfoData->iSDNNumberLengthMax;
  2555                 iStoreInfoData->iSDNTextLengthMax;
  2550                 iStoreInfoData->iSDNTextLengthMax;
  2556 
  2551 
  2557             // The total number of entries
  2552             // The total number of entries
  2558             iPhoneBookInfoChanged->iTotalEntries =
  2553             iPhoneBookInfoChanged->iTotalEntries =
  2559                 iStoreInfoData->iSDNNumOfEntries;
  2554                 iStoreInfoData->iSDNNumOfEntries;
  2560 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_15, "TSY: CMmPhoneBookStoreTsy::GetInfoL - total entries: %d",iStoreInfoData->iSDNNumOfEntries );
  2555 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - total entries: %i",iStoreInfoData->iSDNNumOfEntries );
  2561 
  2556 
  2562             if ( !iIsUsedEntriesCounted )
  2557             if ( !iIsUsedEntriesCounted )
  2563                 {
  2558                 {
  2564                 // Check first that SIM server is ready before doing this
  2559                 // Check first that SIM server is ready before doing this
  2565                 if ( !iIsUsedEntriesCounted &&
  2560                 if ( !iIsUsedEntriesCounted &&
  2572                     ret = CountEntriesL();
  2567                     ret = CountEntriesL();
  2573                     }
  2568                     }
  2574                 else
  2569                 else
  2575                     {
  2570                     {
  2576                     iPhoneBookInfoChanged = NULL;
  2571                     iPhoneBookInfoChanged = NULL;
  2577 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_16, "TSY: CMmPhoneBookStoreTsy::GetInfoL, not ready to perform CountEntriesL()");
  2572 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL, not ready to perform CountEntriesL()");
  2578                     ret = KErrNotReady;
  2573                     ret = KErrNotReady;
  2579                     }
  2574                     }
  2580                 }
  2575                 }
  2581             }
  2576             }
  2582         //VMBX need to read total and used entries
  2577         //VMBX need to read total and used entries
  2583         else if ( KVMBXPhoneBook == iPhoneBookType )
  2578         else if ( KVMBXPhoneBook == iPhoneBookType )
  2584             {
  2579             {
  2585 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_17, "TSY: CMmPhoneBookStoreTsy::GetInfoL - VMBX" );
  2580 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL - VMBX" );
  2586             ret = KErrNone;
  2581             ret = KErrNone;
  2587 
  2582 
  2588             // The maximum length for the number in a phonebook entry
  2583             // The maximum length for the number in a phonebook entry
  2589             iPhoneBookInfoChanged->iMaxNumLength =
  2584             iPhoneBookInfoChanged->iMaxNumLength =
  2590                 iStoreInfoData->iVMBXNumberLengthMax;
  2585                 iStoreInfoData->iVMBXNumberLengthMax;
  2594                 iStoreInfoData->iVMBXTextLengthMax;
  2589                 iStoreInfoData->iVMBXTextLengthMax;
  2595 
  2590 
  2596             // The total number of entries
  2591             // The total number of entries
  2597             iPhoneBookInfoChanged->iTotalEntries =
  2592             iPhoneBookInfoChanged->iTotalEntries =
  2598                 iStoreInfoData->iVMBXNumOfEntries;
  2593                 iStoreInfoData->iVMBXNumOfEntries;
  2599 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_18, "TSY: CMmPhoneBookStoreTsy::GetInfoL - total entries: %d",iStoreInfoData->iVMBXNumOfEntries );
  2594 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - total entries: %i",iStoreInfoData->iVMBXNumOfEntries );
  2600 
  2595 
  2601             // Set caps by the store info data 
  2596             // Set caps by the store info data 
  2602             //iPhoneBookInfoChanged->iCaps = iStoreInfoData->iVMBXCaps;
  2597             //iPhoneBookInfoChanged->iCaps = iStoreInfoData->iVMBXCaps;
  2603             iPhoneBookInfoChanged->iCaps = KPBTypeVMBXCaps;
  2598             iPhoneBookInfoChanged->iCaps = KPBTypeVMBXCaps;
  2604             
  2599             
  2614                     ret = CountEntriesL();
  2609                     ret = CountEntriesL();
  2615                     }
  2610                     }
  2616                 else
  2611                 else
  2617                     {
  2612                     {
  2618                     iPhoneBookInfoChanged = NULL;
  2613                     iPhoneBookInfoChanged = NULL;
  2619 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_19, "TSY: CMmPhoneBookStoreTsy::GetInfoL, not ready to perform CountEntriesL()");
  2614 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL, not ready to perform CountEntriesL()");
  2620                     ret = KErrNotReady;
  2615                     ret = KErrNotReady;
  2621                     }
  2616                     }
  2622                 }
  2617                 }
  2623             }
  2618             }
  2624          //MBDN
  2619          //MBDN
  2625         else if ( KMBDNPhoneBook == iPhoneBookType )
  2620         else if ( KMBDNPhoneBook == iPhoneBookType )
  2626             {
  2621             {
  2627 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_20, "TSY: CMmPhoneBookStoreTsy::GetInfoL - MBDN" );
  2622 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::GetInfoL - MBDN" );
  2628             ret = KErrNone;
  2623             ret = KErrNone;
  2629 
  2624 
  2630             // The maximum length for the number in a phonebook entry
  2625             // The maximum length for the number in a phonebook entry
  2631             iPhoneBookInfoChanged->iMaxNumLength =
  2626             iPhoneBookInfoChanged->iMaxNumLength =
  2632                 iStoreInfoData->iMBDNNumberLengthMax;
  2627                 iStoreInfoData->iMBDNNumberLengthMax;
  2636                 iStoreInfoData->iMBDNTextLengthMax;
  2631                 iStoreInfoData->iMBDNTextLengthMax;
  2637 
  2632 
  2638             // The total number of entries
  2633             // The total number of entries
  2639             iPhoneBookInfoChanged->iTotalEntries =
  2634             iPhoneBookInfoChanged->iTotalEntries =
  2640                 iStoreInfoData->iMBDNNumOfEntries;
  2635                 iStoreInfoData->iMBDNNumOfEntries;
  2641 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_21, "TSY: CMmPhoneBookStoreTsy::GetInfoL - total entries: %d",iPhoneBookInfoChanged->iTotalEntries );
  2636 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - total entries: %i",iPhoneBookInfoChanged->iTotalEntries );
  2642 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_22, "TSY: CMmPhoneBookStoreTsy::GetInfoL - iMaxNumLength: %d",iPhoneBookInfoChanged->iMaxNumLength );
  2637 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - iMaxNumLength: %i",iPhoneBookInfoChanged->iMaxNumLength );
  2643 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOL_23, "TSY: CMmPhoneBookStoreTsy::GetInfoL - iMaxTextLength: %d",iPhoneBookInfoChanged->iMaxTextLength );
  2638 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoL - iMaxTextLength: %i",iPhoneBookInfoChanged->iMaxTextLength );
  2644 
  2639 
  2645             // Set caps by the store info data 
  2640             // Set caps by the store info data 
  2646             iPhoneBookInfoChanged->iCaps = KPBTypeMBDNCaps;
  2641             iPhoneBookInfoChanged->iCaps = KPBTypeMBDNCaps;
  2647             }
  2642             }
  2648         if ( completeRequest )
  2643         if ( completeRequest )
  2673 // ---------------------------------------------------------------------------
  2668 // ---------------------------------------------------------------------------
  2674 //
  2669 //
  2675 void CMmPhoneBookStoreTsy::CompleteGetInfo(
  2670 void CMmPhoneBookStoreTsy::CompleteGetInfo(
  2676     TInt aError )
  2671     TInt aError )
  2677     {
  2672     {
  2678 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETEGETINFO_1, "TSY: CMmPhoneBookStoreTsy::CompleteGetInfo - Result: %d", aError );
  2673 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteGetInfo - Result: %i", aError );
  2679     // Reset req handle. Returns the deleted req handle
  2674     // Reset req handle. Returns the deleted req handle
  2680     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2675     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2681         EMultimodePhoneStoreGetInfo );
  2676         EMultimodePhoneStoreGetInfo );
  2682 
  2677 
  2683     if ( EMultimodePhoneBookStoreReqHandleUnknown != reqHandle )
  2678     if ( EMultimodePhoneBookStoreReqHandleUnknown != reqHandle )
  2754         iPhoneBookInfoChanged->iCaps = KPBTypeMBDNCaps;
  2749         iPhoneBookInfoChanged->iCaps = KPBTypeMBDNCaps;
  2755         }
  2750         }
  2756 
  2751 
  2757     // Indicates the current number of entries that may be held in this store
  2752     // Indicates the current number of entries that may be held in this store
  2758     iPhoneBookInfoChanged->iUsedEntries = iUsedEntries;
  2753     iPhoneBookInfoChanged->iUsedEntries = iUsedEntries;
  2759 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SETINFO_1, "TSY: CMmPhoneBookStoreTsy::SetInfo - used entries: %d",iUsedEntries );
  2754 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::SetInfo - used entries: %i",iUsedEntries );
  2760 
  2755 
  2761     // Indicates the total number of entries
  2756     // Indicates the total number of entries
  2762     iPhoneBookInfoChanged->iTotalEntries = KNoInfoAvail;
  2757     iPhoneBookInfoChanged->iTotalEntries = KNoInfoAvail;
  2763     }
  2758     }
  2764 
  2759 
  2770 // ---------------------------------------------------------------------------
  2765 // ---------------------------------------------------------------------------
  2771 //
  2766 //
  2772 TInt CMmPhoneBookStoreTsy::GetInfoCancel(
  2767 TInt CMmPhoneBookStoreTsy::GetInfoCancel(
  2773     const TTsyReqHandle aTsyReqHandle )
  2768     const TTsyReqHandle aTsyReqHandle )
  2774     {
  2769     {
  2775 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETINFOCANCEL_1, "TSY: CMmPhoneBookStoreTsy::GetInfoCancel - Handle:%d", aTsyReqHandle );
  2770 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::GetInfoCancel - Handle:%d", aTsyReqHandle );
  2776 
  2771 
  2777     // Reset req handle. Returns the deleted req handle
  2772     // Reset req handle. Returns the deleted req handle
  2778     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2773     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2779         EMultimodePhoneStoreGetInfo );
  2774         EMultimodePhoneStoreGetInfo );
  2780 
  2775 
  2803 //
  2798 //
  2804 TInt CMmPhoneBookStoreTsy::NotifyStoreEvent(
  2799 TInt CMmPhoneBookStoreTsy::NotifyStoreEvent(
  2805     RMobilePhoneStore::TMobileStoreEvent *aEvent,
  2800     RMobilePhoneStore::TMobileStoreEvent *aEvent,
  2806     TInt* aIndex )
  2801     TInt* aIndex )
  2807     {
  2802     {
  2808 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_NOTIFYSTOREEVENT_1, "TSY: CMmPhoneBookStoreTsy::NotifyStoreEvent - called" );
  2803 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::NotifyStoreEvent - called" );
  2809 
  2804 
  2810     TTsyReqHandle requestHandle = iTsyReqHandleStore->GetTsyReqHandle(
  2805     TTsyReqHandle requestHandle = iTsyReqHandleStore->GetTsyReqHandle(
  2811         EMultimodePhoneStoreNotifyStoreEvent );
  2806         EMultimodePhoneStoreNotifyStoreEvent );
  2812 
  2807 
  2813     // If request is not running
  2808     // If request is not running
  2831 // ---------------------------------------------------------------------------
  2826 // ---------------------------------------------------------------------------
  2832 //
  2827 //
  2833 TInt CMmPhoneBookStoreTsy::NotifyStoreEventCancel(
  2828 TInt CMmPhoneBookStoreTsy::NotifyStoreEventCancel(
  2834     const TTsyReqHandle aTsyReqHandle )
  2829     const TTsyReqHandle aTsyReqHandle )
  2835     {
  2830     {
  2836 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_NOTIFYSTOREEVENTCANCEL_1, "TSY: CMmPhoneBookStoreTsy::NotifyStoreEventCancel - called" );
  2831 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::NotifyStoreEventCancel - called" );
  2837 
  2832 
  2838     // Reset req handle. Returns the deleted req handle
  2833     // Reset req handle. Returns the deleted req handle
  2839     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2834     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2840         EMultimodePhoneStoreNotifyStoreEvent );
  2835         EMultimodePhoneStoreNotifyStoreEvent );
  2841 
  2836 
  2857 // ---------------------------------------------------------------------------
  2852 // ---------------------------------------------------------------------------
  2858 //
  2853 //
  2859 void CMmPhoneBookStoreTsy::CompleteNotifyStoreEvent(
  2854 void CMmPhoneBookStoreTsy::CompleteNotifyStoreEvent(
  2860     TInt aLocation )
  2855     TInt aLocation )
  2861     {
  2856     {
  2862 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETENOTIFYSTOREEVENT_1, "TSY: CMmPhoneBookStoreTsy::CompleteNotifyStoreEvent - Called" );
  2857 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::CompleteNotifyStoreEvent - Called" );
  2863 
  2858 
  2864     //reset req handle. Returns the deleted req handle
  2859     //reset req handle. Returns the deleted req handle
  2865     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2860     TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
  2866                                 EMultimodePhoneStoreNotifyStoreEvent );
  2861                                 EMultimodePhoneStoreNotifyStoreEvent );
  2867 
  2862 
  2869         {
  2864         {
  2870         RMobilePhoneStore::TMobileStoreEvent* phoneBookStoreEvent =
  2865         RMobilePhoneStore::TMobileStoreEvent* phoneBookStoreEvent =
  2871             REINTERPRET_CAST( RMobilePhoneStore::TMobileStoreEvent*,
  2866             REINTERPRET_CAST( RMobilePhoneStore::TMobileStoreEvent*,
  2872             iNotifyPhoneBookStoreEventPtr );
  2867             iNotifyPhoneBookStoreEventPtr );
  2873 
  2868 
  2874 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETENOTIFYSTOREEVENT_2, "TSY: CMmPhoneBookStoreTsy::CompleteNotifyStoreEvent - StoreEvent %8X ", (TUint)iMobilePhoneBookStoreEvent );
  2869 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteNotifyStoreEvent - StoreEvent %i ", iMobilePhoneBookStoreEvent );
  2875 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_COMPLETENOTIFYSTOREEVENT_3, "TSY: CMmPhoneBookStoreTsy::CompleteNotifyStoreEvent - location %d ", aLocation );
  2870 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::CompleteNotifyStoreEvent - location %i ", aLocation );
  2876         // Fill notify information
  2871         // Fill notify information
  2877         *phoneBookStoreEvent = iMobilePhoneBookStoreEvent;
  2872         *phoneBookStoreEvent = iMobilePhoneBookStoreEvent;
  2878         *iNotifyPhoneBookStoreEventIndexPtr = aLocation;
  2873         *iNotifyPhoneBookStoreEventIndexPtr = aLocation;
  2879 
  2874 
  2880         ReqCompleted( reqHandle, KErrNone );
  2875         ReqCompleted( reqHandle, KErrNone );
  2918 // (other items were commented in a header).
  2913 // (other items were commented in a header).
  2919 // ---------------------------------------------------------------------------
  2914 // ---------------------------------------------------------------------------
  2920 //
  2915 //
  2921 void CMmPhoneBookStoreTsy::ResetVariables()
  2916 void CMmPhoneBookStoreTsy::ResetVariables()
  2922     {
  2917     {
  2923 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_RESETVARIABLES_1, "TSY: CMmPhoneBookStoreTsy::ResetVariables" );
  2918 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ResetVariables" );
  2924 
  2919 
  2925     // Reset phonebooktype
  2920     // Reset phonebooktype
  2926     iPhoneBookType = 0;
  2921     iPhoneBookType = 0;
  2927 
  2922 
  2928     // Cache variables
  2923     // Cache variables
  2963 // (other items were commented in a header).
  2958 // (other items were commented in a header).
  2964 // ---------------------------------------------------------------------------
  2959 // ---------------------------------------------------------------------------
  2965 //
  2960 //
  2966 void CMmPhoneBookStoreTsy::ResetCache()
  2961 void CMmPhoneBookStoreTsy::ResetCache()
  2967     {
  2962     {
  2968 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_RESETCACHE_1, "TSY: CMmPhoneBookStoreTsy::ResetCache" );
  2963 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ResetCache" );
  2969 
  2964 
  2970     // SDN and VMBX do not have cache. Skip reset if the cache pointer is null.
  2965     // SDN and VMBX do not have cache. Skip reset if the cache pointer is null.
  2971     if ( NULL != iPBStoreCache )
  2966     if ( NULL != iPBStoreCache )
  2972         {
  2967         {
  2973 
  2968 
  2983 // (other items were commented in a header).
  2978 // (other items were commented in a header).
  2984 // ---------------------------------------------------------------------------
  2979 // ---------------------------------------------------------------------------
  2985 //
  2980 //
  2986 void CMmPhoneBookStoreTsy::ResetCacheReady()
  2981 void CMmPhoneBookStoreTsy::ResetCacheReady()
  2987     {
  2982     {
  2988 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_RESETCACHEREADY_1, "TSY: CMmPhoneBookStoreTsy::ResetCacheReady" );
  2983 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ResetCacheReady" );
  2989     iCacheReady = EFalse;
  2984     iCacheReady = EFalse;
  2990     CMmCustomTsy* mmCustom = NULL;
  2985     CMmCustomTsy* mmCustom = NULL;
  2991 
  2986 
  2992     if( iMmPhoneTsy )
  2987     if( iMmPhoneTsy )
  2993         {
  2988         {
  2994         mmCustom = iMmPhoneTsy->GetCustomTsy();
  2989         mmCustom = iMmPhoneTsy->GetCustomTsy();
  2995         }
  2990         }
  2996 
  2991 
  2997     if ( NULL != mmCustom )
  2992     if ( NULL != mmCustom )
  2998         {
  2993         {
  2999 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_RESETCACHEREADY_2, "TSY: CMmPhoneBookStoreTsy::ResetCacheReady, mmCustom->UpdateCacheStatus - not ready" );
  2994 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ResetCacheReady, mmCustom->UpdateCacheStatus - not ready" );
  3000         mmCustom->UpdateCacheStatus( RMmCustomAPI::ECacheNotReady,
  2995         mmCustom->UpdateCacheStatus( RMmCustomAPI::ECacheNotReady,
  3001             iPhoneBookName );
  2996             iPhoneBookName );
  3002         }
  2997         }
  3003     }
  2998     }
  3004 
  2999 
  3026 //
  3021 //
  3027 void CMmPhoneBookStoreTsy::ReqCompleted(
  3022 void CMmPhoneBookStoreTsy::ReqCompleted(
  3028     const TTsyReqHandle aTsyReqHandle,
  3023     const TTsyReqHandle aTsyReqHandle,
  3029     const TInt aError )
  3024     const TInt aError )
  3030     {
  3025     {
  3031 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_REQCOMPLETED_1, "TSY: CMmPhoneBookStoreTsy::ReqCompleted - Handle:%d Error:%d", aTsyReqHandle, aError);
  3026 TFLOGSTRING3("TSY: CMmPhoneBookStoreTsy::ReqCompleted - Handle:%d Error:%d", aTsyReqHandle, aError);
  3032     CTelObject::ReqCompleted( aTsyReqHandle, aError );
  3027     CTelObject::ReqCompleted( aTsyReqHandle, aError );
  3033     }
  3028     }
  3034 
  3029 
  3035 #endif
  3030 #endif
  3036 
  3031 
  3047 //
  3042 //
  3048 void CMmPhoneBookStoreTsy::SetTypeOfResponse(
  3043 void CMmPhoneBookStoreTsy::SetTypeOfResponse(
  3049     const TInt aReqHandleType,
  3044     const TInt aReqHandleType,
  3050     const TTsyReqHandle aTsyReqHandle )
  3045     const TTsyReqHandle aTsyReqHandle )
  3051     {
  3046     {
  3052 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SETTYPEOFRESPONSE_1, "TSY: CMmPhoneBookStoreTsy::SetTypeOfResponse - Handle:%d Type:%d", aTsyReqHandle, aReqHandleType );
  3047 TFLOGSTRING3("TSY: CMmPhoneBookStoreTsy::SetTypeOfResponse - Handle:%d Type:%d", aTsyReqHandle, aReqHandleType );
  3053 
  3048 
  3054     TInt timeOut( 0 );
  3049     TInt timeOut( 0 );
  3055 
  3050 
  3056     //example switch
  3051     //example switch
  3057     switch ( aReqHandleType )
  3052     switch ( aReqHandleType )
  3146 // (other items were commented in a header).
  3141 // (other items were commented in a header).
  3147 // ---------------------------------------------------------------------------
  3142 // ---------------------------------------------------------------------------
  3148 //
  3143 //
  3149 void CMmPhoneBookStoreTsy::ContinueReadL()
  3144 void CMmPhoneBookStoreTsy::ContinueReadL()
  3150     {
  3145     {
  3151 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_CONTINUEREADL_1, "TSY: CMmPhoneBookStoreTsy::ContinueReadL ");
  3146 TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::ContinueReadL ");
  3152 
  3147 
  3153     iRequestedOnPBRead = EFalse;
  3148     iRequestedOnPBRead = EFalse;
  3154     //Reguest Read with stored parameters
  3149     //Reguest Read with stored parameters
  3155     if( iReadReqStore )
  3150     if( iReadReqStore )
  3156         {
  3151         {
  3165 // (other items were commented in a header).
  3160 // (other items were commented in a header).
  3166 // ---------------------------------------------------------------------------
  3161 // ---------------------------------------------------------------------------
  3167 //    
  3162 //    
  3168 TBool CMmPhoneBookStoreTsy::IsPBInitDone()
  3163 TBool CMmPhoneBookStoreTsy::IsPBInitDone()
  3169     {
  3164     {
  3170 OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_ISPBINITDONE_1, "TSY: CMmPhoneBookStoreTsy::IsPBInitDone: - PB %S", iPhoneBookName);
  3165 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::IsPBInitDone: - PB %S", &iPhoneBookName);
  3171 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_ISPBINITDONE_2, "TSY: CMmPhoneBookStoreTsy::IsPBInitDone: - PB iIsPBInitCompleted = %d ", iIsPBInitCompleted );
  3166 TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::IsPBInitDone: - PB iIsPBInitCompleted = %d ", iIsPBInitCompleted );
  3172     
  3167     
  3173     return iIsPBInitCompleted;
  3168     return iIsPBInitCompleted;
  3174     }
  3169     }
  3175 
  3170 
  3176 // ---------------------------------------------------------------------------
  3171 // ---------------------------------------------------------------------------
  3179 // (other items were commented in a header).
  3174 // (other items were commented in a header).
  3180 // ---------------------------------------------------------------------------
  3175 // ---------------------------------------------------------------------------
  3181 // 
  3176 // 
  3182 TUint8 CMmPhoneBookStoreTsy::GetPhonebookType()
  3177 TUint8 CMmPhoneBookStoreTsy::GetPhonebookType()
  3183  	{
  3178  	{
  3184 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_GETPHONEBOOKTYPE_1,  "TSY: CMmPhoneBookStoreTsy::GetPhonebookType - iPhoneBookType: %d", iPhoneBookType);
  3179 TFLOGSTRING2( "TSY: CMmPhoneBookStoreTsy::GetPhonebookType - iPhoneBookType: %d", iPhoneBookType);	            
  3185  	return iPhoneBookType;
  3180  	return iPhoneBookType;
  3186  	}
  3181  	}
  3187 
  3182 
  3188 // ---------------------------------------------------------------------------
  3183 // ---------------------------------------------------------------------------
  3189 // CMmPhoneBookStoreTsy::CopyLtsyCacheToCtsyCacheL
  3184 // CMmPhoneBookStoreTsy::CopyLtsyCacheToCtsyCacheL
  3271 // ---------------------------------------------------------------------------
  3266 // ---------------------------------------------------------------------------
  3272 //
  3267 //
  3273 void CMmPhoneBookStoreTsy::SimIsReady()
  3268 void CMmPhoneBookStoreTsy::SimIsReady()
  3274     {
  3269     {
  3275     
  3270     
  3276     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SIMISREADY_1, "TSY: CMmPhoneBookStoreTsy::SimIsReady - iIsPhonebookInitialized: %u", (TUint)iStoreInfoData->iIsPhonebookInitialized);
  3271     TFLOGSTRING2("TSY: CMmPhoneBookStoreTsy::SimIsReady - iIsPhonebookInitialized: %i", iStoreInfoData->iIsPhonebookInitialized);
  3277     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SIMISREADY_2, "TSY: CMmPhoneBookStoreTsy::SimIsReady - before initialization");
  3272     TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SimIsReady - before initialization");
  3278         // Check if phonebook has been initialized
  3273         // Check if phonebook has been initialized
  3279         if ( !iMmPhoneTsy->IsPBInitActive()
  3274         if ( !iMmPhoneTsy->IsPBInitActive()
  3280             && ( !iStoreInfoData->iIsPhonebookInitialized )
  3275             && ( !iStoreInfoData->iIsPhonebookInitialized )
  3281             )
  3276             )
  3282             {
  3277             {
  3283     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SIMISREADY_3, "TSY: CMmPhoneBookStoreTsy::SimIsReady - starting initialization");
  3278     TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SimIsReady - starting initialization");
  3284 
  3279 
  3285             // before phonebook requests, phonebook must be initialized
  3280             // before phonebook requests, phonebook must be initialized
  3286             iMmPhoneBookStoreExtInterface->InitPhonebook(
  3281             iMmPhoneBookStoreExtInterface->InitPhonebook(
  3287                 EMmTsyPhoneBookStoreInitIPC, iPhoneBookName );
  3282                 EMmTsyPhoneBookStoreInitIPC, iPhoneBookName );
  3288 
  3283 
  3289             iMmPhoneTsy->SetPBInitActiveStatus( ETrue );
  3284             iMmPhoneTsy->SetPBInitActiveStatus( ETrue );
  3290             }
  3285             }
  3291         else if (iMmPhoneTsy->IsPBInitActive())
  3286         else if (iMmPhoneTsy->IsPBInitActive())
  3292             {
  3287             {
  3293     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SIMISREADY_4, "TSY: CMmPhoneBookStoreTsy::SimIsReady - initialization active via other store, waiting for completion");
  3288     TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SimIsReady - initialization active via other store, waiting for completion");
  3294             iIsPBInitCompleted = EFalse;
  3289             iIsPBInitCompleted = EFalse;
  3295             }
  3290             }
  3296         else
  3291         else
  3297             {
  3292             {
  3298     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SIMISREADY_5, "TSY: CMmPhoneBookStoreTsy::SimIsReady - Initialization was done via other store");
  3293     TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SimIsReady - Initialization was done via other store");
  3299             // Set initialization flag 
  3294             // Set initialization flag 
  3300             iIsPBInitCompleted = ETrue;
  3295             iIsPBInitCompleted = ETrue;
  3301             }
  3296             }
  3302         
  3297         
  3303         if ( iStoreInfoData->iIsPhonebookInitialized
  3298         if ( iStoreInfoData->iIsPhonebookInitialized
  3304             && ( iPhoneBookType == KADNPhoneBook
  3299             && ( iPhoneBookType == KADNPhoneBook
  3305             || iPhoneBookType == KFDNPhoneBook ) )
  3300             || iPhoneBookType == KFDNPhoneBook ) )
  3306             {
  3301             {
  3307     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CMMPHONEBOOKSTORETSY_SIMISREADY_6, "TSY: CMmPhoneBookStoreTsy::SimIsReady - starting caching");
  3302     TFLOGSTRING("TSY: CMmPhoneBookStoreTsy::SimIsReady - starting caching");
  3308             // Call CacheEntries method to read entries from SIM.
  3303             // Call CacheEntries method to read entries from SIM.
  3309             CacheEntriesL();
  3304             CacheEntriesL();
  3310             }
  3305             }
  3311     }
  3306     }
  3312 
  3307