|
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 * GetConversationUnreadListL |
|
79 * Get Conversation list with contact details and unread conversation |
|
80 * for all stored conversations |
|
81 * This API can be used to prepare conversation list |
|
82 * |
|
83 * @param aClientConversationList list of CCsClientConversations |
|
84 */ |
|
85 void GetConversationUnreadListL( |
|
86 RPointerArray<CCsClientConversation>* aClientConversationList); |
|
87 |
|
88 /** |
|
89 * GetConversationsL |
|
90 * Gets the Conversation Entries of a given Client Conversation |
|
91 * |
|
92 * @param aClientConversation object of CCsClientConversation |
|
93 * for which the Converstion entries needs to be fetched |
|
94 * @param aConversationEntryList list of CCsConversationEntries |
|
95 */ |
|
96 void |
|
97 GetConversationsL( |
|
98 const CCsClientConversation* aClientConversation, |
|
99 RPointerArray<CCsConversationEntry>* aConversationEntryList); |
|
100 |
|
101 /** |
|
102 * HandleConversations |
|
103 * Handle the conversation notification from plugin |
|
104 * |
|
105 * @param aConversationEntryLists array of conversation entries from pugin |
|
106 * @param aConversationEven an Unsigned number specifying the |
|
107 * event type add, update or delete |
|
108 */ |
|
109 void |
|
110 HandleConversations( |
|
111 const RPointerArray<CCsConversationEntry>& aConversationEntryLists, |
|
112 const TUint32 aConversationEvent); |
|
113 |
|
114 /** |
|
115 * Gets the total number of unread conversation entries in all the |
|
116 * Client Conversations. |
|
117 * |
|
118 * @return Total number of unread conversation entries. |
|
119 */ |
|
120 TUint32 GetTotalUnreadCount(); |
|
121 |
|
122 public: |
|
123 |
|
124 // --------------From MCsContactsManagerObserver-------------------- |
|
125 |
|
126 /** |
|
127 * HandleAddContact |
|
128 * This asynchronous callback is invoked when the new contact is added. |
|
129 */ |
|
130 void HandleAddContact(CCsContactDetail& aDetail); |
|
131 |
|
132 /** |
|
133 * HandleContactChange |
|
134 * This asynchronous callback is invoked when the contact is changed. |
|
135 */ |
|
136 void HandleContactChange(CCsContactDetail& aDetail); |
|
137 |
|
138 /** |
|
139 * HandleDeleteContact |
|
140 * This asynchronous callback is invoked when the contact is deleted. |
|
141 */ |
|
142 void HandleDeleteContact(CCsContactDetail& aDetail); |
|
143 |
|
144 // ----- public API's --------------- |
|
145 /** |
|
146 * MarkConversationAsDeleted |
|
147 * Marks a conversation as being deleted. |
|
148 * |
|
149 * @param aConversationId Conversation Id. |
|
150 * @param aDeleted ETrue if conversation is being deleted else EFalse |
|
151 */ |
|
152 void MarkConversationAsDeleted(TInt aConversationId, TBool aDeleted); |
|
153 |
|
154 /** |
|
155 * IsDeleted |
|
156 * Check if a conversation is being deleted. |
|
157 * |
|
158 * @param aConversationId Conversation Id. |
|
159 * @return ETrue if deleted. |
|
160 */ |
|
161 TBool IsDeleted(TInt aConversationId); |
|
162 |
|
163 /** |
|
164 * ConversationList |
|
165 * Returns the internal conversation list |
|
166 * @return pointer to array of conversations |
|
167 */ |
|
168 RPointerArray<CCsConversation>* ConversationList(); |
|
169 |
|
170 /** |
|
171 * ContactsManager |
|
172 * This returns the handle of contact manager |
|
173 * @return instance of CCsContactsManager |
|
174 */ |
|
175 CCsContactsManager* ContactsManager() const; |
|
176 |
|
177 /** |
|
178 * Get conversation id for a contact id. |
|
179 * @param aContactId The contact id. |
|
180 * @return The conversation id. |
|
181 */ |
|
182 TInt GetConversationIdL(TInt aContactId); |
|
183 |
|
184 /** |
|
185 * Get conversation id for a contact address |
|
186 * @param aContactAddress contact address |
|
187 * @return The conversation id |
|
188 */ |
|
189 TInt GetConversationIdFromAddressL(TDesC& aContactAddress); |
|
190 |
|
191 /** |
|
192 * Get conversation from message-id |
|
193 * @param aMessageId Message id |
|
194 * @return CCsClientConversation The conversation |
|
195 */ |
|
196 CCsClientConversation* GetConversationFromMessageIdL(TInt aMessageId); |
|
197 |
|
198 private: |
|
199 |
|
200 /** |
|
201 * private Constructor |
|
202 * |
|
203 * @param aContactsManager instance of CCsContactsManager |
|
204 * @param aCsServer instance of CCsServer |
|
205 */ |
|
206 CCsConversationCache(CCsContactsManager* aContactsManager, |
|
207 CCsServer* aCsServer); |
|
208 |
|
209 /** |
|
210 * ConstructL |
|
211 * Second phase constructor |
|
212 */ |
|
213 void ConstructL(); |
|
214 |
|
215 private: |
|
216 |
|
217 /** |
|
218 * NotifyL |
|
219 * Sends notification to client |
|
220 * |
|
221 * @param aconversation, details of CCsClientConversation |
|
222 * @param aEvent an integer to specify the type of event |
|
223 * - add modify or delete |
|
224 */ |
|
225 void NotifyL(CCsClientConversation* aconversation, TUint32 aEvent); |
|
226 |
|
227 /** |
|
228 * CachingCompleted |
|
229 * Sends the Caching Completed Event to the server, |
|
230 * as the temp list became zero. |
|
231 */ |
|
232 void CachingCompletedL(); |
|
233 |
|
234 /** |
|
235 * FindConversation |
|
236 * Finds the conversation depending on the Contact Id |
|
237 * |
|
238 * @param aContactId given contact link Integer Id |
|
239 * @return KErrNotFound or integer where find found |
|
240 */ |
|
241 TInt FindConversation(TInt32 aContactId); |
|
242 |
|
243 /** |
|
244 * FindConversation |
|
245 * Find an associated conversation for a contact. |
|
246 * Contact specified in as a phone number |
|
247 * |
|
248 * @param aPhoneNumber phone number |
|
249 * @return KErrNotFound or integer where find found |
|
250 */ |
|
251 TInt FindConversation(TDesC& aPhoneNumber); |
|
252 |
|
253 /** |
|
254 * Redo the contact resolving for the contact at this index |
|
255 * |
|
256 * @param index from where to pick conversation for redo the resolving |
|
257 */ |
|
258 void RedoResolvingL(TInt aIndex); |
|
259 |
|
260 /** |
|
261 * CreateClientConvL |
|
262 * create CCsConversation from CCsConversation and CCsConversationEntry |
|
263 * |
|
264 * @param aConversation CCsConversation object |
|
265 * @param aConversationEntry CCsConversationEntry object |
|
266 * @return instance of CCsClientConversation |
|
267 */ |
|
268 CCsClientConversation |
|
269 * CreateClientConvLC(const CCsConversation* aConversation, |
|
270 const CCsConversationEntry* aConversationEntry); |
|
271 |
|
272 private: |
|
273 |
|
274 /** |
|
275 * iCsServer |
|
276 * Reference to server (not owned) |
|
277 */ |
|
278 CCsServer* iCsServer; |
|
279 |
|
280 /** |
|
281 * iContactsManager |
|
282 * Contact manager for contact mapping |
|
283 * Not Owned |
|
284 */ |
|
285 CCsContactsManager* iContactsManager; |
|
286 |
|
287 /** |
|
288 * iConversationList |
|
289 * Conversation Cache entry list |
|
290 * Own |
|
291 */ |
|
292 RPointerArray<CCsConversation>* iConversationList; |
|
293 |
|
294 private: |
|
295 //Friend classes |
|
296 |
|
297 friend class CCsConversationCacheHelper; |
|
298 |
|
299 /** iConversationCacheHelper |
|
300 * This shall be cache helper, an active object which process over all the |
|
301 * conversation and checks cache for add/update/delete data |
|
302 * In case of new entries, it shall be resolved by Contact Resolver class |
|
303 * |
|
304 * Own |
|
305 */ |
|
306 CCsConversationCacheHelper* iConversationCacheHelper; |
|
307 |
|
308 /** |
|
309 * The amount of digits to be used in contact matching |
|
310 */ |
|
311 TInt iMatchDigitCount; |
|
312 }; |
|
313 |
|
314 #endif // __C_CS_CONVERSATION_CACHE_H |