LRESULT	CDlgMaintabDownload::OnCurSelFile(WPARAM wParam, LPARAM lParam)
{	
	if (!lParam)
	{
		theApp.emuledlg->m_mainTabWnd.m_dlgDownload.m_dlgPeerLog.m_LogListCtrl.DeleteAllItems();
		theApp.emuledlg->m_mainTabWnd.m_dlgDownload.m_dlgDetailInfo.m_ListDetail.DeleteAllItems();
		return 0;
	}

	if (wParam == 1)
	{
		CKnownFile* pKnownFile= (CKnownFile*)lParam;
		if( pKnownFile->HasNullHash() )
		{
			CFileTaskItem* pFileTaskItem = CGlobalVariable::filemgr.GetFileTaskItem(pKnownFile->GetPartFileURL());
			ASSERT(pFileTaskItem);
			if(pFileTaskItem) 
				m_dlgDetailInfo.FileInfo(pFileTaskItem);
		}
		else
		{
			m_dlgDetailInfo.UpdateInfo((CPartFile*)lParam, CDetailInfo::IM_COMBINE_DOWNLOADED);
		}

		return 0;
	}

	CPartFile *pFile = (CPartFile*) lParam;
	if (IsRemarkTabActived())
	{
		RefreshLowerPannel(pFile);
	}
	else /*if( IsLogTabActived() )*/
	{
		m_dlgPeerLog.m_LogListCtrl.ShowSelectedFileLogs(pFile);
	}

	//MODIFIED by VC-fengwen on 2008/03/17 <begin> : 无论是否处于当前页面都更新DetailInfo(为了方便处理,而且此处性能消耗不大)
	if ( IsDownloadingActived() && pFile->GetStatus() != PS_COMPLETE && pFile->GetFileSize() != (uint64)0)
	{
		m_dlgDetailInfo.UpdateInfo(pFile, CDetailInfo::IM_COMBINE_DOWNLOAD);
	}
	else if (IsDownloadingActived() && pFile->GetFileSize() == (uint64)0)
	{   
		CFileTaskItem* pFileTaskItem = CGlobalVariable::filemgr.GetFileTaskItem(pFile->GetPartFileURL());
		ASSERT(pFileTaskItem);
		if(pFileTaskItem) 
			m_dlgDetailInfo.FileInfo(pFileTaskItem);
	}
	else
	{
		m_dlgDetailInfo.UpdateInfo(pFile, CDetailInfo::IM_COMBINE_DOWNLOADED);
	}
	//MODIFIED by VC-fengwen on 2008/03/17 <end> : 无论是否处于当前页面都更新DetailInfo(为了方便处理,而且此处性能消耗不大)
		
	return 0;
}
Example #2
0
CString	CDetailInfo::GetLink(CKnownFile* pFile)
{
	//ADDED by fengwen on 2007/07/12 <begin>	:	如果是url下载,则返回源url。
	if (NULL == pFile)
		return _T("");

	if (pFile->IsPartFile())
	{
		CPartFile	*pPartFile = (CPartFile	*) pFile;
		if ( pPartFile->HasNullHash() )
			return pPartFile->GetPartFileURL();
	}
	//ADDED by fengwen on 2007/07/12 <end>	:	如果是url下载,则返回源url。

	CString strLinks;
	CString strBuffer;

	bool bHashset = false;
	bool bHTML = false;
//	bool bSource = true;
//	bool bHostname  = true;
	bool bEMHash = true;

	if (!strLinks.IsEmpty())
		strLinks += _T("\r\n\r\n");

	if (bHTML)
		strLinks += _T("<a href=\"");

	//const CKnownFile* file = STATIC_DOWNCAST(CKnownFile, (*pFile)[i]);
	const CKnownFile* file = pFile;
	strLinks += CreateED2kLink(file, false);

	if (bHashset && file->GetHashCount() > 0 && file->GetHashCount() == file->GetED2KPartHashCount())
	{
		strLinks += _T("p=");
		for (UINT j = 0; j < file->GetHashCount(); j++)
		{
			if (j > 0)
				strLinks += _T(':');
			strLinks += EncodeBase16(file->GetPartHash(j), 16);
		}
		strLinks += _T('|');
	}

	if (bEMHash && file->GetAICHHashset()->HasValidMasterHash() && 
		(file->GetAICHHashset()->GetStatus() == AICH_VERIFIED || file->GetAICHHashset()->GetStatus() == AICH_HASHSETCOMPLETE))
	{
		strBuffer.Format(_T("h=%s|"), file->GetAICHHashset()->GetMasterHash().GetString() );
		strLinks += strBuffer;			
	}
    if(!strLinks.IsEmpty())
	    strLinks += _T('/');
	//if (bHostname)
	//{
	//	strBuffer.Format(_T("|sources,%s:%i|/"), thePrefs.GetYourHostname(), thePrefs.GetPort() );
	//	strLinks += strBuffer;
	//}
	//else if(bSource)
	//{
	//	uint32 dwID = CGlobalVariable::GetID();
	//	strBuffer.Format(_T("|sources,%i.%i.%i.%i:%i|/"),(uint8)dwID,(uint8)(dwID>>8),(uint8)(dwID>>16),(uint8)(dwID>>24), thePrefs.GetPort() );
	//	strLinks += strBuffer;
	//}

	if (bHTML)
		strLinks += _T("\">") + StripInvalidFilenameChars(file->GetFileName(), true) + _T("</a>");

	return strLinks;
}