1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//
// This file is part of the aMule Project.
//
// Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
// Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net )
//
// Any parts of this program derived from the xMule, lMule or eMule project,
// or contributed by third-party developers are copyrighted by their
// respective authors.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
//

#ifndef ED2KLINK_H
#define ED2KLINK_H


#include "MD4Hash.h"		// Needed for CMD4Hash
#include "SHAHashSet.h"		// Needed for CAICHHash



class CMemFile;


class CED2KLink
{
public:
	typedef enum { kServerList, kServer , kFile , kInvalid } LinkType;

	static CED2KLink* CreateLinkFromUrl(const wxString& link);

	LinkType GetKind() const;
	virtual wxString GetLink() const = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class

	virtual	~CED2KLink();<--- Virtual destructor in base class

protected:
	CED2KLink( LinkType type );

private:
	LinkType	m_type;
};


class CED2KFileLink : public CED2KLink
{
	friend class CED2KLink;
	CED2KFileLink(const wxString& link);

public:
	virtual ~CED2KFileLink();<--- Destructor in derived class

	virtual wxString GetLink() const;<--- Function in derived class

	wxString GetName() const;
	uint64 GetSize() const;
	const CMD4Hash& GetHashKey() const;

	// AICH data
	bool	HasValidAICHHash() const;
	const CAICHHash&	GetAICHHash() const;

	CMemFile* m_hashset;

	/**
	 * Structure used to store sources found in file links.
	 */
	struct SED2KLinkSource
	{
		//! Hostname or dot-address.
		wxString addr;
		//! The source's TCP-port.
		uint16 port;
		//! Client hash for encryption
		wxString hash;
		//! Client cryptoptions
		uint8 cryptoptions;
	};

	typedef std::deque<SED2KLinkSource> CED2KLinkSourceList;
	CED2KLinkSourceList m_sources;

private:
	CED2KFileLink(); // Not defined
	CED2KFileLink(const CED2KFileLink&); // Not defined
	CED2KFileLink& operator=(const CED2KFileLink&); // Not defined

	wxString	m_name;
	uint64		m_size;
	CMD4Hash	m_hash;
	bool		m_bAICHHashValid;
	CAICHHash	m_AICHHash;
};


class CED2KServerLink : public CED2KLink
{
	friend class CED2KLink;
	CED2KServerLink(const wxString& link);

public:
	virtual wxString GetLink() const;<--- Function in derived class

	uint32 GetIP() const;
	uint16 GetPort() const;

private:
	CED2KServerLink(); // Not defined
	CED2KServerLink(const CED2KServerLink&); // Not defined
	CED2KServerLink& operator=(const CED2KServerLink&); // Not defined

	uint32 m_ip;
	uint16 m_port;
};


class CED2KServerListLink : public CED2KLink
{
	friend class CED2KLink;
	CED2KServerListLink(const wxString& link);

public:
	virtual wxString GetLink() const;<--- Function in derived class

	const wxString& GetAddress() const;

private:
	CED2KServerListLink(); // Not defined
	CED2KServerListLink(const CED2KFileLink&); // Not defined
	CED2KServerListLink& operator=(const CED2KFileLink&); // Not defined

	wxString m_address;
};


#endif
// File_checked_for_headers