Пример #1
0
void CPrivateChatWnd::OnChatPriority()
{
	if ( ! m_pSession )
		return;

	CSingleLock pLock( &Transfers.m_pSection );
	if ( ! pLock.Lock( 500 ) )
		return;

	DWORD nAddress = m_pSession->m_pHost.sin_addr.s_addr;

	for ( POSITION pos = Uploads.GetIterator() ; pos ; )
	{
		CUploadTransfer* pUpload = Uploads.GetNext( pos );

		if ( pUpload->m_pHost.sin_addr.s_addr == nAddress &&
			 pUpload->m_nState == upsQueued )
		{
			pUpload->Promote();
		}
	}

	CString strMessage;
	strMessage.Format( LoadString( IDS_CHAT_PRIORITY_GRANTED ), (LPCTSTR)HostToString( &m_pSession->m_pHost ) );
	CChatWnd::OnStatusMessage( 2, strMessage );
}
void CPrivateChatFrame::OnChatPriority()
{
	CSingleLock pLock( &Transfers.m_pSection );
	if ( ! pLock.Lock( 500 ) ) return;

	const DWORD nAddress = m_pSession->m_pHost.sin_addr.S_un.S_addr;
	int nCount = 0;

	for ( POSITION pos = Uploads.GetIterator() ; pos ; )
	{
		CUploadTransfer* pUpload = Uploads.GetNext( pos );

		if ( pUpload->m_pHost.sin_addr.S_un.S_addr == nAddress && pUpload->m_nState == upsQueued )
			pUpload->Promote( nCount < 2 ); 	// First couple get unlimited, others dequeued

		nCount++;
	}

	m_pSession->StatusMessage( 2, IDS_CHAT_PRIORITY_GRANTED, (LPCTSTR)m_pSession->m_sAddress, nCount );
}