apt @VERSION@
|
Represents the process by which a pkgAcquire object should {{{ retrieve a file or a collection of files. More...
#include <acquire-item.h>
Public Types | |
enum | ItemState { StatIdle, StatFetching, StatDone, StatError, StatAuthError, StatTransientNetworkError } |
The current status of this item. More... | |
Public Member Functions | |
virtual void | Failed (string Message, pkgAcquire::MethodConfig *Cnf) |
Invoked by the acquire worker when the object couldn't be fetched. | |
virtual void | Done (string Message, unsigned long Size, string Hash, pkgAcquire::MethodConfig *Cnf) |
Invoked by the acquire worker when the object was fetched successfully. | |
virtual void | Start (string Message, unsigned long Size) |
Invoked when the worker starts to fetch this object. | |
virtual string | Custom600Headers () |
Custom headers to be sent to the fetch process. | |
virtual string | DescURI ()=0 |
A "descriptive" URI-like string. | |
virtual string | ShortDesc () |
Short item description. | |
virtual void | Finished () |
Invoked by the worker when the download is completely done. | |
virtual string | HashSum () |
HashSum. | |
pkgAcquire * | GetOwner () |
virtual bool | IsTrusted () |
void | ReportMirrorFailure (string FailCode) |
Report mirror problem. | |
Item (pkgAcquire *Owner) | |
Initialize an item. | |
virtual | ~Item () |
Remove this item from its owner's queue by invoking pkgAcquire::Remove. | |
Public Attributes | |
enum pkgAcquire::Item::ItemState | Status |
string | ErrorText |
Contains a textual description of the error encountered if #Status is StatError or StatAuthError. | |
unsigned long long | FileSize |
The size of the object to fetch. | |
unsigned long long | PartialSize |
How much of the object was already fetched. | |
const char * | Mode |
If not NULL, contains the name of a subprocess that is operating on this object (for instance, "gzip" or "gpgv"). | |
unsigned long | ID |
A client-supplied unique identifier. | |
bool | Complete |
If true, the entire object has been successfully fetched. | |
bool | Local |
If true, the URI of this object is "local". | |
string | UsedMirror |
unsigned int | QueueCounter |
The number of fetch queues into which this item has been inserted. | |
string | DestFile |
The name of the file into which the retrieved object will be written. | |
Protected Member Functions | |
void | QueueURI (ItemDesc &Item) |
Insert this item into its owner's queue. | |
void | Dequeue () |
Remove this item from its owner's queue. | |
void | Rename (string From, string To) |
Rename a file without modifying its timestamp. | |
Protected Attributes | |
pkgAcquire * | Owner |
The acquire object with which this item is associated. |
Represents the process by which a pkgAcquire object should {{{ retrieve a file or a collection of files.
By convention, Item subclasses should insert themselves into the acquire queue when they are created by calling QueueURI(), and remove themselves by calling Dequeue() when either Done() or Failed() is invoked. Item objects are also responsible for notifying the download progress indicator (accessible via Owner->Log) of their status.
enum ItemState |
The current status of this item.
Item | ( | pkgAcquire * | Owner | ) |
Initialize an item.
Adds the item to the list of items known to the acquire process, but does not place it into any fetch queues (you must manually invoke QueueURI() to do so).
Initializes all fields of the item other than Owner to 0, false, or the empty string.
Owner | The new owner of this item. |
References pkgAcquire::Add(), and StatIdle.
virtual string Custom600Headers | ( | ) | [inline, virtual] |
Custom headers to be sent to the fetch process.
Reimplemented in pkgAcqSubIndex, pkgAcqDiffIndex, pkgAcqIndex, pkgAcqIndexTrans, pkgAcqMetaSig, pkgAcqMetaIndex, pkgAcqMetaClearSig, and pkgAcqFile.
Referenced by pkgAcquire::Worker::QueueItem().
virtual string DescURI | ( | ) | [pure virtual] |
A "descriptive" URI-like string.
Implemented in pkgAcqSubIndex, pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndex, pkgAcqMetaSig, pkgAcqMetaIndex, pkgAcqArchive, and pkgAcqFile.
Referenced by pkgAcquire::Worker::RunMessages(), and ShortDesc().
virtual void Done | ( | string | Message, |
unsigned long | Size, | ||
string | Hash, | ||
pkgAcquire::MethodConfig * | Cnf | ||
) | [virtual] |
Invoked by the acquire worker when the object was fetched successfully.
Note that the object might not have been written to DestFile; check for the presence of an Alt-Filename entry in Message to find the file to which it was really written.
Done is often used to switch from one stage of the processing to the next (e.g. fetching, unpacking, copying). It is one branch of the continuation of the fetch process.
Message | Data from the acquire method. Use LookupTag() to parse it. |
Size | The size of the object that was fetched. |
Hash | The HashSum of the object that was fetched. |
Cnf | The method via which the object was fetched. |
Reimplemented in pkgAcqSubIndex, pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndex, pkgAcqMetaSig, pkgAcqMetaIndex, pkgAcqArchive, and pkgAcqFile.
Referenced by pkgAcquire::Worker::RunMessages().
virtual void Failed | ( | string | Message, |
pkgAcquire::MethodConfig * | Cnf | ||
) | [virtual] |
Invoked by the acquire worker when the object couldn't be fetched.
This is a branch of the continuation of the fetch process.
Message | An RFC822-formatted message from the acquire method describing what went wrong. Use LookupTag() to parse it. |
Cnf | The method via which the worker tried to fetch this object. |
Reimplemented in pkgAcqSubIndex, pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndex, pkgAcqIndexTrans, pkgAcqMetaSig, pkgAcqMetaIndex, pkgAcqMetaClearSig, pkgAcqArchive, and pkgAcqFile.
Referenced by pkgAcquire::Worker::RunMessages().
pkgAcquire* GetOwner | ( | ) | [inline] |
References Owner.
Referenced by pkgAcquire::Worker::RunMessages().
virtual string HashSum | ( | ) | [inline, virtual] |
HashSum.
Reimplemented in pkgAcqIndex, pkgAcqArchive, and pkgAcqFile.
Referenced by pkgAcquire::Worker::RunMessages().
virtual bool IsTrusted | ( | ) | [inline, virtual] |
Reimplemented in pkgAcqArchive.
void QueueURI | ( | ItemDesc & | Item | ) | [inline, protected] |
Insert this item into its owner's queue.
References pkgAcquire::Enqueue(), and Owner.
Referenced by pkgAcqDiffIndex::pkgAcqDiffIndex(), pkgAcqFile::pkgAcqFile(), pkgAcqMetaIndex::pkgAcqMetaIndex(), pkgAcqMetaSig::pkgAcqMetaSig(), pkgAcqSubIndex::pkgAcqSubIndex(), pkgAcqArchive::QueueNext(), and pkgAcqMetaIndex::RetrievalDone().
void Rename | ( | string | From, |
string | To | ||
) | [protected] |
Rename a file without modifying its timestamp.
Many item methods call this as their final action.
From | The file to be renamed. |
To | The new name of #From. If #To exists it will be overwritten. |
Referenced by pkgAcqMetaIndex::AuthDone(), and pkgAcqMetaSig::pkgAcqMetaSig().
void ReportMirrorFailure | ( | string | FailCode | ) |
Report mirror problem.
This allows reporting mirror failures back to a centralized server. The apt-report-mirror-failure script is called for this
FailCode | A short failure string that is send |
virtual string ShortDesc | ( | ) | [inline, virtual] |
Short item description.
Reimplemented in pkgAcqArchive.
References DescURI().
Referenced by pkgAcqIndex::Custom600Headers(), pkgAcqDiffIndex::pkgAcqDiffIndex(), pkgAcqFile::pkgAcqFile(), pkgAcqIndexDiffs::pkgAcqIndexDiffs(), pkgAcqMetaIndex::pkgAcqMetaIndex(), pkgAcqMetaSig::pkgAcqMetaSig(), and pkgAcqSubIndex::pkgAcqSubIndex().
virtual void Start | ( | string | Message, |
unsigned long | Size | ||
) | [virtual] |
Invoked when the worker starts to fetch this object.
Message | RFC822-formatted data from the worker process. Use LookupTag() to parse it. |
Size | The size of the object being fetched. |
Referenced by pkgAcquire::Worker::RunMessages().
bool Complete |
If true, the entire object has been successfully fetched.
Subclasses should set this to true when appropriate.
Referenced by pkgAcquire::Enqueue(), pkgAcqArchive::Finished(), pkgAcqDiffIndex::ParseDiffIndex(), pkgAcqArchive::QueueNext(), and pkgAcqMetaIndex::RetrievalDone().
unsigned long ID |
A client-supplied unique identifier.
This field is initalized to 0; it is meant to be filled in by clients that wish to use it to uniquely identify items.
bool Local |
If true, the URI of this object is "local".
The only effect of this field is to exclude the object from the download progress indicator's overall statistics.
Referenced by pkgAcquire::Enqueue(), pkgAcqArchive::QueueNext(), and pkgAcqMetaIndex::RetrievalDone().
unsigned int QueueCounter |
The number of fetch queues into which this item has been inserted.
There is one queue for each source from which an item could be downloaded.
Referenced by pkgAcquire::Queue::Dequeue(), pkgAcquire::Queue::Enqueue(), and pkgAcquire::Queue::ItemDone().