phonebookengines/VirtualPhonebook/VPbkSimStoreImpl/src/COwnNumberStore.cpp
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     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 own number store, contains the contacts in the MSISDN file
       
    15 *                in (U)SIM
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "COwnNumberStore.h"
       
    23 
       
    24 #include "CPhone.h"
       
    25 #include "CSingleReadCmd.h"
       
    26 #include "COwnNumberWriteCmd.h"
       
    27 #include "CDeleteCmd.h"
       
    28 #include "TVPbkSimStoreProperty.h"
       
    29 #include "CVPbkSimContact.h"
       
    30 #include "CVPbkSimCntField.h"
       
    31 #include "CVPbkSimCommandStore.h"
       
    32 #include "CSequentialCompositeCmd.h"
       
    33 
       
    34 // From VPbkSimStoreCommon
       
    35 #include <RVPbkStreamedIntArray.h>
       
    36 
       
    37 // From VPbkEng
       
    38 #include <VPbkDebug.h>
       
    39 
       
    40 namespace VPbkSimStoreImpl {
       
    41 
       
    42 // ============================ MEMBER FUNCTIONS ===============================
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // COwnNumberStore::COwnNumberStore
       
    46 // C++ default constructor can NOT contain any code, that
       
    47 // might leave.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 COwnNumberStore::COwnNumberStore( TStoreParams& aParams )
       
    51     :   CStoreBase( aParams ),
       
    52         iETelInfoPckg( iETelStoreInfo )
       
    53     {
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // COwnNumberStore::ConstructL
       
    58 // Symbian 2nd phase constructor can leave.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 void COwnNumberStore::ConstructL()
       
    62     {
       
    63     CStoreBase::ConstructL();
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // COwnNumberStore::NewL
       
    68 // Two-phased constructor.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 COwnNumberStore* COwnNumberStore::NewL( TStoreParams& aParams )
       
    72     {
       
    73     COwnNumberStore* self = new( ELeave ) COwnNumberStore( aParams );
       
    74     CleanupStack::PushL( self );
       
    75     self->ConstructL();
       
    76     CleanupStack::Pop( self );
       
    77     return self;
       
    78     }
       
    79 
       
    80     
       
    81 // Destructor
       
    82 COwnNumberStore::~COwnNumberStore()
       
    83     {
       
    84     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
    85         "VPbkSimStoreImpl: COwnNumberStore::~COwnNumberStore"));
       
    86     CancelRequests();
       
    87     iETelStore.Close();
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // COwnNumberStore::ETelName
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 const TDesC& COwnNumberStore::ETelName() const
       
    95     {
       
    96     return KETelOwnNumberStore;
       
    97     }
       
    98 
       
    99 // ----------------------------------------------------------------------------
       
   100 // COwnNumberStore::CompleteSATRefresh
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 void COwnNumberStore::CompleteSATRefresh( 
       
   104         MSimRefreshCompletion& aSimRefreshCompletion )
       
   105     {
       
   106     // It's assumed that own number store init reads only SAT defined EFs
       
   107     aSimRefreshCompletion.SatRefreshCompleted( *this, EFalse );
       
   108     }
       
   109     
       
   110 // ----------------------------------------------------------------------------
       
   111 // COwnNumberStore::SaveL
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 MVPbkSimStoreOperation* COwnNumberStore::SaveL( const TDesC8& aData, 
       
   115         TInt& aSimIndex, MVPbkSimContactObserver& aObserver )
       
   116     {
       
   117     COwnNumberWriteCmd* cmd = 
       
   118         COwnNumberWriteCmd::NewL( *this, aData, aSimIndex, aObserver );
       
   119     cmd->Execute();
       
   120     return cmd;
       
   121     }
       
   122     
       
   123 // -----------------------------------------------------------------------------
       
   124 // COwnNumberStore::DeleteL
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 MVPbkSimStoreOperation* COwnNumberStore::DeleteL( 
       
   128         RVPbkStreamedIntArray& aSimIndexes, 
       
   129         MVPbkSimContactObserver& aObserver )
       
   130     {
       
   131     CDeleteCmd* cmd = CDeleteCmd::NewL( *this, aSimIndexes, aObserver );
       
   132     cmd->Execute();
       
   133     return cmd;
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // COwnNumberStore::GetGsmStoreProperties
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 TInt COwnNumberStore::GetGsmStoreProperties( 
       
   141     TVPbkGsmStoreProperty& aGsmProperties ) const
       
   142     {
       
   143     aGsmProperties.iCaps = ConvertETelStoreCaps( iETelStoreInfo.iCaps );
       
   144     aGsmProperties.iMaxNumLength = iETelStoreInfo.iNumberLen;
       
   145     aGsmProperties.iMaxTextLength = iETelStoreInfo.iTextLen;
       
   146     aGsmProperties.iTotalEntries = iETelStoreInfo.iTotalEntries;
       
   147     aGsmProperties.iUsedEntries = iETelStoreInfo.iUsedEntries;
       
   148     return KErrNone;
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // COwnNumberStore::DestroyAllCommands
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 TInt COwnNumberStore::GetUSimStoreProperties( 
       
   156     TVPbkUSimStoreProperty& aUSimProperties ) const
       
   157     {
       
   158     aUSimProperties.iMaxAnrLength = KVPbkSimStorePropertyUndefined;
       
   159     aUSimProperties.iMaxEmailLength = KVPbkSimStorePropertyUndefined;
       
   160     aUSimProperties.iMaxGroupNameLength = KVPbkSimStorePropertyUndefined;
       
   161     aUSimProperties.iMaxNumOfAnrs = KVPbkSimStorePropertyUndefined;
       
   162     aUSimProperties.iMaxNumOfEmails = KVPbkSimStorePropertyUndefined;
       
   163     aUSimProperties.iMaxNumOfGroupNames = KVPbkSimStorePropertyUndefined;
       
   164     aUSimProperties.iMaxNumOfScndNames = KVPbkSimStorePropertyUndefined;
       
   165     aUSimProperties.iMaxScndNameLength = KVPbkSimStorePropertyUndefined;
       
   166     return KErrNone;
       
   167     }
       
   168 
       
   169 // ----------------------------------------------------------------------------
       
   170 // COwnNumberStore::ElementaryFiles
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 TUint32 COwnNumberStore::ElementaryFiles()
       
   174     {
       
   175     return KONRefresh | KONExtRefresh | KSimReset | KSimInit | 
       
   176 			KSimInitFullFileChangeNotification | KUsimApplicationReset |
       
   177 			K3GSessionReset;
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // COwnNumberStore::ETelStoreBase
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 RMobilePhoneStore& COwnNumberStore::ETelStoreBase()
       
   185     {
       
   186     return iETelStore;
       
   187     }
       
   188     
       
   189 // -----------------------------------------------------------------------------
       
   190 // COwnNumberStore::ETelStoreInfo
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 RMobilePhoneStore::TMobilePhoneStoreInfoV1& COwnNumberStore::ETelStoreInfo()
       
   194     {
       
   195     return iETelStoreInfo;
       
   196     }
       
   197     
       
   198 // -----------------------------------------------------------------------------
       
   199 // COwnNumberStore::ETelStoreInfoPackge
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 TDes8& COwnNumberStore::ETelStoreInfoPackge()
       
   203     {
       
   204     return iETelInfoPckg;
       
   205     }
       
   206     
       
   207 // -----------------------------------------------------------------------------
       
   208 // COwnNumberStore::OpenETelStoreL
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 void COwnNumberStore::OpenETelStoreL()
       
   212     {
       
   213     User::LeaveIfError( iETelStore.Open( Phone().ETelPhone() ) );
       
   214     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   215         "VPbkSimStoreImpl: RMobileONStore::Open h%d %S"),
       
   216         iETelStore.SubSessionHandle(),&ETelName());
       
   217     }
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // COwnNumberStore::CloseETelStore
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 void COwnNumberStore::CloseETelStore()
       
   224     {
       
   225     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING(
       
   226         "VPbkSimStoreImpl: RMobileONStore::Close h%d %S"),
       
   227         iETelStore.SubSessionHandle(), &ETelName());
       
   228     iETelStore.Close();
       
   229     }
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // COwnNumberStore::CreateInitCommandL
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 MVPbkSimCommand* COwnNumberStore::CreateInitCommandL( 
       
   236     MVPbkSimCommandObserver& aObserver )
       
   237     {
       
   238     // Create a init command chain
       
   239     CCompositeCmdBase* cmdChain = CSequentialCompositeCmd::NewLC();
       
   240     cmdChain->AddObserverL( aObserver );
       
   241     
       
   242     // Get phonebook information to know the current state of the phonebook
       
   243     AddGetInfoCmdToChainL( *cmdChain );
       
   244 
       
   245     // Read all contacts after info is up to date
       
   246     CSingleONReadCmd* readCmd = 
       
   247         new( ELeave ) CSingleONReadCmd( *this );
       
   248     CleanupStack::PushL( readCmd );
       
   249     cmdChain->AddSubCommandL( readCmd );
       
   250    
       
   251     CleanupStack::Pop( 2 ); // readCmd, cmdChain
       
   252     return cmdChain;
       
   253     }
       
   254 
       
   255 // -----------------------------------------------------------------------------
       
   256 // COwnNumberStore::CreateUpdateCommandL
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 MVPbkSimCommand* COwnNumberStore::CreateUpdateCommandL( TInt aSimIndex )
       
   260     {
       
   261     // Create a update command chain
       
   262     CCompositeCmdBase* cmdChain = CSequentialCompositeCmd::NewLC();
       
   263 
       
   264     // Get phonebook information to know the current state of the phonebook
       
   265     AddGetInfoCmdToChainL( *cmdChain );
       
   266     
       
   267     // Read the changed contact
       
   268     CSingleONReadCmd* readCmd = 
       
   269         new( ELeave ) CSingleONReadCmd( *this, aSimIndex );
       
   270     CleanupStack::PushL( readCmd );
       
   271     cmdChain->AddSubCommandL( readCmd );
       
   272    
       
   273     CleanupStack::Pop( 2 ); // readCmd, cmdChain
       
   274     return cmdChain;
       
   275     }
       
   276 
       
   277 // -----------------------------------------------------------------------------
       
   278 // COwnNumberStore::CreateUpdateCommandUsingRefL
       
   279 // -----------------------------------------------------------------------------
       
   280 //
       
   281 MVPbkSimCommand* COwnNumberStore::CreateUpdateCommandUsingRefL( 
       
   282         TInt& aSimIndexRef )
       
   283     {
       
   284     // Create a update command chain
       
   285     CCompositeCmdBase* cmdChain = CSequentialCompositeCmd::NewLC();
       
   286 
       
   287     // Get phonebook information to know the current state of the phonebook
       
   288     AddGetInfoCmdToChainL( *cmdChain );
       
   289     
       
   290     // Read the changed contact
       
   291     CSingleONReadCmd* readCmd = 
       
   292         new( ELeave ) CSingleONReadCmd( aSimIndexRef, *this );
       
   293     CleanupStack::PushL( readCmd );
       
   294     cmdChain->AddSubCommandL( readCmd );
       
   295    
       
   296     CleanupStack::Pop( 2 ); // readCmd, cmdChain
       
   297     return cmdChain;
       
   298     }
       
   299 } // namespace VPbkSimStoreImpl 
       
   300 //  End of File