00001 // 00002 // DownloadWithTiger.h 00003 // 00004 // Copyright (c) Shareaza Development Team, 2002-2005. 00005 // This file is part of SHAREAZA (www.shareaza.com) 00006 // 00007 // Shareaza is free software; you can redistribute it 00008 // and/or modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 of 00010 // the License, or (at your option) any later version. 00011 // 00012 // Shareaza is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with Shareaza; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 // 00021 00022 #if !defined(AFX_DOWNLOADWITHTIGER_H__8F105434_164D_4F58_BAA4_8DB2B29CA259__INCLUDED_) 00023 #define AFX_DOWNLOADWITHTIGER_H__8F105434_164D_4F58_BAA4_8DB2B29CA259__INCLUDED_ 00024 00025 #pragma once 00026 00027 #include "DownloadWithTorrent.h" 00028 #include "TigerTree.h" 00029 #include "ED2K.h" 00030 00031 00032 class CDownloadWithTiger : public CDownloadWithTorrent 00033 { 00034 // Construction 00035 public: 00036 CDownloadWithTiger(); 00037 virtual ~CDownloadWithTiger(); 00038 00039 // Attributes 00040 private: 00041 CTigerTree m_pTigerTree; 00042 BYTE* m_pTigerBlock; 00043 DWORD m_nTigerBlock; 00044 DWORD m_nTigerSize; 00045 DWORD m_nTigerSuccess; 00046 private: 00047 CED2K m_pHashset; 00048 BYTE* m_pHashsetBlock; 00049 DWORD m_nHashsetBlock; 00050 DWORD m_nHashsetSuccess; 00051 private: 00052 DWORD m_nVerifyCookie; 00053 int m_nVerifyHash; 00054 DWORD m_nVerifyBlock; 00055 QWORD m_nVerifyOffset; 00056 QWORD m_nVerifyLength; 00057 DWORD m_tVerifyLast; 00058 00059 // Operations 00060 public: 00061 DWORD GetValidationCookie() const; 00062 QWORD GetVerifyLength(int nHash = HASH_NULL) const; 00063 BOOL GetNextVerifyRange(QWORD& nOffset, QWORD& nLength, BOOL& bSuccess, int nHash = HASH_NULL) const; 00064 BOOL IsFullyVerified(); 00065 public: 00066 BOOL NeedTigerTree() const; 00067 BOOL SetTigerTree(BYTE* pTiger, DWORD nTiger); 00068 CTigerTree* GetTigerTree(); 00069 BOOL NeedHashset() const; 00070 BOOL SetHashset(BYTE* pSource, DWORD nSource); 00071 CED2K* GetHashset(); 00072 protected: 00073 BOOL ValidationCanFinish() const; 00074 void RunValidation(BOOL bSeeding); 00075 private: 00076 BOOL FindNewValidationBlock(int nHash); 00077 void ContinueValidation(); 00078 void FinishValidation(); 00079 void SubtractHelper(FF::SimpleFragmentList& ppCorrupted, BYTE* pBlock, QWORD nBlock, QWORD nSize); 00080 public: 00081 virtual CString GetAvailableRanges() const; 00082 virtual void ResetVerification(); 00083 virtual void ClearVerification(); 00084 virtual void Serialize(CArchive& ar, int nVersion); 00085 00086 friend class CEDClient; 00087 friend class CDownloadTipCtrl; 00088 }; 00089 00090 #endif // !defined(AFX_DOWNLOADWITHTIGER_H__8F105434_164D_4F58_BAA4_8DB2B29CA259__INCLUDED_)