00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 class CUploadQueue;
00025 class CUploadTransfer;
00026
00027 class CLibraryFile;
00028 class CDownload;
00029
00030
00031 class CUploadQueues
00032 {
00033
00034 public:
00035 CUploadQueues();
00036 virtual ~CUploadQueues();
00037
00038
00039 public:
00040 CCriticalSection m_pSection;
00041 CUploadQueue* m_pTorrentQueue;
00042 CUploadQueue* m_pHistoryQueue;
00043 protected:
00044 CPtrList m_pList;
00045
00046 BOOL m_bDonkeyLimited;
00047
00048
00049 public:
00050 BOOL Enqueue(CUploadTransfer* pUpload, BOOL bForce = FALSE);
00051 BOOL Dequeue(CUploadTransfer* pUpload);
00052 int GetPosition(CUploadTransfer* pUpload, BOOL bStart);
00053 BOOL StealPosition(CUploadTransfer* pTarget, CUploadTransfer* pSource);
00054 public:
00055 CUploadQueue* Create(LPCTSTR pszName = NULL, BOOL bTop = FALSE);
00056 void Delete(CUploadQueue* pQueue);
00057 BOOL Reorder(CUploadQueue* pQueue, CUploadQueue* pBefore);
00058 CUploadQueue* SelectQueue(PROTOCOLID nProtocol, CLibraryFile* pFile);
00059 CUploadQueue* SelectQueue(PROTOCOLID nProtocol, CDownload* pFile);
00060 CUploadQueue* SelectQueue(PROTOCOLID nProtocol, LPCTSTR pszName, QWORD nSize, BOOL bPartial, LPCTSTR pszShareTags = NULL);
00061 public:
00062 int GetTotalBandwidthPoints( BOOL ActiveOnly = FALSE );
00063 int GetQueueCapacity();
00064 int GetQueuedCount();
00065 int GetQueueRemaining();
00066 int GetTransferCount();
00067 BOOL IsTransferAvailable();
00068 DWORD GetMinimumDonkeyBandwidth();
00069 DWORD GetCurrentDonkeyBandwidth();
00070 BOOL CanUpload(PROTOCOLID nProtocol, CLibraryFile *pFile, BOOL bCanQueue = FALSE );
00071 int QueueRank(PROTOCOLID nProtocol, CLibraryFile *pFile );
00072
00073 public:
00074 void Clear();
00075 BOOL Load();
00076 BOOL Save();
00077 void CreateDefault();
00078 void Validate();
00079 protected:
00080 void Serialize(CArchive& ar);
00081
00082
00083 public:
00084 inline POSITION GetIterator() const
00085 {
00086 return m_pList.GetHeadPosition();
00087 }
00088
00089 inline CUploadQueue* GetNext(POSITION& pos) const
00090 {
00091 return (CUploadQueue*)m_pList.GetNext( pos );
00092 }
00093
00094 inline int GetCount() const
00095 {
00096 return m_pList.GetCount();
00097 }
00098
00099 inline BOOL Check(CUploadQueue* pQueue) const
00100 {
00101 if ( pQueue == NULL ) return FALSE;
00102 return m_pList.Find( pQueue ) != NULL;
00103 }
00104
00105 inline BOOL IsDonkeyRatioActive() const
00106 {
00107 return ( m_bDonkeyLimited );
00108 }
00109
00110 };
00111
00112 extern CUploadQueues UploadQueues;