void CUploadsWnd::OnSecurityBan() { CSingleLock pLock( &Transfers.m_pSection, TRUE ); CList<CUploadFile*> pList; for ( POSITION pos = UploadFiles.GetIterator() ; pos ; ) { CUploadFile* pFile = UploadFiles.GetNext( pos ); if ( IsSelected( pFile ) ) pList.AddTail( pFile ); } while ( ! pList.IsEmpty() ) { CUploadFile* pFile = pList.RemoveHead(); if ( UploadFiles.Check( pFile ) && pFile->GetActive() != NULL ) { CUploadTransfer* pUpload = pFile->GetActive(); IN_ADDR pAddress = pUpload->m_pHost.sin_addr; pUpload->Remove( FALSE ); pLock.Unlock(); Security.Ban( &pAddress, banSession ); pLock.Lock(); } } }
void CUploadFile::Remove() { for ( POSITION pos = m_pTransfers.GetHeadPosition() ; pos ; ) { CUploadTransfer* pUpload = (CUploadTransfer*)m_pTransfers.GetNext( pos ); pUpload->Remove(); } }
void CUploadsWnd::OnUploadsClearCompleted() { CSingleLock pLock( &Transfers.m_pSection, TRUE ); for ( POSITION pos = Uploads.GetIterator() ; pos ; ) { CUploadTransfer* pUpload = Uploads.GetNext( pos ); if ( pUpload->m_nState == upsNull ) pUpload->Remove( FALSE ); } m_wndUploads.Update(); }
void CUploadsWnd::OnTimer(UINT_PTR nIDEvent) { // Reset Selection Timer event (posted by ctrluploads) if ( nIDEvent == 5 ) { m_tSel = 0; return; } const DWORD tNow = GetTickCount(); // Clear event (5 second timer) if ( nIDEvent == 4 ) { CSingleLock pLock( &Transfers.m_pSection ); if ( ! pLock.Lock( 10 ) ) return; //BOOL bCull = Uploads.GetCount( NULL ) > 50; // Obsolete DWORD nCount = 0; for ( POSITION pos = Uploads.GetIterator() ; pos ; ) { CUploadTransfer* pUpload = Uploads.GetNext( pos ); if ( pUpload->m_nState == upsNull ) { if ( ( tNow > pUpload->m_tConnected + Settings.Uploads.ClearDelay ) && ( Settings.Uploads.AutoClear || pUpload->m_nUploaded == 0 || nCount > 30 ) ) pUpload->Remove( FALSE ); else nCount++; } } return; } // Update event (2 second timer) if ( nIDEvent == 2 ) { // If the window is visible or hasn't been updated in 10 seconds if ( ( IsWindowVisible() && IsActive( FALSE ) ) || tNow > m_tLastUpdate + 10*1000 ) { m_wndUploads.Update(); m_tLastUpdate = tNow; } return; } }
void CUploadsWnd::OnTimer(UINT nIDEvent) { // Reset Selection Timer event (posted by ctrluploads) if ( nIDEvent == 5 ) m_tSel = 0; // Clear event (5 second timer) if ( nIDEvent == 4 ) { CSingleLock pLock( &Transfers.m_pSection ); if ( ! pLock.Lock( 10 ) ) return; DWORD tNow = GetTickCount(); BOOL bCull = Uploads.GetCount( NULL ) > 75; for ( POSITION pos = Uploads.GetIterator() ; pos ; ) { CUploadTransfer* pUpload = Uploads.GetNext( pos ); if ( pUpload->m_nState == upsNull && tNow - pUpload->m_tConnected > Settings.Uploads.ClearDelay ) { if ( Settings.Uploads.AutoClear || pUpload->m_nUploaded == 0 || bCull ) { pUpload->Remove( FALSE ); } } } } // Update event (2 second timer) if ( nIDEvent == 2 ) { DWORD tNow = GetTickCount(); // If the window is visible or hasn't been updated in 10 seconds if ( ( IsWindowVisible() && IsActive( FALSE ) ) || ( ( tNow - m_tLastUpdate ) > 10*1000 ) ) { m_wndUploads.Update(); m_tLastUpdate = tNow; } } }