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_UPLOADTRANSFER_H__16B2B6A4_C939_4018_81B6_B1C4460B3CD0__INCLUDED_)
00023 #define AFX_UPLOADTRANSFER_H__16B2B6A4_C939_4018_81B6_B1C4460B3CD0__INCLUDED_
00024
00025 #pragma once
00026
00027 #include "Transfer.h"
00028
00029 class CUploadQueue;
00030 class CUploadFile;
00031 class CTransferFile;
00032 class CLibraryFile;
00033 class CDownload;
00034
00035 #define ULA_SLOTS 16
00036
00037
00038 class CUploadTransfer : public CTransfer
00039 {
00040
00041 public:
00042 CUploadTransfer(PROTOCOLID nProtocol);
00043 virtual ~CUploadTransfer();
00044
00045
00046 public:
00047 PROTOCOLID m_nProtocol;
00048 int m_nState;
00049 CUploadQueue* m_pQueue;
00050 CUploadFile* m_pBaseFile;
00051 CTransferFile* m_pDiskFile;
00052 DWORD m_nBandwidth;
00053 CString m_sNick;
00054 DWORD m_nUserRating;
00055 BOOL m_bClientExtended;
00056 public:
00057 BOOL m_bSHA1;
00058 SHA1 m_pSHA1;
00059 BOOL m_bTiger;
00060 TIGEROOT m_pTiger;
00061 BOOL m_bED2K;
00062 MD4 m_pED2K;
00063 CString m_sFileName;
00064 CString m_sFilePath;
00065 QWORD m_nFileBase;
00066 QWORD m_nFileSize;
00067 BOOL m_bFilePartial;
00068 CString m_sFileTags;
00069 public:
00070 BOOL m_bLive;
00071 DWORD m_nRequests;
00072 QWORD m_nUploaded;
00073 DWORD m_tContent;
00074 QWORD m_nOffset;
00075 QWORD m_nLength;
00076 QWORD m_nPosition;
00077 protected:
00078 BOOL m_bStopTransfer;
00079 DWORD m_tRotateTime;
00080 DWORD m_tAverageTime;
00081 int m_nAveragePos;
00082 DWORD m_nAverageRate[ULA_SLOTS];
00083 DWORD m_tRatingTime;
00084
00085
00086 public:
00087 virtual void Remove(BOOL bMessage = TRUE);
00088 virtual void Close(BOOL bMessage = FALSE);
00089 virtual BOOL Promote();
00090 virtual BOOL OnRename(LPCTSTR pszSource, LPCTSTR pszTarget);
00091 public:
00092 virtual float GetProgress();
00093 virtual DWORD GetAverageSpeed();
00094 virtual DWORD GetMeasuredSpeed();
00095 virtual void SetSpeedLimit(DWORD nLimit);
00096 protected:
00097 virtual BOOL OnRun();
00098 virtual BOOL OnRead();
00099 virtual BOOL OnWrite();
00100 virtual void OnQueueKick() {};
00101 protected:
00102 void LongTermAverage(DWORD tNow);
00103 void RotatingQueue(DWORD tNow);
00104 void CalculateRating(DWORD tNow);
00105 void ClearHashes();
00106 BOOL HashesFromURN(LPCTSTR pszURN);
00107 void ClearRequest();
00108 BOOL RequestComplete(CLibraryFile* pFile);
00109 BOOL RequestPartial(CDownload* pFile);
00110 void StartSending(int nState);
00111 void AllocateBaseFile();
00112 void CloseFile();
00113
00114 };
00115
00116 enum UserRating
00117 {
00118 urNull, urCredit, urSharing, urNew, urNotSharing
00119
00120
00121
00122
00123 };
00124
00125
00126 enum UploadState
00127 {
00128 upsNull, upsReady, upsConnecting,
00129 upsRequest, upsHeaders, upsQueued,
00130 upsUploading, upsResponse,
00131 upsBrowse, upsTigerTree, upsMetadata, upsPreview, upsPreQueue
00132 };
00133
00134 #endif // !defined(AFX_UPLOADTRANSFER_H__16B2B6A4_C939_4018_81B6_B1C4460B3CD0__INCLUDED_)