| author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> | 
| Wed, 18 Aug 2010 09:45:25 +0300 | |
| changeset 52 | 12db4185673b | 
| 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: 
31diff
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 | |
| 52 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 203 | // Get segment of conversations for a given conversation Id, knownIndex and page size. | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 204 | // The return list is set inside aConversationEntryList and aTotalConversationCount | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 205 | // has total conversation count. | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 206 | // ---------------------------------------------------------------------------- | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 207 | void | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 208 | CCsConversationCache::GetConversationsL( | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 209 | const CCsClientConversation* aClientConversation, | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 210 | RPointerArray<CCsConversationEntry>* aConversationEntryList, | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 211 | TInt aKnownIndex, | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 212 | TInt aPageSize, | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 213 | TInt& aTotalConversationCount) | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 214 |     {
 | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 215 | TInt conversationCount = iConversationList->Count(); | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 216 | |
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 217 | // Get the entry id from Client Conversation for which conversations are required | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 218 | TCsConversationEntryID conversationEntryID = | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 219 | aClientConversation->GetConversationEntryId(); | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 220 | |
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 221 | for (TInt loop= 0; loop < conversationCount; loop++ ) | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 222 |         {
 | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 223 | //match entry ID; | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 224 | CCsConversation* conversation = | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 225 | static_cast<CCsConversation*>((*iConversationList)[loop]); | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 226 | |
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 227 | if(conversationEntryID == conversation->GetConversationId()) | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 228 |             {
 | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 229 | TInt endIndex = conversation->GetEntryCount(); | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 230 | TInt startIndex(0); | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 231 | if((aKnownIndex!= 0) || (aPageSize !=0 )) | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 232 |                 {
 | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 233 | endIndex = endIndex- aKnownIndex; | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 234 | startIndex = endIndex - aPageSize; | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 235 | if( startIndex < 0 ) startIndex = 0; | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 236 | } | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 237 | // Search the conversation id and get the list inside | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 238 | // No need to check, becz it is initialize here only. | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 239 | conversation->GetEntryListL(aConversationEntryList, | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 240 | startIndex,endIndex); | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 241 | // May, meanwhile new conversation cached. | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 242 | aTotalConversationCount = conversation->GetEntryCount(); | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 243 | break; | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 244 | } | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 245 | } | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 246 |     PRINT1 ( _L("CCsConversationCache::GetConversationsL - conversationCount:%d"),
 | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 247 | conversationCount ); | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 248 | } | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 249 | // ---------------------------------------------------------------------------- | 
