author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:32:06 +0100 | |
branch | GCC_SURGE |
changeset 47 | 5b14749788d7 |
parent 25 | 84d9eb65b26f |
parent 44 | 36f374c67aa8 |
permissions | -rw-r--r-- |
31 | 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. |
|
15 |
* This cache all the conversation from plugins |
|
16 |
* and responds to the client request |
|
17 |
* |
|
18 |
*/ |
|
19 |
||
20 |
// INCLUDE FILES |
|
21 |
||
22 |
// SYSTEM INCLUDE FILES |
|
23 |
#include <ccsclientconversation.h> |
|
24 |
#include <ccsconversationentry.h> |
|
25 |
#include <ccsdefs.h> |
|
26 |
#include <telconfigcrkeys.h> // KCRUidTelephonyConfiguration |
|
27 |
#include <centralrepository.h> |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
28 |
#include <xqconversions.h> |
31 | 29 |
// USER INCLUDE FILES |
30 |
#include "ccsconversationcache.h" |
|
31 |
#include "ccsconversationcachehelper.h" |
|
32 |
#include "ccsconversationcontact.h" |
|
33 |
#include "ccsconversation.h" |
|
34 |
#include "ccscontactsmanager.h" |
|
35 |
#include "ccscontactsresolver.h" |
|
36 |
#include "ccsconversationevent.h" |
|
37 |
#include "ccsserver.h" |
|
38 |
#include "ccsdebug.h" |
|
39 |
||
40 |
// ============================== MEMBER FUNCTIONS ============================ |
|
41 |
||
42 |
// ---------------------------------------------------------------------------- |
|
43 |
// CCsConversationCache::NewL |
|
44 |
// Two Phase Construction |
|
45 |
// ---------------------------------------------------------------------------- |
|
46 |
CCsConversationCache* |
|
47 |
CCsConversationCache::NewL(CCsContactsManager* aContactManager, |
|
48 |
CCsServer* aCsServer) |
|
49 |
{ |
|
50 |
PRINT ( _L("Enter CCsConversationCache::NewL") ); |
|
51 |
||
52 |
CCsConversationCache* self = |
|
53 |
new (ELeave) CCsConversationCache(aContactManager, aCsServer); |
|
54 |
CleanupStack::PushL(self); |
|
55 |
self->ConstructL(); |
|
56 |
CleanupStack::Pop(self); |
|
57 |
||
58 |
PRINT ( _L("End CCsConversationCache::NewL") ); |
|
59 |
||
60 |
return self; |
|
61 |
} |
|
62 |
||
63 |
// ---------------------------------------------------------------------------- |
|
64 |
// CCsConversationCache::CCsConversationCache |
|
65 |
// Construtor |
|
66 |
// ---------------------------------------------------------------------------- |
|
67 |
CCsConversationCache::CCsConversationCache(CCsContactsManager* aContactManager, |
|
68 |
CCsServer* aCsServer) : |
|
69 |
iCsServer(aCsServer), iContactsManager(aContactManager) |
|
70 |
{ |
|
71 |
} |
|
72 |
||
73 |
// ---------------------------------------------------------------------------- |
|
74 |
// CCsConversationCache::ConstructL |
|
75 |
// Second phase constructor |
|
76 |
// ---------------------------------------------------------------------------- |
|
77 |
void CCsConversationCache::ConstructL() |
|
78 |
{ |
|
79 |
PRINT ( _L("Enter CCsConversationCache::ConstructL") ); |
|
80 |
||
81 |
// Register for events from contact manager |
|
82 |
iContactsManager->addObserver(this); |
|
83 |
||
84 |
// initialize the main cache entries |
|
85 |
iConversationList = new (ELeave) RPointerArray<CCsConversation> (); |
|
86 |
||
87 |
// initialize the class helper class |
|
88 |
iConversationCacheHelper = CCsConversationCacheHelper::NewL(this); |
|
89 |
||
90 |
iMatchDigitCount = KDefaultGsmNumberMatchLength; |
|
91 |
||
92 |
// Read the amount of digits to be used in contact matching |
|
93 |
// The key is owned by PhoneApp |
|
94 |
CRepository* repository = CRepository::NewLC(KCRUidTelConfiguration); |
|
95 |
if (repository->Get(KTelMatchDigits, iMatchDigitCount) == KErrNone) |
|
96 |
{ |
|
97 |
// Min is 7 |
|
98 |
iMatchDigitCount = Max(iMatchDigitCount, KDefaultGsmNumberMatchLength); |
|
99 |
} |
|
100 |
CleanupStack::PopAndDestroy(); // repository |
|
101 |
||
102 |
PRINT ( _L("End CCsConversationCache::ConstructL") ); |
|
103 |
} |
|
104 |
||
105 |
// ---------------------------------------------------------------------------- |
|
106 |
// CCsConversationCache::CCsConversationCache |
|
107 |
// Destructor |
|
108 |
// ---------------------------------------------------------------------------- |
|
109 |
CCsConversationCache::~CCsConversationCache() |
|
110 |
{ |
|
111 |
PRINT ( _L("Enter CCsConversationCache::~CCsConversationCache") ); |
|
112 |
||
113 |
if (iContactsManager) |
|
114 |
{ |
|
115 |
iContactsManager->removeObserver(this); |
|
116 |
} |
|
117 |
||
118 |
// delete the set of all conversations |
|
119 |
if (iConversationList) |
|
120 |
{ |
|
121 |
iConversationList->ResetAndDestroy(); |
|
122 |
iConversationList->Close(); |
|
123 |
delete iConversationList; |
|
124 |
iConversationList = NULL; |
|
125 |
} |
|
126 |
||
127 |
if (iConversationCacheHelper) |
|
128 |
{ |
|
129 |
delete iConversationCacheHelper; |
|
130 |
iConversationCacheHelper = NULL; |
|
131 |
} |
|
132 |
||
133 |
PRINT ( _L("End CCsConversationCache::~CCsConversationCache") ); |
|
134 |
} |
|
135 |
||
136 |
// ---------------------------------------------------------------------------- |
|
137 |
// CCsConversationCache::GetConversationListL |
|
138 |
// Get Conversation list with contact details |
|
139 |
// for all stored conversations |
|
140 |
// This API can be used to prepare conversation list |
|
141 |
// ---------------------------------------------------------------------------- |
|
142 |
void CCsConversationCache::GetConversationListL(RPointerArray< |
|
143 |
CCsClientConversation>* aClientConversationList) |
|
144 |
{ |
|
145 |
TInt totalConversation = iConversationList->Count(); |
|
146 |
||
147 |
// Write the contact display names |
|
148 |
for (TInt loop = 0; loop < totalConversation; loop++) |
|
149 |
{ |
|
150 |
CCsConversation* conversation = |
|
151 |
static_cast<CCsConversation*> ( (*iConversationList)[loop]); |
|
152 |
||
153 |
// The check is needed to avoid crash while internalizing resulting |
|
154 |
// from the row added for unknown drafts |
|
155 |
if (conversation->GetEntryCount()) |
|
156 |
{ |
|
157 |
CCsClientConversation* clientConversation = |
|
158 |
CreateClientConvLC(conversation, |
|
159 |
conversation->GetLatestEntryL()); |
|
160 |
aClientConversationList->Append(clientConversation); |
|
161 |
CleanupStack::Pop(); |
|
162 |
} |
|
163 |
} |
|
164 |
||
165 |
PRINT1 ( _L("CCsConversationCache::GetConversationEntryListL - conversationCount:%d"), |
|
166 |
totalConversation ); |
|
167 |
} |
|
168 |
||
169 |
// ---------------------------------------------------------------------------- |
|
170 |
// CCsConversationCache::GetConversationUnreadListL |
|
171 |
// Get Conversation list with contact details and unread conversation |
|
172 |
// for all stored conversations |
|
173 |
// This API can be used to prepare conversation list |
|
174 |
// ---------------------------------------------------------------------------- |
|
175 |
void CCsConversationCache::GetConversationUnreadListL(RPointerArray< |
|
176 |
CCsClientConversation>* aClientConversationList) |
|
177 |
{ |
|
178 |
TInt conversationCount = iConversationList->Count(); |
|
179 |
||
180 |
// Write the contact display names |
|
181 |
for (TInt loop = 0; loop < conversationCount; loop++) |
|
182 |
{ |
|
183 |
CCsConversation* conversation = |
|
184 |
static_cast<CCsConversation*> ((*iConversationList)[loop]); |
|
185 |
||
186 |
// The check is needed to avoid crash while internalizing resulting |
|
187 |
// from the row added for unknown drafts |
|
188 |
if (conversation->GetEntryCount() && conversation->GetUnreadMessageCount()) |
|
189 |
{ |
|
190 |
CCsClientConversation* clientConversation = CreateClientConvLC( |
|
191 |
conversation, conversation->GetLatestUnreadEntryL()); |
|
192 |
aClientConversationList->Append(clientConversation); |
|
193 |
CleanupStack::Pop(); |
|
194 |
} |
|
195 |
} |
|
196 |
||
197 |
PRINT1 ( _L("CCsConversationCache::GetConversationUnreadListL - conversationCount:%d"), |
|
198 |
conversationCount ); |
|
199 |
} |
|
200 |
||
201 |
// ---------------------------------------------------------------------------- |
|
202 |
// CCsConversationCache::GetConversationsL |
|
203 |
// Get All Conversations for a given conversation Id |
|
204 |
// the return list is set inside aConversationEntryList |
|
205 |
// ---------------------------------------------------------------------------- |
|
206 |
void CCsConversationCache::GetConversationsL( |
|
207 |
const CCsClientConversation* aClientConversation, |
|
208 |
RPointerArray<CCsConversationEntry>* aConversationEntryList) |
|
209 |
{ |
|
210 |
TInt totalConversation = iConversationList->Count(); |
|
211 |
||
212 |
// Get the entry id from Client Conversation for which conversations are required |
|
213 |
TCsConversationEntryID conversationEntryID = |
|
214 |
aClientConversation->GetConversationEntryId(); |
|
215 |
||
216 |
// Write the contact display names |
|
217 |
for (TInt loop = 0; loop < totalConversation; loop++) |
|
218 |
{ |
|
219 |
//match entry ID; |
|
220 |
CCsConversation* conversation = |
|
221 |
static_cast<CCsConversation*> ( (*iConversationList)[loop]); |
|
222 |
||
223 |
if (conversationEntryID == conversation->GetConversationId()) |
|
224 |
{ |
|
225 |
// search the conversation id and get the list inside |
|
226 |
conversation->GetEntryListL(aConversationEntryList); |
|
227 |
break; |
|
228 |
} |
|
229 |
} |
|
230 |
PRINT1 ( _L("CCsConversationCache::GetConversationsL - conversationCount:%d"), |
|
231 |
totalConversation ); |
|
232 |
} |
|
233 |
||
234 |
// ---------------------------------------------------------------------------- |
|
235 |
// CCsConversationCache::HandleConversations |
|
236 |
// Called from server. This is to handle the event callback from plugin dll |
|
237 |
// The idea is to add entries to the cache and at the same time update the clients |
|
238 |
// ---------------------------------------------------------------------------- |
|
239 |
void CCsConversationCache::HandleConversations(const RPointerArray< |
|
240 |
CCsConversationEntry>& aConversationEntryLists, |
|
241 |
const TUint32 aConversationEvent) |
|
242 |
{ |
|
243 |
// get count |
|
244 |
TInt count = aConversationEntryLists.Count(); |
|
245 |
||
246 |
// go through each conversation entry |
|
247 |
// add it into queue, event list |
|
248 |
for (TInt loop = 0; loop < count; loop++) |
|
249 |
{ |
|
250 |
//get copy of conversation event |
|
251 |
TInt error; |
|
252 |
CCsConversationEvent* conEvent = NULL; |
|
253 |
CCsClientConversation* clientCon = NULL; |
|
254 |
CCsConversationEntry* conEntry = aConversationEntryLists[loop]; |
|
255 |
||
256 |
if (aConversationEntryLists[loop]) |
|
257 |
{ |
|
258 |
TRAP( |
|
259 |
error, |
|
260 |
conEvent = CCsConversationEvent::NewL(); |
|
261 |
CleanupStack::PushL(conEvent); |
|
262 |
//create clientconversation |
|
263 |
clientCon = CCsClientConversation::NewL(); |
|
264 |
CleanupStack::PushL(clientCon); |
|
265 |
clientCon->SetConversationEntryL(conEntry); |
|
266 |
//set conversation entry |
|
267 |
conEvent->SetClientConversationL(*clientCon); |
|
268 |
//set event |
|
269 |
conEvent->SetEvent(aConversationEvent); |
|
270 |
//add entry |
|
271 |
iConversationCacheHelper->ConversationEventList()->AppendL(conEvent); |
|
272 |
CleanupStack::PopAndDestroy(clientCon); |
|
273 |
CleanupStack::Pop(conEvent)); |
|
274 |
||
275 |
if (error != KErrNone) |
|
276 |
{ |
|
277 |
PRINT1 ( _L("CCsConversationCache::HandleConversation - Error:%d"), |
|
278 |
error ); |
|
279 |
continue; |
|
280 |
} |
|
281 |
} |
|
282 |
} |
|
283 |
iConversationCacheHelper->StartCacheUpdate(); |
|
284 |
} |
|
285 |
||
286 |
// ---------------------------------------------------------------------------- |
|
287 |
// CCsConversationCache::GetTotalUnreadCount |
|
288 |
// Pending event count |
|
289 |
// ---------------------------------------------------------------------------- |
|
290 |
TUint32 CCsConversationCache::GetTotalUnreadCount() |
|
291 |
{ |
|
292 |
TUint32 totalUnread = 0; |
|
293 |
||
294 |
for (TInt loop = 0; loop < iConversationList->Count(); ++loop) |
|
295 |
{ |
|
296 |
CCsConversation* conversation = |
|
297 |
static_cast<CCsConversation*> ((*iConversationList)[loop]); |
|
298 |
totalUnread += conversation->GetUnreadMessageCount(); |
|
299 |
} |
|
300 |
return totalUnread; |
|
301 |
} |
|
302 |
||
303 |
// ---------------------------------------------------------------------------- |
|
304 |
// CCsConversationCache::NotifyL |
|
305 |
// Send the notification client |
|
306 |
// ---------------------------------------------------------------------------- |
|
307 |
void CCsConversationCache::NotifyL(CCsClientConversation* aConversation, |
|
308 |
TUint32 aEvent) |
|
309 |
{ |
|
310 |
iCsServer->NotifySessions(aConversation, aEvent); |
|
311 |
} |
|
312 |
||
313 |
// ---------------------------------------------------------------------------- |
|
314 |
// CCsConversationCache::CachingCompletedL |
|
315 |
// This is called from cache helper after it resolves all events from plugin |
|
316 |
// ---------------------------------------------------------------------------- |
|
317 |
void CCsConversationCache::CachingCompletedL() |
|
318 |
{ |
|
319 |
// Not supported |
|
320 |
} |
|
321 |
||
322 |
// ---------------------------------------------------------------------------- |
|
323 |
// CCsConversationCache::FindConversation |
|
324 |
// Find a conversation based on contact Id |
|
325 |
// ---------------------------------------------------------------------------- |
|
326 |
TInt CCsConversationCache::FindConversation(TInt32 aContactId) |
|
327 |
{ |
|
328 |
if (aContactId == KErrNotFound) |
|
329 |
return KErrNotFound; |
|
330 |
||
331 |
TInt totalConversations = iConversationList->Count(); |
|
332 |
||
333 |
for (TInt index = 0; index < totalConversations; index++) |
|
334 |
{ |
|
335 |
CCsConversation* conversation = |
|
336 |
static_cast<CCsConversation*> ( (*iConversationList)[index]); |
|
337 |
||
338 |
CCsConversationContact* inCache = conversation->GetContact(); |
|
339 |
||
340 |
TInt32 idInCache = inCache->GetContactId(); |
|
341 |
||
342 |
if (idInCache == KErrNotFound) |
|
343 |
continue; |
|
344 |
||
345 |
if (idInCache == aContactId) |
|
346 |
{ |
|
347 |
return index; |
|
348 |
} |
|
349 |
} |
|
350 |
return KErrNotFound; |
|
351 |
} |
|
352 |
||
353 |
// ---------------------------------------------------------------------------- |
|
354 |
// CCsConversationCache::FindConversation |
|
355 |
// Find a conversation based on phone number |
|
356 |
// ---------------------------------------------------------------------------- |
|
357 |
TInt CCsConversationCache::FindConversation(TDesC& aPhoneNumber) |
|
358 |
{ |
|
359 |
TInt count = iConversationList->Count(); |
|
360 |
||
361 |
for (TInt cIndex = 0; cIndex < count; cIndex++) |
|
362 |
{ |
|
363 |
CCsConversation* conversation = |
|
364 |
static_cast<CCsConversation*> ( (*iConversationList)[cIndex]); |
|
365 |
||
366 |
CCsConversationContact* inCache = conversation->GetContact(); |
|
367 |
||
368 |
if (inCache->MatchPhoneNumber(aPhoneNumber, iMatchDigitCount)) |
|
369 |
{ |
|
370 |
return cIndex; |
|
371 |
} |
|
372 |
} |
|
373 |
return KErrNotFound; |
|
374 |
} |
|
375 |
||
376 |
// ---------------------------------------------------------------------------- |
|
377 |
// CCsConversationCache::RedoResolvingL |
|
378 |
// Redo contact resolving for the conversation at this index |
|
379 |
// ---------------------------------------------------------------------------- |
|
380 |
void CCsConversationCache::RedoResolvingL(TInt aIndex) |
|
381 |
{ |
|
382 |
// Recover the associated conversation object |
|
383 |
CCsConversation* conversation = |
|
384 |
static_cast<CCsConversation*> ( (*iConversationList)[aIndex]); |
|
385 |
||
386 |
// Get the conversation entries |
|
387 |
RPointerArray<CCsConversationEntry> entryList; |
|
388 |
conversation->GetEntryListL(&entryList); |
|
389 |
||
390 |
// Handle as if they are new conversations |
|
391 |
HandleConversations(entryList, KConversationEventNew); |
|
392 |
||
393 |
// Send a notification for delete conversation |
|
394 |
CCsConversationEntry* convEntry = conversation->GetLatestEntryL(); |
|
395 |
||
396 |
if (iConversationCacheHelper->IsNotifyRequiredL(conversation, |
|
397 |
convEntry, |
|
398 |
KConversationListEventDelete, |
|
399 |
conversation->GetUnreadMessageCount())) |
|
400 |
{ |
|
401 |
//clone conversation and send update to client |
|
402 |
CCsClientConversation* clientConv = CreateClientConvLC(conversation, |
|
403 |
convEntry); |
|
404 |
NotifyL(clientConv, KConversationListEventDelete); |
|
405 |
CleanupStack::PopAndDestroy(clientConv); |
|
406 |
} |
|
407 |
||
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
408 |
// send all CV entry delete events, required in case CV is open |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
409 |
// Notify client of conversation change |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
410 |
TInt totalEntryCount = conversation->GetEntryCount(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
411 |
for (TInt entryCounter = totalEntryCount - 1; entryCounter >= 0; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
412 |
entryCounter--) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
413 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
414 |
CCsConversationEntry* entryInConversation = |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
415 |
conversation->GetEntryL(entryCounter); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
416 |
CCsClientConversation * clientConv = |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
417 |
CreateClientConvLC(conversation, entryInConversation); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
418 |
NotifyL(clientConv, KConversationEventDelete); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
419 |
CleanupStack::PopAndDestroy(clientConv); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
420 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
421 |
|
31 | 422 |
iConversationList->Remove(aIndex); |
423 |
entryList.ResetAndDestroy(); |
|
424 |
||
425 |
delete conversation; |
|
426 |
} |
|
427 |
||
428 |
// ---------------------------------------------------------------------------- |
|
429 |
// CCsConversationCache::CreateClientConvLC |
|
430 |
// create CCsConversation from CCsConversation and CCsConversationEntry |
|
431 |
// ---------------------------------------------------------------------------- |
|
432 |
CCsClientConversation* CCsConversationCache::CreateClientConvLC( |
|
433 |
const CCsConversation* aConversation, |
|
434 |
const CCsConversationEntry* aConversationEntry) |
|
435 |
{ |
|
436 |
//create clientconversation |
|
437 |
CCsClientConversation* clientConversation = CCsClientConversation::NewL(); |
|
438 |
CleanupStack::PushL(clientConversation); |
|
439 |
||
440 |
clientConversation->SetDisplayNameL(aConversation->GetDisplayName()); |
|
441 |
clientConversation->SetConversationEntryId(aConversation->GetConversationId()); |
|
442 |
clientConversation->SetConversationEntryL(aConversationEntry); |
|
443 |
clientConversation->SetContactId(aConversation->GetContactId()); |
|
444 |
clientConversation->SetUnreadMessageCount(aConversation->GetUnreadMessageCount()); |
|
445 |
||
446 |
return clientConversation; |
|
447 |
} |
|
448 |
||
449 |
// ---------------------------------------------------------------------------- |
|
450 |
// CCsConversationCache::MarkConversationAsDeleted |
|
451 |
// ---------------------------------------------------------------------------- |
|
452 |
void CCsConversationCache::MarkConversationAsDeleted(TInt aConversationId, |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
453 |
TBool aDeleted, TInt aCount) |
31 | 454 |
{ |
455 |
TInt conversationCount = iConversationList->Count(); |
|
456 |
||
457 |
for (TInt loop = 0; loop < conversationCount; loop++) |
|
458 |
{ |
|
459 |
CCsConversation* conversation = |
|
460 |
static_cast<CCsConversation*> ( (*iConversationList)[loop]); |
|
461 |
TInt id = conversation->GetConversationId(); |
|
462 |
||
463 |
if (id == aConversationId) |
|
464 |
{ |
|
465 |
conversation->MarkDeleted(aDeleted); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
466 |
if( aCount ) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
467 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
468 |
CCsClientConversation* clientConversation = |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
469 |
CreateClientConvLC(conversation, |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
470 |
conversation->GetLatestEntryL()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
471 |
NotifyL(clientConversation, KConversationListEventPartialDelete); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
472 |
CleanupStack::PopAndDestroy();// clientConversation |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
473 |
} |
31 | 474 |
break; |
475 |
} |
|
476 |
} |
|
477 |
} |
|
478 |
||
479 |
// ---------------------------------------------------------------------------- |
|
480 |
// CCsConversationCache::IsDeleted |
|
481 |
// ---------------------------------------------------------------------------- |
|
482 |
TBool CCsConversationCache::IsDeleted(TInt aConversationId) |
|
483 |
{ |
|
484 |
TInt conversationCount = iConversationList->Count(); |
|
485 |
||
486 |
for (TInt loop = 0; loop < conversationCount; loop++) |
|
487 |
{ |
|
488 |
CCsConversation* conversation = |
|
489 |
static_cast<CCsConversation*> ( (*iConversationList)[loop]); |
|
490 |
TInt id = conversation->GetConversationId(); |
|
491 |
||
492 |
if (id == aConversationId) |
|
493 |
{ |
|
494 |
return conversation->IsDeleted(); |
|
495 |
} |
|
496 |
} |
|
497 |
return EFalse; |
|
498 |
} |
|
499 |
||
500 |
// ---------------------------------------------------------------------------- |
|
501 |
// CCsConversationCache::ConversationList |
|
502 |
// Pls refer to .h file |
|
503 |
// ---------------------------------------------------------------------------- |
|
504 |
RPointerArray<CCsConversation>* |
|
505 |
CCsConversationCache::ConversationList() |
|
506 |
{ |
|
507 |
return iConversationList; |
|
508 |
} |
|
509 |
||
510 |
// ---------------------------------------------------------------------------- |
|
511 |
// CCsConversationCache::getContactsManager |
|
512 |
// Pls refer to .h file |
|
513 |
// ---------------------------------------------------------------------------- |
|
514 |
CCsContactsManager* |
|
515 |
CCsConversationCache::ContactsManager() const |
|
516 |
{ |
|
517 |
return iContactsManager; |
|
518 |
} |
|
519 |
// ---------------------------------------------------------------------------- |
|
520 |
// CCsConversationCache::HandleAddContact |
|
521 |
// Pls refer to .h file |
|
522 |
// ---------------------------------------------------------------------------- |
|
523 |
void CCsConversationCache::HandleAddContact(CCsContactDetail& aDetail) |
|
524 |
{ |
|
525 |
//handle addition of new contact |
|
526 |
||
527 |
QStringList phoneNumberList = aDetail.addressList; |
|
528 |
TInt totalPhoneNumber = phoneNumberList.count(); |
|
529 |
||
530 |
// Get the conversation indexes for the phone numbers |
|
531 |
RArray<TInt> conversationIndex; |
|
532 |
||
533 |
for (int i = 0; i < totalPhoneNumber; i++) |
|
534 |
{ |
|
535 |
QString phoneNumber = phoneNumberList.at(i); |
|
536 |
HBufC* phoneNumber_s60 = |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
537 |
XQConversions::qStringToS60Desc(phoneNumber); |
31 | 538 |
TInt cIndex = FindConversation(*phoneNumber_s60); |
539 |
if (cIndex != KErrNotFound) |
|
540 |
{ |
|
541 |
if (conversationIndex.Find(cIndex) == KErrNotFound) |
|
542 |
{ |
|
543 |
conversationIndex.Append(cIndex); |
|
544 |
} |
|
545 |
} |
|
546 |
delete phoneNumber_s60; |
|
547 |
} |
|
548 |
||
549 |
// Sort the conversationIndex |
|
550 |
conversationIndex.Sort(); |
|
551 |
||
552 |
// Redo contact resolving for the affected conversations |
|
553 |
for ( TInt i = conversationIndex.Count() - 1; i >= 0 ; i-- ) |
|
554 |
{ |
|
555 |
RedoResolvingL(conversationIndex[i]); |
|
556 |
} |
|
557 |
||
558 |
conversationIndex.Reset(); |
|
559 |
} |
|
560 |
||
561 |
// ---------------------------------------------------------------------------- |
|
562 |
// CCsConversationCache::HandleContactChange |
|
563 |
// Pls refer to .h file |
|
564 |
// ---------------------------------------------------------------------------- |
|
565 |
void CCsConversationCache::HandleContactChange(CCsContactDetail& aDetail) |
|
566 |
{ |
|
567 |
//handle contact change |
|
568 |
QStringList phoneNumberList = aDetail.addressList; |
|
569 |
int countNumberList = phoneNumberList.count(); |
|
570 |
||
571 |
// Get the conversation indexes for the phone numbers |
|
572 |
RArray<TInt> conversationIndex; |
|
573 |
for (int i=0; i < countNumberList ; i++) |
|
574 |
{ |
|
575 |
QString phoneNumber = phoneNumberList.at(i); |
|
576 |
HBufC* phoneNumber_s60 = |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
577 |
XQConversions::qStringToS60Desc(phoneNumber); |
31 | 578 |
|
579 |
TInt cIndex = FindConversation(*phoneNumber_s60); |
|
580 |
if ( cIndex != KErrNotFound ) |
|
581 |
{ |
|
582 |
conversationIndex.InsertInOrder(cIndex); |
|
583 |
} |
|
584 |
delete phoneNumber_s60; |
|
585 |
} |
|
586 |
||
587 |
// Get the conversation index corresponding to the contact Id |
|
588 |
TInt linkIdIndex = FindConversation(aDetail.contactId); |
|
589 |
if (linkIdIndex != KErrNotFound) |
|
590 |
{ |
|
591 |
conversationIndex.InsertInOrder(linkIdIndex); |
|
592 |
} |
|
593 |
||
594 |
// Redo contact resolving for the affected conversations |
|
595 |
for ( TInt i = conversationIndex.Count() - 1; i >= 0 ; i-- ) |
|
596 |
{ |
|
597 |
RedoResolvingL(conversationIndex[i]); |
|
598 |
} |
|
599 |
||
600 |
conversationIndex.Reset(); |
|
601 |
} |
|
602 |
||
603 |
// ---------------------------------------------------------------------------- |
|
604 |
// CCsConversationCache::HandleDeleteContact |
|
605 |
// Pls refer to .h file |
|
606 |
// ---------------------------------------------------------------------------- |
|
607 |
void CCsConversationCache::HandleDeleteContact(CCsContactDetail& aDetail) |
|
608 |
{ |
|
609 |
//handle if contact is deleted |
|
610 |
TInt cIndex = FindConversation(aDetail.contactId); |
|
611 |
if (cIndex == KErrNotFound) |
|
612 |
{ |
|
613 |
// No need to handle this change |
|
614 |
return; |
|
615 |
} |
|
616 |
||
617 |
// Redo resolving for the affected conversation |
|
618 |
RedoResolvingL(cIndex); |
|
619 |
} |
|
620 |
||
621 |
// ---------------------------------------------------------------------------- |
|
622 |
// CCsConversationCache::GetConversationIdL |
|
623 |
// ---------------------------------------------------------------------------- |
|
624 |
TInt CCsConversationCache::GetConversationIdL(TInt aContactId) |
|
625 |
{ |
|
626 |
TInt conversationCount = iConversationList->Count(); |
|
627 |
||
628 |
for ( TInt loop= 0; loop < conversationCount; loop++ ) |
|
629 |
{ |
|
630 |
CCsConversation* conversation = |
|
631 |
static_cast<CCsConversation*>((*iConversationList)[loop]); |
|
632 |
TInt contactId = conversation->GetContactId(); |
|
633 |
||
634 |
if ( contactId == aContactId ) |
|
635 |
{ |
|
636 |
return conversation->GetConversationId(); |
|
637 |
} |
|
638 |
} |
|
639 |
||
640 |
return -1; |
|
641 |
} |
|
642 |
||
643 |
// ---------------------------------------------------------------------------- |
|
644 |
// CCsConversationCache::GetConversationIdFromAddressL |
|
645 |
// ---------------------------------------------------------------------------- |
|
646 |
TInt CCsConversationCache::GetConversationIdFromAddressL(TDesC& aContactAddress) |
|
647 |
{ |
|
648 |
TInt conversationCount = iConversationList->Count(); |
|
649 |
||
650 |
for ( TInt loop= 0; loop < conversationCount; loop++ ) |
|
651 |
{ |
|
652 |
CCsConversation* conversation = |
|
653 |
static_cast<CCsConversation*>((*iConversationList)[loop]); |
|
654 |
CCsConversationContact* contact = conversation->GetContact(); |
|
655 |
if(contact->MatchPhoneNumber(aContactAddress,iMatchDigitCount)) |
|
656 |
{ |
|
657 |
return conversation->GetConversationId(); |
|
658 |
} |
|
659 |
} |
|
660 |
return -1; |
|
661 |
} |
|
662 |
||
663 |
// ---------------------------------------------------------------------------- |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
664 |
// CCsConversationCache::GetConversationFromConversationId |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
665 |
// ---------------------------------------------------------------------------- |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
666 |
CCsClientConversation* CCsConversationCache::GetConversationFromConversationIdL(TInt aConversationId) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
667 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
668 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
669 |
CCsClientConversation* clientConv = NULL; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
670 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
671 |
for ( TInt loop = 0; loop < iConversationList->Count(); ++loop ) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
672 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
673 |
CCsConversation* conversation = |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
674 |
static_cast<CCsConversation*>((*iConversationList)[loop]); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
675 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
676 |
if (aConversationId == conversation->GetConversationId()) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
677 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
678 |
clientConv = CreateClientConvLC(conversation, conversation->GetLatestEntryL()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
679 |
CleanupStack::Pop(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
680 |
break; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
681 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
682 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
683 |
return clientConv; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
684 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
685 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
686 |
// ---------------------------------------------------------------------------- |
31 | 687 |
// CCsConversationCache::GetConversationFromMessageIdL |
688 |
// --------------------------------------------------------------------------- |
|
689 |
CCsClientConversation* CCsConversationCache::GetConversationFromMessageIdL(TInt aMessageId) |
|
690 |
{ |
|
691 |
TInt conversationCount = iConversationList->Count(); |
|
692 |
||
693 |
for ( TInt loop = 0; loop < conversationCount; loop++ ) |
|
694 |
{ |
|
695 |
CCsConversation* conversation = |
|
696 |
static_cast<CCsConversation*>((*iConversationList)[loop]); |
|
697 |
||
698 |
// Get the conversation entries |
|
699 |
RPointerArray<CCsConversationEntry> entryList; |
|
700 |
conversation->GetEntryListL(&entryList); |
|
701 |
||
702 |
for ( TInt loop1 = 0; loop1 < entryList.Count(); loop1++ ) |
|
703 |
{ |
|
704 |
TInt messageId = entryList[loop1]->EntryId(); |
|
705 |
if ( messageId == aMessageId ) |
|
706 |
{ |
|
707 |
CCsClientConversation *clientConv = CreateClientConvLC(conversation, entryList[loop1]); |
|
708 |
CleanupStack::Pop(); |
|
709 |
return clientConv; |
|
710 |
} |
|
711 |
} |
|
712 |
} |
|
713 |
return NULL; |
|
714 |
} |
|
715 |
||
716 |
//end of file |