/**
 * @param buddies set of buddies
 * @short Makes chat object that aggregates all chats for given buddy set.
 * @return chat object that aggregates all chats for given buddy set
 *
 * This method will create and return new chat of 'Aggregate' type that
 * contains all chats (for different accounts) for given set of buddies.
 */
Chat AggregateChatManager::aggregateChat(const BuddySet &buddies)
{
	if (!AggregateChats.contains(buddies))
		return Chat::null;

	QList<Chat> chats = AggregateChats[buddies];
	if (chats.count() <= 1)
		return Chat::null;

	Chat result = Chat::create();
	result.setType(chats.at(0).type());

	ChatDetailsAggregate *details = new ChatDetailsAggregate(result);
	details->setChats(chats);
	result.setDetails(details);

	return result;
}