| 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 250 | // CCsConversationCache::GetConversationsL | 
| 31 | 251 | // Get All Conversations for a given conversation Id | 
| 252 | // the return list is set inside aConversationEntryList | |
| 253 | // ---------------------------------------------------------------------------- | |
| 254 | void CCsConversationCache::GetConversationsL( | |
| 255 | const CCsClientConversation* aClientConversation, | |
| 256 | RPointerArray<CCsConversationEntry>* aConversationEntryList) | |
| 257 | {
 | |
| 258 | TInt totalConversation = iConversationList->Count(); | |
| 259 | ||
| 260 | // Get the entry id from Client Conversation for which conversations are required | |
| 261 | TCsConversationEntryID conversationEntryID = | |
| 262 | aClientConversation->GetConversationEntryId(); | |
| 263 | ||
| 264 | // Write the contact display names | |
| 265 | for (TInt loop = 0; loop < totalConversation; loop++) | |
| 266 |     {
 | |
| 267 | //match entry ID; | |
| 268 | CCsConversation* conversation = | |
| 269 | static_cast<CCsConversation*> ( (*iConversationList)[loop]); | |
| 270 | ||
| 271 | if (conversationEntryID == conversation->GetConversationId()) | |
| 272 |         {
 | |
| 273 | // search the conversation id and get the list inside | |
| 274 | conversation->GetEntryListL(aConversationEntryList); | |
| 275 | break; | |
| 276 | } | |
| 277 | } | |
| 278 |     PRINT1 ( _L("CCsConversationCache::GetConversationsL - conversationCount:%d"),
 | |
| 279 | totalConversation ); | |
| 280 | } | |
| 281 | ||
| 282 | // ---------------------------------------------------------------------------- | |
| 283 | // CCsConversationCache::HandleConversations | |
| 284 | // Called from server. This is to handle the event callback from plugin dll | |
| 285 | // The idea is to add entries to the cache and at the same time update the clients | |
| 286 | // ---------------------------------------------------------------------------- | |
| 287 | void CCsConversationCache::HandleConversations(const RPointerArray< | |
| 288 | CCsConversationEntry>& aConversationEntryLists, | |
| 289 | const TUint32 aConversationEvent) | |
| 290 | {
 | |
| 291 | // get count | |
| 292 | TInt count = aConversationEntryLists.Count(); | |
| 293 | ||
| 294 | // go through each conversation entry | |
| 295 | // add it into queue, event list | |
| 296 | for (TInt loop = 0; loop < count; loop++) | |
| 297 |     {
 | |
| 298 | //get copy of conversation event | |
| 299 | TInt error; | |
| 300 | CCsConversationEvent* conEvent = NULL; | |
| 301 | CCsClientConversation* clientCon = NULL; | |
| 302 | CCsConversationEntry* conEntry = aConversationEntryLists[loop]; | |
| 303 | ||
| 304 | if (aConversationEntryLists[loop]) | |
| 305 |         {
 | |
| 306 | TRAP( | |
| 307 | error, | |
| 308 | conEvent = CCsConversationEvent::NewL(); | |
| 309 | CleanupStack::PushL(conEvent); | |
| 310 | //create clientconversation | |
| 311 | clientCon = CCsClientConversation::NewL(); | |
| 312 | CleanupStack::PushL(clientCon); | |
| 313 | clientCon->SetConversationEntryL(conEntry); | |
| 314 | //set conversation entry | |
| 315 | conEvent->SetClientConversationL(*clientCon); | |
| 316 | //set event | |
| 317 | conEvent->SetEvent(aConversationEvent); | |
| 318 | //add entry | |
| 319 | iConversationCacheHelper->ConversationEventList()->AppendL(conEvent); | |
| 320 | CleanupStack::PopAndDestroy(clientCon); | |
| 321 | CleanupStack::Pop(conEvent)); | |
| 322 | ||
| 323 | if (error != KErrNone) | |
| 324 |             {
 | |
| 325 |                 PRINT1 ( _L("CCsConversationCache::HandleConversation - Error:%d"),
 | |
| 326 | error ); | |
| 327 | continue; | |
| 328 | } | |
| 329 | } | |
| 330 | } | |
| 331 | iConversationCacheHelper->StartCacheUpdate(); | |
| 332 | } | |
| 333 | ||
| 334 | // ---------------------------------------------------------------------------- | |
| 335 | // CCsConversationCache::GetTotalUnreadCount | |
| 336 | // Pending event count | |
| 337 | // ---------------------------------------------------------------------------- | |
| 338 | TUint32 CCsConversationCache::GetTotalUnreadCount() | |
| 339 |     {
 | |
| 340 | TUint32 totalUnread = 0; | |
| 341 | ||
| 342 | for (TInt loop = 0; loop < iConversationList->Count(); ++loop) | |
| 343 |         {
 | |
| 344 | CCsConversation* conversation = | |
| 345 | static_cast<CCsConversation*> ((*iConversationList)[loop]); | |
| 346 | totalUnread += conversation->GetUnreadMessageCount(); | |
| 347 | } | |
| 348 | return totalUnread; | |
| 349 | } | |
| 350 | ||
| 351 | // ---------------------------------------------------------------------------- | |
| 352 | // CCsConversationCache::NotifyL | |
| 353 | // Send the notification client | |
| 354 | // ---------------------------------------------------------------------------- | |
| 355 | void CCsConversationCache::NotifyL(CCsClientConversation* aConversation, | |
| 356 | TUint32 aEvent) | |
| 357 | {
 | |
| 358 | iCsServer->NotifySessions(aConversation, aEvent); | |
| 359 | } | |
| 360 | ||
| 361 | // ---------------------------------------------------------------------------- | |
| 362 | // CCsConversationCache::CachingCompletedL | |
| 363 | // This is called from cache helper after it resolves all events from plugin | |
| 364 | // ---------------------------------------------------------------------------- | |
| 365 | void CCsConversationCache::CachingCompletedL() | |
| 366 | {
 | |
| 367 | // Not supported | |
| 368 | } | |
| 369 | ||
| 370 | // ---------------------------------------------------------------------------- | |
| 371 | // CCsConversationCache::FindConversation | |
| 372 | // Find a conversation based on contact Id | |
| 373 | // ---------------------------------------------------------------------------- | |
| 374 | TInt CCsConversationCache::FindConversation(TInt32 aContactId) | |
| 375 | {
 | |
| 376 | if (aContactId == KErrNotFound) | |
| 377 | return KErrNotFound; | |
| 378 | ||
| 379 | TInt totalConversations = iConversationList->Count(); | |
| 380 | ||
| 381 | for (TInt index = 0; index < totalConversations; index++) | |
| 382 |     {
 | |
| 383 | CCsConversation* conversation = | |
| 384 | static_cast<CCsConversation*> ( (*iConversationList)[index]); | |
| 385 | ||
| 386 | CCsConversationContact* inCache = conversation->GetContact(); | |
| 387 | ||
| 388 | TInt32 idInCache = inCache->GetContactId(); | |
| 389 | ||
| 390 | if (idInCache == KErrNotFound) | |
| 391 | continue; | |
| 392 | ||
| 393 | if (idInCache == aContactId) | |
| 394 |         {
 | |
| 395 | return index; | |
| 396 | } | |
| 397 | } | |
| 398 | return KErrNotFound; | |
| 399 | } | |
| 400 | ||
| 401 | // ---------------------------------------------------------------------------- | |
| 402 | // CCsConversationCache::FindConversation | |
| 403 | // Find a conversation based on phone number | |
| 404 | // ---------------------------------------------------------------------------- | |
| 405 | TInt CCsConversationCache::FindConversation(TDesC& aPhoneNumber) | |
| 406 | {
 | |
| 407 | TInt count = iConversationList->Count(); | |
| 408 | ||
| 409 | for (TInt cIndex = 0; cIndex < count; cIndex++) | |
| 410 |     {
 | |
| 411 | CCsConversation* conversation = | |
| 412 | static_cast<CCsConversation*> ( (*iConversationList)[cIndex]); | |
| 413 | ||
| 414 | CCsConversationContact* inCache = conversation->GetContact(); | |
| 415 | ||
| 416 | if (inCache->MatchPhoneNumber(aPhoneNumber, iMatchDigitCount)) | |
| 417 |         {
 | |
| 418 | return cIndex; | |
| 419 | } | |
| 420 | } | |
| 421 | return KErrNotFound; | |
| 422 | } | |
| 423 | ||
| 424 | // ---------------------------------------------------------------------------- | |
| 425 | // CCsConversationCache::RedoResolvingL | |
| 426 | // Redo contact resolving for the conversation at this index | |
| 427 | // ---------------------------------------------------------------------------- | |
| 428 | void CCsConversationCache::RedoResolvingL(TInt aIndex) | |
| 429 | {
 | |
| 430 | // Recover the associated conversation object | |
| 431 | CCsConversation* conversation = | |
| 432 | static_cast<CCsConversation*> ( (*iConversationList)[aIndex]); | |
| 433 | ||
| 434 | // Get the conversation entries | |
| 435 | RPointerArray<CCsConversationEntry> entryList; | |
| 436 | conversation->GetEntryListL(&entryList); | |
| 437 | ||
| 438 | // Handle as if they are new conversations | |
| 439 | HandleConversations(entryList, KConversationEventNew); | |
| 440 | ||
| 441 | // Send a notification for delete conversation | |
| 442 | CCsConversationEntry* convEntry = conversation->GetLatestEntryL(); | |
| 443 | ||
| 444 | if (iConversationCacheHelper->IsNotifyRequiredL(conversation, | |
| 445 | convEntry, | |
| 446 | KConversationListEventDelete, | |
| 447 | conversation->GetUnreadMessageCount())) | |
| 448 |     {
 | |
| 449 | //clone conversation and send update to client | |
| 450 | CCsClientConversation* clientConv = CreateClientConvLC(conversation, | |
| 451 | convEntry); | |
| 452 | NotifyL(clientConv, KConversationListEventDelete); | |
| 453 | CleanupStack::PopAndDestroy(clientConv); | |
| 454 | } | |
| 455 | ||
| 44 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 456 | // 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: 
43diff
changeset | 457 | // Notify client of conversation change | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 458 | TInt totalEntryCount = conversation->GetEntryCount(); | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 459 | for (TInt entryCounter = totalEntryCount - 1; entryCounter >= 0; | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 460 | entryCounter--) | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 461 |     {
 | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 462 | CCsConversationEntry* entryInConversation = | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 463 | conversation->GetEntryL(entryCounter); | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 464 | CCsClientConversation * clientConv = | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 465 | CreateClientConvLC(conversation, entryInConversation); | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 466 | NotifyL(clientConv, KConversationEventDelete); | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 467 | CleanupStack::PopAndDestroy(clientConv); | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 468 | } | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 469 | |
