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

Uploads.h

Go to the documentation of this file.
00001 //
00002 // Uploads.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 #pragma once
00023 
00024 class CBuffer;
00025 class CConnection;
00026 class CUploadTransfer;
00027 
00028 
00029 class CUploads  
00030 {
00031 // Construction
00032 public:
00033         CUploads();
00034         virtual ~CUploads();
00035         
00036 // Attributes
00037 public:
00038         DWORD           m_nCount;                       // Active count
00039         DWORD           m_nBandwidth;           // Total speed
00040         DWORD           m_nTorrentSpeed;        // BitTorrent clamp
00041 public:
00042         BOOL            m_bStable;                      // Stable flag
00043         DWORD           m_nBestSpeed;           // Best speed
00044 protected:
00045         CPtrList        m_pList;
00046 
00047 // Operations
00048 public:
00049         void            Clear(BOOL bMessage = TRUE);
00050         int                     GetCount(CUploadTransfer* pExcept, int nState = -1) const;
00051         int                     GetTorrentCount(int nState) const;
00052 public:
00053         BOOL            AllowMoreTo(IN_ADDR* pAddress) const;
00054         BOOL            CanUploadFileTo(IN_ADDR* pAddress, const SHA1* pSHA1 = NULL) const;
00055         BOOL            EnforcePerHostLimit(CUploadTransfer* pUpload, BOOL bRequest = FALSE);
00056 public:
00057         void            SetStable(DWORD nSpeed);
00058         DWORD           GetBandwidth() const;
00059         void            OnRun();
00060         BOOL            OnAccept(CConnection* pConnection, LPCTSTR pszHandshake);
00061         void            OnRename(LPCTSTR pszSource, LPCTSTR pszTarget = (LPCTSTR)1);
00062 public:
00063         void            Add(CUploadTransfer* pUpload);
00064         void            Remove(CUploadTransfer* pUpload);
00065 
00066 // List Access
00067 public:
00068         inline POSITION GetIterator() const
00069         {
00070                 return m_pList.GetHeadPosition();
00071         }
00072         
00073         inline CUploadTransfer* GetNext(POSITION& pos) const
00074         {
00075                 return (CUploadTransfer*)m_pList.GetNext( pos );
00076         }
00077         
00078         inline BOOL Check(CUploadTransfer* pUpload) const
00079         {
00080                 return m_pList.Find( pUpload ) != NULL;
00081         }
00082         
00083         inline int GetTransferCount() const
00084         {
00085                 return GetCount( NULL, -2 );
00086         }
00087 
00088         inline int GetTorrentTransferCount() const
00089         {
00090                 return GetTorrentCount( -2 );
00091         }
00092 
00093         inline int GetTorrentUploadCount() const
00094         {
00095                 return GetTorrentCount( -3 );
00096         }
00097         
00098 };
00099 
00100 extern CUploads Uploads;

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