2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Phonebook contact iterator
20 #ifndef __CPbkContactIter_H__
21 #define __CPbkContactIter_H__
24 #include <e32base.h> // CBase
25 #include <cntdb.h> // TContactIter
27 // FORWARD DECLARATIONS
28 class CPbkContactEngine;
29 class CPbkContactItem;
35 * Phonebook contact iterator. Only iterates through recognised Phonebook
36 * contact cards, not groups or templates. NextL jumps over any other contacts.
38 class CPbkContactIter : public CBase
40 public: // Constructors and destructor
42 * Creates a new instace of this class.
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.
49 IMPORT_C static CPbkContactIter* NewL
50 (CPbkContactEngine& aEngine, TBool aUseMinimalRead=EFalse);
53 * Same as NewL but leaves the created object on the cleanup stack.
54 * Creates a new instace of this class.
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.
61 IMPORT_C static CPbkContactIter* NewLC
62 (CPbkContactEngine& aEngine, TBool aUseMinimalRead=EFalse);
71 * Intializes the iterator to the first Phonebook contact.
72 * @return Id of the first Phonebook contact, KNullContactId if none found.
74 IMPORT_C TContactItemId FirstL();
77 * Advances the iterator to the next Phonebook contact.
78 * @return Id of the next Phonebook contact, KNullContactId if none found.
80 IMPORT_C TContactItemId NextL();
83 * Resets the iterator to null state.
85 IMPORT_C void Reset();
88 * Returns the current Phonebook contact, NULL if none.
89 * @return The contact item the iterator is currently pointing at.
91 IMPORT_C CPbkContactItem* CurrentL() const;
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.
99 IMPORT_C CPbkContactItem* GetCurrentL() const;
103 private: // Implementation
104 CPbkContactIter(CPbkContactEngine& aEngine, TBool aUseMinimalRead);
105 CContactItem* ReadPhonebookContactL(TContactItemId aId);
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;
121 #endif // __CPbkContactIter_H__