ED2KFile Class Reference

ED2KFile class represents a file as is known to ED2K network. More...

#include <ed2kfile.h>

List of all members.


Public Types

enum  Flags { FL_COMPLETE = 0x01, FL_USECOMPLETEINFO = 0x02 }
 Flags usable at ED2KFile constructor arguments. More...
enum  Rating {
  FR_NORATING = 0x00, FR_INVALID, FR_POOR, FR_GOOD,
  FR_FAIR, FR_EXCELLENT
}
 File ratings. More...

Public Member Functions

 ED2KFile (Hash< ED2KHash > h, const std::string &name, uint32_t size, FileType type, uint8_t flags)
 Construct using hash, name and type.
 ED2KFile (Hash< ED2KHash > h, const std::string &name, uint32_t size, const std::string &type, uint8_t flags)
 Construct using hash, name and type.
 ED2KFile (Hash< ED2KHash > h, const std::string &name, uint32_t size, uint32_t id, uint16_t port)
 Construct an ED2KFile object which has bare minimum of information, plus client id and client port.
Accessors
Hash< ED2KHash > getHash () const
std::string getName () const
uint32_t getSize () const
FileType getHNType () const
std::string getStrType () const
uint32_t getId () const
uint16_t getPort () const

Static Public Member Functions

static std::string ratingToString (const Rating &r)
 Converts rating value to rating string.
Static utility functions for file type conversions
static std::string HNType2ED2KType (FileType type)
 Converts HydraNode filetype into ED2K filetype.
static FileType ED2KType2HNType (const std::string &type)
 Converts ED2K file type to HydraNode file type.

Private Attributes

const Hash< ED2KHash > m_hash
 File hash.
const std::string m_name
 File name.
uint32_t m_size
 File size.
FileType m_hnType
 File type (HN-compatible).
std::string m_ed2kType
 File type (ed2k-compatible).
uint8_t m_flags
 Various useful flags.
uint32_t m_id
 ClientId sharing this file.
uint16_t m_port
 ClientPort of the client.

Friends

std::ostream & operator<< (std::ostream &o, const ED2KFile &f)
 Output operator to streams for usage in ed2k protocol.
boost::shared_ptr< ED2KFilemakeED2KFile (SharedFile *sf, MetaData *md, HashSetBase *hs, bool useCompleteInfo)
 Convenience method for constructing complex ED2KFile object from pre-given data.

Detailed Description

ED2KFile class represents a file as is known to ED2K network.

ED2K network puts some restrictions on the files it can support - namely, the file must have a valid ED2KHash present. Additional fields ED2KFile is required to include are size, type, and completeness.

Note that file size is 32-bit value in eDonkey2000 network - max ED2KFile size is 2^32 bytes. While HydraNode supports up to 2^64 byte files internally, eDonkey2000 network doesn't - thus sharing files with size > 4gb is not possible on ed2k.

File type is used in eDonkey2000 network as strings (refer to opcodes.h for the actual strings definitions), and not all file types that HydraNode supports are also supported by eDonkey2000 network. In any case, we provide convenience accessors and constructors for using HydraNode FileType enum values here, and handle the details internally as needed.

Definition at line 46 of file ed2kfile.h.


Member Enumeration Documentation

enum ED2KFile::Flags
 

Flags usable at ED2KFile constructor arguments.

Enumeration values:
FL_COMPLETE  If this file is complete.
FL_USECOMPLETEINFO  Whether to send complete info.

Definition at line 107 of file ed2kfile.h.

enum ED2KFile::Rating
 

File ratings.

Enumeration values:
FR_NORATING 
FR_INVALID 
FR_POOR 
FR_GOOD 
FR_FAIR 
FR_EXCELLENT 

Definition at line 113 of file ed2kfile.h.


Constructor & Destructor Documentation

ED2KFile::ED2KFile Hash< ED2KHash >  h,
const std::string &  name,
uint32_t  size,
FileType  type,
uint8_t  flags
 

Construct using hash, name and type.

Parameters:
h ED2KHash of the file
name File name (excluding path)
type Type of file, as specified in hn/metadata.h
flags Bitfield of Flags

Definition at line 32 of file ed2kfile.cpp.

References HNType2ED2KType(), m_ed2kType, and m_hnType.

ED2KFile::ED2KFile Hash< ED2KHash >  h,
const std::string &  name,
uint32_t  size,
const std::string &  type,
uint8_t  flags
 

Construct using hash, name and type.

Parameters:
h ED2KHash of the file
name File name (excluding path)
type Type of file, as used in ED2K network (strings)
flags Bitfield of Flags

Definition at line 42 of file ed2kfile.cpp.

References ED2KType2HNType(), and m_hnType.

