Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Downloads.h

Go to the documentation of this file.
00001 //
00002 // Downloads.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_DOWNLOADS_H__0C075423_D022_4530_8B45_6B7EF79712CB__INCLUDED_)
00023 #define AFX_DOWNLOADS_H__0C075423_D022_4530_8B45_6B7EF79712CB__INCLUDED_
00024 
00025 #pragma once
00026 
00027 class CDownload;
00028 class CDownloadSource;
00029 class CConnection;
00030 class CQueryHit;
00031 class CMatchFile;
00032 class CBuffer;
00033 class CShareazaURL;
00034 class CEDClient;
00035 
00036 
00037 class CDownloads
00038 {
00039 // Construction
00040 public:
00041         CDownloads();
00042         virtual ~CDownloads();
00043 
00044 // Attributes
00045 public:
00046         DWORD                   m_nLimitGeneric;
00047         DWORD                   m_nLimitDonkey;
00048         DWORD                   m_nTransfers;
00049         DWORD                   m_nBandwidth;
00050         DWORD                   m_nValidation;
00051         BOOL                    m_bAllowMoreDownloads;
00052         BOOL                    m_bAllowMoreTransfers;
00053         BOOL                    m_bClosing;
00054         DWORD                   m_tLastConnect;
00055 protected:
00056         CPtrList                m_pList;
00057         CMapPtrToPtr    m_pHostLimits;
00058         int                             m_nRunCookie;
00059 public:
00060         enum
00061         {
00062                 dlPathNull, dlPathComplete, dlPathIncomplete
00063         };
00064 
00065 // Operations
00066 public:
00067         CDownload*      Add();
00068         CDownload*      Add(CQueryHit* pHit, BOOL bAddToHead = FALSE);
00069         CDownload*      Add(CMatchFile* pFile, BOOL bAddToHead = FALSE);
00070         CDownload*      Add(CShareazaURL* pURL);
00071         void            PauseAll();
00072         void            ClearCompleted();
00073         void            ClearPaused();
00074         void            Clear(BOOL bClosing = FALSE);
00075         void            CloseTransfers();
00076 public:
00077         int                     GetSeedCount() const;
00078         int                     GetActiveTorrentCount() const;
00079         int                     GetCount(BOOL bActiveOnly = FALSE) const;
00080         int                     GetTransferCount() const;
00081         int                     GetTryingCount(BOOL bTorrentsOnly = FALSE) const;
00082         int                     GetConnectingTransferCount() const;
00083         BOOL            Check(CDownloadSource* pSource) const;
00084         BOOL            CheckActive(CDownload* pDownload, int nScope) const;
00085         BOOL            Move(CDownload* pDownload, int nDelta);
00086         BOOL            Reorder(CDownload* pDownload, CDownload* pBefore);
00087         BOOL            Swap(CDownload* p1, CDownload* p2);
00088         CDownload*      FindByURN(LPCTSTR pszURN, BOOL bSharedOnly = FALSE) const;
00089         CDownload*      FindBySHA1(const SHA1* pHash, BOOL bSharedOnly = FALSE) const;
00090         CDownload*      FindByTiger(const TIGEROOT* pHash, BOOL bSharedOnly = FALSE) const;
00091         CDownload*      FindByED2K(const MD4* pED2K, BOOL bSharedOnly = FALSE) const;
00092         CDownload*      FindByBTH(const SHA1* pHash, BOOL bSharedOnly = FALSE) const;
00093         CDownload*      FindBySID(DWORD nSerID) const;
00094         DWORD           GetFreeSID();
00095         QWORD           GetAmountDownloadedFrom(IN_ADDR* pAddress);
00096         DWORD           GetBandwidth() const;
00097 public:
00098         void            Load();
00099         void            Save(BOOL bForce = TRUE);
00100         void            OnRun();
00101         BOOL            OnPush(GGUID* pGUID, CConnection* pConnection);
00102         BOOL            OnDonkeyCallback(CEDClient* pClient, CDownloadSource* pExcept = NULL);
00103         void            OnQueryHits(CQueryHit* pHits);
00104         void            OnVerify(LPCTSTR pszPath, BOOL bVerified);
00105         void            SetPerHostLimit(IN_ADDR* pAddress, int nLimit);
00106         BOOL            IsSpaceAvailable(QWORD nVolume, int nPath = dlPathNull);
00107 protected:
00108         void            UpdateAllows(BOOL bNew);
00109         BOOL            AllowMoreDownloads() const;
00110         BOOL            AllowMoreTransfers(IN_ADDR* pAdress = NULL) const;
00111         void            Remove(CDownload* pDownload);
00112         void            LoadFromCompoundFiles();
00113         BOOL            LoadFromCompoundFile(LPCTSTR pszFile);
00114         BOOL            LoadFromTimePair();
00115         void            SerializeCompound(CArchive& ar);
00116         void            PurgeDeletes();
00117         void            PurgePreviews();
00118 
00119 // Inlines
00120 public:
00121         inline POSITION CDownloads::GetIterator() const
00122         {
00123                 return m_pList.GetHeadPosition();
00124         }
00125 
00126         inline POSITION CDownloads::GetReverseIterator() const
00127         {
00128                 return m_pList.GetTailPosition();
00129         }
00130 
00131         inline CDownload* CDownloads::GetNext(POSITION& pos) const
00132         {
00133                 return (CDownload*)m_pList.GetNext( pos );
00134         }
00135 
00136         inline CDownload* CDownloads::GetPrevious(POSITION& pos) const
00137         {
00138                 return (CDownload*)m_pList.GetPrev( pos );
00139         }
00140 
00141         inline BOOL CDownloads::Check(CDownload* pDownload) const
00142         {
00143                 return m_pList.Find( pDownload ) != NULL;
00144         }
00145 
00146         friend class CDownload;
00147         friend class CDownloadBase;
00148         friend class CDownloadWithTransfers;
00149         friend class CDownloadSource;
00150 };
00151 
00152 extern CDownloads Downloads;
00153 
00154 
00155 #endif // !defined(AFX_DOWNLOADS_H__0C075423_D022_4530_8B45_6B7EF79712CB__INCLUDED_)

Generated on Thu Dec 15 10:39:40 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2