|
1 /* |
|
2 * Copyright (c) 2008 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: Contact list container implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CVIMPSTSTORAGECONTACTLIST_H |
|
21 #define CVIMPSTSTORAGECONTACTLIST_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "mvimpststoragecontactlist.h" |
|
26 #include "mvimpststoragecontact.h" |
|
27 #include "tvimpstenums.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CVIMPSTStorageContactSorter; |
|
31 class MVPbkContactLink; |
|
32 class MVPbkBaseContact; |
|
33 |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * Contact list data implementation |
|
39 */ |
|
40 NONSHARABLE_CLASS( CVIMPSTStorageContactList ) : public CBase, |
|
41 public MVIMPSTStorageContactList |
|
42 { |
|
43 public: // Constructors and destructor |
|
44 |
|
45 /** |
|
46 * Two-phased constructor. |
|
47 * @param aObserver. Observer for events |
|
48 * @param aSorter. Sorter for contaclist. |
|
49 * @param aInfo. Information from storage |
|
50 * @param alistId. List id of list. Default value KNullDesC, if not set. |
|
51 * @param aDisplayname. Name of list. |
|
52 */ |
|
53 static CVIMPSTStorageContactList* NewL( CVIMPSTStorageContactSorter& aSorter, |
|
54 const TDesC& aListId, |
|
55 const TDesC& aDisplayName = KNullDesC ); |
|
56 /** |
|
57 * Two-phased constructor. |
|
58 * @param aObserver. Observer for events |
|
59 * @param aSorter. Sorter for contaclist. |
|
60 * @param aInfo. Information from storage |
|
61 * @param alistId. List id of list. |
|
62 * @param alistId. List id of list. Default value KNullDesC, if not set. |
|
63 */ |
|
64 static CVIMPSTStorageContactList* NewLC( CVIMPSTStorageContactSorter& aSorter, |
|
65 const TDesC& aListId, |
|
66 const TDesC& aDisplayName = KNullDesC ); |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 */ |
|
71 ~CVIMPSTStorageContactList(); |
|
72 |
|
73 |
|
74 public: |
|
75 |
|
76 /** |
|
77 * @see MVIMPSTStorageContactList |
|
78 */ |
|
79 const TDesC& ListId() const; |
|
80 |
|
81 /** |
|
82 * @see MVIMPSTStorageContactList |
|
83 */ |
|
84 TPtrC DisplayName() const; |
|
85 |
|
86 /** |
|
87 * @see MVIMPSTStorageContactList |
|
88 */ |
|
89 TInt Count() const; |
|
90 |
|
91 /** |
|
92 * @see MVIMPSTContactList |
|
93 */ |
|
94 MVIMPSTStorageContact& operator[]( TInt aIndex ) const; |
|
95 |
|
96 /** |
|
97 * @see MVIMPSTStorageContactList |
|
98 */ |
|
99 MVIMPSTStorageContact& FilteredContact( |
|
100 TInt aIndex, TVIMPSTEnums::TFilterType aFilter ) const; |
|
101 |
|
102 /** |
|
103 * @see MVIMPSTStorageContactList |
|
104 */ |
|
105 virtual TInt FilteredCount( |
|
106 TVIMPSTEnums::TFilterType aFilter ) const; |
|
107 |
|
108 |
|
109 /** |
|
110 * @see MVIMPSTStorageContactList |
|
111 */ |
|
112 void Sort(); |
|
113 |
|
114 /** |
|
115 * @see MVIMPSTStorageContactList |
|
116 */ |
|
117 void ResortContact( MVIMPSTStorageContact* aContact ); |
|
118 |
|
119 /** |
|
120 * @see MVIMPSTStorageContactList |
|
121 */ |
|
122 TInt FindIndexOfContact( |
|
123 const MVIMPSTStorageContact* aContact, |
|
124 TVIMPSTEnums::TFilterType aFilter = |
|
125 TVIMPSTEnums::EFilterAll ) const; |
|
126 |
|
127 /** |
|
128 * @see MVIMPSTStorageContactList |
|
129 */ |
|
130 TBool FilterAllowsContact( const MVIMPSTStorageContact* aContact, |
|
131 TVIMPSTEnums::TFilterType aFilter ) const; |
|
132 public: // New functions |
|
133 |
|
134 MVIMPSTStorageContact* FindContact( const TDesC& aContactId ); |
|
135 |
|
136 |
|
137 /** |
|
138 * Find contact by MVPbkContactLink Contact Link VPBK. |
|
139 * @param aContactLink. Contact Link to find. |
|
140 * @return Pointer to found contact. NULL if not found. |
|
141 */ |
|
142 MVIMPSTStorageContact* FindContactByContactLink( const MVPbkContactLink& aContactLink ); |
|
143 |
|
144 |
|
145 /** |
|
146 * Remove contact from list |
|
147 * @param aContactId. Id of contact to be removed. |
|
148 */ |
|
149 TInt RemoveContactFromCacheL( const TDesC& aContactId, TInt& index ); |
|
150 |
|
151 |
|
152 /** |
|
153 * Remove contact from list |
|
154 * @param aContactLink. Contact Link of the item to be removed. |
|
155 */ |
|
156 TInt RemoveContactFromCacheL( const MVPbkContactLink& aContactLink, TInt& index ); |
|
157 |
|
158 /** |
|
159 * add contact to list |
|
160 * @param aContact. Contact item to be added. |
|
161 * @param index of index |
|
162 */ |
|
163 TInt AddStorageContactToCacheL( MVIMPSTStorageContact* aContact, TInt& aIndex ); |
|
164 |
|
165 /** |
|
166 * Count of contacts in list. Skipp all ofline contacts. |
|
167 */ |
|
168 TInt ContactCount( TBool aSkipOfflineContacts, |
|
169 TBool aSkipBlocekedContacts ) const; |
|
170 |
|
171 /** |
|
172 * Count of online items in list |
|
173 * @return count of online contacts |
|
174 */ |
|
175 TInt OnlineCount() const; |
|
176 |
|
177 |
|
178 /** |
|
179 * Get online list item by index from list |
|
180 * @param aIndex. Index of online item. |
|
181 * @return Online contact in index. |
|
182 */ |
|
183 MVIMPSTStorageContact& OnlineContact( TInt aIndex ) const; |
|
184 |
|
185 |
|
186 private: // Own methods |
|
187 |
|
188 /** |
|
189 * Constructor |
|
190 */ |
|
191 CVIMPSTStorageContactList( CVIMPSTStorageContactSorter& aSorter); |
|
192 |
|
193 /** |
|
194 * Two-phased constructor |
|
195 */ |
|
196 void ConstructL( const TDesC& aListId, const TDesC& aDisplayName ); |
|
197 |
|
198 /** |
|
199 * Find Contact based on contact link |
|
200 */ |
|
201 TInt FindContactByLinkL( const MVPbkContactLink& aContactLink, |
|
202 TInt& aIndexOrderedArray ) const; |
|
203 |
|
204 /** |
|
205 * Gets the index of given aContact |
|
206 */ |
|
207 TInt FindContactEntry( const MVIMPSTStorageContact* aContact ) const; |
|
208 |
|
209 |
|
210 TInt FindContactIndex( const TDesC& aContactId, |
|
211 TInt& aOrderedIndex ) const; |
|
212 |
|
213 private: // Data |
|
214 |
|
215 /// Owns Stored contacts in contact list. |
|
216 RPointerArray< MVIMPSTStorageContact > iContactArray; |
|
217 |
|
218 /// Not owns Alphabeticaly ordered Contacts |
|
219 RPointerArray< MVIMPSTStorageContact > iOrderedContacts; |
|
220 |
|
221 /// Sorter for contacts. |
|
222 CVIMPSTStorageContactSorter& iSorter; |
|
223 |
|
224 /// Id of list |
|
225 HBufC* iListId; |
|
226 |
|
227 /// Displayname of list |
|
228 HBufC* iDisplayName; |
|
229 |
|
230 }; |
|
231 |
|
232 #endif // CVIMPSTSTORAGECONTACTLIST_H |
|
233 |
|
234 // End of File |