phonebookengines/VirtualPhonebook/VPbkSimStoreImpl/inc/CSingleReadCmd.h
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:  A class that reads one contact at a time using ETel
       
    15 *                RMobilePhoneStore Read
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef VPBKSIMSTOREIMPL_CSINGLEREADCMD_H
       
    22 #define VPBKSIMSTOREIMPL_CSINGLEREADCMD_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <MVPbkSimCommand.h>
       
    27 #include <etelmm.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 
       
    31 namespace VPbkSimStoreImpl {
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class CStoreBase;
       
    35 
       
    36 // CLASS DECLARATION
       
    37 
       
    38 /**
       
    39 *  A class that reads one contact at a time using ETel RMobilePhoneStore Read
       
    40 *  @precond GetInfoCmd must have been run before this if all contacts are read.
       
    41 */
       
    42 template<class ETelContact>
       
    43 NONSHARABLE_CLASS(CSingleReadBase) : public CActive,
       
    44                                      public MVPbkSimCommand
       
    45     {
       
    46     public: // Functions from base classes
       
    47 
       
    48         /**
       
    49         * From MVPbkSimCommand
       
    50         */
       
    51         void Execute();
       
    52         
       
    53         /**
       
    54         * From MVPbkSimCommand
       
    55         */
       
    56         void AddObserverL( MVPbkSimCommandObserver& aObserver );
       
    57 
       
    58         /**
       
    59         * From MVPbkSimCommand
       
    60         */
       
    61         void CancelCmd();
       
    62         
       
    63     private: // Functions from base classes
       
    64         /**
       
    65         * From CActive
       
    66         */
       
    67         void RunL();
       
    68         
       
    69         /**
       
    70         * From CActive
       
    71         */
       
    72         void DoCancel();
       
    73         
       
    74         /**
       
    75         * From CActive
       
    76         */
       
    77         TInt RunError( TInt aError );
       
    78         
       
    79     protected:
       
    80 
       
    81         /**
       
    82         * C++ constructor.
       
    83         *
       
    84         * @param aStore the store to use for reading
       
    85         * @param aIndexToRead the sim index to read
       
    86         */
       
    87         CSingleReadBase( CStoreBase& aStore, TInt aIndexToRead );
       
    88 
       
    89         /**
       
    90         * C++ constructor.
       
    91         *
       
    92         * The store information is used the get the amount of sim slots 
       
    93         * in the store. All slots are read.
       
    94         * @param aStore the store to use for reading
       
    95         */
       
    96         CSingleReadBase( CStoreBase& aStore );
       
    97  
       
    98         /**
       
    99         * C++ constructor.
       
   100         *
       
   101         * This is used when the sim index is not known when creating the command
       
   102         * @param aIndexToReadRef a reference to sim index to read.
       
   103         * @param aStore the store to use for reading
       
   104         */
       
   105         CSingleReadBase( TInt& aIndexToReadRef, CStoreBase& aStore );
       
   106 
       
   107     
       
   108     private:    // New functions
       
   109         
       
   110         /// Starts reading next contact
       
   111         TBool ReadNext();
       
   112         /// Called from RunL. sub class must overwrite this to handle
       
   113         /// contact that was read
       
   114         virtual void HandleRunL() = 0;
       
   115         
       
   116     protected: // Data
       
   117         /// The ETel store that supports multiple read
       
   118         CStoreBase& iStore;
       
   119         /// The ETel contact
       
   120         ETelContact iETelContact;
       
   121         
       
   122     private:    // Data
       
   123         /// A package for the ETel contact
       
   124         TPckg<ETelContact> iETelContactPckg;
       
   125         /// The current index to read
       
   126         TInt iCurrentIndex;
       
   127         /// The amount contacts that is tried to read at once
       
   128         TInt iLastIndexToRead;
       
   129         /// a reference to the sim index
       
   130         const TInt& iSimIndexRef;
       
   131         /// Ref: only one observer supported
       
   132         MVPbkSimCommandObserver* iObserver;
       
   133     };
       
   134 
       
   135 /**
       
   136 *  A class that reads own number contacts
       
   137 *
       
   138 */
       
   139 NONSHARABLE_CLASS(CSingleONReadCmd) : 
       
   140         public CSingleReadBase<RMobileONStore::TMobileONEntryV1>
       
   141     {
       
   142     public:  // Constructors and destructor
       
   143         
       
   144         /**
       
   145         * C++ constructor.
       
   146         *
       
   147         * @param aStoreBase the parent store for the contacts
       
   148         * @param aIndexToRead the ETel index to read ( >=1 )
       
   149         */
       
   150         CSingleONReadCmd( CStoreBase& aStoreBase, TInt aIndexToRead );
       
   151 
       
   152         /**
       
   153         * C++ constructor.
       
   154         * Read all contacts.
       
   155         *
       
   156         * @param aStoreBase the parent store for the contacts
       
   157         */
       
   158         CSingleONReadCmd( CStoreBase& aStoreBase );
       
   159         
       
   160         /**
       
   161         * C++ constructor.
       
   162         * This is used when the sim index is not known when creating the command
       
   163         *
       
   164         * @param aIndexToReadRef a reference to sim index to read.
       
   165         * @param aStore the store to use for reading
       
   166         */
       
   167         CSingleONReadCmd( TInt& aIndexToReadRef, CStoreBase& aStore );
       
   168             
       
   169         /**
       
   170         * Destructor.
       
   171         */
       
   172         virtual ~CSingleONReadCmd();
       
   173 
       
   174     private: // Functions from base classes
       
   175 
       
   176         /**
       
   177         * From CSingleReadBase
       
   178         */
       
   179         void HandleRunL();
       
   180 
       
   181     private:    // New functions
       
   182         /// Adds new contact to the contact array
       
   183         void AddContactL();
       
   184     };
       
   185 } // namespace VPbkSimStoreImpl 
       
   186 #endif      // VPBKSIMSTOREIMPL_CSINGLEREADCMD_H
       
   187             
       
   188 // End of File