void CUploadsWnd::OnUploadsClear()
{
	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 ) )
		{
			CUploadTransfer* pUpload = pFile->GetActive();

			if ( pUpload != NULL && pUpload->m_nProtocol == PROTOCOL_ED2K && pUpload->m_nState != upsNull )
			{
				CString strFormat, strMessage;
				LoadString( strFormat, IDS_UPLOAD_CANCEL_ED2K );
				strMessage.Format( strFormat, (LPCTSTR)pUpload->m_sFileName );
				pLock.Unlock();
				UINT nResp = AfxMessageBox( strMessage, MB_ICONQUESTION|MB_YESNOCANCEL|MB_DEFBUTTON2 );
				pLock.Lock();
				if ( nResp == IDCANCEL ) break;
				if ( nResp != IDYES || ! UploadFiles.Check( pFile ) ) continue;
			}

			pFile->Remove();
		}
	}
}
Beispiel #2
0
void CUploadFiles::Remove(CUploadTransfer* pTransfer)
{
	for ( POSITION pos = GetIterator() ; pos ; )
	{
		POSITION posRemove = pos;
		CUploadFile* pFile = GetNext( pos );

		if ( pFile->Remove( pTransfer ) )
		{
			delete pFile;
			m_pList.RemoveAt( posRemove );
		}
	}
}
Beispiel #3
0
void CRemote::PageUploads()
{
	if ( CheckCookie() ) return;
	m_nTab = tabUploads;

	CSingleLock pLock( &UploadQueues.m_pSection, FALSE );
	if ( ! SafeLock( pLock ) )
		return;

	Prepare();		// Header

	CString strRandom;
	strRandom.Format( L"%i", GetRandomNum( 0i32, _I32_MAX ) );
	Add( L"random", strRandom );

	Output( L"uploadsHeader" );

	for ( POSITION posQueue = CUploadsCtrl::GetQueueIterator(); posQueue != NULL; )
	{
		CUploadQueue* pQueue = CUploadsCtrl::GetNextQueue( posQueue );

		CString strQueueID;
		strQueueID.Format( L"%p", pQueue );

		if ( GetKey( L"queue_expand" ) == strQueueID )
			pQueue->m_bExpanded = TRUE;
		else if ( GetKey( L"queue_collapse" ) == strQueueID )
			pQueue->m_bExpanded = FALSE;

		POSITION posFile = CUploadsCtrl::GetFileIterator( pQueue );
		if ( posFile == NULL ) continue;

		Prepare();
		Add( L"queue_id", strQueueID );
		Add( L"queue_caption", pQueue->m_sName );
		if ( pQueue->m_bExpanded )
			Add( L"queue_expanded", L"true" );

		if ( pQueue != UploadQueues.m_pTorrentQueue && pQueue != UploadQueues.m_pHistoryQueue )
		{
			CString str;
			str.Format( L"%u", pQueue->GetTransferCount() );
			Add( L"queue_transfers", str );
			str.Format( L"%u", pQueue->GetQueuedCount() );
			Add( L"queue_queued", str );
			Add( L"queue_bandwidth", Settings.SmartSpeed( pQueue->GetMeasuredSpeed() ) );
		}

		Output( L"uploadsQueueStart" );

		if ( pQueue->m_bExpanded )
		{
			while ( posFile != NULL )
			{
				int nPosition;
				CUploadFile* pFile = CUploadsCtrl::GetNextFile( pQueue, posFile, &nPosition );
				if ( pFile == NULL ) continue;
				CUploadTransfer* pTransfer = pFile->GetActive();

				CString strFileID;
				strFileID.Format( L"%p", pFile );

				if ( GetKey( L"drop" ) == strFileID )
				{
					pFile->Remove();
					continue;
				}

				Add( L"file_id", strFileID );
				Add( L"file_filename", pFile->m_sName );
				Add( L"file_size", Settings.SmartVolume( pFile->m_nSize ) );

				if ( pTransfer != NULL )
				{
					Add( L"file_address", pTransfer->m_sAddress );
					Add( L"file_nick", pTransfer->m_sRemoteNick );
					Add( L"file_user", pTransfer->m_sAddress + L" - " + pTransfer->m_sRemoteNick );
					Add( L"file_agent", pTransfer->m_sUserAgent );
				}

				CString str;
				if ( pTransfer == NULL || pTransfer->m_nState == upsNull )
				{
					LoadString( str, IDS_STATUS_COMPLETED );
				}
				else if ( pTransfer->m_nProtocol == PROTOCOL_BT )
				{
					CUploadTransferBT* pBT = (CUploadTransferBT*)pTransfer;

					if ( ! pBT->m_bInterested )
						LoadString( str, IDS_STATUS_UNINTERESTED );
					else if ( pBT->m_bChoked )
						LoadString( str, IDS_STATUS_CHOKED );
					else if ( DWORD nSpeed = pTransfer->GetMeasuredSpeed() )
						str = Settings.SmartSpeed( nSpeed );
				}
				else if ( nPosition > 0 )
				{
					LoadString( str, IDS_STATUS_Q );
					str.Format( L"%s %i", (LPCTSTR)str, nPosition );
				}
				else
				{
					if ( DWORD nSpeed = pTransfer->GetMeasuredSpeed() )
						str = Settings.SmartSpeed( nSpeed );
					else
						LoadString( str, IDS_STATUS_NEXT );
				}
				Add( L"file_speed", str );
				Add( L"file_status", str );

				Output( L"uploadsFile" );
				Prepare( L"file_" );
			}
		}

		Output( L"uploadsQueueEnd" );
		Prepare( L"queue_" );
	}

	Prepare();
	Output( L"uploadsFooter" );
}