当前位置: 首页>>代码示例>>C++>>正文


C++ CDownload类代码示例

本文整理汇总了C++中CDownload的典型用法代码示例。如果您正苦于以下问题:C++ CDownload类的具体用法?C++ CDownload怎么用?C++ CDownload使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CDownload类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: l

void CDownloads::start()
{
	QMutexLocker l(&m_pSection);

	QDir d(quazaaSettings.Downloads.IncompletePath);

	if( !d.exists() )
		d.mkpath(quazaaSettings.Downloads.IncompletePath);

	if( d.isReadable() )
	{
		QStringList files = d.entryList(QStringList() << "*.!qd");

		foreach(QString f, files)
		{
			QFile file(quazaaSettings.Downloads.IncompletePath + "/" + f);

			if( file.exists() && file.open(QFile::ReadOnly) )
			{
				CDownload* pDownload = new CDownload();
				QDataStream stream(&file);

				stream >> *pDownload;

				pDownload->moveToThread(&TransfersThread);
				m_lDownloads.append(pDownload);
				emit downloadAdded(pDownload);
				systemLog.postLog( LogSeverity::Notice, Components::Downloads,
				                   qPrintable( tr( "Loaded download: %s" ) ),
				                   qPrintable( pDownload->m_sDisplayName ) );
			}
开发者ID:c3c,项目名称:quazaa,代码行数:31,代码来源:downloads.cpp

示例2: pLock

void CDownloads::ClearPaused()
{
	CSingleLock pLock( &Transfers.m_pSection, TRUE );

	for ( POSITION pos = GetIterator() ; pos ; )
	{
		CDownload* pDownload = GetNext( pos );
		if ( pDownload->IsPaused() ) pDownload->Remove();
	}
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:10,代码来源:Downloads.cpp

示例3: ASSUME_LOCK

void CDownloads::add(CQueryHit *pHit)
{
	ASSUME_LOCK(Downloads.m_pSection);

	CDownload* pDownload = new CDownload(pHit);
	pDownload->moveToThread(&TransfersThread);
	m_lDownloads.append(pDownload);
	pDownload->saveState();
	systemLog.postLog(LogSeverity::Notice, qPrintable(tr("Queued download job for %s")), qPrintable(pDownload->m_sDisplayName));
	emit downloadAdded(pDownload);
}
开发者ID:aboduo,项目名称:quazaa,代码行数:11,代码来源:downloads.cpp

示例4: GetPrevious

BOOL CDownloads::CheckActive(CDownload* pDownload, int nScope) const
{
	for ( POSITION pos = GetReverseIterator() ; pos && nScope > 0 ; )
	{
		CDownload* pTest = GetPrevious( pos );
		BOOL bActive = pTest->IsPaused() == FALSE && pTest->IsCompleted() == FALSE;
		
		if ( pDownload == pTest ) return bActive;
		if ( bActive ) nScope--;
	}
	
	return FALSE;
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:13,代码来源:Downloads.cpp

示例5: GetNext

int CDownloads::GetConnectingTransferCount() const
{
	int nCount = 0;
	
	for ( POSITION pos = GetIterator() ; pos ; )
	{
		CDownload* pDownload = GetNext( pos );
		
		nCount += pDownload->GetTransferCount( dtsConnecting );
	}
	
	return nCount;
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:13,代码来源:Downloads.cpp

示例6: ASSERT

void CDownloads::SerializeCompound(CArchive& ar)
{
	ASSERT( ar.IsLoading() );
	
	int nVersion;
	ar >> nVersion;
	if ( nVersion < 4 ) return;
	
	for ( int nCount = ar.ReadCount() ; nCount > 0 ; nCount-- )
	{
		CDownload* pDownload = new CDownload();
		m_pList.AddTail( pDownload );
		pDownload->Serialize( ar, nVersion );
	}
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:15,代码来源:Downloads.cpp

示例7: ASSUME_LOCK

BOOL CTorrentGeneralPage::OnInitDialog()
{
	if ( ! CPropertyPageAdv::OnInitDialog() )
		return FALSE;

	ASSUME_LOCK( Transfers.m_pSection );

	CDownload* pDownload = ((CDownloadSheet*)GetParent())->GetDownload();
	ASSERT( pDownload && pDownload->IsTorrent() );

	CBTInfo& oInfo = pDownload->m_pTorrent;

	m_sName			= oInfo.m_sName;
	m_sComment		= oInfo.m_sComment;
	m_sCreatedBy	= oInfo.m_sCreatedBy;
	if ( oInfo.m_tCreationDate > 0 )
	{
		CTime pTime( (time_t)oInfo.m_tCreationDate );
		m_sCreationDate = pTime.Format( _T("%Y-%m-%d  %H:%M") );
	}

	// Assembler 'other' string
	if ( oInfo.m_bPrivate )
	{
		m_sTorrentOther += LoadString( IDS_BT_PRIVATE );
		m_sTorrentOther += _T(", ");
	}
	if ( oInfo.HasEncodingError() )
	{
		m_sTorrentOther += LoadString( IDS_BT_ENCODING );
		m_sTorrentOther += _T(", ");
	}

	// Cut off last comma
	if ( ! m_sTorrentOther.IsEmpty() )
		m_sTorrentOther = m_sTorrentOther.Left( m_sTorrentOther.GetLength() - 2 );

	m_wndStartDownloads.SetCurSel( oInfo.m_nStartDownloads );

	m_sUploadTotal.Format( _T(" %s"),
		(LPCTSTR)Settings.SmartVolume( oInfo.m_nTotalUpload ) );

	UpdateData( FALSE );

	return TRUE;
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:46,代码来源:PageTorrentGeneral.cpp

示例8: ASSERT

int CLocalSearch::ExecutePartialFiles(int nMaximum)
{
	ASSERT( m_nProtocol == PROTOCOL_G2 );
	ASSERT( m_pSearch != NULL );

	if ( m_pSearch->m_bTiger == FALSE && m_pSearch->m_bSHA1 == FALSE &&
		 m_pSearch->m_bED2K  == FALSE && m_pSearch->m_bBTH == FALSE ) return 0;

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

	int nCount = 0;
	m_pPacket = NULL;

	for ( POSITION pos = Downloads.GetIterator() ; pos ; )
	{
		CDownload* pDownload = Downloads.GetNext( pos );

		if ( ! pDownload->IsShared() ) continue;

		if (	( m_pSearch->m_bTiger && pDownload->m_bTiger && m_pSearch->m_pTiger == pDownload->m_pTiger )
			||	( m_pSearch->m_bSHA1  && pDownload->m_bSHA1  && m_pSearch->m_pSHA1  == pDownload->m_pSHA1 )
			||	( m_pSearch->m_bED2K  && pDownload->m_bED2K  && m_pSearch->m_pED2K  == pDownload->m_pED2K )
			||	( m_pSearch->m_bBTH   && pDownload->m_bBTH   && m_pSearch->m_pBTH   == pDownload->m_pBTH ) )
		{
			if ( pDownload->m_bBTH || pDownload->IsStarted() )
			{
				if ( m_pPacket == NULL ) CreatePacketG2();
				AddHit( pDownload, nCount++ );
			}
		}
	}

	if ( m_pPacket != NULL )
	{
		WriteTrailerG2();
		DispatchPacket();
	}

	return nCount;
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:41,代码来源:LocalSearch.cpp

示例9: ATLASSERT

unsigned int __stdcall CDownload::_RunThreadFun( void* lpThis )
{
	ATLASSERT(lpThis);
	CDownload *pThis = (CDownload*) lpThis;
	
	ULONG uMaxConns = 2;
	ULONG uSize = sizeof( uMaxConns );
	if ( InternetQueryOption( NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &uMaxConns, &uSize ) )
	{
		uMaxConns += pThis->m_nCocurrent;
		InternetSetOption( NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &uMaxConns, sizeof( uMaxConns ) );
	}
	
	if(pThis)
		pThis->_RunThreadFun_();
		
	uSize = sizeof( uMaxConns );
	if ( InternetQueryOption( NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &uMaxConns, &uSize ) )
	{
		uMaxConns -= pThis->m_nCocurrent;
		InternetSetOption( NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &uMaxConns, sizeof( uMaxConns ) );
	}
	return 0;
}
开发者ID:6520874,项目名称:pcmanager,代码行数:24,代码来源:Download.cpp

示例10: GetRandomNum

void CRemote::PageDownloads()
{
	if ( CheckCookie() ) return;
	m_nTab = tabDownloads;

	CString str;
	str.Format( L"%i", GetRandomNum( 0i32, _I32_MAX ) );

	CSingleLock pLock( &DownloadGroups.m_pSection, TRUE );

	Prepare();		// Header
	Add( L"random", str );
	Output( L"downloadsHeader" );

	BOOL bExclusive = ! GetKey( L"group_exclusive" ).IsEmpty();
	BOOL bReveal = ! GetKey( L"group_reveal" ).IsEmpty();

	for ( POSITION posGroup = DownloadGroups.GetIterator(); posGroup != NULL; )
	{
		CDownloadGroup* pGroup = DownloadGroups.GetNext( posGroup );

		CString strGroupID;
		strGroupID.Format( L"%p", pGroup );
		Add( L"group_id", strGroupID );

		if ( bExclusive )
			pGroup->m_bRemoteSelected = ( GetKey( L"group_exclusive" ) == strGroupID );
		else if ( bReveal )
			pGroup->m_bRemoteSelected = TRUE;
		else if ( GetKey( L"group_select" ) == strGroupID )
			pGroup->m_bRemoteSelected = TRUE;
		else if ( GetKey( L"group_deselect" ) == strGroupID )
			pGroup->m_bRemoteSelected = FALSE;

		Add( L"group_caption", pGroup->m_sName );
		if ( pGroup->m_bRemoteSelected )
			Add( L"group_selected", L"true" );
		Output( L"downloadsTab" );
		Prepare( L"group_" );
	}

	if ( ! GetKey( L"filter_set" ).IsEmpty() )
	{
		Settings.Downloads.FilterMask &= ~( DLF_ACTIVE | DLF_PAUSED | DLF_QUEUED | DLF_SOURCES | DLF_SEED );
		if ( GetKey( L"filter_active" ) == L"1" ) Settings.Downloads.FilterMask |= DLF_ACTIVE;
		if ( GetKey( L"filter_paused" ) == L"1" ) Settings.Downloads.FilterMask |= DLF_PAUSED;
		if ( GetKey( L"filter_queued" ) == L"1" ) Settings.Downloads.FilterMask |= DLF_QUEUED;
		if ( GetKey( L"filter_sources" ) == L"1" ) Settings.Downloads.FilterMask |= DLF_SOURCES;
		if ( GetKey( L"filter_seeds" ) == L"1" )  Settings.Downloads.FilterMask |= DLF_SEED;
		Settings.Downloads.ShowSources = ( GetKey( L"filter_show_all" ) == L"1" );
	}

	Add( L"filter_active", ( Settings.Downloads.FilterMask & DLF_ACTIVE ) ? L"checked=\"checked\"" : L"" );
	Add( L"filter_paused", ( Settings.Downloads.FilterMask & DLF_PAUSED ) ? L"checked=\"checked\"" : L"" );
	Add( L"filter_queued", ( Settings.Downloads.FilterMask & DLF_QUEUED ) ? L"checked=\"checked\"" : L"" );
	Add( L"filter_sources", ( Settings.Downloads.FilterMask & DLF_SOURCES ) ? L"checked=\"checked\"" : L"" );
	Add( L"filter_seeds", ( Settings.Downloads.FilterMask & DLF_PAUSED ) ? L"checked=\"checked\"" : L"" );
	Add( L"filter_show_all", Settings.Downloads.ShowSources ? L"checked=\"checked\"" : L"" );
	Output( L"downloadsTop" );

	for ( POSITION posDownload = Downloads.GetIterator(); posDownload != NULL; )
	{
		CDownload* pDownload = Downloads.GetNext( posDownload );

		CString strDownloadID;
		strDownloadID.Format( L"%p", pDownload );

		if ( GetKey( L"modify_id" ) == strDownloadID )
		{
			CString strAction = GetKey( L"modify_action" );
			strAction.MakeLower();

			if ( strAction == L"expand" )
			{
				if ( CDownloadsCtrl::IsExpandable( pDownload ) )
					pDownload->m_bExpanded = TRUE;
			}
			else if ( strAction == L"collapse" )
			{
				if ( CDownloadsCtrl::IsExpandable( pDownload ) )
					pDownload->m_bExpanded = FALSE;
			}
			else if ( strAction == L"resume" )
			{
				pDownload->Resume();
			}
			else if ( strAction == L"pause" )
			{
				if ( ! pDownload->IsPaused() && ! pDownload->IsTasking() )
					pDownload->Pause();
			}
			else if ( strAction == L"cancel" )
			{
				if ( ! pDownload->IsTasking() )
					pDownload->Remove();
				continue;
			}
			else if ( strAction == L"clear" )
			{
				if ( pDownload->IsCompleted() && ! pDownload->IsPreviewVisible() )
//.........这里部分代码省略.........
开发者ID:GetEnvy,项目名称:Envy,代码行数:101,代码来源:Remote.cpp

示例11: pSingleLock

void CBaseMatchWnd::OnSearchDownload() 
{
	CSingleLock pSingleLock( &m_pMatches->m_pSection, TRUE );
	CPtrList pFiles, pHits;
	POSITION pos;
	
	for ( pos = m_pMatches->m_pSelectedFiles.GetHeadPosition() ; pos ; )
	{
		CMatchFile* pFile = (CMatchFile*)m_pMatches->m_pSelectedFiles.GetNext( pos );
		
		pSingleLock.Unlock();
		
		switch ( CheckExisting( pFile->m_bSHA1, &pFile->m_pSHA1, pFile->m_bTiger, &pFile->m_pTiger, pFile->m_bED2K, &pFile->m_pED2K ) )
		{
		case 1:
			pFiles.AddTail( pFile );
			break;
		case 3:
			return;
		}
		
		pSingleLock.Lock();
	}
	
	for ( pos = m_pMatches->m_pSelectedHits.GetHeadPosition() ; pos ; )
	{
		CQueryHit* pHit = (CQueryHit*)m_pMatches->m_pSelectedHits.GetNext( pos );
		
		pSingleLock.Unlock();
		
		switch ( CheckExisting( pHit->m_bSHA1, &pHit->m_pSHA1, pHit->m_bTiger, &pHit->m_pTiger, pHit->m_bED2K, &pHit->m_pED2K ) )
		{
		case 1:
			pHits.AddTail( pHit );
			break;
		case 3:
			return;
		}
		
		pSingleLock.Lock();
	}
	
	pSingleLock.Unlock();
	
	if ( pFiles.IsEmpty() && pHits.IsEmpty() ) return;
	
	CSyncObject* pSync[2] = { &Network.m_pSection, &Transfers.m_pSection };
	CMultiLock pMultiLock( pSync, 2, TRUE );
	
	for ( pos = pFiles.GetHeadPosition() ; pos ; )
	{
		CMatchFile* pFile = (CMatchFile*)pFiles.GetNext( pos );
		if ( m_pMatches->m_pSelectedFiles.Find( pFile ) != NULL ) Downloads.Add( pFile );

	}
	
	for ( pos = pHits.GetHeadPosition() ; pos ; )
	{
		CQueryHit* pHit = (CQueryHit*)pHits.GetNext( pos );
		if ( m_pMatches->m_pSelectedHits.Find( pHit ) != NULL ) 
		{
			CDownload *pDownload = Downloads.Add( pHit );
			// Send any reviews to the download, so they can be viewed later
			if ( pDownload && ( pHit->m_nRating || ! pHit->m_sComments.IsEmpty() ) )
			{
				pDownload->AddReview( &pHit->m_pAddress, 2, pHit->m_nRating, pHit->m_sNick, pHit->m_sComments );
			}
		}
	}
	
	pMultiLock.Unlock();
	
	m_wndList.Invalidate();
	
	if ( Settings.Search.SwitchToTransfers && ! m_bContextMenu && GetTickCount() - m_tContextMenu > 5000 )
	{
		GetManager()->Open( RUNTIME_CLASS(CDownloadsWnd) );
	}
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:79,代码来源:WndBaseMatch.cpp

示例12: ASSUME_LOCK

BOOL CTorrentTrackersPage::OnInitDialog()
{
	if ( ! CPropertyPageAdv::OnInitDialog() )
		return FALSE;

	m_wndAdd.SetIcon( CoolInterface.ExtractIcon( ID_MEDIA_ADD ) );
	m_wndDel.SetIcon( CoolInterface.ExtractIcon( ID_MEDIA_REMOVE ) );
//	m_wndRename.SetIcon( CoolInterface.ExtractIcon( ID_LIBRARY_RENAME ) );

	ASSUME_LOCK( Transfers.m_pSection );

	CDownloadSheet* pSheet = (CDownloadSheet*)GetParent();
	CDownload* pDownload = pSheet->GetDownload();
	ASSERT( pDownload && pDownload->IsTorrent() );

	CBTInfo& oInfo = pDownload->m_pTorrent;

	m_sOriginalTracker = oInfo.GetTrackerAddress();
	m_wndTracker.SetWindowText( m_sOriginalTracker );

	int nCount = oInfo.GetTrackerCount();
	m_nOriginalMode = oInfo.GetTrackerMode();
	m_wndTrackerMode.SetCurSel( m_nOriginalMode );

	// Remove invalid modes
	//if ( nCount < 2 )
	//{
	//	m_wndTrackerMode.DeleteString( CBTInfo::tMultiFound );
	//	m_wndTrackerMode.DeleteString( CBTInfo::tMultiFinding );
	//}

	CRect rc;
	m_wndTrackers.GetClientRect( &rc );
	rc.right -= GetSystemMetrics( SM_CXVSCROLL );

	CoolInterface.SetImageListTo( m_wndTrackers, LVSIL_SMALL );
	m_wndTrackers.SetExtendedStyle( LVS_EX_DOUBLEBUFFER|LVS_EX_HEADERDRAGDROP|LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP );
	m_wndTrackers.InsertColumn( 0, _T("Tracker"), LVCFMT_LEFT, rc.right - 82, -1 );
	m_wndTrackers.InsertColumn( 1, _T("Status"), LVCFMT_CENTER, 82, 0 );
	m_wndTrackers.InsertColumn( 2, _T("Type"), LVCFMT_CENTER, 0, 0 );
	Skin.Translate( _T("CTorrentTrackerList"), m_wndTrackers.GetHeaderCtrl() );

	if ( m_wndTrackers.SetBkImage( Skin.GetWatermark( _T("CListCtrl") ) ) )		// || m_wndTrackers.SetBkImage( Images.m_bmSystemWindow.m_hObject )		"System.Windows"
		m_wndTrackers.SetExtendedStyle( LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_LABELTIP );	// No LVS_EX_DOUBLEBUFFER
	else
	{
		m_wndTrackers.SetBkColor( Colors.m_crWindow );
		m_wndTrackers.SetTextBkColor( Colors.m_crWindow );
	}

	m_wndTrackers.SetTextColor( Colors.m_crText );

	for ( int nTracker = 0 ; nTracker < nCount ; nTracker++ )
	{
		//LV_ITEM pItem = {};
		//pItem.mask	= LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM;
		//pItem.iItem	= m_wndTrackers.GetItemCount();
		//pItem.lParam	= (LPARAM)nTracker;
		//
		//if ( oInfo.GetTrackerIndex() == nTracker )
		//	pItem.iImage = CoolInterface.ImageForID( ID_MEDIA_SELECT );
		//else if ( oInfo.GetTrackerAddress( nTracker ).GetAt( 0 ) == BAD_TRACKER_TOKEN )
		//	pItem.iImage = CoolInterface.ImageForID( ID_DISCOVERY_BLOCKED );
		//else
		//	pItem.iImage = CoolInterface.ImageForID( ID_DOWNLOADS_URI );
		//
		//pItem.pszText	= (LPTSTR)(LPCTSTR)oInfo.GetTrackerAddress( nTracker );
		//pItem.iItem	= m_wndTrackers.InsertItem( &pItem );

		CString strTracker = oInfo.GetTrackerAddress( nTracker );
		m_sOriginalTrackers.AddTail( strTracker );

		// Display status
		CString strStatus;
		UINT nStatusIcon = ID_DOWNLOADS_URI;
		if ( ! StartsWith( oInfo.GetTrackerAddress( nTracker ), _PT("http://") ) &&
			 ! StartsWith( oInfo.GetTrackerAddress( nTracker ), _PT("udp://") ) )
		{
			// Bad format, or BAD_TRACKER_TOKEN Tagged for display only (*https:// etc.)
			LoadString( strStatus, IDS_STATUS_UNSUPPORTED );
			nStatusIcon = ID_DISCOVERY_BLOCKED;
		}
		else
		{
			switch ( oInfo.GetTrackerStatus( nTracker ) )
			{
			case TRI_TRUE:
				LoadString( strStatus, IDS_STATUS_ACTIVE );
				break;
			case TRI_FALSE:
				LoadString( strStatus, IDS_STATUS_TRACKERDOWN );
				break;
			case TRI_UNKNOWN:
				LoadString( strStatus, IDS_STATUS_UNKNOWN );
			//	break;
			}
		}

		// pItem.iItem
		int nItem = m_wndTrackers.InsertItem( m_wndTrackers.GetItemCount(), strTracker, CoolInterface.ImageForID( nStatusIcon ) );
//.........这里部分代码省略.........
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:101,代码来源:PageTorrentTrackers.cpp

示例13: LoadString

BOOL CDownloadEditPage::OnApply()
{
	if ( ! UpdateData() )
		return FALSE;

	CString strMessage;

	Hashes::Sha1Hash oSHA1;
	Hashes::TigerHash oTiger;
	Hashes::Ed2kHash oED2K;
	Hashes::Md5Hash oMD5;
	Hashes::BtHash oBTH;

	oSHA1.fromString( m_sSHA1 );
	oTiger.fromString( m_sTiger );
	oED2K.fromString( m_sED2K );
	oMD5.fromString( m_sMD5 );
	oBTH.fromString( m_sBTH );

	if ( ! m_sSHA1.IsEmpty() && ! oSHA1 )
	{
		strMessage.Format( LoadString( IDS_DOWNLOAD_EDIT_BAD_HASH ), _T("SHA1") );
		MsgBox( strMessage, MB_ICONEXCLAMATION );
		GetDlgItem( IDC_URN_SHA1 )->SetFocus();
		return FALSE;
	}
	if ( ! m_sTiger.IsEmpty() && ! oTiger )
	{
		strMessage.Format( LoadString( IDS_DOWNLOAD_EDIT_BAD_HASH ), _T("Tiger-Root") );
		MsgBox( strMessage, MB_ICONEXCLAMATION );
		GetDlgItem( IDC_URN_TIGER )->SetFocus();
		return FALSE;
	}
	if ( ! m_sED2K.IsEmpty() && ! oED2K )
	{
		strMessage.Format( LoadString( IDS_DOWNLOAD_EDIT_BAD_HASH ), _T("ED2K") );
		MsgBox( strMessage, MB_ICONEXCLAMATION );
		GetDlgItem( IDC_URN_ED2K )->SetFocus();
		return FALSE;
	}
	if ( ! m_sMD5.IsEmpty() && ! oMD5 )
	{
		strMessage.Format( LoadString( IDS_DOWNLOAD_EDIT_BAD_HASH ), _T("MD5") );
		MsgBox( strMessage, MB_ICONEXCLAMATION );
		GetDlgItem( IDC_URN_MD5 )->SetFocus();
		return FALSE;
	}
	if ( ! m_sBTH.IsEmpty() && ! oBTH )
	{
		strMessage.Format( LoadString( IDS_DOWNLOAD_EDIT_BAD_HASH ), _T("BitTorrent") );
		MsgBox( strMessage, MB_ICONEXCLAMATION );
		GetDlgItem( IDC_URN_BTH )->SetFocus();
		return FALSE;
	}

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

	CDownloadSheet* pSheet = (CDownloadSheet*)GetParent();
	CDownload* pDownload = pSheet->GetDownload();
	if ( ! pDownload )
		return CPropertyPageAdv::OnApply();		// Invalid download

	bool bNeedUpdate = false;
	bool bCriticalChange = false;

	bNeedUpdate	= pDownload->m_bSHA1Trusted ^ ( m_bSHA1Trusted == TRUE );
	bNeedUpdate	|= pDownload->m_bTigerTrusted ^ ( m_bTigerTrusted == TRUE );
	bNeedUpdate	|= pDownload->m_bED2KTrusted ^ ( m_bED2KTrusted == TRUE );
	bNeedUpdate	|= pDownload->m_bMD5Trusted ^ ( m_bMD5Trusted == TRUE );
	bNeedUpdate	|= pDownload->m_bBTHTrusted ^ ( m_bBTHTrusted == TRUE );

	if ( pDownload->m_sName != m_sName )
	{
		pLock.Unlock();
		if ( MsgBox( IDS_DOWNLOAD_EDIT_CHANGE_NAME, MB_ICONQUESTION|MB_YESNO ) != IDYES ) return FALSE;		// Was IDS_DOWNLOAD_EDIT_RENAME
		pLock.Lock();
		pDownload = pSheet->GetDownload();
		if ( ! pDownload ) return CPropertyPageAdv::OnApply();
		pDownload->Rename( m_sName );
		bNeedUpdate = true;
	}

	QWORD nNewSize = 0;
	if ( _stscanf( m_sFileSize, _T("%I64u"), &nNewSize ) == 1 && nNewSize != pDownload->m_nSize )
	{
		pLock.Unlock();
		if ( MsgBox( IDS_DOWNLOAD_EDIT_CHANGE_SIZE, MB_ICONQUESTION|MB_YESNO ) != IDYES ) return FALSE;
		pLock.Lock();
		pDownload = pSheet->GetDownload();
		if ( ! pDownload ) return CPropertyPageAdv::OnApply();
		pDownload->m_nSize = nNewSize;
		pDownload->CloseTransfers();
		pDownload->ClearVerification();
		bCriticalChange = true;
	}

	SYSTEMTIME tDate;
	m_wndDate.GetTime( &tDate );
//.........这里部分代码省略.........
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:101,代码来源:PageDownloadEdit.cpp


注:本文中的CDownload类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。