224 PackAndNotifyEventL(EIMOperationUnreadChange, sericeId, iActiveHeader , NULL ); |
224 PackAndNotifyEventL(EIMOperationUnreadChange, sericeId, iActiveHeader , NULL ); |
225 // once request is completed, mark as fetch completed |
225 // once request is completed, mark as fetch completed |
226 } |
226 } |
227 // if there are no unread messages then reset the status pane indicator. |
227 // if there are no unread messages then reset the status pane indicator. |
228 TInt unreadCount = 0; |
228 TInt unreadCount = 0; |
229 TInt currentContactUnReadCount = 0; |
|
230 TInt headerCount = iHeaderArray.Count(); |
229 TInt headerCount = iHeaderArray.Count(); |
231 TInt id = 0; |
|
232 for( TInt i=0; i< headerCount; i++ ) |
230 for( TInt i=0; i< headerCount; i++ ) |
233 { |
231 { |
234 // note in this case reciepient is own user id |
232 // note in this case reciepient is own user id |
235 MIMCacheMessageHeader* header = iHeaderArray[i]; |
233 MIMCacheMessageHeader* header = iHeaderArray[i]; |
236 if( header->ServiceId() == sericeId ) |
234 if( header->ServiceId() == sericeId ) |
237 { |
235 { |
238 if(buddyId->Compare(iHeaderArray[i]->BuddyId()) == 0) |
236 unreadCount = unreadCount + header->UnreadMessageCount(); |
239 { |
|
240 currentContactUnReadCount = header->UnreadMessageCount(); |
|
241 } |
|
242 if(header->UnreadMessageCount()) |
|
243 { |
|
244 id = i; |
|
245 } |
|
246 |
|
247 } |
237 } |
248 } |
238 } |
249 |
239 if(!unreadCount) |
250 if(!currentContactUnReadCount) |
240 { |
251 { |
241 PublishMessageInfoL(*buddyId,sericeId); |
252 PublishMessageInfoL(iHeaderArray[id]->BuddyId(),sericeId); |
|
253 } |
242 } |
254 |
243 |
255 CleanupStack::PopAndDestroy(buddyId); |
244 CleanupStack::PopAndDestroy(buddyId); |
256 |
245 |
257 TRACE( T_LIT( "CCacheServerActiveHelper::StartNewConversationL end") ); |
246 TRACE( T_LIT( "CCacheServerActiveHelper::StartNewConversationL end") ); |
439 iHeaderArray.Remove(headerIndex); |
428 iHeaderArray.Remove(headerIndex); |
440 if(msgHeader == iActiveHeader) |
429 if(msgHeader == iActiveHeader) |
441 { |
430 { |
442 iActiveHeader = NULL; |
431 iActiveHeader = NULL; |
443 } |
432 } |
444 // remove the universal indicator notification if there are no more unread messages, |
433 |
445 // apart form whose conversation is closed. loop through |
|
446 TInt headerCount = iHeaderArray.Count(); |
|
447 headerIndex = KErrNotFound; |
|
448 for( TInt i=0; i< headerCount; i++ ) |
|
449 { |
|
450 // note in this case reciepient is own user id |
|
451 MIMCacheMessageHeader* header = iHeaderArray[i]; |
|
452 TRACE(T_LIT( "CCacheServerActiveHelper::PublishMessageInfoL UnreadMessageCount -- %d"), header->UnreadMessageCount()); |
|
453 if( header->ServiceId() == sericeId && header->UnreadMessageCount() ) |
|
454 { |
|
455 // this is required in the following scenario |
|
456 // you receive 10 new messgaes form two parties(5, each) |
|
457 // whne you close the conversation form one, the universal indicator is still |
|
458 // for the other party's messages, and when clicked on universal indicator it should |
|
459 // open the conversation view wiht the latest user id. |
|
460 headerIndex = i; |
|
461 } |
|
462 } |
|
463 // there are new messages received form only one party. |
|
464 // hence the buddyid is required as conversation view will be openend. |
|
465 if(KErrNone == headerIndex) |
|
466 { |
|
467 PublishMessageInfoL(iHeaderArray[headerIndex]->BuddyId(), sericeId, ETrue); |
|
468 } |
|
469 // new messages are recieved from multiple parties, hence no need of the sender id |
|
470 // as the service tab will be opened. |
|
471 else |
|
472 { |
|
473 PublishMessageInfoL(KNullDesC(), sericeId,ETrue); |
|
474 } |
|
475 PackAndNotifyEventL( EIMOperationChatDeleted, sericeId, msgHeader, NULL ); |
434 PackAndNotifyEventL( EIMOperationChatDeleted, sericeId, msgHeader, NULL ); |
476 |
435 |
477 delete msgHeader; |
436 delete msgHeader; |
478 iHeaderArray.Compress(); |
437 iHeaderArray.Compress(); |
479 |
438 |
508 needToNotify = ETrue; |
467 needToNotify = ETrue; |
509 } |
468 } |
510 } |
469 } |
511 if( needToNotify ) |
470 if( needToNotify ) |
512 { |
471 { |
513 // remove the universal indicator notification if there it was displayed, |
|
514 // as when you logout all the ocnversations are removed. |
|
515 PublishMessageInfoL(KNullDesC(), aServiceId, ETrue); |
|
516 |
|
517 PackAndNotifyEventL( EIMOperationAllChatDeleted, aServiceId, NULL, NULL ); |
472 PackAndNotifyEventL( EIMOperationAllChatDeleted, aServiceId, NULL, NULL ); |
518 } |
473 } |
519 TRACE( T_LIT( "CCacheServerActiveHelper::CloseAllConversationL End") ); |
474 TRACE( T_LIT( "CCacheServerActiveHelper::CloseAllConversationL End") ); |
520 } |
475 } |
521 // --------------------------------------------------------- |
476 // --------------------------------------------------------- |
593 // |
548 // |
594 void CCacheServerActiveHelper::GetServiceChatHeaderArrayL(TInt aServiceId , RPointerArray<MIMCacheMessageHeader>& aServiceHeaderArray) |
549 void CCacheServerActiveHelper::GetServiceChatHeaderArrayL(TInt aServiceId , RPointerArray<MIMCacheMessageHeader>& aServiceHeaderArray) |
595 { |
550 { |
596 TRACE( T_LIT( "CCacheServerActiveHelper::GetServiceChatHeaderArrayL start") ); |
551 TRACE( T_LIT( "CCacheServerActiveHelper::GetServiceChatHeaderArrayL start") ); |
597 |
552 |
598 CleanupClosePushL(aServiceHeaderArray); |
|
599 |
553 |
600 if( -1 == aServiceId ) |
554 if( -1 == aServiceId ) |
601 { |
555 { |
602 aServiceHeaderArray = iHeaderArray; |
556 aServiceHeaderArray = iHeaderArray; |
603 } |
557 } |
610 { |
564 { |
611 aServiceHeaderArray.AppendL(header); |
565 aServiceHeaderArray.AppendL(header); |
612 } |
566 } |
613 } |
567 } |
614 } |
568 } |
615 CleanupStack::Pop(&aServiceHeaderArray); |
|
616 TRACE( T_LIT( "CCacheServerActiveHelper::GetServiceChatHeaderArrayL end") ); |
569 TRACE( T_LIT( "CCacheServerActiveHelper::GetServiceChatHeaderArrayL end") ); |
617 } |
570 } |
618 |
571 |
619 // --------------------------------------------------------- |
572 // --------------------------------------------------------- |
620 // CCacheServerActiveHelper::ChatHeaderL |
573 // CCacheServerActiveHelper::ChatHeaderL |
667 // ----------------------------------------------------------------------------- |
620 // ----------------------------------------------------------------------------- |
668 // CCacheServerActiveHelper::PublishMessageInfoL() |
621 // CCacheServerActiveHelper::PublishMessageInfoL() |
669 // name of history data |
622 // name of history data |
670 // ----------------------------------------------------------------------------- |
623 // ----------------------------------------------------------------------------- |
671 // |
624 // |
672 void CCacheServerActiveHelper::PublishMessageInfoL(const TDesC& aSenderId,TInt aServiceId, |
625 void CCacheServerActiveHelper::PublishMessageInfoL(const TDesC& aSenderId,TInt aServiceId ) |
673 TBool aCloseConversation /*= EFalse*/ ) |
|
674 { |
626 { |
675 // set/reset the status pane indicator here |
627 // set/reset the status pane indicator here |
676 // based on the unread count. |
628 // based on the unread count. |
677 // as we need to show the indicator only for the received messages |
629 // as we need to show the indicator only for the received messages |
678 TInt unreadCount = 0; |
630 TInt unreadCount = 0; |
698 // the next command handler. If none of the plugins leave, there will |
650 // the next command handler. If none of the plugins leave, there will |
699 // be only one TRAP used. |
651 // be only one TRAP used. |
700 for ( TInt index = 0; index < count; ++index ) |
652 for ( TInt index = 0; index < count; ++index ) |
701 { |
653 { |
702 //trap is required if one plugin leaves then it should continue with other plugins. |
654 //trap is required if one plugin leaves then it should continue with other plugins. |
703 TRAP_IGNORE(iPluginInfo[index]->Plugin().MessageInfoL(unreadCount,aServiceId,aSenderId,multipleSender,aCloseConversation)); |
655 TRAP_IGNORE(iPluginInfo[index]->Plugin().MessageInfoL(unreadCount,aServiceId,aSenderId,multipleSender)); |
704 } |
656 } |
705 } |
657 } |
706 // ----------------------------------------------------------------------------- |
658 // ----------------------------------------------------------------------------- |
707 // CCacheServerActiveHelper::LoadPluginL |
659 // CCacheServerActiveHelper::LoadPluginL |
708 // ----------------------------------------------------------------------------- |
660 // ----------------------------------------------------------------------------- |