epoc32/include/app/cpbkcontactiter.h
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 cpbkcontactiter.h
     1 /*
       
     2 * Copyright (c) 2002 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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *    Phonebook contact iterator
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CPbkContactIter_H__
       
    21 #define __CPbkContactIter_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include    <e32base.h>     // CBase
       
    25 #include    <cntdb.h>       // TContactIter
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CPbkContactEngine;
       
    29 class CPbkContactItem;
       
    30 class CContactItem;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35  * Phonebook contact iterator. Only iterates through recognised Phonebook
       
    36  * contact cards, not groups or templates. NextL jumps over any other contacts. 
       
    37  */
       
    38 class CPbkContactIter : public CBase
       
    39 	{
       
    40     public:  // Constructors and destructor
       
    41         /**
       
    42          * Creates a new instace of this class.
       
    43          *
       
    44          * @param aEngine   Phonebook engine whose contacts to iterate.
       
    45          * @param aUseMinimalRead   Use ReadMinimalContactL instead of 
       
    46          *                          ReadContactL to read the contacts.
       
    47          * @return Contact iterator instance.
       
    48          */
       
    49         IMPORT_C static CPbkContactIter* NewL
       
    50             (CPbkContactEngine& aEngine, TBool aUseMinimalRead=EFalse);
       
    51 
       
    52         /**
       
    53          * Same as NewL but leaves the created object on the cleanup stack.
       
    54          * Creates a new instace of this class.
       
    55          *
       
    56          * @param aEngine   Phonebook engine whose contacts to iterate.
       
    57          * @param aUseMinimalRead   Use ReadMinimalContactL instead of 
       
    58          *                          ReadContactL to read the contacts.
       
    59          * @return Contact iterator instance.
       
    60          */
       
    61         IMPORT_C static CPbkContactIter* NewLC
       
    62             (CPbkContactEngine& aEngine, TBool aUseMinimalRead=EFalse);
       
    63 
       
    64 	    /**
       
    65          * Destructor.
       
    66          */
       
    67         ~CPbkContactIter();
       
    68 
       
    69     public:  // interface
       
    70         /**
       
    71          * Intializes the iterator to the first Phonebook contact.
       
    72          * @return Id of the first Phonebook contact, KNullContactId if none found.
       
    73          */
       
    74 	    IMPORT_C TContactItemId FirstL();
       
    75 
       
    76         /**
       
    77          * Advances the iterator to the next Phonebook contact.
       
    78          * @return Id of the next Phonebook contact, KNullContactId if none found.
       
    79          */
       
    80 	    IMPORT_C TContactItemId NextL();
       
    81 
       
    82         /**
       
    83          * Resets the iterator to null state.
       
    84          */
       
    85 	    IMPORT_C void Reset();
       
    86 
       
    87         /**
       
    88          * Returns the current Phonebook contact, NULL if none.
       
    89          * @return  The contact item the iterator is currently pointing at.
       
    90          */
       
    91         IMPORT_C CPbkContactItem* CurrentL() const;
       
    92 
       
    93         /**
       
    94          * Returns the current Phonebook contact, NULL if none.
       
    95          * Caller is responsible for deleting the contact, thus ownership of the
       
    96          * contact item is passed to the client.
       
    97          * @return  The contact item the iterator is currently pointing at.
       
    98          */
       
    99         IMPORT_C CPbkContactItem* GetCurrentL() const;
       
   100 
       
   101         __DECLARE_TEST;
       
   102 
       
   103     private:  // Implementation
       
   104 	    CPbkContactIter(CPbkContactEngine& aEngine, TBool aUseMinimalRead);
       
   105         CContactItem* ReadPhonebookContactL(TContactItemId aId);
       
   106 
       
   107     private:  // Data
       
   108 		/// Ref: phonebook engine
       
   109         CPbkContactEngine& iEngine;
       
   110 		/// Own: contact iterator
       
   111         TContactIter iCmIter;
       
   112 		/// Own: current item
       
   113         mutable CContactItem* iCurrentItem;
       
   114 		/// Own: current pbk-item
       
   115         mutable CPbkContactItem* iCurrentPbkItem;
       
   116 		/// Own: minimal read flag
       
   117         const TBool iUseMinimalRead;
       
   118 	};
       
   119 
       
   120 
       
   121 #endif // __CPbkContactIter_H__
       
   122 
       
   123 // End of File