phonebookengines/VirtualPhonebook/VPbkSimStoreImpl/src/CUsimAdnStore.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  An USIM ADN store that supports ADN specific store information
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CUsimAdnStore.h"
       
    22 #include "CPhone.h"
       
    23 #include "CGet3GPBInfoCmd.h"
       
    24 #include "CMultipleReadCmd.h"
       
    25 #include "CSequentialCompositeCmd.h"
       
    26 #include "TVPbkSimStoreProperty.h"
       
    27 
       
    28 #include <VPbkDebug.h>
       
    29 
       
    30 namespace VPbkSimStoreImpl {
       
    31 
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CUsimAdnStore::CUsimAdnStore
       
    37 // C++ default constructor can NOT contain any code, that
       
    38 // might leave.
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CUsimAdnStore::CUsimAdnStore( TStoreParams& aParams )
       
    42 :   CCustomStore( aParams )
       
    43     {
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CUsimAdnStore::ConstructL
       
    48 // Symbian 2nd phase constructor can leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CUsimAdnStore::ConstructL()
       
    52     {
       
    53     CCustomStore::ConstructL();
       
    54     Phone().AddObserverL( *this );
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CUsimAdnStore::NewL
       
    59 // Two-phased constructor.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CUsimAdnStore* CUsimAdnStore::NewL( TStoreParams& aParams )
       
    63     {
       
    64     CUsimAdnStore* self = new( ELeave ) CUsimAdnStore( aParams );
       
    65     CleanupStack::PushL( self );
       
    66     self->ConstructL();
       
    67     CleanupStack::Pop( self );
       
    68     return self;
       
    69     }
       
    70     
       
    71 // Destructor
       
    72 CUsimAdnStore::~CUsimAdnStore()
       
    73     {
       
    74     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    75         "VPbkSimStoreImpl: CUsimAdnStore::~CUsimAdnStore"));
       
    76     CancelRequests();
       
    77     Phone().RemoveObserver(*this);
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CUsimAdnStore::ETelName
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 const TDesC& CUsimAdnStore::ETelName() const
       
    85     {
       
    86     return KETelIccAdnPhoneBook;
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CUsimAdnStore::CompleteSATRefresh
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 void CUsimAdnStore::CompleteSATRefresh( 
       
    94         MSimRefreshCompletion& aSimRefreshCompletion )
       
    95     {
       
    96     // It's assumed that USIM phonebook init read other EFs too so complete
       
    97     // with ETrue
       
    98     aSimRefreshCompletion.SatRefreshCompleted( *this, ETrue );
       
    99     }
       
   100     
       
   101 // -----------------------------------------------------------------------------
       
   102 // CUsimAdnStore::GetUSimStoreProperties
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 TInt CUsimAdnStore::GetUSimStoreProperties( 
       
   106     TVPbkUSimStoreProperty& aUSimProperties ) const
       
   107     {    
       
   108     aUSimProperties.iMaxAnrLength = i3GPBInfo.iMaxLenAnr;
       
   109     aUSimProperties.iMaxEmailLength = i3GPBInfo.iMaxLenEmail;
       
   110     aUSimProperties.iMaxGroupNameLength = i3GPBInfo.iMaxLenGroupName;
       
   111     aUSimProperties.iMaxNumOfAnrs = i3GPBInfo.iMaxNumAnr;
       
   112     aUSimProperties.iMaxNumOfEmails = i3GPBInfo.iMaxNumEmail;
       
   113     aUSimProperties.iMaxNumOfGroupNames = i3GPBInfo.iMaxNumGroupName;
       
   114     aUSimProperties.iMaxNumOfScndNames = i3GPBInfo.iMaxNumSne;
       
   115     aUSimProperties.iMaxScndNameLength = i3GPBInfo.iMaxLenSne;
       
   116     return KErrNone;
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CUsimAdnStore::CreateInitCommandL
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 MVPbkSimCommand* CUsimAdnStore::CreateInitCommandL( 
       
   124     MVPbkSimCommandObserver& aObserver )
       
   125     {
       
   126     // Create a init command chain
       
   127     CCompositeCmdBase* cmdChain = CSequentialCompositeCmd::NewLC();
       
   128     cmdChain->AddObserverL( aObserver );
       
   129     
       
   130     // Wait TSY cache first.
       
   131     AddTSYCacheReadyCmdToChainL( *cmdChain );
       
   132 
       
   133     // Get phonebook information to know the current state of the phonebook
       
   134     AddGetInfoCmdToChainL( *cmdChain );
       
   135 
       
   136     // Get 3G ADN phonebook information
       
   137     Add3GPBInfoCmdToChainL( *cmdChain );
       
   138 
       
   139     // Start reading contacts after the total amount of contacts is known
       
   140     AddMultipleReadCmdToChainL( *cmdChain, KErrNotFound, KErrNotFound );
       
   141 
       
   142     CleanupStack::Pop( cmdChain );
       
   143     return cmdChain;
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CUsimAdnStore::CreateInitCommandL
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 MVPbkSimCommand* CUsimAdnStore::CreateUpdateCommandL( TInt aSimIndex )
       
   151     {
       
   152     // Create a update command chain
       
   153     CCompositeCmdBase* cmdChain = CSequentialCompositeCmd::NewLC();
       
   154 
       
   155     // Get phonebook information
       
   156     AddGetInfoCmdToChainL( *cmdChain );
       
   157     
       
   158     // Get 3G ADN phonebook information
       
   159     Add3GPBInfoCmdToChainL( *cmdChain );
       
   160 
       
   161     // Read the changed contact
       
   162     AddMultipleReadCmdToChainL( *cmdChain, aSimIndex, aSimIndex );
       
   163     
       
   164     CleanupStack::Pop( cmdChain );
       
   165     return cmdChain;
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // CUsimAdnStore::::CreateUpdateCommandUsingRefL
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 MVPbkSimCommand* CUsimAdnStore::CreateUpdateCommandUsingRefL( 
       
   173     TInt& aSimIndexRef )
       
   174     {
       
   175     // Create a update command chain
       
   176     CCompositeCmdBase* cmdChain = CSequentialCompositeCmd::NewLC();
       
   177 
       
   178     // Read the changed contact
       
   179     cmdChain->AddSubCommandL( 
       
   180         CMultipleReadCmd::NewLC( *this, aSimIndexRef ) );
       
   181     CleanupStack::Pop(); // CMultipleReadCmd
       
   182     
       
   183     // Get phonebook information to know the current state of the phonebook
       
   184     AddGetInfoCmdToChainL( *cmdChain );
       
   185     
       
   186     // Get 3G ADN phonebook information
       
   187     Add3GPBInfoCmdToChainL( *cmdChain );
       
   188     
       
   189     CleanupStack::Pop( cmdChain );
       
   190     return cmdChain;
       
   191     }
       
   192 
       
   193 // ----------------------------------------------------------------------------
       
   194 // CUsimAdnStore::ElementaryFiles
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 TUint32 CUsimAdnStore::ElementaryFiles()
       
   198     {
       
   199     return KADNRefresh | KADNExtRefresh | KSimReset | KSimInit | 
       
   200             KSimInitFullFileChangeNotification | KUsimApplicationReset |
       
   201             K3GSessionReset;
       
   202     }
       
   203     
       
   204 // ----------------------------------------------------------------------------
       
   205 // CUsimAdnStore::PhoneOpened
       
   206 // -----------------------------------------------------------------------------
       
   207 //    
       
   208 void CUsimAdnStore::PhoneOpened( MVPbkSimPhone& /*aPhone*/ )
       
   209     {
       
   210     // Phone is already opened before store
       
   211     }
       
   212 
       
   213 // ----------------------------------------------------------------------------
       
   214 // CAdnStore::PhoneError
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void CUsimAdnStore::PhoneError( MVPbkSimPhone& /*aPhone*/, 
       
   218         TErrorIdentifier /*aIdentifier*/, TInt /*aError*/ )
       
   219     {
       
   220     // Phone is already opened before store
       
   221     }
       
   222 
       
   223 // ----------------------------------------------------------------------------
       
   224 // CUsimAdnStore::ServiceTableUpdated
       
   225 // -----------------------------------------------------------------------------
       
   226 //      
       
   227 void CUsimAdnStore::ServiceTableUpdated( TUint32 /*aServiceTable*/ )
       
   228     {
       
   229     // Not interested in service table
       
   230     }
       
   231     
       
   232 // ----------------------------------------------------------------------------
       
   233 // CUsimAdnStore::FixedDiallingStatusChanged
       
   234 // -----------------------------------------------------------------------------
       
   235 //    
       
   236 void CUsimAdnStore::FixedDiallingStatusChanged( TInt aFDNStatus )
       
   237     {
       
   238     VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING( "CUsimAdnStore::FixedDiallingStatusChanged" ) );
       
   239 
       
   240     TStoreState state = CurrentState();
       
   241 
       
   242     if ( aFDNStatus != MVPbkSimPhone::EFdnIsActive && 
       
   243          aFDNStatus != MVPbkSimPhone::EFdnIsPermanentlyActive &&
       
   244          ( state == EStoreNotOpen || state == EStoreNotAvailable ) )
       
   245         {
       
   246         if ( state == EStoreNotAvailable )
       
   247             {
       
   248             VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING( "CUsimAdnStore::FixedDiallingStatusChanged - reset store") );
       
   249             ResetStore();
       
   250             }
       
   251         
       
   252         VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING( "CUsimAdnStore::FixedDiallingStatusChanged - construct store") );
       
   253         TRAPD( res, ConstructStoreL() );
       
   254 
       
   255         if ( res != KErrNone )
       
   256             {
       
   257             SendStoreErrorEvent( res );
       
   258             }
       
   259         }
       
   260     }
       
   261 
       
   262 // -----------------------------------------------------------------------------
       
   263 // CUsimAdnStore::Add3GPBInfoCmdToChainL
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 void CUsimAdnStore::Add3GPBInfoCmdToChainL( CCompositeCmdBase& aCmdChain )
       
   267     {
       
   268     CGet3GPBInfoCmd* cmd = CGet3GPBInfoCmd::NewLC( *this );
       
   269     aCmdChain.AddSubCommandL( cmd );
       
   270     CleanupStack::Pop( cmd );
       
   271     }
       
   272 } // namespace VPbkSimStoreImpl 
       
   273 //  End of File