apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pkgAcquireStatus Class Referenceabstract

A monitor object for downloads controlled by the pkgAcquire class. {{{. More...

#include <acquire.h>

Inheritance diagram for pkgAcquireStatus:
[legend]

Classes

struct  ReleaseInfoChange
 

Public Member Functions

virtual void Fetched (unsigned long long Size, unsigned long long ResumePoint)
 Invoked when a local or remote file has been completely fetched. More...
 
virtual bool MediaChange (std::string Media, std::string Drive)=0
 Invoked when the user should be prompted to change the inserted removable media. More...
 
virtual bool ReleaseInfoChanges (metaIndex const *const LastRelease, metaIndex const *const CurrentRelease, std::vector< ReleaseInfoChange > &&Changes)
 ask the user for confirmation of changes to infos about a repository More...
 
virtual void IMSHit (pkgAcquire::ItemDesc &)
 Invoked when an item is confirmed to be up-to-date. More...
 
virtual void Fetch (pkgAcquire::ItemDesc &)
 Invoked when some of an item's data is fetched. More...
 
virtual void Done (pkgAcquire::ItemDesc &)
 Invoked when an item is successfully and completely fetched. More...
 
virtual void Fail (pkgAcquire::ItemDesc &)
 Invoked when the process of fetching an item encounters a fatal error. More...
 
virtual bool Pulse (pkgAcquire *Owner)
 Periodically invoked while the Acquire process is underway. More...
 
virtual void Start ()
 Invoked when the Acquire process starts running. More...
 
virtual void Stop ()
 Invoked when the Acquire process stops running. More...
 
 pkgAcquireStatus ()
 Initialize all counters to 0 and the time to the current time. More...
 
virtual ~pkgAcquireStatus ()
 

Static Public Member Functions

static APT_HIDDEN bool ReleaseInfoChangesAsGlobalErrors (std::vector< ReleaseInfoChange > &&Changes)
 

Public Attributes

bool Update
 If true, the download scheduler should call Pulse() at the next available opportunity. More...
 
bool MorePulses
 If true, extra Pulse() invocations will be performed. More...
 

Protected Attributes

struct timeval Time
 The last time at which this monitor object was updated. More...
 
struct timeval StartTime
 The time at which the download started. More...
 
unsigned long long LastBytes
 The number of bytes fetched as of the previous call to pkgAcquireStatus::Pulse, including local items. More...
 
unsigned long long CurrentCPS
 The current rate of download as of the most recent call to pkgAcquireStatus::Pulse, in bytes per second. More...
 
unsigned long long CurrentBytes
 The number of bytes fetched as of the most recent call to pkgAcquireStatus::Pulse, including local items. More...
 
unsigned long long TotalBytes
 The total number of bytes that need to be fetched. More...
 
unsigned long long FetchedBytes
 The total number of bytes accounted for by items that were successfully fetched. More...
 
unsigned long long ElapsedTime
 The amount of time that has elapsed since the download started. More...
 
unsigned long TotalItems
 The total number of items that need to be fetched. More...
 
unsigned long CurrentItems
 The number of items that have been successfully downloaded. More...
 
double Percent
 The estimated percentage of the download (0-100) More...
 

Private Attributes

void *const d
 dpointer placeholder (for later in case we need it) More...
 

Detailed Description

A monitor object for downloads controlled by the pkgAcquire class. {{{.

Todo:
Why protected members?

Definition at line 695 of file acquire.h.

Constructor & Destructor Documentation

◆ pkgAcquireStatus()

Initialize all counters to 0 and the time to the current time.

Definition at line 1285 of file acquire.cc.

References Start().

◆ ~pkgAcquireStatus()

~pkgAcquireStatus ( )
virtual

Definition at line 1512 of file acquire.cc.

Member Function Documentation

◆ Done()

virtual void Done ( pkgAcquire::ItemDesc &  )
inlinevirtual

Invoked when an item is successfully and completely fetched.

Reimplemented in AcqTextStatus.

Definition at line 835 of file acquire.h.

◆ Fail()

virtual void Fail ( pkgAcquire::ItemDesc &  )
inlinevirtual

Invoked when the process of fetching an item encounters a fatal error.

Reimplemented in AcqTextStatus.

Definition at line 840 of file acquire.h.

Referenced by CheckForBadItemAndFailIt().

◆ Fetch()

virtual void Fetch ( pkgAcquire::ItemDesc &  )
inlinevirtual

Invoked when some of an item's data is fetched.

Reimplemented in AcqTextStatus.

Definition at line 832 of file acquire.h.

◆ Fetched()

void Fetched ( unsigned long long  Size,
unsigned long long  ResumePoint 
)
virtual

Invoked when a local or remote file has been completely fetched.

Parameters
SizeThe size of the file fetched.
ResumePointHow much of the file was already fetched.

Definition at line 1473 of file acquire.cc.

References FetchedBytes.

◆ IMSHit()

virtual void IMSHit ( pkgAcquire::ItemDesc &  )
inlinevirtual

Invoked when an item is confirmed to be up-to-date.

For instance, when an HTTP download is informed that the file on the server was not modified.

Reimplemented in AcqTextStatus.

Definition at line 829 of file acquire.h.

◆ MediaChange()

virtual bool MediaChange ( std::string  Media,
std::string  Drive 
)
pure virtual

Invoked when the user should be prompted to change the inserted removable media.

This method should not return until the user has confirmed to the user interface that the media change is complete.

Parameters
MediaThe name of the media type that should be changed.
DriveThe identifying name of the drive whose media should be changed.
Returns
true if the user confirms the media change, false if it is cancelled.
Todo:
This is a horrible blocking monster; it should be CPSed with prejudice.

Implemented in AcqTextStatus.

◆ Pulse()

bool Pulse ( pkgAcquire Owner)
virtual

Periodically invoked while the Acquire process is underway.

Subclasses should first call pkgAcquireStatus::Pulse(), then update their status output. The download process is blocked while Pulse() is being called.

Returns
false if the user asked to cancel the whole Acquire process.
See also
pkgAcquire::Run

Reimplemented in AcqTextStatus.

Definition at line 1302 of file acquire.cc.

References _config, CurrentBytes, CurrentCPS, CurrentItems, ElapsedTime, GetTimevalFromSteadyClock(), I, pkgAcquire::ItemsBegin(), pkgAcquire::ItemsEnd(), LastBytes, msg, Percent, SizeToStr(), strprintf(), Time, TimeToStr(), TotalBytes, TotalItems, pkgAcquire::Worker(), pkgAcquire::WorkersBegin(), pkgAcquire::WorkerStep(), and FileFd::Write().

Referenced by AcqTextStatus::Pulse(), and pkgAcquire::Run().

◆ ReleaseInfoChanges()

bool ReleaseInfoChanges ( metaIndex const *const  LastRelease,
metaIndex const *const  CurrentRelease,
std::vector< ReleaseInfoChange > &&  Changes 
)
virtual

ask the user for confirmation of changes to infos about a repository

This method should present the user with a choice of accepting the change or not and indicate the user opinion via the return value. If DefaultAction is true it is acceptable to only notify the user about the change, but to accept the change automatically on behalf of the user.

The default implementation will fail if any Change has DefaultAction == false. Regardless of success it will print for each change the message attached to it via GlobalError either as an error (if DefaultAction == false) or as a notice otherwise.

Parameters
LastReleasecan be used to extract further information from the previous Release file
CurrentReleasecan be used to extract further information from the current Release file
Changesis an array of changes alongside explanatory messages which should be presented in some way to the user.
Returns
true if all changes are accepted by user, otherwise or if user can't be asked false

Reimplemented in AcqTextStatus.

Definition at line 1478 of file acquire.cc.

References ReleaseInfoChangesAsGlobalErrors().

Referenced by AcqTextStatus::ReleaseInfoChanges().

◆ ReleaseInfoChangesAsGlobalErrors()

bool ReleaseInfoChangesAsGlobalErrors ( std::vector< ReleaseInfoChange > &&  Changes)
static

Definition at line 1485 of file acquire.cc.

Referenced by ReleaseInfoChanges(), and pkgAcqMetaBase::VerifyVendor().

◆ Start()

void Start ( )
virtual

Invoked when the Acquire process starts running.

Reimplemented in AcqTextStatus.

Definition at line 1436 of file acquire.cc.

References CurrentBytes, CurrentCPS, CurrentItems, ElapsedTime, FetchedBytes, GetTimevalFromSteadyClock(), LastBytes, StartTime, Time, TotalBytes, and TotalItems.

Referenced by pkgAcquireStatus(), pkgAcquire::Run(), and AcqTextStatus::Start().

◆ Stop()

void Stop ( )
virtual

Invoked when the Acquire process stops running.

Reimplemented in AcqTextStatus.

Definition at line 1452 of file acquire.cc.

References CurrentBytes, CurrentCPS, ElapsedTime, FetchedBytes, GetTimevalFromSteadyClock(), LastBytes, and StartTime.

Referenced by pkgAcquire::Run(), and AcqTextStatus::Stop().

Member Data Documentation

◆ CurrentBytes

unsigned long long CurrentBytes
protected

The number of bytes fetched as of the most recent call to pkgAcquireStatus::Pulse, including local items.

Definition at line 721 of file acquire.h.

Referenced by Pulse(), AcqTextStatus::Pulse(), Start(), and Stop().

◆ CurrentCPS

unsigned long long CurrentCPS
protected

The current rate of download as of the most recent call to pkgAcquireStatus::Pulse, in bytes per second.

Definition at line 716 of file acquire.h.

Referenced by Pulse(), AcqTextStatus::Pulse(), Start(), Stop(), and AcqTextStatus::Stop().

◆ CurrentItems

unsigned long CurrentItems
protected

The number of items that have been successfully downloaded.

Definition at line 748 of file acquire.h.

Referenced by Pulse(), and Start().

◆ d

void* const d
private

dpointer placeholder (for later in case we need it)

Definition at line 698 of file acquire.h.

◆ ElapsedTime

unsigned long long ElapsedTime
protected

The amount of time that has elapsed since the download started.

Definition at line 738 of file acquire.h.

Referenced by Pulse(), Start(), Stop(), and AcqTextStatus::Stop().

◆ FetchedBytes

unsigned long long FetchedBytes
protected

The total number of bytes accounted for by items that were successfully fetched.

Definition at line 733 of file acquire.h.

Referenced by Fetched(), Start(), Stop(), and AcqTextStatus::Stop().

◆ LastBytes

unsigned long long LastBytes
protected

The number of bytes fetched as of the previous call to pkgAcquireStatus::Pulse, including local items.

Definition at line 711 of file acquire.h.

Referenced by Pulse(), Start(), and Stop().

◆ MorePulses

bool MorePulses

If true, extra Pulse() invocations will be performed.

With this option set, Pulse() will be called every time that a download item starts downloading, finishes downloading, or terminates with an error.

Definition at line 767 of file acquire.h.

◆ Percent

double Percent
protected

The estimated percentage of the download (0-100)

Definition at line 752 of file acquire.h.

Referenced by Pulse(), and AcqTextStatus::Pulse().

◆ StartTime

struct timeval StartTime
protected

The time at which the download started.

Definition at line 698 of file acquire.h.

Referenced by Start(), and Stop().

◆ Time

struct timeval Time
protected

The last time at which this monitor object was updated.

Definition at line 698 of file acquire.h.

Referenced by Pulse(), and Start().

◆ TotalBytes

unsigned long long TotalBytes
protected

The total number of bytes that need to be fetched.

Warning
This member is inaccurate, as new items might be enqueued while the download is in progress!

Definition at line 728 of file acquire.h.

Referenced by Pulse(), AcqTextStatus::Pulse(), and Start().

◆ TotalItems

unsigned long TotalItems
protected

The total number of items that need to be fetched.

Warning
This member is inaccurate, as new items might be enqueued while the download is in progress!

Definition at line 745 of file acquire.h.

Referenced by Pulse(), and Start().

◆ Update

bool Update

If true, the download scheduler should call Pulse() at the next available opportunity.

Definition at line 759 of file acquire.h.

Referenced by AcqTextStatus::Done(), AcqTextStatus::Fail(), AcqTextStatus::Fetch(), AcqTextStatus::IMSHit(), AcqTextStatus::MediaChange(), AcqTextStatus::Pulse(), and pkgAcquire::Run().


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