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