00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(AFX_DOWNLOADWITHFILE_H__79FE6B65_04DF_4CD5_A1BC_9AF8429664DC__INCLUDED_)
00023 #define AFX_DOWNLOADWITHFILE_H__79FE6B65_04DF_4CD5_A1BC_9AF8429664DC__INCLUDED_
00024
00025 #pragma once
00026
00027 #include "DownloadWithTransfers.h"
00028 #include "FileFragments.hpp"
00029
00030 class CFragmentedFile;
00031
00032 class CDownloadWithFile : public CDownloadWithTransfers
00033 {
00034
00035 public:
00036 CDownloadWithFile();
00037 virtual ~CDownloadWithFile();
00038
00039
00040 public:
00041 CFragmentedFile* m_pFile;
00042 DWORD m_tReceived;
00043 BOOL m_bDiskFull;
00044
00045
00046 public:
00047 float GetProgress() const;
00048 QWORD GetVolumeComplete() const;
00049 QWORD GetVolumeRemaining() const;
00050 DWORD GetTimeRemaining() const;
00051 CString GetDisplayName() const;
00052 public:
00053 const FF::SimpleFragmentList& GetEmptyFragmentList() const;
00054 FF::SimpleFragmentList GetPossibleFragments(const FF::SimpleFragmentList& oAvailable, FF::SimpleFragment& oLargest);
00055 BOOL GetFragment(CDownloadTransfer* pTransfer);
00056 BOOL IsPositionEmpty(QWORD nOffset);
00057 BOOL AreRangesUseful(const FF::SimpleFragmentList& oAvailable);
00058 BOOL IsRangeUseful(QWORD nOffset, QWORD nLength);
00059 BOOL IsRangeUsefulEnough(CDownloadTransfer* pTransfer, QWORD nOffset, QWORD nLength);
00060 virtual CString GetAvailableRanges() const;
00061 BOOL ClipUploadRange(QWORD nOffset, QWORD& nLength) const;
00062 BOOL GetRandomRange(QWORD& nOffset, QWORD& nLength) const;
00063 BOOL PrepareFile();
00064 BOOL SubmitData(QWORD nOffset, LPBYTE pData, QWORD nLength);
00065 QWORD EraseRange(QWORD nOffset, QWORD nLength);
00066 BOOL MakeComplete();
00067 protected:
00068 BOOL OpenFile();
00069 void CloseFile();
00070 void DeleteFile(BOOL bForce = FALSE);
00071 BOOL RunFile(DWORD tNow);
00072 BOOL WriteMetadata(LPCTSTR pszPath);
00073 BOOL AppendMetadata();
00074 BOOL AppendMetadataID3v1(HANDLE hFile, CXMLElement* pXML);
00075 protected:
00076 virtual void Serialize(CArchive& ar, int nVersion);
00077
00078 friend class CDownloadTransfer;
00079 };
00080
00081 #endif // !defined(AFX_DOWNLOADWITHFILE_H__79FE6B65_04DF_4CD5_A1BC_9AF8429664DC__INCLUDED_)