Naanou.ResourceExchange
Class Source.Manifest

Wraps up info about what part of a resource a particular source has

Field Summary
int completeness
         Percentage host has of file
string discoveryMethod
long fileSize
string[] likelyAltSources
bool preexisting
bool queriedOk
Naanou.ResourceExchange.ByteRange[] ranges
string resource
Naanou.ResourceExchange.Source source
long totalSize
double transferSpeed
         Last recorded bytes/s being read and written to disk

Constructor Summary
Source.Manifest(Naanou.ResourceExchange.Source source, string resource, Naanou.ResourceExchange.ByteRange[] ranges, string discoveryMethod)
         Constructor

Property Summary
double Completeness
         Completeness (percentage), or System.Double.NaN if unavailable, that this host has of the file
string DiscoveryMethod
long FileLength
         Gets the file length
bool PreExisting
         Was this source from preexisting knowledge
int RangeCount
         Gets the number of ranges this source has
Naanou.ResourceExchange.ByteRange[] Ranges
         Gets the byte ranges that this source has (a copy)
string Resource
         Gets or sets the resource this source is for
Naanou.ResourceExchange.Source Source
         Gets the source this manifest belongs to
double TransferSpeed
         Gets the speed of the transfer

Method Summary
Naanou.ResourceExchange.Block Download(Naanou.ResourceExchange.Downloader downloader, Naanou.ResourceExchange.ResourceAvailRange range, Naanou.ResourceExchange.WorkStatusHandler statusCallback)
         Download a range block from source. Closes off block when done, or deletes it if there was a problem.
string[] GetLikelyAlternateSources(int byteRangeIndex)
         Gets a list of likely alternate sources for a byte range this source has
bool HasRange(Naanou.ResourceExchange.ByteRange range)
         Has manifest got this range?
void PaintRange(Naanou.ResourceExchange.ByteRange range, long totalSize, System.Drawing.Graphics g, System.Drawing.Rectangle rect, System.Drawing.Brush brush)
         Paints status
void PaintStatus(System.Drawing.Graphics g, System.Drawing.Rectangle rect)
         Paints status
void Query()
         Attempts to identify how much of the resource this source has [blocking]
Naanou.ResourceExchange.ByteRange RangeAt(int index)
         Gets the range at the specified index

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString


Field Detail

completeness

private int completeness

Percentage host has of file


discoveryMethod

private string discoveryMethod


fileSize

private long fileSize


likelyAltSources

private string[] likelyAltSources


preexisting

private bool preexisting


queriedOk

private bool queriedOk


ranges

private Naanou.ResourceExchange.ByteRange[] ranges


resource

private string resource


source

private Naanou.ResourceExchange.Source source


totalSize

private long totalSize


transferSpeed

private double transferSpeed

Last recorded bytes/s being read and written to disk

Constructor Detail

Source.Manifest

internal Source.Manifest(Naanou.ResourceExchange.Source source,
                         string resource,
                         Naanou.ResourceExchange.ByteRange[] ranges,
                         string discoveryMethod)

Constructor

Parameters:
resource - Resource hash
ranges - Ranges source has
discoveryMethod - Discovery method
source - Source
Property Detail

Completeness

public double Completeness

Completeness (percentage), or System.Double.NaN if unavailable, that this host has of the file


DiscoveryMethod

public string DiscoveryMethod


FileLength

public long FileLength

Gets the file length


PreExisting

public bool PreExisting

Was this source from preexisting knowledge


RangeCount

public int RangeCount

Gets the number of ranges this source has


Ranges

public Naanou.ResourceExchange.ByteRange[] Ranges

Gets the byte ranges that this source has (a copy)

If the record is preexisting, a query does not need to be done, although ranges on server may be different than what we know. Running a query in this case will update ranges. If a record is not preexisting (i.e. all we know about it is its url), a Query must be run before using this property.


Resource

public string Resource

Gets or sets the resource this source is for


Source

public Naanou.ResourceExchange.Source Source

Gets the source this manifest belongs to


TransferSpeed

public double TransferSpeed

Gets the speed of the transfer

Method Detail

Download

internal Naanou.ResourceExchange.Block Download(Naanou.ResourceExchange.Downloader downloader,
                                                Naanou.ResourceExchange.ResourceAvailRange range,
                                                Naanou.ResourceExchange.WorkStatusHandler statusCallback)

Download a range block from source. Closes off block when done, or deletes it if there was a problem.

Parameters:
downloader - Downloader
range - Range to get
statusCallback - Status callback (can be null)
Returns:
Block that contains range

GetLikelyAlternateSources

public string[] GetLikelyAlternateSources(int byteRangeIndex)

Gets a list of likely alternate sources for a byte range this source has

Parameters:
byteRangeIndex - Index
Returns:
Likely sources, or null

HasRange

public bool HasRange(Naanou.ResourceExchange.ByteRange range)

Has manifest got this range?

Parameters:
range -
Returns:

PaintRange

public void PaintRange(Naanou.ResourceExchange.ByteRange range,
                       long totalSize,
                       System.Drawing.Graphics g,
                       System.Drawing.Rectangle rect,
                       System.Drawing.Brush brush)

Paints status

Parameters:
range -
totalSize -
g -
rect -
brush -

PaintStatus

public void PaintStatus(System.Drawing.Graphics g,
                        System.Drawing.Rectangle rect)

Paints status

Parameters:
g -
rect -

Query

public void Query()

Attempts to identify how much of the resource this source has [blocking]


RangeAt

public Naanou.ResourceExchange.ByteRange RangeAt(int index)

Gets the range at the specified index

Parameters:
index -
Returns: