author | Simon Howkins <simonh@symbian.org> |
Mon, 29 Nov 2010 11:18:43 +0000 | |
branch | RCL_3 |
changeset 37 | 7506649dda4d |
parent 34 | e7f34e614544 |
permissions | -rw-r--r-- |
29 | 1 |
/* |
2 |
* Copyright (c) 2007-2008 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: container class for im messages |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "cimcvenginechatcontainer.h" |
|
20 |
||
21 |
#include "cimcvenginemessagecontainer.h" |
|
22 |
#include "mimcvenginenewmsgobserver.h" |
|
23 |
#include "mimcvenginemessage.h" |
|
24 |
#include <hal.h> |
|
25 |
#include "imcvlogger.h" |
|
26 |
#include "mimcvenginechatlistobserver.h" |
|
27 |
||
28 |
||
29 |
#include <hal.h> |
|
30 |
||
31 |
const TInt KMinAvailableMemory = 0x32000; // 200kb |
|
32 |
||
33 |
//----------------------------------------------------------------------------- |
|
34 |
// CIMCVEngineChatContainer::CIMCVEngineChatContainer |
|
35 |
// ( Other items commented in header ) |
|
36 |
//----------------------------------------------------------------------------- |
|
37 |
CIMCVEngineChatContainer::CIMCVEngineChatContainer(TInt aServiceId): |
|
38 |
iServiceId( aServiceId ) |
|
39 |
{ |
|
40 |
} |
|
41 |
||
42 |
//----------------------------------------------------------------------------- |
|
43 |
// CIMCVEngineChatContainer::CIMCVEngineChatContainer |
|
44 |
// ( Other items commented in header ) |
|
45 |
//----------------------------------------------------------------------------- |
|
46 |
CIMCVEngineChatContainer::~CIMCVEngineChatContainer() |
|
47 |
{ |
|
48 |
iChatContainer.ResetAndDestroy(); |
|
49 |
iSendContainer.ResetAndDestroy(); |
|
50 |
iNewMsgObserver = NULL; |
|
51 |
iChatListObservers.Reset(); |
|
52 |
} |
|
53 |
||
54 |
//----------------------------------------------------------------------------- |
|
55 |
// CIMCVEngineChatContainer::NewL |
|
56 |
// ( Other items commented in header ) |
|
57 |
//----------------------------------------------------------------------------- |
|
58 |
CIMCVEngineChatContainer* CIMCVEngineChatContainer::NewL(TInt aServiceId) |
|
59 |
{ |
|
60 |
CIMCVEngineChatContainer* self = |
|
61 |
new ( ELeave ) CIMCVEngineChatContainer(aServiceId); |
|
62 |
||
63 |
return self; |
|
64 |
} |
|
65 |
||
66 |
//----------------------------------------------------------------------------- |
|
67 |
// CIMCVEngineChatContainer::MessageReadInterfaceL |
|
68 |
// ( Other items commented in header ) |
|
69 |
//----------------------------------------------------------------------------- |
|
70 |
MIMCVEngineMessageReadInterface& CIMCVEngineChatContainer::MessageReadInterfaceL( |
|
71 |
TInt aServiceId, |
|
72 |
const TDesC& aTargetId, |
|
73 |
const TDesC& aDisplayName, |
|
74 |
const TDesC8& aContactLink, |
|
75 |
MIMCVEngineMessageReadInterface::TContainerType aType ) |
|
76 |
{ |
|
77 |
return *ChatL( ChatL( aServiceId, aTargetId,aDisplayName,aContactLink,aType ) ); |
|
78 |
} |
|
79 |
||
80 |
//----------------------------------------------------------------------------- |
|
81 |
// CIMCVEngineChatContainer::MessageWriteInterfaceL |
|
82 |
// ( Other items commented in header ) |
|
83 |
//----------------------------------------------------------------------------- |
|
84 |
MIMCVEngineMessageWriteInterface& CIMCVEngineChatContainer::MessageWriteInterfaceL( |
|
85 |
TInt aServiceId, |
|
86 |
const TDesC& aTargetId, |
|
87 |
const TDesC& aDisplayName, |
|
88 |
const TDesC8& aContactLink, |
|
89 |
MIMCVEngineMessageReadInterface::TContainerType aType ) |
|
90 |
{ |
|
91 |
return *ChatL( ChatL( aServiceId, aTargetId, aDisplayName, aContactLink , aType ) ); |
|
92 |
} |
|
93 |
||
94 |
//----------------------------------------------------------------------------- |
|
95 |
// CIMCVEngineChatContainer::DeleteChatL |
|
96 |
// ( Other items commented in header ) |
|
97 |
//----------------------------------------------------------------------------- |
|
98 |
void CIMCVEngineChatContainer::DeleteChatL( |
|
99 |
TInt aServiceId, |
|
100 |
const TDesC& aTargetId ) |
|
101 |
{ |
|
102 |
// Find out if chat exist or not. ChatExists() not used, |
|
103 |
// because we need index. |
|
104 |
CIMCVEngineMessageContainer* tempChat = CreateContainerLC( |
|
105 |
aServiceId, |
|
106 |
aTargetId, |
|
107 |
KNullDesC, |
|
108 |
KNullDesC8, |
|
109 |
*this, |
|
110 |
MIMCVEngineMessageReadInterface::ENoneContainer ); |
|
111 |
TInt index( FindChat( *tempChat ) ); |
|
112 |
CleanupStack::PopAndDestroy( tempChat ); |
|
113 |
||
114 |
// If index is positive value, Chat exists and we can remove it. |
|
115 |
if( index >= 0 ) |
|
116 |
{ |
|
117 |
CIMCVEngineMessageContainer* target = ChatL( index, EFalse ); |
|
118 |
||
119 |
// Get count of pending messages before removing chat |
|
120 |
TInt ignore; |
|
121 |
TInt pendignMsgs = MessagesPendingCount( ignore ); |
|
122 |
||
123 |
RemoveChat( index ); |
|
124 |
||
125 |
// Check if removed chat had unread messages |
|
126 |
if( pendignMsgs != MessagesPendingCount( ignore ) ) |
|
127 |
{ |
|
128 |
// Notify about changed unread count |
|
129 |
HandleChatEventL( EUnreadCountChanged ); |
|
130 |
} |
|
131 |
||
132 |
// Observers are notified, delete target. |
|
133 |
delete target; |
|
134 |
} |
|
135 |
else if( index != KErrNotFound ) |
|
136 |
{ |
|
137 |
// some other error than not found occurred. Inform caller. |
|
138 |
User::Leave( index ); |
|
139 |
} |
|
140 |
} |
|
141 |
||
142 |
//----------------------------------------------------------------------------- |
|
143 |
// CIMCVEngineChatContainer::CloseAllContainers |
|
144 |
// ( Other items commented in header ) |
|
145 |
//----------------------------------------------------------------------------- |
|
146 |
void CIMCVEngineChatContainer::CloseAllContainers() |
|
147 |
{ |
|
148 |
IM_CV_LOGS(TXT("CIMCVEngineChatContainer::CloseAllContainers() START") ); |
|
149 |
TInt count( iChatListObservers.Count() ); |
|
150 |
for( TInt a( 0 ); a < count; ++a ) |
|
151 |
{ |
|
152 |
IM_CV_LOGS(TXT("CIMCVEngineChatContainer::CloseAllContainers() closing container ") ); |
|
153 |
iChatListObservers[ a ]->HandleChatListEvent( iServiceId, EChatAllItemDeleted, NULL ); |
|
154 |
} |
|
34
e7f34e614544
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
29
diff
changeset
|
155 |
iChatContainer.ResetAndDestroy(); |
29 | 156 |
IM_CV_LOGS(TXT("CIMCVEngineChatContainer::CloseAllContainers() End") ); |
157 |
} |
|
158 |
||
159 |
//----------------------------------------------------------------------------- |
|
160 |
// CIMCVEngineChatContainer::ChatCount |
|
161 |
// ( Other items commented in header ) |
|
162 |
//----------------------------------------------------------------------------- |
|
163 |
TInt CIMCVEngineChatContainer::ChatCount() const |
|
164 |
{ |
|
165 |
return iChatContainer.Count(); |
|
166 |
} |
|
167 |
||
168 |
//----------------------------------------------------------------------------- |
|
169 |
// CIMCVEngineChatContainer::ChatAt |
|
170 |
// ( Other items commented in header ) |
|
171 |
//----------------------------------------------------------------------------- |
|
172 |
MIMCVEngineMessageReadInterface& CIMCVEngineChatContainer::ChatAt( TInt aIndex ) const |
|
173 |
{ |
|
174 |
//__CHAT_ASSERT_DEBUG( aIndex >= 0 && aIndex < ChatCount() ) |
|
175 |
return *iChatContainer[ aIndex ]; |
|
176 |
} |
|
177 |
||
178 |
||
179 |
//----------------------------------------------------------------------------- |
|
180 |
// CIMCVEngineChatContainer::RegisterNewMsgObserver |
|
181 |
// ( Other items commented in header ) |
|
182 |
//----------------------------------------------------------------------------- |
|
183 |
void CIMCVEngineChatContainer::RegisterNewMsgObserver( MIMCVEngineNewMsgObserver* aObserver ) |
|
184 |
{ |
|
185 |
iNewMsgObserver = aObserver; |
|
186 |
} |
|
187 |
||
188 |
//----------------------------------------------------------------------------- |
|
189 |
// CIMCVEngineChatContainer::UnregisterNewMsgObserver |
|
190 |
// ( Other items commented in header ) |
|
191 |
//----------------------------------------------------------------------------- |
|
192 |
void CIMCVEngineChatContainer::UnregisterNewMsgObserver() |
|
193 |
{ |
|
194 |
iNewMsgObserver = NULL; |
|
195 |
} |
|
196 |
||
197 |
//----------------------------------------------------------------------------- |
|
198 |
// CIMCVEngineChatContainer::RegisterChatListObserver |
|
199 |
// ( Other items commented in header ) |
|
200 |
//----------------------------------------------------------------------------- |
|
201 |
TInt CIMCVEngineChatContainer::RegisterChatListObserver( MIMCVEngineChatListObserver* aObserver ) |
|
202 |
{ |
|
203 |
TInt index = iChatListObservers.Find( aObserver ); |
|
204 |
if( index == KErrNotFound ) |
|
205 |
{ |
|
206 |
return iChatListObservers.Append( aObserver ); |
|
207 |
} |
|
208 |
return KErrAlreadyExists; |
|
209 |
} |
|
210 |
||
211 |
//----------------------------------------------------------------------------- |
|
212 |
// CIMCVEngineChatContainer::UnregisterChatListObserver |
|
213 |
// ( Other items commented in header ) |
|
214 |
//----------------------------------------------------------------------------- |
|
215 |
TInt CIMCVEngineChatContainer::UnregisterChatListObserver( MIMCVEngineChatListObserver* aObserver ) |
|
216 |
{ |
|
217 |
TInt index = iChatListObservers.Find( aObserver ); |
|
218 |
if( index >= 0 ) |
|
219 |
{ |
|
220 |
iChatListObservers.Remove( index ); |
|
221 |
return KErrNone; |
|
222 |
} |
|
223 |
return index; |
|
224 |
} |
|
225 |
||
226 |
//----------------------------------------------------------------------------- |
|
227 |
// CIMCVEngineChatContainer::PendingMessagesCount |
|
228 |
// ( Other items commented in header ) |
|
229 |
//----------------------------------------------------------------------------- |
|
230 |
TInt CIMCVEngineChatContainer::MessagesPendingCount( TInt& aCountOfChats, |
|
231 |
MIMCVEngineMessageReadInterface::TUnreadFilter aUnreadFilter |
|
232 |
/*= MIMCVEngineMessageReadInterface::EUnreadAll*/ ) const |
|
233 |
{ |
|
234 |
TInt count( ChatCount() ); |
|
235 |
TInt pendingCount( 0 ); |
|
236 |
aCountOfChats = 0; |
|
237 |
for( TInt a( 0 ); a < count; ++a ) |
|
238 |
{ |
|
239 |
TInt unreadCount = ChatAt( a ).UnreadCount( aUnreadFilter ); |
|
240 |
if( unreadCount > 0 ) |
|
241 |
{ |
|
242 |
pendingCount += unreadCount; |
|
243 |
++aCountOfChats; |
|
244 |
} |
|
245 |
} |
|
246 |
return pendingCount; |
|
247 |
} |
|
248 |
||
249 |
||
250 |
//----------------------------------------------------------------------------- |
|
251 |
// CIMCVEngineChatContainer::MessageInterface |
|
252 |
// ( Other items commented in header ) |
|
253 |
//----------------------------------------------------------------------------- |
|
254 |
TBool CIMCVEngineChatContainer::FreeMemoryIfNeededL( TInt aSize ) |
|
255 |
{ |
|
256 |
//CHAT_DP_FUNC_ENTER( "CIMCVEngineChatContainer::FreeMemoryIfNeededL" ); |
|
257 |
||
258 |
TInt halSize; |
|
259 |
TInt biggestBlock; |
|
260 |
||
261 |
HAL::Get( HALData::EMemoryRAMFree, halSize ); |
|
262 |
TInt maxHeap = Min( User::Heap().MaxLength(), halSize ); |
|
263 |
TInt available = maxHeap - ( User::Heap().Size() - User::Heap().Available( biggestBlock ) ); |
|
264 |
TInt memoryNeed = KMinAvailableMemory + aSize; |
|
265 |
||
266 |
TTime oldestUnread; |
|
267 |
TInt unreadIndex; |
|
268 |
||
269 |
IM_CV_LOGS(TXT( "CIMCVEngineChatContainer::FreeMemoryIfNeededL, heapSize = %d"), maxHeap ); |
|
270 |
IM_CV_LOGS(TXT( "****heapSize, available, need = %d, %d, %d"), |
|
271 |
maxHeap, available, memoryNeed ); |
|
272 |
||
273 |
TBool ready = EFalse; |
|
274 |
TBool memLowNotified = EFalse; |
|
275 |
while( !ready ) |
|
276 |
{ |
|
277 |
TBool freeMemoryNeeded( EFalse ); |
|
278 |
if( iExternalMemoryHandler ) |
|
279 |
{ |
|
280 |
freeMemoryNeeded = !iExternalMemoryHandler->FreeMemoryIfNeededL( aSize ); |
|
281 |
} |
|
282 |
if( freeMemoryNeeded || memoryNeed > available ) |
|
283 |
{ |
|
284 |
// we have to react. |
|
285 |
TInt count = ChatCount(); |
|
286 |
||
287 |
// Check how much memory can be made free |
|
288 |
TInt freeableBytes = 0; |
|
289 |
for( TInt i = 0; i < count; ++i ) |
|
290 |
{ |
|
291 |
TBool locked = iChatContainer[i]->IsLocked(); |
|
292 |
if ( iChatContainer[i]->AllMessagesCount() && !locked ) |
|
293 |
{ |
|
294 |
freeableBytes += iChatContainer[i]->ContainerSizeInBytes(); |
|
295 |
} |
|
296 |
} |
|
297 |
||
298 |
if ( ( ( available + freeableBytes ) < memoryNeed ) |
|
299 |
&& !memLowNotified ) |
|
300 |
{ |
|
301 |
// Can't free enough memory |
|
302 |
return EFalse; |
|
303 |
} |
|
304 |
||
305 |
oldestUnread.HomeTime(); |
|
306 |
unreadIndex = KErrNotFound; |
|
307 |
||
308 |
for( TInt a( 0 ); a < count; ++a ) |
|
309 |
{ |
|
310 |
MIMCVEngineMessageReadInterface& chat = ChatAt( a ); |
|
311 |
TBool locked = iChatContainer[ a ]->IsLocked(); |
|
312 |
if( iChatContainer[ a ]->AllMessagesCount() && !locked ) |
|
313 |
{ |
|
314 |
MIMCVEngineMessage& message = iChatContainer[ a ]->MessageFromAll( 0 ); |
|
315 |
if( oldestUnread > message.TimeStamp() ) |
|
316 |
{ |
|
317 |
oldestUnread = message.TimeStamp(); |
|
318 |
unreadIndex = a; |
|
319 |
} |
|
320 |
} |
|
321 |
} |
|
322 |
||
323 |
if( unreadIndex == KErrNotFound ) |
|
324 |
{ |
|
325 |
return EFalse; |
|
326 |
} |
|
327 |
else |
|
328 |
{ |
|
329 |
// Inform observers about memory handling |
|
330 |
if ( !memLowNotified ) |
|
331 |
{ |
|
332 |
HandleChatEventL( EMemoryLow ); |
|
333 |
memLowNotified = ETrue; |
|
334 |
} |
|
335 |
iChatContainer[ unreadIndex ]->DeleteMessageFromAll( 0 ); |
|
336 |
} |
|
337 |
available = maxHeap - ( User::Heap().Size() - User::Heap().Available( biggestBlock ) ); |
|
338 |
IM_CV_LOGS(TXT( "****heapSize, available, need = %d, %d, %d"), |
|
339 |
maxHeap, available, memoryNeed ); |
|
340 |
} |
|
341 |
else |
|
342 |
{ |
|
343 |
ready = ETrue; |
|
344 |
} |
|
345 |
} |
|
346 |
//CHAT_DP_FUNC_DONE( "CIMCVEngineChatContainer::FreeMemoryIfNeededL" ); |
|
347 |
return ETrue; |
|
348 |
} |
|
349 |
||
350 |
//----------------------------------------------------------------------------- |
|
351 |
// CIMCVEngineChatContainer::HandleChatEventL |
|
352 |
// ( Other items commented in header ) |
|
353 |
//----------------------------------------------------------------------------- |
|
354 |
void CIMCVEngineChatContainer::HandleChatEventL( TChatEventType aEvent, |
|
355 |
MIMCVEngineMessage* aMessage ) |
|
356 |
{ |
|
357 |
if( iNewMsgObserver ) |
|
358 |
{ |
|
359 |
iNewMsgObserver->HandleChatEventL( aEvent, aMessage ); |
|
360 |
} |
|
361 |
} |
|
362 |
||
363 |
||
364 |
//----------------------------------------------------------------------------- |
|
365 |
// CIMCVEngineChatContainer::ChatL |
|
366 |
// ( Other items commented in header ) |
|
367 |
//----------------------------------------------------------------------------- |
|
368 |
TInt CIMCVEngineChatContainer::ChatL( |
|
369 |
TInt aServiceId, |
|
370 |
const TDesC& aTargetId, |
|
371 |
const TDesC& aDisplayName, |
|
372 |
const TDesC8& aContactLink, |
|
373 |
MIMCVEngineMessageReadInterface::TContainerType aType |
|
374 |
/*= MIMCVEngineMessageReadInterface::ENoneContainer*/ ) |
|
375 |
{ |
|
376 |
IM_CV_LOGS(TXT("CIMCVEngineChatContainer::ChatL aName= %S"),&aDisplayName ); |
|
377 |
||
378 |
IM_CV_LOGS(TXT("CIMCVEngineChatContainer::ChatL aLink= %S"),&aContactLink); |
|
379 |
||
380 |
CIMCVEngineMessageContainer* tempChat = |
|
381 |
CreateContainerLC( aServiceId, aTargetId, aDisplayName, aContactLink, *this, aType ); |
|
382 |
||
383 |
TInt index( FindChat( *tempChat ) ); |
|
384 |
if( index == KErrNotFound ) |
|
385 |
{ |
|
386 |
IM_CV_LOGS(TXT("CIMCVEngineChatContainer::ChatL,Chat not found creating with aName %S"),&aDisplayName ); |
|
387 |
IM_CV_LOGS(TXT("CIMCVEngineChatContainer::ChatL,Chat not found creating with xspId %S"),&aTargetId ); |
|
388 |
||
389 |
TLinearOrder< CIMCVEngineMessageContainer > order( |
|
390 |
CIMCVEngineMessageContainer::OrderUid ); |
|
391 |
// User::LeaveIfError returns value if value is positive. |
|
392 |
iLatestType = tempChat->ContainerType(); |
|
393 |
switch( iLatestType ) |
|
394 |
{ |
|
395 |
case MIMCVEngineMessageReadInterface::EChatContainer: |
|
396 |
{ |
|
397 |
User::LeaveIfError( iChatContainer.InsertInOrder( tempChat, |
|
398 |
order ) ); |
|
399 |
index = FindChat( *tempChat ); |
|
400 |
iChatContainer[ index ]->SetChatObserver( this ); |
|
401 |
||
402 |
HandleChatListEvent( EChatItemAdded, *tempChat ); |
|
403 |
break; |
|
404 |
} |
|
405 |
case MIMCVEngineMessageReadInterface::ESendContainer: |
|
406 |
{ |
|
407 |
User::LeaveIfError( iSendContainer.InsertInOrder( tempChat, |
|
408 |
order ) ); |
|
409 |
||
410 |
index = FindChat( *tempChat ); |
|
411 |
break; |
|
412 |
} |
|
413 |
default: |
|
414 |
{ |
|
415 |
User::Leave( KErrArgument ); |
|
416 |
break; |
|
417 |
} |
|
418 |
} |
|
419 |
CleanupStack::Pop( tempChat ); |
|
420 |
} |
|
421 |
else |
|
422 |
{ |
|
423 |
// if contact link is null |
|
424 |
if(!(iChatContainer[ index ]->ContactLink().Length())) |
|
425 |
{ |
|
426 |
if( (aContactLink.Length() > 0) && (iLatestType == MIMCVEngineMessageReadInterface::EChatContainer)) |
|
427 |
{ |
|
428 |
iChatContainer[ index ]->SetLinkL(aContactLink); |
|
429 |
} |
|
430 |
} |
|
431 |
CleanupStack::PopAndDestroy( tempChat ); |
|
432 |
} |
|
433 |
||
434 |
return User::LeaveIfError( index ); |
|
435 |
} |
|
436 |
||
437 |
//----------------------------------------------------------------------------- |
|
438 |
// CIMCVEngineChatContainer::ChatL |
|
439 |
// ( Other items commented in header ) |
|
440 |
//----------------------------------------------------------------------------- |
|
441 |
CIMCVEngineMessageContainer* CIMCVEngineChatContainer::ChatL( TInt aIndex, |
|
442 |
TBool aResetLatest /* = ETrue*/ ) |
|
443 |
{ |
|
444 |
MIMCVEngineMessageReadInterface::TContainerType type = iLatestType; |
|
445 |
||
446 |
if( aResetLatest ) |
|
447 |
{ |
|
448 |
iLatestType = MIMCVEngineMessageReadInterface::ENoneContainer; |
|
449 |
} |
|
450 |
||
451 |
switch( type ) |
|
452 |
{ |
|
453 |
||
454 |
case MIMCVEngineMessageReadInterface::EChatContainer: |
|
455 |
{ |
|
456 |
return iChatContainer[ aIndex ]; |
|
457 |
} |
|
458 |
case MIMCVEngineMessageReadInterface::ESendContainer: |
|
459 |
{ |
|
460 |
return iSendContainer[ aIndex ]; |
|
461 |
} |
|
462 |
default: |
|
463 |
{ |
|
464 |
User::Leave( KErrArgument ); |
|
465 |
break; |
|
466 |
} |
|
467 |
} |
|
468 |
// Can never get this far |
|
469 |
//__CHAT_ASSERT_DEBUG( EFalse ); |
|
470 |
return NULL; |
|
471 |
} |
|
472 |
||
473 |
//----------------------------------------------------------------------------- |
|
474 |
// CIMCVEngineChatContainer::RemoveChatL |
|
475 |
// ( Other items commented in header ) |
|
476 |
//----------------------------------------------------------------------------- |
|
477 |
void CIMCVEngineChatContainer::RemoveChat( TInt aIndex, |
|
478 |
TBool aResetLatest /* = ETrue */ ) |
|
479 |
{ |
|
480 |
MIMCVEngineMessageReadInterface::TContainerType type = iLatestType; |
|
481 |
||
482 |
if( aResetLatest ) |
|
483 |
{ |
|
484 |
iLatestType = MIMCVEngineMessageReadInterface::ENoneContainer; |
|
485 |
} |
|
486 |
||
487 |
switch( type ) |
|
488 |
{ |
|
489 |
case MIMCVEngineMessageReadInterface::EChatContainer: |
|
490 |
{ |
|
491 |
HandleChatListEvent( EChatItemDeleted, *iChatContainer[aIndex] ); |
|
492 |
iChatContainer.Remove( aIndex ); |
|
493 |
break; |
|
494 |
} |
|
495 |
case MIMCVEngineMessageReadInterface::ESendContainer: |
|
496 |
{ |
|
497 |
||
498 |
iSendContainer.Remove( aIndex ); |
|
499 |
break; |
|
500 |
} |
|
501 |
default: |
|
502 |
{ |
|
503 |
break; |
|
504 |
} |
|
505 |
} |
|
506 |
} |
|
507 |
||
508 |
//----------------------------------------------------------------------------- |
|
509 |
// CIMCVEngineChatContainer::FindChat |
|
510 |
// ( Other items commented in header ) |
|
511 |
//----------------------------------------------------------------------------- |
|
512 |
TInt CIMCVEngineChatContainer::FindChat( const CIMCVEngineMessageContainer& aChat ) |
|
513 |
{ |
|
514 |
||
515 |
TInt index( 0 ); |
|
516 |
TLinearOrder< CIMCVEngineMessageContainer > order( CIMCVEngineMessageContainer::OrderUid ); |
|
517 |
TInt status = iChatContainer.FindInOrder( &aChat, index, order ); |
|
518 |
if( status == KErrNone ) |
|
519 |
{ |
|
520 |
iLatestType = MIMCVEngineMessageReadInterface::EChatContainer; |
|
521 |
return index; |
|
522 |
} |
|
523 |
||
524 |
iLatestType = MIMCVEngineMessageReadInterface::ESendContainer; |
|
525 |
status = iSendContainer.FindInOrder( &aChat, index, order ); |
|
526 |
return ( status == KErrNone ? index : status ); |
|
527 |
} |
|
528 |
||
529 |
//----------------------------------------------------------------------------- |
|
530 |
// CIMCVEngineChatContainer::CreateContainerLC |
|
531 |
// ( Other items commented in header ) |
|
532 |
//----------------------------------------------------------------------------- |
|
533 |
CIMCVEngineMessageContainer* CIMCVEngineChatContainer::CreateContainerLC( |
|
534 |
TInt aServiceId, |
|
535 |
const TDesC& aTargetId, |
|
536 |
const TDesC& aDisplayName, |
|
537 |
const TDesC8& aContactLink, |
|
538 |
MIMCVEngineBufferMemoryHandler& aMemoryHandler, |
|
539 |
MIMCVEngineMessageReadInterface::TContainerType aType ) |
|
540 |
{ |
|
541 |
||
542 |
CIMCVEngineMessageContainer* messageContainer = CIMCVEngineMessageContainer::NewL( |
|
543 |
aServiceId, |
|
544 |
aTargetId, |
|
545 |
aDisplayName, |
|
546 |
aContactLink, |
|
547 |
aMemoryHandler, |
|
548 |
aType ); |
|
549 |
CleanupStack::PushL( messageContainer ); |
|
550 |
return messageContainer; |
|
551 |
} |
|
552 |
||
553 |
||
554 |
// --------------------------------------------------------- |
|
555 |
// CIMCVEngineChatContainer::MemoryHandler |
|
556 |
// --------------------------------------------------------- |
|
557 |
// |
|
558 |
MIMCVEngineBufferMemoryHandler& CIMCVEngineChatContainer::MemoryHandler() |
|
559 |
{ |
|
560 |
return *this; |
|
561 |
} |
|
562 |
||
563 |
||
564 |
// --------------------------------------------------------- |
|
565 |
// CIMCVEngineChatContainer::HandleChatListEvent |
|
566 |
// --------------------------------------------------------- |
|
567 |
// |
|
568 |
void CIMCVEngineChatContainer::HandleChatListEvent( TChatListEventType aEvent, |
|
569 |
MIMCVEngineMessageReadInterface& aContainerInfo ) |
|
570 |
{ |
|
571 |
IM_CV_LOGS (TXT("CIMCVENGINECHATCONTAINER :: HANDLECHATLISTEVENT")); |
|
572 |
// Inform all observer about chat event. |
|
573 |
//TInt count( iChatListObservers.Count() ); //kept for reference |
|
574 |
for( TInt a( 0 ); a < iChatListObservers.Count() ; ++a ) |
|
575 |
{ |
|
576 |
iChatListObservers[ a ]->HandleChatListEvent( iServiceId, aEvent, &aContainerInfo ); |
|
577 |
} |
|
578 |
} |
|
579 |
// end of file |