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

UploadTransfer.h

Go to the documentation of this file.
00001 //
00002 // UploadTransfer.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_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 // Construction
00041 public:
00042         CUploadTransfer(PROTOCOLID nProtocol);
00043         virtual ~CUploadTransfer();
00044 
00045 // Attributes
00046 public:
00047         PROTOCOLID              m_nProtocol;            // Protocol ID
00048         int                             m_nState;                       // Common state code
00049         CUploadQueue*   m_pQueue;                       // Queue reference
00050         CUploadFile*    m_pBaseFile;            // Reference file
00051         CTransferFile*  m_pDiskFile;            // Disk file
00052         DWORD                   m_nBandwidth;           // Bandwidth
00053         CString                 m_sNick;                        // User Nick
00054         DWORD                   m_nUserRating;          // Has the downloader uploaded anything?
00055         BOOL                    m_bClientExtended;      // Does the user support extended (G2) functions? (In practice, this means can we use G2 chat, browse, etc...)
00056 public:
00057         BOOL                    m_bSHA1;                        // Hash of requested file
00058         SHA1                    m_pSHA1;                        // ..
00059         BOOL                    m_bTiger;                       // ..
00060         TIGEROOT                m_pTiger;                       // ..
00061         BOOL                    m_bED2K;                        // ..
00062         MD4                             m_pED2K;                        // ..
00063         CString                 m_sFileName;            // Name of requested file
00064         CString                 m_sFilePath;            // Path of requested file
00065         QWORD                   m_nFileBase;            // Base offset in requested file
00066         QWORD                   m_nFileSize;            // Size of requested file
00067         BOOL                    m_bFilePartial;         // Partial file flag
00068         CString                 m_sFileTags;            // File sharing tags
00069 public:
00070         BOOL                    m_bLive;                        // Live connection tag
00071         DWORD                   m_nRequests;            // Request count
00072         QWORD                   m_nUploaded;            // Bytes uploaded
00073         DWORD                   m_tContent;                     // Send start timestamp
00074         QWORD                   m_nOffset;                      // Fragment offset
00075         QWORD                   m_nLength;                      // Fragment length
00076         QWORD                   m_nPosition;            // Send position
00077 protected:
00078         BOOL                    m_bStopTransfer;        // Should this transfer stop? (to allow queue rotation, etc)
00079         DWORD                   m_tRotateTime;
00080         DWORD                   m_tAverageTime;
00081         int                             m_nAveragePos;
00082         DWORD                   m_nAverageRate[ULA_SLOTS];
00083         DWORD                   m_tRatingTime;          //      When rating was last calculated
00084         
00085 // Operations
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         // 1 = Uploaded more to us than we have to them (We 'owe' them upload)
00120         // 2 = Known Sharer (We've given them more than they have given us)
00121         // 3 = New user ()
00122         // 4 = Known user who has not uploaded (May simply not have anything we want)
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_)

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