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_DOWNLOADWITHSOURCES_H__D6932F45_0557_4098_B2F3_AE35BC43ECC0__INCLUDED_)
00023 #define AFX_DOWNLOADWITHSOURCES_H__D6932F45_0557_4098_B2F3_AE35BC43ECC0__INCLUDED_
00024
00025 #pragma once
00026
00027 #include "DownloadBase.h"
00028
00029 class CDownloadSource;
00030 class CQueryHit;
00031 class CXMLElement;
00032
00033
00034 class CDownloadWithSources : public CDownloadBase
00035 {
00036
00037 public:
00038 CDownloadWithSources();
00039 virtual ~CDownloadWithSources();
00040
00041
00042 protected:
00043 CDownloadSource* m_pSourceFirst;
00044 CDownloadSource* m_pSourceLast;
00045 int m_nSourceCount;
00046 public:
00047 CStringList m_pFailedSources;
00048 CXMLElement* m_pXML;
00049
00050
00051 public:
00052 CString GetSourceURLs(CStringList* pState, int nMaximum, PROTOCOLID nProtocol, CDownloadSource* pExcept);
00053 int GetSourceCount(BOOL bNoPush = FALSE, BOOL bSane = FALSE) const;
00054 int GetBTSourceCount(BOOL bNoPush = FALSE) const;
00055 int GetED2KCompleteSourceCount() const;
00056 BOOL CheckSource(CDownloadSource* pSource) const;
00057 void ClearSources();
00058 public:
00059 BOOL AddSourceHit(CQueryHit* pHit, BOOL bForce = FALSE);
00060 BOOL AddSourceED2K(DWORD nClientID, WORD nClientPort, DWORD nServerIP, WORD nServerPort, GGUID* pGUID = NULL);
00061 BOOL AddSourceBT(SHA1* pGUID, IN_ADDR* pAddress, WORD nPort);
00062 BOOL AddSourceURL(LPCTSTR pszURL, BOOL bURN = FALSE, FILETIME* pLastSeen = NULL);
00063 int AddSourceURLs(LPCTSTR pszURLs, BOOL bURN = FALSE);
00064 virtual BOOL OnQueryHits(CQueryHit* pHits);
00065 virtual void Serialize(CArchive& ar, int nVersion);
00066
00067
00068 protected:
00069 BOOL AddSourceInternal(CDownloadSource* pSource);
00070 void RemoveSource(CDownloadSource* pSource, BOOL bBan);
00071 void SortSource(CDownloadSource* pSource, BOOL bTop);
00072 void SortSource(CDownloadSource* pSource);
00073 protected:
00074 void RemoveOverlappingSources(QWORD nOffset, QWORD nLength);
00075 int GetSourceColour();
00076
00077
00078 public:
00079 inline CDownloadSource* GetFirstSource() const
00080 {
00081 return m_pSourceFirst;
00082 }
00083
00084 friend class CDownloadSource;
00085 friend class CDownloadTransfer;
00086 };
00087
00088 #endif // !defined(AFX_DOWNLOADWITHSOURCES_H__D6932F45_0557_4098_B2F3_AE35BC43ECC0__INCLUDED_)