ED2KFile::ED2KFile Hash< ED2KHash >  h,
const std::string &  name,
uint32_t  size,
uint32_t  id,
uint16_t  port
 

Construct an ED2KFile object which has bare minimum of information, plus client id and client port.

This omit type and flags data, however adds clientid/port, which comes in handy when handling search results for example. The type and flags may be added later using accessor methods.

Parameters:
h ED2KHash of the file
name File name
size File size
id ClientId of the client sharing this file
port ClientPort of the client sharing this file

Definition at line 49 of file ed2kfile.cpp.


Member Function Documentation

Hash<ED2KHash> ED2KFile::getHash  )  const [inline]
 

Definition at line 94 of file ed2kfile.h.

References m_hash.

std::string ED2KFile::getName  )  const [inline]
 

Definition at line 95 of file ed2kfile.h.

References m_name.

uint32_t ED2KFile::getSize  )  const [inline]
 

Definition at line 96 of file ed2kfile.h.

References m_size.

FileType ED2KFile::getHNType  )  const [inline]
 

Definition at line 97 of file ed2kfile.h.

References m_hnType.

std::string ED2KFile::getStrType  )  const [inline]
 

Definition at line 98 of file ed2kfile.h.

References m_ed2kType.

uint32_t ED2KFile::getId  )  const [inline]
 

Definition at line 99 of file ed2kfile.h.

References m_id.

uint16_t ED2KFile::getPort  )  const [inline]
 

Definition at line 100 of file ed2kfile.h.

References m_port.

std::string ED2KFile::ratingToString const Rating r  )  [static]
 

Converts rating value to rating string.

Definition at line 130 of file ed2kfile.cpp.

References FR_EXCELLENT, FR_FAIR, FR_GOOD, FR_INVALID, FR_NORATING, and FR_POOR.

Referenced by Client::onPacket().

std::string ED2KFile::HNType2ED2KType FileType  type  )  [static]
 

Converts HydraNode filetype into ED2K filetype.

Definition at line 83 of file ed2kfile.cpp.

References FT_ED2K_AUDIO, FT_ED2K_DOCUMENT, FT_ED2K_IMAGE, FT_ED2K_PROGRAM, and FT_ED2K_VIDEO.

Referenced by ED2KFile().

FileType ED2KFile::ED2KType2HNType const std::string &  type  )  [static]
 

Converts ED2K file type to HydraNode file type.

Definition at line 95 of file ed2kfile.cpp.

References FT_ED2K_AUDIO, FT_ED2K_DOCUMENT, FT_ED2K_IMAGE, FT_ED2K_PROGRAM, and FT_ED2K_VIDEO.

Referenced by ED2KFile().


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  o,
const ED2KFile f
[friend]
 

Output operator to streams for usage in ed2k protocol.

Definition at line 55 of file ed2kfile.cpp.

boost::shared_ptr<ED2KFile> makeED2KFile SharedFile *  sf,
MetaData *  md,
HashSetBase *  hs,
bool  useCompleteInfo
[friend]
 

Convenience method for constructing complex ED2KFile object from pre-given data.

Parameters:
sf SharedFile to refer to
md MetaData corresponding to the SharedFile
hs ED2KHashSet corresponding to this file
useCompletEInfo Whether to include "complete" information
Returns:
Newly allocated ED2KFile object

Definition at line 112 of file ed2kfile.cpp.


Member Data Documentation

const Hash<ED2KHash> ED2KFile::m_hash [private]
 

File hash.

Definition at line 133 of file ed2kfile.h.

Referenced by getHash().

const std::string ED2KFile::m_name [private]
 

File name.

Definition at line 134 of file ed2kfile.h.

Referenced by getName().

uint32_t ED2KFile::m_size [private]
 

File size.

Definition at line 135 of file ed2kfile.h.

Referenced by getSize().

FileType ED2KFile::m_hnType [private]
 

File type (HN-compatible).

Definition at line 136 of file ed2kfile.h.

Referenced by ED2KFile(), and getHNType().

std::string ED2KFile::m_ed2kType [private]
 

File type (ed2k-compatible).

Definition at line 137 of file ed2kfile.h.

Referenced by ED2KFile(), and getStrType().

uint8_t ED2KFile::m_flags [private]
 

Various useful flags.

Definition at line 138 of file ed2kfile.h.

uint32_t ED2KFile::m_id [private]
 

ClientId sharing this file.

Definition at line 139 of file ed2kfile.h.

Referenced by getId().

uint16_t ED2KFile::m_port [private]
 

ClientPort of the client.

Definition at line 140 of file ed2kfile.h.

Referenced by getPort().


The documentation for this class was generated from the following files: