|
1 /* |
|
2 * Copyright (c) 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: CS Conversation Cache class. This shall cache |
|
15 * the conversation/messages from plugins and responds |
|
16 * to the server request |
|
17 * |
|
18 */ |
|
19 |
|
20 #ifndef __C_CS_CONVERSATION_CACHE_H |
|
21 #define __C_CS_CONVERSATION_CACHE_H |
|
22 |
|
23 // SYSTEM INCLUDE FILES |
|
24 |
|
25 //USER INCLUDES |
|
26 #include "mcscontactsmanagerobserver.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CCsConversation; |
|
30 class CCsConversationEntry; |
|
31 class CCsConversationEvent; |
|
32 class CCsClientConversation; |
|
33 class CCsServer; |
|
34 class CCsSession; |
|
35 class CCsConversationCacheHelper; |
|
36 class CCsContactsManager; |
|
37 class CCsContactDetail; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 /** |
|
41 * CS Conversation Cache main class. |
|
42 * This caches all the conversation from plugins. This is the actual cache of |
|
43 * server data. Also,Resolves contacts in phonebook and related functionality. |
|
44 */ |
|
45 class CCsConversationCache : public CBase, public MCsContactsManagerObserver |
|
46 { |
|
47 |
|
48 public: |
|
49 |
|
50 /** |
|
51 * Two phase construction |
|
52 * |
|
53 * @param aContactManager CCsContactsManager object reference |
|
54 * @param aCsServer CCsServer object refernce |
|
55 * @return instance of CCsConversationCache |
|
56 */ |
|
57 static CCsConversationCache* NewL(CCsContactsManager* aContactManager, |
|
58 CCsServer* aCsServer); |
|
59 |
|
60 /** |
|
61 * Destructor |
|
62 */ |
|
63 ~CCsConversationCache(); |
|
64 |
|
65 /** |
|
66 * GetConversationListL |
|
67 * Get Conversation list with contact details and latest conversation |
|
68 * for all stored conversations |
|
69 * This API can be used to prepare conversation list |
|
70 * |
|
71 * @param aClientConversationList list of CCsClientConversations |
|
72 */ |
|
73 void |
|
74 GetConversationListL( |
|
75 RPointerArray<CCsClientConversation>* aClientConversationList); |
|
76 |
|
77 /** |
|
78 * GetConversationsL |
|
79 * Gets the Conversation Entries of a given Client Conversation |
|
80 * |
|
81 * @param aClientConversation object of CCsClientConversation |
|
82 * for which the Converstion entries needs to be fetched |
|
83 * @param aConversationEntryList list of CCsConversationEntries |
|
84 * @param aKnownIndex - last message index of client total messages. |
|
85 * @param aPageSize - Number of messages need to be fetched. |
|
86 * @param aTotalConversationCount - Has total number of message count |
|
87 */ |
|
88 void GetConversationsL( |
|
89 const CCsClientConversation* aClientConversation, |
|
90 RPointerArray<CCsConversationEntry>* aConversationEntryList, |
|
91 TInt aKnownIndex, TInt aPageSize, |
|
92 TInt& aTotalConversationCount); |
|
93 |
|
94 /** |
|
95 * GetConversationUnreadListL |
|
96 * Get Conversation list with contact details and unread conversation |
|
97 * for all stored conversations |
|
98 * This API can be used to prepare conversation list |
|
99 * |
|
100 * @param aClientConversationList list of CCsClientConversations |
|
101 */ |
|
102 void GetConversationUnreadListL( |
|
103 RPointerArray<CCsClientConversation>* aClientConversationList); |
|
104 |
|
105 /** |
|
106 * GetConversationsL |
|
107 * Gets the Conversation Entries of a given Client Conversation |
|
108 * |
|
109 * @param aClientConversation object of CCsClientConversation |
|
110 * for which the Converstion entries needs to be fetched |
|
111 * @param aConversationEntryList list of CCsConversationEntries |
|
112 */ |
|
113 void |
|
114 GetConversationsL( |
|
115 const CCsClientConversation* aClientConversation, |
|
116 RPointerArray<CCsConversationEntry>* aConversationEntryList); |
|
117 |
|
118 /** |
|
119 * HandleConversations |
|
120 * Handle the conversation notification from plugin |
|
121 * |
|
122 * @param aConversationEntryLists array of conversation entries from pugin |
|
123 * @param aConversationEven an Unsigned number specifying the |
|
124 * event type add, update or delete |
|
125 */ |
|
126 void |
|
127 HandleConversations( |
|
128 const RPointerArray<CCsConversationEntry>& aConversationEntryLists, |
|
129 const TUint32 aConversationEvent); |
|
130 |
|
131 /** |
|
132 * Gets the total number of unread conversation entries in all the |
|
133 * Client Conversations. |
|
134 * |
|
135 * @return Total number of unread conversation entries. |
|
136 */ |
|
137 TUint32 GetTotalUnreadCount(); |
|
138 |
|
139 public: |
|
140 |
|
141 // --------------From MCsContactsManagerObserver-------------------- |
|
142 |
|
143 /** |
|
144 * HandleAddContact |
|
145 * This asynchronous callback is invoked when the new contact is added. |
|
146 */ |
|
147 void HandleAddContact(CCsContactDetail& aDetail); |
|
148 |
|
149 /** |
|
150 * HandleContactChange |
|
151 * This asynchronous callback is invoked when the contact is changed. |
|
152 */ |
|
153 void HandleContactChange(CCsContactDetail& aDetail); |
|
154 |
|
155 /** |
|
156 * HandleDeleteContact |
|
157 * This asynchronous callback is invoked when the contact is deleted. |
|
158 */ |
|
159 void HandleDeleteContact(CCsContactDetail& aDetail); |
|
160 |
|
161 // ----- public API's --------------- |
|
162 /** |
|
163 * MarkConversationAsDeleted |
|
164 * Marks a conversation as being deleted. |
|
165 * |
|
166 * @param aConversationId Conversation Id. |
|
167 * @param aDeleted ETrue if conversation is being deleted else EFalse |
|
168 * @param aCount = 0, count of messages in sending-state/not-deleted |
|
169 */ |
|
170 void MarkConversationAsDeleted(TInt aConversationId, TBool aDeleted, TInt aCount = 0); |
|
171 |
|
172 /** |
|
173 * IsDeleted |
|
174 * Check if a conversation is being deleted. |
|
175 * |
|
176 * @param aConversationId Conversation Id. |
|
177 * @return ETrue if deleted. |
|
178 */ |
|
179 TBool IsDeleted(TInt aConversationId); |
|
180 |
|
181 /** |
|
182 * ConversationList |
|
183 * Returns the internal conversation list |
|
184 * @return pointer to array of conversations |
|
185 */ |
|
186 RPointerArray<CCsConversation>* ConversationList(); |
|
187 |
|
188 /** |
|
189 * ContactsManager |
|
190 * This returns the handle of contact manager |
|
191 * @return instance of CCsContactsManager |
|
192 */ |
|
193 CCsContactsManager* ContactsManager() const; |
|
194 |
|
195 /** |
|
196 * Get conversation id for a contact id. |
|
197 * @param aContactId The contact id. |
|
198 * @return The conversation id. |
|
199 */ |
|
200 TInt GetConversationIdL(TInt aContactId); |
|
201 |
|
202 /** |
|
203 * Get conversation id for a contact address |
|
204 * @param aContactAddress contact address |
|
205 * @return The conversation id |
|
206 */ |
|
207 TInt GetConversationIdFromAddressL(TDesC& aContactAddress); |
|
208 |
|
209 CCsClientConversation* GetConversationFromConversationIdL(TInt aConversationId); |
|
210 |
|
211 /** |
|
212 * Get conversation from message-id |
|
213 * @param aMessageId Message id |
|
214 * @return CCsClientConversation The conversation |
|
215 */ |
|
216 CCsClientConversation* GetConversationFromMessageIdL(TInt aMessageId); |
|
217 |
|
218 private: |
|
219 |
|
220 /** |
|
221 * private Constructor |
|
222 * |
|
223 * @param aContactsManager instance of CCsContactsManager |
|
224 * @param aCsServer instance of CCsServer |
|
225 */ |
|
226 CCsConversationCache(CCsContactsManager* aContactsManager, |
|
227 CCsServer* aCsServer); |
|
228 |
|
229 /** |
|
230 * ConstructL |
|
231 * Second phase constructor |
|
232 */ |
|
233 void ConstructL(); |
|
234 |
|
235 private: |
|
236 |
|
237 /** |
|
238 * NotifyL |
|
239 * Sends notification to client |
|
240 * |
|
241 * @param aconversation, details of CCsClientConversation |
|
242 * @param aEvent an integer to specify the type of event |
|
243 * - add modify or delete |
|
244 */ |
|
245 void NotifyL(CCsClientConversation* aconversation, TUint32 aEvent); |
|
246 |
|
247 /** |
|
248 * CachingCompleted |
|
249 * Sends the Caching Completed Event to the server, |
|
250 * as the temp list became zero. |
|
251 */ |
|
252 void CachingCompletedL(); |
|
253 |
|
254 /** |
|
255 * FindConversation |
|
256 * Finds the conversation depending on the Contact Id |
|
257 * |
|
258 * @param aContactId given contact link Integer Id |
|
259 * @return KErrNotFound or integer where find found |
|
260 */ |
|
261 TInt FindConversation(TInt32 aContactId); |
|
262 |
|
263 /** |
|
264 * FindConversation |
|
265 * Find an associated conversation for a contact. |
|
266 * Contact specified in as a phone number |
|
267 * |
|
268 * @param aPhoneNumber phone number |
|
269 * @return KErrNotFound or integer where find found |
|
270 */ |
|
271 TInt FindConversation(TDesC& aPhoneNumber); |
|
272 |
|
273 /** |
|
274 * Redo the contact resolving for the contact at this index |
|
275 * |
|
276 * @param index from where to pick conversation for redo the resolving |
|
277 */ |
|
278 void RedoResolvingL(TInt aIndex); |
|
279 |
|
280 /** |
|
281 * CreateClientConvL |
|
282 * create CCsConversation from CCsConversation and CCsConversationEntry |
|
283 * |
|
284 * @param aConversation CCsConversation object |
|
285 * @param aConversationEntry CCsConversationEntry object |
|
286 * @return instance of CCsClientConversation |
|
287 */ |
|
288 CCsClientConversation |
|
289 * CreateClientConvLC(const CCsConversation* aConversation, |
|
290 const CCsConversationEntry* aConversationEntry); |
|
291 |
|
292 private: |
|
293 |
|
294 /** |
|
295 * iCsServer |
|
296 * Reference to server (not owned) |
|
297 */ |
|
298 CCsServer* iCsServer; |
|
299 |
|
300 /** |
|
301 * iContactsManager |
|
302 * Contact manager for contact mapping |
|
303 * Not Owned |
|
304 */ |
|
305 CCsContactsManager* iContactsManager; |
|
306 |
|
307 /** |
|
308 * iConversationList |
|
309 * Conversation Cache entry list |
|
310 * Own |
|
311 */ |
|
312 RPointerArray<CCsConversation>* iConversationList; |
|
313 |
|
314 private: |
|
315 //Friend classes |
|
316 |
|
317 friend class CCsConversationCacheHelper; |
|
318 |
|
319 /** iConversationCacheHelper |
|
320 * This shall be cache helper, an active object which process over all the |
|
321 * conversation and checks cache for add/update/delete data |
|
322 * In case of new entries, it shall be resolved by Contact Resolver class |
|
323 * |
|
324 * Own |
|
325 */ |
|
326 CCsConversationCacheHelper* iConversationCacheHelper; |
|
327 |
|
328 /** |
|
329 * The amount of digits to be used in contact matching |
|
330 */ |
|
331 TInt iMatchDigitCount; |
|
332 }; |
|
333 |
|
334 #endif // __C_CS_CONVERSATION_CACHE_H |