00001 // 00002 // EDClient.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_EDCLIENT_H__4D9C179A_0C83_4A98_8CC0_E82644224697__INCLUDED_) 00023 #define AFX_EDCLIENT_H__4D9C179A_0C83_4A98_8CC0_E82644224697__INCLUDED_ 00024 00025 #pragma once 00026 00027 #include "Transfer.h" 00028 00029 class CEDPacket; 00030 class CDownload; 00031 class CDownloadSource; 00032 class CDownloadTransferED2K; 00033 class CUploadTransferED2K; 00034 00035 00036 class CEDClient : public CTransfer 00037 { 00038 // Construction 00039 public: 00040 CEDClient(); 00041 virtual ~CEDClient(); 00042 00043 // Attributes 00044 public: 00045 CEDClient* m_pEdPrev; 00046 CEDClient* m_pEdNext; 00047 public: 00048 BOOL m_bGUID; 00049 GGUID m_pGUID; 00050 DWORD m_nClientID; 00051 WORD m_nUDP; 00052 SOCKADDR_IN m_pServer; 00053 public: 00054 CString m_sNick; 00055 int m_nVersion; 00056 BOOL m_bEmule; 00057 00058 int m_nEmVersion; 00059 int m_nEmCompatible; 00060 DWORD m_nSoftwareVersion; 00061 public: //Client capabilities 00062 BOOL m_bEmAICH; // Not supported 00063 BOOL m_bEmUnicode; 00064 BOOL m_bEmUDPVersion; 00065 BOOL m_bEmDeflate; 00066 BOOL m_bEmSecureID; // Not supported 00067 BOOL m_bEmSources; 00068 BOOL m_bEmRequest; 00069 BOOL m_bEmComments; 00070 BOOL m_bEmPeerCache; // Not supported 00071 BOOL m_bEmBrowse; // Not over ed2k 00072 BOOL m_bEmMultiPacket; // Not supported 00073 BOOL m_bEmPreview; // Not over ed2k 00074 public: 00075 BOOL m_bLogin; 00076 BOOL m_bUpMD4; 00077 MD4 m_pUpMD4; 00078 QWORD m_nUpSize; 00079 public: 00080 CDownloadTransferED2K* m_pDownload; 00081 CUploadTransferED2K* m_pUpload; 00082 BOOL m_bSeeking; 00083 DWORD m_nRunExCookie; 00084 00085 BOOL m_bOpenChat; 00086 BOOL m_bCommentSent; 00087 00088 // Operations 00089 public: 00090 BOOL ConnectTo(DWORD nClientID, WORD nClientPort, IN_ADDR* pServerAddress, WORD nServerPort, GGUID* pGUID); 00091 BOOL Equals(CEDClient* pClient); 00092 BOOL Connect(); 00093 void Remove(); 00094 void Merge(CEDClient* pClient); 00095 void Send(CEDPacket* pPacket, BOOL bRelease = TRUE); 00096 void OnRunEx(DWORD tNow); 00097 public: 00098 BOOL AttachDownload(CDownloadTransferED2K* pDownload); 00099 void OnDownloadClose(); 00100 void OnUploadClose(); 00101 CString GetSourceURL(); 00102 void WritePartStatus(CEDPacket* pPacket, CDownload* pDownload); 00103 BOOL SeekNewDownload(CDownloadSource* pExcept = NULL); 00104 inline void OpenChat() { m_bOpenChat = TRUE; } 00105 BOOL SendCommentsPacket(int nRating, LPCTSTR pszComments); 00106 protected: 00107 void DeriveSoftwareVersion(); // ID clients using the newer 'SoftwareVersion' tag 00108 void DeriveVersion(); // ID clients using the older method(s) 00109 BOOL OnLoggedIn(); 00110 void DetachDownload(); 00111 void DetachUpload(); 00112 void NotifyDropped(BOOL bError = TRUE); 00113 public: 00114 virtual void AttachTo(CConnection* pConnection); 00115 virtual void Close(); 00116 protected: 00117 virtual BOOL OnRun(); 00118 virtual BOOL OnConnected(); 00119 virtual void OnDropped(BOOL bError); 00120 virtual BOOL OnWrite(); 00121 virtual BOOL OnRead(); 00122 protected: 00123 BOOL OnPacket(CEDPacket* pPacket); 00124 void SendHello(BYTE nType); 00125 BOOL OnHello(CEDPacket* pPacket); 00126 void SendEmuleInfo(BYTE nType); 00127 BOOL OnEmuleInfo(CEDPacket* pPacket); 00128 BOOL OnFileRequest(CEDPacket* pPacket); 00129 BOOL OnFileStatusRequest(CEDPacket* pPacket); 00130 BOOL OnHashsetRequest(CEDPacket* pPacket); 00131 BOOL OnQueueRequest(CEDPacket* pPacket); 00132 BOOL OnSourceRequest(CEDPacket* pPacket); 00133 BOOL OnSourceAnswer(CEDPacket* pPacket); 00134 BOOL OnMessage(CEDPacket* pPacket); 00135 public: 00136 BOOL OnUdpReask(CEDPacket* pPacket); 00137 BOOL OnUdpReaskAck(CEDPacket* pPacket); 00138 BOOL OnUdpQueueFull(CEDPacket* pPacket); 00139 BOOL OnUdpFileNotFound(CEDPacket* pPacket); 00140 00141 inline BOOL IsOnline() const { return m_bConnected && m_bLogin; } 00142 }; 00143 00144 #endif // !defined(AFX_EDCLIENT_H__4D9C179A_0C83_4A98_8CC0_E82644224697__INCLUDED_)