Beispiel #1
0
void IRCSession::processCommandNames(shared_ptr<IRCCommandNames> command)
{
	OS_ASSERT(command != nullptr);

	OS_LOCK(m_dataCS);	

	Rooms::const_iterator r = m_rooms.find(command->getChannel());
	if(r == m_rooms.end())
	{
		OS_ASSERTFALSE();
		return;
	}

	shared_ptr<IRCRoom> room = r->second;
	OS_ASSERT(room != nullptr);
	
	const IRCCommandNames::Users &users = command->getUsers();
	for(IRCCommandNames::Users::const_iterator i = users.begin(); i != users.end(); ++i)
	{
		std::string nickname;
		IRCUserType userType = ircUserTypeNormal;
		if(IRCParser::parseNickname(*i, nickname, userType))
		{	
			shared_ptr<IRCRoom::UserDetails> userDetails = room->ensureUser(ensureUser(nickname));				
			OS_ASSERT(userDetails != nullptr);
			if(userDetails != nullptr)
				userDetails->setType(userType);
		}
	}	
}
Beispiel #2
0
shared_ptr<IRCRoom::UserDetails> IRCRoom::getLocalUserDetails()
{
	shared_ptr<IRCSession> session = getSession();
	if(session == nullptr)
		return nullptr;

	shared_ptr<IRCUser> user = session->getLocalUser();
	if(user == nullptr)
	{
		OS_ASSERTFALSE();
		return nullptr;
	}

	return ensureUser(user);
}
Beispiel #3
0
void IRCSession::processCommandMessage(shared_ptr<IRCCommandMessage> command)
{
	OS_ASSERT(command != nullptr);

	OS_LOCK(m_dataCS);

	if(isLocalUser(command->getTarget()))
	{
		std::string name;
		IRCUserType type = ircUserTypeNormal;
		if(IRCParser::parseNickname(command->getSender(), name, type))
		{
			OS_ASSERT(type == ircUserTypeNormal);
			ensureRoom(ensureUser(name), true);			
		}
	}
}
Beispiel #4
0
void IRCSession::processCommandJoin(shared_ptr<IRCCommandJoin> command)
{
	OS_ASSERT(command != nullptr);

	shared_ptr<IRCRoom> room;

	{
		OS_LOCK(m_dataCS);

		const std::string &channelName = command->getChannel();

		shared_ptr<IRCChannel> channel;

		Rooms::const_iterator i = m_rooms.find(channelName);
		
		if(isLocalUser(command->getNick()))
			channel = ensureChannel(channelName);
		else
			channel = findChannel(channelName);
		
		if(channel != nullptr)
		{
			room = ensureRoom(channel, false);
			OS_ASSERT(room != nullptr);

			std::string nickname;
			IRCUserType userType = ircUserTypeNormal;
			if(IRCParser::parseNickname(command->getNick(), nickname, userType))
			{
				shared_ptr<IRCRoom::UserDetails> userDetails = room->ensureUser(ensureUser(nickname));				
				OS_ASSERT(userDetails != nullptr);
				if(userDetails != nullptr)
					userDetails->setType(userType);
			}
		}		
	}

	if(room != nullptr)
		updateRoom(room, false);	
}
Beispiel #5
0
shared_ptr<IRCUser> IRCSession::getLocalUser()
{
	OS_LOCK(m_dataCS);
	return ensureUser(m_nick);
}