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>
|
|
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->SetDisplayNameL(aConversation->GetDisplayName());
|
|
428 |
clientConversation->SetConversationEntryId(aConversation->GetConversationId());
|
|
429 |
clientConversation->SetConversationEntryL(aConversationEntry);
|
|
430 |
clientConversation->SetContactId(aConversation->GetContactId());
|
|
431 |
clientConversation->SetUnreadMessageCount(aConversation->GetUnreadMessageCount());
|
|
432 |
|
|
433 |
return clientConversation;
|
|
434 |
}
|
|
435 |
|
|
436 |
// ----------------------------------------------------------------------------
|
|
437 |
// CCsConversationCache::MarkConversationAsDeleted
|
|
438 |
// ----------------------------------------------------------------------------
|
|
439 |
void CCsConversationCache::MarkConversationAsDeleted(TInt aConversationId,
|
|
440 |
TBool aDeleted)
|
|
441 |
{
|
|
442 |
TInt conversationCount = iConversationList->Count();
|
|
443 |
|
|
444 |
for (TInt loop = 0; loop < conversationCount; loop++)
|
|
445 |
{
|
|
446 |
CCsConversation* conversation =
|
|
447 |
static_cast<CCsConversation*> ( (*iConversationList)[loop]);
|
|
448 |
TInt id = conversation->GetConversationId();
|
|
449 |
|
|
450 |
if (id == aConversationId)
|
|
451 |
{
|
|
452 |
conversation->MarkDeleted(aDeleted);
|
|
453 |
break;
|
|
454 |
}
|
|
455 |
}
|
|
456 |
}
|
|
457 |
|
|
458 |
// ----------------------------------------------------------------------------
|
|
459 |
// CCsConversationCache::IsDeleted
|
|
460 |
// ----------------------------------------------------------------------------
|
|
461 |
TBool CCsConversationCache::IsDeleted(TInt aConversationId)
|
|
462 |
{
|
|
463 |
TInt conversationCount = iConversationList->Count();
|
|
464 |
|
|
465 |
for (TInt loop = 0; loop < conversationCount; loop++)
|
|
466 |
{
|
|
467 |
CCsConversation* conversation =
|
|
468 |
static_cast<CCsConversation*> ( (*iConversationList)[loop]);
|
|
469 |
TInt id = conversation->GetConversationId();
|
|
470 |
|
|
471 |
if (id == aConversationId)
|
|
472 |
{
|
|
473 |
return conversation->IsDeleted();
|
|
474 |
}
|
|
475 |
}
|
|
476 |
return EFalse;
|
|
477 |
}
|
|
478 |
|
|
479 |
// ----------------------------------------------------------------------------
|
|
480 |
// CCsConversationCache::ConversationList
|
|
481 |
// Pls refer to .h file
|
|
482 |
// ----------------------------------------------------------------------------
|
|
483 |
RPointerArray<CCsConversation>*
|
|
484 |
CCsConversationCache::ConversationList()
|
|
485 |
{
|
|
486 |
return iConversationList;
|
|
487 |
}
|
|
488 |
|
|
489 |
// ----------------------------------------------------------------------------
|
|
490 |
// CCsConversationCache::getContactsManager
|
|
491 |
// Pls refer to .h file
|
|
492 |
// ----------------------------------------------------------------------------
|
|
493 |
CCsContactsManager*
|
|
494 |
CCsConversationCache::ContactsManager() const
|
|
495 |
{
|
|
496 |
return iContactsManager;
|
|
497 |
}
|
|
498 |
// ----------------------------------------------------------------------------
|
|
499 |
// CCsConversationCache::HandleAddContact
|
|
500 |
// Pls refer to .h file
|
|
501 |
// ----------------------------------------------------------------------------
|
|
502 |
void CCsConversationCache::HandleAddContact(CCsContactDetail& aDetail)
|
|
503 |
{
|
|
504 |
//handle addition of new contact
|
|
505 |
|
|
506 |
QStringList phoneNumberList = aDetail.addressList;
|
|
507 |
TInt totalPhoneNumber = phoneNumberList.count();
|
|
508 |
|
|
509 |
// Get the conversation indexes for the phone numbers
|
|
510 |
RArray<TInt> conversationIndex;
|
|
511 |
|
|
512 |
for (int i = 0; i < totalPhoneNumber; i++)
|
|
513 |
{
|
|
514 |
QString phoneNumber = phoneNumberList.at(i);
|
|
515 |
HBufC* phoneNumber_s60 =
|
|
516 |
S60QConversions::qStringToS60Desc(phoneNumber);
|
|
517 |
TInt cIndex = FindConversation(*phoneNumber_s60);
|
|
518 |
if (cIndex != KErrNotFound)
|
|
519 |
{
|
|
520 |
if (conversationIndex.Find(cIndex) == KErrNotFound)
|
|
521 |
{
|
|
522 |
conversationIndex.Append(cIndex);
|
|
523 |
}
|
|
524 |
}
|
|
525 |
delete phoneNumber_s60;
|
|
526 |
}
|
|
527 |
|
|
528 |
// Sort the conversationIndex
|
|
529 |
conversationIndex.Sort();
|
|
530 |
|
|
531 |
// Redo contact resolving for the affected conversations
|
|
532 |
for ( TInt i = conversationIndex.Count() - 1; i >= 0 ; i-- )
|
|
533 |
{
|
|
534 |
RedoResolvingL(conversationIndex[i]);
|
|
535 |
}
|
|
536 |
|
|
537 |
conversationIndex.Reset();
|
|
538 |
}
|
|
539 |
|
|
540 |
// ----------------------------------------------------------------------------
|
|
541 |
// CCsConversationCache::HandleContactChange
|
|
542 |
// Pls refer to .h file
|
|
543 |
// ----------------------------------------------------------------------------
|
|
544 |
void CCsConversationCache::HandleContactChange(CCsContactDetail& aDetail)
|
|
545 |
{
|
|
546 |
//handle contact change
|
|
547 |
QStringList phoneNumberList = aDetail.addressList;
|
|
548 |
int countNumberList = phoneNumberList.count();
|
|
549 |
|
|
550 |
// Get the conversation indexes for the phone numbers
|
|
551 |
RArray<TInt> conversationIndex;
|
|
552 |
for (int i=0; i < countNumberList ; i++)
|
|
553 |
{
|
|
554 |
QString phoneNumber = phoneNumberList.at(i);
|
|
555 |
HBufC* phoneNumber_s60 =
|
|
556 |
S60QConversions::qStringToS60Desc(phoneNumber);
|
|
557 |
|
|
558 |
TInt cIndex = FindConversation(*phoneNumber_s60);
|
|
559 |
if ( cIndex != KErrNotFound )
|
|
560 |
{
|
|
561 |
conversationIndex.InsertInOrder(cIndex);
|
|
562 |
}
|
|
563 |
delete phoneNumber_s60;
|
|
564 |
}
|
|
565 |
|
|
566 |
// Get the conversation index corresponding to the contact Id
|
|
567 |
TInt linkIdIndex = FindConversation(aDetail.contactId);
|
|
568 |
if (linkIdIndex != KErrNotFound)
|
|
569 |
{
|
|
570 |
conversationIndex.InsertInOrder(linkIdIndex);
|
|
571 |
}
|
|
572 |
|
|
573 |
// Redo contact resolving for the affected conversations
|
|
574 |
for ( TInt i = conversationIndex.Count() - 1; i >= 0 ; i-- )
|
|
575 |
{
|
|
576 |
RedoResolvingL(conversationIndex[i]);
|
|
577 |
}
|
|
578 |
|
|
579 |
conversationIndex.Reset();
|
|
580 |
}
|
|
581 |
|
|
582 |
// ----------------------------------------------------------------------------
|
|
583 |
// CCsConversationCache::HandleDeleteContact
|
|
584 |
// Pls refer to .h file
|
|
585 |
// ----------------------------------------------------------------------------
|
|
586 |
void CCsConversationCache::HandleDeleteContact(CCsContactDetail& aDetail)
|
|
587 |
{
|
|
588 |
//handle if contact is deleted
|
|
589 |
TInt cIndex = FindConversation(aDetail.contactId);
|
|
590 |
if (cIndex == KErrNotFound)
|
|
591 |
{
|
|
592 |
// No need to handle this change
|
|
593 |
return;
|
|
594 |
}
|
|
595 |
|
|
596 |
// Redo resolving for the affected conversation
|
|
597 |
RedoResolvingL(cIndex);
|
|
598 |
}
|
|
599 |
|
|
600 |
// ----------------------------------------------------------------------------
|
|
601 |
// CCsConversationCache::GetConversationIdL
|
|
602 |
// ----------------------------------------------------------------------------
|
|
603 |
TInt CCsConversationCache::GetConversationIdL(TInt aContactId)
|
|
604 |
{
|
|
605 |
TInt conversationCount = iConversationList->Count();
|
|
606 |
|
|
607 |
for ( TInt loop= 0; loop < conversationCount; loop++ )
|
|
608 |
{
|
|
609 |
CCsConversation* conversation =
|
|
610 |
static_cast<CCsConversation*>((*iConversationList)[loop]);
|
|
611 |
TInt contactId = conversation->GetContactId();
|
|
612 |
|
|
613 |
if ( contactId == aContactId )
|
|
614 |
{
|
|
615 |
return conversation->GetConversationId();
|
|
616 |
}
|
|
617 |
}
|
|
618 |
|
|
619 |
return -1;
|
|
620 |
}
|
|
621 |
|
|
622 |
// ----------------------------------------------------------------------------
|
|
623 |
// CCsConversationCache::GetConversationIdFromAddressL
|
|
624 |
// ----------------------------------------------------------------------------
|
|
625 |
TInt CCsConversationCache::GetConversationIdFromAddressL(TDesC& aContactAddress)
|
|
626 |
{
|
|
627 |
TInt conversationCount = iConversationList->Count();
|
|
628 |
|
|
629 |
for ( TInt loop= 0; loop < conversationCount; loop++ )
|
|
630 |
{
|
|
631 |
CCsConversation* conversation =
|
|
632 |
static_cast<CCsConversation*>((*iConversationList)[loop]);
|
|
633 |
CCsConversationContact* contact = conversation->GetContact();
|
|
634 |
if(contact->MatchPhoneNumber(aContactAddress,iMatchDigitCount))
|
|
635 |
{
|
|
636 |
return conversation->GetConversationId();
|
|
637 |
}
|
|
638 |
}
|
|
639 |
return -1;
|
|
640 |
}
|
|
641 |
|
|
642 |
// ----------------------------------------------------------------------------
|
|
643 |
// CCsConversationCache::GetConversationFromMessageIdL
|
|
644 |
// ---------------------------------------------------------------------------
|
|
645 |
CCsClientConversation* CCsConversationCache::GetConversationFromMessageIdL(TInt aMessageId)
|
|
646 |
{
|
|
647 |
TInt conversationCount = iConversationList->Count();
|
|
648 |
|
|
649 |
for ( TInt loop = 0; loop < conversationCount; loop++ )
|
|
650 |
{
|
|
651 |
CCsConversation* conversation =
|
|
652 |
static_cast<CCsConversation*>((*iConversationList)[loop]);
|
|
653 |
|
|
654 |
// Get the conversation entries
|
|
655 |
RPointerArray<CCsConversationEntry> entryList;
|
|
656 |
conversation->GetEntryListL(&entryList);
|
|
657 |
|
|
658 |
for ( TInt loop1 = 0; loop1 < entryList.Count(); loop1++ )
|
|
659 |
{
|
|
660 |
TInt messageId = entryList[loop1]->EntryId();
|
|
661 |
if ( messageId == aMessageId )
|
|
662 |
{
|
|
663 |
CCsClientConversation *clientConv = CreateClientConvLC(conversation, entryList[loop1]);
|
|
664 |
CleanupStack::Pop();
|
|
665 |
return clientConv;
|
|
666 |
}
|
|
667 |
}
|
|
668 |
}
|
|
669 |
return NULL;
|
|
670 |
}
|
|
671 |
|
|
672 |
//end of file
|