| 31 | 470 | iConversationList->Remove(aIndex); | 
| 471 | entryList.ResetAndDestroy(); | |
| 472 | ||
| 473 | delete conversation; | |
| 474 | } | |
| 475 | ||
| 476 | // ---------------------------------------------------------------------------- | |
| 477 | // CCsConversationCache::CreateClientConvLC | |
| 478 | // create CCsConversation from CCsConversation and CCsConversationEntry | |
| 479 | // ---------------------------------------------------------------------------- | |
| 480 | CCsClientConversation* CCsConversationCache::CreateClientConvLC( | |
| 481 | const CCsConversation* aConversation, | |
| 482 | const CCsConversationEntry* aConversationEntry) | |
| 483 | {
 | |
| 484 | //create clientconversation | |
| 485 | CCsClientConversation* clientConversation = CCsClientConversation::NewL(); | |
| 486 | CleanupStack::PushL(clientConversation); | |
| 487 | ||
| 488 | clientConversation->SetDisplayNameL(aConversation->GetDisplayName()); | |
| 489 | clientConversation->SetConversationEntryId(aConversation->GetConversationId()); | |
| 490 | clientConversation->SetConversationEntryL(aConversationEntry); | |
| 491 | clientConversation->SetContactId(aConversation->GetContactId()); | |
| 492 | clientConversation->SetUnreadMessageCount(aConversation->GetUnreadMessageCount()); | |
| 493 | ||
| 494 | return clientConversation; | |
| 495 | } | |
| 496 | ||
| 497 | // ---------------------------------------------------------------------------- | |
| 498 | // CCsConversationCache::MarkConversationAsDeleted | |
| 499 | // ---------------------------------------------------------------------------- | |
| 500 | void CCsConversationCache::MarkConversationAsDeleted(TInt aConversationId, | |
| 44 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 501 | TBool aDeleted, TInt aCount) | 
| 31 | 502 | {
 | 
| 503 | TInt conversationCount = iConversationList->Count(); | |
| 504 | ||
| 505 | for (TInt loop = 0; loop < conversationCount; loop++) | |
| 506 |     {
 | |
| 507 | CCsConversation* conversation = | |
| 508 | static_cast<CCsConversation*> ( (*iConversationList)[loop]); | |
| 509 | TInt id = conversation->GetConversationId(); | |
| 510 | ||
| 511 | if (id == aConversationId) | |
| 512 |         {
 | |
| 513 | conversation->MarkDeleted(aDeleted); | |
| 44 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 514 | if( aCount ) | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 515 |                 {
 | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 516 | CCsClientConversation* clientConversation = | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 517 | CreateClientConvLC(conversation, | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 518 | conversation->GetLatestEntryL()); | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 519 | NotifyL(clientConversation, KConversationListEventPartialDelete); | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 520 | CleanupStack::PopAndDestroy();// clientConversation | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 521 | } | 
| 31 | 522 | break; | 
| 523 | } | |
| 524 | } | |
| 525 | } | |
| 526 | ||
| 527 | // ---------------------------------------------------------------------------- | |
| 528 | // CCsConversationCache::IsDeleted | |
| 529 | // ---------------------------------------------------------------------------- | |
| 530 | TBool CCsConversationCache::IsDeleted(TInt aConversationId) | |
| 531 | {
 | |
| 532 | TInt conversationCount = iConversationList->Count(); | |
| 533 | ||
| 534 | for (TInt loop = 0; loop < conversationCount; loop++) | |
| 535 |     {
 | |
| 536 | CCsConversation* conversation = | |
| 537 | static_cast<CCsConversation*> ( (*iConversationList)[loop]); | |
| 538 | TInt id = conversation->GetConversationId(); | |
| 539 | ||
| 540 | if (id == aConversationId) | |
| 541 |         {
 | |
| 542 | return conversation->IsDeleted(); | |
| 543 | } | |
| 544 | } | |
| 545 | return EFalse; | |
| 546 | } | |
| 547 | ||
| 548 | // ---------------------------------------------------------------------------- | |
| 549 | // CCsConversationCache::ConversationList | |
| 550 | // Pls refer to .h file | |
| 551 | // ---------------------------------------------------------------------------- | |
| 552 | RPointerArray<CCsConversation>* | |
| 553 | CCsConversationCache::ConversationList() | |
| 554 | {
 | |
| 555 | return iConversationList; | |
| 556 | } | |
| 557 | ||
| 558 | // ---------------------------------------------------------------------------- | |
| 559 | // CCsConversationCache::getContactsManager | |
| 560 | // Pls refer to .h file | |
| 561 | // ---------------------------------------------------------------------------- | |
| 562 | CCsContactsManager* | |
| 563 | CCsConversationCache::ContactsManager() const | |
| 564 | {
 | |
| 565 | return iContactsManager; | |
| 566 | } | |
| 567 | // ---------------------------------------------------------------------------- | |
| 568 | // CCsConversationCache::HandleAddContact | |
| 569 | // Pls refer to .h file | |
| 570 | // ---------------------------------------------------------------------------- | |
| 571 | void CCsConversationCache::HandleAddContact(CCsContactDetail& aDetail) | |
| 572 | {
 | |
| 573 | //handle addition of new contact | |
| 574 | ||
| 575 | QStringList phoneNumberList = aDetail.addressList; | |
| 576 | TInt totalPhoneNumber = phoneNumberList.count(); | |
| 577 | ||
| 578 | // Get the conversation indexes for the phone numbers | |
| 579 | RArray<TInt> conversationIndex; | |
| 580 | ||
| 581 | for (int i = 0; i < totalPhoneNumber; i++) | |
| 582 |     {
 | |
| 583 | QString phoneNumber = phoneNumberList.at(i); | |
| 584 | HBufC* phoneNumber_s60 = | |
| 43 
35b64624a9e7
Revision: 201023
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 585 | XQConversions::qStringToS60Desc(phoneNumber); | 
| 31 | 586 | TInt cIndex = FindConversation(*phoneNumber_s60); | 
| 587 | if (cIndex != KErrNotFound) | |
| 588 |         {
 | |
| 589 | if (conversationIndex.Find(cIndex) == KErrNotFound) | |
| 590 |             {
 | |
| 591 | conversationIndex.Append(cIndex); | |
| 592 | } | |
| 593 | } | |
| 594 | delete phoneNumber_s60; | |
| 595 | } | |
| 596 | ||
| 597 | // Sort the conversationIndex | |
| 598 | conversationIndex.Sort(); | |
| 599 | ||
| 600 | // Redo contact resolving for the affected conversations | |
| 601 | for ( TInt i = conversationIndex.Count() - 1; i >= 0 ; i-- ) | |
| 602 |     {
 | |
| 603 | RedoResolvingL(conversationIndex[i]); | |
| 604 | } | |
| 605 | ||
| 606 | conversationIndex.Reset(); | |
| 607 | } | |
| 608 | ||
| 609 | // ---------------------------------------------------------------------------- | |
| 610 | // CCsConversationCache::HandleContactChange | |
| 611 | // Pls refer to .h file | |
| 612 | // ---------------------------------------------------------------------------- | |
| 613 | void CCsConversationCache::HandleContactChange(CCsContactDetail& aDetail) | |
| 614 | {
 | |
| 615 | //handle contact change | |
| 616 | QStringList phoneNumberList = aDetail.addressList; | |
| 617 | int countNumberList = phoneNumberList.count(); | |
| 618 | ||
| 619 | // Get the conversation indexes for the phone numbers | |
| 620 | RArray<TInt> conversationIndex; | |
| 621 | for (int i=0; i < countNumberList ; i++) | |
| 622 |     {
 | |
| 623 | QString phoneNumber = phoneNumberList.at(i); | |
| 624 | HBufC* phoneNumber_s60 = | |
| 43 
35b64624a9e7
Revision: 201023
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 625 | XQConversions::qStringToS60Desc(phoneNumber); | 
| 31 | 626 | |
| 627 | TInt cIndex = FindConversation(*phoneNumber_s60); | |
| 628 | if ( cIndex != KErrNotFound ) | |
| 629 |         {
 | |
| 630 | conversationIndex.InsertInOrder(cIndex); | |
| 631 | } | |
| 632 | delete phoneNumber_s60; | |
| 633 | } | |
| 634 | ||
| 635 | // Get the conversation index corresponding to the contact Id | |
| 636 | TInt linkIdIndex = FindConversation(aDetail.contactId); | |
| 637 | if (linkIdIndex != KErrNotFound) | |
| 638 |     {
 | |
| 639 | conversationIndex.InsertInOrder(linkIdIndex); | |
| 640 | } | |
| 641 | ||
| 642 | // Redo contact resolving for the affected conversations | |
| 643 | for ( TInt i = conversationIndex.Count() - 1; i >= 0 ; i-- ) | |
| 644 |     {
 | |
| 645 | RedoResolvingL(conversationIndex[i]); | |
| 646 | } | |
| 647 | ||
| 648 | conversationIndex.Reset(); | |
| 649 | } | |
| 650 | ||
| 651 | // ---------------------------------------------------------------------------- | |
| 652 | // CCsConversationCache::HandleDeleteContact | |
| 653 | // Pls refer to .h file | |
| 654 | // ---------------------------------------------------------------------------- | |
| 655 | void CCsConversationCache::HandleDeleteContact(CCsContactDetail& aDetail) | |
| 656 | {
 | |
| 657 | //handle if contact is deleted | |
| 658 | TInt cIndex = FindConversation(aDetail.contactId); | |
| 659 | if (cIndex == KErrNotFound) | |
| 660 |     {
 | |
| 661 | // No need to handle this change | |
| 662 | return; | |
| 663 | } | |
| 664 | ||
| 665 | // Redo resolving for the affected conversation | |
| 666 | RedoResolvingL(cIndex); | |
| 667 | } | |
| 668 | ||
| 669 | // ---------------------------------------------------------------------------- | |
| 670 | // CCsConversationCache::GetConversationIdL | |
| 671 | // ---------------------------------------------------------------------------- | |
| 672 | TInt CCsConversationCache::GetConversationIdL(TInt aContactId) | |
| 673 |     {
 | |
| 674 | TInt conversationCount = iConversationList->Count(); | |
| 675 | ||
| 676 | for ( TInt loop= 0; loop < conversationCount; loop++ ) | |
| 677 |        {
 | |
| 678 | CCsConversation* conversation = | |
| 679 | static_cast<CCsConversation*>((*iConversationList)[loop]); | |
| 680 | TInt contactId = conversation->GetContactId(); | |
| 681 | ||
| 682 | if ( contactId == aContactId ) | |
| 683 |            {
 | |
| 684 | return conversation->GetConversationId(); | |
| 685 | } | |
| 686 | } | |
| 687 | ||
| 688 | return -1; | |
| 689 | } | |
| 690 | ||
| 691 | // ---------------------------------------------------------------------------- | |
| 692 | // CCsConversationCache::GetConversationIdFromAddressL | |
| 693 | // ---------------------------------------------------------------------------- | |
| 694 | TInt CCsConversationCache::GetConversationIdFromAddressL(TDesC& aContactAddress) | |
| 695 |     {
 | |
| 696 | TInt conversationCount = iConversationList->Count(); | |
| 697 | ||
| 698 | for ( TInt loop= 0; loop < conversationCount; loop++ ) | |
| 699 |     {
 | |
| 700 | CCsConversation* conversation = | |
| 701 | static_cast<CCsConversation*>((*iConversationList)[loop]); | |
| 702 | CCsConversationContact* contact = conversation->GetContact(); | |
| 703 | if(contact->MatchPhoneNumber(aContactAddress,iMatchDigitCount)) | |
| 704 |             {
 | |
| 705 | return conversation->GetConversationId(); | |
| 706 | } | |
| 707 | } | |
| 708 | return -1; | |
| 709 | } | |
| 710 | ||
| 711 | // ---------------------------------------------------------------------------- | |
| 44 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 712 | // CCsConversationCache::GetConversationFromConversationId | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 713 | // ---------------------------------------------------------------------------- | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 714 | CCsClientConversation* CCsConversationCache::GetConversationFromConversationIdL(TInt aConversationId) | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 715 |     {
 | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 716 | |
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 717 | CCsClientConversation* clientConv = NULL; | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 718 | |
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 719 | for ( TInt loop = 0; loop < iConversationList->Count(); ++loop ) | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 720 |        {
 | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 721 | CCsConversation* conversation = | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 722 | static_cast<CCsConversation*>((*iConversationList)[loop]); | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 723 | |
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 724 | if (aConversationId == conversation->GetConversationId()) | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 725 |               {
 | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 726 | clientConv = CreateClientConvLC(conversation, conversation->GetLatestEntryL()); | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 727 | CleanupStack::Pop(); | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 728 | break; | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 729 | } | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 730 | } | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 731 | return clientConv; | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 732 | } | 
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 733 | |
| 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
43diff
changeset | 734 | // ---------------------------------------------------------------------------- | 
| 31 | 735 | // CCsConversationCache::GetConversationFromMessageIdL | 
| 736 | // --------------------------------------------------------------------------- | |
| 737 | CCsClientConversation* CCsConversationCache::GetConversationFromMessageIdL(TInt aMessageId) | |
| 738 | {
 | |
| 739 | TInt conversationCount = iConversationList->Count(); | |
| 52 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 740 | CCsClientConversation *clientConv = NULL; | 
| 31 | 741 | for ( TInt loop = 0; loop < conversationCount; loop++ ) | 
| 742 |     {
 | |
| 743 | CCsConversation* conversation = | |
| 744 | static_cast<CCsConversation*>((*iConversationList)[loop]); | |
| 745 | ||
| 746 | // Get the conversation entries | |
| 747 | RPointerArray<CCsConversationEntry> entryList; | |
| 748 | conversation->GetEntryListL(&entryList); | |
| 749 | ||
| 750 | for ( TInt loop1 = 0; loop1 < entryList.Count(); loop1++ ) | |
| 751 |         {
 | |
| 752 | TInt messageId = entryList[loop1]->EntryId(); | |
| 753 | if ( messageId == aMessageId ) | |
| 754 |             {
 | |
| 52 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 755 | clientConv = CreateClientConvLC(conversation, entryList[loop1]); | 
| 31 | 756 | CleanupStack::Pop(); | 
| 52 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 757 | break; | 
| 31 | 758 | } | 
| 759 | } | |
| 760 | } | |
| 52 
12db4185673b
Revision: 201031
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
44diff
changeset | 761 | return clientConv; | 
| 31 | 762 | } | 
| 763 | ||
| 764 | //end of file |