1// 2// This file is part of the aMule Project. 3// 4// Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org ) 5// Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net ) 6// 7// Any parts of this program derived from the xMule, lMule or eMule project, 8// or contributed by third-party developers are copyrighted by their 9// respective authors. 10// 11// This program is free software; you can redistribute it and/or modify 12// it under the terms of the GNU General Public License as published by 13// the Free Software Foundation; either version 2 of the License, or 14// (at your option) any later version. 15// 16// This program is distributed in the hope that it will be useful, 17// but WITHOUT ANY WARRANTY; without even the implied warranty of 18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19// GNU General Public License for more details. 20// 21// You should have received a copy of the GNU General Public License 22// along with this program; if not, write to the Free Software 23// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 24// 25 26#ifndef ED2KLINK_H 27#define ED2KLINK_H 28 29 30#include "MD4Hash.h" // Needed for CMD4Hash 31#include "SHAHashSet.h" // Needed for CAICHHash 32 33 34 35class CMemFile; 36 37 38class CED2KLink 39{ 40public: 41 typedef enum { kServerList, kServer , kFile , kInvalid } LinkType; 42 43 static CED2KLink* CreateLinkFromUrl(const wxString& link); 44 45 LinkType GetKind() const; 46 virtual wxString GetLink() const = 0; 47 48 virtual ~CED2KLink(); 49 50protected: 51 CED2KLink( LinkType type ); 52 53private: 54 LinkType m_type; 55}; 56 57 58class CED2KFileLink : public CED2KLink 59{ 60 friend class CED2KLink; 61 CED2KFileLink(const wxString& link); 62 63public: 64 virtual ~CED2KFileLink(); 65 66 virtual wxString GetLink() const; 67 68 wxString GetName() const; 69 uint64 GetSize() const; 70 const CMD4Hash& GetHashKey() const; 71 72 // AICH data 73 bool HasValidAICHHash() const; 74 const CAICHHash& GetAICHHash() const; 75 76 CMemFile* m_hashset; 77 78 /** 79 * Structure used to store sources found in file links. 80 */ 81 struct SED2KLinkSource 82 { 83 //! Hostname or dot-address. 84 wxString addr; 85 //! The source's TCP-port. 86 uint16 port; 87 //! Client hash for encryption 88 wxString hash; 89 //! Client cryptoptions 90 uint8 cryptoptions; 91 }; 92 93 typedef std::deque<SED2KLinkSource> CED2KLinkSourceList; 94 CED2KLinkSourceList m_sources; 95 96private: 97 CED2KFileLink(); // Not defined 98 CED2KFileLink(const CED2KFileLink&); // Not defined 99 CED2KFileLink& operator=(const CED2KFileLink&); // Not defined 100 101 wxString m_name; 102 uint64 m_size; 103 CMD4Hash m_hash; 104 bool m_bAICHHashValid; 105 CAICHHash m_AICHHash; 106}; 107 108 109class CED2KServerLink : public CED2KLink 110{ 111 friend class CED2KLink; 112 CED2KServerLink(const wxString& link); 113 114public: 115 virtual wxString GetLink() const; 116 117 uint32 GetIP() const; 118 uint16 GetPort() const; 119 120private: 121 CED2KServerLink(); // Not defined 122 CED2KServerLink(const CED2KServerLink&); // Not defined 123 CED2KServerLink& operator=(const CED2KServerLink&); // Not defined 124 125 uint32 m_ip; 126 uint16 m_port; 127}; 128 129 130class CED2KServerListLink : public CED2KLink 131{ 132 friend class CED2KLink; 133 CED2KServerListLink(const wxString& link); 134 135public: 136 virtual wxString GetLink() const; 137 138 const wxString& GetAddress() const; 139 140private: 141 CED2KServerListLink(); // Not defined 142 CED2KServerListLink(const CED2KFileLink&); // Not defined 143 CED2KServerListLink& operator=(const CED2KFileLink&); // Not defined 144 145 wxString m_address; 146}; 147 148 149#endif 150// File_checked_for_headers 151