imservices/instantmessagingcache/imcacheserver/src/ccacheserveractivehelper.cpp
branchRCL_3
changeset 22 113b91e0a2ad
parent 21 cfd5c2994f10
equal deleted inserted replaced
21:cfd5c2994f10 22:113b91e0a2ad
   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;
   229     TInt headerCount = iHeaderArray.Count();
   230     TInt headerCount = iHeaderArray.Count();
       
   231     TInt id = 0;
   230     for( TInt i=0; i< headerCount; i++ )
   232     for( TInt i=0; i< headerCount; i++ )
   231         {
   233         {
   232         // note in this case reciepient is own user id 
   234         // note in this case reciepient is own user id 
   233         MIMCacheMessageHeader* header = iHeaderArray[i];
   235         MIMCacheMessageHeader* header = iHeaderArray[i];
   234         if( header->ServiceId() == sericeId )   
   236         if( header->ServiceId() == sericeId )   
   235             {
   237             {
   236             unreadCount = unreadCount + header->UnreadMessageCount();   
   238 			if(buddyId->Compare(iHeaderArray[i]->BuddyId()) == 0)
   237             }
   239 				{
   238         }
   240 				currentContactUnReadCount = header->UnreadMessageCount();
   239     if(!unreadCount)
   241 				}
   240         {
   242             if(header->UnreadMessageCount()) 
   241         PublishMessageInfoL(*buddyId,sericeId);
   243                	{
       
   244 				id = i;
       
   245             	}
       
   246             
       
   247             }
       
   248         }
       
   249     
       
   250     if(!currentContactUnReadCount)
       
   251         {
       
   252 		PublishMessageInfoL(iHeaderArray[id]->BuddyId(),sericeId);
   242         }
   253         }
   243     
   254     
   244 	CleanupStack::PopAndDestroy(buddyId);
   255 	CleanupStack::PopAndDestroy(buddyId);
   245 	
   256 	
   246     TRACE( T_LIT( "CCacheServerActiveHelper::StartNewConversationL	end") );
   257     TRACE( T_LIT( "CCacheServerActiveHelper::StartNewConversationL	end") );
   428         iHeaderArray.Remove(headerIndex);
   439         iHeaderArray.Remove(headerIndex);
   429         if(msgHeader == iActiveHeader)
   440         if(msgHeader == iActiveHeader)
   430             {
   441             {
   431             iActiveHeader = NULL;
   442             iActiveHeader = NULL;
   432             }
   443             }
   433        
   444         // remove the universal indicator notification if there are no more unread messages,
       
   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             }
   434 		PackAndNotifyEventL( EIMOperationChatDeleted, sericeId, msgHeader, NULL ); 
   475 		PackAndNotifyEventL( EIMOperationChatDeleted, sericeId, msgHeader, NULL ); 
   435 		 
   476 		 
   436         delete msgHeader;
   477         delete msgHeader;
   437         iHeaderArray.Compress();  
   478         iHeaderArray.Compress();  
   438        		      
   479        		      
   467             needToNotify = ETrue;
   508             needToNotify = ETrue;
   468             }
   509             }
   469         }
   510         }
   470     if( needToNotify )
   511     if( needToNotify )
   471         {
   512         {
       
   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         
   472         PackAndNotifyEventL( EIMOperationAllChatDeleted, aServiceId, NULL, NULL ); 
   517         PackAndNotifyEventL( EIMOperationAllChatDeleted, aServiceId, NULL, NULL ); 
   473         }
   518         }
   474     TRACE( T_LIT( "CCacheServerActiveHelper::CloseAllConversationL  End") );
   519     TRACE( T_LIT( "CCacheServerActiveHelper::CloseAllConversationL  End") );
   475     }
   520     }
   476 // ---------------------------------------------------------
   521 // ---------------------------------------------------------
   548 //
   593 //
   549 void CCacheServerActiveHelper::GetServiceChatHeaderArrayL(TInt aServiceId , RPointerArray<MIMCacheMessageHeader>& aServiceHeaderArray)
   594 void CCacheServerActiveHelper::GetServiceChatHeaderArrayL(TInt aServiceId , RPointerArray<MIMCacheMessageHeader>& aServiceHeaderArray)
   550 	{
   595 	{
   551 	TRACE( T_LIT( "CCacheServerActiveHelper::GetServiceChatHeaderArrayL	start") );		
   596 	TRACE( T_LIT( "CCacheServerActiveHelper::GetServiceChatHeaderArrayL	start") );		
   552 	
   597 	
       
   598 	CleanupClosePushL(aServiceHeaderArray);
   553    
   599    
   554     if( -1 == aServiceId )
   600     if( -1 == aServiceId )
   555         {
   601         {
   556         aServiceHeaderArray = iHeaderArray;        
   602         aServiceHeaderArray = iHeaderArray;        
   557         }
   603         }
   564                 {
   610                 {
   565                 aServiceHeaderArray.AppendL(header);
   611                 aServiceHeaderArray.AppendL(header);
   566                 }
   612                 }
   567             }        
   613             }        
   568         }
   614         }
       
   615     CleanupStack::Pop(&aServiceHeaderArray);
   569     TRACE( T_LIT( "CCacheServerActiveHelper::GetServiceChatHeaderArrayL    end") );
   616     TRACE( T_LIT( "CCacheServerActiveHelper::GetServiceChatHeaderArrayL    end") );
   570 	}
   617 	}
   571 
   618 
   572 // ---------------------------------------------------------
   619 // ---------------------------------------------------------
   573 // CCacheServerActiveHelper::ChatHeaderL
   620 // CCacheServerActiveHelper::ChatHeaderL
   620 // -----------------------------------------------------------------------------
   667 // -----------------------------------------------------------------------------
   621 // CCacheServerActiveHelper::PublishMessageInfoL()
   668 // CCacheServerActiveHelper::PublishMessageInfoL()
   622 // name of history data
   669 // name of history data
   623 // -----------------------------------------------------------------------------
   670 // -----------------------------------------------------------------------------
   624 //
   671 //
   625 void  CCacheServerActiveHelper::PublishMessageInfoL(const TDesC& aSenderId,TInt aServiceId )
   672 void  CCacheServerActiveHelper::PublishMessageInfoL(const TDesC& aSenderId,TInt aServiceId, 
       
   673                                                     TBool aCloseConversation /*= EFalse*/ )
   626     {
   674     {
   627     // set/reset  the status pane indicator here
   675     // set/reset  the status pane indicator here
   628     // based on the unread count.
   676     // based on the unread count.
   629     // as we need to show the indicator only for the received messages
   677     // as we need to show the indicator only for the received messages
   630     TInt unreadCount = 0;
   678     TInt unreadCount = 0;
   650     // the next command handler. If none of the plugins leave, there will
   698     // the next command handler. If none of the plugins leave, there will
   651     // be only one TRAP used.
   699     // be only one TRAP used.
   652     for ( TInt index = 0; index < count; ++index )
   700     for ( TInt index = 0; index < count; ++index )
   653         {
   701         {
   654         //trap is required if one plugin leaves then it should continue with other plugins.
   702         //trap is required if one plugin leaves then it should continue with other plugins.
   655         TRAP_IGNORE(iPluginInfo[index]->Plugin().MessageInfoL(unreadCount,aServiceId,aSenderId,multipleSender));
   703         TRAP_IGNORE(iPluginInfo[index]->Plugin().MessageInfoL(unreadCount,aServiceId,aSenderId,multipleSender,aCloseConversation));
   656         }
   704         }
   657     }
   705     }
   658  // -----------------------------------------------------------------------------
   706  // -----------------------------------------------------------------------------
   659  // CCacheServerActiveHelper::LoadPluginL
   707  // CCacheServerActiveHelper::LoadPluginL
   660  // -----------------------------------------------------------------------------
   708  // -----------------------------------------------------------------------------