Esempio n. 1
0
bool ParticipantList::includeInCandidateList( const ContactProfile& contactProfile, const IMChatSession& chatSession, bool& bInChatSession )
{
	bool			  bInclude  = true;
	const IMContact*  imContact = NULL;

	bInChatSession = false;

	if ( _includeOnlyOnline )
	{
		imContact = contactProfile.getFirstAvailableIMContact( const_cast<IMChatSession&>(chatSession) );	//This seems wrong.
	}
	else
	{
		imContact = contactProfile.getPreferredIMContact();
	}

	if ( imContact )
	{
		IMContact* imContact2 = chatSession.getIMContactSet().findByContact( *imContact );	//Don't add IMContacts already in chatsession.

		//Jabber IMContacts for Group Chats are not built correctly (missing domain), so try a second find.
		if ( imContact2 == NULL )
		{
			std::string accountId = imContact->getIMAccountId();
			std::string contactId = imContact->getContactId();
			imContact2 = chatSession.getIMContactSet().findBy( accountId, contactId, true );
		}

		bInChatSession = (imContact2 != NULL);

		if ( _sameNetworkOnly )
		{
			bInclude = (imContact->getProtocol() == chatSession.getIMContactSet().begin()->getProtocol() );	//OK use of getProtocol().
		}
	}

	return bInclude;
}