|
1 /* |
|
2 * Copyright (c) 2005 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 data container implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCACONTACTLIST_H |
|
21 #define CCACONTACTLIST_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "MCAContactList.h" |
|
26 #include "MCAStoredContact.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class MCAStoredContact; |
|
30 class CCAContactSorter; |
|
31 class MCAStorageInfo; |
|
32 class MCAStoredContactsObserver; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * Contact list data implementation |
|
38 * |
|
39 * @lib CAStorage.dll |
|
40 * @since 3.0 |
|
41 */ |
|
42 NONSHARABLE_CLASS( CCAContactList ) : public CBase, public MCAContactList |
|
43 { |
|
44 public: // Constructors and destructor |
|
45 |
|
46 /** |
|
47 * Two-phased constructor. |
|
48 * @param aObserver. Observer for events |
|
49 * @param aSorter. Sorter for contaclist. |
|
50 * @param aInfo. Information from storage |
|
51 * @param alistId. List id of list. Default value KNullDesC, if not set. |
|
52 * @param aDisplayname. Name of list. |
|
53 */ |
|
54 static CCAContactList* NewL( MCAStoredContactsObserver& aObserver, |
|
55 CCAContactSorter& aSorter, |
|
56 MCAStorageInfo& aInfo, |
|
57 const TDesC& aListId, |
|
58 const TDesC& aDisplayName = KNullDesC ); |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 * @param aObserver. Observer for events |
|
62 * @param aSorter. Sorter for contaclist. |
|
63 * @param aInfo. Information from storage |
|
64 * @param alistId. List id of list. |
|
65 * @param alistId. List id of list. Default value KNullDesC, if not set. |
|
66 */ |
|
67 static CCAContactList* NewLC( MCAStoredContactsObserver& aObserver, |
|
68 CCAContactSorter& aSorter, |
|
69 MCAStorageInfo& aInfo, |
|
70 const TDesC& aListId, |
|
71 const TDesC& aDisplayName = KNullDesC ); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 ~CCAContactList(); |
|
77 |
|
78 |
|
79 public: |
|
80 |
|
81 /** |
|
82 * @see MCAContactList |
|
83 */ |
|
84 const TDesC& ListId() const; |
|
85 |
|
86 /** |
|
87 * @see MCAContactList |
|
88 */ |
|
89 TPtrC DisplayName() const; |
|
90 |
|
91 /** |
|
92 * @see MCAContactList |
|
93 */ |
|
94 void SetDisplayNameL( const TDesC& aDisplayName ); |
|
95 |
|
96 /** |
|
97 * @see MCAContactList |
|
98 */ |
|
99 void SetCollapsed( TBool aCollapsed ); |
|
100 |
|
101 /** |
|
102 * @see MCAContactList |
|
103 */ |
|
104 TBool Collapsed() const; |
|
105 |
|
106 /** |
|
107 * @see MCAContactList |
|
108 */ |
|
109 TInt Count() const; |
|
110 |
|
111 /** |
|
112 * @see MCAContactList |
|
113 */ |
|
114 MCAStoredContact& operator[]( TInt aIndex ) const; |
|
115 |
|
116 /** |
|
117 * @see MCAContactList |
|
118 */ |
|
119 MCAStoredContact& FilteredContact( |
|
120 TInt aIndex, TStorageManagerGlobals::TFilterType aFilter ) const; |
|
121 |
|
122 /** |
|
123 * @see MCAContactList |
|
124 */ |
|
125 virtual TInt FilteredCount( |
|
126 TStorageManagerGlobals::TFilterType aFilter ) const; |
|
127 |
|
128 /** |
|
129 * @see MCAContactList |
|
130 */ |
|
131 TInt PendingMessages() const; |
|
132 |
|
133 /** |
|
134 * @see MCAContactList |
|
135 */ |
|
136 void Sort(); |
|
137 |
|
138 /** |
|
139 * @see MCAContactList |
|
140 */ |
|
141 void ResortContact( MCAStoredContact* aContact ); |
|
142 void ResortUnKnownContact( MCAStoredContact* aContact ); |
|
143 |
|
144 /** |
|
145 * @see MCAContactList |
|
146 */ |
|
147 TBool Selected() const; |
|
148 |
|
149 /** |
|
150 * @see MCAContactList |
|
151 */ |
|
152 void SetSelected( TBool aSelected ); |
|
153 |
|
154 /** |
|
155 * @see MCAContactList |
|
156 */ |
|
157 TInt FindIndexOfContact( |
|
158 const MCAStoredContact* aContact, |
|
159 TStorageManagerGlobals::TFilterType aFilter = |
|
160 TStorageManagerGlobals::EFilterAll ) const; |
|
161 |
|
162 /** |
|
163 * @see MCAContactList |
|
164 */ |
|
165 TBool FilterAllowsContact( const MCAStoredContact* aContact, |
|
166 TStorageManagerGlobals::TFilterType aFilter ) const; |
|
167 |
|
168 /** |
|
169 * @see MCAContactList |
|
170 */ |
|
171 void SetSynchronised( TSynchroniseState aSynchroniseState = ESynchroniseDone ); |
|
172 |
|
173 /** |
|
174 * @see MCAContactList |
|
175 */ |
|
176 TSynchroniseState Synchronised() const; |
|
177 |
|
178 public: // New functions |
|
179 |
|
180 /** |
|
181 * Set list id |
|
182 * @param aListId. New list id for list. |
|
183 */ |
|
184 void SetListIdL( const TDesC& aListId ); |
|
185 |
|
186 /** |
|
187 * Find contact by contact id. |
|
188 * @param aContactId. Id to find. |
|
189 * @return Pointer to found contact. NULL if not found. |
|
190 */ |
|
191 MCAStoredContact* FindContact( const TDesC& aContactId ); |
|
192 |
|
193 /** |
|
194 * Find contact by contact id. |
|
195 * @param aContactId. Pointer of contact to find. |
|
196 * @return Pointer to found contact. NULL if not found. |
|
197 */ |
|
198 MCAStoredContact* FindContact( const MCAStoredContact* aContact ); |
|
199 |
|
200 /** |
|
201 * Find contact by contact nickname. |
|
202 * @param aNick. Id to find. |
|
203 * @return Pointer to found contact. NULL if not found. |
|
204 */ |
|
205 MCAStoredContact* FindContactByNick( const TDesC& aNick ); |
|
206 |
|
207 /** |
|
208 * Remove contact from list |
|
209 * @param aContactId. Id of contact to be removed. |
|
210 */ |
|
211 TInt RemoveContact( const TDesC& aContactId ); |
|
212 |
|
213 /** |
|
214 * Add contact to list. |
|
215 * @param aContact. Contact to be added to list. |
|
216 * @return Pointer of added contact |
|
217 */ |
|
218 MCAStoredContact* AddContactL( MCAStoredContact* aContact ); |
|
219 |
|
220 /** |
|
221 * Count of contacts in list. Skipp all ofline contacts. |
|
222 */ |
|
223 TInt ContactCount( TBool aSkipOfflineContacts, |
|
224 TBool aSkipBlocekedContacts ) const; |
|
225 |
|
226 /** |
|
227 * Count of online items in list |
|
228 * @return count of online contacts |
|
229 */ |
|
230 TInt OnlineCount() const; |
|
231 |
|
232 /** |
|
233 * Count of non-blocked items in list |
|
234 * @return count of non-blocked contacts |
|
235 */ |
|
236 TInt NonBlockedCount() const; |
|
237 |
|
238 /** |
|
239 * Get online list item by index from list |
|
240 * @param aIndex. Index of online item. |
|
241 * @return Online contact in index. |
|
242 */ |
|
243 MCAStoredContact& OnlineContact( TInt aIndex ) const; |
|
244 |
|
245 /** |
|
246 * Get non-blocked list item by index from list |
|
247 * @param aIndex. Index of non-blocked item. |
|
248 * @return non-blocked contact in index. |
|
249 */ |
|
250 MCAStoredContact& NonBlockedContact( TInt aIndex ) const; |
|
251 |
|
252 /** |
|
253 * Set primary list properties in use. |
|
254 * @param aPrimaryInuse. If ETrue, primary in use. |
|
255 * EFalse secondary in use. |
|
256 */ |
|
257 void SetPrimaryInuse( TBool aPrimaryInUse ); |
|
258 |
|
259 private: // Own methods |
|
260 |
|
261 /** |
|
262 * Constructor |
|
263 */ |
|
264 CCAContactList( MCAStoredContactsObserver& aObserver, |
|
265 CCAContactSorter& aSorter, |
|
266 MCAStorageInfo& aInfo ); |
|
267 |
|
268 /** |
|
269 * Two-phased constructor |
|
270 */ |
|
271 void ConstructL( const TDesC& aListId, const TDesC& aDisplayName ); |
|
272 |
|
273 /** |
|
274 * Identity relation for finding contact by id. |
|
275 */ |
|
276 static TBool ContactFindById( const TDesC& aId, |
|
277 const MCAStoredContact& aContact ); |
|
278 |
|
279 /** |
|
280 * Identity relation for finding contact by nickname. |
|
281 */ |
|
282 static TBool ContactFindByNick( const TDesC& aId, |
|
283 const MCAStoredContact& aContact ); |
|
284 /** |
|
285 * |
|
286 */ |
|
287 TInt FindContactIndex( const TDesC& aContactId, |
|
288 TInt& aOrderedIndex ) const; |
|
289 |
|
290 /** |
|
291 * Gets the index of contact with the given nick |
|
292 */ |
|
293 TInt FindContactIndexByNick( const TDesC& aNick ) const; |
|
294 |
|
295 |
|
296 TInt FindContactInArray( const TDesC& aId, |
|
297 TBool ( *aCompare )( const TDesC&, const MCAStoredContact& ) ) const; |
|
298 |
|
299 TInt FindContactEntry( const MCAStoredContact* aContact ) const; |
|
300 |
|
301 TInt FindContactByUserId( const TDesC& aUserId, |
|
302 TInt& aIndexOrderedArray ) const; |
|
303 |
|
304 private: // Data |
|
305 |
|
306 /// Stored contacts in contact list. |
|
307 RPointerArray< MCAStoredContact > iContacts; |
|
308 |
|
309 /// Alphabeticaly ordered Contacts |
|
310 RPointerArray< MCAStoredContact > iOrderedContacts; |
|
311 |
|
312 /// Sorter for contacts. |
|
313 CCAContactSorter& iSorter; |
|
314 |
|
315 /// Information from storage. |
|
316 MCAStorageInfo& iInfo; |
|
317 |
|
318 /// Id of list |
|
319 HBufC* iListId; |
|
320 |
|
321 /// Displayname of list |
|
322 HBufC* iDisplayName; |
|
323 |
|
324 /// Collapsed or not. This will be primary state of list. |
|
325 TBool iPrimaryCollapsed; |
|
326 |
|
327 /// When needed secondary collapse status, this is needed. |
|
328 TBool iSecondaryCollapsed; |
|
329 |
|
330 /// This will be primary/secondary collapsed. |
|
331 TBool *iCurrentCollapsed; |
|
332 |
|
333 /// Selected or not |
|
334 TBool iSelected; |
|
335 |
|
336 /// Observer for events. |
|
337 MCAStoredContactsObserver& iObserver; |
|
338 |
|
339 /// Synchronise state |
|
340 TSynchroniseState iSyncState; |
|
341 }; |
|
342 |
|
343 |
|
344 #endif // CCACONTACTLIST_H |
|
345 |
|
346 // End of File |