Exemplo n.º 1
0
BOOL CHostBrowser::OnPacket(CG2Packet* pPacket)
{
	switch ( pPacket->m_nType )
	{
	case G2_PACKET_HIT:
		if ( CQueryHit* pHits = CQueryHit::FromG2Packet( pPacket ) )
		{
			OnQueryHits( pHits );
		}
		else
		{
			theApp.Message( MSG_ERROR, IDS_BROWSE_PACKET_ERROR, (LPCTSTR)m_sAddress );
			return FALSE;
		}
		break;

	case G2_PACKET_PHYSICAL_FOLDER:
		if ( m_pNotify != NULL )
			m_pNotify->OnPhysicalTree( pPacket );
		break;

	case G2_PACKET_VIRTUAL_FOLDER:
		if ( m_pNotify != NULL )
			m_pNotify->OnVirtualTree( pPacket );
		break;

	case G2_PACKET_PROFILE_DELIVERY:
		OnProfilePacket( pPacket );
		if ( m_pProfile && m_pNotify )
			m_pNotify->OnProfileReceived();
		break;

	case G2_PACKET_PROFILE_AVATAR:
		if ( m_pNotify != NULL )
			m_pNotify->OnHeadPacket( pPacket );
		break;

	case G2_PACKET_PEER_CHAT:
		if ( ! m_bCanChat )
		{
			m_bCanChat = TRUE;
			if ( m_pNotify )
				m_pNotify->OnProfileReceived();
		}
		break;

#ifdef _DEBUG
	default:
		CString str;
		str.Format( L"Unknown G2 Browse packet from %s:%u",
			(LPCTSTR)CString( inet_ntoa( m_pHost.sin_addr ) ),
			htons( m_pHost.sin_port ) );
		pPacket->Debug( str );
#endif	// Debug
	}

	return TRUE;
}
Exemplo n.º 2
0
BOOL CHostBrowser::OnPacket(CG2Packet* pPacket)
{
	if ( pPacket->IsType( G2_PACKET_HIT ) )
	{
		CQueryHit* pHits = CQueryHit::FromPacket( pPacket );

		if ( pHits == NULL )
		{
			theApp.Message( MSG_ERROR, IDS_BROWSE_PACKET_ERROR, (LPCTSTR)m_sAddress );
			return FALSE;
		}

		m_bCanPush	= TRUE;
		m_pClientID	= pHits->m_pClientID;

		for ( CQueryHit* pCount = pHits ; pCount ; pCount = pCount->m_pNext )
		{
			m_nHits++;
		}

		Downloads.OnQueryHits( pHits );

		if ( ! m_bCanChat && pHits->m_bChat )
		{
			m_bCanChat = TRUE;
			if ( m_pNotify && m_pProfile != NULL ) m_pNotify->OnProfileReceived();
		}

		if ( m_pNotify != NULL )
			m_pNotify->OnBrowseHits( pHits );
		else
			pHits->Delete();
	}
	else if ( pPacket->IsType( G2_PACKET_PHYSICAL_FOLDER ) )
	{
		if ( m_pNotify != NULL ) m_pNotify->OnPhysicalTree( pPacket );
	}
	else if ( pPacket->IsType( G2_PACKET_VIRTUAL_FOLDER ) )
	{
		if ( m_pNotify != NULL ) m_pNotify->OnVirtualTree( pPacket );
	}
	else if ( pPacket->IsType( G2_PACKET_PROFILE_DELIVERY ) )
	{
		OnProfilePacket( pPacket );

		if ( m_pProfile != NULL && m_pNotify != NULL )
		{
			m_pNotify->OnProfileReceived();
		}
	}
	else if ( pPacket->IsType( G2_PACKET_PROFILE_AVATAR ) )
	{
		if ( m_pNotify != NULL ) m_pNotify->OnHeadPacket( pPacket );
	}

	return TRUE;
}