示例#1
0
void CDownloads_Deleted::Sort()
{
	if (m_sortMode != LCSM_NONE)
		SortItems (_sortFunc, DWORD (this));
	else
	{
		DeleteAllItems ();
		for (int i = _DldsMgr.Get_DeletedDownloadCount () - 1; i >= 0; i--)
			AddDownload (_DldsMgr.Get_DeletedDownload (i));
	}
}
示例#2
0
BOOL FAsyncDownload::Resume(DHANDLE hDownload)
{
	SynchronizeThread(m_Sync); 
	for (size_t k = 0; k < m_aPaused.GetCount(); k++)
	{
		if (m_aPaused[k] && m_aPaused[k]->m_pUrlInfo->m_Handle == hDownload){
			m_aPaused[k]->pBindStatusCallback.m_Paused = FALSE;
			m_aPaused[k]->pBindStatusCallback.m_Abort = FALSE;
			FAsyncDownData* pData = m_aPaused[k];
			m_aPaused.RemoveAt(k); 
			return AddDownload(pData);
		}
	}
	return FALSE; 
}
示例#3
0
void CDownloadQueue::AddSearchToDownload(CSearchFile* toadd, uint8 category)
{
	if ( IsFileExisting(toadd->GetFileHash()) ) {
		return;
	}

	if (toadd->GetFileSize() > OLD_MAX_FILE_SIZE) {
		if (!PlatformSpecific::CanFSHandleLargeFiles(thePrefs::GetTempDir())) {
			AddLogLineC(_("Filesystem for Temp directory cannot handle large files."));
			return;
		} else if (!PlatformSpecific::CanFSHandleLargeFiles(theApp->glob_prefs->GetCatPath(category))) {
			AddLogLineC(_("Filesystem for Incoming directory cannot handle large files."));
			return;
		}
	}

	CPartFile* newfile = NULL;
	try {
		newfile = new CPartFile(toadd);
	} catch (const CInvalidPacket& WXUNUSED(e)) {
		AddDebugLogLineC(logDownloadQueue, wxT("Search-result contained invalid tags, could not add"));
	}
	
	if ( newfile && newfile->GetStatus() != PS_ERROR ) {
		AddDownload( newfile, thePrefs::AddNewFilesPaused(), category );
		// Add any possible sources
		if (toadd->GetClientID() && toadd->GetClientPort()) {
			CMemFile sources(1+4+2);
			sources.WriteUInt8(1);
			sources.WriteUInt32(toadd->GetClientID());
			sources.WriteUInt16(toadd->GetClientPort());
			sources.Reset();
			newfile->AddSources(sources, toadd->GetClientServerIP(), toadd->GetClientServerPort(), SF_SEARCH_RESULT, false);
		}
		for (std::list<CSearchFile::ClientStruct>::const_iterator it = toadd->GetClients().begin(); it != toadd->GetClients().end(); ++it) {
			CMemFile sources(1+4+2);
			sources.WriteUInt8(1);
			sources.WriteUInt32(it->m_ip);
			sources.WriteUInt16(it->m_port);
			sources.Reset();
			newfile->AddSources(sources, it->m_serverIP, it->m_serverPort, SF_SEARCH_RESULT, false);
		}
	} else {
		delete newfile;
	}
}
示例#4
0
bool CDownloadQueue::AddED2KLink( const CED2KFileLink* link, uint8 category )
{
	CPartFile* file = NULL;
	if (IsFileExisting(link->GetHashKey())) {
		// Must be a shared file if we are to add hashes or sources
		if ((file = GetFileByID(link->GetHashKey())) == NULL) {
			return false;
		}
	} else {
		if (link->GetSize() > OLD_MAX_FILE_SIZE) {
			if (!PlatformSpecific::CanFSHandleLargeFiles(thePrefs::GetTempDir())) {
				AddLogLineC(_("Filesystem for Temp directory cannot handle large files."));
				return false;
			} else if (!PlatformSpecific::CanFSHandleLargeFiles(theApp->glob_prefs->GetCatPath(category))) {
				AddLogLineC(_("Filesystem for Incoming directory cannot handle large files."));
				return false;
			}
		}

		file = new CPartFile(link);
	
		if (file->GetStatus() == PS_ERROR) {
			delete file;
			return false;
		}
		
		AddDownload(file, thePrefs::AddNewFilesPaused(), category);
	}
	
	if (link->HasValidAICHHash()) {
		CAICHHashSet* hashset = file->GetAICHHashset();
		
		if (!hashset->HasValidMasterHash() || (hashset->GetMasterHash() != link->GetAICHHash())) {
			hashset->SetMasterHash(link->GetAICHHash(), AICH_VERIFIED);
			hashset->FreeHashSet();
		}
	}
	
	const CED2KFileLink::CED2KLinkSourceList& list = link->m_sources;
	CED2KFileLink::CED2KLinkSourceList::const_iterator it = list.begin();
	for (; it != list.end(); ++it) {
		AddToResolve(link->GetHashKey(), it->addr, it->port, it->hash, it->cryptoptions);
	}

	return true;	
}
示例#5
0
DHANDLE FAsyncDownload::DownloadURL(FDownloadInfo* pInfo,  IClipDownloadNotify* pvObj)
{
	if (!pInfo)
		return 0; 

	if (!PathIsURL(pInfo->m_DownloadUrl))
	{
		_DBGAlert("**FAsyncDownload: Path is not a URL: %s\n", pInfo->m_DownloadUrl); 
		return 0; 
	}

	DHANDLE hHandle = (DWORD)InterlockedIncrement((LONG*)&m_HandleID);

	FAsyncDownData* pData = new FAsyncDownData; 
	pData->m_pUrlInfo = pInfo; 
	pData->m_pNotify = pvObj; 
	pData->m_pUrlInfo->m_Handle = hHandle; 
	AddDownload(pData);
    return hHandle; 
}
示例#6
0
STDMETHODIMP CWGUrlReceiver::ShowAddDownloadDialog()
{
	return AddDownload ();
}