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_UPLOADQUEUE_H__2C8AAF1A_A452_4275_B5D5_06ED2F46BAA8__INCLUDED_)
00023 #define AFX_UPLOADQUEUE_H__2C8AAF1A_A452_4275_B5D5_06ED2F46BAA8__INCLUDED_
00024
00025 #pragma once
00026
00027 class CUploadTransfer;
00028
00029
00030 class CUploadQueue
00031 {
00032
00033 public:
00034 CUploadQueue();
00035 virtual ~CUploadQueue();
00036
00037
00038 protected:
00039 CPtrList m_pActive;
00040 CPtrArray m_pQueued;
00041 public:
00042 int m_nIndex;
00043 CString m_sName;
00044 BOOL m_bEnable;
00045 DWORD m_nProtocols;
00046 QWORD m_nMinSize;
00047 QWORD m_nMaxSize;
00048 BOOL m_bPartial;
00049 CString m_sShareTag;
00050 CString m_sNameMatch;
00051 public:
00052 int m_nCapacity;
00053 int m_nMinTransfers;
00054 int m_nMaxTransfers;
00055 int m_nBandwidthPoints;
00056 BOOL m_bRotate;
00057 DWORD m_nRotateTime;
00058 DWORD m_nRotateChunk;
00059 BOOL m_bRewardUploaders;
00060 public:
00061 BOOL m_bExpanded;
00062 BOOL m_bSelected;
00063 DWORD m_nMeasured;
00064
00065
00066 public:
00067 CString GetCriteriaString() const;
00068 void Serialize(CArchive& ar, int nVersion);
00069 public:
00070 BOOL CanAccept(PROTOCOLID nProtocol, LPCTSTR pszName, QWORD nSize, BOOL bPartial, LPCTSTR pszShareTags = NULL) const;
00071 BOOL Enqueue(CUploadTransfer* pUpload, BOOL bForce = FALSE, BOOL bStart = FALSE);
00072 BOOL Dequeue(CUploadTransfer* pUpload);
00073 int GetPosition(CUploadTransfer* pUpload, BOOL bStart);
00074 BOOL StealPosition(CUploadTransfer* pTarget, CUploadTransfer* pSource);
00075 BOOL Start(CUploadTransfer* pUpload, BOOL bPeek = FALSE);
00076 public:
00077 int GetBandwidthPoints(int nTransfers = -1) const;
00078 DWORD GetBandwidthLimit(int nTransfers = -1) const;
00079 DWORD GetAvailableBandwidth() const;
00080 DWORD GetPredictedBandwidth() const;
00081 void SpreadBandwidth();
00082 void RescaleBandwidth();
00083 protected:
00084 void StartImpl(CUploadTransfer* pUpload);
00085
00086
00087 public:
00088 inline int GetTransferCount(BOOL bMax = FALSE) const
00089 {
00090 if ( ! bMax ) return m_pActive.GetCount();
00091 int nActive = m_pActive.GetCount();
00092 return max( nActive, m_nMinTransfers );
00093 }
00094
00095 inline int GetQueueCapacity() const
00096 {
00097 return m_nCapacity;
00098 }
00099
00100 inline int GetQueuedCount() const
00101 {
00102 return m_pQueued.GetSize();
00103 }
00104
00105 inline int GetQueueRemaining() const
00106 {
00107 return GetQueueCapacity() - GetQueuedCount();
00108 }
00109
00110 inline BOOL IsActive(CUploadTransfer* pUpload) const
00111 {
00112 ASSERT( pUpload != NULL );
00113 return ( m_pActive.Find( pUpload ) != NULL );
00114 }
00115
00116 inline DWORD GetMeasuredSpeed() const
00117 {
00118 return m_nMeasured;
00119 }
00120
00121 friend class CUploadsCtrl;
00122 friend class CUploadsWnd;
00123 };
00124
00125 #endif // !defined(AFX_UPLOADQUEUE_H__2C8AAF1A_A452_4275_B5D5_06ED2F46BAA8__INCLUDED_)